[PATCH] [WinEH] Demote values live across exception handlers up front

David Majnemer david.majnemer at gmail.com
Tue Apr 21 10:32:14 PDT 2015


================
Comment at: lib/CodeGen/WinEHPrepare.cpp:22
@@ -21,2 +21,3 @@
 #include "llvm/ADT/TinyPtrVector.h"
+#include "llvm/ADT/SetVector.h"
 #include "llvm/Analysis/LibCallSemantics.h"
----------------
Please sort this include with the others.

================
Comment at: lib/CodeGen/WinEHPrepare.cpp:388
@@ +387,3 @@
+    // Don't follow unwind edges of invokes.
+    if (InvokeInst *II = dyn_cast<InvokeInst>(BB->getTerminator())) {
+      Worklist.insert(II->getNormalDest());
----------------
auto?

================
Comment at: lib/CodeGen/WinEHPrepare.cpp:452-457
@@ +451,8 @@
+      for (Value *Op : I.operands()) {
+        // Don't demote static allocas, constants, and labels.
+        if (isa<Constant>(Op) || isa<BasicBlock>(Op))
+          continue;
+        auto *AI = dyn_cast<AllocaInst>(Op);
+        if (AI && AI->isStaticAlloca())
+          continue;
+
----------------
Is it possible to demote a dynamic alloca in the exceptional path?

================
Comment at: lib/CodeGen/WinEHPrepare.cpp:521-522
@@ +520,4 @@
+    for (Instruction &Inst : *LPadBB) {
+      if (auto *IntrinCall = dyn_cast<IntrinsicInst>(&Inst)) {
+        if (IntrinCall->getIntrinsicID() == Intrinsic::eh_actions)
+          return false;
----------------
You could make this just:
  if (match(&Inst, m_Intrinsic<Intrinsic::eh_actions>())
    return false;

================
Comment at: lib/CodeGen/WinEHPrepare.cpp:1468-1469
@@ -1348,6 +1467,4 @@
   if (isa<Instruction>(V) || isa<Argument>(V)) {
-    AllocaInst *NewAlloca =
-        Builder.CreateAlloca(V->getType(), nullptr, "eh.temp.alloca");
-    FrameVarInfo[V].push_back(NewAlloca);
-    LoadInst *NewLoad = Builder.CreateLoad(NewAlloca, V->getName() + ".reload");
-    return NewLoad;
+    dbgs() << "Failed to demote instruction used in exception handler:\n";
+    dbgs() << "  " << *V << '\n';
+    report_fatal_error("WinEHPrepare failed to demote instruction");
----------------
Wrap these in DEBUG?

http://reviews.llvm.org/D9158

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/






More information about the llvm-commits mailing list