Skip to content

Commit

Permalink
Use NoMerge condition per Vitaly's feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
thurstond committed Nov 26, 2024
1 parent 7fec45e commit ee1c299
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions clang/lib/CodeGen/CGExpr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3905,9 +3905,11 @@ void CodeGenFunction::EmitTrapCheck(llvm::Value *Checked,

llvm::BasicBlock *&TrapBB = TrapBBs[CheckHandlerID];

if (!ClSanitizeDebugDeoptimization &&
CGM.getCodeGenOpts().OptimizationLevel && TrapBB &&
(!CurCodeDecl || !CurCodeDecl->hasAttr<OptimizeNoneAttr>())) {
bool NoMerge = ClSanitizeDebugDeoptimization ||
!CGM.getCodeGenOpts().OptimizationLevel ||
(CurCodeDecl && CurCodeDecl->hasAttr<OptimizeNoneAttr>());

if (TrapBB && !NoMerge) {
auto Call = TrapBB->begin();
assert(isa<llvm::CallInst>(Call) && "Expected call in trap BB");

Expand All @@ -3928,10 +3930,8 @@ void CodeGenFunction::EmitTrapCheck(llvm::Value *Checked,
CGM.getCodeGenOpts().TrapFuncName);
TrapCall->addFnAttr(A);
}
// We unconditionally add NoMerge, even if this is the first time we've
// seen this type of trap in this function. This is necessary because
// inlining may occur in later stages.
TrapCall->addFnAttr(llvm::Attribute::NoMerge);
if (NoMerge)
TrapCall->addFnAttr(llvm::Attribute::NoMerge);
TrapCall->setDoesNotReturn();
TrapCall->setDoesNotThrow();
Builder.CreateUnreachable();
Expand Down

0 comments on commit ee1c299

Please sign in to comment.