This is an archive of the discontinued LLVM Phabricator instance.

[Clang][Interp] Add some basic functionality to the experimental new constant interpreter
AbandonedPublic

Authored by tbaeder on Aug 15 2022, 6:33 AM.

Details

Summary

Hi,

I wanted to maybe work on the new experimental constant interpreter in clang. I took last week to get to know the code a little and implement some basic functionality.

New in this patch are:

  • Simple function calls
  • array initializers and subscript expressions
  • pointer reference and dereference
  • local and global variables

Some tests for the functionality is in test/AST/Interp/interp.cpp.

As far as I know the interpreter has been abandoned quite some time ago, so I was just looking for some basic feedback about whether this is worth it to pursue. If the feedback is positive, I will continue working on it.

Diff Detail

Event Timeline

tbaeder created this revision.Aug 15 2022, 6:33 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 15 2022, 6:33 AM
Herald added a subscriber: StephenFan. · View Herald Transcript
tbaeder requested review of this revision.Aug 15 2022, 6:33 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 15 2022, 6:33 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript

So you're right, we haven't seen much work on this interpreter in a while, and I have no real experience with reviewing it at all, which I'm sure is the experience of most of my co-reviewers.

At the same time, I believe there is good potential in this interpreter, so I would love to see progress on it.

SO, if you could start by splitting this patch up into the smallest parts possible, it would be really appreciated. This patch seems to be doing a lot, and I'm a bit overwhelmed trying to review it all at once.

Additionally, I suspect there is going to be a LOT of tests, so I'd suggest writing 1 whole 'test file' per topic (instead of throwing everything into interp.cpp). I also suspect that there is need for more in depth testing than that. For exmaple, 'if' statements likely need to check things like side-effects and init statements/etc.

One valuable strategy might be to temporarily switch this over to the 'default' interpreter in your local workspace, make changes, and see if you can add a new 'run' line to any existing tests that each individual change you make causes to pass.

Thanks for the fast reply, Erich!

So you're right, we haven't seen much work on this interpreter in a while, and I have no real experience with reviewing it at all, which I'm sure is the experience of most of my co-reviewers.

Sure, that's expected.

At the same time, I believe there is good potential in this interpreter, so I would love to see progress on it.

SO, if you could start by splitting this patch up into the smallest parts possible, it would be really appreciated. This patch seems to be doing a lot, and I'm a bit overwhelmed trying to review it all at once.

I actually have several smaller patches locally but merged them into one for review :) I'll try to find a middle way.

Additionally, I suspect there is going to be a LOT of tests, so I'd suggest writing 1 whole 'test file' per topic (instead of throwing everything into interp.cpp). I also suspect that there is need for more in depth testing than that. For exmaple, 'if' statements likely need to check things like side-effects and init statements/etc.

One valuable strategy might be to temporarily switch this over to the 'default' interpreter in your local workspace, make changes, and see if you can add a new 'run' line to any existing tests that each individual change you make causes to pass.

I tried running the clang testsuite locally with the new interpreter, but basically all tests fail because something is missing, so I think that's gonna have to wait. But adding more files and tests on a per-patch basis is a good approach.

tbaeder abandoned this revision.Aug 25 2022, 9:54 PM