forked from OSchip/llvm-project
[DebugInfo] generate btf_tag annotations for func parameters
Generate btf_tag annotations for function parameters. A field "annotations" is introduced to DILocalVariable, and annotations are represented as an DINodeArray, similar to DIComposite elements. The following example illustrates how annotations are encoded in IR: distinct !DILocalVariable(name: "info",, arg: 1, ..., annotations: !10) !10 = !{!11, !12} !11 = !{!"btf_tag", !"a"} !12 = !{!"btf_tag", !"b"} Differential Revision: https://reviews.llvm.org/D106620
This commit is contained in:
parent
7309359928
commit
1bebc31c61
|
@ -688,7 +688,8 @@ namespace llvm {
|
|||
createParameterVariable(DIScope *Scope, StringRef Name, unsigned ArgNo,
|
||||
DIFile *File, unsigned LineNo, DIType *Ty,
|
||||
bool AlwaysPreserve = false,
|
||||
DINode::DIFlags Flags = DINode::FlagZero);
|
||||
DINode::DIFlags Flags = DINode::FlagZero,
|
||||
DINodeArray Annotations = nullptr);
|
||||
|
||||
/// Create a new descriptor for the specified
|
||||
/// variable which has a complex address expression for its address.
|
||||
|
|
|
@ -3113,34 +3113,37 @@ class DILocalVariable : public DIVariable {
|
|||
static DILocalVariable *getImpl(LLVMContext &Context, DIScope *Scope,
|
||||
StringRef Name, DIFile *File, unsigned Line,
|
||||
DIType *Type, unsigned Arg, DIFlags Flags,
|
||||
uint32_t AlignInBits, StorageType Storage,
|
||||
bool ShouldCreate = true) {
|
||||
uint32_t AlignInBits, DINodeArray Annotations,
|
||||
StorageType Storage, bool ShouldCreate = true) {
|
||||
return getImpl(Context, Scope, getCanonicalMDString(Context, Name), File,
|
||||
Line, Type, Arg, Flags, AlignInBits, Storage, ShouldCreate);
|
||||
Line, Type, Arg, Flags, AlignInBits, Annotations.get(), Storage,
|
||||
ShouldCreate);
|
||||
}
|
||||
static DILocalVariable *getImpl(LLVMContext &Context, Metadata *Scope,
|
||||
MDString *Name, Metadata *File, unsigned Line,
|
||||
Metadata *Type, unsigned Arg, DIFlags Flags,
|
||||
uint32_t AlignInBits, StorageType Storage,
|
||||
bool ShouldCreate = true);
|
||||
uint32_t AlignInBits, Metadata *Annotations,
|
||||
StorageType Storage, bool ShouldCreate = true);
|
||||
|
||||
TempDILocalVariable cloneImpl() const {
|
||||
return getTemporary(getContext(), getScope(), getName(), getFile(),
|
||||
getLine(), getType(), getArg(), getFlags(),
|
||||
getAlignInBits());
|
||||
getAlignInBits(), getAnnotations());
|
||||
}
|
||||
|
||||
public:
|
||||
DEFINE_MDNODE_GET(DILocalVariable,
|
||||
(DILocalScope * Scope, StringRef Name, DIFile *File,
|
||||
unsigned Line, DIType *Type, unsigned Arg, DIFlags Flags,
|
||||
uint32_t AlignInBits),
|
||||
(Scope, Name, File, Line, Type, Arg, Flags, AlignInBits))
|
||||
uint32_t AlignInBits, DINodeArray Annotations),
|
||||
(Scope, Name, File, Line, Type, Arg, Flags, AlignInBits,
|
||||
Annotations))
|
||||
DEFINE_MDNODE_GET(DILocalVariable,
|
||||
(Metadata * Scope, MDString *Name, Metadata *File,
|
||||
unsigned Line, Metadata *Type, unsigned Arg,
|
||||
DIFlags Flags, uint32_t AlignInBits),
|
||||
(Scope, Name, File, Line, Type, Arg, Flags, AlignInBits))
|
||||
DIFlags Flags, uint32_t AlignInBits, Metadata *Annotations),
|
||||
(Scope, Name, File, Line, Type, Arg, Flags, AlignInBits,
|
||||
Annotations))
|
||||
|
||||
TempDILocalVariable clone() const { return cloneImpl(); }
|
||||
|
||||
|
@ -3155,6 +3158,11 @@ public:
|
|||
unsigned getArg() const { return Arg; }
|
||||
DIFlags getFlags() const { return Flags; }
|
||||
|
||||
DINodeArray getAnnotations() const {
|
||||
return cast_or_null<MDTuple>(getRawAnnotations());
|
||||
}
|
||||
Metadata *getRawAnnotations() const { return getOperand(4); }
|
||||
|
||||
bool isArtificial() const { return getFlags() & FlagArtificial; }
|
||||
bool isObjectPointer() const { return getFlags() & FlagObjectPointer; }
|
||||
|
||||
|
|
|
@ -4976,13 +4976,15 @@ bool LLParser::parseDILocalVariable(MDNode *&Result, bool IsDistinct) {
|
|||
OPTIONAL(line, LineField, ); \
|
||||
OPTIONAL(type, MDField, ); \
|
||||
OPTIONAL(flags, DIFlagField, ); \
|
||||
OPTIONAL(align, MDUnsignedField, (0, UINT32_MAX));
|
||||
OPTIONAL(align, MDUnsignedField, (0, UINT32_MAX)); \
|
||||
OPTIONAL(annotations, MDField, );
|
||||
PARSE_MD_FIELDS();
|
||||
#undef VISIT_MD_FIELDS
|
||||
|
||||
Result = GET_OR_DISTINCT(DILocalVariable,
|
||||
(Context, scope.Val, name.Val, file.Val, line.Val,
|
||||
type.Val, arg.Val, flags.Val, align.Val));
|
||||
type.Val, arg.Val, flags.Val, align.Val,
|
||||
annotations.Val));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -1961,18 +1961,23 @@ Error MetadataLoader::MetadataLoaderImpl::parseOneMetadata(
|
|||
bool HasTag = !HasAlignment && Record.size() > 8;
|
||||
DINode::DIFlags Flags = static_cast<DINode::DIFlags>(Record[7 + HasTag]);
|
||||
uint32_t AlignInBits = 0;
|
||||
Metadata *Annotations = nullptr;
|
||||
if (HasAlignment) {
|
||||
if (Record[8 + HasTag] > (uint64_t)std::numeric_limits<uint32_t>::max())
|
||||
if (Record[8] > (uint64_t)std::numeric_limits<uint32_t>::max())
|
||||
return error("Alignment value is too large");
|
||||
AlignInBits = Record[8 + HasTag];
|
||||
AlignInBits = Record[8];
|
||||
if (Record.size() > 9)
|
||||
Annotations = getMDOrNull(Record[9]);
|
||||
}
|
||||
|
||||
MetadataList.assignValue(
|
||||
GET_OR_DISTINCT(DILocalVariable,
|
||||
(Context, getMDOrNull(Record[1 + HasTag]),
|
||||
getMDString(Record[2 + HasTag]),
|
||||
getMDOrNull(Record[3 + HasTag]), Record[4 + HasTag],
|
||||
getDITypeRefOrNull(Record[5 + HasTag]),
|
||||
Record[6 + HasTag], Flags, AlignInBits)),
|
||||
Record[6 + HasTag], Flags, AlignInBits,
|
||||
Annotations)),
|
||||
NextMetadataNo);
|
||||
NextMetadataNo++;
|
||||
break;
|
||||
|
|
|
@ -1994,6 +1994,7 @@ void ModuleBitcodeWriter::writeDILocalVariable(
|
|||
Record.push_back(N->getArg());
|
||||
Record.push_back(N->getFlags());
|
||||
Record.push_back(N->getAlignInBits());
|
||||
Record.push_back(VE.getMetadataOrNullID(N->getAnnotations().get()));
|
||||
|
||||
Stream.EmitRecord(bitc::METADATA_LOCAL_VAR, Record, Abbrev);
|
||||
Record.clear();
|
||||
|
|
|
@ -2316,6 +2316,7 @@ static void writeDILocalVariable(raw_ostream &Out, const DILocalVariable *N,
|
|||
Printer.printMetadata("type", N->getRawType());
|
||||
Printer.printDIFlags("flags", N->getFlags());
|
||||
Printer.printInt("align", N->getAlignInBits());
|
||||
Printer.printMetadata("annotations", N->getRawAnnotations());
|
||||
Out << ")";
|
||||
}
|
||||
|
||||
|
|
|
@ -739,7 +739,7 @@ static DILocalVariable *createLocalVariable(
|
|||
DenseMap<MDNode *, SmallVector<TrackingMDNodeRef, 1>> &PreservedVariables,
|
||||
DIScope *Scope, StringRef Name, unsigned ArgNo, DIFile *File,
|
||||
unsigned LineNo, DIType *Ty, bool AlwaysPreserve, DINode::DIFlags Flags,
|
||||
uint32_t AlignInBits) {
|
||||
uint32_t AlignInBits, DINodeArray Annotations = nullptr) {
|
||||
// FIXME: Why getNonCompileUnitScope()?
|
||||
// FIXME: Why is "!Context" okay here?
|
||||
// FIXME: Why doesn't this check for a subprogram or lexical block (AFAICT
|
||||
|
@ -748,7 +748,8 @@ static DILocalVariable *createLocalVariable(
|
|||
|
||||
auto *Node =
|
||||
DILocalVariable::get(VMContext, cast_or_null<DILocalScope>(Context), Name,
|
||||
File, LineNo, Ty, ArgNo, Flags, AlignInBits);
|
||||
File, LineNo, Ty, ArgNo, Flags, AlignInBits,
|
||||
Annotations);
|
||||
if (AlwaysPreserve) {
|
||||
// The optimizer may remove local variables. If there is an interest
|
||||
// to preserve variable info in such situation then stash it in a
|
||||
|
@ -772,11 +773,12 @@ DILocalVariable *DIBuilder::createAutoVariable(DIScope *Scope, StringRef Name,
|
|||
|
||||
DILocalVariable *DIBuilder::createParameterVariable(
|
||||
DIScope *Scope, StringRef Name, unsigned ArgNo, DIFile *File,
|
||||
unsigned LineNo, DIType *Ty, bool AlwaysPreserve, DINode::DIFlags Flags) {
|
||||
unsigned LineNo, DIType *Ty, bool AlwaysPreserve, DINode::DIFlags Flags,
|
||||
DINodeArray Annotations) {
|
||||
assert(ArgNo && "Expected non-zero argument number for parameter");
|
||||
return createLocalVariable(VMContext, PreservedVariables, Scope, Name, ArgNo,
|
||||
File, LineNo, Ty, AlwaysPreserve, Flags,
|
||||
/* AlignInBits */0);
|
||||
/* AlignInBits */0, Annotations);
|
||||
}
|
||||
|
||||
DILabel *DIBuilder::createLabel(
|
||||
|
|
|
@ -1011,6 +1011,7 @@ DILocalVariable *DILocalVariable::getImpl(LLVMContext &Context, Metadata *Scope,
|
|||
unsigned Line, Metadata *Type,
|
||||
unsigned Arg, DIFlags Flags,
|
||||
uint32_t AlignInBits,
|
||||
Metadata *Annotations,
|
||||
StorageType Storage,
|
||||
bool ShouldCreate) {
|
||||
// 64K ought to be enough for any frontend.
|
||||
|
@ -1020,8 +1021,8 @@ DILocalVariable *DILocalVariable::getImpl(LLVMContext &Context, Metadata *Scope,
|
|||
assert(isCanonical(Name) && "Expected canonical MDString");
|
||||
DEFINE_GETIMPL_LOOKUP(DILocalVariable,
|
||||
(Scope, Name, File, Line, Type, Arg, Flags,
|
||||
AlignInBits));
|
||||
Metadata *Ops[] = {Scope, Name, File, Type};
|
||||
AlignInBits, Annotations));
|
||||
Metadata *Ops[] = {Scope, Name, File, Type, Annotations};
|
||||
DEFINE_GETIMPL_STORE(DILocalVariable, (Line, Arg, Flags, AlignInBits), Ops);
|
||||
}
|
||||
|
||||
|
|
|
@ -1042,22 +1042,25 @@ template <> struct MDNodeKeyImpl<DILocalVariable> {
|
|||
unsigned Arg;
|
||||
unsigned Flags;
|
||||
uint32_t AlignInBits;
|
||||
Metadata *Annotations;
|
||||
|
||||
MDNodeKeyImpl(Metadata *Scope, MDString *Name, Metadata *File, unsigned Line,
|
||||
Metadata *Type, unsigned Arg, unsigned Flags,
|
||||
uint32_t AlignInBits)
|
||||
uint32_t AlignInBits, Metadata *Annotations)
|
||||
: Scope(Scope), Name(Name), File(File), Line(Line), Type(Type), Arg(Arg),
|
||||
Flags(Flags), AlignInBits(AlignInBits) {}
|
||||
Flags(Flags), AlignInBits(AlignInBits), Annotations(Annotations) {}
|
||||
MDNodeKeyImpl(const DILocalVariable *N)
|
||||
: Scope(N->getRawScope()), Name(N->getRawName()), File(N->getRawFile()),
|
||||
Line(N->getLine()), Type(N->getRawType()), Arg(N->getArg()),
|
||||
Flags(N->getFlags()), AlignInBits(N->getAlignInBits()) {}
|
||||
Flags(N->getFlags()), AlignInBits(N->getAlignInBits()),
|
||||
Annotations(N->getRawAnnotations()) {}
|
||||
|
||||
bool isKeyOf(const DILocalVariable *RHS) const {
|
||||
return Scope == RHS->getRawScope() && Name == RHS->getRawName() &&
|
||||
File == RHS->getRawFile() && Line == RHS->getLine() &&
|
||||
Type == RHS->getRawType() && Arg == RHS->getArg() &&
|
||||
Flags == RHS->getFlags() && AlignInBits == RHS->getAlignInBits();
|
||||
Flags == RHS->getFlags() && AlignInBits == RHS->getAlignInBits() &&
|
||||
Annotations == RHS->getRawAnnotations();
|
||||
}
|
||||
|
||||
unsigned getHashValue() const {
|
||||
|
@ -1068,7 +1071,7 @@ template <> struct MDNodeKeyImpl<DILocalVariable> {
|
|||
// clang/test/CodeGen/debug-info-257-args.c is an example of this problem,
|
||||
// generated IR is random for each run and test fails with Align included.
|
||||
// TODO: make hashing work fine with such situations
|
||||
return hash_combine(Scope, Name, File, Line, Type, Arg, Flags);
|
||||
return hash_combine(Scope, Name, File, Line, Type, Arg, Flags, Annotations);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -0,0 +1,46 @@
|
|||
; REQUIRES: x86-registered-target
|
||||
; RUN: llvm-as < %s | llvm-dis | FileCheck %s
|
||||
|
||||
; Function Attrs: mustprogress nofree norecurse nosync nounwind readnone uwtable willreturn
|
||||
define dso_local i32 @f(i32 %a) local_unnamed_addr #0 !dbg !8 {
|
||||
entry:
|
||||
call void @llvm.dbg.value(metadata i32 %a, metadata !13, metadata !DIExpression()), !dbg !17
|
||||
ret i32 0, !dbg !18
|
||||
}
|
||||
|
||||
; Function Attrs: nofree nosync nounwind readnone speculatable willreturn
|
||||
declare void @llvm.dbg.value(metadata, metadata, metadata) #1
|
||||
|
||||
attributes #0 = { mustprogress nofree norecurse nosync nounwind readnone uwtable willreturn "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
|
||||
attributes #1 = { nofree nosync nounwind readnone speculatable willreturn }
|
||||
|
||||
!llvm.dbg.cu = !{!0}
|
||||
!llvm.module.flags = !{!3, !4, !5, !6}
|
||||
!llvm.ident = !{!7}
|
||||
|
||||
!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 13.0.0 (https://github.com/llvm/llvm-project.git c9e3139e00bcef23b236a02890b909a130d1b3d9)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, splitDebugInlining: false, nameTableKind: None)
|
||||
!1 = !DIFile(filename: "func.c", directory: "/home/yhs/work/tests/llvm/btf_tag")
|
||||
!2 = !{}
|
||||
!3 = !{i32 7, !"Dwarf Version", i32 4}
|
||||
!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 (https://github.com/llvm/llvm-project.git c9e3139e00bcef23b236a02890b909a130d1b3d9)"}
|
||||
!8 = distinct !DISubprogram(name: "f", scope: !1, file: !1, line: 1, type: !9, scopeLine: 1, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !12)
|
||||
!9 = !DISubroutineType(types: !10)
|
||||
!10 = !{!11, !11}
|
||||
!11 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
|
||||
!12 = !{!13}
|
||||
!13 = !DILocalVariable(name: "a", arg: 1, scope: !8, file: !1, line: 1, type: !11, annotations: !14)
|
||||
!14 = !{!15, !16}
|
||||
!15 = !{!"btf_tag", !"a"}
|
||||
!16 = !{!"btf_tag", !"b"}
|
||||
|
||||
; CHECK: !DILocalVariable(name: "a", arg: 1,
|
||||
; CHECK-SAME: annotations: ![[ANNOT:[0-9]+]]
|
||||
; CHECK: ![[ANNOT]] = !{![[TAG1:[0-9]+]], ![[TAG2:[0-9]+]]}
|
||||
; CHECK: ![[TAG1]] = !{!"btf_tag", !"a"}
|
||||
; CHECK: ![[TAG2]] = !{!"btf_tag", !"b"}
|
||||
|
||||
!17 = !DILocation(line: 0, scope: !8)
|
||||
!18 = !DILocation(line: 1, column: 76, scope: !8)
|
|
@ -1171,7 +1171,7 @@ TEST_F(DISubrangeTest, getVariableCount) {
|
|||
DIType *Type = getDerivedType();
|
||||
DINode::DIFlags Flags = static_cast<DINode::DIFlags>(7);
|
||||
auto *VlaExpr = DILocalVariable::get(Context, Scope, "vla_expr", File, 8,
|
||||
Type, 2, Flags, 8);
|
||||
Type, 2, Flags, 8, nullptr);
|
||||
|
||||
auto *N = DISubrange::get(Context, VlaExpr, 0);
|
||||
auto Count = N->getCount();
|
||||
|
@ -1199,7 +1199,7 @@ TEST_F(DISubrangeTest, fortranAllocatableInt) {
|
|||
auto *UIother = ConstantAsMetadata::get(
|
||||
ConstantInt::getSigned(Type::getInt64Ty(Context), 20));
|
||||
auto *UVother = DILocalVariable::get(Context, Scope, "ubother", File, 8, Type,
|
||||
2, Flags, 8);
|
||||
2, Flags, 8, nullptr);
|
||||
auto *UEother = DIExpression::get(Context, {5, 6});
|
||||
auto *LIZero = ConstantAsMetadata::get(
|
||||
ConstantInt::getSigned(Type::getInt64Ty(Context), 0));
|
||||
|
@ -1242,13 +1242,16 @@ TEST_F(DISubrangeTest, fortranAllocatableVar) {
|
|||
DIType *Type = getDerivedType();
|
||||
DINode::DIFlags Flags = static_cast<DINode::DIFlags>(7);
|
||||
auto *LV =
|
||||
DILocalVariable::get(Context, Scope, "lb", File, 8, Type, 2, Flags, 8);
|
||||
DILocalVariable::get(Context, Scope, "lb", File, 8, Type, 2, Flags, 8,
|
||||
nullptr);
|
||||
auto *UV =
|
||||
DILocalVariable::get(Context, Scope, "ub", File, 8, Type, 2, Flags, 8);
|
||||
DILocalVariable::get(Context, Scope, "ub", File, 8, Type, 2, Flags, 8,
|
||||
nullptr);
|
||||
auto *SV =
|
||||
DILocalVariable::get(Context, Scope, "st", File, 8, Type, 2, Flags, 8);
|
||||
DILocalVariable::get(Context, Scope, "st", File, 8, Type, 2, Flags, 8,
|
||||
nullptr);
|
||||
auto *SVother = DILocalVariable::get(Context, Scope, "stother", File, 8, Type,
|
||||
2, Flags, 8);
|
||||
2, Flags, 8, nullptr);
|
||||
auto *SIother = ConstantAsMetadata::get(
|
||||
ConstantInt::getSigned(Type::getInt64Ty(Context), 20));
|
||||
auto *SEother = DIExpression::get(Context, {5, 6});
|
||||
|
@ -1289,7 +1292,7 @@ TEST_F(DISubrangeTest, fortranAllocatableExpr) {
|
|||
auto *LIother = ConstantAsMetadata::get(
|
||||
ConstantInt::getSigned(Type::getInt64Ty(Context), 20));
|
||||
auto *LVother = DILocalVariable::get(Context, Scope, "lbother", File, 8, Type,
|
||||
2, Flags, 8);
|
||||
2, Flags, 8, nullptr);
|
||||
|
||||
auto *N = DISubrange::get(Context, nullptr, LE, UE, SE);
|
||||
|
||||
|
@ -1328,7 +1331,7 @@ TEST_F(DIGenericSubrangeTest, fortranAssumedRankInt) {
|
|||
auto *SI = DIExpression::get(Context, {dwarf::DW_OP_consts, 4});
|
||||
auto *UIother = DIExpression::get(Context, {dwarf::DW_OP_consts, 20});
|
||||
auto *UVother = DILocalVariable::get(Context, Scope, "ubother", File, 8, Type,
|
||||
2, Flags, 8);
|
||||
2, Flags, 8, nullptr);
|
||||
auto *UEother = DIExpression::get(Context, {5, 6});
|
||||
auto *LIZero = DIExpression::get(Context, {dwarf::DW_OP_consts, 0});
|
||||
auto *UIZero = DIExpression::get(Context, {dwarf::DW_OP_consts, 0});
|
||||
|
@ -1371,13 +1374,16 @@ TEST_F(DIGenericSubrangeTest, fortranAssumedRankVar) {
|
|||
DIType *Type = getDerivedType();
|
||||
DINode::DIFlags Flags = static_cast<DINode::DIFlags>(7);
|
||||
auto *LV =
|
||||
DILocalVariable::get(Context, Scope, "lb", File, 8, Type, 2, Flags, 8);
|
||||
DILocalVariable::get(Context, Scope, "lb", File, 8, Type, 2, Flags, 8,
|
||||
nullptr);
|
||||
auto *UV =
|
||||
DILocalVariable::get(Context, Scope, "ub", File, 8, Type, 2, Flags, 8);
|
||||
DILocalVariable::get(Context, Scope, "ub", File, 8, Type, 2, Flags, 8,
|
||||
nullptr);
|
||||
auto *SV =
|
||||
DILocalVariable::get(Context, Scope, "st", File, 8, Type, 2, Flags, 8);
|
||||
DILocalVariable::get(Context, Scope, "st", File, 8, Type, 2, Flags, 8,
|
||||
nullptr);
|
||||
auto *SVother = DILocalVariable::get(Context, Scope, "stother", File, 8, Type,
|
||||
2, Flags, 8);
|
||||
2, Flags, 8, nullptr);
|
||||
auto *SIother = DIExpression::get(
|
||||
Context, {dwarf::DW_OP_consts, static_cast<uint64_t>(-1)});
|
||||
auto *SEother = DIExpression::get(Context, {5, 6});
|
||||
|
@ -1412,12 +1418,12 @@ TEST_F(DIGenericSubrangeTest, useDIBuilder) {
|
|||
DIType *Type = getDerivedType();
|
||||
DINode::DIFlags Flags = static_cast<DINode::DIFlags>(7);
|
||||
auto *LV =
|
||||
DILocalVariable::get(Context, Scope, "lb", File, 8, Type, 2, Flags, 8);
|
||||
DILocalVariable::get(Context, Scope, "lb", File, 8, Type, 2, Flags, 8, nullptr);
|
||||
auto *UE = DIExpression::get(Context, {2, 3});
|
||||
auto *SE = DIExpression::get(Context, {3, 4});
|
||||
|
||||
auto *LVother = DILocalVariable::get(Context, Scope, "lbother", File, 8, Type,
|
||||
2, Flags, 8);
|
||||
2, Flags, 8, nullptr);
|
||||
auto *LIother = DIExpression::get(
|
||||
Context, {dwarf::DW_OP_consts, static_cast<uint64_t>(-1)});
|
||||
|
||||
|
@ -1917,9 +1923,9 @@ TEST_F(DICompositeTypeTest, dynamicArray) {
|
|||
StringRef Identifier = "some id";
|
||||
DIType *Type = getDerivedType();
|
||||
Metadata *DlVar1 = DILocalVariable::get(Context, Scope, "dl_var1", File, 8,
|
||||
Type, 2, Flags, 8);
|
||||
Type, 2, Flags, 8, nullptr);
|
||||
Metadata *DlVar2 = DILocalVariable::get(Context, Scope, "dl_var2", File, 8,
|
||||
Type, 2, Flags, 8);
|
||||
Type, 2, Flags, 8, nullptr);
|
||||
uint64_t Elements1[] = {dwarf::DW_OP_push_object_address, dwarf::DW_OP_deref};
|
||||
Metadata *DataLocation1 = DIExpression::get(Context, Elements1);
|
||||
|
||||
|
@ -2697,7 +2703,7 @@ TEST_F(DILocalVariableTest, get) {
|
|||
|
||||
auto *N =
|
||||
DILocalVariable::get(Context, Scope, Name, File, Line, Type, Arg, Flags,
|
||||
AlignInBits);
|
||||
AlignInBits, nullptr);
|
||||
EXPECT_TRUE(N->isParameter());
|
||||
EXPECT_EQ(Scope, N->getScope());
|
||||
EXPECT_EQ(Name, N->getName());
|
||||
|
@ -2708,25 +2714,26 @@ TEST_F(DILocalVariableTest, get) {
|
|||
EXPECT_EQ(Flags, N->getFlags());
|
||||
EXPECT_EQ(AlignInBits, N->getAlignInBits());
|
||||
EXPECT_EQ(N, DILocalVariable::get(Context, Scope, Name, File, Line, Type, Arg,
|
||||
Flags, AlignInBits));
|
||||
Flags, AlignInBits, nullptr));
|
||||
|
||||
EXPECT_FALSE(
|
||||
DILocalVariable::get(Context, Scope, Name, File, Line, Type, 0, Flags,
|
||||
AlignInBits)->isParameter());
|
||||
AlignInBits, nullptr)->isParameter());
|
||||
EXPECT_NE(N, DILocalVariable::get(Context, getSubprogram(), Name, File, Line,
|
||||
Type, Arg, Flags, AlignInBits));
|
||||
Type, Arg, Flags, AlignInBits, nullptr));
|
||||
EXPECT_NE(N, DILocalVariable::get(Context, Scope, "other", File, Line, Type,
|
||||
Arg, Flags, AlignInBits));
|
||||
Arg, Flags, AlignInBits, nullptr));
|
||||
EXPECT_NE(N, DILocalVariable::get(Context, Scope, Name, getFile(), Line, Type,
|
||||
Arg, Flags, AlignInBits));
|
||||
Arg, Flags, AlignInBits, nullptr));
|
||||
EXPECT_NE(N, DILocalVariable::get(Context, Scope, Name, File, Line + 1, Type,
|
||||
Arg, Flags, AlignInBits));
|
||||
Arg, Flags, AlignInBits, nullptr));
|
||||
EXPECT_NE(N, DILocalVariable::get(Context, Scope, Name, File, Line,
|
||||
getDerivedType(), Arg, Flags, AlignInBits));
|
||||
getDerivedType(), Arg, Flags, AlignInBits,
|
||||
nullptr));
|
||||
EXPECT_NE(N, DILocalVariable::get(Context, Scope, Name, File, Line, Type,
|
||||
Arg + 1, Flags, AlignInBits));
|
||||
Arg + 1, Flags, AlignInBits, nullptr));
|
||||
EXPECT_NE(N, DILocalVariable::get(Context, Scope, Name, File, Line, Type,
|
||||
Arg, Flags, (AlignInBits << 1)));
|
||||
Arg, Flags, (AlignInBits << 1), nullptr));
|
||||
|
||||
TempDILocalVariable Temp = N->clone();
|
||||
EXPECT_EQ(N, MDNode::replaceWithUniqued(std::move(Temp)));
|
||||
|
@ -2734,17 +2741,21 @@ TEST_F(DILocalVariableTest, get) {
|
|||
|
||||
TEST_F(DILocalVariableTest, getArg256) {
|
||||
EXPECT_EQ(255u, DILocalVariable::get(Context, getSubprogram(), "", getFile(),
|
||||
0, nullptr, 255, DINode::FlagZero, 0)
|
||||
0, nullptr, 255, DINode::FlagZero, 0,
|
||||
nullptr)
|
||||
->getArg());
|
||||
EXPECT_EQ(256u, DILocalVariable::get(Context, getSubprogram(), "", getFile(),
|
||||
0, nullptr, 256, DINode::FlagZero, 0)
|
||||
0, nullptr, 256, DINode::FlagZero, 0,
|
||||
nullptr)
|
||||
->getArg());
|
||||
EXPECT_EQ(257u, DILocalVariable::get(Context, getSubprogram(), "", getFile(),
|
||||
0, nullptr, 257, DINode::FlagZero, 0)
|
||||
0, nullptr, 257, DINode::FlagZero, 0,
|
||||
nullptr)
|
||||
->getArg());
|
||||
unsigned Max = UINT16_MAX;
|
||||
EXPECT_EQ(Max, DILocalVariable::get(Context, getSubprogram(), "", getFile(),
|
||||
0, nullptr, Max, DINode::FlagZero, 0)
|
||||
0, nullptr, Max, DINode::FlagZero, 0,
|
||||
nullptr)
|
||||
->getArg());
|
||||
}
|
||||
|
||||
|
@ -3456,9 +3467,9 @@ TEST_F(DebugVariableTest, DenseMap) {
|
|||
DILocation *InlinedLoc = DILocation::get(Context, 2, 7, Scope);
|
||||
|
||||
DILocalVariable *VarA =
|
||||
DILocalVariable::get(Context, Scope, "A", File, 5, Type, 2, Flags, 8);
|
||||
DILocalVariable::get(Context, Scope, "A", File, 5, Type, 2, Flags, 8, nullptr);
|
||||
DILocalVariable *VarB =
|
||||
DILocalVariable::get(Context, Scope, "B", File, 7, Type, 3, Flags, 8);
|
||||
DILocalVariable::get(Context, Scope, "B", File, 7, Type, 3, Flags, 8, nullptr);
|
||||
|
||||
DebugVariable DebugVariableA(VarA, NoneType(), nullptr);
|
||||
DebugVariable DebugVariableInlineA(VarA, NoneType(), InlinedLoc);
|
||||
|
|
Loading…
Reference in New Issue