Commit Graph

269952 Commits

Author SHA1 Message Date
George Karpenkov a2f383d072 Fixed driver tests for -fsanitize=fuzzer.
llvm-svn: 311412
2017-08-22 00:04:05 +00:00
George Karpenkov 10ab2ace13 Move libFuzzer to compiler_rt.
Resulting library binaries will be named libclang_rt.fuzzer*, and will
be placed in Clang toolchain, allowing redistribution.

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

llvm-svn: 311407
2017-08-21 23:25:50 +00:00
George Karpenkov 9f6f74c2c5 Moving libFuzzer to compiler-rt: required updates to the Clang driver.
Differential Revision: https://reviews.llvm.org/D36909

llvm-svn: 311406
2017-08-21 23:25:19 +00:00
George Karpenkov 748bf121bb Moving libFuzzer from LLVM to compiler-rt.
This change only removes libFuzzer tests and CMake machinery,
the source copy temporarily remains at the old location.

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

llvm-svn: 311405
2017-08-21 23:25:12 +00:00
Michael Kruse f281ae5992 [test] Add some test cases for computeArrayUnused.
llvm-svn: 311404
2017-08-21 23:04:55 +00:00
Michael Kruse ade14269cd [DeLICM] Fix unused zone for writes without in-between read.
The implementation of computeArrayUnused did not consider writes without
reads before, except for the first write in the SCoP. This caused it to
'forget' writes directly following another write.

This patch re-adds the entire reaching defintion of a write that has not
been covered before by a read.

This fixes Polybench 4.2 2mm where only one of the matrix-multiplication
was detected.

llvm-svn: 311403
2017-08-21 23:04:45 +00:00
Justin Bogner 7d449d31a4 Re-apply "Introduce FuzzMutate library"
Same as r311392 with some fixes for library dependencies. Thanks to
Chapuni for helping work those out!

Original commit message:

This introduces the FuzzMutate library, which provides structured
fuzzing for LLVM IR, as described in my EuroLLVM 2017 talk. Most of
the basic mutators to inject and delete IR are provided, with support
for most basic operations.

llvm-svn: 311402
2017-08-21 22:57:06 +00:00
Quentin Colombet 4056e80719 [RegAlloc] Make sure live-ranges reflect the state of the IR when removing them
When removing a live-range we used to not touch them making debug
prints harder to read because the IR was not matching what the
live-ranges information was saying.

This only affects debug printing and allows to put stronger asserts in
the code (see r308906 for instance).

llvm-svn: 311401
2017-08-21 22:56:18 +00:00
Craig Topper 7227ebad9c [ValueTracking] Add assertions that the starting Depth in isKnownToBeAPowerOfTwo and ComputeNumSignBitsImpl is not above MaxDepth
The function does an equality check later to terminate the recursion, but that won't work if its starts out too high. Similar assert already exists in computeKnownBits.

llvm-svn: 311400
2017-08-21 22:56:12 +00:00
Bruce Mitchener 416bc3d70a lldb-argdumper doesn't need lldbCore.
Summary: lldb-argdumper only needs lldbUtility to successfully build and link.

Reviewers: beanz, zturner, labath

Subscribers: mgorny, lldb-commits

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

llvm-svn: 311399
2017-08-21 22:54:49 +00:00
Akira Hatanaka a423cb431d [Driver][Darwin] Do not pass -munwind-table if -fno-excpetions is
supplied.

With this change, -fno-exceptions disables unwind tables unless
-funwind-tables is supplied too or the target is x86-64 (x86-64 requires
emitting unwind tables).

rdar://problem/33934446

llvm-svn: 311397
2017-08-21 22:46:46 +00:00
Sanjay Patel 6f527aae0b [InstCombine] add udiv/urem tests with constant numerator; NFC
llvm-svn: 311396
2017-08-21 22:40:02 +00:00
Evgeniy Stepanov 753297e634 Fix ASan version list dependency in multi-arch builds.
Fixes PR32390.

Patch by Andrey Krayniak.

llvm-svn: 311394
2017-08-21 22:31:31 +00:00
Justin Bogner 6e39755d84 Revert "Re-apply "Introduce FuzzMutate library""
The dependencies for the new library seem to be misconfigured on some
linux configs:

  http://bb.pgr.jp/builders/llvm-i686-linux-RA/builds/5435/steps/build_all/logs/stdio

This reverts r311392.

llvm-svn: 311393
2017-08-21 22:28:47 +00:00
Justin Bogner f5c8736482 Re-apply "Introduce FuzzMutate library"
Redo r311356 with a fix to avoid std::uniform_int_distribution<bool>.
The bool specialization is undefined according to the standard, even
though libc++ seems to have it.

Original commit message:

This introduces the FuzzMutate library, which provides structured
fuzzing for LLVM IR, as described in my [EuroLLVM 2017 talk][1]. Most
of the basic mutators to inject and delete IR are provided, with
support for most basic operations.

llvm-svn: 311392
2017-08-21 22:25:04 +00:00
Stephan T. Lavavej 4c30b74390 [Driver] Recognize DevDiv internal builds of MSVC, with a different directory structure.
This is a reasonably non-intrusive change, which I've verified
works for both x86 and x64 DevDiv-internal builds.

The idea is to change `bool IsVS2017OrNewer` into a 3-state
`ToolsetLayout VSLayout`. Either a build is DevDiv-internal,
released VS 2017 or newer, or released VS 2015 or older. When looking at
the directory structure, if instead of `"VC"` we see `"x86ret"`, `"x86chk"`,
`"amd64ret"`, or `"amd64chk"`, we recognize this as a DevDiv-internal build.

After we get past the directory structure validation, we use this knowledge
to regenerate paths appropriately. `llvmArchToDevDivInternalArch()` knows how
we use `"i386"` subdirectories, and `MSVCToolChain::getSubDirectoryPath()`
uses that. It also knows that DevDiv-internal builds have an `"inc"`
subdirectory instead of `"include"`.

This may still not be the "right" fix in any sense, but I believe that it's
non-intrusive in the sense that if the special directory names aren't found,
no codepaths are affected. (`ToolsetLayout::OlderVS` and
`ToolsetLayout::VS2017OrNewer` correspond to `IsVS2017OrNewer` being `false`
or `true`, respectively.) I searched for all references to `IsVS2017OrNewer`,
which are places where Clang cares about VS's directory structure, and the
only one that isn't being patched is some logic to deal with
cross-compilation. I'm fine with that not working for DevDiv-internal builds
for the moment (we typically test the native compilers), so I added a comment.

Fixes D36860.

llvm-svn: 311391
2017-08-21 22:19:33 +00:00
Sanjay Patel 5e3037cfc4 [InstCombine] add more tests for udiv/urem narrowing; NFC
We don't currently limit these folds with hasOneUse() or shouldChangeType().

llvm-svn: 311390
2017-08-21 21:57:52 +00:00
Evandro Menezes bc11ca1a31 [AArch64] Restore the test of conditional branch fusion
Restore the functionality of this test that was broken by
https://reviews.llvm.org/rL306144.

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

llvm-svn: 311389
2017-08-21 21:57:43 +00:00
Tim Northover ef1fc5ae89 GlobalISel (AArch64): fix ABI at border between GPRs and SP.
If a struct would end up half in GPRs and half on SP the ABI says it should
actually go entirely on the stack. We were getting this wrong in GlobalISel
before, causing compatibility issues.

llvm-svn: 311388
2017-08-21 21:56:11 +00:00
Steven Wu 010fc49e42 [IR] AutoUpgrade ModuleFlagBehavior for PIC and PIE level
Summary:
From r303590, ModuleFlagBehavior for PIC and PIE level is changed from
Error to Max. This will cause bitcode compatibility issue when linking
against a bitcode static archive built with old compiler.
Add an auto-ugprade path to upgrade the the ModuleFlagBehavior in the
old bitcode to match the new one so IRLinker can link them.

Reviewers: tejohnson, mehdi_amini, dexonsmith

Reviewed By: dexonsmith

Subscribers: hans, llvm-commits

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

llvm-svn: 311387
2017-08-21 21:49:13 +00:00
Kostya Kortchinsky 0d3439a29c [sanitizer] Do not over-dup string flags
Summary:
String flags values appear to be duped twice. Once in `FlagParser::parse_flag`
using the `LowLevelAllocator` via `ll_strndup`, once in
`FlagHandler<const char *>::Parse` using the `InternalAllocator` via
`internal_strdup`. It looks like the second one is redundant, as the memory
for the first one is never freed and not used for anything else.

Assigning the value to the flag instead of duping it has a few advantages:
- if it was the only use of the `InternalAllocator` (which is the case for
  Scudo), then the related code will not be compiled it, which saves us a
  whole instantiation of the CombinedAllocator worth of extra code;
- in the event a string flag is parsed, the `InternalAllocator` would have
  created a whole SizeClassAllocator32 region for a single allocation, which is
  kind of wasteful.
- also, the string is dup'ed twice for the whole lifetime of a process.

I tested check-{sanitizer,asan,tsan,ubsan,scudo} successfully, so as far as I
can tell this doesn't appear to have bad side effects.

Reviewers: eugenis, alekseyshl

Reviewed By: eugenis

Subscribers: kubamracek, llvm-commits

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

llvm-svn: 311386
2017-08-21 21:25:38 +00:00
George Karpenkov 93e9e8a0d3 [NFC CMake] Do not relink test targets every time in compiler-rt
CMake's add_custom_target is considered to be *always* out of date.
This patch changes it to a combination of add_custom_target and
add_custom_command which actually tracks dependencies' timestamps.

On my machine this reliably saves 6-7 seconds on each test group.
This can be a large difference when debugging small tests.

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

llvm-svn: 311384
2017-08-21 21:19:13 +00:00
Craig Topper 775ffcc8f5 [InstCombine] Move the checks for pointer types in getMaskedTypeForICmpPair earlier in the function
I don't think there's any reason to have them scattered about and on all 4 operands. We already have an early check that both compares must be the same type. And within a given compare the LHS and RHS must have the same type. Beyond that I don't think there's anyway this function returns anything valid for pointer types. So let's just return early and be done with it.

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

llvm-svn: 311383
2017-08-21 21:00:45 +00:00
Pirama Arumuga Nainar 3d48bb5fc2 [Support, Windows] Handle long paths with unix separators
Summary:
The function widenPath() for Windows also normalizes long path names by
iterating over the path's components and calling append().  The
assumption during the iteration that separators are not returned by the
iterator doesn't hold because the iterators do return a separator when
the path has a drive name.  Handle this case by ignoring separators
during iteration.

Reviewers: rnk

Subscribers: danalbert, srhines

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

llvm-svn: 311382
2017-08-21 20:49:44 +00:00
Sanjoy Das 08a38fe71e Revert "Reapply: [ADCE][Dominators] Teach ADCE to preserve dominators"
Summary: This partially reverts commit r311057 since it breaks ADCE.  See PR34258.

Reviewers: kuhar

Subscribers: mcrosier, david2050, llvm-commits

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

llvm-svn: 311381
2017-08-21 20:39:18 +00:00
Sam Elliott 6f9a9b5769 [ORE] Remove Old Optimization Remark API
Summary: https://bugs.llvm.org/show_bug.cgi?id=33789

Reviewers: anemet

Reviewed By: anemet

Subscribers: llvm-commits

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

llvm-svn: 311380
2017-08-21 20:30:44 +00:00
George Karpenkov 9d7a75d617 Fix multi-architecture build for lib/xray.
Differential Revision: https://reviews.llvm.org/D36881

llvm-svn: 311379
2017-08-21 20:28:32 +00:00
Zachary Turner 5641c07d6b [PDB] Serialize records into a stack-allocated buffer.
We were using a std::vector<> and resizing to MaxRecordLength,
which is ~64KB.  We would then do this repeatedly often many
times in a tight loop, which was causing measurable performance
impact when linking PDBs.

Patch by Alex Telishev
Differential Revision: https://reviews.llvm.org/D36940

llvm-svn: 311375
2017-08-21 20:17:19 +00:00
George Karpenkov fb0994b37e Always compile libFuzzer with no coverage
Do not compile libFuzzer itself with coverage, regardless of LLVM variables

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

llvm-svn: 311374
2017-08-21 20:12:58 +00:00
Zachary Turner d76dc2d31e [lld/pdb] Speed up construction of publics & globals addr map.
computeAddrMap function calls std::stable_sort with a comparison
function that computes deserialized symbols every time its called.
In the result deserializeAs<PublicSym32> is called 20-30 times per
symbol. It's much faster to calculate it beforehand and pass a
pointer to it to the comparison function.

Patch by Alex Telishev
Differential Revision: https://reviews.llvm.org/D36941

llvm-svn: 311373
2017-08-21 20:08:40 +00:00
Haicheng Wu 0812c5bea3 [InlineCost] Add cl::opt to allow full inline cost to be computed for debugging purposes.
Currently, the inline cost model will bail once the inline cost exceeds the
inline threshold in order to avoid unnecessary compile-time. However, when
debugging it is useful to compute the full cost, so this command line option
is added to override the default behavior.

I took over this work from Chad Rosier (mcrosier@codeaurora.org).

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

llvm-svn: 311371
2017-08-21 20:00:09 +00:00
Chad Rosier 4eb18742ca [InlineCost] Add more debug during inline cost computation.
llvm-svn: 311370
2017-08-21 19:56:46 +00:00
Zachary Turner abc037927b [BinaryStream] Defaultify copy and move constructors.
The various BinaryStream classes had explicit copy constructors
which resulted in deleted move constructors.  This was causing
the internal std::shared_ptr to get copied rather than moved
very frequently, since these classes are often used as return
values.

Patch by Alex Telishev
Differential Revision: https://reviews.llvm.org/D36942

llvm-svn: 311368
2017-08-21 19:46:46 +00:00
Sanjay Patel 82ec872990 [LibCallSimplifier] try harder to fold memcmp with constant arguments (2nd try)
The 1st try was reverted because it could inf-loop by creating a dead instruction.
Fixed that to not happen and added a test case to verify.

Original commit message:

Try to fold:
memcmp(X, C, ConstantLength) == 0 --> load X == *C

Without this change, we're unnecessarily checking the alignment of the constant data,
so we miss the transform in the first 2 tests in the patch.

I noted this shortcoming of LibCallSimpifier in one of the recent CGP memcmp expansion
patches. This doesn't help the example in:
https://bugs.llvm.org/show_bug.cgi?id=34032#c13
...directly, but it's worth short-circuiting more of these simple cases since we're
already trying to do that.

The benefit of transforming to load+cmp is that existing IR analysis/transforms may
further simplify that code. For example, if the load of the variable is common to
multiple memcmp calls, CSE can remove the duplicate instructions.

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

llvm-svn: 311366
2017-08-21 19:13:14 +00:00
Kamil Rytarowski d986545df6 Enable libfuzzer on NetBSD/amd64
Summary:
Enable SanitizerKind::Fuzzer and SanitizerKind::FuzzerNoLink on x86_64.

Sponsored by <The NetBSD Foundation>

Reviewers: joerg, kcc, vitalybuka, george.karpenkov

Reviewed By: vitalybuka

Subscribers: cfe-commits, #sanitizers

Tags: #sanitizers

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

llvm-svn: 311365
2017-08-21 19:12:14 +00:00
Craig Topper 74177e1ed1 [InstCombine] Teach foldSelectICmpAnd to recognize a (icmp slt X, 0) and (icmp sgt X, -1) as equivalent to an and with the sign bit of the truncated type
This is similar to what was already done in foldSelectICmpAndOr. Ultimately I'd like to see if we can call foldSelectICmpAnd from foldSelectIntoOp if we detect a power of 2 constant. This would allow us to remove foldSelectICmpAndOr entirely.

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

llvm-svn: 311362
2017-08-21 19:02:06 +00:00
Siddharth Bhat a8c329b0eb [ManagedMemoryRewrite] slightly tweak debug output style. [NFC]
llvm-svn: 311361
2017-08-21 18:58:33 +00:00
Siddharth Bhat 557ce3a8b0 [ManagedMemoryRewrite] Print reasons for skipping global array to dbgs(). [NFC]
llvm-svn: 311360
2017-08-21 18:52:15 +00:00
Justin Bogner b5fb3b56d7 Revert "Introduce FuzzMutate library"
Looks like this fails to build with libstdc++.

This reverts r311356

llvm-svn: 311358
2017-08-21 17:57:12 +00:00
Justin Bogner 0233637085 Introduce FuzzMutate library
This introduces the FuzzMutate library, which provides structured
fuzzing for LLVM IR, as described in my [EuroLLVM 2017 talk][1]. Most
of the basic mutators to inject and delete IR are provided, with
support for most basic operations.

I will follow up with the instruction selection fuzzer, which is
implemented in terms of this library.

[1]: http://llvm.org/devmtg/2017-03//2017/02/20/accepted-sessions.html#2

llvm-svn: 311356
2017-08-21 17:44:36 +00:00
Michal Gorny d5ac1812b7 [unittests] Build LLVMTestingSupport for out-of-source builds
The Process/gdb-remote test now requires the LLVMTestingSupport library
that is not installed by LLVM. As a result, when doing an out-of-source
build it fails being unable to find the library. To solve that, build
a local copy of the library when building LLDB with unittests and LLVM
sources available. This is based on how we deal with bundled gtest
sources.

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

llvm-svn: 311355
2017-08-21 17:41:39 +00:00
Michal Gorny 7e1c51e0c1 [cmake] Explicitly link dependency libraries in the Host library
Add explicit linkage to the necessary system libraries in the Host
library. Otherwise, the library fails to build with -Wl,--as-needed.
The system libraries ended up being listed on the linker command-line
before the static libraries needing them, resulting in --as-needed
stripping them.

Listing the dependent libraries explicitly is the canonical way of
declaring libraries in CMake. It guarantees that the system library
dependencies will be correctly propagated to reverse dependencies.

The code used to link libraries reuses existing EXTRA_LIBS variable,
copying code from other parts of LLDB. We might eventually remove
the direct use of system libraries in the programs; however, I would
prefer if we focused on fixing the build regressions in 5.0 branch
first, and went further after the release.

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

llvm-svn: 311354
2017-08-21 17:41:33 +00:00
Sean Fertile 00393cce3a [PPC] Refine checks for emiting TOC restore nop and tail-call eligibility.
For the medium and large code models we only need to check if a call crosses
dso-boundaries when considering tail-call elgibility.

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

llvm-svn: 311353
2017-08-21 17:35:32 +00:00
Sam Elliott e963c89d11 Migrate WholeProgramDevirt to new Optimization Remark API
Summary:
This is an attempt to move WholeProgramDevirt to the new remark API.

https://bugs.llvm.org/show_bug.cgi?id=33793

Reviewers: anemet

Reviewed By: anemet

Subscribers: fhahn, llvm-commits

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

llvm-svn: 311352
2017-08-21 16:57:21 +00:00
Davide Italiano 5a2530da05 [APFloat] Fix IsInteger() for DoubleAPFloat.
Previously, we would just assert instead.

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

llvm-svn: 311351
2017-08-21 16:51:54 +00:00
Sanjay Patel cf081f9a30 [InstCombine] add tests for memcmp with constant; NFC
This is the baseline (current) version of the tests that would
have been added with the transform in r311333 (reverted at 
r311340 due to inf-looping).

Adding these now to aid in testing and minimize the patch if/when
it is reinstated.

llvm-svn: 311350
2017-08-21 16:47:12 +00:00
Sam Elliott e604b563ea Emit only A Single Opt Remark When Inlining
Summary:
This updates the Inliner to only add a single Optimization
Remark when Inlining, rather than an Analysis Remark and an
Optimization Remark.

Fixes https://bugs.llvm.org/show_bug.cgi?id=33786

Reviewers: anemet, davidxl, chandlerc

Reviewed By: anemet

Subscribers: haicheng, fhahn, mehdi_amini, dblaikie, llvm-commits, eraman

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

llvm-svn: 311349
2017-08-21 16:45:47 +00:00
Sam Elliott 29404b3a62 [lld] Update Tests for Emitting Single Inline Remark
Summary: This change depends on https://reviews.llvm.org/D36054 and should be landed at the same time.

Reviewers: anemet

Reviewed By: anemet

Subscribers: llvm-commits, emaste

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

llvm-svn: 311348
2017-08-21 16:41:59 +00:00
Sam Elliott 2307905561 [clang] Fix tests for Emitting Single Inline Remark
Summary: This change depends on https://reviews.llvm.org/D36054 and should be landed at the same time.

Reviewers: anemet

Reviewed By: anemet

Subscribers: cfe-commits

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

llvm-svn: 311347
2017-08-21 16:40:35 +00:00
Peter Szecsi 3c3e1b0b54 [StaticAnalyzer] LoopUnrolling: Track a LoopStack in order to completely unroll specific loops
The LoopExit CFG information provides the opportunity to not mark the loops but
having a stack which tracks if a loop is unrolled or not. So in case of
simulating a loop we just add it and the information if it meets the
requirements to be unrolled to the top of the stack.

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

llvm-svn: 311346
2017-08-21 16:32:57 +00:00