From 356347b58d18b5b7984fbc5487532f49c7e98237 Mon Sep 17 00:00:00 2001 From: Adrian Prantl Date: Thu, 26 Oct 2017 20:08:52 +0000 Subject: 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 --- clang/test/CodeGen/debug-info-block-vars.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 clang/test/CodeGen/debug-info-block-vars.c (limited to 'clang/test/CodeGen/debug-info-block-vars.c') 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(); + }); +} -- cgit v1.2.3