Created
February 3, 2015 13:59
-
-
Save robstewart57/c6be7dd6a496a8d028c7 to your computer and use it in GitHub Desktop.
simple C to LLVM
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* C code */ | |
int add(int x, int y) | |
{ | |
return (x+y); | |
} | |
int main() | |
{ | |
return (add (2,3) ); | |
} | |
/* corresponding LLVM IR for `main` from `clang` */ | |
define i32 @main() #0 { | |
entry: | |
%retval = alloca i32, align 4 | |
store i32 0, i32* %retval | |
%call = call i32 @add(i32 2, i32 3) | |
ret i32 %call | |
} | |
/* corresponding LLVM IR for `main` from `clang -O` */ | |
define i32 @main() #0 { | |
entry: | |
ret i32 5 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment