[llvm] [CGP] Do not eliminate blocks which have their address taken (PR #163962)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 20 05:47:44 PDT 2025
tetzank wrote:
> And if a block gets eliminated between the start of codegen and isel, we have some code that's supposed to deal with it. See AddrLabelMap::takeDeletedSymbolsForFunction in AsmPrinter.cpp. (see also [db035a0](https://github.com/llvm/llvm-project/commit/db035a0af2ac5dfbefe952a874903b08d9b48152)). This is supposed to handle testcases like #161164. If that code isn't functioning correctly, we should fix it.
Looks like the code in AddrLabelMap in the end just adds a label definition at the beginning of a function, if it was collected previously as a deleted symbol.
https://github.com/llvm/llvm-project/blob/a4dde449a043f3aeba3d14cd32b9b8da1ece8c3e/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp#L1058-L1066
Deleted symbols are collected in AddrLabelMap::UpdateForDeletedBlock.
This sounds like a band aid to not get the undefined symbol error, if we spot the missing location to call UpdateForDeletedBlock. But I have the feeling the code is broken afterwards. We are just placing the symbol somewhere.
It does not fix the lost update (neither does my fix of avoiding block elimination). codegenprepare updates the blockaddress referring to the eliminated block, but it does not work if blockaddress is in a function defined before the current one.
https://github.com/llvm/llvm-project/pull/163962
More information about the llvm-commits
mailing list