1. May 06, 2021
    • Matt Arsenault's avatar
      GlobalISel: Update documentation · e723b511
      Matt Arsenault authored
      e723b511
    • Matt Arsenault's avatar
      AMDGPU/GlobalISel: Remove unnecessary override · 8fc4eb9e
      Matt Arsenault authored
      This is the same as the default implementation
      8fc4eb9e
    • Matt Arsenault's avatar
      X86/GlobalISel: Use generic version of splitToValueTypes · 23ae35e8
      Matt Arsenault authored
      The custom insert of an unmerge and the callback weirdness should be
      unnecessary. Since handleAssignments should now use
      getRegisterTypeForCalling conv as SelectionDAG builder would, this
      should now just be able to use the generic code. X86-32 relies on the
      generated CCAssignFns not seeing illegal types and sharing code with
      x86_64, so i64 values would incorrectly be assigned to 64-bit
      registers.
      23ae35e8
    • Matt Arsenault's avatar
      GlobalISel: Use DAG call lowering infrastructure in a more compatible way · fa0b93b5
      Matt Arsenault authored
      Unfortunately the current call lowering code is built on top of the
      legacy MVT/DAG based code. However, GlobalISel was not using it the
      same way. In short, the DAG passes legalized types to the assignment
      function, and GlobalISel was passing the original raw type if it was
      simple.
      
      I do believe the DAG lowering is conceptually broken since it requires
      picking a type up front before knowing how/where the value will be
      passed. This ends up being a problem for AArch64, which wants to pass
      i1/i8/i16 values as a different size if passed on the stack or in
      registers.
      
      The argument type decision is split across 3 different places which is
      hard to follow. SelectionDAG builder uses
      getRegisterTypeForCallingConv to pick a legal type, tablegen gives the
      illusion of controlling the type, and the target may have additional
      hacks in the C++ part of the call lowering. AArch64 hacks around this
      by not using the standard AnalyzeFormalArguments and special casing
      i1/i8/i16 by looking at the underlying type of the original IR
      argument.
      
      I believe people have generally assumed the calling convention code is
      processing the original types, and I've discovered a number of dead
      paths in several targets.
      
      x86 actually relies on the opposite behavior from AArch64, and relies
      on x86_32 and x86_64 sharing calling convention code where the 64-bit
      cases implicitly do not work on x86_32 due to using the pre-legalized
      types.
      
      AMDGPU targets without legal i16/f16 have always used a broken ABI
      that promotes to i32/f32. GlobalISel accidentally fixed this to be the
      ABI we should have, but this fixes it so we're using the worse ABI
      that is compatible with the DAG. Ideally we would fix the DAG to match
      the old GlobalISel behavior, but I don't wish to fight that battle.
      
      A new native GlobalISel call lowering framework should let the target
      process the incoming types directly.
      
      CCValAssigns select a "ValVT" and "LocVT" but the meanings of these
      aren't entirely clear. Different targets don't use them consistently,
      even within their own call lowering code. My current belief is the
      intent was "ValVT" is supposed to be the legalized value type to use
      in the end, and and LocVT was supposed to be the ABI passed type
      (which is also legalized).
      
      With the default CCState::Analyze functions always passing the same
      type for these arguments, these only differ when the TableGen part of
      the lowering decide to promote the type from one legal type to
      another. AArch64's i1/i8/i16 hack ends up inverting the meanings of
      these values, so I had to add an additional hack to let the target
      interpret how large the argument memory is.
      
      Since targets don't consistently interpret ValVT and LocVT, this
      doesn't produce quite equivalent code to the initial DAG
      lowerings. I've opted to consistently interpret LocVT as the in-memory
      size for stack passed values, and ValVT as the register type to assign
      from that memory. We therefore produce extending loads directly out of
      the IRTranslator, whereas the DAG would emit regular loads of smaller
      values. This will also produce loads/stores that are wider than the
      argument value if the allocated stack slot is larger (and there will
      be undef padding bytes). If we had the optimizations to reduce
      load/stores based on truncated values, this wouldn't produce a
      different end result.
      
      Since ValVT/LocVT are more consistently interpreted, we now will emit
      more G_BITCASTS as requested by the CCAssignFn. For example AArch64
      was directly assigning types to some physical vector registers which
      according to the tablegen spec should have been casted to a vector
      with a different element type.
      
      This also moves the responsibility for inserting
      G_ASSERT_SEXT/G_ASSERT_ZEXT from the target ValueHandlers into the
      generic code, which is closer to how SelectionDAGBuilder works.
      
      I had to xfail an x86 test since I don't see a quick way to fix it
      right now (I filed bug 50035 for this). It's broken independently of
      this change, and only triggers since now we end up with more ands
      which hit the improperly handled selection pattern.
      
      I also observed that FP arguments that need promotion (e.g. f16 passed
      as f32) are broken, and use regular G_TRUNC and G_ANYEXT.
      
      TLDR; the current call lowering infrastructure is bad and nobody has
      ever understood how it chooses types.
      fa0b93b5
    • Emilio Cota's avatar
      [mlir] Add polynomial approximation for math::ExpM1 · 0edc4bc8
      Emilio Cota authored
      This approximation matches the one in Eigen.
      
      ```
      name                      old cpu/op  new cpu/op  delta
      BM_mlir_Expm1_f32/10      90.9ns ± 4%  52.2ns ± 4%  -42.60%    (p=0.000 n=74+87)
      BM_mlir_Expm1_f32/100      837ns ± 3%   231ns ± 4%  -72.43%    (p=0.000 n=79+69)
      BM_mlir_Expm1_f32/1k      8.43µs ± 3%  1.58µs ± 5%  -81.30%    (p=0.000 n=77+83)
      BM_mlir_Expm1_f32/10k     83.8µs ± 3%  15.4µs ± 5%  -81.65%    (p=0.000 n=83+69)
      BM_eigen_s_Expm1_f32/10   68.8ns ±17%  72.5ns ±14%   +5.40%  (p=0.000 n=118+115)
      BM_eigen_s_Expm1_f32/100   694ns ±11%   717ns ± 2%   +3.34%   (p=0.000 n=120+75)
      BM_eigen_s_Expm1_f32/1k   7.69µs ± 2%  7.97µs ±11%   +3.56%   (p=0.000 n=95+117)
      BM_eigen_s_Expm1_f32/10k  88.0µs ± 1%  89.3µs ± 6%   +1.45%   (p=0.000 n=74+106)
      BM_eigen_v_Expm1_f32/10   44.3ns ± 6%  45.0ns ± 8%   +1.45%   (p=0.018 n=81+111)
      BM_eigen_v_Expm1_f32/100   351ns ± 1%   360ns ± 9%   +2.58%    (p=0.000 n=73+99)
      BM_eigen_v_Expm1_f32/1k   3.31µs ± 1%  3.42µs ± 9%   +3.37%   (p=0.000 n=71+100)
      BM_eigen_v_Expm1_f32/10k  33.7µs ± 8%  34.1µs ± 9%   +1.04%    (p=0.007 n=99+98)
      ```
      
      Reviewed By: ezhulenev
      
      Differential Revision: https://reviews.llvm.org/D101852
      0edc4bc8
    • Michael Kitzan's avatar
      [MachineCSE][NFC]: Refactor and comment on preventing CSE for isConvergent instrs · a11489ae
      Michael Kitzan authored
      - Move the code preventing CSE of `isConvergent` instrs into
        `ProcessBlockCSE` (from `isProfitableToCSE`)
      - Add comments explaining why `isConvergent` is used to prevent
        CSE of non-local instrs in MachineCSE and the new test
      a11489ae
    • Giorgis Georgakoudis's avatar
      [Utils][NFC] Rename replace-function-regex in update_cc_test_checks · 78a7d8c4
      Giorgis Georgakoudis authored
      This patch renames the replace-function-regex to replace-value-regex to indicate that the existing regex replacement functionality can replace any IR value besides functions.
      
      Reviewed By: jdoerfert
      
      Differential Revision: https://reviews.llvm.org/D101934
      78a7d8c4
    • Krzysztof Parzyszek's avatar
      Preserve metadata on masked intrinsics in auto-upgrade · 1817dae1
      Krzysztof Parzyszek authored
      When auto-upgrade was replacing a call to a masked intrinsic, it would
      not copy the metadata from the original call.
      
      If an intrinsic had metadata, but did not need any updates, the metadata
      would stay, but if an update was needed, the would end up being removed.
      A similar effect could be observed with masked_expandload and
      masked_compressstore, which at the moment are not handled by auto-upgrade:
      the metadata remained untouched.
      
      Differential Revision: https://reviews.llvm.org/D101201
      1817dae1
    • Roman Lebedev's avatar
    • Thomas Lively's avatar
      [WebAssembly] Add SIMD const_splat intrinsics · 81fce29d
      Thomas Lively authored
      These intrinsics do not correspond to their own underlying instruction, but are
      a convenience for the common case of materializing a constant vector that has
      the same value in each lane.
      
      Differential Revision: https://reviews.llvm.org/D101885
      81fce29d
    • Isuru Fernando's avatar
      [lld] Convert LLVM_CMAKE_PATH to a CMake path · 662a58fa
      Isuru Fernando authored
      Otherwise I get the following error on windows.
      ```
      CMake Error at D:/bld/lld_1569206597988/work/build/CMakeFiles/CMakeTmp/CMakeLists.txt:2 (set):
        Syntax error in cmake code at
      
          D:/bld/lld_1569206597988/work/build/CMakeFiles/CMakeTmp/CMakeLists.txt:2
      
        when parsing string
      
          D:\bld\lld_1569206597988\_h_env\Library\lib\cmake\llvm
      
        Invalid character escape '\b'.
      
      CMake Error at D:/bld/lld_1569206597988/_build_env/Library/share/cmake-3.15/Modules/CheckSymbolExists.cmake:100 (try_compile):
        Failed to configure test project build system.
      Call Stack (most recent call first):
        D:/bld/lld_1569206597988/_build_env/Library/share/cmake-3.15/Modules/CheckSymbolExists.cmake:57 (__CHECK_SYMBOL_EXISTS_IMPL)
        D:/bld/lld_1569206597988/_h_env/Library/lib/cmake/llvm/HandleLLVMOptions.cmake:943 (check_symbol_exists)
        CMakeLists.txt:56 (include)
      ```
      
      Reviewed By: sbc100
      
      Differential Revision: https://reviews.llvm.org/D68158
      662a58fa
    • Rob Suderman's avatar
      [mlir][tosa] Add tosa.depthwise lowering to existing linalg.depthwise_conv · 7abb56c7
      Rob Suderman authored
      Implements support for undialated depthwise convolution using the existing
      depthwise convolution operation. Once convolutions migrate to yaml defined
      versions we can rewrite for cleaner implementation.
      
      Reviewed By: mravishankar
      
      Differential Revision: https://reviews.llvm.org/D101579
      7abb56c7
    • Vitaly Buka's avatar
      [scudo] Align objects with alignas · 1d767b13
      Vitaly Buka authored
      Operator new must align allocations for types with large alignment.
      
      Before c++17 behavior was implementation defined and both clang and gc++
      before 11 ignored alignment. Miss-aligned objects mysteriously crashed
      tests on Ubuntu 14.
      
      Alternatives are compile with -std=c++17 or -faligned-new, but they were
      discarded as less portable.
      
      Reviewed By: hctim
      
      Differential Revision: https://reviews.llvm.org/D101874
      1d767b13
    • Arthur O'Dwyer's avatar
      [libc++] [LIBCXX-DEBUG-FIXME] Stop using invalid iterators to insert into sets/maps. · 9ea2db2c
      Arthur O'Dwyer authored
      This simply applies Howard's commit 4c80bfbd consistently
      across all the associative and unordered container tests.
      
      "unord.set/insert_hint_const_lvalue.pass.cpp" failed with `-D_LIBCPP_DEBUG=1`
      before this patch; it was the only one that incorrectly reused
      invalid iterator `e`. The others already used valid iterators
      (generally `c.end()`); I'm just making them all match the same pattern
      of usage: "e, then r, then c.end() for the rest."
      
      Differential Revision: https://reviews.llvm.org/D101679
      9ea2db2c
    • Arthur O'Dwyer's avatar
      [libc++] [LIBCXX-DEBUG-FIXME] std::advance shouldn't use ADL `>=` on the _Distance type. · 9571b8f2
      Arthur O'Dwyer authored
      Convert to a primitive type first; then use primitive `>=` on that value.
      
      Differential Revision: https://reviews.llvm.org/D101678
      9571b8f2
    • Arthur O'Dwyer's avatar
      [libc++] [LIBCXX-DEBUG-FIXME] Our `__debug_less` breaks some complexity guarantees. · 165ad899
      Arthur O'Dwyer authored
      `__debug_less` ends up running the comparator up-to-twice per comparison,
      because whenever `(x < y)` it goes on to verify that `!(y < x)`.
      This breaks the strict "Complexity" guarantees of algorithms like
      `inplace_merge`, which we test in the test suite. So, just skip the
      complexity assertions in debug mode.
      
      Differential Revision: https://reviews.llvm.org/D101677
      165ad899
    • Arthur O'Dwyer's avatar
      [libc++] [LIBCXX-DEBUG-FIXME] Iterating a string::iterator "off the end" is UB. · 12dd9cdf
      Arthur O'Dwyer authored
      The range of char pointers [data, data+size] is a valid closed range,
      but the range [begin, end) is valid only half-open.
      
      Differential Revision: https://reviews.llvm.org/D101676
      12dd9cdf
    • Arthur O'Dwyer's avatar
      [libc++] [LIBCXX-DEBUG-FIXME] Fix an iterator-invalidation issue in string::assign. · db9425cb
      Arthur O'Dwyer authored
      This appears to be a bug in our string::assign: when assigning into
      a longer string, from a shorter snippet of itself, we invalidate
      iterators before doing the copy. We should invalidate them afterward.
      Also drive-by improve the formatting of a function header.
      
      Differential Revision: https://reviews.llvm.org/D101675
      db9425cb
    • Arthur O'Dwyer's avatar
      [libc++] Move <__sso_allocator> out of include/ into src/. NFCI. · 0b10bb7d
      Arthur O'Dwyer authored
      This allocator is not intended for libc++'s users to use;
      it's strictly an implementation detail of `src/locale.cpp`.
      So, move it to the `src/include/` directory.
      
      Drive-by const-qualify its comparison operators.
      
      For consistency with `__hidden_allocator` (defined in `src/thread.cpp`),
      do *not* remove it from "libcxx/lib/libc++unexp.exp",
      "libcxx/utils/symcheck-blacklists/linux_blacklist.txt", etc.
      
      Differential Revision: https://reviews.llvm.org/D101293
      0b10bb7d
    • Thomas Lively's avatar
      [WebAssembly] Fix constness of pointer params to load intrinsics · 602f318c
      Thomas Lively authored
      Update the SIMD builtin load functions to take pointers to const data and update
      the intrinsics themselves to not cast away constness.
      
      Differential Revision: https://reviews.llvm.org/D101884
      602f318c
    • Thomas Lively's avatar
      [WebAssembly] Update narrowing builtin function operand types · 627a5269
      Thomas Lively authored
      Make the inputs to all narrowing builtins signed, which is how they are
      interpreted by the underlying instructions (only the result changes sign
      between instructions).
      
      Differential Revision: https://reviews.llvm.org/D101883
      627a5269
    • Tomasz Miąsko's avatar
      Add fuzzer for Rust demangler · 0e7c2aea
      Tomasz Miąsko authored
      Reviewed By: dblaikie
      
      Differential Revision: https://reviews.llvm.org/D101823
      0e7c2aea
    • Jez Ng's avatar
      [lld-macho] Try to unbreak build · 75ba3513
      Jez Ng authored
      Looks like the PointerUnion casting cares about const-ness...
      75ba3513
    • Martin Storsjö's avatar
      [libcxx] [ci] Add a Windows CI configuration for a statically linked libc++ · 9b24ff9c
      Martin Storsjö authored
      On Windows, static vs DLL linking affects details in quite a few
      cases, so it's good to have coverage for both cases.
      
      Testing with static linking also increases coverage for a number of
      cases and individual checks that have had to be waived for the DLL
      case, and allows testing libc++experimental, increasing the number
      of test cases actually executed by 180 (176 new tests from
      libc++experimental and 4 ones that are XFAIL windows-dll).
      
      Also drop the "generic-" prefix from these configuration names, as
      they're perhaps not what the "generic" prefix intended originally
      in the other generic-posix configurations.
      
      Differential Revision: https://reviews.llvm.org/D101565
      9b24ff9c
    • Louis Dionne's avatar
    • Thomas Lively's avatar
      [WebAssembly] Set alignment to 1 for SIMD memory intrinsics · 89333b35
      Thomas Lively authored
      The WebAssembly SIMD intrinsics in wasm_simd128.h generally try not to require
      any particular alignment for memory operations to be maximally flexible. For
      builtin memory access functions and their corresponding LLVM IR intrinsics,
      there's no way to set the expected alignment, so the best we can do is set the
      alignment to 1 in the backend. This change means that the alignment hints in the
      emitted code will no longer be incorrect when users use the intrinsics to access
      unaligned data.
      
      Differential Revision: https://reviews.llvm.org/D101850
      89333b35
    • Jon Chesterfield's avatar
      [libomptarget] Initial documentation on amdgpu offload · 25fe17d3
      Jon Chesterfield authored
      [libomptarget] Initial documentation on amdgpu offload
      
      Reviewed By: jdoerfert
      
      Differential Revision: https://reviews.llvm.org/D101927
      25fe17d3
    • Evgenii Stepanov's avatar
      [hwasan] Fix missing synchronization in AllocThread. · 18959a6a
      Evgenii Stepanov authored
      The problem was introduced in D100348.
      
      It's really hard to trigger the bug in a stress test - the race is just too
      narrow - but the new checks in Thread::Init should at least provide usable
      diagnostic if the problem ever returns.
      
      Differential Revision: https://reviews.llvm.org/D101881
      18959a6a
    • Jez Ng's avatar
      [lld-macho] Preliminary support for ARM_RELOC_BR24 · 8806df47
      Jez Ng authored
      ARM_RELOC_BR24 is used for BL/BLX instructions from within ARM (i.e. not
      Thumb) code. This diff just handles the basic case: branches from ARM to
      ARM, or from ARM to Thumb where no shimming is required. (See comments
      in ARM.cpp for why shims are required.)
      
      Note: I will likely be deprioritizing ARM work for the near future to
      focus on other parts of LLD. Apologies for the half-done state of this;
      I'm just trying to wrap up what I've already worked on.
      
      Reviewed By: #lld-macho, alexshap
      
      Differential Revision: https://reviews.llvm.org/D101814
      8806df47
    • Jez Ng's avatar
      [lld-macho] Have --reproduce account for path rerooting · 20f51ffe
      Jez Ng authored
      We need to account for path rerooting when generating the response
      file. We could either reroot the paths before generating the file, or pass
      through the original filenames and change just the syslibroot. I've opted for
      the latter, in order that the reproduction run more closely mirrors the
      original.
      
      We must also be careful *not* to make an absolute path relative if it is
      shadowed by a rerooted path. See repro6.tar in reroot-path.s for
      details.
      
      I've moved the call to `createResponseFile()` after the initialization of
      `config->systemLibraryRoots`, since it now needs to know what those roots are.
      
      Reviewed By: #lld-macho, oontvoo
      
      Differential Revision: https://reviews.llvm.org/D101224
      20f51ffe
    • Harald van Dijk's avatar
      Make clangd CompletionModel not depend on directory layout. · 7907c46f
      Harald van Dijk authored
      The current code accounts for two possible layouts, but there is at
      least a third supported layout: clang-tools-extra may also be checked
      out as clang/tools/extra with the releases, which was not yet handled.
      Rather than treating that as a special case, use the location of
      CompletionModel.cmake to handle all three cases. This should address the
      problems that prompted D96787 and the problems that prompted the
      proposed revert D100625.
      
      Reviewed By: usaxena95
      
      Differential Revision: https://reviews.llvm.org/D101851
      7907c46f
    • Nick Desaulniers's avatar
      [Clang] remove text extension from diag::err_drv_invalid_value_with_suggestion · aefbfbcb
      Nick Desaulniers authored
      This hinders translations, as per:
      https://clang.llvm.org/docs/InternalsManual.html#the-format-string
      
      Reviewed By: MaskRay, xbolva00
      
      Differential Revision: https://reviews.llvm.org/D101387
      aefbfbcb
    • Roman Lebedev's avatar
    • Fangrui Song's avatar
      [llvm-objcopy][ELF] --only-keep-debug: set offset/size of segments with no sections to zero · b3336bfa
      Fangrui Song authored
      PR50160: we currently ignore non-PT_PHDR segments with no sections, not
      accounting for its p_offset and p_filesz: this can cause an out-of-bounds write
      in `writeSegmentData` if the p_offset+p_filesz is larger than the total file
      size.
      
      This can be fixed by setting p_offset=p_filesz=0. The logic nicely unifies with
      the logic added in D90897.
      
      Reviewed By: jhenderson, rupprecht
      
      Differential Revision: https://reviews.llvm.org/D101560
      b3336bfa
    • Saleem Abdulrasool's avatar
      RISSCV: clang-format RISC-V AsmParser (NFC) · ba5c1226
      Saleem Abdulrasool authored
      This corrects a few issues identified by `clang-format`.  This is meant
      to be preparation for a subsequent change.
      ba5c1226
    • Roman Lebedev's avatar
      833b33a7
    • Philipp Krones's avatar
      [MC] Untangle MCContext and MCObjectFileInfo · 632ebc4a
      Philipp Krones authored
      This untangles the MCContext and the MCObjectFileInfo. There is a circular
      dependency between MCContext and MCObjectFileInfo. Currently this dependency
      also exists during construction: You can't contruct a MOFI without a MCContext
      without constructing the MCContext with a dummy version of that MOFI first.
      This removes this dependency during construction. In a perfect world,
      MCObjectFileInfo wouldn't depend on MCContext at all, but only be stored in the
      MCContext, like other MC information. This is future work.
      
      This also shifts/adds more information to the MCContext making it more
      available to the different targets. Namely:
      
      - TargetTriple
      - ObjectFileType
      - SubtargetInfo
      
      Reviewed By: MaskRay
      
      Differential Revision: https://reviews.llvm.org/D101462
      632ebc4a
    • Philip Reames's avatar
      [LV] Workaround PR49900 (a crash due to analyzing partially mutated IR) · 80e80250
      Philip Reames authored
      LoopVectorize has a fairly deeply baked in design problem where it will try to query analysis (primarily SCEV, but also ValueTracking) in the midst of mutating IR. In particular, the intermediate IR state does not represent the semantics of the original (or final) program.
      
      Fixing this for real is hard, but all of the cases seen so far share a common symptom. In cases seen to date, the analysis being queried is the computation of the original loop's trip count. We can fix this particular instance of the issue by simply computing the trip count early, and caching it.
      
      I want to be really clear that this is nothing but a workaround. It does nothing to fix the root issue, and at best, delays the time until we have to fix this for real. Florian and I have discussed an eventual solution in the review comments for https://reviews.llvm.org/D100663, but it's a lot of work.
      
      Test taken from https://reviews.llvm.org/D100663.
      
      Differential Revision: https://reviews.llvm.org/D101487
      80e80250
    • Javier Setoain's avatar
      [mlir][ArmSVE] Add masked arithmetic operations · 95861216
      Javier Setoain authored
      These instructions map to SVE-specific instrinsics that accept a
      predicate operand to support control flow in vector code.
      
      Differential Revision: https://reviews.llvm.org/D100982
      95861216
    • Nico Weber's avatar
      [clang] remove an incremental build workaround · f16afcd9
      Nico Weber authored
      This cleaned up an oversight over a year ago. Should no longer be needed.
      f16afcd9