[PATCH] D126010: Make sure the AsmPrinter doesn't emit any zero-sized symbols to `.debug_aranges`.

David Blaikie via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon May 23 17:34:27 PDT 2022


dblaikie added a comment.

In D126010#3529743 <https://reviews.llvm.org/D126010#3529743>, @dblaikie wrote:

> In D126010#3528129 <https://reviews.llvm.org/D126010#3528129>, @rnk wrote:
>
>> I agree with David, I would like to see LLVM move in the direction of never emitting empty functions. These are just labels that snap to the next function in the same section, and that's silly. I'm not sure what happens if you use function sections. We should just emit some trap instruction, and let the linker do identical code folding (ICF) to merge them back together. This will regress code size, but I doubt out users will complain, and ICF will recover most of the size regression.
>>
>> Regarding global symbols, I don't know about Rust, but I believe it is possible to emit empty global variables in LLVM IR with zero-sized arrays. So, I think this change probably has merit on its own, without getting into the handling of empty function bodies.
>
> LLVM IR/C++ does support zero-sized arrays, though I think even in that case it might be better to make them non-zero symbols for symbolizing purposes, etc - GCC seems to make them non-zero size: https://godbolt.org/z/vh4z3G4fh

I'm still inclined towards GCC's direction here - making everything non-zero length. It means querying for an address makes sense, for instance. Otherwise what does it mean to search the DWARF for an address? If there is nothing /at/ that address (or the next thing is technically at that address, because the thing you're looking for is zero length) - like if you want to print out the symbol name of a zero-length symbol, the search should technically come back empty, because there's nothing at the address.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D126010/new/

https://reviews.llvm.org/D126010



More information about the llvm-commits mailing list