-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[TableGen] Add a SmallPtrSet to track WriteRes that are referenced by some ReadAdvance. NFC #124160
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…me ReadAdvance. NFC Use this to remove a linear scan from CodeGenProcModel::hasReadOfWrite. This reduces build time of RISCVGenSubtargetInfo.inc on by machine from ~6 seconds to ~3 seconds.
@llvm/pr-subscribers-tablegen Author: Craig Topper (topperc) ChangesUse this to remove a linear scan from CodeGenProcModel::hasReadOfWrite. This reduces build time of RISCVGenSubtargetInfo.inc on by machine from ~6 seconds to ~3 seconds. Full diff: https://github.com/llvm/llvm-project/pull/124160.diff 2 Files Affected:
diff --git a/llvm/utils/TableGen/Common/CodeGenSchedule.cpp b/llvm/utils/TableGen/Common/CodeGenSchedule.cpp
index 8919a278f352bf..631b24ce2ad129 100644
--- a/llvm/utils/TableGen/Common/CodeGenSchedule.cpp
+++ b/llvm/utils/TableGen/Common/CodeGenSchedule.cpp
@@ -2129,13 +2129,15 @@ void CodeGenSchedModels::addWriteRes(const Record *ProcWriteResDef,
void CodeGenSchedModels::addReadAdvance(const Record *ProcReadAdvanceDef,
CodeGenProcModel &PM) {
for (const Record *ValidWrite :
- ProcReadAdvanceDef->getValueAsListOfDefs("ValidWrites"))
+ ProcReadAdvanceDef->getValueAsListOfDefs("ValidWrites")) {
if (getSchedRWIdx(ValidWrite, /*IsRead=*/false) == 0)
PrintFatalError(
ProcReadAdvanceDef->getLoc(),
"ReadAdvance referencing a ValidWrite that is not used by "
"any instruction (" +
ValidWrite->getName() + ")");
+ PM.ReadOfWriteSet.insert(ValidWrite);
+ }
ConstRecVec &RADefs = PM.ReadAdvanceDefs;
if (is_contained(RADefs, ProcReadAdvanceDef))
@@ -2173,12 +2175,7 @@ bool CodeGenProcModel::isUnsupported(const CodeGenInstruction &Inst) const {
}
bool CodeGenProcModel::hasReadOfWrite(const Record *WriteDef) const {
- for (auto &RADef : ReadAdvanceDefs) {
- ConstRecVec ValidWrites = RADef->getValueAsListOfDefs("ValidWrites");
- if (is_contained(ValidWrites, WriteDef))
- return true;
- }
- return false;
+ return ReadOfWriteSet.count(WriteDef) != 0;
}
#ifndef NDEBUG
diff --git a/llvm/utils/TableGen/Common/CodeGenSchedule.h b/llvm/utils/TableGen/Common/CodeGenSchedule.h
index 5d5aa44d882e59..67979e7cbfe758 100644
--- a/llvm/utils/TableGen/Common/CodeGenSchedule.h
+++ b/llvm/utils/TableGen/Common/CodeGenSchedule.h
@@ -250,6 +250,9 @@ struct CodeGenProcModel {
// Map from the ReadType field to the parent ReadAdvance record.
DenseMap<const Record *, const Record *> ReadAdvanceMap;
+ // Set of WriteRes that are referenced by a ReadAdvance.
+ DenseSet<const Record *> ReadOfWriteSet;
+
// Per-operand machine model resources associated with this processor.
ConstRecVec ProcResourceDefs;
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Use this to remove a linear scan from CodeGenProcModel::hasReadOfWrite.
This reduces build time of RISCVGenSubtargetInfo.inc on by machine from ~6 seconds to ~3 seconds.