[PATCH] D143739: [WinEH][NFC] Assert for dynamic alloca in WinEH BBs

Phoebe Wang via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 10 07:31:16 PST 2023


pengfei created this revision.
pengfei added reviewers: majnemer, rnk.
Herald added a subscriber: hiraditya.
Herald added a project: All.
pengfei requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

It seems D17823 <https://reviews.llvm.org/D17823> assumes catch objects are always fixed objects.
Though dynamic alloca is rare, it exists in manually written IR, e.g., https://godbolt.org/z/a8xY91seG
We may not need to support it in WinEH, but we should detect the problem in advance.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D143739

Files:
  llvm/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp


Index: llvm/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp
===================================================================
--- llvm/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp
+++ llvm/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp
@@ -98,7 +98,8 @@
   DenseMap<const AllocaInst *, TinyPtrVector<int *>> CatchObjects;
   EHPersonality Personality = classifyEHPersonality(
       Fn->hasPersonalityFn() ? Fn->getPersonalityFn() : nullptr);
-  if (isFuncletEHPersonality(Personality)) {
+  bool IsFuncletEHPersonality = isFuncletEHPersonality(Personality);
+  if (IsFuncletEHPersonality) {
     // Calculate state numbers if we haven't already.
     WinEHFuncInfo &EHInfo = *MF->getWinEHFuncInfo();
     if (Personality == EHPersonality::MSVC_CXX)
@@ -169,6 +170,8 @@
           // a single dynamic allocation instead of using a separate
           // stack allocation for each one.
           // Inform the Frame Information that we have variable-sized objects.
+          assert(!IsFuncletEHPersonality &&
+                 "CatchObjects must be fixed objects");
           MF->getFrameInfo().CreateVariableSizedObject(
               Alignment <= StackAlign ? Align(1) : Alignment, AI);
         }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D143739.496468.patch
Type: text/x-patch
Size: 1215 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230210/d34486e1/attachment.bin>


More information about the llvm-commits mailing list