1. Aug 04, 2021
  2. Aug 03, 2021
    • Cullen Rhodes's avatar
      [ReleaseNotes] Add scalable matrix extension support to AArch64 changes · eff062e5
      Cullen Rhodes authored
      Reviewed By: sdesmalen
      
      Differential Revision: https://reviews.llvm.org/D106853
      eff062e5
    • Muhammad Omair Javaid's avatar
      [llvm][Release notes] Add AArch64 SVE, PAC and LLDB prebuilt binary · 9413df38
      Muhammad Omair Javaid authored
      This patch updates LLVM release notes to add a announcement about
      AArch64 SVE, PAC and LLDB prebuilt binary.
      9413df38
    • David Spickett's avatar
    • David Spickett's avatar
      [lldb][AArch64] Mark mismatched tags in tag read output · 0b8dc914
      David Spickett authored
      The "memory tag read" command will now tell you
      when the allocation tag read does not match the logical
      tag.
      
      (lldb) memory tag read mte_buf+(8*16) mte_buf+(8*16)+48
      Logical tag: 0x9
      Allocation tags:
      [0xfffff7ff7080, 0xfffff7ff7090): 0x8 (mismatch)
      [0xfffff7ff7090, 0xfffff7ff70a0): 0x9
      [0xfffff7ff70a0, 0xfffff7ff70b0): 0xa (mismatch)
      
      The logical tag will be taken from the start address
      so the end could have a different tag. You could for example
      read from ptr_to_array_1 to ptr_to_array_2. Where the latter
      is tagged differently to prevent buffer overflow.
      
      The existing command will read 1 granule if you leave
      off the end address. So you can also use it as a quick way
      to check a single location.
      
      (lldb) memory tag read mte_buf
      Logical tag: 0x9
      Allocation tags:
      [0xfffff7ff7000, 0xfffff7ff7010): 0x0 (mismatch)
      
      This avoids the need for a seperate "memory tag check" command.
      
      Reviewed By: omjavaid
      
      Differential Revision: https://reviews.llvm.org/D106880
      
      (cherry picked from commit 98b5659b)
      0b8dc914
    • David Spickett's avatar
      [lldb] Correct format of qMemTags type field · c47d79b3
      David Spickett authored
      The type field is a signed integer.
      (https://sourceware.org/gdb/current/onlinedocs/gdb/General-Query-Packets.html)
      
      However it's not packed in the packet in the way
      you might think. For example the type -1 should be:
      qMemTags:<addr>,<len>:ffffffff
      Instead of:
      qMemTags:<addr>,<len>:-1
      
      This change makes lldb-server's parsing more strict
      and adds more tests to check that we handle negative types
      correctly in lldb and lldb-server.
      
      We only support one tag type value at this point,
      for AArch64 MTE, which is positive. So this doesn't change
      any of those interactions. It just brings us in line with GDB.
      
      Also check that the test target has MTE. Previously
      we just checked that we were AArch64 with a toolchain
      that supports MTE.
      
      Finally, update the tag type check for QMemTags to use
      the same conversion steps that qMemTags now does.
      Using static_cast can invoke UB and though we do do a limit
      check to avoid this, I think it's clearer with the new method.
      
      Reviewed By: omjavaid
      
      Differential Revision: https://reviews.llvm.org/D104914
      
      (cherry picked from commit 555cd031)
      c47d79b3
    • David Spickett's avatar
      [lldb][AArch64] Annotate synchronous tag faults · bc0cc109
      David Spickett authored
      In the latest Linux kernels synchronous tag faults
      include the tag bits in their address.
      This change adds logical and allocation tags to the
      description of synchronous tag faults.
      (asynchronous faults have no address)
      
      Process 1626 stopped
      * thread #1, name = 'a.out', stop reason = signal SIGSEGV: sync tag check fault (fault address: 0x900fffff7ff9010 logical tag: 0x9 allocation tag: 0x0)
      
      This extends the existing description and will
      show as much as it can on the rare occasion something
      fails.
      
      This change supports AArch64 MTE only but other
      architectures could be added by extending the
      switch at the start of AnnotateSyncTagCheckFault.
      The rest of the function is generic code.
      
      Tests have been added for synchronous and asynchronous
      MTE faults.
      
      Reviewed By: omjavaid
      
      Differential Revision: https://reviews.llvm.org/D105178
      
      (cherry picked from commit d510b5f1)
      bc0cc109
    • David Spickett's avatar
      [lldb] Add "memory tag write" --end-addr option · dc00e191
      David Spickett authored
      The default mode of "memory tag write" is to calculate the
      range from the start address and the number of tags given.
      (just like "memory write" does)
      
      (lldb) memory tag write mte_buf 1 2
      (lldb) memory tag read mte_buf mte_buf+48
      Logical tag: 0x0
      Allocation tags:
      [0xfffff7ff9000, 0xfffff7ff9010): 0x1
      [0xfffff7ff9010, 0xfffff7ff9020): 0x2
      [0xfffff7ff9020, 0xfffff7ff9030): 0x0
      
      This new option allows you to set an end address and have
      the tags repeat until that point.
      
      (lldb) memory tag write mte_buf 1 2 --end-addr mte_buf+64
      (lldb) memory tag read mte_buf mte_buf+80
      Logical tag: 0x0
      Allocation tags:
      [0xfffff7ff9000, 0xfffff7ff9010): 0x1
      [0xfffff7ff9010, 0xfffff7ff9020): 0x2
      [0xfffff7ff9020, 0xfffff7ff9030): 0x1
      [0xfffff7ff9030, 0xfffff7ff9040): 0x2
      [0xfffff7ff9040, 0xfffff7ff9050): 0x0
      
      This is implemented using the QMemTags packet previously
      added. We skip validating the number of tags in lldb and send
      them on to lldb-server, which repeats them as needed.
      
      Apart from the number of tags, all the other client side checks
      remain. Tag values, memory range must be tagged, etc.
      
      Reviewed By: omjavaid
      
      Differential Revision: https://reviews.llvm.org/D105183
      
      (cherry picked from commit 6eded00e)
      dc00e191
    • David Spickett's avatar
      [lldb] Add "memory tag write" command · 45d98857
      David Spickett authored
      This adds a new command for writing memory tags.
      It is based on the existing "memory write" command.
      
      Syntax: memory tag write <address-expression> <value> [<value> [...]]
      (where "value" is a tag value)
      
      (lldb) memory tag write mte_buf 1 2
      (lldb) memory tag read mte_buf mte_buf+32
      Logical tag: 0x0
      Allocation tags:
      [0xfffff7ff9000, 0xfffff7ff9010): 0x1
      [0xfffff7ff9010, 0xfffff7ff9020): 0x2
      
      The range you are writing to will be calculated by
      aligning the address down to a granule boundary then
      adding as many granules as there are tags.
      
      (a repeating mode with an end address will be in a follow
      up patch)
      
      This is why "memory tag write" uses MakeTaggedRange but has
      some extra steps to get this specific behaviour.
      
      The command does all the usual argument validation:
      * Address must evaluate
      * You must supply at least one tag value
        (though lldb-server would just treat that as a nop anyway)
      * Those tag values must be valid for your tagging scheme
        (e.g. for MTE the value must be > 0 and < 0xf)
      * The calculated range must be memory tagged
      
      That last error will show you the final range, not just
      the start address you gave the command.
      
      (lldb) memory tag write mte_buf_2+page_size-16 6
      (lldb) memory tag write mte_buf_2+page_size-16 6 7
      error: Address range 0xfffff7ffaff0:0xfffff7ffb010 is not in a memory tagged region
      
      (note that we do not check if the region is writeable
      since lldb can write to it anyway)
      
      The read and write tag tests have been merged into
      a single set of "tag access" tests as their test programs would
      have been almost identical.
      (also I have renamed some of the buffers to better
      show what each one is used for)
      
      Reviewed By: omjavaid
      
      Differential Revision: https://reviews.llvm.org/D105182
      
      (cherry picked from commit 6a7a2ee8)
      45d98857
    • Matheus Izvekov's avatar
      [clang] fix concepts crash on substitution failure during normalization · 4ae33534
      Matheus Izvekov authored
      
      
      When substitution failed on the first constrained template argument (but
      only the first), we would assert / crash. Checking for failure was only
      being performed from the second constraint on.
      
      This changes it so the checking is performed in that case,
      and the code is also now simplified a little bit to hopefully
      avoid this confusion.
      
      Signed-off-by: default avatarMatheus Izvekov <mizvekov@gmail.com>
      
      Reviewed By: rsmith
      
      Differential Revision: https://reviews.llvm.org/D106907
      4ae33534
    • Markus Böck's avatar
      [mlir] Change ABI breaking use of NDEBUG to LLVM_ENABLE_ABI_BREAKING_CHECKS · a7eab64b
      Markus Böck authored
      The `DataLayout` class currently contains the member `layoutStack` which is hidden behind a preprocessor region dependant on the NDEBUG macro. Code wise this makes a lot of sense, as the `layoutStack` is used for extra assertions that users will want when compiling a debug build.
      It however has the uncomfortable consequence of leading to a different ABI in Debug and Release builds. This I think is a bit annoying for downstream projects and others as they may want to build against a stable Release of MLIR in Release mode, but be able to debug their own project depending on MLIR.
      
      This patch changes the related uses of NDEBUG to LLVM_ENABLE_ABI_BREAKING_CHECKS. As the macro is computed at configure time of LLVM, it may not change based on compiler settings of a downstream projects like NDEBUG would.
      
      Differential Revision: https://reviews.llvm.org/D107227
      
      (cherry picked from commit 97335ad1)
      a7eab64b
    • Sanjay Patel's avatar
      [Analysis] improve function signature checking for snprintf · d6974c01
      Sanjay Patel authored
      The check for size_t parameter 1 was already here for snprintf_chk,
      but it wasn't applied to regular snprintf. This could lead to
      mismatching and eventually crashing as shown in:
      https://llvm.org/PR50885
      
      (cherry picked from commit 7f555577)
      d6974c01
    • Jose M Monsalve Diaz's avatar
      [OpenMP] Fixing llvm-omp-device-info compilation with runtimes · 60c388a4
      Jose M Monsalve Diaz authored
      When using `-DLLVM_ENABLED_RUNTIMES` instead of `-DLLVM_ENABLED_PROJECTS`
      the `llvm-omp-device-info` tool is not compiled or installed.
      In general, no llvm tool would be build on runtimes, because the
      -DLLVM_BUILD_TOOLS flag is removed by the way runtimes compilation calls
      cmake again.
      
      This patch is simple. Just forward the value of this flag to the
      runtime cmake command.
      
      I'm also removing an unnecessary comment in the compilation of the tool
      
      Differential Revision: https://reviews.llvm.org/D107177
      
      (cherry picked from commit 5424ceed)
      60c388a4
    • Simon Pilgrim's avatar
      [X86][AVX] Add test case for PR51281 · ec7ef426
      Simon Pilgrim authored
      (cherry picked from commit 6569b7f9)
      ec7ef426
    • Dmitry Vyukov's avatar
      Revert "sanitizers: increase .clang-format columns to 100" · 73249a83
      Dmitry Vyukov authored
      This reverts commit 5d1df6d2.
      
      There is a strong objection to this change:
      https://reviews.llvm.org/D106436#2905618
      
      Reviewed By: dblaikie
      
      Differential Revision: https://reviews.llvm.org/D106847
      
      (cherry picked from commit 440e936c)
      73249a83
    • Tom Stellard's avatar
      Revert "[Preprocessor] Implement -fminimize-whitespace." · 4a450da7
      Tom Stellard authored
      This reverts commit ae6b4000.
      
      llvm.org/PR51300
      4a450da7
    • Sanjay Patel's avatar
      [DAGCombiner] don't try to partially reduce add-with-overflow ops · 3bce6131
      Sanjay Patel authored
      This transform was added with D58874, but there were no tests for overflow ops.
      We need to change this one way or another because it can crash as shown in:
      https://llvm.org/PR51238
      
      Note that if there are no uses of an overflow op's bool overflow result, we
      reduce it to a regular math op, so we continue to fold that case either way.
      If we have uses of both the math and the overflow bool, then we are likely
      not saving anything by creating an independent sub instruction as seen in
      the test diffs here.
      
      This patch makes the behavior in SDAG consistent with what we do in
      instcombine AFAICT.
      
      Differential Revision: https://reviews.llvm.org/D106983
      
      (cherry picked from commit fa6b2c99)
      3bce6131
    • Sanjay Patel's avatar
      [AArch64][x86] add tests for add-with-overflow folds; NFC · e6ca0238
      Sanjay Patel authored
      There's a generic combine for these, but no test coverage.
      It's not clear if this is actually a good fold.
      The combine was added with D58874, but it has a bug that
      can cause crashing ( https://llvm.org/PR51238 ).
      
      (cherry picked from commit e427077e)
      e6ca0238
    • Sanjay Patel's avatar
      [DivRemPairs] make sure we have a valid CFG for hoisting division · 2f43c816
      Sanjay Patel authored
      This transform was added with e38b7e89
      and as shown in:
      https://llvm.org/PR51241
      ...it could crash without an extra check of the blocks.
      
      There might be a more compact way to write this constraint,
      but we can't just count the successors/predecessors without
      affecting a test that includes a switch instruction.
      
      (cherry picked from commit 5b83261c)
      2f43c816
    • Craig Topper's avatar
      [RISCV] Restrict performANY_EXTENDCombine to prevent an infinite loop. · 9ac5717f
      Craig Topper authored
      The sign_extend we insert here can get turned into a zero_extend if
      the sign bit is known zero. This can enable a setcc combine that
      shrinks compares with zero_extend. This reduces the use count of
      the zero_extend allowing other combines to turn it back into an
      any_extend.
      
      This restricts the combine to only cases where the result is used
      by a CopyToReg. This works for my original motivating case. I
      hope the CopyToReg use will prevent any converted extends from
      turning back into an any_extend.
      
      Reviewed By: luismarques
      
      Differential Revision: https://reviews.llvm.org/D106754
      
      (cherry picked from commit 54588bcc)
      9ac5717f
    • Tom Stellard's avatar
      Import workflows from release/12.x branch · ddd8ca69
      Tom Stellard authored
      (cherry picked from commit 7546a34044ae28b62bd43e6dc0952622e1b6e77f)
      ddd8ca69
    • Mateusz Mikuła's avatar
      [LLD][MinGW] Accept joined format for --stack · a6c39006
      Mateusz Mikuła authored
      Postgresql uses `--stack=` in its Makefile.
      
      Downstream issue: https://github.com/msys2/MINGW-packages/pull/9167
      
      Reviewed By: mstorsjo
      
      Differential Revision: https://reviews.llvm.org/D107237
      
      (cherry picked from commit 05b025ed)
      a6c39006
    • Martin Storsjö's avatar
      [clang-repl] Fix building with win32 dylibs · 332ac2f8
      Martin Storsjö authored
      Use `clang_target_link_libraries` to avoid duplicate libraries when
      the same symbol is provided both by a static library and a larger
      dylib, fixing linking with win32 dylibs. This fixes errors like
      these:
      
          ld.lld: error: duplicate symbol: llvm::createStringError(std::__1::error_code, char const*)
          >>> defined at libLLVMSupport.a(Error.cpp.obj)
          >>> defined at libLLVM-14git.dll
      
      This matches how other clang tools declare their dependencies.
      
      Differential Revision: https://reviews.llvm.org/D107231
      
      (cherry picked from commit 25a288b0)
      332ac2f8
  3. Aug 02, 2021
  4. Jul 30, 2021
    • Christopher Di Bella's avatar
      Revert "Revert "[clang][pp] adds '#pragma include_instead'"" · 6eaf46be
      Christopher Di Bella authored
      Includes regression test for problem noted by @hans.
      This reverts commit 973de718.
      
      Differential Revision: https://reviews.llvm.org/D106898
      
      (cherry picked from commit 08719541)
      6eaf46be
    • Fangrui Song's avatar
      [ELF] Add -Bsymbolic-non-weak-functions · ad5a6b15
      Fangrui Song authored
      This option is a subset of -Bsymbolic-functions. It applies to STB_GLOBAL
      STT_FUNC definitions.
      
      The address of a vague linkage function (STB_WEAK STT_FUNC, e.g. an inline
      function, a template instantiation) seen by a -Bsymbolic-functions linked
      shared object may be different from the address seen from outside the shared
      object. Such cases are uncommon. (ELF/Mach-O programs may use
      `-fvisibility-inlines-hidden` to break such pointer equality.  On Windows,
      correct dllexport and dllimport are needed to make pointer equality work.
      Windows link.exe enables /OPT:ICF by default so different inline functions may
      have the same address.)
      
      ```
      // a.cc -> a.o -> a.so (-Bsymbolic-functions)
      inline void f() {}
      void *g() { return (void *)&f; }
      
      // b.cc -> b.o -> exe
      // The address is different!
      inline void f() {}
      ```
      
      -Bsymbolic-non-weak-functions is a safer (C++ conforming) subset of
      -Bsymbolic-functions, which can make such programs work.
      
      Implementations usually emit a vague linkage definition in a COMDAT group.  We
      could detect the group (with more code) but I feel that we should just check
      STB_WEAK for simplicity. A weak definition will thus serve as an escape hatch
      for rare cases when users want interposition on definitions.
      
      GNU ld feature request: https://sourceware.org/bugzilla/show_bug.cgi?id=27871
      
      Longer write-up: https://maskray.me/blog/2021-05-16-elf-interposition-and-bsymbolic
      
      If Linux distributions migrate to protected non-vague-linkage external linkage
      functions by default, the linker option can still be handy because it allows
      rapid experiment without recompilation. Protected function addresses currently
      have deep issues in GNU ld.
      
      Reviewed By: peter.smith
      
      Differential Revision: https://reviews.llvm.org/D102570
      
      (cherry picked from commit b06426da)
      ad5a6b15
  5. Jul 29, 2021
  6. Jul 28, 2021
    • Whisperity's avatar
    • Jose M Monsalve Diaz's avatar
      [OpenMP] Fixing missing variables when CUDA SDK not in system · 88e66fa6
      Jose M Monsalve Diaz authored
      This patch fixes the error reported in D106751. When there is no CUDA SDK
      installed in the system, the build fails due to missing `CU_DEVICE_ATTRIBUTE`
      variables.
      
      Using @zsrkmyn sugested fix
      
      Reviewed By: jdoerfert
      
      Differential Revision: https://reviews.llvm.org/D106933
      88e66fa6
    • Jose M Monsalve Diaz's avatar
      [OpenMP][Tool] Introducing the `llvm-omp-device-info` tool · 313c5239
      Jose M Monsalve Diaz authored
      This patch introduces the `llvm-omp-device-info` tool, which uses the
      omptarget library and interface to query the device info from all the
      available devices as seen by OpenMP. This is inspired by PGI's `pgaccelinfo`
      
      Since omptarget usually requires a description structure with executable
      kernels, I split the initialization of the RTLs and Devices to be able to
      initialize all possible devices and query each of them.
      
      This revision relies on the patch that introduces the print device info.
      
      A limitation is that the order in which the devices are initialized, and the
      corresponding device ID is not necesarily the one seen by OpenMP.
      
      The changes are as follows:
      1. Separate the RTL initialization that was performed in `RegisterLib` to its own `initRTLonce` function
      2. Create an `initAllRTLs` method that initializes all available RTLs at runtime
      3. Created the `llvm-deviceinfo.cpp` tool that uses `omptarget` to query each device and prints its information.
      
      Example Output:
      ```
      Device (0):
          print_device_info not implemented
      
      Device (1):
          print_device_info not implemented
      
      Device (2):
          print_device_info not implemented
      
      Device (3):
          print_device_info not implemented
      
      Device (4):
          CUDA Driver Version:                11000
          CUDA Device Number:                 0
          Device Name:                        Quadro P1000
          Global Memory Size:                 4236312576 bytes
          Number of Multiprocessors:          5
          Concurrent Copy and Execution:      Yes
          Total Constant Memory:              65536 bytes
          Max Shared Memory per Block:        49152 bytes
          Registers per Block:                65536
          Warp Size:                          32 Threads
          Maximum Threads per Block:          1024
          Maximum Block Dimensions:           1024, 1024, 64
          Maximum Grid Dimensions:            2147483647 x 65535 x 65535
          Maximum Memory Pitch:               2147483647 bytes
          Texture Alignment:                  512 bytes
          Clock Rate:                         1480500 kHz
          Execution Timeout:                  Yes
          Integrated Device:                  No
          Can Map Host Memory:                Yes
          Compute Mode:                       DEFAULT
          Concurrent Kernels:                 Yes
          ECC Enabled:                        No
          Memory Clock Rate:                  2505000 kHz
          Memory Bus Width:                   128 bits
          L2 Cache Size:                      1048576 bytes
          Max Threads Per SMP:                2048
          Async Engines:                      Yes (2)
          Unified Addressing:                 Yes
          Managed Memory:                     Yes
          Concurrent Managed Memory:          Yes
          Preemption Supported:               Yes
          Cooperative Launch:                 Yes
          Multi-Device Boars:                 No
          Compute Capabilities:               61
      ```
      
      Reviewed By: tianshilei1992
      
      Differential Revision: https://reviews.llvm.org/D106752
      313c5239