This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Pass OptLevel to `RISCVDAGToDAGISel` correctly
ClosedPublic

Authored by eopXD on May 30 2022, 5:07 AM.

Details

Summary

Originally, OptLevel isn't passed into the MachineFunctionPass.
This lets the default parameter of SelectionDAGISel, which is
CodeGenOpt::Default, be passed in. OptLevelChanger captures the
optimization level with the parameter, and rather not the value
within TargetMachine. This lets the optimization be
unintentionally overwriten if other value than CodeGenOpt::Default
passed.

This patch fixes this by passing the optimization level rather
than using the default value.

Diff Detail

Event Timeline

eopXD created this revision.May 30 2022, 5:07 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 30 2022, 5:07 AM
eopXD requested review of this revision.May 30 2022, 5:07 AM
eopXD retitled this revision from [RISCV] Pass OptLevel to RISCVDAGToDAGISel correctly to [RISCV] Pass OptLevel to `RISCVDAGToDAGISel` correctly.May 30 2022, 5:08 AM
eopXD edited the summary of this revision. (Show Details)
eopXD added a comment.May 30 2022, 1:43 PM

Created pre-commit test case D126677, will rebase upon it to reflect the change.

craig.topper accepted this revision.May 30 2022, 2:52 PM

I see that this is how many other targets do it. It would have been helpful to mention that in the description so we immediately know you're not inventing something new.

LGTM

This revision is now accepted and ready to land.May 30 2022, 2:52 PM
eopXD updated this revision to Diff 432991.May 30 2022, 4:07 PM

Rebase and show bug fix.

eopXD updated this revision to Diff 432993.EditedMay 30 2022, 4:16 PM

Update checks for CodeGen/RISCV/O0-pipeline.ll.

Now the correct optimization level is recovered, some passes should not be executed.

eopXD added a comment.May 30 2022, 5:22 PM

I see that this is how many other targets do it. It would have been helpful to mention that in the description so we immediately know you're not inventing something new.

LGTM

Yes you are right, I could have done better explaining my patch.
I will try to mention how other targets do to bring in the context.
Thank you for the swift review.

This revision was landed with ongoing or failed builds.May 30 2022, 5:22 PM
This revision was automatically updated to reflect the committed changes.

I see that this is how many other targets do it. It would have been helpful to mention that in the description so we immediately know you're not inventing something new.

LGTM

Yes you are right, I could have done better explaining my patch.
I will try to mention how other targets do to bring in the context.
Thank you for the swift review.

The commit message was identical to the original review summary?..

eopXD added a comment.May 30 2022, 5:27 PM

I see that this is how many other targets do it. It would have been helpful to mention that in the description so we immediately know you're not inventing something new.

LGTM

Yes you are right, I could have done better explaining my patch.
I will try to mention how other targets do to bring in the context.
Thank you for the swift review.

What I meant is I will explain things better in the future.