Skip to content

Commit 2b8b38a

Browse files
committed
localoob
Created using spr 1.3.7
1 parent a8be55d commit 2b8b38a

File tree

2 files changed

+18
-16
lines changed

2 files changed

+18
-16
lines changed

llvm/lib/Transforms/Instrumentation/BoundsChecking.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,8 @@ static bool addBoundsChecking(Function &F, TargetLibraryInfo &TLI,
265265
bool MayReturn = Opts.Rt && Opts.Rt->MayReturn;
266266
if (MayReturn) {
267267
IRB.CreateBr(Cont);
268+
if (Opts.Rt && Opts.Rt->HandlerPreserveAllRegs && Opts.Rt->MinRuntime)
269+
TrapCall->setCallingConv(CallingConv::PreserveAll);
268270
} else {
269271
TrapCall->setDoesNotReturn();
270272
IRB.CreateUnreachable();

llvm/test/Instrumentation/BoundsChecking/runtimes.ll

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,22 @@ define void @f1(i64 %x) nounwind {
9696
; RTABORT-NOMERGE-NEXT: call void @__ubsan_handle_local_out_of_bounds_abort() #[[ATTR2:[0-9]+]], !nosanitize [[META0]]
9797
; RTABORT-NOMERGE-NEXT: unreachable, !nosanitize [[META0]]
9898
;
99+
; MINRT-PRESERVE-NOMERGE-LABEL: define void @f1(
100+
; MINRT-PRESERVE-NOMERGE-SAME: i64 [[X:%.*]]) #[[ATTR0:[0-9]+]] {
101+
; MINRT-PRESERVE-NOMERGE-NEXT: [[TMP1:%.*]] = mul i64 16, [[X]]
102+
; MINRT-PRESERVE-NOMERGE-NEXT: [[TMP2:%.*]] = alloca i128, i64 [[X]], align 8
103+
; MINRT-PRESERVE-NOMERGE-NEXT: [[TMP3:%.*]] = sub i64 [[TMP1]], 0, !nosanitize [[META0:![0-9]+]]
104+
; MINRT-PRESERVE-NOMERGE-NEXT: [[TMP4:%.*]] = icmp ult i64 [[TMP3]], 16, !nosanitize [[META0]]
105+
; MINRT-PRESERVE-NOMERGE-NEXT: [[TMP5:%.*]] = or i1 false, [[TMP4]], !nosanitize [[META0]]
106+
; MINRT-PRESERVE-NOMERGE-NEXT: [[TMP6:%.*]] = or i1 false, [[TMP5]], !nosanitize [[META0]]
107+
; MINRT-PRESERVE-NOMERGE-NEXT: br i1 [[TMP6]], label %[[TRAP:.*]], label %[[BB7:.*]]
108+
; MINRT-PRESERVE-NOMERGE: [[BB7]]:
109+
; MINRT-PRESERVE-NOMERGE-NEXT: [[TMP8:%.*]] = load i128, ptr [[TMP2]], align 4
110+
; MINRT-PRESERVE-NOMERGE-NEXT: ret void
111+
; MINRT-PRESERVE-NOMERGE: [[TRAP]]:
112+
; MINRT-PRESERVE-NOMERGE-NEXT: call preserve_allcc void @__ubsan_handle_local_out_of_bounds_minimal_preserve() #[[ATTR1:[0-9]+]], !nosanitize [[META0]]
113+
; MINRT-PRESERVE-NOMERGE-NEXT: br label %[[BB7]], !nosanitize [[META0]]
114+
;
99115
; MINRT-NOMERGE-LABEL: define void @f1(
100116
; MINRT-NOMERGE-SAME: i64 [[X:%.*]]) #[[ATTR0:[0-9]+]] {
101117
; MINRT-NOMERGE-NEXT: [[TMP1:%.*]] = mul i64 16, [[X]]
@@ -112,22 +128,6 @@ define void @f1(i64 %x) nounwind {
112128
; MINRT-NOMERGE-NEXT: call void @__ubsan_handle_local_out_of_bounds_minimal() #[[ATTR1:[0-9]+]], !nosanitize [[META0]]
113129
; MINRT-NOMERGE-NEXT: br label %[[BB7]], !nosanitize [[META0]]
114130
;
115-
; MINRT-PRESERVE-NOMERGE-LABEL: define void @f1(
116-
; MINRT-PRESERVE-NOMERGE-SAME: i64 [[X:%.*]]) #[[ATTR0:[0-9]+]] {
117-
; MINRT-PRESERVE-NOMERGE-NEXT: [[TMP1:%.*]] = mul i64 16, [[X]]
118-
; MINRT-PRESERVE-NOMERGE-NEXT: [[TMP2:%.*]] = alloca i128, i64 [[X]], align 8
119-
; MINRT-PRESERVE-NOMERGE-NEXT: [[TMP3:%.*]] = sub i64 [[TMP1]], 0, !nosanitize [[META0:![0-9]+]]
120-
; MINRT-PRESERVE-NOMERGE-NEXT: [[TMP4:%.*]] = icmp ult i64 [[TMP3]], 16, !nosanitize [[META0]]
121-
; MINRT-PRESERVE-NOMERGE-NEXT: [[TMP5:%.*]] = or i1 false, [[TMP4]], !nosanitize [[META0]]
122-
; MINRT-PRESERVE-NOMERGE-NEXT: [[TMP6:%.*]] = or i1 false, [[TMP5]], !nosanitize [[META0]]
123-
; MINRT-PRESERVE-NOMERGE-NEXT: br i1 [[TMP6]], label %[[TRAP:.*]], label %[[BB7:.*]]
124-
; MINRT-PRESERVE-NOMERGE: [[BB7]]:
125-
; MINRT-PRESERVE-NOMERGE-NEXT: [[TMP8:%.*]] = load i128, ptr [[TMP2]], align 4
126-
; MINRT-PRESERVE-NOMERGE-NEXT: ret void
127-
; MINRT-PRESERVE-NOMERGE: [[TRAP]]:
128-
; MINRT-PRESERVE-NOMERGE-NEXT: call void @__ubsan_handle_local_out_of_bounds_minimal_preserve() #[[ATTR1:[0-9]+]], !nosanitize [[META0]]
129-
; MINRT-PRESERVE-NOMERGE-NEXT: br label %[[BB7]], !nosanitize [[META0]]
130-
;
131131
; MINRTABORT-NOMERGE-LABEL: define void @f1(
132132
; MINRTABORT-NOMERGE-SAME: i64 [[X:%.*]]) #[[ATTR0:[0-9]+]] {
133133
; MINRTABORT-NOMERGE-NEXT: [[TMP1:%.*]] = mul i64 16, [[X]]

0 commit comments

Comments
 (0)