Skip to content

Commit 7dbdb66

Browse files
authored
[TableGen] Avoid field lookup in a performance critical place (NFC) (#154871)
`Target.getInstructions()` is called by virtually all TableGen backends. It is slow, and one of the two factors is the use of an expensive predicate in `llvm::sort`. This change speeds up sorting by 10x.
1 parent 872a1ed commit 7dbdb66

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

llvm/utils/TableGen/Common/CodeGenTarget.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,8 +270,8 @@ void CodeGenTarget::ComputeInstrsByEnum() const {
270270
const Record &D2 = *Rec2->TheDef;
271271
// Sort all pseudo instructions before non-pseudo ones, and sort by name
272272
// within.
273-
return std::tuple(!D1.getValueAsBit("isPseudo"), D1.getName()) <
274-
std::tuple(!D2.getValueAsBit("isPseudo"), D2.getName());
273+
return std::tuple(!Rec1->isPseudo, D1.getName()) <
274+
std::tuple(!Rec2->isPseudo, D2.getName());
275275
});
276276

277277
// Assign an enum value to each instruction according to the sorted order.

0 commit comments

Comments
 (0)