diff options
| author | Jessica Paquette <jpaquette@apple.com> | 2019-01-28 19:22:29 +0000 |
|---|---|---|
| committer | Jessica Paquette <jpaquette@apple.com> | 2019-01-28 19:22:29 +0000 |
| commit | 2e35dc5185841d6e7a2653becf47f731e5f7ad5a (patch) | |
| tree | 06cffe1cb7ae3e91b1ca3ca5dbe7a8174c4420b9 /llvm/test/CodeGen/AArch64 | |
| parent | 8e1a464e6ad8b81a4ae3ba3fa07a176e2ba23152 (diff) | |
| download | bcm5719-llvm-2e35dc5185841d6e7a2653becf47f731e5f7ad5a.tar.gz bcm5719-llvm-2e35dc5185841d6e7a2653becf47f731e5f7ad5a.zip | |
[GlobalISel] Add ISel support for @llvm.lifetime.start and @llvm.lifetime.end
This adds ISel support for lifetime markers in opt levels above O0.
It also updates the arm64-irtranslator test, and updates some AArch64 tests that
use them for added coverage.
It also adds a testcase taken from the X86 codegen tests which verified a bug
caused by lifetime markers + stack colouring in the past. This is intended to
make sure that GISel doesn't re-introduce the bug.
(This is basically a straight copy from what SelectionDAG does in
SelectionDAGBuilder.cpp)
https://reviews.llvm.org/D57187
llvm-svn: 352410
Diffstat (limited to 'llvm/test/CodeGen/AArch64')
4 files changed, 68 insertions, 0 deletions
diff --git a/llvm/test/CodeGen/AArch64/GlobalISel/arm64-irtranslator.ll b/llvm/test/CodeGen/AArch64/GlobalISel/arm64-irtranslator.ll index 30b2ad357fc..98326a9cfdf 100644 --- a/llvm/test/CodeGen/AArch64/GlobalISel/arm64-irtranslator.ll +++ b/llvm/test/CodeGen/AArch64/GlobalISel/arm64-irtranslator.ll @@ -1,4 +1,5 @@ ; RUN: llc -O0 -aarch64-enable-atomic-cfg-tidy=0 -stop-after=irtranslator -global-isel -verify-machineinstrs %s -o - 2>&1 | FileCheck %s +; RUN: llc -O3 -aarch64-enable-atomic-cfg-tidy=0 -stop-after=irtranslator -global-isel -verify-machineinstrs %s -o - 2>&1 | FileCheck %s --check-prefix=O3 ; This file checks that the translation from llvm IR to generic MachineInstr ; is correct. @@ -1481,6 +1482,11 @@ declare void @llvm.lifetime.end.p0i8(i64, i8*) define void @test_lifetime_intrin() { ; CHECK-LABEL: name: test_lifetime_intrin ; CHECK: RET_ReallyLR +; O3-LABEL: name: test_lifetime_intrin +; O3: {{%[0-9]+}}:_(p0) = G_FRAME_INDEX %stack.0.slot +; O3-NEXT: LIFETIME_START %stack.0.slot +; O3-NEXT: LIFETIME_END %stack.0.slot +; O3-NEXT: RET_ReallyLR %slot = alloca i8, i32 4 call void @llvm.lifetime.start.p0i8(i64 0, i8* %slot) call void @llvm.lifetime.end.p0i8(i64 0, i8* %slot) diff --git a/llvm/test/CodeGen/AArch64/GlobalISel/dynamic-alloca-lifetime.ll b/llvm/test/CodeGen/AArch64/GlobalISel/dynamic-alloca-lifetime.ll new file mode 100644 index 00000000000..3ce873f2f6e --- /dev/null +++ b/llvm/test/CodeGen/AArch64/GlobalISel/dynamic-alloca-lifetime.ll @@ -0,0 +1,47 @@ +; RUN: llc -mtriple aarch64-unknown-unknown -global-isel \ +; RUN: -no-stack-coloring=false -pass-remarks-missed=gisel* < %s \ +; RUN: 2>&1 | FileCheck %s + +; Same as the dynamic-alloca-lifetime.ll X86 test, which was used to fix a bug +; in stack colouring + lifetime markers. + +; This test crashed in PEI because the stack protector was dead. +; This was due to it being colored, which was in turn due to incorrect +; lifetimes being applied to the stack protector frame index. + +; CHECK: stack_chk_guard +; CHECK-NOT: remark{{.*}}foo + +; Function Attrs: nounwind +declare void @llvm.lifetime.start.p0i8(i64, i8* nocapture) #0 + +; Function Attrs: nounwind +declare void @llvm.lifetime.end.p0i8(i64, i8* nocapture) #0 + +; Function Attrs: ssp +define void @foo(i1 %cond1, i1 %cond2) #1 { +entry: + %bitmapBuffer = alloca [8192 x i8], align 1 + br i1 %cond1, label %end1, label %bb1 + +bb1: + %bitmapBuffer229 = alloca [8192 x i8], align 1 + br i1 %cond2, label %end1, label %if.else130 + +end1: + ret void + +if.else130: ; preds = %bb1 + %tmp = getelementptr inbounds [8192 x i8], [8192 x i8]* %bitmapBuffer, i32 0, i32 0 + call void @llvm.lifetime.start.p0i8(i64 8192, i8* %tmp) #0 + call void @llvm.lifetime.end.p0i8(i64 8192, i8* %tmp) #0 + %tmp25 = getelementptr inbounds [8192 x i8], [8192 x i8]* %bitmapBuffer229, i32 0, i32 0 + call void @llvm.lifetime.start.p0i8(i64 8192, i8* %tmp25) #0 + call void @llvm.lifetime.end.p0i8(i64 8192, i8* %tmp25) #0 + br label %end1 +} + +declare void @bar() + +attributes #0 = { nounwind } +attributes #1 = { ssp } diff --git a/llvm/test/CodeGen/AArch64/mingw-refptr.ll b/llvm/test/CodeGen/AArch64/mingw-refptr.ll index 3a76d858627..dde1b895257 100644 --- a/llvm/test/CodeGen/AArch64/mingw-refptr.ll +++ b/llvm/test/CodeGen/AArch64/mingw-refptr.ll @@ -1,4 +1,6 @@ ; RUN: llc < %s -mtriple=aarch64-w64-mingw32 | FileCheck %s +; RUN: llc < %s -global-isel -global-isel-abort=2 -pass-remarks-missed=gisel* \ +; RUN: -mtriple=aarch64-w64-mingw32 2>&1| FileCheck %s --check-prefixes=GISEL,FALLBACK @var = external local_unnamed_addr global i32, align 4 @dsolocalvar = external dso_local local_unnamed_addr global i32, align 4 @@ -68,11 +70,16 @@ entry: declare dso_local void @otherFunc() +; FALLBACK-NOT: remark:{{.*}}sspFunc define dso_local void @sspFunc() #0 { ; CHECK-LABEL: sspFunc: ; CHECK: adrp x8, .refptr.__stack_chk_guard ; CHECK: ldr x8, [x8, .refptr.__stack_chk_guard] ; CHECK: ldr x8, [x8] +; GISEL-LABEL: sspFunc: +; GISEL: adrp x8, .refptr.__stack_chk_guard +; GISEL: ldr x8, [x8, .refptr.__stack_chk_guard] +; GISEL: ldr x8, [x8] entry: %c = alloca i8, align 1 call void @llvm.lifetime.start.p0i8(i64 1, i8* nonnull %c) diff --git a/llvm/test/CodeGen/AArch64/stack_guard_remat.ll b/llvm/test/CodeGen/AArch64/stack_guard_remat.ll index 2b7b3485311..3a87a37316b 100644 --- a/llvm/test/CodeGen/AArch64/stack_guard_remat.ll +++ b/llvm/test/CodeGen/AArch64/stack_guard_remat.ll @@ -4,6 +4,12 @@ ; RUN: llc < %s -mtriple=aarch64-linux-gnu -relocation-model=static -code-model=large -no-integrated-as | FileCheck %s -check-prefix=STATIC-LARGE ; RUN: llc < %s -mtriple=aarch64-linux-gnu -relocation-model=static -code-model=small -no-integrated-as | FileCheck %s -check-prefix=STATIC-SMALL +; RUN: llc < %s -global-isel -global-isel-abort=2 -pass-remarks-missed=gisel* -mtriple=arm64-apple-ios -relocation-model=pic -no-integrated-as 2>&1 | FileCheck %s -check-prefixes=DARWIN,FALLBACK +; RUN: llc < %s -global-isel -global-isel-abort=2 -pass-remarks-missed=gisel* -mtriple=arm64-apple-ios -relocation-model=static -no-integrated-as 2>&1 | FileCheck %s -check-prefixes=DARWIN,FALLBACK +; RUN: llc < %s -global-isel -global-isel-abort=2 -pass-remarks-missed=gisel* -mtriple=aarch64-linux-gnu -relocation-model=pic -no-integrated-as 2>&1 | FileCheck %s -check-prefixes=PIC-LINUX,FALLBACK +; RUN: llc < %s -global-isel -global-isel-abort=2 -pass-remarks-missed=gisel* -mtriple=aarch64-linux-gnu -relocation-model=static -code-model=large -no-integrated-as 2>&1 | FileCheck %s -check-prefixes=STATIC-LARGE,FALLBACK +; RUN: llc < %s -global-isel -global-isel-abort=2 -pass-remarks-missed=gisel* -mtriple=aarch64-linux-gnu -relocation-model=static -code-model=small -no-integrated-as 2>&1 | FileCheck %s -check-prefixes=STATIC-SMALL,FALLBACK + ; DARWIN: foo2 ; DARWIN: adrp [[R0:x[0-9]+]], ___stack_chk_guard@GOTPAGE ; DARWIN: ldr [[R1:x[0-9]+]], {{\[}}[[R0]], ___stack_chk_guard@GOTPAGEOFF{{\]}} @@ -25,6 +31,8 @@ ; STATIC-SMALL: adrp [[R0:x[0-9]+]], __stack_chk_guard ; STATIC-SMALL: ldr {{x[0-9]+}}, {{\[}}[[R0]], :lo12:__stack_chk_guard{{\]}} +; FALLBACK-NOT: remark:{{.*}}llvm.lifetime.end +; FALLBACK-NOT: remark:{{.*}}llvm.lifetime.start define i32 @test_stack_guard_remat() #0 { entry: %a1 = alloca [256 x i32], align 4 |

