Skip to content

Commit 5ee4534

Browse files
committed
[CIR][CIRGen] fix calling a function through a function pointer
1 parent 89c4579 commit 5ee4534

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

clang/lib/CIR/CodeGen/CIRGenExpr.cpp

-4
Original file line numberDiff line numberDiff line change
@@ -1145,10 +1145,6 @@ RValue CIRGenFunction::buildCall(clang::QualType CalleeType,
11451145
if (isa<FunctionNoProtoType>(FnType) || Chain) {
11461146
assert(!UnimplementedFeature::chainCalls());
11471147
assert(!UnimplementedFeature::addressSpace());
1148-
1149-
// Set no-proto function as callee.
1150-
auto Fn = llvm::dyn_cast<mlir::cir::FuncOp>(Callee.getFunctionPointer());
1151-
Callee.setFunctionPointer(Fn);
11521148
}
11531149

11541150
assert(!CGM.getLangOpts().HIP && "HIP NYI");

clang/test/CIR/CodeGen/no-proto-fun-ptr.c

+10
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,13 @@ void check_noproto_ptr() {
1515

1616
void empty(void) {}
1717

18+
void buz() {
19+
void (*func)();
20+
(*func)();
21+
}
22+
23+
// CHECK: cir.func no_proto @buz()
24+
// CHECK: [[FNPTR_ALLOC:%.*]] = cir.alloca !cir.ptr<!cir.func<!void (...)>>, cir.ptr <!cir.ptr<!cir.func<!void (...)>>>, ["func"] {alignment = 8 : i64}
25+
// CHECK: [[FNPTR:%.*]] = cir.load deref [[FNPTR_ALLOC]] : cir.ptr <!cir.ptr<!cir.func<!void (...)>>>, !cir.ptr<!cir.func<!void (...)>>
26+
// CHECK: cir.call [[FNPTR]]() : (!cir.ptr<!cir.func<!void (...)>>) -> ()
27+
// CHECK: cir.return

0 commit comments

Comments
 (0)