1. Jun 12, 2021
    • Uday Bondhugula's avatar
      [MLIR] Execution engine python binding support for shared libraries · c8b8e8e0
      Uday Bondhugula authored
      Add support to Python bindings for the MLIR execution engine to load a
      specified list of shared libraries - for eg. to use MLIR runtime
      utility libraries.
      
      Differential Revision: https://reviews.llvm.org/D104009
      c8b8e8e0
    • Kai Luo's avatar
      [AIX][compiler-rt] Fix cmake build of libatomic for cmake-3.16+ · 6393164c
      Kai Luo authored
      cmake-3.16+ for AIX changes the default behavior of building a `SHARED` library which breaks AIX's build of libatomic, i.e., cmake-3.16+ builds `SHARED` as an archive of dynamic libraries. To fix it, we have to build `libatomic.so.1` as `MODULE` which keeps `libatomic.so.1` as an normal dynamic library.
      
      Reviewed By: jsji
      
      Differential Revision: https://reviews.llvm.org/D103786
      6393164c
    • Adrian Prantl's avatar
      Allow signposts to take advantage of deferred string substitution · 4fc93a3a
      Adrian Prantl authored
      One nice feature of the os_signpost API is that format string
      substitutions happen in the consumer, not the logging
      application. LLVM's current Signpost class doesn't take advantage of
      this though and instead always uses a static "Begin/End %s" format
      string.
      
      This patch uses variadic macros to allow the API to be used as
      intended. Unfortunately, the primary use-case I had in mind (the
      LLDB_SCOPED_TIMER() macro) does not get much better from this, because
      __PRETTY_FUNCTION__ is *not* a macro, but a static string, so
      signposts created by LLDB_SCOPED_TIMER() still use a static "%s"
      format string. At least LLDB_SCOPED_TIMERF() works as intended.
      
      This reapplies the previsously reverted patch with support for
      platforms where signposts are unavailable.
      
      Differential Revision: https://reviews.llvm.org/D103575
      4fc93a3a
    • Jez Ng's avatar
      [lld-macho] Have dead-stripping work with literal sections · 464d3dc3
      Jez Ng authored
      Literal sections are not atomically live or dead. Rather,
      liveness is tracked for each individual literal they contain. CStrings
      have their liveness tracked via a `live` bit in StringPiece, and
      fixed-width literals have theirs tracked via a BitVector.
      
      The live-marking code now needs to track the offset within each section
      that is to be marked live, in order to identify the literal at that
      particular offset.
      
      Numbers for linking chromium_framework on my 3.2 GHz 16-Core Intel Xeon W
      with both `-dead_strip` and `--deduplicate-literals`, with and without this diff
      applied:
      
      ```
          N           Min           Max        Median           Avg        Stddev
      x  20          4.32          4.44         4.375         4.372    0.03105174
      +  20           4.3          4.39          4.36        4.3595   0.023277502
      No difference proven at 95.0% confidence
      ```
      This gives us size savings of about 0.4%.
      
      Reviewed By: #lld-macho, thakis
      
      Differential Revision: https://reviews.llvm.org/D103979
      464d3dc3
    • Jez Ng's avatar
      [lld-macho][nfc] Have InputSection ctors take some parameters · 681cfeb5
      Jez Ng authored
      This is motivated by an upcoming diff in which the
      WordLiteralInputSection ctor sets itself up based on the value of its
      section flags. As such, it needs to be passed the `flags` value as part
      of its ctor parameters, instead of having them assigned after the fact
      in `parseSection()`. While refactoring code to make that possible, I
      figured it would make sense for the other InputSections to also take
      their initial values as ctor parameters.
      
      Reviewed By: #lld-macho, thakis
      
      Differential Revision: https://reviews.llvm.org/D103978
      681cfeb5
    • Jez Ng's avatar
      [lld-macho][nfc] Move liveness-tracking fields into ConcatInputSection · 7f2ba39b
      Jez Ng authored
      These fields currently live in the parent InputSection class,
      but they should be specific to ConcatInputSection, since the other
      InputSection classes (that contain literals) aren't atomically live or
      dead -- rather their component string/int literals should have
      individual liveness states. (An upcoming diff will add liveness bits for
      StringPieces and fixed-sized literals.)
      
      I also factored out some asserts for isCoalescedWeak() in MarkLive.cpp.
      We now avoid putting coalesced sections in the `inputSections` vector,
      so we don't have to check/assert against it everywhere.
      
      Reviewed By: #lld-macho, thakis
      
      Differential Revision: https://reviews.llvm.org/D103977
      7f2ba39b
    • Jez Ng's avatar
      [lld-macho] Deduplicate fixed-width literals · 5d88f2dd
      Jez Ng authored
      Conceptually, the implementation is pretty straightforward: we put each
      literal value into a hashtable, and then write out the keys of that
      hashtable at the end.
      
      In contrast with ELF, the Mach-O format does not support variable-length
      literals that aren't strings. Its literals are either 4, 8, or 16 bytes
      in length. LLD-ELF dedups its literals via sorting + uniq'ing, but since
      we don't need to worry about overly-long values, we should be able to do
      a faster job by just hashing.
      
      That said, the implementation right now is far from optimal, because we
      add to those hashtables serially. To parallelize this, we'll need a
      basic concurrent hashtable (only needs to support concurrent writes w/o
      interleave reads), which shouldn't be to hard to implement, but I'd like
      to punt on it for now.
      
      Numbers for linking chromium_framework on my 3.2 GHz 16-Core Intel Xeon W:
      
            N           Min           Max        Median           Avg        Stddev
        x  20          4.27          4.39         4.315        4.3225   0.033225703
        +  20          4.36          4.82          4.44        4.4845    0.13152846
        Difference at 95.0% confidence
                0.162 +/- 0.0613971
                3.74783% +/- 1.42041%
                (Student's t, pooled s = 0.0959262)
      
      This corresponds to binary size savings of 2MB out of 335MB, or 0.6%.
      It's not a great tradeoff as-is, but as mentioned our implementation can
      be signficantly optimized, and literal dedup will unlock more
      opportunities for ICF to identify identical structures that reference
      the same literals.
      
      Reviewed By: #lld-macho, gkm
      
      Differential Revision: https://reviews.llvm.org/D103113
      5d88f2dd
    • Adrian Prantl's avatar
      Revert "Allow signposts to take advantage of deferred string substitution" · b90f9bea
      Adrian Prantl authored
      I forgot to make the LLDB macro conditional on Linux.
      
      This reverts commit 541ccd1c.
      b90f9bea
    • Andrew Litteken's avatar
      [IRSim] Strip out the findSimilarity call from the constructor · f6dea2e7
      Andrew Litteken authored
      Both doInitialize and runOnModule were running the entire analysis
      due to the actual work being done in the constructor. Strip it out here
      and only get the similarity during runOnModule.
      
      Author: lanza
      Reviewers: AndrewLitteken, paquette, plofti
      
      Differential Revision: https://reviews.llvm.org/D92524
      f6dea2e7
    • Adrian Prantl's avatar
      Disambiguate usage of struct mach_header and other MachO definitions. · 635b7213
      Adrian Prantl authored
      Unfortunately the Darwin signpost header also pulls in the system
      MachO header and so we need to make sure to use the LLVM versions of
      those definitions.
      635b7213
    • Adrian Prantl's avatar
      Allow signposts to take advantage of deferred string substitution · 541ccd1c
      Adrian Prantl authored
      One nice feature of the os_signpost API is that format string
      substitutions happen in the consumer, not the logging
      application. LLVM's current Signpost class doesn't take advantage of
      this though and instead always uses a static "Begin/End %s" format
      string.
      
      This patch uses variadic macros to allow the API to be used as
      intended. Unfortunately, the primary use-case I had in mind (the
      LLDB_SCOPED_TIMER() macro) does not get much better from this, because
      __PRETTY_FUNCTION__ is *not* a macro, but a static string, so
      signposts created by LLDB_SCOPED_TIMER() still use a static "%s"
      format string. At least LLDB_SCOPED_TIMERF() works as intended.
      
      Differential Revision: https://reviews.llvm.org/D103575
      541ccd1c
    • Alexander Shaposhnikov's avatar
      [llvm-objcopy][MachO] Do not strip symbols with the flag REFERENCED_DYNAMICALLY set · 0276cc74
      Alexander Shaposhnikov authored
      Do not strip symbols having the flag REFERENCED_DYNAMICALLY set.
      
      Test plan: make check-all
      
      Differential revision: https://reviews.llvm.org/D104092
      0276cc74
    • Reid Kleckner's avatar
    • Arthur Eubanks's avatar
      [NFC][OpaquePtr] Make getMemoryParamAllocType() compatible with opaque pointers · 37a2c451
      Arthur Eubanks authored
      These ABI attributes now always require the type parameter.
      
      sret was missing from the first set of checks but was covered by the
      second set.
      37a2c451
    • Sanjay Patel's avatar
    • Sanjay Patel's avatar
      [InstCombine] update test checks; NFC · ad1d60bf
      Sanjay Patel authored
      ad1d60bf
    • Kevin Athey's avatar
    • Kevin Athey's avatar
      [sanitizer] Replace -mllvm -asan-use-after-return in compile-rt tests with... · 60084d49
      Kevin Athey authored
      [sanitizer] Replace -mllvm -asan-use-after-return in compile-rt tests with -fsanitize-address-use-after-return (NFC)
      
      for issue: https://github.com/google/sanitizers/issues/1394
      
      Reviewed By: vitalybuka
      
      Differential Revision: https://reviews.llvm.org/D104146
      60084d49
    • Andrew Litteken's avatar
      [IRSim] Don't copy the Mapper for createCandidatesFromSuffixTree · 64720f57
      Andrew Litteken authored
      Every invocation this was copying the Mapper for no reason. Take a const
      ref instead.
      
      Author: lanza
      Reviewers: AndrewLitteken, plofti, paquette,
      
      Differential Review: https://reviews.llvm.org/D92532
      64720f57
    • Raphael Isemann's avatar
      [lldb] Remove GCC XFAIL for TestCPPAuto and TestClassTemplateParameterPack · 60fde954
      Raphael Isemann authored
      Both tests are passing for GCC>8 on Linux so let's mark them as passing.
      
      TestCPPAuto was originally disabled due to "an problem with debug info generation"
      in ea35dbef .
      
      TestClassTemplateParameterPack was disabled without explanation in
      0f01fb39 .
      60fde954
    • Roman Lebedev's avatar
      [NFC][X86][Codegen] Megacommit: mass-regenerate all check lines that were already autogenerated · 0aef747b
      Roman Lebedev authored
      The motivation is that the update script has at least two deviations
      (`<...>@GOT`/`<...>@PLT`/ and not hiding pointer arithmetics) from
      what pretty much all the checklines were generated with,
      and most of the tests are still not updated, so each time one of the
      non-up-to-date tests is updated to see the effect of the code change,
      there is a lot of noise. Instead of having to deal with that each
      time, let's just deal with everything at once.
      
      This has been done via:
      ```
      cd llvm-project/llvm/test/CodeGen/X86
      grep -rl "; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py" | xargs -L1 <...>/llvm-project/llvm/utils/update_llc_test_checks.py --llc-binary <...>/llvm-project/build/bin/llc
      ```
      
      Not all tests were regenerated, however.
      0aef747b
    • Daniil Fukalov's avatar
      [NFC][CostModel] Fixed comment that comparisons work regardless of the state. · 79ffbc9c
      Daniil Fukalov authored
      Reviewed By: sdesmalen
      
      Differential Revision: https://reviews.llvm.org/D104068
      79ffbc9c
    • Andrew Litteken's avatar
      Revert "[IRSim] Adding basic implementation of llvm-sim." · 8bc0eb40
      Andrew Litteken authored
      This reverts commit f47d00c5.
      8bc0eb40
    • Philip Reames's avatar
      Allow ptrtoint/inttoptr of non-integral pointer types in IR · ac81cb7e
      Philip Reames authored
      I don't like landing this change, but it's an acknowledgement of a practical reality.  Despite not having well specified semantics for inttoptr and ptrtoint involving non-integral pointer types, they are used in practice.  Here's a quick summary of the current pragmatic reality:
      * I happen to know that the main external user of non-integral pointers has effectively disabled the verifier rules.
      * RS4GC (the lowering pass for abstract GC machine model which is the key motivation for non-integral pointers), even supports them.  We just have all the tests using an integral pointer space to let the verifier run.
      * Certain idioms (such as alignment checks for alignment N, where any relocation is guaranteed to be N byte aligned) are fine in practice.
      * As implemented, inttoptr/ptrtoint are CSEd and are not control dependent.  This means that any code which is intending to check a particular bit pattern at site of use must be wrapped in an intrinsic or external function call.
      
      This change allows them in the Verifier, and updates the LangRef to specific them as implementation dependent.  This allows us to acknowledge current reality while still leaving ourselves room to punt on figuring out "good" semantics until the future.
      ac81cb7e
    • Alex Lorenz's avatar
      [clang][ObjC] allow the use of NSAttributedString * argument type with format attribute · 22dea692
      Alex Lorenz authored
      This is useful for APIs that want to accept an attributed NSString as their format string
      
      rdar://79163229
      22dea692
    • Andrew Litteken's avatar
      [IRSim] Adding basic implementation of llvm-sim. · f47d00c5
      Andrew Litteken authored
      This is a similarity visualization tool that accepts a Module and
      passes it to the IRSimilarityIdentifier.  The resulting SimilarityGroups
      are output in a JSON file.
      
      Tests are found in test/tools/llvm-sim and check for the file not found,
      a bad module, and that the JSON is created correctly.
      
      Reviewers: paquette, jroelofs, MaskRay
      
      Recommit of: 15645d04 to fix linking
      errors.
      
      Differential Revision: https://reviews.llvm.org/D86974
      f47d00c5
    • Arthur Eubanks's avatar
    • Marius Brehler's avatar
      [mlir][docs] Reorder PassWrapper arguments · f60d23c7
      Marius Brehler authored
      Fixes the order of template arguments passed to the `PassWrapper`.
      
      Reviewed By: mehdi_amini
      
      Differential Revision: https://reviews.llvm.org/D104132
      f60d23c7
    • Peter Steinfeld's avatar
      [flang] Handle multiple USE statements for the same module · 1b241b9b
      Peter Steinfeld authored
      It's possible to have several USE statements for the same module that
      have different mixes of rename clauses and ONLY clauses.  The presence
      of a rename cause has the effect of hiding a previously associated name,
      and the presence of an ONLY clause forces the name to be visible even in
      the presence of a rename.
      
      I fixed this by keeping track of the names that appear on rename and ONLY
      clauses.  Then, when processing the USE association of a name, I check to see
      if it previously appeared in a rename clause and not in a USE clause.  If so, I
      remove its USE associated symbol.  Also, when USE associating all of the names
      in a module, I do not USE associate names that have appeared in rename clauses.
      
      I also added a test.
      
      Differential Revision: https://reviews.llvm.org/D104130
      1b241b9b
    • Kevin Athey's avatar
      [clang-cl][sanitizer] Add -fsanitize-address-use-after-return to clang. · e0b469ff
      Kevin Athey authored
      Also:
        - add driver test (fsanitize-use-after-return.c)
        - add basic IR test (asan-use-after-return.cpp)
        - (NFC) cleaned up logic for generating table of __asan_stack_malloc
          depending on flag.
      
      for issue: https://github.com/google/sanitizers/issues/1394
      
      Reviewed By: vitalybuka
      
      Differential Revision: https://reviews.llvm.org/D104076
      e0b469ff
    • Arthur Eubanks's avatar
      [NFC][OpaquePtr] Explicitly pass GEP source type in optimizeGatherScatterInst() · c0c5a98b
      Arthur Eubanks authored
      Reviewed By: craig.topper
      
      Differential Revision: https://reviews.llvm.org/D103480
      c0c5a98b
    • John Paul Adrian Glaubitz's avatar
      [compiler-rt] Add platform detection support for x32 · 27ef43d2
      John Paul Adrian Glaubitz authored
      Currently, the compiler-rt build system checks only whether __X86_64
      is defined to determine whether the default compiler-rt target arch
      is x86_64. Since x32 defines __X86_64 as well, we must also check that
      the default pointer size is eight bytes and not four bytes to properly
      detect a 64-bit x86_64 compiler-rt default target arch.
      
      Reviewed By: hvdijk, vitalybuka
      
      Differential Revision: https://reviews.llvm.org/D99988
      27ef43d2
    • LLVM GN Syncbot's avatar
      [gn build] Port 7eba4856 · a67780f7
      LLVM GN Syncbot authored
      a67780f7
    • zoecarver's avatar
      [libcxx][ranges] Add class ref_view. · 7eba4856
      zoecarver authored
      Differential Revision: https://reviews.llvm.org/D102020
      7eba4856
    • Matt Arsenault's avatar
      AMDGPU/GlobalISel: Remove leftover hack for argument memory sizes · a845dc1e
      Matt Arsenault authored
      Since the call lowering code now tries to respect the tablegen
      reported argument types, this is no longer necessary.
      a845dc1e
    • Matt Arsenault's avatar
      AMDGPU/GlobalISel: Fix indentation · 6dd54dad
      Matt Arsenault authored
      6dd54dad
    • Matt Arsenault's avatar
      9d7299b6
    • Matt Arsenault's avatar
      CodeGen: Fix missing const · 93f3c7cc
      Matt Arsenault authored
      93f3c7cc
    • eahcmrh's avatar
      [Sema] Address-space sensitive check for unbounded arrays (v2) · ce44fe19
      eahcmrh authored
      Check applied to unbounded (incomplete) arrays and pointers to spot
      cases where the computed address is beyond the largest possible
      addressable extent of the array, based on the address space in which the
      array is delcared, or which the pointer refers to.
      
      Check helps to avoid cases of nonsense pointer math and array indexing
      which could lead to linker failures or runtime exceptions.  Of
      particular interest when building for embedded systems with small
      address spaces.
      
      This is version 2 of this patch -- version 1 had some testing issues
      due to a sign error in existing code.  That error is corrected and
      lit test for this chagne is extended to verify the fix.
      
      Originally reviewed/accepted by: aaron.ballman
      Original revision: https://reviews.llvm.org/D86796
      
      Reviewed By: aaron.ballman, ebevhan
      
      Differential Revision: https://reviews.llvm.org/D88174
      ce44fe19
    • Denys Shabalin's avatar
      Introduce alloca_scope op · fdc0d436
      Denys Shabalin authored
      ## Introduction
      
      This proposal describes the new op to be added to the `std` (and later moved `memref`)
      dialect called `alloca_scope`.
      
      ## Motivation
      
      Alloca operations are easy to misuse, especially if one relies on it while doing
      rewriting/conversion passes. For example let's consider a simple example of two
      independent dialects, one defines an op that wants to allocate on-stack and
      another defines a construct that corresponds to some form of looping:
      
      ```
      dialect1.looping_op {
        %x = dialect2.stack_allocating_op
      }
      ```
      
      Since the dialects might not know about each other they are going to define a
      lowering to std/scf/etc independently:
      
      ```
      scf.for … {
         %x_temp = std.alloca …
         … // do some domain-specific work using %x_temp buffer
         … // and store the result into %result
         %x = %result
      }
      ```
      
      Later on the scf and `std.alloca` is going to be lowered to llvm using a
      combination of `llvm.alloca` and unstructured control flow.
      
      At this point the use of `%x_temp` is bound to either be either optimized by
      llvm (for example using mem2reg) or in the worst case: perform an independent
      stack allocation on each iteration of the loop. While the llvm optimizations are
      likely to succeed they are not guaranteed to do so, and they provide
      opportunities for surprising issues with unexpected use of stack size.
      
      ## Proposal
      
      We propose a new operation that defines a finer-grain allocation scope for the
      alloca-allocated memory called `alloca_scope`:
      
      ```
      alloca_scope {
         %x_temp = alloca …
         ...
      }
      ```
      
      Here the lifetime of `%x_temp` is going to be bound to the narrow annotated
      region within `alloca_scope`. Moreover, one can also return values out of the
      alloca_scope with an accompanying `alloca_scope.return` op (that behaves
      similarly to `scf.yield`):
      
      ```
      %result = alloca_scope {
         %x_temp = alloca …
         …
         alloca_scope.return %myvalue
      }
      ```
      
      Under the hood the `alloca_scope` is going to lowered to a combination of
      `llvm.intr.stacksave` and `llvm.intr.strackrestore` that are going to be invoked
      automatically as control-flow enters and leaves the body of the `alloca_scope`.
      
      The key value of the new op is to allow deterministic guaranteed stack use
      through an explicit annotation in the code which is finer-grain than the
      function-level scope of `AutomaticAllocationScope` interface. `alloca_scope`
      can be inserted at arbitrary locations and doesn’t require non-trivial
      transformations such as outlining.
      
      ## Which dialect
      
      Before memref dialect is split, `alloca_scope` can temporarily reside in `std`
      dialect, and later on be moved to `memref` together with the rest of
      memory-related operations.
      
      ## Implementation
      
      An implementation of the op is available [here](https://reviews.llvm.org/D97768).
      
      Original commits:
      
      * Add initial scaffolding for alloca_scope op
      * Add alloca_scope.return op
      * Add no region arguments and variadic results
      * Add op descriptions
      * Add failing test case
      * Add another failing test
      * Initial implementation of lowering for std.alloca_scope
      * Fix backticks
      * Fix getSuccessorRegions implementation
      
      Reviewed By: ftynse
      
      Differential Revision: https://reviews.llvm.org/D97768
      fdc0d436