[llvm] [CodeGen] Treat Reg uses which are partailly defined within bundle as internal read (PR #201004)
Vikram Hegde via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 3 22:08:32 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);
----------------
vikramRH wrote:
refactored code to use LiveRegUnits throughout. looks more compact now.
https://github.com/llvm/llvm-project/pull/201004
More information about the llvm-commits
mailing list