1. Jan 31, 2024
    • Tianlan Zhou's avatar
      [clang] static operators should evaluate object argument (#68485) · 30155fc0
      Tianlan Zhou authored
      
      
      ### Description
      
      clang don't evaluate the object argument of `static operator()` and
      `static operator[]` currently, for example:
      
      ```cpp
      #include <iostream>
      
      struct Foo {
          static int operator()(int x, int y) {
              std::cout << "Foo::operator()" << std::endl;
              return x + y;
          }
          static int operator[](int x, int y) {
              std::cout << "Foo::operator[]" << std::endl;
              return x + y;
          }
      };
      Foo getFoo() {
          std::cout << "getFoo()" << std::endl;
          return {};
      }
      int main() {
          std::cout << getFoo()(1, 2) << std::endl;
          std::cout << getFoo()[1, 2] << std::endl;
      }
      ```
      
      `getFoo()` is expected to be called, but clang don't call it currently
      (17.0.2). This PR fixes this issue.
      
      Fixes #67976.
      
      ### Walkthrough
      
      - **clang/lib/Sema/SemaOverload.cpp**
      - **`Sema::CreateOverloadedArraySubscriptExpr` &
      `Sema::BuildCallToObjectOfClassType`**
      Previously clang generate `CallExpr` for static operators, ignoring the
      object argument. In this PR `CXXOperatorCallExpr` is generated for
      static operators instead, with the object argument as the first
      argument.
        - **`TryObjectArgumentInitialization`**
      `const` / `volatile` objects are allowed for static methods, so that we
      can call static operators on them.
      - **clang/lib/CodeGen/CGExpr.cpp**
        - **`CodeGenFunction::EmitCall`**
      CodeGen changes for `CXXOperatorCallExpr` with static operators: emit
      and ignore the object argument first, then emit the operator call.
      - **clang/lib/AST/ExprConstant.cpp**
        - **`‎ExprEvaluatorBase::handleCallExpr‎`**
      Evaluation of static operators in constexpr also need some small changes
      to work, so that the arguments won't be out of position.
      - **clang/lib/Sema/SemaChecking.cpp**
        - **`Sema::CheckFunctionCall`**
      Code for argument checking also need to be modify, or it will fail the
      test `clang/test/SemaCXX/overloaded-operator-decl.cpp`.
      
      ### Tests
      
      - **Added:**
          - **clang/test/AST/ast-dump-static-operators.cpp**
            Verify the AST generated for static operators.
          - **clang/test/SemaCXX/cxx2b-static-operator.cpp**
      Static operators should be able to be called on const / volatile
      objects.
      - **Modified:**
          - **clang/test/CodeGenCXX/cxx2b-static-call-operator.cpp**
          - **clang/test/CodeGenCXX/cxx2b-static-subscript-operator.cpp**
            Matching the new CodeGen.
      
      ### Documentation
      
      - **clang/docs/ReleaseNotes.rst**
        Update release notes.
      
      ---------
      
      Co-authored-by: default avatarShafik Yaghmour <shafik@users.noreply.github.com>
      Co-authored-by: default avatarcor3ntin <corentinjabot@gmail.com>
      Co-authored-by: default avatarAaron Ballman <aaron@aaronballman.com>
      30155fc0
    • michaelrj-google's avatar
      [reland][libc] add epoll_wait functions (#79635) · 9f3854a0
      michaelrj-google authored
      The epoll_wait functions are syscall wrappers that were requested by
      upstream users. This patch adds them, as well as their header and types.
      
      The tests are currently incomplete since they require epoll_create to
      properly test epoll_wait. That will be added in a followup patch since
      this one is already very large.
      9f3854a0
    • Felipe de Azevedo Piovezan's avatar
      [DebugNames] Use hashes to quickly filter false positives (#79755) · 69cb99f9
      Felipe de Azevedo Piovezan authored
      The current implementation of DebugNames is _only_ using hashes to
      compute the bucket number. Once inside the bucket, it reverts back to
      string comparisons, even though not all hashes inside a bucket are
      identical.
      
      This commit changes the behavior so that we check the hash before
      comparing strings. Such check is so important that it speeds up a simple
      benchmark by 20%. In other words, the following expression evaluation
      time goes from 1100ms to 850ms.
      
      ```
      bin/lldb \
      		--batch \
      		-o "b CodeGenFunction::GenerateCode" \
      		-o run \
      		-o "expr Fn" \
      		-- \
      		clang++ -c -g test.cpp -o /dev/null &> output
      ```
      
      (Note, these numbers are considering the usage of IDX_parent)
      69cb99f9
    • Craig Topper's avatar
      [ValueTracking] Add experimental_get_vector_length to isKnownNonZero. (#79950) · d8e1b451
      Craig Topper authored
      If the input is non-zero, this intrinsic should also return a non-zero
      value.
      d8e1b451
    • Craig Topper's avatar
      [RISCV] Remove StackAlign attribute enum. NFC (#79946) · 80ee6083
      Craig Topper authored
      The alignment is directly encoded in the attribute. There doesn't seem
      to be a good reason to give the possible alignments a name.
      80ee6083
    • Craig Topper's avatar
      [IR] Add more efficient getOperand methods to some of the Operator subclasses. (#79943) · 8369f619
      Craig Topper authored
      ConstantExpr does not use HungOffUses. If we know that the Instruction
      the Operator subclass can represent also does not use HungOffUses, we
      can be more efficient than falling back to User::getOperand.
      8369f619
    • Zixu Wang's avatar
    • fabrizio-indirli's avatar
      [mlir][scf] Relax requirements for loops fusion (#79187) · d17b005e
      fabrizio-indirli authored
      
      
      Enable the fusion of parallel loops also when the 1st loop contains
      multiple write accesses to the same buffer, if the accesses are always
      on the same indices.
      Fix LIT test cases whose loops were not being fused.
      
      Signed-off-by: default avatarFabrizio Indirli <Fabrizio.Indirli@arm.com>
      d17b005e
    • Wanyi's avatar
      [llvm-gsymutil] Remove '--num-threads' in test (#79934) · 036a20cc
      Wanyi authored
      Number of threads will automatically be set to a good value
      036a20cc
    • Vyacheslav Levytskyy's avatar
      fix producing multiple identical opaque pointer types (#79060) · 9e02e8f1
      Vyacheslav Levytskyy authored
      This PR fixes https://github.com/llvm/llvm-project/issues/79057 and
      improves code generation for opaque pointers by replacing the culprit
      SPIRVGlobalRegistry::getOpTypePointer() call with a more appropriate
      SPIRVGlobalRegistry::getOrCreateSPIRVPointerType() call. The latter
      function works together with the `DuplicatesTracker`
      (`SPIRVGeneralDuplicatesTracker DT;` from `class SPIRVGlobalRegistry`)
      to trace existence of previous definitions of opaque pointers. This
      allows to produce just one `OpTypePointer` command for all identical
      opaque pointers definitions and to return the very same type record for
      subsequent `SPIRVGlobalRegistry::createSPIRVType()` invocations.
      
      This PR alone improves code generation by producing a single needed
      definition per all opaque pointers to i8 of the same address space
      instead of multiple identical definitions produced before the patch.
      From the root cause analysis of
      https://github.com/llvm/llvm-project/issues/79057 we see also that this
      PR resolves the problem of inconsistency between keeping multiple
      instruction for identical opaque pointer types and just a single record
      for all such instructions in the `DuplicatesTracker`, and so it also
      resolves the issue with crashes on creation of a struct with opaque
      pointer fields due to the fact that now such struct fields refer to the
      same operand `<id>` having a required record in the data structure used
      for dependencies analysis (see
      https://github.com/llvm/llvm-project/issues/79057).
      9e02e8f1
    • Vyacheslav Levytskyy's avatar
      prevent undefined behaviour of SPIR-V Backend non-asserts builds when dealing... · 39483797
      Vyacheslav Levytskyy authored
      prevent undefined behaviour of SPIR-V Backend non-asserts builds when dealing with token type (#78437)
      
      The goal of this PR is to fix the issue when use of token type in LLVM
      intrinsic causes undefined behavior of SPIR-V Backend code generator
      when assertions are disabled:
      https://github.com/llvm/llvm-project/issues/78434
      
      Among possible fix options, discussed in the
      https://github.com/llvm/llvm-project/issues/78434 issue description, the
      option to generate a meaningful error before execution arrives at the
      `llvm_unreachable` call looks like a better solution for now, because
      SPIR-V doesn't support token type anyway without additional extensions.
      
      The PR is to generate a user-friendly error message and exit without
      generating a stack dump when such a usage of token type was detected
      that would lead to undefined behavior of SPIR-V Backend code generator.
      39483797
    • Vyacheslav Levytskyy's avatar
      generate a name of an unnamed global variable for Instruction Selection (#78293) · b9d62310
      Vyacheslav Levytskyy authored
      The goal of this PR is to fix the issue of global unnamed variables
      causing SPIR-V Backend code generation to crash:
      https://github.com/llvm/llvm-project/issues/78278
      
      The reason for the crash is that GlobalValue's getGlobalIdentifier()
      would fail for unnamed global variable when trying to access the first
      character of the name (see lib/IR/Globals.cpp:150). This leads to assert
      in Debug and undefined behaviour in Release builds.
      
      The proposed fix generates a name of an unnamed global variable as
      __unnamed_<unsigned number>, in a style of similar existing LLVM
      implementation (see lib/IR/Mangler.cpp:131). A new class member variable
      is added into `SPIRVInstructionSelector` class to keep track of the
      number we give to anonymous global values to generate the same name
      every time when this is needed.
      
      The patch adds a new LIT test with the smallest implementation of
      reproducer ll code.
      b9d62310
    • Joel Wee's avatar
      [mlir] Fix after #75103 · fe0d16ff
      Joel Wee authored
      fe0d16ff
    • Daniel Chen's avatar
      [Flang]: Lowering reference to functions that return a procedure pointer (#78194) · cdb320b4
      Daniel Chen authored
      
      
      This PR adds lowering the reference to a function that returns a
      procedure pointer. It also fixed intrinsic ASSOCIATED to take such
      argument.
      
      ---------
      
      Co-authored-by: default avatarjeanPerier <jperier@nvidia.com>
      cdb320b4
    • Nick Desaulniers's avatar
      [libc][docs] add page for stdbit.h (#79908) · 223025a6
      Nick Desaulniers authored
      To build libc docs:
      - Configure with `-DLLVM_ENABLE_SPHINX=ON -DLIBC_INCLUDE_DOCS=ON`
      - Build with `ninja docs-libc-html`
      223025a6
    • Matthias Springer's avatar
      [mlir] Fix build after #75103 · c5edef62
      Matthias Springer authored
      After #75103, `MLPrgramTransforms` depends on `BufferizationDialect`.
      Also fix an unrelated compile error in `GreedyPatternRewriteDriver.cpp`.
      (This was not failing on CI. I may be running an old compiler locally.)
      c5edef62
    • Shengchen Kan's avatar
      [X86][NFC] Extract code for commute in foldMemoryOperandImpl into functions · 2960656e
      Shengchen Kan authored
      To share code for folding broadcast in #79761
      2960656e
    • Thomas Preud'homme's avatar
      Fix TOSA FP16->INT16 CAST lowering (#79299) · b23e518c
      Thomas Preud'homme authored
      Currently cast from FP to int is implemented by clamping on the min and
      max
      integer values in the floating-point domain and then converting to
      integer. However, the max int values are often non representable in the
      floating-point input type due to lack of mantissa bits.
      
      This patch instead use a select acting on a compare against max int + 1
      which is representable in floating-point. It also has a special lowering
      for cases where the integer range is wider than the floating-point range
      to clamp the infinite values.
      b23e518c
    • Stefan Gränitz's avatar
      [llvm-jitlink] Fix detectStubKind() for big endian systems (#79970) · 8a5bdd89
      Stefan Gränitz authored
      This function is used in `jitlink-check` lines in LIT tests. In #78371 I
      missed to swap initial instruction bytes for systems that store the
      constants as big-endian.
      8a5bdd89
  2. Jan 30, 2024