[llvm] r214417 - UseListOrder: Handle self-users

Duncan P. N. Exon Smith dexonsmith at apple.com
Thu Jul 31 11:33:12 PDT 2014


Author: dexonsmith
Date: Thu Jul 31 13:33:12 2014
New Revision: 214417

URL: http://llvm.org/viewvc/llvm-project?rev=214417&view=rev
Log:
UseListOrder: Handle self-users

Correctly sort self-users (such as PHI nodes).  I added a targeted test
in `test/Bitcode/use-list-order.ll` and the final missing RUN line to
tests in `test/Assembly`.

This is part of PR5680.

Modified:
    llvm/trunk/lib/Bitcode/Writer/ValueEnumerator.cpp
    llvm/trunk/test/Assembler/2002-08-22-DominanceProblem.ll
    llvm/trunk/test/Bitcode/use-list-order.ll

Modified: llvm/trunk/lib/Bitcode/Writer/ValueEnumerator.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Writer/ValueEnumerator.cpp?rev=214417&r1=214416&r2=214417&view=diff
==============================================================================
--- llvm/trunk/lib/Bitcode/Writer/ValueEnumerator.cpp (original)
+++ llvm/trunk/lib/Bitcode/Writer/ValueEnumerator.cpp Thu Jul 31 13:33:12 2014
@@ -166,13 +166,13 @@ static void predictValueUseListOrderImpl
 
     // If ID is 4, then expect: 7 6 5 1 2 3.
     if (LID < RID) {
-      if (RID < ID)
+      if (RID <= ID)
         if (!IsGlobalValue) // GlobalValue uses don't get reversed.
           return true;
       return false;
     }
     if (RID < LID) {
-      if (LID < ID)
+      if (LID <= ID)
         if (!IsGlobalValue) // GlobalValue uses don't get reversed.
           return false;
       return true;
@@ -180,7 +180,7 @@ static void predictValueUseListOrderImpl
 
     // LID and RID are equal, so we have different operands of the same user.
     // Assume operands are added in order for all instructions.
-    if (LID < ID)
+    if (LID <= ID)
       if (!IsGlobalValue) // GlobalValue uses don't get reversed.
         return LU->getOperandNo() < RU->getOperandNo();
     return LU->getOperandNo() > RU->getOperandNo();

Modified: llvm/trunk/test/Assembler/2002-08-22-DominanceProblem.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Assembler/2002-08-22-DominanceProblem.ll?rev=214417&r1=214416&r2=214417&view=diff
==============================================================================
--- llvm/trunk/test/Assembler/2002-08-22-DominanceProblem.ll (original)
+++ llvm/trunk/test/Assembler/2002-08-22-DominanceProblem.ll Thu Jul 31 13:33:12 2014
@@ -1,4 +1,5 @@
 ; RUN: llvm-as %s -o /dev/null
+; RUN: verify-uselistorder %s -preserve-bc-use-list-order -num-shuffles=5
 
 ; Dominance relationships is not calculated correctly for unreachable blocks,
 ; which causes the verifier to barf on this input.

Modified: llvm/trunk/test/Bitcode/use-list-order.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Bitcode/use-list-order.ll?rev=214417&r1=214416&r2=214417&view=diff
==============================================================================
--- llvm/trunk/test/Bitcode/use-list-order.ll (original)
+++ llvm/trunk/test/Bitcode/use-list-order.ll Thu Jul 31 13:33:12 2014
@@ -118,3 +118,16 @@ entry:
   %local = load i4* @globalAndFunction
   ret i4 %local
 }
+
+; Check for when an instruction is its own user.
+define void @selfUser() {
+entry:
+  ret void
+
+loop1:
+  br label %loop2
+
+loop2:
+  %var = phi i32 [ %var, %loop1 ], [ %var, %loop2 ]
+  br label %loop1
+}





More information about the llvm-commits mailing list