[llvm] 723fea2 - Silence 'warning: unused variable' when compiling with Clang 10.0

David Blaikie via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 23 14:25:42 PDT 2020


Generally, if a variable is only used in one assertion right next to
it - it'd be preferably to fold the expression into the assertion,
rather than #ifndefing (makes future changes easier - the assertion
can be removed without leaving dead code, etc)

On Tue, Sep 22, 2020 at 9:17 AM Alexandre Ganea via llvm-commits
<llvm-commits at lists.llvm.org> wrote:
>
>
> Author: Alexandre Ganea
> Date: 2020-09-22T12:17:40-04:00
> New Revision: 723fea23079f9c85800e5cdc90a75414af182bfd
>
> URL: https://github.com/llvm/llvm-project/commit/723fea23079f9c85800e5cdc90a75414af182bfd
> DIFF: https://github.com/llvm/llvm-project/commit/723fea23079f9c85800e5cdc90a75414af182bfd.diff
>
> LOG: Silence 'warning: unused variable' when compiling with Clang 10.0
>
> Added:
>
>
> Modified:
>     llvm/lib/CodeGen/PeepholeOptimizer.cpp
>
> Removed:
>
>
>
> ################################################################################
> diff  --git a/llvm/lib/CodeGen/PeepholeOptimizer.cpp b/llvm/lib/CodeGen/PeepholeOptimizer.cpp
> index ca9e3cd25caa..4f05468d976b 100644
> --- a/llvm/lib/CodeGen/PeepholeOptimizer.cpp
> +++ b/llvm/lib/CodeGen/PeepholeOptimizer.cpp
> @@ -1413,7 +1413,9 @@ bool PeepholeOptimizer::foldRedundantCopy(
>
>    MachineInstr *PrevCopy = CopyMIs.find(SrcPair)->second;
>
> +#ifndef NDEBUG
>    unsigned PrevSrcSubReg = PrevCopy->getOperand(1).getSubReg();
> +#endif
>    assert(SrcSubReg == PrevSrcSubReg && "Unexpected mismatching subreg!");
>
>    Register PrevDstReg = PrevCopy->getOperand(0).getReg();
>
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits


More information about the llvm-commits mailing list