summaryrefslogtreecommitdiff
path: root/lib/Target/X86/X86TargetMachine.cpp
diff options
context:
space:
mode:
authorYaron Keren <yaron.keren@gmail.com>2014-04-19 13:47:43 +0000
committerYaron Keren <yaron.keren@gmail.com>2014-04-19 13:47:43 +0000
commit64b2297786f7fd6f5fa24cdd4db0298fbf211466 (patch)
treec5250834c0fd832fbdb7363822269f603cee844f /lib/Target/X86/X86TargetMachine.cpp
parent2fa9e6ca34a1f696904c0b8006c91d64679c2b51 (diff)
downloadllvm-64b2297786f7fd6f5fa24cdd4db0298fbf211466.tar.gz
llvm-64b2297786f7fd6f5fa24cdd4db0298fbf211466.tar.bz2
llvm-64b2297786f7fd6f5fa24cdd4db0298fbf211466.tar.xz
Patch by Vadim Chugunov
Win64 stack unwinder gets confused when execution flow "falls through" after a call to 'noreturn' function. This fixes the "missing epilogue" problem by emitting a trap instruction for IR 'unreachable' on x86_x64-pc-windows. A secondary use for it would be for anyone wanting to make double-sure that 'noreturn' functions, indeed, do not return. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@206684 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/X86/X86TargetMachine.cpp')
-rw-r--r--lib/Target/X86/X86TargetMachine.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/Target/X86/X86TargetMachine.cpp b/lib/Target/X86/X86TargetMachine.cpp
index 6f09ccf0ce..cb5ab0dd50 100644
--- a/lib/Target/X86/X86TargetMachine.cpp
+++ b/lib/Target/X86/X86TargetMachine.cpp
@@ -108,6 +108,13 @@ X86TargetMachine::X86TargetMachine(const Target &T, StringRef TT,
if (Options.FloatABIType == FloatABI::Default)
this->Options.FloatABIType = FloatABI::Hard;
+ // Windows stack unwinder gets confused when execution flow "falls through"
+ // after a call to 'noreturn' function.
+ // To prevent that, we emit a trap for 'unreachable' IR instructions.
+ // (which on X86, happens to be the 'ud2' instruction)
+ if (Subtarget.isTargetWin64())
+ this->Options.TrapUnreachable = true;
+
initAsmInfo();
}