[clang] a7db230 - [X86] Add CMPXCHG16B feature to amdfam10 in the frontend.

2020-06-25 Thread Craig Topper via cfe-commits

Author: Craig Topper
Date: 2020-06-25T22:55:36-07:00
New Revision: a7db230d752be4a104c496eb68a82a5acb4bb35c

URL: 
https://github.com/llvm/llvm-project/commit/a7db230d752be4a104c496eb68a82a5acb4bb35c
DIFF: 
https://github.com/llvm/llvm-project/commit/a7db230d752be4a104c496eb68a82a5acb4bb35c.diff

LOG: [X86] Add CMPXCHG16B feature to amdfam10 in the frontend.

We already have this feature on it in the backend.

Added: 


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

Removed: 




diff  --git a/clang/lib/Basic/Targets/X86.cpp b/clang/lib/Basic/Targets/X86.cpp
index cc37c8a5cba0..184090fe104f 100644
--- a/clang/lib/Basic/Targets/X86.cpp
+++ b/clang/lib/Basic/Targets/X86.cpp
@@ -336,6 +336,7 @@ bool X86TargetInfo::initFeatureMap(
 setFeatureEnabledImpl(Features, "popcnt", true);
 setFeatureEnabledImpl(Features, "sahf", true);
 setFeatureEnabledImpl(Features, "prfchw", true);
+setFeatureEnabledImpl(Features, "cx16", true);
 LLVM_FALLTHROUGH;
   case CK_K8SSE3:
 setFeatureEnabledImpl(Features, "sse3", true);

diff  --git a/clang/test/Preprocessor/predefined-arch-macros.c 
b/clang/test/Preprocessor/predefined-arch-macros.c
index 4e1535c91c08..91f6a99a29c2 100644
--- a/clang/test/Preprocessor/predefined-arch-macros.c
+++ b/clang/test/Preprocessor/predefined-arch-macros.c
@@ -2397,6 +2397,7 @@
 // RUN:   | FileCheck -match-full-lines %s -check-prefix=CHECK_AMDFAM10_M64
 // CHECK_AMDFAM10_M64: #define __3dNOW_A__ 1
 // CHECK_AMDFAM10_M64: #define __3dNOW__ 1
+// CHECK_AMDFAM10_M64: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_16 1
 // CHECK_AMDFAM10_M64: #define __LZCNT__ 1
 // CHECK_AMDFAM10_M64: #define __MMX__ 1
 // CHECK_AMDFAM10_M64: #define __POPCNT__ 1



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


[PATCH] D82506: [HIP] Add missing options for lto

2020-06-25 Thread Yaxun Liu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8013ce449022: [HIP] Add missing options for lto (authored by 
yaxunl).
Herald added a project: clang.

Changed prior to commit:
  https://reviews.llvm.org/D82506?vs=273424=273588#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82506/new/

https://reviews.llvm.org/D82506

Files:
  clang/lib/Driver/ToolChains/AMDGPU.h
  clang/lib/Driver/ToolChains/HIP.cpp
  clang/test/Driver/hip-link-save-temps.hip
  clang/test/Driver/hip-save-temps.hip
  clang/test/Driver/hip-toolchain-features.hip
  clang/test/Driver/hip-toolchain-mllvm.hip
  clang/test/Driver/hip-toolchain-opt.hip
  clang/test/Driver/hip-toolchain-rdc-separate.hip
  clang/test/Driver/hip-toolchain-rdc.hip

Index: clang/test/Driver/hip-toolchain-rdc.hip
===
--- clang/test/Driver/hip-toolchain-rdc.hip
+++ clang/test/Driver/hip-toolchain-rdc.hip
@@ -53,7 +53,8 @@
 // CHECK-NOT: "*.llvm-link"
 // CHECK-NOT: ".*opt"
 // CHECK-NOT: ".*llc"
-// CHECK: {{".*lld.*"}} {{.*}} "-mllvm" "-amdgpu-internalize-symbols"
+// CHECK: {{".*lld.*"}} {{.*}} "-plugin-opt=-amdgpu-internalize-symbols"
+// CHECK-SAME: "-plugin-opt=mcpu=gfx803"
 // CHECK-SAME: "-o" "[[IMG_DEV1:.*.out]]" [[A_BC1]] [[B_BC1]]
 
 // generate image for device side path on gfx900
@@ -80,7 +81,8 @@
 // CHECK-NOT: "*.llvm-link"
 // CHECK-NOT: ".*opt"
 // CHECK-NOT: ".*llc"
-// CHECK: {{".*lld.*"}} {{.*}} "-mllvm" "-amdgpu-internalize-symbols"
+// CHECK: {{".*lld.*"}} {{.*}} "-plugin-opt=-amdgpu-internalize-symbols"
+// CHECK-SAME: "-plugin-opt=mcpu=gfx900"
 // CHECK-SAME: "-o" "[[IMG_DEV2:.*.out]]" [[A_BC2]] [[B_BC2]]
 
 // combine images generated into hip fat binary object
Index: clang/test/Driver/hip-toolchain-rdc-separate.hip
===
--- clang/test/Driver/hip-toolchain-rdc-separate.hip
+++ clang/test/Driver/hip-toolchain-rdc-separate.hip
@@ -107,13 +107,15 @@
 // LINK-NOT: "*.llvm-link"
 // LINK-NOT: ".*opt"
 // LINK-NOT: ".*llc"
-// LINK: {{".*lld.*"}} {{.*}} "-mllvm" "-amdgpu-internalize-symbols"
+// LINK: {{".*lld.*"}} {{.*}} "-plugin-opt=-amdgpu-internalize-symbols"
+// LINK: "-plugin-opt=mcpu=gfx803"
 // LINK-SAME: "-o" "[[IMG_DEV1:.*.out]]" "[[A_BC1]]" "[[B_BC1]]"
 
 // LINK-NOT: "*.llvm-link"
 // LINK-NOT: ".*opt"
 // LINK-NOT: ".*llc"
-// LINK: {{".*lld.*"}} {{.*}} "-mllvm" "-amdgpu-internalize-symbols"
+// LINK: {{".*lld.*"}} {{.*}} "-plugin-opt=-amdgpu-internalize-symbols"
+// LINK: "-plugin-opt=mcpu=gfx900"
 // LINK-SAME: "-o" "[[IMG_DEV2:.*.out]]" "[[A_BC2]]" "[[B_BC2]]"
 
 // LINK: [[BUNDLER:".*clang-offload-bundler"]] "-type=o"
Index: clang/test/Driver/hip-toolchain-opt.hip
===
--- clang/test/Driver/hip-toolchain-opt.hip
+++ clang/test/Driver/hip-toolchain-opt.hip
@@ -72,6 +72,16 @@
 
 // ALL-NOT: "{{.*}}llc"
 
+// ALL: "{{.*}}lld{{.*}}" {{.*}} "-plugin-opt=mcpu=gfx900"
+// DEFAULT-NOT: "-plugin-opt=O{{.*}}"
+// O0-SAME: "-plugin-opt=O0"
+// O1-SAME: "-plugin-opt=O1"
+// O2-SAME: "-plugin-opt=O2"
+// O3-SAME: "-plugin-opt=O3"
+// Os-SAME: "-plugin-opt=O2"
+// Oz-SAME: "-plugin-opt=O2"
+// Og-SAME: "-plugin-opt=O1"
+
 // ALL: "{{.*}}clang{{.*}}" "-cc1" "-triple" "x86_64-unknown-linux-gnu"
 // DEFAULT-NOT: "-O{{.}}"
 // O0-SAME: "-O0"
Index: clang/test/Driver/hip-toolchain-mllvm.hip
===
--- clang/test/Driver/hip-toolchain-mllvm.hip
+++ clang/test/Driver/hip-toolchain-mllvm.hip
@@ -7,20 +7,25 @@
 // RUN:   -mllvm -amdgpu-function-calls=0 \
 // RUN:   %s 2>&1 | FileCheck %s
 
+// RUN: %clang -### -target x86_64-linux-gnu \
+// RUN:   --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 \
+// RUN:   -fgpu-rdc -mllvm -amdgpu-function-calls=0 \
+// RUN:   %s 2>&1 | FileCheck -check-prefixes=CHECK,RDC %s
+
 // CHECK: [[CLANG:".*clang.*"]] "-cc1" "-triple" "amdgcn-amd-amdhsa"
 // CHECK-SAME: "-aux-triple" "x86_64-unknown-linux-gnu"
-// CHECK-SAME: "-emit-obj"
 // CHECK-SAME: {{.*}} "-target-cpu" "gfx803"
 // CHECK-SAME: {{.*}} "-mllvm" "-amdgpu-function-calls=0" {{.*}}
 
 // CHECK-NOT: {{".*opt"}}
 // CHECK-NOT: {{".*llc"}}
+// RDC: [[LLD:".*lld.*"]] {{.*}} "-plugin-opt=-amdgpu-function-calls=0"
 
 // CHECK: [[CLANG]] "-cc1" "-triple" "amdgcn-amd-amdhsa"
 // CHECK-SAME: "-aux-triple" "x86_64-unknown-linux-gnu"
-// CHECK-SAME: "-emit-obj"
 // CHECK-SAME: {{.*}} "-target-cpu" "gfx900"
 // CHECK-SAME: {{.*}} "-mllvm" "-amdgpu-function-calls=0" {{.*}}
 
 // CHECK-NOT: {{".*opt"}}
 // CHECK-NOT: {{".*llc"}}
+// RDC: [[LLD:".*lld.*"]] {{.*}} "-plugin-opt=-amdgpu-function-calls=0"
Index: clang/test/Driver/hip-toolchain-features.hip
===
--- clang/test/Driver/hip-toolchain-features.hip
+++ clang/test/Driver/hip-toolchain-features.hip
@@ -2,39 +2,45 @@
 // 

[PATCH] D82312: Add `CharLiteral` to SyntaxTree

2020-06-25 Thread Vlad Vereschaka via Phabricator via cfe-commits
vvereschaka added a comment.

Hello Eduardo,

sorry, but one of your these commits break the clang unit tests on the 
following builders:

- http://lab.llvm.org:8011/builders/llvm-clang-x86_64-win-fast/builds/18313
- http://lab.llvm.org:8011/builders/llvm-clang-win-x-aarch64/builds/256
- http://lab.llvm.org:8011/builders/llvm-clang-win-x-armv7l/builds/96

with the following errors:

  FAILED: 
tools/clang/unittests/Tooling/Syntax/CMakeFiles/SyntaxTests.dir/TreeTest.cpp.obj
 
  
C:\PROGRA~2\MICROS~1\2017\COMMUN~1\VC\Tools\MSVC\1416~1.270\bin\Hostx64\x64\cl.exe
  /nologo /TP -DGTEST_HAS_RTTI=0 -DGTEST_HAS_TR1_TUPLE=0 -DGTEST_LANG_CXX11=1 
-DUNICODE -D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_NONSTDC_NO_WARNINGS 
-D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS -D_GNU_SOURCE 
-D_HAS_EXCEPTIONS=0 -D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS 
-D_UNICODE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS 
-D__STDC_LIMIT_MACROS -Itools\clang\unittests\Tooling\Syntax 
-IC:\buildbot\as-builder-3\llvm-clang-x86_64-win-fast\llvm-project\clang\unittests\Tooling\Syntax
 
-IC:\buildbot\as-builder-3\llvm-clang-x86_64-win-fast\llvm-project\clang\include
 -Itools\clang\include -Iinclude 
-IC:\buildbot\as-builder-3\llvm-clang-x86_64-win-fast\llvm-project\llvm\include 
-IC:\buildbot\as-builder-3\llvm-clang-x86_64-win-fast\llvm-project\llvm\utils\unittest\googletest\include
 
-IC:\buildbot\as-builder-3\llvm-clang-x86_64-win-fast\llvm-project\llvm\utils\unittest\googlemock\include
 /DWIN32 /D_WINDOWS   /Zc:inline /Zc:strictStrings /Oi /Zc:rvalueCast /W4 
-wd4141 -wd4146 -wd4244 -wd4267 -wd4291 -wd4351 -wd4456 -wd4457 -wd4458 -wd4459 
-wd4503 -wd4624 -wd4722 -wd4100 -wd4127 -wd4512 -wd4505 -wd4610 -wd4510 -wd4702 
-wd4245 -wd4706 -wd4310 -wd4701 -wd4703 -wd4389 -wd4611 -wd4805 -wd4204 -wd4577 
-wd4091 -wd4592 -wd4319 -wd4709 -wd4324 -w14062 -we4238 /Gw /MD /O2 /Ob2 
/DNDEBUG/EHs-c- /GR- -std:c++14 /showIncludes 
/Fotools\clang\unittests\Tooling\Syntax\CMakeFiles\SyntaxTests.dir\TreeTest.cpp.obj
 /Fdtools\clang\unittests\Tooling\Syntax\CMakeFiles\SyntaxTests.dir\ /FS -c 
C:\buildbot\as-builder-3\llvm-clang-x86_64-win-fast\llvm-project\clang\unittests\Tooling\Syntax\TreeTest.cpp
  
C:\buildbot\as-builder-3\llvm-clang-x86_64-win-fast\llvm-project\clang\unittests\Tooling\Syntax\TreeTest.cpp(1665):
 error C2017: illegal escape sequence
  
C:\buildbot\as-builder-3\llvm-clang-x86_64-win-fast\llvm-project\clang\unittests\Tooling\Syntax\TreeTest.cpp(1665):
 error C2146: syntax error: missing ')' before identifier 'n'
  
C:\buildbot\as-builder-3\llvm-clang-x86_64-win-fast\llvm-project\clang\unittests\Tooling\Syntax\TreeTest.cpp(1639):
 error C2660: 'testing::internal::GetBoolAssertionFailureMessage': function 
does not take 2 arguments
  
C:\buildbot\as-builder-3\llvm-clang-x86_64-win-fast\llvm-project\llvm\utils\unittest\googletest\include\gtest/internal/gtest-internal.h(226):
 note: see declaration of 'testing::internal::GetBoolAssertionFailureMessage'
  
C:\buildbot\as-builder-3\llvm-clang-x86_64-win-fast\llvm-project\clang\unittests\Tooling\Syntax\TreeTest.cpp(1639):
 error C2440: '': cannot convert from 'initializer list' 
to 'testing::internal::AssertHelper'
  
C:\buildbot\as-builder-3\llvm-clang-x86_64-win-fast\llvm-project\clang\unittests\Tooling\Syntax\TreeTest.cpp(1665):
 note: No constructor could take the source type, or constructor overload 
resolution was ambiguous
  
C:\buildbot\as-builder-3\llvm-clang-x86_64-win-fast\llvm-project\clang\unittests\Tooling\Syntax\TreeTest.cpp(1665):
 error C2146: syntax error: missing ';' before identifier 'n'
  
C:\buildbot\as-builder-3\llvm-clang-x86_64-win-fast\llvm-project\clang\unittests\Tooling\Syntax\TreeTest.cpp(1665):
 error C2059: syntax error: ')'
  
C:\buildbot\as-builder-3\llvm-clang-x86_64-win-fast\llvm-project\clang\unittests\Tooling\Syntax\TreeTest.cpp(1639):
 error C2065: 'n': undeclared identifier
  
C:\buildbot\as-builder-3\llvm-clang-x86_64-win-fast\llvm-project\clang\unittests\Tooling\Syntax\TreeTest.cpp(1665):
 error C2146: syntax error: missing ';' before identifier 'SyntaxTree'
  
C:\buildbot\as-builder-3\llvm-clang-x86_64-win-fast\llvm-project\clang\unittests\Tooling\Syntax\TreeTest.cpp(1639):
 error C2065: 'SyntaxTree': undeclared identifier
  
C:\buildbot\as-builder-3\llvm-clang-x86_64-win-fast\llvm-project\clang\unittests\Tooling\Syntax\TreeTest.cpp(1639):
 error C2143: syntax error: missing ';' before 'string'

see more details here: 
http://lab.llvm.org:8011/builders/llvm-clang-x86_64-win-fast/builds/18313/steps/test-check-clang-unit/logs/stdio

I mean the following commits:
*221d7bbe49cceb0e408f0f46d9f8371e6c9fee2c 
* 
https://reviews.llvm.org/D82312
*466e8b7ea6e162d48cac42ccda210bdeb11080e3 
* 
https://reviews.llvm.org/D82360
*7b404b6d003181e990f53d27866ee98d5151c4f3 

[clang] 8013ce4 - [HIP] Add missing options for lto

2020-06-25 Thread Yaxun Liu via cfe-commits

Author: Yaxun (Sam) Liu
Date: 2020-06-26T00:26:05-04:00
New Revision: 8013ce4490225faf8aae911ee88087ce445e604c

URL: 
https://github.com/llvm/llvm-project/commit/8013ce4490225faf8aae911ee88087ce445e604c
DIFF: 
https://github.com/llvm/llvm-project/commit/8013ce4490225faf8aae911ee88087ce445e604c.diff

LOG: [HIP] Add missing options for lto

Add -mcpu, -mattr, -mllvm, and -save-temps options for lto when necessary.

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/AMDGPU.h
clang/lib/Driver/ToolChains/HIP.cpp
clang/test/Driver/hip-link-save-temps.hip
clang/test/Driver/hip-save-temps.hip
clang/test/Driver/hip-toolchain-features.hip
clang/test/Driver/hip-toolchain-mllvm.hip
clang/test/Driver/hip-toolchain-opt.hip
clang/test/Driver/hip-toolchain-rdc-separate.hip
clang/test/Driver/hip-toolchain-rdc.hip

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/AMDGPU.h 
b/clang/lib/Driver/ToolChains/AMDGPU.h
index 671a987bf9fc..3b2a85b23375 100644
--- a/clang/lib/Driver/ToolChains/AMDGPU.h
+++ b/clang/lib/Driver/ToolChains/AMDGPU.h
@@ -85,6 +85,8 @@ class LLVM_LIBRARY_VISIBILITY AMDGPUToolChain : public 
Generic_ELF {
 return true;
   }
 
+  /// Needed for translating LTO options.
+  const char *getDefaultLinker() const override { return "ld.lld"; }
 };
 
 class LLVM_LIBRARY_VISIBILITY ROCMToolChain : public AMDGPUToolChain {

diff  --git a/clang/lib/Driver/ToolChains/HIP.cpp 
b/clang/lib/Driver/ToolChains/HIP.cpp
index f524951ce837..15c44f394466 100644
--- a/clang/lib/Driver/ToolChains/HIP.cpp
+++ b/clang/lib/Driver/ToolChains/HIP.cpp
@@ -57,14 +57,38 @@ void AMDGCN::Linker::constructLldCommand(Compilation , 
const JobAction ,
   const llvm::opt::ArgList ) 
const {
   // Construct lld command.
   // The output from ld.lld is an HSA code object file.
-  ArgStringList LldArgs{"-flavor",
-"gnu",
-"--no-undefined",
-"-shared",
-"-mllvm",
-"-amdgpu-internalize-symbols",
-"-o",
-Output.getFilename()};
+  ArgStringList LldArgs{"-flavor", "gnu", "--no-undefined", "-shared",
+"-plugin-opt=-amdgpu-internalize-symbols"};
+
+  auto  = getToolChain();
+  auto  = TC.getDriver();
+  assert(!Inputs.empty() && "Must have at least one input.");
+  addLTOOptions(TC, Args, LldArgs, Output, Inputs[0],
+D.getLTOMode() == LTOK_Thin);
+
+  // Extract all the -m options
+  std::vector Features;
+  amdgpu::getAMDGPUTargetFeatures(D, Args, Features);
+
+  // Add features to mattr such as cumode
+  std::string MAttrString = "-plugin-opt=-mattr=";
+  for (auto OneFeature : unifyTargetFeatures(Features)) {
+MAttrString.append(Args.MakeArgString(OneFeature));
+if (OneFeature != Features.back())
+  MAttrString.append(",");
+  }
+  if (!Features.empty())
+LldArgs.push_back(Args.MakeArgString(MAttrString));
+
+  for (const Arg *A : Args.filtered(options::OPT_mllvm)) {
+LldArgs.push_back(
+Args.MakeArgString(Twine("-plugin-opt=") + A->getValue(0)));
+  }
+
+  if (C.getDriver().isSaveTempsEnabled())
+LldArgs.push_back("-save-temps");
+
+  LldArgs.append({"-o", Output.getFilename()});
   for (auto Input : Inputs)
 LldArgs.push_back(Input.getFilename());
   const char *Lld = Args.MakeArgString(getToolChain().GetProgramPath("lld"));

diff  --git a/clang/test/Driver/hip-link-save-temps.hip 
b/clang/test/Driver/hip-link-save-temps.hip
index d03cf1e5f4a9..60f71d0c5249 100644
--- a/clang/test/Driver/hip-link-save-temps.hip
+++ b/clang/test/Driver/hip-link-save-temps.hip
@@ -41,9 +41,9 @@
 // CHECK-NOT: {{".*/llvm-link"}}
 // CHECK-NOT: {{".*/opt"}}
 // CHECK-NOT: {{".*/llc"}}
-// CHECK: "{{.*lld.*}}" {{.*}} "-mllvm" "-amdgpu-internalize-symbols"
+// CHECK: "{{.*lld.*}}" {{.*}} "-plugin-opt=-amdgpu-internalize-symbols"
 // CHECK-SAME: "-o" "a.out-hip-amdgcn-amd-amdhsa-gfx900" 
"obj1-hip-amdgcn-amd-amdhsa-gfx900.o" "obj2-hip-amdgcn-amd-amdhsa-gfx900.o"
-// CHECK: "{{.*lld.*}}" {{.*}} "-mllvm" "-amdgpu-internalize-symbols"
+// CHECK: "{{.*lld.*}}" {{.*}} "-plugin-opt=-amdgpu-internalize-symbols"
 // CHECK-SAME: "-o" "a.out-hip-amdgcn-amd-amdhsa-gfx906" 
"obj1-hip-amdgcn-amd-amdhsa-gfx906.o" "obj2-hip-amdgcn-amd-amdhsa-gfx906.o"
 // CHECK: {{".*llvm-mc.*"}} "-triple" "amdgcn-amd-amdhsa" "-o"
 // CHECK-SAME: "[[OBJBUNDLE:.*.o]]" "{{.*}}.mcin" "--filetype=obj"

diff  --git a/clang/test/Driver/hip-save-temps.hip 
b/clang/test/Driver/hip-save-temps.hip
index f326f4155a15..b5d54a8092a9 100644
--- a/clang/test/Driver/hip-save-temps.hip
+++ b/clang/test/Driver/hip-save-temps.hip
@@ -54,7 +54,7 @@
 // CHECK-NOT: "{{.*}}opt"
 // CHECK-NOT: "{{.*}}llc"
 // NORDC: {{.*lld.*}}"-o" 

[clang] 471c806 - [hip] Refine `clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu`

2020-06-25 Thread Michael Liao via cfe-commits

Author: Michael Liao
Date: 2020-06-25T23:57:08-04:00
New Revision: 471c806a45bbac2f0f4274d8bea383d06d397a84

URL: 
https://github.com/llvm/llvm-project/commit/471c806a45bbac2f0f4274d8bea383d06d397a84
DIFF: 
https://github.com/llvm/llvm-project/commit/471c806a45bbac2f0f4274d8bea383d06d397a84.diff

LOG: [hip] Refine `clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu`

- Require target x86 being enabled as well.

Added: 


Modified: 
clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu

Removed: 




diff  --git a/clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu 
b/clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu
index 99284c04e5cc..2660a5f14f90 100644
--- a/clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu
+++ b/clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu
@@ -1,4 +1,6 @@
+// REQUIRES: x86-registered-target
 // REQUIRES: amdgpu-registered-target
+
 // RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -fcuda-is-device -emit-llvm -x 
hip %s -o - | FileCheck --check-prefixes=COMMON,CHECK %s
 // RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -fcuda-is-device -emit-llvm -x 
hip %s -disable-O0-optnone -o - | opt -S -O2 | FileCheck %s 
--check-prefixes=COMMON,OPT
 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -x hip %s -o - 
| FileCheck -check-prefix=HOST %s



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


[PATCH] D82579: [NFC] Extract unifyTargetFeatures

2020-06-25 Thread Yaxun Liu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
yaxunl marked an inline comment as done.
Closed by commit rGed398c3ca404: [NFC] Extract unifyTargetFeatures (authored by 
yaxunl).
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82579/new/

https://reviews.llvm.org/D82579

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/lib/Driver/ToolChains/CommonArgs.h
  clang/test/Driver/hip-toolchain-features.hip

Index: clang/test/Driver/hip-toolchain-features.hip
===
--- clang/test/Driver/hip-toolchain-features.hip
+++ clang/test/Driver/hip-toolchain-features.hip
@@ -35,3 +35,13 @@
 
 // ALL3: {{.*}}clang{{.*}}"-target-feature" "+xnack" "-target-feature" "+sram-ecc"
 // NOALL3: {{.*}}clang{{.*}}"-target-feature" "-xnack" "-target-feature" "-sram-ecc"
+
+// RUN: %clang -### -target x86_64-linux-gnu -fgpu-rdc -nogpulib \
+// RUN:   --cuda-gpu-arch=gfx1010 %s \
+// RUN:   -mcumode -mcumode -mno-cumode -mwavefrontsize64 -mcumode \
+// RUN:   -mwavefrontsize64 -mno-wavefrontsize64 2>&1 \
+// RUN:   | FileCheck %s -check-prefix=DUP
+// DUP: {{.*}}clang{{.*}} "-target-feature" "-wavefrontsize16"
+// DUP-SAME: "-target-feature" "+wavefrontsize32"
+// DUP-SAME: "-target-feature" "-wavefrontsize64"
+// DUP-SAME: "-target-feature" "+cumode"
Index: clang/lib/Driver/ToolChains/CommonArgs.h
===
--- clang/lib/Driver/ToolChains/CommonArgs.h
+++ clang/lib/Driver/ToolChains/CommonArgs.h
@@ -106,10 +106,20 @@
 std::string getCPUName(const llvm::opt::ArgList , const llvm::Triple ,
bool FromAs = false);
 
+/// Iterate \p Args and convert -mxxx to +xxx and -mno-xxx to -xxx and
+/// append it to \p Features.
+///
+/// Note: Since \p Features may contain default values before calling
+/// this function, or may be appended with entries to override arguments,
+/// entries in \p Features are not unique.
 void handleTargetFeaturesGroup(const llvm::opt::ArgList ,
std::vector ,
llvm::opt::OptSpecifier Group);
 
+/// If there are multiple +xxx or -xxx features, keep the last one.
+std::vector
+unifyTargetFeatures(const std::vector );
+
 /// Handles the -save-stats option and returns the filename to save statistics
 /// to.
 SmallString<128> getStatsFileName(const llvm::opt::ArgList ,
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -84,6 +84,31 @@
   }
 }
 
+std::vector
+tools::unifyTargetFeatures(const std::vector ) {
+  std::vector UnifiedFeatures;
+  // Find the last of each feature.
+  llvm::StringMap LastOpt;
+  for (unsigned I = 0, N = Features.size(); I < N; ++I) {
+StringRef Name = Features[I];
+assert(Name[0] == '-' || Name[0] == '+');
+LastOpt[Name.drop_front(1)] = I;
+  }
+
+  for (unsigned I = 0, N = Features.size(); I < N; ++I) {
+// If this feature was overridden, ignore it.
+StringRef Name = Features[I];
+llvm::StringMap::iterator LastI = LastOpt.find(Name.drop_front(1));
+assert(LastI != LastOpt.end());
+unsigned Last = LastI->second;
+if (Last != I)
+  continue;
+
+UnifiedFeatures.push_back(Name);
+  }
+  return UnifiedFeatures;
+}
+
 void tools::addDirectoryList(const ArgList , ArgStringList ,
  const char *ArgName, const char *EnvVar) {
   const char *DirList = ::getenv(EnvVar);
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -374,25 +374,9 @@
 ve::getVETargetFeatures(D, Args, Features);
   }
 
-  // Find the last of each feature.
-  llvm::StringMap LastOpt;
-  for (unsigned I = 0, N = Features.size(); I < N; ++I) {
-StringRef Name = Features[I];
-assert(Name[0] == '-' || Name[0] == '+');
-LastOpt[Name.drop_front(1)] = I;
-  }
-
-  for (unsigned I = 0, N = Features.size(); I < N; ++I) {
-// If this feature was overridden, ignore it.
-StringRef Name = Features[I];
-llvm::StringMap::iterator LastI = LastOpt.find(Name.drop_front(1));
-assert(LastI != LastOpt.end());
-unsigned Last = LastI->second;
-if (Last != I)
-  continue;
-
+  for (auto Feature : unifyTargetFeatures(Features)) {
 CmdArgs.push_back(IsAux ? "-aux-target-feature" : "-target-feature");
-CmdArgs.push_back(Name.data());
+CmdArgs.push_back(Feature.data());
   }
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D82623: [sve][acle] Enable feature macros for SVE ACLE extensions.

2020-06-25 Thread Francesco Petrogalli via Phabricator via cfe-commits
fpetrogalli added a comment.

Reviewers, I have added 2 parent revision with the last two set of intrinsics 
that are enabled by the macro introduced in this patch. I will update those 
tests in this patch once the patches are in. Meanwhile, please double check 
that my interpretation of the feature macros and relative target feature flags 
is correct.

Grazie,

Francesco


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82623/new/

https://reviews.llvm.org/D82623



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


[PATCH] D82623: [sve][acle] Enable feature macros for SVE ACLE extensions.

2020-06-25 Thread Francesco Petrogalli via Phabricator via cfe-commits
fpetrogalli created this revision.
fpetrogalli added reviewers: sdesmalen, efriedma, c-rhodes, kmclaughlin, 
SjoerdMeijer.
Herald added subscribers: cfe-commits, psnobl, rkruppe, kristof.beyls, tschuett.
Herald added a reviewer: rengolin.
Herald added a project: clang.
fpetrogalli added parent revisions: D82345: [sve][acle] Implement some of the C 
intrinsics for brain float., D82501: [sve][acle] Add reinterpret intrinsics for 
brain float..
fpetrogalli added a comment.

Reviewers, I have added 2 parent revision with the last two set of intrinsics 
that are enabled by the macro introduced in this patch. I will update those 
tests in this patch once the patches are in. Meanwhile, please double check 
that my interpretation of the feature macros and relative target feature flags 
is correct.

Grazie,

Francesco


The following feature macros have been added:

__ARM_FEATURE_SVE_BF16

__ARM_FEATURE_SVE_MATMUL_INT8

__ARM_FEATURE_SVE_MATMUL_FP32

__ARM_FEATURE_SVE_MATMUL_FP64

The driver has been updated to enable them accordingly to the value of
the target feature passed at command line.

The SVE ACLE tests using the macros have been modified to work with
the target feature instead of passing the macro at command line.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D82623

Files:
  clang/lib/Basic/Targets/AArch64.cpp
  clang/lib/Basic/Targets/AArch64.h
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_bfdot.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_bfmlalb.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_bfmlalt.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_bfmmla.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cnt-bfloat.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cvt-bfloat.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cvtnt.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ld1-bfloat.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ld1ro-bfloat.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ld1ro.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ld1rq-bfloat.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ld2-bfloat.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ld3-bfloat.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ld4-bfloat.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ldff1-bfloat.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ldnf1-bfloat.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ldnt1-bfloat.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_len-bfloat.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_matmul_fp32.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_matmul_fp64.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_mmla.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_rev-bfloat.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_sel-bfloat.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_splice-bfloat.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_st2-bfloat.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_st3-bfloat.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_st4-bfloat.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_sudot.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_tbl-bfloat.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_trn1-bfloat.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_trn1-fp64-bfloat.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_trn1-fp64.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_trn2-bfloat.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_trn2-fp64-bfloat.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_trn2-fp64.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_usdot.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_uzp1-bfloat.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_uzp1-fp64-bfloat.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_uzp1-fp64.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_uzp2-bfloat.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_uzp2-fp64-bfloat.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_uzp2-fp64.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_zip1-bfloat.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_zip1-fp64-bfloat.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_zip1-fp64.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_zip2-bfloat.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_zip2-fp64-bfloat.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_zip2-fp64.c
  clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_tbl2-bfloat.c
  clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_tbx-bfloat.c
  clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_whilerw-bfloat.c
  clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_whilewr-bfloat.c
  clang/test/Preprocessor/aarch64-target-features.c

Index: clang/test/Preprocessor/aarch64-target-features.c

[clang] ed398c3 - [NFC] Extract unifyTargetFeatures

2020-06-25 Thread Yaxun Liu via cfe-commits

Author: Yaxun (Sam) Liu
Date: 2020-06-25T23:17:08-04:00
New Revision: ed398c3ca404f9ec50b134863a227555a9e374df

URL: 
https://github.com/llvm/llvm-project/commit/ed398c3ca404f9ec50b134863a227555a9e374df
DIFF: 
https://github.com/llvm/llvm-project/commit/ed398c3ca404f9ec50b134863a227555a9e374df.diff

LOG: [NFC] Extract unifyTargetFeatures

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Driver/ToolChains/CommonArgs.cpp
clang/lib/Driver/ToolChains/CommonArgs.h
clang/test/Driver/hip-toolchain-features.hip

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index d908e0039db7..8903641a26c6 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -374,25 +374,9 @@ static void getTargetFeatures(const Driver , const 
llvm::Triple ,
 ve::getVETargetFeatures(D, Args, Features);
   }
 
-  // Find the last of each feature.
-  llvm::StringMap LastOpt;
-  for (unsigned I = 0, N = Features.size(); I < N; ++I) {
-StringRef Name = Features[I];
-assert(Name[0] == '-' || Name[0] == '+');
-LastOpt[Name.drop_front(1)] = I;
-  }
-
-  for (unsigned I = 0, N = Features.size(); I < N; ++I) {
-// If this feature was overridden, ignore it.
-StringRef Name = Features[I];
-llvm::StringMap::iterator LastI = 
LastOpt.find(Name.drop_front(1));
-assert(LastI != LastOpt.end());
-unsigned Last = LastI->second;
-if (Last != I)
-  continue;
-
+  for (auto Feature : unifyTargetFeatures(Features)) {
 CmdArgs.push_back(IsAux ? "-aux-target-feature" : "-target-feature");
-CmdArgs.push_back(Name.data());
+CmdArgs.push_back(Feature.data());
   }
 }
 

diff  --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp 
b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index 2a9d7e30a461..976db3feb9fc 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -84,6 +84,31 @@ void tools::handleTargetFeaturesGroup(const ArgList ,
   }
 }
 
+std::vector
+tools::unifyTargetFeatures(const std::vector ) {
+  std::vector UnifiedFeatures;
+  // Find the last of each feature.
+  llvm::StringMap LastOpt;
+  for (unsigned I = 0, N = Features.size(); I < N; ++I) {
+StringRef Name = Features[I];
+assert(Name[0] == '-' || Name[0] == '+');
+LastOpt[Name.drop_front(1)] = I;
+  }
+
+  for (unsigned I = 0, N = Features.size(); I < N; ++I) {
+// If this feature was overridden, ignore it.
+StringRef Name = Features[I];
+llvm::StringMap::iterator LastI = 
LastOpt.find(Name.drop_front(1));
+assert(LastI != LastOpt.end());
+unsigned Last = LastI->second;
+if (Last != I)
+  continue;
+
+UnifiedFeatures.push_back(Name);
+  }
+  return UnifiedFeatures;
+}
+
 void tools::addDirectoryList(const ArgList , ArgStringList ,
  const char *ArgName, const char *EnvVar) {
   const char *DirList = ::getenv(EnvVar);

diff  --git a/clang/lib/Driver/ToolChains/CommonArgs.h 
b/clang/lib/Driver/ToolChains/CommonArgs.h
index c7d695ebf415..29dedec9b09c 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.h
+++ b/clang/lib/Driver/ToolChains/CommonArgs.h
@@ -106,10 +106,20 @@ void AddTargetFeature(const llvm::opt::ArgList ,
 std::string getCPUName(const llvm::opt::ArgList , const llvm::Triple ,
bool FromAs = false);
 
+/// Iterate \p Args and convert -mxxx to +xxx and -mno-xxx to -xxx and
+/// append it to \p Features.
+///
+/// Note: Since \p Features may contain default values before calling
+/// this function, or may be appended with entries to override arguments,
+/// entries in \p Features are not unique.
 void handleTargetFeaturesGroup(const llvm::opt::ArgList ,
std::vector ,
llvm::opt::OptSpecifier Group);
 
+/// If there are multiple +xxx or -xxx features, keep the last one.
+std::vector
+unifyTargetFeatures(const std::vector );
+
 /// Handles the -save-stats option and returns the filename to save statistics
 /// to.
 SmallString<128> getStatsFileName(const llvm::opt::ArgList ,

diff  --git a/clang/test/Driver/hip-toolchain-features.hip 
b/clang/test/Driver/hip-toolchain-features.hip
index 3b90d4101ee3..d45a7129f793 100644
--- a/clang/test/Driver/hip-toolchain-features.hip
+++ b/clang/test/Driver/hip-toolchain-features.hip
@@ -35,3 +35,13 @@
 
 // ALL3: {{.*}}clang{{.*}}"-target-feature" "+xnack" "-target-feature" 
"+sram-ecc"
 // NOALL3: {{.*}}clang{{.*}}"-target-feature" "-xnack" "-target-feature" 
"-sram-ecc"
+
+// RUN: %clang -### -target x86_64-linux-gnu -fgpu-rdc -nogpulib \
+// RUN:   --cuda-gpu-arch=gfx1010 %s \
+// RUN:   -mcumode -mcumode -mno-cumode -mwavefrontsize64 -mcumode \
+// RUN:   -mwavefrontsize64 -mno-wavefrontsize64 2>&1 \
+// RUN:   | FileCheck 

[PATCH] D82620: [clang-format] Preserve whitespace in selected macros

2020-06-25 Thread Jake Merdich via Phabricator via cfe-commits
JakeMerdichAMD created this revision.
Herald added subscribers: cfe-commits, kristof.beyls.
Herald added a project: clang.
JakeMerdichAMD added reviewers: MyDeveloperDay, curdeius, sammccall, jbcoe.
JakeMerdichAMD added a project: clang-format.

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

When the c preprocessor stringizes tokens, the generated string literals
are affected by the whitespace. This means clang-format can affect
codegen silently, adding spaces and newlines to strings.  Practically
speaking, the vast majority of cases will be harmless, only affecting
single identifiers or debug macros.

In the interest of doing no harm in other cases though, this introduces
a blacklist option 'WhitespaceSensitiveMacros', which contains a list of
names of function-like macros whose contents should not be touched by
clang-format, period. Clang-format can't automatically detect these
without a real compile context, so users will have to specify it
explicitly (it still beats clang-format off'ing at every invocation).

I added one default, "STRINGIZE", but am not particularly attached to
it, nor have I given much thought to defaults.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D82620

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/include/clang/Format/Format.h
  clang/lib/Format/Format.cpp
  clang/lib/Format/FormatToken.h
  clang/lib/Format/FormatTokenLexer.cpp
  clang/lib/Format/TokenAnnotator.cpp
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -13957,6 +13957,13 @@
   CHECK_PARSE("NamespaceMacros: [TESTSUITE, SUITE]", NamespaceMacros,
   std::vector({"TESTSUITE", "SUITE"}));
 
+  Style.WhitespaceSensitiveMacros.clear();
+  CHECK_PARSE("WhitespaceSensitiveMacros: [STRINGIZE]",
+  WhitespaceSensitiveMacros, std::vector{"STRINGIZE"});
+  CHECK_PARSE("WhitespaceSensitiveMacros: [STRINGIZE, ASSERT]",
+  WhitespaceSensitiveMacros,
+  std::vector({"STRINGIZE", "ASSERT"}));
+
   Style.IncludeStyle.IncludeCategories.clear();
   std::vector ExpectedCategories = {
   {"abc/.*", 2, 0}, {".*", 1, 0}};
@@ -16466,6 +16473,33 @@
   verifyFormat("foo(operator, , -42);", Style);
 }
 
+TEST_F(FormatTest, WhitespaceSensitiveMacros) {
+  FormatStyle Style = getLLVMStyle();
+  Style.WhitespaceSensitiveMacros.push_back("FOO");
+
+  // Don't use the helpers here, since 'mess up' will change the whitespace
+  // and these are all whitespace sensitive by definition
+  EXPECT_EQ("FOO(String-ized+But(: :Still)=Intentional);",
+format("FOO(String-ized+But(: :Still)=Intentional);", Style));
+  EXPECT_EQ("FOO(String-ized+But,: :Still=Intentional);",
+format("FOO(String-ized+But,: :Still=Intentional);", Style));
+  EXPECT_EQ("FOO(String-ized+But,: :\n"
+"   Still=Intentional);",
+format("FOO(String-ized+But,: :\n"
+   "   Still=Intentional);",
+   Style));
+  Style.AlignConsecutiveAssignments = true;
+  EXPECT_EQ("FOO(String-ized=+But,: :\n"
+"   Still=Intentional);",
+format("FOO(String-ized=+But,: :\n"
+   "   Still=Intentional);",
+   Style));
+
+  Style.ColumnLimit = 21;
+  EXPECT_EQ("FOO(String-ized+But: :Still=Intentional);",
+format("FOO(String-ized+But: :Still=Intentional);", Style));
+}
+
 TEST_F(FormatTest, VeryLongNamespaceCommentSplit) {
   // These tests are not in NamespaceFixer because that doesn't
   // test its interaction with line wrapping
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -160,6 +160,27 @@
 return false;
   }
 
+  bool parseUntouchableParens() {
+while (CurrentToken) {
+  CurrentToken->Finalized = true;
+  switch (CurrentToken->Tok.getKind()) {
+  case tok::l_paren:
+next();
+if (!parseUntouchableParens())
+  return false;
+continue;
+  case tok::r_paren:
+next();
+return true;
+  default:
+// no-op
+break;
+  }
+  next();
+}
+return false;
+  }
+
   bool parseParens(bool LookForDecls = false) {
 if (!CurrentToken)
   return false;
@@ -171,6 +192,11 @@
 Contexts.back().ColonIsForRangeExpr =
 Contexts.size() == 2 && Contexts[0].ColonIsForRangeExpr;
 
+if (Left->Previous && Left->Previous->is(TT_UntouchableMacroFunc)) {
+  Left->Finalized = true;
+  return parseUntouchableParens();
+}
+
 bool StartsObjCMethodExpr = false;
 if (FormatToken *MaybeSel = Left->Previous) {
   // @selector( starts a selector.
@@ -1311,7 +1337,7 @@
 TT_TypenameMacro, TT_FunctionLBrace, 

[PATCH] D80970: [PowerPC][Power10] Implement centrifuge, vector gather every nth bit, vector evaluate Builtins in LLVM/Clang

2020-06-25 Thread Amy Kwan via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe0c02dc9800e: [PowerPC][Power10] Implement centrifuge, 
vector gather every nth bit, vector… (authored by amyk).

Changed prior to commit:
  https://reviews.llvm.org/D80970?vs=267775=273581#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D80970/new/

https://reviews.llvm.org/D80970

Files:
  clang/include/clang/Basic/BuiltinsPPC.def
  clang/lib/Headers/altivec.h
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/builtins-ppc-p10.c
  clang/test/CodeGen/builtins-ppc-p10vector.c
  llvm/include/llvm/IR/IntrinsicsPowerPC.td
  llvm/lib/Target/PowerPC/PPCInstrPrefix.td
  llvm/test/CodeGen/PowerPC/p10-bit-manip-ops.ll
  llvm/test/MC/Disassembler/PowerPC/p10insts.txt
  llvm/test/MC/PowerPC/p10.s

Index: llvm/test/MC/PowerPC/p10.s
===
--- llvm/test/MC/PowerPC/p10.s
+++ llvm/test/MC/PowerPC/p10.s
@@ -15,6 +15,20 @@
 # CHECK-BE: pextd 1, 2, 4 # encoding: [0x7c,0x41,0x21,0x78]
 # CHECK-LE: pextd 1, 2, 4 # encoding: [0x78,0x21,0x41,0x7c]
 pextd 1, 2, 4
+# CHECK-BE: vcfuged 1, 2, 4   # encoding: [0x10,0x22,0x25,0x4d]
+# CHECK-LE: vcfuged 1, 2, 4   # encoding: [0x4d,0x25,0x22,0x10]
+vcfuged 1, 2, 4
+# CHECK-BE: cfuged 1, 2, 4# encoding: [0x7c,0x41,0x21,0xb8]
+# CHECK-LE: cfuged 1, 2, 4# encoding: [0xb8,0x21,0x41,0x7c]
+cfuged 1, 2, 4
+# CHECK-BE: vgnb 1, 2, 2  # encoding: [0x10,0x22,0x14,0xcc]
+# CHECK-LE: vgnb 1, 2, 2  # encoding: [0xcc,0x14,0x22,0x10]
+vgnb 1, 2, 2
+# CHECK-BE: xxeval 32, 1, 2, 3, 2 # encoding: [0x05,0x00,0x00,0x02,
+# CHECK-BE-SAME:   0x88,0x01,0x10,0xd1]
+# CHECK-LE: xxeval 32, 1, 2, 3, 2 # encoding: [0x02,0x00,0x00,0x05,
+# CHECK-LE-SAME:   0xd1,0x10,0x01,0x88]
+xxeval 32, 1, 2, 3, 2
 # CHECK-BE: vclzdm 1, 2, 3# encoding: [0x10,0x22,0x1f,0x84]
 # CHECK-LE: vclzdm 1, 2, 3# encoding: [0x84,0x1f,0x22,0x10]
 vclzdm 1, 2, 3
Index: llvm/test/MC/Disassembler/PowerPC/p10insts.txt
===
--- llvm/test/MC/Disassembler/PowerPC/p10insts.txt
+++ llvm/test/MC/Disassembler/PowerPC/p10insts.txt
@@ -13,6 +13,18 @@
 # CHECK: pextd 1, 2, 4
 0x7c 0x41 0x21 0x78
 
+# CHECK: vcfuged 1, 2, 4
+0x10 0x22 0x25 0x4d
+
+# CHECK: cfuged 1, 2, 4
+0x7c 0x41 0x21 0xb8
+
+# CHECK: vgnb 1, 2, 2
+0x10 0x22 0x14 0xcc
+
+# CHECK: xxeval 32, 1, 2, 3, 2
+0x05 0x00 0x00 0x02 0x88 0x01 0x10 0xd1
+
 # CHECK: vclzdm 1, 2, 3
 0x10 0x22 0x1f 0x84
 
Index: llvm/test/CodeGen/PowerPC/p10-bit-manip-ops.ll
===
--- llvm/test/CodeGen/PowerPC/p10-bit-manip-ops.ll
+++ llvm/test/CodeGen/PowerPC/p10-bit-manip-ops.ll
@@ -9,6 +9,10 @@
 declare <2 x i64> @llvm.ppc.altivec.vpextd(<2 x i64>, <2 x i64>)
 declare i64 @llvm.ppc.pdepd(i64, i64)
 declare i64 @llvm.ppc.pextd(i64, i64)
+declare <2 x i64> @llvm.ppc.altivec.vcfuged(<2 x i64>, <2 x i64>)
+declare i64 @llvm.ppc.cfuged(i64, i64)
+declare i64 @llvm.ppc.altivec.vgnb(<1 x i128>, i32)
+declare <2 x i64> @llvm.ppc.vsx.xxeval(<2 x i64>, <2 x i64>, <2 x i64>, i32)
 declare <2 x i64> @llvm.ppc.altivec.vclzdm(<2 x i64>, <2 x i64>)
 declare <2 x i64> @llvm.ppc.altivec.vctzdm(<2 x i64>, <2 x i64>)
 declare i64 @llvm.ppc.cntlzdm(i64, i64)
@@ -54,6 +58,66 @@
   ret i64 %tmp
 }
 
+define <2 x i64> @test_vcfuged(<2 x i64> %a, <2 x i64> %b) {
+; CHECK-LABEL: test_vcfuged:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:vcfuged v2, v2, v3
+; CHECK-NEXT:blr
+entry:
+  %tmp = tail call <2 x i64> @llvm.ppc.altivec.vcfuged(<2 x i64> %a, <2 x i64> %b)
+  ret <2 x i64> %tmp
+}
+
+define i64 @test_cfuged(i64 %a, i64 %b) {
+; CHECK-LABEL: test_cfuged:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:cfuged r3, r3, r4
+; CHECK-NEXT:blr
+entry:
+  %tmp = tail call i64 @llvm.ppc.cfuged(i64 %a, i64 %b)
+  ret i64 %tmp
+}
+
+define i64 @test_vgnb_1(<1 x i128> %a) {
+; CHECK-LABEL: test_vgnb_1:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:vgnb r3, v2, 2
+; CHECK-NEXT:blr
+entry:
+  %tmp = tail call i64 @llvm.ppc.altivec.vgnb(<1 x i128> %a, i32 2)
+  ret i64 %tmp
+}
+
+define i64 @test_vgnb_2(<1 x i128> %a) {
+; CHECK-LABEL: test_vgnb_2:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:vgnb r3, v2, 7
+; CHECK-NEXT:blr
+entry:
+  %tmp = tail call i64 @llvm.ppc.altivec.vgnb(<1 x i128> %a, i32 7)
+  ret i64 %tmp
+}
+
+define i64 @test_vgnb_3(<1 x i128> %a) {
+; CHECK-LABEL: test_vgnb_3:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:vgnb r3, v2, 5
+; 

[clang] e0c02dc - [PowerPC][Power10] Implement centrifuge, vector gather every nth bit, vector evaluate Builtins in LLVM/Clang

2020-06-25 Thread Amy Kwan via cfe-commits

Author: Amy Kwan
Date: 2020-06-25T21:34:41-05:00
New Revision: e0c02dc9800ebd317d1369848f4e74c8f783533a

URL: 
https://github.com/llvm/llvm-project/commit/e0c02dc9800ebd317d1369848f4e74c8f783533a
DIFF: 
https://github.com/llvm/llvm-project/commit/e0c02dc9800ebd317d1369848f4e74c8f783533a.diff

LOG: [PowerPC][Power10] Implement centrifuge, vector gather every nth bit, 
vector evaluate Builtins in LLVM/Clang

This patch implements builtins for the following prototypes:

unsigned long long __builtin_cfuged (unsigned long long, unsigned long long);
vector unsigned long long vec_cfuge (vector unsigned long long, vector unsigned 
long long);
unsigned long long vec_gnb (vector unsigned __int128, const unsigned int);
vector unsigned char vec_ternarylogic (vector unsigned char, vector unsigned 
char, vector unsigned char, const unsigned int);
vector unsigned short vec_ternarylogic (vector unsigned short, vector unsigned 
short, vector unsigned short, const unsigned int);
vector unsigned int vec_ternarylogic (vector unsigned int, vector unsigned int, 
vector unsigned int, const unsigned int);
vector unsigned long long vec_ternarylogic (vector unsigned long long, vector 
unsigned long long, vector unsigned long long, const unsigned int);
vector unsigned __int128 vec_ternarylogic (vector unsigned __int128, vector 
unsigned __int128, vector unsigned __int128, const unsigned int);

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

Added: 


Modified: 
clang/include/clang/Basic/BuiltinsPPC.def
clang/lib/Headers/altivec.h
clang/lib/Sema/SemaChecking.cpp
clang/test/CodeGen/builtins-ppc-p10.c
clang/test/CodeGen/builtins-ppc-p10vector.c
llvm/include/llvm/IR/IntrinsicsPowerPC.td
llvm/lib/Target/PowerPC/PPCInstrPrefix.td
llvm/test/CodeGen/PowerPC/p10-bit-manip-ops.ll
llvm/test/MC/Disassembler/PowerPC/p10insts.txt
llvm/test/MC/PowerPC/p10.s

Removed: 




diff  --git a/clang/include/clang/Basic/BuiltinsPPC.def 
b/clang/include/clang/Basic/BuiltinsPPC.def
index 5bc41c9d6cea..fa5b0b9d0920 100644
--- a/clang/include/clang/Basic/BuiltinsPPC.def
+++ b/clang/include/clang/Basic/BuiltinsPPC.def
@@ -302,6 +302,12 @@ BUILTIN(__builtin_altivec_vrldnm, "V2ULLiV2ULLiV2ULLi", "")
 BUILTIN(__builtin_altivec_vpdepd, "V2ULLiV2ULLiV2ULLi", "")
 BUILTIN(__builtin_altivec_vpextd, "V2ULLiV2ULLiV2ULLi", "")
 
+// P10 Vector Centrifuge built-in.
+BUILTIN(__builtin_altivec_vcfuged, "V2ULLiV2ULLiV2ULLi", "")
+
+// P10 Vector Gather Every N-th Bit built-in.
+BUILTIN(__builtin_altivec_vgnb, "ULLiV1ULLLiIi", "")
+
 // P10 Vector Clear Bytes built-ins.
 BUILTIN(__builtin_altivec_vclrlb, "V16cV16cUi", "")
 BUILTIN(__builtin_altivec_vclrrb, "V16cV16cUi", "")
@@ -439,6 +445,8 @@ BUILTIN(__builtin_vsx_extractuword, "V2ULLiV16UcIi", "")
 BUILTIN(__builtin_vsx_xxpermdi, "v.", "t")
 BUILTIN(__builtin_vsx_xxsldwi, "v.", "t")
 
+BUILTIN(__builtin_vsx_xxeval, "V2ULLiV2ULLiV2ULLiV2ULLiIi", "")
+
 // Float 128 built-ins
 BUILTIN(__builtin_sqrtf128_round_to_odd, "LLdLLd", "")
 BUILTIN(__builtin_addf128_round_to_odd, "LLdLLdLLd", "")
@@ -489,6 +497,7 @@ BUILTIN(__builtin_divdeu, "ULLiULLiULLi", "")
 BUILTIN(__builtin_bpermd, "SLLiSLLiSLLi", "")
 BUILTIN(__builtin_pdepd, "ULLiULLiULLi", "")
 BUILTIN(__builtin_pextd, "ULLiULLiULLi", "")
+BUILTIN(__builtin_cfuged, "ULLiULLiULLi", "")
 BUILTIN(__builtin_cntlzdm, "ULLiULLiULLi", "")
 BUILTIN(__builtin_cnttzdm, "ULLiULLiULLi", "")
 

diff  --git a/clang/lib/Headers/altivec.h b/clang/lib/Headers/altivec.h
index f9fd3e2e50eb..91279119630d 100644
--- a/clang/lib/Headers/altivec.h
+++ b/clang/lib/Headers/altivec.h
@@ -16777,6 +16777,42 @@ vec_pext(vector unsigned long long __a, vector 
unsigned long long __b) {
   return __builtin_altivec_vpextd(__a, __b);
 }
 
+/* vec_cfuge */
+
+static __inline__ vector unsigned long long __ATTRS_o_ai
+vec_cfuge(vector unsigned long long __a, vector unsigned long long __b) {
+  return __builtin_altivec_vcfuged(__a, __b);
+}
+
+/* vec_gnb */
+
+#define vec_gnb(__a, __b) __builtin_altivec_vgnb(__a, __b)
+
+/* vec_ternarylogic */
+#ifdef __VSX__
+#define vec_ternarylogic(__a, __b, __c, __imm) 
\
+  _Generic((__a), vector unsigned char 
\
+   : __builtin_vsx_xxeval((vector unsigned long long)(__a),
\
+  (vector unsigned long long)(__b),
\
+  (vector unsigned long long)(__c), (__imm)),  
\
+ vector unsigned short 
\
+   : __builtin_vsx_xxeval((vector unsigned long long)(__a),
\
+  (vector unsigned long long)(__b),
\
+  (vector unsigned long long)(__c), (__imm)),  
\
+ vector unsigned int   
\
+

[clang] 0723b18 - [hip] Re-enable `clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu`

2020-06-25 Thread Michael Liao via cfe-commits

Author: Michael Liao
Date: 2020-06-25T22:29:27-04:00
New Revision: 0723b1891fac8f79f92549e3bcac9112be4ebd43

URL: 
https://github.com/llvm/llvm-project/commit/0723b1891fac8f79f92549e3bcac9112be4ebd43
DIFF: 
https://github.com/llvm/llvm-project/commit/0723b1891fac8f79f92549e3bcac9112be4ebd43.diff

LOG: [hip] Re-enable `clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu`

- Require amdgpu target being enabled.

Added: 


Modified: 
clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu

Removed: 




diff  --git a/clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu 
b/clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu
index 3021e73780f4..99284c04e5cc 100644
--- a/clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu
+++ b/clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu
@@ -1,4 +1,4 @@
-// XFAIL: *
+// REQUIRES: amdgpu-registered-target
 // RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -fcuda-is-device -emit-llvm -x 
hip %s -o - | FileCheck --check-prefixes=COMMON,CHECK %s
 // RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -fcuda-is-device -emit-llvm -x 
hip %s -disable-O0-optnone -o - | opt -S -O2 | FileCheck %s 
--check-prefixes=COMMON,OPT
 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -x hip %s -o - 
| FileCheck -check-prefix=HOST %s



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


[PATCH] D82609: [PowerPC][Power10] Implement Vector Multiply High/Divide Extended Builtins in LLVM/Clang

2020-06-25 Thread Amy Kwan via Phabricator via cfe-commits
amyk updated this revision to Diff 273578.
amyk added a comment.

Addressed Anil's comments.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82609/new/

https://reviews.llvm.org/D82609

Files:
  clang/include/clang/Basic/BuiltinsPPC.def
  clang/lib/Headers/altivec.h
  clang/test/CodeGen/builtins-ppc-p10vector.c
  llvm/include/llvm/IR/IntrinsicsPowerPC.td
  llvm/lib/Target/PowerPC/PPCInstrPrefix.td
  llvm/test/CodeGen/PowerPC/p10-vector-divide.ll
  llvm/test/CodeGen/PowerPC/p10-vector-multiply.ll
  llvm/test/MC/Disassembler/PowerPC/p10insts.txt
  llvm/test/MC/PowerPC/p10.s

Index: llvm/test/MC/PowerPC/p10.s
===
--- llvm/test/MC/PowerPC/p10.s
+++ llvm/test/MC/PowerPC/p10.s
@@ -84,3 +84,15 @@
 # CHECK-BE: vmulhud 1, 2, 3   # encoding: [0x10,0x22,0x1a,0xc9]
 # CHECK-LE: vmulhud 1, 2, 3   # encoding: [0xc9,0x1a,0x22,0x10]
 vmulhud 1, 2, 3
+# CHECK-BE: vdivesw 21, 11, 10# encoding: [0x12,0xab,0x53,0x8b]
+# CHECK-LE: vdivesw 21, 11, 10# encoding: [0x8b,0x53,0xab,0x12]
+vdivesw 21, 11, 10
+# CHECK-BE: vdiveuw 21, 11, 10# encoding: [0x12,0xab,0x52,0x8b]
+# CHECK-LE: vdiveuw 21, 11, 10# encoding: [0x8b,0x52,0xab,0x12]
+vdiveuw 21, 11, 10
+# CHECK-BE: vdivesd 21, 11, 10# encoding: [0x12,0xab,0x53,0xcb]
+# CHECK-LE: vdivesd 21, 11, 10# encoding: [0xcb,0x53,0xab,0x12]
+vdivesd 21, 11, 10
+# CHECK-BE: vdiveud 21, 11, 10# encoding: [0x12,0xab,0x52,0xcb]
+# CHECK-LE: vdiveud 21, 11, 10# encoding: [0xcb,0x52,0xab,0x12]
+vdiveud 21, 11, 10
Index: llvm/test/MC/Disassembler/PowerPC/p10insts.txt
===
--- llvm/test/MC/Disassembler/PowerPC/p10insts.txt
+++ llvm/test/MC/Disassembler/PowerPC/p10insts.txt
@@ -81,3 +81,15 @@
 
 # CHECK: vmulhud 1, 2, 3
 0x10 0x22 0x1a 0xc9
+
+# CHECK: vdivesw 21, 11, 10
+0x12 0xab 0x53 0x8b
+
+# CHECK: vdiveuw 21, 11, 10
+0x12 0xab 0x52 0x8b
+
+# CHECK: vdivesd 21, 11, 10
+0x12 0xab 0x53 0xcb
+
+# CHECK: vdiveud 21, 11, 10
+0x12 0xab 0x52 0xcb
Index: llvm/test/CodeGen/PowerPC/p10-vector-multiply.ll
===
--- llvm/test/CodeGen/PowerPC/p10-vector-multiply.ll
+++ llvm/test/CodeGen/PowerPC/p10-vector-multiply.ll
@@ -72,3 +72,49 @@
   %tr = trunc <4 x i64> %shr to <4 x i32>
   ret <4 x i32> %tr
 }
+
+; Test the vector multiply high intrinsics.
+declare <4 x i32> @llvm.ppc.altivec.vmulhsw(<4 x i32>, <4 x i32>)
+declare <4 x i32> @llvm.ppc.altivec.vmulhuw(<4 x i32>, <4 x i32>)
+declare <2 x i64> @llvm.ppc.altivec.vmulhsd(<2 x i64>, <2 x i64>)
+declare <2 x i64> @llvm.ppc.altivec.vmulhud(<2 x i64>, <2 x i64>)
+
+define <4 x i32> @test_vmulhsw_intrinsic(<4 x i32> %a, <4 x i32> %b) {
+; CHECK-LABEL: test_vmulhsw_intrinsic:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:vmulhsw v2, v2, v3
+; CHECK-NEXT:blr
+entry:
+  %mulh = tail call <4 x i32> @llvm.ppc.altivec.vmulhsw(<4 x i32> %a, <4 x i32> %b)
+  ret <4 x i32> %mulh
+}
+
+define <4 x i32> @test_vmulhuw_intrinsic(<4 x i32> %a, <4 x i32> %b) {
+; CHECK-LABEL: test_vmulhuw_intrinsic:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:vmulhuw v2, v2, v3
+; CHECK-NEXT:blr
+entry:
+  %mulh = tail call <4 x i32> @llvm.ppc.altivec.vmulhuw(<4 x i32> %a, <4 x i32> %b)
+  ret <4 x i32> %mulh
+}
+
+define <2 x i64> @test_vmulhsd_intrinsic(<2 x i64> %a, <2 x i64> %b) {
+; CHECK-LABEL: test_vmulhsd_intrinsic:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:vmulhsd v2, v2, v3
+; CHECK-NEXT:blr
+entry:
+  %mulh = tail call <2 x i64> @llvm.ppc.altivec.vmulhsd(<2 x i64> %a, <2 x i64> %b)
+  ret <2 x i64> %mulh
+}
+
+define <2 x i64> @test_vmulhud_intrinsic(<2 x i64> %a, <2 x i64> %b) {
+; CHECK-LABEL: test_vmulhud_intrinsic:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:vmulhud v2, v2, v3
+; CHECK-NEXT:blr
+entry:
+  %mulh = tail call <2 x i64> @llvm.ppc.altivec.vmulhud(<2 x i64> %a, <2 x i64> %b)
+  ret <2 x i64> %mulh
+}
Index: llvm/test/CodeGen/PowerPC/p10-vector-divide.ll
===
--- llvm/test/CodeGen/PowerPC/p10-vector-divide.ll
+++ llvm/test/CodeGen/PowerPC/p10-vector-divide.ll
@@ -46,3 +46,49 @@
   %div = sdiv <4 x i32> %a, %b
   ret <4 x i32> %div
 }
+
+; Test the vector divide extended intrinsics.
+declare <4 x i32> @llvm.ppc.altivec.vdivesw(<4 x i32>, <4 x i32>)
+declare <4 x i32> @llvm.ppc.altivec.vdiveuw(<4 x i32>, <4 x i32>)
+declare <2 x i64> @llvm.ppc.altivec.vdivesd(<2 x i64>, <2 x i64>)
+declare <2 x i64> @llvm.ppc.altivec.vdiveud(<2 x i64>, <2 x i64>)
+
+define <4 x i32> @test_vdivesw(<4 x i32> %a, <4 x i32> %b) {
+; CHECK-LABEL: test_vdivesw:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:vdivesw v2, v2, v3
+; 

[PATCH] D79773: [clang-format] Improve clang-formats handling of concepts

2020-06-25 Thread Johel Ernesto Guerrero Peña via Phabricator via cfe-commits
JohelEGP requested changes to this revision.
JohelEGP added a comment.
This revision now requires changes to proceed.

`BreakBeforeBraces: Allman` isn't respected.

  template 
  friend constexpr auto
  operator*(const size2d& l, const units::quantity& r) noexcept(
  noexcept(l.w* r)) requires(requires { l.w* r; }) //
  {
  return size2d{l.w * r, l.h * r};
  }

When a trailing //requires-clause// is right before the function body, its 
opening brace should go on its own line, as dictated by my config file 
.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D79773/new/

https://reviews.llvm.org/D79773



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


[clang] d3f437d - [hip] Disable test temporarily due to failures on build servers.

2020-06-25 Thread Michael Liao via cfe-commits

Author: Michael Liao
Date: 2020-06-25T22:04:20-04:00
New Revision: d3f437d35189f7567294daf3e60e08326e64994a

URL: 
https://github.com/llvm/llvm-project/commit/d3f437d35189f7567294daf3e60e08326e64994a
DIFF: 
https://github.com/llvm/llvm-project/commit/d3f437d35189f7567294daf3e60e08326e64994a.diff

LOG: [hip] Disable test temporarily due to failures on build servers.

Added: 


Modified: 
clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu

Removed: 




diff  --git a/clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu 
b/clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu
index 8c102d339863..3021e73780f4 100644
--- a/clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu
+++ b/clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu
@@ -1,3 +1,4 @@
+// XFAIL: *
 // RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -fcuda-is-device -emit-llvm -x 
hip %s -o - | FileCheck --check-prefixes=COMMON,CHECK %s
 // RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -fcuda-is-device -emit-llvm -x 
hip %s -disable-O0-optnone -o - | opt -S -O2 | FileCheck %s 
--check-prefixes=COMMON,OPT
 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -x hip %s -o - 
| FileCheck -check-prefix=HOST %s



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


[PATCH] D82604: No nested namespaces in Clang-Tidy checkers

2020-06-25 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay requested changes to this revision.
MaskRay added a comment.
This revision now requires changes to proceed.

As the warnings suggest, nested name definitions can't be used because 
llvm-project is still using C++14.

`llvm.org` as a reviewer doesn't work. You can use `git log` and find active 
contributors for your patches.

Last time you closed a revision manually for a commit I pushed on your behalf - 
it is not necessary, Phabricator will close a revision automatically if a 
commit description contains `Differential Revision: `


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82604/new/

https://reviews.llvm.org/D82604



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


[PATCH] D82617: Disable GCC's -Woverloaded-virtual, which has false positives.

2020-06-25 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
sammccall added reviewers: kadircet, uabelho, bjope.
Herald added subscribers: cfe-commits, mgorny.
Herald added a project: clang.

Currently this warning is on for both clang and GCC, when building clang.
It's off for the rest of LLVM, so my sense is it isn't that vital.

Clang's version seems to be OK: it warns if you're declaring a method that's
virtual in the base, but not overriding.

GCC's version warns whenever there's name hiding, even if you are overriding
something. It fires on this legitimate pattern:

  class Base {
virtual void foo(); // to be overridden
void foo(int); // implemented in terms of foo()
  };

foo(int) is hidden in derived classes, but foo(int) is used polymorphically
through Base* and works fine there.
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=20423


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D82617

Files:
  clang/CMakeLists.txt


Index: clang/CMakeLists.txt
===
--- clang/CMakeLists.txt
+++ clang/CMakeLists.txt
@@ -393,8 +393,11 @@
 
 # Add appropriate flags for GCC
 if (LLVM_COMPILER_IS_GCC_COMPATIBLE)
-  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-common -Woverloaded-virtual")
-  if (NOT "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
+  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-common")
+  if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
+# Clang's version of -Woverloaded-virtual is OK, GCC's is too noisy.
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Woverloaded-virtual")
+  else()
 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-strict-aliasing")
   endif ()
 


Index: clang/CMakeLists.txt
===
--- clang/CMakeLists.txt
+++ clang/CMakeLists.txt
@@ -393,8 +393,11 @@
 
 # Add appropriate flags for GCC
 if (LLVM_COMPILER_IS_GCC_COMPATIBLE)
-  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-common -Woverloaded-virtual")
-  if (NOT "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
+  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-common")
+  if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
+# Clang's version of -Woverloaded-virtual is OK, GCC's is too noisy.
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Woverloaded-virtual")
+  else()
 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-strict-aliasing")
   endif ()
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D79732: AMDGPU/HIP: Don't replace pointer types in kernel argument structs

2020-06-25 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm abandoned this revision.
arsenm added a comment.

I think this is obsoleted now


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D79732/new/

https://reviews.llvm.org/D79732



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


LLVM Lab network works today at 6:30 PM PST

2020-06-25 Thread Galina Kistanova via cfe-commits
Hello everyone,


LLVM Lab will be unavailable for a short time at about 6:30 PM PST due
network maintenance.

Thank you for understanding.


Thanks


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


RE: [clang] 466e8b7 - Add StringLiteral to SyntaxTree

2020-06-25 Thread Yung, Douglas via cfe-commits
Hi Eduardo,

Your change is causing a build failure on PS4 Windows build bot, can you please 
take a look and fix it or revert the change if you cannot fix it soon so we can 
get the bot green again?

http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/33164

FAILED: 
tools/clang/unittests/Tooling/Syntax/CMakeFiles/SyntaxTests.dir/TreeTest.cpp.obj
 
C:\PROGRA~2\MIB055~1\2019\COMMUN~1\VC\Tools\MSVC\1425~1.286\bin\Hostx64\x64\cl.exe
  /nologo /TP -DBUILD_EXAMPLES -DGTEST_HAS_RTTI=0 -DGTEST_HAS_TR1_TUPLE=0 
-DGTEST_LANG_CXX11=1 -DUNICODE -D_CRT_NONSTDC_NO_DEPRECATE 
-D_CRT_NONSTDC_NO_WARNINGS -D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS 
-D_GNU_SOURCE -D_HAS_EXCEPTIONS=0 -D_SCL_SECURE_NO_DEPRECATE 
-D_SCL_SECURE_NO_WARNINGS -D_UNICODE -D__STDC_CONSTANT_MACROS 
-D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS 
-Itools\clang\unittests\Tooling\Syntax 
-IC:\ps4-buildslave2\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm-project\clang\unittests\Tooling\Syntax
 
-IC:\ps4-buildslave2\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm-project\clang\include
 -Itools\clang\include -Iinclude 
-IC:\ps4-buildslave2\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm-project\llvm\include
 
-IC:\ps4-buildslave2\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm-project\llvm\utils\unittest\googletest\include
 
-IC:\ps4-buildslave2\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm-project\llvm\utils\unittest\googlemock\include
 /DWIN32 /D_WINDOWS   /Zc:inline /Zc:strictStrings /Oi /Zc:rvalueCast /W4 
-wd4141 -wd4146 -wd4244 -wd4267 -wd4291 -wd4351 -wd4456 -wd4457 -wd4458 -wd4459 
-wd4503 -wd4624 -wd4722 -wd4100 -wd4127 -wd4512 -wd4505 -wd4610 -wd4510 -wd4702 
-wd4245 -wd4706 -wd4310 -wd4701 -wd4703 -wd4389 -wd4611 -wd4805 -wd4204 -wd4577 
-wd4091 -wd4592 -wd4319 -wd4709 -wd4324 -w14062 -we4238 /Gw /MD /O2 /Ob2
/EHs-c- /GR- -UNDEBUG -std:c++14 /showIncludes 
/Fotools\clang\unittests\Tooling\Syntax\CMakeFiles\SyntaxTests.dir\TreeTest.cpp.obj
 /Fdtools\clang\unittests\Tooling\Syntax\CMakeFiles\SyntaxTests.dir\ /FS -c 
C:\ps4-buildslave2\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm-project\clang\unittests\Tooling\Syntax\TreeTest.cpp
C:\ps4-buildslave2\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm-project\clang\unittests\Tooling\Syntax\TreeTest.cpp(1665):
 error C2017: illegal escape sequence
C:\ps4-buildslave2\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm-project\clang\unittests\Tooling\Syntax\TreeTest.cpp(1639):
 error C2146: syntax error: missing ')' before identifier 'n'
C:\ps4-buildslave2\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm-project\clang\unittests\Tooling\Syntax\TreeTest.cpp(1639):
 error C2660: 'testing::internal::GetBoolAssertionFailureMessage': function 
does not take 2 arguments
C:\ps4-buildslave2\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm-project\llvm\utils\unittest\googletest\include\gtest/internal/gtest-internal.h(226):
 note: see declaration of 'testing::internal::GetBoolAssertionFailureMessage'
C:\ps4-buildslave2\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm-project\clang\unittests\Tooling\Syntax\TreeTest.cpp(1639):
 error C2440: '': cannot convert from 'initializer list' 
to 'testing::internal::AssertHelper'
C:\ps4-buildslave2\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm-project\clang\unittests\Tooling\Syntax\TreeTest.cpp(1665):
 note: No constructor could take the source type, or constructor overload 
resolution was ambiguous
C:\ps4-buildslave2\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm-project\clang\unittests\Tooling\Syntax\TreeTest.cpp(1639):
 error C2064: term does not evaluate to a function taking 3 arguments
C:\ps4-buildslave2\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm-project\clang\unittests\Tooling\Syntax\TreeTest.cpp(1639):
 error C2146: syntax error: missing ';' before identifier 'n'
C:\ps4-buildslave2\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm-project\clang\unittests\Tooling\Syntax\TreeTest.cpp(1665):
 error C2059: syntax error: ')'
C:\ps4-buildslave2\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm-project\clang\unittests\Tooling\Syntax\TreeTest.cpp(1639):
 error C2065: 'n': undeclared identifier
C:\ps4-buildslave2\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm-project\clang\unittests\Tooling\Syntax\TreeTest.cpp(1639):
 error C2146: syntax error: missing ';' before identifier 'SyntaxTree'
C:\ps4-buildslave2\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm-project\clang\unittests\Tooling\Syntax\TreeTest.cpp(1639):
 error C2065: 'SyntaxTree': undeclared identifier
C:\ps4-buildslave2\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm-project\clang\unittests\Tooling\Syntax\TreeTest.cpp(1639):
 error C2143: syntax error: missing ';' before 'string'

Douglas Yung

-Original Message-
From: cfe-commits  On Behalf Of Eduardo 
Caldas via cfe-commits
Sent: Thursday, June 25, 2020 10:05
To: cfe-commits@lists.llvm.org

[PATCH] D81938: [InferAddressSpaces] Handle the pair of `ptrtoint`/`inttoptr`.

2020-06-25 Thread Michael Liao via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGdccfaacf93e1: [InferAddressSpaces] Handle the pair of 
`ptrtoint`/`inttoptr`. (authored by hliao).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81938/new/

https://reviews.llvm.org/D81938

Files:
  clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu
  llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp
  llvm/test/Transforms/InferAddressSpaces/AMDGPU/noop-ptrint-pair.ll

Index: llvm/test/Transforms/InferAddressSpaces/AMDGPU/noop-ptrint-pair.ll
===
--- /dev/null
+++ llvm/test/Transforms/InferAddressSpaces/AMDGPU/noop-ptrint-pair.ll
@@ -0,0 +1,101 @@
+; RUN: opt -mtriple=amdgcn-amd-amdhsa -S -o - -infer-address-spaces %s | FileCheck -check-prefixes=COMMON,AMDGCN %s
+; RUN: opt -S -o - -infer-address-spaces -assume-default-is-flat-addrspace %s | FileCheck -check-prefixes=COMMON,NOTTI %s
+
+target datalayout = "e-p:64:64-p1:64:64-p2:32:32-p3:32:32-p4:64:64-p5:32:32-p6:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-S32-A5-ni:7"
+
+; COMMON-LABEL: @noop_ptrint_pair(
+; AMDGCN-NEXT: store i32 0, i32 addrspace(1)* %{{.*}}
+; AMDGCN-NEXT: ret void
+; NOTTI-NEXT: %1 = ptrtoint i32 addrspace(1)* %x.coerce to i64
+; NOTTI-NEXT: %2 = inttoptr i64 %1 to i32*
+; NOTTI-NEXT: store i32 0, i32* %2
+; NOTTI-NEXT: ret void
+define void @noop_ptrint_pair(i32 addrspace(1)* %x.coerce) {
+  %1 = ptrtoint i32 addrspace(1)* %x.coerce to i64
+  %2 = inttoptr i64 %1 to i32*
+  store i32 0, i32* %2
+  ret void
+}
+
+; COMMON-LABEL: @non_noop_ptrint_pair(
+; AMDGCN-NEXT: ptrtoint i32 addrspace(3)* %{{.*}} to i64
+; AMDGCN-NEXT: inttoptr i64 %{{.*}} to i32*
+; AMDGCN-NEXT: store i32 0, i32* %{{.*}}
+; AMDGCN-NEXT: ret void
+; NOTTI-NEXT: ptrtoint i32 addrspace(3)* %{{.*}} to i64
+; NOTTI-NEXT: inttoptr i64 %{{.*}} to i32*
+; NOTTI-NEXT: store i32 0, i32* %{{.*}}
+; NOTTI-NEXT: ret void
+define void @non_noop_ptrint_pair(i32 addrspace(3)* %x.coerce) {
+  %1 = ptrtoint i32 addrspace(3)* %x.coerce to i64
+  %2 = inttoptr i64 %1 to i32*
+  store i32 0, i32* %2
+  ret void
+}
+
+; COMMON-LABEL: @non_noop_ptrint_pair2(
+; AMDGCN-NEXT: ptrtoint i32 addrspace(1)* %{{.*}} to i32
+; AMDGCN-NEXT: inttoptr i32 %{{.*}} to i32*
+; AMDGCN-NEXT: store i32 0, i32* %{{.*}}
+; AMDGCN-NEXT: ret void
+; NOTTI-NEXT: ptrtoint i32 addrspace(1)* %{{.*}} to i32
+; NOTTI-NEXT: inttoptr i32 %{{.*}} to i32*
+; NOTTI-NEXT: store i32 0, i32* %{{.*}}
+; NOTTI-NEXT: ret void
+define void @non_noop_ptrint_pair2(i32 addrspace(1)* %x.coerce) {
+  %1 = ptrtoint i32 addrspace(1)* %x.coerce to i32
+  %2 = inttoptr i32 %1 to i32*
+  store i32 0, i32* %2
+  ret void
+}
+
+@g = addrspace(1) global i32 0, align 4
+@l = addrspace(3) global i32 0, align 4
+
+; COMMON-LABEL: @noop_ptrint_pair_ce(
+; AMDGCN-NEXT: store i32 0, i32 addrspace(1)* @g
+; AMDGCN-NEXT: ret void
+; NOTTI-NEXT: store i32 0, i32* inttoptr (i64 ptrtoint (i32 addrspace(1)* @g to i64) to i32*)
+; NOTTI-NEXT: ret void
+define void @noop_ptrint_pair_ce() {
+  store i32 0, i32* inttoptr (i64 ptrtoint (i32 addrspace(1)* @g to i64) to i32*)
+  ret void
+}
+
+; COMMON-LABEL: @noop_ptrint_pair_ce2(
+; AMDGCN-NEXT: ret i32* addrspacecast (i32 addrspace(1)* @g to i32*)
+; NOTTI-NEXT: ret i32* inttoptr (i64 ptrtoint (i32 addrspace(1)* @g to i64) to i32*)
+define i32* @noop_ptrint_pair_ce2() {
+  ret i32* inttoptr (i64 ptrtoint (i32 addrspace(1)* @g to i64) to i32*)
+}
+
+; COMMON-LABEL: @non_noop_ptrint_pair_ce(
+; AMDGCN-NEXT: store i32 0, i32* inttoptr (i64 ptrtoint (i32 addrspace(3)* @l to i64) to i32*)
+; AMDGCN-NEXT: ret void
+; NOTTI-NEXT: store i32 0, i32* inttoptr (i64 ptrtoint (i32 addrspace(3)* @l to i64) to i32*)
+; NOTTI-NEXT: ret void
+define void @non_noop_ptrint_pair_ce() {
+  store i32 0, i32* inttoptr (i64 ptrtoint (i32 addrspace(3)* @l to i64) to i32*)
+  ret void
+}
+
+; COMMON-LABEL: @non_noop_ptrint_pair_ce2(
+; AMDGCN-NEXT: ret i32* inttoptr (i64 ptrtoint (i32 addrspace(3)* @l to i64) to i32*)
+; NOTTI-NEXT: ret i32* inttoptr (i64 ptrtoint (i32 addrspace(3)* @l to i64) to i32*)
+define i32* @non_noop_ptrint_pair_ce2() {
+  ret i32* inttoptr (i64 ptrtoint (i32 addrspace(3)* @l to i64) to i32*)
+}
+
+; COMMON-LABEL: @non_noop_ptrint_pair_ce3(
+; AMDGCN-NEXT: ret i32* inttoptr (i32 ptrtoint (i32 addrspace(1)* @g to i32) to i32*)
+; NOTTI-NEXT: ret i32* inttoptr (i32 ptrtoint (i32 addrspace(1)* @g to i32) to i32*)
+define i32* @non_noop_ptrint_pair_ce3() {
+  ret i32* inttoptr (i32 ptrtoint (i32 addrspace(1)* @g to i32) to i32*)
+}
+
+; COMMON-LABEL: @non_noop_ptrint_pair_ce4(
+; AMDGCN-NEXT: ret i32* inttoptr (i128 ptrtoint (i32 addrspace(3)* @l to i128) to i32*)
+; NOTTI-NEXT: ret i32* inttoptr (i128 ptrtoint (i32 addrspace(3)* @l to i128) to i32*)
+define i32* @non_noop_ptrint_pair_ce4() {
+  ret i32* inttoptr (i128 ptrtoint (i32 

[PATCH] D81315: [analyzer] Warning for default constructed unique pointer dereferences

2020-06-25 Thread Nithin VR via Phabricator via cfe-commits
vrnithinkumar added a comment.

In D81315#2079457 , @Szelethus wrote:

> Best of luck on your GSoC! I don't have much else to add to your patch, but 
> you seem to have made good progress already!


Thanks!

> In D81315#2078043 , @xazax.hun wrote:
> 
>> some folks have automated scripts based on that tag to add themselves as 
>> subscriber/reviewer.
> 
> 
> Hope you don't mind my intrusion :)

Not at all.

>> I am not sure about whether I should use eval::Call or both check::PreCall 
>> and check::PostCall. In the eval::Call documentation I found this "Note, 
>> that only one checker can evaluate a call.". So I am little bit confused 
>> about using it.
> 
> Inlining (when we model a function call, https://youtu.be/yh2qdnJjizE?t=238) 
> is rather expensive. Creating a new stack frame, parameters, new 
> `ExplodedNode`s, running checkers, etc., eats memory for breakfast, is slow 
> and limits how deep the analysis can go. Worse still, the analysis could lose 
> precision if the called function's definition isn't available. `eval::Call` 
> serves to circumvent this by allowing the analyzer to give a precise summary 
> of the function. `StreamChecker`, for instance, uses this for functions such 
> as `clearerr()` -- the C standard defines how this function should behave, so 
> upon encountering a call to it, we don't need all the extra work regular 
> inlining demands, just ask `StreamChecker` to model it for us.
> 
> Use `eval::Call` if you can provide a precise model for a function. Only a 
> single checker is allowed to do that -- you can see that it returns with a 
> boolean value to sign whether the checker could provide an evaluation, and as 
> far as I know, the first checker that returns true will be doing it.
> 
> I think it would be appropriate in this instance, because we're modeling a 
> well established API. In general, I think we should use it when appropriate 
> more often, like in MallocChecker.

Thank you for the detailed help.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81315/new/

https://reviews.llvm.org/D81315



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


[clang-tools-extra] 0e1997e - [clangd] Fix test compile with GCC (name conflict)

2020-06-25 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2020-06-26T03:02:28+02:00
New Revision: 0e1997ed4ef74202a1bec6e7c18ba7a1df496896

URL: 
https://github.com/llvm/llvm-project/commit/0e1997ed4ef74202a1bec6e7c18ba7a1df496896
DIFF: 
https://github.com/llvm/llvm-project/commit/0e1997ed4ef74202a1bec6e7c18ba7a1df496896.diff

LOG: [clangd] Fix test compile with GCC (name conflict)

Added: 


Modified: 
clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp 
b/clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp
index db94e7b8ac56..e3b8215670c0 100644
--- a/clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp
+++ b/clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp
@@ -59,10 +59,10 @@ struct CapturedDiags {
   Out.Pos.character = D.getColumnNo(); // Zero-based - bug in SourceMgr?
   if (!D.getRanges().empty()) {
 const auto  = D.getRanges().front();
-Out.Range.emplace();
-Out.Range->start.line = Out.Range->end.line = Out.Pos.line;
-Out.Range->start.character = R.first;
-Out.Range->end.character = R.second;
+Out.Rng.emplace();
+Out.Rng->start.line = Out.Rng->end.line = Out.Pos.line;
+Out.Rng->start.character = R.first;
+Out.Rng->end.character = R.second;
   }
 };
   }
@@ -70,7 +70,7 @@ struct CapturedDiags {
 std::string Message;
 llvm::SourceMgr::DiagKind Kind;
 Position Pos;
-llvm::Optional Range;
+llvm::Optional Rng;
 
 friend void PrintTo(const Diag , std::ostream *OS) {
   *OS << (D.Kind == llvm::SourceMgr::DK_Error ? "error: " : "warning: ")
@@ -83,7 +83,7 @@ struct CapturedDiags {
 MATCHER_P(DiagMessage, M, "") { return arg.Message == M; }
 MATCHER_P(DiagKind, K, "") { return arg.Kind == K; }
 MATCHER_P(DiagPos, P, "") { return arg.Pos == P; }
-MATCHER_P(DiagRange, R, "") { return arg.Range == R; }
+MATCHER_P(DiagRange, R, "") { return arg.Rng == R; }
 
 TEST(ParseYAML, SyntacticForms) {
   CapturedDiags Diags;



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


[PATCH] D81315: [analyzer] Warning for default constructed unique pointer dereferences

2020-06-25 Thread Nithin VR via Phabricator via cfe-commits
vrnithinkumar updated this revision to Diff 273568.
vrnithinkumar marked 16 inline comments as done.
vrnithinkumar added a comment.

Addressing review comments


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81315/new/

https://reviews.llvm.org/D81315

Files:
  clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
  clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
  clang/test/Analysis/Inputs/system-header-simulator-cxx.h
  clang/test/Analysis/analyzer-config.c
  clang/test/Analysis/smart-ptr.cpp

Index: clang/test/Analysis/smart-ptr.cpp
===
--- clang/test/Analysis/smart-ptr.cpp
+++ clang/test/Analysis/smart-ptr.cpp
@@ -1,5 +1,6 @@
 // RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection\
 // RUN:   -analyzer-checker cplusplus.Move,cplusplus.SmartPtr\
+// RUN:   -analyzer-config cplusplus.SmartPtr:CheckSmartPtrDereference=true\
 // RUN:   -std=c++11 -verify %s
 
 #include "Inputs/system-header-simulator-cxx.h"
@@ -10,7 +11,7 @@
   std::unique_ptr Q = std::move(P);
   if (Q)
 clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}}
-  *Q.get() = 1; // no-warning
+  *Q.get() = 1; // no-warning
   if (P)
 clang_analyzer_warnIfReached(); // no-warning
   // TODO: Report a null dereference (instead).
@@ -26,3 +27,70 @@
   (s->*func)(); // no-crash
 }
 } // namespace testUnknownCallee
+
+class A {
+public:
+  A(){};
+  void foo();
+};
+
+A *return_null() {
+  return nullptr;
+}
+
+void derefAfterValidCtr() {
+  std::unique_ptr P(new A());
+  P->foo(); // No warning.
+}
+
+void derefAfterDefaultCtr() {
+  std::unique_ptr P;
+  P->foo(); // expected-warning {{Dereference of null smart pointer [cplusplus.SmartPtr]}}
+}
+
+void derefAfterCtrWithNull() {
+  std::unique_ptr P(nullptr);
+  *P; // expected-warning {{Dereference of null smart pointer [cplusplus.SmartPtr]}}
+}
+
+void derefAfterCtrWithNullReturnMethod() {
+  std::unique_ptr P(return_null());
+  P->foo(); // expected-warning {{Dereference of null smart pointer [cplusplus.SmartPtr]}}
+}
+
+void derefAfterRelease() {
+  std::unique_ptr P(new A());
+  P.release();
+  P->foo(); // expected-warning {{Dereference of null smart pointer [cplusplus.SmartPtr]}}
+}
+
+void derefAfterReset() {
+  std::unique_ptr P(new A());
+  P.reset();
+  P->foo(); // expected-warning {{Dereference of null smart pointer [cplusplus.SmartPtr]}}
+}
+
+void derefAfterResetWithNull() {
+  std::unique_ptr P(new A());
+  P.reset(nullptr);
+  P->foo(); // expected-warning {{Dereference of null smart pointer [cplusplus.SmartPtr]}}
+}
+
+void derefAfterResetWithNonNull() {
+  std::unique_ptr P;
+  P.reset(new A());
+  P->foo(); // No warning.
+}
+
+void derefAfterReleaseAndResetWithNonNull() {
+  std::unique_ptr P(new A());
+  P.release();
+  P.reset(new A());
+  P->foo(); // No warning.
+}
+
+void derefOnReleasedNullRawPtr() {
+  std::unique_ptr P;
+  A *AP = P.release();
+  AP->foo(); // expected-warning {{Called C++ object pointer is null [core.CallAndMessage]}}
+}
Index: clang/test/Analysis/analyzer-config.c
===
--- clang/test/Analysis/analyzer-config.c
+++ clang/test/Analysis/analyzer-config.c
@@ -39,6 +39,7 @@
 // CHECK-NEXT: core.CallAndMessage:ParameterCount = true
 // CHECK-NEXT: core.CallAndMessage:UndefReceiver = true
 // CHECK-NEXT: cplusplus.Move:WarnOn = KnownsAndLocals
+// CHECK-NEXT: cplusplus.SmartPtr:CheckSmartPtrDereference = false
 // CHECK-NEXT: crosscheck-with-z3 = false
 // CHECK-NEXT: ctu-dir = ""
 // CHECK-NEXT: ctu-import-threshold = 100
Index: clang/test/Analysis/Inputs/system-header-simulator-cxx.h
===
--- clang/test/Analysis/Inputs/system-header-simulator-cxx.h
+++ clang/test/Analysis/Inputs/system-header-simulator-cxx.h
@@ -946,10 +946,15 @@
   template  // TODO: Implement the stub for deleter.
   class unique_ptr {
   public:
+unique_ptr() {}
+unique_ptr(T *) {}
 unique_ptr(const unique_ptr &) = delete;
 unique_ptr(unique_ptr &&);
 
 T *get() const;
+T *release() const;
+void reset(T *p = nullptr) const;
+void swap(unique_ptr ) const;
 
 typename std::add_lvalue_reference::type operator*() const;
 T *operator->() const;
Index: clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
+++ clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
@@ -13,26 +13,60 @@
 
 #include "Move.h"
 
+#include "clang/AST/DeclCXX.h"
 #include "clang/AST/ExprCXX.h"
+#include "clang/AST/Type.h"
 #include "clang/StaticAnalyzer/Checkers/BuiltinCheckerRegistration.h"
 #include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
 #include "clang/StaticAnalyzer/Core/Checker.h"
 #include "clang/StaticAnalyzer/Core/CheckerManager.h"
 #include 

[PATCH] D81315: [analyzer] Warning for default constructed unique pointer dereferences

2020-06-25 Thread Nithin VR via Phabricator via cfe-commits
vrnithinkumar added inline comments.



Comment at: clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp:35
   bool isNullAfterMoveMethod(const CallEvent ) const;
+  BugType NullDereferenceBugType{this, "Null-smartPtr-deref",
+ "C++ smart pointer"};

xazax.hun wrote:
> Nit: We do not use hypens/dashes in diagnostic names.
Fixed the format



Comment at: clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp:53
+  // Set of STL smart pointer class which we are trying to model.
+  const llvm::StringSet<> StdSmartPtrs = {
+  "shared_ptr",

xazax.hun wrote:
> It might be just a personal preference but I tend to put these at the top of 
> the file for easier discoverability. Feel free to ignore this comment unless 
> other reviewers have the same preference as me.
Thanks!
Moved to top.



Comment at: clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp:81
 CheckerContext ) const {
-  if (!isNullAfterMoveMethod(Call))
+  if (isNullAfterMoveMethod(Call)) {
+ProgramStateRef State = C.getState();

xazax.hun wrote:
> Don't we want this to be also protected by the `isStdSmartPointerClass` check?
added `isStdSmartPointerClass` check in the beginning.



Comment at: clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp:115
+  const auto *MethodDecl = dyn_cast(Call.getDecl());
+  if (!MethodDecl || !isStdSmartPointerClass(MethodDecl->getParent()))
+return;

xazax.hun wrote:
> I wonder if making `isStdSmartPointerClass` operate on `CallEvent` would 
> simllify the call sites of this function.
Yeah. Thanks!
That makes it better.
Made changes to pass `CallEvent` to `isStdSmartPointerClass`



Comment at: clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp:124
+return;
+  updateTrackedRegion(Call, C, ThisValRegion);
+}

NoQ wrote:
> NoQ wrote:
> > Not all constructors behave this way. In particular, if it's a copy/move 
> > constructor this function would track the value of the original smart 
> > pointer to this smart pointer, but what we need is to track the value of 
> > the raw pointer instead.
> Actually, let's add an assertion into `updateTrackedRegion` that the value 
> that's put into the map is of pointer type. This would give us an automatic 
> notification when we make such mistakes.
- Added check to filter out copy/move constructor
- Added  assert to check the value is of type pointer.



Comment at: clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp:137
+if (IsRegDead) {
+  State = State->remove(Region);
+}

NoQ wrote:
> xazax.hun wrote:
> > In LLVM we often omit braces for small single statement branches. Also, 
> > Artem mentioned that we could interact with the malloc checker. Maybe it is 
> > worth considering to notify the malloc checker to mark the appropriate 
> > region as deallocated? This would help find double release errors, avoid 
> > spurious leak errors and so on. 
> > Maybe it is worth considering to notify the malloc checker to mark the 
> > appropriate region as deallocated?
> 
> This happens in destructor.
removed the braces



Comment at: clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp:155
+
+  if (MethodDecl && MethodDecl->isOverloadedOperator()) {
+OverloadedOperatorKind OOK = MethodDecl->getOverloadedOperator();

xazax.hun wrote:
> Early returns can decrease the indentation. 
Updated with early return. 
Thanks!



Comment at: clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp:175
+return;
+  updateTrackedRegion(Call, C, ThisValRegion);
+}

NoQ wrote:
> When you're doing `evalCall`, you're responsible for all aspects of the call 
> - not just your private GDM map but also the Store and the Environment.
> 
> For `.reset()` the other important thing to do would be to invalidate the 
> region in the Store so that the Store did not think that it contains the old 
> value. We can't set the new value correctly but invalidating it would still 
> be better than doing nothing - simply because "not being sure" is not as bad 
> as "being confidently incorrect". That said, once you model *all* methods of 
> the smart pointers, you would probably no longer need to invalidate the 
> Store, because it will never be actually accessed during analysis. So my 
> conclusion here is:
> - For this first patch invalidating the Store is probably not worth it but 
> let's add a FIXME.
> - We should make sure that we eventually add the invalidation if we don't 
> have time to model all methods.
> 
> Now, you're calling this same function for `.release()` as well. And for 
> `.release()` there is another important thing that we're responsible for: 
> //model the return value//. The `.release()` method returns the raw pointer - 
> which is 

[PATCH] D82249: [HWASan] Disable GlobalISel/FastISel for HWASan Globals.

2020-06-25 Thread Mitch Phillips via Phabricator via cfe-commits
hctim abandoned this revision.
hctim added a comment.

Abandoning - fixing the underlying issue at D82615 
.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82249/new/

https://reviews.llvm.org/D82249



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


[clang] dccfaac - [InferAddressSpaces] Handle the pair of `ptrtoint`/`inttoptr`.

2020-06-25 Thread Michael Liao via cfe-commits

Author: Michael Liao
Date: 2020-06-25T20:46:56-04:00
New Revision: dccfaacf93e1c4801cbcc4686f64eb8a35564ff7

URL: 
https://github.com/llvm/llvm-project/commit/dccfaacf93e1c4801cbcc4686f64eb8a35564ff7
DIFF: 
https://github.com/llvm/llvm-project/commit/dccfaacf93e1c4801cbcc4686f64eb8a35564ff7.diff

LOG: [InferAddressSpaces] Handle the pair of `ptrtoint`/`inttoptr`.

Summary:
- `ptrtoint` and `inttoptr` are defined as no-op casts if the integer
  value as the same size as the pointer value. The pair of
  `ptrtoint`/`inttoptr` is in fact a no-op cast sequence between
  different address spaces. Teach `infer-address-spaces` to handle them
  like a `bitcast`.

Reviewers: arsenm, chandlerc

Subscribers: jvesely, wdng, nhaehnle, hiraditya, kerbowa, cfe-commits, 
llvm-commits

Tags: #clang, #llvm

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

Added: 
llvm/test/Transforms/InferAddressSpaces/AMDGPU/noop-ptrint-pair.ll

Modified: 
clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu
llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp

Removed: 




diff  --git a/clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu 
b/clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu
index 73ab9edf318e..8c102d339863 100644
--- a/clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu
+++ b/clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu
@@ -1,37 +1,52 @@
-// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -fcuda-is-device -emit-llvm -x 
hip %s -o - | FileCheck %s
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -fcuda-is-device -emit-llvm -x 
hip %s -o - | FileCheck --check-prefixes=COMMON,CHECK %s
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -fcuda-is-device -emit-llvm -x 
hip %s -disable-O0-optnone -o - | opt -S -O2 | FileCheck %s 
--check-prefixes=COMMON,OPT
 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -x hip %s -o - 
| FileCheck -check-prefix=HOST %s
 
 #include "Inputs/cuda.h"
 
 // Coerced struct from `struct S` without all generic pointers lowered into
 // global ones.
-// CHECK: %struct.S.coerce = type { i32 addrspace(1)*, float addrspace(1)* }
-// CHECK: %struct.T.coerce = type { [2 x float addrspace(1)*] }
+// COMMON: %struct.S.coerce = type { i32 addrspace(1)*, float addrspace(1)* }
+// COMMON: %struct.T.coerce = type { [2 x float addrspace(1)*] }
 
 // On the host-side compilation, generic pointer won't be coerced.
 // HOST-NOT: %struct.S.coerce
 // HOST-NOT: %struct.T.coerce
 
-// CHECK: define amdgpu_kernel void  @_Z7kernel1Pi(i32 addrspace(1)* %x.coerce)
 // HOST: define void @_Z22__device_stub__kernel1Pi(i32* %x)
+// COMMON-LABEL: define amdgpu_kernel void @_Z7kernel1Pi(i32 
addrspace(1)*{{.*}} %x.coerce)
+// CHECK: = addrspacecast [[TYPE:.*]] addrspace(1)* %{{.*}} to [[TYPE]]*
+// CHECK-NOT: = addrspacecast [[TYPE:.*]] addrspace(1)* %{{.*}} to [[TYPE]]*
+// OPT: [[VAL:%.*]] = load i32, i32 addrspace(1)* %x.coerce, align 4
+// OPT: [[INC:%.*]] = add nsw i32 [[VAL]], 1
+// OPT: store i32 [[INC]], i32 addrspace(1)* %x.coerce, align 4
+// OPT: ret void
 __global__ void kernel1(int *x) {
   x[0]++;
 }
 
-// CHECK: define amdgpu_kernel void  @_Z7kernel2Ri(i32 addrspace(1)* nonnull 
align 4 dereferenceable(4) %x.coerce)
 // HOST: define void @_Z22__device_stub__kernel2Ri(i32* nonnull align 4 
dereferenceable(4) %x)
+// COMMON-LABEL: define amdgpu_kernel void @_Z7kernel2Ri(i32 
addrspace(1)*{{.*}} nonnull align 4 dereferenceable(4) %x.coerce)
+// CHECK: = addrspacecast [[TYPE:.*]] addrspace(1)* %{{.*}} to [[TYPE]]*
+// CHECK-NOT: = addrspacecast [[TYPE:.*]] addrspace(1)* %{{.*}} to [[TYPE]]*
+// OPT: [[VAL:%.*]] = load i32, i32 addrspace(1)* %x.coerce, align 4
+// OPT: [[INC:%.*]] = add nsw i32 [[VAL]], 1
+// OPT: store i32 [[INC]], i32 addrspace(1)* %x.coerce, align 4
+// OPT: ret void
 __global__ void kernel2(int ) {
   x++;
 }
 
-// CHECK: define amdgpu_kernel void  @_Z7kernel3PU3AS2iPU3AS1i(i32 
addrspace(2)* %x, i32 addrspace(1)* %y)
 // HOST: define void @_Z22__device_stub__kernel3PU3AS2iPU3AS1i(i32 
addrspace(2)* %x, i32 addrspace(1)* %y)
+// CHECK-LABEL: define amdgpu_kernel void  @_Z7kernel3PU3AS2iPU3AS1i(i32 
addrspace(2)*{{.*}} %x, i32 addrspace(1)*{{.*}} %y)
+// CHECK-NOT: = addrspacecast [[TYPE:.*]] addrspace(1)* %{{.*}} to [[TYPE]]*
 __global__ void kernel3(__attribute__((address_space(2))) int *x,
 __attribute__((address_space(1))) int *y) {
   y[0] = x[0];
 }
 
-// CHECK: define void @_Z4funcPi(i32* %x)
+// COMMON-LABEL: define void @_Z4funcPi(i32*{{.*}} %x)
+// CHECK-NOT: = addrspacecast [[TYPE:.*]] addrspace(1)* %{{.*}} to [[TYPE]]*
 __device__ void func(int *x) {
   x[0]++;
 }
@@ -42,16 +57,25 @@ struct S {
 };
 // `by-val` struct will be coerced into a similar struct with all generic
 // pointers lowerd into global ones.
-// CHECK: define amdgpu_kernel void @_Z7kernel41S(%struct.S.coerce %s.coerce)
 // HOST: define void 

[PATCH] D82609: [PowerPC][Power10] Implement Vector Multiply High/Divide Extended Builtins in LLVM/Clang

2020-06-25 Thread Amy Kwan via Phabricator via cfe-commits
amyk marked 2 inline comments as done.
amyk added inline comments.



Comment at: clang/test/CodeGen/builtins-ppc-p10vector.c:18
+  // CHECK-NEXT: ret <4 x i32>
+  return vec_dive(vsia, vsib);
+}

anil9 wrote:
> I may be wrong but where are the variables declared ? I do not see the 
> variables delclared above in the file, i mean many of them.
I accidentally uploaded the wrong diff, I will update this. 



Comment at: llvm/test/CodeGen/PowerPC/p10-vector-divide.ll:49
 }
+
+declare <4 x i32> @llvm.ppc.altivec.vdivesw(<4 x i32>, <4 x i32>)

anil9 wrote:
> nit : you put a comment right at this position in the multiply.ll file, for 
> consistency you could add one here or remove the one there. 
Will fix.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82609/new/

https://reviews.llvm.org/D82609



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


[PATCH] D82612: [clangd] Config: compile Fragment -> CompiledFragment -> Config

2020-06-25 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
Herald added subscribers: cfe-commits, usaxena95, kadircet, arphaman, jkorous, 
MaskRay, ilya-biryukov, mgorny.
Herald added a project: clang.
sammccall added a parent revision: D82606: [clangd] Config: config struct 
propagated through Context.
sammccall edited the summary of this revision.
sammccall added a reviewer: hokein.

https://reviews.llvm.org/D82335 shows how this fits in with related config work.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D82612

Files:
  clang-tools-extra/clangd/CMakeLists.txt
  clang-tools-extra/clangd/ConfigCompile.cpp
  clang-tools-extra/clangd/ConfigProvider.h
  clang-tools-extra/clangd/unittests/CMakeLists.txt
  clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
  clang-tools-extra/clangd/unittests/ConfigTesting.h
  clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp

Index: clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp
===
--- clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp
+++ clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp
@@ -8,14 +8,13 @@
 
 #include "Annotations.h"
 #include "ConfigFragment.h"
-#include "Matchers.h"
+#include "ConfigTesting.h"
 #include "Protocol.h"
 #include "llvm/Support/SMLoc.h"
 #include "llvm/Support/ScopedPrinter.h"
 #include "llvm/Support/SourceMgr.h"
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
-#include "gtest/internal/gtest-internal.h"
 
 namespace clang {
 namespace clangd {
@@ -36,55 +35,6 @@
   return false;
 }
 
-Position toPosition(llvm::SMLoc L, const llvm::SourceMgr ) {
-  auto LineCol = SM.getLineAndColumn(L);
-  Position P;
-  P.line = LineCol.first - 1;
-  P.character = LineCol.second - 1;
-  return P;
-}
-
-Range toRange(llvm::SMRange R, const llvm::SourceMgr ) {
-  return Range{toPosition(R.Start, SM), toPosition(R.End, SM)};
-}
-
-struct CapturedDiags {
-  std::function callback() {
-return [this](const llvm::SMDiagnostic ) {
-  Diagnostics.emplace_back();
-  Diag  = Diagnostics.back();
-  Out.Message = D.getMessage().str();
-  Out.Kind = D.getKind();
-  Out.Pos.line = D.getLineNo() - 1;
-  Out.Pos.character = D.getColumnNo(); // Zero-based - bug in SourceMgr?
-  if (!D.getRanges().empty()) {
-const auto  = D.getRanges().front();
-Out.Range.emplace();
-Out.Range->start.line = Out.Range->end.line = Out.Pos.line;
-Out.Range->start.character = R.first;
-Out.Range->end.character = R.second;
-  }
-};
-  }
-  struct Diag {
-std::string Message;
-llvm::SourceMgr::DiagKind Kind;
-Position Pos;
-llvm::Optional Range;
-
-friend void PrintTo(const Diag , std::ostream *OS) {
-  *OS << (D.Kind == llvm::SourceMgr::DK_Error ? "error: " : "warning: ")
-  << D.Message << "@" << llvm::to_string(D.Pos);
-}
-  };
-  std::vector Diagnostics;
-};
-
-MATCHER_P(DiagMessage, M, "") { return arg.Message == M; }
-MATCHER_P(DiagKind, K, "") { return arg.Kind == K; }
-MATCHER_P(DiagPos, P, "") { return arg.Pos == P; }
-MATCHER_P(DiagRange, R, "") { return arg.Range == R; }
-
 TEST(ParseYAML, SyntacticForms) {
   CapturedDiags Diags;
   const char *YAML = R"yaml(
Index: clang-tools-extra/clangd/unittests/ConfigTesting.h
===
--- /dev/null
+++ clang-tools-extra/clangd/unittests/ConfigTesting.h
@@ -0,0 +1,77 @@
+//===-- ConfigTesting.h - Helpers for configuration tests ---*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_UNITTESTS_CONFIGTESTING_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_UNITTESTS_CONFIGTESTING_H
+
+#include "Protocol.h"
+#include "llvm/Support/ScopedPrinter.h"
+#include "llvm/Support/SourceMgr.h"
+#include "gmock/gmock.h"
+#include 
+
+namespace clang {
+namespace clangd {
+namespace config {
+
+// Provides a DiagnosticsCallback that records diganostics.
+// Unlike just pushing them into a vector, underlying storage need not survive.
+struct CapturedDiags {
+  std::function callback() {
+return [this](const llvm::SMDiagnostic ) {
+  Diagnostics.emplace_back();
+  Diag  = Diagnostics.back();
+  Out.Message = D.getMessage().str();
+  Out.Kind = D.getKind();
+  Out.Pos.line = D.getLineNo() - 1;
+  Out.Pos.character = D.getColumnNo(); // Zero-based - bug in SourceMgr?
+  if (!D.getRanges().empty()) {
+const auto  = D.getRanges().front();
+Out.Range.emplace();
+Out.Range->start.line = Out.Range->end.line = Out.Pos.line;
+Out.Range->start.character = R.first;
+Out.Range->end.character = R.second;
+  }
+};
+  }
+  struct Diag {
+

[PATCH] D76323: [AST] Fix handling of long double and bool in __builtin_bit_cast

2020-06-25 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington added a comment.

Ping, @rsmith did you want to take another look at this?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D76323/new/

https://reviews.llvm.org/D76323



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


[PATCH] D82611: [SemaObjC] Add a warning for @selector expressions that potentially refer to objc_direct methods

2020-06-25 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington created this revision.
erik.pilkington added reviewers: rjmccall, MadCoder.
Herald added subscribers: ributzka, dexonsmith, jkorous.

As a heuristic, only warn if the selector matches a method declared in the 
current interface.

rdar://64621668


https://reviews.llvm.org/D82611

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaExprObjC.cpp
  clang/test/SemaObjC/potentially-direct-selector.m

Index: clang/test/SemaObjC/potentially-direct-selector.m
===
--- /dev/null
+++ clang/test/SemaObjC/potentially-direct-selector.m
@@ -0,0 +1,127 @@
+// RUN: %clang_cc1 %s -Wpotentially-direct-selector -verify
+
+#define NS_DIRECT __attribute__((objc_direct))
+
+@interface Dummies
+-(void)inBase;
+-(void)inBaseImpl;
+-(void)inBaseCat;
+-(void)inBaseCatImpl;
+-(void)inDerived;
+-(void)inDerivedImpl;
+-(void)inDerivedCat;
+-(void)inDerivedCatImpl;
++(void)inBaseClass;
++(void)inDerivedClass;
++(void)inDerivedCatClass;
+@end
+
+__attribute__((objc_root_class))
+@interface Base
+-(void)inBase NS_DIRECT; // expected-note 2 {{direct method}}
++(void)inBaseClass NS_DIRECT;  // expected-note 2 {{direct method}}
+@end
+
+@implementation Base
+-(void)inBaseImpl NS_DIRECT { // expected-note 2 {{direct method}}
+}
+-(void)inBase {}
++(void)inBaseClass {}
+@end
+
+@interface Base (Cat)
+-(void)inBaseCat NS_DIRECT; // expected-note 2 {{direct method}}
+@end
+
+@implementation Base (Cat)
+-(void)inBaseCatImpl NS_DIRECT { // expected-note 2 {{direct method}}
+}
+-(void)inBaseCat {}
+@end
+
+@interface Derived : Base
+-(void)inDerived NS_DIRECT; // expected-note{{direct method}}
++(void)inDerivedClass NS_DIRECT;  // expected-note{{direct method}}
+@end
+
+@implementation Derived
+-(void)inDerivedImpl NS_DIRECT { // expected-note{{direct method}}
+}
+-(void)inDerived {}
++(void)inDerivedClass {}
+@end
+
+@interface Derived (Cat)
+-(void)inDerivedCat NS_DIRECT; // expected-note{{direct method}}
++(void)inDerivedCatClass NS_DIRECT; // expected-note{{direct method}}
+@end
+
+@implementation Derived (Cat)
+-(void)inDerivedCatImpl NS_DIRECT { // expected-note{{direct method}}
+}
+-(void)inDerivedCat {}
++(void)inDerivedCatClass {}
+
+-(void)test1 {
+  (void)@selector(inBase); // expected-warning{{@selector expression formed with potentially direct selector}}
+  (void)@selector(inBaseImpl); // expected-warning{{@selector expression formed with potentially direct selector}}
+  (void)@selector(inBaseCat); // expected-warning{{@selector expression formed with potentially direct selector}}
+  (void)@selector(inBaseCatImpl); // expected-warning{{@selector expression formed with potentially direct selector}}
+  (void)@selector(inDerived); // expected-warning{{@selector expression formed with potentially direct selector}}
+  (void)@selector(inDerivedImpl); // expected-warning{{@selector expression formed with potentially direct selector}}
+  (void)@selector(inDerivedCat); // expected-warning{{@selector expression formed with potentially direct selector}}
+  (void)@selector(inDerivedCatImpl); // expected-warning{{@selector expression formed with potentially direct selector}}
+  (void)@selector(inDerivedClass); // expected-warning{{@selector expression formed with potentially direct selector}}
+  (void)@selector(inBaseClass); // expected-warning{{@selector expression formed with potentially direct selector}}
+  (void)@selector(inDerivedCatClass); // expected-warning{{@selector expression formed with potentially direct selector}}
+}
+@end
+
+void test2() {
+  (void)@selector(inBase);
+  (void)@selector(inBaseImpl);
+  (void)@selector(inBaseCat);
+  (void)@selector(inBaseCatImpl);
+  (void)@selector(inDerived);
+  (void)@selector(inDerivedImpl);
+  (void)@selector(inDerivedCat);
+  (void)@selector(inDerivedCatImpl);
+  (void)@selector(inDerivedClass);
+  (void)@selector(inBaseClass);
+  (void)@selector(inDerivedCatClass);
+}
+
+@interface OnlyBase : Base @end
+@implementation OnlyBase
+-(void)test3 {
+  (void)@selector(inBase); // expected-warning{{@selector expression formed with potentially direct selector}}
+  (void)@selector(inBaseImpl); // expected-warning{{@selector expression formed with potentially direct selector}}
+  (void)@selector(inBaseCat); // expected-warning{{@selector expression formed with potentially direct selector}}
+  (void)@selector(inBaseCatImpl); // expected-warning{{@selector expression formed with potentially direct selector}}
+  (void)@selector(inDerived);
+  (void)@selector(inDerivedImpl);
+  (void)@selector(inDerivedCat);
+  (void)@selector(inDerivedCatImpl);
+  (void)@selector(inDerivedClass);
+  (void)@selector(inBaseClass); // expected-warning{{@selector expression formed with potentially direct selector}}
+  (void)@selector(inDerivedCatClass);
+}
+@end
+
+__attribute__((objc_root_class))
+@interface Unrelated @end
+@implementation Unrelated
+-(void)test3 {
+  (void)@selector(inBase);
+  

[PATCH] D82609: [PowerPC][Power10] Implement Vector Multiply High/Divide Extended Builtins in LLVM/Clang

2020-06-25 Thread Anil Mahmud via Phabricator via cfe-commits
anil9 added inline comments.



Comment at: clang/test/CodeGen/builtins-ppc-p10vector.c:18
+  // CHECK-NEXT: ret <4 x i32>
+  return vec_dive(vsia, vsib);
+}

I may be wrong but where are the variables declared ? I do not see the 
variables delclared above in the file, i mean many of them.



Comment at: llvm/test/CodeGen/PowerPC/p10-vector-divide.ll:49
 }
+
+declare <4 x i32> @llvm.ppc.altivec.vdivesw(<4 x i32>, <4 x i32>)

nit : you put a comment right at this position in the multiply.ll file, for 
consistency you could add one here or remove the one there. 


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82609/new/

https://reviews.llvm.org/D82609



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


[PATCH] D82130: [WebAssembly] Adding 64-bit versions of __stack_pointer and other globals

2020-06-25 Thread Wouter van Oortmerssen via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb9a539c01084: [WebAssembly] Adding 64-bit versions of 
__stack_pointer and other globals (authored by aardappel).

Changed prior to commit:
  https://reviews.llvm.org/D82130?vs=273539=273548#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82130/new/

https://reviews.llvm.org/D82130

Files:
  clang/lib/Driver/ToolChains/WebAssembly.cpp
  lld/wasm/Config.h
  lld/wasm/Driver.cpp
  lld/wasm/InputChunks.cpp
  lld/wasm/Options.td
  llvm/include/llvm/BinaryFormat/Wasm.h
  llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyFrameLowering.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyFrameLowering.h
  llvm/lib/Target/WebAssembly/WebAssemblyISelDAGToDAG.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyLateEHPrepare.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyMCInstLower.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyRegStackify.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyRegisterInfo.cpp
  llvm/test/CodeGen/WebAssembly/stack-alignment.ll
  llvm/test/CodeGen/WebAssembly/userstack.ll
  llvm/test/MC/WebAssembly/stack-ptr.ll
  llvm/test/MC/WebAssembly/wasm64.s

Index: llvm/test/MC/WebAssembly/wasm64.s
===
--- llvm/test/MC/WebAssembly/wasm64.s
+++ llvm/test/MC/WebAssembly/wasm64.s
@@ -51,6 +51,11 @@
 i64.const   0
 f32.store   .L.str# relocatable offset!
 
+### 64-bit SP
+
+global.get  __stack_pointer
+drop
+
 end_function
 
 .section.rodata..L.str,"",@
@@ -62,7 +67,7 @@
 .size   .L.str, 24
 
 .globaltype myglob64, i64
-
+.globaltype __stack_pointer, i64
 
 
 # CHECK:  .functype   test (i64) -> ()
@@ -155,6 +160,11 @@
 # BIN-NEXT: Kind:GLOBAL
 # BIN-NEXT: GlobalType:  I64
 # BIN-NEXT: GlobalMutable:   true
+# BIN-NEXT:   - Module:  env
+# BIN-NEXT: Field:   __stack_pointer
+# BIN-NEXT: Kind:GLOBAL
+# BIN-NEXT: GlobalType:  I64
+# BIN-NEXT: GlobalMutable:   true
 # BIN-NEXT:   - Type:FUNCTION
 # BIN-NEXT: FunctionTypes:   [ 0 ]
 # BIN-NEXT:   - Type:DATACOUNT
@@ -179,12 +189,15 @@
 # BIN-NEXT:   - Type:R_WASM_MEMORY_ADDR_LEB64
 # BIN-NEXT: Index:   1
 # BIN-NEXT: Offset:  0x0078
+# BIN-NEXT:   - Type: R_WASM_GLOBAL_INDEX_LEB
+# BIN-NEXT: Index: 3
+# BIN-NEXT: Offset: 0x0083
 # BIN-NEXT: Functions:
 # BIN-NEXT:   - Index:   0
 # BIN-NEXT: Locals:
 # BIN-NEXT:   - Type:I64
 # BIN-NEXT: Count:   1
-# BIN-NEXT: Body:42002A02001A20002A02001A42808080808080808080002A02001A2380808080002A02001A42002A02808080808080808080001A43420038020043200038020043428080808080808080800038020043238080808000380200434200380280808080808080808B
+# BIN-NEXT: Body:42002A02001A20002A02001A42808080808080808080002A02001A2380808080002A02001A42002A02808080808080808080001A434200380200432000380200434280808080808080808000380200432380808080003802004342003802808080808080808080002381808080001A0B
 # BIN-NEXT:   - Type:DATA
 # BIN-NEXT: Relocations:
 # BIN-NEXT:   - Type:R_WASM_MEMORY_ADDR_I64
@@ -217,6 +230,11 @@
 # BIN-NEXT: Name:myglob64
 # BIN-NEXT: Flags:   [ UNDEFINED ]
 # BIN-NEXT: Global:  0
+# BIN-NEXT:   - Index:   3
+# BIN-NEXT: Kind:GLOBAL
+# BIN-NEXT: Name:__stack_pointer
+# BIN-NEXT: Flags:   [ UNDEFINED ]
+# BIN-NEXT: Global:  1
 # BIN-NEXT: SegmentInfo:
 # BIN-NEXT:   - Index:   0
 # BIN-NEXT: Name:.rodata..L.str
Index: llvm/test/MC/WebAssembly/stack-ptr.ll
===
--- llvm/test/MC/WebAssembly/stack-ptr.ll
+++ llvm/test/MC/WebAssembly/stack-ptr.ll
@@ -1,6 +1,5 @@
-; RUN: llc -filetype=obj %s -o - | obj2yaml | FileCheck %s
-
-target triple = "wasm32-unknown-unknown"
+; RUN: llc --mtriple=wasm32-unknown-unknown -filetype=obj %s -o - | obj2yaml | FileCheck --check-prefixes CHECK,CHK32 %s
+; RUN: llc --mtriple=wasm64-unknown-unknown -filetype=obj %s -o - | obj2yaml | FileCheck --check-prefixes CHECK,CHK64 %s
 
 ; Function that uses explict stack, and should generate a reference to
 ; __stack_pointer, along with the corresponding reloction entry.
@@ -15,7 +14,8 @@
 ; CHECK:   - Module:  env
 ; CHECK: Field:   __stack_pointer
 ; CHECK: Kind:GLOBAL
-; CHECK: GlobalType:  I32
+; CHK32:

[PATCH] D82502: [PowerPC][Power10] Implement Load VSX Vector and Sign Extend and Zero Extend

2020-06-25 Thread Anil Mahmud via Phabricator via cfe-commits
anil9 added inline comments.



Comment at: clang/test/CodeGen/builtins-ppc-p10vector.c:17
+unsigned int uia, *uiap;
+signed int *ia;
+signed short *sia;

nit: It seems that most pull requests follow an ordering like first signed 
declaration and then unsigned, declaration, this one follows too , except the 
above two lines.  And should the above declarations of chars, be along with 
these lines ?



Comment at: llvm/test/CodeGen/PowerPC/p10-vsx-builtins.ll:56
+
+; CHECK: lxvrdx
+; Function Attrs: norecurse nounwind readonly

I am not too familiar with the builtins but I never saw a check outside of the 
two braces in the test cases before,  is it not posible to include it inside 
the test cases ?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82502/new/

https://reviews.llvm.org/D82502



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


[PATCH] D82609: [PowerPC][Power10] Implement Vector Multiply High/Divide Extended Builtins in LLVM/Clang

2020-06-25 Thread Amy Kwan via Phabricator via cfe-commits
amyk created this revision.
amyk added reviewers: power-llvm-team, PowerPC, nemanjai, lei, saghir.
amyk added projects: LLVM, clang, PowerPC.
Herald added subscribers: shchenz, hiraditya.

This patch implements the following function prototypes to utilize the 
`vmulh[s|u][w|d]` and `vdive[s|u][w|d]` instructions:

  vector signed int vec_mulh (vector signed int a, vector signed int b);  
  vector unsigned int vec_mulh (vector unsigned int a, vector unsigned int b); 
  vector signed long long vec_mulh (vector signed long long a, vector signed 
long long b); 
  vector unsigned long long vec_mulh (vector unsigned long long a, vector 
unsigned long long b);
  
  vector signed int vec_dive (vector signed int a, vector signed int b);
  vector unsigned int vec_dive (vector unsigned int a, vector unsigned int b);
  vector signed long long vec_dive (vector signed long long a, vector signed 
long long b);
  vector unsigned long long vec_dive (vector unsigned long long a, vector 
unsigned long long b);

Depends on D82584 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D82609

Files:
  clang/include/clang/Basic/BuiltinsPPC.def
  clang/lib/Headers/altivec.h
  clang/test/CodeGen/builtins-ppc-p10vector.c
  llvm/include/llvm/IR/IntrinsicsPowerPC.td
  llvm/lib/Target/PowerPC/PPCInstrPrefix.td
  llvm/test/CodeGen/PowerPC/p10-vector-divide.ll
  llvm/test/CodeGen/PowerPC/p10-vector-multiply.ll
  llvm/test/MC/Disassembler/PowerPC/p10insts.txt
  llvm/test/MC/PowerPC/p10.s

Index: llvm/test/MC/PowerPC/p10.s
===
--- llvm/test/MC/PowerPC/p10.s
+++ llvm/test/MC/PowerPC/p10.s
@@ -84,3 +84,15 @@
 # CHECK-BE: vmulhud 1, 2, 3   # encoding: [0x10,0x22,0x1a,0xc9]
 # CHECK-LE: vmulhud 1, 2, 3   # encoding: [0xc9,0x1a,0x22,0x10]
 vmulhud 1, 2, 3
+# CHECK-BE: vdivesw 21, 11, 10# encoding: [0x12,0xab,0x53,0x8b]
+# CHECK-LE: vdivesw 21, 11, 10# encoding: [0x8b,0x53,0xab,0x12]
+vdivesw 21, 11, 10
+# CHECK-BE: vdiveuw 21, 11, 10# encoding: [0x12,0xab,0x52,0x8b]
+# CHECK-LE: vdiveuw 21, 11, 10# encoding: [0x8b,0x52,0xab,0x12]
+vdiveuw 21, 11, 10
+# CHECK-BE: vdivesd 21, 11, 10# encoding: [0x12,0xab,0x53,0xcb]
+# CHECK-LE: vdivesd 21, 11, 10# encoding: [0xcb,0x53,0xab,0x12]
+vdivesd 21, 11, 10
+# CHECK-BE: vdiveud 21, 11, 10# encoding: [0x12,0xab,0x52,0xcb]
+# CHECK-LE: vdiveud 21, 11, 10# encoding: [0xcb,0x52,0xab,0x12]
+vdiveud 21, 11, 10
Index: llvm/test/MC/Disassembler/PowerPC/p10insts.txt
===
--- llvm/test/MC/Disassembler/PowerPC/p10insts.txt
+++ llvm/test/MC/Disassembler/PowerPC/p10insts.txt
@@ -81,3 +81,15 @@
 
 # CHECK: vmulhud 1, 2, 3
 0x10 0x22 0x1a 0xc9
+
+# CHECK: vdivesw 21, 11, 10
+0x12 0xab 0x53 0x8b
+
+# CHECK: vdiveuw 21, 11, 10
+0x12 0xab 0x52 0x8b
+
+# CHECK: vdivesd 21, 11, 10
+0x12 0xab 0x53 0xcb
+
+# CHECK: vdiveud 21, 11, 10
+0x12 0xab 0x52 0xcb
Index: llvm/test/CodeGen/PowerPC/p10-vector-multiply.ll
===
--- llvm/test/CodeGen/PowerPC/p10-vector-multiply.ll
+++ llvm/test/CodeGen/PowerPC/p10-vector-multiply.ll
@@ -72,3 +72,49 @@
   %tr = trunc <4 x i64> %shr to <4 x i32>
   ret <4 x i32> %tr
 }
+
+; Test the vector multiply high intrinsics.
+declare <4 x i32> @llvm.ppc.altivec.vmulhsw(<4 x i32>, <4 x i32>)
+declare <4 x i32> @llvm.ppc.altivec.vmulhuw(<4 x i32>, <4 x i32>)
+declare <2 x i64> @llvm.ppc.altivec.vmulhsd(<2 x i64>, <2 x i64>)
+declare <2 x i64> @llvm.ppc.altivec.vmulhud(<2 x i64>, <2 x i64>)
+
+define <4 x i32> @test_vmulhsw_intrinsic(<4 x i32> %a, <4 x i32> %b) {
+; CHECK-LABEL: test_vmulhsw_intrinsic:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:vmulhsw v2, v2, v3
+; CHECK-NEXT:blr
+entry:
+  %mulh = tail call <4 x i32> @llvm.ppc.altivec.vmulhsw(<4 x i32> %a, <4 x i32> %b)
+  ret <4 x i32> %mulh
+}
+
+define <4 x i32> @test_vmulhuw_intrinsic(<4 x i32> %a, <4 x i32> %b) {
+; CHECK-LABEL: test_vmulhuw_intrinsic:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:vmulhuw v2, v2, v3
+; CHECK-NEXT:blr
+entry:
+  %mulh = tail call <4 x i32> @llvm.ppc.altivec.vmulhuw(<4 x i32> %a, <4 x i32> %b)
+  ret <4 x i32> %mulh
+}
+
+define <2 x i64> @test_vmulhsd_intrinsic(<2 x i64> %a, <2 x i64> %b) {
+; CHECK-LABEL: test_vmulhsd_intrinsic:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:vmulhsd v2, v2, v3
+; CHECK-NEXT:blr
+entry:
+  %mulh = tail call <2 x i64> @llvm.ppc.altivec.vmulhsd(<2 x i64> %a, <2 x i64> %b)
+  ret <2 x i64> %mulh
+}
+
+define <2 x i64> @test_vmulhud_intrinsic(<2 x i64> %a, <2 x i64> %b) {
+; CHECK-LABEL: test_vmulhud_intrinsic:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:

[PATCH] D82606: [clangd] Config: config struct propagated through Context

2020-06-25 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 273543.
sammccall added a comment.

config() -> Config::current(). "config" already names a namespace.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82606/new/

https://reviews.llvm.org/D82606

Files:
  clang-tools-extra/clangd/CMakeLists.txt
  clang-tools-extra/clangd/CompileCommands.cpp
  clang-tools-extra/clangd/Config.cpp
  clang-tools-extra/clangd/Config.h
  clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp

Index: clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp
===
--- clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp
+++ clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp
@@ -7,7 +7,9 @@
 //===--===//
 
 #include "CompileCommands.h"
+#include "Config.h"
 #include "TestFS.h"
+#include "support/Context.h"
 
 #include "llvm/ADT/ScopeExit.h"
 #include "llvm/ADT/StringExtras.h"
@@ -185,6 +187,26 @@
 }
 #endif
 
+TEST(CommandMangler, ConfigEdits) {
+  auto Mangler = CommandMangler::forTests();
+  std::vector Cmd = {"clang++", "foo.cc"};
+  {
+Config Cfg;
+Cfg.CompileFlags.Edits.push_back([](std::vector ) {
+  for (auto  : Argv)
+for (char  : Arg)
+  C = llvm::toUpper(C);
+});
+Cfg.CompileFlags.Edits.push_back(
+[](std::vector ) { Argv.push_back("--hello"); });
+WithContextValue WithConfig(Config::Key, std::move(Cfg));
+Mangler.adjust(Cmd);
+  }
+  // Edits are applied in given order and before other mangling.
+  EXPECT_THAT(Cmd,
+  ElementsAre("CLANG++", "FOO.CC", "--hello", "-fsyntax-only"));
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/Config.h
===
--- /dev/null
+++ clang-tools-extra/clangd/Config.h
@@ -0,0 +1,63 @@
+//===--- Config.h - User configuration of clangd behavior *- C++-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// Various clangd features have configurable behaviour (or can be disabled).
+// This file defines "resolved" configuration seen by features within clangd.
+// For example, settings may vary per-file, the resolved Config only contains
+// settings that apply to the current file.
+//
+// This is distinct from how the config is specified by the user (Fragment)
+// interpreted (CompiledFragment), and combined (Provider).
+// ConfigFragment.h describes the steps to add a new configuration option.
+//
+// Because this structure is shared throughout clangd, it's a potential source
+// of layering problems. Config should be expressed in terms of simple
+// vocubulary types where possible.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_CONFIG_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_CONFIG_H
+
+#include "support/Context.h"
+#include "llvm/ADT/FunctionExtras.h"
+#include 
+#include 
+
+namespace clang {
+namespace clangd {
+
+/// Settings that express user/project preferences and control clangd behavior.
+///
+/// Generally, features should consume Config::current() and the caller is
+/// responsible for setting it appropriately. In practice these callers are
+/// ClangdServer, TUScheduler, and BackgroundQueue.
+struct Config {
+  /// Returns the Config of the current Context, or an empty configuration.
+  static const Config ();
+  /// Context key which can be used to set the current Config.
+  static clangd::Key Key;
+
+  Config() = default;
+  Config(const Config &) = delete;
+  Config =(const Config &) = delete;
+  Config(Config &&) = default;
+  Config =(Config &&) = default;
+
+  /// Controls how the compile command for the current file is determined.
+  struct {
+// Edits to apply to the compile command, in sequence.
+// FIXME: these functions need to be const-callable. For now, const_cast.
+std::vector &)>> Edits;
+  } CompileFlags;
+};
+
+} // namespace clangd
+} // namespace clang
+
+#endif
Index: clang-tools-extra/clangd/Config.cpp
===
--- /dev/null
+++ clang-tools-extra/clangd/Config.cpp
@@ -0,0 +1,25 @@
+//===--- Config.cpp - User configuration of clangd behavior ---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "Config.h"
+#include "support/Context.h"
+

[PATCH] D82130: [WebAssembly] Adding 64-bit versions of __stack_pointer and other globals

2020-06-25 Thread Wouter van Oortmerssen via Phabricator via cfe-commits
aardappel updated this revision to Diff 273539.
aardappel added a comment.

types & variables in InputChunks.cpp


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82130/new/

https://reviews.llvm.org/D82130

Files:
  clang/lib/Driver/ToolChains/WebAssembly.cpp
  lld/wasm/Config.h
  lld/wasm/Driver.cpp
  lld/wasm/InputChunks.cpp
  lld/wasm/Options.td
  llvm/include/llvm/BinaryFormat/Wasm.h
  llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyFrameLowering.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyFrameLowering.h
  llvm/lib/Target/WebAssembly/WebAssemblyISelDAGToDAG.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyLateEHPrepare.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyMCInstLower.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyRegStackify.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyRegisterInfo.cpp
  llvm/test/CodeGen/WebAssembly/stack-alignment.ll
  llvm/test/CodeGen/WebAssembly/userstack.ll
  llvm/test/MC/WebAssembly/stack-ptr.ll
  llvm/test/MC/WebAssembly/wasm64.s

Index: llvm/test/MC/WebAssembly/wasm64.s
===
--- llvm/test/MC/WebAssembly/wasm64.s
+++ llvm/test/MC/WebAssembly/wasm64.s
@@ -51,6 +51,11 @@
 i64.const   0
 f32.store   .L.str# relocatable offset!
 
+### 64-bit SP
+
+global.get  __stack_pointer
+drop
+
 end_function
 
 .section.rodata..L.str,"",@
@@ -62,7 +67,7 @@
 .size   .L.str, 24
 
 .globaltype myglob64, i64
-
+.globaltype __stack_pointer, i64
 
 
 # CHECK:  .functype   test (i64) -> ()
@@ -155,6 +160,11 @@
 # BIN-NEXT: Kind:GLOBAL
 # BIN-NEXT: GlobalType:  I64
 # BIN-NEXT: GlobalMutable:   true
+# BIN-NEXT:   - Module:  env
+# BIN-NEXT: Field:   __stack_pointer
+# BIN-NEXT: Kind:GLOBAL
+# BIN-NEXT: GlobalType:  I64
+# BIN-NEXT: GlobalMutable:   true
 # BIN-NEXT:   - Type:FUNCTION
 # BIN-NEXT: FunctionTypes:   [ 0 ]
 # BIN-NEXT:   - Type:DATACOUNT
@@ -179,12 +189,15 @@
 # BIN-NEXT:   - Type:R_WASM_MEMORY_ADDR_LEB64
 # BIN-NEXT: Index:   1
 # BIN-NEXT: Offset:  0x0078
+# BIN-NEXT:   - Type: R_WASM_GLOBAL_INDEX_LEB
+# BIN-NEXT: Index: 3
+# BIN-NEXT: Offset: 0x0083
 # BIN-NEXT: Functions:
 # BIN-NEXT:   - Index:   0
 # BIN-NEXT: Locals:
 # BIN-NEXT:   - Type:I64
 # BIN-NEXT: Count:   1
-# BIN-NEXT: Body:42002A02001A20002A02001A42808080808080808080002A02001A2380808080002A02001A42002A02808080808080808080001A43420038020043200038020043428080808080808080800038020043238080808000380200434200380280808080808080808B
+# BIN-NEXT: Body:42002A02001A20002A02001A42808080808080808080002A02001A2380808080002A02001A42002A02808080808080808080001A434200380200432000380200434280808080808080808000380200432380808080003802004342003802808080808080808080002381808080001A0B
 # BIN-NEXT:   - Type:DATA
 # BIN-NEXT: Relocations:
 # BIN-NEXT:   - Type:R_WASM_MEMORY_ADDR_I64
@@ -217,6 +230,11 @@
 # BIN-NEXT: Name:myglob64
 # BIN-NEXT: Flags:   [ UNDEFINED ]
 # BIN-NEXT: Global:  0
+# BIN-NEXT:   - Index:   3
+# BIN-NEXT: Kind:GLOBAL
+# BIN-NEXT: Name:__stack_pointer
+# BIN-NEXT: Flags:   [ UNDEFINED ]
+# BIN-NEXT: Global:  1
 # BIN-NEXT: SegmentInfo:
 # BIN-NEXT:   - Index:   0
 # BIN-NEXT: Name:.rodata..L.str
Index: llvm/test/MC/WebAssembly/stack-ptr.ll
===
--- llvm/test/MC/WebAssembly/stack-ptr.ll
+++ llvm/test/MC/WebAssembly/stack-ptr.ll
@@ -1,6 +1,5 @@
-; RUN: llc -filetype=obj %s -o - | obj2yaml | FileCheck %s
-
-target triple = "wasm32-unknown-unknown"
+; RUN: llc --mtriple=wasm32-unknown-unknown -filetype=obj %s -o - | obj2yaml | FileCheck --check-prefixes CHECK,CHK32 %s
+; RUN: llc --mtriple=wasm64-unknown-unknown -filetype=obj %s -o - | obj2yaml | FileCheck --check-prefixes CHECK,CHK64 %s
 
 ; Function that uses explict stack, and should generate a reference to
 ; __stack_pointer, along with the corresponding reloction entry.
@@ -15,7 +14,8 @@
 ; CHECK:   - Module:  env
 ; CHECK: Field:   __stack_pointer
 ; CHECK: Kind:GLOBAL
-; CHECK: GlobalType:  I32
+; CHK32: GlobalType:  I32
+; CHK64: GlobalType:  I64
 ; CHECK: GlobalMutable:   true
 ; CHECK:   - Type:CODE
 ; CHECK: Relocations:
Index: 

[clang] b9a539c - [WebAssembly] Adding 64-bit versions of __stack_pointer and other globals

2020-06-25 Thread Wouter van Oortmerssen via cfe-commits

Author: Wouter van Oortmerssen
Date: 2020-06-25T15:52:44-07:00
New Revision: b9a539c01084a572e406579c326a0da1e22e286f

URL: 
https://github.com/llvm/llvm-project/commit/b9a539c01084a572e406579c326a0da1e22e286f
DIFF: 
https://github.com/llvm/llvm-project/commit/b9a539c01084a572e406579c326a0da1e22e286f.diff

LOG: [WebAssembly] Adding 64-bit versions of __stack_pointer and other globals

We have 6 globals, all of which except for __table_base are 64-bit under wasm64.

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/WebAssembly.cpp
lld/wasm/Config.h
lld/wasm/Driver.cpp
lld/wasm/InputChunks.cpp
lld/wasm/Options.td
llvm/include/llvm/BinaryFormat/Wasm.h
llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
llvm/lib/Target/WebAssembly/WebAssemblyFrameLowering.cpp
llvm/lib/Target/WebAssembly/WebAssemblyFrameLowering.h
llvm/lib/Target/WebAssembly/WebAssemblyISelDAGToDAG.cpp
llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
llvm/lib/Target/WebAssembly/WebAssemblyLateEHPrepare.cpp
llvm/lib/Target/WebAssembly/WebAssemblyMCInstLower.cpp
llvm/lib/Target/WebAssembly/WebAssemblyRegStackify.cpp
llvm/lib/Target/WebAssembly/WebAssemblyRegisterInfo.cpp
llvm/test/CodeGen/WebAssembly/stack-alignment.ll
llvm/test/CodeGen/WebAssembly/userstack.ll
llvm/test/MC/WebAssembly/stack-ptr.ll
llvm/test/MC/WebAssembly/wasm64.s

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/WebAssembly.cpp 
b/clang/lib/Driver/ToolChains/WebAssembly.cpp
index 48f9a9b603db..13d713dfb54e 100644
--- a/clang/lib/Driver/ToolChains/WebAssembly.cpp
+++ b/clang/lib/Driver/ToolChains/WebAssembly.cpp
@@ -62,6 +62,12 @@ void wasm::Linker::ConstructJob(Compilation , const 
JobAction ,
   const char *Linker = Args.MakeArgString(getLinkerPath(Args));
   ArgStringList CmdArgs;
 
+  CmdArgs.push_back("-m");
+  if (getToolChain().getTriple().isArch64Bit())
+CmdArgs.push_back("wasm64");
+  else
+CmdArgs.push_back("wasm32");
+
   if (Args.hasArg(options::OPT_s))
 CmdArgs.push_back("--strip-all");
 

diff  --git a/lld/wasm/Config.h b/lld/wasm/Config.h
index 1ba28899e64d..4a1f7a69d079 100644
--- a/lld/wasm/Config.h
+++ b/lld/wasm/Config.h
@@ -36,6 +36,7 @@ struct Configuration {
   bool importMemory;
   bool sharedMemory;
   bool importTable;
+  bool is64;
   bool mergeDataSegments;
   bool pie;
   bool printGcSections;

diff  --git a/lld/wasm/Driver.cpp b/lld/wasm/Driver.cpp
index c6036111ec79..636aa6509b25 100644
--- a/lld/wasm/Driver.cpp
+++ b/lld/wasm/Driver.cpp
@@ -378,6 +378,18 @@ static void readConfigs(opt::InputArgList ) {
   config->exportDynamic =
   args.hasFlag(OPT_export_dynamic, OPT_no_export_dynamic, config->shared);
 
+  // Parse wasm32/64.
+  config->is64 = false;
+  if (auto *arg = args.getLastArg(OPT_m)) {
+StringRef s = arg->getValue();
+if (s == "wasm32")
+  config->is64 = false;
+else if (s == "wasm64")
+  config->is64 = true;
+else
+  error("invalid target architecture: " + s);
+  }
+
   // --threads= takes a positive integer and provides the default value for
   // --thinlto-jobs=.
   if (auto *arg = args.getLastArg(OPT_threads)) {
@@ -498,9 +510,15 @@ createUndefinedGlobal(StringRef name, 
llvm::wasm::WasmGlobalType *type) {
 static GlobalSymbol *createGlobalVariable(StringRef name, bool isMutable,
   int value) {
   llvm::wasm::WasmGlobal wasmGlobal;
-  wasmGlobal.Type = {WASM_TYPE_I32, isMutable};
-  wasmGlobal.InitExpr.Value.Int32 = value;
-  wasmGlobal.InitExpr.Opcode = WASM_OPCODE_I32_CONST;
+  if (config->is64) {
+wasmGlobal.Type = {WASM_TYPE_I64, isMutable};
+wasmGlobal.InitExpr.Value.Int64 = value;
+wasmGlobal.InitExpr.Opcode = WASM_OPCODE_I64_CONST;
+  } else {
+wasmGlobal.Type = {WASM_TYPE_I32, isMutable};
+wasmGlobal.InitExpr.Value.Int32 = value;
+wasmGlobal.InitExpr.Opcode = WASM_OPCODE_I32_CONST;
+  }
   wasmGlobal.SymbolName = name;
   return symtab->addSyntheticGlobal(name, WASM_SYMBOL_VISIBILITY_HIDDEN,
 make(wasmGlobal, nullptr));
@@ -513,9 +531,13 @@ static void createSyntheticSymbols() {
 
   static WasmSignature nullSignature = {{}, {}};
   static WasmSignature i32ArgSignature = {{}, {ValType::I32}};
+  static WasmSignature i64ArgSignature = {{}, {ValType::I64}};
   static llvm::wasm::WasmGlobalType globalTypeI32 = {WASM_TYPE_I32, false};
+  static llvm::wasm::WasmGlobalType globalTypeI64 = {WASM_TYPE_I64, false};
   static llvm::wasm::WasmGlobalType mutableGlobalTypeI32 = {WASM_TYPE_I32,
 true};
+  static llvm::wasm::WasmGlobalType mutableGlobalTypeI64 = {WASM_TYPE_I64,
+true};
   WasmSym::callCtors = symtab->addSyntheticFunction(
   

[PATCH] D82130: [WebAssembly] Adding 64-bit versions of __stack_pointer and other globals

2020-06-25 Thread Derek Schuff via Phabricator via cfe-commits
dschuff accepted this revision.
dschuff added a comment.

Compiler changes LGTM




Comment at: llvm/test/CodeGen/WebAssembly/stack-alignment.ll:1
-; RUN: llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt 
-wasm-keep-registers | FileCheck %s
-
-target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
-target triple = "wasm32-unknown-unknown"
+; RUN: llc < %s --mtriple=wasm32-unknown-unknown -asm-verbose=false 
-disable-wasm-fallthrough-return-opt -wasm-keep-registers | FileCheck -DPTR=32 
%s
+; RUN: llc < %s --mtriple=wasm64-unknown-unknown -asm-verbose=false 
-disable-wasm-fallthrough-return-opt -wasm-keep-registers | FileCheck -DPTR=64 
%s

that -D flag is really nice.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82130/new/

https://reviews.llvm.org/D82130



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


[PATCH] D82122: [analyzer][Liveness][RFC][NFC] Propose to turn statement liveness into expression liveness

2020-06-25 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus abandoned this revision.
Szelethus added a comment.

This revision has done its job.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82122/new/

https://reviews.llvm.org/D82122



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


[PATCH] D82598: [analyzer][Liveness][NFC] Get rid of statement liveness, because such a thing doesn't exist

2020-06-25 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ accepted this revision.
NoQ added a comment.
This revision is now accepted and ready to land.

> We could just kill all subexpr at the end of the full expression

I suspect that it would be pretty bad if you, say, kill the condition of the 
`if`-statement before picking the branch. Or kill the initializer in the 
`DeclStmt` before putting it into the variable (same for `CXXCtorInitializer` 
which isn't even a `Stmt`!).

> I might need a tip on how to test on ObjC code :)

Unfortunately i don't have any helpful tips for you :( Such code is not 
cross-compiled very often. I vaguely remember seeing some Objective-C code in 
linux software but it's most likely not very modern/representative. So i guess 
it's on us to inform you of the potential problems.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82598/new/

https://reviews.llvm.org/D82598



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


[PATCH] D71687: Fix full loop unrolling initialization in new pass manager

2020-06-25 Thread Eric Christopher via Phabricator via cfe-commits
echristo closed this revision.
echristo added a comment.

Committed a while back.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D71687/new/

https://reviews.llvm.org/D71687



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


[PATCH] D81938: [InferAddressSpaces] Handle the pair of `ptrtoint`/`inttoptr`.

2020-06-25 Thread Michael Liao via Phabricator via cfe-commits
hliao updated this revision to Diff 273531.
hliao added a comment.

remove 'an'


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81938/new/

https://reviews.llvm.org/D81938

Files:
  clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu
  llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp
  llvm/test/Transforms/InferAddressSpaces/AMDGPU/noop-ptrint-pair.ll

Index: llvm/test/Transforms/InferAddressSpaces/AMDGPU/noop-ptrint-pair.ll
===
--- /dev/null
+++ llvm/test/Transforms/InferAddressSpaces/AMDGPU/noop-ptrint-pair.ll
@@ -0,0 +1,101 @@
+; RUN: opt -mtriple=amdgcn-amd-amdhsa -S -o - -infer-address-spaces %s | FileCheck -check-prefixes=COMMON,AMDGCN %s
+; RUN: opt -S -o - -infer-address-spaces -assume-default-is-flat-addrspace %s | FileCheck -check-prefixes=COMMON,NOTTI %s
+
+target datalayout = "e-p:64:64-p1:64:64-p2:32:32-p3:32:32-p4:64:64-p5:32:32-p6:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-S32-A5-ni:7"
+
+; COMMON-LABEL: @noop_ptrint_pair(
+; AMDGCN-NEXT: store i32 0, i32 addrspace(1)* %{{.*}}
+; AMDGCN-NEXT: ret void
+; NOTTI-NEXT: %1 = ptrtoint i32 addrspace(1)* %x.coerce to i64
+; NOTTI-NEXT: %2 = inttoptr i64 %1 to i32*
+; NOTTI-NEXT: store i32 0, i32* %2
+; NOTTI-NEXT: ret void
+define void @noop_ptrint_pair(i32 addrspace(1)* %x.coerce) {
+  %1 = ptrtoint i32 addrspace(1)* %x.coerce to i64
+  %2 = inttoptr i64 %1 to i32*
+  store i32 0, i32* %2
+  ret void
+}
+
+; COMMON-LABEL: @non_noop_ptrint_pair(
+; AMDGCN-NEXT: ptrtoint i32 addrspace(3)* %{{.*}} to i64
+; AMDGCN-NEXT: inttoptr i64 %{{.*}} to i32*
+; AMDGCN-NEXT: store i32 0, i32* %{{.*}}
+; AMDGCN-NEXT: ret void
+; NOTTI-NEXT: ptrtoint i32 addrspace(3)* %{{.*}} to i64
+; NOTTI-NEXT: inttoptr i64 %{{.*}} to i32*
+; NOTTI-NEXT: store i32 0, i32* %{{.*}}
+; NOTTI-NEXT: ret void
+define void @non_noop_ptrint_pair(i32 addrspace(3)* %x.coerce) {
+  %1 = ptrtoint i32 addrspace(3)* %x.coerce to i64
+  %2 = inttoptr i64 %1 to i32*
+  store i32 0, i32* %2
+  ret void
+}
+
+; COMMON-LABEL: @non_noop_ptrint_pair2(
+; AMDGCN-NEXT: ptrtoint i32 addrspace(1)* %{{.*}} to i32
+; AMDGCN-NEXT: inttoptr i32 %{{.*}} to i32*
+; AMDGCN-NEXT: store i32 0, i32* %{{.*}}
+; AMDGCN-NEXT: ret void
+; NOTTI-NEXT: ptrtoint i32 addrspace(1)* %{{.*}} to i32
+; NOTTI-NEXT: inttoptr i32 %{{.*}} to i32*
+; NOTTI-NEXT: store i32 0, i32* %{{.*}}
+; NOTTI-NEXT: ret void
+define void @non_noop_ptrint_pair2(i32 addrspace(1)* %x.coerce) {
+  %1 = ptrtoint i32 addrspace(1)* %x.coerce to i32
+  %2 = inttoptr i32 %1 to i32*
+  store i32 0, i32* %2
+  ret void
+}
+
+@g = addrspace(1) global i32 0, align 4
+@l = addrspace(3) global i32 0, align 4
+
+; COMMON-LABEL: @noop_ptrint_pair_ce(
+; AMDGCN-NEXT: store i32 0, i32 addrspace(1)* @g
+; AMDGCN-NEXT: ret void
+; NOTTI-NEXT: store i32 0, i32* inttoptr (i64 ptrtoint (i32 addrspace(1)* @g to i64) to i32*)
+; NOTTI-NEXT: ret void
+define void @noop_ptrint_pair_ce() {
+  store i32 0, i32* inttoptr (i64 ptrtoint (i32 addrspace(1)* @g to i64) to i32*)
+  ret void
+}
+
+; COMMON-LABEL: @noop_ptrint_pair_ce2(
+; AMDGCN-NEXT: ret i32* addrspacecast (i32 addrspace(1)* @g to i32*)
+; NOTTI-NEXT: ret i32* inttoptr (i64 ptrtoint (i32 addrspace(1)* @g to i64) to i32*)
+define i32* @noop_ptrint_pair_ce2() {
+  ret i32* inttoptr (i64 ptrtoint (i32 addrspace(1)* @g to i64) to i32*)
+}
+
+; COMMON-LABEL: @non_noop_ptrint_pair_ce(
+; AMDGCN-NEXT: store i32 0, i32* inttoptr (i64 ptrtoint (i32 addrspace(3)* @l to i64) to i32*)
+; AMDGCN-NEXT: ret void
+; NOTTI-NEXT: store i32 0, i32* inttoptr (i64 ptrtoint (i32 addrspace(3)* @l to i64) to i32*)
+; NOTTI-NEXT: ret void
+define void @non_noop_ptrint_pair_ce() {
+  store i32 0, i32* inttoptr (i64 ptrtoint (i32 addrspace(3)* @l to i64) to i32*)
+  ret void
+}
+
+; COMMON-LABEL: @non_noop_ptrint_pair_ce2(
+; AMDGCN-NEXT: ret i32* inttoptr (i64 ptrtoint (i32 addrspace(3)* @l to i64) to i32*)
+; NOTTI-NEXT: ret i32* inttoptr (i64 ptrtoint (i32 addrspace(3)* @l to i64) to i32*)
+define i32* @non_noop_ptrint_pair_ce2() {
+  ret i32* inttoptr (i64 ptrtoint (i32 addrspace(3)* @l to i64) to i32*)
+}
+
+; COMMON-LABEL: @non_noop_ptrint_pair_ce3(
+; AMDGCN-NEXT: ret i32* inttoptr (i32 ptrtoint (i32 addrspace(1)* @g to i32) to i32*)
+; NOTTI-NEXT: ret i32* inttoptr (i32 ptrtoint (i32 addrspace(1)* @g to i32) to i32*)
+define i32* @non_noop_ptrint_pair_ce3() {
+  ret i32* inttoptr (i32 ptrtoint (i32 addrspace(1)* @g to i32) to i32*)
+}
+
+; COMMON-LABEL: @non_noop_ptrint_pair_ce4(
+; AMDGCN-NEXT: ret i32* inttoptr (i128 ptrtoint (i32 addrspace(3)* @l to i128) to i32*)
+; NOTTI-NEXT: ret i32* inttoptr (i128 ptrtoint (i32 addrspace(3)* @l to i128) to i32*)
+define i32* @non_noop_ptrint_pair_ce4() {
+  ret i32* inttoptr (i128 ptrtoint (i32 addrspace(3)* @l to i128) to i32*)
+}
Index: llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp

[PATCH] D82598: [analyzer][Liveness][NFC] Get rid of statement liveness, because such a thing doesn't exist

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

I always wondered if we actually need to track the liveness of exprs at all. We 
could just kill all subexpr at the end of the full expression without 
precomputing anything. But I might miss something.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82598/new/

https://reviews.llvm.org/D82598



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


[PATCH] D78655: [CUDA][HIP] Let non-caputuring lambda be host device

2020-06-25 Thread Aaron Enye Shi via Phabricator via cfe-commits
ashi1 added inline comments.



Comment at: clang/test/CodeGenCUDA/lambda.cu:53
+// DEV:  call void @_ZZ12test_resolvevENKUlvE_clEv
+// DEV-LABE: define internal void @_ZZ12test_resolvevENKUlvE_clEv
+// DEV:  call i32 @_Z10overloadedIiET_v

There is a typo here, DEV-LABEL


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D78655/new/

https://reviews.llvm.org/D78655



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


[PATCH] D79719: [AIX] Implement AIX special alignment rule about double/long double

2020-06-25 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added inline comments.



Comment at: clang/include/clang/AST/RecordLayout.h:75
+  // can be different than Alignment in cases where it is beneficial for
+  // performance or backwards compatibility perserving (e.g. AIX-ABI).
+  CharUnits PreferredAlignment;

I'm still evaluating this; however, I might as well note a minor nit first:
s/perserving/preserving/g;
for all instances within this patch.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D79719/new/

https://reviews.llvm.org/D79719



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


[PATCH] D79972: [OpenMP5.0] map item can be non-contiguous for target update

2020-06-25 Thread Chi Chun Chen via Phabricator via cfe-commits
cchen updated this revision to Diff 273529.
cchen added a comment.

Pass Info directly


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D79972/new/

https://reviews.llvm.org/D79972

Files:
  clang/include/clang/AST/OpenMPClause.h
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.h
  clang/lib/Sema/SemaOpenMP.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/OpenMP/target_update_ast_print.cpp
  clang/test/OpenMP/target_update_codegen.cpp
  clang/test/OpenMP/target_update_messages.cpp
  clang/test/OpenMP/target_update_to_messages.cpp

Index: clang/test/OpenMP/target_update_to_messages.cpp
===
--- clang/test/OpenMP/target_update_to_messages.cpp
+++ clang/test/OpenMP/target_update_to_messages.cpp
@@ -79,6 +79,10 @@
 #pragma omp target update to(*(*(this->ptr)+a+this->ptr)) // le45-error {{expected expression containing only member accesses and/or array sections based on named variables}} le45-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
 #pragma omp target update to(*(this+this)) // expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}} expected-error {{invalid operands to binary expression ('S8 *' and 'S8 *')}}
 {}
+
+double marr[10][5][10];
+#pragma omp target update to(marr [0:] [2:4] [1:2]) // le45-error {{array section does not specify contiguous storage}} le45-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
+{}
   }
 };
 
Index: clang/test/OpenMP/target_update_messages.cpp
===
--- clang/test/OpenMP/target_update_messages.cpp
+++ clang/test/OpenMP/target_update_messages.cpp
@@ -1,6 +1,8 @@
-// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 %s -Wuninitialized
+// RUN: %clang_cc1 -verify=expected,le45 -fopenmp -ferror-limit 100 %s -Wuninitialized
+// RUN: %clang_cc1 -verify=expected,le50 -fopenmp -fopenmp-version=50 -ferror-limit 100 %s -Wuninitialized
 
-// RUN: %clang_cc1 -verify -fopenmp-simd -ferror-limit 100 %s -Wuninitialized
+// RUN: %clang_cc1 -verify=expected,le45 -fopenmp-simd -ferror-limit 100 %s -Wuninitialized
+// RUN: %clang_cc1 -verify=expected,le50 -fopenmp-simd -fopenmp-version=50 -ferror-limit 100 %s -Wuninitialized
 
 void xxx(int argc) {
   int x; // expected-note {{initialize the variable 'x' to silence this warning}}
@@ -36,5 +38,21 @@
   {
 foo();
   }
+
+  double marr[10][5][10];
+#pragma omp target update to(marr [0:] [2:4] [1:2]) // le45-error {{array section does not specify contiguous storage}} le45-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
+  {}
+#pragma omp target update from(marr [0:] [2:4] [1:2]) // le45-error {{array section does not specify contiguous storage}} le45-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
+
+  int arr[4][3][2][1];
+#pragma omp target update to(arr [0:2] [2:4][:2][1]) // le45-error {{array section does not specify contiguous storage}} le45-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
+  {}
+#pragma omp target update from(arr [0:2] [2:4][:2][1]) // le45-error {{array section does not specify contiguous storage}} le45-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
+
+  double ***dptr;
+#pragma omp target update to(dptr [0:2] [2:4] [1:2]) // le45-error {{array section does not specify contiguous storage}} le50-error 2 {{section length is unspecified and cannot be inferred because subscripted value is an array of unknown bound}} le45-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
+  {}
+#pragma omp target update from(dptr [0:2] [2:4] [1:2]) // le45-error {{array section does not specify contiguous storage}} le50-error 2 {{section length is unspecified and cannot be inferred because subscripted value is an array of unknown bound}} le45-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
+
   return tmain(argc, argv);
 }
Index: clang/test/OpenMP/target_update_codegen.cpp
===
--- clang/test/OpenMP/target_update_codegen.cpp
+++ clang/test/OpenMP/target_update_codegen.cpp
@@ -1059,5 +1059,304 @@
   #pragma omp target update from(([sa][5])f)
 }
 
+#endif
+///==///
+// RUN: %clang_cc1 -DCK19 -verify -fopenmp -fopenmp-version=50 -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck %s --check-prefix CK19 

[PATCH] D82561: [analyzer][CrossTU] Lower CTUImportThreshold default value

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

The analyzer inlines small functions within a TU regardless of the thresholds. 
I think it would be sensible to do the same across TUs in the case we don't do 
this already.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82561/new/

https://reviews.llvm.org/D82561



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


[PATCH] D82130: [WebAssembly] Adding 64-bit versions of __stack_pointer and other globals

2020-06-25 Thread Sam Clegg via Phabricator via cfe-commits
sbc100 accepted this revision.
sbc100 added a comment.

Linker changes still lgtm % comments




Comment at: lld/wasm/InputChunks.cpp:338
 
+  auto WASM_OPCODE_PTR_CONST =
+  config->is64 ? WASM_OPCODE_I64_CONST : WASM_OPCODE_I32_CONST;

sbc100 wrote:
> Just use normal variable names here?  `opcode_const` and `opcode_add`?
Normal variable names?



Comment at: lld/wasm/InputChunks.cpp:363
+
+auto is64 = relocIs64(rel.Type);
+auto opcode_const =

Again I think you appetite for the use of auto is exceeding that of the llvm 
coding style...  I tend to stick to cases where the type is spelled out later 
in the same line.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82130/new/

https://reviews.llvm.org/D82130



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


[PATCH] D82604: No nested namespaces in Clang-Tidy checkers

2020-06-25 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

Isn't that C++17?
LLVM is at C++14.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82604/new/

https://reviews.llvm.org/D82604



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


[PATCH] D82606: [clangd] Config: config struct propagated through Context

2020-06-25 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
sammccall added reviewers: hokein, kadircet.
Herald added subscribers: cfe-commits, usaxena95, arphaman, jkorous, MaskRay, 
ilya-biryukov, mgorny.
Herald added a project: clang.

This introduces the "semantic form" of config exposed to features,
contrasted with the "syntactic form" exposed to users in e9fb1506b83d 
.

The two are not connected, CompiledFragment and Provider will bridge that gap.
Nor is configuration actually set: that needs changes to ClangdServer,
TUScheduler, and BackgroundQueue.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D82606

Files:
  clang-tools-extra/clangd/CMakeLists.txt
  clang-tools-extra/clangd/CompileCommands.cpp
  clang-tools-extra/clangd/Config.cpp
  clang-tools-extra/clangd/Config.h
  clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp

Index: clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp
===
--- clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp
+++ clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp
@@ -7,7 +7,9 @@
 //===--===//
 
 #include "CompileCommands.h"
+#include "Config.h"
 #include "TestFS.h"
+#include "support/Context.h"
 
 #include "llvm/ADT/ScopeExit.h"
 #include "llvm/ADT/StringExtras.h"
@@ -185,6 +187,26 @@
 }
 #endif
 
+TEST(CommandMangler, ConfigEdits) {
+  auto Mangler = CommandMangler::forTests();
+  std::vector Cmd = {"clang++", "foo.cc"};
+  {
+Config Cfg;
+Cfg.CompileFlags.Edits.push_back([](std::vector ) {
+  for (auto  : Argv)
+for (char  : Arg)
+  C = llvm::toUpper(C);
+});
+Cfg.CompileFlags.Edits.push_back(
+[](std::vector ) { Argv.push_back("--hello"); });
+WithContextValue WithConfig(Config::Key, std::move(Cfg));
+Mangler.adjust(Cmd);
+  }
+  // Edits are applied in given order and before other mangling.
+  EXPECT_THAT(Cmd,
+  ElementsAre("CLANG++", "FOO.CC", "--hello", "-fsyntax-only"));
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/Config.h
===
--- /dev/null
+++ clang-tools-extra/clangd/Config.h
@@ -0,0 +1,64 @@
+//===--- Config.h - User configuration of clangd behavior *- C++-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// Various clangd features have configurable behaviour (or can be disabled).
+// This file defines "resolved" configuration seen by features within clangd.
+// For example, settings may vary per-file, the resolved Config only contains
+// settings that apply to the current file.
+//
+// This is distinct from how the config is specified by the user (Fragment)
+// interpreted (CompiledFragment), and combined (Provider).
+// ConfigFragment.h describes the steps to add a new configuration option.
+//
+// Because this structure is shared throughout clangd, it's a potential source
+// of layering problems. Config should be expressed in terms of simple
+// vocubulary types where possible.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_CONFIG_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_CONFIG_H
+
+#include "support/Context.h"
+#include "llvm/ADT/FunctionExtras.h"
+#include 
+#include 
+
+namespace clang {
+namespace clangd {
+
+/// Settings that express user/project preferences and control clangd behavior.
+///
+/// Generally, features should consume config() and the caller is responsible
+/// for setting it appropriately. In practice these callers are ClangdServer,
+/// TUScheduler, and BackgroundQueue.
+struct Config {
+  /// Context key which can be used to set the current Config.
+  static clangd::Key Key;
+
+  Config() = default;
+  Config(const Config &) = delete;
+  Config =(const Config &) = delete;
+  Config(Config &&) = default;
+  Config =(Config &&) = default;
+
+  /// Controls how the compile command for the current file is determined.
+  struct {
+// Edits to apply to the compile command, in sequence.
+// FIXME: these functions need to be const-callable. For now, const_cast.
+std::vector &)>> Edits;
+  } CompileFlags;
+};
+
+/// Returns the Config of the current Context, or an empty configuration.
+const Config ();
+
+} // namespace clangd
+} // namespace clang
+
+#endif
Index: clang-tools-extra/clangd/Config.cpp
===
--- /dev/null
+++ clang-tools-extra/clangd/Config.cpp
@@ -0,0 +1,25 @@
+//===--- Config.cpp - User configuration of clangd 

[PATCH] D81938: [InferAddressSpaces] Handle the pair of `ptrtoint`/`inttoptr`.

2020-06-25 Thread Michael Liao via Phabricator via cfe-commits
hliao updated this revision to Diff 273524.
hliao added a comment.

Revie the grammar. s/is/as/ in the first sentence.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81938/new/

https://reviews.llvm.org/D81938

Files:
  clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu
  llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp
  llvm/test/Transforms/InferAddressSpaces/AMDGPU/noop-ptrint-pair.ll

Index: llvm/test/Transforms/InferAddressSpaces/AMDGPU/noop-ptrint-pair.ll
===
--- /dev/null
+++ llvm/test/Transforms/InferAddressSpaces/AMDGPU/noop-ptrint-pair.ll
@@ -0,0 +1,101 @@
+; RUN: opt -mtriple=amdgcn-amd-amdhsa -S -o - -infer-address-spaces %s | FileCheck -check-prefixes=COMMON,AMDGCN %s
+; RUN: opt -S -o - -infer-address-spaces -assume-default-is-flat-addrspace %s | FileCheck -check-prefixes=COMMON,NOTTI %s
+
+target datalayout = "e-p:64:64-p1:64:64-p2:32:32-p3:32:32-p4:64:64-p5:32:32-p6:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-S32-A5-ni:7"
+
+; COMMON-LABEL: @noop_ptrint_pair(
+; AMDGCN-NEXT: store i32 0, i32 addrspace(1)* %{{.*}}
+; AMDGCN-NEXT: ret void
+; NOTTI-NEXT: %1 = ptrtoint i32 addrspace(1)* %x.coerce to i64
+; NOTTI-NEXT: %2 = inttoptr i64 %1 to i32*
+; NOTTI-NEXT: store i32 0, i32* %2
+; NOTTI-NEXT: ret void
+define void @noop_ptrint_pair(i32 addrspace(1)* %x.coerce) {
+  %1 = ptrtoint i32 addrspace(1)* %x.coerce to i64
+  %2 = inttoptr i64 %1 to i32*
+  store i32 0, i32* %2
+  ret void
+}
+
+; COMMON-LABEL: @non_noop_ptrint_pair(
+; AMDGCN-NEXT: ptrtoint i32 addrspace(3)* %{{.*}} to i64
+; AMDGCN-NEXT: inttoptr i64 %{{.*}} to i32*
+; AMDGCN-NEXT: store i32 0, i32* %{{.*}}
+; AMDGCN-NEXT: ret void
+; NOTTI-NEXT: ptrtoint i32 addrspace(3)* %{{.*}} to i64
+; NOTTI-NEXT: inttoptr i64 %{{.*}} to i32*
+; NOTTI-NEXT: store i32 0, i32* %{{.*}}
+; NOTTI-NEXT: ret void
+define void @non_noop_ptrint_pair(i32 addrspace(3)* %x.coerce) {
+  %1 = ptrtoint i32 addrspace(3)* %x.coerce to i64
+  %2 = inttoptr i64 %1 to i32*
+  store i32 0, i32* %2
+  ret void
+}
+
+; COMMON-LABEL: @non_noop_ptrint_pair2(
+; AMDGCN-NEXT: ptrtoint i32 addrspace(1)* %{{.*}} to i32
+; AMDGCN-NEXT: inttoptr i32 %{{.*}} to i32*
+; AMDGCN-NEXT: store i32 0, i32* %{{.*}}
+; AMDGCN-NEXT: ret void
+; NOTTI-NEXT: ptrtoint i32 addrspace(1)* %{{.*}} to i32
+; NOTTI-NEXT: inttoptr i32 %{{.*}} to i32*
+; NOTTI-NEXT: store i32 0, i32* %{{.*}}
+; NOTTI-NEXT: ret void
+define void @non_noop_ptrint_pair2(i32 addrspace(1)* %x.coerce) {
+  %1 = ptrtoint i32 addrspace(1)* %x.coerce to i32
+  %2 = inttoptr i32 %1 to i32*
+  store i32 0, i32* %2
+  ret void
+}
+
+@g = addrspace(1) global i32 0, align 4
+@l = addrspace(3) global i32 0, align 4
+
+; COMMON-LABEL: @noop_ptrint_pair_ce(
+; AMDGCN-NEXT: store i32 0, i32 addrspace(1)* @g
+; AMDGCN-NEXT: ret void
+; NOTTI-NEXT: store i32 0, i32* inttoptr (i64 ptrtoint (i32 addrspace(1)* @g to i64) to i32*)
+; NOTTI-NEXT: ret void
+define void @noop_ptrint_pair_ce() {
+  store i32 0, i32* inttoptr (i64 ptrtoint (i32 addrspace(1)* @g to i64) to i32*)
+  ret void
+}
+
+; COMMON-LABEL: @noop_ptrint_pair_ce2(
+; AMDGCN-NEXT: ret i32* addrspacecast (i32 addrspace(1)* @g to i32*)
+; NOTTI-NEXT: ret i32* inttoptr (i64 ptrtoint (i32 addrspace(1)* @g to i64) to i32*)
+define i32* @noop_ptrint_pair_ce2() {
+  ret i32* inttoptr (i64 ptrtoint (i32 addrspace(1)* @g to i64) to i32*)
+}
+
+; COMMON-LABEL: @non_noop_ptrint_pair_ce(
+; AMDGCN-NEXT: store i32 0, i32* inttoptr (i64 ptrtoint (i32 addrspace(3)* @l to i64) to i32*)
+; AMDGCN-NEXT: ret void
+; NOTTI-NEXT: store i32 0, i32* inttoptr (i64 ptrtoint (i32 addrspace(3)* @l to i64) to i32*)
+; NOTTI-NEXT: ret void
+define void @non_noop_ptrint_pair_ce() {
+  store i32 0, i32* inttoptr (i64 ptrtoint (i32 addrspace(3)* @l to i64) to i32*)
+  ret void
+}
+
+; COMMON-LABEL: @non_noop_ptrint_pair_ce2(
+; AMDGCN-NEXT: ret i32* inttoptr (i64 ptrtoint (i32 addrspace(3)* @l to i64) to i32*)
+; NOTTI-NEXT: ret i32* inttoptr (i64 ptrtoint (i32 addrspace(3)* @l to i64) to i32*)
+define i32* @non_noop_ptrint_pair_ce2() {
+  ret i32* inttoptr (i64 ptrtoint (i32 addrspace(3)* @l to i64) to i32*)
+}
+
+; COMMON-LABEL: @non_noop_ptrint_pair_ce3(
+; AMDGCN-NEXT: ret i32* inttoptr (i32 ptrtoint (i32 addrspace(1)* @g to i32) to i32*)
+; NOTTI-NEXT: ret i32* inttoptr (i32 ptrtoint (i32 addrspace(1)* @g to i32) to i32*)
+define i32* @non_noop_ptrint_pair_ce3() {
+  ret i32* inttoptr (i32 ptrtoint (i32 addrspace(1)* @g to i32) to i32*)
+}
+
+; COMMON-LABEL: @non_noop_ptrint_pair_ce4(
+; AMDGCN-NEXT: ret i32* inttoptr (i128 ptrtoint (i32 addrspace(3)* @l to i128) to i32*)
+; NOTTI-NEXT: ret i32* inttoptr (i128 ptrtoint (i32 addrspace(3)* @l to i128) to i32*)
+define i32* @non_noop_ptrint_pair_ce4() {
+  ret i32* inttoptr (i128 ptrtoint (i32 addrspace(3)* @l to i128) to i32*)
+}
Index: 

[PATCH] D82226: Add Metadata to Transformer tooling

2020-06-25 Thread Andy Soffer via Phabricator via cfe-commits
asoffer updated this revision to Diff 273522.
asoffer added a comment.

Last diff was a mistake.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82226/new/

https://reviews.llvm.org/D82226

Files:
  clang/include/clang/Tooling/Refactoring/AtomicChange.h
  clang/include/clang/Tooling/Transformer/RewriteRule.h
  clang/lib/Tooling/Refactoring/AtomicChange.cpp
  clang/lib/Tooling/Transformer/RewriteRule.cpp
  clang/lib/Tooling/Transformer/Transformer.cpp
  clang/unittests/Tooling/RefactoringTest.cpp
  clang/unittests/Tooling/TransformerTest.cpp

Index: clang/unittests/Tooling/TransformerTest.cpp
===
--- clang/unittests/Tooling/TransformerTest.cpp
+++ clang/unittests/Tooling/TransformerTest.cpp
@@ -439,6 +439,29 @@
   Input, Expected);
 }
 
+TEST_F(TransformerTest, WithMetadata) {
+  std::string Input = R"cc(
+int f() {
+  int x = 5;
+  return 7;
+}
+  )cc";
+
+  Transformer T(
+  makeRule(declStmt().bind("decl"),
+   withMetadata(remove(statement(std::string("decl"))), 17)),
+  consumer());
+  T.registerMatchers();
+  auto Factory = newFrontendActionFactory();
+  EXPECT_TRUE(runToolOnCodeWithArgs(
+  Factory->create(), Input, std::vector(), "input.cc",
+  "clang-tool", std::make_shared(), {}));
+  ASSERT_EQ(Changes.size(), 1);
+  const llvm::Any  = Changes[0].getMetadata();
+  ASSERT_TRUE(llvm::any_isa(Metadata));
+  EXPECT_THAT(llvm::any_cast(Metadata), 17);
+}
+
 TEST_F(TransformerTest, MultiChange) {
   std::string Input = R"cc(
 void foo() {
Index: clang/unittests/Tooling/RefactoringTest.cpp
===
--- clang/unittests/Tooling/RefactoringTest.cpp
+++ clang/unittests/Tooling/RefactoringTest.cpp
@@ -1296,6 +1296,18 @@
   Replacement(Context.Sources, SourceLocation(), 0, "b")));
 }
 
+TEST_F(AtomicChangeTest, Metadata) {
+  AtomicChange Change(Context.Sources, DefaultLoc, 17);
+  const llvm::Any  = Change.getMetadata();
+  ASSERT_TRUE(llvm::any_isa(Metadata));
+  EXPECT_EQ(llvm::any_cast(Metadata), 17);
+}
+
+TEST_F(AtomicChangeTest, NoMetadata) {
+  AtomicChange Change(Context.Sources, DefaultLoc);
+  EXPECT_FALSE(Change.getMetadata().hasValue());
+}
+
 class ApplyAtomicChangesTest : public ::testing::Test {
 protected:
   ApplyAtomicChangesTest() : FilePath("file.cc") {
Index: clang/lib/Tooling/Transformer/Transformer.cpp
===
--- clang/lib/Tooling/Transformer/Transformer.cpp
+++ clang/lib/Tooling/Transformer/Transformer.cpp
@@ -53,7 +53,7 @@
 auto ID = Result.SourceManager->getFileID(T.Range.getBegin());
 auto Iter = ChangesByFileID
 .emplace(ID, AtomicChange(*Result.SourceManager,
-  T.Range.getBegin()))
+  T.Range.getBegin(), T.Metadata))
 .first;
 auto  = Iter->second;
 if (auto Err = AC.replace(*Result.SourceManager, T.Range, T.Replacement)) {
Index: clang/lib/Tooling/Transformer/RewriteRule.cpp
===
--- clang/lib/Tooling/Transformer/RewriteRule.cpp
+++ clang/lib/Tooling/Transformer/RewriteRule.cpp
@@ -47,6 +47,7 @@
 transformer::Edit T;
 T.Range = *EditRange;
 T.Replacement = std::move(*Replacement);
+T.Metadata = E.Metadata;
 Edits.push_back(std::move(T));
   }
   return Edits;
Index: clang/lib/Tooling/Refactoring/AtomicChange.cpp
===
--- clang/lib/Tooling/Refactoring/AtomicChange.cpp
+++ clang/lib/Tooling/Refactoring/AtomicChange.cpp
@@ -204,6 +204,12 @@
   Key = FilePath + ":" + std::to_string(FileIDAndOffset.second);
 }
 
+AtomicChange::AtomicChange(const SourceManager , SourceLocation KeyPosition,
+   llvm::Any M)
+: AtomicChange(SM, KeyPosition) {
+  Metadata = std::move(M);
+}
+
 AtomicChange::AtomicChange(std::string Key, std::string FilePath,
std::string Error,
std::vector InsertedHeaders,
Index: clang/include/clang/Tooling/Transformer/RewriteRule.h
===
--- clang/include/clang/Tooling/Transformer/RewriteRule.h
+++ clang/include/clang/Tooling/Transformer/RewriteRule.h
@@ -35,6 +35,7 @@
 struct Edit {
   CharSourceRange Range;
   std::string Replacement;
+  llvm::Any Metadata;
 };
 
 /// Maps a match result to a list of concrete edits (with possible
@@ -85,6 +86,7 @@
   RangeSelector TargetRange;
   TextGenerator Replacement;
   TextGenerator Note;
+  llvm::Any Metadata;
 };
 
 /// Lifts a list of `ASTEdit`s into an `EditGenerator`.
@@ -258,6 +260,11 @@
 /// Removes the source selected by \p S.
 ASTEdit remove(RangeSelector S);
 
+inline ASTEdit withMetadata(ASTEdit edit, 

[PATCH] D80970: [PowerPC][Power10] Implement centrifuge, vector gather every nth bit, vector evaluate Builtins in LLVM/Clang

2020-06-25 Thread Amy Kwan via Phabricator via cfe-commits
amyk added a comment.

Talked to Anil, and will address his nit comments on the commit and disregard 
the comment about the test.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D80970/new/

https://reviews.llvm.org/D80970



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


[PATCH] D82604: No nested namespaces in Clang-Tidy checkers

2020-06-25 Thread Seija Kijin via Phabricator via cfe-commits
pi1024e created this revision.
Herald added subscribers: cfe-commits, Charusso.
Herald added a project: clang.

A lot of the code, including ironically the nested namespace checker itself, 
was using "namespace clang { tidy { modernize...", so I put those together for 
readability as "namespace clang::tidy::modernize"


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D82604

Files:
  clang-tools-extra/clang-tidy/modernize/AvoidBindCheck.cpp
  clang-tools-extra/clang-tidy/modernize/AvoidBindCheck.h
  clang-tools-extra/clang-tidy/modernize/AvoidCArraysCheck.cpp
  clang-tools-extra/clang-tidy/modernize/AvoidCArraysCheck.h
  clang-tools-extra/clang-tidy/modernize/ConcatNestedNamespacesCheck.cpp
  clang-tools-extra/clang-tidy/modernize/ConcatNestedNamespacesCheck.h
  clang-tools-extra/clang-tidy/modernize/DeprecatedHeadersCheck.cpp
  clang-tools-extra/clang-tidy/modernize/DeprecatedHeadersCheck.h
  clang-tools-extra/clang-tidy/modernize/DeprecatedIosBaseAliasesCheck.cpp
  clang-tools-extra/clang-tidy/modernize/DeprecatedIosBaseAliasesCheck.h
  clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp
  clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.h
  clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.cpp
  clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.h
  clang-tools-extra/clang-tidy/modernize/MakeSharedCheck.cpp
  clang-tools-extra/clang-tidy/modernize/MakeSharedCheck.h
  clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.cpp
  clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.h
  clang-tools-extra/clang-tidy/modernize/MakeUniqueCheck.cpp
  clang-tools-extra/clang-tidy/modernize/MakeUniqueCheck.h
  clang-tools-extra/clang-tidy/modernize/ModernizeTidyModule.cpp
  clang-tools-extra/clang-tidy/modernize/PassByValueCheck.cpp
  clang-tools-extra/clang-tidy/modernize/PassByValueCheck.h
  clang-tools-extra/clang-tidy/modernize/RawStringLiteralCheck.cpp
  clang-tools-extra/clang-tidy/modernize/RawStringLiteralCheck.h
  clang-tools-extra/clang-tidy/modernize/RedundantVoidArgCheck.cpp
  clang-tools-extra/clang-tidy/modernize/RedundantVoidArgCheck.h
  clang-tools-extra/clang-tidy/modernize/ReplaceAutoPtrCheck.cpp
  clang-tools-extra/clang-tidy/modernize/ReplaceAutoPtrCheck.h
  
clang-tools-extra/clang-tidy/modernize/ReplaceDisallowCopyAndAssignMacroCheck.cpp
  
clang-tools-extra/clang-tidy/modernize/ReplaceDisallowCopyAndAssignMacroCheck.h
  clang-tools-extra/clang-tidy/modernize/ReplaceRandomShuffleCheck.cpp
  clang-tools-extra/clang-tidy/modernize/ReplaceRandomShuffleCheck.h
  clang-tools-extra/clang-tidy/modernize/ReturnBracedInitListCheck.cpp
  clang-tools-extra/clang-tidy/modernize/ReturnBracedInitListCheck.h
  clang-tools-extra/clang-tidy/modernize/ShrinkToFitCheck.cpp
  clang-tools-extra/clang-tidy/modernize/ShrinkToFitCheck.h
  clang-tools-extra/clang-tidy/modernize/UnaryStaticAssertCheck.cpp
  clang-tools-extra/clang-tidy/modernize/UnaryStaticAssertCheck.h
  clang-tools-extra/clang-tidy/modernize/UseAutoCheck.cpp
  clang-tools-extra/clang-tidy/modernize/UseAutoCheck.h
  clang-tools-extra/clang-tidy/modernize/UseBoolLiteralsCheck.cpp
  clang-tools-extra/clang-tidy/modernize/UseBoolLiteralsCheck.h
  clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
  clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.h
  clang-tools-extra/clang-tidy/modernize/UseEmplaceCheck.cpp
  clang-tools-extra/clang-tidy/modernize/UseEmplaceCheck.h
  clang-tools-extra/clang-tidy/modernize/UseEqualsDefaultCheck.cpp
  clang-tools-extra/clang-tidy/modernize/UseEqualsDefaultCheck.h
  clang-tools-extra/clang-tidy/modernize/UseEqualsDeleteCheck.cpp
  clang-tools-extra/clang-tidy/modernize/UseEqualsDeleteCheck.h
  clang-tools-extra/clang-tidy/modernize/UseNodiscardCheck.cpp
  clang-tools-extra/clang-tidy/modernize/UseNodiscardCheck.h
  clang-tools-extra/clang-tidy/modernize/UseNoexceptCheck.cpp
  clang-tools-extra/clang-tidy/modernize/UseNoexceptCheck.h
  clang-tools-extra/clang-tidy/modernize/UseNullptrCheck.cpp
  clang-tools-extra/clang-tidy/modernize/UseNullptrCheck.h
  clang-tools-extra/clang-tidy/modernize/UseOverrideCheck.cpp
  clang-tools-extra/clang-tidy/modernize/UseOverrideCheck.h
  clang-tools-extra/clang-tidy/modernize/UseTrailingReturnTypeCheck.cpp
  clang-tools-extra/clang-tidy/modernize/UseTrailingReturnTypeCheck.h
  clang-tools-extra/clang-tidy/modernize/UseTransparentFunctorsCheck.cpp
  clang-tools-extra/clang-tidy/modernize/UseTransparentFunctorsCheck.h
  clang-tools-extra/clang-tidy/modernize/UseUncaughtExceptionsCheck.cpp
  clang-tools-extra/clang-tidy/modernize/UseUncaughtExceptionsCheck.h
  clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp
  clang-tools-extra/clang-tidy/modernize/UseUsingCheck.h
  clang/lib/Analysis/Consumed.cpp
  clang/lib/Analysis/ReachableCode.cpp
  clang/lib/Analysis/ThreadSafety.cpp
  clang/lib/Analysis/ThreadSafetyCommon.cpp
  clang/lib/Analysis/ThreadSafetyLogical.cpp

Index: 

[PATCH] D79972: [OpenMP5.0] map item can be non-contiguous for target update

2020-06-25 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: clang/lib/CodeGen/CGOpenMPRuntime.cpp:10334-10335
+MCHandler.generateAllInfo(BasePointers, Pointers, Sizes, MapTypes,
+  Info.Dims, Info.Offsets, Info.Counts,
+  Info.Strides);
 

Better to pass `Info` here directly.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D79972/new/

https://reviews.llvm.org/D79972



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


[PATCH] D82226: Add Metadata to Transformer tooling

2020-06-25 Thread Andy Soffer via Phabricator via cfe-commits
asoffer updated this revision to Diff 273520.
asoffer marked an inline comment as done.
asoffer added a comment.

Updating other test.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82226/new/

https://reviews.llvm.org/D82226

Files:
  clang/include/clang/Tooling/Refactoring/AtomicChange.h
  clang/include/clang/Tooling/Transformer/RewriteRule.h
  clang/lib/Tooling/Refactoring/AtomicChange.cpp
  clang/lib/Tooling/Transformer/RewriteRule.cpp
  clang/lib/Tooling/Transformer/Transformer.cpp
  clang/unittests/Tooling/RefactoringTest.cpp
  clang/unittests/Tooling/TransformerTest.cpp

Index: clang/unittests/Tooling/TransformerTest.cpp
===
--- clang/unittests/Tooling/TransformerTest.cpp
+++ clang/unittests/Tooling/TransformerTest.cpp
@@ -439,6 +439,29 @@
   Input, Expected);
 }
 
+TEST_F(TransformerTest, WithMetadata) {
+  std::string Input = R"cc(
+int f() {
+  int x = 5;
+  return 7;
+}
+  )cc";
+
+  Transformer T(
+  makeRule(declStmt().bind("decl"),
+   withMetadata(remove(statement(std::string("decl"))), 17)),
+  consumer());
+  T.registerMatchers();
+  auto Factory = newFrontendActionFactory();
+  EXPECT_TRUE(runToolOnCodeWithArgs(
+  Factory->create(), Input, std::vector(), "input.cc",
+  "clang-tool", std::make_shared(), {}));
+  ASSERT_EQ(Changes.size(), 1);
+  const llvm::Any  = Changes[0].getMetadata();
+  ASSERT_TRUE(llvm::any_isa(Metadata));
+  EXPECT_THAT(llvm::any_cast(Metadata), 17);
+}
+
 TEST_F(TransformerTest, MultiChange) {
   std::string Input = R"cc(
 void foo() {
Index: clang/unittests/Tooling/RefactoringTest.cpp
===
--- clang/unittests/Tooling/RefactoringTest.cpp
+++ clang/unittests/Tooling/RefactoringTest.cpp
@@ -1296,6 +1296,22 @@
   Replacement(Context.Sources, SourceLocation(), 0, "b")));
 }
 
+struct SomeMetadata {
+  int Data;
+};
+
+TEST_F(AtomicChangeTest, Metadata) {
+  AtomicChange Change(Context.Sources, DefaultLoc, SomeMetadata{17});
+  const llvm::Any  = Change.getMetadata();
+  ASSERT_TRUE(llvm::any_isa(Metadata));
+  EXPECT_EQ(llvm::any_cast(Metadata).Data, 17);
+}
+
+TEST_F(AtomicChangeTest, NoMetadata) {
+  AtomicChange Change(Context.Sources, DefaultLoc);
+  EXPECT_FALSE(Change.getMetadata().hasValue());
+}
+
 class ApplyAtomicChangesTest : public ::testing::Test {
 protected:
   ApplyAtomicChangesTest() : FilePath("file.cc") {
Index: clang/lib/Tooling/Transformer/Transformer.cpp
===
--- clang/lib/Tooling/Transformer/Transformer.cpp
+++ clang/lib/Tooling/Transformer/Transformer.cpp
@@ -53,7 +53,7 @@
 auto ID = Result.SourceManager->getFileID(T.Range.getBegin());
 auto Iter = ChangesByFileID
 .emplace(ID, AtomicChange(*Result.SourceManager,
-  T.Range.getBegin()))
+  T.Range.getBegin(), T.Metadata))
 .first;
 auto  = Iter->second;
 if (auto Err = AC.replace(*Result.SourceManager, T.Range, T.Replacement)) {
Index: clang/lib/Tooling/Transformer/RewriteRule.cpp
===
--- clang/lib/Tooling/Transformer/RewriteRule.cpp
+++ clang/lib/Tooling/Transformer/RewriteRule.cpp
@@ -47,6 +47,7 @@
 transformer::Edit T;
 T.Range = *EditRange;
 T.Replacement = std::move(*Replacement);
+T.Metadata = E.Metadata;
 Edits.push_back(std::move(T));
   }
   return Edits;
Index: clang/lib/Tooling/Refactoring/AtomicChange.cpp
===
--- clang/lib/Tooling/Refactoring/AtomicChange.cpp
+++ clang/lib/Tooling/Refactoring/AtomicChange.cpp
@@ -204,6 +204,12 @@
   Key = FilePath + ":" + std::to_string(FileIDAndOffset.second);
 }
 
+AtomicChange::AtomicChange(const SourceManager , SourceLocation KeyPosition,
+   llvm::Any M)
+: AtomicChange(SM, KeyPosition) {
+  Metadata = std::move(M);
+}
+
 AtomicChange::AtomicChange(std::string Key, std::string FilePath,
std::string Error,
std::vector InsertedHeaders,
Index: clang/include/clang/Tooling/Transformer/RewriteRule.h
===
--- clang/include/clang/Tooling/Transformer/RewriteRule.h
+++ clang/include/clang/Tooling/Transformer/RewriteRule.h
@@ -35,6 +35,7 @@
 struct Edit {
   CharSourceRange Range;
   std::string Replacement;
+  llvm::Any Metadata;
 };
 
 /// Maps a match result to a list of concrete edits (with possible
@@ -85,6 +86,7 @@
   RangeSelector TargetRange;
   TextGenerator Replacement;
   TextGenerator Note;
+  llvm::Any Metadata;
 };
 
 /// Lifts a list of `ASTEdit`s into an `EditGenerator`.
@@ -258,6 +260,11 @@
 /// Removes the source 

[PATCH] D82226: Add Metadata to Transformer tooling

2020-06-25 Thread Andy Soffer via Phabricator via cfe-commits
asoffer updated this revision to Diff 273516.
asoffer marked an inline comment as done and an inline comment as not done.
asoffer added a comment.

Commenting fields and simplifying test.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82226/new/

https://reviews.llvm.org/D82226

Files:
  clang/include/clang/Tooling/Refactoring/AtomicChange.h
  clang/include/clang/Tooling/Transformer/RewriteRule.h
  clang/lib/Tooling/Refactoring/AtomicChange.cpp
  clang/lib/Tooling/Transformer/RewriteRule.cpp
  clang/lib/Tooling/Transformer/Transformer.cpp
  clang/unittests/Tooling/RefactoringTest.cpp
  clang/unittests/Tooling/TransformerTest.cpp

Index: clang/unittests/Tooling/TransformerTest.cpp
===
--- clang/unittests/Tooling/TransformerTest.cpp
+++ clang/unittests/Tooling/TransformerTest.cpp
@@ -439,6 +439,29 @@
   Input, Expected);
 }
 
+TEST_F(TransformerTest, WithMetadata) {
+  std::string Input = R"cc(
+int f() {
+  int x = 5;
+  return 7;
+}
+  )cc";
+
+  Transformer T(
+  makeRule(declStmt().bind("decl"),
+   withMetadata(remove(statement(std::string("decl"))), 17)),
+  consumer());
+  T.registerMatchers();
+  auto Factory = newFrontendActionFactory();
+  EXPECT_TRUE(runToolOnCodeWithArgs(
+  Factory->create(), Input, std::vector(), "input.cc",
+  "clang-tool", std::make_shared(), {}));
+  ASSERT_EQ(Changes.size(), 1);
+  const llvm::Any  = Changes[0].getMetadata();
+  ASSERT_TRUE(llvm::any_isa(Metadata));
+  EXPECT_THAT(llvm::any_cast(Metadata), 17);
+}
+
 TEST_F(TransformerTest, MultiChange) {
   std::string Input = R"cc(
 void foo() {
Index: clang/unittests/Tooling/RefactoringTest.cpp
===
--- clang/unittests/Tooling/RefactoringTest.cpp
+++ clang/unittests/Tooling/RefactoringTest.cpp
@@ -1296,6 +1296,22 @@
   Replacement(Context.Sources, SourceLocation(), 0, "b")));
 }
 
+struct SomeMetadata {
+  int Data;
+};
+
+TEST_F(AtomicChangeTest, Metadata) {
+  AtomicChange Change(Context.Sources, DefaultLoc, SomeMetadata{17});
+  const llvm::Any  = Change.getMetadata();
+  ASSERT_TRUE(llvm::any_isa(Metadata));
+  EXPECT_EQ(llvm::any_cast(Metadata).Data, 17);
+}
+
+TEST_F(AtomicChangeTest, NoMetadata) {
+  AtomicChange Change(Context.Sources, DefaultLoc);
+  EXPECT_FALSE(Change.getMetadata().hasValue());
+}
+
 class ApplyAtomicChangesTest : public ::testing::Test {
 protected:
   ApplyAtomicChangesTest() : FilePath("file.cc") {
Index: clang/lib/Tooling/Transformer/Transformer.cpp
===
--- clang/lib/Tooling/Transformer/Transformer.cpp
+++ clang/lib/Tooling/Transformer/Transformer.cpp
@@ -53,7 +53,7 @@
 auto ID = Result.SourceManager->getFileID(T.Range.getBegin());
 auto Iter = ChangesByFileID
 .emplace(ID, AtomicChange(*Result.SourceManager,
-  T.Range.getBegin()))
+  T.Range.getBegin(), T.Metadata))
 .first;
 auto  = Iter->second;
 if (auto Err = AC.replace(*Result.SourceManager, T.Range, T.Replacement)) {
Index: clang/lib/Tooling/Transformer/RewriteRule.cpp
===
--- clang/lib/Tooling/Transformer/RewriteRule.cpp
+++ clang/lib/Tooling/Transformer/RewriteRule.cpp
@@ -47,6 +47,7 @@
 transformer::Edit T;
 T.Range = *EditRange;
 T.Replacement = std::move(*Replacement);
+T.Metadata = E.Metadata;
 Edits.push_back(std::move(T));
   }
   return Edits;
Index: clang/lib/Tooling/Refactoring/AtomicChange.cpp
===
--- clang/lib/Tooling/Refactoring/AtomicChange.cpp
+++ clang/lib/Tooling/Refactoring/AtomicChange.cpp
@@ -204,6 +204,12 @@
   Key = FilePath + ":" + std::to_string(FileIDAndOffset.second);
 }
 
+AtomicChange::AtomicChange(const SourceManager , SourceLocation KeyPosition,
+   llvm::Any M)
+: AtomicChange(SM, KeyPosition) {
+  Metadata = std::move(M);
+}
+
 AtomicChange::AtomicChange(std::string Key, std::string FilePath,
std::string Error,
std::vector InsertedHeaders,
Index: clang/include/clang/Tooling/Transformer/RewriteRule.h
===
--- clang/include/clang/Tooling/Transformer/RewriteRule.h
+++ clang/include/clang/Tooling/Transformer/RewriteRule.h
@@ -35,6 +35,7 @@
 struct Edit {
   CharSourceRange Range;
   std::string Replacement;
+  llvm::Any Metadata;
 };
 
 /// Maps a match result to a list of concrete edits (with possible
@@ -85,6 +86,7 @@
   RangeSelector TargetRange;
   TextGenerator Replacement;
   TextGenerator Note;
+  llvm::Any Metadata;
 };
 
 /// Lifts a list of `ASTEdit`s into an 

[PATCH] D79972: [OpenMP5.0] map item can be non-contiguous for target update

2020-06-25 Thread Chi Chun Chen via Phabricator via cfe-commits
cchen updated this revision to Diff 273517.
cchen added a comment.

Fix based on feedback


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D79972/new/

https://reviews.llvm.org/D79972

Files:
  clang/include/clang/AST/OpenMPClause.h
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.h
  clang/lib/Sema/SemaOpenMP.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/OpenMP/target_update_ast_print.cpp
  clang/test/OpenMP/target_update_codegen.cpp
  clang/test/OpenMP/target_update_messages.cpp
  clang/test/OpenMP/target_update_to_messages.cpp

Index: clang/test/OpenMP/target_update_to_messages.cpp
===
--- clang/test/OpenMP/target_update_to_messages.cpp
+++ clang/test/OpenMP/target_update_to_messages.cpp
@@ -79,6 +79,10 @@
 #pragma omp target update to(*(*(this->ptr)+a+this->ptr)) // le45-error {{expected expression containing only member accesses and/or array sections based on named variables}} le45-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
 #pragma omp target update to(*(this+this)) // expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}} expected-error {{invalid operands to binary expression ('S8 *' and 'S8 *')}}
 {}
+
+double marr[10][5][10];
+#pragma omp target update to(marr [0:] [2:4] [1:2]) // le45-error {{array section does not specify contiguous storage}} le45-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
+{}
   }
 };
 
Index: clang/test/OpenMP/target_update_messages.cpp
===
--- clang/test/OpenMP/target_update_messages.cpp
+++ clang/test/OpenMP/target_update_messages.cpp
@@ -1,6 +1,8 @@
-// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 %s -Wuninitialized
+// RUN: %clang_cc1 -verify=expected,le45 -fopenmp -ferror-limit 100 %s -Wuninitialized
+// RUN: %clang_cc1 -verify=expected,le50 -fopenmp -fopenmp-version=50 -ferror-limit 100 %s -Wuninitialized
 
-// RUN: %clang_cc1 -verify -fopenmp-simd -ferror-limit 100 %s -Wuninitialized
+// RUN: %clang_cc1 -verify=expected,le45 -fopenmp-simd -ferror-limit 100 %s -Wuninitialized
+// RUN: %clang_cc1 -verify=expected,le50 -fopenmp-simd -fopenmp-version=50 -ferror-limit 100 %s -Wuninitialized
 
 void xxx(int argc) {
   int x; // expected-note {{initialize the variable 'x' to silence this warning}}
@@ -36,5 +38,21 @@
   {
 foo();
   }
+
+  double marr[10][5][10];
+#pragma omp target update to(marr [0:] [2:4] [1:2]) // le45-error {{array section does not specify contiguous storage}} le45-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
+  {}
+#pragma omp target update from(marr [0:] [2:4] [1:2]) // le45-error {{array section does not specify contiguous storage}} le45-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
+
+  int arr[4][3][2][1];
+#pragma omp target update to(arr [0:2] [2:4][:2][1]) // le45-error {{array section does not specify contiguous storage}} le45-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
+  {}
+#pragma omp target update from(arr [0:2] [2:4][:2][1]) // le45-error {{array section does not specify contiguous storage}} le45-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
+
+  double ***dptr;
+#pragma omp target update to(dptr [0:2] [2:4] [1:2]) // le45-error {{array section does not specify contiguous storage}} le50-error 2 {{section length is unspecified and cannot be inferred because subscripted value is an array of unknown bound}} le45-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
+  {}
+#pragma omp target update from(dptr [0:2] [2:4] [1:2]) // le45-error {{array section does not specify contiguous storage}} le50-error 2 {{section length is unspecified and cannot be inferred because subscripted value is an array of unknown bound}} le45-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
+
   return tmain(argc, argv);
 }
Index: clang/test/OpenMP/target_update_codegen.cpp
===
--- clang/test/OpenMP/target_update_codegen.cpp
+++ clang/test/OpenMP/target_update_codegen.cpp
@@ -1059,5 +1059,304 @@
   #pragma omp target update from(([sa][5])f)
 }
 
+#endif
+///==///
+// RUN: %clang_cc1 -DCK19 -verify -fopenmp -fopenmp-version=50 -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck %s --check-prefix CK19 

[PATCH] D82579: [NFC] Extract unifyTargetFeatures

2020-06-25 Thread Artem Belevich via Phabricator via cfe-commits
tra accepted this revision.
tra added inline comments.
This revision is now accepted and ready to land.



Comment at: clang/lib/Driver/ToolChains/CommonArgs.cpp:93
+StringRef Name = Features[I];
+assert(Name[0] == '-' || Name[0] == '+');
+LastOpt[Name.drop_front(1)] = I;

yaxunl wrote:
> tra wrote:
> > yaxunl wrote:
> > > tra wrote:
> > > > I don't think assert should be used for something that may be specified 
> > > > to the user on command line.
> > > > 
> > > The entries in this array is not directly from command line.
> > > 
> > > It is either put in by clang code, or translated from -mxxx or -mno-xxx 
> > > options whereas the translated entry should always have + or - prefix. So 
> > > if things go wrong, it is due to developers.
> > While clang may be the primary user of those options, features can be 
> > specified by the user, too.
> > The general rule of thumb is that invalid external input should produce 
> > diagnostics, not compiler crashes.
> > Asserts are for programming errors. Granted, when the inputs may be  
> > generated by our code the boundary is blurred, but in this case I would err 
> > on the side of not crashing.
> user may use -target-feature to directly specify features and they may forget 
> +/- there but that is a -cc1 option, whereas this function is used in `tool` 
> and will never be used in -cc1. The features in this vector can only come 
> from clang driver, where the code is supposed to always add +/- to the 
> entries. How could user inputs can cause +/- not added?
Got it. I indeed had `-target-feature` in mind: 
https://github.com/llvm/llvm-project/blob/32ea3397bec820f98f0b77ca37244142ce700207/clang/lib/Frontend/CompilerInvocation.cpp#L3648




CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82579/new/

https://reviews.llvm.org/D82579



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


[PATCH] D82561: [analyzer][CrossTU] Lower CTUImportThreshold default value

2020-06-25 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus accepted this revision.
Szelethus added a comment.
This revision is now accepted and ready to land.

Based on discussions I heard in between @dkrupp, @martong and You, this seems 
appropriate.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82561/new/

https://reviews.llvm.org/D82561



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


[PATCH] D82386: [clangd] Config: Fragments and parsing from YAML

2020-06-25 Thread Sam McCall via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
sammccall marked an inline comment as done.
Closed by commit rGe9fb1506b83d: [clangd] Config: Fragments and parsing from 
YAML (authored by sammccall).

Changed prior to commit:
  https://reviews.llvm.org/D82386?vs=273254=273512#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82386/new/

https://reviews.llvm.org/D82386

Files:
  clang-tools-extra/clangd/CMakeLists.txt
  clang-tools-extra/clangd/ConfigFragment.h
  clang-tools-extra/clangd/ConfigYAML.cpp
  clang-tools-extra/clangd/unittests/CMakeLists.txt
  clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp

Index: clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp
===
--- /dev/null
+++ clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp
@@ -0,0 +1,160 @@
+//===-- ConfigYAMLTests.cpp ---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "Annotations.h"
+#include "ConfigFragment.h"
+#include "Matchers.h"
+#include "Protocol.h"
+#include "llvm/Support/SMLoc.h"
+#include "llvm/Support/ScopedPrinter.h"
+#include "llvm/Support/SourceMgr.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+#include "gtest/internal/gtest-internal.h"
+
+namespace clang {
+namespace clangd {
+namespace config {
+template  void PrintTo(const Located , std::ostream *OS) {
+  *OS << ::testing::PrintToString(*V);
+}
+
+namespace {
+using ::testing::AllOf;
+using ::testing::ElementsAre;
+using ::testing::IsEmpty;
+
+MATCHER_P(Val, Value, "") {
+  if (*arg == Value)
+return true;
+  *result_listener << "value is " << *arg;
+  return false;
+}
+
+Position toPosition(llvm::SMLoc L, const llvm::SourceMgr ) {
+  auto LineCol = SM.getLineAndColumn(L);
+  Position P;
+  P.line = LineCol.first - 1;
+  P.character = LineCol.second - 1;
+  return P;
+}
+
+Range toRange(llvm::SMRange R, const llvm::SourceMgr ) {
+  return Range{toPosition(R.Start, SM), toPosition(R.End, SM)};
+}
+
+struct CapturedDiags {
+  std::function callback() {
+return [this](const llvm::SMDiagnostic ) {
+  Diagnostics.emplace_back();
+  Diag  = Diagnostics.back();
+  Out.Message = D.getMessage().str();
+  Out.Kind = D.getKind();
+  Out.Pos.line = D.getLineNo() - 1;
+  Out.Pos.character = D.getColumnNo(); // Zero-based - bug in SourceMgr?
+  if (!D.getRanges().empty()) {
+const auto  = D.getRanges().front();
+Out.Range.emplace();
+Out.Range->start.line = Out.Range->end.line = Out.Pos.line;
+Out.Range->start.character = R.first;
+Out.Range->end.character = R.second;
+  }
+};
+  }
+  struct Diag {
+std::string Message;
+llvm::SourceMgr::DiagKind Kind;
+Position Pos;
+llvm::Optional Range;
+
+friend void PrintTo(const Diag , std::ostream *OS) {
+  *OS << (D.Kind == llvm::SourceMgr::DK_Error ? "error: " : "warning: ")
+  << D.Message << "@" << llvm::to_string(D.Pos);
+}
+  };
+  std::vector Diagnostics;
+};
+
+MATCHER_P(DiagMessage, M, "") { return arg.Message == M; }
+MATCHER_P(DiagKind, K, "") { return arg.Kind == K; }
+MATCHER_P(DiagPos, P, "") { return arg.Pos == P; }
+MATCHER_P(DiagRange, R, "") { return arg.Range == R; }
+
+TEST(ParseYAML, SyntacticForms) {
+  CapturedDiags Diags;
+  const char *YAML = R"yaml(
+If:
+  PathMatch:
+- 'abc'
+CompileFlags: { Add: [foo, bar] }
+---
+CompileFlags:
+  Add: |
+b
+az
+  )yaml";
+  auto Results = Fragment::parseYAML(YAML, "config.yaml", Diags.callback());
+  EXPECT_THAT(Diags.Diagnostics, IsEmpty());
+  ASSERT_EQ(Results.size(), 2u);
+  EXPECT_FALSE(Results.front().Condition.HasUnrecognizedCondition);
+  EXPECT_THAT(Results.front().Condition.PathMatch, ElementsAre(Val("abc")));
+  EXPECT_THAT(Results.front().CompileFlags.Add,
+  ElementsAre(Val("foo"), Val("bar")));
+
+  EXPECT_THAT(Results.back().CompileFlags.Add, ElementsAre(Val("b\naz\n")));
+}
+
+TEST(ParseYAML, Locations) {
+  CapturedDiags Diags;
+  Annotations YAML(R"yaml(
+If:
+  PathMatch: [['???bad***regex(((']]
+  )yaml");
+  auto Results =
+  Fragment::parseYAML(YAML.code(), "config.yaml", Diags.callback());
+  EXPECT_THAT(Diags.Diagnostics, IsEmpty());
+  ASSERT_EQ(Results.size(), 1u);
+  ASSERT_NE(Results.front().Source.Manager, nullptr);
+  EXPECT_EQ(toRange(Results.front().Condition.PathMatch.front().Range,
+*Results.front().Source.Manager),
+YAML.range());
+}
+
+TEST(ParseYAML, Diagnostics) {
+  CapturedDiags Diags;
+  Annotations YAML(R"yaml(
+If:
+  [[UnknownCondition]]: "foo"
+CompileFlags:
+  Add: 'first'
+---
+CompileFlags: {^
+)yaml");
+ 

[PATCH] D82226: Add Metadata to Transformer tooling

2020-06-25 Thread Andy Soffer via Phabricator via cfe-commits
asoffer marked 2 inline comments as done.
asoffer added a comment.

In D82226#2114111 , @ymandel wrote:

> Looks good! Only real question is one of design -- should we consider the 
> (deeper) change of templating the various types rather than using dynamic 
> typing?  For that matter, the decision doesn't even have to be the same for 
> both AtomicChange and the Transformer types. Transformer could be templated 
> while AtomicChange uses any.


I think the tradeoff here is 
Dynamic typing -- faster compile times, type safety checked at run-time (in 
tests), lower maintenance cost
Templates -- Faster runtime, type safety checked at compile-time, better user 
expereience

I don't think the runtime speed is particularly important here in the sense 
that it's unlikely to be the bottleneck. Given the crash-on-invalid-type 
semantics, we're essentially trading off usability for maintenance cost. In 
this case I don't think asking users to do the extra cast is a significant 
enough burden to warrant the cost of templating everything.

I also don't strongly object to it. The nice thing about llvm::Any, is that 
this can be mostly changed incrementally if we later decide that's appropriate 
(only having to change the one getMetadata call at the call-site).




Comment at: clang/lib/Tooling/Refactoring/AtomicChange.cpp:210
+: AtomicChange(SM, KeyPosition) {
+  Metadata = std::move(M);
+}

ymandel wrote:
> I assume that  
> ```
> : AtomicChange(SM, KeyPosition), Metadata(std::move(M)) {}
> ```
> didn't work?
Correct. You can't use a forwarding constructor followed by a field initializer 
(which I learned by attempt it on this PR).



Comment at: clang/unittests/Tooling/TransformerTest.cpp:460
+  auto Factory = newFrontendActionFactory();
+  EXPECT_TRUE(runToolOnCodeWithArgs(
+  Factory->create(), Input, std::vector(), "input.cc",

ymandel wrote:
> Why expect vs assert?
EXPECT when the test can reasonably continue to produce useful output without 
crashing. So here, if the tool fails, we can still safely access Changes, but 
if Changes.size() != 1, we can't safely index into it.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82226/new/

https://reviews.llvm.org/D82226



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


[PATCH] D82386: [clangd] Config: Fragments and parsing from YAML

2020-06-25 Thread Sam McCall via Phabricator via cfe-commits
sammccall marked 9 inline comments as done.
sammccall added a comment.

Thanks for the careful review!




Comment at: clang-tools-extra/clangd/ConfigFragment.h:73
+/// Only valid if SourceManager is set.
+llvm::SMLoc Location;
+  };

kadircet wrote:
> sammccall wrote:
> > kadircet wrote:
> > > what is the use of this ?
> > There may be multiple fragments in a file.
> > 
> > When tracking how fragments are used in the logs, there should be enough 
> > information to identify the particular fragment, without having to guess.
> >  - during parsing, we can log in some source-specific way
> >  - in the Fragment form, we can log this location to identify the fragment
> >  - during compilation, we log this location and the pointer address of the 
> > new CompiledFragment
> >  - subsequently we can just log the CompiledFragment address
> right, I was thinking that we already have location information available for 
> the start of the fragment during parsing and wasn't sure how useful it would 
> be in later on stages as we know the exact location of the relevant entries 
> (keys, scalars etc.) for logging.
> 
> I wasn't against the idea of storing it, just wanted to learn if it has any 
> significant importance for the upcoming stages. thanks for the info!
Yeah, storing the start of the fragment given a slightly more correct location 
to represent the fragment itself, but more importantly we don't have to hunt 
around the config to find something that has a location.



Comment at: clang-tools-extra/clangd/ConfigFragment.h:77
+
+  struct ConditionFragment {
+std::vector> PathMatch;

kadircet wrote:
> sammccall wrote:
> > kadircet wrote:
> > > comments?
> > Whoops, done. There's an argument to be made that we shouldn't maintain 
> > docs in two places, and the user docs should be canonical.
> > Something to think about later, maybe we can generate them.
> > 
> > I'm always unsure whether to put the doc for "blocks" like this on the 
> > struct or the field...
> I suppose it makes sense to put the part starting with `  /// Conditions 
> based on a file's path use the following form:` above the field rather than 
> the struct, especially if we are planning to generate docs.
> 
> also:
> s/ConfigFragment/Fragment/
Yeah - the counter-argument is that if you *are* reading the code then having 
the general documentation above the specific stuff reads better. And we can 
teach a doc generator/extractor to grab the right text easily enough. I'll 
leave it for now, I think.

> s/ConfigFragment/Fragment/

Doh, I did update this everywhere, but apparently not in my brain, so it keeps 
coming back...



Comment at: clang-tools-extra/clangd/ConfigFragment.h:81
+/// The condition will evaluate to false.
+bool UnrecognizedCondition;
+  };

kadircet wrote:
> sammccall wrote:
> > kadircet wrote:
> > > `HasUnrecognizedCondition` ?
> > > 
> > > also default init to `true` maybe?
> > Renamed. I guess you meant `false` here? (an empty condition should not 
> > have this set)
> I was actually suggesting `true` to make sure this is explicitly set by the 
> parser in case of success and not forgotten when something slips away. but 
> not that important.
The problem is the only sensible implementation for a parser is to set it to 
false again, then set it to true once you hit an unknown key.
Particularly now that condition is not Optional. I think the invariant that a 
default-initialized Fragment corresponds to an empty document is more valuable.



Comment at: clang-tools-extra/clangd/ConfigFragment.h:87
+std::vector> Add;
+  } CompileFlags;
+};

kadircet wrote:
> sammccall wrote:
> > kadircet wrote:
> > > maybe make this an llvm:Optional too. Even though emptiness of `Add` 
> > > would be OK in this case, for non-container "blocks" we might need to 
> > > introduce an optional, and homogeneity would be nice when it happens.
> > I'd rather push this the other way: the presence of an empty block like 
> > this shouldn't have any semantic effect - I think we can be consistent 
> > about this and it helps the schema feel regular/extensible/predictable.
> > 
> > Condition was the only tricky case, but I don't think we need it, so I've 
> > removed the Optional on the condition instead. it's an AND, so an empty set 
> > of conditions evaluates to "unconditionally true" anyway.
> sure SG, I was rather afraid of introducing an `int` option one day, then we 
> might need to signal it's existence with an `Optional` but one might also 
> argue that we would likely have a "default" value for such options, hence 
> instead of marking it as `None` we could just make use of the default in 
> absence of that option.
Oh definitely I think we'll want `Optional` for singular leaf fields, like 
`Optional BackgroundIndexBlock::Enabled` or whatever.
You want a tristate of yes/no/inherit-existing and 

[PATCH] D82598: [analyzer][Liveness][NFC] Get rid of statement liveness, because such a thing doesn't exist

2020-06-25 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus created this revision.
Szelethus added reviewers: NoQ, xazax.hun, vsavchenko, martong, dcoughlin.
Szelethus added a project: clang.
Herald added subscribers: cfe-commits, ASDenysPetrov, steakhal, Charusso, 
gamesh411, dkrupp, donat.nagy, mikhail.ramalho, a.sidorin, rnkovacs, szepet, 
baloghadamsoftware, whisperity.
Szelethus added a comment.

I didn't run this on big projects just yet, and judging from the fact that 
`Environment` only contained ObjetiveC examples of non-expression statements, I 
might need a tip on how to test on ObjC code :)


The summary and very short discussion in D82122 
 summarizes whats happening here.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D82598

Files:
  clang/include/clang/Analysis/Analyses/LiveVariables.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h
  clang/lib/Analysis/LiveVariables.cpp
  clang/lib/StaticAnalyzer/Checkers/DebugCheckers.cpp
  clang/lib/StaticAnalyzer/Core/Environment.cpp
  clang/lib/StaticAnalyzer/Core/SymbolManager.cpp

Index: clang/lib/StaticAnalyzer/Core/SymbolManager.cpp
===
--- clang/lib/StaticAnalyzer/Core/SymbolManager.cpp
+++ clang/lib/StaticAnalyzer/Core/SymbolManager.cpp
@@ -482,7 +482,7 @@
 }
 
 bool
-SymbolReaper::isLive(const Stmt *ExprVal, const LocationContext *ELCtx) const {
+SymbolReaper::isLive(const Expr *ExprVal, const LocationContext *ELCtx) const {
   if (LCtx == nullptr)
 return false;
 
Index: clang/lib/StaticAnalyzer/Core/Environment.cpp
===
--- clang/lib/StaticAnalyzer/Core/Environment.cpp
+++ clang/lib/StaticAnalyzer/Core/Environment.cpp
@@ -183,12 +183,15 @@
  F.getTreeFactory());
 
   // Iterate over the block-expr bindings.
-  for (Environment::iterator I = Env.begin(), E = Env.end();
-   I != E; ++I) {
+  for (Environment::iterator I = Env.begin(), End = Env.end(); I != End; ++I) {
 const EnvironmentEntry  = I.getKey();
 const SVal  = I.getData();
 
-if (SymReaper.isLive(BlkExpr.getStmt(), BlkExpr.getLocationContext())) {
+const Expr *E = dyn_cast(BlkExpr.getStmt());
+if (!E)
+  continue;
+
+if (SymReaper.isLive(E, BlkExpr.getLocationContext())) {
   // Copy the binding to the new map.
   EBMapRef = EBMapRef.add(BlkExpr, X);
 
Index: clang/lib/StaticAnalyzer/Checkers/DebugCheckers.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/DebugCheckers.cpp
+++ clang/lib/StaticAnalyzer/Checkers/DebugCheckers.cpp
@@ -136,7 +136,7 @@
   void checkASTCodeBody(const Decl *D, AnalysisManager& Mgr,
 BugReporter ) const {
 if (LiveVariables *L = Mgr.getAnalysis(D))
-  L->dumpStmtLiveness(Mgr.getSourceManager());
+  L->dumpExprLiveness(Mgr.getSourceManager());
   }
 };
 }
Index: clang/lib/Analysis/LiveVariables.cpp
===
--- clang/lib/Analysis/LiveVariables.cpp
+++ clang/lib/Analysis/LiveVariables.cpp
@@ -27,7 +27,7 @@
 class LiveVariablesImpl {
 public:
   AnalysisDeclContext 
-  llvm::ImmutableSet::Factory SSetFact;
+  llvm::ImmutableSet::Factory SSetFact;
   llvm::ImmutableSet::Factory DSetFact;
   llvm::ImmutableSet::Factory BSetFact;
   llvm::DenseMap blocksEndToLiveness;
@@ -45,7 +45,7 @@
  LiveVariables::Observer *obs = nullptr);
 
   void dumpBlockLiveness(const SourceManager& M);
-  void dumpStmtLiveness(const SourceManager& M);
+  void dumpExprLiveness(const SourceManager& M);
 
   LiveVariablesImpl(AnalysisDeclContext , bool KillAtAssign)
 : analysisContext(ac),
@@ -54,7 +54,7 @@
   BSetFact(false),
   killAtAssign(KillAtAssign) {}
 };
-}
+} // namespace
 
 static LiveVariablesImpl (void *x) {
   return *((LiveVariablesImpl *) x);
@@ -64,8 +64,8 @@
 // Operations and queries on LivenessValues.
 //===--===//
 
-bool LiveVariables::LivenessValues::isLive(const Stmt *S) const {
-  return liveStmts.contains(S);
+bool LiveVariables::LivenessValues::isLive(const Expr *E) const {
+  return liveExprs.contains(E);
 }
 
 bool LiveVariables::LivenessValues::isLive(const VarDecl *D) const {
@@ -97,9 +97,9 @@
 LiveVariablesImpl::merge(LiveVariables::LivenessValues valsA,
  LiveVariables::LivenessValues valsB) {
 
-  llvm::ImmutableSetRef
-SSetRefA(valsA.liveStmts.getRootWithoutRetain(), SSetFact.getTreeFactory()),
-SSetRefB(valsB.liveStmts.getRootWithoutRetain(), SSetFact.getTreeFactory());
+  llvm::ImmutableSetRef
+SSetRefA(valsA.liveExprs.getRootWithoutRetain(), SSetFact.getTreeFactory()),
+SSetRefB(valsB.liveExprs.getRootWithoutRetain(), SSetFact.getTreeFactory());
 
 
   llvm::ImmutableSetRef
@@ -122,7 +122,7 @@
 }
 
 bool LiveVariables::LivenessValues::equals(const LivenessValues ) 

[PATCH] D82598: [analyzer][Liveness][NFC] Get rid of statement liveness, because such a thing doesn't exist

2020-06-25 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added a comment.

I didn't run this on big projects just yet, and judging from the fact that 
`Environment` only contained ObjetiveC examples of non-expression statements, I 
might need a tip on how to test on ObjC code :)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82598/new/

https://reviews.llvm.org/D82598



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


[PATCH] D81938: [InferAddressSpaces] Handle the pair of `ptrtoint`/`inttoptr`.

2020-06-25 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added inline comments.



Comment at: llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp:238-239
+return false;
+  // Check it's really safe to treat that pair of `ptrtoint`/`inttoptr` is a
+  // no-op cast. Besides checking both of them are no-op casts, as the
+  // reinterpreted pointer may be used in other pointer arithemetic, we also

The grammar for the first sentence is off.  "Check if the pair of 
ptrtoint/inttoptr is a no-op cast."



Comment at: llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp:246
+  // especially a clear definition for pointer bits in non-0 address spaces. It
+  // would be an undefined behavior if that pointer bits are accessed after an
+  // invalid reinterpret cast. Also, due to the unclearness for the meaning of

No "an".

"if that pionter is dereferenced" would be more specific than than "pointer 
bits accessed"


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81938/new/

https://reviews.llvm.org/D81938



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


[PATCH] D79972: [OpenMP5.0] map item can be non-contiguous for target update

2020-06-25 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: clang/lib/Sema/SemaOpenMP.cpp:16624
+  if (IsPointer && !AllowAnotherPtr)
+SemaRef.Diag(ELoc, diag::err_omp_section_length_undefined) << true;
+  else

cchen wrote:
> ABataev wrote:
> > Better to use integer value as selectors, not boolean.
> The selector for `err_omp_section_length_undefined` is a bool value. (true 
> for unknown bound false for not a array type, so always be true here).
> Do you mean that I need to create a new kind of diagnosis message here and 
> use integer as selectors?
No, it is an integer, starts from `0`


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D79972/new/

https://reviews.llvm.org/D79972



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


[PATCH] D82130: [WebAssembly] Adding 64-bit versions of __stack_pointer and other globals

2020-06-25 Thread Wouter van Oortmerssen via Phabricator via cfe-commits
aardappel updated this revision to Diff 273503.
aardappel added a comment.

- Fixed ISEL for FrameIndex
- Fixed 64-bit conditions in branches (thanks @aheejin!)
- Made the FrameIndex generation code in WebAssemblyRegisterInfo work.
- Made userstack.ll and stack-alignment.ll pass in wasm64.
- Code review fixes.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82130/new/

https://reviews.llvm.org/D82130

Files:
  clang/lib/Driver/ToolChains/WebAssembly.cpp
  lld/wasm/Config.h
  lld/wasm/Driver.cpp
  lld/wasm/InputChunks.cpp
  lld/wasm/Options.td
  llvm/include/llvm/BinaryFormat/Wasm.h
  llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyFrameLowering.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyFrameLowering.h
  llvm/lib/Target/WebAssembly/WebAssemblyISelDAGToDAG.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyLateEHPrepare.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyMCInstLower.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyRegStackify.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyRegisterInfo.cpp
  llvm/test/CodeGen/WebAssembly/stack-alignment.ll
  llvm/test/CodeGen/WebAssembly/userstack.ll
  llvm/test/MC/WebAssembly/stack-ptr.ll
  llvm/test/MC/WebAssembly/wasm64.s

Index: llvm/test/MC/WebAssembly/wasm64.s
===
--- llvm/test/MC/WebAssembly/wasm64.s
+++ llvm/test/MC/WebAssembly/wasm64.s
@@ -51,6 +51,11 @@
 i64.const   0
 f32.store   .L.str# relocatable offset!
 
+### 64-bit SP
+
+global.get  __stack_pointer
+drop
+
 end_function
 
 .section.rodata..L.str,"",@
@@ -62,7 +67,7 @@
 .size   .L.str, 24
 
 .globaltype myglob64, i64
-
+.globaltype __stack_pointer, i64
 
 
 # CHECK:  .functype   test (i64) -> ()
@@ -155,6 +160,11 @@
 # BIN-NEXT: Kind:GLOBAL
 # BIN-NEXT: GlobalType:  I64
 # BIN-NEXT: GlobalMutable:   true
+# BIN-NEXT:   - Module:  env
+# BIN-NEXT: Field:   __stack_pointer
+# BIN-NEXT: Kind:GLOBAL
+# BIN-NEXT: GlobalType:  I64
+# BIN-NEXT: GlobalMutable:   true
 # BIN-NEXT:   - Type:FUNCTION
 # BIN-NEXT: FunctionTypes:   [ 0 ]
 # BIN-NEXT:   - Type:DATACOUNT
@@ -179,12 +189,15 @@
 # BIN-NEXT:   - Type:R_WASM_MEMORY_ADDR_LEB64
 # BIN-NEXT: Index:   1
 # BIN-NEXT: Offset:  0x0078
+# BIN-NEXT:   - Type: R_WASM_GLOBAL_INDEX_LEB
+# BIN-NEXT: Index: 3
+# BIN-NEXT: Offset: 0x0083
 # BIN-NEXT: Functions:
 # BIN-NEXT:   - Index:   0
 # BIN-NEXT: Locals:
 # BIN-NEXT:   - Type:I64
 # BIN-NEXT: Count:   1
-# BIN-NEXT: Body:42002A02001A20002A02001A42808080808080808080002A02001A2380808080002A02001A42002A02808080808080808080001A43420038020043200038020043428080808080808080800038020043238080808000380200434200380280808080808080808B
+# BIN-NEXT: Body:42002A02001A20002A02001A42808080808080808080002A02001A2380808080002A02001A42002A02808080808080808080001A434200380200432000380200434280808080808080808000380200432380808080003802004342003802808080808080808080002381808080001A0B
 # BIN-NEXT:   - Type:DATA
 # BIN-NEXT: Relocations:
 # BIN-NEXT:   - Type:R_WASM_MEMORY_ADDR_I64
@@ -217,6 +230,11 @@
 # BIN-NEXT: Name:myglob64
 # BIN-NEXT: Flags:   [ UNDEFINED ]
 # BIN-NEXT: Global:  0
+# BIN-NEXT:   - Index:   3
+# BIN-NEXT: Kind:GLOBAL
+# BIN-NEXT: Name:__stack_pointer
+# BIN-NEXT: Flags:   [ UNDEFINED ]
+# BIN-NEXT: Global:  1
 # BIN-NEXT: SegmentInfo:
 # BIN-NEXT:   - Index:   0
 # BIN-NEXT: Name:.rodata..L.str
Index: llvm/test/MC/WebAssembly/stack-ptr.ll
===
--- llvm/test/MC/WebAssembly/stack-ptr.ll
+++ llvm/test/MC/WebAssembly/stack-ptr.ll
@@ -1,6 +1,5 @@
-; RUN: llc -filetype=obj %s -o - | obj2yaml | FileCheck %s
-
-target triple = "wasm32-unknown-unknown"
+; RUN: llc --mtriple=wasm32-unknown-unknown -filetype=obj %s -o - | obj2yaml | FileCheck --check-prefixes CHECK,CHK32 %s
+; RUN: llc --mtriple=wasm64-unknown-unknown -filetype=obj %s -o - | obj2yaml | FileCheck --check-prefixes CHECK,CHK64 %s
 
 ; Function that uses explict stack, and should generate a reference to
 ; __stack_pointer, along with the corresponding reloction entry.
@@ -15,7 +14,8 @@
 ; CHECK:   - Module:  env
 ; CHECK: Field:   __stack_pointer
 ; CHECK: Kind:GLOBAL
-; CHECK: GlobalType:  I32
+; CHK32: 

[clang-tools-extra] e9fb150 - [clangd] Config: Fragments and parsing from YAML

2020-06-25 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2020-06-25T22:55:45+02:00
New Revision: e9fb1506b83d001082dc535af12acf45050a527c

URL: 
https://github.com/llvm/llvm-project/commit/e9fb1506b83d001082dc535af12acf45050a527c
DIFF: 
https://github.com/llvm/llvm-project/commit/e9fb1506b83d001082dc535af12acf45050a527c.diff

LOG: [clangd] Config: Fragments and parsing from YAML

Summary:
This is a piece from the design in https://tinyurl.com/clangd-config
https://reviews.llvm.org/D82335 is a draft with all the bits linked together.
It doesn't do anything yet, it's just a library + tests.

It deliberately implements a minimal set of actual configuration options.

Reviewers: kadircet, adamcz

Subscribers: mgorny, ilya-biryukov, MaskRay, jkorous, arphaman, usaxena95, 
cfe-commits

Tags: #clang

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

Added: 
clang-tools-extra/clangd/ConfigFragment.h
clang-tools-extra/clangd/ConfigYAML.cpp
clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp

Modified: 
clang-tools-extra/clangd/CMakeLists.txt
clang-tools-extra/clangd/unittests/CMakeLists.txt

Removed: 




diff  --git a/clang-tools-extra/clangd/CMakeLists.txt 
b/clang-tools-extra/clangd/CMakeLists.txt
index 3ff609a86da9..de3dd81a81db 100644
--- a/clang-tools-extra/clangd/CMakeLists.txt
+++ b/clang-tools-extra/clangd/CMakeLists.txt
@@ -36,6 +36,7 @@ add_clang_library(clangDaemon
   CollectMacros.cpp
   CompileCommands.cpp
   Compiler.cpp
+  ConfigYAML.cpp
   Diagnostics.cpp
   DraftStore.cpp
   ExpectedTypes.cpp

diff  --git a/clang-tools-extra/clangd/ConfigFragment.h 
b/clang-tools-extra/clangd/ConfigFragment.h
new file mode 100644
index ..2cb646757e17
--- /dev/null
+++ b/clang-tools-extra/clangd/ConfigFragment.h
@@ -0,0 +1,118 @@
+//===--- ConfigFragment.h - Unit of user-specified configuration -*- 
C++-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// Various clangd features have configurable behaviour (or can be disabled).
+// The configuration system allows users to control this:
+//  - in a user config file, a project config file, via LSP, or via flags
+//  - specifying 
diff erent settings for 
diff erent files
+//
+// This file defines the config::Fragment structure which models one piece of
+// configuration as obtained from a source like a file.
+//
+// This is distinct from how the config is interpreted (CompiledFragment),
+// combined (Provider) and exposed to the rest of clangd (Config).
+//
+//===--===//
+//
+// To add a new configuration option, you must:
+//  - add its syntactic form to Fragment
+//  - update ConfigYAML.cpp to parse it
+//  - add its semantic form to Config (in Config.h)
+//  - update ConfigCompile.cpp to map Fragment -> Config
+//  - make use of the option inside clangd
+//  - document the new option (config.md in the llvm/clangd-www repository)
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_CONFIGFRAGMENT_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_CONFIGFRAGMENT_H
+
+#include "llvm/ADT/Optional.h"
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/Support/Error.h"
+#include "llvm/Support/SMLoc.h"
+#include "llvm/Support/SourceMgr.h"
+#include 
+#include 
+
+namespace clang {
+namespace clangd {
+namespace config {
+
+/// An entity written in config along, with its optional location in the file.
+template  struct Located {
+  Located(T Value, llvm::SMRange Range = {})
+  : Range(Range), Value(std::move(Value)) {}
+
+  llvm::SMRange Range;
+  T >() { return Value; }
+  const T >() const { return Value; }
+  T *() { return Value; }
+  const T *() const { return Value; }
+
+private:
+  T Value;
+};
+
+/// Used to report problems in parsing or interpreting a config.
+/// Errors reflect structurally invalid config that should be user-visible.
+/// Warnings reflect e.g. unknown properties that are recoverable.
+using DiagnosticCallback = llvm::function_ref;
+
+/// A chunk of configuration obtained from a config file, LSP, or elsewhere.
+struct Fragment {
+  /// Parses fragments from a YAML file (one from each --- delimited document).
+  /// Documents that contained fatal errors are omitted from the results.
+  /// BufferName is used for the SourceMgr and diagnostics.
+  static std::vector parseYAML(llvm::StringRef YAML,
+ llvm::StringRef BufferName,
+ DiagnosticCallback);
+
+  /// These fields are not part of the user-specified configuration, but
+  /// instead are populated by the parser to describe the configuration 

[PATCH] D79972: [OpenMP5.0] map item can be non-contiguous for target update

2020-06-25 Thread Chi Chun Chen via Phabricator via cfe-commits
cchen marked an inline comment as done.
cchen added inline comments.



Comment at: clang/lib/Sema/SemaOpenMP.cpp:16624
+  if (IsPointer && !AllowAnotherPtr)
+SemaRef.Diag(ELoc, diag::err_omp_section_length_undefined) << true;
+  else

ABataev wrote:
> Better to use integer value as selectors, not boolean.
The selector for `err_omp_section_length_undefined` is a bool value. (true for 
unknown bound false for not a array type, so always be true here).
Do you mean that I need to create a new kind of diagnosis message here and use 
integer as selectors?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D79972/new/

https://reviews.llvm.org/D79972



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


[PATCH] D82345: [sve][acle] Implement some of the C intrinsics for brain float.

2020-06-25 Thread Francesco Petrogalli via Phabricator via cfe-commits
fpetrogalli updated this revision to Diff 273498.
fpetrogalli marked 5 inline comments as done.
fpetrogalli added a comment.

This patch needed some love...

@c-rhodes, I have addressed your feedback, thank you.

I have also predicated all the instruction selection pattern for 
`-mattr=+bf16`, and I have updated the test to use the per-function attribute 
instead of adding the extra `-mattr=+bf16` option at command line.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82345/new/

https://reviews.llvm.org/D82345

Files:
  clang/include/clang/Basic/arm_sve.td
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_clasta-bfloat.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_clastb-bfloat.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_dup-bfloat.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_dupq-bfloat.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_insr-bfloat.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_lasta-bfloat.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_lastb-bfloat.c
  llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
  llvm/test/CodeGen/AArch64/sve-intrinsics-dup-x.ll
  llvm/test/CodeGen/AArch64/sve-intrinsics-perm-select.ll
  llvm/test/CodeGen/AArch64/sve-intrinsics-scalar-to-vec.ll
  llvm/test/CodeGen/AArch64/sve-intrinsics-shifts.ll

Index: llvm/test/CodeGen/AArch64/sve-intrinsics-shifts.ll
===
--- llvm/test/CodeGen/AArch64/sve-intrinsics-shifts.ll
+++ llvm/test/CodeGen/AArch64/sve-intrinsics-shifts.ll
@@ -165,6 +165,14 @@
   ret  %out
 }
 
+define  @insr_bf16( %a, bfloat %b) #0 {
+; CHECK-LABEL: insr_bf16:
+; CHECK: insr z0.h, h1
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.insr.nxv8bf16( %a, bfloat %b)
+  ret  %out
+}
+
 define  @insr_f32( %a, float %b) {
 ; CHECK-LABEL: insr_f32:
 ; CHECK: insr z0.s, s1
@@ -348,6 +356,7 @@
 declare  @llvm.aarch64.sve.insr.nxv4i32(, i32)
 declare  @llvm.aarch64.sve.insr.nxv2i64(, i64)
 declare  @llvm.aarch64.sve.insr.nxv8f16(, half)
+declare  @llvm.aarch64.sve.insr.nxv8bf16(, bfloat)
 declare  @llvm.aarch64.sve.insr.nxv4f32(, float)
 declare  @llvm.aarch64.sve.insr.nxv2f64(, double)
 
@@ -368,3 +377,6 @@
 declare  @llvm.aarch64.sve.lsr.wide.nxv16i8(, , )
 declare  @llvm.aarch64.sve.lsr.wide.nxv8i16(, , )
 declare  @llvm.aarch64.sve.lsr.wide.nxv4i32(, , )
+
+; +bf16 is required for the bfloat version.
+attributes #0 = { "target-features"="+sve,+bf16" }
Index: llvm/test/CodeGen/AArch64/sve-intrinsics-scalar-to-vec.ll
===
--- llvm/test/CodeGen/AArch64/sve-intrinsics-scalar-to-vec.ll
+++ llvm/test/CodeGen/AArch64/sve-intrinsics-scalar-to-vec.ll
@@ -57,6 +57,16 @@
   ret  %out
 }
 
+define  @dup_bf16( %a,  %pg, bfloat %b) #0 {
+; CHECK-LABEL: dup_bf16:
+; CHECK: mov z0.h, p0/m, h1
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.dup.nxv8bf16( %a,
+%pg,
+   bfloat %b)
+  ret  %out
+}
+
 define  @dup_f32( %a,  %pg, float %b) {
 ; CHECK-LABEL: dup_f32:
 ; CHECK: mov z0.s, p0/m, s1
@@ -77,10 +87,41 @@
   ret  %out
 }
 
+define  @test_svdup_n_bf16_z( %pg, bfloat %op) #0 {
+; CHECK-LABEL: test_svdup_n_bf16_z:
+; CHECK: mov z1.h, #0
+; CHECK: mov z1.h, p0/m, h0
+; CHECK: mov z0.d, z1.d
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.dup.nxv8bf16( zeroinitializer,  %pg, bfloat %op)
+  ret  %out
+}
+
+define  @test_svdup_n_bf16_m( %inactive,  %pg, bfloat %op) #0 {
+; CHECK-LABEL: test_svdup_n_bf16_m:
+; CHECK: mov z0.h, p0/m, h1
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.dup.nxv8bf16( %inactive,  %pg, bfloat %op)
+  ret  %out
+}
+
+
+define  @test_svdup_n_bf16_x( %pg, bfloat %op) #0 {
+; CHECK-LABEL: test_svdup_n_bf16_x:
+; CHECK: mov z0.h, p0/m, h0
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.dup.nxv8bf16( undef,  %pg, bfloat %op)
+  ret  %out
+}
+
 declare  @llvm.aarch64.sve.dup.nxv16i8(, , i8)
 declare  @llvm.aarch64.sve.dup.nxv8i16(, , i16)
 declare  @llvm.aarch64.sve.dup.nxv4i32(, , i32)
 declare  @llvm.aarch64.sve.dup.nxv2i64(, , i64)
 declare  @llvm.aarch64.sve.dup.nxv8f16(, , half)
+declare  @llvm.aarch64.sve.dup.nxv8bf16(, , bfloat)
 declare  @llvm.aarch64.sve.dup.nxv4f32(, , float)
 declare  @llvm.aarch64.sve.dup.nxv2f64(, , double)
+
+; +bf16 is required for the bfloat version.
+attributes #0 = { "target-features"="+sve,+bf16" }
Index: llvm/test/CodeGen/AArch64/sve-intrinsics-perm-select.ll
===
--- llvm/test/CodeGen/AArch64/sve-intrinsics-perm-select.ll
+++ llvm/test/CodeGen/AArch64/sve-intrinsics-perm-select.ll
@@ -57,6 +57,16 @@
   ret  %out
 }
 
+define  @clasta_bf16( %pg,  %a,  %b) #0 {
+; CHECK-LABEL: clasta_bf16:
+; CHECK: clasta z0.h, p0, z0.h, z1.h
+; CHECK-NEXT: ret
+  %out = 

[PATCH] D82579: [NFC] Extract unifyTargetFeatures

2020-06-25 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl marked 3 inline comments as done.
yaxunl added inline comments.



Comment at: clang/lib/Driver/ToolChains/CommonArgs.cpp:93
+StringRef Name = Features[I];
+assert(Name[0] == '-' || Name[0] == '+');
+LastOpt[Name.drop_front(1)] = I;

tra wrote:
> yaxunl wrote:
> > tra wrote:
> > > I don't think assert should be used for something that may be specified 
> > > to the user on command line.
> > > 
> > The entries in this array is not directly from command line.
> > 
> > It is either put in by clang code, or translated from -mxxx or -mno-xxx 
> > options whereas the translated entry should always have + or - prefix. So 
> > if things go wrong, it is due to developers.
> While clang may be the primary user of those options, features can be 
> specified by the user, too.
> The general rule of thumb is that invalid external input should produce 
> diagnostics, not compiler crashes.
> Asserts are for programming errors. Granted, when the inputs may be  
> generated by our code the boundary is blurred, but in this case I would err 
> on the side of not crashing.
user may use -target-feature to directly specify features and they may forget 
+/- there but that is a -cc1 option, whereas this function is used in `tool` 
and will never be used in -cc1. The features in this vector can only come from 
clang driver, where the code is supposed to always add +/- to the entries. How 
could user inputs can cause +/- not added?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82579/new/

https://reviews.llvm.org/D82579



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


[PATCH] D79972: [OpenMP5.0] map item can be non-contiguous for target update

2020-06-25 Thread Chi Chun Chen via Phabricator via cfe-commits
cchen marked an inline comment as done.
cchen added inline comments.



Comment at: clang/lib/CodeGen/CGOpenMPRuntime.cpp:8781
  MappableExprsHandler::MapFlagsArrayTy ,
- CGOpenMPRuntime::TargetDataInfo ) {
+ MappableExprsHandler::MapDimArrayTy ,
+ CGOpenMPRuntime::TargetDataInfo ,

ABataev wrote:
> Do you really need to pass `Dims` here if you have `Dims` data member in 
> `Info` parameter? Why you can't use `Info.Dims` instead?
I think I haven't added Dims in TargetDataInfo atm, I'll add into it and then 
use it via Info.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D79972/new/

https://reviews.llvm.org/D79972



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


[PATCH] D81282: [builtins] Move more float128-related helpers to GENERIC_TF_SOURCES list

2020-06-25 Thread Anton Korobeynikov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa931ec7ca0ee: [builtins] Move more float128-related helpers 
to GENERIC_TF_SOURCES list (authored by atrosinenko, committed by asl).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81282/new/

https://reviews.llvm.org/D81282

Files:
  compiler-rt/lib/builtins/CMakeLists.txt


Index: compiler-rt/lib/builtins/CMakeLists.txt
===
--- compiler-rt/lib/builtins/CMakeLists.txt
+++ compiler-rt/lib/builtins/CMakeLists.txt
@@ -46,7 +46,6 @@
   absvti2.c
   adddf3.c
   addsf3.c
-  addtf3.c
   addvdi3.c
   addvsi3.c
   addvti3.c
@@ -75,9 +74,7 @@
   divsc3.c
   divsf3.c
   divsi3.c
-  divtc3.c
   divti3.c
-  divtf3.c
   extendsfdf2.c
   extendhfsf2.c
   ffsdi2.c
@@ -123,7 +120,6 @@
   mulsc3.c
   mulsf3.c
   multi3.c
-  multf3.c
   mulvdi3.c
   mulvsi3.c
   mulvti3.c
@@ -143,13 +139,11 @@
   popcountti2.c
   powidf2.c
   powisf2.c
-  powitf2.c
   subdf3.c
   subsf3.c
   subvdi3.c
   subvsi3.c
   subvti3.c
-  subtf3.c
   trampoline_setup.c
   truncdfhf2.c
   truncdfsf2.c
@@ -168,7 +162,10 @@
 )
 
 set(GENERIC_TF_SOURCES
+  addtf3.c
   comparetf2.c
+  divtc3.c
+  divtf3.c
   extenddftf2.c
   extendsftf2.c
   fixtfdi.c
@@ -184,6 +181,9 @@
   floatunsitf.c
   floatuntitf.c
   multc3.c
+  multf3.c
+  powitf2.c
+  subtf3.c
   trunctfdf2.c
   trunctfsf2.c
 )


Index: compiler-rt/lib/builtins/CMakeLists.txt
===
--- compiler-rt/lib/builtins/CMakeLists.txt
+++ compiler-rt/lib/builtins/CMakeLists.txt
@@ -46,7 +46,6 @@
   absvti2.c
   adddf3.c
   addsf3.c
-  addtf3.c
   addvdi3.c
   addvsi3.c
   addvti3.c
@@ -75,9 +74,7 @@
   divsc3.c
   divsf3.c
   divsi3.c
-  divtc3.c
   divti3.c
-  divtf3.c
   extendsfdf2.c
   extendhfsf2.c
   ffsdi2.c
@@ -123,7 +120,6 @@
   mulsc3.c
   mulsf3.c
   multi3.c
-  multf3.c
   mulvdi3.c
   mulvsi3.c
   mulvti3.c
@@ -143,13 +139,11 @@
   popcountti2.c
   powidf2.c
   powisf2.c
-  powitf2.c
   subdf3.c
   subsf3.c
   subvdi3.c
   subvsi3.c
   subvti3.c
-  subtf3.c
   trampoline_setup.c
   truncdfhf2.c
   truncdfsf2.c
@@ -168,7 +162,10 @@
 )
 
 set(GENERIC_TF_SOURCES
+  addtf3.c
   comparetf2.c
+  divtc3.c
+  divtf3.c
   extenddftf2.c
   extendsftf2.c
   fixtfdi.c
@@ -184,6 +181,9 @@
   floatunsitf.c
   floatuntitf.c
   multc3.c
+  multf3.c
+  powitf2.c
+  subtf3.c
   trunctfdf2.c
   trunctfsf2.c
 )
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D79972: [OpenMP5.0] map item can be non-contiguous for target update

2020-06-25 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: clang/lib/CodeGen/CGOpenMPRuntime.cpp:8781
  MappableExprsHandler::MapFlagsArrayTy ,
- CGOpenMPRuntime::TargetDataInfo ) {
+ MappableExprsHandler::MapDimArrayTy ,
+ CGOpenMPRuntime::TargetDataInfo ,

Do you really need to pass `Dims` here if you have `Dims` data member in `Info` 
parameter? Why you can't use `Info.Dims` instead?



Comment at: clang/lib/CodeGen/CGOpenMPRuntime.cpp:8901-8929
+  // Build an array of struct descriptor_dim and then assign it to
+  // offload_args.
+  //
+  // struct descriptor_dim {
+  //  int64_t offset;
+  //  int64_t count;
+  //  int64_t stride

Maybe worth it to outline it into a separate function to reduce code size and 
the complexity of this function? And just call this new function here.



Comment at: clang/lib/Sema/SemaOpenMP.cpp:16624
+  if (IsPointer && !AllowAnotherPtr)
+SemaRef.Diag(ELoc, diag::err_omp_section_length_undefined) << true;
+  else

Better to use integer value as selectors, not boolean.



Comment at: clang/lib/Sema/SemaOpenMP.cpp:18519-18522
+MVLI.VarComponents.back().emplace_back(
+OMPClauseMappableExprCommon::MappableComponent(
+SimpleRefExpr, D,
+/*IsNonContiguous=*/false));

`.emplace_back(SimpleRefExpr, D, /*IsNonContiguous=*/false);`



Comment at: clang/lib/Sema/SemaOpenMP.cpp:18588
 // against other clauses later on.
-OMPClauseMappableExprCommon::MappableComponent MC(SimpleRefExpr, D);
+OMPClauseMappableExprCommon::MappableComponent MC(SimpleRefExpr, D, false);
 DSAStack->addMappableExpressionComponents(

Add a comment for `false` argument with the name of parameter.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D79972/new/

https://reviews.llvm.org/D79972



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


[PATCH] D82563: [Sema][NFC] Remove Redundant Condition

2020-06-25 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added a comment.
This revision is now accepted and ready to land.

Nice!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82563/new/

https://reviews.llvm.org/D82563



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


[PATCH] D79972: [OpenMP5.0] map item can be non-contiguous for target update

2020-06-25 Thread Chi Chun Chen via Phabricator via cfe-commits
cchen updated this revision to Diff 273484.
cchen added a comment.

Fix coding style


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D79972/new/

https://reviews.llvm.org/D79972

Files:
  clang/include/clang/AST/OpenMPClause.h
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.h
  clang/lib/Sema/SemaOpenMP.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/OpenMP/target_update_ast_print.cpp
  clang/test/OpenMP/target_update_codegen.cpp
  clang/test/OpenMP/target_update_messages.cpp
  clang/test/OpenMP/target_update_to_messages.cpp

Index: clang/test/OpenMP/target_update_to_messages.cpp
===
--- clang/test/OpenMP/target_update_to_messages.cpp
+++ clang/test/OpenMP/target_update_to_messages.cpp
@@ -79,6 +79,10 @@
 #pragma omp target update to(*(*(this->ptr)+a+this->ptr)) // le45-error {{expected expression containing only member accesses and/or array sections based on named variables}} le45-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
 #pragma omp target update to(*(this+this)) // expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}} expected-error {{invalid operands to binary expression ('S8 *' and 'S8 *')}}
 {}
+
+double marr[10][5][10];
+#pragma omp target update to(marr [0:] [2:4] [1:2]) // le45-error {{array section does not specify contiguous storage}} le45-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
+{}
   }
 };
 
Index: clang/test/OpenMP/target_update_messages.cpp
===
--- clang/test/OpenMP/target_update_messages.cpp
+++ clang/test/OpenMP/target_update_messages.cpp
@@ -1,6 +1,8 @@
-// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 %s -Wuninitialized
+// RUN: %clang_cc1 -verify=expected,le45 -fopenmp -ferror-limit 100 %s -Wuninitialized
+// RUN: %clang_cc1 -verify=expected,le50 -fopenmp -fopenmp-version=50 -ferror-limit 100 %s -Wuninitialized
 
-// RUN: %clang_cc1 -verify -fopenmp-simd -ferror-limit 100 %s -Wuninitialized
+// RUN: %clang_cc1 -verify=expected,le45 -fopenmp-simd -ferror-limit 100 %s -Wuninitialized
+// RUN: %clang_cc1 -verify=expected,le50 -fopenmp-simd -fopenmp-version=50 -ferror-limit 100 %s -Wuninitialized
 
 void xxx(int argc) {
   int x; // expected-note {{initialize the variable 'x' to silence this warning}}
@@ -36,5 +38,21 @@
   {
 foo();
   }
+
+  double marr[10][5][10];
+#pragma omp target update to(marr [0:] [2:4] [1:2]) // le45-error {{array section does not specify contiguous storage}} le45-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
+  {}
+#pragma omp target update from(marr [0:] [2:4] [1:2]) // le45-error {{array section does not specify contiguous storage}} le45-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
+
+  int arr[4][3][2][1];
+#pragma omp target update to(arr [0:2] [2:4][:2][1]) // le45-error {{array section does not specify contiguous storage}} le45-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
+  {}
+#pragma omp target update from(arr [0:2] [2:4][:2][1]) // le45-error {{array section does not specify contiguous storage}} le45-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
+
+  double ***dptr;
+#pragma omp target update to(dptr [0:2] [2:4] [1:2]) // le45-error {{array section does not specify contiguous storage}} le50-error 2 {{section length is unspecified and cannot be inferred because subscripted value is an array of unknown bound}} le45-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
+  {}
+#pragma omp target update from(dptr [0:2] [2:4] [1:2]) // le45-error {{array section does not specify contiguous storage}} le50-error 2 {{section length is unspecified and cannot be inferred because subscripted value is an array of unknown bound}} le45-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
+
   return tmain(argc, argv);
 }
Index: clang/test/OpenMP/target_update_codegen.cpp
===
--- clang/test/OpenMP/target_update_codegen.cpp
+++ clang/test/OpenMP/target_update_codegen.cpp
@@ -1059,5 +1059,304 @@
   #pragma omp target update from(([sa][5])f)
 }
 
+#endif
+///==///
+// RUN: %clang_cc1 -DCK19 -verify -fopenmp -fopenmp-version=50 -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck %s --check-prefix CK19 --check-prefix 

[PATCH] D82592: [libTooling] Rename overloaded `range` range selector.

2020-06-25 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel created this revision.
ymandel added a reviewer: tdl-g.
Herald added a project: clang.
tdl-g accepted this revision.
This revision is now accepted and ready to land.

Renames the overloaded `RangeSelector` combinator `range` to the more
descriptive `enclose` and `encloseNodes`. The old overloads are left in place
and marked deprected and will be deleted at a future time.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D82592

Files:
  clang/include/clang/Tooling/Transformer/RangeSelector.h
  clang/lib/Tooling/Transformer/RangeSelector.cpp
  clang/unittests/Tooling/RangeSelectorTest.cpp


Index: clang/unittests/Tooling/RangeSelectorTest.cpp
===
--- clang/unittests/Tooling/RangeSelectorTest.cpp
+++ clang/unittests/Tooling/RangeSelectorTest.cpp
@@ -201,7 +201,7 @@
   )cc";
   auto Matcher = callExpr(hasArgument(0, expr().bind("a0")),
   hasArgument(1, expr().bind("a1")));
-  RangeSelector R = range("a0", "a1");
+  RangeSelector R = encloseNodes("a0", "a1");
   TestMatch Match = matchCode(Code, Matcher);
   EXPECT_THAT_EXPECTED(select(R, Match), HasValue("3, 7"));
 }
@@ -213,7 +213,7 @@
   )cc";
   auto Matcher = callExpr(hasArgument(0, expr().bind("a0")),
   hasArgument(1, expr().bind("a1")));
-  RangeSelector R = range(node("a0"), node("a1"));
+  RangeSelector R = enclose(node("a0"), node("a1"));
   TestMatch Match = matchCode(Code, Matcher);
   EXPECT_THAT_EXPECTED(select(R, Match), HasValue("3, 7"));
 }
Index: clang/lib/Tooling/Transformer/RangeSelector.cpp
===
--- clang/lib/Tooling/Transformer/RangeSelector.cpp
+++ clang/lib/Tooling/Transformer/RangeSelector.cpp
@@ -146,7 +146,7 @@
   };
 }
 
-RangeSelector transformer::range(RangeSelector Begin, RangeSelector End) {
+RangeSelector transformer::enclose(RangeSelector Begin, RangeSelector End) {
   return [Begin, End](const MatchResult ) -> Expected {
 Expected BeginRange = Begin(Result);
 if (!BeginRange)
@@ -165,8 +165,9 @@
   };
 }
 
-RangeSelector transformer::range(std::string BeginID, std::string EndID) {
-  return transformer::range(node(std::move(BeginID)), node(std::move(EndID)));
+RangeSelector transformer::encloseNodes(std::string BeginID,
+std::string EndID) {
+  return transformer::enclose(node(std::move(BeginID)), 
node(std::move(EndID)));
 }
 
 RangeSelector transformer::member(std::string ID) {
Index: clang/include/clang/Tooling/Transformer/RangeSelector.h
===
--- clang/include/clang/Tooling/Transformer/RangeSelector.h
+++ clang/include/clang/Tooling/Transformer/RangeSelector.h
@@ -32,10 +32,20 @@
 }
 
 /// Selects from the start of \p Begin and to the end of \p End.
-RangeSelector range(RangeSelector Begin, RangeSelector End);
+RangeSelector enclose(RangeSelector Begin, RangeSelector End);
 
 /// Convenience version of \c range where end-points are bound nodes.
-RangeSelector range(std::string BeginID, std::string EndID);
+RangeSelector encloseNodes(std::string BeginID, std::string EndID);
+
+/// DEPRECATED. Use `enclose`.
+inline RangeSelector range(RangeSelector Begin, RangeSelector End) {
+  return enclose(std::move(Begin), std::move(End));
+}
+
+/// DEPRECATED. Use `encloseNodes`.
+inline RangeSelector range(std::string BeginID, std::string EndID) {
+  return encloseNodes(std::move(BeginID), std::move(EndID));
+}
 
 /// Selects the (empty) range [B,B) when \p Selector selects the range [B,E).
 RangeSelector before(RangeSelector Selector);


Index: clang/unittests/Tooling/RangeSelectorTest.cpp
===
--- clang/unittests/Tooling/RangeSelectorTest.cpp
+++ clang/unittests/Tooling/RangeSelectorTest.cpp
@@ -201,7 +201,7 @@
   )cc";
   auto Matcher = callExpr(hasArgument(0, expr().bind("a0")),
   hasArgument(1, expr().bind("a1")));
-  RangeSelector R = range("a0", "a1");
+  RangeSelector R = encloseNodes("a0", "a1");
   TestMatch Match = matchCode(Code, Matcher);
   EXPECT_THAT_EXPECTED(select(R, Match), HasValue("3, 7"));
 }
@@ -213,7 +213,7 @@
   )cc";
   auto Matcher = callExpr(hasArgument(0, expr().bind("a0")),
   hasArgument(1, expr().bind("a1")));
-  RangeSelector R = range(node("a0"), node("a1"));
+  RangeSelector R = enclose(node("a0"), node("a1"));
   TestMatch Match = matchCode(Code, Matcher);
   EXPECT_THAT_EXPECTED(select(R, Match), HasValue("3, 7"));
 }
Index: clang/lib/Tooling/Transformer/RangeSelector.cpp
===
--- clang/lib/Tooling/Transformer/RangeSelector.cpp
+++ clang/lib/Tooling/Transformer/RangeSelector.cpp
@@ -146,7 +146,7 @@
   };
 }
 
-RangeSelector transformer::range(RangeSelector Begin, RangeSelector End) {
+RangeSelector 

[PATCH] D81672: [Driver] When forcing a crash print the bug report message

2020-06-25 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: clang/tools/driver/driver.cpp:515
+
+  llvm::dbgs() << llvm::getBugReportMsg();
 }

john.brawn wrote:
> MaskRay wrote:
> > Why ` llvm::dbgs() << llvm::getBugReportMsg();` when -gen-reproducer is 
> > specified? The user requests to generate a reproduce file, but this does 
> > not suggest that clang has a bug. Dumping an URL is not very appropriate.
> Emitting the bug report message is primarily for when 
> FORCE_CLANG_DIAGNOSTICS_CRASH is set (because we can get here either due to 
> that or -gen-reproducer). I could adjust this to only emit the message when 
> that is set if you'd like? Though either way we get the "PLEASE ATTACH THE 
> FOLLOWING FILES TO THE BUG REPORT:" message.
When `FORCE_CLANG_DIAGNOSTICS_CRASH` is set or `-gen-reproducer` is specified, 
I feel that a URL or "PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT" is 
not very appropriate because this is not a real crash..


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81672/new/

https://reviews.llvm.org/D81672



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


[clang] 6673d69 - [X86] Don't imply -mprfchw when -m3dnow is specified. Enable prefetchw in the backend with 3dnow feature.

2020-06-25 Thread Craig Topper via cfe-commits

Author: Craig Topper
Date: 2020-06-25T12:46:52-07:00
New Revision: 6673d69226d86f4906dca4b627d6e0582486d072

URL: 
https://github.com/llvm/llvm-project/commit/6673d69226d86f4906dca4b627d6e0582486d072
DIFF: 
https://github.com/llvm/llvm-project/commit/6673d69226d86f4906dca4b627d6e0582486d072.diff

LOG: [X86] Don't imply -mprfchw when -m3dnow is specified. Enable prefetchw in 
the backend with 3dnow feature.

The PREFETCHW instruction was originally part of the 3DNow. But
it was given its own CPUID bit on later CPUs just before 3DNow
was deprecated.

We were setting the -mprfchw flag if -m3dnow was passed or the CPU
supported 3dnow unless -mno-prfchw was passed. But -march=native
on a CPU without the PRFCHW CPUID bit set will pass -mno-prfchw.
So -march=k8 will behave differently than -march=native on a K8
for example.

So remove this implicit setting from the frontend and instead
enable the backend to use PREFETCHW if 3dnow OR prfchw is enabled.

Also enable PRFCHW flag on amdfam10/barcelona which seems to be
where this CPUID bit was introduced. That CPU also supported
3dnow.

Added: 


Modified: 
clang/lib/Basic/Targets/X86.cpp
clang/test/Preprocessor/predefined-arch-macros.c
clang/test/Preprocessor/x86_target_features.c
llvm/lib/Target/X86/X86.td
llvm/lib/Target/X86/X86InstrInfo.td
llvm/lib/Target/X86/X86Subtarget.h
llvm/test/CodeGen/X86/prefetch.ll

Removed: 




diff  --git a/clang/lib/Basic/Targets/X86.cpp b/clang/lib/Basic/Targets/X86.cpp
index fcf690847078..cc37c8a5cba0 100644
--- a/clang/lib/Basic/Targets/X86.cpp
+++ b/clang/lib/Basic/Targets/X86.cpp
@@ -335,6 +335,7 @@ bool X86TargetInfo::initFeatureMap(
 setFeatureEnabledImpl(Features, "lzcnt", true);
 setFeatureEnabledImpl(Features, "popcnt", true);
 setFeatureEnabledImpl(Features, "sahf", true);
+setFeatureEnabledImpl(Features, "prfchw", true);
 LLVM_FALLTHROUGH;
   case CK_K8SSE3:
 setFeatureEnabledImpl(Features, "sse3", true);
@@ -450,12 +451,6 @@ bool X86TargetInfo::initFeatureMap(
   llvm::find(FeaturesVec, "-popcnt") == FeaturesVec.end())
 Features["popcnt"] = true;
 
-  // Enable prfchw if 3DNow! is enabled and prfchw is not explicitly disabled.
-  I = Features.find("3dnow");
-  if (I != Features.end() && I->getValue() &&
-  llvm::find(FeaturesVec, "-prfchw") == FeaturesVec.end())
-Features["prfchw"] = true;
-
   // Additionally, if SSE is enabled and mmx is not explicitly disabled,
   // then enable MMX.
   I = Features.find("sse");

diff  --git a/clang/test/Preprocessor/predefined-arch-macros.c 
b/clang/test/Preprocessor/predefined-arch-macros.c
index f7de81028327..4e1535c91c08 100644
--- a/clang/test/Preprocessor/predefined-arch-macros.c
+++ b/clang/test/Preprocessor/predefined-arch-macros.c
@@ -2379,6 +2379,7 @@
 // CHECK_AMDFAM10_M32: #define __LZCNT__ 1
 // CHECK_AMDFAM10_M32: #define __MMX__ 1
 // CHECK_AMDFAM10_M32: #define __POPCNT__ 1
+// CHECK_AMDFAM10_M32: #define __PRFCHW__ 1
 // CHECK_AMDFAM10_M32: #define __SSE2_MATH__ 1
 // CHECK_AMDFAM10_M32: #define __SSE2__ 1
 // CHECK_AMDFAM10_M32: #define __SSE3__ 1
@@ -2399,6 +2400,7 @@
 // CHECK_AMDFAM10_M64: #define __LZCNT__ 1
 // CHECK_AMDFAM10_M64: #define __MMX__ 1
 // CHECK_AMDFAM10_M64: #define __POPCNT__ 1
+// CHECK_AMDFAM10_M64: #define __PRFCHW__ 1
 // CHECK_AMDFAM10_M64: #define __SSE2_MATH__ 1
 // CHECK_AMDFAM10_M64: #define __SSE2__ 1
 // CHECK_AMDFAM10_M64: #define __SSE3__ 1

diff  --git a/clang/test/Preprocessor/x86_target_features.c 
b/clang/test/Preprocessor/x86_target_features.c
index 8e24c1518720..6f3c0cffb17e 100644
--- a/clang/test/Preprocessor/x86_target_features.c
+++ b/clang/test/Preprocessor/x86_target_features.c
@@ -374,10 +374,12 @@
 
 // RUN: %clang -target i386-unknown-unknown -march=atom -m3dnow -x c -E -dM -o 
- %s | FileCheck -match-full-lines --check-prefix=3DNOWPRFCHW %s
 
-// 3DNOWPRFCHW: #define __PRFCHW__ 1
+// 3DNOWPRFCHW: #define __3dNOW__ 1
+// 3DNOWPRFCHW-NOT: #define __PRFCHW__ 1
 
 // RUN: %clang -target i386-unknown-unknown -march=atom -mno-prfchw -m3dnow -x 
c -E -dM -o - %s | FileCheck -match-full-lines --check-prefix=3DNOWNOPRFCHW %s
 
+// 3DNOWNOPRFCHW: #define __3dNOW__ 1
 // 3DNOWNOPRFCHW-NOT: #define __PRFCHW__ 1
 
 // RUN: %clang -target i386-unknown-unknown -march=atom -mprfchw -mno-3dnow -x 
c -E -dM -o - %s | FileCheck -match-full-lines --check-prefix=NO3DNOWPRFCHW %s

diff  --git a/llvm/lib/Target/X86/X86.td b/llvm/lib/Target/X86/X86.td
index bcbc1ae492b2..3e85d4ab2a4c 100644
--- a/llvm/lib/Target/X86/X86.td
+++ b/llvm/lib/Target/X86/X86.td
@@ -847,6 +847,7 @@ def ProcessorFeatures {
  FeatureFXSR,
  FeatureNOPL,
  FeatureCMPXCHG16B,
+ FeaturePRFCHW,
   

[PATCH] D82586: [HIP] Improve check patterns to avoid test failures in case string "opt", etc. happens to be in the command path.

2020-06-25 Thread Hiroshi Yamauchi via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9da93f590414: [HIP] Improve check patterns to avoid test 
failures in case string opt, etc. (authored by yamauchi).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82586/new/

https://reviews.llvm.org/D82586

Files:
  clang/test/Driver/hip-link-save-temps.hip


Index: clang/test/Driver/hip-link-save-temps.hip
===
--- clang/test/Driver/hip-link-save-temps.hip
+++ clang/test/Driver/hip-link-save-temps.hip
@@ -38,9 +38,9 @@
 
 // CHECK: "{{.*clang-offload-bundler.*}}" {{.*}} 
"-outputs=obj1-host-x86_64-unknown-linux-gnu.o,obj1-hip-amdgcn-amd-amdhsa-gfx900.o,obj1-hip-amdgcn-amd-amdhsa-gfx906.o"
 "-unbundle"
 // CHECK: "{{.*clang-offload-bundler.*}}" {{.*}} 
"-outputs=obj2-host-x86_64-unknown-linux-gnu.o,obj2-hip-amdgcn-amd-amdhsa-gfx900.o,obj2-hip-amdgcn-amd-amdhsa-gfx906.o"
 "-unbundle"
-// CHECK-NOT: llvm-link
-// CHECK-NOT: opt
-// CHECK-NOT: llc
+// CHECK-NOT: {{".*/llvm-link"}}
+// CHECK-NOT: {{".*/opt"}}
+// CHECK-NOT: {{".*/llc"}}
 // CHECK: "{{.*lld.*}}" {{.*}} "-mllvm" "-amdgpu-internalize-symbols"
 // CHECK-SAME: "-o" "a.out-hip-amdgcn-amd-amdhsa-gfx900" 
"obj1-hip-amdgcn-amd-amdhsa-gfx900.o" "obj2-hip-amdgcn-amd-amdhsa-gfx900.o"
 // CHECK: "{{.*lld.*}}" {{.*}} "-mllvm" "-amdgpu-internalize-symbols"


Index: clang/test/Driver/hip-link-save-temps.hip
===
--- clang/test/Driver/hip-link-save-temps.hip
+++ clang/test/Driver/hip-link-save-temps.hip
@@ -38,9 +38,9 @@
 
 // CHECK: "{{.*clang-offload-bundler.*}}" {{.*}} "-outputs=obj1-host-x86_64-unknown-linux-gnu.o,obj1-hip-amdgcn-amd-amdhsa-gfx900.o,obj1-hip-amdgcn-amd-amdhsa-gfx906.o" "-unbundle"
 // CHECK: "{{.*clang-offload-bundler.*}}" {{.*}} "-outputs=obj2-host-x86_64-unknown-linux-gnu.o,obj2-hip-amdgcn-amd-amdhsa-gfx900.o,obj2-hip-amdgcn-amd-amdhsa-gfx906.o" "-unbundle"
-// CHECK-NOT: llvm-link
-// CHECK-NOT: opt
-// CHECK-NOT: llc
+// CHECK-NOT: {{".*/llvm-link"}}
+// CHECK-NOT: {{".*/opt"}}
+// CHECK-NOT: {{".*/llc"}}
 // CHECK: "{{.*lld.*}}" {{.*}} "-mllvm" "-amdgpu-internalize-symbols"
 // CHECK-SAME: "-o" "a.out-hip-amdgcn-amd-amdhsa-gfx900" "obj1-hip-amdgcn-amd-amdhsa-gfx900.o" "obj2-hip-amdgcn-amd-amdhsa-gfx900.o"
 // CHECK: "{{.*lld.*}}" {{.*}} "-mllvm" "-amdgpu-internalize-symbols"
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D82579: [NFC] Extract unifyTargetFeatures

2020-06-25 Thread Artem Belevich via Phabricator via cfe-commits
tra marked an inline comment as done.
tra added inline comments.



Comment at: clang/lib/Driver/ToolChains/CommonArgs.cpp:93
+StringRef Name = Features[I];
+assert(Name[0] == '-' || Name[0] == '+');
+LastOpt[Name.drop_front(1)] = I;

yaxunl wrote:
> tra wrote:
> > I don't think assert should be used for something that may be specified to 
> > the user on command line.
> > 
> The entries in this array is not directly from command line.
> 
> It is either put in by clang code, or translated from -mxxx or -mno-xxx 
> options whereas the translated entry should always have + or - prefix. So if 
> things go wrong, it is due to developers.
While clang may be the primary user of those options, features can be specified 
by the user, too.
The general rule of thumb is that invalid external input should produce 
diagnostics, not compiler crashes.
Asserts are for programming errors. Granted, when the inputs may be  generated 
by our code the boundary is blurred, but in this case I would err on the side 
of not crashing.



Comment at: clang/lib/Driver/ToolChains/CommonArgs.cpp:97
+
+  for (unsigned I = 0, N = Features.size(); I < N; ++I) {
+// If this feature was overridden, ignore it.

yaxunl wrote:
> tra wrote:
> > Would it be simpler to just iterate over features backwards and skip the 
> > features we've already seen?
> > 
> That may save a little when there are repeating entries but you need to 
> reverse the obtained vector to maintain the order. Since most cases there are 
> just a few unique features, reversing may ends up slower.
Up to you. Performance does not matter here, but simpler code with improved 
readability is always a plus.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82579/new/

https://reviews.llvm.org/D82579



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


[PATCH] D79719: [AIX] Implement AIX special alignment rule about double/long double

2020-06-25 Thread Jason Liu via Phabricator via cfe-commits
jasonliu accepted this revision.
jasonliu added a comment.

LGTM. I have no further comments on this patch.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D79719/new/

https://reviews.llvm.org/D79719



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


[PATCH] D81672: [Driver] When forcing a crash print the bug report message

2020-06-25 Thread John Brawn via Phabricator via cfe-commits
john.brawn marked an inline comment as done.
john.brawn added inline comments.



Comment at: clang/tools/driver/driver.cpp:515
+
+  llvm::dbgs() << llvm::getBugReportMsg();
 }

MaskRay wrote:
> Why ` llvm::dbgs() << llvm::getBugReportMsg();` when -gen-reproducer is 
> specified? The user requests to generate a reproduce file, but this does not 
> suggest that clang has a bug. Dumping an URL is not very appropriate.
Emitting the bug report message is primarily for when 
FORCE_CLANG_DIAGNOSTICS_CRASH is set (because we can get here either due to 
that or -gen-reproducer). I could adjust this to only emit the message when 
that is set if you'd like? Though either way we get the "PLEASE ATTACH THE 
FOLLOWING FILES TO THE BUG REPORT:" message.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81672/new/

https://reviews.llvm.org/D81672



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


[PATCH] D81938: [InferAddressSpaces] Handle the pair of `ptrtoint`/`inttoptr`.

2020-06-25 Thread Michael Liao via Phabricator via cfe-commits
hliao updated this revision to Diff 273477.
hliao added a comment.

Revise


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81938/new/

https://reviews.llvm.org/D81938

Files:
  clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu
  llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp
  llvm/test/Transforms/InferAddressSpaces/AMDGPU/noop-ptrint-pair.ll

Index: llvm/test/Transforms/InferAddressSpaces/AMDGPU/noop-ptrint-pair.ll
===
--- /dev/null
+++ llvm/test/Transforms/InferAddressSpaces/AMDGPU/noop-ptrint-pair.ll
@@ -0,0 +1,101 @@
+; RUN: opt -mtriple=amdgcn-amd-amdhsa -S -o - -infer-address-spaces %s | FileCheck -check-prefixes=COMMON,AMDGCN %s
+; RUN: opt -S -o - -infer-address-spaces -assume-default-is-flat-addrspace %s | FileCheck -check-prefixes=COMMON,NOTTI %s
+
+target datalayout = "e-p:64:64-p1:64:64-p2:32:32-p3:32:32-p4:64:64-p5:32:32-p6:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-S32-A5-ni:7"
+
+; COMMON-LABEL: @noop_ptrint_pair(
+; AMDGCN-NEXT: store i32 0, i32 addrspace(1)* %{{.*}}
+; AMDGCN-NEXT: ret void
+; NOTTI-NEXT: %1 = ptrtoint i32 addrspace(1)* %x.coerce to i64
+; NOTTI-NEXT: %2 = inttoptr i64 %1 to i32*
+; NOTTI-NEXT: store i32 0, i32* %2
+; NOTTI-NEXT: ret void
+define void @noop_ptrint_pair(i32 addrspace(1)* %x.coerce) {
+  %1 = ptrtoint i32 addrspace(1)* %x.coerce to i64
+  %2 = inttoptr i64 %1 to i32*
+  store i32 0, i32* %2
+  ret void
+}
+
+; COMMON-LABEL: @non_noop_ptrint_pair(
+; AMDGCN-NEXT: ptrtoint i32 addrspace(3)* %{{.*}} to i64
+; AMDGCN-NEXT: inttoptr i64 %{{.*}} to i32*
+; AMDGCN-NEXT: store i32 0, i32* %{{.*}}
+; AMDGCN-NEXT: ret void
+; NOTTI-NEXT: ptrtoint i32 addrspace(3)* %{{.*}} to i64
+; NOTTI-NEXT: inttoptr i64 %{{.*}} to i32*
+; NOTTI-NEXT: store i32 0, i32* %{{.*}}
+; NOTTI-NEXT: ret void
+define void @non_noop_ptrint_pair(i32 addrspace(3)* %x.coerce) {
+  %1 = ptrtoint i32 addrspace(3)* %x.coerce to i64
+  %2 = inttoptr i64 %1 to i32*
+  store i32 0, i32* %2
+  ret void
+}
+
+; COMMON-LABEL: @non_noop_ptrint_pair2(
+; AMDGCN-NEXT: ptrtoint i32 addrspace(1)* %{{.*}} to i32
+; AMDGCN-NEXT: inttoptr i32 %{{.*}} to i32*
+; AMDGCN-NEXT: store i32 0, i32* %{{.*}}
+; AMDGCN-NEXT: ret void
+; NOTTI-NEXT: ptrtoint i32 addrspace(1)* %{{.*}} to i32
+; NOTTI-NEXT: inttoptr i32 %{{.*}} to i32*
+; NOTTI-NEXT: store i32 0, i32* %{{.*}}
+; NOTTI-NEXT: ret void
+define void @non_noop_ptrint_pair2(i32 addrspace(1)* %x.coerce) {
+  %1 = ptrtoint i32 addrspace(1)* %x.coerce to i32
+  %2 = inttoptr i32 %1 to i32*
+  store i32 0, i32* %2
+  ret void
+}
+
+@g = addrspace(1) global i32 0, align 4
+@l = addrspace(3) global i32 0, align 4
+
+; COMMON-LABEL: @noop_ptrint_pair_ce(
+; AMDGCN-NEXT: store i32 0, i32 addrspace(1)* @g
+; AMDGCN-NEXT: ret void
+; NOTTI-NEXT: store i32 0, i32* inttoptr (i64 ptrtoint (i32 addrspace(1)* @g to i64) to i32*)
+; NOTTI-NEXT: ret void
+define void @noop_ptrint_pair_ce() {
+  store i32 0, i32* inttoptr (i64 ptrtoint (i32 addrspace(1)* @g to i64) to i32*)
+  ret void
+}
+
+; COMMON-LABEL: @noop_ptrint_pair_ce2(
+; AMDGCN-NEXT: ret i32* addrspacecast (i32 addrspace(1)* @g to i32*)
+; NOTTI-NEXT: ret i32* inttoptr (i64 ptrtoint (i32 addrspace(1)* @g to i64) to i32*)
+define i32* @noop_ptrint_pair_ce2() {
+  ret i32* inttoptr (i64 ptrtoint (i32 addrspace(1)* @g to i64) to i32*)
+}
+
+; COMMON-LABEL: @non_noop_ptrint_pair_ce(
+; AMDGCN-NEXT: store i32 0, i32* inttoptr (i64 ptrtoint (i32 addrspace(3)* @l to i64) to i32*)
+; AMDGCN-NEXT: ret void
+; NOTTI-NEXT: store i32 0, i32* inttoptr (i64 ptrtoint (i32 addrspace(3)* @l to i64) to i32*)
+; NOTTI-NEXT: ret void
+define void @non_noop_ptrint_pair_ce() {
+  store i32 0, i32* inttoptr (i64 ptrtoint (i32 addrspace(3)* @l to i64) to i32*)
+  ret void
+}
+
+; COMMON-LABEL: @non_noop_ptrint_pair_ce2(
+; AMDGCN-NEXT: ret i32* inttoptr (i64 ptrtoint (i32 addrspace(3)* @l to i64) to i32*)
+; NOTTI-NEXT: ret i32* inttoptr (i64 ptrtoint (i32 addrspace(3)* @l to i64) to i32*)
+define i32* @non_noop_ptrint_pair_ce2() {
+  ret i32* inttoptr (i64 ptrtoint (i32 addrspace(3)* @l to i64) to i32*)
+}
+
+; COMMON-LABEL: @non_noop_ptrint_pair_ce3(
+; AMDGCN-NEXT: ret i32* inttoptr (i32 ptrtoint (i32 addrspace(1)* @g to i32) to i32*)
+; NOTTI-NEXT: ret i32* inttoptr (i32 ptrtoint (i32 addrspace(1)* @g to i32) to i32*)
+define i32* @non_noop_ptrint_pair_ce3() {
+  ret i32* inttoptr (i32 ptrtoint (i32 addrspace(1)* @g to i32) to i32*)
+}
+
+; COMMON-LABEL: @non_noop_ptrint_pair_ce4(
+; AMDGCN-NEXT: ret i32* inttoptr (i128 ptrtoint (i32 addrspace(3)* @l to i128) to i32*)
+; NOTTI-NEXT: ret i32* inttoptr (i128 ptrtoint (i32 addrspace(3)* @l to i128) to i32*)
+define i32* @non_noop_ptrint_pair_ce4() {
+  ret i32* inttoptr (i128 ptrtoint (i32 addrspace(3)* @l to i128) to i32*)
+}
Index: llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp

[PATCH] D81282: [builtins] Move more float128-related helpers to GENERIC_TF_SOURCES list

2020-06-25 Thread Eli Friedman via Phabricator via cfe-commits
efriedma accepted this revision.
efriedma added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81282/new/

https://reviews.llvm.org/D81282



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


[clang] 9da93f5 - [HIP] Improve check patterns to avoid test failures in case string "opt", etc. happens to be in the command path.

2020-06-25 Thread Hiroshi Yamauchi via cfe-commits

Author: Hiroshi Yamauchi
Date: 2020-06-25T12:18:43-07:00
New Revision: 9da93f590414ae3b7be20061d8a97695b263482e

URL: 
https://github.com/llvm/llvm-project/commit/9da93f590414ae3b7be20061d8a97695b263482e
DIFF: 
https://github.com/llvm/llvm-project/commit/9da93f590414ae3b7be20061d8a97695b263482e.diff

LOG: [HIP] Improve check patterns to avoid test failures in case string "opt", 
etc. happens to be in the command path.

Similarly to D82046.

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

Added: 


Modified: 
clang/test/Driver/hip-link-save-temps.hip

Removed: 




diff  --git a/clang/test/Driver/hip-link-save-temps.hip 
b/clang/test/Driver/hip-link-save-temps.hip
index 15ab210a84f7..d03cf1e5f4a9 100644
--- a/clang/test/Driver/hip-link-save-temps.hip
+++ b/clang/test/Driver/hip-link-save-temps.hip
@@ -38,9 +38,9 @@
 
 // CHECK: "{{.*clang-offload-bundler.*}}" {{.*}} 
"-outputs=obj1-host-x86_64-unknown-linux-gnu.o,obj1-hip-amdgcn-amd-amdhsa-gfx900.o,obj1-hip-amdgcn-amd-amdhsa-gfx906.o"
 "-unbundle"
 // CHECK: "{{.*clang-offload-bundler.*}}" {{.*}} 
"-outputs=obj2-host-x86_64-unknown-linux-gnu.o,obj2-hip-amdgcn-amd-amdhsa-gfx900.o,obj2-hip-amdgcn-amd-amdhsa-gfx906.o"
 "-unbundle"
-// CHECK-NOT: llvm-link
-// CHECK-NOT: opt
-// CHECK-NOT: llc
+// CHECK-NOT: {{".*/llvm-link"}}
+// CHECK-NOT: {{".*/opt"}}
+// CHECK-NOT: {{".*/llc"}}
 // CHECK: "{{.*lld.*}}" {{.*}} "-mllvm" "-amdgpu-internalize-symbols"
 // CHECK-SAME: "-o" "a.out-hip-amdgcn-amd-amdhsa-gfx900" 
"obj1-hip-amdgcn-amd-amdhsa-gfx900.o" "obj2-hip-amdgcn-amd-amdhsa-gfx900.o"
 // CHECK: "{{.*lld.*}}" {{.*}} "-mllvm" "-amdgpu-internalize-symbols"



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


[PATCH] D82579: [NFC] Extract unifyTargetFeatures

2020-06-25 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 273473.
yaxunl marked 2 inline comments as done.
yaxunl added a comment.

return the unified features.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82579/new/

https://reviews.llvm.org/D82579

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/lib/Driver/ToolChains/CommonArgs.h
  clang/test/Driver/hip-toolchain-features.hip

Index: clang/test/Driver/hip-toolchain-features.hip
===
--- clang/test/Driver/hip-toolchain-features.hip
+++ clang/test/Driver/hip-toolchain-features.hip
@@ -35,3 +35,13 @@
 
 // ALL3: {{.*}}clang{{.*}}"-target-feature" "+xnack" "-target-feature" "+sram-ecc"
 // NOALL3: {{.*}}clang{{.*}}"-target-feature" "-xnack" "-target-feature" "-sram-ecc"
+
+// RUN: %clang -### -target x86_64-linux-gnu -fgpu-rdc -nogpulib \
+// RUN:   --cuda-gpu-arch=gfx1010 %s \
+// RUN:   -mcumode -mcumode -mno-cumode -mwavefrontsize64 -mcumode \
+// RUN:   -mwavefrontsize64 -mno-wavefrontsize64 2>&1 \
+// RUN:   | FileCheck %s -check-prefix=DUP
+// DUP: {{.*}}clang{{.*}} "-target-feature" "-wavefrontsize16"
+// DUP-SAME: "-target-feature" "+wavefrontsize32"
+// DUP-SAME: "-target-feature" "-wavefrontsize64"
+// DUP-SAME: "-target-feature" "+cumode"
Index: clang/lib/Driver/ToolChains/CommonArgs.h
===
--- clang/lib/Driver/ToolChains/CommonArgs.h
+++ clang/lib/Driver/ToolChains/CommonArgs.h
@@ -106,10 +106,20 @@
 std::string getCPUName(const llvm::opt::ArgList , const llvm::Triple ,
bool FromAs = false);
 
+/// Iterate \p Args and convert -mxxx to +xxx and -mno-xxx to -xxx and
+/// append it to \p Features.
+///
+/// Note: Since \p Features may contain default values before calling
+/// this function, or may be appended with entries to override arguments,
+/// entries in \p Features are not unique.
 void handleTargetFeaturesGroup(const llvm::opt::ArgList ,
std::vector ,
llvm::opt::OptSpecifier Group);
 
+/// If there are multiple +xxx or -xxx features, keep the last one.
+std::vector
+unifyTargetFeatures(const std::vector );
+
 /// Handles the -save-stats option and returns the filename to save statistics
 /// to.
 SmallString<128> getStatsFileName(const llvm::opt::ArgList ,
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -84,6 +84,31 @@
   }
 }
 
+std::vector
+tools::unifyTargetFeatures(const std::vector ) {
+  std::vector UnifiedFeatures;
+  // Find the last of each feature.
+  llvm::StringMap LastOpt;
+  for (unsigned I = 0, N = Features.size(); I < N; ++I) {
+StringRef Name = Features[I];
+assert(Name[0] == '-' || Name[0] == '+');
+LastOpt[Name.drop_front(1)] = I;
+  }
+
+  for (unsigned I = 0, N = Features.size(); I < N; ++I) {
+// If this feature was overridden, ignore it.
+StringRef Name = Features[I];
+llvm::StringMap::iterator LastI = LastOpt.find(Name.drop_front(1));
+assert(LastI != LastOpt.end());
+unsigned Last = LastI->second;
+if (Last != I)
+  continue;
+
+UnifiedFeatures.push_back(Name);
+  }
+  return UnifiedFeatures;
+}
+
 void tools::addDirectoryList(const ArgList , ArgStringList ,
  const char *ArgName, const char *EnvVar) {
   const char *DirList = ::getenv(EnvVar);
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -374,25 +374,9 @@
 ve::getVETargetFeatures(D, Args, Features);
   }
 
-  // Find the last of each feature.
-  llvm::StringMap LastOpt;
-  for (unsigned I = 0, N = Features.size(); I < N; ++I) {
-StringRef Name = Features[I];
-assert(Name[0] == '-' || Name[0] == '+');
-LastOpt[Name.drop_front(1)] = I;
-  }
-
-  for (unsigned I = 0, N = Features.size(); I < N; ++I) {
-// If this feature was overridden, ignore it.
-StringRef Name = Features[I];
-llvm::StringMap::iterator LastI = LastOpt.find(Name.drop_front(1));
-assert(LastI != LastOpt.end());
-unsigned Last = LastI->second;
-if (Last != I)
-  continue;
-
+  for (auto Feature : unifyTargetFeatures(Features)) {
 CmdArgs.push_back(IsAux ? "-aux-target-feature" : "-target-feature");
-CmdArgs.push_back(Name.data());
+CmdArgs.push_back(Feature.data());
   }
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D82332: [Coroutines] Handle dependent promise types for final_suspend non-throw check

2020-06-25 Thread Xun Li via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc25acec84594: [Coroutines] Handle dependent promise types 
for final_suspend non-throw check (authored by lxfind).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82332/new/

https://reviews.llvm.org/D82332

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaCoroutine.cpp
  clang/lib/Sema/TreeTransform.h
  clang/test/SemaCXX/coroutine-final-suspend-noexcept.cpp

Index: clang/test/SemaCXX/coroutine-final-suspend-noexcept.cpp
===
--- clang/test/SemaCXX/coroutine-final-suspend-noexcept.cpp
+++ clang/test/SemaCXX/coroutine-final-suspend-noexcept.cpp
@@ -11,27 +11,27 @@
 
 template 
 struct coroutine_handle {
-  static coroutine_handle from_address(void *); // expected-note {{must be declared with 'noexcept'}}
+  static coroutine_handle from_address(void *); // expected-note 2 {{must be declared with 'noexcept'}}
 };
 template <>
 struct coroutine_handle {
   template 
-  coroutine_handle(coroutine_handle); // expected-note {{must be declared with 'noexcept'}}
+  coroutine_handle(coroutine_handle); // expected-note 2 {{must be declared with 'noexcept'}}
 };
 
 struct suspend_never {
-  bool await_ready() { return true; }   // expected-note {{must be declared with 'noexcept'}}
-  void await_suspend(coroutine_handle<>) {} // expected-note {{must be declared with 'noexcept'}}
-  void await_resume() {}// expected-note {{must be declared with 'noexcept'}}
-  ~suspend_never() noexcept(false); // expected-note {{must be declared with 'noexcept'}}
+  bool await_ready() { return true; }   // expected-note 2 {{must be declared with 'noexcept'}}
+  void await_suspend(coroutine_handle<>) {} // expected-note 2 {{must be declared with 'noexcept'}}
+  void await_resume() {}// expected-note 2 {{must be declared with 'noexcept'}}
+  ~suspend_never() noexcept(false); // expected-note 2 {{must be declared with 'noexcept'}}
 };
 
 struct suspend_always {
   bool await_ready() { return false; }
   void await_suspend(coroutine_handle<>) {}
   void await_resume() {}
-  suspend_never operator co_await(); // expected-note {{must be declared with 'noexcept'}}
-  ~suspend_always() noexcept(false); // expected-note {{must be declared with 'noexcept'}}
+  suspend_never operator co_await(); // expected-note 2 {{must be declared with 'noexcept'}}
+  ~suspend_always() noexcept(false); // expected-note 2 {{must be declared with 'noexcept'}}
 };
 
 } // namespace experimental
@@ -50,7 +50,7 @@
   struct promise_type {
 coro_t get_return_object();
 suspend_never initial_suspend();
-suspend_always final_suspend(); // expected-note {{must be declared with 'noexcept'}}
+suspend_always final_suspend(); // expected-note 2 {{must be declared with 'noexcept'}}
 void return_void();
 static void unhandled_exception();
   };
@@ -60,3 +60,13 @@
   A a{};
   co_await a;
 }
+
+template 
+coro_t f_dep(T n) { // expected-error {{the expression 'co_await __promise.final_suspend()' is required to be non-throwing}}
+  A a{};
+  co_await a;
+}
+
+void foo() {
+  f_dep(5); // expected-note {{in instantiation of function template specialization 'f_dep' requested here}}
+}
Index: clang/lib/Sema/TreeTransform.h
===
--- clang/lib/Sema/TreeTransform.h
+++ clang/lib/Sema/TreeTransform.h
@@ -7630,7 +7630,8 @@
 return StmtError();
   StmtResult FinalSuspend =
   getDerived().TransformStmt(S->getFinalSuspendStmt());
-  if (FinalSuspend.isInvalid())
+  if (FinalSuspend.isInvalid() ||
+  !SemaRef.checkFinalSuspendNoThrow(FinalSuspend.get()))
 return StmtError();
   ScopeInfo->setCoroutineSuspends(InitSuspend.get(), FinalSuspend.get());
   assert(isa(InitSuspend.get()) && isa(FinalSuspend.get()));
Index: clang/lib/Sema/SemaCoroutine.cpp
===
--- clang/lib/Sema/SemaCoroutine.cpp
+++ clang/lib/Sema/SemaCoroutine.cpp
@@ -642,7 +642,6 @@
   } else if (SC == Expr::CallExprClass || SC == Expr::CXXMemberCallExprClass ||
  SC == Expr::CXXOperatorCallExprClass) {
 if (!cast(E)->isTypeDependent()) {
-  // FIXME: Handle dependent types.
   checkDeclNoexcept(cast(E)->getCalleeDecl());
   auto ReturnType = cast(E)->getCallReturnType(S.getASTContext());
   // Check the destructor of the call return type, if any.
@@ -662,22 +661,20 @@
   }
 }
 
-/// Check that the expression co_await promise.final_suspend() shall not be
-/// potentially-throwing.
-static bool checkNoThrow(Sema , const Stmt *FinalSuspend) {
+bool Sema::checkFinalSuspendNoThrow(const Stmt *FinalSuspend) {
   llvm::SmallPtrSet ThrowingDecls;
   // We first collect all declarations that should not throw but not declared
   // with noexcept. We then sort them 

[PATCH] D82579: [NFC] Extract unifyTargetFeatures

2020-06-25 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl marked 4 inline comments as done.
yaxunl added inline comments.



Comment at: clang/lib/Driver/ToolChains/CommonArgs.cpp:93
+StringRef Name = Features[I];
+assert(Name[0] == '-' || Name[0] == '+');
+LastOpt[Name.drop_front(1)] = I;

tra wrote:
> I don't think assert should be used for something that may be specified to 
> the user on command line.
> 
The entries in this array is not directly from command line.

It is either put in by clang code, or translated from -mxxx or -mno-xxx options 
whereas the translated entry should always have + or - prefix. So if things go 
wrong, it is due to developers.



Comment at: clang/lib/Driver/ToolChains/CommonArgs.cpp:97
+
+  for (unsigned I = 0, N = Features.size(); I < N; ++I) {
+// If this feature was overridden, ignore it.

tra wrote:
> Would it be simpler to just iterate over features backwards and skip the 
> features we've already seen?
> 
That may save a little when there are repeating entries but you need to reverse 
the obtained vector to maintain the order. Since most cases there are just a 
few unique features, reversing may ends up slower.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82579/new/

https://reviews.llvm.org/D82579



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


[PATCH] D82477: [lldb-vscode] Add Support for Module Event

2020-06-25 Thread Greg Clayton via Phabricator via cfe-commits
clayborg added a comment.

Here is a makefile that does stripping:

llvm-project/lldb/test/API/lang/objc/objc-ivar-stripped/Makefile

Then when creating the target, use a.out.stripped:

  exe = self.getBuildArtifact("a.out.stripped")
  symbols = exe = self.getBuildArtifact("a.out")
  target = self.dbg.CreateTarget(exe)

Then after you get the modules, you can do:

  self.dbg.HandleCommand('target symbols add "%s"' % (symbols))

And that should trigger the symbols added notification and then you can fetch 
the modules again and verify that there is now a symbol file for 
"a.out.stripped".


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82477/new/

https://reviews.llvm.org/D82477



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


[PATCH] D81678: Introduce noundef attribute at call sites for stricter poison analysis

2020-06-25 Thread Gui Andrade via Phabricator via cfe-commits
guiand updated this revision to Diff 273456.
guiand retitled this revision from "Introduce frozen attribute at call sites 
for stricter poison analysis" to "Introduce noundef attribute at call sites for 
stricter poison analysis".
guiand edited the summary of this revision.
guiand added a comment.

Renamed to noundef, added additional checks before determining attribute


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81678/new/

https://reviews.llvm.org/D81678

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Driver/CC1Options.td
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  llvm/include/llvm/Bitcode/LLVMBitCodes.h
  llvm/include/llvm/IR/Attributes.td
  llvm/lib/AsmParser/LLLexer.cpp
  llvm/lib/AsmParser/LLParser.cpp
  llvm/lib/AsmParser/LLToken.h
  llvm/lib/Bitcode/Reader/BitcodeReader.cpp
  llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
  llvm/lib/IR/Attributes.cpp
  llvm/lib/Transforms/Utils/CodeExtractor.cpp

Index: llvm/lib/Transforms/Utils/CodeExtractor.cpp
===
--- llvm/lib/Transforms/Utils/CodeExtractor.cpp
+++ llvm/lib/Transforms/Utils/CodeExtractor.cpp
@@ -929,6 +929,7 @@
   case Attribute::StrictFP:
   case Attribute::UWTable:
   case Attribute::NoCfCheck:
+  case Attribute::NoUndef:
 break;
   }
 
Index: llvm/lib/IR/Attributes.cpp
===
--- llvm/lib/IR/Attributes.cpp
+++ llvm/lib/IR/Attributes.cpp
@@ -443,6 +443,8 @@
 return "cold";
   if (hasAttribute(Attribute::ImmArg))
 return "immarg";
+  if (hasAttribute(Attribute::NoUndef))
+return "noundef";
 
   if (hasAttribute(Attribute::ByVal)) {
 std::string Result;
Index: llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
===
--- llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
+++ llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
@@ -731,6 +731,8 @@
 return bitc::ATTR_KIND_SANITIZE_MEMTAG;
   case Attribute::Preallocated:
 return bitc::ATTR_KIND_PREALLOCATED;
+  case Attribute::NoUndef:
+return bitc::ATTR_KIND_NOUNDEF;
   case Attribute::EndAttrKinds:
 llvm_unreachable("Can not encode end-attribute kinds marker.");
   case Attribute::None:
Index: llvm/lib/Bitcode/Reader/BitcodeReader.cpp
===
--- llvm/lib/Bitcode/Reader/BitcodeReader.cpp
+++ llvm/lib/Bitcode/Reader/BitcodeReader.cpp
@@ -1532,6 +1532,8 @@
 return Attribute::SanitizeMemTag;
   case bitc::ATTR_KIND_PREALLOCATED:
 return Attribute::Preallocated;
+  case bitc::ATTR_KIND_NOUNDEF:
+return Attribute::NoUndef;
   }
 }
 
Index: llvm/lib/AsmParser/LLToken.h
===
--- llvm/lib/AsmParser/LLToken.h
+++ llvm/lib/AsmParser/LLToken.h
@@ -196,6 +196,7 @@
   kw_naked,
   kw_nest,
   kw_noalias,
+  kw_noundef,
   kw_nobuiltin,
   kw_nocapture,
   kw_noduplicate,
Index: llvm/lib/AsmParser/LLParser.cpp
===
--- llvm/lib/AsmParser/LLParser.cpp
+++ llvm/lib/AsmParser/LLParser.cpp
@@ -1374,6 +1374,7 @@
 case lltok::kw_inalloca:
 case lltok::kw_nest:
 case lltok::kw_noalias:
+case lltok::kw_noundef:
 case lltok::kw_nocapture:
 case lltok::kw_nonnull:
 case lltok::kw_returned:
@@ -1677,6 +1678,9 @@
 case lltok::kw_inalloca:B.addAttribute(Attribute::InAlloca); break;
 case lltok::kw_inreg:   B.addAttribute(Attribute::InReg); break;
 case lltok::kw_nest:B.addAttribute(Attribute::Nest); break;
+case lltok::kw_noundef:
+  B.addAttribute(Attribute::NoUndef);
+  break;
 case lltok::kw_noalias: B.addAttribute(Attribute::NoAlias); break;
 case lltok::kw_nocapture:   B.addAttribute(Attribute::NoCapture); break;
 case lltok::kw_nofree:  B.addAttribute(Attribute::NoFree); break;
@@ -1774,6 +1778,9 @@
 }
 case lltok::kw_inreg:   B.addAttribute(Attribute::InReg); break;
 case lltok::kw_noalias: B.addAttribute(Attribute::NoAlias); break;
+case lltok::kw_noundef:
+  B.addAttribute(Attribute::NoUndef);
+  break;
 case lltok::kw_nonnull: B.addAttribute(Attribute::NonNull); break;
 case lltok::kw_signext: B.addAttribute(Attribute::SExt); break;
 case lltok::kw_zeroext: B.addAttribute(Attribute::ZExt); break;
Index: llvm/lib/AsmParser/LLLexer.cpp
===
--- llvm/lib/AsmParser/LLLexer.cpp
+++ llvm/lib/AsmParser/LLLexer.cpp
@@ -696,6 +696,7 @@
   KEYWORD(writeonly);
   KEYWORD(zeroext);
   KEYWORD(immarg);
+  KEYWORD(noundef);
 
   KEYWORD(type);
   KEYWORD(opaque);
Index: llvm/include/llvm/IR/Attributes.td

[PATCH] D81678: Introduce noundef attribute at call sites for stricter poison analysis

2020-06-25 Thread Gui Andrade via Phabricator via cfe-commits
guiand marked an inline comment as done.
guiand added inline comments.



Comment at: clang/lib/CodeGen/CGCall.cpp:2082
+  const Type *RetTyPtr = RetTy.getTypePtr();
+  if (!RetTy->isVoidType() && !RetTyPtr->isRecordType() &&
+  RetAI.getKind() != ABIArgInfo::Indirect) {

guiand wrote:
> rsmith wrote:
> > Other types that we should think about from a padding perspective:
> > 
> >  * `nullptr_t` (which has the same size and alignment as `void*` but is all 
> > padding)
> >  * 80-bit `long double` and `_Complex long double` (I don't know whether we 
> > guarantee to initialize the 6 padding bytes)
> >  * member pointers might contain padding under some ABI rules -- under the 
> > MS ABI, you get a struct containing N pointers followed by M ints, which 
> > could have 4 bytes of tail padding on 64-bit targets
> >  * vector types with tail padding (eg, a vector of 3 `char`s is sometimes 
> > passed as an `i32` with one byte `undef`)
> >  * matrix types (presumably the same concerns as for vector types apply 
> > here)
> >  * maybe Obj-C object types?
> >  * `_ExtInt` types (eg, returning an `_ExtInt(65)` initialized to 0 
> > produces an `{i64, i64}` containing 7 bytes of `undef`)
> > 
> > It would be safer to list exactly those types for which we know this 
> > assumption is correct rather than assuming that it's correct by default -- 
> > I think more than half of the `Type` subclasses for concrete canonical 
> > types can have undef bits in their IR representation.
> This is a good point, and I think there was some nuance that I had previously 
> included in determining this for records (since removed) that I didn't think 
> to include in CGCall.cpp.
> 
> I think one particular check, `llvm::DataLayout::typeSizeEqualsStoreSize`, 
> handles a lot of these cases:
> - `long double`
> - oddly-sized vectors
> - `_ExtInt` types
> 
> I don't know if the `matrix` type has internal padding (like structs) but if 
> not it would cover that as well.  
> I believe that the struct with padding wouldn't be an issue as we're 
> excluding record types here.  
> And I'd have to take a closer look at `nullptr_t` to see how it behaves here.
> 
> ~~~
> 
> But if I'd like to build an exhaustive list of types I think will work 
> correctly with a check like this:
> - scalars
> - floating point numbers
> - pointers
> 
> I think I'd need also need an inner `typeSizeEqualsStoreSize` check on the 
> base type of vectors/complex numbers.
> nullptr_t (which has the same size and alignment as void* but is all padding)

From what I can gather looking at the IR of `test/CodeGenCXX/nullptr.cpp`, it 
looks like `nullptr_t` arguments and return values are represented as normal 
`i8*` types but given the special value `null`. From this it seems like we can 
mark them `noundef` without worry?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81678/new/

https://reviews.llvm.org/D81678



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


[clang] 01c18f9 - Revert "[X86] Don't imply -mprfchw when -m3dnow is specified. Enable prefetchw in the backend with 3dnow feature."

2020-06-25 Thread Craig Topper via cfe-commits

Author: Craig Topper
Date: 2020-06-25T11:43:02-07:00
New Revision: 01c18f9199ace4cb15a7c82a4163c9ef84972342

URL: 
https://github.com/llvm/llvm-project/commit/01c18f9199ace4cb15a7c82a4163c9ef84972342
DIFF: 
https://github.com/llvm/llvm-project/commit/01c18f9199ace4cb15a7c82a4163c9ef84972342.diff

LOG: Revert "[X86] Don't imply -mprfchw when -m3dnow is specified. Enable 
prefetchw in the backend with 3dnow feature."

This is failing on the bots.

This reverts commit 636d31a5c341ff2ca5eefd6075ff059eb60b5a80.

Added: 


Modified: 
clang/lib/Basic/Targets/X86.cpp
clang/test/Preprocessor/predefined-arch-macros.c
llvm/lib/Target/X86/X86.td
llvm/lib/Target/X86/X86InstrInfo.td
llvm/lib/Target/X86/X86Subtarget.h
llvm/test/CodeGen/X86/prefetch.ll

Removed: 




diff  --git a/clang/lib/Basic/Targets/X86.cpp b/clang/lib/Basic/Targets/X86.cpp
index cc37c8a5cba0..fcf690847078 100644
--- a/clang/lib/Basic/Targets/X86.cpp
+++ b/clang/lib/Basic/Targets/X86.cpp
@@ -335,7 +335,6 @@ bool X86TargetInfo::initFeatureMap(
 setFeatureEnabledImpl(Features, "lzcnt", true);
 setFeatureEnabledImpl(Features, "popcnt", true);
 setFeatureEnabledImpl(Features, "sahf", true);
-setFeatureEnabledImpl(Features, "prfchw", true);
 LLVM_FALLTHROUGH;
   case CK_K8SSE3:
 setFeatureEnabledImpl(Features, "sse3", true);
@@ -451,6 +450,12 @@ bool X86TargetInfo::initFeatureMap(
   llvm::find(FeaturesVec, "-popcnt") == FeaturesVec.end())
 Features["popcnt"] = true;
 
+  // Enable prfchw if 3DNow! is enabled and prfchw is not explicitly disabled.
+  I = Features.find("3dnow");
+  if (I != Features.end() && I->getValue() &&
+  llvm::find(FeaturesVec, "-prfchw") == FeaturesVec.end())
+Features["prfchw"] = true;
+
   // Additionally, if SSE is enabled and mmx is not explicitly disabled,
   // then enable MMX.
   I = Features.find("sse");

diff  --git a/clang/test/Preprocessor/predefined-arch-macros.c 
b/clang/test/Preprocessor/predefined-arch-macros.c
index 4e1535c91c08..f7de81028327 100644
--- a/clang/test/Preprocessor/predefined-arch-macros.c
+++ b/clang/test/Preprocessor/predefined-arch-macros.c
@@ -2379,7 +2379,6 @@
 // CHECK_AMDFAM10_M32: #define __LZCNT__ 1
 // CHECK_AMDFAM10_M32: #define __MMX__ 1
 // CHECK_AMDFAM10_M32: #define __POPCNT__ 1
-// CHECK_AMDFAM10_M32: #define __PRFCHW__ 1
 // CHECK_AMDFAM10_M32: #define __SSE2_MATH__ 1
 // CHECK_AMDFAM10_M32: #define __SSE2__ 1
 // CHECK_AMDFAM10_M32: #define __SSE3__ 1
@@ -2400,7 +2399,6 @@
 // CHECK_AMDFAM10_M64: #define __LZCNT__ 1
 // CHECK_AMDFAM10_M64: #define __MMX__ 1
 // CHECK_AMDFAM10_M64: #define __POPCNT__ 1
-// CHECK_AMDFAM10_M64: #define __PRFCHW__ 1
 // CHECK_AMDFAM10_M64: #define __SSE2_MATH__ 1
 // CHECK_AMDFAM10_M64: #define __SSE2__ 1
 // CHECK_AMDFAM10_M64: #define __SSE3__ 1

diff  --git a/llvm/lib/Target/X86/X86.td b/llvm/lib/Target/X86/X86.td
index 3e85d4ab2a4c..bcbc1ae492b2 100644
--- a/llvm/lib/Target/X86/X86.td
+++ b/llvm/lib/Target/X86/X86.td
@@ -847,7 +847,6 @@ def ProcessorFeatures {
  FeatureFXSR,
  FeatureNOPL,
  FeatureCMPXCHG16B,
- FeaturePRFCHW,
  FeatureLZCNT,
  FeaturePOPCNT,
  FeatureSlowSHLD,

diff  --git a/llvm/lib/Target/X86/X86InstrInfo.td 
b/llvm/lib/Target/X86/X86InstrInfo.td
index 46ca1896e4e2..262961af7c51 100644
--- a/llvm/lib/Target/X86/X86InstrInfo.td
+++ b/llvm/lib/Target/X86/X86InstrInfo.td
@@ -928,10 +928,11 @@ def HasRTM   : Predicate<"Subtarget->hasRTM()">;
 def HasADX   : Predicate<"Subtarget->hasADX()">;
 def HasSHA   : Predicate<"Subtarget->hasSHA()">;
 def HasSGX   : Predicate<"Subtarget->hasSGX()">;
+def HasPRFCHW: Predicate<"Subtarget->hasPRFCHW()">;
 def HasRDSEED: Predicate<"Subtarget->hasRDSEED()">;
 def HasSSEPrefetch : Predicate<"Subtarget->hasSSEPrefetch()">;
 def NoSSEPrefetch : Predicate<"!Subtarget->hasSSEPrefetch()">;
-def HasPrefetchW : Predicate<"Subtarget->hasPrefetchW()">;
+def HasPrefetchW : Predicate<"Subtarget->hasPRFCHW()">;
 def HasPREFETCHWT1 : Predicate<"Subtarget->hasPREFETCHWT1()">;
 def HasLAHFSAHF  : Predicate<"Subtarget->hasLAHFSAHF()">;
 def HasMWAITX: Predicate<"Subtarget->hasMWAITX()">;

diff  --git a/llvm/lib/Target/X86/X86Subtarget.h 
b/llvm/lib/Target/X86/X86Subtarget.h
index 16483e835f50..5c514311db90 100644
--- a/llvm/lib/Target/X86/X86Subtarget.h
+++ b/llvm/lib/Target/X86/X86Subtarget.h
@@ -647,15 +647,8 @@ class X86Subtarget final : public X86GenSubtargetInfo {
   bool hasRTM() const { return HasRTM; }
   bool hasADX() const { return HasADX; }
   

[clang] c25acec - [Coroutines] Handle dependent promise types for final_suspend non-throw check

2020-06-25 Thread Xun Li via cfe-commits

Author: Xun Li
Date: 2020-06-25T11:27:27-07:00
New Revision: c25acec84594ca15748553341969f8e579290e27

URL: 
https://github.com/llvm/llvm-project/commit/c25acec84594ca15748553341969f8e579290e27
DIFF: 
https://github.com/llvm/llvm-project/commit/c25acec84594ca15748553341969f8e579290e27.diff

LOG: [Coroutines] Handle dependent promise types for final_suspend non-throw 
check

Summary:
Check that the co_await promise.final_suspend() does not potentially throw 
again after we have resolved dependent types.
This takes care of the cases where promises types are templated.
Added test cases for this scenario and confirmed that the checks happen now.
Also run libcxx tests locally to make sure all tests pass.

Reviewers: Benabik, lewissbaker, junparser, modocache

Reviewed By: modocache

Subscribers: modocache, cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang/include/clang/Sema/Sema.h
clang/lib/Sema/SemaCoroutine.cpp
clang/lib/Sema/TreeTransform.h
clang/test/SemaCXX/coroutine-final-suspend-noexcept.cpp

Removed: 




diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 19c68423e5da..f3024efa293c 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -9804,6 +9804,9 @@ class Sema final {
   void CheckCompletedCoroutineBody(FunctionDecl *FD, Stmt *);
   ClassTemplateDecl *lookupCoroutineTraits(SourceLocation KwLoc,
SourceLocation FuncLoc);
+  /// Check that the expression co_await promise.final_suspend() shall not be
+  /// potentially-throwing.
+  bool checkFinalSuspendNoThrow(const Stmt *FinalSuspend);
 
   
//======//
   // OpenCL extensions.

diff  --git a/clang/lib/Sema/SemaCoroutine.cpp 
b/clang/lib/Sema/SemaCoroutine.cpp
index 6262f4b117d3..70b8fd282056 100644
--- a/clang/lib/Sema/SemaCoroutine.cpp
+++ b/clang/lib/Sema/SemaCoroutine.cpp
@@ -642,7 +642,6 @@ static void checkNoThrow(Sema , const Stmt *E,
   } else if (SC == Expr::CallExprClass || SC == Expr::CXXMemberCallExprClass ||
  SC == Expr::CXXOperatorCallExprClass) {
 if (!cast(E)->isTypeDependent()) {
-  // FIXME: Handle dependent types.
   checkDeclNoexcept(cast(E)->getCalleeDecl());
   auto ReturnType = 
cast(E)->getCallReturnType(S.getASTContext());
   // Check the destructor of the call return type, if any.
@@ -662,22 +661,20 @@ static void checkNoThrow(Sema , const Stmt *E,
   }
 }
 
-/// Check that the expression co_await promise.final_suspend() shall not be
-/// potentially-throwing.
-static bool checkNoThrow(Sema , const Stmt *FinalSuspend) {
+bool Sema::checkFinalSuspendNoThrow(const Stmt *FinalSuspend) {
   llvm::SmallPtrSet ThrowingDecls;
   // We first collect all declarations that should not throw but not declared
   // with noexcept. We then sort them based on the location before printing.
   // This is to avoid emitting the same note multiple times on the same
   // declaration, and also provide a deterministic order for the messages.
-  checkNoThrow(S, FinalSuspend, ThrowingDecls);
+  checkNoThrow(*this, FinalSuspend, ThrowingDecls);
   auto SortedDecls = llvm::SmallVector{ThrowingDecls.begin(),
 ThrowingDecls.end()};
   sort(SortedDecls, [](const Decl *A, const Decl *B) {
 return A->getEndLoc() < B->getEndLoc();
   });
   for (const auto *D : SortedDecls) {
-S.Diag(D->getEndLoc(), diag::note_coroutine_function_declare_noexcept);
+Diag(D->getEndLoc(), diag::note_coroutine_function_declare_noexcept);
   }
   return ThrowingDecls.empty();
 }
@@ -724,7 +721,7 @@ bool Sema::ActOnCoroutineBodyStart(Scope *SC, 
SourceLocation KWLoc,
 return true;
 
   StmtResult FinalSuspend = buildSuspends("final_suspend");
-  if (FinalSuspend.isInvalid() || !checkNoThrow(*this, FinalSuspend.get()))
+  if (FinalSuspend.isInvalid() || 
!checkFinalSuspendNoThrow(FinalSuspend.get()))
 return true;
 
   ScopeInfo->setCoroutineSuspends(InitSuspend.get(), FinalSuspend.get());

diff  --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h
index ff9d4d610660..ce9c30339617 100644
--- a/clang/lib/Sema/TreeTransform.h
+++ b/clang/lib/Sema/TreeTransform.h
@@ -7630,7 +7630,8 @@ 
TreeTransform::TransformCoroutineBodyStmt(CoroutineBodyStmt *S) {
 return StmtError();
   StmtResult FinalSuspend =
   getDerived().TransformStmt(S->getFinalSuspendStmt());
-  if (FinalSuspend.isInvalid())
+  if (FinalSuspend.isInvalid() ||
+  !SemaRef.checkFinalSuspendNoThrow(FinalSuspend.get()))
 return StmtError();
   ScopeInfo->setCoroutineSuspends(InitSuspend.get(), FinalSuspend.get());
   assert(isa(InitSuspend.get()) && isa(FinalSuspend.get()));

diff  --git a/clang/test/SemaCXX/coroutine-final-suspend-noexcept.cpp 

[clang] 636d31a - [X86] Don't imply -mprfchw when -m3dnow is specified. Enable prefetchw in the backend with 3dnow feature.

2020-06-25 Thread Craig Topper via cfe-commits

Author: Craig Topper
Date: 2020-06-25T11:25:35-07:00
New Revision: 636d31a5c341ff2ca5eefd6075ff059eb60b5a80

URL: 
https://github.com/llvm/llvm-project/commit/636d31a5c341ff2ca5eefd6075ff059eb60b5a80
DIFF: 
https://github.com/llvm/llvm-project/commit/636d31a5c341ff2ca5eefd6075ff059eb60b5a80.diff

LOG: [X86] Don't imply -mprfchw when -m3dnow is specified. Enable prefetchw in 
the backend with 3dnow feature.

The PREFETCHW instruction was originally part of the 3DNow. But
it was given its own CPUID bit on later CPUs just before 3DNow
was deprecated.

We were setting the -mprfchw flag if -m3dnow was passed or the CPU
supported 3dnow unless -mno-prfchw was passed. But -march=native
on a CPU without the PRFCHW CPUID bit set will pass -mno-prfchw.
So -march=k8 will behave differently than -march=native on a K8
for example.

So remove this implicit setting from the frontend and instead
enable the backend to use PREFETCHW if 3dnow OR prfchw is enabled.

Also enable PRFCHW flag on amdfam10/barcelona which seems to be
where this CPUID bit was introduced. That CPU also supported
3dnow.

Added: 


Modified: 
clang/lib/Basic/Targets/X86.cpp
clang/test/Preprocessor/predefined-arch-macros.c
llvm/lib/Target/X86/X86.td
llvm/lib/Target/X86/X86InstrInfo.td
llvm/lib/Target/X86/X86Subtarget.h
llvm/test/CodeGen/X86/prefetch.ll

Removed: 




diff  --git a/clang/lib/Basic/Targets/X86.cpp b/clang/lib/Basic/Targets/X86.cpp
index fcf690847078..cc37c8a5cba0 100644
--- a/clang/lib/Basic/Targets/X86.cpp
+++ b/clang/lib/Basic/Targets/X86.cpp
@@ -335,6 +335,7 @@ bool X86TargetInfo::initFeatureMap(
 setFeatureEnabledImpl(Features, "lzcnt", true);
 setFeatureEnabledImpl(Features, "popcnt", true);
 setFeatureEnabledImpl(Features, "sahf", true);
+setFeatureEnabledImpl(Features, "prfchw", true);
 LLVM_FALLTHROUGH;
   case CK_K8SSE3:
 setFeatureEnabledImpl(Features, "sse3", true);
@@ -450,12 +451,6 @@ bool X86TargetInfo::initFeatureMap(
   llvm::find(FeaturesVec, "-popcnt") == FeaturesVec.end())
 Features["popcnt"] = true;
 
-  // Enable prfchw if 3DNow! is enabled and prfchw is not explicitly disabled.
-  I = Features.find("3dnow");
-  if (I != Features.end() && I->getValue() &&
-  llvm::find(FeaturesVec, "-prfchw") == FeaturesVec.end())
-Features["prfchw"] = true;
-
   // Additionally, if SSE is enabled and mmx is not explicitly disabled,
   // then enable MMX.
   I = Features.find("sse");

diff  --git a/clang/test/Preprocessor/predefined-arch-macros.c 
b/clang/test/Preprocessor/predefined-arch-macros.c
index f7de81028327..4e1535c91c08 100644
--- a/clang/test/Preprocessor/predefined-arch-macros.c
+++ b/clang/test/Preprocessor/predefined-arch-macros.c
@@ -2379,6 +2379,7 @@
 // CHECK_AMDFAM10_M32: #define __LZCNT__ 1
 // CHECK_AMDFAM10_M32: #define __MMX__ 1
 // CHECK_AMDFAM10_M32: #define __POPCNT__ 1
+// CHECK_AMDFAM10_M32: #define __PRFCHW__ 1
 // CHECK_AMDFAM10_M32: #define __SSE2_MATH__ 1
 // CHECK_AMDFAM10_M32: #define __SSE2__ 1
 // CHECK_AMDFAM10_M32: #define __SSE3__ 1
@@ -2399,6 +2400,7 @@
 // CHECK_AMDFAM10_M64: #define __LZCNT__ 1
 // CHECK_AMDFAM10_M64: #define __MMX__ 1
 // CHECK_AMDFAM10_M64: #define __POPCNT__ 1
+// CHECK_AMDFAM10_M64: #define __PRFCHW__ 1
 // CHECK_AMDFAM10_M64: #define __SSE2_MATH__ 1
 // CHECK_AMDFAM10_M64: #define __SSE2__ 1
 // CHECK_AMDFAM10_M64: #define __SSE3__ 1

diff  --git a/llvm/lib/Target/X86/X86.td b/llvm/lib/Target/X86/X86.td
index bcbc1ae492b2..3e85d4ab2a4c 100644
--- a/llvm/lib/Target/X86/X86.td
+++ b/llvm/lib/Target/X86/X86.td
@@ -847,6 +847,7 @@ def ProcessorFeatures {
  FeatureFXSR,
  FeatureNOPL,
  FeatureCMPXCHG16B,
+ FeaturePRFCHW,
  FeatureLZCNT,
  FeaturePOPCNT,
  FeatureSlowSHLD,

diff  --git a/llvm/lib/Target/X86/X86InstrInfo.td 
b/llvm/lib/Target/X86/X86InstrInfo.td
index 262961af7c51..46ca1896e4e2 100644
--- a/llvm/lib/Target/X86/X86InstrInfo.td
+++ b/llvm/lib/Target/X86/X86InstrInfo.td
@@ -928,11 +928,10 @@ def HasRTM   : Predicate<"Subtarget->hasRTM()">;
 def HasADX   : Predicate<"Subtarget->hasADX()">;
 def HasSHA   : Predicate<"Subtarget->hasSHA()">;
 def HasSGX   : Predicate<"Subtarget->hasSGX()">;
-def HasPRFCHW: Predicate<"Subtarget->hasPRFCHW()">;
 def HasRDSEED: Predicate<"Subtarget->hasRDSEED()">;
 def HasSSEPrefetch : Predicate<"Subtarget->hasSSEPrefetch()">;
 def NoSSEPrefetch : Predicate<"!Subtarget->hasSSEPrefetch()">;
-def HasPrefetchW : Predicate<"Subtarget->hasPRFCHW()">;
+def HasPrefetchW : 

[PATCH] D82415: [Coroutines] Special handle __builtin_coro_resume for final_suspend nothrow check

2020-06-25 Thread Xun Li via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
lxfind marked an inline comment as done.
Closed by commit rG366159566df3: [Coroutines] Special handle 
__builtin_coro_resume for final_suspend nothrow… (authored by lxfind).

Changed prior to commit:
  https://reviews.llvm.org/D82415?vs=272910=273466#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82415/new/

https://reviews.llvm.org/D82415

Files:
  clang/lib/Sema/SemaCoroutine.cpp


Index: clang/lib/Sema/SemaCoroutine.cpp
===
--- clang/lib/Sema/SemaCoroutine.cpp
+++ clang/lib/Sema/SemaCoroutine.cpp
@@ -614,6 +614,17 @@
 // In the case of dtor, the call to dtor is implicit and hence we should
 // pass nullptr to canCalleeThrow.
 if (Sema::canCalleeThrow(S, IsDtor ? nullptr : cast(E), D)) {
+  if (const auto *FD = dyn_cast(D)) {
+// co_await promise.final_suspend() could end up calling
+// __builtin_coro_resume for symmetric transfer if await_suspend()
+// returns a handle. In that case, even __builtin_coro_resume is not
+// declared as noexcept and may throw, it does not throw _into_ the
+// coroutine that just suspended, but rather throws back out from
+// whoever called coroutine_handle::resume(), hence we claim that
+// logically it does not throw.
+if (FD->getBuiltinID() == Builtin::BI__builtin_coro_resume)
+  return;
+  }
   if (ThrowingDecls.empty()) {
 // First time seeing an error, emit the error message.
 S.Diag(cast(S.CurContext)->getLocation(),


Index: clang/lib/Sema/SemaCoroutine.cpp
===
--- clang/lib/Sema/SemaCoroutine.cpp
+++ clang/lib/Sema/SemaCoroutine.cpp
@@ -614,6 +614,17 @@
 // In the case of dtor, the call to dtor is implicit and hence we should
 // pass nullptr to canCalleeThrow.
 if (Sema::canCalleeThrow(S, IsDtor ? nullptr : cast(E), D)) {
+  if (const auto *FD = dyn_cast(D)) {
+// co_await promise.final_suspend() could end up calling
+// __builtin_coro_resume for symmetric transfer if await_suspend()
+// returns a handle. In that case, even __builtin_coro_resume is not
+// declared as noexcept and may throw, it does not throw _into_ the
+// coroutine that just suspended, but rather throws back out from
+// whoever called coroutine_handle::resume(), hence we claim that
+// logically it does not throw.
+if (FD->getBuiltinID() == Builtin::BI__builtin_coro_resume)
+  return;
+  }
   if (ThrowingDecls.empty()) {
 // First time seeing an error, emit the error message.
 S.Diag(cast(S.CurContext)->getLocation(),
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D82306: [Sema][CodeComplete][ObjC] Don't split the first selector fragment

2020-06-25 Thread David Goldman via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc61ef1f25c7f: [Sema][CodeComplete][ObjC] Dont split 
the first selector fragment (authored by dgoldman).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82306/new/

https://reviews.llvm.org/D82306

Files:
  clang/lib/Sema/SemaCodeComplete.cpp
  clang/test/Index/complete-method-decls.m
  clang/test/Index/complete-parameterized-classes.m

Index: clang/test/Index/complete-parameterized-classes.m
===
--- clang/test/Index/complete-parameterized-classes.m
+++ clang/test/Index/complete-parameterized-classes.m
@@ -65,9 +65,9 @@
 // CHECK-CC5: ObjCIvarDecl:{ResultType __kindof NSObject *}{TypedText myVar} (35)
 
 // RUN: c-index-test -code-completion-at=%s:37:2 %s | FileCheck -check-prefix=CHECK-CC6 %s
-// CHECK-CC6: ObjCInstanceMethodDecl:{LeftParen (}{Text void}{RightParen )}{TypedText apply2}{TypedText :}{LeftParen (}{Text void (^)(id, NSObject *)}{RightParen )}{Text block} (40)
-// CHECK-CC6: ObjCInstanceMethodDecl:{LeftParen (}{Text void}{RightParen )}{TypedText apply}{TypedText :}{LeftParen (}{Text void (^)(id, NSObject *)}{RightParen )}{Text block} (40)
-// CHECK-CC6: ObjCInstanceMethodDecl:{LeftParen (}{Text NSObject *}{RightParen )}{TypedText getit}{TypedText :}{LeftParen (}{Text id}{RightParen )}{Text val} (40)
+// CHECK-CC6: ObjCInstanceMethodDecl:{LeftParen (}{Text void}{RightParen )}{TypedText apply2:}{LeftParen (}{Text void (^)(id, NSObject *)}{RightParen )}{Text block} (40)
+// CHECK-CC6: ObjCInstanceMethodDecl:{LeftParen (}{Text void}{RightParen )}{TypedText apply:}{LeftParen (}{Text void (^)(id, NSObject *)}{RightParen )}{Text block} (40)
+// CHECK-CC6: ObjCInstanceMethodDecl:{LeftParen (}{Text NSObject *}{RightParen )}{TypedText getit:}{LeftParen (}{Text id}{RightParen )}{Text val} (40)
 // CHECK-CC6: ObjCInstanceMethodDecl:{LeftParen (}{Text id}{RightParen )}{TypedText prop} (40)
 
 // RUN: c-index-test -code-completion-at=%s:41:8 %s | FileCheck -check-prefix=CHECK-CC7 %s
Index: clang/test/Index/complete-method-decls.m
===
--- clang/test/Index/complete-method-decls.m
+++ clang/test/Index/complete-method-decls.m
@@ -111,40 +111,40 @@
 // CHECK-CC1: ObjCInstanceMethodDecl:{LeftParen (}{Text id}{RightParen )}{TypedText abc} (40)
 // CHECK-CC1: ObjCInstanceMethodDecl:{LeftParen (}{Text int}{RightParen )}{TypedText getInt} (40)
 // CHECK-CC1: ObjCInstanceMethodDecl:{LeftParen (}{Text id}{RightParen )}{TypedText getSelf} (40)
-// CHECK-CC1: ObjCInstanceMethodDecl:{LeftParen (}{Text id}{RightParen )}{TypedText initWithInt}{TypedText :}{LeftParen (}{Text int}{RightParen )}{Text x} (40)
-// CHECK-CC1: ObjCInstanceMethodDecl:{LeftParen (}{Text id}{RightParen )}{TypedText initWithTwoInts}{TypedText :}{LeftParen (}{Text inout }{Text int}{RightParen )}{Text x}{HorizontalSpace  }{TypedText second:}{LeftParen (}{Text int}{RightParen )}{Text y} (40)
+// CHECK-CC1: ObjCInstanceMethodDecl:{LeftParen (}{Text id}{RightParen )}{TypedText initWithInt:}{LeftParen (}{Text int}{RightParen )}{Text x} (40)
+// CHECK-CC1: ObjCInstanceMethodDecl:{LeftParen (}{Text id}{RightParen )}{TypedText initWithTwoInts:}{LeftParen (}{Text inout }{Text int}{RightParen )}{Text x}{HorizontalSpace  }{TypedText second:}{LeftParen (}{Text int}{RightParen )}{Text y} (40)
 // RUN: c-index-test -code-completion-at=%s:17:7 %s | FileCheck -check-prefix=CHECK-CC2 %s
 // CHECK-CC2: ObjCInstanceMethodDecl:{TypedText abc}
 // CHECK-CC2-NEXT: ObjCInstanceMethodDecl:{TypedText getSelf}
-// CHECK-CC2: ObjCInstanceMethodDecl:{TypedText initWithInt}{TypedText :}{LeftParen (}{Text int}{RightParen )}{Text x}
-// CHECK-CC2: ObjCInstanceMethodDecl:{TypedText initWithTwoInts}{TypedText :}{LeftParen (}{Text inout }{Text int}{RightParen )}{Text x}{HorizontalSpace  }{TypedText second:}{LeftParen (}{Text int}{RightParen )}{Text y}
+// CHECK-CC2: ObjCInstanceMethodDecl:{TypedText initWithInt:}{LeftParen (}{Text int}{RightParen )}{Text x}
+// CHECK-CC2: ObjCInstanceMethodDecl:{TypedText initWithTwoInts:}{LeftParen (}{Text inout }{Text int}{RightParen )}{Text x}{HorizontalSpace  }{TypedText second:}{LeftParen (}{Text int}{RightParen )}{Text y}
 // RUN: c-index-test -code-completion-at=%s:24:7 %s | FileCheck -check-prefix=CHECK-CC3 %s
 // CHECK-CC3: ObjCInstanceMethodDecl:{TypedText abc}
 // CHECK-CC3-NEXT: ObjCInstanceMethodDecl:{TypedText getSelf}
 // CHECK-CC3: ObjCInstanceMethodDecl:{TypedText init}
-// CHECK-CC3: ObjCInstanceMethodDecl:{TypedText initWithInt}{TypedText :}{LeftParen (}{Text int}{RightParen )}{Text x}
-// CHECK-CC3: ObjCInstanceMethodDecl:{TypedText initWithTwoInts}{TypedText :}{LeftParen (}{Text inout }{Text int}{RightParen )}{Text x}{HorizontalSpace  }{TypedText second:}{LeftParen (}{Text int}{RightParen )}{Text y}
+// CHECK-CC3: ObjCInstanceMethodDecl:{TypedText 

  1   2   3   >