Closed llvmbot closed 14 years ago
Done! It is bug 2283
Incidentally, many tests from the gcc testsuite fail at -O0, e.g. gcc.c-torture/20010605-1.c
This fires an assertion I have here locally that checks that CreateTemporary is not used when the gcc type has variable size. So at first glance it looks to me like this isn't really a problem with nested functions as such. Can you please open a new PR for this.
Incidentally, many tests from the gcc testsuite fail at -O0, e.g. gcc.c-torture/20010605-1.c
Actually, this looks like an unrelated bug. I've filed it as Bug 1274.
-Chris
Verified, this example doesn't use trampolines, but causes infinite recursion in the FE.
I'm still getting a segfault: /tmp/delta$ /usr/local/code/llvm/llvm-gcc4/install/bin/gcc --emit-llvm -S foo.i -fnested-functions gcc: Internal error: Segmentation fault (program cc1) Please submit a full bug report. See <URL:http://llvm.org/bugs> for instructions. /tmp/delta$ cat foo.i static void foo(void *a){ inline void foo_bar() { a += 1; } }
Nested subroutines as used in the examples in this PR are now supported. However there is no support yet for trampolines, i.e. taking the address of a nested subroutine, nor for non-local gotos. I've opened llvm/llvm-bugzilla-archive#1190 for tracking progress on trampolines. I didn't bother for non-local gotos because it's less clear that anyone is interested in that. By the way, the testcase in attachment 625 still fails to compile, because tree-nested.c goes into an infinite loop, i.e. this seems to be a gcc bug not an LLVM one.
This is dying when trying to codegen the static chain. This would be easy to add support for in llvm- gcc, but would require intrinsics to represent this and code generator work to implement these. This is all possible, but not something I have time for. I'll leave this for someone else to pick up.
As a consolation prize, I checked in a patch that causes this to be emitted:
/Users/sabre/asm.c: In function 'b': /Users/sabre/asm.c:3: sorry, unimplemented: nested functions not supported by LLVM
instead of ICE'ing.
-Chris
I'm not shocked, we don't support nested functions properly. I will see if there is something easy we can do, but we won't supported taking the address of a nested function in the near future.
-Chris
Extended Description
$ /usr/local/llvm/cfrontend/install/bin/llvm-gcc --emit-llvm -S foo.i -fnested-functions foo.i: In function ?b?: foo.i:3: internal compiler error: in lhd_set_decl_assembler_name, at langhooks.c:193 Please submit a full bug report, with preprocessed source if appropriate. See <URL:http://llvm.org/bugs> for instructions. $ cat foo.i static void a() { int foo; inline void b() { foo = -1; } b(); }