Index: llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp =================================================================== --- llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp +++ llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp @@ -130,6 +130,7 @@ } void RISCVDAGToDAGISel::PostprocessISelDAG() { + HandleSDNode Dummy(CurDAG->getRoot()); SelectionDAG::allnodes_iterator Position = CurDAG->allnodes_end(); bool MadeChange = false; @@ -144,6 +145,8 @@ MadeChange |= doPeepholeMaskedRVV(N); } + CurDAG->setRoot(Dummy.getValue()); + if (MadeChange) CurDAG->RemoveDeadNodes(); }