summaryrefslogtreecommitdiffstats
path: root/clang/test/CodeGen/debug-info-block-vars.c
diff options
context:
space:
mode:
authorAdrian Prantl <aprantl@apple.com>2017-10-26 20:08:52 +0000
committerAdrian Prantl <aprantl@apple.com>2017-10-26 20:08:52 +0000
commit356347b58d18b5b7984fbc5487532f49c7e98237 (patch)
treeb563889edd0d291d255052af0d797611889742a8 /clang/test/CodeGen/debug-info-block-vars.c
parent86cf0856ae78c1d4e31a19b7fa0ab957379bee03 (diff)
downloadbcm5719-llvm-356347b58d18b5b7984fbc5487532f49c7e98237.tar.gz
bcm5719-llvm-356347b58d18b5b7984fbc5487532f49c7e98237.zip
Simplify codegen and debug info generation for block context parameters.
The exisiting code goes out of its way to put block parameters into an alloca only at -O0, and then describes the funciton argument with a dbg.declare, which is undocumented in the LLVM-CFE contract and does not actually behave as intended after LLVM r642022. This patch just generates the alloca unconditionally, the mem2reg pass will eliminate it at -O1 and up anyway and points the dbg.declare to the alloca as intended (which mem2reg will then correctly rewrite into a dbg.value). This reapplies r316684 with some dead code removed. rdar://problem/35043980 Differential Revision: https://reviews.llvm.org/D39305 llvm-svn: 316689
Diffstat (limited to 'clang/test/CodeGen/debug-info-block-vars.c')
-rw-r--r--clang/test/CodeGen/debug-info-block-vars.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/clang/test/CodeGen/debug-info-block-vars.c b/clang/test/CodeGen/debug-info-block-vars.c
new file mode 100644
index 00000000000..e0bb61e5e85
--- /dev/null
+++ b/clang/test/CodeGen/debug-info-block-vars.c
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -x c -fblocks -debug-info-kind=standalone -emit-llvm -O0 \
+// RUN: -triple x86_64-apple-darwin -o - %s | FileCheck %s
+// RUN: %clang_cc1 -x c -fblocks -debug-info-kind=standalone -emit-llvm -O1 \
+// RUN: -triple x86_64-apple-darwin -o - %s \
+// RUN: | FileCheck --check-prefix=CHECK-OPT %s
+
+// CHECK: define internal void @__f_block_invoke(i8* %.block_descriptor)
+// CHECK: %.block_descriptor.addr = alloca i8*, align 8
+// CHECK: %block.addr = alloca <{ i8*, i32, i32, i8*, %struct.__block_descriptor* }>*, align 8
+// CHECK: store i8* %.block_descriptor, i8** %.block_descriptor.addr, align 8
+// CHECK: call void @llvm.dbg.declare(metadata i8** %.block_descriptor.addr,
+// CHECK-SAME: metadata !DIExpression())
+// CHECK-OPT-NOT: alloca
+// CHECK-OPT: call void @llvm.dbg.value(metadata i8* %.block_descriptor,
+// CHECK-OPT-SAME: metadata !DIExpression())
+void f() {
+ a(^{
+ b();
+ });
+}
OpenPOWER on IntegriCloud