Skip to content

Conversation

@amanasifkhalid
Copy link
Contributor

@amanasifkhalid amanasifkhalid commented Aug 6, 2024

Fixes #105971. Lowering::TryMakeIndirsAdjacent and Lowering::TryMakeIndirAndStoreAdjacent require that no GenTree nodes are marked upon entry, and that marked nodes are cleared upon exit, but in the case of the first method, not every exit path was unmarking the tree. jitstd::utility::scoped_code makes this invariant clear.

@ghost ghost added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Aug 6, 2024
@amanasifkhalid
Copy link
Contributor Author

/azp run runtime-coreclr superpmi-asmdiffs-checked-release

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@amanasifkhalid amanasifkhalid changed the title JIT: Save/Restore gtLIRFlags state on Debug path in Lowering::TryMakeIndirsAdjacent JIT: Use jitstd::utility::scoped_code to unmark trees during lowering Aug 6, 2024
@amanasifkhalid
Copy link
Contributor Author

/azp run runtime-coreclr superpmi-asmdiffs-checked-release

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@amanasifkhalid
Copy link
Contributor Author

cc @dotnet/jit-contrib, @jakobbotsch PTAL. Thanks!

Copy link
Member

@jakobbotsch jakobbotsch left a comment

Choose a reason for hiding this comment

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

Thanks for fixing this!

Copy link
Contributor

@teo-tsirpanis teo-tsirpanis left a comment

Choose a reason for hiding this comment

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

There's a chance (I'm not 100% sure, I haven't tried it) that C++ can deduce the template argument, which can enable inlining the auto code = variable.

Comment on lines +9362 to +9365
auto code = [this, indir] {
UnmarkTree(indir);
};
jitstd::utility::scoped_code<decltype(code)> finally(code);
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
auto code = [this, indir] {
UnmarkTree(indir);
};
jitstd::utility::scoped_code<decltype(code)> finally(code);
jitstd::utility::scoped_code finally([this, indir] {
UnmarkTree(indir);
});

Comment on lines +1204 to +1207
auto code = [this, store] {
UnmarkTree(store);
};
jitstd::utility::scoped_code<decltype(code)> finally(code);
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
auto code = [this, store] {
UnmarkTree(store);
};
jitstd::utility::scoped_code<decltype(code)> finally(code);
jitstd::utility::scoped_code finally([this, store] {
UnmarkTree(store);
});

@amanasifkhalid
Copy link
Contributor Author

There's a chance (I'm not 100% sure, I haven't tried it) that C++ can deduce the template argument, which can enable inlining the auto code = variable.

Thank you for the suggestion! I tried this, and it didn't compile... I don't think this type deduction works when it's used on a templated class, at least in C++11.

@amanasifkhalid amanasifkhalid merged commit 95e1d8d into dotnet:main Aug 7, 2024
@teo-tsirpanis
Copy link
Contributor

Oh you are on C++11, this feature was added in C++17. 😔

@amanasifkhalid amanasifkhalid deleted the fix-checked-release-diffs branch August 7, 2024 14:46
@amanasifkhalid
Copy link
Contributor Author

Oh you are on C++11, this feature was added in C++17. 😔

Yeah, I'm not sure if we have any plans to upgrade in the near future, though it's helpful to know this is another pattern we could clean up if we did upgrade.

@github-actions github-actions bot locked and limited conversation to collaborators Sep 7, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

JIT: checked-release asmdiffs for libraries_tests.run.linux.arm64.Release.mch

3 participants