Skip to content

Commit 97cbd1f

Browse files
committed
[Bitcode] Fix nondeterministic phi instruction order
Currently there can be nondeterminism of the form ```diff - <INST_PHI op0=307 op1=2 op2=22 op3=67 op4=29 op5=111 op6=57 ...> + <INST_PHI op0=307 op1=2 op2=22 op3=67 op4=29 op5=157 op6=71 ...> ``` in generated bitcode. Stably sorting the use-list entries solves that.
1 parent 2368be3 commit 97cbd1f

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

llvm/lib/Bitcode/Writer/ValueEnumerator.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ static void predictValueUseListOrderImpl(const Value *V, const Function *F,
186186
return;
187187

188188
bool IsGlobalValue = OM.isGlobalValue(ID);
189-
llvm::sort(List, [&](const Entry &L, const Entry &R) {
189+
llvm::stable_sort(List, [&](const Entry &L, const Entry &R) {
190190
const Use *LU = L.first;
191191
const Use *RU = R.first;
192192
if (LU == RU)

0 commit comments

Comments
 (0)