[clang] [CIR] Freeze maybe_undef call arguments (PR #234124)
Arseniy Obolenskiy via cfe-commits
cfe-commits at lists.llvm.org
Mon Nov 16 21:51:36 PST 2026
================
@@ -2189,6 +2198,25 @@ CIRABIRewriteContext::rewriteCallSite(mlir::Operation *callOp,
if (ac.kind == ArgKind::Ignore)
continue;
mlir::Value arg = argOperands[idx];
+
+ // Refreeze after the ABI rewrite, as classic CodeGen does, so padding is
+ // frozen too. Indirect freezes only the pointer, so keep non-load freezes.
+ auto freeze = arg.getDefiningOp<cir::FreezeOp>();
+ if (freeze && freeze->hasOneUse() &&
+ (ac.kind != ArgKind::Indirect ||
+ freeze.getInput().getDefiningOp<cir::LoadOp>())) {
+ arg = freeze.getInput();
+ deadFreezes.push_back(freeze);
+ } else {
+ freeze = {};
+ }
+ llvm::scope_exit refreeze([&, firstNewArg = newArgs.size()] {
----------------
aobolensk wrote:
Replaced the scope_exit
Loop records where each argument starts in newArgs and creates the freezes after the loop, so an error exit creates none
https://github.com/llvm/llvm-project/pull/234124
More information about the cfe-commits
mailing list