forked from OSchip/llvm-project
[NFC] Fix compile time regression seen on some benchmarks after a630ea3003
commit
The goal of this change is fixing most of compile time slowdown seen after a630ea3003
commit on lencod and sqlite3 benchmarks.
There are 3 improvements included in this patch:
1. In getNumOperands when possible get value directly from SmallNumOps.
2. Inline getLargePtr by moving its definition to header.
3. In TBAAStructTypeNode::getField get all operands once instead taking operands in loop one after one.
Differential Revision: https://reviews.llvm.org/D129468
This commit is contained in:
parent
81b62f7feb
commit
165240fe38
|
@ -999,7 +999,13 @@ class MDNode : public Metadata {
|
||||||
alignTo(getAllocSize(), alignof(uint64_t));
|
alignTo(getAllocSize(), alignof(uint64_t));
|
||||||
}
|
}
|
||||||
|
|
||||||
void *getLargePtr() const;
|
void *getLargePtr() const {
|
||||||
|
static_assert(alignof(LargeStorageVector) <= alignof(Header),
|
||||||
|
"LargeStorageVector too strongly aligned");
|
||||||
|
return reinterpret_cast<char *>(const_cast<Header *>(this)) -
|
||||||
|
sizeof(LargeStorageVector);
|
||||||
|
}
|
||||||
|
|
||||||
void *getSmallPtr();
|
void *getSmallPtr();
|
||||||
|
|
||||||
LargeStorageVector &getLarge() {
|
LargeStorageVector &getLarge() {
|
||||||
|
@ -1032,6 +1038,12 @@ class MDNode : public Metadata {
|
||||||
return makeArrayRef(reinterpret_cast<const MDOperand *>(this) - SmallSize,
|
return makeArrayRef(reinterpret_cast<const MDOperand *>(this) - SmallSize,
|
||||||
SmallNumOps);
|
SmallNumOps);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned getNumOperands() const {
|
||||||
|
if (!IsLarge)
|
||||||
|
return SmallNumOps;
|
||||||
|
return getLarge().size();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Header &getHeader() { return *(reinterpret_cast<Header *>(this) - 1); }
|
Header &getHeader() { return *(reinterpret_cast<Header *>(this) - 1); }
|
||||||
|
@ -1283,7 +1295,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return number of MDNode operands.
|
/// Return number of MDNode operands.
|
||||||
unsigned getNumOperands() const { return getHeader().operands().size(); }
|
unsigned getNumOperands() const { return getHeader().getNumOperands(); }
|
||||||
|
|
||||||
/// Methods for support type inquiry through isa, cast, and dyn_cast:
|
/// Methods for support type inquiry through isa, cast, and dyn_cast:
|
||||||
static bool classof(const Metadata *MD) {
|
static bool classof(const Metadata *MD) {
|
||||||
|
|
|
@ -303,24 +303,27 @@ public:
|
||||||
/// given offset. Update the offset to be relative to the field type.
|
/// given offset. Update the offset to be relative to the field type.
|
||||||
TBAAStructTypeNode getField(uint64_t &Offset) const {
|
TBAAStructTypeNode getField(uint64_t &Offset) const {
|
||||||
bool NewFormat = isNewFormat();
|
bool NewFormat = isNewFormat();
|
||||||
|
const ArrayRef<MDOperand> Operands(Node->op_begin(), Node->op_end());
|
||||||
|
const unsigned NumOperands = Operands.size();
|
||||||
|
|
||||||
if (NewFormat) {
|
if (NewFormat) {
|
||||||
// New-format root and scalar type nodes have no fields.
|
// New-format root and scalar type nodes have no fields.
|
||||||
if (Node->getNumOperands() < 6)
|
if (NumOperands < 6)
|
||||||
return TBAAStructTypeNode();
|
return TBAAStructTypeNode();
|
||||||
} else {
|
} else {
|
||||||
// Parent can be omitted for the root node.
|
// Parent can be omitted for the root node.
|
||||||
if (Node->getNumOperands() < 2)
|
if (NumOperands < 2)
|
||||||
return TBAAStructTypeNode();
|
return TBAAStructTypeNode();
|
||||||
|
|
||||||
// Fast path for a scalar type node and a struct type node with a single
|
// Fast path for a scalar type node and a struct type node with a single
|
||||||
// field.
|
// field.
|
||||||
if (Node->getNumOperands() <= 3) {
|
if (NumOperands <= 3) {
|
||||||
uint64_t Cur = Node->getNumOperands() == 2
|
uint64_t Cur =
|
||||||
? 0
|
NumOperands == 2
|
||||||
: mdconst::extract<ConstantInt>(Node->getOperand(2))
|
? 0
|
||||||
->getZExtValue();
|
: mdconst::extract<ConstantInt>(Operands[2])->getZExtValue();
|
||||||
Offset -= Cur;
|
Offset -= Cur;
|
||||||
MDNode *P = dyn_cast_or_null<MDNode>(Node->getOperand(1));
|
MDNode *P = dyn_cast_or_null<MDNode>(Operands[1]);
|
||||||
if (!P)
|
if (!P)
|
||||||
return TBAAStructTypeNode();
|
return TBAAStructTypeNode();
|
||||||
return TBAAStructTypeNode(P);
|
return TBAAStructTypeNode(P);
|
||||||
|
@ -332,10 +335,11 @@ public:
|
||||||
unsigned FirstFieldOpNo = NewFormat ? 3 : 1;
|
unsigned FirstFieldOpNo = NewFormat ? 3 : 1;
|
||||||
unsigned NumOpsPerField = NewFormat ? 3 : 2;
|
unsigned NumOpsPerField = NewFormat ? 3 : 2;
|
||||||
unsigned TheIdx = 0;
|
unsigned TheIdx = 0;
|
||||||
for (unsigned Idx = FirstFieldOpNo; Idx < Node->getNumOperands();
|
|
||||||
|
for (unsigned Idx = FirstFieldOpNo; Idx < NumOperands;
|
||||||
Idx += NumOpsPerField) {
|
Idx += NumOpsPerField) {
|
||||||
uint64_t Cur = mdconst::extract<ConstantInt>(Node->getOperand(Idx + 1))
|
uint64_t Cur =
|
||||||
->getZExtValue();
|
mdconst::extract<ConstantInt>(Operands[Idx + 1])->getZExtValue();
|
||||||
if (Cur > Offset) {
|
if (Cur > Offset) {
|
||||||
assert(Idx >= FirstFieldOpNo + NumOpsPerField &&
|
assert(Idx >= FirstFieldOpNo + NumOpsPerField &&
|
||||||
"TBAAStructTypeNode::getField should have an offset match!");
|
"TBAAStructTypeNode::getField should have an offset match!");
|
||||||
|
@ -345,11 +349,11 @@ public:
|
||||||
}
|
}
|
||||||
// Move along the last field.
|
// Move along the last field.
|
||||||
if (TheIdx == 0)
|
if (TheIdx == 0)
|
||||||
TheIdx = Node->getNumOperands() - NumOpsPerField;
|
TheIdx = NumOperands - NumOpsPerField;
|
||||||
uint64_t Cur = mdconst::extract<ConstantInt>(Node->getOperand(TheIdx + 1))
|
uint64_t Cur =
|
||||||
->getZExtValue();
|
mdconst::extract<ConstantInt>(Operands[TheIdx + 1])->getZExtValue();
|
||||||
Offset -= Cur;
|
Offset -= Cur;
|
||||||
MDNode *P = dyn_cast_or_null<MDNode>(Node->getOperand(TheIdx));
|
MDNode *P = dyn_cast_or_null<MDNode>(Operands[TheIdx]);
|
||||||
if (!P)
|
if (!P)
|
||||||
return TBAAStructTypeNode();
|
return TBAAStructTypeNode();
|
||||||
return TBAAStructTypeNode(P);
|
return TBAAStructTypeNode(P);
|
||||||
|
|
|
@ -592,13 +592,6 @@ MDNode::Header::~Header() {
|
||||||
(void)(O - 1)->~MDOperand();
|
(void)(O - 1)->~MDOperand();
|
||||||
}
|
}
|
||||||
|
|
||||||
void *MDNode::Header::getLargePtr() const {
|
|
||||||
static_assert(alignof(LargeStorageVector) <= alignof(Header),
|
|
||||||
"LargeStorageVector too strongly aligned");
|
|
||||||
return reinterpret_cast<char *>(const_cast<Header *>(this)) -
|
|
||||||
sizeof(LargeStorageVector);
|
|
||||||
}
|
|
||||||
|
|
||||||
void *MDNode::Header::getSmallPtr() {
|
void *MDNode::Header::getSmallPtr() {
|
||||||
static_assert(alignof(MDOperand) <= alignof(Header),
|
static_assert(alignof(MDOperand) <= alignof(Header),
|
||||||
"MDOperand too strongly aligned");
|
"MDOperand too strongly aligned");
|
||||||
|
|
Loading…
Reference in New Issue