tstellar / rpms / llvm

Forked from rpms/llvm 5 years ago
Clone
0c3be08
From 5ac4f80be3e8b5d42475aeaba246455e0016c7ef Mon Sep 17 00:00:00 2001
0c3be08
From: Anthony Ramine <n.oxyde@gmail.com>
0c3be08
Date: Sun, 27 Nov 2016 16:28:12 +0100
0c3be08
Subject: [rust-lang/llvm#57] Backport rL277331
0c3be08
0c3be08
---
0c3be08
 lib/Target/AArch64/AArch64InstrInfo.cpp            |  3 +
0c3be08
 .../MIR/AArch64/inst-size-tlsdesc-callseq.mir      | 84 ++++++++++++++++++++++
0c3be08
 2 files changed, 87 insertions(+)
0c3be08
 create mode 100644 test/CodeGen/MIR/AArch64/inst-size-tlsdesc-callseq.mir
0c3be08
0c3be08
diff --git a/lib/Target/AArch64/AArch64InstrInfo.cpp b/lib/Target/AArch64/AArch64InstrInfo.cpp
0c3be08
index 0aa4708f35ac..d39542a8e4eb 100644
0c3be08
--- a/lib/Target/AArch64/AArch64InstrInfo.cpp
0c3be08
+++ b/lib/Target/AArch64/AArch64InstrInfo.cpp
0c3be08
@@ -56,6 +56,9 @@ unsigned AArch64InstrInfo::GetInstSizeInBytes(const MachineInstr &MI) const {
0c3be08
   case TargetOpcode::IMPLICIT_DEF:
0c3be08
   case TargetOpcode::KILL:
0c3be08
     return 0;
0c3be08
+  case AArch64::TLSDESC_CALLSEQ:
0c3be08
+    // This gets lowered to an instruction sequence which takes 16 bytes
0c3be08
+    return 16;
0c3be08
   }
0c3be08
 
0c3be08
   llvm_unreachable("GetInstSizeInBytes()- Unable to determin insn size");
0c3be08
diff --git a/test/CodeGen/MIR/AArch64/inst-size-tlsdesc-callseq.mir b/test/CodeGen/MIR/AArch64/inst-size-tlsdesc-callseq.mir
0c3be08
new file mode 100644
0c3be08
index 000000000000..2d966ece768e
0c3be08
--- /dev/null
0c3be08
+++ b/test/CodeGen/MIR/AArch64/inst-size-tlsdesc-callseq.mir
0c3be08
@@ -0,0 +1,84 @@
0c3be08
+# RUN: llc -mtriple=aarch64-unknown -run-pass aarch64-branch-relax -aarch64-tbz-offset-bits=4 %s -o - | FileCheck %s
0c3be08
+--- |
0c3be08
+  ; ModuleID = 'test.ll'
0c3be08
+  source_filename = "test.ll"
0c3be08
+  target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
0c3be08
+  target triple = "aarch64-unknown"
0c3be08
+
0c3be08
+  @ThreadLocalGlobal = external thread_local local_unnamed_addr global i32, align 8
0c3be08
+
0c3be08
+  define i32 @test_tlsdesc_callseq_length(i32 %in) {
0c3be08
+    %val = and i32 %in, 1
0c3be08
+    %tst = icmp eq i32 %val, 0
0c3be08
+    br i1 %tst, label %true, label %false
0c3be08
+
0c3be08
+  true:                                             ; preds = %0
0c3be08
+    %1 = load i32, i32* @ThreadLocalGlobal, align 8
0c3be08
+    ret i32 %1
0c3be08
+
0c3be08
+  false:                                            ; preds = %0
0c3be08
+    ret i32 0
0c3be08
+  }
0c3be08
+
0c3be08
+...
0c3be08
+---
0c3be08
+# CHECK-LABEL: name:{{.*}}test_tlsdesc_callseq_length
0c3be08
+# If the size of TLSDESC_CALLSEQ is computed correctly, that will push
0c3be08
+# the bb.2.false block too far away from the TBNZW, so the branch will
0c3be08
+# have to be relaxed (note that we're using -aarch64-tbz-offset-bits to
0c3be08
+# constrain the range that can be reached with the TBNZW to something smaller
0c3be08
+# than what TLSDESC_CALLSEQ is lowered to).
0c3be08
+# CHECK: TBZW killed %w0, 0, %bb.1.true
0c3be08
+# CHECK: B %bb.2.false
0c3be08
+name:            test_tlsdesc_callseq_length
0c3be08
+alignment:       2
0c3be08
+exposesReturnsTwice: false
0c3be08
+hasInlineAsm:    false
0c3be08
+allVRegsAllocated: true
0c3be08
+isSSA:           false
0c3be08
+tracksRegLiveness: false
0c3be08
+tracksSubRegLiveness: false
0c3be08
+liveins:
0c3be08
+  - { reg: '%w0' }
0c3be08
+frameInfo:
0c3be08
+  isFrameAddressTaken: false
0c3be08
+  isReturnAddressTaken: false
0c3be08
+  hasStackMap:     false
0c3be08
+  hasPatchPoint:   false
0c3be08
+  stackSize:       16
0c3be08
+  offsetAdjustment: 0
0c3be08
+  maxAlignment:    16
0c3be08
+  adjustsStack:    false
0c3be08
+  hasCalls:        true
0c3be08
+  maxCallFrameSize: 0
0c3be08
+  hasOpaqueSPAdjustment: false
0c3be08
+  hasVAStart:      false
0c3be08
+  hasMustTailInVarArgFunc: false
0c3be08
+stack:
0c3be08
+  - { id: 0, type: spill-slot, offset: -16, size: 8, alignment: 16, callee-saved-register: '%lr' }
0c3be08
+body:             |
0c3be08
+  bb.0 (%ir-block.0):
0c3be08
+    successors: %bb.1.true, %bb.2.false
0c3be08
+    liveins: %w0, %lr
0c3be08
+
0c3be08
+    TBNZW killed %w0, 0, %bb.2.false
0c3be08
+
0c3be08
+  bb.1.true:
0c3be08
+    liveins: %lr
0c3be08
+
0c3be08
+    early-clobber %sp = frame-setup STRXpre killed %lr, %sp, -16 :: (store 8 into %stack.0)
0c3be08
+    frame-setup CFI_INSTRUCTION def_cfa_offset 16
0c3be08
+    frame-setup CFI_INSTRUCTION offset %w30, -16
0c3be08
+    TLSDESC_CALLSEQ target-flags(aarch64-tls) @ThreadLocalGlobal, implicit-def dead %lr, implicit-def %x0, implicit-def dead %x1
0c3be08
+    %x8 = MRS 56962
0c3be08
+    %w0 = LDRWroX killed %x8, killed %x0, 0, 0 :: (load 4 from @ThreadLocalGlobal, align 8)
0c3be08
+    early-clobber %sp, %lr = LDRXpost %sp, 16 :: (load 8 from %stack.0)
0c3be08
+    RET killed %lr, implicit killed %w0
0c3be08
+
0c3be08
+  bb.2.false:
0c3be08
+    liveins: %lr
0c3be08
+
0c3be08
+    %w0 = ORRWrs %wzr, %wzr, 0
0c3be08
+    RET killed %lr, implicit killed %w0
0c3be08
+
0c3be08
+...
0c3be08
-- 
0c3be08
2.9.3
0c3be08