aboutsummaryrefslogtreecommitdiffstats
path: root/lib/CodeGen/DwarfEHPrepare.cpp
diff options
context:
space:
mode:
authorBill Wendling <isanbard@gmail.com>2010-03-27 01:19:12 +0000
committerBill Wendling <isanbard@gmail.com>2010-03-27 01:19:12 +0000
commitbfbd853958518981dc7a614a388bf93e1895d2b5 (patch)
tree9a2020ca14104146939290cddd2e5362e91a6232 /lib/CodeGen/DwarfEHPrepare.cpp
parent897dd0c58859e10afaa36e4175eef9a703b4a794 (diff)
downloadexternal_llvm-bfbd853958518981dc7a614a388bf93e1895d2b5.zip
external_llvm-bfbd853958518981dc7a614a388bf93e1895d2b5.tar.gz
external_llvm-bfbd853958518981dc7a614a388bf93e1895d2b5.tar.bz2
If a selector has a call to ".llvm.eh.catch.all.value" that we haven't
converted, then use the initializer, since using the name itself won't work. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@99692 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/DwarfEHPrepare.cpp')
-rw-r--r--lib/CodeGen/DwarfEHPrepare.cpp46
1 files changed, 38 insertions, 8 deletions
diff --git a/lib/CodeGen/DwarfEHPrepare.cpp b/lib/CodeGen/DwarfEHPrepare.cpp
index 3d2ace5..1285fc8 100644
--- a/lib/CodeGen/DwarfEHPrepare.cpp
+++ b/lib/CodeGen/DwarfEHPrepare.cpp
@@ -83,6 +83,11 @@ namespace {
CreateExceptionValueCall(BB) : CreateValueLoad(BB);
}
+ /// CleanupSelectors - Any remaining eh.selector intrinsic calls which still
+ /// use the ".llvm.eh.catch.all.value" call need to convert to using it's
+ /// initializer instead.
+ void CleanupSelectors();
+
/// HandleURoRInvokes - Handle invokes of "_Unwind_Resume_or_Rethrow"
/// calls. The "unwind" part of these invokes jump to a landing pad within
/// the current function. This is a candidate to merge the selector
@@ -212,6 +217,24 @@ DwarfEHPrepare::FindSelectorAndURoR(Instruction *Inst, bool &URoRInvoke,
return Changed;
}
+/// CleanupSelectors - Any remaining eh.selector intrinsic calls which still use
+/// the ".llvm.eh.catch.all.value" call need to convert to using it's
+/// initializer instead.
+void DwarfEHPrepare::CleanupSelectors() {
+ for (Value::use_iterator
+ I = SelectorIntrinsic->use_begin(),
+ E = SelectorIntrinsic->use_end(); I != E; ++I) {
+ IntrinsicInst *Sel = dyn_cast<IntrinsicInst>(I);
+ if (!Sel || Sel->getParent()->getParent() != F) continue;
+
+ // Index of the ".llvm.eh.catch.all.value" variable.
+ unsigned OpIdx = Sel->getNumOperands() - 1;
+ GlobalVariable *GV = dyn_cast<GlobalVariable>(Sel->getOperand(OpIdx));
+ if (GV != EHCatchAllValue) continue;
+ Sel->setOperand(OpIdx, EHCatchAllValue->getInitializer());
+ }
+}
+
/// HandleURoRInvokes - Handle invokes of "_Unwind_Resume_or_Rethrow" calls. The
/// "unwind" part of these invokes jump to a landing pad within the current
/// function. This is a candidate to merge the selector associated with the URoR
@@ -223,21 +246,27 @@ bool DwarfEHPrepare::HandleURoRInvokes() {
if (!EHCatchAllValue) return false;
}
+ if (!SelectorIntrinsic) {
+ SelectorIntrinsic =
+ Intrinsic::getDeclaration(F->getParent(), Intrinsic::eh_selector);
+ if (!SelectorIntrinsic) return false;
+ }
+
if (!URoR) {
URoR = F->getParent()->getFunction("_Unwind_Resume_or_Rethrow");
- if (!URoR) return false;
+ if (!URoR) {
+ CleanupSelectors();
+ return false;
+ }
}
if (!ExceptionValueIntrinsic) {
ExceptionValueIntrinsic =
Intrinsic::getDeclaration(F->getParent(), Intrinsic::eh_exception);
- if (!ExceptionValueIntrinsic) return false;
- }
-
- if (!SelectorIntrinsic) {
- SelectorIntrinsic =
- Intrinsic::getDeclaration(F->getParent(), Intrinsic::eh_selector);
- if (!SelectorIntrinsic) return false;
+ if (!ExceptionValueIntrinsic) {
+ CleanupSelectors();
+ return false;
+ }
}
bool Changed = false;
@@ -308,6 +337,7 @@ bool DwarfEHPrepare::HandleURoRInvokes() {
}
}
+ CleanupSelectors();
return Changed;
}