[RISCV] Pass OptLevel to `RISCVDAGToDAGISel` correctly
authoreopXD <eop.chen@sifive.com>
Mon, 30 May 2022 12:06:48 +0000 (05:06 -0700)
committereopXD <eop.chen@sifive.com>
Tue, 31 May 2022 00:22:50 +0000 (17:22 -0700)
commit2cadf84fc817a6c89eca0556a078d7879091e2a5
treef6d8a9b1fc1f18d78112f7d55604fca77c601fa2
parent40e52d30332e2e7da7f08018bb91f87440c01e8d
[RISCV] Pass OptLevel to `RISCVDAGToDAGISel` correctly

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.

Reviewed By: craig.topper

Differential Revision: https://reviews.llvm.org/D126641
llvm/lib/Target/RISCV/RISCV.h
llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp
llvm/lib/Target/RISCV/RISCVISelDAGToDAG.h
llvm/lib/Target/RISCV/RISCVTargetMachine.cpp
llvm/test/CodeGen/RISCV/O0-pipeline.ll
llvm/test/CodeGen/RISCV/isel-optnone.ll