platform/upstream/llvm.git
6 years ago[AArch64][GlobalISel] Fix an assert fail/miscompile when fp16 types are copied
Amara Emerson [Sun, 18 Feb 2018 17:10:49 +0000 (17:10 +0000)]
[AArch64][GlobalISel] Fix an assert fail/miscompile when fp16 types are copied
to gpr register banks.

PR36345.

rdar://36478867

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

llvm-svn: 325463

6 years ago[AArch64][GlobalISel] Support G_INSERT/G_EXTRACT of types < s32 bits.
Amara Emerson [Sun, 18 Feb 2018 17:03:02 +0000 (17:03 +0000)]
[AArch64][GlobalISel] Support G_INSERT/G_EXTRACT of types < s32 bits.

These are needed for operations on fp16 types in a later patch.

llvm-svn: 325462

6 years ago[PatternMatch] reformatting and comment clean-ups; NFC
Sanjay Patel [Sun, 18 Feb 2018 16:19:22 +0000 (16:19 +0000)]
[PatternMatch] reformatting and comment clean-ups; NFC

llvm-svn: 325461

6 years ago[Support] Replace hand-written scope_exit with make_scope_exit.
Benjamin Kramer [Sun, 18 Feb 2018 16:05:40 +0000 (16:05 +0000)]
[Support] Replace hand-written scope_exit with make_scope_exit.

No functionality change intended.

llvm-svn: 325460

6 years ago[AArch64] Coalesce Copy Zero during instruction selection
Haicheng Wu [Sun, 18 Feb 2018 13:51:33 +0000 (13:51 +0000)]
[AArch64] Coalesce Copy Zero during instruction selection

Add special case for copy of zero to avoid a double copy.

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

llvm-svn: 325459

6 years ago[clangd] Fix link failures for Preprocessor::addCommentHandler
Heejin Ahn [Sun, 18 Feb 2018 10:50:16 +0000 (10:50 +0000)]
[clangd] Fix link failures for Preprocessor::addCommentHandler

Summary:
D42640 adds calls to `Preprocessor::addCommentHandler` in
`unittests/clangd/SymbolCollectorTests.cpp` and
`clangd/global-symbol-builder/GlobalSymbolBuilderMain.cpp` but does not
link `clangLex` library. This causes undefined reference errors when
built with `-DBUILD_SHARED_LIBS=ON`.

Reviewers: ioeric

Subscribers: klimek, mgorny, ilya-biryukov, jkorous-apple, cfe-commits

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

llvm-svn: 325458

6 years ago[BPF] Return true in enableMultipleCopyHints().
Jonas Paulsson [Sun, 18 Feb 2018 10:09:54 +0000 (10:09 +0000)]
[BPF]  Return true in enableMultipleCopyHints().

Enable multiple COPY hints to eliminate more COPYs during register allocation.

Note that this is something all targets should do, see
https://reviews.llvm.org/D38128.

Review: Yonghong Song
llvm-svn: 325457

6 years ago[X86] Make masked pcmpeq commutable during isel so we can fold loads in other operand...
Craig Topper [Sun, 18 Feb 2018 02:37:33 +0000 (02:37 +0000)]
[X86] Make masked pcmpeq commutable during isel so we can fold loads in other operand to the shorter encoding.

Previously we used the immediate encoding if the load was in operand 0 and the short encoding if the load was in operand 1.

This added an insane number of bytes to the size of the isel table. I'm wondering if we should always use the immediate form during isel and change to the short form during emission. This would remove the need to pattern match every combination for both the immediate form and the short form during isel. We could do the same with vpcmpgt

llvm-svn: 325456

6 years ago[X86] Add -show-mc-encoding to the avx512-vec-cmp.ll test and add test case to show...
Craig Topper [Sun, 18 Feb 2018 02:37:32 +0000 (02:37 +0000)]
[X86] Add -show-mc-encoding to the avx512-vec-cmp.ll test and add test case to show that we're failing to use the shorter pcmpeq encoding when the memory arguemnt is the first argument.

This can't be spotted without showing the encodings since they have the same mnemonic.

llvm-svn: 325455

6 years agoRevert: [llvm] r325448 - [ThinLTO] Add GraphTraits for FunctionSummaries
Simon Pilgrim [Sun, 18 Feb 2018 00:01:36 +0000 (00:01 +0000)]
Revert: [llvm] r325448 - [ThinLTO] Add GraphTraits for FunctionSummaries

Add GraphTraits definitions to the FunctionSummary and ModuleSummaryIndex classes. These GraphTraits will be used to construct find SCC's in ThinLTO analysis passes.

Second attempt, since last patch caused stage2 build to fail (now using function_ref rather than std::function).

Reverted due to buildbot failures

llvm-svn: 325454

6 years agoSimplify.
Rui Ueyama [Sat, 17 Feb 2018 23:37:26 +0000 (23:37 +0000)]
Simplify.

llvm-svn: 325453

6 years agoAdd DEBUGSERVER_PATH to the cache so it'll be available for tests.
Don Hinton [Sat, 17 Feb 2018 23:06:15 +0000 (23:06 +0000)]
Add DEBUGSERVER_PATH to the cache so it'll be available for tests.

This fixed a problem caused by r325442.

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

llvm-svn: 325452

6 years agoFix Wparentheses warning. NFCI
Simon Pilgrim [Sat, 17 Feb 2018 22:45:56 +0000 (22:45 +0000)]
Fix Wparentheses warning. NFCI

llvm-svn: 325451

6 years ago[SelectionDAG] ComputeNumSignBits - add support for SMIN+SMAX clamp patterns
Simon Pilgrim [Sat, 17 Feb 2018 22:19:50 +0000 (22:19 +0000)]
[SelectionDAG] ComputeNumSignBits - add support for SMIN+SMAX clamp patterns

If we have a clamp pattern, SMIN(SMAX(X, LO),HI) or SMAX(SMIN(X, HI),LO) then we can deduce that the number of signbits will be at least the minimum of the LO and HI constants.

I haven't bothered with the UMIN/UMAX equivalent as (1) we don't have any current use cases and (2) I wonder if we'd be better off immediately falling back for ComputeKnownBits for UMIN/UMAX which already has optimization patterns useful for unsigned cases.

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

llvm-svn: 325450

6 years ago[SelectionDAG] SimplifyDemandedVectorElts - add support for VECTOR_INSERT_ELT
Simon Pilgrim [Sat, 17 Feb 2018 21:49:40 +0000 (21:49 +0000)]
[SelectionDAG] SimplifyDemandedVectorElts - add support for VECTOR_INSERT_ELT

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

llvm-svn: 325449

6 years ago[ThinLTO] Add GraphTraits for FunctionSummaries
Charles Saternos [Sat, 17 Feb 2018 21:39:24 +0000 (21:39 +0000)]
[ThinLTO] Add GraphTraits for FunctionSummaries

Add GraphTraits definitions to the FunctionSummary and ModuleSummaryIndex classes. These GraphTraits will be used to construct find SCC's in ThinLTO analysis passes.

Second attempt, since last patch caused stage2 build to fail (now using function_ref rather than std::function).

llvm-svn: 325448

6 years ago[MIPS][MSA] Convert vector integer min/max opcodes to use generic implementation
Simon Pilgrim [Sat, 17 Feb 2018 21:29:45 +0000 (21:29 +0000)]
[MIPS][MSA] Convert vector integer min/max opcodes to use generic implementation

Found while investigating D43338

Simon^3 - the LLVM project needs more Simons.

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

llvm-svn: 325447

6 years ago[X86] Add 'sahf' CPU feature to frontend
Dimitry Andric [Sat, 17 Feb 2018 21:04:35 +0000 (21:04 +0000)]
[X86] Add 'sahf' CPU feature to frontend

Summary:
Make clang accept `-msahf` (and `-mno-sahf`) flags to activate the
`+sahf` feature for the backend, for bug 36028 (Incorrect use of
pushf/popf enables/disables interrupts on amd64 kernels).  This was
originally submitted in bug 36037 by Jonathan Looney
<jonlooney@gmail.com>.

As described there, GCC also uses `-msahf` for this feature, and the
backend already recognizes the `+sahf` feature. All that is needed is to
teach clang to pass this on to the backend.

The mapping of feature support onto CPUs may not be complete; rather, it
was chosen to match LLVM's idea of which CPUs support this feature (see
lib/Target/X86/X86.td).

I also updated the affected test case (CodeGen/attr-target-x86.c) to
match the emitted output.

Reviewers: craig.topper, coby, efriedma, rsmith

Reviewed By: craig.topper

Subscribers: emaste, cfe-commits

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

llvm-svn: 325446

6 years agoRemove an unused accessor and simplify the logic a bit. NFC.
Rui Ueyama [Sat, 17 Feb 2018 20:41:38 +0000 (20:41 +0000)]
Remove an unused accessor and simplify the logic a bit. NFC.

llvm-svn: 325445

6 years agoFactor out common code from applySecRel functions.
Rui Ueyama [Sat, 17 Feb 2018 20:28:15 +0000 (20:28 +0000)]
Factor out common code from applySecRel functions.

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

llvm-svn: 325444

6 years ago[ARM] Add LLVM tests for the vcvtr builtins
Sjoerd Meijer [Sat, 17 Feb 2018 19:59:29 +0000 (19:59 +0000)]
[ARM] Add LLVM tests for the vcvtr builtins

Follow up of Clang commit r325351; this adds the LLVM tests, which
were also missing.

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

llvm-svn: 325443

6 years ago[cmake] Fix LLDB_CODESIGN_IDENTITY logic.
Don Hinton [Sat, 17 Feb 2018 19:17:21 +0000 (19:17 +0000)]
[cmake] Fix LLDB_CODESIGN_IDENTITY logic.

Summary:
Consolidate LLDB_CODESIGN_IDENTITY logic in one place and use
SKIP_DEBUGSERVER, which can be set independently, to control
codesigning targets.

Currently, running cmake the first time in a clean directory, without
passing -DLLDB_CODESIGN_IDENTITY='', fails.  However, subsequent runs
succeed.  That's because LLDB_CODESIGN_IDENTITY gets added to the
CACHE after the initial test.  To fix that, the default value must be
set before it's tested.

Here's the error produced on the first run:

CMake Error at tools/lldb/tools/debugserver/source/CMakeLists.txt:215 (add_custom_command):
  No TARGET 'debugserver' has been created in this directory.

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

llvm-svn: 325442

6 years ago[RISCV] Revert r324172 now r323991 was reverted
Alex Bradbury [Sat, 17 Feb 2018 18:17:47 +0000 (18:17 +0000)]
[RISCV] Revert r324172 now r323991 was reverted

This fixes the build, now that r325421 was commited to revert r323991.

llvm-svn: 325441

6 years agoMade test dbg_value_fastisel.ll specific to AArch64 fast-isel.
Sander de Smalen [Sat, 17 Feb 2018 17:43:24 +0000 (17:43 +0000)]
Made test dbg_value_fastisel.ll specific to AArch64 fast-isel.

Some buildbots failed on this test (rL325438) because they don't
build all targets. I set the triple to aarch64 and moved the test
to test/CodeGen/AArch64/fast-isel-dbg-value.ll.

llvm-svn: 325440

6 years ago[X86] Add 'sahf' to getHostCPUFeatures so -march=native will pick it up correctly.
Craig Topper [Sat, 17 Feb 2018 16:52:49 +0000 (16:52 +0000)]
[X86] Add 'sahf' to getHostCPUFeatures so -march=native will pick it up correctly.

Summary: We probably mostly get this right due to family/model/stepping mapping to CPU names. But we should detect it explicitly.

Reviewers: RKSimon, echristo, dim, spatel

Reviewed By: dim

Subscribers: llvm-commits

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

llvm-svn: 325439

6 years ago[DebugInfo][FastISel] Fix dropping dbg.value()
Sander de Smalen [Sat, 17 Feb 2018 16:42:54 +0000 (16:42 +0000)]
[DebugInfo][FastISel] Fix dropping dbg.value()

Summary:
https://llvm.org/PR36263 shows that when compiling at -O0 a dbg.value()
instruction (that remains from an original dbg.declare()) is dropped
by FastISel. Since FastISel selects instructions by iterating a basic
block backwards, it drops the dbg.value if one of its operands is not
yet instantiated by a previously selected instruction.

Instead of calling 'lookUpRegForValue()' we can call 'getRegForValue()'
instead that will insert a placeholder for the operand to be filled in
when continuing the instruction selection.

Reviewers: aprantl, dblaikie, probinson

Reviewed By: aprantl

Subscribers: llvm-commits, dstenb, JDevlieghere

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

llvm-svn: 325438

6 years ago[PatternMatch] enhance m_One() to ignore undef elements in vectors
Sanjay Patel [Sat, 17 Feb 2018 16:00:42 +0000 (16:00 +0000)]
[PatternMatch] enhance m_One() to ignore undef elements in vectors

llvm-svn: 325437

6 years ago[InstSimplify, InstCombine] add tests with vector undef elts; NFC
Sanjay Patel [Sat, 17 Feb 2018 15:55:40 +0000 (15:55 +0000)]
[InstSimplify, InstCombine] add tests with vector undef elts; NFC

These would fold if the m_One pattern matcher accounted for undef elts.

llvm-svn: 325436

6 years ago[X86][3DNow!] Add PFRCP reg-reg disassembler test case (PR21168)
Simon Pilgrim [Sat, 17 Feb 2018 14:58:16 +0000 (14:58 +0000)]
[X86][3DNow!] Add PFRCP reg-reg disassembler test case (PR21168)

llvm-svn: 325435

6 years ago[InstSimplify] move select undef cond fold with other constant cond folds; NFCI
Sanjay Patel [Sat, 17 Feb 2018 14:50:13 +0000 (14:50 +0000)]
[InstSimplify] move select undef cond fold with other constant cond folds; NFCI

llvm-svn: 325434

6 years ago[AArch64] Implement dynamic stack probing for windows
Martin Storsjo [Sat, 17 Feb 2018 14:26:32 +0000 (14:26 +0000)]
[AArch64] Implement dynamic stack probing for windows

This makes sure that alloca() function calls properly probe the
stack as needed.

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

llvm-svn: 325433

6 years agoFix unused variable warning. NFCI.
Simon Pilgrim [Sat, 17 Feb 2018 13:48:23 +0000 (13:48 +0000)]
Fix unused variable warning. NFCI.

We were casting to AArch64InstrInfo but only using it for static methods which some compilers complain about.

llvm-svn: 325432

6 years agoRecognize all NetBSD architectures in UBSan
Kamil Rytarowski [Sat, 17 Feb 2018 13:35:09 +0000 (13:35 +0000)]
Recognize all NetBSD architectures in UBSan

Summary:
Use uniform accessors for Program Pointer,
Stack Pointer and Frame Pointer.

Remove CPU check in UBSan supported platforms
and rely only on the OS type.

This adds NetBSD support in GetPcSpBp() for:
 - ARM
 - ARM64
 - HPPA
 - PowerPC/PowerPC64
 - SPARC/SPARC64
 - MIPS
 - DEC Alpha AXP
 - DEC VAX
 - M68K and M68010
 - SH3
 - IA64
 - OR1K
 - RISCV

Sponsored by <The NetBSD Foundation>

Reviewers: joerg, vitalybuka, ro

Reviewed By: vitalybuka

Subscribers: aemerson, jyknight, sdardis, kubamracek, arichardson, llvm-commits, kristof.beyls, fedor.sergeev, #sanitizers

Tags: #sanitizers

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

llvm-svn: 325431

6 years ago[dwarfdump] Fix spurious verification errors for DW_AT_location attributes
Jonas Devlieghere [Sat, 17 Feb 2018 13:06:37 +0000 (13:06 +0000)]
[dwarfdump] Fix spurious verification errors for DW_AT_location attributes

Verifying any DWARF file that is optimized and contains at least one tag
with a DW_AT_location with a location list offset as a
DW_AT_form_dataXXX results in dwarfdump spuriously claiming that the
location list is invalid.

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

llvm-svn: 325430

6 years ago[DAGCombiner] Remove simplifyShuffleMask - now handled more generally by SimplifyDema...
Simon Pilgrim [Sat, 17 Feb 2018 12:36:56 +0000 (12:36 +0000)]
[DAGCombiner] Remove simplifyShuffleMask - now handled more generally by SimplifyDemandedVectorElts.

llvm-svn: 325429

6 years agoFix signed/unsigned comparison warning in AsmGenMatcher generated code. NFCI.
Simon Pilgrim [Sat, 17 Feb 2018 12:29:47 +0000 (12:29 +0000)]
Fix signed/unsigned comparison warning in AsmGenMatcher generated code. NFCI.

llvm-svn: 325428

6 years ago[DebugInfo] Removed assert on missing CountVarDIE
Sander de Smalen [Sat, 17 Feb 2018 11:06:53 +0000 (11:06 +0000)]
[DebugInfo] Removed assert on missing CountVarDIE

Summary:
The assert for a DISubrange's CountVarDIE to be available fails
when the dbg.value() has been optimized away for any reason.
Having the assert for that is a little heavy, so instead removing
it now in favor of not generating the 'count' expression.

Addresses http://llvm.org/PR36263 .

Reviewers: aprantl, dblaikie, probinson

Reviewed By: aprantl

Subscribers: JDevlieghere, llvm-commits, dstenb

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

llvm-svn: 325427

6 years agoReport fatal error in the case of out of memory
Serge Pavlov [Sat, 17 Feb 2018 10:21:33 +0000 (10:21 +0000)]
Report fatal error in the case of out of memory

This is partial recommit of r325224, reverted in 325227. The relevant
part of original comment is below.

Analysis of fails in the case of out of memory errors can be tricky on
Windows. Such error emerges at the point where memory allocation function
fails, but manifests itself when null pointer is used. These two points
may be distant from each other. Besides, next runs may not exhibit
allocation error.

Usual programming practice does not require checking result of 'operator
new' because it throws 'std::bad_alloc' in the case of allocation error.
However, LLVM is usually built with exceptions turned off, so 'new' can
return null pointer. This change installs custom new handler, which causes
fatal error in the case of out of memory. The handler is installed
automatically prior to call to 'main' during construction of a static
object defined in 'lib/Support/ErrorHandling.cpp'. If the application does
not use this file, the handler may be installed manually by a call to
'llvm::install_out_of_memory_new_handler', declared in
'include/llvm/Support/ErrorHandling.h".

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

llvm-svn: 325426

6 years ago[AMDGPU] Return true in enableMultipleCopyHints().
Jonas Paulsson [Sat, 17 Feb 2018 10:00:28 +0000 (10:00 +0000)]
[AMDGPU]  Return true in enableMultipleCopyHints().

Enable multiple COPY hints to eliminate more COPYs during register allocation.

Note that this is something all targets should do, see
https://reviews.llvm.org/D38128.

Review: Stanislav Mekhanoshin, Tom Stellard.
llvm-svn: 325425

6 years ago[OMPT] Omissionin in OMPT Formatting
Joachim Protze [Sat, 17 Feb 2018 09:54:10 +0000 (09:54 +0000)]
[OMPT] Omissionin in OMPT Formatting

Applying clang-format to the /runtime/src/ folder

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

llvm-svn: 325424

6 years ago[OMPT] Add interoperability testcase
Joachim Protze [Sat, 17 Feb 2018 09:40:08 +0000 (09:40 +0000)]
[OMPT] Add interoperability testcase

Test whether OMPT-callbacks for two threads that initiate a parallel region are correct.

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

llvm-svn: 325423

6 years ago[OMPT] Update api_calls testcase
Joachim Protze [Sat, 17 Feb 2018 09:40:02 +0000 (09:40 +0000)]
[OMPT] Update api_calls testcase

Only use ompt_ functions when testing OMPT in api_calls testcase.
Add size parameter to print_list.
Fix small bug in implementation of ompt_get_partition_place_nums(): return correct length.

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

llvm-svn: 325422

6 years agoRevert "[MachineCopyPropagation] Extend pass to do COPY source forwarding"
Quentin Colombet [Sat, 17 Feb 2018 03:05:33 +0000 (03:05 +0000)]
Revert "[MachineCopyPropagation] Extend pass to do COPY source forwarding"

This reverts commit r323991.

This commit breaks target that don't model all the register constraints
in TableGen. So far the workaround was to set the
hasExtraXXXRegAllocReq, but it proves that it doesn't cover all the
cases.
For instance, when mutating an instruction (like in the lowering of
COPYs) the isRenamable flag is not properly updated. The same problem
will happen when attaching machine operand from one instruction to
another.

Geoff Berry is working on a fix in https://reviews.llvm.org/D43042.

llvm-svn: 325421

6 years ago[DAG, X86] Revert r324797, r324491, and r324359.
Chandler Carruth [Sat, 17 Feb 2018 02:26:25 +0000 (02:26 +0000)]
[DAG, X86] Revert r324797, r324491, and r324359.

Sadly, r324359 caused at least PR36312. There is a patch out for review
but it seems to be taking a bit and we've already had these crashers in
tree for too long. We're hitting this PR in real code now and are
blocked on shipping new compilers as a consequence so I'm reverting us
back to green.

Sorry for the churn due to the stacked changes that I had to revert. =/

llvm-svn: 325420

6 years ago[InstSimplify] add vector select tests with undef elts in condition; NFC
Sanjay Patel [Sat, 17 Feb 2018 01:18:53 +0000 (01:18 +0000)]
[InstSimplify] add vector select tests with undef elts in condition; NFC

llvm-svn: 325419

6 years ago[WebAssembly] Remove unneeded classifer methods from Symbol class. NFC.
Sam Clegg [Sat, 17 Feb 2018 00:44:21 +0000 (00:44 +0000)]
[WebAssembly] Remove unneeded classifer methods from Symbol class. NFC.

We already have isa<> for this, and these methods were simply
duplicating those redundantly.

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

llvm-svn: 325418

6 years ago[X86] Turn selects with constant condition into vector shuffles during DAG combine
Craig Topper [Sat, 17 Feb 2018 00:30:30 +0000 (00:30 +0000)]
[X86] Turn selects with constant condition into vector shuffles during DAG combine

Summary:
Currently we convert to shuffles during lowering. This moves it to DAG combine so hopefully we can get it done before type legalization has to extend the condition.

I believe in some cases we're creating SHRUNKBLENDs that end up with constant conditions because we see the extended on the condition and think its a dynamic selelect before DAG combine gets a chance to constant fold the extend. We could add combines to turn SHRUNKBLENDs with constant condition back to vselect. But it seemed like it might be better to just send them to shuffles as early as possible so they never get a chance to become SHRUNKBLENDs. This the reason some tests went from blends controlled by a constant pool load to just move.

Some of the constant pool entries changed because the sign_extend introduced by type legalization turned undef elements in select condition into 0s. While the select->shuffle used -1 in the shuffle mask. So now the shuffle lowering can do what it wants with them.

I'll remove the lowering code as a follow up. We might be able to simplify some of the pre-checks for SHRUNKBLEND as the FIXME there says.

Reviewers: spatel, RKSimon, efriedma, zvi, andreadb

Reviewed By: spatel

Subscribers: llvm-commits

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

llvm-svn: 325417

6 years agoUse toString to print out garbage-collected sections.
Rui Ueyama [Sat, 17 Feb 2018 00:09:49 +0000 (00:09 +0000)]
Use toString to print out garbage-collected sections.

Currently, archive file name is missing in this message. In general,
we should avoid constructing strings in an ad-hoc manner and instead
use toString() to get consistent output strings.

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

llvm-svn: 325416

6 years ago[WebAssembly] Simplify FunctionSymbol::get/set/hasFunctionType. NFC.
Sam Clegg [Fri, 16 Feb 2018 23:50:23 +0000 (23:50 +0000)]
[WebAssembly] Simplify FunctionSymbol::get/set/hasFunctionType. NFC.

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

llvm-svn: 325415

6 years ago[WebAssembly] Remove unneeded Chunk::getFileName() method. NFC.
Sam Clegg [Fri, 16 Feb 2018 23:46:51 +0000 (23:46 +0000)]
[WebAssembly] Remove unneeded Chunk::getFileName() method. NFC.

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

llvm-svn: 325414

6 years agoRemove "--full-shutdown" and instead use an environment variable LLD_IN_TEST.
Rui Ueyama [Fri, 16 Feb 2018 23:41:48 +0000 (23:41 +0000)]
Remove "--full-shutdown" and instead use an environment variable LLD_IN_TEST.

We are running lld tests with "--full-shutdown" option because we don't
want to call _exit() in lld if it is running tests. Regular shutdown
is needed for leak sanitizer.

This patch changes the way how we tell lld that it is running tests.
Now "--full-shutdown" is removed, and LLD_IN_TEST environment variable
is used instead.

This patch enables full shutdown on all ports, e.g. ELF, COFF and wasm.
Previously, we enabled it only for ELF.

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

llvm-svn: 325413

6 years ago[Basic] Fix some Clang-tidy modernize and Include What You Use warnings; other minor...
Eugene Zelenko [Fri, 16 Feb 2018 23:40:07 +0000 (23:40 +0000)]
[Basic] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).

llvm-svn: 325412

6 years ago[ThinLTO] Allow indexing to request backend to ignore the module
Vitaly Buka [Fri, 16 Feb 2018 23:38:22 +0000 (23:38 +0000)]
[ThinLTO] Allow indexing to request backend to ignore the module

Summary:
Gold plugin does not add pass to ThinLTO modules without useful symbols.
In this case ThinLTO can't create corresponding index file and some features, like CFI,
cannot be processes by backed correctly without index.
Given that we don't need the backed output we can request it to avoid
processing the module. This is implemented by this patch using new
"SkipModuleByDistributedBackend" flag.

Reviewers: pcc, tejohnson

Subscribers: mehdi_amini, inglorion, eraman, cfe-commits

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

llvm-svn: 325411

6 years ago[ThinLTO] Ignore object files with no ThinLTO modules if -fthinlto-index= is set
Vitaly Buka [Fri, 16 Feb 2018 23:34:16 +0000 (23:34 +0000)]
[ThinLTO] Ignore object files with no ThinLTO modules if -fthinlto-index= is set

Summary:
ThinLTO compilation may decide not to split module and keep at as regular LTO.
In this can this module already processed during indexing and already a part of
merged object file. So here we can just skip it.

Reviewers: pcc, tejohnson

Reviewed By: tejohnson

Subscribers: mehdi_amini, inglorion, eraman, cfe-commits

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

llvm-svn: 325410

6 years ago[clangd] Rename some protocol field to lower case
Marc-Andre Laperle [Fri, 16 Feb 2018 23:12:26 +0000 (23:12 +0000)]
[clangd] Rename some protocol field to lower case

Summary:
Also fixes a GCC compilation error.

Signed-off-by: Marc-Andre Laperle <marc-andre.laperle@ericsson.com>
Subscribers: klimek, ilya-biryukov, jkorous-apple, ioeric, cfe-commits

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

llvm-svn: 325409

6 years agoAMDGPU: Remove unused private member of AMDGPUTargetELFStreamer
Konstantin Zhuravlyov [Fri, 16 Feb 2018 23:04:11 +0000 (23:04 +0000)]
AMDGPU: Remove unused private member of AMDGPUTargetELFStreamer

llvm-svn: 325408

6 years agoRun these tests, the errors were old and not valid anymore.
Eric Christopher [Fri, 16 Feb 2018 23:02:28 +0000 (23:02 +0000)]
Run these tests, the errors were old and not valid anymore.

llvm-svn: 325407

6 years agoDo not print out "no input files" twice.
Rui Ueyama [Fri, 16 Feb 2018 22:58:19 +0000 (22:58 +0000)]
Do not print out "no input files" twice.

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

llvm-svn: 325406

6 years agoUse wasm-ld instead of "lld -flavor wasm".
Rui Ueyama [Fri, 16 Feb 2018 22:58:02 +0000 (22:58 +0000)]
Use wasm-ld instead of "lld -flavor wasm".

Invoking lld as ld.lld, ld.ld64, lld-link or wasm-ld is preferred
than invoking lld as lld and pass an -flavor option. We have "lld"
file mostly for historical reasons.

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

llvm-svn: 325405

6 years agoAMDGPU/LLD: Remove the use of binary file from one of the AMDGPU tests
Konstantin Zhuravlyov [Fri, 16 Feb 2018 22:55:36 +0000 (22:55 +0000)]
AMDGPU/LLD: Remove the use of binary file from one of the AMDGPU tests

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

llvm-svn: 325404

6 years agoRemove an unused function.
Eric Christopher [Fri, 16 Feb 2018 22:46:47 +0000 (22:46 +0000)]
Remove an unused function.

llvm-svn: 325403

6 years agoSilence an unsigned vs signed compare warning.
Eric Christopher [Fri, 16 Feb 2018 22:46:45 +0000 (22:46 +0000)]
Silence an unsigned vs signed compare warning.

llvm-svn: 325402

6 years ago[GISel]: Make GlobalISelEmitter rule prioritization compatible with selectionDAG
Aditya Nandakumar [Fri, 16 Feb 2018 22:37:15 +0000 (22:37 +0000)]
[GISel]: Make GlobalISelEmitter rule prioritization compatible with selectionDAG

This patch changes GlobalISelEmitter to rank patterns similar to how the
DAG does it (ie it computes a score for a pattern and adds the added
complexity to it).
This is so that the decision tree for GISelSelector remains compatible
with that of SelectionDAG.

https://reviews.llvm.org/D43270

llvm-svn: 325401

6 years agoAMDGPU: Update elf flags in amdgpu-elf-flags.s
Konstantin Zhuravlyov [Fri, 16 Feb 2018 22:35:36 +0000 (22:35 +0000)]
AMDGPU: Update elf flags in amdgpu-elf-flags.s

This is required after r325399:
  - EF_AMDGPU_ARCH_GCN got removed
  - In the test, EF_AMDGPU_ARCH_GCN is replaced with EF_AMDGPU_MACH_AMDGCN_GFX803

llvm-svn: 325400

6 years agoAMDGPU: Bring elf flags in sync with the spec
Konstantin Zhuravlyov [Fri, 16 Feb 2018 22:33:59 +0000 (22:33 +0000)]
AMDGPU: Bring elf flags in sync with the spec

- Add MACH flags
- Add XNACK flag
- Add reserved flags
- Minor cleanups in docs

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

llvm-svn: 325399

6 years ago[Constant] add floating-point helpers for normal/finite-nz; NFC
Sanjay Patel [Fri, 16 Feb 2018 22:32:54 +0000 (22:32 +0000)]
[Constant] add floating-point helpers for normal/finite-nz; NFC

...and delete the equivalent local functiona from InstCombine.

These might be useful to other InstCombine files or other passes
and makes FP queries more similar to integer constant queries.

llvm-svn: 325398

6 years agoMake sure we invoke ld64.lld and ld-wasm in the build directory.
Rui Ueyama [Fri, 16 Feb 2018 22:19:38 +0000 (22:19 +0000)]
Make sure we invoke ld64.lld and ld-wasm in the build directory.

llvm-svn: 325397

6 years ago[COFF] Add support for ARM64 secrel relocations for add/load instructions
Martin Storsjo [Fri, 16 Feb 2018 22:02:38 +0000 (22:02 +0000)]
[COFF] Add support for ARM64 secrel relocations for add/load instructions

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

llvm-svn: 325396

6 years ago[clangd] Implement textDocument/hover
Marc-Andre Laperle [Fri, 16 Feb 2018 21:38:15 +0000 (21:38 +0000)]
[clangd] Implement textDocument/hover

Summary: Implemention of textDocument/hover as described in LSP definition.

This patch adds a basic Hover implementation.  When hovering a variable,
function, method or namespace, clangd will return a text containing the
declaration's scope, as well as the declaration of the hovered entity.
For example, for a variable:

  Declared in class Foo::Bar

  int hello = 2

For macros, the macro definition is returned.

This patch doesn't include:

- markdown support (the client I use doesn't support it yet)
- range support (optional in the Hover response)
- comments associated to variables/functions/classes

They are kept as future work to keep this patch simpler.

I added tests in XRefsTests.cpp.  hover.test contains one simple
smoketest to make sure the feature works from a black box perspective.

Reviewers: malaperle, krasimir, bkramer, ilya-biryukov

Subscribers: sammccall, mgrang, klimek, rwols, ilya-biryukov, arphaman, cfe-commits

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

Signed-off-by: Simon Marchi <simon.marchi@ericsson.com>
Signed-off-by: William Enright <william.enright@polymtl.ca>
llvm-svn: 325395

6 years ago[X86] In lowerVSELECTtoVectorShuffle, don't map undef select condition to undef in...
Craig Topper [Fri, 16 Feb 2018 21:36:29 +0000 (21:36 +0000)]
[X86] In lowerVSELECTtoVectorShuffle, don't map undef select condition to undef in shuffle mask.

Undef in select condition means we should pick the element from one side or the other. An undef in a shuffle mask means pick any element from either source or worse.

I suspect by the time we get here most of the undefs in a constant vector have been removed by other things, but doing this for safety.

llvm-svn: 325394

6 years agoAMDGPU: Bring processors and features in sync with the spec
Konstantin Zhuravlyov [Fri, 16 Feb 2018 21:26:25 +0000 (21:26 +0000)]
AMDGPU: Bring processors and features in sync with the spec

- Remove gfx800
- Make iceland gfx802
- Add xnack to gfx902

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

llvm-svn: 325393

6 years agoRevert an accidental change to where "-flavor GNU" was used by intention.
Rui Ueyama [Fri, 16 Feb 2018 21:24:01 +0000 (21:24 +0000)]
Revert an accidental change to where "-flavor GNU" was used by intention.

llvm-svn: 325392

6 years ago[OPENMP] Do not emit messages for templates in declare target
Alexey Bataev [Fri, 16 Feb 2018 21:23:23 +0000 (21:23 +0000)]
[OPENMP] Do not emit messages for templates in declare target
constructs.

The compiler may emit some extra warnings for functions, that are
implicit specialization of the templates, declared in the target region.

llvm-svn: 325391

6 years agoReplace -flavor {gnu,darwin} with ld64.lld or ld.lld.
Rui Ueyama [Fri, 16 Feb 2018 21:16:57 +0000 (21:16 +0000)]
Replace -flavor {gnu,darwin} with ld64.lld or ld.lld.

llvm-svn: 325390

6 years agoTry again to fix the build.
Zachary Turner [Fri, 16 Feb 2018 21:10:34 +0000 (21:10 +0000)]
Try again to fix the build.

This doesn't repro with clang or MSVC so I'm just blindly
guessing.

llvm-svn: 325389

6 years agoTry to fix broken build with some compilers.
Zachary Turner [Fri, 16 Feb 2018 20:58:25 +0000 (20:58 +0000)]
Try to fix broken build with some compilers.

llvm-svn: 325388

6 years agoRemove `else` after `break`.
Rui Ueyama [Fri, 16 Feb 2018 20:53:53 +0000 (20:53 +0000)]
Remove `else` after `break`.

llvm-svn: 325387

6 years agoFix emission of PDB string table.
Zachary Turner [Fri, 16 Feb 2018 20:46:04 +0000 (20:46 +0000)]
Fix emission of PDB string table.

This was originally reported as a bug with the symptom being "cvdump
crashes when printing an LLD-linked PDB that has an S_FILESTATIC record
in it". After some additional investigation, I determined that this was
a symptom of a larger problem, and in fact the real problem was in the
way we emitted the global PDB string table. As evidence of this, you can
take any lld-generated PDB, run cvdump -stringtable on it, and it would
return no results.

My hypothesis was that cvdump could not *find* the string table to begin
with. Normally it would do this by looking in the "named stream map",
finding the string /names, and using its value as the stream index. If
this lookup fails, then cvdump would fail to load the string table.

To test this hypothesis, I looked at the name stream map generated by a
link.exe PDB, and I emitted exactly those bytes into an LLD-generated
PDB. Suddenly, cvdump could read our string table!

This code has always been hacky and we knew there was something we
didn't understand. After all, there were some comments to the effect of
"we have to emit strings in a specific order, otherwise things don't
work". The key to fixing this was finally understanding this.

The way it works is that it makes use of a generic serializable hash map
that maps integers to other integers. In this case, the "key" is the
offset into a buffer, and the value is the stream number. If you index
into the buffer at the offset specified by a given key, you find the
name. The underlying cause of all these problems is that we were using
the identity function for the hash. i.e. if a string's offset in the
buffer was 12, the hash value was 12. Instead, we need to hash the
string *at that offset*. There is an additional catch, in that we have
to compute the hash as a uint32 and then truncate it to uint16.

Making this work is a little bit annoying, because we use the same hash
table in other places as well, and normally just using the identity
function for the hash function is actually what's desired. I'm not
totally happy with the template goo I came up with, but it works in any
case.

The reason we never found this bug through our own testing is because we
were building a /parallel/ hash table (in the form of an
llvm::StringMap<>) and doing all of our lookups and "real" hash table
work against that. I deleted all of that code and now everything goes
through the real hash table. Then, to test it, I added a unit test which
adds 7 strings and queries the associated values. I test every possible
insertion order permutation of these 7 strings, to verify that it really
does work as expected.

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

llvm-svn: 325386

6 years agoRemove useless comment - seems to be a copy+paste typo. NFCI
Simon Pilgrim [Fri, 16 Feb 2018 20:41:06 +0000 (20:41 +0000)]
Remove useless comment - seems to be a copy+paste typo. NFCI

llvm-svn: 325385

6 years agoUse write32le instead of write32<little>.
Rui Ueyama [Fri, 16 Feb 2018 20:38:15 +0000 (20:38 +0000)]
Use write32le instead of write32<little>.

llvm-svn: 325384

6 years agoRefactor wasm/WriterUtil.{cpp,h}.
Rui Ueyama [Fri, 16 Feb 2018 20:38:00 +0000 (20:38 +0000)]
Refactor wasm/WriterUtil.{cpp,h}.

Summary:
 - Makes code more in line with LLVM style (e.g. const char * -> StringRef)
 - Do not use formatv since we can construct message just by `+`
 - Replace some odd types such as `const StringRef` with more common type
 - Do not use default arguments if they are not necessary

Reviewers: sbc100

Subscribers: jfb, aheejin, llvm-commits, sunfish

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

llvm-svn: 325383

6 years ago[WebAssebmly] Remove unneeded cast. NFC.
Sam Clegg [Fri, 16 Feb 2018 20:26:15 +0000 (20:26 +0000)]
[WebAssebmly] Remove unneeded cast. NFC.

llvm-svn: 325382

6 years ago[clang-include-fixer] Use add_clang_tool instead add_clang_executable
Petr Hosek [Fri, 16 Feb 2018 20:25:45 +0000 (20:25 +0000)]
[clang-include-fixer] Use add_clang_tool instead add_clang_executable

This makes it possible to include clang-include-fixer as distribution
component when building Clang based toolchain using CMake.

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

llvm-svn: 325381

6 years agoELF: Stop collecting a list of symbols in ArchiveFile.
Peter Collingbourne [Fri, 16 Feb 2018 20:23:54 +0000 (20:23 +0000)]
ELF: Stop collecting a list of symbols in ArchiveFile.

There seems to be no reason to collect this list of symbols.

Also fix a bug where --exclude-libs would apply to all symbols that
appear in an archive's symbol table, even if the relevant archive
member was not added to the link.

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

llvm-svn: 325380

6 years agoDon't depend on "call foo" producing a X86_64_PC32.
Rafael Espindola [Fri, 16 Feb 2018 20:05:58 +0000 (20:05 +0000)]
Don't depend on "call foo" producing a X86_64_PC32.

Newer versions of the gnu assembler produce a X86_64_PLT32 for
calls. There is a change under review in llvm to do the same, so update
the tests to not depend on it.

We can still produce a R_X86_64_PC32 with ".long foo - .".

llvm-svn: 325379

6 years ago[AArch64] Fix BITCAST lowering crash
Evandro Menezes [Fri, 16 Feb 2018 20:00:57 +0000 (20:00 +0000)]
[AArch64] Fix BITCAST lowering crash

The data type is assumed to be a vector, but sometimes it is not, leading
to an assertion.

Add simple test-case to verify this.

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

llvm-svn: 325378

6 years agoStyle fix. NFC.
Rui Ueyama [Fri, 16 Feb 2018 19:53:29 +0000 (19:53 +0000)]
Style fix. NFC.

llvm-svn: 325377

6 years ago[WebAssembly] Fix bug is function signature checking
Sam Clegg [Fri, 16 Feb 2018 19:45:41 +0000 (19:45 +0000)]
[WebAssembly] Fix bug is function signature checking

This bug effected undefined symbols that were resolved by
existing defined symbols.  We were skipping the signature
check in this case.

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

llvm-svn: 325376

6 years ago[MS] Make constexpr static data members implicitly inline
Reid Kleckner [Fri, 16 Feb 2018 19:44:47 +0000 (19:44 +0000)]
[MS] Make constexpr static data members implicitly inline

This handles them exactly the same way that we handle const integral
static data members with inline definitions, which is what MSVC does.

As a follow-up, now that we have a way to mark variables inline in the
AST, we should consider marking them implicitly inline there instead of
only treating them as inline in CodeGen. Unfortunately, this breaks a
lot of dllimport test cases, so that is future work for now.

Fixes PR36125.

llvm-svn: 325375

6 years ago[Documentation] Fix Sphinx error. Limit text width to 80 characters.
Eugene Zelenko [Fri, 16 Feb 2018 19:31:28 +0000 (19:31 +0000)]
[Documentation] Fix Sphinx error. Limit text width to 80 characters.

llvm-svn: 325374

6 years ago[OPENMP] Fix PR35873: Fix data-sharing attributes for const variables.
Alexey Bataev [Fri, 16 Feb 2018 19:16:54 +0000 (19:16 +0000)]
[OPENMP] Fix PR35873: Fix data-sharing attributes for const variables.

Compiler erroneously returned wrong data-sharing attributes for the
constant variables if they have explictly specified attributes.

llvm-svn: 325373

6 years agoAMDGPU/SI: Extend promoting alloca to vector to arrays of up to 16 elements
Changpeng Fang [Fri, 16 Feb 2018 19:14:17 +0000 (19:14 +0000)]
AMDGPU/SI: Extend promoting alloca to vector to arrays of up to 16 elements

Summary:
  This patch extends the promotion of alloca to vector to the arrays of up to 16 elements. Also we introduce
an option, -disable-promote-alloca-to-vector, to switch promotion to vector off, if needed.

Reviewers:
  arsenm

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

llvm-svn: 325372

6 years ago[X86] Only reorder srl/and on last DAG combiner run
Craig Topper [Fri, 16 Feb 2018 18:51:09 +0000 (18:51 +0000)]
[X86] Only reorder srl/and on last DAG combiner run

This seems to interfere with a target independent brcond combine that looks for the (srl (and X, C1), C2) pattern to enable TEST instructions. Once we flip, that combine doesn't fire and we end up exposing it to the X86 specific BT combine which causes us to emit a BT instruction. BT has lower throughput than TEST.

We could try to make the brcond combine aware of the alternate pattern, but since the flip was just a code size reduction and not likely to enable other combines, it seemed easier to just delay it until after lowering.

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

llvm-svn: 325371

6 years ago[WebAssembly] Fix typos in comment. NFC.
Sam Clegg [Fri, 16 Feb 2018 18:37:32 +0000 (18:37 +0000)]
[WebAssembly] Fix typos in comment. NFC.

Patch by Nicholas Wilson!

llvm-svn: 325370

6 years ago[OPENMP] Fix parsing of the directives with inner directives.
Alexey Bataev [Fri, 16 Feb 2018 18:36:44 +0000 (18:36 +0000)]
[OPENMP] Fix parsing of the directives with inner directives.

The parsing may lead to compiler hanging because of the incorrect
processing of inner OpenMP pragmas.

llvm-svn: 325369

6 years ago[X86] Remove call to ShrinkDemandedCosntant from the SHRUNKBLEND creation code.
Craig Topper [Fri, 16 Feb 2018 18:34:46 +0000 (18:34 +0000)]
[X86] Remove call to ShrinkDemandedCosntant from the SHRUNKBLEND creation code.

We only run this code if know the condition isn't a constant vector. ShrinkDemandedConstant isn't going to find any different.

llvm-svn: 325368

6 years ago[WebAssembly] MC: Make explicit our current lack of support for relocations against...
Sam Clegg [Fri, 16 Feb 2018 18:06:05 +0000 (18:06 +0000)]
[WebAssembly] MC: Make explicit our current lack of support for relocations against unnamed temporary symbols.

Add an explicit check before looking up symbol in SymbolIndices.
This was previously silently succeeding and returning zero for such
unnamed temporaries.

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

llvm-svn: 325367

6 years ago[InstCombine] clean up fdiv-with-fdiv folds; NFCI
Sanjay Patel [Fri, 16 Feb 2018 17:52:32 +0000 (17:52 +0000)]
[InstCombine] clean up fdiv-with-fdiv folds; NFCI

llvm-svn: 325366

6 years ago[InstCombine] add FMF to better show current fdiv fold behavior; NFC
Sanjay Patel [Fri, 16 Feb 2018 17:46:50 +0000 (17:46 +0000)]
[InstCombine] add FMF to better show current fdiv fold behavior; NFC

llvm-svn: 325365

6 years agoClean up 'target' attribute diagnostics
Erich Keane [Fri, 16 Feb 2018 17:31:59 +0000 (17:31 +0000)]
Clean up 'target' attribute diagnostics

There were a few issues previously with the target
attribute diagnostics implementation that lead to the
attribute being added to the AST despite having an error
in it.

This patch changes that, and adds a test to ensure it
does not get added to the AST.

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

llvm-svn: 325364