1. Jun 27, 2023
    • Tobias Gysi's avatar
      [mlir][llvm] Add comdat attribute to functions · b126ee65
      Tobias Gysi authored
      This revision adds comdat support to functions. Additionally,
      it ensures only comdats that have uses are imported/exported and
      only non-empty global comdat operations are created.
      
      Reviewed By: Dinistro
      
      Differential Revision: https://reviews.llvm.org/D153739
      b126ee65
    • Aiden Grossman's avatar
      [llvm-exegesis] Fix warning and hoist statement of arch-specific section · 9b684ecd
      Aiden Grossman authored
      My last patch broke most of the builders that aren't currently running
      at least Kernel 5.6 as there was a variable used later on inside a
      region that required that kernel version. Also fixes a minor warning
      left over from a bad merge.
      9b684ecd
    • Aiden Grossman's avatar
      [llvm-exegesis] Add support for using memory annotations · 9f80831f
      Aiden Grossman authored
      This patch adds in support for using memory annotations in the
      subprocess execution mode.
      9f80831f
    • Mehdi Amini's avatar
      Revert "[mlir][Transform] Add support for mma.sync m16n8k16 f16 rewrite." and... · 6506692f
      Mehdi Amini authored
      Revert "[mlir][Transform] Add support for mma.sync m16n8k16 f16 rewrite." and "[mlir][Transform] Introduce nvgpu transform extensions"
      
      This reverts commit 40deed40.
      and commit 1660f217.
      
      The buildbot is broken, the two tests aren't passing.
      6506692f
    • Aiden Grossman's avatar
      [llvm-exegesis] Remove extraneous print debug statement · 41ba29d3
      Aiden Grossman authored
      This was leftover when I was working on the lit config while recomitting
      a patch and never should've made it in tree.
      41ba29d3
    • Aiden Grossman's avatar
      Revert "[NFC] Refactor MBB hotness/coldness into templated PSI functions." · bfa1057b
      Aiden Grossman authored
      This reverts commit c3e33720.
      
      This has broken quite a few buildbots.
      bfa1057b
    • Jim Lin's avatar
      [LibCallsShrinkWrap][NFC] Reuse createCond and createOrCond · f6cb9b82
      Jim Lin authored
      Add two new functions `createCond` and `createOrCond` that accept extra
      arguments Arg and Arg/Arg2 respectively.
      
      Reviewed By: efriedma
      
      Differential Revision: https://reviews.llvm.org/D153253
      f6cb9b82
    • Craig Topper's avatar
    • Aiden Grossman's avatar
      [llvm-exegesis] Add memory annotation parsing · f0655b0d
      Aiden Grossman authored
      This patch adds memory annotation parsing to llvm-exegesis. The memory
      annotations cannot be used currently, but this allows for using parsed
      memory annotations within a FunctionExecutorImpl to set up a specified
      execution environment.
      f0655b0d
    • Fangrui Song's avatar
      [test] Improve symbol visibility test · 32c7efdd
      Fangrui Song authored
      32c7efdd
    • Aiden Grossman's avatar
      [llvm-exegesis] Fix test failure caused by assymetric values · 3cbbdbbc
      Aiden Grossman authored
      I fixed compilation on 32-bit ARM earlier in the -Werror case using
      preprocessor directives but forgot to update the unit tests that also
      depend upon that value. This patch updates the unit tests as well as a
      quick fix for the builders that were broken by the earlier patch.
      3cbbdbbc
    • Han Shen's avatar
      [NFC] Refactor MBB hotness/coldness into templated PSI functions. · c3e33720
      Han Shen authored
      In D152399, we calculate BPI->BFI in MachineFunctionSplit pass just to
      use PSI->isFunctionHotInCallGraph, which is expensive. Instead, we can
      implement this directly with MBFI.
      
      Reviewer mentioned in the comment, that machine_size_opts already has
      isFunctionColdInCallGraph, isFunctionHotInCallGraphNthPercentile, etc
      implemented. These can be refactored and reused across MFS and machine
      size opts.
      
      This CL does this - it refactors out those internal static functions
      into PSI as templated functions, so they can be accessed easily.
      
      Differential Revision: https://reviews.llvm.org/D152758
      c3e33720
    • Advenam Tacet's avatar
      [2a/3][ASan][libcxx] std::deque annotations · 10ec9276
      Advenam Tacet authored
      This revision 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`, to `std::string` and `std::deque` collections. These changes allow ASan to detect cases when the instrumented program accesses memory which is internally allocated by the collection but is still not in-use (accesses before or after the stored elements for `std::deque`, or between the size and capacity bounds for `std::string`).
      
      The motivation for the research and those changes was a bug, found by Trail of Bits, in a real code where an out-of-bounds read could happen as two strings were compared via a std::equals function that took `iter1_begin`, `iter1_end`, `iter2_begin` iterators (with a custom comparison function). When object `iter1` was longer than `iter2`, read out-of-bounds on `iter2` could happen. Container sanitization would detect it.
      
      This revision introduces annotations for `std::deque`. Each chunk of the container can now be annotated using the `__sanitizer_annotate_double_ended_contiguous_container` function, which was added in the rG1c5ad6d2. Any attempt to access poisoned memory will trigger an ASan error. Although false negatives are rare, they are possible due to limitations in the ASan API, where a few (usually up to 7) bytes before the container may remain unpoisoned. There are no false positives in the same way as with `std::vector` annotations.
      
      This patch only supports objects (deques) that use the standard allocator. However, it can be easily extended to support all allocators, as suggested in the D146815 revision.
      
      Furthermore, the patch includes the addition of the `is_double_ended_contiguous_container_asan_correct` function to `libcxx/test/support/asan_testing.h`. This function can be used to verify whether a `std::deque` object has been correctly annotated.
      
      Finally, the patch extends the unit tests to verify ASan annotations (added LIBCPP_ASSERTs).
      If a program is compiled without ASan, all helper functions will be no-ops. In binaries with ASan, there is a negligible performance impact since the code from the change is only executed when the deque container changes in size and it’s proportional to the change. It is important to note that regardless of whether or not these changes are in use, every access to the container's memory is instrumented.
      
      If you have any questions, please email:
      - advenam.tacet@trailofbits.com
      - disconnect3d@trailofbits.com
      
      Reviewed By: #libc, philnik
      
      Differential Revision: https://reviews.llvm.org/D132092
      10ec9276
    • Advenam Tacet's avatar
      [ASan] Remove sanity checks during annotation of contiguous container · 0b2c0dc6
      Advenam Tacet authored
      This revision removes sanity checks in
      `__sanitizer_annotate_contiguous_container`.
      (Changed them to `DCHECK_EQ`.)
      Those checks may be problematic, if someone manually unpoisoned memory block.
      Manual unpoisoning may be used if part of the program is not
      instrumented.
      
      Those checks are helpful while confirming correctness of ASan annotations
      implementation.
      
      Originally suggested here: https://reviews.llvm.org/D136765#4174546
      
      Reviewed By: vitalybuka
      
      Differential Revision: https://reviews.llvm.org/D145482
      0b2c0dc6
    • Slava Zakharin's avatar
      [flang][hlfir] Special handling for temporary LHS in AssignOp. · ebd0b8a0
      Slava Zakharin authored
      When `AssignOp` is used with LHS that is a compiler generated temporary
      special care must be taken to initialize the temporary and avoid
      finalizations of its components. This change-set adds optional
      `temporary_lhs` attribute for `AssignOp` to convey this information
      to HLFIR-to-FIR conversion pass. Currently, this results in
      calling `AssignTemporary` runtime for doing the assignment.
      
      Reviewed By: jeanPerier, tblah
      
      Differential Revision: https://reviews.llvm.org/D152482
      ebd0b8a0
    • Jie Fu's avatar
      [llvm-exegesis] Fix unused variable 'VAddressSpaceCeiling' warning (NFC) · 62883d9f
      Jie Fu authored
      /Users/jiefu/llvm-project/llvm/tools/llvm-exegesis/lib/X86/Target.cpp:52:33: error: unused variable 'VAddressSpaceCeiling' [-Werror,-Wunused-const-variable]
      static constexpr const intptr_t VAddressSpaceCeiling = 0x0000800000000000;
                                      ^
      1 error generated.
      62883d9f
    • Fangrui Song's avatar
    • Fangrui Song's avatar
    • Fangrui Song's avatar
      [MC] Add SMLoc to MCCFIInstruction · 665ccc19
      Fangrui Song authored
      to help debug and report better diagnostics for functions like
      relaxDwarfCallFrameFragment (D153167).
      
      In MCStreamer, some emitCFI* functions already take a SMLoc argument. Add a
      SMLoc argument to the remaining functions that generate a MCCFIInstruction.
      665ccc19
    • Jason Molenda's avatar
      FileSystem::EnumerateDirectory should skip entries w/o Status, not halt · 2c1108f4
      Jason Molenda authored
      EnumerateDirectory gets the vfs::Status of each directory entry to
      decide how to process it.  If it is unable to get the Status for
      a directory entry, it will currently halt the directory iteration
      entirely.  It should only skip this entry.
      
      Differential Revision: https://reviews.llvm.org/D153822
      rdar://110861210
      2c1108f4
    • Hongtao Yu's avatar
      [CSSPGO][Preinliner] Bump up the threshold to favor previous compiler inline decision. · 5cbcaf16
      Hongtao Yu authored
      The compiler has more insight and knowledge about functions based on their IR and attribures and should make a better inline decision than the offline preinliner does which is purely based on callsites hotness and code size.  Therefore I'm making changes to favor previous compiler inline decision by bumping up the callsite allowance.
      
      This should improve the performance by more than 1% according to testing on Meta services.
      
      Reviewed By: wenlei
      
      Differential Revision: https://reviews.llvm.org/D153797
      5cbcaf16
    • LLVM GN Syncbot's avatar
      [gn build] Port 12e9c7aa · 7c653d48
      LLVM GN Syncbot authored
      7c653d48
    • William Huang's avatar
      [llvm-profdata] Refactoring Sample Profile Reader to increase FDO build speed... · 12e9c7aa
      William Huang authored
      [llvm-profdata] Refactoring Sample Profile Reader to increase FDO build speed using MD5 as key to Sample Profile map
      
      This is phase 1 of multiple planned improvements on the sample profile loader.   The major change is to use MD5 hash code ((instead of the function itself) as the key to look up the function offset table and the profiles, which significantly reduce the time it takes to construct the map.
      
      The optimization is based on the fact that many practical sample profiles are using MD5 values for function names to reduce profile size, so we shouldn't need to convert the MD5 to a string and then to a SampleContext and use it as the map's key, because it's extremely slow.
      
      Several changes to note:
      
      (1) For non-CS SampleContext, if it is already MD5 string, the hash value will be its integral value, instead of hashing the MD5 again. In phase 2 this is going to be optimized further using a union to represent MD5 function (without converting it to string) and regular function names.
      
      (2) The SampleProfileMap is a wrapper to *map<uint64_t, FunctionSamples>, while providing interface allowing using SampleContext as key, so that existing code still work. It will check for MD5 collision (unlikely but not too unlikely, since we only takes the lower 64 bits) and handle it to at least guarantee compilation correctness (conflicting old profile is dropped, instead of returning an old profile with inconsistent context). Other code should not try to use MD5 as key to access the map directly, because it will not be able to handle MD5 collision at all. (see exception at (5) )
      
      (3) Any SampleProfileMap::emplace() followed by SampleContext assignment if newly inserted, should be replaced with SampleProfileMap::Create(), which does the same thing.
      
      (4) Previously we ensure an invariant that in SampleProfileMap, the key is equal to the Context of the value, for profile map that is eventually being used for output (as in llvm-profdata/llvm-profgen). Since the key became MD5 hash, only the value keeps the context now, in several places where an intermediate SampleProfileMap is created, each new FunctionSample's context is set immediately after insertion, which is necessary to "remember" the context otherwise irretrievable.
      
      (5) When reading a profile, we cache the MD5 values of all functions, because they are used at least twice (one to index into FuncOffsetTable, the other into SampleProfileMap, more if there are additional sections), in this case the SampleProfileMap is directly accessed with MD5 value so that we don't recalculate it each time (expensive)
      
      Performance impact:
      When reading a ~1GB extbinary profile (fixed length MD5, not compressed) with 10 million function names and 2.5 million top level functions (non CS functions, each function has varying nesting level from 0 to 20), this patch improves the function offset table loading time by 20%, and improves full profile read by 5%.
      
      Reviewed By: davidxl, snehasish
      
      Differential Revision: https://reviews.llvm.org/D147740
      12e9c7aa
    • River Riddle's avatar
      [mlir][bytecode] Fix lazy loading of non-isolated regions · 6ee1aba8
      River Riddle authored
      The bytecode reader currently assumes all regions can be lazy
      loaded, which breaks reading any non-isolated region. This patch
      fixes that by properly handling nested non-lazy regions, and only
      considers isolated regions as lazy.
      
      Differential Revision: https://reviews.llvm.org/D153795
      6ee1aba8
    • Benjamin Kramer's avatar
      a1826647
    • Petr Hosek's avatar
      [Driver][BareMetal] Support --emit-static-lib in BareMetal driver · 5614d1a0
      Petr Hosek authored
      This allows building static libraries with Clang driver.
      
      Differential Revision: https://reviews.llvm.org/D148869
      5614d1a0
    • Alex MacLean's avatar
      [SelectionDAG] Add memory size for CSEMap ID calculation · 17aa37dd
      Alex MacLean authored
      In NVPTX `ReplaceVectorLoad()`, i1 and i8 types are promoted to i16,
      followed by a truncate operation. Thus, v2i8 (or v2i1) and v2i16 will
      have the same VTList, which causes a collision in CSEMap.
      
      To differentiate the original VTList, let's add the size in generating
      an ID. Otherwise the compiler crashes in refineAlignment:
      `MMO->getSize() == getSize() && "Size mismatch!"`
      
      Reviewed By: craig.topper
      
      Differential Revision: https://reviews.llvm.org/D153712
      17aa37dd
    • Jerry Wu's avatar
      [mlir] Add pattern to handle trivial shape_cast in SPIR-V · 405d6cad
      Jerry Wu authored
      Handle the trivial case of size-1 vector.shape_cast.
      
      Differential Revision: https://reviews.llvm.org/D153719
      405d6cad
    • Jim Ingham's avatar
      Don't allow SBValue::Cast to cast from a smaller type to a larger, · f05e2fb0
      Jim Ingham authored
      as we don't in general know where the extra data should come from.
      
      Differential Revision: https://reviews.llvm.org/D153657
      f05e2fb0
    • fernandosalas's avatar
      [scudo] Secondary Cache Dump · 4cf35a85
      fernandosalas authored
      Dumped some basic info about what is being cached and about the cache
      itself. Output of test below:
      
      ...
      Stats: MapAllocatorCache: EntriesCount: 33, MaxEntriesCount: 64, MaxEntrySize: 1048576
      StartBlockAddress: 0x6d342c1000, EndBlockAddress: 0x6d342d2000, BlockSize: 69632
      StartBlockAddress: 0x6fc45ff000, EndBlockAddress: 0x6fc462f000, BlockSize: 196608
      ...
      
      Reviewed By: Chia-hungDuan
      
      Differential Revision: https://reviews.llvm.org/D153483
      4cf35a85
    • Riley's avatar
      [scudo] Fix data leak in wrappers_c_test.cpp · 01c02abc
      Riley authored
      In SmallAlign implemented deallocation for the pointers
      
      Reviewed By: cferris, Chia-hungDuan
      
      Differential Revision: https://reviews.llvm.org/D153480
      01c02abc
    • Chia-hung Duan's avatar
      [scudo] Fix insufficient blocks when pushing BatchClass blocks · b3e42830
      Chia-hung Duan authored
      `populateFreeListAndPopBatch` may return batch with single block. Merge
      it with the reported free blocks and enqueue them together.
      
      Reviewed By: cferris, fabio-d
      
      Differential Revision: https://reviews.llvm.org/D153787
      b3e42830
    • Eduard Zingerman's avatar
      [BPF] Propagate NoMerge attribute when lowering function calls · 6a6db74b
      Eduard Zingerman authored
      `NoMerge` attribute on machine instructions prevents certain
      transformations from merging these instructions.
      One of such transformations is 'llvm/lib/CodeGen/BranchFolding.cpp'.
      
      This attribute should be copied from IR `call` instructions to machine
      level instructions. See `X86TargetLowering::LowerCall` as another
      example.
      
      Differential Revision: https://reviews.llvm.org/D152987
      6a6db74b
    • Eduard Zingerman's avatar
      [clang] Allow 'nomerge' attribute for function pointers · 06eee734
      Eduard Zingerman authored
      Allow specifying 'nomerge' attribute for function pointers,
      e.g. like in the following C code:
      
          extern void (*foo)(void) __attribute__((nomerge));
          void bar(long i) {
            if (i)
              foo();
            else
              foo();
          }
      
      With the goal to attach 'nomerge' to both calls done through 'foo':
      
          @foo = external local_unnamed_addr global ptr, align 8
          define dso_local void @bar(i64 noundef %i) local_unnamed_addr #0 {
            ; ...
            %0 = load ptr, ptr @foo, align 8, !tbaa !5
            ; ...
          if.then:
            tail call void %0() #1
            br label %if.end
          if.else:
            tail call void %0() #1
            br label %if.end
          if.end:
            ret void
          }
          ; ...
          attributes #1 = { nomerge ... }
      
      Report a warning in case if 'nomerge' is specified for a variable that
      is not a function pointer, e.g.:
      
          t.c:2:22: warning: 'nomerge' attribute is ignored because 'j' is not a function pointer [-Wignored-attributes]
              2 | int j __attribute__((nomerge));
                |                      ^
      
      The intended use-case is for BPF backend.
      
      BPF provides a sort of "standard library" functions that are called
      helpers. BPF also verifies usage of these helpers before program
      execution. Because of limitations of verification / runtime model it
      is important to keep calls to some of such helpers from merging.
      
      An example could be found by the link [1], there input C code:
      
           if (data_end - data > 1024) {
               bpf_for_each_map_elem(&map1, cb, &cb_data, 0);
           } else {
               bpf_for_each_map_elem(&map2, cb, &cb_data, 0);
           }
      
      Is converted to bytecode equivalent to:
      
           if (data_end - data > 1024)
             tmp = &map1;
           else
             tmp = &map2;
           bpf_for_each_map_elem(tmp, cb, &cb_data, 0);
      
      However, BPF verification/runtime requires to use the same map address
      for each particular `bpf_for_each_map_elem()` call.
      
      The 'nomerge' attribute is a perfect match for this situation, but
      unfortunately BPF helpers are declared as pointers to functions:
      
          static long (*bpf_for_each_map_elem)(void *map, ...) = (void *) 164;
      
      Hence, this commit, allowing to use 'nomerge' for function pointers.
      
      [1] https://lore.kernel.org/bpf/03bdf90f-f374-1e67-69d6-76dd9c8318a4@meta.com/
      
      Differential Revision: https://reviews.llvm.org/D152986
      06eee734
    • Kelvin Li's avatar
      [flang] Fix flang-aarch64-latest-gcc build failure due to f295c889 · d45b1b6b
      Kelvin Li authored
      Insert a return statement
      d45b1b6b
    • Alex Langford's avatar
      [lldb] Increase the maximum number of classes we can read from shared cache · 7ed3c2ed
      Alex Langford authored
      The shared cache has grown past the previously hardcoded limit. As a
      temporary measure, I am increasing the hardcoded number of classes we
      can expect to read from the shared cache. This is not a good long-term
      solution.
      
      Differential Revision: https://reviews.llvm.org/D153817
      7ed3c2ed
    • David Green's avatar
      [AArch64] Don't recreate nodes in tryCombineLongOpWithDup · aaca8e2c
      David Green authored
      If we don't find a node with either operand through
      isEssentiallyExtractHighSubvector, there is little point
      recreating the node with the same operands. Returning
      SDValue better communicates that no changes were made.
      
      This fixes #63491 by not recreating uabd nodes with swapped
      operands. As noted in the ticket there are other fixes that
      might be useful to make too, but this should prevent the
      infinite combine.
      aaca8e2c
    • Andres Villegas's avatar
      [llvm-libtool-darwin] Switch to OptTableSummary · 939c0351
      Andres Villegas authored
      Switch the parse of command line options fromllvm::cl to OptTable.
      The motivation for this change is to continue adding llvm based tools
      to the llvm driver multicall.
      
      Differential Revision: https://reviews.llvm.org/D153665
      939c0351
    • Douglas Yung's avatar
    • Fangrui Song's avatar
      [MC] Reject CFI advance_loc separated by a non-private label for Mach-O · 0b067277
      Fangrui Song authored
      Due to Mach-O's .subsections_via_symbols mechanism, non-private labels cannot
      appear between .cfi_startproc/.cfi_endproc. Compilers do not produce such
      labels, but hand-written assembly may. Give an error. Unfortunately,
      emitDwarfAdvanceFrameAddr generated MCExpr doesn't have location
      informatin.
      
      Note: evaluateKnownAbsolute is to force folding A-B to a constant even if A and
      B are separate by a non-private label. The function is a workaround for some
      Mach-O assembler issues and should generally be avoided.
      
      Reviewed By: efriedma
      
      Differential Revision: https://reviews.llvm.org/D153167
      0b067277