I'm trying to figure out the unwind primitive. I've written a program which should: 1. Recursively grow the stack until it reaches a threshold 2. Then unwind and print a message Instead what happens is: 1. Recursively grow the stack until it reaches a threshold 2. Then it dies with: Abort trap Can you point me to an example using uwind that "works" ? Thanks. Here's the code: %str_sp = internal constant [9 x sbyte] c"SP = %i\0A\00" ; <[9 x sbyte]*> [#uses=1] %str_msg = internal constant [15 x sbyte] c"Bottom'd Out!\0A\00" implementation ; Functions: declare int %printf(sbyte*, ...) internal void %stack_check() { entry: %xyzzy = alloca int ; <int*> [#uses=1] %spcheck.0 = cast int* %xyzzy to int %spcheck.1 = setlt int %spcheck.0, -1080000000 br bool %spcheck.1, label %the_return, label %endif endif: %tmp.0 = getelementptr [9 x sbyte]* %str_sp, int 0, int 0 %tmp.1 = call int (sbyte*, ...)* %printf( sbyte* %tmp.0, int* %xyzzy) call void %stack_check() br label %the_return the_return: ; ret void unwind } int %main() { entry: invoke void %stack_check() to label %normal_ret unwind label %exn_ret exn_ret: %foo.0 = getelementptr [15 x sbyte]* %str_msg, int 0, int 0 %foo.1 = call int (sbyte*, ...)* %printf(sbyte* %foo.0) br label %normal_ret normal_ret: ret int 0 }
On Tue, 19 Apr 2005, Greg Pettyjohn wrote:> I'm trying to figure out the unwind primitive. > I've written a program which should: > > 1. Recursively grow the stack until it reaches a threshold > 2. Then unwind and print a message > > Instead what happens is: > 1. Recursively grow the stack until it reaches a threshold > 2. Then it dies with: > Abort trap > > Can you point me to an example using uwind that "works" ?I have no idea if that test should work for your platform or not, but make sure you pass -enable-correct-eh-support to LLC when you compile the program. -Chris> Thanks. > > Here's the code: > > %str_sp = internal constant [9 x sbyte] c"SP = %i\0A\00" ; <[9 x sbyte]*> > [#uses=1] > %str_msg = internal constant [15 x sbyte] c"Bottom'd Out!\0A\00" > > implementation ; Functions: > > declare int %printf(sbyte*, ...) > > internal void %stack_check() { > entry: > %xyzzy = alloca int ; <int*> [#uses=1] > %spcheck.0 = cast int* %xyzzy to int > %spcheck.1 = setlt int %spcheck.0, -1080000000 > br bool %spcheck.1, label %the_return, label %endif > > endif: > %tmp.0 = getelementptr [9 x sbyte]* %str_sp, int 0, int 0 > %tmp.1 = call int (sbyte*, ...)* %printf( sbyte* %tmp.0, int* %xyzzy) > call void %stack_check() > br label %the_return > > the_return: > ; ret void > unwind > } > > int %main() { > entry: > invoke void %stack_check() > to label %normal_ret > unwind label %exn_ret > > exn_ret: > %foo.0 = getelementptr [15 x sbyte]* %str_msg, int 0, int 0 > %foo.1 = call int (sbyte*, ...)* %printf(sbyte* %foo.0) > br label %normal_ret > > normal_ret: > ret int 0 > } > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://mail.cs.uiuc.edu/mailman/listinfo/llvmdev >-Chris -- http://nondot.org/sabre/ http://llvm.cs.uiuc.edu/
Possibly Parallel Threads
- 17 commits - libswfdec/js libswfdec/swfdec_js.c libswfdec/swfdec_js_global.c libswfdec/swfdec_js.h libswfdec/swfdec_js_movie.c libswfdec/swfdec_movie.c libswfdec/swfdec_player.c libswfdec/swfdec_player_internal.h libswfdec/swfdec_root_movie.c
- Branch 'as' - 4 commits - libswfdec/Makefile.am libswfdec/swfdec_as_context.c libswfdec/swfdec_as_frame.c libswfdec/swfdec_as_interpret.c libswfdec/swfdec_as_interpret.h libswfdec/swfdec_as_object.c libswfdec/swfdec_as_types.c libswfdec/swfdec_as_types.h
- Branch 'interpreter' - 28 commits - configure.ac libswfdec/js libswfdec/swfdec_buffer.c libswfdec/swfdec_edittext_movie.c libswfdec/swfdec_js.c libswfdec/swfdec_js_global.c libswfdec/swfdec_js.h libswfdec/swfdec_js_movie.c libswfdec/swfdec_player.c
- 109 commits - configure.ac libswfdec/js libswfdec/Makefile.am libswfdec/swfdec_bits.c libswfdec/swfdec_bits.h libswfdec/swfdec_buffer.c libswfdec/swfdec_button_movie.c libswfdec/swfdec_codec_screen.c libswfdec/swfdec_color.c libswfdec/swfdec_color.h