llvm-project/clang/test/CodeGen/debug-info-block-vars.c
Adrian Prantl 356347b58d 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
2017-10-26 20:08:52 +00:00

21 lines
958 B
C

// 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();
});
}