1. Apr 11, 2020
    • Louis Dionne's avatar
    • River Riddle's avatar
      [mlir] Emit errors if global constructors are found within lib/ · 3db57d14
      River Riddle authored
      Summary: This avoids adding any additional global constructors, like cl::opt. There is a temporary exception on IR/, which has a few cl::opts that require a bit of plumbing to remove.
      
      Differential Revision: https://reviews.llvm.org/D77824
      3db57d14
    • Sanjay Patel's avatar
      [x86] add test for FP->int->FP casts; NFC (PR36617) · ebf22a49
      Sanjay Patel authored
      Also, add a common prefix for SSE to reduce redundant CHECK lines.
      ebf22a49
    • Jacques Pienaar's avatar
      [mlir][drr] Allow specifying string in location · d6b32e39
      Jacques Pienaar authored
      Summary:
      The string in the location is used to provide metadata for the fused location
      or create a NamedLoc. This allows tagging individual locations to convey
      additional rewrite information.
      
      Differential Revision: https://reviews.llvm.org/D77840
      d6b32e39
    • Craig Topper's avatar
    • LLVM GN Syncbot's avatar
      [gn build] Port ea11f472 · 516a671b
      LLVM GN Syncbot authored
      516a671b
    • Marcello Maggioni's avatar
      Split LiveRangeCalc in LiveRangeCalc/LiveIntervalCalc. NFC · ea11f472
      Marcello Maggioni authored
      Summary:
      Refactor LiveRangeCalc such that it is now split into two classes
      
      The objective is to split all the "register specific" logic away
      from LiveRangeCalc.
      The two new classes created are:
      
      - LiveRangeCalc - is meant as a generic class to compute and modify
        live ranges in a generic way. This class should deal only with
        SlotIndices and VNInfo objects.
      
      - LiveIntervalCals - is meant to be equivalent to the old LiveRangeCalc.
        It computes the liveness virtual registers tracked by a LiveInterval
        object.
      
      With this refactoring LiveRangeCalc can be used to implement tracking of
      liveness of LiveRanges that represent other things than just registers.
      
      Subscribers: MatzeB, qcolombet, mgorny, hiraditya, llvm-commits
      
      Tags: #llvm
      
      Differential Revision: https://reviews.llvm.org/D76584
      ea11f472
    • Nicolas Vasilache's avatar
      [mlir][Linalg] Create a tool to generate named Linalg ops from a Tensor... · 882ba484
      Nicolas Vasilache authored
      [mlir][Linalg] Create a tool to generate named Linalg ops from a Tensor Comprehensions-like specification.
      
      Summary:
      
      This revision adds a tool that generates the ODS and C++ implementation for "named" Linalg ops according to the [RFC discussion](https://llvm.discourse.group/t/rfc-declarative-named-ops-in-the-linalg-dialect/745).
      
      While the mechanisms and language aspects are by no means set in stone, this revision allows connecting the pieces end-to-end from a mathematical-like specification.
      
      Some implementation details and short-term decisions taken for the purpose of bootstrapping and that are not set in stone include:
      
          1. using a "[Tensor Comprehension](https://arxiv.org/abs/1802.04730)-inspired" syntax
          2. implicit and eager discovery of dims and symbols when parsing
          3. using EDSC ops to specify the computation (e.g. std_addf, std_mul_f, ...)
      
      A followup revision will connect this tool to tablegen mechanisms and allow the emission of named Linalg ops that automatically lower to various loop forms and run end to end.
      
      For the following "Tensor Comprehension-inspired" string:
      
      ```
          def batch_matmul(A: f32(Batch, M, K), B: f32(K, N)) -> (C: f32(Batch, M, N)) {
            C(b, m, n) = std_addf<k>(std_mulf(A(b, m, k), B(k, n)));
          }
      ```
      
      With -gen-ods-decl=1, this emits (modulo formatting):
      
      ```
            def batch_matmulOp : LinalgNamedStructured_Op<"batch_matmul", [
              NInputs<2>,
              NOutputs<1>,
              NamedStructuredOpTraits]> {
                let arguments = (ins Variadic<LinalgOperand>:$views);
                let results = (outs Variadic<AnyRankedTensor>:$output_tensors);
                let extraClassDeclaration = [{
                  llvm::Optional<SmallVector<StringRef, 8>> referenceIterators();
                  llvm::Optional<SmallVector<AffineMap, 8>> referenceIndexingMaps();
                  void regionBuilder(ArrayRef<BlockArgument> args);
                }];
                let hasFolder = 1;
            }
      ```
      
      With -gen-ods-impl, this emits (modulo formatting):
      
      ```
            llvm::Optional<SmallVector<StringRef, 8>> batch_matmul::referenceIterators() {
                return SmallVector<StringRef, 8>{ getParallelIteratorTypeName(),
                                                  getParallelIteratorTypeName(),
                                                  getParallelIteratorTypeName(),
                                                  getReductionIteratorTypeName() };
            }
            llvm::Optional<SmallVector<AffineMap, 8>> batch_matmul::referenceIndexingMaps()
            {
              MLIRContext *context = getContext();
              AffineExpr d0, d1, d2, d3;
              bindDims(context, d0, d1, d2, d3);
              return SmallVector<AffineMap, 8>{
                  AffineMap::get(4, 0, {d0, d1, d3}),
                  AffineMap::get(4, 0, {d3, d2}),
                  AffineMap::get(4, 0, {d0, d1, d2}) };
            }
            void batch_matmul::regionBuilder(ArrayRef<BlockArgument> args) {
              using namespace edsc;
              using namespace intrinsics;
              ValueHandle _0(args[0]), _1(args[1]), _2(args[2]);
      
              ValueHandle _4 = std_mulf(_0, _1);
              ValueHandle _5 = std_addf(_2, _4);
              (linalg_yield(ValueRange{ _5 }));
            }
      ```
      
      Differential Revision: https://reviews.llvm.org/D77067
      882ba484
    • Sumanth Gundapaneni's avatar
    • Matt Morehouse's avatar
      Implement `-fsanitize-coverage-whitelist` and `-fsanitize-coverage-blacklist` for clang · bef187c7
      Matt Morehouse authored
      Summary:
      This commit adds two command-line options to clang.
      These options let the user decide which functions will receive SanitizerCoverage instrumentation.
      This is most useful in the libFuzzer use case, where it enables targeted coverage-guided fuzzing.
      
      Patch by Yannis Juglaret of DGA-MI, Rennes, France
      
      libFuzzer tests its target against an evolving corpus, and relies on SanitizerCoverage instrumentation to collect the code coverage information that drives corpus evolution. Currently, libFuzzer collects such information for all functions of the target under test, and adds to the corpus every mutated sample that finds a new code coverage path in any function of the target. We propose instead to let the user specify which functions' code coverage information is relevant for building the upcoming fuzzing campaign's corpus. To this end, we add two new command line options for clang, enabling targeted coverage-guided fuzzing with libFuzzer. We see targeted coverage guided fuzzing as a simple way to leverage libFuzzer for big targets with thousands of functions or multiple dependencies. We publish this patch as work from DGA-MI of Rennes, France, with proper authorization from the hierarchy.
      
      Targeted coverage-guided fuzzing can accelerate bug finding for two reasons. First, the compiler will avoid costly instrumentation for non-relevant functions, accelerating fuzzer execution for each call to any of these functions. Second, the built fuzzer will produce and use a more accurate corpus, because it will not keep the samples that find new coverage paths in non-relevant functions.
      
      The two new command line options are `-fsanitize-coverage-whitelist` and `-fsanitize-coverage-blacklist`. They accept files in the same format as the existing `-fsanitize-blacklist` option <https://clang.llvm.org/docs/SanitizerSpecialCaseList.html#format>. The new options influence SanitizerCoverage so that it will only instrument a subset of the functions in the target. We explain these options in detail in `clang/docs/SanitizerCoverage.rst`.
      
      Consider now the woff2 fuzzing example from the libFuzzer tutorial <https://github.com/google/fuzzer-test-suite/blob/master/tutorial/libFuzzerTutorial.md>. We are aware that we cannot conclude much from this example because mutating compressed data is generally a bad idea, but let us use it anyway as an illustration for its simplicity. Let us use an empty blacklist together with one of the three following whitelists:
      
      ```
        # (a)
        src:*
        fun:*
      
        # (b)
        src:SRC/*
        fun:*
      
        # (c)
        src:SRC/src/woff2_dec.cc
        fun:*
      ```
      
      Running the built fuzzers shows how many instrumentation points the compiler adds, the fuzzer will output //XXX PCs//. Whitelist (a) is the instrument-everything whitelist, it produces 11912 instrumentation points. Whitelist (b) focuses coverage to instrument woff2 source code only, ignoring the dependency code for brotli (de)compression; it produces 3984 instrumented instrumentation points. Whitelist (c) focuses coverage to only instrument functions in the main file that deals with WOFF2 to TTF conversion, resulting in 1056 instrumentation points.
      
      For experimentation purposes, we ran each fuzzer approximately 100 times, single process, with the initial corpus provided in the tutorial. We let the fuzzer run until it either found the heap buffer overflow or went out of memory. On this simple example, whitelists (b) and (c) found the heap buffer overflow more reliably and 5x faster than whitelist (a). The average execution times when finding the heap buffer overflow were as follows: (a) 904 s, (b) 156 s, and (c) 176 s.
      
      We explain these results by the fact that WOFF2 to TTF conversion calls the brotli decompression algorithm's functions, which are mostly irrelevant for finding bugs in WOFF2 font reconstruction but nevertheless instrumented and used by whitelist (a) to guide fuzzing. This results in longer execution time for these functions and a partially irrelevant corpus. Contrary to whitelist (a), whitelists (b) and (c) will execute brotli-related functions without instrumentation overhead, and ignore new code paths found in them. This results in faster bug finding for WOFF2 font reconstruction.
      
      The results for whitelist (b) are similar to the ones for whitelist (c). Indeed, WOFF2 to TTF conversion calls functions that are mostly located in SRC/src/woff2_dec.cc. The 2892 extra instrumentation points allowed by whitelist (b) do not tamper with bug finding, even though they are mostly irrelevant, simply because most of these functions do not get called. We get a slightly faster average time for bug finding with whitelist (b), which might indicate that some of the extra instrumentation points are actually relevant, or might just be random noise.
      
      Reviewers: kcc, morehouse, vitalybuka
      
      Reviewed By: morehouse, vitalybuka
      
      Subscribers: pratyai, vitalybuka, eternalsakura, xwlin222, dende, srhines, kubamracek, #sanitizers, lebedev.ri, hiraditya, cfe-commits, llvm-commits
      
      Tags: #clang, #sanitizers, #llvm
      
      Differential Revision: https://reviews.llvm.org/D63616
      bef187c7
    • Fangrui Song's avatar
      [MC][RISCV] Make .reloc support arbitrary relocation types · a7aaaf70
      Fangrui Song authored
      Similar to D76746 (ARM), D76754 (AArch64) and llvmorg-11-init-6967-g152d14da (x86)
      
      Differential Revision: https://reviews.llvm.org/D77018
      a7aaaf70
    • Matt Arsenault's avatar
      AMDGPU: Teach toolchain to link rocm device libs · 4593e413
      Matt Arsenault authored
      Currently the library is separately linked, but this isn't correct to
      implement fast math flags correctly. Each module should get the
      version of the library appropriate for its combination of fast math
      and related flags, with the attributes propagated into its functions
      and internalized.
      
      HIP already maintains the list of libraries, but this is not used for
      OpenCL. Unfortunately, HIP uses a separate --hip-device-lib argument,
      despite both languages using the same bitcode library. Eventually
      these two searches need to be merged.
      
      An additional problem is there are 3 different locations the libraries
      are installed, depending on which build is used. This also needs to be
      consolidated (or at least the search logic needs to deal with this
      unnecessary complexity).
      4593e413
    • Adrian Prantl's avatar
    • Craig Topper's avatar
      [CallSite removal][X86] Remove unneeded use of CallSite. NFC · a6732069
      Craig Topper authored
      We already have a CallInst, we can just get the calling convention from it.
      a6732069
    • Raphael Isemann's avatar
      02d152bb
    • David Blaikie's avatar
      Fix a few mismatched iterator types revealed from a libc++ + LLVM_EXPENSIVE_CHECKS build · 67a2cc80
      David Blaikie authored
      These were accidental SCARY iterator uses that weren't guaranteed and in
      libc++'s debug checking mode were actually distinct types. Use decltype
      to make it easier to keep these things up to date.
      67a2cc80
    • Kevin P. Neal's avatar
      [FPEnv][AArch64] Platform-specific builtin constrained FP enablement · 7f38812d
      Kevin P. Neal authored
      When constrained floating point is enabled the AArch64-specific builtins don't use constrained intrinsics in some cases. Fix that.
      
      Neon is part of this patch, so ARM is affected as well.
      
      Differential Revision: https://reviews.llvm.org/D77074
      7f38812d
    • Nemanja Ivanovic's avatar
      [PowerPC][NFC] Add test for 5b18b6e9 · 95b718e5
      Nemanja Ivanovic authored
      When the above commit was added to fix a kernel build break, no tests were
      added. Just adding some testing to ensure similar regressions do not recur.
      95b718e5
    • Simon Pilgrim's avatar
    • Simon Pilgrim's avatar
    • Fangrui Song's avatar
      [llvm-dwarfdump] Interface cleanup. NFC · b1849231
      Fangrui Song authored
      This patch moves interface declarations into llvm-dwarfdump.h and wrap
      declarations in anonymous namespaces as appropriate. At the same time,
      the externals are moved into the `llvm::dwarfdump` namespace`.
      
      Reviewed By: djtodoro
      
      Differential Revision: https://reviews.llvm.org/D77848
      b1849231
    • Fangrui Song's avatar
      [AArch64InstPrinter] Change printAlignedLabel to print the target address in hexadecimal form · 7f36cb1f
      Fangrui Song authored
      Similar to D76580 (x86) and D76591 (PPC).
      
      ```
      // llvm-objdump -d output (before)
      10000: 08 00 00 94                   bl      #32
      10004: 08 00 00 94                   bl      #32
      
      // llvm-objdump -d output (after)
      10000: 08 00 00 94                   bl      0x10020
      10004: 08 00 00 94                   bl      0x10024
      
      // GNU objdump -d. The lack of 0x is not ideal due to ambiguity.
      10000:       94000008        bl      10020 <bar+0x18>
      10004:       94000008        bl      10024 <bar+0x1c>
      ```
      
      The new output makes it easier to find the jump target.
      
      Differential Revision: https://reviews.llvm.org/D77853
      7f36cb1f
    • Simon Pilgrim's avatar
    • Simon Pilgrim's avatar
    • Simon Pilgrim's avatar
      dd84a2f7
  2. Apr 10, 2020
    • LLVM GN Syncbot's avatar
      [gn build] Port 89f1321f · de3122a7
      LLVM GN Syncbot authored
      de3122a7
    • Michael Wyman's avatar
      [clang-tidy] Add check to find calls to NSInvocation methods under ARC that... · 89f1321f
      Michael Wyman authored
      [clang-tidy] Add check to find calls to NSInvocation methods under ARC that don't have proper object argument lifetimes.
      
      Summary: This check is similar to an ARC Migration check that warned about this incorrect usage under ARC, but most projects are no longer undergoing migration from pre-ARC code. The documentation for NSInvocation is not explicit about these requirements and incorrect usage has been found in many of our projects.
      
      Reviewers: stephanemoore, benhamilton, dmaclach, alexfh, aaron.ballman, hokein, njames93
      
      Reviewed By: stephanemoore, benhamilton, aaron.ballman
      
      Subscribers: xazax.hun, Eugene.Zelenko, mgorny, cfe-commits
      
      Tags: #clang, #clang-tools-extra
      
      Differential Revision: https://reviews.llvm.org/D77571
      89f1321f
    • Christopher Tetreault's avatar
      Clean up usages of asserting vector getters in Type · 65b8b643
      Christopher Tetreault authored
      Summary:
      Remove usages of asserting vector getters in Type in preparation for the
      VectorType refactor. The existence of these functions complicates the
      refactor while adding little value.
      
      Reviewers: sdesmalen, efriedma, jonpa
      
      Reviewed By: sdesmalen
      
      Subscribers: hiraditya, llvm-commits
      
      Tags: #llvm
      
      Differential Revision: https://reviews.llvm.org/D77265
      65b8b643
    • Simon Pilgrim's avatar
      ProfileSummaryInfo.h - remove unnecessary includes. NFC · a88cc204
      Simon Pilgrim authored
      Remove a number of includes that aren't necessary (nor are we relying on the remaining includes to provide the declarations), we just needed a llvm::Instruction forward declaration.
      
      This exposed a couple of source files that were implicitly replying on the includes for their use of llvm::SmallSet or std::set, requiring local includes to be added there instead.
      a88cc204
    • Stanislav Mekhanoshin's avatar
      [AMDGPU] Disable sub-dword scralar loads IR widening · 44920e85
      Stanislav Mekhanoshin authored
      These will be widened in the DAG. In the meanwhile early
      widening prevents otherwise possible vectorization of
      such loads.
      
      Differential Revision: https://reviews.llvm.org/D77835
      44920e85
    • Mircea Trofin's avatar
      [llvm][NFC] Style fixes in Inliner.cpp · f62335b5
      Mircea Trofin authored
      Summary:
      Function names: camel case, lower case first letter.
      Variable names: start with upper letter. For iterators that were 'i',
      renamed with a descriptive name, as 'I' is 'Instruction&'.
      
      Lambda captures simplification.
      
      Opportunistic boolean return simplification.
      
      Reviewers: davidxl, dblaikie
      
      Subscribers: eraman, hiraditya, llvm-commits
      
      Tags: #llvm
      
      Differential Revision: https://reviews.llvm.org/D77837
      f62335b5
    • Jinsong Ji's avatar
      [NFC][UpdateTestChecks] Fix typos in comments · 6d7c25bb
      Jinsong Ji authored
      6d7c25bb
    • Ilya Leoshkevich's avatar
      [MSan] Add instrumentation for SystemZ · 3bc439bd
      Ilya Leoshkevich authored
      Summary:
      This patch establishes memory layout and adds instrumentation. It does
      not add runtime support and does not enable MSan, which will be done
      separately.
      
      Memory layout is based on PPC64, with the exception that XorMask
      is not used - low and high memory addresses are chosen in a way that
      applying AndMask to low and high memory produces non-overlapping
      results.
      
      VarArgHelper is based on AMD64. It might be tempting to share some
      code between the two implementations, but we need to keep in mind that
      all the ABI similarities are coincidental, and therefore any such
      sharing might backfire.
      
      copyRegSaveArea() indiscriminately copies the entire register save area
      shadow, however, fragments thereof not filled by the corresponding
      visitCallSite() invocation contain irrelevant data. Whether or not this
      can lead to practical problems is unclear, hence a simple TODO comment.
      Note that the behavior of the related copyOverflowArea() is correct: it
      copies only the vararg-related fragment of the overflow area shadow.
      
      VarArgHelper test is based on the AArch64 one.
      
      s390x ABI requires that arguments are zero-extended to 64 bits. This is
      particularly important for __msan_maybe_warning_*() and
      __msan_maybe_store_origin_*() shadow and origin arguments, since non
      zeroed upper parts thereof confuse these functions. Therefore, add ZExt
      attribute to the corresponding parameters.
      
      Add ZExt attribute checks to msan-basic.ll. Since with
      -msan-instrumentation-with-call-threshold=0 instrumentation looks quite
      different, introduce the new CHECK-CALLS check prefix.
      
      Reviewers: eugenis, vitalybuka, uweigand, jonpa
      
      Reviewed By: eugenis
      
      Subscribers: kristof.beyls, hiraditya, danielkiss, llvm-commits, stefansf, Andreas-Krebbel
      
      Tags: #llvm
      
      Differential Revision: https://reviews.llvm.org/D76624
      3bc439bd
    • Simon Pilgrim's avatar
    • Simon Pilgrim's avatar
    • Simon Pilgrim's avatar
    • Simon Pilgrim's avatar
      SizeOpts.h - remove ProfileSummaryInfo forward declaration. NFC. · 8a33920f
      Simon Pilgrim authored
      We're include the entire ProfileSummaryInfo.h as inline functions use it in the header.
      8a33920f
    • Christopher Tetreault's avatar
      Clean up usages of asserting vector getters in Type · 3bebf028
      Christopher Tetreault authored
      Summary:
      Remove usages of asserting vector getters in Type in preparation for the
      VectorType refactor. The existence of these functions complicates the
      refactor while adding little value.
      
      Reviewers: sdesmalen, rriddle, efriedma
      
      Reviewed By: sdesmalen
      
      Subscribers: hiraditya, llvm-commits
      
      Tags: #llvm
      
      Differential Revision: https://reviews.llvm.org/D77262
      3bebf028
    • Jessica Clarke's avatar
      [RISCV] Consume error from parsing attributes section · 49e20c4c
      Jessica Clarke authored
      Summary:
      We don't consume the error from getBuildAttributes, so an assertions
      build crashes with "Program aborted due to an unhandled Error:".
      Explicitly consume it like the ARM version in that case.
      
      Reviewers: asb, jhenderson, MaskRay, HsiangKai
      
      Reviewed By: MaskRay
      
      Subscribers: kristof.beyls, hiraditya, simoncook, kito-cheng, shiva0217, rogfer01, rkruppe, psnobl, benna, Jim, lenary, s.egerton, sameer.abuasal, luismarques, evandro, danielkiss, llvm-commits
      
      Tags: #llvm
      
      Differential Revision: https://reviews.llvm.org/D77841
      49e20c4c
    • Simon Pilgrim's avatar
      [CostModel][X86] Improve InsertElement costs for sub-128bit vectors · 91bc50c0
      Simon Pilgrim authored
      If we're inserting into v2i8/v4i8/v8i8/v2i16/v4i16 style sub-128bit vectors ensure we don't use the SK_PermuteTwoSrc cost of the legalized value type - this is a followup to rG12c629ec which added equivalent sub-128bit shuffle costs
      91bc50c0