1. Jun 27, 2023
    • 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
    • yzhang93's avatar
      [mlir] Narrow bitwidth emulation for MemRef load · 5a1cdcbd
      yzhang93 authored
      This patch adds support for narrow bitwidth storage emulation. The goal is to support sub-byte type
      codegen for LLVM CPU. Specifically, a type converter is added to convert memref of narrow bitwidth
      (e.g., i4) into supported wider bitwidth (e.g., i8). Another focus of this patch is to populate the
      pattern for int4 memref.load. memref.store pattern should be added in a seperate patch.
      
      Reviewed By: hanchung, mravishankar
      
      Differential Revision: https://reviews.llvm.org/D151519
      5a1cdcbd
    • cabreraam's avatar
      [flang][hlfir] `hlfir.char_extremum` lowering · 7827beee
      cabreraam authored
      This patch implements the lowering for the `hlfir.char_extremum` operation.
      
      Discussion for this patch can be found in the draft patch [here](https://reviews.llvm.org/D143326). The reason
      for not promoting this draft to a true patch for review was because I needed to separate the op
      definition/codegen and lowering into two separate patches, as preferred by @jeanPerier.
      
      Depends on D152474
      
      Reviewed By: jeanPerier
      
      Differential Revision: https://reviews.llvm.org/D152475
      7827beee
    • Fangrui Song's avatar
    • Aiden Grossman's avatar
      [llvm-exegesis] Define SYS_mmap to be SYS_mmap2 on 32-bit ARM · 82909f4e
      Aiden Grossman authored
      llvm-exegesis currently isn't compiling on 32-bit ARM due to SYS_mmap
      not being defined as 32-bit ARM instead uses SYS_mmap2. This patch
      defines SYS_mmap to be SYS_mmap2 in the relevant places to allow for
      compilation to succeed.
      82909f4e
    • Matthias Braun's avatar
      Ignore load/store until stack address computation · 02ba5b8c
      Matthias Braun authored
      No longer conservatively assume a load/store accesses the stack when we
      can prove that we did not compute any stack-relative address up to this
      point in the program.
      
      We do this in a cheap not-quite-a-dataflow-analysis: Assume
      `NoStackAddressUsed` when all predecessors of a block already guarantee
      it. Process blocks in reverse post order to guarantee that except for
      loop headers we have processed all predecessors of a block before
      processing the block itself. For loops we accept the conservative answer
      as they are unlikely to be shrink-wrappable anyway.
      
      Differential Revision: https://reviews.llvm.org/D152213
      02ba5b8c
    • Matthias Braun's avatar
      Switch tests to use update_llc_test_checks · 759b2176
      Matthias Braun authored
      Switch and update some tests to use `update_llc_test_checks` to reduce
      clutter in upcoming change.
      
      Differential Revision: https://reviews.llvm.org/D152215
      759b2176
    • Aiden Grossman's avatar
      [llvm-exegesis] Define MAP_FIXED_NOREPLACE if not available · 4cdfdb5e
      Aiden Grossman authored
      Some builders are currently failing as they don't have
      MAP_FIXED_NOREPLACE available. This patch checks if MAP_FIXED_NOREPLACE
      is available and if it isn't, it is simply defined as MAP_FIXED.
      4cdfdb5e
    • Shubham Sandeep Rastogi's avatar
      Do not emit a named symbol to denote the start of the debug_frame section · 17202379
      Shubham Sandeep Rastogi authored
      When emitting a debug_frame section, it contains a named symbol.
      
      > echo "void foo(void) {}" | clang -arch arm64  -ffreestanding -g -c -o \
      /tmp/test.o -x c -
      > nm /tmp/test.o -s __DWARF __debug_frame
      0000000000000200 s ltmp1
      
      There are no such symbols emitted in any of the other DWARF sections,
      this is because when the __debug_frame section is created, it doesn't
      get a `BeginSymName` and so it creates a named symbol, such as `ltmp1`
      and emits it when we switch to the section in MCDwarf.cpp.
      
      This patch fixes the above issue.
      
      Differential Revision: https://reviews.llvm.org/D153484
      17202379
    • Aiden Grossman's avatar
      [llvm-exegesis] Explicitly link llvm-exegesis unit tests against librt · 3500d3ba
      Aiden Grossman authored
      On some platforms such as PPC shm_open is in librt and it isn't
      automatically linked against. This patch explicitly links against librt
      in the unittests which should hopefully fix the symbol resolution
      errors.
      3500d3ba
    • Diego Caballero's avatar
      [mlir][Vector] Fix vectorization of generic ops with transposed outputs · 13f15e8f
      Diego Caballero authored
      This patch fixes a bug in the way we compute the vector type for vector
      transfer writes when the value to store needs to be transposed.
      
      Reviewed By: nicolasvasilache, mravishankar
      
      Differential Revision: https://reviews.llvm.org/D153687
      13f15e8f
    • Nicolas Vasilache's avatar
      [mlir][linalg] Add named op for matmul_transpose_a · cb1911a2
      Nicolas Vasilache authored
      matmul with transposed LHS operand allows better memory access
      patterns on several architectures including common GPUs. Having a named
      op for it allows to handle this kind of matmul in a more explicit way.
      cb1911a2
    • LLVM GN Syncbot's avatar
      [gn build] Port f8927838 · d2b484ff
      LLVM GN Syncbot authored
      d2b484ff
    • LLVM GN Syncbot's avatar
      [gn build] Port 83f875dc · 40e19a0a
      LLVM GN Syncbot authored
      40e19a0a
    • Nico Weber's avatar
      [gn] prepare for porting f8927838 · aa2a4ce7
      Nico Weber authored
      aa2a4ce7
    • Aart Bik's avatar
      [mlir][sparse] minor code changes · 11a4f5bd
      Aart Bik authored
      Submitting for Wren
      
      Reviewed By: K-Wu
      
      Differential Revision: https://reviews.llvm.org/D153804
      11a4f5bd
    • Fangrui Song's avatar
      [bazel] Add includes after 5a63b2b3 · 19e9b9b5
      Fangrui Song authored
      19e9b9b5
    • Nicolas Vasilache's avatar
      [mlir][linalg] Add missing op to match the generated file · 9a592d82
      Nicolas Vasilache authored
      D141430 added the generated yaml file for (batch_)?matmul_transpose_b ops, but the source of truth core_named_ops.py was not updated.
      This change fixes .py file to generate the same result as the yaml file.
      
      Differential revision: https://reviews.llvm.org/D150059
      
      
      
      Authored-by: default avatarkon72 <kinsei0916@gmail.com>
      9a592d82
    • Philip Reames's avatar