platform/upstream/llvm.git
7 years ago[KnownBits] Add bit counting methods to KnownBits struct and use them where possible
Craig Topper [Fri, 12 May 2017 17:20:30 +0000 (17:20 +0000)]
[KnownBits] Add bit counting methods to KnownBits struct and use them where possible

This patch adds min/max population count, leading/trailing zero/one bit counting methods.

The min methods return answers based on bits that are known without considering unknown bits. The max methods give answers taking into account the largest count that unknown bits could give.

Differential Revision: https://reviews.llvm.org/D32931

llvm-svn: 302925

7 years ago[ubsan] Enable debug info in test binaries
Reid Kleckner [Fri, 12 May 2017 17:06:16 +0000 (17:06 +0000)]
[ubsan] Enable debug info in test binaries

This fixes tests that use debug info to check ubsan stack traces.  One
was XFAILd on Windows and the other was actively failing for weeks.

llvm-svn: 302924

7 years ago[codeview] Fix assertion failure introduced in r295354 refactoring
Reid Kleckner [Fri, 12 May 2017 17:02:40 +0000 (17:02 +0000)]
[codeview] Fix assertion failure introduced in r295354 refactoring

CodeViewDebug sets Asm to nullptr to disable debug info generation.  You
can get a .ll file like no-cus.ll from 'clang -gcodeview -g0', which
happens in the ubsan test suite.

llvm-svn: 302923

7 years agoMake sure we have actually written what is expected by the test.
Galina Kistanova [Fri, 12 May 2017 17:00:13 +0000 (17:00 +0000)]
Make sure we have actually written what is expected by the test.

llvm-svn: 302922

7 years ago[ELF] - Apply clang-format. NFC.
George Rimar [Fri, 12 May 2017 17:00:07 +0000 (17:00 +0000)]
[ELF] - Apply clang-format. NFC.

llvm-svn: 302921

7 years agoDisable two failing darwin lsan tests
Francis Ricci [Fri, 12 May 2017 16:52:19 +0000 (16:52 +0000)]
Disable two failing darwin lsan tests

These tests don't fail consistently in all cases, but they
fail most of the time on the buildbots. Mark as UNSUPPORTED for now to
avoid buildbots failing due to XPASS.

llvm-svn: 302920

7 years agoAMDGPU/GlobalISel: Mark 32-bit integer constants as legal
Tom Stellard [Fri, 12 May 2017 16:46:46 +0000 (16:46 +0000)]
AMDGPU/GlobalISel: Mark 32-bit integer constants as legal

Reviewers: arsenm

Reviewed By: arsenm

Subscribers: kzhuravl, wdng, nhaehnle, yaxunl, rovka, kristof.beyls, igorb, dstuttard, tpr, t-tye, llvm-commits

Differential Revision: https://reviews.llvm.org/D33115

llvm-svn: 302919

7 years ago[index] Index template specialization arguments for function templats
Alex Lorenz [Fri, 12 May 2017 16:32:26 +0000 (16:32 +0000)]
[index] Index template specialization arguments for function templats

Also ensure that class template specialization arguments are covered

rdar://31812032

llvm-svn: 302918

7 years ago[asan/win] Re-enable Win64 asan tests on Win8+
Reid Kleckner [Fri, 12 May 2017 16:30:56 +0000 (16:30 +0000)]
[asan/win] Re-enable Win64 asan tests on Win8+

Our theory is that reserving large amounts of shadow memory isn't
reliable on Win7 and earlier NT kernels. This affects the
clang-x64-ninja-win7 buildbot, which uses Windows 7.

llvm-svn: 302917

7 years ago[APInt] Use MathExtras.h BitsToFloat/Double and Float/DoubleToBits instead of type...
Craig Topper [Fri, 12 May 2017 16:28:21 +0000 (16:28 +0000)]
[APInt] Use MathExtras.h BitsToFloat/Double and Float/DoubleToBits instead of type punning through a union

The functions in MathExtras.h uses a safer memcpy instead of going through a union.

Differential Revision: https://reviews.llvm.org/D33116

llvm-svn: 302916

7 years agoSimplify DINamespace caching in CGDebugInfo
Adrian Prantl [Fri, 12 May 2017 16:23:53 +0000 (16:23 +0000)]
Simplify DINamespace caching in CGDebugInfo

This addresses review feedback from r302840.

By not canonicalizing namespace decls and using lexical decl context
instead of lookuing up the semantic decl context we can take advantage
of the fact that DINamespaces a reuniqued. This way non-module debug
info is unchanged and module debug info still gets distinct namespace
declarations when they ocur in different modules.

Thanks to Richard Smith for pointing this out!

llvm-svn: 302915

7 years ago[SPARC] Support 'f' and 'e' inline asm constraints.
James Y Knight [Fri, 12 May 2017 16:01:23 +0000 (16:01 +0000)]
[SPARC] Support 'f' and 'e' inline asm constraints.

Patch by Patrick Boettcher.

Differential Revision: https://reviews.llvm.org/D29117

llvm-svn: 302913

7 years agoDisable two failing darwin lsan tests
Francis Ricci [Fri, 12 May 2017 16:01:15 +0000 (16:01 +0000)]
Disable two failing darwin lsan tests

These are causing buildbot failures, disable for now.

llvm-svn: 302912

7 years ago[SPARC] Support 'f' and 'e' inline asm constraints.
James Y Knight [Fri, 12 May 2017 15:59:10 +0000 (15:59 +0000)]
[SPARC] Support 'f' and 'e' inline asm constraints.

Based on patch by Patrick Boettcher and Chris Dewhurst.

Differential Revision: https://reviews.llvm.org/D29116

llvm-svn: 302911

7 years ago[x86] add tests for potential vector narrowing optimization (PR32790)
Sanjay Patel [Fri, 12 May 2017 15:56:39 +0000 (15:56 +0000)]
[x86] add tests for potential vector narrowing optimization (PR32790)

llvm-svn: 302910

7 years ago[LoopUnroll] Fix a test. REQUIRE should be REQUIRES.
Davide Italiano [Fri, 12 May 2017 15:30:58 +0000 (15:30 +0000)]
[LoopUnroll] Fix a test. REQUIRE should be REQUIRES.

Found by inspection.

llvm-svn: 302909

7 years ago[NewGVN] Improve debug output a bit. NFCI.
Davide Italiano [Fri, 12 May 2017 15:28:12 +0000 (15:28 +0000)]
[NewGVN] Improve debug output a bit. NFCI.

While debugging a predicate info problem, I noticed this was missing
a newline, making the debug output slightly less readable.

llvm-svn: 302908

7 years ago[DAGCombine] Use SelectionDAG::getAnyExtOrTrunc helper. NFCI.
Simon Pilgrim [Fri, 12 May 2017 15:26:50 +0000 (15:26 +0000)]
[DAGCombine] Use SelectionDAG::getAnyExtOrTrunc helper. NFCI.

llvm-svn: 302907

7 years ago[NewGVN] Format an assertion and fix a typo. NFCI.
Davide Italiano [Fri, 12 May 2017 15:25:56 +0000 (15:25 +0000)]
[NewGVN] Format an assertion and fix a typo. NFCI.

llvm-svn: 302906

7 years ago[NewGVN] Don't incorrectly reset the memory leader.
Davide Italiano [Fri, 12 May 2017 15:22:45 +0000 (15:22 +0000)]
[NewGVN] Don't incorrectly reset the memory leader.

This code was missing a check for stores, so we were thinking the
congruency class didn't have any memory members, and reset the
memory leader.

Differential Revision:  https://reviews.llvm.org/D33056

llvm-svn: 302905

7 years agoEnable lsan test suite on Darwin x86_64 builds
Francis Ricci [Fri, 12 May 2017 15:10:05 +0000 (15:10 +0000)]
Enable lsan test suite on Darwin x86_64 builds

Reviewers: kubamracek, alekseyshl

Subscribers: mgorny, llvm-commits

Differential Revision: https://reviews.llvm.org/D32191

llvm-svn: 302904

7 years agoOptimize orphan placement in a general way.
Rafael Espindola [Fri, 12 May 2017 14:52:22 +0000 (14:52 +0000)]
Optimize orphan placement in a general way.

We used to place orphans by just using compareSectionsNonScript.

Then we noticed that since linker scripts can use another order, we
should first try match the section to a given PT_LOAD. But there is
nothing special about PT_LOAD. The same issue can show up for
PT_GNU_RELRO for example.

In general, we have to search for the most similar section and put the
orphan next to it. Most similar being defined as how long they follow
the same code path in compareSecitonsNonScript.

That is what this patch does. We now compute a rank for each output
section, with a bit for each branch in what was
compareSectionsNonScript.

With this findOrphanPos is now fully general and orphan placement can
be optimized by placing every section with the same rank at once.

The included testcase is a variation of many-sections.s that uses
allocatable sections to avoid the fast path in the existing
code. Without threads it goes form 46 seconds to 0.9 seconds.

llvm-svn: 302903

7 years ago[Polly][NewPM] Port ScopDetection to the new PassManager
Philip Pfaffe [Fri, 12 May 2017 14:37:29 +0000 (14:37 +0000)]
[Polly][NewPM] Port ScopDetection to the new PassManager

Summary: This is a proof of concept of how to port polly-passes to the new PassManager architecture.  This approach works ootb for Function-Passes, but might not be directly applicable to Scop/Region-Passes. While we could just run the Analyses/Transforms over functions instead, we'd surrender the nice pipelining behaviour we have now.

Reviewers: Meinersbur, grosser

Reviewed By: grosser

Subscribers: pollydev, sanjoy, nemanjai, llvm-commits

Tags: #polly

Differential Revision: https://reviews.llvm.org/D31459

llvm-svn: 302902

7 years agoEnabling the /bigobj flag for SemaDeclAttr.cpp.
Aaron Ballman [Fri, 12 May 2017 14:30:49 +0000 (14:30 +0000)]
Enabling the /bigobj flag for SemaDeclAttr.cpp.

This resolves compile errors with MSVC 2015 x64 debug builds where SemaDeclAttr.cpp is hitting the section symbol limit.

llvm-svn: 302901

7 years agoAdd dyld to sanitizer procmaps on darwin
Francis Ricci [Fri, 12 May 2017 14:10:53 +0000 (14:10 +0000)]
Add dyld to sanitizer procmaps on darwin

Summary:
Sanitizer procmaps uses dyld apis to iterate over the list of images
in the process. This is much more performan than manually recursing
over all of the memory regions in the process, however, dyld does
not report itself in the list of images. In order to prevent reporting
leaks from dyld globals and to symbolize dyld functions in stack traces,
this patch special-cases dyld and ensures that it is added to the
list of modules.

This is accomplished by recursing through the memory map of the process
until a dyld Mach header is found. While this recursion is expensive,
it is run before the full set of images has been loaded in the process,
so only a few calls are required. The result is cached so that it never
needs to be searched for when the full process memory map exists, as this
would be incredibly slow, on the order of minutes for leak sanitizer with
only 25 or so libraries loaded.

Reviewers: alekseyshl, kubamracek

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D32968

llvm-svn: 302899

7 years agoAccount for stack redzone when computing sp on darwin
Francis Ricci [Fri, 12 May 2017 14:10:51 +0000 (14:10 +0000)]
Account for stack redzone when computing sp on darwin

thread_get_register_pointer_values handles the redzone computation
automatically, but is marked as an unavailable API function. This
patch replicates its logic accounting for the stack redzone on
x86_64.

Should fix flakiness in the use_stack_threaded test for lsan on darwin.

llvm-svn: 302898

7 years ago[DAGCombine] Use SelectionDAG::getZExtOrTrunc helper. NFCI.
Simon Pilgrim [Fri, 12 May 2017 13:22:12 +0000 (13:22 +0000)]
[DAGCombine] Use SelectionDAG::getZExtOrTrunc helper. NFCI.

llvm-svn: 302897

7 years agoUse SDValue::getOperand() helper. NFCI.
Simon Pilgrim [Fri, 12 May 2017 13:20:24 +0000 (13:20 +0000)]
Use SDValue::getOperand() helper. NFCI.

llvm-svn: 302896

7 years ago[Hexagon] Make sure to pass empty struct arguments with nontrivial ctors
Krzysztof Parzyszek [Fri, 12 May 2017 13:18:07 +0000 (13:18 +0000)]
[Hexagon] Make sure to pass empty struct arguments with nontrivial ctors

Thanks to Richard Smith for the suggested fix.

This fixes llvm.org/PR33009

llvm-svn: 302895

7 years agoUse SDValue::getOperand() helper. NFCI.
Simon Pilgrim [Fri, 12 May 2017 13:08:45 +0000 (13:08 +0000)]
Use SDValue::getOperand() helper. NFCI.

llvm-svn: 302894

7 years agoclang-format: [JS] support non-null assertions after all identifiers.
Martin Probst [Fri, 12 May 2017 13:00:33 +0000 (13:00 +0000)]
clang-format: [JS] support non-null assertions after all identifiers.

Summary:
Previously:
    x = namespace !;

Now:
    x = namespace!;

Reviewers: djasper

Subscribers: klimek

Differential Revision: https://reviews.llvm.org/D33113

llvm-svn: 302893

7 years ago[NFC] [Fortran Support] Run -instnamer on testcases
Siddharth Bhat [Fri, 12 May 2017 12:36:04 +0000 (12:36 +0000)]
[NFC] [Fortran Support] Run -instnamer on testcases

llvm-svn: 302892

7 years ago[FIX] Fix regression caused by c29f4ed, testcase matches output
Siddharth Bhat [Fri, 12 May 2017 11:34:51 +0000 (11:34 +0000)]
[FIX] Fix regression caused by c29f4ed, testcase matches output

- Commit changed codegen for induction variables
- Updated testcase

llvm-svn: 302891

7 years ago[clang-tidy] Add a test for PR33020
Alexander Kornienko [Fri, 12 May 2017 11:24:58 +0000 (11:24 +0000)]
[clang-tidy] Add a test for PR33020

Fix committed in clang as r302889.

llvm-svn: 302890

7 years agoFix an assertion failure (PR33020).
Alexander Kornienko [Fri, 12 May 2017 11:24:25 +0000 (11:24 +0000)]
Fix an assertion failure (PR33020).

Adding a test separately (tools/extra/test/clang-tidy/misc-use-after-move.cpp).

llvm-svn: 302889

7 years ago[Polly][CMake] Fix variable name in target exports
Philip Pfaffe [Fri, 12 May 2017 10:39:38 +0000 (10:39 +0000)]
[Polly][CMake] Fix variable name in target exports

llvm-svn: 302888

7 years ago[msan] Remove a failing test from MemorySanitizer.ICmpRelational
Alexander Potapenko [Fri, 12 May 2017 09:39:32 +0000 (09:39 +0000)]
[msan] Remove a failing test from MemorySanitizer.ICmpRelational

This is a follow-up to r302787, which broke MemorySanitizer.ICmpRelational.

MSan is now reporting a false positive on the following test case:
  TestForNotPoisoned((poisoned(-1, 0x80000000U) >= poisoned(-1, 0U)))
, which is sort of anticipated, because we're approximating the comparison
with an OR of the arguments' shadow values.

llvm-svn: 302887

7 years ago[NFC] [Fortran Support] Cleanup Fortran Array pattern mactch testcases
Siddharth Bhat [Fri, 12 May 2017 09:37:39 +0000 (09:37 +0000)]
[NFC] [Fortran Support] Cleanup Fortran Array pattern mactch testcases

- Move the testcases to ScopInfo/ since the processing takes place in
  ScopBuilder.

- Cleanup testcases, run -polly-canonicalize on them, find minimal set
  of opt parameters.

llvm-svn: 302886

7 years ago[AVR] Migrate to new StructType::get owing to Supress all uses of LLVM_END_WITH_NULL
Leslie Zhai [Fri, 12 May 2017 09:08:03 +0000 (09:08 +0000)]
[AVR] Migrate to new StructType::get owing to Supress all uses of LLVM_END_WITH_NULL

Reviewers: dylanmckay, jroelofs, RKSimon, serge-sans-paille

Reviewed By: serge-sans-paille

Differential Revision: https://reviews.llvm.org/D33119

llvm-svn: 302885

7 years ago[ELF] - Stop support of DF_STATIC_TLS flag.
George Rimar [Fri, 12 May 2017 08:04:58 +0000 (08:04 +0000)]
[ELF] - Stop support of DF_STATIC_TLS flag.

This reverts changes introduced in r302414 "[ELF] - Set DF_STATIC_TLS flag for i386 target."

Because DF_STATIC_TLS does not look to be used by glibc or anything else.

llvm-svn: 302884

7 years ago[BPI] Ignore remainder while distributing the remaining probability from unreachanble
Serguei Katkov [Fri, 12 May 2017 07:50:06 +0000 (07:50 +0000)]
[BPI] Ignore remainder while distributing the remaining probability from unreachanble

This is a follow up patch for https://reviews.llvm.org/rL300440
to address a comment.

To make implementation to be consistent with other cases we just
ignore the remainder after distribution of remaining probability between
reachable edges.

If we reduced the probability of some edges coming to unreachable
blocks we should distribute the remaining part across other edges
coming to reachable blocks to satisfy the condition that sum of all
probabilities should be equal to one. If this remaining part is not
divided by number of "reachable" edges then we get this remainder.
This remainder probability should be pretty small. Other cases just ignore
if the sum of probabilities is not equal to one so we do the same.

Reviewers: chandlerc, sanjoy, vsk, junbuml, reames
Reviewed By: reames
Subscribers: reames, llvm-commits
Differential Revision: https://reviews.llvm.org/D32124

llvm-svn: 302883

7 years ago[APInt] Fix a case where udivrem might delete and create a new allocation instead...
Craig Topper [Fri, 12 May 2017 07:21:09 +0000 (07:21 +0000)]
[APInt] Fix a case where udivrem might delete and create a new allocation instead of reusing the original.

llvm-svn: 302882

7 years ago[ELF] - Don't allow R_X86_64_TPOFF32 dynamic relocation when linking PIC
George Rimar [Fri, 12 May 2017 07:19:11 +0000 (07:19 +0000)]
[ELF] - Don't allow R_X86_64_TPOFF32 dynamic relocation when linking PIC

Both gold and bfd restrict that one:

ld.bfd: test.o: relocation R_X86_64_TPOFF32 against `var' can not be
used when making a shared object; recompile with -fPIC
ld.gold: error: test.o: unsupported reloc 23 against global symbol var

What looks reasonable because it is 32 bit one. Patch do the same.

Differential revision: https://reviews.llvm.org/D33100

llvm-svn: 302881

7 years ago[analyzer] Add modelling of __builtin_assume
Gabor Horvath [Fri, 12 May 2017 07:02:54 +0000 (07:02 +0000)]
[analyzer] Add modelling of __builtin_assume

Differential Revision: https://reviews.llvm.org/D33092

llvm-svn: 302880

7 years ago[analyzer] Avoid an allocation in Std C function modelling
Gabor Horvath [Fri, 12 May 2017 06:53:55 +0000 (06:53 +0000)]
[analyzer] Avoid an allocation in Std C function modelling

Differential Revision: https://reviews.llvm.org/D33095

llvm-svn: 302879

7 years ago[Support/Compiler.h] - Use gnu::fallthrough for LLVM_FALLTHROUGH when available.
George Rimar [Fri, 12 May 2017 06:53:48 +0000 (06:53 +0000)]
[Support/Compiler.h] - Use gnu::fallthrough for LLVM_FALLTHROUGH when available.

I tried to compile LLD using GCC 7.1.0 and got warnings like
"warning: this statement may fall through [-Wimplicit-fallthrough=]"
(some more details are here: D32907)

GCC's __cplusplus value is 201402L by default, so macro expands to nothing,
though GCC 7 has support for [[fallthrough]].

Patch uses gnu::fallthrough when it is available and fixes warning I am observing.

Initial idea of way to fix belongs to Davide Italiano.

Differential revision: https://reviews.llvm.org/D33036

llvm-svn: 302878

7 years agoHandle a COPY with undef source operand in LowerCopy()
Jonas Paulsson [Fri, 12 May 2017 06:32:03 +0000 (06:32 +0000)]
Handle a COPY with undef source operand in LowerCopy()

Llvm-stress discovered that a COPY may end up in ExpandPostRA::LowerCopy()
with an undef source operand. It is not possible for the target to handle
this, as this flag is not passed to TII->copyPhysReg().

This patch solves this by treating such a COPY as an identity COPY.

Review: Matthias Braun
https://reviews.llvm.org/D32892

llvm-svn: 302877

7 years ago[IfConversion] Keep the CFG updated incrementally in IfConvertTriangle
Mikael Holmen [Fri, 12 May 2017 06:28:58 +0000 (06:28 +0000)]
[IfConversion] Keep the CFG updated incrementally in IfConvertTriangle

Summary:
Instead of using RemoveExtraEdges (which uses analyzeBranch, which cannot
always be trusted) at the end to fixup the CFG we keep the CFG updated as
we go along and remove or add branches and merge blocks.

This way we won't have any problems if the involved MBBs contain
unanalyzable instructions.

This fixes PR32721.

In that case we had a triangle

   EBB
   | \
   |  |
   | TBB
   |  /
   FBB

where FBB didn't have any successors at all since it ended with an
unconditional return. Then TBB and FBB were be merged into EBB, but EBB
would still keep its successors, and the use of analyzeBranch and
CorrectExtraCFGEdges wouldn't help to remove them since the return
instruction is not analyzable (at least not on ARM).

Reviewers: kparzysz, iteratee, MatzeB

Reviewed By: iteratee

Subscribers: aemerson, rengolin, javed.absar, llvm-commits

Differential Revision: https://reviews.llvm.org/D33037

llvm-svn: 302876

7 years agoUpdate StructuredData::String to return StringRefs.
Zachary Turner [Fri, 12 May 2017 05:49:54 +0000 (05:49 +0000)]
Update StructuredData::String to return StringRefs.

It was returning const std::string& which was leading to
unnecessary copies all over the place, and preventing people
from doing things like Dict->GetValueForKeyAsString("foo", ref);

llvm-svn: 302875

7 years agoFix Linux Buildbot.
Zachary Turner [Fri, 12 May 2017 05:48:54 +0000 (05:48 +0000)]
Fix Linux Buildbot.

llvm-svn: 302874

7 years ago[XRay][compiler-rt] Only run custom event logging in x86_64-linux
Dean Michael Berris [Fri, 12 May 2017 05:13:11 +0000 (05:13 +0000)]
[XRay][compiler-rt] Only run custom event logging in x86_64-linux

We only have an implementation in x86_64 that works for the
patching/unpatching and runtime support (trampolines).

Follow-up to D30630.

llvm-svn: 302873

7 years agoRename Error -> Status.
Zachary Turner [Fri, 12 May 2017 04:51:55 +0000 (04:51 +0000)]
Rename Error -> Status.

This renames the LLDB error class to Status, as discussed
on the lldb-dev mailing list.

A change of this magnitude cannot easily be done without
find and replace, but that has potential to catch unwanted
occurrences of common strings such as "Error".  Every effort
was made to find all the obvious things such as the word "Error"
appearing in a string, etc, but it's possible there are still
some lingering occurences left around.  Hopefully nothing too
serious.

llvm-svn: 302872

7 years agoFix C++03 test failures caused by static_assert emulation
Eric Fiselier [Fri, 12 May 2017 03:53:56 +0000 (03:53 +0000)]
Fix C++03 test failures caused by static_assert emulation

llvm-svn: 302871

7 years agoCleanup test issues reported by STL @ Microsoft.
Eric Fiselier [Fri, 12 May 2017 03:38:28 +0000 (03:38 +0000)]
Cleanup test issues reported by STL @ Microsoft.

This patch cleans up a number of issues reported by STL, including:

1) Fix duplicate is_convertible test.
2) Move non-standard reference_wrapper tests under test/libcxx
3) Fix assumption that sizeof(wchar_t) == 32 in the codecvt and
   wstring_convert tests.

llvm-svn: 302870

7 years agoRemove non-standard basic_string_view::clear() member.
Eric Fiselier [Fri, 12 May 2017 03:35:53 +0000 (03:35 +0000)]
Remove non-standard basic_string_view::clear() member.

This patch removes the clear() member from <string_view>. The
modifier was removed from the TS before it ever landed in the standard.
There is no reason libc++ should be providing this method.

llvm-svn: 302869

7 years ago[Polly] Remove unused header
Hongbin Zheng [Fri, 12 May 2017 02:21:50 +0000 (02:21 +0000)]
[Polly] Remove unused header

llvm-svn: 302868

7 years ago[PM/Unswitch] Teach the new simple loop unswitch to handle loop
Chandler Carruth [Fri, 12 May 2017 02:19:59 +0000 (02:19 +0000)]
[PM/Unswitch] Teach the new simple loop unswitch to handle loop
invariant PHI inputs and to rewrite PHI nodes during the actual
unswitching.

The checking is quite easy, but rewriting the PHI nodes is somewhat
surprisingly challenging. This should handle both branches and switches.

I think this is now a full featured trivial unswitcher, and more full
featured than the trivial cases in the old pass while still being (IMO)
somewhat simpler in how it works.

Next up is to verify its correctness in more widespread testing, and
then to add non-trivial unswitching.

Thanks to Davide and Sanjoy for the excellent review. There is one
remaining question that I may address in a follow-up patch (see the
review thread for details) but it isn't related to the functionality
specifically.

Differential Revision: https://reviews.llvm.org/D32699

llvm-svn: 302867

7 years ago[Polly] Generate more 'canonical' induction variable
Hongbin Zheng [Fri, 12 May 2017 02:17:15 +0000 (02:17 +0000)]
[Polly] Generate more 'canonical' induction variable

Today Polly generates induction variable in this way:

polly.indvar = phi 0, polly.indvar.next
...
polly.indvar.next = polly.indvar + stide
polly.loop_cond = predicate polly.indvar, (UB - stride)

Instead of:

polly.indvar = phi 0, polly.indvar.next
...
polly.indvar.next = polly.indvar + stide
polly.loop_cond = predicate polly.indvar.next, UB

The way Polly generate induction variable cause some problem in the indvar simplify pass.
This patch make polly generate the later form, by assuming the induction variable never overflow

Differential Revision: https://reviews.llvm.org/D33089

llvm-svn: 302866

7 years agoMove POSIX specific test under test/libcxx subdirectory
Eric Fiselier [Fri, 12 May 2017 02:02:09 +0000 (02:02 +0000)]
Move POSIX specific test under test/libcxx subdirectory

llvm-svn: 302865

7 years agoMove tests for libc++ configurations into libcxx/ test subdirectory
Eric Fiselier [Fri, 12 May 2017 01:49:32 +0000 (01:49 +0000)]
Move tests for libc++ configurations into libcxx/ test subdirectory

llvm-svn: 302864

7 years ago[APInt] Add a utility method to change the bit width and storage size of an APInt.
Craig Topper [Fri, 12 May 2017 01:46:01 +0000 (01:46 +0000)]
[APInt] Add a utility method to change the bit width and storage size of an APInt.

Summary:
This adds a resize method to APInt that manages deleting/allocating storage for an APInt and changes its bit width. Use this to simplify code in copy assignment and divide.

The assignment code in particular was overly complicated. Treating every possible case as a separate implementation. I'm also pretty sure the clearUnusedBits code at the end was unnecessary. Since we always copying whole words from the source APInt. All unused bits should be clear in the source.

Reviewers: hans, RKSimon

Reviewed By: RKSimon

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D33073

llvm-svn: 302863

7 years agoFix or move tests with non-standard assumptions
Eric Fiselier [Fri, 12 May 2017 01:44:51 +0000 (01:44 +0000)]
Fix or move tests with non-standard assumptions

llvm-svn: 302862

7 years ago[XRay][compiler-rt] Remove unused variable after refactoring
Dean Michael Berris [Fri, 12 May 2017 01:43:20 +0000 (01:43 +0000)]
[XRay][compiler-rt] Remove unused variable after refactoring

Follow-up to D30630.

llvm-svn: 302861

7 years ago[XRay][compiler-rt] Fix misspeling of XRaySledEntry
Dean Michael Berris [Fri, 12 May 2017 01:33:55 +0000 (01:33 +0000)]
[XRay][compiler-rt] Fix misspeling of XRaySledEntry

Follow-up to D30630.

llvm-svn: 302860

7 years agoGuard usage of libc++ regex internals inside test.
Eric Fiselier [Fri, 12 May 2017 01:19:01 +0000 (01:19 +0000)]
Guard usage of libc++ regex internals inside test.

This patch attempts to make lookup_classname.pass.cpp usable against
other STL implementations by guarding the use of __regex_word. That being
said it seems likely that the test is still non-conforming due to how
libc++ handles the "w" character class.

llvm-svn: 302859

7 years agoDWARF: Avoid cross-CU references under Fission
David Blaikie [Fri, 12 May 2017 01:13:45 +0000 (01:13 +0000)]
DWARF: Avoid cross-CU references under Fission

Turns out that the Fission/Split DWARF package format (DWP) is currently
insufficient to handle cross-CU (ref_addr) references. So for now,
duplicate any debug info needed in these situations:
* inlined_subroutine's abstract_origin
* inlined variable's abstract_origin
* types

Keep the ref_addr behavior in general, including in the split DWARF
inline debug info that can be emitted into the object files for online
symbolication.
Keep a flag to use the old (ref_addr) behavior for testing ways of
addressing this limitation in the DWP tool (& for those not using DWP
packaging).

llvm-svn: 302858

7 years ago[XRay][compiler-rt] Runtime changes to support custom event logging
Dean Michael Berris [Fri, 12 May 2017 01:07:41 +0000 (01:07 +0000)]
[XRay][compiler-rt] Runtime changes to support custom event logging

Summary:
This change implements support for the custom event logging sleds and
intrinsics at runtime. For now it only supports handling the sleds in
x86_64, with the implementations for other architectures stubbed out to
do nothing.

NOTE: Work in progress, uploaded for exposition/exploration purposes.

Depends on D27503, D30018, and D33032.

Reviewers: echristo, javed.absar, timshen

Subscribers: mehdi_amini, nemanjai, llvm-commits

Differential Revision: https://reviews.llvm.org/D30630

llvm-svn: 302857

7 years ago[XRay][lib] Support and temporarily skip over CustomEvent records
Dean Michael Berris [Fri, 12 May 2017 01:06:41 +0000 (01:06 +0000)]
[XRay][lib] Support and temporarily skip over CustomEvent records

Summary:
In D30630 we will start writing custom event records. To avoid breaking
the tools that read the FDR mode records, we skip over these records.
To support these custom event records more effectively, we will have to
expose them in the trace loading API. Those changes will be forthcoming.

Reviewers: kpw, pelikan

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D33032

llvm-svn: 302856

7 years ago[tooling] RefactoringCallbacks code cleanup
Alexander Shaposhnikov [Fri, 12 May 2017 00:16:56 +0000 (00:16 +0000)]
[tooling] RefactoringCallbacks code cleanup

This diff
 1. adds missing "explicit" for single argument constructors
 2. adds missing std::move in ReplaceNodeWithTemplate constructor

Test plan: make check-all

Differential revision: https://reviews.llvm.org/D33061

llvm-svn: 302855

7 years agoFix uninitialized bool read causing x86_64-mno-sse.c test failure
Reid Kleckner [Fri, 12 May 2017 00:10:49 +0000 (00:10 +0000)]
Fix uninitialized bool read causing x86_64-mno-sse.c test failure

llvm-svn: 302854

7 years ago[git-llvm] Fix svn:eol-style issue for one-file patches
Reid Kleckner [Fri, 12 May 2017 00:10:19 +0000 (00:10 +0000)]
[git-llvm] Fix svn:eol-style issue for one-file patches

llvm-svn: 302853

7 years agoCallGraph: Remove almost-unused field 'Root'.
Peter Collingbourne [Thu, 11 May 2017 23:59:05 +0000 (23:59 +0000)]
CallGraph: Remove almost-unused field 'Root'.

llvm-svn: 302852

7 years agoChange sample profile writer to make it deterministic.
Dehao Chen [Thu, 11 May 2017 23:43:44 +0000 (23:43 +0000)]
Change sample profile writer to make it deterministic.

Summary: This patch changes the function profile output order to be deterministic. In order to make it easier to understand, hottest functions (with most total samples) is ordered first.

Reviewers: dnovillo, davidxl

Reviewed By: dnovillo

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D33111

llvm-svn: 302851

7 years agoxfail TestClassTemplateParameterPack on gcc to mollify lldb-x86_64-ubuntu-14.04-cmake.
Sean Callanan [Thu, 11 May 2017 23:38:21 +0000 (23:38 +0000)]
xfail TestClassTemplateParameterPack on gcc to mollify lldb-x86_64-ubuntu-14.04-cmake.

llvm-svn: 302850

7 years agoDetemplate compareSections. NFC.
Rafael Espindola [Thu, 11 May 2017 23:37:55 +0000 (23:37 +0000)]
Detemplate compareSections. NFC.

llvm-svn: 302849

7 years agoDetemplate compareSectionsNonScript. NFC.
Rafael Espindola [Thu, 11 May 2017 23:33:19 +0000 (23:33 +0000)]
Detemplate compareSectionsNonScript. NFC.

llvm-svn: 302848

7 years agoDetemplate isRelroSection. NFC.
Rafael Espindola [Thu, 11 May 2017 23:31:06 +0000 (23:31 +0000)]
Detemplate isRelroSection. NFC.

llvm-svn: 302847

7 years agoDetemplate SymbolBody::getGotVA. NFC.
Rafael Espindola [Thu, 11 May 2017 23:28:49 +0000 (23:28 +0000)]
Detemplate SymbolBody::getGotVA. NFC.

llvm-svn: 302846

7 years agoDetemplate the got.
Rafael Espindola [Thu, 11 May 2017 23:26:03 +0000 (23:26 +0000)]
Detemplate the got.

This is a bit hackish, but allows for a lot of followup cleanups.

llvm-svn: 302845

7 years agoRestrict call metadata based hotness detection to Sample PGO mode
Teresa Johnson [Thu, 11 May 2017 23:18:05 +0000 (23:18 +0000)]
Restrict call metadata based hotness detection to Sample PGO mode

Summary:
Don't use the metadata on call instructions for determining hotness
unless we are in sample PGO mode, where it is needed because profile
counts are not accurate. In instrumentation mode this is not necessary
and does more harm than good when calls have VP metadata that hasn't
been properly scaled after transformations or dropped after constant
prop based devirtualization (both should be fixed, but we don't need
to do this in the first place for instrumentation PGO).

This required adjusting a number of tests to distinguish between sample
and instrumentation PGO handling, and to add in profile summary metadata
so that getProfileCount can get the summary.

Reviewers: davidxl, danielcdh

Subscribers: aemerson, rengolin, mehdi_amini, Prazek, llvm-commits

Differential Revision: https://reviews.llvm.org/D32877

llvm-svn: 302844

7 years agoReduce templating. NFC.
Rafael Espindola [Thu, 11 May 2017 23:16:43 +0000 (23:16 +0000)]
Reduce templating. NFC.

llvm-svn: 302843

7 years agoRemove unnecessary mapping from SourceLocation to Module.
Richard Smith [Thu, 11 May 2017 23:11:16 +0000 (23:11 +0000)]
Remove unnecessary mapping from SourceLocation to Module.

When we parse a redefinition of an entity for which we have a hidden existing
declaration, make it visible in the current module instead of mapping the
current source location to its containing module.

llvm-svn: 302842

7 years agoFix XFAIL to reflect recent fixes in GCC
Eric Fiselier [Thu, 11 May 2017 23:04:04 +0000 (23:04 +0000)]
Fix XFAIL to reflect recent fixes in GCC

llvm-svn: 302841

7 years agoModule Debug Info: Emit namespaced C++ forward decls in the correct module.
Adrian Prantl [Thu, 11 May 2017 22:59:19 +0000 (22:59 +0000)]
Module Debug Info: Emit namespaced C++ forward decls in the correct module.

The AST merges NamespaceDecls, but for module debug info it is
important to put a namespace decl (or rather its children) into the
correct (sub-)module, so we need to use the parent module of the decl
that triggered this namespace to be serialized as a second key when
looking up DINamespace nodes.

rdar://problem/29339538

llvm-svn: 302840

7 years ago[DeLICM] Use input access heuristic for mapped PHI WRITEs.
Michael Kruse [Thu, 11 May 2017 22:56:59 +0000 (22:56 +0000)]
[DeLICM] Use input access heuristic for mapped PHI WRITEs.

As with the scalar operand of the initial StoreInst, also use input
accesses when searching for new opportunities after mapping a
PHI write.

The same rational applies here: After LICM has been applied, the
promoted value will either be an instruction in the same statement
(in which case we fall back to try every scalar access of the
statement), or in another statement such that there will be such
an input access. In the latter case other scalars cannot have
originated from the same register promotion, at least not by LICM.

This mostly helps to decrease compilation time and makes debugging
easier by not pursuing unpromising routes. In some circumstances,
it may change the compiler's output.

llvm-svn: 302839

7 years ago[DeLICM] Lookup input accesses.
Michael Kruse [Thu, 11 May 2017 22:56:46 +0000 (22:56 +0000)]
[DeLICM] Lookup input accesses.

Previous to this patch, we used VirtualUse to determine the input
access of an llvm::Value in a statement. The input access is the
READ MemoryAccess that makes a value available in that statement,
which can either be a READ of a MemoryKind::Value or the
MemoryKind::PHI for a PHINode in the statement. DeLICM uses the input
access to heuristically find a candidate to map without searching all
possible values.

This might modify the behaviour in that previously PHI accesses were
not considered input accesses before. This was unintentially lost when
"VirtualUse" was extracted from the "Known Knowledge" patch.

llvm-svn: 302838

7 years ago[VirtualInstruction] Do a lookup instead of a linear search. NFC.
Michael Kruse [Thu, 11 May 2017 22:56:27 +0000 (22:56 +0000)]
[VirtualInstruction] Do a lookup instead of a linear search. NFC.

llvm-svn: 302837

7 years ago[ScopInfo] Keep scalar acceess dictionaries up-to-data. NFC.
Michael Kruse [Thu, 11 May 2017 22:56:12 +0000 (22:56 +0000)]
[ScopInfo] Keep scalar acceess dictionaries up-to-data. NFC.

When removing a MemoryAccess, also remove it from maps pointing to it.
This was already done for InstructionToAccess, but not yet for
ValueReads, ValueWrites and PHIWrites as those were only used during
the ScopBuilder phase. Keeping them updated allows us to use them
later as well.

llvm-svn: 302836

7 years agoIssue diagnostics when returning FP values on x86_64 without SSE1/2
Reid Kleckner [Thu, 11 May 2017 22:43:02 +0000 (22:43 +0000)]
Issue diagnostics when returning FP values on x86_64 without SSE1/2

Avoid using report_fatal_error, because it will ask the user to file a
bug. If the user attempts to disable SSE on x86_64 and them use floating
point, that's a bug in their code, not a bug in the compiler.

This is just a start. There are other ways to crash the backend in this
configuration, but they should be updated to follow this pattern.

Differential Revision: https://reviews.llvm.org/D27522

llvm-svn: 302835

7 years ago[PPC] Change the register constraint of the first source operand of instruction mtvsr...
Guozhi Wei [Thu, 11 May 2017 22:17:35 +0000 (22:17 +0000)]
[PPC] Change the register constraint of the first source operand of instruction mtvsrdd to g8rc_nox0

According to Power ISA V3.0 document, the first source operand of mtvsrdd is constant 0 if r0 is specified. So the corresponding register constraint should be g8rc_nox0.

This bug caused wrong output generated by 401.bzip2 when -mcpu=power9 and fdo are specified.

Differential Revision: https://reviews.llvm.org/D32880

llvm-svn: 302834

7 years ago[DWARF parser] Produce correct template parameter packs
Sean Callanan [Thu, 11 May 2017 22:08:05 +0000 (22:08 +0000)]
[DWARF parser] Produce correct template parameter packs

Templates can end in parameter packs, like this

template <class T...> struct MyStruct
  { /*...*/ };

LLDB does not currently support these parameter packs;
it does not emit them into the template argument list
at all. This causes problems when you specialize, e.g.:

template <> struct MyStruct<int>
  { /*...*/ };
template <> struct MyStruct<int, int> : MyStruct<int>
  { /*...*/ };

LLDB generates two template specializations, each with
no template arguments, and then when they are imported
by the ASTImporter into a parser's AST context we get a
single specialization that inherits from itself,
causing Clang's record layout mechanism to smash its
stack.

This patch fixes the problem for classes and adds
tests. The tests for functions fail because Clang's
ASTImporter can't import them at the moment, so I've
xfailed that test.

Differential Revision: https://reviews.llvm.org/D33025

llvm-svn: 302833

7 years agoReduce template usage. NFC.
Rafael Espindola [Thu, 11 May 2017 22:02:41 +0000 (22:02 +0000)]
Reduce template usage. NFC.

llvm-svn: 302832

7 years ago[GISel]: Remove unused lambda captures. NFC
Aditya Nandakumar [Thu, 11 May 2017 21:56:51 +0000 (21:56 +0000)]
[GISel]: Remove unused lambda captures. NFC

https://reviews.llvm.org/D33085

llvm-svn: 302831

7 years ago[scudo] Use our own combined allocator
Kostya Kortchinsky [Thu, 11 May 2017 21:40:45 +0000 (21:40 +0000)]
[scudo] Use our own combined allocator

Summary:
The reasoning behind this change is twofold:
- the current combined allocator (sanitizer_allocator_combined.h) implements
  features that are not relevant for Scudo, making some code redundant, and
  some restrictions not pertinent (alignments for example). This forced us to
  do some weird things between the frontend and our secondary to make things
  work;
- we have enough information to be able to know if a chunk will be serviced by
  the Primary or Secondary, allowing us to avoid extraneous calls to functions
  such as `PointerIsMine` or `CanAllocate`.

As a result, the new scudo-specific combined allocator is very straightforward,
and allows us to remove some now unnecessary code both in the frontend and the
secondary. Unused functions have been left in as unimplemented for now.

It turns out to also be a sizeable performance gain (3% faster in some Android
memory_replay benchmarks, doing some more on other platforms).

Reviewers: alekseyshl, kcc, dvyukov

Reviewed By: alekseyshl

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D33007

llvm-svn: 302830

7 years agoDecrease inlinecold-threshold to 45
Easwaran Raman [Thu, 11 May 2017 21:36:28 +0000 (21:36 +0000)]
Decrease inlinecold-threshold to 45

I ran the test-suite (including SPEC 2006) in PGO mode comparing cold
thresholds of 225 and 45. Here are some stats on the text size:

Out of 904 tests that ran, 197 see a change in text size. The average
text size reduction (of all the 904 binaries) is 1.07%. Of the 197
binaries, 19 see a text size increase, as high as 18%, but most of them
are small single source benchmarks. There are 3 multisource benchmarks
with a >0.5% size increase (0.7, 1.3 and 2.1 are their % increases). On
the other side of the spectrum, 31 benchmarks see >10% size reduction
and 6 of them are MultiSource.

I haven't run the test-suite with other values of inlinecold-threshold.
Since we have a cold callsite threshold of 45, I picked this value.

Differential revision: https://reviews.llvm.org/D33106

llvm-svn: 302829

7 years agoReduce template usage. NFC.
Rafael Espindola [Thu, 11 May 2017 21:33:30 +0000 (21:33 +0000)]
Reduce template usage. NFC.

llvm-svn: 302828

7 years agoDe-virtualize TerminatorInst successor accessors
Reid Kleckner [Thu, 11 May 2017 21:26:55 +0000 (21:26 +0000)]
De-virtualize TerminatorInst successor accessors

Use the same switch technique to eliminate virtual successor accessors
from TerminatorInst. Extracted from D31261.

NFC

llvm-svn: 302827

7 years agoReduce template usage. NFC.
Rafael Espindola [Thu, 11 May 2017 21:23:38 +0000 (21:23 +0000)]
Reduce template usage. NFC.

llvm-svn: 302826

7 years agoXFAIL this test for Hexagon.
Richard Smith [Thu, 11 May 2017 21:18:27 +0000 (21:18 +0000)]
XFAIL this test for Hexagon.

It's failing due to Hexagon calling convention lowering being broken (empty
structs are not passed even if they have nontrivial destructors / copy ctors).

llvm-svn: 302825

7 years ago[Libcxxabi]: Support using compiler-rt for MinGW64
Martell Malone [Thu, 11 May 2017 21:16:29 +0000 (21:16 +0000)]
[Libcxxabi]: Support using compiler-rt for MinGW64

Reviewers: EricWF

Differential Revision: https://reviews.llvm.org/D33098

llvm-svn: 302824