llvm.org GIT mirror llvm / b7cecba
Revert r265039 "[X86] Merge adjacent stack adjustments in eliminateCallFramePseudoInstr (PR27140)" I think it might have caused these build breakages: http://lab.llvm.org:8011/builders/clang-x86-win2008-selfhost/builds/7234/steps/build%20stage%202/logs/stdio http://lab.llvm.org:8011/builders/sanitizer-windows/builds/19566/steps/run%20tests/logs/stdio git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265046 91177308-0d34-0410-b5e6-96231b3b80d8 Hans Wennborg 3 years ago
9 changed file(s) with 31 addition(s) and 66 deletion(s). Raw diff Collapse all Expand all
25332533 BuildCFI(MBB, I, DL,
25342534 MCCFIInstruction::createAdjustCfaOffset(nullptr, -InternalAmt));
25352535
2536 // Add Amount to SP to destroy a frame, or subtract to setup.
2537 int64_t StackAdjustment = isDestroy ? Amount : -Amount;
2538
2539 if (StackAdjustment) {
2540 // Merge with any previous or following adjustment instruction.
2541 StackAdjustment += mergeSPUpdates(MBB, I, true);
2542 StackAdjustment += mergeSPUpdates(MBB, I, false);
2543
2544 if (!StackAdjustment) {
2545 // This and the merged instruction canceled out each other.
2546 return I;
2547 }
2548
2549 if (!(Fn->optForMinSize() &&
2550 adjustStackWithPops(MBB, I, DL, StackAdjustment)))
2551 BuildStackAdjustment(MBB, I, DL, StackAdjustment, /*InEpilogue=*/false);
2536 if (Amount) {
2537 // Add Amount to SP to destroy a frame, and subtract to setup.
2538 int Offset = isDestroy ? Amount : -Amount;
2539
2540 if (!(Fn->optForMinSize() &&
2541 adjustStackWithPops(MBB, I, DL, Offset)))
2542 BuildStackAdjustment(MBB, I, DL, Offset, /*InEpilogue=*/false);
25522543 }
25532544
25542545 if (DwarfCFI && !hasFP(MF)) {
25582549 // CFI only for EH purposes or for debugging. EH only requires the CFA
25592550 // offset to be correct at each call site, while for debugging we want
25602551 // it to be more precise.
2561
2552 int CFAOffset = Amount;
25622553 // TODO: When not using precise CFA, we also need to adjust for the
25632554 // InternalAmt here.
2564 if (StackAdjustment) {
2565 BuildCFI(MBB, I, DL, MCCFIInstruction::createAdjustCfaOffset(
2566 nullptr, -StackAdjustment));
2555
2556 if (CFAOffset) {
2557 CFAOffset = isDestroy ? -CFAOffset : CFAOffset;
2558 BuildCFI(MBB, I, DL,
2559 MCCFIInstruction::createAdjustCfaOffset(nullptr, CFAOffset));
25672560 }
25682561 }
25692562
0 ; REQUIRES: asserts
11 ; RUN: llc < %s -mtriple=i686-unknown-linux -relocation-model=static -stats 2>&1 | \
2 ; RUN: grep asm-printer | grep 14
2 ; RUN: grep asm-printer | grep 15
33 ;
44 ; It's possible to schedule this in 14 instructions by avoiding
55 ; callee-save registers, but the scheduler isn't currently that
1313 ; SLM: movl (%esp), [[RELOAD:%e..]]
1414 ; SLM-NEXT: pushl [[RELOAD]]
1515 ; CHECK: calll
16 ; CHECK-NEXT: addl $8, %esp
16 ; CHECK-NEXT: addl $4, %esp
1717 %c = add i32 %a, %b
1818 call void @foo(i32 %c)
1919 call void asm sideeffect "nop", "~{ax},~{bx},~{cx},~{dx},~{bp},~{si},~{di}"()
3131 ; CHECK: movl %{{...}}, %esp
3232 ; CHECK-NOT: {{[^ ,]*}}, %esp
3333 ;
34 ; Next we set up the memset call.
34 ; Next we set up the memset call, and then undo it.
3535 ; CHECK: subl $20, %esp
3636 ; CHECK-NOT: {{[^ ,]*}}, %esp
37 ; CHECK: pushl
38 ; CHECK: pushl
39 ; CHECK: pushl
4037 ; CHECK: calll memset
41 ;
42 ; Deallocating 32 bytes of outgoing call frame for memset and
43 ; allocating 28 bytes for calling f yields a 4-byte adjustment:
44 ; CHECK-NEXT: addl $4, %esp
38 ; CHECK-NEXT: addl $32, %esp
4539 ; CHECK-NOT: {{[^ ,]*}}, %esp
4640 ;
47 ; And move on to call 'f', and then restore the stack.
48 ; CHECK: pushl
41 ; Next we set up the call to 'f'.
42 ; CHECK: subl $28, %esp
4943 ; CHECK-NOT: {{[^ ,]*}}, %esp
5044 ; CHECK: calll f
5145 ; CHECK-NEXT: addl $32, %esp
136136 ; X86: movl $13, (%esp)
137137 ; X86: pushl $0
138138 ; X86: calll _print_framealloc_from_fp
139 ; X86: addl $12, %esp
139 ; X86: addl $4, %esp
140 ; X86: addl $8, %esp
140141 ; X86: retl
44
55 define fastcc void @t1() nounwind {
66 ; CHECK-LABEL: t1:
7 ; CHECK: subl $16, %esp
7 ; CHECK: subl $12, %esp
88 ; CHECK: pushl $188
99 ; CHECK-NEXT: pushl $0
1010 ; CHECK-NEXT: pushl $0
11 ; RUN: llc < %s -mtriple=i686-windows -no-x86-call-frame-opt | FileCheck %s -check-prefix=NOPUSH
22 ; RUN: llc < %s -mtriple=x86_64-windows | FileCheck %s -check-prefix=X64
33 ; RUN: llc < %s -mtriple=i686-windows -stackrealign -stack-alignment=32 | FileCheck %s -check-prefix=ALIGNED
4 ; RUN: llc < %s -mtriple=i686-pc-linux | FileCheck %s -check-prefix=LINUX
54
65 %class.Class = type { i32 }
76 %struct.s = type { i64 }
223222 ; NORMAL-NEXT: pushl $2
224223 ; NORMAL-NEXT: pushl $1
225224 ; NORMAL-NEXT: call
226 ; NORMAL-NEXT: subl $4, %esp
225 ; NORMAL-NEXT: addl $16, %esp
226 ; NORMAL-NEXT: subl $20, %esp
227227 ; NORMAL-NEXT: movl 20(%esp), [[E1:%e..]]
228228 ; NORMAL-NEXT: movl 24(%esp), [[E2:%e..]]
229229 ; NORMAL-NEXT: movl [[E2]], 4(%esp)
260260 ; NORMAL-NEXT: pushl $2
261261 ; NORMAL-NEXT: pushl $1
262262 ; NORMAL-NEXT: calll *16(%esp)
263 ; NORMAL-NEXT: addl $24, %esp
263 ; NORMAL-NEXT: addl $16, %esp
264264 define void @test10() optsize {
265265 %stack_fptr = alloca void (i32, i32, i32, i32)*
266266 store void (i32, i32, i32, i32)* @good, void (i32, i32, i32, i32)** %stack_fptr
313313 ; NORMAL-NEXT: pushl $2
314314 ; NORMAL-NEXT: pushl $1
315315 ; NORMAL-NEXT: calll _good
316 ; NORMAL-NEXT: subl $4, %esp
316 ; NORMAL-NEXT: addl $16, %esp
317 ; NORMAL-NEXT: subl $20, %esp
317318 ; NORMAL: movl $8, 16(%esp)
318319 ; NORMAL-NEXT: movl $7, 12(%esp)
319320 ; NORMAL-NEXT: movl $6, 8(%esp)
356357 call void @good(i32 %val1, i32 %val2, i32 %val3, i32 %add)
357358 ret i32* %ptr3
358359 }
359
360 ; Make sure to fold adjacent stack adjustments.
361 ; LINUX-LABEL: pr27140:
362 ; LINUX: subl $12, %esp
363 ; LINUX: .cfi_def_cfa_offset 16
364 ; LINUX-NOT: sub
365 ; LINUX: pushl $4
366 ; LINUX: .cfi_adjust_cfa_offset 4
367 ; LINUX: pushl $3
368 ; LINUX: .cfi_adjust_cfa_offset 4
369 ; LINUX: pushl $2
370 ; LINUX: .cfi_adjust_cfa_offset 4
371 ; LINUX: pushl $1
372 ; LINUX: .cfi_adjust_cfa_offset 4
373 ; LINUX: calll good
374 ; LINUX: addl $28, %esp
375 ; LINUX: .cfi_adjust_cfa_offset -28
376 ; LINUX-NOT: add
377 ; LINUX: retl
378 define void @pr27140() optsize {
379 entry:
380 tail call void @good(i32 1, i32 2, i32 3, i32 4)
381 ret void
382 }
2222 ; CHECK: .cfi_adjust_cfa_offset 4
2323 ; CHECK: calll stdfoo
2424 ; CHECK: .cfi_adjust_cfa_offset -8
25 ; CHECK: addl $20, %esp
26 ; CHECK: .cfi_adjust_cfa_offset -20
25 ; CHECK: addl $8, %esp
26 ; CHECK: .cfi_adjust_cfa_offset -8
2727 define void @test1() #0 !dbg !4 {
2828 entry:
2929 tail call void @foo(i32 1, i32 2) #1, !dbg !10
8181 ; LINUX-NEXT: Ltmp{{[0-9]+}}:
8282 ; LINUX-NEXT: .cfi_adjust_cfa_offset 4
8383 ; LINUX-NEXT: call
84 ; LINUX-NEXT: addl $28, %esp
85 ; LINUX: .cfi_adjust_cfa_offset -28
84 ; LINUX-NEXT: addl $16, %esp
85 ; LINUX: .cfi_adjust_cfa_offset -16
8686 ; DARWIN-NOT: .cfi_escape
8787 ; DARWIN-NOT: pushl
8888 define void @test2_nofp() #0 personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {