1. Oct 10, 2019
    • Roman Lebedev's avatar
      [ADR] ArrayRefTest: disable SizeTSizedOperations test - it's UB. · abb34df4
      Roman Lebedev authored
      This test is not defined.
      
      FAIL: LLVM-Unit :: ADT/./ADTTests/ArrayRefTest.SizeTSizedOperations (178 of 33926)
      ******************** TEST 'LLVM-Unit :: ADT/./ADTTests/ArrayRefTest.SizeTSizedOperations' FAILED ********************
      Note: Google Test filter = ArrayRefTest.SizeTSizedOperations
      [==========] Running 1 test from 1 test case.
      [----------] Global test environment set-up.
      [----------] 1 test from ArrayRefTest
      [ RUN      ] ArrayRefTest.SizeTSizedOperations
      /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/llvm/include/llvm/ADT/ArrayRef.h:180:32: runtime error: applying non-zero offset 9223372036854775806 to null pointer
          #0 0x5ae8dc in llvm::ArrayRef<char>::slice(unsigned long, unsigned long) const /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/llvm/include/llvm/ADT/ArrayRef.h:180:32
          #1 0x5ae44c in (anonymous namespace)::ArrayRefTest_SizeTSizedOperations_Test::TestBody() /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/llvm/unittests/ADT/ArrayRefTest.cpp:85:3
          #2 0x928a96 in testing::Test::Run() /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/llvm/utils/unittest/googletest/src/gtest.cc:2474:5
          #3 0x929793 in testing::TestInfo::Run() /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/llvm/utils/unittest/googletest/src/gtest.cc:2656:11
          #4 0x92a152 in testing::TestCase::Run() /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/llvm/utils/unittest/googletest/src/gtest.cc:2774:28
          #5 0x9319d2 in testing::internal::UnitTestImpl::RunAllTests() /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/llvm/utils/unittest/googletest/src/gtest.cc:4649:43
          #6 0x931416 in testing::UnitTest::Run() /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/llvm/utils/unittest/googletest/src/gtest.cc:4257:10
          #7 0x920ac3 in RUN_ALL_TESTS /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/llvm/utils/unittest/googletest/include/gtest/gtest.h:2233:46
          #8 0x920ac3 in main /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/llvm/utils/unittest/UnitTestMain/TestMain.cpp:50:10
          #9 0x7f66135b72e0 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x202e0)
          #10 0x472c19 in _start (/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build_ubsan/unittests/ADT/ADTTests+0x472c19)
      
      SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/llvm/include/llvm/ADT/ArrayRef.h:180:32 in
      llvm-svn: 374327
      abb34df4
    • Simon Pilgrim's avatar
      Fix -Wparentheses warning. NFCI. · 788ba151
      Simon Pilgrim authored
      llvm-svn: 374326
      788ba151
    • Aleksandr Urakov's avatar
      [Windows] Introduce a switch for the `lldb-server` mode on Windows · 08913665
      Aleksandr Urakov authored
      Summary:
      This patch introduces a switch, based on the environment variable
      `LLDB_USE_LLDB_SERVER`, to determine whether to use the `ProcessWindows` plugin
      (the old way) or the `lldb-server` way for debugging on Windows.
      
      Reviewers: labath, amccarth, asmith, stella.stamenova
      
      Reviewed By: labath, amccarth
      
      Subscribers: mstorsjo, abidh, JDevlieghere, lldb-commits, leonid.mashinskiy
      
      Tags: #lldb
      
      Differential Revision: https://reviews.llvm.org/D68258
      
      llvm-svn: 374325
      08913665
    • Kadir Cetinkaya's avatar
      Revert "Use -fdebug-compilation-dir to form absolute paths in coverage mappings" · 62808631
      Kadir Cetinkaya authored
      This reverts commit f6777964.
      
      Because the absolute path check relies on temporary path containing
      "clang", "test" and "CoverageMapping" as a subsequence, which is not
      necessarily true on all systems(breaks internal integrates). Wanted to
      fix it by checking for a leading "/" instead, but then noticed that it
      would break windows tests, so leaving it to the author instead.
      
      llvm-svn: 374324
      62808631
    • Pavel Labath's avatar
      TestFileHandle.py: relax exception type checks · 44506cd7
      Pavel Labath authored
      the exceptions returned differ between swig4 (TypeError) and swig<=3
      (NotImplementedError). Just check for the base Exception class instead.
      
      Theoretically we could switch on the swig version and expect the precise
      type directly, but checking the exact type does not seem that important.
      
      Thanks to Raphael for helping me figure this out.
      
      llvm-svn: 374322
      44506cd7
    • Russell Gallop's avatar
      Fix sanitizer lint check after r374315 · 38ac46b4
      Russell Gallop authored
      llvm-svn: 374321
      38ac46b4
    • Mirko Brkusanin's avatar
      [Mips] Fix 374055 · c2e48167
      Mirko Brkusanin authored
      EXPENSIVE_CHECKS build was failing on new test.
      This is fixed by marking $ra register as undef.
      Test now has -verify-machineinstrs to check for operand flags.
      
      llvm-svn: 374320
      c2e48167
    • Thomas Preud'homme's avatar
      [test] Use system locale for mri-utf8.test · b6f1d1fa
      Thomas Preud'homme authored
      Summary:
      llvm-ar's mri-utf8.test test relies on the en_US.UTF-8 locale to be
      installed for its last RUN line to work. If not installed, the unicode
      string gets encoded (interpreted) as ascii which fails since the most
      significant byte is non zero. This commit changes the test to only rely
      on the system being able to encode the pound sign in its default
      encoding (e.g. UTF-16 for Microsoft Windows) by always opening the file
      via input/output redirection. This avoids forcing a given locale to be
      present and supported. A Byte Order Mark is also added to help
      recognizing the encoding of the file and its endianness.
      
      Reviewers: gbreynoo, MaskRay, rupprecht, JamesNagurne, jfb
      
      Subscribers: dexonsmith, llvm-commits
      
      Tags: #llvm
      
      Differential Revision: https://reviews.llvm.org/D68472
      
      llvm-svn: 374318
      b6f1d1fa
    • Roman Lebedev's avatar
      [UBSan] Appease linter · 6430adbe
      Roman Lebedev authored
      llvm-svn: 374316
      6430adbe
    • David Carlier's avatar
      [Sanitizers] Porting getrandom/getentropy interceptors to FreeBSD · 90c8b59c
      David Carlier authored
      - Available from 12.x branch, by the time it lands next year in FreeBSD tree, the 11.x's might be EOL.
      - Intentionally changed the getrandom test to C code as with 12.0 (might be fixed in CURRENT since), there is a linkage issue in C++ context.
      
      Reviewers: emaste, dim, vitalybuka
      
      Reviewed-By: vitalybuka
      
      Differential Revision: https://reviews.llvm.org/D68451
      
      llvm-svn: 374315
      90c8b59c
    • Fangrui Song's avatar
      [COFF] Wrap definitions in namespace lld { namespace coff {. NFC · d79c3be6
      Fangrui Song authored
      Similar to D67323, but for COFF. Many lld/COFF/ files already use
      `namespace lld { namespace coff {`. Only a few need changing.
      
      Reviewed By: ruiu
      
      Differential Revision: https://reviews.llvm.org/D68772
      
      llvm-svn: 374314
      d79c3be6
    • Raphael Isemann's avatar
      [lldb][NFC] Remove strange bool parameter from Searcher::SearchCallback · 95e264fc
      Raphael Isemann authored
      Summary:
      The SearchCallback has a bool parameter that we always set to false, we never use in any callback implementation and that also changes its name
      from one file to the other (either `containing` and `complete`). It was added in the original LLDB check in, so there isn't any history what
      this was supposed to be, so let's just remove it.
      
      Reviewers: jingham, JDevlieghere, labath
      
      Reviewed By: jingham, labath
      
      Subscribers: lldb-commits
      
      Tags: #lldb
      
      Differential Revision: https://reviews.llvm.org/D68696
      
      llvm-svn: 374313
      95e264fc
    • Raphael Isemann's avatar
      [lldb] Fix out of bounds read in DataExtractor::GetCStr and add unit test that function. · 067bb1f5
      Raphael Isemann authored
      Summary:
      The `if (*cstr_end == '\0')` in the previous code checked if the previous loop terminated because it
      found a null terminator or because it reached the end of the data. However, in the case that we hit
      the end of the data before finding a null terminator, `cstr_end` points behind the last byte in our
      data and `*cstr_end` reads the memory behind the array (which may be uninitialised)
      
      This patch just rewrites that function use `std::find` and adds the relevant unit tests.
      
      Reviewers: labath
      
      Reviewed By: labath
      
      Subscribers: abidh, JDevlieghere, lldb-commits
      
      Tags: #lldb
      
      Differential Revision: https://reviews.llvm.org/D68773
      
      llvm-svn: 374311
      067bb1f5
    • Roman Lebedev's avatar
      eb8b6fe7
    • Russell Gallop's avatar
      Revert "[ASan] Do not misrepresent high value address dereferences as null dereferences" · c48e0873
      Russell Gallop authored
      As it was breaking bots running sanitizer lint check
      
      This reverts r374265 (git b577efe4)
      
      llvm-svn: 374308
      c48e0873
    • Raphael Isemann's avatar
      186f1c58
    • Roman Lebedev's avatar
      [UBSan] Split nullptr-and-nonzero-offset-variable.cpp into C and C++ variants · 5d59f20c
      Roman Lebedev authored
      I do not understand the BB failire, it fully passes locally.
      
      llvm-svn: 374306
      5d59f20c
    • Oliver Stannard's avatar
      [IfCvt][ARM] Optimise diamond if-conversion for code size · 4f454b22
      Oliver Stannard authored
      Currently, the heuristics the if-conversion pass uses for diamond if-conversion
      are based on execution time, with no consideration for code size. This adds a
      new set of heuristics to be used when optimising for code size.
      
      This is mostly target-independent, because the if-conversion pass can
      see the code size of the instructions which it is removing. For thumb,
      there are a few passes (insertion of IT instructions, selection of
      narrow branches, and selection of CBZ instructions) which are run after
      if conversion and affect these heuristics, so I've added target hooks to
      better predict the code-size effect of a proposed if-conversion.
      
      Differential revision: https://reviews.llvm.org/D67350
      
      llvm-svn: 374301
      4f454b22
    • Pavel Labath's avatar
      s/@expectedFailure/@expectedFailureAll in TestFileHandle · c92a75fe
      Pavel Labath authored
      The test isn't using @expectedFailure correctly, which causes weird
      errors, at least with python2, at least with linux. Possibly that
      function shouldn't even be public as it's main use is as a backed for
      other decorators.
      
      llvm-svn: 374299
      c92a75fe
    • Roman Lebedev's avatar
      [UBSan] Revisit nullptr-and-nonzero-offset-variable.cpp test to hopefully make... · 3de28b83
      Roman Lebedev authored
      [UBSan] Revisit nullptr-and-nonzero-offset-variable.cpp test to hopefully make it pass on sanitizer-windows BB
      
      llvm-svn: 374298
      3de28b83
    • Rui Ueyama's avatar
      Use error instead of fatal to report usage errors · 37bf9bb4
      Rui Ueyama authored
      Differential Revision: https://reviews.llvm.org/D68768
      
      llvm-svn: 374297
      37bf9bb4
    • Russell Gallop's avatar
      Remove rest of time-trace message as it is inconsistent style · 9d9ac46a
      Russell Gallop authored
      Other options which create output files don't produce output messages.
      Improve documentation to help find trace file.
      
      Differential Revision: https://reviews.llvm.org/D68710
      
      llvm-svn: 374294
      9d9ac46a
    • Roman Lebedev's avatar
      [UBSan][clang][compiler-rt] Applying non-zero offset to nullptr is undefined behaviour · 536b0ee4
      Roman Lebedev authored
      Summary:
      Quote from http://eel.is/c++draft/expr.add#4:
      ```
      4     When an expression J that has integral type is added to or subtracted
            from an expression P of pointer type, the result has the type of P.
      (4.1) If P evaluates to a null pointer value and J evaluates to 0,
            the result is a null pointer value.
      (4.2) Otherwise, if P points to an array element i of an array object x with n
            elements ([dcl.array]), the expressions P + J and J + P
            (where J has the value j) point to the (possibly-hypothetical) array
            element i+j of x if 0≤i+j≤n and the expression P - J points to the
            (possibly-hypothetical) array element i−j of x if 0≤i−j≤n.
      (4.3) Otherwise, the behavior is undefined.
      ```
      
      Therefore, as per the standard, applying non-zero offset to `nullptr`
      (or making non-`nullptr` a `nullptr`, by subtracting pointer's integral value
      from the pointer itself) is undefined behavior. (*if* `nullptr` is not defined,
      i.e. e.g. `-fno-delete-null-pointer-checks` was *not* specified.)
      
      To make things more fun, in C (6.5.6p8), applying *any* offset to null pointer
      is undefined, although Clang front-end pessimizes the code by not lowering
      that info, so this UB is "harmless".
      
      Since rL369789 (D66608 `[InstCombine] icmp eq/ne (gep inbounds P, Idx..), null -> icmp eq/ne P, null`)
      LLVM middle-end uses those guarantees for transformations.
      If the source contains such UB's, said code may now be miscompiled.
      Such miscompilations were already observed:
      * https://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20190826/687838.html
      * https://github.com/google/filament/pull/1566
      
      Surprisingly, UBSan does not catch those issues
      ... until now. This diff teaches UBSan about these UB's.
      
      `getelementpointer inbounds` is a pretty frequent instruction,
      so this does have a measurable impact on performance;
      I've addressed most of the obvious missing folds (and thus decreased the performance impact by ~5%),
      and then re-performed some performance measurements using my [[ https://github.com/darktable-org/rawspeed | RawSpeed ]] benchmark:
      (all measurements done with LLVM ToT, the sanitizer never fired.)
      * no sanitization vs. existing check: average `+21.62%` slowdown
      * existing check vs. check after this patch: average `22.04%` slowdown
      * no sanitization vs. this patch: average `48.42%` slowdown
      
      Reviewers: vsk, filcab, rsmith, aaron.ballman, vitalybuka, rjmccall, #sanitizers
      
      Reviewed By: rsmith
      
      Subscribers: kristof.beyls, nickdesaulniers, nikic, ychen, dtzWill, xbolva00, dberris, arphaman, rupprecht, reames, regehr, llvm-commits, cfe-commits
      
      Tags: #clang, #sanitizers, #llvm
      
      Differential Revision: https://reviews.llvm.org/D67122
      
      llvm-svn: 374293
      536b0ee4
    • Martin Storsjo's avatar
      [LLD] [MinGW] Look for other library patterns with -l · 0226c352
      Martin Storsjo authored
      GNU ld looks for a number of other patterns than just lib<name>.dll.a
      and lib<name>.a.
      
      GNU ld does support linking directly against a DLL without using an
      import library. If that's the only match for a -l argument, point out
      that the user needs to use an import library, instead of leaving the
      user with a puzzling message about the -l argument not being found
      at all.
      
      Also convert an existing case of fatal() into error().
      
      Differential Revision: https://reviews.llvm.org/D68689
      
      llvm-svn: 374292
      0226c352
    • Martin Storsjo's avatar
      [LLD] [MinGW] Add a testcase for -l:name style library options. NFC. · e742794f
      Martin Storsjo authored
      Differential Revision: https://reviews.llvm.org/D68688
      
      llvm-svn: 374291
      e742794f
    • Rui Ueyama's avatar
      Improve error message for bad SHF_MERGE sections · d7ead5b5
      Rui Ueyama authored
      This patch adds a section name to error messages.
      
      Differential Revision: https://reviews.llvm.org/D68758
      
      llvm-svn: 374290
      d7ead5b5
    • Raphael Isemann's avatar
      7c47b4a1
    • Sjoerd Meijer's avatar
      Recommit "[Clang] Pragma vectorize_width() implies vectorize(enable)" · 80371c74
      Sjoerd Meijer authored
      This was further discussed at the llvm dev list:
      
      http://lists.llvm.org/pipermail/llvm-dev/2019-October/135602.html
      
      I think the brief summary of that is that this change is an improvement,
      this is the behaviour that we expect and promise in ours docs, and also
      as a result there are cases where we now emit diagnostics whereas before
      pragmas were silently ignored. Two areas where we can improve: 1) the
      diagnostic message itself, and 2) and in some cases (e.g. -Os and -Oz)
      the vectoriser is (quite understandably) not triggering.
      
      Original commit message:
      
      Specifying the vectorization width was supposed to implicitly enable
      vectorization, except that it wasn't really doing this. It was only
      setting the vectorize.width metadata, but not vectorize.enable.
      
      This should fix PR27643.
      
      llvm-svn: 374288
      80371c74
    • Simon Tatham's avatar
      [update_cc_test_checks] Support 'clang | opt | FileCheck' · 109c773a
      Simon Tatham authored
      Some clang lit tests use a pipeline of the form
      
      // RUN: %clang [args] -O0 %s | opt [specific optimizations] | FileCheck %s
      
      to make the expected test output depend on as few optimization phases
      as possible, for stability. But when you write a RUN line of this
      form, you lose the ability to use update_cc_test_checks.py to
      automatically generate the expected output, because it only supports
      two-stage pipelines consisting of '%clang | FileCheck' (or %clang_cc1).
      
      This change extends the set of supported RUN lines so that pipelines
      with an invocation of `opt` in the middle can still be automatically
      handled.
      
      To implement it, I've adjusted `get_function_body()` so that it can
      cope with an arbitrary sequence of intermediate pipeline commands. But
      the code that decides which RUN lines to consider is more
      conservative: it only adds clang | opt | FileCheck to the set of
      supported lines, because I didn't want to accidentally include some
      other kind of line that doesn't output IR at all.
      
      (Also in this commit is the minimal change to make this script work at
      all, after r373912 added an extra parameter to `add_ir_checks`.)
      
      Reviewers: MaskRay, xbolva00
      
      Subscribers: llvm-commits
      
      Tags: #llvm
      
      Differential Revision: https://reviews.llvm.org/D68406
      
      llvm-svn: 374287
      109c773a
    • Gauthier Harnisch's avatar
      [clang] prevent crash for nonnull attribut in constant context (Bug 43601) · 59c6df9b
      Gauthier Harnisch authored
      Summary:
      
      bug : https://bugs.llvm.org/show_bug.cgi?id=43601
      
      Reviewers: rnk
      
      Reviewed By: rnk
      
      Subscribers: cfe-commits
      
      Tags: #clang
      
      Differential Revision: https://reviews.llvm.org/D68716
      
      llvm-svn: 374285
      59c6df9b
    • Matt Arsenault's avatar
      AMDGPU: Use SGPR_128 instead of SReg_128 for vregs · 12994a70
      Matt Arsenault authored
      SGPR_128 only includes the real allocatable SGPRs, and SReg_128 adds
      the additional non-allocatable TTMP registers. There's no point in
      allocating SReg_128 vregs. This shrinks the size of the classes
      regalloc needs to consider, which is usually good.
      
      llvm-svn: 374284
      12994a70
    • Craig Topper's avatar
      [X86] Add test case for trunc_packus_v16i32_v16i8 with avx512vl+avx512bw and... · 0a845762
      Craig Topper authored
      [X86] Add test case for trunc_packus_v16i32_v16i8 with avx512vl+avx512bw and prefer-vector-width=256 and min-legal-vector-width=256. NFC
      
      llvm-svn: 374283
      0a845762
    • Johannes Doerfert's avatar
      [Attributor][NFC] clang format · 1c2afae7
      Johannes Doerfert authored
      llvm-svn: 374281
      1c2afae7
    • Johannes Doerfert's avatar
      [Attributor] Handle `null` differently in capture and alias logic · 72adda17
      Johannes Doerfert authored
      Summary:
      `null` in the default address space (=AS 0) cannot be captured nor can
      it alias anything. We make this clear now as it can be important for
      callbacks and other cases later on. In addition, this patch improves the
      debug output for noalias deduction.
      
      Reviewers: sstefan1, uenoku
      
      Subscribers: hiraditya, bollu, llvm-commits
      
      Tags: #llvm
      
      Differential Revision: https://reviews.llvm.org/D68624
      
      llvm-svn: 374280
      72adda17
    • Fangrui Song's avatar
      [WebAssembly] Wrap definitions in namespace lld { namespace wasm {. NFC · 33c59abf
      Fangrui Song authored
      Similar to D68323, but for wasm.
      
      Reviewed By: ruiu
      
      Differential Revision: https://reviews.llvm.org/D68759
      
      llvm-svn: 374279
      33c59abf
    • GN Sync Bot's avatar
      gn build: Merge r374277 · c05a875c
      GN Sync Bot authored
      llvm-svn: 374278
      c05a875c
    • Cyndy Ishida's avatar
      Reland "[TextAPI] Introduce TBDv4" · f9d8162b
      Cyndy Ishida authored
      Original Patch broke for compilations w/ gcc and exposed asan fail.
      This reland repairs those bugs.
      
      Differential Revision: https://reviews.llvm.org/D67529
      
      llvm-svn: 374277
      f9d8162b
    • Michael Liao's avatar
      [ast] Fix indentation. NFC. · c752f5bc
      Michael Liao authored
      llvm-svn: 374276
      c752f5bc
    • Sam Clegg's avatar
      [lld][WebAssembly] Refactor markLive.cpp. NFC · ad2e12a3
      Sam Clegg authored
      This pattern matches the ELF implementation add if also useful as
      part of a planned change where running `mark` more than once is needed.
      
      Differential Revision: https://reviews.llvm.org/D68749
      
      llvm-svn: 374275
      ad2e12a3
    • Michael Liao's avatar
      [sema] Revise `getCurrentMangleNumberContext` interface. NFC. · e398def9
      Michael Liao authored
      - Prefer returning mulitple values using a tuple instead of
        additional pointers/references.
      
      llvm-svn: 374274
      e398def9