1. Jan 14, 2021
    • Fangrui Song's avatar
      [test] Add Clang side tests for -fdebug-info-for-profiling · 74a42aed
      Fangrui Song authored
      There is currently a driver test but no test for its effect on linkageName & pass pipeline.
      
      Reviewed By: dblaikie
      
      Differential Revision: https://reviews.llvm.org/D94381
      74a42aed
    • Michael Jones's avatar
      [libc][NFC] change isblank and iscntrl from implicit casting · ea8034ec
      Michael Jones authored
      isblank and iscntrl were casting an int to a char implicitly and this
      was throwing errors under Fuchsia. I've added a static cast to resolve
      this issue.
      
      Reviewed By: sivachandra
      
      Differential Revision: https://reviews.llvm.org/D94634
      ea8034ec
    • Florian Hahn's avatar
      [DSE] Add tests with stores of existing values. · 6077d553
      Florian Hahn authored
      This patch pre-commits test cases with dead stores of
      existing values for D90328. It also updates a few tests that had such
      stores by accident, to preserve the original spirit of those tests.
      6077d553
    • Nikita Popov's avatar
      f711cb9a
    • Kazu Hirata's avatar
      Fix the warnings on unused variables (NFC) · fb98a1be
      Kazu Hirata authored
      fb98a1be
    • Michael Jones's avatar
      [libc][NFC] add macro for fuchsia to switch test backend to zxtest · 4cfccd51
      Michael Jones authored
      This moves utils/UnitTest/Test.[h/cpp] to LibcTest.[h/cpp] and adds a
      new Test.h that acts as a switcher so that Fuchsia can use the zxtest
      backend for running our tests as part of their build.
      
      FuchsiaTest.h is for including fuchsia's zxtest library and anything
      else needed to make the tests work under fuchsia (currently just
      undefining the isascii macro for the test).
      
      Downstream users, please fix your build instead of reverting.
      
      Reviewed By: sivachandra
      
      Differential Revision: https://reviews.llvm.org/D94625
      4cfccd51
    • Tim Keith's avatar
      [flang] Fix accessibility of USEd name in .mod file · 18278ff1
      Tim Keith authored
      If a module specifies default private accessibility, names that have
      been use-associated are private by default. This was not reflected in
      .mod files.
      
      Differential Revision: https://reviews.llvm.org/D94602
      18278ff1
    • Florian Hahn's avatar
      [LTO] Add test for freestanding LTO option. · 01c31358
      Florian Hahn authored
      This patch adds a test for the -lto-freestanding option, similar to
      llvm/test/ThinLTO/X86/tli-nobuiltin.ll.
      01c31358
    • Aart Bik's avatar
      [mlir][sparse] add vectorization strategies to sparse compiler · f4f158b2
      Aart Bik authored
      Similar to the parallelization strategies, the vectorization strategies
      provide control on what loops should be vectorize. Unlike the parallel
      strategies, only innermost loops are considered, but including reductions,
      with the control of vectorizing dense loops only or dense and sparse loops.
      
      The vectorized loops are always controlled by a vector mask to avoid
      overrunning the iterations, but subsequent vector operation folding removes
      redundant masks and replaces the operations with more efficient counterparts.
      Similarly, we will rely on subsequent loop optimizations to further optimize
      masking, e.g. using an unconditional full vector loop and scalar cleanup loop.
      
      The current strategy already demonstrates a nice interaction between the
      sparse compiler and all prior optimizations that went into the vector dialect.
      
      Ongoing discussion at:
      https://llvm.discourse.group/t/mlir-support-for-sparse-tensors/2020/10
      
      Reviewed By: penpornk
      
      Differential Revision: https://reviews.llvm.org/D94551
      f4f158b2
    • Jeroen Dobbelaere's avatar
      [NFC] Use correct ssa.copy spelling when referring to the intrinsic · bb72adca
      Jeroen Dobbelaere authored
      Split out from D91250. Fixes wrong ssa_copy naming.
      
      Reviewed By: fhahn
      
      Differential Revision: https://reviews.llvm.org/D94310
      bb72adca
    • Alexandre Ganea's avatar
      [LLD][COFF] Avoid std::vector resizes during type merging · e7a371f9
      Alexandre Ganea authored
      Consistently saves approx. 0.6 sec (out of 18 sec) on a large output (400 MB EXE, 2 GB PDB).
      
      Differential Revision: https://reviews.llvm.org/D94555
      e7a371f9
    • Tres Popp's avatar
      [mlir] Correct 2 places that result in corrupted conversion rollbacks · 3bd620d4
      Tres Popp authored
      This corrects the last 2 issues caught by tests when causing dialect
      conversion rollbacks to occur.
      
      Differential Revision: https://reviews.llvm.org/D94623
      3bd620d4
    • wlei's avatar
      [NFC] fix missing SectionName declaration · 33a84665
      wlei authored
      33a84665
    • wlei's avatar
      [CSSPGO][llvm-profgen] Virtual unwinding with pseudo probe · c681400b
      wlei authored
      This change extends virtual unwinder to support pseudo probe in llvm-profgen. Please refer https://groups.google.com/g/llvm-dev/c/1p1rdYbL93s and https://reviews.llvm.org/D89707 for more context about CSSPGO and llvm-profgen.
      
      **Implementation**
      
      - Added `ProbeBasedCtxKey` derived from `ContextKey` for sample counter aggregation. As we need string splitting to infer the profile for callee function, string based context introduces more string handling overhead, here we just use probe pointer based context.
      - For linear unwinding, as inline context is encoded in each pseudo probe, we don't need to go through each instruction to extract range sharing same inliner. So just record the range for the context.
      - For probe based context, we should ignore the top frame probe since it will be extracted from the address range. we defer the extraction in `ProfileGeneration`.
      - Added `PseudoProbeProfileGenerator` for pseudo probe based profile generation.
      - Some helper function to get pseduo probe info(call probe, inline context) from profiled binary.
      - Added regression test for unwinder's output
      
      The pseudo probe based profile generation will be in the upcoming patch.
      
      Test Plan:
      
      ninja & ninja check-llvm
      
      Differential Revision: https://reviews.llvm.org/D92896
      c681400b
    • wlei's avatar
      [CSSPGO][llvm-profgen] Refactor to unify hashable interface for trace sample... · 414930b9
      wlei authored
      [CSSPGO][llvm-profgen] Refactor to unify hashable interface for trace sample and context-sensitive counter
      
      As we plan to support both CSSPGO and AutoFDO for llvm-profgen, we will have different kinds of perf sample and different kinds of sample counter(cs/non-cs, with/without pseudo probe) which both need to do aggregation in hash map.  This change implements the hashable interface(`Hashable`) and the unified base class for them to have better extensibility and reusability.
      
      Currently perf trace sample and sample counter with context implemented this `Hashable` and  the class hierarchy is like:
      
      ```
      | Hashable
                 | PerfSample
                                | HybridSample
                                | LBRSample
                 | ContextKey
                                | StringBasedCtxKey
                                | ProbeBasedCtxKey
                                | CallsiteBasedCtxKey
                 | ...
      ```
      
      - Class specifying `Hashable` should implement `getHashCode` and `isEqual`. Here we make `getHashCode` a non-virtual function to avoid vtable overhead, so derived class should calculate and assign the base class's HashCode manually. This also provides the flexibility for calculating the hash code incrementally(like rolling hash) during frame stack unwinding
      - `isEqual` is a virtual function, which will have perf overhead. In the future, if we redesign a better hash function, then we can just skip this or switch to non-virtual function.
      - Added `PerfSample` and `ContextKey` as base class for perf sample and counter context key, leveraging llvm-style RTTI for this.
      - Added `StringBasedCtxKey` class extending  `ContextKey` to use string as context id.
      - Refactor `AggregationCounter` to take all kinds of `PerfSample` as key
      - Refactor `ContextSampleCounter` to take all kinds of `ContextKey` as key
      - Other refactoring work:
       - Create a wrapper class `SampleCounter` to wrap `RangeCounter` and `BranchCounter`
       - Hoist `ContextId` and `FunctionProfile` out of `populateFunctionBodySamples` and `populateFunctionBoundarySamples` to reuse them in ProfileGenerator
      
      Differential Revision: https://reviews.llvm.org/D92584
      414930b9
    • wlei's avatar
      [CSSPGO][llvm-profgen] Pseudo probe decoding and disassembling · b3154d11
      wlei authored
      This change implements pseudo probe decoding and disassembling for llvm-profgen/CSSPGO. Please see https://groups.google.com/g/llvm-dev/c/1p1rdYbL93s and https://reviews.llvm.org/D89707 for more context about CSSPGO and llvm-profgen.
      
      **ELF section format**
      Please see the encoding patch(https://reviews.llvm.org/D91878) for more details of the format, just copy the example here:
      
      Two section(`.pseudo_probe_desc` and  `.pseudoprobe` ) is emitted in ELF to support pseudo probe.
      The format of `.pseudo_probe_desc` section looks like:
      
      ```
      .section   .pseudo_probe_desc,"",@progbits
      .quad   6309742469962978389  // Func GUID
      .quad   4294967295           // Func Hash
      .byte   9                    // Length of func name
      .ascii  "_Z5funcAi"          // Func name
      .quad   7102633082150537521
      .quad   138828622701
      .byte   12
      .ascii  "_Z8funcLeafi"
      .quad   446061515086924981
      .quad   4294967295
      .byte   9
      .ascii  "_Z5funcBi"
      .quad   -2016976694713209516
      .quad   72617220756
      .byte   7
      .ascii  "_Z3fibi"
      ```
      
      For each `.pseudoprobe` section, the encoded binary data consists of a single function record corresponding to an outlined function (i.e, a function with a code entry in the `.text` section). A function record has the following format :
      
      ```
      FUNCTION BODY (one for each outlined function present in the text section)
          GUID (uint64)
              GUID of the function
          NPROBES (ULEB128)
              Number of probes originating from this function.
          NUM_INLINED_FUNCTIONS (ULEB128)
              Number of callees inlined into this function, aka number of
              first-level inlinees
          PROBE RECORDS
              A list of NPROBES entries. Each entry contains:
                INDEX (ULEB128)
                TYPE (uint4)
                  0 - block probe, 1 - indirect call, 2 - direct call
                ATTRIBUTE (uint3)
                  reserved
                ADDRESS_TYPE (uint1)
                  0 - code address, 1 - address delta
                CODE_ADDRESS (uint64 or ULEB128)
                  code address or address delta, depending on ADDRESS_TYPE
          INLINED FUNCTION RECORDS
              A list of NUM_INLINED_FUNCTIONS entries describing each of the inlined
              callees.  Each record contains:
                INLINE SITE
                  GUID of the inlinee (uint64)
                  ID of the callsite probe (ULEB128)
                FUNCTION BODY
                  A FUNCTION BODY entry describing the inlined function.
      ```
      
      **Disassembling**
      A switch `--show-pseudo-probe` is added to use along with `--show-disassembly` to print disassembly code with pseudo probe directives.
      
      For example:
      ```
      00000000002011a0 <foo2>:
        2011a0: 50                    push   rax
        2011a1: 85 ff                 test   edi,edi
        [Probe]:  FUNC: foo2  Index: 1  Type: Block
        2011a3: 74 02                 je     2011a7 <foo2+0x7>
        [Probe]:  FUNC: foo2  Index: 3  Type: Block
        [Probe]:  FUNC: foo2  Index: 4  Type: Block
        [Probe]:  FUNC: foo   Index: 1  Type: Block  Inlined: @ foo2:6
        2011a5: 58                    pop    rax
        2011a6: c3                    ret
        [Probe]:  FUNC: foo2  Index: 2  Type: Block
        2011a7: bf 01 00 00 00        mov    edi,0x1
        [Probe]:  FUNC: foo2  Index: 5  Type: IndirectCall
        2011ac: ff d6                 call   rsi
        [Probe]:  FUNC: foo2  Index: 4  Type: Block
        2011ae: 58                    pop    rax
        2011af: c3                    ret
      ```
      
      **Implementation**
      - `PseudoProbeDecoder` is added in ProfiledBinary as an infra for the decoding. It decoded the two section and generate two map: `GUIDProbeFunctionMap` stores all the `PseudoProbeFunction` which is the abstraction of a general function. `AddressProbesMap` stores all the pseudo probe info indexed by its address.
      - All the inline info is encoded into binary as a trie(`PseudoProbeInlineTree`) and will be constructed from the decoding. Each pseudo probe can get its inline context(`getInlineContext`) by traversing its inline tree node backwards.
      
      Test Plan:
      ninja & ninja check-llvm
      
      Differential Revision: https://reviews.llvm.org/D92334
      b3154d11
    • peter klausler's avatar
      [flang] Do not create HostAssoc symbols in derived type scopes · 166e5c33
      peter klausler authored
      When needed due to a specification expression in a derived type,
      the host association symbols should be created in the surrounding
      subprogram's scope instead.
      
      Differential Revision: https://reviews.llvm.org/D94567
      166e5c33
    • Sanjay Patel's avatar
      [SLP] simplify type check for reductions · 123674a8
      Sanjay Patel authored
      This is NFC-intended. The 'valid' call allows int/FP/pointers
      for other parts of SLP. The difference here is that we can't
      reduce pointers.
      123674a8
    • Krzysztof Parzyszek's avatar
      a2e6506c
    • peter klausler's avatar
      [flang] Fix classification of shape inquiries in specification exprs · a50bb84e
      peter klausler authored
      In some contexts, including the motivating case of determining whether
      the expressions that define the shape of a variable are "constant expressions"
      in the sense of the Fortran standard, expression rewriting via Fold()
      is not necessary, and should not be required.  The inquiry intrinsics LBOUND,
      UBOUND, and SIZE work correctly now in specification expressions and are
      classified correctly as being constant expressions (or not).  Getting this right
      led to a fair amount of API clean-up as a consequence, including the
      folding of shapes and TypeAndShape objects, and new APIs for shapes
      that do not fold for those cases where folding isn't needed.  Further,
      the symbol-testing predicate APIs in Evaluate/tools.h now all resolve any
      associations of their symbols and work transparently on use-, host-, and
      construct-association symbols; the tools used to resolve those associations have
      been defined and documented more precisely, and their clients adjusted as needed.
      
      Differential Revision: https://reviews.llvm.org/D94561
      a50bb84e
    • LLVM GN Syncbot's avatar
      [gn build] Port 60fda8eb · 14f322f0
      LLVM GN Syncbot authored
      14f322f0
    • Sam Tebbs's avatar
      [ARM] Add a pass that re-arranges blocks when there is a backwards WLS branch · 60fda8eb
      Sam Tebbs authored
      Blocks can be laid out such that a t2WhileLoopStart branches backwards. This is forbidden by the architecture and so it fails to be converted into a low-overhead loop. This new pass checks for these cases and moves the target block, fixing any fall-through that would then be broken.
      
      Differential Revision: https://reviews.llvm.org/D92385
      60fda8eb
    • Simon Pilgrim's avatar
    • Simon Pilgrim's avatar
    • Simon Pilgrim's avatar
      [X86][SSE] canonicalizeShuffleMaskWithHorizOp - simplify... · cbbfc825
      Simon Pilgrim authored
      [X86][SSE] canonicalizeShuffleMaskWithHorizOp - simplify shuffle(HOP(HOP(X,Y),HOP(Z,W))) style chains.
      
      See if we can remove the shuffle by resorting a HOP chain so that the HOP args are pre-shuffled.
      
      This initial version just handles (the most common) v4i32/v4f32 hadd/hsub reduction patterns - future work can extend this to v8i16 types plus PACK chains (2f64 HADD/HSUB should already be handled in the half-lane combine code later on).
      cbbfc825
    • Jonas Devlieghere's avatar
      [dsymutil] Warn on timestmap mismatch between object file and debug map · 48d2068f
      Jonas Devlieghere authored
      This re-lands e5553b9a with two small fixes to the tests:
      
       - Don't touch the source directory in debug-map-parsing.test but
         instead copy everything over in a temporary directory in
         timestamp-mismatch.test.
       - Don't redirect stderr to stdout to avoid the output getting
         intertwined in extern-alias.test.
      48d2068f
    • Andrew Litteken's avatar
      [IROutliner] Adapting to hoisted bitcasts in CodeExtractor · 05b1a15f
      Andrew Litteken authored
      In commit 700d2417 the CodeExtractor
      was updated so that bitcasts that have lifetime markers that beginning
      outside of the region are deduplicated outside the region and are not
      used as an output.  This caused a discrepancy in the IROutliner, where
      in these cases there were arguments added to the aggregate function
      that were not needed causing assertion errors.
      
      The IROutliner queries the CodeExtractor twice to determine the inputs
      and outputs, before and after `findAllocas` is called with the same
      ValueSet for the outputs causing the duplication. This has been fixed
      with a dummy ValueSet for the first call.
      
      However, the additional bitcasts prevent us from using the same
      similarity relationships that were previously defined by the
      IR Similarity Analysis Pass. In these cases, we check whether the
      initial version of the region being analyzed for outlining is still the
      same as it was previously.  If it is not, i.e. because of the additional
      bitcast instructions from the CodeExtractor, we discard the region.
      
      Reviewers: yroux
      
      Differential Revision: https://reviews.llvm.org/D94303
      05b1a15f
    • Sam McCall's avatar
    • Utkarsh Saxena's avatar
      [clangd] Remove "decision-forest-base" experimental flag. · a4f38668
      Utkarsh Saxena authored
      The value of this flag can only be fine tuned by using A/B testing on large
      user base.
      We do not expect individual users to use and fine tune this flag.
      
      Differential Revision: https://reviews.llvm.org/D94513
      a4f38668
    • Nikita Popov's avatar
      [InstCombine] Fold select -> and/or using impliesPoison · 17863614
      Nikita Popov authored
      We can fold a ? b : false to a & b if is_poison(b) implies that
      is_poison(a), at which point we're able to reuse all the usual fold
      on ands. In particular, this covers the very common case of
      icmp X, C && icmp X, C'. The same applies to ors.
      
      This currently only has an effect if the
      -instcombine-unsafe-select-transform=0 option is set.
      
      Differential Revision: https://reviews.llvm.org/D94550
      17863614
    • Sanjay Patel's avatar
      [SLP] add reduction test for FMF; NFC · e433ca28
      Sanjay Patel authored
      e433ca28
    • Sam McCall's avatar
      [clangd] Avoid reallocating buffers for each message read: · 466acd69
      Sam McCall authored
       - reuse std::string we read messages into
       - when reading line-wise, use SmallVector<128> and read in chunks of 128
         (this affects headers, which are short, and tests, which don't matter)
      
      Differential Revision: https://reviews.llvm.org/D93653
      466acd69
    • Sam McCall's avatar
      [clangd] Explicitly avoid background-indexing the same file twice. · 66d5994b
      Sam McCall authored
      This used to implicitly never happen due to only discovering each CDB
      once.
      
      We may want to carefully support reindexing one day, but we need to do
      it carefully (tricky tradeoffs) and it would need further support in
      background indexer.
      
      Making this explicit here rather than just turning off rebroadcast in
      background index for a few reasons:
      - allows *new* files in the same CDB to be indexed
      - relying on bugs-at-a-distance cancelling each other out is bound to bite us
      - gets us closer to actually supporting reindexing, which requires similar tracking
      
      Differential Revision: https://reviews.llvm.org/D94503
      66d5994b
    • Terry Wilmarth's avatar
      [OpenMP] Fix hierarchical barrier · 4fe17ada
      Terry Wilmarth authored
      Hierarchical barrier is an experimental barrier algorithm that uses aspects
      of machine hierarchy to define the barrier tree structure. This patch fixes
      offset calculation in hierarchical barrier. The offset is used to store info
      on a flag about sleeping threads waiting on a location stored in the flag.
      This commit also fixes a potential deadlock in hierarchical barrier when
      using infinite blocktime by adjusting the offset value of leaf kids so that
      it matches the value of leaf state. It also adds testing of default barriers
      with infinite blocktime, and also tests hierarchical barrier algorithm with
      both default and infinite blocktime.
      
      Patch by Terry Wilmarth and Nawrin Sultana.
      
      Differential Revision: https://reviews.llvm.org/D94241
      4fe17ada
    • Joseph Huber's avatar
      [OpenMP] Add documentation for error messages and release notes · a9576349
      Joseph Huber authored
      Add extra information to the runtime page describing the error messages and add information to the release notes for clang 12.0
      
      Reviewed By: jdoerfert
      
      Differential Revision: https://reviews.llvm.org/D94562
      a9576349
  2. Jan 13, 2021
    • Xiangling Liao's avatar
      [Frontend] Add pragma align natural and sort out pragma pack stack effect · f0abe2ae
      Xiangling Liao authored
      - Implemente the natural align for XL on AIX
      - Sort out pragma pack stack effect
      - Add -fxl-pragma-stack option to enable XL on AIX pragma stack effect
      
      Differential Revision: https://reviews.llvm.org/D87702
      f0abe2ae
    • Sam Clegg's avatar
      [lld][WebAssembly] Fix for TLS + --relocatable · 07b6aeb5
      Sam Clegg authored
      When running in `-r/--relocatable` we output relocations but the
      new TLS relocations type was missing from `ObjFile::calcNewAddend`
      causing this combination of inputs/flags to crash the linker.
      
      Also avoid creating tls variables in relocatable mode.  These variables
      are only needed when linking final executables.
      
      Fixes: https://github.com/emscripten-core/emscripten/issues/12934
      Fixes: PR48506
      
      Differential Revision: https://reviews.llvm.org/D93554
      07b6aeb5
    • Muhammad Asif Manzoor's avatar
      [AArch64][GlobalISel] Add support for FCONSTANT of FP128 type · 4e8e8889
      Muhammad Asif Manzoor authored
      Add support for G_FCONSTANT of FP128 (Quadruple precision) type.
      It replaces the constant by emitting a load with a constant pool entry.
      
      Reviewed By: aemerson
      
      Differential Revision: https://reviews.llvm.org/D94437
      4e8e8889
    • Hsiangkai Wang's avatar
    • Matt Arsenault's avatar
      GlobalISel: Do not set observer of MachineIRBuilder in LegalizerHelper · d55d592a
      Matt Arsenault authored
      This fixes double printing of insertion debug messages in the
      legalizer.
      
      Try to cleanup usage of observers. Currently the use of observers is
      pretty hard to follow and it's not clear what is responsible for
      them. Observers are referenced in 3 places:
      
      1. In the MachineFunction
      2. In the MachineIRBuilder
      3. In the LegalizerHelper
      
      The observers in the MachineFunction and MachineIRBuilder are both
      called only on insertions, and are redundant with each other. The
      source of the double printing was the same observer was added to both
      the MachineFunction, and the MachineIRBuilder. One of these references
      needs to be removed. Arguably observers in general should be fully
      removed from one or the other, but it may be useful to have a local
      observer in the MachineIRBuilder that is not added to the function's
      observers. Alternatively, the wrapper observer could manage a local
      observer in one place.
      
      The LegalizerHelper only ever calls the observer on changing/changed
      instructions, and never insertions. Logically these are two different
      types of observers, for changes and for insertions.
      
      Additionally, some places used the GISelObserverWrapper when they only
      needed a single observer they could use directly.
      
      Setting the observer in the LegalizerHelper constructor is not
      flexible enough if the LegalizerHelper is constructed anywhere outside
      the one used by the legalizer. AMDGPU calls the LegalizerHelper in
      RegBankSelect, and needs to use a local observer to apply the regbank
      to newly created instructions. Currently it accomplishes this by
      constructing a local MachineIRBuilder. I'm trying to move the
      MachineIRBuilder to be owned/maintained by the RegBankSelect pass
      itself, but the locally constructed LegalizerHelper would reset the
      observer.
      
      Mips also has a special case use of the LegalizationArtifactCombiner
      in applyMappingImpl; I think we do need to run the artifact combiner
      during RegBankSelect, but in a more consistent way outside of
      applyMappingImpl.
      d55d592a