[PATCH] D49930: [DebugInfo][OpenCL] Generate correct block literal debug info for OpenCL

2018-07-30 Thread Eric Christopher via Phabricator via cfe-commits
echristo added a comment.

In https://reviews.llvm.org/D49930#1181000, @scott.linder wrote:

> Sorry, I didn't see the additional comments until after I committed. I will 
> make those changes; is it OK to update this review, or should I create a new 
> one?


A new one is great. Just treat this as post commit :)

> As for choosing limited it was just what the function adding the debug info 
> checked for as a minimum; what would you generally choose instead?

I'd have just suggested plain -g for it?


Repository:
  rL LLVM

https://reviews.llvm.org/D49930



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D49930: [DebugInfo][OpenCL] Generate correct block literal debug info for OpenCL

2018-07-30 Thread Scott Linder via Phabricator via cfe-commits
scott.linder added a comment.

Sorry, I didn't see the additional comments until after I committed. I will 
make those changes; is it OK to update this review, or should I create a new 
one?

As for choosing limited it was just what the function adding the debug info 
checked for as a minimum; what would you generally choose instead?


Repository:
  rL LLVM

https://reviews.llvm.org/D49930



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D49930: [DebugInfo][OpenCL] Generate correct block literal debug info for OpenCL

2018-07-30 Thread Scott Linder via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL338299: [DebugInfo][OpenCL] Generate correct block literal 
debug info for OpenCL (authored by scott.linder, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D49930?vs=157737&id=158060#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D49930

Files:
  cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
  cfe/trunk/test/CodeGenOpenCL/blocks.cl

Index: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
===
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
@@ -971,20 +971,25 @@
   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));
+  }
 
   FieldOffset += FieldSize;
   Elements = DBuilder.getOrCreateArray(EltTys);
@@ -3847,26 +3852,35 @@
   CGM.getDataLayout().getStructLayout(block.StructureType);
 
   SmallVector 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),
+ 

[PATCH] D49930: [DebugInfo][OpenCL] Generate correct block literal debug info for OpenCL

2018-07-30 Thread Eric Christopher via Phabricator via cfe-commits
echristo added a comment.

The patch is fine, in general, couple of comments:

a) Can you refactor this so the if conditionals are just two functions? Those 
functions are big enough already.
b) I'm not quite sure why you're picking limited here, do you have an 
explanation?
c) Can you split that part out into a separate test? Additional run lines in 
the existing blocks.cl test would be fine.

Thanks!


Repository:
  rC Clang

https://reviews.llvm.org/D49930



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D49930: [DebugInfo][OpenCL] Generate correct block literal debug info for OpenCL

2018-07-30 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl accepted this revision.
yaxunl added a comment.
This revision is now accepted and ready to land.

In https://reviews.llvm.org/D49930#1180388, @scott.linder wrote:

> Thank you for taking a look @yaxunl. Should I wait for another reviewer or 
> can I commit this?


I think it is OK to land. We could have post-commit reviews if there are any 
issues.


Repository:
  rC Clang

https://reviews.llvm.org/D49930



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D49930: [DebugInfo][OpenCL] Generate correct block literal debug info for OpenCL

2018-07-30 Thread Scott Linder via Phabricator via cfe-commits
scott.linder added a comment.

Thank you for taking a look @yaxunl. Should I wait for another reviewer or can 
I commit this?


Repository:
  rC Clang

https://reviews.llvm.org/D49930



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D49930: [DebugInfo][OpenCL] Generate correct block literal debug info for OpenCL

2018-07-27 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

LGTM. Thanks.


Repository:
  rC Clang

https://reviews.llvm.org/D49930



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D49930: [DebugInfo][OpenCL] Generate correct block literal debug info for OpenCL

2018-07-27 Thread Scott Linder via Phabricator via cfe-commits
scott.linder created this revision.
scott.linder added reviewers: Anastasia, echristo.
Herald added subscribers: cfe-commits, JDevlieghere, aprantl, yaxunl.

OpenCL block literal structs have different fields which are now correctly 
identified in the debug info.


Repository:
  rC Clang

https://reviews.llvm.org/D49930

Files:
  lib/CodeGen/CGDebugInfo.cpp
  test/CodeGenOpenCL/blocks.cl

Index: test/CodeGenOpenCL/blocks.cl
===
--- test/CodeGenOpenCL/blocks.cl
+++ test/CodeGenOpenCL/blocks.cl
@@ -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 @@
 // 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"
Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -971,20 +971,25 @@
   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));
+  }
 
   FieldOffset += FieldSize;
   Elements = DBuilder.getOrCreateArray(EltTys);
@@ -3847,26 +3852,35 @@
   CGM.getDataLayout().getStructLayout(block.StructureType);
 
   SmallVector 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_publi