Commit 6d43205
committed
[CodeGen][ObjC] Build the global block structure before emitting the
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
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@314029 91177308-0d34-0410-b5e6-96231b3b80d8
(cherry picked from commit a3394c6dfe197d84e74eae9cc8b77dc4356cff54)
apple-llvm-split-commit: ab7472e733a4081d672e2ef9a8e2011d941d1347
apple-llvm-split-dir: clang/1 parent e47fec6 commit 6d43205
File tree
5 files changed
+32
-17
lines changed- clang
- lib/CodeGen
- test
- CodeGenObjC
- CodeGen
5 files changed
+32
-17
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
714 | 714 | | |
715 | 715 | | |
716 | 716 | | |
717 | | - | |
| 717 | + | |
| 718 | + | |
718 | 719 | | |
719 | 720 | | |
720 | 721 | | |
721 | 722 | | |
722 | | - | |
| 723 | + | |
723 | 724 | | |
724 | 725 | | |
725 | 726 | | |
| |||
1074 | 1075 | | |
1075 | 1076 | | |
1076 | 1077 | | |
1077 | | - | |
1078 | 1078 | | |
1079 | 1079 | | |
1080 | | - | |
1081 | | - | |
1082 | | - | |
1083 | | - | |
| 1080 | + | |
| 1081 | + | |
| 1082 | + | |
1084 | 1083 | | |
1085 | | - | |
1086 | 1084 | | |
1087 | | - | |
| 1085 | + | |
1088 | 1086 | | |
1089 | 1087 | | |
1090 | 1088 | | |
| |||
1175 | 1173 | | |
1176 | 1174 | | |
1177 | 1175 | | |
1178 | | - | |
| 1176 | + | |
| 1177 | + | |
1179 | 1178 | | |
1180 | 1179 | | |
1181 | 1180 | | |
| |||
1224 | 1223 | | |
1225 | 1224 | | |
1226 | 1225 | | |
| 1226 | + | |
| 1227 | + | |
| 1228 | + | |
| 1229 | + | |
1227 | 1230 | | |
1228 | 1231 | | |
1229 | 1232 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1565 | 1565 | | |
1566 | 1566 | | |
1567 | 1567 | | |
1568 | | - | |
| 1568 | + | |
| 1569 | + | |
1569 | 1570 | | |
1570 | 1571 | | |
1571 | 1572 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
16 | | - | |
| 15 | + | |
| 16 | + | |
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
| 21 | + | |
22 | 22 | | |
23 | 23 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
49 | 60 | | |
50 | 61 | | |
51 | 62 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
22 | | - | |
| 21 | + | |
| 22 | + | |
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | | - | |
| 27 | + | |
28 | 28 | | |
0 commit comments