1. Mar 12, 2021
    • Ruiling Song's avatar
      [AMDGPU] Don't check hasStackObjects() when reserving VGPR · e8e6817d
      Ruiling Song authored
      We have amdgpu_gfx functions that have high register pressure. If
      we do not reserve VGPR for SGPR spill, we will fall into the path
      to spill the SGPR to memory, which does not only have correctness issue,
      but also have really bad performance.
      
      I don't know why there is the check for hasStackObjects(), in our case,
      we don't have stack objects at the time of finalizeLowering(). So just
      remove the check that we always reserve a VGPR for possible SGPR spill
      in non-entry functions.
      
      Reviewed by: arsenm
      
      Differential Revision: https://reviews.llvm.org/D98345
      e8e6817d
    • Ruiling Song's avatar
      [AMDGPU] Free reserved VGPR if no SGPR spill · 4cee5cad
      Ruiling Song authored
      I met some code generation behavior change when I tried to remove
      the hasStackObject() check when reserving VGPR for SGPR spill.
      For example, the function `callee_no_stack_no_fp_elim_all` in the lit
      test file `callee-frame-setup.ll`.
      The generated code changed from:
      ```
        s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
        s_mov_b32 s4, s33
        s_mov_b32 s33, s32
        s_mov_b32 s33, s4
        s_setpc_b64 s[30:31]
      ```
      
      into something like:
      ```
        s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
        v_writelane_b32 v63, s33, 0
        s_mov_b32 s33, s32
        v_readlane_b32 s33, v63, 0
        s_setpc_b64 s[30:31]
      ```
      
      I think we still prefer the old version where only scalar instructions are needed.
      The idea here is free the reserved VGPR if no SGPR spills. So we will very likely
      to use a free SGPR for fp/sp spill.
      
      Reviewed by: arsenm
      
      Differential Revision: https://reviews.llvm.org/D98344
      4cee5cad
    • Aaron Green's avatar
      [crt][fuzzer] Fix up various numeric conversions · 6708186c
      Aaron Green authored
      Attempting to build a standalone libFuzzer in Fuchsia's default toolchain for the purpose of cross-compiling the unit tests  revealed a number of not-quite-proper type conversions. Fuchsia's toolchain include `-std=c++17` and `-Werror`, among others, leading to many errors like `-Wshorten-64-to-32`, `-Wimplicit-float-conversion`, etc.
      
      Most of these have been addressed by simply making the conversion explicit with a `static_cast`. These typically fell into one of two categories: 1) conversions between types where high precision isn't critical, e.g. the "energy" calculations for `InputInfo`, and 2) conversions where the values will never reach the bits being truncated, e.g. `DftTimeInSeconds` is not going to exceed 136 years.
      
      The major exception to this is the number of features: there are several places that treat features as `size_t`, and others as `uint32_t`. This change makes the decision to cap the features at 32 bits. The maximum value of a feature as produced by `TracePC::CollectFeatures` is roughly:
        (NumPCsInPCTables + ValueBitMap::kMapSizeInBits + ExtraCountersBegin() - ExtraCountersEnd() + log2(SIZE_MAX)) * 8
      
      It's conceivable for extremely large targets and/or extra counters that this limit could be reached. This shouldn't break fuzzing, but it will cause certain features to collide and lower the fuzzers overall precision. To address this, this change adds a warning to TracePC::PrintModuleInfo about excessive feature size if it is detected, and recommends refactoring the fuzzer into several smaller ones.
      
      Reviewed By: morehouse
      
      Differential Revision: https://reviews.llvm.org/D97992
      6708186c
    • Craig Topper's avatar
      [RISCV] Add test cases for fixed vector bitreverse, bswap, ctlz, cttz, and ctpop. · 2ac7a3cf
      Craig Topper authored
      Codegen needs to be improved, but I wanted to check for crashes.
      2ac7a3cf
    • David Blaikie's avatar
    • Diego Caballero's avatar
      Reland: [mlir][Affine][Vector] Add initial support for 'iter_args' to Affine vectorizer. · 0fd0fb53
      Diego Caballero authored
      This patch adds support for vectorizing loops with 'iter_args' when those loops
      are not a vector dimension. This allows vectorizing outer loops with an inner
      'iter_args' loop (e.g., reductions). Vectorizing scenarios where 'iter_args'
      loops are vector dimensions would require more work (e.g., analysis,
      generating horizontal reduction, etc.) not included in this patch.
      
      Reviewed By: nicolasvasilache
      
      Differential Revision: https://reviews.llvm.org/D97892
      0fd0fb53
    • Reid Kleckner's avatar
      [PDB] Improve warning for corrupt debug info · b552adf8
      Reid Kleckner authored
      The S_[GL]PROC32_ID symbol records are supposed to point to function ID
      records. If they don't, they are corrupt. The warning message here was
      very technical, but a user has encountered it in the wild. Add some more
      information and some more testing.
      b552adf8
    • Florian Hahn's avatar
      [Matrix] Add support for matrix-by-scalar division. · c92ec0dd
      Florian Hahn authored
      This patch extends the matrix spec to allow matrix-by-scalar division.
      
      Originally support for `/` was left out to avoid ambiguity for the
      matrix-matrix version of `/`, which could either be elementwise or
      specified as matrix multiplication M1 * (1/M2).
      
      For the matrix-scalar version, no ambiguity exists; `*` is also
      an elementwise operation in that case. Matrix-by-scalar division
      is commonly supported by systems including Matlab, Mathematica
      or NumPy.
      
      Reviewed By: rjmccall
      
      Differential Revision: https://reviews.llvm.org/D97857
      c92ec0dd
    • Diego Caballero's avatar
      Reland: [mlir][Vector][Affine] Improve affine vectorizer algorithm · 96891f04
      Diego Caballero authored
      This patch replaces the root-terminal vectorization approach implemented in the
      Affine vectorizer with a topological order approach that vectorizes all the
      operations within the target loop nest. These are the most important changes
      introduced by the new algorithm:
        * Removed tracking of root and terminal ops. Existing vectorization
          functionality is preserved and extended so that loop nests without
          root-terminal chains can be vectorized.
        * Vectorizing a loop nest now only requires a single topological traversal.
        * A new vector loop nest is incrementally built along the vectorization
          process. The original scalar loop is kept intact. No cloning guard is needed
          to recover the scalar loop if vectorization fails. This approach also
          simplifies the challenging task of replacing a loop operation amid the
          vectorization process without invalidating the analysis information that
          depends on the original loop.
        * Vectorization of specific operations has been implemented as independent,
          preparing them to be moved to a potential vectorization interface.
      
      Reviewed By: nicolasvasilache
      
      Differential Revision: https://reviews.llvm.org/D97442
      96891f04
    • Stanislav Mekhanoshin's avatar
      [AMDGPU] Remove dead MTBUF patterns · 6e8a0213
      Stanislav Mekhanoshin authored
      These patterns are obviously dead, they are using format
      operand which is not selected and we have no corresponding
      SelectMUBUF() function.
      
      Differential Revision: https://reviews.llvm.org/D98451
      6e8a0213
    • Jianzhou Zhao's avatar
      37520a0b
    • Martin Storsjö's avatar
      [compiler-rt] Partially revert 8bd2722f · 7b153b43
      Martin Storsjö authored
      Don't normalize arm architecture names; doing that loses the ability
      to pick the right implementation of builtins for each architecture
      variant. When building compiler-rt builtins as part of a
      runtimes build, builtins for multiple armv* variants could be built
      in the same directory, and with the simplified architecture name,
      they'd all be built in the same directory, overlapping each other.
      7b153b43
    • Nikita Popov's avatar
      [Attributor] Don't access pointer elem type in constructPointer (NFC) · 2fe85dd2
      Nikita Popov authored
      Splitting this out as the change is non-trivial: The way this code
      handled pointer types doesn't really make sense, as GEPs can only
      apply an offset to the outermost pointer, but can't drill down
      into interior pointer types (which would require dereferencing
      memory).
      
      Instead give special treatment to the first (pointer) index.
      I've hardcoded it to zero as that's the only way the function is
      used right now, but handling non-zero indexes would be
      straightforward.
      
      The original goal here was to have an element type for CreateGEP.
      2fe85dd2
    • Petr Hosek's avatar
      [InstrProfiling] Generate runtime hook for ELF platforms · 87fd09b2
      Petr Hosek authored
      When using -fprofile-list to selectively apply instrumentation only
      to certain files or functions, we may end up with a binary that doesn't
      have any counters in the case where no files were selected. However,
      because on Linux and Fuchsia, we pass -u__llvm_profile_runtime, the
      runtime would still be pulled in and incur some non-trivial overhead,
      especially in the case when the continuous or runtime counter relocation
      mode is being used. A better way would be to pull in the profile runtime
      only when needed by declaring the __llvm_profile_runtime symbol in the
      translation unit only when needed.
      
      This approach was already used prior to 9a041a75, but we changed it
      to always generate the __llvm_profile_runtime due to a TAPI limitation.
      Since TAPI is only used on Mach-O platforms, we could use the early
      emission of __llvm_profile_runtime there, and on other platforms we
      could change back to the earlier approach where the symbol is generated
      later only when needed. We can stop passing -u__llvm_profile_runtime to
      the linker on Linux and Fuchsia since the generated undefined symbol in
      each translation unit that needed it serves the same purpose.
      
      Differential Revision: https://reviews.llvm.org/D98061
      87fd09b2
    • Weiwei Li's avatar
      Test commit · 63e676ff
      Weiwei Li authored
      63e676ff
    • Valery N Dmitriev's avatar
      [SLP] Fix crash when matching associative reduction for integer min/max. · 73f94969
      Valery N Dmitriev authored
      Associative reduction matcher in SLP begins with select instruction but when
      it reached call to llvm.umax (or alike) via def-use chain the latter also matched
      as UMax kind. The routine's later code assumes matched instruction to be a select
      and thus it merely died on the first encountered cast that did not fit.
      
      Differential Revision: https://reviews.llvm.org/D98432
      73f94969
    • Marek Kurdej's avatar
    • River Riddle's avatar
      [mlir][StorageUniquer] Properly call the destructor on non-trivially destructible storage instances · 31bb8efd
      River Riddle authored
      This allows for storage instances to store data that isn't uniqued in the context, or contain otherwise non-trivial logic, in the rare situations that they occur. Storage instances with trivial destructors will still have their destructor skipped. A consequence of this is that the storage instance definition must be visible from the place that registers the type.
      
      Differential Revision: https://reviews.llvm.org/D98311
      31bb8efd
    • Kadir Cetinkaya's avatar
      [clangd] Make ProjectAwareIndex optionally sync · dc9c0963
      Kadir Cetinkaya authored
      Depends on D98029.
      
      Differential Revision: https://reviews.llvm.org/D98165
      dc9c0963
    • Kadir Cetinkaya's avatar
      [clangd] Add config block for Completion and option for AllScopes · ac292daf
      Kadir Cetinkaya authored
      Depends on D98029
      
      Differential Revision: https://reviews.llvm.org/D98037
      ac292daf
    • Wei Mi's avatar
      [IndirectCallPromotion] Don't strip ".__uniq." suffix when it strips · 90dfbeef
      Wei Mi authored
      ".llvm." suffix.
      
      Currently IndirectCallPromotion simply strip everything after the first "."
      in LTO mode, in order to match the symbol name and the name with ".llvm."
      suffix in the value profile. However, if -funique-internal-linkage-names
      and thinlto are both enabled, the name may have both ".__uniq." suffix and
      ".llvm." suffix, and the current mechanism will strip them both, which is
      unexpected. The patch fixes the problem.
      
      Differential Revision: https://reviews.llvm.org/D98389
      90dfbeef
    • Martin Storsjö's avatar
      [libcxx] Test accessing a directory on windows that gives "access denied" errors · e69c65d5
      Martin Storsjö authored
      Fix handling of skip_permission_denied on windows; after converting
      the return value of GetLastError() to a standard error_code, ec.value()
      is in the standard errc range, not a native windows error code. This
      was missed in 15618072.
      
      The directory "C:\System Volume Information" does seem to exist and
      have these properties on most relevant contempory setups.
      
      Differential Revision: https://reviews.llvm.org/D98166
      e69c65d5
    • LemonBoy's avatar
      [SelectionDAG] Improve scalarization of irregular vector types · cfe69c8e
      LemonBoy authored
      Use a more general strategy when splitting a vector into scalar parts (and vice-versa) to correctly handle vector types whose element size is not a power of 2 (and a multiple of 8).
      
      Reviewed By: atanasyan
      
      Differential Revision: https://reviews.llvm.org/D98273
      cfe69c8e
    • LemonBoy's avatar
      [MIPS] Fix lowering of irregular vector arguments · cc999c95
      LemonBoy authored
      The code deciding how to split the vector in register-sized integers used the integer division operator, thus rounding down the result.
      Correct the computation for irregularly-sized types (non-power-of-two, non multiple of 8) by rounding the division result upwards.
      
      Reviewed By: atanasyan
      
      Differential Revision: https://reviews.llvm.org/D98189
      cc999c95
    • Raphael Isemann's avatar
      [lldb] Fix the man page build · 75f97cda
      Raphael Isemann authored
      In D94489 we changed the way we build the docs and now have some additional
      dependencies to generate the Python API docs. As the same sphinx project is
      generating the man pages for LLDB it should have in theory the same setup code
      that sets up the mocked LLDB module.
      
      However, as we don't have that setup code the man page generation just fails as
      there is no mocked LLDB module and the Python API generation errors out.
      
      The man page anyway doesn't cover the Python API so I don't think there is any
      point of going through the whole process (and requiring the sphinx plugins) just
      to generate the (eventually unused) Python docs.
      
      This patch just skips the relevant Python API generation when we are building
      the man page.
      
      Reviewed By: JDevlieghere
      
      Differential Revision: https://reviews.llvm.org/D98441
      75f97cda
    • Diego Caballero's avatar
      [mlir][Vector][Affine] Fix heap-use-after-free in vectorizer · ed193bce
      Diego Caballero authored
      This patch fixes a heap-use-after-free introduced by the recent changes
      in the vectorizer: https://reviews.llvm.org/rG95db7b4aeaad590f37720898e339a6d54313422f
      The problem is due to the way candidate loops are visited. All candidate loops
      are pattern-matched beforehand using the 'NestedMatch' utility. These matches may
      intersect with each other so it may happen that we try to vectorize a loop that
      was previously vectorized. The new vectorization algorithm replaces the original
      loops that are vectorized with new loops and, therefore, any reference to the
      original loops in the pre-computed matches becomes invalid.
      
      This patch fixes the problem by classifying the candidate matches into buckets
      before vectorization. Each bucket contains all the matches that intersect. The
      vectorizer uses these buckets to make sure that we only vectorize *one* match from
      each bucket, at most.
      
      Differential Revision: https://reviews.llvm.org/D98382
      ed193bce
    • LLVM GN Syncbot's avatar
      [gn build] Port 5433a791 · 0cb0c6be
      LLVM GN Syncbot authored
      0cb0c6be
    • Jez Ng's avatar
      29bbbd06
    • Jez Ng's avatar
      [lld-macho] Avoid requiring shell in tests · d1e57ee9
      Jez Ng authored
      There are 3 remaining tests that still have `REQUIRE: shell`:
      * color-diagnostics.test -- seems necessary for ANSI escape sequence support
      * stabs.s -- the shell part could be removed, but I don't think we can support
        the test on Windows anyway due to its reliance on `touch` to set the modtime
      * framework.s -- uses symlinks, I'm not sure this works on Windows
      
      Addresses PR49512.
      
      Reviewed By: #lld-macho, alexshap
      
      Differential Revision: https://reviews.llvm.org/D98395
      d1e57ee9
    • Jez Ng's avatar
      [lld-macho][nfc] Refactor subtractor reloc handling · a723db92
      Jez Ng authored
      SUBTRACTOR relocations are always paired with UNSIGNED
      relocations to indicate a pair of symbols whose address difference we
      want. Functionally they are like a single relocation: only one pointer
      gets written / relocated. Previously, we would handle these pairs by
      skipping over the SUBTRACTOR relocation and writing the pointer when
      handling the UNSIGNED reloc. This diff reverses things, so we write
      while handling SUBTRACTORs and skip over the UNSIGNED relocs instead.
      
      Being able to distinguish between SUBTRACTOR and UNSIGNED relocs in the
      write phase (i.e. inside `relocateOne`) is useful for the upcoming range
      check diff: we want to check that SUBTRACTOR relocs write signed values,
      but UNSIGNED relocs (naturally) write unsigned values.
      
      Reviewed By: #lld-macho, thakis
      
      Differential Revision: https://reviews.llvm.org/D98386
      a723db92
    • Jez Ng's avatar
      [lld-macho] Fix handling of X86_64_RELOC_SIGNED_{1,2,4} · e8a30583
      Jez Ng authored
      The previous implementation miscalculated the addend, resulting
      in an underflow. This meant that every SIGNED_N section relocation would
      be associated with the last subsection (since the addend would now be a
      huge number). We were "lucky" that this mistake was typically cancelled
      out -- 64-to-32-bit-truncation meant that the final value was correct,
      as long as subsections were not rearranged.
      
      Reviewed By: #lld-macho, thakis
      
      Differential Revision: https://reviews.llvm.org/D98385
      e8a30583
    • Jez Ng's avatar
      [lld-macho][nfc] Create Relocations.{h,cpp} for relocation-specific code · 5433a791
      Jez Ng authored
      This more closely mirrors the structure of lld-ELF.
      
      Reviewed By: #lld-macho, thakis
      
      Differential Revision: https://reviews.llvm.org/D98384
      5433a791
    • Jez Ng's avatar
      [lld-macho][nfc] Remove `MachO::` prefix where possible · 1752f285
      Jez Ng authored
      Previously, SyntheticSections.cpp did not have a top-level `using namespace
      llvm::MachO` because it caused a naming conflict: `llvm::MachO::Symbol` would
      collide with `lld::macho::Symbol`.
      
      `MachO::Symbol` represents the symbols defined in InterfaceFiles (TBDs). By
      moving the inclusion of InterfaceFile.h into our .cpp files, we can avoid this
      name collision in other files where we are only dealing with LLD's own symbols.
      
      Along the way, I removed all unnecessary "MachO::" prefixes in our code.
      
      Cons of this approach: If TextAPI/MachO/Symbol.h gets included via some other
      header file in the future, we could run into this collision again.
      
      Alternative 1: Have either TextAPI/MachO or BinaryFormat/MachO.h use a different
      namespace. Most of the benefit of `using namespace llvm::MachO` comes from being
      able to use things in BinaryFormat/MachO.h conveniently; if TextAPI was under a
      different (and fully-qualified) namespace like `llvm::tapi` that would solve our
      problems. Cons: lots of files across llvm-project will need to be updated, and
      folks who own the TextAPI code need to agree to the name change.
      
      Alternative 2: Rename our Symbol to something like `LldSymbol`. I think this is
      ugly.
      
      Personally I think alternative #1 is ideal, but I'm not sure the effort to do it is
      worthwhile, this diff's halfway solution seems good enough to me. Thoughts?
      
      Reviewed By: #lld-macho, oontvoo, MaskRay
      
      Differential Revision: https://reviews.llvm.org/D98149
      1752f285
    • Martin Storsjö's avatar
      [libcxx] [test] Disable a test regarding error behaviour for excessively long paths on windows · 8ba05e14
      Martin Storsjö authored
      Checking for the existence of an invalid long path name isn't
      an error in itself on windows.
      
      Differential Revision: https://reviews.llvm.org/D98141
      8ba05e14
    • Peter Steinfeld's avatar
      [flang] Handle type-bound procedures with alternate returns · 868187df
      Peter Steinfeld authored
      If you specify a type-bound procedure with an alternate return, there
      will be no symbol associated with that dummy argument.  In such cases,
      the compiler's list of dummy arguments will contain a nullptr.  In our
      analysis of the PASS arguments of type-bound procedures, we were
      assuming that all dummy arguments had non-null symbols associated with
      them and were using that assumption to get the name of the dummy
      argument.  This caused the compiler to try to dereference a nullptr.
      
      I fixed this by explicitly checking for a nullptr and, in such cases, emitting
      an error message.  I also added tests that contain type-bound procedures with
      alternate returns in both legal and illegal constructs to ensure that semantic
      analysis is working for them.
      
      Differential Revision: https://reviews.llvm.org/D98430
      868187df
    • Wenlei He's avatar
      [SamplePGO] Skip inlinee profile scaling for sample loader inlining · 051f2c14
      Wenlei He authored
      For CGSCC inline, we need to scale down a function's branch weights and entry counts when thee it's inlined at a callsite. This is done through updateCallProfile. Additionally, we also scale the weigths for the inlined clone based on call site count in updateCallerBFI. Neither is needed for inlining during sample profile loader as it's using context profile that is separated from inlinee's own profile. This change skip the inlinee profile scaling for sample loader inlining.
      
      Differential Revision: https://reviews.llvm.org/D98187
      051f2c14
    • Fangrui Song's avatar
      [Driver] Drop $sysroot/usr special case from Gentoo gcc-config detection · 8d8a9190
      Fangrui Song authored
      If --gcc-toolchain is specified, we should detect GCC installation there, and suppress other directories for detection.
      
      Reviewed By: mgorny, manojgupta
      
      Differential Revision: https://reviews.llvm.org/D97894
      8d8a9190
    • Nikita Popov's avatar
      [UnitTests] Remove uses of deprecated CreateLoad() API · 7046b2b2
      Nikita Popov authored
      Missed this usage inside OpenMPIRBuilderTest.
      7046b2b2
    • Craig Topper's avatar
      [RISCV] Support fixed vector copysign. · c82f4429
      Craig Topper authored
      Reviewed By: frasercrmck
      
      Differential Revision: https://reviews.llvm.org/D98394
      c82f4429
    • David Green's avatar
      [ARM] Move t2DoLoopStart reg alloc hint · bd516d24
      David Green authored
      This adjusts the place that the t2DoLoopStart reg allocation hint is
      inserted, adding it in the ARMTPAndVPTOptimizaionPass in a similar place
      as other tail predicated loop optimizations. This removes the need for
      doing so in a custom inserter, and should make the hint more accurate,
      only adding it where we expect to create a DLS (not DLSTP or WLS).
      bd516d24