[llvm] r247820 - [WinEH] Skip state numbering when no EH pads are present
Reid Kleckner via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 16 10:19:44 PDT 2015
Author: rnk
Date: Wed Sep 16 12:19:44 2015
New Revision: 247820
URL: http://llvm.org/viewvc/llvm-project?rev=247820&view=rev
Log:
[WinEH] Skip state numbering when no EH pads are present
Otherwise we'd try to emit the thunk that passes the LSDA to
__CxxFrameHandler3. We don't emit the LSDA if there were no landingpads,
so we'd end up with an assembler error when trying to write the COFF
object.
Modified:
llvm/trunk/include/llvm/CodeGen/MachineModuleInfo.h
llvm/trunk/lib/Target/X86/X86WinEHState.cpp
llvm/trunk/test/CodeGen/WinEH/wineh-statenumbering.ll
Modified: llvm/trunk/include/llvm/CodeGen/MachineModuleInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineModuleInfo.h?rev=247820&r1=247819&r2=247820&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/MachineModuleInfo.h (original)
+++ llvm/trunk/include/llvm/CodeGen/MachineModuleInfo.h Wed Sep 16 12:19:44 2015
@@ -252,6 +252,9 @@ public:
bool callsUnwindInit() const { return CallsUnwindInit; }
void setCallsUnwindInit(bool b) { CallsUnwindInit = b; }
+ bool hasEHFunclets() const { return HasEHFunclets; }
+ void setHasEHFunclets(bool V) { HasEHFunclets = V; }
+
bool usesVAFloatArgument() const {
return UsesVAFloatArgument;
}
@@ -365,12 +368,6 @@ public:
return LandingPads;
}
- bool hasEHFunclets() const {
- return HasEHFunclets;
- }
-
- void setHasEHFunclets(bool V) { HasEHFunclets = true; }
-
/// setCallSiteLandingPad - Map the landing pad's EH symbol to the call
/// site indexes.
void setCallSiteLandingPad(MCSymbol *Sym, ArrayRef<unsigned> Sites);
Modified: llvm/trunk/lib/Target/X86/X86WinEHState.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86WinEHState.cpp?rev=247820&r1=247819&r2=247820&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86WinEHState.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86WinEHState.cpp Wed Sep 16 12:19:44 2015
@@ -167,6 +167,20 @@ bool WinEHStatePass::runOnFunction(Funct
if (!isMSVCEHPersonality(Personality))
return false;
+ // 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;
+ }
+ }
+ 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
// use an arbitrary register?
Modified: llvm/trunk/test/CodeGen/WinEH/wineh-statenumbering.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/WinEH/wineh-statenumbering.ll?rev=247820&r1=247819&r2=247820&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/WinEH/wineh-statenumbering.ll (original)
+++ llvm/trunk/test/CodeGen/WinEH/wineh-statenumbering.ll Wed Sep 16 12:19:44 2015
@@ -82,6 +82,14 @@ unreachable.for.entry:
unreachable
}
+define i32 @nopads() #0 personality i32 (...)* @__CxxFrameHandler3 {
+ ret i32 0
+}
+
+; CHECK-LABEL: define i32 @nopads()
+; CHECK-NEXT: ret i32 0
+; CHECK-NOT: __ehhandler$nopads
+
declare void @g(i32) #0
declare x86_stdcallcc void @_CxxThrowException(i8*, %eh.ThrowInfo*)
More information about the llvm-commits
mailing list