1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 10:42:39 +01:00

Revert "[DebugInfo][clang][DWARF5]: Added support for debuginfo generation for defaulted parameters"

The Bitcode/DITemplateParameter-5.0.ll test is failing:

FAIL: LLVM :: Bitcode/DITemplateParameter-5.0.ll (5894 of 36324)
******************** TEST 'LLVM :: Bitcode/DITemplateParameter-5.0.ll' FAILED ********************
Script:
--
: 'RUN: at line 1';   /usr/local/google/home/thakis/src/llvm-project/out/gn/bin/llvm-dis -o - /usr/local/google/home/thakis/src/llvm-project/llvm/test/Bitcode/DITemplateParameter-5.0.ll.bc | /usr/local/google/home/thakis/src/llvm-project/out/gn/bin/FileCheck /usr/local/google/home/thakis/src/llvm-project/llvm/test/Bitcode/DITemplateParameter-5.0.ll
--
Exit Code: 2

Command Output (stderr):
--

It looks like the Bitcode/DITemplateParameter-5.0.ll.bc file was never checked in.

This reverts commit c2b437d53d40b6dc5603c97f527398f477d9c5f1.
This commit is contained in:
Hans Wennborg 2020-03-02 09:26:00 +01:00
parent 0c03c0d36d
commit e0fb9eaf01
12 changed files with 87 additions and 271 deletions

View File

@ -443,22 +443,19 @@ namespace llvm {
/// \param Scope Scope in which this type is defined.
/// \param Name Type parameter name.
/// \param Ty Parameter type.
/// \param IsDefault Parameter is default or not
DITemplateTypeParameter *createTemplateTypeParameter(DIScope *Scope,
StringRef Name,
DIType *Ty,
bool IsDefault);
DITemplateTypeParameter *
createTemplateTypeParameter(DIScope *Scope, StringRef Name, DIType *Ty);
/// Create debugging information for template
/// value parameter.
/// \param Scope Scope in which this type is defined.
/// \param Name Value parameter name.
/// \param Ty Parameter type.
/// \param IsDefault Parameter is default or not
/// \param Val Constant parameter value.
DITemplateValueParameter *
createTemplateValueParameter(DIScope *Scope, StringRef Name, DIType *Ty,
bool IsDefault, Constant *Val);
DITemplateValueParameter *createTemplateValueParameter(DIScope *Scope,
StringRef Name,
DIType *Ty,
Constant *Val);
/// Create debugging information for a template template parameter.
/// \param Scope Scope in which this type is defined.

View File

@ -2131,11 +2131,9 @@ public:
/// Base class for template parameters.
class DITemplateParameter : public DINode {
protected:
bool IsDefault;
DITemplateParameter(LLVMContext &Context, unsigned ID, StorageType Storage,
unsigned Tag, bool IsDefault, ArrayRef<Metadata *> Ops)
: DINode(Context, ID, Storage, Tag, Ops), IsDefault(IsDefault) {}
unsigned Tag, ArrayRef<Metadata *> Ops)
: DINode(Context, ID, Storage, Tag, Ops) {}
~DITemplateParameter() = default;
public:
@ -2144,7 +2142,6 @@ public:
MDString *getRawName() const { return getOperandAs<MDString>(0); }
Metadata *getRawType() const { return getOperand(1); }
bool isDefault() const { return IsDefault; }
static bool classof(const Metadata *MD) {
return MD->getMetadataID() == DITemplateTypeParameterKind ||
@ -2157,35 +2154,30 @@ class DITemplateTypeParameter : public DITemplateParameter {
friend class MDNode;
DITemplateTypeParameter(LLVMContext &Context, StorageType Storage,
bool IsDefault, ArrayRef<Metadata *> Ops)
ArrayRef<Metadata *> Ops)
: DITemplateParameter(Context, DITemplateTypeParameterKind, Storage,
dwarf::DW_TAG_template_type_parameter, IsDefault,
Ops) {}
dwarf::DW_TAG_template_type_parameter, Ops) {}
~DITemplateTypeParameter() = default;
static DITemplateTypeParameter *getImpl(LLVMContext &Context, StringRef Name,
DIType *Type, bool IsDefault,
StorageType Storage,
DIType *Type, StorageType Storage,
bool ShouldCreate = true) {
return getImpl(Context, getCanonicalMDString(Context, Name), Type,
IsDefault, Storage, ShouldCreate);
return getImpl(Context, getCanonicalMDString(Context, Name), Type, Storage,
ShouldCreate);
}
static DITemplateTypeParameter *getImpl(LLVMContext &Context, MDString *Name,
Metadata *Type, bool IsDefault,
StorageType Storage,
Metadata *Type, StorageType Storage,
bool ShouldCreate = true);
TempDITemplateTypeParameter cloneImpl() const {
return getTemporary(getContext(), getName(), getType(), isDefault());
return getTemporary(getContext(), getName(), getType());
}
public:
DEFINE_MDNODE_GET(DITemplateTypeParameter,
(StringRef Name, DIType *Type, bool IsDefault),
(Name, Type, IsDefault))
DEFINE_MDNODE_GET(DITemplateTypeParameter,
(MDString *Name, Metadata *Type, bool IsDefault),
(Name, Type, IsDefault))
DEFINE_MDNODE_GET(DITemplateTypeParameter, (StringRef Name, DIType *Type),
(Name, Type))
DEFINE_MDNODE_GET(DITemplateTypeParameter, (MDString * Name, Metadata *Type),
(Name, Type))
TempDITemplateTypeParameter clone() const { return cloneImpl(); }
@ -2199,40 +2191,36 @@ class DITemplateValueParameter : public DITemplateParameter {
friend class MDNode;
DITemplateValueParameter(LLVMContext &Context, StorageType Storage,
unsigned Tag, bool IsDefault,
ArrayRef<Metadata *> Ops)
unsigned Tag, ArrayRef<Metadata *> Ops)
: DITemplateParameter(Context, DITemplateValueParameterKind, Storage, Tag,
IsDefault, Ops) {}
Ops) {}
~DITemplateValueParameter() = default;
static DITemplateValueParameter *getImpl(LLVMContext &Context, unsigned Tag,
StringRef Name, DIType *Type,
bool IsDefault, Metadata *Value,
StorageType Storage,
Metadata *Value, StorageType Storage,
bool ShouldCreate = true) {
return getImpl(Context, Tag, getCanonicalMDString(Context, Name), Type,
IsDefault, Value, Storage, ShouldCreate);
Value, Storage, ShouldCreate);
}
static DITemplateValueParameter *getImpl(LLVMContext &Context, unsigned Tag,
MDString *Name, Metadata *Type,
bool IsDefault, Metadata *Value,
StorageType Storage,
Metadata *Value, StorageType Storage,
bool ShouldCreate = true);
TempDITemplateValueParameter cloneImpl() const {
return getTemporary(getContext(), getTag(), getName(), getType(),
isDefault(), getValue());
getValue());
}
public:
DEFINE_MDNODE_GET(DITemplateValueParameter,
(unsigned Tag, StringRef Name, DIType *Type, bool IsDefault,
(unsigned Tag, StringRef Name, DIType *Type,
Metadata *Value),
(Tag, Name, Type, IsDefault, Value))
DEFINE_MDNODE_GET(DITemplateValueParameter,
(unsigned Tag, MDString *Name, Metadata *Type,
bool IsDefault, Metadata *Value),
(Tag, Name, Type, IsDefault, Value))
(Tag, Name, Type, Value))
DEFINE_MDNODE_GET(DITemplateValueParameter, (unsigned Tag, MDString *Name,
Metadata *Type, Metadata *Value),
(Tag, Name, Type, Value))
TempDITemplateValueParameter clone() const { return cloneImpl(); }

View File

@ -4842,38 +4842,33 @@ bool LLParser::ParseDIModule(MDNode *&Result, bool IsDistinct) {
}
/// ParseDITemplateTypeParameter:
/// ::= !DITemplateTypeParameter(name: "Ty", type: !1, defaulted: false)
/// ::= !DITemplateTypeParameter(name: "Ty", type: !1)
bool LLParser::ParseDITemplateTypeParameter(MDNode *&Result, bool IsDistinct) {
#define VISIT_MD_FIELDS(OPTIONAL, REQUIRED) \
OPTIONAL(name, MDStringField, ); \
REQUIRED(type, MDField, ); \
OPTIONAL(defaulted, MDBoolField, );
REQUIRED(type, MDField, );
PARSE_MD_FIELDS();
#undef VISIT_MD_FIELDS
Result = GET_OR_DISTINCT(DITemplateTypeParameter,
(Context, name.Val, type.Val, defaulted.Val));
Result =
GET_OR_DISTINCT(DITemplateTypeParameter, (Context, name.Val, type.Val));
return false;
}
/// ParseDITemplateValueParameter:
/// ::= !DITemplateValueParameter(tag: DW_TAG_template_value_parameter,
/// name: "V", type: !1, defaulted: false,
/// value: i32 7)
/// name: "V", type: !1, value: i32 7)
bool LLParser::ParseDITemplateValueParameter(MDNode *&Result, bool IsDistinct) {
#define VISIT_MD_FIELDS(OPTIONAL, REQUIRED) \
OPTIONAL(tag, DwarfTagField, (dwarf::DW_TAG_template_value_parameter)); \
OPTIONAL(name, MDStringField, ); \
OPTIONAL(type, MDField, ); \
OPTIONAL(defaulted, MDBoolField, ); \
REQUIRED(value, MDField, );
PARSE_MD_FIELDS();
#undef VISIT_MD_FIELDS
Result = GET_OR_DISTINCT(
DITemplateValueParameter,
(Context, tag.Val, name.Val, type.Val, defaulted.Val, value.Val));
Result = GET_OR_DISTINCT(DITemplateValueParameter,
(Context, tag.Val, name.Val, type.Val, value.Val));
return false;
}

View File

@ -1668,34 +1668,27 @@ Error MetadataLoader::MetadataLoaderImpl::parseOneMetadata(
break;
}
case bitc::METADATA_TEMPLATE_TYPE: {
if (Record.size() < 3 || Record.size() > 4)
if (Record.size() != 3)
return error("Invalid record");
IsDistinct = Record[0];
MetadataList.assignValue(
GET_OR_DISTINCT(DITemplateTypeParameter,
(Context, getMDString(Record[1]),
getDITypeRefOrNull(Record[2]),
(Record.size() == 4) ? getMDOrNull(Record[3])
: getMDOrNull(false))),
NextMetadataNo);
MetadataList.assignValue(GET_OR_DISTINCT(DITemplateTypeParameter,
(Context, getMDString(Record[1]),
getDITypeRefOrNull(Record[2]))),
NextMetadataNo);
NextMetadataNo++;
break;
}
case bitc::METADATA_TEMPLATE_VALUE: {
if (Record.size() < 5 || Record.size() > 6)
if (Record.size() != 5)
return error("Invalid record");
IsDistinct = Record[0];
MetadataList.assignValue(
GET_OR_DISTINCT(
DITemplateValueParameter,
(Context, Record[1], getMDString(Record[2]),
getDITypeRefOrNull(Record[3]),
(Record.size() == 6) ? getMDOrNull(Record[4]) : getMDOrNull(false),
(Record.size() == 6) ? getMDOrNull(Record[5])
: getMDOrNull(Record[4]))),
GET_OR_DISTINCT(DITemplateValueParameter,
(Context, Record[1], getMDString(Record[2]),
getDITypeRefOrNull(Record[3]),
getMDOrNull(Record[4]))),
NextMetadataNo);
NextMetadataNo++;
break;

View File

@ -1792,7 +1792,6 @@ void ModuleBitcodeWriter::writeDITemplateTypeParameter(
Record.push_back(N->isDistinct());
Record.push_back(VE.getMetadataOrNullID(N->getRawName()));
Record.push_back(VE.getMetadataOrNullID(N->getType()));
Record.push_back(N->isDefault());
Stream.EmitRecord(bitc::METADATA_TEMPLATE_TYPE, Record, Abbrev);
Record.clear();
@ -1805,7 +1804,6 @@ void ModuleBitcodeWriter::writeDITemplateValueParameter(
Record.push_back(N->getTag());
Record.push_back(VE.getMetadataOrNullID(N->getRawName()));
Record.push_back(VE.getMetadataOrNullID(N->getType()));
Record.push_back(N->isDefault());
Record.push_back(VE.getMetadataOrNullID(N->getValue()));
Stream.EmitRecord(bitc::METADATA_TEMPLATE_VALUE, Record, Abbrev);

View File

@ -2073,7 +2073,6 @@ static void writeDITemplateTypeParameter(raw_ostream &Out,
MDFieldPrinter Printer(Out, TypePrinter, Machine, Context);
Printer.printString("name", N->getName());
Printer.printMetadata("type", N->getRawType(), /* ShouldSkipNull */ false);
Printer.printBool("defaulted", N->isDefault(), /* Default= */ false);
Out << ")";
}
@ -2088,7 +2087,6 @@ static void writeDITemplateValueParameter(raw_ostream &Out,
Printer.printTag(N);
Printer.printString("name", N->getName());
Printer.printMetadata("type", N->getRawType());
Printer.printBool("defaulted", N->isDefault(), /* Default= */ false);
Printer.printMetadata("value", N->getValue(), /* ShouldSkipNull */ false);
Out << ")";
}

View File

@ -406,26 +406,25 @@ DIBuilder::createObjCProperty(StringRef Name, DIFile *File, unsigned LineNumber,
DITemplateTypeParameter *
DIBuilder::createTemplateTypeParameter(DIScope *Context, StringRef Name,
DIType *Ty, bool isDefault) {
DIType *Ty) {
assert((!Context || isa<DICompileUnit>(Context)) && "Expected compile unit");
return DITemplateTypeParameter::get(VMContext, Name, Ty, isDefault);
return DITemplateTypeParameter::get(VMContext, Name, Ty);
}
static DITemplateValueParameter *
createTemplateValueParameterHelper(LLVMContext &VMContext, unsigned Tag,
DIScope *Context, StringRef Name, DIType *Ty,
bool IsDefault, Metadata *MD) {
Metadata *MD) {
assert((!Context || isa<DICompileUnit>(Context)) && "Expected compile unit");
return DITemplateValueParameter::get(VMContext, Tag, Name, Ty, IsDefault, MD);
return DITemplateValueParameter::get(VMContext, Tag, Name, Ty, MD);
}
DITemplateValueParameter *
DIBuilder::createTemplateValueParameter(DIScope *Context, StringRef Name,
DIType *Ty, bool isDefault,
Constant *Val) {
DIType *Ty, Constant *Val) {
return createTemplateValueParameterHelper(
VMContext, dwarf::DW_TAG_template_value_parameter, Context, Name, Ty,
isDefault, getConstantOrNull(Val));
getConstantOrNull(Val));
}
DITemplateValueParameter *
@ -433,7 +432,7 @@ DIBuilder::createTemplateTemplateParameter(DIScope *Context, StringRef Name,
DIType *Ty, StringRef Val) {
return createTemplateValueParameterHelper(
VMContext, dwarf::DW_TAG_GNU_template_template_param, Context, Name, Ty,
false, MDString::get(VMContext, Val));
MDString::get(VMContext, Val));
}
DITemplateValueParameter *
@ -441,7 +440,7 @@ DIBuilder::createTemplateParameterPack(DIScope *Context, StringRef Name,
DIType *Ty, DINodeArray Val) {
return createTemplateValueParameterHelper(
VMContext, dwarf::DW_TAG_GNU_template_parameter_pack, Context, Name, Ty,
false, Val.get());
Val.get());
}
DICompositeType *DIBuilder::createClassType(

View File

@ -724,24 +724,24 @@ DIModule *DIModule::getImpl(LLVMContext &Context, Metadata *Scope,
DEFINE_GETIMPL_STORE_NO_CONSTRUCTOR_ARGS(DIModule, Ops);
}
DITemplateTypeParameter *
DITemplateTypeParameter::getImpl(LLVMContext &Context, MDString *Name,
Metadata *Type, bool isDefault,
StorageType Storage, bool ShouldCreate) {
DITemplateTypeParameter *DITemplateTypeParameter::getImpl(LLVMContext &Context,
MDString *Name,
Metadata *Type,
StorageType Storage,
bool ShouldCreate) {
assert(isCanonical(Name) && "Expected canonical MDString");
DEFINE_GETIMPL_LOOKUP(DITemplateTypeParameter, (Name, Type, isDefault));
DEFINE_GETIMPL_LOOKUP(DITemplateTypeParameter, (Name, Type));
Metadata *Ops[] = {Name, Type};
DEFINE_GETIMPL_STORE(DITemplateTypeParameter, (isDefault), Ops);
DEFINE_GETIMPL_STORE_NO_CONSTRUCTOR_ARGS(DITemplateTypeParameter, Ops);
}
DITemplateValueParameter *DITemplateValueParameter::getImpl(
LLVMContext &Context, unsigned Tag, MDString *Name, Metadata *Type,
bool isDefault, Metadata *Value, StorageType Storage, bool ShouldCreate) {
Metadata *Value, StorageType Storage, bool ShouldCreate) {
assert(isCanonical(Name) && "Expected canonical MDString");
DEFINE_GETIMPL_LOOKUP(DITemplateValueParameter,
(Tag, Name, Type, isDefault, Value));
DEFINE_GETIMPL_LOOKUP(DITemplateValueParameter, (Tag, Name, Type, Value));
Metadata *Ops[] = {Name, Type, Value};
DEFINE_GETIMPL_STORE(DITemplateValueParameter, (Tag, isDefault), Ops);
DEFINE_GETIMPL_STORE(DITemplateValueParameter, (Tag), Ops);
}
DIGlobalVariable *

View File

@ -843,45 +843,36 @@ template <> struct MDNodeKeyImpl<DIModule> {
template <> struct MDNodeKeyImpl<DITemplateTypeParameter> {
MDString *Name;
Metadata *Type;
bool IsDefault;
MDNodeKeyImpl(MDString *Name, Metadata *Type, bool IsDefault)
: Name(Name), Type(Type), IsDefault(IsDefault) {}
MDNodeKeyImpl(MDString *Name, Metadata *Type) : Name(Name), Type(Type) {}
MDNodeKeyImpl(const DITemplateTypeParameter *N)
: Name(N->getRawName()), Type(N->getRawType()),
IsDefault(N->isDefault()) {}
: Name(N->getRawName()), Type(N->getRawType()) {}
bool isKeyOf(const DITemplateTypeParameter *RHS) const {
return Name == RHS->getRawName() && Type == RHS->getRawType() &&
IsDefault == RHS->isDefault();
return Name == RHS->getRawName() && Type == RHS->getRawType();
}
unsigned getHashValue() const { return hash_combine(Name, Type, IsDefault); }
unsigned getHashValue() const { return hash_combine(Name, Type); }
};
template <> struct MDNodeKeyImpl<DITemplateValueParameter> {
unsigned Tag;
MDString *Name;
Metadata *Type;
bool IsDefault;
Metadata *Value;
MDNodeKeyImpl(unsigned Tag, MDString *Name, Metadata *Type, bool IsDefault,
Metadata *Value)
: Tag(Tag), Name(Name), Type(Type), IsDefault(IsDefault), Value(Value) {}
MDNodeKeyImpl(unsigned Tag, MDString *Name, Metadata *Type, Metadata *Value)
: Tag(Tag), Name(Name), Type(Type), Value(Value) {}
MDNodeKeyImpl(const DITemplateValueParameter *N)
: Tag(N->getTag()), Name(N->getRawName()), Type(N->getRawType()),
IsDefault(N->isDefault()), Value(N->getValue()) {}
Value(N->getValue()) {}
bool isKeyOf(const DITemplateValueParameter *RHS) const {
return Tag == RHS->getTag() && Name == RHS->getRawName() &&
Type == RHS->getRawType() && IsDefault == RHS->isDefault() &&
Value == RHS->getValue();
Type == RHS->getRawType() && Value == RHS->getValue();
}
unsigned getHashValue() const {
return hash_combine(Tag, Name, Type, IsDefault, Value);
}
unsigned getHashValue() const { return hash_combine(Tag, Name, Type, Value); }
};
template <> struct MDNodeKeyImpl<DIGlobalVariable> {

View File

@ -1,65 +0,0 @@
; RUN: llvm-as < %s | llvm-dis | llvm-as | llvm-dis | FileCheck %s
; RUN: verify-uselistorder %s
; ModuleID = '/dir/test.cpp'
source_filename = "test.cpp"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
%class.foo = type { i8 }
%class.foo.0 = type { i8 }
; Function Attrs: noinline norecurse nounwind optnone uwtable
define dso_local i32 @main() #0 !dbg !7 {
entry:
%retval = alloca i32, align 4
%f1 = alloca %class.foo, align 1
%f2 = alloca %class.foo.0, align 1
store i32 0, i32* %retval, align 4
call void @llvm.dbg.declare(metadata %class.foo* %f1, metadata !11, metadata !DIExpression()), !dbg !16
call void @llvm.dbg.declare(metadata %class.foo.0* %f2, metadata !17, metadata !DIExpression()), !dbg !23
ret i32 0, !dbg !24
}
; Function Attrs: nounwind readnone speculatable willreturn
declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
attributes #0 = { noinline norecurse nounwind optnone uwtable }
attributes #1 = { nounwind readnone speculatable willreturn }
!llvm.dbg.cu = !{!0}
!llvm.module.flags = !{!3, !4, !5}
!llvm.ident = !{!6}
!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, producer: "clang version 11.0.0", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, splitDebugInlining: false, nameTableKind: None)
!1 = !DIFile(filename: "test.cpp", directory: "/dir/", checksumkind: CSK_MD5, checksum: "863d08522c2300490dea873efc4b2369")
!2 = !{}
!3 = !{i32 7, !"Dwarf Version", i32 5}
!4 = !{i32 2, !"Debug Info Version", i32 3}
!5 = !{i32 1, !"wchar_size", i32 4}
!6 = !{!"clang version 11.0.0"}
!7 = distinct !DISubprogram(name: "main", scope: !1, file: !1, line: 29, type: !8, scopeLine: 29, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2)
!8 = !DISubroutineType(types: !9)
!9 = !{!10}
!10 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
!11 = !DILocalVariable(name: "f1", scope: !7, file: !1, line: 30, type: !12)
!12 = distinct !DICompositeType(tag: DW_TAG_class_type, name: "foo<int, 6>", file: !1, line: 26, size: 8, flags: DIFlagTypePassByValue, elements: !2, templateParams: !13, identifier: "_ZTS3fooIiLi6EE")
!13 = !{!14, !15}
; CHECK: 14 = !DITemplateTypeParameter(name: "T", type: !{{[0-9]*}})
!14 = !DITemplateTypeParameter(name: "T", type: !10)
; CHECK: 15 = !DITemplateValueParameter(name: "i", type: !{{[0-9]*}}, value: i32 6)
!15 = !DITemplateValueParameter(name: "i", type: !10, value: i32 6)
!16 = !DILocation(line: 30, column: 14, scope: !7)
!17 = !DILocalVariable(name: "f2", scope: !7, file: !1, line: 31, type: !18)
!18 = distinct !DICompositeType(tag: DW_TAG_class_type, name: "foo<char, 3>", file: !1, line: 26, size: 8, flags: DIFlagTypePassByValue, elements: !2, templateParams: !19, identifier: "_ZTS3fooIcLi3EE")
!19 = !{!20, !22}
; CHECK: 20 = !DITemplateTypeParameter({{.*}}, defaulted: true
!20 = !DITemplateTypeParameter(name: "T", type: !21, defaulted: true)
!21 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char)
; CHECK: 22 = !DITemplateValueParameter({{.*}}, defaulted: true
!22 = !DITemplateValueParameter(name: "i", type: !10, defaulted: true, value: i32 3)
!23 = !DILocation(line: 31, column: 9, scope: !7)
!24 = !DILocation(line: 32, column: 3, scope: !7)

View File

@ -1,69 +0,0 @@
; RUN: llvm-dis -o - %s.bc | FileCheck %s
; ModuleID = '/dir/test.cpp'
source_filename = "test.cpp"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
%class.foo = type { i8 }
%class.foo.0 = type { i8 }
; Function Attrs: noinline norecurse nounwind optnone uwtable
define dso_local i32 @main() #0 !dbg !7 {
entry:
%retval = alloca i32, align 4
%f1 = alloca %class.foo, align 1
%f2 = alloca %class.foo.0, align 1
store i32 0, i32* %retval, align 4
call void @llvm.dbg.declare(metadata %class.foo* %f1, metadata !11, metadata !DIExpression()), !dbg !16
call void @llvm.dbg.declare(metadata %class.foo.0* %f2, metadata !17, metadata !DIExpression()), !dbg !23
ret i32 0, !dbg !24
}
; Function Attrs: nounwind readnone speculatable willreturn
declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
attributes #0 = { noinline norecurse nounwind optnone uwtable }
attributes #1 = { nounwind readnone speculatable willreturn }
!llvm.dbg.cu = !{!0}
!llvm.module.flags = !{!3, !4, !5}
!llvm.ident = !{!6}
!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, producer: "clang version 11.0.0", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, splitDebugInlining: false, nameTableKind: None)
!1 = !DIFile(filename: "test.cpp", directory: "/dir/", checksumkind: CSK_MD5, checksum: "863d08522c2300490dea873efc4b2369")
!2 = !{}
!3 = !{i32 7, !"Dwarf Version", i32 5}
!4 = !{i32 2, !"Debug Info Version", i32 3}
!5 = !{i32 1, !"wchar_size", i32 4}
!6 = !{!"clang version 11.0.0"}
!7 = distinct !DISubprogram(name: "main", scope: !1, file: !1, line: 29, type: !8, scopeLine: 29, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2)
!8 = !DISubroutineType(types: !9)
!9 = !{!10}
!10 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
!11 = !DILocalVariable(name: "f1", scope: !7, file: !1, line: 30, type: !12)
!12 = distinct !DICompositeType(tag: DW_TAG_class_type, name: "foo<int, 6>", file: !1, line: 26, size: 8, flags: DIFlagTypePassByValue, elements: !2, templateParams: !13, identifier: "_ZTS3fooIiLi6EE")
!13 = !{!14, !15}
; Old-style DITemplateTypeParameter and DITemplateValueParameter should be
; upgraded to include defaulted flag.
; CHECK: !DITemplateTypeParameter({{.*}}
!14 = !DITemplateTypeParameter(name: "T", type: !10)
; CHECK: !DITemplateValueParameter({{.*}}
!15 = !DITemplateValueParameter(name: "i", type: !10, value: i32 6)
!16 = !DILocation(line: 30, column: 14, scope: !7)
!17 = !DILocalVariable(name: "f2", scope: !7, file: !1, line: 31, type: !18)
!18 = distinct !DICompositeType(tag: DW_TAG_class_type, name: "foo<char, 3>", file: !1, line: 26, size: 8, flags: DIFlagTypePassByValue, elements: !2, templateParams: !19, identifier: "_ZTS3fooIcLi3EE")
!19 = !{!20, !22}
; CHECK: !DITemplateTypeParameter({{.*}} defaulted: true
!20 = !DITemplateTypeParameter(name: "T", type: !21, defaulted: true)
!21 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char)
; CHECK: !DITemplateValueParameter({{.*}} defaulted: true
!22 = !DITemplateValueParameter(name: "i", type: !10, defaulted: true, value: i32 3)
!23 = !DILocation(line: 31, column: 9, scope: !7)
!24 = !DILocation(line: 32, column: 3, scope: !7)

View File

@ -2076,19 +2076,17 @@ typedef MetadataTest DITemplateTypeParameterTest;
TEST_F(DITemplateTypeParameterTest, get) {
StringRef Name = "template";
DIType *Type = getBasicType("basic");
bool defaulted = false;
auto *N = DITemplateTypeParameter::get(Context, Name, Type, defaulted);
auto *N = DITemplateTypeParameter::get(Context, Name, Type);
EXPECT_EQ(dwarf::DW_TAG_template_type_parameter, N->getTag());
EXPECT_EQ(Name, N->getName());
EXPECT_EQ(Type, N->getType());
EXPECT_EQ(N, DITemplateTypeParameter::get(Context, Name, Type, defaulted));
EXPECT_EQ(N, DITemplateTypeParameter::get(Context, Name, Type));
EXPECT_NE(N, DITemplateTypeParameter::get(Context, "other", Type, defaulted));
EXPECT_NE(N, DITemplateTypeParameter::get(Context, Name,
getBasicType("other"), defaulted));
EXPECT_NE(N, DITemplateTypeParameter::get(Context, Name, Type, true));
EXPECT_NE(N, DITemplateTypeParameter::get(Context, "other", Type));
EXPECT_NE(N,
DITemplateTypeParameter::get(Context, Name, getBasicType("other")));
TempDITemplateTypeParameter Temp = N->clone();
EXPECT_EQ(N, MDNode::replaceWithUniqued(std::move(Temp)));
@ -2100,31 +2098,24 @@ TEST_F(DITemplateValueParameterTest, get) {
unsigned Tag = dwarf::DW_TAG_template_value_parameter;
StringRef Name = "template";
DIType *Type = getBasicType("basic");
bool defaulted = false;
Metadata *Value = getConstantAsMetadata();
auto *N =
DITemplateValueParameter::get(Context, Tag, Name, Type, defaulted, Value);
auto *N = DITemplateValueParameter::get(Context, Tag, Name, Type, Value);
EXPECT_EQ(Tag, N->getTag());
EXPECT_EQ(Name, N->getName());
EXPECT_EQ(Type, N->getType());
EXPECT_EQ(Value, N->getValue());
EXPECT_EQ(N, DITemplateValueParameter::get(Context, Tag, Name, Type,
defaulted, Value));
EXPECT_EQ(N, DITemplateValueParameter::get(Context, Tag, Name, Type, Value));
EXPECT_NE(N, DITemplateValueParameter::get(
Context, dwarf::DW_TAG_GNU_template_template_param, Name,
Type, defaulted, Value));
EXPECT_NE(N, DITemplateValueParameter::get(Context, Tag, "other", Type,
defaulted, Value));
EXPECT_NE(N, DITemplateValueParameter::get(Context, Tag, Name,
getBasicType("other"), defaulted,
Value));
Type, Value));
EXPECT_NE(N,
DITemplateValueParameter::get(Context, Tag, Name, Type, defaulted,
getConstantAsMetadata()));
EXPECT_NE(
N, DITemplateValueParameter::get(Context, Tag, Name, Type, true, Value));
DITemplateValueParameter::get(Context, Tag, "other", Type, Value));
EXPECT_NE(N, DITemplateValueParameter::get(Context, Tag, Name,
getBasicType("other"), Value));
EXPECT_NE(N, DITemplateValueParameter::get(Context, Tag, Name, Type,
getConstantAsMetadata()));
TempDITemplateValueParameter Temp = N->clone();
EXPECT_EQ(N, MDNode::replaceWithUniqued(std::move(Temp)));