[llvm] [CodeGen] Clear InitUndef pass new register cache between pass runs (PR #90967)

Joe Faulls via llvm-commits llvm-commits at lists.llvm.org
Fri May 3 06:15:39 PDT 2024


https://github.com/joe-img created https://github.com/llvm/llvm-project/pull/90967

Multiple invocations of the pass could interfere with eachother, preventing some undefs being initialised.

I found it very difficult to create a unit test for this due to it being dependent on particular allocations of a previous function. However, the bug can be observed here: https://godbolt.org/z/7xnMo41Gv with the creation of the illegal instruction `vnsrl.wi        v9, v8, 0`

Does this patch require a unit test?

>From 3216f21329d7b9acb7a4f4e732e14683bb2448f2 Mon Sep 17 00:00:00 2001
From: "Joseph.Faulls" <Joseph.Faulls at imgtec.com>
Date: Fri, 3 May 2024 14:08:17 +0100
Subject: [PATCH] [CodeGen] Clear InitUndef pass new register cache between
 pass runs

Multiple invocations of the pass could interfere with eachother,
preventing some undefs being initialised.
---
 llvm/lib/CodeGen/InitUndef.cpp | 1 +
 1 file changed, 1 insertion(+)

diff --git a/llvm/lib/CodeGen/InitUndef.cpp b/llvm/lib/CodeGen/InitUndef.cpp
index 96ac385b6abf82..782649b640079a 100644
--- a/llvm/lib/CodeGen/InitUndef.cpp
+++ b/llvm/lib/CodeGen/InitUndef.cpp
@@ -272,6 +272,7 @@ bool InitUndef::runOnMachineFunction(MachineFunction &MF) {
   for (auto *DeadMI : DeadInsts)
     DeadMI->eraseFromParent();
   DeadInsts.clear();
+  NewRegs.clear();
 
   return Changed;
 }



More information about the llvm-commits mailing list