[llvm] [CodeGen] Use first EHLabel as a stop gate for live range shrinking (PR #114195)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 31 08:59:52 PDT 2024


================
@@ -135,6 +137,13 @@ bool LiveRangeShrink::runOnMachineFunction(MachineFunction &MF) {
         continue;
       if (MI.mayStore())
         SawStore = true;
+      if (IsEHPad && !SawEHLabel && MI.isEHLabel() && Next != MBB.end()) {
+        // If MI is the first EHLabel of an EHPad, it should become a
+        // barrier for code motion. IOM is rebuild from the next instruction
+        // to prevent later instructions from being moved before this MI.
+        SawEHLabel = true;
+        BuildInstOrderMap(Next, IOM);
----------------
arsenm wrote:

This amounts to recomputing a machineinstr->index map twice. Why not just use SkipPHIsLabelsAndDebug up above ni the original map computation, and re-use the iterator at the start of the loop here 

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


More information about the llvm-commits mailing list