[llvm] [CodeGen] Treat Reg uses which are partailly defined within bundle as internal read (PR #201004)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 2 10:54:20 PDT 2026


================
@@ -150,6 +136,37 @@ void llvm::finalizeBundle(MachineBasicBlock &MBB,
       BuildMI(MF, getDebugLoc(FirstMI, LastMI), TII->get(TargetOpcode::BUNDLE));
   Bundle.prepend(MIB);
 
+  // Compute the regunits whose definitions reach the bundle from outside,
+  // we use this to mark a partial-def + full-reg-uses as IsInternalRead.
+  bool TracksLiveness = MF.getRegInfo().tracksLiveness();
+  BitVector ExternDefs(TRI->getNumRegUnits());
+  if (TracksLiveness) {
+    if (MF.getRegInfo().reservedRegsFrozen()) {
+      const BitVector &Reserved = MF.getRegInfo().getReservedRegs();
+      for (int RegIdx = Reserved.find_first(); RegIdx >= 0;
+           RegIdx = Reserved.find_next(RegIdx)) {
+        for (MCRegUnit U : TRI->regunits(MCRegister(RegIdx)))
+          ExternDefs.set(static_cast<unsigned>(U));
+      }
+    }
+    {
+      LiveRegUnits LRU(*TRI);
+      LRU.addLiveIns(MBB);
----------------
arsenm wrote:

This probably shouldn't be using a throwaway LiveRegUnits 

https://github.com/llvm/llvm-project/pull/201004


More information about the llvm-commits mailing list