2 ;; From: test/Programs/External/SPEC/CINT2000/254.gap.llvm.bc
3 ;; Function: int %OpenOutput(sbyte* %filename.1)
5 ;; Error: A sequence of GEPs is folded incorrectly by llc during selection
6 ;; causing an assertion about a dynamic casting error.
7 ;; This code sequence was produced (correctly) by preselection
8 ;; from a nested pair of ConstantExpr getelementptrs.
9 ;; The code below is the output of preselection.
10 ;; The original ConstantExprs are included in a comment.
12 ;; Cause: FoldGetElemChain() was inserting an extra leading 0 even though
13 ;; the first instruction in the sequence contributes no indices.
14 ;; The next instruction contributes a leading non-zero so another
15 ;; zero should not be added before it!
19 %FileType = type { int, [256 x sbyte], int, int, int, int }
20 %OutputFiles = uninitialized global [16 x %FileType]
21 %Output = internal global %FileType* null
24 implementation; Functions:
26 internal int %OpenOutput(sbyte* %filename.1) {
28 %tmp.0 = load %FileType** %Output
29 %tmp.4 = getelementptr %FileType* %tmp.0, long 1
31 ;;------ Original instruction in 254.gap.llvm.bc:
32 ;; %tmp.10 = seteq { int, [256 x sbyte], int, int, int, int }* %tmp.4, getelementptr ([16 x { int, [256 x sbyte], int, int, int, int }]* getelementptr ([16 x { int, [256 x sbyte], int, int, int, int }]* %OutputFiles, long 1), long 0, long 0)
34 ;;------ Code sequence produced by preselection phase for above instr:
35 ;; This code sequence is folded incorrectly by llc during selection
36 ;; causing an assertion about a dynamic casting error.
37 %addrOfGlobal = getelementptr [16 x %FileType]* %OutputFiles, long 0
38 %constantGEP = getelementptr [16 x %FileType]* %addrOfGlobal, long 1
39 %constantGEP = getelementptr [16 x %FileType]* %constantGEP, long 0, long 0
40 %tmp.10 = seteq %FileType* %tmp.4, %constantGEP
41 br bool %tmp.10, label %return, label %endif.0