1. Jul 13, 2023
    • Qiongsi Wu's avatar
      [libLTO][AIX] Respect `-f[no]-integrated-as` on AIX · 41447f6f
      Qiongsi Wu authored
      `libLTO` currently ignores the `-f[no-]integrated-as` flags. This patch teaches `libLTO` to respect them on AIX.
      
      The implementation consists of two parts:
      
        # Migrate `llc`'s `-no-integrated-as` option to a codegen option so that the option is available to `libLTO`/`lld`/`gold`.
        # Teach `clang` to pass `-no-integrated-as` accordingly to `libLTO` depending on the `-f[no-]integrated-as` flags.
      
      On platforms other than AIX, the `-f[no-]integrated-as` flags are ignored.
      
      Reviewed By: MaskRay, steven_wu
      
      Differential Revision: https://reviews.llvm.org/D152924
      41447f6f
    • varconst's avatar
      [libc++][hardening][NFC] Remove the `LIBCXX_DEBUG_BUILD` CMake variable. · 1ba514c2
      varconst authored
      It's no longer necessary to define `_DEBUG` because we use our own
      internal assertion mechanism in libc++.
      
      Differential Revision: https://reviews.llvm.org/D155038
      1ba514c2
    • Matt Arsenault's avatar
      ValueTracking: Recognize fpclass clamping select patterns · 6ed48ebf
      Matt Arsenault authored
      Improve computeKnownFPClass select handling to cover the case where
      the condition performs a class test. This allows us to recognize
      no-nans in cases like:
      
        %not.nan = fcmp ord float %x, 0.0
        %select = select i1 %not.nan, float %x, float 0.0
      
      Math library code has similar edge case filtering on the inputs and
      final results.
      
      https://reviews.llvm.org/D153089
      6ed48ebf
    • Matt Arsenault's avatar
      ValueTracking: Add base computeKnownFPClass select handling tests · 05f0de3d
      Matt Arsenault authored
      Prepare to handle class clamping patterns. Working around some kind of
      select special casing bug in attributor where computeKnownFPClass is
      never called on select.
      05f0de3d
    • Matt Arsenault's avatar
      ValueTracking: Replace CannotBeNegativeZero · 0f4eb557
      Matt Arsenault authored
      This is now just a wrapper around computeKnownFPClass.
      0f4eb557
    • varconst's avatar
      [libc++][hardening][NFC] Add macros to enable hardened mode. · d1367ca4
      varconst authored
      This patch only adds new configuration knobs -- the actual assertions
      will be added in follow-up patches.
      
      Differential Revision: https://reviews.llvm.org/D153902
      d1367ca4
    • varconst's avatar
      [libc++] Fix an exception safety issue in `forward_list` and add tests. · d0b51657
      varconst authored
      When inserting nodes into a forward list, each new node is allocated but
      not constructed. The constructor was being called explicitly on the node
      `value_` but the `next_` pointer remained uninitialized rather than
      being set to null. This bug is only triggered in the cleanup code if an
      exception is thrown -- upon successful creation of new nodes, the last
      incorrect "next" value is overwritten to a correct pointer.
      
      This issue was found due to new tests added in
      https://reviews.llvm.org/D149830.
      
      Differential Revision: https://reviews.llvm.org/D152327
      d0b51657
    • Tom Eccles's avatar
      [flang][HLFIR] allow hlfir.get_length with hlfir.associate · 345f8699
      Tom Eccles authored
      hlfir.get_length will not modify the buffer and so it is safe for a
      hlfir.associate using the same expression buffer not to make its own
      copy.
      
      Differential Revision: https://reviews.llvm.org/D154942
      345f8699
    • Tai Ly's avatar
      [TOSA] Add level checks and remove Tensor1DTo4D · d713a002
      Tai Ly authored
      
      
      Remove Tosa_Tensor1Dto4D and Tosa_TensorUpto4D in the Tosa Dialect
      and added level checks to TosaValidation pass to validate per spec.
      
      Signed-off-by: default avatarTai Ly <tai.ly@arm.com>
      Change-Id: Icd32137e9f8051f99994cee9f388f20c1a840f4b
      
      Reviewed By: eric-k256
      
      Differential Revision: https://reviews.llvm.org/D154273
      d713a002
    • Nick Desaulniers's avatar
      [ConstantHoisting] simplify NumUses accounting NFC · cb79b5b5
      Nick Desaulniers authored
      The `Uses` variable is unnecessary. Just use `UsesNum` instead.
      
      Reviewed By: MaskRay
      
      Differential Revision: https://reviews.llvm.org/D155020
      cb79b5b5
    • Eduard Zingerman's avatar
      [BPF][DebugInfo] Use .BPF.ext for line info when DWARF is not available · c8e055d4
      Eduard Zingerman authored
      "BTF" is a debug information format used by LLVM's BPF backend.
      The format is much smaller in scope than DWARF, the following info is
      available:
      - full set of C types used in the binary file;
      - types for global values;
      - line number / line source code information .
      
      BTF information is embedded in ELF as .BTF and .BTF.ext sections.
      Detailed format description could be found as a part of Linux Source
      tree, e.g. here: [1].
      
      This commit modifies `llvm-objdump` utility to use line number
      information provided by BTF if DWARF information is not available.
      E.g., the goal is to make the following to print source code lines,
      interleaved with disassembly:
      
          $ clang --target=bpf -g test.c -o test.o
          $ llvm-strip --strip-debug test.o
          $ llvm-objdump -Sd test.o
      
          test.o:	file format elf64-bpf
      
          Disassembly of section .text:
      
          <foo>:
          ; void foo(void) {
          	r1 = 0x1
          ;   consume(1);
          	call -0x1
          	r1 = 0x2
          ;   consume(2);
          	call -0x1
          ; }
          	exit
      
      A common production use case for BPF programs is to:
      - compile separate object files using clang with `-g -c` flags;
      - link these files as a final "static" binary using bpftool linker ([2]).
      The bpftool linker discards most of the DWARF sections
      (line information sections as well) but merges .BTF and .BTF.ext sections.
      Hence, having `llvm-objdump` capable to print source code using .BTF.ext
      is valuable.
      
      The commit consists of the following modifications:
      
      - llvm/lib/DebugInfo/BTF aka `DebugInfoBTF` component is added to host
        the code needed to process BTF (with assumption that BTF support
        would be added to some other tools as well, e.g. `llvm-readelf`):
        - `DebugInfoBTF` provides `llvm::BTFParser` class, that loads information
          from `.BTF` and `.BTF.ext` sections of a given `object::ObjectFile`
          instance and allows to query this information.
          Currently only line number information is loaded.
      
        - `DebugInfoBTF` also provides `llvm::BTFContext` class, which is an
          implementation of `DIContext` interface, used by `llvm-objdump` to
          query information about line numbers corresponding to specific
          instructions.
      
      - Structure `DILineInfo` is modified with field `LineSource`.
      
        `DIContext` interface uses `DILineInfo` structure to communicate
        line number and source code information.
        Specifically, `DILineInfo::Source` field encodes full file source code,
        if available. BTF only stores source code for selected lines of the
        file, not a complete source file. Moreover, stored lines are not
        guaranteed to be sorted in a specific order.
      
        To avoid reconstruction of a file source code from a set of
        available lines, this commit adds `LineSource` field instead.
      
      - `Symbolize` class is modified to use `BTFContext` instead of
        `DWARFContext` when DWARF sections are not available but BTF
        sections are present in the object file.
        (`Symbolize` is instantiated by `llvm-objdump`).
      
      - Integration and unit tests.
      
      Note, that DWARF has a notion of "instruction sequence".
      DWARF implementation of `DIContext::getLineInfoForAddress()` provides
      inexact responses if exact address information is not available but
      address falls within "instruction sequence" with some known line
      information (see `DWARFDebugLine::LineTable::findRowInSeq()`).
      
      BTF does not provide instruction sequence groupings, thus
      `getLineInfoForAddress()` queries only return exact matches.
      This does not seem to be a big issue in practice, but output
      of the `llvm-objdump -Sd` might differ slightly when BTF
      is used instead of DWARF.
      
      [1] https://www.kernel.org/doc/html/latest/bpf/btf.html
      [2] https://github.com/libbpf/bpftool
      
      Depends on https://reviews.llvm.org/D149501
      
      Reviewed By: MaskRay, yonghong-song, nickdesaulniers, #debug-info
      
      Differential Revision: https://reviews.llvm.org/D149058
      c8e055d4
    • Nick Desaulniers's avatar
      [ConstantHoisting] use BasicBlock::getFirstInsertionPt NFC · 1936bb81
      Nick Desaulniers authored
      Rather than open coding the same implementation.
      
      Reviewed By: MaskRay, void
      
      Differential Revision: https://reviews.llvm.org/D154996
      1936bb81
    • Ted Woodward's avatar
      Fix mixed disassembly showing source lines for "line 0" · ded1bad6
      Ted Woodward authored
      "line 0" in a DWARF linetable means something that doesn't have associated
      source. The code for mixed disassembly has a comment indicating that
      "line 0" should be skipped, but the wrong value was returned. Fix the return
      value and add a test to check that we don't incorrectly show source lines
      from the beginning of the file.
      
      Reviewed By: jasonmolenda
      
      Differential Revision: https://reviews.llvm.org/D112931
      ded1bad6
    • Craig Topper's avatar
      [ARM][AArch64] Add ARM specific builtin for clz that is not undefined for 0 in ubsan. · 85b27ace
      Craig Topper authored
      D152023 made ubsan consider __builtin_clz of 0 undefined regardless of
      the target. This ensures portability and matches gcc.
      
      This causes the ACLE intrinsics to also be considered to also be
      considered to be undefined for 0 since they used the generic builtins
      as their implementation.
      
      This patch adds builtins for ARM that ubsan doesn't know about to make
      the behavior defined for 0. Alternatively, I could have added a zero
      check to the intrinsics, but the dedicated builtin will give better -O0
      codegen.
      
      Fixes #63113.
      
      Reviewed By: tmatheson
      
      Differential Revision: https://reviews.llvm.org/D154915
      85b27ace
  2. Jul 12, 2023