TemporaryMDNode
public class TemporaryMDNode : IRMetadata
Represents a temporary metadata node.
Temporary metadata nodes aid in the construction of cyclic metadata. The typical construction pattern is usually as follows:
// Allocate a temporary temp node
let temp = TemporaryMDNode(in: context, operands: [])
// Prepare the operands to the metadata node...
var ops = [IRMetadata]()
// ...
// Create the real node
let root = MDNode(in: context, operands: ops)
At this point we have the following metadata structure:
// !0 = metadata !{} <- temp
// !1 = metadata !{metadata !0} <- root
// Replace the temp operand with the root node
The knot is tied by RAUW'ing the temporary node:
temp.replaceAllUses(with: root)
// We now have
// !1 = metadata !{metadata !1} <- self-referential root
Warning
It is critical that temporary metadata nodes be “RAUW’d” (replace-all-uses-with) before the metadata graph is finalized. After that time, all remaining temporary metadata nodes will become unresolved metadata.-
Declaration
Swift
required public init(llvm: LLVMMetadataRef)
-
Create a new temporary metadata node in the given context with the given operands.
Declaration
Swift
public init(in context: Context = .global, operands: [IRMetadata])
Parameters
context
The context to allocate the node in.
operands
The operands to attach to the metadata node.
-
Declaration
Swift
public func asMetadata() -> LLVMMetadataRef