1. Oct 12, 2021
    • Sjoerd Meijer's avatar
      [FuncSpec] Allow ConstExprs that are function pointers · fc0fa851
      Sjoerd Meijer authored
      This is a follow up of D110529 that disallowed constexprs. That change
      introduced a regression as this also disallowed constexprs that are function
      pointers, which is actually one of the motivating use cases that we do want to
      support.
      
      Differential Revision: https://reviews.llvm.org/D111567
      fc0fa851
    • Florian Hahn's avatar
      [LoopPeel] Peel if it turns invariant loads dereferenceable. · cd0ba9dc
      Florian Hahn authored
      This patch adds a new cost heuristic that allows peeling a single
      iteration off read-only loops, if the loop contains a load that
      
          1. is feeding an exit condition,
          2. dominates the latch,
          3. is not already known to be dereferenceable,
          4. and has a loop invariant address.
      
      If all non-latch exits are terminated with unreachable, such loads
      in the loop are guaranteed to be dereferenceable after peeling,
      enabling hoisting/CSE'ing them.
      
      This enables vectorization of loops with certain runtime-checks, like
      multiple calls to `std::vector::at` if the vector is passed as pointer.
      
      Reviewed By: mkazantsev
      
      Differential Revision: https://reviews.llvm.org/D108114
      cd0ba9dc
    • Jan Svoboda's avatar
      [clang][deps] Prune unused header search paths · 6a1f50b8
      Jan Svoboda authored
      To reduce the number of explicit builds of a single module, we can try to squash multiple occurrences of the module with different command-lines (and context hashes) by removing benign command-line options. The greatest contributors to benign differences between command-lines are the header search paths.
      
      In this patch, the lookup cache in `HeaderSearch` is used to identify paths that were actually used when implicitly building the module during scanning. This information is serialized into the unhashed control block of the implicitly-built PCM. The dependency scanner then loads this and may use it to prune the header search paths before computing the context hash of the module and generating the command-line.
      
      We could also prune the header search paths when serializing `HeaderSearchOptions` into the PCM. That way, we could do it only once instead of every load of the PCM file by dependency scanner. However, that would result in a PCM file whose contents don't produce the same context hash as the original build, which is probably highly surprising.
      
      There is an alternative approach to storing extra information into the PCM: wire up preprocessor callbacks to capture the used header search paths on-the-fly during preprocessing of modularized headers (similar to what we currently do for the main source file and textual headers). Right now, that's not compatible with the fact that we do an actual implicit build producing PCM files during dependency scanning. The second run of dependency scanner loads the PCM from the first run, skipping the preprocessing altogether, which would result in different results between runs. We can revisit this approach when we stop building implicitly during dependency scanning.
      
      Depends on D102923.
      
      Reviewed By: dexonsmith
      
      Differential Revision: https://reviews.llvm.org/D102488
      6a1f50b8
    • Nico Weber's avatar
      [gn build] (manually) port f4c1258d · e19bbd0f
      Nico Weber authored
      e19bbd0f
    • Vladislav Vinogradov's avatar
      [mlir] Allow to use vformat utility with MLIR classes · d6296c3b
      Vladislav Vinogradov authored
      Make `raw_ostream operator<<` follow const correctness semantic,
      since it is a requirement of FormatVariadic implementation.
      
      Reviewed By: rriddle
      
      Differential Revision: https://reviews.llvm.org/D111547
      d6296c3b
    • jacquesguan's avatar
      [RISCV][Clang] Fix RISCV vector header comment. · 477f5f4f
      jacquesguan authored
      Reviewed By: khchen
      
      Differential Revision: https://reviews.llvm.org/D111597
      477f5f4f
    • Jan Svoboda's avatar
      [clang][lex] Remark on search path usage · 44451351
      Jan Svoboda authored
      For dependency scanning, it would be useful to collect header search paths (provided on command-line via `-I` and friends) that were actually used during preprocessing. This patch adds that feature to `HeaderSearch` along with a new remark that reports such paths as they get used.
      
      Previous version of this patch tried to use the existing `LookupFileCache` to report used paths via `HitIdx`. That doesn't work for `ComputeUserEntryUsage` (which is intended to be called *after* preprocessing), because it indexes used search paths by the file name. This means the values get overwritten when the code contains `#include_next`.
      
      Note that `HeaderSearch` doesn't use `HeaderSearchOptions::UserEntries` directly. Instead, `InitHeaderSearch` pre-processes them (adds platform-specific paths, removes duplicates, removes paths that don't exist) and creates `DirectoryLookup` instances. This means we need a mechanism for translating between those two. It's not possible to go from `DirectoryLookup` back to the original `HeaderSearch`, so `InitHeaderSearch` now tracks the relationships explicitly.
      
      Depends on D111557.
      
      Reviewed By: dexonsmith
      
      Differential Revision: https://reviews.llvm.org/D102923
      44451351
    • Louis Dionne's avatar
      [libc++] Add an option to disable wide character support in libc++ · f4c1258d
      Louis Dionne authored
      Some embedded platforms do not wish to support the C library functionality
      for handling wchar_t because they have no use for it. It makes sense for
      libc++ to work properly on those platforms, so this commit adds a carve-out
      of functionality for wchar_t.
      
      Unfortunately, unlike some other carve-outs (e.g. random device), this
      patch touches several parts of the library. However, despite the wide
      impact of this patch, I still think it is important to support this
      configuration since it makes it much simpler to port libc++ to some
      embedded platforms.
      
      Differential Revision: https://reviews.llvm.org/D111265
      f4c1258d
    • Caitlyn Cano's avatar
      [mlir] Make ConversionTarget dynamic legality callbacks composable · c6828e0c
      Caitlyn Cano authored
      * Change callback signature `bool(Operation *)` -> `Optional<bool>(Operation *)`
      * addDynamicallyLegalOp add callback to the chain
      * If callback returned empty `Optional` next callback in chain will be called
      
      Differential Revision: https://reviews.llvm.org/D110487
      c6828e0c
    • Andrew Ng's avatar
    • Sven van Haastregt's avatar
      [OpenCL] Add atomic_half type builtins · 544d89e8
      Sven van Haastregt authored
      Add atomic_half types and builtins operating on the types from the
      cl_ext_float_atomics extension.
      
      Patch by Haonan Yang.
      
      Differential Revision: https://reviews.llvm.org/D109740
      544d89e8
    • Nimish Mishra's avatar
      [flang][OpenMP] Added test case for OpenMP 5.0 specification based semantic... · d4717b9b
      Nimish Mishra authored
      [flang][OpenMP] Added test case for OpenMP 5.0 specification based semantic checks for parallel sections construct
      
      Parallel sections directive borrows the semantic checks from both sections directive and parallel directive. Semantic checks for both are merged in main branch; this test case is added to make sure correct semantic checks upon merging the two.
      
      Reviewed By: kiranchandramohan
      
      Differential Revision: https://reviews.llvm.org/D111438
      d4717b9b
    • Vladislav Vinogradov's avatar
      [mlir] Fix AsmPrinter for types with sub elements · c6390f19
      Vladislav Vinogradov authored
      Call `printType(subElemType)` instead of `os << subElemType` for them.
      It allows to handle type aliases inside complex types.
      
      As a side effect, fixed `test.int` parsing.
      
      Reviewed By: rriddle
      
      Differential Revision: https://reviews.llvm.org/D111536
      c6390f19
    • Vladislav Vinogradov's avatar
      [mlir] Clean up boolean flags usage in LIT tests · 505afd1e
      Vladislav Vinogradov authored
      * Call `llvm_canonicalize_cmake_booleans` for all CMake options,
        which are propagated to `lit.local.cfg` files.
      * Use Python native boolean values instead of strings for such options.
      
      This fixes the cases, when CMake variables have values other than `ON` (like `TRUE`).
      This might happen due to IDE integration or due to CMake preset usage.
      
      Reviewed By: ftynse
      
      Differential Revision: https://reviews.llvm.org/D110073
      505afd1e
    • Roger Ferrer Ibanez's avatar
      [SelectionDAG] Fix typo in VPLoadStoreSDNode · e2d5a380
      Roger Ferrer Ibanez authored
      There is no code that uses this base class yet, hence the typo went
      unnoticed when this class was added in D105871
      
      Differential Revision: https://reviews.llvm.org/D110930
      e2d5a380
    • Diana Picus's avatar
      [flang] Add runtime interface for GET_ENVIRONMENT_VARIABLE · 02602c02
      Diana Picus authored
      Split into 2 entry points, one for the length and one for the value.
      
      Differential Revision: https://reviews.llvm.org/D111392
      02602c02
    • Qiu Chaofan's avatar
      Pre-commit pre-inc-disable.ll to avoid dead code · 1f253e4f
      Qiu Chaofan authored
      The case was added in 728e1397, testing it outputs lxsibzx instead of
      lbzux. Here we need some minimal update to avoid DCE in future patches.
      1f253e4f
    • Jan Svoboda's avatar
      [clang][modules] Default `SourceLocation` parameter in `HeaderSearch::lookupModule` · 1341a2c1
      Jan Svoboda authored
      This fixes an LLDB build failure where the `ImportLoc` argument is missing: https://lab.llvm.org/buildbot#builders/68/builds/19975
      
      This change also makes it possible to drop `SourceLocation()` in `Preprocessor::getCurrentModule`.
      1341a2c1
    • Victor Campos's avatar
      [docs] List support for Armv9-A, Armv9.1-A and Armv9.2-A in LLVM and Clang · 3e7cf33a
      Victor Campos authored
      Reviewed By: pratlucas
      
      Differential Revision: https://reviews.llvm.org/D110241
      3e7cf33a
    • Jan Svoboda's avatar
      [clang][modules] NFC: Propagate import `SourceLocation` into `HeaderSearch::lookupModule` · 638c673a
      Jan Svoboda authored
      This patch propagates the import `SourceLocation` into `HeaderSearch::lookupModule`. This enables remarks on search path usage (implemented in D102923) to point to the source code that initiated header search.
      
      Reviewed By: dexonsmith
      
      Differential Revision: https://reviews.llvm.org/D111557
      638c673a
    • Valentin Clement's avatar
      [fir][NFC] Add two negative tests for needExternalNameMangling · 5371968e
      Valentin Clement authored
      Add two test for needExternalNameMangling.
      - One varibale in a function
      - One namelist in a module
      
      This patch is part of the upstreaming effort from fir-dev branch.
      
      Reviewed By: schweitz
      
      Differential Revision: https://reviews.llvm.org/D111544
      5371968e
    • jacquesguan's avatar
      [RISCV] Rename assembler mnemonic of unordered floating-point reductions for v1.0-rc change · 0608bbd4
      jacquesguan authored
      Rename vfredsum and vfwredsum to vfredusum and vfwredusum. Add aliases for vfredsum and vfwredsum.
      
      Reviewed By: luismarques, HsiangKai, khchen, frasercrmck, kito-cheng, craig.topper
      
      Differential Revision: https://reviews.llvm.org/D105690
      0608bbd4
    • Lang Hames's avatar
      [ORC] More attempts to work around compiler failures. · 5829ba7a
      Lang Hames authored
      Commit 731f991c seems to have helped, but did not catch all instances (see
      https://lab.llvm.org/buildbot/#/builders/193/builds/104). Switch more inner
      structs to C++98 initializers to work around the issue. Add FIXMEs to revisit
      in the future.
      5829ba7a
    • Lang Hames's avatar
      [ORC] Attempt to work around compile failure on some bots. · 731f991c
      Lang Hames authored
      See e.g. https://lab.llvm.org/buildbot/#/builders/193/builds/98.
      
      I think this failure is related to a C++ standard defect, 1397 --"Class
      completeness in non-static data member initializers" [1]. If so, moving
      to C++98 initialization should work around the issue.
      
      [1] http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1397
      731f991c
    • Yonghong Song's avatar
      [Clang][Attr] rename btf_tag to btf_decl_tag · a162b67c
      Yonghong Song authored
      Current btf_tag is applied to declaration only.
      Per discussion in https://reviews.llvm.org/D111199,
      we plan to introduce btf_type_tag attribute for types.
      So rename btf_tag to btf_decl_tag to make it easily
      differentiable from btf_type_tag.
      
      Differential Revision: https://reviews.llvm.org/D111588
      a162b67c
    • modimo's avatar
      [NFC][LangRef] Update description for FuncFlags · ef643617
      modimo authored
      Add the additional flags from D36850 as well as noInline/alwaysInline from previous changes.
      
      Reviewed By: tejohnson
      
      Differential Revision: https://reviews.llvm.org/D111600
      ef643617
    • Lang Hames's avatar
      [ORC] Add more explicit narrowing casts. · 3a52a639
      Lang Hames authored
      This should fix the buildbot failure at
      https://lab.llvm.org/buildbot/#/builders/187/builds/2140
      3a52a639
    • LLVM GN Syncbot's avatar
      [gn build] Port 962a2479 · db832d46
      LLVM GN Syncbot authored
      db832d46
    • Lang Hames's avatar
      [ORC] Fix a typo in a variable name. · 9ca50641
      Lang Hames authored
      9ca50641
    • Lang Hames's avatar
      Re-apply e50aea58, "Major JITLinkMemoryManager refactor". with fixes. · 962a2479
      Lang Hames authored
      Adds explicit narrowing casts to JITLinkMemoryManager.cpp.
      
      Honors -slab-address option in llvm-jitlink.cpp, which was accidentally
      dropped in the refactor.
      
      This effectively reverts commit 6641d29b.
      962a2479
    • hsmahesha's avatar
      [CFE][Codegen] Remove CodeGenFunction::InitTempAlloca() · db9c2d77
      hsmahesha authored
      Sequel patch to https://reviews.llvm.org/D111316
      
      Finally, remove the defintion of CodeGenFunction::InitTempAlloca().
      
      Reviewed By: rjmccall
      
      Differential Revision: https://reviews.llvm.org/D111324
      db9c2d77
    • Yonghong Song's avatar
      BPF: rename BTF_KIND_TAG to BTF_KIND_DECL_TAG · 1321e472
      Yonghong Song authored
      Per discussion in https://reviews.llvm.org/D111199,
      the existing btf_tag attribute will be renamed to
      btf_decl_tag. This patch updated BTF backend to
      use btf_decl_tag attribute name and also
      renamed BTF_KIND_TAG to BTF_KIND_DECL_TAG.
      
      Differential Revision: https://reviews.llvm.org/D111592
      1321e472
    • hsmahesha's avatar
      [CFE][Codegen][In-progress] Remove CodeGenFunction::InitTempAlloca() · f7de6962
      hsmahesha authored
      Sequel patch to https://reviews.llvm.org/D111293.
      
      Remove call to CodeGenFunction::InitTempAlloca() from OpenMP related
      codegen part.
      
      Also remove the metadata `!llvm.access.group` from the updated lit
      tests.
      
      Reviewed By: rjmccall
      
      Differential Revision: https://reviews.llvm.org/D111316
      f7de6962
    • hsmahesha's avatar
      [AMDGPU] Remove dead frame indices after sgpr spill. · 52cb3af0
      hsmahesha authored
      All those frame indices which are dead after sgpr spill should be removed from
      the function frame. Othewise, there is a side effect such as re-mapping of free
      frame index ids by the later pass(es) like "stack slot coloring" which in turn
      could mess-up with the book keeping of "frame index to VGPR lane".
      
      Reviewed By: cdevadas
      
      Differential Revision: https://reviews.llvm.org/D111150
      52cb3af0
    • Yonghong Song's avatar
      [NFC][Attr] rename attribute btf_tag to btf_decl_tag · 325d0007
      Yonghong Song authored
      Per discussion in https://reviews.llvm.org/D111199,
      the existing btf_tag attribute will be renamed to
      btf_decl_tag. This patch mostly updated the Bitcode and
      DebugInfo test cases with new attribute name.
      
      Differential Revision: https://reviews.llvm.org/D111591
      325d0007
    • Lang Hames's avatar
      [llvm-jitlink] Fix a broken warning. · b7c1ccd4
      Lang Hames authored
      This warning should only be issued if -slab-page-size has not been used.
      b7c1ccd4
    • Freddy Ye's avatar
      [X86][ISel] Lowering llvm.thread.pointer · d57a87ea
      Freddy Ye authored
      Reviewed By: pengfei
      
      Differential Revision: https://reviews.llvm.org/D110681
      d57a87ea
    • Hsiangkai Wang's avatar
      [RISCV] Define _m intrinsics as builtins, instead of macros. · 97f0c637
      Hsiangkai Wang authored
      In the original design, we levarage _mt intrinsics to define macros for
      _m intrinsics. Such as,
      
      ```
      __builtin_rvv_vadd_vv_i8m1_mt((vbool8_t)(op0), (vint8m1_t)(op1), (vint8m1_t)(op2), (vint8m1_t)(op3), (size_t)(op4), (size_t)VE_TAIL_AGNOSTIC)
      ```
      
      However, we could not define generic interface for mask intrinsics any
      more due to clang_builtin_alias only accepts clang builtins as its
      argument.
      
      In the example,
      
      ```
       __rvv_overloaded
       __attribute__((clang_builtin_alias(__builtin_rvv_vadd_vv_i8m1_mt)))
        vint8m1_t vadd(vbool8_t op0, vint8m1_t op1, vint8m1_t op2, vint8m1_t
        op3, size_t op4, size_t op5);
      ```
      
      op5 is the tail policy argument. When users want to use vadd generic
      interface for masked vector add, they need to specify tail policy in the
      previous design. In this patch, we define _m intrinsics as clang
      builtins to solve the problem.
      
      Differential Revision: https://reviews.llvm.org/D110684
      97f0c637
    • Lang Hames's avatar
      Revert "[JITLink][ORC] Major JITLinkMemoryManager refactor." · 6641d29b
      Lang Hames authored
      This reverts commit e50aea58 while I
      investigate bot failures.
      6641d29b
    • Lang Hames's avatar
      [JITLink][ORC] Major JITLinkMemoryManager refactor. · e50aea58
      Lang Hames authored
      This commit substantially refactors the JITLinkMemoryManager API to: (1) add
      asynchronous versions of key operations, (2) give memory manager implementations
      full control over link graph address layout, (3) enable more efficient tracking
      of allocated memory, and (4) support "allocation actions" and finalize-lifetime
      memory.
      
      Together these changes provide a more usable API, and enable more powerful and
      efficient memory manager implementations.
      
      To support these changes the JITLinkMemoryManager::Allocation inner class has
      been split into two new classes: InFlightAllocation, and FinalizedAllocation.
      The allocate method returns an InFlightAllocation that tracks memory (both
      working and executor memory) prior to finalization. The finalize method returns
      a FinalizedAllocation object, and the InFlightAllocation is discarded. Breaking
      Allocation into InFlightAllocation and FinalizedAllocation allows
      InFlightAllocation subclassses to be written more naturally, and FinalizedAlloc
      to be implemented and used efficiently (see (3) below).
      
      In addition to the memory manager changes this commit also introduces a new
      MemProt type to represent memory protections (MemProt replaces use of
      sys::Memory::ProtectionFlags in JITLink), and a new MemDeallocPolicy type that
      can be used to indicate when a section should be deallocated (see (4) below).
      
      Plugin/pass writers who were using sys::Memory::ProtectionFlags will have to
      switch to MemProt -- this should be straightworward. Clients with out-of-tree
      memory managers will need to update their implementations. Clients using
      in-tree memory managers should mostly be able to ignore it.
      
      Major features:
      
      (1) More asynchrony:
      
      The allocate and deallocate methods are now asynchronous by default, with
      synchronous convenience wrappers supplied. The asynchronous versions allow
      clients (including JITLink) to request and deallocate memory without blocking.
      
      (2) Improved control over graph address layout:
      
      Instead of a SegmentRequestMap, JITLinkMemoryManager::allocate now takes a
      reference to the LinkGraph to be allocated. The memory manager is responsible
      for calculating the memory requirements for the graph, and laying out the graph
      (setting working and executor memory addresses) within the allocated memory.
      This gives memory managers full control over JIT'd memory layout. For clients
      that don't need or want this degree of control the new "BasicLayout" utility can
      be used to get a segment-based view of the graph, similar to the one provided by
      SegmentRequestMap. Once segment addresses are assigned the BasicLayout::apply
      method can be used to automatically lay out the graph.
      
      (3) Efficient tracking of allocated memory.
      
      The FinalizedAlloc type is a wrapper for an ExecutorAddr and requires only
      64-bits to store in the controller. The meaning of the address held by the
      FinalizedAlloc is left up to the memory manager implementation, but the
      FinalizedAlloc type enforces a requirement that deallocate be called on any
      non-default values prior to destruction. The deallocate method takes a
      vector<FinalizedAlloc>, allowing for bulk deallocation of many allocations in a
      single call.
      
      Memory manager implementations will typically store the address of some
      allocation metadata in the executor in the FinalizedAlloc, as holding this
      metadata in the executor is often cheaper and may allow for clean deallocation
      even in failure cases where the connection with the controller is lost.
      
      (4) Support for "allocation actions" and finalize-lifetime memory.
      
      Allocation actions are pairs (finalize_act, deallocate_act) of JITTargetAddress
      triples (fn, arg_buffer_addr, arg_buffer_size), that can be attached to a
      finalize request. At finalization time, after memory protections have been
      applied, each of the "finalize_act" elements will be called in order (skipping
      any elements whose fn value is zero) as
      
      ((char*(*)(const char *, size_t))fn)((const char *)arg_buffer_addr,
                                           (size_t)arg_buffer_size);
      
      At deallocation time the deallocate elements will be run in reverse order (again
      skipping any elements where fn is zero).
      
      The returned char * should be null to indicate success, or a non-null
      heap-allocated string error message to indicate failure.
      
      These actions allow finalization and deallocation to be extended to include
      operations like registering and deregistering eh-frames, TLS sections,
      initializer and deinitializers, and language metadata sections. Previously these
      operations required separate callWrapper invocations. Compared to callWrapper
      invocations, actions require no extra IPC/RPC, reducing costs and eliminating
      a potential source of errors.
      
      Finalize lifetime memory can be used to support finalize actions: Sections with
      finalize lifetime should be destroyed by memory managers immediately after
      finalization actions have been run. Finalize memory can be used to support
      finalize actions (e.g. with extra-metadata, or synthesized finalize actions)
      without incurring permanent memory overhead.
      e50aea58