platform/upstream/llvm.git
7 years ago[SCEV] Fix wrong Equal predicate created in getAddRecForPhiWithCasts
Dorit Nuzman [Sun, 10 Dec 2017 11:13:35 +0000 (11:13 +0000)]
[SCEV] Fix wrong Equal predicate created in getAddRecForPhiWithCasts

CreateAddRecFromPHIWithCastsImpl() adds an IncrementNUSW overflow predicate
which allows the PSCEV rewriter to rewrite this scev expression:
 (zext i8 {0, + , (trunc i32 step to i8)} to i32)
into
 {0, +, (sext i8 (trunc i32 step to i8) to i32)}

But then it adds the wrong Equal predicate:
 %step == (zext i8 (trunc i32 %step to i8) to i32).
instead of:
 %step == (sext i8 (trunc i32 %step to i8) to i32)

This is fixed here.

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

llvm-svn: 320298

7 years agoFix MSVC 'not all control paths return a value' warning
Simon Pilgrim [Sun, 10 Dec 2017 11:05:14 +0000 (11:05 +0000)]
Fix MSVC 'not all control paths return a value' warning

llvm-svn: 320297

7 years ago[X86] Tag MORESTACK instructions as ret scheduler class
Simon Pilgrim [Sun, 10 Dec 2017 10:08:21 +0000 (10:08 +0000)]
[X86] Tag MORESTACK instructions as ret scheduler class

llvm-svn: 320296

7 years ago[X86] Fix duplicate entries in skylake server scheduler model by changing Z128 to...
Craig Topper [Sun, 10 Dec 2017 09:14:45 +0000 (09:14 +0000)]
[X86] Fix duplicate entries in skylake server scheduler model by changing Z128 to Z256

Based on the fact that the 'Y' version of the instruction is next to this, I assume Z256 is the intended value.

llvm-svn: 320295

7 years ago[X86] Add MOVQI2PQIrm, MOVSDmr, and MOVSDrm to scheduler information
Craig Topper [Sun, 10 Dec 2017 09:14:44 +0000 (09:14 +0000)]
[X86] Add MOVQI2PQIrm, MOVSDmr, and MOVSDrm to scheduler information

The VEX versions were present but not the legacy SSE versions.

llvm-svn: 320294

7 years ago[X86] Add LEA64_32r to scheduler models for Sandybridge,Haswell,Broadwell,Skylake
Craig Topper [Sun, 10 Dec 2017 09:14:42 +0000 (09:14 +0000)]
[X86] Add LEA64_32r to scheduler models for Sandybridge,Haswell,Broadwell,Skylake

llvm-svn: 320293

7 years ago[X86] Add IN16/OUT16 to scheduling information for Haswell,Broadwell,Skylake
Craig Topper [Sun, 10 Dec 2017 09:14:41 +0000 (09:14 +0000)]
[X86] Add IN16/OUT16 to scheduling information for Haswell,Broadwell,Skylake

Sandy Bridge is also missing it, but it has other issues. See PR35590.

llvm-svn: 320292

7 years ago[X86] Fix scheduler models to support ADD32ri in addition to ADD32ri8. Similar for...
Craig Topper [Sun, 10 Dec 2017 09:14:39 +0000 (09:14 +0000)]
[X86] Fix scheduler models to support ADD32ri in addition to ADD32ri8. Similar for all sizes of AND/OR/XOR/SUB/ADC/SBB/CMP.

llvm-svn: 320291

7 years ago[X86] Rename some instructions so that 'b' is added as a suffix instead of replacing...
Craig Topper [Sun, 10 Dec 2017 09:14:38 +0000 (09:14 +0000)]
[X86] Rename some instructions so that 'b' is added as a suffix instead of replacing an 'r'

llvm-svn: 320290

7 years ago[X86] Add CMPSDrr/rm to the scheduler models.
Craig Topper [Sun, 10 Dec 2017 09:14:37 +0000 (09:14 +0000)]
[X86] Add CMPSDrr/rm to the scheduler models.

Somehow CMPSSrr/rm was there and the VEX version was there, but this was consistently missing.

llvm-svn: 320289

7 years ago[Docs] Fix typo in scheduler model documentation. enumemation->enumeration
Craig Topper [Sun, 10 Dec 2017 09:14:35 +0000 (09:14 +0000)]
[Docs] Fix typo in scheduler model documentation. enumemation->enumeration

llvm-svn: 320288

7 years agoPowerPC: support external pid instructions in MC layer.
Tim Northover [Sun, 10 Dec 2017 08:43:19 +0000 (08:43 +0000)]
PowerPC: support external pid instructions in MC layer.

This adds assembly & disassembly support for the e500mc "external pid"
instructions.

See https://reviews.llvm.org/D39249.

Patch by vit9696 <vit9696@avp.su>

llvm-svn: 320287

7 years agoPPC32: Support R_PPC_PLTREL32 in static mode.
Tim Northover [Sun, 10 Dec 2017 08:42:34 +0000 (08:42 +0000)]
PPC32: Support R_PPC_PLTREL32 in static mode.

See https://reviews.llvm.org/D39226

Patch by vit9696 <vit9696@avp.su>

llvm-svn: 320286

7 years ago[PGO] change arg type to uint64_t to match member field type
Xinliang David Li [Sun, 10 Dec 2017 07:39:53 +0000 (07:39 +0000)]
[PGO] change arg type to uint64_t to match member field type

llvm-svn: 320285

7 years agoUpdate another sanitizer test for C++14.
Ahmed Bougacha [Sun, 10 Dec 2017 05:50:23 +0000 (05:50 +0000)]
Update another sanitizer test for C++14.

Follow-up to r320251.

llvm-svn: 320284

7 years ago[X86] Rename the rb form of scalar ADD/SUB/MUL/DIV to include _Int since they can...
Craig Topper [Sun, 10 Dec 2017 04:07:28 +0000 (04:07 +0000)]
[X86] Rename the rb form of scalar ADD/SUB/MUL/DIV to include _Int since they can only be selected by intrinsics.

llvm-svn: 320283

7 years ago[X86] Correct the _Int part of more scheduler model instrexes. Put _b in the correct...
Craig Topper [Sun, 10 Dec 2017 03:16:38 +0000 (03:16 +0000)]
[X86] Correct the _Int part of more scheduler model instrexes. Put _b in the correct order relative to _Int

llvm-svn: 320282

7 years ago[X86] Remove ReadAfterLd from several several rb instructions
Craig Topper [Sun, 10 Dec 2017 03:16:36 +0000 (03:16 +0000)]
[X86] Remove ReadAfterLd from several several rb instructions

This affects CVTSD2SS, FMA, RCP28, RSQRT28, and SQRT scalar instructions

'b' here refers to 'sae' not broadcast. These aren't memory instructions.

llvm-svn: 320281

7 years ago[X86] Fix test case I failed ot update in r320279.
Craig Topper [Sun, 10 Dec 2017 01:27:54 +0000 (01:27 +0000)]
[X86] Fix test case I failed ot update in r320279.

llvm-svn: 320280

7 years ago[X86] Fix bad regular expressions in the scheduler models. Question marks should...
Craig Topper [Sun, 10 Dec 2017 01:24:08 +0000 (01:24 +0000)]
[X86] Fix bad regular expressions in the scheduler models. Question marks should be outside of multicharacter parenthesized expressions

If the question mark is inside the parentheses it only applies to the single character proceeding it.

I had to make a few additional cleanups to fix some duplicate warnings that were exposed by fixing this.

llvm-svn: 320279

7 years ago[X86] Make the _Int part of some instregex sheduler patterns optional
Craig Topper [Sun, 10 Dec 2017 01:24:06 +0000 (01:24 +0000)]
[X86] Make the _Int part of some instregex sheduler patterns optional

llvm-svn: 320278

7 years ago[X86] Add the commutable floating point min/max pseudo instructions to sandybridge...
Craig Topper [Sun, 10 Dec 2017 01:24:05 +0000 (01:24 +0000)]
[X86] Add the commutable floating point min/max pseudo instructions to sandybridge,haswell,broadwell,skylakeclient scheduler models.

llvm-svn: 320277

7 years ago[X86] Tag PIC setup instruction as jump scheduler class
Simon Pilgrim [Sun, 10 Dec 2017 00:40:37 +0000 (00:40 +0000)]
[X86] Tag PIC setup instruction as jump scheduler class

llvm-svn: 320276

7 years ago[X86] Tag ACQUIRE/RELEASE atomic instructions as microcoded scheduler classes
Simon Pilgrim [Sun, 10 Dec 2017 00:30:57 +0000 (00:30 +0000)]
[X86] Tag ACQUIRE/RELEASE atomic instructions as microcoded scheduler classes

Note: We may be too pessimistic here and should possibly use something closer to the LOCK arithmetic instructions
llvm-svn: 320275

7 years ago[X86] Tag TLS instructions as system scheduler classes
Simon Pilgrim [Sun, 10 Dec 2017 00:12:57 +0000 (00:12 +0000)]
[X86] Tag TLS instructions as system scheduler classes

llvm-svn: 320274

7 years ago[X86] Tag ALLOCA/VAARG instructions as system scheduler classes
Simon Pilgrim [Sun, 10 Dec 2017 00:03:16 +0000 (00:03 +0000)]
[X86] Tag ALLOCA/VAARG instructions as system scheduler classes

llvm-svn: 320273

7 years ago[AArch64] Improve loop unrolling performance on Cavium T99
Joel Jones [Sat, 9 Dec 2017 23:59:55 +0000 (23:59 +0000)]
[AArch64] Improve loop unrolling performance on Cavium T99

This patch improves performance on Cavium T99 as shown here (libquantum 0.2.4):

https://docs.google.com/spreadsheets/d/1Lo1o2E1NjrpkwS7DvYYWsiVvPdd93h7KBaqeptMrZPY/edit?usp=sharing

By increasing the LoopMicroOpsBufferSize in the Cavium T99 Scheduler file,
loop unrolling becomes more aggressive. This helps performance on T99.

Test case included.

Patch by Stefan Teleman

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

llvm-svn: 320272

7 years agoUpdate Clang CMake cache to use cxx-headers, NFC
Duncan P. N. Exon Smith [Sat, 9 Dec 2017 23:44:42 +0000 (23:44 +0000)]
Update Clang CMake cache to use cxx-headers, NFC

Apparently libcxx-headers is going away.  Fixes PR35584.

llvm-svn: 320271

7 years ago[InstCombine] Fix SimplifyDemandedUseBits SHL handling (PR35515)
Simon Pilgrim [Sat, 9 Dec 2017 23:42:56 +0000 (23:42 +0000)]
[InstCombine] Fix SimplifyDemandedUseBits SHL handling (PR35515)

Don't assume that the pattern matched SRL can be cast to an Instruction (might be ConstExpr etc.)

llvm-svn: 320270

7 years agoInfer lowest bits of an integer Multiply when the low bits of the operands are known
Simon Dardis [Sat, 9 Dec 2017 23:25:57 +0000 (23:25 +0000)]
Infer lowest bits of an integer Multiply when the low bits of the operands are known

When the lowest bits of the operands to an integer multiply are known, the low bits of the result are deducible.
Code to deduce known-zero bottom bits already existed, but this change improves on that by deducing known-ones.

Patch by: Pedro Ferreira

Reviewers: craig.topper, sanjoy, efriedma

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

llvm-svn: 320269

7 years ago[X86] Use KMOV instructions to zero upper bits of vectors when possible.
Craig Topper [Sat, 9 Dec 2017 23:10:59 +0000 (23:10 +0000)]
[X86] Use KMOV instructions to zero upper bits of vectors when possible.

llvm-svn: 320268

7 years ago[X86] Improve lowering of vXi1 insert_subvectors to better utilize (insert_subvector...
Craig Topper [Sat, 9 Dec 2017 22:44:42 +0000 (22:44 +0000)]
[X86] Improve lowering of vXi1 insert_subvectors to better utilize (insert_subvector zero, vec, 0) for zeroing upper bits.

This can be better recognized during isel when the producer already zeroed the upper bits.

llvm-svn: 320267

7 years ago[X86] Tag LOCK/REX64/DATA16/DATA32 instruction prefix scheduler classes
Simon Pilgrim [Sat, 9 Dec 2017 21:27:03 +0000 (21:27 +0000)]
[X86] Tag LOCK/REX64/DATA16/DATA32 instruction prefix scheduler classes

llvm-svn: 320266

7 years agoStrip trailing whitespace. NFCI.
Simon Pilgrim [Sat, 9 Dec 2017 20:44:51 +0000 (20:44 +0000)]
Strip trailing whitespace. NFCI.

llvm-svn: 320265

7 years ago[X86] Tag FS/GS BASE R/W instruction scheduler classes
Simon Pilgrim [Sat, 9 Dec 2017 20:42:27 +0000 (20:42 +0000)]
[X86] Tag FS/GS BASE R/W instruction scheduler classes

llvm-svn: 320264

7 years ago[X86] Tag REP/REPNE prefix instructions as microcoded scheduler classes
Simon Pilgrim [Sat, 9 Dec 2017 20:16:37 +0000 (20:16 +0000)]
[X86] Tag REP/REPNE prefix instructions as microcoded scheduler classes

llvm-svn: 320263

7 years ago[X86] Tag missing EH pseudo instruction scheduler classes
Simon Pilgrim [Sat, 9 Dec 2017 20:04:02 +0000 (20:04 +0000)]
[X86] Tag missing EH pseudo instruction scheduler classes

llvm-svn: 320262

7 years ago[X86] Tag frame pointer XORs instruction scheduler classes
Simon Pilgrim [Sat, 9 Dec 2017 19:56:39 +0000 (19:56 +0000)]
[X86] Tag frame pointer XORs instruction scheduler classes

llvm-svn: 320261

7 years ago[X86] Don't use getTargetConstant for all 0s and all 1s mask vector.
Craig Topper [Sat, 9 Dec 2017 19:18:30 +0000 (19:18 +0000)]
[X86] Don't use getTargetConstant for all 0s and all 1s mask vector.

llvm-svn: 320260

7 years ago[libFuzzer] even less aggressive step function for stack depth. Also don't use asan...
Kostya Serebryany [Sat, 9 Dec 2017 19:18:10 +0000 (19:18 +0000)]
[libFuzzer] even less aggressive step function for stack depth. Also don't use asan in one test to speed it up

llvm-svn: 320259

7 years agoRemove duplicate option from documentation.
Adrian Prantl [Sat, 9 Dec 2017 19:09:59 +0000 (19:09 +0000)]
Remove duplicate option from documentation.

llvm-svn: 320258

7 years ago[X86] Tag segment prefixes as NOP instruction scheduling classes
Simon Pilgrim [Sat, 9 Dec 2017 16:58:34 +0000 (16:58 +0000)]
[X86] Tag segment prefixes as NOP instruction scheduling classes

llvm-svn: 320257

7 years agoRemove some includes from InputFiles.h.
Rafael Espindola [Sat, 9 Dec 2017 16:56:18 +0000 (16:56 +0000)]
Remove some includes from InputFiles.h.

They were not used in InputFiles.h and it was getting too easy to add
circular includes.

llvm-svn: 320256

7 years ago[X86][AVX512] Drop a default NoItinerary argument that isn't used any more. NFCI.
Simon Pilgrim [Sat, 9 Dec 2017 16:20:54 +0000 (16:20 +0000)]
[X86][AVX512] Drop a default NoItinerary argument that isn't used any more. NFCI.

Requires re-ordering of AVX512_maskable_custom arguments.

llvm-svn: 320255

7 years agoFix 'enumeral and non-enumeral type in conditional expression' gcc warning. NFCI.
Simon Pilgrim [Sat, 9 Dec 2017 16:19:18 +0000 (16:19 +0000)]
Fix 'enumeral and non-enumeral type in conditional expression' gcc warning. NFCI.

llvm-svn: 320254

7 years agoFix signed/unsigned gcc warning. NFCI.
Simon Pilgrim [Sat, 9 Dec 2017 16:04:57 +0000 (16:04 +0000)]
Fix signed/unsigned gcc warning. NFCI.

llvm-svn: 320253

7 years ago[InlineFunction] Set debug loc for call to forward varargs.
Florian Hahn [Sat, 9 Dec 2017 14:25:33 +0000 (14:25 +0000)]
[InlineFunction] Set debug loc for call to forward varargs.

Reviewers: aprantl, dblaikie, rnk

Reviewed By: rnk

Subscribers: eraman, llvm-commits, JDevlieghere

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

llvm-svn: 320252

7 years agoUpdate sanitizer tests for C++14 default in Clang
Tim Northover [Sat, 9 Dec 2017 13:35:52 +0000 (13:35 +0000)]
Update sanitizer tests for C++14 default in Clang

llvm-svn: 320251

7 years agoSwitch to gnu++14 as the default dialect.
Tim Northover [Sat, 9 Dec 2017 12:09:54 +0000 (12:09 +0000)]
Switch to gnu++14 as the default dialect.

This is C++14 with conforming GNU extensions.

llvm-svn: 320250

7 years ago[X86] When inserting into the upper bits of a vXi1 vector, make sure we shift enough...
Craig Topper [Sat, 9 Dec 2017 08:19:07 +0000 (08:19 +0000)]
[X86] When inserting into the upper bits of a vXi1 vector, make sure we shift enough bits if we widened the vector.

We may need to widen the vector to make the shifts legal, but if we do that we need to make sure we shift left/right after accounting for the new size. If not we can't guarantee we are shifting in zeros.

The test cases affected actually show cases where we should move the shifts all together, but that's another problem.

llvm-svn: 320248

7 years agoRevert and accidentally committed revert commit
Dylan McKay [Sat, 9 Dec 2017 08:01:28 +0000 (08:01 +0000)]
Revert and accidentally committed revert commit

This reverts commit r320245.

llvm-svn: 320247

7 years ago[AVR] Fix two CodeGen tests
Dylan McKay [Sat, 9 Dec 2017 07:51:43 +0000 (07:51 +0000)]
[AVR] Fix two CodeGen tests

These were broken because of various printing format changes.

llvm-svn: 320246

7 years agoRevert "[AVR] Override ParseDirective"
Dylan McKay [Sat, 9 Dec 2017 07:51:37 +0000 (07:51 +0000)]
Revert "[AVR] Override ParseDirective"

This reverts commit 57c16f9267969ebb09d6448607999b4a9f40c418.

llvm-svn: 320245

7 years ago[X86] Improve lowering of concats of mask vectors to better optimize zero vector...
Craig Topper [Sat, 9 Dec 2017 07:02:19 +0000 (07:02 +0000)]
[X86] Improve lowering of concats of mask vectors to better optimize zero vector inputs.

We were previously using kunpck with zero inputs unnecessarily. And we had cases where we would insert into a zero vector and then insert into larger zero vector incurring two sets of shifts.

llvm-svn: 320244

7 years agoRelax unaligned access assertion when type is byte aligned
Dylan McKay [Sat, 9 Dec 2017 06:45:36 +0000 (06:45 +0000)]
Relax unaligned access assertion when type is byte aligned

Summary:
This relaxes an assertion inside SelectionDAGBuilder which is overly
restrictive on targets which have no concept of alignment (such as AVR).

In these architectures, all types are aligned to 8-bits.

After this, LLVM will only assert that accesses are aligned on targets
which actually require alignment.

This patch follows from a discussion on llvm-dev a few months ago
http://llvm.1065342.n5.nabble.com/llvm-dev-Unaligned-atomic-load-store-td112815.html

Reviewers: bogner, nemanjai, joerg, efriedma

Reviewed By: efriedma

Subscribers: efriedma, cactus, llvm-commits

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

llvm-svn: 320243

7 years agoChange uses of strncpy in debugserver to strlcpy
Jason Molenda [Sat, 9 Dec 2017 03:37:09 +0000 (03:37 +0000)]
Change uses of strncpy in debugserver to strlcpy
for better safety.

<rdar://problem/32906923>

llvm-svn: 320242

7 years agoChange the ordering that we search for kexts and kernels on the local
Jason Molenda [Sat, 9 Dec 2017 03:28:15 +0000 (03:28 +0000)]
Change the ordering that we search for kexts and kernels on the local
computer.  When doing kernel debugging, lldb scrapes around a few
well-known locations to find kexts and kernels.  It builds up two
lists - kexts and kernels with dSYM, and kexts and kernels without dSYMs.
After both lists have failed to provide a file, then we'll call out
to things like the DebugSymbols framework to find a kext/kernel.

This meant that when you had a kext/kernel on the local computer that
did not have debug information, lldb wouldn't consult DebugSymbols etc
once it'd locked on to one of these no-debug-info binaries on the local
computer.

Reorder this so we give DebugSymbols etc a shot at finding a debug-info
file before we use any of the no-debug-info binaries that were found on
the system.

<rdar://problem/34434440>

llvm-svn: 320241

7 years agoUpdate PlatformDarwin::GetDeveloperDir to handle the two
Jason Molenda [Sat, 9 Dec 2017 03:06:19 +0000 (03:06 +0000)]
Update PlatformDarwin::GetDeveloperDir to handle the two
most common cases where the Xcode.app bundle puts lldb -
either as a default part of the bundle, or in a toolchain
subdirectory, so the platform subclasses can find files
relative to this directory.

Dropped support for handling the case where the lldb
framework was in /Library/PrivateFrameworks.  I think
this was intended to handle the case where lldb is installed
in / (outside the Xcode.app bundle) - but in that case, we
can look in the raw directory file paths to find anything.

<rdar://problem/35285622>

llvm-svn: 320240

7 years agoRevert r320230 to fix buildbots.
Richard Trieu [Sat, 9 Dec 2017 03:02:21 +0000 (03:02 +0000)]
Revert r320230 to fix buildbots.

llvm-svn: 320239

7 years agoFix Driver/darwin-version.c test
Alex Lorenz [Sat, 9 Dec 2017 02:56:48 +0000 (02:56 +0000)]
Fix Driver/darwin-version.c test

A target argument should be provided to avoid failures on non-Darwin

llvm-svn: 320238

7 years ago[libFuzzer] make the stack depth signal less agressive, otherwise we are sometimes...
Kostya Serebryany [Sat, 9 Dec 2017 02:45:23 +0000 (02:45 +0000)]
[libFuzzer] make the stack depth signal less agressive, otherwise we are sometimes exploding the corpus size. This still needs more analysis and tuning

llvm-svn: 320237

7 years agoRevert change in test/msan/textdomain.cc for NetBSD
Kamil Rytarowski [Sat, 9 Dec 2017 02:38:58 +0000 (02:38 +0000)]
Revert change in test/msan/textdomain.cc for NetBSD

SVN r. 320226

This breaks Linux.

llvm-svn: 320236

7 years ago[driver][darwin] Refactor the target selection code, NFC
Alex Lorenz [Sat, 9 Dec 2017 02:27:11 +0000 (02:27 +0000)]
[driver][darwin] Refactor the target selection code, NFC

The simulator variant of Darwin's platforms is removed in favor of a new
environment field.
The code that selects the platform and the version is split into 4 different
functions instead of being all in one function.
This is an NFC commit, although it slightly improves the
"invalid version number" diagnostic by displaying the environment variable
instead of -m<os>-version-min if the OS version was derived from the
environment.

rdar://35813850

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

llvm-svn: 320235

7 years agoCorrect handling of the TLS/NetBSD block of the main program
Kamil Rytarowski [Sat, 9 Dec 2017 02:23:33 +0000 (02:23 +0000)]
Correct handling of the TLS/NetBSD block of the main program

Summary:
Include <sys/tls.h> for:

 - struct tls_tcb - thread control block structure
 - __HAVE___LWP_GETTCB_FAST - __lwp_gettcb_fast() is available
 - __HAVE___LWP_GETPRIVATE_FAST -  __lwp_getprivate_fast() is available
 - __HAVE_TLS_VARIANT_I - TLS Variant I for this architecture
 - __HAVE_TLS_VARIANT_II - TLS Variant II for this architecture

Rename ThreadSelfSegbase() to ThreadSelfTlsTcb and switch it
to retrieve in a portable way TCB.

Switch ThreadSelf() to retrieve pthread from struct tcb_tls.

Use dl_iterate_phdr() to find out the size of TLS block of
the main program.

Correct the index of the  TLS block of the main program
(dlpi_tls_modid); it's 1, not 2.

New NetBSD code is now CPU (NetBSD port) agnostic.

Stop sharing the same code with FreeBSD.

Sponsored by <The NetBSD Foundation>

Reviewers: dvyukov, joerg, vitalybuka

Reviewed By: vitalybuka

Subscribers: emaste, kubamracek, llvm-commits, #sanitizers

Tags: #sanitizers

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

llvm-svn: 320234

7 years agoFix fsanitize-blacklist test on Windows.
Evgeniy Stepanov [Sat, 9 Dec 2017 02:15:42 +0000 (02:15 +0000)]
Fix fsanitize-blacklist test on Windows.

Broken in r320232.

llvm-svn: 320233

7 years agoHardware-assisted AddressSanitizer (clang part).
Evgeniy Stepanov [Sat, 9 Dec 2017 01:32:07 +0000 (01:32 +0000)]
Hardware-assisted AddressSanitizer (clang part).

Summary:
Driver, frontend and LLVM codegen for HWASan.
A clone of ASan, basically.

Reviewers: kcc, pcc, alekseyshl

Subscribers: srhines, javed.absar, cfe-commits

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

llvm-svn: 320232

7 years agoHardware-assisted AddressSanitizer (compiler-rt)
Evgeniy Stepanov [Sat, 9 Dec 2017 01:31:51 +0000 (01:31 +0000)]
Hardware-assisted AddressSanitizer (compiler-rt)

Summary:
Runtime library for HWASan, initial commit.
Does not randomize tags yet, does not handle stack or globals.

Reviewers: kcc, pcc, alekseyshl

Subscribers: srhines, kubamracek, dberris, mgorny, llvm-commits, krytarowski

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

llvm-svn: 320231

7 years ago[ODRHash] Support ODR violation detection in functions.
Richard Trieu [Sat, 9 Dec 2017 01:29:40 +0000 (01:29 +0000)]
[ODRHash] Support ODR violation detection in functions.

Extend the hashing to functions, which allows detection of function definition
mismatches across modules.

llvm-svn: 320230

7 years ago[MachineOutliner] Outline calls
Jessica Paquette [Sat, 9 Dec 2017 00:43:49 +0000 (00:43 +0000)]
[MachineOutliner] Outline calls

The outliner previously would never outline calls. Calls are pretty common in
files, so it makes sense to outline them. In fact, in the LLVM test suite, if
you count the number of instructions that the outliner misses when you outline
calls vs when you don't, it turns out that, on average, around 6% of the
instructions encountered are calls. So, if we outline calls, we can find more
candidates, and thus save some more space.

This commit adds that functionality and updates the mir test to reflect that.

llvm-svn: 320229

7 years agoFix test/msan/iconv.cc on NetBSD
Kamil Rytarowski [Sat, 9 Dec 2017 00:41:59 +0000 (00:41 +0000)]
Fix test/msan/iconv.cc on NetBSD

Summary:
NetBSD still uses the old POSIX iconv(3) signature with the 2nd const argument.

Sponsored by <The NetBSD Foundation>

Reviewers: joerg, eugenis, vitalybuka

Reviewed By: vitalybuka

Subscribers: llvm-commits, #sanitizers

Tags: #sanitizers

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

llvm-svn: 320228

7 years ago[NFC] Change the string offsets table tests to generate the object on the fly
Wolfgang Pieb [Sat, 9 Dec 2017 00:39:53 +0000 (00:39 +0000)]
[NFC] Change the string offsets table tests to generate the object on the fly
which enables us to remove the test scripts and object files from the repository.

https://reviews.llvm.org/D40914

llvm-svn: 320227

7 years agoFix test/msan/textdomain.cc on NetBSD
Kamil Rytarowski [Sat, 9 Dec 2017 00:39:04 +0000 (00:39 +0000)]
Fix test/msan/textdomain.cc on NetBSD

Summary:
This tests must be linked with -lintl for the gettext(3) features.

Sponsored by <The NetBSD Foundation>

Reviewers: joerg, eugenis, vitalybuka

Reviewed By: vitalybuka

Subscribers: llvm-commits, #sanitizers

Tags: #sanitizers

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

llvm-svn: 320226

7 years agoDisable test/msan/tsearch.cc on NetBSD
Kamil Rytarowski [Sat, 9 Dec 2017 00:37:58 +0000 (00:37 +0000)]
Disable test/msan/tsearch.cc on NetBSD

Summary:
This test uses GNU-specific extension to libc: tdestroy() and as-is is not compatible with NetBSD.

Sponsored by <The NetBSD Foundation>

Reviewers: joerg, eugenis, vitalybuka

Reviewed By: vitalybuka

Subscribers: llvm-commits, #sanitizers

Tags: #sanitizers

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

llvm-svn: 320225

7 years agoDisable test/msan/pvalloc.cc on NetBSD
Kamil Rytarowski [Sat, 9 Dec 2017 00:37:20 +0000 (00:37 +0000)]
Disable test/msan/pvalloc.cc on NetBSD

Summary:
The pvalloc(3) function is a non-standard extension missing on NetBSD.

Sponsored by <The NetBSD Foundation>

Reviewers: joerg, eugenis, vitalybuka

Reviewed By: vitalybuka

Subscribers: llvm-commits, #sanitizers

Tags: #sanitizers

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

llvm-svn: 320224

7 years agoFix test/msan/ifaddrs.cc for NetBSD
Kamil Rytarowski [Sat, 9 Dec 2017 00:36:49 +0000 (00:36 +0000)]
Fix test/msan/ifaddrs.cc for NetBSD

Summary:
NetBSD requires to include <sys/socket.h> for struct sockaddr.

Sponsored by <The NetBSD Foundation>

Reviewers: joerg, eugenis, vitalybuka

Reviewed By: vitalybuka

Subscribers: llvm-commits, #sanitizers

Tags: #sanitizers

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

llvm-svn: 320223

7 years agoDisable test/msan/ftime.cc on NetBSD
Kamil Rytarowski [Sat, 9 Dec 2017 00:36:17 +0000 (00:36 +0000)]
Disable test/msan/ftime.cc on NetBSD

Summary:
ftime(3) has been removed from libc/NetBSD.

Sponsored by <The NetBSD Foundation>

Reviewers: joerg, eugenis, vitalybuka

Reviewed By: vitalybuka

Subscribers: llvm-commits, #sanitizers

Tags: #sanitizers

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

llvm-svn: 320222

7 years agoNetBSD ships with POSIX strerror_r(3)
Kamil Rytarowski [Sat, 9 Dec 2017 00:35:44 +0000 (00:35 +0000)]
NetBSD ships with POSIX strerror_r(3)

Summary:
Switch NetBSD from GNU to the POSIX strerror_r(3) interceptor.

Sponsored by <The NetBSD Foundation>

Reviewers: joerg, eugenis, vitalybuka

Reviewed By: vitalybuka

Subscribers: srhines, kubamracek, llvm-commits, #sanitizers

Tags: #sanitizers

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

llvm-svn: 320221

7 years agoDon't link NetBSD programs with -ldl in linkXRayRuntimeDeps
Kamil Rytarowski [Sat, 9 Dec 2017 00:34:01 +0000 (00:34 +0000)]
Don't link NetBSD programs with -ldl in linkXRayRuntimeDeps

Summary:
There is no such library on NetBSD, the corresponding functions like dlopen(3) are in libc.

Sponsored by <The NetBSD Foundation>

Reviewers: joerg, vitalybuka, eugenis

Reviewed By: vitalybuka

Subscribers: dberris, llvm-commits, #sanitizers

Tags: #sanitizers

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

llvm-svn: 320220

7 years agoRegister NetBSD/x86_64 in MemorySanitizer.cpp
Kamil Rytarowski [Sat, 9 Dec 2017 00:32:09 +0000 (00:32 +0000)]
Register NetBSD/x86_64 in MemorySanitizer.cpp

Summary:
Reuse the Linux new mapping as it is.

Sponsored by <The NetBSD Foundation>

Reviewers: joerg, eugenis, vitalybuka

Reviewed By: vitalybuka

Subscribers: llvm-commits, #sanitizers

Tags: #sanitizers

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

llvm-svn: 320219

7 years agoAdd NetBSD/x86_64 mapping in MSan
Kamil Rytarowski [Sat, 9 Dec 2017 00:27:52 +0000 (00:27 +0000)]
Add NetBSD/x86_64 mapping in MSan

Summary:
Reuse the Linux new mapping as it is.

Sponsored by <The NetBSD Foundation>

Reviewers: joerg, vitalybuka, eugenis

Reviewed By: vitalybuka

Subscribers: llvm-commits, #sanitizers

Tags: #sanitizers

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

llvm-svn: 320218

7 years agoHardware-assisted AddressSanitizer (llvm part).
Evgeniy Stepanov [Sat, 9 Dec 2017 00:21:41 +0000 (00:21 +0000)]
Hardware-assisted AddressSanitizer (llvm part).

Summary:
This is LLVM instrumentation for the new HWASan tool. It is basically
a stripped down copy of ASan at this point, w/o stack or global
support. Instrumenation adds a global constructor + runtime callbacks
for every load and store.

HWASan comes with its own IR attribute.

A brief design document can be found in
clang/docs/HardwareAssistedAddressSanitizerDesign.rst (submitted earlier).

Reviewers: kcc, pcc, alekseyshl

Subscribers: srhines, mehdi_amini, mgorny, javed.absar, eraman, llvm-commits, hiraditya

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

llvm-svn: 320217

7 years agoFix out-of-order stepping behavior in programs with sunk instructions.
Paul Robinson [Sat, 9 Dec 2017 00:17:01 +0000 (00:17 +0000)]
Fix out-of-order stepping behavior in programs with sunk instructions.

MachineSink attempts to place instructions near the basic blocks where
they are needed.  Once an instruction has been sunk, its location
relative to other instructions no longer is consistent with the
original source code. In order to ensure correct stepping in the
debugger, the debug location for sunk instructions is either merged
with the insertion point or erased if the target successor block is
empty.

Originally submitted as r318679, revised to fix sanitizer failure and
improve testing.

Patch by Matthew Voss!

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

llvm-svn: 320216

7 years ago[CodeGen][X86] Fix handling of __fp16 vectors.
Akira Hatanaka [Sat, 9 Dec 2017 00:02:37 +0000 (00:02 +0000)]
[CodeGen][X86] Fix handling of __fp16 vectors.

This commit fixes a bug in IRGen where it generates completely broken
code for __fp16 vectors on X86. For example when the following code is
compiled:

half4 hv0, hv1, hv2; // these are vectors of __fp16.

void foo221() {
  hv0 = hv1 + hv2;
}

clang generates the following IR, in which two i16 vectors are added:

@hv1 = common global <4 x i16> zeroinitializer, align 8
@hv2 = common global <4 x i16> zeroinitializer, align 8
@hv0 = common global <4 x i16> zeroinitializer, align 8

define void @foo221() {
  %0 = load <4 x i16>, <4 x i16>* @hv1, align 8
  %1 = load <4 x i16>, <4 x i16>* @hv2, align 8
  %add = add <4 x i16> %0, %1
  store <4 x i16> %add, <4 x i16>* @hv0, align 8
  ret void
}

To fix the bug, this commit uses the code committed in r314056, which
modified clang to promote and truncate __fp16 vectors to and from float
vectors in the AST. It also fixes another IRGen bug where a short value
is assigned to an __fp16 variable without any integer-to-floating-point
conversion, as shown in the following example:

__fp16 a;
short b;

void foo1() {
  a = b;
}

@b = common global i16 0, align 2
@a = common global i16 0, align 2

define void @foo1() #0 {
  %0 = load i16, i16* @b, align 2
  store i16 %0, i16* @a, align 2
  ret void
}

rdar://problem/20625184

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

llvm-svn: 320215

7 years agodwarfdump: Add support for the --diff option.
Adrian Prantl [Fri, 8 Dec 2017 23:32:47 +0000 (23:32 +0000)]
dwarfdump: Add support for the --diff option.

--diff      Emit the output in a diff-friendly way by omitting offsets and
            addresses.

<rdar://problem/34502625>

llvm-svn: 320214

7 years ago[X86][Mips] Remove unused method declaration from the X86 and Mips AsmPrinters.
Craig Topper [Fri, 8 Dec 2017 23:30:03 +0000 (23:30 +0000)]
[X86][Mips] Remove unused method declaration from the X86 and Mips AsmPrinters.

Both had a declaration of EmitXRayTable, but there is no method defined in either with that name. There is a emitXRayTable in the base class with a lower case 'e' and they both call that.

llvm-svn: 320213

7 years agoRemove creation of out-of-bounds value of enumeration type (resulting in UB).
Richard Smith [Fri, 8 Dec 2017 23:29:59 +0000 (23:29 +0000)]
Remove creation of out-of-bounds value of enumeration type (resulting in UB).

Also remove unnecessary initialization of out-parameters with this value, so
that MSan is able to catch errors appropriately.

llvm-svn: 320212

7 years agoUnify implementation of our two different flavours of -Wtautological-compare,
Richard Smith [Fri, 8 Dec 2017 22:57:11 +0000 (22:57 +0000)]
Unify implementation of our two different flavours of -Wtautological-compare,
and fold together into a single function.

In so doing, fix a handful of remaining bugs where we would report false
positives or false negatives if we promote a signed value to an unsigned type
for the comparison.

This re-commits r320122 and r320124, minus two changes:

 * Comparisons between a constant and a non-constant expression of enumeration
   type never warn, not even if the constant is out of range. We should be
   warning about the creation of such a constant, not about its use.

 * We do not use more precise bit-widths for comparisons against bit-fields.
   The more precise diagnostics probably are the right thing, but we should
   consider moving them under their own warning flag.

Other than the refactoring, this patch should only change the behavior for the
buggy cases (where the warnings didn't take into account that promotion from
signed to unsigned can leave a range of inaccessible values in the middle of
the promoted type).

llvm-svn: 320211

7 years ago[libFuzzer] Add support for Fuchsia OS.
Matt Morehouse [Fri, 8 Dec 2017 22:54:44 +0000 (22:54 +0000)]
[libFuzzer] Add support for Fuchsia OS.

Summary:
This patch adds the initial support for Fuchsia.

- LIBFUZZER_FUCHSIA is added as an OS type in FuzzerDefs.h
- Fuchsia is, by design, not POSIX compliant. However, it does use ELF and
  supports common POSIX I/O functions. Thus, FuzzerExtFunctions.h and
  FuzzerIO.h are implemented by extending the header guards in
  FuzzerExtFunctionsWeak.cpp and FuzzerIOPosix.cpp to include
  LIBFUZZER_FUCHSIA.
- The platform-specific portions of FuzzerUtil.h are implemented by
  FuzzerUtilFuchsia.cpp, which makes use of exception ports, syscalls, and
  the launchpad library.
- The experimental equivalence server is not currently supported, so
  FuzzerShmem.h is implemented by stub methods in FuzzerShmemFuchsia.cpp.
  Any future implementation will likely involve VMOs.

Tested with ASAN/SanCov on Fuchsia/x86-64 with the canonical toy fuzzer.

Patch By: aarongreen

Reviewers: kcc, morehouse, flowerhack, phosek

Reviewed By: kcc, phosek, Eugene.Zelenko

Subscribers: srhines, mgorny, Eugene.Zelenko

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

llvm-svn: 320210

7 years ago[CodeGen] Move printing MO_Immediate operands to MachineOperand::print
Francis Visoiu Mistrih [Fri, 8 Dec 2017 22:53:21 +0000 (22:53 +0000)]
[CodeGen] Move printing MO_Immediate operands to MachineOperand::print

Work towards the unification of MIR and debug output by refactoring the
interfaces.

Add support for operand subreg index as an immediate to debug printing
and use ::print in the MIRPrinter.

Differential Review: https://reviews.llvm.org/D40965

llvm-svn: 320209

7 years agoRevert part of "Cleanup some GraphTraits iteration code"
Duncan P. N. Exon Smith [Fri, 8 Dec 2017 22:42:43 +0000 (22:42 +0000)]
Revert part of "Cleanup some GraphTraits iteration code"

This reverts part of r300656, which caused a regression in
propagateMassToSuccessors by counting edges n^2 times, where n is the
number of edges from the source basic block to the same successor basic
block. The result was both incorrect and very slow to compute for large
values of n (e.g. switches with multiple cases that go to the same basic
block).

Patch by Andrew Scheidecker!

llvm-svn: 320208

7 years ago[Lex] Fix some Clang-tidy modernize and Include What You Use warnings; other minor...
Eugene Zelenko [Fri, 8 Dec 2017 22:39:26 +0000 (22:39 +0000)]
[Lex] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).

llvm-svn: 320207

7 years agoAvoid constructing an out-of-range value for an enumeration (which results in UB).
Richard Smith [Fri, 8 Dec 2017 22:32:35 +0000 (22:32 +0000)]
Avoid constructing an out-of-range value for an enumeration (which results in UB).

llvm-svn: 320206

7 years ago[libFuzzer] honor -use_counters, sligntly change the meaning of -experimental_len_con...
Kostya Serebryany [Fri, 8 Dec 2017 22:21:42 +0000 (22:21 +0000)]
[libFuzzer] honor -use_counters, sligntly change the meaning of -experimental_len_control, call UpdateFeatureFrequency only if instructed by the flag

llvm-svn: 320205

7 years ago[AArch64] Rename AArch64VecorByElementOpt.cpp into AArch64SIMDInstrOpt.cpp to reflect...
Abderrazek Zaafrani [Fri, 8 Dec 2017 22:04:13 +0000 (22:04 +0000)]
[AArch64] Rename AArch64VecorByElementOpt.cpp into AArch64SIMDInstrOpt.cpp to reflect the recently added features.

The name change is dicsussed in https://reviews.llvm.org/D38196

llvm-svn: 320204

7 years agoGeneralize llvm::replaceDbgDeclare and actually support the use-case that
Adrian Prantl [Fri, 8 Dec 2017 21:58:18 +0000 (21:58 +0000)]
Generalize llvm::replaceDbgDeclare and actually support the use-case that
is mentioned in the documentation (inserting a deref before the plus_uconst).

llvm-svn: 320203

7 years ago[Debugify] Add a pass to test debug info preservation
Vedant Kumar [Fri, 8 Dec 2017 21:57:28 +0000 (21:57 +0000)]
[Debugify] Add a pass to test debug info preservation

The Debugify pass synthesizes debug info for IR. It's paired with a
CheckDebugify pass which determines how much of the original debug info
is preserved. These passes make it easier to create targeted tests for
debug info preservation.

Here is the Debugify algorithm:

  NextLine = 1
  for (Instruction &I : M)
    attach DebugLoc(NextLine++) to I

  NextVar = 1
  for (Instruction &I : M)
    if (canAttachDebugValue(I))
      attach dbg.value(NextVar++) to I

The CheckDebugify pass expects contiguous ranges of DILocations and
DILocalVariables. If it fails to find all of the expected debug info, it
prints a specific error to stderr which can be FileChecked.

This was discussed on llvm-dev in the thread:
"Passes to add/validate synthetic debug info"

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

llvm-svn: 320202

7 years ago[libc++] Unbreak Apple buildbots
Shoaib Meenai [Fri, 8 Dec 2017 21:50:32 +0000 (21:50 +0000)]
[libc++] Unbreak Apple buildbots

These buildbots are using the deprecated target name install-libcxx-headers
instead of the more up to date install-cxx-headers, so I need to add an
install-libcxx-headers-stripped target to satisfy them.

llvm-svn: 320201

7 years agoMake createSyntheticSections a static helper. NFC.
Rafael Espindola [Fri, 8 Dec 2017 21:50:29 +0000 (21:50 +0000)]
Make createSyntheticSections a static helper. NFC.

llvm-svn: 320200

7 years ago[CodeExtractor] Add debug locations for new call and branch instrs.
Florian Hahn [Fri, 8 Dec 2017 21:49:03 +0000 (21:49 +0000)]
[CodeExtractor] Add debug locations for new call and branch instrs.

Summary:
If a partially inlined function has debug info, we have to add debug
locations to the call instruction calling the outlined function.
We use the debug location of the first instruction in the outlined
function, as the introduced call transfers control to this statement and
there is no other equivalent line in the source code.

We also use the same debug location for the branch instruction added
to jump from artificial entry block for the outlined function, which just
jumps to the first actual basic block of the outlined function.

Reviewers: davide, aprantl, rriddle, dblaikie, danielcdh, wmi

Reviewed By: aprantl, rriddle, danielcdh

Subscribers: eraman, JDevlieghere, llvm-commits

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

llvm-svn: 320199

7 years agoMake findSection a static function. NFC.
Rafael Espindola [Fri, 8 Dec 2017 21:44:11 +0000 (21:44 +0000)]
Make findSection a static function. NFC.

llvm-svn: 320198