1. Mar 07, 2024
  2. Mar 06, 2024
    • Max Winkler's avatar
      [clang][Sema] Warn on self move for inlined static cast (#76646) · d9d9301e
      Max Winkler authored
      There are code bases that inline `std::move` manually via `static_cast`.
      Treat a static cast to an xvalue as an inlined `std::move` call and warn
      on a self move.
      d9d9301e
    • Timm Bäder's avatar
      [clang][Interp] Diagnose dummy pointers used in Inc/Dec ops · 12fdabc7
      Timm Bäder authored
      For example for unknown parameter decls.
      12fdabc7
    • Nikolas Klauser's avatar
      8e4887ff
    • Alejandro Álvarez Ayllón's avatar
      [clang][analyzer] Model allocation behavior or getdelim/geline (#83138) · 67c6ad6f
      Alejandro Álvarez Ayllón authored
      `getdelim` and `getline` may free, allocate, or re-allocate the input
      buffer, ensuring its size is enough to hold the incoming line, the
      delimiter, and the null terminator.
      
      `*lineptr` must be a valid argument to `free`, which means it can be
      either
      
      1. `NULL`, in which case these functions perform an allocation
      equivalent to a call to `malloc` even on failure.
      2. A pointer returned by the `malloc` family of functions. Other
      pointers are UB (`alloca`, a pointer to a static, to a stack variable, etc.)
      67c6ad6f
    • Krzysztof Drewniak's avatar
      [AMDGPU] Add IR-level pass to rewrite away address space 7 (#77952) · 6540f163
      Krzysztof Drewniak authored
      This commit adds the -lower-buffer-fat-pointers pass, which is
      applicable to all AMDGCN compilations.
      
      The purpose of this pass is to remove the type `ptr addrspace(7)` from
      incoming IR. This must be done at the LLVM IR level because `ptr
      addrspace(7)`, as a 160-bit primitive type, cannot be correctly handled
      by SelectionDAG.
      
      The detailed operation of the pass is described in comments, but, in
      summary, the removal proceeds by:
      1. Rewriting loads and stores of ptr addrspace(7) to loads and stores of
      i160 (including vectors and aggregates). This is needed because the
      in-register representation of these pointers will stop matching their
      in-memory representation in step 2, and so ptrtoint/inttoptr operations
      are used to preserve the expected memory layout
      
      2. Mutating the IR to replace all occurrences of `ptr addrspace(7)` with
      the type `{ptr addrspace(8), ptr addrspace(6) }`, which makes the two
      parts of a buffer fat pointer (the 128-bit address space 8 resource and
      the 32-bit address space 6 offset) visible in the IR. This also impacts
      the argument and return types of functions.
      
      3. *Splitting* the resource and offset parts. All instructions that
      produce or consume buffer fat pointers (like GEP or load) are rewritten
      to produce or consume the resource and offset parts separately. For
      example, GEP updates the offset part of the result and a load uses the
      resource and offset parts to populate the relevant
      llvm.amdgcn.raw.ptr.buffer.load intrinsic call.
      
      At the end of this process, the original mutated instructions are
      replaced by their new split counterparts, ensuring no invalidly-typed IR
      escapes this pass. (For operations like call, where the struct form is
      needed, insertelement operations are inserted).
      
      Compared to LGC's PatchBufferOp (
      
      https://github.com/GPUOpen-Drivers/llpc/blob/32cda89776980202597d5bf4ed4447a1bae64047/lgc/patch/PatchBufferOp.cpp
      ): this pass
      - Also handles vectors of ptr addrspace(7)s
      - Also handles function boundaries
      - Includes the same uniform buffer optimization for loops and
      conditionals
      - Does *not* handle memcpy() and friends (this is future work)
      - Does *not* break up large loads and stores into smaller parts. This
      should be handled by extending the legalization
      of *.buffer.{load,store} to handle larger types by producing multiple
      instructions (the same way ordinary LOAD and STORE are legalized). That
      work is planned for a followup commit.
      - Does *not* have special logic for handling divergent buffer
      descriptors. The logic in LGC is, as far as I can tell, incorrect in
      general, and, per discussions with @nhaehnle, isn't widely used.
      Therefore, divergent descriptors are handled with waterfall loops later
      in legalization.
      
      As a final matter, this commit updates atomic expansion to treat buffer
      operations analogously to global ones.
      
      (One question for reviewers: is the new pass is the right place? Should
      it be later in the pipeline?)
      
      Differential Revision: https://reviews.llvm.org/D158463
      6540f163
    • Simon Pilgrim's avatar
      [TTI] getInstructionCost - pull out repeated getShuffleMask() calls. NFC. · 37113296
      Simon Pilgrim authored
      Pulled out of #84156
      37113296
    • Simon Pilgrim's avatar
      5a896c66
    • Simon Pilgrim's avatar
    • NagyDonat's avatar
      [analyzer] Demonstrate superfluous unsigned >= 0 assumption (#78442) · ad1b2a81
      NagyDonat authored
      This commit adds a testcase which highlights the current incorrect
      behavior of the CSA diagnostic generation: it produces a note which says
      "Assuming 'arg' is >= 0" in a situation where this is not a fresh
      assumption because 'arg' is an unsigned integer.
      
      I also created ticket 78440 to track this bug.
      ad1b2a81
    • Mirko Brkušanin's avatar
      [AMDGPU] Handle amdgpu.last.use metadata (#83816) · 1fd1f4c0
      Mirko Brkušanin authored
      Convert !amdgpu.last.use metadata into MachineMemOperand for last use
      and handle it in SIMemoryLegalizer similar to nontemporal and volatile.
      1fd1f4c0
    • Balazs Benics's avatar
      [clang][NFC] Trim license header comments to 81 characters (#82919) · a87dc23a
      Balazs Benics authored
      clang-format would format these headers poorly by splitting it into
      multiple lines.
      a87dc23a
    • Joe Nash's avatar
      [AMDGPU] Make gfx11 vop1 disassembler tests use strict-whitespace (#84078) · f448b8ec
      Joe Nash authored
      NFC.
      The whitespace needs to be consistently formatted in some manner. Might
      as well use -strict-whitespace as the standard.
      Adds -strict-whitespace to RUN lines and adjust CHECK line space padding
      accordingly.
      
      Also test REAL16 and FAKE16 CHECK lines with wave64.
      f448b8ec
    • Haojian Wu's avatar
      [clang] Use getDefaultArgRange instead of getDefaultArg to retrieve the (#79296) · fec47164
      Haojian Wu authored
      source location in` AliasTemplateDeductionGuideTransform`.
      
      I don't have a reproducible testcase, but this should be a safe and
      non-functional change. We have checked the `hasDefaultArg` before
      calling `getDefaultArg()`, but `hasDefaultArg` allows
      unparsed/uninstantiated default arg which is prohibited in
      `getDefaultArg()`.
      
      Since we're only interested in the source location, we switch to use
      `getDefaultArgRange()` API.
      fec47164
    • Emma Pilkington's avatar
      [AMDGPU] Rename COV module flag to amdhsa_code_object_version (#79905) · 4490003a
      Emma Pilkington authored
      The previous name 'amdgpu_code_object_version', was misleading since
      this is really a property of the HSA OS. The new spelling also matches
      the asm directive I added in bc82cfb3.
      4490003a
    • Jakub Kuderski's avatar
      [Support][Casting] Add predicates for `isa*` functions (#83753) · 8fdec5d3
      Jakub Kuderski authored
      Expose function objects that call into `llvm::isa` and
      `llvm::isa_and_present`, such that these type checks can be used as
      predicates in generic algorithms.
      
      Before this change, `llvm::isa*` functions cannot be easily used without
      knowing both the argument type and the checked types, which leads to
      them being wrapped in lambdas. For example:
      ```c++
      llvm::all_of(myTypes,
                   [](auto type) { return llvm::isa<VectorType>(type); });
      ```
      
      With this PR the example above becomes:
      ```c++
      llvm::all_of(myTypes, llvm::IsaPred<VectorType>);
      ```
      
      As an alternative solution, I considered redefining `isa*` as function
      objects, but I decided against doing that because it would create
      asymmetry with other cast *functions* and could break code that depends
      on them being actual functions.
      8fdec5d3