1. Oct 12, 2021
    • 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
    • Ahmed Bougacha's avatar
      [Driver] Re-enable aarch64-cpus.c test for arm64-apple. · c30a5285
      Ahmed Bougacha authored
      "darwin" is ambiguous.  When there isn't a better source
      of truth (e.g., SDKs), the driver will either interpret it
      as "iOS" when cross-compiling to a different architecture,
      or "the host" when not.  That's now the case on AS Macs.
      
      Update the test to more explicitly test the OS.
      aarch64-mac-cpus.c already tests the mac-specific driver logic.
      c30a5285
    • Haowei Wu's avatar
      Reland "[clang][Fuchsia] Support availability attr on Fuchsia" · 998e067a
      Haowei Wu authored
      This reland commit 1131b1eb, which
      adds support to __attribute__((availability)) annotation for Fuchsia
      platform. This patch also adds '-ffuchsia-api-level' to allow specify
      Fuchsia API level from the command line.
      
      Differential Revision: https://reviews.llvm.org/D108592
      998e067a
    • Joe Loser's avatar
      [libc++][docs] Mark LWG3447 as complete · e8890999
      Joe Loser authored
      Mark LWG3447 as complete since it was not an issue since the original
      implementation of `take_view` from
      0f4b41e0. Currently, `take_view`'s
      deduction guide does not constrain the range on the `range` concept.
      
      Reviewed By: ldionne, Mordante, #libc
      
      Differential Revision: https://reviews.llvm.org/D111501
      e8890999
    • Haowei Wu's avatar
      Revert "[clang][Fuchsia] Support availability attr on Fuchsia" · b5e8348b
      Haowei Wu authored
      This reverts commit 1131b1eb, which
      breaks several llvm bots.
      b5e8348b
    • Chris Lattner's avatar
      LLVM_ATTRIBUTE_NODEBUG: GCC 4.0 apparently had ((nodebug)) but removed it. · a185d513
      Chris Lattner authored
      This should fix a bunch of warnings on the flang-aarch64-latest-gcc builder.
      a185d513
    • Richard Smith's avatar
      PR52139: Properly handle more kinds of declaration when checking for · 25b3370f
      Richard Smith authored
      usage of an abstract class type within itself.
      
      We were missing handling for deduction guides (which would assert),
      friend declarations, and variable templates. We were mishandling inline
      variables and other variables defined inside the class definition.
      
      These diagnostics should be downgraded to warnings, or perhaps removed
      entirely, once we implement P0929R2.
      25b3370f
    • Arthur Eubanks's avatar
    • Arthur Eubanks's avatar
      Remove checks for old gcc versions for LLVM_ATTRIBUTE_* · f5b52453
      Arthur Eubanks authored
      According to [1] we only support gcc 5.1+. So these checks for older gcc versions are not supported.
      
      [1] https://llvm.org/docs/GettingStarted.html#host-c-toolchain-both-compiler-and-standard-library
      
      Reviewed By: MaskRay
      
      Differential Revision: https://reviews.llvm.org/D111581
      f5b52453
    • Ben Shi's avatar
      [RISCV][test] Add more tests of immediate materialisation · c9db5f0f
      Ben Shi authored
      Reviewed By: craig.topper
      
      Differential Revision: https://reviews.llvm.org/D111483
      c9db5f0f
    • Amara Emerson's avatar
      [AArch64][GlobalISel] Fix combiner assertion in matchConstantOp(). · 53ebfa7c
      Amara Emerson authored
      We shouldn't call APInt::getSExtValue() on a >64b value.
      53ebfa7c
    • Yonghong Song's avatar
      Revert "[Clang] Ignore BTFTag attr if used as a type attribute" · c5fb1a09
      Yonghong Song authored
      This reverts commit b8753438.
      
      Per discussion in https://reviews.llvm.org/D111199, instead to make
      existing btf_tag attribute as a type-or-decl attribute, we will
      make existing btf_tag attribute as a decl only attribute, and
      introduce btf_type_tag as a type only attribute. This will make
      it easy for cases like typedef where an attribute may be applied
      as either a type attribute or a decl attribute.
      c5fb1a09
    • Haowei Wu's avatar
      [clang][Fuchsia] Support availability attr on Fuchsia · 1131b1eb
      Haowei Wu authored
      This patch adds support to __attribute__((availability)) annotation for
      Fuchsia platform. This patch also adds '-ffuchsia-api-level' to allow
      specify Fuchsia API level from the command line.
      
      Differential Revision: https://reviews.llvm.org/D108592
      1131b1eb
    • Guozhi Wei's avatar
      [TwoAddressInstructionPass] Improve the SrcRegMap and DstRegMap computation · 6599961c
      Guozhi Wei authored
      This patch contains following enhancements to SrcRegMap and DstRegMap:
      
        1 In findOnlyInterestingUse not only check if the Reg is two address usage,
          but also check after commutation can it be two address usage.
      
        2 If a physical register is clobbered, remove SrcRegMap entries that are
          mapped to it.
      
        3 In processTiedPairs, when create a new COPY instruction, add a SrcRegMap
          entry only when the COPY instruction is coalescable. (The COPY src is
          killed)
      
      With these enhancements isProfitableToCommute can do better commute decision,
      and finally more register copies are removed.
      
      Differential Revision: https://reviews.llvm.org/D108731
      6599961c
    • Jacques Pienaar's avatar
      [mlir] Restrict to requiring traits when using InferTensorType trait. · c3dcf395
      Jacques Pienaar authored
      Avoids running into segfaults accidentally.
      
      Differential Revision: https://reviews.llvm.org/D110297
      c3dcf395
    • Amara Emerson's avatar
    • Jinsong Ji's avatar
      64d1d5f3
    • Alina Sbirlea's avatar
      [LoopSimplifyCFG] Do not require MSSA. Continue to preserve if available. · f7ca5428
      Alina Sbirlea authored
      LoopSimplifyCFG does not need MSSA, but should preserve it if it's available.
      
      This is a legacy PM change, aimed to denoise the test changes in D109958.
      
      Differential Revision: https://reviews.llvm.org/D111578
      f7ca5428
    • Lang Hames's avatar
      [ORC] Propagate errors to handlers when sendMessage fails. · 17a0858f
      Lang Hames authored
      In SimpleRemoteEPC, calls to from callWrapperAsync to sendMessage may fail.
      The handlers may or may not be sent failure messages by handleDisconnect,
      depending on when that method is run. This patch adds a check for an un-failed
      handler, and if it finds one sends it a failure message.
      17a0858f
    • Lang Hames's avatar
      [ORC] Destroy FinalizeErr if there is a serialization error. · 4fc2a4cc
      Lang Hames authored
      If there is a serialization error then FinalizeErr should never be set, so we
      can use cantFail rather than consumeError here.
      4fc2a4cc
    • Lang Hames's avatar
      [ORC] Propagate out-of-band errors in callAsync. · 8abf46d3
      Lang Hames authored
      Returned out-of-band errors should be wrapped as llvm::Errors and passed to the
      SendDeserializedResult function. Failure to do this results in an assertion when
      we try to deserialize from the WrapperFunctionResult while it's in the
      out-of-band error state.
      8abf46d3
    • Nikita Popov's avatar
      [IVUsers] Check for preheader instead of loop simplify form · 2a2a37d9
      Nikita Popov authored
      IVUsers currently makes sure that all loops dominating a user are
      in loop simplify form, because SCEVExpander needs a preheader to
      insert into. However, loop simplify form requires much more than
      that. In particular, it requires dedicated exits, which means that
      exits need to be found and walked. For large functions with many
      nested loops, this can result in pathological compile-time explosion.
      
      Fix this by only checking the property we're actually interested in,
      which is incidentally cheap to check.
      
      Differential Revision: https://reviews.llvm.org/D111493
      2a2a37d9
    • David Green's avatar
      [ARM] Be more explicit about disabling CombineBaseUpdate for MVE. · 860b4479
      David Green authored
      This shouldn't be called for non-neon targets at the moment in either
      case, but it is good to be expliit about the CombineBaseUpdate being a
      NEON function, not expecting to be run under MVE.
      860b4479
    • Roman Lebedev's avatar
    • Arthur Eubanks's avatar
      [LCG] Don't skip invalidation of LazyCallGraph if CFG analyses are preserved · 259390de
      Arthur Eubanks authored
      The CFG being changed and the overall call graph are not related, we can introduce/remove calls without changing the CFG.
      
      Resolves one of the issues in PR51946.
      
      Reviewed By: asbirlea
      
      Differential Revision: https://reviews.llvm.org/D111275
      259390de
    • Sanjay Patel's avatar
      [InstCombine] fold signbit check of X | (X -1) · 59441c73
      Sanjay Patel authored
      There may be some other patterns like this or a generalization,
      but this is an example that I noticed would definitely regress
      with a planned follow-up to D111410.
      
      https://alive2.llvm.org/ce/z/GVpQDb
      59441c73
    • Sanjay Patel's avatar
      518ec39d
    • Arthur Eubanks's avatar
      [SCCP] Properly report changes when changing a pointer argument · fbddf22e
      Arthur Eubanks authored
      Fixes one of the issues in PR51946.
      
      Reviewed By: asbirlea
      
      Differential Revision: https://reviews.llvm.org/D111277
      fbddf22e
    • Chris Lattner's avatar
      [TypeSwitch/Compiler.h] Provide a LLVM_NODEBUG macro and use it in TypeSwitch.h · e0582e69
      Chris Lattner authored
      TypeSwitch.h is used pervasively in MLIR and often has dozens of types switched
      over.  It uses "zero cost" variadic templates to implement the dispatching
      mechanism... which isn't zero cost in debug builds, and which causes a massive
      problem for actually debugging things that use it - you get dozens of nonsense
      frames in the debugger for simple things like a visitor.
      
      Fix this by marking the key method in TypeSwitch as nodebug + alwaysinline.
      This resolves LLVM PR49301
      
      Differential Revision: https://reviews.llvm.org/D111520
      e0582e69
    • Daniel Resnick's avatar
      [mlir][ODS] Support result type inference in custom assembly format · 1760d8b3
      Daniel Resnick authored
      Operations that have the InferTypeOpInterface trait can now omit the return
      types in their custom assembly formats.
      
      Differential Revision: https://reviews.llvm.org/D111326
      1760d8b3
    • James King's avatar
      Add release note about `TypeLoc` matchers. · 25fabc43
      James King authored
      Reviewed By: ymandel, aaron.ballman
      
      Differential Revision: https://reviews.llvm.org/D111518
      25fabc43
    • Chris Bieneman's avatar
      AddGlobalAnnotations for function with or without function body. · 121b2252
      Chris Bieneman authored
      When AnnotateAttr is on a function, AddGlobalAnnotations is only called
      in CodeGenModule::EmitGlobalFunctionDefinition which means AnnotateAttr
      on function declaration without function body will be ignored.
      The patch will move AddGlobalAnnotations  to
      CodeGenModule::SetFunctionAttributes, so with or without function body,
      the AnnotateAttr will get code gen for a function.
      
      It'll help case when AnnotateAttr is on external function, and the
      AnnotateAttr will be consumed in IR level.
      
      For example, a pass to collect num of uses for functions with
      __attribute((annotate("count_use"))) after optimizations,
      As long as there's __attribute((annotate("count_use"))), function with
      or without function body should be counted.
      
      Reviewed By: aaron.ballman
      
      Differential Revision: https://reviews.llvm.org/D111109
      
      Patch by:  python3kgae (Xiang Li)
      121b2252
    • Jay Foad's avatar
      [PHIElimination] Fix accounting for undef uses when updating LiveVariables · edfdce26
      Jay Foad authored
      PHI elimination updates LiveVariables info as described here:
      
          // We only need to update the LiveVariables kill of SrcReg if this was the
          // last PHI use of SrcReg to be lowered on this CFG edge and it is not live
          // out of the predecessor. We can also ignore undef sources.
      
      Unfortunately if the last use also happened to be an undef use then it
      would fail to update the LiveVariables at all. Fix this by not counting
      undef uses in the VRegPHIUse map.
      
      Thanks to Mikael Holmén for the test case!
      
      Differential Revision: https://reviews.llvm.org/D111552
      edfdce26
    • Jay Foad's avatar
      [AMDGPU] Fix copying a machine operand · 2e1ad932
      Jay Foad authored
      Without this I get:
      
      *** Bad machine code: Instruction has operand with wrong parent set ***
      - function:    available_externally_test
      - basic block: %bb.0  (0x7dad598)
      - instruction: %0:r600_treg32_x = MOV 1, 0, 0, 0, $alu_literal_x, 0, 0, 0, -1, 1, $pred_sel_off, @available_externally, 0
      
      Differential Revision: https://reviews.llvm.org/D111549
      2e1ad932