[clang] [CIR] Update uses of no-prototype GetGlobalOp (PR #193868)
Erich Keane via cfe-commits
cfe-commits at lists.llvm.org
Fri Apr 24 06:05:30 PDT 2026
================
@@ -1816,9 +1816,23 @@ void CIRGenModule::replaceUsesOfNonProtoTypeWithRealFunction(
noProtoCallOp.erase();
} else if (auto getGlobalOp =
mlir::dyn_cast<cir::GetGlobalOp>(use.getUser())) {
- // Replace type
- getGlobalOp.getAddr().setType(
- cir::PointerType::get(newFn.getFunctionType()));
+ // The GetGlobal was emitted with the no-proto FuncType. Uses of this
+ // operation (cir.store, cir.cast) were built for that pointer type. When
+ // we re-type the result to the real FuncType, we need to add a bit the
+ // old pointer type so those uses are still valid. This can lead to
+ // some redundant bitcast chains, but those will be cleaned up by the
+ // canonicalizer.
+ mlir::Value res = getGlobalOp.getAddr();
+ const mlir::Type oldResTy = res.getType();
+ const auto newPtrTy = cir::PointerType::get(newFn.getFunctionType());
+ res.setType(newPtrTy);
----------------
erichkeane wrote:
can we/should we move 'set type' inside the '!=' branch below?
https://github.com/llvm/llvm-project/pull/193868
More information about the cfe-commits
mailing list