Lizunov, Andrey E
2015-May-21 07:18 UTC
[LLVMdev] [LLVM 3.6.0] Metadata/Value split and RAUW.
Hello everyone, If I understand correctly after the Metadata/Value split the Metadata support of RAUW is limited by ValueAsMetadata and MDNodeFwdDecl (i.e. until cycled in MDNode are not resovled). And my question is. Is where any way to replace an MDNode which is referenced by other MDNodes w\o iterating over all MDNodes in LLMVContext to find and replace those references? Unfortunately I couldn't find such example in LLVM source code... BR, Andrey Lizunov -------------------------------------------------------------------- Closed Joint Stock Company Intel A/O Registered legal address: Krylatsky Hills Business Park, 17 Krylatskaya Str., Bldg 4, Moscow 121614, Russian Federation This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150521/0f655333/attachment.html>
Duncan P. N. Exon Smith
2015-Jun-02 21:17 UTC
[LLVMdev] [LLVM 3.6.0] Metadata/Value split and RAUW.
> On 2015-May-21, at 00:18, Lizunov, Andrey E <andrey.e.lizunov at intel.com> wrote: > > Hello everyone, > > > If I understand correctly after the Metadata/Value split the Metadata support of RAUW is limited by ValueAsMetadata and MDNodeFwdDecl (i.e. until cycled in MDNode are not resovled). > > And my question is. Is where any way to replace an MDNode which is referenced by other MDNodes w\o iterating over all MDNodes in LLMVContext to find and replace those references? Unfortunately I couldn’t find such example in LLVM source code…There are three ways I can think of. 1. During graph construction, create a temporary MDNode instead of a normal one. In 3.6, that's a `MDNodeFwdDecl`; in trunk, that's just a temporary. Before the end of graph construction, you need to RAUW it with the final node (in trunk, there's a function called MDNode::replaceWithPermanent()) that probably does what you need). This is the approach the debug info schema uses. 2. Change the schema to add a layer of indirection in the spots where you need to change the pointee. In particular, instead of !0 = !{!"interesting data"} !2 = !{!"points at !0", !0} use: !0 = !{!"interesting data"} !1 = !{!0} !2 = !{!"points at !0", !1} If everyone reference !0 does so indirectly, via !1, then you can call `!1->replaceOperandWith(0, NewNode)` to change the effective pointee. 3. Use the `ValueMapper` infrastructure to remap the metadata in the module to point at the new node instead of the old one (this is spiritually similar to your suggested approach).
Lizunov, Andrey E
2015-Jul-02 12:09 UTC
[LLVMdev] [LLVM 3.6.0] Metadata/Value split and RAUW.
Duncan, thank you for your answer! These are interesting alternatives. Unfortunately only the third one is suitable to me since it needs to alternate the graph after the construction and its topology is fixed. IMHO RAUW was a good feature for the metadata from that point of view. BR, Andrey Lizunov -----Original Message----- From: Duncan P. N. Exon Smith [mailto:dexonsmith at apple.com] Sent: Wednesday, June 03, 2015 12:18 AM To: Lizunov, Andrey E Cc: llvmdev at cs.uiuc.edu Subject: Re: [LLVMdev] [LLVM 3.6.0] Metadata/Value split and RAUW.> On 2015-May-21, at 00:18, Lizunov, Andrey E <andrey.e.lizunov at intel.com> wrote: > > Hello everyone, > > > If I understand correctly after the Metadata/Value split the Metadata support of RAUW is limited by ValueAsMetadata and MDNodeFwdDecl (i.e. until cycled in MDNode are not resovled). > > And my question is. Is where any way to replace an MDNode which is referenced by other MDNodes w\o iterating over all MDNodes in LLMVContext to find and replace those references? Unfortunately I couldn’t find such example in LLVM source code…There are three ways I can think of. 1. During graph construction, create a temporary MDNode instead of a normal one. In 3.6, that's a `MDNodeFwdDecl`; in trunk, that's just a temporary. Before the end of graph construction, you need to RAUW it with the final node (in trunk, there's a function called MDNode::replaceWithPermanent()) that probably does what you need). This is the approach the debug info schema uses. 2. Change the schema to add a layer of indirection in the spots where you need to change the pointee. In particular, instead of !0 = !{!"interesting data"} !2 = !{!"points at !0", !0} use: !0 = !{!"interesting data"} !1 = !{!0} !2 = !{!"points at !0", !1} If everyone reference !0 does so indirectly, via !1, then you can call `!1->replaceOperandWith(0, NewNode)` to change the effective pointee. 3. Use the `ValueMapper` infrastructure to remap the metadata in the module to point at the new node instead of the old one (this is spiritually similar to your suggested approach). -------------------------------------------------------------------- Closed Joint Stock Company Intel A/O Registered legal address: Krylatsky Hills Business Park, 17 Krylatskaya Str., Bldg 4, Moscow 121614, Russian Federation This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies.
Reasonably Related Threads
- [LLVMdev] Assertion: replaceAllUses of value with new value of different type! being thrown all of a sudden
- [LLVMdev] [RFC] Separating Metadata from the Value hierarchy
- [LLVMdev] [RFC] Separating Metadata from the Value hierarchy
- [LLVMdev] Crash on invalid during LLVMContext destruction MDNode::dropAllReferences
- Metadata RAUW