[llvm] 6904c71 - [IR] Remove MSVC warning workaround (NFC)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 17 09:28:52 PDT 2020


On Thu, Jul 16, 2020 at 2:32 AM Kaylor, Andrew <andrew.kaylor at intel.com>
wrote:

> Hi Nikita,
>
> This change broke some of our builds, which are still using Visual Studio
> 2017. While it appears not to have caused problems for buildbots, that
> doesn't mean there are no users of LLVM who are building with VS2017 and
> werror.
>
> Can you work around the problem in a different way?
>
> Thanks,
> Andy
>

Sure! I've applied
https://github.com/llvm/llvm-project/commit/f7dce88915ad1629df2d19cd41e45a5e64f2664c
to hopefully avoid the warning, but don't have MSVC to test it myself.
Please tell me if the issue persists.

Regards,
Nikita


> -----Original Message-----
> From: llvm-commits <llvm-commits-bounces at lists.llvm.org> On Behalf Of
> Nikita Popov via llvm-commits
> Sent: Tuesday, June 23, 2020 1:34 PM
> To: llvm-commits at lists.llvm.org
> Subject: [llvm] 6904c71 - [IR] Remove MSVC warning workaround (NFC)
>
>
> Author: Nikita Popov
> Date: 2020-06-23T22:33:57+02:00
> New Revision: 6904c7129b26373eb33489b43538ab580829655e
>
> URL:
> https://github.com/llvm/llvm-project/commit/6904c7129b26373eb33489b43538ab580829655e
> DIFF:
> https://github.com/llvm/llvm-project/commit/6904c7129b26373eb33489b43538ab580829655e.diff
>
> LOG: [IR] Remove MSVC warning workaround (NFC)
>
> While LLVM does fold this to x+1, GCC does not. As this is hot code, let's
> try to avoid that.
>
> According to
>
> https://developercommunity.visualstudio.com/content/problem/211134/unsigned-integer-overflows-in-constexpr-functionsa.html
> this spurious warning in MSVC has been fixed in Visual Studio 2019 Version
> 16.4. Let's see if there are any build bots running old MSVC versions with
> warnings treated as errors...
>
> Added:
>
>
> Modified:
>     llvm/lib/IR/Attributes.cpp
>
> Removed:
>
>
>
>
> ################################################################################
> diff  --git a/llvm/lib/IR/Attributes.cpp b/llvm/lib/IR/Attributes.cpp
> index d8798eb12ae7..8bdd67907106 100644
> --- a/llvm/lib/IR/Attributes.cpp
> +++ b/llvm/lib/IR/Attributes.cpp
> @@ -965,11 +965,9 @@ std::string AttributeSetNode::getAsString(bool
> InAttrGrp) const {
> //===----------------------------------------------------------------------===//
>
>  /// Map from AttributeList index to the internal array index. Adding one
> happens -/// to work, but it relies on unsigned integer wrapping. MSVC
> warns about -/// unsigned wrapping in constexpr functions, so write out the
> conditional. LLVM -/// folds it to add anyway.
> +/// to work, because -1 wraps around to 0.
>  static constexpr unsigned attrIdxToArrayIdx(unsigned Index) {
> -  return Index == AttributeList::FunctionIndex ? 0 : Index + 1;
> +  return Index + 1;
>  }
>
>  AttributeListImpl::AttributeListImpl(ArrayRef<AttributeSet> Sets)
>
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> https://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/20200717/acc5bf56/attachment.html>


More information about the llvm-commits mailing list