[llvm] Reland "[NVPTX] Cleanup/Refactoring in NVPTX AsmPrinter and RegisterInfo (NFC)" (PR #127089)

Artem Belevich via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 13 11:24:05 PST 2025


================
@@ -914,7 +914,7 @@ void NVPTXAsmPrinter::emitLinkageDirective(const GlobalValue *V,
       else
         O << ".visible ";
     } else if (V->hasAppendingLinkage()) {
-      report_fatal_error("Symbol '" + llvm::Twine(V->getNameOrAsOperand()) +
+      report_fatal_error("Symbol '" + (V->hasName() ? V->getName() : "") +
----------------
Artem-B wrote:

IMO, it would make sense to make `getNameOrAsOperand()` available in general, but that's unrelated to your patch.

I think the initial commit that introduced `getNameOrAsOperand` was somewhat misguided to put that function under NDEBUG. IMO debug/nodebug should not change availability of class members. It's OK to change member function implementation, if necessary. E.g how it's done here:
https://github.com/llvm/llvm-project/blob/c2e96778e04197dd266f7c540bf174b6ec28a434/llvm/include/llvm/IR/Value.h#L338-L342
It just adds unnecessary headache without buying us anything.

That said, that `getNameOrAsOperand` is a terrible name. Your code as is makes more sense. Let's keep it.

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


More information about the llvm-commits mailing list