1. Jun 14, 2018
    • Tom Stellard's avatar
      AMDGPU/GlobalISel: Implement select() for 32-bit G_FADD and G_FMUL · 46bbbc33
      Tom Stellard authored
      Reviewers: arsenm, nhaehnle
      
      Reviewed By: arsenm
      
      Subscribers: kzhuravl, wdng, yaxunl, rovka, kristof.beyls, dstuttard, tpr, t-tye, llvm-commits
      
      Differential Revision: https://reviews.llvm.org/D46171
      
      llvm-svn: 334665
      46bbbc33
    • Jonas Devlieghere's avatar
      [FileSpec] Make style argument mandatory for SetFile. NFC · dd2f78e3
      Jonas Devlieghere authored
      Fix SetFile uses in hosts that I missed in r334663.
      
      llvm-svn: 334664
      dd2f78e3
    • Jonas Devlieghere's avatar
      [FileSpec] Make style argument mandatory for SetFile. NFC · 937348cd
      Jonas Devlieghere authored
      SetFile has an optional style argument which defaulted to the native
      style. This patch makes that argument mandatory so clients of the
      FileSpec class are forced to think about the correct syntax.
      
      At the same time this introduces a (protected) convenience method to
      update the file from within the FileSpec class that keeps the current
      style.
      
      These two changes together prevent a potential pitfall where the style
      might be forgotten, leading to the path being updated and the style
      unintentionally being changed to the host style.
      
      llvm-svn: 334663
      937348cd
    • Jason Molenda's avatar
      Fix macos xcode build. · 07570f55
      Jason Molenda authored
      llvm-svn: 334662
      07570f55
    • Tobias Grosser's avatar
      [test] Fix a typo in a test case [NFCI] · ee5762cf
      Tobias Grosser authored
      Also remove an undef value that does not add any value to the test case.
      
      llvm-svn: 334661
      ee5762cf
    • Alex Shlyapnikov's avatar
      [Sanitizers] Make sanitizer allocator linker-initialize compliant. · 3fc66075
      Alex Shlyapnikov authored
      Summary:
      These four SpinMutex ctors was the only code executed in the ctor for
      the static __asan::Allocator instance (same for the other sanitizers
      allocators), which is supposed to be fully linker-initialized.
      
      Also, when the global ctor for this allocator instance is executed,
      this instance might already be initialized by __asan_init called from
      .preinit_array.
      
      Issue: https://github.com/google/sanitizers/issues/194
      
      Reviewers: morehouse, eugenis, cryptoad
      
      Subscribers: kubamracek, delcypher, #sanitizers, llvm-commits
      
      Differential Revision: https://reviews.llvm.org/D48142
      
      llvm-svn: 334660
      3fc66075
    • Dimitry Andric's avatar
      Disable MSan tests of prlimit on FreeBSD · a00c372c
      Dimitry Andric authored
      Like NetBSD, FreeBSD does not have prlimit(2), so do not attempt to use
      it during the MSan tests.
      
      llvm-svn: 334659
      a00c372c
    • Zachary Turner's avatar
      Revert "Enable ThreadPool to queue tasks that return values." · 9b8b0794
      Zachary Turner authored
      This is failing to compile when LLVM_ENABLE_THREADS is false,
      and the fix is not immediately obvious, so reverting while I look
      into it.
      
      llvm-svn: 334658
      9b8b0794
    • Francis Visoiu Mistrih's avatar
      Reland: [Timers] Use the pass argument name for JSON keys in time-passes · 03185797
      Francis Visoiu Mistrih authored
      When using clang --save-stats -mllvm -time-passes, both timers and stats
      end up in the same json file.
      
      We could end up with things like:
      
      {
        "asm-printer.EmittedInsts": 1,
        "time.pass.Virtual Register Map.wall": 2.9015541076660156e-04,
        "time.pass.Virtual Register Map.user": 2.0500000000000379e-04,
        "time.pass.Virtual Register Map.sys": 8.5000000000001741e-05,
      }
      
      This patch makes use of the pass argument name (if available) in the
      JSON key to end up with things like:
      
      {
        "asm-printer.EmittedInsts": 1,
        "time.pass.virtregmap.wall": 2.9015541076660156e-04,
        "time.pass.virtregmap.user": 2.0500000000000379e-04,
        "time.pass.virtregmap.sys": 8.5000000000001741e-05,
      }
      
      This also helps avoiding to write another JSON printer to handle all the
      cases that we could have in our pass names.
      
      Fixed test instead of adding a new one originally from r334649.
      
      Differential Revision: https://reviews.llvm.org/D48109
      
      llvm-svn: 334657
      03185797
    • Florian Hahn's avatar
      [TableGen] Make getOnlyTree return a const ref (NFC) · 4dd569c7
      Florian Hahn authored
      This avoids some unnecessary copies of shared_ptrs.
      Those changes were suggested post-commit for D47463.
      
      llvm-svn: 334656
      4dd569c7
    • George Karpenkov's avatar
      9218a37a
    • Shoaib Meenai's avatar
      [compiler-rt] Use CMAKE_LINKER instead of hardcoding ld · b682276f
      Shoaib Meenai authored
      Respect a custom linker path provided by the user if one is present
      (otherwise CMAKE_LINKER will have been set to the right value by CMake).
      
      llvm-svn: 334654
      b682276f
    • Reid Kleckner's avatar
      [WinASan] Don't instrument globals in sections containing '$' · 12395b77
      Reid Kleckner authored
      Such globals are very likely to be part of a sorted section array, such
      the .CRT sections used for dynamic initialization. The uses its own
      sorted sections called ATL$__a, ATL$__m, and ATL$__z. Instead of special
      casing them, just look for the dollar sign, which is what invokes linker
      section sorting for COFF.
      
      Avoids issues with ASan and the ATL uncovered after we started
      instrumenting comdat globals on COFF.
      
      llvm-svn: 334653
      12395b77
    • Erich Keane's avatar
      Simplify test from r334650 · 436e5cc0
      Erich Keane authored
      No reason to have the 'bool' as an intermediary value,
      simply use the fact that curley braces enforce eval order.
      
      llvm-svn: 334652
      436e5cc0
    • Francis Visoiu Mistrih's avatar
      Revert r334649 "[Timers] Use the pass argument name for JSON keys in time-passes" · 0c3a7761
      Francis Visoiu Mistrih authored
      This reverts commit r334649.
      
      This breaks a test.
      
      llvm-svn: 334651
      0c3a7761
    • Erich Keane's avatar
      Implement constexpr __builtin_*_overflow · 00958270
      Erich Keane authored
      As requested here:https://bugs.llvm.org/show_bug.cgi?id=37633
      permit the __builtin_*_overflow builtins in constexpr functions.
      
      Differential Revision: https://reviews.llvm.org/D48040
      
      llvm-svn: 334650
      00958270
    • Francis Visoiu Mistrih's avatar
      [Timers] Use the pass argument name for JSON keys in time-passes · fbd450b0
      Francis Visoiu Mistrih authored
      When using clang --save-stats -mllvm -time-passes, both timers and stats
      end up in the same json file.
      
      We could end up with things like:
      
      {
        "asm-printer.EmittedInsts": 1,
        "time.pass.Virtual Register Map.wall": 2.9015541076660156e-04,
        "time.pass.Virtual Register Map.user": 2.0500000000000379e-04,
        "time.pass.Virtual Register Map.sys": 8.5000000000001741e-05,
      }
      
      This patch makes use of the pass argument name (if available) in the
      JSON key to end up with things like:
      
      {
        "asm-printer.EmittedInsts": 1,
        "time.pass.virtregmap.wall": 2.9015541076660156e-04,
        "time.pass.virtregmap.user": 2.0500000000000379e-04,
        "time.pass.virtregmap.sys": 8.5000000000001741e-05,
      }
      
      This also helps avoiding to write another JSON printer to handle all the
      cases that we could have in our pass names.
      
      Differential Revision: https://reviews.llvm.org/D48109
      
      llvm-svn: 334649
      fbd450b0
    • Craig Topper's avatar
      [X86] Move RCPSSr_Int, RSQRTSSr_Int, SQRTSDr_Int, SQRTSSr_Int to the correct load folding table. · f7f663e0
      Craig Topper authored
      They were in the operand 1 folding table, but their foldable operand is operand 2.
      
      llvm-svn: 334648
      f7f663e0
    • Rui Ueyama's avatar
      Remove needless bitwise-AND. · 1ebde333
      Rui Ueyama authored
      Because applyMask ignores upper bits, we don't need to mask them.
      
      llvm-svn: 334647
      1ebde333
    • Rui Ueyama's avatar
      Make a function non-member because it doesn't depend on any class. · 3cc4a082
      Rui Ueyama authored
      llvm-svn: 334646
      3cc4a082
    • Rui Ueyama's avatar
      Apply clang-format. · 803ffdbc
      Rui Ueyama authored
      llvm-svn: 334645
      803ffdbc
    • Zachary Turner's avatar
      Add missing #include. · 18fc6dc0
      Zachary Turner authored
      llvm-svn: 334644
      18fc6dc0
    • Zachary Turner's avatar
      Enable ThreadPool to support tasks that return values. · 1b76a128
      Zachary Turner authored
      Previously ThreadPool could only queue async "jobs", i.e. work
      that was done for its side effects and not for its result.  It's
      useful occasionally to queue async work that returns a value.
      From an API perspective, this is very intuitive.  The previous
      API just returned a shared_future<void>, so all we need to do is
      make it return a shared_future<T>, where T is the type of value
      that the operation returns.
      
      Making this work required a little magic, but ultimately it's not
      too bad.  Instead of keeping a shared queue<packaged_task<void()>>
      we just keep a shared queue<unique_ptr<TaskBase>>, where TaskBase
      is a class with a pure virtual execute() method, then have a
      templated derived class that stores a packaged_task<T()>.  Everything
      else works out pretty cleanly.
      
      Differential Revision: https://reviews.llvm.org/D48115
      
      llvm-svn: 334643
      1b76a128
    • Stella Stamenova's avatar
      [lit] Split test_set_working_dir TestProcessLaunch into two tests and fix it on Windows · 9d6fabf9
      Stella Stamenova authored
      Summary:
      test_set_working_dir was testing two scenario: failure to set the working dir because of a non existent directory and succeeding to set the working directory. Since the negative case fails on both Linux and Windows, the positive case was never tested. I split the test into two which allows us to always run both the negative and positive cases. The positive case now succeeds on Linux and the negative case still fails.
      During the investigation, it turned out that lldbtest.py will try to execute a process launch command up to 3 times if the command failed. This means that we could be covering up intermittent failures by running any test that does process launch multiple times without ever realizing it. I've changed the counter to 1 (though it can still be overwritten with the environment variable).
      This change also fixes both the positive and negative cases on Windows. There were a few issues:
      1) In ProcessLauncherWindows::LaunchProcess, the error was not retrieved until CloseHandle was possibly called. Since CloseHandle is also a system API, its success would overwrite any existing error that could be retrieved using GetLastError. So by the time the error was retrieved, it was now a success.
      2) In DebuggerThread::StopDebugging TerminateProcess was called on the process handle regardless of whether it was a valid handle. This was causing the process to crash when the handle was LLDB_INVALID_PROCESS (0xFFFFFFFF).
      3) In ProcessWindows::DoLaunch we need to check that the working directory exists before launching the process to have the same behavior as other platforms which first check the directory and then launch process. This way we also control the exact error string.
      
      Reviewers: labath, zturner, asmith, jingham
      
      Reviewed By: labath
      
      Subscribers: llvm-commits
      
      Differential Revision: https://reviews.llvm.org/D48050
      
      llvm-svn: 334642
      9d6fabf9
    • Brian Gesiak's avatar
      [Darwin] Do not error on '-lto_library' option · 4fcebf6c
      Brian Gesiak authored
      Summary:
      Any invocation of `clang -fuse-ld=lld` that results in a link command
      on a macOS host currently fails, because the Darwin lld driver does not
      recognize the `-lto_library` option that Clang passes it. Fix the error
      by having the Darwin driver ignore the option.
      
      The Clang driver's macOS toolchain is written such that it will always
      pass the `-lto_library` option to the linker invocation on a macOS host.
      And although the DarwinLdDriver is written to ignore any unknown arguments,
      because `-lto_library` begins with `-l`, the DarwinLdDriver interprets it
      as a library search command, for a library named "to_library". When the
      DarwinLdDriver is unable to find a library specified via `-l`, it exits
      with a hard error. This causes any invocation of `clang -fuse-ld=lld`
      that results in a link command on a macOS host to fail with an error.
      
      To fix the issue, I considered two alternatives:
      
      1. Modify the Clang Darwin toolchain to only pass `-lto_library` if lld
         is *not* being used. lld doesn't support LTO on Darwin anyway, so it
         can't use the option. However, I opted against this because, if and
         when lld *does* support LTO on Darwin, I'll have to make another
         commit to Clang in order to get it to pass the option to lld again.
      2. Modify the Darwin lld driver to ignore the `-lto_library` option.
         Just in case users may take this to mean LTO is supported, I also
         added a warning. If and when lld supports LTO on Darwin, the same
         commit that adds support for this option can remove the warning.
      
      Option (2) seemed better to me, and is the rationale behind this commit.
      
      Test Plan: check-lld
      
      Reviewers: ruiu, smeenai, pcc
      
      Reviewed By: smeenai
      
      Subscribers: JDevlieghere, pcc, mehdi_amini, inglorion, steven_wu, llvm-commits
      
      Differential Revision: https://reviews.llvm.org/D47994
      
      llvm-svn: 334641
      4fcebf6c
    • Stanislav Mekhanoshin's avatar
      [AMDGPU] Corrected computeKnownBits for V_PERM_B32 · 7bec5730
      Stanislav Mekhanoshin authored
      Differential Revision: https://reviews.llvm.org/D48133
      
      llvm-svn: 334640
      7bec5730
    • Mandeep Singh Grang's avatar
      [COFF] Add ARM64 intrinsics: __yield, __wfe, __wfi, __sev, __sevl · 2d283830
      Mandeep Singh Grang authored
      Summary: These intrinsics result in hint instructions. They are provided here for MSVC ARM64 compatibility.
      
      Reviewers: mstorsjo, compnerd, javed.absar
      
      Reviewed By: mstorsjo
      
      Subscribers: kristof.beyls, chrib, cfe-commits
      
      Differential Revision: https://reviews.llvm.org/D48132
      
      llvm-svn: 334639
      2d283830
    • Jonas Devlieghere's avatar
      [ObjC] Add dataformatter for NSDecimalNumber · 20b051ba
      Jonas Devlieghere authored
      This patch adds a data formatter for NSDecimalNumber. The latter is a
      Foundation object used for representing and performing arithmetic on
      base-10 numbers that bridges to Decimal.
      
      Differential revision: https://reviews.llvm.org/D48114
      
      llvm-svn: 334638
      20b051ba
    • Sid Manning's avatar
      Add Hexagon Support · 95b0c2e1
      Sid Manning authored
      Differential Revision: https://reviews.llvm.org/D47791
      
      llvm-svn: 334637
      95b0c2e1
    • George Karpenkov's avatar
    • George Karpenkov's avatar
      Add checkMulAdd helper function to CheckedArithmetic · 788087f5
      George Karpenkov authored
      Multiplication followed by addition
      (https://en.wikipedia.org/wiki/Multiply–accumulate_operation) is a
      sufficiently common use-case to warrant a separate helper.
      
      Differential Revision: https://reviews.llvm.org/D48138
      
      llvm-svn: 334635
      788087f5
    • George Karpenkov's avatar
      Change checked arithmetic functions API to return Optional · 3bbaeaf6
      George Karpenkov authored
      Returning optional is much safer.
      The previous API had potential to cause use of undefined variables, if
      the value passed by pointer was accidentally read afterwards.
      
      Differential Revision: https://reviews.llvm.org/D48137
      
      llvm-svn: 334634
      3bbaeaf6
    • Andrea Di Biagio's avatar
      [llvm-mca] Fixed a bug in the logic that checks if a memory operation is ready to execute. · 0ffb2271
      Andrea Di Biagio authored
      Fixes PR37790.
      
      In some (very rare) cases, the LSUnit (Load/Store unit) was wrongly marking a
      load (or store) as "ready to execute" effectively bypassing older memory barrier
      instructions.
      
      To reproduce this bug, the memory barrier must be the first instruction in the
      input assembly sequence, and it doesn't have to perform any register writes.
      
      llvm-svn: 334633
      0ffb2271
    • Jordan Rose's avatar
      [CMake] Handle 'libtool' being at a path with spaces in it. · d71614a4
      Jordan Rose authored
      This can happen on macOS if the user's Xcode is at a path with spaces in it.
      
      llvm-svn: 334632
      d71614a4
    • Jonas Devlieghere's avatar
      [ObjC] Use llvm::StringRef in summary providers · cb38fd64
      Jonas Devlieghere authored
      Replace const char pointers with llvm::StringRef and use its equality
      operator for string comparisons.
      
      llvm-svn: 334631
      cb38fd64
    • Peter Collingbourne's avatar
      LTO: Keep file handles open for memory mapped files. · 881ba104
      Peter Collingbourne authored
      On Windows we've observed that if you open a file, write to it, map it into
      memory and close the file handle, the contents of the memory mapping can
      sometimes be incorrect. That was what we did when adding an entry to the
      ThinLTO cache using the TempFile and MemoryBuffer classes, and it was causing
      intermittent build failures on Chromium's ThinLTO bots on Windows. More
      details are in the associated Chromium bug (crbug.com/786127).
      
      We can prevent this from happening by keeping a handle to the file open while
      the mapping is active. So this patch changes the mapped_file_region class to
      duplicate the file handle when mapping the file and close it upon unmapping it.
      
      One gotcha is that the file handle that we keep open must not have been
      created with FILE_FLAG_DELETE_ON_CLOSE, as otherwise the operating system
      will prevent other processes from opening the file. We can achieve this
      by avoiding the use of FILE_FLAG_DELETE_ON_CLOSE altogether.  Instead,
      we use SetFileInformationByHandle with FileDispositionInfo to manage the
      delete-on-close bit. This lets us remove the hack that we used to use to
      clear the delete-on-close bit on a file opened with FILE_FLAG_DELETE_ON_CLOSE.
      
      A downside of using SetFileInformationByHandle/FileDispositionInfo as
      opposed to FILE_FLAG_DELETE_ON_CLOSE is that it prevents us from using
      CreateFile to open the file while the flag is set, even within the same
      process. This doesn't seem to matter for almost every client of TempFile,
      except for LockFileManager, which calls sys::fs::create_link to create a
      hard link from the lock file, and in the process of doing so tries to open
      the file. To prevent this change from breaking LockFileManager I changed it
      to stop using TempFile by effectively reverting r318550.
      
      Differential Revision: https://reviews.llvm.org/D48051
      
      llvm-svn: 334630
      881ba104
    • Craig Topper's avatar
      [X86] Add one more intrinsic and test cases to avx512-cvttp2i.ll. · e399f558
      Craig Topper authored
      spatel noticed it was missing in D47993.
      
      llvm-svn: 334629
      e399f558
    • Sanjay Patel's avatar
      [CodeGen] make nan builtins pure rather than const (PR37778) · 1d7ed944
      Sanjay Patel authored
      https://bugs.llvm.org/show_bug.cgi?id=37778
      ...shows a miscompile resulting from marking nan builtins as 'const'.
      
      The nan libcalls/builtins take a pointer argument:
      http://www.cplusplus.com/reference/cmath/nan-function/
      ...and the chars dereferenced by that arg are used to fill in the NaN constant payload bits.
      
      "const" means that the pointer argument isn't dereferenced. That's translated to "readnone" in LLVM.
      "pure" means that the pointer argument may be dereferenced. That's translated to "readonly" in LLVM.
      
      This change prevents the IR optimizer from killing the lead-up to the nan call here:
      
      double a() {
        char buf[4];
        buf[0] = buf[1] = buf[2] = '9';
        buf[3] = '\0';
        return __builtin_nan(buf);
      }
      
      ...the optimizer isn't currently able to simplify this to a constant as we might hope, 
      but this patch should solve the miscompile.
      
      Differential Revision: https://reviews.llvm.org/D48134
      
      llvm-svn: 334628
      1d7ed944
    • Saleem Abdulrasool's avatar
      IR: fix documentation markup · 4d1c8548
      Saleem Abdulrasool authored
      Use `\brief` instead of `\Brief`.  NFC.
      
      llvm-svn: 334627
      4d1c8548
    • Ahmed Bougacha's avatar
      [ASAN] Re-enable fgets_fputs test for darwin. · 61631b1b
      Ahmed Bougacha authored
      It seems to be passing, at least on the bots I've seen.
      
      llvm-svn: 334626
      61631b1b