Skip to content

Commit 29f515b

Browse files
committed
llvm 20
1 parent 0d7bd47 commit 29f515b

File tree

14 files changed

+104
-89
lines changed

14 files changed

+104
-89
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-exceptions")
6565
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti")
6666
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
6767
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra")
68-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-variable -Wno-unused-parameter -Wno-comment -Wno-unused-function -Wno-deprecated-this-capture")
68+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-variable -Wno-unused-parameter -Wno-comment -Wno-unused-function -Wno-deprecated-this-capture -Wno-dangling-assignment-gsl")
6969
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-implicit-int-float-conversion -Wno-reserved-macro-identifier -Wno-c++98-compat -Wno-c++98-compat-pedantic -Wno-old-style-cast -Wno-sign-conversion -Wshadow-field-in-constructor -Wno-language-extension-token -Wno-deprecated-declarations -Wno-invalid-offsetof")
7070

7171
set(CMAKE_INSTALL_RPATH "$ORIGIN/../lib")

build.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ def main():
231231
"--depth",
232232
"1",
233233
"-b",
234-
"release/19.x",
234+
"release/20.x",
235235
)
236236

237237
if debug_llvm and not exists(llvm_install_debug_dir) and args.llvm_dir == "":

lib/backend/src/BackEnd.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ limitations under the License.
4848
#include "llvm/Support/raw_ostream.h"
4949
#include "llvm/Target/TargetMachine.h"
5050
#include "llvm/TargetParser/Host.h"
51-
#include "llvm/Transforms/Instrumentation.h"
5251
#include "llvm/Transforms/Instrumentation/SanitizerCoverage.h"
5352
#include "llvm/Transforms/Utils/Mem2Reg.h"
5453
#include "mlir/Conversion/FuncToLLVM/ConvertFuncToLLVMPass.h"
@@ -183,8 +182,8 @@ static void runOptimizer(
183182
}
184183
else
185184
{
186-
ModulePassManager MPM =
187-
PB.buildO0DefaultPipeline(OptimizationLevel::O0, true);
185+
ModulePassManager MPM = PB.buildO0DefaultPipeline(
186+
OptimizationLevel::O0, ThinOrFullLTOPhase::None);
188187
if (targetIsWindows)
189188
MPM.addPass(createModuleToFunctionPassAdaptor(AddWindowsDLLExportPass()));
190189
if (emitSanitizerInstrumentation and not targetIsWindows)
@@ -292,7 +291,7 @@ static void compile(
292291
M->setDataLayout(*info.pimpl->datalayout);
293292
llvm::UpgradeDebugInfo(*M);
294293

295-
auto &LLVMTM = static_cast<LLVMTargetMachine &>(*info.pimpl->targetMachine);
294+
auto &LLVMTM = *info.pimpl->targetMachine;
296295
auto *MMIWP = new MachineModuleInfoWrapperPass(&LLVMTM);
297296

298297
llvm::legacy::PassManager manager;
@@ -336,7 +335,7 @@ static mlir::LogicalResult getLinkerInvocation(
336335
auto binDir = llvm::sys::path::parent_path(clangPath);
337336
auto installDir = llvm::sys::path::parent_path(binDir);
338337
llvm::SmallVector<char, 4> clangResourceDir;
339-
llvm::sys::path::append(clangResourceDir, installDir, "lib", "clang", "19");
338+
llvm::sys::path::append(clangResourceDir, installDir, "lib", "clang", "20");
340339
driver.ResourceDir =
341340
llvm::StringRef(clangResourceDir.data(), clangResourceDir.size());
342341
if (targetMac and not llvm::sys::Process::GetEnv("SDKROOT"))

lib/dialect/include/rlc/dialect/ConstraintsAnalysis.hpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -153,10 +153,7 @@ namespace mlir::rlc
153153
}
154154

155155
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(ConstraintsLattice);
156-
explicit ConstraintsLattice(mlir::ProgramPoint point)
157-
: mlir::dataflow::AbstractDenseLattice(point)
158-
{
159-
}
156+
using dataflow::AbstractDenseLattice::AbstractDenseLattice;
160157

161158
// Method for returning the lattice (useful only at the end) <- maybe can do
162159
// everything in the class
@@ -227,7 +224,7 @@ namespace mlir::rlc
227224
ConstraintsLattice>::DenseBackwardDataFlowAnalysis;
228225

229226
private:
230-
void visitOperation(
227+
mlir::LogicalResult visitOperation(
231228
mlir::Operation* op,
232229
const ConstraintsLattice& after,
233230
ConstraintsLattice* before) override;

lib/dialect/include/rlc/dialect/ReachingDefinitions.hpp

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,7 @@ namespace mlir
3030
{
3131
public:
3232
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(ReachingDefinitionsLattice);
33-
explicit ReachingDefinitionsLattice(mlir::ProgramPoint point)
34-
: mlir::dataflow::AbstractDenseLattice(point)
35-
{
36-
}
33+
using dataflow::AbstractDenseLattice::AbstractDenseLattice;
3734

3835
mlir::ChangeResult meet(
3936
const mlir::dataflow::AbstractDenseLattice& val) override
@@ -100,7 +97,7 @@ namespace mlir
10097
using mlir::dataflow::DenseForwardDataFlowAnalysis<
10198
ReachingDefinitionsLattice>::DenseForwardDataFlowAnalysis;
10299

103-
void visitOperation(
100+
mlir::LogicalResult visitOperation(
104101
mlir::Operation* op,
105102
const ReachingDefinitionsLattice& before,
106103
ReachingDefinitionsLattice* after) override
@@ -132,6 +129,7 @@ namespace mlir
132129
propagateIfChanged(after, ChangeResult::Change);
133130
else
134131
propagateIfChanged(after, ChangeResult::NoChange);
132+
return success();
135133
}
136134

137135
void visitCallControlFlowTransfer(
@@ -147,7 +145,7 @@ namespace mlir
147145
}
148146
else
149147
{
150-
visitOperation(call, before, after);
148+
auto _ = visitOperation(call, before, after);
151149
}
152150
}
153151
void visitRegionBranchControlFlowTransfer(
@@ -159,16 +157,14 @@ namespace mlir
159157
{
160158
// when we are leaving the operation, we add our just defined operation
161159
// to the list of things to destroy
162-
visitOperation(branch, before, after);
160+
auto _ = visitOperation(branch, before, after);
163161
}
164162

165163
void setToEntryState(ReachingDefinitionsLattice* lattice) override {}
166164

167165
bool reachesOperation(mlir::Value value, mlir::Operation* op)
168166
{
169-
auto* lattice = op->getPrevNode() != nullptr
170-
? getLattice(mlir::ProgramPoint(op->getPrevNode()))
171-
: getLattice(op->getBlock());
167+
auto* lattice = getLattice(LatticeAnchor(getProgramPointBefore(op)));
172168
if (value.getType().isa<mlir::rlc::ContextType>() or
173169
value.getType().isa<mlir::rlc::FrameType>())
174170
return true;

lib/dialect/src/ActionLiveness.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,7 @@ namespace mlir::rlc
2929
{
3030
public:
3131
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(ActionValueLivenessLattice);
32-
explicit ActionValueLivenessLattice(mlir::ProgramPoint point)
33-
: mlir::dataflow::AbstractDenseLattice(point)
34-
{
35-
}
32+
using dataflow::AbstractDenseLattice::AbstractDenseLattice;
3633

3734
mlir::ChangeResult meet(
3835
const mlir::dataflow::AbstractDenseLattice& val) override
@@ -101,6 +98,7 @@ namespace mlir::rlc
10198
bool isAlive(mlir::Value val) { return content.contains(val); }
10299

103100
private:
101+
mlir::ProgramPoint point;
104102
llvm::DenseSet<mlir::Value> content;
105103
};
106104

@@ -154,14 +152,15 @@ namespace mlir::rlc
154152
return toKill;
155153
}
156154

157-
void visitOperation(
155+
mlir::LogicalResult visitOperation(
158156
mlir::Operation* op,
159157
const ActionValueLivenessLattice& after,
160158
ActionValueLivenessLattice* before) override
161159
{
162160
propagateIfChanged(
163161
before,
164162
before->joinAndMark(after, getJustUsed(op), getJustDefined(op)));
163+
return mlir::success();
165164
}
166165

167166
void visitCallControlFlowTransfer(
@@ -214,8 +213,8 @@ namespace mlir::rlc
214213
public:
215214
bool isDeadAfter(mlir::Value val, mlir::Operation* op)
216215
{
217-
auto* lattice = op != nullptr ? getLattice(mlir::ProgramPoint(op))
218-
: getLattice(op->getBlock());
216+
assert(op != nullptr);
217+
auto* lattice = getLattice(LatticeAnchor(getProgramPointAfter(op)));
219218
return not lattice->isAlive(val);
220219
}
221220
};

lib/dialect/src/ConstraintsAnalysis.cpp

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -834,8 +834,9 @@ namespace mlir::rlc
834834
}
835835
else
836836
{
837-
this->ranges.insert(std::make_pair(
838-
keyToInsert, createRange(min.value_or(MIN), max.value_or(MAX))));
837+
this->ranges.insert(
838+
std::make_pair(
839+
keyToInsert, createRange(min.value_or(MIN), max.value_or(MAX))));
839840
return true;
840841
}
841842
}
@@ -844,7 +845,7 @@ namespace mlir::rlc
844845
// ConstraintsAnalysis METHODS
845846
//////////////////////////////////////////////////////////////////////////////
846847

847-
void ConstraintsAnalysis::visitOperation(
848+
mlir::LogicalResult ConstraintsAnalysis::visitOperation(
848849
mlir::Operation* op,
849850
const ConstraintsLattice& after,
850851
ConstraintsLattice* before)
@@ -868,6 +869,7 @@ namespace mlir::rlc
868869
{
869870
propagateIfChanged(before, before->copy(after));
870871
}
872+
return mlir::success();
871873
}
872874

873875
void ConstraintsAnalysis::visitCallControlFlowTransfer(
@@ -898,8 +900,9 @@ namespace mlir::rlc
898900
// Useful debugging method
899901
void ConstraintsAnalysis::printRanges(mlir::Operation* op)
900902
{
901-
auto* lattice = op != nullptr ? getLattice(mlir::ProgramPoint(op))
902-
: getLattice(op->getBlock());
903+
assert(op != nullptr);
904+
auto* lattice = getLattice(LatticeAnchor(getProgramPointBefore(op)));
905+
903906
lattice->print(llvm::outs());
904907
}
905908

@@ -909,14 +912,15 @@ namespace mlir::rlc
909912
mlir::rlc::ConstraintsLattice::IntegerRange>&
910913
ConstraintsAnalysis::getUnderlyingLattice(mlir::Operation* op)
911914
{
912-
return this->getLattice(mlir::ProgramPoint(op))->getUnderlyingLattice();
915+
return getLattice(LatticeAnchor(getProgramPointBefore(op)))
916+
->getUnderlyingLattice();
913917
}
914918

915919
// Useful method
916920
const mlir::rlc::ConstraintsLattice* ConstraintsAnalysis::getObjLattice(
917921
mlir::Operation* op)
918922
{
919-
return this->getLattice(mlir::ProgramPoint(op));
923+
return getLattice(LatticeAnchor(getProgramPointBefore(op)));
920924
}
921925

922926
// Class which starts the analysis

lib/dialect/src/Conversion.cpp

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -225,8 +225,9 @@ class LowerMalloc: public mlir::OpConversionPattern<mlir::rlc::MallocOp>
225225

226226
const auto& dl = mlir::DataLayout::closest(op);
227227

228-
auto baseType = typeConverter->convertType(mlir::rlc::ProxyType::get(
229-
op.getType().cast<mlir::rlc::OwningPtrType>().getUnderlying()));
228+
auto baseType = typeConverter->convertType(
229+
mlir::rlc::ProxyType::get(
230+
op.getType().cast<mlir::rlc::OwningPtrType>().getUnderlying()));
230231

231232
auto baseSize = rewriter.getI64IntegerAttr(dl.getTypeSize(baseType));
232233
auto count = rewriter.create<mlir::LLVM::ConstantOp>(
@@ -377,10 +378,13 @@ class ExplicitConstructRewriter
377378
typeConverter->convertType(mlir::rlc::ProxyType::get(op.getType()));
378379
auto alloca = makeAlloca(rewriter, mapped, op.getLoc());
379380

380-
rewriter.create<mlir::LLVM::CallOp>(
381+
auto callOp = rewriter.create<mlir::LLVM::CallOp>(
381382
op.getLoc(),
382-
mlir::TypeRange(),
383+
mlir::LLVM::LLVMFunctionType::get(
384+
mlir::LLVM::LLVMVoidType::get(op.getContext()),
385+
{ alloca.getType() }),
383386
mlir::ValueRange({ adaptor.getInitializer(), alloca }));
387+
384388
rewriter.replaceOp(op, alloca);
385389
return mlir::LogicalResult::success();
386390
}
@@ -528,10 +532,11 @@ class IsOpRewriter: public mlir::OpConversionPattern<mlir::rlc::IsOp>
528532
return mlir::success();
529533
}
530534

531-
auto convertedUnionType = typeConverter
532-
->convertType(mlir::rlc::ProxyType::get(
533-
op.getExpression().getType()))
534-
.cast<mlir::LLVM::LLVMStructType>();
535+
auto convertedUnionType =
536+
typeConverter
537+
->convertType(
538+
mlir::rlc::ProxyType::get(op.getExpression().getType()))
539+
.cast<mlir::LLVM::LLVMStructType>();
535540
auto lastElementIndex = convertedUnionType.getBody().size() - 1;
536541

537542
auto zero = rewriter.getZeroAttr(rewriter.getI64Type());
@@ -629,8 +634,9 @@ class ValueUpcastRewriter
629634
if (op.getInput().getType() != op.getResult().getType() and
630635
not op.getInput().getType().isa<mlir::rlc::AlternativeType>())
631636
{
632-
op.emitError("internal error somehow a template upcast did not had the "
633-
"same input and output type at lowering time");
637+
op.emitError(
638+
"internal error somehow a template upcast did not had the "
639+
"same input and output type at lowering time");
634640
return mlir::failure();
635641
}
636642
rewriter.replaceOp(op, op.getInput());
@@ -1278,6 +1284,7 @@ class CallRewriter: public mlir::OpConversionPattern<mlir::rlc::CallOp>
12781284
{
12791285
rewriter.setInsertionPoint(op);
12801286
llvm::SmallVector<mlir::Value, 2> args;
1287+
llvm::SmallVector<mlir::Type, 2> argTypes;
12811288
assert(op.getNumResults() <= 1);
12821289
args.push_back(adaptor.getCallee());
12831290
auto loc = op.getLoc();
@@ -1296,10 +1303,16 @@ class CallRewriter: public mlir::OpConversionPattern<mlir::rlc::CallOp>
12961303
}
12971304

12981305
for (auto arg : adaptor.getArgs())
1306+
{
12991307
args.push_back(arg);
1308+
argTypes.push_back(arg.getType());
1309+
}
13001310

13011311
auto newOp = rewriter.create<mlir::LLVM::CallOp>(
1302-
op.getLoc(), mlir::ValueRange(), args);
1312+
op.getLoc(),
1313+
mlir::LLVM::LLVMFunctionType::get(
1314+
mlir::LLVM::LLVMVoidType::get(op.getContext()), argTypes),
1315+
args);
13031316

13041317
if (type.isa<mlir::rlc::ReferenceType>())
13051318
result = makeAlignedLoad(
@@ -1839,8 +1852,9 @@ class FunctionRewriter
18391852
{
18401853
auto subprogramAttr = diGenerator.getFunctionAttr(
18411854
newF, op.getUnmangledName(), op.getType());
1842-
newF->setLoc(mlir::FusedLoc::get(
1843-
op.getContext(), { newF.getLoc() }, subprogramAttr));
1855+
newF->setLoc(
1856+
mlir::FusedLoc::get(
1857+
op.getContext(), { newF.getLoc() }, subprogramAttr));
18441858

18451859
rewriter.setInsertionPointToStart(&newF.getBody().front());
18461860
for (auto [argument, value, newValue] : llvm::zip(

0 commit comments

Comments
 (0)