Skip to content

Commit

Permalink
the classic hello world
Browse files Browse the repository at this point in the history
  • Loading branch information
Zdancewic authored and Chobbes committed Apr 18, 2023
1 parent 3516ceb commit 6886c12
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 0 deletions.
35 changes: 35 additions & 0 deletions tests/io/puts_test2.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
; ModuleID = 'puts1.c'
source_filename = "puts1.c"
target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-apple-macosx13.0.0"

@.str = private unnamed_addr constant [4 x i8] c"abc\00", align 1
@.str.1 = private unnamed_addr constant [4 x i8] c"def\00", align 1

; Function Attrs: noinline nounwind optnone ssp uwtable
define i32 @main(i32 noundef %0, i8** noundef %1) #0 {
%3 = alloca i32, align 4
%4 = alloca i32, align 4
%5 = alloca i8**, align 8
store i32 0, i32* %3, align 4
store i32 %0, i32* %4, align 4
store i8** %1, i8*** %5, align 8
%6 = call i32 @puts(i8* noundef getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @puts(i8* noundef getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
ret i32 0
}

declare i32 @puts(i8* noundef) #1

attributes #0 = { noinline nounwind optnone ssp uwtable "darwin-stkchk-strong-link" "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "probe-stack"="___chkstk_darwin" "stack-protector-buffer-size"="8" "target-cpu"="penryn" "target-features"="+cx16,+cx8,+fxsr,+mmx,+sahf,+sse,+sse2,+sse3,+sse4.1,+ssse3,+x87" "tune-cpu"="generic" }
attributes #1 = { "darwin-stkchk-strong-link" "frame-pointer"="all" "no-trapping-math"="true" "probe-stack"="___chkstk_darwin" "stack-protector-buffer-size"="8" "target-cpu"="penryn" "target-features"="+cx16,+cx8,+fxsr,+mmx,+sahf,+sse,+sse2,+sse3,+sse4.1,+ssse3,+x87" "tune-cpu"="generic" }

!llvm.module.flags = !{!0, !1, !2, !3, !4}
!llvm.ident = !{!5}

!0 = !{i32 2, !"SDK Version", [2 x i32] [i32 13, i32 3]}
!1 = !{i32 1, !"wchar_size", i32 4}
!2 = !{i32 7, !"PIC Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{i32 7, !"frame-pointer", i32 2}
!5 = !{!"Apple clang version 14.0.3 (clang-1403.0.22.14.1)"}
34 changes: 34 additions & 0 deletions tests/io/puts_test3.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
declare i32 @puts(i8* %str)

define i32 @main(i32 %argc, i8** %argv) {
%str = alloca [13 x i8]
%p0 = getelementptr [13 x i8], [13 x i8]* %str, i64 0, i64 0
store i8 72, i8* %p0
%p1 = getelementptr [13 x i8], [13 x i8]* %str, i64 0, i64 1
store i8 101, i8* %p1
%p2 = getelementptr [13 x i8], [13 x i8]* %str, i64 0, i64 2
store i8 108, i8* %p2
%p3 = getelementptr [13 x i8], [13 x i8]* %str, i64 0, i64 3
store i8 108, i8* %p3
%p4 = getelementptr [13 x i8], [13 x i8]* %str, i64 0, i64 4
store i8 111, i8* %p4
%p5 = getelementptr [13 x i8], [13 x i8]* %str, i64 0, i64 5
store i8 32, i8* %p5
%p6 = getelementptr [13 x i8], [13 x i8]* %str, i64 0, i64 6
store i8 119, i8* %p6
%p7 = getelementptr [13 x i8], [13 x i8]* %str, i64 0, i64 7
store i8 111, i8* %p7
%p8 = getelementptr [13 x i8], [13 x i8]* %str, i64 0, i64 8
store i8 114, i8* %p8
%p9 = getelementptr [13 x i8], [13 x i8]* %str, i64 0, i64 9
store i8 108, i8* %p9
%p10 = getelementptr [13 x i8], [13 x i8]* %str, i64 0, i64 10
store i8 100, i8* %p10
%p11 = getelementptr [13 x i8], [13 x i8]* %str, i64 0, i64 11
store i8 33, i8* %p11
%p12 = getelementptr [13 x i8], [13 x i8]* %str, i64 0, i64 12
store i8 0, i8* %p12
%p = bitcast [13 x i8]* %str to i8*
%ans = call i32 @puts(i8* %p)
ret i32 %ans
}

0 comments on commit 6886c12

Please sign in to comment.