Skip to content

Commit 9d65d37

Browse files
committed
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@214417 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 5dbbe4a commit 9d65d37

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

lib/Bitcode/Writer/ValueEnumerator.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -166,21 +166,21 @@ static void predictValueUseListOrderImpl(const Value *V, const Function *F,
166166

167167
// If ID is 4, then expect: 7 6 5 1 2 3.
168168
if (LID < RID) {
169-
if (RID < ID)
169+
if (RID <= ID)
170170
if (!IsGlobalValue) // GlobalValue uses don't get reversed.
171171
return true;
172172
return false;
173173
}
174174
if (RID < LID) {
175-
if (LID < ID)
175+
if (LID <= ID)
176176
if (!IsGlobalValue) // GlobalValue uses don't get reversed.
177177
return false;
178178
return true;
179179
}
180180

181181
// LID and RID are equal, so we have different operands of the same user.
182182
// Assume operands are added in order for all instructions.
183-
if (LID < ID)
183+
if (LID <= ID)
184184
if (!IsGlobalValue) // GlobalValue uses don't get reversed.
185185
return LU->getOperandNo() < RU->getOperandNo();
186186
return LU->getOperandNo() > RU->getOperandNo();

test/Assembler/2002-08-22-DominanceProblem.ll

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
; RUN: llvm-as %s -o /dev/null
2+
; RUN: verify-uselistorder %s -preserve-bc-use-list-order -num-shuffles=5
23

34
; Dominance relationships is not calculated correctly for unreachable blocks,
45
; which causes the verifier to barf on this input.

test/Bitcode/use-list-order.ll

+13
Original file line numberDiff line numberDiff line change
@@ -118,3 +118,16 @@ entry:
118118
%local = load i4* @globalAndFunction
119119
ret i4 %local
120120
}
121+
122+
; Check for when an instruction is its own user.
123+
define void @selfUser() {
124+
entry:
125+
ret void
126+
127+
loop1:
128+
br label %loop2
129+
130+
loop2:
131+
%var = phi i32 [ %var, %loop1 ], [ %var, %loop2 ]
132+
br label %loop1
133+
}

0 commit comments

Comments
 (0)