Skip to content

Commit 3963265

Browse files
committed
run SCFPreparePass cir pass always when lowering throughMLIR
1 parent 78a81f8 commit 3963265

File tree

4 files changed

+9
-10
lines changed

4 files changed

+9
-10
lines changed

clang/include/clang/CIR/CIRToCIRPasses.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ mlir::LogicalResult runCIRToCIRPasses(
3434
llvm::StringRef lifetimeOpts, bool enableIdiomRecognizer,
3535
llvm::StringRef idiomRecognizerOpts, bool enableLibOpt,
3636
llvm::StringRef libOptOpts, std::string &passOptParsingFailure,
37-
bool enableCIRSimplify, bool flattenCIR, bool emitMLIR,
37+
bool enableCIRSimplify, bool flattenCIR, bool throughMLIR,
3838
bool enableCallConvLowering, bool enableMem2reg);
3939

4040
} // namespace cir

clang/lib/CIR/CodeGen/CIRPasses.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ mlir::LogicalResult runCIRToCIRPasses(
2828
llvm::StringRef lifetimeOpts, bool enableIdiomRecognizer,
2929
llvm::StringRef idiomRecognizerOpts, bool enableLibOpt,
3030
llvm::StringRef libOptOpts, std::string &passOptParsingFailure,
31-
bool enableCIRSimplify, bool flattenCIR, bool emitCore,
31+
bool enableCIRSimplify, bool flattenCIR, bool throughMLIR,
3232
bool enableCallConvLowering, bool enableMem2Reg) {
3333

3434
llvm::TimeTraceScope scope("CIR To CIR Passes");
@@ -81,7 +81,7 @@ mlir::LogicalResult runCIRToCIRPasses(
8181
if (enableMem2Reg)
8282
pm.addPass(mlir::createMem2Reg());
8383

84-
if (emitCore)
84+
if (throughMLIR)
8585
pm.addPass(mlir::createSCFPreparePass());
8686

8787
// FIXME: once CIRCodenAction fixes emission other than CIR we

clang/lib/CIR/FrontendAction/CIRGenAction.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -210,18 +210,16 @@ class CIRGenConsumer : public clang::ASTConsumer {
210210
action == CIRGenAction::OutputType::EmitMLIR &&
211211
feOptions.MLIRTargetDialect == clang::frontend::MLIR_CIR_FLAT;
212212

213-
bool emitCore = action == CIRGenAction::OutputType::EmitMLIR &&
214-
feOptions.MLIRTargetDialect == clang::frontend::MLIR_CORE;
215-
216213
// Setup and run CIR pipeline.
217214
std::string passOptParsingFailure;
218215
if (runCIRToCIRPasses(
219216
mlirMod, mlirCtx.get(), C, !feOptions.ClangIRDisableCIRVerifier,
220217
feOptions.ClangIRLifetimeCheck, lifetimeOpts,
221218
feOptions.ClangIRIdiomRecognizer, idiomRecognizerOpts,
222219
feOptions.ClangIRLibOpt, libOptOpts, passOptParsingFailure,
223-
codeGenOptions.OptimizationLevel > 0, flattenCIR, emitCore,
224-
enableCCLowering, feOptions.ClangIREnableMem2Reg)
220+
codeGenOptions.OptimizationLevel > 0, flattenCIR,
221+
!feOptions.ClangIRDirectLowering, enableCCLowering,
222+
feOptions.ClangIREnableMem2Reg)
225223
.failed()) {
226224
if (!passOptParsingFailure.empty())
227225
diagnosticsEngine.Report(diag::err_drv_cir_pass_opt_parsing)

clang/lib/CIR/Lowering/ThroughMLIR/LowerCIRLoopToSCF.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -321,8 +321,9 @@ void SCFLoop::transferToSCFForOp() {
321321
}
322322
return mlir::WalkResult::advance();
323323
});
324-
325-
// All uses have been replaced by the scf.IV and we can remove the alloca + initial store operations
324+
325+
// All uses have been replaced by the scf.IV and we can remove the alloca +
326+
// initial store operations
326327

327328
// The operations before the loop have been transferred to MLIR.
328329
// So we need to go through getRemappedValue to find the operations.

0 commit comments

Comments
 (0)