|
| 1 | +# RUN: llc -mtriple riscv64 -mattr=+m,+v -run-pass=prologepilog \ |
| 2 | +# RUN: -riscv-v-vector-bits-min=512 -o - %s | FileCheck %s |
| 3 | +# |
| 4 | +# Stack layout of this program |
| 5 | +# |--------------------------| -- <-- Incoming SP |
| 6 | +# | a7 (Vaarg) | |
| 7 | +# | ------------------------ | -- <-- New SP + vlenb + 56 |
| 8 | +# | a6 (Vaarg) | |
| 9 | +# | ------------------------ | -- <-- New SP + vlenb + 48 |
| 10 | +# | ra (Callee-saved reg) | |
| 11 | +# | ------------------------ | -- <-- New SP + vlenb + 40 |
| 12 | +# | s0 (Callee-saved reg) | |
| 13 | +# | ------------------------ | -- <-- New SP + vlenb + 32 |
| 14 | +# | s1 (Callee-saved reg) | |
| 15 | +# | ------------------------ | -- <-- New SP + vlenb + 24 |
| 16 | +# | v8 (RVV objects) | |
| 17 | +# | ------------------------ | -- <-- New SP + 24 |
| 18 | +# | buf1 | |
| 19 | +# |--------------------------| -- <-- New SP + 16 |
| 20 | +# | Stack ID 5 | |
| 21 | +# |--------------------------| -- <-- New SP + 8 |
| 22 | +# | Stack ID 6 | |
| 23 | +# |--------------------------| -- <-- New SP |
| 24 | + |
| 25 | +--- | |
| 26 | + ; ModuleID = 'wrong-stack-offset-for-rvv-object.ll' |
| 27 | + source_filename = "wrong-stack-offset-for-rvv-object.ll" |
| 28 | + target datalayout = "e-m:e-p:64:64-i64:64-i128:128-n64-S128" |
| 29 | + target triple = "riscv64" |
| 30 | + |
| 31 | + %struct = type { i32 } |
| 32 | + |
| 33 | + define void @asm_fprintf(%struct %file, i8* %p, [10 x i8]* %buf, i8* %arrayidx3, <2 x i8>* %0, i8* %1, ...) #0 { |
| 34 | + entry: |
| 35 | + %buf1 = alloca [10 x i8], i32 0, align 8 |
| 36 | + %arrayidx32 = getelementptr inbounds [10 x i8], [10 x i8]* %buf, i64 0, i64 1 |
| 37 | + br label %while.cond |
| 38 | + |
| 39 | + while.cond: ; preds = %while.cond, %sw.bb, %entry |
| 40 | + %incdec.ptr = getelementptr inbounds i8, i8* undef, i64 1 |
| 41 | + %2 = load i8, i8* null, align 1 |
| 42 | + %3 = zext i8 0 to i64 |
| 43 | + %cond = icmp eq i64 %3, 0 |
| 44 | + br i1 %cond, label %sw.bb, label %while.cond |
| 45 | + |
| 46 | + sw.bb: ; preds = %while.cond |
| 47 | + %4 = load i8, i8* null, align 1 |
| 48 | + store <2 x i8> zeroinitializer, <2 x i8>* %0, align 1 |
| 49 | + %call = call i32 (i8*, ...) @fprintf(i8* %p) |
| 50 | + br label %while.cond |
| 51 | + } |
| 52 | + |
| 53 | + declare i32 @fprintf(i8*, ...) #0 |
| 54 | + |
| 55 | + attributes #0 = { "target-features"="+m,+v" } |
| 56 | + |
| 57 | +... |
| 58 | +--- |
| 59 | +name: asm_fprintf |
| 60 | +alignment: 4 |
| 61 | +exposesReturnsTwice: false |
| 62 | +legalized: false |
| 63 | +regBankSelected: false |
| 64 | +selected: false |
| 65 | +failedISel: false |
| 66 | +tracksRegLiveness: true |
| 67 | +hasWinCFI: false |
| 68 | +failsVerification: false |
| 69 | +tracksDebugUserValues: true |
| 70 | +registers: [] |
| 71 | +liveins: |
| 72 | + - { reg: '$x11', virtual-reg: '' } |
| 73 | + - { reg: '$x14', virtual-reg: '' } |
| 74 | + - { reg: '$x16', virtual-reg: '' } |
| 75 | + - { reg: '$x17', virtual-reg: '' } |
| 76 | +frameInfo: |
| 77 | + isFrameAddressTaken: false |
| 78 | + isReturnAddressTaken: false |
| 79 | + hasStackMap: false |
| 80 | + hasPatchPoint: false |
| 81 | + stackSize: 0 |
| 82 | + offsetAdjustment: 0 |
| 83 | + maxAlignment: 8 |
| 84 | + adjustsStack: false |
| 85 | + hasCalls: true |
| 86 | + stackProtector: '' |
| 87 | + maxCallFrameSize: 4294967295 |
| 88 | + cvBytesOfCalleeSavedRegisters: 0 |
| 89 | + hasOpaqueSPAdjustment: false |
| 90 | + hasVAStart: false |
| 91 | + hasMustTailInVarArgFunc: false |
| 92 | + hasTailCall: false |
| 93 | + localFrameSize: 0 |
| 94 | + savePoint: '' |
| 95 | + restorePoint: '' |
| 96 | +fixedStack: |
| 97 | + - { id: 0, type: default, offset: -8, size: 8, alignment: 8, stack-id: default, |
| 98 | + isImmutable: true, isAliased: false, callee-saved-register: '', callee-saved-restored: true, |
| 99 | + debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } |
| 100 | + - { id: 1, type: default, offset: -16, size: 8, alignment: 16, stack-id: default, |
| 101 | + isImmutable: true, isAliased: false, callee-saved-register: '', callee-saved-restored: true, |
| 102 | + debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } |
| 103 | + - { id: 2, type: default, offset: -16, size: 8, alignment: 16, stack-id: default, |
| 104 | + isImmutable: true, isAliased: false, callee-saved-register: '', callee-saved-restored: true, |
| 105 | + debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } |
| 106 | +stack: |
| 107 | + - { id: 0, name: buf1, type: default, offset: 0, size: 1, alignment: 8, |
| 108 | + stack-id: default, callee-saved-register: '', callee-saved-restored: true, |
| 109 | + debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } |
| 110 | + - { id: 1, name: '', type: spill-slot, offset: 0, size: 8, alignment: 8, |
| 111 | + stack-id: scalable-vector, callee-saved-register: '', callee-saved-restored: true, |
| 112 | + debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } |
| 113 | +callSites: [] |
| 114 | +debugValueSubstitutions: [] |
| 115 | +constants: [] |
| 116 | +machineFunctionInfo: |
| 117 | + varArgsFrameIndex: -1 |
| 118 | + varArgsSaveSize: 16 |
| 119 | +body: | |
| 120 | + ; CHECK-LABEL: name: asm_fprintf |
| 121 | + ; CHECK: stack: |
| 122 | + ; CHECK-NEXT: - { id: 0, name: buf1, type: default, offset: -48, size: 1, alignment: 8, |
| 123 | + ; CHECK-NEXT: stack-id: default, callee-saved-register: '', callee-saved-restored: true, |
| 124 | + ; CHECK-NEXT: debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } |
| 125 | + ; CHECK-NEXT: - { id: 1, name: '', type: spill-slot, offset: -8, size: 8, alignment: 8, |
| 126 | + ; CHECK-NEXT: stack-id: scalable-vector, callee-saved-register: '', callee-saved-restored: true, |
| 127 | + ; CHECK-NEXT: debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } |
| 128 | + ; CHECK-NEXT: - { id: 2, name: '', type: spill-slot, offset: -24, size: 8, alignment: 8, |
| 129 | + ; CHECK-NEXT: stack-id: default, callee-saved-register: '$x1', callee-saved-restored: true, |
| 130 | + ; CHECK-NEXT: debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } |
| 131 | + ; CHECK-NEXT: - { id: 3, name: '', type: spill-slot, offset: -32, size: 8, alignment: 8, |
| 132 | + ; CHECK-NEXT: stack-id: default, callee-saved-register: '$x8', callee-saved-restored: true, |
| 133 | + ; CHECK-NEXT: debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } |
| 134 | + ; CHECK-NEXT: - { id: 4, name: '', type: spill-slot, offset: -40, size: 8, alignment: 8, |
| 135 | + ; CHECK-NEXT: stack-id: default, callee-saved-register: '$x9', callee-saved-restored: true, |
| 136 | + ; CHECK-NEXT: debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } |
| 137 | + ; CHECK-NEXT: - { id: 5, name: '', type: default, offset: -56, size: 8, alignment: 8, |
| 138 | + ; CHECK-NEXT: stack-id: default, callee-saved-register: '', callee-saved-restored: true, |
| 139 | + ; CHECK-NEXT: debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } |
| 140 | + ; CHECK-NEXT: - { id: 6, name: '', type: default, offset: -64, size: 8, alignment: 8, |
| 141 | + ; CHECK-NEXT: stack-id: default, callee-saved-register: '', callee-saved-restored: true, |
| 142 | + ; CHECK-NEXT: debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } |
| 143 | + ; CHECK: bb.0.entry: |
| 144 | + ; CHECK-NEXT: successors: %bb.1(0x80000000) |
| 145 | + ; CHECK-NEXT: liveins: $x11, $x14, $x16, $x17, $x1, $x8, $x9 |
| 146 | + ; CHECK-NEXT: {{ $}} |
| 147 | + ; CHECK-NEXT: $x2 = frame-setup ADDI $x2, -64 |
| 148 | + ; CHECK-NEXT: frame-setup CFI_INSTRUCTION def_cfa_offset 64 |
| 149 | + ; CHECK-NEXT: SD killed $x1, $x2, 40 :: (store (s64) into %stack.2) |
| 150 | + ; CHECK-NEXT: SD killed $x8, $x2, 32 :: (store (s64) into %stack.3) |
| 151 | + ; CHECK-NEXT: SD killed $x9, $x2, 24 :: (store (s64) into %stack.4) |
| 152 | + ; CHECK-NEXT: frame-setup CFI_INSTRUCTION offset $x1, -24 |
| 153 | + ; CHECK-NEXT: frame-setup CFI_INSTRUCTION offset $x8, -32 |
| 154 | + ; CHECK-NEXT: frame-setup CFI_INSTRUCTION offset $x9, -40 |
| 155 | + ; CHECK-NEXT: $x10 = frame-setup PseudoReadVLENB |
| 156 | + ; CHECK-NEXT: $x2 = frame-setup SUB $x2, killed $x10 |
| 157 | + ; CHECK-NEXT: renamable $x8 = COPY $x14 |
| 158 | + ; CHECK-NEXT: renamable $x9 = COPY $x11 |
| 159 | + ; CHECK-NEXT: $x10 = PseudoReadVLENB |
| 160 | + ; CHECK-NEXT: $x10 = ADD $x2, killed $x10 |
| 161 | + ; CHECK-NEXT: SD killed renamable $x17, killed $x10, 56 :: (store (s64)) |
| 162 | + ; CHECK-NEXT: $x10 = PseudoReadVLENB |
| 163 | + ; CHECK-NEXT: $x10 = ADD $x2, killed $x10 |
| 164 | + ; CHECK-NEXT: SD killed renamable $x16, killed $x10, 48 :: (store (s64) into %fixed-stack.1, align 16) |
| 165 | + ; CHECK-NEXT: dead $x0 = PseudoVSETIVLI 2, 69, implicit-def $vl, implicit-def $vtype |
| 166 | + ; CHECK-NEXT: renamable $v8 = PseudoVMV_V_I_MF8 0, 2, 3, implicit $vl, implicit $vtype |
| 167 | + ; CHECK-NEXT: $x10 = ADDI $x2, 40 |
| 168 | + ; CHECK-NEXT: PseudoVSPILL_M1 killed renamable $v8, killed $x10 :: (store unknown-size into %stack.1, align 8) |
| 169 | + ; CHECK-NEXT: {{ $}} |
| 170 | + ; CHECK-NEXT: bb.1.while.cond: |
| 171 | + ; CHECK-NEXT: successors: %bb.2(0x30000000), %bb.1(0x50000000) |
| 172 | + ; CHECK-NEXT: liveins: $x8, $x9 |
| 173 | + ; CHECK-NEXT: {{ $}} |
| 174 | + ; CHECK-NEXT: BNE $x0, $x0, %bb.1 |
| 175 | + ; CHECK-NEXT: PseudoBR %bb.2 |
| 176 | + ; CHECK-NEXT: {{ $}} |
| 177 | + ; CHECK-NEXT: bb.2.sw.bb: |
| 178 | + ; CHECK-NEXT: successors: %bb.1(0x80000000) |
| 179 | + ; CHECK-NEXT: liveins: $x8, $x9 |
| 180 | + ; CHECK-NEXT: {{ $}} |
| 181 | + ; CHECK-NEXT: dead $x0 = PseudoVSETIVLI 2, 69, implicit-def $vl, implicit-def $vtype |
| 182 | + ; CHECK-NEXT: $x10 = ADDI $x2, 40 |
| 183 | + ; CHECK-NEXT: renamable $v8 = PseudoVRELOAD_M1 killed $x10 :: (load unknown-size from %stack.1, align 8) |
| 184 | + ; CHECK-NEXT: PseudoVSE8_V_MF8 killed renamable $v8, renamable $x8, 2, 3, implicit $vl, implicit $vtype :: (store (s16) into %ir.0, align 1) |
| 185 | + ; CHECK-NEXT: $x10 = COPY renamable $x9 |
| 186 | + ; CHECK-NEXT: PseudoCALL target-flags(riscv-plt) @fprintf, csr_ilp32d_lp64d, implicit-def dead $x1, implicit killed $x10, implicit-def $x2, implicit-def dead $x10 |
| 187 | + ; CHECK-NEXT: PseudoBR %bb.1 |
| 188 | + bb.0.entry: |
| 189 | + successors: %bb.1(0x80000000) |
| 190 | + liveins: $x11, $x14, $x16, $x17 |
| 191 | +
|
| 192 | + renamable $x8 = COPY $x14 |
| 193 | + renamable $x9 = COPY $x11 |
| 194 | + SD killed renamable $x17, %fixed-stack.0, 0 :: (store (s64)) |
| 195 | + SD killed renamable $x16, %fixed-stack.1, 0 :: (store (s64) into %fixed-stack.1, align 16) |
| 196 | + dead $x0 = PseudoVSETIVLI 2, 69, implicit-def $vl, implicit-def $vtype |
| 197 | + renamable $v8 = PseudoVMV_V_I_MF8 0, 2, 3, implicit $vl, implicit $vtype |
| 198 | + PseudoVSPILL_M1 killed renamable $v8, %stack.1 :: (store unknown-size into %stack.1, align 8) |
| 199 | +
|
| 200 | + bb.1.while.cond: |
| 201 | + successors: %bb.2(0x30000000), %bb.1(0x50000000) |
| 202 | + liveins: $x8, $x9 |
| 203 | +
|
| 204 | + BNE $x0, $x0, %bb.1 |
| 205 | + PseudoBR %bb.2 |
| 206 | +
|
| 207 | + bb.2.sw.bb: |
| 208 | + successors: %bb.1(0x80000000) |
| 209 | + liveins: $x8, $x9 |
| 210 | +
|
| 211 | + dead $x0 = PseudoVSETIVLI 2, 69, implicit-def $vl, implicit-def $vtype |
| 212 | + renamable $v8 = PseudoVRELOAD_M1 %stack.1 :: (load unknown-size from %stack.1, align 8) |
| 213 | + PseudoVSE8_V_MF8 killed renamable $v8, renamable $x8, 2, 3, implicit $vl, implicit $vtype :: (store (s16) into %ir.0, align 1) |
| 214 | + ADJCALLSTACKDOWN 0, 0, implicit-def dead $x2, implicit $x2 |
| 215 | + $x10 = COPY renamable $x9 |
| 216 | + PseudoCALL target-flags(riscv-plt) @fprintf, csr_ilp32d_lp64d, implicit-def dead $x1, implicit killed $x10, implicit-def $x2, implicit-def dead $x10 |
| 217 | + ADJCALLSTACKUP 0, 0, implicit-def dead $x2, implicit $x2 |
| 218 | + PseudoBR %bb.1 |
| 219 | +
|
| 220 | +... |
0 commit comments