[clang] [llvm] [HLSL][Clang] Start emitting @llvm.structured.alloca (PR #190157)

Nathan Gauër via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 14 07:20:33 PDT 2026


================
@@ -107,7 +107,12 @@ RawAddress
 CodeGenFunction::CreateTempAllocaWithoutCast(llvm::Type *Ty, CharUnits Align,
                                              const Twine &Name,
                                              llvm::Value *ArraySize) {
-  auto Alloca = CreateTempAlloca(Ty, Name, ArraySize);
+  if (getLangOpts().EmitLogicalPointer) {
+    auto Alloca = Builder.CreateStructuredAlloca(Ty, Name);
+    return RawAddress(Alloca, Ty, Align, KnownNonNull);
+  }
----------------
Keenuts wrote:

An example is the Exception handling is using allocas. We don't use exception in HLSL, but allowing structured allocas to end up in the exception handling code with this flag is out of scope (don't know enough about this part to make a call)
Those then also end up in a list of escaped locals, still in the exception handling bits.
Second part is related to RAII, which tracks Allocas.
I'm not saying we shouldn't, but I'm saying it may not be just a mater of sinking the call slightly further, hence why I want to deccorelate this. 

https://github.com/llvm/llvm-project/pull/190157


More information about the cfe-commits mailing list