1. Sep 01, 2023
    • Alex Langford's avatar
      [lldb] Add support for recognizing swift ast sections in object files · 764287f1
      Alex Langford authored
      In Apple's downstream fork, there is support for understanding the swift
      AST sections in various binaries. Even though the lldb on llvm.org does
      not have support for debugging swift, I think it makes sense to move
      support for recognizing swift ast sections upstream.
      
      Differential Revision: https://reviews.llvm.org/D159142
      764287f1
    • Matt Arsenault's avatar
      MachineFunction: Add verify method that accepts LiveIntervals · dfc0ede1
      Matt Arsenault authored
      This version can be used without a PassManager
      
      https://reviews.llvm.org/D133784
      dfc0ede1
    • Philip Reames's avatar
    • Matt Arsenault's avatar
      SelectionDAG: Swap operands of atomic_store · ad9d13d5
      Matt Arsenault authored
      Irritatingly, atomic_store had operands in the opposite order from
      regular store. This made it difficult to share patterns between
      regular and atomic stores.
      
      There was a previous incomplete attempt to move atomic_store into the
      regular StoreSDNode which would be better.
      
      I think it was a mistake for all atomicrmw to swap the operand order,
      so maybe it's better to take this one step further.
      
      https://reviews.llvm.org/D123143
      ad9d13d5
    • Nick Desaulniers's avatar
      Revert "[llvm][docs] commit phabricator patch" · e0447ce1
      Nick Desaulniers authored
      This reverts commit ef4beb8b.
      
      It also removes the prior note about needing to patch ``arcanist``.
      
      This is patch is no longer necessary:
      1. arcanist came out of hibernation and updated to support PHP 8.1.
         https://github.com/phacility/arcanist/commits/master
      2. llvm/llvm-project is moving to github pull requests starting Sept 1
         (tomorrow).
         https://discourse.llvm.org/t/pull-request-migration-schedule/71595
      
      Fixes: #64470
      
      Reviewed By: MaskRay
      
      Differential Revision: https://reviews.llvm.org/D159291
      e0447ce1
    • Galen Elias's avatar
      [clang-format] Fix AlignArrayOfStructures + Cpp11BracedListStyle=false · 58c67e72
      Galen Elias authored
      Currently AlignArrayOfStructures=Left is hard coding setting Spaces to
      0 for the token following the initial opening brace, but not touching
      Spaces for the subsequent lines, which leads to the array being
      misaligned. Additionally, it's not adding a space before the trailing
      } which is generally done when Cpp11BracedListStyle=false.
      
      I'm not exactly sure why this function needs to override the Spaces as
      it seems to generally already be set to either 0 or 1 according to
      the other formatting settings, but I'm going with an explicit fix where
      I just force the padding to 1 when Cpp11BracedListStyle=false.
      
      AlignArrayOfStructures=Right doesn't have any alignment problems, but
      isn't adding the expected padding around the braces either, so I'm
      giving that the same treatment.
      
      Fixes #57611.
      
      Differential Revision: https://reviews.llvm.org/D158795
      58c67e72
    • Med Ismail Bennani's avatar
      [lldb] Fix test failure for breakpoint_function_callback.test · c9ecaf32
      Med Ismail Bennani authored
      
      
      This should fix the test failure in breakpoint_function_callback.test
      since SBStructuredData can now display the content of SBStructuredData.
      
      Signed-off-by: default avatarMed Ismail Bennani <ismail@bennani.ma>
      c9ecaf32
    • Nick Desaulniers's avatar
      [Sema] add test cases for D152495 NFC · cfa578cd
      Nick Desaulniers authored
      Ensure these don't regress the next time we reland D152495.
      
      Link: https://github.com/ClangBuiltLinux/linux/issues/1926
      
      Reviewed By: cor3ntin, MaskRay
      
      Differential Revision: https://reviews.llvm.org/D159307
      cfa578cd
    • Arthur Eubanks's avatar
      [X86] Use 64-bit jump table entries for large code model PIC · 2a2f02e1
      Arthur Eubanks authored
      With the large code model, the label difference may not fit into 32 bits.
      Even if we assume that any individual function is no larger than 2^32
      and use a difference from the function entry to the target destination,
      things like BOLT can rearrange blocks (even if BOLT doesn't necessarily
      work with the large code model right now).
      
      set directives avoid static relocations in some 32-bit entry cases, but
      don't worry about set directives for 64-bit jump table entries (we can
      do that later if somebody really cares about it).
      
      check-llvm in a bootstrapped clang with the large code model passes.
      
      Fixes #62894
      
      Reviewed By: rnk
      
      Differential Revision: https://reviews.llvm.org/D159297
      2a2f02e1
    • Avimitin's avatar
      [mlir][doc] fix document link in Builtin Dialect document · 8399f373
      Avimitin authored
      The inline link to RankedTensorType in UnrankedTensorType section
      and the inline link to MemRefType in UnrankedMemrefType section
      are all invalid. This patch update these link.
      
      Reviewed By: aartbik
      
      Differential Revision: https://reviews.llvm.org/D152682
      8399f373
    • Jacques Pienaar's avatar
    • Nick Desaulniers's avatar
      Revert "[RISCV] Teach RISCVMergeBaseOffset to handle inline asm" · fc5306d1
      Nick Desaulniers authored
      This reverts commit f281543a.
      
      Sami Tolvanen reports that this breaks the Linux kernel's arch=RISCV
      defconfig.
      
      Link: https://github.com/ClangBuiltLinux/linux/issues/1928
      fc5306d1
    • Vitaly Buka's avatar
      [NFC][HWASAN] Extract insertShadowTagCheck() · c6aaf2e5
      Vitaly Buka authored
      Reviewed By: fmayer
      
      Differential Revision: https://reviews.llvm.org/D159165
      c6aaf2e5
    • LLVM GN Syncbot's avatar
      [gn build] Port c01794e7 · b8f60c69
      LLVM GN Syncbot authored
      b8f60c69
    • Joseph Huber's avatar
      [libc] Support 'assert.h' on the GPU · 533145c4
      Joseph Huber authored
      This patch adds the necessary support to provide `assert` functionality
      through the GPU `libc` implementation. This implementation creates a
      special-case GPU implementation rather than relying on the common
      version. This is because the GPU has special considerings for printing.
      The assertion is printed out in chunks with `write_to_stderr`, however
      when combined with the GPU execution model this causes 32+ threads to
      all execute in-lock step. Meaning that we'll get a horribly fragmented
      message. Furthermore, potentially thousands of threads could hit the
      assertion at once and try to print even if we had it all in one
      `printf`.
      
      This is solved by having a one-time lock that each thread group / wave /
      warp will attempt to claim. We only let one thread group pass through
      while the others simply stop executing. Finally only the first thread in
      that group will do the printing until we finally abort execution.
      
      Reviewed By: sivachandra
      
      Differential Revision: https://reviews.llvm.org/D159296
      533145c4
    • Piotr Zegar's avatar
      [clang-tidy] Add exit code support to clang-tidy-diff.py · 4294bca5
      Piotr Zegar authored
      Modify script to fail when some run clang-tidy
      command fails. Based on run_clang-tidy.
      
      Fixes: #65000
      
      Reviewed By: carlosgalvezp
      
      Differential Revision: https://reviews.llvm.org/D158929
      4294bca5
    • Piotr Zegar's avatar
      [clang-tidy] readability-container-size-empty handle std::string length() · efebb4e0
      Piotr Zegar authored
      
      
      Extends readability-container-size-empty to check std::string length() similar to size().
      
      Fixes: #37603
      
      Co-authored-by: default avatarDmitry Venikov <quolyk@gmail.com>
      
      Reviewed By: carlosgalvezp
      
      Differential Revision: https://reviews.llvm.org/D56644
      efebb4e0
    • Hiroshi Yamauchi's avatar
      [AArch64][WinCFI] Handle cases where no SEH opcodes in the prologue · 8942d304
      Hiroshi Yamauchi authored
      but there are some in the epilogue.
      
      Make a decision whether or not to have a startepilogue/endepilogue
      based on whether we actually insert SEH opcodes in the epilogue,
      rather than whether we had SEH opcodes in the prologue or not.
      
      This fixes an assert failure when there are no SEH opcodes in the
      prologue but there are SEH opcodes in the epilogue (for example, when
      there is no stack frame but there are stack arguments) which was not
      covered in https://reviews.llvm.org/D88641.
      
      Assertion failed: HasWinCFI == MF.hasWinCFI(), file C:\Users\hiroshi\llvm-project\llvm\lib\Target\AArch64\AArch64FrameLowering.cpp, line 1988
      
      Differential Revision: https://reviews.llvm.org/D159238
      8942d304
    • Med Ismail Bennani's avatar
      Re-land "[lldb/docs] Silence warnings when generating website" · 6813ef37
      Med Ismail Bennani authored
      This patch re-lands f0731d5b with more fixes and improvements.
      
      First, this patch removes `__eq__` implementations from classes that
      didn't implemented `operator!=` on the C++ implementation.
      
      This patch removes sphinx document generation for special members such
      as `__len__`, since there is no straightforward way to skip class that
      don't implement them. We also don't want to introduce a change in
      behavior by implementing artifical special members for classes that are
      missing them.
      
      Finally, this patch improve the ergonomics of some classes by
      implementing special members where it makes sense, i.e. `hex(SBFrame)`
      is equivalent to `SBFrame.GetPC()`.
      
      Differential Revision: https://reviews.llvm.org/D159017
      
      
      
      Signed-off-by: default avatarMed Ismail Bennani <ismail@bennani.ma>
      6813ef37
    • Vitaly Buka's avatar
      [NFC][hwasan] Rename local variable · b80fa58b
      Vitaly Buka authored
      b80fa58b
    • Piotr Zegar's avatar
      [clang-tidy][NFC] Improve compilation time of IntegralLiteralExpressionMatcher · a199d8fa
      Piotr Zegar authored
      When using agressive inlining -Xclang -mllvm -Xclang -inline-threshold=500,
      this file takes 10-18 min to compile. This is caused by in-direct recursion.
      Looks like transforming code to use templates and lambdas instead of
      std::function and member function pointer reduces this time to 0.5s.
      
      Fixes: #59658
      a199d8fa
    • Daniel Paoliello's avatar
      Emit the CodeView `S_ARMSWITCHTABLE` debug symbol for jump tables · 0c5c7b52
      Daniel Paoliello authored
      The CodeView `S_ARMSWITCHTABLE` debug symbol is used to describe the layout of a jump table, it contains the following information:
      
      * The address of the branch instruction that uses the jump table.
      * The address of the jump table.
      * The "base" address that the values in the jump table are relative to.
      * The type of each entry (absolute pointer, a relative integer, a relative integer that is shifted).
      
      Together this information can be used by debuggers and binary analysis tools to understand what an jump table indirect branch is doing and where it might jump to.
      
      Documentation for the symbol can be found in the Microsoft PDB library dumper: https://github.com/microsoft/microsoft-pdb/blob/0fe89a942f9a0f8e061213313e438884f4c9b876/cvdump/dumpsym7.cpp#L5518
      
      This change adds support to LLVM to emit the `S_ARMSWITCHTABLE` debug symbol as well as to dump it out (for testing purposes).
      
      Reviewed By: efriedma
      
      Differential Revision: https://reviews.llvm.org/D149367
      0c5c7b52
    • Michael Maitland's avatar
      [RISCV] Set SEW on VPseudoTernaryWithTailPolicy and VPseudoTernaryWithTailPolicyRoundingMode · cf552493
      Michael Maitland authored
      The SEW field should be set here so llvm-mca can correctly resolve the
      SchedClassID from the InversePseudosTable.
      
      Differential Revision: https://reviews.llvm.org/D159231
      cf552493
    • Nick Desaulniers's avatar
      Revert "Reland "[Clang][SemaCXX] Add unused warning for variables declared in... · f0f395e0
      Nick Desaulniers authored
      Revert "Reland "[Clang][SemaCXX] Add unused warning for variables declared in condition expressions""
      
      This reverts commit 92023b15.
      
      Further issues were uncovered:
      - False positive -Wunused-variable on function-static variables with the
        used attribute. https://github.com/ClangBuiltLinux/linux/issues/1926
        A test case needs to be added for this.
      - Request for a new flag for these.
        https://reviews.llvm.org/D152495#4628877
        https://reviews.llvm.org/D152495#4628887
      f0f395e0
    • Louis Dionne's avatar
      [libc++abi] Use std::abort() instead of std::terminate() on failure to allocate · f6ba9850
      Louis Dionne authored
      Inside the Itanium demangler, we would previously call std::terminate()
      after failing to (re)allocate. However, programs are free to install a
      custom terminate_handler which does non-trivial things. In fact, by
      default libc++abi itself installs a demangling_terminate_handler() which
      tries to demangle the currently active exception before aborting the
      program.
      
      In case of an out-of-memory exception caused by the system truly having
      no more memory (as opposed to attempting to allocate INT_MAX just once),
      we will end up trying to demangle the exception, failing to do so because
      we can't grow the OutputBuffer inside ItaniumDemangle.h, and then calling
      std::terminate() there. That will call the demangling_terminate_handler(),
      which will then start this loop again. We eventually end up crashing due
      to a stack overflow.
      
      To fix this problem, this patch calls std::abort() directly from the
      demangler instead of going through std::terminate(). After all, calling
      std::abort() is the default behavior for std::terminate() according
      to the Standard, so this behavior is definitely valid. The downside of
      this approach is that in case of a "true" out-of-memory condition:
      1. the program will throw an exception
      2. std::terminate() will be called if uncaught
      3. demangling_terminate_handler() will be called and will fail
      4. abort() will be called
      
      We'll end up aborting the program without mentioning the cause, which
      normally looks like:
      
        terminating due to uncaught exception of type <TYPE>: <what()-MESSAGE>
      
      Another option would be to properly handle failure-to-allocate inside
      ItaniumDemangle.h and to propagate something like an error code or a
      std::expected to the caller of all functions in the demangler that
      can allocate. Then, we could make sure that __cxa_demangle returns
      nullptr when it fails to demangle the input due to any error, as it is
      supposed to (but today "true" out-of-memory conditions are not handled
      properly). The demangling_terminate_handler() would then see that
      __cxa_demangle failed to do its job and would still print the
      appropriate message, simply using the non-demangled exception type.
      However, this is akin to a partial rewrite of the demangler code since
      a large number of functions would now have to return a std::expected
      to account for out-of-memory conditions.
      
      Using exceptions would be a lot simpler in terms of code changes and
      would achieve the same result, however the demangler can't use exceptions
      because it is used inside LLVM and libc++abi implements the exception
      runtime anyway (so while it might be possible to use them in that
      context, I'd argue we'd only be playing with fire).
      
      rdar://110767664
      
      Differential Revision: https://reviews.llvm.org/D155598
      f6ba9850
    • Louis Dionne's avatar
      [libc++] Move once_flag outside of <mutex> · c01794e7
      Louis Dionne authored
      This allows including once_flag directly from <__locale> instead of
      depending on all of <mutex>, which requires threading. In turn, this
      makes it easier to support locales on platforms without threading.
      
      Drive-by change: clang-format once_flag.h and use _LIBCPP_HIDE_FROM_ABI
      
      Differential Revision: https://reviews.llvm.org/D155487
      c01794e7
    • Luke Lau's avatar
      [RISCV] Fix crash during during i1 vector bitreverse lowering · 1664eb05
      Luke Lau authored
      A shuffle of v256i1 with a large enough minimum vlen might make it through type
      legalization and into lowering. In this case, zvl1024b was enough. The
      bitreverse shuffle lowering would then try to convert this to a v1i256 type
      which is invalid (v1i128 exists though, which is why the existing v128i1 tests
      were fine).
      
      This patch checks to make sure that the new type is not only legal but also
      valid.
      
      Reviewed By: craig.topper, reames
      
      Differential Revision: https://reviews.llvm.org/D159215
      1664eb05
    • Konstantina Mitropoulou's avatar
      [DAGCombiner] Change foldAndOrOfSETCC() to optimize and/or patterns with floating points. · 17fc78e7
      Konstantina Mitropoulou authored
      This reverts commit 48fa79a5.
      
      Reviewed By: brooksmoses
      
      Differential Revision: https://reviews.llvm.org/D159240
      17fc78e7
    • Luke Lau's avatar
      [RISCV] Remove vmv_v_x_vl workaround for constant splat. NFC · 7b33f60f
      Luke Lau authored
      Now that DAG.getConstant uses splat_vector_parts if needed on RV32, we can use
      it directly without having to manually lower to a vmv_v_x_vl.
      
      Reviewed By: reames
      
      Differential Revision: https://reviews.llvm.org/D159287
      7b33f60f
    • Alex Langford's avatar
      [lldb][NFCI] Remove unneeded ConstString conversions · 14d95b26
      Alex Langford authored
      ConstString can be implicitly converted into a llvm::StringRef. This is
      very useful in many places, but it also hides places where we are
      creating a ConstString only to use it as a StringRef for the entire
      lifespan of the ConstString object.
      
      I locally removed the implicit conversion and found some of the places we
      were doing this.
      
      Differential Revision: https://reviews.llvm.org/D159237
      14d95b26
    • Philip Reames's avatar
      [RISCV] Rename getELEN to getELen [nfc] · 3e89aca4
      Philip Reames authored
      Let's follow the naming scheme use for DLen, XLen, and FLen.
      3e89aca4
    • Vitaly Buka's avatar
      [test][HWASAN] Precommit -hwasan-inline-fast-path-checks tests · bb637396
      Vitaly Buka authored
      Reviewed By: fmayer
      
      Differential Revision: https://reviews.llvm.org/D159157
      bb637396
    • Eric Fiselier's avatar
      Remove lit's --summary flag from buildbots. · 3e0bc8cf
      Eric Fiselier authored
      The summary flag causes a progress bar to appear and be rewritten using
      a curses like interface. This works great for interactive sessions, but
      produces line after line of garbage in the logs.
      
      This should cause the logs to be much smaller and more readable.
      
      Reviewed By: #libc, ldionne
      
      Differential Revision: https://reviews.llvm.org/D159120
      3e0bc8cf
    • Mark de Wever's avatar
      [clang][doc] Uses C++20 instead of C++2a. · fa832d5a
      Mark de Wever authored
      fa832d5a
    • Philip Reames's avatar
      [RISCV] Kill off redundant field XLenVT [nfc] · 1c43aa44
      Philip Reames authored
      We're already tracking XLen, we can compute XLenVt from that.  Note that XLen itself should probably be driven from IsRV64 (the processor flag), but I'm leaving that to a separate change (with review).
      1c43aa44
    • Craig Topper's avatar
      [RISCV] Prefer ShortForwardBranch over the fully generic Zicond expansion. · d1c3784a
      Craig Topper authored
      Short forward branch is shorter than (or (czero.eqz), (czero.nez)).
      
      Reviewed By: reames
      
      Differential Revision: https://reviews.llvm.org/D159295
      d1c3784a
    • Philip Reames's avatar
    • Amir Ayupov's avatar
      [BOLT][test] Move asm-dump.c to runtime/X86 · 8f9006bf
      Amir Ayupov authored
      Since the test executes instrumented version of the binary, move it under
      runtime/X86. Note that it can be adjusted to also run under AArch64 now that
      instrumentation is supported.
      
      Reviewed By: #bolt, maksfb
      
      Differential Revision: https://reviews.llvm.org/D159298
      8f9006bf
    • Alex Langford's avatar
      [lldb][NFCI] Replace bespoke iterator check with std::next · 9ed72d4d
      Alex Langford authored
      The primary goal of this change is to change `if (pair != *(--m_dict.end()))`
      to `if (std::next(iter) != m_dict.end())`. I was experimenting with
      changing the underlying type of `m_dict` and found that this was an
      issue. Specifically, it assumes that m_dict iterators are bidirectional.
      This change should make it so we only need to assume m_dict iterators can move
      forward.
      
      Differential Revision: https://reviews.llvm.org/D159150
      9ed72d4d
    • Greg Clayton's avatar
      Fix shared library loading when users define duplicate _r_debug structure. · 07c215e8
      Greg Clayton authored
      We ran into a case where shared libraries would fail to load in some processes on linux. The issue turned out to be if the main executable or a shared library defined a symbol named "_r_debug", then it would cause problems once the executable that contained it was loaded into the process. The "_r_debug" structure is currently found by looking through the .dynamic section in the main executable and finding the DT_DEBUG entry which points to this structure. The dynamic loader will update this structure as shared libraries are loaded and LLDB watches the contents of this structure as the dyld breakpoint is hit. Currently we expect the "state" in this structure to change as things happen. An issue comes up if someone defines another "_r_debug" struct in their program:
      ```
      r_debug _r_debug;
      ```
      If this code is included, a new "_r_debug" structure is created and it causes problems once the executable is loaded. This is because of the way symbol lookups happen in linux: they use the shared library list in the order it created and the dynamic loader is always last. So at some point the dynamic loader will start updating this other copy of "_r_debug", yet LLDB is only watching the copy inside of the dynamic loader.
      
      Steps that show the problem are:
      - lldb finds the "_r_debug" structure via the DT_DEBUG entry in the .dynamic section and this points to the "_r_debug" in ld.so
      - ld.so modifies its copy of "_r_debug" with "state = eAdd" before it loads the shared libraries and calls the dyld function that LLDB has set a breakpoint on and we find this state and do nothing (we are waiting for a state of eConsistent to tell us the shared libraries have been fully loaded)
      - ld.so loads the main executable and any dependent shared libraries and wants to update the "_r_debug" structure, but it now finds "_r_debug" in the a.out program and updates the state in this other copy
      - lldb hits the notification breakpoint and checks the ld.so copy of "_r_debug" which still has a state of "eAdd". LLDB wants the new "eConsistent" state which will trigger the shared libraries to load, but it gets stale data and doesn't do anyhing and library load is missed. The "_r_debug" in a.out has the state set correctly, but we don't know which "_r_debug" is the right one.
      
      The new fix detects the two "eAdd" states and loads shared libraries and will emit a log message in the "log enable lldb dyld" log channel which states there might be multiple "_r_debug" structs.
      
      The correct solution is that no one should be adding a duplicate "_r_debug" symbol to their binaries, but we have programs that are doing this already and since it can be done, we should be able to work with this and keep debug sessions working as expected. If a user #includes the <link.h> file, they can just use the existing "_r_debug" structure as it is defined in this header file as "extern struct r_debug _r_debug;" and no local copies need to be made.
      
      If your ld.so has debug info, you can easily see the duplicate "_r_debug" structs by doing:
      ```
      (lldb) target variable _r_debug --raw
      (r_debug) _r_debug = {
        r_version = 1
        r_map = 0x00007ffff7e30210
        r_brk = 140737349972416
        r_state = RT_CONSISTENT
        r_ldbase = 0
      }
      (r_debug) _r_debug = {
        r_version = 1
        r_map = 0x00007ffff7e30210
        r_brk = 140737349972416
        r_state = RT_ADD
        r_ldbase = 140737349943296
      }
      (lldb) target variable &_r_debug
      (r_debug *) &_r_debug = 0x0000555555601040
      (r_debug *) &_r_debug = 0x00007ffff7e301e0
      ```
      And if you do a "image lookup --address <addr>" in the addresses, you can see one is in the a.out and one in the ld.so.
      
      Adding more logging to print out the m_previous and m_current Rendezvous structures to make things more clear. Also added a log when we detect multiple eAdd states in a row to detect this problem in logs.
      
      Differential Revision: https://reviews.llvm.org/D158583
      07c215e8