[clang] [llvm] [NVPTX] Add NVVMUpgradeAnnotations pass to cleanup legacy annotations (PR #119261)

Artem Belevich via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 10 10:43:21 PST 2024


================
@@ -302,6 +299,19 @@ void NVPTXTargetCodeGenInfo::addNVVMMetadata(
       llvm::ConstantAsMetadata::get(GV), llvm::MDString::get(Ctx, Name),
       llvm::ConstantAsMetadata::get(
           llvm::ConstantInt::get(llvm::Type::getInt32Ty(Ctx), Operand))};
+  // Append metadata to nvvm.annotations
+  MD->addOperand(llvm::MDNode::get(Ctx, MDVals));
+}
+
+void NVPTXTargetCodeGenInfo::addNVVMGridConstantMetadata(
+    llvm::GlobalValue *GV, const SmallVectorImpl<int> &GridConstantArgs) {
+  llvm::Module *M = GV->getParent();
+  llvm::LLVMContext &Ctx = M->getContext();
+
+  // Get "nvvm.annotations" metadata node
+  llvm::NamedMDNode *MD = M->getOrInsertNamedMetadata("nvvm.annotations");
----------------
Artem-B wrote:

> For this MR I want to lay down the framework

SGTM. We don't have to it all at once.

> Specifically for grid_constant can we just upgrade to the existing readonly parameter attribute?

That would be even better. No custom attributes *and* we can take advantage of local copy avoidance without explicit user annotations. Sounds like a win-win to me. I can't think of a reason not to do that.

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


More information about the llvm-commits mailing list