Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Explicitly specify target in Compilation constructor #5506

Merged
merged 1 commit into from
Sep 1, 2020

Conversation

dchopra001
Copy link
Contributor

This is needed so that the codegen is able to set the correct
flags when initializing.

Signed-off-by: Dhruv Chopra [email protected]

@dchopra001
Copy link
Contributor Author

Tagging @harryyu1994 @mpirvu @dsouzai for review.

Copy link
Contributor

@mpirvu mpirvu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@dchopra001
Copy link
Contributor Author

The following tests:
eclipse.omr (x86-64 macOS) Failing after 18m — x86-64 macOS failed
eclipse.omr Failing after 34m — Build #20200827.16 had test failures

Failed with what look like port library tests. I don't think these are related.

}
else
{
_target = TR::Compiler->target;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is the pattern to be adopted does the visibility of TR::Compiler->target need to change to stop people accidentally using it rather than the target from the compilation? Having the two and having them potentially vary seems dangerous and likely to produce subtle bugs...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was suggesting to not attach a default value to _target and force user to specify one when they use TR::Compilation().

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think @andrewcraik's concern is around other areas of the compiler codebase using TR::Compiler-> such as the optimizer or codegen and expecting it to be the same as comp()->target()->. Does that sound correct?

Whether we specify a _target or not in TR::Compilation(), his concern will still be valid.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dchopra001 yup - any time there are two ways to answer seemingly the same question and they don't give the same answer you will get bugs. So I would prefer we find a way to avoid this duality or prevent the bugs before they happen through the structure of the code if possible.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this was a problem before as well though. We would change the comp()->target's cpu inside the TR::Compilation constructor. So if anyone was using TR::Compiler->target.cpu to grab information, it would end up being incorrect. I don't think the code in this PR specifically is introducing this problem.

Copy link
Contributor

@harryyu1994 harryyu1994 Aug 27, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh okay, that seems like a tough issue to solve and we've already run into countless bugs related to comp()->target() vs. TR::Compiler->target. In places where we are not doing compilation, TR::Compiler->target is still needed.

Copy link
Contributor

@dsouzai dsouzai Aug 27, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is the pattern to be adopted does the visibility of TR::Compiler->target need to change to stop people accidentally using it rather than the target from the compilation? Having the two and having them potentially vary seems dangerous and likely to produce subtle bugs...

Most of the queries to the target is done via the comp object; there are some outstanding locations where that hasn't happened (see #4518). I think my intention originally was to make the _target private to TR::Compiler but I couldn't do it because of those outstanding locations.

EDIT: Here's the PR where the switch to comp local target was made: #4568

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe changes were made as part of the processor detection work to avoid using TR::Compiler->target.cpu.getSupportsArch and only use comp()->target().cpu.isAtLeast when checking for a particular architecture level support. I believe this is the only area that would be different at the moment.

But I agree, this is an issue, and I did have to deal with the above mentioned problem on Z.

Copy link
Contributor

@dsouzai dsouzai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually; don't you need to also add the change to the constructor of TR::Compilation? ie in https://github.com/eclipse/omr/blob/master/compiler/compile/Compilation.hpp

This is needed so that the codegen is able to set the correct
flags when initializing.

Signed-off-by: Dhruv Chopra <[email protected]>
@dchopra001
Copy link
Contributor Author

dchopra001 commented Aug 27, 2020

Actually; don't you need to also add the change to the constructor of TR::Compilation?

I have made the change here: d0e0cc1

@andrewcraik
Copy link
Contributor

given #4518 is open I'm ok with merging this now, but I think that issue really needs some attention - this is a bug waiting to happen.

Copy link
Contributor

@andrewcraik andrewcraik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my concern about keeping the compiler and environment in sync is addressed by an open PR - I leave the detailed review to others more familiar with these paths.

@fjeremic fjeremic self-assigned this Aug 28, 2020
@fjeremic
Copy link
Contributor

fjeremic commented Aug 28, 2020

Leaving this open until Monday if anyone else has concerns given the flurry of discussion above.

@genie-omr build all

@0xdaryl
Copy link
Contributor

0xdaryl commented Aug 31, 2020

@fjeremic: Please don't merge this yet. I'd like to review and think through a few things, hopefully by end of day.

@fjeremic
Copy link
Contributor

@fjeremic: Please don't merge this yet. I'd like to review and think through a few things, hopefully by end of day.

Sure. I'll transfer committer over to you then.

@fjeremic fjeremic assigned 0xdaryl and unassigned fjeremic Aug 31, 2020
Copy link
Contributor

@0xdaryl 0xdaryl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the changes proposed here are fine. I agree that the larger problem of a disparity between the environment set outside of a compilation context (i.e., via TR::Compiler->target.cpu) versus the target within a compilation context (i.e., via comp()->target) is not addressed, but this makes the current solution incrementally better because it introduces the target before the CodeGenerator object is allocated.

However, despite #4518 remaining open it is not immediately clear without reading through the issue and between the lines what the next steps are to resolve this properly. That's not a discussion for this PR, however. I will pick up the discussion on that topic in #4518.

@0xdaryl 0xdaryl merged commit a6b90c9 into eclipse-omr:master Sep 1, 2020
@dchopra001 dchopra001 mentioned this pull request Sep 28, 2020
18 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants