summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/WinException.cpp50
-rw-r--r--llvm/lib/CodeGen/MachineModuleInfo.cpp10
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp16
-rw-r--r--llvm/lib/CodeGen/WinEHPrepare.cpp8
-rw-r--r--llvm/lib/Target/X86/X86ISelLowering.cpp6
-rw-r--r--llvm/lib/Target/X86/X86WinEHState.cpp23
6 files changed, 41 insertions, 72 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/WinException.cpp b/llvm/lib/CodeGen/AsmPrinter/WinException.cpp
index adc47650235..f6945b1d1fb 100644
--- a/llvm/lib/CodeGen/AsmPrinter/WinException.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/WinException.cpp
@@ -67,7 +67,6 @@ void WinException::beginFunction(const MachineFunction *MF) {
bool hasEHFunclets = MMI->hasEHFunclets();
const Function *F = MF->getFunction();
- const Function *ParentF = MMI->getWinEHParent(F);
shouldEmitMoves = Asm->needsSEHMoves();
@@ -91,11 +90,8 @@ void WinException::beginFunction(const MachineFunction *MF) {
// If we're not using CFI, we don't want the CFI or the personality, but we
// might want EH tables if we had EH pads.
- // FIXME: If WinEHPrepare outlined something, we should emit the LSDA. Remove
- // this once WinEHPrepare stops doing that.
if (!Asm->MAI->usesWindowsCFI()) {
- shouldEmitLSDA =
- hasEHFunclets || (F->hasFnAttribute("wineh-parent") && F == ParentF);
+ shouldEmitLSDA = hasEHFunclets;
shouldEmitPersonality = false;
return;
}
@@ -152,25 +148,23 @@ void WinException::endFunction(const MachineFunction *MF) {
/// Retreive the MCSymbol for a GlobalValue or MachineBasicBlock. GlobalValues
/// are used in the old WinEH scheme, and they will be removed eventually.
-static MCSymbol *getMCSymbolForMBBOrGV(AsmPrinter *Asm, ValueOrMBB Handler) {
- if (!Handler)
+static MCSymbol *getMCSymbolForMBB(AsmPrinter *Asm,
+ const MachineBasicBlock *MBB) {
+ if (!MBB)
return nullptr;
- if (Handler.is<const MachineBasicBlock *>()) {
- auto *MBB = Handler.get<const MachineBasicBlock *>();
- assert(MBB->isEHFuncletEntry());
-
- // Give catches and cleanups a name based off of their parent function and
- // their funclet entry block's number.
- const MachineFunction *MF = MBB->getParent();
- const Function *F = MF->getFunction();
- StringRef FuncLinkageName = GlobalValue::getRealLinkageName(F->getName());
- MCContext &Ctx = MF->getContext();
- StringRef HandlerPrefix = MBB->isCleanupFuncletEntry() ? "dtor" : "catch";
- return Ctx.getOrCreateSymbol("?" + HandlerPrefix + "$" +
- Twine(MBB->getNumber()) + "@?0?" +
- FuncLinkageName + "@4HA");
- }
- return Asm->getSymbol(cast<GlobalValue>(Handler.get<const Value *>()));
+
+ assert(MBB->isEHFuncletEntry());
+
+ // Give catches and cleanups a name based off of their parent function and
+ // their funclet entry block's number.
+ const MachineFunction *MF = MBB->getParent();
+ const Function *F = MF->getFunction();
+ StringRef FuncLinkageName = GlobalValue::getRealLinkageName(F->getName());
+ MCContext &Ctx = MF->getContext();
+ StringRef HandlerPrefix = MBB->isCleanupFuncletEntry() ? "dtor" : "catch";
+ return Ctx.getOrCreateSymbol("?" + HandlerPrefix + "$" +
+ Twine(MBB->getNumber()) + "@?0?" +
+ FuncLinkageName + "@4HA");
}
void WinException::beginFunclet(const MachineBasicBlock &MBB,
@@ -180,7 +174,7 @@ void WinException::beginFunclet(const MachineBasicBlock &MBB,
const Function *F = Asm->MF->getFunction();
// If a symbol was not provided for the funclet, invent one.
if (!Sym) {
- Sym = getMCSymbolForMBBOrGV(Asm, &MBB);
+ Sym = getMCSymbolForMBB(Asm, &MBB);
// Describe our funclet symbol as a function with internal linkage.
Asm->OutStreamer->BeginCOFFSymbolDef(Sym);
@@ -504,7 +498,7 @@ void WinException::emitSEHActionsForRange(WinEHFuncInfo &FuncInfo,
const MCExpr *ExceptOrNull;
auto *Handler = UME.Handler.get<MachineBasicBlock *>();
if (UME.IsFinally) {
- FilterOrFinally = create32bitRef(getMCSymbolForMBBOrGV(Asm, Handler));
+ FilterOrFinally = create32bitRef(getMCSymbolForMBB(Asm, Handler));
ExceptOrNull = MCConstantExpr::create(0, Ctx);
} else {
// For an except, the filter can be 1 (catch-all) or a function
@@ -597,7 +591,8 @@ void WinException::emitCXXFrameHandler3Table(const MachineFunction *MF) {
if (UnwindMapXData) {
OS.EmitLabel(UnwindMapXData);
for (const CxxUnwindMapEntry &UME : FuncInfo.CxxUnwindMap) {
- MCSymbol *CleanupSym = getMCSymbolForMBBOrGV(Asm, UME.Cleanup);
+ MCSymbol *CleanupSym =
+ getMCSymbolForMBB(Asm, UME.Cleanup.dyn_cast<MachineBasicBlock *>());
OS.EmitIntValue(UME.ToState, 4); // ToState
OS.EmitValue(create32bitRef(CleanupSym), 4); // Action
}
@@ -677,7 +672,8 @@ void WinException::emitCXXFrameHandler3Table(const MachineFunction *MF) {
FrameAllocOffsetRef = MCConstantExpr::create(0, Asm->OutContext);
}
- MCSymbol *HandlerSym = getMCSymbolForMBBOrGV(Asm, HT.Handler);
+ MCSymbol *HandlerSym =
+ getMCSymbolForMBB(Asm, HT.Handler.dyn_cast<MachineBasicBlock *>());
OS.EmitIntValue(HT.Adjectives, 4); // Adjectives
OS.EmitValue(create32bitRef(HT.TypeDescriptor), 4); // Type
diff --git a/llvm/lib/CodeGen/MachineModuleInfo.cpp b/llvm/lib/CodeGen/MachineModuleInfo.cpp
index ee5852a8f93..33db3edffb7 100644
--- a/llvm/lib/CodeGen/MachineModuleInfo.cpp
+++ b/llvm/lib/CodeGen/MachineModuleInfo.cpp
@@ -467,16 +467,8 @@ try_next:;
return FilterID;
}
-const Function *MachineModuleInfo::getWinEHParent(const Function *F) const {
- StringRef WinEHParentName =
- F->getFnAttribute("wineh-parent").getValueAsString();
- if (WinEHParentName.empty() || WinEHParentName == F->getName())
- return F;
- return F->getParent()->getFunction(WinEHParentName);
-}
-
WinEHFuncInfo &MachineModuleInfo::getWinEHFuncInfo(const Function *F) {
- auto &Ptr = FuncInfoMap[getWinEHParent(F)];
+ auto &Ptr = FuncInfoMap[F];
if (!Ptr)
Ptr.reset(new WinEHFuncInfo);
return *Ptr;
diff --git a/llvm/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp b/llvm/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp
index d9b32d92c8e..b0d81030931 100644
--- a/llvm/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp
@@ -285,15 +285,14 @@ void FunctionLoweringInfo::set(const Function &fn, MachineFunction &mf,
// Calculate state numbers if we haven't already.
WinEHFuncInfo &EHInfo = MMI.getWinEHFuncInfo(&fn);
- const Function *WinEHParentFn = MMI.getWinEHParent(&fn);
if (Personality == EHPersonality::MSVC_CXX)
- calculateWinCXXEHStateNumbers(WinEHParentFn, EHInfo);
+ calculateWinCXXEHStateNumbers(&fn, EHInfo);
else if (isAsynchronousEHPersonality(Personality))
- calculateSEHStateNumbers(WinEHParentFn, EHInfo);
+ calculateSEHStateNumbers(&fn, EHInfo);
else if (Personality == EHPersonality::CoreCLR)
- calculateClrEHStateNumbers(WinEHParentFn, EHInfo);
+ calculateClrEHStateNumbers(&fn, EHInfo);
- calculateCatchReturnSuccessorColors(WinEHParentFn, EHInfo);
+ calculateCatchReturnSuccessorColors(&fn, EHInfo);
// Map all BB references in the WinEH data to MBBs.
for (WinEHTryBlockMapEntry &TBME : EHInfo.TryBlockMap) {
@@ -304,14 +303,13 @@ void FunctionLoweringInfo::set(const Function &fn, MachineFunction &mf,
} else {
H.CatchObj.FrameIndex = INT_MAX;
}
- if (const auto *BB = dyn_cast<BasicBlock>(H.Handler.get<const Value *>()))
- H.Handler = MBBMap[BB];
+ if (H.Handler)
+ H.Handler = MBBMap[H.Handler.get<const BasicBlock *>()];
}
}
for (CxxUnwindMapEntry &UME : EHInfo.CxxUnwindMap)
if (UME.Cleanup)
- if (const auto *BB = dyn_cast<BasicBlock>(UME.Cleanup.get<const Value *>()))
- UME.Cleanup = MBBMap[BB];
+ UME.Cleanup = MBBMap[UME.Cleanup.get<const BasicBlock *>()];
for (SEHUnwindMapEntry &UME : EHInfo.SEHUnwindMap) {
const BasicBlock *BB = UME.Handler.get<const BasicBlock *>();
UME.Handler = MBBMap[BB];
diff --git a/llvm/lib/CodeGen/WinEHPrepare.cpp b/llvm/lib/CodeGen/WinEHPrepare.cpp
index 5affb3f0924..3872879cd74 100644
--- a/llvm/lib/CodeGen/WinEHPrepare.cpp
+++ b/llvm/lib/CodeGen/WinEHPrepare.cpp
@@ -144,10 +144,6 @@ bool WinEHPrepare::runOnFunction(Function &Fn) {
if (!Fn.hasPersonalityFn())
return false;
- // No need to prepare outlined handlers.
- if (Fn.hasFnAttribute("wineh-parent"))
- return false;
-
// Classify the personality to see what kind of preparation we need.
Personality = classifyEHPersonality(Fn.getPersonalityFn());
@@ -173,10 +169,10 @@ void WinEHPrepare::getAnalysisUsage(AnalysisUsage &AU) const {
}
static int addUnwindMapEntry(WinEHFuncInfo &FuncInfo, int ToState,
- const Value *V) {
+ const BasicBlock *BB) {
CxxUnwindMapEntry UME;
UME.ToState = ToState;
- UME.Cleanup = V;
+ UME.Cleanup = BB;
FuncInfo.CxxUnwindMap.push_back(UME);
return FuncInfo.getLastStateNumber();
}
diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp
index f6f137a1b92..069cfe49f2e 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.cpp
+++ b/llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -2701,10 +2701,6 @@ SDValue X86TargetLowering::LowerFormalArguments(
}
MachineModuleInfo &MMI = MF.getMMI();
- const Function *WinEHParent = nullptr;
- if (MMI.hasWinEHFuncInfo(Fn))
- WinEHParent = MMI.getWinEHParent(Fn);
- bool IsWinEHParent = WinEHParent && WinEHParent == Fn;
// Figure out if XMM registers are in use.
assert(!(Subtarget->useSoftFloat() &&
@@ -2861,7 +2857,7 @@ SDValue X86TargetLowering::LowerFormalArguments(
FuncInfo->setArgumentStackSize(StackSize);
- if (IsWinEHParent) {
+ if (MMI.hasWinEHFuncInfo(Fn)) {
if (Is64Bit) {
int UnwindHelpFI = MFI->CreateStackObject(8, 8, /*isSS=*/false);
SDValue StackSlot = DAG.getFrameIndex(UnwindHelpFI, MVT::i64);
diff --git a/llvm/lib/Target/X86/X86WinEHState.cpp b/llvm/lib/Target/X86/X86WinEHState.cpp
index ed909c58e9b..a4ae396f826 100644
--- a/llvm/lib/Target/X86/X86WinEHState.cpp
+++ b/llvm/lib/Target/X86/X86WinEHState.cpp
@@ -149,13 +149,6 @@ void WinEHStatePass::getAnalysisUsage(AnalysisUsage &AU) const {
}
bool WinEHStatePass::runOnFunction(Function &F) {
- // If this is an outlined handler, don't do anything. We'll do state insertion
- // for it in the parent.
- StringRef WinEHParentName =
- F.getFnAttribute("wineh-parent").getValueAsString();
- if (WinEHParentName != F.getName() && !WinEHParentName.empty())
- return false;
-
// Check the personality. Do nothing if this personality doesn't use funclets.
if (!F.hasPersonalityFn())
return false;
@@ -169,17 +162,15 @@ bool WinEHStatePass::runOnFunction(Function &F) {
// Skip this function if there are no EH pads and we aren't using IR-level
// outlining.
- if (WinEHParentName.empty()) {
- bool HasPads = false;
- for (BasicBlock &BB : F) {
- if (BB.isEHPad()) {
- HasPads = true;
- break;
- }
+ bool HasPads = false;
+ for (BasicBlock &BB : F) {
+ if (BB.isEHPad()) {
+ HasPads = true;
+ break;
}
- if (!HasPads)
- return false;
}
+ if (!HasPads)
+ return false;
// Disable frame pointer elimination in this function.
// FIXME: Do the nested handlers need to keep the parent ebp in ebp, or can we
OpenPOWER on IntegriCloud