[LLVMdev] Another memory fun

Zalunin Pavel wr4bbit at gmail.com
Sun Jan 6 13:20:45 PST 2008


but why this code don't work:

; ModuleID = 'sample.lz'
@.str1 = internal global [6 x i8] c"world\00"           ; <[6 x i8]*>
[#uses=1]
@.str2 = internal global [7 x i8] c"hello \00"          ; <[7 x i8]*>
[#uses=1]
@.str7 = internal global [7 x i8] c"father\00"          ; <[7 x i8]*>
[#uses=1]
@.str8 = internal global [8 x i8] c"mother \00"         ; <[8 x i8]*>
[#uses=1]

declare i32 @puts(i8*)

declare i8* @strcat(i8*, i8*)

declare i32 @strlen(i8*)

declare void @llvm.memcpy.i32(i8*, i8*, i32, i32)

define i32 @main() {
mainBlock:
        %str3 = getelementptr [7 x i8]* @.str2, i64 0, i64 0            ;
<i8*> [#uses=2]
        %str4 = getelementptr [6 x i8]* @.str1, i64 0, i64 0            ;
<i8*> [#uses=1]
        call i8* @strcat( i8* %str3, i8* %str4 )                ; <i8*>:0
[#uses=0]
        %tmp6 = call i32 @puts( i8* %str3 )             ; <i32> [#uses=0]
        %str9 = getelementptr [8 x i8]* @.str8, i64 0, i64 0            ;
<i8*> [#uses=2]
        %str10 = getelementptr [7 x i8]* @.str7, i64 0, i64 0           ;
<i8*> [#uses=1]
        call i8* @strcat( i8* %str9, i8* %str10 )               ; <i8*>:1
[#uses=0]
        %tmp12 = call i32 @puts( i8* %str9 )            ; <i32> [#uses=0]
        ret i32 0
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20080106/4353f37a/attachment.html>


More information about the llvm-dev mailing list