This is an archive of the discontinued LLVM Phabricator instance.

[clang][Interp] Check This pointer without creating InterpFrame
ClosedPublic

Authored by tbaeder on Jan 26 2023, 5:10 AM.

Details

Summary
The InterpFrame was only created so early so we could use getThis().
However, we need to know the Function when creating the InterpFrame and
in the case of virtual functions, we need to determine what function to
call at interpretation time.

Get the This pointer ourselves and just create the InterpFrame later.

This is of course in preparation for virtual function calls.

Diff Detail

Event Timeline

tbaeder created this revision.Jan 26 2023, 5:10 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 26 2023, 5:10 AM
tbaeder requested review of this revision.Jan 26 2023, 5:10 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 26 2023, 5:10 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
aaron.ballman added inline comments.Mar 1 2023, 6:25 AM
clang/lib/AST/Interp/InterpStack.h
75–77

Ooofda, this only differs from peek() on line 97 because this function has a templated return type, but otherwise the signatures only differ based on return type. This doesn't feel like the most clean overload set...

Also, should this be worrying about alignment of T compared to the offset we find it at? (Should there be an assert that the offset is sensible for a T?)

tbaeder updated this revision to Diff 501502.Mar 1 2023, 7:06 AM

Added an aligned() assertion and renamed the old peek(unsigned Offset) returning a void* to peekData(), so both peek overloads are now public member functions.

This revision is now accepted and ready to land.Mar 1 2023, 8:30 AM
shafik accepted this revision.Mar 14 2023, 9:47 PM

LGTM

This revision was landed with ongoing or failed builds.Mar 31 2023, 7:18 AM
This revision was automatically updated to reflect the committed changes.