Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ubsan] Change ubsan-unique-traps to use nomerge instead of counter #117651

Merged
merged 16 commits into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Revert "Don't apply nomerge for the first instance of each TrapBB typ…
…e, per"

This reverts commit 5107ce1.

Doesn't work because CodeGen happens before inlining, so the ubsantraps in functions f(), g() and m() will not have nomerge.
  • Loading branch information
thurstond committed Nov 26, 2024
commit e752957962a38b4c7f3091ebe7304e88cb217610
4 changes: 1 addition & 3 deletions clang/lib/CodeGen/CGExpr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3915,7 +3915,6 @@ void CodeGenFunction::EmitTrapCheck(llvm::Value *Checked,
Builder.getCurrentDebugLocation());
Builder.CreateCondBr(Checked, Cont, TrapBB);
} else {
bool NewTrapBB = (TrapBB == nullptr);
TrapBB = createBasicBlock("trap");
Builder.CreateCondBr(Checked, Cont, TrapBB);
EmitBlock(TrapBB);
Expand All @@ -3929,8 +3928,7 @@ void CodeGenFunction::EmitTrapCheck(llvm::Value *Checked,
CGM.getCodeGenOpts().TrapFuncName);
TrapCall->addFnAttr(A);
}
if (!NewTrapBB)
TrapCall->addFnAttr(llvm::Attribute::NoMerge);
TrapCall->addFnAttr(llvm::Attribute::NoMerge);
vitalybuka marked this conversation as resolved.
Show resolved Hide resolved
TrapCall->setDoesNotReturn();
TrapCall->setDoesNotThrow();
Builder.CreateUnreachable();
Expand Down
5 changes: 2 additions & 3 deletions clang/test/CodeGen/ubsan-trap-merge.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ int g(int x) {
// CHECK-NEXT: [[TMP3:%.*]] = extractvalue { i32, i1 } [[TMP2]], 1, !nosanitize [[META2]]
// CHECK-NEXT: br i1 [[TMP3]], label %[[TRAP1:.*]], label %[[CONT2:.*]], !nosanitize [[META2]]
// CHECK: [[TRAP1]]:
// CHECK-NEXT: tail call void @llvm.ubsantrap(i8 0) #[[ATTR5:[0-9]+]], !nosanitize [[META2]]
// CHECK-NEXT: tail call void @llvm.ubsantrap(i8 0) #[[ATTR4]], !nosanitize [[META2]]
// CHECK-NEXT: unreachable, !nosanitize [[META2]]
// CHECK: [[CONT2]]:
// CHECK-NEXT: [[TMP4:%.*]] = extractvalue { i32, i1 } [[TMP2]], 0, !nosanitize [[META2]]
Expand Down Expand Up @@ -102,5 +102,4 @@ int m(int x, int y) {
return f(x) + g(y);
}
//.
// CHECK: attributes #[[ATTR4]] = { noreturn nounwind }
// CHECK: attributes #[[ATTR5]] = { nomerge noreturn nounwind }
// CHECK: attributes #[[ATTR4]] = { nomerge noreturn nounwind }