[PATCH] D101512: [CodeGen] don't emit addrsig symbol if it's used only by metadata
Reid Kleckner via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 29 12:12:48 PDT 2021
rnk added inline comments.
================
Comment at: llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp:1854
+ for (auto U = GV.user_begin(), E = GV.user_end(); U != E; ++U)
+ if (U->isUsedByMetadata())
+ ++MetadataCount;
----------------
I see, so, the GV is used by a constant, which is then used by metadata. Metadata uses do not appear in the use list.
I think this condition is slightly incorrect, though, the bitcast constant expression could be used by metadata *and* a real Value. So, consider your test case, but then add in a real instruction that uses the same bitcast. In this case, we should still put GV into the addrsig table.
One refinement would be to check that each user is a Constant with no uses, instead of checking if it is used by metadata. This could be:
if (isa<Constant>(U) && U->use_empty())
However, this will not handle nested constant expressions. Consider a series of `getelementptr` and `bitcast` constant expressions. To be fully general, you need a worklist to check that all transitive users of GV are non-GlobalValue Constants that are only used by other constants.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D101512/new/
https://reviews.llvm.org/D101512
More information about the llvm-commits
mailing list