]> granicus.if.org Git - clang/log
clang
6 years ago[analyzer] [NFC] Remove unused Extensive diagnostic setting,
George Karpenkov [Tue, 12 Jun 2018 19:07:41 +0000 (19:07 +0000)]
[analyzer] [NFC] Remove unused Extensive diagnostic setting,

Rename AlternateExtensive to Extensive.
In 2013, five years ago, we have switched to AlternateExtensive
diagnostics by default, and Extensive was available under unused,
undocumented flag.
This change remove the flag, renames the Alternate
diagnostic to Extensive (as it's no longer Alternate), and ports the
test.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@334524 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoRefactor ExecuteAndWait to take StringRefs.
Zachary Turner [Tue, 12 Jun 2018 17:43:52 +0000 (17:43 +0000)]
Refactor ExecuteAndWait to take StringRefs.

This simplifies some code which had StringRefs to begin with, and
makes other code more complicated which had const char* to begin
with.

In the end, I think this makes for a more idiomatic and platform
agnostic API.  Not all platforms launch process with null terminated
c-string arrays for the environment pointer and argv, but the api
was designed that way because it allowed easy pass-through for
posix-based platforms.  There's a little additional overhead now
since on posix based platforms we'll be takign StringRefs which
were constructed from null terminated strings and then copying
them to null terminate them again, but from a readability and
usability standpoint of the API user, I think this API signature
is strictly better.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@334518 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[clang-format] Discourage breaks in submessage entries, hard rule
Krasimir Georgiev [Tue, 12 Jun 2018 17:26:31 +0000 (17:26 +0000)]
[clang-format] Discourage breaks in submessage entries, hard rule

Summary:
Currently clang-format allows this for text protos:
```
submessage:
    { key: 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' }
```
when it is under the column limit and when putting it all on one line exceeds the column limit.

This is not a very intuitive formatting, so I'd prefer having
```
submessage: {
  key: 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'
}
```
instead, even if it takes one line more.

This patch prevents clang-format from inserting a break between `: {` and similar cases.

Reviewers: djasper, sammccall

Reviewed By: sammccall

Subscribers: cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@334517 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoFix overload resolution between Ptr-To-Member and Bool
Erich Keane [Tue, 12 Jun 2018 13:59:32 +0000 (13:59 +0000)]
Fix overload resolution between Ptr-To-Member and Bool

As reported here (https://bugs.llvm.org/show_bug.cgi?id=19808)
and discovered independently when looking at plum-hall tests,
we incorrectly implemented over.ics.rank, which says "A conversion
that is not a conversion of a pointer, or pointer to member, to bool
is better than another conversion that is such a conversion.".

In the current Draft (N4750), this is phrased slightly differently in
paragraph 4.1: A conversion that does not convert a pointer, a pointer
to member, or std::nullptr_t to bool is better than one that does.

The comment on isPointerConversionToBool (the changed function)
also confirms that this is the case (note outdated reference):
isPointerConversionToBool - Determines whether this conversion is
a conversion of a pointer or pointer-to-member to bool. This is
used as part of the ranking of standard conversion sequences
(C++ 13.3.3.2p4).

However, despite this comment, it didn't check isMemberPointerType
on the 'FromType', presumably incorrectly assuming that 'isPointerType'
matched it.  This patch fixes this by adding isMemberPointerType to
this function. Additionally, member function pointers are just
MemberPointerTypes that point to functions insted of data, so that
is fixed in this patch as well.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@334503 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoRe-apply r334418 "Enable crash recovery tests on Windows, globs work in the lit inter...
Hans Wennborg [Tue, 12 Jun 2018 11:51:22 +0000 (11:51 +0000)]
Re-apply r334418 "Enable crash recovery tests on Windows, globs work in the lit internal shell now"

Plus change run lines from

  not env FOO=bar %clang

to

  env FOO=bar not %clang

To not confuse the internal shell.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@334494 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoRevert r334418 "Enable crash recovery tests on Windows, globs work in the lit interna...
Hans Wennborg [Tue, 12 Jun 2018 11:33:44 +0000 (11:33 +0000)]
Revert r334418 "Enable crash recovery tests on Windows, globs work in the lit internal shell now"

The tests fail on Windows bots, and for me locally.

> Enable crash recovery tests on Windows, globs work in the lit internal shell now

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@334493 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[AArch64] Corrected FP16 Intrinsic range checks in Clang + added Sema tests
Luke Geeson [Tue, 12 Jun 2018 09:54:27 +0000 (09:54 +0000)]
[AArch64] Corrected FP16 Intrinsic range checks in Clang + added Sema tests

Summary:
This fixes the ranges for the vcvth family of FP16 intrinsics in the clang front end. Previously it was accepting incorrect ranges
-Changed builtin range checking in SemaChecking
-added tests SemaCheck changes - included in  their own file since no similar one exists
-modified existing tests to reflect new ranges

Reviewers: SjoerdMeijer, javed.absar

Reviewed By: SjoerdMeijer

Subscribers: kristof.beyls, cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@334489 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoFix that AlignedAllocation.h doesn't compile because of VersionTuple
Raphael Isemann [Tue, 12 Jun 2018 03:43:21 +0000 (03:43 +0000)]
Fix that AlignedAllocation.h doesn't compile because of VersionTuple

Summary:
 rL334399 put VersionTuple in the llvm namespace, but this header still assumes it's in the clang namespace.
This leads to compilation failures with enabled modules when building Clang.

Subscribers: cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@334471 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[CUDA][HIP] Set kernel calling convention before arrange function
Yaxun Liu [Tue, 12 Jun 2018 00:16:33 +0000 (00:16 +0000)]
[CUDA][HIP] Set kernel calling convention before arrange function

Currently clang set kernel calling convention for CUDA/HIP after
arranging function, which causes incorrect kernel function type since
it depends on calling convention.

This patch moves setting kernel convention before arranging
function.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@334457 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[CMake] Use libc++ and compiler-rt for bootstrap Fuchsia Clang
Petr Hosek [Mon, 11 Jun 2018 22:06:44 +0000 (22:06 +0000)]
[CMake] Use libc++ and compiler-rt for bootstrap Fuchsia Clang

We want to build the second stage compiler with libc++ and compiler-rt,
also include builtins and runtimes into extra bootstrap components to
ensure these get built.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@334445 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[CMake] Allow specifying extra dependencies of bootstrap stage
Petr Hosek [Mon, 11 Jun 2018 20:59:31 +0000 (20:59 +0000)]
[CMake] Allow specifying extra dependencies of bootstrap stage

This allows adding additional bootstrap dependencies to the bootstrap
compiler that may be needed by later stages.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@334437 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[X86] Fix operand order in the shuffle created for blend builtins.
Craig Topper [Mon, 11 Jun 2018 17:06:01 +0000 (17:06 +0000)]
[X86] Fix operand order in the shuffle created for blend builtins.

This was broken when the builtin was added in r334249.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@334422 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[clang-fuzzer] Modified protobuf and converter to add new signature, remove conditionals.
Matt Morehouse [Mon, 11 Jun 2018 17:05:45 +0000 (17:05 +0000)]
[clang-fuzzer] Modified protobuf and converter to add new signature, remove conditionals.

Changed the function signature and removed conditionals from loop body.

Patch By:  emmettneyman

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@334421 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoEnable crash recovery tests on Windows, globs work in the lit internal shell now
Reid Kleckner [Mon, 11 Jun 2018 16:50:07 +0000 (16:50 +0000)]
Enable crash recovery tests on Windows, globs work in the lit internal shell now

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@334418 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[MS] Use mangled names and comdats for string merging with ASan
Reid Kleckner [Mon, 11 Jun 2018 16:49:43 +0000 (16:49 +0000)]
[MS] Use mangled names and comdats for string merging with ASan

This should reduce the binary size penalty of ASan on Windows. After
r334313, ASan will add red zones to globals in comdats, so we will still
find OOB accesses to string literals.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@334417 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[X86] Properly account for the immediate being multiplied by 8 in the immediate range...
Craig Topper [Mon, 11 Jun 2018 16:34:10 +0000 (16:34 +0000)]
[X86] Properly account for the immediate being multiplied by 8 in the immediate range checking for BI__builtin_ia32_psrldqi128 and friends.

The limit was set to 1023 which only up to 127*8. It needs to be 2047 to allow 255*8.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@334416 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoclang-format: [JS] strict prop init annotation.
Martin Probst [Mon, 11 Jun 2018 16:20:13 +0000 (16:20 +0000)]
clang-format: [JS] strict prop init annotation.

Summary:
TypeScript uses the `!` token for strict property initialization
assertions, as in:

    class X {
      strictPropAsserted!: string;
    }

Previously, clang-format would wrap between the `!` and the `:` for
overly long lines. This patch fixes that by generally preventing the
wrap in that location.

Reviewers: krasimir

Subscribers: cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@334415 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[Driver] Add aliases for -Qn/-Qy
Mikhail Maltsev [Mon, 11 Jun 2018 16:10:06 +0000 (16:10 +0000)]
[Driver] Add aliases for -Qn/-Qy

This patch adds aliases for -Qn (-fno-ident) and -Qy (-fident) which
look less cryptic than -Qn/-Qy. The aliases are compatible with GCC.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@334414 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoclang-format: Introduce BreakInheritanceList option
Francois Ferrand [Mon, 11 Jun 2018 14:41:26 +0000 (14:41 +0000)]
clang-format: Introduce BreakInheritanceList option

Summary:
This option replaces the BreakBeforeInheritanceComma option with an
enum, thus introducing a mode where the colon stays on the same line as
constructor declaration:

  // When it fits on line:
  class A : public B, public C {
    ...
  };

  // When it does not fit:
  class A :
      public B,
      public C {
    ...
  };

This matches the behavior of the `BreakConstructorInitializers` option,
introduced in https://reviews.llvm.org/D32479.

Reviewers: djasper, klimek

Reviewed By: djasper

Subscribers: mzeren-vmw, cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@334408 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[clang-format] text protos: put entries on separate lines if there is a submessage
Krasimir Georgiev [Mon, 11 Jun 2018 12:53:25 +0000 (12:53 +0000)]
[clang-format] text protos: put entries on separate lines if there is a submessage

Summary:
This patch updates clang-format text protos to put entries of a submessage into separate lines if the submessage contains at least two entries and contains at least one submessage entry.

For example, the entries here are kept on separate lines even if putting them on a single line would be under the column limit:
```
message: {
  entry: 1
  submessage: { key: value }
}
```

Messages containing a single submessage or several scalar entries can still be put on one line if they fit:
```
message { submessage { key: value } }
message { x: 1 y: 2 z: 3 }
```

Reviewers: sammccall

Reviewed By: sammccall

Subscribers: klimek, cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@334401 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoMove VersionTuple from clang/Basic to llvm/Support
Pavel Labath [Mon, 11 Jun 2018 10:28:04 +0000 (10:28 +0000)]
Move VersionTuple from clang/Basic to llvm/Support

Summary:
This kind of functionality is useful to other project apart from clang.
LLDB works with version numbers a lot, but it does not have a convenient
abstraction for this. Moving this class to a lower level library allows
it to be freely used within LLDB.

Since this class is used in a lot of places in clang, and it used to be
in the clang namespace, it seemed appropriate to add it to the list of
adopted classes in LLVM.h to avoid prefixing all uses with "llvm::".

Also, I didn't find any tests specific for this class, so I wrote a
couple of quick ones for the more interesting bits of functionality.

Reviewers: zturner, erik.pilkington

Subscribers: mgorny, cfe-commits, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@334399 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[MS ABI] Mangle unnamed empty enums (PR37723)
Hans Wennborg [Mon, 11 Jun 2018 06:54:23 +0000 (06:54 +0000)]
[MS ABI] Mangle unnamed empty enums (PR37723)

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@334388 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[X86] Remove masking from dbpsadbw builtins, use select builtin instead.
Craig Topper [Mon, 11 Jun 2018 06:18:29 +0000 (06:18 +0000)]
[X86] Remove masking from dbpsadbw builtins, use select builtin instead.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@334385 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[X86] Use target independent masked expandload and compressstore intrinsics to implem...
Craig Topper [Sun, 10 Jun 2018 17:27:05 +0000 (17:27 +0000)]
[X86] Use target independent masked expandload and compressstore intrinsics to implement expandload/compressstore builtins.

Summary: We've had these target independent intrinsics for at least a year and a half. Looks like they do exactly what we need here and the backend already supports them.

Reviewers: RKSimon, delena, spatel, GBuella

Reviewed By: RKSimon

Subscribers: cfe-commits, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@334366 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[NEON] Support VST1xN intrinsics in AArch32 mode (Clang part)
Ivan A. Kosarev [Sun, 10 Jun 2018 09:28:10 +0000 (09:28 +0000)]
[NEON] Support VST1xN intrinsics in AArch32 mode (Clang part)

We currently support them only in AArch64. The NEON Reference,
however, says they are 'ARMv7, ARMv8' intrinsics.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@334362 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[X86] Remove masking from the 512-bit packed floating point add/sub/mul/div builtins...
Craig Topper [Sun, 10 Jun 2018 06:01:42 +0000 (06:01 +0000)]
[X86] Remove masking from the 512-bit packed floating point add/sub/mul/div builtins. Use select in IR instead.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@334359 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[analyzer] Clean up the program state map of DanglingInternalBufferChecker.
Reka Kovacs [Sat, 9 Jun 2018 21:08:27 +0000 (21:08 +0000)]
[analyzer] Clean up the program state map of DanglingInternalBufferChecker.

Symbols are cleaned up from the program state map when they go out of scope.
Memory regions are cleaned up when the corresponding object is destroyed, and
additionally in 'checkDeadSymbols' in case destructor modeling was incomplete.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@334352 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[analyzer] Add dangling internal buffer check.
Reka Kovacs [Sat, 9 Jun 2018 13:03:49 +0000 (13:03 +0000)]
[analyzer] Add dangling internal buffer check.

This check will mark raw pointers to C++ standard library container internal
buffers 'released' when the objects themselves are destroyed. Such information
can be used by MallocChecker to warn about use-after-free problems.

In this first version, 'std::basic_string's are supported.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@334348 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoUse SmallPtrSet instead of SmallSet in places where we iterate over the set.
Craig Topper [Sat, 9 Jun 2018 00:30:45 +0000 (00:30 +0000)]
Use SmallPtrSet instead of SmallSet in places where we iterate over the set.

SmallSet forwards to SmallPtrSet for pointer types. SmallPtrSet supports iteration, but a normal SmallSet doesn't. So if it wasn't for the forwarding, this wouldn't work.

These places were found by hiding the begin/end methods in the SmallSet forwarding.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@334339 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[X86] Add avx512 feature flags to __builtin_ia32_select*.
Craig Topper [Fri, 8 Jun 2018 22:19:42 +0000 (22:19 +0000)]
[X86] Add avx512 feature flags to __builtin_ia32_select*.

There are many masked intrinsics that just wrap a select around a legacy intrinsic from a pre-avx512 instruciton set. If that intrinsic is implemented as a macro, nothing prevents it from being used when only the older feature was enabled. This likely generates very poor code since we don't have a good way to convert from the scalar masked type used by the intrinsic into a vector control for a legacy blend instruction. If we even have a blend instruction to use.

By adding a feature to the select builtins we can prevent and diagnose misuse of these intrinsics.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@334334 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[X86] Add back some masked vector truncate builtins. Custom IRgen a a few others.
Craig Topper [Fri, 8 Jun 2018 21:50:08 +0000 (21:50 +0000)]
[X86] Add back some masked vector truncate builtins. Custom IRgen a a few others.

I'd like to make the select builtins require an avx512f, avx512bw, or avx512vl fature to match what is normally required to get masking. Truncate is special in that there are instructions with a 128/256-bit masked result even without avx512vl.

By using special buitlins we can emit a select without using the 128/256-bit select builtins.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@334331 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[X86] Fold masking into subvector extract builtins.
Craig Topper [Fri, 8 Jun 2018 21:50:07 +0000 (21:50 +0000)]
[X86] Fold masking into subvector extract builtins.

I'm looking into making the select builtins require avx512f, avx512bw, or avx512vl since masking operations generally require those features.

The extract builtins are funny because the 512-bit versions return a 128 or 256 bit vector with masking even when avx512vl is not supported.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@334330 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[X86] Add builtins for vpermq/vpermpd instructions to enable target feature checking.
Craig Topper [Fri, 8 Jun 2018 18:00:25 +0000 (18:00 +0000)]
[X86] Add builtins for vpermq/vpermpd instructions to enable target feature checking.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@334311 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[X86] Change immediate type for some builtins from char to int.
Craig Topper [Fri, 8 Jun 2018 18:00:22 +0000 (18:00 +0000)]
[X86] Change immediate type for some builtins from char to int.

These builtins are all handled by CGBuiltin.cpp so it doesn't much matter what the immediate type is, but int matches the intrinsic spec.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@334310 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[CUDA] Fix emission of constant strings in sections
Jonas Hahnfeld [Fri, 8 Jun 2018 11:17:08 +0000 (11:17 +0000)]
[CUDA] Fix emission of constant strings in sections

CGM.GetAddrOfConstantCString() sets the adress of the created GlobalValue
to unnamed. When emitting the object file LLVM will mark the surrounding
section as SHF_MERGE iff the string is nul-terminated and contains no
other nuls (see IsNullTerminatedString). This results in problems when
saving temporaries because LLVM doesn't set an EntrySize, so reading in
the serialized assembly file fails.
This never happened for the GPU binaries because they usually contain
a nul-character somewhere. Instead this only affected the module ID
when compiling relocatable device code.

However, this points to a potentially larger problem: If we put a
constant string into a named section, we really want the data to end
up in that section in the object file. To avoid LLVM merging sections
this patch unmarks the GlobalVariable's address as unnamed which also
fixes the problem of invalid serialized assembly files when saving
temporaries.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@334281 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[X86] Add builtins for shufps and shufpd to enable target feature and immediate range...
Craig Topper [Fri, 8 Jun 2018 07:18:33 +0000 (07:18 +0000)]
[X86] Add builtins for shufps and shufpd to enable target feature and immediate range checking.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@334266 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[X86] Add builtins for pshufd, pshuflw, and pshufhw to enable target feature and...
Craig Topper [Fri, 8 Jun 2018 06:13:16 +0000 (06:13 +0000)]
[X86] Add builtins for pshufd, pshuflw, and pshufhw to enable target feature and immediate range checking.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@334265 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[X86] Fix some typecasts in intrinsic headers that I messed up in r334261.
Craig Topper [Fri, 8 Jun 2018 04:09:14 +0000 (04:09 +0000)]
[X86] Fix some typecasts in intrinsic headers that I messed up in r334261.

This was caught by the Header tests, but not the CodeGen tests.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@334264 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[X86] Add subvector insert and extract builtins to enable target feature checking...
Craig Topper [Fri, 8 Jun 2018 03:24:47 +0000 (03:24 +0000)]
[X86] Add subvector insert and extract builtins to enable target feature checking and immediate range checking.

Test changes are due to differences in how we generate undef elements now. We also changed the types used for extractf128_si256/insertf128_si256 to match the signature of the builtin that previously existed which this patch resurrects. This also matches gcc.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@334261 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[X86] Add builtins for vpermilps/pd instructions to enable target feature checking.
Craig Topper [Fri, 8 Jun 2018 00:59:27 +0000 (00:59 +0000)]
[X86] Add builtins for vpermilps/pd instructions to enable target feature checking.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@334256 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[CodeGen] Always use MSVC personality for windows-msvc targets
Shoaib Meenai [Fri, 8 Jun 2018 00:41:01 +0000 (00:41 +0000)]
[CodeGen] Always use MSVC personality for windows-msvc targets

The windows-msvc target is meant to be ABI compatible with MSVC,
including the exception handling. Ensure that a windows-msvc triple
always equates to the MSVC personality being used.

This mostly affects the GNUStep and ObjFW Obj-C runtimes. To the best of
my knowledge, those are normally not used with windows-msvc triples. I
believe WinObjC is based on GNUStep (or it at least uses libobjc2), but
that also takes the approach of wrapping Obj-C exceptions in C++
exceptions, so the MSVC personality function is the right one to use
there as well.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@334253 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[clang-fuzzer] Made loop_proto more "vectorizable".
Matt Morehouse [Fri, 8 Jun 2018 00:33:35 +0000 (00:33 +0000)]
[clang-fuzzer] Made loop_proto more "vectorizable".

Edited loop_proto and its converter to make more "vectorizable" code
according to kcc's comment in D47666
  - Removed all while loops
  - Can only index into array with induction variable

Patch By: emmettneyman

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@334252 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoReapply "[Parse] Use CapturedStmt for @finally on MSVC"
Shoaib Meenai [Fri, 8 Jun 2018 00:30:00 +0000 (00:30 +0000)]
Reapply "[Parse] Use CapturedStmt for @finally on MSVC"

This reapplies r334224 and adds explicit triples to some tests to fix
them on Windows (where otherwise they would have run with the default
windows-msvc triple, which I'm changing the behavior for).

Original commit message:
The body of a `@finally` needs to be executed on both exceptional and
non-exceptional paths. On landingpad platforms, this is straightforward:
the `@finally` body is emitted as a normal (non-exceptional) cleanup,
and then a catch-all is emitted which branches to that cleanup (the
cleanup has code to conditionally re-throw based on a flag which is set
by the catch-all).

Unfortunately, we can't use the same approach for MSVC exceptions, where
the catch-all will be emitted as a catchpad. We can't just branch to the
cleanup from within the catchpad, since we can only exit it via a
catchret, at which point the exception is destroyed and we can't
rethrow. We could potentially emit the finally body inside the catchpad
and have the normal cleanup path somehow branch into it, but that would
require some new IR construct that could branch into a catchpad.

Instead, after discussing it with Reid Kleckner, we decided that
frontend outlining was the best approach, similar to how SEH `__finally`
works today. We decided to use CapturedStmt (which was also suggested by
Reid) rather than CaptureFinder (which is what `__finally` uses) since
the latter doesn't handle a lot of cases we care about, e.g. self
accesses, property accesses, block captures, etc. Extending
CaptureFinder to handle those additional cases proved unwieldy, whereas
CapturedStmt already took care of all of those.  In theory `__finally`
could also be moved over to CapturedStmt, which would remove some
existing limitations (e.g. the inability to capture this), although
CaptureFinder would still be needed for SEH filters.

The one case supported by `@finally` but not CapturedStmt (or
CaptureFinder for that matter) is arbitrary control flow out of the
`@finally`, e.g. having a return statement inside a `@finally`. We can
add that support as a follow-up, but in practice we've found it to be
used very rarely anyway.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@334251 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[X86] Add builtins for blend with immediate control to enforce target feature require...
Craig Topper [Fri, 8 Jun 2018 00:00:21 +0000 (00:00 +0000)]
[X86] Add builtins for blend with immediate control to enforce target feature requirements and check immediate range.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@334249 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[X86] Add builtins for shuff32x4/shuff64x2/shufi32x4/shuff64x2 to enable target featu...
Craig Topper [Thu, 7 Jun 2018 23:03:08 +0000 (23:03 +0000)]
[X86] Add builtins for shuff32x4/shuff64x2/shufi32x4/shuff64x2 to enable target feature checking and immediate range checking.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@334244 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[Frontend] Disallow non-MSVC exception models for windows-msvc targets
Shoaib Meenai [Thu, 7 Jun 2018 22:54:54 +0000 (22:54 +0000)]
[Frontend] Disallow non-MSVC exception models for windows-msvc targets

The windows-msvc target is used for MSVC ABI compatibility, including
the exceptions model. It doesn't make sense to pair a windows-msvc
target with a non-MSVC exception model. This would previously cause an
assertion failure; explicitly error out for it in the frontend instead.
This also allows us to reduce the matrix of target/exception models a
bit (see the modified tests), and we can possibly simplify some of the
personality code in a follow-up.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@334243 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoRevert "[Parse] Use CapturedStmt for @finally on MSVC"
Shoaib Meenai [Thu, 7 Jun 2018 22:24:20 +0000 (22:24 +0000)]
Revert "[Parse] Use CapturedStmt for @finally on MSVC"

This reverts commit r334224.

This is causing buildbot failures on Windows, presumably because some
tests don't specify a triple. I'll test this on Windows locally and
recommit with the tests fixed.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@334240 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[MS] Re-add support for the ARM interlocked bittest intrinscs
Reid Kleckner [Thu, 7 Jun 2018 21:39:04 +0000 (21:39 +0000)]
[MS] Re-add support for the ARM interlocked bittest intrinscs

Adds support for these intrinsics, which are ARM and ARM64 only:
  _interlockedbittestandreset_acq
  _interlockedbittestandreset_rel
  _interlockedbittestandreset_nf
  _interlockedbittestandset_acq
  _interlockedbittestandset_rel
  _interlockedbittestandset_nf

Refactor the bittest intrinsic handling to decompose each intrinsic into
its action, its width, and its atomicity.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@334239 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[X86] Add builtins for VALIGNQ/VALIGND to enable proper target feature checking.
Craig Topper [Thu, 7 Jun 2018 21:27:41 +0000 (21:27 +0000)]
[X86] Add builtins for VALIGNQ/VALIGND to enable proper target feature checking.

We still emit shufflevector instructions we just do it from CGBuiltin.cpp now. This ensures the intrinsics that use this are only available on CPUs that support the feature.

I also added range checking to the immediate, but only checked it is 8 bits or smaller. We should maybe be stricter since we never use all 8 bits, but gcc doesn't seem to do that.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@334237 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[Parse] Use CapturedStmt for @finally on MSVC
Shoaib Meenai [Thu, 7 Jun 2018 20:07:52 +0000 (20:07 +0000)]
[Parse] Use CapturedStmt for @finally on MSVC

The body of a `@finally` needs to be executed on both exceptional and
non-exceptional paths. On landingpad platforms, this is straightforward:
the `@finally` body is emitted as a normal (non-exceptional) cleanup,
and then a catch-all is emitted which branches to that cleanup (the
cleanup has code to conditionally re-throw based on a flag which is set
by the catch-all).

Unfortunately, we can't use the same approach for MSVC exceptions, where
the catch-all will be emitted as a catchpad. We can't just branch to the
cleanup from within the catchpad, since we can only exit it via a
catchret, at which point the exception is destroyed and we can't
rethrow. We could potentially emit the finally body inside the catchpad
and have the normal cleanup path somehow branch into it, but that would
require some new IR construct that could branch into a catchpad.

Instead, after discussing it with Reid Kleckner, we decided that
frontend outlining was the best approach, similar to how SEH `__finally`
works today. We decided to use CapturedStmt (which was also suggested by
Reid) rather than CaptureFinder (which is what `__finally` uses) since
the latter doesn't handle a lot of cases we care about, e.g. self
accesses, property accesses, block captures, etc. Extending
CaptureFinder to handle those additional cases proved unwieldy, whereas
CapturedStmt already took care of all of those.  In theory `__finally`
could also be moved over to CapturedStmt, which would remove some
existing limitations (e.g. the inability to capture this), although
CaptureFinder would still be needed for SEH filters.

The one case supported by `@finally` but not CapturedStmt (or
CaptureFinder for that matter) is arbitrary control flow out of the
`@finally`, e.g. having a return statement inside a `@finally`. We can
add that support as a follow-up, but in practice we've found it to be
used very rarely anyway.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@334224 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[FileSystem] Split up the OpenFlags enumeration.
Zachary Turner [Thu, 7 Jun 2018 19:58:58 +0000 (19:58 +0000)]
[FileSystem] Split up the OpenFlags enumeration.

This breaks the OpenFlags enumeration into two separate
enumerations: OpenFlags and CreationDisposition.  The first
controls the behavior of the API depending on whether or not
the target file already exists, and is not a flags-based
enum.  The second controls more flags-like values.

This yields a more easy to understand API, while also allowing
flags to be passed to the openForRead api, where most of the
values didn't make sense before.  This also makes the apis more
testable as it becomes easy to enumerate all the configurations
which make sense, so I've added many new tests to exercise all
the different values.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@334221 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoIntroducing single for loop into clang_proto_fuzzer
Vitaly Buka [Thu, 7 Jun 2018 19:17:46 +0000 (19:17 +0000)]
Introducing single for loop into clang_proto_fuzzer

Summary:
Created a new protobuf and protobuf-to-C++ "converter" that wraps the entire C++ code in a single for loop.
  - Slightly changed cxx_proto.proto -> cxx_loop_proto.proto
  - Made some changes to proto_to_cxx files to handle the new kind of protobuf
  - Created ExampleClangLoopProtoFuzzer to test new protobuf and "converter"

Patch by Emmett Neyman

Reviewers: kcc, vitalybuka, morehouse

Reviewed By: vitalybuka, morehouse

Subscribers: mgorny, llvm-commits, cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@334216 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[X86] Add back builtins for _mm_slli_si128/_mm_srli_si128 and similar intrinsics.
Craig Topper [Thu, 7 Jun 2018 17:28:03 +0000 (17:28 +0000)]
[X86] Add back builtins for  _mm_slli_si128/_mm_srli_si128 and similar intrinsics.

We still lower them to native shuffle IR, but we do it in CGBuiltin.cpp now. This allows us to check the target feature and ensure the immediate fits in 8 bits.

This also improves our -O0 codegen slightly because we're able to see the zeroinitializer in the shuffle. It looks like it got lost behind a store+load previously.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@334208 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[clang-format] Consider tok::hashhash in python-style comments
Krasimir Georgiev [Thu, 7 Jun 2018 09:46:24 +0000 (09:46 +0000)]
[clang-format] Consider tok::hashhash in python-style comments

Summary: We were missing the case when python-style comments in text protos start with `##`.

Subscribers: cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@334179 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[CodeGen] Improve diagnostics related to target attributes
Gabor Buella [Thu, 7 Jun 2018 08:48:36 +0000 (08:48 +0000)]
[CodeGen] Improve diagnostics related to target attributes

Summary:
When requirement imposed by __target__ attributes on functions
are not satisfied, prefer printing those requirements, which
are explicitly mentioned in the attributes.

This makes such messages more useful, e.g. printing avx512f instead of avx2
in the following scenario:

```
$ cat foo.c
static inline void __attribute__((__always_inline__, __target__("avx512f")))
x(void)
{
}

int main(void)
{
            x();
}
$ clang foo.c
foo.c:7:2: error: always_inline function 'x' requires target feature 'avx2', but would be inlined into function 'main' that is compiled without support for 'avx2'
        x();
    ^
1 error generated.
```

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

Reviewers: craig.topper, echristo, dblaikie

Reviewed By: craig.topper, echristo

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@334174 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoChange return value of trivial visibility check.
Richard Trieu [Thu, 7 Jun 2018 03:20:30 +0000 (03:20 +0000)]
Change return value of trivial visibility check.

Previous, if no Decl's were checked, visibility was set to false.  Switch it
so that in cases of no Decl's, return true.  These are the Decl's after being
filtered.  Also remove an unreachable return statement since it is directly
after another return statement.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@334160 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[X86] Add back _mask, _maskz, and _mask3 builtins for some 512-bit fmadd/fmsub/fmadds...
Craig Topper [Thu, 7 Jun 2018 02:46:02 +0000 (02:46 +0000)]
[X86] Add back _mask, _maskz, and _mask3 builtins for some 512-bit fmadd/fmsub/fmaddsub/fmsubadd builtins.

Summary:
We recently switch to using a selects in the intrinsics header files for FMA instructions. But the 512-bit versions support flavors with rounding mode which must be an Integer Constant Expression. This has forced those intrinsics to be implemented as macros. As it stands now the mask and mask3 intrinsics evaluate one of their macro arguments twice. If that argument itself is another intrinsic macro, we can end up over expanding macros. Or if its something we can CSE later it would show up multiple times when it shouldn't.

I tried adding __extension__ around the macro and making it an expression statement and declaring a local variable. But whatever name you choose for the local variable can never be used as the name of an input to the macro in user code. If that happens you would end up with the same name on the LHS and RHS of an assignment after expansion. We might be safe if we use __ in front of the variable names because those names are reserved and user code shouldn't use that, but I wasn't sure I wanted to make that claim.

The other option which I've chosen here, is to add back _mask, _maskz, and _mask3 flavors of the builtin which we will expand in CGBuiltin.cpp to replicate the argument as needed and insert any fneg needed on the third operand to make a subtract. The _maskz isn't truly necessary if we have an unmasked version or if we use the masked version with a -1 mask and wrap a select around it. But I've chosen to make things more uniform.

I separated out the scalar builtin handling to avoid too many things going on in EmitX86FMAExpr. It was different enough due to the extract and insert that the minor duplication of the CreateCall was probably worth it.

Reviewers: tkrupa, RKSimon, spatel, GBuella

Reviewed By: tkrupa

Subscribers: cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@334159 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoClangTidy fix - 'clang::Sema::checkAllowedCUDAInitializer' has a definition with...
Han Shen [Thu, 7 Jun 2018 00:55:54 +0000 (00:55 +0000)]
ClangTidy fix - 'clang::Sema::checkAllowedCUDAInitializer' has a definition with different parameter names.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@334155 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoChange the wording of RTTI errors to make them more generic.
Sunil Srivastava [Thu, 7 Jun 2018 00:42:59 +0000 (00:42 +0000)]
Change the wording of RTTI errors to make them more generic.

An attempt to use dynamic_cast while rtti is disabled, used to emit the error:

  cannot use dynamic_cast with -fno-rtti

and a similar one for typeid.

This patch changes that to:

  use of dynamic_cast requires -frtti

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@334153 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[ODRHash] Adjust info stored for FunctionTemplateDecl.
Richard Trieu [Thu, 7 Jun 2018 00:20:58 +0000 (00:20 +0000)]
[ODRHash] Adjust info stored for FunctionTemplateDecl.

Avoid storing information for definitions since those can be out-of-line and
vary between modules even when the declarations are the same.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@334151 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[Driver] Stop passing -fseh-exceptions for x86_64-windows-msvc
Shoaib Meenai [Wed, 6 Jun 2018 23:09:02 +0000 (23:09 +0000)]
[Driver] Stop passing -fseh-exceptions for x86_64-windows-msvc

-fseh-exceptions is only meaningful for MinGW targets, and that driver
already has logic to pass either -fdwarf-exceptions or -fseh-exceptions
as appropriate. -fseh-exceptions is just a no-op for MSVC triples, and
passing it to cc1 causes unnecessary confusion.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@334145 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[CUDA] Check initializers of instantiated template variables.
Artem Belevich [Wed, 6 Jun 2018 22:37:25 +0000 (22:37 +0000)]
[CUDA] Check initializers of instantiated template variables.

We were already performing checks on non-template variables,
but the checks on templated ones were missing.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@334143 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[HIP] Fix unbundling
Yaxun Liu [Wed, 6 Jun 2018 19:44:10 +0000 (19:44 +0000)]
[HIP] Fix unbundling

HIP uses clang-offload-bundler to bundle intermediate files for host
and different gpu archs together. When a file is unbundled,
clang-offload-bundler should be called only once, and the objects
for host and different gpu archs should be passed to the next
jobs. This is because Driver maintains CachedResults which maps
triple-arch string to output files for each job.

This patch fixes a bug in Driver::BuildJobsForActionNoCache which
uses incorrect key for CachedResults for HIP which causes
clang-offload-bundler being called mutiple times and incorrect
output files being used.

It only affects HIP.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@334128 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[PATCH 2/2] [test] Add support for Samsung Exynos M4 (NFC)
Evandro Menezes [Wed, 6 Jun 2018 18:58:01 +0000 (18:58 +0000)]
[PATCH 2/2] [test] Add support for Samsung Exynos M4 (NFC)

Add test cases for Exynos M4.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@334116 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[MS][ARM64]: Promote _setjmp to_setjmpex as there is no _setjmp in the ARM64 libvcrun...
Reid Kleckner [Wed, 6 Jun 2018 18:39:47 +0000 (18:39 +0000)]
[MS][ARM64]: Promote _setjmp to_setjmpex as there is no _setjmp in the ARM64 libvcruntime.lib

Factor out the common setjmp call emission code.

Based on a patch by Chris January

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@334112 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[CUDA] Replace 'nv_weak' attributes in CUDA headers with 'weak'.
Artem Belevich [Wed, 6 Jun 2018 17:52:55 +0000 (17:52 +0000)]
[CUDA] Replace 'nv_weak' attributes in CUDA headers with 'weak'.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@334108 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoPR37680: fix faulty assertion condition.
Richard Smith [Wed, 6 Jun 2018 16:36:56 +0000 (16:36 +0000)]
PR37680: fix faulty assertion condition.

When looking up a template name, we can find an overload set containing a
function template and an unresolved non-type using declaration.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@334106 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[Driver] Add flag "--dependent-lib=..." when enabling asan or ubsan on PS4.
Pierre Gousseau [Wed, 6 Jun 2018 14:04:15 +0000 (14:04 +0000)]
[Driver] Add flag "--dependent-lib=..." when enabling asan or ubsan on PS4.

NFC for targets other than PS4.

Simplify users' workflow when enabling asan or ubsan and calling the linker separately.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@334096 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoChange test to output 'pcm' to the temp dir, not the source dir
Ilya Biryukov [Wed, 6 Jun 2018 08:50:12 +0000 (08:50 +0000)]
Change test to output 'pcm' to the temp dir, not the source dir

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@334073 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoFix build - use llvm::make_unique
Ivan Donchevskii [Wed, 6 Jun 2018 08:25:54 +0000 (08:25 +0000)]
Fix build - use llvm::make_unique

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@334072 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[Frontend] Honor UserFilesAreVolatile flag getting file buffer in ASTUnit
Ivan Donchevskii [Wed, 6 Jun 2018 07:17:26 +0000 (07:17 +0000)]
[Frontend] Honor UserFilesAreVolatile flag getting file buffer in ASTUnit

Do not memory map the main file if the flag UserFilesAreVolatile is set to true
in ASTUnit when calling FileSystem::getBufferForFile.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@334070 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[Analyzer][Z3] Test fixes for Z3 constraint manager
Vlad Tsyrklevich [Wed, 6 Jun 2018 06:25:51 +0000 (06:25 +0000)]
[Analyzer][Z3] Test fixes for Z3 constraint manager

Summary:
Since Z3 tests have been not been running [1] some tests needed to be
updated. I also added a regression test for [1].

[1] https://reviews.llvm.org/D47722

Reviewers: george.karpenkov, NoQ, ddcc

Reviewed By: george.karpenkov

Subscribers: mikhail.ramalho, dcoughlin, xazax.hun, szepet, zzheng, a.sidorin, cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@334067 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[Analyzer] Fix Z3ConstraintManager crash (PR37646)
Vlad Tsyrklevich [Wed, 6 Jun 2018 06:09:02 +0000 (06:09 +0000)]
[Analyzer] Fix Z3ConstraintManager crash (PR37646)

Summary:
Fix another Z3ConstraintManager crash, use fixAPSInt() to extend a
boolean APSInt.

Reviewers: george.karpenkov, NoQ, ddcc

Reviewed By: george.karpenkov

Subscribers: xazax.hun, szepet, a.sidorin, cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@334065 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[Fuchsia] Include install-distribution-stripped in bootstrap targets
Petr Hosek [Wed, 6 Jun 2018 05:18:39 +0000 (05:18 +0000)]
[Fuchsia] Include install-distribution-stripped in bootstrap targets

This enables the use of install-distribution-stripped target in the
2-stage builds.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@334063 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[Sema] Fix parsing of anonymous union in language linkage specification
Jan Korous [Wed, 6 Jun 2018 05:16:34 +0000 (05:16 +0000)]
[Sema] Fix parsing of anonymous union in language linkage specification

C++17 [dcl.link]p4:
A linkage specification does not establish a scope.

C++17 [class.union.anon]p2:
Namespace level anonymous unions shall be declared static.

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

rdar://problem/37545925

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@334062 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[X86] Move the vec_set/vec_ext builtins for 64-bit elements to BuiltinsX86_64.def.
Craig Topper [Wed, 6 Jun 2018 04:51:52 +0000 (04:51 +0000)]
[X86] Move the vec_set/vec_ext builtins for 64-bit elements to BuiltinsX86_64.def.

The instructions these correspond to and the intrinsics that use them are only available in 64-bit mode.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@334061 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoFix std::tuple errors
Reid Kleckner [Wed, 6 Jun 2018 01:44:10 +0000 (01:44 +0000)]
Fix std::tuple errors

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@334060 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoImplement bittest intrinsics generically for non-x86 platforms
Reid Kleckner [Wed, 6 Jun 2018 01:35:08 +0000 (01:35 +0000)]
Implement bittest intrinsics generically for non-x86 platforms

I tested these locally on an x86 machine by disabling the inline asm
codepath and confirming that it does the same bitflips as we do with the
inline asm.

Addresses code review feedback.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@334059 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[X86] Add builtins for vector element insert and extract for different 128 and 256...
Craig Topper [Wed, 6 Jun 2018 00:24:55 +0000 (00:24 +0000)]
[X86] Add builtins for vector element insert and extract for different 128 and 256 bit vector types. Use them to implement the extract and insert intrinsics.

Previously we were just using extended vector operations in the header file.

This unfortunately allowed non-constant indices to be used with the intrinsics. This is incompatible with gcc, icc, and MSVC. It also introduces a different performance characteristic because non-constant index gets lowered to a vector store and an element sized load.

By adding the builtins we can check for the index to be a constant and ensure its in range of the vector element count.

User code still has the option to use extended vector operations themselves if they need non-constant indexing.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@334057 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[X86] Implement __builtin_ia32_vec_ext_v2si correctly even though we only use it...
Craig Topper [Tue, 5 Jun 2018 22:40:03 +0000 (22:40 +0000)]
[X86] Implement __builtin_ia32_vec_ext_v2si correctly even though we only use it with an index of 0.

This builtin takes an index as its second operand, but the codegen hardcodes an index of 0 and doesn't use the operand. The only use of the builtin in the header file passes 0 to the operand so this works for that usage. But its more correct to use the real operand.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@334054 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[X86] Make __builtin_ia32_vec_ext_v2si require ICE for its index argument. Add warnin...
Craig Topper [Tue, 5 Jun 2018 21:54:35 +0000 (21:54 +0000)]
[X86] Make __builtin_ia32_vec_ext_v2si require ICE for its index argument. Add warnings for out of range indices for __builtin_ia32_vec_ext_v2si, __builtin_ia32_vec_ext_v4hi, and __builtin_ia32_vec_set_v4hi.

These should take a constant value for an index and that constant should be a valid element number.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@334051 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[CUDA][HIP] Do not emit type info when compiling for device
Yaxun Liu [Tue, 5 Jun 2018 15:11:02 +0000 (15:11 +0000)]
[CUDA][HIP] Do not emit type info when compiling for device

CUDA/HIP does not support RTTI on device side, therefore there
is no point of emitting type info when compiling for device.

Emitting type info for device not only clutters the IR with useless
global variables, but also causes undefined symbol at linking
since vtable for cxxabiv1::class_type_info has external linkage.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@334021 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoDetect an incompatible VLA pointer assignment
Jeremy Morse [Tue, 5 Jun 2018 09:18:26 +0000 (09:18 +0000)]
Detect an incompatible VLA pointer assignment

For pointer assignments of VLA types, Clang currently detects when array
dimensions _lower_ than a variable dimension differ, and reports a warning.
However it does not do the same when the _higher_ dimensions differ, a
case that GCC does catch.

These two pointer types

    int (*foo)[1][bar][3];
    int (*baz)[1][2][3];

are compatible with each another, and the program is well formed if
bar == 2, a matter that is the programmers problem. However the following:

    int (*qux)[2][2][3];

would not be compatible with either, because the upper dimension differs
in size. Clang reports baz is incompatible with qux, but not that foo is
incompatible with qux because it doesn't check those higher dimensions.

Fix this by comparing array sizes on higher dimensions: if both are
constants but unequal then report incompatibility; if either dimension is
variable then we can't know either way.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@333989 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[X86] Mark all the builtins and intrinsics that require MMX and an SSE feature as...
Craig Topper [Tue, 5 Jun 2018 03:12:14 +0000 (03:12 +0000)]
[X86] Mark all the builtins and intrinsics that require MMX and an SSE feature as requiring both mmx and the sse feature.

Previously we only checked the sse feature, but this means that if you passed -mno-mmx, the builtins/intrinsics wouldn't be disabled in the frontend and would instead fail backend isel.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@333980 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[Driver][Fuchsia] Pass LTO flags to linker
Petr Hosek [Tue, 5 Jun 2018 01:50:59 +0000 (01:50 +0000)]
[Driver][Fuchsia] Pass LTO flags to linker

Even though we use lld by default for Fuchsia, we use Gold plugin
arguments like all other drivers as lld supports Gold plugin options.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@333979 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoReimplement the bittest intrinsic family as builtins with inline asm
Reid Kleckner [Tue, 5 Jun 2018 01:33:40 +0000 (01:33 +0000)]
Reimplement the bittest intrinsic family as builtins with inline asm

We need to implement _interlockedbittestandset as a builtin for
windows.h, so we might as well do the whole family. It reduces code
duplication anyway.

Fixes PR33188, a long standing bug in our bittest implementation
encountered by Chakra.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@333978 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[clang-proto-fuzzer] Refactored LLVMFuzzerInitialize into its own file.
Matt Morehouse [Tue, 5 Jun 2018 00:11:41 +0000 (00:11 +0000)]
[clang-proto-fuzzer] Refactored LLVMFuzzerInitialize into its own file.

Copied and renamed some files in preparation for new loop-proto-fuzzer.

Patch By: emmettneyman

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@333969 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[ThinLTO] Add testing of new summary index format to a couple CFI tests
Teresa Johnson [Mon, 4 Jun 2018 23:05:24 +0000 (23:05 +0000)]
[ThinLTO] Add testing of new summary index format to a couple CFI tests

Summary:
Adds testing of combined index summary entries in disassembly format
to CFI tests that were already testing the bitcode format.

Depends on D46699.

Reviewers: pcc

Subscribers: mehdi_amini, inglorion, eraman, cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@333966 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoRevert r333791 "Cap "voluntary" vector alignment at 16 for all Darwin platforms."
Reid Kleckner [Mon, 4 Jun 2018 21:39:20 +0000 (21:39 +0000)]
Revert r333791 "Cap "voluntary" vector alignment at 16 for all Darwin platforms."

Adding __attribute__((aligned(32))) to __m256 breaks the implementation
of _mm256_loadu_ps on Windows. On Windows, alignment attributes have
higher precedence than packing attributes.

We also might want to carefully consider the consequences of changing
our vector typedefs, since many users copy them and invent their own
new, non-Intel specific vector type names.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@333958 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoUpdate for an LLVM header file move
David Blaikie [Mon, 4 Jun 2018 21:23:29 +0000 (21:23 +0000)]
Update for an LLVM header file move

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@333955 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[analyzer] Re-enable constructors when lifetime extension through fields occurs.
Artem Dergachev [Mon, 4 Jun 2018 20:18:37 +0000 (20:18 +0000)]
[analyzer] Re-enable constructors when lifetime extension through fields occurs.

Temporary object constructor inlining was disabled in r326240 for code like

    const int &x = A().x;

because automatic destructor for the lifetime-extended object A() was not
working correctly in CFG.

CFG was fixed in r333941, so inlining can be re-enabled. CFG for lifetime
extension through aggregates still needs to be fixed.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@333946 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[X86] Avoid passing _mm_undefined* to builtin_shufflevector if we are able to pass...
Craig Topper [Mon, 4 Jun 2018 19:28:09 +0000 (19:28 +0000)]
[X86] Avoid passing _mm_undefined* to builtin_shufflevector if we are able to pass the first input a second time.

This is more consistent with other usages of builtin_shufflevector. Later optimization passes or codegen will detect the duplicate vector and replace it with undef. Using _mm_undefined just puts a zeroinitializer that still needs to be optimized out later.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@333944 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[CFG] Fix automatic destructors when a member is bound to a reference.
Artem Dergachev [Mon, 4 Jun 2018 18:56:25 +0000 (18:56 +0000)]
[CFG] Fix automatic destructors when a member is bound to a reference.

In code like

    const int &x = A().x;

automatic destructor for the object A() lifetime-extended by reference 'x' was
not present in the clang CFG due to ad-hoc pattern-matching in
getReferenceInitTemporaryType().

Re-use skipRValueSubobjectAdjustments() again to find the lifetime-extended
object in the AST and emit the correct destructor.

Lifetime extension through aggregates with references still needs to be covered.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@333941 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoRemove llvm::Triple argument from get***Personality() functions. NFC.
Heejin Ahn [Mon, 4 Jun 2018 18:23:00 +0000 (18:23 +0000)]
Remove llvm::Triple argument from get***Personality() functions. NFC.

Summary:
Because `llvm::Triple` can be derived from `TargetInfo`, it is simpler
to take only `TargetInfo` argument.

Reviewers: sbc100

Subscribers: cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@333938 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoThis diff includes changes for supporting the following types.
Leonard Chan [Mon, 4 Jun 2018 16:07:52 +0000 (16:07 +0000)]
This diff includes changes for supporting the following types.

// Primary fixed point types
signed short _Accum s_short_accum;
signed _Accum s_accum;
signed long _Accum s_long_accum;
unsigned short _Accum u_short_accum;
unsigned _Accum u_accum;
unsigned long _Accum u_long_accum;

// Aliased fixed point types
short _Accum short_accum;
_Accum accum;
long _Accum long_accum;
This diff only allows for declaration of the fixed point types. Assignment and other operations done on fixed point types according to http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1169.pdf will be added in future patches. The saturated versions of these types and the equivalent _Fract types will also be added in future patches.

The tests included are for asserting that we can declare these types.

Fixed the test that was failing by not checking for dso_local on some
targets.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@333923 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[analyzer] False positive refutation with Z3
Mikhail R. Gadelha [Mon, 4 Jun 2018 14:40:44 +0000 (14:40 +0000)]
[analyzer] False positive refutation with Z3

Summary: This is a prototype of a bug reporter visitor that invalidates bug reports by re-checking constraints of certain states on the bug path using the Z3 constraint manager backend. The functionality is available under the `crosscheck-with-z3` analyzer config flag.

Reviewers: george.karpenkov, NoQ, dcoughlin, rnkovacs

Reviewed By: george.karpenkov

Subscribers: rnkovacs, NoQ, george.karpenkov, dcoughlin, xbolva00, ddcc, mikhail.ramalho, MTC, fhahn, whisperity, baloghadamsoftware, szepet, a.sidorin, gsd, dkrupp, xazax.hun, cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@333903 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago Created a tiny SMT interface and make Z3ConstraintManager implement it
Mikhail R. Gadelha [Mon, 4 Jun 2018 14:25:58 +0000 (14:25 +0000)]
 Created a tiny SMT interface and make Z3ConstraintManager implement it

Summary:
This patch implements a simple SMTConstraintManager API, and requires the implementation of two methods for now: `addRangeConstraints` and `isModelFeasible`.

Update Z3ConstraintManager to inherit it and implement required methods.

I also moved the method to dump the SMT formula from D45517 to this patch.

This patch was created based on the reviews from D47640.

Reviewers: george.karpenkov, NoQ, ddcc, dcoughlin

Reviewed By: george.karpenkov

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@333899 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[clang][tooling] Don't forget to link to clangToolingInclusions.
Roman Lebedev [Mon, 4 Jun 2018 12:04:41 +0000 (12:04 +0000)]
[clang][tooling] Don't forget to link to clangToolingInclusions.

Fixes build with shared libs, broken by rL333874.
Some buildbot converage is sorely missing.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@333890 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoReland "Move #include manipulation code to new lib/Tooling/Inclusions."
Eric Liu [Mon, 4 Jun 2018 09:04:12 +0000 (09:04 +0000)]
Reland "Move #include manipulation code to new lib/Tooling/Inclusions."

This reverts commit r333534 (i.e. reland r332720) after fixing module build.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@333874 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[X86] Fix a couple places that were using macro arguments twice when of the usages...
Craig Topper [Mon, 4 Jun 2018 02:56:18 +0000 (02:56 +0000)]
[X86] Fix a couple places that were using macro arguments twice when of the usages could just be undefined.

One of the arguments was being used when the passthru argument is unused due to the mask being all 1s. But in that case the actual value doesn't matter so we should use undef instead to avoid expanding the macro argument unnecessarily.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@333865 91177308-0d34-0410-b5e6-96231b3b80d8