This is an archive of the discontinued LLVM Phabricator instance.

[lldb] Don't defend against internal LLVM errors in IRInterpreter
ClosedPublic

Authored by teemperor on Jan 13 2020, 3:19 AM.

Details

Summary

Whenever we cast an LLVM instruction to one of its subclasses, we do a double check if the RTTI
enum value actually allows us to cast the class. I don't see a way this can ever happen as even when
LLVM's RTTI system has some corrupt internal state (which we probably should not test in the first
place) we just reuse LLVM RTTI to do the second check.

This also means that if we ever make an actual programming error in this function (e.g., have a enum
value and then cast it to a different subclass), we just silently fall back to the JIT in our tests.

We also can't test this code in any reasonable way.

This removes the checks and uses llvm::cast instead which will raise a fatal error when casting fails.

Diff Detail

Event Timeline

teemperor created this revision.Jan 13 2020, 3:19 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 13 2020, 3:19 AM
teemperor edited the summary of this revision. (Show Details)Jan 13 2020, 3:19 AM
teemperor edited the summary of this revision. (Show Details)
teemperor edited the summary of this revision. (Show Details)Jan 13 2020, 4:13 AM
labath accepted this revision.Jan 14 2020, 12:41 AM

Yes, I remember being baffled by this in the past...

This revision is now accepted and ready to land.Jan 14 2020, 12:41 AM
This revision was automatically updated to reflect the committed changes.