On Sep 25, 2008, at 7:10 AM, Mark Shannon wrote:
> Hi everyone,
>
> I don't know if this is a bug or I am misunderstanding things.
> I couldn't find anything in the Bugzilla database.
>
> The following code:
>
> 1 @sp = external global i8** ; <i8***>
> 2
> 3 define void @test(i8* %x) {
> 4 entry:
> 5 load i8*** @sp ; <i8**>:1
> 6 getelementptr i8** %1, i32 1 ; <i8**>:2
> 7 store i8** %2, i8*** @sp, align 4
> 8 ret void
> 9 }
>
> causes llvm-as (version 2.3) to choke:
> llvm-as: test.ll:7,0: Reference to an invalid definition: #2 of type
> 'i8 * *'
First, note that the comments ("; ...") are completely ignored. I
assume that there was another line, that you deleted. Because of
that, line #5 actually defines %0 (not %1). Because of that, line 6
defines %1, and there is no %2.
> There are variations, such as:
>
> 1 @sp = external global i8** ; <i8***>
> 2
> 3 define void @test(i32 %X) {
> 4 entry:
> 5 load i8*** @sp ; <i8**>:1
> 6 getelementptr i8** %1, i32 -1 ; <i8**> :2
> 7 store i8** %2, i8*** @sp, align 4
> 8 inttoptr i32 %X to i8* ; <i8*> :3
> 9 store i8* %3, i8** %2, align 4
> 10 ret void
> 11}
>
> which produces
> llvm-as: test.ll:9,0: Numbered value (%2) of type 'i8 *' does not
> match expected type, 'i8 * *'
This is the same sort of thing, because you're off by one, you're
referring to the wrong value.
-Chris