@@ -3546,7 +3546,7 @@ static void emitCheckHandlerCall(CodeGenFunction &CGF,
35463546 ArrayRef<llvm::Value *> FnArgs,
35473547 SanitizerHandler CheckHandler,
35483548 CheckRecoverableKind RecoverKind, bool IsFatal,
3549- llvm::BasicBlock *ContBB, bool NoMerge ) {
3549+ llvm::BasicBlock *ContBB) {
35503550 assert (IsFatal || RecoverKind != CheckRecoverableKind::Unrecoverable);
35513551 std::optional<ApplyDebugLocation> DL;
35523552 if (!CGF.Builder .getCurrentDebugLocation ()) {
@@ -3581,9 +3581,10 @@ static void emitCheckHandlerCall(CodeGenFunction &CGF,
35813581 llvm::AttributeList::FunctionIndex, B),
35823582 /* Local=*/ true );
35833583 llvm::CallInst *HandlerCall = CGF.EmitNounwindRuntimeCall (Fn, FnArgs);
3584- NoMerge = NoMerge || ClSanitizeDebugDeoptimization ||
3585- !CGF.CGM .getCodeGenOpts ().OptimizationLevel ||
3586- (CGF.CurCodeDecl && CGF.CurCodeDecl ->hasAttr <OptimizeNoneAttr>());
3584+ bool NoMerge =
3585+ ClSanitizeDebugDeoptimization ||
3586+ !CGF.CGM .getCodeGenOpts ().OptimizationLevel ||
3587+ (CGF.CurCodeDecl && CGF.CurCodeDecl ->hasAttr <OptimizeNoneAttr>());
35873588 if (NoMerge)
35883589 HandlerCall->addFnAttr (llvm::Attribute::NoMerge);
35893590 if (!MayReturn) {
@@ -3607,7 +3608,6 @@ void CodeGenFunction::EmitCheck(
36073608 llvm::Value *FatalCond = nullptr ;
36083609 llvm::Value *RecoverableCond = nullptr ;
36093610 llvm::Value *TrapCond = nullptr ;
3610- bool NoMerge = false ;
36113611 for (int i = 0 , n = Checked.size (); i < n; ++i) {
36123612 llvm::Value *Check = Checked[i].first ;
36133613 // -fsanitize-trap= overrides -fsanitize-recover=.
@@ -3618,9 +3618,6 @@ void CodeGenFunction::EmitCheck(
36183618 ? RecoverableCond
36193619 : FatalCond;
36203620 Cond = Cond ? Builder.CreateAnd (Cond, Check) : Check;
3621-
3622- if (!CGM.getCodeGenOpts ().SanitizeMergeHandlers .has (Checked[i].second ))
3623- NoMerge = true ;
36243621 }
36253622
36263623 if (ClSanitizeGuardChecks) {
@@ -3635,7 +3632,7 @@ void CodeGenFunction::EmitCheck(
36353632 }
36363633
36373634 if (TrapCond)
3638- EmitTrapCheck (TrapCond, CheckHandler, NoMerge );
3635+ EmitTrapCheck (TrapCond, CheckHandler);
36393636 if (!FatalCond && !RecoverableCond)
36403637 return ;
36413638
@@ -3701,7 +3698,7 @@ void CodeGenFunction::EmitCheck(
37013698 // Simple case: we need to generate a single handler call, either
37023699 // fatal, or non-fatal.
37033700 emitCheckHandlerCall (*this , FnType, Args, CheckHandler, RecoverKind,
3704- (FatalCond != nullptr ), Cont, NoMerge );
3701+ (FatalCond != nullptr ), Cont);
37053702 } else {
37063703 // Emit two handler calls: first one for set of unrecoverable checks,
37073704 // another one for recoverable.
@@ -3711,10 +3708,10 @@ void CodeGenFunction::EmitCheck(
37113708 Builder.CreateCondBr (FatalCond, NonFatalHandlerBB, FatalHandlerBB);
37123709 EmitBlock (FatalHandlerBB);
37133710 emitCheckHandlerCall (*this , FnType, Args, CheckHandler, RecoverKind, true ,
3714- NonFatalHandlerBB, NoMerge );
3711+ NonFatalHandlerBB);
37153712 EmitBlock (NonFatalHandlerBB);
37163713 emitCheckHandlerCall (*this , FnType, Args, CheckHandler, RecoverKind, false ,
3717- Cont, NoMerge );
3714+ Cont);
37183715 }
37193716
37203717 EmitBlock (Cont);
@@ -3904,8 +3901,7 @@ void CodeGenFunction::EmitUnreachable(SourceLocation Loc) {
39043901}
39053902
39063903void CodeGenFunction::EmitTrapCheck (llvm::Value *Checked,
3907- SanitizerHandler CheckHandlerID,
3908- bool NoMerge) {
3904+ SanitizerHandler CheckHandlerID) {
39093905 llvm::BasicBlock *Cont = createBasicBlock (" cont" );
39103906
39113907 // If we're optimizing, collapse all calls to trap down to just one per
@@ -3915,9 +3911,9 @@ void CodeGenFunction::EmitTrapCheck(llvm::Value *Checked,
39153911
39163912 llvm::BasicBlock *&TrapBB = TrapBBs[CheckHandlerID];
39173913
3918- NoMerge = NoMerge || ClSanitizeDebugDeoptimization ||
3919- !CGM.getCodeGenOpts ().OptimizationLevel ||
3920- (CurCodeDecl && CurCodeDecl->hasAttr <OptimizeNoneAttr>());
3914+ bool NoMerge = ClSanitizeDebugDeoptimization ||
3915+ !CGM.getCodeGenOpts ().OptimizationLevel ||
3916+ (CurCodeDecl && CurCodeDecl->hasAttr <OptimizeNoneAttr>());
39213917
39223918 if (TrapBB && !NoMerge) {
39233919 auto Call = TrapBB->begin ();
0 commit comments