Skip to content

Commit a962fc8

Browse files
committed
add additional tests
1 parent 6ce279a commit a962fc8

File tree

4 files changed

+57
-0
lines changed

4 files changed

+57
-0
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
2+
; RUN: llc -mtriple=aarch64 -global-isel=0 < %s | FileCheck %s
3+
; RUN: llc -mtriple=aarch64 -global-isel=1 < %s | FileCheck %s
4+
5+
; Check that lifetime.start/end with poison argument are ignored.
6+
7+
define void @test() {
8+
; CHECK-LABEL: test:
9+
; CHECK: // %bb.0:
10+
; CHECK-NEXT: ret
11+
call void @llvm.lifetime.start.p0(i64 4, ptr poison)
12+
call void @llvm.lifetime.end.p0(i64 4, ptr poison)
13+
ret void
14+
}

llvm/test/Instrumentation/AddressSanitizer/lifetime.ll

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,21 @@ entry:
334334

335335
ret void
336336
}
337+
338+
; Lifetimes on poison should be ignored.
339+
define void @lifetime_poison(i64 %a) #0 {
340+
; CHECK-LABEL: define void @lifetime_poison(
341+
; CHECK-SAME: i64 [[A:%.*]]) {
342+
; CHECK-NEXT: [[A_ADDR:%.*]] = alloca i64, align 8
343+
; CHECK-NEXT: store i64 [[A]], ptr [[A_ADDR]], align 8
344+
; CHECK-NEXT: ret void
345+
;
346+
%a.addr = alloca i64, align 8
347+
call void @llvm.lifetime.start.p0(i64 8, ptr poison)
348+
store i64 %a, ptr %a.addr, align 8
349+
call void @llvm.lifetime.end.p0(i64 8, ptr poison)
350+
ret void
351+
}
337352
;.
338353
; CHECK-DEFAULT: [[PROF1]] = !{!"branch_weights", i32 1, i32 1048575}
339354
;.

llvm/test/Instrumentation/HWAddressSanitizer/stack-safety-analysis.ll

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,25 @@ entry:
395395
ret i32 0
396396
}
397397

398+
; Check that lifetimes on poison are ignored.
399+
define i32 @test_lifetime_poison(ptr %a) sanitize_hwaddress {
400+
entry:
401+
; CHECK-LABEL: @test_lifetime_poison
402+
; NOSAFETY: call {{.*}}__hwasan_generate_tag
403+
; NOSAFETY: call {{.*}}__hwasan_store
404+
; SAFETY-NOT: call {{.*}}__hwasan_generate_tag
405+
; SAFETY-NOT: call {{.*}}__hwasan_store
406+
; NOSTACK-NOT: call {{.*}}__hwasan_generate_tag
407+
; NOSTACK-NOT: call {{.*}}__hwasan_store
408+
; SAFETY-REMARKS: --- !Passed{{[[:space:]]}}Pass: hwasan{{[[:space:]]}}Name: safeAlloca{{[[:space:]]}}Function: test_lifetime_poison
409+
; SAFETY-REMARKS: --- !Passed{{[[:space:]]}}Pass: hwasan{{[[:space:]]}}Name: ignoreAccess{{[[:space:]]}}Function: test_lifetime_poison
410+
%buf.sroa.0 = alloca i8, align 4
411+
call void @llvm.lifetime.start.p0(i64 1, ptr poison)
412+
store volatile i8 0, ptr %buf.sroa.0, align 4, !tbaa !8
413+
call void @llvm.lifetime.end.p0(i64 1, ptr poison)
414+
ret i32 0
415+
}
416+
398417
; Function Attrs: argmemonly mustprogress nofree nosync nounwind willreturn
399418
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture)
400419

llvm/test/Transforms/InstCombine/unreachable-alloca-lifetime-markers.ll

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,12 @@ bb2:
4040
%phi2 = phi ptr [ null, %entry ], [ %a, %bb1 ]
4141
br label %bb1
4242
}
43+
44+
define void @lifetime_poison() {
45+
; CHECK-LABEL: define void @lifetime_poison() {
46+
; CHECK-NEXT: ret void
47+
;
48+
call void @llvm.lifetime.start.p0(i64 4, ptr poison)
49+
call void @llvm.lifetime.end.p0(i64 4, ptr poison)
50+
ret void
51+
}

0 commit comments

Comments
 (0)