platform/upstream/llvm.git
5 years ago[mips][mc] Emit R_{MICRO}MIPS_JALR when expanding jal to jalr
Vladimir Stefanovic [Mon, 10 Dec 2018 15:07:36 +0000 (15:07 +0000)]
[mips][mc] Emit R_{MICRO}MIPS_JALR when expanding jal to jalr

When replacing jal with jalr, also emit '.reloc R_MIPS_JALR' (R_MICROMIPS_JALR
for micromips). The linker might then be able to turn jalr into a direct
call.
Add '-mips-jalr-reloc' to enable/disable this feature (default is true).

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

llvm-svn: 348760

5 years ago[DAGCombiner] Use the result value type in visitCONCAT_VECTORS
Francis Visoiu Mistrih [Mon, 10 Dec 2018 14:31:34 +0000 (14:31 +0000)]
[DAGCombiner] Use the result value type in visitCONCAT_VECTORS

This triggers an assert when combining concat_vectors of a bitcast of
merge_values.

With asserts disabled, it fails to select:
fatal error: error in backend: Cannot select: 0x7ff19d000e90: i32 = any_extend 0x7ff19d000ae8
  0x7ff19d000ae8: f64,ch = CopyFromReg 0x7ff19d000c20:1, Register:f64 %1
    0x7ff19d000b50: f64 = Register %1
In function: d

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

llvm-svn: 348759

5 years ago[OPENMP][NVPTX]Enable fast shuffles on 64bit values only if CUDA >= 9.
Alexey Bataev [Mon, 10 Dec 2018 14:29:05 +0000 (14:29 +0000)]
[OPENMP][NVPTX]Enable fast shuffles on 64bit values only if CUDA >= 9.

Summary:
Shuffle on 64bit data is allowed only for CUDA >= 9.0. Also, fixed the
constant for the mask, need one extra L in the end.

Reviewers: gtbercea, kkwli0

Subscribers: guansong, caomhin, openmp-commits

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

llvm-svn: 348758

5 years ago[NFC][AArch64] Remove duplicate Arch list in target parser tests
David Spickett [Mon, 10 Dec 2018 14:26:06 +0000 (14:26 +0000)]
[NFC][AArch64] Remove duplicate Arch list in target parser tests

The list generated in the target parser tests is the
same as the one in the AArch64 target parser.
Use that one instead.

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

llvm-svn: 348757

5 years agoSupport clang compiling under windows-gnu and windows-msvc
Andrey Churbanov [Mon, 10 Dec 2018 13:45:00 +0000 (13:45 +0000)]
Support clang compiling under windows-gnu and windows-msvc

Patch by Peiyuan Song <squallatf@gmail.com>

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

llvm-svn: 348756

5 years agoMisc typos fixes in ./lib folder
Raphael Isemann [Mon, 10 Dec 2018 12:37:46 +0000 (12:37 +0000)]
Misc typos fixes in ./lib folder

Summary: Found via `codespell -q 3 -I ../clang-whitelist.txt -L uint,importd,crasher,gonna,cant,ue,ons,orign,ned`

Reviewers: teemperor

Reviewed By: teemperor

Subscribers: teemperor, jholewinski, jvesely, nhaehnle, whisperity, jfb, cfe-commits

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

llvm-svn: 348755

5 years ago[AMDGPU] Add new Mode Register pass
Tim Corringham [Mon, 10 Dec 2018 12:06:10 +0000 (12:06 +0000)]
[AMDGPU] Add new Mode Register pass

A new pass to manage the Mode register.

Currently this just manages the floating point double precision
rounding requirements, but is intended to be easily extended to
encompass all Mode register settings.

The immediate motivation comes from the requirement to use the
round-to-zero rounding mode for the 16 bit interpolation
instructions, where the rounding mode setting is shared between
16 and 64 bit operations.

llvm-svn: 348754

5 years ago[DebugInfo] Don't drop dbg.value's of nullptr
Jeremy Morse [Mon, 10 Dec 2018 12:04:08 +0000 (12:04 +0000)]
[DebugInfo] Don't drop dbg.value's of nullptr

Currently, dbg.value's of "nullptr" are dropped when entering a SelectionDAG --
apparently just because of an oversight when recognising Values that are
constant (see PR39787). This patch adds ConstantPointerNull to the list of
constants that can be turned into DBG_VALUEs.

The matter of what bit-value a null pointer constant in LLVM has was raised
in this mailing list thread:

  http://lists.llvm.org/pipermail/llvm-dev/2018-December/128234.html

Where it transpires LLVM relies on (IR) null pointers being zero valued,
thus I've baked this assumption into the patch.

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

llvm-svn: 348753

5 years ago[OpenCL][CodeGen] Fix replacing memcpy with addrspacecast
Andrew Savonichev [Mon, 10 Dec 2018 12:03:00 +0000 (12:03 +0000)]
[OpenCL][CodeGen] Fix replacing memcpy with addrspacecast

Summary:
If a function argument is byval and RV is located in default or alloca address space
an optimization of creating addrspacecast instead of memcpy is performed. That is
not correct for OpenCL, where that can lead to a situation of address space casting
from __private * to __global *. See an example below:

```
typedef struct {
  int x;
} MyStruct;

void foo(MyStruct val) {}

kernel void KernelOneMember(__global MyStruct* x) {
  foo (*x);
}
```

for this code clang generated following IR:
...
%0 = load %struct.MyStruct addrspace(1)*, %struct.MyStruct addrspace(1)**
%x.addr, align 4
%1 = addrspacecast %struct.MyStruct addrspace(1)* %0 to %struct.MyStruct*
...

So the optimization was disallowed for OpenCL if RV is located in an address space
different than that of the argument (0).

Reviewers: yaxunl, Anastasia

Reviewed By: Anastasia

Subscribers: cfe-commits, asavonic

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

llvm-svn: 348752

5 years ago[DebugInfo] Emit undef DBG_VALUEs when SDNodes are optimised out
Jeremy Morse [Mon, 10 Dec 2018 11:20:47 +0000 (11:20 +0000)]
[DebugInfo] Emit undef DBG_VALUEs when SDNodes are optimised out

This is a fix for PR39896, where dbg.value's of SDNodes that have been
optimised out do not lead to "DBG_VALUE undef" instructions being created.
Such undef instructions are necessary to terminate earlier variable
ranges, otherwise variable values leak past the point where they're valid.

The "invalidated" flag of SDDbgValue is currently being abused to mean two
things:
 * The corresponding SDNode is now invalid
 * This SDDbgValue should not be emitted
Of which there are several legitimate combinations of meaning:
 * The SDNode has been invalidated and we should emit "DBG_VALUE undef"
 * The SDNode has been invalidated but the debug data was salvaged, don't
   emit anything for this SDDbgValue
 * This SDDbgValue has been emitted

This patch introduces distinct "Emitted" and "Invalidated" fields to the
SDDbgValue class, updates users accordingly, and generates "undef"
DBG_VALUEs for invalidated records. Awkwardly, there are circumstances
where we emit SDDbgValue's twice, specifically DebugInfo/X86/dbg-addr-dse.ll
which I've preserved.

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

llvm-svn: 348751

5 years ago[X86] Fix AvoidStoreForwardingBlocks pass for negative displacements
Nikita Popov [Mon, 10 Dec 2018 10:16:50 +0000 (10:16 +0000)]
[X86] Fix AvoidStoreForwardingBlocks pass for negative displacements

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

The size of the first copy was computed as
std::abs(std::abs(LdDisp2) - std::abs(LdDisp1)), which results in
skipped bytes if the signs of LdDisp2 and LdDisp1 differ. As far as
I can see, this should just be LdDisp2 - LdDisp1. The case where
LdDisp1 > LdDisp2 is already handled in the code above, in which case
LdDisp2 is set to LdDisp1 and this subtraction will evaluate to
Size1 = 0, which is the correct value to skip an overlapping copy.

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

llvm-svn: 348750

5 years ago[LLD][ELF] - Support discarding the .dynamic section.
George Rimar [Mon, 10 Dec 2018 09:24:49 +0000 (09:24 +0000)]
[LLD][ELF] - Support discarding the .dynamic section.

This is a part of https://bugs.llvm.org/show_bug.cgi?id=39810.

Seems it turns out that supporting /DISCARD/ for the .dynamic section with the
linker script is something we can do easily. The patch does this.

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

llvm-svn: 348749

5 years ago[ELF] - Allow discarding .dynsym from the linker script.
George Rimar [Mon, 10 Dec 2018 09:13:36 +0000 (09:13 +0000)]
[ELF] - Allow discarding .dynsym from the linker script.

This is a part of https://bugs.llvm.org/show_bug.cgi?id=39810.
The patch allows discarding the .dynsym section using linker script.

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

llvm-svn: 348748

5 years agoAdd data types needed for md2(3)/NetBSD interceptors
Kamil Rytarowski [Mon, 10 Dec 2018 09:09:18 +0000 (09:09 +0000)]
Add data types needed for md2(3)/NetBSD interceptors

Missing part of D55469.

llvm-svn: 348747

5 years ago[LLD][ELF] - Support discarding .dynstr section.
George Rimar [Mon, 10 Dec 2018 09:07:30 +0000 (09:07 +0000)]
[LLD][ELF] - Support discarding .dynstr section.

This is a part of https://bugs.llvm.org/show_bug.cgi?id=39810.
The patch allows discarding the .dynstr section using linker script.

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

llvm-svn: 348746

5 years agoAdd interceptors for the sha2(3) from NetBSD
Kamil Rytarowski [Mon, 10 Dec 2018 09:06:56 +0000 (09:06 +0000)]
Add interceptors for the sha2(3) from NetBSD

Summary:
SHA224_Init, SHA224_Update, SHA224_Final, SHA224_End, SHA224_File,
SHA224_FileChunk, SHA224_Data, SHA256_Init, SHA256_Update, SHA256_Final,
SHA256_End, SHA256_File, SHA256_FileChunk, SHA256_Data, SHA384_Init,
SHA384_Update, SHA384_Final, SHA384_End, SHA384_File, SHA384_FileChunk,
SHA384_Data, SHA512_Init, SHA512_Update, SHA512_Final, SHA512_End,
SHA512_File, SHA512_FileChunk, SHA512_Data – calculates the NIST Secure
Hash Standard (version 2)

Add tests for new interceptors.

Reviewers: vitalybuka, joerg

Reviewed By: vitalybuka

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

Tags: #sanitizers

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

llvm-svn: 348745

5 years agoAdd interceptors for md2(3) from NetBSD
Kamil Rytarowski [Mon, 10 Dec 2018 09:01:00 +0000 (09:01 +0000)]
Add interceptors for md2(3) from NetBSD

Summary:
MD2Init, MD2Update, MD2Final, MD2End, MD2File, MD2Data - calculates the
RSA Data Security, Inc., "MD2" message digest.

Add a dedicated test.

Reviewers: vitalybuka, joerg

Reviewed By: vitalybuka

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

Tags: #sanitizers

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

llvm-svn: 348744

5 years agoAdd new interceptors for FILE repositioning stream
Kamil Rytarowski [Mon, 10 Dec 2018 08:56:14 +0000 (08:56 +0000)]
Add new interceptors for FILE repositioning stream

Summary:
Add new interceptors for a set of functions to reposition a stream:
fgetpos, fseek, fseeko, fsetpos, ftell, ftello, rewind .

Add a dedicated test.

Enable this interface on NetBSD.

Reviewers: joerg, vitalybuka

Reviewed By: vitalybuka

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

Tags: #sanitizers

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

llvm-svn: 348743

5 years agoRevert r348741 "[Sema] Further improvements to to static_assert diagnostics."
Clement Courbet [Mon, 10 Dec 2018 08:53:17 +0000 (08:53 +0000)]
Revert r348741 "[Sema] Further improvements to to static_assert diagnostics."

Seems to break build bots.

llvm-svn: 348742

5 years ago[Sema] Further improvements to to static_assert diagnostics.
Clement Courbet [Mon, 10 Dec 2018 08:19:38 +0000 (08:19 +0000)]
[Sema] Further improvements to to static_assert diagnostics.

Summary:
We're now handling cases like `static_assert(!expr)` and
static_assert(!(expr))`.

Reviewers: aaron.ballman, Quuxplusone

Subscribers: cfe-commits

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

llvm-svn: 348741

5 years ago[llvm-exegesis] Also check latency mode in local lit.
Clement Courbet [Mon, 10 Dec 2018 07:29:47 +0000 (07:29 +0000)]
[llvm-exegesis] Also check latency mode in local lit.

Summary: This should avoid failing on old CPUs that do not have a cycle counter.

Subscribers: tschuett, llvm-commits

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

llvm-svn: 348740

5 years ago[CostModel][X86][AArch64] Adjust cost of the scalarization part of min/max reduction.
Craig Topper [Mon, 10 Dec 2018 06:58:58 +0000 (06:58 +0000)]
[CostModel][X86][AArch64] Adjust cost of the scalarization part of min/max reduction.

Summary: The comment says we need 3 extracts and a select at the end. But didn't we just account for the select in the vector cost above. Aren't we just extracting the single element after taking the min/max in the vector register?

Reviewers: RKSimon, spatel, ABataev

Reviewed By: RKSimon

Subscribers: javed.absar, kristof.beyls, llvm-commits

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

llvm-svn: 348739

5 years ago[X86] Remove the addcarry builtins. Leaving only the addcarryx builtins since that...
Craig Topper [Mon, 10 Dec 2018 06:07:59 +0000 (06:07 +0000)]
[X86] Remove the addcarry builtins. Leaving only the addcarryx builtins since that matches gcc.

The addcarry and addcarryx builtins do the same thing. The only difference is that addcarryx previously required adx feature.

This commit removes the adx feature check from addcarryx and removes the addcarry builtin. This matches the builtins that gcc has. We don't guarantee compatibility in builtins, but we generally try to be consistent if its not a burden.

llvm-svn: 348738

5 years ago[X86] Merge addcarryx/addcarry intrinsic into a single addcarry intrinsic.
Craig Topper [Mon, 10 Dec 2018 06:07:50 +0000 (06:07 +0000)]
[X86] Merge addcarryx/addcarry intrinsic into a single addcarry intrinsic.

Both intrinsics do the exact same thing so we really only need one.

Earlier in the 8.0 cycle we changed the signature of this intrinsic without renaming it. But it looks difficult to get the autoupgrade code to allow me to merge the intrinsics and change the signature at the same time. So I've renamed the intrinsic slightly for the new merged intrinsic. I'm skipping autoupgrading from the previous new to 8.0 signature. I've also renamed the subborrow for consistency.

llvm-svn: 348737

5 years ago[TextAPI][elfabi] Fix build by adding std::move() to r348735
Armando Montanez [Mon, 10 Dec 2018 03:05:58 +0000 (03:05 +0000)]
[TextAPI][elfabi] Fix build by adding std::move() to r348735

llvm-svn: 348736

5 years ago[TextAPI][elfabi] Make TBE handlers functions that return Errors
Armando Montanez [Mon, 10 Dec 2018 02:36:33 +0000 (02:36 +0000)]
[TextAPI][elfabi] Make TBE handlers functions that return Errors

Since TBEHandler doesn't maintain state or otherwise have any need to be
a class right now, the read and write functions have been moved out and
turned into standalone functions. Additionally, the TBE read function
has been updated to return an Expected value for better error handling.
Tests have been updated to reflect these changes.

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

llvm-svn: 348735

5 years ago[bugpoint] Find 'opt', etc., in bugpoint directory
Brian Gesiak [Mon, 10 Dec 2018 00:56:13 +0000 (00:56 +0000)]
[bugpoint] Find 'opt', etc., in bugpoint directory

Summary:
When bugpoint attempts to find the other executables it needs to run,
such as `opt` or `clang`, it tries searching the user's PATH. However,
in many cases, the 'bugpoint' executable is part of an LLVM build, and
the 'opt' executable it's looking for is in that same directory.

Many LLVM tools handle this case by using the `Paths` parameter of
`llvm::sys::findProgramByName`, passing the parent path of the currently
running executable. Do this same thing for bugpoint. However, to
preserve the current behavior exactly, first search the user's PATH,
and then search for 'opt' in the directory containing 'bugpoint'.

Test Plan:
`check-llvm`. Many of the existing bugpoint tests no longer need to use the
`--opt-command` option as a result of these changes.

Reviewers: MatzeB, silvas, davide

Reviewed By: MatzeB, davide

Subscribers: davide, llvm-commits

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

llvm-svn: 348734

5 years agoRe-commit "[IR] Add NODISCARD to attribute functions"
Brian Gesiak [Sun, 9 Dec 2018 22:36:07 +0000 (22:36 +0000)]
Re-commit "[IR] Add NODISCARD to attribute functions"

Now that https://reviews.llvm.org/D55435 is committed,
https://reviews.llvm.org/D55217 can be committed once again -- all warnings are
now fixed.

llvm-svn: 348733

5 years ago[AMDGPU] Fix discarded result of addAttribute
Brian Gesiak [Sun, 9 Dec 2018 21:56:50 +0000 (21:56 +0000)]
[AMDGPU] Fix discarded result of addAttribute

Summary:
`llvm::AttributeList` and `llvm::AttributeSet` are immutable, and so methods
defined on these classes, such as `addAttribute`, return a new immutable
object with the attribute added. In https://reviews.llvm.org/D55217 I attempted
to annotate methods such as `addAttribute` with `LLVM_NODISCARD`, since
calling these methods has no side-effects, and so ignoring the result
that is returned is almost certainly a programmer error.

However, committing the change resulted in new warnings in the AMDGPU target.
The AMDGPU simplify libcalls pass added in https://reviews.llvm.org/D36436
attempts to add the readonly and nounwind attributes to simplified
library functions, but instead calls the `addAttribute` methods and
ignores the result.

Modify the simplify libcalls pass to actually add the nounwind and
readonly attributes. Also update the simplify libcalls test to assert
that these attributes are actually being set.

Reviewers: rampitec, vpykhtin, rnk

Reviewed By: rampitec

Subscribers: arsenm, kzhuravl, jvesely, wdng, nhaehnle, yaxunl, dstuttard, tpr, t-tye, llvm-commits

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

llvm-svn: 348732

5 years agoSpeculatively fixing the build; it seems add_pointer_t and add_const_t are not implem...
Aaron Ballman [Sun, 9 Dec 2018 20:04:54 +0000 (20:04 +0000)]
Speculatively fixing the build; it seems add_pointer_t and add_const_t are not implemented everywhere.

llvm-svn: 348731

5 years agoMove the make_const_ptr trait into STLExtras; use add_pointer where possible; NFC.
Aaron Ballman [Sun, 9 Dec 2018 19:53:24 +0000 (19:53 +0000)]
Move the make_const_ptr trait into STLExtras; use add_pointer where possible; NFC.

llvm-svn: 348730

5 years agoAdding an STL-like type trait that is duplicated in multiple places in Clang.
Aaron Ballman [Sun, 9 Dec 2018 19:53:15 +0000 (19:53 +0000)]
Adding an STL-like type trait that is duplicated in multiple places in Clang.

This trait is used by several AST visitor classes to control whether the AST is visiting const nodes or non-const nodes. These uses cannot be easily replaced with the STL traits directly due to use of an unspecialized templated when a type is expected (due to the template template parameter involved).

llvm-svn: 348729

5 years ago[X86] Add some comments about when some X86 intrinsic autoupgrade code was added.
Craig Topper [Sun, 9 Dec 2018 18:02:40 +0000 (18:02 +0000)]
[X86] Add some comments about when some X86 intrinsic autoupgrade code was added.

Someday we'd like to remove old autoupgrade code so it helps to annotate how long its been there so we don't have to go digging through commit history.

llvm-svn: 348728

5 years ago[X86] If the carry input to an addcarry/subborrow intrinsic is known to be 0, emit...
Craig Topper [Sun, 9 Dec 2018 18:02:37 +0000 (18:02 +0000)]
[X86] If the carry input to an addcarry/subborrow intrinsic is known to be 0, emit a flag setting ADD/SUB instead of ADC/SBB.

Previously we had to take the carry in and add -1 to it to set the carry flag so we could use it with ADC/SBB. But if we know its 0 then we don't need to bother.

This should go a long way towards fixing PR24545.

llvm-svn: 348727

5 years agoAdd OpenBSD support to OpenMP
Kamil Rytarowski [Sun, 9 Dec 2018 16:46:48 +0000 (16:46 +0000)]
Add OpenBSD support to OpenMP

Summary: This patch permits OpenMP to build and work (with both gcc and clang) on OpenBSD. It mostly follows what was done for FreeBSD and NetBSD, except OpenBSD does not have pthread_getattr_np support, so it follows OS X in that one instance.

Reviewers: #openmp, krytarowski

Reviewed By: krytarowski

Subscribers: guansong, jfb, emaste, mgorny, krytarowski, #openmp

Tags: #openmp

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

llvm-svn: 348726

5 years agoAdd DragonFlyBSD support to OpenMP
Kamil Rytarowski [Sun, 9 Dec 2018 16:40:33 +0000 (16:40 +0000)]
Add DragonFlyBSD support to OpenMP

Summary:
Additions mostly follow FreeBSD and NetBSD and are not intrusive.
There is similar patch for OpenBSD: https://reviews.llvm.org/D34280

The -lm was being omitted due to -Wl,--as-needed in cmake rule, similar patch is in freebsd-ports/devel/llvm-devel port.

Simple OpenMP programs compile and work as expected:
$ clang-devel ~/omp_hello.c -fopenmp -I/usr/local/llvm-devel/include
$ LD_LIBRARY_PATH=/usr/local/llvm-devel/lib OMP_NUM_THREADS=100 ./a.out

The assertion in LLVMgold.so when -fopenmp was used together with -flto in 20170524 snapshot is no longer triggered on current svn-trunk and works fine as in llvm-4.0 with our local patches.

Reviewers: #openmp, krytarowski

Reviewed By: krytarowski

Subscribers: dexonsmith, jfb, krytarowski, guansong, gregrodgers, emaste, mgorny, mehdi_amini

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

llvm-svn: 348725

5 years agoRemove unneeded dependency from lib/Target/X86/Utils/ to lib/IR (aka Core).
Nico Weber [Sun, 9 Dec 2018 15:15:13 +0000 (15:15 +0000)]
Remove unneeded dependency from lib/Target/X86/Utils/ to lib/IR (aka Core).

The dependency was added in r213995 in response to r213986 which did make
X86/Utils depend on IR, but r256680 later removed that dependency again.

llvm-svn: 348724

5 years ago[x86] regenerate test checks; NFC
Sanjay Patel [Sun, 9 Dec 2018 14:47:53 +0000 (14:47 +0000)]
[x86] regenerate test checks; NFC

llvm-svn: 348723

5 years ago[x86] don't try to convert add with undef operands to LEA
Sanjay Patel [Sun, 9 Dec 2018 14:40:37 +0000 (14:40 +0000)]
[x86] don't try to convert add with undef operands to LEA

The existing code tries to handle an undef operand while transforming an add to an LEA,
but it's incomplete because we will crash on the i16 test with the debug output shown below.
It's better to just give up instead. Really, GlobalIsel should have folded these before we
could get into trouble.

# Machine code for function add_undef_i16: NoPHIs, TracksLiveness, Legalized, RegBankSelected, Selected

bb.0 (%ir-block.0):
  liveins: $edi
  %1:gr32 = COPY killed $edi
  %0:gr16 = COPY %1.sub_16bit:gr32
  %5:gr64_nosp = IMPLICIT_DEF
  %5.sub_16bit:gr64_nosp = COPY %0:gr16
  %6:gr64_nosp = IMPLICIT_DEF
  %6.sub_16bit:gr64_nosp = COPY %2:gr16
  %4:gr32 = LEA64_32r killed %5:gr64_nosp, 1, killed %6:gr64_nosp, 0, $noreg
  %3:gr16 = COPY killed %4.sub_16bit:gr32
  $ax = COPY killed %3:gr16
  RET 0, implicit killed $ax

# End machine code for function add_undef_i16.

*** Bad machine code: Reading virtual register without a def ***
- function:    add_undef_i16
- basic block: %bb.0  (0x7fe6cd83d940)
- instruction: %6.sub_16bit:gr64_nosp = COPY %2:gr16
- operand 1:   %2:gr16
LLVM ERROR: Found 1 machine code errors.

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

llvm-svn: 348722

5 years ago[X86] Extend pfm counter coverage for llvm-exegesis
Simon Pilgrim [Sun, 9 Dec 2018 13:45:15 +0000 (13:45 +0000)]
[X86] Extend pfm counter coverage for llvm-exegesis

Extension to rL348617, turns out llvm-exegesis doesn't need to match the perf counter name against a scheduler model resource name - so I've added a few more counters that I could find in the libpfm4 source code (and fix a typo in the knl/knm retired_uops counter - which uses 'all' instead of 'any').

llvm-svn: 348721

5 years agoNFC: Rename TemplateDecl dump utilities
Stephen Kelly [Sun, 9 Dec 2018 13:33:30 +0000 (13:33 +0000)]
NFC: Rename TemplateDecl dump utilities

There is a clang::TemplateDecl AST type, so a method called
VisitTemplateDecl looks like it should 'override' the method from the
base visitor, but it does not because of the extra parameters it takes.

In reality, these methods are utilities, so name them like utilities.

llvm-svn: 348720

5 years agoNFC: Move dump of individual comment nodes to NodeDumper
Stephen Kelly [Sun, 9 Dec 2018 13:30:17 +0000 (13:30 +0000)]
NFC: Move dump of individual comment nodes to NodeDumper

Reviewers: aaron.ballman

Subscribers: cfe-commits

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

llvm-svn: 348719

5 years agoRevert "Introduce optional labels to dumpStmt"
Stephen Kelly [Sun, 9 Dec 2018 13:24:40 +0000 (13:24 +0000)]
Revert "Introduce optional labels to dumpStmt"

This reverts commit 933402caa09963792058198578522a95f013c69c.

llvm-svn: 348718

5 years agoIntroduce optional labels to dumpStmt
Stephen Kelly [Sun, 9 Dec 2018 13:23:07 +0000 (13:23 +0000)]
Introduce optional labels to dumpStmt

If the label is present, it is added as a child, with the statement a
child of the label.  This preserves behavior of the InitListExpr dump
output.

llvm-svn: 348717

5 years agoInline hasNodes into only caller
Stephen Kelly [Sun, 9 Dec 2018 13:20:43 +0000 (13:20 +0000)]
Inline hasNodes into only caller

It is easier to refactor with fewer utility methods.

llvm-svn: 348716

5 years agoInline dumpFullComment into callers
Stephen Kelly [Sun, 9 Dec 2018 13:18:55 +0000 (13:18 +0000)]
Inline dumpFullComment into callers

It causes confusion over whether it or dumpComment is the more
important. It is easier to refactor with fewer utility methods.

llvm-svn: 348715

5 years agoRe-order content from InitListExpr
Stephen Kelly [Sun, 9 Dec 2018 13:15:18 +0000 (13:15 +0000)]
Re-order content from InitListExpr

Summary:
This causes no change in the output of ast-dump-stmt.cpp due to the way
child nodes are printed with a delay.

Reviewers: aaron.ballman

Subscribers: cfe-commits

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

llvm-svn: 348714

5 years agoFix InitListExpr test
Stephen Kelly [Sun, 9 Dec 2018 13:13:41 +0000 (13:13 +0000)]
Fix InitListExpr test

Wrong case of Check meant this has no effect.

llvm-svn: 348713

5 years ago[X86] Add test for PR39926; NFC
Nikita Popov [Sun, 9 Dec 2018 12:02:56 +0000 (12:02 +0000)]
[X86] Add test for PR39926; NFC

The test file shows a case where the avoid store forwarding block
pass misses to copy a range (-1..1) when the load displacement
changes sign.

Baseline test for D55485.

llvm-svn: 348712

5 years agoRevert a hunk that shouldn't have been included in the last commit.
Frederic Riss [Sun, 9 Dec 2018 02:38:04 +0000 (02:38 +0000)]
Revert a hunk that shouldn't have been included in the last commit.

I've seen this line trigger UB, but that's obviously not the correct fix...

llvm-svn: 348711

5 years agoRemove some UB in RegisterContextDarwin_arm64.cpp
Frederic Riss [Sun, 9 Dec 2018 02:35:19 +0000 (02:35 +0000)]
Remove some UB in RegisterContextDarwin_arm64.cpp

llvm-svn: 348710

5 years agoSourceManager: insert(make_pair(..)) -> try_emplace. NFC
Fangrui Song [Sun, 9 Dec 2018 01:46:01 +0000 (01:46 +0000)]
SourceManager: insert(make_pair(..)) -> try_emplace. NFC

llvm-svn: 348709

5 years ago[COFF] Map truncated .eh_frame section name
Martin Storsjo [Sat, 8 Dec 2018 18:15:41 +0000 (18:15 +0000)]
[COFF] Map truncated .eh_frame section name

PE/COFF sections can have section names truncated to 8 chars, in order to
have the name available at runtime. (The string table, where long untruncated
names are stored, isn't loaded at runtime.)

This allows various llvm tools to dump the .eh_frame section from such
executables.

Patch by Peiyuan Song!

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

llvm-svn: 348708

5 years agoFix conflict types for this FreeBSD test.
David Carlier [Sat, 8 Dec 2018 16:29:50 +0000 (16:29 +0000)]
Fix conflict types for this FreeBSD test.

llvm-svn: 348707

5 years ago[DAGCombiner] re-enable truncation of binops
Sanjay Patel [Sat, 8 Dec 2018 16:07:38 +0000 (16:07 +0000)]
[DAGCombiner] re-enable truncation of binops

This is effectively re-committing the changes from:
rL347917 (D54640)
rL348195 (D55126)
...which were effectively reverted here:
rL348604
...because the code had a bug that could induce infinite looping
or eventual out-of-memory compilation.

The bug was that this code did not guard against transforming
opaque constants. More details are in the post-commit mailing
list thread for r347917. A reduced test for that is included
in the x86 bool-math.ll file. (I wasn't able to reduce a PPC
backend test for this, but it was almost the same pattern.)

Original commit message for r347917:

The motivating case for this is shown in:
https://bugs.llvm.org/show_bug.cgi?id=32023
and the corresponding rot16.ll regression tests.

Because x86 scalar shift amounts are i8 values, we can end up with trunc-binop-trunc
sequences that don't get folded in IR.

As the TODO comments suggest, there will be regressions if we extend this (for x86,
we mostly seem to be missing LEA opportunities, but there are likely vector folds
missing too). I think those should be considered existing bugs because this is the
same transform that we do as an IR canonicalization in instcombine. We just need
more tests to make those visible independent of this patch.

llvm-svn: 348706

5 years ago[x86] add 32-bit RUN for tests and test with opaque constants; NFC
Sanjay Patel [Sat, 8 Dec 2018 15:34:09 +0000 (15:34 +0000)]
[x86] add 32-bit RUN for tests and test with opaque constants; NFC

The opaque constant test is reduced from a Chrome file that
infinite-looped with rL347917.

llvm-svn: 348705

5 years ago[gn build] Add build files for CodeGen subfolders AsmPrinter, GlobalISel, SelectionDAG.
Nico Weber [Sat, 8 Dec 2018 10:53:10 +0000 (10:53 +0000)]
[gn build] Add build files for CodeGen subfolders AsmPrinter, GlobalISel, SelectionDAG.

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

llvm-svn: 348704

5 years ago[WebAssembly] Add support for the event section
Heejin Ahn [Sat, 8 Dec 2018 06:17:43 +0000 (06:17 +0000)]
[WebAssembly] Add support for the event section

Summary:
This adds support for the 'event section' specified in the exception
handling proposal.

Wasm exception handling binary model spec:
https://github.com/WebAssembly/exception-handling/blob/master/proposals/Exceptions.md#changes-to-the-binary-model

Reviewers: sbc100, ruiu

Subscribers: dschuff, jgravelle-google, sunfish, llvm-commits

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

llvm-svn: 348703

5 years ago[WebAssembly] Make WasmSymbol's signature usable for events (NFC)
Heejin Ahn [Sat, 8 Dec 2018 06:16:13 +0000 (06:16 +0000)]
[WebAssembly] Make WasmSymbol's signature usable for events (NFC)

Summary:
WasmSignature used to use its `WasmSignature` member variable only for
function types, but now it also can be used for events as well.

Reviewers: sbc100

Subscribers: dschuff, jgravelle-google, sunfish, llvm-commits

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

llvm-svn: 348702

5 years ago[llvm-readobj] Little clean up inside `parseDynamicTable`
Xing GUO [Sat, 8 Dec 2018 05:32:28 +0000 (05:32 +0000)]
[llvm-readobj] Little clean up inside `parseDynamicTable`

Summary:
This anoymous function actually has same logic with `Obj->toMappedAddr`.

Besides, I have a question on resolving illegal value. `gnu-readelf`, `gnu-objdump` and `llvm-objdump` could parse the test file 'test/tools/llvm-objdump/Inputs/private-headers-x86_64.elf', but `llvm-readobj` will fail when parse `DT_RELR` segment. Because, the value is 0x87654321 which is illegal. So, shall we do this clean up rather then remove the checking statements inside anoymous function?

```
if (Delta >= Phdr.p_filesz)
    return createError("Virtual address is not in any segment");
```

Reviewers: rupprecht, jhenderson

Reviewed By: jhenderson

Subscribers: llvm-commits

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

llvm-svn: 348701

5 years agoConvert some ObjC msgSends to runtime calls.
Pete Cooper [Sat, 8 Dec 2018 05:13:50 +0000 (05:13 +0000)]
Convert some ObjC msgSends to runtime calls.

It is faster to directly call the ObjC runtime for methods such as alloc/allocWithZone instead of sending a message to those functions.

This patch adds support for converting messages to alloc/allocWithZone to their equivalent runtime calls.

Tests included for the positive case of applying this transformation, negative tests that we ensure we only convert "alloc" to objc_alloc, not "alloc2", and also a driver test to ensure we enable this only for supported runtime versions.

Reviewed By: rjmccall

https://reviews.llvm.org/D55349

llvm-svn: 348687

5 years agoMove diagnostic enums into Basic.
Richard Trieu [Sat, 8 Dec 2018 05:05:03 +0000 (05:05 +0000)]
Move diagnostic enums into Basic.

Move enums from */*Diagnostic.h to Basic/Diagnostic*.h.  Basic/AllDiagnostics.h
needs all the enums and moving the sources to Basic prevents a Basic->*->Basic
dependency loop.  This also allows each Basic/Diagnostics*Kinds.td to have a
header at Basic/Diagnostic*.h (except for Common).  The old headers are kept in place since other packages are still using them.

llvm-svn: 348685

5 years agoFix a typo in the strtoi test
Kamil Rytarowski [Sat, 8 Dec 2018 04:46:15 +0000 (04:46 +0000)]
Fix a typo in the strtoi test

https://reviews.llvm.org/D54702

llvm-svn: 348683

5 years agoRevert a chunk of previous change in sanitizer_platform_limits_netbsd.h
Kamil Rytarowski [Sat, 8 Dec 2018 02:47:12 +0000 (02:47 +0000)]
Revert a chunk of previous change in sanitizer_platform_limits_netbsd.h

Undefining INLINE breaks the build.
The invalid change in this file has been overlooked in D55386.

llvm-svn: 348680

5 years agoAdd interceptors for md5(3) from NetBSD
Kamil Rytarowski [Sat, 8 Dec 2018 01:50:18 +0000 (01:50 +0000)]
Add interceptors for md5(3) from NetBSD

Summary:
MD5Init, MD5Update, MD5Final, MD5End, MD5File, MD5Data - calculates the
RSA Data Security, Inc., "MD5" message digest.

Add a dedicated test.

Reviewers: vitalybuka, joerg

Reviewed By: vitalybuka

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

Tags: #sanitizers

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

llvm-svn: 348679

5 years agoAdd interceptors for the rmd160(3) from NetBSD
Kamil Rytarowski [Sat, 8 Dec 2018 01:47:29 +0000 (01:47 +0000)]
Add interceptors for the rmd160(3) from NetBSD

Summary:
RMD160Init, RMD160Update, RMD160Final, RMD160Transform, RMD160End,
RMD160File, RMD160Data - calculates the ``RIPEMD-160'' message digest.

Add a dedicated test for this API.

Reviewers: vitalybuka, joerg

Reviewed By: vitalybuka

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

Tags: #sanitizers

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

llvm-svn: 348678

5 years agoAdd interceptors for the md4(3) from NetBSD
Kamil Rytarowski [Sat, 8 Dec 2018 01:43:39 +0000 (01:43 +0000)]
Add interceptors for the md4(3) from NetBSD

Summary:
MD4Init, MD4Update, MD4Final, MD4End, MD4File, MD4Data - calculates the
RSA Data Security, Inc., "MD4" message digest.

Add dedicated test.

Reviewers: vitalybuka, joerg

Reviewed By: vitalybuka

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

Tags: #sanitizers

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

llvm-svn: 348677

5 years agoAdd interceptors for the sha1(3) from NetBSD
Kamil Rytarowski [Sat, 8 Dec 2018 01:39:47 +0000 (01:39 +0000)]
Add interceptors for the sha1(3) from NetBSD

Summary:
Add interceptors for:

 - SHA1Init
 - SHA1Update
 - SHA1Final
 - SHA1Transform
 - SHA1End
 - SHA1File
 - SHA1FileChunk
 - SHA1Data

Add a dedicated regression test for this API.

Reviewers: vitalybuka, joerg

Reviewed By: vitalybuka

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

Tags: #sanitizers

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

llvm-svn: 348676

5 years agoStop tracking retain count of OSObject after escape to void * / other primitive types
George Karpenkov [Sat, 8 Dec 2018 01:18:40 +0000 (01:18 +0000)]
Stop tracking retain count of OSObject after escape to void * / other primitive types

Escaping to void * / uint64_t / others non-OSObject * should stop tracking,
as such functions can have heterogeneous semantics depending on context,
and can not always be annotated.

rdar://46439133

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

llvm-svn: 348675

5 years ago[sanitizer] Add lit.local.cfg for FreeBSD
Vitaly Buka [Sat, 8 Dec 2018 01:00:45 +0000 (01:00 +0000)]
[sanitizer] Add lit.local.cfg for FreeBSD

llvm-svn: 348674

5 years ago[sanitizer] Suppress lint warning conflicting with clang-format
Vitaly Buka [Sat, 8 Dec 2018 01:00:37 +0000 (01:00 +0000)]
[sanitizer] Suppress lint warning conflicting with clang-format

llvm-svn: 348673

5 years agoFix style.
David Carlier [Sat, 8 Dec 2018 00:44:38 +0000 (00:44 +0000)]
Fix style.

llvm-svn: 348672

5 years ago[gn build] Merge r348593
Nico Weber [Sat, 8 Dec 2018 00:37:14 +0000 (00:37 +0000)]
[gn build] Merge r348593

llvm-svn: 348671

5 years ago[SelectionDAG] Remove ISD::ADDC/ADDE from some undef handling code in getNode. NFCI
Craig Topper [Sat, 8 Dec 2018 00:27:34 +0000 (00:27 +0000)]
[SelectionDAG] Remove ISD::ADDC/ADDE from some undef handling code in getNode. NFCI

These nodes should have two results. A real VT and a Glue. But this code would have returned Undef which would only be a single result. But we're in the single result version of getNode so these opcodes should never be seen by this function anyway.

llvm-svn: 348670

5 years agoConflict fixes from previous commits.
David Carlier [Sat, 8 Dec 2018 00:21:40 +0000 (00:21 +0000)]
Conflict fixes from previous commits.

llvm-svn: 348669

5 years ago[Sanitizer] capsicum api subset interception
David Carlier [Sat, 8 Dec 2018 00:14:04 +0000 (00:14 +0000)]
[Sanitizer] capsicum api subset interception

- For the moment a subset of this api dealing with file descriptors permissions and ioctls.

Reviewers: vitalybuka, krytarowski

Reviewed By: vitalybuka

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

llvm-svn: 348668

5 years ago[gn build] Add build files for lib/CodeGen, lib/Transforms/..., and lib/Bitcode/Writer
Nico Weber [Sat, 8 Dec 2018 00:09:56 +0000 (00:09 +0000)]
[gn build] Add build files for lib/CodeGen, lib/Transforms/..., and lib/Bitcode/Writer

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

llvm-svn: 348667

5 years ago[Documentation] Alphabetical order in new checks list.
Eugene Zelenko [Sat, 8 Dec 2018 00:07:34 +0000 (00:07 +0000)]
[Documentation] Alphabetical order in new checks list.

llvm-svn: 348666

5 years ago[tests] Fix the FileManagerTest getVirtualFile test on Windows
Stella Stamenova [Fri, 7 Dec 2018 23:50:05 +0000 (23:50 +0000)]
[tests] Fix the FileManagerTest getVirtualFile test on Windows

Summary: The test passes on Windows only when it is executed on the C: drive. If the build and tests run on a different drive, the test is currently failing.

Reviewers: kadircet, asmith

Subscribers: cfe-commits

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

llvm-svn: 348665

5 years ago[lit] Fix case-insensitive test
Stella Stamenova [Fri, 7 Dec 2018 23:30:38 +0000 (23:30 +0000)]
[lit] Fix case-insensitive test

The test still only passes when not run from VS because the previous patch did not remove the original build commands.... This also simplifies the build command by removing some defaults

llvm-svn: 348664

5 years agoAdd interceptors for the strtoi(3)/strtou(3) from NetBSD
Kamil Rytarowski [Fri, 7 Dec 2018 22:24:35 +0000 (22:24 +0000)]
Add interceptors for the strtoi(3)/strtou(3) from NetBSD

Summary:
strtoi/strtou converts string value to an intmax_t/uintmax_t integer.

Add a dedicated test.

Enable this API for NetBSD.

It's a reworked version of the original work by Yang Zheng.

Reviewers: joerg, vitalybuka

Reviewed By: vitalybuka

Subscribers: kubamracek, tomsun.0.7, mgorny, llvm-commits, #sanitizers

Tags: #sanitizers

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

llvm-svn: 348663

5 years ago[CUDA] Added missing 'inline' for functions defined in a header.
Artem Belevich [Fri, 7 Dec 2018 22:20:53 +0000 (22:20 +0000)]
[CUDA] Added missing 'inline' for functions defined in a header.

llvm-svn: 348662

5 years ago[X86] Remove the XFAILed test added in r348620
Craig Topper [Fri, 7 Dec 2018 22:16:40 +0000 (22:16 +0000)]
[X86] Remove the XFAILed test added in r348620

It seems to be unexpectedly passing on some bots probably because it requires asserts to fail, but doesn't say that. But we already have a patch in review to make it not xfail so I'd rather just focus on getting it passing rather than trying to figure out an unexpected pass.

llvm-svn: 348661

5 years agoUpdate a couple of vector<bool> tests that were testing libc++-specific bahavior...
Marshall Clow [Fri, 7 Dec 2018 22:16:26 +0000 (22:16 +0000)]
Update a couple of vector<bool> tests that were testing libc++-specific bahavior. Thanks to Andrey Maksimov for the catch.

llvm-svn: 348660

5 years agoFix IOError exception being raised in `asan_symbolize.py`crash when
Dan Liew [Fri, 7 Dec 2018 22:14:20 +0000 (22:14 +0000)]
Fix IOError exception being raised in `asan_symbolize.py`crash when
using `atos` symbolizer on Darwin when the binaries don't exist.

For now we just produce an unsymbolicated stackframe when the binary
doesn't exist.

llvm-svn: 348659

5 years agoAMDGPU: Fix offsets for < 4-byte aggregate kernel arguments
Matt Arsenault [Fri, 7 Dec 2018 22:12:17 +0000 (22:12 +0000)]
AMDGPU: Fix offsets for < 4-byte aggregate kernel arguments

We were still using the rounded down offset and alignment even though
they aren't handled because you can't trivially bitcast the loaded
value.

llvm-svn: 348658

5 years ago[GlobalISel] Add IR translation support for the @llvm.log10 intrinsic
Jessica Paquette [Fri, 7 Dec 2018 22:08:02 +0000 (22:08 +0000)]
[GlobalISel] Add IR translation support for the @llvm.log10 intrinsic

This adds IR translation support for @llvm.log10 and updates relevant tests.

https://reviews.llvm.org/D55392

llvm-svn: 348657

5 years agoAdd a new interceptors for statvfs1(2) and fstatvfs1(2) from NetBSD
Kamil Rytarowski [Fri, 7 Dec 2018 22:01:16 +0000 (22:01 +0000)]
Add a new interceptors for statvfs1(2) and fstatvfs1(2) from NetBSD

Summary:
statvfs1, fstatvfs1 - get file system statistics.

While there, use file descriptor related macros in the fstatvfs interceptor.

Add a dedicated test.

Reviewers: vitalybuka, joerg

Reviewed By: vitalybuka

Subscribers: dvyukov, kubamracek, mgorny, llvm-commits, #sanitizers

Tags: #sanitizers

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

llvm-svn: 348656

5 years ago[Hexagon] Fix post-ra expansion of PS_wselect
Krzysztof Parzyszek [Fri, 7 Dec 2018 22:00:53 +0000 (22:00 +0000)]
[Hexagon] Fix post-ra expansion of PS_wselect

llvm-svn: 348655

5 years agoAdd a new interceptor for fparseln(3) from NetBSD
Kamil Rytarowski [Fri, 7 Dec 2018 21:50:44 +0000 (21:50 +0000)]
Add a new interceptor for fparseln(3) from NetBSD

Summary:
fparseln - returns the next logical line from a stream.

Add a dedicated test for this API.

Reviewers: vitalybuka, joerg

Reviewed By: vitalybuka

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

Tags: #sanitizers

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

llvm-svn: 348654

5 years ago[libcxx] Remove the availability_markup LIT feature
Louis Dionne [Fri, 7 Dec 2018 21:48:39 +0000 (21:48 +0000)]
[libcxx] Remove the availability_markup LIT feature

It is now equivalent to the 'availability' LIT feature, so there's no
reason to keep both.

llvm-svn: 348653

5 years agoclang-format LLVM.h (NFC)
Heejin Ahn [Fri, 7 Dec 2018 21:48:38 +0000 (21:48 +0000)]
clang-format LLVM.h (NFC)

Summary:
- LLVM style does not indent inside namespaces
- Alphabetize

Reviewers: ruiu

Subscribers: sbc100, llvm-commits

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

llvm-svn: 348652

5 years agoAdd new interceptor for strtonum(3)
Kamil Rytarowski [Fri, 7 Dec 2018 21:47:36 +0000 (21:47 +0000)]
Add new interceptor for strtonum(3)

Summary:
strtonum(3) reliably convertss string value to an integer.
This function is used in OpenBSD compat namespace
and is located inside NetBSD's libc.

Add a dedicated test for this interface.

It's a reworked version of the original code by Yang Zheng.

Reviewers: joerg, vitalybuka

Reviewed By: vitalybuka

Subscribers: tomsun.0.7, kubamracek, llvm-commits, mgorny, #sanitizers

Tags: #sanitizers

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

llvm-svn: 348651

5 years ago[ModuleSummary] use StringRefs to avoid a redundant copy; NFC
George Burgess IV [Fri, 7 Dec 2018 21:47:32 +0000 (21:47 +0000)]
[ModuleSummary] use StringRefs to avoid a redundant copy; NFC

`Saver` is a StringSaver, which has a few overloads of `save` that all
ultimately just call `StringRef save(StringRef)`. Just take a StringRef
here instead of building up a std::string to convert it to a StringRef.

llvm-svn: 348650

5 years agoFix unused variable warning. NFCI.
Simon Pilgrim [Fri, 7 Dec 2018 21:44:25 +0000 (21:44 +0000)]
Fix unused variable warning. NFCI.

llvm-svn: 348649

5 years ago[WebAssembly] clang-format/clang-tidy AsmParser (NFC)
Heejin Ahn [Fri, 7 Dec 2018 21:35:37 +0000 (21:35 +0000)]
[WebAssembly] clang-format/clang-tidy AsmParser (NFC)

Summary:
- LLVM clang-format style doesn't allow one-line ifs.
- LLVM clang-tidy style says method names should start with a lowercase
  letter. But currently WebAssemblyAsmParser's parent class
  MCTargetAsmParser is mixing lowercase and uppercase method names
  itself so overridden methods cannot be renamed now.
- Changed else ifs after returns to ifs.
- Added some newlines for readability.

Reviewers: aardappel, sbc100

Subscribers: dschuff, jgravelle-google, sunfish, llvm-commits

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

llvm-svn: 348648

5 years agoDelete registerScope function
Heejin Ahn [Fri, 7 Dec 2018 21:31:14 +0000 (21:31 +0000)]
Delete registerScope function

`unregisterScope()` is not currently used, so removing it.

llvm-svn: 348647

5 years agoFollow-up from r348441 to add the rest of the objc ARC intrinsics.
Pete Cooper [Fri, 7 Dec 2018 21:28:47 +0000 (21:28 +0000)]
Follow-up from r348441 to add the rest of the objc ARC intrinsics.

This adds the other intrinsics used by ARC and codegen's them to their respective runtime methods.

llvm-svn: 348646

5 years ago[MemCpyOpt] memset->memcpy forwarding with undef tail
Nikita Popov [Fri, 7 Dec 2018 21:16:58 +0000 (21:16 +0000)]
[MemCpyOpt] memset->memcpy forwarding with undef tail

Currently memcpyopt optimizes cases like

    memset(a, byte, N);
    memcpy(b, a, M);

to

    memset(a, byte, N);
    memset(b, byte, M);

if M <= N. Often this allows further simplifications down the line,
which drop the first memset entirely.

This patch extends this optimization for the case where M > N, but we
know that the bytes a[N..M] are undef due to alloca/lifetime.start.

This situation arises relatively often for Rust code, because Rust does
not initialize trailing structure padding and loves to insert redundant
memcpys. This also fixes https://bugs.llvm.org/show_bug.cgi?id=39844.

For the implementation, I'm reusing a bit of code for a similar existing
optimization (direct memcpy of undef). I've also added memset support to
MemDepAnalysis GetLocation -- Instead, getPointerDependencyFrom could be
used, but it seems to make more sense to add this to GetLocation and thus
make the computation cachable.

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

llvm-svn: 348645

5 years ago[MemCpyOpt] Add tests for memset->memcpy forwaring with undef tail; NFC
Nikita Popov [Fri, 7 Dec 2018 21:16:52 +0000 (21:16 +0000)]
[MemCpyOpt] Add tests for memset->memcpy forwaring with undef tail; NFC

These are baseline tests for D55120.

llvm-svn: 348644