diff --git a/llvm/lib/Target/RISCV/RISCV.h b/llvm/lib/Target/RISCV/RISCV.h --- a/llvm/lib/Target/RISCV/RISCV.h +++ b/llvm/lib/Target/RISCV/RISCV.h @@ -35,7 +35,8 @@ bool lowerRISCVMachineOperandToMCOperand(const MachineOperand &MO, MCOperand &MCOp, const AsmPrinter &AP); -FunctionPass *createRISCVISelDag(RISCVTargetMachine &TM); +FunctionPass *createRISCVISelDag(RISCVTargetMachine &TM, + CodeGenOpt::Level OptLevel); FunctionPass *createRISCVMakeCompressibleOptPass(); void initializeRISCVMakeCompressibleOptPass(PassRegistry &); diff --git a/llvm/lib/Target/RISCV/RISCVISelDAGToDAG.h b/llvm/lib/Target/RISCV/RISCVISelDAGToDAG.h --- a/llvm/lib/Target/RISCV/RISCVISelDAGToDAG.h +++ b/llvm/lib/Target/RISCV/RISCVISelDAGToDAG.h @@ -24,8 +24,9 @@ const RISCVSubtarget *Subtarget = nullptr; public: - explicit RISCVDAGToDAGISel(RISCVTargetMachine &TargetMachine) - : SelectionDAGISel(TargetMachine) {} + explicit RISCVDAGToDAGISel(RISCVTargetMachine &TargetMachine, + CodeGenOpt::Level OptLevel) + : SelectionDAGISel(TargetMachine, OptLevel) {} StringRef getPassName() const override { return "RISCV DAG->DAG Pattern Instruction Selection"; diff --git a/llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp b/llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp --- a/llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp +++ b/llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp @@ -2436,6 +2436,7 @@ // This pass converts a legalized DAG into a RISCV-specific DAG, ready // for instruction scheduling. -FunctionPass *llvm::createRISCVISelDag(RISCVTargetMachine &TM) { - return new RISCVDAGToDAGISel(TM); +FunctionPass *llvm::createRISCVISelDag(RISCVTargetMachine &TM, + CodeGenOpt::Level OptLevel) { + return new RISCVDAGToDAGISel(TM, OptLevel); } diff --git a/llvm/lib/Target/RISCV/RISCVTargetMachine.cpp b/llvm/lib/Target/RISCV/RISCVTargetMachine.cpp --- a/llvm/lib/Target/RISCV/RISCVTargetMachine.cpp +++ b/llvm/lib/Target/RISCV/RISCVTargetMachine.cpp @@ -182,7 +182,7 @@ } bool RISCVPassConfig::addInstSelector() { - addPass(createRISCVISelDag(getRISCVTargetMachine())); + addPass(createRISCVISelDag(getRISCVTargetMachine(), getOptLevel())); return false; } diff --git a/llvm/test/CodeGen/RISCV/O0-pipeline.ll b/llvm/test/CodeGen/RISCV/O0-pipeline.ll --- a/llvm/test/CodeGen/RISCV/O0-pipeline.ll +++ b/llvm/test/CodeGen/RISCV/O0-pipeline.ll @@ -35,13 +35,6 @@ ; CHECK-NEXT: Safe Stack instrumentation pass ; CHECK-NEXT: Insert stack protectors ; CHECK-NEXT: Module Verifier -; CHECK-NEXT: Basic Alias Analysis (stateless AA impl) -; CHECK-NEXT: Function Alias Analysis Results -; CHECK-NEXT: Natural Loop Information -; CHECK-NEXT: Post-Dominator Tree Construction -; CHECK-NEXT: Branch Probability Analysis -; CHECK-NEXT: Lazy Branch Probability Analysis -; CHECK-NEXT: Lazy Block Frequency Analysis ; CHECK-NEXT: RISCV DAG->DAG Pattern Instruction Selection ; CHECK-NEXT: Finalize ISel and expand pseudo-instructions ; CHECK-NEXT: Local Stack Slot Allocation diff --git a/llvm/test/CodeGen/RISCV/isel-optnone.ll b/llvm/test/CodeGen/RISCV/isel-optnone.ll --- a/llvm/test/CodeGen/RISCV/isel-optnone.ll +++ b/llvm/test/CodeGen/RISCV/isel-optnone.ll @@ -2,11 +2,9 @@ ; RUN: llc < %s -O0 -mtriple=riscv64 -debug-only=isel 2>&1 | FileCheck %s define i32* @fooOptnone(i32* %p, i32* %q, i32** %z) #0 { -; CHECK: Changing optimization level for Function fooOptnone -; CHECL: Before: -O2 ; After: -O0 +; CHECK-NOT: Changing optimization level for Function fooOptnone +; CHECK-NOT: Restoring optimization level for Function fooOptnone -; CHECK: Restoring optimization level for Function fooOptnone -; CHECK: Before: -O0 ; After: -O2 entry: %r = load i32, i32* %p %s = load i32, i32* %q