platform/upstream/llvm.git
7 years agoFix 'set but not used' [-Wunused-but-set-variable] warning
Simon Pilgrim [Wed, 24 May 2017 10:38:09 +0000 (10:38 +0000)]
Fix 'set but not used' [-Wunused-but-set-variable] warning

llvm-svn: 303734

7 years ago[ARM] Remove ThumbTargetMachines. (NFC)
Florian Hahn [Wed, 24 May 2017 10:18:57 +0000 (10:18 +0000)]
[ARM] Remove ThumbTargetMachines. (NFC)

Summary:
Thumb code generation is controlled by ARMSubtarget and the concrete
ThumbLETargetMachine and ThumbBETargetMachine are not needed.

Eric Christopher suggested removing the unneeded target machines in
https://reviews.llvm.org/D33287.

I think it still makes sense to keep separate TargetMachines for big and
little endian as we probably do not want to have different endianess for
difference functions in a single compilation unit. The MIPS backend has
two separate TargetMachines for big and little endian as well.

Reviewers: echristo, rengolin, kristof.beyls, t.p.northover

Reviewed By: echristo

Subscribers: aemerson, javed.absar, arichardson, llvm-commits

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

llvm-svn: 303733

7 years agoRunThreadPlan: Fix halting logic in IgnoreBreakpoints = false
Pavel Labath [Wed, 24 May 2017 09:46:48 +0000 (09:46 +0000)]
RunThreadPlan: Fix halting logic in IgnoreBreakpoints = false

Summary:
The function had logic to handle the case when the expression terminated
while we were trying to halt the process, but it failed to take into
account the possibility that the expression stopped because it hit a
breakpoint. This was caused by the fact that the handling of the stopped
events was duplicated for the "halting" and regular cases (the regular
case handled this situation correctly). I've tried to merge these two
cases into one to make sure they stay in sync.

I should call out that the two cases were checking whether the thread
plan has completed in slightly different ways. I am not sure what is the
difference between them, but I think the check should be the same in
both cases, whatever it is, so I just took the one from the regular
case, as that is probably more tested.

For the test, I modified TestUnwindExpression to run the expression with
a smaller timeout (this is how I found this bug originally). With a 1ms
one thread timeout, the test failed consistently without this patch.

Reviewers: jingham

Subscribers: lldb-commits

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

llvm-svn: 303732

7 years agoMachineCSE: Respect interblock physreg liveness
Mikael Holmen [Wed, 24 May 2017 09:35:23 +0000 (09:35 +0000)]
MachineCSE: Respect interblock physreg liveness

Summary:
This is a fix for PR32538. MachineCSE first looks at MO.isDead(), but
if it is not marked dead, MachineCSE still wants to do its own check
to see if it is trivially dead. This check for the trivial case
assumed that physical registers cannot be live out of a block.

Patch by Mattias Eriksson.

Reviewers: qcolombet, jbhateja

Reviewed By: qcolombet, jbhateja

Subscribers: jbhateja, llvm-commits

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

llvm-svn: 303731

7 years ago[SCEV] Do not fold dominated SCEVUnknown into AddRecExpr start
Max Kazantsev [Wed, 24 May 2017 08:52:18 +0000 (08:52 +0000)]
[SCEV] Do not fold dominated SCEVUnknown into AddRecExpr start

When folding arguments of AddExpr or MulExpr with recurrences, we rely on the fact that
the loop of our base recurrency is the bottom-lost in terms of domination. This assumption
may be broken by an expression which is treated as invariant, and which depends on a complex
Phi for which SCEVUnknown was created. If such Phi is a loop Phi, and this loop is lower than
the chosen AddRecExpr's loop, it is invalid to fold our expression with the recurrence.

Another reason why it might be invalid to fold SCEVUnknown into Phi start value is that unlike
other SCEVs, SCEVUnknown are sometimes position-bound. For example, here:

for (...) { // loop
  phi = {A,+,B}
}
X = load ...
Folding phi + X into {A+X,+,B}<loop> actually makes no sense, because X does not exist and cannot
exist while we are iterating in loop (this memory can be even not allocated and not filled by this moment).
It is only valid to make such folding if X is defined before the loop. In this case the recurrence {A+X,+,B}<loop>
may be existant.

This patch prohibits folding of SCEVUnknown (and those who use them) into the start value of an AddRecExpr,
if this instruction is dominated by the loop. Merging the dominating unknown values is still valid. Some tests that
relied on the fact that some SCEVUnknown should be folded into AddRec's are changed so that they no longer
expect such behavior.

llvm-svn: 303730

7 years ago[compiler-rt] Change default of allow_user_segv_handler to true
Vitaly Buka [Wed, 24 May 2017 07:21:39 +0000 (07:21 +0000)]
[compiler-rt] Change default of allow_user_segv_handler to true

Reviewers: eugenis

Subscribers: srhines, kubamracek, llvm-commits

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

llvm-svn: 303729

7 years ago[asan] Remove allow_user_segv_handler on Windows.
Vitaly Buka [Wed, 24 May 2017 07:17:27 +0000 (07:17 +0000)]
[asan] Remove allow_user_segv_handler on Windows.

Summary:
This flags is not covered by tests on Windows and looks like it's implemented
incorrectly. Switching its default breaks some tests.

Taking into account that related handle_segv flag is not supported on Windows
it's safer to remove it until we commit to support it.

Reviewers: eugenis, zturner, rnk

Subscribers: kubamracek, llvm-commits

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

llvm-svn: 303728

7 years agoExplicitly set CPU and -slow-incdec to try to fix r303678's test on llvm-clang-x86_64...
Daniel Sanders [Wed, 24 May 2017 07:02:37 +0000 (07:02 +0000)]
Explicitly set CPU and -slow-incdec to try to fix r303678's test on llvm-clang-x86_64-expensive-checks-win.

llvm-svn: 303727

7 years ago[APInt] Use std::end to avoid mentioning the size of a local buffer repeatedly.
Craig Topper [Wed, 24 May 2017 07:00:55 +0000 (07:00 +0000)]
[APInt] Use std::end to avoid mentioning the size of a local buffer repeatedly.

llvm-svn: 303726

7 years agoAdd a permanent Polly Hangouts URL
Tobias Grosser [Wed, 24 May 2017 06:46:11 +0000 (06:46 +0000)]
Add a permanent Polly Hangouts URL

llvm-svn: 303725

7 years agoAdd new C++ bindings to release notes
Tobias Grosser [Wed, 24 May 2017 06:46:09 +0000 (06:46 +0000)]
Add new C++ bindings to release notes

llvm-svn: 303724

7 years agoUpdate version number in Polly release notes
Tobias Grosser [Wed, 24 May 2017 06:46:06 +0000 (06:46 +0000)]
Update version number in Polly release notes

llvm-svn: 303723

7 years agoHeader file to help forcibly link GPURuntime
Tobias Grosser [Wed, 24 May 2017 06:46:03 +0000 (06:46 +0000)]
Header file to help forcibly link GPURuntime

Summary: LinkGPURuntime.h defines and creates a structure ForceGPURuntimeLinking which creates an artificial dependency to functions defined in GPUJIT.c. The presence of this structure ensures that these functions are a part of the compiled object/library files including it.

Reviewers: grosser, Meinersbur

Reviewed By: grosser

Subscribers: #polly, pollydev

Tags: #polly

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

llvm-svn: 303722

7 years agoRevert r303720: Tweak r303678's test to try to fix llvm-clang-x86_64-expensive-checks...
Daniel Sanders [Wed, 24 May 2017 06:44:55 +0000 (06:44 +0000)]
Revert r303720: Tweak r303678's test to try to fix llvm-clang-x86_64-expensive-checks-win.

It doesn't fix that builder.

llvm-svn: 303721

7 years agoTweak r303678's test to try to fix llvm-clang-x86_64-expensive-checks-win.
Daniel Sanders [Wed, 24 May 2017 06:05:14 +0000 (06:05 +0000)]
Tweak r303678's test to try to fix llvm-clang-x86_64-expensive-checks-win.

I suspect this buildbot has slow-incdec set by default, most likely due to
the default CPU having this set. This feature bit can prevent optsize from
having an effect on this IR.

llvm-svn: 303720

7 years ago[XRay][clang] Allow imbuing arg1 logging attribute via -fxray-always-instrument=
Dean Michael Berris [Wed, 24 May 2017 05:46:36 +0000 (05:46 +0000)]
[XRay][clang] Allow imbuing arg1 logging attribute via -fxray-always-instrument=

Summary:
This change allows us to add arg1 logging support to functions through
the special case list provided through -fxray-always-instrument=. This
is useful for adding arg1 logging to functions that are either in
headers that users don't have control over (i.e. cannot change the
source) or would rather not do.

It only takes effect when the pattern is matched through the "fun:"
special case, as a category. As in:

  fun:*pattern=arg1

Reviewers: pelikan, rnk

Subscribers: cfe-commits

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

llvm-svn: 303719

7 years ago[demangler] Fix a crash in the demangler during parsing of a lamdba
Erik Pilkington [Wed, 24 May 2017 05:44:19 +0000 (05:44 +0000)]
[demangler] Fix a crash in the demangler during parsing of a lamdba

The problem is that multiple types could have been parsed from parse_type(),
which the lamdba parameter parsing didn't handle.

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

llvm-svn: 303718

7 years ago[ARM] Add VLDx/VSTx sched defs for machine-schedulers. NFCI
Javed Absar [Wed, 24 May 2017 05:32:48 +0000 (05:32 +0000)]
[ARM] Add VLDx/VSTx sched defs for machine-schedulers. NFCI

This patch adds missing scheds for Neon VLDx/VSTx instructions.
This will help one write schedulers easier/faster in the future for ARM sub-targets.
Existing models will not affected by this patch.
Reviewed by: Renato Golin, Diana Picus
Differential Revision: https://reviews.llvm.org/D33120

llvm-svn: 303717

7 years ago[coroutines] Implement correct GRO lifetime
Gor Nishanov [Wed, 24 May 2017 02:38:26 +0000 (02:38 +0000)]
[coroutines] Implement correct GRO lifetime

Summary:
Sema creates a declaration for gro variable as:

auto $gro = $promise.get_return_object();

However, gro variable has to outlive coroutine frame and coroutine promise, but,
it can only be initialized after the coroutine promise was created, thus, we
split its emission in two parts: EmitGroAlloca emits an alloca and sets up
the cleanups. Later when the coroutine promise is available we initialize
the gro and set the flag that the cleanup is now active.

Duplicate of: https://reviews.llvm.org/D31670 (which arc patch refuses to apply for some reason)

Reviewers: GorNishanov, rsmith

Reviewed By: GorNishanov

Subscribers: EricWF, cfe-commits

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

llvm-svn: 303716

7 years ago[NewGVN] Update additionalUsers when we simplify to a value.
Davide Italiano [Wed, 24 May 2017 02:30:24 +0000 (02:30 +0000)]
[NewGVN] Update additionalUsers when we simplify to a value.

Otherwise we don't revisit an instruction that could be simplified,
and when we verify, we discover there's something that changed, i.e.
what we had wasn't a maximal fixpoint.

Fixes PR32836.

llvm-svn: 303715

7 years ago[coroutines] Fix leak in CGCoroutine.cpp
Gor Nishanov [Wed, 24 May 2017 01:54:37 +0000 (01:54 +0000)]
[coroutines] Fix leak in CGCoroutine.cpp

FinalBB need to be emitted even when unused to make sure it is deleted

llvm-svn: 303714

7 years agoChange __has_feature(objc_diagnose_if_attr) to __has_feature(attribute_diagnose_if_ob...
Argyrios Kyrtzidis [Wed, 24 May 2017 01:38:00 +0000 (01:38 +0000)]
Change __has_feature(objc_diagnose_if_attr) to __has_feature(attribute_diagnose_if_objc) for consistency with rest of attribute checks.

llvm-svn: 303713

7 years agoEnhance the 'diagnose_if' attribute so that we can apply it for ObjC methods and...
Argyrios Kyrtzidis [Wed, 24 May 2017 00:46:27 +0000 (00:46 +0000)]
Enhance the 'diagnose_if' attribute so that we can apply it for ObjC methods and properties as well

This is an initial commit to allow using it with constant expressions, a follow-up commit will enable full support for it in ObjC methods.

llvm-svn: 303712

7 years agoFix broken build.
Zachary Turner [Wed, 24 May 2017 00:35:32 +0000 (00:35 +0000)]
Fix broken build.

llvm-svn: 303711

7 years agoRevert "Disable coverage opt-out for strong postdominator blocks."
George Karpenkov [Wed, 24 May 2017 00:29:12 +0000 (00:29 +0000)]
Revert "Disable coverage opt-out for strong postdominator blocks."

This reverts commit 2ed06f05fc10869dd1239cff96fcdea2ee8bf4ef.
Buildbots do not like this on Linux.

llvm-svn: 303710

7 years agoRevert "Fixes for tests for r303698"
George Karpenkov [Wed, 24 May 2017 00:29:08 +0000 (00:29 +0000)]
Revert "Fixes for tests for r303698"

This reverts commit 69bfaf72e7502eb08bbca88a57925fa31c6295c6.

llvm-svn: 303709

7 years agogit-llvm script should add .exe on Windows.
Zachary Turner [Wed, 24 May 2017 00:28:46 +0000 (00:28 +0000)]
git-llvm script should add .exe on Windows.

llvm-svn: 303708

7 years agoDon't do a full scan of the type stream before processing records.
Zachary Turner [Wed, 24 May 2017 00:26:27 +0000 (00:26 +0000)]
Don't do a full scan of the type stream before processing records.

LazyRandomTypeCollection is designed for random access, and in
order to provide this it lazily indexes ranges of types.  In the
case of types from an object file, there is no partial index
to build off of, so it has to index the full stream up front.
However, merging types only requires sequential access, and when
that is needed, this extra work is simply wasted.  Changing the
algorithm to work on sequential arrays of types rather than
random access type collections eliminates this up front scan.

llvm-svn: 303707

7 years ago[SCCP] Use the `hasAddressTaken()` version defined in `Function`.
Davide Italiano [Tue, 23 May 2017 23:59:23 +0000 (23:59 +0000)]
[SCCP] Use the `hasAddressTaken()` version defined in `Function`.

Instead of using the SCCP homegrown one. We should eventually
make the private SCCP version disappear, but that wont' be today.
PR33143 tracks this issue.

Add braces for consistency while here. No functional change intended.

llvm-svn: 303706

7 years ago[Modules] Fix overly conservative assertion for import diagnostic
Bruno Cardoso Lopes [Tue, 23 May 2017 23:53:17 +0000 (23:53 +0000)]
[Modules] Fix overly conservative assertion for import diagnostic

We currenltly assert when want to diagnose a missing import and the decl
in question is already visible. It turns out that the decl in question
might be visible because another decl from the same module actually made
the module visible in a previous error diagnostic.

Remove the assertion and avoid re-exporting the module if it's already
visible.

rdar://problem/27975402

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

llvm-svn: 303705

7 years ago[LIR] Use the newly `getRecurrenceVar()` helper. NFCI.
Davide Italiano [Tue, 23 May 2017 23:51:54 +0000 (23:51 +0000)]
[LIR] Use the newly `getRecurrenceVar()` helper. NFCI.

llvm-svn: 303704

7 years agoClear OutSec->Sections.
Rafael Espindola [Tue, 23 May 2017 22:54:06 +0000 (22:54 +0000)]
Clear OutSec->Sections.

Once the dummy linker script is created, we want it to be used for
everything to avoid having two redundant representations that can get
out of sync.

We were already clearing OutputSections. With this patch we clear the
Sections vector of every OutputSection.

llvm-svn: 303703

7 years agoUse more strict types. NFC.
Rafael Espindola [Tue, 23 May 2017 22:47:31 +0000 (22:47 +0000)]
Use more strict types. NFC.

By the time we get to linker scripts, all special InputSectionBase
should have been combined into synthetic sections, which are a type of
InputSection. The net result is that we can use InputSection in a few
places that were using InputSectionBase.

llvm-svn: 303702

7 years agoFixes for tests for r303698
George Karpenkov [Tue, 23 May 2017 22:42:34 +0000 (22:42 +0000)]
Fixes for tests for r303698

llvm-svn: 303701

7 years ago[LIR] Strengthen the check for recurrence variable in popcnt/CTLZ.
Davide Italiano [Tue, 23 May 2017 22:32:56 +0000 (22:32 +0000)]
[LIR] Strengthen the check for recurrence variable in popcnt/CTLZ.

Fixes PR33114.
Differential Revision:  https://reviews.llvm.org/D33420

llvm-svn: 303700

7 years ago[modules] When reparenting a local declaration, don't mark the declaration as
Richard Smith [Tue, 23 May 2017 22:02:49 +0000 (22:02 +0000)]
[modules] When reparenting a local declaration, don't mark the declaration as
being visible with its owning module if we're not tracking owning modules for
local declarations.

This avoids the possibility of a declaration being (meaninglessly) marked as
hidden with no owning module, which would otherwise lead to violated AST
invariants (checked by the added assertion).

llvm-svn: 303699

7 years agoDisable coverage opt-out for strong postdominator blocks.
George Karpenkov [Tue, 23 May 2017 21:58:54 +0000 (21:58 +0000)]
Disable coverage opt-out for strong postdominator blocks.

Coverage instrumentation has an optimization not to instrument extra
blocks, if the pass is already "accounted for" by a
successor/predecessor basic block.
However (https://github.com/google/sanitizers/issues/783) this
reasoning may become circular, which stops valid paths from having
coverage.
In the worst case this can cause fuzzing to stop working entirely.

This change simplifies logic to something which trivially can not have
such circular reasoning, as losing valid paths does not seem like a
good trade-off for a ~15% decrease in the # of instrumented basic blocks.

llvm-svn: 303698

7 years agoRevert LLVM changes for "Sema: allow imaginary constants via GNU extension if UDL...
Tim Northover [Tue, 23 May 2017 21:53:11 +0000 (21:53 +0000)]
Revert LLVM changes for "Sema: allow imaginary constants via GNU extension if UDL overloads not present."

The changes accidentally crept into a Clang commit I was making.

llvm-svn: 303697

7 years ago[git-llvm] Check if svn is installed.
Rui Ueyama [Tue, 23 May 2017 21:50:40 +0000 (21:50 +0000)]
[git-llvm] Check if svn is installed.

The error message that git-llvm script prints out when svn is missing
is very cryptic. I spent a fair amount of time to find what was wrong
with my environment. It looks like many newcomers also exprienced a
hard time to submit their first patches due to this error.

This patch adds a more user-friendly error message.

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

llvm-svn: 303696

7 years ago[MSP430] Add subtarget features for hardware multiplier.
Vadzim Dambrouski [Tue, 23 May 2017 21:49:42 +0000 (21:49 +0000)]
[MSP430] Add subtarget features for hardware multiplier.

Also add more processors to make -mcpu option behave similar to gcc.

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

llvm-svn: 303695

7 years agoSema: allow imaginary constants via GNU extension if UDL overloads not present.
Tim Northover [Tue, 23 May 2017 21:41:49 +0000 (21:41 +0000)]
Sema: allow imaginary constants via GNU extension if UDL overloads not present.

C++14 added user-defined literal support for complex numbers so that you can
write something like "complex<double> val = 2i". However, there is an existing
GNU extension supporting this syntax and interpreting the result as a _Complex
type.

This changes parsing so that such literals are interpreted in terms of C++14's
operators if an overload is present but otherwise falls back to the original
GNU extension.

llvm-svn: 303694

7 years agoSilence MSVC warning about unsigned integer overflow, which has defined behavior
Reid Kleckner [Tue, 23 May 2017 21:35:32 +0000 (21:35 +0000)]
Silence MSVC warning about unsigned integer overflow, which has defined behavior

llvm-svn: 303693

7 years agoabtest: remove duplicate script
Francis Visoiu Mistrih [Tue, 23 May 2017 21:28:41 +0000 (21:28 +0000)]
abtest: remove duplicate script

This is fixing a mistake from r303690.

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

llvm-svn: 303692

7 years ago[AMDGPU] Add INDIRECT_BASE_ADDR to R600_Reg32 class (PR33045)
Simon Pilgrim [Tue, 23 May 2017 21:27:15 +0000 (21:27 +0000)]
[AMDGPU] Add INDIRECT_BASE_ADDR to R600_Reg32 class (PR33045)

This fixes 17 of the 41 -verify-machineinstrs test failures identified in PR33045

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

llvm-svn: 303691

7 years agoAsmPrinter: mark the beginning and the end of a function in verbose mode
Francis Visoiu Mistrih [Tue, 23 May 2017 21:22:16 +0000 (21:22 +0000)]
AsmPrinter: mark the beginning and the end of a function in verbose mode

llvm-svn: 303690

7 years agoELF: The later of --build-id and --build-id= wins.
Peter Collingbourne [Tue, 23 May 2017 21:16:48 +0000 (21:16 +0000)]
ELF: The later of --build-id and --build-id= wins.

If the compiler driver passes --build-id and the user uses -Wl to
pass --build-id= then the user's flag should take precedence.

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

llvm-svn: 303689

7 years ago[Frontend] Don't index into an empty string.
Benjamin Kramer [Tue, 23 May 2017 20:48:21 +0000 (20:48 +0000)]
[Frontend] Don't index into an empty string.

Found by msan!

llvm-svn: 303686

7 years agomerge-request.sh: Use https url for bugzilla
Tom Stellard [Tue, 23 May 2017 20:35:38 +0000 (20:35 +0000)]
merge-request.sh: Use https url for bugzilla

With the http url, the script fails with:

Connection lost/failed: 411 Client Error: Length Required

llvm-svn: 303685

7 years agoAMDGPU/SI: Move the local memory usage related checking after calling convention...
Changpeng Fang [Tue, 23 May 2017 20:25:41 +0000 (20:25 +0000)]
AMDGPU/SI: Move the local memory usage related checking after calling convention checking in PromoteAlloca

Summary:
  Promoting Alloca to Vector and Promoting Alloca to LDS are two independent handling of Alloca and should not affect each other.
As a result, we should not give up promoting to vector if there is not enough LDS. This patch factors out the local memory usage
related checking out and replace it after the calling convention checking.

Reviewer:
  arsenm

Differential Revision:
  http://reviews.llvm.org/D33139

llvm-svn: 303684

7 years agoFix unused variable warnings after r303678
Daniel Sanders [Tue, 23 May 2017 20:02:48 +0000 (20:02 +0000)]
Fix unused variable warnings after r303678

This should fix lld-x86_64-darwin13

llvm-svn: 303683

7 years ago[AArch64][Falkor] Refine sched details for LSLfast/ASRfast.
Geoff Berry [Tue, 23 May 2017 19:57:45 +0000 (19:57 +0000)]
[AArch64][Falkor] Refine sched details for LSLfast/ASRfast.

llvm-svn: 303682

7 years ago[AMDGPU] Combine and (srl) into shl (bfe)
Stanislav Mekhanoshin [Tue, 23 May 2017 19:54:48 +0000 (19:54 +0000)]
[AMDGPU] Combine and (srl) into shl (bfe)

Perform DAG combine:
and (srl x, c), mask => shl (bfe x, nb + c, mask >> nb), nb
Where nb is a number of trailing zeroes in mask.

It replaces two instructions with two and BFE is generally a more
expensive one. However this is only done if we are selecting a byte
or word at an aligned boundary which results in a proper SDWA
operand pattern. It is only done if SDWA is supported.

TODO: improve SDWA pass to actually convert this pattern. It is not
done now because we have an immediate in the instruction, which has
be moved into a VGPR.

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

llvm-svn: 303681

7 years ago[AArch64][Falkor] Fix sched details for FMOV of WZR/XZR.
Geoff Berry [Tue, 23 May 2017 19:54:28 +0000 (19:54 +0000)]
[AArch64][Falkor] Fix sched details for FMOV of WZR/XZR.

llvm-svn: 303680

7 years ago[ARM] Temporarily disable globals promotion to constant pools to prevent miscompilation
Oleg Ranevskyy [Tue, 23 May 2017 19:38:37 +0000 (19:38 +0000)]
[ARM] Temporarily disable globals promotion to constant pools to prevent miscompilation

Summary:
A temporary workaround for PR32780 - rematerialized instructions accessing the same promoted global through different constant pool entries.

The patch turns off the globals promotion optimization leaving all its code in place, so that it can be easily turned on once PR32780 is fixed.

Since this is a miscompilation issue causing generation of misbehaving code, and the problem is very subtle, the patch might be valuable enough to get into 4.0.1.

Reviewers: efriedma, jmolloy

Reviewed By: efriedma

Subscribers: aemerson, javed.absar, llvm-commits, rengolin, asl, tstellar

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

llvm-svn: 303679

7 years ago[globalisel][tablegen] Add support for (set $dst, 1) and test X86's OptForSize predicate.
Daniel Sanders [Tue, 23 May 2017 19:33:16 +0000 (19:33 +0000)]
[globalisel][tablegen] Add support for (set $dst, 1) and test X86's OptForSize predicate.

Summary:
It's rare but a small number of patterns use IntInit's at the root of the match.
On X86, one such rule is enabled by the OptForSize predicate and causes the
compiler to use the smaller:
%0 = MOV32r1
instead of the usual:
%0 = MOV32ri 1

This patch adds support for matching IntInit's at the root and uses this as a
test case for the optsize attribute that was implemented in r301750

Reviewers: qcolombet, ab, t.p.northover, rovka, kristof.beyls, aditya_nandakumar

Reviewed By: qcolombet

Subscribers: igorb, llvm-commits

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

llvm-svn: 303678

7 years agoFix bad change in RenderScriptx86ABIFixups.cpp, forgot to change everything necessary
Stephane Sezer [Tue, 23 May 2017 19:22:31 +0000 (19:22 +0000)]
Fix bad change in RenderScriptx86ABIFixups.cpp, forgot to change everything necessary

Summary: I didn't change all instances of i to I in this loop. I am a bad person and should feel bad. :(

Reviewers: sas

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

Change by Alex Langford <apl@fb.com>

llvm-svn: 303677

7 years ago[CodeView] Eliminate redundant hashes and allocations.
Zachary Turner [Tue, 23 May 2017 18:56:23 +0000 (18:56 +0000)]
[CodeView] Eliminate redundant hashes and allocations.

When writing field list records, we would construct a temporary
type serializer that shared a bump ptr allocator with the rest
of the application, so anything allocated from here would live
forever.  Furthermore, this temporary serializer had all the
properties of a full blown serializer including record hashing
and de-duplication.

These features are required when you're merging multiple type
streams into each other, because different streams may contain
identical records, but records from the same type stream will
never collide with each other.  So all of this hashing was
unnecessary.

To solve this, two fixes are made:

1) The temporary serializer keeps its own bump ptr allocator
instead of sharing a global one.  When it's finished, all of
its memory is freed.

2) Instead of using the same temporary serializer for the life
of an entire type stream, we use it only for the life of a single
field list record and delete it when the field list record is
completed.  This way the hash table will not grow as other
records from the same type stream get inserted.  Further improvements
could eliminate hashing entirely from this codepath.

This reduces the link time by 85% in my test, from 1 minute to 9
seconds.

llvm-svn: 303676

7 years agoImplement LWG#2790: Remove istreambuf_iterator::operator->. It never did anything...
Marshall Clow [Tue, 23 May 2017 18:55:32 +0000 (18:55 +0000)]
Implement LWG#2790: Remove istreambuf_iterator::operator->. It never did anything useful.

llvm-svn: 303675

7 years agohange RenderScriptx86ABIFixups.cpp to use llvm::AttributeList iterator
Stephane Sezer [Tue, 23 May 2017 18:54:03 +0000 (18:54 +0000)]
hange RenderScriptx86ABIFixups.cpp to use llvm::AttributeList iterator

LLVM::AttributeList recently had getNumSlots() removed, which broke the
build. This fixes the build using functions introduced in the
update to LLVM::AttributeList.

Change by Alex Langford <apl@fb.com>

llvm-svn: 303674

7 years ago[DAG] Add AddressSpace parameter to canMergeStoresTo. NFC.
Nirav Dave [Tue, 23 May 2017 18:53:02 +0000 (18:53 +0000)]
[DAG] Add AddressSpace parameter to canMergeStoresTo. NFC.

llvm-svn: 303673

7 years agoRemove trailing whitespace
Yuka Takahashi [Tue, 23 May 2017 18:52:27 +0000 (18:52 +0000)]
Remove trailing whitespace

llvm-svn: 303672

7 years ago[InstSimplify] Add more tests for undef inputs and multiplying by 0 for the add/sub...
Craig Topper [Tue, 23 May 2017 18:42:58 +0000 (18:42 +0000)]
[InstSimplify] Add more tests for undef inputs and multiplying by 0 for the add/sub/mul with overflow intrinsics. NFC

llvm-svn: 303671

7 years ago[GSoC] Shell autocompletion for clang
Yuka Takahashi [Tue, 23 May 2017 18:39:08 +0000 (18:39 +0000)]
[GSoC] Shell autocompletion for clang

Summary:
This is a first patch for GSoC project, bash-completion for clang.
To use this on bash, please run `source clang/utils/bash-autocomplete.sh`.
bash-autocomplete.sh is code for bash-completion.

Simple flag completion and path completion is available in this patch.

Reviewers: teemperor, v.g.vassilev, ruiu, Bigcheese, efriedma

Subscribers: llvm-commits

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

llvm-svn: 303670

7 years agoFix DIEHash refactoring that dropped the DW_AT_name from the hash
David Blaikie [Tue, 23 May 2017 18:36:07 +0000 (18:36 +0000)]
Fix DIEHash refactoring that dropped the DW_AT_name from the hash

llvm-svn: 303669

7 years ago[DAG] Add canMergeStoresTo predicate checks. NFCI.
Nirav Dave [Tue, 23 May 2017 18:33:09 +0000 (18:33 +0000)]
[DAG] Add canMergeStoresTo predicate checks. NFCI.

Propagate canMergeStoresTo checks to missing cases in StoreMerge.

llvm-svn: 303668

7 years agoSpeculative build fix for non-Windows
Reid Kleckner [Tue, 23 May 2017 18:28:13 +0000 (18:28 +0000)]
Speculative build fix for non-Windows

llvm-svn: 303667

7 years agoRefactor DWARF hashing to use a .def file to avoid repetition
David Blaikie [Tue, 23 May 2017 18:27:09 +0000 (18:27 +0000)]
Refactor DWARF hashing to use a .def file to avoid repetition

llvm-svn: 303666

7 years ago[PDB] Hash types up front when merging types instead of using StringMap
Reid Kleckner [Tue, 23 May 2017 18:23:59 +0000 (18:23 +0000)]
[PDB] Hash types up front when merging types instead of using StringMap

Summary:
First, StringMap uses llvm::HashString, which is only good for short
identifiers and really bad for large blobs of binary data like type
records. Moving to `DenseMap<StringRef, TypeIndex>` with some tricks for
memory allocation fixes that.

Unfortunately, that didn't buy very much performance. Profiling showed
that we spend a long time during DenseMap growth rehashing existing
entries. Also, in general, DenseMap is faster when the keys are small.
This change takes that to the logical conclusion by introducing a small
wrapper value type around a pointer to key data. The key data contains a
precomputed hash, the original record data (pointer and size), and the
type index, which is the "value" of our original map.

This reduces the time to produce llvm-as.exe and llvm-as.pdb from ~15s
on my machine to 3.5s, which is about a 4x improvement.

Reviewers: zturner, inglorion, ruiu

Subscribers: llvm-commits

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

llvm-svn: 303665

7 years ago[InstSimplify] auto-generate test checks. NFC
Craig Topper [Tue, 23 May 2017 17:57:36 +0000 (17:57 +0000)]
[InstSimplify] auto-generate test checks. NFC

llvm-svn: 303664

7 years ago[InstCombine] auto-generate test checks; NFC
Sanjay Patel [Tue, 23 May 2017 17:51:22 +0000 (17:51 +0000)]
[InstCombine] auto-generate test checks; NFC

llvm-svn: 303663

7 years agoDisable flaky ASan tests temporarily on darwin
Adam Nemet [Tue, 23 May 2017 17:50:48 +0000 (17:50 +0000)]
Disable flaky ASan tests temporarily on darwin

llvm-svn: 303662

7 years ago[InstCombine] allow icmp-xor folds for vectors (PR33138)
Sanjay Patel [Tue, 23 May 2017 17:29:58 +0000 (17:29 +0000)]
[InstCombine] allow icmp-xor folds for vectors (PR33138)

This fixes the first part of:
https://bugs.llvm.org/show_bug.cgi?id=33138

More work is needed for the bitcasted variant.

llvm-svn: 303660

7 years ago[InstCombine] Use update_test_checks to regenerate the ctpop test. NFC
Craig Topper [Tue, 23 May 2017 17:20:18 +0000 (17:20 +0000)]
[InstCombine] Use update_test_checks to regenerate the ctpop test. NFC

llvm-svn: 303659

7 years agoAMDGPU: Fold CI-specific complex SMRD patterns into existing complex patterns
Marek Olsak [Tue, 23 May 2017 17:14:34 +0000 (17:14 +0000)]
AMDGPU: Fold CI-specific complex SMRD patterns into existing complex patterns

This is just a cleanup. Also, it adds checking that ByteCount is aligned to 4.

Reviewers: arsenm, nhaehnle, tstellarAMD

Subscribers: kzhuravl, wdng, yaxunl, tony-tye

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

llvm-svn: 303658

7 years agoCommit AttributeList change that was supposed to be part of r303654
Reid Kleckner [Tue, 23 May 2017 17:03:28 +0000 (17:03 +0000)]
Commit AttributeList change that was supposed to be part of r303654

llvm-svn: 303656

7 years ago[RuntimeDyld, PowerPC] Fix regression from r303637
Ulrich Weigand [Tue, 23 May 2017 17:03:23 +0000 (17:03 +0000)]
[RuntimeDyld, PowerPC] Fix regression from r303637

Actually, to identify external symbols, we need to check for
*either* non-null Value.SymbolName *or* a SymType of
Symbol::ST_Unknown.

The former may happen for symbols not known to the JIT at all
(e.g. defined in a native library), while the latter happens
for symbols known to the JIT, but defined in a different module.

Fixed several regressions on big-endian ppc64.

llvm-svn: 303655

7 years ago[IR] Switch AttributeList to use an array for O(1) access
Reid Kleckner [Tue, 23 May 2017 17:01:48 +0000 (17:01 +0000)]
[IR] Switch AttributeList to use an array for O(1) access

Summary:
Before this change, AttributeLists stored a pair of index and
AttributeSet. This is memory efficient if most arguments do not have
attributes. However, it requires doing a search over the pairs to test
an argument or function attribute. Profiling shows that this loop was
0.76% of the time in 'opt -O2' of sqlite3.c, because LLVM constantly
tests values for nullability.

This was worth about 2.5% of mid-level optimization cycles on the
sqlite3 amalgamation. Here are the full perf results:
https://reviews.llvm.org/P7995

Here are just the before and after cycle counts:
```
$ perf stat -r 5 ./opt_before -O2 sqlite3.bc -o /dev/null
    13,274,181,184      cycles                    #    3.047 GHz                      ( +-  0.28% )
$ perf stat -r 5 ./opt_after -O2 sqlite3.bc -o /dev/null
    12,906,927,263      cycles                    #    3.043 GHz                      ( +-  0.51% )
```

This patch *does not* change the indices used to query attributes, as
requested by reviewers. Tracking whether an index is usable for array
indexing is a huge pain that affects many of the internal APIs, so it
would be good to come back later and do a cleanup to remove this
internal adjustment.

Reviewers: pete, chandlerc

Subscribers: javed.absar, llvm-commits

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

llvm-svn: 303654

7 years agoRemoved fallthrough annotation which does not directly precede switch label.
Galina Kistanova [Tue, 23 May 2017 16:56:10 +0000 (16:56 +0000)]
Removed fallthrough annotation which does not directly precede switch label.

llvm-svn: 303653

7 years ago[InstCombine] add icmp-xor tests to show vector neglect; NFC
Sanjay Patel [Tue, 23 May 2017 16:53:05 +0000 (16:53 +0000)]
[InstCombine] add icmp-xor tests to show vector neglect; NFC

Also, rename the tests and the file, add comments, and add more tests
because there are no existing tests for some of these folds.

These patterns are particularly important for crippled vector ISAs that
have limited compare predicates (PR33138).

llvm-svn: 303652

7 years ago[index] The references to enum constants from member enums that are
Alex Lorenz [Tue, 23 May 2017 16:47:01 +0000 (16:47 +0000)]
[index] The references to enum constants from member enums that are
from template instantiations should refer to the enum constant in the pattern
enum in the base template

rdar://32325459

llvm-svn: 303651

7 years ago[index] The references to member enums from template instantiations should
Alex Lorenz [Tue, 23 May 2017 16:35:50 +0000 (16:35 +0000)]
[index] The references to member enums from template instantiations should
refer to the pattern member enum in the base template

rdar://32325459

llvm-svn: 303650

7 years agoAdded LLVM_FALLTHROUGH to address gcc warning: this statement may fall through.
Galina Kistanova [Tue, 23 May 2017 16:33:07 +0000 (16:33 +0000)]
Added LLVM_FALLTHROUGH to address gcc warning: this statement may fall through.

llvm-svn: 303649

7 years ago[index] The references to type aliases and typedefs from template
Alex Lorenz [Tue, 23 May 2017 16:27:42 +0000 (16:27 +0000)]
[index] The references to type aliases and typedefs from template
instantiations should refer to the pattern type aliases / typedefs in the base
templates

rdar://32325459

llvm-svn: 303648

7 years ago[index] The references to fields from nested records in template instantiations
Alex Lorenz [Tue, 23 May 2017 16:25:06 +0000 (16:25 +0000)]
[index] The references to fields from nested records in template instantiations
should refer to the pattern fields in the nested records in the base templates

rdar://32352429

llvm-svn: 303647

7 years ago[index] The references to records from template instantiations should refer
Alex Lorenz [Tue, 23 May 2017 16:23:28 +0000 (16:23 +0000)]
[index] The references to records from template instantiations should refer
to the pattern records in the base templates

rdar://32325459

llvm-svn: 303646

7 years ago[clang-tidy] Do not dereference a null BaseType
Chih-Hung Hsieh [Tue, 23 May 2017 16:19:04 +0000 (16:19 +0000)]
[clang-tidy] Do not dereference a null BaseType

Check BaseType before dereference.
Simplified test case is derived from Android Open Source code.

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

llvm-svn: 303645

7 years ago[AMDGPU] Do not require opencl triple environment for OpenCL
Yaxun Liu [Tue, 23 May 2017 16:15:53 +0000 (16:15 +0000)]
[AMDGPU] Do not require opencl triple environment for OpenCL

A recent change requires opencl triple environment for compiling OpenCL
program, which causes regressions in libclc.

This patch fixes that. Instead of deducing language based on triple
environment, it checks LangOptions.

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

llvm-svn: 303644

7 years agoWe shouldn't put actual tests in directories that contain
Jim Ingham [Tue, 23 May 2017 16:11:21 +0000 (16:11 +0000)]
We shouldn't put actual tests in directories that contain
other test directories.

llvm-svn: 303643

7 years agoAdd test coverage for recent behavior change in GNU line marker pre-processing
Reid Kleckner [Tue, 23 May 2017 16:09:13 +0000 (16:09 +0000)]
Add test coverage for recent behavior change in GNU line marker pre-processing

llvm-svn: 303642

7 years ago[AMDGPU] Convert shl (add) into add (shl)
Stanislav Mekhanoshin [Tue, 23 May 2017 15:59:58 +0000 (15:59 +0000)]
[AMDGPU] Convert shl (add) into add (shl)

shl (or|add x, c2), c1 => or|add (shl x, c1), (c2 << c1)
This allows to fold a constant into an address in some cases as
well as to eliminate second shift if the expression is used as
an address and second shift is a result of a GEP.

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

llvm-svn: 303641

7 years agoRevert "Make TypeSerializer's StringMap use the same allocator."
Zachary Turner [Tue, 23 May 2017 15:50:37 +0000 (15:50 +0000)]
Revert "Make TypeSerializer's StringMap use the same allocator."

This reverts commit e34ccb7b57da25cc89ded913d8638a2906d1110a.

This is causing failures on the ASAN bots.

llvm-svn: 303640

7 years ago[mips] Remove unused class field. NFC
Simon Atanasyan [Tue, 23 May 2017 15:00:30 +0000 (15:00 +0000)]
[mips] Remove unused class field. NFC

llvm-svn: 303639

7 years ago[mips] Change type of MipsSubtarget ctor arguments s/std::string/StringRef/. NFC
Simon Atanasyan [Tue, 23 May 2017 15:00:26 +0000 (15:00 +0000)]
[mips] Change type of MipsSubtarget ctor arguments s/std::string/StringRef/. NFC

llvm-svn: 303638

7 years ago[RuntimeDyld, PowerPC] Fix check for external symbols when detecting reloction overflow
Ulrich Weigand [Tue, 23 May 2017 14:51:18 +0000 (14:51 +0000)]
[RuntimeDyld, PowerPC] Fix check for external symbols when detecting reloction overflow

The PowerPC part of processRelocationRef currently assumes that external
symbols can be identified by checking for SymType == SymbolRef::ST_Unknown.
This is actually incorrect in some cases, causing relocation overflows to
be mis-detected. The correct check is to test whether Value.SymbolName
is null.

Includes test case. Note that it is a bit tricky to replicate the exact
condition that triggers the bug in a test case. The one included here
seems to fail reliably (before the fix) across different operating
system versions on Power, but it still makes a few assumptions (called
out in the test case comments).

Also add ppc64le platform name to the supported list in the lit.local.cfg
files for the MCJIT and OrcMCJIT directories, since those tests were
currently not run at all.

Fixes PR32650.

Reviewer: hfinkel

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

llvm-svn: 303637

7 years ago[clangd] Added a missing dependency on clangdAST to fix the build
Ilya Biryukov [Tue, 23 May 2017 13:59:37 +0000 (13:59 +0000)]
[clangd] Added a missing dependency on clangdAST to fix the build

llvm-svn: 303636

7 years ago[Tooling][libclang] Remove unused CompilationDatabase::MappedSources
Krasimir Georgiev [Tue, 23 May 2017 13:50:43 +0000 (13:50 +0000)]
[Tooling][libclang] Remove unused CompilationDatabase::MappedSources

Summary:
This field is never assigned to and it's only ever read from libclang.
This patch removes it and adapts libclang to return constants.

Reviewers: klimek, bkramer

Reviewed By: klimek

Subscribers: cfe-commits, klimek

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

llvm-svn: 303635

7 years ago[clangd] Replaced WorkerRequest with std::function...
Ilya Biryukov [Tue, 23 May 2017 13:42:59 +0000 (13:42 +0000)]
[clangd] Replaced WorkerRequest with std::function...

Summary:
And implemented a helper function to dump an AST of a file for
testing/debugging purposes.

Reviewers: bkramer, krasimir

Reviewed By: krasimir

Subscribers: klimek, cfe-commits

Tags: #clang-tools-extra

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

llvm-svn: 303634

7 years ago[JumpThreading] Safely replace uses of condition
Anna Thomas [Tue, 23 May 2017 13:36:25 +0000 (13:36 +0000)]
[JumpThreading] Safely replace uses of condition

This patch builds over https://reviews.llvm.org/rL303349 and replaces
the use of the condition only if it is safe to do so.

We should not blindly RAUW the condition if experimental.guard or assume
is a use of that
condition. This is because LVI may have used the guard/assume to
identify the
value of the condition, and RUAWing will fold the guard/assume and uses
before the guards/assumes.

Reviewers: sanjoy, reames, trentxintong, mkazantsev

Reviewed by: sanjoy, reames

Subscribers: llvm-commits

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

llvm-svn: 303633

7 years ago[RuntimeDyld, PowerPC] Fix relocation detection overflow
Ulrich Weigand [Tue, 23 May 2017 12:43:57 +0000 (12:43 +0000)]
[RuntimeDyld, PowerPC] Fix relocation detection overflow

Code in RuntimeDyldELF currently uses 32-bit temporaries to detect
whether a PPC64 relocation target is out of range. This is incorrect,
and can mis-detect overflow where the distance between relocation site
and target is close to a multiple of 4GB. Fixed by using 64-bit
temporaries.

Noticed while debugging PR32650.

Reviewer: hfinkel

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

llvm-svn: 303632

7 years ago[NFC] [PolyhedralInfo] fix typo
Siddharth Bhat [Tue, 23 May 2017 11:41:52 +0000 (11:41 +0000)]
[NFC] [PolyhedralInfo] fix typo

"an" -> "and"

llvm-svn: 303631