Skip to content
  1. Jun 09, 2020
  2. Jun 08, 2020
    • Petr Hosek's avatar
      Revert "[InstrProfiling] Use !associated metadata for counters, data and values" · ba10bedf
      Petr Hosek authored
      This reverts commit 39b3c41b due to
      a failing associated.ll test.
      ba10bedf
    • Stanislav Mekhanoshin's avatar
      Stabilize alloca slices sort in SROA · 87ff3401
      Stanislav Mekhanoshin authored
      Slice::operator<() has a non-deterministic behavior. If we have
      identical slices comparison will depend on the order or operands.
      Normally that does not result in unstable compilation results
      because the order in which slices are inserted into the vector
      is deterministic and llvm::sort() normally behaves as a stable
      sort, although that is not guaranteed.
      
      However, there is test option -sroa-random-shuffle-slices which
      is used to check exactly this aspect. The vector is first randomly
      shuffled and then sorted. The same shuffling happens without this
      option under expensive llvm checks.
      
      I have managed to write a test which has hit this problem.
      
      There are no fields in the Slice class to resolve the instability.
      We only have offsets, IsSplittable and Use, but neither Use nor
      User have anything suitable for predictable comparison.
      
      I have switched to stable_sort which has to be sufficient and
      removed that randon shuffle option.
      
      Differential Revision: https://reviews.llvm.org/D81310
      87ff3401
    • Richard Smith's avatar
      Remove improper uses of DiagnosticErrorTrap and hasErrorOccurred. · 56a87294
      Richard Smith authored
      DiagnosticErrorTrap is usually inappropriate because it indicates
      whether an error message was rendered in a given region (and is
      therefore affected by -ferror-limit and by suppression of errors if we
      see an invalid declaration).
      
      hasErrorOccurred() is usually inappropriate because it indicates
      whethere an "error:" message was displayed, regardless of whether the
      message was a warning promoted to an error, and therefore depends on
      things like -Werror that are usually irrelevant.
      
      Where applicable, CodeSynthesisContexts are used to attach notes to
      the first diagnostic produced in a region of code, isnstead of using an
      error trap and then attaching a note to whichever diagnostic happened to
      be produced last (or suppressing the note if the final diagnostic is a
      disabled warning!).
      
      This is mostly NFC.
      56a87294
    • Sterling Augustine's avatar
      Add #includes so that ROCm.h is compilable stand-alone. · f07b3d41
      Sterling Augustine authored
      Summary:
      ROCm.h had been getting the declarations for various data structures
      by being #included next to them, rather than #includeing them itself.
      
      This change fixes that by explicitly including the appropriate headers.
      
      Subscribers: cfe-commits
      
      Tags: #clang
      
      Differential Revision: https://reviews.llvm.org/D81432
      f07b3d41
    • Yonghong Song's avatar
      [DebugInfo] Fix assertion for extern void type · 3eb465a3
      Yonghong Song authored
      Commit d77ae155 ("[DebugInfo] Support to emit debugInfo
      for extern variables") added support to emit debuginfo
      for extern variables. Currently, only BPF target enables to
      emit debuginfo for extern variables.
      
      But if the extern variable has "void" type, the compilation will
      fail.
      
        -bash-4.4$ cat t.c
        extern void bla;
        void *test() {
          void *x = &bla;
          return x;
        }
        -bash-4.4$ clang -target bpf -g -O2 -S t.c
        missing global variable type
        !1 = distinct !DIGlobalVariable(name: "bla", scope: !2, file: !3, line: 1,
                                        isLocal: false, isDefinition: false)
        ...
        fatal error: error in backend: Broken module found, compilation aborted!
        PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace,
            preprocessed source, and associated run script.
        Stack dump:
        ...
      
      The IR requires a DIGlobalVariable must have a valid type and the
      "void" type does not generate any type, hence the above fatal error.
      
      Note that if the extern variable is defined as "const void", the
      compilation will succeed.
      
      -bash-4.4$ cat t.c
      extern const void bla;
      const void *test() {
        const void *x = &bla;
        return x;
      }
      -bash-4.4$ clang -target bpf -g -O2 -S t.c
      -bash-4.4$ cat t.ll
      ...
      !1 = distinct !DIGlobalVariable(name: "bla", scope: !2, file: !3, line: 1,
                                      type: !6, isLocal: false, isDefinition: false)
      !6 = !DIDerivedType(tag: DW_TAG_const_type, baseType: null)
      ...
      
      Since currently, "const void extern_var" is supported by the
      debug info, it is natural that "void extern_var" should also
      be supported. This patch disabled assertion of "void extern_var"
      in IR verifier and add proper guarding when emiting potential
      null debug info type to dwarf types.
      
      Differential Revision: https://reviews.llvm.org/D81131
      3eb465a3
    • Petr Hosek's avatar
      [InstrProfiling] Use !associated metadata for counters, data and values · 39b3c41b
      Petr Hosek authored
      The !associated metadata may be attached to a global object declaration
      with a single argument that references another global object. This
      metadata prevents discarding of the global object in linker GC unless
      the referenced object is also discarded.
      
      Furthermore, when a function symbol is discarded by the linker, setting
      up !associated metadata allows linker to discard counters, data and
      values associated with that function symbol. This is not possible today
      because there's metadata to guide the linker. This approach is also used
      by other instrumentations like sanitizers.
      
      Note that !associated metadata is only supported by ELF, it does not have
      any effect on non-ELF targets.
      
      Differential Revision: https://reviews.llvm.org/D76802
      39b3c41b
    • Roman Lebedev's avatar
      [Support] FoldingSetNodeID::AddString(): reserve memory · 932ad994
      Roman Lebedev authored
      Summary:
      It is traditionally potentially very inefficient to not preallocate the memory,
      but rely on reallocation every time you push something into vector.
      
      For example, looking at unity build of RawSpeed
      (`-O3 -g0 -emit-llvm -Xclang -disable-llvm-optzns`),
      the memory story is as follows:
      ```
      total runtime: 11.34s.
      calls to allocation functions: 2694053 (237612/s)
      temporary memory allocations: 645188 (56904/s)
      peak heap memory consumption: 231.36MB
      peak RSS (including heaptrack overhead): 397.39MB
      ```
      
      Looking at details, `FoldingSetNodeID::AddString()` is noteworthy, frequently called and is allocation-heavy.
      
      But it is quite obvious how many times we will push into `Bits` - we will push `String.size()` itself,
      and then we will push once per every 4 bytes of `String` (padding last block).
      
      And if we preallocate, we get:
      ```
      total runtime: 11.20s.
      calls to allocation functions: 2594704 (231669/s)
      temporary memory allocations: 560004 (50000/s)
      peak heap memory consumption: 231.36MB
      peak RSS (including heaptrack overhead): 398.06MB
      ```
      Which is a measurable win:
      ```
      total runtime: -0.14s.                             #  -1.23 %
      calls to allocation functions: -99349 (719920/s)   #  -3.69 %
      temporary memory allocations: -85184 (617275/s)    # -13.2 % (!)
      peak heap memory consumption: 0B
      peak RSS (including heaptrack overhead): 0B
      total memory leaked: 0B
      ```
      
      Reviewers: efriedma, nikic, bkramer
      
      Reviewed By: bkramer
      
      Subscribers: hiraditya, llvm-commits
      
      Tags: #llvm
      
      Differential Revision: https://reviews.llvm.org/D81342
      932ad994
    • Michael Liao's avatar
    • Richard Smith's avatar
      More robust fix for crash on invalid range-based for statement. · 58f831d2
      Richard Smith authored
      Reliably mark the loop variable declaration in a range for as having an
      invalid initializer if anything goes wrong building the initializer. We
      previously based this determination on whether an error was emitted,
      which is not a reliable signal due to error suppression (during error
      recovery etc).
      
      Also, properly mark the variable as having initializer errors rather
      than simply marking it invalid. This is necessary to mark any structured
      bindings as invalid too.
      
      This generalizes the previous fix in
      936ec89e.
      58f831d2
    • jasonliu's avatar
      [XCOFF][AIX] report_fatal_error when an overflow section is needed · 775ef445
      jasonliu authored
      If there are more than 65534 relocation entries in a single section,
      we should generate an overflow section.
      Since we don't support overflow section for now, we should generate
      an error.
      
      Differential revision: https://reviews.llvm.org/D81104
      775ef445
    • Valentin Clement's avatar
      Apply fix from D81179 only from GCC < 8 · 38674030
      Valentin Clement authored
      Summary: Apply workaround done in D81179 only for GCC < 8. As @klausler mentioned in D81179 we want to avoid additional checks for other compilers that do not need them.
      
      Reviewers: DavidTruby, klausler, jdoerfert, sscalpone
      
      Reviewed By: klausler, sscalpone
      
      Subscribers: llvm-commits, tskeith, isuruf, klausler
      
      Tags: #flang, #llvm
      
      Differential Revision: https://reviews.llvm.org/D81208
      38674030
    • Arthur Eubanks's avatar
      a92ce3b7
    • LLVM GN Syncbot's avatar
      [gn build] Port bb677cac · 8e1d2043
      LLVM GN Syncbot authored
      8e1d2043
    • Andrew Litteken's avatar
      [SuffixTree][MachOpt] Factoring out Suffix Tree and adding Unit Tests · bb677cac
      Andrew Litteken authored
      This moves the SuffixTree test used in the Machine Outliner and moves it into Support for use in other outliners elsewhere in the compilation pipeline.
      
      Differential Revision: https://reviews.llvm.org/D80586
      bb677cac
    • Julian Lettner's avatar
      [TSan] Revert removal of ignore_interceptors_accesses flag · e47c0ef0
      Julian Lettner authored
      This flag suppresses TSan FPs on Darwin.  I removed this flag
      prematurely and have been dealing with the fallout ever since.
      
      This commit puts back the flag, reverting 7d1085cb [1].
      
      [1] https://reviews.llvm.org/D55075
      e47c0ef0
    • Jian Cai's avatar
      Add a flag to debug automatic variable initialization · 4db2b702
      Jian Cai authored
      Summary:
      Add -ftrivial-auto-var-init-stop-after= to limit the number of times
      stack variables are initialized when -ftrivial-auto-var-init= is used to
      initialize stack variables to zero or a pattern. This flag can be used
      to bisect uninitialized uses of a stack variable exposed by automatic
      variable initialization, such as http://crrev.com/c/2020401.
      
      Reviewers: jfb, vitalybuka, kcc, glider, rsmith, rjmccall, pcc, eugenis, vlad.tsyrklevich
      
      Reviewed By: jfb
      
      Subscribers: phosek, hubert.reinterpretcast, srhines, MaskRay, george.burgess.iv, dexonsmith, inglorion, gbiv, llozano, manojgupta, cfe-commits
      
      Tags: #clang
      
      Differential Revision: https://reviews.llvm.org/D77168
      4db2b702
    • Nico Weber's avatar
      f25e3c2d
    • Florian Hahn's avatar
      [AArch64] Fix ldst-opt of multiple disjunct subregs. · 1975ff9a
      Florian Hahn authored
      Currently aarch64-ldst-opt will incorrectly rename registers with
      multiple disjunct subregisters (e.g. result of LD3). This patch updates
      the canRenameUpToDef to bail out if it encounters such a register class
      that contains the register to rename.
      
      Fixes PR46105.
      
      Reviewers: efriedma, dmgreen, paquette, t.p.northover
      
      Reviewed By: efriedma
      
      Differential Revision: https://reviews.llvm.org/D81108
      1975ff9a
    • Isuru Fernando's avatar
      [flang] Fix issue of flang/runtime/config.h not being found in out of tree builds · bb73d1b2
      Isuru Fernando authored
      Summary: Fixes https://bugs.llvm.org/show_bug.cgi?id=46078
      
      Reviewers: DavidTruby, jdoerfert, PeteSteinfeld, sscalpone, tskeith
      
      Reviewed By: PeteSteinfeld, sscalpone, tskeith
      
      Subscribers: mgorny, llvm-commits, tskeith
      
      Tags: #llvm, #flang
      
      Differential Revision: https://reviews.llvm.org/D81266
      bb73d1b2
    • Hans Wennborg's avatar
      [PGO] CallPromotion: Don't try to pass sret args to varargs functions · fc202c5f
      Hans Wennborg authored
      It's not allowed by the verifier.
      
      Differential revision: https://reviews.llvm.org/D81409
      fc202c5f
    • Arthur Eubanks's avatar
      Move *San module passes later in the NPM pipeline · c07339c6
      Arthur Eubanks authored
      Summary:
      This fixes pr33372.cpp under the new pass manager.
      
      ASan adds padding to globals. For example, it will change a {i32, i32, i32} to a {{i32, i32, i32}, [52 x i8]}. However, when loading from the {i32, i32, i32}, InstCombine may (after various optimizations) end up loading 16 bytes instead of 12, likely because it thinks the [52 x i8] padding is ok to load from. But ASan checks that padding should not be loaded from.
      
      Ultimately this is an issue of *San passes wanting to be run after all optimizations. This change moves the module passes right next to the corresponding function passes.
      
      Also remove comment that's no longer relevant, this is the last ASan/MSan/TSan failure under the NPM (hopefully...).
      
      As mentioned in https://reviews.llvm.org/rG1285e8bcac2c54ddd924ffb813b2b187467ac2a6, NPM doesn't support LTO + sanitizers, so modified some tests that test for that.
      
      Reviewers: leonardchan, vitalybuka
      
      Subscribers: cfe-commits
      
      Tags: #clang
      
      Differential Revision: https://reviews.llvm.org/D81323
      c07339c6
    • Louis Dionne's avatar
      [libc++] Improve tests for iterators.operations · 60cde7bb
      Louis Dionne authored
      Reduce duplication between the constexpr and the non-constexpr test cases,
      and add tests for the return type of the various operations.
      60cde7bb
    • Craig Topper's avatar
      [X86] Prevent LowerSELECT from causing suboptimal codegen for __builtin_ffs(X) - 1. · 2328cab1
      Craig Topper authored
      LowerSELECT sees the CMP with 0 and wants to use a trick with SUB
      and SBB. But we can use the flags from the BSF/TZCNT.
      
      Fixes PR46203.
      
      Differential Revision: https://reviews.llvm.org/D81312
      2328cab1
    • Hendrik Greving's avatar
      [ModuloSchedule] Support instructions with > 1 destination when walking canonical use. · f3d8a939
      Hendrik Greving authored
      Fixes a minor bug that led to finding the wrong register if the definition had more
      than one register destination.
      f3d8a939
    • Sanjay Patel's avatar
      [InstCombine] improve matching for sext-lshr-trunc patterns, part 2 · d50366d2
      Sanjay Patel authored
      Similar to rG42f488b63a04
      
      This is intended to preserve the logic of the existing transform,
      but remove unnecessary restrictions on uses and types.
      
      https://rise4fun.com/Alive/oS0
      
        Name: narrow input
        Pre: C1 <= width(C1) - 24
        %B = sext i8 %A
        %C = lshr %B, C1
        %r = trunc %C to i24
        =>
        %s = ashr i8 %A, trunc(umin(C1, 7))
        %r = sext i8 %s to i24
      
        Name: wide input
        Pre: C1 <= width(C1) - 24
        %B = sext i24 %A
        %C = lshr %B, C1
        %r = trunc %C to i8
        =>
        %s = ashr i24 %A, trunc(umin(C1, 23))
        %r = trunc i24 %s to i8
      d50366d2
    • Sanjay Patel's avatar
      [InstCombine] add tests for sext+lshr+trunc; NFC · 9b41821c
      Sanjay Patel authored
      Shows missing transforms with extra uses and vectors.
      9b41821c
    • Christopher Tetreault's avatar
      [SVE] Eliminate calls to default-false VectorType::get() from llvm-stress · 2c512eaf
      Christopher Tetreault authored
      Reviewers: efriedma, kmclaughlin, sdesmalen, MaskRay, JDevlieghere
      
      Reviewed By: sdesmalen
      
      Subscribers: tschuett, rkruppe, psnobl, llvm-commits
      
      Tags: #llvm
      
      Differential Revision: https://reviews.llvm.org/D81201
      2c512eaf
    • Chris Jackson's avatar
      [DebugInfo] Reduce SalvageDebugInfo() functions · c6c65164
      Chris Jackson authored
      - Now all SalvageDebugInfo() calls will mark undef if the salvage
        attempt fails.
      
       Reviewed by: vsk, Orlando
      
       Differential Revision: https://reviews.llvm.org/D78369
      c6c65164
    • Yaxun (Sam) Liu's avatar
      Rename arg name in __clang_hip_math.h · 4615abc1
      Yaxun (Sam) Liu authored
      __sptr is a keyword for ms-extension. Change it from __sptr to __sinptr.
      4615abc1
    • Saleem Abdulrasool's avatar
      lld: improve the `-arch` handling for MachO · fcdf7578
      Saleem Abdulrasool authored
      Use the default target triple configured by the user to determine the
      default architecture for `ld64.lld`.  Stash the architecture in the
      configuration as when linking against TBDs, we will need to filter out
      the symbols based upon the architecture.  Treat the Haswell slice as it
      is equivalent to `x86_64` but with the extra Haswell extensions (e.g.
      AVX2, FMA3, BMI1, etc).  This will make it easier to add new
      architectures in the future.
      
      This change also changes the failure mode where an invalid `-arch`
      parameter will result in the linker exiting without further processing.
      fcdf7578
    • Florian Hahn's avatar
      [AArch64] Add a ldst-opt test with undef operands (NFC). · 22c2dc59
      Florian Hahn authored
      This patch adds a test to check that we do not use an undef renamable
      register for renaming the other operand in a LDP instruction, as
      suggested in D81108.
      22c2dc59
    • Jan-Willem Maessen's avatar
      [NFC] Fix quadratic LexicalScopes::constructScopeNest · 3610d31e
      Jan-Willem Maessen authored
      We sometimes have functions with large numbers of sibling basic
      blocks (usually with an error path exit from each one). This was
      triggering the qudratic behavior in this function - after visiting
      each child llvm would re-scan the parent from the beginning again. We
      modify the work stack to record the next index to be worked on
      alongside the pointer. This avoids the need to linearly search for
      the next unfinished child.
      
      Differential Revision: https://reviews.llvm.org/D80029
      3610d31e
Loading