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

Reid Kleckner via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 14 11:41:01 PDT 2021


rnk added a comment.

Please add a test.

I know you said that copyAttributesFrom crashes, but there are many other attributes to consider:
https://github.com/llvm/llvm-project/blob/main/llvm/lib/IR/Globals.cpp#L65

  void GlobalValue::copyAttributesFrom(const GlobalValue *Src) {
    setVisibility(Src->getVisibility());
    setUnnamedAddr(Src->getUnnamedAddr());
    setThreadLocalMode(Src->getThreadLocalMode());
    setDLLStorageClass(Src->getDLLStorageClass());
    setDSOLocal(Src->isDSOLocal());
    setPartition(Src->getPartition());
  }
  ...
  void GlobalObject::copyAttributesFrom(const GlobalObject *Src) {
    GlobalValue::copyAttributesFrom(Src);
    setAlignment(MaybeAlign(Src->getAlignment()));
    setSection(Src->getSection());
  }

Some of these, like DSO local or the alignment, might be worth copying. I think I would prefer to figure out which of these attributes is causing the crash, to clear that attribute from `F` (we are about to erase `F`), and then to copy the rest of the attributes. I suspect there is some assertion about function attributes that cannot be applied to a declaration, or that the function has argument attributes for parameters that are not part of the void prototype. If it ends up being the `AttributeList` that causes the crash, you can clear them all or copy them more selectively.


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