This reverts commit 2691b96415. This
reapply fixes the buildbot breakage of the original patch, by updating
clang/test/CodeGen/ubsan-trap-debugloc.c to specify -fsanitize-merge
(the default, which is merge, is applied by the driver but not
clang_cc1).
This reapply also expands clang/test/CodeGen/ubsan-trap-merge.c.
----
Original commit message:
'-mllvm -ubsan-unique-traps'
(https://github.com/llvm/llvm-project/pull/65972) applies to all UBSan
checks. This patch introduces -fsanitize-merge (defaults to on,
maintaining the status quo behavior) and -fno-sanitize-merge (equivalent
to '-mllvm -ubsan-unique-traps'), with the option to selectively
applying non-merged handlers to a subset of UBSan checks (e.g.,
-fno-sanitize-merge=bool,enum).
N.B. we do not use "trap" in the argument name since
https://github.com/llvm/llvm-project/pull/119302 has generalized
-ubsan-unique-traps to work for non-trap modes (min-rt and regular rt).
This patch does not remove the -ubsan-unique-traps flag; that will
override -f(no-)sanitize-merge.
25 lines
952 B
C
25 lines
952 B
C
// RUN: %clang_cc1 -emit-llvm -disable-llvm-passes -O -fsanitize=signed-integer-overflow -fsanitize-trap=signed-integer-overflow -fsanitize-merge=signed-integer-overflow %s -o - -debug-info-kind=line-tables-only | FileCheck %s
|
|
|
|
|
|
void foo(volatile int a) {
|
|
// CHECK-LABEL: @foo
|
|
// CHECK: call void @llvm.ubsantrap(i8 0){{.*}} !dbg [[LOC:![0-9]+]]
|
|
a = a + 1;
|
|
a = a + 1;
|
|
}
|
|
|
|
void bar(volatile int a) __attribute__((optnone)) {
|
|
// CHECK-LABEL: @bar
|
|
// CHECK: call void @llvm.ubsantrap(i8 0){{.*}} !dbg [[LOC2:![0-9]+]]
|
|
// CHECK: call void @llvm.ubsantrap(i8 0){{.*}} !dbg [[LOC3:![0-9]+]]
|
|
a = a + 1;
|
|
a = a + 1;
|
|
}
|
|
|
|
// With optimisations enabled the traps are merged and need to share a debug location
|
|
// CHECK: [[LOC]] = !DILocation(line: 0
|
|
|
|
// With optimisations disabled the traps are not merged and retain accurate debug locations
|
|
// CHECK: [[LOC2]] = !DILocation(line: 15, column: 9
|
|
// CHECK: [[LOC3]] = !DILocation(line: 16, column: 9
|