[PATCH] D53821: [ELF][PPC64]Workaround bogus Visual Studio build warning

James Henderson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 29 09:32:55 PDT 2018


jhenderson created this revision.
jhenderson added reviewers: ruiu, sfertile.
Herald added subscribers: jsji, kbarton, arichardson, nemanjai, emaste.
Herald added a reviewer: espindola.

Visual Studio has a bug where it converts the integer literal 2147483648 into an unsigned int instead of a long long (i.e. it follows C89 rules). The bug has been reported as https://developercommunity.visualstudio.com/content/problem/141813/-2147483648-c4146-error.html. Because of this bug, we were getting a signed/unsigned comparison warning in VS2015 from the old code (the subsequent unary negation had no effect on the type). I have fixed this by assigning the literal to an int32_t explicitly before the comparison. We could also fix this by using `INT32_MIN` or `std::numeric_limts<int32_t>::min()`, if preferred.


Repository:
  rLLD LLVM Linker

https://reviews.llvm.org/D53821

Files:
  ELF/Arch/PPC64.cpp


Index: ELF/Arch/PPC64.cpp
===================================================================
--- ELF/Arch/PPC64.cpp
+++ ELF/Arch/PPC64.cpp
@@ -850,7 +850,8 @@
   int32_t StackFrameSize = (HiImm * 65536) + LoImm;
   // Check that the adjusted size doesn't overflow what we can represent with 2
   // instructions.
-  if (StackFrameSize < -2147483648 + Config->SplitStackAdjustSize) {
+  int32_t MinValue = -2147483648;
+  if (StackFrameSize < MinValue + Config->SplitStackAdjustSize) {
     error(getErrorLocation(Loc) + "split-stack prologue adjustment overflows");
     return false;
   }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D53821.171521.patch
Type: text/x-patch
Size: 591 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181029/de09b159/attachment.bin>


More information about the llvm-commits mailing list