[llvm] [VPlan] Manage instruction medata in VPlan. (PR #135272)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 18 03:11:09 PDT 2025
================
@@ -1190,28 +1190,55 @@ struct VPIRPhi : public VPIRInstruction {
#endif
};
+using MDArrayRef = ArrayRef<std::pair<unsigned, MDNode *>>;
+
+/// Helper to manage IR metadata for recipes. It filters out metadata that
+/// cannot be proagated.
+class VPWithIRMetadata {
+ SmallVector<std::pair<unsigned, MDNode *>> Metadata;
+
+protected:
+ VPWithIRMetadata() {}
+ VPWithIRMetadata(MDArrayRef Metadata) : Metadata(Metadata) {}
+
+ void addMetadata(MDArrayRef Metadata) {
+ append_range(this->Metadata, Metadata);
+ }
+
+public:
+ /// Add all metadata to \p V if it is an instruction.
+ void setMetadata(Value *V) const;
+
+ void addMetadata(unsigned Kind, MDNode *N) { Metadata.emplace_back(Kind, N); }
+
+ MDArrayRef getMetadata() const { return Metadata; }
----------------
ayalz wrote:
Comment that this serves recipe cloning?
Would `transferMetadata()` be useful for cloning instead, consistent with `transferFlags()`?
Note that in contrast Instruction::getMetadata() returns a single MDNote per given kind (which is more accurately getMetadatum()...).
https://github.com/llvm/llvm-project/pull/135272
More information about the llvm-commits
mailing list