Ignore load/store until stack address computation
authorMatthias Braun <matze@braunis.de>
Mon, 5 Jun 2023 22:15:01 +0000 (15:15 -0700)
committerMatthias Braun <matze@braunis.de>
Mon, 26 Jun 2023 20:50:36 +0000 (13:50 -0700)
commit02ba5b8c6b9f0c1ce6df421db5dd5eb307d7d27d
tree752ea7db9ee879f79ddd878cc7bbe6a5dff0750b
parent759b21762634b906ff545353deae47dfbfc45c0b
Ignore load/store until stack address computation

No longer conservatively assume a load/store accesses the stack when we
can prove that we did not compute any stack-relative address up to this
point in the program.

We do this in a cheap not-quite-a-dataflow-analysis: Assume
`NoStackAddressUsed` when all predecessors of a block already guarantee
it. Process blocks in reverse post order to guarantee that except for
loop headers we have processed all predecessors of a block before
processing the block itself. For loops we accept the conservative answer
as they are unlikely to be shrink-wrappable anyway.

Differential Revision: https://reviews.llvm.org/D152213
27 files changed:
llvm/lib/CodeGen/ShrinkWrap.cpp
llvm/test/CodeGen/AArch64/branch-relax-cbz.ll
llvm/test/CodeGen/AArch64/optimize-cond-branch.ll
llvm/test/CodeGen/ARM/arm-shrink-wrapping.ll
llvm/test/CodeGen/ARM/machine-cse-cmp.ll
llvm/test/CodeGen/ARM/machine-sink-multidef.ll
llvm/test/CodeGen/ARM/swifterror.ll
llvm/test/CodeGen/PowerPC/BreakableToken-reduced.ll
llvm/test/CodeGen/PowerPC/aix-lower-jump-table.ll
llvm/test/CodeGen/PowerPC/licm-tocReg.ll
llvm/test/CodeGen/PowerPC/p10-spill-creq.ll
llvm/test/CodeGen/PowerPC/sms-cpy-1.ll
llvm/test/CodeGen/RISCV/half-round-conv-sat.ll
llvm/test/CodeGen/RISCV/half-round-conv.ll
llvm/test/CodeGen/RISCV/rvv/fixed-vectors-masked-gather.ll
llvm/test/CodeGen/Thumb2/LowOverheadLoops/fast-fp-loops.ll
llvm/test/CodeGen/X86/MachineSink-eflags.ll
llvm/test/CodeGen/X86/callbr-asm-label-addr.ll
llvm/test/CodeGen/X86/dag-update-nodetomatch.ll
llvm/test/CodeGen/X86/fold-pcmpeqd-2.ll
llvm/test/CodeGen/X86/fp128-select.ll
llvm/test/CodeGen/X86/i386-shrink-wrapping.ll
llvm/test/CodeGen/X86/inline-asm-flag-output.ll
llvm/test/CodeGen/X86/pr56103.ll
llvm/test/CodeGen/X86/test-shrink-bug.ll
llvm/test/CodeGen/X86/xchg-nofold.ll
llvm/test/Transforms/CodeGenPrepare/AArch64/large-offset-gep.ll