This is an archive of the discontinued LLVM Phabricator instance.

[X86] Use a std::vector for the memory unfolding vector.
ClosedPublic

Authored by craig.topper on Jun 25 2018, 11:03 PM.

Details

Summary

Previously we used a DenseMap which is costly to setup due to multiple full table rehashes as the size increases and causes the table to be reallocated.

This patch changes the table to a vector of structs. We now walk the reg->mem tables and push new entries in the mem->reg table for each row not marked TB_NO_REVERSE. Once all the table entries have been created, we sort the vector. Then we can use a binary search for lookups.

Diff Detail

Repository
rL LLVM

Event Timeline

craig.topper created this revision.Jun 25 2018, 11:03 PM

LGTM.

lib/Target/X86/X86InstrInfo.cpp
5424 ↗(On Diff #152840)

One thing I have wanted with the previous assert is to dump the duplicate entry so I know what to look for. That's probably a separate change, but a useful one, I think. I've been bitten by this before and it's a pain to figure out what happened. Since this is under NDEBUG it seems like we can do a little more work here to inform about what's going on.

lib/Target/X86/X86InstrInfo.h
175 ↗(On Diff #152840)

Wonderful!

@greened, did you forget to Accept when you wrote LGTM or should I wait for another reviewer?

lib/Target/X86/X86InstrInfo.cpp
5424 ↗(On Diff #152840)

What would that look like? Do you just want to print the enum values from the failing row or do you want to try to turn that back into a string that a human could read?

RKSimon accepted this revision.Jun 29 2018, 6:14 AM

LGTM - better error reporting would be great but not mandatory.

lib/Target/X86/X86InstrInfo.cpp
5424 ↗(On Diff #152840)

Anything that can be used to debug would be useful - enums are easy enough to work with as you can manually look them up in X86GenInstrInfo.inc - but an actual string would be even better.

This revision is now accepted and ready to land.Jun 29 2018, 6:14 AM

@greened, did you forget to Accept when you wrote LGTM or should I wait for another reviewer?

I'm not a code owner and I don't know what the rules are around accepting.

This revision was automatically updated to reflect the committed changes.