platform/upstream/llvm.git
6 years ago[DAGCombiner] isAllOnesConstantOrAllOnesSplatConstant(): look through bitcasts
Roman Lebedev [Mon, 21 May 2018 21:41:10 +0000 (21:41 +0000)]
[DAGCombiner] isAllOnesConstantOrAllOnesSplatConstant(): look through bitcasts

Summary:
As pointed out in D46528, we errneously transform cases like `xor X, -1`,
even though we use said function.
It's because the `-1` is actually a bitcast there.
So i think we can just look through it in the function.

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

llvm-svn: 332905

6 years ago[DAGCombine][X86][AArch64] Masked merge unfolding: vector edition.
Roman Lebedev [Mon, 21 May 2018 21:41:02 +0000 (21:41 +0000)]
[DAGCombine][X86][AArch64] Masked merge unfolding: vector edition.

Summary:
This **appears** to be the last missing piece for the masked merge pattern handling in the backend.

This is [[ https://bugs.llvm.org/show_bug.cgi?id=37104 | PR37104 ]].

[[ https://bugs.llvm.org/show_bug.cgi?id=6773 | PR6773 ]] will introduce an IR canonicalization that is likely bad for the end assembly.
Previously, `andps`+`andnps` / `bsl` would be generated. (see `@out`)
Now, they would no longer be generated  (see `@in`), and we need to make sure that they are generated.

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

llvm-svn: 332904

6 years ago[X86][AArch64][NFC] Add tests for vector masked merge unfolding
Roman Lebedev [Mon, 21 May 2018 21:40:51 +0000 (21:40 +0000)]
[X86][AArch64][NFC] Add tests for vector masked merge unfolding

Summary:
This is [[ https://bugs.llvm.org/show_bug.cgi?id=37104 | PR37104 ]].

[[ https://bugs.llvm.org/show_bug.cgi?id=6773 | PR6773 ]] will introduce an IR canonicalization that is likely bad for the end assembly.
Previously, `andps`+`andnps` / `bsl` would be generated. (see `@out`)
Now, they would no longer be generated  (see `@in`).

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

llvm-svn: 332903

6 years agoImplement deduction guides for vector
Marshall Clow [Mon, 21 May 2018 21:30:12 +0000 (21:30 +0000)]
Implement deduction guides for vector

llvm-svn: 332901

6 years ago[ORC] Preserve Materializing symbol flag during resolution.
Lang Hames [Mon, 21 May 2018 21:11:22 +0000 (21:11 +0000)]
[ORC] Preserve Materializing symbol flag during resolution.

llvm-svn: 332899

6 years ago[ORC] Lookup now returns an error if any symbols are not found.
Lang Hames [Mon, 21 May 2018 21:11:21 +0000 (21:11 +0000)]
[ORC] Lookup now returns an error if any symbols are not found.

Also tightens the behavior of ExecutionSession::failQuery. Queries can usually
only be failed by marking a symbol as failed-to-materialize, but
ExecutionSession::failQuery provides a second route, and both routes may be
executed from different threads. In the case that a query has already been
failed due to a materialization error, ExecutionSession::failQuery will
direct the error to ExecutionSession::reportError instead.

llvm-svn: 332898

6 years ago[ORC] Remove the optional MaterializationResponsibility argument from lookup.
Lang Hames [Mon, 21 May 2018 21:11:21 +0000 (21:11 +0000)]
[ORC] Remove the optional MaterializationResponsibility argument from lookup.

The lookup function provides blocking symbol resolution for JIT clients (not
layers themselves) so it does not need to track symbol dependencies via a
MaterializationResponsibility.

llvm-svn: 332897

6 years ago[ORC] Add IRLayer and ObjectLayer interfaces and related MaterializationUnits.
Lang Hames [Mon, 21 May 2018 21:11:13 +0000 (21:11 +0000)]
[ORC] Add IRLayer and ObjectLayer interfaces and related MaterializationUnits.

llvm-svn: 332896

6 years ago[DAGCombiner] Use computeKnownBits to match rotate patterns that have had their amoun...
Craig Topper [Mon, 21 May 2018 21:09:18 +0000 (21:09 +0000)]
[DAGCombiner] Use computeKnownBits to match rotate patterns that have had their amount masking modified by simplifyDemandedBits

SimplifyDemandedBits can remove bits from the masks for the shift amounts we need to see to detect rotates.

This patch uses zeroes from computeKnownBits to fill in some of these mask bits to make the match work.

As currently written this calls computeKnownBits even when the mask hasn't been simplified because it made the code simpler. If we're worried about compile time performance we can improve this.

I know we're talking about making a rotate intrinsic, but hopefully we can go ahead and do this change and just make sure the rotate intrinsic also handles it.

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

llvm-svn: 332895

6 years ago[InstCombine] regenerate checks; NFC
Sanjay Patel [Mon, 21 May 2018 21:09:14 +0000 (21:09 +0000)]
[InstCombine] regenerate checks; NFC

llvm-svn: 332894

6 years ago[X86] Simplify some X86 address mode folding code, NFCI
Reid Kleckner [Mon, 21 May 2018 21:03:19 +0000 (21:03 +0000)]
[X86] Simplify some X86 address mode folding code, NFCI

This code should really do exactly the same thing for 32-bit x86 and
64-bit small code models, with the exception that RIP-relative
addressing can't use base and index registers.

llvm-svn: 332893

6 years ago[X86] Remove some unneeded check lines that I copy and pasted when I made vector...
Craig Topper [Mon, 21 May 2018 21:01:13 +0000 (21:01 +0000)]
[X86] Remove some unneeded check lines that I copy and pasted when I made vector tests from some scalar test cases.

llvm-svn: 332892

6 years ago[X86] Remove masking from pternlog llvm intrinsics and use a select instruction instead.
Craig Topper [Mon, 21 May 2018 20:58:23 +0000 (20:58 +0000)]
[X86] Remove masking from pternlog llvm intrinsics and use a select instruction instead.

Because the intrinsics in the headers are implemented as macros, we can't just use a select builtin and pternlog builtin. This would require one of the macro arguments to be used twice. Depending on what was passed to the macro we could expand an expression twice leading to weird behavior. We could maybe declare our local variable in the macro, but that would need to worry about name collisions.

To avoid that just generate IR directly in CGBuiltin.cpp.

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

llvm-svn: 332891

6 years ago[X86] Remove masking from vpternlog intrinsics. Use a select in IR instead.
Craig Topper [Mon, 21 May 2018 20:58:09 +0000 (20:58 +0000)]
[X86] Remove masking from vpternlog intrinsics. Use a select in IR instead.

This removes 6 intrinsics since we no longer need separate mask and maskz intrinsics.

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

llvm-svn: 332890

6 years agoFix a make_unique ambiguity.
Peter Collingbourne [Mon, 21 May 2018 20:56:28 +0000 (20:56 +0000)]
Fix a make_unique ambiguity.

llvm-svn: 332889

6 years ago[asan] Make GetCurrentThread RTEMS-friendly
Walter Lee [Mon, 21 May 2018 20:43:36 +0000 (20:43 +0000)]
[asan] Make GetCurrentThread RTEMS-friendly

On RTEMS, system and user code all live in a single binary and address
space. There is no clean separation, and instrumented code may
execute before the ASan run-time is initialized (or after it has been
destroyed).

Currently, GetCurrentThread() may crash if it's called before ASan
run-time is initialized. Make it return nullptr instead.

Similarly, fix __asan_handle_no_return so that it gives up rather than
try something that may crash.

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

llvm-svn: 332888

6 years ago[InstCombine] remove fptrunc (select) code; NFCI
Sanjay Patel [Mon, 21 May 2018 20:39:35 +0000 (20:39 +0000)]
[InstCombine] remove fptrunc (select) code; NFCI

This pattern is handled within commonCastTransforms(),
so the code here is dead AFAICT.

llvm-svn: 332887

6 years agoRevert r332847; it caused us to miscompile certain forms of reference initialization.
Richard Smith [Mon, 21 May 2018 20:36:58 +0000 (20:36 +0000)]
Revert r332847; it caused us to miscompile certain forms of reference initialization.

llvm-svn: 332886

6 years agoCodeGen, Driver: Start using direct split dwarf emission in clang.
Peter Collingbourne [Mon, 21 May 2018 20:31:59 +0000 (20:31 +0000)]
CodeGen, Driver: Start using direct split dwarf emission in clang.

Fixes PR37466.

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

llvm-svn: 332885

6 years agoLTO: Replace split dwarf implementation that uses objcopy with one that uses direct...
Peter Collingbourne [Mon, 21 May 2018 20:26:49 +0000 (20:26 +0000)]
LTO: Replace split dwarf implementation that uses objcopy with one that uses direct emission.

Part of PR37466.

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

llvm-svn: 332884

6 years ago[InstCombine] add tests for cast-of-select; NFC
Sanjay Patel [Mon, 21 May 2018 20:23:58 +0000 (20:23 +0000)]
[InstCombine] add tests for cast-of-select; NFC

In all cases, we're pulling the cast above the select.
That's not a good canonicalization if we're creating
a select that then mismatches the operand size of its
condition.

llvm-svn: 332883

6 years ago[X86] Use __builtin_convertvector to implement some of the packed integer to packed...
Craig Topper [Mon, 21 May 2018 20:19:17 +0000 (20:19 +0000)]
[X86] Use __builtin_convertvector to implement some of the packed integer to packed float conversion intrinsics.

I believe this is safe assuming default default FP environment. The conversion might be inexact, but it can never overflow the FP type so this shouldn't be undefined behavior for the uitofp/sitofp instructions.

We already do something similar for scalar conversions.

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

llvm-svn: 332882

6 years agoCodeGen: Add a dwo output file argument to addPassesToEmitFile and hook it up to...
Peter Collingbourne [Mon, 21 May 2018 20:16:41 +0000 (20:16 +0000)]
CodeGen: Add a dwo output file argument to addPassesToEmitFile and hook it up to dwo output.

Part of PR37466.

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

llvm-svn: 332881

6 years agoRemove CMake workaround for LLD PR24476 which is no longer needed
Reid Kleckner [Mon, 21 May 2018 20:14:46 +0000 (20:14 +0000)]
Remove CMake workaround for LLD PR24476 which is no longer needed

llvm-svn: 332880

6 years agoRevert r332028; see PR37545 for details.
Richard Smith [Mon, 21 May 2018 20:10:54 +0000 (20:10 +0000)]
Revert r332028; see PR37545 for details.

llvm-svn: 332879

6 years ago[DebugInfo] Fix typo "DWARG" in test comment (NFC)
Brian Gesiak [Mon, 21 May 2018 19:48:27 +0000 (19:48 +0000)]
[DebugInfo] Fix typo "DWARG" in test comment (NFC)

Summary:
The correct spelling is "DWARF", the debugging format, not "DWARG".
The typo is in a (not executed by lit) comment in a test file, so
fixing it does not result in any functional change.

Test Plan: check-llvm, just in case

llvm-svn: 332878

6 years agoEnable Python API for OpenBSD.
Zachary Turner [Mon, 21 May 2018 19:47:45 +0000 (19:47 +0000)]
Enable Python API for OpenBSD.

Patch by David Carlier

llvm-svn: 332877

6 years ago[libFuzzer] reinstate -dump_coverage, which is still in use (reverts r332036)
Kostya Serebryany [Mon, 21 May 2018 19:47:00 +0000 (19:47 +0000)]
[libFuzzer] reinstate -dump_coverage, which is still in use (reverts r332036)

llvm-svn: 332876

6 years agoMC: Introduce an ELF dwo object writer and teach llvm-mc about it.
Peter Collingbourne [Mon, 21 May 2018 19:44:54 +0000 (19:44 +0000)]
MC: Introduce an ELF dwo object writer and teach llvm-mc about it.

Part of PR37466.

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

llvm-svn: 332875

6 years agoAMDGPU: Update GCCBuiltin names for DS FP atomic intrinsics
Matt Arsenault [Mon, 21 May 2018 19:43:02 +0000 (19:43 +0000)]
AMDGPU: Update GCCBuiltin names for DS FP atomic intrinsics

llvm-svn: 332874

6 years ago[DebugInfo] Use absolute addresses in location lists
Jonas Devlieghere [Mon, 21 May 2018 19:36:54 +0000 (19:36 +0000)]
[DebugInfo] Use absolute addresses in location lists

Rather than relying on the user to do the address calculating in
DW_AT_location we should just dump the absolute address.

rdar://problem/38513870

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

llvm-svn: 332873

6 years ago[X86] Add test cases for D47012.
Craig Topper [Mon, 21 May 2018 19:33:42 +0000 (19:33 +0000)]
[X86] Add test cases for D47012.

Patch by Thomasz Krupa.

llvm-svn: 332872

6 years agoRevert "[CMake] Reland "Make simple source used for CMake checks a C file""
Petr Hosek [Mon, 21 May 2018 19:32:43 +0000 (19:32 +0000)]
Revert "[CMake] Reland "Make simple source used for CMake checks a C file""

This reverts commit rCRT332679 which doesn't quite work and will be
replaced by D47100 and D47115 which is a cleaner solution.

llvm-svn: 332871

6 years agoMC: Extract a derived class from ELFObjectWriter. NFCI.
Peter Collingbourne [Mon, 21 May 2018 19:30:59 +0000 (19:30 +0000)]
MC: Extract a derived class from ELFObjectWriter. NFCI.

This class will be used to create regular, non-split ELF files.

Part of PR37466.

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

llvm-svn: 332870

6 years ago[X86] Add test cases for missed vector rotate matching due to SimplifyDemandedBits...
Craig Topper [Mon, 21 May 2018 19:27:50 +0000 (19:27 +0000)]
[X86] Add test cases for missed vector rotate matching due to SimplifyDemandedBits interfering with the AND masks

As requested in D47116

llvm-svn: 332869

6 years agoMC: Separate creating a generic object writer from creating a target object writer...
Peter Collingbourne [Mon, 21 May 2018 19:20:29 +0000 (19:20 +0000)]
MC: Separate creating a generic object writer from creating a target object writer. NFCI.

With this we gain a little flexibility in how the generic object
writer is created.

Part of PR37466.

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

llvm-svn: 332868

6 years agoMC: Extract ELFObjectWriter's ELF writing functionality into an ELFWriter class....
Peter Collingbourne [Mon, 21 May 2018 19:18:28 +0000 (19:18 +0000)]
MC: Extract ELFObjectWriter's ELF writing functionality into an ELFWriter class. NFCI.

The idea is that we will be able to use this class to create multiple
files.

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

llvm-svn: 332867

6 years agoFix ubsan bounds check failure.
Peter Collingbourne [Mon, 21 May 2018 19:09:47 +0000 (19:09 +0000)]
Fix ubsan bounds check failure.

llvm-svn: 332866

6 years ago[EarlyCSE] Improve EarlyCSE of some absolute value cases.
Craig Topper [Mon, 21 May 2018 18:42:42 +0000 (18:42 +0000)]
[EarlyCSE] Improve EarlyCSE of some absolute value cases.

Change matchSelectPattern to return X and -X for ABS/NABS in a well defined order. Adjust EarlyCSE to account for this. Ensure the SPF result is some kind of min/max and not abs/nabs in one place in InstCombine that made me nervous.

Prevously we returned the two operands of the compare part of the abs pattern. The RHS is always going to be a 0i, 1 or -1 constant. This isn't a very meaningful thing to return for any one. There's also some freedom in the abs pattern as to what happens when the value is equal to 0. This freedom led to early cse failing to match when different constants were used in otherwise equivalent operations. By returning the input and its negation in a defined order we can ensure an exact match. This also makes sure both patterns use the exact same subtract instruction for the negation. I believe CSE should evebntually make this happen and properly merge the nsw/nuw flags. But I'm not familiar with CSE and what order it does things in so it seemed like it might be good to really enforce that they were the same.

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

llvm-svn: 332865

6 years agoMC: Remove stream and output functions from MCObjectWriter. NFCI.
Peter Collingbourne [Mon, 21 May 2018 18:28:57 +0000 (18:28 +0000)]
MC: Remove stream and output functions from MCObjectWriter. NFCI.

Part of PR37466.

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

llvm-svn: 332864

6 years agoMC: Have the object writers return the number of bytes written. NFCI.
Peter Collingbourne [Mon, 21 May 2018 18:23:50 +0000 (18:23 +0000)]
MC: Have the object writers return the number of bytes written. NFCI.

This removes the last external use of the stream.

Part of PR37466.

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

llvm-svn: 332863

6 years ago[AMDGPU] Add divergence analysis as a dependency for ISel
Stanislav Mekhanoshin [Mon, 21 May 2018 18:18:52 +0000 (18:18 +0000)]
[AMDGPU] Add divergence analysis as a dependency for ISel

AMDGPUDAGToDAGISel adds DivergenceAnalysis in getAnalysisUsage
but does not list it in pass dependencies which may lead to
crash.

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

llvm-svn: 332862

6 years agoMC: Change object writers to use endian::Writer. NFCI.
Peter Collingbourne [Mon, 21 May 2018 18:17:42 +0000 (18:17 +0000)]
MC: Change object writers to use endian::Writer. NFCI.

Part of PR37466.

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

llvm-svn: 332861

6 years ago[VPlan] Reland r332654 and silence unused func warning
Diego Caballero [Mon, 21 May 2018 18:14:23 +0000 (18:14 +0000)]
[VPlan] Reland r332654 and silence unused func warning

r332654 was reverted due to an unused function warning in
release build. This commit includes the same code with the
warning silenced.

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

llvm-svn: 332860

6 years agoFix typo.
Rui Ueyama [Mon, 21 May 2018 18:12:46 +0000 (18:12 +0000)]
Fix typo.

llvm-svn: 332859

6 years agoMC: Change MCAssembler::writeSectionData and writeFragmentPadding to take a raw_ostre...
Peter Collingbourne [Mon, 21 May 2018 18:11:35 +0000 (18:11 +0000)]
MC: Change MCAssembler::writeSectionData and writeFragmentPadding to take a raw_ostream. NFCI.

Also clean up a couple of hacks where we were writing the section
contents to another stream by setting the object writer's stream,
writing and setting it back.

Part of PR37466.

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

llvm-svn: 332858

6 years agoMC: Change MCAsmBackend::writeNopData() to take a raw_ostream instead of an MCObjectW...
Peter Collingbourne [Mon, 21 May 2018 17:57:19 +0000 (17:57 +0000)]
MC: Change MCAsmBackend::writeNopData() to take a raw_ostream instead of an MCObjectWriter. NFCI.

To make this work I needed to add an endianness field to MCAsmBackend
so that writeNopData() implementations know which endianness to use.

Part of PR37466.

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

llvm-svn: 332857

6 years agoAMDGPU/GlobalISel: Address post-commit review comments for r332379
Tom Stellard [Mon, 21 May 2018 17:49:31 +0000 (17:49 +0000)]
AMDGPU/GlobalISel: Address post-commit review comments for r332379

MCRegisterInfo::getPhysRegSize() will be deprecated.

llvm-svn: 332856

6 years ago[InstCombine] Fix PR37526: MinMax patterns produce an infinite loop.
Alexey Bataev [Mon, 21 May 2018 17:46:34 +0000 (17:46 +0000)]
[InstCombine] Fix PR37526: MinMax patterns produce an infinite loop.

Summary:
This patch fixes PR37526 by simplifying the newly generated LoadInst
instructions. If the pointer address is a bitcast from the pointer to
the NewType, we can just remove this extra bitcast instead of creating
the new one. This fixes the PR37526 + may speed up the whole compilation
process.

Reviewers: spatel, RKSimon, hfinkel

Subscribers: llvm-commits

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

llvm-svn: 332855

6 years ago[Clang Tablegen] Add llvm_unreachable() to getModifierName()
Mark Searles [Mon, 21 May 2018 17:29:08 +0000 (17:29 +0000)]
[Clang Tablegen] Add llvm_unreachable() to getModifierName()

Fix internal build failure:

../../../ClangDiagnosticsEmitter.cpp -o ClangDiagnosticsEmitter.o
../../../ClangDiagnosticsEmitter.cpp: In function 'llvm::StringRef
{anonymous}::getModifierName({anonymous}::ModifierType)':
../../../ClangDiagnosticsEmitter.cpp:495:1: error: control reaches end of non-void function [-Werror=return-type]
}
^

Build failure triggered by git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@332799 91177308-0d34-0410-b5e6-96231b3b80d8

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

llvm-svn: 332854

6 years ago[llvm-mca] Removed an empty line generated by the timeline view. NFC.
Andrea Di Biagio [Mon, 21 May 2018 17:11:56 +0000 (17:11 +0000)]
[llvm-mca] Removed an empty line generated by the timeline view. NFC.

Also, regenerate all tests.

llvm-svn: 332853

6 years ago[OPENMP-SIMD] Fix PR37536: Fix definition of _OPENMP macro.
Alexey Bataev [Mon, 21 May 2018 16:40:32 +0000 (16:40 +0000)]
[OPENMP-SIMD] Fix PR37536: Fix definition of _OPENMP macro.

if `-fopenmp-simd` is specified alone, `_OPENMP` macro should not be
  defined. If `-fopenmp-simd` is specified along with the `-fopenmp`,
  `_OPENMP` macro should be defined with the value `201511`.

llvm-svn: 332852

6 years ago[X86][BtVer2] Add a 'J' prefix to the PRF/RCU defs. NFC
Andrea Di Biagio [Mon, 21 May 2018 16:30:26 +0000 (16:30 +0000)]
[X86][BtVer2] Add a 'J' prefix to the PRF/RCU defs. NFC

This is to keep the Jaguar model's naming convention. Processor resources all
have a 'J' prefix in the BtVer2 scheduling model.

llvm-svn: 332851

6 years ago[LLVM-C] Add DIBuilder Bindings For ObjC Classes
Robert Widmann [Mon, 21 May 2018 16:27:35 +0000 (16:27 +0000)]
[LLVM-C] Add DIBuilder Bindings For ObjC Classes

Summary: Add LLVMDIBuilderCreateObjCIVar, LLVMDIBuilderCreateObjCProperty, and LLVMDIBuilderCreateInheritance to allow declaring metadata for Objective-C class hierarchies and their associated properties and instance variables.

Reviewers: whitequark, deadalnix

Reviewed By: whitequark

Subscribers: harlanhaskins, llvm-commits

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

llvm-svn: 332850

6 years ago[X86] - Avoid SFB pass - fix bug in updating the offsets for newly created copies
Lama Saba [Mon, 21 May 2018 16:23:16 +0000 (16:23 +0000)]
[X86] - Avoid SFB pass - fix bug in updating the offsets for newly created copies

Change-Id: I169ab6fe7e187727c0298c2a1e2868a683f3e688
llvm-svn: 332849

6 years ago[AMDGPU] fixes for lds f32 builtins
Daniil Fukalov [Mon, 21 May 2018 16:18:07 +0000 (16:18 +0000)]
[AMDGPU] fixes for lds f32 builtins

1. added restrictions to memory scope, order and volatile parameters
2. added custom processing for these builtins - currently is not used code,
   needed to switch off GCCBuiltin link to the builtins (ongoing change to llvm
   tree)
3. builtins renamed as requested

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

llvm-svn: 332848

6 years ago[CodeGen] Recognize more cases of zero initialization
Serge Pavlov [Mon, 21 May 2018 16:09:54 +0000 (16:09 +0000)]
[CodeGen] Recognize more cases of zero initialization

If a variable has an initializer, codegen tries to build its value. If
the variable is large in size, building its value requires substantial
resources. It causes strange behavior from user viewpoint: compilation
of huge zero initialized arrays like:

    char data_1[2147483648u] = { 0 };

consumes enormous amount of time and memory.

With this change codegen tries to determine if variable initializer is
equivalent to zero initializer. In this case variable value is not
constructed.

This change fixes PR18978.

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

llvm-svn: 332847

6 years ago[ELF] Update due to API change in .debug_line parsing
James Henderson [Mon, 21 May 2018 15:31:23 +0000 (15:31 +0000)]
[ELF] Update due to API change in .debug_line parsing

See r332845.

Reviewed by: grimar

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

llvm-svn: 332846

6 years ago[DWARF] Refactor callback usage for .debug_line error handling
James Henderson [Mon, 21 May 2018 15:30:54 +0000 (15:30 +0000)]
[DWARF] Refactor callback usage for .debug_line error handling

Change the "recoverable" error callback to take an Error instaed of a
string.

Reviewed by: JDevlieghere

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

llvm-svn: 332845

6 years ago[X86][SSE] Add an assert to ensure that rotation amount is converted to a scale
Simon Pilgrim [Mon, 21 May 2018 15:17:23 +0000 (15:17 +0000)]
[X86][SSE] Add an assert to ensure that rotation amount is converted to a scale

Missed in rL332832 where we added SSE v4i32 rotations for PR37426.

llvm-svn: 332844

6 years ago[Sema] Fix incorrect packed aligned structure layout
Momchil Velikov [Mon, 21 May 2018 14:28:43 +0000 (14:28 +0000)]
[Sema] Fix incorrect packed aligned structure layout

Handle attributes before checking the record layout (e.g. underalignment check
during `alignas` processing), as layout may be cached without taking into
account attributes that may affect it.

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

llvm-svn: 332843

6 years agoFix PathMappingList for relative and empty paths after recent FileSpec normalization...
Greg Clayton [Mon, 21 May 2018 14:14:36 +0000 (14:14 +0000)]
Fix PathMappingList for relative and empty paths after recent FileSpec normalization changes

PathMappingList was broken for relative and empty paths after normalization changes in FileSpec. There were also no tests for PathMappingList so I added those.

Changes include:

Change PathMappingList::ReverseRemapPath() to take FileSpec objects instead of ConstString. The only client of this was doing work to convert to and from ConstString objects for no reason.
Normalize all paths prefix and replacements that are added to the PathMappingList vector so they match the paths that have been already normalized in the debug info
Unify code in the two forms of PathMappingList::RemapPath() so only one contains the actual functionality. Prior to this, there were two versions of this code.
Use FileSpec::AppendPathComponent() and remove a long standing TODO so paths are correctly appended to each other.
Added tests for absolute, relative and empty paths.

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

llvm-svn: 332842

6 years agoReland "[DWARF] Extract indexing code into a separate class hierarchy"
Pavel Labath [Mon, 21 May 2018 14:12:52 +0000 (14:12 +0000)]
Reland "[DWARF] Extract indexing code into a separate class hierarchy"

After this commit, the xcode project will need to be updated to include
the new files added here.

llvm-svn: 332841

6 years agoARM: be conservative when asked load/store alignment of weird type.
Tim Northover [Mon, 21 May 2018 12:43:54 +0000 (12:43 +0000)]
ARM: be conservative when asked load/store alignment of weird type.

Chances are we'll be asked again after type legalization, but before that point
it's better to claim misaligned accesses aren't allowed than to assert.

llvm-svn: 332840

6 years ago[CodeGen] Disable aggressive structor optimizations at -O0, take 2
Pavel Labath [Mon, 21 May 2018 11:47:45 +0000 (11:47 +0000)]
[CodeGen] Disable aggressive structor optimizations at -O0, take 2

The first version of the patch (r332228) was flawed because it was
putting structors into C5/D5 comdats very eagerly. This is correct only
if we can ensure the comdat contains all required versions of the
structor (which wasn't the case). This version uses a more nuanced
approach:
- for local structor symbols we use an alias because we don't have to
  worry about comdats or other compilation units.
- linkonce symbols are emitted separately, as we cannot guarantee we
  will have all symbols we need to form a comdat (they are emitted
  lazily, only when referenced).
- available_externally symbols are also emitted separately, as the code
  seemed to be worried about emitting an alias in this case.
- other linkage types are not affected by the optimization level. They
  either get put into a comdat (weak) or get aliased (external).

Reviewers: rjmccall, aprantl

Subscribers: cfe-commits

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

llvm-svn: 332839

6 years agorevert r332610, it breaks cfi, see D46326
Nico Weber [Mon, 21 May 2018 11:44:39 +0000 (11:44 +0000)]
revert r332610, it breaks cfi, see D46326

llvm-svn: 332838

6 years ago[mips] Revert Merge MipsLongBranch and MipsHazardSchedule passes
Aleksandar Beserminji [Mon, 21 May 2018 11:38:52 +0000 (11:38 +0000)]
[mips] Revert Merge MipsLongBranch and MipsHazardSchedule passes

Revert this patch due buildbot failure.

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

llvm-svn: 332837

6 years ago[CVP] Require DomTree for new Pass Manager
David Green [Mon, 21 May 2018 11:06:28 +0000 (11:06 +0000)]
[CVP] Require DomTree for new Pass Manager

We were previously using a DT in CVP through SimplifyQuery, but not requiring it in
the new pass manager. Hence it would crash if DT was not already available. This now
gets DT directly and plumbs it through to where it is used (instead of using it
through SQ).

llvm-svn: 332836

6 years agoFix up a few grammar issues.
Eric Christopher [Mon, 21 May 2018 10:27:36 +0000 (10:27 +0000)]
Fix up a few grammar issues.

llvm-svn: 332835

6 years ago[mips] Merge MipsLongBranch and MipsHazardSchedule passes
Aleksandar Beserminji [Mon, 21 May 2018 10:20:02 +0000 (10:20 +0000)]
[mips] Merge MipsLongBranch and MipsHazardSchedule passes

MipsLongBranchPass and MipsHazardSchedule passes are joined to one pass
because of mutual conflict. When MipsHazardSchedule inserts 'nop's, it
potentially breaks some jumps, so they have to be expanded to long
branches. When some branch is expanded to long branch, it potentially
creates a hazard situation, which should be fixed by adding nops.
New pass is called MipsBranchExpansion, it combines these two passes,
and runs them alternately until one of them reports no changes were made.

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

llvm-svn: 332834

6 years agoImprove coverage of the apple-tables test
Pavel Labath [Mon, 21 May 2018 10:09:22 +0000 (10:09 +0000)]
Improve coverage of the apple-tables test

After closer examination, it turns out we mis-classify one of the
methods only if two of the structs have the same name. Since this was
meant to be a basic test, I rename one of the structs in the test so
that we have at least some coverage for the apple tables lookup.
Instead, I create an XFAILed test which specifically targets the
same-name case (and file a bug to track it).

llvm-svn: 332833

6 years ago[X86][SSE] Support v4i32 rotations (PR37426)
Simon Pilgrim [Mon, 21 May 2018 09:45:59 +0000 (09:45 +0000)]
[X86][SSE] Support v4i32 rotations (PR37426)

As suggested by Fabian on PR37426, we can use PMULUDQ to perform v4i32 vector rotations as the upper 32bits of the multiply will contain the 'wrapped' bits of the rotation.

v8i16/v16i8 rotations would be straightforward to add to lowerRotate in the future - ideally we'd mostly share code with the vector shifts lowering.

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

llvm-svn: 332832

6 years agoAdd some apple-tables lookup tests
Pavel Labath [Mon, 21 May 2018 09:27:16 +0000 (09:27 +0000)]
Add some apple-tables lookup tests

Summary:
Now that we are able to parse MachO files everywhere, we can write some
cross-platform tests for handling of apple accelerator tables. This
reruns the same lookup tests we have for manual indexes on MachO files
which will use the accelerator tables instead. This makes sure we return
the same results regardless of the method we used to access the debug
info.

The tests confirm we return the same results for looking up types,
namespaces and variables, but have found an inconsistency in the
treatment of function lookup. In the function case we mis-classify the
method "foo" declared in the local struct sbar (inside function ffbar).
We classify it as a function whereas it really is a method. Preliminary
analysis suggests this is because
DWARFASTParserClang::GetClangDeclContextForDIE returns null when given
the local "struct sbar" DIE. This causes us to get the wrong
CompilerDeclContext when we ask for the context of the inner foo, which
means CompilerDeclContext::ISStructUnionOrClass returns false.

Until this is fixed, I do not include the darwin versions of the "base"
and "method" function lookup tests.

Reviewers: JDevlieghere, clayborg

Subscribers: aprantl, ilya-biryukov, ioeric, lldb-commits

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

llvm-svn: 332831

6 years ago[X86] Remove some preprocessor feature checks from intrinsic headers
Craig Topper [Mon, 21 May 2018 06:07:49 +0000 (06:07 +0000)]
[X86] Remove some preprocessor feature checks from intrinsic headers

Summary:
These look to be a couple things that weren't removed when we switched to target attribute.

The popcnt makes including just smmintrin.h also include popcntintrin.h. The popcnt file itself already contains target attrributes.

The prefetch ones are just wrappers around __builtin_prefetch which we have graceful fallbacks for in the backend if the exact instruction isn't available. So there's no reason to hide them. And it makes them available in functions that have the write target attribute but not a -march command line flag.

Reviewers: echristo, RKSimon, spatel, DavidKreitzer

Reviewed By: echristo

Subscribers: cfe-commits

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

llvm-svn: 332830

6 years ago[X86] Remove some unused builtins.
Craig Topper [Mon, 21 May 2018 03:36:57 +0000 (03:36 +0000)]
[X86] Remove some unused builtins.

These were upgraded to native shufflevectors months ago.

llvm-svn: 332829

6 years agowin: try more to fix dia tests with newer msvc versions
Nico Weber [Mon, 21 May 2018 02:55:41 +0000 (02:55 +0000)]
win: try more to fix dia tests with newer msvc versions

llvm-svn: 332828

6 years agowin: try to fix dia tests with newer msvc versions
Nico Weber [Mon, 21 May 2018 02:09:57 +0000 (02:09 +0000)]
win: try to fix dia tests with newer msvc versions

llvm-svn: 332827

6 years ago[LLVM-C] Improve Bindings For Aliases
Robert Widmann [Sun, 20 May 2018 23:49:08 +0000 (23:49 +0000)]
[LLVM-C] Improve Bindings For Aliases

Summary: Add wrappers for a module's alias iterators and a getter and setter for the aliasee value.

Reviewers: whitequark, deadalnix

Reviewed By: whitequark

Subscribers: llvm-commits, harlanhaskins

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

llvm-svn: 332826

6 years ago[X86] Remove mask arguments from permvar builtins/intrinsics. Use a select in IR...
Craig Topper [Sun, 20 May 2018 23:34:10 +0000 (23:34 +0000)]
[X86] Remove mask arguments from permvar builtins/intrinsics. Use a select in IR instead.

Someday maybe we'll use selects for all the builtins.

llvm-svn: 332825

6 years ago[X86] Remove mask arguments from permvar builtins/intrinsics. Use a select in IR...
Craig Topper [Sun, 20 May 2018 23:34:04 +0000 (23:34 +0000)]
[X86] Remove mask arguments from permvar builtins/intrinsics. Use a select in IR instead.

Someday maybe we'll use selects for all intrinsics.

llvm-svn: 332824

6 years agoRevert 332750, llvm part (see comment on D46910).
Nico Weber [Sun, 20 May 2018 23:03:17 +0000 (23:03 +0000)]
Revert 332750, llvm part (see comment on D46910).

llvm-svn: 332823

6 years agoRevert 332750, clang part (see comment on D46910).
Nico Weber [Sun, 20 May 2018 23:02:20 +0000 (23:02 +0000)]
Revert 332750, clang part (see comment on D46910).

llvm-svn: 332822

6 years agoSema: diagnose invalid catch parameter in ObjC
Saleem Abdulrasool [Sun, 20 May 2018 19:26:44 +0000 (19:26 +0000)]
Sema: diagnose invalid catch parameter in ObjC

Ensure that the type being used has an associated interface when
declaring the parameter for `@catch`.

Resolves PR37384!

llvm-svn: 332821

6 years ago[mips] Add microMIPSR6 ll/sc instructions.
Simon Dardis [Sun, 20 May 2018 17:21:00 +0000 (17:21 +0000)]
[mips] Add microMIPSR6 ll/sc instructions.

Previously the compiler was using the microMIPSR3 variants, incorrectly.

Reviewers: atanasyan, abeserminji, smaksimovic

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

llvm-svn: 332820

6 years ago[InstCombine] choose 1 form of abs and nabs as canonical
Sanjay Patel [Sun, 20 May 2018 14:23:23 +0000 (14:23 +0000)]
[InstCombine] choose 1 form of abs and nabs as canonical

We already do this for min/max (see the blob above the diff),
so we should do the same for abs/nabs.
A sign-bit check (<s 0) is used as a predicate for other IR
transforms and it's likely the best for codegen.

This might solve the motivating cases for D47037 and D47041,
but I think those patches still make sense. We can't guarantee
this canonicalization if the icmp has more than one use.

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

llvm-svn: 332819

6 years agoDeduction guides for list
Marshall Clow [Sun, 20 May 2018 14:05:31 +0000 (14:05 +0000)]
Deduction guides for list

llvm-svn: 332818

6 years agoPrint the qualified name when dumping deserialized decls.
Vassil Vassilev [Sun, 20 May 2018 09:38:52 +0000 (09:38 +0000)]
Print the qualified name when dumping deserialized decls.

This is useful to understand and debug the lazy template specializations
used in the pch and modules.

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

llvm-svn: 332817

6 years ago[cmake] Add a switch to enable/disable bindings.
Vassil Vassilev [Sun, 20 May 2018 08:37:54 +0000 (08:37 +0000)]
[cmake] Add a switch to enable/disable bindings.

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

llvm-svn: 332816

6 years ago[X86] Add test cases to show missed rotate opportunities due to SimplifyDemandedBits.
Craig Topper [Sun, 20 May 2018 02:32:45 +0000 (02:32 +0000)]
[X86] Add test cases to show missed rotate opportunities due to SimplifyDemandedBits.

llvm-svn: 332815

6 years ago[polly] Drop nonexistant LLVM_PLUGIN_EXPORT macro from llvmGetPassPluginInfo()
Roman Lebedev [Sat, 19 May 2018 19:16:35 +0000 (19:16 +0000)]
[polly] Drop nonexistant LLVM_PLUGIN_EXPORT macro from llvmGetPassPluginInfo()

Fixes build:
/build/polly/lib/Support/RegisterPasses.cpp:709:80: error: expected ';' after top level declarator
extern "C" ::llvm::PassPluginLibraryInfo LLVM_ATTRIBUTE_WEAK LLVM_PLUGIN_EXPORT
                                                                               ^
                                                                              ;

Was missed in rL332796 / D47082

llvm-svn: 332814

6 years ago[GlobalMerge] Exit early if only one global is to be merged
Haicheng Wu [Sat, 19 May 2018 18:00:02 +0000 (18:00 +0000)]
[GlobalMerge] Exit early if only one global is to be merged

To save some compilation time and prevent some unnecessary changes.

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

llvm-svn: 332813

6 years agoRe-revert "[Option] Fix PR37006 prefix choice in findNearest"
Brian Gesiak [Sat, 19 May 2018 16:21:01 +0000 (16:21 +0000)]
Re-revert "[Option] Fix PR37006 prefix choice in findNearest"

Summary:
Reverting due to a test failure in an llvm-mt test on some buildbots, namely
http://green.lab.llvm.org/green/job/clang-stage2-configure-Rlto/26020/.

llvm-svn: 332812

6 years agoImplement deduction guides for forward_list
Marshall Clow [Sat, 19 May 2018 16:02:05 +0000 (16:02 +0000)]
Implement deduction guides for forward_list

llvm-svn: 332811

6 years ago[LLVM-C] Use Length-Providing Value Name Getters and Setters
Robert Widmann [Sat, 19 May 2018 15:08:36 +0000 (15:08 +0000)]
[LLVM-C] Use Length-Providing Value Name Getters and Setters

Summary:
- Provide LLVMGetValueName2 and LLVMSetValueName2 that return and take the length of the provided C string respectively
- Deprecate LLVMGetValueName and LLVMSetValueName

Reviewers: whitequark, deadalnix

Reviewed By: whitequark

Subscribers: llvm-commits, harlanhaskins

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

llvm-svn: 332810

6 years ago[IRCE] Fix miscompile with range checks against negative values
Max Kazantsev [Sat, 19 May 2018 13:06:37 +0000 (13:06 +0000)]
[IRCE] Fix miscompile with range checks against negative values

In the patch rL329547, we have lifted the over-restrictive limitation on collected range
checks, allowing to work with range checks with the end of their range not being
provably non-negative. However it appeared that the non-negativity of this value was
assumed in the utility function `ClampedSubtract`. In particular, its reasoning is based
on the fact that `0 <= SINT_MAX - X`, which is not true if `X` is negative.

The function `ClampedSubtract` is only called twice, once with `X = 0` (which is OK)
and the second time with `X = IRC.getEnd()`, where we may now see the problem if
the end is actually a negative value. In this case, we may sometimes miscompile.

This patch is the conservative fix of the miscompile problem. Rather than rejecting
non-provably non-negative `getEnd()` values, we will check it for non-negativity in
runtime. For this, we use function `smax(smin(X, 0), -1) + 1` that is equal to `1` if `X`
is non-negative and is equal to 0 if `X` is negative. If we multiply `Begin, End` of safe
iteration space by this function calculated for `X = IRC.getEnd()`, we will get the original
`[Begin, End)` if `IRC.getEnd()` was non-negative (and, thus, `ClampedSubtract` worked
correctly) and the empty range `[0, 0)` in case if ` IRC.getEnd()` was negative.

So we in fact prohibit execution of the main loop if at least one of range checks was
made against a negative value (and we figured it out in runtime). It is still better than
what we have before (non-negativity had to be proved in compile time) and prevents
us from miscompile, however it is sometiles too restrictive for unsigned range checks
against a negative value (which in fact can be eliminated).

Once we re-implement `ClampedSubtract` in a way that it handles negative `X` correctly,
this limitation can be lifted, too.

Differential Revision: https://reviews.llvm.org/D46860
Reviewed By: samparker

llvm-svn: 332809

6 years ago[MergeICmps] Don't crash when memcmp is not available
Benjamin Kramer [Sat, 19 May 2018 12:51:59 +0000 (12:51 +0000)]
[MergeICmps] Don't crash when memcmp is not available

Fixes clang crashing with -fno-builtin, PR37527.

llvm-svn: 332808

6 years agoFix MSVC unused variable warning. NFCI.
Simon Pilgrim [Sat, 19 May 2018 12:46:02 +0000 (12:46 +0000)]
Fix MSVC unused variable warning. NFCI.

AMDGPURegisterInfo::getSubRegFromChannel is a static method - we don't need to get the AMDGPURegisterInfo instance.

llvm-svn: 332807

6 years ago[Driver] Temporarily remove test for LLVM findNearest
Brian Gesiak [Sat, 19 May 2018 12:44:02 +0000 (12:44 +0000)]
[Driver] Temporarily remove test for LLVM findNearest

Summary:
This fixes a failure caused by the revert of https://reviews.llvm.org/rL332805.

llvm-svn: 332806

6 years agoUn-revert "[Option] Fix PR37006 prefix choice in findNearest"
Brian Gesiak [Sat, 19 May 2018 12:03:26 +0000 (12:03 +0000)]
Un-revert "[Option] Fix PR37006 prefix choice in findNearest"

Summary:
In https://reviews.llvm.org/rL332804 I loosed the assertion in
the Clang driver test that forced me to revert
https://reviews.llvm.org/rL332299. Once this lands I should be
able to narrow down what caused PS4 buildbots to fail, and
reinstate the check in that test.

Test Plan: check-llvm & check-clang

llvm-svn: 332805

6 years ago[Driver] Loosen test for LLVM findNearest
Brian Gesiak [Sat, 19 May 2018 11:46:58 +0000 (11:46 +0000)]
[Driver] Loosen test for LLVM findNearest

Summary:
When https://reviews.llvm.org/D46776 landed to improve the behavior of
`llvm::OptTable::findNearest`, a PS4 buildbot began failing due to an
assertion that a suggestion "-debug-info-macro" should be provided for
the unrecognized option `clang -cc1as -debug-info-macros`. All other
buildbots succeeded in this check, and the PS4 buildbot succeeded in the
other `findNearest` tests.

Temporarily loosen this check in order to reland the `findNearest`
change.

Test Plan: check-clang

llvm-svn: 332804