summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2015-02-27 18:18:39 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2015-02-27 18:18:39 +0000
commit629cdbae948a101e6e20784e6d0e86929030462e (patch)
tree895a7612aadcd8bed73c0c3dcee31c2eaa734b93 /llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
parentaf0ff1093ec4042c6abacf67ad30c6543887e674 (diff)
downloadbcm5719-llvm-629cdbae948a101e6e20784e6d0e86929030462e.tar.gz
bcm5719-llvm-629cdbae948a101e6e20784e6d0e86929030462e.zip
Centralize handling of the eh_begin and eh_end labels.
This removes a bit of duplicated code and more importantly, remembers the labels so that they don't need to be looked up by name. This in turn allows for any name to be used and avoids a crash if the name we wanted was already taken. llvm-svn: 230772
Diffstat (limited to 'llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp')
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
index 988381d745a..b94278fae07 100644
--- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
@@ -109,6 +109,8 @@ AsmPrinter::AsmPrinter(TargetMachine &tm, std::unique_ptr<MCStreamer> Streamer)
LI = nullptr;
MF = nullptr;
CurrentFnSym = CurrentFnSymForSize = nullptr;
+ CurrentFnBegin = nullptr;
+ CurrentFnEnd = nullptr;
GCMetadataPrinters = nullptr;
VerboseAsm = OutStreamer.isVerboseAsm();
}
@@ -554,6 +556,19 @@ void AsmPrinter::EmitFunctionHeader() {
OutStreamer.EmitLabel(DeadBlockSyms[i]);
}
+ if (!MMI->getLandingPads().empty()) {
+ CurrentFnBegin = createTempSymbol("eh_func_begin", getFunctionNumber());
+
+ if (MAI->useAssignmentForEHBegin()) {
+ MCSymbol *CurPos = OutContext.CreateTempSymbol();
+ OutStreamer.EmitLabel(CurPos);
+ OutStreamer.EmitAssignment(CurrentFnBegin,
+ MCSymbolRefExpr::Create(CurPos, OutContext));
+ } else {
+ OutStreamer.EmitLabel(CurrentFnBegin);
+ }
+ }
+
// Emit pre-function debug and/or EH information.
for (const HandlerInfo &HI : Handlers) {
NamedRegionTimer T(HI.TimerName, HI.TimerGroupName, TimePassesIsEnabled);
@@ -867,6 +882,12 @@ void AsmPrinter::EmitFunctionBody() {
// Emit target-specific gunk after the function body.
EmitFunctionBodyEnd();
+ if (!MMI->getLandingPads().empty()) {
+ // Create a symbol for the end of function.
+ CurrentFnEnd = createTempSymbol("eh_func_end", getFunctionNumber());
+ OutStreamer.EmitLabel(CurrentFnEnd);
+ }
+
// If the target wants a .size directive for the size of the function, emit
// it.
if (MAI->hasDotTypeDotSizeDirective()) {
@@ -2273,6 +2294,9 @@ MCSymbol *AsmPrinter::GetTempSymbol(const Twine &Name) const {
Name);
}
+MCSymbol *AsmPrinter::createTempSymbol(const Twine &Name, unsigned ID) const {
+ return OutContext.createTempSymbol(Name + Twine(ID));
+}
MCSymbol *AsmPrinter::GetBlockAddressSymbol(const BlockAddress *BA) const {
return MMI->getAddrLabelSymbol(BA->getBasicBlock());
OpenPOWER on IntegriCloud