[llvm] [VPlan] Manage noalias/alias_scope metadata in VPlan. (NFC) (PR #136450)

via llvm-commits llvm-commits at lists.llvm.org
Fri May 2 13:09:54 PDT 2025


================
@@ -9011,6 +8995,20 @@ bool VPRecipeBuilder::getScaledReductions(
   return false;
 }
 
+SmallVector<std::pair<unsigned, MDNode *>>
+VPRecipeBuilder::getMetadataToPropagate(Instruction *I) const {
+  SmallVector<std::pair<unsigned, MDNode *>> Metadata;
+  ::getMetadataToPropagate(I, Metadata);
+  if (LVer && isa<LoadInst, StoreInst>(I)) {
+    const auto &[AliasScopeMD, NoAliasMD] = LVer->getNoAliasMetadataFor(I);
+    if (AliasScopeMD)
+      Metadata.emplace_back(LLVMContext::MD_alias_scope, AliasScopeMD);
+    if (NoAliasMD)
+      Metadata.emplace_back(LLVMContext::MD_noalias, NoAliasMD);
+  }
+  return Metadata;
+}
+
----------------
ayalz wrote:

Agree that it's better to avoid passing `LVer` to recipe constructors. Perhaps also better to avoid passing them Metadata lists as well - and employ VPIRMetadata to pass/clone metadata between recipes instead? I.e., have getRecipeMetadata() return a VPIRMetadata which it constructs using an Instruction and LVer (and appropriate VPIRMetadata constructor). Then pass that to recipe constructors, who effectively clone it. Thereby hopefully avoiding a public getMetadata(). Sounds reasonable?

https://github.com/llvm/llvm-project/pull/136450


More information about the llvm-commits mailing list