[PATCH] D100498: [ThinLTO] Copy UnnamedAddr when spliting module.

Reid Kleckner via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 19 11:35:09 PDT 2021


rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

Looks good with a minor simplification



================
Comment at: llvm/lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp:163
+    NewF->copyAttributesFrom(&F);
+    auto Attrs = F.getAttributes();
+    for (unsigned i = 0; i < F.arg_size(); ++i) {
----------------
Instead of iterating over return and parameter attributes, I suggest you build a new AttributeList that consists of nothing but function attributes. This code might work, but I haven't actually compiled it:
  NewF->setAttributes(AttributeList::get(M.getContext(), {AttributeList::FunctionIndex, F.getAttributes().getFnAttributes()}));

This has a nice side effect of not leaking lots of temporary AttributeList objects.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100498



More information about the llvm-commits mailing list