Commit Graph

238900 Commits

Author SHA1 Message Date
Benjamin Kramer a0a13c3649 Move helpers into anonymous namespaces. NFC.
llvm-svn: 277918
2016-08-06 11:21:04 +00:00
Benjamin Kramer 5251494969 [StaticAnalyzer] Remove dead code.
llvm-svn: 277917
2016-08-06 11:20:59 +00:00
Benjamin Kramer b7d3311c77 Move helpers into anonymous namespaces. NFC.
llvm-svn: 277916
2016-08-06 11:13:10 +00:00
David Majnemer 70c93fa69a [CodeGen] Fix a -Wdocumentation warning
A parameter was documented with the wrong name.
No functionality change is intended.

llvm-svn: 277915
2016-08-06 08:37:12 +00:00
David Majnemer a19d0f2f3e [ValueTracking] Teach computeKnownBits about [su]min/max
Reasoning about a select in terms of a min or max allows us to derive a
tigher bound on the result.

llvm-svn: 277914
2016-08-06 08:16:00 +00:00
David Majnemer 1665d8635e [CallGraphSCCPass] Use an ArrayRef instead of a pair of iterators
No functional change is intended.

llvm-svn: 277913
2016-08-06 06:21:02 +00:00
Chandler Carruth 9dd96d73f7 [ADT] Make the triple test 1000x faster through more focused test cases.
The current approach isn't a long-term viable pattern. Given the set of
architectures A, vendors V, operating systems O, and environments E, it
does |A| * |V| * |O| * |E| * 4! tests. As LLVM grows, this test keeps
getting slower, despite my working very hard to make it get some
"optimizations" even in -O0 builds in order to lower the constant
factors. Fundamentally, we're doing an unreasonable amount of work.i

Looking at the specific thing being tested -- the goal seems very
clearly to be testing the *permutations*, not the *combinations*. The
combinations are driving up the complexity much more than anything else.

Instead, test every possible value for a given triple entry in every
permutation of *some* triple. This really seems to cover the core goal
of the test. Every single possible triple component is tested in every
position. But because we keep the rest of the triple constant, it does
so in a dramatically more scalable amount of time. With this model we do
(|A| + |V| + |O| + |E|) * 4! tests.

For me on a debug build, this goes from running for 19 seconds to 19
milliseconds, or a 1000x improvement. This makes a world of difference
for the critical path of 'ninja check-llvm' and other extremely common
workflows.

Thanks to Renato, Dean, and David for the helpful review comments and
helping me refine the explanation of the change.

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

llvm-svn: 277912
2016-08-06 06:00:50 +00:00
Simon Atanasyan 24c24fedba [ELF][MIPS] Produce a correct and complete set of MIPS ELF header flags
The patch extends the `getMipsEFlags` function. Now in that function
we iterate over all object files, parse ELF header flags and merge them.
If a file is incompatible with previously analyzed ones we show an error
or warning. That can happen if, for example, we try to link files with
incompatible ABI, ISA, NAN encoding etc.

There is an alternative solution. We can check and merge flags and
reject incompatible input modules in the `isCompatible` function which
is called from the `SymbolTable::addFile` method. But in that case we
have to save and keep somewhere a merged ELF flags combination to use it
later in the writer.

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

llvm-svn: 277911
2016-08-06 05:11:41 +00:00
Sanjoy Das ba04d3a620 [InstCombine] Don't coerce non-integral pointers to integers
Reviewers: majnemer

Subscribers: mcrosier, llvm-commits

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

llvm-svn: 277910
2016-08-06 02:58:48 +00:00
Matthias Braun 9a0035d8d2 Revert "(refs/bisect/bad) GVN-hoist: enable by default"
GVN-Hoist appears to miscompile llvm-testsuite
SingleSource/Benchmarks/Misc/fbench.c at the moment.

I filed http://llvm.org/PR28880

This reverts commit r277786.

llvm-svn: 277909
2016-08-06 02:23:15 +00:00
Gor Nishanov 31d8c9af89 Part 4c: Coroutine Devirtualization: Devirtualize coro.resume and coro.destroy.
Summary:
This is the 4c patch of the coroutine series. CoroElide pass now checks if PostSplit coro.begin
is referenced by coro.subfn.addr intrinsics. If so replace coro.subfn.addrs with an appropriate coroutine
subfunction associated with that coro.begin.

Documentation and overview is here: http://llvm.org/docs/Coroutines.html.

Upstreaming sequence (rough plan)
1.Add documentation. (https://reviews.llvm.org/D22603)
2.Add coroutine intrinsics. (https://reviews.llvm.org/D22659)
3.Add empty coroutine passes. (https://reviews.llvm.org/D22847)
4.Add coroutine devirtualization + tests.
ab) Lower coro.resume and coro.destroy (https://reviews.llvm.org/D22998)
c) Do devirtualization <= we are here
5.Add CGSCC restart trigger + tests.
6.Add coroutine heap elision + tests.
7.Add the rest of the logic (split into more patches)

Reviewers: majnemer

Subscribers: mehdi_amini, llvm-commits

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

llvm-svn: 277908
2016-08-06 02:16:35 +00:00
Nico Weber c893e603ab Revert r277896.
It breaks ExecutionEngine/OrcLazy/weak-function.ll on most bots.

Script:
--
...
--
Exit Code: 1

Command Output (stderr):
--
Could not find main function.

llvm-svn: 277907
2016-08-06 02:00:45 +00:00
Erik Pilkington f3d77e45c4 [NFC] Silence noisy -Wreturn-type warnings
llvm-svn: 277906
2016-08-06 01:54:50 +00:00
Kyle Butt 71cb44d969 CodeGen: If Convert blocks that would form a diamond when tail-merged.
The following function currently relies on tail-merging for if
conversion to succeed. The common tail of cond_true and cond_false is
extracted, and this then forms a diamond pattern that can be
successfully if converted.

If this block does not get extracted, either because tail-merging is
disabled or the threshold is higher, we should still recognize this
pattern and if-convert it.
define i32 @t2(i32 %a, i32 %b) nounwind {
entry:
	%tmp1434 = icmp eq i32 %a, %b		; <i1> [#uses=1]
	br i1 %tmp1434, label %bb17, label %bb.outer

bb.outer:		; preds = %cond_false, %entry
	%b_addr.021.0.ph = phi i32 [ %b, %entry ], [ %tmp10, %cond_false ]
	%a_addr.026.0.ph = phi i32 [ %a, %entry ], [ %a_addr.026.0, %cond_false ]
	br label %bb

bb:		; preds = %cond_true, %bb.outer
	%indvar = phi i32 [ 0, %bb.outer ], [ %indvar.next, %cond_true ]
	%tmp. = sub i32 0, %b_addr.021.0.ph
	%tmp.40 = mul i32 %indvar, %tmp.
	%a_addr.026.0 = add i32 %tmp.40, %a_addr.026.0.ph
	%tmp3 = icmp sgt i32 %a_addr.026.0, %b_addr.021.0.ph
	br i1 %tmp3, label %cond_true, label %cond_false

cond_true:		; preds = %bb
	%tmp7 = sub i32 %a_addr.026.0, %b_addr.021.0.ph
	%tmp1437 = icmp eq i32 %tmp7, %b_addr.021.0.ph
	%indvar.next = add i32 %indvar, 1
	br i1 %tmp1437, label %bb17, label %bb

cond_false:		; preds = %bb
	%tmp10 = sub i32 %b_addr.021.0.ph, %a_addr.026.0
	%tmp14 = icmp eq i32 %a_addr.026.0, %tmp10
	br i1 %tmp14, label %bb17, label %bb.outer

bb17:		; preds = %cond_false, %cond_true, %entry
	%a_addr.026.1 = phi i32 [ %a, %entry ], [ %tmp7, %cond_true ], [ %a_addr.026.0, %cond_false ]
	ret i32 %a_addr.026.1
}

Without tail-merging or diamond-tail if conversion:
LBB1_1:                                 @ %bb
                                        @ =>This Inner Loop Header: Depth=1
        cmp     r0, r1
        ble     LBB1_3
@ BB#2:                                 @ %cond_true
                                        @   in Loop: Header=BB1_1 Depth=1
        subs    r0, r0, r1
        cmp     r1, r0
        it      ne
        cmpne   r0, r1
        bgt     LBB1_4
LBB1_3:                                 @ %cond_false
                                        @   in Loop: Header=BB1_1 Depth=1
        subs    r1, r1, r0
        cmp     r1, r0
        bne     LBB1_1
LBB1_4:                                 @ %bb17
        bx      lr

With diamond-tail if conversion, but without tail-merging:
@ BB#0:                                 @ %entry
        cmp     r0, r1
        it      eq
        bxeq    lr
LBB1_1:                                 @ %bb
                                        @ =>This Inner Loop Header: Depth=1
        cmp     r0, r1
        ite     le
        suble   r1, r1, r0
        subgt   r0, r0, r1
        cmp     r1, r0
        bne     LBB1_1
@ BB#2:                                 @ %bb17
        bx      lr

llvm-svn: 277905
2016-08-06 01:52:37 +00:00
Kyle Butt 54bf3cef92 IfConverter: Split ScanInstructions into 2 functions.
ScanInstructions is now 2 functions:
AnalyzeBranches and ScanInstructions. ScanInstructions also now takes a
pair of arguments delimiting the instructions to be scanned. This will
be used for forked diamond support to re-scan only a portion of the
block.

llvm-svn: 277904
2016-08-06 01:52:34 +00:00
Kyle Butt 4f0e287906 IfConversion: Document countDuplicatedInstructions. NFC
llvm-svn: 277903
2016-08-06 01:52:33 +00:00
Kyle Butt fe916828ee IfConversion: factor out 2 functions to skip debug instrs. NFC
Skipping debug instructions occurrs repeatedly, factor it out.

llvm-svn: 277902
2016-08-06 01:52:31 +00:00
Michael Zolotukhin 09cf304ebc Revert "[LoopSimplify] Fix updating LCSSA after separating nested loops."
This reverts commit r277877.
Try to appease clang-x64-ninja-win7 buildbot.

llvm-svn: 277901
2016-08-06 01:48:51 +00:00
Richard Trieu e056aee9d9 Fix typos from r277797 and unused variable from r277889.
llvm-svn: 277900
2016-08-06 01:44:06 +00:00
Kostya Serebryany 4cd2845e6a [sanitizer] allocator: move TransferBatch into SizeClassAllocator64/SizeClassAllocator32 because we actually need different iplementations for the 64- and 32-bit case. NFC; the following patches will make the TransferBatch implementations differ
llvm-svn: 277899
2016-08-06 01:24:11 +00:00
Reid Kleckner c209664b07 Try to fix the ill.cc test on Linux
llvm-svn: 277898
2016-08-06 00:57:58 +00:00
Enrico Granata 0765abf772 The lack of classes in the hash table is not an error - it's very legitimately possible for a process to define no ObjC classes of its own. Discovered by debugging /bin/ls
llvm-svn: 277897
2016-08-06 00:57:07 +00:00
Lang Hames 62a459603c [ORC] Add (partial) weak symbol support to the CompileOnDemand layer.
This adds partial support for weak functions to the CompileOnDemandLayer by
modifying the addLogicalModule method to check for existing stub definitions
before building a new stub for a weak function. This scheme is sufficient to
support ODR definitions, but fails for general weak definitions if strong
definition is encountered after the first weak definition. (A more extensive
refactor will be required to fully support weak symbols).

This patch does *not* add weak symbol support to RuntimeDyld: I hope to add
that in the near future.

llvm-svn: 277896
2016-08-06 00:54:43 +00:00
Oleksiy Vyalov 000ca1850d Fix Windows build - add return statement in SBThread::StepUsingScriptedThreadPlan.
llvm-svn: 277895
2016-08-06 00:42:23 +00:00
Reid Kleckner 2a38531eca Use %stdcxx11 instead of -std=c++11 so the test passes with VS 2015
llvm-svn: 277894
2016-08-06 00:37:14 +00:00
Zachary Turner 83816cea35 Fix a -Wunused-const-variable due to a bug in clang.
llvm-svn: 277893
2016-08-06 00:13:32 +00:00
Sanjoy Das b8c2ebea08 [IRCE] Remove unused headers; NFC
llvm-svn: 277892
2016-08-06 00:02:01 +00:00
Sanjoy Das cf181867a6 [IRCE] Preserve loop-simplify form
Fixes PR28764.  Right now there is no way to test this, but (as
mentioned on the PR) with Michael Zolotukhin's yet to be checked in
LoopSimplify verfier, 8 of the llvm-lit tests for IRCE crash.

llvm-svn: 277891
2016-08-06 00:01:56 +00:00
Jim Ingham bbe3288b06 Mention the scripted thread plans in the python reference.
llvm-svn: 277890
2016-08-05 23:35:26 +00:00
Richard Trieu 81b6c561ea Fix two false positives in -Wreturn-stack-address
If the return type is a pointer and the function returns the reference to a
pointer, don't warn since only the value is returned, not the reference.

If a reference function parameter appears in the reference chain, don't warn
since binding happens at the caller scope, so addresses returned are not
to local stack.  This includes default arguments as well.

llvm-svn: 277889
2016-08-05 23:24:47 +00:00
Zachary Turner 9e91c28b71 Resubmit "Make YAML support SmallVector"
This resubmits a3770391c5fb64108d565e12f61dd77ce71b5b4f,
which was reverted due to breakages on non-Windows machines.

Due to differences in template instantiation rules on Microsoft
and non-Microsoft platforms, a member access restriction was
triggering on non-Microsoft compilers.  Previously, a friend
declaration for std::vector<> had been introduced into the
DebugMap class to make the member access restriction pass,
but the introduction of support for SmallVector<> meant that
an additional friend declaration would need to be added.

This didn't really make a lot of sense since the user of the
macro is probably only using one type (SmallVector<>, vector<>,
etc) and we could in theory add support for even more types
to this macro in the future (e.g. std::deque), so rather than
add another friend declaration, I just made the type being
referenced a public nested typedef instead of a private nested
typedef.

llvm-svn: 277888
2016-08-05 23:12:31 +00:00
Erik Pilkington 796a3e2bdd [NFC][ObjC Availability] Refactor DiagnoseAvailabilityOfDecl
Differential revision: https://reviews.llvm.org/D23221

llvm-svn: 277887
2016-08-05 22:59:03 +00:00
Nico Weber 023bb97737 Disable a few more flaky asan64 tests.
llvm-svn: 277886
2016-08-05 22:51:10 +00:00
Vedant Kumar 957d7a00bc [clang-tblgen] Remove unused #include (NFC)
llvm-svn: 277885
2016-08-05 22:48:53 +00:00
Jim Ingham fd0dbab248 Mention is_stale in the scripted step doc.
llvm-svn: 277884
2016-08-05 22:47:43 +00:00
Sanjay Patel 8e3ab17c44 [InstCombine] refactor ctlz/cttz folds (NFCI)
Note that this fold really belongs in InstSimplify.
Refactoring here anyway as an intermediate step because
there's a planned addition to this function in D23134.

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

llvm-svn: 277883
2016-08-05 22:42:46 +00:00
Nico Weber 0f6aad4ad2 Disable a few win asan64 tests that don't reliably pass, https://reviews.llvm.org/D23230
llvm-svn: 277882
2016-08-05 22:36:30 +00:00
Justin Bogner 1219a60e26 Revert "Make YAML support SmallVector"
This breaks building dsymutil, causing my local build and many bots to
fail.

This reverts r277870.

llvm-svn: 277881
2016-08-05 22:32:33 +00:00
Daniel Berlin 7ac3d74017 [MSSA] Use depth first iterator instead of custom version.
Summary:
Originally the plan was to use the custom worklist to do some block popping,
and because we don't actually need a visited set. The custom one we have
here is slightly broken, and it's not worth fixing vs using depth_first_iterator since we aren't going to go the route we originally
were.

Fixes PR28874
Reviewers: george.burgess.iv

Subscribers: llvm-commits, gberry

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

llvm-svn: 277880
2016-08-05 22:09:14 +00:00
Jim Ingham c915a7d2e8 Add a few more needed bits to the scripted thread plans.
llvm-svn: 277879
2016-08-05 22:06:12 +00:00
Justin Bogner 272cbacc25 CodeView: Remove an unused variable
It was breaking the -Werror build.

llvm-svn: 277878
2016-08-05 21:57:10 +00:00
Michael Zolotukhin 4c65c3596a [LoopSimplify] Fix updating LCSSA after separating nested loops.
This fixes PR28825. The problem was that we only checked if a value from
a created inner loop is used in the outer loop, and fixed LCSSA for
them. But we missed to fixup LCSSA for values used in exits of the outer
loop.

llvm-svn: 277877
2016-08-05 21:52:58 +00:00
Zachary Turner 5e35eaac83 Fix non portable include path.
llvm-svn: 277876
2016-08-05 21:50:02 +00:00
Justin Bogner 6863027f00 PowerPC: Add a triple to this test
This is running opt without specifying a triple, which isn't correct.

llvm-svn: 277875
2016-08-05 21:49:54 +00:00
Reid Kleckner 9cba2e2d97 Fix two tests in Win64 ASan
Go back to intercepting kernel32!RaiseException, and only go for
ntdll!RtlRaiseException if that fails. Fixes throw_and_catch.cc test.

Work around an issue in LLVM's win64 epilogues. We end up with an
epilogue that looks like this, and it drives the Win64 unwinder crazy
until stack overflow:
        call    ill_cc!__asan_handle_no_return
        xor     eax,eax
        add     rsp,40h // epilogue starts
        pop     rbp     // CSR
        ud2             // Trap here
        ret             // Ret?
        nop     word ptr [rax+rax]
        sub     rsp,28h // Next function

Will file a PR soon.

llvm-svn: 277874
2016-08-05 21:47:46 +00:00
Daniel Berlin 7af95876cf [MSSA] Match assert vs llvm_unreachable style in verification functions.
llvm-svn: 277873
2016-08-05 21:47:20 +00:00
Daniel Berlin 2919b1c41b Rewrite domination verifier to handle local domination as well.
Summary:
Rewrite domination verifier to handle local domination as well.
This catches a bug Geoff Berry noticed.

Reviewers: george.burgess.iv

Subscribers: llvm-commits

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

llvm-svn: 277872
2016-08-05 21:46:52 +00:00
Zachary Turner 5e3e4bb26b [CodeView] Decouple record deserialization from visitor dispatch.
Until now, our use case for the visitor has been to take a stream of bytes
representing a type stream, deserialize the records in sequence, and do
something with them, where "something" is determined by how the user
implements a particular set of callbacks on an abstract class.

For actually writing PDBs, however, we want to do the reverse. We have
some kind of description of the list of records in their in-memory format,
and we want to process each one. Perhaps by serializing them to a byte
stream, or perhaps by converting them from one description format (Yaml)
to another (in-memory representation).

This was difficult in the current model because deserialization and
invoking the callbacks were tightly coupled.

With this patch we change this so that TypeDeserializer is itself an
implementation of the particular set of callbacks. This decouples
deserialization from the iteration over a list of records and invocation
of the callbacks.  TypeDeserializer is initialized with another
implementation of the callback interface, so that upon deserialization it
can pass the deserialized record through to the next set of callbacks. In
a sense this is like an implementation of the Decorator design pattern,
where the Deserializer is a decorator.

This will be useful for writing Pdbs from yaml, where we have a
description of the type records in Yaml format. In this case, the visitor
implementation would have each visitation callback method implemented in
such a way as to extract the proper set of fields from the Yaml, and it
could maintain state that builds up a list of these records. Finally at
the end we can pass this information through to another set of callbacks
which serializes them into a byte stream.

Reviewed By: majnemer, ruiu, rnk
Differential Revision: https://reviews.llvm.org/D23177

llvm-svn: 277871
2016-08-05 21:45:34 +00:00
Zachary Turner 9c3dac8efd Make YAML support SmallVector
Currently YAML sequences require std::vectors. All of the methods that the
YAML parser accesses though are present in SmallVector, so there's no
reason we can't support SmallVector inherently. This patch does that.

Reviewed By: majnemer
Differential Revision: https://reviews.llvm.org/D23213

llvm-svn: 277870
2016-08-05 21:45:19 +00:00
Pete Cooper d0de3683ec ExportTrie nodes need to be visisted in order.
The export trie was being emitted in the order the nodes were
added to the vector, but instead needs to be visited in the order
that the nodes are traversed.  This matches the behaviour of ld64.

llvm-svn: 277869
2016-08-05 21:37:12 +00:00