[clang] [Clang][CodeGen] Emit dereferenceable and nofree for indirect arguments (PR #213347)
Sayan Sivakumaran via cfe-commits
cfe-commits at lists.llvm.org
Sun Aug 2 18:31:08 PDT 2026
================
@@ -3238,6 +3235,23 @@ void CodeGenModule::ConstructAttributeList(StringRef Name,
assert(!Align.isZero());
Attrs.addAlignmentAttr(Align.getQuantity());
+ // According to [basic.stc.auto], parameters have automatic storage
+ // duration. Therefore, the underlying object of this pointer will not be
+ // freed during the function's execution. If the parameter is realigned,
+ // this may not be true, but realignment does not currently occur for
+ // non-byval. Hmm....
----------------
sivakusayan wrote:
Okay, fixed. To put it in my own words to make sure I understand:
The point of `IndirectRealign` is to get around scenarios where the default stack alignment is not strict enough for types that have high alignment requirements. This can happen with `byval` when the data itself is passed on the stack. However, without `byval` there is no stack alignment we need to worry about - the copy in the caller should already be aligned. So `IndirectRealign` is non-applicable.
https://github.com/llvm/llvm-project/pull/213347
More information about the cfe-commits
mailing list