Skip to content

[Exegesis][RISCV] Remove the usage of RISCVSubtarget #129568

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mshockwave
Copy link
Member

Replace the usage of RISCVSubtarget in RISCVExegesisPreprocessingPass with an equivalent. Because including RISCVSubtarget.h might slow down the build speed by hindering the degree of parallelism for components outside LLVMRISCVCodeGen.

Replace the usage of RISCVSubtarget in RISCVExegesisPreprocessingPass
with an equivalent. Because including RISCVSubtarget.h might slow down
the build speed by hindering the degree of parallelism for components
outside LLVMRISCVCodeGen.
@llvmbot
Copy link
Member

llvmbot commented Mar 3, 2025

@llvm/pr-subscribers-tools-llvm-exegesis

@llvm/pr-subscribers-backend-risc-v

Author: Min-Yih Hsu (mshockwave)

Changes

Replace the usage of RISCVSubtarget in RISCVExegesisPreprocessingPass with an equivalent. Because including RISCVSubtarget.h might slow down the build speed by hindering the degree of parallelism for components outside LLVMRISCVCodeGen.


Full diff: https://github.com/llvm/llvm-project/pull/129568.diff

1 Files Affected:

  • (modified) llvm/tools/llvm-exegesis/lib/RISCV/RISCVExegesisPreprocessing.cpp (+8-4)
diff --git a/llvm/tools/llvm-exegesis/lib/RISCV/RISCVExegesisPreprocessing.cpp b/llvm/tools/llvm-exegesis/lib/RISCV/RISCVExegesisPreprocessing.cpp
index 7f1cfd9ea52df..69a02e94ecb39 100644
--- a/llvm/tools/llvm-exegesis/lib/RISCV/RISCVExegesisPreprocessing.cpp
+++ b/llvm/tools/llvm-exegesis/lib/RISCV/RISCVExegesisPreprocessing.cpp
@@ -12,9 +12,10 @@
 #include "RISCV.h"
 #include "RISCVExegesisPasses.h"
 #include "RISCVRegisterInfo.h"
-#include "RISCVSubtarget.h"
 #include "llvm/CodeGen/MachineFunctionPass.h"
 #include "llvm/CodeGen/MachineRegisterInfo.h"
+#include "llvm/CodeGen/TargetInstrInfo.h"
+#include "llvm/MC/MCContext.h"
 
 using namespace llvm;
 
@@ -63,10 +64,13 @@ static bool processAVLOperand(MachineInstr &MI, MachineRegisterInfo &MRI,
 
 bool RISCVExegesisPreprocessing::runOnMachineFunction(MachineFunction &MF) {
   MachineRegisterInfo &MRI = MF.getRegInfo();
-  const auto &STI = MF.getSubtarget<RISCVSubtarget>();
-  if (!STI.hasVInstructions())
+  // We could have use RISCVSubtarget::hasVInstructions here but including
+  // RISCVSubtarget.h would serialize the build of components outside
+  // LLVMRISCVCodeGen.
+  const MCSubtargetInfo &STI = *MF.getContext().getSubtargetInfo();
+  if (!STI.hasFeature(RISCV::FeatureStdExtZve32x))
     return false;
-  const TargetInstrInfo &TII = *STI.getInstrInfo();
+  const TargetInstrInfo &TII = *MF.getSubtarget().getInstrInfo();
 
   LLVM_DEBUG(MF.print(dbgs() << "===Before RISCVExegesisPoreprocessing===\n");
              dbgs() << "\n");

@topperc
Copy link
Collaborator

topperc commented Mar 3, 2025

Isn't the dependency on RISCVMCTargetDesc.h through the RISCV.h the same issue?

const auto &STI = MF.getSubtarget<RISCVSubtarget>();
if (!STI.hasVInstructions())
// We could have use RISCVSubtarget::hasVInstructions here but including
// RISCVSubtarget.h would serialize the build of components outside
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't the build ordering be defined by the CMake target dependencies and not what headers get included?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah the RISCV part of llvm-exegesis already depends on RISCVCommonTableGen

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nico I assumed you raised the original concern when you're dealing with GN, how are dependencies in this case got resolved in GN?

@mshockwave
Copy link
Member Author

@nico do you mind sharing how GN resolves dependencies? #129568 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants