Skip to content

Commit e49834b

Browse files
committed
Revert "Don't apply nomerge for the first instance of each TrapBB type, per"
This reverts commit 5107ce194c9b03c2f32eb1508df0c92b13b3e2fd. Doesn't work because CodeGen happens before inlining, so the ubsantraps in functions f(), g() and m() will not have nomerge.
1 parent c7fb7d5 commit e49834b

File tree

2 files changed

+3
-6
lines changed

2 files changed

+3
-6
lines changed

clang/lib/CodeGen/CGExpr.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3915,7 +3915,6 @@ void CodeGenFunction::EmitTrapCheck(llvm::Value *Checked,
39153915
Builder.getCurrentDebugLocation());
39163916
Builder.CreateCondBr(Checked, Cont, TrapBB);
39173917
} else {
3918-
bool NewTrapBB = (TrapBB == nullptr);
39193918
TrapBB = createBasicBlock("trap");
39203919
Builder.CreateCondBr(Checked, Cont, TrapBB);
39213920
EmitBlock(TrapBB);
@@ -3929,8 +3928,7 @@ void CodeGenFunction::EmitTrapCheck(llvm::Value *Checked,
39293928
CGM.getCodeGenOpts().TrapFuncName);
39303929
TrapCall->addFnAttr(A);
39313930
}
3932-
if (!NewTrapBB)
3933-
TrapCall->addFnAttr(llvm::Attribute::NoMerge);
3931+
TrapCall->addFnAttr(llvm::Attribute::NoMerge);
39343932
TrapCall->setDoesNotReturn();
39353933
TrapCall->setDoesNotThrow();
39363934
Builder.CreateUnreachable();

clang/test/CodeGen/ubsan-trap-merge.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ int g(int x) {
5555
// CHECK-NEXT: [[TMP3:%.*]] = extractvalue { i32, i1 } [[TMP2]], 1, !nosanitize [[META2]]
5656
// CHECK-NEXT: br i1 [[TMP3]], label %[[TRAP1:.*]], label %[[CONT2:.*]], !nosanitize [[META2]]
5757
// CHECK: [[TRAP1]]:
58-
// CHECK-NEXT: tail call void @llvm.ubsantrap(i8 0) #[[ATTR5:[0-9]+]], !nosanitize [[META2]]
58+
// CHECK-NEXT: tail call void @llvm.ubsantrap(i8 0) #[[ATTR4]], !nosanitize [[META2]]
5959
// CHECK-NEXT: unreachable, !nosanitize [[META2]]
6060
// CHECK: [[CONT2]]:
6161
// CHECK-NEXT: [[TMP4:%.*]] = extractvalue { i32, i1 } [[TMP2]], 0, !nosanitize [[META2]]
@@ -102,5 +102,4 @@ int m(int x, int y) {
102102
return f(x) + g(y);
103103
}
104104
//.
105-
// CHECK: attributes #[[ATTR4]] = { noreturn nounwind }
106-
// CHECK: attributes #[[ATTR5]] = { nomerge noreturn nounwind }
105+
// CHECK: attributes #[[ATTR4]] = { nomerge noreturn nounwind }

0 commit comments

Comments
 (0)