[clang] [WinEH] Fix crash when aligning parameters larger than ABI (PR #180905)

via cfe-commits cfe-commits at lists.llvm.org
Wed Feb 11 01:41:54 PST 2026


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: None (GkvJwa)

<details>
<summary>Changes</summary>

Fix #<!-- -->180648

---
Full diff: https://github.com/llvm/llvm-project/pull/180905.diff


1 Files Affected:

- (modified) clang/lib/CodeGen/CGException.cpp (+14-2) 


``````````diff
diff --git a/clang/lib/CodeGen/CGException.cpp b/clang/lib/CodeGen/CGException.cpp
index 2f1df6e9a8a5c..de5c9e92dd655 100644
--- a/clang/lib/CodeGen/CGException.cpp
+++ b/clang/lib/CodeGen/CGException.cpp
@@ -1836,8 +1836,20 @@ Address CodeGenFunction::recoverAddrOfEscapedLocal(CodeGenFunction &ParentCGF,
                                                    llvm::Value *ParentFP) {
   llvm::CallInst *RecoverCall = nullptr;
   CGBuilderTy Builder(*this, AllocaInsertPt);
-  if (auto *ParentAlloca =
-          dyn_cast_or_null<llvm::AllocaInst>(ParentVar.getBasePointer())) {
+  auto *ParentAlloca =
+      dyn_cast_or_null<llvm::AllocaInst>(ParentVar.getBasePointer());
+  if (!ParentAlloca) {
+    if (auto *ParentArg =
+            dyn_cast_or_null<llvm::Argument>(ParentVar.getBasePointer())) {
+      llvm::BasicBlock &EntryBB = ParentCGF.CurFn->getEntryBlock();
+      llvm::IRBuilder<> ParentEntryBuilder(&EntryBB, EntryBB.begin());
+      ParentAlloca = ParentEntryBuilder.CreateAlloca(
+          ParentArg->getType(), nullptr, ParentArg->getName() + ".addr");
+      ParentEntryBuilder.CreateStore(ParentArg, ParentAlloca);
+    }
+  }
+
+  if (ParentAlloca) {
     // Mark the variable escaped if nobody else referenced it and compute the
     // localescape index.
     auto InsertPair = ParentCGF.EscapedLocals.insert(

``````````

</details>


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


More information about the cfe-commits mailing list