]> granicus.if.org Git - llvm/commitdiff
[RISCV] Fix static analysis issues
authorLuis Marques <luismarques@lowrisc.org>
Fri, 20 Sep 2019 13:48:02 +0000 (13:48 +0000)
committerLuis Marques <luismarques@lowrisc.org>
Fri, 20 Sep 2019 13:48:02 +0000 (13:48 +0000)
Unlikely to be problematic but still worth fixing.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@372391 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
lib/Target/RISCV/RISCVISelDAGToDAG.cpp
lib/Target/RISCV/RISCVISelLowering.cpp

index 8612af39c2ea7ea9db72f48d193ba6fa0928b37e..5f93db484b3ab9853a1b903e225ed43f72d771d0 100644 (file)
@@ -374,8 +374,8 @@ public:
       return true;
     // Given only Imm, ensuring that the actually specified constant is either
     // a signed or unsigned 64-bit number is unfortunately impossible.
-    bool IsInRange = isRV64() ? true : isInt<32>(Imm) || isUInt<32>(Imm);
-    return IsConstantImm && IsInRange && VK == RISCVMCExpr::VK_RISCV_None;
+    return IsConstantImm && VK == RISCVMCExpr::VK_RISCV_None &&
+           (isRV64() || (isInt<32>(Imm) || isUInt<32>(Imm)));
   }
 
   bool isUImmLog2XLen() const {
index 8439278b4ed53fdf4dfeab8be2dc036381b2725e..1a12d9177d2a679f52cd027e82489d6151711d79 100644 (file)
@@ -68,7 +68,7 @@ static SDNode *selectImm(SelectionDAG *CurDAG, const SDLoc &DL, int64_t Imm,
   RISCVMatInt::InstSeq Seq;
   RISCVMatInt::generateInstSeq(Imm, XLenVT == MVT::i64, Seq);
 
-  SDNode *Result;
+  SDNode *Result = nullptr;
   SDValue SrcReg = CurDAG->getRegister(RISCV::X0, XLenVT);
   for (RISCVMatInt::Inst &Inst : Seq) {
     SDValue SDImm = CurDAG->getTargetConstant(Inst.Imm, DL, XLenVT);
index 371e19c2ee0fad4e43ad0a0685df2546e0c22cf6..e8dedffa9c270b1e87857f064d8900f2d78921d5 100644 (file)
@@ -1903,8 +1903,7 @@ SDValue RISCVTargetLowering::LowerFormalArguments(
     // ensure that the frame pointer is 2*XLEN-aligned, which in turn ensures
     // offsets to even-numbered registered remain 2*XLEN-aligned.
     if (Idx % 2) {
-      FI = MFI.CreateFixedObject(XLenInBytes, VaArgOffset - (int)XLenInBytes,
-                                 true);
+      MFI.CreateFixedObject(XLenInBytes, VaArgOffset - (int)XLenInBytes, true);
       VarArgsSaveSize += XLenInBytes;
     }