From eebabb0665099dc705be28ecc5d85d1304a098db Mon Sep 17 00:00:00 2001 From: Florian Hahn Date: Sat, 15 Dec 2018 01:32:58 +0000 Subject: [PATCH] [SILoadStoreOptimizer] Use std::abs to avoid truncation. Using regular abs() causes the following warning error: absolute value function 'abs' given an argument of type 'int64_t' (aka 'long') but has parameter of type 'int' which may cause truncation of value [-Werror,-Wabsolute-value] (uint32_t)abs(Dist) > MaxDist) { ^ lib/Target/AMDGPU/SILoadStoreOptimizer.cpp:1369:19: note: use function 'std::abs' instead which causes a bot to fail: http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux/builds/18284/steps/bootstrap%20clang/logs/stdio llvm-svn: 349224 --- lib/Target/AMDGPU/SILoadStoreOptimizer.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Target/AMDGPU/SILoadStoreOptimizer.cpp b/lib/Target/AMDGPU/SILoadStoreOptimizer.cpp index d755f7609cc..9f3983c7256 100644 --- a/lib/Target/AMDGPU/SILoadStoreOptimizer.cpp +++ b/lib/Target/AMDGPU/SILoadStoreOptimizer.cpp @@ -1366,8 +1366,8 @@ bool SILoadStoreOptimizer::promoteConstantOffsetToImm( AM.HasBaseReg = true; AM.BaseOffs = Dist; if (TLI->isLegalGlobalAddressingMode(AM) && - (uint32_t)abs(Dist) > MaxDist) { - MaxDist = abs(Dist); + (uint32_t)std::abs(Dist) > MaxDist) { + MaxDist = std::abs(Dist); AnchorAddr = MAddrNext; AnchorInst = &MINext;