[PATCH] D10884: [CodeGen] Force emission of personality directive if explicitly specified
Keno Fischer
kfischer at college.harvard.edu
Thu Jul 2 09:51:13 PDT 2015
loladiro updated this revision to Diff 28961.
loladiro added a comment.
Updated to check attributes.
REPOSITORY
rL LLVM
http://reviews.llvm.org/D10884
Files:
include/llvm/CodeGen/MachineModuleInfo.h
lib/CodeGen/AsmPrinter/DwarfCFIException.cpp
lib/CodeGen/AsmPrinter/EHStreamer.cpp
lib/CodeGen/MachineModuleInfo.cpp
Index: lib/CodeGen/MachineModuleInfo.cpp
===================================================================
--- lib/CodeGen/MachineModuleInfo.cpp
+++ lib/CodeGen/MachineModuleInfo.cpp
@@ -320,7 +320,10 @@
const Function *Personality) {
LandingPadInfo &LP = getOrCreateLandingPadInfo(LandingPad);
LP.Personality = Personality;
+ addPersonality(Personality);
+}
+void MachineModuleInfo::addPersonality(const Function *Personality) {
for (unsigned i = 0; i < Personalities.size(); ++i)
if (Personalities[i] == Personality)
return;
Index: lib/CodeGen/AsmPrinter/EHStreamer.cpp
===================================================================
--- lib/CodeGen/AsmPrinter/EHStreamer.cpp
+++ lib/CodeGen/AsmPrinter/EHStreamer.cpp
@@ -309,7 +309,7 @@
// If some instruction between the previous try-range and the end of the
// function may throw, create a call-site entry with no landing pad for the
// region following the try-range.
- if (SawPotentiallyThrowing && !IsSJLJ) {
+ if (SawPotentiallyThrowing && !IsSJLJ && LastLabel != nullptr) {
CallSiteEntry Site = { LastLabel, nullptr, nullptr, 0 };
CallSites.push_back(Site);
}
Index: lib/CodeGen/AsmPrinter/DwarfCFIException.cpp
===================================================================
--- lib/CodeGen/AsmPrinter/DwarfCFIException.cpp
+++ lib/CodeGen/AsmPrinter/DwarfCFIException.cpp
@@ -89,9 +89,13 @@
void DwarfCFIException::beginFunction(const MachineFunction *MF) {
shouldEmitMoves = shouldEmitPersonality = shouldEmitLSDA = false;
+ const Function *F = MF->getFunction();
// If any landing pads survive, we need an EH table.
bool hasLandingPads = !MMI->getLandingPads().empty();
+ bool forceEmitPersonality =
+ F->hasPersonalityFn() && (!F->hasFnAttribute(Attribute::NoUnwind) ||
+ F->hasFnAttribute(Attribute::UWTable));
// See if we need frame move info.
AsmPrinter::CFIMoveType MoveType = Asm->needsCFIMoves();
@@ -104,10 +108,16 @@
const TargetLoweringObjectFile &TLOF = Asm->getObjFileLowering();
unsigned PerEncoding = TLOF.getPersonalityEncoding();
- const Function *Per = MMI->getPersonality();
+ const Function *Per = F->hasPersonalityFn()
+ ? dyn_cast<Function>(F->getPersonalityFn())
+ : nullptr;
+ if (!Per)
+ Per = MMI->getPersonality();
- shouldEmitPersonality = hasLandingPads &&
- PerEncoding != dwarf::DW_EH_PE_omit && Per;
+ shouldEmitPersonality =
+ (forceEmitPersonality ||
+ (hasLandingPads && PerEncoding != dwarf::DW_EH_PE_omit)) &&
+ Per;
unsigned LSDAEncoding = TLOF.getLSDAEncoding();
shouldEmitLSDA = shouldEmitPersonality &&
@@ -123,6 +133,11 @@
if (!shouldEmitPersonality)
return;
+ // If we are forced to emit this personality, make sure to record
+ // it because it might not appear in any landingpad
+ if (forceEmitPersonality)
+ MMI->addPersonality(Per);
+
const MCSymbol *Sym =
TLOF.getCFIPersonalitySymbol(Per, *Asm->Mang, Asm->TM, MMI);
Asm->OutStreamer->EmitCFIPersonality(Sym, PerEncoding);
Index: include/llvm/CodeGen/MachineModuleInfo.h
===================================================================
--- include/llvm/CodeGen/MachineModuleInfo.h
+++ include/llvm/CodeGen/MachineModuleInfo.h
@@ -320,6 +320,7 @@
/// information.
void addPersonality(MachineBasicBlock *LandingPad,
const Function *Personality);
+ void addPersonality(const Function *Personality);
void addWinEHState(MachineBasicBlock *LandingPad, int State);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D10884.28961.patch
Type: text/x-patch
Size: 3645 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150702/4290a411/attachment.bin>
More information about the llvm-commits
mailing list