IR: Remove unnecessary fields from MDTemplateParameter

I noticed this fields were never used in r228607, but I neglected to
propagate that into `MDTemplateParameter` until now.  This really should
have been done before commit in r228640; sorry for the churn.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@228652 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Duncan P. N. Exon Smith 2015-02-10 01:59:57 +00:00
parent 27f4f37b97
commit 3740ae4600
4 changed files with 72 additions and 134 deletions

View File

@ -1096,24 +1096,16 @@ public:
/// TODO: Remove File, Line and Column. They're always 0 and never /// TODO: Remove File, Line and Column. They're always 0 and never
/// referenced. /// referenced.
class MDTemplateParameter : public DebugNode { class MDTemplateParameter : public DebugNode {
unsigned Line;
unsigned Column;
protected: protected:
MDTemplateParameter(LLVMContext &Context, unsigned ID, StorageType Storage, MDTemplateParameter(LLVMContext &Context, unsigned ID, StorageType Storage,
unsigned Tag, unsigned Line, unsigned Column, unsigned Tag, ArrayRef<Metadata *> Ops)
ArrayRef<Metadata *> Ops) : DebugNode(Context, ID, Storage, Tag, Ops) {}
: DebugNode(Context, ID, Storage, Tag, Ops), Line(Line), Column(Column) {}
~MDTemplateParameter() {} ~MDTemplateParameter() {}
public: public:
unsigned getLine() const { return Line; } Metadata *getScope() const { return getOperand(0); }
unsigned getColumn() const { return Column; } StringRef getName() const { return getStringOperand(1); }
Metadata *getType() const { return getOperand(2); }
Metadata *getFile() const { return getOperand(0); }
Metadata *getScope() const { return getOperand(1); }
StringRef getName() const { return getStringOperand(2); }
Metadata *getType() const { return getOperand(3); }
static bool classof(const Metadata *MD) { static bool classof(const Metadata *MD) {
return MD->getMetadataID() == MDTemplateTypeParameterKind || return MD->getMetadataID() == MDTemplateTypeParameterKind ||
@ -1126,43 +1118,34 @@ class MDTemplateTypeParameter : public MDTemplateParameter {
friend class MDNode; friend class MDNode;
MDTemplateTypeParameter(LLVMContext &Context, StorageType Storage, MDTemplateTypeParameter(LLVMContext &Context, StorageType Storage,
unsigned Line, unsigned Column,
ArrayRef<Metadata *> Ops) ArrayRef<Metadata *> Ops)
: MDTemplateParameter(Context, MDTemplateTypeParameterKind, Storage, : MDTemplateParameter(Context, MDTemplateTypeParameterKind, Storage,
dwarf::DW_TAG_template_type_parameter, Line, Column, dwarf::DW_TAG_template_type_parameter, Ops) {}
Ops) {}
~MDTemplateTypeParameter() {} ~MDTemplateTypeParameter() {}
static MDTemplateTypeParameter *getImpl(LLVMContext &Context, Metadata *Scope, static MDTemplateTypeParameter *getImpl(LLVMContext &Context, Metadata *Scope,
StringRef Name, Metadata *Type, StringRef Name, Metadata *Type,
Metadata *File, unsigned Line, StorageType Storage,
unsigned Column, StorageType Storage,
bool ShouldCreate = true) { bool ShouldCreate = true) {
return getImpl(Context, Scope, getCanonicalMDString(Context, Name), Type, return getImpl(Context, Scope, getCanonicalMDString(Context, Name), Type,
File, Line, Column, Storage, ShouldCreate); Storage, ShouldCreate);
} }
static MDTemplateTypeParameter *getImpl(LLVMContext &Context, Metadata *Scope, static MDTemplateTypeParameter *getImpl(LLVMContext &Context, Metadata *Scope,
MDString *Name, Metadata *Type, MDString *Name, Metadata *Type,
Metadata *File, unsigned Line, StorageType Storage,
unsigned Column, StorageType Storage,
bool ShouldCreate = true); bool ShouldCreate = true);
TempMDTemplateTypeParameter cloneImpl() const { TempMDTemplateTypeParameter cloneImpl() const {
return getTemporary(getContext(), getScope(), getName(), getType(), return getTemporary(getContext(), getScope(), getName(), getType());
getFile(), getLine(), getColumn());
} }
public: public:
DEFINE_MDNODE_GET(MDTemplateTypeParameter, DEFINE_MDNODE_GET(MDTemplateTypeParameter,
(Metadata * Scope, StringRef Name, Metadata *Type, (Metadata * Scope, StringRef Name, Metadata *Type),
Metadata *File = nullptr, unsigned Line = 0, (Scope, Name, Type))
unsigned Column = 0),
(Scope, Name, Type, File, Line, Column))
DEFINE_MDNODE_GET(MDTemplateTypeParameter, DEFINE_MDNODE_GET(MDTemplateTypeParameter,
(Metadata * Scope, MDString *Name, Metadata *Type, (Metadata * Scope, MDString *Name, Metadata *Type),
Metadata *File = nullptr, unsigned Line = 0, (Scope, Name, Type))
unsigned Column = 0),
(Scope, Name, Type, File, Line, Column))
TempMDTemplateTypeParameter clone() const { return cloneImpl(); } TempMDTemplateTypeParameter clone() const { return cloneImpl(); }
@ -1176,43 +1159,41 @@ class MDTemplateValueParameter : public MDTemplateParameter {
friend class MDNode; friend class MDNode;
MDTemplateValueParameter(LLVMContext &Context, StorageType Storage, MDTemplateValueParameter(LLVMContext &Context, StorageType Storage,
unsigned Tag, unsigned Line, unsigned Column, unsigned Tag, ArrayRef<Metadata *> Ops)
ArrayRef<Metadata *> Ops)
: MDTemplateParameter(Context, MDTemplateValueParameterKind, Storage, Tag, : MDTemplateParameter(Context, MDTemplateValueParameterKind, Storage, Tag,
Line, Column, Ops) {} Ops) {}
~MDTemplateValueParameter() {} ~MDTemplateValueParameter() {}
static MDTemplateValueParameter * static MDTemplateValueParameter *getImpl(LLVMContext &Context, unsigned Tag,
getImpl(LLVMContext &Context, unsigned Tag, Metadata *Scope, StringRef Name, Metadata *Scope, StringRef Name,
Metadata *Type, Metadata *Value, Metadata *File, unsigned Line, Metadata *Type, Metadata *Value,
unsigned Column, StorageType Storage, bool ShouldCreate = true) { StorageType Storage,
bool ShouldCreate = true) {
return getImpl(Context, Tag, Scope, getCanonicalMDString(Context, Name), return getImpl(Context, Tag, Scope, getCanonicalMDString(Context, Name),
Type, Value, File, Line, Column, Storage, ShouldCreate); Type, Value, Storage, ShouldCreate);
} }
static MDTemplateValueParameter * static MDTemplateValueParameter *getImpl(LLVMContext &Context, unsigned Tag,
getImpl(LLVMContext &Context, unsigned Tag, Metadata *Scope, MDString *Name, Metadata *Scope, MDString *Name,
Metadata *Type, Metadata *Value, Metadata *File, unsigned Line, Metadata *Type, Metadata *Value,
unsigned Column, StorageType Storage, bool ShouldCreate = true); StorageType Storage,
bool ShouldCreate = true);
TempMDTemplateValueParameter cloneImpl() const { TempMDTemplateValueParameter cloneImpl() const {
return getTemporary(getContext(), getTag(), getScope(), getName(), return getTemporary(getContext(), getTag(), getScope(), getName(),
getType(), getValue(), getFile(), getLine(), getType(), getValue());
getColumn());
} }
public: public:
DEFINE_MDNODE_GET(MDTemplateValueParameter, DEFINE_MDNODE_GET(MDTemplateValueParameter,
(unsigned Tag, Metadata *Scope, StringRef Name, (unsigned Tag, Metadata *Scope, StringRef Name,
Metadata *Type, Metadata *Value, Metadata *File = nullptr, Metadata *Type, Metadata *Value),
unsigned Line = 0, unsigned Column = 0), (Tag, Scope, Name, Type, Value))
(Tag, Scope, Name, Type, Value, File, Line, Column))
DEFINE_MDNODE_GET(MDTemplateValueParameter, DEFINE_MDNODE_GET(MDTemplateValueParameter,
(unsigned Tag, Metadata *Scope, MDString *Name, (unsigned Tag, Metadata *Scope, MDString *Name,
Metadata *Type, Metadata *Value, Metadata *File = nullptr, Metadata *Type, Metadata *Value),
unsigned Line = 0, unsigned Column = 0), (Tag, Scope, Name, Type, Value))
(Tag, Scope, Name, Type, Value, File, Line, Column))
Metadata *getValue() const { return getOperand(4); } Metadata *getValue() const { return getOperand(3); }
static bool classof(const Metadata *MD) { static bool classof(const Metadata *MD) {
return MD->getMetadataID() == MDTemplateValueParameterKind; return MD->getMetadataID() == MDTemplateValueParameterKind;

View File

@ -126,6 +126,10 @@ void GenericDebugNode::recalculateHash() {
#define DEFINE_GETIMPL_STORE_NO_OPS(CLASS, ARGS) \ #define DEFINE_GETIMPL_STORE_NO_OPS(CLASS, ARGS) \
return storeImpl(new (0u) CLASS(Context, Storage, UNWRAP_ARGS(ARGS)), \ return storeImpl(new (0u) CLASS(Context, Storage, UNWRAP_ARGS(ARGS)), \
Storage, Context.pImpl->CLASS##s) Storage, Context.pImpl->CLASS##s)
#define DEFINE_GETIMPL_STORE_NO_CONSTRUCTOR_ARGS(CLASS, OPS) \
return storeImpl(new (ArrayRef<Metadata *>(OPS).size()) \
CLASS(Context, Storage, OPS), \
Storage, Context.pImpl->CLASS##s)
MDSubrange *MDSubrange::getImpl(LLVMContext &Context, int64_t Count, int64_t Lo, MDSubrange *MDSubrange::getImpl(LLVMContext &Context, int64_t Count, int64_t Lo,
StorageType Storage, bool ShouldCreate) { StorageType Storage, bool ShouldCreate) {
@ -290,26 +294,23 @@ MDNamespace *MDNamespace::getImpl(LLVMContext &Context, Metadata *Scope,
MDTemplateTypeParameter * MDTemplateTypeParameter *
MDTemplateTypeParameter::getImpl(LLVMContext &Context, Metadata *Scope, MDTemplateTypeParameter::getImpl(LLVMContext &Context, Metadata *Scope,
MDString *Name, Metadata *Type, Metadata *File, MDString *Name, Metadata *Type,
unsigned Line, unsigned Column,
StorageType Storage, bool ShouldCreate) { StorageType Storage, bool ShouldCreate) {
assert(isCanonical(Name) && "Expected canonical MDString"); assert(isCanonical(Name) && "Expected canonical MDString");
DEFINE_GETIMPL_LOOKUP(MDTemplateTypeParameter, DEFINE_GETIMPL_LOOKUP(MDTemplateTypeParameter,
(Scope, getString(Name), Type, File, Line, Column)); (Scope, getString(Name), Type));
Metadata *Ops[] = {File, Scope, Name, Type}; Metadata *Ops[] = {Scope, Name, Type};
DEFINE_GETIMPL_STORE(MDTemplateTypeParameter, (Line, Column), Ops); DEFINE_GETIMPL_STORE_NO_CONSTRUCTOR_ARGS(MDTemplateTypeParameter, Ops);
} }
MDTemplateValueParameter *MDTemplateValueParameter::getImpl( MDTemplateValueParameter *MDTemplateValueParameter::getImpl(
LLVMContext &Context, unsigned Tag, Metadata *Scope, MDString *Name, LLVMContext &Context, unsigned Tag, Metadata *Scope, MDString *Name,
Metadata *Type, Metadata *Value, Metadata *File, unsigned Line, Metadata *Type, Metadata *Value, StorageType Storage, bool ShouldCreate) {
unsigned Column, StorageType Storage, bool ShouldCreate) {
assert(isCanonical(Name) && "Expected canonical MDString"); assert(isCanonical(Name) && "Expected canonical MDString");
DEFINE_GETIMPL_LOOKUP( DEFINE_GETIMPL_LOOKUP(MDTemplateValueParameter,
MDTemplateValueParameter, (Tag, Scope, getString(Name), Type, Value));
(Tag, Scope, getString(Name), Type, Value, File, Line, Column)); Metadata *Ops[] = {Scope, Name, Type, Value};
Metadata *Ops[] = {File, Scope, Name, Type, Value}; DEFINE_GETIMPL_STORE(MDTemplateValueParameter, (Tag), Ops);
DEFINE_GETIMPL_STORE(MDTemplateValueParameter, (Tag, Line, Column), Ops);
} }
MDGlobalVariable * MDGlobalVariable *

View File

@ -649,26 +649,17 @@ template <> struct MDNodeKeyImpl<MDTemplateTypeParameter> {
Metadata *Scope; Metadata *Scope;
StringRef Name; StringRef Name;
Metadata *Type; Metadata *Type;
Metadata *File;
unsigned Line;
unsigned Column;
MDNodeKeyImpl(Metadata *Scope, StringRef Name, Metadata *Type, Metadata *File, MDNodeKeyImpl(Metadata *Scope, StringRef Name, Metadata *Type)
unsigned Line, unsigned Column) : Scope(Scope), Name(Name), Type(Type) {}
: Scope(Scope), Name(Name), Type(Type), File(File), Line(Line),
Column(Column) {}
MDNodeKeyImpl(const MDTemplateTypeParameter *N) MDNodeKeyImpl(const MDTemplateTypeParameter *N)
: Scope(N->getScope()), Name(N->getName()), Type(N->getType()), : Scope(N->getScope()), Name(N->getName()), Type(N->getType()) {}
File(N->getFile()), Line(N->getLine()), Column(N->getColumn()) {}
bool isKeyOf(const MDTemplateTypeParameter *RHS) const { bool isKeyOf(const MDTemplateTypeParameter *RHS) const {
return Scope == RHS->getScope() && Name == RHS->getName() && return Scope == RHS->getScope() && Name == RHS->getName() &&
Type == RHS->getType() && File == RHS->getFile() && Type == RHS->getType();
Line == RHS->getLine() && Column == RHS->getColumn();
}
unsigned getHashValue() const {
return hash_combine(Scope, Name, Type, File, Line, Column);
} }
unsigned getHashValue() const { return hash_combine(Scope, Name, Type); }
}; };
template <> struct MDNodeKeyImpl<MDTemplateValueParameter> { template <> struct MDNodeKeyImpl<MDTemplateValueParameter> {
@ -677,27 +668,21 @@ template <> struct MDNodeKeyImpl<MDTemplateValueParameter> {
StringRef Name; StringRef Name;
Metadata *Type; Metadata *Type;
Metadata *Value; Metadata *Value;
Metadata *File;
unsigned Line;
unsigned Column;
MDNodeKeyImpl(unsigned Tag, Metadata *Scope, StringRef Name, Metadata *Type, MDNodeKeyImpl(unsigned Tag, Metadata *Scope, StringRef Name, Metadata *Type,
Metadata *Value, Metadata *File, unsigned Line, unsigned Column) Metadata *Value)
: Tag(Tag), Scope(Scope), Name(Name), Type(Type), Value(Value), : Tag(Tag), Scope(Scope), Name(Name), Type(Type), Value(Value) {}
File(File), Line(Line), Column(Column) {}
MDNodeKeyImpl(const MDTemplateValueParameter *N) MDNodeKeyImpl(const MDTemplateValueParameter *N)
: Tag(N->getTag()), Scope(N->getScope()), Name(N->getName()), : Tag(N->getTag()), Scope(N->getScope()), Name(N->getName()),
Type(N->getType()), Value(N->getValue()), File(N->getFile()), Type(N->getType()), Value(N->getValue()) {}
Line(N->getLine()), Column(N->getColumn()) {}
bool isKeyOf(const MDTemplateValueParameter *RHS) const { bool isKeyOf(const MDTemplateValueParameter *RHS) const {
return Tag == RHS->getTag() && Scope == RHS->getScope() && return Tag == RHS->getTag() && Scope == RHS->getScope() &&
Name == RHS->getName() && Type == RHS->getType() && Name == RHS->getName() && Type == RHS->getType() &&
Value == RHS->getValue() && File == RHS->getFile() && Value == RHS->getValue();
Line == RHS->getLine() && Column == RHS->getColumn();
} }
unsigned getHashValue() const { unsigned getHashValue() const {
return hash_combine(Tag, Scope, Name, Type, Value, File, Line, Column); return hash_combine(Tag, Scope, Name, Type, Value);
} }
}; };

View File

@ -1194,35 +1194,18 @@ TEST_F(MDTemplateTypeParameterTest, get) {
Metadata *Scope = MDTuple::getDistinct(Context, None); Metadata *Scope = MDTuple::getDistinct(Context, None);
StringRef Name = "template"; StringRef Name = "template";
Metadata *Type = MDTuple::getDistinct(Context, None); Metadata *Type = MDTuple::getDistinct(Context, None);
Metadata *File = MDTuple::getDistinct(Context, None);
unsigned Line = 5;
unsigned Column = 7;
auto *N = MDTemplateTypeParameter::get(Context, Scope, Name, Type, File, Line, auto *N = MDTemplateTypeParameter::get(Context, Scope, Name, Type);
Column);
EXPECT_EQ(dwarf::DW_TAG_template_type_parameter, N->getTag()); EXPECT_EQ(dwarf::DW_TAG_template_type_parameter, N->getTag());
EXPECT_EQ(Scope, N->getScope()); EXPECT_EQ(Scope, N->getScope());
EXPECT_EQ(Name, N->getName()); EXPECT_EQ(Name, N->getName());
EXPECT_EQ(Type, N->getType()); EXPECT_EQ(Type, N->getType());
EXPECT_EQ(File, N->getFile()); EXPECT_EQ(N, MDTemplateTypeParameter::get(Context, Scope, Name, Type));
EXPECT_EQ(Line, N->getLine());
EXPECT_EQ(Column, N->getColumn());
EXPECT_EQ(N, MDTemplateTypeParameter::get(Context, Scope, Name, Type, File,
Line, Column));
EXPECT_NE(N, MDTemplateTypeParameter::get(Context, Type, Name, Type, File, EXPECT_NE(N, MDTemplateTypeParameter::get(Context, Type, Name, Type));
Line, Column)); EXPECT_NE(N, MDTemplateTypeParameter::get(Context, Scope, "other", Type));
EXPECT_NE(N, MDTemplateTypeParameter::get(Context, Scope, "other", Type, File, EXPECT_NE(N, MDTemplateTypeParameter::get(Context, Scope, Name, Scope));
Line, Column));
EXPECT_NE(N, MDTemplateTypeParameter::get(Context, Scope, Name, Scope, File,
Line, Column));
EXPECT_NE(N, MDTemplateTypeParameter::get(Context, Scope, Name, Type, Scope,
Line, Column));
EXPECT_NE(N, MDTemplateTypeParameter::get(Context, Scope, Name, Type, File,
Line + 1, Column));
EXPECT_NE(N, MDTemplateTypeParameter::get(Context, Scope, Name, Type, File,
Line, Column + 1));
} }
typedef MetadataTest MDTemplateValueParameterTest; typedef MetadataTest MDTemplateValueParameterTest;
@ -1233,40 +1216,28 @@ TEST_F(MDTemplateValueParameterTest, get) {
StringRef Name = "template"; StringRef Name = "template";
Metadata *Type = MDTuple::getDistinct(Context, None); Metadata *Type = MDTuple::getDistinct(Context, None);
Metadata *Value = MDTuple::getDistinct(Context, None); Metadata *Value = MDTuple::getDistinct(Context, None);
Metadata *File = MDTuple::getDistinct(Context, None);
unsigned Line = 5;
unsigned Column = 7;
auto *N = MDTemplateValueParameter::get(Context, Tag, Scope, Name, Type, auto *N =
Value, File, Line, Column); MDTemplateValueParameter::get(Context, Tag, Scope, Name, Type, Value);
EXPECT_EQ(Tag, N->getTag()); EXPECT_EQ(Tag, N->getTag());
EXPECT_EQ(Scope, N->getScope()); EXPECT_EQ(Scope, N->getScope());
EXPECT_EQ(Name, N->getName()); EXPECT_EQ(Name, N->getName());
EXPECT_EQ(Type, N->getType()); EXPECT_EQ(Type, N->getType());
EXPECT_EQ(Value, N->getValue()); EXPECT_EQ(Value, N->getValue());
EXPECT_EQ(File, N->getFile()); EXPECT_EQ(
EXPECT_EQ(Line, N->getLine()); N, MDTemplateValueParameter::get(Context, Tag, Scope, Name, Type, Value));
EXPECT_EQ(Column, N->getColumn());
EXPECT_EQ(N, MDTemplateValueParameter::get(Context, Tag, Scope, Name, Type,
Value, File, Line, Column));
EXPECT_NE(N, MDTemplateValueParameter::get( EXPECT_NE(N, MDTemplateValueParameter::get(
Context, dwarf::DW_TAG_GNU_template_template_param, Scope, Context, dwarf::DW_TAG_GNU_template_template_param, Scope,
Name, Type, Value, File, Line, Column)); Name, Type, Value));
EXPECT_NE(N, MDTemplateValueParameter::get(Context, Tag, Type, Name, Type, EXPECT_NE(
Value, File, Line, Column)); N, MDTemplateValueParameter::get(Context, Tag, Type, Name, Type, Value));
EXPECT_NE(N, MDTemplateValueParameter::get(Context, Tag, Scope, "other", Type, EXPECT_NE(N, MDTemplateValueParameter::get(Context, Tag, Scope, "other", Type,
Value, File, Line, Column)); Value));
EXPECT_NE(N, MDTemplateValueParameter::get(Context, Tag, Scope, Name, Scope, EXPECT_NE(N, MDTemplateValueParameter::get(Context, Tag, Scope, Name, Scope,
Value, File, Line, Column)); Value));
EXPECT_NE(N, MDTemplateValueParameter::get(Context, Tag, Scope, Name, Type, EXPECT_NE(
Scope, File, Line, Column)); N, MDTemplateValueParameter::get(Context, Tag, Scope, Name, Type, Scope));
EXPECT_NE(N, MDTemplateValueParameter::get(Context, Tag, Scope, Name, Type,
Value, Scope, Line, Column));
EXPECT_NE(N, MDTemplateValueParameter::get(Context, Tag, Scope, Name, Type,
Value, File, Line + 1, Column));
EXPECT_NE(N, MDTemplateValueParameter::get(Context, Tag, Scope, Name, Type,
Value, File, Line, Column + 1));
} }
typedef MetadataTest MDGlobalVariableTest; typedef MetadataTest MDGlobalVariableTest;