Skip to content

Commit e525eaf

Browse files
s-barannikovgithub-actions[bot]
authored andcommitted
Automerge: [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.
2 parents a396fba + 7dbdb66 commit e525eaf

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)