1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-24 11:42:57 +01:00

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.

llvm-svn: 99692
This commit is contained in:
Bill Wendling 2010-03-27 01:19:12 +00:00
parent 794a9a3941
commit 4b55d4fd59

View File

@ -83,6 +83,11 @@ namespace {
CreateExceptionValueCall(BB) : CreateValueLoad(BB); 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" /// HandleURoRInvokes - Handle invokes of "_Unwind_Resume_or_Rethrow"
/// calls. The "unwind" part of these invokes jump to a landing pad within /// calls. The "unwind" part of these invokes jump to a landing pad within
/// the current function. This is a candidate to merge the selector /// the current function. This is a candidate to merge the selector
@ -212,6 +217,24 @@ DwarfEHPrepare::FindSelectorAndURoR(Instruction *Inst, bool &URoRInvoke,
return Changed; 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 /// HandleURoRInvokes - Handle invokes of "_Unwind_Resume_or_Rethrow" calls. The
/// "unwind" part of these invokes jump to a landing pad within the current /// "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 /// 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 (!EHCatchAllValue) return false;
} }
if (!SelectorIntrinsic) {
SelectorIntrinsic =
Intrinsic::getDeclaration(F->getParent(), Intrinsic::eh_selector);
if (!SelectorIntrinsic) return false;
}
if (!URoR) { if (!URoR) {
URoR = F->getParent()->getFunction("_Unwind_Resume_or_Rethrow"); URoR = F->getParent()->getFunction("_Unwind_Resume_or_Rethrow");
if (!URoR) return false; if (!URoR) {
CleanupSelectors();
return false;
}
} }
if (!ExceptionValueIntrinsic) { if (!ExceptionValueIntrinsic) {
ExceptionValueIntrinsic = ExceptionValueIntrinsic =
Intrinsic::getDeclaration(F->getParent(), Intrinsic::eh_exception); Intrinsic::getDeclaration(F->getParent(), Intrinsic::eh_exception);
if (!ExceptionValueIntrinsic) return false; if (!ExceptionValueIntrinsic) {
} CleanupSelectors();
return false;
if (!SelectorIntrinsic) { }
SelectorIntrinsic =
Intrinsic::getDeclaration(F->getParent(), Intrinsic::eh_selector);
if (!SelectorIntrinsic) return false;
} }
bool Changed = false; bool Changed = false;
@ -308,6 +337,7 @@ bool DwarfEHPrepare::HandleURoRInvokes() {
} }
} }
CleanupSelectors();
return Changed; return Changed;
} }