This is an archive of the discontinued LLVM Phabricator instance.

DebugInfo: Emit any enum with a referenced enum constant.
AbandonedPublic

Authored by dblaikie on May 6 2014, 10:22 PM.

Details

Reviewers
aprantl
Summary

This is incomplete/too verbose. Even if the enum constant is used in a
header (to declare the size of an array member of a type that's never
used, or in an inline function never called).

This could be fixed by keeping a chain of references "this enum is
referenced from this type which is referenced from this type, used in
this inline function, etc..." which is a substantial undertaking, though
it would help power several other debug info correctness/optimizations.
(eg: struct foo { ... }; .... void *f; ((foo*)f)->x currently doesn't
emit the definition of 'foo', but we could keep track of the fact that
foo was referenced from that expression, etc)

Diff Detail

Event Timeline

dblaikie updated this revision to Diff 9146.May 6 2014, 10:22 PM
dblaikie retitled this revision from to DebugInfo: Emit any enum with a referenced enum constant..
dblaikie updated this object.
dblaikie edited the test plan for this revision. (Show Details)
dblaikie added reviewers: rsmith, echristo, aprantl.
dblaikie added a subscriber: Unknown Object (MLST).May 6 2014, 10:24 PM

Just wrapping my head around Arcanist - bumping this to the mailing list.

(apologies to 'reviewers' for popping this into your inbox instead of your mailing list filters... )

This is just a throwaway patch - something I've written up, but I think it'll be too much work to implement well now.

(oh, and imported entities have the same problem as enums... it'd be nice to have their use tracked precisely too so we could reduce some debug info size)

I haven't done the size analysis to see just how bad this is, perhaps it's acceptable as-is, even without the use tracking, but I rather doubt it.

rsmith edited edge metadata.May 20 2014, 7:41 PM

Implementation LGTM, if you decide that you want to go in this direction.

echristo resigned from this revision.Mar 2 2016, 3:05 PM
echristo removed a reviewer: echristo.
rsmith removed a reviewer: rsmith.Mar 18 2016, 10:50 AM
dblaikie abandoned this revision.Apr 4 2016, 11:43 AM
dblaikie added a subscriber: rsmith.
In D3635#44720, @rsmith wrote:

Implementation LGTM, if you decide that you want to go in this direction.

Just looking over some old patches/git branches I had lying around.

It seems what I might need to make this closer to GCC's size/fidelity tradeoff, is the ability to detect if the use of the enumerator was an ODR use. So that this:

enum X { Y };
int i = Y;

was a use, but this:

int i[Y];

was not.

Is that reasnable? Can I practically detect that property in MarkAnyDeclReferenced?

(is "int i = Y;" an ODR use? Perhaps I'm getting the terminology wrong... maybe there is no nice linguistic property that distinguishes these two cases?)

& just for the record, the patch as it stands grows the .dwo size for the dwos build for the clang binary by a little over 18% :/

& using the MightBeOdrUse flag to MarkAnyDeclReferenced didn't seem to change the array case behavior above - I didn't get aggregate numbers to see if it had any impact.