Ensure metadata for declarations copied during materialization
is properly mapped if declarations do not become definitions.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Is this a case where we didn't in the past have metadata attachments on declarations requiring mapping, and now we do? Also, the example uses a "!types" metadata - I'm familiar with !type metadata on definitions, but haven't seen !types before - is this new metadata? I can't find any uses of it in the test suite or any documentation.
llvm/lib/Linker/IRMover.cpp | ||
---|---|---|
1144 | GlobalVariable are also GlobalObjects, should they get the same treatment in linkGlobalVariable? But is this removal needed at all, since the loop over UnmappedMetadata later on ignores definitions? |
Thanks for the context. lgtm with a comment suggestion.
llvm/lib/Linker/IRMover.cpp | ||
---|---|---|
412 | Add doxygen comment. |
Sorry, context should be fixed now.
The only change over the accepted revision is IRMover.cpp:1066.
llvm/lib/Linker/IRMover.cpp | ||
---|---|---|
1066 | Looking at remangleIntrinsicFunction, it doesn't appear to copy any metadata from F. I'm not sure if this is because intrinsic function declarations can never have metadata, or it just hasn't been needed thus far. I think it would be safer to add NewGV to the UnmappedMetadata set (if F was in it) in case the latter is true, meaning there is no guarantee we couldn't have any that needs to be mapped in the future. Also, it would be good to expand your test case to test this case (i.e. I assume we end up with a crash if an intrinsic that was renamed had ended up in the UnmappedMetadata set without this change?). Actually, in thinking through the case that presumably had an issue without this change (which I'm assuming was an intrinsic that was added to the UnmappedMetadata that did not in fact have any metadata, since I don't see remangleIntrinsicFunction copying any metadata), I'm wondering if we can reduce the amount of unnecessary stuff initially added to UnmappedMetadata, but guarding it with a check of NewGO->hasMetadata() ? |
llvm/lib/Linker/IRMover.cpp | ||
---|---|---|
1066 |
And if you do that, it should avoid the need to remove F from the UnmappedMetadata set here (under the assumption that we don't currently have intrinsic functions with any metadata at this point). So you can simply replace this line with an assert that F is not in UnmappedMetadata, with a comment noting that remangleIntrinsicFunction does not copy any metadata over, so we assume that F could not have metadata to start with. If the assert is ever hit, then not only does this code need to change but remangleIntrinsicFunction needs to be updated as well. |
- Exclude global objects without metadata from unmapped set
- Add assertion to cover the case of intrinsics with metadata
llvm/lib/Linker/IRMover.cpp | ||
---|---|---|
1066 | This seems like a good solution to me. |
Add doxygen comment.