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

Alex MacLean via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 9 20:32:11 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");
----------------
AlexMaclean wrote:

Yea, I completely agree, I think almost all the other nvvm.annotations can be converted as well. For this MR I want to lay down the framework for a couple and once that is setup it should be fairly trivial to convert all the others.

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

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


More information about the llvm-commits mailing list