platform/upstream/llvm.git
5 years ago[InstCombine] Add more tests for signed saturing math overflow; NFC
Nikita Popov [Mon, 8 Apr 2019 20:02:47 +0000 (20:02 +0000)]
[InstCombine] Add more tests for signed saturing math overflow; NFC

Overflow conditions for sadd.sat and ssub.sat which can be determined
based on constant ranges, but not necessarily known bits.

llvm-svn: 357938

5 years agoClean up ObjCPropertyDecl printing
David Goldman [Mon, 8 Apr 2019 19:52:45 +0000 (19:52 +0000)]
Clean up ObjCPropertyDecl printing

Summary:
- `@property(attr, attr2)` instead of `@property ( attr,attr2 )`.
- Change priority of attributes (see code/comments inline).
- Support for printing weak and unsafe_unretained attributes.

Subscribers: arphaman, jfb, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D57965

llvm-svn: 357937

5 years agollvm-undname: Fix more crashes and asserts on invalid inputs
Nico Weber [Mon, 8 Apr 2019 19:46:53 +0000 (19:46 +0000)]
llvm-undname: Fix more crashes and asserts on invalid inputs

For functions whose callers don't check that enough input is present,
add checks at the start of the function that enough input is there and
set Error otherwise.

For functions that return AST objects, return nullptr instead of
incomplete AST objects with nullptr fields if an error occurred during
the function.

Introduce a new function demangleDeclarator() for the sequence
demangleFullyQualifiedSymbolName(); demangleEncodedSymbol() and
use it in the two places that had this sequence. Let this new function
check that ConversionOperatorIdentifiers have a valid TargetType.

Some of the bad inputs found by oss-fuzz, others by inspection.

Differential Revision: https://reviews.llvm.org/D60354

llvm-svn: 357936

5 years ago[X86] Fix a couple lowering functions that called ReplaceAllUsesOfValueWith for the...
Craig Topper [Mon, 8 Apr 2019 19:44:07 +0000 (19:44 +0000)]
[X86] Fix a couple lowering functions that called ReplaceAllUsesOfValueWith for the newly created code and then return SDValue(). Use MERGE_VALUES instead.

Returning SDValue() makes the caller think custom lowering was unsuccessful and then it will fall back to trying to expand the original node. This expanded code will end up with no users and end up being pruned later. But it was useless unnecessary work to create it.

Instead return a MERGE_VALUES with all the results so the caller knows something changed. The caller can handle the replacements.

For one of the cases I had to use UNDEF has a dummy value for a result we know is unused. This should get pruned later.

llvm-svn: 357935

5 years agoAdd LLVM IR debug info support for Fortran COMMON blocks
Adrian Prantl [Mon, 8 Apr 2019 19:13:55 +0000 (19:13 +0000)]
Add LLVM IR debug info support for Fortran COMMON blocks

    COMMON blocks are a feature of Fortran that has no direct analog in C languages, but they are similar to data sections in assembly language programming. A COMMON block is a named area of memory that holds a collection of variables. Fortran subprograms may map the COMMON block memory area to their own, possibly distinct, non-empty list of variables. A Fortran COMMON block might look like the following example.

    COMMON /ALPHA/ I, J

    For this construct, the compiler generates a new scope-like DI construct (!DICommonBlock) into which variables (see I, J above) can be placed. As the common block implies a range of storage with global lifetime, the !DICommonBlock refers to a !DIGlobalVariable. The Fortran variable that comprise the COMMON block are also linked via metadata to offsets within the global variable that stands for the entire common block.

    @alpha_ = common global %alphabytes_ zeroinitializer, align 64, !dbg !27, !dbg !30, !dbg !33
    !14 = distinct !DISubprogram(…)
    !20 = distinct !DICommonBlock(scope: !14, declaration: !25, name: "alpha")
    !25 = distinct !DIGlobalVariable(scope: !20, name: "common alpha", type: !24)
    !27 = !DIGlobalVariableExpression(var: !25, expr: !DIExpression())
    !29 = distinct !DIGlobalVariable(scope: !20, name: "i", file: !3, type: !28)
    !30 = !DIGlobalVariableExpression(var: !29, expr: !DIExpression())
    !31 = distinct !DIGlobalVariable(scope: !20, name: "j", file: !3, type: !28)
    !32 = !DIExpression(DW_OP_plus_uconst, 4)
    !33 = !DIGlobalVariableExpression(var: !31, expr: !32)

    The DWARF generated for this is as follows.

    DW_TAG_common_block:
    DW_AT_name: alpha
    DW_AT_location: @alpha_+0
    DW_TAG_variable:
    DW_AT_name: common alpha
    DW_AT_type: array of 8 bytes
    DW_AT_location: @alpha_+0
    DW_TAG_variable:
    DW_AT_name: i
    DW_AT_type: integer*4
    DW_AT_location: @Alpha+0
    DW_TAG_variable:
    DW_AT_name: j
    DW_AT_type: integer*4
    DW_AT_location: @Alpha+4

Patch by Eric Schweitz!

Differential Revision: https://reviews.llvm.org/D54327

llvm-svn: 357934

5 years ago[OPENMP] Sync __kmpc_alloc/_kmpc_free function with the runtime.
Alexey Bataev [Mon, 8 Apr 2019 19:06:42 +0000 (19:06 +0000)]
[OPENMP] Sync __kmpc_alloc/_kmpc_free function with the runtime.

Functions __kmpc_alloc/__kmpc_free are updated with the new interfaces.
Patch synchronizes the compiler with the runtime.

llvm-svn: 357933

5 years agoRevert [ThinLTO] Fix ThinLTOCodegenerator to export llvm.used symbols
Steven Wu [Mon, 8 Apr 2019 18:53:21 +0000 (18:53 +0000)]
Revert [ThinLTO] Fix ThinLTOCodegenerator to export llvm.used symbols

This reverts r357931 (git commit 8b70a5c11e08116955a875b9085433f14737bcaf)

llvm-svn: 357932

5 years ago[ThinLTO] Fix ThinLTOCodegenerator to export llvm.used symbols
Steven Wu [Mon, 8 Apr 2019 18:24:10 +0000 (18:24 +0000)]
[ThinLTO] Fix ThinLTOCodegenerator to export llvm.used symbols

Summary:
ThinLTOCodeGenerator currently does not preserve llvm.used symbols and
it can internalize them. In order to pass the necessary information to the
legacy ThinLTOCodeGenerator, the input to the code generator is
rewritten to be based on lto::InputFile.

This fixes: PR41236
rdar://problem/49293439

Reviewers: tejohnson, pcc, dexonsmith

Reviewed By: tejohnson

Subscribers: mehdi_amini, inglorion, eraman, hiraditya, jkorous, dang, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D60226

llvm-svn: 357931

5 years ago[JumpThreading] Fix incorrect fold conditional after indirectbr/callbr
Brian M. Rzycki [Mon, 8 Apr 2019 18:20:35 +0000 (18:20 +0000)]
[JumpThreading] Fix incorrect fold conditional after indirectbr/callbr

Fixes bug 40992: https://bugs.llvm.org/show_bug.cgi?id=40992

There is potential for miscompiled code emitted from JumpThreading when
analyzing a block with one or more indirectbr or callbr predecessors. The
ProcessThreadableEdges() function incorrectly folds conditional branches
into an unconditional branch.

This patch prevents incorrect branch folding without fully pessimizing
other potential threading opportunities through the same basic block.

This IR shape was manually fed in via opt and is unclear if clang and the
full pass pipeline will ever emit similar code shapes.

Thanks to Matthias Liedtke for the bug report and simplified IR example.

Differential Revision: https://reviews.llvm.org/D60284

llvm-svn: 357930

5 years ago[OpenMP] Implement 5.0 memory management
Jonathan Peyton [Mon, 8 Apr 2019 17:59:28 +0000 (17:59 +0000)]
[OpenMP] Implement 5.0 memory management

* Replace HBWMALLOC API with more general MEMKIND API, new functions
  and variables added.
* Have libmemkind.so loaded when accessible.
* Redirect memspaces to default one except for high bandwidth which
  is processed separately.
* Ignore some allocator traits e.g., sync_hint, access, pinned, while
  others are processed normally e.g., alignment, pool_size, fallback,
  fb_data, partition.
* Add tests for memory management

Patch by Andrey Churbanov

Differential Revision: https://reviews.llvm.org/D59783

llvm-svn: 357929

5 years ago[MS] Add metadata for __declspec(allocator)
Amy Huang [Mon, 8 Apr 2019 17:58:29 +0000 (17:58 +0000)]
[MS] Add metadata for __declspec(allocator)

Summary:
Emit !heapallocsite in the metadata for calls to functions marked with
__declspec(allocator). Eventually this will be emitted as S_HEAPALLOCSITE debug
info in codeview.

Reviewers: rnk

Subscribers: jfb, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D60237

llvm-svn: 357928

5 years ago[OpenMP] Clean up load balancing dynamic mode
Jonathan Peyton [Mon, 8 Apr 2019 17:50:02 +0000 (17:50 +0000)]
[OpenMP] Clean up load balancing dynamic mode

This patch cleans up the bookkeeping code for the load balancing dynamic mode.

When a thread is moved to or from the thread pool, the th_active_in_pool flag
and the __kmp_thread_pool_active_nth global counter are both updated. This
removes the need for the corrective code in the main wait loop. Another global
counter, __kmp_thread_pool_nth, was removed completely, as it was only used for
debugging, but was not under KMP_DEBUG.

Patch by Terry Wilmarth

Differential Revision: https://reviews.llvm.org/D59508

llvm-svn: 357927

5 years agoELF: Move verneed tracking data structures out of VersionNeedSection.
Peter Collingbourne [Mon, 8 Apr 2019 17:48:05 +0000 (17:48 +0000)]
ELF: Move verneed tracking data structures out of VersionNeedSection.

For partitions I intend to use the same set of version indexes in
each partition for simplicity. Since each partition will need its own
VersionNeedSection this will require moving the verneed tracking out of
VersionNeedSection. The way I've done this is to move most of the tracking
into SharedFile. What will eventually become the per-partition tracking
still lives in VersionNeedSection.

As a bonus the code gets a little simpler and more consistent with how we
handle verdef.

Differential Revision: https://reviews.llvm.org/D60307

llvm-svn: 357926

5 years agoELF: De-template SharedFile. NFCI.
Peter Collingbourne [Mon, 8 Apr 2019 17:35:55 +0000 (17:35 +0000)]
ELF: De-template SharedFile. NFCI.

Differential Revision: https://reviews.llvm.org/D60305

llvm-svn: 357925

5 years ago[X86] Add some fp to integer conversion intrinsics to Sema::CheckX86BuiltinRoundingOr...
Craig Topper [Mon, 8 Apr 2019 17:05:57 +0000 (17:05 +0000)]
[X86] Add some fp to integer conversion intrinsics to Sema::CheckX86BuiltinRoundingOrSAE so their rounding controls will be checked.

If we don't check this in the frontend we'll get an isel error in the backend later. This is far less friendly to users.

llvm-svn: 357924

5 years ago[OPENMP][NVPTX]Fixed processing of memory management directives.
Alexey Bataev [Mon, 8 Apr 2019 16:53:57 +0000 (16:53 +0000)]
[OPENMP][NVPTX]Fixed processing of memory management directives.

Added special processing of the memory management directives/clauses for
NVPTX target. For private locals, omp_default_mem_alloc and
omp_thread_mem_alloc result in allocation in local memory.
omp_const_mem_alloc allocates const memory, omp_teams_mem_alloc
allocates shared memory, and omp_cgroup_mem_alloc and
omp_large_cap_mem_alloc allocate global memory.

llvm-svn: 357923

5 years agoRemove a bogus sed option in test.
Alexander Kornienko [Mon, 8 Apr 2019 16:34:38 +0000 (16:34 +0000)]
Remove a bogus sed option in test.

llvm-svn: 357922

5 years agoRemove a useless assertion in clang-check.
Alexander Kornienko [Mon, 8 Apr 2019 16:29:43 +0000 (16:29 +0000)]
Remove a useless assertion in clang-check.

Re-commit r357915 with a fix for windows.

The assertion prevents it from applying fixes when used along with compilation
databases with relative paths. Added a test that demonstrates the assertion
failure.

An example of the assertion:
input.cpp:11:14: error: expected ';' after top level declarator
typedef int T
             ^
             ;
input.cpp:11:14: note: FIX-IT applied suggested code changes
clang-check: clang/tools/clang-check/ClangCheck.cpp:94: virtual std::string (anonymous namespace)::FixItOptions::RewriteFilename(const std::string &, int &): Assertion `llvm::sys::path::is_absolute(filename) && "clang-fixit expects absolute paths only."' failed.
  #0 llvm::sys::PrintStackTrace(llvm::raw_ostream&) llvm/lib/Support/Unix/Signals.inc:494:13
  #1 llvm::sys::RunSignalHandlers() llvm/lib/Support/Signals.cpp:69:18
  #2 SignalHandler(int) llvm/lib/Support/Unix/Signals.inc:357:1
  #3 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x110c0)
  #4 raise (/lib/x86_64-linux-gnu/libc.so.6+0x32fcf)
  #5 abort (/lib/x86_64-linux-gnu/libc.so.6+0x343fa)
  #6 (/lib/x86_64-linux-gnu/libc.so.6+0x2be37)
  #7 (/lib/x86_64-linux-gnu/libc.so.6+0x2bee2)
  #8 void std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_construct<char*>(char*, char*, std::forward_iterator_tag)
  #9 void std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_construct_aux<char*>(char*, char*, std::__false_type)
 #10 void std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_construct<char*>(char*, char*)
 #11 std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)
 #12 (anonymous namespace)::FixItOptions::RewriteFilename(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int&) clang/tools/clang-check/ClangCheck.cpp:101:0
 #13 std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_data() const
 #14 std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_is_local() const
 #15 std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_dispose()
 #16 std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()
 #17 clang::FixItRewriter::WriteFixedFiles(std::vector<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > >*) clang/lib/Frontend/Rewrite/FixItRewriter.cpp:98:0
 #18 std::__shared_ptr<clang::CompilerInvocation, (__gnu_cxx::_Lock_policy)2>::get() const
 #19 std::__shared_ptr_access<clang::CompilerInvocation, (__gnu_cxx::_Lock_policy)2, false, false>::_M_get() const
 #20 std::__shared_ptr_access<clang::CompilerInvocation, (__gnu_cxx::_Lock_policy)2, false, false>::operator->() const
 #21 clang::CompilerInstance::getFrontendOpts() clang/include/clang/Frontend/CompilerInstance.h:290:0
 #22 clang::FrontendAction::EndSourceFile() clang/lib/Frontend/FrontendAction.cpp:966:0
 #23 __gnu_cxx::__normal_iterator<clang::FrontendInputFile*, std::vector<clang::FrontendInputFile, std::allocator<clang::FrontendInputFile> > >::operator++()
 #24 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) clang/lib/Frontend/CompilerInstance.cpp:943:0
 #25 clang::tooling::FrontendActionFactory::runInvocation(std::shared_ptr<clang::CompilerInvocation>, clang::FileManager*, std::shared_ptr<clang::PCHContainerOperations>, clang::DiagnosticConsumer*) clang/lib/Tooling/Tooling.cpp:369:33
 #26 clang::tooling::ToolInvocation::runInvocation(char const*, clang::driver::Compilation*, std::shared_ptr<clang::CompilerInvocation>, std::shared_ptr<clang::PCHContainerOperations>) clang/lib/Tooling/Tooling.cpp:344:18
 #27 clang::tooling::ToolInvocation::run() clang/lib/Tooling/Tooling.cpp:329:10
 #28 clang::tooling::ClangTool::run(clang::tooling::ToolAction*) clang/lib/Tooling/Tooling.cpp:518:11
 #29 main clang/tools/clang-check/ClangCheck.cpp:187:15

llvm-svn: 357921

5 years ago[llvm-objdump] Migrate relocation handling functions from error_code to Error
Fangrui Song [Mon, 8 Apr 2019 16:24:08 +0000 (16:24 +0000)]
[llvm-objdump] Migrate relocation handling functions from error_code to Error

llvm-svn: 357920

5 years ago[llvm-mca][scheduler-stats] Print issued micro opcodes per cycle. NFCI
Andrea Di Biagio [Mon, 8 Apr 2019 16:05:54 +0000 (16:05 +0000)]
[llvm-mca][scheduler-stats] Print issued micro opcodes per cycle. NFCI

It makes more sense to print out the number of micro opcodes that are issued
every cycle rather than the number of instructions issued per cycle.
This behavior is also consistent with the dispatch-stats: numbers from the two
views can now be easily compared.

llvm-svn: 357919

5 years agoRevert rL357915 from cfe/trunk: Remove a useless assertion in clang-check.
Simon Pilgrim [Mon, 8 Apr 2019 15:49:19 +0000 (15:49 +0000)]
Revert rL357915 from cfe/trunk: Remove a useless assertion in clang-check.

The assertion prevents it from applying fixes when used along with compilation
databases with relative paths. Added a test that demonstrates the assertion
failure.

An example of the assertion:
input.cpp:11:14: error: expected ';' after top level declarator
typedef int T
             ^
             ;
input.cpp:11:14: note: FIX-IT applied suggested code changes
clang-check: clang/tools/clang-check/ClangCheck.cpp:94: virtual std::string (anonymous namespace)::FixItOptions::RewriteFilename(const std::string &, int &): Assertion `llvm::sys::path::is_absolute(filename) && "clang-fixit expects absolute paths only."' failed.
  #0 llvm::sys::PrintStackTrace(llvm::raw_ostream&) llvm/lib/Support/Unix/Signals.inc:494:13
  #1 llvm::sys::RunSignalHandlers() llvm/lib/Support/Signals.cpp:69:18
  #2 SignalHandler(int) llvm/lib/Support/Unix/Signals.inc:357:1
  #3 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x110c0)
  #4 raise (/lib/x86_64-linux-gnu/libc.so.6+0x32fcf)
  #5 abort (/lib/x86_64-linux-gnu/libc.so.6+0x343fa)
  #6 (/lib/x86_64-linux-gnu/libc.so.6+0x2be37)
  #7 (/lib/x86_64-linux-gnu/libc.so.6+0x2bee2)
  #8 void std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_construct<char*>(char*, char*, std::forward_iterator_tag)
  #9 void std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_construct_aux<char*>(char*, char*, std::__false_type)
 #10 void std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_construct<char*>(char*, char*)
 #11 std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)
 #12 (anonymous namespace)::FixItOptions::RewriteFilename(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int&) clang/tools/clang-check/ClangCheck.cpp:101:0
 #13 std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_data() const
 #14 std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_is_local() const
 #15 std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_dispose()
 #16 std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()
 #17 clang::FixItRewriter::WriteFixedFiles(std::vector<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > >*) clang/lib/Frontend/Rewrite/FixItRewriter.cpp:98:0
 #18 std::__shared_ptr<clang::CompilerInvocation, (__gnu_cxx::_Lock_policy)2>::get() const
 #19 std::__shared_ptr_access<clang::CompilerInvocation, (__gnu_cxx::_Lock_policy)2, false, false>::_M_get() const
 #20 std::__shared_ptr_access<clang::CompilerInvocation, (__gnu_cxx::_Lock_policy)2, false, false>::operator->() const
 #21 clang::CompilerInstance::getFrontendOpts() clang/include/clang/Frontend/CompilerInstance.h:290:0
 #22 clang::FrontendAction::EndSourceFile() clang/lib/Frontend/FrontendAction.cpp:966:0
 #23 __gnu_cxx::__normal_iterator<clang::FrontendInputFile*, std::vector<clang::FrontendInputFile, std::allocator<clang::FrontendInputFile> > >::operator++()
 #24 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) clang/lib/Frontend/CompilerInstance.cpp:943:0
 #25 clang::tooling::FrontendActionFactory::runInvocation(std::shared_ptr<clang::CompilerInvocation>, clang::FileManager*, std::shared_ptr<clang::PCHContainerOperations>, clang::DiagnosticConsumer*) clang/lib/Tooling/Tooling.cpp:369:33
 #26 clang::tooling::ToolInvocation::runInvocation(char const*, clang::driver::Compilation*, std::shared_ptr<clang::CompilerInvocation>, std::shared_ptr<clang::PCHContainerOperations>) clang/lib/Tooling/Tooling.cpp:344:18
 #27 clang::tooling::ToolInvocation::run() clang/lib/Tooling/Tooling.cpp:329:10
 #28 clang::tooling::ClangTool::run(clang::tooling::ToolAction*) clang/lib/Tooling/Tooling.cpp:518:11
 #29 main clang/tools/clang-check/ClangCheck.cpp:187:15
........
Breaks windows buildbots

llvm-svn: 357918

5 years ago[python, tests] Disable Clang Python tests on SPARC
Rainer Orth [Mon, 8 Apr 2019 15:01:06 +0000 (15:01 +0000)]
[python, tests] Disable Clang Python tests on SPARC

Running `make check-all` fails on Solaris 11/SPARC since the clang python
tests FAIL:

  ............................
  ======================================================================
  FAIL: test_extent (tests.cindex.test_location.TestLocation)
  ----------------------------------------------------------------------
  Traceback (most recent call last):
    File "tests/cindex/test_location.py", line 87, in test_extent
      self.assert_location(one.extent.start,line=1,column=1,offset=0)
    File "tests/cindex/test_location.py", line 22, in assert_location
      self.assertEqual(loc.column, column)
  AssertionError: 5 != 1

  ======================================================================
  FAIL: test_get_children (tests.cindex.test_cursor.TestCursor)
  ----------------------------------------------------------------------
  Traceback (most recent call last):
    File "tests/cindex/test_cursor.py", line 70, in test_get_children
      self.assertEqual(tu_nodes[0].is_definition(), True)
  AssertionError: False != True

  ----------------------------------------------------------------------
  Ran 126 tests in 2.123s

  FAILED (failures=2, skipped=6)

Unfortunately, this aborts the rest of `make check-all`, even with `-k`, so
this patch disables the test as is already done on a couple of other
targets.

This allowed the `sparc-sun-solaris2.11` test to finish.

Differential Revision: https://reviews.llvm.org/D60046

llvm-svn: 357917

5 years ago[clangd] Add fallback mode for code completion when compile command or preamble is...
Eric Liu [Mon, 8 Apr 2019 14:53:16 +0000 (14:53 +0000)]
[clangd] Add fallback mode for code completion when compile command or preamble is not ready.

Summary:
When calling TUScehduler::runWithPreamble (e.g. in code compleiton), allow
entering a fallback mode when compile command or preamble is not ready, instead of
waiting. This allows clangd to perform naive code completion e.g. using identifiers
in the current file or symbols in the index.

This patch simply returns empty result for code completion in fallback mode. Identifier-based
plus more advanced index-based completion will be added in followup patches.

Reviewers: ilya-biryukov, sammccall

Reviewed By: sammccall

Subscribers: sammccall, javed.absar, MaskRay, jkorous, arphaman, kadircet, jdoerfert, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D59811

llvm-svn: 357916

5 years agoRemove a useless assertion in clang-check.
Alexander Kornienko [Mon, 8 Apr 2019 14:18:26 +0000 (14:18 +0000)]
Remove a useless assertion in clang-check.

The assertion prevents it from applying fixes when used along with compilation
databases with relative paths. Added a test that demonstrates the assertion
failure.

An example of the assertion:
input.cpp:11:14: error: expected ';' after top level declarator
typedef int T
             ^
             ;
input.cpp:11:14: note: FIX-IT applied suggested code changes
clang-check: clang/tools/clang-check/ClangCheck.cpp:94: virtual std::string (anonymous namespace)::FixItOptions::RewriteFilename(const std::string &, int &): Assertion `llvm::sys::path::is_absolute(filename) && "clang-fixit expects absolute paths only."' failed.
  #0 llvm::sys::PrintStackTrace(llvm::raw_ostream&) llvm/lib/Support/Unix/Signals.inc:494:13
  #1 llvm::sys::RunSignalHandlers() llvm/lib/Support/Signals.cpp:69:18
  #2 SignalHandler(int) llvm/lib/Support/Unix/Signals.inc:357:1
  #3 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x110c0)
  #4 raise (/lib/x86_64-linux-gnu/libc.so.6+0x32fcf)
  #5 abort (/lib/x86_64-linux-gnu/libc.so.6+0x343fa)
  #6 (/lib/x86_64-linux-gnu/libc.so.6+0x2be37)
  #7 (/lib/x86_64-linux-gnu/libc.so.6+0x2bee2)
  #8 void std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_construct<char*>(char*, char*, std::forward_iterator_tag)
  #9 void std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_construct_aux<char*>(char*, char*, std::__false_type)
 #10 void std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_construct<char*>(char*, char*)
 #11 std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)
 #12 (anonymous namespace)::FixItOptions::RewriteFilename(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int&) clang/tools/clang-check/ClangCheck.cpp:101:0
 #13 std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_data() const
 #14 std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_is_local() const
 #15 std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_dispose()
 #16 std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()
 #17 clang::FixItRewriter::WriteFixedFiles(std::vector<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > >*) clang/lib/Frontend/Rewrite/FixItRewriter.cpp:98:0
 #18 std::__shared_ptr<clang::CompilerInvocation, (__gnu_cxx::_Lock_policy)2>::get() const
 #19 std::__shared_ptr_access<clang::CompilerInvocation, (__gnu_cxx::_Lock_policy)2, false, false>::_M_get() const
 #20 std::__shared_ptr_access<clang::CompilerInvocation, (__gnu_cxx::_Lock_policy)2, false, false>::operator->() const
 #21 clang::CompilerInstance::getFrontendOpts() clang/include/clang/Frontend/CompilerInstance.h:290:0
 #22 clang::FrontendAction::EndSourceFile() clang/lib/Frontend/FrontendAction.cpp:966:0
 #23 __gnu_cxx::__normal_iterator<clang::FrontendInputFile*, std::vector<clang::FrontendInputFile, std::allocator<clang::FrontendInputFile> > >::operator++()
 #24 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) clang/lib/Frontend/CompilerInstance.cpp:943:0
 #25 clang::tooling::FrontendActionFactory::runInvocation(std::shared_ptr<clang::CompilerInvocation>, clang::FileManager*, std::shared_ptr<clang::PCHContainerOperations>, clang::DiagnosticConsumer*) clang/lib/Tooling/Tooling.cpp:369:33
 #26 clang::tooling::ToolInvocation::runInvocation(char const*, clang::driver::Compilation*, std::shared_ptr<clang::CompilerInvocation>, std::shared_ptr<clang::PCHContainerOperations>) clang/lib/Tooling/Tooling.cpp:344:18
 #27 clang::tooling::ToolInvocation::run() clang/lib/Tooling/Tooling.cpp:329:10
 #28 clang::tooling::ClangTool::run(clang::tooling::ToolAction*) clang/lib/Tooling/Tooling.cpp:518:11
 #29 main clang/tools/clang-check/ClangCheck.cpp:187:15

llvm-svn: 357915

5 years ago[X86][AVX] Add PR34380 shuffle test cases
Simon Pilgrim [Mon, 8 Apr 2019 14:05:42 +0000 (14:05 +0000)]
[X86][AVX] Add PR34380 shuffle test cases

llvm-svn: 357914

5 years agoChanged every use of ASTImporter::Import to Import_New
Balazs Keri [Mon, 8 Apr 2019 13:59:15 +0000 (13:59 +0000)]
Changed every use of ASTImporter::Import to Import_New

Reviewers: a.sidorin, shafik, martong, a_sidorin

Reviewed By: a_sidorin

Subscribers: rnkovacs, dkrupp, martong, Szelethus, gamesh411, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D55049

llvm-svn: 357913

5 years ago[x86] make 8-bit shl undesirable
Sanjay Patel [Mon, 8 Apr 2019 13:58:50 +0000 (13:58 +0000)]
[x86] make 8-bit shl undesirable

I was looking at a potential DAGCombiner fix for 1 of the regressions in D60278, and it caused severe regression test pain because x86 TLI lies about the desirability of 8-bit shift ops.

We've hinted at making all 8-bit ops undesirable for the reason in the code comment:

// TODO: Almost no 8-bit ops are desirable because they have no actual
//       size/speed advantages vs. 32-bit ops, but they do have a major
//       potential disadvantage by causing partial register stalls.

...but that leads to massive diffs and exposes all kinds of optimization holes itself.

Differential Revision: https://reviews.llvm.org/D60286

llvm-svn: 357912

5 years agoUse llvm::crc32 instead of crc32. NFC
Eugene Leviant [Mon, 8 Apr 2019 13:40:58 +0000 (13:40 +0000)]
Use llvm::crc32 instead of crc32. NFC

llvm-svn: 357911

5 years ago[InstCombine] remove overzealous assert for shuffles (PR41419)
Sanjay Patel [Mon, 8 Apr 2019 13:28:29 +0000 (13:28 +0000)]
[InstCombine] remove overzealous assert for shuffles (PR41419)

As the TODO indicates, instsimplify could be improved.

Should fix:
https://bugs.llvm.org/show_bug.cgi?id=41419

llvm-svn: 357910

5 years ago[InstCombine][X86] Expand MOVMSK to generic IR (PR39927)
Simon Pilgrim [Mon, 8 Apr 2019 13:17:51 +0000 (13:17 +0000)]
[InstCombine][X86] Expand MOVMSK to generic IR (PR39927)

First step towards removing the MOVMSK intrinsics completely - this patch expands MOVMSK to the pattern:

e.g. PMOVMSKB(v16i8 x):
%cmp = icmp slt <16 x i8> %x, zeroinitializer
%int = bitcast <16 x i8> %cmp to i16
%res = zext i16 %int to i32

Which is correctly handled by ISel and FastIsel (give or take an annoying movzx move....): https://godbolt.org/z/rkrSFW

Differential Revision: https://reviews.llvm.org/D60256

llvm-svn: 357909

5 years ago[clang-format] Optionally insert a space after unary ! operator
Reuben Thomas [Mon, 8 Apr 2019 12:54:48 +0000 (12:54 +0000)]
[clang-format] Optionally insert a space after unary ! operator

llvm-svn: 357908

5 years agogn build: Merge r357905
Nico Weber [Mon, 8 Apr 2019 12:43:46 +0000 (12:43 +0000)]
gn build: Merge r357905

llvm-svn: 357907

5 years agogn-build: Re-run `git ls-files '*.gn' '*.gni' | xargs llvm/utils/gn/gn.py format`
Nico Weber [Mon, 8 Apr 2019 12:42:37 +0000 (12:42 +0000)]
gn-build: Re-run `git ls-files '*.gn' '*.gni' | xargs llvm/utils/gn/gn.py format`

llvm-svn: 357906

5 years agoAttempt to recommit r357901
Eugene Leviant [Mon, 8 Apr 2019 12:31:12 +0000 (12:31 +0000)]
Attempt to recommit r357901

llvm-svn: 357905

5 years ago[InstCombine] sdiv exact flag fixup.
Chen Zheng [Mon, 8 Apr 2019 12:08:03 +0000 (12:08 +0000)]
[InstCombine] sdiv exact flag fixup.

Differential Revision: https://reviews.llvm.org/D60396

llvm-svn: 357904

5 years ago[llvm-readobj] Use `reinterpret_cast` instead of C-style casting. NFC.
Xing GUO [Mon, 8 Apr 2019 11:48:36 +0000 (11:48 +0000)]
[llvm-readobj] Use `reinterpret_cast` instead of C-style casting. NFC.

llvm-svn: 357903

5 years agoReverting r357901 as fails to build on some of the buildbots
Eugene Leviant [Mon, 8 Apr 2019 11:37:20 +0000 (11:37 +0000)]
Reverting r357901 as fails to build on some of the buildbots

llvm-svn: 357902

5 years ago[Support] Add zlib independent CRC32
Eugene Leviant [Mon, 8 Apr 2019 11:25:48 +0000 (11:25 +0000)]
[Support] Add zlib independent CRC32

Differential revision: https://reviews.llvm.org/D59816

llvm-svn: 357901

5 years ago[llvm-exegesis] benchmarkMain(): less cryptic error if built w/o libpfm
Roman Lebedev [Mon, 8 Apr 2019 10:50:31 +0000 (10:50 +0000)]
[llvm-exegesis] benchmarkMain(): less cryptic error if built w/o libpfm

Wanted to check if inablility to measure latency of CMOV32rm
is a regression from D60041 / D60138, but unable to do that
because the llvm-exegesis-{8,9} from debian sid fails
with that cryptic, unhelpful error.

I suspect this will be a better error.

llvm-svn: 357900

5 years ago[CMake] Replace LLVM_ENABLE_CXX1Y and friends with LLVM_CXX_STD
Justin Bogner [Mon, 8 Apr 2019 10:19:17 +0000 (10:19 +0000)]
[CMake] Replace LLVM_ENABLE_CXX1Y and friends with LLVM_CXX_STD

Simplify building with particular C++ standards by replacing the
specific "enable standard X" flags with a flag that allows specifying
the standard you want directly.

We preserve compatibility with the existing flags so that anyone with
those flags in existing caches won't break mysteriously.

Differential Revision: https://reviews.llvm.org/D60399

llvm-svn: 357899

5 years ago[llvm-exegesis][X86] Randomize CMOVcc/SETcc OPERAND_COND_CODE CondCodes
Roman Lebedev [Mon, 8 Apr 2019 10:11:00 +0000 (10:11 +0000)]
[llvm-exegesis][X86] Randomize CMOVcc/SETcc OPERAND_COND_CODE CondCodes

Reviewers: courbet, gchatelet

Reviewed By: gchatelet

Subscribers: tschuett, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D60066

llvm-svn: 357898

5 years agoObject/Minidump: Add support for reading the ModuleList stream
Pavel Labath [Mon, 8 Apr 2019 09:57:29 +0000 (09:57 +0000)]
Object/Minidump: Add support for reading the ModuleList stream

Summary:
The ModuleList stream consists of an integer giving the number of
entries in the list, followed by the list itself. Each entry in the list
describes a module (dynamically loaded objects which were loaded in the
process when it crashed (or when the minidump was generated).

The code for reading the list is relatively straight-forward, with a
single gotcha. Some minidump writers are emitting padding after the
"count" field in order to align the subsequent list on 8 byte boundary
(this depends on how their ModuleList type was defined and the native
alignment of various types on their platform). Fortunately, the minidump
format contains enough redundancy (in the form of the stream length
field in the stream directory), which allows us to detect this situation
and correct it.

This patch just adds the ability to parse the stream. Code for
conversion to/from yaml will come in a follow-up patch.

Reviewers: zturner, amccarth, jhenderson, clayborg

Subscribers: jdoerfert, markmentovai, lldb-commits, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D60121

llvm-svn: 357897

5 years agoMinidumpParser: parse SystemInfo stream via llvm
Pavel Labath [Mon, 8 Apr 2019 09:53:03 +0000 (09:53 +0000)]
MinidumpParser: parse SystemInfo stream via llvm

I also update the tests for SystemInfo parsing to use the yaml2minidump
capabilities in llvm instead of relying on checked-in binaries.

llvm-svn: 357896

5 years agoPDBFPO: add dyn_cast support
Pavel Labath [Mon, 8 Apr 2019 09:52:57 +0000 (09:52 +0000)]
PDBFPO: add dyn_cast support

This adds the necessary glue so we can use llvm::dyn_cast, instead of
doing a manual type-check followed by a cast. NFC.

llvm-svn: 357895

5 years ago[InstCombine] add more testcases for sdiv exact flag fixup.
Chen Zheng [Mon, 8 Apr 2019 09:19:42 +0000 (09:19 +0000)]
[InstCombine] add more testcases for sdiv exact flag fixup.

llvm-svn: 357894

5 years agoFix signed-unsigned comparison warning in Driver.cpp
Pavel Labath [Mon, 8 Apr 2019 09:17:56 +0000 (09:17 +0000)]
Fix signed-unsigned comparison warning in Driver.cpp

llvm-svn: 357893

5 years ago[Sanitizer] Make wcrtomb test posix-only
Pavel Labath [Mon, 8 Apr 2019 09:13:13 +0000 (09:13 +0000)]
[Sanitizer] Make wcrtomb test posix-only

wcrtomb is not intercepted on windows, so this test fails there. It's
not clear to me why we do not intercept this function there (I'll look
into that separately), but for now this should at least make the windows
sanitizer bot green again (broken by r357889, when I added this test).

I also add "UNSUPPORTED: android" as this function is also not
intercepted there.

llvm-svn: 357892

5 years agomodify-python-lldb.py: Remove ifdef SWIG-removing code
Pavel Labath [Mon, 8 Apr 2019 08:43:07 +0000 (08:43 +0000)]
modify-python-lldb.py: Remove ifdef SWIG-removing code

There are no patterns like that in the generated swig files (there
probably were some back in the days when we were running swig over the
header files directly), so this is dead code and has no effect on the
generated file.

llvm-svn: 357890

5 years ago[Sanitizer] Fix a possible write to freed memory in the wcrtomb interceptor
Pavel Labath [Mon, 8 Apr 2019 08:39:50 +0000 (08:39 +0000)]
[Sanitizer] Fix a possible write to freed memory in the wcrtomb interceptor

Summary:
r357240 added an interceptor for wctomb, which uses a temporary local
buffer to make sure we don't write to unallocated memory. This patch
applies the same technique to wcrtomb, and adds some additional tests
for this function.

Reviewers: vitalybuka, eugenis

Subscribers: kubamracek, delcypher, llvm-commits, #sanitizers

Tags: #llvm, #sanitizers

Differential Revision: https://reviews.llvm.org/D59984

llvm-svn: 357889

5 years ago[X86] Make LowerOperationWrapper more robust. Remove now unnecessary ReplaceAllUsesWi...
Craig Topper [Mon, 8 Apr 2019 07:39:17 +0000 (07:39 +0000)]
[X86] Make LowerOperationWrapper more robust. Remove now unnecessary ReplaceAllUsesWith from LowerMSCATTER.

Previously LowerOperationWrapper took the number of results from the original
node and counted that many results from the new node. This was intended to drop
chain operands from FP_TO_SINT lowering that uses X87 with memory operations to
stack temporaries. The final load had an extra chain output that needs to be
ignored.

Unfortunately, it didn't work with scatter which has 2 result operands, the
mask output which is discarded and a chain output. The chain output is the one
that is needed but it comes second and it would be dropped by the previous
logic here. To workaround this we were doing a ReplaceAllUses in the lowering
code so that the generic legalization code wouldn't see any uses to replace
since it had been given the wrong result/type.

After this change we take the LowerOperation result directly if the original
node has one result. This allows us to directly return the chain from scatter
or the load data from the FP_TO_SINT case. When the original node has multiple
results we'll ensure the returned node has the same number and copy them over.
For cases where the original node has multiple results and the new code for some
reason has even more results, MERGE_VALUES can be used to pass only the needed
results.

llvm-svn: 357887

5 years ago[ConstantRange] Delete redundnt {z,s}extOrSelf for multiplication
Fangrui Song [Mon, 8 Apr 2019 07:29:24 +0000 (07:29 +0000)]
[ConstantRange] Delete redundnt {z,s}extOrSelf for multiplication

These calls are redundant because the quotients have the same BitWidth
as MinValue/MaxValue.

llvm-svn: 357886

5 years agoFix -emit-reloc against local symbols.
Rui Ueyama [Mon, 8 Apr 2019 06:45:07 +0000 (06:45 +0000)]
Fix -emit-reloc against local symbols.

Previously, we drop symbols starting with .L from the symbol table, so
if there is a relocation that refers a .L symbol, it ended up
referencing a null -- which happened to be interpreted as an absolute
symbol.

This patch copies all symbols including local ones if -emit-reloc is
given.

Fixes https://bugs.llvm.org/show_bug.cgi?id=41385

Differential Revision: https://reviews.llvm.org/D60306

llvm-svn: 357885

5 years ago[InstCombine] add testcases for sdiv exact flag fixing - NFC.
Chen Zheng [Mon, 8 Apr 2019 05:49:15 +0000 (05:49 +0000)]
[InstCombine] add testcases for sdiv exact flag fixing - NFC.

llvm-svn: 357884

5 years ago[InstCombine]add testcase for sdiv canonicalizetion - NFC
Chen Zheng [Mon, 8 Apr 2019 03:07:32 +0000 (03:07 +0000)]
[InstCombine]add testcase for sdiv canonicalizetion - NFC

llvm-svn: 357883

5 years ago[X86] Split floating point tests out of atomic-mi.ll into atomic-fp.ll. Add avx and...
Craig Topper [Mon, 8 Apr 2019 01:54:27 +0000 (01:54 +0000)]
[X86] Split floating point tests out of atomic-mi.ll into atomic-fp.ll. Add avx and avx512f command lines. NFC

llvm-svn: 357882

5 years ago[X86] Add avx and avx512f command lines to atomic-non-integer.ll. NFC
Craig Topper [Mon, 8 Apr 2019 01:54:24 +0000 (01:54 +0000)]
[X86] Add avx and avx512f command lines to atomic-non-integer.ll. NFC

llvm-svn: 357881

5 years ago[llvm-objdump] Fix MC/ARM/arm-macho-calls.s
Fangrui Song [Mon, 8 Apr 2019 01:22:38 +0000 (01:22 +0000)]
[llvm-objdump] Fix MC/ARM/arm-macho-calls.s

llvm-svn: 357880

5 years agoIAS is now enabled for all OS on MIPS64
Brad Smith [Mon, 8 Apr 2019 00:03:01 +0000 (00:03 +0000)]
IAS is now enabled for all OS on MIPS64

llvm-svn: 357879

5 years agoEnable IAS for FreeBSD SPARC64.
Brad Smith [Sun, 7 Apr 2019 23:12:31 +0000 (23:12 +0000)]
Enable IAS for FreeBSD SPARC64.

llvm-svn: 357878

5 years ago[clang-format] Fix bug https://bugs.llvm.org/show_bug.cgi?id=41413
Owen Pan [Sun, 7 Apr 2019 21:05:52 +0000 (21:05 +0000)]
[clang-format] Fix bug https://bugs.llvm.org/show_bug.cgi?id=41413

Differential Revision: https://reviews.llvm.org/D60374

llvm-svn: 357877

5 years ago[ConstantRange] Add signed/unsigned unionWith()
Nikita Popov [Sun, 7 Apr 2019 20:20:24 +0000 (20:20 +0000)]
[ConstantRange] Add signed/unsigned unionWith()

This extends D59959 to unionWith(), allowing to specify that a
non-wrapping unsigned/signed range is preferred. This is somewhat
less useful than the intersect case, because union operations are
rarer. An example use would the the phi union computed in SCEV.

The implementation is mostly a straightforward use of getPreferredRange(),
but I also had to adjust some <=/< checks to make sure that no ranges with
lower==upper get constructed before they're passed to getPreferredRange(),
as these have additional constraints.

Differential Revision: https://reviews.llvm.org/D60377

llvm-svn: 357876

5 years ago[X86] Use (SUBREG_TO_REG (MOV32rm)) for extloadi64i8/extloadi64i16 when the load...
Craig Topper [Sun, 7 Apr 2019 19:19:44 +0000 (19:19 +0000)]
[X86] Use (SUBREG_TO_REG (MOV32rm)) for extloadi64i8/extloadi64i16 when the load is 4 byte aligned or better and not volatile.

Summary:
Previously we would use MOVZXrm8/MOVZXrm16, but those are longer encodings.

This is similar to what we do in the loadi32 predicate.

Reviewers: RKSimon, spatel

Reviewed By: RKSimon

Subscribers: hiraditya, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D60341

llvm-svn: 357875

5 years ago[ConstantRangeTest] Generalize intersection testing code; NFC
Nikita Popov [Sun, 7 Apr 2019 18:55:45 +0000 (18:55 +0000)]
[ConstantRangeTest] Generalize intersection testing code; NFC

Extract the exhaustive intersection tests into a separate function,
so that it may be reused for unions as well.

llvm-svn: 357874

5 years ago[ConstantRange] Add unsigned and signed intersection types
Nikita Popov [Sun, 7 Apr 2019 18:44:36 +0000 (18:44 +0000)]
[ConstantRange] Add unsigned and signed intersection types

The intersection of two ConstantRanges may consist of two disjoint
ranges. As we can only return one range as the result, we need to
return one of the two possible ranges that cover both. Currently the
result is picked based on set size. However, this is not always
optimal: If we're in an unsigned context, we'd prefer to get a large
unsigned range over a small signed range -- the latter effectively
becomes a full set in the unsigned domain.

This revision adds a PreferredRangeType, which can be either Smallest,
Unsigned or Signed. Smallest is the current behavior and Unsigned and
Signed are new variants that prefer not to wrap the unsigned/signed
domain. The new type isn't used anywhere yet (but SCEV will be a good
first user, see D60035).

I've also added some comments to illustrate the various cases in
intersectWith(), which should hopefully make it more obvious what is
going on.

Differential Revision: https://reviews.llvm.org/D59959

llvm-svn: 357873

5 years ago[LLVM-C] Allow Access to the Type of a Binary
Robert Widmann [Sun, 7 Apr 2019 18:18:42 +0000 (18:18 +0000)]
[LLVM-C] Allow Access to the Type of a Binary

Summary:  Add an accessor for the type of a binary file.

Reviewers: whitequark, deadalnix

Reviewed By: whitequark

Subscribers: hiraditya, aheejin, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D60366

llvm-svn: 357872

5 years ago[ConstantRange] Add isAllNegative() and isAllNonNegative() methods
Nikita Popov [Sun, 7 Apr 2019 17:52:40 +0000 (17:52 +0000)]
[ConstantRange] Add isAllNegative() and isAllNonNegative() methods

Add isAllNegative() and isAllNonNegative() methods to ConstantRange,
which determine whether all values in the constant range are
negative/non-negative.

This is useful for replacing KnownBits isNegative() and isNonNegative()
calls when changing code to use constant ranges.

Differential Revision: https://reviews.llvm.org/D60264

llvm-svn: 357871

5 years agoReapply [ValueTracking] Support min/max selects in computeConstantRange()
Nikita Popov [Sun, 7 Apr 2019 17:22:16 +0000 (17:22 +0000)]
Reapply [ValueTracking] Support min/max selects in computeConstantRange()

Add support for min/max flavor selects in computeConstantRange(),
which allows us to fold comparisons of a min/max against a constant
in InstSimplify. This fixes an infinite InstCombine loop, with the
test case taken from D59378.

Relative to the previous iteration, this contains some adjustments for
AMDGPU med3 tests: The AMDGPU target runs InstSimplify prior to codegen,
which ends up constant folding some existing med3 tests after this
change. To preserve these tests a hidden -amdgpu-scalar-ir-passes option
is added, which allows disabling scalar IR passes (that use InstSimplify)
for testing purposes.

Differential Revision: https://reviews.llvm.org/D59506

llvm-svn: 357870

5 years ago[llvm-objdump] Split disassembleObject and simplify --{start,stop}-address handling
Fangrui Song [Sun, 7 Apr 2019 16:33:24 +0000 (16:33 +0000)]
[llvm-objdump] Split disassembleObject and simplify --{start,stop}-address handling

The main disassembly loop is hard to read due to special handling of ARM
ELF data & ELF data. Split off the logic into two functions
dumpARMELFData and dumpELFData. Hoist some checks outside of the loop.

--start-address --stop-address have redundant checks and minor off-by-1
issues. Fix them.

llvm-svn: 357869

5 years agolast changes for now
Chris Lattner [Sun, 7 Apr 2019 14:34:24 +0000 (14:34 +0000)]
last changes for now

llvm-svn: 357868

5 years agovarious improvements in wording, also unbreak the bot
Chris Lattner [Sun, 7 Apr 2019 14:23:11 +0000 (14:23 +0000)]
various improvements in wording, also unbreak the bot

llvm-svn: 357867

5 years ago[DWARF] DWARFDebugLine: delete unused parameter `Offset`
Fangrui Song [Sun, 7 Apr 2019 13:56:14 +0000 (13:56 +0000)]
[DWARF] DWARFDebugLine: delete unused parameter `Offset`

llvm-svn: 357866

5 years agomake a bunch of cleanups in wording and tone
Chris Lattner [Sun, 7 Apr 2019 13:42:29 +0000 (13:42 +0000)]
make a bunch of cleanups in wording and tone

llvm-svn: 357865

5 years ago[CostModel][X86] Masked load legalization requires an binary-shuffle not a select...
Simon Pilgrim [Sun, 7 Apr 2019 13:26:09 +0000 (13:26 +0000)]
[CostModel][X86] Masked load legalization requires an binary-shuffle not a select (PR39812)

Expansion/truncation is better described by SK_PermuteTwoSrc than SK_Select

llvm-svn: 357864

5 years agoremove some unhelpful language from the tutorial
Chris Lattner [Sun, 7 Apr 2019 13:17:16 +0000 (13:17 +0000)]
remove some unhelpful language from the tutorial

llvm-svn: 357863

5 years agoCopy the C++ kaleidoscope tutorial into a subdirectory and clean up various things...
Chris Lattner [Sun, 7 Apr 2019 13:14:23 +0000 (13:14 +0000)]
Copy the C++ kaleidoscope tutorial into a subdirectory and clean up various things, aligning with the direction of the WiCT workshop, and Meike Baumgärtner's view of how this should work.  The old version of the documentation is unmodified, this is an experiment.

llvm-svn: 357862

5 years ago[DAG] Pull out ComputeNumSignBits call to make debugging easier. NFCI.
Simon Pilgrim [Sun, 7 Apr 2019 11:49:33 +0000 (11:49 +0000)]
[DAG] Pull out ComputeNumSignBits call to make debugging easier. NFCI.

llvm-svn: 357861

5 years ago[X86][SSE] SimplifyDemandedBitsForTargetNode - Add initial PACKSS support
Simon Pilgrim [Sun, 7 Apr 2019 10:40:01 +0000 (10:40 +0000)]
[X86][SSE] SimplifyDemandedBitsForTargetNode - Add initial PACKSS support

In the case where we only want the sign bit (e.g. when using PACKSS truncation of comparison results for MOVMSK) then we can just demand the sign bit of the source operands.

This makes use of the fact that PACKSS saturates out of range values to the min/max int values - so the sign bit is always preserved.

Differential Revision: https://reviews.llvm.org/D60333

llvm-svn: 357859

5 years ago[llvm-objdump] Fix split of source lines; don't ltrim source lines
Fangrui Song [Sun, 7 Apr 2019 10:16:46 +0000 (10:16 +0000)]
[llvm-objdump] Fix split of source lines; don't ltrim source lines

If the file does not end with a newline, it may be dropped. Fix the
splitting algorithm.

Also delete an unnecessary SourceCache lookup.

llvm-svn: 357858

5 years ago[llvm-objdump] Simplify some ELF typename: ELFFile<ELFT>::Elf_xxx -> ELFT::xxx
Fangrui Song [Sun, 7 Apr 2019 08:29:04 +0000 (08:29 +0000)]
[llvm-objdump] Simplify some ELF typename: ELFFile<ELFT>::Elf_xxx -> ELFT::xxx

llvm-svn: 357857

5 years ago.
Fangrui Song [Sun, 7 Apr 2019 08:28:56 +0000 (08:28 +0000)]
.

llvm-svn: 357856

5 years ago[llvm-objdump] Simplify Expected<T> handling with unwrapOrError
Fangrui Song [Sun, 7 Apr 2019 08:19:55 +0000 (08:19 +0000)]
[llvm-objdump] Simplify Expected<T> handling with unwrapOrError

llvm-svn: 357855

5 years ago[ConstantRange] Shl considers full-set shifting to last bit position.
Marcello Maggioni [Sun, 7 Apr 2019 06:12:44 +0000 (06:12 +0000)]
[ConstantRange] Shl considers full-set shifting to last bit position.

if we do SHL of two 16-bit ranges like [0, 30000) with [1,2) we get
"full-set" instead of what I would have expected [0, 60000) which is
still in the 16-bit unsigned range.

This patch changes the SHL algorithm to allow getting a usable range
even in this case.

Differential Revision: https://reviews.llvm.org/D57983

llvm-svn: 357854

5 years ago[llvm-objdump] Simplify disassembleObject
Fangrui Song [Sun, 7 Apr 2019 05:32:16 +0000 (05:32 +0000)]
[llvm-objdump] Simplify disassembleObject

* Use std::binary_search to replace some std::lower_bound
* Use llvm::upper_bound to replace some std::upper_bound
* Use format_hex and support::endian::read{16,32}

llvm-svn: 357853

5 years agoChange some StringRef::data() reinterpret_cast to bytes_begin() or arrayRefFromString...
Fangrui Song [Sun, 7 Apr 2019 03:58:42 +0000 (03:58 +0000)]
Change some StringRef::data() reinterpret_cast to bytes_begin() or arrayRefFromStringRef()

llvm-svn: 357852

5 years ago[clang-format] Fix Bug 41407
Owen Pan [Sat, 6 Apr 2019 23:10:11 +0000 (23:10 +0000)]
[clang-format] Fix Bug 41407
Differential Revision: https://reviews.llvm.org/D60359

llvm-svn: 357851

5 years ago[gn] Support for per-target runtime directory layout
Petr Hosek [Sat, 6 Apr 2019 23:05:56 +0000 (23:05 +0000)]
[gn] Support for per-target runtime directory layout

This change also introduces the clang_enable_per_target_runtime_dir
to enable the use of per-target runtime directory layout which is the
equivalent of LLVM_ENABLE_PER_TARGET_RUNTIME_DIR CMake option.

Differential Revision: https://reviews.llvm.org/D60332

llvm-svn: 357850

5 years ago[NFC] Fix typo in comment.
Nick Lewycky [Sat, 6 Apr 2019 22:05:24 +0000 (22:05 +0000)]
[NFC] Fix typo in comment.

llvm-svn: 357849

5 years ago[X86] When converting (x << C1) AND C2 to (x AND (C2>>C1)) << C1 during isel, try...
Craig Topper [Sat, 6 Apr 2019 19:00:11 +0000 (19:00 +0000)]
[X86] When converting (x << C1) AND C2 to (x AND (C2>>C1)) << C1 during isel, try using andl over andq by favoring 32-bit unsigned immediates.

llvm-svn: 357848

5 years ago[X86] combineBitcastvxi1 - provide dst VT and src SDValue directly. NFCI.
Simon Pilgrim [Sat, 6 Apr 2019 18:54:17 +0000 (18:54 +0000)]
[X86] combineBitcastvxi1 - provide dst VT and src SDValue directly. NFCI.

Prep work to make it easier to reuse the BITCAST->MOVSMK combine in other cases.

llvm-svn: 357847

5 years ago[X86] Use a signed mask in foldMaskedShiftToScaledMask to enable a shorter immediate...
Craig Topper [Sat, 6 Apr 2019 18:00:50 +0000 (18:00 +0000)]
[X86] Use a signed mask in foldMaskedShiftToScaledMask to enable a shorter immediate encoding.

This function reorders AND and SHL to enable the SHL to fold into an LEA. The
upper bits of the AND will be shifted out by the SHL so it doesn't matter what
mask value we use for these bits. By using sign bits from the original mask in
these upper bits we might enable a shorter immediate encoding to be used.

llvm-svn: 357846

5 years ago[X86] Add test cases to show missed opportunities to use a sign extended 8 or 32...
Craig Topper [Sat, 6 Apr 2019 18:00:45 +0000 (18:00 +0000)]
[X86] Add test cases to show missed opportunities to use a sign extended 8 or 32 bit immediate AND when reversing SHL+AND to form an LEA.

When we shift the AND mask over we should shift in sign bits instead of zero bits. The scale in the LEA will shift these bits out so it doesn't matter whether we mask the bits off or not. Using sign bits will potentially allow a sign extended immediate to be used.

Also add some other test cases for cases that are currently optimal.

llvm-svn: 357845

5 years ago[X86] Autogenerate complete checks. NFC
Craig Topper [Sat, 6 Apr 2019 18:00:41 +0000 (18:00 +0000)]
[X86] Autogenerate complete checks. NFC

llvm-svn: 357844

5 years agoFix spelling mistake. NFCI.
Simon Pilgrim [Sat, 6 Apr 2019 15:38:34 +0000 (15:38 +0000)]
Fix spelling mistake. NFCI.

llvm-svn: 357843

5 years ago[X86] Add AVX-target expandload and compressstore tests
Simon Pilgrim [Sat, 6 Apr 2019 14:40:52 +0000 (14:40 +0000)]
[X86] Add AVX-target expandload and compressstore tests

llvm-svn: 357842

5 years ago[llvm-exegesis][X86] Handle CMOVcc/SETcc OPERAND_COND_CODE OperandType
Roman Lebedev [Sat, 6 Apr 2019 14:16:26 +0000 (14:16 +0000)]
[llvm-exegesis][X86] Handle CMOVcc/SETcc OPERAND_COND_CODE OperandType

Summary:
D60041 / D60138 refactoring changed how CMOV/SETcc opcodes
are handled. concode is now an immediate, with it's own operand type.

This at least allows to not crash on the opcode.
However, this still won't generate all the snippets
with all the condcode enumerators. D60066 does that.

Reviewers: courbet, gchatelet

Reviewed By: gchatelet

Subscribers: tschuett, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D60057

llvm-svn: 357841

5 years ago[X86] Split expandload and compressstore tests
Simon Pilgrim [Sat, 6 Apr 2019 14:14:54 +0000 (14:14 +0000)]
[X86] Split expandload and compressstore tests

llvm-svn: 357840

5 years ago[X86][SSE] Add more exhaustive masked load/store tests
Simon Pilgrim [Sat, 6 Apr 2019 14:01:37 +0000 (14:01 +0000)]
[X86][SSE] Add more exhaustive masked load/store tests

Reordered/renamed some existing tests to match the cleaned up order

llvm-svn: 357839

5 years ago[CostModel][X86] Add more exhaustive masked load/store/gather/scatter/expand/compress...
Simon Pilgrim [Sat, 6 Apr 2019 12:08:37 +0000 (12:08 +0000)]
[CostModel][X86] Add more exhaustive masked load/store/gather/scatter/expand/compress cost tests

llvm-svn: 357838

5 years ago[clang-format] BreakAfterReturnType ignored on functions with numeric template parameters
Paul Hoad [Sat, 6 Apr 2019 10:13:04 +0000 (10:13 +0000)]
[clang-format] BreakAfterReturnType ignored on functions with numeric template parameters

Summary:
Addresses PR40696 - https://bugs.llvm.org/show_bug.cgi?id=40696

The BreakAfterReturnType didn't work if it had a single arguments which was a template with an integer template parameter

```
int  foo(A<8> a) { return a; }
```

When run with the Mozilla style. would not break after the `int`

```
int TestFn(A<8> a)
{
  return a;
}

```

This revision resolves this issue by allowing numeric constants to be considered function parameters if if seen inside `<>`

Reviewers: djasper, klimek, JonasToth, krasimir, reuk, alexfh

Reviewed By: klimek

Subscribers: cfe-commits, llvm-commits

Tags: #clang-tools-extra

Differential Revision: https://reviews.llvm.org/D59309

llvm-svn: 357837

5 years ago[AMDGPU] Sort out and rename multiple CI/VI predicates
Stanislav Mekhanoshin [Sat, 6 Apr 2019 09:20:48 +0000 (09:20 +0000)]
[AMDGPU] Sort out and rename multiple CI/VI predicates

Differential Revision: https://reviews.llvm.org/D60346

llvm-svn: 357835