Index: lib/CodeGen/CGExpr.cpp =================================================================== --- lib/CodeGen/CGExpr.cpp +++ lib/CodeGen/CGExpr.cpp @@ -2535,19 +2535,24 @@ void CodeGenFunction::EmitTrapCheck(llvm::Value *Checked) { llvm::BasicBlock *Cont = createBasicBlock("cont"); + // Collapsing all calls to trap down to one per function makes debugging + // these issues much more difficult. Eliminating this optimization for now, + // with the thought that control by either a debug flag or tying it to an + // optimization level/sanitizer may be a decent path for the future. + // RE: Bug: 25682 // If we're optimizing, collapse all calls to trap down to just one per // function to save on code size. - if (!CGM.getCodeGenOpts().OptimizationLevel || !TrapBB) { - TrapBB = createBasicBlock("trap"); - Builder.CreateCondBr(Checked, Cont, TrapBB); - EmitBlock(TrapBB); - llvm::CallInst *TrapCall = EmitTrapCall(llvm::Intrinsic::trap); - TrapCall->setDoesNotReturn(); - TrapCall->setDoesNotThrow(); - Builder.CreateUnreachable(); - } else { - Builder.CreateCondBr(Checked, Cont, TrapBB); - } + // if (!CGM.getCodeGenOpts().OptimizationLevel || !TrapBB) { + TrapBB = createBasicBlock("trap"); + Builder.CreateCondBr(Checked, Cont, TrapBB); + EmitBlock(TrapBB); + llvm::CallInst *TrapCall = EmitTrapCall(llvm::Intrinsic::trap); + TrapCall->setDoesNotReturn(); + TrapCall->setDoesNotThrow(); + Builder.CreateUnreachable(); + //} else { + //Builder.CreateCondBr(Checked, Cont, TrapBB); + //} EmitBlock(Cont); }