[X86] Fix an unused variable warning in released builds.
[oota-llvm.git] / lib / Target / X86 / X86TargetMachine.cpp
index d318244e0f70710ac78b5e32b9eaad3adf36fd19..0e7e4c0c84a96d725c61e88c1cb16d9f4583b69a 100644 (file)
@@ -110,6 +110,13 @@ X86TargetMachine::X86TargetMachine(const Target &T, const Triple &TT,
                         OL),
       TLOF(createTLOF(getTargetTriple())),
       Subtarget(TT, CPU, FS, *this, Options.StackAlignmentOverride) {
+  // 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;
+
   // By default (and when -ffast-math is on), enable estimate codegen for
   // everything except scalar division. By default, use 1 refinement step for
   // all operations. Defaults may be overridden by using command-line options.
@@ -247,6 +254,9 @@ bool X86PassConfig::addPreISel() {
 }
 
 void X86PassConfig::addPreRegAlloc() {
+  if (getOptLevel() != CodeGenOpt::None)
+    addPass(createX86OptimizeLEAs());
+
   addPass(createX86CallFrameOptimization());
 }