[PATCH] D121428: [lld-macho] Extend lto-internalize-unnamed-addr.ll

Teresa Johnson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 15 14:07:55 PDT 2022


tejohnson added inline comments.


================
Comment at: lld/test/MachO/lto-internalize-unnamed-addr.ll:47
+; THINLTO-BC-DAG: @local_unnamed_sometimes_const = weak_odr local_unnamed_addr constant i8 42
+; THINLTO-BC-DAG: @local_unnamed = weak_odr local_unnamed_addr global i8 42
+
----------------
int3 wrote:
> tejohnson wrote:
> > int3 wrote:
> > > modimo wrote:
> > > > I find it odd that `local_unnamed` is able to be internalized in fullLTO but not thinLTO. The code path is https://github.com/llvm/llvm-project/blob/9f616a467fc710f084b7e57812a2ed64c214c2c6/llvm/lib/LTO/LTO.cpp#L349 where any linkonce_odr gets upgraded to weak but if this is the only copy that exists it appears to fit within the rules coming from D20348. cc @tejohnson is there an opportunity here?
> > > I realize `global_unnamed_sometimes_linkonce` has the same issue too. I've added a FIXME for this
> > That's true, if there is only one copy no need to make the prevailing one weak_odr. Is changing that sufficient to get the internalization in the ThinLTO case?
> I tried https://gist.github.com/int3/b66de20462da71e8757e09bacfc361ca but that just seems to result in `global_unnamed` and `local_unnamed_const` no longer being marked as `hidden`...
To get hidden back this would need to be adjusted accordingly to handle linkonce_odr:
http://llvm-cs.pcc.me.uk/lib/Transforms/IPO/FunctionImport.cpp#980


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D121428/new/

https://reviews.llvm.org/D121428



More information about the llvm-commits mailing list