mirror of
https://github.com/Gericom/teak-llvm.git
synced 2025-06-19 11:35:51 -04:00

body of global block invoke functions. This commit fixes an infinite loop in IRGen that occurs when compiling the following code: void FUNC2() { static void (^const block1)(int) = ^(int a){ if (a--) block1(a); }; } This is how IRGen gets stuck in the infinite loop: 1. GenerateBlockFunction is called to emit the body of "block1". 2. GetAddrOfGlobalBlock is called to get the address of "block1". The function calls getAddrOfGlobalBlockIfEmitted to check whether the global block has been emitted. If it hasn't been emitted, it then tries to emit the body of the block function by calling GenerateBlockFunction, which goes back to step 1. This commit prevents the inifinite loop by building the global block in GenerateBlockFunction before emitting the body of the block function. rdar://problem/34541684 Differential Revision: https://reviews.llvm.org/D38118 llvm-svn: 314029
24 lines
1.0 KiB
C
24 lines
1.0 KiB
C
// RUN: %clang_cc1 -triple i386-apple-ios -fblocks -emit-llvm -o - %s | FileCheck %s
|
|
|
|
void __assert_rtn(const char *, const char *, int, const char *)
|
|
__attribute__ (( noreturn ));
|
|
|
|
void (^mangle(void))(void) {
|
|
return ^{
|
|
void (^block)(void) = ^{
|
|
__assert_rtn(__func__, __FILE__, __LINE__, "mangle");
|
|
};
|
|
};
|
|
}
|
|
|
|
// CHECK: @__func__.__mangle_block_invoke_2 = private unnamed_addr constant [22 x i8] c"mangle_block_invoke_2\00", align 1
|
|
// CHECK: @.str{{.*}} = private unnamed_addr constant {{.*}}, align 1
|
|
// CHECK: @.str[[STR1:.*]] = private unnamed_addr constant [7 x i8] c"mangle\00", align 1
|
|
|
|
// CHECK: define internal void @__mangle_block_invoke(i8* %.block_descriptor)
|
|
|
|
// CHECK: define internal void @__mangle_block_invoke_2(i8* %.block_descriptor){{.*}}{
|
|
// CHECK: call void @__assert_rtn(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @__func__.__mangle_block_invoke_2, i32 0, i32 0), i8* getelementptr inbounds {{.*}}, i32 9, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str[[STR1]], i32 0, i32 0))
|
|
// CHECK: }
|
|
|