|
| 1 | +From 5ac4f80be3e8b5d42475aeaba246455e0016c7ef Mon Sep 17 00:00:00 2001 |
| 2 | +From: Anthony Ramine < [email protected]> |
| 3 | +Date: Sun, 27 Nov 2016 16:28:12 +0100 |
| 4 | +Subject: [rust-lang/llvm#57] Backport rL277331 |
| 5 | + |
| 6 | +--- |
| 7 | + lib/Target/AArch64/AArch64InstrInfo.cpp | 3 + |
| 8 | + .../MIR/AArch64/inst-size-tlsdesc-callseq.mir | 84 ++++++++++++++++++++++ |
| 9 | + 2 files changed, 87 insertions(+) |
| 10 | + create mode 100644 test/CodeGen/MIR/AArch64/inst-size-tlsdesc-callseq.mir |
| 11 | + |
| 12 | +diff --git a/lib/Target/AArch64/AArch64InstrInfo.cpp b/lib/Target/AArch64/AArch64InstrInfo.cpp |
| 13 | +index 0aa4708f35ac..d39542a8e4eb 100644 |
| 14 | +--- a/lib/Target/AArch64/AArch64InstrInfo.cpp |
| 15 | ++++ b/lib/Target/AArch64/AArch64InstrInfo.cpp |
| 16 | +@@ -56,6 +56,9 @@ unsigned AArch64InstrInfo::GetInstSizeInBytes(const MachineInstr &MI) const { |
| 17 | + case TargetOpcode::IMPLICIT_DEF: |
| 18 | + case TargetOpcode::KILL: |
| 19 | + return 0; |
| 20 | ++ case AArch64::TLSDESC_CALLSEQ: |
| 21 | ++ // This gets lowered to an instruction sequence which takes 16 bytes |
| 22 | ++ return 16; |
| 23 | + } |
| 24 | + |
| 25 | + llvm_unreachable("GetInstSizeInBytes()- Unable to determin insn size"); |
| 26 | +diff --git a/test/CodeGen/MIR/AArch64/inst-size-tlsdesc-callseq.mir b/test/CodeGen/MIR/AArch64/inst-size-tlsdesc-callseq.mir |
| 27 | +new file mode 100644 |
| 28 | +index 000000000000..2d966ece768e |
| 29 | +--- /dev/null |
| 30 | ++++ b/test/CodeGen/MIR/AArch64/inst-size-tlsdesc-callseq.mir |
| 31 | +@@ -0,0 +1,84 @@ |
| 32 | ++# RUN: llc -mtriple=aarch64-unknown -run-pass aarch64-branch-relax -aarch64-tbz-offset-bits=4 %s -o - | FileCheck %s |
| 33 | ++--- | |
| 34 | ++ ; ModuleID = 'test.ll' |
| 35 | ++ source_filename = "test.ll" |
| 36 | ++ target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128" |
| 37 | ++ target triple = "aarch64-unknown" |
| 38 | ++ |
| 39 | ++ @ThreadLocalGlobal = external thread_local local_unnamed_addr global i32, align 8 |
| 40 | ++ |
| 41 | ++ define i32 @test_tlsdesc_callseq_length(i32 %in) { |
| 42 | ++ %val = and i32 %in, 1 |
| 43 | ++ %tst = icmp eq i32 %val, 0 |
| 44 | ++ br i1 %tst, label %true, label %false |
| 45 | ++ |
| 46 | ++ true: ; preds = %0 |
| 47 | ++ %1 = load i32, i32* @ThreadLocalGlobal, align 8 |
| 48 | ++ ret i32 %1 |
| 49 | ++ |
| 50 | ++ false: ; preds = %0 |
| 51 | ++ ret i32 0 |
| 52 | ++ } |
| 53 | ++ |
| 54 | ++... |
| 55 | ++--- |
| 56 | ++# CHECK-LABEL: name:{{.*}}test_tlsdesc_callseq_length |
| 57 | ++# If the size of TLSDESC_CALLSEQ is computed correctly, that will push |
| 58 | ++# the bb.2.false block too far away from the TBNZW, so the branch will |
| 59 | ++# have to be relaxed (note that we're using -aarch64-tbz-offset-bits to |
| 60 | ++# constrain the range that can be reached with the TBNZW to something smaller |
| 61 | ++# than what TLSDESC_CALLSEQ is lowered to). |
| 62 | ++# CHECK: TBZW killed %w0, 0, %bb.1.true |
| 63 | ++# CHECK: B %bb.2.false |
| 64 | ++name: test_tlsdesc_callseq_length |
| 65 | ++alignment: 2 |
| 66 | ++exposesReturnsTwice: false |
| 67 | ++hasInlineAsm: false |
| 68 | ++allVRegsAllocated: true |
| 69 | ++isSSA: false |
| 70 | ++tracksRegLiveness: false |
| 71 | ++tracksSubRegLiveness: false |
| 72 | ++liveins: |
| 73 | ++ - { reg: '%w0' } |
| 74 | ++frameInfo: |
| 75 | ++ isFrameAddressTaken: false |
| 76 | ++ isReturnAddressTaken: false |
| 77 | ++ hasStackMap: false |
| 78 | ++ hasPatchPoint: false |
| 79 | ++ stackSize: 16 |
| 80 | ++ offsetAdjustment: 0 |
| 81 | ++ maxAlignment: 16 |
| 82 | ++ adjustsStack: false |
| 83 | ++ hasCalls: true |
| 84 | ++ maxCallFrameSize: 0 |
| 85 | ++ hasOpaqueSPAdjustment: false |
| 86 | ++ hasVAStart: false |
| 87 | ++ hasMustTailInVarArgFunc: false |
| 88 | ++stack: |
| 89 | ++ - { id: 0, type: spill-slot, offset: -16, size: 8, alignment: 16, callee-saved-register: '%lr' } |
| 90 | ++body: | |
| 91 | ++ bb.0 (%ir-block.0): |
| 92 | ++ successors: %bb.1.true, %bb.2.false |
| 93 | ++ liveins: %w0, %lr |
| 94 | ++ |
| 95 | ++ TBNZW killed %w0, 0, %bb.2.false |
| 96 | ++ |
| 97 | ++ bb.1.true: |
| 98 | ++ liveins: %lr |
| 99 | ++ |
| 100 | ++ early-clobber %sp = frame-setup STRXpre killed %lr, %sp, -16 :: (store 8 into %stack.0) |
| 101 | ++ frame-setup CFI_INSTRUCTION def_cfa_offset 16 |
| 102 | ++ frame-setup CFI_INSTRUCTION offset %w30, -16 |
| 103 | ++ TLSDESC_CALLSEQ target-flags(aarch64-tls) @ThreadLocalGlobal, implicit-def dead %lr, implicit-def %x0, implicit-def dead %x1 |
| 104 | ++ %x8 = MRS 56962 |
| 105 | ++ %w0 = LDRWroX killed %x8, killed %x0, 0, 0 :: (load 4 from @ThreadLocalGlobal, align 8) |
| 106 | ++ early-clobber %sp, %lr = LDRXpost %sp, 16 :: (load 8 from %stack.0) |
| 107 | ++ RET killed %lr, implicit killed %w0 |
| 108 | ++ |
| 109 | ++ bb.2.false: |
| 110 | ++ liveins: %lr |
| 111 | ++ |
| 112 | ++ %w0 = ORRWrs %wzr, %wzr, 0 |
| 113 | ++ RET killed %lr, implicit killed %w0 |
| 114 | ++ |
| 115 | ++... |
| 116 | +-- |
| 117 | +2.9.3 |
| 118 | + |
0 commit comments