[llvm] r311520 - Add test case for r311511

Matthias Braun via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 22 20:17:59 PDT 2017


Author: matze
Date: Tue Aug 22 20:17:59 2017
New Revision: 311520

URL: http://llvm.org/viewvc/llvm-project?rev=311520&view=rev
Log:
Add test case for r311511

This also changes the TailDuplicator to be configured explicitely
pre/post regalloc rather than relying on the isSSA() flag. This was
necessary to have `llc -run-pass` work reliably.

Added:
    llvm/trunk/test/CodeGen/ARM/tail-dup-bundle.mir
Modified:
    llvm/trunk/include/llvm/CodeGen/TailDuplicator.h
    llvm/trunk/lib/CodeGen/MachineBlockPlacement.cpp
    llvm/trunk/lib/CodeGen/TailDuplication.cpp
    llvm/trunk/lib/CodeGen/TailDuplicator.cpp

Modified: llvm/trunk/include/llvm/CodeGen/TailDuplicator.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/TailDuplicator.h?rev=311520&r1=311519&r2=311520&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/TailDuplicator.h (original)
+++ llvm/trunk/include/llvm/CodeGen/TailDuplicator.h Tue Aug 22 20:17:59 2017
@@ -61,13 +61,14 @@ class TailDuplicator {
 public:
   /// Prepare to run on a specific machine function.
   /// @param MF - Function that will be processed
+  /// @param PreRegAlloc - true if used before register allocation
   /// @param MBPI - Branch Probability Info. Used to propagate correct
   ///     probabilities when modifying the CFG.
   /// @param LayoutMode - When true, don't use the existing layout to make
   ///     decisions.
   /// @param TailDupSize - Maxmimum size of blocks to tail-duplicate. Zero
   ///     default implies using the command line value TailDupSize.
-  void initMF(MachineFunction &MF,
+  void initMF(MachineFunction &MF, bool PreRegAlloc,
               const MachineBranchProbabilityInfo *MBPI,
               bool LayoutMode, unsigned TailDupSize = 0);
 

Modified: llvm/trunk/lib/CodeGen/MachineBlockPlacement.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineBlockPlacement.cpp?rev=311520&r1=311519&r2=311520&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MachineBlockPlacement.cpp (original)
+++ llvm/trunk/lib/CodeGen/MachineBlockPlacement.cpp Tue Aug 22 20:17:59 2017
@@ -2729,7 +2729,8 @@ bool MachineBlockPlacement::runOnMachine
     MPDT = &getAnalysis<MachinePostDominatorTree>();
     if (MF.getFunction()->optForSize())
       TailDupSize = 1;
-    TailDup.initMF(MF, MBPI, /* LayoutMode */ true, TailDupSize);
+    bool PreRegAlloc = false;
+    TailDup.initMF(MF, PreRegAlloc, MBPI, /* LayoutMode */ true, TailDupSize);
     precomputeTriangleChains();
   }
 

Modified: llvm/trunk/lib/CodeGen/TailDuplication.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/TailDuplication.cpp?rev=311520&r1=311519&r2=311520&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/TailDuplication.cpp (original)
+++ llvm/trunk/lib/CodeGen/TailDuplication.cpp Tue Aug 22 20:17:59 2017
@@ -52,7 +52,10 @@ bool TailDuplicatePass::runOnMachineFunc
 
   auto MBPI = &getAnalysis<MachineBranchProbabilityInfo>();
 
-  Duplicator.initMF(MF, MBPI, /* LayoutMode */ false);
+  // TODO: Querying isSSA() to determine pre-/post-regalloc is fragile, better
+  // split this into two passes instead.
+  bool PreRegAlloc = MF.getRegInfo().isSSA();
+  Duplicator.initMF(MF, PreRegAlloc, MBPI, /* LayoutMode */ false);
 
   bool MadeChange = false;
   while (Duplicator.tailDuplicateBlocks())

Modified: llvm/trunk/lib/CodeGen/TailDuplicator.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/TailDuplicator.cpp?rev=311520&r1=311519&r2=311520&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/TailDuplicator.cpp (original)
+++ llvm/trunk/lib/CodeGen/TailDuplicator.cpp Tue Aug 22 20:17:59 2017
@@ -75,7 +75,7 @@ static cl::opt<bool>
 static cl::opt<unsigned> TailDupLimit("tail-dup-limit", cl::init(~0U),
                                       cl::Hidden);
 
-void TailDuplicator::initMF(MachineFunction &MFin,
+void TailDuplicator::initMF(MachineFunction &MFin, bool PreRegAlloc,
                             const MachineBranchProbabilityInfo *MBPIin,
                             bool LayoutModeIn, unsigned TailDupSizeIn) {
   MF = &MFin;
@@ -89,7 +89,7 @@ void TailDuplicator::initMF(MachineFunct
   assert(MBPI != nullptr && "Machine Branch Probability Info required");
 
   LayoutMode = LayoutModeIn;
-  PreRegAlloc = MRI->isSSA();
+  this->PreRegAlloc = PreRegAlloc;
 }
 
 static void VerifyPHIs(MachineFunction &MF, bool CheckExtra) {

Added: llvm/trunk/test/CodeGen/ARM/tail-dup-bundle.mir
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/tail-dup-bundle.mir?rev=311520&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/ARM/tail-dup-bundle.mir (added)
+++ llvm/trunk/test/CodeGen/ARM/tail-dup-bundle.mir Tue Aug 22 20:17:59 2017
@@ -0,0 +1,36 @@
+# RUN: llc -o - %s -run-pass=block-placement -mtriple=thumbv7k-apple-ios8.0.0 -verify-machineinstrs -O3 | FileCheck %s
+---
+# CHECK-LABEL: name: func
+# Make sure the bundle gets duplicated correctly
+# CHECK: BUNDLE implicit-def dead %itstate, implicit-def %cpsr, implicit killed %r0, implicit killed %cpsr {
+# CHECK:   t2IT 1, 24, implicit-def %itstate
+# CHECK:   t2CMPri killed %r0, 9, 1, killed %cpsr, implicit-def %cpsr, implicit internal killed %itstate
+# CHECK: }
+# CHECK: BUNDLE implicit-def dead %itstate, implicit-def %cpsr, implicit killed %r0, implicit killed %cpsr {
+# CHECK:   t2IT 1, 24, implicit-def %itstate
+# CHECK:   t2CMPri killed %r0, 9, 1, killed %cpsr, implicit-def %cpsr, implicit internal killed %itstate
+# CHECK: }
+name: func
+tracksRegLiveness: true
+body: |
+  bb.0:
+    liveins: %r0, %lr, %r7
+
+  bb.1:
+    liveins: %r0
+
+    t2CMPri %r0, 32, 14, _, implicit-def %cpsr
+    BUNDLE implicit-def dead %itstate, implicit-def %cpsr, implicit killed %r0, implicit killed %cpsr {
+      t2IT 1, 24, implicit-def %itstate
+      t2CMPri killed %r0, 9, 1, killed %cpsr, implicit-def %cpsr, implicit internal killed %itstate
+    }
+    t2Bcc %bb.3, 1, killed %cpsr
+
+  bb.2:
+    %r0 = IMPLICIT_DEF
+    t2B %bb.1, 14, _
+
+  bb.3:
+    %r0 = IMPLICIT_DEF
+    t2B %bb.1, 14, _
+...




More information about the llvm-commits mailing list