[PATCH] D101512: [CodeGen] don't emit addrsig symbol if it's used only by metadata

Zequan Wu via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 29 14:20:55 PDT 2021


zequanwu 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;
----------------
rnk wrote:
> 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.
Yea, I see the problem. 
> `if (isa<Constant>(U) && U->use_empty())`
I understand this, but confused by below.
> check that all transitive users of GV are non-GlobalValue Constants that are only used by other constants.
IIUC, if all transitive users of the GV are non-GlobalValue constants that are not transitively used by any non-GlobalValue constants, the GV is not address significant. For example, in the test case below, `@a1` and `@i1` are not address significant, right?


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