summaryrefslogtreecommitdiff
path: root/lib/CodeGen/DwarfEHPrepare.cpp
diff options
context:
space:
mode:
authorBill Wendling <isanbard@gmail.com>2010-06-24 18:49:10 +0000
committerBill Wendling <isanbard@gmail.com>2010-06-24 18:49:10 +0000
commitefbf30610739d73d1f2dba9a8c29aa30c8c3daa4 (patch)
tree5ebfe5c5e3542a5335933b5340aff2044693d361 /lib/CodeGen/DwarfEHPrepare.cpp
parent761fa7af9e883c81da52b27abd0d6971dadbc923 (diff)
downloadllvm-efbf30610739d73d1f2dba9a8c29aa30c8c3daa4.tar.gz
llvm-efbf30610739d73d1f2dba9a8c29aa30c8c3daa4.tar.bz2
llvm-efbf30610739d73d1f2dba9a8c29aa30c8c3daa4.tar.xz
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@106772 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/DwarfEHPrepare.cpp')
-rw-r--r--lib/CodeGen/DwarfEHPrepare.cpp40
1 files changed, 10 insertions, 30 deletions
diff --git a/lib/CodeGen/DwarfEHPrepare.cpp b/lib/CodeGen/DwarfEHPrepare.cpp
index 6673931625..651740d377 100644
--- a/lib/CodeGen/DwarfEHPrepare.cpp
+++ b/lib/CodeGen/DwarfEHPrepare.cpp
@@ -89,7 +89,7 @@ namespace {
/// 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 @@ FunctionPass *llvm::createDwarfEHPass(const TargetMachine *tm, bool fast) {
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 @@ FindAllCleanupSelectors(SmallPtrSet<IntrinsicInst*, 32> &Sels) {
if (II->getParent()->getParent() != F)
continue;
- if (IsACleanupSelector(II))
+ if (!HasCatchAllInSelector(II))
Sels.insert(II);
}
}
@@ -387,7 +367,7 @@ bool DwarfEHPrepare::HandleURoRInvokes() {
// 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);
}
}