Patch by Vadim Chugunov
[oota-llvm.git] / lib / Target / X86 / X86TargetMachine.cpp
index 6f09ccf0cec2829125e497b6ef3dc90b6291496f..cb5ab0dd50200e337a8c3531c0a7882829f839b6 100644 (file)
@@ -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();
 }