[llvm] [llc] Remove an unnecessary cast (NFC) (PR #151085)

Kazu Hirata via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 28 22:33:17 PDT 2025


https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/151085

getObjFileLowering() already returns TargetLoweringObjectFile *.


>From 82d69e93e28b7b2c579ecaeb7e8abe2e12da93d1 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Sun, 27 Jul 2025 12:06:05 -0700
Subject: [PATCH] [llc] Remove an unnecessary cast (NFC)

getObjFileLowering() already returns TargetLoweringObjectFile *.
---
 llvm/tools/llc/llc.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/llvm/tools/llc/llc.cpp b/llvm/tools/llc/llc.cpp
index 93b4a50ef86d7e..b3d7185e7f1445 100644
--- a/llvm/tools/llc/llc.cpp
+++ b/llvm/tools/llc/llc.cpp
@@ -733,8 +733,8 @@ static int compileModule(char **argv, LLVMContext &Context) {
         reportError("target does not support generation of this file type");
     }
 
-    const_cast<TargetLoweringObjectFile *>(Target->getObjFileLowering())
-        ->Initialize(MMIWP->getMMI().getContext(), *Target);
+    Target->getObjFileLowering()->Initialize(MMIWP->getMMI().getContext(),
+                                             *Target);
     if (MIR) {
       assert(MMIWP && "Forgot to create MMIWP?");
       if (MIR->parseMachineFunctions(*M, MMIWP->getMMI()))



More information about the llvm-commits mailing list