diff options
author | Yaron Keren <yaron.keren@gmail.com> | 2014-04-19 13:47:43 +0000 |
---|---|---|
committer | Yaron Keren <yaron.keren@gmail.com> | 2014-04-19 13:47:43 +0000 |
commit | d7ba46b287c29f8b188a6515f3911bb7817a455d (patch) | |
tree | b65dba085b0487fb80ee68d4e971a6eaf701003c /llvm/lib/Target/X86/X86TargetMachine.cpp | |
parent | 421304d18c2dba1bd6fa976b205f5c15196720a0 (diff) | |
download | bcm5719-llvm-d7ba46b287c29f8b188a6515f3911bb7817a455d.tar.gz bcm5719-llvm-d7ba46b287c29f8b188a6515f3911bb7817a455d.zip |
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.
llvm-svn: 206684
Diffstat (limited to 'llvm/lib/Target/X86/X86TargetMachine.cpp')
-rw-r--r-- | llvm/lib/Target/X86/X86TargetMachine.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/llvm/lib/Target/X86/X86TargetMachine.cpp b/llvm/lib/Target/X86/X86TargetMachine.cpp index 6f09ccf0cec..cb5ab0dd502 100644 --- a/llvm/lib/Target/X86/X86TargetMachine.cpp +++ b/llvm/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(); } |