1. May 08, 2024
    • Benoit Jacob's avatar
      [mlir][tensor] Remove assertion in ExpandShapeOp::build (#91361) · 62bed56e
      Benoit Jacob authored
      Unblocking downstream integrate where an expected-to-fail test was
      expecting this to be a runtime verifier error, not a compiler crash:
      https://github.com/llvm/torch-mlir/pull/3279.
      62bed56e
    • Edwin Vane's avatar
      [clang-tidy] Refactor how NamedDecl are renamed (#88735) · b1bc1dbe
      Edwin Vane authored
      The handling of renaming failures and multiple usages related to those
      failures is currently spread over several functions. Identifying the
      failure NamedDecl for a given usage is also duplicated, once when
      creating failures and again when identify usages. There are currently
      two ways to a failed NamedDecl from a usage: use the canonical decl or
      use the overridden method. With new methods about to be added, a cleanup
      was in order.
      
      The data flow is simplified as follows:
      * The visitor always forwards NamedDecls to addUsage(NamedDecl).
      * addUsage(NamedDecl) determines the failed NamedDecl and determines
      potential new names based on that failure. Usages are registered using
      addUsage(NamingCheckId).
      * addUsage(NamingCheckId) is now protected and its single responsibility
      is maintaining the integrity of the failure/usage map.
      b1bc1dbe
    • Krystian Stasiowski's avatar
      [Clang] Unify interface for accessing template arguments as written for... · 7115ed0f
      Krystian Stasiowski authored
      [Clang] Unify interface for accessing template arguments as written for class/variable template specializations (#81642)
      
      Our current method of storing the template arguments as written for
      `(Class/Var)Template(Partial)SpecializationDecl` suffers from a number
      of flaws:
      - We use `TypeSourceInfo` to store `TemplateArgumentLocs` for class
      template/variable template partial/explicit specializations. For
      variable template specializations, this is a rather unintuitive hack (as
      we store a non-type specialization as a type). Moreover, we don't ever
      *need* the type as written -- in almost all cases, we only want the
      template arguments (e.g. in tooling use-cases).
      - The template arguments as written are stored in a number of redundant
      data members. For example, `(Class/Var)TemplatePartialSpecialization`
      have their own `ArgsAsWritten` member that stores an
      `ASTTemplateArgumentListInfo` (the template arguments).
      `VarTemplateSpecializationDecl` has yet _another_ redundant member
      "`TemplateArgsInfo`" that also stores an `ASTTemplateArgumentListInfo`.
      
      This patch eliminates all
      `(Class/Var)Template(Partial)SpecializationDecl` members which store the
      template arguments as written, and turns the `ExplicitInfo` member into
      a `llvm::PointerUnion<const ASTTemplateArgumentListInfo*,
      ExplicitInstantiationInfo*>` (to avoid unnecessary allocations when the
      declaration isn't an explicit instantiation). The template arguments as
      written are now accessed via `getTemplateArgsWritten` in all cases.
      
      The "most breaking" change is to AST Matchers, insofar that `hasTypeLoc`
      will no longer match class template specializations (since they no
      longer store the type as written).
      7115ed0f
    • Brendan Dahl's avatar
      [WebAssembly] Implement prototype f32.load_f16 instruction. (#90906) · 1a2a1fbd
      Brendan Dahl authored
      Adds a builtin and intrinsic for the f32.load_f16 instruction.
      
      The instruction loads an f16 value from memory and puts it in an f32.
      Specified at:
      
      https://github.com/WebAssembly/half-precision/blob/29a9b9462c9285d4ccc1a5dc39214ddfd1892658/proposals/half-precision/Overview.md
      
      Note: the current spec has f32.load_f16 as opcode 0xFD0120, but this is
      incorrect and will be changed to 0xFC30 soon.
      1a2a1fbd
    • Keith Smiley's avatar
    • Joseph Huber's avatar
      [libc] Add __FE_DENORM to the fenv macros (#91353) · 873431a6
      Joseph Huber authored
      Summary:
      Some targets support denormals as floating point exceptions. This is
      provided as an extension in the GNU headers as __FE_DENORM.
      
      This provides it in our headers, however I'm unsure if we should make it
      internal or external. I do not think it should be in all exception as it
      doesn't represent an exceptional behavior as far as the standard is
      concerned, but I'm not an expert.
      873431a6
    • Kazu Hirata's avatar
      [Analysis, CodeGen, DebugInfo] Use StringRef::operator== instead of... · 026a29e8
      Kazu Hirata authored
      [Analysis, CodeGen, DebugInfo] Use StringRef::operator== instead of StringRef::equals (NFC) (#91304)
      
      I'm planning to remove StringRef::equals in favor of
      StringRef::operator==.
      
      - StringRef::operator==/!= outnumber StringRef::equals by a factor of
        53 under llvm/ in terms of their usage.
      
      - The elimination of StringRef::equals brings StringRef closer to
        std::string_view, which has operator== but not equals.
      
      - S == "foo" is more readable than S.equals("foo"), especially for
        !Long.Expression.equals("str") vs Long.Expression != "str".
      026a29e8
    • Prashant Kumar's avatar
      [mlir][math] Add Polynomial Approximation for acos, asin op (#90962) · 72085698
      Prashant Kumar authored
      Adds the Polynomial Approximation for math.acos and math.asin op. Also,
      it adds integration tests.
      The Approximation has been borrowed from
      https://stackoverflow.com/a/42683455
      I added this script:
      https://gist.github.com/pashu123/cd3e682b21a64ac306f650fb842a422b to
      test 50 values between -1 and 1. The results are
      https://gist.github.com/pashu123/8acb233bd045bacabfa8c992d4040465. It's
      well within the bounds.
      72085698
    • Andrzej Warzyński's avatar
      [flang] Remove driver-help-hidden.f90 (#91307) · 486695d1
      Andrzej Warzyński authored
      This file was originally removed in #89504 and then accidentally
      re-added in #89938.
      486695d1
    • Yeting Kuo's avatar
      [RISCV][NFC] Remove redundant test cases. (#91324) · 13182305
      Yeting Kuo authored
      PR #89727 added the two test cases to verify `.option arch` should only
      work when having -menable-experimental-extensions. And the test idea
      could be splitted to
      1. When having menable-experimental-extensions, clang passes
      +experimental.
      2. `.option arch` only enabled when +experimental enabled. 
      
      And we already had the two kind of tests.
      13182305
    • Tacet's avatar
      [ASan][libc++] Turn on ASan annotations for short strings (#79536) · 1a961795
      Tacet authored
      This pull request is the third iteration aiming to integrate short
      string annotations. This commit includes:
      - Enabling basic_string annotations for short strings.
      - Setting a value of `__trivially_relocatable` in `std::basic_string` to
      `false_type` when compiling with ASan (nothing changes when compiling
      without ASan). Short string annotations make `std::basic_string` to not
      be trivially relocatable, because memory has to be unpoisoned.
      - Adding a `_LIBCPP_STRING_INTERNAL_MEMORY_ACCESS` modifier to two
      functions.
      - Creating a macro `_LIBCPP_ASAN_VOLATILE_WRAPPER` to prevent
      problematic stack optimizations (the macro modifies code behavior only
      when compiling with ASan).
      
      Previously we had issues with compiler optimization, which we understand
      thanks to @vitalybuka. This commit also addresses smaller changes in
      short string, since previous upstream attempts.
      
      Problematic optimization was loading two values in code similar to:
      ```
      __is_long() ? __get_long_size() : __get_short_size();
      ```
      We aim to resolve it with the volatile wrapper.
      
      This commit is built on top of two previous attempts which descriptions
      are below.
      
      Additionally, in the meantime, annotations were updated (but it
      shouldn't have any impact on anything):
      - https://github.com/llvm/llvm-project/pull/79292
      
      ---
      
      Previous PR: https://github.com/llvm/llvm-project/pull/79049
      Reverted:
      https://github.com/llvm/llvm-project/commit/a16f81f5e3313e88f96de35e5edfe8bee463d308
      
      Previous description:
      
      Originally merged here: https://github.com/llvm/llvm-project/pull/75882
      Reverted here: https://github.com/llvm/llvm-project/pull/78627
      
      Reverted due to failing buildbots. The problem was not caused by the
      annotations code, but by code in the `UniqueFunctionBase` class and in
      the `JSON.h` file. That code caused the program to write to memory that
      was already being used by string objects, which resulted in an ASan
      error.
      
      Fixes are implemented in:
      - https://github.com/llvm/llvm-project/pull/79065
      - https://github.com/llvm/llvm-project/pull/79066
      
      Problematic code from `UniqueFunctionBase` for example:
      ```cpp
          // In debug builds, we also scribble across the rest of the storage.
          memset(RHS.getInlineStorage(), 0xAD, InlineStorageSize);
      ```
      
      ---
      
      Original description:
      
      This commit turns on ASan annotations in `std::basic_string` for short
      stings (SSO case).
      
      Originally suggested here: https://reviews.llvm.org/D147680
      
      String annotations added here:
      https://github.com/llvm/llvm-project/pull/72677
      
      Requires to pass CI without fails:
      - https://github.com/llvm/llvm-project/pull/75845
      - https://github.com/llvm/llvm-project/pull/75858
      
      Annotating `std::basic_string` with default allocator is implemented in
      https://github.com/llvm/llvm-project/pull/72677 but annotations for
      short strings (SSO - Short String Optimization) are turned off there.
      This commit turns them on. This also removes
      `_LIBCPP_SHORT_STRING_ANNOTATIONS_ALLOWED`, because we do not plan to
      support turning on and off short string annotations.
      
      Support in ASan API exists since
      https://github.com/llvm/llvm-project/commit/dd1b7b797a116eed588fd752fbe61d34deeb24e4.
      You can turn off annotations for a specific allocator based on changes
      from
      https://github.com/llvm/llvm-project/commit/2fa1bec7a20bb23f2e6620085adb257dafaa3be0.
      
      This PR is a part of a series of patches extending AddressSanitizer C++
      container overflow detection capabilities by adding annotations, similar
      to those existing in `std::vector` and `std::deque` collections. These
      enhancements empower ASan to effectively detect instances where the
      instrumented program attempts to access memory within a collection's
      internal allocation that remains unused. This includes cases where
      access occurs before or after the stored elements in `std::deque`, or
      between the `std::basic_string`'s size (including the null terminator)
      and capacity bounds.
      
      The introduction of these annotations was spurred by a real-world
      software bug discovered by Trail of Bits, involving an out-of-bounds
      memory access during the comparison of two strings using the
      `std::equals` function. This function was taking iterators
      (`iter1_begin`, `iter1_end`, `iter2_begin`) to perform the comparison,
      using a custom comparison function. When the `iter1` object exceeded the
      length of `iter2`, an out-of-bounds read could occur on the `iter2`
      object. Container sanitization, upon enabling these annotations, would
      effectively identify and flag this potential vulnerability.
      
      If you have any questions, please email:
      
      - advenam.tacet@trailofbits.com
      - disconnect3d@trailofbits.com
      1a961795
    • Simon Pilgrim's avatar
      7198b8a3
    • Simon Pilgrim's avatar
      [X86] sext-subreg.ll - regenerate checks · 63ceb9af
      Simon Pilgrim authored
      63ceb9af
    • Matt Arsenault's avatar
      AMDGPU: Do not bitcast atomicrmw in IR (#90045) · 7927bcdb
      Matt Arsenault authored
      This is the first step to eliminating shouldCastAtomicRMWIInIR. This and
      the other atomic expand casting hooks should be removed. This adds
      duplicate legalization machinery and interfaces. This is already what
      codegen is supposed to do, and already does for the promotion case.
      
      In the case of atomicrmw xchg, there seems to be some benefit to having
      the bitcasts moved outside of the cmpxchg loop on targets with separate
      int and FP registers, which we should be able to deal with by directly
      checking for the legality of the underlying operation.
      
      The casting path was also losing metadata when it recreated the
      instruction.
      7927bcdb
    • Aart Bik's avatar
      [mlir][sparse] force a properly sized view on pos/crd/val under codegen (#91288) · 5c511655
      Aart Bik authored
      Codegen "vectors" for pos/crd/val use the capacity as memref size, not
      the actual used size. Although the sparsifier itself always uses just
      the defined pos/crd/val parts, printing these and passing them back to a
      runtime environment could benefit from wrapping the basic pos/crd/val
      getters into a proper memref view that sets the right size.
      5c511655
    • Petr Hosek's avatar
      [Clang] -fseparate-named-sections option (#91028) · 8bcb0737
      Petr Hosek authored
      When set, the compiler will use separate unique sections for global
      symbols in named special sections (e.g. symbols that are annotated with
      __attribute__((section(...)))). Doing so enables linker GC to collect
      unused symbols without having to use a different section per-symbol.
      8bcb0737
    • Fangrui Song's avatar
      cc1: Report an error for multiple actions unless separated by -main-file-name (#91140) · e74a7a9f
      Fangrui Song authored
      When multiple actions are specified, the last one is used and others are
      overridden. This might lead to confusion if the user is used to driver's
      `-S -emit-llvm` behavior.
      
      ```
      %clang_cc1 -S -emit-llvm a.c     # -S is overridden
      %clang_cc1 -emit-llvm -S a.c     # -emit-llvm is overridden
      %clang_cc1 -fsyntax-only -S a.c  # -fsyntax-only is overridden
      ```
      
      However, we want to continue supporting overriding the driver action
      with -Xclang:
      
      * `clang -c -Xclang -ast-dump a.c` (`%clang -cc1 -emit-obj ...
      -main-file-name a.c ... -ast-dump`)
      * `clang -c -xc++ -Xclang -emit-module stl.modulemap`
      
      As an exception, we allow -ast-dump* options to be composed together
      (e.g. `-ast-dump -ast-dump-lookups` in AST/ast-dump-lookups.cpp).
      e74a7a9f
  2. May 07, 2024