Commit Graph

4366 Commits

Author SHA1 Message Date
Tim Shen a70ed1d693 [ThinLTO] Add x86 requires to thin_link_bitcode. NFC.
It already specifies the triples, so the intention was to test x86 for
now (or then).

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

llvm-svn: 304501
2017-06-02 00:08:58 +00:00
Tim Shen 50fedec147 [ThinLTO] Wire up ThinLTO and new PM
Summary: This patch teaches clang to use and propagate new PM in ThinLTO.

Reviewers: davide, chandlerc, tejohnson

Subscribers: mehdi_amini, Prazek, inglorion, cfe-commits

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

llvm-svn: 304496
2017-06-01 23:27:51 +00:00
Abderrazek Zaafrani a44e5f601d [AArch64] Add ARMv8.2-A FP16 vefctor intrinsics
llvm-svn: 304493
2017-06-01 23:22:29 +00:00
Vedant Kumar 7f2e3d1eba Relax test to try and appease builders. NFC.
I'm not sure why, but on some bots, the order of two instructions are
swapped (as compared to the output on my machine). Loosen up the
CHECK-NEXT directives to deal with this.

Failing bot: http://lab.llvm.org:8011/builders/clang-with-lto-ubuntu/builds/3097

llvm-svn: 304486
2017-06-01 22:27:39 +00:00
Simon Pilgrim a5dbbc6ead Don't assume that a store source is a vector type just because the destination is (PR26099)
llvm-svn: 304465
2017-06-01 20:13:34 +00:00
Vedant Kumar a125eb55cb [ubsan] Add a check for pointer overflow UB
Check pointer arithmetic for overflow.

For some more background on this check, see:

  https://wdtz.org/catching-pointer-overflow-bugs.html
  https://reviews.llvm.org/D20322

Patch by Will Dietz and John Regehr!

This version of the patch is different from the original in a few ways:

  - It introduces the EmitCheckedInBoundsGEP utility which inserts
    checks when the pointer overflow check is enabled.

  - It does some constant-folding to reduce instrumentation overhead.

  - It does not check some GEPs in CGExprCXX. I'm not sure that
    inserting checks here, or in CGClass, would catch many bugs.

Possible future directions for this check:

  - Introduce CGF.EmitCheckedStructGEP, to detect overflows when
    accessing structures.

Testing: Apart from the added lit test, I ran check-llvm and check-clang
with a stage2, ubsan-instrumented clang. Will and John have also done
extensive testing on numerous open source projects.

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

llvm-svn: 304459
2017-06-01 19:22:18 +00:00
Alexander Kornienko 50e3e123e8 Enable the ARM Neon intrinsics test by default.
The test being marked 'REQUIRES: long-tests' doesn't make sense. It's not the
first time the test is broken without being noticed by the committer. If the
test is too long, it should be shortened, split in multiple ones or removed
altogether. Keeping it as is is actively harmful.
(BTW, on my machine `ninja check-clang` takes 90-92 seconds with and without
this test. The difference in times is below the spread caused by random
factors.)

llvm-svn: 304302
2017-05-31 14:35:50 +00:00
Alexander Kornienko 915e3ab8f6 Revert "[ARM] Update long-test after r304201."
This reverts commit 304208, since r304201 has been reverted as well.

The test needs to be turned on by default to detect breakages earlier. Will
commit this change separately.

llvm-svn: 304301
2017-05-31 14:33:29 +00:00
Javed Absar 089f678784 Reverting Neon vector type 64-alignment fix
The patch caused ABI breaks on darwin/others.
Reverting to come back with a more restrictive patch.

llvm-svn: 304220
2017-05-30 17:09:47 +00:00
Diana Picus 6d5ac7af4a Fixup r304205 - Require PowerPC target
llvm-svn: 304211
2017-05-30 14:05:33 +00:00
Javed Absar 0841d620c5 Fix issue with test that caused bildbot failure
These tests did not specify the target. 
The failure was triggered by change - 
https://reviews.llvm.org/D33205
http://lab.llvm.org:8011/builders/clang-cmake-armv7-a15-full/builds/7314

which sets vector alignment to 8-byte for arm-targets (except for Android).
So, fixing the test to make it target specific. 

llvm-svn: 304210
2017-05-30 13:34:26 +00:00
Benjamin Kramer 88d73626cd [ARM] Update long-test after r304201.
llvm-svn: 304208
2017-05-30 12:44:48 +00:00
Benjamin Kramer c796245431 [PPC] Make altivec conversion function macros.
The second argument must be a constant, otherwise instruction selection
will fail. always_inline is not enough for isel to always fold
everything away at -O0.

Sadly the overloading turned this into a big macro mess. Fixes PR33212.

llvm-svn: 304205
2017-05-30 11:37:29 +00:00
Javed Absar 3d92d7ab36 [ARM] Fix Neon vector type alignment to 64-bit
The maximum alignment for ARM NEON data types should be 64-bits as specified
in ARM procedure call standard document Sec. A.2 Notes.
This patch fixes it from its current larger natural default values, except
for Android (so as not to break existing ABI).
Reviewed by: Stephen Hines, Renato Golin.
Differential Revision: https://reviews.llvm.org/D33205

llvm-svn: 304201
2017-05-30 10:12:15 +00:00
Benjamin Kramer e524ddeef3 Unbreak long test after r304127.
llvm-svn: 304167
2017-05-29 18:11:11 +00:00
Mehdi Amini 6aa9e9b41a IRGen: Add optnone attribute on function during O0
Amongst other, this will help LTO to correctly handle/honor files
compiled with O0, helping debugging failures.
It also seems in line with how we handle other options, like how
-fnoinline adds the appropriate attribute as well.

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

llvm-svn: 304127
2017-05-29 05:38:20 +00:00
Arnold Schwaighofer 634e320376 CodeGen: Define Swift's legal vector types for AArch64, ARM
rdar://32401301

llvm-svn: 304017
2017-05-26 18:11:54 +00:00
Oren Ben Simhon 140c1fb9ec [X86] Adding avx512_vpopcntdq feature set and its intrinsics
AVX512_VPOPCNTDQ is a new feature set that was published by Intel.
The patch represents the Clang side of the addition of six intrinsics for two new machine instructions (vpopcntd and vpopcntq).
It also includes the addition of the new feature set.

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

llvm-svn: 303857
2017-05-25 13:44:11 +00:00
Krzysztof Parzyszek 5960a57ef7 [CodeGen] Pessimize aliasing for member unions (and may-alias) objects
Use the TBAA info of the omnipotent char for these objects.

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

llvm-svn: 303851
2017-05-25 12:55:47 +00:00
Tony Jiang f70a913e13 Fix one test case faiulre in commit 303766.
It is clean when I build boostrap and run make checkall on my machine, I guess
it could be I only build bootstrap with assert, while the buildbots may build
without asserts, which could cause the difference.

llvm-svn: 303786
2017-05-24 18:12:11 +00:00
Tony Jiang 9aa2c0383d [PowerPC] Implement vec_xxsldwi builtin.
The vec_xxsldwi builtin is missing from altivec.h. This has been requested by
developers working on libvpx for VP9 support for Google.

The patch fixes PR: https://bugs.llvm.org/show_bug.cgi?id=32653
Differential Revision: https://reviews.llvm.org/D33236

llvm-svn: 303766
2017-05-24 15:54:13 +00:00
Tony Jiang bbc48e9164 [PowerPC] Implement vec_xxpermdi builtin.
The vec_xxpermdi builtin is missing from altivec.h. This has been requested by
developers working on libvpx for VP9 support for Google.

The patch fixes PR: https://bugs.llvm.org/show_bug.cgi?id=32653
Differential Revision: https://reviews.llvm.org/D33053

llvm-svn: 303760
2017-05-24 15:13:32 +00:00
Dean Michael Berris 170429e290 [XRay][clang] Allow imbuing arg1 logging attribute via -fxray-always-instrument=
Summary:
This change allows us to add arg1 logging support to functions through
the special case list provided through -fxray-always-instrument=. This
is useful for adding arg1 logging to functions that are either in
headers that users don't have control over (i.e. cannot change the
source) or would rather not do.

It only takes effect when the pattern is matched through the "fun:"
special case, as a category. As in:

  fun:*pattern=arg1

Reviewers: pelikan, rnk

Subscribers: cfe-commits

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

llvm-svn: 303719
2017-05-24 05:46:36 +00:00
Simon Dardis 657188ab00 [mips] Make checks in CodeGen/mips-varargs.c less fragile
This test was failing on our fork of clang because it was not capturing
[[ARG]] in the N32 case. Therefore it used the value from the last function
which does not always have to be the same. All other cases were already
capturing ARG so this appears to be an oversight.
The test now uses -enable-var-scope to prevent such errors in the future.

Reviewers: sdardis, atanasyan

Patch by: Alexander Richardson

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

llvm-svn: 303619
2017-05-23 09:42:50 +00:00
Teresa Johnson acf4b09fee Adjust clang test for r303590
Forgot to commit this separately from the llvm change to use a new
module flag type for pic and pie levels. Should fix the bot errors

llvm-svn: 303593
2017-05-23 00:35:09 +00:00
Simon Atanasyan 2c87f5341d [mips] Support `micromips` attribute
This patch adds support for the `micromips` and `nomicromips` attributes
for MIPS targets.

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

llvm-svn: 303546
2017-05-22 12:47:43 +00:00
Matthias Braun a451953224 CodeGenModule: Always output wchar_size, check LLVM assumptions.
Re-commit r303463 now that LLVM is fixed and adjust some lit tests.

llvm::TargetLibraryInfo needs to know the size of wchar_t to work on
functions like `wcslen`. This patch changes clang to always emit the
wchar_size module flag (it would only do so for ARM previously).
This also adds an `assert()` to ensure the LLVM defaults based on the
target triple are in sync with clang.

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

llvm-svn: 303478
2017-05-20 01:29:55 +00:00
Matthias Braun 421b63dd70 Revert "CodeGenModule: Always output wchar_size, check LLVM assumptions."
Let's revert this for now (and with it the assert()) to get the bots
back to green until I have LLVM synced up properly.

This reverts commit r303463.

llvm-svn: 303474
2017-05-20 00:38:27 +00:00
Matthias Braun bf4a869dfb CodeGenModule: Always output wchar_size, check LLVM assumptions.
llvm::TargetLibraryInfo needs to know the size of wchar_t to work on
functions like `wcslen`. This patch changes clang to always emit the
wchar_size module flag (it would only do so for ARM previously).
This also adds an `assert()` to ensure the LLVM defaults based on the
target triple are in sync with clang.

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

llvm-svn: 303463
2017-05-19 22:37:15 +00:00
Yaxun Liu 6d96f16347 CodeGen: Cast alloca to expected address space
Alloca always returns a pointer in alloca address space, which may
be different from the type defined by the language. For example,
in C++ the auto variables are in the default address space. Therefore
cast alloca to the expected address space when necessary.

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

llvm-svn: 303370
2017-05-18 18:51:09 +00:00
Evgeniy Stepanov 5c3e07f78d [asan] One more test for -fsanitize-address-globals-dead-stripping.
llvm-svn: 303114
2017-05-15 20:43:48 +00:00
Teresa Johnson 517729fb20 Remove ignore-empty-index-file option
Summary:
Clang changes to remove this option and replace with a parameter
always set in the context of a ThinLTO distributed backend.

Depends on D33133.

Reviewers: pcc

Subscribers: mehdi_amini, eraman, cfe-commits

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

llvm-svn: 302940
2017-05-12 19:32:17 +00:00
James Y Knight eb96e44aea [SPARC] Support 'f' and 'e' inline asm constraints.
Patch by Patrick Boettcher.

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

llvm-svn: 302913
2017-05-12 16:01:23 +00:00
Reid Kleckner 43bbeb4c9f Issue diagnostics when returning FP values on x86_64 without SSE1/2
Avoid using report_fatal_error, because it will ask the user to file a
bug. If the user attempts to disable SSE on x86_64 and them use floating
point, that's a bug in their code, not a bug in the compiler.

This is just a start. There are other ways to crash the backend in this
configuration, but they should be updated to follow this pattern.

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

llvm-svn: 302835
2017-05-11 22:43:02 +00:00
Petar Jovanovic 6f4cdb8912 Reland: [mips] Impose a threshold for coercion of aggregates
Modified MipsABIInfo::classifyArgumentType so that it now coerces
    aggregate structures only if the size of said aggregate is less than
    16/64 bytes, depending on the ABI.

    Patch by Stefan Maksimovic.

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

with minor changes (use regexp instead of the hardcoded values) to the test.

llvm-svn: 302670
2017-05-10 14:28:18 +00:00
Vedant Kumar 4b62b5cddd [ubsan] Mark overflow checks with !nosanitize
Sanitizer instrumentation generally needs to be marked with !nosanitize,
but we're not doing this properly for ubsan's overflow checks.

r213291 has more information about why this is needed.

llvm-svn: 302598
2017-05-09 23:34:49 +00:00
Evgeniy Stepanov d991cdd50b [asan] A clang flag to enable ELF globals-gc.
This feature is subtly broken when the linker is gold 2.26 or
earlier. See the following bug for details:
  https://sourceware.org/bugzilla/show_bug.cgi?id=19002

Since the decision needs to be made at compilation time, we can not
test the linker version. The flag is off by default on ELF targets,
and on otherwise.

llvm-svn: 302591
2017-05-09 21:57:43 +00:00
Petar Jovanovic 753267b750 Revert r302547 ([mips] Impose a threshold for coercion of aggregates)
Reverting
  Modified MipsABIInfo::classifyArgumentType so that it now coerces
  aggregate structures only if the size of said aggregate is less than 16/64
  bytes, depending on the ABI.
as it broke clang-with-lto-ubuntu builder.

llvm-svn: 302555
2017-05-09 17:20:06 +00:00
Petar Jovanovic 125c03070e [mips] Impose a threshold for coercion of aggregates
Modified MipsABIInfo::classifyArgumentType so that it now coerces aggregate
structures only if the size of said aggregate is less than 16/64 bytes,
depending on the ABI.

Patch by Stefan Maksimovic.

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

llvm-svn: 302547
2017-05-09 16:24:03 +00:00
Dean Michael Berris 42af651358 [XRay] Add __xray_customeevent(...) as a clang-supported builtin
Summary:
We define the `__xray_customeevent` builtin that gets translated to
IR calls to the correct intrinsic. The default implementation of this is
a no-op function. The codegen side of this follows the following logic:

- When `-fxray-instrument` is not provided in the driver, we elide all
calls to `__xray_customevent`.
- When `-fxray-instrument` is enabled and a function is marked as "never
instrumented", we elide all calls to `__xray_customevent` in that
function; if either marked as "always instrumented" or subject to
threshold-based instrumentation, we emit a call to the
`llvm.xray.customevent` intrinsic from LLVM for each
`__xray_customevent` occurrence in the function.

This change depends on D27503 (to land in LLVM first).

Reviewers: echristo, rsmith

Subscribers: mehdi_amini, pelikan, lrl, cfe-commits

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

llvm-svn: 302492
2017-05-09 00:45:40 +00:00
Simon Pilgrim 3511348dbb [X86][LWP] Add clang support for LWP instructions.
This patch adds support for the the LightWeight Profiling (LWP) instructions which are available on all AMD Bulldozer class CPUs (bdver1 to bdver4).

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

llvm-svn: 302418
2017-05-08 12:09:45 +00:00
Tim Northover 23bcad226c AArch64: fix weird edge case in ABI.
It turns out there are some sort-of-but-not-quite empty structs that break all
the rules. For example:

struct SuperEmpty { int arr[0]; };
struct SortOfEmpty { struct SuperEmpty e; };

Both of these have sizeof == 0, even in C++ mode, for GCC compatibility. The
first one also doesn't occupy a register when passed by value in GNU C++ mode,
unlike everything else.

On Darwin, we want to ignore the lot (and especially don't want to try to use
an i0 as we were).

llvm-svn: 302313
2017-05-05 22:36:06 +00:00
Reid Kleckner 6d2ea6ec80 [ms-inline-asm] Use the frontend size only for ambiguous instructions
This avoids problems on code like this:
  char buf[16];
  __asm {
    movups xmm0, [buf]
    mov [buf], eax
  }

The frontend size in this case (1) is wrong, and the register makes the
instruction matching unambiguous. There are also enough bytes available
that we shouldn't complain to the user that they are potentially using
an incorrectly sized instruction to access the variable.

Supersedes D32636 and D26586 and fixes PR28266

llvm-svn: 302179
2017-05-04 18:19:52 +00:00
Peter Collingbourne 9667b91b13 Re-apply r302108, "IR: Use pointers instead of GUIDs to represent edges in the module summary. NFCI."
with a fix for the clang backend.

llvm-svn: 302176
2017-05-04 18:03:25 +00:00
Sam Parker b9ea36f9c1 [ARM] ACLE Chapter 9 intrinsics
Implemented the remaining integer data processing intrinsics from
the ARM ACLE v2.1 spec, such as parallel arithemtic and DSP style
multiplications.

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

llvm-svn: 302131
2017-05-04 08:37:59 +00:00
Daniel Jasper 6e254b5f38 Fix tests after speculatable intrinsics patch
These were relying on the attribute group numbering

llvm-svn: 302009
2017-05-03 10:04:25 +00:00
Matt Arsenault 7c4c1cb2f5 Fix tests after speculatable intrinsics patch
These were relying on the attribute group numbering

llvm-svn: 301996
2017-05-03 03:04:40 +00:00
Vedant Kumar d919115983 [ubsan] Skip overflow checks on safe arithmetic (fixes PR32874)
Currently, ubsan emits overflow checks for arithmetic that is known to
be safe at compile-time, e.g:

  1 + 1 => CheckedAdd(1, 1)

This leads to breakage when using the __builtin_prefetch intrinsic. LLVM
expects the arguments to @llvm.prefetch to be constant integers, and
when ubsan inserts unnecessary checks on the operands to the intrinsic,
this contract is broken, leading to verifier failures (see PR32874).

Instead of special-casing __builtin_prefetch for ubsan, this patch fixes
the underlying problem, i.e that clang currently emits unnecessary
overflow checks.

Testing: I ran the check-clang and check-ubsan targets with a stage2,
ubsan-enabled build of clang. I added a regression test for PR32874, and
some extra checking to make sure we don't regress runtime checking for
unsafe arithmetic. The existing ubsan-promoted-arithmetic.cpp test also
provides coverage for this change.

llvm-svn: 301988
2017-05-02 23:46:56 +00:00
Sanjay Patel 77f3b188a2 [CodeGen] remove/fix checks that will fail when r301923 is recommitted
Don't test the optimizer as part of front-end verification.

llvm-svn: 301928
2017-05-02 15:20:18 +00:00
Simon Pilgrim 96d02f5503 [X86][AVX] Added support for _mm256_zext* helper intrinsics (PR32839)
llvm-svn: 301749
2017-04-29 17:17:06 +00:00
Simon Pilgrim 99ed27053d [X86][SSE] Add _mm_set_pd1 (PR32827)
Matches _mm_set_ps1 implementation

llvm-svn: 301637
2017-04-28 10:28:32 +00:00
Rui Ueyama 0fcbb2893e Revert r301487: Replace HashString algorithm with xxHash64
This reverts commit r301487 to make buildbots green.

llvm-svn: 301491
2017-04-26 23:15:10 +00:00
Rui Ueyama 87b30ac9d3 Replace HashString algorithm with xxHash64
The previous algorithm processed one character at a time, which is very
painful on a modern CPU. Replace it with xxHash64, which both already
exists in the codebase and is fairly fast.

Patch from Scott Smith!

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

llvm-svn: 301487
2017-04-26 22:45:04 +00:00
Vedant Kumar e859ebbd06 [ubsan] Skip alignment checks on allocas with known alignment
It's possible to determine the alignment of an alloca at compile-time.
Use this information to skip emitting some runtime alignment checks.

Testing: check-clang, check-ubsan.

This significantly reduces the amount of alignment checks we emit when
compiling X86ISelLowering.cpp. Here are the numbers from patched/unpatched
clangs based on r301361.

  ------------------------------------------
  | Setup          | # of alignment checks |
  ------------------------------------------
  | unpatched, -O0 |                 47195 |
  | patched, -O0   |                 30876 | (-34.6%)
  ------------------------------------------

llvm-svn: 301377
2017-04-26 02:17:21 +00:00
Evgeniy Stepanov c7b90947bd [asan] Unconditionally enable GC of globals on COFF.
This change restores pre-r301225 behavior, where linker GC compatible global
instrumentation was used on COFF targets disregarding -f(no-)data-sections and/or
/Gw flags.

This instrumentation puts each global in a COMDAT with an ASan descriptor for that global.
It effectively enables -fdata-sections, but limits it to ASan-instrumented globals.

llvm-svn: 301374
2017-04-26 00:51:06 +00:00
Davide Italiano e2ff98d9f8 [PGO/tests] Update comment to reflect reality.
llvm-svn: 301344
2017-04-25 18:04:31 +00:00
Davide Italiano 44f6ea8818 [PGO] Update test now that we don't call IndirectCallPromotion.
llvm-svn: 301339
2017-04-25 17:48:10 +00:00
Evgeniy Stepanov df217a2f3c [asan] Disable ASan global-GC depending on the target and compiler flags.
llvm-svn: 301225
2017-04-24 19:34:12 +00:00
David Blaikie 8150355498 Move Split DWARF handling to an MC option/command line argument rather than using metadata
Since Split DWARF needs to name the actual .dwo file that is generated,
it can't be known at the time the llvm::Module is produced as it may be
merged with other Modules before the object is generated and that object
may be generated with any name.

By passing the Split DWARF file name when LLVM is producing object code
the .dwo file name in the object file can match correctly.

The support for Split DWARF for implicit modules remains the same -
using metadata to store the dwo name and dwo id so that potentially
multiple skeleton CUs referring to different dwo files can be generated
from one llvm::Module.

llvm-svn: 301063
2017-04-21 23:35:36 +00:00
Adam Nemet 03af42444b Don't pass FPOpFusion::Strict to the backend
This restores the behavior prior to D31167 where the code-gen default was
FPC_On which mapped to FPOpFusion::Standard.  After merging the FE
state (on/off) and the code-gen state (on/fast/off), the default became off to
match the front-end.

In other words, the front-end controls when to fuse along the language
standards and the backend shouldn't override this by splitting fused
intrinsics as FPOpFusion::Strict would imply.

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

llvm-svn: 300858
2017-04-20 17:09:35 +00:00
David Blaikie 6e2ec5f10e Parse backend options during thinlto backend compile actions
llvm-svn: 300741
2017-04-19 20:08:21 +00:00
Adrian Prantl c3782a1a6f Debug Info: Remove special-casing of indirect function argument handling.
LLVM has changed the semantics of dbg.declare for describing function
arguments. After this patch a dbg.declare always takes the *address*
of a variable as the first argument, even if the argument is not an
alloca.

https://bugs.llvm.org/show_bug.cgi?id=32382
rdar://problem/31205000

llvm-svn: 300523
2017-04-18 01:22:01 +00:00
Simon Pilgrim 9f6e79c5e4 [X86][SSE] Update MOVNTDQA non-temporal loads to generic implementation (clang)
MOVNTDQA non-temporal aligned vector loads can be correctly represented using generic builtin loads, allowing us to remove the existing x86 intrinsics.

LLVM companion patch: D31767.

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

llvm-svn: 300326
2017-04-14 15:05:57 +00:00
Yaxun Liu b34ec829be [OpenCL] Map default address space to alloca address space
For OpenCL, the private address space qualifier is 0 in AST. Before this change, 0 address space qualifier
is always mapped to target address space 0. As now target private address space is specified by
alloca address space in data layout, address space qualifier 0 needs to be mapped to alloca addr space specified by the data layout.

This change has no impact on targets whose alloca addr space is 0.

With contributions from Matt Arsenault, Tony Tye and Wen-Heng (Jack) Chung

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

llvm-svn: 299965
2017-04-11 17:24:23 +00:00
Reid Kleckner eb9dd5b87f Reland "[IR] Make AttributeSetNode public, avoid temporary AttributeList copies"
This re-lands r299875.

I introduced a bug in Clang code responsible for replacing K&R, no
prototype declarations with a real function definition with a prototype.
The bug was here:

       // Collect any return attributes from the call.
  -    if (oldAttrs.hasAttributes(llvm::AttributeList::ReturnIndex))
  -      newAttrs.push_back(llvm::AttributeList::get(newFn->getContext(),
  -                                                  oldAttrs.getRetAttributes()));
  +    newAttrs.push_back(oldAttrs.getRetAttributes());

Previously getRetAttributes() carried AttributeList::ReturnIndex in its
AttributeList. Now that we return the AttributeSetNode* directly, it no
longer carries that index, and we call this overload with a single node:
  AttributeList::get(LLVMContext&, ArrayRef<AttributeSetNode*>)

That aborted with an assertion on x86_32 targets. I added an explicit
triple to the test and added CHECKs to help find issues like this in the
future sooner.

llvm-svn: 299899
2017-04-10 23:31:05 +00:00
Matt Arsenault d972949b10 Update for lifetime intrinsic signature change
llvm-svn: 299877
2017-04-10 20:18:45 +00:00
Evgeniy Stepanov 1a8030e737 [cfi] Emit __cfi_check stub in the frontend.
Previously __cfi_check was created in LTO optimization pipeline, which
means LLD has no way of knowing about the existence of this symbol
without rescanning the LTO output object. As a result, LLD fails to
export __cfi_check, even when given --export-dynamic-symbol flag.

llvm-svn: 299806
2017-04-07 23:00:38 +00:00
Hans Wennborg f6388b182d Attempt to fix ms-intrinsics.c test
llvm-svn: 299785
2017-04-07 17:01:56 +00:00
Hans Wennborg 5c3c51fe05 Implement _interlockedbittestandset as a builtin
It's used by MS headers in VS 2017 without including intrin.h, so we
can't implement it in the header anymore.

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

llvm-svn: 299782
2017-04-07 16:41:47 +00:00
Adam Nemet 60d3264d5f Add #pragma clang fp
This adds the new pragma and the first variant, contract(on/off/fast).

The pragma has the same block scope rules as STDC FP_CONTRACT, i.e. it can be
placed at the beginning of a compound statement or at file scope.

Similarly to STDC FP_CONTRACT there is no need to use attributes.  First an
annotate token is inserted with the parsed details of the pragma.  Then the
annotate token is parsed in the proper contexts and the Sema is updated with
the corresponding FPOptions using the shared ActOn function with STDC
FP_CONTRACT.

After this the FPOptions from the Sema is propagated into the AST expression
nodes.  There is no change here.

I was going to add a 'default' option besides 'on/off/fast' similar to STDC
FP_CONTRACT but then decided against it. I think that we'd have to make option
uppercase then to avoid using 'default' the keyword.  Also because of the
scoped activation of pragma I am not sure there is really a need a for this.

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

llvm-svn: 299470
2017-04-04 21:18:36 +00:00
Adam Nemet 370d0877f6 Set FMF for -ffp-contract=fast
With this, FMF(contract) becomes an alternative way to express the request to
contract.

These are currently only propagated for FMul, FAdd and FSub.  The rest will be
added as more FMFs are hooked up for this.

This is toward fixing PR25721.

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

llvm-svn: 299469
2017-04-04 21:18:30 +00:00
Coby Tayree b76fb84032 [fixup][X86][inline-asm] Add support for MS 'EVEN' directive
refining tested targets resolution, to amend failures caused by rL299454

llvm-svn: 299459
2017-04-04 19:20:21 +00:00
Coby Tayree b186493cc8 [X86][inline-asm] Add support for MS 'EVEN' directive
MS assembly syntax provide us with the 'EVEN' directive as a synonymous to at&t '.even'.
This patch include the (small, simple) changes need to allow it.

llvm-side:
https://reviews.llvm.org/D27417

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

llvm-svn: 299454
2017-04-04 17:58:28 +00:00
Michael Zuckerman 13bcf4944a Fix problem with test.
llvm-svn: 299442
2017-04-04 15:44:06 +00:00
Michael Zuckerman 755a13db3d [X86][Clang] Converting __mm{|256|512}_movm_epi{8|16|32|64} LLVMIR call into generic intrinsics.
This patch is a part two of two reviews, one for the clang and the other for LLVM. 
In this patch, I covered the clang side, by introducing the intrinsic to the front end. 
This is done by creating a generic replacement.

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

llvm-svn: 299431
2017-04-04 13:29:53 +00:00
Teresa Johnson b637cb07ed [ThinLTO] Handle -emit-llvm* in ThinLTO backends
Summary:
Use PreCodeGenModuleHook to invoke the correct writer when emitting LLVM
IR, returning false to skip codegen from within thinBackend.

Reviewers: pcc, mehdi_amini

Subscribers: Prazek, cfe-commits

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

llvm-svn: 299274
2017-03-31 22:35:47 +00:00
Craig Topper f771f79b2f [Sema][X86] Update immediate check for gather/scatter prefetch instructions to match the _MM_HINT_T0/T1 constant definitions
Our _MM_HINT_T0/T1 constant values are 3/2 which matches gcc, but not icc or Intel documentation. Interestingly gcc had this same bug on their implementation of the gather/scatter builtins at one point too.

Fixes PR32411.

llvm-svn: 299233
2017-03-31 17:22:30 +00:00
Petar Jovanovic 9b8b9e81dd [mips][msa] Range adjustment for ldi_b builtin function operand
Reasoning behind this change was allowing the function to accept all values
from range [-128, 255] since all of them can be encoded in an 8bit wide
value.
This differs from the prior state where only range [-128, 127] was accepted,
where values were assumed to be signed, whereas now the actual
interpretation of the immediate is deferred to the consumer as required.

Patch by Stefan Maksimovic.

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

llvm-svn: 299229
2017-03-31 16:16:43 +00:00
Teresa Johnson 3cfab4b934 Add back test for r299152
I am hoping the bot failures are addressed by using cc1 for the ThinLTO
backend invocations as well.

llvm-svn: 299217
2017-03-31 13:48:18 +00:00
Teresa Johnson adeae05f2d Revert test added in r299152
Removing the test until I can figure out how to get the ThinLTO backend
invocation of clang to use the correct target.

llvm-svn: 299181
2017-03-31 04:29:07 +00:00
Teresa Johnson 163e4992b7 Add target-cpu
Sigh, another follow-on fix needed for test in r299152 causing bot
failures. We also need the target-cpu for the ThinLTO BE clang
invocation.

llvm-svn: 299178
2017-03-31 03:49:52 +00:00
Teresa Johnson 0c835d21c0 Add more target triples to test
Third and hopefully final fix to test for r299152 that is causing bot
failures: make sure the target triple specified for the ThinLTO backend
clang invocations as well.

llvm-svn: 299176
2017-03-31 03:27:47 +00:00
Teresa Johnson fcb8989d72 Fix new compile command in test
My previous attempt to fix bot failures from r299152 didn't add the
necessary option to get bitcode out of the cc1 step.

llvm-svn: 299173
2017-03-31 02:55:31 +00:00
Teresa Johnson ae9c74280c Add triple to new test
Attempt to fix bot errors from r299152 by using clang_cc1 and specifying
target triple to compile step.

llvm-svn: 299170
2017-03-31 02:36:47 +00:00
Teresa Johnson 5ed6c10761 [ThinLTO] Set up lto::Config properly for codegen in ThinLTO backends
Summary:
This involved refactoring out pieces of
EmitAssemblyHelper::CreateTargetMachine for use in runThinLTOBackend.

Subsumes D31114.

Reviewers: mehdi_amini, pcc

Subscribers: Prazek, cfe-commits

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

llvm-svn: 299152
2017-03-31 02:05:15 +00:00
Dean Michael Berris ac7a2f97d4 fixup: use CHECK for non-atttribute sets
llvm-svn: 299127
2017-03-30 22:46:49 +00:00
Dean Michael Berris 504fc2262a [XRay][clang] Fix the -fxray-instruction-threshold flag processing
Summary:
The refactoring introduced a regression in the flag processing for
-fxray-instruction-threshold which causes it to not get passed properly.
This change should restore the previous behaviour.

Reviewers: rnk, pelikan

Subscribers: cfe-commits

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

llvm-svn: 299126
2017-03-30 22:46:45 +00:00
Erich Keane 623efd8a75 Clang changes for alloc_align attribute
GCC has the alloc_align attribute, which is similar to assume_aligned, except the attribute's parameter is the index of the integer parameter that needs aligning to.

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

llvm-svn: 299117
2017-03-30 21:48:55 +00:00
Dean Michael Berris 835832d37a [XRay] Add -fxray-{always,never}-instrument= flags to clang
Summary:
The -fxray-always-instrument= and -fxray-never-instrument= flags take
filenames that are used to imbue the XRay instrumentation attributes
using a whitelist mechanism (similar to the sanitizer special cases
list). We use the same syntax and semantics as the sanitizer blacklists
files in the implementation.

As implemented, we respect the attributes that are already defined in
the source file (i.e. those that have the
[[clang::xray_{always,never}_instrument]] attributes) before applying
the always/never instrument lists.

Reviewers: rsmith, chandlerc

Subscribers: jfb, mgorny, cfe-commits

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

llvm-svn: 299041
2017-03-30 00:29:36 +00:00
Chandler Carruth 45bbe0117b Revert r298491 and r298494 which changed Clang's handling of 'nonnull'
attributes.

These patches don't work because we can't currently access the parameter
information in a reliable way when building attributes. I thought this
would be relatively straightforward to fix, but it seems not to be the
case. Fixing this will requrie a substantial re-plumbing of machinery to
allow attributes to be handled in this location, and several other fixes
to the attribute machinery should probably be made at the same time. All
of this will make the patch .... substantially more complicated.

Reverting for now as there are active miscompiles caused by the current
version.

llvm-svn: 298695
2017-03-24 09:11:57 +00:00
Dehao Chen 1240bd31e9 Update the SamplePGO test to verify that unroll/icp is not invoked in thinlto compile phase.
Summary: This is the test added for https://reviews.llvm.org/D31217

Reviewers: tejohnson, mehdi_amini

Reviewed By: tejohnson

Subscribers: cfe-commits, Prazek

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

llvm-svn: 298647
2017-03-23 21:20:17 +00:00
Teresa Johnson 488d1dc0ed [ThinLTO] Clang support for emitting minimized bitcode for thin link
Summary:
Clang companion patch to LLVM patch D31027, which adds support
for emitting minimized bitcode file for use in the thin link step.
Add a cc1 option -fthin-link-bitcode=<file> to trigger this behavior.

Depends on D31027.

Reviewers: mehdi_amini, pcc

Subscribers: cfe-commits, Prazek

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

llvm-svn: 298639
2017-03-23 19:47:49 +00:00
Hans Wennborg 043f402586 [X86] Implement __readgsqword (and the rest) as builtins (PR32373)
It seems MS headers have started using __readgsqword, and since it's
used in a header that doesn't include intrin.h, we can't implement it as
an inline function anymore.

That was already the case for __readfsdword, which Saleem added support
for in r220859. This patch reuses that codegen to implement all of
__read[fg]s{byte,word,dword,qword}.

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

llvm-svn: 298538
2017-03-22 19:13:13 +00:00
Simon Pilgrim 0f3a52b8c9 [X86][MMX] Add tests for _mm_set*_* intrinsics
llvm-svn: 298511
2017-03-22 14:55:43 +00:00
Chandler Carruth 421fa6c9e2 Remove an overly aggressive assert in r298491 and leave a comment
explaining why we have to ignore errors here even though in other parts
of codegen we can be more strict with builtins.

Also add a test case based on the code in a TSan test that found this
issue.

llvm-svn: 298494
2017-03-22 10:38:07 +00:00
Chandler Carruth 9b3607f0a6 [nonnull] Teach Clang to attach the nonnull LLVM attribute to
declarations and calls instead of just definitions, and then teach it to
*not* attach such attributes even if the source code contains them.

This follows the design direction discussed on cfe-dev here:
http://lists.llvm.org/pipermail/cfe-dev/2017-January/052066.html

The idea is that for C standard library builtins, even if the library
vendor chooses to annotate their routines with __attribute__((nonnull)),
we will ignore those attributes which pertain to pointer arguments that
have an associated size. This allows the widespread (and seemingly
reasonable) pattern of calling these routines with a null pointer and
a zero size. I have only done this for the library builtins currently
recognized by Clang, but we can now trivially add to this set. This will
be controllable with -fno-builtin if anyone should care to do so.

Note that this does *not* change the AST. As a consequence, warnings,
static analysis, and source code rewriting are not impacted.

This isn't even a regression on any platform as neither Clang nor LLVM
have ever put 'nonnull' onto these arguments for declarations. All this
patch does is enable it on other declarations while preventing us from
ever accidentally enabling it on these libc functions due to a library
vendor.

It will also allow any other libraries using this annotation to gain
optimizations based on the annotation even when only a declaration is
visible.

llvm-svn: 298491
2017-03-22 09:09:13 +00:00
Adam Nemet 5827756e90 Remove -ffp-contract=fast from this test
It does not need it and causes mismatch after -ffp-contract=fast is turned
into an FMF.

llvm-svn: 298469
2017-03-22 00:58:18 +00:00
Adam Nemet 3087c96348 Change -ffp-contract=fast test to run on Aarch64
(I don't have powerpc enabled in my build and I am changing
how -ffp-contract=fast works.)

llvm-svn: 298468
2017-03-22 00:58:15 +00:00
Eric Christopher 758aad76d8 Remove the -faltivec alias option and replace it with -maltivec everywhere.
The alias was only ever used on darwin and had some issues there,
and isn't used in practice much. Also fixes a problem with -mno-altivec
not turning off -maltivec.

Also add a diagnostic for faltivec/fno-altivec that directs users to use
maltivec options and include the altivec.h file explicitly.

llvm-svn: 298449
2017-03-21 22:06:18 +00:00
George Burgess IV a63f91574f Let llvm.objectsize be conservative with null pointers
D28494 adds another parameter to @llvm.objectsize. Clang needs to be
sure to pass that third arg whenever applicable.

llvm-svn: 298431
2017-03-21 20:09:35 +00:00
Dehao Chen ce39fdd6ee Clang change: Do not inline hot callsites for samplepgo in thinlto compile phase.
Summary:
Because SamplePGO passes will be invoked twice in ThinLTO build: once at compile phase, the other at backend. We want to make sure the IR at the 2nd phase matches the hot part in pro
file, thus we do not want to inline hot callsites in the first phase.

Reviewers: tejohnson, eraman

Reviewed By: tejohnson

Subscribers: mehdi_amini, cfe-commits, Prazek

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

llvm-svn: 298429
2017-03-21 19:55:46 +00:00
Coby Tayree 665b89bac5 [X86][MS-compatability][clang] allow MS TYPE/SIZE/LENGTH operators as a part of a compound expression
This patch introduces X86AsmParser with the ability to handle the aforementioned ops within compound "MS" arithmetical expressions.
Currently - only supported as a stand alone Operand, e.g.:
"TYPE X"
now allowed :
"4 + TYPE X * 128"

LLVM side: https://reviews.llvm.org/D31173
Differential Revision: https://reviews.llvm.org/D31174

llvm-svn: 298426
2017-03-21 19:33:32 +00:00
Simon Pilgrim 60e924985c [X86][AVX512] Add _mm512_cvtsd_f64 and _mm512_cvtss_f32 intrinsics (PR32305)
Differential Revision: https://reviews.llvm.org/D31155

llvm-svn: 298364
2017-03-21 12:46:13 +00:00
Igor Breger f050b797ac [X86][AVX512][Clang][Intrinsics] Adding missing intrinsics to Clang .
Summary:
Adding missing intrinsics :
    _mm512_set_epi16,
    _mm512_set_epi8,
    _mm512_permutevar_epi32
    _mm512_mask_permutevar_epi32

Reviewers: zvi, guyblank, eladcohen, craig.topper

Reviewed By: craig.topper

Subscribers: craig.topper, cfe-commits

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

llvm-svn: 298208
2017-03-19 08:27:16 +00:00
Nirav Dave 8497ef4086 [X86] Add NumRegisterParameters Module Flag.
Reviewers: rnk, mkuper

Subscribers: llvm-commits

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

llvm-svn: 298177
2017-03-18 00:43:39 +00:00
Craig Topper 208c80556c [AVX-512] Fix test cases that were using the builtins directly without typecasts instead of the intrinsic header.
llvm-svn: 298041
2017-03-17 05:59:22 +00:00
Simon Pilgrim 6c38e71476 [X86][XOP] Add codegen tests for vector integer comparison intrinsics (PR15844)
We were testing for the generic _mm_com_* intrinsics, but not the specific comparison mode versions.

llvm-svn: 297885
2017-03-15 20:20:43 +00:00
Sanjay Patel e795daa55e [x86] these aren't the undefs you're looking for (PR32176)
x86 has undef SSE/AVX intrinsics that should represent a bogus register operand. 
This is not the same as LLVM's undef value which can take on multiple bit patterns.

There are better solutions / follow-ups to this discussed here:
https://bugs.llvm.org/show_bug.cgi?id=32176
...but this should prevent miscompiles with a one-line code change.

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

llvm-svn: 297588
2017-03-12 19:15:10 +00:00
Petar Jovanovic bc97ab28a4 [mips][msa] Remove range checks for non-immediate sld.[bhwd] instructions
Removes immediate range checks for these instructions, since they have GPR
rt as their input operand.

Patch by Stefan Maksimovic.

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

llvm-svn: 297485
2017-03-10 17:51:01 +00:00
Roger Ferrer Ibanez 3fa38a14ac Honor __unaligned in codegen for declarations and expressions
This patch honors the unaligned type qualifier (currently available through he
keyword __unaligned and -fms-extensions) in CodeGen. In the current form the
patch affects declarations and expressions. It does not affect fields of
classes.

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

llvm-svn: 297276
2017-03-08 14:00:44 +00:00
Sanjay Patel 3a8ec02743 fix test to not check optimized IR; NFCI
This test broke with an LLVM instcombine patch (r297166).
I changed the RUN line to only run -mem2reg (to save time checking this large chunk of tests)
and updated the checks using the script attached to D17999:
https://reviews.llvm.org/D17999

The goal is to make this test immune to optimizer changes. If there's something in these
tests that was checking for an IR optimization, that should be tested in LLVM, not Clang.

llvm-svn: 297189
2017-03-07 19:24:54 +00:00
Reid Kleckner b04cb9ab7a [MS] Add support for __ud2 and __int2c MSVC intrinsics
This was requested in PR31958 and elsewhere.

llvm-svn: 297057
2017-03-06 19:43:16 +00:00
Dean Michael Berris 418da3fe80 [XRay] [clang] Allow logging the first argument of a function call.
Summary:
Functions with the "xray_log_args" attribute will tell LLVM to emit a special
XRay sled for compiler-rt to copy any call arguments to your logging handler.

Reviewers: dberris

Reviewed By: dberris

Subscribers: cfe-commits

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

llvm-svn: 296999
2017-03-06 07:08:21 +00:00
Erich Keane 2fe684bb14 Allow attributes before union definition
permits typedef union __attribute__((transparent_union)) {...}

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

llvm-svn: 296518
2017-02-28 20:44:39 +00:00
Vedant Kumar 42de380765 [ubsan] Detect signed overflow UB in remainder operations
Teach ubsan to diagnose remainder operations which have undefined
behavior due to signed overflow (e.g INT_MIN % -1).

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

llvm-svn: 296214
2017-02-25 00:43:39 +00:00
Vedant Kumar 82ee16beb8 [ubsan] Omit superflous overflow checks for promoted arithmetic (PR20193)
C requires the operands of arithmetic expressions to be promoted if
their types are smaller than an int. Ubsan emits overflow checks when
this sort of type promotion occurs, even if there is no way to actually
get an overflow with the promoted type.

This patch teaches clang how to omit the superflous overflow checks
(addressing PR20193).

Testing: check-clang and check-ubsan.

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

llvm-svn: 296213
2017-02-25 00:43:36 +00:00
Alex Lorenz e3e8131460 NFC, Add a test that ensure that we don't emit helper code in copy/dispose
routines for variables that are const-captured

This is a preparation commit that improves code-coverage in code that emits
block copy/dispose routines.

llvm-svn: 296040
2017-02-23 23:41:50 +00:00
George Burgess IV 0d6592a899 [CodeGen] Don't reemit expressions for pass_object_size params.
This fixes an assertion failure in cases where we had expression
statements that declared variables nested inside of pass_object_size
args. Since we were emitting the same ExprStmt twice (once for the arg,
once for the @llvm.objectsize call), we were getting issues with
redefining locals.

This also means that we can be more lax about when we emit
@llvm.objectsize for pass_object_size args: since we're reusing the
arg's value itself, we don't have to care so much about side-effects.

llvm-svn: 295935
2017-02-23 05:59:56 +00:00
George Burgess IV 8856aa9a54 Call the correct @llvm.objectsize.
The following code would crash clang:

void foo(unsigned *const __attribute__((pass_object_size(0))));
void bar(unsigned *i) { foo(i); }

This is because we were always selecting the version of
`@llvm.objectsize` that takes an i8* in CodeGen. Passing an i32* as an
i8* makes LLVM very unhappy.

(Yes, I'm surprised that this remained uncaught for so long, too. :) )

As an added bonus, we'll now also use the appropriate address space when
emitting @llvm.objectsize calls.

llvm-svn: 295805
2017-02-22 02:35:51 +00:00
Jacob Gravelle 40aefb5fe0 Declare lgamma library builtins as never being const
Summary:
POSIX requires lgamma writes to an external global variable, signgam.
This prevents annotating lgamma with readnone, which is incorrect on
targets that write to signgam.

Reviewers: efriedma, rsmith

Subscribers: cfe-commits

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

llvm-svn: 295781
2017-02-21 22:37:27 +00:00
Tim Shen d4ba2f2336 [XRay] Merge xray clang flag tests, and add powerpc64le.
Summary: I'm not sure why they were in different files, but it's kind of harder to maintain. I create this patch partially for initiate a discussion.

Reviewers: dberris

Subscribers: nemanjai, cfe-commits

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

llvm-svn: 295778
2017-02-21 22:30:00 +00:00
Craig Topper 117892098a [X86] Replace XOP vpcmov builtins with native vector logical operations.
llvm-svn: 295570
2017-02-18 21:15:30 +00:00
Vedant Kumar 34b1fd6aaa Retry^2: [ubsan] Reduce null checking of C++ object pointers (PR27581)
This patch teaches ubsan to insert exactly one null check for the 'this'
pointer per method/lambda.

Previously, given a load of a member variable from an instance method
('this->x'), ubsan would insert a null check for 'this', and another
null check for '&this->x', before allowing the load to occur.

Similarly, given a call to a method from another method bound to the
same instance ('this->foo()'), ubsan would a redundant null check for
'this'. There is also a redundant null check in the case where the
object pointer is a reference ('Ref.foo()').

This patch teaches ubsan to remove the redundant null checks identified
above.

Testing: check-clang, check-ubsan, and a stage2 ubsan build.

I also compiled X86FastISel.cpp with -fsanitize=null using
patched/unpatched clangs based on r293572. Here are the number of null
checks emitted:

  -------------------------------------
  | Setup          | # of null checks |
  -------------------------------------
  | unpatched, -O0 |            21767 |
  | patched, -O0   |            10758 |
  -------------------------------------

Changes since the initial commit:
- Don't introduce any unintentional object-size or alignment checks.
- Don't rely on IRGen of C labels in the test.

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

llvm-svn: 295515
2017-02-17 23:22:59 +00:00
Vedant Kumar 29ba8d9bfe Revert "Retry: [ubsan] Reduce null checking of C++ object pointers (PR27581)"
This reverts commit r295401. It breaks the ubsan self-host. It inserts
object size checks once per C++ method which fire when the structure is
empty.

llvm-svn: 295494
2017-02-17 20:59:40 +00:00
Vedant Kumar 55875b9955 Retry: [ubsan] Reduce null checking of C++ object pointers (PR27581)
This patch teaches ubsan to insert exactly one null check for the 'this'
pointer per method/lambda.

Previously, given a load of a member variable from an instance method
('this->x'), ubsan would insert a null check for 'this', and another
null check for '&this->x', before allowing the load to occur.

Similarly, given a call to a method from another method bound to the
same instance ('this->foo()'), ubsan would a redundant null check for
'this'. There is also a redundant null check in the case where the
object pointer is a reference ('Ref.foo()').

This patch teaches ubsan to remove the redundant null checks identified
above.

Testing: check-clang and check-ubsan. I also compiled X86FastISel.cpp
with -fsanitize=null using patched/unpatched clangs based on r293572.
Here are the number of null checks emitted:

  -------------------------------------
  | Setup          | # of null checks |
  -------------------------------------
  | unpatched, -O0 |            21767 |
  | patched, -O0   |            10758 |
  -------------------------------------

Changes since the initial commit: don't rely on IRGen of C labels in the
test.

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

llvm-svn: 295401
2017-02-17 02:03:51 +00:00
Vedant Kumar 4f94a94bea Revert "[ubsan] Reduce null checking of C++ object pointers (PR27581)"
This reverts commit r295391. It breaks this bot:

http://lab.llvm.org:8011/builders/clang-with-thin-lto-ubuntu/builds/1898

I need to not rely on labels in the IR test.

llvm-svn: 295396
2017-02-17 01:42:36 +00:00
Vedant Kumar 3e5a9a6be8 [ubsan] Reduce null checking of C++ object pointers (PR27581)
This patch teaches ubsan to insert exactly one null check for the 'this'
pointer per method/lambda.

Previously, given a load of a member variable from an instance method
('this->x'), ubsan would insert a null check for 'this', and another
null check for '&this->x', before allowing the load to occur.

Similarly, given a call to a method from another method bound to the
same instance ('this->foo()'), ubsan would a redundant null check for
'this'. There is also a redundant null check in the case where the
object pointer is a reference ('Ref.foo()').

This patch teaches ubsan to remove the redundant null checks identified
above.

Testing: check-clang and check-ubsan. I also compiled X86FastISel.cpp
with -fsanitize=null using patched/unpatched clangs based on r293572.
Here are the number of null checks emitted:

  -------------------------------------
  | Setup          | # of null checks |
  -------------------------------------
  | unpatched, -O0 |            21767 |
  | patched, -O0   |            10758 |
  -------------------------------------

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

llvm-svn: 295391
2017-02-17 01:05:42 +00:00
Craig Topper f0d1147fae [AVX-512] Replace 512-bit masked packss/packus builtins and replace with new unmasked builtins.
These new unmasked builtins will enable us to easily support optimizing these builtins in InstCombine in the backend.

llvm-svn: 295291
2017-02-16 06:32:07 +00:00
Evgeniy Stepanov 287b04b000 Add missing regexp quantifiers in a test.
llvm-svn: 295267
2017-02-16 01:35:23 +00:00
Sagar Thakur 9d0ed930ec [XRAY][MIPS] Add -fxray-instrument for mips/mipsel/mips64/mips64el
Summary: Adds xray instrument option for mips/mipsel/mips64/mips64el.

Reviewed by sdardis, dberris
Differential: D27698

llvm-svn: 295163
2017-02-15 10:41:38 +00:00
Reid Kleckner fb9f647e5f MS inline asm: Filter MXCSR out of the inferred clobber list
Since r295004, LLVM has started modelling this new register, but we
don't have GCC constraint inline asm spellings for it yet.

llvm-svn: 295107
2017-02-14 21:38:17 +00:00
Dylan McKay 315edb0216 [AVR] Fix __AVR_xxx macro definitions; authored by Peter Wu
Summary:
The -mmcu option for GCC sets macros like __AVR_ATmega328P__ (with the trailing
underscores), be sure to include these underscores for Clangs -mcpu option.

See "AVR Built-in Macros" in https://gcc.gnu.org/onlinedocs/gcc/AVR-Options.html

Reviewers: jroelofs, dylanmckay

Reviewed By: jroelofs, dylanmckay

Subscribers: efriedma, cfe-commits

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

llvm-svn: 294869
2017-02-11 21:06:07 +00:00
Richard Trieu f11ab87ba3 Move test include file from include/ to Inputs/
The Inputs/ directory is the recommended location for extra files for test
cases.  No functional change.

llvm-svn: 294815
2017-02-11 00:52:01 +00:00
George Burgess IV f9013bf8f0 Don't let EvaluationModes dictate whether an invalid base is OK
What we want to actually control this behavior is something more local
than an EvalutationMode. Please see the linked revision for more
discussion on why/etc.

This fixes PR31843.

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

llvm-svn: 294800
2017-02-10 22:52:29 +00:00
Eric Christopher f6ee1f3d69 Temporarily revert "For X86-64 linux and PPC64 linux align int128 to 16 bytes."
until we can get better TargetMachine::isCompatibleDataLayout to compare - otherwise
we can't code generate existing bitcode without a string equality data layout.

This reverts commit r294703.

llvm-svn: 294708
2017-02-10 04:35:21 +00:00
Eric Christopher 4855ba8f24 For X86-64 linux and PPC64 linux align int128 to 16 bytes.
For other platforms we should find out what they need and likely
make the same change, however, a smaller additional change is easier
for platforms we know have it specified in the ABI.

clang support for r294702

llvm-svn: 294703
2017-02-10 03:32:34 +00:00
Amjad Aboud 546bc1103b [DebugInfo] Added support to Clang FE for generating debug info for preprocessor macros.
Added "-fdebug-macro" flag (and "-fno-debug-macro" flag) to enable (and to disable) emitting macro debug info.
Added CC1 "-debug-info-macro" flag that enables emitting macro debug info.

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

llvm-svn: 294637
2017-02-09 22:07:24 +00:00
Reid Kleckner 04f9f91da6 [MS] Implement the __fastfail intrinsic as a builtin
__fastfail terminates the process immediately with a special system
call. It does not run any process shutdown code or exception recovery
logic.

Fixes PR31854

llvm-svn: 294606
2017-02-09 18:31:06 +00:00
Craig Topper 41cb8ffcc1 [X86] Fix copy and paste bug in clzero test from r294559.
llvm-svn: 294560
2017-02-09 06:22:43 +00:00
Craig Topper 4574226c3f [X86] Clzero flag addition and inclusion under znver1
1. Adds the command line flag for clzero.
2. Includes the clzero flag under znver1.
3. Defines the macro for clzero.
4. Adds a new file which has the intrinsic definition for clzero instruction.

Patch by Ganesh Gopalasubramanian with some additional tests from me.

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

llvm-svn: 294559
2017-02-09 06:10:14 +00:00
Dylan McKay e8232d73f5 [AVR] Add support for the 'interrupt' and 'naked' attributes
Summary:
This teaches clang how to parse and lower the 'interrupt' and 'naked'
attributes.

This allows interrupt signal handlers to be written.

Reviewers: aaron.ballman

Subscribers: malcolm.parsons, cfe-commits

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

llvm-svn: 294402
2017-02-08 05:09:26 +00:00
Dylan McKay ecb6e7b83c Revert "Revert "[AVR] Allow specifying the CPU on the command line""
This reverts commit 7ac30e0f839fdab6d723ce2ef6a5b7a4cf03d150.

llvm-svn: 294282
2017-02-07 06:04:18 +00:00
Diana Picus 37a2d6d699 Revert "[AVR] Allow specifying the CPU on the command line"
This reverts commit r294177. It seems to have broken some buildbots.

llvm-svn: 294180
2017-02-06 11:35:42 +00:00
Dylan McKay 8464c9b579 [AVR] Allow specifying the CPU on the command line
Summary:
This tells clang about all of the different AVR microcontrollers.

It also adds code to define the correct preprocessor macros for each
device.

Reviewers: jroelofs, asl

Reviewed By: asl

Subscribers: asl, cfe-commits

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

llvm-svn: 294177
2017-02-06 09:07:56 +00:00
Dylan McKay d31534cd3a [AVR] Add support for the full set of inline asm constraints
Summary:
Previously the method would simply return false, causing every single
inline assembly constraint to trigger a compile error.

This adds inline assembly constraint support for the AVR target.

This patch is derived from the code in
AVRISelLowering::getConstraintType.

More details can be found on the AVR-GCC reference wiki
http://www.nongnu.org/avr-libc/user-manual/inline_asm.html

Reviewers: jroelofs, asl

Reviewed By: asl

Subscribers: asl, ahatanak, saaadhu, cfe-commits

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

llvm-svn: 294176
2017-02-06 09:01:59 +00:00
Coby Tayree c0fb36f442 [X86][MS]Adjacent comments within multi-line inline assembly statement
Allowing adjacent comments within MS inline assembly multi-line statement

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

llvm-svn: 294120
2017-02-05 10:23:06 +00:00
Sanjay Patel 3bd28f85d5 [x86] fix tests with wrong dependency to pass because they broke with r294049
llvm-svn: 294058
2017-02-03 22:03:47 +00:00
Davide Italiano 8236b73dee [CodeGen] Update test after recent changes in llvm (r293846).
llvm-svn: 293848
2017-02-02 00:47:53 +00:00
Davide Italiano 0449607738 [CodeGen] Update test after recent changes in llvm (r293799).
llvm-svn: 293810
2017-02-01 20:43:28 +00:00
Nirav Dave 0c86ccf4b4 [X86] Teach Clang about -mfentry flag
Replace mcount calls with calls to fentry.

Reviewers: hfinkel, craig.topper

Subscribers: llvm-commits

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

llvm-svn: 293649
2017-01-31 17:00:35 +00:00
Vedant Kumar d3a601b06b Re-apply "[ubsan] Sanity-check shift amounts before truncation"
This re-applies r293343 (reverts commit r293475) with a fix for an
assertion failure caused by a missing integer cast. I tested this patch
by using the built compiler to compile X86FastISel.cpp.o with ubsan.

Original commit message:

Ubsan does not report UB shifts in some cases where the shift exponent
needs to be truncated to match the type of the shift base. We perform a
range check on the truncated shift amount, leading to false negatives.

Fix the issue (PR27271) by performing the range check on the original
shift amount.

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

llvm-svn: 293572
2017-01-30 23:38:54 +00:00
Alex Lorenz 94c26be581 Revert "r293343 - [ubsan] Sanity-check shift amounts before truncation
(fixes PR27271)"

After r293343 clang fails to compile itself with -fsanitize=undefined (
http://lab.llvm.org:8080/green/job/clang-stage2-cmake-RgSan_build/).

rdar://30259929

llvm-svn: 293475
2017-01-30 11:37:18 +00:00
Vedant Kumar 3db9974b2d [ubsan] Sanity-check shift amounts before truncation (fixes PR27271)
Ubsan does not report UB shifts in some cases where the shift exponent
needs to be truncated to match the type of the shift base. We perform a
range check on the truncated shift amount, leading to false negatives.

Fix the issue (PR27271) by performing the range check on the original
shift amount.

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

llvm-svn: 293343
2017-01-27 23:02:44 +00:00
Peter Collingbourne 7af93e31fe Add missing x86 requirement.
llvm-svn: 293210
2017-01-26 21:38:48 +00:00
Peter Collingbourne f5d1712189 IRGen: When loading the main module in the distributed ThinLTO backend, look for the module containing the summary.
Differential Revision: https://reviews.llvm.org/D29067

llvm-svn: 293209
2017-01-26 21:09:48 +00:00
Adam Nemet 1a89f25b6e Further fixes to test from r293146
Require aarch64 and avoid filename in YAML since it may require quotation.

llvm-svn: 293149
2017-01-26 04:34:07 +00:00
Adam Nemet 3071266f6f Fix test from r293146
llvm-svn: 293147
2017-01-26 04:14:04 +00:00
Adam Nemet 7b796f825b Support MIR opt-remarks with -fsave-optimization-record
The handler that deals with IR passed/missed/analysis remarks is extended to
also handle the corresponding MIR remarks.

The more thorough testing in done via llc (rL293113, rL293121).  Here we just
make sure that the functionality is accessible through clang.

llvm-svn: 293146
2017-01-26 04:07:11 +00:00
Akira Hatanaka 151d339125 Fix test case committed in r293106 so that it passes on targets whose
pointers are 4-bytes instead of 8-bytes.

llvm-svn: 293111
2017-01-25 23:36:15 +00:00
Akira Hatanaka cb904604c9 Remove the return type from the check string in test case.
Bots were failing because some targets emit signext before i32.

llvm-svn: 293108
2017-01-25 23:16:32 +00:00
Akira Hatanaka fdcd18b4c9 [CodeGen] Suppress emission of lifetime markers if a label has been seen
in the current lexical scope.

clang currently emits the lifetime.start marker of a variable when the
variable comes into scope even though a variable's lifetime starts at
the entry of the block with which it is associated, according to the C
standard. This normally doesn't cause any problems, but in the rare case
where a goto jumps backwards past the variable declaration to an earlier
point in the block (see the test case added to lifetime2.c), it can
cause mis-compilation.

To prevent such mis-compiles, this commit conservatively disables
emitting lifetime variables when a label has been seen in the current
block.

This problem was discussed on cfe-dev here: 
http://lists.llvm.org/pipermail/cfe-dev/2016-July/050066.html

rdar://problem/30153946

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

llvm-svn: 293106
2017-01-25 22:55:13 +00:00
Tim Shen fd1e5aa8df [APFloat] Switch from (PPCDoubleDoubleImpl, IEEEdouble) layout to (IEEEdouble, IEEEdouble)
Summary:
This patch changes the layout of DoubleAPFloat, and adjust all
operations to do either:
1) (IEEEdouble, IEEEdouble) -> (uint64_t, uint64_t) -> PPCDoubleDoubleImpl,
   then run the old algorithm.
2) Do the right thing directly.

1) includes multiply, divide, remainder, mod, fusedMultiplyAdd, roundToIntegral,
   convertFromString, next, convertToInteger, convertFromAPInt,
   convertFromSignExtendedInteger, convertFromZeroExtendedInteger,
   convertToHexString, toString, getExactInverse.
2) includes makeZero, makeLargest, makeSmallest, makeSmallestNormalized,
   compare, bitwiseIsEqual, bitcastToAPInt, isDenormal, isSmallest,
   isLargest, isInteger, ilogb, scalbn, frexp, hash_value, Profile.

I could split this into two patches, e.g. use
1) for all operatoins first, then incrementally change some of them to
2). I didn't do that, because 1) involves code that converts data between
PPCDoubleDoubleImpl and (IEEEdouble, IEEEdouble) back and forth, and may
pessimize the compiler. Instead, I find easy functions and use
approach 2) for them directly.

Next step is to implement move multiply and divide from 1) to 2). I don't
have plans for other functions in 1).

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

llvm-svn: 292839
2017-01-23 22:39:35 +00:00
Tim Shen 867be0d14c [Altivec] Change vec_sl to a << (b % (sizeof(a) * 8))
For a << b (as original vec_sl does), if b >= sizeof(a) * 8, the
behavior is undefined. However, Power instructions do define the
behavior, which is equivalent to a << (b % (sizeof(a) * 8)).

This patch changes altivec.h to use a << (b % (sizeof(a) * 8)), to
ensure the consistent semantic of the instructions. Then it combines
the generated multiple instructions back to a single shift.

This patch handles left shift only. Right shift, on the other hand, is
more complicated, considering arithematic/logical right shift.

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

llvm-svn: 292659
2017-01-20 22:05:33 +00:00
Craig Topper 367c86ddbe [AVX-512] Replace subvector broadcast builtins with shufflevectors and selects.
Verified that the backend codegens this equally well.

llvm-svn: 292329
2017-01-18 02:17:10 +00:00
Dan Gohman 0c5954195b [WebAssembly] Update grow_memory's return type.
The grow_memory instruction now returns the previous memory size. Add the
return type to the clang intrinsic.

llvm-svn: 292324
2017-01-18 01:03:35 +00:00
Dehao Chen 1ef69d8eb0 Temporarily revert the test change in 291870, which is broken in certain buildbots.
llvm-svn: 291874
2017-01-13 01:09:43 +00:00
Dehao Chen a1bd2d6585 Pass -fprofile-sample-use to lto backends.
Summary: LTO backend will not invoke SampleProfileLoader pass even if -fprofile-sample-use is specified. This patch passes the flag down so that pass manager can add the SampleProfileLoader pass correctly.

Reviewers: mehdi_amini, tejohnson

Subscribers: cfe-commits

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

llvm-svn: 291870
2017-01-13 00:51:55 +00:00
Anna Zaks e43b4fc0ae [tsan] Do not report errors in __destroy_helper_block_
There is a synchronization point between the reference count of a block dropping to zero and it's destruction, which TSan does not observe. Do not report errors in the compiler-emitted block destroy method and everything called from it.

This is similar to https://reviews.llvm.org/D25857

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

llvm-svn: 291868
2017-01-13 00:50:50 +00:00
Chandler Carruth 9d25111a4a Fix two test cases I missed updating in r291850. Sorry for the noise.
llvm-svn: 291853
2017-01-12 22:48:28 +00:00
Chandler Carruth 7e8283ae6b Replace some stray uses of the old spelling of the flag with the new
spelling. NFC.

llvm-svn: 291851
2017-01-12 22:43:37 +00:00
Eli Friedman 6503f24da8 Add additional testcases for nsw markings on ++ and --.
clang has generated correct IR for char/short decrement since r126816,
but we didn't have any test coverage for decrement.

Patch by Andrew Rogers.

llvm-svn: 291805
2017-01-12 19:51:44 +00:00
Dehao Chen 37c79c236d Revert r291774 which caused buildbot failure.
llvm-svn: 291775
2017-01-12 16:56:18 +00:00
Dehao Chen bd3689de91 Pass -fprofile-sample-use to lto backends.
Summary: LTO backend will not invoke SampleProfileLoader pass even if -fprofile-sample-use is specified. This patch passes the flag down so that pass manager can add the SampleProfileLoader pass correctly.

Reviewers: mehdi_amini, tejohnson

Subscribers: cfe-commits

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

llvm-svn: 291774
2017-01-12 16:29:25 +00:00
Tony Jiang 974e4c7899 [PowerPC] Fix the wrong implementation of builtin vec_rlnm.
llvm-svn: 291702
2017-01-11 20:59:42 +00:00
Chad Rosier c22abb3820 [ARM] Use generic bitreverse intrinsic, rather than ARM specific rbit.
The backend already supports lowering this intrinsic to a rbit instruction.

llvm-svn: 291582
2017-01-10 18:55:11 +00:00
Chad Rosier 5a4a1be690 [AArch64] Use generic bitreverse intrinsic, rather than AArch64 specific.
Differential Revision: https://reviews.llvm.org/D28400

llvm-svn: 291574
2017-01-10 17:20:28 +00:00
Teresa Johnson a8b5558f9c [ThinLTO] Specify target triple in new test
This should fix bot failures in this test.

llvm-svn: 291310
2017-01-07 00:09:42 +00:00
Teresa Johnson cffeb54fc9 [ThinLTO] Optionally ignore empty index file
Summary:
In order to simplify distributed build system integration, where actions
may be scheduled before the Thin Link which determines the list of
objects selected by the linker. The gold plugin currently will emit
0-sized index files for objects not selected by the link, to enable
checking for expected output files by the build system. If the build
system then schedules a backend action for these bitcode files, we want
to be able to fall back to normal compilation instead of failing.

Fallback is enabled under an option in LLVM (D28410), in which case a
nullptr is returned from llvm::getModuleSummaryIndexForFile. Clang can
just proceed with non-ThinLTO compilation in that case.

I am investigating whether this can be addressed in our build system,
but that is a longer term fix and so this enables a workaround in the
meantime.

Reviewers: mehdi_amini

Subscribers: cfe-commits

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

llvm-svn: 291303
2017-01-06 23:37:33 +00:00
Mehdi Amini 7f873070c4 Add a cc1 option to force disabling lifetime-markers emission from clang
Summary: This intended as a debugging/development flag only.

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

llvm-svn: 291300
2017-01-06 23:18:09 +00:00
Filipe Cabecinhas fe5e5afd53 [ubsan] Minimize size of data for type_mismatch (Redo of D19667)
Summary:
This patch makes the type_mismatch static data 7 bytes smaller (and it
ends up being 16 bytes smaller due to alignment restrictions, at least
on some x86-64 environments).

It revs up the type_mismatch handler version since we're breaking binary
compatibility. I will soon post a patch for the compiler-rt side.

Reviewers: rsmith, kcc, vitalybuka, pgousseau, gbedwell

Subscribers: llvm-commits

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

llvm-svn: 291236
2017-01-06 14:40:12 +00:00
Saleem Abdulrasool 3f4ab5c0c6 CodeGen: address post commit review comments for r291123
This test would force the execution of the backend.  However, the
backend already has a test for this.  Effectively, this was trying to
test that an API call was made properly.  We do not have a good way to
really test this.  The test itself tested very little.

Addresses post-commit review comments from Eric Christopher.

llvm-svn: 291208
2017-01-06 02:27:40 +00:00
Sean Fertile 222626564d Remove the ppc insertword/extractword expected fail tests.
llvm-svn: 291188
2017-01-05 22:54:34 +00:00
Sean Fertile 96d9e0ec05 Add vec_insert4b and vec_extract4b functions to altivec.h
Add builtins for the functions and custom codegen mapping the builtins to their
corresponding intrinsics and handling the endian related swapping.

https://reviews.llvm.org/D26546

llvm-svn: 291179
2017-01-05 21:43:30 +00:00
Saleem Abdulrasool 16a6efe43d test: add a requires registered target
It seems that the ARM buildbots do not include x86 support.  However,
other x86 targets do not support the ARM target.  Use a x86 triple and
require the registered target.

llvm-svn: 291142
2017-01-05 17:09:20 +00:00
Saleem Abdulrasool 7bf88b3c1f test: add an explicit triple
Not all targets use the integrated assembler.  Specify a triple to
ensure we use the integrated as for this.

llvm-svn: 291125
2017-01-05 16:36:15 +00:00
Saleem Abdulrasool 888e289ed7 CodeGen: plumb header search down to the IAS
inline assembly may use the `.include` directive to include other
content into the file.  Without the integrated assembler, the `-I` group
gets passed to the assembler.  Emulate this by collecting the header
search paths and passing them to the IAS.

Resolves PR24811!

llvm-svn: 291123
2017-01-05 16:02:32 +00:00
Erich Keane 521ed960ed Correct Vectorcall Register passing and HVA Behavior
Front end component (back end changes are D27392).  The vectorcall 
calling convention was broken subtly in two cases.  First, 
it didn't properly handle homogeneous vector aggregates (HVAs). 
Second, the vectorcall specification requires that only the 
first 6 parameters be eligible for register assignment. 
This patch fixes both issues.

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

llvm-svn: 291041
2017-01-05 00:20:51 +00:00
George Burgess IV 7fb7e361bf Re-add objectsize function/incomplete type checks.
I accidentally omitted these when refactoring this code. This caused
problems when building parts of the test-suite on MacOS.

llvm-svn: 290916
2017-01-03 23:35:19 +00:00
Reid Kleckner 9bb64de0de Relax CHECK line from r290906
llvm-svn: 290907
2017-01-03 21:29:51 +00:00
Reid Kleckner d2ad9dfdb9 [Win64] Don't widen integer literal zero arguments to unprototyped function calls
The special case to widen the integer literal zero when passed to
variadic function calls should only apply to variadic functions, not
unprototyped functions. This is consistent with what MSVC does. In this
test case, MSVC uses a 4-byte store to pass the 5th argument to 'kr' and
an 8-byte store to pass the zero to 'v':

  void v(int, ...);
  void kr();
  void f(void) {
    v(1, 2, 3, 4, 0);
    kr(1, 2, 3, 4, 0);
  }

Aaron Ballman discovered this issue in https://reviews.llvm.org/D28166

llvm-svn: 290906
2017-01-03 21:23:35 +00:00
Teresa Johnson 3f4c87d0b5 [ThinLTO] Add missing FileCheck invocation
One of the intended checks was not being performed.

llvm-svn: 290671
2016-12-28 16:45:37 +00:00
George Burgess IV 1a39b86d0f [CodeGen] Unique constant CompoundLiterals.
Our newly aggressive constant folding logic makes it possible for
CGExprConstant to see the same CompoundLiteralExpr more than once. So,
emitting a new GlobalVariable every time we see a CompoundLiteral is no
longer correct.

We had a similar issue with BlockExprs that was caught while testing
said aggressive folding, so I applied the same style of fix (see D26410)
here. If we find yet another case where this needs to happen, we should
probably refactor this so we don't have a third DenseMap+getter+setter.

As a design note: getAddrOfConstantCompoundLiteralIfEmitted is really
only intended to be called by ConstExprEmitter::EmitLValue. So,
returning a GlobalVariable* instead of a ConstantAddress costs us
effectively nothing, and saves us either a few bytes per entry in our
map or a bit of code duplication.

llvm-svn: 290661
2016-12-28 07:27:40 +00:00
Michael Kuperstein 071345178b Update test that relies on the optimizer to match new output.
llvm-svn: 290642
2016-12-28 00:30:43 +00:00
Craig Topper 70536f4e47 [AVX-512] Replace masked 512-bit pmuldq and pmuludq builtins with the newly added unmasked versions and selects.
llvm-svn: 290580
2016-12-27 04:04:57 +00:00
Craig Topper c5ab78d4c3 Revert r290575 "[AVX-512] Replace masked 512-bit pmuldq and pmuludq builtins with the newly added unmasked versions and selects."
I failed to merge this with r290574.

llvm-svn: 290578
2016-12-27 04:03:25 +00:00
Craig Topper 6ad5bcc8ac [AVX-512] Replace masked 512-bit pmuldq and pmuludq builtins with the newly added unmasked versions and selects.
llvm-svn: 290575
2016-12-27 03:46:16 +00:00
Chandler Carruth 88c4ffb4e0 [PM] The new pass manager requires a registered target for these, and
given that they hard code specific triples that seems reasonable so add
the REQUIRES.

llvm-svn: 290560
2016-12-27 00:31:34 +00:00
Chandler Carruth 6d1b83ef87 [PH] Teach the new PM code path to support -disable-llvm-passes.
This is kind of funny because I specifically did work to make this easy
and then it didn't actually get implemented.

I've also ported a set of tests that rely on this functionality to run
with the new PM as well as the old PM so that we don't mess this up in
the future.

llvm-svn: 290558
2016-12-27 00:13:09 +00:00
Amjad Aboud e2aab8c30c [DebugInfo] Added support for Checksum debug info feature.
Differential Revision: https://reviews.llvm.org/D27641

llvm-svn: 290515
2016-12-25 10:12:27 +00:00
Chandler Carruth b322d1e6f0 [PM] Fix up from r290449 to start requiring the x86 target to be
available.

It doesn't seem terribly important to test this with a specific target
triple but without that target available.

llvm-svn: 290451
2016-12-23 21:19:16 +00:00