1. Aug 19, 2019
    • Fangrui Song's avatar
      [ELF] Simplify processRelocAux and allow a corner-case error · ec4540d8
      Fangrui Song authored
      After D66007/r369262, if the control flow reaches `if (sym.isUndefined())`, we know:
      
      * The relocation is not a link-time constant => symbol is preemptable => Undefined or SharedSymbol
      * Not an undef weak.
      * -no-pie.
      * The symbol type is neither STT_OBJECT nor STT_FUNC.
      
      ld.lld --export-dynamic --unresolved-symbols=ignore-all %t.o can satisfy
      these conditions. Delete the isUndefined() test so that we error
      `symbol '...' has no type`, because we don't know the type to make the
      decision to create copy relocation/canonical PLT.
      
      llvm-svn: 369271
      ec4540d8
    • Zoe Carver's avatar
      [libc++] reverts commit a5f5aad5. · 471bbb6e
      Zoe Carver authored
      The commit being reverted caused segfaults when building
      with libc++ and GCC (and possibly other configurations).
      
      Differential Revision: https://reviews.llvm.org/D62868
      
      llvm-svn: 369270
      471bbb6e
    • Pavel Labath's avatar
      Filesystem/Windows: fix inconsistency in readNativeFileSlice API · 08c77b97
      Pavel Labath authored
      Summary:
      The windows version implementation of readNativeFileSlice, was trying to
      match the POSIX behavior of not treating EOF as an error, but it was
      only handling the case of reading from a pipe. Attempting to read past
      the end of a regular file returns a slightly different error code, which
      needs to be handled too. This patch adds ERROR_HANDLE_EOF to the list of
      error codes to be treated as an end of file, and adds some unit tests
      for the API.
      
      This issue was found while attempting to land D66224, which caused a bunch of
      lldb tests to start failing on windows.
      
      Reviewers: rnk, aganea
      
      Subscribers: kristina, llvm-commits
      
      Tags: #llvm
      
      Differential Revision: https://reviews.llvm.org/D66344
      
      llvm-svn: 369269
      08c77b97
    • Roman Lebedev's avatar
      [TargetLowering] x s% C == 0 fold: vector divisor with INT_MIN handling · edfaee08
      Roman Lebedev authored
      Summary:
      The general fold is only valid for positive divisors.
      Which effectively means, it is invalid for `INT_MIN` divisors,
      and we currently bailout if we see them.
      
      But that is too strict, we can just fix-up the results.
      For that, let's do a second computation 'in parallel':
      ```
      Name: srem -> and
      Pre: isPowerOf2(C)
      %o = srem i8 %X, C
      %r = icmp eq %o, 0
        =>
      %n = and i8 %X, C-1
      %r = icmp eq %n, 0
      ```
      https://rise4fun.com/Alive/Sup
      
      And then just blend results: if the divisor was `INT_MIN`,
      pick the value we got via bit-test,
      else pick the value from general fold.
      
      There's interesting observation - `ISD::ROTR` is set to
      `LegalizeAction::Expand` before AVX512, so we should not
      treat `INT_MIN` divisor as even; and as it can be seen
      while `@test_srem_odd_even_one` improves on all run-lines,
      `@test_srem_odd_even_INT_MIN` only improves for AVX512.
      
      Reviewers: RKSimon, craig.topper, spatel
      
      Reviewed By: RKSimon
      
      Subscribers: hiraditya, llvm-commits
      
      Tags: #llvm
      
      Differential Revision: https://reviews.llvm.org/D66300
      
      llvm-svn: 369268
      edfaee08
    • Raphael Isemann's avatar
      [lldb][NFC] Stop using GetNumberOfMatches in CompletionRequest test · 6632ad58
      Raphael Isemann authored
      This function is just a wrapper for GetNumberOfResults and will
      be removed soon. This patch just changes all calls to GetNumberOfResults
      where possible (which is currently just the unit test).
      
      llvm-svn: 369267
      6632ad58
    • Serge Guelton's avatar
      [nfc] Silent gcc warning · a023d6b7
      Serge Guelton authored
      llvm-svn: 369266
      a023d6b7
    • George Rimar's avatar
      [llvm-objdump] - Restore lost comment. · 42336682
      George Rimar authored
      It was removed by mistake in r369263 (D66417).
      
      llvm-svn: 369265
      42336682
    • Amaury Sechet's avatar
      Automatically generate AVX512 test cases. NFC · 81301541
      Amaury Sechet authored
      llvm-svn: 369264
      81301541
    • George Rimar's avatar
      [Object/COFF.h] - Stop returning std::error_code in a few methods. NFCI. · 9d5e8a47
      George Rimar authored
      There are 4 methods that return std::error_code now,
      though they do not have to because they are always succeed.
      I refactored them.
      
      This allows to simplify the code in tools a bit.
      
      llvm-svn: 369263
      9d5e8a47
    • Fangrui Song's avatar
      [ELF] Move (copy relocation/canonical PLT) before error checking · ac0e6c65
      Fangrui Song authored
      In processRelocAux(), we handle errors before copy relocation/canonical PLT.
      This makes error checking a bit complex because we have to check for
      conditions that will be allowed by copy relocation/canonical PLT.
      
      Instead, move copy relocation/canonical PLT before error checking. This
      simplifies the previous clumsy error checking code
      
      `config->shared || (config->pie && expr == R_ABS && type != target->symbolicRel)`
      
      to the simple `config->isPic`. Some diagnostics can be reported in
      different ways. The code motion changes diagnostics for some contrived
      test cases:
      
      * copy-rel-pie-error.s -> copy-rel-pie2.s:
        It was rejected before but accepted now. ld.bfd also accepts the case.
      * copy-errors.s: "cannot preempt symbol" changes to "symbol 'bar' has no type"
      * got32{,x}-i386.s: the suggestion changes from "-fPIC or -Wl,-z,notext" to "-fPIE"
      * x86-64-dyn-rel-error5.s: one diagnostic changes for -pie case
      
      Reviewed By: peter.smith
      
      Differential Revision: https://reviews.llvm.org/D66007
      
      llvm-svn: 369262
      ac0e6c65
    • Jinsong Ji's avatar
      [PeepholeOptimizer] Don't assume bitcast def always has input · 0776da52
      Jinsong Ji authored
      Summary:
      If we have a MI marked with bitcast bits, but without input operands,
      PeepholeOptimizer might crash with assert.
      
      eg:
      If we apply the changes in PPCInstrVSX.td as in this patch:
      
      [(set v4i32:$XT, (bitconvert (v16i8 immAllOnesV)))]>;
      
      We will get assert in PeepholeOptimizer.
      
      ```
      llvm-lit llvm-project/llvm/test/CodeGen/PowerPC/build-vector-tests.ll -v
      
      llvm-project/llvm/include/llvm/CodeGen/MachineInstr.h:417: const
      llvm::MachineOperand &llvm::MachineInstr::getOperand(unsigned int)
      const: Assertion `i < getNumOperands() && "getOperand() out of range!"'
      failed.
      ```
      
      The fix is to abort if we found out of bound access.
      
      Reviewers: qcolombet, MatzeB, hfinkel, arsenm
      
      Reviewed By: qcolombet
      
      Subscribers: wdng, arsenm, steven.zhang, wuzish, nemanjai, hiraditya, kbarton, MaskRay, llvm-commits
      
      Tags: #llvm
      
      Differential Revision: https://reviews.llvm.org/D65542
      
      llvm-svn: 369261
      0776da52
    • Fangrui Song's avatar
      [ELF][Hexagon] Improve error message for unknown relocations · c8a1dfc4
      Fangrui Song authored
      Like rLLD354040
      
      Previously, for unknown relocation types, in -no-pie/-pie mode, we got something like:
      
          foo.o: unrecognized relocation ...
      
      In -shared mode:
      
          error: can't create dynamic relocation ... against symbol: yyy in readonly segment
      
      Delete the default case from Hexagon::getRelExpr and add the error there. We will get consistent error message like `error: unknown relocation (1024) against symbol foo`
      
      Reviewed By: sidneym
      
      Differential Revision: https://reviews.llvm.org/D66275
      
      llvm-svn: 369260
      c8a1dfc4
    • Aaron Ballman's avatar
      Don't keep stale pointers to LoopInfos. · b6ab533b
      Aaron Ballman authored
      CGLoopInfo was keeping pointers to parent loop LoopInfos, but when the loop info vector grew, it reallocated the storage and invalidated all of the parent pointers, causing use-after-free. Manage the lifetimes of the LoopInfos separately so that the pointers aren't stale.
      
      Patch by Bevin Hansson.
      
      llvm-svn: 369259
      b6ab533b
    • Sid Manning's avatar
      [lld][Hexagon] Add GOTREL relocations. · a0a4c6b7
      Sid Manning authored
      Add GOTREL relocation support. (S + A - GOT)
      
      Differential Revision: https://reviews.llvm.org/D66260
      
      llvm-svn: 369258
      a0a4c6b7
    • Alex Bradbury's avatar
      [RISCV] Don't force absolute FK_Data_X fixups to relocs · 1c1f8f21
      Alex Bradbury authored
      The current behavior of shouldForceRelocation forces relocations for the
      majority of fixups when relaxation is enabled. This makes sense for
      fixups which incorporate symbols but is unnecessary for simple data
      fixups where the fixup target is already resolved to an absolute value.
      
      Differential Revision: https://reviews.llvm.org/D63404
      Patch by Edward Jones.
      
      llvm-svn: 369257
      1c1f8f21
    • David Stenberg's avatar
      [DebugInfo] Allow bundled calls in the MIR's call site info · 88df53e6
      David Stenberg authored
      Summary:
      Extend the MIR parser and writer so that the call site information can
      refer to calls that are bundled.
      
      Reviewers: aprantl, asowda, NikolaPrica, djtodoro, ivanbaev, vsk
      
      Reviewed By: aprantl
      
      Subscribers: arsenm, hiraditya, llvm-commits
      
      Tags: #debug-info, #llvm
      
      Differential Revision: https://reviews.llvm.org/D66145
      
      llvm-svn: 369256
      88df53e6
    • Sanjay Patel's avatar
      [SLP] add test that requires shuffle of scalars; NFC · 0f9b5f86
      Sanjay Patel authored
      llvm-svn: 369255
      0f9b5f86
    • Fangrui Song's avatar
      6520ba3e
    • Sven van Haastregt's avatar
      [OpenCL] Add generic type handling for builtin functions · b21a3654
      Sven van Haastregt authored
      Generic types are an abstraction of type sets.  It mimics the way
      functions are defined in the OpenCL specification.  For example,
      floatN can abstract all the vector sizes of the float type.
      
      This allows to
       * stick more closely to the specification, which uses generic types;
       * factorize definitions of functions with numerous prototypes in the
         tablegen file; and
       * reduce the memory impact of functions with many overloads.
      
      Patch by Pierre Gondois and Sven van Haastregt.
      
      Differential Revision: https://reviews.llvm.org/D65456
      
      llvm-svn: 369253
      b21a3654
    • Raphael Isemann's avatar
      [lldb][NFC] Use CompletionRequest in Variable::AutoComplete · 06841321
      Raphael Isemann authored
      llvm-svn: 369252
      06841321
    • Anastasia Stulova's avatar
      [OpenCL] Fix addr space deduction for pointers/references to arrays. · eb801abd
      Anastasia Stulova authored
      Rewrite the logic for detecting if we are deducing addr space of
      a pointee type to take into account special logic for arrays. For
      pointers/references to arrays we can have any number of parentheses
      expressions as well as nested pointers.
      
      Differential Revision: https://reviews.llvm.org/D66137
      
      llvm-svn: 369251
      eb801abd
    • Sanjay Patel's avatar
      [SLP] reduce duplicated code; NFC · b38bac36
      Sanjay Patel authored
      llvm-svn: 369250
      b38bac36
    • Raphael Isemann's avatar
      [lldb][NFC] Add a few more completion tests to increase test coverage · fb443746
      Raphael Isemann authored
      These tests are mostly trying to reach the different completion functions
      in CommandCompletions.cpp (::ArchitectureNames, ::DiskFiles, ::Modules).
      
      llvm-svn: 369249
      fb443746
    • Fangrui Song's avatar
      [MC] Simplify ELFObjectWriter::recordRelocation. NFC · d9a071c5
      Fangrui Song authored
      llvm-svn: 369248
      d9a071c5
    • Jeremy Morse's avatar
      [DebugInfo] Make postra sinking of DBG_VALUEs subregister-safe · 176bbd5c
      Jeremy Morse authored
      Currently the machine instruction sinker identifies DBG_VALUE insts that
      also need to sink by comparing register numbers. Unfortunately this isn't
      safe, because (after register allocation) a DBG_VALUE may read a register
      that aliases what's being sunk. To fix this, identify the DBG_VALUEs that
      need to sink by recording & examining their register units. Register units
      gives us the following guarantee:
      
        "Two registers overlap if and only if they have a common register unit"
        [MCRegisterInfo.h]
      
      Thus we can always identify aliasing DBG_VALUEs if the set of register
      units read by the DBG_VALUE, and the register units of the instruction
      being sunk, intersect. (MachineSink already uses classes like
      "LiveRegUnits" for determining sinking validity anyway).
      
      The test added checks for super and subregister DBG_VALUE reads of a sunk
      copy being sunk as well.
      
      Differential Revision: https://reviews.llvm.org/D58191
      
      llvm-svn: 369247
      176bbd5c
    • Peter Smith's avatar
      [ELF][ARM] Add a test that maxes out the thunk convergence limit · 2cafd872
      Peter Smith authored
      Add a test that takes the maximum amount of passes permitted to converge.
      This will make sure that any symbol defined in a linker script gets the
      correct value and that any other convergence limit involving symbol address
      doesn't restrict Thunk convergence.
      
      Differential Revision: https://reviews.llvm.org/D66346
      
      llvm-svn: 369246
      2cafd872
    • Sam Tebbs's avatar
      [ARM] Add support for MVE vaddv · f312c1ec
      Sam Tebbs authored
      This patch adds vecreduce_add and the relevant instruction selection for
      vaddv.
      
      Differential revision: https://reviews.llvm.org/D66085
      
      llvm-svn: 369245
      f312c1ec
    • David Green's avatar
      [ARM] MVE sext costs · 2bfc13fd
      David Green authored
      This adds some sext costs for MVE, taken from the length of assembly sequences
      that we currently generate.
      
      Differential Revision: https://reviews.llvm.org/D66010
      
      llvm-svn: 369244
      2bfc13fd
    • Jeremy Morse's avatar
      [DebugInfo] Test for variable range un-coalescing · b58ba8aa
      Jeremy Morse authored
      LiveDebugVariables can coalesce ranges of variable locations across
      multiple basic blocks. However when it recreates DBG_VALUE instructions,
      it has to recreate one DBG_VALUE per block, otherwise it doesn't
      represent the pre-regalloc layout and variable assignments can go missing.
      
      This feature works -- however while mucking around with LiveDebugVariables,
      I commented the relevant code it out and no tests failed. Thus, here's a
      test that checks LiveDebugVariables preserves DBG_VALUEs across block
      boundaries.
      
      Differential Revision: https://reviews.llvm.org/D66347
      
      llvm-svn: 369243
      b58ba8aa
    • Raphael Isemann's avatar
      [lldb][NFC] Remove StringList::AutoComplete · b8639f5c
      Raphael Isemann authored
      We don't need this very specific function in StringList that
      we only call once in LLDB.
      
      llvm-svn: 369242
      b8639f5c
    • David L. Jones's avatar
      Revert [Attributor] Fix: Make sure we set the changed flag · cedd0d9a
      David L. Jones authored
      This reverts r369159 (git commit cbaf1fde)
      
      r369160 caused a test to fail under UBSAN. See thread on llvm-commits.
      
      llvm-svn: 369241
      cedd0d9a
    • Raphael Isemann's avatar
      81094aad
    • Fangrui Song's avatar
      [MC] Delete unnecessary diagnostic: "No relocation available to represent this relative expression" · b127771f
      Fangrui Song authored
      Replace
      
      - error: No relocation available to represent this relative expression
      
      with
      
      + error: symbol 'undef' can not be undefined in a subtraction expression
      
      or
      
      + error: Cannot represent a difference across sections
      
      Keep !IsPcRel as an assertion after the two diagnostic checks are done.
      
      llvm-svn: 369239
      b127771f
    • Johan Vikstrom's avatar
      [clangd] Added special HighlightingKind for function parameters. · 17587b36
      Johan Vikstrom authored
      Summary: This means that function parameters are no longer highlighted as variable.other.cpp but instead as variable.parameter.cpp which is the more "correct" TextMate scope for them.
      
      Reviewers: hokein, ilya-biryukov
      
      Subscribers: MaskRay, jkorous, arphaman, kadircet, cfe-commits
      
      Tags: #clang
      
      Differential Revision: https://reviews.llvm.org/D66335
      
      llvm-svn: 369238
      17587b36
    • Raphael Isemann's avatar
      [lldb][NFC] Address review comments to StringList for-loop support · 21599876
      Raphael Isemann authored
      llvm-svn: 369237
      21599876
    • David L. Jones's avatar
      Revert [Attributor] Fix: Do not partially resolve returned calls. · b1752f67
      David L. Jones authored
      This reverts r369160 (git commit f72d9b1c)
      
      r369160 caused some tests to fail under UBSAN. See thread on llvm-commits.
      
      llvm-svn: 369236
      b1752f67
    • Jan Kratochvil's avatar
      [lldb] Remove unused inheritance in RegularExpression · 0697bcd1
      Jan Kratochvil authored
      D66174 left inherited llvm::Regex which is now a member variable there.
      
      Approved as a part of: https://reviews.llvm.org/D66392#1634575
      
      llvm-svn: 369235
      0697bcd1
    • Seiya Nuta's avatar
      Revert r369230 and r369231 · 1e335611
      Seiya Nuta authored
      Looks these commits break CI builds:
      
      - http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-gn/builds/4159
      
      This commit reverts r369230 and r369231 (git coommit: 4a198a7f and dee9546b).
      
      llvm-svn: 369234
      1e335611
    • Fangrui Song's avatar
      [MC] Don't emit .symver redirected symbols to the symbol table · 38426c11
      Fangrui Song authored
      GNU as keeps the original symbol in the symbol table for defined @ and
      @@, but suppresses it in other cases (@@@ or undefined). The original
      symbol is usually undesired:
      In a shared object, the original symbol can be localized with a version
      script, but it is hard to remove/localize in an archive:
      
      1) a post-processing step removes the undesired original symbol
      2) consumers (executable) of the archive are built with the
         version script
      
      Moreover, it can cause linker issues like binutils PR/18703 if the
      original symbol name and the base name of the versioned symbol is the
      same (both ld.bfd and gold have some code to work around defined @ and
      @@). In lld, if it sees f and f@v1:
      
        --version-script =(printf 'v1 {};') => f and f@v1
        --version-script =(printf 'v1 { f; };') => f@v1 and f@@v1
      
      It can be argued that @@@ added on 2000-11-13 corrected the @ and @@ mistake.
      
      This patch catches some more multiple version errors (defined @ and @@),
      and consistently suppress the original symbol. This addresses all the
      problems listed above.
      
      If the user wants other aliases to the versioned symbol, they can copy
      the original symbol to other symbol names with .set directive, e.g.
      
          .symver f, f@v1  # emit f@v1 but not f into .symtab
          .set f_impl, f   # emit f_impl into .symtab
      
      llvm-svn: 369233
      38426c11
    • Craig Topper's avatar
      [X86] Teach lower1BitShuffle to match right shifts with upper zero elements on... · ebb7ddc6
      Craig Topper authored
      [X86] Teach lower1BitShuffle to match right shifts with upper zero elements on types that don't natively support KSHIFT.
      
      We can support these by widening to a supported type,
      then shifting all the way to the left and then
      back to the right to ensure that we shift in zeroes.
      
      llvm-svn: 369232
      ebb7ddc6