irgen: "invalid getelementptr indices"
mewmew opened this issue · 3 comments
mewmew commented
Dereference nested pointers with load instructions before using getelementptr to access retrieve pointers to elements.
This feature affects the following test cases.
- testdata/extra/irgen/array_param.c
- testdata/noisy/advanced/8queens.c
- testdata/noisy/simple/sim11.c
- testdata/quiet/semantic/s04.c
- testdata/quiet/semantic/s03.c
- testdata/quiet/semantic/s02.c
- testdata/quiet/mips/m01.c
- testdata/quiet/rtl/r05.c
Invalid getelementptr indices
testdata/extra/irgen/array_param.c
u@x1 ~/D/g/s/g/m/uc> ./compile.sh testdata/extra/irgen/array_param.c
Compiling "testdata/extra/irgen/array_param.c"
llvm-link: a.ll:5:27: error: invalid getelementptr indices
%2 = getelementptr i32*, i32** %1, i64 0, i64 3
^
testdata/noisy/advanced/8queens.c
Compiling "testdata/noisy/advanced/8queens.c"
llvm-link: a.ll:19:27: error: invalid getelementptr indices
%9 = getelementptr i32*, i32** %1, i64 0, i64 %8
^
testdata/noisy/simple/sim11.c
Compiling "testdata/noisy/simple/sim11.c"
llvm-link: a.ll:10:26: error: invalid getelementptr indices
%4 = getelementptr i8*, i8** %2, i64 0, i64 0
^
testdata/quiet/semantic/s04.c
Compiling "testdata/quiet/semantic/s04.c"
llvm-link: a.ll:5:26: error: invalid getelementptr indices
%2 = getelementptr i8*, i8** %1, i64 0, i64 0
^
testdata/quiet/semantic/s03.c
Compiling "testdata/quiet/semantic/s03.c"
llvm-link: a.ll:6:27: error: invalid getelementptr indices
%2 = getelementptr i32*, i32** %1, i64 0, i64 0
^
testdata/quiet/semantic/s02.c
Compiling "testdata/quiet/semantic/s02.c"
2016/06/19 00:56:06 (testdata/quiet/semantic/s02.c:3) error: missing return at end of non-void function "foo"
; }
^
testdata/quiet/mips/m01.c
Compiling "testdata/quiet/mips/m01.c"
2016/06/19 00:56:06 (testdata/quiet/mips/m01.c:13) error: missing return at end of non-void function "mov"
}
^
testdata/quiet/rtl/r05.c
Compiling "testdata/quiet/rtl/r05.c"
llvm-link: a.ll:6:27: error: invalid getelementptr indices
%2 = getelementptr i32*, i32** %1, i64 0, i64 5
^
mewmew commented
Hopefully fixed in commit 66b23f7 :) Re-open this issue if any further relevant issues are identified.
mewmew commented
Re-open the issue as it was closed prematurely. The following test case is still failing.
irgen_test.go:321: "../testdata/extra/irgen/issue_73_pointer_pointer_ref.c": module mismatch; expected `define void @f(i32* %x) {
; <label>:0
%1 = alloca i32*
store i32* %x, i32** %1
%2 = load i32*, i32** %1
ret void
}
`, got `define void @f(i32* %x) {
; <label>:0
%1 = alloca i32*
store i32* %x, i32** %1
ret void
}
`