This is an archive of the discontinued LLVM Phabricator instance.

Change MCRegisterInfo::getLLVMRegNum() not to assert on unknown register.
AcceptedPublic

Authored by friss on Nov 12 2014, 6:33 PM.

Details

Reviewers
dblaikie
Summary

I want to use this method in llvm-dwarfdump to be able to pretty
print register names in dwarf expressions. As the data I'll feed
to the method comes directly from the binary file, it might be
anything and I'd like to avoid asserting when an unknown register
number is requested.

This patch makes the method return -1 when the register isn't found.
The new behavior is the same as its inverse function getDwarfRegNum.
Note that although this method returns an 'int', each and every user I
could find stores the result in an 'unsigned' variable. Would it
make sense to change the method return type to unsigned? Should the
assert be kept and propagated to the callers? Any other suggestion
to achieve what I want?

Diff Detail

Event Timeline

friss updated this revision to Diff 16128.Nov 12 2014, 6:33 PM
friss retitled this revision from to Change MCRegisterInfo::getLLVMRegNum() not to assert on unknown register..
friss updated this object.
friss added a subscriber: Unknown Object (MLST).
friss updated this revision to Diff 16186.Nov 13 2014, 3:28 PM

Keep the current asserting behavior in getLLVMRegNum() but
implement it in terms of a new non-asserting tryGetLLVMRegNum().

dblaikie accepted this revision.Nov 13 2014, 4:01 PM
dblaikie added a reviewer: dblaikie.
dblaikie added a subscriber: dblaikie.

Looks fine to me (not sure if that's it's not readily unit testable... oh well - I guess your use case will follow swiftly after)

This revision is now accepted and ready to land.Nov 13 2014, 4:01 PM

Looks like patch was not committed.