platform/upstream/llvm.git
9 years agolibLTO, llvm-lto, gold: Introduce flag for controlling optimization level.
Peter Collingbourne [Thu, 19 Mar 2015 22:01:00 +0000 (22:01 +0000)]
libLTO, llvm-lto, gold: Introduce flag for controlling optimization level.

This change also introduces a link-time optimization level of 1. This
optimization level runs only the globaldce pass as well as cleanup passes for
passes that run at -O0, specifically simplifycfg which cleans up lowerbitsets.

http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20150316/266951.html

llvm-svn: 232769

9 years agoMove LLDB initialization/shutdown to Initialization.
Zachary Turner [Thu, 19 Mar 2015 22:00:21 +0000 (22:00 +0000)]
Move LLDB initialization/shutdown to Initialization.

This creates a new top-level folder called Initialization which
is intended to hold code specific to LLDB system initialization.
Currently this holds the Initialize() and Terminate() functions,
as well as the fatal error handler.

This provides a means to break the massive dependency cycle which
is caused by the fact that Debugger depends on Initialize and
Terminate which then depends on the entire LLDB project.  With
this structure, it will be possible for applications to invoke
lldb_private::Initialize() directly, and have that invoke
Debugger::Initialize.

llvm-svn: 232768

9 years agoFix SBFrame::FindValue for when only global variables exist.
Chaoren Lin [Thu, 19 Mar 2015 22:00:13 +0000 (22:00 +0000)]
Fix SBFrame::FindValue for when only global variables exist.

Summary:
sc.block->AppendVariables(...) returns 0 if there are no arguments or local
variables, but we still need to check for global variables.

Test Plan:
```
$ cat test.cpp
int i;
int main() {
}
$ lldb test -o 'b main' -o r
(lldb) script
>>> print lldb.frame.FindValue('i', lldb.eValueTypeVariableGlobal)
(int) i = 0 # as opposed to "No value"
```

Reviewers: jingham, ovyalov, vharron, clayborg

Reviewed By: clayborg

Subscribers: lldb-commits

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

llvm-svn: 232767

9 years agoMS ABI: Implement the MSVC 2015 scheme for scope disambiguation
David Majnemer [Thu, 19 Mar 2015 21:54:30 +0000 (21:54 +0000)]
MS ABI: Implement the MSVC 2015 scheme for scope disambiguation

consider C++ that looks like:
  inline int &f(bool b) {
    if (b) {
      static int i;
      return i;
    }
    static int i;
    return i;
  }

Both 'i' variables must have distinct (and stable) names for linkage
purposes.  The MSVC 2013 ABI would number the variables using a count of
the number of scopes that have been created.  However, the final 'i'
returns to a scope that has already been created leading to a mangling
collision.

MSVC 2015 fixes this by giving the second 'i' the name it would have if
it were declared before the 'if'.  However, this results in ABI breakage
because the mangled name, in cases where there was no ambiguity, would
now be different.

We implement the new behavior and only enable it if we are targeting the
MSVC 2015 ABI, otherwise the old behavior will be used.

This fixes PR18131.

llvm-svn: 232766

9 years agoPassManagerBuilder: Remove effectively dead 'StripDebug' option
Duncan P. N. Exon Smith [Thu, 19 Mar 2015 21:37:17 +0000 (21:37 +0000)]
PassManagerBuilder: Remove effectively dead 'StripDebug' option

`StripDebug` was only used by tools/opt/opt.cpp in
`AddStandardLinkPasses()`, but opt.cpp adds the same pass based on its
command-line flag before it calls `AddStandardLinkPasses()`.  Stripping
debug info twice isn't very useful.

llvm-svn: 232765

9 years agoCreate macro to allow testing of is_convertible without the compiler builtin.
Eric Fiselier [Thu, 19 Mar 2015 21:11:02 +0000 (21:11 +0000)]
Create macro to allow testing of is_convertible without the compiler builtin.

Summary: This patch also fixes one test case that failed in the library version of is_convertible.

Reviewers: mclow.lists, EricWF

Reviewed By: EricWF

Subscribers: cfe-commits

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

llvm-svn: 232764

9 years ago[sanitizer] fix 'sancov.py merge' and add a test for it
Kostya Serebryany [Thu, 19 Mar 2015 21:01:27 +0000 (21:01 +0000)]
[sanitizer] fix 'sancov.py merge' and add a test for it

llvm-svn: 232763

9 years ago[libcxx] Unify LIBCXX_<ABI-Name>_INCLUDE_PATHS to be LIBCXX_CXX_ABI_INCLUDE_PATHS
Eric Fiselier [Thu, 19 Mar 2015 20:59:45 +0000 (20:59 +0000)]
[libcxx] Unify LIBCXX_<ABI-Name>_INCLUDE_PATHS to be LIBCXX_CXX_ABI_INCLUDE_PATHS

Summary:
Clean up all the different possible CMake options for specifying the ABI include paths into one CMake option named `LIBCXX_CXX_ABI_INCLUDE_PATHS`.
The documentation has been updated to reflect this change.

For the next week I have added explicit errors if any of the old flags is used. These errors inform users of the change and the new option to use.

Before committing the change I will announce this change on cfe-dev.

Reviewers: danalbert, mclow.lists

Reviewed By: danalbert, mclow.lists

Subscribers: jroelofs, cbergstrom, cfe-commits

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

llvm-svn: 232762

9 years ago[Mips] Add comments to the relocation calculation functions
Simon Atanasyan [Thu, 19 Mar 2015 20:56:34 +0000 (20:56 +0000)]
[Mips] Add comments to the relocation calculation functions

No functional changes.

llvm-svn: 232761

9 years agoCorrect typos in C11 generic-selection expressions.
Kaelyn Takata [Thu, 19 Mar 2015 20:56:07 +0000 (20:56 +0000)]
Correct typos in C11 generic-selection expressions.

llvm-svn: 232760

9 years agoSwitch lowering: extract NextBlock function. NFC.
Hans Wennborg [Thu, 19 Mar 2015 20:41:48 +0000 (20:41 +0000)]
Switch lowering: extract NextBlock function. NFC.

llvm-svn: 232759

9 years agoUnxfail test/CodeGen/Generic/vector.ll now passing on Hexagon
Krzysztof Parzyszek [Thu, 19 Mar 2015 20:22:17 +0000 (20:22 +0000)]
Unxfail test/CodeGen/Generic/vector.ll now passing on Hexagon

llvm-svn: 232758

9 years ago[Mips] Implement R_MIPS_PCHI16 / R_MIPS_PCLO16 relocations handling
Simon Atanasyan [Thu, 19 Mar 2015 19:59:17 +0000 (19:59 +0000)]
[Mips] Implement R_MIPS_PCHI16 / R_MIPS_PCLO16 relocations handling

llvm-svn: 232757

9 years ago[Mips] Implement R_MIPS_PC18_S3 relocation handling
Simon Atanasyan [Thu, 19 Mar 2015 19:59:06 +0000 (19:59 +0000)]
[Mips] Implement R_MIPS_PC18_S3 relocation handling

llvm-svn: 232756

9 years ago[Mips] Implement R_MIPS_PC19_S2 / R_MIPS_PC26_S2 relocations handling
Simon Atanasyan [Thu, 19 Mar 2015 19:58:58 +0000 (19:58 +0000)]
[Mips] Implement R_MIPS_PC19_S2 / R_MIPS_PC26_S2 relocations handling

llvm-svn: 232755

9 years ago[sanitizer] trying to fix sancov.py with 32-bit python
Kostya Serebryany [Thu, 19 Mar 2015 19:52:30 +0000 (19:52 +0000)]
[sanitizer] trying to fix sancov.py with 32-bit python

llvm-svn: 232754

9 years agoRemove unused diagnostic.
Benjamin Kramer [Thu, 19 Mar 2015 19:44:37 +0000 (19:44 +0000)]
Remove unused diagnostic.

Unused since r231851.

llvm-svn: 232751

9 years agoAdd -Wpartial-availability.
Nico Weber [Thu, 19 Mar 2015 19:18:22 +0000 (19:18 +0000)]
Add -Wpartial-availability.

This warns when using decls that are not available on all deployment targets.
For example, a call to

  - (void)ppartialMethod __attribute__((availability(macosx,introduced=10.8)));

will warn if -mmacosx-version-min is set to less than 10.8.

To silence the warning, one has to explicitly redeclare the method like so:

  @interface Whatever(MountainLionAPI)
  - (void)ppartialMethod;
  @end

This way, one cannot accidentally call a function that isn't available
everywhere.  Having to add the redeclaration will hopefully remind the user
to add an explicit respondsToSelector: call as well.

Some projects build against old SDKs to get this effect, but building against
old SDKs suppresses some bug fixes -- see http://crbug.com/463171 for examples.
The hope is that SDK headers are annotated well enough with availability
attributes that new SDK + this warning offers the same amount of protection
as using an old SDK.

llvm-svn: 232750

9 years agoRemove .CUDAIsDevice flags from CodeGenOpts as it's already
Artem Belevich [Thu, 19 Mar 2015 18:58:18 +0000 (18:58 +0000)]
Remove .CUDAIsDevice flags from CodeGenOpts as it's already
available in LangOpts.

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

llvm-svn: 232749

9 years agoFix -ast-dump of dependent new and delete exprs
Reid Kleckner [Thu, 19 Mar 2015 18:47:47 +0000 (18:47 +0000)]
Fix -ast-dump of dependent new and delete exprs

llvm-svn: 232748

9 years agoIgnore device-side asm constraint errors while compiling CUDA code for host and vice...
Artem Belevich [Thu, 19 Mar 2015 18:40:25 +0000 (18:40 +0000)]
Ignore device-side asm constraint errors while compiling CUDA code for host and vice versa.

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

llvm-svn: 232747

9 years agogold: Make powerpc support optional for the tests.
Peter Collingbourne [Thu, 19 Mar 2015 18:23:31 +0000 (18:23 +0000)]
gold: Make powerpc support optional for the tests.

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

llvm-svn: 232744

9 years agoGlobalDCE: Improve performance for large modules containing comdats.
Peter Collingbourne [Thu, 19 Mar 2015 18:23:29 +0000 (18:23 +0000)]
GlobalDCE: Improve performance for large modules containing comdats.

When we encounter a global with a comdat, rather than iterating over
every global in the module to find globals in the same comdat, store the
members in a multimap. This effectively lowers the complexity to O(N log N),
improving performance significantly for large modules such as might be
encountered during LTO.

It looks like we used to do something like this until r219191.

No functional change.

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

llvm-svn: 232743

9 years agodocs: Update llvm-cov docs for the -use-color flag
Justin Bogner [Thu, 19 Mar 2015 18:22:46 +0000 (18:22 +0000)]
docs: Update llvm-cov docs for the -use-color flag

llvm-svn: 232742

9 years agoAdded missing case for IK_PreprocessedCuda.
Artem Belevich [Thu, 19 Mar 2015 18:12:26 +0000 (18:12 +0000)]
Added missing case for IK_PreprocessedCuda.

llvm-svn: 232741

9 years agoAdd -ast-dump support for new and delete expressions to help figure out which operato...
Reid Kleckner [Thu, 19 Mar 2015 18:09:25 +0000 (18:09 +0000)]
Add -ast-dump support for new and delete expressions to help figure out which operator got selected

llvm-svn: 232740

9 years agoFix incremental linking with ninja and CMake 3.2+, see LLVM r232662 for details
Reid Kleckner [Thu, 19 Mar 2015 17:45:12 +0000 (17:45 +0000)]
Fix incremental linking with ninja and CMake 3.2+, see LLVM r232662 for details

llvm-svn: 232739

9 years agoRemove IDE_MI_APP_EXIT_OK msg on exit (MI)
Ilia K [Thu, 19 Mar 2015 17:40:15 +0000 (17:40 +0000)]
Remove IDE_MI_APP_EXIT_OK msg on exit (MI)

Summary: Remove IDE_MI_APP_EXIT_OK msg on exit (MI)

Reviewers: abidh

Reviewed By: abidh

Subscribers: lldb-commits, abidh

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

llvm-svn: 232738

9 years agoEnsure that we still parse preprocessed CUDA files as CUDA when we use
Artem Belevich [Thu, 19 Mar 2015 17:32:06 +0000 (17:32 +0000)]
Ensure that we still parse preprocessed CUDA files as CUDA when we use
-save-temps option.

Summary: Fixes PR22926.

Review: http://reviews.llvm.org/D8383
llvm-svn: 232737

9 years agoexpose 64 bit addresses through MI
Ilia K [Thu, 19 Mar 2015 17:27:23 +0000 (17:27 +0000)]
expose 64 bit addresses through MI

Summary:
This changes all reporting of addresses from lldb-mi to be 64 bit capable. There could have been cases where a 64 bit address was getting truncated to 32 bit format.

Patch from chuckr@microsoft.com

Reviewers: abidh, ChuckR

Reviewed By: abidh

Subscribers: paulmaybee, ki.stfu, zturner, lldb-commits

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

llvm-svn: 232736

9 years agoFix memory allocating inside signal handler (MI)
Ilia K [Thu, 19 Mar 2015 17:17:26 +0000 (17:17 +0000)]
Fix memory allocating inside signal handler (MI)

Summary:
This patch fixes a memory allocating inside signal handler.

This bug was found by @vharron:
> Hi all,
>
> I noticed these thread sanitizer warnings while running lldb-mi tests on
> Linux.
>
> WARNING: ThreadSanitizer: signal-unsafe call inside of a signal (pid=39721)
>
>     #0 operator new(unsigned long) <null>:0 (lldb-mi-3.7.0+0x000000092b9d)
>
>     #1 std::string::_Rep::_S_create(unsigned long, unsigned long,
> std::allocator<char> const&) <null>:0 (libstdc++.so.6+0x0000000ba3b8)
>
>     #2 CMICmnResources::GetStringFromResource(unsigned int, CMIUtilString&)
> const
> /usr/local/google/home/vharron/ll/tot/llvm/tools/lldb/tools/lldb-mi/MICmnResources.cpp:434
> (lldb-mi-3.7.0+0x00000014ddd8)
>
>     #3 CMICmnResources::GetString(unsigned int) const
> /usr/local/google/home/vharron/ll/tot/llvm/tools/lldb/tools/lldb-mi/MICmnResources.cpp:371
> (lldb-mi-3.7.0+0x00000014db81)
>
>     #4 sigwinch_handler(int)
> /usr/local/google/home/vharron/ll/tot/llvm/tools/lldb/tools/lldb-mi/MIDriverMain.cpp:99
> (lldb-mi-3.7.0+0x0000001589ff)
>
>     #5 __tsan::CallUserSignalHandler(__tsan::ThreadState*, bool, bool, int,
> my_siginfo_t*, void*) tsan_interceptors.o:0 (lldb-mi-3.7.0+0x00000009f25f)
>
>     #6 void std::this_thread::sleep_for<long, std::ratio<1l, 1000l>
> >(std::chrono::duration<long, std::ratio<1l, 1000l> > const&)
> /usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/thread:279
> (lldb-mi-3.7.0+0x00000013243e)
>
>     #7 CMIDriver::ReadStdinLineQueue()
> /usr/local/google/home/vharron/ll/tot/llvm/tools/lldb/tools/lldb-mi/MIDriver.cpp:710
> (lldb-mi-3.7.0+0x000000155e62)
>
>     #8 CMIDriver::DoMainLoop()
> /usr/local/google/home/vharron/ll/tot/llvm/tools/lldb/tools/lldb-mi/MIDriver.cpp:631
> (lldb-mi-3.7.0+0x000000155d37)
>
>     #9 non-virtual thunk to CMIDriver::DoMainLoop()
> /usr/local/google/home/vharron/ll/tot/llvm/tools/lldb/tools/lldb-mi/MIDriver.cpp:648
> (lldb-mi-3.7.0+0x000000155fbd)
>
>     #10 CMIDriverMgr::DriverMainLoop()
> /usr/local/google/home/vharron/ll/tot/llvm/tools/lldb/tools/lldb-mi/MIDriverMgr.cpp:340
> (lldb-mi-3.7.0+0x000000159ee6)
>
>     #11 main
> /usr/local/google/home/vharron/ll/tot/llvm/tools/lldb/tools/lldb-mi/MIDriverMain.cpp:364
> (lldb-mi-3.7.0+0x000000158f60)

Reviewers: vharron, abidh

Reviewed By: abidh

Subscribers: lldb-commits, abidh, vharron

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

llvm-svn: 232735

9 years agoFix -break-insert for system functions (MI)
Ilia K [Thu, 19 Mar 2015 17:13:20 +0000 (17:13 +0000)]
Fix -break-insert for system functions (MI)

Summary:
# Fix -break-insert for system functions
# Fix MiExecTestCase to use -break-insert instead of CLI "b"
# Improve MiBreakTestCase: now it uses printf() instead of in-house function

All tests pass on OS X.

Test Plan:
```
$ bin/lldb-mi --interpreter
(gdb)
-file-exec-and-symbols ~/p/hello
^done
(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"]
-break-insert -f printf
^done,bkpt={number="1",type="breakpoint",disp="keep",enabled="y",addr="0xffffffff",func="??",file="??",fullname="??/??",line="0",pending=["printf"],times="0",original-location="printf"}
(gdb)
=breakpoint-modified,bkpt={number="1",type="breakpoint",disp="keep",enabled="y",addr="0xffffffff",func="??",file="??",fullname="??/??",line="0",pending=["printf"],times="0",original-location="printf"}
-exec-run
^running
...
*stopped,reason="breakpoint-hit",disp="del",bkptno="1",frame={addr="0x7fff8a476910",func="printf",args=[],file="??",fullname="??",line="-1"},thread-id="1",stopped-threads="all"
(gdb)
```

Reviewers: abidh, clayborg

Reviewed By: clayborg

Subscribers: lldb-commits, clayborg, abidh

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

llvm-svn: 232734

9 years agoAdd code to honor the match_not_bol and match_not_eol regex flats. Fixes PR#22651...
Marshall Clow [Thu, 19 Mar 2015 17:05:59 +0000 (17:05 +0000)]
Add code to honor the match_not_bol and match_not_eol regex flats. Fixes PR#22651. Thanks to Jim Porter for the report and suggested fix.

llvm-svn: 232733

9 years agoAdd support for __nvvm_reflect changes in libdevice in CUDA-7.0
Artem Belevich [Thu, 19 Mar 2015 17:05:35 +0000 (17:05 +0000)]
Add support for __nvvm_reflect changes in libdevice in CUDA-7.0

Summary:
CUDA 7.0's libdevice uses slightly different IR to call __nvvm_reflect
and that triggers an assertion in nvvm_reflect optimization pass. This
change allows nvvm_reflect pass to deal with both old and new ways to
pass an argument to __nvvm_reflect.

Test Plan: ninja check-all

Reviewers: eliben, echristo

Subscribers: jholewinski, llvm-commits

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

llvm-svn: 232732

9 years agoRevert "Improvement on sized deallocation from r230160"
Reid Kleckner [Thu, 19 Mar 2015 17:03:58 +0000 (17:03 +0000)]
Revert "Improvement on sized deallocation from r230160"

This reverts commit r230580.

extern_weak functions don't appear to work on Darwin (PR22951), so we'll
need to come up with a new approach.

llvm-svn: 232731

9 years agoFixing dependencies for native tablegen.
Chris Bieneman [Thu, 19 Mar 2015 16:49:44 +0000 (16:49 +0000)]
Fixing dependencies for native tablegen.

The dependencies for cross-built tablegen were a bit confused. This fixes that. The following dependencies are now enforced:

(1) Tablegen tasks depend on the native tablegen
(2) Native tablegen depends on the cross-compiled tablegen

Although the native tablegen doesn't actually require the cross tablegen, having this dependency forces the native tablegen to rebuild whenever the cross tablegen changes.

llvm-svn: 232730

9 years agoSwitch lowering: remove unnecessary ConstantInt casts. NFC.
Hans Wennborg [Thu, 19 Mar 2015 16:42:21 +0000 (16:42 +0000)]
Switch lowering: remove unnecessary ConstantInt casts. NFC.

llvm-svn: 232729

9 years ago[Hexagon] Add support for vector instructions
Krzysztof Parzyszek [Thu, 19 Mar 2015 16:33:08 +0000 (16:33 +0000)]
[Hexagon] Add support for vector instructions

llvm-svn: 232728

9 years ago[CMake] Don't pass in MSVC warning flags as definitions.
Greg Bedwell [Thu, 19 Mar 2015 16:32:47 +0000 (16:32 +0000)]
[CMake] Don't pass in MSVC warning flags as definitions.

NFC currently but required as a prerequisite for using
the Microsoft resource compiler in conjunction with
CMake's ninja generator, which knows how to filter flags
appropriately, but not definitions.

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

llvm-svn: 232727

9 years agoDevirtualize Attr and all subclasses.
Benjamin Kramer [Thu, 19 Mar 2015 16:06:49 +0000 (16:06 +0000)]
Devirtualize Attr and all subclasses.

We know all subclasses in tblgen so just generate a giant switch for
the few virtual methods or turn them into a member variable using spare
bits. The giant jump tables aren't pretty but still much smaller than
a vtable for every attribute, shrinking Release+Asserts clang by ~400k.

Also halves the size of the Attr base class. No functional change
intended.

llvm-svn: 232726

9 years ago[Hexagon] ENDLOOP is a non-reversible conditional branch
Krzysztof Parzyszek [Thu, 19 Mar 2015 15:18:57 +0000 (15:18 +0000)]
[Hexagon] ENDLOOP is a non-reversible conditional branch

llvm-svn: 232725

9 years agoDon't close pseudo terminal master file descriptor on EOF
Tamas Berghammer [Thu, 19 Mar 2015 14:58:36 +0000 (14:58 +0000)]
Don't close pseudo terminal master file descriptor on EOF

Some application on Linux an all application on android close stdout and
stderr during the libc exit stage. Previously the master file descriptor
of the pseudo terminal used to communicate with the inferior was closed
on an EOF causing a race condition and a possible SIGHUP on process
exit. After this change the master file descriptor will be closed by the
destructor of the GDBRemoteCommunicationServerLLGS class.

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

llvm-svn: 232724

9 years agoMove ThreadSafetyReporter into an anonymous namespace. NFC.
Benjamin Kramer [Thu, 19 Mar 2015 14:23:45 +0000 (14:23 +0000)]
Move ThreadSafetyReporter into an anonymous namespace. NFC.

llvm-svn: 232723

9 years agoInternalize PEI. NFC.
Benjamin Kramer [Thu, 19 Mar 2015 14:09:20 +0000 (14:09 +0000)]
Internalize PEI. NFC.

llvm-svn: 232722

9 years agoAdd option to switch off putting header modules into the dependency file.
Manuel Klimek [Thu, 19 Mar 2015 12:00:22 +0000 (12:00 +0000)]
Add option to switch off putting header modules into the dependency file.

llvm-svn: 232721

9 years ago[sparc] Small fix to r232719 to make 2007-12-17-InvokeAsm.ll pass on the buildbot.
Daniel Sanders [Thu, 19 Mar 2015 11:27:23 +0000 (11:27 +0000)]
[sparc] Small fix to r232719 to make 2007-12-17-InvokeAsm.ll pass on the buildbot.

llvm-svn: 232720

9 years ago[sparc] Only support the 'm' inline assembly memory constraint. NFC.
Daniel Sanders [Thu, 19 Mar 2015 11:26:05 +0000 (11:26 +0000)]
[sparc] Only support the 'm' inline assembly memory constraint. NFC.

Summary:
SPARC doesn't seem to support any additional constraints. Therefore remove
the target hook.

No functional change intended.

Reviewers: venkatra

Subscribers: llvm-commits

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

llvm-svn: 232719

9 years ago[InstCombine] Don't fold a GEP into itself through a PHI node
Daniel Jasper [Thu, 19 Mar 2015 11:05:08 +0000 (11:05 +0000)]
[InstCombine] Don't fold a GEP into itself through a PHI node

This can only occur (I think) through the back-edge of the loop.

However, folding a GEP into itself means that the value of the previous
iteration needs to be stored in the meantime, thus requiring an
additional register variable to be live, but not actually achieving
anything (the gep still needs to be executed once per loop iteration).

The attached test case is derived from:
  typedef unsigned uint32;
  typedef unsigned char uint8;
  inline uint8 *f(uint32 value, uint8 *target) {
    while (value >= 0x80) {
      value >>= 7;
      ++target;
    }
    ++target;
    return target;
  }
  uint8 *g(uint32 b, uint8 *target) {
    target = f(b, f(42, target));
    return target;
  }

What happens is that the GEP stored in incptr2 is folded into itself
through the loop's back-edge and the phi-node stored in loopptr,
effectively incrementing the ptr by "2" in each iteration instead of "1".

In this case, it is actually increasing the number of GEPs required as
the GEP before the loop can't be folded away anymore. For comparison:

With this patch:
  define i8* @test4(i32 %value, i8* %buffer) {
  entry:
    %cmp = icmp ugt i32 %value, 127
    br i1 %cmp, label %loop.header, label %exit

  loop.header:                                      ; preds = %entry
    br label %loop.body

  loop.body:                                        ; preds = %loop.body, %loop.header
    %buffer.pn = phi i8* [ %buffer, %loop.header ], [ %loopptr, %loop.body ]
    %newval = phi i32 [ %value, %loop.header ], [ %shr, %loop.body ]
    %loopptr = getelementptr inbounds i8, i8* %buffer.pn, i64 1
    %shr = lshr i32 %newval, 7
    %cmp2 = icmp ugt i32 %newval, 16383
    br i1 %cmp2, label %loop.body, label %loop.exit

  loop.exit:                                        ; preds = %loop.body
    br label %exit

  exit:                                             ; preds = %loop.exit, %entry
    %0 = phi i8* [ %loopptr, %loop.exit ], [ %buffer, %entry ]
    %incptr3 = getelementptr inbounds i8, i8* %0, i64 2
    ret i8* %incptr3
  }

Without this patch:
  define i8* @test4(i32 %value, i8* %buffer) {
  entry:
    %incptr = getelementptr inbounds i8, i8* %buffer, i64 1
    %cmp = icmp ugt i32 %value, 127
    br i1 %cmp, label %loop.header, label %exit

  loop.header:                                      ; preds = %entry
    br label %loop.body

  loop.body:                                        ; preds = %loop.body, %loop.header
    %0 = phi i8* [ %buffer, %loop.header ], [ %loopptr, %loop.body ]
    %loopptr = phi i8* [ %incptr, %loop.header ], [ %incptr2, %loop.body ]
    %newval = phi i32 [ %value, %loop.header ], [ %shr, %loop.body ]
    %shr = lshr i32 %newval, 7
    %incptr2 = getelementptr inbounds i8, i8* %0, i64 2
    %cmp2 = icmp ugt i32 %newval, 16383
    br i1 %cmp2, label %loop.body, label %loop.exit

  loop.exit:                                        ; preds = %loop.body
    br label %exit

  exit:                                             ; preds = %loop.exit, %entry
    %ptr2 = phi i8* [ %incptr2, %loop.exit ], [ %incptr, %entry ]
    %incptr3 = getelementptr inbounds i8, i8* %ptr2, i64 1
    ret i8* %incptr3
  }

Review: http://reviews.llvm.org/D8245
llvm-svn: 232718

9 years agoclang-format: Fix another bug in wrapping around "*".
Daniel Jasper [Thu, 19 Mar 2015 09:40:16 +0000 (09:40 +0000)]
clang-format: Fix another bug in wrapping around "*".

Before:
  void aaaaa(
      aaaaaaaaaaaaaaaaaaaaaaaaaa) {} // even violation the column limit

After:
  void aaaaa(aaaaaaaaaaaa*
                 aaaaaaaaaaaaaa) {}

llvm-svn: 232717

9 years agoDon't print debugging messages to stdout.
Ed Schouten [Thu, 19 Mar 2015 09:17:21 +0000 (09:17 +0000)]
Don't print debugging messages to stdout.

There is some debugging code in cxa_demangle.cpp that prints messages on
stdout. In general this is not safe, as the program itself may use
stdout to write its output. Change this code to write to stderr.

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

llvm-svn: 232716

9 years agoFix double (gdb) prompt when command doesn't exist
Ilia K [Thu, 19 Mar 2015 09:17:06 +0000 (09:17 +0000)]
Fix double (gdb) prompt when command doesn't exist

llvm-svn: 232715

9 years agoAdd support for kfreebsd. Thanks to Jan Henke
Sylvestre Ledru [Thu, 19 Mar 2015 09:03:58 +0000 (09:03 +0000)]
Add support for kfreebsd. Thanks to Jan Henke
Reported on the Debian BTS:
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=780106

llvm-svn: 232714

9 years agoFix error handling in CMIDriver::DoMainLoop after r215223 (MI)
Ilia K [Thu, 19 Mar 2015 08:54:17 +0000 (08:54 +0000)]
Fix error handling in CMIDriver::DoMainLoop after r215223 (MI)

llvm-svn: 232713

9 years ago[OPENMP] Fixed bug in codegen of 'atomic write'.
Alexey Bataev [Thu, 19 Mar 2015 08:44:10 +0000 (08:44 +0000)]
[OPENMP] Fixed bug in codegen of 'atomic write'.

Fixed codegen for exit/continue order after success/failed atomic cmpxchg instruction for 'atomic write' construct.

llvm-svn: 232712

9 years agoAdd some missing __isl_give/__isl_keep annotations
Tobias Grosser [Thu, 19 Mar 2015 07:43:35 +0000 (07:43 +0000)]
Add some missing __isl_give/__isl_keep annotations

llvm-svn: 232711

9 years agoAdd forgotten 'FileCheck' to tiling test cases
Tobias Grosser [Thu, 19 Mar 2015 07:39:34 +0000 (07:39 +0000)]
Add forgotten 'FileCheck' to tiling test cases

These test cases did not verify the CHECK lines at all. We add the FileCheck
and also fix some broken CHECK lines. Being here, we extend the checks to
cover the whole loop structure.

llvm-svn: 232710

9 years agoUpdate isl to 94d707d
Tobias Grosser [Thu, 19 Mar 2015 07:27:29 +0000 (07:27 +0000)]
Update isl to 94d707d

The major improvements are:

  - Extended schedule tree support
  - AST generation from schedule trees

llvm-svn: 232709

9 years ago[ARM] Implement static (initial exec) TLS model
Denis Protivensky [Thu, 19 Mar 2015 06:47:44 +0000 (06:47 +0000)]
[ARM] Implement static (initial exec) TLS model

This includes handling of R_ARM_TLS_IE32 and R_ARM_TLS_LE32 relocs.

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

llvm-svn: 232708

9 years ago[Mips] Implement R_MIPS_PC21_S2 relocation handling
Simon Atanasyan [Thu, 19 Mar 2015 05:44:22 +0000 (05:44 +0000)]
[Mips] Implement R_MIPS_PC21_S2 relocation handling

llvm-svn: 232707

9 years ago[Mips] Recognize and check compatibility MIPS32R6 / MIPS64R6 ISA's
Simon Atanasyan [Thu, 19 Mar 2015 05:44:13 +0000 (05:44 +0000)]
[Mips] Recognize and check compatibility MIPS32R6 / MIPS64R6 ISA's

llvm-svn: 232706

9 years ago[Mips] Replace "hand-made" function by the `llvm::SignExtend32()` routine
Simon Atanasyan [Thu, 19 Mar 2015 05:44:04 +0000 (05:44 +0000)]
[Mips] Replace "hand-made" function by the `llvm::SignExtend32()` routine

No functional changes.

llvm-svn: 232705

9 years agollvm-cov: Rename -color={always|never} to -use-color[=0]
Justin Bogner [Thu, 19 Mar 2015 04:45:16 +0000 (04:45 +0000)]
llvm-cov: Rename -color={always|never} to -use-color[=0]

This is an ugly hack to fix the configure --enable-shared build. It
turns out that *every cl::opt in LLVM* shows up in *every tool* in
that configuration, which is hopelessly broken. This skirts around the
issue by not colliding with another option's name, for now.

I've also simplified the option implementation - the other "color"
option used cl::boolOrDefault and was much nicer than what I'd written
before.

llvm-svn: 232704

9 years agoFix use after free and calls to operator comma in debug mode
Eric Fiselier [Thu, 19 Mar 2015 03:20:02 +0000 (03:20 +0000)]
Fix use after free and calls to operator comma in debug mode

llvm-svn: 232703

9 years agoAdd NameMatches.h header to fix FreeBSD build after r232673
Ed Maste [Thu, 19 Mar 2015 02:47:36 +0000 (02:47 +0000)]
Add NameMatches.h header to fix FreeBSD build after r232673

llvm-svn: 232702

9 years agoNote that we don't support COFF on PPC.
Rafael Espindola [Thu, 19 Mar 2015 02:40:56 +0000 (02:40 +0000)]
Note that we don't support COFF on PPC.

Should bring back the windows bots.

llvm-svn: 232701

9 years agollvm-cov: Continue trying to appease a bot
Justin Bogner [Thu, 19 Mar 2015 02:00:54 +0000 (02:00 +0000)]
llvm-cov: Continue trying to appease a bot

This bot doesn't like me. I don't know why:

    http://lab.llvm.org:8011/builders/clang-hexagon-elf/builds/24425

Move the color option enum's definition out of the function that
creates the cl::opt.

llvm-svn: 232700

9 years agoSplit the object streamer callback in one per file format.
Rafael Espindola [Thu, 19 Mar 2015 01:50:16 +0000 (01:50 +0000)]
Split the object streamer callback in one per file format.

There are two main advantages to doing this

* Targets that only need to handle one of the formats specially don't have
  to worry about the others. For example, x86 now only registers a
  constructor for the COFF streamer.

* Changes to the arguments passed to one format constructor will not impact
  the other formats.

llvm-svn: 232699

9 years agollvm-cov: Try to appease a bot
Justin Bogner [Thu, 19 Mar 2015 01:07:22 +0000 (01:07 +0000)]
llvm-cov: Try to appease a bot

The clang-hexagon elf bot was complaining that "Option 'color'
registered more than once!":

    http://lab.llvm.org:8011/builders/clang-hexagon-elf/builds/24425

I don't understand why this error is happening, and I don't see it on
any other bots or on my own machine, so I'm kind of grasping at
straws. Try using an unscoped enum and specifying a cl::init to see if
they help.

llvm-svn: 232698

9 years agoSelectionDAGBuilder: update comment in HandlePHINodesInSuccessorBlocks.
Hans Wennborg [Thu, 19 Mar 2015 00:57:51 +0000 (00:57 +0000)]
SelectionDAGBuilder: update comment in HandlePHINodesInSuccessorBlocks.

From what I can tell, the code is checking for PHIs that expect any value from
this block, not just constants.

llvm-svn: 232697

9 years agoDo not track subregister liveness when it brings no benefits
Matthias Braun [Thu, 19 Mar 2015 00:21:58 +0000 (00:21 +0000)]
Do not track subregister liveness when it brings no benefits

Some subregisters are only to indicate different access sizes, while not
providing any way to actually divide the register up into multiple
disjunct parts. Avoid tracking subregister liveness in these cases as it
is not beneficial.

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

llvm-svn: 232695

9 years agoParse: Don't assume tokens have a length
David Majnemer [Thu, 19 Mar 2015 00:10:23 +0000 (00:10 +0000)]
Parse: Don't assume tokens have a length

Don't crash if the last token in a bad inline method body is an
annotation token.

llvm-svn: 232694

9 years agollvm-cov: Only emit colour by default if the output is a tty
Justin Bogner [Thu, 19 Mar 2015 00:02:23 +0000 (00:02 +0000)]
llvm-cov: Only emit colour by default if the output is a tty

This replaces the -no-color flag with a -color={auto|always|never}
option, with auto as the default, which is much saner.

llvm-svn: 232693

9 years agoSelectionDAGIsel: Fix comment about terminators being "handled below".
Hans Wennborg [Thu, 19 Mar 2015 00:02:22 +0000 (00:02 +0000)]
SelectionDAGIsel: Fix comment about terminators being "handled below".

That changed in r102128.

llvm-svn: 232692

9 years ago[CodeGenPrepare] Remove broken, dead, code.
Quentin Colombet [Wed, 18 Mar 2015 23:17:28 +0000 (23:17 +0000)]
[CodeGenPrepare] Remove broken, dead, code.
NFC.

llvm-svn: 232690

9 years agoComment discouraging writing command based test cases.
Jim Ingham [Wed, 18 Mar 2015 23:16:58 +0000 (23:16 +0000)]
Comment discouraging writing command based test cases.

llvm-svn: 232689

9 years agotwo or more, use a for.
Rafael Espindola [Wed, 18 Mar 2015 23:15:49 +0000 (23:15 +0000)]
two or more, use a for.

llvm-svn: 232688

9 years agoEnable TestCallStdStringFunction for GCC.
Siva Chandra [Wed, 18 Mar 2015 23:02:28 +0000 (23:02 +0000)]
Enable TestCallStdStringFunction for GCC.

Test Plan: dotest.py -C gcc -p TestCallStdStringFunction

Reviewers: vharron

Subscribers: lldb-commits

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

llvm-svn: 232687

9 years ago[libc++] Fix PR22922 - Allocator support for std::function does not know how to rebind.
Eric Fiselier [Wed, 18 Mar 2015 22:56:50 +0000 (22:56 +0000)]
[libc++] Fix PR22922 - Allocator support for std::function does not know how to rebind.

Summary:
This patch changes std::function to use allocator_traits to rebind the allocator instead of allocator itself.

It also changes most of the tests to use `bare_allocator` where possible instead of `test_allocator`.

Reviewers: mclow.lists

Reviewed By: mclow.lists

Subscribers: cfe-commits

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

llvm-svn: 232686

9 years agoFixed failing test due to missing target triple causing different results on differen...
Simon Pilgrim [Wed, 18 Mar 2015 22:51:45 +0000 (22:51 +0000)]
Fixed failing test due to missing target triple causing different results on different buildbots.

llvm-svn: 232685

9 years agoTeach getDefaultFormat that we only support ELF on some architectures.
Rafael Espindola [Wed, 18 Mar 2015 22:19:16 +0000 (22:19 +0000)]
Teach getDefaultFormat that we only support ELF on some architectures.

This should bring the windows bots back.

It is a bit ugly, but it is better than what we had before: The triple would
say that the object format was COFF, but llc/llvm-mc would produce an ELF.

llvm-svn: 232683

9 years ago[X86][SSE] Avoid scalarization of v2i64 vector shifts (REAPPLIED)
Simon Pilgrim [Wed, 18 Mar 2015 22:18:51 +0000 (22:18 +0000)]
[X86][SSE] Avoid scalarization of v2i64 vector shifts (REAPPLIED)

Fixed broken tests.

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

llvm-svn: 232682

9 years ago[PowerPC] Correct typo in PPCInstrAltivec.td
Bill Schmidt [Wed, 18 Mar 2015 22:13:03 +0000 (22:13 +0000)]
[PowerPC] Correct typo in PPCInstrAltivec.td

llvm-svn: 232681

9 years agoMS ABI: Don't try to emit VF/VB-Tables for extern class templates
David Majnemer [Wed, 18 Mar 2015 22:04:43 +0000 (22:04 +0000)]
MS ABI: Don't try to emit VF/VB-Tables for extern class templates

There will be an explicit template instantiation in another translation
unit which will provide the definition of the VF/VB-Tables.

This fixes PR22932.

llvm-svn: 232680

9 years ago[sanitizer] change the sanitizer coverage format once again, this time adding a magic...
Kostya Serebryany [Wed, 18 Mar 2015 22:03:39 +0000 (22:03 +0000)]
[sanitizer] change the sanitizer coverage format once again, this time adding a magic to the beginning of the file

llvm-svn: 232679

9 years agoCleanup to simplify the formatter for std::map of libstdc++.
Siva Chandra [Wed, 18 Mar 2015 22:01:45 +0000 (22:01 +0000)]
Cleanup to simplify the formatter for std::map of libstdc++.

Summary:
GCC does not emit some DWARF required for the simplified formatter
to work. A workaround for it has been incorporated in the formatter.
The corresponding test TestDataFormatterStdMap has also been enabled
for GCC.

Test Plan: dotest.py -C <clang|gcc> -p TestDataFormatterStdMap

Reviewers: clayborg, vharron, granata.enrico

Subscribers: lldb-commits

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

llvm-svn: 232678

9 years agoUpdate 3.7 Release Note mentionning the non-optionality of the DataLayout
Mehdi Amini [Wed, 18 Mar 2015 22:01:44 +0000 (22:01 +0000)]
Update 3.7 Release Note mentionning the non-optionality of the DataLayout

From: Mehdi Amini <mehdi.amini@apple.com>
llvm-svn: 232677

9 years agoRevert "Generate targets for each lit suite."
Chris Bieneman [Wed, 18 Mar 2015 21:53:29 +0000 (21:53 +0000)]
Revert "Generate targets for each lit suite."

This change broke Polly. I'll track down the failure when I have a chance and re-apply the change.

llvm-svn: 232676

9 years agoWhen cloning LocalInstantiationScope's, don't update the current scope in Sema.
Richard Trieu [Wed, 18 Mar 2015 21:52:47 +0000 (21:52 +0000)]
When cloning LocalInstantiationScope's, don't update the current scope in Sema.

Construction of LocalInstantiationScope automatically updates the current scope
inside Sema.  However, when cloning a scope, the current scope does not change.
Change the cloning function to preserve the current scope.

Review: http://reviews.llvm.org/D8407
BUG: https://llvm.org/bugs/show_bug.cgi?id=22931
llvm-svn: 232675

9 years agomath: Implement erfc
Aaron Watry [Wed, 18 Mar 2015 21:52:07 +0000 (21:52 +0000)]
math: Implement erfc

Signed-off-by: Aaron Watry <awatry@gmail.com>
Reviewed-by: Tom Stellard <thomas.stellard@amd.com>
llvm-svn: 232674

9 years agoMove some functions from source/lldb.cpp to Utility.
Zachary Turner [Wed, 18 Mar 2015 21:31:45 +0000 (21:31 +0000)]
Move some functions from source/lldb.cpp to Utility.

Specifically, there were some functions for converting enums
to strings and a function for matching a string using a specific
matching algorithm.  This moves those functions to more appropriate
headers in lldb/Utility and updates references to include the
new headers.

llvm-svn: 232673

9 years agoasan: Cargo cult the linux test changes in r232501 to the darwin tests
Justin Bogner [Wed, 18 Mar 2015 21:30:46 +0000 (21:30 +0000)]
asan: Cargo cult the linux test changes in r232501 to the darwin tests

This gets check-asan working again on Darwin - it looks like it was
just an omission not to update this as part of r232501.

llvm-svn: 232672

9 years agoGenerate targets for each lit suite.
Chris Bieneman [Wed, 18 Mar 2015 21:19:06 +0000 (21:19 +0000)]
Generate targets for each lit suite.

Summary:
This change makes CMake scan for lit suites and generate a target for each lit test suite. The targets follow the format check-<project>-<suite path>.

For example:
check-llvm-unit - Runs the LLVM unit tests
check-llvm-codegen-arm - Runs the ARM codeine tests

Note: These targets are not generated during multi-configuration generators (i.e. Xcode and Visual Studio) because target clutter impacts UI usability.

Reviewers: chandlerc

Subscribers: aemerson, llvm-commits

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

llvm-svn: 232671

9 years agoRevert "[X86][SSE] Avoid scalarization of v2i64 vector shifts" as it
Eric Christopher [Wed, 18 Mar 2015 21:01:00 +0000 (21:01 +0000)]
Revert "[X86][SSE] Avoid scalarization of v2i64 vector shifts" as it
appears to have broken tests/bots.

This reverts commit r232660.

llvm-svn: 232670

9 years agoTry to fix the Makefile build.
Zachary Turner [Wed, 18 Mar 2015 20:58:39 +0000 (20:58 +0000)]
Try to fix the Makefile build.

I deleted lldb-log.cpp, but the Makefile build lists this file
explicitly, so it is removed in this patch.

llvm-svn: 232669

9 years agoDon't load register data from memory.
Greg Clayton [Wed, 18 Mar 2015 20:45:28 +0000 (20:45 +0000)]
Don't load register data from memory.

llvm-svn: 232668

9 years agoRevert "Add a TargetMachine local MCRegisterInfo and MCInstrInfo so that"
Eric Christopher [Wed, 18 Mar 2015 20:41:44 +0000 (20:41 +0000)]
Revert "Add a TargetMachine local MCRegisterInfo and MCInstrInfo so that"
Committed too early.

This reverts commit r232666.

llvm-svn: 232667

9 years agoAdd a TargetMachine local MCRegisterInfo and MCInstrInfo so that
Eric Christopher [Wed, 18 Mar 2015 20:37:36 +0000 (20:37 +0000)]
Add a TargetMachine local MCRegisterInfo and MCInstrInfo so that
they can be used without a subtarget in constructing subtarget
independent passes.

llvm-svn: 232666

9 years agoRevert "Migrate the AArch64 TargetRegisterInfo to its TargetMachine"
Eric Christopher [Wed, 18 Mar 2015 20:37:30 +0000 (20:37 +0000)]
Revert "Migrate the AArch64 TargetRegisterInfo to its TargetMachine"
as we don't necessarily need to do this yet - though we could move
the base class to the TargetMachine as it isn't subtarget dependent.

This reverts commit r232103.

llvm-svn: 232665

9 years agoUse WinEHPrepare to outline SEH finally blocks
Reid Kleckner [Wed, 18 Mar 2015 20:26:53 +0000 (20:26 +0000)]
Use WinEHPrepare to outline SEH finally blocks

No outlining is necessary for SEH catch blocks. Use the blockaddr of the
handler in place of the usual outlined function.

Reviewers: majnemer, andrew.w.kaylor

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

llvm-svn: 232664

9 years agoFix cmake build.
Rafael Espindola [Wed, 18 Mar 2015 20:21:06 +0000 (20:21 +0000)]
Fix cmake build.

llvm-svn: 232663