-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Enable "Allocate on stack" for NAOT/R2R #104411
Conversation
src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/StackAllocatedBox.cs
Show resolved
Hide resolved
Is the .NET main branch broken on CE somehow? Checking the codegen for the example, yields older code. |
|
I'm surprised that you don't need to do anything on the runtime side to implement |
CI is currently failing with:
🙂 |
/azp run runtime-nativeaot-outerloop |
Azure Pipelines successfully started running 1 pipeline(s). |
I think this is ready, PTAL @jkotas @MichalStrehovsky @AndyAyersMS |
src/coreclr/nativeaot/Runtime.Base/src/System/Runtime/RuntimeExports.cs
Outdated
Show resolved
Hide resolved
Outerloops:
|
This is #104500. |
if (attribs.Length == 0) | ||
return true; // Assume corelib is optimized in this case |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding <DebuggerSupport>true</DebuggerSupport>
to the project file would make the attribute visible, but ILC has its own optimization switch so CoreLib having this attribute still doesn't necessarily imply how optimized it is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@MichalStrehovsky do we run runtime tests with NativeAOT in full debug mode?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So can you tell me how to properly check it here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@MichalStrehovsky do we run runtime tests with NativeAOT in full debug mode?
We do have such legs, I'm not sure if they include this test too. It would be in the runtime or runtime-nativeaot-outerloop if it exists.
So can you tell me how to properly check it here?
Native AOT will use the same settings for optimizing both CoreLib and user code so enabling the attribute and looking for the attribute on Assembly.GetEntryAssembly
would give the answer.
I guess I don't understand why this is looking at whether corelib is optimized. Why does that affect stack allocations in this test?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess I don't understand why this is looking at whether corelib is optimized. Why does that affect stack allocations in this test?
Maybe the way we build the tests, optimization of CoreLib always matches optimization of the test?
If that's the case, all that's needed is to add <DebuggerSupport>true</DebuggerSupport>
to the test project and this will work the same. It will also fail the same if there's ever mismatch between test optimization and corelib optimization.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess I don't understand why this is looking at whether corelib is optimized. Why does that affect stack allocations in this test?
I am not the original author (I presume the authors no longer work in the team), but looks like the test tries to be agile and validate that nothing is stack-allocated under debug maybe? 🤷
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not the original author (I presume the authors no longer work in the team), but looks like the test tries to be agile and validate that nothing is stack-allocated under debug maybe?
Right, but for that one would check whether the test is optimized, not corelib. One can build the test with <Optimize>true</Optimize>
and have corelib from a debug build. I assume the test would fail in that case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(I mean in the JIT case. It would also fail in the AOT case because I believe the test is looking at the wrong assembly.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I ended up removing these bits and the test is still working fine (it's always optimized due to <Optimize>true</Optimize>
)
/azp run runtime-nativeaot-outerloop |
Azure Pipelines successfully started running 1 pipeline(s). |
/azp run runtime-coreclr runtime-nativeaot-outerloop |
No pipelines are associated with this pull request. |
/azp run runtime-nativeaot-outerloop |
Azure Pipelines successfully started running 1 pipeline(s). |
@jkotas @MichalStrehovsky can this be merged then? All nativeaot-outerloop failures are either #104862 or #104500 |
src/tests/JIT/opt/ObjectStackAllocation/ObjectStackAllocationTests.csproj
Outdated
Show resolved
Hide resolved
src/tests/JIT/opt/ObjectStackAllocation/ObjectStackAllocationTests.csproj
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM otherwise. Thank you!
Closes #104350
Fixes #104337
This PR adds NAOT/R2R support for #103361
Example:
Old codegen for
Test()
on NAOT (and R2R):New codegen: