llvm.org GIT mirror llvm / d28c8c8
Regression test for llc bug that was folding two getelementptrs illegally. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@3971 91177308-0d34-0410-b5e6-96231b3b80d8 Vikram S. Adve 17 years ago
2 changed file(s) with 54 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
0 ;; GetMemInstArgs() folded the two getElementPtr instructions together,
1 ;; producing an illegal getElementPtr. That's because the type generated
2 ;; by the last index for the first one is a structure field, not an array
3 ;; element, and the second one indexes off that structure field.
4 ;; The code is legal but not type-safe and the two GEPs should not be folded.
5 ;;
6 ;; This code fragment is from Spec/CINT2000/197.parser/197.parser.bc,
7 ;; file post_process.c, function build_domain().
8 ;; (Modified to replace store with load and return load value.)
9 ;;
10
11 %Domain = type { sbyte*, int, int*, int, int, int*, %Domain* }
12 %domain_array = internal uninitialized global [497 x %Domain]
13
14 implementation; Functions:
15
16 declare void %opaque([497 x %Domain]*)
17
18 int %main(int %argc, sbyte** %argv) {
19 bb0: ;[#uses=0]
20 call void %opaque([497 x %Domain]* %domain_array)
21 %cann-indvar-idxcast = cast int %argc to long
22 %reg841 = getelementptr [497 x %Domain]* %domain_array, long 0, long %cann-indvar-idxcast, ubyte 3
23 %reg846 = getelementptr int* %reg841, long 1
24 %reg820 = load int* %reg846
25 ret int %reg820
26 }
0 ;; GetMemInstArgs() folded the two getElementPtr instructions together,
1 ;; producing an illegal getElementPtr. That's because the type generated
2 ;; by the last index for the first one is a structure field, not an array
3 ;; element, and the second one indexes off that structure field.
4 ;; The code is legal but not type-safe and the two GEPs should not be folded.
5 ;;
6 ;; This code fragment is from Spec/CINT2000/197.parser/197.parser.bc,
7 ;; file post_process.c, function build_domain().
8 ;; (Modified to replace store with load and return load value.)
9 ;;
10
11 %Domain = type { sbyte*, int, int*, int, int, int*, %Domain* }
12 %domain_array = internal uninitialized global [497 x %Domain]
13
14 implementation; Functions:
15
16 declare void %opaque([497 x %Domain]*)
17
18 int %main(int %argc, sbyte** %argv) {
19 bb0: ;[#uses=0]
20 call void %opaque([497 x %Domain]* %domain_array)
21 %cann-indvar-idxcast = cast int %argc to long
22 %reg841 = getelementptr [497 x %Domain]* %domain_array, long 0, long %cann-indvar-idxcast, ubyte 3
23 %reg846 = getelementptr int* %reg841, long 1
24 %reg820 = load int* %reg846
25 ret int %reg820
26 }