LLVM: Hello-World.c - Example
Clang & LLVM have been installed on $PATH.
clang hello-world.c -S -emit-llvm -o -
Workstation1:build genuser1$ clang hello-world.c -S -emit-llvm -o -
; ModuleID = ' hello-world.c'
source_filename = " hello-world.c"
target datalayout = " e-m:o-i64:64-f80:128-n8:16:32:64-S128"
target triple = " x86_64-apple-macosx10.13.0"
@.str = private unnamed_addr constant [13 x i8] c" Hello World\0A\00" , align 1
; Function Attrs: noinline nounwind optnone ssp uwtable
define i32 @main(i32, i8** ) # 0 {
%3 = alloca i32, align 4
%4 = alloca i8** , align 8
store i32 %0, i32* %3, align 4
store i8** %1, i8*** %4, align 8
%5 = call i32 (i8* , ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
ret i32 0
}
declare i32 @printf(i8* , ...) # 1
attributes # 0 = { noinline nounwind optnone ssp uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="penryn" "target-features"="+cx16,+cx8,+fxsr,+mmx,+sahf,+sse,+sse2,+sse3,+sse4.1,+ssse3,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
attributes # 1 = { "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="penryn" "target-features"="+cx16,+cx8,+fxsr,+mmx,+sahf,+sse,+sse2,+sse3,+sse4.1,+ssse3,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
! llvm.module.flags = ! {! 0, ! 1}
! llvm.ident = ! {! 2}
! 0 = ! {i32 1, ! " wchar_size" , i32 4}
! 1 = ! {i32 7, ! " PIC Level" , i32 2}
! 2 = ! {! " clang version 9.0.0 (tags/RELEASE_900/final)" }