Commit Graph

221868 Commits

Author SHA1 Message Date
Wei Mi a49559befb [SCEV] Try to reuse existing value during SCEV expansion
Current SCEV expansion will expand SCEV as a sequence of operations
and doesn't utilize the value already existed. This will introduce
redundent computation which may not be cleaned up throughly by
following optimizations.

This patch introduces an ExprValueMap which is a map from SCEV to the
set of equal values with the same SCEV. When a SCEV is expanded, the
set of values is checked and reused whenever possible before generating
a sequence of operations.

The original commit triggered regressions in Polly tests. The regressions
exposed two problems which have been fixed in current version.

1. Polly will generate a new function based on the old one. To generate an
instruction for the new function, it builds SCEV for the old instruction,
applies some tranformation on the SCEV generated, then expands the transformed
SCEV and insert the expanded value into new function. Because SCEV expansion
may reuse value cached in ExprValueMap, the value in old function may be
inserted into new function, which is wrong.
   In SCEVExpander::expand, there is a logic to check the cached value to
be used should dominate the insertion point. However, for the above
case, the check always passes. That is because the insertion point is
in a new function, which is unreachable from the old function. However
for unreachable node, DominatorTreeBase::dominates thinks it will be
dominated by any other node.
   The fix is to simply add a check that the cached value to be used in
expansion should be in the same function as the insertion point instruction.

2. When the SCEV is of scConstant type, expanding it directly is cheaper than
reusing a normal value cached. Although in the cached value set in ExprValueMap,
there is a Constant type value, but it is not easy to find it out -- the cached
Value set is not sorted according to the potential cost. Existing reuse logic
in SCEVExpander::expand simply chooses the first legal element from the cached
value set.
   The fix is that when the SCEV is of scConstant type, don't try the reuse
logic. simply expand it.

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

llvm-svn: 259736
2016-02-04 01:27:38 +00:00
Richard Smith 69cb000974 Fix undefined behavior when compiling in C++14 mode (with sized deletion
enabled): ensure that we do not invoke the sized deallocator for MemoryBuffer
subclasses that have tail-allocated data.

llvm-svn: 259735
2016-02-04 01:21:16 +00:00
Ben Langmuir f5416740fc Fix predefine for __NSConstantString struct type
Per review feedback the name was wrong and it can be used outside
Objective-C.

Unfortunately, making the internal struct visible broke some ASTMatchers
tests that assumed that the first record decl would be from user code,
rather than a builtin type.  I'm worried that this will also affect
users' code.  So this patch adds a typedef to wrap the internal struct
and only makes the typedef visible to namelookup.  This is sufficient to
allow the ASTReader to merge the decls we need without making the struct
itself visible.

rdar://problem/24425801

llvm-svn: 259734
2016-02-04 00:55:24 +00:00
Reid Kleckner cb91e7d395 [codeview] Don't attempt a cross-section label diff
This only comes up when we're trying to find the next .cv_loc label.

Fixes PR26467

llvm-svn: 259733
2016-02-04 00:21:42 +00:00
Kostya Serebryany ce925c580e [libFuzzer] hot fix a test
llvm-svn: 259732
2016-02-04 00:12:28 +00:00
Kostya Serebryany b92602ada0 [libFuzzer] don't write the test unit when a leak is detected (since we don't know which unit causes the leak)
llvm-svn: 259731
2016-02-04 00:02:17 +00:00
Gerolf Hoflehner 2432bd0ddd [SimplifyCFG] Fix for "endless" loop after dead code removal (Alternative to
D16251)

Summary:
This is a simpler fix to the problem than the dominator approach in
http://reviews.llvm.org/D16251. It adds only values into the gather() while loop
that have been seen before.

The actual endless loop is in the constant compare gather() routine in
Utils/SimplifyCFG.cpp. The same value ret.0.off0.i is pushed back into the
queue:
%.ret.0.off0.i = or i1 %.ret.0.off0.i, %cmp10.i

Here is what happens at the IR level:

for.cond.i:                                       ; preds = %if.end6.i,
%if.end.i54
%ix.0.i = phi i32 [ 0, %if.end.i54 ], [ %inc.i55, %if.end6.i ]
%ret.0.off0.i = phi i1 [false, %if.end.i54], [%.ret.0.off0.i, %if.end6.i] <<<
%cmp2.i = icmp ult i32 %ix.0.i, %11
br i1 %cmp2.i, label %for.body.i, label %LBJ_TmpSimpleNeedExt.exit

if.end6.i:                                        ; preds = %for.body.i
%cmp10.i = icmp ugt i32 %conv.i, %add9.i
%.ret.0.off0.i = or i1 %ret.0.off0.i, %cmp10.i <<<

When if.end.i54 gets eliminated which removes the definition of ret.0.off0.i.
The result is the expression %.ret.0.off0.i = or i1 %.ret.0.off0.i, %cmp10.i
(Note the first ‘or’ operand is now %.ret.0.off0.i, and *NOT* %ret.0.off0.i).
And
now there is use of .ret.0.off0.i before a definition which triggers the
“endless” loop in gather():

while(!DFT.empty()) {

    V = DFT.pop_back_val();   // V is .ret.0.off0.i

    if (Instruction *I = dyn_cast<Instruction>(V)) {
      // If it is a || (or && depending on isEQ), process the operands.
      if (I->getOpcode() == (isEQ ? Instruction::Or : Instruction::And)) {
        DFT.push_back(I->getOperand(1));  // This is now .ret.0.off0.i also
        DFT.push_back(I->getOperand(0));

        continue; // “endless loop” for .ret.0.off0.i
      }

Reviewers: reames, ahatanak

Subscribers: llvm-commits

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

llvm-svn: 259730
2016-02-03 23:54:25 +00:00
Pete Cooper 451ec4b68e Add support for -sdk_version cmdline option.
This option is emitted in the min_version load commands.

Note, there's currently a difference in behaviour compared to ld64 in
that we emit a warning if we generate a min_version load command and
didn't give an sdk_version.  We need to decide what the correct behaviour
is here as its possible we want to emit an error and force clients to
provide the option.

llvm-svn: 259729
2016-02-03 23:39:05 +00:00
Manman Ren b72f766e12 Bump DiagnosticSemaKinds count; we're close to hitting it.
$ grep '= DIAG_START_SEMA' include/clang/Basic/DiagnosticIDs.h
       DIAG_START_ANALYSIS      = DIAG_START_SEMA            + 3000
 $ grep 'def ' include/clang/Basic/DiagnosticSemaKinds.td | wc -l
       2994

llvm-svn: 259728
2016-02-03 23:35:29 +00:00
Vedant Kumar 2d5b5d3d3a [InstrProfiling] Fix a comment (NFC)
llvm-svn: 259727
2016-02-03 23:22:43 +00:00
David L Kreitzer f24d409dce Unify the target opcode enum in TargetOpcodes.h and the FixedInstrs array in
CodeGenTarget.cpp to avoid the ordering dependence. NFCI.

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

llvm-svn: 259726
2016-02-03 23:17:32 +00:00
Junmo Park e90057a5f3 Minor code cleanups. NFC.
llvm-svn: 259725
2016-02-03 23:16:39 +00:00
Zachary Turner 3abbf6f6db Fix missing module qualification of subprocess.PIPE.
llvm-svn: 259724
2016-02-03 22:53:18 +00:00
David Majnemer d74490f2cc Print the OffsetStart field's relocation
llvm-svn: 259723
2016-02-03 22:45:21 +00:00
Sanjay Patel e9fa3363b4 rangify; NFCI
llvm-svn: 259722
2016-02-03 22:44:14 +00:00
Quentin Colombet 043406b87f Reapply r259624, it is likely not the commit causing the bot failures.
Original message:
Make CF constant string decl visible to name lookup to fix module errors

The return type of the __builtin___*StringMakeConstantString functions
is a pointer to a struct, so we need that struct to be visible to name
lookup so that we will correctly merge multiple declarations of that
type if they come from different modules.

Incidentally, to make this visible to name lookup we need to rename the
type to __NSConstantString, since the real NSConstantString is an
Objective-C interface type.  This shouldn't affect anyone outside the
compiler since users of the constant string builtins cast the result
immediately to CFStringRef.

Since this struct type is otherwise implicitly created by the AST
context and cannot access namelookup, we make this a predefined type
and initialize it in Sema.

Note: this issue of builtins that refer to types not visible to name
lookup technically also affects other builtins (e.g. objc_msgSendSuper),
but in all other cases the builtin is a library builtin and the issue
goes away if you include the library that defines the types it uses,
unlike for these constant string builtins.

rdar://problem/24425801

llvm-svn: 259721
2016-02-03 22:41:00 +00:00
Sanjay Patel 460ce9cd9b clean up; NFC
llvm-svn: 259720
2016-02-03 22:37:37 +00:00
David Majnemer ac10cfde97 [llvm-readobj] Add support for dumping S_DEFRANGE symbols
llvm-svn: 259719
2016-02-03 22:36:46 +00:00
Pete Cooper 354809e139 Add generation of LC_VERSION_MIN load commands.
If the command line contains something like -macosx_version_min and we
don't explicitly disable generation with -no_version_load_command then
we generate the LC_VERSION_MIN command in the output file.

There's a couple of FIXME's in here.  These will be handled soon with
more tests but I didn't want to grow this patch any more than it already was.

rdar://problem/24472630

llvm-svn: 259718
2016-02-03 22:28:29 +00:00
Evgeniy Stepanov 73583d5f2d [cfi] Safe handling of unaddressable vtable pointers (compiler-rt).
Avoid crashing when printing diagnostics for vtable-related CFI
errors. In diagnostic mode, the frontend does an additional check of
the vtable pointer against the set of all known vtable addresses and
lets the runtime handler know if it is safe to inspect the vtable.

http://reviews.llvm.org/D16824

llvm-svn: 259717
2016-02-03 22:19:04 +00:00
Evgeniy Stepanov f31ea30694 [cfi] Safe handling of unaddressable vtable pointers (clang).
Avoid crashing when printing diagnostics for vtable-related CFI
errors. In diagnostic mode, the frontend does an additional check of
the vtable pointer against the set of all known vtable addresses and
lets the runtime handler know if it is safe to inspect the vtable.

http://reviews.llvm.org/D16823

llvm-svn: 259716
2016-02-03 22:18:55 +00:00
Quentin Colombet 0cdb86bd38 Revert r259624 - Make CF constant string decl visible to name lookup to fix module errors.
This breaks some internal bots in stage2: clang seg fault.
Looking with Ben to see what is going on.

llvm-svn: 259715
2016-02-03 22:14:53 +00:00
Oleksiy Vyalov e551051a58 Pass socket scheme as part of debug server listen URL.
http://reviews.llvm.org/D16861

llvm-svn: 259714
2016-02-03 22:02:43 +00:00
Reid Kleckner 0d4ecb6ff5 Replace static const int with enum to fix obnoxious linker errors about a missing definition
llvm-svn: 259712
2016-02-03 21:45:39 +00:00
Reid Kleckner 17495274fd [unittests] Move TargetRegistry test from Support to MC
This removes the dependency from SupportTests to all of the LLVM
backends, and makes it link faster.

llvm-svn: 259705
2016-02-03 21:41:24 +00:00
Reid Kleckner c2e2311627 Silence -Wsign-conversion issue in ProgramTest.cpp
Unfortunately, ProgramInfo::ProcessId is signed on Unix and unsigned on
Windows, breaking the standard fix of using '0U' in the gtest
expectation.

llvm-svn: 259704
2016-02-03 21:41:12 +00:00
Ana Pazos b3596028cf Fix pointers to go on the right hand side. NFC.
Summary:
Fixed pointers to go on the right hand side following coding guidelines. NFC.

Patch by Mandeep Singh Grang.

Reviewers: majnemer, arsenm, sanjoy

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

llvm-svn: 259703
2016-02-03 21:34:39 +00:00
David Majnemer a53b5bbb18 [LoopStrengthReduce] Don't rewrite PHIs with incoming values from CatchSwitches
Bail out if we have a PHI on an EHPad that gets a value from a
CatchSwitchInst.  Because the CatchSwitchInst cannot be split, there is
no good place to stick any instructions.

This fixes PR26373.

llvm-svn: 259702
2016-02-03 21:30:34 +00:00
David Majnemer fa8681e452 [ScalarEvolutionExpander] Simplify findInsertPointAfter
No functional change is intended.  The loop could only execute, at most,
once.

llvm-svn: 259701
2016-02-03 21:30:31 +00:00
Reid Kleckner eb3bcdd28b [codeview] Remove EmitLabelDiff in favor emitAbsoluteSymbolDiff
llvm-svn: 259700
2016-02-03 21:24:42 +00:00
Reid Kleckner dac21b43d5 [codeview] Use the MCStreamer interface directly instead of AsmPrinter
This is mostly about having shorter lines and standardizing on one
interface, but it also avoids some needless indirection.

No functional change.

llvm-svn: 259697
2016-02-03 21:15:48 +00:00
Keno Fischer 6c1e47a66b [DWARFDebug] Fix another case of overlapping ranges
Summary:
In r257979, I added code to ensure that we wouldn't merge DebugLocEntries if
the pieces they describe overlap. Unfortunately, I failed to cover the case,
where there may have multiple active Expressions in the entry, in which case we
need to make sure that no two values overlap before we can perform the merge.

This fixed PR26148.

Reviewers: aprantl
Differential Revision: http://reviews.llvm.org/D16742

llvm-svn: 259696
2016-02-03 21:13:33 +00:00
Todd Fiala 675bdcedff Address NDEBUG-related linkage issues for Value::assertModuleIsMaterialized()
The IR/Value class had a linkage issue present when LLVM was built
as a library, and the LLVM library build time had different settings
for NDEBUG than the client of the LLVM library.  Clients could get
into a state where the LLVM lib expected
Value::assertModuleIsMaterialized() to be inline-defined in the header
but clients expected that method to be defined in the LLVM library.

See this llvm-commits thread for more details:
http://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20160201/329667.html

llvm-svn: 259695
2016-02-03 21:13:23 +00:00
Tobias Grosser ba043143a9 test: make test case more robust against removal of unrelated instructions
llvm-svn: 259693
2016-02-03 21:10:11 +00:00
Rafael Espindola 9e3f84bf95 Fix addend computation for IRELATIVE relocations.
llvm-svn: 259692
2016-02-03 21:02:48 +00:00
Tim Shen f99f0d5a7e [SelectionDAG] Fix CombineToPreIndexedLoadStore O(n^2) behavior
This patch consists of two parts: a performance fix in DAGCombiner.cpp
and a correctness fix in SelectionDAG.cpp.

The test case tests the bug that's uncovered by the performance fix, and
fixed by the correctness fix.

The performance fix keeps the containers required by the
hasPredecessorHelper (which is a lazy DFS) and reuse them. Since
hasPredecessorHelper is called in a loop, the overall efficiency reduced
from O(n^2) to O(n), where n is the number of SDNodes.

The correctness fix keeps iterating the neighbor list even if it's time
to early return. It will return after finishing adding all neighbors to
Worklist, so that no neighbors are discarded due to the original early
return.

llvm-svn: 259691
2016-02-03 20:58:55 +00:00
Artem Belevich 7b660e2604 [CUDA] added declarations for device-side system calls
...and std:: wrappers for free/malloc.

llvm-svn: 259690
2016-02-03 20:53:58 +00:00
Reid Kleckner de9dfe7888 Fix sign conversion warnings in LLDB Python unittests
llvm-svn: 259689
2016-02-03 20:48:09 +00:00
Richard Smith df18ee9620 Ensure that we substitute into the declaration of a template parameter pack
(that is not a pack expansion) during template argument deduction, even if we
deduced that the pack would be empty.

llvm-svn: 259688
2016-02-03 20:40:30 +00:00
Richard Smith 37acb79084 Refactor conversion of deduced template arguments to reduce repetition.
llvm-svn: 259687
2016-02-03 20:15:01 +00:00
Davide Italiano f5935a0abc [NetBSD] Remove dead code.
PR:		http://reviews.llvm.org/D16818
llvm-svn: 259686
2016-02-03 20:13:50 +00:00
Jim Ingham ac96dd3335 Remove a stray ;.
llvm-svn: 259685
2016-02-03 19:49:03 +00:00
Jim Ingham 22eeb7227c The SetStopInfo from a Mach Exception was setting the stop
reason to None when we stop due to a trace, then noticed that
we were on a breakpoint that was not valid for the current thread.
That should actually have set it back to trace.

This was pr26441 (<rdar://problem/24470203>)

llvm-svn: 259684
2016-02-03 19:45:31 +00:00
Reid Kleckner 45b6159ed3 Minor performance tweaks to llvm-tblgen (and a few that might be a good idea)
Summary:
This patch adds a reserve call to an expensive function
(`llvm::LoadIntrinsics`), and may fix a few other low hanging
performance fruit (I've put them in comments for now, so we can
discuss).

**Motivation:**

As I'm sure other developers do, when I build LLVM, I build the entire
project with the same config (`Debug`, `MinSizeRel`, `Release`, or
`RelWithDebInfo`). However, the `Debug` config also builds llvm-tblgen
in `Debug` mode. Later build steps that run llvm-tblgen then can
actually be the slowest steps in the entire build. Nobody likes slow
builds.

Reviewers: rnk, dblaikie

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

Patch by Alexander G. Riccio

llvm-svn: 259683
2016-02-03 19:34:28 +00:00
Duncan P. N. Exon Smith f42ef3efca re.results.form: Format out-of-range subexpression references as null
Rather than crashing in match_results::format() when a reference to a
marked subexpression is out of range, format the subexpression as empty
(i.e., replace it with an empty string).  Note that
match_results::operator[]() has a range-check and returns a null match
in this case, so this just re-uses that logic.

llvm-svn: 259682
2016-02-03 19:30:20 +00:00
Douglas Gregor 0fc3a00168 [Sema debugger support] Require non-void types to be complete in unknown-anytype casts.
When performing a cast from an __unknown_anytype function call to a
non-void type, we need to make sure that type is complete. Fixes
rdar://problem/23959960.

llvm-svn: 259681
2016-02-03 19:13:08 +00:00
Zachary Turner 62d3a6570a Move some android platform functions to lldbplatformutil.
My eventual goal is to move all of the test decorators to their
own module such as `decorators.py`.  But some of the decorators
use existing functions in `lldbtest.py` and conceptually the
functions are probably more appropriately placed in lldbplatformutil.
Moreover, lldbtest.py is a huge file with a ton of random utility
functions scattered around, so this patch also workds toward the
goal of reducing the footprint of this one module to a more
reasonable size.

So this patch moves some of them over to lldbplatformutil with the
eventual goal of moving decorators over to their own module.

Reviewed By: Tamas Berghammer, Pavel Labath
Differential Revision: http://reviews.llvm.org/D16830

llvm-svn: 259680
2016-02-03 19:12:30 +00:00
Rui Ueyama c2d2f44683 ELF: Remove dead code.
R_X86_64_DTPOFF64 relocs are for the dynamic linker.
Static linkers create them but don't consume them.

llvm-svn: 259679
2016-02-03 19:07:56 +00:00
Anastasia Stulova 126a2b534e Added Anastasia Stulova as a code owner for OpenCL
Reviewers: Chris Lattner

Subscribers: cfe-dev
llvm-svn: 259678
2016-02-03 18:51:19 +00:00
Richard Smith 7b4df3bf5b Fix regression from r259622: the operand of an increment that is the operand of
a cast expression is not the operand of a cast expression itself, so if it's
parenthesized we need to form a ParenExpr not a ParenListExpr.

llvm-svn: 259677
2016-02-03 18:48:43 +00:00