Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CIR] Enable per-pass IR printing #234

Merged
merged 1 commit into from
Aug 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions clang/lib/CIR/Dialect/Transforms/LifetimeCheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1907,15 +1907,13 @@ void LifetimeCheckPass::checkOperation(Operation *op) {
}

void LifetimeCheckPass::runOnOperation() {
assert(astCtx && "Missing ASTContext, please construct with the right ctor");
opts.parseOptions(*this);
Operation *op = getOperation();
checkOperation(op);
}

std::unique_ptr<Pass> mlir::createLifetimeCheckPass() {
// FIXME: MLIR requres a default "constructor", but should never
// be used.
llvm_unreachable("Check requires clang::ASTContext, use the other ctor");
return std::make_unique<LifetimeCheckPass>();
}

Expand Down
1 change: 1 addition & 0 deletions clang/lib/FrontendTool/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ set(deps)
if(CLANG_ENABLE_CIR)
list(APPEND link_libs
clangCIRFrontendAction
MLIRCIRTransforms
MLIRIR
MLIRPass
)
Expand Down
2 changes: 2 additions & 0 deletions clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#include "mlir/IR/AsmState.h"
#include "mlir/IR/MLIRContext.h"
#include "mlir/Pass/PassManager.h"
#include "clang/CIR/Dialect/Passes.h"
#include "clang/CIRFrontendAction/CIRGenAction.h"
#endif

Expand Down Expand Up @@ -317,6 +318,7 @@ bool ExecuteCompilerInvocation(CompilerInstance *Clang) {
#endif
#if CLANG_ENABLE_CIR
if (!Clang->getFrontendOpts().MLIRArgs.empty()) {
mlir::registerCIRPasses();
mlir::registerMLIRContextCLOptions();
mlir::registerPassManagerCLOptions();
mlir::registerAsmPrinterCLOptions();
Expand Down
4 changes: 4 additions & 0 deletions clang/test/CIR/mlirprint.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// RUN: %clang_cc1 -fclangir-enable -emit-cir -mmlir --mlir-print-ir-after-all %s -o %t.cir 2>&1 | FileCheck %s -check-prefix=CIR
// RUN: %clang_cc1 -fclangir-enable -emit-llvm -mmlir --mlir-print-ir-after-all -mllvm -print-after-all %s -o %t.ll 2>&1 | FileCheck %s -check-prefix=CIR -check-prefix=LLVM
// RUN: %clang_cc1 -fclangir-enable -emit-cir -mmlir --mlir-print-ir-after=cir-drop-ast %s -o %t.cir 2>&1 | FileCheck %s -check-prefix=CIRPASS

int foo(void) {
int i = 3;
Expand All @@ -15,3 +16,6 @@ int foo(void) {
// LLVM: llvm.func @foo() -> i32
// LLVM: IR Dump After VerifierPass on [module] ***
// LLVM: define i32 @foo()

// CIRPASS-NOT: IR Dump After MergeCleanups
// CIRPASS: IR Dump After DropAST