This is an archive of the discontinued LLVM Phabricator instance.

[NVPTX][AsmPrinter] Avoid removing globals before calling AsmPrinter::doFinalization()

Authored by krisb on Nov 11 2021, 12:52 AM.



Instead of removing globals from a module, we, it seems, can just override
AsmPrinter::emitGlobalVariable() to do nothing as NVPTXAsmPrinter already
emitted globals by this time and we don't want to do it twice.

This patch doesn't affect any existing regression tests,
so I'd want to consider it at least as NFCI.

Diff Detail

Event Timeline

krisb created this revision.Nov 11 2021, 12:52 AM
krisb requested review of this revision.Nov 11 2021, 12:52 AM
Herald added a project: Restricted Project. · View Herald TranscriptNov 11 2021, 12:52 AM
asavonic added inline comments.Nov 11 2021, 2:37 AM

Can we keep the original comment to explain the problem? Something like:

Do not allow base AsmPrinter doing something with globals: global variables are emitted at the beginning and base AsmPrinter will attempt to do that again in doFinalization().
tra added a comment.Nov 11 2021, 10:19 AM

LGTM in general.


+1. We do need a good explanation why we're doing something as odd as not emitting globals.

krisb updated this revision to Diff 386751.Nov 12 2021, 12:16 AM

Make the comment for emitGlobalVariable() more detailed.

tra accepted this revision.Nov 24 2021, 5:30 PM
This revision is now accepted and ready to land.Nov 24 2021, 5:30 PM