Skip to content

Commit 994af14

Browse files
committed
Bitcode: Correctly compare a Use against itself
Fix the sort of expected order in the reader to correctly return `false` when comparing a `Use` against itself. This was caught by test/Bitcode/binaryIntInstructions.3.2.ll, so I'm adding a `RUN` line using `llvm-uselistorder` for every test in `test/Bitcode` that passes. A few tests still fail, so I'll investigate those next. This is part of PR5680. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@214157 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 15f92a3 commit 994af14

36 files changed

+38
-0
lines changed

lib/Bitcode/Writer/ValueEnumerator.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,9 @@ static void predictValueUseListOrderImpl(const Value *V, const Function *F,
106106
[&OM, ID](const Entry &L, const Entry &R) {
107107
const Use *LU = L.first;
108108
const Use *RU = R.first;
109+
if (LU == RU)
110+
return false;
111+
109112
auto LID = OM.lookup(LU->getUser()).first;
110113
auto RID = OM.lookup(RU->getUser()).first;
111114
// If ID is 4, then expect: 7 6 5 1 2 3.

test/Bitcode/2006-12-11-Cast-ConstExpr.ll

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
; This test ensures that we get a bitcast constant expression in and out,
22
; not a sitofp constant expression.
33
; RUN: llvm-as < %s | llvm-dis | FileCheck %s
4+
; RUN: llvm-uselistorder < %s -preserve-bc-use-list-order -num-shuffles=5
45
; CHECK: bitcast (
56

67
@G = external global i32

test/Bitcode/2009-06-11-FirstClassAggregateConstant.ll

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
; RUN: llvm-as < %s | llvm-dis -disable-output
2+
; RUN: llvm-uselistorder < %s -preserve-bc-use-list-order -num-shuffles=5
23
; PR4373
34

45
@foo = weak global { i32 } zeroinitializer

test/Bitcode/aggregateInstructions.3.2.ll

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
; RUN: llvm-dis < %s.bc| FileCheck %s
2+
; RUN: llvm-uselistorder < %s.bc -preserve-bc-use-list-order -num-shuffles=5
23

34
; aggregateOperations.3.2.ll.bc was generated by passing this file to llvm-as-3.2.
45
; The test checks that LLVM does not misread instructions with aggregate operands

test/Bitcode/arm32_neon_vcnt_upgrade.ll

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
; RUN: llvm-as < %s | llvm-dis | FileCheck %s
2+
; RUN: llvm-uselistorder < %s -preserve-bc-use-list-order -num-shuffles=5
23
; Tests vclz and vcnt
34

45
define <4 x i16> @vclz16(<4 x i16>* %A) nounwind {

test/Bitcode/atomic.ll

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

34
define void @test_cmpxchg(i32* %addr, i32 %desired, i32 %new) {
45
cmpxchg i32* %addr, i32 %desired, i32 %new seq_cst seq_cst

test/Bitcode/attributes-3.3.ll

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
; RUN: llvm-dis < %s.bc| FileCheck %s
2+
; RUN: llvm-uselistorder < %s.bc -preserve-bc-use-list-order -num-shuffles=5
23

34
; attributes-3.3.ll.bc was generated by passing this file to llvm-as-3.3.
45
; The test checks that LLVM does not silently misread attributes of

test/Bitcode/attributes.ll

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
; RUN: llvm-as < %s | llvm-dis | FileCheck %s
2+
; RUN: llvm-uselistorder < %s -preserve-bc-use-list-order -num-shuffles=5
23
; PR12696
34

45
define void @f1(i8 zeroext)

test/Bitcode/binaryFloatInstructions.3.2.ll

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
; RUN: llvm-dis < %s.bc| FileCheck %s
2+
; RUN: llvm-uselistorder < %s.bc -preserve-bc-use-list-order -num-shuffles=5
23

34
; BinaryFloatOperation.3.2.ll.bc was generated by passing this file to llvm-as-3.2.
45
; The test checks that LLVM does not misread binary float instructions from

test/Bitcode/binaryIntInstructions.3.2.ll

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
; RUN: llvm-dis < %s.bc| FileCheck %s
2+
; RUN: llvm-uselistorder < %s.bc -preserve-bc-use-list-order -num-shuffles=5
23

34
; BinaryIntOperation.3.2.ll.bc was generated by passing this file to llvm-as-3.2.
45
; The test checks that LLVM does not misread binary integer instructions from

test/Bitcode/bitwiseInstructions.3.2.ll

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
; RUN: llvm-dis < %s.bc| FileCheck %s
2+
; RUN: llvm-uselistorder < %s.bc -preserve-bc-use-list-order -num-shuffles=5
23

34
; bitwiseOperations.3.2.ll.bc was generated by passing this file to llvm-as-3.2.
45
; The test checks that LLVM does not misread bitwise instructions from

test/Bitcode/calling-conventions.3.2.ll

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
; RUN: llvm-dis < %s.bc| FileCheck %s
2+
; RUN: llvm-uselistorder < %s.bc -preserve-bc-use-list-order -num-shuffles=5
23

34
; calling-conventions.3.2.ll.bc was generated by passing this file to llvm-as-3.2.
45
; The test checks that LLVM does not silently misread calling conventions of

test/Bitcode/case-ranges-3.3.ll

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
; RUN: llvm-dis < %s.bc| FileCheck %s
2+
; RUN: llvm-uselistorder < %s.bc -preserve-bc-use-list-order -num-shuffles=5
23

34
; case-ranges.ll.bc was generated by passing this file to llvm-as from the 3.3
45
; release of LLVM. This tests that the bitcode for switches from that release

test/Bitcode/cmpxchg-upgrade.ll

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
; RUN: llvm-dis < %s.bc | FileCheck %s
2+
; RUN: llvm-uselistorder < %s.bc -preserve-bc-use-list-order -num-shuffles=5
23

34
; cmpxchg-upgrade.ll.bc was produced by running a version of llvm-as from just
45
; before the IR change on this file.

test/Bitcode/conversionInstructions.3.2.ll

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
; RUN: llvm-dis < %s.bc| FileCheck %s
2+
; RUN: llvm-uselistorder < %s.bc -preserve-bc-use-list-order -num-shuffles=5
23

34
; conversionOperations.3.2.ll.bc was generated by passing this file to llvm-as-3.2.
45
; The test checks that LLVM does not misread conversion instructions from

test/Bitcode/drop-debug-info.ll

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
; RUN: llvm-as < %s -o %t.bc 2>&1 >/dev/null | FileCheck -check-prefix=WARN %s
22
; RUN: llvm-dis < %t.bc | FileCheck %s
3+
; RUN: llvm-uselistorder < %t.bc -preserve-bc-use-list-order -num-shuffles=5
34

45
define i32 @main() {
56
entry:

test/Bitcode/extractelement.ll

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
; RUN: opt < %s -constprop | llvm-dis -disable-output
2+
; RUN: llvm-uselistorder < %s -preserve-bc-use-list-order -num-shuffles=5
23
; PR3465
34

45
define double @test() {

test/Bitcode/flags.ll

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
; RUN: llvm-as < %s | llvm-dis > %t0
22
; RUN: opt -S < %s > %t1
33
; RUN: diff %t0 %t1
4+
; RUN: llvm-uselistorder < %s -preserve-bc-use-list-order -num-shuffles=5
45
; PR6140
56

67
; Make sure the flags are serialized/deserialized properly for both

test/Bitcode/function-encoding-rel-operands.ll

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
; Basic sanity test to check that instruction operands are encoded with
22
; relative IDs.
33
; RUN: llvm-as < %s | llvm-bcanalyzer -dump | FileCheck %s
4+
; RUN: llvm-uselistorder < %s -preserve-bc-use-list-order -num-shuffles=5
45

56
; CHECK: FUNCTION_BLOCK
67
; CHECK: INST_BINOP {{.*}}op0=1 op1=1

test/Bitcode/global-variables.3.2.ll

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
; RUN: llvm-dis < %s.bc| FileCheck %s
2+
; RUN: llvm-uselistorder < %s.bc -preserve-bc-use-list-order -num-shuffles=5
23

34
; global-variables.3.2.ll.bc was generated by passing this file to llvm-as-3.2.
45
; The test checks that LLVM does not silently misread global variables attributes of

test/Bitcode/inalloca.ll

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
; RUN: llvm-as < %s | llvm-dis | FileCheck %s
2+
; RUN: llvm-uselistorder < %s -preserve-bc-use-list-order -num-shuffles=5
23

34
; inalloca should roundtrip.
45

test/Bitcode/linkage-types-3.2.ll

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
; RUN: llvm-dis < %s.bc| FileCheck %s
2+
; RUN: llvm-uselistorder < %s.bc -preserve-bc-use-list-order -num-shuffles=5
23

34
; linkage-types-3.2.ll.bc was generated by passing this file to llvm-as-3.2
45
; The test checks that LLVM does not silently misread linkage types of

test/Bitcode/memInstructions.3.2.ll

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
; RUN: llvm-dis < %s.bc| FileCheck %s
2+
; RUN: llvm-uselistorder < %s.bc -preserve-bc-use-list-order -num-shuffles=5
23

34
; memOperations.3.2.ll.bc was generated by passing this file to llvm-as-3.2.
45
; The test checks that LLVM does not misread memory related instructions of

test/Bitcode/metadata.ll

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
; RUN: llvm-as < %s | llvm-dis -disable-output
2+
; RUN: llvm-uselistorder < %s -preserve-bc-use-list-order -num-shuffles=5
23

34
!llvm.foo = !{!0}
45
!0 = metadata !{i32 42}

test/Bitcode/ptest-new.ll

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
; RUN: llvm-as < %s | llvm-dis | FileCheck %s
2+
; RUN: llvm-uselistorder < %s -preserve-bc-use-list-order -num-shuffles=5
23

34
define i32 @foo(<2 x i64> %bar) nounwind {
45
entry:

test/Bitcode/ptest-old.ll

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
; RUN: llvm-as < %s | llvm-dis | FileCheck %s
2+
; RUN: llvm-uselistorder < %s -preserve-bc-use-list-order -num-shuffles=5
23

34
define i32 @foo(<4 x float> %bar) nounwind {
45
entry:

test/Bitcode/select.ll

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
; RUN: llvm-as < %s | llvm-dis | FileCheck %s
2+
; RUN: llvm-uselistorder < %s -preserve-bc-use-list-order -num-shuffles=5
23

34
define <2 x i32> @main() {
45
ret <2 x i32> select (<2 x i1> <i1 false, i1 undef>, <2 x i32> zeroinitializer, <2 x i32> <i32 0, i32 undef>)

test/Bitcode/shuffle.ll

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
; RUN: llvm-as < %s | llvm-dis -disable-output
2+
; RUN: llvm-uselistorder < %s -preserve-bc-use-list-order -num-shuffles=5
23

34
; <rdar://problem/8622574>
45
; tests the bitcodereader can handle the case where the reader will initially

test/Bitcode/tailcall.ll

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
; RUN: llvm-as < %s | llvm-dis | FileCheck %s
2+
; RUN: llvm-uselistorder < %s -preserve-bc-use-list-order -num-shuffles=5
23

34
; Check that musttail and tail roundtrip.
45

test/Bitcode/terminatorInstructions.3.2.ll

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
; RUN: llvm-dis < %s.bc| FileCheck %s
2+
; RUN: llvm-uselistorder < %s.bc -preserve-bc-use-list-order -num-shuffles=5
23

34
; TerminatorOperations.3.2.ll.bc was generated by passing this file to llvm-as-3.2.
45
; The test checks that LLVM does not misread terminator instructions from

test/Bitcode/upgrade-global-ctors.ll

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
; RUN: llvm-dis < %s.bc| FileCheck %s
2+
; RUN: llvm-uselistorder < %s.bc -preserve-bc-use-list-order -num-shuffles=5
23

34
; CHECK: @llvm.global_ctors = appending global [0 x { i32, void ()*, i8* }] zeroinitializer

test/Bitcode/upgrade-loop-metadata.ll

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
; Test to make sure loop vectorizer metadata is automatically upgraded.
22
;
33
; RUN: llvm-dis < %s.bc | FileCheck %s
4+
; RUN: llvm-uselistorder < %s.bc -preserve-bc-use-list-order -num-shuffles=5
45

56
define void @_Z28loop_with_vectorize_metadatav() {
67
entry:

test/Bitcode/upgrade-tbaa.ll

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
; RUN: llvm-as < %s | llvm-dis | FileCheck %s
2+
; RUN: llvm-uselistorder < %s -preserve-bc-use-list-order -num-shuffles=5
23

34
; Function Attrs: nounwind
45
define void @_Z4testPiPf(i32* nocapture %pI, float* nocapture %pF) #0 {

test/Bitcode/vectorInstructions.3.2.ll

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
; RUN: llvm-dis < %s.bc| FileCheck %s
2+
; RUN: llvm-uselistorder < %s.bc -preserve-bc-use-list-order -num-shuffles=5
23

34
; vectorOperations.3.2.ll.bc was generated by passing this file to llvm-as-3.2.
45
; The test checks that LLVM does not misread vector operations of

test/Bitcode/visibility-styles.3.2.ll

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
; RUN: llvm-dis < %s.bc| FileCheck %s
2+
; RUN: llvm-uselistorder < %s.bc -preserve-bc-use-list-order -num-shuffles=5
23

34
; visibility-styles.3.2.ll.bc was generated by passing this file to llvm-as-3.2.
45
; The test checks that LLVM does not silently misread visibility styles of

test/Bitcode/weak-cmpxchg-upgrade.ll

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
; RUN: llvm-dis < %s.bc | FileCheck %s
2+
; RUN: llvm-uselistorder < %s.bc -preserve-bc-use-list-order -num-shuffles=5
23

34
; cmpxchg-upgrade.ll.bc was produced by running a version of llvm-as from just
45
; before the IR change on this file.

0 commit comments

Comments
 (0)