1. Dec 06, 2023
    • Jon Roelofs's avatar
      [𝘀𝗽𝗿] changes introduced through rebase · 67574ebe
      Jon Roelofs authored
      Created using spr 1.3.4
      
      [skip ci]
      67574ebe
    • LLVM GN Syncbot's avatar
      [gn build] Port 030b8cb1 · d2819413
      LLVM GN Syncbot authored
      d2819413
    • James Y Knight's avatar
      [XCore] Set MaxAtomicSizeInBitsSupported to 0 (#74389) · 020746d1
      James Y Knight authored
      XCore does not appear to have any support for atomicrmw or cmpxchg.
      
      This will result in all atomic operations getting expanded to __atomic_*
      libcalls via AtomicExpandPass, which matches what Clang already does in
      the frontend.
      
      Additionally, remove the code which handles atomic load/store, as it
      will no longer be used.
      020746d1
    • Lang Hames's avatar
      [llvm-jitlink] Add Process and Platform JITDylibs, generalize alias option. · 3d0dd1a7
      Lang Hames authored
      The Process JITDylib holds reflected process symbols. The Platform JITDylib
      holds ORC runtime symbols if the ORC runtime is loaded. The Platform and
      Process JITDylibs are appended to the link order of all other JITDylibs,
      including the main JITDylib, after any explicitly specified libraries. This
      scheme is similar to the one introduced in LLJIT in 371cb1af, and makes
      it easier to introduce aliases for process and platform symbols in a way that
      affects all JITDylibs uniformly.
      
      Since the Process and Platform JITDylibs are created implicitly the -alias
      option is generalized to allow source and destination JITDylibs to be explicitly
      specified, i.e. the -alias option now supports general re-exports.
      
      Testcases are updated to account for the change.
      3d0dd1a7
    • Jeremy Morse's avatar
    • Aart Bik's avatar
      [mlir][sparse] minor refactoring of sparsification file (#74403) · 067bebb5
      Aart Bik authored
      Removed obsoleted TODOs and NOTEs, formatting, removed unused parameter
      067bebb5
    • Eduard Zingerman's avatar
      [BPF] Attribute preserve_static_offset for structs · 030b8cb1
      Eduard Zingerman authored
      This commit adds a new BPF specific structure attribte
      `__attribute__((preserve_static_offset))` and a pass to deal with it.
      
      This attribute may be attached to a struct or union declaration, where
      it notifies the compiler that this structure is a "context" structure.
      The following limitations apply to context structures:
      - runtime environment might patch access to the fields of this type by
        updating the field offset;
      
        BPF verifier limits access patterns allowed for certain data
        types. E.g. `struct __sk_buff` and `struct bpf_sock_ops`. For these
        types only `LD/ST <reg> <static-offset>` memory loads and stores are
        allowed.
      
        This is so because offsets of the fields of these structures do not
        match real offsets in the running kernel. During BPF program
        load/verification loads and stores to the fields of these types are
        rewritten so that offsets match real offsets. For this rewrite to
        happen static offsets have to be encoded in the instructions.
      
        See `kernel/bpf/verifier.c:convert_ctx_access` function in the Linux
        kernel source tree for details.
      
      - runtime environment might disallow access to the field of the type
        through modified pointers.
      
        During BPF program verification a tag `PTR_TO_CTX` is tracked for
        register values. In case if register with such tag is modified BPF
        programs are not allowed to read or write memory using register. See
        kernel/bpf/verifier.c:check_mem_access function in the Linux kernel
        source tree for details.
      
      Access to the structure fields is translated to IR as a sequence:
      - `(load (getelementptr %ptr %offset))` or
      - `(store (getelementptr %ptr %offset))`
      
      During instruction selection phase such sequences are translated as a
      single load instruction with embedded offset, e.g. `LDW %ptr, %offset`,
      which matches access pattern necessary for the restricted
      set of types described above (when `%offset` is static).
      
      Multiple optimizer passes might separate these instructions, this
      includes:
      - SimplifyCFGPass (sinking)
      - InstCombine (sinking)
      - GVN (hoisting)
      
      The `preserve_static_offset` attribute marks structures for which the
      following transformations happen:
      - at the early IR processing stage:
        - `(load (getelementptr ...))` replaced by call to intrinsic
          `llvm.bpf.getelementptr.and.load`;
        - `(store (getelementptr ...))` replaced by call to intrinsic
          `llvm.bpf.getelementptr.and.store`;
      - at the late IR processing stage this modification is undone.
      
      Such handling prevents various optimizer passes from generating
      sequences of instructions that would be rejected by BPF verifier.
      
      The __attribute__((preserve_static_offset)) has a priority over
      __attribute__((preserve_access_index)). When preserve_access_index
      attribute is present preserve access index transformations are not
      applied.
      
      This addresses the issue reported by the following thread:
      
      https://lore.kernel.org/bpf/CAA-VZPmxh8o8EBcJ=m-DH4ytcxDFmo0JKsm1p1gf40kS0CE3NQ@mail.gmail.com/T/#m4b9ce2ce73b34f34172328f975235fc6f19841b6
      
      This is a second attempt to commit this change, previous reverted
      commit is: cb13e928.
      The following items had been fixed:
      - test case bpf-preserve-static-offset-bitfield.c now uses
        `-triple bpfel` to avoid different codegen for little/big endian
        targets.
      - BPFPreserveStaticOffset.cpp:removePAICalls() modified to avoid
        use after free for `WorkList` elements `V`.
      
      Differential Revision: https://reviews.llvm.org/D133361
      030b8cb1
    • James Y Knight's avatar
      Include LLVM_VERSION_SUFFIX in the Clang version string. (#74469) · 31aebdd8
      James Y Knight authored
      This causes current mainline to now report "18.0.0git" instead of
      "18.0.0".
      
      Fixes #53825
      31aebdd8
    • Schrodinger ZHU Yifan's avatar
      [libc] [search] improve hsearch robustness (#73896) · 86e99e11
      Schrodinger ZHU Yifan authored
      Following up the discussion at
      https://github.com/llvm/llvm-project/pull/73469#discussion_r1409593911
      by @nickdesaulniers.
      
      According to FreeBSD implementation
      (https://android.googlesource.com/platform/bionic/+/refs/heads/main/libc/upstream-freebsd/lib/libc/stdlib/hcreate.c),
      `hsearch` is able to handle the cases where the global table is not
      properly initialized. To do this, FreeBSD actually allows hash table to
      be dynamically resized. If the global table is uninitialized at the
      first call, the table will be initialized with a minimal size; hence
      subsequent insertion will be reasonable as the table grows
      automatically.
      
      This patch mimic such behaviors. More precisely, this patch introduces:
      
      1. a full table iterator that scans each element in the table,
      2. a resize routine that is automatically triggered whenever the load
      factor is reached where it iterates the old table and insert the entries
      into a new one,
      3. more tests that cove...
      86e99e11
    • Valentin Clement (バレンタイン クレメン)'s avatar
      [flang] Fix issue with lookup in the binding table (#74416) · 67f9b5ae
      This patch is fixing two issue relative to the dynamic dispatch for
      polymorphic entities.
      
      1. Fix the `requireDispatchCall` function. It was checking for the first
      symbol of the component but this is not the one to be checked. Instead
      the last symbol of the base of the component object is the one to check
      to know if it is polymorphic object with a dispatch call or not. This is
      demonstrated in the new added test in `flang/test/Lower/dispatch.f90`
      where the first symbol would point to `q` which is monomorphic and would
      result in a simple `fir.call`
      2. Fix the pass object in a no pass situation. In a no pass situation
      the pass object is lowered anyway to be able to do the lookup in the
      binding table. It was previously lowered wrongly an lead to unresolved
      lookup. The base of the component is the passed object and should be
      lowered. To achieve this, the `gen(DataRef)` entry point is exposed form
      `ConvertExprToHLFIR` through a `convertDataRefToValue` function. The
      same test added in `flang/test/Lower/dispatch.f90` is checking for the
      correct passed object.
      
      In addition couple of tests were updated to HLFIR since the lowering
      used only works with it.
      67f9b5ae
    • Jeremy Morse's avatar
      [DebugInfo] Follow up to 34cdc913 to fix a crash · 2a95d47e
      Jeremy Morse authored
      We're removing trailing debug-records at the correct time, but from the
      wrong block. Broken the iterators buildbot:
      
        https://lab.llvm.org/buildbot/#/builders/275/builds/1889
      2a95d47e
    • Juergen Ributzka's avatar
      [clang][modules] Reset codegen options (take 2). (#74388) · 5ad3a32c
      Juergen Ributzka authored
      CodeGen options do not affect the AST, so they usually can be ignored.
      The only exception to the rule is when a PCM is created with
      `-gmodules`.
      In that case the Clang module format is switched to object file
      container and contains also serialized debug information that can be
      affected by debug options. There the following approach was choosen:
      
      1.) Split out all the debug options into a separate `DebugOptions.def`
          file. The file is included by `CodeGenOptions.def`, so the change is
          transparent to all existing users of `CodeGenOptions.def`.
      2.) Reset all CodeGen options, but excluding affecting debug options.
      3.) Conditionally reset debug options that can affect the PCM.
      
      This fixes rdar://113135909.
      5ad3a32c
    • Fangrui Song's avatar
      [Driver] Mark -arch as TargetSpecific (#74365) · 4e0275a2
      Fangrui Song authored
      `-arch` is a Darwin-specific option that is ignored for other targets
      and not known by GCC.
      ```
      % clang -arch arm64 -c a.c
      clang: warning: argument unused during compilation: '-arch arm64' [-Wunused-command-line-argument]
      ```
      
      We are utilizing TargetSpecific (from https://reviews.llvm.org/D151590)
      to make more options lead to errors for unsupported targets.
      4e0275a2
    • Arthur Eubanks's avatar
      [X86] Set SHF_X86_64_LARGE for globals with explicit well-known large section name (#74381) · 323451ab
      Arthur Eubanks authored
      Globals marked with the .lbss/.ldata/.lrodata should automatically be
      treated as large.
      Do this regardless of the code model for consistency when mixing object
      files compiled with different code models.
      
      Basically the other half of #70748.
      
      Example in the wild:
      https://codebrowser.dev/qt5/qtbase/src/testlib/qtestcase.cpp.html#1664
      323451ab
    • Stephan T. Lavavej's avatar
      [libc++][test] Fix assumptions that `std::array` iterators are pointers (#74430) · f1db578f
      Stephan T. Lavavej authored
      Found while running libc++'s tests with MSVC's STL, where `std::array`
      iterators are never pointers.
      
      Most of these changes are reasonably self-explanatory (the `std::array`s
      are right there, and the sometimes-slightly-wrapped raw pointer types
      are a short distance away). A couple of changes are less obvious:
      
      In `libcxx/test/std/containers/from_range_helpers.h`, `wrap_input()` is
      called with `Iter` types that are constructible from raw pointers. It's
      also sometimes called with an `array` as the `input`, so the first
      overload was implicitly assuming that `array` iterators are pointers. We
      can fix this assumption by providing a dedicated overload for `array`,
      just like the one for `vector` immediately below. Finally,
      `from_range_helpers.h` should explicitly include both `<array>` and
      `<vector>`, even though they were apparently being dragged in already.
      
      In `libcxx/test/std/containers/views/views.span/span.cons/iterator_sentinel.pass.cpp`,
      fix `throw_operator_minus`. The error was pretty complicated, caused by
      the concepts machinery noticing that `value_type` and `element_type`
      were inconsistent. In the template instantiation context, you can see
      the critical detail that `throw_operator_minus<std::_Array_iterator>` is
      being formed.
      
      Fortunately, the fix is extremely simple. To produce `element_type`
      (which retains any cv-qualification, unlike `value_type`), we shouldn't
      attempt to `remove_pointer` with the iterator type `It`. Instead, we've
      already obtained the `reference` type, so we can `remove_reference_t`.
      (This is modern code, where we have access to the alias templates, so I
      saw no reason to use the older verbose form.)
      f1db578f
    • Jeremy Morse's avatar
      [NFC][DebugInfo][RemoveDIs] Use iterators to insert in callsite-splitting (#74455) · 34cdc913
      Jeremy Morse authored
      This patch gets call site splitting to use iterators for insertion
      rather than instruction pointers. When we switch on non-instr debug-info
      this becomes significant, as the iterators are going to signal whether
      or not a position is before or after debug-info.
      
      NFC as this isn't going to affect the output of any existing test.
      34cdc913
    • Louis Dionne's avatar
    • Louis Dionne's avatar
      [libc++] Replace uses of _VSTD:: by std:: (#74331) · 77a00c0d
      Louis Dionne authored
      As part of the upcoming clang-formatting of libc++, this patch performs
      the long desired removal of the _VSTD macro.
      
      See https://discourse.llvm.org/t/rfc-clang-formatting-all-of-libc-once-and-for-all
      for the clang-format proposal.
      77a00c0d
    • Jonas Paulsson's avatar
      [SystemZ] Properly support 16 byte atomic int/fp types and ops. (#73134) · c568927f
      Jonas Paulsson authored
      - Clang FE now has MaxAtomicPromoteWidth / MaxAtomicInlineWidth set to 128, and now produces IR
        instead of calls to __atomic instrinsics for 16 bytes as well.
      - Atomic __int128 (and long double) variables are now aligned to 16 bytes by default (like gcc 14).
      - AtomicExpand pass now expands 16 byte operations as well.
      - tests for __atomic builtins for all integer widths, and __atomic_is_lock_free with friends.
      - TODO: AtomicExpand pass handles with this patch expansion of i128 atomicrmw:s. As a next step
        smaller integer types should also be possible to handle this way instead of by the backend.
      c568927f
    • Jakub Mazurkiewicz's avatar
    • Nikita Popov's avatar
      [SCEV] Use or disjoint flag (#74467) · ff0e4fb8
      Nikita Popov authored
      Use the disjoint flag to convert or to add instead of calling the
      haveNoCommonBitsSet() ValueTracking query. This ensures that we can
      reliably undo add -> or canonicalization, even in cases where the
      necessary information has been lost or is too complex to reinfer in
      SCEV.
      
      I have updated the bulk of the test coverage to add the necessary
      disjoint flags in advance.
      ff0e4fb8
  2. Dec 05, 2023