r314194 - [XRay] Avoid actual linking when testing the driver

2017-09-25 Thread Dean Michael Berris via cfe-commits
Author: dberris
Date: Mon Sep 25 21:29:25 2017
New Revision: 314194

URL: http://llvm.org/viewvc/llvm-project?rev=314194=rev
Log:
[XRay] Avoid actual linking when testing the driver

Use -### in the command to see just look for the output of -v.

Follow-up to D38226.

Modified:
cfe/trunk/test/Driver/XRay/xray-shared-noxray.cpp

Modified: cfe/trunk/test/Driver/XRay/xray-shared-noxray.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/XRay/xray-shared-noxray.cpp?rev=314194=314193=314194=diff
==
--- cfe/trunk/test/Driver/XRay/xray-shared-noxray.cpp (original)
+++ cfe/trunk/test/Driver/XRay/xray-shared-noxray.cpp Mon Sep 25 21:29:25 2017
@@ -1,9 +1,9 @@
-// RUN: %clangxx -shared -o /dev/null -v -fxray-instrument %s
-// RUN: %clangxx -shared -o /dev/null -v -fxray-instrument %s 2>&1 | \
+// RUN: %clangxx -shared -o /dev/null -v -fxray-instrument %s -###
+// RUN: %clangxx -shared -o /dev/null -v -fxray-instrument %s -### 2>&1 | \
 // RUN: FileCheck %s --check-prefix=SHARED
-// RUN: %clangxx -static -o /dev/null -v -fxray-instrument %s -DMAIN
-// RUN: %clangxx -static -o /dev/null -v -fxray-instrument %s 2>&1 -DMAIN | \
-// RUN: FileCheck %s --check-prefix=STATIC
+// RUN: %clangxx -static -o /dev/null -v -fxray-instrument %s -### -DMAIN
+// RUN: %clangxx -static -o /dev/null -v -fxray-instrument %s -### 2>&1 -DMAIN 
\
+// RUN: | FileCheck %s --check-prefix=STATIC
 //
 // SHARED-NOT: {{clang_rt\.xray-}}
 // STATIC: {{clang_rt\.xray-}}


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


r314193 - [XRay] Run command once without piping to FileCheck

2017-09-25 Thread Dean Michael Berris via cfe-commits
Author: dberris
Date: Mon Sep 25 21:17:37 2017
New Revision: 314193

URL: http://llvm.org/viewvc/llvm-project?rev=314193=rev
Log:
[XRay] Run command once without piping to FileCheck

This allows us to debug the failures that come up from the build bots.

Follow-up to D38226.

Modified:
cfe/trunk/test/Driver/XRay/xray-shared-noxray.cpp

Modified: cfe/trunk/test/Driver/XRay/xray-shared-noxray.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/XRay/xray-shared-noxray.cpp?rev=314193=314192=314193=diff
==
--- cfe/trunk/test/Driver/XRay/xray-shared-noxray.cpp (original)
+++ cfe/trunk/test/Driver/XRay/xray-shared-noxray.cpp Mon Sep 25 21:17:37 2017
@@ -1,5 +1,7 @@
+// RUN: %clangxx -shared -o /dev/null -v -fxray-instrument %s
 // RUN: %clangxx -shared -o /dev/null -v -fxray-instrument %s 2>&1 | \
 // RUN: FileCheck %s --check-prefix=SHARED
+// RUN: %clangxx -static -o /dev/null -v -fxray-instrument %s -DMAIN
 // RUN: %clangxx -static -o /dev/null -v -fxray-instrument %s 2>&1 -DMAIN | \
 // RUN: FileCheck %s --check-prefix=STATIC
 //


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


r314191 - [XRay] Only run shared tests when 'enable_shared' is true

2017-09-25 Thread Dean Michael Berris via cfe-commits
Author: dberris
Date: Mon Sep 25 21:07:45 2017
New Revision: 314191

URL: http://llvm.org/viewvc/llvm-project?rev=314191=rev
Log:
[XRay] Only run shared tests when 'enable_shared' is true

Follow-up to D38226.

Modified:
cfe/trunk/test/Driver/XRay/lit.local.cfg
cfe/trunk/test/Driver/XRay/xray-shared-noxray.cpp

Modified: cfe/trunk/test/Driver/XRay/lit.local.cfg
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/XRay/lit.local.cfg?rev=314191=314190=314191=diff
==
--- cfe/trunk/test/Driver/XRay/lit.local.cfg (original)
+++ cfe/trunk/test/Driver/XRay/lit.local.cfg Mon Sep 25 21:07:45 2017
@@ -19,3 +19,6 @@ if len(triple_set.intersection(supported
 # Do not run for 'android' despite being linux.
 if len(triple_set.intersection(supported_oses)) == 0 or 'android' in 
triple_set:
   config.unsupported = True
+
+if config.enable_shared:
+  config.available_features.update(['enable_shared'])

Modified: cfe/trunk/test/Driver/XRay/xray-shared-noxray.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/XRay/xray-shared-noxray.cpp?rev=314191=314190=314191=diff
==
--- cfe/trunk/test/Driver/XRay/xray-shared-noxray.cpp (original)
+++ cfe/trunk/test/Driver/XRay/xray-shared-noxray.cpp Mon Sep 25 21:07:45 2017
@@ -6,7 +6,7 @@
 // SHARED-NOT: {{clang_rt\.xray-}}
 // STATIC: {{clang_rt\.xray-}}
 //
-// REQUIRES: linux
+// REQUIRES: linux, enable_shared
 int foo() { return 42; }
 
 #ifdef MAIN


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


r314190 - [XRay] Remove -fPIC from shared build test.

2017-09-25 Thread Dean Michael Berris via cfe-commits
Author: dberris
Date: Mon Sep 25 21:00:41 2017
New Revision: 314190

URL: http://llvm.org/viewvc/llvm-project?rev=314190=rev
Log:
[XRay] Remove -fPIC from shared build test.

Follow-up to D38226.

Modified:
cfe/trunk/test/Driver/XRay/xray-shared-noxray.cpp

Modified: cfe/trunk/test/Driver/XRay/xray-shared-noxray.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/XRay/xray-shared-noxray.cpp?rev=314190=314189=314190=diff
==
--- cfe/trunk/test/Driver/XRay/xray-shared-noxray.cpp (original)
+++ cfe/trunk/test/Driver/XRay/xray-shared-noxray.cpp Mon Sep 25 21:00:41 2017
@@ -1,4 +1,4 @@
-// RUN: %clangxx -shared -fPIC -o /dev/null -v -fxray-instrument %s 2>&1 | \
+// RUN: %clangxx -shared -o /dev/null -v -fxray-instrument %s 2>&1 | \
 // RUN: FileCheck %s --check-prefix=SHARED
 // RUN: %clangxx -static -o /dev/null -v -fxray-instrument %s 2>&1 -DMAIN | \
 // RUN: FileCheck %s --check-prefix=STATIC


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


r314189 - [XRay] Stop running tests for 'amd64', and remove -fPIE from tests.

2017-09-25 Thread Dean Michael Berris via cfe-commits
Author: dberris
Date: Mon Sep 25 20:45:37 2017
New Revision: 314189

URL: http://llvm.org/viewvc/llvm-project?rev=314189=rev
Log:
[XRay] Stop running tests for 'amd64', and remove -fPIE from tests.

Follow-up to D38226.

Modified:
cfe/trunk/test/Driver/XRay/lit.local.cfg
cfe/trunk/test/Driver/XRay/xray-shared-noxray.cpp

Modified: cfe/trunk/test/Driver/XRay/lit.local.cfg
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/XRay/lit.local.cfg?rev=314189=314188=314189=diff
==
--- cfe/trunk/test/Driver/XRay/lit.local.cfg (original)
+++ cfe/trunk/test/Driver/XRay/lit.local.cfg Mon Sep 25 20:45:37 2017
@@ -3,8 +3,8 @@ config.available_features.update(target_
 
 # Only run the tests in platforms where XRay instrumentation is supported.
 supported_targets = [
-'amd64', 'x86_64', 'x86_64h', 'arm', 'aarch64', 'arm64', 'powerpc64le',
-'mips', 'mipsel', 'mips64', 'mips64el'
+'x86_64', 'x86_64h', 'arm', 'aarch64', 'arm64', 'powerpc64le', 'mips',
+'mipsel', 'mips64', 'mips64el'
 ]
 
 # Only on platforms we support.

Modified: cfe/trunk/test/Driver/XRay/xray-shared-noxray.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/XRay/xray-shared-noxray.cpp?rev=314189=314188=314189=diff
==
--- cfe/trunk/test/Driver/XRay/xray-shared-noxray.cpp (original)
+++ cfe/trunk/test/Driver/XRay/xray-shared-noxray.cpp Mon Sep 25 20:45:37 2017
@@ -2,8 +2,6 @@
 // RUN: FileCheck %s --check-prefix=SHARED
 // RUN: %clangxx -static -o /dev/null -v -fxray-instrument %s 2>&1 -DMAIN | \
 // RUN: FileCheck %s --check-prefix=STATIC
-// RUN: %clangxx -static -fPIE -o /dev/null -v -fxray-instrument %s 2>&1 \
-// RUN: -DMAIN | FileCheck %s --check-prefix=STATIC
 //
 // SHARED-NOT: {{clang_rt\.xray-}}
 // STATIC: {{clang_rt\.xray-}}


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


r314188 - [XRay][Driver] Do not link in XRay runtime in shared libs

2017-09-25 Thread Dean Michael Berris via cfe-commits
Author: dberris
Date: Mon Sep 25 20:18:11 2017
New Revision: 314188

URL: http://llvm.org/viewvc/llvm-project?rev=314188=rev
Log:
[XRay][Driver] Do not link in XRay runtime in shared libs

Summary:
This change ensures that we don't link in the XRay runtime when building
shared libraries with clang. This doesn't prevent us from building
shared libraris tht have XRay instrumentation sleds, but it does prevent
us from linking in the static XRay runtime into a shared library.

The XRay runtime currently doesn't support dynamic registration of
instrumentation sleds in shared objects, which we'll start enabling in
the future. That work has to happen in the back-end and in the runtime.

Reviewers: rnk, pelikan

Subscribers: cfe-commits

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

Added:
cfe/trunk/test/Driver/XRay/xray-shared-noxray.cpp
Modified:
cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
cfe/trunk/test/Driver/XRay/lit.local.cfg

Modified: cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Gnu.cpp?rev=314188=314187=314188=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Gnu.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Gnu.cpp Mon Sep 25 20:18:11 2017
@@ -206,6 +206,10 @@ void tools::gcc::Linker::RenderExtraTool
 
 static bool addXRayRuntime(const ToolChain , const ArgList ,
ArgStringList ) {
+  // Do not add the XRay runtime to shared libraries.
+  if (Args.hasArg(options::OPT_shared))
+return false;
+
   if (Args.hasFlag(options::OPT_fxray_instrument,
options::OPT_fnoxray_instrument, false)) {
 CmdArgs.push_back("-whole-archive");
@@ -213,6 +217,7 @@ static bool addXRayRuntime(const ToolCha
 CmdArgs.push_back("-no-whole-archive");
 return true;
   }
+
   return false;
 }
 

Modified: cfe/trunk/test/Driver/XRay/lit.local.cfg
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/XRay/lit.local.cfg?rev=314188=314187=314188=diff
==
--- cfe/trunk/test/Driver/XRay/lit.local.cfg (original)
+++ cfe/trunk/test/Driver/XRay/lit.local.cfg Mon Sep 25 20:18:11 2017
@@ -1,2 +1,21 @@
 target_triple_components = config.target_triple.split('-')
 config.available_features.update(target_triple_components)
+
+# Only run the tests in platforms where XRay instrumentation is supported.
+supported_targets = [
+'amd64', 'x86_64', 'x86_64h', 'arm', 'aarch64', 'arm64', 'powerpc64le',
+'mips', 'mipsel', 'mips64', 'mips64el'
+]
+
+# Only on platforms we support.
+supported_oses = [
+'linux'
+]
+
+triple_set = set(target_triple_components)
+if len(triple_set.intersection(supported_targets)) == 0:
+  config.unsupported = True
+
+# Do not run for 'android' despite being linux.
+if len(triple_set.intersection(supported_oses)) == 0 or 'android' in 
triple_set:
+  config.unsupported = True

Added: cfe/trunk/test/Driver/XRay/xray-shared-noxray.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/XRay/xray-shared-noxray.cpp?rev=314188=auto
==
--- cfe/trunk/test/Driver/XRay/xray-shared-noxray.cpp (added)
+++ cfe/trunk/test/Driver/XRay/xray-shared-noxray.cpp Mon Sep 25 20:18:11 2017
@@ -0,0 +1,16 @@
+// RUN: %clangxx -shared -fPIC -o /dev/null -v -fxray-instrument %s 2>&1 | \
+// RUN: FileCheck %s --check-prefix=SHARED
+// RUN: %clangxx -static -o /dev/null -v -fxray-instrument %s 2>&1 -DMAIN | \
+// RUN: FileCheck %s --check-prefix=STATIC
+// RUN: %clangxx -static -fPIE -o /dev/null -v -fxray-instrument %s 2>&1 \
+// RUN: -DMAIN | FileCheck %s --check-prefix=STATIC
+//
+// SHARED-NOT: {{clang_rt\.xray-}}
+// STATIC: {{clang_rt\.xray-}}
+//
+// REQUIRES: linux
+int foo() { return 42; }
+
+#ifdef MAIN
+int main() { return foo(); }
+#endif


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


r314187 - CodeGenModule: Adapt to LLVM TargetLibraryInfo changes

2017-09-25 Thread Matthias Braun via cfe-commits
Author: matze
Date: Mon Sep 25 19:37:23 2017
New Revision: 314187

URL: http://llvm.org/viewvc/llvm-project?rev=314187=rev
Log:
CodeGenModule: Adapt to LLVM TargetLibraryInfo changes

Adapt to LLVM TargetLibraryInfo changes in r314185.

See also https://reviews.llvm.org/D38106 and https://reviews.llvm.org/D37891

Modified:
cfe/trunk/lib/CodeGen/CodeGenModule.cpp

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=314187=314186=314187=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Mon Sep 25 19:37:23 2017
@@ -476,17 +476,11 @@ void CodeGenModule::Release() {
 getModule().addModuleFlag(llvm::Module::Warning, "Debug Info Version",
   llvm::DEBUG_METADATA_VERSION);
 
-  // Width of wchar_t in bytes
-  uint64_t WCharWidth =
-  Context.getTypeSizeInChars(Context.getWideCharType()).getQuantity();
-  assert((LangOpts.ShortWChar ||
-  llvm::TargetLibraryInfoImpl::getTargetWCharSize(Target.getTriple()) 
==
-  Target.getWCharWidth() / 8) &&
- "LLVM wchar_t size out of sync");
-
   // We need to record the widths of enums and wchar_t, so that we can generate
   // the correct build attributes in the ARM backend. wchar_size is also used 
by
   // TargetLibraryInfo.
+  uint64_t WCharWidth =
+  Context.getTypeSizeInChars(Context.getWideCharType()).getQuantity();
   getModule().addModuleFlag(llvm::Module::Error, "wchar_size", WCharWidth);
 
   llvm::Triple::ArchType Arch = Context.getTargetInfo().getTriple().getArch();


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


r314178 - Revert "[XRay][Driver] Do not link in XRay runtime in shared libs"

2017-09-25 Thread Dean Michael Berris via cfe-commits
Author: dberris
Date: Mon Sep 25 17:41:08 2017
New Revision: 314178

URL: http://llvm.org/viewvc/llvm-project?rev=314178=rev
Log:
Revert "[XRay][Driver] Do not link in XRay runtime in shared libs"

Reverts r314177.

Removed:
cfe/trunk/test/Driver/XRay/xray-shared-noxray.cpp
Modified:
cfe/trunk/lib/Driver/ToolChains/Gnu.cpp

Modified: cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Gnu.cpp?rev=314178=314177=314178=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Gnu.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Gnu.cpp Mon Sep 25 17:41:08 2017
@@ -206,10 +206,6 @@ void tools::gcc::Linker::RenderExtraTool
 
 static bool addXRayRuntime(const ToolChain , const ArgList ,
ArgStringList ) {
-  // Do not add the XRay runtime to shared libraries.
-  if (Args.hasArg(options::OPT_shared))
-return false;
-
   if (Args.hasFlag(options::OPT_fxray_instrument,
options::OPT_fnoxray_instrument, false)) {
 CmdArgs.push_back("-whole-archive");
@@ -217,7 +213,6 @@ static bool addXRayRuntime(const ToolCha
 CmdArgs.push_back("-no-whole-archive");
 return true;
   }
-
   return false;
 }
 

Removed: cfe/trunk/test/Driver/XRay/xray-shared-noxray.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/XRay/xray-shared-noxray.cpp?rev=314177=auto
==
--- cfe/trunk/test/Driver/XRay/xray-shared-noxray.cpp (original)
+++ cfe/trunk/test/Driver/XRay/xray-shared-noxray.cpp (removed)
@@ -1,14 +0,0 @@
-// RUN: %clangxx -shared -fPIC -o /dev/null -v -fxray-instrument %s 2>&1 | \
-// RUN: FileCheck %s --check-prefix=SHARED
-// RUN: %clangxx -static -o /dev/null -v -fxray-instrument %s 2>&1 -DMAIN | \
-// RUN: FileCheck %s --check-prefix=STATIC
-// RUN: %clangxx -static -fPIE -o /dev/null -v -fxray-instrument %s 2>&1 \
-// RUN: -DMAIN | FileCheck %s --check-prefix=STATIC
-//
-// SHARED-NOT: {{clang_rt\.xray-}}
-// STATIC: {{clang_rt\.xray-}}
-int foo() { return 42; }
-
-#ifdef MAIN
-int main() { return foo(); }
-#endif


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


Re: [PATCH] D38208: Add support for remembering origins to ExternalASTMerger

2017-09-25 Thread Sean Callanan via cfe-commits
Updated the diff.  Unfortunately reviews.llvm.org is down, so I'll try 
updating that page in the morning.


Sean

On 9/25/17 5:04 AM, Bruno Cardoso Lopes via Phabricator wrote:

bruno added inline comments.



Comment at: lib/AST/ExternalASTMerger.cpp:79
+  return cast(SearchResultDecl)->getPrimaryContext();
+else
+  return nullptr; // This type of lookup is unsupported

No need for `else` here.



Comment at: lib/AST/ExternalASTMerger.cpp:173
+ASTImporter ::ImporterForOrigin(ASTContext ) {
+  for (const std::unique_ptr  : Importers) {
+if (>getFromContext() == )

No need for curly braces here.



Comment at: lib/AST/ExternalASTMerger.cpp:189
+bool ExternalASTMerger::HasImporterForOrigin(ASTContext ) {
+  for (const std::unique_ptr  : Importers) {
+if (>getFromContext() == )

No need for curly braces here.



Comment at: lib/AST/ExternalASTMerger.cpp:289
+  LookupSameContext(Origin.AST->getTranslationUnitDecl(), ToDC, Reverse);
+  if (!FoundFromDC || !IsSameDC(FoundFromDC.get(), Origin.DC)) {
+if (LoggingEnabled())

You can probably simplify this to something like:


```
bool RecordOrigin = !FoundFromDC || !IsSameDC(FoundFromDC.get(), Origin.DC);

if (RecordOrigin)
   RecordOriginImpl(ToDC, Origin, Importer);
   
if (LoggingEnabled()) {

   logs() << "(ExternalASTMerger*)" << (void*)this
  << " decided";
  
   if (!RecordOrigin)

 logs() << " NOT";
 
   logs() << " to record origin (DeclContext*)" << (void*)Origin.DC

  << ", (ASTContext*)" << (void*)
  << "\n";
}
```



Comment at: lib/AST/ExternalASTMerger.cpp:380
+
+  if (Candidates.empty()) {
+return false;

No need for curly braces here.



Comment at: tools/clang-import-test/clang-import-test.cpp:329
  CG.GetModule()->print(llvm::outs(), nullptr);
-  if (CI->getDiagnosticClient().getNumErrors()) {
+  if (CI.getDiagnosticClient().getNumErrors()) {
  return llvm::make_error(

No need for curly braces here


Repository:
   rL LLVM

https://reviews.llvm.org/D38208





Index: include/clang/AST/ExternalASTMerger.h
===
--- include/clang/AST/ExternalASTMerger.h   (revision 313996)
+++ include/clang/AST/ExternalASTMerger.h   (working copy)
@@ -1,51 +1,176 @@
 //===--- ExternalASTMerger.h - Merging External AST Interface ---*- C++ 
-*-===//
 //
 // The LLVM Compiler Infrastructure
 //
 // This file is distributed under the University of Illinois Open Source
 // License. See LICENSE.TXT for details.
 //
 
//===--===//
 //
 //  This file declares the ExternalASTMerger, which vends a combination of ASTs
 //  from several different ASTContext/FileManager pairs
 //
 
//===--===//
 #ifndef LLVM_CLANG_AST_EXTERNALASTMERGER_H
 #define LLVM_CLANG_AST_EXTERNALASTMERGER_H
 
 #include "clang/AST/ASTImporter.h"
 #include "clang/AST/ExternalASTSource.h"
+#include "llvm/Support/raw_ostream.h"
 
 namespace clang {
 
+/// ExternalASTSource implementation that merges information from several
+/// ASTContexts.
+///
+/// ExtermalASTMerger maintains a vector of ASTImporters that it uses to import
+/// (potentially incomplete) Decls and DeclContexts from the source ASTContexts
+/// in response to ExternalASTSource API calls.
+///
+/// When lookup occurs in the resulting imported DeclContexts, the original
+/// DeclContexts need to be queried.  Roughly, there are three cases here:
+///
+/// - The DeclContext of origin can be found by simple name lookup.  In this
+///   case, no additional state is required.
+///
+/// - The DeclContext of origin is different from what would be found by name
+///   lookup.  In this case, Origins contains an entry overriding lookup and
+///   specifying the correct pair of DeclContext/ASTContext.
+///
+/// - The DeclContext of origin was determined by another ExterenalASTMerger. 
+///   (This is possible when the source ASTContext for one of the Importers has
+///   its own ExternalASTMerger).  The origin must be properly forwarded in 
this
+///   case.
+///
+/// ExternalASTMerger's job is to maintain the data structures necessary to
+/// allow this.  The data structures themselves can be extracted (read-only) 
and
+/// copied for re-use.
 class ExternalASTMerger : public ExternalASTSource {
 public:
-  struct ImporterPair {
-std::unique_ptr Forward;
-std::unique_ptr Reverse;
+  /// A single origin for a DeclContext.  Unlike Decls, DeclContexts do
+  /// not allow their containing ASTContext to be determined in all cases.
+  struct DCOrigin {
+DeclContext *DC;
+ASTContext *AST;
   };
 
+  typedef std::map OriginMap;
+  typedef 

r314177 - [XRay][Driver] Do not link in XRay runtime in shared libs

2017-09-25 Thread Dean Michael Berris via cfe-commits
Author: dberris
Date: Mon Sep 25 16:40:33 2017
New Revision: 314177

URL: http://llvm.org/viewvc/llvm-project?rev=314177=rev
Log:
[XRay][Driver] Do not link in XRay runtime in shared libs

Summary:
This change ensures that we don't link in the XRay runtime when building
shared libraries with clang. This doesn't prevent us from building
shared libraris tht have XRay instrumentation sleds, but it does prevent
us from linking in the static XRay runtime into a shared library.

The XRay runtime currently doesn't support dynamic registration of
instrumentation sleds in shared objects, which we'll start enabling in
the future. That work has to happen in the back-end and in the runtime.

Reviewers: rnk, pelikan

Subscribers: cfe-commits

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

Added:
cfe/trunk/test/Driver/XRay/xray-shared-noxray.cpp
Modified:
cfe/trunk/lib/Driver/ToolChains/Gnu.cpp

Modified: cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Gnu.cpp?rev=314177=314176=314177=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Gnu.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Gnu.cpp Mon Sep 25 16:40:33 2017
@@ -206,6 +206,10 @@ void tools::gcc::Linker::RenderExtraTool
 
 static bool addXRayRuntime(const ToolChain , const ArgList ,
ArgStringList ) {
+  // Do not add the XRay runtime to shared libraries.
+  if (Args.hasArg(options::OPT_shared))
+return false;
+
   if (Args.hasFlag(options::OPT_fxray_instrument,
options::OPT_fnoxray_instrument, false)) {
 CmdArgs.push_back("-whole-archive");
@@ -213,6 +217,7 @@ static bool addXRayRuntime(const ToolCha
 CmdArgs.push_back("-no-whole-archive");
 return true;
   }
+
   return false;
 }
 

Added: cfe/trunk/test/Driver/XRay/xray-shared-noxray.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/XRay/xray-shared-noxray.cpp?rev=314177=auto
==
--- cfe/trunk/test/Driver/XRay/xray-shared-noxray.cpp (added)
+++ cfe/trunk/test/Driver/XRay/xray-shared-noxray.cpp Mon Sep 25 16:40:33 2017
@@ -0,0 +1,14 @@
+// RUN: %clangxx -shared -fPIC -o /dev/null -v -fxray-instrument %s 2>&1 | \
+// RUN: FileCheck %s --check-prefix=SHARED
+// RUN: %clangxx -static -o /dev/null -v -fxray-instrument %s 2>&1 -DMAIN | \
+// RUN: FileCheck %s --check-prefix=STATIC
+// RUN: %clangxx -static -fPIE -o /dev/null -v -fxray-instrument %s 2>&1 \
+// RUN: -DMAIN | FileCheck %s --check-prefix=STATIC
+//
+// SHARED-NOT: {{clang_rt\.xray-}}
+// STATIC: {{clang_rt\.xray-}}
+int foo() { return 42; }
+
+#ifdef MAIN
+int main() { return foo(); }
+#endif


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


r314172 - clang-format/java: Always put space after `assert` keyword.

2017-09-25 Thread Nico Weber via cfe-commits
Author: nico
Date: Mon Sep 25 15:42:49 2017
New Revision: 314172

URL: http://llvm.org/viewvc/llvm-project?rev=314172=rev
Log:
clang-format/java: Always put space after `assert` keyword.

Previously, it was missing if the expression after the assert started with a (.

Modified:
cfe/trunk/lib/Format/TokenAnnotator.cpp
cfe/trunk/unittests/Format/FormatTestJava.cpp

Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=314172=314171=314172=diff
==
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Mon Sep 25 15:42:49 2017
@@ -2185,6 +2185,8 @@ bool TokenAnnotator::spaceRequiredBetwee
   const FormatToken ) {
   if (Left.is(tok::kw_return) && Right.isNot(tok::semi))
 return true;
+  if (Left.is(Keywords.kw_assert) && Style.Language == FormatStyle::LK_Java)
+return true;
   if (Style.ObjCSpaceAfterProperty && Line.Type == LT_ObjCProperty &&
   Left.Tok.getObjCKeywordID() == tok::objc_property)
 return true;

Modified: cfe/trunk/unittests/Format/FormatTestJava.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJava.cpp?rev=314172=314171=314172=diff
==
--- cfe/trunk/unittests/Format/FormatTestJava.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestJava.cpp Mon Sep 25 15:42:49 2017
@@ -412,6 +412,7 @@ TEST_F(FormatTestJava, SynchronizedKeywo
 
 TEST_F(FormatTestJava, AssertKeyword) {
   verifyFormat("assert a && b;");
+  verifyFormat("assert (a && b);");
 }
 
 TEST_F(FormatTestJava, PackageDeclarations) {


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


r314171 - Allow specifying sanitizers in blacklists

2017-09-25 Thread Vlad Tsyrklevich via cfe-commits
Author: vlad.tsyrklevich
Date: Mon Sep 25 15:11:12 2017
New Revision: 314171

URL: http://llvm.org/viewvc/llvm-project?rev=314171=rev
Log:
Allow specifying sanitizers in blacklists

Summary:
This is the follow-up patch to D37924.

This change refactors clang to use the the newly added section headers
in SpecialCaseList to specify which sanitizers blacklists entries
should apply to, like so:

  [cfi-vcall]
  fun:*bad_vcall*
  [cfi-derived-cast|cfi-unrelated-cast]
  fun:*bad_cast*

The SanitizerSpecialCaseList class has been added to allow querying by
SanitizerMask, and SanitizerBlacklist and its downstream users have been
updated to provide that information. Old blacklists not using sections
will continue to function identically since the blacklist entries will
be placed into a '[*]' section by default matching against all
sanitizers.

Reviewers: pcc, kcc, eugenis, vsk

Reviewed By: eugenis

Subscribers: dberris, cfe-commits, mgorny

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

Added:
cfe/trunk/include/clang/Basic/SanitizerSpecialCaseList.h
cfe/trunk/lib/Basic/SanitizerSpecialCaseList.cpp
cfe/trunk/test/CodeGen/Inputs/sanitizer-special-case-list.sanitized.txt
cfe/trunk/test/CodeGen/Inputs/sanitizer-special-case-list.unsanitized1.txt
cfe/trunk/test/CodeGen/Inputs/sanitizer-special-case-list.unsanitized2.txt
cfe/trunk/test/CodeGen/Inputs/sanitizer-special-case-list.unsanitized3.txt
cfe/trunk/test/CodeGen/Inputs/sanitizer-special-case-list.unsanitized4.txt
cfe/trunk/test/CodeGen/sanitizer-special-case-list.c
Modified:
cfe/trunk/docs/ControlFlowIntegrity.rst
cfe/trunk/docs/SanitizerSpecialCaseList.rst
cfe/trunk/include/clang/Basic/SanitizerBlacklist.h
cfe/trunk/lib/AST/Decl.cpp
cfe/trunk/lib/Basic/CMakeLists.txt
cfe/trunk/lib/Basic/SanitizerBlacklist.cpp
cfe/trunk/lib/Basic/XRayLists.cpp
cfe/trunk/lib/CodeGen/CGClass.cpp
cfe/trunk/lib/CodeGen/CGDeclCXX.cpp
cfe/trunk/lib/CodeGen/CGExpr.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.h
cfe/trunk/test/CodeGenCXX/cfi-blacklist.cpp

Modified: cfe/trunk/docs/ControlFlowIntegrity.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ControlFlowIntegrity.rst?rev=314171=314170=314171=diff
==
--- cfe/trunk/docs/ControlFlowIntegrity.rst (original)
+++ cfe/trunk/docs/ControlFlowIntegrity.rst Mon Sep 25 15:11:12 2017
@@ -243,17 +243,25 @@ Blacklist
 
 A :doc:`SanitizerSpecialCaseList` can be used to relax CFI checks for certain
 source files, functions and types using the ``src``, ``fun`` and ``type``
-entity types.
+entity types. Specific CFI modes can be be specified using ``[section]``
+headers.
 
 .. code-block:: bash
 
-# Suppress checking for code in a file.
+# Suppress all CFI checking for code in a file.
 src:bad_file.cpp
 src:bad_header.h
 # Ignore all functions with names containing MyFooBar.
 fun:*MyFooBar*
 # Ignore all types in the standard library.
 type:std::*
+# Disable only unrelated cast checks for this function
+[cfi-unrelated-cast]
+fun:*UnrelatedCast*
+# Disable CFI call checks for this function without affecting cast checks
+[cfi-vcall|cfi-nvcall|cfi-icall]
+fun:*BadCall*
+
 
 .. _cfi-cross-dso:
 

Modified: cfe/trunk/docs/SanitizerSpecialCaseList.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/SanitizerSpecialCaseList.rst?rev=314171=314170=314171=diff
==
--- cfe/trunk/docs/SanitizerSpecialCaseList.rst (original)
+++ cfe/trunk/docs/SanitizerSpecialCaseList.rst Mon Sep 25 15:11:12 2017
@@ -51,14 +51,23 @@ Example
 Format
 ==
 
-Each line contains an entity type, followed by a colon and a regular
-expression, specifying the names of the entities, optionally followed by
-an equals sign and a tool-specific category. Empty lines and lines starting
-with "#" are ignored. The meanining of ``*`` in regular expression for entity
-names is different - it is treated as in shell wildcarding. Two generic
-entity types are ``src`` and ``fun``, which allow user to add, respectively,
-source files and functions to special case list. Some sanitizer tools may
-introduce custom entity types - refer to tool-specific docs.
+Blacklists consist of entries, optionally grouped into sections. Empty lines 
and
+lines starting with "#" are ignored.
+
+Section names are regular expressions written in square brackets that denote
+which sanitizer the following entries apply to. For example, ``[address]``
+specifies AddressSanitizer while ``[cfi-vcall|cfi-icall]`` specifies Control
+Flow Integrity virtual and indirect call checking. Entries without a section
+will be placed under the ``[*]`` section applying to all enabled sanitizers.
+
+Entries contain an entity type, followed by a 

[PATCH] D37914: [OpenMP] Don't throw cudalib not found error if only front-end is required.

2017-09-25 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea reopened this revision.
gtbercea added a comment.
This revision is now accepted and ready to land.

Open.


Repository:
  rL LLVM

https://reviews.llvm.org/D37914



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


[PATCH] D37913: [OpenMP] Enable the existing nocudalib flag for OpenMP offloading toolchain.

2017-09-25 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea updated this revision to Diff 116621.
gtbercea added a comment.

Split line.


https://reviews.llvm.org/D37913

Files:
  lib/Driver/ToolChains/Cuda.cpp
  test/Driver/openmp-offload-gpu.c


Index: test/Driver/openmp-offload-gpu.c
===
--- test/Driver/openmp-offload-gpu.c
+++ test/Driver/openmp-offload-gpu.c
@@ -125,3 +125,13 @@
 // RUN:   | FileCheck -check-prefix=CHK-PTXAS-RELO %s
 
 // CHK-PTXAS-RELO: ptxas{{.*}}" "-c"
+
+/// ###
+
+/// Check that error is not thrown by toolchain when no cuda lib flag is used.
+/// Check that the flag is passed when -fopenmp-relocatable-target is used.
+// RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda 
-Xopenmp-target -march=sm_60 \
+// RUN:   -nocudalib -fopenmp-relocatable-target -save-temps 
-no-canonical-prefixes %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-FLAG-NOLIBDEVICE %s
+
+// CHK-FLAG-NOLIBDEVICE-NOT: error:{{.*}}sm_60
Index: lib/Driver/ToolChains/Cuda.cpp
===
--- lib/Driver/ToolChains/Cuda.cpp
+++ lib/Driver/ToolChains/Cuda.cpp
@@ -492,11 +492,11 @@
 if (DriverArgs.hasFlag(options::OPT_fcuda_approx_transcendentals,
options::OPT_fno_cuda_approx_transcendentals, 
false))
   CC1Args.push_back("-fcuda-approx-transcendentals");
-
-if (DriverArgs.hasArg(options::OPT_nocudalib))
-  return;
   }
 
+  if (DriverArgs.hasArg(options::OPT_nocudalib))
+return;
+
   std::string LibDeviceFile = CudaInstallation.getLibDeviceFile(GpuArch);
 
   if (LibDeviceFile.empty()) {


Index: test/Driver/openmp-offload-gpu.c
===
--- test/Driver/openmp-offload-gpu.c
+++ test/Driver/openmp-offload-gpu.c
@@ -125,3 +125,13 @@
 // RUN:   | FileCheck -check-prefix=CHK-PTXAS-RELO %s
 
 // CHK-PTXAS-RELO: ptxas{{.*}}" "-c"
+
+/// ###
+
+/// Check that error is not thrown by toolchain when no cuda lib flag is used.
+/// Check that the flag is passed when -fopenmp-relocatable-target is used.
+// RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 \
+// RUN:   -nocudalib -fopenmp-relocatable-target -save-temps -no-canonical-prefixes %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-FLAG-NOLIBDEVICE %s
+
+// CHK-FLAG-NOLIBDEVICE-NOT: error:{{.*}}sm_60
Index: lib/Driver/ToolChains/Cuda.cpp
===
--- lib/Driver/ToolChains/Cuda.cpp
+++ lib/Driver/ToolChains/Cuda.cpp
@@ -492,11 +492,11 @@
 if (DriverArgs.hasFlag(options::OPT_fcuda_approx_transcendentals,
options::OPT_fno_cuda_approx_transcendentals, false))
   CC1Args.push_back("-fcuda-approx-transcendentals");
-
-if (DriverArgs.hasArg(options::OPT_nocudalib))
-  return;
   }
 
+  if (DriverArgs.hasArg(options::OPT_nocudalib))
+return;
+
   std::string LibDeviceFile = CudaInstallation.getLibDeviceFile(GpuArch);
 
   if (LibDeviceFile.empty()) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r314159 - [x86] make assertions less strict in avx512f test file

2017-09-25 Thread Sanjay Patel via cfe-commits
Author: spatel
Date: Mon Sep 25 14:31:08 2017
New Revision: 314159

URL: http://llvm.org/viewvc/llvm-project?rev=314159=rev
Log:
[x86] make assertions less strict in avx512f test file

Missed a line in r314158.

Modified:
cfe/trunk/test/CodeGen/avx512f-builtins.c

Modified: cfe/trunk/test/CodeGen/avx512f-builtins.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/avx512f-builtins.c?rev=314159=314158=314159=diff
==
--- cfe/trunk/test/CodeGen/avx512f-builtins.c (original)
+++ cfe/trunk/test/CodeGen/avx512f-builtins.c Mon Sep 25 14:31:08 2017
@@ -8351,7 +8351,7 @@ __m128d test_mm_maskz_move_sd (__mmask8
   // CHECK-LABEL: @test_mm_maskz_move_sd
   // CHECK:  extractelement <2 x double> %{{.*}}, i32 0
   // CHECK:  phi double [ %{{.*}}, %{{.*}} ], [ 0.00e+00, %{{.*}} ]
-  // CHECK:  insertelement <2 x double> %6, double %cond.i, i32 0
+  // CHECK:  insertelement <2 x double> %{{.*}}, double %{{.*}}, i32 0
   return _mm_maskz_move_sd (__U, __A, __B);
 }
 


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


[PATCH] D37656: [cfi] Set function attributes for __cfi_* functions.

2017-09-25 Thread Evgenii Stepanov via Phabricator via cfe-commits
eugenis updated this revision to Diff 116618.
eugenis added a comment.

Switched to SetLLVMFunctionAttributes


https://reviews.llvm.org/D37656

Files:
  clang/lib/CodeGen/CGExpr.cpp
  clang/test/CodeGen/cfi-check-thumb.c
  llvm/lib/Transforms/IPO/CrossDSOCFI.cpp
  llvm/test/Transforms/CrossDSOCFI/thumb.ll


Index: llvm/test/Transforms/CrossDSOCFI/thumb.ll
===
--- llvm/test/Transforms/CrossDSOCFI/thumb.ll
+++ /dev/null
@@ -1,22 +0,0 @@
-; RUN: opt -mtriple=armv7-linux-android -S -cross-dso-cfi < %s | FileCheck 
--check-prefix=THUMB %s
-; RUN: opt -mtriple=thumbv7-linux-android -S -cross-dso-cfi < %s | FileCheck 
--check-prefix=THUMB %s
-; RUN: opt -mtriple=i386-linux -S -cross-dso-cfi < %s | FileCheck 
--check-prefix=NOTHUMB %s
-; RUN: opt -mtriple=x86_64-linux -S -cross-dso-cfi < %s | FileCheck 
--check-prefix=NOTHUMB %s
-
-target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64"
-
-define signext i8 @f() !type !0 !type !1 {
-entry:
-  ret i8 1
-}
-
-!llvm.module.flags = !{!2}
-
-!0 = !{i64 0, !"_ZTSFcvE"}
-!1 = !{i64 0, i64 111}
-!2 = !{i32 4, !"Cross-DSO CFI", i32 1}
-
-; THUMB: define void @__cfi_check({{.*}} #[[A:.*]] align 4096
-; THUMB: attributes #[[A]] = { {{.*}}"target-features"="+thumb-mode"
-
-; NOTHUMB: define void @__cfi_check({{.*}} align 4096
Index: llvm/lib/Transforms/IPO/CrossDSOCFI.cpp
===
--- llvm/lib/Transforms/IPO/CrossDSOCFI.cpp
+++ llvm/lib/Transforms/IPO/CrossDSOCFI.cpp
@@ -117,10 +117,6 @@
   F->deleteBody();
   F->setAlignment(4096);
 
-  Triple T(M.getTargetTriple());
-  if (T.isARM() || T.isThumb())
-F->addFnAttr("target-features", "+thumb-mode");
-
   auto args = F->arg_begin();
   Value  = *(args++);
   CallSiteTypeId.setName("CallSiteTypeId");
Index: clang/test/CodeGen/cfi-check-thumb.c
===
--- /dev/null
+++ clang/test/CodeGen/cfi-check-thumb.c
@@ -0,0 +1,18 @@
+// Test that __cfi_check and __cfi_check_fail have common attributes and 
calling convention.
+// Also __cfi_check is always using Thumb encoding.
+// RUN: %clang_cc1 -triple armv7-linux-android -O0 -fsanitize-cfi-cross-dso \
+// RUN: -fsanitize=cfi-vcall \
+// RUN: -emit-llvm -o - %s | FileCheck --check-prefixes=CHECK,CHECK-ARM %s
+//
+// RUN: %clang_cc1 -triple thumbv7-linux-android -O0 -fsanitize-cfi-cross-dso \
+// RUN: -fsanitize=cfi-vcall \
+// RUN: -emit-llvm -o - %s | FileCheck --check-prefixes=CHECK,CHECK-THUMB 
%s
+//
+// REQUIRES: arm-registered-target
+
+// CHECK-ARM: define weak_odr hidden void @__cfi_check_fail(i8*, i8*) 
#[[ARM:.*]] {
+// CHECK-THUMB: define weak_odr hidden void @__cfi_check_fail(i8*, i8*) 
#[[THUMB:.*]] {
+// CHECK: define weak void @__cfi_check(i64, i8*, i8*) #[[THUMB:.*]] {
+
+// CHECK-ARM: attributes #[[ARM]] = {{.*}}"target-features"="{{.*}}-thumb-mode
+// CHECK: attributes #[[THUMB]] = {{.*}}"target-features"="{{.*}}+thumb-mode
Index: clang/lib/CodeGen/CGExpr.cpp
===
--- clang/lib/CodeGen/CGExpr.cpp
+++ clang/lib/CodeGen/CGExpr.cpp
@@ -2928,6 +2928,18 @@
   llvm::CallInst::Create(
   llvm::Intrinsic::getDeclaration(M, llvm::Intrinsic::trap), "", BB);
   llvm::ReturnInst::Create(Ctx, nullptr, BB);
+
+  // Set default function attributes, but force thumb encoding if applicable.
+  const CGFunctionInfo  =
+  CGM.getTypes().arrangeBuiltinFunctionDeclaration(getContext().VoidTy, 
{});
+  FunctionDecl *FD =
+  FunctionDecl::Create(getContext(), getContext().getTranslationUnitDecl(),
+   {}, {}, {}, getContext().VoidTy, nullptr, 
SC_Extern);
+  const auto  = getTarget().getTriple();
+  if (Triple.isARM() || Triple.isThumb()) {
+FD->addAttr(TargetAttr::CreateImplicit(getContext(), "thumb"));
+  }
+  CGM.SetLLVMFunctionAttributes(FD, FI, F);
 }
 
 // This function is basically a switch over the CFI failure kind, which is
@@ -3011,6 +3023,9 @@
   }
 
   FinishFunction();
+
+  CGM.SetLLVMFunctionAttributes(nullptr, FI, F);
+
   // The only reference to this function will be created during LTO link.
   // Make sure it survives until then.
   CGM.addUsedGlobal(F);


Index: llvm/test/Transforms/CrossDSOCFI/thumb.ll
===
--- llvm/test/Transforms/CrossDSOCFI/thumb.ll
+++ /dev/null
@@ -1,22 +0,0 @@
-; RUN: opt -mtriple=armv7-linux-android -S -cross-dso-cfi < %s | FileCheck --check-prefix=THUMB %s
-; RUN: opt -mtriple=thumbv7-linux-android -S -cross-dso-cfi < %s | FileCheck --check-prefix=THUMB %s
-; RUN: opt -mtriple=i386-linux -S -cross-dso-cfi < %s | FileCheck --check-prefix=NOTHUMB %s
-; RUN: opt -mtriple=x86_64-linux -S -cross-dso-cfi < %s | FileCheck --check-prefix=NOTHUMB %s
-
-target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64"
-
-define signext i8 @f() !type !0 !type !1 {
-entry:
-  

r314158 - [x86] make assertions less strict in avx512f test file

2017-09-25 Thread Sanjay Patel via cfe-commits
Author: spatel
Date: Mon Sep 25 14:27:37 2017
New Revision: 314158

URL: http://llvm.org/viewvc/llvm-project?rev=314158=rev
Log:
[x86] make assertions less strict in avx512f test file

I'm not sure why yet, but there may be differences depending on the host?

Modified:
cfe/trunk/test/CodeGen/avx512f-builtins.c

Modified: cfe/trunk/test/CodeGen/avx512f-builtins.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/avx512f-builtins.c?rev=314158=314157=314158=diff
==
--- cfe/trunk/test/CodeGen/avx512f-builtins.c (original)
+++ cfe/trunk/test/CodeGen/avx512f-builtins.c Mon Sep 25 14:27:37 2017
@@ -8306,52 +8306,52 @@ __m512d test_mm512_setzero_pd()
 __mmask16 test_mm512_int2mask(int __a)
 {
   // CHECK-LABEL: test_mm512_int2mask
-  // CHECK: trunc i32 %1 to i16
+  // CHECK: trunc i32 %{{.*}} to i16
   return _mm512_int2mask(__a);
 }
 
 int test_mm512_mask2int(__mmask16 __a)
 {
   // CHECK-LABEL: test_mm512_mask2int
-  // CHECK: zext i16 %1 to i32
+  // CHECK: zext i16 %{{.*}} to i32
   return _mm512_mask2int(__a);
 }
 
 __m128 test_mm_mask_move_ss (__m128 __W, __mmask8 __U, __m128 __A, __m128 __B)
 {
   // CHECK-LABEL: @test_mm_mask_move_ss
-  // CHECK: %vecext.i = extractelement <4 x float> %6, i32 0
-  // CHECK: %vecext1.i = extractelement <4 x float> %7, i32 0
-  // CHECK: %cond.i = phi float [ %vecext.i, %cond.true.i ], [ %vecext1.i, 
%cond.false.i ]
-  // CHECK: %vecins.i = insertelement <4 x float> %8, float %cond.i, i32 0
+  // CHECK:  extractelement <4 x float> %{{.*}}, i32 0
+  // CHECK:  extractelement <4 x float> %{{.*}}, i32 0
+  // CHECK:  phi float [ %{{.*}}, %{{.*}} ], [ %{{.*}}, %{{.*}} ]
+  // CHECK:  insertelement <4 x float> %{{.*}}, float %cond.i, i32 0
   return _mm_mask_move_ss ( __W,  __U,  __A,  __B);
 }
 
 __m128 test_mm_maskz_move_ss (__mmask8 __U, __m128 __A, __m128 __B)
 {
   // CHECK-LABEL: @test_mm_maskz_move_ss
-  // CHECK: %vecext.i = extractelement <4 x float> %5, i32 0
-  // CHECK: %cond.i = phi float [ %vecext.i, %cond.true.i ], [ 0.00e+00, 
%cond.false.i ]
-  // CHECK: %vecins.i = insertelement <4 x float> %6, float %cond.i, i32 0
+  // CHECK:  extractelement <4 x float> %{{.*}}, i32 0
+  // CHECK:  phi float [ %{{.*}}, %{{.*}} ], [ 0.00e+00, %{{.*}} ]
+  // CHECK:  insertelement <4 x float> %{{.*}}, float %{{.*}}, i32 0
   return _mm_maskz_move_ss (__U, __A, __B);
 }
 
 __m128d test_mm_mask_move_sd (__m128d __W, __mmask8 __U, __m128d __A, __m128d 
__B)
 {
   // CHECK-LABEL: @test_mm_mask_move_sd
-  // CHECK: %vecext.i = extractelement <2 x double> %6, i32 0
-  // CHECK: %vecext1.i = extractelement <2 x double> %7, i32 0
-  // CHECK: %cond.i = phi double [ %vecext.i, %cond.true.i ], [ %vecext1.i, 
%cond.false.i ]
-  // CHECK: %vecins.i = insertelement <2 x double> %8, double %cond.i, i32 0
+  // CHECK:  extractelement <2 x double> %{{.*}}, i32 0
+  // CHECK:  extractelement <2 x double> %{{.*}}, i32 0
+  // CHECK:  phi double [ %{{.*}}, %{{.*}} ], [ %{{.*}}, %{{.*}} ]
+  // CHECK:  insertelement <2 x double> %{{.*}}, double %{{.*}}, i32 0
   return _mm_mask_move_sd ( __W,  __U,  __A,  __B);
 }
 
 __m128d test_mm_maskz_move_sd (__mmask8 __U, __m128d __A, __m128d __B)
 {
   // CHECK-LABEL: @test_mm_maskz_move_sd
-  // CHECK: %vecext.i = extractelement <2 x double> %5, i32 0
-  // CHECK: %cond.i = phi double [ %vecext.i, %cond.true.i ], [ 0.00e+00, 
%cond.false.i ]
-  // CHECK: %vecins.i = insertelement <2 x double> %6, double %cond.i, i32 0
+  // CHECK:  extractelement <2 x double> %{{.*}}, i32 0
+  // CHECK:  phi double [ %{{.*}}, %{{.*}} ], [ 0.00e+00, %{{.*}} ]
+  // CHECK:  insertelement <2 x double> %6, double %cond.i, i32 0
   return _mm_maskz_move_sd (__U, __A, __B);
 }
 


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


[PATCH] D38259: [OpenMP] Fix translation of target args

2017-09-25 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld created this revision.

ToolChain::TranslateArgs() returns nullptr if no changes are performed.
This would currently mean that OpenMPArgs are lost. Patch fixes this
by falling back to simply using OpenMPArgs in that case.


https://reviews.llvm.org/D38259

Files:
  lib/Driver/Compilation.cpp


Index: lib/Driver/Compilation.cpp
===
--- lib/Driver/Compilation.cpp
+++ lib/Driver/Compilation.cpp
@@ -57,14 +57,16 @@
 *TranslatedArgs, DeviceOffloadKind, AllocatedArgs);
 if (!OpenMPArgs) {
   Entry = TC->TranslateArgs(*TranslatedArgs, BoundArch, DeviceOffloadKind);
+  if (!Entry)
+Entry = TranslatedArgs;
 } else {
   Entry = TC->TranslateArgs(*OpenMPArgs, BoundArch, DeviceOffloadKind);
-  delete OpenMPArgs;
+  if (!Entry)
+Entry = OpenMPArgs;
+  else
+delete OpenMPArgs;
 }
 
-if (!Entry)
-  Entry = TranslatedArgs;
-
 // Add allocated arguments to the final DAL.
 for (auto ArgPtr : AllocatedArgs) {
   Entry->AddSynthesizedArg(ArgPtr);


Index: lib/Driver/Compilation.cpp
===
--- lib/Driver/Compilation.cpp
+++ lib/Driver/Compilation.cpp
@@ -57,14 +57,16 @@
 *TranslatedArgs, DeviceOffloadKind, AllocatedArgs);
 if (!OpenMPArgs) {
   Entry = TC->TranslateArgs(*TranslatedArgs, BoundArch, DeviceOffloadKind);
+  if (!Entry)
+Entry = TranslatedArgs;
 } else {
   Entry = TC->TranslateArgs(*OpenMPArgs, BoundArch, DeviceOffloadKind);
-  delete OpenMPArgs;
+  if (!Entry)
+Entry = OpenMPArgs;
+  else
+delete OpenMPArgs;
 }
 
-if (!Entry)
-  Entry = TranslatedArgs;
-
 // Add allocated arguments to the final DAL.
 for (auto ArgPtr : AllocatedArgs) {
   Entry->AddSynthesizedArg(ArgPtr);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D38258: [OpenMP] Fix passing of -m arguments to device toolchain

2017-09-25 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld created this revision.

AuxTriple is not set if host and device share a toolchain. Also,
removing an argument modifies the DAL which needs to be returned
for future use.
(Move tests back to offload-openmp.c as they are not related to GPUs.)


https://reviews.llvm.org/D38258

Files:
  lib/Driver/ToolChain.cpp
  test/Driver/openmp-offload-gpu.c
  test/Driver/openmp-offload.c

Index: test/Driver/openmp-offload.c
===
--- test/Driver/openmp-offload.c
+++ test/Driver/openmp-offload.c
@@ -39,6 +39,54 @@
 
 /// ###
 
+/// Check -Xopenmp-target=powerpc64le-ibm-linux-gnu -mcpu=pwr7 is passed when compiling for the device.
+// RUN:   %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=powerpc64le-ibm-linux-gnu -Xopenmp-target=powerpc64le-ibm-linux-gnu -mcpu=pwr7 %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-FOPENMP-EQ-TARGET %s
+
+// CHK-FOPENMP-EQ-TARGET: clang{{.*}} "-target-cpu" "pwr7" {{.*}}"-fopenmp-is-device"
+
+/// ###
+
+/// Check -Xopenmp-target -mcpu=pwr7 is passed when compiling for the device.
+// RUN:   %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=powerpc64le-ibm-linux-gnu -Xopenmp-target -mcpu=pwr7 %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-FOPENMP-TARGET %s
+
+// CHK-FOPENMP-TARGET: clang{{.*}} "-target-cpu" "pwr7" {{.*}}"-fopenmp-is-device"
+
+/// ##
+
+/// Check -mcpu=pwr7 is passed to the same triple.
+// RUN:%clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=powerpc64le-ibm-linux-gnu -target powerpc64le-ibm-linux-gnu -mcpu=pwr7 %s 2>&1 \
+// RUN:| FileCheck -check-prefix=CHK-FOPENMP-MCPU-TO-SAME-TRIPLE %s
+
+// CHK-FOPENMP-MCPU-TO-SAME-TRIPLE: clang{{.*}} "-target-cpu" "pwr7" {{.*}}"-fopenmp-is-device"
+
+/// ##
+
+/// Check -march=pwr7 is NOT passed to nvptx64-nvidia-cuda.
+// RUN:%clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -march=pwr7 %s 2>&1 \
+// RUN:| FileCheck -check-prefix=CHK-FOPENMP-MARCH-TO-GPU %s
+
+// CHK-FOPENMP-MARCH-TO-GPU-NOT: clang{{.*}} "-target-cpu" "pwr7" {{.*}}"-fopenmp-is-device"
+
+/// ###
+
+/// Check -Xopenmp-target triggers error when multiple triples are used.
+// RUN:   %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=powerpc64le-ibm-linux-gnu,powerpc64le-unknown-linux-gnu -Xopenmp-target -mcpu=pwr8 %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-FOPENMP-TARGET-AMBIGUOUS-ERROR %s
+
+// CHK-FOPENMP-TARGET-AMBIGUOUS-ERROR: clang{{.*}} error: cannot deduce implicit triple value for -Xopenmp-target, specify triple using -Xopenmp-target=
+
+/// ###
+
+/// Check -Xopenmp-target triggers error when an option requiring arguments is passed to it.
+// RUN:   %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=powerpc64le-ibm-linux-gnu -Xopenmp-target -Xopenmp-target -mcpu=pwr8 %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-FOPENMP-TARGET-NESTED-ERROR %s
+
+// CHK-FOPENMP-TARGET-NESTED-ERROR: clang{{.*}} error: invalid -Xopenmp-target argument: '-Xopenmp-target -Xopenmp-target', options requiring arguments are unsupported
+
+/// ###
+
 /// Check the phases graph when using a single target, different from the host.
 /// We should have an offload action joining the host compile and device
 /// preprocessor and another one joining the device linking outputs to the host
Index: test/Driver/openmp-offload-gpu.c
===
--- test/Driver/openmp-offload-gpu.c
+++ test/Driver/openmp-offload-gpu.c
@@ -9,38 +9,6 @@
 
 /// ###
 
-/// Check -Xopenmp-target=powerpc64le-ibm-linux-gnu -march=pwr7 is passed when compiling for the device.
-// RUN:   %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=powerpc64le-ibm-linux-gnu -Xopenmp-target=powerpc64le-ibm-linux-gnu -mcpu=pwr7 %s 2>&1 \
-// RUN:   | FileCheck -check-prefix=CHK-FOPENMP-EQ-TARGET %s
-
-// CHK-FOPENMP-EQ-TARGET: clang{{.*}} "-target-cpu" "pwr7"
-
-/// ###
-
-/// Check -Xopenmp-target -march=pwr7 is passed when compiling for the device.
-// RUN:   %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=powerpc64le-ibm-linux-gnu -Xopenmp-target -mcpu=pwr7 %s 2>&1 \
-// RUN:   | FileCheck -check-prefix=CHK-FOPENMP-TARGET %s
-
-// CHK-FOPENMP-TARGET: clang{{.*}} "-target-cpu" 

[PATCH] D38257: [OpenMP] Fix memory leak when translating arguments

2017-09-25 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld created this revision.

Parsing the argument after -Xopenmp-target allocates memory that needs
to be freed. Associate it with the final DerivedArgList after we know
which one will be used.


https://reviews.llvm.org/D38257

Files:
  include/clang/Driver/ToolChain.h
  lib/Driver/Compilation.cpp
  lib/Driver/ToolChain.cpp
  test/Driver/openmp-offload-gpu.c


Index: test/Driver/openmp-offload-gpu.c
===
--- test/Driver/openmp-offload-gpu.c
+++ test/Driver/openmp-offload-gpu.c
@@ -2,9 +2,6 @@
 /// Perform several driver tests for OpenMP offloading
 ///
 
-// Until this test is stabilized on all local configurations.
-// UNSUPPORTED: linux
-
 // REQUIRES: clang-driver
 // REQUIRES: x86-registered-target
 // REQUIRES: powerpc-registered-target
Index: lib/Driver/ToolChain.cpp
===
--- lib/Driver/ToolChain.cpp
+++ lib/Driver/ToolChain.cpp
@@ -800,9 +800,10 @@
   return VersionTuple();
 }
 
-llvm::opt::DerivedArgList *
-ToolChain::TranslateOpenMPTargetArgs(const llvm::opt::DerivedArgList ,
-Action::OffloadKind DeviceOffloadKind) const {
+llvm::opt::DerivedArgList *ToolChain::TranslateOpenMPTargetArgs(
+const llvm::opt::DerivedArgList ,
+Action::OffloadKind DeviceOffloadKind,
+SmallVector ) const {
   if (DeviceOffloadKind == Action::OFK_OpenMP) {
 DerivedArgList *DAL = new DerivedArgList(Args.getBaseArgs());
 const OptTable  = getDriver().getOpts();
@@ -854,6 +855,7 @@
   }
   XOpenMPTargetArg->setBaseArg(A);
   A = XOpenMPTargetArg.release();
+  AllocatedArgs.push_back(A);
   DAL->append(A);
   NewArgAdded = true;
 }
Index: lib/Driver/Compilation.cpp
===
--- lib/Driver/Compilation.cpp
+++ lib/Driver/Compilation.cpp
@@ -51,9 +51,10 @@
 
   DerivedArgList * = TCArgs[{TC, BoundArch, DeviceOffloadKind}];
   if (!Entry) {
+SmallVector AllocatedArgs;
 // Translate OpenMP toolchain arguments provided via the -Xopenmp-target 
flags.
-DerivedArgList *OpenMPArgs = TC->TranslateOpenMPTargetArgs(*TranslatedArgs,
-DeviceOffloadKind);
+DerivedArgList *OpenMPArgs = TC->TranslateOpenMPTargetArgs(
+*TranslatedArgs, DeviceOffloadKind, AllocatedArgs);
 if (!OpenMPArgs) {
   Entry = TC->TranslateArgs(*TranslatedArgs, BoundArch, DeviceOffloadKind);
 } else {
@@ -63,6 +64,11 @@
 
 if (!Entry)
   Entry = TranslatedArgs;
+
+// Add allocated arguments to the final DAL.
+for (auto ArgPtr : AllocatedArgs) {
+  Entry->AddSynthesizedArg(ArgPtr);
+}
   }
 
   return *Entry;
Index: include/clang/Driver/ToolChain.h
===
--- include/clang/Driver/ToolChain.h
+++ include/clang/Driver/ToolChain.h
@@ -249,9 +249,10 @@
   ///
   /// \param DeviceOffloadKind - The device offload kind used for the
   /// translation.
-  virtual llvm::opt::DerivedArgList *
-  TranslateOpenMPTargetArgs(const llvm::opt::DerivedArgList ,
-  Action::OffloadKind DeviceOffloadKind) const;
+  virtual llvm::opt::DerivedArgList *TranslateOpenMPTargetArgs(
+  const llvm::opt::DerivedArgList ,
+  Action::OffloadKind DeviceOffloadKind,
+  SmallVector ) const;
 
   /// Choose a tool to use to handle the action \p JA.
   ///


Index: test/Driver/openmp-offload-gpu.c
===
--- test/Driver/openmp-offload-gpu.c
+++ test/Driver/openmp-offload-gpu.c
@@ -2,9 +2,6 @@
 /// Perform several driver tests for OpenMP offloading
 ///
 
-// Until this test is stabilized on all local configurations.
-// UNSUPPORTED: linux
-
 // REQUIRES: clang-driver
 // REQUIRES: x86-registered-target
 // REQUIRES: powerpc-registered-target
Index: lib/Driver/ToolChain.cpp
===
--- lib/Driver/ToolChain.cpp
+++ lib/Driver/ToolChain.cpp
@@ -800,9 +800,10 @@
   return VersionTuple();
 }
 
-llvm::opt::DerivedArgList *
-ToolChain::TranslateOpenMPTargetArgs(const llvm::opt::DerivedArgList ,
-Action::OffloadKind DeviceOffloadKind) const {
+llvm::opt::DerivedArgList *ToolChain::TranslateOpenMPTargetArgs(
+const llvm::opt::DerivedArgList ,
+Action::OffloadKind DeviceOffloadKind,
+SmallVector ) const {
   if (DeviceOffloadKind == Action::OFK_OpenMP) {
 DerivedArgList *DAL = new DerivedArgList(Args.getBaseArgs());
 const OptTable  = getDriver().getOpts();
@@ -854,6 +855,7 @@
   }
   XOpenMPTargetArg->setBaseArg(A);
   A = XOpenMPTargetArg.release();
+  AllocatedArgs.push_back(A);
   DAL->append(A);
   NewArgAdded = true;
 }
Index: lib/Driver/Compilation.cpp
===
--- lib/Driver/Compilation.cpp
+++ lib/Driver/Compilation.cpp
@@ -51,9 +51,10 @@
 
   DerivedArgList * = TCArgs[{TC, BoundArch, 

[PATCH] D37903: Fix assume-filename handling in clang-format.el

2017-09-25 Thread Micah Werbitt via Phabricator via cfe-commits
werbitt updated this revision to Diff 116605.
werbitt added a comment.

Cleanup Docs

- The first line of of an emacs docstring should be a complete sentence.

-Specify that "-assume-filname" is a clang-format option


https://reviews.llvm.org/D37903

Files:
  tools/clang-format/clang-format.el


Index: tools/clang-format/clang-format.el
===
--- tools/clang-format/clang-format.el
+++ tools/clang-format/clang-format.el
@@ -119,12 +119,10 @@
   (byte-to-position (1+ byte)
 
 ;;;###autoload
-(defun clang-format-region (start end  style assume-file-name)
-  "Use clang-format to format the code between START and END according to STYLE
-using ASSUME-FILE-NAME to locate a style config file. If called interactively
-uses the region or the current statement if there is no active region. If no
-style is given uses `clang-format-style'. If no assume-file-name is given uses
-`buffer-file-name'."
+(defun clang-format-region (start end  style)
+  "Use clang-format to format the code between START and END according to 
STYLE.
+If called interactively uses the region or the current statement if there
+is no active region.  If no style is given uses `clang-format-style'."
   (interactive
(if (use-region-p)
(list (region-beginning) (region-end))
@@ -133,9 +131,6 @@
   (unless style
 (setq style clang-format-style))
 
-  (unless assume-file-name
-(setq assume-file-name buffer-file-name))
-
   (let ((file-start (clang-format--bufferpos-to-filepos start 'approximate
 'utf-8-unix))
 (file-end (clang-format--bufferpos-to-filepos end 'approximate
@@ -149,20 +144,16 @@
 ;; always use ‘utf-8-unix’ and ignore the buffer coding system.
 (default-process-coding-system '(utf-8-unix . utf-8-unix)))
 (unwind-protect
-(let ((status (apply #'call-process-region
- nil nil clang-format-executable
- nil `(,temp-buffer ,temp-file) nil
- `("-output-replacements-xml"
-   ;; Gaurd against a nil assume-file-name.
-   ;; If -assume-filename is given a blank string
-   ;; it will crash as per the following bug report
-   ;; https://bugs.llvm.org/show_bug.cgi?id=34667
-   ,@(and assume-file-name
-  (list "-assume-filename" 
assume-file-name))
-   "-style" ,style
-   "-offset" ,(number-to-string file-start)
-   "-length" ,(number-to-string (- file-end 
file-start))
-   "-cursor" ,(number-to-string cursor
+(let ((status (call-process-region
+   nil nil clang-format-executable
+   nil `(,temp-buffer ,temp-file) nil
+
+   "-output-replacements-xml"
+   "-assume-filename" (or (buffer-file-name) "")
+   "-style" style
+   "-offset" (number-to-string file-start)
+   "-length" (number-to-string (- file-end file-start))
+   "-cursor" (number-to-string cursor)))
   (stderr (with-temp-buffer
 (unless (zerop (cadr (insert-file-contents temp-file)))
   (insert ": "))
@@ -190,12 +181,10 @@
   (when (buffer-name temp-buffer) (kill-buffer temp-buffer)
 
 ;;;###autoload
-(defun clang-format-buffer ( style assume-file-name)
-  "Use clang-format to format the current buffer according to STYLE using
-ASSUME-FILE-NAME to locate a style config file. If no style is given uses
-`clang-format-style'. If no assume-file-name is given uses `buffer-file-name'."
+(defun clang-format-buffer ( style)
+  "Use clang-format to format the current buffer according to STYLE."
   (interactive)
-  (clang-format-region (point-min) (point-max) style assume-file-name))
+  (clang-format-region (point-min) (point-max) style))
 
 ;;;###autoload
 (defalias 'clang-format 'clang-format-region)


Index: tools/clang-format/clang-format.el
===
--- tools/clang-format/clang-format.el
+++ tools/clang-format/clang-format.el
@@ -119,12 +119,10 @@
   (byte-to-position (1+ byte)
 
 ;;;###autoload
-(defun clang-format-region (start end  style assume-file-name)
-  "Use clang-format to format the code between START and END according to STYLE
-using ASSUME-FILE-NAME to locate a style config file. If called interactively
-uses the region or the current statement if there is no active region. If no
-style is given uses `clang-format-style'. If no assume-file-name is given uses
-`buffer-file-name'."
+(defun clang-format-region (start end  style)
+  "Use 

[PATCH] D37903: Fix assume-filename handling in clang-format.el

2017-09-25 Thread Micah Werbitt via Phabricator via cfe-commits
werbitt reclaimed this revision.
werbitt added a comment.
This revision is now accepted and ready to land.

It looks like I just uploaded a diff against a bad branch, and I can't figure 
out how to undo it. Sorry about that.


https://reviews.llvm.org/D37903



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


[PATCH] D38209: [Sema] Correct nothrow inherited by noexcept

2017-09-25 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a reviewer: rsmith.
aaron.ballman added a comment.

In https://reviews.llvm.org/D38209#880553, @STL_MSFT wrote:

> > do you think `__declspec(nothrow)` calling the terminate handler in Clang 
> > is a bug?
>
> It's certainly a behavior difference with potential performance impact, 
> although I don't think it can be viewed as a bug, strictly speaking. MSVC 
> treats `__declspec(nothrow)` as an optimization request, with undefined 
> behavior if it's violated. Termination is definitely one of the possible 
> results of undefined behavior.
>
> We've recently had to slightly rethink our EH strategy in light of C++17's 
> addition of noexcept into the type system, and the removal of dynamic 
> exception specifications (and the change in semantics to throw()). MSVC's 
> /EHsc makes this extra fun. If you're interested, I can put you in contact 
> with the compiler dev who recently made those changes.


That might be helpful. I'm mostly interested in whether `__declspec(nothrow)` 
is intended to be part of the type system in the same way `noexcept` specifiers 
are.

@erichkeane -- can you see whether `__attribute__((nothrow))` is part of the 
type system as far as GCC is concerned (in C++17 mode, assuming GCC has 
implemented that functionality already)?


https://reviews.llvm.org/D38209



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


[PATCH] D38209: [Sema] Correct nothrow inherited by noexcept

2017-09-25 Thread Stephan T. Lavavej via Phabricator via cfe-commits
STL_MSFT added a comment.

> do you think `__declspec(nothrow)` calling the terminate handler in Clang is 
> a bug?

It's certainly a behavior difference with potential performance impact, 
although I don't think it can be viewed as a bug, strictly speaking. MSVC 
treats `__declspec(nothrow)` as an optimization request, with undefined 
behavior if it's violated. Termination is definitely one of the possible 
results of undefined behavior.

We've recently had to slightly rethink our EH strategy in light of C++17's 
addition of noexcept into the type system, and the removal of dynamic exception 
specifications (and the change in semantics to throw()). MSVC's /EHsc makes 
this extra fun. If you're interested, I can put you in contact with the 
compiler dev who recently made those changes.


https://reviews.llvm.org/D38209



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


[PATCH] D36806: Switch to cantFail(), since it does the same assertion.

2017-09-25 Thread Stephen Hines via Phabricator via cfe-commits
srhines added a comment.

Ping.


https://reviews.llvm.org/D36806



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


r314145 - Reinstall the patch "Use EmitPointerWithAlignment to get alignment information of the pointer used in atomic expr" after fixing PR31620.

2017-09-25 Thread Wei Mi via cfe-commits
Author: wmi
Date: Mon Sep 25 12:57:59 2017
New Revision: 314145

URL: http://llvm.org/viewvc/llvm-project?rev=314145=rev
Log:
Reinstall the patch "Use EmitPointerWithAlignment to get alignment information 
of the pointer used in atomic expr" after fixing PR31620.

This is to fix PR34347. EmitAtomicExpr now only uses alignment information from
Type, instead of Decl, so when the declaration of an atomic variable is marked
to have the alignment equal as its size, EmitAtomicExpr doesn't know about it 
and
will generate libcall instead of atomic op. The patch uses 
EmitPointerWithAlignment
to get the precise alignment information.

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

Added:
cfe/trunk/test/CodeGenCXX/atomic-align.cpp
Modified:
cfe/trunk/lib/CodeGen/CGAtomic.cpp

Modified: cfe/trunk/lib/CodeGen/CGAtomic.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGAtomic.cpp?rev=314145=314144=314145=diff
==
--- cfe/trunk/lib/CodeGen/CGAtomic.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGAtomic.cpp Mon Sep 25 12:57:59 2017
@@ -745,19 +745,19 @@ RValue CodeGenFunction::EmitAtomicExpr(A
   QualType MemTy = AtomicTy;
   if (const AtomicType *AT = AtomicTy->getAs())
 MemTy = AT->getValueType();
-  CharUnits sizeChars, alignChars;
-  std::tie(sizeChars, alignChars) = getContext().getTypeInfoInChars(AtomicTy);
-  uint64_t Size = sizeChars.getQuantity();
-  unsigned MaxInlineWidthInBits = getTarget().getMaxAtomicInlineWidth();
-  bool UseLibcall = (sizeChars != alignChars ||
- getContext().toBits(sizeChars) > MaxInlineWidthInBits);
-
   llvm::Value *IsWeak = nullptr, *OrderFail = nullptr;
 
   Address Val1 = Address::invalid();
   Address Val2 = Address::invalid();
   Address Dest = Address::invalid();
-  Address Ptr(EmitScalarExpr(E->getPtr()), alignChars);
+  Address Ptr = EmitPointerWithAlignment(E->getPtr());
+
+  CharUnits sizeChars, alignChars;
+  std::tie(sizeChars, alignChars) = getContext().getTypeInfoInChars(AtomicTy);
+  uint64_t Size = sizeChars.getQuantity();
+  unsigned MaxInlineWidthInBits = getTarget().getMaxAtomicInlineWidth();
+  bool UseLibcall = ((Ptr.getAlignment() % sizeChars) != 0 ||
+ getContext().toBits(sizeChars) > MaxInlineWidthInBits);
 
   if (E->getOp() == AtomicExpr::AO__c11_atomic_init ||
   E->getOp() == AtomicExpr::AO__opencl_atomic_init) {

Added: cfe/trunk/test/CodeGenCXX/atomic-align.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/atomic-align.cpp?rev=314145=auto
==
--- cfe/trunk/test/CodeGenCXX/atomic-align.cpp (added)
+++ cfe/trunk/test/CodeGenCXX/atomic-align.cpp Mon Sep 25 12:57:59 2017
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 %s -std=c++11 -emit-llvm -o - -triple=x86_64-linux-gnu | 
FileCheck %s
+
+struct AM {
+  int f1, f2;
+};
+alignas(8) AM m;
+AM load1() {
+  AM am;
+  // m is declared to align to 8bytes, so generate load atomic instead
+  // of libcall.
+  // CHECK-LABEL: @_Z5load1v
+  // CHECK: load atomic {{.*}} monotonic
+  __atomic_load(, , 0);
+  return am;
+}
+
+struct BM {
+  int f1;
+  alignas(8) AM f2;
+};
+BM bm;
+AM load2() {
+  AM am;
+  // BM::f2 is declared to align to 8bytes, so generate load atomic instead
+  // of libcall.
+  // CHECK-LABEL: @_Z5load2v
+  // CHECK: load atomic {{.*}} monotonic
+  __atomic_load(, , 0);
+  return am;
+}


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


[PATCH] D38250: [libunwind] Implement the Get/SetTopOfFunctionStack functions via a __thread TLS variable

2017-09-25 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo created this revision.

When targeting apple platforms, these functions are implemented in
Unwind_AppleExtras.cpp, but there's previously no implementation for
other platforms.

Does `__thread` have any specific runtime requirements on e.g. windows?


https://reviews.llvm.org/D38250

Files:
  src/Unwind-sjlj.c


Index: src/Unwind-sjlj.c
===
--- src/Unwind-sjlj.c
+++ src/Unwind-sjlj.c
@@ -465,4 +465,18 @@
   return 0;
 }
 
+#ifndef __APPLE__
+__thread struct _Unwind_FunctionContext *stack = NULL;
+
+_LIBUNWIND_HIDDEN
+struct _Unwind_FunctionContext *__Unwind_SjLj_GetTopOfFunctionStack() {
+  return stack;
+}
+
+_LIBUNWIND_HIDDEN
+void __Unwind_SjLj_SetTopOfFunctionStack(struct _Unwind_FunctionContext *fc) {
+  stack = fc;
+}
+#endif // !defined(__APPLE__)
+
 #endif // defined(_LIBUNWIND_BUILD_SJLJ_APIS)


Index: src/Unwind-sjlj.c
===
--- src/Unwind-sjlj.c
+++ src/Unwind-sjlj.c
@@ -465,4 +465,18 @@
   return 0;
 }
 
+#ifndef __APPLE__
+__thread struct _Unwind_FunctionContext *stack = NULL;
+
+_LIBUNWIND_HIDDEN
+struct _Unwind_FunctionContext *__Unwind_SjLj_GetTopOfFunctionStack() {
+  return stack;
+}
+
+_LIBUNWIND_HIDDEN
+void __Unwind_SjLj_SetTopOfFunctionStack(struct _Unwind_FunctionContext *fc) {
+  stack = fc;
+}
+#endif // !defined(__APPLE__)
+
 #endif // defined(_LIBUNWIND_BUILD_SJLJ_APIS)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D38249: [libunwind] Skip building unused parts when targeting SJLJ

2017-09-25 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo created this revision.
Herald added subscribers: kristof.beyls, aemerson.

When SJLJ exceptions are used, those functions aren't used.

This fixes build failures on ARM with SJLJ enabled, such as armv7/iOS.


https://reviews.llvm.org/D38249

Files:
  src/UnwindLevel1.c
  src/UnwindRegistersRestore.S
  src/UnwindRegistersSave.S
  src/libunwind.cpp


Index: src/libunwind.cpp
===
--- src/libunwind.cpp
+++ src/libunwind.cpp
@@ -24,6 +24,7 @@
 #include 
 
 
+#ifndef __USING_SJLJ_EXCEPTIONS__
 #include "AddressSpace.hpp"
 #include "UnwindCursor.hpp"
 
@@ -341,6 +342,7 @@
   
DwarfFDECache::removeAllIn((LocalAddressSpace::pint_t)fde);
 }
 #endif // defined(_LIBUNWIND_SUPPORT_DWARF_UNWIND)
+#endif // !defined(__USING_SJLJ_EXCEPTIONS__)
 
 
 
Index: src/UnwindRegistersSave.S
===
--- src/UnwindRegistersSave.S
+++ src/UnwindRegistersSave.S
@@ -289,7 +289,7 @@
   movx0, #0   // return UNW_ESUCCESS
   ret
 
-#elif defined(__arm__) && !defined(__APPLE__)
+#elif defined(__arm__) && !(defined(__APPLE__) || 
defined(__USING_SJLJ_EXCEPTIONS__))
 
 #if !defined(__ARM_ARCH_ISA_ARM)
   .thumb
Index: src/UnwindRegistersRestore.S
===
--- src/UnwindRegistersRestore.S
+++ src/UnwindRegistersRestore.S
@@ -308,7 +308,7 @@
   ldpx0, x1,  [x0, #0x000]  // restore x0,x1
   retx30// jump to pc
 
-#elif defined(__arm__) && !defined(__APPLE__)
+#elif defined(__arm__) && !(defined(__APPLE__) || 
defined(__USING_SJLJ_EXCEPTIONS__))
 
 #if !defined(__ARM_ARCH_ISA_ARM)
   .thumb
Index: src/UnwindLevel1.c
===
--- src/UnwindLevel1.c
+++ src/UnwindLevel1.c
@@ -30,7 +30,7 @@
 #include "unwind.h"
 #include "config.h"
 
-#if !defined(_LIBUNWIND_ARM_EHABI)
+#if !defined(_LIBUNWIND_ARM_EHABI) && !defined(__USING_SJLJ_EXCEPTIONS__)
 
 static _Unwind_Reason_Code
 unwind_phase1(unw_context_t *uc, unw_cursor_t *cursor, _Unwind_Exception 
*exception_object) {
@@ -503,4 +503,4 @@
   unw_set_reg(cursor, UNW_REG_IP, value);
 }
 
-#endif // !defined(_LIBUNWIND_ARM_EHABI)
+#endif // !defined(_LIBUNWIND_ARM_EHABI) && !defined(__USING_SJLJ_EXCEPTIONS__)


Index: src/libunwind.cpp
===
--- src/libunwind.cpp
+++ src/libunwind.cpp
@@ -24,6 +24,7 @@
 #include 
 
 
+#ifndef __USING_SJLJ_EXCEPTIONS__
 #include "AddressSpace.hpp"
 #include "UnwindCursor.hpp"
 
@@ -341,6 +342,7 @@
   DwarfFDECache::removeAllIn((LocalAddressSpace::pint_t)fde);
 }
 #endif // defined(_LIBUNWIND_SUPPORT_DWARF_UNWIND)
+#endif // !defined(__USING_SJLJ_EXCEPTIONS__)
 
 
 
Index: src/UnwindRegistersSave.S
===
--- src/UnwindRegistersSave.S
+++ src/UnwindRegistersSave.S
@@ -289,7 +289,7 @@
   movx0, #0   // return UNW_ESUCCESS
   ret
 
-#elif defined(__arm__) && !defined(__APPLE__)
+#elif defined(__arm__) && !(defined(__APPLE__) || defined(__USING_SJLJ_EXCEPTIONS__))
 
 #if !defined(__ARM_ARCH_ISA_ARM)
   .thumb
Index: src/UnwindRegistersRestore.S
===
--- src/UnwindRegistersRestore.S
+++ src/UnwindRegistersRestore.S
@@ -308,7 +308,7 @@
   ldpx0, x1,  [x0, #0x000]  // restore x0,x1
   retx30// jump to pc
 
-#elif defined(__arm__) && !defined(__APPLE__)
+#elif defined(__arm__) && !(defined(__APPLE__) || defined(__USING_SJLJ_EXCEPTIONS__))
 
 #if !defined(__ARM_ARCH_ISA_ARM)
   .thumb
Index: src/UnwindLevel1.c
===
--- src/UnwindLevel1.c
+++ src/UnwindLevel1.c
@@ -30,7 +30,7 @@
 #include "unwind.h"
 #include "config.h"
 
-#if !defined(_LIBUNWIND_ARM_EHABI)
+#if !defined(_LIBUNWIND_ARM_EHABI) && !defined(__USING_SJLJ_EXCEPTIONS__)
 
 static _Unwind_Reason_Code
 unwind_phase1(unw_context_t *uc, unw_cursor_t *cursor, _Unwind_Exception *exception_object) {
@@ -503,4 +503,4 @@
   unw_set_reg(cursor, UNW_REG_IP, value);
 }
 
-#endif // !defined(_LIBUNWIND_ARM_EHABI)
+#endif // !defined(_LIBUNWIND_ARM_EHABI) && !defined(__USING_SJLJ_EXCEPTIONS__)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D36737: [analyzer] Store design discussions in docs/analyzer for future use.

2017-09-25 Thread Anna Zaks via Phabricator via cfe-commits
zaks.anna accepted this revision.
zaks.anna added a comment.
This revision is now accepted and ready to land.

Thanks!


https://reviews.llvm.org/D36737



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


[PATCH] D30295: [analyzer] clarify undef shift result when shift count is negative or exceeds the bit width

2017-09-25 Thread Anna Zaks via Phabricator via cfe-commits
zaks.anna added inline comments.



Comment at: lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp:134
+else if (I->isUnsigned())
+  OS << I->getZExtValue() << ", which is";
+else

Please print single quotes around the value.



Comment at: lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp:138
+
+OS << " larger or equal with the width of type '"
+   << B->getLHS()->getType().getAsString() << "'.";

"equal with the width" -> "equal to the width"


Repository:
  rL LLVM

https://reviews.llvm.org/D30295



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


[PATCH] D30295: [analyzer] clarify undef shift result when shift count is negative or exceeds the bit width

2017-09-25 Thread Anna Zaks via Phabricator via cfe-commits
zaks.anna added a comment.

Sorry for the wait!


Repository:
  rL LLVM

https://reviews.llvm.org/D30295



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


[PATCH] D38247: [libunwind] Correct data types in the _Unwind_FunctionContext struct

2017-09-25 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo created this revision.

This makes it match the definition used within llvm and in libgcc, we 
previously got the wrong layout on 64 bit.


https://reviews.llvm.org/D38247

Files:
  src/Unwind-sjlj.c


Index: src/Unwind-sjlj.c
===
--- src/Unwind-sjlj.c
+++ src/Unwind-sjlj.c
@@ -39,10 +39,10 @@
   struct _Unwind_FunctionContext *prev;
 
   // set by calling function before registering to be the landing pad
-  uintptr_t   resumeLocation;
+  uint32_tresumeLocation;
 
   // set by personality handler to be parameters passed to landing pad function
-  uintptr_t   resumeParameters[4];
+  uint32_tresumeParameters[4];
 
   // set by calling function before registering
   __personality_routine   personality; // arm offset=24


Index: src/Unwind-sjlj.c
===
--- src/Unwind-sjlj.c
+++ src/Unwind-sjlj.c
@@ -39,10 +39,10 @@
   struct _Unwind_FunctionContext *prev;
 
   // set by calling function before registering to be the landing pad
-  uintptr_t   resumeLocation;
+  uint32_tresumeLocation;
 
   // set by personality handler to be parameters passed to landing pad function
-  uintptr_t   resumeParameters[4];
+  uint32_tresumeParameters[4];
 
   // set by calling function before registering
   __personality_routine   personality; // arm offset=24
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r314142 - Revert "[NVPTX] added match.{any, all}.sync instructions, intrinsics & builtins.", rL314135.

2017-09-25 Thread Justin Lebar via cfe-commits
Author: jlebar
Date: Mon Sep 25 12:41:56 2017
New Revision: 314142

URL: http://llvm.org/viewvc/llvm-project?rev=314142=rev
Log:
Revert "[NVPTX] added match.{any,all}.sync instructions, intrinsics & 
builtins.", rL314135.

Causing assertion failures on macos:

> Assertion failed: (Num < NumOperands && "Invalid child # of SDNode!"),
> function getOperand, file
> /Users/buildslave/jenkins/workspace/clang-stage1-cmake-RA-incremental/llvm/include/llvm/CodeGen/SelectionDAGNodes.h,
> line 835.

http://green.lab.llvm.org/green/job/clang-stage1-cmake-RA-incremental/42739/testReport/LLVM/CodeGen_NVPTX/surf_read_cuda_ll/

Modified:
cfe/trunk/include/clang/Basic/BuiltinsNVPTX.def
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/lib/Headers/__clang_cuda_intrinsics.h
cfe/trunk/test/CodeGen/builtins-nvptx-ptx60.cu

Modified: cfe/trunk/include/clang/Basic/BuiltinsNVPTX.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsNVPTX.def?rev=314142=314141=314142=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsNVPTX.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsNVPTX.def Mon Sep 25 12:41:56 2017
@@ -413,13 +413,6 @@ TARGET_BUILTIN(__nvvm_vote_any_sync, "bU
 TARGET_BUILTIN(__nvvm_vote_uni_sync, "bUib", "", "ptx60")
 TARGET_BUILTIN(__nvvm_vote_ballot_sync, "UiUib", "", "ptx60")
 
-// Match
-TARGET_BUILTIN(__nvvm_match_any_sync_i32, "UiUiUi", "", "ptx60")
-TARGET_BUILTIN(__nvvm_match_any_sync_i64, "WiUiWi", "", "ptx60")
-// These return a pair {value, predicate}, which requires custom lowering.
-TARGET_BUILTIN(__nvvm_match_all_sync_i32p, "UiUiUii*", "", "ptx60")
-TARGET_BUILTIN(__nvvm_match_all_sync_i64p, "WiUiWii*", "", "ptx60")
-
 // Membar
 
 BUILTIN(__nvvm_membar_cta, "v", "")

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=314142=314141=314142=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Mon Sep 25 12:41:56 2017
@@ -9589,21 +9589,6 @@ Value *CodeGenFunction::EmitNVPTXBuiltin
 {Ptr->getType()->getPointerElementType(), Ptr->getType()}),
 {Ptr, EmitScalarExpr(E->getArg(1)), EmitScalarExpr(E->getArg(2))});
   }
-  case NVPTX::BI__nvvm_match_all_sync_i32p:
-  case NVPTX::BI__nvvm_match_all_sync_i64p: {
-Value *Mask = EmitScalarExpr(E->getArg(0));
-Value *Val = EmitScalarExpr(E->getArg(1));
-Address PredOutPtr = EmitPointerWithAlignment(E->getArg(2));
-Value *ResultPair = Builder.CreateCall(
-CGM.getIntrinsic(BuiltinID == NVPTX::BI__nvvm_match_all_sync_i32p
- ? Intrinsic::nvvm_match_all_sync_i32p
- : Intrinsic::nvvm_match_all_sync_i64p),
-{Mask, Val});
-Value *Pred = Builder.CreateZExt(Builder.CreateExtractValue(ResultPair, 1),
- PredOutPtr.getElementType());
-Builder.CreateStore(Pred, PredOutPtr);
-return Builder.CreateExtractValue(ResultPair, 0);
-  }
   default:
 return nullptr;
   }

Modified: cfe/trunk/lib/Headers/__clang_cuda_intrinsics.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/__clang_cuda_intrinsics.h?rev=314142=314141=314142=diff
==
--- cfe/trunk/lib/Headers/__clang_cuda_intrinsics.h (original)
+++ cfe/trunk/lib/Headers/__clang_cuda_intrinsics.h Mon Sep 25 12:41:56 2017
@@ -92,9 +92,8 @@ __MAKE_SHUFFLES(__shfl_xor, __nvvm_shfl_
 
 #endif // !defined(__CUDA_ARCH__) || __CUDA_ARCH__ >= 300
 
-#if CUDA_VERSION >= 9000
-#if (!defined(__CUDA_ARCH__) || __CUDA_ARCH__ >= 300)
 // __shfl_sync_* variants available in CUDA-9
+#if CUDA_VERSION >= 9000 && (!defined(__CUDA_ARCH__) || __CUDA_ARCH__ >= 300)
 #pragma push_macro("__MAKE_SYNC_SHUFFLES")
 #define __MAKE_SYNC_SHUFFLES(__FnName, __IntIntrinsic, __FloatIntrinsic,   
\
  __Mask)   
\
@@ -188,33 +187,8 @@ inline __device__ unsigned int __ballot_
 
 inline __device__ unsigned int activemask() { return __nvvm_vote_ballot(1); }
 
-#endif // !defined(__CUDA_ARCH__) || __CUDA_ARCH__ >= 300
-
-// Define __match* builtins CUDA-9 headers expect to see.
-#if !defined(__CUDA_ARCH__) || __CUDA_ARCH__ >= 700
-inline __device__ unsigned int __match32_any_sync(unsigned int mask,
-  unsigned int value) {
-  return __nvvm_match_any_sync_i32(mask, value);
-}
-
-inline __device__ unsigned long long
-__match64_any_sync(unsigned int mask, unsigned long long value) {
-  return __nvvm_match_any_sync_i64(mask, value);
-}
-
-inline __device__ unsigned int
-__match32_all_sync(unsigned int mask, unsigned int value, int *pred) {
-  return __nvvm_match_all_sync_i32p(mask, value, pred);
-}
-

[PATCH] D38214: [analyzer] Fix crash on modeling of pointer arithmetic

2017-09-25 Thread Alexander Shaposhnikov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL314141: [analyzer] Fix crash on modeling of pointer 
arithmetic (authored by alexshap).

Changed prior to commit:
  https://reviews.llvm.org/D38214?vs=116455=116590#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D38214

Files:
  cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
  cfe/trunk/test/Analysis/ptr-arith.cpp


Index: cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
@@ -726,9 +726,11 @@
 if (Optional rInt = rhs.getAs()) {
   // If one of the operands is a symbol and the other is a constant,
   // build an expression for use by the constraint manager.
-  if (SymbolRef lSym = lhs.getAsLocSymbol(true))
-return MakeSymIntVal(lSym, op, rInt->getValue(), resultTy);
-
+  if (SymbolRef lSym = lhs.getAsLocSymbol(true)) {
+if (BinaryOperator::isComparisonOp(op))
+  return MakeSymIntVal(lSym, op, rInt->getValue(), resultTy);
+return UnknownVal();
+  }
   // Special case comparisons to NULL.
   // This must come after the test if the LHS is a symbol, which is used to
   // build constraints. The address of any non-symbolic region is 
guaranteed
Index: cfe/trunk/test/Analysis/ptr-arith.cpp
===
--- cfe/trunk/test/Analysis/ptr-arith.cpp
+++ cfe/trunk/test/Analysis/ptr-arith.cpp
@@ -111,3 +111,9 @@
   __UINTPTR_TYPE__ y = (__UINTPTR_TYPE__)p - 1;
   return y == x;
 }
+
+// Bug 34374
+bool integerAsPtrSubtractionNoCrash(char *p, __UINTPTR_TYPE__ m) {
+  auto n = p - reinterpret_cast((__UINTPTR_TYPE__)1);
+  return n == m;
+}


Index: cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
@@ -726,9 +726,11 @@
 if (Optional rInt = rhs.getAs()) {
   // If one of the operands is a symbol and the other is a constant,
   // build an expression for use by the constraint manager.
-  if (SymbolRef lSym = lhs.getAsLocSymbol(true))
-return MakeSymIntVal(lSym, op, rInt->getValue(), resultTy);
-
+  if (SymbolRef lSym = lhs.getAsLocSymbol(true)) {
+if (BinaryOperator::isComparisonOp(op))
+  return MakeSymIntVal(lSym, op, rInt->getValue(), resultTy);
+return UnknownVal();
+  }
   // Special case comparisons to NULL.
   // This must come after the test if the LHS is a symbol, which is used to
   // build constraints. The address of any non-symbolic region is guaranteed
Index: cfe/trunk/test/Analysis/ptr-arith.cpp
===
--- cfe/trunk/test/Analysis/ptr-arith.cpp
+++ cfe/trunk/test/Analysis/ptr-arith.cpp
@@ -111,3 +111,9 @@
   __UINTPTR_TYPE__ y = (__UINTPTR_TYPE__)p - 1;
   return y == x;
 }
+
+// Bug 34374
+bool integerAsPtrSubtractionNoCrash(char *p, __UINTPTR_TYPE__ m) {
+  auto n = p - reinterpret_cast((__UINTPTR_TYPE__)1);
+  return n == m;
+}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r314141 - [analyzer] Fix crash on modeling of pointer arithmetic

2017-09-25 Thread Alexander Shaposhnikov via cfe-commits
Author: alexshap
Date: Mon Sep 25 12:32:33 2017
New Revision: 314141

URL: http://llvm.org/viewvc/llvm-project?rev=314141=rev
Log:
[analyzer] Fix crash on modeling of pointer arithmetic

This patch fixes analyzer's crash on the newly added test case 
(see also https://bugs.llvm.org/show_bug.cgi?id=34374).
Pointers subtraction appears to be modeled incorrectly 
in the following example:
  char* p;
  auto n = p - reinterpret_cast((unsigned long)1);
In this case the analyzer (built without this patch) 
tries to create a symbolic value for the difference 
treating reinterpret_cast((unsigned long)1) 
as an integer, that is not correct.

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

Test plan: make check-all

Modified:
cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
cfe/trunk/test/Analysis/ptr-arith.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp?rev=314141=314140=314141=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp Mon Sep 25 12:32:33 
2017
@@ -726,9 +726,11 @@ SVal SimpleSValBuilder::evalBinOpLL(Prog
 if (Optional rInt = rhs.getAs()) {
   // If one of the operands is a symbol and the other is a constant,
   // build an expression for use by the constraint manager.
-  if (SymbolRef lSym = lhs.getAsLocSymbol(true))
-return MakeSymIntVal(lSym, op, rInt->getValue(), resultTy);
-
+  if (SymbolRef lSym = lhs.getAsLocSymbol(true)) {
+if (BinaryOperator::isComparisonOp(op))
+  return MakeSymIntVal(lSym, op, rInt->getValue(), resultTy);
+return UnknownVal();
+  }
   // Special case comparisons to NULL.
   // This must come after the test if the LHS is a symbol, which is used to
   // build constraints. The address of any non-symbolic region is 
guaranteed

Modified: cfe/trunk/test/Analysis/ptr-arith.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/ptr-arith.cpp?rev=314141=314140=314141=diff
==
--- cfe/trunk/test/Analysis/ptr-arith.cpp (original)
+++ cfe/trunk/test/Analysis/ptr-arith.cpp Mon Sep 25 12:32:33 2017
@@ -111,3 +111,9 @@ bool ptrAsIntegerSubtractionNoCrash(__UI
   __UINTPTR_TYPE__ y = (__UINTPTR_TYPE__)p - 1;
   return y == x;
 }
+
+// Bug 34374
+bool integerAsPtrSubtractionNoCrash(char *p, __UINTPTR_TYPE__ m) {
+  auto n = p - reinterpret_cast((__UINTPTR_TYPE__)1);
+  return n == m;
+}


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


[PATCH] D37530: [MinGW] Don't link -lmsvcrt if a different msvcrt version is to be linked

2017-09-25 Thread Martin Storsjö via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL314138: [MinGW] Don't link -lmsvcrt if a different msvcrt 
version is to be linked (authored by mstorsjo).

Changed prior to commit:
  https://reviews.llvm.org/D37530?vs=114429=116587#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D37530

Files:
  cfe/trunk/lib/Driver/ToolChains/MinGW.cpp
  cfe/trunk/test/Driver/mingw-msvcrt.c


Index: cfe/trunk/lib/Driver/ToolChains/MinGW.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/MinGW.cpp
+++ cfe/trunk/lib/Driver/ToolChains/MinGW.cpp
@@ -82,6 +82,9 @@
 
   CmdArgs.push_back("-lmoldname");
   CmdArgs.push_back("-lmingwex");
+  for (auto Lib : Args.getAllArgValues(options::OPT_l))
+if (StringRef(Lib).startswith("msvcr") || Lib == "ucrtbase")
+  return;
   CmdArgs.push_back("-lmsvcrt");
 }
 
Index: cfe/trunk/test/Driver/mingw-msvcrt.c
===
--- cfe/trunk/test/Driver/mingw-msvcrt.c
+++ cfe/trunk/test/Driver/mingw-msvcrt.c
@@ -0,0 +1,5 @@
+// RUN: %clang -v -target i686-pc-windows-gnu -### %s 2>&1 | FileCheck 
-check-prefix=CHECK_DEFAULT %s
+// RUN: %clang -v -target i686-pc-windows-gnu -lmsvcr120 -### %s 2>&1 | 
FileCheck -check-prefix=CHECK_MSVCR120 %s
+
+// CHECK_DEFAULT: "-lmingwex" "-lmsvcrt" "-ladvapi32"
+// CHECK_MSVCR120: "-lmingwex" "-ladvapi32"


Index: cfe/trunk/lib/Driver/ToolChains/MinGW.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/MinGW.cpp
+++ cfe/trunk/lib/Driver/ToolChains/MinGW.cpp
@@ -82,6 +82,9 @@
 
   CmdArgs.push_back("-lmoldname");
   CmdArgs.push_back("-lmingwex");
+  for (auto Lib : Args.getAllArgValues(options::OPT_l))
+if (StringRef(Lib).startswith("msvcr") || Lib == "ucrtbase")
+  return;
   CmdArgs.push_back("-lmsvcrt");
 }
 
Index: cfe/trunk/test/Driver/mingw-msvcrt.c
===
--- cfe/trunk/test/Driver/mingw-msvcrt.c
+++ cfe/trunk/test/Driver/mingw-msvcrt.c
@@ -0,0 +1,5 @@
+// RUN: %clang -v -target i686-pc-windows-gnu -### %s 2>&1 | FileCheck -check-prefix=CHECK_DEFAULT %s
+// RUN: %clang -v -target i686-pc-windows-gnu -lmsvcr120 -### %s 2>&1 | FileCheck -check-prefix=CHECK_MSVCR120 %s
+
+// CHECK_DEFAULT: "-lmingwex" "-lmsvcrt" "-ladvapi32"
+// CHECK_MSVCR120: "-lmingwex" "-ladvapi32"
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r314138 - [MinGW] Don't link -lmsvcrt if a different msvcrt version is to be linked

2017-09-25 Thread Martin Storsjo via cfe-commits
Author: mstorsjo
Date: Mon Sep 25 12:24:45 2017
New Revision: 314138

URL: http://llvm.org/viewvc/llvm-project?rev=314138=rev
Log:
[MinGW] Don't link -lmsvcrt if a different msvcrt version is to be linked

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

Added:
cfe/trunk/test/Driver/mingw-msvcrt.c
Modified:
cfe/trunk/lib/Driver/ToolChains/MinGW.cpp

Modified: cfe/trunk/lib/Driver/ToolChains/MinGW.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/MinGW.cpp?rev=314138=314137=314138=diff
==
--- cfe/trunk/lib/Driver/ToolChains/MinGW.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/MinGW.cpp Mon Sep 25 12:24:45 2017
@@ -82,6 +82,9 @@ void tools::MinGW::Linker::AddLibGCC(con
 
   CmdArgs.push_back("-lmoldname");
   CmdArgs.push_back("-lmingwex");
+  for (auto Lib : Args.getAllArgValues(options::OPT_l))
+if (StringRef(Lib).startswith("msvcr") || Lib == "ucrtbase")
+  return;
   CmdArgs.push_back("-lmsvcrt");
 }
 

Added: cfe/trunk/test/Driver/mingw-msvcrt.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/mingw-msvcrt.c?rev=314138=auto
==
--- cfe/trunk/test/Driver/mingw-msvcrt.c (added)
+++ cfe/trunk/test/Driver/mingw-msvcrt.c Mon Sep 25 12:24:45 2017
@@ -0,0 +1,5 @@
+// RUN: %clang -v -target i686-pc-windows-gnu -### %s 2>&1 | FileCheck 
-check-prefix=CHECK_DEFAULT %s
+// RUN: %clang -v -target i686-pc-windows-gnu -lmsvcr120 -### %s 2>&1 | 
FileCheck -check-prefix=CHECK_MSVCR120 %s
+
+// CHECK_DEFAULT: "-lmingwex" "-lmsvcrt" "-ladvapi32"
+// CHECK_MSVCR120: "-lmingwex" "-ladvapi32"


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


[PATCH] D37695: [clang-format] Break non-trailing comments, try 2

2017-09-25 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir added a comment.

ping


https://reviews.llvm.org/D37695



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


[PATCH] D38191: [NVPTX] added match.{any, all}.sync instructions, intrinsics & builtins.

2017-09-25 Thread Artem Belevich via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL314135: [NVPTX] added match.{any,all}.sync instructions, 
intrinsics & builtins. (authored by tra).

Changed prior to commit:
  https://reviews.llvm.org/D38191?vs=116578=116584#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D38191

Files:
  cfe/trunk/include/clang/Basic/BuiltinsNVPTX.def
  cfe/trunk/lib/CodeGen/CGBuiltin.cpp
  cfe/trunk/lib/Headers/__clang_cuda_intrinsics.h
  cfe/trunk/test/CodeGen/builtins-nvptx-ptx60.cu
  llvm/trunk/include/llvm/IR/IntrinsicsNVVM.td
  llvm/trunk/lib/Target/NVPTX/NVPTXISelDAGToDAG.cpp
  llvm/trunk/lib/Target/NVPTX/NVPTXISelDAGToDAG.h
  llvm/trunk/lib/Target/NVPTX/NVPTXInstrInfo.td
  llvm/trunk/lib/Target/NVPTX/NVPTXIntrinsics.td
  llvm/trunk/test/CodeGen/NVPTX/match.ll

Index: llvm/trunk/lib/Target/NVPTX/NVPTXISelDAGToDAG.cpp
===
--- llvm/trunk/lib/Target/NVPTX/NVPTXISelDAGToDAG.cpp
+++ llvm/trunk/lib/Target/NVPTX/NVPTXISelDAGToDAG.cpp
@@ -714,6 +714,9 @@
 return false;
   case Intrinsic::nvvm_texsurf_handle_internal:
 SelectTexSurfHandle(N);
+  case Intrinsic::nvvm_match_all_sync_i32p:
+  case Intrinsic::nvvm_match_all_sync_i64p:
+SelectMatchAll(N);
 return true;
   }
 }
@@ -726,6 +729,36 @@
 MVT::i64, GlobalVal));
 }
 
+void NVPTXDAGToDAGISel::SelectMatchAll(SDNode *N) {
+  SDLoc DL(N);
+  enum { IS_I64 = 4, HAS_CONST_VALUE = 2, HAS_CONST_MASK = 1 };
+  unsigned IID = cast(N->getOperand(0))->getZExtValue();
+  unsigned OpcodeIndex =
+  (IID == Intrinsic::nvvm_match_all_sync_i64p) ? IS_I64 : 0;
+  SDValue MaskOp = N->getOperand(1);
+  SDValue ValueOp = N->getOperand(2);
+  if (ConstantSDNode *ValueConst = dyn_cast(ValueOp)) {
+OpcodeIndex |= HAS_CONST_VALUE;
+ValueOp = CurDAG->getTargetConstant(ValueConst->getZExtValue(), DL,
+ValueConst->getValueType(0));
+  }
+  if (ConstantSDNode *MaskConst = dyn_cast(MaskOp)) {
+OpcodeIndex |= HAS_CONST_MASK;
+MaskOp = CurDAG->getTargetConstant(MaskConst->getZExtValue(), DL,
+   MaskConst->getValueType(0));
+  }
+  // Maps {IS_I64, HAS_CONST_VALUE, HAS_CONST_MASK} -> opcode
+  unsigned Opcodes[8] = {
+  NVPTX::MATCH_ALLP_SYNC_32rr, NVPTX::MATCH_ALLP_SYNC_32ri,
+  NVPTX::MATCH_ALLP_SYNC_32ir, NVPTX::MATCH_ALLP_SYNC_32ii,
+  NVPTX::MATCH_ALLP_SYNC_64rr, NVPTX::MATCH_ALLP_SYNC_64ri,
+  NVPTX::MATCH_ALLP_SYNC_64ir, NVPTX::MATCH_ALLP_SYNC_64ii};
+  SDNode *NewNode = CurDAG->getMachineNode(Opcodes[OpcodeIndex], DL,
+   {ValueOp->getValueType(0), MVT::i1},
+   {MaskOp, ValueOp});
+  ReplaceNode(N, NewNode);
+}
+
 void NVPTXDAGToDAGISel::SelectAddrSpaceCast(SDNode *N) {
   SDValue Src = N->getOperand(0);
   AddrSpaceCastSDNode *CastN = cast(N);
Index: llvm/trunk/lib/Target/NVPTX/NVPTXInstrInfo.td
===
--- llvm/trunk/lib/Target/NVPTX/NVPTXInstrInfo.td
+++ llvm/trunk/lib/Target/NVPTX/NVPTXInstrInfo.td
@@ -158,6 +158,7 @@
 def hasPTX60 : Predicate<"Subtarget->getPTXVersion() >= 60">;
 
 def hasSM30 : Predicate<"Subtarget->getSmVersion() >= 30">;
+def hasSM70 : Predicate<"Subtarget->getSmVersion() >= 70">;
 
 def useFP16Math: Predicate<"Subtarget->allowFP16Math()">;
 
Index: llvm/trunk/lib/Target/NVPTX/NVPTXISelDAGToDAG.h
===
--- llvm/trunk/lib/Target/NVPTX/NVPTXISelDAGToDAG.h
+++ llvm/trunk/lib/Target/NVPTX/NVPTXISelDAGToDAG.h
@@ -58,6 +58,7 @@
   bool tryIntrinsicNoChain(SDNode *N);
   bool tryIntrinsicChain(SDNode *N);
   void SelectTexSurfHandle(SDNode *N);
+  void SelectMatchAll(SDNode *N);
   bool tryLoad(SDNode *N);
   bool tryLoadVector(SDNode *N);
   bool tryLDGLDU(SDNode *N);
Index: llvm/trunk/lib/Target/NVPTX/NVPTXIntrinsics.td
===
--- llvm/trunk/lib/Target/NVPTX/NVPTXIntrinsics.td
+++ llvm/trunk/lib/Target/NVPTX/NVPTXIntrinsics.td
@@ -247,6 +247,63 @@
 defm VOTE_SYNC_UNI : VOTE_SYNC;
 defm VOTE_SYNC_BALLOT : VOTE_SYNC;
 
+multiclass MATCH_ANY_SYNC {
+  def ii : NVPTXInst<(outs regclass:$dest), (ins i32imm:$mask, ImmOp:$value),
+  "match.any.sync." # ptxtype # " \t$dest, $value, $mask;",
+  [(set regclass:$dest, (IntOp imm:$mask, imm:$value))]>,
+   Requires<[hasPTX60, hasSM70]>;
+  def ir : NVPTXInst<(outs regclass:$dest), (ins Int32Regs:$mask, ImmOp:$value),
+  "match.any.sync." # ptxtype # " \t$dest, $value, $mask;",
+  [(set regclass:$dest, (IntOp Int32Regs:$mask, imm:$value))]>,
+   Requires<[hasPTX60, hasSM70]>;
+  def ri : NVPTXInst<(outs regclass:$dest), (ins i32imm:$mask, 

[PATCH] D36487: Emit section information for extern variables.

2017-09-25 Thread Elizabeth Andrews via Phabricator via cfe-commits
eandrews updated this revision to Diff 116581.
eandrews added a comment.

I've modified the patch to emit a warning for re-declarations only. I also 
removed the isUsed check.


https://reviews.llvm.org/D36487

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/CodeGen/CodeGenModule.cpp
  lib/Sema/SemaDecl.cpp
  test/CodeGenCXX/extern-section-attribute.cpp
  test/Sema/attr-section.c


Index: test/Sema/attr-section.c
===
--- test/Sema/attr-section.c
+++ test/Sema/attr-section.c
@@ -19,3 +19,7 @@
 void __attribute__((section("bar,zed"))) test2(void) {} // expected-warning 
{{section does not match previous declaration}}
 
 enum __attribute__((section("NEAR,x"))) e { one }; // expected-error 
{{'section' attribute only applies to functions, methods, properties, and 
global variables}}
+
+extern int a; // expected-note {{previous declaration is here}}
+int *b = 
+extern int a __attribute__((section("foo,zed"))); // expected-warning 
{{section attribute is specified on redeclared variable}}
Index: test/CodeGenCXX/extern-section-attribute.cpp
===
--- /dev/null
+++ test/CodeGenCXX/extern-section-attribute.cpp
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - -triple=x86_64-pc-linux-gnu | FileCheck 
%s
+
+extern int aa __attribute__((section(".sdata")));
+// CHECK-DAG: @aa = external global i32, section ".sdata", align 4
+
+extern int bb __attribute__((section(".sdata"))) = 1;
+// CHECK-DAG: @bb = global i32 1, section ".sdata", align 4
+
+int foo() {
+  return aa + bb;
+}
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -2607,6 +2607,16 @@
 }
   }
 
+  // This redeclaration adds a section attribute.
+  if (New->hasAttr() && !Old->hasAttr()) {
+if (auto *VD = dyn_cast(New)) {
+  if (VD->isThisDeclarationADefinition() != VarDecl::Definition) {
+Diag(New->getLocation(), 
diag::warn_attribute_section_on_redeclaration);
+Diag(Old->getLocation(), diag::note_previous_declaration);
+  }
+}
+  }
+
   if (!Old->hasAttrs())
 return;
 
Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -2436,6 +2436,12 @@
   EmitGlobalVarDefinition(D);
 }
 
+// Emit section information for extern variables.
+if (D->hasExternalStorage()) {
+  if (const SectionAttr *SA = D->getAttr())
+GV->setSection(SA->getName());
+}
+
 // Handle XCore specific ABI requirements.
 if (getTriple().getArch() == llvm::Triple::xcore &&
 D->getLanguageLinkage() == CLanguageLinkage &&
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -2620,6 +2620,8 @@
   "argument to 'section' attribute is not valid for this target: %0">;
 def warn_mismatched_section : Warning<
   "section does not match previous declaration">, InGroup;
+def warn_attribute_section_on_redeclaration : Warning<
+  "section attribute is specified on redeclared variable">, InGroup;
 
 def err_anonymous_property: Error<
   "anonymous property is not supported">;


Index: test/Sema/attr-section.c
===
--- test/Sema/attr-section.c
+++ test/Sema/attr-section.c
@@ -19,3 +19,7 @@
 void __attribute__((section("bar,zed"))) test2(void) {} // expected-warning {{section does not match previous declaration}}
 
 enum __attribute__((section("NEAR,x"))) e { one }; // expected-error {{'section' attribute only applies to functions, methods, properties, and global variables}}
+
+extern int a; // expected-note {{previous declaration is here}}
+int *b = 
+extern int a __attribute__((section("foo,zed"))); // expected-warning {{section attribute is specified on redeclared variable}}
Index: test/CodeGenCXX/extern-section-attribute.cpp
===
--- /dev/null
+++ test/CodeGenCXX/extern-section-attribute.cpp
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - -triple=x86_64-pc-linux-gnu | FileCheck %s
+
+extern int aa __attribute__((section(".sdata")));
+// CHECK-DAG: @aa = external global i32, section ".sdata", align 4
+
+extern int bb __attribute__((section(".sdata"))) = 1;
+// CHECK-DAG: @bb = global i32 1, section ".sdata", align 4
+
+int foo() {
+  return aa + bb;
+}
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -2607,6 +2607,16 @@
 }
   }
 
+  // This redeclaration adds a section attribute.
+  if (New->hasAttr() && !Old->hasAttr()) {
+if (auto *VD = dyn_cast(New)) {
+  if 

r314135 - [NVPTX] added match.{any, all}.sync instructions, intrinsics & builtins.

2017-09-25 Thread Artem Belevich via cfe-commits
Author: tra
Date: Mon Sep 25 11:53:57 2017
New Revision: 314135

URL: http://llvm.org/viewvc/llvm-project?rev=314135=rev
Log:
[NVPTX] added match.{any,all}.sync instructions, intrinsics & builtins.

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

Modified:
cfe/trunk/include/clang/Basic/BuiltinsNVPTX.def
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/lib/Headers/__clang_cuda_intrinsics.h
cfe/trunk/test/CodeGen/builtins-nvptx-ptx60.cu

Modified: cfe/trunk/include/clang/Basic/BuiltinsNVPTX.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsNVPTX.def?rev=314135=314134=314135=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsNVPTX.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsNVPTX.def Mon Sep 25 11:53:57 2017
@@ -413,6 +413,13 @@ TARGET_BUILTIN(__nvvm_vote_any_sync, "bU
 TARGET_BUILTIN(__nvvm_vote_uni_sync, "bUib", "", "ptx60")
 TARGET_BUILTIN(__nvvm_vote_ballot_sync, "UiUib", "", "ptx60")
 
+// Match
+TARGET_BUILTIN(__nvvm_match_any_sync_i32, "UiUiUi", "", "ptx60")
+TARGET_BUILTIN(__nvvm_match_any_sync_i64, "WiUiWi", "", "ptx60")
+// These return a pair {value, predicate}, which requires custom lowering.
+TARGET_BUILTIN(__nvvm_match_all_sync_i32p, "UiUiUii*", "", "ptx60")
+TARGET_BUILTIN(__nvvm_match_all_sync_i64p, "WiUiWii*", "", "ptx60")
+
 // Membar
 
 BUILTIN(__nvvm_membar_cta, "v", "")

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=314135=314134=314135=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Mon Sep 25 11:53:57 2017
@@ -9589,6 +9589,21 @@ Value *CodeGenFunction::EmitNVPTXBuiltin
 {Ptr->getType()->getPointerElementType(), Ptr->getType()}),
 {Ptr, EmitScalarExpr(E->getArg(1)), EmitScalarExpr(E->getArg(2))});
   }
+  case NVPTX::BI__nvvm_match_all_sync_i32p:
+  case NVPTX::BI__nvvm_match_all_sync_i64p: {
+Value *Mask = EmitScalarExpr(E->getArg(0));
+Value *Val = EmitScalarExpr(E->getArg(1));
+Address PredOutPtr = EmitPointerWithAlignment(E->getArg(2));
+Value *ResultPair = Builder.CreateCall(
+CGM.getIntrinsic(BuiltinID == NVPTX::BI__nvvm_match_all_sync_i32p
+ ? Intrinsic::nvvm_match_all_sync_i32p
+ : Intrinsic::nvvm_match_all_sync_i64p),
+{Mask, Val});
+Value *Pred = Builder.CreateZExt(Builder.CreateExtractValue(ResultPair, 1),
+ PredOutPtr.getElementType());
+Builder.CreateStore(Pred, PredOutPtr);
+return Builder.CreateExtractValue(ResultPair, 0);
+  }
   default:
 return nullptr;
   }

Modified: cfe/trunk/lib/Headers/__clang_cuda_intrinsics.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/__clang_cuda_intrinsics.h?rev=314135=314134=314135=diff
==
--- cfe/trunk/lib/Headers/__clang_cuda_intrinsics.h (original)
+++ cfe/trunk/lib/Headers/__clang_cuda_intrinsics.h Mon Sep 25 11:53:57 2017
@@ -92,8 +92,9 @@ __MAKE_SHUFFLES(__shfl_xor, __nvvm_shfl_
 
 #endif // !defined(__CUDA_ARCH__) || __CUDA_ARCH__ >= 300
 
+#if CUDA_VERSION >= 9000
+#if (!defined(__CUDA_ARCH__) || __CUDA_ARCH__ >= 300)
 // __shfl_sync_* variants available in CUDA-9
-#if CUDA_VERSION >= 9000 && (!defined(__CUDA_ARCH__) || __CUDA_ARCH__ >= 300)
 #pragma push_macro("__MAKE_SYNC_SHUFFLES")
 #define __MAKE_SYNC_SHUFFLES(__FnName, __IntIntrinsic, __FloatIntrinsic,   
\
  __Mask)   
\
@@ -187,8 +188,33 @@ inline __device__ unsigned int __ballot_
 
 inline __device__ unsigned int activemask() { return __nvvm_vote_ballot(1); }
 
-#endif // __CUDA_VERSION >= 9000 && (!defined(__CUDA_ARCH__) ||
-   // __CUDA_ARCH__ >= 300)
+#endif // !defined(__CUDA_ARCH__) || __CUDA_ARCH__ >= 300
+
+// Define __match* builtins CUDA-9 headers expect to see.
+#if !defined(__CUDA_ARCH__) || __CUDA_ARCH__ >= 700
+inline __device__ unsigned int __match32_any_sync(unsigned int mask,
+  unsigned int value) {
+  return __nvvm_match_any_sync_i32(mask, value);
+}
+
+inline __device__ unsigned long long
+__match64_any_sync(unsigned int mask, unsigned long long value) {
+  return __nvvm_match_any_sync_i64(mask, value);
+}
+
+inline __device__ unsigned int
+__match32_all_sync(unsigned int mask, unsigned int value, int *pred) {
+  return __nvvm_match_all_sync_i32p(mask, value, pred);
+}
+
+inline __device__ unsigned long long
+__match64_all_sync(unsigned int mask, unsigned long long value, int *pred) {
+  return __nvvm_match_all_sync_i64p(mask, value, pred);
+}
+#include "crt/sm_70_rt.hpp"
+
+#endif // !defined(__CUDA_ARCH__) || __CUDA_ARCH__ >= 700
+#endif 

[PATCH] D35743: [clang-format] Adjust space around &/&& of structured bindings

2017-09-25 Thread Chih-Hung Hsieh via Phabricator via cfe-commits
chh added a comment.

ping.


https://reviews.llvm.org/D35743



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


[PATCH] D38191: [NVPTX] added match.{any, all}.sync instructions, intrinsics & builtins.

2017-09-25 Thread Artem Belevich via Phabricator via cfe-commits
tra added inline comments.



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:9603
+Value *Pred = Builder.CreateSExt(Builder.CreateExtractValue(ResultPair, 1),
+ PredOutPtr.getElementType());
+Builder.CreateStore(Pred, PredOutPtr);

jlebar wrote:
> Doing sext i1 -> i32 is going to cause us to store 0 or -1 in the pred 
> (right?).  The CUDA docs say
> 
> > Predicate pred is set to true if all threads in mask have the same value of 
> > value; otherwise the predicate is set to false.
> 
> I'd guess that "true" probably means 1 (i.e. uext i1 -> i32) rather than -1, 
> although, I guess we have to check.
Right. It should've been ZExt. In similar places CUDA headers use "selp %r1, 1, 
0, %p".


https://reviews.llvm.org/D38191



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


[PATCH] D38191: [NVPTX] added match.{any, all}.sync instructions, intrinsics & builtins.

2017-09-25 Thread Artem Belevich via Phabricator via cfe-commits
tra updated this revision to Diff 116578.
tra marked an inline comment as done.
tra added a comment.

Addressed Justin's comments.


https://reviews.llvm.org/D38191

Files:
  clang/include/clang/Basic/BuiltinsNVPTX.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Headers/__clang_cuda_intrinsics.h
  clang/test/CodeGen/builtins-nvptx-ptx60.cu
  llvm/include/llvm/IR/IntrinsicsNVVM.td
  llvm/lib/Target/NVPTX/NVPTXISelDAGToDAG.cpp
  llvm/lib/Target/NVPTX/NVPTXISelDAGToDAG.h
  llvm/lib/Target/NVPTX/NVPTXInstrInfo.td
  llvm/lib/Target/NVPTX/NVPTXIntrinsics.td
  llvm/test/CodeGen/NVPTX/match.ll

Index: llvm/test/CodeGen/NVPTX/match.ll
===
--- /dev/null
+++ llvm/test/CodeGen/NVPTX/match.ll
@@ -0,0 +1,117 @@
+; RUN: llc < %s -march=nvptx64 -mcpu=sm_70 -mattr=+ptx60 | FileCheck %s
+
+declare i32 @llvm.nvvm.match.any.sync.i32(i32, i32)
+declare i64 @llvm.nvvm.match.any.sync.i64(i32, i64)
+
+; CHECK-LABEL: .func{{.*}}match.any.sync.i32
+define i32 @match.any.sync.i32(i32 %mask, i32 %value) {
+  ; CHECK: ld.param.u32 	[[MASK:%r[0-9]+]], [match.any.sync.i32_param_0];
+  ; CHECK: ld.param.u32 	[[VALUE:%r[0-9]+]], [match.any.sync.i32_param_1];
+
+  ; CHECK:  match.any.sync.b32  [[V0:%r[0-9]+]], [[VALUE]], [[MASK]];
+  %v0 = call i32 @llvm.nvvm.match.any.sync.i32(i32 %mask, i32 %value)
+  ; CHECK:  match.any.sync.b32  [[V1:%r[0-9]+]], [[VALUE]], 1;
+  %v1 = call i32 @llvm.nvvm.match.any.sync.i32(i32 1, i32 %value)
+  ; CHECK:  match.any.sync.b32  [[V2:%r[0-9]+]], 2, [[MASK]];
+  %v2 = call i32 @llvm.nvvm.match.any.sync.i32(i32 %mask, i32 2)
+  ; CHECK:  match.any.sync.b32  [[V3:%r[0-9]+]], 4, 3;
+  %v3 = call i32 @llvm.nvvm.match.any.sync.i32(i32 3, i32 4)
+  %sum1 = add i32 %v0, %v1
+  %sum2 = add i32 %v2, %v3
+  %sum3 = add i32 %sum1, %sum2
+  ret i32 %sum3;
+}
+
+; CHECK-LABEL: .func{{.*}}match.any.sync.i64
+define i64 @match.any.sync.i64(i32 %mask, i64 %value) {
+  ; CHECK: ld.param.u32 	[[MASK:%r[0-9]+]], [match.any.sync.i64_param_0];
+  ; CHECK: ld.param.u64 	[[VALUE:%rd[0-9]+]], [match.any.sync.i64_param_1];
+
+  ; CHECK:  match.any.sync.b64  [[V0:%rd[0-9]+]], [[VALUE]], [[MASK]];
+  %v0 = call i64 @llvm.nvvm.match.any.sync.i64(i32 %mask, i64 %value)
+  ; CHECK:  match.any.sync.b64  [[V1:%rd[0-9]+]], [[VALUE]], 1;
+  %v1 = call i64 @llvm.nvvm.match.any.sync.i64(i32 1, i64 %value)
+  ; CHECK:  match.any.sync.b64  [[V2:%rd[0-9]+]], 2, [[MASK]];
+  %v2 = call i64 @llvm.nvvm.match.any.sync.i64(i32 %mask, i64 2)
+  ; CHECK:  match.any.sync.b64  [[V3:%rd[0-9]+]], 4, 3;
+  %v3 = call i64 @llvm.nvvm.match.any.sync.i64(i32 3, i64 4)
+  %sum1 = add i64 %v0, %v1
+  %sum2 = add i64 %v2, %v3
+  %sum3 = add i64 %sum1, %sum2
+  ret i64 %sum3;
+}
+
+declare {i32, i1} @llvm.nvvm.match.all.sync.i32p(i32, i32)
+declare {i64, i1} @llvm.nvvm.match.all.sync.i64p(i32, i64)
+
+; CHECK-LABEL: .func{{.*}}match.all.sync.i32p(
+define {i32,i1} @match.all.sync.i32p(i32 %mask, i32 %value) {
+  ; CHECK: ld.param.u32 	[[MASK:%r[0-9]+]], [match.all.sync.i32p_param_0];
+  ; CHECK: ld.param.u32 	[[VALUE:%r[0-9]+]], [match.all.sync.i32p_param_1];
+
+  ; CHECK:  match.all.sync.b32 {{%r[0-9]+\|%p[0-9]+}}, [[VALUE]], [[MASK]];
+  %r1 = call {i32, i1} @llvm.nvvm.match.all.sync.i32p(i32 %mask, i32 %value)
+  %v1 = extractvalue {i32, i1} %r1, 0
+  %p1 = extractvalue {i32, i1} %r1, 1
+
+  ; CHECK:  match.all.sync.b32 {{%r[0-9]+\|%p[0-9]+}}, 1, [[MASK]];
+  %r2 = call {i32, i1} @llvm.nvvm.match.all.sync.i32p(i32 %mask, i32 1)
+  %v2 = extractvalue {i32, i1} %r2, 0
+  %p2 = extractvalue {i32, i1} %r2, 1
+
+  ; CHECK:  match.all.sync.b32 {{%r[0-9]+\|%p[0-9]+}}, [[VALUE]], 2;
+  %r3 = call {i32, i1} @llvm.nvvm.match.all.sync.i32p(i32 2, i32 %value)
+  %v3 = extractvalue {i32, i1} %r3, 0
+  %p3 = extractvalue {i32, i1} %r3, 1
+
+  ; CHECK:  match.all.sync.b32 {{%r[0-9]+\|%p[0-9]+}}, 4, 3;
+  %r4 = call {i32, i1} @llvm.nvvm.match.all.sync.i32p(i32 3, i32 4)
+  %v4 = extractvalue {i32, i1} %r4, 0
+  %p4 = extractvalue {i32, i1} %r4, 1
+
+  %vsum1 = add i32 %v1, %v2
+  %vsum2 = add i32 %v3, %v4
+  %vsum3 = add i32 %vsum1, %vsum2
+  %psum1 = add i1 %p1, %p2
+  %psum2 = add i1 %p3, %p4
+  %psum3 = add i1 %psum1, %psum2
+  %ret0 = insertvalue {i32, i1} undef, i32 %vsum3, 0
+  %ret1 = insertvalue {i32, i1} %ret0, i1 %psum3, 1
+  ret {i32, i1} %ret1;
+}
+
+; CHECK-LABEL: .func{{.*}}match.all.sync.i64p(
+define {i64,i1} @match.all.sync.i64p(i32 %mask, i64 %value) {
+  ; CHECK: ld.param.u32 	[[MASK:%r[0-9]+]], [match.all.sync.i64p_param_0];
+  ; CHECK: ld.param.u64 	[[VALUE:%rd[0-9]+]], [match.all.sync.i64p_param_1];
+
+  ; CHECK:  match.all.sync.b64 {{%rd[0-9]+\|%p[0-9]+}}, [[VALUE]], [[MASK]];
+  %r1 = call {i64, i1} @llvm.nvvm.match.all.sync.i64p(i32 %mask, i64 %value)
+  %v1 = extractvalue {i64, i1} %r1, 0
+  %p1 = extractvalue {i64, i1} %r1, 1
+
+  ; CHECK:  match.all.sync.b64 {{%rd[0-9]+\|%p[0-9]+}}, 1, [[MASK]];
+  %r2 = call {i64, i1} @llvm.nvvm.match.all.sync.i64p(i32 %mask, i64 1)
+  %v2 = 

[PATCH] D38191: [NVPTX] added match.{any, all}.sync instructions, intrinsics & builtins.

2017-09-25 Thread Justin Lebar via Phabricator via cfe-commits
jlebar added inline comments.



Comment at: clang/include/clang/Basic/BuiltinsNVPTX.def:419
+TARGET_BUILTIN(__nvvm_match_any_sync_i64, "WiUiWi", "", "ptx60")
+// These return a pair {value, predicate} which requires custom lowering.
+TARGET_BUILTIN(__nvvm_match_all_sync_i32p, "UiUiUii*", "", "ptx60")

Nit, non-restrictive "which" should get a comma.  :)



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:9603
+Value *Pred = Builder.CreateSExt(Builder.CreateExtractValue(ResultPair, 1),
+ PredOutPtr.getElementType());
+Builder.CreateStore(Pred, PredOutPtr);

Doing sext i1 -> i32 is going to cause us to store 0 or -1 in the pred 
(right?).  The CUDA docs say

> Predicate pred is set to true if all threads in mask have the same value of 
> value; otherwise the predicate is set to false.

I'd guess that "true" probably means 1 (i.e. uext i1 -> i32) rather than -1, 
although, I guess we have to check.


https://reviews.llvm.org/D38191



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


[PATCH] D38188: [CUDA] Fix names of __nvvm_vote* intrinsics.

2017-09-25 Thread Artem Belevich via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL314129: [CUDA] Fix names of __nvvm_vote* intrinsics. 
(authored by tra).

Changed prior to commit:
  https://reviews.llvm.org/D38188?vs=116400=116576#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D38188

Files:
  cfe/trunk/lib/Headers/__clang_cuda_intrinsics.h


Index: cfe/trunk/lib/Headers/__clang_cuda_intrinsics.h
===
--- cfe/trunk/lib/Headers/__clang_cuda_intrinsics.h
+++ cfe/trunk/lib/Headers/__clang_cuda_intrinsics.h
@@ -170,22 +170,22 @@
 }
 
 inline __device__ int __all_sync(unsigned int mask, int pred) {
-  return __nvvm_vote_sync_all(mask, pred);
+  return __nvvm_vote_all_sync(mask, pred);
 }
 
 inline __device__ int __any_sync(unsigned int mask, int pred) {
-  return __nvvm_vote_sync_any(mask, pred);
+  return __nvvm_vote_any_sync(mask, pred);
 }
 
 inline __device__ int __uni_sync(unsigned int mask, int pred) {
-  return __nvvm_vote_sync_uni(mask, pred);
+  return __nvvm_vote_uni_sync(mask, pred);
 }
 
 inline __device__ unsigned int __ballot_sync(unsigned int mask, int pred) {
-  return __nvvm_vote_sync_ballot(mask, pred);
+  return __nvvm_vote_ballot_sync(mask, pred);
 }
 
-inline __device__ activemask() { return __nvvm_vote.ballot(1); }
+inline __device__ unsigned int activemask() { return __nvvm_vote_ballot(1); }
 
 #endif // __CUDA_VERSION >= 9000 && (!defined(__CUDA_ARCH__) ||
// __CUDA_ARCH__ >= 300)


Index: cfe/trunk/lib/Headers/__clang_cuda_intrinsics.h
===
--- cfe/trunk/lib/Headers/__clang_cuda_intrinsics.h
+++ cfe/trunk/lib/Headers/__clang_cuda_intrinsics.h
@@ -170,22 +170,22 @@
 }
 
 inline __device__ int __all_sync(unsigned int mask, int pred) {
-  return __nvvm_vote_sync_all(mask, pred);
+  return __nvvm_vote_all_sync(mask, pred);
 }
 
 inline __device__ int __any_sync(unsigned int mask, int pred) {
-  return __nvvm_vote_sync_any(mask, pred);
+  return __nvvm_vote_any_sync(mask, pred);
 }
 
 inline __device__ int __uni_sync(unsigned int mask, int pred) {
-  return __nvvm_vote_sync_uni(mask, pred);
+  return __nvvm_vote_uni_sync(mask, pred);
 }
 
 inline __device__ unsigned int __ballot_sync(unsigned int mask, int pred) {
-  return __nvvm_vote_sync_ballot(mask, pred);
+  return __nvvm_vote_ballot_sync(mask, pred);
 }
 
-inline __device__ activemask() { return __nvvm_vote.ballot(1); }
+inline __device__ unsigned int activemask() { return __nvvm_vote_ballot(1); }
 
 #endif // __CUDA_VERSION >= 9000 && (!defined(__CUDA_ARCH__) ||
// __CUDA_ARCH__ >= 300)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r314129 - [CUDA] Fix names of __nvvm_vote* intrinsics.

2017-09-25 Thread Artem Belevich via cfe-commits
Author: tra
Date: Mon Sep 25 10:55:26 2017
New Revision: 314129

URL: http://llvm.org/viewvc/llvm-project?rev=314129=rev
Log:
[CUDA] Fix names of __nvvm_vote* intrinsics.

Also fixed a syntax error in activemask().

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

Modified:
cfe/trunk/lib/Headers/__clang_cuda_intrinsics.h

Modified: cfe/trunk/lib/Headers/__clang_cuda_intrinsics.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/__clang_cuda_intrinsics.h?rev=314129=314128=314129=diff
==
--- cfe/trunk/lib/Headers/__clang_cuda_intrinsics.h (original)
+++ cfe/trunk/lib/Headers/__clang_cuda_intrinsics.h Mon Sep 25 10:55:26 2017
@@ -170,22 +170,22 @@ inline __device__ void __barrier_sync_co
 }
 
 inline __device__ int __all_sync(unsigned int mask, int pred) {
-  return __nvvm_vote_sync_all(mask, pred);
+  return __nvvm_vote_all_sync(mask, pred);
 }
 
 inline __device__ int __any_sync(unsigned int mask, int pred) {
-  return __nvvm_vote_sync_any(mask, pred);
+  return __nvvm_vote_any_sync(mask, pred);
 }
 
 inline __device__ int __uni_sync(unsigned int mask, int pred) {
-  return __nvvm_vote_sync_uni(mask, pred);
+  return __nvvm_vote_uni_sync(mask, pred);
 }
 
 inline __device__ unsigned int __ballot_sync(unsigned int mask, int pred) {
-  return __nvvm_vote_sync_ballot(mask, pred);
+  return __nvvm_vote_ballot_sync(mask, pred);
 }
 
-inline __device__ activemask() { return __nvvm_vote.ballot(1); }
+inline __device__ unsigned int activemask() { return __nvvm_vote_ballot(1); }
 
 #endif // __CUDA_VERSION >= 9000 && (!defined(__CUDA_ARCH__) ||
// __CUDA_ARCH__ >= 300)


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


[PATCH] D38188: [CUDA] Fix names of __nvvm_vote* intrinsics.

2017-09-25 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

In https://reviews.llvm.org/D38188#880318, @jlebar wrote:

> Should we add tests to the test-suite?  Or, are these already caught by the 
> existing tests we have?


That's the plan. Once clang can compile CUDA headers, I'll add CUDA-9 specific 
tests to the testsuite and update the buildbot to compile/run tests with CUDA-9.


https://reviews.llvm.org/D38188



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


[PATCH] D38243: [clang-format] Add ext/ to google include categories

2017-09-25 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir created this revision.
Herald added a subscriber: klimek.

This adds an ext/ header include category for google style.


https://reviews.llvm.org/D38243

Files:
  lib/Format/Format.cpp


Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -665,7 +665,8 @@
   GoogleStyle.AlwaysBreakTemplateDeclarations = true;
   GoogleStyle.ConstructorInitializerAllOnOneLineOrOnePerLine = true;
   GoogleStyle.DerivePointerAlignment = true;
-  GoogleStyle.IncludeCategories = {{"^<.*\\.h>", 1}, {"^<.*", 2}, {".*", 3}};
+  GoogleStyle.IncludeCategories = {
+  {"^", 2}, {"^<.*\\.h>", 1}, {"^<.*", 2}, {".*", 3}};
   GoogleStyle.IncludeIsMainRegex = "([-_](test|unittest))?$";
   GoogleStyle.IndentCaseLabels = true;
   GoogleStyle.KeepEmptyLinesAtTheStartOfBlocks = false;


Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -665,7 +665,8 @@
   GoogleStyle.AlwaysBreakTemplateDeclarations = true;
   GoogleStyle.ConstructorInitializerAllOnOneLineOrOnePerLine = true;
   GoogleStyle.DerivePointerAlignment = true;
-  GoogleStyle.IncludeCategories = {{"^<.*\\.h>", 1}, {"^<.*", 2}, {".*", 3}};
+  GoogleStyle.IncludeCategories = {
+  {"^", 2}, {"^<.*\\.h>", 1}, {"^<.*", 2}, {".*", 3}};
   GoogleStyle.IncludeIsMainRegex = "([-_](test|unittest))?$";
   GoogleStyle.IndentCaseLabels = true;
   GoogleStyle.KeepEmptyLinesAtTheStartOfBlocks = false;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D38188: [CUDA] Fix names of __nvvm_vote* intrinsics.

2017-09-25 Thread Justin Lebar via Phabricator via cfe-commits
jlebar accepted this revision.
jlebar added a comment.
This revision is now accepted and ready to land.

Should we add tests to the test-suite?  Or, are these already caught by the 
existing tests we have?


https://reviews.llvm.org/D38188



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


r314124 - [Sema] Null check in BuildDeclarationNameExpr

2017-09-25 Thread Yi Kong via cfe-commits
Author: kongyi
Date: Mon Sep 25 10:36:54 2017
New Revision: 314124

URL: http://llvm.org/viewvc/llvm-project?rev=314124=rev
Log:
[Sema] Null check in BuildDeclarationNameExpr

Qualtype may point to null if we cannot infer its type yet.

Fixes PR33843

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

Modified:
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/SemaCXX/typo-correction-crash.cpp

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=314124=314123=314124=diff
==
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Mon Sep 25 10:36:54 2017
@@ -2803,6 +2803,8 @@ ExprResult Sema::BuildDeclarationNameExp
 
   {
 QualType type = VD->getType();
+if (type.isNull())
+  return ExprError();
 if (auto *FPT = type->getAs()) {
   // C++ [except.spec]p17:
   //   An exception-specification is considered to be needed when:

Modified: cfe/trunk/test/SemaCXX/typo-correction-crash.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/typo-correction-crash.cpp?rev=314124=314123=314124=diff
==
--- cfe/trunk/test/SemaCXX/typo-correction-crash.cpp (original)
+++ cfe/trunk/test/SemaCXX/typo-correction-crash.cpp Mon Sep 25 10:36:54 2017
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -std=c++14 -verify %s
+// RUN: %clang_cc1 -fsyntax-only -std=c++17 -verify %s
 auto check1() {
   return 1;
   return s; // expected-error {{use of undeclared identifier 's'}}
@@ -19,3 +19,5 @@ struct FooRecord { };
 FooRecord::NestedNamespace::type x; // expected-error {{no member named 
'NestedNamespace' in 'FooRecord'; did you mean 
'BarNamespace::NestedNamespace'?}}
 
 void cast_expr(int g) { +int(n)(g); } // expected-error {{undeclared 
identifier 'n'}}
+
+void bind() { for (const auto& [test,_] : _test_) { }; } // expected-error 
{{undeclared identifier '_test_'}}


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


[PATCH] D38158: [Sema] Null check in BuildDeclarationNameExpr

2017-09-25 Thread Yi Kong via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL314124: [Sema] Null check in BuildDeclarationNameExpr 
(authored by kongyi).

Changed prior to commit:
  https://reviews.llvm.org/D38158?vs=116279=116571#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D38158

Files:
  cfe/trunk/lib/Sema/SemaExpr.cpp
  cfe/trunk/test/SemaCXX/typo-correction-crash.cpp


Index: cfe/trunk/test/SemaCXX/typo-correction-crash.cpp
===
--- cfe/trunk/test/SemaCXX/typo-correction-crash.cpp
+++ cfe/trunk/test/SemaCXX/typo-correction-crash.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -std=c++14 -verify %s
+// RUN: %clang_cc1 -fsyntax-only -std=c++17 -verify %s
 auto check1() {
   return 1;
   return s; // expected-error {{use of undeclared identifier 's'}}
@@ -19,3 +19,5 @@
 FooRecord::NestedNamespace::type x; // expected-error {{no member named 
'NestedNamespace' in 'FooRecord'; did you mean 
'BarNamespace::NestedNamespace'?}}
 
 void cast_expr(int g) { +int(n)(g); } // expected-error {{undeclared 
identifier 'n'}}
+
+void bind() { for (const auto& [test,_] : _test_) { }; } // expected-error 
{{undeclared identifier '_test_'}}
Index: cfe/trunk/lib/Sema/SemaExpr.cpp
===
--- cfe/trunk/lib/Sema/SemaExpr.cpp
+++ cfe/trunk/lib/Sema/SemaExpr.cpp
@@ -2803,6 +2803,8 @@
 
   {
 QualType type = VD->getType();
+if (type.isNull())
+  return ExprError();
 if (auto *FPT = type->getAs()) {
   // C++ [except.spec]p17:
   //   An exception-specification is considered to be needed when:


Index: cfe/trunk/test/SemaCXX/typo-correction-crash.cpp
===
--- cfe/trunk/test/SemaCXX/typo-correction-crash.cpp
+++ cfe/trunk/test/SemaCXX/typo-correction-crash.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -std=c++14 -verify %s
+// RUN: %clang_cc1 -fsyntax-only -std=c++17 -verify %s
 auto check1() {
   return 1;
   return s; // expected-error {{use of undeclared identifier 's'}}
@@ -19,3 +19,5 @@
 FooRecord::NestedNamespace::type x; // expected-error {{no member named 'NestedNamespace' in 'FooRecord'; did you mean 'BarNamespace::NestedNamespace'?}}
 
 void cast_expr(int g) { +int(n)(g); } // expected-error {{undeclared identifier 'n'}}
+
+void bind() { for (const auto& [test,_] : _test_) { }; } // expected-error {{undeclared identifier '_test_'}}
Index: cfe/trunk/lib/Sema/SemaExpr.cpp
===
--- cfe/trunk/lib/Sema/SemaExpr.cpp
+++ cfe/trunk/lib/Sema/SemaExpr.cpp
@@ -2803,6 +2803,8 @@
 
   {
 QualType type = VD->getType();
+if (type.isNull())
+  return ExprError();
 if (auto *FPT = type->getAs()) {
   // C++ [except.spec]p17:
   //   An exception-specification is considered to be needed when:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D38158: [Sema] Null check in BuildDeclarationNameExpr

2017-09-25 Thread Reid Kleckner via Phabricator via cfe-commits
rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

lgtm


Repository:
  rL LLVM

https://reviews.llvm.org/D38158



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


[PATCH] D38225: [clangd] Fix missing "message" key when responding with unsupported method

2017-09-25 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL314119: [clangd] Fix missing "message" key when responding 
with unsupported method (authored by d0k).

Repository:
  rL LLVM

https://reviews.llvm.org/D38225

Files:
  clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp
  clang-tools-extra/trunk/test/clangd/unsupported-method.test


Index: clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp
===
--- clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp
+++ clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp
@@ -42,7 +42,7 @@
   // Return that this method is unsupported.
   writeMessage(
   R"({"jsonrpc":"2.0","id":)" + ID +
-  R"(,"error":{"code":-32601}})");
+  R"(,"error":{"code":-32601,"message":"method not found"}})");
 }
 
 void Handler::handleNotification(llvm::yaml::MappingNode *Params) {
Index: clang-tools-extra/trunk/test/clangd/unsupported-method.test
===
--- clang-tools-extra/trunk/test/clangd/unsupported-method.test
+++ clang-tools-extra/trunk/test/clangd/unsupported-method.test
@@ -0,0 +1,19 @@
+# RUN: clangd -run-synchronously < %s | FileCheck %s
+# It is absolutely vital that this file has CRLF line endings.
+#
+Content-Length: 125
+
+{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
+
+Content-Length: 143
+
+{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"file:///main.cpp","languageId":"cpp","version":1,"text":""}}}
+
+Content-Length: 92
+
+{"jsonrpc":"2.0","id":1,"method":"textDocument/jumpInTheAirLikeYouJustDontCare","params":{}}
+# CHECK: {"jsonrpc":"2.0","id":1,"error":{"code":-32601,"message":"method not 
found"}}
+
+Content-Length: 44
+
+{"jsonrpc":"2.0","id":2,"method":"shutdown"}


Index: clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp
===
--- clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp
+++ clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp
@@ -42,7 +42,7 @@
   // Return that this method is unsupported.
   writeMessage(
   R"({"jsonrpc":"2.0","id":)" + ID +
-  R"(,"error":{"code":-32601}})");
+  R"(,"error":{"code":-32601,"message":"method not found"}})");
 }
 
 void Handler::handleNotification(llvm::yaml::MappingNode *Params) {
Index: clang-tools-extra/trunk/test/clangd/unsupported-method.test
===
--- clang-tools-extra/trunk/test/clangd/unsupported-method.test
+++ clang-tools-extra/trunk/test/clangd/unsupported-method.test
@@ -0,0 +1,19 @@
+# RUN: clangd -run-synchronously < %s | FileCheck %s
+# It is absolutely vital that this file has CRLF line endings.
+#
+Content-Length: 125
+
+{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
+
+Content-Length: 143
+
+{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"file:///main.cpp","languageId":"cpp","version":1,"text":""}}}
+
+Content-Length: 92
+
+{"jsonrpc":"2.0","id":1,"method":"textDocument/jumpInTheAirLikeYouJustDontCare","params":{}}
+# CHECK: {"jsonrpc":"2.0","id":1,"error":{"code":-32601,"message":"method not found"}}
+
+Content-Length: 44
+
+{"jsonrpc":"2.0","id":2,"method":"shutdown"}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r314119 - [clangd] Fix missing "message" key when responding with unsupported method

2017-09-25 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Mon Sep 25 10:16:47 2017
New Revision: 314119

URL: http://llvm.org/viewvc/llvm-project?rev=314119=rev
Log:
[clangd] Fix missing "message" key when responding with unsupported method

The language server protocol dictates that a ResponseError should have a
[message string][1] describing the error. This adds a simple message to the
error and a simple test.

[1]: 
https://github.com/Microsoft/language-server-protocol/blob/master/protocol.md#response-message

Patch by Raoul Wols!

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

Added:
clang-tools-extra/trunk/test/clangd/unsupported-method.test
Modified:
clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp

Modified: clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp?rev=314119=314118=314119=diff
==
--- clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp (original)
+++ clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp Mon Sep 25 10:16:47 
2017
@@ -42,7 +42,7 @@ void Handler::handleMethod(llvm::yaml::M
   // Return that this method is unsupported.
   writeMessage(
   R"({"jsonrpc":"2.0","id":)" + ID +
-  R"(,"error":{"code":-32601}})");
+  R"(,"error":{"code":-32601,"message":"method not found"}})");
 }
 
 void Handler::handleNotification(llvm::yaml::MappingNode *Params) {

Added: clang-tools-extra/trunk/test/clangd/unsupported-method.test
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clangd/unsupported-method.test?rev=314119=auto
==
--- clang-tools-extra/trunk/test/clangd/unsupported-method.test (added)
+++ clang-tools-extra/trunk/test/clangd/unsupported-method.test Mon Sep 25 
10:16:47 2017
@@ -0,0 +1,19 @@
+# RUN: clangd -run-synchronously < %s | FileCheck %s
+# It is absolutely vital that this file has CRLF line endings.
+#
+Content-Length: 125
+
+{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
+
+Content-Length: 143
+
+{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"file:///main.cpp","languageId":"cpp","version":1,"text":""}}}
+
+Content-Length: 92
+
+{"jsonrpc":"2.0","id":1,"method":"textDocument/jumpInTheAirLikeYouJustDontCare","params":{}}
+# CHECK: {"jsonrpc":"2.0","id":1,"error":{"code":-32601,"message":"method not 
found"}}
+
+Content-Length: 44
+
+{"jsonrpc":"2.0","id":2,"method":"shutdown"}


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


[PATCH] D38158: [Sema] Null check in BuildDeclarationNameExpr

2017-09-25 Thread Yi Kong via Phabricator via cfe-commits
kongyi added a comment.

ping...


Repository:
  rL LLVM

https://reviews.llvm.org/D38158



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


[PATCH] D38225: [clangd] Fix missing "message" key when responding with unsupported method

2017-09-25 Thread Raoul Wols via Phabricator via cfe-commits
rwols added a comment.

No, I don't have commit access. Feel free to merge.


https://reviews.llvm.org/D38225



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


[PATCH] D30295: [analyzer] clarify undef shift result when shift count is negative or exceeds the bit width

2017-09-25 Thread Daniel Marjamäki via Phabricator via cfe-commits
danielmarjamaki added a comment.

ping


Repository:
  rL LLVM

https://reviews.llvm.org/D30295



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


[PATCH] D37822: [OpenCL] Clean up and add missing fields for block struct

2017-09-25 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added inline comments.



Comment at: lib/CodeGen/CGBlocks.cpp:311
+// The header is basically 'struct { int; int; generic void *;
+// custom_fields; }'. Assert that that struct is packed.
+auto GenPtrAlign = CharUnits::fromQuantity(

remove one "that".



Comment at: lib/CodeGen/CGBlocks.cpp:312
+// custom_fields; }'. Assert that that struct is packed.
+auto GenPtrAlign = CharUnits::fromQuantity(
+CGM.getTarget().getPointerAlign(LangAS::opencl_generic) / 8);

I think the alignment might not be computed correctly now if there will be 
custom fields that might have a bigger size than a pointer? Also what happens 
if we have captures as well?



Comment at: lib/CodeGen/CGBlocks.cpp:850
+   CGM.getDataLayout().getTypeAllocSize(I->getType())),
+   "block.custom");
+  }

do we need to add numeration to each item name?



Comment at: lib/CodeGen/CGBlocks.cpp:1250
   // Function
   fields.add(blockFn);
 

If we reorder fields and put this on top we can merge the if statements above 
and below this point.


https://reviews.llvm.org/D37822



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


Re: r314079 - Fix implicit-fallthrough warning by adding missing break

2017-09-25 Thread David Blaikie via cfe-commits
Is there also missing test coverage here?

On Sun, Sep 24, 2017 at 8:19 AM Simon Pilgrim via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: rksimon
> Date: Sun Sep 24 08:17:46 2017
> New Revision: 314079
>
> URL: http://llvm.org/viewvc/llvm-project?rev=314079=rev
> Log:
> Fix implicit-fallthrough warning by adding missing break
>
> Modified:
> cfe/trunk/lib/CrossTU/CrossTranslationUnit.cpp
>
> Modified: cfe/trunk/lib/CrossTU/CrossTranslationUnit.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CrossTU/CrossTranslationUnit.cpp?rev=314079=314078=314079=diff
>
> ==
> --- cfe/trunk/lib/CrossTU/CrossTranslationUnit.cpp (original)
> +++ cfe/trunk/lib/CrossTU/CrossTranslationUnit.cpp Sun Sep 24 08:17:46 2017
> @@ -185,6 +185,7 @@ void CrossTranslationUnitContext::emitCr
>case index_error_code::invalid_index_format:
>  Context.getDiagnostics().Report(diag::err_fnmap_parsing)
>  << IE.getFileName() << IE.getLineNum();
> +break;
>case index_error_code::multiple_definitions:
>  Context.getDiagnostics().Report(diag::err_multiple_def_index)
>  << IE.getLineNum();
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libclc] r314112 - Rework atomic ops to use clang builtins rather than llvm asm

2017-09-25 Thread Jan Vesely via cfe-commits
Author: jvesely
Date: Mon Sep 25 09:07:34 2017
New Revision: 314112

URL: http://llvm.org/viewvc/llvm-project?rev=314112=rev
Log:
Rework atomic ops to use clang builtins rather than llvm asm

reviewer: Aaron Watry

Signed-off-by: Jan Vesely 

Added:
libclc/trunk/generic/lib/atomic/atomic_add.cl
libclc/trunk/generic/lib/atomic/atomic_and.cl
libclc/trunk/generic/lib/atomic/atomic_cmpxchg.cl
libclc/trunk/generic/lib/atomic/atomic_max.cl
libclc/trunk/generic/lib/atomic/atomic_min.cl
libclc/trunk/generic/lib/atomic/atomic_or.cl
libclc/trunk/generic/lib/atomic/atomic_sub.cl
libclc/trunk/generic/lib/atomic/atomic_xor.cl
Removed:
libclc/trunk/amdgpu/lib/atomic/atomic.cl
libclc/trunk/generic/lib/atomic/atomic_impl.ll
Modified:
libclc/trunk/amdgpu/lib/SOURCES
libclc/trunk/generic/lib/SOURCES
libclc/trunk/generic/lib/atomic/atomic_xchg.cl

Modified: libclc/trunk/amdgpu/lib/SOURCES
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/amdgpu/lib/SOURCES?rev=314112=314111=314112=diff
==
--- libclc/trunk/amdgpu/lib/SOURCES (original)
+++ libclc/trunk/amdgpu/lib/SOURCES Mon Sep 25 09:07:34 2017
@@ -1,4 +1,3 @@
-atomic/atomic.cl
 math/nextafter.cl
 math/sqrt.cl
 image/get_image_width.cl

Removed: libclc/trunk/amdgpu/lib/atomic/atomic.cl
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/amdgpu/lib/atomic/atomic.cl?rev=314111=auto
==
--- libclc/trunk/amdgpu/lib/atomic/atomic.cl (original)
+++ libclc/trunk/amdgpu/lib/atomic/atomic.cl (removed)
@@ -1,65 +0,0 @@
-#include 
-
-#define ATOMIC_FUNC_DEFINE(RET_SIGN, ARG_SIGN, TYPE, CL_FUNCTION, 
CLC_FUNCTION, CL_ADDRSPACE, LLVM_ADDRSPACE) \
-_CLC_OVERLOAD _CLC_DEF RET_SIGN TYPE CL_FUNCTION (volatile CL_ADDRSPACE 
RET_SIGN TYPE *p, RET_SIGN TYPE val) { \
-   return (RET_SIGN 
TYPE)__clc_##CLC_FUNCTION##_addr##LLVM_ADDRSPACE((volatile CL_ADDRSPACE 
ARG_SIGN TYPE*)p, (ARG_SIGN TYPE)val); \
-}
-
-/* For atomic functions that don't need different bitcode dependending on 
argument signedness */
-#define ATOMIC_FUNC_SIGN(TYPE, FUNCTION, CL_ADDRSPACE, LLVM_ADDRSPACE) \
-   _CLC_DECL signed TYPE __clc_##FUNCTION##_addr##LLVM_ADDRSPACE(volatile 
CL_ADDRSPACE signed TYPE*, signed TYPE); \
-   ATOMIC_FUNC_DEFINE(signed, signed, TYPE, FUNCTION, FUNCTION, 
CL_ADDRSPACE, LLVM_ADDRSPACE) \
-   ATOMIC_FUNC_DEFINE(unsigned, signed, TYPE, FUNCTION, FUNCTION, 
CL_ADDRSPACE, LLVM_ADDRSPACE)
-
-#define ATOMIC_FUNC_ADDRSPACE(TYPE, FUNCTION) \
-   ATOMIC_FUNC_SIGN(TYPE, FUNCTION, global, 1) \
-   ATOMIC_FUNC_SIGN(TYPE, FUNCTION, local, 3)
-
-#define ATOMIC_FUNC(FUNCTION) \
-   ATOMIC_FUNC_ADDRSPACE(int, FUNCTION)
-
-#define ATOMIC_FUNC_DEFINE_3_ARG(RET_SIGN, ARG_SIGN, TYPE, CL_FUNCTION, 
CLC_FUNCTION, CL_ADDRSPACE, LLVM_ADDRSPACE) \
-_CLC_OVERLOAD _CLC_DEF RET_SIGN TYPE CL_FUNCTION (volatile CL_ADDRSPACE 
RET_SIGN TYPE *p, RET_SIGN TYPE cmp, RET_SIGN TYPE val) { \
-   return (RET_SIGN 
TYPE)__clc_##CLC_FUNCTION##_addr##LLVM_ADDRSPACE((volatile CL_ADDRSPACE 
ARG_SIGN TYPE*)p, (ARG_SIGN TYPE)cmp, (ARG_SIGN TYPE)val); \
-}
-
-/* For atomic functions that don't need different bitcode dependending on 
argument signedness */
-#define ATOMIC_FUNC_SIGN_3_ARG(TYPE, FUNCTION, CL_ADDRSPACE, LLVM_ADDRSPACE) \
-   _CLC_DECL signed TYPE __clc_##FUNCTION##_addr##LLVM_ADDRSPACE(volatile 
CL_ADDRSPACE signed TYPE*, signed TYPE, signed TYPE); \
-   ATOMIC_FUNC_DEFINE_3_ARG(signed, signed, TYPE, FUNCTION, FUNCTION, 
CL_ADDRSPACE, LLVM_ADDRSPACE) \
-   ATOMIC_FUNC_DEFINE_3_ARG(unsigned, signed, TYPE, FUNCTION, FUNCTION, 
CL_ADDRSPACE, LLVM_ADDRSPACE)
-
-#define ATOMIC_FUNC_ADDRSPACE_3_ARG(TYPE, FUNCTION) \
-   ATOMIC_FUNC_SIGN_3_ARG(TYPE, FUNCTION, global, 1) \
-   ATOMIC_FUNC_SIGN_3_ARG(TYPE, FUNCTION, local, 3)
-
-#define ATOMIC_FUNC_3_ARG(FUNCTION) \
-   ATOMIC_FUNC_ADDRSPACE_3_ARG(int, FUNCTION)
-
-ATOMIC_FUNC(atomic_add)
-ATOMIC_FUNC(atomic_and)
-ATOMIC_FUNC(atomic_or)
-ATOMIC_FUNC(atomic_sub)
-ATOMIC_FUNC(atomic_xchg)
-ATOMIC_FUNC(atomic_xor)
-ATOMIC_FUNC_3_ARG(atomic_cmpxchg)
-
-_CLC_DECL signed int __clc_atomic_max_addr1(volatile global signed int*, 
signed int);
-_CLC_DECL signed int __clc_atomic_max_addr3(volatile local signed int*, signed 
int);
-_CLC_DECL uint __clc_atomic_umax_addr1(volatile global uint*, uint);
-_CLC_DECL uint __clc_atomic_umax_addr3(volatile local uint*, uint);
-
-ATOMIC_FUNC_DEFINE(signed, signed, int, atomic_max, atomic_max, global, 1)
-ATOMIC_FUNC_DEFINE(signed, signed, int, atomic_max, atomic_max, local, 3)
-ATOMIC_FUNC_DEFINE(unsigned, unsigned, int, atomic_max, atomic_umax, global, 1)
-ATOMIC_FUNC_DEFINE(unsigned, unsigned, int, atomic_max, atomic_umax, local, 3)
-
-_CLC_DECL signed int __clc_atomic_min_addr1(volatile global signed int*, 
signed int);
-_CLC_DECL signed int 

[libclc] r314111 - prepare_builtins: Fix compile breakage with older LLVM

2017-09-25 Thread Jan Vesely via cfe-commits
Author: jvesely
Date: Mon Sep 25 09:04:37 2017
New Revision: 314111

URL: http://llvm.org/viewvc/llvm-project?rev=314111=rev
Log:
prepare_builtins: Fix compile breakage with older LLVM

Fixes r314050

reviewer: Tom Stellard

Signed-off-by: Jan Vesely 

Modified:
libclc/trunk/utils/prepare-builtins.cpp

Modified: libclc/trunk/utils/prepare-builtins.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/utils/prepare-builtins.cpp?rev=314111=314110=314111=diff
==
--- libclc/trunk/utils/prepare-builtins.cpp (original)
+++ libclc/trunk/utils/prepare-builtins.cpp Mon Sep 25 09:04:37 2017
@@ -84,8 +84,13 @@ int main(int argc, char **argv) {
   }
 
   std::error_code EC;
+#if HAVE_LLVM >= 0x0600
   std::unique_ptr Out(
   new ToolOutputFile(OutputFilename, EC, sys::fs::F_None));
+#else
+  std::unique_ptr Out(
+  new tool_output_file(OutputFilename, EC, sys::fs::F_None));
+#endif
   if (EC) {
 errs() << EC.message() << '\n';
 exit(1);


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


[PATCH] D38226: [XRay][Driver] Do not link in XRay runtime in shared libs

2017-09-25 Thread Reid Kleckner via Phabricator via cfe-commits
rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

Looks good


https://reviews.llvm.org/D38226



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


[PATCH] D36973: [libclang] Add support for querying cursor availability

2017-09-25 Thread Jonathan B Coe via Phabricator via cfe-commits
jbcoe added inline comments.



Comment at: bindings/python/tests/cindex/test_cursor.py:407
+# AvailabilityKind.DEPRECATED
+tu = get_tu('#include \n void test(char* s) { std::gets(s); }', 
lang='cpp')
+cursor = get_cursor(tu, 'gets')

It might be better to use a user-defined function that is explicitly deprecated 
rather than relying on 3rd party standard includes deprecating things for you.


https://reviews.llvm.org/D36973



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


[PATCH] D38134: [OpenCL] Emit enqueued block as kernel

2017-09-25 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

I think we should add a test case when the same block is both called and 
enqueued.




Comment at: lib/CodeGen/CGOpenCLRuntime.cpp:113
+
+llvm::Value *CGOpenCLRuntime::emitOpenCLEnqueuedBlock(CodeGenFunction ,
+  const Expr *E) {

yaxunl wrote:
> Anastasia wrote:
> > yaxunl wrote:
> > > Anastasia wrote:
> > > > I am not particularly in favour of duplicating CodeGen functionality as 
> > > > it typically has so many special cases that are hard to catch. Is this 
> > > > logic needed in order to pass to block literal information  that the 
> > > > block is enqueued?
> > > This code is needed to emit separate functions for a block which is 
> > > directly called and also enqueued as a kernel. Since the kernel needs to 
> > > have proper calling convention and ABI, it cannot be emitted as the same 
> > > function as when the block is called directly. Since it is OpenCL 
> > > specific code, I found it is cleaner to separate this code as member of 
> > > CGOpenCLRuntime instead of fitting it into CGF.EmitBlockLiteral.
> > This part is replacing standard `EmitScalarExpr` call which is doing 
> > several things before calling into block generation. That's why I am a bit 
> > worried we are covering all the corner cases here.
> > 
> > So if we transform all blocks into kernels unconditionally we won't need 
> > this special handling then?
> > 
> > Do we generate two versions of the blocks now: one for enqueue and one for 
> > call?
> If we transform all blocks into kernels, we could simplify the logic. 
> Probably will not need this special handling.
> 
> However, when the block is called directly, the first argument is a private 
> pointer, when it is executed as a kernel, the first argument is a global 
> pointer or a struct (for amdgpu target), therefore the emitted functions 
> cannot be the same.
Would using generic address space for this first argument not work?



Comment at: test/CodeGenOpenCL/amdgpu-enqueue-kernel.cl:3
+
+// CHECK: %[[S1:struct.__amdgpu_block_arg_t.*]] = type { [3 x i64], [1 x i8] }
+// CHECK: %[[S2:struct.__amdgpu_block_arg_t.*]] = type { [5 x i64], [1 x i8] }

yaxunl wrote:
> Anastasia wrote:
> > This struct is not identical to block literal struct?
> The LLVM type of the first argument of block invoke function is created 
> directly with sorting and rearrangement. There is no AST type corresponding 
> to it. However, the function codegen requires AST type of this argument. I 
> feel it is unnecessary to create the corresponding AST type. For simplicity, 
> just create an AST type with the same size and alignment as the LLVM type. In 
> the function code, it will be bitcasted to the correct LLVM struct type and 
> get the captured variables.
So `void ptr` won't be possible here? Since it is cast to a right struct inside 
the block anyway. Once again a block is a special type object with known 
semantic to compiler and runtime in contract to kernels that can be written 
with any arbitrary type of arguments.

I just don't like the idea of duplicating the block invoke function in case 
it's being both called and enqueued. Also the login in blocks code generation 
becomes difficult to understand. So I am wondering if we could perhaps create a 
separate kernel function (as a wrapper) for enqueue_kernel which would call a 
block instead. What do you think about it? I think the kernel prototype would 
be fairly generic as it would just have a block call inside and pass the 
arguments into it... We won't need to modify block generation then at all. 


https://reviews.llvm.org/D38134



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


[PATCH] D38225: [clangd] Fix missing "message" key when responding with unsupported method

2017-09-25 Thread Benjamin Kramer via Phabricator via cfe-commits
bkramer accepted this revision.
bkramer added a comment.
This revision is now accepted and ready to land.

This looks good. Do you have commit access?


https://reviews.llvm.org/D38225



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


[PATCH] D37150: [clangd] Command line arg to specify compile_commands.json path

2017-09-25 Thread William Enright via Phabricator via cfe-commits
Nebiroth updated this revision to Diff 116559.
Nebiroth added a comment.

Fixed inverted compile_commands check logic that made tests fail.
More readable command arg checks.


https://reviews.llvm.org/D37150

Files:
  clangd/ClangdLSPServer.cpp
  clangd/ClangdLSPServer.h
  clangd/GlobalCompilationDatabase.cpp
  clangd/GlobalCompilationDatabase.h
  clangd/tool/ClangdMain.cpp

Index: clangd/tool/ClangdMain.cpp
===
--- clangd/tool/ClangdMain.cpp
+++ clangd/tool/ClangdMain.cpp
@@ -11,16 +11,23 @@
 #include "JSONRPCDispatcher.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Path.h"
 #include "llvm/Support/Program.h"
-
 #include 
 #include 
 #include 
 #include 
+#include 
 
 using namespace clang;
 using namespace clang::clangd;
 
+static llvm::cl::opt CompileCommandsDir(
+"compile-commands-dir",
+llvm::cl::desc("Specify a path to look for compile_commands.json. If path "
+   "is invalid, clangd will look in the current directory and "
+   "parent paths of each source file."));
+
 static llvm::cl::opt
 WorkerThreadsCount("j",
llvm::cl::desc("Number of async workers used by clangd"),
@@ -56,18 +63,40 @@
   if (RunSynchronously)
 WorkerThreadsCount = 0;
 
+  /// Validate command line arguments.
   llvm::raw_ostream  = llvm::outs();
   llvm::raw_ostream  = llvm::errs();
   JSONOutput Out(Outs, Logs);
 
-  // Change stdin to binary to not lose \r\n on windows.
-  llvm::sys::ChangeStdinToBinary();
+  // If --compile-commands-dir arg was invoked, check value and override default
+  // path.
+  namespace path = llvm::sys::path;
+  llvm::Optional CompileCommandsDirPath;
+
+  if (CompileCommandsDir.empty())
+CompileCommandsDirPath = llvm::None;
+  else if (!llvm::sys::path::is_absolute(CompileCommandsDir)) {
+llvm::errs()
+<< "Path specified by --compile-commands-dir must be an absolute "
+   "path. The argument will be ignored.\n";
+CompileCommandsDirPath = llvm::None;
+  } else if (!llvm::sys::fs::exists(CompileCommandsDir)) {
+llvm::errs() << "Path specified by --compile-commands-dir does not exist. "
+"The argument will be "
+"ignored.\n";
+CompileCommandsDirPath = llvm::None;
+  } else
+CompileCommandsDirPath = CompileCommandsDir;
 
   llvm::Optional ResourceDirRef = None;
   if (!ResourceDir.empty())
 ResourceDirRef = ResourceDir;
 
+  /// Change stdin to binary to not lose \r\n on windows.
+  llvm::sys::ChangeStdinToBinary();
+
+  /// Initialize and run ClangdLSPServer.
   ClangdLSPServer LSPServer(Out, WorkerThreadsCount, EnableSnippets,
-ResourceDirRef);
+ResourceDirRef, CompileCommandsDirPath);
   LSPServer.run(std::cin);
 }
Index: clangd/GlobalCompilationDatabase.h
===
--- clangd/GlobalCompilationDatabase.h
+++ clangd/GlobalCompilationDatabase.h
@@ -47,15 +47,17 @@
 class DirectoryBasedGlobalCompilationDatabase
 : public GlobalCompilationDatabase {
 public:
-  DirectoryBasedGlobalCompilationDatabase(clangd::Logger );
+  DirectoryBasedGlobalCompilationDatabase(
+  clangd::Logger , llvm::Optional NewCompileCommandsDir);
 
   std::vector
   getCompileCommands(PathRef File) override;
 
   void setExtraFlagsForFile(PathRef File, std::vector ExtraFlags);
 
 private:
   tooling::CompilationDatabase *getCompilationDatabase(PathRef File);
+  tooling::CompilationDatabase *tryLoadDatabaseFromPath(PathRef File);
 
   std::mutex Mutex;
   /// Caches compilation databases loaded from directories(keys are
@@ -67,6 +69,9 @@
   llvm::StringMap ExtraFlagsForFile;
   /// Used for logging.
   clangd::Logger 
+  /// Used for command argument pointing to folder where compile_commands.json
+  /// is located.
+  llvm::Optional CompileCommandsDir;
 };
 } // namespace clangd
 } // namespace clang
Index: clangd/GlobalCompilationDatabase.cpp
===
--- clangd/GlobalCompilationDatabase.cpp
+++ clangd/GlobalCompilationDatabase.cpp
@@ -38,8 +38,9 @@
 }
 
 DirectoryBasedGlobalCompilationDatabase::
-DirectoryBasedGlobalCompilationDatabase(clangd::Logger )
-: Logger(Logger) {}
+DirectoryBasedGlobalCompilationDatabase(
+clangd::Logger , llvm::Optional NewCompileCommandsDir)
+: Logger(Logger), CompileCommandsDir(NewCompileCommandsDir) {}
 
 std::vector
 DirectoryBasedGlobalCompilationDatabase::getCompileCommands(PathRef File) {
@@ -67,34 +68,48 @@
 }
 
 tooling::CompilationDatabase *
-DirectoryBasedGlobalCompilationDatabase::getCompilationDatabase(PathRef File) {
-  std::lock_guard Lock(Mutex);
+DirectoryBasedGlobalCompilationDatabase::tryLoadDatabaseFromPath(PathRef File) {
 
   namespace path = llvm::sys::path;
+  auto CachedIt = 

[PATCH] D37804: [OpenCL] Handle address space conversion while setting type alignment

2017-09-25 Thread Alexey Bader via Phabricator via cfe-commits
bader accepted this revision.
bader added a comment.

LGTM. Thanks!


https://reviews.llvm.org/D37804



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


[clang-tools-extra] r314107 - Fix clangd when built with LLVM_LINK_LLVM_DYLIB=ON

2017-09-25 Thread Sylvestre Ledru via cfe-commits
Author: sylvestre
Date: Mon Sep 25 07:08:35 2017
New Revision: 314107

URL: http://llvm.org/viewvc/llvm-project?rev=314107=rev
Log:
Fix clangd when built with LLVM_LINK_LLVM_DYLIB=ON

Reviewers: malaperle, malaperle-ericsson, bkramer

Reviewed By: bkramer

Subscribers: bkramer, mgorny, ilya-biryukov, cfe-commits

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

Modified:
clang-tools-extra/trunk/clangd/tool/CMakeLists.txt

Modified: clang-tools-extra/trunk/clangd/tool/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/tool/CMakeLists.txt?rev=314107=314106=314107=diff
==
--- clang-tools-extra/trunk/clangd/tool/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clangd/tool/CMakeLists.txt Mon Sep 25 07:08:35 2017
@@ -6,6 +6,10 @@ add_clang_tool(clangd
 
 install(TARGETS clangd RUNTIME DESTINATION bin)
 
+set(LLVM_LINK_COMPONENTS
+  support
+  )
+
 target_link_libraries(clangd
   clangBasic
   clangDaemon
@@ -14,5 +18,4 @@ target_link_libraries(clangd
   clangSema
   clangTooling
   clangToolingCore
-  LLVMSupport
   )


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


[PATCH] D37804: [OpenCL] Handle address space conversion while setting type alignment

2017-09-25 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia updated this revision to Diff 116548.
Anastasia added a comment.

Addressed comments from Alexey.


https://reviews.llvm.org/D37804

Files:
  lib/CodeGen/CGBuilder.h
  lib/CodeGen/CGExpr.cpp
  test/CodeGenOpenCL/vectorLoadStore.cl


Index: test/CodeGenOpenCL/vectorLoadStore.cl
===
--- test/CodeGenOpenCL/vectorLoadStore.cl
+++ test/CodeGenOpenCL/vectorLoadStore.cl
@@ -1,9 +1,22 @@
-// RUN: %clang_cc1 %s -emit-llvm -O0 -o - | FileCheck %s
+// RUN: %clang_cc1 -triple "spir-unknown-unknown" %s -emit-llvm -O0 -o - | 
FileCheck %s
 
-typedef char char3 __attribute((ext_vector_type(3)));;
+typedef char char2 __attribute((ext_vector_type(2)));
+typedef char char3 __attribute((ext_vector_type(3)));
+typedef char char8 __attribute((ext_vector_type(8)));
+typedef float float4 __attribute((ext_vector_type(4)));
 
 // Check for optimized vec3 load/store which treats vec3 as vec4.
 void foo(char3 *P, char3 *Q) {
   *P = *Q;
   // CHECK: %{{.*}} = shufflevector <4 x i8> %{{.*}}, <4 x i8> undef, <3 x 
i32> 
 }
+
+// CHECK: define spir_func void @alignment()
+void alignment() {
+  __private char2 data_generic[100];
+  __private char8 data_private[100];
+
+  // CHECK: %{{.*}} = load <4 x float>, <4 x float> addrspace(4)* %{{.*}}, 
align 2
+  // CHECK: store <4 x float> %{{.*}}, <4 x float>* %{{.*}}, align 8
+  ((private float4 *)data_private)[1] = ((float4 *)data_generic)[2];
+}
Index: lib/CodeGen/CGExpr.cpp
===
--- lib/CodeGen/CGExpr.cpp
+++ lib/CodeGen/CGExpr.cpp
@@ -925,6 +925,7 @@
 // Non-converting casts (but not C's implicit conversion from void*).
 case CK_BitCast:
 case CK_NoOp:
+case CK_AddressSpaceConversion:
   if (auto PtrTy = CE->getSubExpr()->getType()->getAs()) {
 if (PtrTy->getPointeeType()->isVoidType())
   break;
@@ -953,8 +954,10 @@
   CodeGenFunction::CFITCK_UnrelatedCast,
   CE->getLocStart());
 }
-
-return Builder.CreateBitCast(Addr, ConvertType(E->getType()));
+return CE->getCastKind() != CK_AddressSpaceConversion
+   ? Builder.CreateBitCast(Addr, ConvertType(E->getType()))
+   : Builder.CreateAddrSpaceCast(Addr,
+ ConvertType(E->getType()));
   }
   break;
 
Index: lib/CodeGen/CGBuilder.h
===
--- lib/CodeGen/CGBuilder.h
+++ lib/CodeGen/CGBuilder.h
@@ -145,6 +145,13 @@
Addr.getAlignment());
   }
 
+  using CGBuilderBaseTy::CreateAddrSpaceCast;
+  Address CreateAddrSpaceCast(Address Addr, llvm::Type *Ty,
+  const llvm::Twine  = "") {
+return Address(CreateAddrSpaceCast(Addr.getPointer(), Ty, Name),
+   Addr.getAlignment());
+  }
+
   /// Cast the element type of the given address to a different type,
   /// preserving information like the alignment and address space.
   Address CreateElementBitCast(Address Addr, llvm::Type *Ty,


Index: test/CodeGenOpenCL/vectorLoadStore.cl
===
--- test/CodeGenOpenCL/vectorLoadStore.cl
+++ test/CodeGenOpenCL/vectorLoadStore.cl
@@ -1,9 +1,22 @@
-// RUN: %clang_cc1 %s -emit-llvm -O0 -o - | FileCheck %s
+// RUN: %clang_cc1 -triple "spir-unknown-unknown" %s -emit-llvm -O0 -o - | FileCheck %s
 
-typedef char char3 __attribute((ext_vector_type(3)));;
+typedef char char2 __attribute((ext_vector_type(2)));
+typedef char char3 __attribute((ext_vector_type(3)));
+typedef char char8 __attribute((ext_vector_type(8)));
+typedef float float4 __attribute((ext_vector_type(4)));
 
 // Check for optimized vec3 load/store which treats vec3 as vec4.
 void foo(char3 *P, char3 *Q) {
   *P = *Q;
   // CHECK: %{{.*}} = shufflevector <4 x i8> %{{.*}}, <4 x i8> undef, <3 x i32> 
 }
+
+// CHECK: define spir_func void @alignment()
+void alignment() {
+  __private char2 data_generic[100];
+  __private char8 data_private[100];
+
+  // CHECK: %{{.*}} = load <4 x float>, <4 x float> addrspace(4)* %{{.*}}, align 2
+  // CHECK: store <4 x float> %{{.*}}, <4 x float>* %{{.*}}, align 8
+  ((private float4 *)data_private)[1] = ((float4 *)data_generic)[2];
+}
Index: lib/CodeGen/CGExpr.cpp
===
--- lib/CodeGen/CGExpr.cpp
+++ lib/CodeGen/CGExpr.cpp
@@ -925,6 +925,7 @@
 // Non-converting casts (but not C's implicit conversion from void*).
 case CK_BitCast:
 case CK_NoOp:
+case CK_AddressSpaceConversion:
   if (auto PtrTy = CE->getSubExpr()->getType()->getAs()) {
 if (PtrTy->getPointeeType()->isVoidType())
   break;
@@ -953,8 +954,10 @@
   CodeGenFunction::CFITCK_UnrelatedCast,
   

[PATCH] D38228: Fix clangd when built with LLVM_LINK_LLVM_DYLIB=ON

2017-09-25 Thread Benjamin Kramer via Phabricator via cfe-commits
bkramer accepted this revision.
bkramer added a comment.
This revision is now accepted and ready to land.

lg


https://reviews.llvm.org/D38228



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


[PATCH] D38171: Implement clang-tidy check aliases.

2017-09-25 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

In https://reviews.llvm.org/D38171#880025, @xazax.hun wrote:

> In https://reviews.llvm.org/D38171#880022, @lebedev.ri wrote:
>
> > A mail [0] posted by @JonasToth is about the similar problem, i think we 
> > can continue there.
>
>
> Great! Could you summarize your points there as well? Thanks in advance.


Done. 

In https://reviews.llvm.org/D38171#880024, @alexfh wrote:

> In https://reviews.llvm.org/D38171#878814, @lebedev.ri wrote:
>
> > On a somewhat related  note, since this is already talking about aliases
> >
> > I feel like the current handling of the clang-tidy check aliases needs 
> > adjusting.
> >  If one enables all the checks (`Checks: '*'`), and then disables some of 
> > them
> >  on check-by-check basis,
>
>
> Clang-tidy allows doing so, but I doubt this is a use case we want to 
> encourage.
>  At least, not for a day-to-day use.


It's much like clang's `-Weverything`, which is rather convenient, and is
inconveniently 'missing 
' in gcc, because the 
devs believe that there would
be complains that it results in new warnings each release, 
which is kinda the point of that flag...

> Most checks require a certain amount of work on the target code and sometimes
>  fine tuning of the check options to be useful for any real codebase. Apart 
> from that,
>  there are checks that give duplicate warnings (some are aliases and some 
> just cover
>  intersecting set of issues), and there are checks that can give conflicting 
> advice.
>  These facts don't combine well with the "enable almost all checks" use case 
> and limit
>  its area of applicability to stress-testing clang-tidy and maybe to initial 
> evaluation of
>  clang-tidy checks on a certain codebase (though going from the other 
> direction and
>  determining the set of style rules for the codebase and then finding which 
> of those
>  are implemented in clang-tidy is a more fruitful approach).

Except the disagreeing checks, same could be said about `-Weverything`, 
clang-analyzer,
etc :)   Yes, of course it does not just work, and of course needs some further 
tuning,
and of course the codebase that is being checked needs to be fixed not to warn.

I.e. the use-case is to always have all the warnings enabled, and each time a 
new check
is triggered, analyze whether it should be kept enabled, or disable it.


https://reviews.llvm.org/D38171



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


r314104 - [Clang] Adding missing feature to goldmont

2017-09-25 Thread Michael Zuckerman via cfe-commits
Author: mzuckerm
Date: Mon Sep 25 06:49:32 2017
New Revision: 314104

URL: http://llvm.org/viewvc/llvm-project?rev=314104=rev
Log:
[Clang] Adding missing feature to goldmont

Change-Id: I6c22478d16b8e02ce60dae2f8c80d43bc5ab3a9c

Modified:
cfe/trunk/lib/Basic/Targets/X86.cpp
cfe/trunk/test/Preprocessor/predefined-arch-macros.c

Modified: cfe/trunk/lib/Basic/Targets/X86.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/X86.cpp?rev=314104=314103=314104=diff
==
--- cfe/trunk/lib/Basic/Targets/X86.cpp (original)
+++ cfe/trunk/lib/Basic/Targets/X86.cpp Mon Sep 25 06:49:32 2017
@@ -215,6 +215,7 @@ bool X86TargetInfo::initFeatureMap(
 setFeatureEnabledImpl(Features, "xsaves", true);
 setFeatureEnabledImpl(Features, "clflushopt", true);
 setFeatureEnabledImpl(Features, "mpx", true);
+setFeatureEnabledImpl(Features, "fsgsbase", true);
 LLVM_FALLTHROUGH;
   case CK_Silvermont:
 setFeatureEnabledImpl(Features, "aes", true);

Modified: cfe/trunk/test/Preprocessor/predefined-arch-macros.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/predefined-arch-macros.c?rev=314104=314103=314104=diff
==
--- cfe/trunk/test/Preprocessor/predefined-arch-macros.c (original)
+++ cfe/trunk/test/Preprocessor/predefined-arch-macros.c Mon Sep 25 06:49:32 
2017
@@ -991,6 +991,7 @@
 // RUN:   | FileCheck %s -check-prefix=CHECK_GLM_M32
 // CHECK_GLM_M32: #define __AES__ 1
 // CHECK_GLM_M32: #define __CLFLUSHOPT__ 1
+// CHECK_GLM_M32: #define __FSGSBASE__ 1
 // CHECK_GLM_M32: #define __FXSR__ 1
 // CHECK_GLM_M32: #define __MMX__ 1
 // CHECK_GLM_M32: #define __MPX__ 1
@@ -1030,6 +1031,7 @@
 // RUN:   | FileCheck %s -check-prefix=CHECK_GLM_M64
 // CHECK_GLM_M64: #define __AES__ 1
 // CHECK_GLM_M64: #define __CLFLUSHOPT__ 1
+// CHECK_GLM_M64: #define __FSGSBASE__ 1
 // CHECK_GLM_M64: #define __FXSR__ 1
 // CHECK_GLM_M64: #define __MMX__ 1
 // CHECK_GLM_M64: #define __MPX__ 1


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


[PATCH] D38231: fixing a bug in mask[z]_set1

2017-09-25 Thread jina via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL314102: fixing a bug in mask[z]_set1 intrinsic (authored by 
jina.nahias).

Changed prior to commit:
  https://reviews.llvm.org/D38231?vs=116513=116545#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D38231

Files:
  cfe/trunk/lib/Headers/avx512vlintrin.h
  cfe/trunk/test/CodeGen/avx512vl-builtins.c


Index: cfe/trunk/lib/Headers/avx512vlintrin.h
===
--- cfe/trunk/lib/Headers/avx512vlintrin.h
+++ cfe/trunk/lib/Headers/avx512vlintrin.h
@@ -5761,15 +5761,15 @@
 _mm_mask_set1_epi64 (__m128i __O, __mmask8 __M, long long __A)
 {
   return (__m128i) __builtin_ia32_selectq_128(__M,
-  (__v2di) _mm_set1_epi8(__A),
+  (__v2di) _mm_set1_epi64x(__A),
   (__v2di) __O);
 }
 
 static __inline__ __m128i __DEFAULT_FN_ATTRS
 _mm_maskz_set1_epi64 (__mmask8 __M, long long __A)
 {
   return (__m128i) __builtin_ia32_selectq_128(__M,
-  (__v2di) _mm_set1_epi8(__A),
+  (__v2di) _mm_set1_epi64x(__A),
   (__v2di) _mm_setzero_si128());
 }
 
Index: cfe/trunk/test/CodeGen/avx512vl-builtins.c
===
--- cfe/trunk/test/CodeGen/avx512vl-builtins.c
+++ cfe/trunk/test/CodeGen/avx512vl-builtins.c
@@ -4563,45 +4563,17 @@
 #ifdef __x86_64__
 __m128i test_mm_mask_set1_epi64(__m128i __O, __mmask8 __M, long long __A) {
   // CHECK-LABEL: @test_mm_mask_set1_epi64
-  // CHECK: insertelement <16 x i8> undef, i8 %{{.*}}, i32 0
-  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 1
-  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 2
-  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 3
-  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 4
-  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 5
-  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 6
-  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 7
-  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 8
-  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 9
-  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 10
-  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 11
-  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 12
-  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 13
-  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 14
-  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 15
+  // CHECK: insertelement <2 x i64> undef, i64 %{{.*}}, i32 0
+  // CHECK: insertelement <2 x i64> %{{.*}}, i64 %{{.*}}, i32 1
   // CHECK: shufflevector <8 x i1> %{{.*}}, <8 x i1> %{{.*}}, <2 x i32> 
   // CHECK: select <2 x i1> %{{.*}}, <2 x i64> %{{.*}}, <2 x i64> %{{.*}}
   return _mm_mask_set1_epi64(__O, __M, __A); 
 }
 
 __m128i test_mm_maskz_set1_epi64(__mmask8 __M, long long __A) {
   // CHECK-LABEL: @test_mm_maskz_set1_epi64
-  // CHECK: insertelement <16 x i8> undef, i8 %{{.*}}, i32 0
-  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 1
-  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 2
-  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 3
-  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 4
-  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 5
-  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 6
-  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 7
-  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 8
-  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 9
-  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 10
-  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 11
-  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 12
-  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 13
-  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 14
-  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 15
+  // CHECK: insertelement <2 x i64> undef, i64 %{{.*}}, i32 0
+  // CHECK: insertelement <2 x i64> %{{.*}}, i64 %{{.*}}, i32 1
   // CHECK: shufflevector <8 x i1> %{{.*}}, <8 x i1> %{{.*}}, <2 x i32> 
   // CHECK: select <2 x i1> %{{.*}}, <2 x i64> %{{.*}}, <2 x i64> %{{.*}}
   return _mm_maskz_set1_epi64(__M, __A); 


Index: cfe/trunk/lib/Headers/avx512vlintrin.h
===
--- cfe/trunk/lib/Headers/avx512vlintrin.h
+++ cfe/trunk/lib/Headers/avx512vlintrin.h
@@ -5761,15 +5761,15 @@
 _mm_mask_set1_epi64 (__m128i __O, __mmask8 __M, long long __A)
 {
   return (__m128i) __builtin_ia32_selectq_128(__M,
-  (__v2di) _mm_set1_epi8(__A),
+   

r314102 - fixing a bug in mask[z]_set1 intrinsic

2017-09-25 Thread Jina Nahias via cfe-commits
Author: jina.nahias
Date: Mon Sep 25 06:38:08 2017
New Revision: 314102

URL: http://llvm.org/viewvc/llvm-project?rev=314102=rev
Log:
fixing a bug in mask[z]_set1 intrinsic

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

Change-Id: I80bbff9cbe93e4be54d8a761ef9723edf3f57c57

Modified:
cfe/trunk/lib/Headers/avx512vlintrin.h
cfe/trunk/test/CodeGen/avx512vl-builtins.c

Modified: cfe/trunk/lib/Headers/avx512vlintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512vlintrin.h?rev=314102=314101=314102=diff
==
--- cfe/trunk/lib/Headers/avx512vlintrin.h (original)
+++ cfe/trunk/lib/Headers/avx512vlintrin.h Mon Sep 25 06:38:08 2017
@@ -5761,7 +5761,7 @@ static __inline__ __m128i __DEFAULT_FN_A
 _mm_mask_set1_epi64 (__m128i __O, __mmask8 __M, long long __A)
 {
   return (__m128i) __builtin_ia32_selectq_128(__M,
-  (__v2di) _mm_set1_epi8(__A),
+  (__v2di) _mm_set1_epi64x(__A),
   (__v2di) __O);
 }
 
@@ -5769,7 +5769,7 @@ static __inline__ __m128i __DEFAULT_FN_A
 _mm_maskz_set1_epi64 (__mmask8 __M, long long __A)
 {
   return (__m128i) __builtin_ia32_selectq_128(__M,
-  (__v2di) _mm_set1_epi8(__A),
+  (__v2di) _mm_set1_epi64x(__A),
   (__v2di) _mm_setzero_si128());
 }
 

Modified: cfe/trunk/test/CodeGen/avx512vl-builtins.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/avx512vl-builtins.c?rev=314102=314101=314102=diff
==
--- cfe/trunk/test/CodeGen/avx512vl-builtins.c (original)
+++ cfe/trunk/test/CodeGen/avx512vl-builtins.c Mon Sep 25 06:38:08 2017
@@ -4563,22 +4563,8 @@ __m256i test_mm256_maskz_set1_epi32(__mm
 #ifdef __x86_64__
 __m128i test_mm_mask_set1_epi64(__m128i __O, __mmask8 __M, long long __A) {
   // CHECK-LABEL: @test_mm_mask_set1_epi64
-  // CHECK: insertelement <16 x i8> undef, i8 %{{.*}}, i32 0
-  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 1
-  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 2
-  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 3
-  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 4
-  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 5
-  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 6
-  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 7
-  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 8
-  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 9
-  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 10
-  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 11
-  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 12
-  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 13
-  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 14
-  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 15
+  // CHECK: insertelement <2 x i64> undef, i64 %{{.*}}, i32 0
+  // CHECK: insertelement <2 x i64> %{{.*}}, i64 %{{.*}}, i32 1
   // CHECK: shufflevector <8 x i1> %{{.*}}, <8 x i1> %{{.*}}, <2 x i32> 
   // CHECK: select <2 x i1> %{{.*}}, <2 x i64> %{{.*}}, <2 x i64> %{{.*}}
   return _mm_mask_set1_epi64(__O, __M, __A); 
@@ -4586,22 +4572,8 @@ __m128i test_mm_mask_set1_epi64(__m128i
 
 __m128i test_mm_maskz_set1_epi64(__mmask8 __M, long long __A) {
   // CHECK-LABEL: @test_mm_maskz_set1_epi64
-  // CHECK: insertelement <16 x i8> undef, i8 %{{.*}}, i32 0
-  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 1
-  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 2
-  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 3
-  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 4
-  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 5
-  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 6
-  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 7
-  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 8
-  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 9
-  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 10
-  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 11
-  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 12
-  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 13
-  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 14
-  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 15
+  // CHECK: insertelement <2 x i64> undef, i64 %{{.*}}, i32 0
+  // CHECK: insertelement <2 x i64> %{{.*}}, i64 %{{.*}}, i32 1
   // CHECK: shufflevector <8 x i1> %{{.*}}, <8 x i1> %{{.*}}, <2 x i32> 
   // CHECK: select <2 x i1> %{{.*}}, <2 x i64> %{{.*}}, <2 x i64> %{{.*}}
   return 

[PATCH] D36150: [clangd] LSP extension to switch between source/header file

2017-09-25 Thread William Enright via Phabricator via cfe-commits
Nebiroth added a comment.

In https://reviews.llvm.org/D36150#879194, @ilya-biryukov wrote:

> Looks good.
>  Do you want me to submit this patch for you?


Yes please.


https://reviews.llvm.org/D36150



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


[PATCH] D37023: [analyzer] Fix bugreporter::getDerefExpr() again.

2017-09-25 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ updated this revision to Diff 116542.
NoQ added a comment.

@dcoughlin: You're right, my reasoning and understanding was not correct, and 
your explanation is much more clear. My code still makes sense to me though, so 
i updated the comments to match. And moved the unusual logic for the 
lvalue-to-rvalue cast unwrap to the bottom of the function.

Essentially, `getDerefExpr()` tries its best to explain where the null pointer 
comes from, on the syntactic level, by unpacking expressions that wrap the 
expression from which the pointer "originates", where "originates" is 
understood in a vague manner defined only by what the callers of this utility 
function expect to see. This leaves us with a few kinds of expressions that we 
need to unwrap, and we shouldn't touch other expressions, leaving 
pattern-matching over them to the caller.

There are other facilities that work on non-syntactic level, like your example 
where we might jump from function expression to return statement within the 
callee if the callee was inlined, or how `getNilReceiver()` function unwraps 
`ObjCMessageExpr` to the `self` pointer *iff* it `self` was `nil` during 
symbolic execution (which implies that the whole message expression is `nil`).

So that's right - lvalue-to-rvalue casts are not "the whole point", but merely 
an example of an expression kind that we do not have a right to unwrap. In 
fact, the callers still expect us to unwrap it once, but immediately stop 
afterwards. This inconsistency should probably be fixed, but `getDerefExpr` is 
used by checkers, and current code in checkers seems clean and concise enough.

I had a look at other cast kinds in `OperationKinds.def`, and all of them 
seemed as if they're worth unwrapping, apart from, of course, 
`CK_LValueToRValue`.

@xazax.hun: So, i guess, if the cast is earlier than we'd expect, then we'd 
just fail to unwrap something. So we won't find where the pointer comes from, 
and give up prematurely on our pattern-matching, while looking at roughly the 
same expression/value, plus-minus offsets. It sounds better than the case when 
the cast is //later// than we'd expect, where we may accidentally unwrap wrong 
stuff and start tracking a completely unrelated value, so i hope it shouldn't 
be a problem. Thanks for sharing the concern - the AST is huge and very few 
people possess really deep understanding of it, so any curious findings about 
it are really nice to share.


https://reviews.llvm.org/D37023

Files:
  lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
  test/Analysis/null-deref-path-notes.m

Index: test/Analysis/null-deref-path-notes.m
===
--- test/Analysis/null-deref-path-notes.m
+++ test/Analysis/null-deref-path-notes.m
@@ -50,6 +50,23 @@
   *p = 1; // expected-warning{{Dereference of null pointer}} expected-note{{Dereference of null pointer}}
 }
 
+@interface WithArrayPtr
+- (void) useArray;
+@end
+
+@implementation WithArrayPtr {
+@public int *p;
+}
+- (void)useArray {
+  p[1] = 2; // expected-warning{{Array access (via ivar 'p') results in a null pointer dereference}}
+// expected-note@-1{{Array access (via ivar 'p') results in a null pointer dereference}}
+}
+@end
+
+void testWithArrayPtr(WithArrayPtr *w) {
+  w->p = 0; // expected-note{{Null pointer value stored to 'p'}}
+  [w useArray]; // expected-note{{Calling 'useArray'}}
+}
 
 // CHECK:  diagnostics
 // CHECK-NEXT:  
@@ -801,4 +818,227 @@
 // CHECK-NEXT:file0
 // CHECK-NEXT:   
 // CHECK-NEXT:   
+// CHECK-NEXT:   
+// CHECK-NEXT:path
+// CHECK-NEXT:
+// CHECK-NEXT: 
+// CHECK-NEXT:  kindevent
+// CHECK-NEXT:  location
+// CHECK-NEXT:  
+// CHECK-NEXT:   line67
+// CHECK-NEXT:   col3
+// CHECK-NEXT:   file0
+// CHECK-NEXT:  
+// CHECK-NEXT:  ranges
+// CHECK-NEXT:  
+// CHECK-NEXT:
+// CHECK-NEXT: 
+// CHECK-NEXT:  line67
+// CHECK-NEXT:  col3
+// CHECK-NEXT:  file0
+// CHECK-NEXT: 
+// CHECK-NEXT: 
+// CHECK-NEXT:  line67
+// CHECK-NEXT:  col10
+// CHECK-NEXT:  file0
+// CHECK-NEXT: 
+// CHECK-NEXT:
+// CHECK-NEXT:  
+// CHECK-NEXT:  depth0
+// CHECK-NEXT:  extended_message
+// CHECK-NEXT:  Null pointer value stored to p
+// CHECK-NEXT:  message
+// CHECK-NEXT:  Null pointer value stored to p
+// CHECK-NEXT: 
+// CHECK-NEXT: 
+// CHECK-NEXT:  kindcontrol
+// CHECK-NEXT:  edges
+// CHECK-NEXT:   
+// CHECK-NEXT:
+// CHECK-NEXT: start
+// CHECK-NEXT:  
+// CHECK-NEXT:   
+// CHECK-NEXT:line67
+// CHECK-NEXT:col3
+// CHECK-NEXT:file0
+// CHECK-NEXT:   
+// CHECK-NEXT:   
+// CHECK-NEXT:line67
+// CHECK-NEXT:col3
+// CHECK-NEXT:file0
+// CHECK-NEXT:   
+// CHECK-NEXT:  
+// CHECK-NEXT: end
+// 

[PATCH] D38171: Implement clang-tidy check aliases.

2017-09-25 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added a comment.

In https://reviews.llvm.org/D38171#880022, @lebedev.ri wrote:

> A mail [0] posted by @JonasToth is about the similar problem, i think we can 
> continue there.


Great! Could you summarize your points there as well? Thanks in advance.


https://reviews.llvm.org/D38171



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


[PATCH] D38171: Implement clang-tidy check aliases.

2017-09-25 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment.

In https://reviews.llvm.org/D38171#878814, @lebedev.ri wrote:

> On a somewhat related  note, since this is already talking about aliases
>
> I feel like the current handling of the clang-tidy check aliases needs 
> adjusting.
>  If one enables all the checks (`Checks: '*'`), and then disables some of them
>  on check-by-check basis,


Clang-tidy allows doing so, but I doubt this is a use case we want to 
encourage. At least, not for a day-to-day use. Most checks require a certain 
amount of work on the target code and sometimes fine tuning of the check 
options to be useful for any real codebase. Apart from that, there are checks 
that give duplicate warnings (some are aliases and some just cover intersecting 
set of issues), and there are checks that can give conflicting advice. These 
facts don't combine well with the "enable almost all checks" use case and limit 
its area of applicability to stress-testing clang-tidy and maybe to initial 
evaluation of clang-tidy checks on a certain codebase (though going from the 
other direction and determining the set of style rules for the codebase and 
then finding which of those are implemented in clang-tidy is a more fruitful 
approach).

> if the disabled check has aliases
>  (`cppcoreguidelines-pro-type-vararg` vs `hicpp-vararg`, 
> `hicpp-no-array-decay`
>  vs `cppcoreguidelines-pro-bounds-array-to-pointer-decay` and so on)
>  each of the aliases must be explicitly be disabled too.

It seems to be the least confusing of possible options. Gabor made a good point 
why this is useful as it is.

> This is rather inconvenient.
> 
> If that is intentional, perhaps there could be a config option to either 
> disable
>  creation/registration of the check aliases altogether, or an option to threat
>  aliases as a hard link, so anything happening to any of the aliases/base 
> check
>  would happen to all of them.
> 
> (Also, if the check has parameters, and one specifies different parameters 
> for the base check, and the aliases, what happens?)




https://reviews.llvm.org/D38171



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


[PATCH] D38171: Implement clang-tidy check aliases.

2017-09-25 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

In https://reviews.llvm.org/D38171#880016, @xazax.hun wrote:

> In https://reviews.llvm.org/D38171#878814, @lebedev.ri wrote:
>
> > I feel like the current handling of the clang-tidy check aliases needs 
> > adjusting.
> >  If one enables all the checks (`Checks: '*'`), and then disables some of 
> > them
> >  on check-by-check basis, if the disabled check has aliases
> >  (`cppcoreguidelines-pro-type-vararg` vs `hicpp-vararg`, 
> > `hicpp-no-array-decay`
> >  vs `cppcoreguidelines-pro-bounds-array-to-pointer-decay` and so on)
> >  each of the aliases must be explicitly be disabled too.
>
>
> That is somewhat intentional I think. Lets imagined you are interested in 
> cppcoreguidelines but not interested in high integrity cpp. It would be great 
> to be able to use Checks: `'cppcoreguidelines*,-hicpp*'` without having to 
> worry about the aliases.
>
> In https://reviews.llvm.org/D38171#878814, @lebedev.ri wrote:
>
> > If that is intentional, perhaps there could be a config option to either 
> > disable
> >  creation/registration of the check aliases altogether, or an option to 
> > threat
> >  aliases as a hard link, so anything happening to any of the aliases/base 
> > check
> >  would happen to all of them.
>
>
> I think the source of the problems is that conceptually there are two 
> distinct reasons to disable a check. One reason when the user is not 
> interested in the results regardless what is the category or name of the 
> check. In this case, all aliases should be disabled. The second is when a 
> category of checks (e.g.: a guideline) is not applicable to the code. In this 
> case aliases should not be disabled. So I think a global option would not 
> solve this issue. A better solution might be a per glob notation. So `-` 
> could mean do not disable aliases and `--` could mean disable aliases as well 
> but that is just an example.
>
> All in all, I think this is not related strictly to this issue and I think we 
> should discuss this separately on the mailing list.
>
> In https://reviews.llvm.org/D38171#878814, @lebedev.ri wrote:
>
> > (Also, if the check has parameters, and one specifies different parameters 
> > for the base check, and the aliases, what happens?)
>
>
> I think this is a very good point, this needs to be documented somewhere.


A mail [0] posted by @JonasToth is about the similar problem, i think we can 
continue there.

I *think* he has a point, a some better way to setup aliases, without actually
creating aliased checks is the solution IMO. This way, there won't be any
need to disable all the aliases when completely disabling the checks, and
there won't be multiple config options for the each alias. The legacy support
is the question though.

[0] (https://lists.llvm.org/pipermail/cfe-dev/2017-September/055589.html)


https://reviews.llvm.org/D38171



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


[PATCH] D38171: Implement clang-tidy check aliases.

2017-09-25 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added a comment.

In https://reviews.llvm.org/D38171#878808, @alexfh wrote:

> András, that's definitely an interesting idea. However, it might be 
> interesting to explore a more principled approach:
>
> 1. Make `clang-diagnostic-*` checks first-class citizens and take full 
> control of all diagnostics, i.e. disable all Clang diagnostics by default, 
> and enable the ones that correspond to the enabled clang-diagnostic checks.


I agree that this is a good idea. I think it could be done in this patch. But 
to be sure, could you elaborate on what do you mean by first-class citizen?

> 2. Make aliases first-class citizens (there was a proposal as well, but we 
> didn't arrive to a consensus at that time). That would include the ability to 
> configure an alias name for any check including clang-diagnostic- and 
> clang-analyzer- checks.

Do you have a link to the proposal? What do you mean by the ability to 
configure? As in having a config file or registering aliases in modules like 
now? If you mean the former, I think that is better addressed in a follow-up 
patch.

> 3. Use aliases to map clang-diagnostic- checks to check names under cert-, 
> hicpp-, etc.
> 
>   I didn't carefully consider all possible implications and there may be 
> issues with any or all of the three parts of this, but I think it's worth 
> exploring.




https://reviews.llvm.org/D38171



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


[PATCH] D38209: [Sema] Correct nothrow inherited by noexcept

2017-09-25 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

I'm not certain we have the semantics of `__declspec(nothrow)` exactly correct 
-- a simple test shows that `__attribute__((nothrow))`, `__declspec(nothrow)`, 
and `noexcept(true)` are subtly different.

When I run this with MSVC 2017, the terminate handler is not called and the 
application continues rather than terminates, but Clang calls the terminate 
handler.

  #include 
  #include 
  
  __declspec(nothrow) void f() { throw 1; }
  
  int main() {
std::set_terminate([]() {
  std::cout << "terminate called" << std::endl;
  std::abort();
});
  
f();
  }

However, in this case terminate is called using GCC 6.3 and Clang.

  #include 
  #include 
   
  __attribute__((nothrow)) void f() { throw 1; }
   
  int main() {
std::set_terminate([]() {
  std::cout << "terminate called" << std::endl;
  std::abort();
});
   
f();
  }

For your test case: GCC accepts (with __attribute__), MSVC accepts (with 
__declspec), and EDG rejects `Derived() noexcept = default` because of 
incompatible exception specs. I think it's probably reasonable for us to accept 
despite the slight semantic differences.

@STL_MSFT -- do you think `__declspec(nothrow)` calling the terminate handler 
in Clang is a bug?




Comment at: lib/Sema/SemaDeclCXX.cpp:170
 
+  if (EST == EST_None && Method->hasAttr()) {
+EST = EST_BasicNoexcept;

Elide the braces.



Comment at: test/SemaCXX/nothrow-as-noexcept-ctor.cpp:3
+
+
+// expected-no-diagnostics

You can remove the spurious newline from the test.


https://reviews.llvm.org/D38209



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


[PATCH] D38171: Implement clang-tidy check aliases.

2017-09-25 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added a comment.

@leanil : Could you add a test case where the warnings are explicitly disabled 
in the compilation command and also one where only the aliased warning is 
explicitly disabled?

In https://reviews.llvm.org/D38171#878814, @lebedev.ri wrote:

> I feel like the current handling of the clang-tidy check aliases needs 
> adjusting.
>  If one enables all the checks (`Checks: '*'`), and then disables some of them
>  on check-by-check basis, if the disabled check has aliases
>  (`cppcoreguidelines-pro-type-vararg` vs `hicpp-vararg`, 
> `hicpp-no-array-decay`
>  vs `cppcoreguidelines-pro-bounds-array-to-pointer-decay` and so on)
>  each of the aliases must be explicitly be disabled too.


That is somewhat intentional I think. Lets imagined you are interested in 
cppcoreguidelines but not interested in high integrity cpp. It would be great 
to be able to use Checks: `'cppcoreguidelines*,-hicpp*'` without having to 
worry about the aliases.

In https://reviews.llvm.org/D38171#878814, @lebedev.ri wrote:

> If that is intentional, perhaps there could be a config option to either 
> disable
>  creation/registration of the check aliases altogether, or an option to threat
>  aliases as a hard link, so anything happening to any of the aliases/base 
> check
>  would happen to all of them.


I think the source of the problems is that conceptually there are two distinct 
reasons to disable a check. One reason when the user is not interested in the 
results regardless what is the category or name of the check. In this case, all 
aliases should be disabled. The second is when a category of checks (e.g.: a 
guideline) is not applicable to the code. In this case aliases should not be 
disabled. So I think a global option would not solve this issue. A better 
solution might be a per glob notation. So `-` could mean do not disable aliases 
and `--` could mean disable aliases as well but that is just an example.

All in all, I think this is not related strictly to this issue and I think we 
should discuss this separately on the mailing list.

In https://reviews.llvm.org/D38171#878814, @lebedev.ri wrote:

> (Also, if the check has parameters, and one specifies different parameters 
> for the base check, and the aliases, what happens?)


I think this is a very good point, this needs to be documented somewhere.


https://reviews.llvm.org/D38171



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


[PATCH] D38231: fixing a bug in mask[z]_set1

2017-09-25 Thread Igor Breger via Phabricator via cfe-commits
igorb accepted this revision.
igorb added a comment.
This revision is now accepted and ready to land.

LGTM


https://reviews.llvm.org/D38231



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


[PATCH] D38205: [Sema] Warn on attribute nothrow conflicting with language specifiers

2017-09-25 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: include/clang/Basic/DiagnosticSemaKinds.td:1411
+def warn_nothrow_attr_disagrees_with_exception_specification
+: ExtWarn<"Attribute nothrow ignored, it disagrees with language specified 
"
+  "exception specification">,

How about: `"attribute 'nothrow' ignored due to conflicting exception 
specification"`



Comment at: lib/Sema/SemaDeclAttr.cpp:1972
 
+static void handleNoThrowAttr(Sema , Decl *D, const AttributeList ) {
+  assert(isa(D) && "attribute nothrow only valid on functions");

`attr` doesn't meet the coding guidelines. I'd go with `AL`.



Comment at: test/SemaCXX/warn-conflicting-nothrow-attr-exception-spec.cpp:3
+
+struct S {
+  //expected-warning@+2 {{Attribute nothrow ignored, it disagrees with}}

You should add some tests that include templates and test it on Windows as well 
as non-Windows. I'm wondering about computed exception specifications during 
template instantiation. e.g.,
```
void throwing() noexcept(false);
void non_throwing() noexcept;

template 
struct T {
  __attribute__((nothrow)) void f(Fn) noexcept(Fn());
};

template struct T;
template struct T;
```


https://reviews.llvm.org/D38205



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


[PATCH] D33826: [clang-tidy] avoid pointer cast to more strict alignment check

2017-09-25 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

Nice!

  /home/eenitot/new_llvm/llvm/lib/Support/ConvertUTFWrapper.cpp:38:26: warning: 
do not cast pointers into more strictly aligned pointer types [cert-exp36-c]
  UTF16 *targetStart = reinterpret_cast(ResultPtr);
   ^

Hmm, the text is well-worded, but i wonder if a bit more context, much like the 
`-Wcast-align`, would be nicer, something like:

  warning: casting from type `T1` (alignment `a1`) to type `T2` (alignment 
`a2`) increases required alignment [cert-exp36-c]

It does mix the alignment of the type `T` and the alignment specified by 
`__attribute__((aligned()))` / `alignas()`, but i'm not sure it is possible to 
show that in the message..
Thoughts?


Repository:
  rL LLVM

https://reviews.llvm.org/D33826



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


[PATCH] D38203: [Sema] Corrected the warn-on-throw-from-noexcept behavior to include nothrow

2017-09-25 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

Aside from a minor testing nit, LGTM! Thanks!




Comment at: test/SemaCXX/warn-throw-out-noexcept-func.cpp:20
+  }
+  void __attribute__((nothrow)) SomeThrow() {// expected-note {{function 
declared non-throwing here}}
+   throw 1; // expected-warning {{has a non-throwing exception specification 
but}}

Can you also add a test for `__declspec(nothrow)`?


https://reviews.llvm.org/D38203



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


[PATCH] D38202: Add Documentation to attribute-nothrow. Additionally, limit to functions.

2017-09-25 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: include/clang/Basic/AttrDocs.td:2692
+  let Content = [{
+Clang supports the GNU style ``__attribute__((nothrow))`` attribute as an
+equivilent of `noexcept` on function declarations. This attribute informs the

Should probably add something about `__declspec(nothrow)` as well.

Are the semantics really identical to `noexcept`? For instance, does 
`std::terminate()` get called if a function is marked `__declspec(nothrow)` and 
it throws, or does it simply crash?



Comment at: include/clang/Basic/AttrDocs.td:2694
+equivilent of `noexcept` on function declarations. This attribute informs the
+compiler that the annotated function does cannot throw an exception. This
+prevents exception-unwinding. This attribute is particularly useful on 
functions

"does cannot"


https://reviews.llvm.org/D38202



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


[PATCH] D32520: Support __fp16 vectors

2017-09-25 Thread Akira Hatanaka via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL314056: Promote storage-only __fp16 vector operands to float 
vectors. (authored by ahatanak).

Changed prior to commit:
  https://reviews.llvm.org/D32520?vs=116275=116533#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D32520

Files:
  cfe/trunk/lib/CodeGen/CGExprScalar.cpp
  cfe/trunk/lib/Sema/SemaExpr.cpp
  cfe/trunk/test/CodeGen/fp16vec-ops.c
  cfe/trunk/test/Sema/fp16vec-sema.c

Index: cfe/trunk/lib/CodeGen/CGExprScalar.cpp
===
--- cfe/trunk/lib/CodeGen/CGExprScalar.cpp
+++ cfe/trunk/lib/CodeGen/CGExprScalar.cpp
@@ -1014,10 +1014,41 @@
 return Builder.CreateVectorSplat(NumElements, Src, "splat");
   }
 
-  // Allow bitcast from vector to integer/fp of the same size.
-  if (isa(SrcTy) ||
-  isa(DstTy))
-return Builder.CreateBitCast(Src, DstTy, "conv");
+  if (isa(SrcTy) || isa(DstTy)) {
+// Allow bitcast from vector to integer/fp of the same size.
+unsigned SrcSize = SrcTy->getPrimitiveSizeInBits();
+unsigned DstSize = DstTy->getPrimitiveSizeInBits();
+if (SrcSize == DstSize)
+  return Builder.CreateBitCast(Src, DstTy, "conv");
+
+// Conversions between vectors of different sizes are not allowed except
+// when vectors of half are involved. Operations on storage-only half
+// vectors require promoting half vector operands to float vectors and
+// truncating the result, which is either an int or float vector, to a
+// short or half vector.
+
+// Source and destination are both expected to be vectors.
+llvm::Type *SrcElementTy = SrcTy->getVectorElementType();
+llvm::Type *DstElementTy = DstTy->getVectorElementType();
+
+assert(((SrcElementTy->isIntegerTy() &&
+ DstElementTy->isIntegerTy()) ||
+(SrcElementTy->isFloatingPointTy() &&
+ DstElementTy->isFloatingPointTy())) &&
+   "unexpected conversion between a floating-point vector and an "
+   "integer vector");
+
+// Truncate an i32 vector to an i16 vector.
+if (SrcElementTy->isIntegerTy())
+  return Builder.CreateIntCast(Src, DstTy, false, "conv");
+
+// Truncate a float vector to a half vector.
+if (SrcSize > DstSize)
+  return Builder.CreateFPTrunc(Src, DstTy, "conv");
+
+// Promote a half vector to a float vector.
+return Builder.CreateFPExt(Src, DstTy, "conv");
+  }
 
   // Finally, we have the arithmetic types: real int/float.
   Value *Res = nullptr;
Index: cfe/trunk/lib/Sema/SemaExpr.cpp
===
--- cfe/trunk/lib/Sema/SemaExpr.cpp
+++ cfe/trunk/lib/Sema/SemaExpr.cpp
@@ -7503,6 +7503,14 @@
   return CheckAssignmentConstraints(LHSType, RHSPtr, K, /*ConvertRHS=*/false);
 }
 
+/// This helper function returns true if QT is a vector type that has element
+/// type ElementType.
+static bool isVector(QualType QT, QualType ElementType) {
+  if (const VectorType *VT = QT->getAs())
+return VT->getElementType() == ElementType;
+  return false;
+}
+
 /// CheckAssignmentConstraints (C99 6.5.16) - This routine currently
 /// has code to accommodate several GCC extensions when type checking
 /// pointers. Here are some objectionable examples that GCC considers warnings:
@@ -8131,6 +8139,25 @@
   return false;
 }
 
+/// Convert vector E to a vector with the same number of elements but different
+/// element type.
+static ExprResult convertVector(Expr *E, QualType ElementType, Sema ) {
+  const auto *VecTy = E->getType()->getAs();
+  assert(VecTy && "Expression E must be a vector");
+  QualType NewVecTy = S.Context.getVectorType(ElementType,
+  VecTy->getNumElements(),
+  VecTy->getVectorKind());
+
+  // Look through the implicit cast. Return the subexpression if its type is
+  // NewVecTy.
+  if (auto *ICE = dyn_cast(E))
+if (ICE->getSubExpr()->getType() == NewVecTy)
+  return ICE->getSubExpr();
+
+  auto Cast = ElementType->isIntegerType() ? CK_IntegralCast : CK_FloatingCast;
+  return S.ImpCastExprToType(E, NewVecTy, Cast);
+}
+
 /// Test if a (constant) integer Int can be casted to another integer type
 /// IntTy without losing precision.
 static bool canConvertIntToOtherIntTy(Sema , ExprResult *Int,
@@ -11465,6 +11492,41 @@
   return nullptr;
 }
 
+// This helper function promotes a binary operator's operands (which are of a
+// half vector type) to a vector of floats and then truncates the result to
+// a vector of either half or short.
+static ExprResult convertHalfVecBinOp(Sema , ExprResult LHS, ExprResult RHS,
+  BinaryOperatorKind Opc, QualType ResultTy,
+  ExprValueKind VK, ExprObjectKind OK,
+  bool IsCompAssign, SourceLocation OpLoc,
+  

[PATCH] D38214: [analyzer] Fix crash on modeling of pointer arithmetic

2017-09-25 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment.

Thanks for the fix!


Repository:
  rL LLVM

https://reviews.llvm.org/D38214



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


[PATCH] D36737: [analyzer] Store design discussions in docs/analyzer for future use.

2017-09-25 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ updated this revision to Diff 116520.
NoQ added a comment.

Update to use `.rst` formatting.


https://reviews.llvm.org/D36737

Files:
  docs/analyzer/DesignDiscussions/InitializerLists.rst

Index: docs/analyzer/DesignDiscussions/InitializerLists.rst
===
--- /dev/null
+++ docs/analyzer/DesignDiscussions/InitializerLists.rst
@@ -0,0 +1,321 @@
+This discussion took place in https://reviews.llvm.org/D35216
+"Escape symbols when creating std::initializer_list".
+
+It touches problems of modelling C++ standard library constructs in general,
+including modelling implementation-defined fields within C++ standard library
+objects, in particular constructing objects into pointers held by such fields,
+and separation of responsibilities between analyzer's core and checkers.
+
+**Artem:**
+
+I've seen a few false positives that appear because we construct
+C++11 std::initializer_list objects with brace initializers, and such
+construction is not properly modeled. For instance, if a new object is
+constructed on the heap only to be put into a brace-initialized STL container,
+the object is reported to be leaked.
+
+Approach (0): This can be trivially fixed by this patch, which causes pointers
+passed into initializer list expressions to immediately escape.
+
+This fix is overly conservative though. So i did a bit of investigation as to
+how model std::initializer_list better.
+
+According to the standard, std::initializer_list is an object that has
+methods begin(), end(), and size(), where begin() returns a pointer to continous
+array of size() objects of type T, and end() is equal to begin() plus size().
+The standard does hint that it should be possible to implement
+std::initializer_list as a pair of pointers, or as a pointer and a size
+integer, however specific fields that the object would contain are an
+implementation detail.
+
+Ideally, we should be able to model the initializer list's methods precisely.
+Or, at least, it should be possible to explain to the analyzer that the list
+somehow "takes hold" of the values put into it. Initializer lists can also be
+copied, which is a separate story that i'm not trying to address here.
+
+The obvious approach to modeling std::initializer_list in a checker would be to
+construct a SymbolMetadata for the memory region of the initializer list object,
+which would be of type T* and represent begin(), so we'd trivially model begin()
+as a function that returns this symbol. The array pointed to by that symbol
+would be bindLoc()ed to contain the list's contents (probably as a CompoundVal
+to produce less bindings in the store). Extent of this array would represent
+size() and would be equal to the length of the list as written.
+
+So this sounds good, however apparently it does nothing to address our false
+positives: when the list escapes, our RegionStoreManager is not magically
+guessing that the metadata symbol attached to it, together with its contents,
+should also escape. In fact, it's impossible to trigger a pointer escape from
+within the checker.
+
+Approach (1): If only we enabled ProgramState::bindLoc(..., notifyChanges=true)
+to cause pointer escapes (not only region changes) (which sounds like the right
+thing to do anyway) such checker would be able to solve the false positives by
+triggering escapes when binding list elements to the list. However, it'd be as
+conservative as the current patch's solution. Ideally, we do not want escapes to
+happen so early. Instead, we'd prefer them to be delayed until the list itself
+escapes.
+
+So i believe that escaping metadata symbols whenever their base regions escape
+would be the right thing to do. Currently we didn't think about that because we
+had neither pointer-type metadatas nor non-pointer escapes.
+
+Approach (2): We could teach the Store to scan itself for bindings to
+metadata-symbolic-based regions during scanReachableSymbols() whenever a region
+turns out to be reachable. This requires no work on checker side, but it sounds
+performance-heavy.
+
+Approach (3): We could let checkers maintain the set of active metadata symbols
+in the program state (ideally somewhere in the Store, which sounds weird but
+causes the smallest amount of layering violations), so that the core knew what
+to escape. This puts a stress on the checkers, but with a smart data map it
+wouldn't be a problem.
+
+Approach (4): We could allow checkers to trigger pointer escapes in arbitrary
+moments. If we allow doing this within checkPointerEscape callback itself, we
+would be able to express facts like "when this region escapes, that metadata
+symbol attached to it should also escape". This sounds like an ultimate freedom,
+with maximum stress on the checkers - still not too much stress when we have
+smart data maps.
+
+I'm personally liking the approach (2) - it should be possible to avoid
+performance overhead, and clarity seems nice.
+
+**Gabor:**
+
+At this 

[PATCH] D38118: [CodeGen][ObjC] Build the global block structure before emitting the body of global block invoke functions

2017-09-25 Thread Akira Hatanaka via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL314029: [CodeGen][ObjC] Build the global block structure 
before emitting the (authored by ahatanak).

Changed prior to commit:
  https://reviews.llvm.org/D38118?vs=116135=116524#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D38118

Files:
  cfe/trunk/lib/CodeGen/CGBlocks.cpp
  cfe/trunk/lib/CodeGen/CodeGenFunction.h
  cfe/trunk/test/CodeGen/mangle-blocks.c
  cfe/trunk/test/CodeGenObjC/local-static-block.m
  cfe/trunk/test/CodeGenObjC/mangle-blocks.m

Index: cfe/trunk/test/CodeGen/mangle-blocks.c
===
--- cfe/trunk/test/CodeGen/mangle-blocks.c
+++ cfe/trunk/test/CodeGen/mangle-blocks.c
@@ -12,12 +12,12 @@
 }
 
 // CHECK: @__func__.__mangle_block_invoke_2 = private unnamed_addr constant [22 x i8] c"mangle_block_invoke_2\00", align 1
-// CHECK: @.str = private unnamed_addr constant {{.*}}, align 1
-// CHECK: @.str.1 = private unnamed_addr constant [7 x i8] c"mangle\00", align 1
+// CHECK: @.str{{.*}} = private unnamed_addr constant {{.*}}, align 1
+// CHECK: @.str[[STR1:.*]] = private unnamed_addr constant [7 x i8] c"mangle\00", align 1
 
 // CHECK: define internal void @__mangle_block_invoke(i8* %.block_descriptor)
 
 // CHECK: define internal void @__mangle_block_invoke_2(i8* %.block_descriptor){{.*}}{
-// CHECK:   call void @__assert_rtn(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @__func__.__mangle_block_invoke_2, i32 0, i32 0), i8* getelementptr inbounds {{.*}}, i32 9, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i32 0, i32 0))
+// CHECK:   call void @__assert_rtn(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @__func__.__mangle_block_invoke_2, i32 0, i32 0), i8* getelementptr inbounds {{.*}}, i32 9, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str[[STR1]], i32 0, i32 0))
 // CHECK: }
 
Index: cfe/trunk/test/CodeGenObjC/mangle-blocks.m
===
--- cfe/trunk/test/CodeGenObjC/mangle-blocks.m
+++ cfe/trunk/test/CodeGenObjC/mangle-blocks.m
@@ -18,11 +18,11 @@
 @end
 
 // CHECK: @"__func__.__14-[Test mangle]_block_invoke_2" = private unnamed_addr constant [30 x i8] c"-[Test mangle]_block_invoke_2\00", align 1
-// CHECK: @.str = private unnamed_addr constant {{.*}}, align 1
-// CHECK: @.str.1 = private unnamed_addr constant [7 x i8] c"mangle\00", align 1
+// CHECK: @.str{{.*}} = private unnamed_addr constant {{.*}}, align 1
+// CHECK: @.str[[STR1:.*]] = private unnamed_addr constant [7 x i8] c"mangle\00", align 1
 
 // CHECK: define internal void @"__14-[Test mangle]_block_invoke"(i8* %.block_descriptor)
 
 // CHECK: define internal void @"__14-[Test mangle]_block_invoke_2"(i8* %.block_descriptor){{.*}}{
-// CHECK: call void @__assert_rtn(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @"__func__.__14-[Test mangle]_block_invoke_2", i32 0, i32 0), i8* getelementptr inbounds {{.*}}, i32 14, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i32 0, i32 0))
+// CHECK: call void @__assert_rtn(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @"__func__.__14-[Test mangle]_block_invoke_2", i32 0, i32 0), i8* getelementptr inbounds {{.*}}, i32 14, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str[[STR1]], i32 0, i32 0))
 // CHECK: }
Index: cfe/trunk/test/CodeGenObjC/local-static-block.m
===
--- cfe/trunk/test/CodeGenObjC/local-static-block.m
+++ cfe/trunk/test/CodeGenObjC/local-static-block.m
@@ -46,6 +46,17 @@
  }
 }
 
+void FUNC2() {
+  static void (^const block1)(int) = ^(int a){
+if (a--)
+  block1(a);
+  };
+}
+
+// CHECK-LABEL-LP64: define void @FUNC2(
+// CHECK: define internal void @_block_invoke{{.*}}(
+// CHECK: call void %{{.*}}(i8* bitcast ({ i8**, i32, i32, i8*, %struct.__block_descriptor* }* @__block_literal_global{{.*}} to i8*), i32 %{{.*}})
+
 void FUNC1()
 {
  static  NSArray *(^ArrayRecurs)(NSArray *addresses, unsigned long level) = ^(NSArray *addresses, unsigned long level) {
Index: cfe/trunk/lib/CodeGen/CodeGenFunction.h
===
--- cfe/trunk/lib/CodeGen/CodeGenFunction.h
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.h
@@ -1586,7 +1586,8 @@
   llvm::Function *GenerateBlockFunction(GlobalDecl GD,
 const CGBlockInfo ,
 const DeclMapTy ,
-bool IsLambdaConversionToBlock);
+bool IsLambdaConversionToBlock,
+bool BuildGlobalBlock);
 
   llvm::Constant *GenerateCopyHelperFunction(const CGBlockInfo );
   llvm::Constant *GenerateDestroyHelperFunction(const CGBlockInfo );
Index: cfe/trunk/lib/CodeGen/CGBlocks.cpp
===
--- cfe/trunk/lib/CodeGen/CGBlocks.cpp
+++ 

[PATCH] D35216: [analyzer] Escape symbols when creating std::initializer_list.

2017-09-25 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ updated this revision to Diff 116512.
NoQ added a comment.

Fix some comments in tests.

Devin: ok to commit? I hope i didn't miss anything in my reasoning about boxed 
expressions.


https://reviews.llvm.org/D35216

Files:
  lib/StaticAnalyzer/Core/ExprEngine.cpp
  test/Analysis/initializer.cpp
  test/Analysis/objc-boxing.m

Index: test/Analysis/objc-boxing.m
===
--- test/Analysis/objc-boxing.m
+++ test/Analysis/objc-boxing.m
@@ -5,6 +5,16 @@
 typedef signed char BOOL;
 typedef long NSInteger;
 typedef unsigned long NSUInteger;
+
+@protocol NSObject
+@end
+@interface NSObject  {}
+@end
+@protocol NSCopying
+@end
+@protocol NSCoding
+@end
+
 @interface NSString @end
 @interface NSString (NSStringExtensionMethods)
 + (id)stringWithUTF8String:(const char *)nullTerminatedCString;
@@ -28,7 +38,15 @@
 + (NSNumber *)numberWithUnsignedInteger:(NSUInteger)value ;
 @end
 
+@interface NSValue : NSObject 
+- (void)getValue:(void *)value;
++ (NSValue *)valueWithBytes:(const void *)value
+   objCType:(const char *)type;
+@end
 
+typedef typeof(sizeof(int)) size_t;
+extern void *malloc(size_t);
+extern void free(void *);
 extern char *strdup(const char *str);
 
 id constant_string() {
@@ -39,6 +57,23 @@
 return @(strdup("boxed dynamic string")); // expected-warning{{Potential memory leak}}
 }
 
+typedef struct __attribute__((objc_boxable)) {
+  const char *str;
+} BoxableStruct;
+
+id leak_within_boxed_struct() {
+  BoxableStruct bs;
+  bs.str = strdup("dynamic string"); // The duped string shall be owned by val.
+  NSValue *val = @(bs); // no-warning
+  return val;
+}
+
+id leak_of_boxed_struct() {
+  BoxableStruct *bs = malloc(sizeof(BoxableStruct)); // The pointer stored in bs isn't owned by val.
+  NSValue *val = @(*bs); // expected-warning{{Potential leak of memory pointed to by 'bs'}}
+  return val;
+}
+
 id const_char_pointer(int *x) {
   if (x)
 return @(3);
Index: test/Analysis/initializer.cpp
===
--- test/Analysis/initializer.cpp
+++ test/Analysis/initializer.cpp
@@ -1,7 +1,9 @@
-// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix.Malloc,debug.ExprInspection -analyzer-config c++-inlining=constructors -std=c++11 -verify %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix.Malloc,cplusplus.NewDeleteLeaks,debug.ExprInspection -analyzer-config c++-inlining=constructors -std=c++11 -verify %s
 
 void clang_analyzer_eval(bool);
 
+#include "Inputs/system-header-simulator-cxx.h"
+
 class A {
   int x;
 public:
@@ -204,3 +206,13 @@
const char()[2];
 };
 }
+
+namespace CXX_initializer_lists {
+struct C {
+  C(std::initializer_list list);
+};
+void foo() {
+  int *x = new int;
+  C c{x}; // no-warning
+}
+}
Index: lib/StaticAnalyzer/Core/ExprEngine.cpp
===
--- lib/StaticAnalyzer/Core/ExprEngine.cpp
+++ lib/StaticAnalyzer/Core/ExprEngine.cpp
@@ -827,6 +827,21 @@
   }
 }
 
+namespace {
+class CollectReachableSymbolsCallback final : public SymbolVisitor {
+  InvalidatedSymbols Symbols;
+
+public:
+  explicit CollectReachableSymbolsCallback(ProgramStateRef State) {}
+  const InvalidatedSymbols () const { return Symbols; }
+
+  bool VisitSymbol(SymbolRef Sym) override {
+Symbols.insert(Sym);
+return true;
+  }
+};
+} // end anonymous namespace
+
 void ExprEngine::Visit(const Stmt *S, ExplodedNode *Pred,
ExplodedNodeSet ) {
   PrettyStackTraceLoc CrashInfo(getContext().getSourceManager(),
@@ -1103,8 +1118,33 @@
 SVal result = svalBuilder.conjureSymbolVal(nullptr, Ex, LCtx,
resultType,
currBldrCtx->blockCount());
-ProgramStateRef state = N->getState()->BindExpr(Ex, LCtx, result);
-Bldr2.generateNode(S, N, state);
+ProgramStateRef State = N->getState()->BindExpr(Ex, LCtx, result);
+
+// Escape pointers passed into the list.
+// TODO: Ideally we also need to escape the elements of
+// ObjCArrayLiterals and ObjCDictionaryLiterals, however these
+// only consist of ObjC objects, and escapes of ObjC objects
+// aren't so important (eg., retain count checker ignores them).
+if (isa(Ex) ||
+(isa(Ex) &&
+ cast(Ex)->getSubExpr()->getType()->isRecordType()))
+  for (auto Child : Ex->children()) {
+if (!Child)
+  continue;
+
+SVal Val = State->getSVal(Child, LCtx);
+
+CollectReachableSymbolsCallback Scanner =
+State->scanReachableSymbols(
+Val);
+const InvalidatedSymbols  = Scanner.getSymbols();
+
+State = getCheckerManager().runCheckersForPointerEscape(
+State, EscapedSymbols,
+/*CallEvent*/ nullptr, 

[PATCH] D38231: fixing a bug in mask[z]_set1

2017-09-25 Thread jina via Phabricator via cfe-commits
jina.nahias updated this revision to Diff 116513.

https://reviews.llvm.org/D38231

Files:
  lib/Headers/avx512vlintrin.h
  test/CodeGen/avx512vl-builtins.c


Index: test/CodeGen/avx512vl-builtins.c
===
--- test/CodeGen/avx512vl-builtins.c
+++ test/CodeGen/avx512vl-builtins.c
@@ -4563,45 +4563,17 @@
 #ifdef __x86_64__
 __m128i test_mm_mask_set1_epi64(__m128i __O, __mmask8 __M, long long __A) {
   // CHECK-LABEL: @test_mm_mask_set1_epi64
-  // CHECK: insertelement <16 x i8> undef, i8 %{{.*}}, i32 0
-  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 1
-  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 2
-  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 3
-  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 4
-  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 5
-  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 6
-  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 7
-  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 8
-  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 9
-  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 10
-  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 11
-  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 12
-  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 13
-  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 14
-  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 15
+  // CHECK: insertelement <2 x i64> undef, i64 %{{.*}}, i32 0
+  // CHECK: insertelement <2 x i64> %{{.*}}, i64 %{{.*}}, i32 1
   // CHECK: shufflevector <8 x i1> %{{.*}}, <8 x i1> %{{.*}}, <2 x i32> 
   // CHECK: select <2 x i1> %{{.*}}, <2 x i64> %{{.*}}, <2 x i64> %{{.*}}
   return _mm_mask_set1_epi64(__O, __M, __A); 
 }
 
 __m128i test_mm_maskz_set1_epi64(__mmask8 __M, long long __A) {
   // CHECK-LABEL: @test_mm_maskz_set1_epi64
-  // CHECK: insertelement <16 x i8> undef, i8 %{{.*}}, i32 0
-  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 1
-  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 2
-  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 3
-  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 4
-  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 5
-  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 6
-  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 7
-  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 8
-  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 9
-  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 10
-  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 11
-  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 12
-  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 13
-  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 14
-  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 15
+  // CHECK: insertelement <2 x i64> undef, i64 %{{.*}}, i32 0
+  // CHECK: insertelement <2 x i64> %{{.*}}, i64 %{{.*}}, i32 1
   // CHECK: shufflevector <8 x i1> %{{.*}}, <8 x i1> %{{.*}}, <2 x i32> 
   // CHECK: select <2 x i1> %{{.*}}, <2 x i64> %{{.*}}, <2 x i64> %{{.*}}
   return _mm_maskz_set1_epi64(__M, __A); 
Index: lib/Headers/avx512vlintrin.h
===
--- lib/Headers/avx512vlintrin.h
+++ lib/Headers/avx512vlintrin.h
@@ -5761,15 +5761,15 @@
 _mm_mask_set1_epi64 (__m128i __O, __mmask8 __M, long long __A)
 {
   return (__m128i) __builtin_ia32_selectq_128(__M,
-  (__v2di) _mm_set1_epi8(__A),
+  (__v2di) _mm_set1_epi64x(__A),
   (__v2di) __O);
 }
 
 static __inline__ __m128i __DEFAULT_FN_ATTRS
 _mm_maskz_set1_epi64 (__mmask8 __M, long long __A)
 {
   return (__m128i) __builtin_ia32_selectq_128(__M,
-  (__v2di) _mm_set1_epi8(__A),
+  (__v2di) _mm_set1_epi64x(__A),
   (__v2di) _mm_setzero_si128());
 }
 


Index: test/CodeGen/avx512vl-builtins.c
===
--- test/CodeGen/avx512vl-builtins.c
+++ test/CodeGen/avx512vl-builtins.c
@@ -4563,45 +4563,17 @@
 #ifdef __x86_64__
 __m128i test_mm_mask_set1_epi64(__m128i __O, __mmask8 __M, long long __A) {
   // CHECK-LABEL: @test_mm_mask_set1_epi64
-  // CHECK: insertelement <16 x i8> undef, i8 %{{.*}}, i32 0
-  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 1
-  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 2
-  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 3
-  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 4
-  // CHECK: insertelement <16 x i8> %{{.*}}, i8 %{{.*}}, i32 5
-  // CHECK: 

[PATCH] D38231: fixing a bug in mask[z]_set1

2017-09-25 Thread jina via Phabricator via cfe-commits
jina.nahias created this revision.

https://reviews.llvm.org/D38231

Files:
  lib/Headers/avx512vlintrin.h


Index: lib/Headers/avx512vlintrin.h
===
--- lib/Headers/avx512vlintrin.h
+++ lib/Headers/avx512vlintrin.h
@@ -5761,15 +5761,15 @@
 _mm_mask_set1_epi64 (__m128i __O, __mmask8 __M, long long __A)
 {
   return (__m128i) __builtin_ia32_selectq_128(__M,
-  (__v2di) _mm_set1_epi8(__A),
+  (__v2di) _mm_set1_epi64(__A),
   (__v2di) __O);
 }
 
 static __inline__ __m128i __DEFAULT_FN_ATTRS
 _mm_maskz_set1_epi64 (__mmask8 __M, long long __A)
 {
   return (__m128i) __builtin_ia32_selectq_128(__M,
-  (__v2di) _mm_set1_epi8(__A),
+  (__v2di) _mm_set1_epi64(__A),
   (__v2di) _mm_setzero_si128());
 }
 


Index: lib/Headers/avx512vlintrin.h
===
--- lib/Headers/avx512vlintrin.h
+++ lib/Headers/avx512vlintrin.h
@@ -5761,15 +5761,15 @@
 _mm_mask_set1_epi64 (__m128i __O, __mmask8 __M, long long __A)
 {
   return (__m128i) __builtin_ia32_selectq_128(__M,
-  (__v2di) _mm_set1_epi8(__A),
+  (__v2di) _mm_set1_epi64(__A),
   (__v2di) __O);
 }
 
 static __inline__ __m128i __DEFAULT_FN_ATTRS
 _mm_maskz_set1_epi64 (__mmask8 __M, long long __A)
 {
   return (__m128i) __builtin_ia32_selectq_128(__M,
-  (__v2di) _mm_set1_epi8(__A),
+  (__v2di) _mm_set1_epi64(__A),
   (__v2di) _mm_setzero_si128());
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D33826: [clang-tidy] avoid pointer cast to more strict alignment check

2017-09-25 Thread Eniko Donatella Toth via Phabricator via cfe-commits
NorenaLeonetti updated this revision to Diff 116510.

Repository:
  rL LLVM

https://reviews.llvm.org/D33826

Files:
  clang-tidy/cert/AvoidPointerCastToMoreStrictAlignmentCheck.cpp
  clang-tidy/cert/AvoidPointerCastToMoreStrictAlignmentCheck.h
  clang-tidy/cert/CERTTidyModule.cpp
  clang-tidy/cert/CMakeLists.txt
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/cert-exp36-c.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/cert-avoid-pointer-cast-to-more-strict-alignment.c
  test/clang-tidy/cert-avoid-pointer-cast-to-more-strict-alignment.cpp

Index: test/clang-tidy/cert-avoid-pointer-cast-to-more-strict-alignment.cpp
===
--- /dev/null
+++ test/clang-tidy/cert-avoid-pointer-cast-to-more-strict-alignment.cpp
@@ -0,0 +1,7 @@
+// RUN: %check_clang_tidy %s cert-exp36-c %t
+
+void function(void) {
+  char c = 'x';
+  int *ip = reinterpret_cast();
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: do not cast pointers into more strictly aligned pointer types [cert-exp36-c] 
+}
Index: test/clang-tidy/cert-avoid-pointer-cast-to-more-strict-alignment.c
===
--- /dev/null
+++ test/clang-tidy/cert-avoid-pointer-cast-to-more-strict-alignment.c
@@ -0,0 +1,122 @@
+// RUN: %check_clang_tidy %s cert-exp36-c %t -- -- -std=c11
+
+void function(void) {
+  char c = 'x';
+  int *ip = (int *)
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: do not cast pointers into more strictly aligned pointer types [cert-exp36-c] 
+}
+
+struct foo_header {
+  int len;
+};
+ 
+void function2(char *data, unsigned offset) {
+  struct foo_header *tmp;
+  struct foo_header header;
+ 
+  tmp = (struct foo_header *)(data + offset);
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: do not cast pointers into more strictly aligned pointer types [cert-exp36-c] 
+}
+
+// Test from -Wcast-align check:
+
+// Simple casts.
+void test0(char *P) {
+  char *a  = (char*)  P;
+  short *b = (short*) P;
+  // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: do not cast pointers into more strictly aligned pointer types [cert-exp36-c]
+  int *c   = (int*)   P;
+  // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: do not cast pointers into more strictly aligned pointer types [cert-exp36-c]
+}
+
+// Casts from void* are a special case.
+void test1(void *P) {
+  char *a  = (char*)  P;
+  short *b = (short*) P;
+  int *c   = (int*)   P;
+
+  const volatile void *P2 = P;
+  char *d  = (char*)  P2;
+  short *e = (short*) P2;
+  int *f   = (int*)   P2;
+
+  const char *g  = (const char*)  P2;
+  const short *h = (const short*) P2;
+  const int *i   = (const int*)   P2;
+
+  const volatile char *j  = (const volatile char*)  P2;
+  const volatile short *k = (const volatile short*) P2;
+  const volatile int *l   = (const volatile int*)   P2;
+}
+
+// Aligned struct.
+struct __attribute__((aligned(16))) A {
+  char buffer[16];
+};
+void test2(char *P) {
+  struct A *a = (struct A*) P;
+  // CHECK-MESSAGES: :[[@LINE-1]]:17: warning: do not cast pointers into more strictly aligned pointer types [cert-exp36-c]
+}
+
+// Incomplete type.
+void test3(char *P) {
+  struct B *b = (struct B*) P;
+}
+
+// Do not issue a warning. The aligned attribute changes the alignment of the
+// variables and fields.
+char __attribute__((aligned(4))) a[16];
+
+struct S0 {
+  char a[16];
+};
+
+struct S {
+  char __attribute__((aligned(4))) a[16];
+  struct S0 __attribute__((aligned(4))) s0;
+};
+
+// same FIXME as in line 120
+void test4() {
+  struct S s;
+  int *i = (int *)s.a;
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: do not cast pointers into more strictly aligned pointer types [cert-exp36-c]
+  i = (int *)
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: do not cast pointers into more strictly aligned pointer types [cert-exp36-c]
+  i = (int *)a;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: do not cast pointers into more strictly aligned pointer types [cert-exp36-c]
+}
+
+// No warnings.
+typedef int (*FnTy)(void);
+unsigned int func5(void);
+
+FnTy test5(void) {
+  return (FnTy)
+}
+
+
+// Something that does not trigger the check:
+
+struct w;
+
+void function3(struct w *v) {
+  int *ip = (int *)v;
+  struct w *u = (struct w *)ip;
+}
+
+struct x {
+   _Alignas(int) char c;
+};
+
+void function4(void) {
+  struct x c = {'x'};
+  int *ip = (int *)
+}
+
+// FIXME: we do not want a warning for this
+void function5(void) {
+  _Alignas(int) char c = 'x';
+  int *ip = (int *)
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: do not cast pointers into more strictly aligned pointer types [cert-exp36-c]
+}
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -20,6 +20,7 @@
bugprone-integer-division
bugprone-suspicious-memset-usage
bugprone-undefined-memory-manipulation
+   cert-exp36-c
cert-dcl03-c (redirects to misc-static-assert) 

[PATCH] D33826: [clang-tidy] avoid pointer cast to more strict alignment check

2017-09-25 Thread Eniko Donatella Toth via Phabricator via cfe-commits
NorenaLeonetti added a comment.

In https://reviews.llvm.org/D33826#866145, @lebedev.ri wrote:

> In https://reviews.llvm.org/D33826#866133, @NorenaLeonetti wrote:
>
> > In https://reviews.llvm.org/D33826#861226, @aaron.ballman wrote:
> >
> > > Have you run this check over any large code bases to see what the quality 
> > > of the diagnostics are?
> >
> >
> > `-checks=-*,cert-exp36-c,modernize-unary-static-assert`
> >
> > the result:
> >
> > real52m6.886s
> >  user298m8.824s
> >  sys 7m29.292s
> >
> > `-checks=-*,modernize-unary-static-assert`
> >
> > the result:
> >
> > real52m5.305s
> >  user302m38.508s
> >  sys 8m53.008s
>
>
> What was meant is, run the check over some large codebase (e.g. all of the 
> LLVM itself), and upload the results somewhere.
>  Then analyze the results. Are there any obvious false-positives?
>  If yes, then minimize the testcase, add it into 
> `test/clang-tidy/cert-avoid-pointer-cast-to-more-strict-alignment.cpp` and 
> fix it's handling.
>  Are there clear bugs in the analyzed code?


I've run the check on the LLVM codebase and got these warnings in the file.
F5385001: test_alignment_check.txt 


Repository:
  rL LLVM

https://reviews.llvm.org/D33826



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


[PATCH] D30691: [analyzer] Support for naive cross translational unit analysis

2017-09-25 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added a comment.

In https://reviews.llvm.org/D30691#878830, @r.stahl wrote:

> For my purposes I replaced the return statement of the 
> compareCrossTUSourceLocs function with:
>
>   return XL.getFileID() < YL.getFileID();
>
>
> A more correct fix would create only one unique diagnostic for both cases.


Thank you for the report, I could reproduce this after modifying the null 
dereference checker. My fear of using file IDs is that I don't know whether 
they are stable. So in subsequent runs, different paths might be chosen by the 
analyzer and this could be confusing to the user.  I will think about a 
workaround that both stable and solves this assertion.

I see two possible ways to do the proper fix. One is to check explicitly for 
this case when the same function appears in multiple translation units. A 
better approach would be to have the ASTImporter handle this case. I think the 
proper fix is better addressed in a separate patch.


https://reviews.llvm.org/D30691



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


[PATCH] D30691: [analyzer] Support for naive cross translational unit analysis

2017-09-25 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun updated this revision to Diff 116502.
xazax.hun added a comment.
Herald added a subscriber: baloghadamsoftware.

- Fixed an issue with source locations
- Updated to latest trunk


https://reviews.llvm.org/D30691

Files:
  include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
  include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
  lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
  lib/StaticAnalyzer/Core/CMakeLists.txt
  lib/StaticAnalyzer/Core/CallEvent.cpp
  lib/StaticAnalyzer/Core/ExprEngine.cpp
  lib/StaticAnalyzer/Core/PathDiagnostic.cpp
  lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
  lib/StaticAnalyzer/Frontend/CMakeLists.txt
  test/Analysis/Inputs/ctu-chain.cpp
  test/Analysis/Inputs/ctu-other.cpp
  test/Analysis/Inputs/externalFnMap.txt
  test/Analysis/ctu-main.cpp
  tools/scan-build-py/libscanbuild/__init__.py
  tools/scan-build-py/libscanbuild/analyze.py
  tools/scan-build-py/libscanbuild/arguments.py
  tools/scan-build-py/libscanbuild/clang.py
  tools/scan-build-py/libscanbuild/report.py
  tools/scan-build-py/tests/unit/test_analyze.py
  tools/scan-build-py/tests/unit/test_clang.py

Index: tools/scan-build-py/tests/unit/test_clang.py
===
--- tools/scan-build-py/tests/unit/test_clang.py
+++ tools/scan-build-py/tests/unit/test_clang.py
@@ -92,3 +92,16 @@
 self.assertEqual('Checker One description', result.get('checker.one'))
 self.assertTrue('checker.two' in result)
 self.assertEqual('Checker Two description', result.get('checker.two'))
+
+
+class ClangIsCtuCapableTest(unittest.TestCase):
+def test_ctu_not_found(self):
+is_ctu = sut.is_ctu_capable('not-found-clang',
+'not-found-clang-func-mapping')
+self.assertFalse(is_ctu)
+
+
+class ClangGetTripleArchTest(unittest.TestCase):
+def test_arch_is_not_empty(self):
+arch = sut.get_triple_arch(['clang', '-E', '-'], '.')
+self.assertTrue(len(arch) > 0)
Index: tools/scan-build-py/tests/unit/test_analyze.py
===
--- tools/scan-build-py/tests/unit/test_analyze.py
+++ tools/scan-build-py/tests/unit/test_analyze.py
@@ -4,12 +4,12 @@
 # This file is distributed under the University of Illinois Open Source
 # License. See LICENSE.TXT for details.
 
-import libear
-import libscanbuild.analyze as sut
 import unittest
 import re
 import os
 import os.path
+import libear
+import libscanbuild.analyze as sut
 
 
 class ReportDirectoryTest(unittest.TestCase):
@@ -333,3 +333,83 @@
 
 def test_method_exception_not_caught(self):
 self.assertRaises(Exception, method_exception_from_inside, dict())
+
+
+class PrefixWithTest(unittest.TestCase):
+
+def test_gives_empty_on_empty(self):
+res = sut.prefix_with(0, [])
+self.assertFalse(res)
+
+def test_interleaves_prefix(self):
+res = sut.prefix_with(0, [1, 2, 3])
+self.assertListEqual([0, 1, 0, 2, 0, 3], res)
+
+
+class MergeCtuMapTest(unittest.TestCase):
+
+def test_no_map_gives_empty(self):
+pairs = sut.create_global_ctu_function_map([])
+self.assertFalse(pairs)
+
+def test_multiple_maps_merged(self):
+concat_map = ['_Z1fun1i@x86_64 ast/x86_64/fun1.c.ast',
+  '_Z1fun2i@x86_64 ast/x86_64/fun2.c.ast',
+  '_Z1fun3i@x86_64 ast/x86_64/fun3.c.ast']
+pairs = sut.create_global_ctu_function_map(concat_map)
+self.assertTrue(('_Z1fun1i@x86_64', 'ast/x86_64/fun1.c.ast') in pairs)
+self.assertTrue(('_Z1fun2i@x86_64', 'ast/x86_64/fun2.c.ast') in pairs)
+self.assertTrue(('_Z1fun3i@x86_64', 'ast/x86_64/fun3.c.ast') in pairs)
+self.assertEqual(3, len(pairs))
+
+def test_not_unique_func_left_out(self):
+concat_map = ['_Z1fun1i@x86_64 ast/x86_64/fun1.c.ast',
+  '_Z1fun2i@x86_64 ast/x86_64/fun2.c.ast',
+  '_Z1fun1i@x86_64 ast/x86_64/fun7.c.ast']
+pairs = sut.create_global_ctu_function_map(concat_map)
+self.assertFalse(('_Z1fun1i@x86_64', 'ast/x86_64/fun1.c.ast') in pairs)
+self.assertFalse(('_Z1fun1i@x86_64', 'ast/x86_64/fun7.c.ast') in pairs)
+self.assertTrue(('_Z1fun2i@x86_64', 'ast/x86_64/fun2.c.ast') in pairs)
+self.assertEqual(1, len(pairs))
+
+def test_duplicates_are_kept(self):
+concat_map = ['_Z1fun1i@x86_64 ast/x86_64/fun1.c.ast',
+  '_Z1fun2i@x86_64 ast/x86_64/fun2.c.ast',
+  '_Z1fun1i@x86_64 ast/x86_64/fun1.c.ast']
+pairs = sut.create_global_ctu_function_map(concat_map)
+self.assertTrue(('_Z1fun1i@x86_64', 'ast/x86_64/fun1.c.ast') in pairs)
+self.assertTrue(('_Z1fun2i@x86_64', 'ast/x86_64/fun2.c.ast') in pairs)
+self.assertEqual(2, len(pairs))
+
+def test_space_handled_in_source(self):
+concat_map = ['_Z1fun1i@x86_64 ast/x86_64/f un.c.ast']
+

[PATCH] D38228: Fix clangd when built with LLVM_LINK_LLVM_DYLIB=ON

2017-09-25 Thread Sylvestre Ledru via Phabricator via cfe-commits
sylvestre.ledru created this revision.
Herald added subscribers: ilya-biryukov, mgorny.

https://reviews.llvm.org/D38228

Files:
  clangd/tool/CMakeLists.txt


Index: clangd/tool/CMakeLists.txt
===
--- clangd/tool/CMakeLists.txt
+++ clangd/tool/CMakeLists.txt
@@ -6,6 +6,10 @@
 
 install(TARGETS clangd RUNTIME DESTINATION bin)
 
+set(LLVM_LINK_COMPONENTS
+  support
+  )
+
 target_link_libraries(clangd
   clangBasic
   clangDaemon
@@ -14,5 +18,4 @@
   clangSema
   clangTooling
   clangToolingCore
-  LLVMSupport
   )


Index: clangd/tool/CMakeLists.txt
===
--- clangd/tool/CMakeLists.txt
+++ clangd/tool/CMakeLists.txt
@@ -6,6 +6,10 @@
 
 install(TARGETS clangd RUNTIME DESTINATION bin)
 
+set(LLVM_LINK_COMPONENTS
+  support
+  )
+
 target_link_libraries(clangd
   clangBasic
   clangDaemon
@@ -14,5 +18,4 @@
   clangSema
   clangTooling
   clangToolingCore
-  LLVMSupport
   )
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


  1   2   >