[llvm] r338204 - [X86] Correct the immediate cost for 'add/sub i64 %x, 0x80000000'.

Dean Michael Berris via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 30 02:45:44 PDT 2018


Confirmed locally that the revert fixes the ubsan failures. Reverted in r338236.
On Mon, Jul 30, 2018 at 7:13 PM Dean Michael Berris <dberris at google.com> wrote:
>
> Hi Craig,
>
> This breaks in ubsan builds:
>
> -- Testing: 26927 tests, 64 threads --
> Testing: 0 .. 10.. 20.. 30.. 40.. 50
> FAIL: LLVM :: CodeGen/X86/lsr-overflow.ll (14236 of 26927)
> ******************** TEST 'LLVM :: CodeGen/X86/lsr-overflow.ll' FAILED
> ********************
> Script:
> --
> : 'RUN: at line 1';
> /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build_ubsan/bin/llc
> < /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm/test/CodeGen/X86/lsr-overflow.ll
> -mtriple=x86_64-linux |
> /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build_ubsan/bin/FileCheck
> /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm/test/CodeGen/X86/lsr-overflow.ll
> : 'RUN: at line 2';
> /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build_ubsan/bin/llc
> < /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm/test/CodeGen/X86/lsr-overflow.ll
> -mtriple=x86_64-win32 |
> /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build_ubsan/bin/FileCheck
> /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm/test/CodeGen/X86/lsr-overflow.ll
> --
> Exit Code: 2
>
> Command Output (stderr):
> --
> /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm/lib/Target/X86/X86TargetTransformInfo.cpp:2340:58:
> runtime error: negation of -9223372036854775808 cannot be represented
> in type 'int64_t' (aka 'long'); cast to an unsigned type to negate
> this value to itself
>     #0 0x154e929 in llvm::X86TTIImpl::getIntImmCost(unsigned int,
> unsigned int, llvm::APInt const&, llvm::Type*)
> /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm/lib/Target/X86/X86TargetTransformInfo.cpp:2340:58
>     #1 0x19ec8e3 in llvm::TargetTransformInfo::getIntImmCost(unsigned
> int, unsigned int, llvm::APInt const&, llvm::Type*) const
> /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm/lib/Analysis/TargetTransformInfo.cpp:319:23
>     #2 0x226028f in
> llvm::ConstantHoistingPass::collectConstantCandidates(llvm::DenseMap<llvm::ConstantInt*,
> unsigned int, llvm::DenseMapInfo<llvm::ConstantInt*>,
> llvm::detail::DenseMapPair<llvm::ConstantInt*, unsigned int> >&,
> llvm::Instruction*, unsigned int, llvm::ConstantInt*)
> /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm/lib/Transforms/Scalar/ConstantHoisting.cpp:354:17
>     #3 0x2260ca9 in
> llvm::ConstantHoistingPass::collectConstantCandidates(llvm::DenseMap<llvm::ConstantInt*,
> unsigned int, llvm::DenseMapInfo<llvm::ConstantInt*>,
> llvm::detail::DenseMapPair<llvm::ConstantInt*, unsigned int> >&,
> llvm::Instruction*)
> /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm/lib/Transforms/Scalar/ConstantHoisting.cpp:433:7
>     #4 0x2260e09 in
> llvm::ConstantHoistingPass::collectConstantCandidates(llvm::Function&)
> /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm/lib/Transforms/Scalar/ConstantHoisting.cpp:444:7
>     #5 0x22643c5 in
> llvm::ConstantHoistingPass::runImpl(llvm::Function&,
> llvm::TargetTransformInfo&, llvm::DominatorTree&,
> llvm::BlockFrequencyInfo*, llvm::BasicBlock&)
> /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm/lib/Transforms/Scalar/ConstantHoisting.cpp:786:3
>     #6 0x2264bf7 in (anonymous
> namespace)::ConstantHoistingLegacyPass::runOnFunction(llvm::Function&)
> /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm/lib/Transforms/Scalar/ConstantHoisting.cpp:139:12
>     #7 0x20f3972 in
> llvm::FPPassManager::runOnFunction(llvm::Function&)
> /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm/lib/IR/LegacyPassManager.cpp:1586:27
>     #8 0x20f3d36 in llvm::FPPassManager::runOnModule(llvm::Module&)
> /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm/lib/IR/LegacyPassManager.cpp:1609:16
>     #9 0x20f4435 in runOnModule
> /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm/lib/IR/LegacyPassManager.cpp:1669:27
>     #10 0x20f4435 in llvm::legacy::PassManagerImpl::run(llvm::Module&)
> /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm/lib/IR/LegacyPassManager.cpp:1774
>     #11 0x796eeb in compileModule(char**, llvm::LLVMContext&)
> /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm/tools/llc/llc.cpp:597:8
>     #12 0x79449b in main
> /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm/tools/llc/llc.cpp:351:22
>     #13 0x7fef709be2e0 in __libc_start_main
> (/lib/x86_64-linux-gnu/libc.so.6+0x202e0)
>     #14 0x775c49 in _start
> (/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build_ubsan/bin/llc+0x775c49)
>
> FileCheck error: '-' is empty.
> FileCheck command line:
> /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build_ubsan/bin/FileCheck
> /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm/test/CodeGen/X86/lsr-overflow.ll
>
> --
>
> ********************
> Testing: 0 .. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90..
> Testing Time: 56.81s
> ********************
> Failing Tests (1):
>     LLVM :: CodeGen/X86/lsr-overflow.ll
>
>   Expected Passes    : 26101
>   Expected Failures  : 149
>   Unsupported Tests  : 676
>   Unexpected Failures: 1
> FAILED: test/CMakeFiles/check-llvm
>
> This is caught by
> http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-bootstrap-ubsan/builds/5233/steps/check-llvm%20ubsan/logs/stdio
> -- can we revert this in the meantime?
>
> Cheers
> On Sun, Jul 29, 2018 at 4:22 AM Craig Topper via llvm-commits
> <llvm-commits at lists.llvm.org> wrote:
> >
> > Author: ctopper
> > Date: Sat Jul 28 11:21:46 2018
> > New Revision: 338204
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=338204&view=rev
> > Log:
> > [X86] Correct the immediate cost for 'add/sub i64 %x, 0x80000000'.
> >
> > X86 normally requires immediates to be a signed 32-bit value which would exclude i64 0x80000000. But for add/sub we can negate the constant and use the opposite instruction.
> >
> > Modified:
> >     llvm/trunk/lib/Target/X86/X86TargetTransformInfo.cpp
> >
> > Modified: llvm/trunk/lib/Target/X86/X86TargetTransformInfo.cpp
> > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86TargetTransformInfo.cpp?rev=338204&r1=338203&r2=338204&view=diff
> > ==============================================================================
> > --- llvm/trunk/lib/Target/X86/X86TargetTransformInfo.cpp (original)
> > +++ llvm/trunk/lib/Target/X86/X86TargetTransformInfo.cpp Sat Jul 28 11:21:46 2018
> > @@ -2332,9 +2332,15 @@ int X86TTIImpl::getIntImmCost(unsigned O
> >      // immediates here as the normal path expects bit 31 to be sign extended.
> >      if (Idx == 1 && Imm.getBitWidth() == 64 && isUInt<32>(Imm.getZExtValue()))
> >        return TTI::TCC_Free;
> > -    LLVM_FALLTHROUGH;
> > +    ImmIdx = 1;
> > +    break;
> >    case Instruction::Add:
> >    case Instruction::Sub:
> > +    // For add/sub, we can use the opposite instruction for INT32_MIN.
> > +    if (Idx == 1 && Imm.getBitWidth() == 64 && isInt<32>(-Imm.getSExtValue()))
> > +      return TTI::TCC_Free;
> > +    ImmIdx = 1;
> > +    break;
> >    case Instruction::Mul:
> >    case Instruction::UDiv:
> >    case Instruction::SDiv:
> >
> >
> > _______________________________________________
> > llvm-commits mailing list
> > llvm-commits at lists.llvm.org
> > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits


More information about the llvm-commits mailing list