Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Forbid LEA without index AND base.#10771

Merged
sandreenko merged 1 commit intodotnet:masterfrom
sandreenko:add-some-asserts
Apr 10, 2017
Merged

Forbid LEA without index AND base.#10771
sandreenko merged 1 commit intodotnet:masterfrom
sandreenko:add-some-asserts

Conversation

@sandreenko
Copy link

@sandreenko sandreenko commented Apr 6, 2017

GT_LEA could have null op1 and null op2. There is no check that at least one operator is presented during a creation process.

This case was not reflected in GenTreeUseEdgeIterator.
It caused an assert failure on a test with a static pinned array.

[FixedAddressValueType]
static int arr[]={1,2,3};

int e = arr[1]; // constant base + constant index * constant size.

It required minopts to prevent constant folding during Value numbering.

Fix DevDiv 400702. I spent some time but was not able to create a small repro for it.

@sandreenko sandreenko force-pushed the add-some-asserts branch 2 times, most recently from 0f5d7a2 to c619b68 Compare April 7, 2017 00:10
@sandreenko sandreenko changed the title [WIP] add some asserts into codegen::genCreateAddrMode return correct edge iterator for GT_LEA Apr 7, 2017
@sandreenko sandreenko requested review from BruceForstall and pgavlin and removed request for BruceForstall April 7, 2017 00:13
@sandreenko
Copy link
Author

PTAL @dotnet/jit-contrib

@sandreenko
Copy link
Author

@dotnet-bot test tizen armel Cross Debug Build

@pgavlin
Copy link

pgavlin commented Apr 7, 2017

@sandreenko it seems odd that we are seeing an address tree of the form that you've described, especially if this occurs only on CoreRT. Are we sure that the base should be a compile-time constant that isn't a relocatable handle (which would not be constant-foldable)?

@sandreenko
Copy link
Author

It is not connected with CoreRT, it is RyuJit x86 problem.
@BruceForstall we need your opinion about this PR.
Possible solutions are:

  1. forbid addr modes without registers, return false in doAddrMode() if it happens and:
    1.1. do constant folding in morph( it will positively affect more code rather then addrModes) ;
    1.2 do not fold constant trees in minopts;
    1.3 do local constant folding from value numbering in minOpts (the best variant in my opinion, but it requires the separate issue).
  2. allow addr modes without registers (it is the current PR), but change EdgeIterator;
  3. return doAddrMode == true for this case, but check that it is actual constant and create constant instead of LEA. (I do not like this variant, it makes code less clear).

@pgavlin
Copy link

pgavlin commented Apr 7, 2017

(3) is my preferred solution, as it is minimally invasive and does not change the semantics of GT_LEA (unlike option 2).

@BruceForstall
Copy link

I'm a bit confused about your suggestions. For 1, are you suggesting having genCreateAddrMode() (not doAddrMode(), which isn't a function that I see) return false if the address mode it computes is purely a constant? That would be my preference. I don't see the need to change any constant folding, in minopts. The comment for genCreateAddrMode() already says it doesn't handle pure [icon] addressing modes, but it didn't expect to see an add that creates such a thing. Changing it to return false in this case seems to strengthen its existing contract.

@danmoseley
Copy link
Member

@dotnet-bot test OSX10.12 x64 Checked Build and Test (network)

@sandreenko sandreenko changed the title return correct edge iterator for GT_LEA Forbid LEA without index AND base. Apr 9, 2017
@sandreenko
Copy link
Author

PR was updated. Please look again.

Copy link

@pgavlin pgavlin left a comment

Choose a reason for hiding this comment

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

LGTM

@sandreenko sandreenko merged commit 25ae09a into dotnet:master Apr 10, 2017
@sandreenko sandreenko deleted the add-some-asserts branch April 10, 2017 16:41
@karelz karelz modified the milestone: 2.0.0 Aug 28, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants