From 050e163ae8b4bb6eb252b59e2f8f36e68ae9239d Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Wed, 13 Jan 2016 19:58:01 +0000 Subject: Vendor import of llvm trunk r257626: https://llvm.org/svn/llvm-project/llvm/trunk@257626 --- .../PowerPC/2016-01-07-BranchWeightCrash.ll | 35 ++++++++++++++ test/CodeGen/PowerPC/ppc64le-localentry-large.ll | 27 +++++++++++ test/CodeGen/PowerPC/ppc64le-localentry.ll | 20 ++++---- test/CodeGen/PowerPC/pr25802.ll | 52 +++++++++++++++++++++ test/CodeGen/PowerPC/tls_get_addr_clobbers.ll | 54 ++++++++++++++++++++++ test/CodeGen/PowerPC/tls_get_addr_stackframe.ll | 32 +++++++++++++ 6 files changed, 210 insertions(+), 10 deletions(-) create mode 100644 test/CodeGen/PowerPC/2016-01-07-BranchWeightCrash.ll create mode 100644 test/CodeGen/PowerPC/ppc64le-localentry-large.ll create mode 100644 test/CodeGen/PowerPC/pr25802.ll create mode 100644 test/CodeGen/PowerPC/tls_get_addr_clobbers.ll create mode 100644 test/CodeGen/PowerPC/tls_get_addr_stackframe.ll (limited to 'test/CodeGen/PowerPC') diff --git a/test/CodeGen/PowerPC/2016-01-07-BranchWeightCrash.ll b/test/CodeGen/PowerPC/2016-01-07-BranchWeightCrash.ll new file mode 100644 index 000000000000..65dff12f3115 --- /dev/null +++ b/test/CodeGen/PowerPC/2016-01-07-BranchWeightCrash.ll @@ -0,0 +1,35 @@ +; RUN: llc <%s | FileCheck %s +target datalayout = "e-m:e-i64:64-n32:64" +target triple = "powerpc64le-unknown-linux-gnu" + +%struct.buffer_t = type { i64, i8*, [4 x i32], [4 x i32], [4 x i32], i32, i8, i8, [2 x i8] } + +declare i32 @__f1(i8*, %struct.buffer_t* noalias) + +; CHECK-LABEL: f1: +define i32 @f1(i8* %__user_context, %struct.buffer_t* noalias %f1.buffer) { +entry: + br i1 undef, label %"assert succeeded", label %"assert failed", !prof !1 + +"assert failed": ; preds = %entry + br label %destructor_block + +"assert succeeded": ; preds = %entry + %__f1_result = call i32 @__f1(i8* %__user_context, %struct.buffer_t* %f1.buffer) #5 + %0 = icmp eq i32 %__f1_result, 0 + br i1 %0, label %"assert succeeded11", label %"assert failed10", !prof !1 + +destructor_block: ; preds = %"assert succeeded11", %"assert failed10", %"assert failed" + %1 = phi i32 [ undef, %"assert failed" ], [ %__f1_result, %"assert failed10" ], [ 0, %"assert succeeded11" ] + ret i32 %1 + +"assert failed10": ; preds = %"assert succeeded" + br label %destructor_block + +"assert succeeded11": ; preds = %"assert succeeded" + br label %destructor_block +} + +attributes #5 = { nounwind } + +!1 = !{!"branch_weights", i32 1073741824, i32 0} diff --git a/test/CodeGen/PowerPC/ppc64le-localentry-large.ll b/test/CodeGen/PowerPC/ppc64le-localentry-large.ll new file mode 100644 index 000000000000..4cf1b5a233d5 --- /dev/null +++ b/test/CodeGen/PowerPC/ppc64le-localentry-large.ll @@ -0,0 +1,27 @@ +; RUN: llc -march=ppc64le -code-model=large < %s | FileCheck %s + +target datalayout = "e-m:e-i64:64-n32:64" +target triple = "powerpc64le-unknown-linux-gnu" + +@number64 = global i64 10, align 8 + +; CHECK: .abiversion 2 + +define i64 @use_toc(i64 %a) nounwind { +entry: +; CHECK: .Lfunc_toc[[FN:[0-9]+]]: +; CHECK-NEXT: .quad .TOC.-.Lfunc_gep[[FN]] +; CHECK: use_toc: +; CHECK-NEXT: .L{{.*}}: +; CHECK-NEXT: .Lfunc_gep[[FN]]: +; CHECK-NEXT: ld 2, .Lfunc_toc[[FN]]-.Lfunc_gep[[FN]](12) +; CHECK-NEXT: add 2, 2, 12 +; CHECK-NEXT: .Lfunc_lep[[FN]]: +; CHECK-NEXT: .localentry use_toc, .Lfunc_lep[[FN]]-.Lfunc_gep[[FN]] +; CHECK-NEXT: %entry + %0 = load i64, i64* @number64, align 8 + %cmp = icmp eq i64 %0, %a + %conv1 = zext i1 %cmp to i64 + ret i64 %conv1 +} + diff --git a/test/CodeGen/PowerPC/ppc64le-localentry.ll b/test/CodeGen/PowerPC/ppc64le-localentry.ll index be64f1151769..45cae6b17bc2 100644 --- a/test/CodeGen/PowerPC/ppc64le-localentry.ll +++ b/test/CodeGen/PowerPC/ppc64le-localentry.ll @@ -17,11 +17,11 @@ define i64 @use_toc(i64 %a) nounwind { entry: ; CHECK-LABEL: @use_toc ; CHECK-NEXT: .L{{.*}}: -; CHECK-NEXT: .Ltmp[[TMP1:[0-9]+]]: -; CHECK-NEXT: addis 2, 12, .TOC.-.Ltmp[[TMP1]]@ha -; CHECK-NEXT: addi 2, 2, .TOC.-.Ltmp[[TMP1]]@l -; CHECK-NEXT: .Ltmp[[TMP2:[0-9]+]]: -; CHECK-NEXT: .localentry use_toc, .Ltmp[[TMP2]]-.Ltmp[[TMP1]] +; CHECK-NEXT: .Lfunc_gep[[FN:[0-9]+]]: +; CHECK-NEXT: addis 2, 12, .TOC.-.Lfunc_gep[[FN]]@ha +; CHECK-NEXT: addi 2, 2, .TOC.-.Lfunc_gep[[FN]]@l +; CHECK-NEXT: .Lfunc_lep[[FN]]: +; CHECK-NEXT: .localentry use_toc, .Lfunc_lep[[FN]]-.Lfunc_gep[[FN]] ; CHECK-NEXT: %entry %0 = load i64, i64* @number64, align 8 %cmp = icmp eq i64 %0, %a @@ -34,11 +34,11 @@ define void @use_toc_implicit() nounwind { entry: ; CHECK-LABEL: @use_toc_implicit ; CHECK-NEXT: .L{{.*}}: -; CHECK-NEXT: .Ltmp[[TMP1:[0-9]+]]: -; CHECK-NEXT: addis 2, 12, .TOC.-.Ltmp[[TMP1]]@ha -; CHECK-NEXT: addi 2, 2, .TOC.-.Ltmp[[TMP1]]@l -; CHECK-NEXT: .Ltmp[[TMP2:[0-9]+]]: -; CHECK-NEXT: .localentry use_toc_implicit, .Ltmp[[TMP2]]-.Ltmp[[TMP1]] +; CHECK-NEXT: .Lfunc_gep[[FN:[0-9]+]]: +; CHECK-NEXT: addis 2, 12, .TOC.-.Lfunc_gep[[FN]]@ha +; CHECK-NEXT: addi 2, 2, .TOC.-.Lfunc_gep[[FN]]@l +; CHECK-NEXT: .Lfunc_lep[[FN]]: +; CHECK-NEXT: .localentry use_toc_implicit, .Lfunc_lep[[FN]]-.Lfunc_gep[[FN]] ; CHECK-NEXT: %entry call void @callee() ret void diff --git a/test/CodeGen/PowerPC/pr25802.ll b/test/CodeGen/PowerPC/pr25802.ll new file mode 100644 index 000000000000..0631850be5fa --- /dev/null +++ b/test/CodeGen/PowerPC/pr25802.ll @@ -0,0 +1,52 @@ +; RUN: llc < %s | FileCheck %s +; CHECK: .long .Ltmp6-.Ltmp12 # Call between .Ltmp12 and .Ltmp6 + +; We used to crash in filetype=obj when computing a negative value. +; RUN: llc -filetype=obj < %s + +target triple = "powerpc--netbsd" +@_ZTI1I = external constant { i8*, i8* } +define void @f(i8 %foo, i32 %bar) personality i8* bitcast (void ()* @g to i8*) { + invoke void @g() + to label %try.cont unwind label %lpad +lpad: ; preds = %0 + %tmp = landingpad { i8*, i32 } + catch i8* bitcast ({ i8*, i8* }* @_ZTI1I to i8*) + br i1 undef, label %catch10, label %catch +catch10: ; preds = %lpad + %tmp8 = load i32, i32* undef, align 4 + %conv.i.i = zext i8 %foo to i32 + %cond.i.i = select i1 undef, i32 %conv.i.i, i32 %tmp8 + invoke void @_Z24__put_character_sequenceIccEvR1AIT_T0_Ej(i32 %cond.i.i) + to label %invoke.cont20 unwind label %lpad15 +invoke.cont20: ; preds = %catch10 + ret void +try.cont: ; preds = %0 + ret void +catch: ; preds = %lpad + %tmp14 = load i32, i32* undef, align 4 + %conv.i.i34 = zext i8 %foo to i32 + %cond.i.i35 = select i1 undef, i32 %conv.i.i34, i32 %tmp14 + invoke void @_Z24__put_character_sequenceIccEvR1AIT_T0_Ej(i32 %cond.i.i35) + to label %invoke.cont8 unwind label %lpad3 +invoke.cont8: ; preds = %call2.i.i.noexc36 + ret void +lpad3: ; preds = %call2.i.i.noexc36, %catch + %tmp16 = landingpad { i8*, i32 } + cleanup + invoke void @g() + to label %eh.resume unwind label %terminate.lpad +lpad15: ; preds = %catch10 + %tmp19 = landingpad { i8*, i32 } + cleanup + invoke void @g() + to label %eh.resume unwind label %terminate.lpad +eh.resume: ; preds = %lpad15, %lpad3 + ret void +terminate.lpad: ; preds = %lpad15, %lpad3 + %tmp22 = landingpad { i8*, i32 } + catch i8* null + ret void +} +declare void @g() +declare void @_Z24__put_character_sequenceIccEvR1AIT_T0_Ej(i32) diff --git a/test/CodeGen/PowerPC/tls_get_addr_clobbers.ll b/test/CodeGen/PowerPC/tls_get_addr_clobbers.ll new file mode 100644 index 000000000000..400a1f297f00 --- /dev/null +++ b/test/CodeGen/PowerPC/tls_get_addr_clobbers.ll @@ -0,0 +1,54 @@ +; RUN: llc -mtriple="powerpc64le-unknown-linux-gnu" -relocation-model=pic < %s | FileCheck %s + +@a = thread_local global i32* null, align 8 + +define void @test_foo(i32* nocapture %x01, i32* nocapture %x02, i32* nocapture %x03, i32* nocapture %x04, i32* nocapture %x05, i32* nocapture %x06, i32* nocapture %x07, i32* nocapture %x08) #0 { +entry: + +; CHECK-LABEL: test_foo: +; CHECK: stdu 1, {{-?[0-9]+}}(1) +; CHECK-DAG: mr [[BACKUP_3:[0-9]+]], 3 +; CHECK-DAG: mr [[BACKUP_4:[0-9]+]], 4 +; CHECK-DAG: mr [[BACKUP_5:[0-9]+]], 5 +; CHECK-DAG: mr [[BACKUP_6:[0-9]+]], 6 +; CHECK-DAG: mr [[BACKUP_7:[0-9]+]], 7 +; CHECK-DAG: mr [[BACKUP_8:[0-9]+]], 8 +; CHECK-DAG: mr [[BACKUP_9:[0-9]+]], 9 +; CHECK-DAG: mr [[BACKUP_10:[0-9]+]], 10 +; CHECK-DAG: std [[BACKUP_3]], {{[0-9]+}}(1) +; CHECK-DAG: std [[BACKUP_4]], {{[0-9]+}}(1) +; CHECK-DAG: std [[BACKUP_5]], {{[0-9]+}}(1) +; CHECK-DAG: std [[BACKUP_6]], {{[0-9]+}}(1) +; CHECK-DAG: std [[BACKUP_7]], {{[0-9]+}}(1) +; CHECK-DAG: std [[BACKUP_8]], {{[0-9]+}}(1) +; CHECK-DAG: std [[BACKUP_9]], {{[0-9]+}}(1) +; CHECK-DAG: std [[BACKUP_10]], {{[0-9]+}}(1) +; CHECK: bl __tls_get_addr +; CHECK-DAG: stw 3, 0([[BACKUP_3]]) +; CHECK-DAG: stw 3, 0([[BACKUP_4]]) +; CHECK-DAG: stw 3, 0([[BACKUP_5]]) +; CHECK-DAG: stw 3, 0([[BACKUP_6]]) +; CHECK-DAG: stw 3, 0([[BACKUP_7]]) +; CHECK-DAG: stw 3, 0([[BACKUP_8]]) +; CHECK-DAG: stw 3, 0([[BACKUP_9]]) +; CHECK-DAG: stw 3, 0([[BACKUP_10]]) +; CHECK: blr + + %0 = load i32*, i32** @a, align 8 + %cmp = icmp eq i32* %0, null + br i1 %cmp, label %return, label %if.end + +if.end: ; preds = %entry + store i32 0, i32* %x01, align 4 + store i32 0, i32* %x02, align 4 + store i32 0, i32* %x03, align 4 + store i32 0, i32* %x04, align 4 + store i32 0, i32* %x05, align 4 + store i32 0, i32* %x06, align 4 + store i32 0, i32* %x07, align 4 + store i32 0, i32* %x08, align 4 + br label %return + +return: ; preds = %entry, %if.end + ret void +} diff --git a/test/CodeGen/PowerPC/tls_get_addr_stackframe.ll b/test/CodeGen/PowerPC/tls_get_addr_stackframe.ll new file mode 100644 index 000000000000..4a235983e6f7 --- /dev/null +++ b/test/CodeGen/PowerPC/tls_get_addr_stackframe.ll @@ -0,0 +1,32 @@ +; RUN: llc -mtriple="powerpc64le-unknown-linux-gnu" -relocation-model=pic < %s | FileCheck %s +; CHECK-LABEL: foo_test: +; CHECK: mflr 0 +; CHECK: __tls_get_addr + +%struct1.2.41 = type { %struct2.0.39, %struct3.1.40, %struct1.2.41* } +%struct2.0.39 = type { i64, i32, i32, i32, i32 } +%struct3.1.40 = type { [160 x i8] } + +@tls_var = external thread_local global %struct1.2.41*, align 8 + +define void @foo_test() { + %1 = load %struct1.2.41*, %struct1.2.41** @tls_var, align 8 + br i1 undef, label %foo.exit, label %2 + +;