llvm/test/Bitcode/use-list-order.ll
Duncan P. N. Exon Smith bd24fe8c7e Bitcode: Serialize (and recover) use-list order
Predict and serialize use-list order in bitcode.  This makes the option
`-preserve-bc-use-list-order` work *most* of the time, but this is still
experimental.

  - Builds a full value-table up front in the writer, sets up a list of
    use-list orders to write out, and discards the table.  This is a
    simpler first step than determining the order from the various
    overlapping IDs of values on-the-fly.

  - The shuffles stored in the use-list order list have an unnecessarily
    large memory footprint.

  - `blockaddress` expressions cause functions to be materialized
    out-of-order.  For now I've ignored this problem, so use-list orders
    will be wrong for constants used by functions that have block
    addresses taken.  There are a couple of ways to fix this, but I
    don't have a concrete plan yet.

  - When materializing functions lazily, the use-lists for constants
    will not be correct.  This use case is out of scope: what should the
    use-list order be, if it's incomplete?

This is part of PR5680.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@214125 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-28 21:19:41 +00:00

83 lines
1.3 KiB
LLVM

; RUN: llvm-uselistorder < %s -preserve-bc-use-list-order
@a = global [4 x i1] [i1 0, i1 1, i1 0, i1 1]
@b = alias i1* getelementptr ([4 x i1]* @a, i64 0, i64 2)
define i64 @f(i64 %f) {
entry:
%sum = add i64 %f, 0
ret i64 %sum
}
define i64 @g(i64 %g) {
entry:
%sum = add i64 %g, 0
ret i64 %sum
}
define i64 @h(i64 %h) {
entry:
%sum = add i64 %h, 0
ret i64 %sum
}
define i64 @i(i64 %i) {
entry:
%sum = add i64 %i, 1
ret i64 %sum
}
define i64 @j(i64 %j) {
entry:
%sum = add i64 %j, 1
ret i64 %sum
}
define i64 @k(i64 %k) {
entry:
%sum = add i64 %k, 1
ret i64 %sum
}
define i64 @l(i64 %l) {
entry:
%sum = add i64 %l, 1
ret i64 %sum
}
define i1 @loadb() {
entry:
%b = load i1* @b
ret i1 %b
}
define i1 @loada() {
entry:
%a = load i1* getelementptr ([4 x i1]* @a, i64 0, i64 2)
ret i1 %a
}
define i32 @f32(i32 %a, i32 %b, i32 %c, i32 %d) {
entry:
br label %first
second:
%eh = mul i32 %e, %h
%sum = add i32 %eh, %ef
br label %exit
exit:
%product = phi i32 [%ef, %first], [%sum, %second]
ret i32 %product
first:
%e = add i32 %a, 7
%f = add i32 %b, 7
%g = add i32 %c, 8
%h = add i32 %d, 8
%ef = mul i32 %e, %f
%gh = mul i32 %g, %h
%gotosecond = icmp slt i32 %gh, -9
br i1 %gotosecond, label %second, label %exit
}