[PATCH] D57716: [CUDA][HIP] Check calling convention based on function target

2019-02-26 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: lib/Sema/SemaDeclAttr.cpp:4620
   const TargetInfo &TI = Context.getTargetInfo();
-  TargetInfo::CallingConvCheckResult A = TI.checkCallingConvention(CC);
+  auto *Aux = Context.getAuxTargetInfo();
+  if (LangOpts.CUDA) {

Please sink these declarations into the CUDA-specific block.  Also, please add 
some comments to explain why different logic is needed for CUDA.


Repository:
  rC Clang

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

https://reviews.llvm.org/D57716



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


[PATCH] D58147: [CodeGen] Fix calling llvm.var.annotation outside of a basic block.

2019-02-26 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a comment.
This revision is now accepted and ready to land.

Well, it won't have a guarantee that it won't see unused annotations, but 
alright, I'm fine with this.


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

https://reviews.llvm.org/D58147



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


[PATCH] D56411: [CUDA][HIP][Sema] Fix template kernel with function as template parameter

2019-02-26 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a comment.
This revision is now accepted and ready to land.

In D56411#1410598 , @yaxunl wrote:

> In D56411#1410153 , @rjmccall wrote:
>
> > In D56411#1406212 , @yaxunl wrote:
> >
> > > I would like to fix the validation issue only and leave the overload 
> > > resolution issue for future.
> >
> >
> > As I understand it, the "validation issue" is just that you'd like a 
> > diagnostic to be emitted when resolving the template argument in order to 
> > force SFINAE to pick a different template.  I think that's actually just 
> > the overload-resolution issue.
>
>
> Currently there are two host-ness related issues about function type template 
> arguments:
>
> 1. when there are two or more candidates for the template argument, clang 
> goes through host-ness based overloading resolution, which does not work 
> properly
> 2. when there is only one candidate for the template argument, clang does not 
> go through overloading resolution, therefore the first issue does not show 
> up. However, clang still checks host-ness of template argument. As discussed 
> before, clang should not check host-ness in non-evaluation or 
> constant-evaluation context. Instead, clang should check host-ness in 
> template instantiation.
>
>   I refer the first issue as host-ness overloading resolution issue and the 
> second issue as host-ness validation issue. They are related but separate.
>
>   The first issue only happens when host-ness based overloading resolution is 
> used. For applications which can be compiled with nvcc, this cannot happen, 
> therefore it is less common and less urgent.
>
>   The second issue can happen to applications which can be compiled with 
> nvcc, therefore is more imminent.
>
>   Fixing the second issue is relatively straightforward. It does not need to 
> introduce new AST types for host-ness. Also it is orthogonal to fixing the 
> first issue.


Okay, I understand now.  LGTM.


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

https://reviews.llvm.org/D56411



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


[PATCH] D58514: Avoid needlessly copying blocks that initialize or are assigned to local auto variables to the heap

2019-02-26 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a comment.
This revision is now accepted and ready to land.

Thanks, LGTM.


Repository:
  rC Clang

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

https://reviews.llvm.org/D58514



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


[PATCH] D56900: [Fixed Point Arithmetic] Fixed Point and Integer Conversions

2019-02-26 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

A couple tweaks, but otherwise LGTM.




Comment at: clang/include/clang/AST/OperationKinds.def:203
 
+/// CK_FixedPointToIntegral - Fixed point to an integral.
+///(int) 2.0k

This is super-picky, but please either just say "integral" (without an article) 
or spell out "an integral type".



Comment at: clang/include/clang/Basic/FixedPoint.h:157
+  /// to be fully stored in the provided width and sign, the overflow parameter
+  /// is set to true.
+  llvm::APSInt convertToInt(unsigned DstWidth, bool DstSign,

Please specify what happens to the overflow flag if there's a fractional 
component.


Repository:
  rC Clang

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

https://reviews.llvm.org/D56900



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


[PATCH] D58537: lib/Header: Simplify CMakeLists.txt

2019-02-26 Thread Tom Stellard via Phabricator via cfe-commits
tstellar added a comment.

In D58537#1411657 , @tstellar wrote:

> Use macros instead of functions.


I mean "Use functions instead of macros."


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D58537



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


[PATCH] D58537: lib/Header: Simplify CMakeLists.txt

2019-02-26 Thread Tom Stellard via Phabricator via cfe-commits
tstellar updated this revision to Diff 188500.
tstellar added a comment.

Use macros instead of functions.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D58537

Files:
  clang/lib/Headers/CMakeLists.txt


Index: clang/lib/Headers/CMakeLists.txt
===
--- clang/lib/Headers/CMakeLists.txt
+++ clang/lib/Headers/CMakeLists.txt
@@ -123,60 +123,53 @@
 )
 
 set(output_dir ${LLVM_LIBRARY_OUTPUT_INTDIR}/clang/${CLANG_VERSION}/include)
-
-# Generate arm_neon.h
-clang_tablegen(arm_neon.h -gen-arm-neon
-  -I ${CLANG_SOURCE_DIR}/include/clang/Basic/
-  SOURCE ${CLANG_SOURCE_DIR}/include/clang/Basic/arm_neon.td)
-# Generate arm_fp16.h
-clang_tablegen(arm_fp16.h -gen-arm-fp16
-  -I ${CLANG_SOURCE_DIR}/include/clang/Basic/
-  SOURCE ${CLANG_SOURCE_DIR}/include/clang/Basic/arm_fp16.td)
-
 set(out_files)
-foreach( f ${files} ${cuda_wrapper_files} )
-  set( src ${CMAKE_CURRENT_SOURCE_DIR}/${f} )
-  set( dst ${output_dir}/${f} )
+
+function(copy_header_to_output_dir src_dir file)
+  set(src ${src_dir}/${file})
+  set(dst ${output_dir}/${file})
   add_custom_command(OUTPUT ${dst}
 DEPENDS ${src}
 COMMAND ${CMAKE_COMMAND} -E copy_if_different ${src} ${dst}
-COMMENT "Copying clang's ${f}...")
+COMMENT "Copying clang's ${file}...")
   list(APPEND out_files ${dst})
+  # The list function only updates out_files in the current scope.  We need
+  # call set in order to also update the variable for the parent's scope.
+  # The parent in this case is the caller of the function.
+  set(out_files ${out_files} PARENT_SCOPE)
+endfunction(copy_header_to_output_dir)
+
+function(clang_generate_header td_option td_file file_list)
+  clang_tablegen(${out_file} ${td_option}
+  -I ${CLANG_SOURCE_DIR}/include/clang/Basic/
+  SOURCE ${CLANG_SOURCE_DIR}/include/clang/Basic/${td_file})
+
+  copy_header_to_output_dir(${CMAKE_CURRENT_BINARY_DIR} out_file file_list)
+endfunction(clang_generate_header)
+
+
+# Copy header files from the source directory to the build directory
+foreach( f ${files} ${cuda_wrapper_files} )
+  copy_header_to_output_dir(${CMAKE_CURRENT_SOURCE_DIR} ${f})
 endforeach( f )
 
-add_custom_command(OUTPUT ${output_dir}/arm_neon.h
-  DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/arm_neon.h
-  COMMAND ${CMAKE_COMMAND} -E copy_if_different 
${CMAKE_CURRENT_BINARY_DIR}/arm_neon.h ${output_dir}/arm_neon.h
-  COMMENT "Copying clang's arm_neon.h...")
-list(APPEND out_files ${output_dir}/arm_neon.h)
-add_custom_command(OUTPUT ${output_dir}/arm_fp16.h
-  DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/arm_fp16.h
-  COMMAND ${CMAKE_COMMAND} -E copy_if_different 
${CMAKE_CURRENT_BINARY_DIR}/arm_fp16.h ${output_dir}/arm_fp16.h
-  COMMENT "Copying clang's arm_fp16.h...")
-list(APPEND out_files ${output_dir}/arm_fp16.h)
+# Generate header files and copy them to the build directory
+# Generate arm_neon.h
+clang_generate_header(-gen-arm-neon arm_neon.td arm_neon.h)
+# Generate arm_fp16.h
+clang_generate_header(-gen-arm-fp16 arm_fp16.td arm_fp16.h)
 
 add_custom_target(clang-headers ALL DEPENDS ${out_files})
 set_target_properties(clang-headers PROPERTIES
   FOLDER "Misc"
   RUNTIME_OUTPUT_DIRECTORY "${output_dir}")
 
-install(
-  FILES ${files} ${CMAKE_CURRENT_BINARY_DIR}/arm_neon.h
-  COMPONENT clang-headers
-  PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
-  DESTINATION lib${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION}/include)
-
-install(
-  FILES ${files} ${CMAKE_CURRENT_BINARY_DIR}/arm_fp16.h
-  COMPONENT clang-headers
-  PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
-  DESTINATION lib${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION}/include)
+set(header_install_dir lib${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION})
 
 install(
-  FILES ${cuda_wrapper_files}
-  COMPONENT clang-headers
-  PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
-  DESTINATION 
lib${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION}/include/cuda_wrappers)
+  DIRECTORY ${output_dir}
+  DESTINATION ${header_install_dir}
+  COMPONENT clang-headers)
 
 if (NOT LLVM_ENABLE_IDE)
   add_llvm_install_targets(install-clang-headers


Index: clang/lib/Headers/CMakeLists.txt
===
--- clang/lib/Headers/CMakeLists.txt
+++ clang/lib/Headers/CMakeLists.txt
@@ -123,60 +123,53 @@
 )
 
 set(output_dir ${LLVM_LIBRARY_OUTPUT_INTDIR}/clang/${CLANG_VERSION}/include)
-
-# Generate arm_neon.h
-clang_tablegen(arm_neon.h -gen-arm-neon
-  -I ${CLANG_SOURCE_DIR}/include/clang/Basic/
-  SOURCE ${CLANG_SOURCE_DIR}/include/clang/Basic/arm_neon.td)
-# Generate arm_fp16.h
-clang_tablegen(arm_fp16.h -gen-arm-fp16
-  -I ${CLANG_SOURCE_DIR}/include/clang/Basic/
-  SOURCE ${CLANG_SOURCE_DIR}/include/clang/Basic/arm_fp16.td)
-
 set(out_files)
-foreach( f ${files} ${cuda_wrapper_files} )
-  set( src ${CMAKE_CURRENT_SOURCE_DIR}/${f} )
-  set( dst ${output_dir}/${f} )
+
+function(copy_header_to_out

[PATCH] D58089: Add missing library dependencies in CMakeLists.txt

2019-02-26 Thread Jan Korous via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rCTE354949: [clangd] Library dependencies in XPC (authored by 
jkorous, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D58089?vs=186369&id=188494#toc

Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D58089

Files:
  clangd/xpc/CMakeLists.txt


Index: clangd/xpc/CMakeLists.txt
===
--- clangd/xpc/CMakeLists.txt
+++ clangd/xpc/CMakeLists.txt
@@ -20,10 +20,10 @@
 
 add_clang_library(clangdXpcJsonConversions
   Conversion.cpp
+  LINK_LIBS clangDaemon
   )
 
 add_clang_library(clangdXpcTransport
   XPCTransport.cpp
-  DEPENDS clangdXpcJsonConversions
-  LINK_LIBS clangdXpcJsonConversions
+  LINK_LIBS clangDaemon clangdXpcJsonConversions
   )


Index: clangd/xpc/CMakeLists.txt
===
--- clangd/xpc/CMakeLists.txt
+++ clangd/xpc/CMakeLists.txt
@@ -20,10 +20,10 @@
 
 add_clang_library(clangdXpcJsonConversions
   Conversion.cpp
+  LINK_LIBS clangDaemon
   )
 
 add_clang_library(clangdXpcTransport
   XPCTransport.cpp
-  DEPENDS clangdXpcJsonConversions
-  LINK_LIBS clangdXpcJsonConversions
+  LINK_LIBS clangDaemon clangdXpcJsonConversions
   )
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r354949 - [clangd] Library dependencies in XPC

2019-02-26 Thread Jan Korous via cfe-commits
Author: jkorous
Date: Tue Feb 26 18:37:44 2019
New Revision: 354949

URL: http://llvm.org/viewvc/llvm-project?rev=354949&view=rev
Log:
[clangd] Library dependencies in XPC

Patch by Nicholas Allegra

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

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

Modified: clang-tools-extra/trunk/clangd/xpc/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/xpc/CMakeLists.txt?rev=354949&r1=354948&r2=354949&view=diff
==
--- clang-tools-extra/trunk/clangd/xpc/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clangd/xpc/CMakeLists.txt Tue Feb 26 18:37:44 2019
@@ -20,10 +20,10 @@ set(LLVM_OPTIONAL_SOURCES Conversion.cpp
 
 add_clang_library(clangdXpcJsonConversions
   Conversion.cpp
+  LINK_LIBS clangDaemon
   )
 
 add_clang_library(clangdXpcTransport
   XPCTransport.cpp
-  DEPENDS clangdXpcJsonConversions
-  LINK_LIBS clangdXpcJsonConversions
+  LINK_LIBS clangDaemon clangdXpcJsonConversions
   )


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


[PATCH] D58089: Add missing library dependencies in CMakeLists.txt

2019-02-26 Thread Jan Korous via Phabricator via cfe-commits
jkorous accepted this revision.
jkorous added a comment.
This revision is now accepted and ready to land.

Reconsidered - let's fix the build first and I can finish my patch tomorrow.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D58089



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


[PATCH] D58089: Add missing library dependencies in CMakeLists.txt

2019-02-26 Thread Jan Korous via Phabricator via cfe-commits
jkorous requested changes to this revision.
jkorous added a comment.
This revision now requires changes to proceed.

Hi @comex, I totally missed this! Thanks for the patch.
I am not entirely happy about this dependency though. I am trying to split off 
the only parts of clangDaemon that XpcTransport actually uses.
I'll either put up my patch for review tomorrow or commit your solution.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D58089



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


[PATCH] D58518: [HIP] change kernel stub name

2019-02-26 Thread Yaxun Liu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL354948: [HIP] change kernel stub name (authored by yaxunl, 
committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D58518?vs=187980&id=188490#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D58518

Files:
  cfe/trunk/lib/CodeGen/CGCUDANV.cpp
  cfe/trunk/lib/CodeGen/CodeGenModule.cpp
  cfe/trunk/test/CodeGenCUDA/kernel-stub-name.cu


Index: cfe/trunk/test/CodeGenCUDA/kernel-stub-name.cu
===
--- cfe/trunk/test/CodeGenCUDA/kernel-stub-name.cu
+++ cfe/trunk/test/CodeGenCUDA/kernel-stub-name.cu
@@ -0,0 +1,20 @@
+// RUN: echo "GPU binary would be here" > %t
+
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s \
+// RUN: -fcuda-include-gpubinary %t -o - -x hip\
+// RUN:   | FileCheck -allow-deprecated-dag-overlap %s --check-prefixes=CHECK
+
+#include "Inputs/cuda.h"
+
+template
+__global__ void kernelfunc() {}
+
+// CHECK-LABEL: define{{.*}}@_Z8hostfuncv()
+// CHECK: call void @[[STUB:_Z10kernelfuncIiEvv.stub]]()
+void hostfunc(void) { kernelfunc<<<1, 1>>>(); }
+
+// CHECK: define{{.*}}@[[STUB]]
+// CHECK: call{{.*}}@hipLaunchByPtr{{.*}}@[[STUB]]
+
+// CHECK-LABEL: define{{.*}}@__hip_register_globals
+// CHECK: call{{.*}}@__hipRegisterFunction{{.*}}@[[STUB]]
Index: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
===
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp
@@ -1048,8 +1048,17 @@
 
   // Keep the first result in the case of a mangling collision.
   const auto *ND = cast(GD.getDecl());
-  auto Result =
-  Manglings.insert(std::make_pair(getMangledNameImpl(*this, GD, ND), GD));
+  std::string MangledName = getMangledNameImpl(*this, GD, ND);
+
+  // Postfix kernel stub names with .stub to differentiate them from kernel
+  // names in device binaries. This is to facilitate the debugger to find
+  // the correct symbols for kernels in the device binary.
+  if (auto *FD = dyn_cast(GD.getDecl()))
+if (getLangOpts().HIP && !getLangOpts().CUDAIsDevice &&
+FD->hasAttr())
+  MangledName = MangledName + ".stub";
+
+  auto Result = Manglings.insert(std::make_pair(MangledName, GD));
   return MangledDeclNames[CanonicalGD] = Result.first->first();
 }
 
Index: cfe/trunk/lib/CodeGen/CGCUDANV.cpp
===
--- cfe/trunk/lib/CodeGen/CGCUDANV.cpp
+++ cfe/trunk/lib/CodeGen/CGCUDANV.cpp
@@ -218,6 +218,7 @@
 void CGNVCUDARuntime::emitDeviceStub(CodeGenFunction &CGF,
  FunctionArgList &Args) {
   assert(getDeviceSideName(CGF.CurFuncDecl) == CGF.CurFn->getName() ||
+ getDeviceSideName(CGF.CurFuncDecl) + ".stub" == CGF.CurFn->getName() 
||
  CGF.CGM.getContext().getTargetInfo().getCXXABI() !=
  CGF.CGM.getContext().getAuxTargetInfo()->getCXXABI());
 


Index: cfe/trunk/test/CodeGenCUDA/kernel-stub-name.cu
===
--- cfe/trunk/test/CodeGenCUDA/kernel-stub-name.cu
+++ cfe/trunk/test/CodeGenCUDA/kernel-stub-name.cu
@@ -0,0 +1,20 @@
+// RUN: echo "GPU binary would be here" > %t
+
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s \
+// RUN: -fcuda-include-gpubinary %t -o - -x hip\
+// RUN:   | FileCheck -allow-deprecated-dag-overlap %s --check-prefixes=CHECK
+
+#include "Inputs/cuda.h"
+
+template
+__global__ void kernelfunc() {}
+
+// CHECK-LABEL: define{{.*}}@_Z8hostfuncv()
+// CHECK: call void @[[STUB:_Z10kernelfuncIiEvv.stub]]()
+void hostfunc(void) { kernelfunc<<<1, 1>>>(); }
+
+// CHECK: define{{.*}}@[[STUB]]
+// CHECK: call{{.*}}@hipLaunchByPtr{{.*}}@[[STUB]]
+
+// CHECK-LABEL: define{{.*}}@__hip_register_globals
+// CHECK: call{{.*}}@__hipRegisterFunction{{.*}}@[[STUB]]
Index: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
===
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp
@@ -1048,8 +1048,17 @@
 
   // Keep the first result in the case of a mangling collision.
   const auto *ND = cast(GD.getDecl());
-  auto Result =
-  Manglings.insert(std::make_pair(getMangledNameImpl(*this, GD, ND), GD));
+  std::string MangledName = getMangledNameImpl(*this, GD, ND);
+
+  // Postfix kernel stub names with .stub to differentiate them from kernel
+  // names in device binaries. This is to facilitate the debugger to find
+  // the correct symbols for kernels in the device binary.
+  if (auto *FD = dyn_cast(GD.getDecl()))
+if (getLangOpts().HIP && !getLangOpts().CUDAIsDevice &&
+FD->hasAttr())
+  MangledName = MangledName + ".stub";
+
+  auto Result = Manglings.insert(std::make_pair(MangledName, GD));
   r

r354948 - [HIP] change kernel stub name

2019-02-26 Thread Yaxun Liu via cfe-commits
Author: yaxunl
Date: Tue Feb 26 18:02:52 2019
New Revision: 354948

URL: http://llvm.org/viewvc/llvm-project?rev=354948&view=rev
Log:
[HIP] change kernel stub name

Add .stub to kernel stub function name so that it is different from kernel
name in device code. This is necessary to let debugger find correct symbol
for kernel.

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

Added:
cfe/trunk/test/CodeGenCUDA/kernel-stub-name.cu
Modified:
cfe/trunk/lib/CodeGen/CGCUDANV.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.cpp

Modified: cfe/trunk/lib/CodeGen/CGCUDANV.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCUDANV.cpp?rev=354948&r1=354947&r2=354948&view=diff
==
--- cfe/trunk/lib/CodeGen/CGCUDANV.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCUDANV.cpp Tue Feb 26 18:02:52 2019
@@ -218,6 +218,7 @@ std::string CGNVCUDARuntime::getDeviceSi
 void CGNVCUDARuntime::emitDeviceStub(CodeGenFunction &CGF,
  FunctionArgList &Args) {
   assert(getDeviceSideName(CGF.CurFuncDecl) == CGF.CurFn->getName() ||
+ getDeviceSideName(CGF.CurFuncDecl) + ".stub" == CGF.CurFn->getName() 
||
  CGF.CGM.getContext().getTargetInfo().getCXXABI() !=
  CGF.CGM.getContext().getAuxTargetInfo()->getCXXABI());
 

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=354948&r1=354947&r2=354948&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Tue Feb 26 18:02:52 2019
@@ -1048,8 +1048,17 @@ StringRef CodeGenModule::getMangledName(
 
   // Keep the first result in the case of a mangling collision.
   const auto *ND = cast(GD.getDecl());
-  auto Result =
-  Manglings.insert(std::make_pair(getMangledNameImpl(*this, GD, ND), GD));
+  std::string MangledName = getMangledNameImpl(*this, GD, ND);
+
+  // Postfix kernel stub names with .stub to differentiate them from kernel
+  // names in device binaries. This is to facilitate the debugger to find
+  // the correct symbols for kernels in the device binary.
+  if (auto *FD = dyn_cast(GD.getDecl()))
+if (getLangOpts().HIP && !getLangOpts().CUDAIsDevice &&
+FD->hasAttr())
+  MangledName = MangledName + ".stub";
+
+  auto Result = Manglings.insert(std::make_pair(MangledName, GD));
   return MangledDeclNames[CanonicalGD] = Result.first->first();
 }
 

Added: cfe/trunk/test/CodeGenCUDA/kernel-stub-name.cu
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCUDA/kernel-stub-name.cu?rev=354948&view=auto
==
--- cfe/trunk/test/CodeGenCUDA/kernel-stub-name.cu (added)
+++ cfe/trunk/test/CodeGenCUDA/kernel-stub-name.cu Tue Feb 26 18:02:52 2019
@@ -0,0 +1,20 @@
+// RUN: echo "GPU binary would be here" > %t
+
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s \
+// RUN: -fcuda-include-gpubinary %t -o - -x hip\
+// RUN:   | FileCheck -allow-deprecated-dag-overlap %s --check-prefixes=CHECK
+
+#include "Inputs/cuda.h"
+
+template
+__global__ void kernelfunc() {}
+
+// CHECK-LABEL: define{{.*}}@_Z8hostfuncv()
+// CHECK: call void @[[STUB:_Z10kernelfuncIiEvv.stub]]()
+void hostfunc(void) { kernelfunc<<<1, 1>>>(); }
+
+// CHECK: define{{.*}}@[[STUB]]
+// CHECK: call{{.*}}@hipLaunchByPtr{{.*}}@[[STUB]]
+
+// CHECK-LABEL: define{{.*}}@__hip_register_globals
+// CHECK: call{{.*}}@__hipRegisterFunction{{.*}}@[[STUB]]


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


r354946 - [index] Fixup for r354942. Specify target in test to achieve stable mangling.

2019-02-26 Thread Volodymyr Sapsai via cfe-commits
Author: vsapsai
Date: Tue Feb 26 17:37:43 2019
New Revision: 354946

URL: http://llvm.org/viewvc/llvm-project?rev=354946&view=rev
Log:
[index] Fixup for r354942. Specify target in test to achieve stable mangling.

Modified:
cfe/trunk/test/Index/ms-property.cpp

Modified: cfe/trunk/test/Index/ms-property.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/ms-property.cpp?rev=354946&r1=354945&r2=354946&view=diff
==
--- cfe/trunk/test/Index/ms-property.cpp (original)
+++ cfe/trunk/test/Index/ms-property.cpp Tue Feb 26 17:37:43 2019
@@ -1,4 +1,4 @@
-// RUN: c-index-test core -print-source-symbols -- -fms-extensions 
-fno-ms-compatibility %s | FileCheck %s
+// RUN: c-index-test core -print-source-symbols -- -target 
x86_64-apple-darwin10 -fms-extensions -fno-ms-compatibility %s | FileCheck %s
 
 // CHECK: [[@LINE+1]]:8 | struct/C++ | Simple | [[Simple_USR:.*]] | 
 | Def | rel: 0
 struct Simple {


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


[PATCH] D57628: [index] Improve indexing support for MSPropertyDecl.

2019-02-26 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai added a comment.

Thanks for reviewing the change!


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

https://reviews.llvm.org/D57628



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


[PATCH] D57628: [index] Improve indexing support for MSPropertyDecl.

2019-02-26 Thread Volodymyr Sapsai via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL354942: [index] Improve indexing support for MSPropertyDecl. 
(authored by vsapsai, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D57628?vs=184860&id=188482#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D57628

Files:
  cfe/trunk/lib/Index/IndexDecl.cpp
  cfe/trunk/lib/Index/IndexSymbol.cpp
  cfe/trunk/test/Index/ms-property.cpp


Index: cfe/trunk/test/Index/ms-property.cpp
===
--- cfe/trunk/test/Index/ms-property.cpp
+++ cfe/trunk/test/Index/ms-property.cpp
@@ -0,0 +1,32 @@
+// RUN: c-index-test core -print-source-symbols -- -fms-extensions 
-fno-ms-compatibility %s | FileCheck %s
+
+// CHECK: [[@LINE+1]]:8 | struct/C++ | Simple | [[Simple_USR:.*]] | 
 | Def | rel: 0
+struct Simple {
+  int GetX() const;
+  // CHECK: [[@LINE-1]]:7 | instance-method/C++ | GetX | [[GetX_USR:.*]] | 
__ZNK6Simple4GetXEv | Decl,RelChild | rel: 1
+  // CHECK-NEXT: RelChild | Simple | [[Simple_USR]]
+
+  void PutX(int i);
+  // CHECK: [[@LINE-1]]:8 | instance-method/C++ | PutX | [[PutX_USR:.*]] | 
__ZN6Simple4PutXEi | Decl,RelChild | rel: 1
+  // CHECK-NEXT: RelChild | Simple | [[Simple_USR]]
+
+  __declspec(property(get=GetX, put=PutX)) int propX;
+  // CHECK: [[@LINE-1]]:48 | instance-property/C++ | propX | [[propX_USR:.*]] 
|  | Def,RelChild | rel: 1
+  // CHECK-NEXT: RelChild | Simple | [[Simple_USR]]
+};
+
+// CHECK: [[@LINE+1]]:5 | function/C | test | [[test_USR:.*]] | __Z4testv | 
Def | rel: 0
+int test() {
+  Simple s;
+  s.propX = 5;
+  // CHECK: [[@LINE-1]]:5 | instance-property/C++ | propX | [[propX_USR]] | 
 | Ref,RelCont | rel: 1
+  // CHECK-NEXT: RelCont | test | [[test_USR]]
+  // CHECK: [[@LINE-3]]:5 | instance-method/C++ | PutX | [[PutX_USR]] | 
__ZN6Simple4PutXEi | Ref,Call,RelCall,RelCont | rel: 1
+  // CHECK-NEXT: RelCall,RelCont | test | [[test_USR]]
+
+  return s.propX;
+  // CHECK: [[@LINE-1]]:12 | instance-property/C++ | propX | [[propX_USR]] | 
 | Ref,RelCont | rel: 1
+  // CHECK-NEXT: RelCont | test | [[test_USR]]
+  // CHECK: [[@LINE-3]]:12 | instance-method/C++ | GetX | [[GetX_USR]] | 
__ZNK6Simple4GetXEv | Ref,Call,RelCall,RelCont | rel: 1
+  // CHECK-NEXT: RelCall,RelCont | test | [[test_USR]]
+}
Index: cfe/trunk/lib/Index/IndexDecl.cpp
===
--- cfe/trunk/lib/Index/IndexDecl.cpp
+++ cfe/trunk/lib/Index/IndexDecl.cpp
@@ -324,6 +324,7 @@
   }
 
   bool VisitMSPropertyDecl(const MSPropertyDecl *D) {
+TRY_DECL(D, IndexCtx.handleDecl(D));
 handleDeclarator(D);
 return true;
   }
Index: cfe/trunk/lib/Index/IndexSymbol.cpp
===
--- cfe/trunk/lib/Index/IndexSymbol.cpp
+++ cfe/trunk/lib/Index/IndexSymbol.cpp
@@ -324,6 +324,14 @@
   Info.Kind = SymbolKind::Variable;
   Info.Lang = SymbolLanguage::CXX;
   break;
+case Decl::MSProperty:
+  Info.Kind = SymbolKind::InstanceProperty;
+  if (const CXXRecordDecl *CXXRec =
+  dyn_cast(D->getDeclContext())) {
+if (!CXXRec->isCLike())
+  Info.Lang = SymbolLanguage::CXX;
+  }
+  break;
 default:
   break;
 }


Index: cfe/trunk/test/Index/ms-property.cpp
===
--- cfe/trunk/test/Index/ms-property.cpp
+++ cfe/trunk/test/Index/ms-property.cpp
@@ -0,0 +1,32 @@
+// RUN: c-index-test core -print-source-symbols -- -fms-extensions -fno-ms-compatibility %s | FileCheck %s
+
+// CHECK: [[@LINE+1]]:8 | struct/C++ | Simple | [[Simple_USR:.*]] |  | Def | rel: 0
+struct Simple {
+  int GetX() const;
+  // CHECK: [[@LINE-1]]:7 | instance-method/C++ | GetX | [[GetX_USR:.*]] | __ZNK6Simple4GetXEv | Decl,RelChild | rel: 1
+  // CHECK-NEXT: RelChild | Simple | [[Simple_USR]]
+
+  void PutX(int i);
+  // CHECK: [[@LINE-1]]:8 | instance-method/C++ | PutX | [[PutX_USR:.*]] | __ZN6Simple4PutXEi | Decl,RelChild | rel: 1
+  // CHECK-NEXT: RelChild | Simple | [[Simple_USR]]
+
+  __declspec(property(get=GetX, put=PutX)) int propX;
+  // CHECK: [[@LINE-1]]:48 | instance-property/C++ | propX | [[propX_USR:.*]] |  | Def,RelChild | rel: 1
+  // CHECK-NEXT: RelChild | Simple | [[Simple_USR]]
+};
+
+// CHECK: [[@LINE+1]]:5 | function/C | test | [[test_USR:.*]] | __Z4testv | Def | rel: 0
+int test() {
+  Simple s;
+  s.propX = 5;
+  // CHECK: [[@LINE-1]]:5 | instance-property/C++ | propX | [[propX_USR]] |  | Ref,RelCont | rel: 1
+  // CHECK-NEXT: RelCont | test | [[test_USR]]
+  // CHECK: [[@LINE-3]]:5 | instance-method/C++ | PutX | [[PutX_USR]] | __ZN6Simple4PutXEi | Ref,Call,RelCall,RelCont | rel: 1
+  // CHECK-NEXT: RelCall,RelCont | test | [[test_USR]]
+
+  return s.propX;
+  // CHECK: [[@LINE-1]]:12 | instance-prop

r354942 - [index] Improve indexing support for MSPropertyDecl.

2019-02-26 Thread Volodymyr Sapsai via cfe-commits
Author: vsapsai
Date: Tue Feb 26 17:04:53 2019
New Revision: 354942

URL: http://llvm.org/viewvc/llvm-project?rev=354942&view=rev
Log:
[index] Improve indexing support for MSPropertyDecl.

Currently the symbol for MSPropertyDecl has kind `SymbolKind::Unknown`
which can trip up various indexing tools.

rdar://problem/46764224

Reviewers: akyrtzi, benlangmuir, jkorous

Reviewed By: jkorous

Subscribers: dexonsmith, cfe-commits, jkorous, jdoerfert, arphaman

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


Added:
cfe/trunk/test/Index/ms-property.cpp
Modified:
cfe/trunk/lib/Index/IndexDecl.cpp
cfe/trunk/lib/Index/IndexSymbol.cpp

Modified: cfe/trunk/lib/Index/IndexDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/IndexDecl.cpp?rev=354942&r1=354941&r2=354942&view=diff
==
--- cfe/trunk/lib/Index/IndexDecl.cpp (original)
+++ cfe/trunk/lib/Index/IndexDecl.cpp Tue Feb 26 17:04:53 2019
@@ -324,6 +324,7 @@ public:
   }
 
   bool VisitMSPropertyDecl(const MSPropertyDecl *D) {
+TRY_DECL(D, IndexCtx.handleDecl(D));
 handleDeclarator(D);
 return true;
   }

Modified: cfe/trunk/lib/Index/IndexSymbol.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/IndexSymbol.cpp?rev=354942&r1=354941&r2=354942&view=diff
==
--- cfe/trunk/lib/Index/IndexSymbol.cpp (original)
+++ cfe/trunk/lib/Index/IndexSymbol.cpp Tue Feb 26 17:04:53 2019
@@ -324,6 +324,14 @@ SymbolInfo index::getSymbolInfo(const De
   Info.Kind = SymbolKind::Variable;
   Info.Lang = SymbolLanguage::CXX;
   break;
+case Decl::MSProperty:
+  Info.Kind = SymbolKind::InstanceProperty;
+  if (const CXXRecordDecl *CXXRec =
+  dyn_cast(D->getDeclContext())) {
+if (!CXXRec->isCLike())
+  Info.Lang = SymbolLanguage::CXX;
+  }
+  break;
 default:
   break;
 }

Added: cfe/trunk/test/Index/ms-property.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/ms-property.cpp?rev=354942&view=auto
==
--- cfe/trunk/test/Index/ms-property.cpp (added)
+++ cfe/trunk/test/Index/ms-property.cpp Tue Feb 26 17:04:53 2019
@@ -0,0 +1,32 @@
+// RUN: c-index-test core -print-source-symbols -- -fms-extensions 
-fno-ms-compatibility %s | FileCheck %s
+
+// CHECK: [[@LINE+1]]:8 | struct/C++ | Simple | [[Simple_USR:.*]] | 
 | Def | rel: 0
+struct Simple {
+  int GetX() const;
+  // CHECK: [[@LINE-1]]:7 | instance-method/C++ | GetX | [[GetX_USR:.*]] | 
__ZNK6Simple4GetXEv | Decl,RelChild | rel: 1
+  // CHECK-NEXT: RelChild | Simple | [[Simple_USR]]
+
+  void PutX(int i);
+  // CHECK: [[@LINE-1]]:8 | instance-method/C++ | PutX | [[PutX_USR:.*]] | 
__ZN6Simple4PutXEi | Decl,RelChild | rel: 1
+  // CHECK-NEXT: RelChild | Simple | [[Simple_USR]]
+
+  __declspec(property(get=GetX, put=PutX)) int propX;
+  // CHECK: [[@LINE-1]]:48 | instance-property/C++ | propX | [[propX_USR:.*]] 
|  | Def,RelChild | rel: 1
+  // CHECK-NEXT: RelChild | Simple | [[Simple_USR]]
+};
+
+// CHECK: [[@LINE+1]]:5 | function/C | test | [[test_USR:.*]] | __Z4testv | 
Def | rel: 0
+int test() {
+  Simple s;
+  s.propX = 5;
+  // CHECK: [[@LINE-1]]:5 | instance-property/C++ | propX | [[propX_USR]] | 
 | Ref,RelCont | rel: 1
+  // CHECK-NEXT: RelCont | test | [[test_USR]]
+  // CHECK: [[@LINE-3]]:5 | instance-method/C++ | PutX | [[PutX_USR]] | 
__ZN6Simple4PutXEi | Ref,Call,RelCall,RelCont | rel: 1
+  // CHECK-NEXT: RelCall,RelCont | test | [[test_USR]]
+
+  return s.propX;
+  // CHECK: [[@LINE-1]]:12 | instance-property/C++ | propX | [[propX_USR]] | 
 | Ref,RelCont | rel: 1
+  // CHECK-NEXT: RelCont | test | [[test_USR]]
+  // CHECK: [[@LINE-3]]:12 | instance-method/C++ | GetX | [[GetX_USR]] | 
__ZNK6Simple4GetXEv | Ref,Call,RelCall,RelCont | rel: 1
+  // CHECK-NEXT: RelCall,RelCont | test | [[test_USR]]
+}


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


[PATCH] D58649: Fix inline assembler constraint validation

2019-02-26 Thread Joerg Sonnenberger via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL354937: Fix inline assembler constraint validation (authored 
by joerg, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D58649?vs=188265&id=188477#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D58649

Files:
  cfe/trunk/include/clang/Basic/TargetInfo.h
  cfe/trunk/test/Sema/inline-asm-validate-x86.c


Index: cfe/trunk/include/clang/Basic/TargetInfo.h
===
--- cfe/trunk/include/clang/Basic/TargetInfo.h
+++ cfe/trunk/include/clang/Basic/TargetInfo.h
@@ -816,6 +816,7 @@
 struct {
   int Min;
   int Max;
+  bool isConstrained;
 } ImmRange;
 llvm::SmallSet ImmSet;
 
@@ -826,6 +827,7 @@
 : Flags(0), TiedOperand(-1), ConstraintStr(ConstraintStr.str()),
   Name(Name.str()) {
   ImmRange.Min = ImmRange.Max = 0;
+  ImmRange.isConstrained = false;
 }
 
 const std::string &getConstraintStr() const { return ConstraintStr; }
@@ -854,8 +856,9 @@
   return (Flags & CI_ImmediateConstant) != 0;
 }
 bool isValidAsmImmediate(const llvm::APInt &Value) const {
-  return (Value.sge(ImmRange.Min) && Value.sle(ImmRange.Max)) ||
- ImmSet.count(Value.getZExtValue()) != 0;
+  if (!ImmSet.empty())
+return ImmSet.count(Value.getZExtValue()) != 0;
+  return !ImmRange.isConstrained || (Value.sge(ImmRange.Min) && 
Value.sle(ImmRange.Max));
 }
 
 void setIsReadWrite() { Flags |= CI_ReadWrite; }
@@ -867,6 +870,7 @@
   Flags |= CI_ImmediateConstant;
   ImmRange.Min = Min;
   ImmRange.Max = Max;
+  ImmRange.isConstrained = true;
 }
 void setRequiresImmediate(llvm::ArrayRef Exacts) {
   Flags |= CI_ImmediateConstant;
@@ -879,8 +883,6 @@
 }
 void setRequiresImmediate() {
   Flags |= CI_ImmediateConstant;
-  ImmRange.Min = INT_MIN;
-  ImmRange.Max = INT_MAX;
 }
 
 /// Indicate that this is an input operand that is tied to
Index: cfe/trunk/test/Sema/inline-asm-validate-x86.c
===
--- cfe/trunk/test/Sema/inline-asm-validate-x86.c
+++ cfe/trunk/test/Sema/inline-asm-validate-x86.c
@@ -55,6 +55,7 @@
 void L(int i, int j) {
   static const int Invalid1 = 1;
   static const int Invalid2 = 42;
+  static const int Invalid3 = 0;
   static const int Valid1 = 0xff;
   static const int Valid2 = 0x;
   static const int Valid3 = 0x;
@@ -69,6 +70,9 @@
   : "0"(i), "L"(Invalid2)); // expected-error{{value '42' out of range 
for constraint 'L'}}
   __asm__("xorl %0,%2"
   : "=r"(i)
+  : "0"(i), "L"(Invalid3)); // expected-error{{value '0' out of range 
for constraint 'L'}}
+  __asm__("xorl %0,%2"
+  : "=r"(i)
   : "0"(i), "L"(Valid1)); // expected-no-error
   __asm__("xorl %0,%2"
   : "=r"(i)


Index: cfe/trunk/include/clang/Basic/TargetInfo.h
===
--- cfe/trunk/include/clang/Basic/TargetInfo.h
+++ cfe/trunk/include/clang/Basic/TargetInfo.h
@@ -816,6 +816,7 @@
 struct {
   int Min;
   int Max;
+  bool isConstrained;
 } ImmRange;
 llvm::SmallSet ImmSet;
 
@@ -826,6 +827,7 @@
 : Flags(0), TiedOperand(-1), ConstraintStr(ConstraintStr.str()),
   Name(Name.str()) {
   ImmRange.Min = ImmRange.Max = 0;
+  ImmRange.isConstrained = false;
 }
 
 const std::string &getConstraintStr() const { return ConstraintStr; }
@@ -854,8 +856,9 @@
   return (Flags & CI_ImmediateConstant) != 0;
 }
 bool isValidAsmImmediate(const llvm::APInt &Value) const {
-  return (Value.sge(ImmRange.Min) && Value.sle(ImmRange.Max)) ||
- ImmSet.count(Value.getZExtValue()) != 0;
+  if (!ImmSet.empty())
+return ImmSet.count(Value.getZExtValue()) != 0;
+  return !ImmRange.isConstrained || (Value.sge(ImmRange.Min) && Value.sle(ImmRange.Max));
 }
 
 void setIsReadWrite() { Flags |= CI_ReadWrite; }
@@ -867,6 +870,7 @@
   Flags |= CI_ImmediateConstant;
   ImmRange.Min = Min;
   ImmRange.Max = Max;
+  ImmRange.isConstrained = true;
 }
 void setRequiresImmediate(llvm::ArrayRef Exacts) {
   Flags |= CI_ImmediateConstant;
@@ -879,8 +883,6 @@
 }
 void setRequiresImmediate() {
   Flags |= CI_ImmediateConstant;
-  ImmRange.Min = INT_MIN;
-  ImmRange.Max = INT_MAX;
 }
 
 /// Indicate that this is an input operand that is tied to
Index: cfe/trunk/test/Sema/inline-asm-validate-x86.c
===
--- cfe/trunk/test/Sema/inline-asm-validate-x86.c
+++ cfe/trunk/test/Sema/inline-asm-validate-x86.c
@@ -55,6 +55,7 @@
 void L(int i, int j) {
   static c

r354937 - Fix inline assembler constraint validation

2019-02-26 Thread Joerg Sonnenberger via cfe-commits
Author: joerg
Date: Tue Feb 26 16:40:59 2019
New Revision: 354937

URL: http://llvm.org/viewvc/llvm-project?rev=354937&view=rev
Log:
Fix inline assembler constraint validation

The current constraint logic is both too lax and too strict. It fails
for input outside the [INT_MIN..INT_MAX] range, but it also implicitly
accepts 0 as value when it should not. Adjust logic to handle both
correctly.

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

Modified:
cfe/trunk/include/clang/Basic/TargetInfo.h
cfe/trunk/test/Sema/inline-asm-validate-x86.c

Modified: cfe/trunk/include/clang/Basic/TargetInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TargetInfo.h?rev=354937&r1=354936&r2=354937&view=diff
==
--- cfe/trunk/include/clang/Basic/TargetInfo.h (original)
+++ cfe/trunk/include/clang/Basic/TargetInfo.h Tue Feb 26 16:40:59 2019
@@ -816,6 +816,7 @@ public:
 struct {
   int Min;
   int Max;
+  bool isConstrained;
 } ImmRange;
 llvm::SmallSet ImmSet;
 
@@ -826,6 +827,7 @@ public:
 : Flags(0), TiedOperand(-1), ConstraintStr(ConstraintStr.str()),
   Name(Name.str()) {
   ImmRange.Min = ImmRange.Max = 0;
+  ImmRange.isConstrained = false;
 }
 
 const std::string &getConstraintStr() const { return ConstraintStr; }
@@ -854,8 +856,9 @@ public:
   return (Flags & CI_ImmediateConstant) != 0;
 }
 bool isValidAsmImmediate(const llvm::APInt &Value) const {
-  return (Value.sge(ImmRange.Min) && Value.sle(ImmRange.Max)) ||
- ImmSet.count(Value.getZExtValue()) != 0;
+  if (!ImmSet.empty())
+return ImmSet.count(Value.getZExtValue()) != 0;
+  return !ImmRange.isConstrained || (Value.sge(ImmRange.Min) && 
Value.sle(ImmRange.Max));
 }
 
 void setIsReadWrite() { Flags |= CI_ReadWrite; }
@@ -867,6 +870,7 @@ public:
   Flags |= CI_ImmediateConstant;
   ImmRange.Min = Min;
   ImmRange.Max = Max;
+  ImmRange.isConstrained = true;
 }
 void setRequiresImmediate(llvm::ArrayRef Exacts) {
   Flags |= CI_ImmediateConstant;
@@ -879,8 +883,6 @@ public:
 }
 void setRequiresImmediate() {
   Flags |= CI_ImmediateConstant;
-  ImmRange.Min = INT_MIN;
-  ImmRange.Max = INT_MAX;
 }
 
 /// Indicate that this is an input operand that is tied to

Modified: cfe/trunk/test/Sema/inline-asm-validate-x86.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/inline-asm-validate-x86.c?rev=354937&r1=354936&r2=354937&view=diff
==
--- cfe/trunk/test/Sema/inline-asm-validate-x86.c (original)
+++ cfe/trunk/test/Sema/inline-asm-validate-x86.c Tue Feb 26 16:40:59 2019
@@ -55,6 +55,7 @@ void K(int i, int j) {
 void L(int i, int j) {
   static const int Invalid1 = 1;
   static const int Invalid2 = 42;
+  static const int Invalid3 = 0;
   static const int Valid1 = 0xff;
   static const int Valid2 = 0x;
   static const int Valid3 = 0x;
@@ -69,6 +70,9 @@ void L(int i, int j) {
   : "0"(i), "L"(Invalid2)); // expected-error{{value '42' out of range 
for constraint 'L'}}
   __asm__("xorl %0,%2"
   : "=r"(i)
+  : "0"(i), "L"(Invalid3)); // expected-error{{value '0' out of range 
for constraint 'L'}}
+  __asm__("xorl %0,%2"
+  : "=r"(i)
   : "0"(i), "L"(Valid1)); // expected-no-error
   __asm__("xorl %0,%2"
   : "=r"(i)


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


[PATCH] D58649: Fix inline assembler constraint validation

2019-02-26 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added inline comments.



Comment at: include/clang/Basic/TargetInfo.h:860
+  if (!ImmSet.empty())
+return ImmSet.count(Value.getZExtValue()) != 0;
+  return !ImmRange.isConstrained || (Value.sge(ImmRange.Min) && 
Value.sle(ImmRange.Max));

Isn't the "ImmSet.count" call still wrong?  It looks like it crashes on an 
128-bit immediate, and implicitly truncates a 64-bit immediate.  I guess you 
could check `Value.isSignedIntN(32)`?


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

https://reviews.llvm.org/D58649



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


[PATCH] D58649: Fix inline assembler constraint validation

2019-02-26 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd accepted this revision.
compnerd added a comment.
This revision is now accepted and ready to land.

Nice find!


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

https://reviews.llvm.org/D58649



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


LLVM buildmaster will be updated and restarted tonight

2019-02-26 Thread Galina Kistanova via cfe-commits
 Hello everyone,

LLVM buildmaster will be updated and restarted after 7PM Pacific time today.

Thanks

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


[PATCH] D56370: [clangd] Add support for type hierarchy (super types only for now)

2019-02-26 Thread Nathan Ridge via Phabricator via cfe-commits
nridge added a comment.

I think this is ready to continue to be reviewed :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D56370



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


r354899 - [X86] AMD znver2 enablement

2019-02-26 Thread Ganesh Gopalasubramanian via cfe-commits
Author: ggopala
Date: Tue Feb 26 09:15:36 2019
New Revision: 354899

URL: http://llvm.org/viewvc/llvm-project?rev=354899&view=rev
Log:
[X86] AMD znver2 enablement

This patch enables the following

1) AMD family 17h "znver2" tune flag (-march, -mcpu).
2) ISAs that are enabled for "znver2" architecture.
3) For the time being, it uses the znver1 scheduler model.
4) Tests are updated.
5) This patch is the clang counterpart to D58343

Reviewers: craig.topper
Tags: #clang

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

Modified:
cfe/trunk/include/clang/Basic/X86Target.def
cfe/trunk/lib/Basic/Targets/X86.cpp
cfe/trunk/test/CodeGen/target-builtin-noerror.c
cfe/trunk/test/Driver/x86-march.c
cfe/trunk/test/Frontend/x86-target-cpu.c
cfe/trunk/test/Misc/target-invalid-cpu-note.c
cfe/trunk/test/Preprocessor/predefined-arch-macros.c

Modified: cfe/trunk/include/clang/Basic/X86Target.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/X86Target.def?rev=354899&r1=354898&r2=354899&view=diff
==
--- cfe/trunk/include/clang/Basic/X86Target.def (original)
+++ cfe/trunk/include/clang/Basic/X86Target.def Tue Feb 26 09:15:36 2019
@@ -236,6 +236,7 @@ PROC_WITH_FEAT(BDVER4, "bdver4", PROC_64
 /// Zen architecture processors.
 //@{
 PROC_WITH_FEAT(ZNVER1, "znver1", PROC_64_BIT, FEATURE_AVX2)
+PROC_WITH_FEAT(ZNVER2, "znver2", PROC_64_BIT, FEATURE_AVX2)
 //@}
 
 /// This specification is deprecated and will be removed in the future.

Modified: cfe/trunk/lib/Basic/Targets/X86.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/X86.cpp?rev=354899&r1=354898&r2=354899&view=diff
==
--- cfe/trunk/lib/Basic/Targets/X86.cpp (original)
+++ cfe/trunk/lib/Basic/Targets/X86.cpp Tue Feb 26 09:15:36 2019
@@ -347,6 +347,11 @@ bool X86TargetInfo::initFeatureMap(
 setFeatureEnabledImpl(Features, "sahf", true);
 break;
 
+  case CK_ZNVER2:
+setFeatureEnabledImpl(Features, "clwb", true);
+setFeatureEnabledImpl(Features, "rdpid", true);
+setFeatureEnabledImpl(Features, "wbnoinvd", true);
+LLVM_FALLTHROUGH;
   case CK_ZNVER1:
 setFeatureEnabledImpl(Features, "adx", true);
 setFeatureEnabledImpl(Features, "aes", true);
@@ -1030,6 +1035,9 @@ void X86TargetInfo::getTargetDefines(con
   case CK_ZNVER1:
 defineCPUMacros(Builder, "znver1");
 break;
+  case CK_ZNVER2:
+defineCPUMacros(Builder, "znver2");
+break;
   case CK_Geode:
 defineCPUMacros(Builder, "geode");
 break;

Modified: cfe/trunk/test/CodeGen/target-builtin-noerror.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/target-builtin-noerror.c?rev=354899&r1=354898&r2=354899&view=diff
==
--- cfe/trunk/test/CodeGen/target-builtin-noerror.c (original)
+++ cfe/trunk/test/CodeGen/target-builtin-noerror.c Tue Feb 26 09:15:36 2019
@@ -120,4 +120,5 @@ void verifycpustrings() {
   (void)__builtin_cpu_is("tremont");
   (void)__builtin_cpu_is("westmere");
   (void)__builtin_cpu_is("znver1");
+  (void)__builtin_cpu_is("znver2");
 }

Modified: cfe/trunk/test/Driver/x86-march.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/x86-march.c?rev=354899&r1=354898&r2=354899&view=diff
==
--- cfe/trunk/test/Driver/x86-march.c (original)
+++ cfe/trunk/test/Driver/x86-march.c Tue Feb 26 09:15:36 2019
@@ -159,3 +159,7 @@
 // RUN: %clang -target x86_64-unknown-unknown -c -### %s -march=znver1 2>&1 \
 // RUN:   | FileCheck %s -check-prefix=znver1
 // znver1: "-target-cpu" "znver1"
+//
+// RUN: %clang -target x86_64-unknown-unknown -c -### %s -march=znver2 2>&1 \
+// RUN:   | FileCheck %s -check-prefix=znver2
+// znver2: "-target-cpu" "znver2"

Modified: cfe/trunk/test/Frontend/x86-target-cpu.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/x86-target-cpu.c?rev=354899&r1=354898&r2=354899&view=diff
==
--- cfe/trunk/test/Frontend/x86-target-cpu.c (original)
+++ cfe/trunk/test/Frontend/x86-target-cpu.c Tue Feb 26 09:15:36 2019
@@ -35,5 +35,6 @@
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -target-cpu btver1 -verify %s
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -target-cpu btver2 -verify %s
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -target-cpu znver1 -verify %s
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -target-cpu znver2 -verify %s
 //
 // expected-no-diagnostics

Modified: cfe/trunk/test/Misc/target-invalid-cpu-note.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/target-invalid-cpu-note.c?rev=354899&r1=354898&r2=354899&view=diff
==
--- cfe/trunk/test/M

[PATCH] D58514: Avoid needlessly copying blocks that initialize or are assigned to local auto variables to the heap

2019-02-26 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak updated this revision to Diff 188472.
ahatanak marked an inline comment as done.
ahatanak added a comment.

Call `IgnoreParens` on the LHS too.


Repository:
  rC Clang

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

https://reviews.llvm.org/D58514

Files:
  include/clang/AST/Decl.h
  include/clang/AST/DeclBase.h
  lib/AST/Decl.cpp
  lib/CodeGen/CGObjC.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaExpr.cpp
  lib/Serialization/ASTReaderDecl.cpp
  lib/Serialization/ASTWriterDecl.cpp
  test/CodeGenObjC/arc-block-copy-escape.m
  test/CodeGenObjC/arc-blocks.m
  test/CodeGenObjCXX/arc-blocks.mm
  test/PCH/arc-blocks.mm

Index: test/PCH/arc-blocks.mm
===
--- /dev/null
+++ test/PCH/arc-blocks.mm
@@ -0,0 +1,49 @@
+// RUN: %clang_cc1 -fobjc-arc -fblocks -std=c++1y -emit-pch %s -o %t
+// RUN: %clang_cc1 -fobjc-arc -fblocks -std=c++1y -include-pch %t -emit-llvm -o - %s | FileCheck %s
+
+#ifndef HEADER_INCLUDED
+#define HEADER_INCLUDED
+
+namespace test_block_retain {
+  typedef void (^BlockTy)();
+  void foo1(id);
+
+  inline void initialization(id a) {
+// Call to @llvm.objc.retainBlock isn't needed.
+BlockTy b0 = ^{ foo1(a); };
+b0();
+  }
+
+  inline void assignmentConditional(id a, bool c) {
+BlockTy b0;
+if (c)
+  // @llvm.objc.retainBlock is called since 'b0' is declared in the outer scope.
+  b0 = ^{ foo1(a); };
+b0();
+  }
+}
+
+#else
+
+// CHECK: %[[STRUCT_BLOCK_DESCRIPTOR:.*]] = type { i64, i64 }
+
+namespace test_block_retain {
+// CHECK-LABEL: define linkonce_odr void @_ZN17test_block_retain14initializationEP11objc_object(
+// CHECK-NOT: call i8* @llvm.objc.retainBlock(
+
+  void test_initialization(id a) {
+initialization(a);
+  }
+
+// CHECK-LABEL: define void @_ZN17test_block_retain26test_assignmentConditionalEP11objc_objectb(
+// CHECK: %[[BLOCK:.*]] = alloca <{ i8*, i32, i32, i8*, %[[STRUCT_BLOCK_DESCRIPTOR]]*, i8* }>, align 8
+// CHECK: %[[V4:.*]] = bitcast <{ i8*, i32, i32, i8*, %[[STRUCT_BLOCK_DESCRIPTOR]]*, i8* }>* %[[BLOCK]] to void ()*
+// CHECK: %[[V5:.*]] = bitcast void ()* %[[V4]] to i8*
+// CHECK: call i8* @llvm.objc.retainBlock(i8* %[[V5]])
+
+  void test_assignmentConditional(id a, bool c) {
+assignmentConditional(a, c);
+  }
+}
+
+#endif
Index: test/CodeGenObjCXX/arc-blocks.mm
===
--- test/CodeGenObjCXX/arc-blocks.mm
+++ test/CodeGenObjCXX/arc-blocks.mm
@@ -201,3 +201,123 @@
   ^{ (void)t0; (void)t1; (void)t2; (void)t3; (void)t4; (void)t5; };
 }
 }
+
+// Test that calls to @llvm.objc.retainBlock aren't emitted in some cases.
+
+namespace test_block_retain {
+  typedef void (^BlockTy)();
+
+  void foo1(id);
+
+// CHECK-LABEL: define void @_ZN17test_block_retain14initializationEP11objc_object(
+// CHECK-NOT: @llvm.objc.retainBlock(
+  void initialization(id a) {
+BlockTy b0 = ^{ foo1(a); };
+BlockTy b1 = (^{ foo1(a); });
+b0();
+b1();
+  }
+
+// CHECK-LABEL: define void @_ZN17test_block_retain20initializationStaticEP11objc_object(
+// CHECK: @llvm.objc.retainBlock(
+  void initializationStatic(id a) {
+static BlockTy b0 = ^{ foo1(a); };
+b0();
+  }
+
+// CHECK-LABEL: define void @_ZN17test_block_retain15initialization2EP11objc_object
+// CHECK: %[[B0:.*]] = alloca void ()*, align 8
+// CHECK: %[[B1:.*]] = alloca void ()*, align 8
+// CHECK: load void ()*, void ()** %[[B0]], align 8
+// CHECK-NOT: @llvm.objc.retainBlock
+// CHECK: %[[V9:.*]] = load void ()*, void ()** %[[B0]], align 8
+// CHECK: %[[V10:.*]] = bitcast void ()* %[[V9]] to i8*
+// CHECK: %[[V11:.*]] = call i8* @llvm.objc.retainBlock(i8* %[[V10]])
+// CHECK: %[[V12:.*]] = bitcast i8* %[[V11]] to void ()*
+// CHECK: store void ()* %[[V12]], void ()** %[[B1]], align 8
+  void initialization2(id a) {
+BlockTy b0 = ^{ foo1(a); };
+b0();
+BlockTy b1 = b0; // can't optimize this yet.
+b1();
+  }
+
+// CHECK-LABEL: define void @_ZN17test_block_retain10assignmentEP11objc_object(
+// CHECK-NOT: @llvm.objc.retainBlock(
+  void assignment(id a) {
+BlockTy b0;
+(b0) = ^{ foo1(a); };
+b0();
+b0 = (^{ foo1(a); });
+b0();
+  }
+
+// CHECK-LABEL: define void @_ZN17test_block_retain16assignmentStaticEP11objc_object(
+// CHECK: @llvm.objc.retainBlock(
+  void assignmentStatic(id a) {
+static BlockTy b0;
+b0 = ^{ foo1(a); };
+b0();
+  }
+
+// CHECK-LABEL: define void @_ZN17test_block_retain21assignmentConditionalEP11objc_objectb(
+// CHECK: @llvm.objc.retainBlock(
+  void assignmentConditional(id a, bool c) {
+BlockTy b0;
+if (c)
+  // can't optimize this since 'b0' is declared in the outer scope.
+  b0 = ^{ foo1(a); };
+b0();
+  }
+
+// CHECK-LABEL: define void @_ZN17test_block_retain11assignment2EP11objc_object(
+// CHECK: %[[B0:.*]] = alloca void ()*, align 8
+// CHECK: %[[B1:.*]] = alloca void ()*, align 8
+// CHECK-NOT: @llvm.objc.retainBlock
+// CHECK: store voi

[PATCH] D58147: [CodeGen] Fix calling llvm.var.annotation outside of a basic block.

2019-02-26 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai added a comment.

In D58147#1398094 , @rjmccall wrote:

> Okay.  Is it acceptable for the annotation to simply disappear in this case?  
> I don't really understand the purposes of annotations well enough to judge.


Looks like it is acceptable. The main justification for this behavior is that 
it is already happening for

  return;
  int after_return = __builtin_annotation(0, "annotation");

so I think it is correct to have the same IR for

  return;
  int after_return __attribute__((annotate("annotation"))) = 0;

Also looks like in the code we don't really use this intrinsic. And according 
to the documentation

> This intrinsic allows annotation of local variables with arbitrary
>  strings. This can be useful for special purpose optimizations that want
>  to look for these annotations. These have no other defined use; they are
>  ignored by code generation and optimization.

I think for the special purpose optimizations it would be more convenient not 
to know about the code after return instead of detecting it and ignoring 
explicitly.


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

https://reviews.llvm.org/D58147



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


[PATCH] D58600: [clangd] Emit source to Diagnostic.

2019-02-26 Thread Jan Korous via Phabricator via cfe-commits
jkorous added inline comments.



Comment at: clangd/Diagnostics.cpp:381
 LastDiag = Diag();
+LastDiag->ID = Info.getID();
 FillDiagBase(*LastDiag);

Nit - is this really intended to be part of this patch?



Comment at: clangd/Diagnostics.h:72
+  // Diagnostic enum ID.
+  unsigned ID;
+  // The source of this diagnostic, e.g. 'clang', 'clang-tidy'.

Nit - is this really intended to be part of this patch?


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D58600



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


[PATCH] D58659: [Sema] Fix assertion when `auto` parameter in lambda has an attribute.

2019-02-26 Thread Jan Korous via Phabricator via cfe-commits
jkorous added inline comments.



Comment at: clang/lib/Sema/SemaType.cpp:266
+auto *NewAttrTy = cast(T.getTypePtr());
+for (TypeAttrPair &A : AttrsForTypes) {
+  if (A.first == AttrTy)

Do you think it would make sense to terminate the loop early if 
`AttrsForTypesSorted == true`?



Comment at: clang/lib/Sema/SemaType.cpp:270
+}
+AttrsForTypesSorted = false;
+  }

Do you think it would be reasonable to conditionally assign (or rather keep) 
`AttrsForTypesSorted = true` in case they were sorted previously and new key 
doesn't break the order?


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

https://reviews.llvm.org/D58659



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


[PATCH] D57335: [IR] Don't assume all functions are 4 byte aligned

2019-02-26 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.

Probably worth sending an email to llvmdev noting that the datalayout is 
changing before you merge this, so a wider audience can review the IR aspects 
of the change.

Otherwise LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D57335



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


[PATCH] D57628: [index] Improve indexing support for MSPropertyDecl.

2019-02-26 Thread Jan Korous via Phabricator via cfe-commits
jkorous accepted this revision.
jkorous added a comment.
This revision is now accepted and ready to land.

LGTM

Thanks for looking into this!


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

https://reviews.llvm.org/D57628



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


[PATCH] D58374: [Clang][NewPM] Don't bail out if the target machine is empty

2019-02-26 Thread Chandler Carruth via Phabricator via cfe-commits
chandlerc requested changes to this revision.
chandlerc added a comment.
This revision now requires changes to proceed.

Maybe update at least some of the tests using these targets to additionally run 
with the new pass manager explicitly enabled via flag?




Comment at: clang/lib/CodeGen/BackendUtil.cpp:950
 
-  // The new pass manager always makes a target machine available to passes
-  // during construction.
-  CreateTargetMachine(/*MustCreateTM*/ true);
-  if (!TM)
-// This will already be diagnosed, just bail.
+  bool UsesCodeGen = (Action != Backend_EmitNothing &&
+  Action != Backend_EmitBC &&

I would say `RequiresCodeGen` instead of `UsesCodeGen` as we will still *use* 
the target manager even if it isn't required when emitting a `.ll` file.


Repository:
  rC Clang

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

https://reviews.llvm.org/D58374



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


[PATCH] D57716: [CUDA][HIP] Check calling convention based on function target

2019-02-26 Thread Yaxun Liu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC354929: [CUDA][HIP] Check calling convention based on 
function target (authored by yaxunl, committed by ).
Herald added a project: clang.

Repository:
  rC Clang

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

https://reviews.llvm.org/D57716

Files:
  lib/Sema/SemaDeclAttr.cpp
  test/SemaCUDA/amdgpu-windows-vectorcall.cu


Index: test/SemaCUDA/amdgpu-windows-vectorcall.cu
===
--- test/SemaCUDA/amdgpu-windows-vectorcall.cu
+++ test/SemaCUDA/amdgpu-windows-vectorcall.cu
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -aux-triple 
x86_64-pc-windows-msvc -fms-compatibility -fcuda-is-device -fsyntax-only 
-verify %s
+
+__cdecl void hostf1();
+__vectorcall void (*hostf2)() = hostf1; // expected-error {{cannot initialize 
a variable of type 'void ((*))() __attribute__((vectorcall))' with an lvalue of 
type 'void () __attribute__((cdecl))'}}
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -4615,8 +4615,36 @@
   default: llvm_unreachable("unexpected attribute kind");
   }
 
+  TargetInfo::CallingConvCheckResult A = TargetInfo::CCCR_OK;
   const TargetInfo &TI = Context.getTargetInfo();
-  TargetInfo::CallingConvCheckResult A = TI.checkCallingConvention(CC);
+  auto *Aux = Context.getAuxTargetInfo();
+  if (LangOpts.CUDA) {
+auto CudaTarget = IdentifyCUDATarget(FD);
+bool CheckHost = false, CheckDevice = false;
+switch (CudaTarget) {
+case CFT_HostDevice:
+  CheckHost = true;
+  CheckDevice = true;
+  break;
+case CFT_Host:
+  CheckHost = true;
+  break;
+case CFT_Device:
+case CFT_Global:
+  CheckDevice = true;
+  break;
+case CFT_InvalidTarget:
+  llvm_unreachable("unexpected cuda target");
+}
+auto *HostTI = LangOpts.CUDAIsDevice ? Aux : &TI;
+auto *DeviceTI = LangOpts.CUDAIsDevice ? &TI : Aux;
+if (CheckHost && HostTI)
+  A = HostTI->checkCallingConvention(CC);
+if (A == TargetInfo::CCCR_OK && CheckDevice && DeviceTI)
+  A = DeviceTI->checkCallingConvention(CC);
+  } else {
+A = TI.checkCallingConvention(CC);
+  }
   if (A != TargetInfo::CCCR_OK) {
 if (A == TargetInfo::CCCR_Warning)
   Diag(Attrs.getLoc(), diag::warn_cconv_ignored) << Attrs;


Index: test/SemaCUDA/amdgpu-windows-vectorcall.cu
===
--- test/SemaCUDA/amdgpu-windows-vectorcall.cu
+++ test/SemaCUDA/amdgpu-windows-vectorcall.cu
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -aux-triple x86_64-pc-windows-msvc -fms-compatibility -fcuda-is-device -fsyntax-only -verify %s
+
+__cdecl void hostf1();
+__vectorcall void (*hostf2)() = hostf1; // expected-error {{cannot initialize a variable of type 'void ((*))() __attribute__((vectorcall))' with an lvalue of type 'void () __attribute__((cdecl))'}}
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -4615,8 +4615,36 @@
   default: llvm_unreachable("unexpected attribute kind");
   }
 
+  TargetInfo::CallingConvCheckResult A = TargetInfo::CCCR_OK;
   const TargetInfo &TI = Context.getTargetInfo();
-  TargetInfo::CallingConvCheckResult A = TI.checkCallingConvention(CC);
+  auto *Aux = Context.getAuxTargetInfo();
+  if (LangOpts.CUDA) {
+auto CudaTarget = IdentifyCUDATarget(FD);
+bool CheckHost = false, CheckDevice = false;
+switch (CudaTarget) {
+case CFT_HostDevice:
+  CheckHost = true;
+  CheckDevice = true;
+  break;
+case CFT_Host:
+  CheckHost = true;
+  break;
+case CFT_Device:
+case CFT_Global:
+  CheckDevice = true;
+  break;
+case CFT_InvalidTarget:
+  llvm_unreachable("unexpected cuda target");
+}
+auto *HostTI = LangOpts.CUDAIsDevice ? Aux : &TI;
+auto *DeviceTI = LangOpts.CUDAIsDevice ? &TI : Aux;
+if (CheckHost && HostTI)
+  A = HostTI->checkCallingConvention(CC);
+if (A == TargetInfo::CCCR_OK && CheckDevice && DeviceTI)
+  A = DeviceTI->checkCallingConvention(CC);
+  } else {
+A = TI.checkCallingConvention(CC);
+  }
   if (A != TargetInfo::CCCR_OK) {
 if (A == TargetInfo::CCCR_Warning)
   Diag(Attrs.getLoc(), diag::warn_cconv_ignored) << Attrs;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r354929 - [CUDA][HIP] Check calling convention based on function target

2019-02-26 Thread Yaxun Liu via cfe-commits
Author: yaxunl
Date: Tue Feb 26 14:24:49 2019
New Revision: 354929

URL: http://llvm.org/viewvc/llvm-project?rev=354929&view=rev
Log:
[CUDA][HIP] Check calling convention based on function target

MSVC header files using vectorcall to differentiate overloaded functions, which
causes failure for AMDGPU target. This is because clang does not check function
calling convention based on function target.

This patch checks calling convention using the proper target info.

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

Added:
cfe/trunk/test/SemaCUDA/amdgpu-windows-vectorcall.cu
Modified:
cfe/trunk/lib/Sema/SemaDeclAttr.cpp

Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=354929&r1=354928&r2=354929&view=diff
==
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Tue Feb 26 14:24:49 2019
@@ -4615,8 +4615,36 @@ bool Sema::CheckCallingConvAttr(const Pa
   default: llvm_unreachable("unexpected attribute kind");
   }
 
+  TargetInfo::CallingConvCheckResult A = TargetInfo::CCCR_OK;
   const TargetInfo &TI = Context.getTargetInfo();
-  TargetInfo::CallingConvCheckResult A = TI.checkCallingConvention(CC);
+  auto *Aux = Context.getAuxTargetInfo();
+  if (LangOpts.CUDA) {
+auto CudaTarget = IdentifyCUDATarget(FD);
+bool CheckHost = false, CheckDevice = false;
+switch (CudaTarget) {
+case CFT_HostDevice:
+  CheckHost = true;
+  CheckDevice = true;
+  break;
+case CFT_Host:
+  CheckHost = true;
+  break;
+case CFT_Device:
+case CFT_Global:
+  CheckDevice = true;
+  break;
+case CFT_InvalidTarget:
+  llvm_unreachable("unexpected cuda target");
+}
+auto *HostTI = LangOpts.CUDAIsDevice ? Aux : &TI;
+auto *DeviceTI = LangOpts.CUDAIsDevice ? &TI : Aux;
+if (CheckHost && HostTI)
+  A = HostTI->checkCallingConvention(CC);
+if (A == TargetInfo::CCCR_OK && CheckDevice && DeviceTI)
+  A = DeviceTI->checkCallingConvention(CC);
+  } else {
+A = TI.checkCallingConvention(CC);
+  }
   if (A != TargetInfo::CCCR_OK) {
 if (A == TargetInfo::CCCR_Warning)
   Diag(Attrs.getLoc(), diag::warn_cconv_ignored) << Attrs;

Added: cfe/trunk/test/SemaCUDA/amdgpu-windows-vectorcall.cu
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCUDA/amdgpu-windows-vectorcall.cu?rev=354929&view=auto
==
--- cfe/trunk/test/SemaCUDA/amdgpu-windows-vectorcall.cu (added)
+++ cfe/trunk/test/SemaCUDA/amdgpu-windows-vectorcall.cu Tue Feb 26 14:24:49 
2019
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -aux-triple 
x86_64-pc-windows-msvc -fms-compatibility -fcuda-is-device -fsyntax-only 
-verify %s
+
+__cdecl void hostf1();
+__vectorcall void (*hostf2)() = hostf1; // expected-error {{cannot initialize 
a variable of type 'void ((*))() __attribute__((vectorcall))' with an lvalue of 
type 'void () __attribute__((cdecl))'}}


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


[PATCH] D57460: [WIP] Prototype a generic kernel offloading interface

2019-02-26 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert updated this revision to Diff 188461.
jdoerfert added a comment.

Remove unneeded changes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D57460

Files:
  clang/lib/CodeGen/CGOpenMPRuntimeTRegion.cpp
  clang/lib/CodeGen/CGOpenMPRuntimeTRegion.h
  clang/lib/CodeGen/CMakeLists.txt
  clang/lib/CodeGen/CodeGenModule.cpp
  llvm/include/llvm/InitializePasses.h
  llvm/include/llvm/LinkAllPasses.h
  llvm/include/llvm/Support/SaveAndRestore.h
  llvm/include/llvm/Transforms/IPO.h
  llvm/lib/Transforms/IPO/CMakeLists.txt
  llvm/lib/Transforms/IPO/IPO.cpp
  llvm/lib/Transforms/IPO/OpenMPOpt.cpp
  llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
  llvm/lib/Transforms/Scalar/SCCP.cpp
  llvm/test/Other/opt-O2-pipeline.ll
  llvm/test/Other/opt-O3-pipeline.ll
  llvm/test/Other/opt-Os-pipeline.ll
  openmp/libomptarget/cmake/Modules/LibomptargetNVPTXBitcodeLibrary.cmake
  openmp/libomptarget/deviceRTLs/common/target_region.h
  openmp/libomptarget/deviceRTLs/nvptx/CMakeLists.txt
  openmp/libomptarget/deviceRTLs/nvptx/src/omp_data.cu
  openmp/libomptarget/deviceRTLs/nvptx/src/omptarget-nvptx.h
  openmp/libomptarget/deviceRTLs/nvptx/src/target_region.cu

Index: openmp/libomptarget/deviceRTLs/nvptx/src/target_region.cu
===
--- /dev/null
+++ openmp/libomptarget/deviceRTLs/nvptx/src/target_region.cu
@@ -0,0 +1,197 @@
+//===-- target_region.cu  CUDA impl. of the target region interface -*-===//
+//
+// 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
+//
+//===--===//
+//
+// This file contains the implementation of the common target region interface.
+//
+//===--===//
+
+// Include the native definitions first as certain defines might be needed in
+// the common interface definition below.
+#include "omptarget-nvptx.h"
+#include "interface.h"
+
+#include "../../common/target_region.h"
+
+/// The pointer used to share memory between team threads.
+extern __device__ __shared__ target_region_shared_buffer
+_target_region_shared_memory;
+
+EXTERN char *__kmpc_target_region_kernel_get_shared_memory() {
+  return _target_region_shared_memory.begin();
+}
+EXTERN char *__kmpc_target_region_kernel_get_private_memory() {
+  return _target_region_shared_memory.begin() +
+ _target_region_shared_memory.get_offset();
+}
+
+/// Simple generic state machine for worker threads.
+INLINE static void
+__kmpc_target_region_state_machine(bool IsOMPRuntimeInitialized) {
+
+  do {
+void *WorkFn = 0;
+
+// Wait for the signal that we have a new work function.
+__kmpc_barrier_simple_spmd(NULL, 0);
+
+// Retrieve the work function from the runtime.
+bool IsActive = __kmpc_kernel_parallel(&WorkFn, IsOMPRuntimeInitialized);
+
+// If there is nothing more to do, break out of the state machine by
+// returning to the caller.
+if (!WorkFn)
+  return;
+
+if (IsActive) {
+  char *SharedVars = __kmpc_target_region_kernel_get_shared_memory();
+  char *PrivateVars = __kmpc_target_region_kernel_get_private_memory();
+
+  ((ParallelWorkFnTy)WorkFn)(SharedVars, PrivateVars);
+
+  __kmpc_kernel_end_parallel();
+}
+
+__kmpc_barrier_simple_spmd(NULL, 0);
+
+  } while (true);
+}
+
+/// Filter threads into masters and workers. If \p UseStateMachine is true,
+/// required workers will enter a state machine through and be trapped there.
+/// Master and surplus worker threads will return from this function immediately
+/// while required workers will only return once there is no more work. The
+/// return value indicates if the thread is a master (1), a surplus worker (0),
+/// or a finished required worker released from the state machine (-1).
+INLINE static int8_t
+__kmpc_target_region_thread_filter(unsigned ThreadLimit, bool UseStateMachine,
+   bool IsOMPRuntimeInitialized) {
+
+  unsigned TId = GetThreadIdInBlock();
+  bool IsWorker = TId < ThreadLimit;
+
+  if (IsWorker) {
+if (UseStateMachine)
+  __kmpc_target_region_state_machine(IsOMPRuntimeInitialized);
+return -1;
+  }
+
+  return TId == GetMasterThreadID();
+}
+
+EXTERN int8_t __kmpc_target_region_kernel_init(bool UseSPMDMode,
+   bool UseStateMachine,
+   bool RequiresOMPRuntime,
+   bool RequiresDataSharing) {
+  unsigned NumThreads = GetNumberOfThreadsInBlock();
+
+  // Handle the SPMD case first.
+  if (UseSPMDMode) {
+
+__kmpc_spmd_kernel_init(NumThreads, RequiresOMPRuntime,
+RequiresDataSharin

[PATCH] D57460: [WIP] Prototype a generic kernel offloading interface

2019-02-26 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert updated this revision to Diff 188462.
jdoerfert added a comment.

Remove more unneeded changes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D57460

Files:
  clang/lib/CodeGen/CGOpenMPRuntimeTRegion.cpp
  clang/lib/CodeGen/CGOpenMPRuntimeTRegion.h
  clang/lib/CodeGen/CMakeLists.txt
  clang/lib/CodeGen/CodeGenModule.cpp
  llvm/include/llvm/InitializePasses.h
  llvm/include/llvm/LinkAllPasses.h
  llvm/include/llvm/Transforms/IPO.h
  llvm/lib/Transforms/IPO/CMakeLists.txt
  llvm/lib/Transforms/IPO/IPO.cpp
  llvm/lib/Transforms/IPO/OpenMPOpt.cpp
  llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
  llvm/lib/Transforms/Scalar/SCCP.cpp
  llvm/test/Other/opt-O2-pipeline.ll
  llvm/test/Other/opt-O3-pipeline.ll
  llvm/test/Other/opt-Os-pipeline.ll
  openmp/libomptarget/cmake/Modules/LibomptargetNVPTXBitcodeLibrary.cmake
  openmp/libomptarget/deviceRTLs/common/target_region.h
  openmp/libomptarget/deviceRTLs/nvptx/CMakeLists.txt
  openmp/libomptarget/deviceRTLs/nvptx/src/omp_data.cu
  openmp/libomptarget/deviceRTLs/nvptx/src/omptarget-nvptx.h
  openmp/libomptarget/deviceRTLs/nvptx/src/target_region.cu

Index: openmp/libomptarget/deviceRTLs/nvptx/src/target_region.cu
===
--- /dev/null
+++ openmp/libomptarget/deviceRTLs/nvptx/src/target_region.cu
@@ -0,0 +1,197 @@
+//===-- target_region.cu  CUDA impl. of the target region interface -*-===//
+//
+// 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
+//
+//===--===//
+//
+// This file contains the implementation of the common target region interface.
+//
+//===--===//
+
+// Include the native definitions first as certain defines might be needed in
+// the common interface definition below.
+#include "omptarget-nvptx.h"
+#include "interface.h"
+
+#include "../../common/target_region.h"
+
+/// The pointer used to share memory between team threads.
+extern __device__ __shared__ target_region_shared_buffer
+_target_region_shared_memory;
+
+EXTERN char *__kmpc_target_region_kernel_get_shared_memory() {
+  return _target_region_shared_memory.begin();
+}
+EXTERN char *__kmpc_target_region_kernel_get_private_memory() {
+  return _target_region_shared_memory.begin() +
+ _target_region_shared_memory.get_offset();
+}
+
+/// Simple generic state machine for worker threads.
+INLINE static void
+__kmpc_target_region_state_machine(bool IsOMPRuntimeInitialized) {
+
+  do {
+void *WorkFn = 0;
+
+// Wait for the signal that we have a new work function.
+__kmpc_barrier_simple_spmd(NULL, 0);
+
+// Retrieve the work function from the runtime.
+bool IsActive = __kmpc_kernel_parallel(&WorkFn, IsOMPRuntimeInitialized);
+
+// If there is nothing more to do, break out of the state machine by
+// returning to the caller.
+if (!WorkFn)
+  return;
+
+if (IsActive) {
+  char *SharedVars = __kmpc_target_region_kernel_get_shared_memory();
+  char *PrivateVars = __kmpc_target_region_kernel_get_private_memory();
+
+  ((ParallelWorkFnTy)WorkFn)(SharedVars, PrivateVars);
+
+  __kmpc_kernel_end_parallel();
+}
+
+__kmpc_barrier_simple_spmd(NULL, 0);
+
+  } while (true);
+}
+
+/// Filter threads into masters and workers. If \p UseStateMachine is true,
+/// required workers will enter a state machine through and be trapped there.
+/// Master and surplus worker threads will return from this function immediately
+/// while required workers will only return once there is no more work. The
+/// return value indicates if the thread is a master (1), a surplus worker (0),
+/// or a finished required worker released from the state machine (-1).
+INLINE static int8_t
+__kmpc_target_region_thread_filter(unsigned ThreadLimit, bool UseStateMachine,
+   bool IsOMPRuntimeInitialized) {
+
+  unsigned TId = GetThreadIdInBlock();
+  bool IsWorker = TId < ThreadLimit;
+
+  if (IsWorker) {
+if (UseStateMachine)
+  __kmpc_target_region_state_machine(IsOMPRuntimeInitialized);
+return -1;
+  }
+
+  return TId == GetMasterThreadID();
+}
+
+EXTERN int8_t __kmpc_target_region_kernel_init(bool UseSPMDMode,
+   bool UseStateMachine,
+   bool RequiresOMPRuntime,
+   bool RequiresDataSharing) {
+  unsigned NumThreads = GetNumberOfThreadsInBlock();
+
+  // Handle the SPMD case first.
+  if (UseSPMDMode) {
+
+__kmpc_spmd_kernel_init(NumThreads, RequiresOMPRuntime,
+RequiresDataSharing);
+
+if (RequiresDataSharing)
+   

[PATCH] D57460: [WIP] Prototype a generic kernel offloading interface

2019-02-26 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert updated this revision to Diff 188460.
jdoerfert added a comment.

Remove leftover debug msgs


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D57460

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.h
  clang/lib/CodeGen/CGOpenMPRuntimeTRegion.cpp
  clang/lib/CodeGen/CGOpenMPRuntimeTRegion.h
  clang/lib/CodeGen/CMakeLists.txt
  clang/lib/CodeGen/CodeGenModule.cpp
  llvm/include/llvm/InitializePasses.h
  llvm/include/llvm/LinkAllPasses.h
  llvm/include/llvm/Support/SaveAndRestore.h
  llvm/include/llvm/Transforms/IPO.h
  llvm/lib/Transforms/IPO/CMakeLists.txt
  llvm/lib/Transforms/IPO/IPO.cpp
  llvm/lib/Transforms/IPO/OpenMPOpt.cpp
  llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
  llvm/lib/Transforms/Scalar/SCCP.cpp
  llvm/test/Other/opt-O2-pipeline.ll
  llvm/test/Other/opt-O3-pipeline.ll
  llvm/test/Other/opt-Os-pipeline.ll
  openmp/libomptarget/cmake/Modules/LibomptargetNVPTXBitcodeLibrary.cmake
  openmp/libomptarget/deviceRTLs/common/target_region.h
  openmp/libomptarget/deviceRTLs/nvptx/CMakeLists.txt
  openmp/libomptarget/deviceRTLs/nvptx/src/omp_data.cu
  openmp/libomptarget/deviceRTLs/nvptx/src/omptarget-nvptx.h
  openmp/libomptarget/deviceRTLs/nvptx/src/target_region.cu

Index: openmp/libomptarget/deviceRTLs/nvptx/src/target_region.cu
===
--- /dev/null
+++ openmp/libomptarget/deviceRTLs/nvptx/src/target_region.cu
@@ -0,0 +1,197 @@
+//===-- target_region.cu  CUDA impl. of the target region interface -*-===//
+//
+// 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
+//
+//===--===//
+//
+// This file contains the implementation of the common target region interface.
+//
+//===--===//
+
+// Include the native definitions first as certain defines might be needed in
+// the common interface definition below.
+#include "omptarget-nvptx.h"
+#include "interface.h"
+
+#include "../../common/target_region.h"
+
+/// The pointer used to share memory between team threads.
+extern __device__ __shared__ target_region_shared_buffer
+_target_region_shared_memory;
+
+EXTERN char *__kmpc_target_region_kernel_get_shared_memory() {
+  return _target_region_shared_memory.begin();
+}
+EXTERN char *__kmpc_target_region_kernel_get_private_memory() {
+  return _target_region_shared_memory.begin() +
+ _target_region_shared_memory.get_offset();
+}
+
+/// Simple generic state machine for worker threads.
+INLINE static void
+__kmpc_target_region_state_machine(bool IsOMPRuntimeInitialized) {
+
+  do {
+void *WorkFn = 0;
+
+// Wait for the signal that we have a new work function.
+__kmpc_barrier_simple_spmd(NULL, 0);
+
+// Retrieve the work function from the runtime.
+bool IsActive = __kmpc_kernel_parallel(&WorkFn, IsOMPRuntimeInitialized);
+
+// If there is nothing more to do, break out of the state machine by
+// returning to the caller.
+if (!WorkFn)
+  return;
+
+if (IsActive) {
+  char *SharedVars = __kmpc_target_region_kernel_get_shared_memory();
+  char *PrivateVars = __kmpc_target_region_kernel_get_private_memory();
+
+  ((ParallelWorkFnTy)WorkFn)(SharedVars, PrivateVars);
+
+  __kmpc_kernel_end_parallel();
+}
+
+__kmpc_barrier_simple_spmd(NULL, 0);
+
+  } while (true);
+}
+
+/// Filter threads into masters and workers. If \p UseStateMachine is true,
+/// required workers will enter a state machine through and be trapped there.
+/// Master and surplus worker threads will return from this function immediately
+/// while required workers will only return once there is no more work. The
+/// return value indicates if the thread is a master (1), a surplus worker (0),
+/// or a finished required worker released from the state machine (-1).
+INLINE static int8_t
+__kmpc_target_region_thread_filter(unsigned ThreadLimit, bool UseStateMachine,
+   bool IsOMPRuntimeInitialized) {
+
+  unsigned TId = GetThreadIdInBlock();
+  bool IsWorker = TId < ThreadLimit;
+
+  if (IsWorker) {
+if (UseStateMachine)
+  __kmpc_target_region_state_machine(IsOMPRuntimeInitialized);
+return -1;
+  }
+
+  return TId == GetMasterThreadID();
+}
+
+EXTERN int8_t __kmpc_target_region_kernel_init(bool UseSPMDMode,
+   bool UseStateMachine,
+   bool RequiresOMPRuntime,
+   bool RequiresDataSharing) {
+  unsigned NumThreads = GetNumberOfThreadsInBlock();
+
+  // Handle the SPMD case first.
+  if (UseSPMDMode) {
+
+__kmpc_spmd_kernel_init(NumThreads, RequiresOMPRuntime,
+ 

[PATCH] D57460: [WIP] Prototype a generic kernel offloading interface

2019-02-26 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

I updated the patch with one that has a clean clang and runtime integration. It 
passes all but one OpenMP V&V test suite test (developed as part of ECP by U 
Del and others). The LLVM optimization gives us 30% speedup on the 
rodinia3.1/nw (Needleman Wunsch) benchmark (more details and a cleaned up LLVM 
part will follow in ~2 weeks time).

Please feel free to look through and comment on the interface (openmp/...) and 
clang part till then!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D57460



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


[PATCH] D57460: [WIP] Prototype a generic kernel offloading interface

2019-02-26 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert updated this revision to Diff 188458.
jdoerfert added a comment.
Herald added projects: clang, OpenMP, LLVM.
Herald added subscribers: llvm-commits, openmp-commits, cfe-commits.

Cleaned up clang part and interface. LLVM part still needs work


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D57460

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.h
  clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
  clang/lib/CodeGen/CGOpenMPRuntimeTRegion.cpp
  clang/lib/CodeGen/CGOpenMPRuntimeTRegion.h
  clang/lib/CodeGen/CMakeLists.txt
  clang/lib/CodeGen/CodeGenModule.cpp
  llvm/include/llvm/InitializePasses.h
  llvm/include/llvm/LinkAllPasses.h
  llvm/include/llvm/Support/SaveAndRestore.h
  llvm/include/llvm/Transforms/IPO.h
  llvm/lib/Transforms/IPO/CMakeLists.txt
  llvm/lib/Transforms/IPO/IPO.cpp
  llvm/lib/Transforms/IPO/OpenMPOpt.cpp
  llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
  llvm/lib/Transforms/Scalar/SCCP.cpp
  llvm/test/Other/opt-O2-pipeline.ll
  llvm/test/Other/opt-O3-pipeline.ll
  llvm/test/Other/opt-Os-pipeline.ll
  openmp/libomptarget/cmake/Modules/LibomptargetNVPTXBitcodeLibrary.cmake
  openmp/libomptarget/deviceRTLs/common/target_region.h
  openmp/libomptarget/deviceRTLs/nvptx/CMakeLists.txt
  openmp/libomptarget/deviceRTLs/nvptx/src/omp_data.cu
  openmp/libomptarget/deviceRTLs/nvptx/src/omptarget-nvptx.h
  openmp/libomptarget/deviceRTLs/nvptx/src/target_region.cu

Index: openmp/libomptarget/deviceRTLs/nvptx/src/target_region.cu
===
--- /dev/null
+++ openmp/libomptarget/deviceRTLs/nvptx/src/target_region.cu
@@ -0,0 +1,197 @@
+//===-- target_region.cu  CUDA impl. of the target region interface -*-===//
+//
+// 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
+//
+//===--===//
+//
+// This file contains the implementation of the common target region interface.
+//
+//===--===//
+
+// Include the native definitions first as certain defines might be needed in
+// the common interface definition below.
+#include "omptarget-nvptx.h"
+#include "interface.h"
+
+#include "../../common/target_region.h"
+
+/// The pointer used to share memory between team threads.
+extern __device__ __shared__ target_region_shared_buffer
+_target_region_shared_memory;
+
+EXTERN char *__kmpc_target_region_kernel_get_shared_memory() {
+  return _target_region_shared_memory.begin();
+}
+EXTERN char *__kmpc_target_region_kernel_get_private_memory() {
+  return _target_region_shared_memory.begin() +
+ _target_region_shared_memory.get_offset();
+}
+
+/// Simple generic state machine for worker threads.
+INLINE static void
+__kmpc_target_region_state_machine(bool IsOMPRuntimeInitialized) {
+
+  do {
+void *WorkFn = 0;
+
+// Wait for the signal that we have a new work function.
+__kmpc_barrier_simple_spmd(NULL, 0);
+
+// Retrieve the work function from the runtime.
+bool IsActive = __kmpc_kernel_parallel(&WorkFn, IsOMPRuntimeInitialized);
+
+// If there is nothing more to do, break out of the state machine by
+// returning to the caller.
+if (!WorkFn)
+  return;
+
+if (IsActive) {
+  char *SharedVars = __kmpc_target_region_kernel_get_shared_memory();
+  char *PrivateVars = __kmpc_target_region_kernel_get_private_memory();
+
+  ((ParallelWorkFnTy)WorkFn)(SharedVars, PrivateVars);
+
+  __kmpc_kernel_end_parallel();
+}
+
+__kmpc_barrier_simple_spmd(NULL, 0);
+
+  } while (true);
+}
+
+/// Filter threads into masters and workers. If \p UseStateMachine is true,
+/// required workers will enter a state machine through and be trapped there.
+/// Master and surplus worker threads will return from this function immediately
+/// while required workers will only return once there is no more work. The
+/// return value indicates if the thread is a master (1), a surplus worker (0),
+/// or a finished required worker released from the state machine (-1).
+INLINE static int8_t
+__kmpc_target_region_thread_filter(unsigned ThreadLimit, bool UseStateMachine,
+   bool IsOMPRuntimeInitialized) {
+
+  unsigned TId = GetThreadIdInBlock();
+  bool IsWorker = TId < ThreadLimit;
+
+  if (IsWorker) {
+if (UseStateMachine)
+  __kmpc_target_region_state_machine(IsOMPRuntimeInitialized);
+return -1;
+  }
+
+  return TId == GetMasterThreadID();
+}
+
+EXTERN int8_t __kmpc_target_region_kernel_init(bool UseSPMDMode,
+   bool UseStateMachine,
+   bool RequiresOMPRuntime,
+   bool RequiresD

[PATCH] D58518: [HIP] change kernel stub name

2019-02-26 Thread Artem Belevich via Phabricator via cfe-commits
tra accepted this revision.
tra added subscribers: jyknight, bkramer.
tra added inline comments.
This revision is now accepted and ready to land.



Comment at: lib/CodeGen/CodeGenModule.cpp:1059
+FD->hasAttr())
+  MangledName = MangledName + ".stub";
+

yaxunl wrote:
> tra wrote:
> > Changing mangled name exposes this change to a wider scope of potential 
> > issues. Is the mangled name still valid after this change? I.e. will 
> > external demanglers have problem with it? Is `.` a valid symbol in mangled 
> > names on all platforms we support?
> > 
> > I think changing the name here is way too late and we should figure out how 
> > to change the stub name when we generate it.
> > 
> > @echristo Eric, what do you think?
> The external demangler can still demangle this name. e.g. c++filt will 
> demangle this name and add [clone .stub] after that.
> 
> As far as I can see this function is only called in codegen to map 
> FunctionDecl names to LLVM function names. I've tried this change with real 
> ML frameworks and it works.
> 
> Changing at this place is not too late. The stub function name is requested 
> at multiple places in codegen, not just at the emitting of stub function 
> definition. For template kernel function, the emitting of stub function 
> definition is deferred after emitting of the call of the stub function. 
> Basically, codegen needs to find the corresponding LLVM stub function by 
> getMangledName first, then by GetOrCreateLLVMFunction. If we do not change 
> getMangledName, codegen will not get the correct stub function name 
> consistently at all places. That's why the previous patch does not work.
I stand corrected. @jyknight and @bkramer pointed out that appending 
`.WHATEVER` is currently used for cloning functions and should be OK to do. 


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

https://reviews.llvm.org/D58518



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


[PATCH] D58494: [ASTImporter] Handle redecl chain of FunctionTemplateDecls

2019-02-26 Thread Aleksei Sidorin via Phabricator via cfe-commits
a_sidorin accepted this revision.
a_sidorin added a comment.
This revision is now accepted and ready to land.

Thanks for the fixes!


Repository:
  rC Clang

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

https://reviews.llvm.org/D58494



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


[PATCH] D57590: [ASTImporter] Improve import of FileID.

2019-02-26 Thread Aleksei Sidorin via Phabricator via cfe-commits
a_sidorin added a comment.

Hi Gabor,
Sorry, missed the patch. It looks mostly good, but do we have any test for this?


Repository:
  rC Clang

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

https://reviews.llvm.org/D57590



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


r354928 - [OPENMP][CUDA]Do not emit warnings for variables in late-reported asm

2019-02-26 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Tue Feb 26 13:51:16 2019
New Revision: 354928

URL: http://llvm.org/viewvc/llvm-project?rev=354928&view=rev
Log:
[OPENMP][CUDA]Do not emit warnings for variables in late-reported asm
statements.

If the assembler instruction is not generated and the delayed diagnostic
is emitted, we may end up with extra warning message for variables used
in the asm statement. Since the asm statement is not built, the
variables may be left non-referenced and it may produce a warning about
a use of the non-initialized variables.

Modified:
cfe/trunk/lib/Sema/SemaStmtAsm.cpp
cfe/trunk/test/OpenMP/nvptx_asm_delayed_diags.c
cfe/trunk/test/Sema/asm.c
cfe/trunk/test/SemaCUDA/asm_delayed_diags.cu

Modified: cfe/trunk/lib/Sema/SemaStmtAsm.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaStmtAsm.cpp?rev=354928&r1=354927&r2=354928&view=diff
==
--- cfe/trunk/lib/Sema/SemaStmtAsm.cpp (original)
+++ cfe/trunk/lib/Sema/SemaStmtAsm.cpp Tue Feb 26 13:51:16 2019
@@ -262,10 +262,15 @@ StmtResult Sema::ActOnGCCAsmStmt(SourceL
   OutputName = Names[i]->getName();
 
 TargetInfo::ConstraintInfo Info(Literal->getString(), OutputName);
-if (!Context.getTargetInfo().validateOutputConstraint(Info))
-  return StmtResult(targetDiag(Literal->getBeginLoc(),
-   diag::err_asm_invalid_output_constraint)
-<< Info.getConstraintStr());
+if (!Context.getTargetInfo().validateOutputConstraint(Info)) {
+  targetDiag(Literal->getBeginLoc(),
+ diag::err_asm_invalid_output_constraint)
+  << Info.getConstraintStr();
+  return new (Context)
+  GCCAsmStmt(Context, AsmLoc, IsSimple, IsVolatile, NumOutputs,
+ NumInputs, Names, Constraints, Exprs.data(), AsmString,
+ NumClobbers, Clobbers, RParenLoc);
+}
 
 ExprResult ER = CheckPlaceholderExpr(Exprs[i]);
 if (ER.isInvalid())
@@ -318,10 +323,15 @@ StmtResult Sema::ActOnGCCAsmStmt(SourceL
 }
 
 unsigned Size = Context.getTypeSize(OutputExpr->getType());
-if (!Context.getTargetInfo().validateOutputSize(Literal->getString(), 
Size))
-  return StmtResult(targetDiag(OutputExpr->getBeginLoc(),
-   diag::err_asm_invalid_output_size)
-<< Info.getConstraintStr());
+if (!Context.getTargetInfo().validateOutputSize(Literal->getString(),
+Size)) {
+  targetDiag(OutputExpr->getBeginLoc(), diag::err_asm_invalid_output_size)
+  << Info.getConstraintStr();
+  return new (Context)
+  GCCAsmStmt(Context, AsmLoc, IsSimple, IsVolatile, NumOutputs,
+ NumInputs, Names, Constraints, Exprs.data(), AsmString,
+ NumClobbers, Clobbers, RParenLoc);
+}
   }
 
   SmallVector InputConstraintInfos;
@@ -337,9 +347,12 @@ StmtResult Sema::ActOnGCCAsmStmt(SourceL
 TargetInfo::ConstraintInfo Info(Literal->getString(), InputName);
 if (!Context.getTargetInfo().validateInputConstraint(OutputConstraintInfos,
  Info)) {
-  return StmtResult(targetDiag(Literal->getBeginLoc(),
-   diag::err_asm_invalid_input_constraint)
-<< Info.getConstraintStr());
+  targetDiag(Literal->getBeginLoc(), 
diag::err_asm_invalid_input_constraint)
+  << Info.getConstraintStr();
+  return new (Context)
+  GCCAsmStmt(Context, AsmLoc, IsSimple, IsVolatile, NumOutputs,
+ NumInputs, Names, Constraints, Exprs.data(), AsmString,
+ NumClobbers, Clobbers, RParenLoc);
 }
 
 ExprResult ER = CheckPlaceholderExpr(Exprs[i]);
@@ -423,10 +436,14 @@ StmtResult Sema::ActOnGCCAsmStmt(SourceL
 
 StringRef Clobber = Literal->getString();
 
-if (!Context.getTargetInfo().isValidClobber(Clobber))
-  return StmtResult(targetDiag(Literal->getBeginLoc(),
-   diag::err_asm_unknown_register_name)
-<< Clobber);
+if (!Context.getTargetInfo().isValidClobber(Clobber)) {
+  targetDiag(Literal->getBeginLoc(), diag::err_asm_unknown_register_name)
+  << Clobber;
+  return new (Context)
+  GCCAsmStmt(Context, AsmLoc, IsSimple, IsVolatile, NumOutputs,
+ NumInputs, Names, Constraints, Exprs.data(), AsmString,
+ NumClobbers, Clobbers, RParenLoc);
+}
   }
 
   GCCAsmStmt *NS =
@@ -437,10 +454,11 @@ StmtResult Sema::ActOnGCCAsmStmt(SourceL
   // have.
   SmallVector Pieces;
   unsigned DiagOffs;
-  if (unsigned DiagID = NS->AnalyzeAsmString(Pieces, Context, DiagOffs))
-return StmtResult(
-targetDiag(getLocationOfStringLiteralByte(AsmString, DiagOffs), DiagID)
-<< AsmString->getSourceRange(

[PATCH] D57716: [CUDA][HIP] Check calling convention based on function target

2019-02-26 Thread Artem Belevich via Phabricator via cfe-commits
tra accepted this revision.
tra added a comment.
This revision is now accepted and ready to land.

LGTM.


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

https://reviews.llvm.org/D57716



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


[PATCH] D57590: [ASTImporter] Improve import of FileID.

2019-02-26 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik accepted this revision.
shafik added a comment.
This revision is now accepted and ready to land.

LGTM I don't see any LLDB test regressions but I would prefer another reviewer 
as well.

I am going to be modifying this soon to fix some issues w/ handling built-ins.


Repository:
  rC Clang

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

https://reviews.llvm.org/D57590



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


[PATCH] D46421: [analyzer][CrossTU] Extend CTU to VarDecls with initializer

2019-02-26 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.
Herald added a subscriber: Charusso.

In D46421#1382017 , @martong wrote:

> > I think you should change back to getInit()
>
> I am not entirely sure about this because the initalizer may not be attached 
> to the canonical decl. `getInit()` gives the initializer of one given 
> specific Decl, however, `getAnyInitializer()` searches through the whole 
> redecl chain.


Ugh, indeed. `getDefinition()` is also not the thing we're looking for. What a 
mess :) Tests are welcome!~

P.S. I don't intend to block this patch; you guys know your stuff, i'm just 
displaying a bit of curiosity and observing how it unfolds.


Repository:
  rC Clang

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

https://reviews.llvm.org/D46421



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


r354925 - [OPENMP]Delay emission for unsupported va_arg expression.

2019-02-26 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Tue Feb 26 12:52:16 2019
New Revision: 354925

URL: http://llvm.org/viewvc/llvm-project?rev=354925&view=rev
Log:
[OPENMP]Delay emission for unsupported va_arg expression.

If the OpenMP device is NVPTX and va_arg is used, delay emission of the
error for va_arg unless it is used in the device code.

Added:
cfe/trunk/test/OpenMP/nvptx_va_arg_delayed_diags.c
Modified:
cfe/trunk/lib/Sema/SemaExpr.cpp

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=354925&r1=354924&r2=354925&view=diff
==
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Tue Feb 26 12:52:16 2019
@@ -13909,6 +13909,11 @@ ExprResult Sema::BuildVAArgExpr(SourceLo
 }
   }
 
+  // NVPTX does not support va_arg expression.
+  if (getLangOpts().OpenMP && getLangOpts().OpenMPIsDevice &&
+  Context.getTargetInfo().getTriple().isNVPTX())
+targetDiag(E->getBeginLoc(), diag::err_va_arg_in_device);
+
   // It might be a __builtin_ms_va_list. (But don't ever mark a va_arg()
   // as Microsoft ABI on an actual Microsoft platform, where
   // __builtin_ms_va_list and __builtin_va_list are the same.)

Added: cfe/trunk/test/OpenMP/nvptx_va_arg_delayed_diags.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/nvptx_va_arg_delayed_diags.c?rev=354925&view=auto
==
--- cfe/trunk/test/OpenMP/nvptx_va_arg_delayed_diags.c (added)
+++ cfe/trunk/test/OpenMP/nvptx_va_arg_delayed_diags.c Tue Feb 26 12:52:16 2019
@@ -0,0 +1,40 @@
+// RUN: %clang_cc1 -fopenmp -x c -triple i386-unknown-unknown 
-fopenmp-targets=nvptx-nvidia-cuda -emit-llvm-bc %s -o %t-x86-host.bc
+// RUN: %clang_cc1 -verify -fopenmp -x c -triple nvptx-unknown-unknown 
-fopenmp-targets=nvptx-nvidia-cuda %s -fopenmp-is-device 
-fopenmp-host-ir-file-path %t-x86-host.bc -fsyntax-only
+// RUN: %clang_cc1 -verify -DDIAGS -DIMMEDIATE -fopenmp -x c -triple 
nvptx-unknown-unknown -fopenmp-targets=nvptx-nvidia-cuda %s -fopenmp-is-device 
-fopenmp-host-ir-file-path %t-x86-host.bc -fsyntax-only
+// RUN: %clang_cc1 -verify -DDIAGS -DDELAYED -fopenmp -x c -triple 
nvptx-unknown-unknown -fopenmp-targets=nvptx-nvidia-cuda %s -fopenmp-is-device 
-fopenmp-host-ir-file-path %t-x86-host.bc -fsyntax-only
+// REQUIRES: x86-registered-target
+// REQUIRES: nvptx-registered-target
+
+#ifndef DIAGS
+// expected-no-diagnostics
+#endif // DIAGS
+
+#ifdef IMMEDIATE
+#pragma omp declare target
+#endif //IMMEDIATE
+void t1(int r, ...) {
+#ifdef DIAGS
+// expected-error@+4 {{CUDA device code does not support va_arg}}
+#endif // DIAGS
+  __builtin_va_list list;
+  __builtin_va_start(list, r);
+  (void)__builtin_va_arg(list, int);
+  __builtin_va_end(list);
+}
+
+#ifdef IMMEDIATE
+#pragma omp end declare target
+#endif //IMMEDIATE
+
+int main() {
+#ifdef DELAYED
+#pragma omp target
+#endif // DELAYED
+  {
+#ifdef DELAYED
+// expected-note@+2 {{called by 'main'}}
+#endif // DELAYED
+t1(0);
+  }
+  return 0;
+}


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


[PATCH] D58691: [MS] Don't emit coverage for deleting dtors

2019-02-26 Thread Reid Kleckner via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL354924: [MS] Don't emit coverage for deleting dtors 
(authored by rnk, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D58691?vs=188434&id=188444#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D58691

Files:
  cfe/trunk/lib/CodeGen/CodeGenPGO.cpp
  cfe/trunk/test/Profile/cxx-abc-deleting-dtor.cpp

Index: cfe/trunk/test/Profile/cxx-abc-deleting-dtor.cpp
===
--- cfe/trunk/test/Profile/cxx-abc-deleting-dtor.cpp
+++ cfe/trunk/test/Profile/cxx-abc-deleting-dtor.cpp
@@ -0,0 +1,83 @@
+// RUN: %clang_cc1 -emit-llvm %s -std=c++11 -o - -fno-rtti \
+// RUN: -fprofile-instrument=clang -fcoverage-mapping -disable-llvm-passes \
+// RUN: -triple=x86_64-windows-msvc | FileCheck %s --check-prefix=MSVC
+// RUN: %clang_cc1 -emit-llvm %s -std=c++11 -o - -fno-rtti \
+// RUN: -fprofile-instrument=clang -fcoverage-mapping -disable-llvm-passes \
+// RUN: -triple=x86_64-linux-gnu | FileCheck %s --check-prefix=LINUX
+
+// Check that clang doesn't emit counters or __profn_ variables for deleting
+// destructor variants in both C++ ABIs.
+
+struct ABC {
+  virtual ~ABC() = default;
+  virtual void pure() = 0;
+};
+struct DerivedABC : ABC {
+  ~DerivedABC() override = default;
+  void pure() override {}
+};
+DerivedABC *useABCVTable() { return new DerivedABC(); }
+
+// MSVC-NOT: @"__profn_??_G{{.*}}" =
+// MSVC: @"__profn_??1DerivedABC@@{{.*}}" =
+// MSVC-NOT: @"__profn_??_G{{.*}}" =
+// MSVC: @"__profn_??1ABC@@{{.*}}" =
+// MSVC-NOT: @"__profn_??_G{{.*}}" =
+
+// MSVC-LABEL: define linkonce_odr dso_local i8* @"??_GDerivedABC@@UEAAPEAXI@Z"(%struct.DerivedABC* %this, {{.*}})
+// MSVC-NOT:   call void @llvm.instrprof.increment({{.*}})
+// MSVC:   call void @"??1DerivedABC@@UEAA@XZ"({{.*}})
+// MSVC:   ret void
+
+// MSVC-LABEL: define linkonce_odr dso_local i8* @"??_GABC@@UEAAPEAXI@Z"(%struct.ABC* %this, {{.*}})
+// MSVC-NOT:   call void @llvm.instrprof.increment({{.*}})
+// MSVC:   call void @llvm.trap()
+// MSVC-NEXT:   unreachable
+
+// MSVC-LABEL: define linkonce_odr dso_local void @"??1DerivedABC@@UEAA@XZ"({{.*}})
+// MSVC:   call void @llvm.instrprof.increment({{.*}})
+// MSVC:   call void @"??1ABC@@UEAA@XZ"({{.*}})
+// MSVC:   ret void
+
+// MSVC-LABEL: define linkonce_odr dso_local void @"??1ABC@@UEAA@XZ"({{.*}})
+// MSVC:   call void @llvm.instrprof.increment({{.*}})
+// MSVC:   ret void
+
+
+// D2 is the base, D1 and D0 are deleting and complete dtors.
+
+// LINUX-NOT: @__profn_{{.*D[01]Ev}} =
+// LINUX: @__profn__ZN10DerivedABCD2Ev =
+// LINUX-NOT: @__profn_{{.*D[01]Ev}} =
+// LINUX: @__profn__ZN3ABCD2Ev =
+// LINUX-NOT: @__profn_{{.*D[01]Ev}} =
+
+// LINUX-LABEL: define linkonce_odr void @_ZN10DerivedABCD1Ev(%struct.DerivedABC* %this)
+// LINUX-NOT:   call void @llvm.instrprof.increment({{.*}})
+// LINUX:   call void @_ZN10DerivedABCD2Ev({{.*}})
+// LINUX:   ret void
+
+// LINUX-LABEL: define linkonce_odr void @_ZN10DerivedABCD0Ev(%struct.DerivedABC* %this)
+// LINUX-NOT:   call void @llvm.instrprof.increment({{.*}})
+// LINUX:   call void @_ZN10DerivedABCD1Ev({{.*}})
+// LINUX:   call void @_ZdlPv({{.*}})
+// LINUX:   ret void
+
+// LINUX-LABEL: define linkonce_odr void @_ZN3ABCD1Ev(%struct.ABC* %this)
+// LINUX-NOT:   call void @llvm.instrprof.increment({{.*}})
+// LINUX:   call void @llvm.trap()
+// LINUX-NEXT:   unreachable
+
+// LINUX-LABEL: define linkonce_odr void @_ZN3ABCD0Ev(%struct.ABC* %this)
+// LINUX-NOT:   call void @llvm.instrprof.increment({{.*}})
+// LINUX:   call void @llvm.trap()
+// LINUX-NEXT:   unreachable
+
+// LINUX-LABEL: define linkonce_odr void @_ZN10DerivedABCD2Ev(%struct.DerivedABC* %this)
+// LINUX:   call void @llvm.instrprof.increment({{.*}})
+// LINUX:   call void @_ZN3ABCD2Ev({{.*}})
+// LINUX:   ret void
+
+// LINUX-LABEL: define linkonce_odr void @_ZN3ABCD2Ev(%struct.ABC* %this)
+// LINUX:   call void @llvm.instrprof.increment({{.*}})
+// LINUX:   ret void
Index: cfe/trunk/lib/CodeGen/CodeGenPGO.cpp
===
--- cfe/trunk/lib/CodeGen/CodeGenPGO.cpp
+++ cfe/trunk/lib/CodeGen/CodeGenPGO.cpp
@@ -771,14 +771,14 @@
   // If so, instrument only base variant, others are implemented by delegation
   // to the base one, it would be counted twice otherwise.
   if (CGM.getTarget().getCXXABI().hasConstructorVariants()) {
-if (isa(D) && GD.getDtorType() != Dtor_Base)
-  return;
-
 if (const auto *CCD = dyn_cast(D))
   if (GD.getCtorType() != Ctor_Base &&
   CodeGenFunction::IsConstructorDelegationValid(CCD))
 return;
   }
+  if (isa(D) && GD.getDtorType() != Dtor_Base)
+return;
+
   CGM.ClearUnusedCoverageMapping(D);
   setFuncName(Fn);
 

r354924 - [MS] Don't emit coverage for deleting dtors

2019-02-26 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Tue Feb 26 12:42:52 2019
New Revision: 354924

URL: http://llvm.org/viewvc/llvm-project?rev=354924&view=rev
Log:
[MS] Don't emit coverage for deleting dtors

Summary:
The MS C++ ABI has no constructor variants, but it has destructor
variants, so we should move the deleting destructor variant check
outside the check for "does the ABI have constructor variants".

Fixes PR37561, so basic code coverage works on Windows with C++.

Reviewers: vsk

Subscribers: jdoerfert, cfe-commits

Tags: #clang

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

Added:
cfe/trunk/test/Profile/cxx-abc-deleting-dtor.cpp
Modified:
cfe/trunk/lib/CodeGen/CodeGenPGO.cpp

Modified: cfe/trunk/lib/CodeGen/CodeGenPGO.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenPGO.cpp?rev=354924&r1=354923&r2=354924&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenPGO.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenPGO.cpp Tue Feb 26 12:42:52 2019
@@ -771,14 +771,14 @@ void CodeGenPGO::assignRegionCounters(Gl
   // If so, instrument only base variant, others are implemented by delegation
   // to the base one, it would be counted twice otherwise.
   if (CGM.getTarget().getCXXABI().hasConstructorVariants()) {
-if (isa(D) && GD.getDtorType() != Dtor_Base)
-  return;
-
 if (const auto *CCD = dyn_cast(D))
   if (GD.getCtorType() != Ctor_Base &&
   CodeGenFunction::IsConstructorDelegationValid(CCD))
 return;
   }
+  if (isa(D) && GD.getDtorType() != Dtor_Base)
+return;
+
   CGM.ClearUnusedCoverageMapping(D);
   setFuncName(Fn);
 

Added: cfe/trunk/test/Profile/cxx-abc-deleting-dtor.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Profile/cxx-abc-deleting-dtor.cpp?rev=354924&view=auto
==
--- cfe/trunk/test/Profile/cxx-abc-deleting-dtor.cpp (added)
+++ cfe/trunk/test/Profile/cxx-abc-deleting-dtor.cpp Tue Feb 26 12:42:52 2019
@@ -0,0 +1,83 @@
+// RUN: %clang_cc1 -emit-llvm %s -std=c++11 -o - -fno-rtti \
+// RUN: -fprofile-instrument=clang -fcoverage-mapping -disable-llvm-passes 
\
+// RUN: -triple=x86_64-windows-msvc | FileCheck %s --check-prefix=MSVC
+// RUN: %clang_cc1 -emit-llvm %s -std=c++11 -o - -fno-rtti \
+// RUN: -fprofile-instrument=clang -fcoverage-mapping -disable-llvm-passes 
\
+// RUN: -triple=x86_64-linux-gnu | FileCheck %s --check-prefix=LINUX
+
+// Check that clang doesn't emit counters or __profn_ variables for deleting
+// destructor variants in both C++ ABIs.
+
+struct ABC {
+  virtual ~ABC() = default;
+  virtual void pure() = 0;
+};
+struct DerivedABC : ABC {
+  ~DerivedABC() override = default;
+  void pure() override {}
+};
+DerivedABC *useABCVTable() { return new DerivedABC(); }
+
+// MSVC-NOT: @"__profn_??_G{{.*}}" =
+// MSVC: @"__profn_??1DerivedABC@@{{.*}}" =
+// MSVC-NOT: @"__profn_??_G{{.*}}" =
+// MSVC: @"__profn_??1ABC@@{{.*}}" =
+// MSVC-NOT: @"__profn_??_G{{.*}}" =
+
+// MSVC-LABEL: define linkonce_odr dso_local i8* 
@"??_GDerivedABC@@UEAAPEAXI@Z"(%struct.DerivedABC* %this, {{.*}})
+// MSVC-NOT:   call void @llvm.instrprof.increment({{.*}})
+// MSVC:   call void @"??1DerivedABC@@UEAA@XZ"({{.*}})
+// MSVC:   ret void
+
+// MSVC-LABEL: define linkonce_odr dso_local i8* 
@"??_GABC@@UEAAPEAXI@Z"(%struct.ABC* %this, {{.*}})
+// MSVC-NOT:   call void @llvm.instrprof.increment({{.*}})
+// MSVC:   call void @llvm.trap()
+// MSVC-NEXT:   unreachable
+
+// MSVC-LABEL: define linkonce_odr dso_local void 
@"??1DerivedABC@@UEAA@XZ"({{.*}})
+// MSVC:   call void @llvm.instrprof.increment({{.*}})
+// MSVC:   call void @"??1ABC@@UEAA@XZ"({{.*}})
+// MSVC:   ret void
+
+// MSVC-LABEL: define linkonce_odr dso_local void @"??1ABC@@UEAA@XZ"({{.*}})
+// MSVC:   call void @llvm.instrprof.increment({{.*}})
+// MSVC:   ret void
+
+
+// D2 is the base, D1 and D0 are deleting and complete dtors.
+
+// LINUX-NOT: @__profn_{{.*D[01]Ev}} =
+// LINUX: @__profn__ZN10DerivedABCD2Ev =
+// LINUX-NOT: @__profn_{{.*D[01]Ev}} =
+// LINUX: @__profn__ZN3ABCD2Ev =
+// LINUX-NOT: @__profn_{{.*D[01]Ev}} =
+
+// LINUX-LABEL: define linkonce_odr void 
@_ZN10DerivedABCD1Ev(%struct.DerivedABC* %this)
+// LINUX-NOT:   call void @llvm.instrprof.increment({{.*}})
+// LINUX:   call void @_ZN10DerivedABCD2Ev({{.*}})
+// LINUX:   ret void
+
+// LINUX-LABEL: define linkonce_odr void 
@_ZN10DerivedABCD0Ev(%struct.DerivedABC* %this)
+// LINUX-NOT:   call void @llvm.instrprof.increment({{.*}})
+// LINUX:   call void @_ZN10DerivedABCD1Ev({{.*}})
+// LINUX:   call void @_ZdlPv({{.*}})
+// LINUX:   ret void
+
+// LINUX-LABEL: define linkonce_odr void @_ZN3ABCD1Ev(%struct.ABC* %this)
+// LINUX-NOT:   call void @llvm.instrprof.increment({{.*}})
+// LINUX:   call void @llvm.trap()
+// LINUX-NEXT:   unreachable
+
+// LINUX-LABEL: define linkonce_odr void @_ZN3ABCD0Ev(%struct.ABC* %this)
+// LINUX-NOT:   call void @llvm.ins

[PATCH] D54176: [PGO] clang part of change for context-sensitive PGO.

2019-02-26 Thread David Li via Phabricator via cfe-commits
davidxl added a comment.

Please add changes to option documentation.


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

https://reviews.llvm.org/D54176



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


[PATCH] D57590: [ASTImporter] Improve import of FileID.

2019-02-26 Thread Gabor Marton via Phabricator via cfe-commits
martong added a comment.

In D57590#1411055 , @efriedma wrote:

> I don't know anything about this particular patch, but you aren't allowed to 
> set deadlines like that; the patch review process requires that the patch is 
> actually reviewed.  If you aren't getting a response, ask on cfe-dev.


Okay sorry about that, I will not commit until we get an approve. I think I was 
mislead by the "LLVM Developer Policy" 
(https://llvm.org/docs/DeveloperPolicy.html)

> Do not assume silent approval, or request active objections to the patch with 
> a deadline.

I interpreted this as after several pings setting a deadline is okay, 
especially if the patch is small and getting old.
Perhaps the policy should be updated to avoid such misinterpretation in the 
future.

Unfortunately this part of Clang (ASTImporter) has quite a few active 
developers other than my colleges. Obviously my colleges could review these 
patches (and they have done that in our fork) but we thought it would be better 
to have accept from devs of other organizations. One of the clients of 
ASTImporter is cross translation unit (CTU) static analysis, the other is LLDB. 
We hope to have more users and developers of CTU by reaching a point where it 
is mature enough to attract more developers. At the moment CTU analysis is not 
successful even on a simple C project like tmux with the upstream master. But 
that is successful on complex C++ projects like protobuf since a long time in 
our fork. Upstreaming to master takes painfully too much time. Our fork is 
already ahead at least 25 commits and it is growing.


Repository:
  rC Clang

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

https://reviews.llvm.org/D57590



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


[PATCH] D58691: [MS] Don't emit coverage for deleting dtors

2019-02-26 Thread Vedant Kumar via Phabricator via cfe-commits
vsk accepted this revision.
vsk added a comment.
This revision is now accepted and ready to land.

Thanks! Lgtm.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D58691



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


[PATCH] D58463: [CUDA]Delayed diagnostics for the asm instructions.

2019-02-26 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

In D58463#1411086 , @tra wrote:

> >> E.g.:
> >> 
> >>   namespace {
> >>   __host__ __device__ a() {
> >> int prev;
> >> __asm__ __volatile__("mov %0, 0" : "=a" (prev)::);
> >> return prev;
> >>   }
> >>   
> >>   __host__ __device__ b() {
> >> int prev;
> >> return prev;
> >>   }
> >>   
> >>   } //namespace
> >> 
> >> 
> >> Ideally we should always emit uninitialized diagnostics for `b`, but never 
> >> for `a` in both host and device compilation modes.
> >>  I think we may want to propagate assignment from the inline asm statement 
> >> -- we may not know the meaning of the constraint, but we do know which 
> >> argument gets used/modified by the asm statement. Perhaps we can construct 
> >> a fake GCCAsmStmt but bail out before we attempt to validate the asm 
> >> string.
> > 
> > But it is going to be emitted for b() if b() is really used on the host or 
> > on the device.
>
> Clang also emits the uninitialized warnings for `b` when it is not used -- as 
> in the example above.
>  I'm OK with that as `b` is a valid function on both sides.
>
> Suppressing uninitialized warning in this case would be wrong, IMO -- that 
> would diverge from what clang would do if `b` didn't have `__host__ 
> __device__` attributes.
>
> > For a() the warning is going to be emitted only if it is really used on 
> > device, otherwise it is not.
>
>
>
> > Instead, we can try to do what we did before: construct GCCAsmStmt object, 
> > just like you said. What option do you prefer?
>
> I think creating a GCCAsmStmt() is the right way to deal with this as it 
> gives compiler the correct (well, as correct as we can at that point) info 
> about the code, as opposed to giving compiler broken pieces and trying to 
> suppress the fallout.


Ok, will prepare a fix shortly.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D58463



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


[PATCH] D58463: [CUDA]Delayed diagnostics for the asm instructions.

2019-02-26 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

>> E.g.:
>> 
>>   namespace {
>>   __host__ __device__ a() {
>> int prev;
>> __asm__ __volatile__("mov %0, 0" : "=a" (prev)::);
>> return prev;
>>   }
>>   
>>   __host__ __device__ b() {
>> int prev;
>> return prev;
>>   }
>>   
>>   } //namespace
>> 
>> 
>> Ideally we should always emit uninitialized diagnostics for `b`, but never 
>> for `a` in both host and device compilation modes.
>>  I think we may want to propagate assignment from the inline asm statement 
>> -- we may not know the meaning of the constraint, but we do know which 
>> argument gets used/modified by the asm statement. Perhaps we can construct a 
>> fake GCCAsmStmt but bail out before we attempt to validate the asm string.
> 
> But it is going to be emitted for b() if b() is really used on the host or on 
> the device.

Clang also emits the uninitialized warnings for `b` when it is not used -- as 
in the example above.
I'm OK with that as `b` is a valid function on both sides.

Suppressing uninitialized warning in this case would be wrong, IMO -- that 
would diverge from what clang would do if `b` didn't have `__host__ __device__` 
attributes.

> For a() the warning is going to be emitted only if it is really used on 
> device, otherwise it is not.



> Instead, we can try to do what we did before: construct GCCAsmStmt object, 
> just like you said. What option do you prefer?

I think creating a GCCAsmStmt() is the right way to deal with this as it gives 
compiler the correct (well, as correct as we can at that point) info about the 
code, as opposed to giving compiler broken pieces and trying to suppress the 
fallout.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D58463



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


[PATCH] D58691: [MS] Don't emit coverage for deleting dtors

2019-02-26 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added inline comments.



Comment at: clang/test/Profile/cxx-abc-deleting-dtor.cpp:28
+// FIXME: Should we emit coverage info for deleting dtors? They do contain
+// conditional branches. LLVM IR PGO will insrument them just fine, though.
+

vsk wrote:
> Probably not. IIUC the branches aren't visible at the source-level?
You're right, they aren't, so I'll remove this.



Comment at: clang/test/Profile/cxx-abc-deleting-dtor.cpp:52
+
+// LINUX-NOT: @__profn_{{.*}}D[01]Ev =
+// LINUX: @__profn__ZN10DerivedABCD2Ev =

vsk wrote:
> Do you need {{[01]}}?
Yes, thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D58691



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


[PATCH] D58691: [MS] Don't emit coverage for deleting dtors

2019-02-26 Thread Reid Kleckner via Phabricator via cfe-commits
rnk updated this revision to Diff 188434.
rnk marked 3 inline comments as done.
rnk added a comment.

- fix CHECK-NOT
- FIXME that isn't needed


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D58691

Files:
  clang/lib/CodeGen/CodeGenPGO.cpp
  clang/test/Profile/cxx-abc-deleting-dtor.cpp

Index: clang/test/Profile/cxx-abc-deleting-dtor.cpp
===
--- /dev/null
+++ clang/test/Profile/cxx-abc-deleting-dtor.cpp
@@ -0,0 +1,83 @@
+// RUN: %clang_cc1 -emit-llvm %s -std=c++11 -o - -fno-rtti \
+// RUN: -fprofile-instrument=clang -fcoverage-mapping -disable-llvm-passes \
+// RUN: -triple=x86_64-windows-msvc | FileCheck %s --check-prefix=MSVC
+// RUN: %clang_cc1 -emit-llvm %s -std=c++11 -o - -fno-rtti \
+// RUN: -fprofile-instrument=clang -fcoverage-mapping -disable-llvm-passes \
+// RUN: -triple=x86_64-linux-gnu | FileCheck %s --check-prefix=LINUX
+
+// Check that clang doesn't emit counters or __profn_ variables for deleting
+// destructor variants in both C++ ABIs.
+
+struct ABC {
+  virtual ~ABC() = default;
+  virtual void pure() = 0;
+};
+struct DerivedABC : ABC {
+  ~DerivedABC() override = default;
+  void pure() override {}
+};
+DerivedABC *useABCVTable() { return new DerivedABC(); }
+
+// MSVC-NOT: @"__profn_??_G{{.*}}" =
+// MSVC: @"__profn_??1DerivedABC@@{{.*}}" =
+// MSVC-NOT: @"__profn_??_G{{.*}}" =
+// MSVC: @"__profn_??1ABC@@{{.*}}" =
+// MSVC-NOT: @"__profn_??_G{{.*}}" =
+
+// MSVC-LABEL: define linkonce_odr dso_local i8* @"??_GDerivedABC@@UEAAPEAXI@Z"(%struct.DerivedABC* %this, {{.*}})
+// MSVC-NOT:   call void @llvm.instrprof.increment({{.*}})
+// MSVC:   call void @"??1DerivedABC@@UEAA@XZ"({{.*}})
+// MSVC:   ret void
+
+// MSVC-LABEL: define linkonce_odr dso_local i8* @"??_GABC@@UEAAPEAXI@Z"(%struct.ABC* %this, {{.*}})
+// MSVC-NOT:   call void @llvm.instrprof.increment({{.*}})
+// MSVC:   call void @llvm.trap()
+// MSVC-NEXT:   unreachable
+
+// MSVC-LABEL: define linkonce_odr dso_local void @"??1DerivedABC@@UEAA@XZ"({{.*}})
+// MSVC:   call void @llvm.instrprof.increment({{.*}})
+// MSVC:   call void @"??1ABC@@UEAA@XZ"({{.*}})
+// MSVC:   ret void
+
+// MSVC-LABEL: define linkonce_odr dso_local void @"??1ABC@@UEAA@XZ"({{.*}})
+// MSVC:   call void @llvm.instrprof.increment({{.*}})
+// MSVC:   ret void
+
+
+// D2 is the base, D1 and D0 are deleting and complete dtors.
+
+// LINUX-NOT: @__profn_{{.*D[01]Ev}} =
+// LINUX: @__profn__ZN10DerivedABCD2Ev =
+// LINUX-NOT: @__profn_{{.*D[01]Ev}} =
+// LINUX: @__profn__ZN3ABCD2Ev =
+// LINUX-NOT: @__profn_{{.*D[01]Ev}} =
+
+// LINUX-LABEL: define linkonce_odr void @_ZN10DerivedABCD1Ev(%struct.DerivedABC* %this)
+// LINUX-NOT:   call void @llvm.instrprof.increment({{.*}})
+// LINUX:   call void @_ZN10DerivedABCD2Ev({{.*}})
+// LINUX:   ret void
+
+// LINUX-LABEL: define linkonce_odr void @_ZN10DerivedABCD0Ev(%struct.DerivedABC* %this)
+// LINUX-NOT:   call void @llvm.instrprof.increment({{.*}})
+// LINUX:   call void @_ZN10DerivedABCD1Ev({{.*}})
+// LINUX:   call void @_ZdlPv({{.*}})
+// LINUX:   ret void
+
+// LINUX-LABEL: define linkonce_odr void @_ZN3ABCD1Ev(%struct.ABC* %this)
+// LINUX-NOT:   call void @llvm.instrprof.increment({{.*}})
+// LINUX:   call void @llvm.trap()
+// LINUX-NEXT:   unreachable
+
+// LINUX-LABEL: define linkonce_odr void @_ZN3ABCD0Ev(%struct.ABC* %this)
+// LINUX-NOT:   call void @llvm.instrprof.increment({{.*}})
+// LINUX:   call void @llvm.trap()
+// LINUX-NEXT:   unreachable
+
+// LINUX-LABEL: define linkonce_odr void @_ZN10DerivedABCD2Ev(%struct.DerivedABC* %this)
+// LINUX:   call void @llvm.instrprof.increment({{.*}})
+// LINUX:   call void @_ZN3ABCD2Ev({{.*}})
+// LINUX:   ret void
+
+// LINUX-LABEL: define linkonce_odr void @_ZN3ABCD2Ev(%struct.ABC* %this)
+// LINUX:   call void @llvm.instrprof.increment({{.*}})
+// LINUX:   ret void
Index: clang/lib/CodeGen/CodeGenPGO.cpp
===
--- clang/lib/CodeGen/CodeGenPGO.cpp
+++ clang/lib/CodeGen/CodeGenPGO.cpp
@@ -771,14 +771,14 @@
   // If so, instrument only base variant, others are implemented by delegation
   // to the base one, it would be counted twice otherwise.
   if (CGM.getTarget().getCXXABI().hasConstructorVariants()) {
-if (isa(D) && GD.getDtorType() != Dtor_Base)
-  return;
-
 if (const auto *CCD = dyn_cast(D))
   if (GD.getCtorType() != Ctor_Base &&
   CodeGenFunction::IsConstructorDelegationValid(CCD))
 return;
   }
+  if (isa(D) && GD.getDtorType() != Dtor_Base)
+return;
+
   CGM.ClearUnusedCoverageMapping(D);
   setFuncName(Fn);
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D58375: [Clang][NewPM] Disable tests that are broken under new PM

2019-02-26 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

I thought the plan was to fix whatever issue was causing the -O0 tests to fail, 
then rebase on top of that?


Repository:
  rC Clang

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

https://reviews.llvm.org/D58375



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


[PATCH] D58463: [CUDA]Delayed diagnostics for the asm instructions.

2019-02-26 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

In D58463#1411039 , @tra wrote:

> > Hi Artem, I think we can just delay emission of this warning to solve this 
> > problem.
>
> I'm not sure we can always tell whether the warning is real or if it's the 
> consequence of failing to parse inline asm.
>
> E.g.:
>
>   namespace {
>   __host__ __device__ a() {
> int prev;
> __asm__ __volatile__("mov %0, 0" : "=a" (prev)::);
> return prev;
>   }
>  
>   __host__ __device__ b() {
> int prev;
> return prev;
>   }
>  
>   } //namespace
>
>
> Ideally we should always emit uninitialized diagnostics for `b`, but never 
> for `a` in both host and device compilation modes.
>  I think we may want to propagate assignment from the inline asm statement -- 
> we may not know the meaning of the constraint, but we do know which argument 
> gets used/modified by the asm statement. Perhaps we can construct a fake 
> GCCAsmStmt but bail out before we attempt to validate the asm string.


But it is going to be emitted for b() if b() is really used on the host or on 
the device. For a() the warning is going to be emitted only if it is really 
used on device, otherwise it is not.
Instead, we can try to do what we did before: construct GCCAsmStmt object, just 
like you said. What option do you prefer?


Repository:
  rL LLVM

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

https://reviews.llvm.org/D58463



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


[PATCH] D57590: [ASTImporter] Improve import of FileID.

2019-02-26 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

I don't know anything about this particular patch, but you aren't allowed to 
set deadlines like that; the patch review process requires that the patch is 
actually reviewed.  If you aren't getting a response, ask on cfe-dev.


Repository:
  rC Clang

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

https://reviews.llvm.org/D57590



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


[PATCH] D56900: [Fixed Point Arithmetic] Fixed Point and Integer Conversions

2019-02-26 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan added a comment.

@rjmccall @ebevhan @bjope *ping* any other comments on this patch?


Repository:
  rC Clang

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

https://reviews.llvm.org/D56900



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


[PATCH] D58691: [MS] Don't emit coverage for deleting dtors

2019-02-26 Thread Vedant Kumar via Phabricator via cfe-commits
vsk added inline comments.



Comment at: clang/test/Profile/cxx-abc-deleting-dtor.cpp:28
+// FIXME: Should we emit coverage info for deleting dtors? They do contain
+// conditional branches. LLVM IR PGO will insrument them just fine, though.
+

Probably not. IIUC the branches aren't visible at the source-level?



Comment at: clang/test/Profile/cxx-abc-deleting-dtor.cpp:52
+
+// LINUX-NOT: @__profn_{{.*}}D[01]Ev =
+// LINUX: @__profn__ZN10DerivedABCD2Ev =

Do you need {{[01]}}?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D58691



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


[PATCH] D58374: [Clang][NewPM] Don't bail out if the target machine is empty

2019-02-26 Thread Petr Hosek via Phabricator via cfe-commits
phosek added a comment.

Ping?


Repository:
  rC Clang

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

https://reviews.llvm.org/D58374



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


[PATCH] D58375: [Clang][NewPM] Disable tests that are broken under new PM

2019-02-26 Thread Petr Hosek via Phabricator via cfe-commits
phosek added a comment.

Ping?


Repository:
  rC Clang

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

https://reviews.llvm.org/D58375



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


[PATCH] D58463: [CUDA]Delayed diagnostics for the asm instructions.

2019-02-26 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

> Hi Artem, I think we can just delay emission of this warning to solve this 
> problem.

I'm not sure we can always tell whether the warning is real or if it's the 
consequence of failing to parse inline asm.

E.g.:

  namespace {
  __host__ __device__ a() {
int prev;
__asm__ __volatile__("mov %0, 0" : "=a" (prev)::);
return prev;
  }
  
  __host__ __device__ b() {
int prev;
return prev;
  }
  
  } //namespace

Ideally we should always emit uninitialized diagnostics for `b`, but never for 
`a` in both host and device compilation modes.
I think we may want to propagate assignment from the inline asm statement -- we 
may not know the meaning of the constraint, but we do know which argument gets 
used/modified by the asm statement. Perhaps we can construct a fake GCCAsmStmt 
but bail out before we attempt to validate the asm string.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D58463



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


[PATCH] D57628: [index] Improve indexing support for MSPropertyDecl.

2019-02-26 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai added a comment.
Herald added a subscriber: jdoerfert.

Ping.


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

https://reviews.llvm.org/D57628



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


[PATCH] D58663: [ASTImporter] Add support for importing ChooseExpr AST nodes.

2019-02-26 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

Sounds good, thanks for debugging this.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D58663



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


RE: r354915 - [X86] Add 'znver2' and 'cascadelake' to the __builtin_cpu_is test.

2019-02-26 Thread Topper, Craig via cfe-commits
You're right. It was already there after Ganesh's patch this morning. I hadn't 
updated my clang tree so I thought it was missing. Sorry.

-Original Message-
From: Roman Lebedev [mailto:lebedev...@gmail.com] 
Sent: Tuesday, February 26, 2019 11:29 AM
To: Topper, Craig 
Cc: cfe-commits@lists.llvm.org
Subject: Re: r354915 - [X86] Add 'znver2' and 'cascadelake' to the 
__builtin_cpu_is test.

Doesn't look like this patch added 'znver2'?

On Tue, Feb 26, 2019 at 10:20 PM Craig Topper via cfe-commits
 wrote:
>
> Author: ctopper
> Date: Tue Feb 26 11:20:04 2019
> New Revision: 354915
>
> URL: http://llvm.org/viewvc/llvm-project?rev=354915&view=rev
> Log:
> [X86] Add 'znver2' and 'cascadelake' to the __builtin_cpu_is test.
>
> These are supported by at least libgcc trunk so we can include them now.
>
> Modified:
> cfe/trunk/test/CodeGen/target-builtin-noerror.c
>
> Modified: cfe/trunk/test/CodeGen/target-builtin-noerror.c
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/target-builtin-noerror.c?rev=354915&r1=354914&r2=354915&view=diff
> ==
> --- cfe/trunk/test/CodeGen/target-builtin-noerror.c (original)
> +++ cfe/trunk/test/CodeGen/target-builtin-noerror.c Tue Feb 26 11:20:04 2019
> @@ -98,6 +98,7 @@ void verifycpustrings() {
>(void)__builtin_cpu_is("btver1");
>(void)__builtin_cpu_is("btver2");
>(void)__builtin_cpu_is("cannonlake");
> +  (void)__builtin_cpu_is("cascadelake");
>(void)__builtin_cpu_is("core2");
>(void)__builtin_cpu_is("corei7");
>(void)__builtin_cpu_is("goldmont");
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D58691: [MS] Don't emit coverage for deleting dtors

2019-02-26 Thread Reid Kleckner via Phabricator via cfe-commits
rnk created this revision.
rnk added a reviewer: vsk.
Herald added a subscriber: jdoerfert.
Herald added a project: clang.

The MS C++ ABI has no constructor variants, but it has destructor
variants, so we should move the deleting destructor variant check
outside the check for "does the ABI have constructor variants".

Fixes PR37561, so basic code coverage works on Windows with C++.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D58691

Files:
  clang/lib/CodeGen/CodeGenPGO.cpp
  clang/test/Profile/cxx-abc-deleting-dtor.cpp

Index: clang/test/Profile/cxx-abc-deleting-dtor.cpp
===
--- /dev/null
+++ clang/test/Profile/cxx-abc-deleting-dtor.cpp
@@ -0,0 +1,86 @@
+// RUN: %clang_cc1 -emit-llvm %s -std=c++11 -o - -fno-rtti \
+// RUN: -fprofile-instrument=clang -fcoverage-mapping -disable-llvm-passes \
+// RUN: -triple=x86_64-windows-msvc | FileCheck %s --check-prefix=MSVC
+// RUN: %clang_cc1 -emit-llvm %s -std=c++11 -o - -fno-rtti \
+// RUN: -fprofile-instrument=clang -fcoverage-mapping -disable-llvm-passes \
+// RUN: -triple=x86_64-linux-gnu | FileCheck %s --check-prefix=LINUX
+
+// Check that clang doesn't emit counters or __profn_ variables for deleting
+// destructor variants in both C++ ABIs.
+
+struct ABC {
+  virtual ~ABC() = default;
+  virtual void pure() = 0;
+};
+struct DerivedABC : ABC {
+  ~DerivedABC() override = default;
+  void pure() override {}
+};
+DerivedABC *useABCVTable() { return new DerivedABC(); }
+
+// MSVC-NOT: @"__profn_??_G{{.*}}" =
+// MSVC: @"__profn_??1DerivedABC@@{{.*}}" =
+// MSVC-NOT: @"__profn_??_G{{.*}}" =
+// MSVC: @"__profn_??1ABC@@{{.*}}" =
+// MSVC-NOT: @"__profn_??_G{{.*}}" =
+
+// FIXME: Should we emit coverage info for deleting dtors? They do contain
+// conditional branches. LLVM IR PGO will insrument them just fine, though.
+
+// MSVC-LABEL: define linkonce_odr dso_local i8* @"??_GDerivedABC@@UEAAPEAXI@Z"(%struct.DerivedABC* %this, {{.*}})
+// MSVC-NOT:   call void @llvm.instrprof.increment({{.*}})
+// MSVC:   call void @"??1DerivedABC@@UEAA@XZ"({{.*}})
+// MSVC:   ret void
+
+// MSVC-LABEL: define linkonce_odr dso_local i8* @"??_GABC@@UEAAPEAXI@Z"(%struct.ABC* %this, {{.*}})
+// MSVC-NOT:   call void @llvm.instrprof.increment({{.*}})
+// MSVC:   call void @llvm.trap()
+// MSVC-NEXT:   unreachable
+
+// MSVC-LABEL: define linkonce_odr dso_local void @"??1DerivedABC@@UEAA@XZ"({{.*}})
+// MSVC:   call void @llvm.instrprof.increment({{.*}})
+// MSVC:   call void @"??1ABC@@UEAA@XZ"({{.*}})
+// MSVC:   ret void
+
+// MSVC-LABEL: define linkonce_odr dso_local void @"??1ABC@@UEAA@XZ"({{.*}})
+// MSVC:   call void @llvm.instrprof.increment({{.*}})
+// MSVC:   ret void
+
+
+// D2 is the base, D1 and D0 are deleting and complete dtors.
+
+// LINUX-NOT: @__profn_{{.*}}D[01]Ev =
+// LINUX: @__profn__ZN10DerivedABCD2Ev =
+// LINUX-NOT: @__profn_{{.*}}D[01]Ev =
+// LINUX: @__profn__ZN3ABCD2Ev =
+// LINUX-NOT: @__profn_{{.*}}D[01]Ev =
+
+// LINUX-LABEL: define linkonce_odr void @_ZN10DerivedABCD1Ev(%struct.DerivedABC* %this)
+// LINUX-NOT:   call void @llvm.instrprof.increment({{.*}})
+// LINUX:   call void @_ZN10DerivedABCD2Ev({{.*}})
+// LINUX:   ret void
+
+// LINUX-LABEL: define linkonce_odr void @_ZN10DerivedABCD0Ev(%struct.DerivedABC* %this)
+// LINUX-NOT:   call void @llvm.instrprof.increment({{.*}})
+// LINUX:   call void @_ZN10DerivedABCD1Ev({{.*}})
+// LINUX:   call void @_ZdlPv({{.*}})
+// LINUX:   ret void
+
+// LINUX-LABEL: define linkonce_odr void @_ZN3ABCD1Ev(%struct.ABC* %this)
+// LINUX-NOT:   call void @llvm.instrprof.increment({{.*}})
+// LINUX:   call void @llvm.trap()
+// LINUX-NEXT:   unreachable
+
+// LINUX-LABEL: define linkonce_odr void @_ZN3ABCD0Ev(%struct.ABC* %this)
+// LINUX-NOT:   call void @llvm.instrprof.increment({{.*}})
+// LINUX:   call void @llvm.trap()
+// LINUX-NEXT:   unreachable
+
+// LINUX-LABEL: define linkonce_odr void @_ZN10DerivedABCD2Ev(%struct.DerivedABC* %this)
+// LINUX:   call void @llvm.instrprof.increment({{.*}})
+// LINUX:   call void @_ZN3ABCD2Ev({{.*}})
+// LINUX:   ret void
+
+// LINUX-LABEL: define linkonce_odr void @_ZN3ABCD2Ev(%struct.ABC* %this)
+// LINUX:   call void @llvm.instrprof.increment({{.*}})
+// LINUX:   ret void
Index: clang/lib/CodeGen/CodeGenPGO.cpp
===
--- clang/lib/CodeGen/CodeGenPGO.cpp
+++ clang/lib/CodeGen/CodeGenPGO.cpp
@@ -771,14 +771,14 @@
   // If so, instrument only base variant, others are implemented by delegation
   // to the base one, it would be counted twice otherwise.
   if (CGM.getTarget().getCXXABI().hasConstructorVariants()) {
-if (isa(D) && GD.getDtorType() != Dtor_Base)
-  return;
-
 if (const auto *CCD = dyn_cast(D))
   if (GD.getCtorType() != Ctor_Base &&
   CodeGenFunction::IsConstructorDelegationValid(CCD))
 return;
   }
+  if (isa(D) && GD.getDtorType() != Dtor_Base)
+return;
+
   CGM.Cle

Re: r354915 - [X86] Add 'znver2' and 'cascadelake' to the __builtin_cpu_is test.

2019-02-26 Thread Roman Lebedev via cfe-commits
Doesn't look like this patch added 'znver2'?

On Tue, Feb 26, 2019 at 10:20 PM Craig Topper via cfe-commits
 wrote:
>
> Author: ctopper
> Date: Tue Feb 26 11:20:04 2019
> New Revision: 354915
>
> URL: http://llvm.org/viewvc/llvm-project?rev=354915&view=rev
> Log:
> [X86] Add 'znver2' and 'cascadelake' to the __builtin_cpu_is test.
>
> These are supported by at least libgcc trunk so we can include them now.
>
> Modified:
> cfe/trunk/test/CodeGen/target-builtin-noerror.c
>
> Modified: cfe/trunk/test/CodeGen/target-builtin-noerror.c
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/target-builtin-noerror.c?rev=354915&r1=354914&r2=354915&view=diff
> ==
> --- cfe/trunk/test/CodeGen/target-builtin-noerror.c (original)
> +++ cfe/trunk/test/CodeGen/target-builtin-noerror.c Tue Feb 26 11:20:04 2019
> @@ -98,6 +98,7 @@ void verifycpustrings() {
>(void)__builtin_cpu_is("btver1");
>(void)__builtin_cpu_is("btver2");
>(void)__builtin_cpu_is("cannonlake");
> +  (void)__builtin_cpu_is("cascadelake");
>(void)__builtin_cpu_is("core2");
>(void)__builtin_cpu_is("corei7");
>(void)__builtin_cpu_is("goldmont");
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D58663: [ASTImporter] Add support for importing ChooseExpr AST nodes.

2019-02-26 Thread Tom Roeder via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rL354916: [ASTImporter] Add support for importing ChooseExpr 
AST nodes. (authored by tmroeder, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D58663?vs=188397&id=188425#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D58663

Files:
  cfe/trunk/docs/LibASTMatchersReference.html
  cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
  cfe/trunk/lib/AST/ASTImporter.cpp
  cfe/trunk/lib/ASTMatchers/ASTMatchersInternal.cpp
  cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
  cfe/trunk/test/ASTMerge/choose-expr/Inputs/choose.c
  cfe/trunk/test/ASTMerge/choose-expr/test.c
  cfe/trunk/unittests/AST/ASTImporterTest.cpp
  cfe/trunk/unittests/ASTMatchers/ASTMatchersNodeTest.cpp

Index: cfe/trunk/lib/AST/ASTImporter.cpp
===
--- cfe/trunk/lib/AST/ASTImporter.cpp
+++ cfe/trunk/lib/AST/ASTImporter.cpp
@@ -552,6 +552,7 @@
 // Importing expressions
 ExpectedStmt VisitExpr(Expr *E);
 ExpectedStmt VisitVAArgExpr(VAArgExpr *E);
+ExpectedStmt VisitChooseExpr(ChooseExpr *E);
 ExpectedStmt VisitGNUNullExpr(GNUNullExpr *E);
 ExpectedStmt VisitPredefinedExpr(PredefinedExpr *E);
 ExpectedStmt VisitDeclRefExpr(DeclRefExpr *E);
@@ -6135,6 +6136,33 @@
   E->isMicrosoftABI());
 }
 
+ExpectedStmt ASTNodeImporter::VisitChooseExpr(ChooseExpr *E) {
+  auto Imp = importSeq(E->getCond(), E->getLHS(), E->getRHS(),
+   E->getBuiltinLoc(), E->getRParenLoc(), E->getType());
+  if (!Imp)
+return Imp.takeError();
+
+  Expr *ToCond;
+  Expr *ToLHS;
+  Expr *ToRHS;
+  SourceLocation ToBuiltinLoc, ToRParenLoc;
+  QualType ToType;
+  std::tie(ToCond, ToLHS, ToRHS, ToBuiltinLoc, ToRParenLoc, ToType) = *Imp;
+
+  ExprValueKind VK = E->getValueKind();
+  ExprObjectKind OK = E->getObjectKind();
+
+  bool TypeDependent = ToCond->isTypeDependent();
+  bool ValueDependent = ToCond->isValueDependent();
+
+  // The value of CondIsTrue only matters if the value is not
+  // condition-dependent.
+  bool CondIsTrue = !E->isConditionDependent() && E->isConditionTrue();
+
+  return new (Importer.getToContext())
+  ChooseExpr(ToBuiltinLoc, ToCond, ToLHS, ToRHS, ToType, VK, OK,
+ ToRParenLoc, CondIsTrue, TypeDependent, ValueDependent);
+}
 
 ExpectedStmt ASTNodeImporter::VisitGNUNullExpr(GNUNullExpr *E) {
   ExpectedType TypeOrErr = import(E->getType());
Index: cfe/trunk/lib/ASTMatchers/ASTMatchersInternal.cpp
===
--- cfe/trunk/lib/ASTMatchers/ASTMatchersInternal.cpp
+++ cfe/trunk/lib/ASTMatchers/ASTMatchersInternal.cpp
@@ -727,6 +727,7 @@
 compoundLiteralExpr;
 const internal::VariadicDynCastAllOfMatcher
 cxxNullPtrLiteralExpr;
+const internal::VariadicDynCastAllOfMatcher chooseExpr;
 const internal::VariadicDynCastAllOfMatcher gnuNullExpr;
 const internal::VariadicDynCastAllOfMatcher atomicExpr;
 const internal::VariadicDynCastAllOfMatcher stmtExpr;
Index: cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
===
--- cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
+++ cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
@@ -147,6 +147,7 @@
   REGISTER_MATCHER(caseStmt);
   REGISTER_MATCHER(castExpr);
   REGISTER_MATCHER(characterLiteral);
+  REGISTER_MATCHER(chooseExpr);
   REGISTER_MATCHER(classTemplateDecl);
   REGISTER_MATCHER(classTemplateSpecializationDecl);
   REGISTER_MATCHER(complexType);
Index: cfe/trunk/unittests/AST/ASTImporterTest.cpp
===
--- cfe/trunk/unittests/AST/ASTImporterTest.cpp
+++ cfe/trunk/unittests/AST/ASTImporterTest.cpp
@@ -563,6 +563,17 @@
   stringLiteral(hasType(asString("const char [7]"));
 }
 
+TEST_P(ImportExpr, ImportChooseExpr) {
+  MatchVerifier Verifier;
+
+  // This case tests C code that is not condition-dependent and has a true
+  // condition.
+  testImport(
+"void declToImport() { (void)__builtin_choose_expr(1, 2, 3); }",
+Lang_C, "", Lang_C, Verifier,
+functionDecl(hasDescendant(chooseExpr(;
+}
+
 TEST_P(ImportExpr, ImportGNUNullExpr) {
   MatchVerifier Verifier;
   testImport(
@@ -1312,6 +1323,29 @@
   ASSERT_EQ(ToTemplated1, ToTemplated);
 }
 
+TEST_P(ASTImporterOptionSpecificTestBase, ImportChooseExpr) {
+  // This tests the import of isConditionTrue directly to make sure the importer
+  // gets it right.
+  Decl *From, *To;
+  std::tie(From, To) = getImportedDecl(
+"void declToImport() { (void)__builtin_choose_expr(1, 0, 1); }",
+Lang_C, "", Lang_C);
+
+  auto ToResults = match(chooseExpr().bind("choose"), To->getASTContext());
+  auto Fro

r354916 - [ASTImporter] Add support for importing ChooseExpr AST nodes.

2019-02-26 Thread Tom Roeder via cfe-commits
Author: tmroeder
Date: Tue Feb 26 11:26:41 2019
New Revision: 354916

URL: http://llvm.org/viewvc/llvm-project?rev=354916&view=rev
Log:
[ASTImporter] Add support for importing ChooseExpr AST nodes.

Summary:
This allows ASTs to be merged when they contain ChooseExpr (the GNU
__builtin_choose_expr construction). This is needed, for example, for
cross-CTU analysis of C code that makes use of __builtin_choose_expr.

The node is already supported in the AST, but it didn't have a matcher
in ASTMatchers. So, this change adds the matcher and adds support to
ASTImporter.

This was originally reviewed and approved in
https://reviews.llvm.org/D58292 and submitted as r354832. It was
reverted in r354839 due to failures on the Windows CI builds.

This version fixes the test failures on Windows, which were caused by
differences in template expansion between versions of clang on different
OSes. The version of clang built with MSVC and running on Windows never
expands the template in the C++ test in ImportExpr.ImportChooseExpr in
clang/unittests/AST/ASTImporter.cpp, but the version on Linux does for
the empty arguments and -fms-compatibility.

So, this version of the patch drops the C++ test for
__builtin_choose_expr, since that version was written to catch
regressions of the logic for isConditionTrue() in the AST import code
for ChooseExpr, and those regressions are also caught by
ASTImporterOptionSpecificTestBase.ImportChooseExpr, which does work on
Windows.

Reviewers: shafik, a_sidorin, martong, aaron.ballman, rnk, a.sidorin

Subscribers: cfe-commits, jdoerfert, rnkovacs, aaron.ballman

Tags: #clang

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

Added:
cfe/trunk/test/ASTMerge/
cfe/trunk/test/ASTMerge/choose-expr/
cfe/trunk/test/ASTMerge/choose-expr/Inputs/
cfe/trunk/test/ASTMerge/choose-expr/Inputs/choose.c
cfe/trunk/test/ASTMerge/choose-expr/test.c
Modified:
cfe/trunk/docs/LibASTMatchersReference.html
cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
cfe/trunk/lib/AST/ASTImporter.cpp
cfe/trunk/lib/ASTMatchers/ASTMatchersInternal.cpp
cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
cfe/trunk/unittests/AST/ASTImporterTest.cpp
cfe/trunk/unittests/ASTMatchers/ASTMatchersNodeTest.cpp

Modified: cfe/trunk/docs/LibASTMatchersReference.html
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/LibASTMatchersReference.html?rev=354916&r1=354915&r2=354916&view=diff
==
--- cfe/trunk/docs/LibASTMatchersReference.html (original)
+++ cfe/trunk/docs/LibASTMatchersReference.html Tue Feb 26 11:26:41 2019
@@ -788,6 +788,11 @@ Example matches 'a', L'a'
 
 
 
+MatcherStmt>chooseExprMatcherChooseExpr>...
+Matches GNU 
__builtin_choose_expr.
+
+
+
 MatcherStmt>compoundLiteralExprMatcherCompoundLiteralExpr>...
 Matches 
compound (i.e. non-scalar) literals
 

Modified: cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h?rev=354916&r1=354915&r2=354916&view=diff
==
--- cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h (original)
+++ cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h Tue Feb 26 11:26:41 2019
@@ -2158,6 +2158,10 @@ extern const internal::VariadicDynCastAl
 extern const internal::VariadicDynCastAllOfMatcher
 cxxNullPtrLiteralExpr;
 
+/// Matches GNU __builtin_choose_expr.
+extern const internal::VariadicDynCastAllOfMatcher
+chooseExpr;
+
 /// Matches GNU __null expression.
 extern const internal::VariadicDynCastAllOfMatcher
 gnuNullExpr;

Modified: cfe/trunk/lib/AST/ASTImporter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTImporter.cpp?rev=354916&r1=354915&r2=354916&view=diff
==
--- cfe/trunk/lib/AST/ASTImporter.cpp (original)
+++ cfe/trunk/lib/AST/ASTImporter.cpp Tue Feb 26 11:26:41 2019
@@ -552,6 +552,7 @@ namespace clang {
 // Importing expressions
 ExpectedStmt VisitExpr(Expr *E);
 ExpectedStmt VisitVAArgExpr(VAArgExpr *E);
+ExpectedStmt VisitChooseExpr(ChooseExpr *E);
 ExpectedStmt VisitGNUNullExpr(GNUNullExpr *E);
 ExpectedStmt VisitPredefinedExpr(PredefinedExpr *E);
 ExpectedStmt VisitDeclRefExpr(DeclRefExpr *E);
@@ -6135,6 +6136,33 @@ ExpectedStmt ASTNodeImporter::VisitVAArg
   E->isMicrosoftABI());
 }
 
+ExpectedStmt ASTNodeImporter::VisitChooseExpr(ChooseExpr *E) {
+  auto Imp = importSeq(E->getCond(), E->getLHS(), E->getRHS(),
+   E->getBuiltinLoc(), E->getRParenLoc(), E->getType());
+  if (!Imp)
+return Imp.takeEr

r354915 - [X86] Add 'znver2' and 'cascadelake' to the __builtin_cpu_is test.

2019-02-26 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Tue Feb 26 11:20:04 2019
New Revision: 354915

URL: http://llvm.org/viewvc/llvm-project?rev=354915&view=rev
Log:
[X86] Add 'znver2' and 'cascadelake' to the __builtin_cpu_is test.

These are supported by at least libgcc trunk so we can include them now.

Modified:
cfe/trunk/test/CodeGen/target-builtin-noerror.c

Modified: cfe/trunk/test/CodeGen/target-builtin-noerror.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/target-builtin-noerror.c?rev=354915&r1=354914&r2=354915&view=diff
==
--- cfe/trunk/test/CodeGen/target-builtin-noerror.c (original)
+++ cfe/trunk/test/CodeGen/target-builtin-noerror.c Tue Feb 26 11:20:04 2019
@@ -98,6 +98,7 @@ void verifycpustrings() {
   (void)__builtin_cpu_is("btver1");
   (void)__builtin_cpu_is("btver2");
   (void)__builtin_cpu_is("cannonlake");
+  (void)__builtin_cpu_is("cascadelake");
   (void)__builtin_cpu_is("core2");
   (void)__builtin_cpu_is("corei7");
   (void)__builtin_cpu_is("goldmont");


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


[PATCH] D58418: [clang][DirectoryWatcher] Upstream DirectoryWatcher

2019-02-26 Thread Jan Korous via Phabricator via cfe-commits
jkorous updated this revision to Diff 188423.
jkorous marked 4 inline comments as done.
jkorous added a comment.

- Use RetryAfterSignal
- Propagate events from inotify directly
- Remove ModTime
- Add assert for unknown event kinds


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

https://reviews.llvm.org/D58418

Files:
  clang/include/clang/DirectoryWatcher/DirectoryWatcher.h
  clang/lib/CMakeLists.txt
  clang/lib/DirectoryWatcher/CMakeLists.txt
  clang/lib/DirectoryWatcher/DirectoryWatcher-linux.inc.h
  clang/lib/DirectoryWatcher/DirectoryWatcher-mac.inc.h
  clang/lib/DirectoryWatcher/DirectoryWatcher.cpp
  clang/unittests/CMakeLists.txt
  clang/unittests/DirectoryWatcher/CMakeLists.txt
  clang/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp

Index: clang/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp
===
--- /dev/null
+++ clang/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp
@@ -0,0 +1,327 @@
+//===- unittests/DirectoryWatcher/DirectoryWatcherTest.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 "clang/DirectoryWatcher/DirectoryWatcher.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Path.h"
+#include "gtest/gtest.h"
+#include 
+#include 
+#include 
+
+using namespace llvm;
+using namespace llvm::sys;
+using namespace llvm::sys::fs;
+using namespace clang;
+
+namespace {
+
+class EventCollection {
+  SmallVector Events;
+
+public:
+  EventCollection() = default;
+  explicit EventCollection(ArrayRef events) {
+append(events);
+  }
+
+  void append(ArrayRef events) {
+Events.append(events.begin(), events.end());
+  }
+
+  bool empty() const { return Events.empty(); }
+  size_t size() const { return Events.size(); }
+  void clear() { Events.clear(); }
+
+  bool hasEvents(ArrayRef filenames,
+ ArrayRef kinds,
+ ArrayRef stats) const {
+assert(filenames.size() == kinds.size());
+assert(filenames.size() == stats.size());
+SmallVector evts = Events;
+bool hadError = false;
+for (unsigned i = 0, e = filenames.size(); i < e; ++i) {
+  StringRef fname = filenames[i];
+  DirectoryWatcher::EventKind kind = kinds[i];
+  auto it = std::find_if(evts.begin(), evts.end(),
+ [&](const DirectoryWatcher::Event &evt) -> bool {
+   return path::filename(evt.Filename) == fname;
+ });
+  if (it == evts.end()) {
+hadError = err(Twine("expected filename '" + fname + "' not found"));
+continue;
+  }
+  if (it->Kind != kind) {
+hadError = err(Twine("filename '" + fname + "' has event kind " +
+ std::to_string((int)it->Kind) + ", expected ") +
+   std::to_string((int)kind));
+  }
+  evts.erase(it);
+}
+for (const auto &evt : evts) {
+  hadError = err(Twine("unexpected filename '" +
+   path::filename(evt.Filename) + "' found"));
+}
+return !hadError;
+  }
+
+  bool hasAdded(ArrayRef filenames,
+ArrayRef stats) const {
+std::vector kinds{
+filenames.size(), DirectoryWatcher::EventKind::Added};
+return hasEvents(filenames, kinds, stats);
+  }
+
+  bool hasRemoved(ArrayRef filenames) const {
+std::vector kinds{
+filenames.size(), DirectoryWatcher::EventKind::Removed};
+std::vector stats{filenames.size(), file_status{}};
+return hasEvents(filenames, kinds, stats);
+  }
+
+private:
+  bool err(Twine msg) const {
+SmallString<128> buf;
+llvm::errs() << msg.toStringRef(buf) << '\n';
+return true;
+  }
+};
+
+struct EventOccurrence {
+  std::vector Events;
+  bool IsInitial;
+};
+
+class DirectoryWatcherTest
+: public std::enable_shared_from_this {
+  std::string WatchedDir;
+  std::string TempDir;
+  std::unique_ptr DirWatcher;
+
+  std::condition_variable Condition;
+  std::mutex Mutex;
+  std::deque EvtOccurs;
+
+public:
+  void init() {
+SmallString<128> pathBuf;
+std::error_code EC = createUniqueDirectory("dirwatcher", pathBuf);
+ASSERT_FALSE(EC);
+TempDir = pathBuf.str();
+path::append(pathBuf, "watch");
+WatchedDir = pathBuf.str();
+EC = create_directory(WatchedDir);
+ASSERT_FALSE(EC);
+  }
+
+  ~DirectoryWatcherTest() {
+stopWatching();
+remove_directories(TempDir);
+  }
+
+public:
+  StringRef getWatchedDir() const { return WatchedDir; }
+
+  void addFile(StringRef filename, file_status &stat) {
+SmallString<128> pathBuf;
+pathBuf = TempDir;
+path::append(pathBuf, filename);
+Expected ft =
+openNativeFileForWrite(pathBuf, CD_Cre

[PATCH] D58663: [ASTImporter] Add support for importing ChooseExpr AST nodes.

2019-02-26 Thread Tom Roeder via Phabricator via cfe-commits
tmroeder added a comment.

I'm going to submit this patch again, since that I believe I understand the 
problem, and I have tested this version on Win10 with the latest MSVC (other 
than the expectation that I just added, but that test wasn't a problem on the 
Windows builders, and the new expectation passes on my Linux dev box). I'll 
watch the Windows build at 
http://lab.llvm.org:8011/builders/clang-x64-windows-msvc and revert if there 
are problems.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D58663



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


[PATCH] D58418: [clang][DirectoryWatcher] Upstream DirectoryWatcher

2019-02-26 Thread Jan Korous via Phabricator via cfe-commits
jkorous marked 18 inline comments as done.
jkorous added inline comments.



Comment at: clang/lib/DirectoryWatcher/DirectoryWatcher-linux.inc.h:116
+
+  DirectoryWatcher::EventKind K = DirectoryWatcher::EventKind::Added;
+  if (ievt->mask & IN_MODIFY) {

jkorous wrote:
> mgorny wrote:
> > I don't think I understand this assumption. Have you any specific event in 
> > mind that is supposed to be treated as added here? If not, maybe it'd be 
> > better to have no default and instead assert that one of the conditions 
> > below matched.
> SGTM. Will rewrite to Optional<> and assert.
Reconsidered and replaced with one-off closure in order not to complicate 
following code with Optional.



Comment at: clang/lib/DirectoryWatcher/DirectoryWatcher-linux.inc.h:135
+if (!statusOpt.hasValue())
+  K = DirectoryWatcher::EventKind::Removed;
+  }

akyrtzi wrote:
> mgorny wrote:
> > akyrtzi wrote:
> > > mgorny wrote:
> > > > akyrtzi wrote:
> > > > > mgorny wrote:
> > > > > > akyrtzi wrote:
> > > > > > > mgorny wrote:
> > > > > > > > jkorous wrote:
> > > > > > > > > mgorny wrote:
> > > > > > > > > > Why? I suppose this deserves a comment.
> > > > > > > > > I'll add this comment:
> > > > > > > > > 
> > > > > > > > > // The file might have been removed just after we received 
> > > > > > > > > the event.
> > > > > > > > Wouldn't that cause removals to be reported twice?
> > > > > > > Not quite sure if it can happen in practice but I'd suggest to 
> > > > > > > accept this as potential occurrence and add it to documentation 
> > > > > > > ("a 'removed' event may be reported twice). I think it is better 
> > > > > > > to handle a definite "fact" (the file doesn't exist) than ignore 
> > > > > > > it and assume the 'removed' event will eventually show up, or try 
> > > > > > > to eliminate the double reporting which would over-complicate the 
> > > > > > > implementation.
> > > > > > > 
> > > > > > > After all, if inotify() is not 100% reliable then there's already 
> > > > > > > the possibility that you'll get a 'removed' event for a file that 
> > > > > > > was not reported as 'added' before.
> > > > > > I see this as a partial workaround for race condition. You 'fix' it 
> > > > > > if removal happens between inotify reporting the event and you 
> > > > > > returning it. You don't if removal happens after you push it to 
> > > > > > events. Therefore, the caller still needs to account for 'added' 
> > > > > > event being obsolete. I don't really see a purpose in trying to 
> > > > > > workaround the problem partially here if the caller still needs to 
> > > > > > account for it. Effectively, you're replacing one normal case and 
> > > > > > one corner case with one normal case and two corner cases.
> > > > > I was mainly pointing out that the client already has to be prepared 
> > > > > for a 'removed' event that does not have an associated 'added' event, 
> > > > > regardless of what this code is doing. Therefore a potential double 
> > > > > 'removed' event doesn't add complexity to the client.
> > > > > 
> > > > > Could you clarify how the code should handle the inability to get the 
> > > > > mod time ? Should it ignore the event ?
> > > > Given the code is supposed to wrap filesystem notification layer, I'd 
> > > > say it should pass the events unmodified and not double-guess what the 
> > > > client expects. The client needs to be prepared for non-atomicity of 
> > > > this anyway.
> > > So it should report an 'added' event but with optional mod-time, 
> > > essentially reporting that something was added that doesn't exist ?
> > > I'd prefer not to do that because it complicates the client without any 
> > > real benefit. It was great that you pointed out this part of the code but 
> > > I'd recommend that if the file is gone we should ignore the 'added' 
> > > event, instead of complicating the API for a corner case.
> > Except that is technically impossible to avoid reporting something that 
> > doesn't exist because it can be removed just after you check for it. So the 
> > client needs to *always* support it, otherwise it's fragile to race 
> > conditions.
> > 
> > This extra check just covers the short period (-> 0) between reporting and 
> > checking. It's needless complexity that doesn't solve the problem. If it 
> > does anything, then it gives you false security that you've solved the 
> > problem when actually the file may still disappear 1 ns after you've 
> > checked that it existed.
> Ok, that's fair, @jkorous I'm fine with removing the mod-time from the 
> DirectoryWatcher API. We can get and report the mod-time at the index-store 
> library layer.
Removed the conditional event kind change and removed ModTime.



Comment at: clang/lib/DirectoryWatcher/DirectoryWatcher-linux.inc.h:154
+errorMsg += llvm::sys::StrError();
+return true;
+  };

dexonsmith wrote:
> jkorous wrote

[PATCH] D58463: [CUDA]Delayed diagnostics for the asm instructions.

2019-02-26 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

In D58463#1410900 , @tra wrote:

> There's a new quirk we've ran into after this patch landed. Consider this 
> code:
>
>   int foo() {
> int prev;
> __asm__ __volatile__("mov %0, 0" : "=a" (prev)::);
> return prev;
>   }
>
>
> When we compile for device, asm constraint is not valid for NVPTX, we emit 
> delayed diag and move on. The function is never code-gen'ed so the diag never 
> shows up. So far so good.
>
> Now we add `-Werror -Wininitialized` and things break -- because we bail out 
> early, `prev` is left uninitialized and is reported as such.
>
>   $ bin/clang++ -c --cuda-gpu-arch=sm_35 asm.cu -nocudainc --cuda-device-only 
> -Wuninitialized -Werror
>   asm.cu:4:10: error: variable 'prev' is uninitialized when used here 
> [-Werror,-Wuninitialized]
> return prev;
>^~~~
>   asm.cu:2:11: note: initialize the variable 'prev' to silence this warning
> int prev;
> ^
>  = 0
>   1 error generated when compiling for sm_35.
>  
>
>
> I think this should also show up in the test case in this patch, too, if you 
> add -Wuninitialized


Hi Artem, I think we can just delay emission of this warning to solve this 
problem.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D58463



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


[PATCH] D58665: [analyzer] Handle comparison between non-default AS symbol and constant

2019-02-26 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

Hi, thanks!, i think this is correct. As in, `LocAsInteger` was clearly a 
mistake to begin with, but this change shouldn't make it worse.

You should be able to get away with not supporting comparisons between regions 
without symbolic base [as integers] and concrete integers because they usually 
yield fairly dumb values anyway. Eg., it's //impossible// for an address of a 
variable to be equal to a null pointer, and whether a variable's address is 
currently equal to `0xbadf00d` is //undefined// anyway - it will cause problems 
when we try to symbolicate our undefined values, but for now we prefer to 
interrupt the analysis whenever they actually end up being used (which causes 
the problem to disappear because symbolication only matters when we use the 
symbol more than once).




Comment at: lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp:574
   llvm::APSInt i = rhs.castAs().getValue();
-  BasicVals.getAPSIntType(Context.VoidPtrTy).apply(i);
+  // FIXME: Handle non-default address spaces for non-symbolic regions.
+  if (SymbolRef lSym = lhs.getAsLocSymbol(true))

Pls be more specific in this comment that we're making this extra check in 
order to support non-default address spaces. Eg., "If the region has a symbolic 
base, pay attention to the type; it might be coming from a non-default address 
space. For non-symbolic regions it doesn't matter that much because such 
comparisons would most likely evaluate to concrete false anyway. FIXME: We 
might still need to handle the non-comparison case."



Comment at: test/Analysis/ptr-cmp-const-trunc.cl:10
+  if ((uint64_t)p <= 1UL << 32)
+bar(p);
+}

Pls add a `// no-warning` here, so that it was clear what the test is about.


Repository:
  rC Clang

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

https://reviews.llvm.org/D58665



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


[PATCH] D58623: [AMDGPU] Allow using integral non-type template parameters

2019-02-26 Thread Michael Liao via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC354909: [AMDGPU] Allow using integral non-type template 
parameters (authored by hliao, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D58623?vs=188172&id=188416#toc

Repository:
  rC Clang

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

https://reviews.llvm.org/D58623

Files:
  include/clang/Basic/Attr.td
  include/clang/Sema/Sema.h
  lib/CodeGen/TargetInfo.cpp
  lib/Sema/SemaDeclAttr.cpp
  lib/Sema/SemaTemplateInstantiateDecl.cpp
  test/SemaCUDA/amdgpu-attrs.cu
  test/SemaOpenCL/amdgpu-attrs.cl

Index: include/clang/Sema/Sema.h
===
--- include/clang/Sema/Sema.h
+++ include/clang/Sema/Sema.h
@@ -8674,6 +8674,16 @@
   void AddXConsumedAttr(Decl *D, SourceRange SR, unsigned SpellingIndex,
 RetainOwnershipKind K, bool IsTemplateInstantiation);
 
+  /// addAMDGPUFlatWorkGroupSizeAttr - Adds an amdgpu_flat_work_group_size
+  /// attribute to a particular declaration.
+  void addAMDGPUFlatWorkGroupSizeAttr(SourceRange AttrRange, Decl *D, Expr *Min,
+  Expr *Max, unsigned SpellingListIndex);
+
+  /// addAMDGPUWavePersEUAttr - Adds an amdgpu_waves_per_eu attribute to a
+  /// particular declaration.
+  void addAMDGPUWavesPerEUAttr(SourceRange AttrRange, Decl *D, Expr *Min,
+   Expr *Max, unsigned SpellingListIndex);
+
   bool checkNSReturnsRetainedReturnType(SourceLocation loc, QualType type);
 
   //======//
Index: include/clang/Basic/Attr.td
===
--- include/clang/Basic/Attr.td
+++ include/clang/Basic/Attr.td
@@ -1484,14 +1484,14 @@
 
 def AMDGPUFlatWorkGroupSize : InheritableAttr {
   let Spellings = [Clang<"amdgpu_flat_work_group_size", 0>];
-  let Args = [UnsignedArgument<"Min">, UnsignedArgument<"Max">];
+  let Args = [ExprArgument<"Min">, ExprArgument<"Max">];
   let Documentation = [AMDGPUFlatWorkGroupSizeDocs];
   let Subjects = SubjectList<[Function], ErrorDiag, "kernel functions">;
 }
 
 def AMDGPUWavesPerEU : InheritableAttr {
   let Spellings = [Clang<"amdgpu_waves_per_eu", 0>];
-  let Args = [UnsignedArgument<"Min">, UnsignedArgument<"Max", 1>];
+  let Args = [ExprArgument<"Min">, ExprArgument<"Max", 1>];
   let Documentation = [AMDGPUWavesPerEUDocs];
   let Subjects = SubjectList<[Function], ErrorDiag, "kernel functions">;
 }
Index: test/SemaOpenCL/amdgpu-attrs.cl
===
--- test/SemaOpenCL/amdgpu-attrs.cl
+++ test/SemaOpenCL/amdgpu-attrs.cl
@@ -27,12 +27,12 @@
 __attribute__((amdgpu_num_sgpr(32))) void func_num_sgpr_32() {} // expected-error {{'amdgpu_num_sgpr' attribute only applies to kernel functions}}
 __attribute__((amdgpu_num_vgpr(64))) void func_num_vgpr_64() {} // expected-error {{'amdgpu_num_vgpr' attribute only applies to kernel functions}}
 
-__attribute__((amdgpu_flat_work_group_size("ABC", "ABC"))) kernel void kernel_flat_work_group_size_ABC_ABC() {} // expected-error {{'amdgpu_flat_work_group_size' attribute requires an integer constant}}
-__attribute__((amdgpu_flat_work_group_size(32, "ABC"))) kernel void kernel_flat_work_group_size_32_ABC() {} // expected-error {{'amdgpu_flat_work_group_size' attribute requires an integer constant}}
-__attribute__((amdgpu_flat_work_group_size("ABC", 64))) kernel void kernel_flat_work_group_size_ABC_64() {} // expected-error {{'amdgpu_flat_work_group_size' attribute requires an integer constant}}
-__attribute__((amdgpu_waves_per_eu("ABC"))) kernel void kernel_waves_per_eu_ABC() {} // expected-error {{'amdgpu_waves_per_eu' attribute requires an integer constant}}
-__attribute__((amdgpu_waves_per_eu(2, "ABC"))) kernel void kernel_waves_per_eu_2_ABC() {} // expected-error {{'amdgpu_waves_per_eu' attribute requires an integer constant}}
-__attribute__((amdgpu_waves_per_eu("ABC", 4))) kernel void kernel_waves_per_eu_ABC_4() {} // expected-error {{'amdgpu_waves_per_eu' attribute requires an integer constant}}
+__attribute__((amdgpu_flat_work_group_size("ABC", "ABC"))) kernel void kernel_flat_work_group_size_ABC_ABC() {} // expected-error {{'amdgpu_flat_work_group_size' attribute requires parameter 0 to be an integer constant}}
+__attribute__((amdgpu_flat_work_group_size(32, "ABC"))) kernel void kernel_flat_work_group_size_32_ABC() {} // expected-error {{'amdgpu_flat_work_group_size' attribute requires parameter 1 to be an integer constant}}
+__attribute__((amdgpu_flat_work_group_size("ABC", 64))) kernel void kernel_flat_work_group_size_ABC_64() {} // expected-error {{'amdgpu_flat_work_group_size' attribute requires parameter 0 to be an integer constant}}
+__attribute__((amdgpu_waves_per_eu("ABC"))) kernel void kernel_waves_per_eu_ABC() {} // expected-error {{'amdgpu_waves_per_eu' attrib

r354909 - [AMDGPU] Allow using integral non-type template parameters

2019-02-26 Thread Michael Liao via cfe-commits
Author: hliao
Date: Tue Feb 26 10:49:36 2019
New Revision: 354909

URL: http://llvm.org/viewvc/llvm-project?rev=354909&view=rev
Log:
[AMDGPU] Allow using integral non-type template parameters

Summary:
- Allow using integral non-type template parameters in the following
  attributes

  __attribute__((amdgpu_flat_work_group_size(, )))
  __attribute__((amdgpu_waves_per_eu([, ])))

Reviewers: kzhuravl, yaxunl

Subscribers: jvesely, wdng, nhaehnle, dstuttard, tpr, t-tye, jdoerfert, 
cfe-commits

Tags: #clang

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

Modified:
cfe/trunk/include/clang/Basic/Attr.td
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/CodeGen/TargetInfo.cpp
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
cfe/trunk/test/SemaCUDA/amdgpu-attrs.cu
cfe/trunk/test/SemaOpenCL/amdgpu-attrs.cl

Modified: cfe/trunk/include/clang/Basic/Attr.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=354909&r1=354908&r2=354909&view=diff
==
--- cfe/trunk/include/clang/Basic/Attr.td (original)
+++ cfe/trunk/include/clang/Basic/Attr.td Tue Feb 26 10:49:36 2019
@@ -1484,14 +1484,14 @@ def RISCVInterrupt : InheritableAttr, Ta
 
 def AMDGPUFlatWorkGroupSize : InheritableAttr {
   let Spellings = [Clang<"amdgpu_flat_work_group_size", 0>];
-  let Args = [UnsignedArgument<"Min">, UnsignedArgument<"Max">];
+  let Args = [ExprArgument<"Min">, ExprArgument<"Max">];
   let Documentation = [AMDGPUFlatWorkGroupSizeDocs];
   let Subjects = SubjectList<[Function], ErrorDiag, "kernel functions">;
 }
 
 def AMDGPUWavesPerEU : InheritableAttr {
   let Spellings = [Clang<"amdgpu_waves_per_eu", 0>];
-  let Args = [UnsignedArgument<"Min">, UnsignedArgument<"Max", 1>];
+  let Args = [ExprArgument<"Min">, ExprArgument<"Max", 1>];
   let Documentation = [AMDGPUWavesPerEUDocs];
   let Subjects = SubjectList<[Function], ErrorDiag, "kernel functions">;
 }

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=354909&r1=354908&r2=354909&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Tue Feb 26 10:49:36 2019
@@ -8674,6 +8674,16 @@ public:
   void AddXConsumedAttr(Decl *D, SourceRange SR, unsigned SpellingIndex,
 RetainOwnershipKind K, bool IsTemplateInstantiation);
 
+  /// addAMDGPUFlatWorkGroupSizeAttr - Adds an amdgpu_flat_work_group_size
+  /// attribute to a particular declaration.
+  void addAMDGPUFlatWorkGroupSizeAttr(SourceRange AttrRange, Decl *D, Expr 
*Min,
+  Expr *Max, unsigned SpellingListIndex);
+
+  /// addAMDGPUWavePersEUAttr - Adds an amdgpu_waves_per_eu attribute to a
+  /// particular declaration.
+  void addAMDGPUWavesPerEUAttr(SourceRange AttrRange, Decl *D, Expr *Min,
+   Expr *Max, unsigned SpellingListIndex);
+
   bool checkNSReturnsRetainedReturnType(SourceLocation loc, QualType type);
 
   
//======//

Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=354909&r1=354908&r2=354909&view=diff
==
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Tue Feb 26 10:49:36 2019
@@ -7797,8 +7797,16 @@ void AMDGPUTargetCodeGenInfo::setTargetA
 
   const auto *FlatWGS = FD->getAttr();
   if (ReqdWGS || FlatWGS) {
-unsigned Min = FlatWGS ? FlatWGS->getMin() : 0;
-unsigned Max = FlatWGS ? FlatWGS->getMax() : 0;
+unsigned Min = 0;
+unsigned Max = 0;
+if (FlatWGS) {
+  Min = FlatWGS->getMin()
+->EvaluateKnownConstInt(M.getContext())
+.getExtValue();
+  Max = FlatWGS->getMax()
+->EvaluateKnownConstInt(M.getContext())
+.getExtValue();
+}
 if (ReqdWGS && Min == 0 && Max == 0)
   Min = Max = ReqdWGS->getXDim() * ReqdWGS->getYDim() * ReqdWGS->getZDim();
 
@@ -7812,8 +7820,12 @@ void AMDGPUTargetCodeGenInfo::setTargetA
   }
 
   if (const auto *Attr = FD->getAttr()) {
-unsigned Min = Attr->getMin();
-unsigned Max = Attr->getMax();
+unsigned Min =
+Attr->getMin()->EvaluateKnownConstInt(M.getContext()).getExtValue();
+unsigned Max = Attr->getMax() ? Attr->getMax()
+->EvaluateKnownConstInt(M.getContext())
+.getExtValue()
+  : 0;
 
 if (Min != 0) {
   assert((Max == 0 || Min <= Max) && "Min must be less than or equal Max");

Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp

[PATCH] D58463: [CUDA]Delayed diagnostics for the asm instructions.

2019-02-26 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

There's a new quirk we've ran into after this patch landed. Consider this code:

  int foo() {
int prev;
__asm__ __volatile__("whatever" : "=a" (prev)::);
return prev;
  }

When we compile for device, asm constraint is not valid for NVPTX, we emit 
delayed diag and move on. The function is never code-gen'ed so the diag never 
shows up. So far so good.

Now we add `-Werror -Wininitialized` and things break -- because we bail out 
early, `prev` is left uninitialized and is reported as such.

  $ bin/clang++ -c --cuda-gpu-arch=sm_35 asm.cu -nocudainc --cuda-device-only 
-Wuninitialized -Werror
  asm.cu:4:10: error: variable 'prev' is uninitialized when used here 
[-Werror,-Wuninitialized]
return prev;
   ^~~~
  asm.cu:2:11: note: initialize the variable 'prev' to silence this warning
int prev;
^
 = 0
  1 error generated when compiling for sm_35.

I think this should also show up in the test case in this patch, too, if you 
add -Wuninitialized


Repository:
  rL LLVM

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

https://reviews.llvm.org/D58463



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


[PATCH] D58091: Customize warnings for missing built-in type

2019-02-26 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert updated this revision to Diff 188411.
jdoerfert marked an inline comment as done.
jdoerfert added a comment.

Fix typo


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D58091

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaDecl.cpp
  clang/test/Analysis/retain-release.m
  clang/test/Sema/builtin-setjmp.c
  clang/test/Sema/implicit-builtin-decl.c

Index: clang/test/Sema/implicit-builtin-decl.c
===
--- clang/test/Sema/implicit-builtin-decl.c
+++ clang/test/Sema/implicit-builtin-decl.c
@@ -55,14 +55,17 @@
 
 void snprintf() { }
 
-// PR8316
-void longjmp(); // expected-warning{{declaration of built-in function 'longjmp' requires inclusion of the header }}
+// PR8316 & PR40692
+void longjmp(); // expected-warning{{declaration of built-in function 'longjmp' requires the definition of the 'jmp_buf' type, commonly proived in the header .}}
 
 extern float fmaxf(float, float);
 
 struct __jmp_buf_tag {};
-void sigsetjmp(struct __jmp_buf_tag[1], int); // expected-warning{{declaration of built-in function 'sigsetjmp' requires inclusion of the header }}
+void sigsetjmp(struct __jmp_buf_tag[1], int); // expected-warning{{declaration of built-in function 'sigsetjmp' requires the declaration of the 'jmp_buf' type, commonly proived in the header .}}
 
 // CHECK: FunctionDecl {{.*}}  col:6 sigsetjmp '
 // CHECK-NOT: FunctionDecl
 // CHECK: ReturnsTwiceAttr {{.*}} <{{.*}}> Implicit
+
+// PR40692
+void pthread_create(); // no warning expected
Index: clang/test/Sema/builtin-setjmp.c
===
--- /dev/null
+++ clang/test/Sema/builtin-setjmp.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only -verify -DNO_JMP_BUF %s
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only -verify %s
+
+#ifdef NO_JMP_BUF
+extern long setjmp(long *);   // expected-warning {{declaration of built-in function 'setjmp' requires the declaration of the 'jmp_buf' type, commonly proived in the header .}}
+#else
+typedef long jmp_buf;
+extern int setjmp(char);  // expected-warning@8 {{incompatible redeclaration of library function 'setjmp'}}
+  // expected-note@8{{'setjmp' is a builtin with type 'int (jmp_buf)' (aka 'int (long)')}}
+#endif
Index: clang/test/Analysis/retain-release.m
===
--- clang/test/Analysis/retain-release.m
+++ clang/test/Analysis/retain-release.m
@@ -2,7 +2,7 @@
 // RUN: %clang_analyze_cc1 -triple x86_64-apple-darwin10\
 // RUN: -analyzer-checker=core,osx.coreFoundation.CFRetainRelease\
 // RUN: -analyzer-checker=osx.cocoa.ClassRelease,osx.cocoa.RetainCount\
-// RUN: -analyzer-checker=debug.ExprInspection -fblocks -verify=expected,C %s\
+// RUN: -analyzer-checker=debug.ExprInspection -fblocks -verify %s\
 // RUN: -Wno-objc-root-class -analyzer-output=plist -o %t.objc.plist
 // RUN: %clang_analyze_cc1 -triple x86_64-apple-darwin10\
 // RUN: -analyzer-checker=core,osx.coreFoundation.CFRetainRelease\
@@ -1231,7 +1231,7 @@
 typedef unsigned long __darwin_pthread_key_t;
 typedef __darwin_pthread_key_t pthread_key_t;
 
-int pthread_create(pthread_t *, const pthread_attr_t *,  // C-warning{{declaration of built-in function 'pthread_create' requires inclusion of the header }}
+int pthread_create(pthread_t *, const pthread_attr_t *,
void *(*)(void *), void *);
 
 int pthread_setspecific(pthread_key_t key, const void *value);
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -1955,10 +1955,27 @@
   ASTContext::GetBuiltinTypeError Error;
   QualType R = Context.GetBuiltinType(ID, Error);
   if (Error) {
-if (ForRedeclaration)
-  Diag(Loc, diag::warn_implicit_decl_requires_sysheader)
-  << getHeaderName(Context.BuiltinInfo, ID, Error)
+if (!ForRedeclaration)
+  return nullptr;
+
+// If we have a builtin without an associated type we should not emit a
+// warning when we were not able to find a type for it.
+if (Error == ASTContext::GE_Missing_type)
+  return nullptr;
+
+// If we could not find a type for setjmp it is because the jmp_buf type was
+// not defined prior to the setjmp declaration.
+if (Error == ASTContext::GE_Missing_setjmp) {
+  Diag(Loc, diag::warn_implicit_decl_no_jmp_buf)
   << Context.BuiltinInfo.getName(ID);
+  return nullptr;
+}
+
+// Generally, we emit a warning that the declaration requires the
+// appropriate header.
+Diag(Loc, diag::warn_implicit_decl_requires_sysheader)
+<< getHeaderName(Context.BuiltinInfo, ID, Error)
+<< Context.BuiltinInfo.getName(ID);
 return nullpt

[clang-tools-extra] r354903 - [clang-tidy] undo bitfields in ExceptionAnalyzer

2019-02-26 Thread Jonas Toth via cfe-commits
Author: jonastoth
Date: Tue Feb 26 10:15:17 2019
New Revision: 354903

URL: http://llvm.org/viewvc/llvm-project?rev=354903&view=rev
Log:
[clang-tidy] undo bitfields in ExceptionAnalyzer

Scoped enums do induce some problems with some MSVC and GCC versions
if used as bitfields. Therefor this is deactivated for now.

Modified:
clang-tools-extra/trunk/clang-tidy/utils/ExceptionAnalyzer.h

Modified: clang-tools-extra/trunk/clang-tidy/utils/ExceptionAnalyzer.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/utils/ExceptionAnalyzer.h?rev=354903&r1=354902&r2=354903&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/utils/ExceptionAnalyzer.h (original)
+++ clang-tools-extra/trunk/clang-tidy/utils/ExceptionAnalyzer.h Tue Feb 26 
10:15:17 2019
@@ -109,19 +109,17 @@ public:
 
 /// Keep track if the entity related to this 'ExceptionInfo' can in 
princple
 /// throw, if it's unknown or if it won't throw.
-State Behaviour : 2;
+State Behaviour;
 
 /// Keep track if the entity contains any unknown elements to keep track
 /// of the certainty of decisions and/or correct 'Behaviour' transition
 /// after filtering.
-bool ContainsUnknown : 1;
+bool ContainsUnknown;
 
 /// 'ThrownException' is empty if the 'Behaviour' is either 'NotThrowing' 
or
 /// 'Unknown'.
 Throwables ThrownExceptions;
   };
-  static_assert(sizeof(ExceptionInfo) <= 64u,
-"size of exceptioninfo shall be at max one cache line");
 
   ExceptionAnalyzer() = default;
 


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


[PATCH] D58623: [AMDGPU] Allow using integral non-type template parameters

2019-02-26 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl accepted this revision.
yaxunl added a comment.
This revision is now accepted and ready to land.

LGTM. Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D58623



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


[PATCH] D57906: [CTU] Do not allow different CPP dialects in CTU

2019-02-26 Thread Gabor Marton via Phabricator via cfe-commits
martong marked 2 inline comments as done.
martong added inline comments.



Comment at: lib/CrossTU/CrossTranslationUnit.cpp:255
+  // in the other unit it has none.
+  if (LangTo.CPlusPlus11 != LangFrom.CPlusPlus11 ||
+  LangTo.CPlusPlus14 != LangFrom.CPlusPlus14 ||

r.stahl wrote:
> This is likely to become a bug in the future, but I didn't see a better way 
> to compare dialects.
> 
> Is there a way to add a test that lights up once there is a new dialect?
> 
> Would it be too pessimistic to compare the entire LangOpts? Some stuff in 
> there should even still produce errors, right? For example "GnuMode". I 
> skimmed over them and didn't find an obvious one that would differ between 
> translation units of the same project. Maybe the template depth could be set 
> selectively, but to fix that we could mask "COMPATIBLE_" and "BENIGN_" opts.
> This is likely to become a bug in the future, but I didn't see a better way 
> to compare dialects.
> Is there a way to add a test that lights up once there is a new dialect?

`LANGOPTS` are defined as bitfields: `#define LANGOPT(Name, Bits, Default, 
Description) unsigned Name : Bits;`
I can't think of any solution to avoid the future bug, because there is no way 
to enumerate all the C++ dialects.
I am going to ask around about this on cfe-dev, maybe somebody will have an 
idea.

> Would it be too pessimistic to compare the entire LangOpts?
I think that would be too pessimistic.


Repository:
  rC Clang

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

https://reviews.llvm.org/D57906



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


[PATCH] D58663: [ASTImporter] Add support for importing ChooseExpr AST nodes.

2019-02-26 Thread Tom Roeder via Phabricator via cfe-commits
tmroeder updated this revision to Diff 188397.
tmroeder added a comment.

Added the other expectation, as suggested.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D58663

Files:
  clang/docs/LibASTMatchersReference.html
  clang/include/clang/ASTMatchers/ASTMatchers.h
  clang/lib/AST/ASTImporter.cpp
  clang/lib/ASTMatchers/ASTMatchersInternal.cpp
  clang/lib/ASTMatchers/Dynamic/Registry.cpp
  clang/test/ASTMerge/choose-expr/Inputs/choose.c
  clang/test/ASTMerge/choose-expr/test.c
  clang/unittests/AST/ASTImporterTest.cpp
  clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp

Index: clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
@@ -754,6 +754,11 @@
   EXPECT_TRUE(matches("int* i = nullptr;", cxxNullPtrLiteralExpr()));
 }
 
+TEST(Matcher, ChooseExpr) {
+  EXPECT_TRUE(matchesC("void f() { (void)__builtin_choose_expr(1, 2, 3); }",
+   chooseExpr()));
+}
+
 TEST(Matcher, GNUNullExpr) {
   EXPECT_TRUE(matches("int* i = __null;", gnuNullExpr()));
 }
Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -563,6 +563,17 @@
   stringLiteral(hasType(asString("const char [7]"));
 }
 
+TEST_P(ImportExpr, ImportChooseExpr) {
+  MatchVerifier Verifier;
+
+  // This case tests C code that is not condition-dependent and has a true
+  // condition.
+  testImport(
+"void declToImport() { (void)__builtin_choose_expr(1, 2, 3); }",
+Lang_C, "", Lang_C, Verifier,
+functionDecl(hasDescendant(chooseExpr(;
+}
+
 TEST_P(ImportExpr, ImportGNUNullExpr) {
   MatchVerifier Verifier;
   testImport(
@@ -1312,6 +1323,29 @@
   ASSERT_EQ(ToTemplated1, ToTemplated);
 }
 
+TEST_P(ASTImporterOptionSpecificTestBase, ImportChooseExpr) {
+  // This tests the import of isConditionTrue directly to make sure the importer
+  // gets it right.
+  Decl *From, *To;
+  std::tie(From, To) = getImportedDecl(
+"void declToImport() { (void)__builtin_choose_expr(1, 0, 1); }",
+Lang_C, "", Lang_C);
+
+  auto ToResults = match(chooseExpr().bind("choose"), To->getASTContext());
+  auto FromResults = match(chooseExpr().bind("choose"), From->getASTContext());
+
+  const ChooseExpr *FromChooseExpr =
+  selectFirst("choose", FromResults);
+  ASSERT_TRUE(FromChooseExpr);
+
+  const ChooseExpr *ToChooseExpr = selectFirst("choose", ToResults);
+  ASSERT_TRUE(ToChooseExpr);
+
+  EXPECT_EQ(FromChooseExpr->isConditionTrue(), ToChooseExpr->isConditionTrue());
+  EXPECT_EQ(FromChooseExpr->isConditionDependent(),
+ToChooseExpr->isConditionDependent());
+}
+
 TEST_P(ASTImporterOptionSpecificTestBase,
ImportFunctionWithBackReferringParameter) {
   Decl *From, *To;
Index: clang/test/ASTMerge/choose-expr/test.c
===
--- /dev/null
+++ clang/test/ASTMerge/choose-expr/test.c
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 -std=c11 -emit-pch -o %t.ast %S/Inputs/choose.c
+// RUN: %clang_cc1 -std=c11 -ast-merge %t.ast -fsyntax-only -verify %s
+// expected-no-diagnostics
+
Index: clang/test/ASTMerge/choose-expr/Inputs/choose.c
===
--- /dev/null
+++ clang/test/ASTMerge/choose-expr/Inputs/choose.c
@@ -0,0 +1,2 @@
+_Static_assert(__builtin_choose_expr(1, 1, 0), "Incorrect semantics of __builtin_choose_expr");
+_Static_assert(__builtin_choose_expr(0, 0, 1), "Incorrect semantics of __builtin_choose_expr");
Index: clang/lib/ASTMatchers/Dynamic/Registry.cpp
===
--- clang/lib/ASTMatchers/Dynamic/Registry.cpp
+++ clang/lib/ASTMatchers/Dynamic/Registry.cpp
@@ -147,6 +147,7 @@
   REGISTER_MATCHER(caseStmt);
   REGISTER_MATCHER(castExpr);
   REGISTER_MATCHER(characterLiteral);
+  REGISTER_MATCHER(chooseExpr);
   REGISTER_MATCHER(classTemplateDecl);
   REGISTER_MATCHER(classTemplateSpecializationDecl);
   REGISTER_MATCHER(complexType);
Index: clang/lib/ASTMatchers/ASTMatchersInternal.cpp
===
--- clang/lib/ASTMatchers/ASTMatchersInternal.cpp
+++ clang/lib/ASTMatchers/ASTMatchersInternal.cpp
@@ -727,6 +727,7 @@
 compoundLiteralExpr;
 const internal::VariadicDynCastAllOfMatcher
 cxxNullPtrLiteralExpr;
+const internal::VariadicDynCastAllOfMatcher chooseExpr;
 const internal::VariadicDynCastAllOfMatcher gnuNullExpr;
 const internal::VariadicDynCastAllOfMatcher atomicExpr;
 const internal::VariadicDynCastAllOfMatcher stmtExpr;
Index: clang/lib/AST/ASTImporter.cpp
===
--- clang/lib/AST/ASTImporter.cpp
+++

[PATCH] D58683: [clangd] Set thread priority on Windows

2019-02-26 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov created this revision.
ilya-biryukov added reviewers: kadircet, gribozavr.
Herald added subscribers: arphaman, jkorous, MaskRay, ioeric.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D58683

Files:
  clang-tools-extra/clangd/Threading.cpp


Index: clang-tools-extra/clangd/Threading.cpp
===
--- clang-tools-extra/clangd/Threading.cpp
+++ clang-tools-extra/clangd/Threading.cpp
@@ -9,6 +9,8 @@
 #include 
 #elif defined(__APPLE__)
 #include 
+#elif defined (_WIN32)
+#include 
 #endif
 
 namespace clang {
@@ -129,6 +131,11 @@
   Priority == ThreadPriority::Low && !AvoidThreadStarvation
   ? PRIO_DARWIN_BG
   : 0);
+#elif defined(_WIN32)
+  SetThreadPriority(GetCurrentThread(),
+Priority == ThreadPriority::Low && !AvoidThreadStarvation
+? THREAD_MODE_BACKGROUND_BEGIN
+: THREAD_MODE_BACKGROUND_END);
 #endif
 }
 


Index: clang-tools-extra/clangd/Threading.cpp
===
--- clang-tools-extra/clangd/Threading.cpp
+++ clang-tools-extra/clangd/Threading.cpp
@@ -9,6 +9,8 @@
 #include 
 #elif defined(__APPLE__)
 #include 
+#elif defined (_WIN32)
+#include 
 #endif
 
 namespace clang {
@@ -129,6 +131,11 @@
   Priority == ThreadPriority::Low && !AvoidThreadStarvation
   ? PRIO_DARWIN_BG
   : 0);
+#elif defined(_WIN32)
+  SetThreadPriority(GetCurrentThread(),
+Priority == ThreadPriority::Low && !AvoidThreadStarvation
+? THREAD_MODE_BACKGROUND_BEGIN
+: THREAD_MODE_BACKGROUND_END);
 #endif
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D58344: Enablement for AMD znver2 architecture - skeleton

2019-02-26 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL354899: [X86] AMD znver2 enablement (authored by ggopala, 
committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D58344?vs=187387&id=188394#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D58344

Files:
  cfe/trunk/include/clang/Basic/X86Target.def
  cfe/trunk/lib/Basic/Targets/X86.cpp
  cfe/trunk/test/CodeGen/target-builtin-noerror.c
  cfe/trunk/test/Driver/x86-march.c
  cfe/trunk/test/Frontend/x86-target-cpu.c
  cfe/trunk/test/Misc/target-invalid-cpu-note.c
  cfe/trunk/test/Preprocessor/predefined-arch-macros.c

Index: cfe/trunk/include/clang/Basic/X86Target.def
===
--- cfe/trunk/include/clang/Basic/X86Target.def
+++ cfe/trunk/include/clang/Basic/X86Target.def
@@ -236,6 +236,7 @@
 /// Zen architecture processors.
 //@{
 PROC_WITH_FEAT(ZNVER1, "znver1", PROC_64_BIT, FEATURE_AVX2)
+PROC_WITH_FEAT(ZNVER2, "znver2", PROC_64_BIT, FEATURE_AVX2)
 //@}
 
 /// This specification is deprecated and will be removed in the future.
Index: cfe/trunk/test/Driver/x86-march.c
===
--- cfe/trunk/test/Driver/x86-march.c
+++ cfe/trunk/test/Driver/x86-march.c
@@ -159,3 +159,7 @@
 // RUN: %clang -target x86_64-unknown-unknown -c -### %s -march=znver1 2>&1 \
 // RUN:   | FileCheck %s -check-prefix=znver1
 // znver1: "-target-cpu" "znver1"
+//
+// RUN: %clang -target x86_64-unknown-unknown -c -### %s -march=znver2 2>&1 \
+// RUN:   | FileCheck %s -check-prefix=znver2
+// znver2: "-target-cpu" "znver2"
Index: cfe/trunk/test/Frontend/x86-target-cpu.c
===
--- cfe/trunk/test/Frontend/x86-target-cpu.c
+++ cfe/trunk/test/Frontend/x86-target-cpu.c
@@ -35,5 +35,6 @@
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -target-cpu btver1 -verify %s
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -target-cpu btver2 -verify %s
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -target-cpu znver1 -verify %s
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -target-cpu znver2 -verify %s
 //
 // expected-no-diagnostics
Index: cfe/trunk/test/CodeGen/target-builtin-noerror.c
===
--- cfe/trunk/test/CodeGen/target-builtin-noerror.c
+++ cfe/trunk/test/CodeGen/target-builtin-noerror.c
@@ -120,4 +120,5 @@
   (void)__builtin_cpu_is("tremont");
   (void)__builtin_cpu_is("westmere");
   (void)__builtin_cpu_is("znver1");
+  (void)__builtin_cpu_is("znver2");
 }
Index: cfe/trunk/test/Misc/target-invalid-cpu-note.c
===
--- cfe/trunk/test/Misc/target-invalid-cpu-note.c
+++ cfe/trunk/test/Misc/target-invalid-cpu-note.c
@@ -19,7 +19,7 @@
 // X86-SAME: skx, cascadelake, cannonlake, icelake-client, icelake-server, knl, knm, lakemont, k6, k6-2, k6-3,
 // X86-SAME: athlon, athlon-tbird, athlon-xp, athlon-mp, athlon-4, k8, athlon64,
 // X86-SAME: athlon-fx, opteron, k8-sse3, athlon64-sse3, opteron-sse3, amdfam10,
-// X86-SAME: barcelona, btver1, btver2, bdver1, bdver2, bdver3, bdver4, znver1,
+// X86-SAME: barcelona, btver1, btver2, bdver1, bdver2, bdver3, bdver4, znver1, znver2,
 // X86-SAME: x86-64, geode
 
 // RUN: not %clang_cc1 -triple x86_64--- -target-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix X86_64
@@ -30,7 +30,7 @@
 // X86_64-SAME: core-avx2, broadwell, skylake, skylake-avx512, skx, cascadelake, cannonlake,
 // X86_64-SAME: icelake-client, icelake-server, knl, knm, k8, athlon64, athlon-fx, opteron, k8-sse3,
 // X86_64-SAME: athlon64-sse3, opteron-sse3, amdfam10, barcelona, btver1,
-// X86_64-SAME: btver2, bdver1, bdver2, bdver3, bdver4, znver1, x86-64
+// X86_64-SAME: btver2, bdver1, bdver2, bdver3, bdver4, znver1, znver2, x86-64
 
 // RUN: not %clang_cc1 -triple nvptx--- -target-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix NVPTX
 // NVPTX: error: unknown target CPU 'not-a-cpu'
Index: cfe/trunk/test/Preprocessor/predefined-arch-macros.c
===
--- cfe/trunk/test/Preprocessor/predefined-arch-macros.c
+++ cfe/trunk/test/Preprocessor/predefined-arch-macros.c
@@ -2676,6 +2676,100 @@
 // CHECK_ZNVER1_M64: #define __znver1 1
 // CHECK_ZNVER1_M64: #define __znver1__ 1
 
+// RUN: %clang -march=znver2 -m32 -E -dM %s -o - 2>&1 \
+// RUN: -target i386-unknown-linux \
+// RUN:   | FileCheck -match-full-lines %s -check-prefix=CHECK_ZNVER2_M32
+// CHECK_ZNVER2_M32-NOT: #define __3dNOW_A__ 1
+// CHECK_ZNVER2_M32-NOT: #define __3dNOW__ 1
+// CHECK_ZNVER2_M32: #define __ADX__ 1
+// CHECK_ZNVER2_M32: #define __AES__ 1
+// CHECK_ZNVER2_M32: #define __AVX2__ 1
+// CHECK_ZNVER2_M32: #define __AVX__ 1
+// CHE

[PATCH] D58343: Enablement for AMD znver2 architecture - skeleton patch

2019-02-26 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL354897: [X86] AMD znver2 enablement (authored by ggopala, 
committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D58343?vs=187389&id=188391#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D58343

Files:
  llvm/trunk/include/llvm/Support/X86TargetParser.def
  llvm/trunk/lib/Support/Host.cpp
  llvm/trunk/lib/Target/X86/X86.td
  llvm/trunk/test/CodeGen/X86/cpus-amd.ll
  llvm/trunk/test/CodeGen/X86/lzcnt-zext-cmp.ll
  llvm/trunk/test/CodeGen/X86/slow-unaligned-mem.ll
  llvm/trunk/test/CodeGen/X86/x86-64-double-shifts-var.ll

Index: llvm/trunk/include/llvm/Support/X86TargetParser.def
===
--- llvm/trunk/include/llvm/Support/X86TargetParser.def
+++ llvm/trunk/include/llvm/Support/X86TargetParser.def
@@ -98,6 +98,7 @@
 X86_CPU_SUBTYPE_COMPAT("cannonlake", INTEL_COREI7_CANNONLAKE, "cannonlake")
 X86_CPU_SUBTYPE_COMPAT("icelake-client", INTEL_COREI7_ICELAKE_CLIENT, "icelake-client")
 X86_CPU_SUBTYPE_COMPAT("icelake-server", INTEL_COREI7_ICELAKE_SERVER, "icelake-server")
+X86_CPU_SUBTYPE_COMPAT("znver2", AMDFAM17H_ZNVER2,"znver2")
 // Entries below this are not in libgcc/compiler-rt.
 X86_CPU_SUBTYPE   ("core2",  INTEL_CORE2_65)
 X86_CPU_SUBTYPE   ("penryn", INTEL_CORE2_45)
Index: llvm/trunk/test/CodeGen/X86/x86-64-double-shifts-var.ll
===
--- llvm/trunk/test/CodeGen/X86/x86-64-double-shifts-var.ll
+++ llvm/trunk/test/CodeGen/X86/x86-64-double-shifts-var.ll
@@ -13,8 +13,9 @@
 ; RUN: llc < %s -mtriple=x86_64-- -mcpu=bdver3 | FileCheck %s
 ; RUN: llc < %s -mtriple=x86_64-- -mcpu=bdver4 | FileCheck %s
 ; RUN: llc < %s -mtriple=x86_64-- -mcpu=znver1 | FileCheck %s
+; RUN: llc < %s -mtriple=x86_64-- -mcpu=znver2 | FileCheck %s
 
-; Verify that for the X86_64 processors that are known to have poor latency 
+; Verify that for the X86_64 processors that are known to have poor latency
 ; double precision shift instructions we do not generate 'shld' or 'shrd'
 ; instructions.
 
@@ -25,7 +26,7 @@
 
 define i64 @lshift(i64 %a, i64 %b, i32 %c) nounwind readnone {
 entry:
-; CHECK-NOT: shld 
+; CHECK-NOT: shld
   %sh_prom = zext i32 %c to i64
   %shl = shl i64 %a, %sh_prom
   %sub = sub nsw i32 64, %c
Index: llvm/trunk/test/CodeGen/X86/cpus-amd.ll
===
--- llvm/trunk/test/CodeGen/X86/cpus-amd.ll
+++ llvm/trunk/test/CodeGen/X86/cpus-amd.ll
@@ -26,6 +26,7 @@
 ; RUN: llc < %s -o /dev/null -mtriple=x86_64-unknown-unknown -mcpu=btver1 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=x86_64-unknown-unknown -mcpu=btver2 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=x86_64-unknown-unknown -mcpu=znver1 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
+; RUN: llc < %s -o /dev/null -mtriple=x86_64-unknown-unknown -mcpu=znver2 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 
 define void @foo() {
   ret void
Index: llvm/trunk/test/CodeGen/X86/lzcnt-zext-cmp.ll
===
--- llvm/trunk/test/CodeGen/X86/lzcnt-zext-cmp.ll
+++ llvm/trunk/test/CodeGen/X86/lzcnt-zext-cmp.ll
@@ -5,6 +5,8 @@
 ; RUN: llc < %s -mtriple=x86_64-pc-linux -mcpu=btver2 -mattr=-fast-lzcnt | FileCheck --check-prefix=ALL --check-prefix=NOFASTLZCNT %s
 ; RUN: llc < %s -mtriple=x86_64-pc-linux -mcpu=znver1 | FileCheck --check-prefix=ALL --check-prefix=FASTLZCNT %s
 ; RUN: llc < %s -mtriple=x86_64-pc-linux -mcpu=znver1 -mattr=-fast-lzcnt | FileCheck --check-prefix=ALL --check-prefix=NOFASTLZCNT %s
+; RUN: llc < %s -mtriple=x86_64-pc-linux -mcpu=znver2 | FileCheck --check-prefix=ALL --check-prefix=FASTLZCNT %s
+; RUN: llc < %s -mtriple=x86_64-pc-linux -mcpu=znver2 -mattr=-fast-lzcnt | FileCheck --check-prefix=ALL --check-prefix=NOFASTLZCNT %s
 
 ; Test one 32-bit input, output is 32-bit, no transformations expected.
 define i32 @test_zext_cmp0(i32 %a) {
Index: llvm/trunk/test/CodeGen/X86/slow-unaligned-mem.ll
===
--- llvm/trunk/test/CodeGen/X86/slow-unaligned-mem.ll
+++ llvm/trunk/test/CodeGen/X86/slow-unaligned-mem.ll
@@ -47,6 +47,7 @@
 ; RUN: llc < %s -mtriple=i386-unknown-unknown -mcpu=bdver32>&1 | FileCheck %s --check-prefix=FAST
 ; RUN: llc < %s -mtriple=i386-unknown-unknown -mcpu=bdver42>&1 | FileCheck %s --check-prefix=FAST
 ; RUN: llc < %s -mtriple=i386-unknown-unknown -mcpu=znver12>&1 | FileCheck %s --check-prefix=FAST
+; RUN: llc < %s -mtriple=i386-unknown-unknown -mcpu=znver22>&1 | FileCheck %s --check-prefix=FAST
 
 ; Other chips with slow unaligned memory accesse

[PATCH] D57716: [CUDA][HIP] Check calling convention based on function target

2019-02-26 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

ping


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

https://reviews.llvm.org/D57716



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


[PATCH] D58494: [ASTImporter] Handle redecl chain of FunctionTemplateDecls

2019-02-26 Thread Gabor Marton via Phabricator via cfe-commits
martong added inline comments.



Comment at: lib/AST/ASTImporter.cpp:4966
 // it has any definition in the redecl chain.
-static ClassTemplateDecl *getDefinition(ClassTemplateDecl *D) {
-  CXXRecordDecl *ToTemplatedDef = D->getTemplatedDecl()->getDefinition();
+template  static auto getDefinition(T *D) -> T * {
+  auto *ToTemplatedDef = D->getTemplatedDecl()->getDefinition();

a_sidorin wrote:
> We should point that this function is for TemplateDecls only somehow. But we 
> can't just pass TemplateDecl as the parameter due to loss of the actual 
> return type. Maybewe should rename this function into 
> "getTemplateDefinition()"?
Ok, I changed that to `getTemplateDefinition`.



Comment at: lib/AST/ASTImporter.cpp:5563
+  // TODO: handle conflicting names
+} // linkage
+  }   // template

a_sidorin wrote:
> We don't usually put such comments after control flow statements. If they are 
> really needed, it is a good sign that a function must be split, and it's 
> better to leave a FIXME for this (or do the split).
Ok, I removed these comments and added a FIXME.


Repository:
  rC Clang

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

https://reviews.llvm.org/D58494



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


r354893 - [OpenCL] Fix assertion due to blocks

2019-02-26 Thread Yaxun Liu via cfe-commits
Author: yaxunl
Date: Tue Feb 26 08:20:41 2019
New Revision: 354893

URL: http://llvm.org/viewvc/llvm-project?rev=354893&view=rev
Log:
[OpenCL] Fix assertion due to blocks

A recent change caused assertion in CodeGenFunction::EmitBlockCallExpr when a 
block is called.

There is code

  Func = CGM.getOpenCLRuntime().getInvokeFunction(E->getCallee());
getCalleeDecl calls Expr::getReferencedDeclOfCallee, which does not handle
BlockExpr and returns nullptr, which causes isa to assert.

This patch fixes that.

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

Modified:
cfe/trunk/lib/AST/Expr.cpp
cfe/trunk/test/CodeGenOpenCL/blocks.cl

Modified: cfe/trunk/lib/AST/Expr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Expr.cpp?rev=354893&r1=354892&r2=354893&view=diff
==
--- cfe/trunk/lib/AST/Expr.cpp (original)
+++ cfe/trunk/lib/AST/Expr.cpp Tue Feb 26 08:20:41 2019
@@ -1358,6 +1358,8 @@ Decl *Expr::getReferencedDeclOfCallee()
 return DRE->getDecl();
   if (MemberExpr *ME = dyn_cast(CEE))
 return ME->getMemberDecl();
+  if (auto *BE = dyn_cast(CEE))
+return BE->getBlockDecl();
 
   return nullptr;
 }

Modified: cfe/trunk/test/CodeGenOpenCL/blocks.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/blocks.cl?rev=354893&r1=354892&r2=354893&view=diff
==
--- cfe/trunk/test/CodeGenOpenCL/blocks.cl (original)
+++ cfe/trunk/test/CodeGenOpenCL/blocks.cl Tue Feb 26 08:20:41 2019
@@ -90,6 +90,12 @@ int get42() {
   return blockArgFunc(^{return 42;});
 }
 
+// COMMON-LABEL: define {{.*}}@call_block
+// call {{.*}}@__call_block_block_invoke
+int call_block() {
+  return ^int(int num) { return num; } (11);
+}
+
 // CHECK-DEBUG: !DIDerivedType(tag: DW_TAG_member, name: "__size"
 // CHECK-DEBUG: !DIDerivedType(tag: DW_TAG_member, name: "__align"
 


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


[PATCH] D58658: [OpenCL] Fix assertion due to blocks

2019-02-26 Thread Yaxun Liu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC354893: [OpenCL] Fix assertion due to blocks (authored by 
yaxunl, committed by ).
Herald added a project: clang.

Repository:
  rC Clang

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

https://reviews.llvm.org/D58658

Files:
  lib/AST/Expr.cpp
  test/CodeGenOpenCL/blocks.cl


Index: test/CodeGenOpenCL/blocks.cl
===
--- test/CodeGenOpenCL/blocks.cl
+++ test/CodeGenOpenCL/blocks.cl
@@ -90,6 +90,12 @@
   return blockArgFunc(^{return 42;});
 }
 
+// COMMON-LABEL: define {{.*}}@call_block
+// call {{.*}}@__call_block_block_invoke
+int call_block() {
+  return ^int(int num) { return num; } (11);
+}
+
 // CHECK-DEBUG: !DIDerivedType(tag: DW_TAG_member, name: "__size"
 // CHECK-DEBUG: !DIDerivedType(tag: DW_TAG_member, name: "__align"
 
Index: lib/AST/Expr.cpp
===
--- lib/AST/Expr.cpp
+++ lib/AST/Expr.cpp
@@ -1358,6 +1358,8 @@
 return DRE->getDecl();
   if (MemberExpr *ME = dyn_cast(CEE))
 return ME->getMemberDecl();
+  if (auto *BE = dyn_cast(CEE))
+return BE->getBlockDecl();
 
   return nullptr;
 }


Index: test/CodeGenOpenCL/blocks.cl
===
--- test/CodeGenOpenCL/blocks.cl
+++ test/CodeGenOpenCL/blocks.cl
@@ -90,6 +90,12 @@
   return blockArgFunc(^{return 42;});
 }
 
+// COMMON-LABEL: define {{.*}}@call_block
+// call {{.*}}@__call_block_block_invoke
+int call_block() {
+  return ^int(int num) { return num; } (11);
+}
+
 // CHECK-DEBUG: !DIDerivedType(tag: DW_TAG_member, name: "__size"
 // CHECK-DEBUG: !DIDerivedType(tag: DW_TAG_member, name: "__align"
 
Index: lib/AST/Expr.cpp
===
--- lib/AST/Expr.cpp
+++ lib/AST/Expr.cpp
@@ -1358,6 +1358,8 @@
 return DRE->getDecl();
   if (MemberExpr *ME = dyn_cast(CEE))
 return ME->getMemberDecl();
+  if (auto *BE = dyn_cast(CEE))
+return BE->getBlockDecl();
 
   return nullptr;
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D58494: [ASTImporter] Handle redecl chain of FunctionTemplateDecls

2019-02-26 Thread Gabor Marton via Phabricator via cfe-commits
martong updated this revision to Diff 188379.
martong marked 4 inline comments as done.
martong added a comment.

- getDefinition -> getTemplateDefinition
- Remove comments for braces, added FIXME


Repository:
  rC Clang

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

https://reviews.llvm.org/D58494

Files:
  lib/AST/ASTImporter.cpp
  unittests/AST/ASTImporterTest.cpp

Index: unittests/AST/ASTImporterTest.cpp
===
--- unittests/AST/ASTImporterTest.cpp
+++ unittests/AST/ASTImporterTest.cpp
@@ -4163,9 +4163,8 @@
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(
 RedeclChain, Variable, ,
 PrototypeShouldBeImportedAsAPrototypeWhenThereIsNoDefinition)
-// FIXME Enable this test, once we import function templates chains correctly.
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(
-RedeclChain, FunctionTemplate, DISABLED_,
+RedeclChain, FunctionTemplate, ,
 PrototypeShouldBeImportedAsAPrototypeWhenThereIsNoDefinition)
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(
 RedeclChain, ClassTemplate, ,
@@ -4180,9 +4179,8 @@
 RedeclChain, Class, , DefinitionShouldBeImportedAsADefinition)
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(
 RedeclChain, Variable, , DefinitionShouldBeImportedAsADefinition)
-// FIXME Enable this test, once we import function templates chains correctly.
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(
-RedeclChain, FunctionTemplate, DISABLED_,
+RedeclChain, FunctionTemplate, ,
 DefinitionShouldBeImportedAsADefinition)
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(
 RedeclChain, ClassTemplate, , DefinitionShouldBeImportedAsADefinition)
@@ -4196,9 +4194,7 @@
 ImportPrototypeAfterImportedPrototype)
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, Variable, ,
 ImportPrototypeAfterImportedPrototype)
-// FIXME Enable this test, once we import function templates chains correctly.
-ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, FunctionTemplate,
-DISABLED_,
+ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, FunctionTemplate, ,
 ImportPrototypeAfterImportedPrototype)
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, ClassTemplate, ,
 ImportPrototypeAfterImportedPrototype)
@@ -4212,9 +4208,7 @@
 ImportDefinitionAfterImportedPrototype)
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, Variable, ,
 ImportDefinitionAfterImportedPrototype)
-// FIXME Enable this test, once we import function templates chains correctly.
-ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, FunctionTemplate,
-DISABLED_,
+ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, FunctionTemplate, ,
 ImportDefinitionAfterImportedPrototype)
 // FIXME This does not pass, possible error with ClassTemplate import.
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, ClassTemplate, DISABLED_,
@@ -4229,9 +4223,7 @@
 ImportPrototypeAfterImportedDefinition)
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, Variable, ,
 ImportPrototypeAfterImportedDefinition)
-// FIXME Enable this test, once we import function templates chains correctly.
-ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, FunctionTemplate,
-DISABLED_,
+ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, FunctionTemplate, ,
 ImportPrototypeAfterImportedDefinition)
 // FIXME This does not pass, possible error with ClassTemplate import.
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, ClassTemplate, DISABLED_,
@@ -4244,9 +4236,8 @@
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, Class, , ImportPrototypes)
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, Variable, ,
 ImportPrototypes)
-// FIXME Enable this test, once we import function templates chains correctly.
-ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, FunctionTemplate,
-DISABLED_, ImportPrototypes)
+ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, FunctionTemplate, ,
+ImportPrototypes)
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, ClassTemplate, ,
 ImportPrototypes)
 // FIXME This does not pass, possible error with Spec import.
@@ -4259,9 +4250,8 @@
 ImportDefinitions)
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, Variable, ,
 ImportDefinitions)
-// FIXME Enable this test, once we import function templates chains corr

[PATCH] D58675: [clang] Adds `-ftime-trace` option to clang that produces Chrome `chrome://tracing` compatible JSON profiling output dumps

2019-02-26 Thread Anton Afanasyev via Phabricator via cfe-commits
anton-afanasyev created this revision.
Herald added subscribers: llvm-commits, cfe-commits, jdoerfert, arphaman, 
mgrang, hiraditya, mgorny, mehdi_amini.
Herald added projects: clang, LLVM.

This is the first part of time tracing system, I have splitted them cause this 
part is mostly written by Aras Pranckevicius except of several minor fixes 
concerning formatting. I'm to commit this in behalf of Aras, we have an 
arrangment with him.
The second part extends this option adding terminal output making no need for 
profiling visualization. I can also add xray support though this need is 
arguable.
The third part is for cleaning up previous attempts of such implementations 
(like https://reviews.llvm.org/D45619, https://reviews.llvm.org/D43578 and 
https://reviews.llvm.org/D47196).

This is taken from GitHub PR: 
https://github.com/aras-p/llvm-project-20170507/pull/2
Here is cfe maillist subject discussion: 
http://lists.llvm.org/pipermail/cfe-dev/2019-January/060836.html


Repository:
  rC Clang

https://reviews.llvm.org/D58675

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Driver/Options.td
  clang/include/clang/Frontend/FrontendOptions.h
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInstance.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Parse/ParseAST.cpp
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/lib/Parse/ParseTemplate.cpp
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaTemplateInstantiate.cpp
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/lib/Serialization/GlobalModuleIndex.cpp
  clang/tools/driver/cc1_main.cpp
  llvm/lib/IR/LegacyPassManager.cpp
  llvm/lib/Support/CMakeLists.txt
  llvm/lib/Support/TimeProfiler.cpp
  llvm/lib/Support/TimeProfiler.h

Index: llvm/lib/Support/TimeProfiler.h
===
--- /dev/null
+++ llvm/lib/Support/TimeProfiler.h
@@ -0,0 +1,71 @@
+//===- llvm/Support/TimeProfiler.h - Hierarchical Time Profiler -*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_SUPPORT_TIME_PROFILER_H
+#define LLVM_SUPPORT_TIME_PROFILER_H
+
+#include "llvm/Support/raw_ostream.h"
+
+namespace llvm {
+
+struct TimeTraceProfiler;
+extern TimeTraceProfiler *TimeTraceProfilerInstance;
+
+/// Initialize the time trace profiler.
+/// This sets up the global \p TimeTraceProfilerInstance
+/// variable to be the profiler instance.
+void TimeTraceProfilerInitialize();
+
+/// Cleanup the time trace profiler, if it was initialized.
+void TimeTraceProfilerCleanup();
+
+/// Is the time trace profiler enabled, i.e. initialized?
+inline bool TimeTraceProfilerEnabled() {
+  return TimeTraceProfilerInstance != nullptr;
+}
+
+/// Write profiling data to output file.
+/// Data produced is JSON, in Chrome "Trace Event" format, see
+/// https://docs.google.com/document/d/1CvAClvFfyA5R-PhYUmn5OOQtYMH4h6I0nSsKchNAySU/preview
+void TimeTraceProfilerWrite(std::unique_ptr &OS);
+
+/// Manually begin a time section, with the given \p name and \p detail.
+/// Profiler copies the string data, so the pointers can be given into
+/// temporaries. Time sections can be hierarchical; every Begin must have a
+/// matching End pair but they can nest.
+void TimeTraceProfilerBegin(const char *name, const char *detail);
+
+/// Manually end the last time section.
+void TimeTraceProfilerEnd();
+
+/// The TimeTraceScope is a helper class to call the begin and end functions.
+/// of the time trace profiler.  When the object is constructed, it
+/// begins the section; and wen it is destroyed, it stops
+/// it.  If the time profiler is not initialized, the overhead
+/// is a single branch.
+struct TimeTraceScope {
+  TimeTraceScope(const char *name, const char *detail) {
+if (TimeTraceProfilerInstance != nullptr)
+  TimeTraceProfilerBegin(name, detail);
+  }
+  ~TimeTraceScope() {
+if (TimeTraceProfilerInstance != nullptr)
+  TimeTraceProfilerEnd();
+  }
+};
+
+/// Evaluates expression if time trace profiler is enabled, or passed null when
+/// it is not. Useful to avoid possibly expensive work in creating a string for
+/// profiling, when profiler is not enabled at all.
+#define TIME_TRACE_OR_NULL(expr)   \
+  (llvm::TimeTraceProfilerInstance != nullptr ? (expr) : nullptr)
+
+} // end namespace llvm
+
+#endif
Index: llvm/lib/Support/TimeProfiler.cpp
===
--- /dev/null
+++ llvm/lib/Support/TimeProfiler.cpp
@@ -0,0 +1,178 @@
+//===-- TimeProfiler.cpp - Hierarchical Time Profiler -===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University

[PATCH] D58137: [clang-tidy] Add the abseil-time-subtraction check

2019-02-26 Thread Hyrum Wright via Phabricator via cfe-commits
hwright marked an inline comment as done.
hwright added inline comments.



Comment at: clang-tidy/abseil/TimeSubtractionCheck.cpp:97
+void TimeSubtractionCheck::check(const MatchFinder::MatchResult &Result) {
+  const auto *BinOp = Result.Nodes.getNodeAs("binop");
+  std::string inverse_name =

hwright wrote:
> JonasToth wrote:
> > hwright wrote:
> > > JonasToth wrote:
> > > > Could you please split this function up into smaller ones. There are 
> > > > three or four distinct cases that are easier to comprehend in isolation.
> > > The actual bodies of these if-statements are only one or two separate 
> > > statements themselves.  Moving those to separate functions seems like it 
> > > would just obfuscate things a bit.
> > IMHO they are complicated statements and hide what is being done. Wrapping 
> > them in a function with a name that states what is done seems appropriate.
> I would agree that they are complicated statements, which is why there are 
> multi-line comments explaining what is being doing.  Moving a two-line 
> compound statement into a separate function which is only called once seems 
> more confusing than simplifying.  More information can be expressed in a 
> prose comment than a single concise function name, no?
I've pulled out the common duplicated functionality which actually emits the 
diagnostic, and I think that's simplified these branches a bit more.


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

https://reviews.llvm.org/D58137



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


[PATCH] D56411: [CUDA][HIP][Sema] Fix template kernel with function as template parameter

2019-02-26 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

In D56411#1410153 , @rjmccall wrote:

> In D56411#1406212 , @yaxunl wrote:
>
> > I would like to fix the validation issue only and leave the overload 
> > resolution issue for future.
>
>
> As I understand it, the "validation issue" is just that you'd like a 
> diagnostic to be emitted when resolving the template argument in order to 
> force SFINAE to pick a different template.  I think that's actually just the 
> overload-resolution issue.


Currently there are two host-ness related issues about function type template 
arguments:

1. when there are two or more candidates for the template argument, clang goes 
through host-ness based overloading resolution, which does not work properly

2. when there is only one candidate for the template argument, clang does not 
go through overloading resolution, therefore the first issue does not show up. 
However, clang still checks host-ness of template argument. As discussed 
before, clang should not check host-ness in non-evaluation or 
constant-evaluation context. Instead, clang should check host-ness in template 
instantiation.

I refer the first issue as host-ness overloading resolution issue and the 
second issue as host-ness validation issue. They are related but separate.

The first issue only happens when host-ness based overloading resolution is 
used. For applications which can be compiled with nvcc, this cannot happen, 
therefore it is less common and less urgent.

The second issue can happen to applications which can be compiled with nvcc, 
therefore is more imminent.

Fixing the second issue is relatively straightforward. It does not need to 
introduce new AST types for host-ness. Also it is orthogonal to fixing the 
first issue.


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

https://reviews.llvm.org/D56411



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


[PATCH] D58137: [clang-tidy] Add the abseil-time-subtraction check

2019-02-26 Thread Hyrum Wright via Phabricator via cfe-commits
hwright updated this revision to Diff 188372.

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

https://reviews.llvm.org/D58137

Files:
  clang-tidy/abseil/AbseilTidyModule.cpp
  clang-tidy/abseil/CMakeLists.txt
  clang-tidy/abseil/DurationRewriter.cpp
  clang-tidy/abseil/DurationRewriter.h
  clang-tidy/abseil/TimeSubtractionCheck.cpp
  clang-tidy/abseil/TimeSubtractionCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/abseil-time-subtraction.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/Inputs/absl/time/time.h
  test/clang-tidy/abseil-time-subtraction.cpp

Index: test/clang-tidy/abseil-time-subtraction.cpp
===
--- /dev/null
+++ test/clang-tidy/abseil-time-subtraction.cpp
@@ -0,0 +1,117 @@
+// RUN: %check_clang_tidy %s abseil-time-subtraction %t -- -- -I%S/Inputs
+
+#include "absl/time/time.h"
+
+void g(absl::Duration d);
+
+void f() {
+  absl::Time t;
+  int x, y;
+  absl::Duration d;
+
+  d = absl::Hours(absl::ToUnixHours(t) - x);
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform subtraction in the time domain [abseil-time-subtraction]
+  // CHECK-FIXES: d = (t - absl::FromUnixHours(x));
+  d = absl::Minutes(absl::ToUnixMinutes(t) - x);
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform subtraction in the time domain [abseil-time-subtraction]
+  // CHECK-FIXES: d = (t - absl::FromUnixMinutes(x));
+  d = absl::Seconds(absl::ToUnixSeconds(t) - x);
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform subtraction in the time domain [abseil-time-subtraction]
+  // CHECK-FIXES: d = (t - absl::FromUnixSeconds(x));
+  d = absl::Milliseconds(absl::ToUnixMillis(t) - x);
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform subtraction in the time domain [abseil-time-subtraction]
+  // CHECK-FIXES: d = (t - absl::FromUnixMillis(x));
+  d = absl::Microseconds(absl::ToUnixMicros(t) - x);
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform subtraction in the time domain [abseil-time-subtraction]
+  // CHECK-FIXES: d = (t - absl::FromUnixMicros(x));
+  d = absl::Nanoseconds(absl::ToUnixNanos(t) - x);
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform subtraction in the time domain [abseil-time-subtraction]
+  // CHECK-FIXES: d = (t - absl::FromUnixNanos(x));
+
+  y = x - absl::ToUnixHours(t);
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform subtraction in the time domain [abseil-time-subtraction]
+  // CHECK-FIXES: y = absl::ToInt64Hours(absl::FromUnixHours(x) - t);
+  y = x - absl::ToUnixMinutes(t);
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform subtraction in the time domain [abseil-time-subtraction]
+  // CHECK-FIXES: y = absl::ToInt64Minutes(absl::FromUnixMinutes(x) - t);
+  y = x - absl::ToUnixSeconds(t);
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform subtraction in the time domain [abseil-time-subtraction]
+  // CHECK-FIXES: y = absl::ToInt64Seconds(absl::FromUnixSeconds(x) - t);
+  y = x - absl::ToUnixMillis(t);
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform subtraction in the time domain [abseil-time-subtraction]
+  // CHECK-FIXES: y = absl::ToInt64Milliseconds(absl::FromUnixMillis(x) - t);
+  y = x - absl::ToUnixMicros(t);
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform subtraction in the time domain [abseil-time-subtraction]
+  // CHECK-FIXES: y = absl::ToInt64Microseconds(absl::FromUnixMicros(x) - t);
+  y = x - absl::ToUnixNanos(t);
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform subtraction in the time domain [abseil-time-subtraction]
+  // CHECK-FIXES: y = absl::ToInt64Nanoseconds(absl::FromUnixNanos(x) - t);
+
+  // Check parenthesis placement
+  d = 5 * absl::Seconds(absl::ToUnixSeconds(t) - x);
+  // CHECK-MESSAGES: [[@LINE-1]]:11: warning: perform subtraction in the time domain [abseil-time-subtraction]
+  // CHECK-FIXES: d = 5 * (t - absl::FromUnixSeconds(x));
+  d = absl::Seconds(absl::ToUnixSeconds(t) - x) / 5;
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform subtraction in the time domain [abseil-time-subtraction]
+  // CHECK-FIXES: d = (t - absl::FromUnixSeconds(x)) / 5;
+
+  // No extra parens around arguments
+  g(absl::Seconds(absl::ToUnixSeconds(t) - x));
+  // CHECK-MESSAGES: [[@LINE-1]]:5: warning: perform subtraction in the time domain [abseil-time-subtraction]
+  // CHECK-FIXES: g(t - absl::FromUnixSeconds(x));
+  g(absl::Seconds(x - absl::ToUnixSeconds(t)));
+  // CHECK-MESSAGES: [[@LINE-1]]:5: warning: perform subtraction in the time domain [abseil-time-subtraction]
+  // CHECK-FIXES: g(absl::FromUnixSeconds(x) - t);
+
+  // More complex subexpressions
+  d = absl::Hours(absl::ToUnixHours(t) - 5 * x);
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform subtraction in the time domain [abseil-time-subtraction]
+  // CHECK-FIXES: d = (t - absl::FromUnixHours(5 * x));
+
+  // These should not trigger; they are likely bugs
+  d = absl::Milliseconds(absl::ToUnixSeconds(t) - x);
+  d = absl::Seconds(absl::ToUnixMicros(t) - x);
+
+  // Variou

[PATCH] D58035: [clang/DIVar] Emit flag for params that have unchanged values

2019-02-26 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro marked an inline comment as done.
djtodoro added inline comments.



Comment at: lib/Sema/SemaExpr.cpp:11292
+}
+
+/// Argument's value might be modified, so update the info.

riccibruno wrote:
> Hmm, I don't think that this will work. Suppose that you have an expression 
> like `(a, b) += c`  You want to mark `b` as modified, but not `a`. What is 
> needed I believe is:
> 
> Given an expression `E` find the variable that this expression designate if 
> any, and if it is a function parameter mark it "known to be modified".
> 
> Visiting all of the children just looking for `DeclRefExpr`s is a bit too 
> blunt I believe.
You are right. We thought it is possible implementing this with some basic 
analysis (with low overhead), but in order to support all cases it would take 
much time and it is not good idea.

I tried to use `ExprMutationAnalyzer ` (that @lebedev.ri mentioned) and it 
seems to be useful for this. It seems that it can be used a little bit later 
than in this phase, because it takes ASTContext, but in this stage we have 
ASTContext finished up to node we are currently observing (an expression from 
which we are extracting DeclRef). But, even using it in the right time, it 
seems that `ExprMutationAnalyzer ` does not have support for comma operator. 
I'm trying to extend this analyzer in order to add support for that. ASAP I 
will post new changes.
For the other cases I tried, it works.


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

https://reviews.llvm.org/D58035



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


[PATCH] D56943: [clang-format][NFC] Allow getLLVMStyle() to take a language

2019-02-26 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added inline comments.
Herald added a subscriber: jdoerfert.



Comment at: clang/lib/Format/ContinuationIndenter.cpp:193
   RawStringFormat.Language, &PredefinedStyle)) {
-PredefinedStyle = getLLVMStyle();
+PredefinedStyle = getLLVMStyle(FormatStyle::LK_Cpp);
 PredefinedStyle.Language = RawStringFormat.Language;

if you've set up a default argument of LK_Cpp do you need to keep supplying it? 
if your going to supply it everywhere don't make it a default argument or vice 
versa

This might make a much smaller patch, a little more digestable and all the 
tests can remain as they are.


Repository:
  rC Clang

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

https://reviews.llvm.org/D56943



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


[PATCH] D58569: [libclang] Avoid crashing when getting layout info of an undeduced type.

2019-02-26 Thread Emilio Cobos Álvarez via Phabricator via cfe-commits
emilio added a comment.

Thank you for all the reviews! :)


Repository:
  rC Clang

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

https://reviews.llvm.org/D58569



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


[PATCH] D58569: [libclang] Avoid crashing when getting layout info of an undeduced type.

2019-02-26 Thread Emilio Cobos Álvarez via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
emilio marked an inline comment as done.
Closed by commit rC354885: [libclang] Avoid crashing when getting layout info 
of an undeduced type. (authored by emilio, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D58569?vs=188254&id=188371#toc

Repository:
  rC Clang

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

https://reviews.llvm.org/D58569

Files:
  include/clang-c/Index.h
  test/Index/print-type-size.cpp
  tools/c-index-test/c-index-test.c
  tools/libclang/CXType.cpp

Index: include/clang-c/Index.h
===
--- include/clang-c/Index.h
+++ include/clang-c/Index.h
@@ -32,7 +32,7 @@
  * compatible, thus CINDEX_VERSION_MAJOR is expected to remain stable.
  */
 #define CINDEX_VERSION_MAJOR 0
-#define CINDEX_VERSION_MINOR 52
+#define CINDEX_VERSION_MINOR 53
 
 #define CINDEX_VERSION_ENCODE(major, minor) ( \
   ((major) * 1)   \
@@ -3841,7 +3841,11 @@
   /**
* The Field name is not valid for this record.
*/
-  CXTypeLayoutError_InvalidFieldName = -5
+  CXTypeLayoutError_InvalidFieldName = -5,
+  /**
+   * The type is undeduced.
+   */
+  CXTypeLayoutError_Undeduced = -6
 };
 
 /**
Index: test/Index/print-type-size.cpp
===
--- test/Index/print-type-size.cpp
+++ test/Index/print-type-size.cpp
@@ -400,4 +400,10 @@
 struct lastValid {
 };
 
+// CHECK64: CXXMethod=Tie:[[@LINE+3]]:8 (const) [type=auto (void *) const] [typekind=FunctionProto] [sizeof=1] [alignof=4] [resulttype=auto] [resulttypekind=Auto] [resultsizeof=-6] [resultalignof=-6]
+// CHECK32: CXXMethod=Tie:[[@LINE+2]]:8 (const) [type=auto (void *) const] [typekind=FunctionProto] [sizeof=1] [alignof=4] [resulttype=auto] [resulttypekind=Auto] [resultsizeof=-6] [resultalignof=-6]
+class BrowsingContext {
+  auto Tie(void*) const;
+};
+
 }
Index: tools/c-index-test/c-index-test.c
===
--- tools/c-index-test/c-index-test.c
+++ tools/c-index-test/c-index-test.c
@@ -1670,29 +1670,44 @@
   return CXChildVisit_Recurse;
 }
 
-static enum CXChildVisitResult PrintTypeSize(CXCursor cursor, CXCursor p,
- CXClientData d) {
-  CXType T;
-  enum CXCursorKind K = clang_getCursorKind(cursor);
-  if (clang_isInvalid(K))
-return CXChildVisit_Recurse;
-  T = clang_getCursorType(cursor);
-  PrintCursor(cursor, NULL);
-  PrintTypeAndTypeKind(T, " [type=%s] [typekind=%s]");
+static void PrintSingleTypeSize(CXType T, const char *TypeKindFormat,
+const char *SizeFormat,
+const char *AlignFormat) {
+  PrintTypeAndTypeKind(T, TypeKindFormat);
   /* Print the type sizeof if applicable. */
   {
 long long Size = clang_Type_getSizeOf(T);
 if (Size >= 0 || Size < -1 ) {
-  printf(" [sizeof=%lld]", Size);
+  printf(SizeFormat, Size);
 }
   }
   /* Print the type alignof if applicable. */
   {
 long long Align = clang_Type_getAlignOf(T);
 if (Align >= 0 || Align < -1) {
-  printf(" [alignof=%lld]", Align);
+  printf(AlignFormat, Align);
 }
   }
+
+  /* Print the return type if it exists. */
+  {
+CXType RT = clang_getResultType(T);
+if (RT.kind != CXType_Invalid)
+  PrintSingleTypeSize(RT, " [resulttype=%s] [resulttypekind=%s]",
+  " [resultsizeof=%lld]", " [resultalignof=%lld]");
+  }
+}
+
+static enum CXChildVisitResult PrintTypeSize(CXCursor cursor, CXCursor p,
+ CXClientData d) {
+  CXType T;
+  enum CXCursorKind K = clang_getCursorKind(cursor);
+  if (clang_isInvalid(K))
+return CXChildVisit_Recurse;
+  T = clang_getCursorType(cursor);
+  PrintCursor(cursor, NULL);
+  PrintSingleTypeSize(T, " [type=%s] [typekind=%s]", " [sizeof=%lld]",
+  " [alignof=%lld]");
   /* Print the record field offset if applicable. */
   {
 CXString FieldSpelling = clang_getCursorSpelling(cursor);
@@ -1730,7 +1745,9 @@
 if (IsBitfield)
   printf(" [BitFieldSize=%d]", clang_getFieldDeclBitWidth(cursor));
   }
+
   printf("\n");
+
   return CXChildVisit_Recurse;
 }
 
Index: tools/libclang/CXType.cpp
===
--- tools/libclang/CXType.cpp
+++ tools/libclang/CXType.cpp
@@ -891,6 +891,9 @@
 return CXTypeLayoutError_Incomplete;
   if (QT->isDependentType())
 return CXTypeLayoutError_Dependent;
+  if (const auto *Deduced = dyn_cast(QT))
+if (Deduced->getDeducedType().isNull())
+  return CXTypeLayoutError_Undeduced;
   // Exceptions by GCC extension - see ASTContext.cpp:1313 getTypeInfoImpl
   // if (QT->isFunctionType()) return 4; // Bug #15511 - should be 1
   // if (QT->isVoidType()) return 1;
@@ -928,6 +931,9 @@
 return CXTypeLayoutError

  1   2   >