Align the W3C images on the right side, bottom of page.
[oota-llvm.git] / test / LLC / badFoldGEP.ll
1 ;; GetMemInstArgs() folded the two getElementPtr instructions together,
2 ;; producing an illegal getElementPtr.  That's because the type generated
3 ;; by the last index for the first one is a structure field, not an array
4 ;; element, and the second one indexes off that structure field.
5 ;; The code is legal but not type-safe and the two GEPs should not be folded.
6 ;; 
7 ;; This code fragment is from Spec/CINT2000/197.parser/197.parser.bc,
8 ;; file post_process.c, function build_domain().
9 ;; (Modified to replace store with load and return load value.)
10 ;; 
11
12 %Domain = type { sbyte*, int, int*, int, int, int*, %Domain* }
13 %domain_array = uninitialized global [497 x %Domain] 
14
15 implementation; Functions:
16
17 declare void %opaque([497 x %Domain]*)
18
19 int %main(int %argc, sbyte** %argv) {
20 bb0:                                    ;[#uses=0]
21         call void %opaque([497 x %Domain]* %domain_array)
22         %cann-indvar-idxcast = cast int %argc to long
23         %reg841 = getelementptr [497 x %Domain]* %domain_array, long 0, long %cann-indvar-idxcast, ubyte 3
24         %reg846 = getelementptr int* %reg841, long 1
25         %reg820 = load int* %reg846
26         ret int %reg820
27 }