platform/upstream/llvm.git
9 years ago[LSR] canonicalize Prod*(1<<C) to Prod<<C
Jingyue Wu [Wed, 24 Jun 2015 19:28:40 +0000 (19:28 +0000)]
[LSR] canonicalize Prod*(1<<C) to Prod<<C

Summary:
Because LSR happens at a late stage where mul of a power of 2 is
typically canonicalized to shl, this canonicalization emits code that
can be better CSE'ed.

Test Plan:
Transforms/LoopStrengthReduce/shl.ll shows how this change makes GVN more
powerful. Fixes some existing tests due to this change.

Reviewers: sanjoy, majnemer, atrick

Reviewed By: majnemer, atrick

Subscribers: majnemer, llvm-commits

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

llvm-svn: 240573

9 years agoUse Symbol.getValue to simplify RuntimeDyldCOFF::getSymbolOffset. NFC.
Rafael Espindola [Wed, 24 Jun 2015 19:27:53 +0000 (19:27 +0000)]
Use Symbol.getValue to simplify RuntimeDyldCOFF::getSymbolOffset. NFC.

llvm-svn: 240572

9 years ago[Preprocessor] Iterating over all macros should include those from modules.
Jordan Rose [Wed, 24 Jun 2015 19:27:02 +0000 (19:27 +0000)]
[Preprocessor] Iterating over all macros should include those from modules.

So, iterate over the list of macros mentioned in modules, and make sure those
are in the master table.

This isn't particularly efficient, but hopefully it's something that isn't
done too often.

PR23929 and rdar://problem/21480635

llvm-svn: 240571

9 years ago[ELF] Fix .init_array initialization
Adhemerval Zanella [Wed, 24 Jun 2015 19:26:00 +0000 (19:26 +0000)]
[ELF] Fix .init_array initialization

Some compilers may not add the section symbol in '.symtab' for the
.init_array and 'ldd' just ignore it.  It results in global constructor
not being called in final executable.

This patch add both '.init_array' and '.fini_array' to be added in
Atom graph generation even when the section contains no symbol.  An
already existing testcase is modified to check for such scenario.

The issue fixes the llvm test-suite regressions for both Single
and MultiSource files.

llvm-svn: 240570

9 years agoAdd a SymbolRef::getValue.
Rafael Espindola [Wed, 24 Jun 2015 19:11:10 +0000 (19:11 +0000)]
Add a SymbolRef::getValue.

This returns either the symbol offset or address. Since it is not defined which
one, it never has to lookup the section and so never fails.

I will add users in the next commit.

llvm-svn: 240569

9 years agoDevirtualize Constant::replaceUsesOfWithOnConstant.
Pete Cooper [Wed, 24 Jun 2015 18:55:24 +0000 (18:55 +0000)]
Devirtualize Constant::replaceUsesOfWithOnConstant.

This is part of the work to devirtualize Value.

The old pattern was to call replaceUsesOfWithOnConstant which was overridden by
subclasses.  Those could then call replaceUsesOfWithOnConstantImpl on Constant
to handle deleting the current value.

To be consistent with other parts of the code, this has been changed so that we
call the method on Constant, and that dispatches to an Impl on subclasses.

As part of this, it made sense to rename the methods to be more descriptive.  The
new name is Constant::handleOperandChange, and it requires that all subclasses of
Constant implement handleOperandChangeImpl, even if they just throw an error if
they shouldn't be called.

Reviewed by Duncan Exon Smith.

llvm-svn: 240567

9 years agoAsmPrinter: Cleanup DIEValue::EmitValue() API, NFC
Duncan P. N. Exon Smith [Wed, 24 Jun 2015 18:48:11 +0000 (18:48 +0000)]
AsmPrinter: Cleanup DIEValue::EmitValue() API, NFC

Stop taking a `dwarf::Form` in `DIEValue::EmitValue()` and
`DIEValue::SizeOf()`, since they're always passed `DIEValue::getForm()`
anyway.  This is just left over from when `DIEValue` didn't know its own
form.

llvm-svn: 240566

9 years agoRevert rL240435: "Mark SBFrame::GetFunctionName and SBFrame::IsInlined as const.".
Oleksiy Vyalov [Wed, 24 Jun 2015 18:35:36 +0000 (18:35 +0000)]
Revert rL240435: "Mark SBFrame::GetFunctionName and SBFrame::IsInlined as const.".

llvm-svn: 240565

9 years agoSafeStack: Add another missing header to try to fix FreeBSD build.
Peter Collingbourne [Wed, 24 Jun 2015 18:16:05 +0000 (18:16 +0000)]
SafeStack: Add another missing header to try to fix FreeBSD build.

llvm-svn: 240564

9 years agoRefactor duplicated code. NFC.
Rafael Espindola [Wed, 24 Jun 2015 18:14:41 +0000 (18:14 +0000)]
Refactor duplicated code. NFC.

llvm-svn: 240563

9 years agoObject: Add XFAILed test case for r239560.
Peter Collingbourne [Wed, 24 Jun 2015 18:03:39 +0000 (18:03 +0000)]
Object: Add XFAILed test case for r239560.

We ought to also emit unmangled references to dllimported functions,
but no existing linker needs this.

llvm-svn: 240562

9 years ago[CaptureTracking] Avoid long compilation time on large basic blocks
Bruno Cardoso Lopes [Wed, 24 Jun 2015 17:53:17 +0000 (17:53 +0000)]
[CaptureTracking] Avoid long compilation time on large basic blocks

CaptureTracking becomes very expensive in large basic blocks while
calling PointerMayBeCaptured. PointerMayBeCaptured scans the BB the
number of times equal to the number of uses of 'BeforeHere', which is
currently capped at 20 and bails out with Tracker->tooManyUses().

The bottleneck here is the number of calls to PointerMayBeCaptured * the
basic block scan. In a testcase with a 82k instruction BB,
PointerMayBeCaptured is called 130k times, leading to 'shouldExplore'
taking 527k runs, this currently takes ~12min.

To fix this we locally (within PointerMayBeCaptured) number the
instructions in the basic block using a DenseMap to cache instruction
positions/numbers. We build the cache incrementally every time we need
to scan an unexplored part of the BB, improving compile time to only
take ~2min.

This triggers in the flow: DeadStoreElimination -> MepDepAnalysis ->
CaptureTracking.

Side note: after multiple runs in the test-suite I've seen no
performance nor compile time regressions, but could note a couple of
compile time improvements:

Performance Improvements - Compile Time Delta Previous  Current StdDev
SingleSource/Benchmarks/Misc-C++/bigfib -4.48%  0.8547  0.8164  0.0022
MultiSource/Benchmarks/TSVC/LoopRerolling-dbl/LoopRerolling-dbl -1.47% 1.3912  1.3707  0.0056

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

llvm-svn: 240560

9 years agoMIR Serialization: Serialize the null register operands.
Alex Lorenz [Wed, 24 Jun 2015 17:34:58 +0000 (17:34 +0000)]
MIR Serialization: Serialize the null register operands.

This commit serializes the null register machine operands.
It uses the '_' keyword to represent them, but the parser
also allows the '%noreg' named register syntax.

Reviewers: Duncan P. N. Exon Smith

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

llvm-svn: 240558

9 years ago[LoopVectorizer] Fix bailing-out condition for OptForSize case.
Michael Zolotukhin [Wed, 24 Jun 2015 17:26:24 +0000 (17:26 +0000)]
[LoopVectorizer] Fix bailing-out condition for OptForSize case.

With option OptForSize enabled, the Loop Vectorizer is not supposed to
create tail loop. The condition checking that was invalid and was not
matching to the comment above.

Patch by Marianne Mailhot-Sarrasin.

llvm-svn: 240556

9 years agoSafeStack: Add #include of <stdint.h>.
Peter Collingbourne [Wed, 24 Jun 2015 17:23:13 +0000 (17:23 +0000)]
SafeStack: Add #include of <stdint.h>.

Should fix the FreeBSD build.

llvm-svn: 240555

9 years agoSimplify the logic, NFC.
Rafael Espindola [Wed, 24 Jun 2015 17:08:44 +0000 (17:08 +0000)]
Simplify the logic, NFC.

llvm-svn: 240554

9 years agoADTTests: merge #ifdef checks from r240436.
Alex Lorenz [Wed, 24 Jun 2015 17:05:04 +0000 (17:05 +0000)]
ADTTests: merge #ifdef checks from r240436.

This commit merges the #ifdef and #ifndef checks into one #if, as
suggested by Duncan P. N. Exon Smith.

llvm-svn: 240553

9 years agoprepare-builtins: Fix build with LLVM 3.7
Tom Stellard [Wed, 24 Jun 2015 17:03:50 +0000 (17:03 +0000)]
prepare-builtins: Fix build with LLVM 3.7

llvm-svn: 240552

9 years agoRemove xfail for TestDisassembleBreakpoint.
Chaoren Lin [Wed, 24 Jun 2015 16:41:39 +0000 (16:41 +0000)]
Remove xfail for TestDisassembleBreakpoint.

LLGS no longer returns trap code in memory.

llvm-svn: 240551

9 years agoRemove SetResumeState from POSIXThread::RefreshStateAfterStop
Ed Maste [Wed, 24 Jun 2015 16:39:22 +0000 (16:39 +0000)]
Remove SetResumeState from POSIXThread::RefreshStateAfterStop

With the removal of ProcessLinux in r240543 this code is used only on
FreeBSD. FreeBSD isn't affected by whichever issue originally prompted
the addition of SetResumeState, so just remove it.

As discussed on the mailing list (and mentioned in a FIXME comment)
it shouldn't be called there.

llvm-svn: 240550

9 years agoRemove empty ProcessPOSIX::StopAllThreads
Ed Maste [Wed, 24 Jun 2015 16:24:56 +0000 (16:24 +0000)]
Remove empty ProcessPOSIX::StopAllThreads

The removal of ProcessLinux in r240543 left only an empty
StopAllThreads (it's not needed on FreeBSD), so just remove it too.

llvm-svn: 240549

9 years agoclang-format: [JS] Support regex literals containing quotes (' and ").
Daniel Jasper [Wed, 24 Jun 2015 16:01:02 +0000 (16:01 +0000)]
clang-format: [JS] Support regex literals containing quotes (' and ").

llvm-svn: 240548

9 years agoRemove unused variable
Ed Maste [Wed, 24 Jun 2015 15:27:35 +0000 (15:27 +0000)]
Remove unused variable

llvm-svn: 240547

9 years agoProper handling of QNonStop packet response.
Ewan Crawford [Wed, 24 Jun 2015 15:14:26 +0000 (15:14 +0000)]
Proper handling of QNonStop packet response.

Turn non-stop mode off if reply to QNonStop packet isn't an OK.

llvm-svn: 240546

9 years agoExpress Driver::GetFilePath more concisely.
Douglas Katzman [Wed, 24 Jun 2015 15:10:30 +0000 (15:10 +0000)]
Express Driver::GetFilePath more concisely.

llvm-svn: 240545

9 years agoDon't get confused with sections whose section number is reserved.
Rafael Espindola [Wed, 24 Jun 2015 14:48:54 +0000 (14:48 +0000)]
Don't get confused with sections whose section number is reserved.

It is perfectly possible for SHNDX to contain indexes that have the same value
as reserved st_shndx values.

llvm-svn: 240544

9 years agoRemove old local-only linux debugging code
Pavel Labath [Wed, 24 Jun 2015 14:43:20 +0000 (14:43 +0000)]
Remove old local-only linux debugging code

Summary:
Currently, the local-only path fails about 50% of the tests, which means that: a) nobody is using
it; and b) the remote debugging path is much more stable. This commit removes the local-only
linux debugging code (ProcessLinux) and makes remote-loopback the only way to debug local
applications (the same architecture as OSX). The ProcessPOSIX code is moved to the FreeBSD
directory, which is now the only user of this class. Hopefully, FreeBSD will soon move to the new
architecture as well and then this code can be removed completely.

Test Plan: Test suite passes via remote stub.

Reviewers: emaste, vharron, ovyalov, clayborg

Subscribers: tberghammer, emaste, lldb-commits

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

llvm-svn: 240543

9 years ago[X86][AVX] Added full set of 256-bit vector shift tests.
Simon Pilgrim [Wed, 24 Jun 2015 13:52:25 +0000 (13:52 +0000)]
[X86][AVX] Added full set of 256-bit vector shift tests.

llvm-svn: 240542

9 years agoasan: fix 32-bit build
Dmitry Vyukov [Wed, 24 Jun 2015 13:27:56 +0000 (13:27 +0000)]
asan: fix 32-bit build

llvm-svn: 240541

9 years agoEliminate additional redundant copies of Triple objects. NFC.
Daniel Sanders [Wed, 24 Jun 2015 13:25:57 +0000 (13:25 +0000)]
Eliminate additional redundant copies of Triple objects. NFC.

Subscribers: rafael, llvm-commits, rengolin

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

llvm-svn: 240540

9 years agotsan: don't print external PCs in reports
Dmitry Vyukov [Wed, 24 Jun 2015 13:04:12 +0000 (13:04 +0000)]
tsan: don't print external PCs in reports

They are meaningless.

llvm-svn: 240539

9 years agoFix instruction scheduling live register tracking
Pawel Bylica [Wed, 24 Jun 2015 12:49:42 +0000 (12:49 +0000)]
Fix instruction scheduling live register tracking

Summary:
This patch fixes PR23405 (https://llvm.org/bugs/show_bug.cgi?id=23405).

During a node unscheduling an entry in LiveRegGens can be replaced with a new value. That corrupts the live reg tracking and LiveReg* structure is not cleared as should be during unscheduling. Problematic condition that enforces Gen replacement is `I->getSUnit()->getHeight() < LiveRegGens[I->getReg()]->getHeight()`. This condition should be checked only if LiveRegGen was set in current node unscheduling.

Test Plan: Regression test included.

Reviewers: hfinkel, atrick

Reviewed By: atrick

Subscribers: llvm-commits

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

llvm-svn: 240538

9 years agoFix location of symbol size calculation in ObjectFileELF
Tamas Berghammer [Wed, 24 Jun 2015 12:31:25 +0000 (12:31 +0000)]
Fix location of symbol size calculation in ObjectFileELF

Bug introduced by r240533

llvm-svn: 240537

9 years agoSilencing some Sphinx warnings about duplicate explicit target names.
Aaron Ballman [Wed, 24 Jun 2015 12:11:04 +0000 (12:11 +0000)]
Silencing some Sphinx warnings about duplicate explicit target names.

llvm-svn: 240536

9 years agotsan: fix unbounded memory consumption for large mallocs
Dmitry Vyukov [Wed, 24 Jun 2015 11:51:41 +0000 (11:51 +0000)]
tsan: fix unbounded memory consumption for large mallocs

This happens only in corner cases, but we observed this on a real app.
See the test for description of the exact scenario that lead to unbounded memory consumption.

llvm-svn: 240535

9 years ago[llvm-stress] Simple refactoring and better style. NFC.
Pawel Bylica [Wed, 24 Jun 2015 11:49:44 +0000 (11:49 +0000)]
[llvm-stress] Simple refactoring and better style. NFC.

llvm-svn: 240534

9 years agoImprove instruction emulation based stack unwinding on ARM
Tamas Berghammer [Wed, 24 Jun 2015 11:27:32 +0000 (11:27 +0000)]
Improve instruction emulation based stack unwinding on ARM

* Add and fix the emulation of several instruction.
* Disable frame pointer usage on Android.
* Specify return address register for the unwind plan instead of explict
  tracking the value of RA.
* Replace prologue detection heuristics (unreliable in several cases)
  with a logic to follow the branch instructions and restore the CFI
  value based on them. The target address for a branch should have the
  same CFI as the source address (if they are in the same function).
* Handle symbols in ELF files where the symbol size is not specified
  with calcualting their size based on the next symbol (already done
  in MachO files).
* Fix architecture in FuncUnwinders with filling up the inforamtion
  missing from the object file with the architecture of the target.
* Add code to read register wehn the value is set to "IsSame" as it
  meanse the value of a register in the parent frame is the same as the
  value in the current frame.

Differential revision: http://reviews.llvm.org/D10447

llvm-svn: 240533

9 years ago[OPENMP] Codegen for 'depend' clause (OpenMP 4.0).
Alexey Bataev [Wed, 24 Jun 2015 11:01:36 +0000 (11:01 +0000)]
[OPENMP] Codegen for 'depend' clause (OpenMP 4.0).

If task directive has associated 'depend' clause then function kmp_int32 __kmpc_omp_task_with_deps ( ident_t *loc_ref, kmp_int32 gtid, kmp_task_t * new_task, kmp_int32 ndeps, kmp_depend_info_t *dep_list,kmp_int32 ndeps_noalias, kmp_depend_info_t *noalias_dep_list) must be called instead of __kmpc_omp_task().
If this directive has associated 'if' clause then also before a call of kmpc_omp_task_begin_if0() a function void __kmpc_omp_wait_deps ( ident_t *loc_ref, kmp_int32 gtid, kmp_int32 ndeps, kmp_depend_info_t *dep_list, kmp_int32 ndeps_noalias, kmp_depend_info_t *noalias_dep_list) must be called.
Array sections are not supported yet.

llvm-svn: 240532

9 years ago[mips][microMIPS] Implement BREAK, EHB and EI instructions
Zoran Jovanovic [Wed, 24 Jun 2015 10:32:16 +0000 (10:32 +0000)]
[mips][microMIPS] Implement BREAK, EHB and EI instructions
http://reviews.llvm.org/D10090

llvm-svn: 240531

9 years agoRemove a limited and somewhat questionable DenseMapInfo specialization
Chandler Carruth [Wed, 24 Jun 2015 10:24:30 +0000 (10:24 +0000)]
Remove a limited and somewhat questionable DenseMapInfo specialization
for StringRef now that the core DenseMap library provides this facility.

llvm-svn: 240530

9 years agoChange how symbol sizes are handled in lib/Object.
Rafael Espindola [Wed, 24 Jun 2015 10:20:30 +0000 (10:20 +0000)]
Change how symbol sizes are handled in lib/Object.

COFF and MachO only define symbol sizes for common symbols. Reflect that
in the class hierarchy by having a method for common symbols only in the base
and a general one in ELF.

This avoids the need of using a magic value for the size, which had a few
problems
* Most callers didn't check for it.
* The ones that did could not tell the magic value from a file actually having
  that value.

llvm-svn: 240529

9 years ago[ADT] Teach DenseMap to support StringRef keys.
Chandler Carruth [Wed, 24 Jun 2015 10:06:29 +0000 (10:06 +0000)]
[ADT] Teach DenseMap to support StringRef keys.

While often you want to use something specialized like StringMap, when
the strings already have persistent storage a normal densemap over them
can be more efficient.

This can't go into StringRef.h because of really obnoxious header chains
from the hashing code to the endian detection code to CPU feature
detection code to StringMap.

llvm-svn: 240528

9 years agoMake support for thread-unsafe C functions optional.
Ed Schouten [Wed, 24 Jun 2015 08:44:38 +0000 (08:44 +0000)]
Make support for thread-unsafe C functions optional.

One of the aspects of CloudABI is that it aims to help you write code
that is thread-safe out of the box. This is very important if you want
to write libraries that are easy to reuse. For CloudABI we decided to
not provide the thread-unsafe functions. So far this is working out
pretty well, as thread-unsafety issues are detected really early on.

The following patch adds a knob to libc++,
_LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS, that can be set to disable
thread-unsafe functions that can easily be avoided in practice. The
following functions are not thread-safe:

- <clocale>: locale handles should be preferred over setlocale().
- <cstdlib>: mbrlen(), mbrtowc() and wcrtomb() should be preferred over
  their non-restartable counterparts.
- <ctime>: asctime(), ctime(), gmtime() and localtime() are not
  thread-safe. The first two are also deprecated by POSIX.

Differential Revision: http://reviews.llvm.org/D8703
Reviewed by: marshall

llvm-svn: 240527

9 years agoHexagon: Paper over the undefined behaviour introduced by r238692
Justin Bogner [Wed, 24 Jun 2015 07:03:07 +0000 (07:03 +0000)]
Hexagon: Paper over the undefined behaviour introduced by r238692

This stops shifting a 32-bit value by such absurd amounts as 96 and
120. We do this by dropping a call to the function that was doing this
entirely, which rather surprisingly doesn't break *any* tests.

I've also added an assert in the misbehaving function to prove that
it's no longer being called with completely invalid arguments.

This change looks pretty bogus and we should probably be reverting
r238692 instead, but this is hard to do with the number of follow ups
that have happened since. It can't be any worse than the undefined
behaviour that was happening before though.

llvm-svn: 240526

9 years agoMILexer.cpp: Try to fix a warning. [-Wsign-compare]
NAKAMURA Takumi [Wed, 24 Jun 2015 06:40:09 +0000 (06:40 +0000)]
MILexer.cpp: Try to fix a warning. [-Wsign-compare]

llvm-svn: 240525

9 years ago[TableGen] Restore the use of the TheInit field in Record to cache the Record's DefIn...
Craig Topper [Wed, 24 Jun 2015 06:19:19 +0000 (06:19 +0000)]
[TableGen] Restore the use of the TheInit field in Record to cache the Record's DefInit. I broke this when I fixed memory leaks recently. Remove the DenseMap that mapped Record's to DefInit.

llvm-svn: 240524

9 years agoDo not treat ARM _MoveToCoprocessor* intrinsics as MSBuiltins.
Bob Wilson [Wed, 24 Jun 2015 06:07:41 +0000 (06:07 +0000)]
Do not treat ARM _MoveToCoprocessor* intrinsics as MSBuiltins.

Those builtins are now handled via ad-hoc code in clang with r240522 to
deal with reordering the arguments to fix PR22560.

llvm-svn: 240523

9 years agoMove the special-case check from r240462 into ARM-specific code.
Bob Wilson [Wed, 24 Jun 2015 06:05:20 +0000 (06:05 +0000)]
Move the special-case check from r240462 into ARM-specific code.

This fixes a serious bug in r240462: checking the BuiltinID for
ARM::BI_MoveToCoprocessor* in EmitBuiltinExpr() ignores the fact that
each target has an overlapping range of the BuiltinID values. That check
can trigger for builtins from other targets, leading to very bad
behavior.

Part of the reason I did not implement r240462 this way to begin with is
the special handling of the last argument for Neon builtins. In this
change, I have factored out the check to see which builtins have that
extra argument into a new HasExtraNeonArgument() function. There is still
some awkwardness in having to check for those builtins in two separate
places, i.e., once to see if the extra argument is present and once to
generate the appropriate IR, but this seems much cleaner than my previous
patch.

llvm-svn: 240522

9 years agoHexagon: Avoid left shifting negative values (it's UB)
Justin Bogner [Wed, 24 Jun 2015 06:00:53 +0000 (06:00 +0000)]
Hexagon: Avoid left shifting negative values (it's UB)

Found by ubsan.

llvm-svn: 240521

9 years agoSystemZ: Rephrase this allOnes calculation to avoid UB
Justin Bogner [Wed, 24 Jun 2015 05:59:19 +0000 (05:59 +0000)]
SystemZ: Rephrase this allOnes calculation to avoid UB

This allOnes function hits undefined behaviour if Count is greater
than 64, but we can avoid that and simplify the calculation by just
saturating if such a value is passed in.

This comes up under ubsan becauseRxSBGOperands is sometimes created
with values that are 128 bits wide. Somebody more familiar with this
code should probably look into whether that's expected, as a 64 bit
mask may or may not be appropriate for such types.

llvm-svn: 240520

9 years agoCOFF: Initial implementation of Identical COMDAT Folding.
Rui Ueyama [Wed, 24 Jun 2015 04:36:52 +0000 (04:36 +0000)]
COFF: Initial implementation of Identical COMDAT Folding.

Identical COMDAT Folding (ICF) is an optimization to reduce binary
size by merging COMDAT sections that contain the same metadata,
actual data and relocations. MSVC link.exe and many other linkers
have this feature. LLD achieves on per with MSVC in terms produced
binary size with this patch.

This technique is pretty effective. For example, LLD's size is
reduced from 64MB to 54MB by enaling this optimization.

The algorithm implemented in this patch is extremely inefficient.
It puts all COMDAT sections into a set to identify duplicates.
Time to self-link with/without ICF are 3.3 and 320 seconds,
respectively. So this option roughly makes LLD 100x slower.
But it's okay as I wanted to achieve correctness first.
LLD is still able to link itself with this optimization.
I'm going to make it more efficient in followup patches.

Note that this optimization is *not* entirely safe. C/C++ require
different functions have different addresses. If your program
relies on that property, your program wouldn't work with ICF.
However, it's not going to be an issue on Windows because MSVC
link.exe turns ICF on by default. As long as your program works
with default settings (or not passing /opt:noicf), your program
would work with LLD too.

llvm-svn: 240519

9 years agoAdd support for srem instruction
Tobias Grosser [Wed, 24 Jun 2015 04:13:29 +0000 (04:13 +0000)]
Add support for srem instruction

Remainder operations with constant divisor can be modeled as quasi-affine
expression. This patch adds support for detecting and modeling them. We also
add a test that ensures they are correctly code generated.

This patch was extracted from a larger patch contributed by Johannes Doerfert
in http://reviews.llvm.org/D5293

llvm-svn: 240518

9 years agoProper changing/restoring for CapturedStmtInfo, NFC.
Alexey Bataev [Wed, 24 Jun 2015 03:35:38 +0000 (03:35 +0000)]
Proper changing/restoring for CapturedStmtInfo, NFC.

Added special RAII class for proper values changing/restoring in CodeGenFunction::CapturedStmtInfo.

llvm-svn: 240517

9 years agoDon't repeat name in comments.
Rafael Espindola [Wed, 24 Jun 2015 03:19:35 +0000 (03:19 +0000)]
Don't repeat name in comments.

llvm-svn: 240516

9 years agoCOFF: Remove unused field SectionChunk::SectionIndex.
Peter Collingbourne [Wed, 24 Jun 2015 00:12:36 +0000 (00:12 +0000)]
COFF: Remove unused field SectionChunk::SectionIndex.

llvm-svn: 240512

9 years agoCOFF: Add some error checking to SymbolTable::addCombinedLTOObject().
Peter Collingbourne [Wed, 24 Jun 2015 00:12:34 +0000 (00:12 +0000)]
COFF: Add some error checking to SymbolTable::addCombinedLTOObject().

llvm-svn: 240511

9 years ago[X86] Don't generate vbroadcasti128 for v4i64 splats from memory.
Ahmed Bougacha [Wed, 24 Jun 2015 00:07:16 +0000 (00:07 +0000)]
[X86] Don't generate vbroadcasti128 for v4i64 splats from memory.

We used to erroneously match:
    (v4i64 shuffle (v2i64 load), <0,0,0,0>)

Whereas vbroadcasti128 is more like:
    (v4i64 shuffle (v2i64 load), <0,1,0,1>)

This problem doesn't exist for vbroadcastf128, which kept matching
the intrinsic after r231182.  We should perhaps re-introduce the
intrinsic here as well, but that's a separate issue still being
discussed.

While there, add some proper vbroadcastf128 tests.  We don't currently
match those, like for loading vbroadcastsd/ss on AVX (the reg-reg
broadcasts where added in AVX2).

Fixes PR23886.

llvm-svn: 240488

9 years agoCOFF: Ignore debug symbols.
Peter Collingbourne [Wed, 24 Jun 2015 00:05:50 +0000 (00:05 +0000)]
COFF: Ignore debug symbols.

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

llvm-svn: 240487

9 years agoRemove unused GlobalVariable::replaceUsesOfWithOnConstant. NFC.
Pete Cooper [Wed, 24 Jun 2015 00:05:07 +0000 (00:05 +0000)]
Remove unused GlobalVariable::replaceUsesOfWithOnConstant.  NFC.

The only caller of this method is Value::replaceAllUsesWith which
explicitly checks that we are not a GlobalValue.  So replace the
body with an unreachable to ensure that we never call it.

The unreachable itself is moved to GlobalValue not GlobalVariable
as that is the base class of all the globals we don't want to call
this method on.

Note, this patch is short lived as i'll soon refactor all callers
of this method.

llvm-svn: 240486

9 years ago[X86] update_llc_test_checks vector-shuffle-*. NFC.
Ahmed Bougacha [Wed, 24 Jun 2015 00:03:48 +0000 (00:03 +0000)]
[X86] update_llc_test_checks vector-shuffle-*. NFC.

Some of them had gone stale.

llvm-svn: 240485

9 years agoCOFF: Add names for logging/debugging to COMDAT chunks.
Rui Ueyama [Wed, 24 Jun 2015 00:00:52 +0000 (00:00 +0000)]
COFF: Add names for logging/debugging to COMDAT chunks.

Chunks are basically unnamed chunks of bytes, and we don't like
to give them names. However, for logging or debugging, we want to
know symbols names of functions for COMDAT chunks. (For example,
we want to print out "we have removed unreferenced COMDAT section
which contains a function FOOBAR.")

This patch is to do that.

llvm-svn: 240484

9 years agoCOFF: Make link order compatible with MSVC link.exe.
Rui Ueyama [Tue, 23 Jun 2015 23:56:39 +0000 (23:56 +0000)]
COFF: Make link order compatible with MSVC link.exe.

Previously, we added files in directive sections to the symbol
table as we read the sections, so the link order was depth-first.
That's not compatible with MSVC link.exe nor the old LLD.

This patch is to queue files so that new files are added to the
end of the queue and processed last. Now addFile() doesn't parse
files nor resolve symbols. You need to call run() to process
queued files.

llvm-svn: 240483

9 years agoMIR Serialization: Serialize immediate machine operands.
Alex Lorenz [Tue, 23 Jun 2015 23:42:28 +0000 (23:42 +0000)]
MIR Serialization: Serialize immediate machine operands.

Reviewers: Duncan P. N. Exon Smith

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

llvm-svn: 240481

9 years agofix typo; NFC
Sanjay Patel [Tue, 23 Jun 2015 23:26:22 +0000 (23:26 +0000)]
fix typo; NFC

llvm-svn: 240480

9 years agoFix test failure if this value doesn't end up named %0.
Richard Smith [Tue, 23 Jun 2015 23:13:31 +0000 (23:13 +0000)]
Fix test failure if this value doesn't end up named %0.

llvm-svn: 240479

9 years agodon't repeat function names in comments; NFC
Sanjay Patel [Tue, 23 Jun 2015 23:05:08 +0000 (23:05 +0000)]
don't repeat function names in comments; NFC

llvm-svn: 240478

9 years agoAdd "-mcpu=" option to llvm-rtdyld
Petar Jovanovic [Tue, 23 Jun 2015 22:52:19 +0000 (22:52 +0000)]
Add "-mcpu=" option to llvm-rtdyld

This patch adds the -mcpu= option to llvm-rtdyld. With this option, one
can test relocations for different types of CPUs (e.g. Mips64r6).

Patch by Vladimir Radosavljevic.

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

llvm-svn: 240477

9 years agoUse range-based loops when handling OPT_print_search_dirs.
Douglas Katzman [Tue, 23 Jun 2015 22:43:50 +0000 (22:43 +0000)]
Use range-based loops when handling OPT_print_search_dirs.

llvm-svn: 240476

9 years agoMIR Parser: Use correct source locations for machine instruction diagnostics.
Alex Lorenz [Tue, 23 Jun 2015 22:39:23 +0000 (22:39 +0000)]
MIR Parser: Use correct source locations for machine instruction diagnostics.

This commit translates the source locations for MIParser diagnostics from
the locations in the machine instruction string to the locations in the
MIR file.

Reviewers: Duncan P. N. Exon Smith

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

llvm-svn: 240474

9 years agoUpdate SafeStack TODO in the safestack.cc
Peter Collingbourne [Tue, 23 Jun 2015 22:26:48 +0000 (22:26 +0000)]
Update SafeStack TODO in the safestack.cc

This patch clarifies the TODO note at the top of safestack.cc and brings
it more in sync with what we (the CPI team) actually plan to work on in
the future.

Patch by Volodymyr Kuznetsov!

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

llvm-svn: 240473

9 years agoSafeStack documentation improvements
Peter Collingbourne [Tue, 23 Jun 2015 22:24:45 +0000 (22:24 +0000)]
SafeStack documentation improvements

This patch makes the following improvements to the SafeStack documentation:

Explicitly states the security guarantees of the SafeStack
Clarifies which of the security guarantees are probabilistic
Re-orders security limitations to put the most severe ones first
Explains how `__attribute__((no_sanitize("safe-stack")))` works and how to use it safely
Explains that SafeStack should be combined with a forward-edge protection mechanism, such as CPI, IFCC or others
Multiple readability and stylistic improvements

Patch by Volodymyr Kuznetsov!

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

llvm-svn: 240472

9 years agoDevirtualize Constant::destroyConstant.
Pete Cooper [Tue, 23 Jun 2015 21:55:11 +0000 (21:55 +0000)]
Devirtualize Constant::destroyConstant.

This reorganizes destroyConstant and destroyConstantImpl.

Now there is only destroyConstant in Constant itself, while
subclasses are required to implement destroyConstantImpl.

destroyConstantImpl no longer calls delete but is instead only
responsible for removing the constant from any maps in which it
is contained.

Reviewed by Duncan Exon Smith.

llvm-svn: 240471

9 years agoWorking on reconciling out-of-tree patches to compiler-rt for building for iOS.
Chris Bieneman [Tue, 23 Jun 2015 21:39:57 +0000 (21:39 +0000)]
Working on reconciling out-of-tree patches to compiler-rt for building for iOS.

Summary:
This is one of many changes needed for compiler-rt to get it building on iOS.

Darwin doesn't have _Unwind_VRS_Get, instead use _Unwind_GetIP directly.

Note: this change does not enable building for iOS, as there are more changes to come.

Reviewers: kubabrecka, bogner, samsonov

Reviewed By: samsonov

Subscribers: samsonov, llvm-commits

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

llvm-svn: 240470

9 years agoWorking on reconciling out-of-tree patches to compiler-rt for building for iOS.
Chris Bieneman [Tue, 23 Jun 2015 21:39:54 +0000 (21:39 +0000)]
Working on reconciling out-of-tree patches to compiler-rt for building for iOS.

Summary:
This is one of many changes needed for compiler-rt to get it building on iOS.

This change ifdefs out headers and functionality that aren't available on iOS, and adds support for iOS and the iOS simulator to as an.

Note: this change does not enable building for iOS, as there are more changes to come.

Reviewers: glider, kubabrecka, bogner, samsonov

Reviewed By: samsonov

Subscribers: samsonov, zaks.anna, llvm-commits

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

llvm-svn: 240469

9 years agoWorking on reconciling out-of-tree patches to compiler-rt for building for iOS.
Chris Bieneman [Tue, 23 Jun 2015 21:39:52 +0000 (21:39 +0000)]
Working on reconciling out-of-tree patches to compiler-rt for building for iOS.

Summary:
This is one of many changes needed for compiler-rt to get it building on iOS.

This change ifdefs out headers and functionality that aren't available on iOS.

Note: this change does not enable building for iOS, as there are more changes to come.

Reviewers: glider, kubabrecka, bogner, samsonov

Reviewed By: samsonov

Subscribers: samsonov, llvm-commits

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

llvm-svn: 240468

9 years agoWorking on reconciling out-of-tree patches to compiler-rt for building for iOS.
Chris Bieneman [Tue, 23 Jun 2015 21:39:49 +0000 (21:39 +0000)]
Working on reconciling out-of-tree patches to compiler-rt for building for iOS.

Summary:
This is one of many changes needed for compiler-rt to get it building on iOS.

This change does the following:
- Don't include crt_externs on iOS (it isn't available)
- Support ARM thread state objects

Note: this change does not enable building for iOS, as there are more changes to come.

Reviewers: glider, kubabrecka, bogner, samsonov

Reviewed By: samsonov

Subscribers: samsonov, aemerson, llvm-commits

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

llvm-svn: 240467

9 years agoImplement the "qSymbol" packet in order to be able to read queue information in debug...
Greg Clayton [Tue, 23 Jun 2015 21:27:50 +0000 (21:27 +0000)]
Implement the "qSymbol" packet in order to be able to read queue information in debugserver and return the info in the stop reply packets.

A "qSymbol::" is sent when shared libraries have been loaded by hooking into the Process::ModulesDidLoad() function from within ProcessGDBRemote. This function was made virtual so that the ProcessGDBRemote version is called, which then first calls the Process::ModulesDidLoad(), and then it queries for any symbol lookups that the remote GDB server might want to do.

This allows debugserver to request the "dispatch_queue_offsets" symbol so that it can read the queue name, queue kind and queue serial number and include this data as part of the stop reply packet. Previously each thread would have to do 3 memory reads in order to read the queue name.

This is part of reducing the number of packets that are sent between LLDB and the remote GDB server.

<rdar://problem/21494354>

llvm-svn: 240466

9 years ago[X86][SSE] Added full set of 128-bit vector shift tests.
Simon Pilgrim [Tue, 23 Jun 2015 21:18:15 +0000 (21:18 +0000)]
[X86][SSE] Added full set of 128-bit vector shift tests.

Removed some old duplicate tests.

llvm-svn: 240465

9 years ago[Driver] Give GnuTool LLVM_LIBRARY_VISIBILITY.
Benjamin Kramer [Tue, 23 Jun 2015 21:15:15 +0000 (21:15 +0000)]
[Driver] Give GnuTool LLVM_LIBRARY_VISIBILITY.

This is consistent with all other classes in Tools.h.

llvm-svn: 240464

9 years agoImprove error handling for PR22560.
Bob Wilson [Tue, 23 Jun 2015 21:10:24 +0000 (21:10 +0000)]
Improve error handling for PR22560.

The ARM _MoveToCoprocessor and _MoveFromCoprocessor builtins require
integer constants for most arguments, but clang was not checking that.
With this change, we now report meaningful errors instead of crashing
in the backend.

llvm-svn: 240463

9 years agoPR22560: Fix argument order for ARM _MoveToCoprocessor builtins.
Bob Wilson [Tue, 23 Jun 2015 21:10:15 +0000 (21:10 +0000)]
PR22560: Fix argument order for ARM _MoveToCoprocessor builtins.

The Microsoft-extension _MoveToCoprocessor and _MoveToCoprocessor2
builtins take the register value to be moved as the first argument,
but the corresponding mcr and mcr2 LLVM intrinsics expect that value
to be the third argument. Handle this as a special case, while still
leaving those intrinsics as generic MSBuiltins. I considered the
alternative of handling these in EmitARMBuiltinExpr, but that does
not work well for the follow-up change that I'm going to make to improve
the error handling for PR22560 -- we need the GetBuiltinType() checks
for ICEArguments, and the ARM version of that code is only used for
Neon intrinsics where the last argument is special and not
checked in the normal way.

llvm-svn: 240462

9 years agoFix the handling of the run lock in cases where you needed to run
Jim Ingham [Tue, 23 Jun 2015 21:02:45 +0000 (21:02 +0000)]
Fix the handling of the run lock in cases where you needed to run
a hand-called function from the private state thread.  The problem
was that on the way out of the private state thread, we try to drop
the run lock.  That is appropriate for the main private state thread,
but not the secondary private state thread.  Only the thread that
spawned them can know whether this is an appropriate thing to do or
not.

<rdar://problem/21375352>

llvm-svn: 240461

9 years agoLet llvm::ReplaceInstWithInst copy debug location from old to new instruction.
Alexey Samsonov [Tue, 23 Jun 2015 21:00:08 +0000 (21:00 +0000)]
Let llvm::ReplaceInstWithInst copy debug location from old to new instruction.

Currently some users of this function do this explicitly, and all the
rest forget to do this.

ThreadSanitizer was one of such users, and had missing debug
locations for calls into TSan runtime handling atomic operations,
eventually leading to poorly symbolized stack traces and malfunctioning
suppressions.

This is another change relevant to PR23837.

llvm-svn: 240460

9 years agoPass 2 more variables to lit tests.
Evgeniy Stepanov [Tue, 23 Jun 2015 20:57:26 +0000 (20:57 +0000)]
Pass 2 more variables to lit tests.

Pass ADB and ADB_SERIAL environment variables to lit tests.
This would allow running Android tests in compiler-rt when
there is more than one device attached to the host.

llvm-svn: 240459

9 years agoReplace srem by function call in nonaffine test cases
Tobias Grosser [Tue, 23 Jun 2015 20:55:05 +0000 (20:55 +0000)]
Replace srem by function call in nonaffine test cases

This makes the test cases nonaffine even if Polly some days gains support for
the srem instruction, an instruction which is currently not modeled but which
can clearly be modeled statically. A call to a function without definition
will always remain non-affine, as there is just insufficient static information
for it to be modeled more precisely.

llvm-svn: 240458

9 years agoAdd git patch files to .gitignore
Tobias Grosser [Tue, 23 Jun 2015 20:55:01 +0000 (20:55 +0000)]
Add git patch files to .gitignore

llvm-svn: 240457

9 years agoMark a couple of features as 'in progress'
Marshall Clow [Tue, 23 Jun 2015 20:48:55 +0000 (20:48 +0000)]
Mark a couple of features as 'in progress'

llvm-svn: 240456

9 years agoPedantically rename all Tool subclasses to be nouns, not verbs. NFC
Douglas Katzman [Tue, 23 Jun 2015 20:42:09 +0000 (20:42 +0000)]
Pedantically rename all Tool subclasses to be nouns, not verbs. NFC

Classes in Tools.h inherit ultimately from Tool, which is a noun,
but subclasses of Tool were named for their operation, such as "Compile",
wherein the constructor call "Compile(args...)" could be misconstrued
as actually causing a compile to happen.

Likewise various other methods were not harmonious with their effect,
in that "BuildLinker()" returned a "new namespace::Link(...)"
instead of a "new namespace::Linker(...)" which it now does.

Exceptions: Clang and ClangAs are un-renamed. Those are their rightful names.
And there is no particulary great way to name the "Lipo-er" and a few others.

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

llvm-svn: 240455

9 years ago[lld] Add MachO thread-local storage support.
Lang Hames [Tue, 23 Jun 2015 20:35:31 +0000 (20:35 +0000)]
[lld] Add MachO thread-local storage support.

This allows LLD to correctly link MachO objects that use thread-local storage.

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

llvm-svn: 240454

9 years ago[MS ABI] Account for the virtual inheritance quirk when mangling
David Majnemer [Tue, 23 Jun 2015 20:34:18 +0000 (20:34 +0000)]
[MS ABI] Account for the virtual inheritance quirk when mangling

Virtual inheritance member pointers are always relative to the vbindex,
even when the member pointer doesn't point into a virtual base.  This is
corrected by adjusting the non-virtual offset backwards from the vbptr
back to the top of the most derived class.  While we performed this
adjustment when manifesting member pointers as constants or when
performing conversions, we didn't perform the adjustment when mangling
them.

llvm-svn: 240453

9 years agoInstrProf: Fix a crash when an implicit def appears in a macro
Justin Bogner [Tue, 23 Jun 2015 20:29:09 +0000 (20:29 +0000)]
InstrProf: Fix a crash when an implicit def appears in a macro

llvm-svn: 240452

9 years agoRemove a few uses of lldb.target, which is not valid
Jim Ingham [Tue, 23 Jun 2015 20:26:45 +0000 (20:26 +0000)]
Remove a few uses of lldb.target, which is not valid
in a scripted command.

llvm-svn: 240451

9 years agoFix incorrect truncation at the overflow boundary
Pirama Arumuga Nainar [Tue, 23 Jun 2015 20:24:53 +0000 (20:24 +0000)]
Fix incorrect truncation at the overflow boundary

Summary:
This patch fixes incorrect truncation when the input wider value is
exactly 2^dstBits.  For that value, the overflow to infinity is not
correctly handled.  The fix is to replace a strict '>' with '>='.

Currently,
__truncdfsf2(340282366900000000000000000000000000000.0) returns infinity
__truncdfsf2(340282366920938463463374607431768211456.0) returns 0
__truncdfsf2(400000000000000000000000000000000000000.0) returns infinity

Likewise, __truncdfhf2 and __truncsfhf2 (and consequently gnu_f2h_ieee)
are discontinuous at 65536.0.

This patch adds tests for all three cases, along with adding a missing
header include to fp_test.h.

Reviewers: joerg, ab, srhines

Subscribers: llvm-commits

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

llvm-svn: 240450

9 years ago[msan] Mark one test as only supported on x86
Jay Foad [Tue, 23 Jun 2015 20:17:45 +0000 (20:17 +0000)]
[msan] Mark one test as only supported on x86

Summary: This test uses x86 intrinsics, so it can't work on other platforms.

Reviewers: garious, eugenis, samsonov

Reviewed By: samsonov

Subscribers: llvm-commits

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

llvm-svn: 240449

9 years agoRevert "[FaultMaps] Move FaultMapParser to Object/"
Sanjoy Das [Tue, 23 Jun 2015 20:09:03 +0000 (20:09 +0000)]
Revert "[FaultMaps] Move FaultMapParser to Object/"

This reverts commit r240364 (git c49542e5bb186).  The issue r240364 was
trying to fix was fixed independently in r240362.

llvm-svn: 240448

9 years agoCOFF: Fix null pointer dereference.
Peter Collingbourne [Tue, 23 Jun 2015 20:02:31 +0000 (20:02 +0000)]
COFF: Fix null pointer dereference.

llvm-svn: 240447

9 years ago[MachO] Initialize all fields of NormalizedFile.
Benjamin Kramer [Tue, 23 Jun 2015 19:55:04 +0000 (19:55 +0000)]
[MachO] Initialize all fields of NormalizedFile.

The ObjectFileYAML.roundTrip serializes a default-constructed
NormalizedFile to YAML, triggering uninitialized memory reads.

While there use in-class member initializers.

llvm-svn: 240446

9 years agoAdd missing dependencies for the CMake shared lld build.
Benjamin Kramer [Tue, 23 Jun 2015 19:54:57 +0000 (19:54 +0000)]
Add missing dependencies for the CMake shared lld build.

llvm-svn: 240445

9 years agoFix FIXME comments in MiBreakTestCase.test_lldbmi_break_insert_settings as suggested...
Dawn Perchik [Tue, 23 Jun 2015 19:21:44 +0000 (19:21 +0000)]
Fix FIXME comments in MiBreakTestCase.test_lldbmi_break_insert_settings as suggested by abidh (MI)

llvm-svn: 240444

9 years agoMake the typo resolution in r240441 apply to all function calls.
Kaelyn Takata [Tue, 23 Jun 2015 19:13:17 +0000 (19:13 +0000)]
Make the typo resolution in r240441 apply to all function calls.

Regular function calls (such as to cabs()) run into the same problem
with handling dependent exprs, not just builtins with custom type
checking.

Fixes PR23775.

llvm-svn: 240443