[clang] [CIR] Reject a global carrying a function type (PR #214065)
Adam Smith via cfe-commits
cfe-commits at lists.llvm.org
Tue Aug 4 13:52:41 PDT 2026
================
@@ -2076,6 +2076,11 @@ static void printConstant(OpAsmPrinter &p, Attribute value) {
}
mlir::LogicalResult cir::GlobalOp::verify() {
+ // A function is not an object, so it cannot be the type of a global. A
+ // global that holds a function's address carries a pointer type instead.
+ if (mlir::isa<cir::FuncType>(getSymType()))
----------------
adams381 wrote:
You cannot get here with C/C++. This was discovered when hand writing CIR for function pointer calling convention lowering support (that PR is going up soon).
It lowers to an `llvm.mlir.global` carrying a function type. The LLVM dialect verifier accepts it and then LLVM IR translation aborts in the `GlobalVariable` constructor with no error message.
https://github.com/llvm/llvm-project/pull/214065
More information about the cfe-commits
mailing list