[llvm] add register logging (PR #137664)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 28 09:31:40 PDT 2025
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff HEAD~1 HEAD --extensions cpp,h -- llvm/lib/Target/NVPTX/NVPTXRegCount.cpp llvm/lib/Target/NVPTX/NVPTX.h llvm/lib/Target/NVPTX/NVPTXTargetMachine.cpp
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/llvm/lib/Target/NVPTX/NVPTXRegCount.cpp b/llvm/lib/Target/NVPTX/NVPTXRegCount.cpp
index 5caf934ed..6306d775b 100644
--- a/llvm/lib/Target/NVPTX/NVPTXRegCount.cpp
+++ b/llvm/lib/Target/NVPTX/NVPTXRegCount.cpp
@@ -10,8 +10,8 @@
//
//===----------------------------------------------------------------------===//
-#include "NVPTXISelDAGToDAG.h"
#include "NVPTX.h"
+#include "NVPTXISelDAGToDAG.h"
#include "NVPTXUtilities.h"
#include "llvm/ADT/APInt.h"
#include "llvm/Analysis/ValueTracking.h"
@@ -31,34 +31,34 @@ using namespace llvm;
namespace {
class NVPTXRegCountPass : public MachineFunctionPass {
- public:
- static char ID;
- NVPTXRegCountPass() : MachineFunctionPass(ID) {}
-
- bool runOnMachineFunction(MachineFunction &MF) override {
- unsigned maxRegs = 0;
- for (const MachineBasicBlock &MBB : MF) {
- unsigned liveRegs = 0;
- for (const MachineInstr &MI : MBB) {
- // Count unique virtual and physical registers
- for (const MachineOperand &MO : MI.operands()) {
- if (MO.isReg() && MO.getReg())
- liveRegs++;
- }
- }
- maxRegs = std::max(maxRegs, liveRegs);
+public:
+ static char ID;
+ NVPTXRegCountPass() : MachineFunctionPass(ID) {}
+
+ bool runOnMachineFunction(MachineFunction &MF) override {
+ unsigned maxRegs = 0;
+ for (const MachineBasicBlock &MBB : MF) {
+ unsigned liveRegs = 0;
+ for (const MachineInstr &MI : MBB) {
+ // Count unique virtual and physical registers
+ for (const MachineOperand &MO : MI.operands()) {
+ if (MO.isReg() && MO.getReg())
+ liveRegs++;
}
- errs() << "Function " << MF.getName() << " uses maximum of "
- << maxRegs << " registers\n";
- return false;
}
- };
+ maxRegs = std::max(maxRegs, liveRegs);
+ }
+ errs() << "Function " << MF.getName() << " uses maximum of " << maxRegs
+ << " registers\n";
+ return false;
+ }
+};
} // namespace
char NVPTXRegCountPass::ID = 0;
// INITIALIZE_PASS(NVPTXRegCountPass, "nvptx-count-reg",
// "NVPTX count reg", false, false)
- FunctionPass *llvm::createNVPTXRegCountPass() {
- return new NVPTXRegCountPass();
- }
\ No newline at end of file
+FunctionPass *llvm::createNVPTXRegCountPass() {
+ return new NVPTXRegCountPass();
+}
\ No newline at end of file
diff --git a/llvm/lib/Target/NVPTX/NVPTXTargetMachine.cpp b/llvm/lib/Target/NVPTX/NVPTXTargetMachine.cpp
index da6ef5a99..bb7d62922 100644
--- a/llvm/lib/Target/NVPTX/NVPTXTargetMachine.cpp
+++ b/llvm/lib/Target/NVPTX/NVPTXTargetMachine.cpp
@@ -239,13 +239,16 @@ void NVPTXTargetMachine::registerDefaultAliasAnalyses(AAManager &AAM) {
struct NVPTXModulePrinter : public PassInfoMixin<NVPTXModulePrinter> {
PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM) {
std::error_code EC;
- raw_fd_ostream OutFile("/home/ubuntu/modular/delete-me-test_batch_kv_cache_flash_attention_causal_mask_ragged_paged.ll", EC);
+ raw_fd_ostream OutFile("/home/ubuntu/modular/"
+ "delete-me-test_batch_kv_cache_flash_attention_"
+ "causal_mask_ragged_paged.ll",
+ EC);
if (!EC) {
M.print(OutFile, nullptr);
}
return PreservedAnalyses::all();
}
-
+
static bool isRequired() { return true; }
};
@@ -266,7 +269,7 @@ void NVPTXTargetMachine::registerPassBuilderCallbacks(PassBuilder &PB) {
FPM.addPass(NVVMIntrRangePass());
if (EarlyByValArgsCopy)
FPM.addPass(NVPTXCopyByValArgsPass());
- //PM.addPass(NVPTXModulePrinter());
+ // PM.addPass(NVPTXModulePrinter());
PM.addPass(createModuleToFunctionPassAdaptor(std::move(FPM)));
});
``````````
</details>
https://github.com/llvm/llvm-project/pull/137664
More information about the llvm-commits
mailing list