1. Mar 26, 2022
    • Fangrui Song's avatar
      [Driver][Linux] Remove D.Dir+"/../lib" from default search paths for LLVM_ENABLE_RUNTIMES builds · afaefb67
      Fangrui Song authored
      The rule was added in 2014 to support -stdlib=libc++ and -lc++ without
      specifying -L, when D.Dir is not a well-known system library directory like
      /usr/lib /usr/lib64. This rule turns out to get in the way with (-m32 for
      64-bit clang) or (-m64 for 32-bit clang) for Gentoo :
      https://github.com/llvm/llvm-project/issues/54515
      
      Nowadays LLVM_ENABLE_RUNTIMES is the only recommended way building libc++ and
      LLVM_ENABLE_PROJECTS=libc++ is deprecated. LLVM_ENABLE_RUNTIMES builds libc++
      in D.Dir+"/../lib/${triple}/". The rule is unneeded. Also reverts D108286.
      
      Gentoo uses a modified LLVM_ENABLE_RUNTIMES that installs libc++.so in
      well-known paths like /usr/lib64 and /usr/lib which are already covered by
      nearby search paths.
      
      Implication: if a downstream package needs something like -lLLVM-15git and uses
      libLLVM-15git.so not in a well-known path, it needs to supply -L
      D.Dir+"/../lib" explicitly (e.g. via LLVMConfig.cmake), instead of relying on
      the previous default search path.
      
      Reviewed By: mgorny
      
      Differential Revision: https://reviews.llvm.org/D122444
      afaefb67
    • Johannes Doerfert's avatar
      Revert "[OpenMP][NFC] Add missing virtual destructor to silence warning" · 6c2be885
      Johannes Doerfert authored
      This reverts commit b9fd8f34 as it
      accidentally contained a unit test change that is not finished (and
      unrelated).
      6c2be885
    • Florian Hahn's avatar
      [Clang] Use pattern to match profile metadata in test. · bb9bdef4
      Florian Hahn authored
      Make the test more robust to slightly different metadata numbering by
      using a pattern instead of hard coding the ids.
      bb9bdef4
    • Johannes Doerfert's avatar
    • Johannes Doerfert's avatar
    • William S. Moses's avatar
      [Clang] Add helper method to determine if a nonvirtual base has an entry in the LLVM struct · 89525cbf
      William S. Moses authored
      This patch adds a helper method to determine if a nonvirtual base has an entry in the LLVM struct. Such a base may not have an entry
      if the base does not have any fields/bases itself that would change the size of the struct. This utility method is useful for other frontends (Polygeist) that use Clang as an API to generate code.
      
      Reviewed By: efriedma
      
      Differential Revision: https://reviews.llvm.org/D122502
      89525cbf
    • Paul Robinson's avatar
      Remove dead code in driver parsing -gsimple-template-names= options · 6aa03977
      Paul Robinson authored
      While -g[no-]simple-template-names is a driver option, the fancier
      -gsimple-template-names={simple,mangled} option is cc1-only, so code
      to handle it in the driver is dead.
      
      Differential Revision: https://reviews.llvm.org/D122503
      6aa03977
    • Peter Klausler's avatar
      [flang] Add & use a better visit() · 2ab9990c
      Peter Klausler authored
      Adds flang/include/flang/Common/visit.h, which defines
      a Fortran::common::visit() template function that is a drop-in
      replacement for std::visit().  Modifies most use sites in
      the front-end and runtime to use common::visit().
      
      The C++ standard mandates that std::visit() have O(1) execution
      time, which forces implementations to build dispatch tables.
      This new common::visit() is O(log2 N) in the number of alternatives
      in a variant<>, but that N tends to be small and so this change
      produces a fairly significant improvement in compiler build
      memory requirements, a 5-10% improvement in compiler build time,
      and a small improvement in compiler execution time.
      
      Building with -DFLANG_USE_STD_VISIT causes common::visit()
      to be an alias for std::visit().
      
      Calls to common::visit() with multiple variant arguments
      are referred to std::visit(), pending further work.
      
      Differential Revision: https://reviews.llvm.org/D122441
      2ab9990c
    • Hongtao Yu's avatar
      [PseudoProbe] Do not emit pseudo probes when module is not probed. · e25f4e4c
      Hongtao Yu authored
      There is a case when a function has pseudo probe intrinsics but the module it resides does not have the probe desc. This could happen when the current module is not built with `-fpseudo-probe-for-profiling` while a function in it calls some other function from a probed module. In thinLTO mode, the callee function could be imported and inlined into the current function.
      While this is undefined behavior, I'm fixing the asm printer to not ICE and warn user about this.
      
      Reviewed By: wenlei
      
      Differential Revision: https://reviews.llvm.org/D121737
      e25f4e4c
    • Emilio Cota's avatar
      [bazel] add missing targets since 3be7c289 · 0e1e3ccc
      Emilio Cota authored
      0e1e3ccc
    • Adrian Prantl's avatar
      1f98e09b
    • Martin Storsjö's avatar
      [clang-tidy] Fix the condition for building CTTestTidyModule · 9a3eeae3
      Martin Storsjö authored
      This is the correct intended condition; the problematic case where
      we don't want to try to build the plugin is "WIN32 AND LLVM_LINK_LLVM_DYLIB"
      and thus the negation is "NOT WIN32 OR NOT LLVM_LINK_LLVM_DYLIB".
      
      Differential Revision: https://reviews.llvm.org/D121687
      9a3eeae3
    • Sam McCall's avatar
      [cmake] Provide CURRENT_TOOLS_DIR centrally, replacing CLANG_TOOLS_DIR · 57ee624d
      Sam McCall authored
      CLANG_TOOLS_DIR holds the the current bin/ directory, maybe with a %(build_mode)
      placeholder. It is used to add the just-built binaries to $PATH for lit tests.
      In most cases it equals LLVM_TOOLS_DIR, which is used for the same purpose.
      But for a standalone build of clang, CLANG_TOOLS_DIR points at the build tree
      and LLVM_TOOLS_DIR points at the provided LLVM binaries.
      
      Currently CLANG_TOOLS_DIR is set in clang/test/, clang-tools-extra/test/, and
      other things always built with clang. This is a few cryptic lines of CMake in
      each place. Meanwhile LLVM_TOOLS_DIR is provided by configure_site_lit_cfg().
      
      This patch moves CLANG_TOOLS_DIR to configure_site_lit_cfg() and renames it:
       - there's nothing clang-specific about the value
       - it will also replace LLD_TOOLS_DIR, LLDB_TOOLS_DIR etc (not in this patch)
      
      It also defines CURRENT_LIBS_DIR. While I removed the last usage of
      CLANG_LIBS_DIR in e4cab4e2, there are LLD_LIBS_DIR usages etc tha...
      57ee624d
    • Chia-hung Duan's avatar
      [mlir] Add InferTensorType without supporting reifyReturnTypeShapes · dda003af
      Chia-hung Duan authored
      This is useful for the case that we don't need to implement
      reifyReturnTypeShapes.
      
      Reviewed By: jpienaar
      
      Differential Revision: https://reviews.llvm.org/D121403
      dda003af
    • Philip Reames's avatar
      [SLP] Simplify eraseInstruction [NFC] · f80aaa67
      Philip Reames authored
      This simplifies the implementation of eraseInstruction by moving the odd-replace-users-with-undef handling back to the only caller which uses it.  This handling was not obviously correct, so add the asserts which make it clear why this is safe to do at all.  The result is simpler code and stronger assertions.
      f80aaa67
    • LLVM GN Syncbot's avatar
      [gn build] Port cef52105 · a78bd832
      LLVM GN Syncbot authored
      a78bd832
    • Douglas Yung's avatar
      Revert "[clang-tidy] Add modernize-macro-to-enum check" · cef52105
      Douglas Yung authored
      This reverts commit 39b80c83.
      
      This change was causing build failures on several build bots:
      - https://lab.llvm.org/buildbot/#/builders/139/builds/19210
      - https://lab.llvm.org/buildbot/#/builders/93/builds/7956
      cef52105
    • Corentin Jabot's avatar
      [Clang] Fix error in Documentation introduced by 3784e8cc [nfc]. · 26e201b7
      Corentin Jabot authored
      The documentation contained extra space.
      Also remove https://github.com/llvm/llvm-project/issues/54296
      from the list of issues by 3784e8cc as this commit did not
      fix it (nor was it supposed to).
      26e201b7
    • Peter Klausler's avatar
      [flang] Fix bogus error from assignment to CLASS(*) · 0363a164
      Peter Klausler authored
      Assignment semantics was coughing up bad errors and crashes for
      intrinsic assignments to unlimited polymorphic entities while
      looking for any (impossible) user defined ASSIGNMENT(=) generic
      or intrinsic type conversion.
      
      Differential Revision: https://reviews.llvm.org/D122440
      0363a164
    • Corentin Jabot's avatar
      [Clang] Fix Unevaluated Lambdas · 3784e8cc
      Corentin Jabot authored
      Unlike other types, when lambdas are instanciated,
      they are recreated from scratch.
      When an unevaluated lambdas appear in the type of a function,
      parameter it is instanciated in the wrong declaration context,
      as parameters are transformed before the function.
      
      To support lambda in function parameters, we try to
      compute whether they are dependant without looking at the
      declaration context.
      
      This is a short term stopgap solution to avoid clang
      iceing. A better fix might be to inject some kind of
      transparent declaration with correctly computed dependency
      for function parameters, variable templates, etc.
      
      Fixes https://github.com/llvm/llvm-project/issues/50376
      Fixes https://github.com/llvm/llvm-project/issues/51414
      Fixes https://github.com/llvm/llvm-project/issues/51416
      Fixes https://github.com/llvm/llvm-project/issues/51641
      Fixes https://github.com/llvm/llvm-project/issues/54296
      
      Reviewed By: aaron.ballman
      
      Differential Revision: https://reviews.llvm.org/D121532
      3784e8cc
    • Florian Hahn's avatar
      [Clang,TBAA] Use pattern for metadata reference in test. · 171cdba8
      Florian Hahn authored
      Update the single check line that still had a hard-coded metadata
      reference. This makes it more robust to slight changes in the metadata
      numbering.
      171cdba8
    • Florian Hahn's avatar
      [ConstraintElimination] Use AddOverflow for offset summation. · 8c3281db
      Florian Hahn authored
      Fixes an incorrect transformation due to values overflowing
      https://alive2.llvm.org/ce/z/uizoea
      8c3281db
    • Florian Hahn's avatar
    • Emil Kieri's avatar
      [clang][driver] Disable non-functional --version option for clang -cc1 · 35b89bc2
      Emil Kieri authored
      This patch removes --version as a clang -cc1 option.
        clang --version
      and
        clang --cc1 -version
      remain valid. This behaviour is consistent with clang -cc1as.
      
      Previously, clang -cc1 accepted both --version and -version, but
      only -version was acted upon. The call
        clang -cc1 --version
      stalled without any message: --version was an accepted option but
      triggered no action, and the driver waited for standard input.
      
      Reviewed By: thakis
      
      Differential Revision: https://reviews.llvm.org/D122344
      35b89bc2
    • Nathan James's avatar
      Reland "[ASTMatchers] Output currently processing match and nodes on crash" · b97f2608
      Nathan James authored
      This reverts commit cff34ccb.
      
      This relands commit d89f9e96
      b97f2608
    • Philip Reames's avatar
      Reapply "[SLP] Schedule only sub-graph of vectorizable instructions"" (try 3) · 48cc9287
      Philip Reames authored
      The original commit exposed several missing dependencies (e.g. latent bugs in SLP scheduling).  Most of these were fixed over the weekend and have had several days to bake.  The last was fixed this morning after being noticed in manual review of test changes yesterday.  See the review thread for links to each change.
      
      Original commit message follows:
      
      SLP currently schedules all instructions within a scheduling window which stretches from the first instruction potentially vectorized to the last. This window can include a very large number of unrelated instructions which are not being considered for vectorization. This change switches the code to only schedule the sub-graph consisting of the instructions being vectorized and their transitive users.
      
      This has the effect of greatly reducing the amount of work performed in large basic blocks, and thus greatly improves compile time on degenerate examples. To understand the effects, I added some statistics (not planned for upstream contribution). Here's an illustration from my motivating example:
      
         Before this patch:
      
         704357 SLP                          - Number of calcDeps actions
         699021 SLP                          - Number of schedule calls
         5598 SLP                          - Number of ReSchedule actions
         59 SLP                          - Number of ReScheduleOnFail actions
         10084 SLP                          - Number of schedule resets
         8523 SLP                          - Number of vector instructions generated
      
         After this patch:
      
         102895 SLP                          - Number of calcDeps actions
         161916 SLP                          - Number of schedule calls
         5637 SLP                          - Number of ReSchedule actions
         55 SLP                          - Number of ReScheduleOnFail actions
         10083 SLP                          - Number of schedule resets
         8403 SLP                          - Number of vector instructions generated
      
      I do want to highlight that there is a small difference in number of generated vector instructions. This example is hitting the bailout due to maximum window size, and the change in scheduling is slightly perturbing when and how we hit it. This can be seen in the RescheduleOnFail counter change. Given that, I think we can safely ignore.
      
      The downside of this change can be seen in the large test diff. We group all vectorizable instructions together at the bottom of the scheduling region. This means that vector instructions can move quite far from their original point in code. While maybe undesirable, I don't see this as being a major problem as this pass is not intended to be a general scheduling pass.
      
      For context, it's worth noting that the pre-scheduling that SLP does while building the vector tree is exactly the sub-graph scheduling implemented by this patch.
      
      Differential Revision: https://reviews.llvm.org/D118538
      48cc9287
    • Christopher Bate's avatar
      [mlir][NVVM] Add support for nvvm mma.sync ops · 3be7c289
      Christopher Bate authored
      This patch adds MLIR NVVM support for the various NVPTX `mma.sync`
      operations. There are a number of possible data type, shape,
      and other attribute combinations supported by the operation, so a
      custom assebmly format is added and attributes are inferred where
      possible.
      
      Reviewed By: ThomasRaoux
      
      Differential Revision: https://reviews.llvm.org/D122410
      3be7c289
    • Jean Perier's avatar
      [flang][lowering] Handle zero extent case in LBOUND · 5bc9ee1b
      Jean Perier authored
      Follow up of https://reviews.llvm.org/D121488. Ensure lower bounds
      are `1` when the related dimension extent is zero. Note that lower
      bounds from descriptors are now guaranteed to fulfill this property
      after the runtime/codegen patches.
      
      Also fixes explicit shape array extent lowering when instantiating
      variables to deal with negative extent cases (issue found while testing
      LBOUND edge case). This notably caused allocation crashes when dealing
      with automatic arrays with reversed bounds or negative size
      specification expression. The standard specifies that the extent of such
      arrays is zero. This change has some ripple effect in the current lit
      tests.
      
      Add move two helpers as part of this change:
      - Add a helper to tell if a fir::ExtendedValue describes an assumed size
        array (last dimension extent is unknown to the compiler, both at compile
        time and runtime).
      
      - Move and share getIntIfConstant from Character.cpp so that it can be
        used elsewhere (NFC).
      
      Differential Revision: https://reviews.llvm.org/D122467
      5bc9ee1b
    • Philip Reames's avatar
      [SLP] Optimize stacksave dependence handling [NFC] · ec858f02
      Philip Reames authored
      After writing the commit message for 4b1bace28, realized that the mentioned optimization was rather straight forward.  We already have the code for scanning a block during region initialization, we can simply keep track if we've seen a stacksave or stackrestore.  If we haven't, none of these dependencies are relevant and we can avoid the relatively expensive scans entirely.
      ec858f02
    • Philip Reames's avatar
      [SLP] Explicit track required stacksave/alloca dependency (try 3) · a16308c2
      Philip Reames authored
      This is an extension of commit b7806c to handle one last case noticed in test changes for D118538.  Again, this is thought to be a latent bug in the existing code, though this time I have not managed to reduce tests for the original algoritthm.
      
      The prior attempt had failed to account for this case:
        %a = alloca i8
        stacksave
        stackrestore
        store i8 0, i8* %a
      
      If we allow '%a' to reorder into the stacksave/restore region, then the alloca will be deallocated before the use.  We will have taken a well defined program, and introduced a use-after-free bug.
      
      There's also an inverse case where the alloca originally follows the stackrestore, and we need to prevent the reordering it above the restore.
      
      Compile time wise, we potentially do an extra scan of the block for each alloca seen in a bundle.  This is significantly more expensive than the stacksave rooted version and is why I'd tried to avoid this in the initial patch.  There is room to optimize this (by essentially caching a "has stacksave" bit per block), but I'm leaving that to future work if it actually shows up in practice.  Since allocas in bundles should be rare in practice, I suspect we can defer the complexity for a long while.
      a16308c2
    • Gulfem Savrun Yeniceri's avatar
      [InstrProfiling] No runtime hook for unused funcs · c7f91e22
      Gulfem Savrun Yeniceri authored
      CoverageMappingModuleGen generates a coverage mapping record
      even for unused functions with internal linkage, e.g.
      static int foo() { return 100; }
      Clang frontend eliminates such functions, but InstrProfiling pass
      still pulls in profile runtime since there is a coverage record.
      Fuchsia uses runtime counter relocation, and pulling in profile
      runtime for unused functions causes a linker error:
      undefined hidden symbol: __llvm_profile_counter_bias.
      Since 389dc94d, we do not hook profile runtime for the binaries
      that none of its translation units have been instrumented in Fuchsia.
      This patch extends that for the instrumented binaries that
      consist of only unused functions.
      
      Differential Revision: https://reviews.llvm.org/D122336
      c7f91e22
    • Argyrios Kyrtzidis's avatar
      [Support/BLAKE3] Do manual instrumentation of `llvm_blake3_hasher_finalize` for memory sanitizer · b867f5c7
      Argyrios Kyrtzidis authored
      This is to avoid false positives when using the uninstrumented assembly code implementation.
      b867f5c7
    • Florian Hahn's avatar
      [LV] Use getVectorLoopRegion to retrieve header. (NFC) · e47d2202
      Florian Hahn authored
      Update all places that currently assume the entry block to the plan is
      also the vector loop header to use getVectorLoopRegion instead.
      
      getVectorLoopRegion will keep doing the right thing when the pre-header
      is modeled explicitly (and becomes the new entry block in the plan).
      e47d2202
    • Jonas Devlieghere's avatar
      [lldb] Conditionalize target_link_libraries on the target · 8f7db763
      Jonas Devlieghere authored
      Fixes "Cannot specify link libraries for target "lldb-target-fuzzer"
      which is not built by this project." Normally that's taken care of by
      add_llvm_fuzzer but we need target_link_libraries for liblldb and our
      utility library.
      8f7db763
    • lipracer's avatar
      [mlir][tosa] : adding folder and canonicalizer for select · 5161835d
      lipracer authored
      define canonicalizer and folder for tosa::select
      
      Reviewed By: mehdi_amini, Mogball
      
      Differential Revision: https://reviews.llvm.org/D121513
      5161835d
    • Peter Klausler's avatar
      [flang] Fix cycle-catcher in procedure characterization · 174cabed
      Peter Klausler authored
      The "seenProcs" sets passed as arguments to the procedure and dummy
      procedure characterization routines need to be passed by value so that
      local updates to those sets do not become permanent.  They are
      presently passed by reference and that has led to bogus errors about
      recursively defined procedures in testing.
      
      (It might be faster to pass the sets by reference and undo those local
      updates in these functions, but that's error-prone, and the performance
      difference is not expected to be detectable in practice.)
      
      Differential Revision: https://reviews.llvm.org/D122439
      174cabed
    • Yitzhak Mandelbaum's avatar
      [clang][dataflow] Add support for disabling warnings on smart pointers. · a184a0d8
      Yitzhak Mandelbaum authored
      This patch provides the user with the ability to disable all checked of accesses
      to optionals that are the pointees of smart pointers. Since smart pointers are
      not modeled (yet), the system cannot distinguish safe from unsafe accesses to
      optionals through smart pointers. This results in false positives whenever
      optionals are used through smart pointers. The patch gives the user the choice
      of ignoring all positivess in these cases.
      
      Differential Revision: https://reviews.llvm.org/D122143
      a184a0d8
    • Johannes Doerfert's avatar
      [OpenMP][FIX] Ensure exclusive access to the HDTT map · 4e34f061
      Johannes Doerfert authored
      This patch solves two problems with the `HostDataToTargetMap` (HDTT
      map) which caused races and crashes before:
      
      1) Any access to the HDTT map needs to be exclusive access. This was not
         the case for the "dump table" traversals that could collide with
         updates by other threads. The new `Accessor` and `ProtectedObject`
         wrappers will ensure we have a hard time introducing similar races in
         the future. Note that we could allow multiple concurrent
         read-accesses but that feature can be added to the `Accessor` API
         later.
      2) The elements of the HDTT map were `HostDataToTargetTy` objects which
         meant that they could be copied/moved/deleted as the map was changed.
         However, we sometimes kept pointers to these elements around after we
         gave up the map lock which caused potential races again. The new
         indirection through `HostDataToTargetMapKeyTy` will allows us to
         modify the map while keeping the (interesting part of the) entries
         val...
      4e34f061
    • Jonas Devlieghere's avatar
      [lldb] Add a fuzzer for target creation · 61efe14e
      Jonas Devlieghere authored
      This patch adds a generic fuzzer that interprets inputs as object files
      and uses them to create a target in lldb. It is very similar to the
      llvm-dwarfdump fuzzer which found a bunch of issues in libObject.
      
      Differential revision: https://reviews.llvm.org/D122461
      61efe14e
    • Tue Ly's avatar
      [libc] Improve the performance of expf. · 6168b422
      Tue Ly authored
      Reduce the polynomial's degree from 7 down to 4.
      
      Currently we use a degree-7 minimax polynomial on an interval of length 2^-7
      around 0 to compute `expf`. Based on the suggestion of @santoshn and the RLIBM
      project (https://github.com/rutgers-apl/rlibm-all/blob/main/source/float/exp.c)
      and the improvement we made with `exp2f` in https://reviews.llvm.org/D122346,
      it is possible to have a good polynomial of degree-4 on a subinterval of length
      2^(-7) to approximate e^x.
      
      We did try to either reduce the degree of the polynomial down to 3 or increase
      the interval size to 2^(-6), but in both cases the number of exceptional values
      exploded. So we settle with using a degree-4 polynomial of the interval of
      size 2^(-7) around 0.
      
      Reviewed By: sivachandra, zimmermann6, santoshn
      
      Differential Revision: https://reviews.llvm.org/D122418
      6168b422