[llvm-commits] [llvm] r106772 - /llvm/trunk/lib/CodeGen/DwarfEHPrepare.cpp

Bill Wendling isanbard at gmail.com
Thu Jun 24 11:49:10 PDT 2010


Author: void
Date: Thu Jun 24 13:49:10 2010
New Revision: 106772

URL: http://llvm.org/viewvc/llvm-project?rev=106772&view=rev
Log:
Loosen up the requirements in the Horrible Hack(tm) to include all selectors
which don't have a catch-all associated with them not just clean-ups. This fixes
the SingleSource/Benchmarks/Shootout-C++/except.cpp testcase that broke because
of my change r105902.

Modified:
    llvm/trunk/lib/CodeGen/DwarfEHPrepare.cpp

Modified: llvm/trunk/lib/CodeGen/DwarfEHPrepare.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/DwarfEHPrepare.cpp?rev=106772&r1=106771&r2=106772&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/DwarfEHPrepare.cpp (original)
+++ llvm/trunk/lib/CodeGen/DwarfEHPrepare.cpp Thu Jun 24 13:49:10 2010
@@ -89,7 +89,7 @@
     /// initializer instead.
     bool CleanupSelectors();
 
-    bool IsACleanupSelector(IntrinsicInst *);
+    bool HasCatchAllInSelector(IntrinsicInst *);
 
     /// FindAllCleanupSelectors - Find all eh.selector calls that are clean-ups.
     void FindAllCleanupSelectors(SmallPtrSet<IntrinsicInst*, 32> &Sels);
@@ -188,34 +188,14 @@
   return new DwarfEHPrepare(tm, fast);
 }
 
-/// IsACleanupSelector - Return true if the intrinsic instruction is a clean-up
-/// selector instruction.
-bool DwarfEHPrepare::IsACleanupSelector(IntrinsicInst *II) {
-  unsigned NumOps = II->getNumOperands();
-  bool IsCleanUp = (NumOps == 3);
-
-  if (IsCleanUp)
-    return true;
-
-  if (ConstantInt *CI = dyn_cast<ConstantInt>(II->getOperand(3))) {
-    unsigned Val = CI->getZExtValue();
-
-    if (Val == 0 || Val + 3 == NumOps) {
-      // If the value is 0 or the selector has only filters in it, then it's
-      // a cleanup.
-      return true;
-    } else {
-      assert(Val + 3 < NumOps && "Ill-formed eh.selector!");
-
-      if (Val + 4 == NumOps) {
-        if (ConstantInt *FinalVal =
-            dyn_cast<ConstantInt>(II->getOperand(NumOps - 1)))
-          return FinalVal->isZero();
-      }
-    }
-  }
+/// HasCatchAllInSelector - Return true if the intrinsic instruction has a
+/// catch-all.
+bool DwarfEHPrepare::HasCatchAllInSelector(IntrinsicInst *II) {
+  if (!EHCatchAllValue) return false;
 
-  return false;
+  unsigned OpIdx = II->getNumOperands() - 1;
+  GlobalVariable *GV = dyn_cast<GlobalVariable>(II->getOperand(OpIdx));
+  return GV == EHCatchAllValue;
 }
 
 /// FindAllCleanupSelectors - Find all eh.selector calls that are clean-ups.
@@ -229,7 +209,7 @@
     if (II->getParent()->getParent() != F)
       continue;
 
-    if (IsACleanupSelector(II))
+    if (!HasCatchAllInSelector(II))
       Sels.insert(II);
   }
 }
@@ -387,7 +367,7 @@
         // need to convert it to a 'catch-all'.
         for (SmallPtrSet<IntrinsicInst*, 8>::iterator
                SI = SelCalls.begin(), SE = SelCalls.end(); SI != SE; ++SI)
-          if (IsACleanupSelector(*SI))
+          if (!HasCatchAllInSelector(*SI))
               SelsToConvert.insert(*SI);
       }
     }





More information about the llvm-commits mailing list