[PATCH] D43679: TableGen: Use DefInit::getDef() instead of the type's getRecord()

Artem Belevich via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 26 13:41:27 PST 2018

tra accepted this revision.
tra added a comment.
This revision is now accepted and ready to land.

In https://reviews.llvm.org/D43679#1018714, @nhaehnle wrote:

> Thanks. It's hard to say who really groks utils/TableGen/FixedLenCodeEmitter.cpp, adding some folks (+ @arsenm) who at least wrote the bits near my changes.
> I've verified that this change doesn't change the generated code in any of the backends in trunk at all.

Great. At least we're not breaking correct code.

> The basic pattern is simple: use `cast<DefInit>(TI)->getDef()` instead of `cast<RecordRecTy>(TI->getType())->getRecord()`. If TI is a DefInit, those will yield the same result. If TI is not a DefInit, then the former will crash and the latter will return the record representing some uninstantiated class, which is not meaningful.

If you can think of a way for user input to trigger this scenario, we should probably issue an error. I'm not sure if that's the case, though.
My attempts to trigger the problem were thwarted by tablegen -- it aborted with an error before TI with a wrong type could get to populateInstruction().

> So I'd say this is a low-risk change.

If nobody chimes in today, I'm OK with landing this change.



More information about the llvm-commits mailing list