[llvm-branch-commits] [llvm] [CFI][annotation] Leave alone function pointers in function annotations (PR #81673)

2024-02-14 Thread Oskar Wirga via llvm-branch-commits

https://github.com/oskarwirga approved this pull request.


https://github.com/llvm/llvm-project/pull/81673
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] Refactor recomputeLiveIns to operate on whole CFG (#79498) (PR #79641)

2024-01-26 Thread Oskar Wirga via llvm-branch-commits

https://github.com/oskarwirga milestoned 
https://github.com/llvm/llvm-project/pull/79641
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] Refactor recomputeLiveIns to operate on whole CFG (#79498) (PR #79641)

2024-01-26 Thread Oskar Wirga via llvm-branch-commits

https://github.com/oskarwirga edited 
https://github.com/llvm/llvm-project/pull/79641
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] Refactor recomputeLiveIns to operate on whole CFG (#79498) (PR #79641)

2024-01-31 Thread Oskar Wirga via llvm-branch-commits

https://github.com/oskarwirga updated 
https://github.com/llvm/llvm-project/pull/79641

>From b4901ff3e9f9fef59bf64fb9f7465f949a2ca32a Mon Sep 17 00:00:00 2001
From: Oskar Wirga <10386631+oskarwi...@users.noreply.github.com>
Date: Tue, 30 Jan 2024 19:33:04 -0800
Subject: [PATCH] Refactor recomputeLiveIns to converge on added
 MachineBasicBlocks (#79940)

This is a fix for the regression seen in
https://github.com/llvm/llvm-project/pull/79498

> Currently, the way that recomputeLiveIns works is that it will
recompute the livein registers for that MachineBasicBlock but it matters
what order you call recomputeLiveIn which can result in incorrect
register allocations down the line.

Now we do not recompute the entire CFG but we do ensure that the newly
added MBB do reach convergence.

(cherry picked from commit ff4636a4ab00b633c15eb3942c26126ceb2662e6)
---
 llvm/include/llvm/CodeGen/LivePhysRegs.h  | 11 --
 llvm/include/llvm/CodeGen/MachineBasicBlock.h |  6 
 llvm/lib/CodeGen/BranchFolding.cpp|  6 ++--
 .../Target/AArch64/AArch64FrameLowering.cpp   |  6 ++--
 llvm/lib/Target/AArch64/AArch64InstrInfo.cpp  | 10 --
 llvm/lib/Target/ARM/ARMLowOverheadLoops.cpp   | 13 +++
 .../PowerPC/PPCExpandAtomicPseudoInsts.cpp| 14 +---
 llvm/lib/Target/PowerPC/PPCFrameLowering.cpp  | 13 ---
 .../Target/SystemZ/SystemZFrameLowering.cpp   | 12 ---
 llvm/lib/Target/X86/X86FrameLowering.cpp  | 15 
 .../SystemZ/branch-folder-hoist-livein.mir| 36 +--
 .../Thumb2/LowOverheadLoops/spillingmove.mir  |  2 +-
 12 files changed, 98 insertions(+), 46 deletions(-)

diff --git a/llvm/include/llvm/CodeGen/LivePhysRegs.h 
b/llvm/include/llvm/CodeGen/LivePhysRegs.h
index 76bb34d270a26..1d40b1cbb0eaa 100644
--- a/llvm/include/llvm/CodeGen/LivePhysRegs.h
+++ b/llvm/include/llvm/CodeGen/LivePhysRegs.h
@@ -193,11 +193,18 @@ void addLiveIns(MachineBasicBlock &MBB, const 
LivePhysRegs &LiveRegs);
 void computeAndAddLiveIns(LivePhysRegs &LiveRegs,
   MachineBasicBlock &MBB);
 
-/// Convenience function for recomputing live-in's for \p MBB.
-static inline void recomputeLiveIns(MachineBasicBlock &MBB) {
+/// Convenience function for recomputing live-in's for a MBB. Returns true if
+/// any changes were made.
+static inline bool recomputeLiveIns(MachineBasicBlock &MBB) {
   LivePhysRegs LPR;
+  auto oldLiveIns = MBB.getLiveIns();
+
   MBB.clearLiveIns();
   computeAndAddLiveIns(LPR, MBB);
+  MBB.sortUniqueLiveIns();
+
+  auto newLiveIns = MBB.getLiveIns();
+  return oldLiveIns != newLiveIns;
 }
 
 } // end namespace llvm
diff --git a/llvm/include/llvm/CodeGen/MachineBasicBlock.h 
b/llvm/include/llvm/CodeGen/MachineBasicBlock.h
index c84fd281c6a54..dc2035fa598c4 100644
--- a/llvm/include/llvm/CodeGen/MachineBasicBlock.h
+++ b/llvm/include/llvm/CodeGen/MachineBasicBlock.h
@@ -111,6 +111,10 @@ class MachineBasicBlock
 
 RegisterMaskPair(MCPhysReg PhysReg, LaneBitmask LaneMask)
 : PhysReg(PhysReg), LaneMask(LaneMask) {}
+
+bool operator==(const RegisterMaskPair &other) const {
+  return PhysReg == other.PhysReg && LaneMask == other.LaneMask;
+}
   };
 
 private:
@@ -473,6 +477,8 @@ class MachineBasicBlock
   /// Remove entry from the livein set and return iterator to the next.
   livein_iterator removeLiveIn(livein_iterator I);
 
+  std::vector getLiveIns() const { return LiveIns; }
+
   class liveout_iterator {
   public:
 using iterator_category = std::input_iterator_tag;
diff --git a/llvm/lib/CodeGen/BranchFolding.cpp 
b/llvm/lib/CodeGen/BranchFolding.cpp
index a9f78358e57b9..ecf7bc30913f5 100644
--- a/llvm/lib/CodeGen/BranchFolding.cpp
+++ b/llvm/lib/CodeGen/BranchFolding.cpp
@@ -2048,8 +2048,10 @@ bool 
BranchFolder::HoistCommonCodeInSuccs(MachineBasicBlock *MBB) {
   FBB->erase(FBB->begin(), FIB);
 
   if (UpdateLiveIns) {
-recomputeLiveIns(*TBB);
-recomputeLiveIns(*FBB);
+bool anyChange = false;
+do {
+  anyChange = recomputeLiveIns(*TBB) || recomputeLiveIns(*FBB);
+} while (anyChange);
   }
 
   ++NumHoist;
diff --git a/llvm/lib/Target/AArch64/AArch64FrameLowering.cpp 
b/llvm/lib/Target/AArch64/AArch64FrameLowering.cpp
index d55deec976009..732e787d2a321 100644
--- a/llvm/lib/Target/AArch64/AArch64FrameLowering.cpp
+++ b/llvm/lib/Target/AArch64/AArch64FrameLowering.cpp
@@ -4339,8 +4339,10 @@ AArch64FrameLowering::inlineStackProbeLoopExactMultiple(
   ExitMBB->transferSuccessorsAndUpdatePHIs(&MBB);
   MBB.addSuccessor(LoopMBB);
   // Update liveins.
-  recomputeLiveIns(*LoopMBB);
-  recomputeLiveIns(*ExitMBB);
+  bool anyChange = false;
+  do {
+anyChange = recomputeLiveIns(*ExitMBB) || recomputeLiveIns(*LoopMBB);
+  } while (anyChange);
 
   return ExitMBB->begin();
 }
diff --git a/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp 
b/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp
index 13e9d9725cc2e..9b4bb7c88bc82 100644
--- a/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp
+++ b/llvm/lib/Target/AArch64

[llvm-branch-commits] [llvm] Refactor recomputeLiveIns to operate on whole CFG (#79498) (PR #79641)

2024-02-01 Thread Oskar Wirga via llvm-branch-commits

https://github.com/oskarwirga edited 
https://github.com/llvm/llvm-project/pull/79641
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits