This is an archive of the discontinued LLVM Phabricator instance.

Change DwarfCompileUnit::createGlobalVariable to getOrCreateGlobalVariable.
ClosedPublic

Authored by friss on Sep 17 2014, 8:18 AM.

Details

Summary

This will allow to request the creation of a forward delacred variable
at is point of use (for imported declarations, this will be
DwarfDebug::constructImportedEntityDIE) rather than having to put the
forward decl in a retention list.

Note that getOrCreateGlobalVariable returns the actual definition DIE when the
routine creates a declaration and a definition DIE. If you agree this is the
right behavior, then I'll have a followup patch that registers the definition
in the DIE map instead of the declaration as it is today (this 'breaks' only
one test, where we test that the imported entity is the declaration). I'm
not sure what's best here, but it's easy enough for a consumer to follow the
DW_AT_specification link to get to the declaration, whereas it takes more
work to find the actual definition from a declaration DIE.

Diff Detail

Repository
rL LLVM

Event Timeline

friss updated this revision to Diff 13786.Sep 17 2014, 8:18 AM
friss retitled this revision from to Change DwarfCompileUnit::createGlobalVariable to getOrCreateGlobalVariable..
friss added reviewers: echristo, dblaikie, aprantl.
friss updated this object.
friss added a subscriber: Unknown Object (MLST).
dblaikie accepted this revision.Sep 18 2014, 12:00 PM
dblaikie edited edge metadata.

Looks good.

I'm on the fence about whether declaration or definition is better - but as you say, definition is somewhat more expressive/useful for some possible consumer scenarios.

This revision is now accepted and ready to land.Sep 18 2014, 12:00 PM
friss closed this revision.Sep 19 2014, 8:22 AM
friss updated this revision to Diff 13874.

Closed by commit rL218126 (authored by @friss).