[PATCH] D126257: Round up zero-sized symbols to 1 byte in `.debug_aranges`.

David Blaikie via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed May 25 13:12:32 PDT 2022


dblaikie added a comment.

In D126257#3538331 <https://reviews.llvm.org/D126257#3538331>, @pcwalton wrote:

> Oh, what I mean is that our choices in the case in which zero-sized global symbols are forbidden at the IR level would be (1) don't emit source-level zero-sized symbols into LLVM IR (or don't emit DWARF metadata for them), or (2) round all zero-sized symbols up to one byte. If we pick (1), I don't think they would show up in the debug info, which could be confusing for programmers. If we pick (2), then certain abstractions which are zero-cost today in Rust become non-zero-cost.

Ah, sorry, yes, I wasn't suggesting (1) - I was suggesting (2). like GCC appears to do: https://godbolt.org/z/E89eo15qd

> Mind you, I don't know of any applications specifically for which adding one extra byte per zero-sized symbol would be a problem. But I'm worried that someone might be, for example, writing a macro which creates thousands of zero-sized globals, as part of some trick along the lines of traits types in C++, and then the runtime space cost of rounding all globals up to size 1 could become noticeable.

Yeah - OK, I can see the hypothetical argument. All the more reason, from my perspective, to avoid enabling these to be truly zero-size now only to realize we need to change this later.

The ability to talk about unique addresses for each entity seems important to me (important for C++ at the language level, I think - though admittedly zero-size entities are an extension, so C++ doesn't really say what it means to take their address, compare that address, etc) - but also for DWARF consumers to search for things. If they're really zero length, then searching for the address sort of /should/ result in no result (because the address you're searching for is not part of the object, even though it is the address of the object - because the object takes up no space) - or should/must result in all the zero-length objects at the address plus whatever object follows it - making any kind of identification (eg: debuggers print out what global a pointer points to - but now it points to more than one thing...) complicated/ambiguous/confusing for the consumer and the users.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126257



More information about the llvm-commits mailing list