[llvm] r317908 - [RISCV] Silence an unused variable warning in release builds [NFC]

Mandeep Singh Grang via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 10 11:09:28 PST 2017


Author: mgrang
Date: Fri Nov 10 11:09:28 2017
New Revision: 317908

URL: http://llvm.org/viewvc/llvm-project?rev=317908&view=rev
Log:
[RISCV] Silence an unused variable warning in release builds [NFC]

Summary:
Also minor cleanups:
1. Avoided multiple calls to Fixup.getKind()
2. Avoided multiple calls to getFixupKindInfo()
3. Removed a redundant return.

Reviewers: asb, apazos

Reviewed By: asb

Subscribers: rbar, johnrusso, llvm-commits

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

Modified:
    llvm/trunk/lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.cpp
    llvm/trunk/lib/Target/RISCV/RISCVRegisterInfo.cpp

Modified: llvm/trunk/lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.cpp?rev=317908&r1=317907&r2=317908&view=diff
==============================================================================
--- llvm/trunk/lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.cpp (original)
+++ llvm/trunk/lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.cpp Fri Nov 10 11:09:28 2017
@@ -161,11 +161,9 @@ void RISCVAsmBackend::applyFixup(const M
                                  MutableArrayRef<char> Data, uint64_t Value,
                                  bool IsResolved) const {
   MCContext &Ctx = Asm.getContext();
-  MCFixupKind Kind = Fixup.getKind();
-  unsigned NumBytes = (getFixupKindInfo(Kind).TargetSize + 7) / 8;
+  MCFixupKindInfo Info = getFixupKindInfo(Fixup.getKind());
   if (!Value)
     return; // Doesn't change encoding.
-  MCFixupKindInfo Info = getFixupKindInfo(Fixup.getKind());
   // Apply any target-specific value adjustments.
   Value = adjustFixupValue(Fixup, Value, Ctx);
 
@@ -173,14 +171,17 @@ void RISCVAsmBackend::applyFixup(const M
   Value <<= Info.TargetOffset;
 
   unsigned Offset = Fixup.getOffset();
+
+#ifndef NDEBUG
+  unsigned NumBytes = (Info.TargetSize + 7) / 8;
   assert(Offset + NumBytes <= Data.size() && "Invalid fixup offset!");
+#endif
 
   // For each byte of the fragment that the fixup touches, mask in the
   // bits from the fixup value.
   for (unsigned i = 0; i != 4; ++i) {
     Data[Offset + i] |= uint8_t((Value >> (i * 8)) & 0xff);
   }
-  return;
 }
 
 std::unique_ptr<MCObjectWriter>

Modified: llvm/trunk/lib/Target/RISCV/RISCVRegisterInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/RISCV/RISCVRegisterInfo.cpp?rev=317908&r1=317907&r2=317908&view=diff
==============================================================================
--- llvm/trunk/lib/Target/RISCV/RISCVRegisterInfo.cpp (original)
+++ llvm/trunk/lib/Target/RISCV/RISCVRegisterInfo.cpp Fri Nov 10 11:09:28 2017
@@ -82,7 +82,6 @@ void RISCVRegisterInfo::eliminateFrameIn
 
   MI.getOperand(FIOperandNum).ChangeToRegister(FrameReg, false);
   MI.getOperand(FIOperandNum + 1).ChangeToImmediate(Offset);
-  return;
 }
 
 unsigned RISCVRegisterInfo::getFrameRegister(const MachineFunction &MF) const {




More information about the llvm-commits mailing list