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

[NativeAOT-LLVM] For TARGET_WASM do not expand to GT_INDEX_ADDR #1824

Merged
merged 3 commits into from
Feb 8, 2022

Conversation

yowl
Copy link
Contributor

@yowl yowl commented Jan 17, 2022

This PR adds support in the LLVM clrjit for the GT_INDEX_ADDR instruction. Do I need some todo's in here for 64 bit Wasm on either the index, the element offset (unlikely I suppose, its just the type + length I think), or the element size?

@cc SingleAccretion.

Thanks,

@yowl
Copy link
Contributor Author

yowl commented Jan 17, 2022

cc @SingleAccretion (had @ in the wrong place)

Comment on lines 1125 to 1133
void Llvm::buildIndexAddr(GenTreeIndexAddr* indexAddr)
{
Value* firstElementAddr =
_builder.CreateGEP(getGenTreeValue(indexAddr->gtGetOp1()), _builder.getInt32(indexAddr->gtElemOffset));
Value* offset = _builder.CreateMul(_builder.getInt32(indexAddr->gtElemSize), getGenTreeValue(indexAddr->Index()));

mapGenTreeToValue(indexAddr, _builder.CreateGEP(firstElementAddr, offset));
}

Choose a reason for hiding this comment

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

Hmm, this won't work as-is, INDEX_ADDR is effectively bounds-checked (and we're missing the bounds check).

I think it would be better to just always fully expand INDEX in morph for LLVM, INDEX_ADDR's only purpose is to increase throughput under MinOpts, and I think that sort of tuning can wait (and is probably not worthwhile anyway).

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 see you've got a PR in runtime around this area. Would you prefer this was left until that was accepted and merged here?

Choose a reason for hiding this comment

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

I don't think there is a need to block this change on my changes in the runtime.

The fix here should be very simple: #ifdef-out the logic that creates INDEX_ADDRs for TARGET_WASM in fgMorphArrayIndex.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thanks, have #if'ed it out.

@yowl yowl changed the title [NativeAOT-LLVM] Add support for GT_INDEX_ADDR [NativeAOT-LLVM] For TARGET_WASM do not expand to GT_INDEX_ADDR Feb 8, 2022
@jkotas jkotas merged commit 56a3284 into dotnet:feature/NativeAOT-LLVM Feb 8, 2022
@yowl yowl deleted the llvm-gt-index-addr branch February 8, 2022 21:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants