[LLVMdev] trouble with getelementptr
Zalunin Pavel
wr4bbit at gmail.com
Sat Jan 5 16:09:49 PST 2008
Hello,
I have next code:
;begin
; ModuleID = 'sample.lz'
@.str1 = internal constant [20 x i8] c"\22hello, cruel
world\22" ; <[20 x i8]*> [#uses=1]
@.str4 = internal constant [9 x i8] c"\22hello, \22" ; <[9 x
i8]*> [#uses=1]
@.str7 = internal constant [7 x i8] c"\22heya!\22" ; <[7 x
i8]*> [#uses=1]
declare i32 @puts(i8*)
declare i8 @strcat(i8*, i8*)
define i32 @main() {
mainBlock:
%tmp2 = getelementptr [20 x i8]* @.str1, i64 0, i64 0 ;
<i8*> [#uses=1]
%tmp3 = call i32 @puts( i8* %tmp2 ) ; <i32> [#uses=0]
%tmp5 = getelementptr [9 x i8]* @.str4, i64 0, i64 0 ;
<i8*> [#uses=1]
%tmp6 = call i32 @puts( i8* %tmp5 ) ; <i32> [#uses=0]
%tmp8 = getelementptr [7 x i8]* @.str7, i64 0, i64 0 ;
<i8*> [#uses=1]
%tmp9 = call i32 @puts( i8* %tmp8 ) ; <i32> [#uses=0]
ret i32 0
}
;end
llvm-as test.ll -o test.ll.bc
llc test.ll.bc -o test.ll.s
gcc test.ll.s -o test.ll.native
After running a see next:
whiter4bbit at LiZa /home/whiter4bbit/programming/study/yapis/liza $
./test.ll.native
"hello, cruel world""hello, ""heya!"
"hello, ""heya!"
"heya!"
It isn't a target result:) target is:
whiter4bbit at LiZa /home/whiter4bbit/programming/study/yapis/liza $
./test.ll.native
"hello, cruel world"
"hello, "
"heya!"
what is the trouble here?
I think about freeing memory after using getelementptr, is it right?(and if
it right can anybody answer 'how?')
Help me please...
Best regards, Zalunin Pavel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20080106/05015829/attachment.html>
More information about the llvm-dev
mailing list