Skip to content

Commit 0d15d46

Browse files
authored
[ubsan] Change ubsan-unique-traps to use nomerge instead of counter (#117651)
#65972 (continuation of https://reviews.llvm.org/D148654) had considered adding nomerge to ubsantrap, but did not proceed with that because of #53011. Instead, it added a counter (based on TrapBB->getParent()->size()) to each ubsantrap call. However, this counter is not guaranteed to be unique after inlining, as shown by #83470, which can result in ubsantraps being merged by the backend. #101549 has since fixed the nomerge limitation ("It sets nomerge flag for the node if the instruction has nomerge arrtibute."). This patch therefore takes advantage of nomerge instead of using the counter, guaranteeing that the ubsantraps are not merged. This patch is equivalent to #83470 but also adds nomerge and updates tests (#117649: ubsan-trap-merge.c; #117657: ubsan-trap-merge.ll, ubsan-trap-nomerge.ll; catch-undef-behavior.c).
1 parent bc1e0c5 commit 0d15d46

File tree

6 files changed

+51
-52
lines changed

6 files changed

+51
-52
lines changed

clang/lib/CodeGen/CGExpr.cpp

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3905,9 +3905,11 @@ void CodeGenFunction::EmitTrapCheck(llvm::Value *Checked,
39053905

39063906
llvm::BasicBlock *&TrapBB = TrapBBs[CheckHandlerID];
39073907

3908-
if (!ClSanitizeDebugDeoptimization &&
3909-
CGM.getCodeGenOpts().OptimizationLevel && TrapBB &&
3910-
(!CurCodeDecl || !CurCodeDecl->hasAttr<OptimizeNoneAttr>())) {
3908+
bool NoMerge = ClSanitizeDebugDeoptimization ||
3909+
!CGM.getCodeGenOpts().OptimizationLevel ||
3910+
(CurCodeDecl && CurCodeDecl->hasAttr<OptimizeNoneAttr>());
3911+
3912+
if (TrapBB && !NoMerge) {
39113913
auto Call = TrapBB->begin();
39123914
assert(isa<llvm::CallInst>(Call) && "Expected call in trap BB");
39133915

@@ -3919,18 +3921,17 @@ void CodeGenFunction::EmitTrapCheck(llvm::Value *Checked,
39193921
Builder.CreateCondBr(Checked, Cont, TrapBB);
39203922
EmitBlock(TrapBB);
39213923

3922-
llvm::CallInst *TrapCall = Builder.CreateCall(
3923-
CGM.getIntrinsic(llvm::Intrinsic::ubsantrap),
3924-
llvm::ConstantInt::get(CGM.Int8Ty,
3925-
ClSanitizeDebugDeoptimization
3926-
? TrapBB->getParent()->size()
3927-
: static_cast<uint64_t>(CheckHandlerID)));
3924+
llvm::CallInst *TrapCall =
3925+
Builder.CreateCall(CGM.getIntrinsic(llvm::Intrinsic::ubsantrap),
3926+
llvm::ConstantInt::get(CGM.Int8Ty, CheckHandlerID));
39283927

39293928
if (!CGM.getCodeGenOpts().TrapFuncName.empty()) {
39303929
auto A = llvm::Attribute::get(getLLVMContext(), "trap-func-name",
39313930
CGM.getCodeGenOpts().TrapFuncName);
39323931
TrapCall->addFnAttr(A);
39333932
}
3933+
if (NoMerge)
3934+
TrapCall->addFnAttr(llvm::Attribute::NoMerge);
39343935
TrapCall->setDoesNotReturn();
39353936
TrapCall->setDoesNotThrow();
39363937
Builder.CreateUnreachable();

clang/test/CodeGen/bounds-checking.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,11 @@ char B2[10];
7474
// CHECK-LABEL: @f8
7575
void f8(int i, int k) {
7676
// NOOPTLOCAL: call void @llvm.ubsantrap(i8 3)
77-
// NOOPTARRAY: call void @llvm.ubsantrap(i8 2)
77+
// NOOPTARRAY: call void @llvm.ubsantrap(i8 18)
7878
B[i] = '\0';
7979

8080
// NOOPTLOCAL: call void @llvm.ubsantrap(i8 5)
81-
// NOOPTARRAY: call void @llvm.ubsantrap(i8 4)
81+
// NOOPTARRAY: call void @llvm.ubsantrap(i8 18)
8282
B2[k] = '\0';
8383
}
8484

clang/test/CodeGen/catch-undef-behavior.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -470,4 +470,4 @@ void call_nonnull_variadic(int a, int *b) {
470470

471471
// CHECK-UBSAN: ![[WEIGHT_MD]] = !{!"branch_weights", i32 1048575, i32 1}
472472

473-
// CHECK-TRAP: attributes [[NR_NUW]] = { noreturn nounwind }
473+
// CHECK-TRAP: attributes [[NR_NUW]] = { nomerge noreturn nounwind }

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// NOTE: Assertions have mostly been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 5
22
// The most important assertion is the attributes at the end of the file, which
3-
// shows that ubsan does not currently attach 'nomerge'.
3+
// shows that -ubsan-unique-traps attaches 'nomerge' to each ubsantrap intrinsic.
44
//
55
// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -fsanitize=signed-integer-overflow -fsanitize-trap=signed-integer-overflow -O3 -mllvm -ubsan-unique-traps %s -o - \
66
// RUN: | FileCheck %s
@@ -14,7 +14,7 @@
1414
// CHECK-NEXT: [[TMP1:%.*]] = extractvalue { i32, i1 } [[TMP0]], 1, !nosanitize [[META2]]
1515
// CHECK-NEXT: br i1 [[TMP1]], label %[[TRAP:.*]], label %[[CONT:.*]], !nosanitize [[META2]]
1616
// CHECK: [[TRAP]]:
17-
// CHECK-NEXT: tail call void @llvm.ubsantrap(i8 2) #[[ATTR4:[0-9]+]], !nosanitize [[META2]]
17+
// CHECK-NEXT: tail call void @llvm.ubsantrap(i8 0) #[[ATTR4:[0-9]+]], !nosanitize [[META2]]
1818
// CHECK-NEXT: unreachable, !nosanitize [[META2]]
1919
// CHECK: [[CONT]]:
2020
// CHECK-NEXT: [[TMP2:%.*]] = extractvalue { i32, i1 } [[TMP0]], 0, !nosanitize [[META2]]
@@ -31,7 +31,7 @@ int f(int x) {
3131
// CHECK-NEXT: [[TMP1:%.*]] = extractvalue { i32, i1 } [[TMP0]], 1, !nosanitize [[META2]]
3232
// CHECK-NEXT: br i1 [[TMP1]], label %[[TRAP:.*]], label %[[CONT:.*]], !nosanitize [[META2]]
3333
// CHECK: [[TRAP]]:
34-
// CHECK-NEXT: tail call void @llvm.ubsantrap(i8 2) #[[ATTR4]], !nosanitize [[META2]]
34+
// CHECK-NEXT: tail call void @llvm.ubsantrap(i8 0) #[[ATTR4]], !nosanitize [[META2]]
3535
// CHECK-NEXT: unreachable, !nosanitize [[META2]]
3636
// CHECK: [[CONT]]:
3737
// CHECK-NEXT: [[TMP2:%.*]] = extractvalue { i32, i1 } [[TMP0]], 0, !nosanitize [[META2]]
@@ -48,14 +48,14 @@ int g(int x) {
4848
// CHECK-NEXT: [[TMP1:%.*]] = extractvalue { i32, i1 } [[TMP0]], 1, !nosanitize [[META2]]
4949
// CHECK-NEXT: br i1 [[TMP1]], label %[[TRAP:.*]], label %[[CONT:.*]], !nosanitize [[META2]]
5050
// CHECK: [[TRAP]]:
51-
// CHECK-NEXT: tail call void @llvm.ubsantrap(i8 2) #[[ATTR4]], !nosanitize [[META2]]
51+
// CHECK-NEXT: tail call void @llvm.ubsantrap(i8 0) #[[ATTR4]], !nosanitize [[META2]]
5252
// CHECK-NEXT: unreachable, !nosanitize [[META2]]
5353
// CHECK: [[CONT]]:
5454
// CHECK-NEXT: [[TMP2:%.*]] = tail call { i32, i1 } @llvm.sadd.with.overflow.i32(i32 [[Y]], i32 129), !nosanitize [[META2]]
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 4) #[[ATTR4]], !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]]
@@ -76,14 +76,14 @@ int h(int x, int y) {
7676
// CHECK-NEXT: [[TMP1:%.*]] = extractvalue { i32, i1 } [[TMP0]], 1, !nosanitize [[META2]]
7777
// CHECK-NEXT: br i1 [[TMP1]], label %[[TRAP_I:.*]], label %[[F_EXIT:.*]], !nosanitize [[META2]]
7878
// CHECK: [[TRAP_I]]:
79-
// CHECK-NEXT: tail call void @llvm.ubsantrap(i8 2) #[[ATTR4]], !nosanitize [[META2]]
79+
// CHECK-NEXT: tail call void @llvm.ubsantrap(i8 0) #[[ATTR4]], !nosanitize [[META2]]
8080
// CHECK-NEXT: unreachable, !nosanitize [[META2]]
8181
// CHECK: [[F_EXIT]]:
8282
// CHECK-NEXT: [[TMP2:%.*]] = tail call { i32, i1 } @llvm.sadd.with.overflow.i32(i32 [[Y]], i32 127), !nosanitize [[META2]]
8383
// CHECK-NEXT: [[TMP3:%.*]] = extractvalue { i32, i1 } [[TMP2]], 1, !nosanitize [[META2]]
8484
// CHECK-NEXT: br i1 [[TMP3]], label %[[TRAP_I2:.*]], label %[[G_EXIT:.*]], !nosanitize [[META2]]
8585
// CHECK: [[TRAP_I2]]:
86-
// CHECK-NEXT: tail call void @llvm.ubsantrap(i8 2) #[[ATTR4]], !nosanitize [[META2]]
86+
// CHECK-NEXT: tail call void @llvm.ubsantrap(i8 0) #[[ATTR4]], !nosanitize [[META2]]
8787
// CHECK-NEXT: unreachable, !nosanitize [[META2]]
8888
// CHECK: [[G_EXIT]]:
8989
// CHECK-NEXT: [[TMP4:%.*]] = extractvalue { i32, i1 } [[TMP0]], 0, !nosanitize [[META2]]
@@ -92,7 +92,7 @@ int h(int x, int y) {
9292
// CHECK-NEXT: [[TMP7:%.*]] = extractvalue { i32, i1 } [[TMP6]], 1, !nosanitize [[META2]]
9393
// CHECK-NEXT: br i1 [[TMP7]], label %[[TRAP:.*]], label %[[CONT:.*]], !nosanitize [[META2]]
9494
// CHECK: [[TRAP]]:
95-
// CHECK-NEXT: tail call void @llvm.ubsantrap(i8 2) #[[ATTR4]], !nosanitize [[META2]]
95+
// CHECK-NEXT: tail call void @llvm.ubsantrap(i8 0) #[[ATTR4]], !nosanitize [[META2]]
9696
// CHECK-NEXT: unreachable, !nosanitize [[META2]]
9797
// CHECK: [[CONT]]:
9898
// CHECK-NEXT: [[TMP8:%.*]] = extractvalue { i32, i1 } [[TMP6]], 0, !nosanitize [[META2]]
@@ -102,4 +102,4 @@ int m(int x, int y) {
102102
return f(x) + g(y);
103103
}
104104
//.
105-
// CHECK: attributes #[[ATTR4]] = { noreturn nounwind }
105+
// CHECK: attributes #[[ATTR4]] = { nomerge noreturn nounwind }

llvm/test/CodeGen/X86/ubsan-trap-merge.ll

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
; This test shows that ubsantrap can, in the absence of nomerge, be merged by
55
; the backend into a single ud1 instruction (thus making debugging difficult).
66
;
7-
; The LLVM IR was generated from clang/test/CodeGen/ubsan-trap-merge.c.
7+
; The LLVM IR was generated from clang/test/CodeGen/ubsan-trap-merge.c with
8+
; 'nomerge' manually removed from ubsantraps.
89
;
910
; ModuleID = '../clang/test/CodeGen/ubsan-trap-merge.c'
1011
source_filename = "../clang/test/CodeGen/ubsan-trap-merge.c"
@@ -21,14 +22,14 @@ define dso_local range(i32 -2147483523, -2147483648) i32 @f(i32 noundef %x) loca
2122
; CHECK-NEXT: movl %edi, %eax
2223
; CHECK-NEXT: retq
2324
; CHECK-NEXT: .LBB0_1: # %trap
24-
; CHECK-NEXT: ud1l 2(%eax), %eax
25+
; CHECK-NEXT: ud1l (%eax), %eax
2526
entry:
2627
%0 = tail call { i32, i1 } @llvm.sadd.with.overflow.i32(i32 %x, i32 125), !nosanitize !5
2728
%1 = extractvalue { i32, i1 } %0, 1, !nosanitize !5
2829
br i1 %1, label %trap, label %cont, !nosanitize !5
2930

3031
trap: ; preds = %entry
31-
tail call void @llvm.ubsantrap(i8 2) #4, !nosanitize !5
32+
tail call void @llvm.ubsantrap(i8 0) #4, !nosanitize !5
3233
unreachable, !nosanitize !5
3334

3435
cont: ; preds = %entry
@@ -52,14 +53,14 @@ define dso_local range(i32 -2147483521, -2147483648) i32 @g(i32 noundef %x) loca
5253
; CHECK-NEXT: movl %edi, %eax
5354
; CHECK-NEXT: retq
5455
; CHECK-NEXT: .LBB1_1: # %trap
55-
; CHECK-NEXT: ud1l 2(%eax), %eax
56+
; CHECK-NEXT: ud1l (%eax), %eax
5657
entry:
5758
%0 = tail call { i32, i1 } @llvm.sadd.with.overflow.i32(i32 %x, i32 127), !nosanitize !5
5859
%1 = extractvalue { i32, i1 } %0, 1, !nosanitize !5
5960
br i1 %1, label %trap, label %cont, !nosanitize !5
6061

6162
trap: ; preds = %entry
62-
tail call void @llvm.ubsantrap(i8 2) #4, !nosanitize !5
63+
tail call void @llvm.ubsantrap(i8 0) #4, !nosanitize !5
6364
unreachable, !nosanitize !5
6465

6566
cont: ; preds = %entry
@@ -75,23 +76,21 @@ define dso_local range(i32 -2147483521, -2147483648) i32 @h(i32 noundef %x, i32
7576
; CHECK-NEXT: jo .LBB2_3
7677
; CHECK-NEXT: # %bb.1: # %cont
7778
; CHECK-NEXT: addl $129, %esi
78-
; CHECK-NEXT: jo .LBB2_4
79+
; CHECK-NEXT: jo .LBB2_3
7980
; CHECK-NEXT: # %bb.2: # %cont2
8081
; CHECK-NEXT: cmpl %esi, %edi
8182
; CHECK-NEXT: cmovll %edi, %esi
8283
; CHECK-NEXT: movl %esi, %eax
8384
; CHECK-NEXT: retq
8485
; CHECK-NEXT: .LBB2_3: # %trap
85-
; CHECK-NEXT: ud1l 2(%eax), %eax
86-
; CHECK-NEXT: .LBB2_4: # %trap1
87-
; CHECK-NEXT: ud1l 4(%eax), %eax
86+
; CHECK-NEXT: ud1l (%eax), %eax
8887
entry:
8988
%0 = tail call { i32, i1 } @llvm.sadd.with.overflow.i32(i32 %x, i32 127), !nosanitize !5
9089
%1 = extractvalue { i32, i1 } %0, 1, !nosanitize !5
9190
br i1 %1, label %trap, label %cont, !nosanitize !5
9291

9392
trap: ; preds = %entry
94-
tail call void @llvm.ubsantrap(i8 2) #4, !nosanitize !5
93+
tail call void @llvm.ubsantrap(i8 0) #4, !nosanitize !5
9594
unreachable, !nosanitize !5
9695

9796
cont: ; preds = %entry
@@ -100,7 +99,7 @@ cont: ; preds = %entry
10099
br i1 %3, label %trap1, label %cont2, !nosanitize !5
101100

102101
trap1: ; preds = %cont
103-
tail call void @llvm.ubsantrap(i8 4) #4, !nosanitize !5
102+
tail call void @llvm.ubsantrap(i8 0) #4, !nosanitize !5
104103
unreachable, !nosanitize !5
105104

106105
cont2: ; preds = %cont
@@ -126,14 +125,14 @@ define dso_local noundef i32 @m(i32 noundef %x, i32 noundef %y) local_unnamed_ad
126125
; CHECK-NEXT: movl %edi, %eax
127126
; CHECK-NEXT: retq
128127
; CHECK-NEXT: .LBB3_4: # %trap.i
129-
; CHECK-NEXT: ud1l 2(%eax), %eax
128+
; CHECK-NEXT: ud1l (%eax), %eax
130129
entry:
131130
%0 = tail call { i32, i1 } @llvm.sadd.with.overflow.i32(i32 %x, i32 125), !nosanitize !5
132131
%1 = extractvalue { i32, i1 } %0, 1, !nosanitize !5
133132
br i1 %1, label %trap.i, label %f.exit, !nosanitize !5
134133

135134
trap.i: ; preds = %entry
136-
tail call void @llvm.ubsantrap(i8 2) #4, !nosanitize !5
135+
tail call void @llvm.ubsantrap(i8 0) #4, !nosanitize !5
137136
unreachable, !nosanitize !5
138137

139138
f.exit: ; preds = %entry
@@ -142,7 +141,7 @@ f.exit: ; preds = %entry
142141
br i1 %3, label %trap.i2, label %g.exit, !nosanitize !5
143142

144143
trap.i2: ; preds = %f.exit
145-
tail call void @llvm.ubsantrap(i8 2) #4, !nosanitize !5
144+
tail call void @llvm.ubsantrap(i8 0) #4, !nosanitize !5
146145
unreachable, !nosanitize !5
147146

148147
g.exit: ; preds = %f.exit
@@ -153,7 +152,7 @@ g.exit: ; preds = %f.exit
153152
br i1 %7, label %trap, label %cont, !nosanitize !5
154153

155154
trap: ; preds = %g.exit
156-
tail call void @llvm.ubsantrap(i8 2) #4, !nosanitize !5
155+
tail call void @llvm.ubsantrap(i8 0) #4, !nosanitize !5
157156
unreachable, !nosanitize !5
158157

159158
cont: ; preds = %g.exit

llvm/test/CodeGen/X86/ubsan-trap-nomerge.ll

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
; This tests that the nomerge attribute for ubsantrap works correctly i.e.,
55
; they are lowered to separate ud1 instructions.
66
;
7-
; The LLVM IR was generated from clang/test/CodeGen/ubsan-trap-merge.c with
8-
; 'nomerge' manually added to ubsantraps.
7+
; The LLVM IR was generated from clang/test/CodeGen/ubsan-trap-merge.c.
98
;
109
; ModuleID = '../clang/test/CodeGen/ubsan-trap-merge.c'
1110
source_filename = "../clang/test/CodeGen/ubsan-trap-merge.c"
@@ -22,14 +21,14 @@ define dso_local range(i32 -2147483523, -2147483648) i32 @f(i32 noundef %x) loca
2221
; CHECK-NEXT: movl %edi, %eax
2322
; CHECK-NEXT: retq
2423
; CHECK-NEXT: .LBB0_1: # %trap
25-
; CHECK-NEXT: ud1l 2(%eax), %eax
24+
; CHECK-NEXT: ud1l (%eax), %eax
2625
entry:
2726
%0 = tail call { i32, i1 } @llvm.sadd.with.overflow.i32(i32 %x, i32 125), !nosanitize !5
2827
%1 = extractvalue { i32, i1 } %0, 1, !nosanitize !5
2928
br i1 %1, label %trap, label %cont, !nosanitize !5
3029

3130
trap: ; preds = %entry
32-
tail call void @llvm.ubsantrap(i8 2) #4, !nosanitize !5
31+
tail call void @llvm.ubsantrap(i8 0) #4, !nosanitize !5
3332
unreachable, !nosanitize !5
3433

3534
cont: ; preds = %entry
@@ -53,14 +52,14 @@ define dso_local range(i32 -2147483521, -2147483648) i32 @g(i32 noundef %x) loca
5352
; CHECK-NEXT: movl %edi, %eax
5453
; CHECK-NEXT: retq
5554
; CHECK-NEXT: .LBB1_1: # %trap
56-
; CHECK-NEXT: ud1l 2(%eax), %eax
55+
; CHECK-NEXT: ud1l (%eax), %eax
5756
entry:
5857
%0 = tail call { i32, i1 } @llvm.sadd.with.overflow.i32(i32 %x, i32 127), !nosanitize !5
5958
%1 = extractvalue { i32, i1 } %0, 1, !nosanitize !5
6059
br i1 %1, label %trap, label %cont, !nosanitize !5
6160

6261
trap: ; preds = %entry
63-
tail call void @llvm.ubsantrap(i8 2) #4, !nosanitize !5
62+
tail call void @llvm.ubsantrap(i8 0) #4, !nosanitize !5
6463
unreachable, !nosanitize !5
6564

6665
cont: ; preds = %entry
@@ -83,16 +82,16 @@ define dso_local range(i32 -2147483521, -2147483648) i32 @h(i32 noundef %x, i32
8382
; CHECK-NEXT: movl %esi, %eax
8483
; CHECK-NEXT: retq
8584
; CHECK-NEXT: .LBB2_3: # %trap
86-
; CHECK-NEXT: ud1l 2(%eax), %eax
85+
; CHECK-NEXT: ud1l (%eax), %eax
8786
; CHECK-NEXT: .LBB2_4: # %trap1
88-
; CHECK-NEXT: ud1l 4(%eax), %eax
87+
; CHECK-NEXT: ud1l (%eax), %eax
8988
entry:
9089
%0 = tail call { i32, i1 } @llvm.sadd.with.overflow.i32(i32 %x, i32 127), !nosanitize !5
9190
%1 = extractvalue { i32, i1 } %0, 1, !nosanitize !5
9291
br i1 %1, label %trap, label %cont, !nosanitize !5
9392

9493
trap: ; preds = %entry
95-
tail call void @llvm.ubsantrap(i8 2) #4, !nosanitize !5
94+
tail call void @llvm.ubsantrap(i8 0) #4, !nosanitize !5
9695
unreachable, !nosanitize !5
9796

9897
cont: ; preds = %entry
@@ -101,7 +100,7 @@ cont: ; preds = %entry
101100
br i1 %3, label %trap1, label %cont2, !nosanitize !5
102101

103102
trap1: ; preds = %cont
104-
tail call void @llvm.ubsantrap(i8 4) #4, !nosanitize !5
103+
tail call void @llvm.ubsantrap(i8 0) #4, !nosanitize !5
105104
unreachable, !nosanitize !5
106105

107106
cont2: ; preds = %cont
@@ -127,18 +126,18 @@ define dso_local noundef i32 @m(i32 noundef %x, i32 noundef %y) local_unnamed_ad
127126
; CHECK-NEXT: movl %edi, %eax
128127
; CHECK-NEXT: retq
129128
; CHECK-NEXT: .LBB3_4: # %trap.i
130-
; CHECK-NEXT: ud1l 2(%eax), %eax
129+
; CHECK-NEXT: ud1l (%eax), %eax
131130
; CHECK-NEXT: .LBB3_5: # %trap.i2
132-
; CHECK-NEXT: ud1l 2(%eax), %eax
131+
; CHECK-NEXT: ud1l (%eax), %eax
133132
; CHECK-NEXT: .LBB3_6: # %trap
134-
; CHECK-NEXT: ud1l 2(%eax), %eax
133+
; CHECK-NEXT: ud1l (%eax), %eax
135134
entry:
136135
%0 = tail call { i32, i1 } @llvm.sadd.with.overflow.i32(i32 %x, i32 125), !nosanitize !5
137136
%1 = extractvalue { i32, i1 } %0, 1, !nosanitize !5
138137
br i1 %1, label %trap.i, label %f.exit, !nosanitize !5
139138

140139
trap.i: ; preds = %entry
141-
tail call void @llvm.ubsantrap(i8 2) #4, !nosanitize !5
140+
tail call void @llvm.ubsantrap(i8 0) #4, !nosanitize !5
142141
unreachable, !nosanitize !5
143142

144143
f.exit: ; preds = %entry
@@ -147,7 +146,7 @@ f.exit: ; preds = %entry
147146
br i1 %3, label %trap.i2, label %g.exit, !nosanitize !5
148147

149148
trap.i2: ; preds = %f.exit
150-
tail call void @llvm.ubsantrap(i8 2) #4, !nosanitize !5
149+
tail call void @llvm.ubsantrap(i8 0) #4, !nosanitize !5
151150
unreachable, !nosanitize !5
152151

153152
g.exit: ; preds = %f.exit
@@ -158,7 +157,7 @@ g.exit: ; preds = %f.exit
158157
br i1 %7, label %trap, label %cont, !nosanitize !5
159158

160159
trap: ; preds = %g.exit
161-
tail call void @llvm.ubsantrap(i8 2) #4, !nosanitize !5
160+
tail call void @llvm.ubsantrap(i8 0) #4, !nosanitize !5
162161
unreachable, !nosanitize !5
163162

164163
cont: ; preds = %g.exit

0 commit comments

Comments
 (0)