We have modules with metadata on declarations, and out-of-tree passes
use that metadata, and we need to clone those modules. We really expect
such metadata is kept during the clone operation.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
llvm/unittests/Transforms/Utils/CloningTest.cpp | ||
---|---|---|
843 ↗ | (On Diff #312448) | Nit: LLVM coding style wants full sentences in comments. |
846 ↗ | (On Diff #312448) | It's not obvious to me what the intended difference between GVD and GV is — is it just the Comdat flag? Could we document that? |
Now that most features of CloneModule() are tested by the unit-test. Is there any specific reason to prefer lit-test over unit-test?
seems that copying the metadata causing the Cloned module still reference some metadata in source modules. and simplifyExternals(*MergedM); in ThinLTOBitcodeWriter.cpp modifies the metadata in the source module M. which is out-of my expectation. I am not familiar with that part of code, so still need some time to continue investigate. I am not sure @pcc Do you have any idea on this?
Actually it is changing a metadata in module M from:
!32 = !DITemplateValueParameter(type: !33, value: { i64, i64 } { i64 ptrtoint (i32 (%class.i*)* @_ZNK1i5m_fn1Ev to i64), i64 0 })
into
!32 = !DITemplateValueParameter(type: !33, value: { i64, i64 } { i64 ptrtoint (void ()* @_ZNK1i5m_fn1Ev to i64), i64 0 })
I dumped the modules before and after my change, this is the only diff of Module M before writing out.