1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 19:12:56 +02:00

[NFC][StackSafety] Test that StackLifetime looks through stripPointerCasts

StackLifetime class collects lifetime marker of an `alloca` by collect
the user of `BitCast` who is the user of the `alloca`. However, either
the `alloca` itself could be used with the lifetime marker or the `BitCast`
of the `alloca` could be transformed to other instructions. (e.g.,
it may be transformed to all zero reps in `InstCombine` pass).
This patch tries to fix this process in `collectMarkers` functions.

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D85399
This commit is contained in:
Chuanqi Xu 2020-08-18 14:30:03 -07:00 committed by Vitaly Buka
parent 8e3a33cacc
commit 3188b05ed0

View File

@ -699,6 +699,50 @@ l2: ; preds = %l2, %entry
br label %l2
}
%struct.char_array = type { [500 x i8] }
define dso_local void @gep_test(i32 %cond) {
; CHECK-LABEL: define dso_local void @gep_test
entry:
; CHECK: entry:
; CHECK-NEXT: Alive: <>
%a = alloca %struct.char_array, align 8
%b = alloca %struct.char_array, align 8
%tobool.not = icmp eq i32 %cond, 0
br i1 %tobool.not, label %if.else, label %if.then
if.then: ; preds = %entry
; CHECK: if.then:
; CHECK-NEXT: Alive: <>
%0 = getelementptr inbounds %struct.char_array, %struct.char_array* %a, i64 0, i32 0, i64 0
call void @llvm.lifetime.start.p0i8(i64 500, i8* nonnull %0)
; CHECK: call void @llvm.lifetime.start.p0i8(i64 500, i8* nonnull %0)
; CHECK-NEXT: Alive: <a>
tail call void @capture8(i8* %0)
call void @llvm.lifetime.end.p0i8(i64 500, i8* nonnull %0)
; CHECK: call void @llvm.lifetime.end.p0i8(i64 500, i8* nonnull %0)
; CHECK-NEXT: Alive: <>
br label %if.end
if.else: ; preds = %entry
; CHECK: if.else:
; CHECK-NEXT: Alive: <>
%1 = getelementptr inbounds %struct.char_array, %struct.char_array* %b, i64 0, i32 0, i64 0
call void @llvm.lifetime.start.p0i8(i64 500, i8* nonnull %1)
; CHECK: call void @llvm.lifetime.start.p0i8(i64 500, i8* nonnull %1)
; CHECK-NEXT: Alive: <b>
tail call void @capture8(i8* %1)
call void @llvm.lifetime.end.p0i8(i64 500, i8* nonnull %1)
; CHECK: call void @llvm.lifetime.end.p0i8(i64 500, i8* nonnull %1)
; CHECK-NEXT: Alive: <>
br label %if.end
if.end: ; preds = %if.else, %if.then
; CHECK: if.end:
; CHECK-NEXT: Alive: <>
ret void
}
define void @if_must(i1 %a) {
; CHECK-LABEL: define void @if_must
entry: