diff options
author | Joerg Sonnenberger <joerg@bec.de> | 2017-01-02 18:05:27 +0000 |
---|---|---|
committer | Joerg Sonnenberger <joerg@bec.de> | 2017-01-02 18:05:27 +0000 |
commit | 7b83732a4025b5a3c652bfb585628104d995df8d (patch) | |
tree | 9099e67ddd72dbb8aeef58aa233333b08a806b93 /llvm/lib/CodeGen | |
parent | 02c6b176e75c650ed1e312541035cb7c086d4da1 (diff) | |
download | bcm5719-llvm-7b83732a4025b5a3c652bfb585628104d995df8d.tar.gz bcm5719-llvm-7b83732a4025b5a3c652bfb585628104d995df8d.zip |
Emit .cfi_sections before the first .cfi_startproc
GNU as rejects input where .cfi_sections is used after .cfi_startproc,
if the new section differs from the old. Adjust our output to always
emit .cfi_sections before the first .cfi_startproc to minimize necessary
code.
Differential Revision: https://reviews.llvm.org/D28011
llvm-svn: 290817
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/ARMException.cpp | 13 | ||||
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/DwarfCFIException.cpp | 17 | ||||
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/DwarfException.h | 6 |
3 files changed, 17 insertions, 19 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/ARMException.cpp b/llvm/lib/CodeGen/AsmPrinter/ARMException.cpp index fff3f003478..0c79def8793 100644 --- a/llvm/lib/CodeGen/AsmPrinter/ARMException.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/ARMException.cpp @@ -43,13 +43,6 @@ ARMTargetStreamer &ARMException::getTargetStreamer() { return static_cast<ARMTargetStreamer &>(TS); } -/// endModule - Emit all exception information that should come after the -/// content. -void ARMException::endModule() { - if (shouldEmitCFI) - Asm->OutStreamer->EmitCFISections(false, true); -} - void ARMException::beginFunction(const MachineFunction *MF) { if (Asm->MAI->getExceptionHandlingType() == ExceptionHandling::ARM) getTargetStreamer().emitFnStart(); @@ -57,7 +50,13 @@ void ARMException::beginFunction(const MachineFunction *MF) { AsmPrinter::CFIMoveType MoveType = Asm->needsCFIMoves(); assert(MoveType != AsmPrinter::CFI_M_EH && "non-EH CFI not yet supported in prologue with EHABI lowering"); + if (MoveType == AsmPrinter::CFI_M_Debug) { + if (!hasEmittedCFISections) { + Asm->OutStreamer->EmitCFISections(false, true); + hasEmittedCFISections = true; + } + shouldEmitCFI = true; Asm->OutStreamer->EmitCFIStartProc(false); } diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfCFIException.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfCFIException.cpp index efe7059a3a0..ef30e279aed 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfCFIException.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfCFIException.cpp @@ -39,7 +39,7 @@ using namespace llvm; DwarfCFIExceptionBase::DwarfCFIExceptionBase(AsmPrinter *A) - : EHStreamer(A), shouldEmitCFI(false) {} + : EHStreamer(A), shouldEmitCFI(false), hasEmittedCFISections(false) {} void DwarfCFIExceptionBase::markFunctionEnd() { endFragment(); @@ -59,7 +59,7 @@ void DwarfCFIExceptionBase::endFragment() { DwarfCFIException::DwarfCFIException(AsmPrinter *A) : DwarfCFIExceptionBase(A), shouldEmitPersonality(false), forceEmitPersonality(false), shouldEmitLSDA(false), - shouldEmitMoves(false), moveTypeModule(AsmPrinter::CFI_M_None) {} + shouldEmitMoves(false) {} DwarfCFIException::~DwarfCFIException() {} @@ -70,9 +70,6 @@ void DwarfCFIException::endModule() { if (!Asm->MAI->usesCFIForEH()) return; - if (moveTypeModule == AsmPrinter::CFI_M_Debug) - Asm->OutStreamer->EmitCFISections(false, true); - const TargetLoweringObjectFile &TLOF = Asm->getObjFileLowering(); unsigned PerEncoding = TLOF.getPersonalityEncoding(); @@ -102,10 +99,6 @@ void DwarfCFIException::beginFunction(const MachineFunction *MF) { // See if we need frame move info. AsmPrinter::CFIMoveType MoveType = Asm->needsCFIMoves(); - if (MoveType == AsmPrinter::CFI_M_EH || - (MoveType == AsmPrinter::CFI_M_Debug && - moveTypeModule == AsmPrinter::CFI_M_None)) - moveTypeModule = MoveType; shouldEmitMoves = MoveType != AsmPrinter::CFI_M_None; @@ -143,6 +136,12 @@ void DwarfCFIException::beginFragment(const MachineBasicBlock *MBB, if (!shouldEmitCFI) return; + if (!hasEmittedCFISections) { + if (Asm->needsCFIMoves() == AsmPrinter::CFI_M_Debug) + Asm->OutStreamer->EmitCFISections(false, true); + hasEmittedCFISections = true; + } + Asm->OutStreamer->EmitCFIStartProc(/*IsSimple=*/false); // Indicate personality routine, if any. diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfException.h b/llvm/lib/CodeGen/AsmPrinter/DwarfException.h index 8287f289f22..80d5bd208ed 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfException.h +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfException.h @@ -28,6 +28,8 @@ protected: /// Per-function flag to indicate if frame CFI info should be emitted. bool shouldEmitCFI; + /// Per-module flag to indicate if .cfi_section has beeen emitted. + bool hasEmittedCFISections; void markFunctionEnd() override; void endFragment() override; @@ -46,8 +48,6 @@ class LLVM_LIBRARY_VISIBILITY DwarfCFIException : public DwarfCFIExceptionBase { /// Per-function flag to indicate if frame moves info should be emitted. bool shouldEmitMoves; - AsmPrinter::CFIMoveType moveTypeModule; - public: //===--------------------------------------------------------------------===// // Main entry points. @@ -81,7 +81,7 @@ public: ~ARMException() override; /// Emit all exception information that should come after the content. - void endModule() override; + void endModule() override {} /// Gather pre-function exception information. Assumes being emitted /// immediately after the function entry point. |