1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 02:52:53 +02:00

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.

llvm-svn: 228652
This commit is contained in:
Duncan P. N. Exon Smith 2015-02-10 01:59:57 +00:00
parent ad09354db9
commit 61535117b4
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
/// referenced.
class MDTemplateParameter : public DebugNode {
unsigned Line;
unsigned Column;
protected:
MDTemplateParameter(LLVMContext &Context, unsigned ID, StorageType Storage,
unsigned Tag, unsigned Line, unsigned Column,
ArrayRef<Metadata *> Ops)
: DebugNode(Context, ID, Storage, Tag, Ops), Line(Line), Column(Column) {}
unsigned Tag, ArrayRef<Metadata *> Ops)
: DebugNode(Context, ID, Storage, Tag, Ops) {}
~MDTemplateParameter() {}
public:
unsigned getLine() const { return Line; }
unsigned getColumn() const { return Column; }
Metadata *getFile() const { return getOperand(0); }
Metadata *getScope() const { return getOperand(1); }
StringRef getName() const { return getStringOperand(2); }
Metadata *getType() const { return getOperand(3); }
Metadata *getScope() const { return getOperand(0); }
StringRef getName() const { return getStringOperand(1); }
Metadata *getType() const { return getOperand(2); }
static bool classof(const Metadata *MD) {
return MD->getMetadataID() == MDTemplateTypeParameterKind ||
@ -1126,43 +1118,34 @@ class MDTemplateTypeParameter : public MDTemplateParameter {
friend class MDNode;
MDTemplateTypeParameter(LLVMContext &Context, StorageType Storage,
unsigned Line, unsigned Column,
ArrayRef<Metadata *> Ops)
: MDTemplateParameter(Context, MDTemplateTypeParameterKind, Storage,
dwarf::DW_TAG_template_type_parameter, Line, Column,
Ops) {}
dwarf::DW_TAG_template_type_parameter, Ops) {}
~MDTemplateTypeParameter() {}
static MDTemplateTypeParameter *getImpl(LLVMContext &Context, Metadata *Scope,
StringRef Name, Metadata *Type,
Metadata *File, unsigned Line,
unsigned Column, StorageType Storage,
StorageType Storage,
bool ShouldCreate = true) {
return getImpl(Context, Scope, getCanonicalMDString(Context, Name), Type,
File, Line, Column, Storage, ShouldCreate);
Storage, ShouldCreate);
}
static MDTemplateTypeParameter *getImpl(LLVMContext &Context, Metadata *Scope,
MDString *Name, Metadata *Type,
Metadata *File, unsigned Line,
unsigned Column, StorageType Storage,
StorageType Storage,
bool ShouldCreate = true);
TempMDTemplateTypeParameter cloneImpl() const {
return getTemporary(getContext(), getScope(), getName(), getType(),
getFile(), getLine(), getColumn());
return getTemporary(getContext(), getScope(), getName(), getType());
}
public:
DEFINE_MDNODE_GET(MDTemplateTypeParameter,
(Metadata * Scope, StringRef Name, Metadata *Type,
Metadata *File = nullptr, unsigned Line = 0,
unsigned Column = 0),
(Scope, Name, Type, File, Line, Column))
(Metadata * Scope, StringRef Name, Metadata *Type),
(Scope, Name, Type))
DEFINE_MDNODE_GET(MDTemplateTypeParameter,
(Metadata * Scope, MDString *Name, Metadata *Type,
Metadata *File = nullptr, unsigned Line = 0,
unsigned Column = 0),
(Scope, Name, Type, File, Line, Column))
(Metadata * Scope, MDString *Name, Metadata *Type),
(Scope, Name, Type))
TempMDTemplateTypeParameter clone() const { return cloneImpl(); }
@ -1176,43 +1159,41 @@ class MDTemplateValueParameter : public MDTemplateParameter {
friend class MDNode;
MDTemplateValueParameter(LLVMContext &Context, StorageType Storage,
unsigned Tag, unsigned Line, unsigned Column,
ArrayRef<Metadata *> Ops)
unsigned Tag, ArrayRef<Metadata *> Ops)
: MDTemplateParameter(Context, MDTemplateValueParameterKind, Storage, Tag,
Line, Column, Ops) {}
Ops) {}
~MDTemplateValueParameter() {}
static MDTemplateValueParameter *
getImpl(LLVMContext &Context, unsigned Tag, Metadata *Scope, StringRef Name,
Metadata *Type, Metadata *Value, Metadata *File, unsigned Line,
unsigned Column, StorageType Storage, bool ShouldCreate = true) {
static MDTemplateValueParameter *getImpl(LLVMContext &Context, unsigned Tag,
Metadata *Scope, StringRef Name,
Metadata *Type, Metadata *Value,
StorageType Storage,
bool ShouldCreate = true) {
return getImpl(Context, Tag, Scope, getCanonicalMDString(Context, Name),
Type, Value, File, Line, Column, Storage, ShouldCreate);
Type, Value, Storage, ShouldCreate);
}
static MDTemplateValueParameter *
getImpl(LLVMContext &Context, unsigned Tag, Metadata *Scope, MDString *Name,
Metadata *Type, Metadata *Value, Metadata *File, unsigned Line,
unsigned Column, StorageType Storage, bool ShouldCreate = true);
static MDTemplateValueParameter *getImpl(LLVMContext &Context, unsigned Tag,
Metadata *Scope, MDString *Name,
Metadata *Type, Metadata *Value,
StorageType Storage,
bool ShouldCreate = true);
TempMDTemplateValueParameter cloneImpl() const {
return getTemporary(getContext(), getTag(), getScope(), getName(),
getType(), getValue(), getFile(), getLine(),
getColumn());
getType(), getValue());
}
public:
DEFINE_MDNODE_GET(MDTemplateValueParameter,
(unsigned Tag, Metadata *Scope, StringRef Name,
Metadata *Type, Metadata *Value, Metadata *File = nullptr,
unsigned Line = 0, unsigned Column = 0),
(Tag, Scope, Name, Type, Value, File, Line, Column))
Metadata *Type, Metadata *Value),
(Tag, Scope, Name, Type, Value))
DEFINE_MDNODE_GET(MDTemplateValueParameter,
(unsigned Tag, Metadata *Scope, MDString *Name,
Metadata *Type, Metadata *Value, Metadata *File = nullptr,
unsigned Line = 0, unsigned Column = 0),
(Tag, Scope, Name, Type, Value, File, Line, Column))
Metadata *Type, Metadata *Value),
(Tag, Scope, Name, Type, Value))
Metadata *getValue() const { return getOperand(4); }
Metadata *getValue() const { return getOperand(3); }
static bool classof(const Metadata *MD) {
return MD->getMetadataID() == MDTemplateValueParameterKind;

View File

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

View File

@ -649,26 +649,17 @@ template <> struct MDNodeKeyImpl<MDTemplateTypeParameter> {
Metadata *Scope;
StringRef Name;
Metadata *Type;
Metadata *File;
unsigned Line;
unsigned Column;
MDNodeKeyImpl(Metadata *Scope, StringRef Name, Metadata *Type, Metadata *File,
unsigned Line, unsigned Column)
: Scope(Scope), Name(Name), Type(Type), File(File), Line(Line),
Column(Column) {}
MDNodeKeyImpl(Metadata *Scope, StringRef Name, Metadata *Type)
: Scope(Scope), Name(Name), Type(Type) {}
MDNodeKeyImpl(const MDTemplateTypeParameter *N)
: Scope(N->getScope()), Name(N->getName()), Type(N->getType()),
File(N->getFile()), Line(N->getLine()), Column(N->getColumn()) {}
: Scope(N->getScope()), Name(N->getName()), Type(N->getType()) {}
bool isKeyOf(const MDTemplateTypeParameter *RHS) const {
return Scope == RHS->getScope() && Name == RHS->getName() &&
Type == RHS->getType() && File == RHS->getFile() &&
Line == RHS->getLine() && Column == RHS->getColumn();
}
unsigned getHashValue() const {
return hash_combine(Scope, Name, Type, File, Line, Column);
Type == RHS->getType();
}
unsigned getHashValue() const { return hash_combine(Scope, Name, Type); }
};
template <> struct MDNodeKeyImpl<MDTemplateValueParameter> {
@ -677,27 +668,21 @@ template <> struct MDNodeKeyImpl<MDTemplateValueParameter> {
StringRef Name;
Metadata *Type;
Metadata *Value;
Metadata *File;
unsigned Line;
unsigned Column;
MDNodeKeyImpl(unsigned Tag, Metadata *Scope, StringRef Name, Metadata *Type,
Metadata *Value, Metadata *File, unsigned Line, unsigned Column)
: Tag(Tag), Scope(Scope), Name(Name), Type(Type), Value(Value),
File(File), Line(Line), Column(Column) {}
Metadata *Value)
: Tag(Tag), Scope(Scope), Name(Name), Type(Type), Value(Value) {}
MDNodeKeyImpl(const MDTemplateValueParameter *N)
: Tag(N->getTag()), Scope(N->getScope()), Name(N->getName()),
Type(N->getType()), Value(N->getValue()), File(N->getFile()),
Line(N->getLine()), Column(N->getColumn()) {}
Type(N->getType()), Value(N->getValue()) {}
bool isKeyOf(const MDTemplateValueParameter *RHS) const {
return Tag == RHS->getTag() && Scope == RHS->getScope() &&
Name == RHS->getName() && Type == RHS->getType() &&
Value == RHS->getValue() && File == RHS->getFile() &&
Line == RHS->getLine() && Column == RHS->getColumn();
Value == RHS->getValue();
}
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);
StringRef Name = "template";
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,
Column);
auto *N = MDTemplateTypeParameter::get(Context, Scope, Name, Type);
EXPECT_EQ(dwarf::DW_TAG_template_type_parameter, N->getTag());
EXPECT_EQ(Scope, N->getScope());
EXPECT_EQ(Name, N->getName());
EXPECT_EQ(Type, N->getType());
EXPECT_EQ(File, N->getFile());
EXPECT_EQ(Line, N->getLine());
EXPECT_EQ(Column, N->getColumn());
EXPECT_EQ(N, MDTemplateTypeParameter::get(Context, Scope, Name, Type, File,
Line, Column));
EXPECT_EQ(N, MDTemplateTypeParameter::get(Context, Scope, Name, Type));
EXPECT_NE(N, MDTemplateTypeParameter::get(Context, Type, Name, Type, File,
Line, Column));
EXPECT_NE(N, MDTemplateTypeParameter::get(Context, Scope, "other", Type, File,
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));
EXPECT_NE(N, MDTemplateTypeParameter::get(Context, Type, Name, Type));
EXPECT_NE(N, MDTemplateTypeParameter::get(Context, Scope, "other", Type));
EXPECT_NE(N, MDTemplateTypeParameter::get(Context, Scope, Name, Scope));
}
typedef MetadataTest MDTemplateValueParameterTest;
@ -1233,40 +1216,28 @@ TEST_F(MDTemplateValueParameterTest, get) {
StringRef Name = "template";
Metadata *Type = 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,
Value, File, Line, Column);
auto *N =
MDTemplateValueParameter::get(Context, Tag, Scope, Name, Type, Value);
EXPECT_EQ(Tag, N->getTag());
EXPECT_EQ(Scope, N->getScope());
EXPECT_EQ(Name, N->getName());
EXPECT_EQ(Type, N->getType());
EXPECT_EQ(Value, N->getValue());
EXPECT_EQ(File, N->getFile());
EXPECT_EQ(Line, N->getLine());
EXPECT_EQ(Column, N->getColumn());
EXPECT_EQ(N, MDTemplateValueParameter::get(Context, Tag, Scope, Name, Type,
Value, File, Line, Column));
EXPECT_EQ(
N, MDTemplateValueParameter::get(Context, Tag, Scope, Name, Type, Value));
EXPECT_NE(N, MDTemplateValueParameter::get(
Context, dwarf::DW_TAG_GNU_template_template_param, Scope,
Name, Type, Value, File, Line, Column));
EXPECT_NE(N, MDTemplateValueParameter::get(Context, Tag, Type, Name, Type,
Value, File, Line, Column));
Name, Type, Value));
EXPECT_NE(
N, MDTemplateValueParameter::get(Context, Tag, Type, Name, Type, Value));
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,
Value, File, Line, Column));
EXPECT_NE(N, MDTemplateValueParameter::get(Context, Tag, Scope, Name, Type,
Scope, File, Line, Column));
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));
Value));
EXPECT_NE(
N, MDTemplateValueParameter::get(Context, Tag, Scope, Name, Type, Scope));
}
typedef MetadataTest MDGlobalVariableTest;