diff options
author | Vitaly Buka <vitalybuka@google.com> | 2024-03-11 12:07:28 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-11 12:07:28 -0700 |
commit | eaa71a97f9155ea9df33141ef2fb369dc8fc464f (patch) | |
tree | 1c9341938fe2d83bc0fdb2a50404735d079fec0b /clang/test | |
parent | 08a9207f947b8b022d70f8ee7eeeda7acc6aac76 (diff) | |
download | llvm-eaa71a97f9155ea9df33141ef2fb369dc8fc464f.zip llvm-eaa71a97f9155ea9df33141ef2fb369dc8fc464f.tar.gz llvm-eaa71a97f9155ea9df33141ef2fb369dc8fc464f.tar.bz2 |
[clang] Add optional pass to remove UBSAN traps using PGO (#84214)
With #83471 it reduces UBSAN overhead from 44% to 6%.
Measured as "Geomean difference" on "test-suite/MultiSource/Benchmarks"
with PGO build.
On real large server binary we see 95% of code is still instrumented,
with 10% -> 1.5% UBSAN overhead improvements. We can pass this test only
with subset of UBSAN, so base overhead is smaller.
We have followup patches to improve it even further.
Diffstat (limited to 'clang/test')
-rw-r--r-- | clang/test/CodeGen/remote-traps.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/clang/test/CodeGen/remote-traps.c b/clang/test/CodeGen/remote-traps.c new file mode 100644 index 0000000..f053d1b --- /dev/null +++ b/clang/test/CodeGen/remote-traps.c @@ -0,0 +1,15 @@ +// RUN: %clang_cc1 -O1 -emit-llvm -fsanitize=signed-integer-overflow -fsanitize-trap=signed-integer-overflow %s -o - | FileCheck %s +// RUN: %clang_cc1 -O1 -emit-llvm -fsanitize=signed-integer-overflow -fsanitize-trap=signed-integer-overflow -mllvm -clang-remove-traps -mllvm -remove-traps-random-rate=1 %s -o - | FileCheck %s --implicit-check-not="call void @llvm.ubsantrap" --check-prefixes=REMOVE + +int f(int x) { + return x + 123; +} + +// CHECK-LABEL: define dso_local noundef i32 @f( +// CHECK: call { i32, i1 } @llvm.sadd.with.overflow.i32( +// CHECK: trap: +// CHECK-NEXT: call void @llvm.ubsantrap(i8 0) +// CHECK-NEXT: unreachable + +// REMOVE-LABEL: define dso_local noundef i32 @f( +// REMOVE: call { i32, i1 } @llvm.sadd.with.overflow.i32( |