[llvm] [NVPTX] Remove unnecessary casts (NFC) (PR #156275)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Sun Aug 31 20:58:08 PDT 2025
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/156275
getSubtargetImpl() already returns const NVPTXSubtarget *.
>From d8e9ce784a983108b2778ff57795654f294de868 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Sat, 30 Aug 2025 16:04:32 -0700
Subject: [PATCH] [NVPTX] Remove unnecessary casts (NFC)
getSubtargetImpl() already returns const NVPTXSubtarget *.
---
llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp | 13 +++++--------
1 file changed, 5 insertions(+), 8 deletions(-)
diff --git a/llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp b/llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp
index 7391c2d488b57..c456d823da555 100644
--- a/llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp
+++ b/llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp
@@ -432,7 +432,7 @@ void NVPTXAsmPrinter::emitKernelFunctionDirectives(const Function &F,
// .maxclusterrank directive requires SM_90 or higher, make sure that we
// filter it out for lower SM versions, as it causes a hard ptxas crash.
const NVPTXTargetMachine &NTM = static_cast<const NVPTXTargetMachine &>(TM);
- const auto *STI = static_cast<const NVPTXSubtarget *>(NTM.getSubtargetImpl());
+ const auto *STI = NTM.getSubtargetImpl();
if (STI->getSmVersion() >= 90) {
const auto ClusterDim = getClusterDim(F);
@@ -669,7 +669,7 @@ void NVPTXAsmPrinter::emitStartOfAsmFile(Module &M) {
// rest of NVPTX isn't friendly to change subtargets per function and
// so the default TargetMachine will have all of the options.
const NVPTXTargetMachine &NTM = static_cast<const NVPTXTargetMachine &>(TM);
- const auto* STI = static_cast<const NVPTXSubtarget*>(NTM.getSubtargetImpl());
+ const auto *STI = NTM.getSubtargetImpl();
SmallString<128> Str1;
raw_svector_ostream OS1(Str1);
@@ -680,8 +680,7 @@ void NVPTXAsmPrinter::emitStartOfAsmFile(Module &M) {
bool NVPTXAsmPrinter::doInitialization(Module &M) {
const NVPTXTargetMachine &NTM = static_cast<const NVPTXTargetMachine &>(TM);
- const NVPTXSubtarget &STI =
- *static_cast<const NVPTXSubtarget *>(NTM.getSubtargetImpl());
+ const NVPTXSubtarget &STI = *NTM.getSubtargetImpl();
if (M.alias_size() && (STI.getPTXVersion() < 63 || STI.getSmVersion() < 30))
report_fatal_error(".alias requires PTX version >= 6.3 and sm_30");
@@ -716,8 +715,7 @@ void NVPTXAsmPrinter::emitGlobals(const Module &M) {
assert(GVVisiting.size() == 0 && "Did not fully process a global variable");
const NVPTXTargetMachine &NTM = static_cast<const NVPTXTargetMachine &>(TM);
- const NVPTXSubtarget &STI =
- *static_cast<const NVPTXSubtarget *>(NTM.getSubtargetImpl());
+ const NVPTXSubtarget &STI = *NTM.getSubtargetImpl();
// Print out module-level global variables in proper order
for (const GlobalVariable *GV : Globals)
@@ -1178,8 +1176,7 @@ void NVPTXAsmPrinter::emitDemotedVars(const Function *F, raw_ostream &O) {
ArrayRef<const GlobalVariable *> GVars = It->second;
const NVPTXTargetMachine &NTM = static_cast<const NVPTXTargetMachine &>(TM);
- const NVPTXSubtarget &STI =
- *static_cast<const NVPTXSubtarget *>(NTM.getSubtargetImpl());
+ const NVPTXSubtarget &STI = *NTM.getSubtargetImpl();
for (const GlobalVariable *GV : GVars) {
O << "\t// demoted variable\n\t";
More information about the llvm-commits
mailing list