[llvm-branch-commits] [llvm] [CodeGen][NPM] VirtRegRewriter: Set VirtReg flag (PR #138660)

Akshat Oke via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Tue May 6 03:15:09 PDT 2025


https://github.com/optimisan updated https://github.com/llvm/llvm-project/pull/138660

>From 87c1295ee4502f5cc227d7912cb21dd7e069320c Mon Sep 17 00:00:00 2001
From: Akshat Oke <Akshat.Oke at amd.com>
Date: Tue, 6 May 2025 09:05:52 +0000
Subject: [PATCH] [CodeGen][NPM] VirtRegRewriter: Set VirtReg flag

---
 llvm/include/llvm/CodeGen/VirtRegMap.h | 8 ++++++++
 llvm/lib/CodeGen/VirtRegMap.cpp        | 2 ++
 2 files changed, 10 insertions(+)

diff --git a/llvm/include/llvm/CodeGen/VirtRegMap.h b/llvm/include/llvm/CodeGen/VirtRegMap.h
index f5fba0d65401e..37d382650ac1f 100644
--- a/llvm/include/llvm/CodeGen/VirtRegMap.h
+++ b/llvm/include/llvm/CodeGen/VirtRegMap.h
@@ -248,6 +248,14 @@ class VirtRegRewriterPass : public PassInfoMixin<VirtRegRewriterPass> {
   static bool isRequired() { return true; }
 
   void printPipeline(raw_ostream &OS, function_ref<StringRef(StringRef)>) const;
+
+  MachineFunctionProperties getSetProperties() const {
+    if (ClearVirtRegs) {
+      return MachineFunctionProperties().set(
+          MachineFunctionProperties::Property::NoVRegs);
+    }
+    return {};
+  }
 };
 
 } // end llvm namespace
diff --git a/llvm/lib/CodeGen/VirtRegMap.cpp b/llvm/lib/CodeGen/VirtRegMap.cpp
index 49e819e2d10f7..839905d5e3860 100644
--- a/llvm/lib/CodeGen/VirtRegMap.cpp
+++ b/llvm/lib/CodeGen/VirtRegMap.cpp
@@ -302,6 +302,8 @@ bool VirtRegRewriterLegacy::runOnMachineFunction(MachineFunction &MF) {
 PreservedAnalyses
 VirtRegRewriterPass::run(MachineFunction &MF,
                          MachineFunctionAnalysisManager &MFAM) {
+  MFPropsModifier _(*this, MF);
+
   VirtRegMap &VRM = MFAM.getResult<VirtRegMapAnalysis>(MF);
   LiveIntervals &LIS = MFAM.getResult<LiveIntervalsAnalysis>(MF);
   LiveRegMatrix &LRM = MFAM.getResult<LiveRegMatrixAnalysis>(MF);



More information about the llvm-branch-commits mailing list