r338299 - [DebugInfo][OpenCL] Generate correct block literal debug info for OpenCL
Benjamin Kramer via cfe-commits
cfe-commits at lists.llvm.org
Mon Jul 30 14:19:07 PDT 2018
On Mon, Jul 30, 2018 at 10:37 PM Scott Linder via cfe-commits <
cfe-commits at lists.llvm.org> wrote:
> Author: scott.linder
> Date: Mon Jul 30 13:31:11 2018
> New Revision: 338299
>
> URL: http://llvm.org/viewvc/llvm-project?rev=338299&view=rev
> Log:
> [DebugInfo][OpenCL] Generate correct block literal debug info for OpenCL
>
> OpenCL block literal structs have different fields which are now correctly
> identified in the debug info.
>
> Differential Revision: https://reviews.llvm.org/D49930
>
> Modified:
> cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
> cfe/trunk/test/CodeGenOpenCL/blocks.cl
>
> Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=338299&r1=338298&r2=338299&view=diff
>
> ==============================================================================
> --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Mon Jul 30 13:31:11 2018
> @@ -971,20 +971,25 @@ llvm::DIType *CGDebugInfo::CreateType(co
> auto *DescTy = DBuilder.createPointerType(EltTy, Size);
>
> FieldOffset = 0;
> - FType = CGM.getContext().getPointerType(CGM.getContext().VoidTy);
> - EltTys.push_back(CreateMemberType(Unit, FType, "__isa", &FieldOffset));
> - FType = CGM.getContext().IntTy;
> - EltTys.push_back(CreateMemberType(Unit, FType, "__flags",
> &FieldOffset));
> - EltTys.push_back(CreateMemberType(Unit, FType, "__reserved",
> &FieldOffset));
> - FType = CGM.getContext().getPointerType(Ty->getPointeeType());
> - EltTys.push_back(CreateMemberType(Unit, FType, "__FuncPtr",
> &FieldOffset));
> -
> - FType = CGM.getContext().getPointerType(CGM.getContext().VoidTy);
> - FieldSize = CGM.getContext().getTypeSize(Ty);
> - FieldAlign = CGM.getContext().getTypeAlign(Ty);
> - EltTys.push_back(DBuilder.createMemberType(
> - Unit, "__descriptor", nullptr, LineNo, FieldSize, FieldAlign,
> FieldOffset,
> - llvm::DINode::FlagZero, DescTy));
> + if (CGM.getLangOpts().OpenCL) {
> + FType = CGM.getContext().IntTy;
> + EltTys.push_back(CreateMemberType(Unit, FType, "__size",
> &FieldOffset));
> + EltTys.push_back(CreateMemberType(Unit, FType, "__align",
> &FieldOffset));
> + } else {
> + FType = CGM.getContext().getPointerType(CGM.getContext().VoidTy);
> + EltTys.push_back(CreateMemberType(Unit, FType, "__isa",
> &FieldOffset));
> + FType = CGM.getContext().IntTy;
> + EltTys.push_back(CreateMemberType(Unit, FType, "__flags",
> &FieldOffset));
> + EltTys.push_back(CreateMemberType(Unit, FType, "__reserved",
> &FieldOffset));
> + FType = CGM.getContext().getPointerType(Ty->getPointeeType());
> + EltTys.push_back(CreateMemberType(Unit, FType, "__FuncPtr",
> &FieldOffset));
> + FType = CGM.getContext().getPointerType(CGM.getContext().VoidTy);
> + FieldSize = CGM.getContext().getTypeSize(Ty);
> + FieldAlign = CGM.getContext().getTypeAlign(Ty);
> + EltTys.push_back(DBuilder.createMemberType(
> + Unit, "__descriptor", nullptr, LineNo, FieldSize, FieldAlign,
> FieldOffset,
> + llvm::DINode::FlagZero, DescTy));
> + }
>
llvm/tools/clang/lib/CodeGen/CGDebugInfo.cpp:974:7: error: variable
'FieldSize' is used uninitialized whenever 'if' condition is true
[-Werror,-Wsometimes-uninitialized]
if (CGM.getLangOpts().OpenCL) {
^~~~~~~~~~~~~~~~~~~~~~~~
llvm/tools/clang/lib/CodeGen/CGDebugInfo.cpp:994:18: note: uninitialized
use occurs here
FieldOffset += FieldSize;
^~~~~~~~~
llvm/tools/clang/lib/CodeGen/CGDebugInfo.cpp:974:3: note: remove the 'if'
if its condition is always false
if (CGM.getLangOpts().OpenCL) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
llvm/tools/clang/lib/CodeGen/CGDebugInfo.cpp:949:21: note: initialize the
variable 'FieldSize' to silence this warning
uint64_t FieldSize, FieldOffset;
^
= 0
1 error generated.
> FieldOffset += FieldSize;
> Elements = DBuilder.getOrCreateArray(EltTys);
> @@ -3847,26 +3852,35 @@ void CGDebugInfo::EmitDeclareOfBlockLite
> CGM.getDataLayout().getStructLayout(block.StructureType);
>
> SmallVector<llvm::Metadata *, 16> fields;
> - fields.push_back(createFieldType("__isa", C.VoidPtrTy, loc, AS_public,
> - blockLayout->getElementOffsetInBits(0),
> - tunit, tunit));
> - fields.push_back(createFieldType("__flags", C.IntTy, loc, AS_public,
> - blockLayout->getElementOffsetInBits(1),
> - tunit, tunit));
> - fields.push_back(createFieldType("__reserved", C.IntTy, loc, AS_public,
> - blockLayout->getElementOffsetInBits(2),
> - tunit, tunit));
> - auto *FnTy = block.getBlockExpr()->getFunctionType();
> - auto FnPtrType = CGM.getContext().getPointerType(FnTy->desugar());
> - fields.push_back(createFieldType("__FuncPtr", FnPtrType, loc, AS_public,
> - blockLayout->getElementOffsetInBits(3),
> - tunit, tunit));
> - fields.push_back(createFieldType(
> - "__descriptor",
> - C.getPointerType(block.NeedsCopyDispose
> - ? C.getBlockDescriptorExtendedType()
> - : C.getBlockDescriptorType()),
> - loc, AS_public, blockLayout->getElementOffsetInBits(4), tunit,
> tunit));
> + if (CGM.getLangOpts().OpenCL) {
> + fields.push_back(createFieldType("__size", C.IntTy, loc, AS_public,
> +
> blockLayout->getElementOffsetInBits(0),
> + tunit, tunit));
> + fields.push_back(createFieldType("__align", C.IntTy, loc, AS_public,
> +
> blockLayout->getElementOffsetInBits(1),
> + tunit, tunit));
> + } else {
> + fields.push_back(createFieldType("__isa", C.VoidPtrTy, loc, AS_public,
> +
> blockLayout->getElementOffsetInBits(0),
> + tunit, tunit));
> + fields.push_back(createFieldType("__flags", C.IntTy, loc, AS_public,
> +
> blockLayout->getElementOffsetInBits(1),
> + tunit, tunit));
> + fields.push_back(createFieldType("__reserved", C.IntTy, loc,
> AS_public,
> +
> blockLayout->getElementOffsetInBits(2),
> + tunit, tunit));
> + auto *FnTy = block.getBlockExpr()->getFunctionType();
> + auto FnPtrType = CGM.getContext().getPointerType(FnTy->desugar());
> + fields.push_back(createFieldType("__FuncPtr", FnPtrType, loc,
> AS_public,
> +
> blockLayout->getElementOffsetInBits(3),
> + tunit, tunit));
> + fields.push_back(createFieldType(
> + "__descriptor",
> + C.getPointerType(block.NeedsCopyDispose
> + ? C.getBlockDescriptorExtendedType()
> + : C.getBlockDescriptorType()),
> + loc, AS_public, blockLayout->getElementOffsetInBits(4), tunit,
> tunit));
> + }
>
> // We want to sort the captures by offset, not because DWARF
> // requires this, but because we're paranoid about debuggers.
>
> Modified: cfe/trunk/test/CodeGenOpenCL/blocks.cl
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/blocks.cl?rev=338299&r1=338298&r2=338299&view=diff
>
> ==============================================================================
> --- cfe/trunk/test/CodeGenOpenCL/blocks.cl (original)
> +++ cfe/trunk/test/CodeGenOpenCL/blocks.cl Mon Jul 30 13:31:11 2018
> @@ -1,5 +1,5 @@
> -// RUN: %clang_cc1 %s -cl-std=CL2.0 -emit-llvm -o - -O0 -triple
> spir-unknown-unknown | FileCheck -check-prefixes=COMMON,SPIR %s
> -// RUN: %clang_cc1 %s -cl-std=CL2.0 -emit-llvm -o - -O0 -triple
> amdgcn-amd-amdhsa | FileCheck -check-prefixes=COMMON,AMDGCN %s
> +// RUN: %clang_cc1 %s -cl-std=CL2.0 -emit-llvm -o - -O0
> -debug-info-kind=limited -triple spir-unknown-unknown | FileCheck
> -check-prefixes=COMMON,SPIR %s
> +// RUN: %clang_cc1 %s -cl-std=CL2.0 -emit-llvm -o - -O0
> -debug-info-kind=limited -triple amdgcn-amd-amdhsa | FileCheck
> -check-prefixes=COMMON,AMDGCN %s
>
> // COMMON: @__block_literal_global = internal addrspace(1) constant {
> i32, i32 } { i32 8, i32 4 }
> // COMMON-NOT: .str
> @@ -60,3 +60,11 @@ void foo(){
> // AMDGCN: %[[block_capture:.*]] = load i32, i32* %[[block_capture_addr]]
>
> // COMMON-NOT: define{{.*}}@__foo_block_invoke_kernel
> +
> +// COMMON: !DIDerivedType(tag: DW_TAG_member, name: "__size"
> +// COMMON: !DIDerivedType(tag: DW_TAG_member, name: "__align"
> +
> +// COMMON-NOT: !DIDerivedType(tag: DW_TAG_member, name: "__isa"
> +// COMMON-NOT: !DIDerivedType(tag: DW_TAG_member, name: "__flags"
> +// COMMON-NOT: !DIDerivedType(tag: DW_TAG_member, name: "__reserved"
> +// COMMON-NOT: !DIDerivedType(tag: DW_TAG_member, name: "__FuncPtr"
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180730/cd758c10/attachment-0001.html>
More information about the cfe-commits
mailing list