[LLVMdev] Unnamed temporaries
Frits van Bommel
fvbommel at gmail.com
Fri Mar 11 03:11:45 PST 2011
On Fri, Mar 11, 2011 at 11:48 AM, Judison <judison at gmail.com> wrote:
> I hope this is the right place to ask it, sorry if I'm wrong...
It's the right place, though the IRC channel would have been good too.
> My compiler is generating this code:
>
> (line numbers included) (Please ignore the extra br label %b0 and the whole
> b0)
Sorry, but the extra branches can't be ignored since they are exactly
your problem.
> 54 define i32 @std_lang__rest() {
> 55 entry:
> 56 %ret = alloca i32 ; <i32*> int*
>
> 57 %0 = icmp eq i32 4, 5 ; <i1> boolean
>
> 58 br i1 %0, label %b0_t, label %b0_f
>
> 59 b0_t:
> 60 %1 = add i32 5, 2 ; <i32> int
>
> 61 store i32 %1, i32* %ret
> 62 br label %return
This "br label %return" ended block %b0_t and automatically started a
new one. Since you didn't provide a label, it's named %2.
>
> 63 br label %b0
> 64 b0_f:
> 65 store i32 5, i32* %ret
>
> 66 br label %return
And here block %b0_f ends, and block %3 begins.
> 67 br label %b0
>
> 68 b0:
> 69 store i32 0, i32* %ret
>
> 70 br label %return
> 71 return:
> 72 %2 = load i32* %ret ; <i32> int
Leading to %4 being the next anonymous value here, not %2.
>
> 73 ret i32 %2
> 74 }
> ...
>
> llvm-as std_lang.ll
> llvm-as: std_lang.ll:72:5: error: instruction expected to be numbered '%4'
> %2 = load i32* %ret ; <i32> int
> ^
>
> Why %4 ??? what I did wrong?
You didn't realize there were anonymous blocks in your code, I'm guessing.
More information about the llvm-dev
mailing list