1. Mar 07, 2023
    • Med Ismail Bennani's avatar
      480eb744
    • Med Ismail Bennani's avatar
      [lldb/Utility] Fix layering violation caused by ScriptedMetadata · 601583e5
      Med Ismail Bennani authored
      
      
      This patch moves `ScriptedMetadata.h` from the `Interpreter` directory to
      the `Utility` sub-directory since `ProcessInfo.h` depends on it.
      
      It also gets rid of the unused `OptionGroupPythonClassWithDict`
      constructor for `ScriptedMetadata` which would address the layering
      violation.
      
      Signed-off-by: default avatarMed Ismail Bennani <medismail.bennani@gmail.com>
      601583e5
    • Med Ismail Bennani's avatar
      [lldb] Add an example of interactive scripted process debugging (NFC) · 70b9822e
      Med Ismail Bennani authored
      
      
      This patch is a proof of concept that shows how a scripted process could
      be used with real process to perform interactive debugging.
      
      In this example, we run a process that spawns 10 threads. Then, we
      create a intermediary scripted process who's job will be to wrap the
      real process while intercepting it's process events and dispatching them
      back either to the real process or to other child scripted processes.
      
      In this example, we have 2 child scripted processes, with even and odd
      thread indices. The goal is to be able to do thread filtering and
      explore the various interactive debugging approaches, by letting a child
      process running when stopping the other process and inspecting it.
      Another approach would be to have the child processes execution in-sync
      to force running every child process when one of them starts running.
      
      Signed-off-by: default avatarMed Ismail Bennani <medismail.bennani@gmail.com>
      70b9822e
    • Med Ismail Bennani's avatar
      [lldb/Plugin] Add breakpoint setting support to ScriptedProcesses. · cfe06f49
      Med Ismail Bennani authored
      This patch adds support for breakpoint setting to Scripted Processes.
      
      For now, Scripted Processes only support setting software breakpoints.
      
      When doing interactive scripted process debugging, it makes use of the
      memory writing capability to write the trap opcodes in the memory of the
      driving process. However the real process' target doesn't keep track of
      the breakpoints that got added by the scripted process. This is a design
      that we might need to change in the future, since we'll probably need to
      do some book keeping to handle breakpoints that were set by different
      scripted processes.
      
      Differential Revision: https://reviews.llvm.org/D145296
      
      
      
      Signed-off-by: default avatarMed Ismail Bennani <medismail.bennani@gmail.com>
      cfe06f49
    • Med Ismail Bennani's avatar
      [lldb] Move ScriptedProcess private state update to implementation · 3c33d72e
      Med Ismail Bennani authored
      While debugging a Scripted Process, in order to update its state and
      work nicely with lldb's execution model, it needs to toggle its private
      state from running to stopped, which will result in broadcasting a
      process state changed event to the debugger listener.
      
      Originally, this state update was done systematically in the Scripted
      Process C++ plugin, however in order to make scripted process
      interactive, we need to be able to update their state dynamically.
      
      This patch makes use of the recent addition of the
      `SBProcess::ForceScriptedState` to programatically, and moves the
      process private state update to the python implementation of the `resume`
      method instead of doing it in `ScriptedProcess::DoResume`.
      
      This patch also removes the unused `ShouldStop` & `Stop` scripted
      process APIs, and adds new ScriptedInterface transform methods for
      boolean arguments. This allow the user to programmatically decide if
      after running the process, we should stop it (which is the default setting).
      
      Differential Revision: https://reviews.llvm.org/D145295
      
      
      
      Signed-off-by: default avatarMed Ismail Bennani <medismail.bennani@gmail.com>
      3c33d72e
    • Med Ismail Bennani's avatar
      [lldb/API] Introduce SBProcess::ForceScriptedState method · 3675e0bb
      Med Ismail Bennani authored
      This patch introduces a new method to the SBProcess API called
      ForceScriptedState. As the name suggests, this affordance will allow the
      user to alter the private state of the scripted process programatically.
      
      This is necessary to update the scripted process state when perform
      interactive debugging.
      
      Differential Revision: https://reviews.llvm.org/D145294
      
      
      
      Signed-off-by: default avatarMed Ismail Bennani <medismail.bennani@gmail.com>
      3675e0bb
    • Owen Pan's avatar
      [clang-format] Don't annotate left brace of class as FunctionLBrace · a02c3af9
      Owen Pan authored
      The l_brace of class/struct/union was incorrectly annotated as
      TT_FunctionLBrace in the presence of attributes. This in turn
      would cause the RemoveSemicolon option to remove the semicolon
      at the end of the declaration, resulting in invalid code being
      generated.
      
      Fixes #61188.
      
      Differential Revision: https://reviews.llvm.org/D145344
      a02c3af9
    • Dave Lee's avatar
      [lldb] Redefine p alias to dwim-print command · a00801d9
      Dave Lee authored
      Redefine the `p` alias to the `dwim-print` command instead of `expression`.
      
      See https://reviews.llvm.org/D138315 for the introduction of `dwim-print`.
      
      To summarize, `dwim-print` is, as the name suggests, a command for printing. How a value
      gets printed, is decided by `dwim-print`. In some cases, `dwim-print` will print values
      using the same means as `frame variable` (because it's generally more reliable and
      faster that `expression` evaluation), and in other cases `dwim-print` uses the same code
      path as `expression`.
      
      This change has been tested in two different ways:
      
      1. Re-aliasing `p` to `dwim-print`, as in this patch
      2. Redefinining the `expression` command to `CommandObjectDWIMPrint`
      
      Previously, many of the lldb's tests used `p`, and which meant a test run with `p`
      aliases to `dwim-print` was a good way to test `dwim-print`. However most of those tests
      were updated to use `expression` explicitly (in anticipation of this change). Now, the
      best way to test `dwim-print` is the second approach:
      
      ```
      diff --git a/lldb/source/Interpreter/CommandInterpreter.cpp b/lldb/source/Interpreter/CommandInterpreter.cpp
      index 373c894f34f5..9c943cd30c7c 100644
      --- a/lldb/source/Interpreter/CommandInterpreter.cpp
      +++ b/lldb/source/Interpreter/CommandInterpreter.cpp
      @@ -539,7 +539,7 @@ void CommandInterpreter::LoadCommandDictionary() {
         REGISTER_COMMAND_OBJECT("diagnostics", CommandObjectDiagnostics);
         REGISTER_COMMAND_OBJECT("disassemble", CommandObjectDisassemble);
         REGISTER_COMMAND_OBJECT("dwim-print", CommandObjectDWIMPrint);
      -  REGISTER_COMMAND_OBJECT("expression", CommandObjectExpression);
      +  REGISTER_COMMAND_OBJECT("expression", CommandObjectDWIMPrint);
         REGISTER_COMMAND_OBJECT("frame", CommandObjectMultiwordFrame);
         REGISTER_COMMAND_OBJECT("gui", CommandObjectGUI);
         REGISTER_COMMAND_OBJECT("help", CommandObjectHelp);
      ```
      
      When the test suite is run with this change, there are two main categories of test
      failures for specific to features that `dwim-print` intentionally doesn't support:
      
      1. Top level expressions (`--top-level`/`-p`)
      2. Multiline expressions
      
      In cases where the behavior of `expression` is needed, users can use `expression` at
      those times.
      
      Differential Revision: https://reviews.llvm.org/D145189
      a00801d9
    • wren romano's avatar
      [mlir][sparse] Renaming "pointer/index" to "position/coordinate" · 84cd51bb
      wren romano authored
      The old "pointer/index" names often cause confusion since these names clash with names of unrelated things in MLIR; so this change rectifies this by changing everything to use "position/coordinate" terminology instead.
      
      In addition to the basic terminology, there have also been various conventions for making certain distinctions like: (1) the overall storage for coordinates in the sparse-tensor, vs the particular collection of coordinates of a given element; and (2) particular coordinates given as a `Value` or `TypedValue<MemRefType>`, vs particular coordinates given as `ValueRange` or similar.  I have striven to maintain these distinctions
      as follows:
      
        * "p/c" are used for individual position/coordinate values, when there is no risk of confusion.  (Just like we use "d/l" to abbreviate "dim/lvl".)
      
        * "pos/crd" are used for individual position/coordinate values, when a longer name is helpful to avoid ambiguity or to form compound names (e.g., "parentPos").  (Just like we use "dim/lvl" when we need a longer form of "d/l".)
      
          I have also used these forms for a handful of compound names where the old name had been using a three-letter form previously, even though a longer form would be more appropriate.  I've avoided renaming these to use a longer form purely for expediency sake, since changing them would require a cascade of other renamings.  They should be updated to follow the new naming scheme, but that can be done in future patches.
      
        * "coords" is used for the complete collection of crd values associated with a single element.  In the runtime library this includes both `std::vector` and raw pointer representations.  In the compiler, this is used specifically for buffer variables with C++ type `Value`, `TypedValue<MemRefType>`, etc.
      
          The bare form "coords" is discouraged, since it fails to make the dim/lvl distinction; so the compound names "dimCoords/lvlCoords" should be used instead.  (Though there may exist a rare few cases where is is appropriate to be intentionally ambiguous about what coordinate-space the coords live in; in which case the bare "coords" is appropriate.)
      
          There is seldom the need for the pos variant of this notion.  In most circumstances we use the term "cursor", since the same buffer is reused for a 'moving' pos-collection.
      
        * "dcvs/lcvs" is used in the compiler as the `ValueRange` analogue of "dimCoords/lvlCoords".  (The "vs" stands for "`Value`s".)  I haven't found the need for it, but "pvs" would be the obvious name for a pos-`ValueRange`.
      
          The old "ind"-vs-"ivs" naming scheme does not seem to have been sustained in more recent code, which instead prefers other mnemonics (e.g., adding "Buf" to the end of the names for `TypeValue<MemRefType>`).  I have cleaned up a lot of these to follow the "coords"-vs-"cvs" naming scheme, though haven't done an exhaustive cleanup.
      
        * "positions/coordinates" are used for larger collections of pos/crd values; in particular, these are used when referring to the complete sparse-tensor storage components.
      
          I also prefer to use these unabbreviated names in the documentation, unless there is some specific reason why using the abbreviated forms helps resolve ambiguity.
      
      In addition to making this terminology change, this change also does some cleanup along the way:
        * correcting the dim/lvl terminology in certain places.
        * adding `const` when it requires no other code changes.
        * miscellaneous cleanup that was entailed in order to make the proper distinctions.  Most of these are in CodegenUtils.{h,cpp}
      
      Reviewed By: aartbik
      
      Differential Revision: https://reviews.llvm.org/D144773
      84cd51bb
    • Yuanfang Chen's avatar
      [NFC][Clang] add test comments for GitHub issue 58896 · 3e00f24f
      Yuanfang Chen authored
      Per discussions with @erichkeane.
      3e00f24f
    • Dave Lee's avatar
      Recommit [lldb] Test 'v' support for direct ivar access (NFC) · 23ee705a
      Dave Lee authored
      Add basic tests for `frame variable`'s ability to direct access fields of `this` and
      ivars of `self`.
      
      This splits the tests, preventing ObjC tests from running on Linux.
      
      Differential Revision: https://reviews.llvm.org/D145348
      23ee705a
    • Jakub Kuderski's avatar
      [ADT] Avoid needless iterator copies in `zippy` · 38774c4f
      Jakub Kuderski authored
      Make `zip_common` increment and decrement iterators in place.
      
      This improves performance with iterator types that have non-triviall
      copy constructors.
      
      Reviewed By: zero9178
      
      Differential Revision: https://reviews.llvm.org/D145337
      38774c4f
    • Chia-hung Duan's avatar
      [scudo] Make the boundary of memory group aligned with region begin · a6e3bb9b
      Chia-hung Duan authored
      This alignment guarantee enables simpler group range check while page
      releasing and a potential optimization which is, now all the pointers
      from the same group are also inth same region, that means the complexity
      in markFreeBlocks() can be reduced as well.
      
      Reviewed By: cferris
      
      Differential Revision: https://reviews.llvm.org/D142931
      a6e3bb9b
    • Dave Lee's avatar
      Revert "[lldb] Test 'v' support for direct ivar access (NFC)" · 3df28efa
      Dave Lee authored
      This reverts commit 03e5c46e.
      3df28efa
    • Jan Svoboda's avatar
      [clang][deps] Un-XFAIL test on AIX · c4de9b9c
      Jan Svoboda authored
      c4de9b9c
    • Sanjay Patel's avatar
      [InstCombine] fold signed absolute diff patterns · 74a58499
      Sanjay Patel authored
      This overlaps partially with the codegen patch D144789. This needs no-wrap
      for correctness, and I'm not sure if there's an unsigned equivalent:
      https://alive2.llvm.org/ce/z/ErmQ-9
      https://alive2.llvm.org/ce/z/mr-c_A
      
      This is obviously an improvement in IR, and it looks like a codegen win
      for all targets and data types that I sampled.
      
      The 'nabs' case is left as a potential follow-up (and seems less likely
      to occur in real code).
      
      Differential Revision: https://reviews.llvm.org/D145073
      74a58499
    • Sanjay Patel's avatar
      870e6b6e
    • Dave Lee's avatar
      [lldb] Add variable completion to dwim-print · 8794712e
      Dave Lee authored
      Enable completion of variables for `dwim-print` command.
      
      Differential Revision: https://reviews.llvm.org/D145124
      8794712e
    • Dave Lee's avatar
      [lldb] Test 'v' support for direct ivar access (NFC) · 03e5c46e
      Dave Lee authored
      Add basic tests for `frame variable`'s ability to direct access fields of `this` and
      ivars of `self`.
      
      Differential Revision: https://reviews.llvm.org/D145348
      03e5c46e
    • Paul Walker's avatar
      04a29a3d
    • Goran Flegar's avatar
      [mlir-opt] Fix dialect preload after fb1bb6a0 · f2cdccc0
      Goran Flegar authored
      Also pipe empty string to the commandline test to make sure it does
      not hang on some configurations.
      f2cdccc0
    • Simon Pilgrim's avatar
    • Jay Foad's avatar
    • Jay Foad's avatar
      e73d3150
    • Kazu Hirata's avatar
      [X86] Optimize umax(X,1) (NFC) · a21a7ddf
      Kazu Hirata authored
      Without this patch:
      
        %cond = call i32 @llvm.umax.i32(i32 %X, i32 1)
      
      is compiled as:
      
        83 ff 02                   cmp    $0x2,%edi
        b8 01 00 00 00             mov    $0x1,%eax
        0f 43 c7                   cmovae %edi,%eax
      
      With this patch, the compiler generates:
      
        89 f8                      mov    %edi,%eax
        83 ff 01                   cmp    $0x1,%edi
        83 d0 00                   adc    $0x0,%eax
      
      saving 3 bytes.  We should be able to save 5 bytes in larger functions
      where the mov is unnecessary.
      
      This patch converts the specific cmov pattern to cmp $1 followed by
      adc $0.
      
      This patch partially fixes:
      
      https://github.com/llvm/llvm-project/issues/60374
      
      The LLVM IR optimizer is yet to canonicalize max expressions to
      actual @llvm.umax.
      
      Differential Revision: https://reviews.llvm.org/D144451
      a21a7ddf
    • Simon Pilgrim's avatar
      [X86] Add Issue #61104 test case · 0e2b9672
      Simon Pilgrim authored
      Shows the failure of combineBitcastvxi1 to sign-extend a select(i1,vXi1,vXi1) pattern
      0e2b9672
    • Alex MacLean's avatar
      [docs][NewPM] fix typos in new pass manager docs · 8a5d4eb7
      Alex MacLean authored
      Fix some minor errors in the code-block sections of the new pass manager documentation
      
      Reviewed By: aeubanks
      
      Differential Revision: https://reviews.llvm.org/D145325
      8a5d4eb7
    • Fangrui Song's avatar
      [Driver] Reject -march= for ppc · 7370b9c8
      Fangrui Song authored
      Clang -march= for ppc triples currently leads to an
      -Wunused-command-line-argument warning but GCC rejects -march=.
      
          error: unrecognized command-line option ‘-march=xxx’
      
      Let's reject -march= as well similar to the Sparc change D130273.
      
      Close https://github.com/llvm/llvm-project/issues/57587
      
      Reviewed By: #powerpc, nemanjai
      
      Differential Revision: https://reviews.llvm.org/D145141
      7370b9c8
    • Arthur Eubanks's avatar
      [Pipeline] Adjust PostOrderFunctionAttrs placement in simplification pipeline · 0d4a709b
      Arthur Eubanks authored
      We can infer more attribute information once functions are fully
      simplified, so move the PostOrderFunctionAttrs pass after the function
      simplification pipeline. However, just doing this can impact
      simplification of recursive functions since function simplification
      takes advantage of function attributes of callees (some LLVM tests are
      actually impacted by this), so keep a copy of PostOrderFunctionAttrs
      before the function simplification pipeline that only runs on recursive
      functions.
      
      For example, this fixes the small regression noticed in https://reviews.llvm.org/D128830.
      
      This requires some restructuring of the CGSCC NoRerun feature. We need
      to cache the ShouldNotRunFunctionPassesAnalysis analysis after the
      simplification is done, which now is after the second
      PostOrderFunctionAttrs run, rather than after the function
      simplification pipeline.
      
      Compile time impact:
      https://llvm-compile-time-tracker.com/compare.php?from=33cf40122279342b50f92a3a53f5c185390b6018&to=1bb2a07875634e508a6bdf2ca1b130f55510f060&stat=instructions:u
      
      Compile time increase from unconditionally running the first PostOrderFunctionAttrs:
      https://llvm-compile-time-tracker.com/compare.php?from=1bb2a07875634e508a6bdf2ca1b130f55510f060&to=f4f87e89cc7a35c64e3a103a8036192a84ae002b&stat=instructions:u
      
      Reviewed By: nikic
      
      Differential Revision: https://reviews.llvm.org/D145210
      0d4a709b
    • Arthur Eubanks's avatar
      [SROA] Make order of analysis fetching more predictable · edd02136
      Arthur Eubanks authored
      For pipeline tests.
      edd02136
    • Dhruv Chawla's avatar
      [clang][alias|ifunc]: Add a diagnostic for mangled names · 9306ef97
      Dhruv Chawla authored
      When an alias or ifunc attribute refers to a function name that is
      mangled, a diagnostic is emitted to suggest the mangled name as a
      replacement for the given function name for every matching name in the
      current TU.
      
      Fixes #59164
      
      Differential Revision: https://reviews.llvm.org/D143803
      9306ef97
    • Valentin Clement's avatar
      [flang] Do not query type_desc for unlimited polymoprhic entities in move_alloc · 38c85a41
      Valentin Clement authored
      In D144997, the dynamic type of polymorphic entities is reset to the declared
      type when the FROM is deallocated. To do this, the declared type was passed as
      a fir.type_desc op. For unlimited polymorphic entities, this should just be a
      null pointer.
      
      Reviewed By: PeteSteinfeld
      
      Differential Revision: https://reviews.llvm.org/D145380
      38c85a41
    • Valentin Clement's avatar
      [flang] Avoid double cleanup when the result is cleaned up by the Destroy function · 30dc0379
      Valentin Clement authored
      The Destroy runtime function does free the memory so do not do it
      inlined when we use Destroy. This avoid a double free execution error.
      
      Reviewed By: PeteSteinfeld
      
      Differential Revision: https://reviews.llvm.org/D145372
      30dc0379
    • Nilay Vaish's avatar
      Checked that complexity of std::sort_heap is 2N log(N) comparisons · 1edc7238
      Nilay Vaish authored
      https://wg21.link/LWG2444 updated the comparison complexity of
      std:sort_heap to be at most 2N log (N) where N == last - first.  In the
      current implementation, we invoke __pop_heap exactly N-1 times.  In each
      call to __pop_heap, we first go down the heap from first to possibly
      last in the function __floyd_sift_down.  Then, we possibly go back up in
      the function __sift_up.
      
      In the function __floyd_sift_down, there is loop in which one comparison
      is made in each iteration.  The loop runs till __child becomes greater
      than (__len - 2) / 2.  __child starts at 0 and it is at least set to 2 *
      __child + 1 on each iteration.  Thus, after k iterations, __child will
      be at least 2^k - 1.  After log(N) iterations,  __child >= 2^(log(N)) -
      1 = N - 1 > (__len - 2) / 2.  This means that the while loop in the
      function __floyd_sift_down would perform at most log(N) comparisons on
      each invocation.
      
      In the function __sift_up, there is one comparison made that will almost
      always occur.  After that there is a do-while loop.  The comparison
      function is invoked once in each iteration.  In the worst case, the loop
      will run till __len goes down to zero.  It can start from (N-3)/2.  In
      each iteration, __len goes down to (__len-1) / 2.  After k iterations,
      __len will be at most (N - 2^(k+1) -1) / 2^(k+1).  Thus, __len will
      become  when (N-2^(k+1)-1) < 2^(k+1)  i.e. N  < 2^(k+2) + 1.  This means
      at most log(N) - 1 iterations for the loop.  So in total at most log(N)
        comparison will be performed in __sift_up.
      
      So overall for each iteration of the loop in __pop_heap, there will at
      most 2 log(N) comparisons.  So, the total number of comparisons is
      at most 2 N log(N).
      
      We also updated the test sort.heap/complexity.pass.cpp to test for the
      number of operations.
      
      Differential Revision: https://reviews.llvm.org/D144538
      1edc7238
    • Goran Flegar's avatar
      [bazel] Fix build after 28d04c56 · d866f87f
      Goran Flegar authored
      d866f87f
    • Chia-hung Duan's avatar
      [scudo] Temporarily disable GetRssFromBuffer test · 0bd4499b
      Chia-hung Duan authored
      This is a flaky test and may not test the thing it expected to verify.
      E.g., it doesn't dirty the pages so the memory usage may not be reflected
      on the RSS.
      
      Reviewed By: cferris
      
      Differential Revision: https://reviews.llvm.org/D145126
      0bd4499b
    • Chia-hung Duan's avatar
      [scudo] Mitigate page releasing thrashing · 436ea548
      Chia-hung Duan authored
      We have the heuristic to determine the threshold of doing page
      releasing for smaller size classes. However, in a case that the
      memory usage is bouncing between that threshold may result in
      frequent try of page releasing but not returning much memory.
      
      This CL add another heuristic to mitigate this problem by increasing
      the minimum pages that potentially can be released. Note that this
      heuristic is only applied on SizeClassAllocator64. SizeClassAllocator32
      has a smaller group size so the overhead is smaller than 64-bit
      platform.
      
      Differential Revision: https://reviews.llvm.org/D144768
      436ea548
    • Chia-hung Duan's avatar
      Reland D144920 "[scudo] Only prepare PageMap entry for partial region · 5b9d6097
      Chia-hung Duan authored
      This reverts commit daaef4c4.
      
      Differential Revision: https://reviews.llvm.org/D144920
      5b9d6097
    • Marco Elver's avatar
      [SelectionDAG] Optimize copyExtraInfo deep copy · bdb4353a
      Marco Elver authored
      It turns out that there are relatively trivial, albeit rare, cases that
      require a MaxDepth of more than 16 (see added test). However, we want to
      avoid having to rely on a large fixed MaxDepth.
      
      Since these cases are relatively rare, apply the following strategy:
      
        1. Start with a low MaxDepth of 16 - if the entry node was not
           reached, we can return (the common case).
      
        2. If the entry node was reached, exponentially increase MaxDepth up
           to some large limit that should cover all cases and guard against
           stack exhaustion.
      
      This retains the better performance with a low MaxDepth in the common
      case, and in complex cases backs off and retries. On a whole, this is
      preferable vs. starting with a large MaxDepth which would unnecessarily
      penalize the common case where a low MaxDepth is sufficient.
      
      Reviewed By: dvyukov
      
      Differential Revision: https://reviews.llvm.org/D145386
      bdb4353a
    • Jakub Kuderski's avatar
      [ADT] Clean up zip iterators. NFC. · e969c803
      Jakub Kuderski authored
      *  Use inheriting constructors declarations to avoid introducing the
         `Base` typedef and duplicate constructor definitions. This should make
         things cleaner, especially since `zip_common` also exposes a `Base`
         typedef.
      *  Drop unnecessary template parameters.
      *  Avoid double negation in `zip_shortest`'s `operator==` and rename the
         comparison function for better readability.
      
      Reviewed By: zero9178
      
      Differential Revision: https://reviews.llvm.org/D145332
      e969c803