llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
29.12k stars 12.01k forks source link

[IPRA][X86] push/pop rbp is unexpectedly optimized out in the function. #109739

Open FreddyLeaf opened 1 month ago

FreddyLeaf commented 1 month ago

When enabling IPRA on X86 on spec-2017/503_bwaves, a segfault happened immediately. I tried to lower the issue. It turns out IPRA is not working correctly on below example: https://gcc.godbolt.org/z/6hh88xv9r. Normally, when a certain callee saved register in caller is not live across the the call, callee's push/pop CSR can be optimized out when IPRA is on. (e.g. if I changed the callee to clobber another callee saved register r12, its push/pop can be optimized out: https://gcc.godbolt.org/z/9nbTMe856) While the issue here we can tell from generated codes that rbp is live across call foo, but it's neither saved/reload in caller or callee, which is explicitly a correctness issue.

llvmbot commented 1 month ago

@llvm/issue-subscribers-backend-x86

Author: Freddy Ye (FreddyLeaf)

When enabling IPRA on X86 on spec-2017/503_bwaves, a segfault happened immediately. I tried to lower the issue. It turns out IPRA is not working correctly on below example: https://gcc.godbolt.org/z/6hh88xv9r. Normally, when a certain callee saved register in caller is not live across the the call, callee's `push/pop CSR` can be optimized out when IPRA is on. (e.g. if I changed the callee to clobber another callee saved register r12, its push/pop can be optimized out: https://gcc.godbolt.org/z/9nbTMe856) While the issue here we can tell from generated codes that rbp is live across `call foo`, but it's neither saved/reload in caller or callee, which is explicitly a correctness issue.