This is an archive of the discontinued LLVM Phabricator instance.

[IR] Make Value::getType() work better with invalid IR.
ClosedPublic

Authored by lattner on Dec 28 2020, 12:01 PM.

Details

Summary

The asmprinter would crash when dumping IR objects that had their
operands dropped. With this change, we now get this output, which
makes op->dump() style debugging more useful.

%5 = "firrtl.eq"(<<NULL>>, <<NULL>>) : (<<NULL TYPE>>, <<NULL TYPE>>) -> !firrtl.uint<1>

Previously the asmprinter would crash getting the types of the null operands.

Diff Detail

Event Timeline

lattner created this revision.Dec 28 2020, 12:01 PM
lattner requested review of this revision.Dec 28 2020, 12:01 PM
jpienaar accepted this revision.Dec 28 2020, 12:08 PM
This revision is now accepted and ready to land.Dec 28 2020, 12:08 PM
This revision was automatically updated to reflect the committed changes.

thanks for the quick review, landed in 87c032f7b44

rriddle added inline comments.Dec 29 2020, 3:11 AM
mlir/lib/IR/Value.cpp
35

Can you instead fix asmprinter? It would avoid weird null checks slipping into these types, which awkwardly breaks the expectation of being pointer-like.

lattner added inline comments.Dec 29 2020, 10:29 AM
mlir/lib/IR/Value.cpp
35

Yes, I can definitely do that if you'd prefer that! It will require deabstracting some stuff, but can definitely do that.

I'm preparing a patch to deabstract this, but it is ugly. The other middle-ground approach is to change ValueTypeIterator to do the null check.