platform/upstream/llvm.git
9 years agoDead code elimination: Update dependences after eliminating code
Tobias Grosser [Wed, 17 Dec 2014 21:13:55 +0000 (21:13 +0000)]
Dead code elimination: Update dependences after eliminating code

Without updating dependences we may lose implicit transitive dependences for
which all explicit dependences have gone through the statement iterations we
have just eliminated.

No test case. We should probably implement a -verify-dependences option.

This fixes llvm.org/PR21227

llvm-svn: 224459

9 years agoR600/SI: Fix f64 inline immediates
Matt Arsenault [Wed, 17 Dec 2014 21:04:08 +0000 (21:04 +0000)]
R600/SI: Fix f64 inline immediates

llvm-svn: 224458

9 years ago[c++1z] Fixes for generalized non-type template argument support: check for
Richard Smith [Wed, 17 Dec 2014 20:42:37 +0000 (20:42 +0000)]
[c++1z] Fixes for generalized non-type template argument support: check for
exact type match for deduced template arguments, and be sure to produce correct
canonical TemplateArgument representations to enable correct redeclaration
matching.

llvm-svn: 224456

9 years ago[Hexagon] Reconfiguring register alternate names.
Colin LeMahieu [Wed, 17 Dec 2014 20:35:11 +0000 (20:35 +0000)]
[Hexagon] Reconfiguring register alternate names.

llvm-svn: 224455

9 years agoDestroy the diagnostic client first in ~DiagnosticEngine
Reid Kleckner [Wed, 17 Dec 2014 20:23:11 +0000 (20:23 +0000)]
Destroy the diagnostic client first in ~DiagnosticEngine

Add a comment and a test to ~DiagnosticEngine about the ordering
requirements on the teardown of DiagnosticConsumer. This could also be
accomplished by rearranging the fields of ~DiagnosticEngine, but I felt
that this was a better, more explicit solution.

This fixes PR21911, an issue that occurred after the unique_ptr
migration in r222193.

llvm-svn: 224454

9 years agoThis test does not pass for -target i686-pc-windows-gnu (-mingw32)
Yaron Keren [Wed, 17 Dec 2014 20:12:29 +0000 (20:12 +0000)]
This test does not pass for -target i686-pc-windows-gnu (-mingw32)
when clang is built with mingw-w64 4.9.1 or according to
http://llvm.org/PR20995  , mingw-w64 4.7.2 as well.

llvm-svn: 224453

9 years agoEnable the P8Model entry
Will Schmidt [Wed, 17 Dec 2014 19:56:29 +0000 (19:56 +0000)]
Enable the P8Model entry

This was missed last time around, for the P8 Instruction Scheduling
changes (223257). This will hook the P8Model entry in so those
changes will actually be used.

llvm-svn: 224452

9 years agoDon't build invalid AST nodes during recovery
Reid Kleckner [Wed, 17 Dec 2014 19:34:15 +0000 (19:34 +0000)]
Don't build invalid AST nodes during recovery

A DependentScopeDeclRefExpr should always have a nested name specifier.
During template instantiation, if we found that the named context was
incomplete, we would previously build a DependentScopeDeclRefExpr with
an empty qualifier.

This error recovery path has been asserting for some time. The other
error codepaths use ExprError, so we can do the same.

Fixes PR21864.

llvm-svn: 224451

9 years ago[ASan] Move flag parsing logic to asan_flags.cc. NFC.
Alexey Samsonov [Wed, 17 Dec 2014 19:31:39 +0000 (19:31 +0000)]
[ASan] Move flag parsing logic to asan_flags.cc. NFC.

llvm-svn: 224450

9 years agoSupport constant evaluation for member calls on std::initializer_list
Richard Smith [Wed, 17 Dec 2014 19:24:30 +0000 (19:24 +0000)]
Support constant evaluation for member calls on std::initializer_list
temporaries.

llvm-svn: 224449

9 years agolld self-hosts on FreeBSD too
Ed Maste [Wed, 17 Dec 2014 19:14:57 +0000 (19:14 +0000)]
lld self-hosts on FreeBSD too

llvm-svn: 224448

9 years agoExecutionDepsFix: Correctly handle wide registers.
Matthias Braun [Wed, 17 Dec 2014 19:13:47 +0000 (19:13 +0000)]
ExecutionDepsFix: Correctly handle wide registers.

The ExecutionDepsFix previously mapped each register to 1 or zero
registers of the register class it was called with and therefore
simulating liveness for.  This was problematic for cases involving wider
registers like Q0 on ARM where ExecutionDepsFix gets invoked for the Dxx
registers. In these cases the wide register would get mapped to the last
matching D register, while it should have been all matching D registers.
This commit changes the AliasMap to use a SmallVector to map registers
to potentially multiple destination regclass registers. This is required
to avoid regressions with subregister liveness tracking enabled.

llvm-svn: 224447

9 years agoRevert "Fix test cases given Clang's improved location information."
David Blaikie [Wed, 17 Dec 2014 19:11:27 +0000 (19:11 +0000)]
Revert "Fix test cases given Clang's improved location information."

The Clang improevments were reverted due to failures created in an asan
bootstrap.

This reverts commit r224387.

llvm-svn: 224446

9 years agoRandom Number Generator Refactoring (removing from Module)
JF Bastien [Wed, 17 Dec 2014 18:12:10 +0000 (18:12 +0000)]
Random Number Generator Refactoring (removing from Module)

This patch removes the RNG from Module. Passes should instead create a new RNG for their use as needed.

Patch by Stephen Crane @rinon.

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

llvm-svn: 224444

9 years agoWork around an internal compiler error in MSVC.
Zachary Turner [Wed, 17 Dec 2014 18:02:36 +0000 (18:02 +0000)]
Work around an internal compiler error in MSVC.

For some reason MSVC ICEs when trying to index into a map using
a temporary object.  Work around this by separating out the call
into multiple lines.

Patch by Aidan Dodds
Differential Revision: http://reviews.llvm.org/D6702
Reviewed by: Zachary Turner, Greg Clayton

llvm-svn: 224443

9 years agoEnhance the Pipe interface for better portability.
Zachary Turner [Wed, 17 Dec 2014 18:02:19 +0000 (18:02 +0000)]
Enhance the Pipe interface for better portability.

This patch makes a number of improvements to the Pipe interface.

1) An interface (PipeBase) is provided which exposes pure virtual
   methods for any implementation of Pipe to override.  While not
   strictly necessary, this helps catch errors where the interfaces
   are out of sync.

2) All methods return lldb_private::Error instead of returning bool
   or void.  This allows richer error information to be propagated
   up to LLDB.

3) A new ReadWithTimeout() method is exposed in the base class and
   implemented on Windows.

4) Support for both named and anonymous pipes is exposed through the
   base interface and implemented on Windows.  For creating a new
   pipe, both named and anonymous pipes are supported, and for
   opening an existing pipe, only named pipes are supported.

New methods described in points #3 and #4 are stubbed out on posix,
but fully implemented on Windows.  These should be implemented by
someone on the linux / mac / bsd side.

Reviewed by: Greg Clayton, Oleksiy Vyalov
Differential Revision: http://reviews.llvm.org/D6686

llvm-svn: 224442

9 years agoRevert "DebugInfo: Generalize debug info location handling"
David Blaikie [Wed, 17 Dec 2014 18:02:04 +0000 (18:02 +0000)]
Revert "DebugInfo: Generalize debug info location handling"

Fails an ASan bootstrap - I'll try to reproduce locally & sort that out
before recommitting.

This reverts commit r224385.

llvm-svn: 224441

9 years ago[NVPTX] Fix bugs related to isSingleValueType
Jingyue Wu [Wed, 17 Dec 2014 17:59:04 +0000 (17:59 +0000)]
[NVPTX] Fix bugs related to isSingleValueType

Summary:
With isSingleValueType starting to treat vector types as single-value types,
code that uses this interface needs to be updated.

Test Plan:
vector-global.ll
nvcl-param-align.ll

Reviewers: jholewinski

Reviewed By: jholewinski

Subscribers: llvm-commits, meheff, eliben, jholewinski

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

llvm-svn: 224440

9 years agoBasic: clean up bleeding whitespace
Saleem Abdulrasool [Wed, 17 Dec 2014 17:52:33 +0000 (17:52 +0000)]
Basic: clean up bleeding whitespace

Whitespace cleanup.  NFC.

llvm-svn: 224439

9 years agoCodeGen: implement __emit intrinsic
Saleem Abdulrasool [Wed, 17 Dec 2014 17:52:30 +0000 (17:52 +0000)]
CodeGen: implement __emit intrinsic

For MSVC compatibility, add the `__emit' builtin. This is used in the Windows
SDK headers, and must therefore be implemented as a builtin rather than an
intrinsic.

The `__emit' builtin provides a mechanism to emit a 16-bit opcode instruction
into the stream. The value must be a compile time constant expression. No
guarantees are made about the CPU and memory states after the execution of the
instruction.

Due to the unchecked nature of the builtin, only support this on Windows on ARM.

llvm-svn: 224438

9 years agoFix CR/LF line endings in test case
Timur Iskhodzhanov [Wed, 17 Dec 2014 17:52:12 +0000 (17:52 +0000)]
Fix CR/LF line endings in test case

llvm-svn: 224437

9 years agoRevert r224433, r224371 is good enough for now.
Joerg Sonnenberger [Wed, 17 Dec 2014 17:14:11 +0000 (17:14 +0000)]
Revert r224433, r224371 is good enough for now.

llvm-svn: 224435

9 years agoRangify for loop, NFC.
Yaron Keren [Wed, 17 Dec 2014 16:56:54 +0000 (16:56 +0000)]
Rangify for loop, NFC.

llvm-svn: 224434

9 years agoDisable the keyword-as-macro warning for now until the noise level is
Joerg Sonnenberger [Wed, 17 Dec 2014 16:25:45 +0000 (16:25 +0000)]
Disable the keyword-as-macro warning for now until the noise level is
reduced.

llvm-svn: 224433

9 years agoARM: correct an off-by-one in an assert
Saleem Abdulrasool [Wed, 17 Dec 2014 16:17:44 +0000 (16:17 +0000)]
ARM: correct an off-by-one in an assert

The assert was off-by-one, resulting in failures for valid input.

Thanks to Asiri Rathnayake for pointing out the failure!

llvm-svn: 224432

9 years agos/ScheduleKind/SchedKind/ in \param. [-Wdocumentation]
NAKAMURA Takumi [Wed, 17 Dec 2014 14:47:06 +0000 (14:47 +0000)]
s/ScheduleKind/SchedKind/ in \param. [-Wdocumentation]

llvm-svn: 224431

9 years agoExclude printLineState() in -Asserts. [-Wunused-function]
NAKAMURA Takumi [Wed, 17 Dec 2014 14:46:56 +0000 (14:46 +0000)]
Exclude printLineState() in -Asserts. [-Wunused-function]

llvm-svn: 224430

9 years ago[DAGCombine] Slightly improve lowering of BUILD_VECTOR into a shuffle.
Michael Kuperstein [Wed, 17 Dec 2014 12:32:17 +0000 (12:32 +0000)]
[DAGCombine] Slightly improve lowering of BUILD_VECTOR into a shuffle.

This handles the case of a BUILD_VECTOR being constructed out of elements extracted from a vector twice the size of the result vector. Previously this was always scalarized. Now, we try to construct a shuffle node that feeds on extract_subvectors.

This fixes PR15872 and provides a partial fix for PR21711.

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

llvm-svn: 224429

9 years ago[mips] Always clobber $1 for MIPS inline asm.
Toma Tabacu [Wed, 17 Dec 2014 12:02:58 +0000 (12:02 +0000)]
[mips] Always clobber $1 for MIPS inline asm.

Summary:
Because GCC doesn't use $1 for code generation, inline assembly code can use $1 without having to add it to the clobbers list.

LLVM, on the other hand, does not shy away from using $1, and this can cause conflicts with inline assembly which assumes GCC-like code generation.

A solution to this problem is to make Clang automatically clobber $1 for all MIPS inline assembly.
This is not the optimal solution, but it seems like a necessary compromise, for now.

Reviewers: dsanders

Reviewed By: dsanders

Subscribers: cfe-commits

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

llvm-svn: 224428

9 years agoMipsABIInfo class is used in different libraries. Moving the files to MCTargetDesc...
Vladimir Medic [Wed, 17 Dec 2014 11:49:56 +0000 (11:49 +0000)]
MipsABIInfo class is used in different libraries. Moving the files to MCTargetDesc folder(LLVMMipsDesc library) prevents linkage errors. There are no functional changes.

llvm-svn: 224427

9 years agoTeach compile_commands.json test that windows-gnu is the new name for mingw32.
Yaron Keren [Wed, 17 Dec 2014 11:04:07 +0000 (11:04 +0000)]
Teach compile_commands.json test that windows-gnu is the new name for mingw32.

llvm-svn: 224426

9 years ago[mips] Set GCC-compatible MIPS asssembler options before inline asm blocks.
Toma Tabacu [Wed, 17 Dec 2014 10:56:16 +0000 (10:56 +0000)]
[mips] Set GCC-compatible MIPS asssembler options before inline asm blocks.

Summary:
When generating MIPS assembly, LLVM always overrides the default assembler options by emitting the '.set noreorder', '.set nomacro' and '.set noat' directives,
while GCC uses the default options if an assembly-level function contains inline assembly code.

This becomes a problem when the code generated by LLVM is interleaved with inline assembly which assumes GCC-like assembler options (from Linux, for example).

This patch fixes these conflicts by setting the appropriate assembler options at the beginning of an inline asm block and popping them at the end.

Reviewers: dsanders

Reviewed By: dsanders

Subscribers: llvm-commits

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

llvm-svn: 224425

9 years agoRevert 224119 "This patch recognizes (+ (+ v0, v1) (+ v2, v3)), reorders them for...
Suyog Sarda [Wed, 17 Dec 2014 10:34:27 +0000 (10:34 +0000)]
Revert 224119 "This patch recognizes (+ (+ v0, v1) (+ v2, v3)), reorders them for bundling into vector of loads,
and vectorizes it."

This was re-ordering floating point data types resulting in mismatch in output.

llvm-svn: 224424

9 years ago[msan] Stop calling pthread_getspecific in signal handlers.
Evgeniy Stepanov [Wed, 17 Dec 2014 10:30:06 +0000 (10:30 +0000)]
[msan] Stop calling pthread_getspecific in signal handlers.

pthread_getspecific is not async-signal-safe.

MsanThread pointer is now stored in a TLS variable, and the TSD slot
is used only for its destructor, and never from a signal handler.

This should fix intermittent CHECK failures in MsanTSDSet.

llvm-svn: 224423

9 years agotsan: add disabled test case for issue 87
Dmitry Vyukov [Wed, 17 Dec 2014 10:19:20 +0000 (10:19 +0000)]
tsan: add disabled test case for issue 87

llvm-svn: 224422

9 years agoTeach lit.cfg to recognize -windows-gnu in addition to -mingw32.
Yaron Keren [Wed, 17 Dec 2014 09:55:15 +0000 (09:55 +0000)]
Teach lit.cfg to recognize -windows-gnu in addition to -mingw32.

llvm-svn: 224421

9 years agoirgen: fix canAvoid*
Peter Collingbourne [Wed, 17 Dec 2014 09:45:05 +0000 (09:45 +0000)]
irgen: fix canAvoid*

Patch by Andrew Wilkins!

canAvoidElementLoad and canAvoidLoad were incorrectly
eliding loads when an index expression is used as an
another array index expression. This led to a panic.

See comments on https://github.com/go-llvm/llgo/issues/175

Test Plan: lit test added

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

llvm-svn: 224420

9 years agoclang-format: Fix incorrect calculation of token lenghts.
Daniel Jasper [Wed, 17 Dec 2014 09:11:08 +0000 (09:11 +0000)]
clang-format: Fix incorrect calculation of token lenghts.

This led, e.g. to break JavaScript regex literals too early.

llvm-svn: 224419

9 years agoAdded 5 more tests related to sink store revision 224247
Elena Demikhovsky [Wed, 17 Dec 2014 08:12:59 +0000 (08:12 +0000)]
Added 5 more tests related to sink store revision 224247
- by Ella Bolshinsky

http://reviews.llvm.org/D6420

llvm-svn: 224418

9 years agoStrength reduce intrinsics with overflow into regular arithmetic operations if possible.
Erik Eckstein [Wed, 17 Dec 2014 07:29:19 +0000 (07:29 +0000)]
Strength reduce intrinsics with overflow into regular arithmetic operations if possible.

Some intrinsics, like s/uadd.with.overflow and umul.with.overflow, are already strength reduced.
This change adds other arithmetic intrinsics: s/usub.with.overflow, smul.with.overflow.
It completes the work on PR20194.

llvm-svn: 224417

9 years agoRevert "Linker: Drop superseded subprograms"
Duncan P. N. Exon Smith [Wed, 17 Dec 2014 07:27:31 +0000 (07:27 +0000)]
Revert "Linker: Drop superseded subprograms"

This reverts commit r224389.  Based on feedback from the bots, the
assertion seems to be going off *more* often, not less (previously I was
just seeing it in an internal bootstrap, now it's happening in public
builds too).

http://lab.llvm.org:8080/green/job/clang-stage2-configure-Rlto_build/936/
http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-bootstrap/builds/5325

Reverting in order to investigate.

llvm-svn: 224416

9 years agoAdd parsing of 'foo@local".
Justin Hibbits [Wed, 17 Dec 2014 06:23:35 +0000 (06:23 +0000)]
Add parsing of 'foo@local".

Summary:
Currently, it supports generating, but not parsing, this expression.
Test added as well.

Test Plan: New test added, no regressions due to this.

Reviewers: hfinkel

Reviewed By: hfinkel

Subscribers: llvm-commits

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

llvm-svn: 224415

9 years agoRemove a debugging assert.
Rafael Espindola [Wed, 17 Dec 2014 03:38:04 +0000 (03:38 +0000)]
Remove a debugging assert.

Sorry for the noise, I have no idea how it survived to the final version.

llvm-svn: 224414

9 years agoRemove unused includes and out of date comment. NFC.
Rafael Espindola [Wed, 17 Dec 2014 03:07:20 +0000 (03:07 +0000)]
Remove unused includes and out of date comment. NFC.

llvm-svn: 224413

9 years agoFix the windows build.
Rafael Espindola [Wed, 17 Dec 2014 02:42:20 +0000 (02:42 +0000)]
Fix the windows build.

llvm-svn: 224412

9 years agoSema: Don't dyn_cast a null pointer in CheckUsingDeclQualifier
David Majnemer [Wed, 17 Dec 2014 02:41:36 +0000 (02:41 +0000)]
Sema: Don't dyn_cast a null pointer in CheckUsingDeclQualifier

This code was written with the intent that a pointer could be null but
we dyn_cast'd it anyway.  Change the dyn_cast to a dyn_cast_or_null.

This fixes PR21933.

llvm-svn: 224411

9 years agoRefactor and simplify the code reading /proc/cpuinfo. NFC.
Rafael Espindola [Wed, 17 Dec 2014 02:32:44 +0000 (02:32 +0000)]
Refactor and simplify the code reading /proc/cpuinfo. NFC.

llvm-svn: 224410

9 years agoRegisterCoalescer: Sprinkle some const modifiers.
Matthias Braun [Wed, 17 Dec 2014 02:18:13 +0000 (02:18 +0000)]
RegisterCoalescer: Sprinkle some const modifiers.

llvm-svn: 224409

9 years agollvm-lto: Add testing coverage for local contexts
Duncan P. N. Exon Smith [Wed, 17 Dec 2014 02:00:38 +0000 (02:00 +0000)]
llvm-lto: Add testing coverage for local contexts

Add coverage in `llvm-lto` for the API exposed by libLTO to create
modules in local contexts.

The goal here isn't to test the symbol-related API extensively, just to
confirm that these modules work at all.  (I'll be shifting code around
soon that should be NFC and I realized there was no test coverage.)

llvm-svn: 224408

9 years agoDelete debugging cruft that crept in with r223802.
Nick Lewycky [Wed, 17 Dec 2014 01:56:51 +0000 (01:56 +0000)]
Delete debugging cruft that crept in with r223802.

llvm-svn: 224407

9 years ago[ASan] Re-structure the allocator code. NFC.
Alexey Samsonov [Wed, 17 Dec 2014 01:55:03 +0000 (01:55 +0000)]
[ASan] Re-structure the allocator code. NFC.

Introduce "Allocator" object, which contains all the bits and pieces
ASan allocation machinery actually use: allocator from sanitizer_common,
quarantine, fallback allocator and quarantine caches, fallback mutex.

This step is a preparation to adding more state to this object. We want
to reduce dependency of Allocator on commandline flags and be able to
"safely" modify its behavior (such as the size of the redzone) at
runtime.

llvm-svn: 224406

9 years agoInstSimplify: shl nsw/nuw undef, %V -> undef
David Majnemer [Wed, 17 Dec 2014 01:54:33 +0000 (01:54 +0000)]
InstSimplify: shl nsw/nuw undef, %V -> undef

We can always choose an value for undef which might cause %V to shift
out an important bit except for one case, when %V is zero.

However, shl behaves like an identity function when the right hand side
is zero.

llvm-svn: 224405

9 years agoMake ValueEnumerator::print use OS for metadata too. Noticed by inspection.
Nick Lewycky [Wed, 17 Dec 2014 01:52:08 +0000 (01:52 +0000)]
Make ValueEnumerator::print use OS for metadata too. Noticed by inspection.

llvm-svn: 224404

9 years agoParse: Consume tokens more carefully in CheckForLParenAfterColonColon
David Majnemer [Wed, 17 Dec 2014 01:39:22 +0000 (01:39 +0000)]
Parse: Consume tokens more carefully in CheckForLParenAfterColonColon

We would consume the lparen even if it wasn't followed by an identifier
or a star-identifier pair.

This fixes PR21815.

llvm-svn: 224403

9 years ago[CodeGenPrepare] Reapply r224351 with a fix for the assertion failure:
Quentin Colombet [Wed, 17 Dec 2014 01:36:17 +0000 (01:36 +0000)]
[CodeGenPrepare] Reapply r224351 with a fix for the assertion failure:
The type promotion helper does not support vector type, so when make
such it does not kick in in such cases.

Original commit message:
[CodeGenPrepare] Move sign/zero extensions near loads using type promotion.

This patch extends the optimization in CodeGenPrepare that moves a sign/zero
extension near a load when the target can combine them. The optimization may
promote any operations between the extension and the load to make that possible.

Although this optimization may be beneficial for all targets, in particular
AArch64, this is enabled for X86 only as I have not benchmarked it for other
targets yet.

** Context **

Most targets feature extended loads, i.e., loads that perform a zero or sign
extension for free. In that context it is interesting to expose such pattern in
CodeGenPrepare so that the instruction selection pass can form such loads.
Sometimes, this pattern is blocked because of instructions between the load and
the extension. When those instructions are promotable to the extended type, we
can expose this pattern.

** Motivating Example **

Let us consider an example:
define void @foo(i8* %addr1, i32* %addr2, i8 %a, i32 %b) {
  %ld = load i8* %addr1
  %zextld = zext i8 %ld to i32
  %ld2 = load i32* %addr2
  %add = add nsw i32 %ld2, %zextld
  %sextadd = sext i32 %add to i64
  %zexta = zext i8 %a to i32
  %addza = add nsw i32 %zexta, %zextld
  %sextaddza = sext i32 %addza to i64
  %addb = add nsw i32 %b, %zextld
  %sextaddb = sext i32 %addb to i64
  call void @dummy(i64 %sextadd, i64 %sextaddza, i64 %sextaddb)
  ret void
}

As it is, this IR generates the following assembly on x86_64:
[...]
  movzbl  (%rdi), %eax   # zero-extended load
  movl  (%rsi), %es      # plain load
  addl  %eax, %esi       # 32-bit add
  movslq  %esi, %rdi     # sign extend the result of add
  movzbl  %dl, %edx      # zero extend the first argument
  addl  %eax, %edx       # 32-bit add
  movslq  %edx, %rsi     # sign extend the result of add
  addl  %eax, %ecx       # 32-bit add
  movslq  %ecx, %rdx     # sign extend the result of add
[...]
The throughput of this sequence is 7.45 cycles on Ivy Bridge according to IACA.

Now, by promoting the additions to form more extended loads we would generate:
[...]
  movzbl  (%rdi), %eax   # zero-extended load
  movslq  (%rsi), %rdi   # sign-extended load
  addq  %rax, %rdi       # 64-bit add
  movzbl  %dl, %esi      # zero extend the first argument
  addq  %rax, %rsi       # 64-bit add
  movslq  %ecx, %rdx     # sign extend the second argument
  addq  %rax, %rdx       # 64-bit add
[...]
The throughput of this sequence is 6.15 cycles on Ivy Bridge according to IACA.

This kind of sequences happen a lot on code using 32-bit indexes on 64-bit
architectures.

Note: The throughput numbers are similar on Sandy Bridge and Haswell.

** Proposed Solution **

To avoid the penalty of all these sign/zero extensions, we merge them in the
loads at the beginning of the chain of computation by promoting all the chain of
computation on the extended type. The promotion is done if and only if we do not
introduce new extensions, i.e., if we do not degrade the code quality.
To achieve this, we extend the existing “move ext to load” optimization with the
promotion mechanism introduced to match larger patterns for addressing mode
(r200947).
The idea of this extension is to perform the following transformation:
ext(promotableInst1(...(promotableInstN(load))))
=>
promotedInst1(...(promotedInstN(ext(load))))

The promotion mechanism in that optimization is enabled by a new TargetLowering
switch, which is off by default. In other words, by default, the optimization
performs the “move ext to load” optimization as it was before this patch.

** Performance **

Configuration: x86_64: Ivy Bridge fixed at 2900MHz running OS X 10.10.
Tested Optimization Levels: O3/Os
Tests: llvm-testsuite + externals.
Results:
- No regression beside noise.
- Improvements:
CINT2006/473.astar:  ~2%
Benchmarks/PAQ8p: ~2%
Misc/perlin: ~3%

The results are consistent for both O3 and Os.

<rdar://problem/18310086>

llvm-svn: 224402

9 years agoAdd missing testcase from r224388.
Richard Smith [Wed, 17 Dec 2014 01:08:39 +0000 (01:08 +0000)]
Add missing testcase from r224388.

llvm-svn: 224401

9 years agoAdd printing the LC_ENCRYPTION_INFO_64 load command with llvm-objdump’s -private...
Kevin Enderby [Wed, 17 Dec 2014 01:01:30 +0000 (01:01 +0000)]
Add printing the LC_ENCRYPTION_INFO_64 load command with llvm-objdump’s -private-headers
and add tests for the two AArch64 binaries.

llvm-svn: 224400

9 years agoPR21875: codegen for non-type template parameters of nullptr_t type
David Blaikie [Wed, 17 Dec 2014 00:43:22 +0000 (00:43 +0000)]
PR21875: codegen for non-type template parameters of nullptr_t type

llvm-svn: 224399

9 years ago[CallGraph] Make sure the edges are not missed due to re-declarations
Anna Zaks [Wed, 17 Dec 2014 00:34:07 +0000 (00:34 +0000)]
[CallGraph] Make sure the edges are not missed due to re-declarations

A patch by Daniel DeFreez!

We were previously dropping edges on re-declarations. Store the
canonical declarations in the graph to ensure that different
references to the same function end up reflected with the same call graph
node.

(Note, this might lead to performance fluctuation because call graph
is used to determine the function analysis order.)

llvm-svn: 224398

9 years agoRevert "[CodeGenPrepare] Move sign/zero extensions near loads using type promotion."
Reid Kleckner [Wed, 17 Dec 2014 00:29:23 +0000 (00:29 +0000)]
Revert "[CodeGenPrepare] Move sign/zero extensions near loads using type promotion."

This reverts commit r224351. It causes assertion failures when building
ICU.

llvm-svn: 224397

9 years agoRename asan_allocator2.cc to asan_allocator.cc
Alexey Samsonov [Wed, 17 Dec 2014 00:26:50 +0000 (00:26 +0000)]
Rename asan_allocator2.cc to asan_allocator.cc

llvm-svn: 224396

9 years ago[ASan] Introduce SetCanPoisonMemory() function.
Alexey Samsonov [Wed, 17 Dec 2014 00:01:02 +0000 (00:01 +0000)]
[ASan] Introduce SetCanPoisonMemory() function.

SetCanPoisonMemory()/CanPoisonMemory() functions are now used
instead of "poison_heap" flag to determine if ASan is allowed
to poison the shadow memory. This allows to hot-patch this
value in runtime (e.g. during ASan activation) without introducing
a data race.

llvm-svn: 224395

9 years agoPR21909: Don't try (and crash) to generate debug info for explicit instantiations...
David Blaikie [Tue, 16 Dec 2014 23:49:18 +0000 (23:49 +0000)]
PR21909: Don't try (and crash) to generate debug info for explicit instantiations of explicit specializations.

llvm-svn: 224394

9 years agoSelectionDAG switch lowering: use 'unsigned' to count destination popularity
Hans Wennborg [Tue, 16 Dec 2014 23:41:59 +0000 (23:41 +0000)]
SelectionDAG switch lowering: use 'unsigned' to count destination popularity

SwitchInst::getNumCases() returns unsinged, so using uint64_t to count cases
seems unnecessary.

Also fix a missing CHECK in the test case.

llvm-svn: 224393

9 years agoAdd the ability to tag one or more breakpoints with a name. These
Jim Ingham [Tue, 16 Dec 2014 23:40:14 +0000 (23:40 +0000)]
Add the ability to tag one or more breakpoints with a name.  These
names can then be used in place of breakpoint id's or breakpoint id
ranges in all the commands that operate on breakpoints.

<rdar://problem/10103959>

llvm-svn: 224392

9 years ago[Hexagon] Updating doubleword shift usages to new versions.
Colin LeMahieu [Tue, 16 Dec 2014 23:36:15 +0000 (23:36 +0000)]
[Hexagon] Updating doubleword shift usages to new versions.

llvm-svn: 224391

9 years agoAdd printing the LC_ENCRYPTION_INFO load command with llvm-objdump’s -private-headers.
Kevin Enderby [Tue, 16 Dec 2014 23:25:52 +0000 (23:25 +0000)]
Add printing the LC_ENCRYPTION_INFO load command with llvm-objdump’s -private-headers.

llvm-svn: 224390

9 years agoLinker: Drop superseded subprograms
Duncan P. N. Exon Smith [Tue, 16 Dec 2014 23:23:41 +0000 (23:23 +0000)]
Linker: Drop superseded subprograms

When a function gets replaced by `ModuleLinker`, drop superseded
subprograms.  This ensures that the "first" subprogram pointing at a
function is the same one that `!dbg` references point at.

This is a stop-gap fix for PR21910.  Notably, this fixes Release+Asserts
bootstraps that are currently asserting out in
`LexicalScopes::initialize()` due to the explicit instantiations in
`lib/IR/Dominators.cpp` eventually getting replaced by -argpromotion.

llvm-svn: 224389

9 years agoDR1684: a constexpr member function need not be a member of a literal class type.
Richard Smith [Tue, 16 Dec 2014 23:12:52 +0000 (23:12 +0000)]
DR1684: a constexpr member function need not be a member of a literal class type.

llvm-svn: 224388

9 years agoFix test cases given Clang's improved location information.
David Blaikie [Tue, 16 Dec 2014 23:07:55 +0000 (23:07 +0000)]
Fix test cases given Clang's improved location information.

llvm-svn: 224387

9 years agoTry typo correction on all initialization arguments and be less
Kaelyn Takata [Tue, 16 Dec 2014 23:07:00 +0000 (23:07 +0000)]
Try typo correction on all initialization arguments and be less
pessimistic about when to do so.

This also fixes PR21905 as the initialization argument was no longer
viewed as being type dependent due to the TypoExpr being type-cast.

llvm-svn: 224386

9 years agoDebugInfo: Generalize debug info location handling
David Blaikie [Tue, 16 Dec 2014 22:49:17 +0000 (22:49 +0000)]
DebugInfo: Generalize debug info location handling

This is a more scalable (fixed in mostly one place, rather than many
places that will need constant improvement/maintenance) solution to
several commits I've made recently to increase source fidelity for
subexpressions.

This resetting had to be done at the DebugLoc level (not the
SourceLocation level) to preserve scoping information (if the resetting
was done with CGDebugInfo::EmitLocation, it would've caused the tail end
of an expression's codegen to end up in a potentially different scope
than the start, even though it was at the same source location). The
drawback to this is that it might leave CGDebugInfo out of sync. Ideally
CGDebugInfo shouldn't have a duplicate sense of the current
SourceLocation, but for now it seems it does... - I don't think I'm
going to tackle removing that just now.

I expect this'll probably cause some more buildbot fallout & I'll
investigate that as it comes up.

Also these sort of improvements might be starting to show a weakness/bug
in LLVM's line table handling: we don't correctly emit is_stmt for
statements, we just put it on every line table entry. This means one
statement split over multiple lines appears as multiple 'statements' and
two statements on one line (without column info) are treated as one
statement.

I don't think we have any IR representation of statements that would
help us distinguish these cases and identify the beginning of each
statement - so that might be something we need to add (possibly to the
lexical scope chain - a scope for each statement). This does cause some
problems for GDB and possibly other DWARF consumers.

llvm-svn: 224385

9 years agofix typo, add spaces; NFC
Sanjay Patel [Tue, 16 Dec 2014 22:48:42 +0000 (22:48 +0000)]
fix typo, add spaces; NFC

llvm-svn: 224384

9 years ago[X86][SSE] Vector double -> float conversion memory folding (cvtpd2ps)
Simon Pilgrim [Tue, 16 Dec 2014 22:30:10 +0000 (22:30 +0000)]
[X86][SSE] Vector double -> float conversion memory folding (cvtpd2ps)

Added a missing memory folding relationship for the (V)CVTPD2PS instruction - we can safely fold these for stack reloads.

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

llvm-svn: 224383

9 years agoMake the assert a bit stronger.
Rafael Espindola [Tue, 16 Dec 2014 22:29:43 +0000 (22:29 +0000)]
Make the assert a bit stronger.

We should get no declarations in here.

llvm-svn: 224382

9 years ago[Hexagon] Removing old XTYPE/BIT instructions and replacing usages.
Colin LeMahieu [Tue, 16 Dec 2014 22:17:09 +0000 (22:17 +0000)]
[Hexagon] Removing old XTYPE/BIT instructions and replacing usages.

llvm-svn: 224381

9 years agoLook at whether TransformTypos returned a different Expr instead of looking at the...
Nick Lewycky [Tue, 16 Dec 2014 22:02:06 +0000 (22:02 +0000)]
Look at whether TransformTypos returned a different Expr instead of looking at the number of uncorrected typos before and after. Correcting one typo may produce an expression with another TypoExpr in it, leading to matching counts even though a typo was corrected.

Fixes PR21925!

llvm-svn: 224380

9 years agomerge consecutive loads that are offset from a base address
Sanjay Patel [Tue, 16 Dec 2014 21:57:18 +0000 (21:57 +0000)]
merge consecutive loads that are offset from a base address

SelectionDAG::isConsecutiveLoad() was not detecting consecutive loads
when the first load was offset from a base address.

This patch recognizes that pattern and subtracts the offset before comparing
the second load to see if it is consecutive.

The codegen change in the new test case improves from:

vmovsd 32(%rdi), %xmm0
vmovsd 48(%rdi), %xmm1
vmovhpd 56(%rdi), %xmm1, %xmm1
vmovhpd 40(%rdi), %xmm0, %xmm0
vinsertf128 $1, %xmm1, %ymm0, %ymm0

To:

vmovups 32(%rdi), %ymm0

An existing test case is also improved from:

vmovsd (%rdi), %xmm0
vmovsd 16(%rdi), %xmm1
vmovsd 24(%rdi), %xmm2
vunpcklpd %xmm2, %xmm0, %xmm0 ## xmm0 = xmm0[0],xmm2[0]
vmovhpd 8(%rdi), %xmm1, %xmm3

To:

vmovsd (%rdi), %xmm0
vmovsd 16(%rdi), %xmm1
vmovhpd 24(%rdi), %xmm0, %xmm0
vmovhpd 8(%rdi), %xmm1, %xmm1

This patch fixes PR21771 ( http://llvm.org/bugs/show_bug.cgi?id=21771 ).

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

llvm-svn: 224379

9 years agoFix handling of invalid -O options.
Rafael Espindola [Tue, 16 Dec 2014 21:57:03 +0000 (21:57 +0000)]
Fix handling of invalid -O options.

We were checking the value after truncating it to a bitfield.

Thanks to Yunzhong Gao for noticing it.

llvm-svn: 224378

9 years agoFix typo in comment. NFC.
Nick Lewycky [Tue, 16 Dec 2014 21:48:39 +0000 (21:48 +0000)]
Fix typo in comment. NFC.

llvm-svn: 224377

9 years agoFix a bug in llvm-objdump’s -private-headers for the LC_VERSION_MIN_IPHONEOS
Kevin Enderby [Tue, 16 Dec 2014 21:48:27 +0000 (21:48 +0000)]
Fix a bug in llvm-objdump’s -private-headers for the LC_VERSION_MIN_IPHONEOS
load command not getting printed.

llvm-svn: 224376

9 years agoAdd a new flag, -fspell-checking-limit=<number> to control how many times we'll do...
Nick Lewycky [Tue, 16 Dec 2014 21:39:02 +0000 (21:39 +0000)]
Add a new flag, -fspell-checking-limit=<number> to control how many times we'll do spell checking. Note that spell checking will change the produced AST, so we don't automatically change this value when someone sets -ferror-limit=. With this, merge test typo-correction-pt2.cpp into typo-correction.cpp.

Remove Sema::UnqualifiedTyposCorrected, a cache of corrected typos. It would only cache typo corrections that didn't provide ValidateCandidate of which there were few left, and it had a bug when we had the same identifier spelled wrong twice. See the last two tests in typo-correction.cpp for cases this fires.

llvm-svn: 224375

9 years ago[Hexagon] Adding tstbit/bitclr/bitset instructions.
Colin LeMahieu [Tue, 16 Dec 2014 21:28:58 +0000 (21:28 +0000)]
[Hexagon] Adding tstbit/bitclr/bitset instructions.

llvm-svn: 224374

9 years agoImprove the performance of the libc++ std::map formatter. This is not the full soluti...
Enrico Granata [Tue, 16 Dec 2014 21:28:16 +0000 (21:28 +0000)]
Improve the performance of the libc++ std::map formatter. This is not the full solution to the slowness of this formatter, but it's a 5% improvement in our testcase performance, which I am not going to complain too hard about.

llvm-svn: 224373

9 years ago[sanitizer] prevent function call merging for sanitizer-coverage callbacks
Kostya Serebryany [Tue, 16 Dec 2014 21:24:15 +0000 (21:24 +0000)]
[sanitizer] prevent function call merging for sanitizer-coverage callbacks

llvm-svn: 224372

9 years agoMove -Wkeyword-macro into -pedantic, remove -Wreserved-id-macro.
Nico Weber [Tue, 16 Dec 2014 21:16:10 +0000 (21:16 +0000)]
Move -Wkeyword-macro into -pedantic, remove -Wreserved-id-macro.

As discussed on the post-commit review thread for r224012, -Wkeyword-macro fires
mostly on headers trying to set up portable defines and doesn't find much bad
stuff in practice.  But [macro.names]p2 does disallow defining or undefining
keywords, override and final, and alignas, so keep the warning but move it
into -pedantic.

-Wreserved-id-macro warns on

    #define __need_size_t

which is more or less public api for glibc headers. Since this warning isn't
motivated by a standard, remove it.

(See also r223114 for a previous follow-up to r224012.)

llvm-svn: 224371

9 years ago[asan] trying to fix Mac build
Kostya Serebryany [Tue, 16 Dec 2014 21:06:07 +0000 (21:06 +0000)]
[asan] trying to fix Mac build

llvm-svn: 224370

9 years agoPut static local variables of inline functions in the function comdat.
Rafael Espindola [Tue, 16 Dec 2014 21:00:30 +0000 (21:00 +0000)]
Put static local variables of inline functions in the function comdat.

The variable (and the GV) is only ever used if the function is. Putting it
in the function's comdat make it easier for the linker to discard them.

The motivating example is

struct S {
  static const int x;
};
// const int S::x = 42;
inline const int *f() {
  static const int y = S::x;
  return &y;
}
const int *g() { return f(); }

With S::x commented out, _ZZ1fvE1y is a variable with a guard variable
that is initialized by f.

With S::x present, _ZZ1fvE1y is a constant.

llvm-svn: 224369

9 years agoFix another use of PRIx32 that should have been PRIx64.
Kevin Enderby [Tue, 16 Dec 2014 21:00:25 +0000 (21:00 +0000)]
Fix another use of PRIx32 that should have been PRIx64.

llvm-svn: 224368

9 years ago[Hexagon] Adding bit count and twiddling instructions.
Colin LeMahieu [Tue, 16 Dec 2014 20:57:56 +0000 (20:57 +0000)]
[Hexagon] Adding bit count and twiddling instructions.

llvm-svn: 224367

9 years agoFix Win build after r224353: void function returning zero.
Hans Wennborg [Tue, 16 Dec 2014 20:46:05 +0000 (20:46 +0000)]
Fix Win build after r224353: void function returning zero.

llvm-svn: 224366

9 years ago[Hexagon] Adding asr/lsr/asl reg/imm, asl with saturation, asr with rounding. Double...
Colin LeMahieu [Tue, 16 Dec 2014 20:40:23 +0000 (20:40 +0000)]
[Hexagon] Adding asr/lsr/asl reg/imm, asl with saturation, asr with rounding.  Doubleword abs/neg/not.  Interleave and deinterleave instructions.

llvm-svn: 224365

9 years agoFixes wrong -march=aarch64 option in compiler-rt
Renato Golin [Tue, 16 Dec 2014 20:31:37 +0000 (20:31 +0000)]
Fixes wrong -march=aarch64 option in compiler-rt

llvm-svn: 224362

9 years ago[dsymutil] Pass the verbosity flag down to the processing. NFC for now.
Frederic Riss [Tue, 16 Dec 2014 20:22:11 +0000 (20:22 +0000)]
[dsymutil] Pass the verbosity flag down to the processing. NFC for now.

llvm-svn: 224361

9 years ago[dsymutil] Avoid calling getStringTableData() for each symbol. NFC.
Frederic Riss [Tue, 16 Dec 2014 20:21:34 +0000 (20:21 +0000)]
[dsymutil] Avoid calling getStringTableData() for each symbol. NFC.

llvm-svn: 224360

9 years agox86-32: PUSHF/POPF use/def EFLAGS
JF Bastien [Tue, 16 Dec 2014 20:15:45 +0000 (20:15 +0000)]
x86-32: PUSHF/POPF use/def EFLAGS

Summary: As a side-quest for D6629 jvoung pointed out that I should use -verify-machineinstrs and this found a bug in x86-32's handling of EFLAGS for PUSHF/POPF. This patch fixes the use/def, and adds -verify-machineinstrs to all x86 tests which contain 'EFLAGS'. One exception: this patch leaves inline-asm-fpstack.ll as-is because it fails -verify-machineinstrs in a way unrelated to EFLAGS. This patch also modifies cmpxchg-clobber-flags.ll along the lines of what D6629 already does by also testing i386.

Test Plan: ninja check

Reviewers: t.p.northover, jvoung

Subscribers: llvm-commits

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

llvm-svn: 224359

9 years agoConsider calls from implict host device functions as valid in SemaCUDA.
Jacques Pienaar [Tue, 16 Dec 2014 20:12:38 +0000 (20:12 +0000)]
Consider calls from implict host device functions as valid in SemaCUDA.

In SemaCUDA all implicit functions were considered host device, this led to
errors such as the following code snippet failing to compile:

struct Copyable {
  const Copyable& operator=(const Copyable& x) { return *this; }
};

struct Simple {
  Copyable b;
};

void foo() {
  Simple a, b;

  a = b;
}

Above the implicit copy assignment operator was inferred as host device but
there was only a host assignment copy defined which is an error in device
compilation mode.

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

llvm-svn: 224358

9 years agoUse the object's package to mangle method names, rather than the receiver's package
Peter Collingbourne [Tue, 16 Dec 2014 20:04:55 +0000 (20:04 +0000)]
Use the object's package to mangle method names, rather than the receiver's package

If we use the receiver's package, we can end up with identical manglings
for different functions. Consider:

package p
type U struct{}
func (U) f()

package q
import "p"
type T struct { p.U }
func (T) f()

The method set of *T has two synthetic methods named (*T).f(); one forwards to
(T).f(), and the other to (U).f(). Previously, we were distinguishing them
by the receiver's package, and in this case because both methods have the
same receiver, they received the same name.

The methods are correctly distinguished by the package owning the identifier
"f", which is available via f.Object().Pkg().

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

llvm-svn: 224357

9 years agoUse CastInst::castIsValid to simplify the verifier.
Rafael Espindola [Tue, 16 Dec 2014 19:29:29 +0000 (19:29 +0000)]
Use CastInst::castIsValid to simplify the verifier.

Also delete a dead member variable.

llvm-svn: 224356

9 years agoNVPTX: Remove duplicate of AsmPrinter::lowerConstant
Matt Arsenault [Tue, 16 Dec 2014 19:16:17 +0000 (19:16 +0000)]
NVPTX: Remove duplicate of AsmPrinter::lowerConstant

llvm-svn: 224355