[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
Sat May 21 17:28:44 PDT 2022


dblaikie added a comment.

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



================
Comment at: llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp:3052-3054
-        if (Size == 0)
-          Size = 1;
-
----------------
This might actually be a more suitable direction for zero-length entries.

Otherwise: What's a consumer going to do if they query for the address and it's not in aranges? (They then need to scan all the DWARF to find the zero-length entry at that address, losing the benefit of aranges?)

(also: what are you using aranges for? They've been off-by-default in Clang for many years now & I don't know of any particular value they have compared to using the ranges on the CUs in .debug_info directly (well, LLVM's aranges include data/non-code symbols, but GCC's don't, so it's hard for a consumer to rely on that extra data anyway) - I hope one day we can remove the support entirely)


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