[llvm] [Pass] Support MachineFunction in getIRName (PR #70901)

via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 1 00:08:04 PDT 2023


https://github.com/paperchalice created https://github.com/llvm/llvm-project/pull/70901

It is necessary in MachinePassManager. `llc` can show function names when using `debug-pass-manager`.

>From 8d2d6796398eadb8b127ac71cf63a676a8069e11 Mon Sep 17 00:00:00 2001
From: liujunchang <lgamma at 163.com>
Date: Wed, 1 Nov 2023 09:16:46 +0800
Subject: [PATCH] [Pass] Support MachineFunction in getIRName It is necessary
 in MachinePassManager

---
 llvm/lib/Passes/StandardInstrumentations.cpp | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/llvm/lib/Passes/StandardInstrumentations.cpp b/llvm/lib/Passes/StandardInstrumentations.cpp
index 06cc58c0219632d..8cae1235487f13b 100644
--- a/llvm/lib/Passes/StandardInstrumentations.cpp
+++ b/llvm/lib/Passes/StandardInstrumentations.cpp
@@ -19,6 +19,7 @@
 #include "llvm/Analysis/CallGraphSCCPass.h"
 #include "llvm/Analysis/LazyCallGraph.h"
 #include "llvm/Analysis/LoopInfo.h"
+#include "llvm/CodeGen/MachineFunction.h"
 #include "llvm/IR/Constants.h"
 #include "llvm/IR/Function.h"
 #include "llvm/IR/Module.h"
@@ -222,6 +223,9 @@ std::string getIRName(Any IR) {
   if (const auto **L = llvm::any_cast<const Loop *>(&IR))
     return (*L)->getName().str();
 
+  if (const auto **MF = llvm::any_cast<const MachineFunction *>(&IR))
+    return (*MF)->getName().str();
+
   llvm_unreachable("Unknown wrapped IR type");
 }
 



More information about the llvm-commits mailing list