[PATCH] Propagate -fno-unwind-tables to EHABI
Renato Golin
renato.golin at linaro.org
Thu Mar 20 09:14:26 PDT 2014
Making the cantunwind decision clearer.
Hi keith.walker.arm, asl, logan, rafael,
http://llvm-reviews.chandlerc.com/D3079
CHANGE SINCE LAST DIFF
http://llvm-reviews.chandlerc.com/D3079?vs=7942&id=7989#toc
Files:
include/llvm/CodeGen/AsmPrinter.h
lib/CodeGen/AsmPrinter/ARMException.cpp
lib/CodeGen/AsmPrinter/AsmPrinter.cpp
lib/CodeGen/AsmPrinter/DwarfException.h
lib/CodeGen/AsmPrinter/Win64Exception.cpp
lib/Target/ARM/ARMAsmPrinter.cpp
Index: include/llvm/CodeGen/AsmPrinter.h
===================================================================
--- include/llvm/CodeGen/AsmPrinter.h
+++ include/llvm/CodeGen/AsmPrinter.h
@@ -219,7 +219,8 @@
};
CFIMoveType needsCFIMoves();
- bool needsSEHMoves();
+ /// True if the function needs unwinding of Type provided
+ bool needsEHMoves(unsigned EHType);
/// EmitConstantPool - Print to the current output stream assembly
/// representations of the constants in the constant pool MCP. This is
Index: lib/CodeGen/AsmPrinter/ARMException.cpp
===================================================================
--- lib/CodeGen/AsmPrinter/ARMException.cpp
+++ lib/CodeGen/AsmPrinter/ARMException.cpp
@@ -38,6 +38,7 @@
ARMException::ARMException(AsmPrinter *A)
: DwarfException(A),
+ shouldEmitEH(false),
shouldEmitCFI(false) {}
ARMException::~ARMException() {}
@@ -57,10 +58,19 @@
/// beginFunction - Gather pre-function exception information. Assumes it's
/// being emitted immediately after the function entry point.
void ARMException::beginFunction(const MachineFunction *MF) {
- getTargetStreamer().emitFnStart();
- if (Asm->MF->getFunction()->needsUnwindTableEntry())
- Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("eh_func_begin",
- Asm->getFunctionNumber()));
+ // FIXME: Change Function::needsUnwindTableEntry() and update other targets
+ shouldEmitEH = Asm->needsEHMoves(ExceptionHandling::ARM) ||
+ Asm->MF->getFunction()->doesNotThrow();
+ // FIXME: This should be based on EH tables, not the lack of UW tables.
+ shouldEmitCantUnwind = !Asm->MF->getFunction()->hasUWTable() &&
+ Asm->MF->getFunction()->doesNotThrow();
+
+ if (shouldEmitEH) {
+ getTargetStreamer().emitFnStart();
+ if (Asm->MF->getFunction()->needsUnwindTableEntry())
+ Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("eh_func_begin",
+ Asm->getFunctionNumber()));
+ }
// See if we need call frame info.
AsmPrinter::CFIMoveType MoveType = Asm->needsCFIMoves();
assert(MoveType != AsmPrinter::CFI_M_EH &&
@@ -77,8 +87,11 @@
if (shouldEmitCFI)
Asm->OutStreamer.EmitCFIEndProc();
+ if (!shouldEmitEH)
+ return;
+
ARMTargetStreamer &ATS = getTargetStreamer();
- if (!Asm->MF->getFunction()->needsUnwindTableEntry())
+ if (shouldEmitCantUnwind)
ATS.emitCantUnwind();
else {
Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("eh_func_end",
Index: lib/CodeGen/AsmPrinter/AsmPrinter.cpp
===================================================================
--- lib/CodeGen/AsmPrinter/AsmPrinter.cpp
+++ lib/CodeGen/AsmPrinter/AsmPrinter.cpp
@@ -681,22 +681,21 @@
return true;
}
+bool AsmPrinter::needsEHMoves(unsigned EHType) {
+ return (MAI->getExceptionHandlingType() == EHType &&
+ MF->getFunction()->needsUnwindTableEntry());
+}
+
AsmPrinter::CFIMoveType AsmPrinter::needsCFIMoves() {
- if (MAI->getExceptionHandlingType() == ExceptionHandling::DwarfCFI &&
- MF->getFunction()->needsUnwindTableEntry())
+ if (needsEHMoves(ExceptionHandling::DwarfCFI))
return CFI_M_EH;
if (MMI->hasDebugInfo())
return CFI_M_Debug;
return CFI_M_None;
}
-bool AsmPrinter::needsSEHMoves() {
- return MAI->getExceptionHandlingType() == ExceptionHandling::Win64 &&
- MF->getFunction()->needsUnwindTableEntry();
-}
-
void AsmPrinter::emitCFIInstruction(const MachineInstr &MI) {
ExceptionHandling::ExceptionsType ExceptionHandlingType =
MAI->getExceptionHandlingType();
Index: lib/CodeGen/AsmPrinter/DwarfException.h
===================================================================
--- lib/CodeGen/AsmPrinter/DwarfException.h
+++ lib/CodeGen/AsmPrinter/DwarfException.h
@@ -183,9 +183,16 @@
void EmitTypeInfos(unsigned TTypeEncoding) override;
ARMTargetStreamer &getTargetStreamer();
+ /// shouldEmitEH - Per-function flag to indicate if frame EH info
+ /// should be emitted.
+ bool shouldEmitEH;
/// shouldEmitCFI - Per-function flag to indicate if frame CFI info
/// should be emitted.
bool shouldEmitCFI;
+ /// emitCantUnwind - Per-function flag to indicate if frame EH info
+ /// should be emitted with CantUnwind. FIXME: Not enough IR information
+ /// to take that decision correctly from the function attributes.
+ bool shouldEmitCantUnwind;
public:
//===--------------------------------------------------------------------===//
Index: lib/CodeGen/AsmPrinter/Win64Exception.cpp
===================================================================
--- lib/CodeGen/AsmPrinter/Win64Exception.cpp
+++ lib/CodeGen/AsmPrinter/Win64Exception.cpp
@@ -57,7 +57,7 @@
// If any landing pads survive, we need an EH table.
bool hasLandingPads = !MMI->getLandingPads().empty();
- shouldEmitMoves = Asm->needsSEHMoves();
+ shouldEmitMoves = Asm->needsEHMoves(ExceptionHandling::Win64);
const TargetLoweringObjectFile &TLOF = Asm->getObjFileLowering();
unsigned PerEncoding = TLOF.getPersonalityEncoding();
Index: lib/Target/ARM/ARMAsmPrinter.cpp
===================================================================
--- lib/Target/ARM/ARMAsmPrinter.cpp
+++ lib/Target/ARM/ARMAsmPrinter.cpp
@@ -907,6 +907,9 @@
assert(MI->getFlag(MachineInstr::FrameSetup) &&
"Only instruction which are involved into frame setup code are allowed");
+ if (!MF->getFunction()->needsUnwindTableEntry())
+ return;
+
MCTargetStreamer &TS = *OutStreamer.getTargetStreamer();
ARMTargetStreamer &ATS = static_cast<ARMTargetStreamer &>(TS);
const MachineFunction &MF = *MI->getParent()->getParent();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D3079.3.patch
Type: text/x-patch
Size: 5700 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140320/1a12ab73/attachment.bin>
More information about the llvm-commits
mailing list