I am interested in language creation and compiler construction, and have been working through the example here: http://gnuu.org/2009/09/18/writing-your-own-toy-compiler/. The author was using LLVM 2.6, and after making a couple changes for LLVM 2.7, I got all the code generation code to compile. When feeding the complier the test code,
int do_math( int a ) {
int x = a * 5 + 3
}
do_math( 10 )
the program works correctly until it tries to run the code, at which point it segfaults. I am in the process of building LLDB on my system, but it the meantime, anyone see an obvious seg fault in this LLVM asm?
; ModuleID = 'main'
define internal void @main() {
entry:
%0 = call i64 @do_math(i64 10) ; <i64> [#uses=0]
ret void
}
define internal i64 @do_math(i64) {
entry:
%a = alloca i64 ; <i64*> [#uses=1]
%x = alloca i64 ; <i64*> [#uses=1]
%1 = add i64 5, 3 ; <i64> [#uses=1]
%2 = load i64* %a ; <i64> [#uses=1]
%3 = mul i64 %2, %1 ; <i64> [#uses=1]
store i64 %3, i64* %x
ret void
}
The output is just:
Segmentation fault
My arch is OS X x86_64.
Thanks.