This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Fix miscompile in SExtWRemoval due to early return ignoring other sources
ClosedPublic

Authored by reames on Feb 8 2023, 10:27 AM.

Details

Summary

This code is walking back through a worklist of sources. All of the sources need to be sign extending for the result to be true. We had a case which returned rather than continued, which causes a miscompile when another source was not sign extended. The flawed logic was introduced in Dec 22, by change 844430bcc377.

This was recently exposed in a stage2 build of llvm-tablegen when we switched from using llvm::Optional to std::optional. The stars aligned in just the wrong way, and we started actively miscompiling idiomatic optional usage. std::optional<uint32_t> appears to use the top 32 bits of the word on RV64 for its tag.

Diff Detail

Event Timeline

reames created this revision.Feb 8 2023, 10:27 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 8 2023, 10:27 AM
reames requested review of this revision.Feb 8 2023, 10:27 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 8 2023, 10:27 AM

LGTM. We should backport to LLVM 16.

asb accepted this revision.Feb 8 2023, 11:09 AM

LGTM. Agreed this should be backported to 16.0.

This revision is now accepted and ready to land.Feb 8 2023, 11:09 AM

LGTM. We should backport to LLVM 16.

Do we have our process for requesting a backport documented somewhere? Haven't done one before.

asb added a comment.EditedFeb 8 2023, 11:54 AM

LGTM. We should backport to LLVM 16.

Do we have our process for requesting a backport documented somewhere? Haven't done one before.

It's now nice and mostly automated. Create an issue on GitHub for the cherry-pick, add it to the LLVM 16.0.0 release milestone, and you can then use these commands (in you case, /cherry-pick foo) in a comment or the initial issue description to trigger a bot to create the appropriate PR.

https://github.com/llvm/llvm-project/issues/60608 for the backport. First time doing this, so we'll see how much I manage to screw this up. :)