Re: r284256 - Link static PIE programs against rcrt0.o on OpenBSD

2016-10-29 Thread Brad Smith via cfe-commits

On 10/25/16 19:34, Brad Smith via cfe-commits wrote:

On 10/18/16 22:13, Brad Smith via cfe-commits wrote:

On Fri, Oct 14, 2016 at 09:47:17PM -0400, Brad Smith via cfe-commits
wrote:

On Fri, Oct 14, 2016 at 05:59:54PM -, Ed Maste via cfe-commits
wrote:

Author: emaste
Date: Fri Oct 14 12:59:53 2016
New Revision: 284256

URL: http://llvm.org/viewvc/llvm-project?rev=284256=rev
Log:
Link static PIE programs against rcrt0.o on OpenBSD

Patch by Stefan Kempf.

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

Modified:
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/test/Driver/openbsd.c

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL:
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=284256=284255=284256=diff

==

--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Fri Oct 14 12:59:53 2016
@@ -8519,6 +8519,10 @@ void openbsd::Linker::ConstructJob(Compi
   if (Args.hasArg(options::OPT_pg))
 CmdArgs.push_back(

Args.MakeArgString(getToolChain().GetFilePath("gcrt0.o")));
+  else if (Args.hasArg(options::OPT_static) &&
+   !Args.hasArg(options::OPT_nopie))
+CmdArgs.push_back(
+
Args.MakeArgString(getToolChain().GetFilePath("rcrt0.o")));
   else
 CmdArgs.push_back(
 Args.MakeArgString(getToolChain().GetFilePath("crt0.o")));

Modified: cfe/trunk/test/Driver/openbsd.c
URL:
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/openbsd.c?rev=284256=284255=284256=diff

==

--- cfe/trunk/test/Driver/openbsd.c (original)
+++ cfe/trunk/test/Driver/openbsd.c Fri Oct 14 12:59:53 2016
@@ -67,3 +67,26 @@
 // CHECK-MIPS64-PIC: as{{.*}}" "-mabi" "64" "-EB" "-KPIC"
 // CHECK-MIPS64EL: as{{.*}}" "-mabi" "64" "-EL"
 // CHECK-MIPS64EL-PIC: as{{.*}}" "-mabi" "64" "-EL" "-KPIC"
+
+// Check linking against correct startup code when (not) using PIE
+// RUN: %clang -no-canonical-prefixes -target i686-pc-openbsd %s
-### 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-PIE %s
+// RUN: %clang -no-canonical-prefixes -target i686-pc-openbsd %s
-fno-pie %s -### 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-PIE %s
+// RUN: %clang -no-canonical-prefixes -target i686-pc-openbsd
-static %s -### 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-STATIC-PIE %s
+// RUN: %clang -no-canonical-prefixes -target i686-pc-openbsd
-static -fno-pie %s -### 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-STATIC-PIE %s
+// RUN: %clang -no-canonical-prefix -target i868-pc-openbsd -nopie
%s -### 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-NOPIE %s
+// RUN: %clang -no-canonical-prefix -target i868-pc-openbsd
-fno-pie -nopie %s -### 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-NOPIE %s
+// RUN: %clang -no-canonical-prefix -target i868-pc-openbsd -static
-nopie %s -### 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-NOPIE %s
+// RUN: %clang -no-canonical-prefix -target i868-pc-openbsd
-fno-pie -static -nopie %s -### 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-NOPIE %s
+// CHECK-PIE: "/usr/lib/crt0.o"
+// CHECK-PIE-NOT: "-nopie"
+// CHECK-STATIC-PIE: "/usr/lib/rcrt0.o"
+// CHECK-STATIC-PIE-NOT: "-nopie"
+// CHECK-NOPIE: "-nopie" {{.*}}"/usr/lib/crt0.o"


Ok, I see the obvious issue with -no-canonical-prefix vs
-no-canonical-prefixes
and fix the typo with the target triples.


After seeing what the test failure was I have adjusted the tests as
appropriate.


ping.


ping ping.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r285511 - clang/test/Driver/openmp-offload.c: Relax expressions if "ld.exe" exists, like mingw.

2016-10-29 Thread NAKAMURA Takumi via cfe-commits
Author: chapuni
Date: Sat Oct 29 21:58:48 2016
New Revision: 285511

URL: http://llvm.org/viewvc/llvm-project?rev=285511=rev
Log:
clang/test/Driver/openmp-offload.c: Relax expressions if "ld.exe" exists, like 
mingw.

Modified:
cfe/trunk/test/Driver/openmp-offload.c

Modified: cfe/trunk/test/Driver/openmp-offload.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/openmp-offload.c?rev=285511=285510=285511=diff
==
--- cfe/trunk/test/Driver/openmp-offload.c (original)
+++ cfe/trunk/test/Driver/openmp-offload.c Sat Oct 29 21:58:48 2016
@@ -250,7 +250,7 @@
 //
 // CHK-COMMANDS: clang{{.*}}" "-cc1" "-triple" "powerpc64le-ibm-linux-gnu" 
"-emit-obj" {{.*}}"-pic-level" "2" {{.*}}"-fopenmp" {{.*}}"-o" "
 // CHK-COMMANDS-SAME: [[T1OBJ:[^\\/]+\.o]]" "-x" "c" "{{.*}}[[INPUT]]" 
"-fopenmp-is-device" "-fopenmp-host-ir-file-path" "{{.*}}[[HOSTBC]]"
-// CHK-COMMANDS: ld" {{.*}}"-o" "
+// CHK-COMMANDS: ld{{(\.exe)?}}" {{.*}}"-o" "
 // CHK-COMMANDS-SAME: [[T1BIN:[^\\/]+\.out]]" {{.*}}"{{.*}}[[T1OBJ]]"
 // CHK-COMMANDS-ST: clang{{.*}}" "-cc1" "-triple" "powerpc64le-ibm-linux-gnu" 
"-E" {{.*}}"-fopenmp" {{.*}}"-o" "
 // CHK-COMMANDS-ST-SAME: [[T1PP:[^\\/]+\.i]]" "-x" "c" "{{.*}}[[INPUT]]"
@@ -260,14 +260,14 @@
 // CHK-COMMANDS-ST-SAME: [[T1ASM:[^\\/]+\.s]]" "-x" "ir" "{{.*}}[[T1BC]]"
 // CHK-COMMANDS-ST: clang{{.*}}" "-cc1as" "-triple" 
"powerpc64le-ibm-linux-gnu" "-filetype" "obj" {{.*}}"-o" "
 // CHK-COMMANDS-ST-SAME: [[T1OBJ:[^\\/]+\.o]]" "{{.*}}[[T1ASM]]"
-// CHK-COMMANDS-ST: ld" {{.*}}"-shared" {{.*}}"-o" "
+// CHK-COMMANDS-ST: ld{{(\.exe)?}}" {{.*}}"-shared" {{.*}}"-o" "
 // CHK-COMMANDS-ST-SAME: 
[[T1BIN:[^\\/]+\.out-openmp-powerpc64le-ibm-linux-gnu]]" {{.*}}"{{.*}}[[T1OBJ]]"
 //
 // Compile for the x86 device.
 //
 // CHK-COMMANDS: clang{{.*}}" "-cc1" "-triple" "x86_64-pc-linux-gnu" 
"-emit-obj" {{.*}}"-pic-level" "2" {{.*}}"-fopenmp"  {{.*}}"-o" "
 // CHK-COMMANDS-SAME: [[T2OBJ:[^\\/]+\.o]]" "-x" "c" "{{.*}}[[INPUT]]" 
"-fopenmp-is-device" "-fopenmp-host-ir-file-path" "{{.*}}[[HOSTBC]]"
-// CHK-COMMANDS: ld" {{.*}}"-o" "
+// CHK-COMMANDS: ld{{(\.exe)?}}" {{.*}}"-o" "
 // CHK-COMMANDS-SAME: [[T2BIN:[^\\/]+\.out]]" {{.*}}"{{.*}}[[T2OBJ]]"
 // CHK-COMMANDS-ST: clang{{.*}}" "-cc1" "-triple" "x86_64-pc-linux-gnu" "-E" 
{{.*}}"-fopenmp" {{.*}}"-o" "
 // CHK-COMMANDS-ST-SAME: [[T2PP:[^\\/]+\.i]]" "-x" "c" "{{.*}}[[INPUT]]"
@@ -277,7 +277,7 @@
 // CHK-COMMANDS-ST-SAME: [[T2ASM:[^\\/]+\.s]]" "-x" "ir" "{{.*}}[[T2BC]]"
 // CHK-COMMANDS-ST: clang{{.*}}" "-cc1as" "-triple" "x86_64-pc-linux-gnu" 
"-filetype" "obj" {{.*}}"-o" "
 // CHK-COMMANDS-ST-SAME: [[T2OBJ:[^\\/]+\.o]]" "{{.*}}[[T2ASM]]"
-// CHK-COMMANDS-ST: ld" {{.*}}"-shared" {{.*}}"-o" "
+// CHK-COMMANDS-ST: ld{{(\.exe)?}}" {{.*}}"-shared" {{.*}}"-o" "
 // CHK-COMMANDS-ST-SAME: [[T2BIN:[^\\/]+\.out-openmp-x86_64-pc-linux-gnu]]" 
{{.*}}"{{.*}}[[T2OBJ]]"
 
 //
@@ -285,14 +285,14 @@
 //
 // CHK-COMMANDS: clang{{.*}}" "-cc1" "-triple" "powerpc64le--linux" 
"-emit-obj" {{.*}}"-fopenmp" {{.*}}"-o" "
 // CHK-COMMANDS-SAME: [[HOSTOBJ:[^\\/]+\.o]]" "-x" "ir" "{{.*}}[[HOSTBC]]"
-// CHK-COMMANDS: ld" {{.*}}"-o" "
+// CHK-COMMANDS: ld{{(\.exe)?}}" {{.*}}"-o" "
 // CHK-COMMANDS-SAME: [[HOSTBIN:[^\\/]+\.out]]"  {{.*}}"-lomptarget" 
{{.*}}"-T" "
 // CHK-COMMANDS-SAME: [[HOSTLK:[^\\/]+\.lk]]"
 // CHK-COMMANDS-ST: clang{{.*}}" "-cc1" "-triple" "powerpc64le--linux" "-S" 
{{.*}}"-fopenmp" {{.*}}"-o" "
 // CHK-COMMANDS-ST-SAME: [[HOSTASM:[^\\/]+\.s]]" "-x" "ir" "{{.*}}[[HOSTBC]]"
 // CHK-COMMANDS-ST: clang{{.*}}" "-cc1as" "-triple" "powerpc64le--linux" 
"-filetype" "obj" {{.*}}"-o" "
 // CHK-COMMANDS-ST-SAME: [[HOSTOBJ:[^\\/]+\.o]]" "{{.*}}[[HOSTASM]]"
-// CHK-COMMANDS-ST: ld" {{.*}}"-o" "
+// CHK-COMMANDS-ST: ld{{(\.exe)?}}" {{.*}}"-o" "
 // CHK-COMMANDS-ST-SAME: [[HOSTBIN:[^\\/]+\.out]]"  {{.*}}"-lomptarget" 
{{.*}}"-T" "
 // CHK-COMMANDS-ST-SAME: [[HOSTLK:[^\\/]+\.lk]]"
 
@@ -464,7 +464,7 @@
 // Create target 1 object.
 // CHK-UBJOBS: clang{{.*}}" "-cc1" "-triple" "powerpc64le-ibm-linux-gnu" 
"-emit-obj" {{.*}}"-fopenmp" {{.*}}"-o" "
 // CHK-UBJOBS-SAME: [[T1OBJ:[^\\/]+\.o]]" "-x" "cpp-output" "{{.*}}[[T1PP]]" 
"-fopenmp-is-device" "-fopenmp-host-ir-file-path" "{{.*}}[[HOSTBC]]"
-// CHK-UBJOBS: ld" {{.*}}"-o" "
+// CHK-UBJOBS: ld{{(\.exe)?}}" {{.*}}"-o" "
 // CHK-UBJOBS-SAME: [[T1BIN:[^\\/]+\.out]]" {{.*}}"{{.*}}[[T1OBJ]]"
 // CHK-UBJOBS-ST: clang{{.*}}" "-cc1" "-triple" "powerpc64le-ibm-linux-gnu" 
"-emit-llvm-bc" {{.*}}"-fopenmp" {{.*}}"-o" "
 // CHK-UBJOBS-ST-SAME: [[T1BC:[^\\/]+\.bc]]" "-x" "cpp-output" 
"{{.*}}[[T1PP]]" "-fopenmp-is-device" "-fopenmp-host-ir-file-path" 
"{{.*}}[[HOSTBC]]"
@@ -472,13 +472,13 @@
 // CHK-UBJOBS-ST-SAME: [[T1ASM:[^\\/]+\.s]]" "-x" "ir" "{{.*}}[[T1BC]]"
 // CHK-UBJOBS-ST: clang{{.*}}" "-cc1as" "-triple" "powerpc64le-ibm-linux-gnu" 
"-filetype" "obj" {{.*}}"-o" "
 // CHK-UBJOBS-ST-SAME: [[T1OBJ:[^\\/]+\.o]]" "{{.*}}[[T1ASM]]"
-// CHK-UBJOBS-ST: ld" {{.*}}"-o" "

Re: r285341 - Add documentation describing the components of a complete toolchain including Clang.

2016-10-29 Thread Will Dietz via cfe-commits
(Agreed, thanks!)

~Will

On Sat, Oct 29, 2016 at 5:50 PM, Sean Silva via cfe-commits
 wrote:
> This is awesome Richard. Thanks!
>
> -- Sean Silva
>
> On Thu, Oct 27, 2016 at 1:55 PM, Richard Smith via cfe-commits
>  wrote:
>>
>> Author: rsmith
>> Date: Thu Oct 27 15:55:56 2016
>> New Revision: 285341
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=285341=rev
>> Log:
>> Add documentation describing the components of a complete toolchain
>> including Clang.
>>
>> Added:
>> cfe/trunk/docs/Toolchain.rst
>> Modified:
>> cfe/trunk/docs/UsersManual.rst
>> cfe/trunk/docs/index.rst
>>
>> Added: cfe/trunk/docs/Toolchain.rst
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/Toolchain.rst?rev=285341=auto
>>
>> ==
>> --- cfe/trunk/docs/Toolchain.rst (added)
>> +++ cfe/trunk/docs/Toolchain.rst Thu Oct 27 15:55:56 2016
>> @@ -0,0 +1,354 @@
>> +===
>> +Assembling a Complete Toolchain
>> +===
>> +
>> +.. contents::
>> +   :local:
>> +   :depth: 2
>> +
>> +Introduction
>> +
>> +
>> +Clang is only one component in a complete tool chain for C family
>> +programming languages. In order to assemble a complete toolchain,
>> +additional tools and runtime libraries are required. Clang is designed
>> +to interoperate with existing tools and libraries for its target
>> +platforms, and the LLVM project provides alternatives for a number
>> +of these components.
>> +
>> +This document describes the required and optional components in a
>> +complete toolchain, where to find them, and the supported versions
>> +and limitations of each option.
>> +
>> +.. warning::
>> +
>> +  This document currently describes Clang configurations on POSIX-like
>> +  operating systems with the GCC-compatible ``clang`` driver. When
>> +  targeting Windows with the MSVC-compatible ``clang-cl`` driver, some
>> +  of the details are different.
>> +
>> +Tools
>> +=
>> +
>> +.. FIXME: Describe DWARF-related tools
>> +
>> +A complete compilation of C family programming languages typically
>> +involves the following pipeline of tools, some of which are omitted
>> +in some compilations:
>> +
>> +* **Preprocessor**: This performs the actions of the C preprocessor:
>> +  expanding #includes and #defines.
>> +  The ``-E`` flag instructs Clang to stop after this step.
>> +
>> +* **Parsing**: This parses and semantically analyzes the source language
>> and
>> +  builds a source-level intermediate representation ("AST"), producing a
>> +  :ref:`precompiled header (PCH) `,
>> +  preamble, or
>> +  :doc:`precompiled module file (PCM) `,
>> +  depending on the input.
>> +  The ``-precompile`` flag instructs Clang to stop after this step. This
>> is
>> +  the default when the input is a header file.
>> +
>> +* **IR generation**: This converts the source-level intermediate
>> representation
>> +  into an optimizer-specific intermediate representation (IR); for Clang,
>> this
>> +  is LLVM IR.
>> +  The ``-emit-llvm`` flag instructs Clang to stop after this step. If
>> combined
>> +  with ``-S``, Clang will produce textual LLVM IR; otherwise, it will
>> produce
>> +  LLVM IR bitcode.
>> +
>> +* **Compiler backend**: This converts the intermediate representation
>> +  into target-specific assembly code.
>> +  The ``-S`` flag instructs Clang to stop after this step.
>> +
>> +* **Assembler**: This converts target-specific assembly code into
>> +  target-specific machine code object files.
>> +  The ``-c`` flag instructs Clang to stop after this step.
>> +
>> +* **Linker**: This combines multiple object files into a single image
>> +  (either a shared object or an executable).
>> +
>> +Clang provides all of these pieces other than the linker. When multiple
>> +steps are performed by the same tool, it is common for the steps to be
>> +fused together to avoid creating intermediate files.
>> +
>> +When given an output of one of the above steps as an input, earlier steps
>> +are skipped (for instance, a ``.s`` file input will be assembled and
>> linked).
>> +
>> +The Clang driver can be invoked with the ``-###`` flag (this argument
>> will need
>> +to be escaped under most shells) to see which commands it would run for
>> the
>> +above steps, without running them. The ``-v`` (verbose) flag will print
>> the
>> +commands in addition to running them.
>> +
>> +Clang frontend
>> +--
>> +
>> +The Clang frontend (``clang -cc1``) is used to compile C family
>> languages. The
>> +command-line interface of the frontend is considered to be an
>> implementation
>> +detail, intentionally has no external documentation, and is subject to
>> change
>> +without notice.
>> +
>> +Language frontends for other languages
>> +--
>> +
>> +Clang can be provided with inputs written in non-C-family languages. In
>> such
>> +cases, an 

Re: r285341 - Add documentation describing the components of a complete toolchain including Clang.

2016-10-29 Thread Sean Silva via cfe-commits
This is awesome Richard. Thanks!

-- Sean Silva

On Thu, Oct 27, 2016 at 1:55 PM, Richard Smith via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: rsmith
> Date: Thu Oct 27 15:55:56 2016
> New Revision: 285341
>
> URL: http://llvm.org/viewvc/llvm-project?rev=285341=rev
> Log:
> Add documentation describing the components of a complete toolchain
> including Clang.
>
> Added:
> cfe/trunk/docs/Toolchain.rst
> Modified:
> cfe/trunk/docs/UsersManual.rst
> cfe/trunk/docs/index.rst
>
> Added: cfe/trunk/docs/Toolchain.rst
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/
> Toolchain.rst?rev=285341=auto
> 
> ==
> --- cfe/trunk/docs/Toolchain.rst (added)
> +++ cfe/trunk/docs/Toolchain.rst Thu Oct 27 15:55:56 2016
> @@ -0,0 +1,354 @@
> +===
> +Assembling a Complete Toolchain
> +===
> +
> +.. contents::
> +   :local:
> +   :depth: 2
> +
> +Introduction
> +
> +
> +Clang is only one component in a complete tool chain for C family
> +programming languages. In order to assemble a complete toolchain,
> +additional tools and runtime libraries are required. Clang is designed
> +to interoperate with existing tools and libraries for its target
> +platforms, and the LLVM project provides alternatives for a number
> +of these components.
> +
> +This document describes the required and optional components in a
> +complete toolchain, where to find them, and the supported versions
> +and limitations of each option.
> +
> +.. warning::
> +
> +  This document currently describes Clang configurations on POSIX-like
> +  operating systems with the GCC-compatible ``clang`` driver. When
> +  targeting Windows with the MSVC-compatible ``clang-cl`` driver, some
> +  of the details are different.
> +
> +Tools
> +=
> +
> +.. FIXME: Describe DWARF-related tools
> +
> +A complete compilation of C family programming languages typically
> +involves the following pipeline of tools, some of which are omitted
> +in some compilations:
> +
> +* **Preprocessor**: This performs the actions of the C preprocessor:
> +  expanding #includes and #defines.
> +  The ``-E`` flag instructs Clang to stop after this step.
> +
> +* **Parsing**: This parses and semantically analyzes the source language
> and
> +  builds a source-level intermediate representation ("AST"), producing a
> +  :ref:`precompiled header (PCH) `,
> +  preamble, or
> +  :doc:`precompiled module file (PCM) `,
> +  depending on the input.
> +  The ``-precompile`` flag instructs Clang to stop after this step. This
> is
> +  the default when the input is a header file.
> +
> +* **IR generation**: This converts the source-level intermediate
> representation
> +  into an optimizer-specific intermediate representation (IR); for Clang,
> this
> +  is LLVM IR.
> +  The ``-emit-llvm`` flag instructs Clang to stop after this step. If
> combined
> +  with ``-S``, Clang will produce textual LLVM IR; otherwise, it will
> produce
> +  LLVM IR bitcode.
> +
> +* **Compiler backend**: This converts the intermediate representation
> +  into target-specific assembly code.
> +  The ``-S`` flag instructs Clang to stop after this step.
> +
> +* **Assembler**: This converts target-specific assembly code into
> +  target-specific machine code object files.
> +  The ``-c`` flag instructs Clang to stop after this step.
> +
> +* **Linker**: This combines multiple object files into a single image
> +  (either a shared object or an executable).
> +
> +Clang provides all of these pieces other than the linker. When multiple
> +steps are performed by the same tool, it is common for the steps to be
> +fused together to avoid creating intermediate files.
> +
> +When given an output of one of the above steps as an input, earlier steps
> +are skipped (for instance, a ``.s`` file input will be assembled and
> linked).
> +
> +The Clang driver can be invoked with the ``-###`` flag (this argument
> will need
> +to be escaped under most shells) to see which commands it would run for
> the
> +above steps, without running them. The ``-v`` (verbose) flag will print
> the
> +commands in addition to running them.
> +
> +Clang frontend
> +--
> +
> +The Clang frontend (``clang -cc1``) is used to compile C family
> languages. The
> +command-line interface of the frontend is considered to be an
> implementation
> +detail, intentionally has no external documentation, and is subject to
> change
> +without notice.
> +
> +Language frontends for other languages
> +--
> +
> +Clang can be provided with inputs written in non-C-family languages. In
> such
> +cases, an external tool will be used to compile the input. The
> +currently-supported languages are:
> +
> +* Ada (``-x ada``, ``.ad[bs]``)
> +* Fortran (``-x f95``, ``.f``, ``.f9[05]``, ``.for``, ``.fpp``,
> case-insensitive)
> +* Java (``-x java``)
> +
> +In each case, 

[PATCH] D25925: [clang-tidy] Update cert-err58-cpp to match its new generalised form.

2016-10-29 Thread Malcolm Parsons via cfe-commits
malcolm.parsons updated this revision to Diff 76318.
malcolm.parsons added a comment.

Check calls to operator new.


https://reviews.llvm.org/D25925

Files:
  clang-tidy/cert/StaticObjectExceptionCheck.cpp
  docs/clang-tidy/checks/cert-err58-cpp.rst
  test/clang-tidy/cert-static-object-exception.cpp

Index: test/clang-tidy/cert-static-object-exception.cpp
===
--- test/clang-tidy/cert-static-object-exception.cpp
+++ test/clang-tidy/cert-static-object-exception.cpp
@@ -16,39 +16,94 @@
   explicit V(const char *) {} // Can throw
 };
 
-struct Cleanup
-{
+struct Cleanup {
   ~Cleanup() {}
 };
 
 struct W {
   W(Cleanup c = {}) noexcept(false);
 };
 
+struct X {
+  X(S = {}) noexcept;
+};
+
+struct Y {
+  S s;
+};
+
+struct Z {
+  T t;
+};
+
+int f();
+int g() noexcept(false);
+int h() noexcept(true);
+
+struct UserConv_Bad {
+  operator int() noexcept(false);
+};
+
+struct UserConv_Good {
+  operator int() noexcept;
+};
+
+UserConv_Bad some_bad_func() noexcept;
+UserConv_Good some_good_func() noexcept;
 
 S s;
-// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: construction of 's' with static storage duration may throw an exception that cannot be caught [cert-err58-cpp]
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: initialization of 's' with static storage duration may throw an exception that cannot be caught [cert-err58-cpp]
 // CHECK-MESSAGES: 4:3: note: possibly throwing constructor declared here
 T t; // ok
 U u;
-// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: construction of 'u' with static storage duration may throw an exception that cannot be caught
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: initialization of 'u' with static storage duration may throw an exception that cannot be caught
 // CHECK-MESSAGES: 12:3: note: possibly throwing constructor declared here
 V v("v");
-// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: construction of 'v' with static storage duration may throw an exception that cannot be caught
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: initialization of 'v' with static storage duration may throw an exception that cannot be caught
 // CHECK-MESSAGES: 16:12: note: possibly throwing constructor declared here
 W w;
-// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: construction of 'w' with static storage duration may throw an exception that cannot be caught
-// CHECK-MESSAGES: 25:3: note: possibly throwing constructor declared here
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: initialization of 'w' with static storage duration may throw an exception that cannot be caught
+// CHECK-MESSAGES: 24:3: note: possibly throwing constructor declared here
+X x1(S{});
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: initialization of 'x1' with static storage duration may throw an exception that cannot be caught
+// CHECK-MESSAGES: 4:3: note: possibly throwing constructor declared here
+X x2;
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: initialization of 'x2' with static storage duration may throw an exception that cannot be caught
+// CHECK-MESSAGES: 4:3: note: possibly throwing constructor declared here
+Y y;
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: initialization of 'y' with static storage duration may throw an exception that cannot be caught
+// CHECK-MESSAGES: 31:8: note: possibly throwing constructor declared here
+Z z;
+
+int i = f();
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: initialization of 'i' with static storage duration may throw an exception that cannot be caught
+// CHECK-MESSAGES: 39:5: note: possibly throwing function declared here
+int j = g();
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: initialization of 'j' with static storage duration may throw an exception that cannot be caught
+// CHECK-MESSAGES: 40:5: note: possibly throwing function declared here
+int k = h();
+int l = some_bad_func();
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: initialization of 'l' with static storage duration may throw an exception that cannot be caught
+// CHECK-MESSAGES: 44:3: note: possibly throwing function declared here
+int m = some_good_func();
+
+typedef decltype(sizeof(int)) size_t;
+inline void *operator new(size_t sz, void *here) noexcept { return here; }
+char n[sizeof(int)];
+int *o = new (n) int();
+int *p = new int();
+// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: initialization of 'p' with static storage duration may throw an exception that cannot be caught
+
 
 thread_local S s3;
-// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: construction of 's3' with thread_local storage duration may throw an exception that cannot be caught
+// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: initialization of 's3' with thread_local storage duration may throw an exception that cannot be caught
 thread_local T t3; // ok
 thread_local U u3;
-// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: construction of 'u3' with thread_local storage duration may throw an exception that cannot be caught
+// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: initialization of 'u3' with 

Re: [libcxx] r285382 - Add __libcpp_version file and __libcpp_library_version function.

2016-10-29 Thread Joerg Sonnenberger via cfe-commits
On Fri, Oct 28, 2016 at 06:06:50AM -, Eric Fiselier via cfe-commits wrote:
> Author: ericwf
> Date: Fri Oct 28 01:06:50 2016
> New Revision: 285382
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=285382=rev
> Log:
> Add __libcpp_version file and __libcpp_library_version function.

I really don't see why this is preferable over just checking __config or
the classic approach of including  and checking the macros.

Joerg
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D26032: [ASTMatcher] Add operatorNew matcher for cxxNewExpr

2016-10-29 Thread Malcolm Parsons via cfe-commits
malcolm.parsons updated this revision to Diff 76316.
malcolm.parsons added a comment.

Extend hasDeclaration instead.


https://reviews.llvm.org/D26032

Files:
  docs/LibASTMatchersReference.html
  include/clang/ASTMatchers/ASTMatchers.h
  include/clang/ASTMatchers/ASTMatchersInternal.h
  unittests/ASTMatchers/ASTMatchersTraversalTest.cpp

Index: unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
+++ unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
@@ -241,6 +241,12 @@
 hasDeclaration(namedDecl(hasName("A";
 }
 
+TEST(HasDeclaration, HasDeclarationOfCXXNewExpr) {
+  EXPECT_TRUE(
+  matches("int *A = new int();",
+  cxxNewExpr(hasDeclaration(functionDecl(parameterCountIs(1));
+}
+
 TEST(HasUnderlyingDecl, Matches) {
   EXPECT_TRUE(matches("namespace N { template  void f(T t); }"
   "template  void g() { using N::f; f(T()); }",
Index: include/clang/ASTMatchers/ASTMatchersInternal.h
===
--- include/clang/ASTMatchers/ASTMatchersInternal.h
+++ include/clang/ASTMatchers/ASTMatchersInternal.h
@@ -787,6 +787,14 @@
 return matchesDecl(Node.getConstructor(), Finder, Builder);
   }
 
+  /// \brief Extracts the operator new of the new call and returns whether the
+  /// inner matcher matches on it.
+  bool matchesSpecialized(const CXXNewExpr ,
+  ASTMatchFinder *Finder,
+  BoundNodesTreeBuilder *Builder) const {
+return matchesDecl(Node.getOperatorNew(), Finder, Builder);
+  }
+
   /// \brief Extracts the \c ValueDecl a \c MemberExpr refers to and returns
   /// whether the inner matcher matches on it.
   bool matchesSpecialized(const MemberExpr ,
@@ -1007,11 +1015,11 @@
  TypeLoc, QualType> AdaptativeDefaultToTypes;
 
 /// \brief All types that are supported by HasDeclarationMatcher above.
-typedef TypeList HasDeclarationSupportedTypes;
+ TemplateTypeParmType, TypedefType, UnresolvedUsingType>
+HasDeclarationSupportedTypes;
 
 /// \brief Converts a \c Matcher to a matcher of desired type \c To by
 /// "adapting" a \c To into a \c T.
Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -2450,16 +2450,18 @@
 /// - for CallExpr, the declaration of the callee
 /// - for MemberExpr, the declaration of the referenced member
 /// - for CXXConstructExpr, the declaration of the constructor
+/// - for CXXNewExpr, the declaration of the operator new
 ///
 /// Also usable as Matcher for any T supporting the getDecl() member
 /// function. e.g. various subtypes of clang::Type and various expressions.
 ///
-/// Usable as: Matcher, Matcher,
-///   Matcher, Matcher, Matcher,
-///   Matcher, Matcher, Matcher,
-///   Matcher, Matcher, Matcher,
-///   Matcher, Matcher,
-///   Matcher, Matcher
+/// Usable as: Matcher, Matcher,
+///   Matcher, Matcher, Matcher,
+///   Matcher, Matcher, Matcher,
+///   Matcher, Matcher, Matcher,
+///   Matcher, Matcher,
+///   Matcher, Matcher,
+///   Matcher
 inline internal::PolymorphicMatcherWithParam1<
 internal::HasDeclarationMatcher, internal::Matcher,
 void(internal::HasDeclarationSupportedTypes)>
Index: docs/LibASTMatchersReference.html
===
--- docs/LibASTMatchersReference.html
+++ docs/LibASTMatchersReference.html
@@ -3767,11 +3767,13 @@
 - for CallExpr, the declaration of the callee
 - for MemberExpr, the declaration of the referenced member
 - for CXXConstructExpr, the declaration of the constructor
+- for CXXNewExpr, the declaration of the operator new
 
 Also usable as MatcherT for any T supporting the getDecl() member
 function. e.g. various subtypes of clang::Type and various expressions.
 
 Usable as: Matcherhttp://clang.llvm.org/doxygen/classclang_1_1CallExpr.html;>CallExpr, Matcherhttp://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html;>CXXConstructExpr,
+  Matcherhttp://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html;>CXXNewExpr,
   Matcherhttp://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html;>DeclRefExpr, Matcherhttp://clang.llvm.org/doxygen/classclang_1_1EnumType.html;>EnumType, Matcherhttp://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html;>InjectedClassNameType,
   

[PATCH] D25316: [clang-tidy] Enhance modernize-use-auto to casts

2016-10-29 Thread Malcolm Parsons via cfe-commits
malcolm.parsons added a comment.

ping.


https://reviews.llvm.org/D25316



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D26119: [clang-tidy] Handle bitfields in cppcoreguidelines-pro-type-member-init

2016-10-29 Thread Malcolm Parsons via cfe-commits
malcolm.parsons created this revision.
malcolm.parsons added reviewers: aaron.ballman, alexfh.
malcolm.parsons added a subscriber: cfe-commits.
Herald added a subscriber: nemanjai.

Unnamed bitfields cannot be initialized.
Bitfields cannot be in-class initialized.


https://reviews.llvm.org/D26119

Files:
  clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
  test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp


Index: test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
===
--- test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
+++ test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
@@ -456,3 +456,20 @@
 template  B(U u) {}
   };
 };
+
+struct PositiveBitfieldMember {
+  PositiveBitfieldMember() {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: constructor does not initialize 
these fields: F
+  unsigned F : 5;
+};
+
+struct NegativeUnnamedBitfieldMember {
+  NegativeUnnamedBitfieldMember() {}
+  unsigned : 5;
+};
+
+struct NegativeInitializedBitfieldMembers {
+  NegativeInitializedBitfieldMembers() : F(3) { G = 2; }
+  unsigned F : 5;
+  unsigned G : 5;
+};
Index: clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
===
--- clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
+++ clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
@@ -358,7 +358,7 @@
 if (!F->hasInClassInitializer() &&
 utils::type_traits::isTriviallyDefaultConstructible(F->getType(),
 Context) &&
-!isEmpty(Context, F->getType()))
+!isEmpty(Context, F->getType()) && !F->isUnnamedBitfield())
   FieldsToInit.insert(F);
   });
   if (FieldsToInit.empty())
@@ -407,7 +407,9 @@
   SmallPtrSet FieldsToFix;
   forEachField(ClassDecl, FieldsToInit, true, [&](const FieldDecl *F) {
 // Don't suggest fixes for enums because we don't know a good default.
-if (!F->getType()->isEnumeralType())
+// Don't suggest fixes for bitfields because in-class initialization is not
+// possible.
+if (!F->getType()->isEnumeralType() && !F->isBitField())
   FieldsToFix.insert(F);
   });
   if (FieldsToFix.empty())


Index: test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
===
--- test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
+++ test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
@@ -456,3 +456,20 @@
 template  B(U u) {}
   };
 };
+
+struct PositiveBitfieldMember {
+  PositiveBitfieldMember() {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: constructor does not initialize these fields: F
+  unsigned F : 5;
+};
+
+struct NegativeUnnamedBitfieldMember {
+  NegativeUnnamedBitfieldMember() {}
+  unsigned : 5;
+};
+
+struct NegativeInitializedBitfieldMembers {
+  NegativeInitializedBitfieldMembers() : F(3) { G = 2; }
+  unsigned F : 5;
+  unsigned G : 5;
+};
Index: clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
===
--- clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
+++ clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
@@ -358,7 +358,7 @@
 if (!F->hasInClassInitializer() &&
 utils::type_traits::isTriviallyDefaultConstructible(F->getType(),
 Context) &&
-!isEmpty(Context, F->getType()))
+!isEmpty(Context, F->getType()) && !F->isUnnamedBitfield())
   FieldsToInit.insert(F);
   });
   if (FieldsToInit.empty())
@@ -407,7 +407,9 @@
   SmallPtrSet FieldsToFix;
   forEachField(ClassDecl, FieldsToInit, true, [&](const FieldDecl *F) {
 // Don't suggest fixes for enums because we don't know a good default.
-if (!F->getType()->isEnumeralType())
+// Don't suggest fixes for bitfields because in-class initialization is not
+// possible.
+if (!F->getType()->isEnumeralType() && !F->isBitField())
   FieldsToFix.insert(F);
   });
   if (FieldsToFix.empty())
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r285504 - [AVX-512] Remove masked 128/256-bit sqrt builtins and replace them with unmasked builtins and a select.

2016-10-29 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Sat Oct 29 14:02:10 2016
New Revision: 285504

URL: http://llvm.org/viewvc/llvm-project?rev=285504=rev
Log:
[AVX-512] Remove masked 128/256-bit sqrt builtins and replace them with 
unmasked builtins and a select.

Modified:
cfe/trunk/include/clang/Basic/BuiltinsX86.def
cfe/trunk/lib/Headers/avx512vlintrin.h
cfe/trunk/test/CodeGen/avx512vl-builtins.c

Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsX86.def?rev=285504=285503=285504=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Sat Oct 29 14:02:10 2016
@@ -1251,10 +1251,6 @@ TARGET_BUILTIN(__builtin_ia32_scattersiv
 TARGET_BUILTIN(__builtin_ia32_scattersiv8sf, "vf*UcV8iV8fIi", "", "avx512vl")
 TARGET_BUILTIN(__builtin_ia32_scattersiv8si, "vi*UcV8iV8iIi", "", "avx512vl")
 
-TARGET_BUILTIN(__builtin_ia32_sqrtpd128_mask, "V2dV2dV2dUc", "", "avx512vl")
-TARGET_BUILTIN(__builtin_ia32_sqrtpd256_mask, "V4dV4dV4dUc", "", "avx512vl")
-TARGET_BUILTIN(__builtin_ia32_sqrtps128_mask, "V4fV4fV4fUc", "", "avx512vl")
-TARGET_BUILTIN(__builtin_ia32_sqrtps256_mask, "V8fV8fV8fUc", "", "avx512vl")
 TARGET_BUILTIN(__builtin_ia32_vpermi2vard128_mask, "V4iV4iV4iV4iUc", "", 
"avx512vl")
 TARGET_BUILTIN(__builtin_ia32_vpermi2vard256_mask, "V8iV8iV8iV8iUc", "", 
"avx512vl")
 TARGET_BUILTIN(__builtin_ia32_vpermi2varpd128_mask, "V2dV2dV2LLiV2dUc", "", 
"avx512vl")

Modified: cfe/trunk/lib/Headers/avx512vlintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512vlintrin.h?rev=285504=285503=285504=diff
==
--- cfe/trunk/lib/Headers/avx512vlintrin.h (original)
+++ cfe/trunk/lib/Headers/avx512vlintrin.h Sat Oct 29 14:02:10 2016
@@ -3955,63 +3955,59 @@ _mm256_maskz_scalef_ps (__mmask8 __U, __
(__v8si)(__m256i)(v1), (int)(scale)); })
 
 static __inline__ __m128d __DEFAULT_FN_ATTRS
-_mm_mask_sqrt_pd (__m128d __W, __mmask8 __U, __m128d __A) {
-  return (__m128d) __builtin_ia32_sqrtpd128_mask ((__v2df) __A,
-  (__v2df) __W,
-  (__mmask8) __U);
+_mm_mask_sqrt_pd(__m128d __W, __mmask8 __U, __m128d __A) {
+  return (__m128d)__builtin_ia32_selectpd_128((__mmask8)__U,
+  (__v2df)_mm_sqrt_pd(__A),
+  (__v2df)__W);
 }
 
 static __inline__ __m128d __DEFAULT_FN_ATTRS
-_mm_maskz_sqrt_pd (__mmask8 __U, __m128d __A) {
-  return (__m128d) __builtin_ia32_sqrtpd128_mask ((__v2df) __A,
-  (__v2df)
-  _mm_setzero_pd (),
-  (__mmask8) __U);
+_mm_maskz_sqrt_pd(__mmask8 __U, __m128d __A) {
+  return (__m128d)__builtin_ia32_selectpd_128((__mmask8)__U,
+  (__v2df)_mm_sqrt_pd(__A),
+  (__v2df)_mm_setzero_pd());
 }
 
 static __inline__ __m256d __DEFAULT_FN_ATTRS
-_mm256_mask_sqrt_pd (__m256d __W, __mmask8 __U, __m256d __A) {
-  return (__m256d) __builtin_ia32_sqrtpd256_mask ((__v4df) __A,
-  (__v4df) __W,
-  (__mmask8) __U);
+_mm256_mask_sqrt_pd(__m256d __W, __mmask8 __U, __m256d __A) {
+  return (__m256d)__builtin_ia32_selectpd_256((__mmask8)__U,
+  (__v4df)_mm256_sqrt_pd(__A),
+  (__v4df)__W);
 }
 
 static __inline__ __m256d __DEFAULT_FN_ATTRS
-_mm256_maskz_sqrt_pd (__mmask8 __U, __m256d __A) {
-  return (__m256d) __builtin_ia32_sqrtpd256_mask ((__v4df) __A,
-  (__v4df)
-  _mm256_setzero_pd (),
-  (__mmask8) __U);
+_mm256_maskz_sqrt_pd(__mmask8 __U, __m256d __A) {
+  return (__m256d)__builtin_ia32_selectpd_256((__mmask8)__U,
+  (__v4df)_mm256_sqrt_pd(__A),
+  (__v4df)_mm256_setzero_pd());
 }
 
 static __inline__ __m128 __DEFAULT_FN_ATTRS
-_mm_mask_sqrt_ps (__m128 __W, __mmask8 __U, __m128 __A) {
-  return (__m128) __builtin_ia32_sqrtps128_mask ((__v4sf) __A,
- (__v4sf) __W,
- (__mmask8) __U);
+_mm_mask_sqrt_ps(__m128 __W, __mmask8 __U, __m128 __A) {
+  return (__m128)__builtin_ia32_selectps_128((__mmask8)__U,
+ (__v4sf)_mm_sqrt_ps(__A),
+ (__v4sf)__W);
 }
 
 static __inline__ __m128 __DEFAULT_FN_ATTRS
-_mm_maskz_sqrt_ps (__mmask8 __U, __m128 __A) {
-  return (__m128) __builtin_ia32_sqrtps128_mask ((__v4sf) __A,
- (__v4sf)
- _mm_setzero_ps (),
- (__mmask8) __U);
+_mm_maskz_sqrt_ps(__mmask8 __U, __m128 __A) {
+  return (__m128)__builtin_ia32_selectps_128((__mmask8)__U,
+ 

r285502 - [AVX-512] Remove masked 128/256-bit floating point max/min builtins. Use unmasked builtins with select instead.

2016-10-29 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Sat Oct 29 14:02:03 2016
New Revision: 285502

URL: http://llvm.org/viewvc/llvm-project?rev=285502=rev
Log:
[AVX-512] Remove masked 128/256-bit floating point max/min builtins. Use 
unmasked builtins with select instead.

Modified:
cfe/trunk/include/clang/Basic/BuiltinsX86.def
cfe/trunk/lib/Headers/avx512vlintrin.h
cfe/trunk/test/CodeGen/avx512vl-builtins.c

Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsX86.def?rev=285502=285501=285502=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Sat Oct 29 14:02:03 2016
@@ -1220,14 +1220,6 @@ TARGET_BUILTIN(__builtin_ia32_getexppd12
 TARGET_BUILTIN(__builtin_ia32_getexppd256_mask, "V4dV4dV4dUc", "", "avx512vl")
 TARGET_BUILTIN(__builtin_ia32_getexpps128_mask, "V4fV4fV4fUc", "", "avx512vl")
 TARGET_BUILTIN(__builtin_ia32_getexpps256_mask, "V8fV8fV8fUc", "", "avx512vl")
-TARGET_BUILTIN(__builtin_ia32_maxpd_mask, "V2dV2dV2dV2dUc", "", "avx512vl")
-TARGET_BUILTIN(__builtin_ia32_maxpd256_mask, "V4dV4dV4dV4dUc", "", "avx512vl")
-TARGET_BUILTIN(__builtin_ia32_maxps_mask, "V4fV4fV4fV4fUc", "", "avx512vl")
-TARGET_BUILTIN(__builtin_ia32_maxps256_mask, "V8fV8fV8fV8fUc", "", "avx512vl")
-TARGET_BUILTIN(__builtin_ia32_minpd_mask, "V2dV2dV2dV2dUc", "", "avx512vl")
-TARGET_BUILTIN(__builtin_ia32_minpd256_mask, "V4dV4dV4dV4dUc", "", "avx512vl")
-TARGET_BUILTIN(__builtin_ia32_minps_mask, "V4fV4fV4fV4fUc", "", "avx512vl")
-TARGET_BUILTIN(__builtin_ia32_minps256_mask, "V8fV8fV8fV8fUc", "", "avx512vl")
 TARGET_BUILTIN(__builtin_ia32_pabsq128_mask, "V2LLiV2LLiV2LLiUc", "", 
"avx512vl")
 TARGET_BUILTIN(__builtin_ia32_pabsq256_mask, "V4LLiV4LLiV4LLiUc", "", 
"avx512vl")
 TARGET_BUILTIN(__builtin_ia32_pmaxsq128_mask, "V2LLiV2LLiV2LLiV2LLiUc", "", 
"avx512vl")

Modified: cfe/trunk/lib/Headers/avx512vlintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512vlintrin.h?rev=285502=285501=285502=diff
==
--- cfe/trunk/lib/Headers/avx512vlintrin.h (original)
+++ cfe/trunk/lib/Headers/avx512vlintrin.h Sat Oct 29 14:02:03 2016
@@ -3064,141 +3064,115 @@ _mm256_maskz_getexp_ps (__mmask8 __U, __
 }
 
 static __inline__ __m128d __DEFAULT_FN_ATTRS
-_mm_mask_max_pd (__m128d __W, __mmask8 __U, __m128d __A, __m128d __B) {
-  return (__m128d) __builtin_ia32_maxpd_mask ((__v2df) __A,
-(__v2df) __B,
-(__v2df) __W,
-(__mmask8) __U);
+_mm_mask_max_pd(__m128d __W, __mmask8 __U, __m128d __A, __m128d __B) {
+  return (__m128d)__builtin_ia32_selectpd_128((__mmask8)__U,
+  (__v2df)_mm_max_pd(__A, __B),
+  (__v2df)__W);
 }
 
 static __inline__ __m128d __DEFAULT_FN_ATTRS
-_mm_maskz_max_pd (__mmask8 __U, __m128d __A, __m128d __B) {
-  return (__m128d) __builtin_ia32_maxpd_mask ((__v2df) __A,
-(__v2df) __B,
-(__v2df)
-_mm_setzero_pd (),
-(__mmask8) __U);
+_mm_maskz_max_pd(__mmask8 __U, __m128d __A, __m128d __B) {
+  return (__m128d)__builtin_ia32_selectpd_128((__mmask8)__U,
+  (__v2df)_mm_max_pd(__A, __B),
+  (__v2df)_mm_setzero_pd());
 }
 
 static __inline__ __m256d __DEFAULT_FN_ATTRS
-_mm256_mask_max_pd (__m256d __W, __mmask8 __U, __m256d __A,
-__m256d __B) {
-  return (__m256d) __builtin_ia32_maxpd256_mask ((__v4df) __A,
- (__v4df) __B,
- (__v4df) __W,
- (__mmask8) __U);
+_mm256_mask_max_pd(__m256d __W, __mmask8 __U, __m256d __A, __m256d __B) {
+  return (__m256d)__builtin_ia32_selectpd_256((__mmask8)__U,
+  (__v4df)_mm256_max_pd(__A, __B),
+  (__v4df)__W);
 }
 
 static __inline__ __m256d __DEFAULT_FN_ATTRS
-_mm256_maskz_max_pd (__mmask8 __U, __m256d __A, __m256d __B) {
-  return (__m256d) __builtin_ia32_maxpd256_mask ((__v4df) __A,
- (__v4df) __B,
- (__v4df)
- _mm256_setzero_pd (),
- (__mmask8) __U);
+_mm256_maskz_max_pd(__mmask8 __U, __m256d __A, __m256d __B) {
+  return (__m256d)__builtin_ia32_selectpd_256((__mmask8)__U,
+  (__v4df)_mm256_max_pd(__A, __B),
+  (__v4df)_mm256_setzero_pd());
 }
 
 static __inline__ __m128 __DEFAULT_FN_ATTRS
-_mm_mask_max_ps (__m128 __W, __mmask8 __U, __m128 __A, __m128 __B) {
-  return (__m128) __builtin_ia32_maxps_mask ((__v4sf) __A,
-   (__v4sf) __B,
-   (__v4sf) __W,
-   (__mmask8) __U);
+_mm_mask_max_ps(__m128 __W, __mmask8 __U, __m128 

r285505 - [AVX-512] Remove 128/256-bit masked pmulhrsw/pmulhuw/pmulhw builtins and use unmasked builtins and select instead.

2016-10-29 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Sat Oct 29 14:02:14 2016
New Revision: 285505

URL: http://llvm.org/viewvc/llvm-project?rev=285505=rev
Log:
[AVX-512] Remove 128/256-bit masked pmulhrsw/pmulhuw/pmulhw builtins and use 
unmasked builtins and select instead.

Modified:
cfe/trunk/include/clang/Basic/BuiltinsX86.def
cfe/trunk/lib/Headers/avx512vlbwintrin.h
cfe/trunk/test/CodeGen/avx512vlbw-builtins.c

Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsX86.def?rev=285505=285504=285505=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Sat Oct 29 14:02:14 2016
@@ -1324,12 +1324,6 @@ TARGET_BUILTIN(__builtin_ia32_pmovuswb12
 TARGET_BUILTIN(__builtin_ia32_pmovuswb256_mask, "V16cV16sV16cUs", "", 
"avx512vl,avx512bw")
 TARGET_BUILTIN(__builtin_ia32_pmovwb128_mask, "V16cV8sV16cUc", "", 
"avx512vl,avx512bw")
 TARGET_BUILTIN(__builtin_ia32_pmovwb256_mask, "V16cV16sV16cUs", "", 
"avx512vl,avx512bw")
-TARGET_BUILTIN(__builtin_ia32_pmulhrsw128_mask, "V8sV8sV8sV8sUc", "", 
"avx512vl,avx512bw")
-TARGET_BUILTIN(__builtin_ia32_pmulhrsw256_mask, "V16sV16sV16sV16sUs", "", 
"avx512vl,avx512bw")
-TARGET_BUILTIN(__builtin_ia32_pmulhuw128_mask, "V8sV8sV8sV8sUc", "", 
"avx512vl,avx512bw")
-TARGET_BUILTIN(__builtin_ia32_pmulhuw256_mask, "V16sV16sV16sV16sUs", "", 
"avx512vl,avx512bw")
-TARGET_BUILTIN(__builtin_ia32_pmulhw128_mask, "V8sV8sV8sV8sUc", "", 
"avx512vl,avx512bw")
-TARGET_BUILTIN(__builtin_ia32_pmulhw256_mask, "V16sV16sV16sV16sUs", "", 
"avx512vl,avx512bw")
 TARGET_BUILTIN(__builtin_ia32_cvtpd2qq512_mask, "V8LLiV8dV8LLiUcIi", "", 
"avx512dq")
 TARGET_BUILTIN(__builtin_ia32_cvtpd2uqq512_mask, "V8LLiV8dV8LLiUcIi", "", 
"avx512dq")
 TARGET_BUILTIN(__builtin_ia32_cvtps2qq512_mask, "V8LLiV8fV8LLiUcIi", "", 
"avx512dq")

Modified: cfe/trunk/lib/Headers/avx512vlbwintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512vlbwintrin.h?rev=285505=285504=285505=diff
==
--- cfe/trunk/lib/Headers/avx512vlbwintrin.h (original)
+++ cfe/trunk/lib/Headers/avx512vlbwintrin.h Sat Oct 29 14:02:14 2016
@@ -1892,104 +1892,89 @@ _mm256_mask_cvtusepi16_storeu_epi8 (void
 {
   __builtin_ia32_pmovuswb256mem_mask ((__v16qi*) __P, (__v16hi) __A, __M);
 }
+
 static __inline__ __m128i __DEFAULT_FN_ATTRS
-_mm_mask_mulhrs_epi16 (__m128i __W, __mmask8 __U, __m128i __X, __m128i __Y) {
-  return (__m128i) __builtin_ia32_pmulhrsw128_mask ((__v8hi) __X,
-   (__v8hi) __Y,
-   (__v8hi) __W,
-   (__mmask8) __U);
+_mm_mask_mulhrs_epi16(__m128i __W, __mmask8 __U, __m128i __X, __m128i __Y) {
+  return (__m128i)__builtin_ia32_selectw_128((__mmask8)__U,
+ (__v8hi)_mm_mulhrs_epi16(__X, 
__Y),
+ (__v8hi)__W);
 }
 
 static __inline__ __m128i __DEFAULT_FN_ATTRS
-_mm_maskz_mulhrs_epi16 (__mmask8 __U, __m128i __X, __m128i __Y) {
-  return (__m128i) __builtin_ia32_pmulhrsw128_mask ((__v8hi) __X,
-   (__v8hi) __Y,
-  (__v8hi) _mm_setzero_si128(),
-   (__mmask8) __U);
+_mm_maskz_mulhrs_epi16(__mmask8 __U, __m128i __X, __m128i __Y) {
+  return (__m128i)__builtin_ia32_selectw_128((__mmask8)__U,
+ (__v8hi)_mm_mulhrs_epi16(__X, 
__Y),
+ (__v8hi)_mm_setzero_si128());
 }
 
 static __inline__ __m256i __DEFAULT_FN_ATTRS
-_mm256_mask_mulhrs_epi16 (__m256i __W, __mmask16 __U, __m256i __X, __m256i 
__Y) {
-  return (__m256i) __builtin_ia32_pmulhrsw256_mask ((__v16hi) __X,
-   (__v16hi) __Y,
-   (__v16hi) __W,
-   (__mmask16) __U);
+_mm256_mask_mulhrs_epi16(__m256i __W, __mmask16 __U, __m256i __X, __m256i __Y) 
{
+  return (__m256i)__builtin_ia32_selectw_256((__mmask16)__U,
+ (__v16hi)_mm256_mulhrs_epi16(__X, 
__Y),
+ (__v16hi)__W);
 }
 
 static __inline__ __m256i __DEFAULT_FN_ATTRS
-_mm256_maskz_mulhrs_epi16 (__mmask16 __U, __m256i __X, __m256i __Y) {
-  return (__m256i) __builtin_ia32_pmulhrsw256_mask ((__v16hi) __X,
-   (__v16hi) __Y,
-   (__v16hi) _mm256_setzero_si256(),
-   (__mmask16) __U);
+_mm256_maskz_mulhrs_epi16(__mmask16 __U, __m256i __X, __m256i __Y) {
+  return (__m256i)__builtin_ia32_selectw_256((__mmask16)__U,
+ (__v16hi)_mm256_mulhrs_epi16(__X, 
__Y),
+ (__v16hi)_mm256_setzero_si256());
 }
 
 static __inline__ __m128i __DEFAULT_FN_ATTRS
-_mm_mask_mulhi_epu16 (__m128i __W, __mmask8 __U, __m128i __A,
-  __m128i __B) {
-  return (__m128i) __builtin_ia32_pmulhuw128_mask 

r285503 - [AVX-512] Remove masked 128/256-bit pmuludq/pmuldq builtins and replace them with unmasked builtins and a select.

2016-10-29 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Sat Oct 29 14:02:07 2016
New Revision: 285503

URL: http://llvm.org/viewvc/llvm-project?rev=285503=rev
Log:
[AVX-512] Remove masked 128/256-bit pmuludq/pmuldq builtins and replace them 
with unmasked builtins and a select.

Modified:
cfe/trunk/include/clang/Basic/BuiltinsX86.def
cfe/trunk/lib/Headers/avx512vlintrin.h
cfe/trunk/test/CodeGen/avx512vl-builtins.c

Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsX86.def?rev=285503=285502=285503=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Sat Oct 29 14:02:07 2016
@@ -1076,11 +1076,6 @@ TARGET_BUILTIN(__builtin_ia32_ucmpd512_m
 TARGET_BUILTIN(__builtin_ia32_ucmpq512_mask, "UcV8LLiV8LLiIiUc", "", "avx512f")
 TARGET_BUILTIN(__builtin_ia32_ucmpw512_mask, "UiV32sV32sIiUi", "", "avx512bw")
 
-TARGET_BUILTIN(__builtin_ia32_pmuldq256_mask, "V4LLiV8iV8iV4LLiUc", "", 
"avx512vl")
-TARGET_BUILTIN(__builtin_ia32_pmuldq128_mask, "V2LLiV4iV4iV2LLiUc", "", 
"avx512vl")
-TARGET_BUILTIN(__builtin_ia32_pmuludq256_mask, "V4LLiV8iV8iV4LLiUc", "", 
"avx512vl")
-TARGET_BUILTIN(__builtin_ia32_pmuludq128_mask, "V2LLiV4iV4iV2LLiUc", "", 
"avx512vl")
-
 TARGET_BUILTIN(__builtin_ia32_pabsb512_mask, "V64cV64cV64cULLi", "", 
"avx512bw")
 TARGET_BUILTIN(__builtin_ia32_pabsw512_mask, "V32sV32sV32sUi", "", "avx512bw")
 TARGET_BUILTIN(__builtin_ia32_packssdw512_mask, "V32sV16iV16iV32sUi", "", 
"avx512bw")

Modified: cfe/trunk/lib/Headers/avx512vlintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512vlintrin.h?rev=285503=285502=285503=diff
==
--- cfe/trunk/lib/Headers/avx512vlintrin.h (original)
+++ cfe/trunk/lib/Headers/avx512vlintrin.h Sat Oct 29 14:02:07 2016
@@ -744,79 +744,67 @@ _mm_maskz_sub_epi64(__mmask8 __U, __m128
 }
 
 static __inline__ __m256i __DEFAULT_FN_ATTRS
-_mm256_mask_mul_epi32 (__m256i __W, __mmask8 __M, __m256i __X,
-   __m256i __Y)
+_mm256_mask_mul_epi32(__m256i __W, __mmask8 __M, __m256i __X, __m256i __Y)
 {
-  return (__m256i) __builtin_ia32_pmuldq256_mask ((__v8si) __X,
-  (__v8si) __Y,
-  (__v4di) __W, __M);
+  return (__m256i)__builtin_ia32_selectq_256((__mmask8)__M,
+ (__v4di)_mm256_mul_epi32(__X, 
__Y),
+ (__v4di)__W);
 }
 
 static __inline__ __m256i __DEFAULT_FN_ATTRS
-_mm256_maskz_mul_epi32 (__mmask8 __M, __m256i __X, __m256i __Y)
+_mm256_maskz_mul_epi32(__mmask8 __M, __m256i __X, __m256i __Y)
 {
-  return (__m256i) __builtin_ia32_pmuldq256_mask ((__v8si) __X,
-  (__v8si) __Y,
-  (__v4di)
-  _mm256_setzero_si256 (),
-  __M);
+  return (__m256i)__builtin_ia32_selectq_256((__mmask8)__M,
+ (__v4di)_mm256_mul_epi32(__X, 
__Y),
+ (__v4di)_mm256_setzero_si256());
 }
 
 static __inline__ __m128i __DEFAULT_FN_ATTRS
-_mm_mask_mul_epi32 (__m128i __W, __mmask8 __M, __m128i __X,
-__m128i __Y)
+_mm_mask_mul_epi32(__m128i __W, __mmask8 __M, __m128i __X, __m128i __Y)
 {
-  return (__m128i) __builtin_ia32_pmuldq128_mask ((__v4si) __X,
-  (__v4si) __Y,
-  (__v2di) __W, __M);
+  return (__m128i)__builtin_ia32_selectq_128((__mmask8)__M,
+ (__v2di)_mm_mul_epi32(__X, __Y),
+ (__v2di)__W);
 }
 
 static __inline__ __m128i __DEFAULT_FN_ATTRS
-_mm_maskz_mul_epi32 (__mmask8 __M, __m128i __X, __m128i __Y)
+_mm_maskz_mul_epi32(__mmask8 __M, __m128i __X, __m128i __Y)
 {
-  return (__m128i) __builtin_ia32_pmuldq128_mask ((__v4si) __X,
-  (__v4si) __Y,
-  (__v2di)
-  _mm_setzero_si128 (),
-  __M);
+  return (__m128i)__builtin_ia32_selectq_128((__mmask8)__M,
+ (__v2di)_mm_mul_epi32(__X, __Y),
+ (__v2di)_mm_setzero_si128());
 }
 
 static __inline__ __m256i __DEFAULT_FN_ATTRS
-_mm256_mask_mul_epu32 (__m256i __W, __mmask8 __M, __m256i __X,
-   __m256i __Y)
+_mm256_mask_mul_epu32(__m256i __W, __mmask8 __M, __m256i __X, __m256i __Y)
 {
-  return (__m256i) __builtin_ia32_pmuludq256_mask ((__v8si) __X,
-   (__v8si) __Y,
-   (__v4di) __W, __M);
+  return (__m256i)__builtin_ia32_selectq_256((__mmask8)__M,
+ (__v4di)_mm256_mul_epu32(__X, 
__Y),
+ (__v4di)__W);
 }
 
 static __inline__ __m256i __DEFAULT_FN_ATTRS
-_mm256_maskz_mul_epu32 (__mmask8 __M, __m256i __X, __m256i __Y)
+_mm256_maskz_mul_epu32(__mmask8 __M, __m256i 

[PATCH] D23765: Fix for clang PR 29087

2016-10-29 Thread Richard Smith via cfe-commits
rsmith added inline comments.



Comment at: lib/Sema/SemaExprCXX.cpp:4390-4391
 // resolution point.
 if (isa(ND))
   continue;
+// UsingDecl itself is not a constructor

You also need to handle the case of an inherited constructor template 
(`isa(ND->getUnderlyingDecl())` will do the right thing 
in both cases).



Comment at: lib/Sema/SemaExprCXX.cpp:4395-4397
+const CXXConstructorDecl *Constructor = nullptr;
+if (auto *CSD = dyn_cast(ND)) {
+  Constructor = cast(CSD->getTargetDecl());

This is better written as

  auto *Constructor = cast(ND->getUnderlyingDecl());



Comment at: lib/Sema/SemaExprCXX.cpp:4398-4401
+  // Default constructor and copy/move constructor are not inherited.
+  if (Constructor->isDefaultConstructor() ||
+  Constructor->isCopyOrMoveConstructor())
+continue;

This is not necessary: Sema has already filtered out the ones that aren't 
inherited.


https://reviews.llvm.org/D23765



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D13419: Fix several problems at the intersection of template instantiations and visibility

2016-10-29 Thread Richard Smith via cfe-commits
rsmith added inline comments.



Comment at: lib/AST/DeclCXX.cpp:1349-1354
+  while (!CTD->isMemberSpecialization()) {
+auto *NewCTD = CTD->getInstantiatedFromMemberTemplate();
+if (!NewCTD)
   break;
 CTD = NewCTD;
   }

loladiro wrote:
> rsmith wrote:
> > The same bug exists in `VarDecl::getTemplateInstantiationPattern`; can you 
> > fix it there too?
> Do you have a test case that shows a problem with the current definition of 
> that function? Would like to include it if possible. I tried cooking one up, 
> but wasn't particularly successful.
Since this is only currently used by the modules visibility code, you'd 
presumably need something like this:
```
  // submodule a.x
  template struct A {
template static const int n;
  };
```
```
  // submodule a.y
  import a.x
  template template const int A::n = 1;
```
```
  // submodule a.z
  import a.x
  template<> template const int A::n = 2;
```
```
  // test
  import a.z
  // I expect this to fail because we would incorrectly check to see whether 
the definition from a.y is visible, because we never check whether the 
definition from a.z is a member specialization.
  static_assert(A::n == 2);


Repository:
  rL LLVM

https://reviews.llvm.org/D13419



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r285500 - Factor finding of libc++ include path out of building -cc1 arguments.

2016-10-29 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Sat Oct 29 12:28:48 2016
New Revision: 285500

URL: http://llvm.org/viewvc/llvm-project?rev=285500=rev
Log:
Factor finding of libc++ include path out of building -cc1 arguments.

Modified:
cfe/trunk/lib/Driver/ToolChains.cpp
cfe/trunk/lib/Driver/ToolChains.h

Modified: cfe/trunk/lib/Driver/ToolChains.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=285500=285499=285500=diff
==
--- cfe/trunk/lib/Driver/ToolChains.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains.cpp Sat Oct 29 12:28:48 2016
@@ -2836,6 +2836,38 @@ bool Generic_GCC::IsIntegratedAssemblerD
   }
 }
 
+void Generic_GCC::AddClangCXXStdlibIncludeArgs(const ArgList ,
+   ArgStringList ) const {
+  if (DriverArgs.hasArg(options::OPT_nostdlibinc) ||
+  DriverArgs.hasArg(options::OPT_nostdincxx))
+return;
+
+  switch (GetCXXStdlibType(DriverArgs)) {
+  case ToolChain::CST_Libcxx: {
+std::string Path = findLibCxxIncludePath();
+if (!Path.empty())
+  addSystemInclude(DriverArgs, CC1Args, Path);
+break;
+  }
+
+  case ToolChain::CST_Libstdcxx:
+addLibStdCxxIncludePaths(DriverArgs, CC1Args);
+break;
+  }
+}
+
+std::string Generic_GCC::findLibCxxIncludePath() const {
+  // FIXME: The Linux behavior would probaby be a better approach here.
+  return getDriver().SysRoot + "/usr/include/c++/v1";
+}
+
+void
+Generic_GCC::addLibStdCxxIncludePaths(const llvm::opt::ArgList ,
+  llvm::opt::ArgStringList ) const 
{
+  // By default, we don't assume we know where libstdc++ might be installed.
+  // FIXME: If we have a valid GCCInstallation, use it.
+}
+
 /// \brief Helper to add the variant paths of a libstdc++ installation.
 bool Generic_GCC::addLibStdCXXIncludePaths(
 Twine Base, Twine Suffix, StringRef GCCTriple, StringRef 
GCCMultiarchTriple,
@@ -3003,25 +3035,16 @@ MipsLLVMToolChain::GetCXXStdlibType(cons
   return ToolChain::CST_Libcxx;
 }
 
-void MipsLLVMToolChain::AddClangCXXStdlibIncludeArgs(
-const ArgList , ArgStringList ) const {
-  if (DriverArgs.hasArg(options::OPT_nostdlibinc) ||
-  DriverArgs.hasArg(options::OPT_nostdincxx))
-return;
-
-  assert((GetCXXStdlibType(DriverArgs) == ToolChain::CST_Libcxx) &&
- "Only -lc++ (aka libcxx) is suported in this toolchain.");
-
-  const auto  = Multilibs.includeDirsCallback();
-  if (Callback) {
+std::string MipsLLVMToolChain::findLibCxxIncludePath() const {
+  if (const auto  = Multilibs.includeDirsCallback()) {
 for (std::string Path : Callback(SelectedMultilib)) {
   Path = getDriver().getInstalledDir() + Path + "/c++/v1";
   if (llvm::sys::fs::exists(Path)) {
-addSystemInclude(DriverArgs, CC1Args, Path);
-break;
+return Path;
   }
 }
   }
+  return "";
 }
 
 void MipsLLVMToolChain::AddCXXStdlibLibArgs(const ArgList ,
@@ -3168,15 +3191,14 @@ void HexagonToolChain::AddClangSystemInc
   addExternCSystemInclude(DriverArgs, CC1Args, TargetDir + "/hexagon/include");
 }
 
-void HexagonToolChain::AddClangCXXStdlibIncludeArgs(
-const ArgList , ArgStringList ) const {
-  if (DriverArgs.hasArg(options::OPT_nostdlibinc) ||
-  DriverArgs.hasArg(options::OPT_nostdincxx))
-return;
 
+void HexagonToolChain::addLibStdCxxIncludePaths(
+const llvm::opt::ArgList ,
+llvm::opt::ArgStringList ) const {
   const Driver  = getDriver();
   std::string TargetDir = getHexagonTargetDir(D.InstalledDir, D.PrefixDirs);
-  addSystemInclude(DriverArgs, CC1Args, TargetDir + "/hexagon/include/c++");
+  addLibStdCXXIncludePaths(TargetDir, "/hexagon/include/c++", "", "", "", "",
+   DriverArgs, CC1Args);
 }
 
 ToolChain::CXXStdlibType
@@ -3334,37 +3356,25 @@ void NaClToolChain::AddCXXStdlibLibArgs(
   CmdArgs.push_back("-lc++");
 }
 
-void NaClToolChain::AddClangCXXStdlibIncludeArgs(const ArgList ,
- ArgStringList ) const 
{
+std::string NaClToolChain::findLibCxxIncludePath() const {
   const Driver  = getDriver();
-  if (DriverArgs.hasArg(options::OPT_nostdlibinc) ||
-  DriverArgs.hasArg(options::OPT_nostdincxx))
-return;
-
-  // Check for -stdlib= flags. We only support libc++ but this consumes the arg
-  // if the value is libc++, and emits an error for other values.
-  GetCXXStdlibType(DriverArgs);
 
   SmallString<128> P(D.Dir + "/../");
   switch (getTriple().getArch()) {
   case llvm::Triple::arm:
 llvm::sys::path::append(P, "arm-nacl/include/c++/v1");
-addSystemInclude(DriverArgs, CC1Args, P.str());
-break;
+return P.str();
   case llvm::Triple::x86:
 llvm::sys::path::append(P, "x86_64-nacl/include/c++/v1");
-addSystemInclude(DriverArgs, CC1Args, P.str());
-break;
+return P.str();
   case llvm::Triple::x86_64:
 llvm::sys::path::append(P, "x86_64-nacl/include/c++/v1");
-

[PATCH] D26118: [clang-tidy] Change readability-redundant-member-init to get base type from constructor

2016-10-29 Thread Malcolm Parsons via cfe-commits
malcolm.parsons created this revision.
malcolm.parsons added reviewers: aaron.ballman, Eugene.Zelenko.
malcolm.parsons added a subscriber: cfe-commits.

Fixes PR30835


https://reviews.llvm.org/D26118

Files:
  clang-tidy/readability/RedundantMemberInitCheck.cpp


Index: clang-tidy/readability/RedundantMemberInitCheck.cpp
===
--- clang-tidy/readability/RedundantMemberInitCheck.cpp
+++ clang-tidy/readability/RedundantMemberInitCheck.cpp
@@ -54,7 +54,7 @@
 } else {
   diag(Init->getSourceLocation(),
"initializer for base class %0 is redundant")
-  << Init->getTypeSourceInfo()->getType()
+  << Construct->getType()
   << FixItHint::CreateRemoval(Init->getSourceRange());
 }
   }


Index: clang-tidy/readability/RedundantMemberInitCheck.cpp
===
--- clang-tidy/readability/RedundantMemberInitCheck.cpp
+++ clang-tidy/readability/RedundantMemberInitCheck.cpp
@@ -54,7 +54,7 @@
 } else {
   diag(Init->getSourceLocation(),
"initializer for base class %0 is redundant")
-  << Init->getTypeSourceInfo()->getType()
+  << Construct->getType()
   << FixItHint::CreateRemoval(Init->getSourceRange());
 }
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D26117: [Devirtualization] Decorate vfunction load with invariant.load

2016-10-29 Thread Piotr Padlewski via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL285497: [Devirtualization] Decorate vfunction load with 
invariant.load (authored by Prazek).

Changed prior to commit:
  https://reviews.llvm.org/D26117?vs=76303=76306#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D26117

Files:
  cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
  cfe/trunk/test/CodeGenCXX/virtual-function-calls.cpp


Index: cfe/trunk/test/CodeGenCXX/virtual-function-calls.cpp
===
--- cfe/trunk/test/CodeGenCXX/virtual-function-calls.cpp
+++ cfe/trunk/test/CodeGenCXX/virtual-function-calls.cpp
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 %s -triple %itanium_abi_triple -std=c++11 -emit-llvm -o - | 
FileCheck %s
+// RUN: %clang_cc1 %s -triple %itanium_abi_triple -std=c++11 -emit-llvm -o - 
-fstrict-vtable-pointers -O1 | FileCheck --check-prefix=CHECK-INVARIANT %s
 
 // PR5021
 namespace PR5021 {
@@ -42,10 +43,14 @@
 [[noreturn]] virtual void f();
   };
 
-  // CHECK: @_ZN15VirtualNoreturn1f
+  // CHECK-LABEL: @_ZN15VirtualNoreturn1f
+  // CHECK-INVARIANT-LABEL: define void @_ZN15VirtualNoreturn1f
   void f(A *p) {
 p->f();
 // CHECK: call {{.*}}void %{{[^#]*$}}
 // CHECK-NOT: unreachable
+// CHECK-INVARIANT: load {{.*}} !invariant.load ![[EMPTY_NODE:[0-9]+]]
   }
 }
+
+// CHECK-INVARIANT: ![[EMPTY_NODE]] = !{}
Index: cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
===
--- cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
+++ cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
@@ -1623,7 +1623,22 @@
 
 llvm::Value *VFuncPtr =
 CGF.Builder.CreateConstInBoundsGEP1_64(VTable, VTableIndex, "vfn");
-VFunc = CGF.Builder.CreateAlignedLoad(VFuncPtr, CGF.getPointerAlign());
+auto *VFuncLoad =
+CGF.Builder.CreateAlignedLoad(VFuncPtr, CGF.getPointerAlign());
+
+// Add !invariant.load md to virtual function load to indicate that
+// function didn't change inside vtable.
+// It's safe to add it without -fstrict-vtable-pointers, but it would not
+// help in devirtualization because it will only matter if we will have 2
+// the same virtual function loads from the same vtable load, which won't
+// happen without enabled devirtualization with -fstrict-vtable-pointers.
+if (CGM.getCodeGenOpts().OptimizationLevel > 0 &&
+CGM.getCodeGenOpts().StrictVTablePointers)
+  VFuncLoad->setMetadata(
+  llvm::LLVMContext::MD_invariant_load,
+  llvm::MDNode::get(CGM.getLLVMContext(),
+llvm::ArrayRef()));
+VFunc = VFuncLoad;
   }
 
   CGCallee Callee(MethodDecl, VFunc);


Index: cfe/trunk/test/CodeGenCXX/virtual-function-calls.cpp
===
--- cfe/trunk/test/CodeGenCXX/virtual-function-calls.cpp
+++ cfe/trunk/test/CodeGenCXX/virtual-function-calls.cpp
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 %s -triple %itanium_abi_triple -std=c++11 -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 %s -triple %itanium_abi_triple -std=c++11 -emit-llvm -o - -fstrict-vtable-pointers -O1 | FileCheck --check-prefix=CHECK-INVARIANT %s
 
 // PR5021
 namespace PR5021 {
@@ -42,10 +43,14 @@
 [[noreturn]] virtual void f();
   };
 
-  // CHECK: @_ZN15VirtualNoreturn1f
+  // CHECK-LABEL: @_ZN15VirtualNoreturn1f
+  // CHECK-INVARIANT-LABEL: define void @_ZN15VirtualNoreturn1f
   void f(A *p) {
 p->f();
 // CHECK: call {{.*}}void %{{[^#]*$}}
 // CHECK-NOT: unreachable
+// CHECK-INVARIANT: load {{.*}} !invariant.load ![[EMPTY_NODE:[0-9]+]]
   }
 }
+
+// CHECK-INVARIANT: ![[EMPTY_NODE]] = !{}
Index: cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
===
--- cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
+++ cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
@@ -1623,7 +1623,22 @@
 
 llvm::Value *VFuncPtr =
 CGF.Builder.CreateConstInBoundsGEP1_64(VTable, VTableIndex, "vfn");
-VFunc = CGF.Builder.CreateAlignedLoad(VFuncPtr, CGF.getPointerAlign());
+auto *VFuncLoad =
+CGF.Builder.CreateAlignedLoad(VFuncPtr, CGF.getPointerAlign());
+
+// Add !invariant.load md to virtual function load to indicate that
+// function didn't change inside vtable.
+// It's safe to add it without -fstrict-vtable-pointers, but it would not
+// help in devirtualization because it will only matter if we will have 2
+// the same virtual function loads from the same vtable load, which won't
+// happen without enabled devirtualization with -fstrict-vtable-pointers.
+if (CGM.getCodeGenOpts().OptimizationLevel > 0 &&
+CGM.getCodeGenOpts().StrictVTablePointers)
+  VFuncLoad->setMetadata(
+  llvm::LLVMContext::MD_invariant_load,
+  llvm::MDNode::get(CGM.getLLVMContext(),
+llvm::ArrayRef()));
+VFunc = VFuncLoad;
   }
 
   CGCallee Callee(MethodDecl, VFunc);

r285497 - [Devirtualization] Decorate vfunction load with invariant.load

2016-10-29 Thread Piotr Padlewski via cfe-commits
Author: prazek
Date: Sat Oct 29 10:28:30 2016
New Revision: 285497

URL: http://llvm.org/viewvc/llvm-project?rev=285497=rev
Log:
[Devirtualization] Decorate vfunction load with invariant.load

Summary:
This patch was introduced one year ago, but because my google account
was disabled, I didn't get email with failing buildbot and I missed
revert of this commit. There was small but in test regex.
I am back.

Reviewers: rsmith, rengolin

Subscribers: nlewycky, rjmccall, cfe-commits

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

Modified:
cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
cfe/trunk/test/CodeGenCXX/virtual-function-calls.cpp

Modified: cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp?rev=285497=285496=285497=diff
==
--- cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp (original)
+++ cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp Sat Oct 29 10:28:30 2016
@@ -1623,7 +1623,22 @@ CGCallee ItaniumCXXABI::getVirtualFuncti
 
 llvm::Value *VFuncPtr =
 CGF.Builder.CreateConstInBoundsGEP1_64(VTable, VTableIndex, "vfn");
-VFunc = CGF.Builder.CreateAlignedLoad(VFuncPtr, CGF.getPointerAlign());
+auto *VFuncLoad =
+CGF.Builder.CreateAlignedLoad(VFuncPtr, CGF.getPointerAlign());
+
+// Add !invariant.load md to virtual function load to indicate that
+// function didn't change inside vtable.
+// It's safe to add it without -fstrict-vtable-pointers, but it would not
+// help in devirtualization because it will only matter if we will have 2
+// the same virtual function loads from the same vtable load, which won't
+// happen without enabled devirtualization with -fstrict-vtable-pointers.
+if (CGM.getCodeGenOpts().OptimizationLevel > 0 &&
+CGM.getCodeGenOpts().StrictVTablePointers)
+  VFuncLoad->setMetadata(
+  llvm::LLVMContext::MD_invariant_load,
+  llvm::MDNode::get(CGM.getLLVMContext(),
+llvm::ArrayRef()));
+VFunc = VFuncLoad;
   }
 
   CGCallee Callee(MethodDecl, VFunc);

Modified: cfe/trunk/test/CodeGenCXX/virtual-function-calls.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/virtual-function-calls.cpp?rev=285497=285496=285497=diff
==
--- cfe/trunk/test/CodeGenCXX/virtual-function-calls.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/virtual-function-calls.cpp Sat Oct 29 10:28:30 
2016
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 %s -triple %itanium_abi_triple -std=c++11 -emit-llvm -o - | 
FileCheck %s
+// RUN: %clang_cc1 %s -triple %itanium_abi_triple -std=c++11 -emit-llvm -o - 
-fstrict-vtable-pointers -O1 | FileCheck --check-prefix=CHECK-INVARIANT %s
 
 // PR5021
 namespace PR5021 {
@@ -42,10 +43,14 @@ namespace VirtualNoreturn {
 [[noreturn]] virtual void f();
   };
 
-  // CHECK: @_ZN15VirtualNoreturn1f
+  // CHECK-LABEL: @_ZN15VirtualNoreturn1f
+  // CHECK-INVARIANT-LABEL: define void @_ZN15VirtualNoreturn1f
   void f(A *p) {
 p->f();
 // CHECK: call {{.*}}void %{{[^#]*$}}
 // CHECK-NOT: unreachable
+// CHECK-INVARIANT: load {{.*}} !invariant.load ![[EMPTY_NODE:[0-9]+]]
   }
 }
+
+// CHECK-INVARIANT: ![[EMPTY_NODE]] = !{}


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r285496 - NFC small format

2016-10-29 Thread Piotr Padlewski via cfe-commits
Author: prazek
Date: Sat Oct 29 10:28:25 2016
New Revision: 285496

URL: http://llvm.org/viewvc/llvm-project?rev=285496=rev
Log:
NFC small format

Modified:
cfe/trunk/lib/Analysis/UninitializedValues.cpp

Modified: cfe/trunk/lib/Analysis/UninitializedValues.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/UninitializedValues.cpp?rev=285496=285495=285496=diff
==
--- cfe/trunk/lib/Analysis/UninitializedValues.cpp (original)
+++ cfe/trunk/lib/Analysis/UninitializedValues.cpp Sat Oct 29 10:28:25 2016
@@ -348,7 +348,8 @@ public:
 }
 
 static const DeclRefExpr *getSelfInitExpr(VarDecl *VD) {
-  if (VD->getType()->isRecordType()) return nullptr;
+  if (VD->getType()->isRecordType())
+return nullptr;
   if (Expr *Init = VD->getInit()) {
 const DeclRefExpr *DRE
   = dyn_cast(stripCasts(VD->getASTContext(), Init));


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D26117: [Devirtualization] Decorate vfunction load with invariant.load

2016-10-29 Thread Piotr Padlewski via cfe-commits
Prazek updated this revision to Diff 76303.
Prazek added a comment.

Updated comment and reformatted


https://reviews.llvm.org/D26117

Files:
  lib/CodeGen/ItaniumCXXABI.cpp
  test/CodeGenCXX/virtual-function-calls.cpp


Index: test/CodeGenCXX/virtual-function-calls.cpp
===
--- test/CodeGenCXX/virtual-function-calls.cpp
+++ test/CodeGenCXX/virtual-function-calls.cpp
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 %s -triple %itanium_abi_triple -std=c++11 -emit-llvm -o - | 
FileCheck %s
+// RUN: %clang_cc1 %s -triple %itanium_abi_triple -std=c++11 -emit-llvm -o - 
-fstrict-vtable-pointers -O1 | FileCheck --check-prefix=CHECK-INVARIANT %s
 
 // PR5021
 namespace PR5021 {
@@ -42,10 +43,14 @@
 [[noreturn]] virtual void f();
   };
 
-  // CHECK: @_ZN15VirtualNoreturn1f
+  // CHECK-LABEL: @_ZN15VirtualNoreturn1f
+  // CHECK-INVARIANT-LABEL: define void @_ZN15VirtualNoreturn1f
   void f(A *p) {
 p->f();
 // CHECK: call {{.*}}void %{{[^#]*$}}
 // CHECK-NOT: unreachable
+// CHECK-INVARIANT: load {{.*}} !invariant.load ![[EMPTY_NODE:[0-9]+]]
   }
 }
+
+// CHECK-INVARIANT: ![[EMPTY_NODE]] = !{}
Index: lib/CodeGen/ItaniumCXXABI.cpp
===
--- lib/CodeGen/ItaniumCXXABI.cpp
+++ lib/CodeGen/ItaniumCXXABI.cpp
@@ -1623,7 +1623,22 @@
 
 llvm::Value *VFuncPtr =
 CGF.Builder.CreateConstInBoundsGEP1_64(VTable, VTableIndex, "vfn");
-VFunc = CGF.Builder.CreateAlignedLoad(VFuncPtr, CGF.getPointerAlign());
+auto *VFuncLoad =
+CGF.Builder.CreateAlignedLoad(VFuncPtr, CGF.getPointerAlign());
+
+// Add !invariant.load md to virtual function load to indicate that
+// function didn't change inside vtable.
+// It's safe to add it without -fstrict-vtable-pointers, but it would not
+// help in devirtualization because it will only matter if we will have 2
+// the same virtual function loads from the same vtable load, which won't
+// happen without enabled devirtualization with -fstrict-vtable-pointers.
+if (CGM.getCodeGenOpts().OptimizationLevel > 0 &&
+CGM.getCodeGenOpts().StrictVTablePointers)
+  VFuncLoad->setMetadata(
+  llvm::LLVMContext::MD_invariant_load,
+  llvm::MDNode::get(CGM.getLLVMContext(),
+llvm::ArrayRef()));
+VFunc = VFuncLoad;
   }
 
   CGCallee Callee(MethodDecl, VFunc);


Index: test/CodeGenCXX/virtual-function-calls.cpp
===
--- test/CodeGenCXX/virtual-function-calls.cpp
+++ test/CodeGenCXX/virtual-function-calls.cpp
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 %s -triple %itanium_abi_triple -std=c++11 -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 %s -triple %itanium_abi_triple -std=c++11 -emit-llvm -o - -fstrict-vtable-pointers -O1 | FileCheck --check-prefix=CHECK-INVARIANT %s
 
 // PR5021
 namespace PR5021 {
@@ -42,10 +43,14 @@
 [[noreturn]] virtual void f();
   };
 
-  // CHECK: @_ZN15VirtualNoreturn1f
+  // CHECK-LABEL: @_ZN15VirtualNoreturn1f
+  // CHECK-INVARIANT-LABEL: define void @_ZN15VirtualNoreturn1f
   void f(A *p) {
 p->f();
 // CHECK: call {{.*}}void %{{[^#]*$}}
 // CHECK-NOT: unreachable
+// CHECK-INVARIANT: load {{.*}} !invariant.load ![[EMPTY_NODE:[0-9]+]]
   }
 }
+
+// CHECK-INVARIANT: ![[EMPTY_NODE]] = !{}
Index: lib/CodeGen/ItaniumCXXABI.cpp
===
--- lib/CodeGen/ItaniumCXXABI.cpp
+++ lib/CodeGen/ItaniumCXXABI.cpp
@@ -1623,7 +1623,22 @@
 
 llvm::Value *VFuncPtr =
 CGF.Builder.CreateConstInBoundsGEP1_64(VTable, VTableIndex, "vfn");
-VFunc = CGF.Builder.CreateAlignedLoad(VFuncPtr, CGF.getPointerAlign());
+auto *VFuncLoad =
+CGF.Builder.CreateAlignedLoad(VFuncPtr, CGF.getPointerAlign());
+
+// Add !invariant.load md to virtual function load to indicate that
+// function didn't change inside vtable.
+// It's safe to add it without -fstrict-vtable-pointers, but it would not
+// help in devirtualization because it will only matter if we will have 2
+// the same virtual function loads from the same vtable load, which won't
+// happen without enabled devirtualization with -fstrict-vtable-pointers.
+if (CGM.getCodeGenOpts().OptimizationLevel > 0 &&
+CGM.getCodeGenOpts().StrictVTablePointers)
+  VFuncLoad->setMetadata(
+  llvm::LLVMContext::MD_invariant_load,
+  llvm::MDNode::get(CGM.getLLVMContext(),
+llvm::ArrayRef()));
+VFunc = VFuncLoad;
   }
 
   CGCallee Callee(MethodDecl, VFunc);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D26117: [Devirtualization] Decorate vfunction load with invariant.load

2016-10-29 Thread Piotr Padlewski via cfe-commits
Prazek updated this revision to Diff 76302.
Prazek added a comment.

rebae


https://reviews.llvm.org/D26117

Files:
  lib/CodeGen/ItaniumCXXABI.cpp
  test/CodeGenCXX/virtual-function-calls.cpp


Index: test/CodeGenCXX/virtual-function-calls.cpp
===
--- test/CodeGenCXX/virtual-function-calls.cpp
+++ test/CodeGenCXX/virtual-function-calls.cpp
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 %s -triple %itanium_abi_triple -std=c++11 -emit-llvm -o - | 
FileCheck %s
+// RUN: %clang_cc1 %s -triple %itanium_abi_triple -std=c++11 -emit-llvm -o - 
-fstrict-vtable-pointers -O1 | FileCheck --check-prefix=CHECK-INVARIANT %s
 
 // PR5021
 namespace PR5021 {
@@ -42,10 +43,14 @@
 [[noreturn]] virtual void f();
   };
 
-  // CHECK: @_ZN15VirtualNoreturn1f
+  // CHECK-LABEL: @_ZN15VirtualNoreturn1f
+  // CHECK-INVARIANT-LABEL: define void @_ZN15VirtualNoreturn1f
   void f(A *p) {
 p->f();
 // CHECK: call {{.*}}void %{{[^#]*$}}
 // CHECK-NOT: unreachable
+// CHECK-INVARIANT: load {{.*}} !invariant.load ![[EMPTY_NODE:[0-9]+]]
   }
 }
+
+// CHECK-INVARIANT: ![[EMPTY_NODE]] = !{}
Index: lib/CodeGen/ItaniumCXXABI.cpp
===
--- lib/CodeGen/ItaniumCXXABI.cpp
+++ lib/CodeGen/ItaniumCXXABI.cpp
@@ -1623,7 +1623,17 @@
 
 llvm::Value *VFuncPtr =
 CGF.Builder.CreateConstInBoundsGEP1_64(VTable, VTableIndex, "vfn");
-VFunc = CGF.Builder.CreateAlignedLoad(VFuncPtr, CGF.getPointerAlign());
+auto *VFuncLoad = CGF.Builder.CreateAlignedLoad(VFuncPtr, CGF
+  .getPointerAlign());
+
+// It's safe to add "invariant.load" without -fstrict-vtable-pointers, but
+// it would not help in devirtualization.
+if (CGM.getCodeGenOpts().OptimizationLevel > 0 &&
+CGM.getCodeGenOpts().StrictVTablePointers)
+  VFuncLoad->setMetadata(llvm::LLVMContext::MD_invariant_load,
+llvm::MDNode::get(CGM.getLLVMContext(),
+  llvm::ArrayRef()));
+VFunc = VFuncLoad;
   }
 
   CGCallee Callee(MethodDecl, VFunc);


Index: test/CodeGenCXX/virtual-function-calls.cpp
===
--- test/CodeGenCXX/virtual-function-calls.cpp
+++ test/CodeGenCXX/virtual-function-calls.cpp
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 %s -triple %itanium_abi_triple -std=c++11 -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 %s -triple %itanium_abi_triple -std=c++11 -emit-llvm -o - -fstrict-vtable-pointers -O1 | FileCheck --check-prefix=CHECK-INVARIANT %s
 
 // PR5021
 namespace PR5021 {
@@ -42,10 +43,14 @@
 [[noreturn]] virtual void f();
   };
 
-  // CHECK: @_ZN15VirtualNoreturn1f
+  // CHECK-LABEL: @_ZN15VirtualNoreturn1f
+  // CHECK-INVARIANT-LABEL: define void @_ZN15VirtualNoreturn1f
   void f(A *p) {
 p->f();
 // CHECK: call {{.*}}void %{{[^#]*$}}
 // CHECK-NOT: unreachable
+// CHECK-INVARIANT: load {{.*}} !invariant.load ![[EMPTY_NODE:[0-9]+]]
   }
 }
+
+// CHECK-INVARIANT: ![[EMPTY_NODE]] = !{}
Index: lib/CodeGen/ItaniumCXXABI.cpp
===
--- lib/CodeGen/ItaniumCXXABI.cpp
+++ lib/CodeGen/ItaniumCXXABI.cpp
@@ -1623,7 +1623,17 @@
 
 llvm::Value *VFuncPtr =
 CGF.Builder.CreateConstInBoundsGEP1_64(VTable, VTableIndex, "vfn");
-VFunc = CGF.Builder.CreateAlignedLoad(VFuncPtr, CGF.getPointerAlign());
+auto *VFuncLoad = CGF.Builder.CreateAlignedLoad(VFuncPtr, CGF
+  .getPointerAlign());
+
+// It's safe to add "invariant.load" without -fstrict-vtable-pointers, but
+// it would not help in devirtualization.
+if (CGM.getCodeGenOpts().OptimizationLevel > 0 &&
+CGM.getCodeGenOpts().StrictVTablePointers)
+  VFuncLoad->setMetadata(llvm::LLVMContext::MD_invariant_load,
+llvm::MDNode::get(CGM.getLLVMContext(),
+  llvm::ArrayRef()));
+VFunc = VFuncLoad;
   }
 
   CGCallee Callee(MethodDecl, VFunc);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D26117: [Devirtualization] Decorate vfunction load with invariant.load

2016-10-29 Thread Piotr Padlewski via cfe-commits
Prazek added a comment.

merging with master. Gonna update patch in a minute.


https://reviews.llvm.org/D26117



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D26117: [Devirtualization] Decorate vfunction load with invariant.load

2016-10-29 Thread Piotr Padlewski via cfe-commits
Prazek added a comment.

Here is commit from last year
https://reviews.llvm.org/D13279


https://reviews.llvm.org/D26117



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D26117: [Devirtualization] Decorate vfunction load with invariant.load

2016-10-29 Thread Piotr Padlewski via cfe-commits
Prazek created this revision.
Prazek added reviewers: rsmith, rengolin.
Prazek added subscribers: cfe-commits, rjmccall, nlewycky.

This patch was introduced one year ago, but because my google account
was disabled, I didn't get email with failing buildbot and I missed
revert of this commit. There was small but in test regex.
I am back.


https://reviews.llvm.org/D26117

Files:
  lib/CodeGen/ItaniumCXXABI.cpp
  test/CodeGenCXX/virtual-function-calls.cpp


Index: test/CodeGenCXX/virtual-function-calls.cpp
===
--- test/CodeGenCXX/virtual-function-calls.cpp
+++ test/CodeGenCXX/virtual-function-calls.cpp
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 %s -triple %itanium_abi_triple -std=c++11 -emit-llvm -o - | 
FileCheck %s
+// RUN: %clang_cc1 %s -triple %itanium_abi_triple -std=c++11 -emit-llvm -o - 
-fstrict-vtable-pointers -O1 | FileCheck --check-prefix=CHECK-INVARIANT %s
 
 // PR5021
 namespace PR5021 {
@@ -42,10 +43,14 @@
 [[noreturn]] virtual void f();
   };
 
-  // CHECK: @_ZN15VirtualNoreturn1f
+  // CHECK-LABEL: @_ZN15VirtualNoreturn1f
+  // CHECK-INVARIANT-LABEL: define void @_ZN15VirtualNoreturn1f
   void f(A *p) {
 p->f();
 // CHECK: call {{.*}}void %{{[^#]*$}}
 // CHECK-NOT: unreachable
+// CHECK-INVARIANT: load {{.*}} !invariant.load ![[EMPTY_NODE:[0-9]+]]
   }
 }
+
+// CHECK-INVARIANT: ![[EMPTY_NODE]] = !{}
Index: lib/CodeGen/ItaniumCXXABI.cpp
===
--- lib/CodeGen/ItaniumCXXABI.cpp
+++ lib/CodeGen/ItaniumCXXABI.cpp
@@ -1618,7 +1618,16 @@
 
 llvm::Value *VFuncPtr =
 CGF.Builder.CreateConstInBoundsGEP1_64(VTable, VTableIndex, "vfn");
-return CGF.Builder.CreateAlignedLoad(VFuncPtr, CGF.getPointerAlign());
+auto *Inst = CGF.Builder.CreateAlignedLoad(VFuncPtr, 
CGF.getPointerAlign());
+
+// It's safe to add "invariant.load" without -fstrict-vtable-pointers, but
+// it would not help in devirtualization.
+if (CGM.getCodeGenOpts().OptimizationLevel > 0 &&
+CGM.getCodeGenOpts().StrictVTablePointers)
+  Inst->setMetadata(llvm::LLVMContext::MD_invariant_load,
+llvm::MDNode::get(CGM.getLLVMContext(),
+  llvm::ArrayRef()));
+return Inst;
   }
 }
 


Index: test/CodeGenCXX/virtual-function-calls.cpp
===
--- test/CodeGenCXX/virtual-function-calls.cpp
+++ test/CodeGenCXX/virtual-function-calls.cpp
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 %s -triple %itanium_abi_triple -std=c++11 -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 %s -triple %itanium_abi_triple -std=c++11 -emit-llvm -o - -fstrict-vtable-pointers -O1 | FileCheck --check-prefix=CHECK-INVARIANT %s
 
 // PR5021
 namespace PR5021 {
@@ -42,10 +43,14 @@
 [[noreturn]] virtual void f();
   };
 
-  // CHECK: @_ZN15VirtualNoreturn1f
+  // CHECK-LABEL: @_ZN15VirtualNoreturn1f
+  // CHECK-INVARIANT-LABEL: define void @_ZN15VirtualNoreturn1f
   void f(A *p) {
 p->f();
 // CHECK: call {{.*}}void %{{[^#]*$}}
 // CHECK-NOT: unreachable
+// CHECK-INVARIANT: load {{.*}} !invariant.load ![[EMPTY_NODE:[0-9]+]]
   }
 }
+
+// CHECK-INVARIANT: ![[EMPTY_NODE]] = !{}
Index: lib/CodeGen/ItaniumCXXABI.cpp
===
--- lib/CodeGen/ItaniumCXXABI.cpp
+++ lib/CodeGen/ItaniumCXXABI.cpp
@@ -1618,7 +1618,16 @@
 
 llvm::Value *VFuncPtr =
 CGF.Builder.CreateConstInBoundsGEP1_64(VTable, VTableIndex, "vfn");
-return CGF.Builder.CreateAlignedLoad(VFuncPtr, CGF.getPointerAlign());
+auto *Inst = CGF.Builder.CreateAlignedLoad(VFuncPtr, CGF.getPointerAlign());
+
+// It's safe to add "invariant.load" without -fstrict-vtable-pointers, but
+// it would not help in devirtualization.
+if (CGM.getCodeGenOpts().OptimizationLevel > 0 &&
+CGM.getCodeGenOpts().StrictVTablePointers)
+  Inst->setMetadata(llvm::LLVMContext::MD_invariant_load,
+llvm::MDNode::get(CGM.getLLVMContext(),
+  llvm::ArrayRef()));
+return Inst;
   }
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D26054: Use `getFileLoc()` instead of `getSpellingLoc()` in the ASTImporter

2016-10-29 Thread Aleksei Sidorin via cfe-commits
a.sidorin accepted this revision.
a.sidorin added a comment.
This revision is now accepted and ready to land.

Looks good. But I think it will be good to put the files in Input to a separate 
directory.


https://reviews.llvm.org/D26054



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D24869: [cfe] [test] Fix detecting LLVM zlib support in stand-alone builds

2016-10-29 Thread Michał Górny via cfe-commits
mgorny added a comment.

Non-gentle ping?


https://reviews.llvm.org/D24869



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D26115: [test] Correctly include build llvm_shlib_dir in stand-alone builds

2016-10-29 Thread Michał Górny via cfe-commits
mgorny created this revision.
mgorny added reviewers: ddunbar, beanz.
mgorny added a subscriber: cfe-commits.

Add the build llvm_shlib_dir into LD_LIBRARY_PATH before the directory
specified as llvm_libs_dir, in order to fix stand-alone builds
attempting to use installed clang libraries.

In case of stand-alone builds llvm_libs_dir specifies the location of
installed LLVM libraries which can also contain an older version
(previous build) of clang libraries. Therefore, ensure to specify
llvm_shlib_dir (which is always the build tree path) before
the potentially-system llvm_libs_dir.


https://reviews.llvm.org/D26115

Files:
  test/lit.cfg


Index: test/lit.cfg
===
--- test/lit.cfg
+++ test/lit.cfg
@@ -102,10 +102,15 @@
 path = os.path.pathsep.join((
 clang_tools_dir, llvm_tools_dir, config.environment['PATH']))
 config.environment['PATH'] = path
+# in stand-alone builds, llvm_shlib_dir is clang's build tree
+# while llvm_libs_dir is installed LLVM (and possibly older clang)
+llvm_shlib_dir = getattr(config, 'llvm_shlib_dir', None)
+if not llvm_shlib_dir:
+lit_config.fatal('No LLVM shlib dir set!')
 llvm_libs_dir = getattr(config, 'llvm_libs_dir', None)
 if not llvm_libs_dir:
 lit_config.fatal('No LLVM libs dir set!')
-path = os.path.pathsep.join((llvm_libs_dir,
+path = os.path.pathsep.join((llvm_shlib_dir, llvm_libs_dir,
  config.environment.get('LD_LIBRARY_PATH','')))
 config.environment['LD_LIBRARY_PATH'] = path
 


Index: test/lit.cfg
===
--- test/lit.cfg
+++ test/lit.cfg
@@ -102,10 +102,15 @@
 path = os.path.pathsep.join((
 clang_tools_dir, llvm_tools_dir, config.environment['PATH']))
 config.environment['PATH'] = path
+# in stand-alone builds, llvm_shlib_dir is clang's build tree
+# while llvm_libs_dir is installed LLVM (and possibly older clang)
+llvm_shlib_dir = getattr(config, 'llvm_shlib_dir', None)
+if not llvm_shlib_dir:
+lit_config.fatal('No LLVM shlib dir set!')
 llvm_libs_dir = getattr(config, 'llvm_libs_dir', None)
 if not llvm_libs_dir:
 lit_config.fatal('No LLVM libs dir set!')
-path = os.path.pathsep.join((llvm_libs_dir,
+path = os.path.pathsep.join((llvm_shlib_dir, llvm_libs_dir,
  config.environment.get('LD_LIBRARY_PATH','')))
 config.environment['LD_LIBRARY_PATH'] = path
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D12839: Extend MoveConstructorInitCheck to also flag constructor arguments passed by value and can be moved assigned to fields.

2016-10-29 Thread Malcolm Parsons via cfe-commits
malcolm.parsons added a comment.

The modernize-pass-by-value check does the same thing:

  test/clang-tidy/misc-move-constructor-init.cpp:98:12: warning: pass by value 
and use std::move [modernize-pass-by-value]
Positive(Movable M) : M_(M) {}
 ^
 std::move( )
  test/clang-tidy/misc-move-constructor-init.cpp:98:28: warning: value argument 
'M' can be moved to avoid copy [misc-move-constructor-init]
Positive(Movable M) : M_(M) {}
 ^

Do we need two checks for this?


https://reviews.llvm.org/D12839



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits