[llvm] r332910 - Fix warning from r332654 with LLVM_ATTRIBUTE_USED

David Blaikie via llvm-commits llvm-commits at lists.llvm.org
Mon May 28 23:13:44 PDT 2018


If this code is only used from an assert, it should probably go in an
ifndef NDEBUG instead? (so that it is detected as unused when the assert
usage goes away).

Or is there some other reason this needs to be attributed used?

On Mon, May 21, 2018 at 3:16 PM Diego Caballero via llvm-commits <
llvm-commits at lists.llvm.org> wrote:

> Author: dcaballe
> Date: Mon May 21 15:12:38 2018
> New Revision: 332910
>
> URL: http://llvm.org/viewvc/llvm-project?rev=332910&view=rev
> Log:
> Fix warning from r332654 with LLVM_ATTRIBUTE_USED
>
> r332654 tried to fix an unused function warning with
> a void cast. This approach worked for clang and gcc
> but not for MSVC. This commit replaces the void cast
> with the LLVM_ATTRIBUTE_USED approach.
>
>
> Modified:
>     llvm/trunk/lib/Transforms/Vectorize/VPlanVerifier.cpp
>
> Modified: llvm/trunk/lib/Transforms/Vectorize/VPlanVerifier.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Vectorize/VPlanVerifier.cpp?rev=332910&r1=332909&r2=332910&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/Transforms/Vectorize/VPlanVerifier.cpp (original)
> +++ llvm/trunk/lib/Transforms/Vectorize/VPlanVerifier.cpp Mon May 21
> 15:12:38 2018
> @@ -26,7 +26,8 @@ static cl::opt<bool> EnableHCFGVerifier(
>
>  /// Utility function that checks whether \p VPBlockVec has duplicate
>  /// VPBlockBases.
> -static bool hasDuplicates(const SmallVectorImpl<VPBlockBase *>
> &VPBlockVec) {
> +LLVM_ATTRIBUTE_USED static bool
> +hasDuplicates(const SmallVectorImpl<VPBlockBase *> &VPBlockVec) {
>    SmallDenseSet<const VPBlockBase *, 8> VPBlockSet;
>    for (const auto *Block : VPBlockVec) {
>      if (VPBlockSet.count(Block))
> @@ -52,7 +53,6 @@ static void verifyBlocksInRegion(const V
>      // TODO: This won't work for switch statements.
>      assert(!hasDuplicates(Successors) &&
>             "Multiple instances of the same successor.");
> -    (void)hasDuplicates;
>
>      for (const VPBlockBase *Succ : Successors) {
>        // There must be a bi-directional link between block and successor.
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180528/039afe20/attachment.html>


More information about the llvm-commits mailing list