[RISCV][NFC] Combine the control flow for different RetOp of interrupt function
authorJim Lin <jim@andestech.com>
Sat, 26 Jun 2021 09:28:01 +0000 (17:28 +0800)
committerJim Lin <jim@andestech.com>
Sat, 26 Jun 2021 09:28:03 +0000 (17:28 +0800)
Reviewed By: frasercrmck

Differential Revision: https://reviews.llvm.org/D104838

llvm/lib/Target/RISCV/RISCVISelLowering.cpp

index 7f9d0cf..3cf3ad9 100644 (file)
@@ -8029,6 +8029,7 @@ RISCVTargetLowering::LowerReturn(SDValue Chain, CallingConv::ID CallConv,
     RetOps.push_back(Glue);
   }
 
+  unsigned RetOpc = RISCVISD::RET_FLAG;
   // Interrupt service routines use different return instructions.
   const Function &Func = DAG.getMachineFunction().getFunction();
   if (Func.hasFnAttribute("interrupt")) {
@@ -8040,18 +8041,15 @@ RISCVTargetLowering::LowerReturn(SDValue Chain, CallingConv::ID CallConv,
     StringRef Kind =
       MF.getFunction().getFnAttribute("interrupt").getValueAsString();
 
-    unsigned RetOpc;
     if (Kind == "user")
       RetOpc = RISCVISD::URET_FLAG;
     else if (Kind == "supervisor")
       RetOpc = RISCVISD::SRET_FLAG;
     else
       RetOpc = RISCVISD::MRET_FLAG;
-
-    return DAG.getNode(RetOpc, DL, MVT::Other, RetOps);
   }
 
-  return DAG.getNode(RISCVISD::RET_FLAG, DL, MVT::Other, RetOps);
+  return DAG.getNode(RetOpc, DL, MVT::Other, RetOps);
 }
 
 void RISCVTargetLowering::validateCCReservedRegs(