1. Jan 17, 2024
    • Bill Wendling's avatar
      [Clang] Implement the 'counted_by' attribute (#76348) · 00b6d032
      Bill Wendling authored
      The 'counted_by' attribute is used on flexible array members. The
      argument for the attribute is the name of the field member holding the
      count of elements in the flexible array. This information is used to
      improve the results of the array bound sanitizer and the
      '__builtin_dynamic_object_size' builtin. The 'count' field member must
      be within the same non-anonymous, enclosing struct as the flexible array
      member. For example:
      
      ```
        struct bar;
        struct foo {
          int count;
          struct inner {
            struct {
              int count; /* The 'count' referenced by 'counted_by' */
            };
            struct {
              /* ... */
              struct bar *array[] __attribute__((counted_by(count)));
            };
          } baz;
        };
      ```
      
      This example specifies that the flexible array member 'array' has the
      number of elements allocated for it in 'count':
      
      ```
        struct bar;
        struct foo {
          size_t count;
           /* ... */
          struct bar *array[] __attribute__((counted_by(count)));
        };
      ```
      
      This establishes a relationship between 'array' and 'count';
      specifically that 'p->array' must have *at least* 'p->count' number of
      elements available. It's the user's responsibility to ensure that this
      relationship is maintained throughout changes to the structure.
      
      In the following, the allocated array erroneously has fewer elements
      than what's specified by 'p->count'. This would result in an
      out-of-bounds access not not being detected:
      
      ```
        struct foo *p;
      
        void foo_alloc(size_t count) {
          p = malloc(MAX(sizeof(struct foo),
                         offsetof(struct foo, array[0]) + count *
                             sizeof(struct bar *)));
          p->count = count + 42;
        }
      ```
      
      The next example updates 'p->count', breaking the relationship
      requirement that 'p->array' must have at least 'p->count' number of
      elements available:
      
      ```
        void use_foo(int index, int val) {
          p->count += 42;
          p->array[index] = val; /* The sanitizer can't properly check this access */
        }
      ```
      
      In this example, an update to 'p->count' maintains the relationship
      requirement:
      
      ```
        void use_foo(int index, int val) {
          if (p->count == 0)
            return;
          --p->count;
          p->array[index] = val;
        }
      ```
      00b6d032
    • Jonas Devlieghere's avatar
      [lldb] Hoist SupportFile out of FileSpecList (NFC) · 1b5f72c5
      Jonas Devlieghere authored
      This hoists SupportFile out of FileSpecList. SupportFileList is still
      implemented there as it's very similar to FileSpecList.
      1b5f72c5
    • Rahman Lavaee's avatar
      [SHT_LLVM_BB_ADDR_MAP,NFC] Add SCOPED_TRACE for convenient mapping of failures... · 6ba2c2bb
      Rahman Lavaee authored
      [SHT_LLVM_BB_ADDR_MAP,NFC] Add SCOPED_TRACE for convenient mapping of failures to test cases. (#78335)
      
      Although parameterized gtests are preferred for this, our tests are not
      very straightforward. So I decided to add SCOPED_TRACE for different
      test cases and the lambda checks as well.
      
      Typical test failure message now looks like:
      
      ```
      ...llvm-project/llvm/unittests/Object/ELFObjectFileTest.cpp:737
      Expected equality of these values:
        *BBAddrMaps
          Which is: { 32-byte object <11-11 01-00 00-00 00-00 C0-A9 FB-3E E4-55 00-00 D0-A9 FB-3E E4-55 00-00 D0-A9 FB-3E E4-55 00-00>, 32-byte object <22-22 02-00 00-00 00-00 F0-8E FB-3E E4-55 00-00 00-8F FB-3E E4-55 00-00 00-8F FB-3E E4-55 00-00> }
        ExpectedResult
          Which is: { 32-byte object <33-33 03-00 00-00 00-00 50-A7 FB-3E E4-55 00-00 60-A7 FB-3E E4-55 00-00 60-A7 FB-3E E4-55 00-00> }
      Google Test trace:
      ...llvm-project/llvm/unittests/Object/ELFObjectFileTest.cpp:726: for TextSectionIndex: 1 and object yaml:
      
      --- !ELF
      FileHeader:
        Class: ELFCLASS64
        Data:  ELFDATA2LSB
        Type:  ET_EXEC
      Sections:
        - Name: .llvm_bb_addr_map_1
          Type: SHT_LLVM_BB_ADDR_MAP
          Link: 1
          Entries:
            - Version: 2
              Address: 0x11111
              BBEntries:
                - ID:            1
                  AddressOffset: 0x0
                  Size:          0x1
                  Metadata:      0x2
        - Name: .llvm_bb_addr_map_2
          Type: SHT_LLVM_BB_ADDR_MAP
          Link: 1
          Entries:
            - Version: 2
              Address: 0x22222
              BBEntries:
                - ID:            2
                  AddressOffset: 0x0
                  Size:          0x2
                  Metadata:      0x4
        - Name: .llvm_bb_addr_map_3
          Type: SHT_LLVM_BB_ADDR_MAP
          Link: 2
          Entries:
            - Version: 1
              Address: 0x33333
              BBEntries:
                - ID:            0
                  AddressOffset: 0x0
                  Size:          0x3
                  Metadata:      0x6
        - Name: .llvm_bb_addr_map_4
          Type: SHT_LLVM_BB_ADDR_MAP_V0
        # Link: 0 (by default, can be overriden)
          Entries:
            - Version: 0
              Address: 0x44444
              BBEntries:
                - ID:            0
                  AddressOffset: 0x0
                  Size:          0x4
                  Metadata:      0x18
      
      ...llvm-project/llvm/unittests/Object/ELFObjectFileTest.cpp:757: normal sections
      ```
      6ba2c2bb
    • Rahman Lavaee's avatar
      [BasicBlockSections] Always keep the entry block in the beginning of the function. (#74696) · e1616ef9
      Rahman Lavaee authored
      BasicBlockSections must enforce placing the entry block at the beginning
      of the function regardless of the basic block sections profile.
      e1616ef9
    • Victor Mustya's avatar
      [InstCombine] Only fold bitcast(fptrunc) if destination type matches fptrunc result type. (#77046) · ad506760
      Victor Mustya authored
      It's not enough to just make sure destination type is floating point,
      because the following chain may be incorrectly optimized:
      ```LLVM
        %trunc = fptrunc float %src to bfloat
        %cast = bitcast bfloat %trunc to half
      ```
      Before the fix, the instruction sequence mentioned above used to be
      translated into single fptrunc instruction as follows:
      ```LLVM
        %trunc = fptrunc float %src to half
      ```
      
      Such transformation was semantically incorrect.
      ad506760
    • Craig Topper's avatar
      Recommit "[AST] Use APIntStorage to fix memory leak in EnumConstantDecl. (#78311)" · 142f270c
      Craig Topper authored
      With lldb build fix.
      
      Original message:
      
      EnumConstantDecl is allocated by the ASTContext allocator so the
      destructor is never called.
      
      This patch takes a similar approach to IntegerLiteral by using
      APIntStorage to allocate large APSInts using the ASTContext allocator as
      well.
      
      The downside is that an additional heap allocation and copy of the data
      needs to be made when calling getInitValue if the APSInt is large.
      
      Fixes #78160.
      142f270c
    • Yeoul Na's avatar
      [BoundsSafety] Initial documentation for -fbounds-safety (#70749) · dda2ce82
      Yeoul Na authored
      The document is mostly the exact copy of RFC: Enforcing Bounds Safety in
      C, except some clarifications made over the PR review:
      
      https://discourse.llvm.org/t/rfc-enforcing-bounds-safety-in-c-fbounds-safety/70854
      
      Further changes and clarifications for the programming model will be
      done as separate patches to make it easier to track history of changes.
      dda2ce82
    • Ivan Kosarev's avatar
      [AMDGPU] Fix predicates for V_DOT instructions. (#78198) · 03abf7fe
      Ivan Kosarev authored
      Resolves AsmParser ambiguities, e.g., between V_DOT4C_I32_I8_dpp_vi and
      V_DOT4C_I32_I8_dpp_gfx10. The latter is predicated with isGFX10Only
      while the first has no subtarget generation predicates.
      
      Part of <https://github.com/llvm/llvm-project/issues/69256>.
      03abf7fe
    • Charlie Barto's avatar
      [ASAN][sanitizers][win] Allow windows-asan to be built with /MDd and intercept... · 41b09bbe
      Charlie Barto authored
      [ASAN][sanitizers][win] Allow windows-asan to be built with /MDd and intercept functions from the debug runtimes. (#77840)
      
      It turns out this works _mostly_ fine, even when mixing debug versions
      of asan with programs built with the release runtime. Using /MT (or
      /MTd) with a dynamically linked asan has never really worked that well,
      and I am planning on opening a PR that will completely remove the
      static-asan configuration for windows and make programs linked with the
      static CRT/runtime work with the DLL version of asan. This is better
      than the current situation because the static linked version of asan
      doesn't work well on windows if there are multiple DLLs in the process
      using it.
      
      The check for building asan with only /MD or /MT has been removed. It
      was in AsanDoesNotSupportStaticLinkage, but was checking for debug CRTs,
      not static linkage. The kind of static linkage this function is supposed
      to check for (on linux for example) doesn't really exist on windows.
      
      Note: There is one outstanding issue with this approach, if you mix a
      /MDd DLLs and /MD dlls in the same process then the "real" function
      called by asan interceptors will be the same for calls from both
      contexts, potentially screwing up things like errno. This only happens
      if you mix /MD and /MDd in the same process, because otherwise asan
      won't find functions from both runtimes to intercept. We are working on
      a fix for this, and it mainly hits with the CRT functions exported from
      both ucrtbase and ntdll.
      
      
      This change is being upstreamed from Microsoft's fork.
      41b09bbe
    • Craig Topper's avatar
      Revert "[AST] Use APIntStorage to fix memory leak in EnumConstantDecl. (#78311)" · f3d534c4
      Craig Topper authored
      This reverts commit 4737959d.
      
      Missed an lldb update.
      f3d534c4
    • serbanu's avatar
      [clang-format] Add parse tests for SeparateDefinitionBlocks option (#78256) · 59a26531
      serbanu authored
      Add config parse tests for SeparateDefinitionBlocks option.
      59a26531
    • Craig Topper's avatar
      [AST] Use APIntStorage to fix memory leak in EnumConstantDecl. (#78311) · 4737959d
      Craig Topper authored
      EnumConstantDecl is allocated by the ASTContext allocator so the
      destructor is never called.
      
      This patch takes a similar approach to IntegerLiteral by using
      APIntStorage to allocate large APSInts using the ASTContext allocator as
      well.
      
      The downside is that an additional heap allocation and copy of the data
      needs to be made when calling getInitValue if the APSInt is large.
      
      Fixes #78160.
      4737959d
    • Nick Desaulniers's avatar
      Revert "[libc][NFC] Refactor FPBits and remove LongDoubleBits specialization (#78192)" (#78329) · 337b7715
      Nick Desaulniers authored
      This reverts commit fdbf255c.
      
      Causes build breakage on 32b arm (see reports:
      https://github.com/llvm/llvm-project/pull/78192).
      
      These are reproducible for the 32b arm baremetal target on x86 hosts as
      well.
      337b7715
    • Arthur Eubanks's avatar
      [gn build] Manually port 8566cd61 · 18478469
      Arthur Eubanks authored
      18478469
    • Pranav Kant's avatar
      [MC][ARM] Fix test · bbb3f9b1
      Pranav Kant authored
      Similar to d88c1f94
      bbb3f9b1
    • Aiden Grossman's avatar
      [llvm-exegesis] Fix snippet value scaling (#77226) · 16b23879
      Aiden Grossman authored
      Currently, BenchmarkRunner scales the per snippet counters by
      multiplying the raw counter values by the number of instructions (casted
      to a double) divided by the minimum number of instructions. This is
      incorrect for the loop repetition mode for snippets that don't fit a
      whole number of times into the minimum instruction count. For example,
      with 3 instructions in the snippet and the minimum number of
      instructions set to 4, the loop repetitor will execute a total of six
      instructions, but BenchmarkRunner will scale the raw count by 3/4
      instead of 3/6=1/2. This will also be incorrect for the duplicate
      snippet repetitor after #77224.
      
      This patch fixes this behavior by dividing the raw count by the ceiling
      of the number of repetitions divided by the instruction count.
      16b23879
    • erichkeane's avatar
      [OpenACC] Implement 'reduction' clause parsing. · 39739552
      erichkeane authored
      The 'reduction' clause takes a mandatory operator followed by a colon,
      followed by a 'var-list'.  This patch implements the parsing for the
      'reduction' clause.
      39739552
    • jimingham's avatar
      Work around a bug in the interaction between newer dyld's and older simulator dyld's (#78004) · 32dd5b20
      jimingham authored
      There's a bad interaction between the macOS 14 dyld and the "dyld_sim"
      shim that comes from older (iOS 15) simulator downloads that results in
      dyld reporting some modules twice in the return from the dyld callback
      to list modules. The records were identical, but lldb wasn't happy with
      seeing the duplicates...
      
      Since it's not possible to load two different modules at the same
      address, this change just picks the first instance of any entries that
      have the same load address.
      
      There really isn't a good way to test this patch.
      32dd5b20
    • Teresa Johnson's avatar
      [MemProf][NFC] Explicitly specify llvm version of function_ref (#77783) · 070738ba
      Teresa Johnson authored
      As suggested in https://github.com/llvm/llvm-project/pull/75823, to
      avoid confusion with std::function_ref, qualify all uses with llvm::
      (we were already using the llvm version, but this avoids ambiguity).
      070738ba
    • Mark de Wever's avatar
      ab398416
    • mmoadeli's avatar
      [NVPTX] Fix generating permute bytes from register pair when the initial... · aa23e493
      mmoadeli authored
      [NVPTX] Fix generating permute bytes from register pair when the initial values are undefined (#74437)
      
      When generating the permute bytes for the prmt instruction, the
      existence of an undefined initial value initialises the int32 that holds
      the mask with all 1's (0xFFFFFFFF). That initialization subsequently
      leads to complications during the subsequent OR operation, leading to
      inaccuracies in populating mask values for the following bytes.
      Consequently, the final value persists as a constant -1, irrespective of
      the actual mask values that succeed the initial set value.
      aa23e493
    • Mark de Wever's avatar
      [libc++][CI] Fixes documentation builder. (#78327) · 7e909d58
      Mark de Wever authored
      The documentation CI no longer builds. This is likely introduced by
      8f90e693. This fixes the issue.
      7e909d58
    • Petr Hosek's avatar
      [CMake] Include riscv32-unknown-elf runtimes in Fuchsia toolchain (#78323) · 8d7bba0d
      Petr Hosek authored
      This contains compiler-rt builtins and llvm-libc for baremetal use.
      
      Differential Revision: https://reviews.llvm.org/D155337
      8d7bba0d
    • Louis Dionne's avatar
      [libc++] Rewrite the IWYU generation (#78295) · 127c390f
      Louis Dionne authored
      This simplifies the IWYU generation script by treating everything as a
      file, instead of dealing with directories and files separately.
      
      This has the downside that the `libcxx.imp` file is a lot larger than it
      used to be, however we now have the flexibility of mapping files under
      detail directories to different public headers. For example, this allows
      us to map <__fwd/subrange.h> to <ranges> but <__fwd/pair.h> to
      <utility>.
      
      This patch also adds basic validation to ensure that we never map a
      header to a public header that doesn't exist. We may still be missing
      some mappings or we may be mapping to incorrect headers, but we won't be
      mapping to headers that downright don't exist.
      
      Fixes #63346
      127c390f
    • Louis Dionne's avatar
      [libc++][NFC] Add deprecated mention for _LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS in the docs · 8803112b
      Louis Dionne authored
      This was missed in the patch where I marked the macro as deprecated.
      8803112b
    • Mark de Wever's avatar
      [libc++][print] Enables it on Apple backdeployment. (#76293) · 4a87db6b
      Mark de Wever authored
      As suggested in #73262 this enable the stream printing on Apple
      backdeployment targets. This omits the check whether the file is a
      terminal. This is not entirely conforming, but the differences should be
      minor and are typically not observable.
      
      Fixes https://github.com/llvm/llvm-project/issues/75225
      4a87db6b
    • Mark de Wever's avatar
      [libc++] Improves _LIBCPP_HAS_NO_THREADS guards. (#76624) · 34933d18
      Mark de Wever authored
      Previously the header included several headers, possibly granularized
      threading headers. This could lead to build errors when these headers
      were incompatible with threading disabled.
      
      Now test the guard before inclusion. This matches the pattern used for
      no localization and no wide characters.
      
      Fixes: https://github.com/llvm/llvm-project/issues/76620
      34933d18
    • Mark de Wever's avatar
      [libc++] Deprecate removed features macros. (#77879) · e0443624
      Mark de Wever authored
      We discussed the removal of these enable-all macros in the libc++
      monthly meeting and we agreed that we should deprecate these macros in
      LLVM 18, and then remove them in LLVM 19 since they can silently enable
      deprecated features that are implemented after the first release of the
      macro.
      
      This patch does the first part of this -- it deprecates the macro.
      
      Note that the file
        test/libcxx/depr/enable_removed_cpp20_features.compile.pass.cpp
      does not exist so this file is not adapted. Since the feature is
      deprecated and slated for removal soon the missing test is not
      implemented.
      
      Partly addresses: https://github.com/llvm/llvm-project/issues/75976
      
      
      
      ---------
      
      Co-authored-by: default avatarLouis Dionne <ldionne.2@gmail.com>
      e0443624
    • Yitzhak Mandelbaum's avatar
      [clang][dataflow] Fix bug in `Value` comparison. (#76746) · 65ecbdf6
      Yitzhak Mandelbaum authored
      Makes value equivalence require that the values have no properties,
      except in
      the case of equivalence by pointer equality (if the pointers are equal,
      nothing
      else is checked).
      
      Fixes issue #76459.
      65ecbdf6
    • Aart Bik's avatar
    • erichkeane's avatar
      [OpenACC] Implement 'self' clause parsing on 'update'. · 9c4e7a15
      erichkeane authored
      The update directive has its own version of 'self' that has a 'var-list'
      instead of a 'condition' (like the serial/parallel/kernel/combined
      constructs).  This patch special cases it on 'update' to make sure we
      parse this correctly.
      9c4e7a15
    • Simon Pilgrim's avatar
      [X86] Add test case for Issue #77805 · d6ee91b1
      Simon Pilgrim authored
      d6ee91b1
    • David Green's avatar
      [NFC] sentinal -> sentinel · 7850c94b
      David Green authored
      7850c94b
    • Alexey Bataev's avatar
      [SLP]Fix PR78298: Assertion `GEP->getNumIndices() == 1 && · 093206bb
      Alexey Bataev authored
      !isa<Constant>(GEPIdx)' failed.
      
      The non-constant index might be folded to constant during earlier stages
      of vectorization. Need to consider this option and filter out out GEP
      with the constant indices from the candidates list.
      093206bb
    • Stanislav Mekhanoshin's avatar
      [AMDGPU] Sign extend simm16 in setreg intrinsic (#77997) · 371fdbaa
      Stanislav Mekhanoshin authored
      We currently force users to use a negative contant in the intrinsic
      call. Changing it zext would break existing programs, so just sign
      extend an argument.
      371fdbaa
    • Alina Sbirlea's avatar
      [MC][ARM] Fix test. · d88c1f94
      Alina Sbirlea authored
      d88c1f94
    • Tom Eccles's avatar
      [flang] Add install target to install flang headers (#78151) · 03f260fd
      Tom Eccles authored
      This makes it more convenient to install flang without using the general
      `ninja install` to install everything.
      
      To install flang-new and associated things one needs `ninja
      install-flang-new install-flang-libraries install-flang-headers`.
      03f260fd
    • Craig Topper's avatar
      [RISCV] Add scheduler model for sifive-p450. (#77989) · 847c7872
      Craig Topper authored
      This is a slightly cleaned up version of what we've been using in our
      downstream toolchain.
      847c7872
    • Craig Topper's avatar
    • yonillasky's avatar
      [Coroutines] Fix incorrect attribute name coroutine.presplit (NFC) (#78296) · be690ea3
      yonillasky authored
      
      
      Those are probably leftovers from an old name of the same attribute.
      Fixed for the sake of consistency.
      
      Co-authored-by: default avatarYoni Lavi <yoni.lavi@nextsilicon.com>
      be690ea3