platform/upstream/llvm.git
9 years agoFix sign extension for MIPS64 in makeLibCall function
Petar Jovanovic [Mon, 23 Mar 2015 12:28:13 +0000 (12:28 +0000)]
Fix sign extension for MIPS64 in makeLibCall function

Fixing sign extension in makeLibCall for MIPS64. In MIPS64 architecture all
32 bit arguments (int, unsigned int, float 32 (soft float)) must be sign
extended. This fixes test "MultiSource/Applications/oggenc/".

Patch by Strahinja Petrovic.

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

llvm-svn: 232943

9 years ago[ARM] Fix entry point for Thumb code
Denis Protivensky [Mon, 23 Mar 2015 11:38:24 +0000 (11:38 +0000)]
[ARM] Fix entry point for Thumb code

Test cases for both entry functions in ARM and Thumb
code are added.

llvm-svn: 232942

9 years ago[aarch64] Distinguish the 'Q' and 'm' inline assembly memory constraints.
Daniel Sanders [Mon, 23 Mar 2015 11:33:15 +0000 (11:33 +0000)]
[aarch64] Distinguish the 'Q' and 'm' inline assembly memory constraints.

Summary:
But still handle them the same way since I don't know how they differ on
this target.

Clang also has code for 'Ump', 'Utf', 'Usa', and 'Ush' but calls
llvm_unreachable() on this code path so they are not converted to a
constraint id at the moment.

No functional change intended.

Reviewers: t.p.northover

Subscribers: aemerson, llvm-commits

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

llvm-svn: 232941

9 years agohandle armeb/thumb/thumbeb consistently in gnutools::Assemble::ConstructJob
Scott Douglass [Mon, 23 Mar 2015 10:54:24 +0000 (10:54 +0000)]
handle armeb/thumb/thumbeb consistently in gnutools::Assemble::ConstructJob

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

llvm-svn: 232940

9 years agoConvert cascading if-else-if to switch. NFC
Scott Douglass [Mon, 23 Mar 2015 10:46:28 +0000 (10:46 +0000)]
Convert cascading if-else-if to switch. NFC

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

llvm-svn: 232939

9 years ago[ELF] Add missing override keyword
Simon Atanasyan [Mon, 23 Mar 2015 10:33:46 +0000 (10:33 +0000)]
[ELF] Add missing override keyword

No functional changes.

llvm-svn: 232938

9 years ago[libsanitizer] Fix OpenFile() usage in TSan and DFSan.
Alexander Potapenko [Mon, 23 Mar 2015 10:32:28 +0000 (10:32 +0000)]
[libsanitizer] Fix OpenFile() usage in TSan and DFSan.
This is a follow-up for r232936.

llvm-svn: 232937

9 years ago[ASan] Distinguish between read, write and read-write file access modes in OpenFile.
Alexander Potapenko [Mon, 23 Mar 2015 10:10:46 +0000 (10:10 +0000)]
[ASan] Distinguish between read, write and read-write file access modes in OpenFile.
This is to fix mapping coverage files into memory on OSX.

llvm-svn: 232936

9 years ago[SDAG] Don't widen VSETCC during type legalization for split operands
Hal Finkel [Mon, 23 Mar 2015 08:22:43 +0000 (08:22 +0000)]
[SDAG] Don't widen VSETCC during type legalization for split operands

Because the operands of a vector SETCC node can be of a different type from the
result (and often are), it can happen that even if we'd prefer to widen the
result type of the SETCC, the operands have been split instead. In this case,
the SETCC result also must be split. This mirrors what is done in
WidenVecRes_SELECT, and should be NFC elsewhere because if the operands are not
widened the following calls to GetWidenedVector will assert (which is what was
happening in the test case).

llvm-svn: 232935

9 years agoDrop -polly-vectorizer-unroll-only option
Tobias Grosser [Mon, 23 Mar 2015 07:00:36 +0000 (07:00 +0000)]
Drop -polly-vectorizer-unroll-only option

This options was earlier used for experiments with the vectorizer, but to my
knowledge is not really used anymore. If anybody needs this, we can always
reintroduce this feature.

llvm-svn: 232934

9 years ago[OPENMP] Fixed test for 'single' directive codegen.
Alexey Bataev [Mon, 23 Mar 2015 06:40:37 +0000 (06:40 +0000)]
[OPENMP] Fixed test for 'single' directive codegen.

llvm-svn: 232933

9 years ago[OPENMP] Codegen for 'copyprivate' clause ('single' directive).
Alexey Bataev [Mon, 23 Mar 2015 06:18:07 +0000 (06:18 +0000)]
[OPENMP] Codegen for 'copyprivate' clause ('single' directive).

If there is at least one 'copyprivate' clause is associated with the single directive, the following code is generated:

```
i32 did_it = 0;                                  \\ for 'copyprivate' clause
if(__kmpc_single(ident_t *, gtid)) {
  SingleOpGen();
  __kmpc_end_single(ident_t *, gtid);
  did_it = 1;                                    \\ for 'copyprivate' clause
}
<copyprivate_list>[0] = &var0;
...
<copyprivate_list>[n] = &varn;
call __kmpc_copyprivate(ident_t *, gtid, <copyprivate_list_size>,
                        <copyprivate_list>, <copy_func>, did_it);

...

void<copy_func>(void *LHSArg, void *RHSArg) {
  Dst = (void * [n])(LHSArg);
  Src = (void * [n])(RHSArg);
  Dst[0] = Src[0];
  ... Dst[n] = Src[n];
}
```
All list items from all 'copyprivate' clauses are gathered into single <copyprivate list> (<copyprivate_list_size> is a size in bytes of this list) and <copy_func> is used to propagate values of private or threadprivate variables from the 'single' region to other implicit threads from outer 'parallel' region.
Differential Revision: http://reviews.llvm.org/D8410

llvm-svn: 232932

9 years ago[Orc] Add missing -use-orcmcjit flag to a number of Orc regression tests.
Lang Hames [Mon, 23 Mar 2015 06:02:49 +0000 (06:02 +0000)]
[Orc] Add missing -use-orcmcjit flag to a number of Orc regression tests.

llvm-svn: 232931

9 years agoRevert "Add CodeGen support for adding cpu attributes on functions based on"
Daniel Jasper [Mon, 23 Mar 2015 05:52:28 +0000 (05:52 +0000)]
Revert "Add CodeGen support for adding cpu attributes on functions based on"

This breaks CodeGen for an internal target. I'll get repro instructions
to you.

llvm-svn: 232930

9 years agoFix typo 'AVX too' instead of 'AVX2'
Craig Topper [Mon, 23 Mar 2015 04:17:11 +0000 (04:17 +0000)]
Fix typo 'AVX too' instead of 'AVX2'

llvm-svn: 232929

9 years ago[modules] Remove redundant import of lexical decls when building a lookup table
Richard Smith [Mon, 23 Mar 2015 03:25:59 +0000 (03:25 +0000)]
[modules] Remove redundant import of lexical decls when building a lookup table
for a DeclContext, and fix propagation of exception specifications along
redeclaration chains.

This reverts r232905, r232907, and r232907, which reverted r232793, r232853,
and r232853.

One additional change is present here to resolve issues with LLDB: distinguish
between whether lexical decls missing from the lookup table are local or are
provided by the external AST source, and still look in the external source if
that's where they came from.

llvm-svn: 232928

9 years ago[X86] Add one stepping of Broadwell to the CPU name autodetection for march=native.
Craig Topper [Mon, 23 Mar 2015 00:15:06 +0000 (00:15 +0000)]
[X86] Add one stepping of Broadwell to the CPU name autodetection for march=native.

llvm-svn: 232927

9 years agoUse POSIX pid_t and not lldb::pid_t.
Davide Italiano [Sun, 22 Mar 2015 23:43:58 +0000 (23:43 +0000)]
Use POSIX pid_t and not lldb::pid_t.

The latter is uint64_t beacuse lldb supports arbitrary pid/platforms
but in this case we're using it as return value for fork() which might
return -1 to the parent in case the syscall fails.

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

llvm-svn: 232926

9 years agoAdd missing #include to fix libc++ Linux build.
Richard Smith [Sun, 22 Mar 2015 23:18:46 +0000 (23:18 +0000)]
Add missing #include to fix libc++ Linux build.

llvm-svn: 232925

9 years ago[ASTMatchers] Factor wrapping matcher classes into a common base class.
Benjamin Kramer [Sun, 22 Mar 2015 21:57:53 +0000 (21:57 +0000)]
[ASTMatchers] Factor wrapping matcher classes into a common base class.

The deduplication here is negligible, but it allows the compiler to
skip emission of many templated base class destructors. Shrinks
clang-query by 53k. No functionality change intended.

llvm-svn: 232924

9 years agoSilence a GCC warning
David Majnemer [Sun, 22 Mar 2015 21:27:10 +0000 (21:27 +0000)]
Silence a GCC warning

llvm-svn: 232923

9 years agoFoldingSet: Make FoldingSetImpl's dtor protected and non-virtual
Benjamin Kramer [Sun, 22 Mar 2015 18:22:33 +0000 (18:22 +0000)]
FoldingSet: Make FoldingSetImpl's dtor protected and non-virtual

It's not intended to be polymorphically deleted. Make FoldingSet
and ContextualFoldingSet final to avoid noise from -Wnon-virtual-dtor.

No functional change intended.

llvm-svn: 232922

9 years ago[Analyzer] Don't inherit from FoldingSet.
Benjamin Kramer [Sun, 22 Mar 2015 18:16:22 +0000 (18:16 +0000)]
[Analyzer] Don't inherit from FoldingSet.

That's not really necessary here. NFCI.

llvm-svn: 232921

9 years agoFix a flaky heap-overflow-large.cc test
Kuba Brecka [Sun, 22 Mar 2015 18:00:58 +0000 (18:00 +0000)]
Fix a flaky heap-overflow-large.cc test

Reviewed at http://reviews.llvm.org/D8515

llvm-svn: 232920

9 years ago[Mips] Pass type of relocation and addendum to the `calculateRelocation`
Simon Atanasyan [Sun, 22 Mar 2015 16:35:08 +0000 (16:35 +0000)]
[Mips] Pass type of relocation and addendum to the `calculateRelocation`
separately

This change reduce difference between the trunk and upcoming patch and
simplify the future code review.

No functional changes.

llvm-svn: 232919

9 years agoUpdate unit test for r232916.
Benjamin Kramer [Sun, 22 Mar 2015 16:05:46 +0000 (16:05 +0000)]
Update unit test for r232916.

llvm-svn: 232918

9 years agoPrevent CHECK-NOTs from matching file paths
Duncan P. N. Exon Smith [Sun, 22 Mar 2015 15:58:21 +0000 (15:58 +0000)]
Prevent CHECK-NOTs from matching file paths

A build directory with a name like `build-Werror` would hit a false
positive on these `CHECK-NOT`s before, since the actual error line looks
like:

    .../build-Werror/bin/llvm-as <stdin>:1:2: error: ...

Switch to using:

    CHECK-NOT: error:

(note the trailing semi-colon) to avoid matching almost any file path.

llvm-svn: 232917

9 years ago[multilib] Turn virtual functor into functin_ref
Benjamin Kramer [Sun, 22 Mar 2015 15:56:12 +0000 (15:56 +0000)]
[multilib] Turn virtual functor into functin_ref

And update code to use lambdas where possible, plus random cleanup. NFCI.

llvm-svn: 232916

9 years ago[Mips] Rename template argument ELFType => ELFT
Simon Atanasyan [Sun, 22 Mar 2015 15:41:16 +0000 (15:41 +0000)]
[Mips] Rename template argument ELFType => ELFT

No functional changes.

llvm-svn: 232915

9 years ago[Mips] Use allocator from the base class
Simon Atanasyan [Sun, 22 Mar 2015 15:41:10 +0000 (15:41 +0000)]
[Mips] Use allocator from the base class

No functional changes.

llvm-svn: 232914

9 years agoFixed MSVC compile warning issue introduced in r232837
Simon Pilgrim [Sun, 22 Mar 2015 13:38:36 +0000 (13:38 +0000)]
Fixed MSVC compile warning issue introduced in r232837

- was reporting 'warning C4715: 'getType32' : not all control paths return a value'

llvm-svn: 232913

9 years agoAdd a dump function to Stmt that takes only an output stream. No functionality change.
Faisal Vali [Sun, 22 Mar 2015 13:35:56 +0000 (13:35 +0000)]
Add a dump function to Stmt that takes only an output stream.  No functionality change.

This allows dumping to any given output stream but without requiring a SourceManager, similar to the interface provided by Decl.

It's useful when writing certain generic debug functions, external to the clang code base (for e.g.).

llvm-svn: 232912

9 years agoUse schedule trees to perform post-scheduling transformations
Tobias Grosser [Sun, 22 Mar 2015 12:06:39 +0000 (12:06 +0000)]
Use schedule trees to perform post-scheduling transformations

Replacing the old band_tree based code with code that is based on the new
schedule tree [1] interface makes applying complex schedule transformations a lot
more straightforward. We now do not need to reason about the meaning of flat
schedules, but can use a more straightforward tree structure. We do not yet
exploit this a lot in the current code, but hopefully we will be able to do so
soon.

This change also allows us to drop some code, as isl now provides some higher
level interfaces to apply loop transformations such as tiling.

This change causes some small test case changes as isl uses a slightly different
way to perform loop tiling, but no significant functional changes are intended.

[1] http://impact.gforge.inria.fr/impact2014/papers/impact2014-verdoolaege.pdf

llvm-svn: 232911

9 years agoDemangling for DlAddrSymbolizer
Kuba Brecka [Sun, 22 Mar 2015 11:38:55 +0000 (11:38 +0000)]
Demangling for DlAddrSymbolizer

On OS X, dladdr() provides mangled names only, so we need need to demangle in
DlAddrSymbolizer::SymbolizePC.

Reviewed at http://reviews.llvm.org/D8291

llvm-svn: 232910

9 years agoRemove empty files left behind by r232907.
Benjamin Kramer [Sun, 22 Mar 2015 10:08:31 +0000 (10:08 +0000)]
Remove empty files left behind by r232907.

llvm-svn: 232909

9 years agoAdd AtosSymbolizer and DlAddrSymbolizer as fallbacks for OS X
Kuba Brecka [Sun, 22 Mar 2015 10:02:50 +0000 (10:02 +0000)]
Add AtosSymbolizer and DlAddrSymbolizer as fallbacks for OS X

This patch changes the symbolizer chain on OS X (which currently only uses 1
symbolizer at most) to use this behavior:

* By default, use LLVMSymbolizer -> DlAddrSymbolizer.
* If the llvm-symbolizer binary is not found, use AtosSymbolizer
    -> DlAddrSymbolizer.
* If the user specifies ASAN_SYMBOLIZER_PATH=.../atos, then use AtosSymbolizer
    -> DlAddrSymbolizer.
* If neither llvm-symbolizer or atos is found, or external symbolication is
    disabled with ASAN_SYMBOLIZER_PATH="", use DlAddrSymbolizer.

Reviewed at http://reviews.llvm.org/D8285

llvm-svn: 232908

9 years agoReverting 232853 and 232870 because they depend on 232793,
Vince Harron [Sun, 22 Mar 2015 08:47:07 +0000 (08:47 +0000)]
Reverting 232853 and 232870 because they depend on 232793,
which was reverted because it was causing LLDB test failures

llvm-svn: 232907

9 years agoMS ABI: Implement driver-level support for thread-safe statics
David Majnemer [Sun, 22 Mar 2015 08:39:22 +0000 (08:39 +0000)]
MS ABI: Implement driver-level support for thread-safe statics

Decide whether or not to use thread-safe statics depending on whether or
not we have an explicit request from the driver.  If we don't have an
explicit request, infer which behavior to use depending on the
compatibility version we are targeting.

N.B. CodeGen support is still ongoing.

llvm-svn: 232906

9 years agoReverting r232793 until some new LLDB failures are discussed
Vince Harron [Sun, 22 Mar 2015 05:59:59 +0000 (05:59 +0000)]
Reverting r232793 until some new LLDB failures are discussed

llvm-svn: 232905

9 years agoReverted r232883 due to failing tests.
Vince Harron [Sun, 22 Mar 2015 05:47:00 +0000 (05:47 +0000)]
Reverted r232883 due to failing tests.

llvm-svn: 232904

9 years ago[SimplifyLibCalls] Fix negative shifts being produced by the memchr -> bitfield trans...
Benjamin Kramer [Sat, 21 Mar 2015 22:04:26 +0000 (22:04 +0000)]
[SimplifyLibCalls] Fix negative shifts being produced by the memchr -> bitfield transform.

llvm-svn: 232903

9 years ago[SimplifyLibCalls] Turn memchr(const, C, const) into a bitfield check.
Benjamin Kramer [Sat, 21 Mar 2015 21:09:33 +0000 (21:09 +0000)]
[SimplifyLibCalls] Turn memchr(const, C, const) into a bitfield check.

strchr("123!", C) != nullptr is a common pattern to check if C is one
of 1, 2, 3 or !. If the largest element of the string is smaller than
the target's register size we can easily create a bitfield and just
do a simple test for set membership.

int foo(char C) { return strchr("123!", C) != nullptr; } now becomes

cmpl $64, %edi ## range check
sbbb %al, %al
movabsq $0xE000200000001, %rcx
btq %rdi, %rcx ## bit test
sbbb %cl, %cl
andb %al, %cl ## and the two conditions
andb $1, %cl
movzbl %cl, %eax ## returning an int
ret

(imho the backend should expand this into a series of branches, but
that's a different story)

The code is currently limited to bit fields that fit in a register, so
usually 64 or 32 bits. Sadly, this misses anything using alpha chars
or {}. This could be fixed by just emitting a i128 bit field, but that
can generate really ugly code so we have to find a better way. To some
degree this is also recreating switch lowering logic, but we can't
simply emit a switch instruction and thus change the CFG within
instcombine.

llvm-svn: 232902

9 years agoR600: Cleanup test with multiple check prefixes
Matt Arsenault [Sat, 21 Mar 2015 19:15:46 +0000 (19:15 +0000)]
R600: Cleanup test with multiple check prefixes

llvm-svn: 232901

9 years ago-Wdynamic-class-memaccess: Also warn about array types.
Nico Weber [Sat, 21 Mar 2015 17:56:44 +0000 (17:56 +0000)]
-Wdynamic-class-memaccess: Also warn about array types.

It looks like not warning on this was an oversight in the original
implementation of this warning.

llvm-svn: 232900

9 years agoDedent code for -Wdynamic-class-memaccess warning. No behavior change.
Nico Weber [Sat, 21 Mar 2015 17:37:46 +0000 (17:37 +0000)]
Dedent code for -Wdynamic-class-memaccess warning. No behavior change.

The diff looks intimidating, but this just moves the -Wdynamic-class-memaccess
code out a scope, protected by a

    if (PointeeTy == QualType())
      continue;

check so that it still only runs when it should.

llvm-svn: 232899

9 years agoStringRef: Just forward StringRef::find to libc's memchr.
Benjamin Kramer [Sat, 21 Mar 2015 16:42:35 +0000 (16:42 +0000)]
StringRef: Just forward StringRef::find to libc's memchr.

Modern libc's have an SSE version of memchr which is a lot faster than our
hand-rolled version. In the past I was reluctant to use it because Darwin's
memchr used a naive ridiculously slow implementation, but that has been fixed
some versions ago.

Should have zero functional impact.

llvm-svn: 232898

9 years agoRevert accidental commit.
Benjamin Kramer [Sat, 21 Mar 2015 15:37:32 +0000 (15:37 +0000)]
Revert accidental commit.

While this is a fun change, I didn't really test it :)

llvm-svn: 232897

9 years agoSimplifyLibCalls: Add basic optimization of memchr calls.
Benjamin Kramer [Sat, 21 Mar 2015 15:36:21 +0000 (15:36 +0000)]
SimplifyLibCalls: Add basic optimization of memchr calls.

This is just memchr(x, y, 0) -> nullptr and constant folding.

llvm-svn: 232896

9 years agoValueTracking: Forward getConstantStringInfo's TrimAtNul param into recursive invocation
Benjamin Kramer [Sat, 21 Mar 2015 15:36:06 +0000 (15:36 +0000)]
ValueTracking: Forward getConstantStringInfo's TrimAtNul param into recursive invocation

Currently this is only used to tweak the backend's memcpy inlining
heuristics, testing that isn't very helpful. A real test case will
follow in the next commit, where this behavior would cause a real
miscompilation.

llvm-svn: 232895

9 years agoTidied up vec_zero_cse.ll test. NFCI.
Simon Pilgrim [Sat, 21 Mar 2015 14:05:12 +0000 (14:05 +0000)]
Tidied up vec_zero_cse.ll test. NFCI.

Added target triple and refactored the CHECKs to be per function.

llvm-svn: 232894

9 years agoSmall test fix for r232890
Alexander Musman [Sat, 21 Mar 2015 11:49:27 +0000 (11:49 +0000)]
Small test fix for r232890

llvm-svn: 232893

9 years agoCompare pointers directly instead of ::strcmp in SBXxx::EventIsXxxEvent()
Ilia K [Sat, 21 Mar 2015 11:11:07 +0000 (11:11 +0000)]
Compare pointers directly instead of ::strcmp in SBXxx::EventIsXxxEvent()

llvm-svn: 232892

9 years agoFix handling of CommandInterpreter's events in lldb-mi
Ilia K [Sat, 21 Mar 2015 10:53:37 +0000 (10:53 +0000)]
Fix handling of CommandInterpreter's events in lldb-mi

Summary:
Previously lldb-mi contains a stub for that but it didn't work and all CommanInterpreter's events were ignored.
This commit adds a handling of CommandInterpreter's events in lldb-mi.

Steps:
# Fix CMICmnLLDBDebugger::InitSBListener
# Add SBCommandInterpreter::EventIsCommandInterpreterEvent
# Exit on lldb::SBCommandInterpreter::eBroadcastBitQuitCommandReceived

All tests pass on OS X.

In further we can remove "quit" hack in lldb-mi.

Test Plan:
# Create start_script file:
```
target create ~/p/hello
b main
r
quit
```

# Run lldb-mi --interpreter
# Execute start_script file by following command:
```
-interpreter-exec console "command source start_script"
```

Log:
```
$ bin/lldb-mi --interpreter
(gdb)
-interpreter-exec console "command source start_script"
Executing commands in '/Users/IliaK/p/llvm/build_ninja/start_script'.
(lldb) target create ~/p/hello
Current executable set to '~/p/hello' (x86_64).
(lldb) b main
Breakpoint 1: where = hello`main + 29 at hello.cpp:12, address = 0x0000000100000e2d
(lldb) r
Process 1582 launched: '/Users/IliaK/p/hello' (x86_64)
(lldb) quit
^done
(gdb)
=thread-created,id="1",group-id="i1"
=thread-selected,id="1"
(gdb)
=shlibs-added,shlib-info=[num="1",name="hello",dyld-addr="-",reason="dyld",path="/Users/IliaK/p/hello",loaded_addr="-",dsym-objpath="/Users/IliaK/p/hello.dSYM/Contents/Resources/DWARF/hello"]
...
=shlibs-added,shlib-info=[num="132",name="libDiagnosticMessagesClient.dylib",dyld-addr="0x7fff91705000",reason="dyld",path="/usr/lib/libDiagnosticMessagesClient.dylib",loaded_addr="0x7fff91705000"]
(gdb)
*stopped,reason="breakpoint-hit",disp="del",bkptno="1",frame={addr="0x100000e2d",func="main",args=[{name="argc",value="1"},{name="argv",value="0x00007fff5fbffc88"}],file="hello.cpp",fullname="/Users/IliaK/p/hello.cpp",line="12"},thread-id="1",stopped-threads="all"
(gdb)<press Enter>

MI: Program exited OK
```

Reviewers: abidh, clayborg

Reviewed By: abidh

Subscribers: jingham, lldb-commits, clayborg, abidh

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

llvm-svn: 232891

9 years ago[OPENMP] CodeGen of the 'linear' clause for the 'omp simd' directive.
Alexander Musman [Sat, 21 Mar 2015 10:12:56 +0000 (10:12 +0000)]
[OPENMP] CodeGen of the 'linear' clause for the 'omp simd' directive.
The linear variable is privatized (similar to 'private') and its
value on current iteration is calculated, similar to the loop
counter variables.
Differential revision: http://reviews.llvm.org/D8375

llvm-svn: 232890

9 years agoMemoryDependenceAnalysis: Don't miscompile atomics
David Majnemer [Sat, 21 Mar 2015 06:19:17 +0000 (06:19 +0000)]
MemoryDependenceAnalysis: Don't miscompile atomics

r216771 introduced a change to MemoryDependenceAnalysis that allowed it
to reason about acquire/release operations.  However, this change does
not ensure that the acquire/release operations pair.  Unfortunately,
this leads to miscompiles as we won't see an acquire load as properly
memory effecting.  This largely reverts r216771.

This fixes PR22708.

llvm-svn: 232889

9 years agoAdd CodeGen support for adding cpu attributes on functions based on
Eric Christopher [Sat, 21 Mar 2015 06:15:15 +0000 (06:15 +0000)]
Add CodeGen support for adding cpu attributes on functions based on
the target-cpu, if different from the triple's cpu, and
target-features as they're written that are passed down from the
driver.

Together with LLVM r232885 this should allow the LTO'ing of binaries
that contain modules compiled with different code generation options
on a subset of architectures with full backend support (x86, powerpc,
aarch64).

llvm-svn: 232888

9 years agoRemove unneeded redeclaration of reference_wrapper.
Eric Fiselier [Sat, 21 Mar 2015 06:05:45 +0000 (06:05 +0000)]
Remove unneeded redeclaration of reference_wrapper.

llvm-svn: 232887

9 years agoAArch64: simplify test case
Tim Northover [Sat, 21 Mar 2015 04:37:08 +0000 (04:37 +0000)]
AArch64: simplify test case

llvm-svn: 232886

9 years agoRemove the target independent TargetMachine::getSubtarget and
Eric Christopher [Sat, 21 Mar 2015 04:22:23 +0000 (04:22 +0000)]
Remove the target independent TargetMachine::getSubtarget and
TargetMachine::getSubtargetImpl routines.

This keeps the target independent code free of bare subtarget
calls while the remainder of the backends are migrated, or not
if they don't wish to support per-function subtargets as would
be needed for function multiversioning or LTO of disparate
cpu subarchitecture types, e.g.

clang -msse4.2 -c foo.c -emit-llvm -o foo.bc
clang -c bar.c -emit-llvm -o bar.bc
llvm-link foo.bc bar.bc -o baz.bc
llc baz.bc

and get appropriate code for what the command lines requested.

llvm-svn: 232885

9 years agoRemove the bare getSubtargetImpl call from the AArch64 port. As part
Eric Christopher [Sat, 21 Mar 2015 04:04:50 +0000 (04:04 +0000)]
Remove the bare getSubtargetImpl call from the AArch64 port. As part
of this add a test that shows we can generate code for functions
that specifically enable a subtarget feature.

llvm-svn: 232884

9 years agoFix ComputeSupportExeDirectory for Linux (merge with Android).
Chaoren Lin [Sat, 21 Mar 2015 03:59:29 +0000 (03:59 +0000)]
Fix ComputeSupportExeDirectory for Linux (merge with Android).

Summary:
ComputeSupportExeDirectory relied on ComputeSharedLibraryDirectory which was
not always reliable. Using procfs seems to be the best way to deal with it on
Linux (since it's already done on Android, might as well merge it).

Reviewers: ovyalov

Reviewed By: ovyalov

Subscribers: lldb-commits

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

llvm-svn: 232883

9 years agoRemove the bare getSubtargetImpl call from the PPC port. As part
Eric Christopher [Sat, 21 Mar 2015 03:36:02 +0000 (03:36 +0000)]
Remove the bare getSubtargetImpl call from the PPC port. As part
of this add a test that shows we can generate code with
for functions that differ by subtarget feature.

llvm-svn: 232882

9 years agoForward the Function based getSubtarget call to the appropriate Impl
Eric Christopher [Sat, 21 Mar 2015 03:32:45 +0000 (03:32 +0000)]
Forward the Function based getSubtarget call to the appropriate Impl
call.

llvm-svn: 232881

9 years agoGrab a subtarget off of an AMDGPUTargetMachine rather than a
Eric Christopher [Sat, 21 Mar 2015 03:17:25 +0000 (03:17 +0000)]
Grab a subtarget off of an AMDGPUTargetMachine rather than a
bare target machine in preparation for the TargetMachine bare
getSubtarget/getSubtargetImpl calls going away.

llvm-svn: 232880

9 years agoCache the Function dependent subtarget on the MachineFunction.
Eric Christopher [Sat, 21 Mar 2015 03:13:10 +0000 (03:13 +0000)]
Cache the Function dependent subtarget on the MachineFunction.

As preparation for removing the getSubtargetImpl() call from
TargetMachine go ahead and flip the switch on caching the function
dependent subtarget and remove the bare getSubtargetImpl call
from the X86 port. As part of this add a few tests that show we
can generate code and assemble on X86 based on features/cpu on
the Function.

llvm-svn: 232879

9 years agoGrab the cached subtarget off of the MachineFunction.
Eric Christopher [Sat, 21 Mar 2015 03:13:07 +0000 (03:13 +0000)]
Grab the cached subtarget off of the MachineFunction.

llvm-svn: 232878

9 years agoGrab a subtarget off of a MipsTargetMachine rather than a
Eric Christopher [Sat, 21 Mar 2015 03:13:05 +0000 (03:13 +0000)]
Grab a subtarget off of a MipsTargetMachine rather than a
bare target machine in preparation for the TargetMachine bare
getSubtarget/getSubtargetImpl calls going away.

llvm-svn: 232877

9 years agoSimplify the query for a subtarget in the NVPTX pass manager.
Eric Christopher [Sat, 21 Mar 2015 03:13:03 +0000 (03:13 +0000)]
Simplify the query for a subtarget in the NVPTX pass manager.

llvm-svn: 232876

9 years agoChange getISAEncoding to use the target triple to determine
Eric Christopher [Sat, 21 Mar 2015 03:13:01 +0000 (03:13 +0000)]
Change getISAEncoding to use the target triple to determine
thumb-ness similar to the rest of the Module level asm printing
infrastructure as debug info finalization happens after the function
may be missing.

llvm-svn: 232875

9 years agoMake the Hexagon ISelDAGToDAG pass set the subtarget dynamically
Eric Christopher [Sat, 21 Mar 2015 03:12:59 +0000 (03:12 +0000)]
Make the Hexagon ISelDAGToDAG pass set the subtarget dynamically
on each runOnMachineFunction invocation.

llvm-svn: 232874

9 years ago[sanitizer] experimental tracing for cmp instructions
Kostya Serebryany [Sat, 21 Mar 2015 01:29:36 +0000 (01:29 +0000)]
[sanitizer] experimental tracing for cmp instructions

llvm-svn: 232873

9 years ago[CodeGen][IfCvt] Don't re-ifcvt blocks with unanalyzable terminators.
Ahmed Bougacha [Sat, 21 Mar 2015 01:23:15 +0000 (01:23 +0000)]
[CodeGen][IfCvt] Don't re-ifcvt blocks with unanalyzable terminators.

If we couldn't analyze its terminator (i.e., it's an indirectbr, or some
other weirdness), we can't safely re-if-convert a predicated block,
because we can't tell whether the predicated terminator can
fallthrough (it does).

Currently, we would completely ignore the fallthrough successor. In
the added testcase, this means we used to generate:

    ...
  @ %entry:
    cmp   r5, #21
    ittt  ne
  @ %cc1f:
    cmpne r7, #42
  @ %cc2t:
    strne.w       r5, [r8]
    movne pc, r10
  @ %cc1t:
    ...

Whereas the successor of %cc1f was originally %bb1.
With the fix, we get the correct:

    ...
  @ %entry:
    cmp   r5, #21
    itt   eq
  @ %cc1t:
    streq.w       r5, [r11]
    moveq pc, r0
  @ %cc1f:
    cmp   r7, #42
    itt   ne
  @ %cc2t:
    strne.w       r5, [r8]
    movne pc, r10
  @ %bb1:
    ...

rdar://20192768
Differential Revision: http://reviews.llvm.org/D8509

llvm-svn: 232872

9 years ago[AArch64] Prefer UZP for concat_vector of illegal truncs.
Ahmed Bougacha [Sat, 21 Mar 2015 01:08:39 +0000 (01:08 +0000)]
[AArch64] Prefer UZP for concat_vector of illegal truncs.

Follow-up to r232459: prefer a UZP shuffle to the intermediate truncs.

llvm-svn: 232871

9 years ago[modules] When either redecl chain merging or an update record causes us to
Richard Smith [Sat, 21 Mar 2015 00:58:54 +0000 (00:58 +0000)]
[modules] When either redecl chain merging or an update record causes us to
give an exception specification to a declaration that didn't have an exception
specification in any of our imported modules, emit an update record ourselves.
Without this, code importing the current module would not see an exception
specification that we could see and might have relied on.

llvm-svn: 232870

9 years agoOnly add -fno-rtti if KernelOrKext or in C++ mode.
Filipe Cabecinhas [Fri, 20 Mar 2015 23:51:15 +0000 (23:51 +0000)]
Only add -fno-rtti if KernelOrKext or in C++ mode.

llvm-svn: 232869

9 years ago[ELF] GLOBAL_OFFSET_TABLE is a hidden symbol
Shankar Easwaran [Fri, 20 Mar 2015 23:47:08 +0000 (23:47 +0000)]
[ELF] GLOBAL_OFFSET_TABLE is a hidden symbol

llvm-svn: 232868

9 years ago[ELF] Dont add local symbols for dynamic lookup.
Shankar Easwaran [Fri, 20 Mar 2015 23:47:05 +0000 (23:47 +0000)]
[ELF] Dont add local symbols for dynamic lookup.

Unable to add a unit test for this, as there is only one local undefined
symbol in regular shared libraries without a name.

llvm-svn: 232867

9 years ago[ELF] OrderPass : Order atoms only by ordinals.
Shankar Easwaran [Fri, 20 Mar 2015 23:47:03 +0000 (23:47 +0000)]
[ELF] OrderPass : Order atoms only by ordinals.

Move the init array/fini array sorting to the Output ELF writer.

AFAIK, this is only needed by the X86_64/ARM ABI.

This shaves time taken to self host lld by 0.2 seconds.

Before patch
----------------
4791.062059 task-clock                #    1.634 CPUs utilized            ( +-  0.28% )
     61,107 context-switches          #    0.013 M/sec                    ( +-  0.56% )
2.932902671 seconds time elapsed                                          ( +-  0.84% )

After patch
-------------
4608.417248 task-clock                #    1.669 CPUs utilized            ( +-  0.30% )
     61,616 context-switches          #    0.013 M/sec                    ( +-  0.63% )
2.761012703 seconds time elapsed                                          ( +-  0.63% )

llvm-svn: 232866

9 years ago[ELF][X86_64] Use anonymous namespace only for class declarations
Shankar Easwaran [Fri, 20 Mar 2015 23:47:01 +0000 (23:47 +0000)]
[ELF][X86_64] Use anonymous namespace only for class declarations

llvm-svn: 232865

9 years ago[ELF] Use unordered_map for AdditionalSegments
Shankar Easwaran [Fri, 20 Mar 2015 23:47:00 +0000 (23:47 +0000)]
[ELF] Use unordered_map for AdditionalSegments

Fix a leftover class during implementation.

llvm-svn: 232864

9 years ago[ELF] Use MapVector.
Shankar Easwaran [Fri, 20 Mar 2015 23:46:58 +0000 (23:46 +0000)]
[ELF] Use MapVector.

Order is still deterministic and we dont need a sorted order.

llvm-svn: 232863

9 years ago[ELF][X86_64] Remove relative references to include files
Shankar Easwaran [Fri, 20 Mar 2015 23:46:56 +0000 (23:46 +0000)]
[ELF][X86_64] Remove relative references to include files

llvm-svn: 232862

9 years ago[ELF][X86_64] Sort includes
Shankar Easwaran [Fri, 20 Mar 2015 23:46:54 +0000 (23:46 +0000)]
[ELF][X86_64] Sort includes

llvm-svn: 232861

9 years agoDon't claim exception related arguments when looking at RTTIMode
Filipe Cabecinhas [Fri, 20 Mar 2015 23:33:23 +0000 (23:33 +0000)]
Don't claim exception related arguments when looking at RTTIMode

Summary:
We were claiming the -f*exceptions arguments when looking for the
RTTIMode. This makes us not warn about unused arguments if compiling a C
file with -fcxx-exceptions.

This patch fixes it by not claiming the exception-related arguments at
that point.

Reviewers: rsmith, samsonov

Subscribers: cfe-commits

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

llvm-svn: 232860

9 years agoMake getLastArgNoClaim work for up to 4 arguments.
Filipe Cabecinhas [Fri, 20 Mar 2015 23:32:58 +0000 (23:32 +0000)]
Make getLastArgNoClaim work for up to 4 arguments.

Summary:
This is needed for http://reviews.llvm.org/D8507
I have no idea what stand-alone tests could be done, if needed.

Reviewers: Bigcheese, craig.topper, samsonov

Subscribers: llvm-commits

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

llvm-svn: 232859

9 years agoImprove automatic detection of filetype for sym_check
Eric Fiselier [Fri, 20 Mar 2015 23:07:38 +0000 (23:07 +0000)]
Improve automatic detection of filetype for sym_check

llvm-svn: 232858

9 years agofixed vperm2* intrinsics to check for shuffles
Sanjay Patel [Fri, 20 Mar 2015 22:37:20 +0000 (22:37 +0000)]
fixed vperm2* intrinsics to check for shuffles

This corresponds to llvm r232852:
http://reviews.llvm.org/rL232852

llvm-svn: 232857

9 years agoFix use of incorrect package name in sym_check
Eric Fiselier [Fri, 20 Mar 2015 22:13:37 +0000 (22:13 +0000)]
Fix use of incorrect package name in sym_check

llvm-svn: 232856

9 years agoAdd symbol checking script to libc++ to help manage exported symbols.
Eric Fiselier [Fri, 20 Mar 2015 22:09:29 +0000 (22:09 +0000)]
Add symbol checking script to libc++ to help manage exported symbols.

Summary:
Add symbol checking scripts for extracting a list of symbols from shared libraries and for comparing symbol lists for differences.

Reviewers: mclow.lists, danalbert, EricWF

Reviewed By: EricWF

Subscribers: majnemer, emaste, cfe-commits

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

llvm-svn: 232855

9 years agoTell lit.cfg about more Windows triples.
Yunzhong Gao [Fri, 20 Mar 2015 22:08:40 +0000 (22:08 +0000)]
Tell lit.cfg about more Windows triples.
For example, the host triple on my 64-bit PC is x86_64-pc-windows-msvc.

llvm-svn: 232854

9 years ago[modules] Remove temporary IdentifierInfo lookup results when we're done with them.
Richard Smith [Fri, 20 Mar 2015 21:56:50 +0000 (21:56 +0000)]
[modules] Remove temporary IdentifierInfo lookup results when we're done with them.

llvm-svn: 232853

9 years ago[X86, AVX] instcombine common cases of vperm2* intrinsics into shuffles
Sanjay Patel [Fri, 20 Mar 2015 21:47:56 +0000 (21:47 +0000)]
[X86, AVX] instcombine common cases of vperm2* intrinsics into shuffles

vperm2* intrinsics are just shuffles.
In a few special cases, they're not even shuffles.

Optimizing intrinsics in InstCombine is better than
handling this in the front-end for at least two reasons:

1. Optimizing custom-written SSE intrinsic code at -O0 makes vector coders
   really angry (and so I have regrets about some patches from last week).

2. Doing mask conversion logic in header files is hard to write and
   subsequently read.

There are a couple of TODOs in this patch to complete this optimization.

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

llvm-svn: 232852

9 years agoFixing a bug with WinEH PHI handling
Andrew Kaylor [Fri, 20 Mar 2015 21:42:54 +0000 (21:42 +0000)]
Fixing a bug with WinEH PHI handling

llvm-svn: 232851

9 years ago[X86] Prefer blendps over insertps codegen for one special case
Sanjay Patel [Fri, 20 Mar 2015 21:19:52 +0000 (21:19 +0000)]
[X86] Prefer blendps over insertps codegen for one special case

With this patch, for this one exact case, we'll generate:

  blendps %xmm0, %xmm1, $1

instead of:

  insertps %xmm0, %xmm1, $0

If there's a memory operand available for load folding and we're
optimizing for size, we'll still generate the insertps.

The detailed performance data motivation for this may be found in D7866;
in summary, blendps has 2-3x throughput vs. insertps on widely used chips.

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

llvm-svn: 232850

9 years ago[analyzer] RetainCountChecker: Don't assume +0 for ivars backing readonly properties.
Jordan Rose [Fri, 20 Mar 2015 21:12:27 +0000 (21:12 +0000)]
[analyzer] RetainCountChecker: Don't assume +0 for ivars backing readonly properties.

Similarly, don't assume +0 if the property's setter is manually implemented.
In both cases, if the property's ownership is explicitly written, then we /do/
assume the ivar has the same ownership.

rdar://problem/20218183

llvm-svn: 232849

9 years agoX86: Make helper functions static. NFC.
Benjamin Kramer [Fri, 20 Mar 2015 21:07:30 +0000 (21:07 +0000)]
X86: Make helper functions static. NFC.

llvm-svn: 232848

9 years agoRemove dead calls and function arguments dealing with TRI in StackMaps.
Eric Christopher [Fri, 20 Mar 2015 21:05:18 +0000 (21:05 +0000)]
Remove dead calls and function arguments dealing with TRI in StackMaps.

llvm-svn: 232847

9 years ago[asan] update the sized_delete_test following the change of clang flags in r232788.
Kostya Serebryany [Fri, 20 Mar 2015 20:45:42 +0000 (20:45 +0000)]
[asan] update the sized_delete_test following the change of clang flags in r232788.

llvm-svn: 232845

9 years agoDebugInfo: Require valid DIDescriptors
Duncan P. N. Exon Smith [Fri, 20 Mar 2015 20:17:07 +0000 (20:17 +0000)]
DebugInfo: Require valid DIDescriptors

As part of PR22777, switch from `dyn_cast_or_null<>` to `cast<>` in most
`DIDescriptor` accessors.  These classes are lightweight wrappers around
pointers, so the users should check for valid pointers before using
them.

This survives a Darwin clang -g bootstrap (after fixing testcases), but
it's possible the bots will complain about other configurations.  I'll
fix any fallout as quickly as I can!  Once this bakes for a bit I'll
remove the macros.

Note that `DebugLoc` implicitly gets stricter with this change as well,
since it forward to `DILocation`.  Any code that's using `DebugLoc`
accessors should check `DebugLoc::isUnknown()` first.  (BTW, I'm also
partway through a cleanup of the `DebugLoc` API to make it more obvious
what it is (a glorified pointer wrapper) and remove cruft from before
the Metadata/Value split.  I'll commit soon.)

llvm-svn: 232844

9 years agoUpdate for llvm api change.
Rafael Espindola [Fri, 20 Mar 2015 20:00:30 +0000 (20:00 +0000)]
Update for llvm api change.

llvm-svn: 232843