[clang] [CIR] Make cir.alloca alignment mandatory with default 0 (PR #172663)
Andy Kaylor via cfe-commits
cfe-commits at lists.llvm.org
Wed Jan 7 09:09:35 PST 2026
================
@@ -530,7 +530,7 @@ def CIR_AllocaOp : CIR_Op<"alloca", [
StrAttr:$name,
UnitAttr:$init,
UnitAttr:$constant,
- ConfinedAttr<OptionalAttr<I64Attr>, [IntMinValue<0>]>:$alignment,
+ ConfinedAttr<DefaultValuedAttr<I64Attr, "0">, [IntMinValue<0>]>:$alignment,
----------------
andykaylor wrote:
In that case, we're providing the alignment in the call to `emitAlloca` (via the `CharUnits()` argument). We're doing it wrong, but that's where we're doing it, so it has nothing to do with the AllocaOp needing to provide a default value.
The equivalent code in classic codegen calls the `llvm::AllocaInst` constructor directly without an alignment argument, and that in turn calls `computeAllocaDefaultAlign`. We should be doing something equivalent to that in `createTempAlloca` (and any other place that doesn't reasonably compute the alignment). I think that's beyond the scope of this PR.
https://github.com/llvm/llvm-project/pull/172663
More information about the cfe-commits
mailing list