platform/upstream/llvm.git
9 years agoDetect Intel MIC architecture and set some defaults at run time instead of build...
Andrey Churbanov [Fri, 20 Feb 2015 18:14:43 +0000 (18:14 +0000)]
Detect Intel MIC architecture and set some defaults at run time instead of build time.

llvm-svn: 230033

9 years agoRemoved unused varargs from __kmpc_flush function.
Andrey Churbanov [Fri, 20 Feb 2015 18:09:27 +0000 (18:09 +0000)]
Removed unused varargs from __kmpc_flush function.

llvm-svn: 230032

9 years agoAdd -funique-section-names and -fno-unique-section-names options.
Rafael Espindola [Fri, 20 Feb 2015 18:08:57 +0000 (18:08 +0000)]
Add -funique-section-names and -fno-unique-section-names options.

For now -funique-section-names is the default, so no change in default behavior.

The total .o size in a build of llvm and clang goes from 241687775 to 230649031
bytes if -fno-unique-section-names is used.

llvm-svn: 230031

9 years agoAdded new user-guided lock api, currently disabled. Use KMP_USE_DYNAMIC_LOCK=1 to...
Andrey Churbanov [Fri, 20 Feb 2015 18:05:17 +0000 (18:05 +0000)]
Added new user-guided lock api, currently disabled. Use KMP_USE_DYNAMIC_LOCK=1 to enable it.

llvm-svn: 230030

9 years agoChanged default stack offset for threads on non-Mac architectures to a CACHE_LINE.
Andrey Churbanov [Fri, 20 Feb 2015 17:57:58 +0000 (17:57 +0000)]
Changed default stack offset for threads on non-Mac architectures to a CACHE_LINE.

llvm-svn: 230029

9 years agoMinor changes after r229901: move the CMICmdCmdStackSelectFrame to the end of header...
Ilia K [Fri, 20 Feb 2015 17:56:05 +0000 (17:56 +0000)]
Minor changes after r229901: move the CMICmdCmdStackSelectFrame to the end of header file

llvm-svn: 230028

9 years agoAdded some compiler flags for security on Linux and Mac link stages.
Andrey Churbanov [Fri, 20 Feb 2015 17:55:48 +0000 (17:55 +0000)]
Added some compiler flags for security on Linux and Mac link stages.

llvm-svn: 230027

9 years ago[Sanitizer] Refactor SuppressionContext class.
Alexey Samsonov [Fri, 20 Feb 2015 17:41:59 +0000 (17:41 +0000)]
[Sanitizer] Refactor SuppressionContext class.

SuppressionContext is no longer a singleton, shared by all sanitizers,
but a regular class. Each of ASan, LSan, UBSan and TSan now have their
own SuppressionContext, which only parses suppressions specific to
that sanitizer.

"suppressions" flag is moved away from common flags into tool-specific
flags, so the user now may pass
  ASAN_OPTIONS=suppressions=asan_supp.txt LSAN_OPIONS=suppressions=lsan_supp.txt
in a single invocation.

llvm-svn: 230026

9 years agoForgot to remove initialization of MiTestCaseBase.mydir in r230022
Ilia K [Fri, 20 Feb 2015 17:21:57 +0000 (17:21 +0000)]
Forgot to remove initialization of MiTestCaseBase.mydir in r230022

llvm-svn: 230025

9 years agocanonicalize a v2f64 blendi of 2 registers
Sanjay Patel [Fri, 20 Feb 2015 16:55:27 +0000 (16:55 +0000)]
canonicalize a v2f64 blendi of 2 registers

This canonicalization step saves us 3 pattern matching possibilities * 4 math ops
for scalar FP math that uses xmm regs. The backend can re-commute the operands
post-instruction-selection if that makes register allocation better.

The tests in llvm/test/CodeGen/X86/sse-scalar-fp-arith.ll cover this scenario already,
so there are no new tests with this patch.

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

llvm-svn: 230024

9 years agoPut MSVC back into the dumb compiler's corner.
Benjamin Kramer [Fri, 20 Feb 2015 16:35:42 +0000 (16:35 +0000)]
Put MSVC back into the dumb compiler's corner.

It fails to compile std::trivially_copyable for forward-declared enums.

llvm-svn: 230023

9 years agoRefactor lldb-mi tests
Ilia K [Fri, 20 Feb 2015 16:34:33 +0000 (16:34 +0000)]
Refactor lldb-mi tests

Summary:
This patch includes following changes:
* split lldb-mi tests into separate folders. It will make our life simpler because we can modify a test program of certain test and don't worry about other tests
* a bit refactoring
* fix comments
* improve some tests

Reviewers: emaste, clayborg, abidh

Reviewed By: clayborg, abidh

Subscribers: clayborg, lldb-commits, emaste, abidh

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

llvm-svn: 230022

9 years agoBase isPodLike on is_trivially_copyable for GCC 5 and MSVC
Benjamin Kramer [Fri, 20 Feb 2015 16:19:28 +0000 (16:19 +0000)]
Base isPodLike on is_trivially_copyable for GCC 5 and MSVC

It would be nice to get rid of the version checks here, but that will
have to wait until libstdc++ is upgraded to 5.0 everywhere ...

llvm-svn: 230021

9 years agoI incorrectly marked the VORC instruction as isCommutable when I added it.
Kit Barton [Fri, 20 Feb 2015 15:54:58 +0000 (15:54 +0000)]
I incorrectly marked the VORC instruction as isCommutable when I added it.
This fix removes the VORC instruction definition from the isCommutable block.

Phabricator review: http://reviews.llvm.org/D7772

llvm-svn: 230020

9 years ago[ASan] Make the argument of '__sanitizer_annotate_contiguous_container' is not aligne...
Timur Iskhodzhanov [Fri, 20 Feb 2015 15:45:51 +0000 (15:45 +0000)]
[ASan] Make the argument of '__sanitizer_annotate_contiguous_container' is not aligned error message easier to understand

llvm-svn: 230019

9 years ago[ASan/Win] Work around PR22545 - unregister globals when using the MD runtime
Timur Iskhodzhanov [Fri, 20 Feb 2015 15:34:16 +0000 (15:34 +0000)]
[ASan/Win] Work around PR22545 - unregister globals when using the MD runtime

llvm-svn: 230018

9 years agoGeneralize statepoint lowering to use ImmutableStatepoint. Move statepoint lowering...
Igor Laevsky [Fri, 20 Feb 2015 15:28:35 +0000 (15:28 +0000)]
Generalize statepoint lowering to use ImmutableStatepoint. Move statepoint lowering into a separate function 'LowerStatepoint' which uses ImmutableStatepoint instead of a CallInst. Also related utility functions are changed to receive ImmutableCallSite.

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

llvm-svn: 230017

9 years agoConstants.cpp: Only read 32 bits for float.
Benjamin Kramer [Fri, 20 Feb 2015 15:11:55 +0000 (15:11 +0000)]
Constants.cpp: Only read 32 bits for float.

Otherwise we'll discard the wrong half of a uint64_t on big-endian systems.

llvm-svn: 230016

9 years agoRemove redundant "explicit".
Rui Ueyama [Fri, 20 Feb 2015 14:57:04 +0000 (14:57 +0000)]
Remove redundant "explicit".

llvm-svn: 230015

9 years agoDeleted module-map-checker, as it's been folded into modularize.
John Thompson [Fri, 20 Feb 2015 14:28:10 +0000 (14:28 +0000)]
Deleted module-map-checker, as it's been folded into modularize.

llvm-svn: 230014

9 years agoConstants.cpp: getElementAsAPFloat(): Don't handle constant value via host's float...
NAKAMURA Takumi [Fri, 20 Feb 2015 14:24:49 +0000 (14:24 +0000)]
Constants.cpp: getElementAsAPFloat(): Don't handle constant value via host's float/double, just handle with APInt/APFloat.

x87 FPU didn't keep SNAN, but demoted to QNAN.

llvm-svn: 230013

9 years agoRewriteStatepointsForGC: Move details into anonymous namespaces. NFC.
Benjamin Kramer [Fri, 20 Feb 2015 14:00:58 +0000 (14:00 +0000)]
RewriteStatepointsForGC: Move details into anonymous namespaces. NFC.

While there reduce the number of duplicated std::map lookups.

llvm-svn: 230012

9 years agoclang-format: [js] Support template strings.
Daniel Jasper [Fri, 20 Feb 2015 13:47:38 +0000 (13:47 +0000)]
clang-format: [js] Support template strings.

Merge template strings (marked by backticks ``).
Do not format any contents of template strings.

Patch by Martin Probst. Thank you.

llvm-svn: 230011

9 years agoMake the static instance of None just const.
Benjamin Kramer [Fri, 20 Feb 2015 13:16:05 +0000 (13:16 +0000)]
Make the static instance of None just const.

This way there shouldn't be any unused variable warnings.

llvm-svn: 230010

9 years agoWrap recursive function only used in assert in #ifndef NDEBUG.
Benjamin Kramer [Fri, 20 Feb 2015 13:15:49 +0000 (13:15 +0000)]
Wrap recursive function only used in assert in #ifndef NDEBUG.

Avoids unused function warnings in Release builds.

llvm-svn: 230009

9 years agoAdd -symbol-list-lines command (MI)
Ilia K [Fri, 20 Feb 2015 13:07:41 +0000 (13:07 +0000)]
Add -symbol-list-lines command (MI)

Summary:
Add -symbol-list-lines command + test.

All test passed on OS X.

Reviewers: emaste, abidh, clayborg

Reviewed By: clayborg

Subscribers: lldb-commits, clayborg, abidh, emaste

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

llvm-svn: 230008

9 years ago[Mach-O] Remove redundant allocator
Jean-Daniel Dupas [Fri, 20 Feb 2015 11:57:06 +0000 (11:57 +0000)]
[Mach-O] Remove redundant allocator

llvm-svn: 230007

9 years agoAdd -fno-implicit-modules.
Manuel Klimek [Fri, 20 Feb 2015 11:44:41 +0000 (11:44 +0000)]
Add -fno-implicit-modules.

If this flag is set, we error out when a module build is required. This is
useful in environments where all required modules are passed via -fmodule-file.

llvm-svn: 230006

9 years agoRefactor OptionValue::SetValueFromCString to use llvm::StringRef
Pavel Labath [Fri, 20 Feb 2015 11:14:59 +0000 (11:14 +0000)]
Refactor OptionValue::SetValueFromCString to use llvm::StringRef

Reviewers: clayborg

Subscribers: lldb-commits

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

llvm-svn: 230005

9 years ago[x86] Switching the shuffle equivalence test to a variadic template was
Chandler Carruth [Fri, 20 Feb 2015 10:47:28 +0000 (10:47 +0000)]
[x86] Switching the shuffle equivalence test to a variadic template was
the wrong answer. We also got initializer lists which are *way* cleaner
for this kind of thing. Let's use those and make this a normal, boring
functionn accepting ArrayRef.

llvm-svn: 230004

9 years agoReduce number of threads in lldb-mi.
Hafiz Abid Qadeer [Fri, 20 Feb 2015 10:20:05 +0000 (10:20 +0000)]
Reduce number of threads in lldb-mi.

LLDB-mi have 3 threads.

1. Wait for input.
2. Process commands.
3. Process events.
This revision merges 1 & 2. Same thread waits on input and then process the
command. This way, no synchronization is needed between first and 2nd. Also it is
easy to check when to exit.

A lot of code will redundant and will be cleaned up gradually.

All lldb-mi tests pass with gcc and clang as test compiler. Also did minimal testing
on command line and works ok. The "quit" and "-gdb-exit" command close the application
without needing any further return.

Reviewed in http://reviews.llvm.org/D7746.

llvm-svn: 230003

9 years ago[TSan][MIPS64] Fix few more test cases for MIPS64
Mohit K. Bhakkad [Fri, 20 Feb 2015 09:32:45 +0000 (09:32 +0000)]
[TSan][MIPS64] Fix few more test cases for MIPS64
Patch by Sagar Thakur

Reviewers: dvyukov, samsonov, kcc.

Subscribers:  dsanders, mohit.bhakkad, Anand.Takale, llvm-commits.

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

llvm-svn: 230002

9 years agoFix wording and grammar in Mips subtarget options.
Eric Christopher [Fri, 20 Feb 2015 08:42:34 +0000 (08:42 +0000)]
Fix wording and grammar in Mips subtarget options.

llvm-svn: 230001

9 years agoGet the cached subtarget off the MachineFunction rather than
Eric Christopher [Fri, 20 Feb 2015 08:39:06 +0000 (08:39 +0000)]
Get the cached subtarget off the MachineFunction rather than
inquiring for a new one from the TargetMachine.

llvm-svn: 230000

9 years agoGet the cached subtarget off the MachineFunction rather than
Eric Christopher [Fri, 20 Feb 2015 08:24:37 +0000 (08:24 +0000)]
Get the cached subtarget off the MachineFunction rather than
inquiring for a new one from the TargetMachine.

llvm-svn: 229999

9 years agoGet the cached subtarget off the MachineFunction rather than
Eric Christopher [Fri, 20 Feb 2015 08:24:34 +0000 (08:24 +0000)]
Get the cached subtarget off the MachineFunction rather than
inquiring for a new one from the TargetMachine.

llvm-svn: 229998

9 years agoDriver: Fix an incorrect use of llvm::None
Justin Bogner [Fri, 20 Feb 2015 08:19:43 +0000 (08:19 +0000)]
Driver: Fix an incorrect use of llvm::None

This function returns a bool, so llvm::None doesn't make sense here.

llvm-svn: 229997

9 years agoSave the MachineFunction in startFunction so that we can use it for
Eric Christopher [Fri, 20 Feb 2015 08:01:55 +0000 (08:01 +0000)]
Save the MachineFunction in startFunction so that we can use it for
lookups of the subtarget later.

llvm-svn: 229996

9 years agoUse the cached subtarget from the MachineFunction rather than
Eric Christopher [Fri, 20 Feb 2015 08:01:52 +0000 (08:01 +0000)]
Use the cached subtarget from the MachineFunction rather than
doing a lookup on the TargetMachine.

llvm-svn: 229995

9 years agoMake the TargetMachine::getSubtarget that takes a Function argument
Eric Christopher [Fri, 20 Feb 2015 07:32:59 +0000 (07:32 +0000)]
Make the TargetMachine::getSubtarget that takes a Function argument
take a reference to match the getSubtargetImpl that takes a Function
argument.

llvm-svn: 229994

9 years agoDisallow implicit conversions from None to integer types
Justin Bogner [Fri, 20 Feb 2015 07:28:28 +0000 (07:28 +0000)]
Disallow implicit conversions from None to integer types

This fixes an error introduced in r228934 where None was converted to
an int instead of the int being converted to an Optional as intended.
We make that sort of mistake a compile error by changing NoneType into
a scoped enum.

Finally, provide a static NoneType called None to avoid forcing all
users to spell it NoneType::None.

llvm-svn: 229980

9 years agoFix build with gcc. This has a -Wsequence-point error on 'MII', which is a good point.
Nick Lewycky [Fri, 20 Feb 2015 07:17:40 +0000 (07:17 +0000)]
Fix build with gcc. This has a -Wsequence-point error on 'MII', which is a good point.

llvm-svn: 229979

9 years agoRemove more uses of TargetMachine::getSubtargetImpl from the
Eric Christopher [Fri, 20 Feb 2015 07:16:19 +0000 (07:16 +0000)]
Remove more uses of TargetMachine::getSubtargetImpl from the
AsmPrinter.

getSubtargetInfo now asserts that the MachineFunction exists.
Debug printing of register naming now uses the register info
from MCAsmInfo as that's unchanging.

llvm-svn: 229978

9 years agoFix build in release mode, -Wunused-variable on this lambda function used only in...
Nick Lewycky [Fri, 20 Feb 2015 07:16:17 +0000 (07:16 +0000)]
Fix build in release mode, -Wunused-variable on this lambda function used only in an assert.

llvm-svn: 229977

9 years agoFix build in release mode, four cases of -Wunused-variable.
Nick Lewycky [Fri, 20 Feb 2015 07:14:02 +0000 (07:14 +0000)]
Fix build in release mode, four cases of -Wunused-variable.

llvm-svn: 229976

9 years agoRemove carriage returns.
Nick Lewycky [Fri, 20 Feb 2015 07:05:56 +0000 (07:05 +0000)]
Remove carriage returns.

llvm-svn: 229975

9 years agoAsmPrinter::doFinalization is at the module level and so doesn't
Eric Christopher [Fri, 20 Feb 2015 06:59:48 +0000 (06:59 +0000)]
AsmPrinter::doFinalization is at the module level and so doesn't
have access to a target specific subtarget info. Grab the module
level MCSubtargetInfo for the JumpInstrTable output stubs.

llvm-svn: 229974

9 years ago[Orc] Add a new JITSymbol constructor to build a symbol from an existing address.
Lang Hames [Fri, 20 Feb 2015 06:48:29 +0000 (06:48 +0000)]
[Orc] Add a new JITSymbol constructor to build a symbol from an existing address.

This constructor is more efficient for symbols that have already been emitted,
since it avoids the construction/execution of a std::function.

Update the ObjectLinkingLayer to use this new constructor where possible.

llvm-svn: 229973

9 years ago[TSan][MIPS] Adding support for MIPS64
Mohit K. Bhakkad [Fri, 20 Feb 2015 06:42:41 +0000 (06:42 +0000)]
[TSan][MIPS] Adding support for MIPS64
Patch by Sagar Thakur

Reviewers: dvyukov, samsonov, petarj, kcc, dsanders.

Subscribers:  mohit.bhakkad, Anand.Takale, llvm-commits.

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

llvm-svn: 229972

9 years agoRemove the MCInstrInfo cached variable as it was only used in a
Eric Christopher [Fri, 20 Feb 2015 06:35:21 +0000 (06:35 +0000)]
Remove the MCInstrInfo cached variable as it was only used in a
single place and replace calls to getSubtargetImpl with calls
to get the subtarget from the MachineFunction where valid.

llvm-svn: 229971

9 years agoFix -Wunused-variable warning in non-asserts build, and optimize a little bit while...
David Blaikie [Fri, 20 Feb 2015 06:28:38 +0000 (06:28 +0000)]
Fix -Wunused-variable warning in non-asserts build, and optimize a little bit while I'm here.

llvm-svn: 229970

9 years agoAdd self to CREDITS.TXT
Larisse Voufo [Fri, 20 Feb 2015 06:17:20 +0000 (06:17 +0000)]
Add self to CREDITS.TXT

llvm-svn: 229969

9 years agoMore on adding sized deallocation functions in libc++: Continuing from r229281, this...
Larisse Voufo [Fri, 20 Feb 2015 06:13:05 +0000 (06:13 +0000)]
More on adding sized deallocation functions in libc++: Continuing from r229281, this adds version guards and test cases.

llvm-svn: 229968

9 years agoLinkerScript: Remove leaks in the parser
David Majnemer [Fri, 20 Feb 2015 05:10:06 +0000 (05:10 +0000)]
LinkerScript: Remove leaks in the parser

LinkerScript AST nodes are never destroyed which means that their
std::vector members will never be destroyed.

Instead, allocate the operand list itself in the Parser's
BumpPtrAllocator.  This ensures that the storage will be destroyed along
with the nodes when the Parser is destroyed.

llvm-svn: 229967

9 years ago[PowerPC] Loop Data Prefetching for the BG/Q
Hal Finkel [Fri, 20 Feb 2015 05:08:21 +0000 (05:08 +0000)]
[PowerPC] Loop Data Prefetching for the BG/Q

The IBM BG/Q supercomputer's A2 cores have a hardware prefetching unit, the
L1P, but it does not prefetch directly into the A2's L1 cache. Instead, it
prefetches into its own L1P buffer, and the latency to access that buffer is
significantly higher than that to the L1 cache (although smaller than the
latency to the L2 cache). As a result, especially when multiple hardware
threads are not actively busy, explicitly prefetching data into the L1 cache is
advantageous.

I've been using this pass out-of-tree for data prefetching on the BG/Q for well
over a year, and it has worked quite well. It is enabled by default only for
the BG/Q, but can be enabled for other cores as well via a command-line option.

Eventually, we might want to add some TTI interfaces and move this into
Transforms/Scalar (there is nothing particularly target dependent about it,
although only machines like the BG/Q will benefit from its simplistic
strategy).

llvm-svn: 229966

9 years agoPR22435: Correctly implement tiebreaker for reference ordering in function
Richard Smith [Fri, 20 Feb 2015 04:45:22 +0000 (04:45 +0000)]
PR22435: Correctly implement tiebreaker for reference ordering in function
template partial ordering rules. This rule applies per pair of types being
compared, not per pair of function templates being compared.

llvm-svn: 229965

9 years ago[x86] Remove the old vector shuffle lowering code and its flag.
Chandler Carruth [Fri, 20 Feb 2015 04:25:04 +0000 (04:25 +0000)]
[x86] Remove the old vector shuffle lowering code and its flag.

The new shuffle lowering has been the default for some time. I've
enabled the new legality testing by default with no really blocking
regressions. I've fuzz tested this very heavily (many millions of fuzz
test cases have passed at this point). And this cleans up a ton of code.
=]

Thanks again to the many folks that helped with this transition. There
was a lot of work by others that went into the new shuffle lowering to
make it really excellent.

In case you aren't using a diff algorithm that can handle this:
  X86ISelLowering.cpp: 22 insertions(+), 2940 deletions(-)

llvm-svn: 229964

9 years ago[x86] Now that the new vector shuffle legality is enabled and everything
Chandler Carruth [Fri, 20 Feb 2015 03:59:35 +0000 (03:59 +0000)]
[x86] Now that the new vector shuffle legality is enabled and everything
is going well, remove the flag and the code for the old legality tests.

This is the first step toward removing the entire old vector shuffle
lowering. *Much* more code to delete coming up next.

llvm-svn: 229963

9 years agoMake FileCheck be a common dependency, not an ASan one.
Filipe Cabecinhas [Fri, 20 Feb 2015 03:41:07 +0000 (03:41 +0000)]
Make FileCheck be a common dependency, not an ASan one.

Summary:
It still gets picked up by ASan, but it also gets picked up by the other
test suites.

Otherwise, some test suites (e.g: UBSan) would complain they had no
dependencies, and wouldn't run.

Reviewers: samsonov, eugenis

Subscribers: llvm-commits

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

llvm-svn: 229962

9 years agoPECOFF: Fix base relocation for ImageBase.
Rui Ueyama [Fri, 20 Feb 2015 03:35:59 +0000 (03:35 +0000)]
PECOFF: Fix base relocation for ImageBase.

This is yet another edge case of base relocation for symbols. Absolute
symbols are in general not target of base relocation because absolute
atom is a way to point to a specific memory location. In r229816, I
removed entries for absolute atoms from the base relocation table
(so that they won't be fixed by the loader).

However, there was one exception -- ImageBase. ImageBase points to the
start address of the current image in memory. That needs to be fixed up
at load time. This patch is to treat the symbol in a special manner.

llvm-svn: 229961

9 years agoBitcode: Stop assuming non-null fields
Duncan P. N. Exon Smith [Fri, 20 Feb 2015 03:17:58 +0000 (03:17 +0000)]
Bitcode: Stop assuming non-null fields

When writing the bitcode serialization for the new debug info hierarchy,
I assumed two fields would never be null.

Drop that assumption, since it's brittle (and crashes the
`BitcodeWriter` if wrong), and is a check better left for the verifier
anyway.  (No need for a bitcode upgrade here, since the new hierarchy is
still not in place.)

The fields in question are `MDCompileUnit::getFile()` and
`MDDerivedType::getBaseType()`, the latter of which isn't null in
test/Transforms/Mem2Reg/ConvertDebugInfo2.ll (see !14, a pointer to
nothing).  While the testcase might have bitrotted, there's no reason
for the bitcode format to rely on non-null for metadata operands.

This also fixes a bug in `AsmWriter` where if the `file:` is null it
isn't emitted (caught by the double-round trip in the testcase I'm
adding) -- this is a required field in `LLParser`.

I'll circle back to ConvertDebugInfo2.  Once the specialized nodes are
in place, I'll be trying to turn the debug info verifier back on by
default (in the newer module pass form committed r206300) and throwing
more logic in there.  If the testcase has bitrotted (as opposed to me
not understanding the schema correctly) I'll fix it then.

llvm-svn: 229960

9 years ago[InstCombine] Remove unnecessary variable indexing into single-element arrays
Hal Finkel [Fri, 20 Feb 2015 03:05:53 +0000 (03:05 +0000)]
[InstCombine] Remove unnecessary variable indexing into single-element arrays

This change addresses a deficiency pointed out in PR22629. To copy from the bug
report:

[from the bug report]

Consider this code:

int f(int x) {
  int a[] = {12};
  return a[x];
}

GCC knows to optimize this to

movl     $12, %eax
ret

The code generated by recent Clang at -O3 is:

movslq   %edi, %rax
movl     .L_ZZ1fiE1a(,%rax,4), %eax
retq

.L_ZZ1fiE1a:
  .long    12                      # 0xc

[end from the bug report]

This definitely seems worth fixing. I've also seen this kind of code before (as
the base case of generic vector wrapper templates with one element).

The general idea is to look at the GEP feeding a load or a store, which has
some variable as its first non-zero index, and determine if that index must be
zero (or else an out-of-bounds access would occur). We can do this for allocas
and globals with constant initializers where we know the maximum size of the
underlying object. When we find such a GEP, we create a new one for the memory
access with that first variable index replaced with a constant zero.

Even if we can't eliminate the memory access (and sometimes we can't), it is
still useful because it removes unnecessary indexing calculations.

llvm-svn: 229959

9 years ago[x86] Make the new vector shuffle legality test on by default, which
Chandler Carruth [Fri, 20 Feb 2015 03:05:47 +0000 (03:05 +0000)]
[x86] Make the new vector shuffle legality test on by default, which
reflects the fact that the x86 backend can in fact lower any shuffle you
want it to with reasonably high code quality.

My recent work on the new vector shuffle has made this regress *very*
little. The diff in the test cases makes me very, very happy.

llvm-svn: 229958

9 years ago[fuzzer] one more experimental search mode: -use_coverage_pairs=1
Kostya Serebryany [Fri, 20 Feb 2015 03:02:37 +0000 (03:02 +0000)]
[fuzzer] one more experimental search mode: -use_coverage_pairs=1

llvm-svn: 229957

9 years agoutils: Teach lldbDataFormatters about llvm::Optional
Justin Bogner [Fri, 20 Feb 2015 02:55:22 +0000 (02:55 +0000)]
utils: Teach lldbDataFormatters about llvm::Optional

llvm-svn: 229956

9 years ago[x86] Clean up a couple of test cases with the new update script. Split
Chandler Carruth [Fri, 20 Feb 2015 02:44:13 +0000 (02:44 +0000)]
[x86] Clean up a couple of test cases with the new update script. Split
one test case that is only partially tested in 32-bits into two test
cases so that the script doesn't generate massive spews of tests for the
cases we don't care about.

llvm-svn: 229955

9 years agoAdjust enablement of RewriteStatepointsForGC
Philip Reames [Fri, 20 Feb 2015 02:34:49 +0000 (02:34 +0000)]
Adjust enablement of RewriteStatepointsForGC

When back merging the changes in 229945 I noticed that I forgot to mark the test cases with the appropriate GC.  We want the rewriting to be off by default (even when manually added to the pass order), not on-by default.  To keep the current test working, mark them as using the statepoint-example GC and whitelist that GC.

Longer term, we need a better selection mechanism here for both actual usage and testing.  As I migrate more tests to the in tree version of this pass, I will probably need to update the enable/disable logic as well.

llvm-svn: 229954

9 years agoIR: Extract macros from DILocation, NFC
Duncan P. N. Exon Smith [Fri, 20 Feb 2015 02:28:49 +0000 (02:28 +0000)]
IR: Extract macros from DILocation, NFC

`DILocation` is a lightweight wrapper.  Its accessors check for null and
the correct type, and then forward to `MDLocation`.

Extract a couple of macros to do the `dyn_cast_or_null<>` and default
return logic.  I'll be using these to minimize error-prone boilerplate
when I move the new hierarchy into place -- since all the other
subclasses of `DIDescriptor` will similarly become lightweight wrappers.

(Note that I hope to obsolete these wrappers fairly quickly, with the
goal of renaming the underlying types (e.g., I'll rename `MDLocation` to
`DILocation` once the name is free).)

llvm-svn: 229953

9 years agoRevert r229944: EH: Prune unreachable resume instructions during Dwarf EH preparation
Chandler Carruth [Fri, 20 Feb 2015 02:15:36 +0000 (02:15 +0000)]
Revert r229944: EH: Prune unreachable resume instructions during Dwarf EH preparation

This doesn't pass 'ninja check-llvm' for me. Lots of tests, including
the ones updated, fail with crashes and other explosions.

llvm-svn: 229952

9 years ago[sanitizer] fix a test broken by r229940
Kostya Serebryany [Fri, 20 Feb 2015 02:12:25 +0000 (02:12 +0000)]
[sanitizer] fix a test broken by r229940

llvm-svn: 229951

9 years agoAdd -fno-sized-deallocation option for completeness of fix in r229241 in documentatio...
Larisse Voufo [Fri, 20 Feb 2015 02:07:22 +0000 (02:07 +0000)]
Add -fno-sized-deallocation option for completeness of fix in r229241 in documentation in r229818.

llvm-svn: 229950

9 years ago[Orc][Kaleidoscope] Fix the orc/kaleidoscope tutorials on linux.
Lang Hames [Fri, 20 Feb 2015 02:03:30 +0000 (02:03 +0000)]
[Orc][Kaleidoscope] Fix the orc/kaleidoscope tutorials on linux.

llvm-svn: 229949

9 years ago[Sanitizer] Remove multiline comment to silence GCC warning. NFC.
Alexey Samsonov [Fri, 20 Feb 2015 01:45:51 +0000 (01:45 +0000)]
[Sanitizer] Remove multiline comment to silence GCC warning. NFC.

llvm-svn: 229948

9 years agoIR: Add getRaw() helper, NFC
Duncan P. N. Exon Smith [Fri, 20 Feb 2015 01:18:47 +0000 (01:18 +0000)]
IR: Add getRaw() helper, NFC

llvm-svn: 229947

9 years agoAdd a pass for constructing gc.statepoint sequences w/explicit relocations
Philip Reames [Fri, 20 Feb 2015 01:06:44 +0000 (01:06 +0000)]
Add a pass for constructing gc.statepoint sequences w/explicit relocations

This patch consists of a single pass whose only purpose is to visit previous inserted gc.statepoints which do not have gc.relocates inserted yet, and insert them. This can be used either immediately after IR generation to perform 'early safepoint insertion' or late in the pass order to perform 'late insertion'.

This patch is setting the stage for work to continue in tree.  In particular, there are known naming and style violations in the current patch.  I'll try to get those resolved over the next week or so.  As I touch each area to make style changes, I need to make sure we have adequate testing in place.  As part of the cleanup, I will be cleaning up a collection of test cases we have out of tree and submitting them upstream. The tests included in this change are very basic and mostly to provide examples of usage.

The pass has several main subproblems it needs to address:
- First, it has identify any live pointers. In the current code, the use of address spaces to distinguish pointers to GC managed objects is hard coded, but this will become parametrizable in the near future.  Note that the current change doesn't actually contain a useful liveness analysis.  It was seperated into a followup change as the code wasn't ready to be shared.  Instead, the current implementation just considers any dominating def of appropriate pointer type to be live.
- Second, it has to identify base pointers for each live pointer. This is a fairly straight forward data flow algorithm.
- Third, the information in the previous steps is used to actually introduce rewrites. Rather than trying to do this by hand, we simply re-purpose the code behind Mem2Reg to do this for us.

llvm-svn: 229945

9 years agoEH: Prune unreachable resume instructions during Dwarf EH preparation
Reid Kleckner [Fri, 20 Feb 2015 01:00:19 +0000 (01:00 +0000)]
EH: Prune unreachable resume instructions during Dwarf EH preparation

Today a simple function that only catches exceptions and doesn't run
destructor cleanups ends up containing a dead call to _Unwind_Resume
(PR20300). We can't remove these dead resume instructions during normal
optimization because inlining might introduce additional landingpads
that do have cleanups to run. Instead we can do this during EH
preparation, which is guaranteed to run after inlining.

Fixes PR20300.

Reviewers: majnemer

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

llvm-svn: 229944

9 years agoRevert "AVX-512: Full implementation for VRNDSCALESS/SD instructions and intrinsics."
Eric Christopher [Fri, 20 Feb 2015 00:45:28 +0000 (00:45 +0000)]
Revert "AVX-512: Full implementation for VRNDSCALESS/SD instructions and intrinsics."

The instructions were being generated on architectures that don't support avx512.

This reverts commit r229837.

llvm-svn: 229942

9 years agoAdd a license header to the AVX512 file.
Eric Christopher [Fri, 20 Feb 2015 00:36:53 +0000 (00:36 +0000)]
Add a license header to the AVX512 file.

llvm-svn: 229941

9 years ago[sanitizer] when dumping the basic block trace, also dump the module names. Patch...
Kostya Serebryany [Fri, 20 Feb 2015 00:30:44 +0000 (00:30 +0000)]
[sanitizer] when dumping the basic block trace, also dump the module names. Patch by Laszlo Szekeres

llvm-svn: 229940

9 years agoThis needs to be a const variable so the two sides of the ternary
Eric Christopher [Fri, 20 Feb 2015 00:03:45 +0000 (00:03 +0000)]
This needs to be a const variable so the two sides of the ternary
operator agree on type.

llvm-svn: 229938

9 years ago[objc-arc-contract] We can not move retains over instructions which can not conservat...
Michael Gottesman [Fri, 20 Feb 2015 00:02:49 +0000 (00:02 +0000)]
[objc-arc-contract] We can not move retains over instructions which can not conservatively be proven to not decrement the retain's RCIdentity.

I also cleaned up the code to make it more understandable for mere mortals.

<rdar://problem/19853758>

llvm-svn: 229937

9 years ago[objc-arc] Add the predicate CanDecrementRefCount.
Michael Gottesman [Fri, 20 Feb 2015 00:02:45 +0000 (00:02 +0000)]
[objc-arc] Add the predicate CanDecrementRefCount.

This is different from CanAlterRefCount since CanDecrementRefCount is
attempting to prove specifically whether or not an instruction can
decrement instead of the more general question of whether it can
decrement or increment.

llvm-svn: 229936

9 years agoFix incorrect locale mapping in config.py on OSX
Eric Fiselier [Thu, 19 Feb 2015 23:57:46 +0000 (23:57 +0000)]
Fix incorrect locale mapping in config.py on OSX

llvm-svn: 229935

9 years ago[analyzer] RetainCountChecker: don't try to track ivars known to be nil.
Jordan Rose [Thu, 19 Feb 2015 23:57:04 +0000 (23:57 +0000)]
[analyzer] RetainCountChecker: don't try to track ivars known to be nil.

We expect in general that any nil value has no retain count information
associated with it; violating this results in unexpected state unification
/later/ when we decide to throw the information away. Unexpectedly caching
out can lead to an assertion failure or crash.

rdar://problem/19862648

llvm-svn: 229934

9 years agoIR: Fix MDType fields from unsigned to uint64_t
Duncan P. N. Exon Smith [Thu, 19 Feb 2015 23:56:07 +0000 (23:56 +0000)]
IR: Fix MDType fields from unsigned to uint64_t

When trying to match the current schema with the new debug info
hierarchy, I downgraded `SizeInBits`, `AlignInBits` and `OffsetInBits`
to 32-bits (oops!).  Caught this while testing my upgrade script to move
the hierarchy into place.  Bump it back up to 64-bits and update tests.

llvm-svn: 229933

9 years ago[ARM] Re-re-apply VLD1/VST1 base-update combine.
Ahmed Bougacha [Thu, 19 Feb 2015 23:52:41 +0000 (23:52 +0000)]
[ARM] Re-re-apply VLD1/VST1 base-update combine.

This re-applies r223862, r224198, r224203, and r224754, which were
reverted in r228129 because they exposed Clang misalignment problems
when self-hosting.

The combine caused the crashes because we turned ISD::LOAD/STORE nodes
to ARMISD::VLD1/VST1_UPD nodes.  When selecting addressing modes, we
were very lax for the former, and only emitted the alignment operand
(as in "[r1:128]") when it was larger than the standard alignment of
the memory type.

However, for ARMISD nodes, we just used the MMO alignment, no matter
what.  In our case, we turned ISD nodes to ARMISD nodes, and this
caused the alignment operands to start being emitted.

And that's how we exposed alignment problems that were ignored before
(but I believe would have been caught with SCTRL.A==1?).

To fix this, we can just mirror the hack done for ISD nodes:  only
take into account the MMO alignment when the access is overaligned.

Original commit message:
We used to only combine intrinsics, and turn them into VLD1_UPD/VST1_UPD
when the base pointer is incremented after the load/store.

We can do the same thing for generic load/stores.

Note that we can only combine the first load/store+adds pair in
a sequence (as might be generated for a v16f32 load for instance),
because other combines turn the base pointer addition chain (each
computing the address of the next load, from the address of the last
load) into independent additions (common base pointer + this load's
offset).

rdar://19717869, rdar://14062261.

llvm-svn: 229932

9 years agoOnly use the initialized MCInstrInfo if it's been initialized already
Eric Christopher [Thu, 19 Feb 2015 23:52:35 +0000 (23:52 +0000)]
Only use the initialized MCInstrInfo if it's been initialized already
during SetupMachineFunction. This is also the single use of MII
and it'll be changing to TargetInstrInfo (which is MachineFunction
based) in the next commit here.

llvm-svn: 229931

9 years agoDebugInfo: Match Name and DisplayName in testcase
Duncan P. N. Exon Smith [Thu, 19 Feb 2015 23:48:17 +0000 (23:48 +0000)]
DebugInfo: Match Name and DisplayName in testcase

There's no way for `DIBuilder` to create a subprogram or global variable
where `getName()` and `getDisplayName()` give different answers.  This
testcase managed to achieve the feat though.  This was probably just
left behind in some sort of upgrade along the way.

llvm-svn: 229930

9 years ago[ARM] Minor cleanup to CombineBaseUpdate. NFC.
Ahmed Bougacha [Thu, 19 Feb 2015 23:30:37 +0000 (23:30 +0000)]
[ARM] Minor cleanup to CombineBaseUpdate. NFC.

In preparation for a future patch:
- rename isLoad to isLoadOp: the former is confusing, and can be taken
  to refer to the fact that the node is an ISD::LOAD.  (it isn't, yet.)
- change formatting here and there.
- add some comments.
- const-ify bools.

llvm-svn: 229929

9 years agoMigrate away a use of the subtarget (and TargetMachine) from
Eric Christopher [Thu, 19 Feb 2015 23:29:42 +0000 (23:29 +0000)]
Migrate away a use of the subtarget (and TargetMachine) from
AsmPrinterDwarf since the information is on the MCRegisterInfo
via the MCContext and MMI that we already have on the AsmPrinter.

llvm-svn: 229928

9 years agoMove to using -fdiagnostics-color=always on both GCC and Clang
Eric Fiselier [Thu, 19 Feb 2015 23:26:54 +0000 (23:26 +0000)]
Move to using -fdiagnostics-color=always on both GCC and Clang

llvm-svn: 229927

9 years agoIR: Add missing null operand to MDSubroutineType
Duncan P. N. Exon Smith [Thu, 19 Feb 2015 23:25:21 +0000 (23:25 +0000)]
IR: Add missing null operand to MDSubroutineType

Add missing `nullptr` from `MDSubroutineType`'s operands for
`MDCompositeTypeBase::getIdentifier()` (and add tests for all the other
unused fields).  This highlights just how crazy it is that
`MDSubroutineType` inherits from `MDCompositeTypeBase`.

llvm-svn: 229926

9 years ago[CodeGen] Use ArrayRef instead of std::vector&. NFC.
Ahmed Bougacha [Thu, 19 Feb 2015 23:13:10 +0000 (23:13 +0000)]
[CodeGen] Use ArrayRef instead of std::vector&. NFC.

The former lets us use SmallVectors.  Do so in ARM and AArch64.

llvm-svn: 229925

9 years ago[Sanitizer] Drop LibIgnore dependency on SuppressionContext. NFC.
Alexey Samsonov [Thu, 19 Feb 2015 22:56:49 +0000 (22:56 +0000)]
[Sanitizer] Drop LibIgnore dependency on SuppressionContext. NFC.

Let each LibIgnore user (for now it's only TSan) manually go
through SuppressionContext and pass ignored library templates to
LibIgnore.

llvm-svn: 229924

9 years ago[Sanitizer] Move TemplateMatch() to sanitizer_common.cc. NFC.
Alexey Samsonov [Thu, 19 Feb 2015 22:56:47 +0000 (22:56 +0000)]
[Sanitizer] Move TemplateMatch() to sanitizer_common.cc. NFC.

llvm-svn: 229923

9 years agoDon't dllexport inline methods when targeting MinGW.
Hans Wennborg [Thu, 19 Feb 2015 22:39:24 +0000 (22:39 +0000)]
Don't dllexport inline methods when targeting MinGW.

MinGW neither imports nor exports such methods. The import bit was
committed earlier, in r221154, and this takes care of the export part.

This also partially fixes PR22591.

llvm-svn: 229922

9 years agoAdd support for analyzing FreeBSD kernel printf extensions.
Dimitry Andric [Thu, 19 Feb 2015 22:32:33 +0000 (22:32 +0000)]
Add support for analyzing FreeBSD kernel printf extensions.

This adds a new __freebsd_kprintf__ format string type, which enables
checking when used in __attribute__((format(...))) attributes.  It can
check the FreeBSD kernel specific %b, %D, %r and %y specifiers, using
existing diagnostic messages.  Also adds test cases for all these
specifiers.

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

llvm-svn: 229921

9 years agoFix formatting
Tobias Grosser [Thu, 19 Feb 2015 22:16:12 +0000 (22:16 +0000)]
Fix formatting

llvm-svn: 229920

9 years ago[Objective-C Sema]. Don't warn about use of
Fariborz Jahanian [Thu, 19 Feb 2015 21:52:41 +0000 (21:52 +0000)]
[Objective-C Sema]. Don't warn about use of
property accessors in @selector not implemented
because they will be auto-synthesized. rdar://16607480

llvm-svn: 229919

9 years agoItanium ABI: Pack expansions change the arity of expressions to unknown
David Majnemer [Thu, 19 Feb 2015 21:41:48 +0000 (21:41 +0000)]
Itanium ABI: Pack expansions change the arity of expressions to unknown

llvm-svn: 229918