[llvm] a5099ad - [WebAssembly] Fix a warning for an unused variable

David Blaikie via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 15 11:47:47 PDT 2020


Perhaps this could be rephrased to avoid the need for the
assert-conditionally-used variable & perhaps more readable:

auto I = llvm::find_if(llvm::reverse(*EHPadLayoutPred), [&](const
MachineInstr &Instr) {
  return Instr->isTerminator();
});
assert(I != EHPadLayoutPred->rend() && "Unconditional branch not found!");
assert(I->getOpcode() == WebAssembly::BR);
I->eraseFromParent();

I /think/ that'd be equivalent and work correctly.


On Wed, Jun 10, 2020 at 10:07 AM Heejin Ahn via llvm-commits
<llvm-commits at lists.llvm.org> wrote:
>
>
> Author: Heejin Ahn
> Date: 2020-06-10T10:06:28-07:00
> New Revision: a5099ad918c58e8a5b713cdf5b8e946b8bdfaa5f
>
> URL: https://github.com/llvm/llvm-project/commit/a5099ad918c58e8a5b713cdf5b8e946b8bdfaa5f
> DIFF: https://github.com/llvm/llvm-project/commit/a5099ad918c58e8a5b713cdf5b8e946b8bdfaa5f.diff
>
> LOG: [WebAssembly] Fix a warning for an unused variable
>
> `ErasedUncondBr` is used only in an `assert`, so it triggers a warning
> on builds without assertions. Fixed.
>
> Added:
>
>
> Modified:
>     llvm/lib/Target/WebAssembly/WebAssemblyCFGStackify.cpp
>
> Removed:
>
>
>
> ################################################################################
> diff  --git a/llvm/lib/Target/WebAssembly/WebAssemblyCFGStackify.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyCFGStackify.cpp
> index 103fe97c6e93..ddf2d8bdfc05 100644
> --- a/llvm/lib/Target/WebAssembly/WebAssemblyCFGStackify.cpp
> +++ b/llvm/lib/Target/WebAssembly/WebAssemblyCFGStackify.cpp
> @@ -679,6 +679,7 @@ void WebAssemblyCFGStackify::removeUnnecessaryInstrs(MachineFunction &MF) {
>      if (Analyzable && ((Cond.empty() && TBB && TBB == Cont) ||
>                         (!Cond.empty() && FBB && FBB == Cont))) {
>        bool ErasedUncondBr = false;
> +      (void)ErasedUncondBr;
>        for (auto I = EHPadLayoutPred->end(), E = EHPadLayoutPred->begin();
>             I != E; --I) {
>          auto PrevI = std::prev(I);
>
>
>
> _______________________________________________
> 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