Skip to content

Commit 1caf737

Browse files
Lancernlanza
authored andcommitted
[CIR][NFC] Fix bug in MLIR lowering of cir.call (#728)
This PR fixes the bug described as in #727 (comment). It should resolve the crash reported in #727 .
1 parent 50babdd commit 1caf737

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ class CIRCallOpLowering : public mlir::OpConversionPattern<mlir::cir::CallOp> {
9999
getTypeConverter()->convertTypes(op.getResultTypes(), types)))
100100
return mlir::failure();
101101
rewriter.replaceOpWithNewOp<mlir::func::CallOp>(
102-
op, mlir::SymbolRefAttr::get(op), types, adaptor.getOperands());
102+
op, op.getCalleeAttr(), types, adaptor.getOperands());
103103
return mlir::LogicalResult::success();
104104
}
105105
};
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -fno-clangir-direct-lowering -emit-mlir %s -o %t.mlir
2+
// RUN: FileCheck --input-file=%t.mlir %s
3+
4+
void foo(int i) {}
5+
6+
int test(void) {
7+
foo(2);
8+
return 0;
9+
}
10+
11+
// CHECK-LABEL: func.func @test() -> i32 {
12+
// CHECK: %[[ARG:.+]] = arith.constant 2 : i32
13+
// CHECK-NEXT: call @foo(%[[ARG]]) : (i32) -> ()
14+
// CHECK: }

0 commit comments

Comments
 (0)