[PATCH] D100630: [Debug-Info][DBX] DW_TAG_rvalue_reference_type should not be generated when dwarf version is smaller than 4

2021-05-24 Thread ChenZheng via Phabricator via cfe-commits
shchenz added a comment.

Thanks for your review! @dblaikie @aprantl


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100630/new/

https://reviews.llvm.org/D100630

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


[PATCH] D100630: [Debug-Info][DBX] DW_TAG_rvalue_reference_type should not be generated when dwarf version is smaller than 4

2021-05-24 Thread ChenZheng via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG99d45ed22fd9: [Debug-Info] handle 
DW_TAG_rvalue_reference_type at strict DWARF. (authored by shchenz).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100630/new/

https://reviews.llvm.org/D100630

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/CodeGenCXX/debug-info-rvalue-ref.cpp


Index: clang/test/CodeGenCXX/debug-info-rvalue-ref.cpp
===
--- clang/test/CodeGenCXX/debug-info-rvalue-ref.cpp
+++ clang/test/CodeGenCXX/debug-info-rvalue-ref.cpp
@@ -1,4 +1,8 @@
 // RUN: %clang_cc1 -std=c++11 -emit-llvm -debug-info-kind=limited -triple 
x86_64-apple-darwin %s -o - | FileCheck %s
+// RUN: %clang_cc1 -std=c++11 -dwarf-version=4 -gstrict-dwarf -emit-llvm 
-debug-info-kind=limited \
+// RUN:   -triple x86_64-apple-darwin %s -o - | FileCheck %s
+// RUN: %clang_cc1 -std=c++11 -dwarf-version=3 -gstrict-dwarf -emit-llvm 
-debug-info-kind=limited \
+// RUN:  -triple x86_64-apple-darwin %s -o - | FileCheck %s 
--check-prefix=NORVALUE
 
 extern "C" {
 extern int printf(const char * format, ...);
@@ -10,3 +14,4 @@
 
 // CHECK: !DIDerivedType(tag: DW_TAG_rvalue_reference_type, baseType: 
![[INT:[0-9]+]], size: 64)
 // CHECK: ![[INT]] = !DIBasicType(name: "int"
+// NORVALUE: !DIDerivedType(tag: DW_TAG_reference_type, baseType: 
![[INT:[0-9]+]], size: 64)
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -2989,8 +2989,13 @@
 
 llvm::DIType *CGDebugInfo::CreateType(const RValueReferenceType *Ty,
   llvm::DIFile *Unit) {
-  return CreatePointerLikeType(llvm::dwarf::DW_TAG_rvalue_reference_type, Ty,
-   Ty->getPointeeType(), Unit);
+  llvm::dwarf::Tag Tag = llvm::dwarf::DW_TAG_rvalue_reference_type;
+  // DW_TAG_rvalue_reference_type was introduced in DWARF 4.
+  if (CGM.getCodeGenOpts().DebugStrictDwarf &&
+  CGM.getCodeGenOpts().DwarfVersion < 4)
+Tag = llvm::dwarf::DW_TAG_reference_type;
+
+  return CreatePointerLikeType(Tag, Ty, Ty->getPointeeType(), Unit);
 }
 
 llvm::DIType *CGDebugInfo::CreateType(const MemberPointerType *Ty,


Index: clang/test/CodeGenCXX/debug-info-rvalue-ref.cpp
===
--- clang/test/CodeGenCXX/debug-info-rvalue-ref.cpp
+++ clang/test/CodeGenCXX/debug-info-rvalue-ref.cpp
@@ -1,4 +1,8 @@
 // RUN: %clang_cc1 -std=c++11 -emit-llvm -debug-info-kind=limited -triple x86_64-apple-darwin %s -o - | FileCheck %s
+// RUN: %clang_cc1 -std=c++11 -dwarf-version=4 -gstrict-dwarf -emit-llvm -debug-info-kind=limited \
+// RUN:   -triple x86_64-apple-darwin %s -o - | FileCheck %s
+// RUN: %clang_cc1 -std=c++11 -dwarf-version=3 -gstrict-dwarf -emit-llvm -debug-info-kind=limited \
+// RUN:  -triple x86_64-apple-darwin %s -o - | FileCheck %s --check-prefix=NORVALUE
 
 extern "C" {
 extern int printf(const char * format, ...);
@@ -10,3 +14,4 @@
 
 // CHECK: !DIDerivedType(tag: DW_TAG_rvalue_reference_type, baseType: ![[INT:[0-9]+]], size: 64)
 // CHECK: ![[INT]] = !DIBasicType(name: "int"
+// NORVALUE: !DIDerivedType(tag: DW_TAG_reference_type, baseType: ![[INT:[0-9]+]], size: 64)
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -2989,8 +2989,13 @@
 
 llvm::DIType *CGDebugInfo::CreateType(const RValueReferenceType *Ty,
   llvm::DIFile *Unit) {
-  return CreatePointerLikeType(llvm::dwarf::DW_TAG_rvalue_reference_type, Ty,
-   Ty->getPointeeType(), Unit);
+  llvm::dwarf::Tag Tag = llvm::dwarf::DW_TAG_rvalue_reference_type;
+  // DW_TAG_rvalue_reference_type was introduced in DWARF 4.
+  if (CGM.getCodeGenOpts().DebugStrictDwarf &&
+  CGM.getCodeGenOpts().DwarfVersion < 4)
+Tag = llvm::dwarf::DW_TAG_reference_type;
+
+  return CreatePointerLikeType(Tag, Ty, Ty->getPointeeType(), Unit);
 }
 
 llvm::DIType *CGDebugInfo::CreateType(const MemberPointerType *Ty,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D100630: [Debug-Info][DBX] DW_TAG_rvalue_reference_type should not be generated when dwarf version is smaller than 4

2021-05-22 Thread David Blaikie via Phabricator via cfe-commits
dblaikie accepted this revision.
dblaikie added a comment.
This revision is now accepted and ready to land.

In D100630#2775207 , @aprantl wrote:

> If gracefully lowering rvalue references to references needs knowledge about 
> the Clang typesystem (or depends on LLVM IR type uniquing to be efficient, as 
> @dblaikie points out) then we should do it in the Clang frontend. As much as 
> we can we should avoid encoding debug info format specific knowledge in the 
> Clang frontend, but that's not always possible. I'm fine with taking this 
> patch.

Fair enough then - thanks for chiming in!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100630/new/

https://reviews.llvm.org/D100630

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


[PATCH] D100630: [Debug-Info][DBX] DW_TAG_rvalue_reference_type should not be generated when dwarf version is smaller than 4

2021-05-22 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl added a comment.

If gracefully lowering rvalue references to references needs knowledge about 
the Clang typesystem (or depends on LLVM IR type uniquing to be efficient, as 
@dblaikie points out) then we should do it in the Clang frontend. As much as we 
can we should avoid encoding debug info format specific knowledge in the Clang 
frontend, but that's not always possible. I'm fine with taking this patch.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100630/new/

https://reviews.llvm.org/D100630

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


[PATCH] D100630: [Debug-Info][DBX] DW_TAG_rvalue_reference_type should not be generated when dwarf version is smaller than 4

2021-05-21 Thread ChenZheng via Phabricator via cfe-commits
shchenz requested review of this revision.
shchenz added a comment.

OK, thanks David @dblaikie .

Ping for your comments, we need some discussion here to decide we should fix 
this in FE or BE. See more in https://reviews.llvm.org/D100630#2762354

@aprantl @probinson and other reviewers ^- ^


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100630/new/

https://reviews.llvm.org/D100630

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


[PATCH] D100630: [Debug-Info][DBX] DW_TAG_rvalue_reference_type should not be generated when dwarf version is smaller than 4

2021-05-21 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

I'd still like to hear from some of the other folks mentioned previously.

(though there is precedent for debug info modes being frontend, like -gmlt, etc 
- so it's not totally novel/to be avoided, but I'd like the discussion first)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100630/new/

https://reviews.llvm.org/D100630

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


[PATCH] D100630: [Debug-Info][DBX] DW_TAG_rvalue_reference_type should not be generated when dwarf version is smaller than 4

2021-05-20 Thread ChenZheng via Phabricator via cfe-commits
shchenz added a comment.

@dblaikie Hi David, should we change to use the FE solution? Maybe we should 
fix the issue where it happens? We should not let the FE generate the un-strict 
dwarf tag in FE and then fix it in the BE. I have changed this patch to fix 
this strict DWARF issue in FE. What do you think? Thanks


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100630/new/

https://reviews.llvm.org/D100630

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


[PATCH] D100630: [Debug-Info][DBX] DW_TAG_rvalue_reference_type should not be generated when dwarf version is smaller than 4

2021-05-20 Thread ChenZheng via Phabricator via cfe-commits
shchenz updated this revision to Diff 346680.
shchenz added a comment.

1: use the solution in the FE


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100630/new/

https://reviews.llvm.org/D100630

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/CodeGenCXX/debug-info-rvalue-ref.cpp


Index: clang/test/CodeGenCXX/debug-info-rvalue-ref.cpp
===
--- clang/test/CodeGenCXX/debug-info-rvalue-ref.cpp
+++ clang/test/CodeGenCXX/debug-info-rvalue-ref.cpp
@@ -1,4 +1,8 @@
 // RUN: %clang_cc1 -std=c++11 -emit-llvm -debug-info-kind=limited -triple 
x86_64-apple-darwin %s -o - | FileCheck %s
+// RUN: %clang_cc1 -std=c++11 -dwarf-version=4 -gstrict-dwarf -emit-llvm 
-debug-info-kind=limited \
+// RUN:   -triple x86_64-apple-darwin %s -o - | FileCheck %s
+// RUN: %clang_cc1 -std=c++11 -dwarf-version=3 -gstrict-dwarf -emit-llvm 
-debug-info-kind=limited \
+// RUN:  -triple x86_64-apple-darwin %s -o - | FileCheck %s 
--check-prefix=NORVALUE
 
 extern "C" {
 extern int printf(const char * format, ...);
@@ -10,3 +14,4 @@
 
 // CHECK: !DIDerivedType(tag: DW_TAG_rvalue_reference_type, baseType: 
![[INT:[0-9]+]], size: 64)
 // CHECK: ![[INT]] = !DIBasicType(name: "int"
+// NORVALUE: !DIDerivedType(tag: DW_TAG_reference_type, baseType: 
![[INT:[0-9]+]], size: 64)
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -2989,8 +2989,13 @@
 
 llvm::DIType *CGDebugInfo::CreateType(const RValueReferenceType *Ty,
   llvm::DIFile *Unit) {
-  return CreatePointerLikeType(llvm::dwarf::DW_TAG_rvalue_reference_type, Ty,
-   Ty->getPointeeType(), Unit);
+  llvm::dwarf::Tag Tag = llvm::dwarf::DW_TAG_rvalue_reference_type;
+  // DW_TAG_rvalue_reference_type was introduced in DWARF 4.
+  if (CGM.getCodeGenOpts().DebugStrictDwarf &&
+  CGM.getCodeGenOpts().DwarfVersion < 4)
+Tag = llvm::dwarf::DW_TAG_reference_type;
+
+  return CreatePointerLikeType(Tag, Ty, Ty->getPointeeType(), Unit);
 }
 
 llvm::DIType *CGDebugInfo::CreateType(const MemberPointerType *Ty,


Index: clang/test/CodeGenCXX/debug-info-rvalue-ref.cpp
===
--- clang/test/CodeGenCXX/debug-info-rvalue-ref.cpp
+++ clang/test/CodeGenCXX/debug-info-rvalue-ref.cpp
@@ -1,4 +1,8 @@
 // RUN: %clang_cc1 -std=c++11 -emit-llvm -debug-info-kind=limited -triple x86_64-apple-darwin %s -o - | FileCheck %s
+// RUN: %clang_cc1 -std=c++11 -dwarf-version=4 -gstrict-dwarf -emit-llvm -debug-info-kind=limited \
+// RUN:   -triple x86_64-apple-darwin %s -o - | FileCheck %s
+// RUN: %clang_cc1 -std=c++11 -dwarf-version=3 -gstrict-dwarf -emit-llvm -debug-info-kind=limited \
+// RUN:  -triple x86_64-apple-darwin %s -o - | FileCheck %s --check-prefix=NORVALUE
 
 extern "C" {
 extern int printf(const char * format, ...);
@@ -10,3 +14,4 @@
 
 // CHECK: !DIDerivedType(tag: DW_TAG_rvalue_reference_type, baseType: ![[INT:[0-9]+]], size: 64)
 // CHECK: ![[INT]] = !DIBasicType(name: "int"
+// NORVALUE: !DIDerivedType(tag: DW_TAG_reference_type, baseType: ![[INT:[0-9]+]], size: 64)
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -2989,8 +2989,13 @@
 
 llvm::DIType *CGDebugInfo::CreateType(const RValueReferenceType *Ty,
   llvm::DIFile *Unit) {
-  return CreatePointerLikeType(llvm::dwarf::DW_TAG_rvalue_reference_type, Ty,
-   Ty->getPointeeType(), Unit);
+  llvm::dwarf::Tag Tag = llvm::dwarf::DW_TAG_rvalue_reference_type;
+  // DW_TAG_rvalue_reference_type was introduced in DWARF 4.
+  if (CGM.getCodeGenOpts().DebugStrictDwarf &&
+  CGM.getCodeGenOpts().DwarfVersion < 4)
+Tag = llvm::dwarf::DW_TAG_reference_type;
+
+  return CreatePointerLikeType(Tag, Ty, Ty->getPointeeType(), Unit);
 }
 
 llvm::DIType *CGDebugInfo::CreateType(const MemberPointerType *Ty,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D100630: [Debug-Info][DBX] DW_TAG_rvalue_reference_type should not be generated when dwarf version is smaller than 4

2021-05-17 Thread ChenZheng via Phabricator via cfe-commits
shchenz added a comment.

In D100630#2760972 , @dblaikie wrote:

> This isn't the sort of thing I'd like to leave to a FIXME later - seems like 
> the sort of thing we shouldn't create now to fix later.
>
> @aprantl mind having a second look at this to consider the situation further?

OK. Let me summary the two solutions here:
1: fixed in the FE. See patch 
https://reviews.llvm.org/D100630?vs=on&id=338035#toc.
Advantage:

- the DWARF info for `DW_TAG_rvalue_reference_type` and `DW_TAG_reference_type` 
is cached, so we will not have redundant info;
- FE also respects strict dwarf option;

Disadvantage:

- No common interface for strict dwarf option.

2: fixed in the BE. See current patch.
Advantage:

- there is a common interface for tags adding, so we can add strict dwarf 
support in one place

Disadvantage:

- Redundant DWARF info since the final DWARF info adding in BE has no cache 
mechanism. And maybe there should be no such mechanism because after we add a 
DIE tag, we may add an attribute anywhere later, so it is hard to tell the DIE 
tag is identical when we create the DIE tag. If we optimize the redundant DWARF 
tag in the place where we add the fix, what about when we need to add another 
attribute to one of the identical DIE tags? Splitting them again into two 
different DIE tags?
- IR Metadata does not respect the strict DWARF option.

Welcome your comments? @dblaikie @aprantl @probinson and other reviewers.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100630/new/

https://reviews.llvm.org/D100630

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


[PATCH] D100630: [Debug-Info][DBX] DW_TAG_rvalue_reference_type should not be generated when dwarf version is smaller than 4

2021-05-15 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

This isn't the sort of thing I'd like to leave to a FIXME later - seems like 
the sort of thing we shouldn't create now to fix later.

@aprantl mind having a second look at this to consider the situation further?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100630/new/

https://reviews.llvm.org/D100630

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


[PATCH] D100630: [Debug-Info][DBX] DW_TAG_rvalue_reference_type should not be generated when dwarf version is smaller than 4

2021-05-14 Thread ChenZheng via Phabricator via cfe-commits
shchenz added a comment.

Thanks for your comments! @dblaikie @aprantl . I think we have an agreement 
that we should handle the strict dwarf tag in the backend.

And for duplicated tags issue, since it may need a while to fix, I have added a 
TODO in the code change and also update to test case to show the duplicated 
tags issue and also a FIXME in the case.

Do you think it is good to treat it as a FIXME for now? I currently have no 
time to fix this, but I will keep this in mind and will fix this later when I 
get a better understanding of the DWARF codes. Thanks.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100630/new/

https://reviews.llvm.org/D100630

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


[PATCH] D100630: [Debug-Info][DBX] DW_TAG_rvalue_reference_type should not be generated when dwarf version is smaller than 4

2021-05-14 Thread ChenZheng via Phabricator via cfe-commits
shchenz updated this revision to Diff 345333.
shchenz added a comment.

1: add the FIXME for the duplicated tags issue


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100630/new/

https://reviews.llvm.org/D100630

Files:
  llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
  llvm/test/DebugInfo/PowerPC/strict-dwarf-tags.ll


Index: llvm/test/DebugInfo/PowerPC/strict-dwarf-tags.ll
===
--- /dev/null
+++ llvm/test/DebugInfo/PowerPC/strict-dwarf-tags.ll
@@ -0,0 +1,67 @@
+; RUN: llc -filetype=obj -mtriple=powerpc64le-unknown-linux-gnu < %s | \
+; RUN:   llvm-dwarfdump -debug-info - | FileCheck %s
+; RUN: llc -filetype=obj -mtriple=powerpc64le-unknown-linux-gnu \
+; RUN:   -strict-dwarf=true < %s | llvm-dwarfdump -debug-info - | \
+; RUN:   FileCheck %s -check-prefix=STRICT
+
+; If not strict DWARF mode, we expect DW_TAG_rvalue_reference_type at DWARF 3.
+; If strict DWARF mode, we expect DW_TAG_reference_type at DWARF 3 as 
DW_TAG_rvalue_reference_type
+; is a DWARF 4 tag.
+
+; CHECK: DW_TAG_rvalue_reference_type
+; CHECK-NEXT: DW_AT_type {{.*}} "int"
+; CHECK: DW_TAG_base_type
+; CHECK-NOT: DW_TAG
+; CHECK: DW_AT_name {{.*}}"int"
+; CHECK: DW_TAG_reference_type
+; CHECK-NEXT: DW_AT_type {{.*}} "int"
+;
+; FIXME: remove the redundant tag DW_TAG_reference_type. We only need one tag
+; DW_TAG_reference_type with base type int.
+;
+; STRICT-NOT: DW_TAG_rvalue_reference_type
+; STRICT: DW_TAG_reference_type
+; STRICT-NEXT: DW_AT_type {{.*}} "int"
+; STRICT: DW_TAG_base_type
+; STRICT-NOT: DW_TAG
+; STRICT: DW_AT_name {{.}}"int"
+; STRICT: DW_TAG_reference_type
+; STRICT-NEXT: DW_AT_type {{.*}} "int"
+
+define void @_Z2f1OiRi(i32* dereferenceable(4) %0, i32* dereferenceable(4) %1) 
#0 !dbg !9 {
+  %3 = alloca i32*, align 8
+  %4 = alloca i32*, align 8
+  store i32* %0, i32** %3, align 8
+  call void @llvm.dbg.declare(metadata i32** %3, metadata !15, metadata 
!DIExpression()), !dbg !16
+  store i32* %1, i32** %4, align 8
+  call void @llvm.dbg.declare(metadata i32** %4, metadata !17, metadata 
!DIExpression()), !dbg !18
+  ret void, !dbg !19
+}
+
+; Function Attrs: nofree nosync nounwind readnone speculatable willreturn
+declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!3, !4, !5, !6, !7}
+!llvm.ident = !{!8}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, 
producer: "clang version 13.0.0", isOptimized: false, runtimeVersion: 0, 
emissionKind: FullDebug, enums: !2, splitDebugInlining: false, nameTableKind: 
None)
+!1 = !DIFile(filename: "1.cpp", directory: "./")
+!2 = !{}
+!3 = !{i32 7, !"Dwarf Version", i32 3}
+!4 = !{i32 2, !"Debug Info Version", i32 3}
+!5 = !{i32 1, !"wchar_size", i32 4}
+!6 = !{i32 7, !"uwtable", i32 1}
+!7 = !{i32 7, !"frame-pointer", i32 2}
+!8 = !{!"clang version 13.0.0"}
+!9 = distinct !DISubprogram(name: "f1", linkageName: "_Z2f1OiRi", scope: !1, 
file: !1, line: 1, type: !10, scopeLine: 1, flags: DIFlagPrototyped, spFlags: 
DISPFlagDefinition, unit: !0, retainedNodes: !2)
+!10 = !DISubroutineType(types: !11)
+!11 = !{null, !12, !14}
+!12 = !DIDerivedType(tag: DW_TAG_rvalue_reference_type, baseType: !13, size: 
64)
+!13 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
+!14 = !DIDerivedType(tag: DW_TAG_reference_type, baseType: !13, size: 64)
+!15 = !DILocalVariable(name: "x", arg: 1, scope: !9, file: !1, line: 1, type: 
!12)
+!16 = !DILocation(line: 1, column: 15, scope: !9)
+!17 = !DILocalVariable(name: "y", arg: 2, scope: !9, file: !1, line: 1, type: 
!14)
+!18 = !DILocation(line: 1, column: 23, scope: !9)
+!19 = !DILocation(line: 2, column: 1, scope: !9)
Index: llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
===
--- llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
+++ llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
@@ -386,6 +386,22 @@
 }
 
 DIE &DwarfUnit::createAndAddDIE(dwarf::Tag Tag, DIE &Parent, const DINode *N) {
+  // For strict DWARF mode, only generate tags available to current DWARF
+  // version.
+  if (Asm->TM.Options.DebugStrictDwarf &&
+  DD->getDwarfVersion() < dwarf::TagVersion(Tag)) {
+// See if there is any replacement for some tags.
+// TODO: the naively replacement may introduce duplicated tags. For 
example,
+// before the replacement, we have DW_TAG_rvalue_reference_type with type
+// int and DW_TAG_reference_type with type int, after the replacement, now
+// we have two DW_TAG_reference_type with type int. We should fix this.
+if (Tag == dwarf::DW_TAG_rvalue_reference_type &&
+DD->getDwarfVersion() >= 3)
+  Tag = dwarf::DW_TAG_reference_type;
+else
+  // Assertion for other cases.
+  assert(false && "Tag is generated not following strict DWARF!");
+  }
   DIE &Die = Parent.addChild(DIE::get(DIEValueAllocator, Tag));
   if (N)
 insertDIE(N, &Die);


Index: llvm/tes

[PATCH] D100630: [Debug-Info][DBX] DW_TAG_rvalue_reference_type should not be generated when dwarf version is smaller than 4

2021-05-13 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

In D100630#2755936 , @aprantl wrote:

> Doing this in the backend SGTM, assuming all of @dblaikie's comments are 
> addressed.

The complication is that if we naively lower DW_TAG_rvalue_reference to 
DW_TAG_reference, then we'll end up with two DW_TAG_reference DIEs in the 
output (one from the rvalue_reference, one from the reference) - which seems 
not ideal. I don't have /great/ ideas about how to address that, but think it 
might be worth figuring out - but doing it in the frontend is pretty simple (& 
CodeView's certainly got precedent for changing the DI metadata in the frontend 
- not sure if we have cases where we change the DI metadata based on DWARF 
version or anything like that - do you know of any?).


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100630/new/

https://reviews.llvm.org/D100630

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


[PATCH] D100630: [Debug-Info][DBX] DW_TAG_rvalue_reference_type should not be generated when dwarf version is smaller than 4

2021-05-13 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl added a comment.

Doing this in the backend SGTM, assuming all of @dblaikie's comments are 
addressed.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100630/new/

https://reviews.llvm.org/D100630

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


[PATCH] D100630: [Debug-Info][DBX] DW_TAG_rvalue_reference_type should not be generated when dwarf version is smaller than 4

2021-05-11 Thread ChenZheng via Phabricator via cfe-commits
shchenz added inline comments.



Comment at: llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp:398-399
+
+// Assertion for other cases.
+assert(true && "Tag is generated not following strict DWARF!");
+  }

dblaikie wrote:
> side note: Not sure what this assertion is for/does?
typo :) 


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100630/new/

https://reviews.llvm.org/D100630

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


[PATCH] D100630: [Debug-Info][DBX] DW_TAG_rvalue_reference_type should not be generated when dwarf version is smaller than 4

2021-05-11 Thread ChenZheng via Phabricator via cfe-commits
shchenz updated this revision to Diff 344300.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100630/new/

https://reviews.llvm.org/D100630

Files:
  llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
  llvm/test/DebugInfo/PowerPC/strict-dwarf-tags.ll


Index: llvm/test/DebugInfo/PowerPC/strict-dwarf-tags.ll
===
--- /dev/null
+++ llvm/test/DebugInfo/PowerPC/strict-dwarf-tags.ll
@@ -0,0 +1,43 @@
+; RUN: llc -filetype=obj -mtriple=powerpc64le-unknown-linux-gnu < %s | \
+; RUN:   llvm-dwarfdump -debug-info - | FileCheck %s
+; RUN: llc -filetype=obj -mtriple=powerpc64le-unknown-linux-gnu \
+; RUN:   -strict-dwarf=true < %s | llvm-dwarfdump -debug-info - | \
+; RUN:   FileCheck %s -check-prefix=STRICT
+
+; If not strict DWARF mode, we expect DW_TAG_rvalue_reference_type at DWARF 3.
+; If strict DWARF mode, we expect DW_TAG_reference_type at DWARF 3 as 
DW_TAG_rvalue_reference_type
+; is a DWARF 4 tag.
+
+; CHECK: DW_TAG_rvalue_reference_type
+; STRICT: DW_TAG_reference_type
+
+define void @_Z3fooOi(i32* dereferenceable(4) %i) !dbg !8 {
+entry:
+  call void @llvm.dbg.value(metadata i32* %i, metadata !14, metadata 
!DIExpression()), !dbg !15
+  ret void, !dbg !16
+}
+
+; Function Attrs: nofree nosync nounwind readnone speculatable willreturn
+declare void @llvm.dbg.value(metadata, metadata, metadata) #1
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!3, !4, !5, !6}
+!llvm.ident = !{!7}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, 
producer: "clang version 13.0.0", isOptimized: true, runtimeVersion: 0, 
emissionKind: FullDebug, enums: !2, splitDebugInlining: false, nameTableKind: 
None)
+!1 = !DIFile(filename: "1.cpp", directory: "./")
+!2 = !{}
+!3 = !{i32 7, !"Dwarf Version", i32 3}
+!4 = !{i32 2, !"Debug Info Version", i32 3}
+!5 = !{i32 1, !"wchar_size", i32 4}
+!6 = !{i32 7, !"uwtable", i32 1}
+!7 = !{!"clang version 13.0.0"}
+!8 = distinct !DISubprogram(name: "foo", linkageName: "_Z3fooOi", scope: !1, 
file: !1, line: 1, type: !9, scopeLine: 2, flags: DIFlagPrototyped | 
DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: 
!0, retainedNodes: !13)
+!9 = !DISubroutineType(types: !10)
+!10 = !{null, !11}
+!11 = !DIDerivedType(tag: DW_TAG_rvalue_reference_type, baseType: !12, size: 
64)
+!12 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
+!13 = !{!14}
+!14 = !DILocalVariable(name: "i", arg: 1, scope: !8, file: !1, line: 1, type: 
!11)
+!15 = !DILocation(line: 0, scope: !8)
+!16 = !DILocation(line: 3, column: 1, scope: !8)
Index: llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
===
--- llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
+++ llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
@@ -386,6 +386,18 @@
 }
 
 DIE &DwarfUnit::createAndAddDIE(dwarf::Tag Tag, DIE &Parent, const DINode *N) {
+  // For strict DWARF mode, only generate tags available to current DWARF
+  // version.
+  if (Asm->TM.Options.DebugStrictDwarf &&
+  DD->getDwarfVersion() < dwarf::TagVersion(Tag)) {
+// See if there is any replacement for some tags.
+if (Tag == dwarf::DW_TAG_rvalue_reference_type &&
+DD->getDwarfVersion() >= 3)
+  Tag = dwarf::DW_TAG_reference_type;
+else
+  // Assertion for other cases.
+  assert(false && "Tag is generated not following strict DWARF!");
+  }
   DIE &Die = Parent.addChild(DIE::get(DIEValueAllocator, Tag));
   if (N)
 insertDIE(N, &Die);


Index: llvm/test/DebugInfo/PowerPC/strict-dwarf-tags.ll
===
--- /dev/null
+++ llvm/test/DebugInfo/PowerPC/strict-dwarf-tags.ll
@@ -0,0 +1,43 @@
+; RUN: llc -filetype=obj -mtriple=powerpc64le-unknown-linux-gnu < %s | \
+; RUN:   llvm-dwarfdump -debug-info - | FileCheck %s
+; RUN: llc -filetype=obj -mtriple=powerpc64le-unknown-linux-gnu \
+; RUN:   -strict-dwarf=true < %s | llvm-dwarfdump -debug-info - | \
+; RUN:   FileCheck %s -check-prefix=STRICT
+
+; If not strict DWARF mode, we expect DW_TAG_rvalue_reference_type at DWARF 3.
+; If strict DWARF mode, we expect DW_TAG_reference_type at DWARF 3 as DW_TAG_rvalue_reference_type
+; is a DWARF 4 tag.
+
+; CHECK: DW_TAG_rvalue_reference_type
+; STRICT: DW_TAG_reference_type
+
+define void @_Z3fooOi(i32* dereferenceable(4) %i) !dbg !8 {
+entry:
+  call void @llvm.dbg.value(metadata i32* %i, metadata !14, metadata !DIExpression()), !dbg !15
+  ret void, !dbg !16
+}
+
+; Function Attrs: nofree nosync nounwind readnone speculatable willreturn
+declare void @llvm.dbg.value(metadata, metadata, metadata) #1
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!3, !4, !5, !6}
+!llvm.ident = !{!7}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 13.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, splitDebugInlining: false, nameTableKind: None)
+!1

[PATCH] D100630: [Debug-Info][DBX] DW_TAG_rvalue_reference_type should not be generated when dwarf version is smaller than 4

2021-05-11 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

In D100630#2749625 , @shchenz wrote:

> In D100630#2749594 , @dblaikie 
> wrote:
>
>> In D100630#2749550 , @shchenz 
>> wrote:
>>
>>> In D100630#2748899 , @dblaikie 
>>> wrote:
>>>
 Does this cause duplicate DW_TAG_reference_types in the output, if the 
 input IR Has both DW_TAG_reference_type and DW_TAG_rvalue_reference_types?
>>>
>>> Yes, it will cause such issue in theory. I can not cook a case that has a 
>>> DW_TAG_reference_type to a DW_TAG_rvalue_reference_types or has a 
>>> DW_TAG_rvalue_reference_types to a DW_TAG_reference_type for now. Is there 
>>> such usage that we both be rvalue-reference and lvalue-reference to a basic 
>>> type?
>>
>> Ah, I was less thinking of a case of an rvalue reference and a normal 
>> reference in the same chain - I was thinking more about two unrelated 
>> reference types.
>>
>> Try some code like:
>>
>>   void f1(int &&x, int &y) {
>>   }
>>
>> I'm guessing without this change - you get 'x's type pointing to the 
>> rvalue_reference_type, 'y's type pointing to the reference_type, and both of 
>> those pointing to the 'int' DW_TAG_basic_type.
>>
>> But with this change I'm worried you'll get two copies of the 
>> DW_TAG_reference_type - one that replaces the rvalue reference, and then the 
>> real one. Instead you should get one copy that both 'x' and 'y' refer to, I 
>> think.
>
> Hmm, yeah, indeed, a duplicated `DW_TAG_reference_type` is generated.
>
>   0x0069:   DW_TAG_reference_type
>   DW_AT_type  (0x006e "int")
>   
>   0x006e:   DW_TAG_base_type
>   DW_AT_name  ("int")
>   DW_AT_encoding  (DW_ATE_signed)
>   DW_AT_byte_size (0x04)
>   
>   0x0075:   DW_TAG_reference_type
>   DW_AT_type  (0x006e "int")
>
> I think rather than fixing the duplicated `DW_TAG_reference_type` in the 
> backend, maybe it is better to fix this strict DWARF issue in the FE like the 
> fix in the previous patch https://reviews.llvm.org/D100630?id=338755
>
> What do you think? @dblaikie

I'd still hope this issue could be addressed in the backend, but yeah - it 
might be non-trivial.

@aprantl @probinson etc - any thoughts on this?




Comment at: llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp:398-399
+
+// Assertion for other cases.
+assert(true && "Tag is generated not following strict DWARF!");
+  }

side note: Not sure what this assertion is for/does?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100630/new/

https://reviews.llvm.org/D100630

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


[PATCH] D100630: [Debug-Info][DBX] DW_TAG_rvalue_reference_type should not be generated when dwarf version is smaller than 4

2021-05-11 Thread ChenZheng via Phabricator via cfe-commits
shchenz added a comment.

In D100630#2749594 , @dblaikie wrote:

> In D100630#2749550 , @shchenz wrote:
>
>> In D100630#2748899 , @dblaikie 
>> wrote:
>>
>>> Does this cause duplicate DW_TAG_reference_types in the output, if the 
>>> input IR Has both DW_TAG_reference_type and DW_TAG_rvalue_reference_types?
>>
>> Yes, it will cause such issue in theory. I can not cook a case that has a 
>> DW_TAG_reference_type to a DW_TAG_rvalue_reference_types or has a 
>> DW_TAG_rvalue_reference_types to a DW_TAG_reference_type for now. Is there 
>> such usage that we both be rvalue-reference and lvalue-reference to a basic 
>> type?
>
> Ah, I was less thinking of a case of an rvalue reference and a normal 
> reference in the same chain - I was thinking more about two unrelated 
> reference types.
>
> Try some code like:
>
>   void f1(int &&x, int &y) {
>   }
>
> I'm guessing without this change - you get 'x's type pointing to the 
> rvalue_reference_type, 'y's type pointing to the reference_type, and both of 
> those pointing to the 'int' DW_TAG_basic_type.
>
> But with this change I'm worried you'll get two copies of the 
> DW_TAG_reference_type - one that replaces the rvalue reference, and then the 
> real one. Instead you should get one copy that both 'x' and 'y' refer to, I 
> think.

Hmm, yeah, indeed, a duplicated `DW_TAG_reference_type` is generated.

  0x0069:   DW_TAG_reference_type
  DW_AT_type  (0x006e "int")
  
  0x006e:   DW_TAG_base_type
  DW_AT_name  ("int")
  DW_AT_encoding  (DW_ATE_signed)
  DW_AT_byte_size (0x04)
  
  0x0075:   DW_TAG_reference_type
  DW_AT_type  (0x006e "int")

I think rather than fixing the duplicated `DW_TAG_reference_type` in the 
backend, maybe it is better to fix this strict DWARF issue in the FE like the 
fix in the previous patch https://reviews.llvm.org/D100630?id=338755

What do you think? @dblaikie


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100630/new/

https://reviews.llvm.org/D100630

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


[PATCH] D100630: [Debug-Info][DBX] DW_TAG_rvalue_reference_type should not be generated when dwarf version is smaller than 4

2021-05-11 Thread ChenZheng via Phabricator via cfe-commits
shchenz added a comment.

In D100630#2748899 , @dblaikie wrote:

> Does this cause duplicate DW_TAG_reference_types in the output, if the input 
> IR Has both DW_TAG_reference_type and DW_TAG_rvalue_reference_types?

Yes, it will cause such issue in theory. I can not cook a case that has a 
DW_TAG_reference_type to a DW_TAG_rvalue_reference_types or has a 
DW_TAG_rvalue_reference_types to a DW_TAG_reference_type for now. Is there such 
usage that we both be rvalue-reference and lvalue-reference to a basic type?




Comment at: llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp:391
+  // version.
+  dwarf::Tag FixedTag = (dwarf::Tag)Tag;
+  if (Asm->TM.Options.DebugStrictDwarf &&

dblaikie wrote:
> Rather than adding a cast here, perhaps the parameter type could be updated? 
> (maybe in a separate preliminary commit, though, so as not to muddy this one)
Add a new NFC patch D102207


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100630/new/

https://reviews.llvm.org/D100630

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


[PATCH] D100630: [Debug-Info][DBX] DW_TAG_rvalue_reference_type should not be generated when dwarf version is smaller than 4

2021-05-11 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

In D100630#2749550 , @shchenz wrote:

> In D100630#2748899 , @dblaikie 
> wrote:
>
>> Does this cause duplicate DW_TAG_reference_types in the output, if the input 
>> IR Has both DW_TAG_reference_type and DW_TAG_rvalue_reference_types?
>
> Yes, it will cause such issue in theory. I can not cook a case that has a 
> DW_TAG_reference_type to a DW_TAG_rvalue_reference_types or has a 
> DW_TAG_rvalue_reference_types to a DW_TAG_reference_type for now. Is there 
> such usage that we both be rvalue-reference and lvalue-reference to a basic 
> type?

Ah, I was less thinking of a case of an rvalue reference and a normal reference 
in the same chain - I was thinking more about two unrelated reference types.

Try some code like:

  void f1(int &&x, int &y) {
  }

I'm guessing without this change - you get 'x's type pointing to the 
rvalue_reference_type, 'y's type pointing to the reference_type, and both of 
those pointing to the 'int' DW_TAG_basic_type.

But with this change I'm worried you'll get two copies of the 
DW_TAG_reference_type - one that replaces the rvalue reference, and then the 
real one. Instead you should get one copy that both 'x' and 'y' refer to, I 
think.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100630/new/

https://reviews.llvm.org/D100630

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


[PATCH] D100630: [Debug-Info][DBX] DW_TAG_rvalue_reference_type should not be generated when dwarf version is smaller than 4

2021-05-11 Thread ChenZheng via Phabricator via cfe-commits
shchenz updated this revision to Diff 344269.
shchenz marked an inline comment as done.
shchenz added a comment.

1: address @dblaikie comments


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100630/new/

https://reviews.llvm.org/D100630

Files:
  llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
  llvm/test/DebugInfo/PowerPC/strict-dwarf-tags.ll


Index: llvm/test/DebugInfo/PowerPC/strict-dwarf-tags.ll
===
--- /dev/null
+++ llvm/test/DebugInfo/PowerPC/strict-dwarf-tags.ll
@@ -0,0 +1,43 @@
+; RUN: llc -filetype=obj -mtriple=powerpc64le-unknown-linux-gnu < %s | \
+; RUN:   llvm-dwarfdump -debug-info - | FileCheck %s
+; RUN: llc -filetype=obj -mtriple=powerpc64le-unknown-linux-gnu \
+; RUN:   -strict-dwarf=true < %s | llvm-dwarfdump -debug-info - | \
+; RUN:   FileCheck %s -check-prefix=STRICT
+
+; If not strict DWARF mode, we expect DW_TAG_rvalue_reference_type at DWARF 3.
+; If strict DWARF mode, we expect DW_TAG_reference_type at DWARF 3 as 
DW_TAG_rvalue_reference_type
+; is a DWARF 4 tag.
+
+; CHECK: DW_TAG_rvalue_reference_type
+; STRICT: DW_TAG_reference_type
+
+define void @_Z3fooOi(i32* dereferenceable(4) %i) !dbg !8 {
+entry:
+  call void @llvm.dbg.value(metadata i32* %i, metadata !14, metadata 
!DIExpression()), !dbg !15
+  ret void, !dbg !16
+}
+
+; Function Attrs: nofree nosync nounwind readnone speculatable willreturn
+declare void @llvm.dbg.value(metadata, metadata, metadata) #1
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!3, !4, !5, !6}
+!llvm.ident = !{!7}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, 
producer: "clang version 13.0.0", isOptimized: true, runtimeVersion: 0, 
emissionKind: FullDebug, enums: !2, splitDebugInlining: false, nameTableKind: 
None)
+!1 = !DIFile(filename: "1.cpp", directory: "./")
+!2 = !{}
+!3 = !{i32 7, !"Dwarf Version", i32 3}
+!4 = !{i32 2, !"Debug Info Version", i32 3}
+!5 = !{i32 1, !"wchar_size", i32 4}
+!6 = !{i32 7, !"uwtable", i32 1}
+!7 = !{!"clang version 13.0.0"}
+!8 = distinct !DISubprogram(name: "foo", linkageName: "_Z3fooOi", scope: !1, 
file: !1, line: 1, type: !9, scopeLine: 2, flags: DIFlagPrototyped | 
DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: 
!0, retainedNodes: !13)
+!9 = !DISubroutineType(types: !10)
+!10 = !{null, !11}
+!11 = !DIDerivedType(tag: DW_TAG_rvalue_reference_type, baseType: !12, size: 
64)
+!12 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
+!13 = !{!14}
+!14 = !DILocalVariable(name: "i", arg: 1, scope: !8, file: !1, line: 1, type: 
!11)
+!15 = !DILocation(line: 0, scope: !8)
+!16 = !DILocation(line: 3, column: 1, scope: !8)
Index: llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
===
--- llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
+++ llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
@@ -386,6 +386,18 @@
 }
 
 DIE &DwarfUnit::createAndAddDIE(dwarf::Tag Tag, DIE &Parent, const DINode *N) {
+  // For strict DWARF mode, only generate tags available to current DWARF
+  // version.
+  if (Asm->TM.Options.DebugStrictDwarf &&
+  DD->getDwarfVersion() < dwarf::TagVersion(Tag)) {
+// See if there is any replacement for some tags.
+if (Tag == dwarf::DW_TAG_rvalue_reference_type &&
+DD->getDwarfVersion() >= 3)
+  Tag = dwarf::DW_TAG_reference_type;
+
+// Assertion for other cases.
+assert(true && "Tag is generated not following strict DWARF!");
+  }
   DIE &Die = Parent.addChild(DIE::get(DIEValueAllocator, Tag));
   if (N)
 insertDIE(N, &Die);


Index: llvm/test/DebugInfo/PowerPC/strict-dwarf-tags.ll
===
--- /dev/null
+++ llvm/test/DebugInfo/PowerPC/strict-dwarf-tags.ll
@@ -0,0 +1,43 @@
+; RUN: llc -filetype=obj -mtriple=powerpc64le-unknown-linux-gnu < %s | \
+; RUN:   llvm-dwarfdump -debug-info - | FileCheck %s
+; RUN: llc -filetype=obj -mtriple=powerpc64le-unknown-linux-gnu \
+; RUN:   -strict-dwarf=true < %s | llvm-dwarfdump -debug-info - | \
+; RUN:   FileCheck %s -check-prefix=STRICT
+
+; If not strict DWARF mode, we expect DW_TAG_rvalue_reference_type at DWARF 3.
+; If strict DWARF mode, we expect DW_TAG_reference_type at DWARF 3 as DW_TAG_rvalue_reference_type
+; is a DWARF 4 tag.
+
+; CHECK: DW_TAG_rvalue_reference_type
+; STRICT: DW_TAG_reference_type
+
+define void @_Z3fooOi(i32* dereferenceable(4) %i) !dbg !8 {
+entry:
+  call void @llvm.dbg.value(metadata i32* %i, metadata !14, metadata !DIExpression()), !dbg !15
+  ret void, !dbg !16
+}
+
+; Function Attrs: nofree nosync nounwind readnone speculatable willreturn
+declare void @llvm.dbg.value(metadata, metadata, metadata) #1
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!3, !4, !5, !6}
+!llvm.ident = !{!7}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 13.0.0", isOptimized: true, runtimeVersion: 0, e

[PATCH] D100630: [Debug-Info][DBX] DW_TAG_rvalue_reference_type should not be generated when dwarf version is smaller than 4

2021-05-10 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

Does this cause duplicate DW_TAG_reference_types in the output, if the input IR 
Has both DW_TAG_reference_type and DW_TAG_rvalue_reference_types?




Comment at: llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp:391
+  // version.
+  dwarf::Tag FixedTag = (dwarf::Tag)Tag;
+  if (Asm->TM.Options.DebugStrictDwarf &&

Rather than adding a cast here, perhaps the parameter type could be updated? 
(maybe in a separate preliminary commit, though, so as not to muddy this one)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100630/new/

https://reviews.llvm.org/D100630

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


[PATCH] D100630: [Debug-Info][DBX] DW_TAG_rvalue_reference_type should not be generated when dwarf version is smaller than 4

2021-05-10 Thread ChenZheng via Phabricator via cfe-commits
shchenz added a comment.

In D100630#2745272 , @dblaikie wrote:

> Mixed feelings - is this the only place where we're changing behavior for 
> strict-DWARF in the frontend/clang? (maybe it'd be better to do it all in the 
> same place, down in the backend when the IR is mapped to actual DWARF)

Update the patch to do the check down in the backend. Seems we already have one 
centralized interface for TAGs generation.

> @aprantl @probinson - you two have any thoughts on this layering aspect?
>
> I think for CodeView we make some different choices up in the frontend (& 
> completely different implementations in the backend), so it's not totally 
> unreasonable, but curious how folks feel.

Welcome your comments! @aprantl @probinson


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100630/new/

https://reviews.llvm.org/D100630

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


[PATCH] D100630: [Debug-Info][DBX] DW_TAG_rvalue_reference_type should not be generated when dwarf version is smaller than 4

2021-05-10 Thread ChenZheng via Phabricator via cfe-commits
shchenz updated this revision to Diff 343983.
shchenz added a comment.
Herald added subscribers: llvm-commits, hiraditya, nemanjai.
Herald added a project: LLVM.

update according to @dblaikie comments


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100630/new/

https://reviews.llvm.org/D100630

Files:
  llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
  llvm/test/DebugInfo/PowerPC/strict-dwarf-tags.ll


Index: llvm/test/DebugInfo/PowerPC/strict-dwarf-tags.ll
===
--- /dev/null
+++ llvm/test/DebugInfo/PowerPC/strict-dwarf-tags.ll
@@ -0,0 +1,43 @@
+; RUN: llc -filetype=obj -mtriple=powerpc64le-unknown-linux-gnu < %s | \
+; RUN:   llvm-dwarfdump -debug-info - | FileCheck %s
+; RUN: llc -filetype=obj -mtriple=powerpc64le-unknown-linux-gnu \
+; RUN:   -strict-dwarf=true < %s | llvm-dwarfdump -debug-info - | \
+; RUN:   FileCheck %s -check-prefix=STRICT
+
+; If not strict DWARF mode, we expect DW_TAG_rvalue_reference_type at DWARF 3.
+; If strict DWARF mode, we expect DW_TAG_reference_type at DWARF 3 as 
DW_TAG_rvalue_reference_type
+; is a DWARF 4 tag.
+
+; CHECK: DW_TAG_rvalue_reference_type
+; STRICT: DW_TAG_reference_type
+
+define void @_Z3fooOi(i32* dereferenceable(4) %i) !dbg !8 {
+entry:
+  call void @llvm.dbg.value(metadata i32* %i, metadata !14, metadata 
!DIExpression()), !dbg !15
+  ret void, !dbg !16
+}
+
+; Function Attrs: nofree nosync nounwind readnone speculatable willreturn
+declare void @llvm.dbg.value(metadata, metadata, metadata) #1
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!3, !4, !5, !6}
+!llvm.ident = !{!7}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, 
producer: "clang version 13.0.0", isOptimized: true, runtimeVersion: 0, 
emissionKind: FullDebug, enums: !2, splitDebugInlining: false, nameTableKind: 
None)
+!1 = !DIFile(filename: "1.cpp", directory: "./")
+!2 = !{}
+!3 = !{i32 7, !"Dwarf Version", i32 3}
+!4 = !{i32 2, !"Debug Info Version", i32 3}
+!5 = !{i32 1, !"wchar_size", i32 4}
+!6 = !{i32 7, !"uwtable", i32 1}
+!7 = !{!"clang version 13.0.0"}
+!8 = distinct !DISubprogram(name: "foo", linkageName: "_Z3fooOi", scope: !1, 
file: !1, line: 1, type: !9, scopeLine: 2, flags: DIFlagPrototyped | 
DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: 
!0, retainedNodes: !13)
+!9 = !DISubroutineType(types: !10)
+!10 = !{null, !11}
+!11 = !DIDerivedType(tag: DW_TAG_rvalue_reference_type, baseType: !12, size: 
64)
+!12 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
+!13 = !{!14}
+!14 = !DILocalVariable(name: "i", arg: 1, scope: !8, file: !1, line: 1, type: 
!11)
+!15 = !DILocation(line: 0, scope: !8)
+!16 = !DILocation(line: 3, column: 1, scope: !8)
Index: llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
===
--- llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
+++ llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
@@ -386,7 +386,20 @@
 }
 
 DIE &DwarfUnit::createAndAddDIE(unsigned Tag, DIE &Parent, const DINode *N) {
-  DIE &Die = Parent.addChild(DIE::get(DIEValueAllocator, (dwarf::Tag)Tag));
+  // For strict DWARF mode, only generate tags available to current DWARF
+  // version.
+  dwarf::Tag FixedTag = (dwarf::Tag)Tag;
+  if (Asm->TM.Options.DebugStrictDwarf &&
+  DD->getDwarfVersion() < dwarf::TagVersion(FixedTag)) {
+// See if there is any replacement for some tags.
+if (FixedTag == dwarf::DW_TAG_rvalue_reference_type &&
+DD->getDwarfVersion() >= 3)
+  FixedTag = dwarf::DW_TAG_reference_type;
+
+// Assertion for other cases.
+assert(true && "Tag is generated not following strict DWARF!");
+  }
+  DIE &Die = Parent.addChild(DIE::get(DIEValueAllocator, FixedTag));
   if (N)
 insertDIE(N, &Die);
   return Die;


Index: llvm/test/DebugInfo/PowerPC/strict-dwarf-tags.ll
===
--- /dev/null
+++ llvm/test/DebugInfo/PowerPC/strict-dwarf-tags.ll
@@ -0,0 +1,43 @@
+; RUN: llc -filetype=obj -mtriple=powerpc64le-unknown-linux-gnu < %s | \
+; RUN:   llvm-dwarfdump -debug-info - | FileCheck %s
+; RUN: llc -filetype=obj -mtriple=powerpc64le-unknown-linux-gnu \
+; RUN:   -strict-dwarf=true < %s | llvm-dwarfdump -debug-info - | \
+; RUN:   FileCheck %s -check-prefix=STRICT
+
+; If not strict DWARF mode, we expect DW_TAG_rvalue_reference_type at DWARF 3.
+; If strict DWARF mode, we expect DW_TAG_reference_type at DWARF 3 as DW_TAG_rvalue_reference_type
+; is a DWARF 4 tag.
+
+; CHECK: DW_TAG_rvalue_reference_type
+; STRICT: DW_TAG_reference_type
+
+define void @_Z3fooOi(i32* dereferenceable(4) %i) !dbg !8 {
+entry:
+  call void @llvm.dbg.value(metadata i32* %i, metadata !14, metadata !DIExpression()), !dbg !15
+  ret void, !dbg !16
+}
+
+; Function Attrs: nofree nosync nounwind readnone speculatable willreturn
+declare void @llvm.dbg.value(metadata, metadata, metadata) #1
+
+!llvm.dbg.cu = !{!

[PATCH] D100630: [Debug-Info][DBX] DW_TAG_rvalue_reference_type should not be generated when dwarf version is smaller than 4

2021-05-08 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

Mixed feelings - is this the only place where we're changing behavior for 
strict-DWARF in the frontend/clang? (maybe it'd be better to do it all in the 
same place, down in the backend when the IR is mapped to actual DWARF)

@aprantl @probinson - you two have any thoughts on this layering aspect?

I think for CodeView we make some different choices up in the frontend (& 
completely different implementations in the backend), so it's not totally 
unreasonable, but curious how folks feel.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100630/new/

https://reviews.llvm.org/D100630

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


[PATCH] D100630: [Debug-Info][DBX] DW_TAG_rvalue_reference_type should not be generated when dwarf version is smaller than 4

2021-05-07 Thread ChenZheng via Phabricator via cfe-commits
shchenz added a comment.

gentle ping.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100630/new/

https://reviews.llvm.org/D100630

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


[PATCH] D100630: [Debug-Info][DBX] DW_TAG_rvalue_reference_type should not be generated when dwarf version is smaller than 4

2021-04-21 Thread ChenZheng via Phabricator via cfe-commits
shchenz updated this revision to Diff 338695.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100630/new/

https://reviews.llvm.org/D100630

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/CodeGenCXX/debug-info-rvalue-ref.cpp


Index: clang/test/CodeGenCXX/debug-info-rvalue-ref.cpp
===
--- clang/test/CodeGenCXX/debug-info-rvalue-ref.cpp
+++ clang/test/CodeGenCXX/debug-info-rvalue-ref.cpp
@@ -1,4 +1,8 @@
 // RUN: %clang_cc1 -std=c++11 -emit-llvm -debug-info-kind=limited -triple 
x86_64-apple-darwin %s -o - | FileCheck %s
+// RUN: %clang_cc1 -std=c++11 -dwarf-version=4 -debugger-tuning=dbx -emit-llvm 
-debug-info-kind=limited \
+// RUN:   -triple x86_64-apple-darwin %s -o - | FileCheck %s
+// RUN: %clang_cc1 -std=c++11 -dwarf-version=3 -debugger-tuning=dbx -emit-llvm 
-debug-info-kind=limited \
+// RUN:  -triple x86_64-apple-darwin %s -o - | FileCheck %s 
--check-prefix=NORVALUE
 
 extern "C" {
 extern int printf(const char * format, ...);
@@ -10,3 +14,4 @@
 
 // CHECK: !DIDerivedType(tag: DW_TAG_rvalue_reference_type, baseType: 
![[INT:[0-9]+]], size: 64)
 // CHECK: ![[INT]] = !DIBasicType(name: "int"
+// NORVALUE: !DIDerivedType(tag: DW_TAG_reference_type, baseType: 
![[INT:[0-9]+]], size: 64)
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -2989,8 +2989,14 @@
 
 llvm::DIType *CGDebugInfo::CreateType(const RValueReferenceType *Ty,
   llvm::DIFile *Unit) {
-  return CreatePointerLikeType(llvm::dwarf::DW_TAG_rvalue_reference_type, Ty,
-   Ty->getPointeeType(), Unit);
+  llvm::dwarf::Tag Tag = llvm::dwarf::DW_TAG_rvalue_reference_type;
+  // DW_TAG_rvalue_reference_type was introduced in DWARF 4, in strict DWARF
+  // mode, only generate it when DWARF version is no smaller than 4.
+  if (CGM.getCodeGenOpts().getDebugStrictDwarf() &&
+  CGM.getCodeGenOpts().DwarfVersion < 4)
+Tag = llvm::dwarf::DW_TAG_reference_type;
+
+  return CreatePointerLikeType(Tag, Ty, Ty->getPointeeType(), Unit);
 }
 
 llvm::DIType *CGDebugInfo::CreateType(const MemberPointerType *Ty,


Index: clang/test/CodeGenCXX/debug-info-rvalue-ref.cpp
===
--- clang/test/CodeGenCXX/debug-info-rvalue-ref.cpp
+++ clang/test/CodeGenCXX/debug-info-rvalue-ref.cpp
@@ -1,4 +1,8 @@
 // RUN: %clang_cc1 -std=c++11 -emit-llvm -debug-info-kind=limited -triple x86_64-apple-darwin %s -o - | FileCheck %s
+// RUN: %clang_cc1 -std=c++11 -dwarf-version=4 -debugger-tuning=dbx -emit-llvm -debug-info-kind=limited \
+// RUN:   -triple x86_64-apple-darwin %s -o - | FileCheck %s
+// RUN: %clang_cc1 -std=c++11 -dwarf-version=3 -debugger-tuning=dbx -emit-llvm -debug-info-kind=limited \
+// RUN:  -triple x86_64-apple-darwin %s -o - | FileCheck %s --check-prefix=NORVALUE
 
 extern "C" {
 extern int printf(const char * format, ...);
@@ -10,3 +14,4 @@
 
 // CHECK: !DIDerivedType(tag: DW_TAG_rvalue_reference_type, baseType: ![[INT:[0-9]+]], size: 64)
 // CHECK: ![[INT]] = !DIBasicType(name: "int"
+// NORVALUE: !DIDerivedType(tag: DW_TAG_reference_type, baseType: ![[INT:[0-9]+]], size: 64)
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -2989,8 +2989,14 @@
 
 llvm::DIType *CGDebugInfo::CreateType(const RValueReferenceType *Ty,
   llvm::DIFile *Unit) {
-  return CreatePointerLikeType(llvm::dwarf::DW_TAG_rvalue_reference_type, Ty,
-   Ty->getPointeeType(), Unit);
+  llvm::dwarf::Tag Tag = llvm::dwarf::DW_TAG_rvalue_reference_type;
+  // DW_TAG_rvalue_reference_type was introduced in DWARF 4, in strict DWARF
+  // mode, only generate it when DWARF version is no smaller than 4.
+  if (CGM.getCodeGenOpts().getDebugStrictDwarf() &&
+  CGM.getCodeGenOpts().DwarfVersion < 4)
+Tag = llvm::dwarf::DW_TAG_reference_type;
+
+  return CreatePointerLikeType(Tag, Ty, Ty->getPointeeType(), Unit);
 }
 
 llvm::DIType *CGDebugInfo::CreateType(const MemberPointerType *Ty,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D100630: [Debug-Info][DBX] DW_TAG_rvalue_reference_type should not be generated when dwarf version is smaller than 4

2021-04-21 Thread ChenZheng via Phabricator via cfe-commits
shchenz updated this revision to Diff 338755.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100630/new/

https://reviews.llvm.org/D100630

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/CodeGenCXX/debug-info-rvalue-ref.cpp


Index: clang/test/CodeGenCXX/debug-info-rvalue-ref.cpp
===
--- clang/test/CodeGenCXX/debug-info-rvalue-ref.cpp
+++ clang/test/CodeGenCXX/debug-info-rvalue-ref.cpp
@@ -1,4 +1,8 @@
 // RUN: %clang_cc1 -std=c++11 -emit-llvm -debug-info-kind=limited -triple 
x86_64-apple-darwin %s -o - | FileCheck %s
+// RUN: %clang_cc1 -std=c++11 -gstrict-dwarf -dwarf-version=4 -emit-llvm 
-debug-info-kind=limited \
+// RUN:   -triple x86_64-apple-darwin %s -o - | FileCheck %s
+// RUN: %clang_cc1 -std=c++11 -gstrict-dwarf -dwarf-version=3 -emit-llvm 
-debug-info-kind=limited \
+// RUN:   -triple x86_64-apple-darwin %s -o - | FileCheck %s 
--check-prefix=NORVALUE
 
 extern "C" {
 extern int printf(const char * format, ...);
@@ -10,3 +14,4 @@
 
 // CHECK: !DIDerivedType(tag: DW_TAG_rvalue_reference_type, baseType: 
![[INT:[0-9]+]], size: 64)
 // CHECK: ![[INT]] = !DIBasicType(name: "int"
+// NORVALUE: !DIDerivedType(tag: DW_TAG_reference_type, baseType: 
![[INT:[0-9]+]], size: 64)
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -2989,8 +2989,14 @@
 
 llvm::DIType *CGDebugInfo::CreateType(const RValueReferenceType *Ty,
   llvm::DIFile *Unit) {
-  return CreatePointerLikeType(llvm::dwarf::DW_TAG_rvalue_reference_type, Ty,
-   Ty->getPointeeType(), Unit);
+  llvm::dwarf::Tag Tag = llvm::dwarf::DW_TAG_rvalue_reference_type;
+  // DW_TAG_rvalue_reference_type was introduced in DWARF 4, in strict DWARF
+  // mode, only generate it when DWARF version is no smaller than 4.
+  if (CGM.getCodeGenOpts().DebugStrictDwarf &&
+  CGM.getCodeGenOpts().DwarfVersion < 4)
+Tag = llvm::dwarf::DW_TAG_reference_type;
+
+  return CreatePointerLikeType(Tag, Ty, Ty->getPointeeType(), Unit);
 }
 
 llvm::DIType *CGDebugInfo::CreateType(const MemberPointerType *Ty,


Index: clang/test/CodeGenCXX/debug-info-rvalue-ref.cpp
===
--- clang/test/CodeGenCXX/debug-info-rvalue-ref.cpp
+++ clang/test/CodeGenCXX/debug-info-rvalue-ref.cpp
@@ -1,4 +1,8 @@
 // RUN: %clang_cc1 -std=c++11 -emit-llvm -debug-info-kind=limited -triple x86_64-apple-darwin %s -o - | FileCheck %s
+// RUN: %clang_cc1 -std=c++11 -gstrict-dwarf -dwarf-version=4 -emit-llvm -debug-info-kind=limited \
+// RUN:   -triple x86_64-apple-darwin %s -o - | FileCheck %s
+// RUN: %clang_cc1 -std=c++11 -gstrict-dwarf -dwarf-version=3 -emit-llvm -debug-info-kind=limited \
+// RUN:   -triple x86_64-apple-darwin %s -o - | FileCheck %s --check-prefix=NORVALUE
 
 extern "C" {
 extern int printf(const char * format, ...);
@@ -10,3 +14,4 @@
 
 // CHECK: !DIDerivedType(tag: DW_TAG_rvalue_reference_type, baseType: ![[INT:[0-9]+]], size: 64)
 // CHECK: ![[INT]] = !DIBasicType(name: "int"
+// NORVALUE: !DIDerivedType(tag: DW_TAG_reference_type, baseType: ![[INT:[0-9]+]], size: 64)
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -2989,8 +2989,14 @@
 
 llvm::DIType *CGDebugInfo::CreateType(const RValueReferenceType *Ty,
   llvm::DIFile *Unit) {
-  return CreatePointerLikeType(llvm::dwarf::DW_TAG_rvalue_reference_type, Ty,
-   Ty->getPointeeType(), Unit);
+  llvm::dwarf::Tag Tag = llvm::dwarf::DW_TAG_rvalue_reference_type;
+  // DW_TAG_rvalue_reference_type was introduced in DWARF 4, in strict DWARF
+  // mode, only generate it when DWARF version is no smaller than 4.
+  if (CGM.getCodeGenOpts().DebugStrictDwarf &&
+  CGM.getCodeGenOpts().DwarfVersion < 4)
+Tag = llvm::dwarf::DW_TAG_reference_type;
+
+  return CreatePointerLikeType(Tag, Ty, Ty->getPointeeType(), Unit);
 }
 
 llvm::DIType *CGDebugInfo::CreateType(const MemberPointerType *Ty,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D100630: [Debug-Info][DBX] DW_TAG_rvalue_reference_type should not be generated when dwarf version is smaller than 4

2021-04-21 Thread ChenZheng via Phabricator via cfe-commits
shchenz added a comment.

In D100630#2697732 , @dblaikie wrote:

> In D100630#2697728 , @shchenz wrote:
>
>> In D100630#2694681 , @probinson 
>> wrote:
>>
>>> If DBX is going to be really pedantic about not recognizing tags or 
>>> attributes that don't align with the DWARF version, maybe we're better off 
>>> with really supporting `-gstrict-dwarf` and just have DBX tuning imply that.
>>
>> Hi @probinson thanks for pointing out the way, agree with this new solution. 
>> After checking the codes, I found there are already `-gstrict-dwarf`, 
>> `-gno-strict-dwarf` options in clang code base, but there seem no users of 
>> them. Do you happen to know the story of these two options? I get a quick 
>> search, no clue yet. Can we reuse these options for the intention here. 
>> Thanks?
>
> I'd suggest checking the history of the commits that added them - but likely 
> they were added for command line compatibility with gcc but I expect they're 
> currently no-ops in Clang. Adding the expected functionality to them seems 
> fine to me.

Yes, it should be for compatibility with gcc. I found same options in gcc. I 
create patch D100809  for this support in 
clang. Could you please help to review? Thanks


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100630/new/

https://reviews.llvm.org/D100630

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


[PATCH] D100630: [Debug-Info][DBX] DW_TAG_rvalue_reference_type should not be generated when dwarf version is smaller than 4

2021-04-19 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

In D100630#2697728 , @shchenz wrote:

> In D100630#2694681 , @probinson 
> wrote:
>
>> If DBX is going to be really pedantic about not recognizing tags or 
>> attributes that don't align with the DWARF version, maybe we're better off 
>> with really supporting `-gstrict-dwarf` and just have DBX tuning imply that.
>
> Hi @probinson thanks for pointing out the way, agree with this new solution. 
> After checking the codes, I found there are already `-gstrict-dwarf`, 
> `-gno-strict-dwarf` options in clang code base, but there seem no users of 
> them. Do you happen to know the story of these two options? I get a quick 
> search, no clue yet. Can we reuse these options for the intention here. 
> Thanks?

I'd suggest checking the history of the commits that added them - but likely 
they were added for command line compatibility with gcc but I expect they're 
currently no-ops in Clang. Adding the expected functionality to them seems fine 
to me.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100630/new/

https://reviews.llvm.org/D100630

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


[PATCH] D100630: [Debug-Info][DBX] DW_TAG_rvalue_reference_type should not be generated when dwarf version is smaller than 4

2021-04-19 Thread ChenZheng via Phabricator via cfe-commits
shchenz added a comment.

In D100630#2694681 , @probinson wrote:

> If DBX is going to be really pedantic about not recognizing tags or 
> attributes that don't align with the DWARF version, maybe we're better off 
> with really supporting `-gstrict-dwarf` and just have DBX tuning imply that.

Hi @probinson thanks for pointing out the way, agree with this new solution. 
After checking the codes, I found there are already `-gstrict-dwarf`, 
`-gno-strict-dwarf` options in clang code base, but there seem no users of 
them. Do you happen to know the story of these two options? I get a quick 
search, no clue yet. Can we reuse these options for the intention here. Thanks?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100630/new/

https://reviews.llvm.org/D100630

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


[PATCH] D100630: [Debug-Info][DBX] DW_TAG_rvalue_reference_type should not be generated when dwarf version is smaller than 4

2021-04-16 Thread Jinsong Ji via Phabricator via cfe-commits
jsji added a comment.

In D100630#2694681 , @probinson wrote:

> If DBX is going to be really pedantic about not recognizing tags or 
> attributes that don't align with the DWARF version, maybe we're better off 
> with really supporting `-gstrict-dwarf` and just have DBX tuning imply that.

Thanks! Yes, that is a good idea. By adding `-gstrict-dwarf`, all these dwarf 
version check work might be beneficial to others, not just for *dbx* .


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100630/new/

https://reviews.llvm.org/D100630

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


[PATCH] D100630: [Debug-Info][DBX] DW_TAG_rvalue_reference_type should not be generated when dwarf version is smaller than 4

2021-04-16 Thread Paul Robinson via Phabricator via cfe-commits
probinson added a comment.

If DBX is going to be really pedantic about not recognizing tags or attributes 
that don't align with the DWARF version, maybe we're better off with really 
supporting `-gstrict-dwarf` and just have DBX tuning imply that.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100630/new/

https://reviews.llvm.org/D100630

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


[PATCH] D100630: [Debug-Info][DBX] DW_TAG_rvalue_reference_type should not be generated when dwarf version is smaller than 4

2021-04-16 Thread ChenZheng via Phabricator via cfe-commits
shchenz created this revision.
shchenz added reviewers: dblaikie, aprantl, probinson, jsji, Esme, echristo, 
PowerPC.
shchenz added a project: debug-info.
shchenz requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

As discussed in D99250  , we added a new 
tuning debugger DBX(D99400 ) to add some debug 
info customizations for DBX on AIX.

This is part of the customizations, not generating DWARF infos not matching the 
DWARF version.

This is for DW_TAG_rvalue_reference_type tag.

Now for DBX, we only generate this tag when DWARF version is 4 or higher.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D100630

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/CodeGenCXX/debug-info-rvalue-ref.cpp


Index: clang/test/CodeGenCXX/debug-info-rvalue-ref.cpp
===
--- clang/test/CodeGenCXX/debug-info-rvalue-ref.cpp
+++ clang/test/CodeGenCXX/debug-info-rvalue-ref.cpp
@@ -1,4 +1,8 @@
 // RUN: %clang_cc1 -std=c++11 -emit-llvm -debug-info-kind=limited -triple 
x86_64-apple-darwin %s -o - | FileCheck %s
+// RUN: %clang_cc1 -std=c++11 -dwarf-version=4 -debugger-tuning=dbx -emit-llvm 
-debug-info-kind=limited \
+// RUN:   -triple x86_64-apple-darwin %s -o - | FileCheck %s
+// RUN: %clang_cc1 -std=c++11 -dwarf-version=3 -debugger-tuning=dbx -emit-llvm 
-debug-info-kind=limited \
+// RUN:  -triple x86_64-apple-darwin %s -o - | FileCheck %s 
--check-prefix=NORVALUE
 
 extern "C" {
 extern int printf(const char * format, ...);
@@ -10,3 +14,4 @@
 
 // CHECK: !DIDerivedType(tag: DW_TAG_rvalue_reference_type, baseType: 
![[INT:[0-9]+]], size: 64)
 // CHECK: ![[INT]] = !DIBasicType(name: "int"
+// NORVALUE: !DIDerivedType(tag: DW_TAG_reference_type, baseType: 
![[INT:[0-9]+]], size: 64)
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -2989,8 +2989,13 @@
 
 llvm::DIType *CGDebugInfo::CreateType(const RValueReferenceType *Ty,
   llvm::DIFile *Unit) {
-  return CreatePointerLikeType(llvm::dwarf::DW_TAG_rvalue_reference_type, Ty,
-   Ty->getPointeeType(), Unit);
+  llvm::dwarf::Tag Tag = llvm::dwarf::DW_TAG_rvalue_reference_type;
+  // For DBX, we generate DWARF 4 tag at DWARF version no less than 4.
+  if (CGM.getCodeGenOpts().getDebuggerTuning() == llvm::DebuggerKind::DBX &&
+  CGM.getCodeGenOpts().DwarfVersion < 4)
+Tag = llvm::dwarf::DW_TAG_reference_type;
+
+  return CreatePointerLikeType(Tag, Ty, Ty->getPointeeType(), Unit);
 }
 
 llvm::DIType *CGDebugInfo::CreateType(const MemberPointerType *Ty,


Index: clang/test/CodeGenCXX/debug-info-rvalue-ref.cpp
===
--- clang/test/CodeGenCXX/debug-info-rvalue-ref.cpp
+++ clang/test/CodeGenCXX/debug-info-rvalue-ref.cpp
@@ -1,4 +1,8 @@
 // RUN: %clang_cc1 -std=c++11 -emit-llvm -debug-info-kind=limited -triple x86_64-apple-darwin %s -o - | FileCheck %s
+// RUN: %clang_cc1 -std=c++11 -dwarf-version=4 -debugger-tuning=dbx -emit-llvm -debug-info-kind=limited \
+// RUN:   -triple x86_64-apple-darwin %s -o - | FileCheck %s
+// RUN: %clang_cc1 -std=c++11 -dwarf-version=3 -debugger-tuning=dbx -emit-llvm -debug-info-kind=limited \
+// RUN:  -triple x86_64-apple-darwin %s -o - | FileCheck %s --check-prefix=NORVALUE
 
 extern "C" {
 extern int printf(const char * format, ...);
@@ -10,3 +14,4 @@
 
 // CHECK: !DIDerivedType(tag: DW_TAG_rvalue_reference_type, baseType: ![[INT:[0-9]+]], size: 64)
 // CHECK: ![[INT]] = !DIBasicType(name: "int"
+// NORVALUE: !DIDerivedType(tag: DW_TAG_reference_type, baseType: ![[INT:[0-9]+]], size: 64)
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -2989,8 +2989,13 @@
 
 llvm::DIType *CGDebugInfo::CreateType(const RValueReferenceType *Ty,
   llvm::DIFile *Unit) {
-  return CreatePointerLikeType(llvm::dwarf::DW_TAG_rvalue_reference_type, Ty,
-   Ty->getPointeeType(), Unit);
+  llvm::dwarf::Tag Tag = llvm::dwarf::DW_TAG_rvalue_reference_type;
+  // For DBX, we generate DWARF 4 tag at DWARF version no less than 4.
+  if (CGM.getCodeGenOpts().getDebuggerTuning() == llvm::DebuggerKind::DBX &&
+  CGM.getCodeGenOpts().DwarfVersion < 4)
+Tag = llvm::dwarf::DW_TAG_reference_type;
+
+  return CreatePointerLikeType(Tag, Ty, Ty->getPointeeType(), Unit);
 }
 
 llvm::DIType *CGDebugInfo::CreateType(const MemberPointerType *Ty,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits