[PATCH] D112941: [clang] Add support for the new pointer authentication builtins.

2021-11-08 Thread Kristof Beyls via Phabricator via cfe-commits
kristof.beyls added inline comments.



Comment at: clang/lib/Headers/ptrauth.h:19-37
+  /* A process-independent key which can be used to sign code pointers.
+ Signing and authenticating with this key is a no-op in processes
+ which disable ABI pointer authentication. */
+  ptrauth_key_process_independent_code = ptrauth_key_asia,
+
+  /* A process-specific key which can be used to sign code pointers.
+ Signing and authenticating with this key is enforced even in processes

rjmccall wrote:
> kristof.beyls wrote:
> > I think, but am not sure, that the decision of which keys are process 
> > independent and which ones are process-dependent is a software platform 
> > choice?
> > If so, maybe ptrauth_key_process_{in,}dependent_* should only get defined 
> > conditionally?
> > I'm not sure if any decisions have been taken already for e.g. linux, 
> > Android, other platforms.
> > If not, maybe this block of code should be surrounded by an ifdef that is 
> > enabled only when targeting Darwin?
> Yes, in retrospect it was a bad idea to define these particular generic 
> names.  I believe Apple platforms no longer have "process-independent" keys.  
> It should really just be (1) the concrete keys, (2) recommended default keys 
> for code and data pointers, and then (3) the specific keys used in specific 
> schemas.  Beyond that, if people want a specific different key for some 
> purpose, they should ask for it.
> 
> Unfortunately, there's already a fair amount of code using these names.  We 
> could deprecate the old names and point people towards the new names, though.
Thanks for those background insights!
I was thinking that maybe the keys that should be deprecated could be enabled 
only when targeting Apple platforms? I'm assuming here that most existing code 
using these only target Apple platforms; so making them available only when 
targeting Apple platforms could help with not letting the use of them spread 
further without impacting existing code much?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112941

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


[PATCH] D113120: [clang] Add early exit when checking for const init of arrays.

2021-11-08 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet accepted this revision.
kadircet added a comment.
This revision is now accepted and ready to land.

thanks, lgtm!




Comment at: clang/lib/AST/ExprConstant.cpp:10617
+// copying the data, which is wasteful.
+for (const unsigned N : {1u, FinalSize}) {
+  unsigned OldElts = Value->getArrayInitializedElts();

adamcz wrote:
> kadircet wrote:
> > maybe unroll the loop with a helper like `checkConstantInitialization` and 
> > just call it for a single element first and perform copy & call again for 
> > the whole thing ?
> > 
> > that way we can migrate performance issues later on (e.g. put a threshold 
> > on `FinalSize`, don't perform the small step check if it's less than 100, 
> > since copying might introduce a significant extra latency in such cases).
> > 
> > WDYT?
> I thought of that and decided against it. I think the for loop gives us the 
> same ability to change the steps - we can just replace {1u, FinalSize} with a 
> vector that could have only one element if FinalSize is below some threshold.
> 
> Something like:
> std::vector steps;
> if (FinalSize < 100) steps = {FinalSize};
> else steps = {1u, FinalSize};
> for (const unsigned N : steps) {
> [...]
> 
> The problem with helper is that it need sooo many arguments:
> N, E, ArrayElt, CAT, Filler, HadZeroInit, Value and "this" (assuming it's 
> free function). Seems like it would hurt readability quite a bit.
> 
> If you still think it should be a helper, let me know and I won't argue 
> further - when it comes to readability the reviewer always knows better :-)
sorry I was actually implying a lambda with the "helper" (should've been more 
explicit && at least use the correct style :D), to prevent the plumbing 
massacre.

having an earlier logic to decide on the steps if need be also sounds like a 
good approach though. so feel free to ignore.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113120

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


[PATCH] D113390: [clangd] Dont include file version in task name

2021-11-08 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet created this revision.
kadircet added a reviewer: sammccall.
Herald added subscribers: usaxena95, arphaman, javed.absar.
kadircet requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang-tools-extra.

This will drop file version information from span names, reducing
overall cardinality and also effect logging when skipping actions in scheduler.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D113390

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


Index: clang-tools-extra/clangd/TUScheduler.cpp
===
--- clang-tools-extra/clangd/TUScheduler.cpp
+++ clang-tools-extra/clangd/TUScheduler.cpp
@@ -992,7 +992,7 @@
std::shared_ptr Preamble,
std::vector CIDiags,
WantDiagnostics WantDiags) {
-  std::string TaskName = llvm::formatv("Build AST for ({0})", PI.Version);
+  llvm::StringLiteral TaskName = "Build AST";
   // Store preamble and build diagnostics with new preamble if requested.
   auto Task = [this, Preamble = std::move(Preamble), CI = std::move(CI),
PI = std::move(PI), CIDiags = std::move(CIDiags),
@@ -1032,7 +1032,7 @@
   }
   {
 std::lock_guard Lock(Mutex);
-PreambleRequests.push_back({std::move(Task), std::move(TaskName),
+PreambleRequests.push_back({std::move(Task), std::string(TaskName),
 steady_clock::now(), 
Context::current().clone(),
 llvm::None, llvm::None,
 TUScheduler::NoInvalidation, nullptr});


Index: clang-tools-extra/clangd/TUScheduler.cpp
===
--- clang-tools-extra/clangd/TUScheduler.cpp
+++ clang-tools-extra/clangd/TUScheduler.cpp
@@ -992,7 +992,7 @@
std::shared_ptr Preamble,
std::vector CIDiags,
WantDiagnostics WantDiags) {
-  std::string TaskName = llvm::formatv("Build AST for ({0})", PI.Version);
+  llvm::StringLiteral TaskName = "Build AST";
   // Store preamble and build diagnostics with new preamble if requested.
   auto Task = [this, Preamble = std::move(Preamble), CI = std::move(CI),
PI = std::move(PI), CIDiags = std::move(CIDiags),
@@ -1032,7 +1032,7 @@
   }
   {
 std::lock_guard Lock(Mutex);
-PreambleRequests.push_back({std::move(Task), std::move(TaskName),
+PreambleRequests.push_back({std::move(Task), std::string(TaskName),
 steady_clock::now(), Context::current().clone(),
 llvm::None, llvm::None,
 TUScheduler::NoInvalidation, nullptr});
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D111190: Comment parsing: Complete list of Doxygen commands

2021-11-08 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 accepted this revision.
gribozavr2 added a comment.
This revision is now accepted and ready to land.

Sorry for the delayed response! LGTM modulo the unit test comment. Please let 
me know if you don't have commit access and you need me to push on your behalf.




Comment at: clang/lib/AST/CommentLexer.cpp:399
+if (C == '$' || C == '(' || C == ')' || C == '[' || C == ']' ||
+C == '{' || C == '}') {
   TokenPtr++;

Please add adjust the unit test: clang/unittests/AST/CommentLexer.cpp 
(`TEST_F(CommentLexerTest, VerbatimBlock9)`)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90

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


[PATCH] D111262: Comment AST: Factor out function type extraction in DeclInfo::fill (NFC)

2021-11-08 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 accepted this revision.
gribozavr2 added inline comments.
This revision is now accepted and ready to land.



Comment at: clang/lib/AST/Comment.cpp:337
+  if (Kind == TypedefKind)
+Kind = FunctionKind;
   ParamVars = FTL.getParams();

Phabricator shows a `>>` chevron on this line, which might be an accidental 
tab. If it is one, please replace with spaces.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111262

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


[PATCH] D112915: WIP: [clang][modules] Granular tracking of includes

2021-11-08 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 updated this revision to Diff 385434.
jansvoboda11 added a comment.
Herald added a subscriber: mgrang.

Fix deserialization, improve (sub)module state tracking


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112915

Files:
  clang/include/clang/Lex/HeaderSearch.h
  clang/include/clang/Lex/Preprocessor.h
  clang/include/clang/Serialization/ASTBitCodes.h
  clang/lib/Lex/HeaderSearch.cpp
  clang/lib/Lex/PPDirectives.cpp
  clang/lib/Lex/PPLexerChange.cpp
  clang/lib/Lex/Preprocessor.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/Modules/Inputs/import-submodule-visibility/A.framework/Headers/A.h
  
clang/test/Modules/Inputs/import-submodule-visibility/A.framework/Modules/module.modulemap
  clang/test/Modules/Inputs/import-submodule-visibility/B.framework/Headers/B1.h
  clang/test/Modules/Inputs/import-submodule-visibility/B.framework/Headers/B2.h
  
clang/test/Modules/Inputs/import-submodule-visibility/B.framework/Modules/module.modulemap
  clang/test/Modules/Inputs/import-submodule-visibility/C/C.h
  clang/test/Modules/Inputs/import-submodule-visibility/C/module.modulemap
  clang/test/Modules/Inputs/import-submodule-visibility/D/D1.h
  clang/test/Modules/Inputs/import-submodule-visibility/D/D2.h
  clang/test/Modules/Inputs/import-submodule-visibility/D/module.modulemap
  clang/test/Modules/Inputs/import-submodule-visibility/Textual.h
  clang/test/Modules/import-submodule-visibility.c

Index: clang/test/Modules/import-submodule-visibility.c
===
--- /dev/null
+++ clang/test/Modules/import-submodule-visibility.c
@@ -0,0 +1,58 @@
+// RUN: rm -rf %t && mkdir -p %t
+
+// This test checks that imports of headers that appeared in a different submodule than
+// what is imported by the current TU don't affect the compilation.
+
+// Framework "A" includes "Textual.h" in the top-level module.
+// This test checks that simply specifying the PCM file on the command line (without actually importing "A") does not
+// prevent "Textual.h" to be included in the TU.
+//
+// RUN: %clang_cc1 -fmodules -I %S/Inputs/import-submodule-visibility \
+// RUN:   -emit-module %S/Inputs/import-submodule-visibility/A.framework/Modules/module.modulemap -fmodule-name=A -o %t/A.pcm
+// RUN: %clang_cc1 -fmodules -I %S/Inputs/import-submodule-visibility -fsyntax-only %s -DA \
+// RUN:   -fmodule-file=%t/A.pcm -fmodule-map-file=%S/Inputs/import-submodule-visibility/A.framework/Modules/module.modulemap
+
+// Framework "B" includes "Textual.h" in the "B1" submodule and its "B2" submodule does not include "Textual.h" at all.
+// This test checks that specifying the PCM file on the command line and importing "B2" in the source does not
+// prevent "Textual.h" to be included in the TU.
+//
+// RUN: %clang_cc1 -fmodules -I %S/Inputs/import-submodule-visibility \
+// RUN:   -emit-module %S/Inputs/import-submodule-visibility/B.framework/Modules/module.modulemap -fmodule-name=B -o %t/B.pcm
+// RUN: %clang_cc1 -fmodules -I %S/Inputs/import-submodule-visibility -fsyntax-only %s -DB -iframework %S/Inputs/import-submodule-visibility \
+// RUN:   -fmodule-file=%t/B.pcm -fmodule-map-file=%S/Inputs/import-submodule-visibility/B.framework/Modules/module.modulemap
+
+// Module "C" includes "Textual.h" in the top level module.
+// This is a module-only version of the test with framework A.
+//
+// RUN: %clang_cc1 -fmodules -I %S/Inputs/import-submodule-visibility \
+// RUN:   -emit-module %S/Inputs/import-submodule-visibility/C/module.modulemap -fmodule-name=C -o %t/C.pcm
+// RUN: %clang_cc1 -fmodules -I %S/Inputs/import-submodule-visibility -fsyntax-only %s -DC \
+// RUN:   -fmodule-file=%t/C.pcm -fmodule-map-file=%S/Inputs/import-submodule-visibility/C/module.modulemap
+
+// Module "D" includes "Textual.h" in the "D1" submodule and its "D2" submodules does not include "Textual.h" at all.
+// This is a module-only version of the test with framework B.
+//
+// RUN: %clang_cc1 -fmodules -I %S/Inputs/import-submodule-visibility \
+// RUN:   -emit-module %S/Inputs/import-submodule-visibility/D/module.modulemap -fmodule-name=D -o %t/D.pcm
+// RUN: %clang_cc1 -fmodules -I %S/Inputs/import-submodule-visibility -fsyntax-only %s -DD \
+// RUN:   -fmodule-file=%t/D.pcm -fmodule-map-file=%S/Inputs/import-submodule-visibility/D/module.modulemap
+
+#ifdef A
+//
+#endif
+
+#ifdef B
+#import 
+#endif
+
+#ifdef C
+//
+#endif
+
+#ifdef D
+#import "D/D2.h"
+#endif
+
+#import "Textual.h"
+
+static int x = MACRO_TEXTUAL;
Index: clang/test/Modules/Inputs/import-submodule-visibility/Textual.h
===
--- /dev/null
+++ clang/test/Modules/Inputs/import-submodule-visibility/Textual.h
@@ -0,0 +1 @@
+#define MACRO_TEXTUAL 1
Index: clang/test/Modules/Inputs/import-submodule-visibility/D/module.modulemap
==

[PATCH] D109885: [MLIR][[amdgpu-arch]][OpenMP] Remove direct dependency on /opt/rocm

2021-11-08 Thread DineshKumar Bhaskaran via Phabricator via cfe-commits
dbhaskaran added a comment.

In D109885#3004269 , @JonChesterfield 
wrote:

> Dropping PATHS /opt/rocm from the openmp parts will break people using an 
> existing rocm install with trunk llvm. I think it would be reasonable to look 
> at whatever ROCM_PATH is set to instead of assuming /opt/rocm. Is that a 
> variable we can pass to find_package?

Added ROCM_PATH environment variable.




Comment at: mlir/lib/Dialect/GPU/CMakeLists.txt:137
   set(CMAKE_MODULE_PATH "${HIP_PATH}/cmake" ${CMAKE_MODULE_PATH})
   find_package(HIP)
   if (NOT HIP_FOUND)

ye-luo wrote:
> Both ROCM_PATH HIP_PATH are used as hints without verification.
> But they are used later for generating include paths. Overall logic is broken.
> 
> if ROCM_PATH takes the precedence over everything else
> You can do this
> if ROCM_PATH defined
> find_path(
>   HIP_MODULE_FILE_DIR FindHIP.cmake
>   HINTS ${ROCM_PATH}
>   PATH_SUFFIXES hip/cmake REQUIRED
>   NO_DEFAULT_PATH)
> else
> find_path(
>   HIP_MODULE_FILE_DIR FindHIP.cmake
>   HINTS $ENV{ROCM_PATH} /opt/rocm
>   PATH_SUFFIXES hip/cmake REQUIRED)
> endif
> 
> by doing this, you can verify that ROCM_PATH is correct if provided and the 
> path the hip module file has been verified. then it is safe to do
> set(CMAKE_MODULE_PATH "${HIP_MODULE_FILE_DIR}" ${CMAKE_MODULE_PATH})
> find_package(HIP)
The primary intention here is to avoid fallback to a default ROCM path  to 
avoid unwanted issues related to multiple installation, however I agree the we 
should use paths with verification so I have accommodated the changes for HIP 
excluding the hint. Thanks for the code snippets. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109885

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


[PATCH] D109885: [MLIR][[amdgpu-arch]][OpenMP] Remove direct dependency on /opt/rocm

2021-11-08 Thread DineshKumar Bhaskaran via Phabricator via cfe-commits
dbhaskaran updated this revision to Diff 385398.
dbhaskaran added a comment.

Updated with review comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109885

Files:
  clang/tools/amdgpu-arch/CMakeLists.txt
  mlir/lib/Dialect/GPU/CMakeLists.txt
  mlir/lib/ExecutionEngine/CMakeLists.txt
  openmp/libomptarget/plugins/amdgpu/CMakeLists.txt

Index: openmp/libomptarget/plugins/amdgpu/CMakeLists.txt
===
--- openmp/libomptarget/plugins/amdgpu/CMakeLists.txt
+++ openmp/libomptarget/plugins/amdgpu/CMakeLists.txt
@@ -14,7 +14,11 @@
 
 
 # as of rocm-3.7, hsa is installed with cmake packages and kmt is found via hsa
-find_package(hsa-runtime64 QUIET 1.2.0 HINTS ${CMAKE_INSTALL_PREFIX} PATHS /opt/rocm)
+if (DEFINED ENV{ROCM_PATH})
+  set(ROCM_PATH $ENV{ROCM_PATH} CACHE PATH "Path to which ROCm has been installed")
+endif()
+
+find_package(hsa-runtime64 QUIET 1.2.0 HINTS ${CMAKE_INSTALL_PREFIX} PATH ${ROCM_PATH})
 
 if(NOT LIBOMPTARGET_DEP_LIBELF_FOUND)
   libomptarget_say("Not building AMDGPU plugin: LIBELF not found")
Index: mlir/lib/ExecutionEngine/CMakeLists.txt
===
--- mlir/lib/ExecutionEngine/CMakeLists.txt
+++ mlir/lib/ExecutionEngine/CMakeLists.txt
@@ -142,13 +142,17 @@
   # Configure ROCm support.
   if (NOT DEFINED ROCM_PATH)
 if (NOT DEFINED ENV{ROCM_PATH})
-  set(ROCM_PATH "/opt/rocm" CACHE PATH "Path to which ROCm has been installed")
+  message(SEND_ERROR "Building mlir with ROCm support requires a working ROCm")
 else()
   set(ROCM_PATH $ENV{ROCM_PATH} CACHE PATH "Path to which ROCm has been installed")
 endif()
-set(HIP_PATH "${ROCM_PATH}/hip" CACHE PATH "Path to which HIP has been installed")
   endif()
-  set(CMAKE_MODULE_PATH "${HIP_PATH}/cmake" ${CMAKE_MODULE_PATH})
+
+  find_path(HIP_MODULE_FILE_DIR FindHIP.cmake
+HINTS ${ROCM_PATH}
+PATH_SUFFIXES hip/cmake REQUIRED
+NO_DEFAULT_PATH)
+  set(CMAKE_MODULE_PATH "${HIP_MODULE_FILE_DIR}" ${CMAKE_MODULE_PATH})
   find_package(HIP)
   if (NOT HIP_FOUND)
 message(SEND_ERROR "Building mlir with ROCm support requires a working ROCm and HIP install")
@@ -158,7 +162,8 @@
 
   # Locate HIP runtime library.
   find_library(ROCM_RUNTIME_LIBRARY amdhip64
-   PATHS "${HIP_PATH}/lib")
+  PATHS "${ROCM_PATH}"
+  PATH_SUFFIXES hip/lib)
   if (NOT ROCM_RUNTIME_LIBRARY)
 message(SEND_ERROR "Could not locate ROCm HIP runtime library")
   else()
@@ -177,7 +182,6 @@
   )
   target_include_directories(mlir_rocm_runtime
 PRIVATE
-${HIP_PATH}/include
 ${ROCM_PATH}/include
   )
   target_link_libraries(mlir_rocm_runtime
Index: mlir/lib/Dialect/GPU/CMakeLists.txt
===
--- mlir/lib/Dialect/GPU/CMakeLists.txt
+++ mlir/lib/Dialect/GPU/CMakeLists.txt
@@ -130,13 +130,17 @@
   # Configure ROCm support.
   if (NOT DEFINED ROCM_PATH)
 if (NOT DEFINED ENV{ROCM_PATH})
-  set(ROCM_PATH "/opt/rocm" CACHE PATH "Path to which ROCm has been installed")
+  message(SEND_ERROR "Building mlir with ROCm support requires a working ROCm")
 else()
   set(ROCM_PATH $ENV{ROCM_PATH} CACHE PATH "Path to which ROCm has been installed")
 endif()
-set(HIP_PATH "${ROCM_PATH}/hip" CACHE PATH " Path to which HIP has been installed")
   endif()
-  set(CMAKE_MODULE_PATH "${HIP_PATH}/cmake" ${CMAKE_MODULE_PATH})
+
+  find_path(HIP_MODULE_FILE_DIR FindHIP.cmake
+HINTS ${ROCM_PATH}
+PATH_SUFFIXES hip/cmake REQUIRED
+NO_DEFAULT_PATH)
+  set(CMAKE_MODULE_PATH "${HIP_MODULE_FILE_DIR}" ${CMAKE_MODULE_PATH})
   find_package(HIP)
   if (NOT HIP_FOUND)
 message(SEND_ERROR "Building mlir with ROCm support requires a working ROCm and HIP install")
@@ -154,7 +158,6 @@
   target_include_directories(obj.MLIRGPUOps
 PRIVATE
 ${MLIR_SOURCE_DIR}/../lld/include
-${HIP_PATH}/include
 ${ROCM_PATH}/include
   )
 
Index: clang/tools/amdgpu-arch/CMakeLists.txt
===
--- clang/tools/amdgpu-arch/CMakeLists.txt
+++ clang/tools/amdgpu-arch/CMakeLists.txt
@@ -6,7 +6,11 @@
 # //
 # //===--===//
 
-find_package(hsa-runtime64 QUIET 1.2.0 HINTS ${CMAKE_INSTALL_PREFIX} PATHS /opt/rocm)
+if (DEFINED ENV{ROCM_PATH})
+  set(ROCM_PATH $ENV{ROCM_PATH} CACHE PATH "Path to which ROCm has been installed")
+endif()
+
+find_package(hsa-runtime64 QUIET 1.2.0 HINTS ${CMAKE_INSTALL_PREFIX} PATH ${ROCM_PATH})
 if (NOT ${hsa-runtime64_FOUND})
   message(STATUS "Not building amdgpu-arch: hsa-runtime64 not found")
   return()
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm

[PATCH] D113391: [Modules] Don't support clang module and c++20 module at the same time

2021-11-08 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu updated this revision to Diff 385440.
ChuanqiXu added reviewers: aaron.ballman, rsmith, urnathan, dblaikie.
ChuanqiXu set the repository for this revision to rG LLVM Github Monorepo.
ChuanqiXu added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113391

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/include/clang/Basic/DiagnosticFrontendKinds.td
  clang/include/clang/Basic/Features.def
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Basic/LangOptions.h
  clang/include/clang/Driver/Options.td
  clang/include/clang/Lex/Preprocessor.h
  clang/lib/ARCMigrate/ObjCMT.cpp
  clang/lib/AST/Decl.cpp
  clang/lib/AST/DeclCXX.cpp
  clang/lib/AST/DeclObjC.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/ASTUnit.cpp
  clang/lib/Frontend/CompilerInstance.cpp
  clang/lib/Frontend/FrontendAction.cpp
  clang/lib/Frontend/FrontendActions.cpp
  clang/lib/Lex/PPDirectives.cpp
  clang/lib/Lex/Preprocessor.cpp
  clang/lib/Parse/ParseObjc.cpp
  clang/lib/Sema/SemaCodeComplete.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclObjC.cpp
  clang/lib/Sema/SemaLookup.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaType.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTReaderDecl.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/ClangScanDeps/Inputs/header-search-pruning/cdb.json
  clang/test/ClangScanDeps/Inputs/module_fmodule_name_cdb.json
  clang/test/ClangScanDeps/Inputs/modules_cdb.json
  clang/test/ClangScanDeps/Inputs/modules_cdb_by_mod_name.json
  clang/test/ClangScanDeps/Inputs/modules_cdb_clangcl.json
  clang/test/ClangScanDeps/Inputs/modules_cdb_clangcl_by_mod_name.json
  clang/test/ClangScanDeps/Inputs/modules_inferred_cdb.json
  clang/test/Driver/conflict-clang-module-and-cxx20-module.cpp
  clang/test/Modules/cxx20.cpp
  clang/test/Modules/ms-enums.cpp
  clang/test/SemaCXX/compare-modules-cxx2a.cpp
  clang/tools/libclang/Indexing.cpp

Index: clang/tools/libclang/Indexing.cpp
===
--- clang/tools/libclang/Indexing.cpp
+++ clang/tools/libclang/Indexing.cpp
@@ -604,7 +604,7 @@
 PPOpts.DetailedRecord = true;
   }
 
-  if (!requestedToGetTU && !CInvok->getLangOpts()->Modules)
+  if (!requestedToGetTU && !CInvok->getLangOpts()->hasModules())
 PPOpts.DetailedRecord = false;
 
   // Unless the user specified that they want the preamble on the first parse
Index: clang/test/SemaCXX/compare-modules-cxx2a.cpp
===
--- clang/test/SemaCXX/compare-modules-cxx2a.cpp
+++ clang/test/SemaCXX/compare-modules-cxx2a.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin -fcxx-exceptions -verify -std=c++2a -fmodules -I%S/Inputs %s -fno-modules-error-recovery
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -fcxx-exceptions -verify -std=c++2a -fmodules -fno-cxx-modules -I%S/Inputs %s -fno-modules-error-recovery
 
 #pragma clang module build compare
 module compare {
Index: clang/test/Modules/ms-enums.cpp
===
--- clang/test/Modules/ms-enums.cpp
+++ clang/test/Modules/ms-enums.cpp
@@ -1,5 +1,5 @@
 // RUN: rm -rf %t
-// RUN: %clang_cc1 -triple x86_64-windows-msvc -fms-extensions -fms-compatibility -x c++ -std=c++20 -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -I %S/Inputs/ms-enums %s -verify -fno-modules-error-recovery
+// RUN: %clang_cc1 -triple x86_64-windows-msvc -fms-extensions -fms-compatibility -x c++ -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -I %S/Inputs/ms-enums %s -verify -fno-modules-error-recovery
 
 #include "B.h"
 // expected-note@A.h:1 {{declaration here is not visible}}
Index: clang/test/Modules/cxx20.cpp
===
--- clang/test/Modules/cxx20.cpp
+++ clang/test/Modules/cxx20.cpp
@@ -1,5 +1,5 @@
 // RUN: rm -rf %t
-// RUN: %clang_cc1 -x c++ -std=c++20 -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -I %S/Inputs/cxx20 %s -verify -fno-modules-error-recovery
+// RUN: %clang_cc1 -x c++ -std=c++20 -fmodules-cache-path=%t -fmodules -fno-cxx-modules -fimplicit-module-maps -I %S/Inputs/cxx20 %s -verify -fno-modules-error-recovery
 
 // expected-no-diagnostics
 
Index: clang/test/Driver/conflict-clang-module-and-cxx20-module.cpp
===
--- /dev/null
+++ clang/test/Driver/conflict-clang-module-and-cxx20-module.cpp
@@ -0,0 +1,7 @@
+// RUN: %clangxx -### -c %s -std=c++20 -fmodules 2>&1 | FileCheck %s
+// RUN: %clangxx -### -c %s -std=c++2a -fmodules 2>&1 | FileCheck %s
+// RUN: %clangxx -### -c %s -std=c++20 -fmodules -fno-cxx-modules 2>&1 | FileCheck %s --check-prefix=FINE
+// RUN: %clangxx -### -c

[PATCH] D112577: [clang][OpenMP] Initial parsing/sema for 'align' clause

2021-11-08 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

Before I land this, it looks like precommit CI is failing with what possibly is 
a related failure:

  [9094/9117] Linking CXX executable 
tools/flang/unittests/Frontend/FlangFrontendTests
  FAILED: tools/flang/unittests/Frontend/FlangFrontendTests
  : && /usr/bin/clang++ -gmlt -fPIC -fvisibility-inlines-hidden 
-Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra 
-Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers 
-pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough 
-Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor 
-Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion 
-Wmisleading-indentation -fdiagnostics-color -ffunction-sections 
-fdata-sections -Wno-deprecated-copy -Wno-string-conversion 
-Wno-unused-command-line-argument -Wstring-conversion   
-Wcovered-switch-default -Wno-nested-anon-types -O3 -DNDEBUG -fuse-ld=lld 
-Wl,--color-diagnostics-Wl,-O3 -Wl,--gc-sections 
tools/flang/unittests/Frontend/CMakeFiles/FlangFrontendTests.dir/CompilerInstanceTest.cpp.o
 
tools/flang/unittests/Frontend/CMakeFiles/FlangFrontendTests.dir/FrontendActionTest.cpp.o
 -o tools/flang/unittests/Frontend/FlangFrontendTests  lib/libLLVMSupport.a  
-lpthread  lib/libgtest_main.a  lib/libgtest.a  -lpthread  lib/libclangBasic.a  
lib/libflangFrontend.a  lib/libflangFrontendTool.a  lib/libFortranParser.a  
lib/libFortranSemantics.a  lib/libFortranCommon.a  lib/libFortranEvaluate.a  
-lpthread  lib/libflangFrontend.a  lib/libFortranLower.a  
lib/libFortranSemantics.a  lib/libFortranEvaluate.a  lib/libFortranParser.a  
lib/libFortranCommon.a  lib/libFortranDecimal.a  lib/libFIRTransforms.a  
lib/libFIRDialect.a  lib/libMLIROpenMPToLLVM.a  lib/libMLIRMemRefToLLVM.a  
lib/libFIRSupport.a  lib/libMLIROpenMPToLLVMIRTranslation.a  
lib/libMLIRAffineTransforms.a  lib/libMLIRAsyncTransforms.a  lib/libMLIREmitC.a 
 lib/libMLIRGPUTransforms.a  lib/libMLIRAsync.a  lib/libMLIRGPUOps.a  
lib/libMLIRDLTI.a  lib/libMLIRLLVMToLLVMIRTranslation.a  
lib/libLLVMNVPTXCodeGen.a  lib/libLLVMNVPTXDesc.a  lib/libLLVMNVPTXInfo.a  
lib/libLLVMAMDGPUAsmParser.a  lib/libLLVMAMDGPUCodeGen.a  
lib/libLLVMAsmPrinter.a  lib/libLLVMDebugInfoDWARF.a  lib/libLLVMDebugInfoMSF.a 
 lib/libLLVMPasses.a  lib/libLLVMCoroutines.a  lib/libLLVMipo.a  
lib/libLLVMVectorize.a  lib/libLLVMIRReader.a  lib/libLLVMLinker.a  
lib/libLLVMInstrumentation.a  lib/libLLVMObjCARCOpts.a  lib/libLLVMGlobalISel.a 
 lib/libLLVMSelectionDAG.a  lib/libLLVMMIRParser.a  lib/libLLVMCodeGen.a  
lib/libLLVMTarget.a  lib/libLLVMAMDGPUDesc.a  lib/libLLVMAMDGPUUtils.a  
lib/libLLVMAMDGPUInfo.a  lib/libMLIRNVVMIR.a  lib/libMLIRROCDLIR.a  
lib/libMLIRVectorToLLVM.a  lib/libMLIRArmNeon.a  lib/libMLIRArmSVETransforms.a  
lib/libMLIRArmSVE.a  lib/libMLIRAMXTransforms.a  lib/libMLIRAMX.a  
lib/libMLIRTargetLLVMIRExport.a  lib/libMLIRLLVMIRTransforms.a  
lib/libMLIRTranslation.a  lib/libMLIRMathTransforms.a  
lib/libMLIRMemRefTransforms.a  lib/libMLIROpenACC.a  lib/libMLIROpenMP.a  
lib/libMLIRShapeOpsTransforms.a  lib/libMLIRShape.a  
lib/libMLIRSparseTensorTransforms.a  lib/libMLIRLinalgTransforms.a  
lib/libMLIRComplex.a  lib/libMLIRLinalgAnalysis.a  
lib/libMLIRComprehensiveBufferize.a  lib/libMLIRBufferizableOpInterface.a  
lib/libMLIRLinalgUtils.a  lib/libMLIRSCFTransforms.a  
lib/libMLIRStandardToLLVM.a  lib/libMLIRArithmeticToLLVM.a  
lib/libMLIRVectorToSCF.a  lib/libMLIRSparseTensor.a  
lib/libMLIRSparseTensorUtils.a  lib/libMLIRSPIRVModuleCombiner.a  
lib/libMLIRSPIRVTransforms.a  lib/libMLIRSPIRVConversion.a  
lib/libMLIRSPIRVUtils.a  lib/libMLIRSPIRV.a  lib/libMLIRStandardOpsTransforms.a 
 lib/libMLIRArithmeticTransforms.a  lib/libMLIRTensorTransforms.a  
lib/libMLIRTosaTransforms.a  lib/libMLIRX86VectorTransforms.a  
lib/libMLIRX86Vector.a  lib/libMLIRLLVMCommonConversion.a  lib/libMLIRLLVMIR.a  
lib/libLLVMAsmParser.a  lib/libLLVMBitWriter.a  lib/libMLIRTosaTestPasses.a  
lib/libMLIRTosa.a  lib/libMLIRQuant.a  lib/libMLIRAffineToStandard.a  
lib/libMLIRSCFToStandard.a  lib/libMLIRTransforms.a  lib/libMLIRVector.a  
lib/libMLIRAffineUtils.a  lib/libMLIRLinalg.a  lib/libMLIRMath.a  
lib/libMLIRParser.a  lib/libMLIRTilingInterface.a  lib/libMLIRTransformUtils.a  
lib/libMLIRLoopAnalysis.a  lib/libMLIRAffine.a  lib/libMLIRSCF.a  
lib/libMLIRMemRef.a  lib/libMLIRMemRefUtils.a  lib/libMLIRTensor.a  
lib/libMLIRDialectUtils.a  lib/libMLIRStandard.a  lib/libMLIRArithmetic.a  
lib/libMLIRDialect.a  lib/libMLIRCastInterfaces.a  
lib/libMLIRVectorInterfaces.a  lib/libMLIRLoopLikeInterface.a  
lib/libMLIRPresburger.a  lib/libMLIRRewrite.a  lib/libMLIRPDLToPDLInterp.a  
lib/libMLIRPDLInterp.a  lib/libMLIRPDL.a  lib/libMLIRPass.a  
lib/libMLIRAnalysis.a  lib/libMLIRSideEffectInterfaces.a  
lib/libMLIRDataLayoutInterfaces.a  lib/libMLIRInferTypeOpInterface.a  
lib/libMLIRViewLikeInterface.a  lib/libMLIRCallInterfaces.a  
lib/libMLIRControlFlowInterfaces.a  lib/libMLIRCopyOpI

[PATCH] D111264: Comment AST: Declare function pointer variables as functions

2021-11-08 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 accepted this revision.
gribozavr2 added a comment.
This revision is now accepted and ready to land.

I feel uneasy about claiming that variable decls of function type are 
FunctionKind for the purposes of comment parsing (even doing it for typedefs is 
questionable). It seems like a better way would be to make "is function like" 
an extra dimension that can be combined with any decl kind.

However since no tests break, it might be not an issue in practice.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111264

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


Re: [clang] 6278682 - In spir functions, llvm.dbg.declare intrinsics created

2021-11-08 Thread Aaron Ballman via cfe-commits
Hello! Was this code reviewed anywhere? I can't seem to spot a review
for it, so wondering if I missed something.

Thanks!

~Aaron

On Fri, Nov 5, 2021 at 6:08 PM Zahira Ammarguellat via cfe-commits
 wrote:
>
>
> Author: Zahira Ammarguellat
> Date: 2021-11-05T15:08:09-07:00
> New Revision: 627868263cd4d57c230b61904483a3dad9e1a1da
>
> URL: 
> https://github.com/llvm/llvm-project/commit/627868263cd4d57c230b61904483a3dad9e1a1da
> DIFF: 
> https://github.com/llvm/llvm-project/commit/627868263cd4d57c230b61904483a3dad9e1a1da.diff
>
> LOG: In spir functions, llvm.dbg.declare intrinsics created
> for parameters and locals need to refer to the stack
> allocation in the alloca address space.
>
> Added:
> clang/test/CodeGenSYCL/debug-info-kernel-variables.cpp
>
> Modified:
> clang/lib/CodeGen/CGDecl.cpp
>
> Removed:
>
>
>
> 
> diff  --git a/clang/lib/CodeGen/CGDecl.cpp b/clang/lib/CodeGen/CGDecl.cpp
> index dfb74a3fc6547..941671c614824 100644
> --- a/clang/lib/CodeGen/CGDecl.cpp
> +++ b/clang/lib/CodeGen/CGDecl.cpp
> @@ -1447,6 +1447,7 @@ CodeGenFunction::EmitAutoVarAlloca(const VarDecl &D) {
>
>if (getLangOpts().OpenMP && OpenMPLocalAddr.isValid()) {
>  address = OpenMPLocalAddr;
> +AllocaAddr = OpenMPLocalAddr;
>} else if (Ty->isConstantSizeType()) {
>  // If this value is an array or struct with a statically determinable
>  // constant initializer, there are optimizations we can do.
> @@ -1492,6 +1493,7 @@ CodeGenFunction::EmitAutoVarAlloca(const VarDecl &D) {
>// return slot, so that we can elide the copy when returning this
>// variable (C++0x [class.copy]p34).
>address = ReturnValue;
> +  AllocaAddr = ReturnValue;
>
>if (const RecordType *RecordTy = Ty->getAs()) {
>  const auto *RD = RecordTy->getDecl();
> @@ -1503,7 +1505,8 @@ CodeGenFunction::EmitAutoVarAlloca(const VarDecl &D) {
>// applied.
>llvm::Value *Zero = Builder.getFalse();
>Address NRVOFlag =
> -CreateTempAlloca(Zero->getType(), CharUnits::One(), "nrvo");
> +  CreateTempAlloca(Zero->getType(), CharUnits::One(), "nrvo",
> +   /*ArraySize=*/nullptr, &AllocaAddr);
>EnsureInsertPoint();
>Builder.CreateStore(Zero, NRVOFlag);
>
> @@ -1605,10 +1608,11 @@ CodeGenFunction::EmitAutoVarAlloca(const VarDecl &D) {
>  DI->setLocation(D.getLocation());
>
>  // If NRVO, use a pointer to the return address.
> -if (UsePointerValue)
> +if (UsePointerValue) {
>DebugAddr = ReturnValuePointer;
> -
> -(void)DI->EmitDeclareOfAutoVariable(&D, DebugAddr.getPointer(), Builder,
> +  AllocaAddr = ReturnValuePointer;
> +}
> +(void)DI->EmitDeclareOfAutoVariable(&D, AllocaAddr.getPointer(), Builder,
>  UsePointerValue);
>}
>
> @@ -2450,6 +2454,7 @@ void CodeGenFunction::EmitParmDecl(const VarDecl &D, 
> ParamValue Arg,
>}
>
>Address DeclPtr = Address::invalid();
> +  Address AllocaPtr = Address::invalid();
>bool DoStore = false;
>bool IsScalar = hasScalarEvaluationKind(Ty);
>// If we already have a pointer to the argument, reuse the input pointer.
> @@ -2464,6 +2469,7 @@ void CodeGenFunction::EmitParmDecl(const VarDecl &D, 
> ParamValue Arg,
>  // from the default address space.
>  auto AllocaAS = CGM.getASTAllocaAddressSpace();
>  auto *V = DeclPtr.getPointer();
> +AllocaPtr = DeclPtr;
>  auto SrcLangAS = getLangOpts().OpenCL ? LangAS::opencl_private : 
> AllocaAS;
>  auto DestLangAS =
>  getLangOpts().OpenCL ? LangAS::opencl_private : LangAS::Default;
> @@ -2500,10 +2506,11 @@ void CodeGenFunction::EmitParmDecl(const VarDecl &D, 
> ParamValue Arg,
>  : Address::invalid();
>  if (getLangOpts().OpenMP && OpenMPLocalAddr.isValid()) {
>DeclPtr = OpenMPLocalAddr;
> +  AllocaPtr = DeclPtr;
>  } else {
>// Otherwise, create a temporary to hold the value.
>DeclPtr = CreateMemTemp(Ty, getContext().getDeclAlign(&D),
> -  D.getName() + ".addr");
> +  D.getName() + ".addr", &AllocaPtr);
>  }
>  DoStore = true;
>}
> @@ -2579,7 +2586,7 @@ void CodeGenFunction::EmitParmDecl(const VarDecl &D, 
> ParamValue Arg,
>if (CGDebugInfo *DI = getDebugInfo()) {
>  if (CGM.getCodeGenOpts().hasReducedDebugInfo() && !CurFuncIsThunk) {
>llvm::DILocalVariable *DILocalVar = DI->EmitDeclareOfArgVariable(
> -  &D, DeclPtr.getPointer(), ArgNo, Builder);
> +  &D, AllocaPtr.getPointer(), ArgNo, Builder);
>if (const auto *Var = dyn_cast_or_null(&D))
>  DI->getParamDbgMappings().insert({Var, DILocalVar});
>  }
>
> diff  --git a/clang/test/CodeGenSYCL/debug-info-kernel-variables.cpp 
> b/clang/test/CodeGenSYCL/debug-info-kernel-variables.cpp
> new file mode

[PATCH] D113391: [Modules] Don't support clang module and c++20 module at the same time

2021-11-08 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu added a comment.

In D113391#3115080 , @tschuett wrote:

> This sounds like an enum.
>
>   enum class ModuleKind {
>   C++20,
>   Clang,
>   Unsupported
>   }

In fact, there is another value `ModuleTS`. But it looks not bad. And the 
variable `CPlusPlusModules` and `ClangModules` comes from options directly (See 
Options.td for details). So it looks like we couldn't eliminate 
`CPlusPlusModules` and `ClangModules` after we introduce this enum. So the 
overall complexity didn't get decreased to me.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113391

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


[PATCH] D93164: [AST] Add generator for source location introspection

2021-11-08 Thread Stephen Kelly via Phabricator via cfe-commits
steveire added inline comments.



Comment at: clang/lib/Tooling/CMakeLists.txt:29-30
+if (NOT Python3_EXECUTABLE
+OR WIN32
+OR APPLE
+OR GENERATOR_IS_MULTI_CONFIG

smeenai wrote:
> I'm looking at this commit in the context of 
> https://bugs.llvm.org/show_bug.cgi?id=52106. Why do we not run the generator 
> when targeting Windows or Apple platforms? Note that WIN32 and APPLE reflect 
> the target platform, not the platform you're building on.
I was not able to make the change pass the LLVM CI system on those platforms.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93164

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


[PATCH] D111266: Comment AST: Add support for variable templates

2021-11-08 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 accepted this revision.
gribozavr2 added inline comments.
This revision is now accepted and ready to land.



Comment at: clang/test/Sema/warn-documentation.cpp:1348
+  /**
+   * functionPointerField
+   *

"functionPointerTemplateMember"


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111266

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


[PATCH] D112777: [X86][FP16] add alias for *_fmul_pch intrinsics

2021-11-08 Thread Freddy, Ye via Phabricator via cfe-commits
FreddyYe updated this revision to Diff 385443.
FreddyYe added a comment.

address comments. add alias for 36 intrinsics in all.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112777

Files:
  clang/lib/Headers/avx512fp16intrin.h
  clang/lib/Headers/avx512vlfp16intrin.h
  clang/test/CodeGen/X86/avx512fp16-builtins.c
  clang/test/CodeGen/X86/avx512vlfp16-builtins.c

Index: clang/test/CodeGen/X86/avx512vlfp16-builtins.c
===
--- clang/test/CodeGen/X86/avx512vlfp16-builtins.c
+++ clang/test/CodeGen/X86/avx512vlfp16-builtins.c
@@ -3114,3 +3114,76 @@
   // CHECK: call nnan half @llvm.vector.reduce.fmax.v8f16(<8 x half> %{{.*}})
   return _mm_reduce_max_ph(__W);
 }
+
+// tests below are for alias intrinsics.
+__m128h test_mm_mul_pch(__m128h __A, __m128h __B) {
+  // CHECK-LABEL: @test_mm_mul_pch
+  // CHECK: @llvm.x86.avx512fp16.mask.vfmul.cph.128
+  return _mm_mul_pch(__A, __B);
+}
+
+__m128h test_mm_mask_mul_pch(__m128h __W, __mmask8 __U, __m128h __A, __m128h __B) {
+  // CHECK-LABEL: @test_mm_mask_mul_pch
+  // CHECK: @llvm.x86.avx512fp16.mask.vfmul.cph.128
+  return _mm_mask_mul_pch(__W, __U, __A, __B);
+}
+
+__m128h test_mm_maskz_mul_pch(__mmask8 __U, __m128h __A, __m128h __B) {
+  // CHECK-LABEL: @test_mm_maskz_mul_pch
+  // CHECK: @llvm.x86.avx512fp16.mask.vfmul.cph.128
+  return _mm_maskz_mul_pch(__U, __A, __B);
+}
+
+__m256h test_mm256_mul_pch(__m256h __A, __m256h __B) {
+  // CHECK-LABEL: @test_mm256_mul_pch
+  // CHECK: @llvm.x86.avx512fp16.mask.vfmul.cph.256
+  return _mm256_mul_pch(__A, __B);
+}
+
+__m256h test_mm256_mask_mul_pch(__m256h __W, __mmask8 __U, __m256h __A, __m256h __B) {
+  // CHECK-LABEL: @test_mm256_mask_mul_pch
+  // CHECK: @llvm.x86.avx512fp16.mask.vfmul.cph.256
+  return _mm256_mask_mul_pch(__W, __U, __A, __B);
+}
+
+__m256h test_mm256_maskz_mul_pch(__mmask8 __U, __m256h __A, __m256h __B) {
+  // CHECK-LABEL: @test_mm256_maskz_mul_pch
+  // CHECK: @llvm.x86.avx512fp16.mask.vfmul.cph.256
+  return _mm256_maskz_mul_pch(__U, __A, __B);
+}
+
+__m128h test_mm_cmul_pch(__m128h __A, __m128h __B) {
+  // CHECK-LABEL: @test_mm_cmul_pch
+  // CHECK: @llvm.x86.avx512fp16.mask.vfcmul.cph.128
+  return _mm_cmul_pch(__A, __B);
+}
+
+__m128h test_mm_mask_cmul_pch(__m128h __W, __mmask8 __U, __m128h __A, __m128h __B) {
+  // CHECK-LABEL: @test_mm_mask_cmul_pch
+  // CHECK: @llvm.x86.avx512fp16.mask.vfcmul.cph.128
+  return _mm_mask_fcmul_pch(__W, __U, __A, __B);
+}
+
+__m128h test_mm_maskz_cmul_pch(__mmask8 __U, __m128h __A, __m128h __B) {
+  // CHECK-LABEL: @test_mm_maskz_cmul_pch
+  // CHECK: @llvm.x86.avx512fp16.mask.vfcmul.cph.128
+  return _mm_maskz_cmul_pch(__U, __A, __B);
+}
+
+__m256h test_mm256_cmul_pch(__m256h __A, __m256h __B) {
+  // CHECK-LABEL: @test_mm256_cmul_pch
+  // CHECK: @llvm.x86.avx512fp16.mask.vfcmul.cph.256
+  return _mm256_cmul_pch(__A, __B);
+}
+
+__m256h test_mm256_mask_cmul_pch(__m256h __W, __mmask8 __U, __m256h __A, __m256h __B) {
+  // CHECK-LABEL: @test_mm256_mask_cmul_pch
+  // CHECK: @llvm.x86.avx512fp16.mask.vfcmul.cph.256
+  return _mm256_mask_cmul_pch(__W, __U, __A, __B);
+}
+
+__m256h test_mm256_maskz_cmul_pch(__mmask8 __U, __m256h __A, __m256h __B) {
+  // CHECK-LABEL: @test_mm256_maskz_cmul_pch
+  // CHECK: @llvm.x86.avx512fp16.mask.vfcmul.cph.256
+  return _mm256_maskz_cmul_pch(__U, __A, __B);
+}
Index: clang/test/CodeGen/X86/avx512fp16-builtins.c
===
--- clang/test/CodeGen/X86/avx512fp16-builtins.c
+++ clang/test/CodeGen/X86/avx512fp16-builtins.c
@@ -4482,3 +4482,147 @@
   // CHECK:  %{{.*}} = bitcast <32 x i16> %{{.*}} to <32 x half>
   return _mm512_permutexvar_ph(__A, __B);
 }
+
+// tests below are for alias intrinsics.
+__m512h test_mm512_mul_pch(__m512h __A, __m512h __B) {
+  // CHECK-LABEL: @test_mm512_mul_pch
+  // CHECK: @llvm.x86.avx512fp16.mask.vfmul.cph.512
+  return _mm512_mul_pch(__A, __B);
+}
+
+__m512h test_mm512_mask_mul_pch(__m512h __W, __mmask16 __U, __m512h __A, __m512h __B) {
+  // CHECK-LABEL: @test_mm512_mask_mul_pch
+  // CHECK: @llvm.x86.avx512fp16.mask.vfmul.cph.512
+  return _mm512_mask_mul_pch(__W, __U, __A, __B);
+}
+
+__m512h test_mm512_maskz_mul_pch(__mmask16 __U, __m512h __A, __m512h __B) {
+  // CHECK-LABEL: @test_mm512_maskz_mul_pch
+  // CHECK: @llvm.x86.avx512fp16.mask.vfmul.cph.512
+  return _mm512_maskz_mul_pch(__U, __A, __B);
+}
+
+__m512h test_mm512_cmul_pch(__m512h __A, __m512h __B) {
+  // CHECK-LABEL: @test_mm512_cmul_pch
+  // CHECK: @llvm.x86.avx512fp16.mask.vfcmul.cph.512
+  return _mm512_cmul_pch(__A, __B);
+}
+__m512h test_mm512_mask_cmul_pch(__m512h __W, __mmask16 __U, __m512h __A, __m512h __B) {
+  // CHECK-LABEL: @test_mm512_mask_cmul_pch
+  // CHECK: @llvm.x86.avx512fp16.mask.vfcmul.cph.512
+  return _mm512_mask_cmul_pch(__W, __U, __A, __B);
+}
+
+__m512h test_mm512_maskz_cmul_pch(__mmask16 __U, __

[PATCH] D108621: [HIPSPV] Add CUDA->SPIR-V address space mapping

2021-11-08 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added inline comments.



Comment at: clang/lib/Basic/Targets/SPIR.h:233
+if (Opts.HIP && Opts.CUDAIsDevice)
+  // Enable address space mapping from HIP to SPIR-V.
+  // See comment on the SPIRDefIsGenMap table.

linjamaki wrote:
> Anastasia wrote:
> > My guess is that this is not only HIP specific but for example the same 
> > applies to SYCL.
> > 
> > I am not sure if it makes more sense to move this into a 
> > `BaseSPIRTargetInfo` since this is not really SPIR-V specific logic. It is 
> > just a clang design misalignment between two address space concepts that 
> > has to be addressed properly at some point.
> > 
> The DefaultIsGeneric AS mapping is enabled for SYCL in the 
> BaseSPIRTargetInfo::adjust (which also means the mapping is available for 
> both the SPIR and SPIR-V targets). On the other hand, the AS mapping for 
> HIPSPV is enabled in SPIRVTargetInfo::adjust only as we intend to emit SPIR-V 
> only. I’m under the impression that this is what was wanted.
I think the issues here is not related to the target but to the flaw in the 
address space design in clang. So right now all languages that don't derive the 
address space semantic from embedded C (SYCL/CUDA/HIP) would need to reset the 
address space map. See FIXME comment in the definition of `adjust`.

So the right thing to do would be to set the address space map correctly 
straight away based on the language being compiled for which would avoid 
overriding this in `adjust`. But if we do override it then it makes more sense 
to at least unify the logic among targets.


> 
> On the other hand, the AS mapping for HIPSPV is enabled in 
> SPIRVTargetInfo::adjust only as we intend to emit SPIR-V only. 
> 


I am not really sure how you would support one target only.
Clang architecture (at least originally) assumes that all languages can map to 
all targets which in practice is not true in some cases. This is why we need to 
provide an address space map even for targets that have no memory segmented 
language compiled to it. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108621

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


[PATCH] D112110: [OpenCL] queue_t and ndrange_t can't be defined in program scope.

2021-11-08 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added inline comments.



Comment at: clang/test/SemaOpenCL/invalid-types.cl:5
+// Test declare "Other Data Type" variables in program scope.
+global queue_t qt; // expected-error {{the '__global queue_t' type cannot be 
used to declare a program scope variable}}
+

if you create a type alias through typedef for `queue_t` or `ndrange_t`, will 
you still get the diagnostic?



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

https://reviews.llvm.org/D112110

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


[PATCH] D113393: [c++2b] Implement P0849R8 auto(x)

2021-11-08 Thread Zhihao Yuan via Phabricator via cfe-commits
lichray created this revision.
lichray requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

https://wg21.link/p0849


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D113393

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/lib/Parse/ParseExpr.cpp
  clang/lib/Parse/ParseExprCXX.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p5.cpp
  clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.auto.deduct/p2.cpp
  clang/test/CXX/expr/expr.post/expr.type.conv/p1-2b.cpp

Index: clang/test/CXX/expr/expr.post/expr.type.conv/p1-2b.cpp
===
--- /dev/null
+++ clang/test/CXX/expr/expr.post/expr.type.conv/p1-2b.cpp
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -std=c++2b -verify %s
+
+template 
+void foo(T);
+
+struct A {
+  int m;
+  char g(int);
+  float g(double);
+} a{1};
+
+void diagnostics() {
+  foo(auto());   // expected-error {{initializer for functional-style cast to 'auto' is empty}}
+  foo(auto {});  // expected-error {{initializer for functional-style cast to 'auto' is empty}}
+  foo(auto({})); // expected-error {{initializer for functional-style cast to 'auto' is empty}}
+
+  foo(auto(a));
+  foo(auto {a});
+  foo(auto(a));
+
+  foo(auto(&A::g)); // expected-error {{functional-style cast to 'auto' has incompatible initializer of type ''}}
+
+  foo(auto(a, 3.14));   // expected-error {{initializer for functional-style cast to 'auto' contains multiple expressions}}
+  foo(auto {a, 3.14});  // expected-error {{initializer for functional-style cast to 'auto' contains multiple expressions}}
+  foo(auto({a, 3.14})); // expected-error {{initializer for functional-style cast to 'auto' contains multiple expressions}}
+}
Index: clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.auto.deduct/p2.cpp
===
--- /dev/null
+++ clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.auto.deduct/p2.cpp
@@ -0,0 +1,56 @@
+// RUN: %clang_cc1 -std=c++2b -verify %s
+// expected-no-diagnostics
+
+void test_decay() {
+  int v[3];
+  static_assert(__is_same(decltype(auto(v)), int *));
+  static_assert(__is_same(decltype(auto("lit")), char const *));
+
+  int fn(char *);
+  static_assert(__is_same(decltype(auto(fn)), int (*)(char *)));
+
+  constexpr long i = 1;
+  static_assert(__is_same(decltype(auto(1L)), long));
+  static_assert(__is_same(decltype(i), long const));
+  static_assert(__is_same(decltype(auto(i)), long));
+
+  class A {
+  } a;
+
+  A &lr = a;
+  A const &lrc = a;
+  A &&rr = static_cast(a);
+  A const &&rrc = static_cast(a);
+
+  static_assert(__is_same(decltype(auto(lr)), A));
+  static_assert(__is_same(decltype(auto(lrc)), A));
+  static_assert(__is_same(decltype(auto(rr)), A));
+  static_assert(__is_same(decltype(auto(rrc)), A));
+}
+
+class cmdline_parser {
+public:
+  cmdline_parser(char const *);
+  auto add_option(char const *, char const *) && -> cmdline_parser &&;
+};
+
+void test_rvalue_fluent_interface() {
+  auto cmdline = cmdline_parser("driver");
+  auto internal = auto {cmdline}.add_option("--dump-full", "do not minimize dump");
+}
+
+class A {
+  int x;
+  friend void f(A &&);
+
+public:
+  A();
+
+  auto test_access() {
+f(A(*this));// ok
+f(auto(*this)); // ok in P0849
+  }
+
+protected:
+  A(const A &);
+};
Index: clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p5.cpp
===
--- clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p5.cpp
+++ clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p5.cpp
@@ -51,8 +51,8 @@
   (void)reinterpret_cast(&n); // expected-error{{'auto' not allowed here}}
   (void)const_cast(n); // expected-error{{'auto' not allowed here}}
   (void)*(auto*)(&n); // expected-error{{'auto' not allowed here}}
-  (void)auto(n); // expected-error{{expected expression}}
-  (void)auto{n}; // expected-error{{expected expression}}
+  (void)auto(n); // expected-error{{'auto' not allowed here}}
+  (void)auto{n}; // expected-error{{'auto' not allowed here}}
 }
 
 template  class C { }; // expected-error{{'auto' not allowed in template parameter}}
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -3395,6 +3395,8 @@
 // class template argument deduction)?
 bool IsCXXAutoType =
 (Auto && Auto->getKeyword() != AutoTypeKeyword::GNUAutoType);
+bool IsAutoKeyword =
+(Auto && Auto->getKeyword() == AutoTypeKeyword::Auto);
 bool IsDeducedReturnType = false;
 
 switch (D.getContext()) {
@@ -3414,8 +3416,7 @@
   InventedTemplateParameterInfo *Info = nullptr;
   if (D.getContext() == DeclaratorContext::Prototype) {
 // With concepts we allow 'auto' in fun

[PATCH] D113393: [c++2b] Implement P0849R8 auto(x)

2021-11-08 Thread Zhihao Yuan via Phabricator via cfe-commits
lichray updated this revision to Diff 385450.
lichray added a comment.

Document updates


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113393

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/lib/Parse/ParseExpr.cpp
  clang/lib/Parse/ParseExprCXX.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p5.cpp
  clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.auto.deduct/p2.cpp
  clang/test/CXX/expr/expr.post/expr.type.conv/p1-2b.cpp
  clang/www/cxx_status.html

Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -1379,6 +1379,11 @@
   https://wg21.link/P2360R0";>P2360R0
   Clang 14
 
+
+  auto(x): decay-copy in the language
+  https://wg21.link/P0849R8";>P0849R8
+  Clang 14
+
 
 
 
Index: clang/test/CXX/expr/expr.post/expr.type.conv/p1-2b.cpp
===
--- /dev/null
+++ clang/test/CXX/expr/expr.post/expr.type.conv/p1-2b.cpp
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -std=c++2b -verify %s
+
+template 
+void foo(T);
+
+struct A {
+  int m;
+  char g(int);
+  float g(double);
+} a{1};
+
+void diagnostics() {
+  foo(auto());   // expected-error {{initializer for functional-style cast to 'auto' is empty}}
+  foo(auto {});  // expected-error {{initializer for functional-style cast to 'auto' is empty}}
+  foo(auto({})); // expected-error {{initializer for functional-style cast to 'auto' is empty}}
+
+  foo(auto(a));
+  foo(auto {a});
+  foo(auto(a));
+
+  foo(auto(&A::g)); // expected-error {{functional-style cast to 'auto' has incompatible initializer of type ''}}
+
+  foo(auto(a, 3.14));   // expected-error {{initializer for functional-style cast to 'auto' contains multiple expressions}}
+  foo(auto {a, 3.14});  // expected-error {{initializer for functional-style cast to 'auto' contains multiple expressions}}
+  foo(auto({a, 3.14})); // expected-error {{initializer for functional-style cast to 'auto' contains multiple expressions}}
+}
Index: clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.auto.deduct/p2.cpp
===
--- /dev/null
+++ clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.auto.deduct/p2.cpp
@@ -0,0 +1,56 @@
+// RUN: %clang_cc1 -std=c++2b -verify %s
+// expected-no-diagnostics
+
+void test_decay() {
+  int v[3];
+  static_assert(__is_same(decltype(auto(v)), int *));
+  static_assert(__is_same(decltype(auto("lit")), char const *));
+
+  int fn(char *);
+  static_assert(__is_same(decltype(auto(fn)), int (*)(char *)));
+
+  constexpr long i = 1;
+  static_assert(__is_same(decltype(auto(1L)), long));
+  static_assert(__is_same(decltype(i), long const));
+  static_assert(__is_same(decltype(auto(i)), long));
+
+  class A {
+  } a;
+
+  A &lr = a;
+  A const &lrc = a;
+  A &&rr = static_cast(a);
+  A const &&rrc = static_cast(a);
+
+  static_assert(__is_same(decltype(auto(lr)), A));
+  static_assert(__is_same(decltype(auto(lrc)), A));
+  static_assert(__is_same(decltype(auto(rr)), A));
+  static_assert(__is_same(decltype(auto(rrc)), A));
+}
+
+class cmdline_parser {
+public:
+  cmdline_parser(char const *);
+  auto add_option(char const *, char const *) && -> cmdline_parser &&;
+};
+
+void test_rvalue_fluent_interface() {
+  auto cmdline = cmdline_parser("driver");
+  auto internal = auto {cmdline}.add_option("--dump-full", "do not minimize dump");
+}
+
+class A {
+  int x;
+  friend void f(A &&);
+
+public:
+  A();
+
+  auto test_access() {
+f(A(*this));// ok
+f(auto(*this)); // ok in P0849
+  }
+
+protected:
+  A(const A &);
+};
Index: clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p5.cpp
===
--- clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p5.cpp
+++ clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p5.cpp
@@ -51,8 +51,8 @@
   (void)reinterpret_cast(&n); // expected-error{{'auto' not allowed here}}
   (void)const_cast(n); // expected-error{{'auto' not allowed here}}
   (void)*(auto*)(&n); // expected-error{{'auto' not allowed here}}
-  (void)auto(n); // expected-error{{expected expression}}
-  (void)auto{n}; // expected-error{{expected expression}}
+  (void)auto(n); // expected-error{{'auto' not allowed here}}
+  (void)auto{n}; // expected-error{{'auto' not allowed here}}
 }
 
 template  class C { }; // expected-error{{'auto' not allowed in template parameter}}
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -3395,6 +3395,8 @@
 // class template argument deduction)?
 bool IsCXXAutoType =
 

[PATCH] D112996: [CodeCompletion] Generally consider header files without extension

2021-11-08 Thread Christian Kandeler via Phabricator via cfe-commits
ckandeler updated this revision to Diff 385453.
ckandeler added a comment.

Addressed formatting comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112996

Files:
  clang/lib/Sema/SemaCodeComplete.cpp


Index: clang/lib/Sema/SemaCodeComplete.cpp
===
--- clang/lib/Sema/SemaCodeComplete.cpp
+++ clang/lib/Sema/SemaCodeComplete.cpp
@@ -9613,6 +9613,10 @@
   }
 }
 
+const StringRef &Dirname = llvm::sys::path::filename(Dir);
+const bool isQt = Dirname.startswith("Qt") || Dirname == "ActiveQt";
+const bool ExtensionlessHeaders =
+IsSystem || isQt || Dir.endswith(".framework/Headers");
 std::error_code EC;
 unsigned Count = 0;
 for (auto It = FS.dir_begin(Dir, EC);
@@ -9639,18 +9643,19 @@
 
 AddCompletion(Filename, /*IsDirectory=*/true);
 break;
-  case llvm::sys::fs::file_type::regular_file:
-// Only files that really look like headers. (Except in system dirs).
-if (!IsSystem) {
-  // Header extensions from Types.def, which we can't depend on here.
-  if (!(Filename.endswith_insensitive(".h") ||
-Filename.endswith_insensitive(".hh") ||
-Filename.endswith_insensitive(".hpp") ||
-Filename.endswith_insensitive(".inc")))
-break;
-}
+  case llvm::sys::fs::file_type::regular_file: {
+// Only files that really look like headers. (Except in special dirs).
+// Header extensions from Types.def, which we can't depend on here.
+const bool IsHeader = Filename.endswith_insensitive(".h") ||
+  Filename.endswith_insensitive(".hh") ||
+  Filename.endswith_insensitive(".hpp") ||
+  Filename.endswith_insensitive(".inc") ||
+  (ExtensionlessHeaders && 
!Filename.contains('.'));
+if (!IsHeader)
+  break;
 AddCompletion(Filename, /*IsDirectory=*/false);
 break;
+  }
   default:
 break;
   }


Index: clang/lib/Sema/SemaCodeComplete.cpp
===
--- clang/lib/Sema/SemaCodeComplete.cpp
+++ clang/lib/Sema/SemaCodeComplete.cpp
@@ -9613,6 +9613,10 @@
   }
 }
 
+const StringRef &Dirname = llvm::sys::path::filename(Dir);
+const bool isQt = Dirname.startswith("Qt") || Dirname == "ActiveQt";
+const bool ExtensionlessHeaders =
+IsSystem || isQt || Dir.endswith(".framework/Headers");
 std::error_code EC;
 unsigned Count = 0;
 for (auto It = FS.dir_begin(Dir, EC);
@@ -9639,18 +9643,19 @@
 
 AddCompletion(Filename, /*IsDirectory=*/true);
 break;
-  case llvm::sys::fs::file_type::regular_file:
-// Only files that really look like headers. (Except in system dirs).
-if (!IsSystem) {
-  // Header extensions from Types.def, which we can't depend on here.
-  if (!(Filename.endswith_insensitive(".h") ||
-Filename.endswith_insensitive(".hh") ||
-Filename.endswith_insensitive(".hpp") ||
-Filename.endswith_insensitive(".inc")))
-break;
-}
+  case llvm::sys::fs::file_type::regular_file: {
+// Only files that really look like headers. (Except in special dirs).
+// Header extensions from Types.def, which we can't depend on here.
+const bool IsHeader = Filename.endswith_insensitive(".h") ||
+  Filename.endswith_insensitive(".hh") ||
+  Filename.endswith_insensitive(".hpp") ||
+  Filename.endswith_insensitive(".inc") ||
+  (ExtensionlessHeaders && !Filename.contains('.'));
+if (!IsHeader)
+  break;
 AddCompletion(Filename, /*IsDirectory=*/false);
 break;
+  }
   default:
 break;
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D113393: [c++2b] Implement P0849R8 auto(x)

2021-11-08 Thread Zhihao Yuan via Phabricator via cfe-commits
lichray updated this revision to Diff 385454.
lichray added a comment.

C++2y -> C++2b


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113393

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/lib/Parse/ParseExpr.cpp
  clang/lib/Parse/ParseExprCXX.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p5.cpp
  clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.auto.deduct/p2.cpp
  clang/test/CXX/expr/expr.post/expr.type.conv/p1-2b.cpp
  clang/www/cxx_status.html

Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -1379,6 +1379,11 @@
   https://wg21.link/P2360R0";>P2360R0
   Clang 14
 
+
+  auto(x): decay-copy in the language
+  https://wg21.link/P0849R8";>P0849R8
+  Clang 14
+
 
 
 
Index: clang/test/CXX/expr/expr.post/expr.type.conv/p1-2b.cpp
===
--- /dev/null
+++ clang/test/CXX/expr/expr.post/expr.type.conv/p1-2b.cpp
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -std=c++2b -verify %s
+
+template 
+void foo(T);
+
+struct A {
+  int m;
+  char g(int);
+  float g(double);
+} a{1};
+
+void diagnostics() {
+  foo(auto());   // expected-error {{initializer for functional-style cast to 'auto' is empty}}
+  foo(auto {});  // expected-error {{initializer for functional-style cast to 'auto' is empty}}
+  foo(auto({})); // expected-error {{initializer for functional-style cast to 'auto' is empty}}
+
+  foo(auto(a));
+  foo(auto {a});
+  foo(auto(a));
+
+  foo(auto(&A::g)); // expected-error {{functional-style cast to 'auto' has incompatible initializer of type ''}}
+
+  foo(auto(a, 3.14));   // expected-error {{initializer for functional-style cast to 'auto' contains multiple expressions}}
+  foo(auto {a, 3.14});  // expected-error {{initializer for functional-style cast to 'auto' contains multiple expressions}}
+  foo(auto({a, 3.14})); // expected-error {{initializer for functional-style cast to 'auto' contains multiple expressions}}
+}
Index: clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.auto.deduct/p2.cpp
===
--- /dev/null
+++ clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.auto.deduct/p2.cpp
@@ -0,0 +1,56 @@
+// RUN: %clang_cc1 -std=c++2b -verify %s
+// expected-no-diagnostics
+
+void test_decay() {
+  int v[3];
+  static_assert(__is_same(decltype(auto(v)), int *));
+  static_assert(__is_same(decltype(auto("lit")), char const *));
+
+  int fn(char *);
+  static_assert(__is_same(decltype(auto(fn)), int (*)(char *)));
+
+  constexpr long i = 1;
+  static_assert(__is_same(decltype(auto(1L)), long));
+  static_assert(__is_same(decltype(i), long const));
+  static_assert(__is_same(decltype(auto(i)), long));
+
+  class A {
+  } a;
+
+  A &lr = a;
+  A const &lrc = a;
+  A &&rr = static_cast(a);
+  A const &&rrc = static_cast(a);
+
+  static_assert(__is_same(decltype(auto(lr)), A));
+  static_assert(__is_same(decltype(auto(lrc)), A));
+  static_assert(__is_same(decltype(auto(rr)), A));
+  static_assert(__is_same(decltype(auto(rrc)), A));
+}
+
+class cmdline_parser {
+public:
+  cmdline_parser(char const *);
+  auto add_option(char const *, char const *) && -> cmdline_parser &&;
+};
+
+void test_rvalue_fluent_interface() {
+  auto cmdline = cmdline_parser("driver");
+  auto internal = auto {cmdline}.add_option("--dump-full", "do not minimize dump");
+}
+
+class A {
+  int x;
+  friend void f(A &&);
+
+public:
+  A();
+
+  auto test_access() {
+f(A(*this));// ok
+f(auto(*this)); // ok in P0849
+  }
+
+protected:
+  A(const A &);
+};
Index: clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p5.cpp
===
--- clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p5.cpp
+++ clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p5.cpp
@@ -51,8 +51,8 @@
   (void)reinterpret_cast(&n); // expected-error{{'auto' not allowed here}}
   (void)const_cast(n); // expected-error{{'auto' not allowed here}}
   (void)*(auto*)(&n); // expected-error{{'auto' not allowed here}}
-  (void)auto(n); // expected-error{{expected expression}}
-  (void)auto{n}; // expected-error{{expected expression}}
+  (void)auto(n); // expected-error{{'auto' not allowed here}}
+  (void)auto{n}; // expected-error{{'auto' not allowed here}}
 }
 
 template  class C { }; // expected-error{{'auto' not allowed in template parameter}}
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -3395,6 +3395,8 @@
 // class template argument deduction)?
 bool IsCXXAutoType =
   

[PATCH] D112680: [OpenMP] Lower printf to __llvm_omp_vprintf

2021-11-08 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield added a comment.

Ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112680

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


[PATCH] D111654: [analyzer] Retrieve a value from list initialization of multi-dimensional array declaration.

2021-11-08 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov updated this revision to Diff 385457.
ASDenysPetrov marked 7 inline comments as done.
ASDenysPetrov added a comment.

Updated according to the nits.


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

https://reviews.llvm.org/D111654

Files:
  clang/lib/StaticAnalyzer/Core/RegionStore.cpp
  clang/test/Analysis/initialization.c
  clang/test/Analysis/initialization.cpp

Index: clang/test/Analysis/initialization.cpp
===
--- clang/test/Analysis/initialization.cpp
+++ clang/test/Analysis/initialization.cpp
@@ -14,13 +14,6 @@
   clang_analyzer_eval(sarr[i].a); // expected-warning{{UNKNOWN}}
 }
 
-int const arr[2][2] = {};
-void arr2init() {
-  int i = 1;
-  // FIXME: Should recognize that it is 0.
-  clang_analyzer_eval(arr[i][0]); // expected-warning{{UNKNOWN}}
-}
-
 int const glob_arr1[3] = {};
 void glob_array_index1() {
   clang_analyzer_eval(glob_arr1[0] == 0); // expected-warning{{TRUE}}
@@ -60,23 +53,18 @@
   return glob_arr3[0]; // no-warning (garbage or undefined)
 }
 
-// TODO: Support multidimensional array.
 int const glob_arr4[4][2] = {};
 void glob_array_index2() {
-  // FIXME: Should be TRUE.
-  clang_analyzer_eval(glob_arr4[1][0] == 0); // expected-warning{{UNKNOWN}}
-  // FIXME: Should be TRUE.
-  clang_analyzer_eval(glob_arr4[1][1] == 0); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(glob_arr4[0][0] == 0); // expected-warning{{TRUE}}
+  clang_analyzer_eval(glob_arr4[1][0] == 0); // expected-warning{{TRUE}}
+  clang_analyzer_eval(glob_arr4[1][1] == 0); // expected-warning{{TRUE}}
 }
 
-// TODO: Support multidimensional array.
 void glob_invalid_index3() {
   int idx = -42;
-  // FIXME: Should warn {{garbage or undefined}}.
-  auto x = glob_arr4[1][idx]; // no-warning
+  auto x = glob_arr4[1][idx]; // expected-warning{{garbage or undefined}}
 }
 
-// TODO: Support multidimensional array.
 void glob_invalid_index4() {
   const int *ptr = glob_arr4[1];
   int idx = -42;
@@ -84,28 +72,18 @@
   auto x = ptr[idx]; // no-warning
 }
 
-// TODO: Support multidimensional array.
 int const glob_arr5[4][2] = {{1}, 3, 4, 5};
 void glob_array_index3() {
-  // FIXME: Should be TRUE.
-  clang_analyzer_eval(glob_arr5[0][0] == 1); // expected-warning{{UNKNOWN}}
-  // FIXME: Should be TRUE.
-  clang_analyzer_eval(glob_arr5[0][1] == 0); // expected-warning{{UNKNOWN}}
-  // FIXME: Should be TRUE.
-  clang_analyzer_eval(glob_arr5[1][0] == 3); // expected-warning{{UNKNOWN}}
-  // FIXME: Should be TRUE.
-  clang_analyzer_eval(glob_arr5[1][1] == 4); // expected-warning{{UNKNOWN}}
-  // FIXME: Should be TRUE.
-  clang_analyzer_eval(glob_arr5[2][0] == 5); // expected-warning{{UNKNOWN}}
-  // FIXME: Should be TRUE.
-  clang_analyzer_eval(glob_arr5[2][1] == 0); // expected-warning{{UNKNOWN}}
-  // FIXME: Should be TRUE.
-  clang_analyzer_eval(glob_arr5[3][0] == 0); // expected-warning{{UNKNOWN}}
-  // FIXME: Should be TRUE.
-  clang_analyzer_eval(glob_arr5[3][1] == 0); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(glob_arr5[0][0] == 1); // expected-warning{{TRUE}}
+  clang_analyzer_eval(glob_arr5[0][1] == 0); // expected-warning{{TRUE}}
+  clang_analyzer_eval(glob_arr5[1][0] == 3); // expected-warning{{TRUE}}
+  clang_analyzer_eval(glob_arr5[1][1] == 4); // expected-warning{{TRUE}}
+  clang_analyzer_eval(glob_arr5[2][0] == 5); // expected-warning{{TRUE}}
+  clang_analyzer_eval(glob_arr5[2][1] == 0); // expected-warning{{TRUE}}
+  clang_analyzer_eval(glob_arr5[3][0] == 0); // expected-warning{{TRUE}}
+  clang_analyzer_eval(glob_arr5[3][1] == 0); // expected-warning{{TRUE}}
 }
 
-// TODO: Support multidimensional array.
 void glob_ptr_index2() {
   int const *ptr = glob_arr5[1];
   // FIXME: Should be TRUE.
@@ -120,19 +98,16 @@
   clang_analyzer_eval(ptr[4] == 0); // expected-warning{{UNKNOWN}}
 }
 
-// TODO: Support multidimensional array.
 void glob_invalid_index5() {
   int idx = -42;
-  // FIXME: Should warn {{garbage or undefined}}.
-  auto x = glob_arr5[1][idx]; // no-warning
+  auto x = glob_arr5[1][idx]; // expected-warning{{garbage or undefined}}
 }
 
-// TODO: Support multidimensional array.
 void glob_invalid_index6() {
   int const *ptr = &glob_arr5[1][0];
   int idx = 42;
   // FIXME: Should warn {{garbage or undefined}}.
-  auto x = ptr[idx]; // // no-warning
+  auto x = ptr[idx]; // no-warning
 }
 
 extern const int glob_arr_no_init[10];
@@ -253,3 +228,31 @@
   clang_analyzer_eval(glob_ptr12[2] == 'c');  // expected-warning{{TRUE}}
   clang_analyzer_eval(glob_ptr12[3] == '\0'); // expected-warning{{TRUE}}
 }
+
+typedef int Int;
+typedef Int const CInt;
+typedef CInt Arr[2];
+typedef Arr Arr2[4];
+Arr2 glob_arr8 = {{1}, 3, 4, 5}; // const int[4][2]
+void glob_array_typedef1() {
+  clang_analyzer_eval(glob_arr8[0][0] == 1); // expected-warning{{TRUE}}
+  clang_analyzer_eval(glob_arr8[0][1] == 0); // expected-warning{{TRUE}}
+  clang_analyzer_eval(glob_arr8[1][0] == 3); // expected-warning{{TRUE}}
+  clan

[PATCH] D111654: [analyzer] Retrieve a value from list initialization of multi-dimensional array declaration.

2021-11-08 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added a comment.

@steakhal

Thanks for your effort!

> Yeah, I'm soo bad in review. I should have proposed these previously. Sorry.

No, you're not! I'm telling you. Keep it up! :)


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

https://reviews.llvm.org/D111654

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


[PATCH] D113319: [clang-format] Improve require handling

2021-11-08 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

I feel anything you do here would be an improvement. its probably worth looking 
at recent issues logged around this issue at the same time

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

When I added this support its was basically to prevent it from mascaraing 
concepts, take my implementation with a grain of salt if you think it needs 
changing please feel free to propose it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113319

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


[clang] 17d9560 - Making the code compliant to the documentation about Floating Point

2021-11-08 Thread Zahira Ammarguellat via cfe-commits

Author: Zahira Ammarguellat
Date: 2021-11-08T07:51:29-05:00
New Revision: 17d9560294eee1eae5e2d3ac1ab84f514318409e

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

LOG: Making the code compliant to the documentation about Floating Point
support default values for C/C++. FPP-MODEL=PRECISE enables FFP-CONTRACT
FMA is enabled.

Fix for https://bugs.llvm.org/show_bug.cgi?id=50222

Added: 
clang/test/CodeGen/ffp-model.c
clang/test/Misc/ffp-contract.c

Modified: 
clang/docs/ReleaseNotes.rst
clang/docs/UsersManual.rst
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/CodeGen/ffp-contract-option.c
clang/test/CodeGen/ppc-emmintrin.c
clang/test/CodeGen/ppc-xmmintrin.c
clang/test/Driver/fp-model.c

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index ba15803e6f48..fe4b563a6d2c 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -202,6 +202,16 @@ Arm and AArch64 Support in Clang
   architecture features, but will enable certain optimizations specific to
   Cortex-A57 CPUs and enable the use of a more accurate scheduling model.
 
+
+Floating Point Support in Clang
+---
+- The -ffp-model=precise now implies -ffp-contract=on rather than
+  -ffp-contract=fast, and the documentation of these features has been
+  clarified. Previously, the documentation claimed that -ffp-model=precise was
+  the default, but this was incorrect because the precise model implied
+  -ffp-contract=fast, whereas the default behavior is -ffp-contract=on.
+  -ffp-model=precise is now exactly the default mode of the compiler.
+
 Internal API Changes
 
 

diff  --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst
index 8c6922db6b37..406efb093d55 100644
--- a/clang/docs/UsersManual.rst
+++ b/clang/docs/UsersManual.rst
@@ -1260,8 +1260,49 @@ installed.
 Controlling Floating Point Behavior
 ---
 
-Clang provides a number of ways to control floating point behavior. The options
-are listed below.
+Clang provides a number of ways to control floating point behavior, including
+with command line options and source pragmas. This section
+describes the various floating point semantic modes and the corresponding 
options.
+
+.. csv-table:: Floating Point Semantic Modes
+  :header: "Mode", "Values"
+  :widths: 15, 30, 30
+
+  "ffp-exception-behavior", "{ignore, strict, may_trap}",
+  "fenv_access", "{off, on}", "(none)"
+  "frounding-math", "{dynamic, tonearest, downward, upward, towardzero}"
+  "ffp-contract", "{on, off, fast, fast-honor-pragmas}"
+  "fdenormal-fp-math", "{IEEE, PreserveSign, PositiveZero}"
+  "fdenormal-fp-math-fp32", "{IEEE, PreserveSign, PositiveZero}"
+  "fmath-errno", "{on, off}"
+  "fhonor-nans", "{on, off}"
+  "fhonor-infinities", "{on, off}"
+  "fsigned-zeros", "{on, off}"
+  "freciprocal-math", "{on, off}"
+  "allow_approximate_fns", "{on, off}"
+  "fassociative-math", "{on, off}"
+
+This table describes the option settings that correspond to the three
+floating point semantic models: precise (the default), strict, and fast.
+
+
+.. csv-table:: Floating Point Models
+  :header: "Mode", "Precise", "Strict", "Fast"
+  :widths: 25, 15, 15, 15
+
+  "except_behavior", "ignore", "strict", "ignore"
+  "fenv_access", "off", "on", "off"
+  "rounding_mode", "tonearest", "dynamic", "tonearest"
+  "contract", "on", "off", "fast"
+  "denormal_fp_math", "IEEE", "IEEE", "PreserveSign"
+  "denormal_fp32_math", "IEEE","IEEE", "PreserveSign"
+  "support_math_errno", "on", "on", "off"
+  "no_honor_nans", "off", "off", "on"
+  "no_honor_infinities", "off", "off", "on"
+  "no_signed_zeros", "off", "off", "on"
+  "allow_reciprocal", "off", "off", "on"
+  "allow_approximate_fns", "off", "off", "on"
+  "allow_reassociation", "off", "off", "on"
 
 .. option:: -ffast-math
 
@@ -1467,7 +1508,7 @@ Note that floating-point operations performed as part of 
constant initialization
and ``fast``.
Details:
 
-   * ``precise`` Disables optimizations that are not value-safe on 
floating-point data, although FP contraction (FMA) is enabled 
(``-ffp-contract=fast``).  This is the default behavior.
+   * ``precise`` Disables optimizations that are not value-safe on 
floating-point data, although FP contraction (FMA) is enabled 
(``-ffp-contract=on``).  This is the default behavior.
* ``strict`` Enables ``-frounding-math`` and 
``-ffp-exception-behavior=strict``, and disables contractions (FMA).  All of 
the ``-ffast-math`` enablements are disabled. Enables ``STDC FENV_ACCESS``: by 
default ``FENV_ACCESS`` is disabled. This option setting behaves as though 
``#pragma STDC FENV_ACESS ON`` appeared at the top of the source file.
* ``fast`` Behaves ide

[PATCH] D112230: [OpenCL] Add support of __opencl_c_device_enqueue feature macro.

2021-11-08 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

In D112230#3078231 , @azabaznov wrote:

> @Anastasia, @yaxunl, do you think it's possible to refactor code generation 
> for blocks such that block literal for global blocks (with no captures) would 
> be emitted in constant address space? Now it's emitted in global address 
> space (for example @__block_literal_global in 
> https://godbolt.org/z/4z8hGj7hz).

I think that the main intent of using `generic` was to simplify the code 
generation to the block invoke function, as it could always just use generic 
address space regardless the block kind, see `@my_block_A_block_invoke` in 
https://godbolt.org/z/956E1KrPP.

However it is probably possible to refactor clang to emit exact address space 
depending on the type of the block literal. However, it would break ABI for 
OpenCL 2.0 which is undesirable and also it would add extra complexity in 
already undocumented and hard to understand code. Plus there are always 
uncertainties around the exact implementation of blocks. So we would need a 
pretty decent prototype before we confirm this is actually even doable. Unless 
we find a strong need for this I would prefer to avoid this refactoring.

How about we clarify with Khronos whether it would be sufficient to add a 
restriction like:

> Program scope blocks are only supported when program scope variables feature 
> is supported.

And then see if this is acceptable route forward?




Comment at: clang/lib/AST/ExprConstant.cpp:9554
+
+const auto &OpenCLFeaturesMap =
+Info.Ctx.getTargetInfo().getSupportedOpenCLOpts();

What test case covers this change? It feels like something we should try to 
diagnose earlier...



Comment at: clang/lib/CodeGen/CGOpenCLRuntime.cpp:191
+// feature support.
+bool CGOpenCLRuntime::blockCanBeGlobal() {
+  const auto &LO = CGM.getLangOpts();

This function feels like something that belongs better to `OpenCLOptions` 
rather than `CodeGen`?



Comment at: clang/lib/Sema/SemaDecl.cpp:8024
 if (T->isBlockPointerType()) {
+  if ((T.getAddressSpace() == LangAS::opencl_constant) &&
+  !getOpenCLOptions().areProgramScopeVariablesSupported(

Good spot, I didn't feel the intent was to allow qualifying the block by an 
address space... but I don't think this was ever clarified. I feel that the 
assumption was that blocks would always be in global address space...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112230

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


Re: [clang] 17d9560 - Making the code compliant to the documentation about Floating Point

2021-11-08 Thread Roman Lebedev via cfe-commits
Was the link to the review omitted in the commit message?

On Mon, Nov 8, 2021 at 3:51 PM Zahira Ammarguellat via cfe-commits
 wrote:
>
>
> Author: Zahira Ammarguellat
> Date: 2021-11-08T07:51:29-05:00
> New Revision: 17d9560294eee1eae5e2d3ac1ab84f514318409e
>
> URL: 
> https://github.com/llvm/llvm-project/commit/17d9560294eee1eae5e2d3ac1ab84f514318409e
> DIFF: 
> https://github.com/llvm/llvm-project/commit/17d9560294eee1eae5e2d3ac1ab84f514318409e.diff
>
> LOG: Making the code compliant to the documentation about Floating Point
> support default values for C/C++. FPP-MODEL=PRECISE enables FFP-CONTRACT
> FMA is enabled.
>
> Fix for https://bugs.llvm.org/show_bug.cgi?id=50222
>
> Added:
> clang/test/CodeGen/ffp-model.c
> clang/test/Misc/ffp-contract.c
>
> Modified:
> clang/docs/ReleaseNotes.rst
> clang/docs/UsersManual.rst
> clang/lib/Driver/ToolChains/Clang.cpp
> clang/test/CodeGen/ffp-contract-option.c
> clang/test/CodeGen/ppc-emmintrin.c
> clang/test/CodeGen/ppc-xmmintrin.c
> clang/test/Driver/fp-model.c
>
> Removed:
>
>
>
> 
> diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
> index ba15803e6f48..fe4b563a6d2c 100644
> --- a/clang/docs/ReleaseNotes.rst
> +++ b/clang/docs/ReleaseNotes.rst
> @@ -202,6 +202,16 @@ Arm and AArch64 Support in Clang
>architecture features, but will enable certain optimizations specific to
>Cortex-A57 CPUs and enable the use of a more accurate scheduling model.
>
> +
> +Floating Point Support in Clang
> +---
> +- The -ffp-model=precise now implies -ffp-contract=on rather than
> +  -ffp-contract=fast, and the documentation of these features has been
> +  clarified. Previously, the documentation claimed that -ffp-model=precise 
> was
> +  the default, but this was incorrect because the precise model implied
> +  -ffp-contract=fast, whereas the default behavior is -ffp-contract=on.
> +  -ffp-model=precise is now exactly the default mode of the compiler.
> +
>  Internal API Changes
>  
>
>
> diff  --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst
> index 8c6922db6b37..406efb093d55 100644
> --- a/clang/docs/UsersManual.rst
> +++ b/clang/docs/UsersManual.rst
> @@ -1260,8 +1260,49 @@ installed.
>  Controlling Floating Point Behavior
>  ---
>
> -Clang provides a number of ways to control floating point behavior. The 
> options
> -are listed below.
> +Clang provides a number of ways to control floating point behavior, including
> +with command line options and source pragmas. This section
> +describes the various floating point semantic modes and the corresponding 
> options.
> +
> +.. csv-table:: Floating Point Semantic Modes
> +  :header: "Mode", "Values"
> +  :widths: 15, 30, 30
> +
> +  "ffp-exception-behavior", "{ignore, strict, may_trap}",
> +  "fenv_access", "{off, on}", "(none)"
> +  "frounding-math", "{dynamic, tonearest, downward, upward, towardzero}"
> +  "ffp-contract", "{on, off, fast, fast-honor-pragmas}"
> +  "fdenormal-fp-math", "{IEEE, PreserveSign, PositiveZero}"
> +  "fdenormal-fp-math-fp32", "{IEEE, PreserveSign, PositiveZero}"
> +  "fmath-errno", "{on, off}"
> +  "fhonor-nans", "{on, off}"
> +  "fhonor-infinities", "{on, off}"
> +  "fsigned-zeros", "{on, off}"
> +  "freciprocal-math", "{on, off}"
> +  "allow_approximate_fns", "{on, off}"
> +  "fassociative-math", "{on, off}"
> +
> +This table describes the option settings that correspond to the three
> +floating point semantic models: precise (the default), strict, and fast.
> +
> +
> +.. csv-table:: Floating Point Models
> +  :header: "Mode", "Precise", "Strict", "Fast"
> +  :widths: 25, 15, 15, 15
> +
> +  "except_behavior", "ignore", "strict", "ignore"
> +  "fenv_access", "off", "on", "off"
> +  "rounding_mode", "tonearest", "dynamic", "tonearest"
> +  "contract", "on", "off", "fast"
> +  "denormal_fp_math", "IEEE", "IEEE", "PreserveSign"
> +  "denormal_fp32_math", "IEEE","IEEE", "PreserveSign"
> +  "support_math_errno", "on", "on", "off"
> +  "no_honor_nans", "off", "off", "on"
> +  "no_honor_infinities", "off", "off", "on"
> +  "no_signed_zeros", "off", "off", "on"
> +  "allow_reciprocal", "off", "off", "on"
> +  "allow_approximate_fns", "off", "off", "on"
> +  "allow_reassociation", "off", "off", "on"
>
>  .. option:: -ffast-math
>
> @@ -1467,7 +1508,7 @@ Note that floating-point operations performed as part 
> of constant initialization
> and ``fast``.
> Details:
>
> -   * ``precise`` Disables optimizations that are not value-safe on 
> floating-point data, although FP contraction (FMA) is enabled 
> (``-ffp-contract=fast``).  This is the default behavior.
> +   * ``precise`` Disables optimizations that are not value-safe on 
> floating-point data, although FP contraction (FMA) is enabled 
> (``-ffp-contract=on``).  This is the default behavior.
> * ``strict`` En

[PATCH] D113201: [clang-tidy] Fix a crash in modernize-loop-convert around conversion operators

2021-11-08 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus updated this revision to Diff 385459.
Szelethus edited the summary of this revision.
Szelethus added a comment.

Clarify the summary.
Delete unnecessary includes.
More fitting `iterator` names in the test files.


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

https://reviews.llvm.org/D113201

Files:
  clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp
  clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.cpp
  clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.h
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/modernize-loop-convert/structures.h
  clang-tools-extra/test/clang-tidy/checkers/modernize-loop-convert-basic.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/modernize-loop-convert-basic.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/modernize-loop-convert-basic.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/modernize-loop-convert-basic.cpp
@@ -273,6 +273,16 @@
   // CHECK-FIXES: for (int & It : Tt)
   // CHECK-FIXES-NEXT: printf("I found %d\n", It);
 
+  // Do not crash because of Qt.begin() converting. Q::iterator converts with a
+  // conversion operator, which has no name, to Q::const_iterator.
+  Q Qt;
+  for (Q::const_iterator It = Qt.begin(), E = Qt.end(); It != E; ++It) {
+printf("I found %d\n", *It);
+  }
+  // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
+  // CHECK-FIXES: for (int & It : Qt)
+  // CHECK-FIXES-NEXT: printf("I found %d\n", It);
+
   T *Pt;
   for (T::iterator It = Pt->begin(), E = Pt->end(); It != E; ++It) {
 printf("I found %d\n", *It);
Index: clang-tools-extra/test/clang-tidy/checkers/Inputs/modernize-loop-convert/structures.h
===
--- clang-tools-extra/test/clang-tidy/checkers/Inputs/modernize-loop-convert/structures.h
+++ clang-tools-extra/test/clang-tidy/checkers/Inputs/modernize-loop-convert/structures.h
@@ -53,6 +53,23 @@
   iterator end();
 };
 
+struct Q {
+  typedef int value_type;
+  struct const_iterator {
+value_type &operator*();
+const value_type &operator*() const;
+const_iterator &operator++();
+bool operator!=(const const_iterator &other);
+void insert(value_type);
+value_type X;
+  };
+  struct iterator {
+operator const_iterator() const;
+  };
+  iterator begin();
+  iterator end();
+};
+
 struct U {
   struct iterator {
 Val& operator*();
Index: clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.h
===
--- clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.h
+++ clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.h
@@ -275,7 +275,7 @@
 typedef llvm::SmallVector UsageResult;
 
 // General functions used by ForLoopIndexUseVisitor and LoopConvertCheck.
-const Expr *digThroughConstructors(const Expr *E);
+const Expr *digThroughConstructorsConversions(const Expr *E);
 bool areSameExpr(ASTContext *Context, const Expr *First, const Expr *Second);
 const DeclRefExpr *getDeclRef(const Expr *E);
 bool areSameVariable(const ValueDecl *First, const ValueDecl *Second);
Index: clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.cpp
===
--- clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.cpp
+++ clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.cpp
@@ -152,7 +152,7 @@
   return true;
 }
 
-/// Look through conversion/copy constructors to find the explicit
+/// Look through conversion/copy constructors and operators to find the explicit
 /// initialization expression, returning it is found.
 ///
 /// The main idea is that given
@@ -165,7 +165,7 @@
 ///   vector::iterator it;
 ///   vector::iterator it(v.begin(), 0); // if this constructor existed
 /// as being initialized from `v.begin()`
-const Expr *digThroughConstructors(const Expr *E) {
+const Expr *digThroughConstructorsConversions(const Expr *E) {
   if (!E)
 return nullptr;
   E = E->IgnoreImplicit();
@@ -178,8 +178,13 @@
 E = ConstructExpr->getArg(0);
 if (const auto *Temp = dyn_cast(E))
   E = Temp->getSubExpr();
-return digThroughConstructors(E);
+return digThroughConstructorsConversions(E);
   }
+  // If this is a conversion (as iterators commonly convert into their const
+  // iterator counterparts), dig through that as well.
+  if (const auto *ME = dyn_cast(E))
+if (const auto *D = dyn_cast(ME->getMethodDecl()))
+  return digThroughConstructorsConversions(ME->getImplicitObjectArgument());
   return E;
 }
 
@@ -357,7 +362,7 @@
   bool OnlyCasts = true;
   const Expr *Init = VDecl->getInit()->IgnoreParenImpCasts();
   if (isa_and_nonnull(Init)) {
-Init = digThroughConstructors(Init);
+Init = digThroughConstructorsConversions(Init);
 OnlyCasts = false;
   }
   if (!Init)
Index: clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp
===

[PATCH] D113256: [AArch64][ARM] Enablement of Cortex-A710 Support

2021-11-08 Thread Mubashar Ahmad via Phabricator via cfe-commits
mubashar_ updated this revision to Diff 385463.
mubashar_ marked 6 inline comments as done.
mubashar_ added a comment.

Patch addresses comments.


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

https://reviews.llvm.org/D113256

Files:
  clang/docs/ReleaseNotes.rst
  clang/test/Driver/aarch64-cpus.c
  clang/test/Driver/arm-cortex-cpus.c
  clang/test/Misc/target-invalid-cpu-note.c
  llvm/include/llvm/Support/AArch64TargetParser.def
  llvm/include/llvm/Support/ARMTargetParser.def
  llvm/lib/Target/AArch64/AArch64.td
  llvm/lib/Target/AArch64/AArch64Subtarget.cpp
  llvm/lib/Target/AArch64/AArch64Subtarget.h
  llvm/lib/Target/ARM/ARM.td
  llvm/lib/Target/ARM/ARMSubtarget.cpp
  llvm/lib/Target/ARM/ARMSubtarget.h
  llvm/unittests/Support/TargetParserTest.cpp

Index: llvm/unittests/Support/TargetParserTest.cpp
===
--- llvm/unittests/Support/TargetParserTest.cpp
+++ llvm/unittests/Support/TargetParserTest.cpp
@@ -275,6 +275,13 @@
  ARM::AEK_VIRT | ARM::AEK_HWDIVARM |
  ARM::AEK_HWDIVTHUMB | ARM::AEK_DSP,
  "8-A"),
+ARMCPUTestParams("cortex-a710", "armv9-a", "neon-fp-armv8",
+ ARM::AEK_SEC | ARM::AEK_MP | ARM::AEK_VIRT |
+ ARM::AEK_HWDIVARM | ARM::AEK_HWDIVTHUMB |
+ ARM::AEK_DSP | ARM::AEK_CRC | ARM::AEK_RAS |
+ ARM::AEK_DOTPROD | ARM::AEK_FP16FML |
+ ARM::AEK_BF16 | ARM::AEK_I8MM | ARM::AEK_SB,
+ "9-A"),
 ARMCPUTestParams("cortex-a72", "armv8-a", "crypto-neon-fp-armv8",
  ARM::AEK_CRC | ARM::AEK_SEC | ARM::AEK_MP |
  ARM::AEK_VIRT | ARM::AEK_HWDIVARM |
@@ -386,7 +393,7 @@
  ARM::AEK_HWDIVARM | ARM::AEK_HWDIVTHUMB | ARM::AEK_DSP,
  "7-S")));
 
-static constexpr unsigned NumARMCPUArchs = 86;
+static constexpr unsigned NumARMCPUArchs = 87;
 
 TEST(TargetParserTest, testARMCPUArchList) {
   SmallVector List;
@@ -976,6 +983,17 @@
  AArch64::AEK_DOTPROD | AArch64::AEK_RCPC |
  AArch64::AEK_SSBS,
  "8.2-A"),
+ARMCPUTestParams("cortex-a710", "armv9-a", "neon-fp-armv8",
+ AArch64::AEK_CRC | AArch64::AEK_FP |
+ AArch64::AEK_SIMD | AArch64::AEK_RAS |
+ AArch64::AEK_LSE | AArch64::AEK_RDM |
+ AArch64::AEK_RCPC | AArch64::AEK_SVE2 |
+ AArch64::AEK_DOTPROD | AArch64::AEK_MTE |
+ AArch64::AEK_FP16FML | AArch64::AEK_SVE2BITPERM |
+ AArch64::AEK_PAUTH | AArch64::AEK_FLAGM |
+ AArch64::AEK_SB | AArch64::AEK_I8MM |
+ AArch64::AEK_BF16,
+ "9-A"),
 ARMCPUTestParams("cortex-a78c", "armv8.2-a", "crypto-neon-fp-armv8",
  AArch64::AEK_RAS | AArch64::AEK_CRC |
  AArch64::AEK_CRYPTO | AArch64::AEK_FP |
@@ -1208,7 +1226,7 @@
  AArch64::AEK_LSE | AArch64::AEK_RDM,
  "8.2-A")));
 
-static constexpr unsigned NumAArch64CPUArchs = 51;
+static constexpr unsigned NumAArch64CPUArchs = 52;
 
 TEST(TargetParserTest, testAArch64CPUArchList) {
   SmallVector List;
Index: llvm/lib/Target/ARM/ARMSubtarget.h
===
--- llvm/lib/Target/ARM/ARMSubtarget.h
+++ llvm/lib/Target/ARM/ARMSubtarget.h
@@ -58,6 +58,7 @@
 CortexA55,
 CortexA57,
 CortexA7,
+CortexA710,
 CortexA72,
 CortexA73,
 CortexA75,
Index: llvm/lib/Target/ARM/ARMSubtarget.cpp
===
--- llvm/lib/Target/ARM/ARMSubtarget.cpp
+++ llvm/lib/Target/ARM/ARMSubtarget.cpp
@@ -288,6 +288,7 @@
   case CortexA53:
   case CortexA55:
   case CortexA57:
+  case CortexA710:
   case CortexA72:
   case CortexA73:
   case CortexA75:
Index: llvm/lib/Target/ARM/ARM.td
===
--- llvm/lib/Target/ARM/ARM.td
+++ llvm/lib/Target/ARM/ARM.td
@@ -634,6 +634,8 @@
"Cortex-A77 ARM processors", []>;
 def ProcA78 : SubtargetFeature<"cortex-a78", "ARMProcFamily", "CortexA78",
"Cortex-A78 ARM processors", []>;
+def ProcA710: SubtargetFeature<"cortex-a710", "ARMProcFamily",
+   "CortexA710", "Cortex-A710 ARM processors", []>;
 def ProcA78C: SubtargetFeature<"a78c", "ARMProcFamily", "CortexA78C",
"Cortex-A78C ARM processors", []>;
 def ProcX1  : SubtargetFeature<"cortex-x1", "ARM

[clang] 0425087 - Revert "Making the code compliant to the documentation about Floating Point"

2021-11-08 Thread Nico Weber via cfe-commits

Author: Nico Weber
Date: 2021-11-08T08:32:42-05:00
New Revision: 0425087b8bac03693976ea34c156ca149482c853

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

LOG: Revert "Making the code compliant to the documentation about Floating 
Point"

This reverts commit 17d9560294eee1eae5e2d3ac1ab84f514318409e.
Breaks check-clang everywhere, see e.g.:
https://lab.llvm.org/buildbot/#/builders/105/builds/17229
https://lab.llvm.org/buildbot/#/builders/109/builds/25831
https://lab.llvm.org/buildbot/#/builders/188/builds/5493
https://lab.llvm.org/buildbot/#/builders/123/builds/7073

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/docs/UsersManual.rst
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/CodeGen/ffp-contract-option.c
clang/test/CodeGen/ppc-emmintrin.c
clang/test/CodeGen/ppc-xmmintrin.c
clang/test/Driver/fp-model.c

Removed: 
clang/test/CodeGen/ffp-model.c
clang/test/Misc/ffp-contract.c



diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index fe4b563a6d2c..ba15803e6f48 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -202,16 +202,6 @@ Arm and AArch64 Support in Clang
   architecture features, but will enable certain optimizations specific to
   Cortex-A57 CPUs and enable the use of a more accurate scheduling model.
 
-
-Floating Point Support in Clang

-- The -ffp-model=precise now implies -ffp-contract=on rather than
-  -ffp-contract=fast, and the documentation of these features has been
-  clarified. Previously, the documentation claimed that -ffp-model=precise was
-  the default, but this was incorrect because the precise model implied
-  -ffp-contract=fast, whereas the default behavior is -ffp-contract=on.
-  -ffp-model=precise is now exactly the default mode of the compiler.
-
 Internal API Changes
 
 

diff  --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst
index 406efb093d55..8c6922db6b37 100644
--- a/clang/docs/UsersManual.rst
+++ b/clang/docs/UsersManual.rst
@@ -1260,49 +1260,8 @@ installed.
 Controlling Floating Point Behavior
 ---
 
-Clang provides a number of ways to control floating point behavior, including
-with command line options and source pragmas. This section
-describes the various floating point semantic modes and the corresponding 
options.
-
-.. csv-table:: Floating Point Semantic Modes
-  :header: "Mode", "Values"
-  :widths: 15, 30, 30
-
-  "ffp-exception-behavior", "{ignore, strict, may_trap}",
-  "fenv_access", "{off, on}", "(none)"
-  "frounding-math", "{dynamic, tonearest, downward, upward, towardzero}"
-  "ffp-contract", "{on, off, fast, fast-honor-pragmas}"
-  "fdenormal-fp-math", "{IEEE, PreserveSign, PositiveZero}"
-  "fdenormal-fp-math-fp32", "{IEEE, PreserveSign, PositiveZero}"
-  "fmath-errno", "{on, off}"
-  "fhonor-nans", "{on, off}"
-  "fhonor-infinities", "{on, off}"
-  "fsigned-zeros", "{on, off}"
-  "freciprocal-math", "{on, off}"
-  "allow_approximate_fns", "{on, off}"
-  "fassociative-math", "{on, off}"
-
-This table describes the option settings that correspond to the three
-floating point semantic models: precise (the default), strict, and fast.
-
-
-.. csv-table:: Floating Point Models
-  :header: "Mode", "Precise", "Strict", "Fast"
-  :widths: 25, 15, 15, 15
-
-  "except_behavior", "ignore", "strict", "ignore"
-  "fenv_access", "off", "on", "off"
-  "rounding_mode", "tonearest", "dynamic", "tonearest"
-  "contract", "on", "off", "fast"
-  "denormal_fp_math", "IEEE", "IEEE", "PreserveSign"
-  "denormal_fp32_math", "IEEE","IEEE", "PreserveSign"
-  "support_math_errno", "on", "on", "off"
-  "no_honor_nans", "off", "off", "on"
-  "no_honor_infinities", "off", "off", "on"
-  "no_signed_zeros", "off", "off", "on"
-  "allow_reciprocal", "off", "off", "on"
-  "allow_approximate_fns", "off", "off", "on"
-  "allow_reassociation", "off", "off", "on"
+Clang provides a number of ways to control floating point behavior. The options
+are listed below.
 
 .. option:: -ffast-math
 
@@ -1508,7 +1467,7 @@ Note that floating-point operations performed as part of 
constant initialization
and ``fast``.
Details:
 
-   * ``precise`` Disables optimizations that are not value-safe on 
floating-point data, although FP contraction (FMA) is enabled 
(``-ffp-contract=on``).  This is the default behavior.
+   * ``precise`` Disables optimizations that are not value-safe on 
floating-point data, although FP contraction (FMA) is enabled 
(``-ffp-contract=fast``).  This is the default behavior.
* ``strict`` Enables ``-frounding-math`` and 
``-ffp-exception-behavior=strict``, and disables contractions (FMA).  All of 
the ``-ffast-math`` enablements are disabled. Enables ``STDC

[clang] a10a69f - [SPIR-V] Add SPIR-V triple and clang target info.

2021-11-08 Thread Anastasia Stulova via cfe-commits

Author: Anastasia Stulova
Date: 2021-11-08T13:34:10Z
New Revision: a10a69fe9c74bef3630795d9f2f516d7b84e1cd3

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

LOG: [SPIR-V] Add SPIR-V triple and clang target info.

Add new triple and target info for ‘spirv32’ and ‘spirv64’ and,
thus, enabling clang (LLVM IR) code emission to SPIR-V target.

The target for SPIR-V is mostly reused from SPIR by derivation
from a common base class since IR output for SPIR-V is mostly
the same as SPIR. Some refactoring are made accordingly.

Added and updated tests for parts that are different between
SPIR and SPIR-V.

Patch by linjamaki (Henry Linjamäki)!

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

Added: 
clang/test/CodeGenOpenCL/spirv_target.cl

Modified: 
clang/include/clang/Basic/DiagnosticGroups.td
clang/lib/Basic/Targets.cpp
clang/lib/Basic/Targets/SPIR.cpp
clang/lib/Basic/Targets/SPIR.h
clang/lib/CodeGen/TargetInfo.cpp
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Frontend/InitPreprocessor.cpp
clang/lib/Headers/opencl-c-base.h
clang/lib/Headers/opencl-c.h
clang/test/Headers/opencl-c-header.cl
clang/test/Preprocessor/predefined-macros.c
llvm/include/llvm/ADT/Triple.h
llvm/lib/Support/Triple.cpp
llvm/unittests/ADT/TripleTest.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticGroups.td 
b/clang/include/clang/Basic/DiagnosticGroups.td
index 0d8c2cb5b67d..60d417fd5770 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -1264,8 +1264,9 @@ def OptionIgnored : DiagGroup<"option-ignored">;
 def UnknownArgument : DiagGroup<"unknown-argument">;
 
 // A warning group for warnings about code that clang accepts when
-// compiling OpenCL C/C++ but which is not compatible with the SPIR spec.
+// compiling OpenCL C/C++ but which is not compatible with the SPIR(-V) spec.
 def SpirCompat : DiagGroup<"spir-compat">;
+def : DiagGroup<"spirv-compat", [SpirCompat]>; // Alias.
 
 // Warning for the GlobalISel options.
 def GlobalISel : DiagGroup<"global-isel">;

diff  --git a/clang/lib/Basic/Targets.cpp b/clang/lib/Basic/Targets.cpp
index 273eecbd09bf..994a491cddf2 100644
--- a/clang/lib/Basic/Targets.cpp
+++ b/clang/lib/Basic/Targets.cpp
@@ -606,6 +606,18 @@ TargetInfo *AllocateTarget(const llvm::Triple &Triple,
   return nullptr;
 return new SPIR64TargetInfo(Triple, Opts);
   }
+  case llvm::Triple::spirv32: {
+if (os != llvm::Triple::UnknownOS ||
+Triple.getEnvironment() != llvm::Triple::UnknownEnvironment)
+  return nullptr;
+return new SPIRV32TargetInfo(Triple, Opts);
+  }
+  case llvm::Triple::spirv64: {
+if (os != llvm::Triple::UnknownOS ||
+Triple.getEnvironment() != llvm::Triple::UnknownEnvironment)
+  return nullptr;
+return new SPIRV64TargetInfo(Triple, Opts);
+  }
   case llvm::Triple::wasm32:
 if (Triple.getSubArch() != llvm::Triple::NoSubArch ||
 Triple.getVendor() != llvm::Triple::UnknownVendor ||

diff  --git a/clang/lib/Basic/Targets/SPIR.cpp 
b/clang/lib/Basic/Targets/SPIR.cpp
index 9b7aab85314a..09d482a8b9ef 100644
--- a/clang/lib/Basic/Targets/SPIR.cpp
+++ b/clang/lib/Basic/Targets/SPIR.cpp
@@ -1,4 +1,4 @@
-//===--- SPIR.cpp - Implement SPIR target feature support 
-===//
+//===--- SPIR.cpp - Implement SPIR and SPIR-V target feature support 
--===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -6,7 +6,7 @@
 //
 
//===--===//
 //
-// This file implements SPIR TargetInfo objects.
+// This file implements SPIR and SPIR-V TargetInfo objects.
 //
 
//===--===//
 
@@ -32,3 +32,20 @@ void SPIR64TargetInfo::getTargetDefines(const LangOptions 
&Opts,
   SPIRTargetInfo::getTargetDefines(Opts, Builder);
   DefineStd(Builder, "SPIR64", Opts);
 }
+
+void SPIRVTargetInfo::getTargetDefines(const LangOptions &Opts,
+   MacroBuilder &Builder) const {
+  DefineStd(Builder, "SPIRV", Opts);
+}
+
+void SPIRV32TargetInfo::getTargetDefines(const LangOptions &Opts,
+ MacroBuilder &Builder) const {
+  SPIRVTargetInfo::getTargetDefines(Opts, Builder);
+  DefineStd(Builder, "SPIRV32", Opts);
+}
+
+void SPIRV64TargetInfo::getTargetDefines(const LangOptions &Opts,
+ MacroBuilder &Builder) const {
+  SPIRVTargetInfo::getTargetDefines(Opts, Builder);
+  DefineStd(Builder, "SPIRV64", Opts);
+}

diff  --git a/clang/lib/Basic/Targets/SPIR.h b/clang/lib/B

[PATCH] D109144: [SPIR-V] Add SPIR-V triple architecture and clang target info

2021-11-08 Thread Anastasia Stulova via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa10a69fe9c74: [SPIR-V] Add SPIR-V triple and clang target 
info. (authored by Anastasia).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109144

Files:
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/lib/Basic/Targets.cpp
  clang/lib/Basic/Targets/SPIR.cpp
  clang/lib/Basic/Targets/SPIR.h
  clang/lib/CodeGen/TargetInfo.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/InitPreprocessor.cpp
  clang/lib/Headers/opencl-c-base.h
  clang/lib/Headers/opencl-c.h
  clang/test/CodeGenOpenCL/spirv_target.cl
  clang/test/Headers/opencl-c-header.cl
  clang/test/Preprocessor/predefined-macros.c
  llvm/include/llvm/ADT/Triple.h
  llvm/lib/Support/Triple.cpp
  llvm/unittests/ADT/TripleTest.cpp

Index: llvm/unittests/ADT/TripleTest.cpp
===
--- llvm/unittests/ADT/TripleTest.cpp
+++ llvm/unittests/ADT/TripleTest.cpp
@@ -224,6 +224,16 @@
   EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
   EXPECT_EQ(Triple::UnknownOS, T.getOS());
 
+  T = Triple("spirv32-unknown-unknown");
+  EXPECT_EQ(Triple::spirv32, T.getArch());
+  EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
+  EXPECT_EQ(Triple::UnknownOS, T.getOS());
+
+  T = Triple("spirv64-unknown-unknown");
+  EXPECT_EQ(Triple::spirv64, T.getArch());
+  EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
+  EXPECT_EQ(Triple::UnknownOS, T.getOS());
+
   T = Triple("x86_64-unknown-ananas");
   EXPECT_EQ(Triple::x86_64, T.getArch());
   EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
@@ -865,6 +875,16 @@
   EXPECT_FALSE(T.isArch32Bit());
   EXPECT_TRUE(T.isArch64Bit());
 
+  T.setArch(Triple::spirv32);
+  EXPECT_FALSE(T.isArch16Bit());
+  EXPECT_TRUE(T.isArch32Bit());
+  EXPECT_FALSE(T.isArch64Bit());
+
+  T.setArch(Triple::spirv64);
+  EXPECT_FALSE(T.isArch16Bit());
+  EXPECT_FALSE(T.isArch32Bit());
+  EXPECT_TRUE(T.isArch64Bit());
+
   T.setArch(Triple::sparc);
   EXPECT_FALSE(T.isArch16Bit());
   EXPECT_TRUE(T.isArch32Bit());
@@ -1032,6 +1052,14 @@
   EXPECT_EQ(Triple::spir, T.get32BitArchVariant().getArch());
   EXPECT_EQ(Triple::spir64, T.get64BitArchVariant().getArch());
 
+  T.setArch(Triple::spirv32);
+  EXPECT_EQ(Triple::spirv32, T.get32BitArchVariant().getArch());
+  EXPECT_EQ(Triple::spirv64, T.get64BitArchVariant().getArch());
+
+  T.setArch(Triple::spirv64);
+  EXPECT_EQ(Triple::spirv32, T.get32BitArchVariant().getArch());
+  EXPECT_EQ(Triple::spirv64, T.get64BitArchVariant().getArch());
+
   T.setArch(Triple::wasm32);
   EXPECT_EQ(Triple::wasm32, T.get32BitArchVariant().getArch());
   EXPECT_EQ(Triple::wasm64, T.get64BitArchVariant().getArch());
Index: llvm/lib/Support/Triple.cpp
===
--- llvm/lib/Support/Triple.cpp
+++ llvm/lib/Support/Triple.cpp
@@ -67,6 +67,8 @@
   case sparcv9:return "sparcv9";
   case spir64: return "spir64";
   case spir:   return "spir";
+  case spirv32:return "spirv32";
+  case spirv64:return "spirv64";
   case systemz:return "s390x";
   case tce:return "tce";
   case tcele:  return "tcele";
@@ -147,6 +149,10 @@
 
   case spir:
   case spir64:  return "spir";
+
+  case spirv32:
+  case spirv64: return "spirv";
+
   case kalimba: return "kalimba";
   case lanai:   return "lanai";
   case shave:   return "shave";
@@ -323,6 +329,8 @@
 .Case("hsail64", hsail64)
 .Case("spir", spir)
 .Case("spir64", spir64)
+.Case("spirv32", spirv32)
+.Case("spirv64", spirv64)
 .Case("kalimba", kalimba)
 .Case("lanai", lanai)
 .Case("shave", shave)
@@ -456,6 +464,8 @@
 .Case("hsail64", Triple::hsail64)
 .Case("spir", Triple::spir)
 .Case("spir64", Triple::spir64)
+.Case("spirv32", Triple::spirv32)
+.Case("spirv64", Triple::spirv64)
 .StartsWith("kalimba", Triple::kalimba)
 .Case("lanai", Triple::lanai)
 .Case("renderscript32", Triple::renderscript32)
@@ -759,6 +769,11 @@
   case Triple::wasm32:
   case Triple::wasm64:
 return Triple::Wasm;
+
+  case Triple::spirv32:
+  case Triple::spirv64:
+// TODO: In future this will be Triple::SPIRV.
+return Triple::UnknownObjectFormat;
   }
   llvm_unreachable("unknown architecture");
 }
@@ -1328,6 +1343,7 @@
   case llvm::Triple::sparc:
   case llvm::Triple::sparcel:
   case llvm::Triple::spir:
+  case llvm::Triple::spirv32:
   case llvm::Triple::tce:
   case llvm::Triple::tcele:
   case llvm::Triple::thumb:
@@ -1354,6 +1370,7 @@
   case llvm::Triple::riscv64:
   case llvm::Triple::sparcv9:
   case llvm::Triple::spir64:
+  case llvm::Triple::spirv64:
   case llvm::Triple::systemz:
   case llvm::Triple::ve:
   case llvm::Triple::wasm64:
@@ -1413,6 +1430,7 @@
   case Triple::sparc:
   case 

[clang] 438437c - Making the code compliant to the documentation about Floating Point

2021-11-08 Thread Zahira Ammarguellat via cfe-commits

Author: Zahira Ammarguellat
Date: 2021-11-08T08:35:19-05:00
New Revision: 438437cbb61a39ce27b3d6218ac426b8f8a0132e

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

LOG: Making the code compliant to the documentation about Floating Point
support default values for C/C++. FPP-MODEL=PRECISE enables FFP-CONTRACT
FMA is enabled.

Fix for https://bugs.llvm.org/show_bug.cgi?id=50222

Added: 
clang/test/CodeGen/ffp-model.c
clang/test/Misc/ffp-contract.c

Modified: 
clang/docs/ReleaseNotes.rst
clang/docs/UsersManual.rst
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/CodeGen/ffp-contract-option.c
clang/test/CodeGen/ppc-emmintrin.c
clang/test/CodeGen/ppc-xmmintrin.c
clang/test/Driver/fp-model.c

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index ba15803e6f48..fe4b563a6d2c 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -202,6 +202,16 @@ Arm and AArch64 Support in Clang
   architecture features, but will enable certain optimizations specific to
   Cortex-A57 CPUs and enable the use of a more accurate scheduling model.
 
+
+Floating Point Support in Clang
+---
+- The -ffp-model=precise now implies -ffp-contract=on rather than
+  -ffp-contract=fast, and the documentation of these features has been
+  clarified. Previously, the documentation claimed that -ffp-model=precise was
+  the default, but this was incorrect because the precise model implied
+  -ffp-contract=fast, whereas the default behavior is -ffp-contract=on.
+  -ffp-model=precise is now exactly the default mode of the compiler.
+
 Internal API Changes
 
 

diff  --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst
index 8c6922db6b37..406efb093d55 100644
--- a/clang/docs/UsersManual.rst
+++ b/clang/docs/UsersManual.rst
@@ -1260,8 +1260,49 @@ installed.
 Controlling Floating Point Behavior
 ---
 
-Clang provides a number of ways to control floating point behavior. The options
-are listed below.
+Clang provides a number of ways to control floating point behavior, including
+with command line options and source pragmas. This section
+describes the various floating point semantic modes and the corresponding 
options.
+
+.. csv-table:: Floating Point Semantic Modes
+  :header: "Mode", "Values"
+  :widths: 15, 30, 30
+
+  "ffp-exception-behavior", "{ignore, strict, may_trap}",
+  "fenv_access", "{off, on}", "(none)"
+  "frounding-math", "{dynamic, tonearest, downward, upward, towardzero}"
+  "ffp-contract", "{on, off, fast, fast-honor-pragmas}"
+  "fdenormal-fp-math", "{IEEE, PreserveSign, PositiveZero}"
+  "fdenormal-fp-math-fp32", "{IEEE, PreserveSign, PositiveZero}"
+  "fmath-errno", "{on, off}"
+  "fhonor-nans", "{on, off}"
+  "fhonor-infinities", "{on, off}"
+  "fsigned-zeros", "{on, off}"
+  "freciprocal-math", "{on, off}"
+  "allow_approximate_fns", "{on, off}"
+  "fassociative-math", "{on, off}"
+
+This table describes the option settings that correspond to the three
+floating point semantic models: precise (the default), strict, and fast.
+
+
+.. csv-table:: Floating Point Models
+  :header: "Mode", "Precise", "Strict", "Fast"
+  :widths: 25, 15, 15, 15
+
+  "except_behavior", "ignore", "strict", "ignore"
+  "fenv_access", "off", "on", "off"
+  "rounding_mode", "tonearest", "dynamic", "tonearest"
+  "contract", "on", "off", "fast"
+  "denormal_fp_math", "IEEE", "IEEE", "PreserveSign"
+  "denormal_fp32_math", "IEEE","IEEE", "PreserveSign"
+  "support_math_errno", "on", "on", "off"
+  "no_honor_nans", "off", "off", "on"
+  "no_honor_infinities", "off", "off", "on"
+  "no_signed_zeros", "off", "off", "on"
+  "allow_reciprocal", "off", "off", "on"
+  "allow_approximate_fns", "off", "off", "on"
+  "allow_reassociation", "off", "off", "on"
 
 .. option:: -ffast-math
 
@@ -1467,7 +1508,7 @@ Note that floating-point operations performed as part of 
constant initialization
and ``fast``.
Details:
 
-   * ``precise`` Disables optimizations that are not value-safe on 
floating-point data, although FP contraction (FMA) is enabled 
(``-ffp-contract=fast``).  This is the default behavior.
+   * ``precise`` Disables optimizations that are not value-safe on 
floating-point data, although FP contraction (FMA) is enabled 
(``-ffp-contract=on``).  This is the default behavior.
* ``strict`` Enables ``-frounding-math`` and 
``-ffp-exception-behavior=strict``, and disables contractions (FMA).  All of 
the ``-ffast-math`` enablements are disabled. Enables ``STDC FENV_ACCESS``: by 
default ``FENV_ACCESS`` is disabled. This option setting behaves as though 
``#pragma STDC FENV_ACESS ON`` appeared at the top of the source file.
* ``fast`` Behaves ide

RE: [clang] 6278682 - In spir functions, llvm.dbg.declare intrinsics created

2021-11-08 Thread Ammarguellat, Zahira via cfe-commits
https://reviews.llvm.org/D112963

-Original Message-
From: Aaron Ballman  
Sent: Monday, November 8, 2021 6:51 AM
To: Ammarguellat, Zahira ; Zahira Ammarguellat 

Cc: cfe-commits 
Subject: Re: [clang] 6278682 - In spir functions, llvm.dbg.declare intrinsics 
created

Hello! Was this code reviewed anywhere? I can't seem to spot a review for it, 
so wondering if I missed something.

Thanks!

~Aaron

On Fri, Nov 5, 2021 at 6:08 PM Zahira Ammarguellat via cfe-commits 
 wrote:
>
>
> Author: Zahira Ammarguellat
> Date: 2021-11-05T15:08:09-07:00
> New Revision: 627868263cd4d57c230b61904483a3dad9e1a1da
>
> URL: 
> https://github.com/llvm/llvm-project/commit/627868263cd4d57c230b619044
> 83a3dad9e1a1da
> DIFF: 
> https://github.com/llvm/llvm-project/commit/627868263cd4d57c230b619044
> 83a3dad9e1a1da.diff
>
> LOG: In spir functions, llvm.dbg.declare intrinsics created for 
> parameters and locals need to refer to the stack allocation in the 
> alloca address space.
>
> Added:
> clang/test/CodeGenSYCL/debug-info-kernel-variables.cpp
>
> Modified:
> clang/lib/CodeGen/CGDecl.cpp
>
> Removed:
>
>
>
> ##
> ## diff  --git a/clang/lib/CodeGen/CGDecl.cpp 
> b/clang/lib/CodeGen/CGDecl.cpp index dfb74a3fc6547..941671c614824 
> 100644
> --- a/clang/lib/CodeGen/CGDecl.cpp
> +++ b/clang/lib/CodeGen/CGDecl.cpp
> @@ -1447,6 +1447,7 @@ CodeGenFunction::EmitAutoVarAlloca(const VarDecl 
> &D) {
>
>if (getLangOpts().OpenMP && OpenMPLocalAddr.isValid()) {
>  address = OpenMPLocalAddr;
> +AllocaAddr = OpenMPLocalAddr;
>} else if (Ty->isConstantSizeType()) {
>  // If this value is an array or struct with a statically determinable
>  // constant initializer, there are optimizations we can do.
> @@ -1492,6 +1493,7 @@ CodeGenFunction::EmitAutoVarAlloca(const VarDecl &D) {
>// return slot, so that we can elide the copy when returning this
>// variable (C++0x [class.copy]p34).
>address = ReturnValue;
> +  AllocaAddr = ReturnValue;
>
>if (const RecordType *RecordTy = Ty->getAs()) {
>  const auto *RD = RecordTy->getDecl(); @@ -1503,7 +1505,8 @@ 
> CodeGenFunction::EmitAutoVarAlloca(const VarDecl &D) {
>// applied.
>llvm::Value *Zero = Builder.getFalse();
>Address NRVOFlag =
> -CreateTempAlloca(Zero->getType(), CharUnits::One(), "nrvo");
> +  CreateTempAlloca(Zero->getType(), CharUnits::One(), "nrvo",
> +   /*ArraySize=*/nullptr, &AllocaAddr);
>EnsureInsertPoint();
>Builder.CreateStore(Zero, NRVOFlag);
>
> @@ -1605,10 +1608,11 @@ CodeGenFunction::EmitAutoVarAlloca(const VarDecl &D) {
>  DI->setLocation(D.getLocation());
>
>  // If NRVO, use a pointer to the return address.
> -if (UsePointerValue)
> +if (UsePointerValue) {
>DebugAddr = ReturnValuePointer;
> -
> -(void)DI->EmitDeclareOfAutoVariable(&D, DebugAddr.getPointer(), Builder,
> +  AllocaAddr = ReturnValuePointer;
> +}
> +(void)DI->EmitDeclareOfAutoVariable(&D, AllocaAddr.getPointer(), 
> + Builder,
>  UsePointerValue);
>}
>
> @@ -2450,6 +2454,7 @@ void CodeGenFunction::EmitParmDecl(const VarDecl &D, 
> ParamValue Arg,
>}
>
>Address DeclPtr = Address::invalid();
> +  Address AllocaPtr = Address::invalid();
>bool DoStore = false;
>bool IsScalar = hasScalarEvaluationKind(Ty);
>// If we already have a pointer to the argument, reuse the input pointer.
> @@ -2464,6 +2469,7 @@ void CodeGenFunction::EmitParmDecl(const VarDecl &D, 
> ParamValue Arg,
>  // from the default address space.
>  auto AllocaAS = CGM.getASTAllocaAddressSpace();
>  auto *V = DeclPtr.getPointer();
> +AllocaPtr = DeclPtr;
>  auto SrcLangAS = getLangOpts().OpenCL ? LangAS::opencl_private : 
> AllocaAS;
>  auto DestLangAS =
>  getLangOpts().OpenCL ? LangAS::opencl_private : 
> LangAS::Default; @@ -2500,10 +2506,11 @@ void 
> CodeGenFunction::EmitParmDecl(const VarDecl &D, ParamValue Arg,
>  : Address::invalid();
>  if (getLangOpts().OpenMP && OpenMPLocalAddr.isValid()) {
>DeclPtr = OpenMPLocalAddr;
> +  AllocaPtr = DeclPtr;
>  } else {
>// Otherwise, create a temporary to hold the value.
>DeclPtr = CreateMemTemp(Ty, getContext().getDeclAlign(&D),
> -  D.getName() + ".addr");
> +  D.getName() + ".addr", &AllocaPtr);
>  }
>  DoStore = true;
>}
> @@ -2579,7 +2586,7 @@ void CodeGenFunction::EmitParmDecl(const VarDecl &D, 
> ParamValue Arg,
>if (CGDebugInfo *DI = getDebugInfo()) {
>  if (CGM.getCodeGenOpts().hasReducedDebugInfo() && !CurFuncIsThunk) {
>llvm::DILocalVariable *DILocalVar = DI->EmitDeclareOfArgVariable(
> -  &D, DeclPtr.getPointer(), ArgNo, Builder);
> +  &D, AllocaPtr.getP

[PATCH] D109885: [MLIR][[amdgpu-arch]][OpenMP] Remove direct dependency on /opt/rocm

2021-11-08 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield requested changes to this revision.
JonChesterfield added a reviewer: ronl.
JonChesterfield added a comment.
This revision now requires changes to proceed.

Marking as request changes because:
`if (DEFINED ENV{ROCM_PATH})`
Looking at environment variables is strictly worse than looking at cmake 
variables. I think we should replace /opt/rocm with a cmake variable that 
points to somewhere to find rocr/roct, and have no strong feelings about what 
the cmake variable should be called


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109885

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


[PATCH] D109885: [MLIR][[amdgpu-arch]][OpenMP] Remove direct dependency on /opt/rocm

2021-11-08 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield added a comment.

I don't know about the MLIR parts, but replacing

> find_package(hsa-runtime64 QUIET 1.2.0 HINTS ${CMAKE_INSTALL_PREFIX} PATHS 
> /opt/rocm)

with

> find_package(hsa-runtime64 QUIET 1.2.0 HINTS ${CMAKE_INSTALL_PREFIX} PATHS 
> ${ROCM_PATH})

seems an improvement, where ROCM_PATH is ideally a CMake variable spelled the 
same way in other components, such that someone can build an LLVM with the 
components all hooked into a specific ROCm location


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109885

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


Re: [clang] 6278682 - In spir functions, llvm.dbg.declare intrinsics created

2021-11-08 Thread Aaron Ballman via cfe-commits
Ah, I see what went wrong. That review was never signed up to the
cfe-commits mailing list, so the only people who ever saw that review
were the people explicitly on the reviewers and subscribers list. Next
time, please be sure to add cfe-commits to the subscribers list
explicitly.

~Aaron

On Mon, Nov 8, 2021 at 7:36 AM Ammarguellat, Zahira
 wrote:
>
> https://reviews.llvm.org/D112963
>
> -Original Message-
> From: Aaron Ballman 
> Sent: Monday, November 8, 2021 6:51 AM
> To: Ammarguellat, Zahira ; Zahira Ammarguellat 
> 
> Cc: cfe-commits 
> Subject: Re: [clang] 6278682 - In spir functions, llvm.dbg.declare intrinsics 
> created
>
> Hello! Was this code reviewed anywhere? I can't seem to spot a review for it, 
> so wondering if I missed something.
>
> Thanks!
>
> ~Aaron
>
> On Fri, Nov 5, 2021 at 6:08 PM Zahira Ammarguellat via cfe-commits 
>  wrote:
> >
> >
> > Author: Zahira Ammarguellat
> > Date: 2021-11-05T15:08:09-07:00
> > New Revision: 627868263cd4d57c230b61904483a3dad9e1a1da
> >
> > URL:
> > https://github.com/llvm/llvm-project/commit/627868263cd4d57c230b619044
> > 83a3dad9e1a1da
> > DIFF:
> > https://github.com/llvm/llvm-project/commit/627868263cd4d57c230b619044
> > 83a3dad9e1a1da.diff
> >
> > LOG: In spir functions, llvm.dbg.declare intrinsics created for
> > parameters and locals need to refer to the stack allocation in the
> > alloca address space.
> >
> > Added:
> > clang/test/CodeGenSYCL/debug-info-kernel-variables.cpp
> >
> > Modified:
> > clang/lib/CodeGen/CGDecl.cpp
> >
> > Removed:
> >
> >
> >
> > ##
> > ## diff  --git a/clang/lib/CodeGen/CGDecl.cpp
> > b/clang/lib/CodeGen/CGDecl.cpp index dfb74a3fc6547..941671c614824
> > 100644
> > --- a/clang/lib/CodeGen/CGDecl.cpp
> > +++ b/clang/lib/CodeGen/CGDecl.cpp
> > @@ -1447,6 +1447,7 @@ CodeGenFunction::EmitAutoVarAlloca(const VarDecl
> > &D) {
> >
> >if (getLangOpts().OpenMP && OpenMPLocalAddr.isValid()) {
> >  address = OpenMPLocalAddr;
> > +AllocaAddr = OpenMPLocalAddr;
> >} else if (Ty->isConstantSizeType()) {
> >  // If this value is an array or struct with a statically determinable
> >  // constant initializer, there are optimizations we can do.
> > @@ -1492,6 +1493,7 @@ CodeGenFunction::EmitAutoVarAlloca(const VarDecl &D) {
> >// return slot, so that we can elide the copy when returning this
> >// variable (C++0x [class.copy]p34).
> >address = ReturnValue;
> > +  AllocaAddr = ReturnValue;
> >
> >if (const RecordType *RecordTy = Ty->getAs()) {
> >  const auto *RD = RecordTy->getDecl(); @@ -1503,7 +1505,8 @@
> > CodeGenFunction::EmitAutoVarAlloca(const VarDecl &D) {
> >// applied.
> >llvm::Value *Zero = Builder.getFalse();
> >Address NRVOFlag =
> > -CreateTempAlloca(Zero->getType(), CharUnits::One(), "nrvo");
> > +  CreateTempAlloca(Zero->getType(), CharUnits::One(), "nrvo",
> > +   /*ArraySize=*/nullptr, &AllocaAddr);
> >EnsureInsertPoint();
> >Builder.CreateStore(Zero, NRVOFlag);
> >
> > @@ -1605,10 +1608,11 @@ CodeGenFunction::EmitAutoVarAlloca(const VarDecl 
> > &D) {
> >  DI->setLocation(D.getLocation());
> >
> >  // If NRVO, use a pointer to the return address.
> > -if (UsePointerValue)
> > +if (UsePointerValue) {
> >DebugAddr = ReturnValuePointer;
> > -
> > -(void)DI->EmitDeclareOfAutoVariable(&D, DebugAddr.getPointer(), 
> > Builder,
> > +  AllocaAddr = ReturnValuePointer;
> > +}
> > +(void)DI->EmitDeclareOfAutoVariable(&D, AllocaAddr.getPointer(),
> > + Builder,
> >  UsePointerValue);
> >}
> >
> > @@ -2450,6 +2454,7 @@ void CodeGenFunction::EmitParmDecl(const VarDecl &D, 
> > ParamValue Arg,
> >}
> >
> >Address DeclPtr = Address::invalid();
> > +  Address AllocaPtr = Address::invalid();
> >bool DoStore = false;
> >bool IsScalar = hasScalarEvaluationKind(Ty);
> >// If we already have a pointer to the argument, reuse the input pointer.
> > @@ -2464,6 +2469,7 @@ void CodeGenFunction::EmitParmDecl(const VarDecl &D, 
> > ParamValue Arg,
> >  // from the default address space.
> >  auto AllocaAS = CGM.getASTAllocaAddressSpace();
> >  auto *V = DeclPtr.getPointer();
> > +AllocaPtr = DeclPtr;
> >  auto SrcLangAS = getLangOpts().OpenCL ? LangAS::opencl_private : 
> > AllocaAS;
> >  auto DestLangAS =
> >  getLangOpts().OpenCL ? LangAS::opencl_private :
> > LangAS::Default; @@ -2500,10 +2506,11 @@ void 
> > CodeGenFunction::EmitParmDecl(const VarDecl &D, ParamValue Arg,
> >  : Address::invalid();
> >  if (getLangOpts().OpenMP && OpenMPLocalAddr.isValid()) {
> >DeclPtr = OpenMPLocalAddr;
> > +  AllocaPtr = DeclPtr;
> >  } else {
> >// Otherwise, create a temporary to hold the value.
> >DeclPtr

[PATCH] D109144: [SPIR-V] Add SPIR-V triple architecture and clang target info

2021-11-08 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

FYI the original RFC is 
https://lists.llvm.org/pipermail/cfe-dev/2021-August/068603.html


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109144

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


Re: [clang] 17d9560 - Making the code compliant to the documentation about Floating Point

2021-11-08 Thread Aaron Ballman via cfe-commits
The link to the review is missing and the review never made it to the
cfe-commits mailing list before being landed. This was also reverted
in 0425087b8bac03693976ea34c156ca149482c853 and but maybe was fixed by
the changes landed in 438437cbb61a39ce27b3d6218ac426b8f8a0132e?

~Aaron


On Mon, Nov 8, 2021 at 8:01 AM Roman Lebedev  wrote:
>
> Was the link to the review omitted in the commit message?
>
> On Mon, Nov 8, 2021 at 3:51 PM Zahira Ammarguellat via cfe-commits
>  wrote:
> >
> >
> > Author: Zahira Ammarguellat
> > Date: 2021-11-08T07:51:29-05:00
> > New Revision: 17d9560294eee1eae5e2d3ac1ab84f514318409e
> >
> > URL: 
> > https://github.com/llvm/llvm-project/commit/17d9560294eee1eae5e2d3ac1ab84f514318409e
> > DIFF: 
> > https://github.com/llvm/llvm-project/commit/17d9560294eee1eae5e2d3ac1ab84f514318409e.diff
> >
> > LOG: Making the code compliant to the documentation about Floating Point
> > support default values for C/C++. FPP-MODEL=PRECISE enables FFP-CONTRACT
> > FMA is enabled.
> >
> > Fix for https://bugs.llvm.org/show_bug.cgi?id=50222
> >
> > Added:
> > clang/test/CodeGen/ffp-model.c
> > clang/test/Misc/ffp-contract.c
> >
> > Modified:
> > clang/docs/ReleaseNotes.rst
> > clang/docs/UsersManual.rst
> > clang/lib/Driver/ToolChains/Clang.cpp
> > clang/test/CodeGen/ffp-contract-option.c
> > clang/test/CodeGen/ppc-emmintrin.c
> > clang/test/CodeGen/ppc-xmmintrin.c
> > clang/test/Driver/fp-model.c
> >
> > Removed:
> >
> >
> >
> > 
> > diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
> > index ba15803e6f48..fe4b563a6d2c 100644
> > --- a/clang/docs/ReleaseNotes.rst
> > +++ b/clang/docs/ReleaseNotes.rst
> > @@ -202,6 +202,16 @@ Arm and AArch64 Support in Clang
> >architecture features, but will enable certain optimizations specific to
> >Cortex-A57 CPUs and enable the use of a more accurate scheduling model.
> >
> > +
> > +Floating Point Support in Clang
> > +---
> > +- The -ffp-model=precise now implies -ffp-contract=on rather than
> > +  -ffp-contract=fast, and the documentation of these features has been
> > +  clarified. Previously, the documentation claimed that -ffp-model=precise 
> > was
> > +  the default, but this was incorrect because the precise model implied
> > +  -ffp-contract=fast, whereas the default behavior is -ffp-contract=on.
> > +  -ffp-model=precise is now exactly the default mode of the compiler.
> > +
> >  Internal API Changes
> >  
> >
> >
> > diff  --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst
> > index 8c6922db6b37..406efb093d55 100644
> > --- a/clang/docs/UsersManual.rst
> > +++ b/clang/docs/UsersManual.rst
> > @@ -1260,8 +1260,49 @@ installed.
> >  Controlling Floating Point Behavior
> >  ---
> >
> > -Clang provides a number of ways to control floating point behavior. The 
> > options
> > -are listed below.
> > +Clang provides a number of ways to control floating point behavior, 
> > including
> > +with command line options and source pragmas. This section
> > +describes the various floating point semantic modes and the corresponding 
> > options.
> > +
> > +.. csv-table:: Floating Point Semantic Modes
> > +  :header: "Mode", "Values"
> > +  :widths: 15, 30, 30
> > +
> > +  "ffp-exception-behavior", "{ignore, strict, may_trap}",
> > +  "fenv_access", "{off, on}", "(none)"
> > +  "frounding-math", "{dynamic, tonearest, downward, upward, towardzero}"
> > +  "ffp-contract", "{on, off, fast, fast-honor-pragmas}"
> > +  "fdenormal-fp-math", "{IEEE, PreserveSign, PositiveZero}"
> > +  "fdenormal-fp-math-fp32", "{IEEE, PreserveSign, PositiveZero}"
> > +  "fmath-errno", "{on, off}"
> > +  "fhonor-nans", "{on, off}"
> > +  "fhonor-infinities", "{on, off}"
> > +  "fsigned-zeros", "{on, off}"
> > +  "freciprocal-math", "{on, off}"
> > +  "allow_approximate_fns", "{on, off}"
> > +  "fassociative-math", "{on, off}"
> > +
> > +This table describes the option settings that correspond to the three
> > +floating point semantic models: precise (the default), strict, and fast.
> > +
> > +
> > +.. csv-table:: Floating Point Models
> > +  :header: "Mode", "Precise", "Strict", "Fast"
> > +  :widths: 25, 15, 15, 15
> > +
> > +  "except_behavior", "ignore", "strict", "ignore"
> > +  "fenv_access", "off", "on", "off"
> > +  "rounding_mode", "tonearest", "dynamic", "tonearest"
> > +  "contract", "on", "off", "fast"
> > +  "denormal_fp_math", "IEEE", "IEEE", "PreserveSign"
> > +  "denormal_fp32_math", "IEEE","IEEE", "PreserveSign"
> > +  "support_math_errno", "on", "on", "off"
> > +  "no_honor_nans", "off", "off", "on"
> > +  "no_honor_infinities", "off", "off", "on"
> > +  "no_signed_zeros", "off", "off", "on"
> > +  "allow_reciprocal", "off", "off", "on"
> > +  "allow_approximate_fns", "off", "off", "on"
> > +  "allow_reassociation", "off", "off", "on"
> >
> > 

[PATCH] D113397: [analyzer][docs] Fix the incorrect structure of the checker docs

2021-11-08 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus created this revision.
Szelethus added reviewers: NoQ, steakhal, dkrupp, martong, vsavchenko, balazske.
Szelethus added a project: clang.
Herald added subscribers: manas, ASDenysPetrov, gamesh411, donat.nagy, 
mikhail.ramalho, a.sidorin, rnkovacs, szepet, baloghadamsoftware, xazax.hun, 
whisperity.
Szelethus requested review of this revision.
Herald added a subscriber: cfe-commits.

The `alpha.security.cert` section came right after `alpha.security`, making it 
look like checkers like `alpha.security.MmapWriteExec` belonged to that package.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D113397

Files:
  clang/docs/analyzer/checkers.rst

Index: clang/docs/analyzer/checkers.rst
===
--- clang/docs/analyzer/checkers.rst
+++ clang/docs/analyzer/checkers.rst
@@ -2048,90 +2048,6 @@
 alpha.security
 ^^
 
-
-alpha.security.cert
-^^^
-
-SEI CERT checkers which tries to find errors based on their `C coding rules `_.
-
-.. _alpha-security-cert-pos-checkers:
-
-alpha.security.cert.pos
-^^^
-
-SEI CERT checkers of `POSIX C coding rules `_.
-
-.. _alpha-security-cert-pos-34c:
-
-alpha.security.cert.pos.34c
-"""
-Finds calls to the ``putenv`` function which pass a pointer to an automatic variable as the argument.
-
-.. code-block:: c
-
-  int func(const char *var) {
-char env[1024];
-int retval = snprintf(env, sizeof(env),"TEST=%s", var);
-if (retval < 0 || (size_t)retval >= sizeof(env)) {
-/* Handle error */
-}
-
-return putenv(env); // putenv function should not be called with auto variables
-  }
-
-alpha.security.cert.env
-^^^
-
-SEI CERT checkers of `POSIX C coding rules `_.
-
-.. _alpha-security-cert-env-InvalidPtr:
-
-alpha.security.cert.env.InvalidPtr
-"""
-
-Corresponds to SEI CERT Rules ENV31-C and ENV34-C.
-
-ENV31-C:
-Rule is about the possible problem with `main` function's third argument, environment pointer,
-"envp". When enviornment array is modified using some modification function
-such as putenv, setenv or others, It may happen that memory is reallocated,
-however "envp" is not updated to reflect the changes and points to old memory
-region.
-
-ENV34-C:
-Some functions return a pointer to a statically allocated buffer.
-Consequently, subsequent call of these functions will invalidate previous
-pointer. These functions include: getenv, localeconv, asctime, setlocale, strerror
-
-.. code-block:: c
-
-  int main(int argc, const char *argv[], const char *envp[]) {
-if (setenv("MY_NEW_VAR", "new_value", 1) != 0) {
-  // setenv call may invalidate 'envp'
-  /* Handle error */
-}
-if (envp != NULL) {
-  for (size_t i = 0; envp[i] != NULL; ++i) {
-puts(envp[i]);
-// envp may no longer point to the current environment
-// this program has unanticipated behavior, since envp
-// does not reflect changes made by setenv function.
-  }
-}
-return 0;
-  }
-
-  void previous_call_invalidation() {
-char *p, *pp;
-
-p = getenv("VAR");
-pp = getenv("VAR2");
-// subsequent call to 'getenv' invalidated previous one
-
-*p;
-// dereferencing invalid pointer
-  }
-
 .. _alpha-security-ArrayBound:
 
 alpha.security.ArrayBound (C)
@@ -2283,6 +2199,95 @@
return x; // warn: undefined or garbage returned
  }
 
+
+alpha.security.cert
+^^^
+
+SEI CERT checkers which tries to find errors based on their `C coding rules `_.
+
+.. _alpha-security-cert-pos-checkers:
+
+alpha.security.cert.pos
+^^^
+
+SEI CERT checkers of `POSIX C coding rules `_.
+
+.. _alpha-security-cert-pos-34c:
+
+alpha.security.cert.pos.34c
+"""
+Finds calls to the ``putenv`` function which pass a pointer to an automatic variable as the argument.
+
+.. code-block:: c
+
+  int func(const char *var) {
+char env[1024];
+int retval = snprintf(env, sizeof(env),"TEST=%s", var);
+if (retval < 0 || (size_t)retval >= sizeof(env)) {
+/* Handle error */
+}
+
+return putenv(env); // putenv function should not be called with auto variables
+  }
+
+alpha.security.cert.env
+^^^
+
+SEI CERT checkers of `Environment C coding rules `_.
+
+.. _alpha-security-cert-env-InvalidPtr:
+
+alpha.security.cert.env.InvalidPtr
+""
+
+Corresponds to SEI CERT Rules ENV31-C and ENV34-C.
+
+ENV31-C:
+Rule is about the possible problem with `main` function's third argument, environment pointe

[PATCH] D80804: [AMDGPU] Introduce Clang builtins to be mapped to AMDGCN atomic inc/dec intrinsics

2021-11-08 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added inline comments.



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:14563
 
-if (isa(Order)) {
-  int ord = cast(Order)->getZExtValue();
+switch (BuiltinID) {
+case AMDGPU::BI__builtin_amdgcn_atomic_inc32:

RKSimon wrote:
> @saiislam @arsenm Coverity is warning that the BI__builtin_amdgcn_fence 
> (fallthrough case) is not handled meaning that BuiltinAtomicOp in 
> uninitialized
Test is also missing for builtin_amdgcn_fence


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80804

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


[PATCH] D112349: [Verifier] Add verification logic for GlobalIFuncs

2021-11-08 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

In D112349#3112315 , @v.g.vassilev 
wrote:

> In D112349#3111927 , @erichkeane 
> wrote:
>
>> In D112349#3111873 , @ibookstein 
>> wrote:
>>
>>> And how is Cling expecting CFE to deal with partial knowledge situations at 
>>> the implementation level? To deal with exactly the non-local cases that the 
>>> current violations address?
>>> If there's no prescriptive way forward to dealing with these cases (so 
>>> they're tech debt without a remediation plan), then as far as I'm concerned 
>>> this case sits exactly under the same tech-debt umbrella of the existing 
>>> violations and the way forward is using the same violating solution for 
>>> this case too. 
>>> We definitely shouldn't block the IR verification indefinitely on this 
>>> impasse. Once an acceptable solution is found, this will also be part of 
>>> that refactor.
>>
>> My understanding is that the REPL setup is that the 'IR' just needs to be in 
>> a state where it doesn't require reverts/rewrites later, so that we can do 
>> partial-back-end-code-generation as we go along.  That said, I'm not 
>> positive as to the implications.  I'm just repeating the discussion the CFE 
>> code-owner made at the time.
>>
>> IMO, the 'acceptable' solution is to have a way to forward-declare an ifunc 
>> in IR so that we can fill in the resolver later on.  From your description 
>> earlier, it seems that this would work as we could emit it as an 'unknown 
>> symbol' (as if it was an undefined function declaration), and would be 
>> completely implementable in the CFE.
>>
>> So it would change your plan from earlier to:
>>
>> When processing cpu_specific, emit the ifunc "x.ifunc", with no resolver;
>> When processing cpu_dispatch:
>>
>>   Get/Create the ifunc, then pull up the resolver.
>>   If the resolver is null (as it should be), create one and update the 
>> 'ifunc'.
>>   Generate said resolver.
>>   
>
> Speaking of the incremental compilation case, we can experiment with the 
> clang-repl binary. I am not sure about the details of this discussion but 
> here is an example that works today:
>
>   llvm/build/bin/clang-repl 
>   clang-repl> __attribute__((cpu_specific(ivybridge))) void 
> single_version(void){}
>   clang-repl> void useage() {single_version();}
>   clang-repl> quit
>
> What would it be a good example to check if the incremental compilation case 
> is covered?

FWIW, the comments above are about not making it 'worse' at least/adding more wo

In D112349#3113054 , @ibookstein 
wrote:

> I feel like we're getting lost in the weeds here.
>
> At the time a bitcode module is finalized, it is supposed to be in a valid 
> state. 
> The LLVM bitcode verifier does not consider GlobalAliases which have either a 
> null or an undefined aliasee to be valid. The same should have held for 
> GlobalIFuncs and their resolvers since their inception, and the fact that it 
> were not so is an oversight.
>
> There are two separate issues here which we need to decouple:
>
> - IFuncs with undefined resolvers were never valid, the verification just 
> happened to be missing. They also misbehave, as demonstrated by my example 
> above where a TU contains both cpu_specific and a usage, but no cpu_dispatch. 
> Therefore, we'd not be making anything worse by plugging the current hole in 
> the verification of GlobalIFunc and keeping cpu_specific/cpu_dispatch 
> working, using the same method we use to handle aliases or ifuncs that come 
> after declarations, i.e. cpu_specific emits plain function declarations, 
> cpu_dispatch upgrades them via takeName+RAUW+eraseFromParent if they already 
> exist. We'll have made the verification more robust, fixed a bug when there's 
> a TU where there's cpu_specific + usage but no cpu_dispatch, and not have 
> incurred more tech debt by doing so (since that tech debt already exists, and 
> a solution would need to address all these cases in exactly the same way).
> - Clang-repl/CGM needs infrastructure for dealing with this sort of 
> 'backtracking' in incremental compilation use-cases (declaration gets 
> upgraded to alias, declaration gets upgraded to ifunc). If it needs IR 
> changes for that, then they should be designed, agreed upon, and integrated. 
> We're not going to have a decision made in this closed PR discussion that 
> either GlobalAliases or GlobalIFuncs support a declaration state all of a 
> sudden. Such decisions could have cross-cutting ramifications in that there 
> would all of a sudden be 3 ways to represent things that are equivalent 
> to/get lowered to function declarations, rather than one. Limiting ourselves 
> to not using the existing solution for these use-cases/bugs in normal 
> compilation with the hope that it will ease the creation of a solution for 
> incremental compilation of the same use-cases is sel

[PATCH] D113294: [IR] Remove unbounded as possible value for vscale_range minimum

2021-11-08 Thread Sander de Smalen via Phabricator via cfe-commits
sdesmalen added a comment.

It would be nice if the LLVM interfaces could be updated as well (could also be 
done in a follow-up patch)

From:

  std::pair getVScaleRangeArgs()

To:

  Optional getVScaleRangeMax();
  unsigned getVScaleRangeMin();

Since that would simplify some of the queries to this interface.




Comment at: clang/include/clang/Basic/DiagnosticDriverKinds.td:597
+def err_cc1_unbounded_vscale_min : Error<
+  "minimum vscale cannot be unbounded (0)">;
 }

nit: `must be an unsigned integer than 0`



Comment at: clang/lib/Frontend/CompilerInvocation.cpp:4130
+  if (Arg *A = Args.getLastArg(options::OPT_mvscale_min_EQ)) {
+if (StringRef(A->getValue()).equals("0"))
+  Diags.Report(diag::err_cc1_unbounded_vscale_min);

I'd suggest parsing the value as an integer, and checking that it's > 1. See 
`StringRef::getAsInteger()`.



Comment at: llvm/docs/LangRef.rst:2137-2138
 This attribute indicates the minimum and maximum vscale value for the given
-function. A value of 0 means unbounded. If the optional max value is 
omitted
-then max is set to the value of min. If the attribute is not present, no
-assumptions are made about the range of vscale.
+function. A value of 0 means unbounded, only the max value can be
+unbounded. If the optional max value is omitted then max is set to the
+value of min. If the attribute is not present, no assumptions are made

A maximum value of 0 means unbounded.



I'd also add that `min` must be greater than 0.



Comment at: llvm/lib/IR/Verifier.cpp:2064
+if (Args.first == 0)
+  CheckFailed("'vscale_range' minimum cannot be unbounded", V);
+

must be greater than 0


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113294

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


[PATCH] D110036: [TargetInfo][LangOpts] Refactor target info and language options adjustment.

2021-11-08 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

Just to elaborate on the problem that is being solved. We have ended up with 
cycling dependencies between `LangOptions` and `TargetInfo` i.e. some language 
options became dependent on the target and vice versa.

The quick solution has always been to mutate the target after its creation even 
though it has been intended to be immutable. While mutating the target some 
language options are being modified too.

So the approach suggested here eliminates this design flaw by adding a special 
member to `LangOptions` to allow resetting the options after the target has 
been created based on the property of the target.

The approach seems reasonable to me and there are probably not so many good 
alternatives. In the past, we have discussed that adjusting target settings can 
be eliminated by adding a special triple component for OpenCL. However, it 
serves a similar purpose as suggested here but seems like a larger conceptual 
change and some redundancy too. I am also not sure whether it is going to fit 
the needs for OpenCL 3 features and also use cases from all other targets...

I would suggest writing an RFC into cfe-dev about this and see if there are any 
other opinions.

Thanks for looking into this long design issue.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110036

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


[PATCH] D110184: [OpenCL] Constructor address space test adjusted for C++ for OpenCL 2021

2021-11-08 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

Ping, @Topotuna do you still plan to commit this?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110184

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


[PATCH] D113397: [analyzer][docs] Fix the incorrect structure of the checker docs

2021-11-08 Thread Balázs Benics via Phabricator via cfe-commits
steakhal requested changes to this revision.
steakhal added a comment.
This revision now requires changes to proceed.

Hmm, something is still bad. F20158447: image.png 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113397

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


[PATCH] D113201: [clang-tidy] Fix a crash in modernize-loop-convert around conversion operators

2021-11-08 Thread Balázs Benics via Phabricator via cfe-commits
steakhal accepted this revision.
steakhal added a comment.
This revision is now accepted and ready to land.

Looks great.




Comment at: clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.cpp:155
 
-/// Look through conversion/copy constructors to find the explicit
+/// Look through conversion/copy constructors and operators to find the 
explicit
 /// initialization expression, returning it is found.

I think it's called //conversion member functions//.



Comment at: clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.h:278
 // General functions used by ForLoopIndexUseVisitor and LoopConvertCheck.
-const Expr *digThroughConstructors(const Expr *E);
+const Expr *digThroughConstructorsConversions(const Expr *E);
 bool areSameExpr(ASTContext *Context, const Expr *First, const Expr *Second);




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

https://reviews.llvm.org/D113201

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


[clang] a12bfac - [analyzer] Retrieve a value from list initialization of multi-dimensional array declaration.

2021-11-08 Thread Denys Petrov via cfe-commits

Author: Denys Petrov
Date: 2021-11-08T16:17:55+02:00
New Revision: a12bfac292db2195d3461dce51467d350de865dc

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

LOG: [analyzer] Retrieve a value from list initialization of multi-dimensional 
array declaration.

Summary: Add support of multi-dimensional arrays in 
`RegionStoreManager::getBindingForElement`. Handle nested ElementRegion's 
getting offsets and checking for being in bounds. Get values from the nested 
initialization lists using obtained offsets.

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

Added: 


Modified: 
clang/lib/StaticAnalyzer/Core/RegionStore.cpp
clang/test/Analysis/initialization.c
clang/test/Analysis/initialization.cpp

Removed: 




diff  --git a/clang/lib/StaticAnalyzer/Core/RegionStore.cpp 
b/clang/lib/StaticAnalyzer/Core/RegionStore.cpp
index 79d2fc76a42f..135130b35ba7 100644
--- a/clang/lib/StaticAnalyzer/Core/RegionStore.cpp
+++ b/clang/lib/StaticAnalyzer/Core/RegionStore.cpp
@@ -437,10 +437,13 @@ class RegionStoreManager : public StoreManager {
 
   RegionBindingsRef removeSubRegionBindings(RegionBindingsConstRef B,
 const SubRegion *R);
-  Optional getConstantValFromConstArrayInitializer(
-  RegionBindingsConstRef B, const VarRegion *VR, const ElementRegion *R);
-  Optional getSValFromInitListExpr(const InitListExpr *ILE,
- uint64_t Offset, QualType ElemT);
+  Optional
+  getConstantValFromConstArrayInitializer(RegionBindingsConstRef B,
+  const ElementRegion *R);
+  Optional
+  getSValFromInitListExpr(const InitListExpr *ILE,
+  const SmallVector &ConcreteOffsets,
+  QualType ElemT);
   SVal getSValFromStringLiteral(const StringLiteral *SL, uint64_t Offset,
 QualType ElemT);
 
@@ -1631,9 +1634,127 @@ 
RegionStoreManager::findLazyBinding(RegionBindingsConstRef B,
   return Result;
 }
 
+/// This is a helper function for `getConstantValFromConstArrayInitializer`.
+///
+/// Return an array of extents of the declared array type.
+///
+/// E.g. for `int x[1][2][3];` returns { 1, 2, 3 }.
+static SmallVector
+getConstantArrayExtents(const ConstantArrayType *CAT) {
+  assert(CAT && "ConstantArrayType should not be null");
+  CAT = cast(CAT->getCanonicalTypeInternal());
+  SmallVector Extents;
+  do {
+Extents.push_back(CAT->getSize().getZExtValue());
+  } while ((CAT = dyn_cast(CAT->getElementType(;
+  return Extents;
+}
+
+/// This is a helper function for `getConstantValFromConstArrayInitializer`.
+///
+/// Return an array of offsets from nested ElementRegions and a root base
+/// region. The array is never empty and a base region is never null.
+///
+/// E.g. for `Element{Element{Element{VarRegion},1},2},3}` returns { 3, 2, 1 }.
+/// This represents an access through indirection: `arr[1][2][3];`
+///
+/// \param ER The given (possibly nested) ElementRegion.
+///
+/// \note The result array is in the reverse order of indirection expression:
+/// arr[1][2][3] -> { 3, 2, 1 }. This helps to provide complexity O(n), where n
+/// is a number of indirections. It may not affect performance in real-life
+/// code, though.
+static std::pair, const MemRegion *>
+getElementRegionOffsetsWithBase(const ElementRegion *ER) {
+  assert(ER && "ConstantArrayType should not be null");
+  const MemRegion *Base;
+  SmallVector SValOffsets;
+  do {
+SValOffsets.push_back(ER->getIndex());
+Base = ER->getSuperRegion();
+ER = dyn_cast(Base);
+  } while (ER);
+  return {SValOffsets, Base};
+}
+
+/// This is a helper function for `getConstantValFromConstArrayInitializer`.
+///
+/// Convert array of offsets from `SVal` to `uint64_t` in consideration of
+/// respective array extents.
+/// \param SrcOffsets [in]   The array of offsets of type `SVal` in reversed
+///   order (expectedly received from `getElementRegionOffsetsWithBase`).
+/// \param ArrayExtents [in] The array of extents.
+/// \param DstOffsets [out]  The array of offsets of type `uint64_t`.
+/// \returns:
+/// - `None` for successful convertion.
+/// - `UndefinedVal` or `UnknownVal` otherwise. It's expected that this SVal
+///   will be returned as a suitable value of the access operation.
+///   which should be returned as a correct
+///
+/// \example:
+///   const int arr[10][20][30] = {}; // ArrayExtents { 10, 20, 30 }
+///   int x1 = arr[4][5][6]; // SrcOffsets { NonLoc(6), NonLoc(5), NonLoc(4) }
+///  // DstOffsets { 4, 5, 6 }
+///  // returns None
+///   int x2 = arr[42][5][-6]; // returns UndefinedVal
+///   int x3 = arr[4][5][x2];  // returns UnknownVal
+static Optional
+

[PATCH] D111654: [analyzer] Retrieve a value from list initialization of multi-dimensional array declaration.

2021-11-08 Thread Denys Petrov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa12bfac292db: [analyzer] Retrieve a value from list 
initialization of multi-dimensional array… (authored by ASDenysPetrov).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111654

Files:
  clang/lib/StaticAnalyzer/Core/RegionStore.cpp
  clang/test/Analysis/initialization.c
  clang/test/Analysis/initialization.cpp

Index: clang/test/Analysis/initialization.cpp
===
--- clang/test/Analysis/initialization.cpp
+++ clang/test/Analysis/initialization.cpp
@@ -14,13 +14,6 @@
   clang_analyzer_eval(sarr[i].a); // expected-warning{{UNKNOWN}}
 }
 
-int const arr[2][2] = {};
-void arr2init() {
-  int i = 1;
-  // FIXME: Should recognize that it is 0.
-  clang_analyzer_eval(arr[i][0]); // expected-warning{{UNKNOWN}}
-}
-
 int const glob_arr1[3] = {};
 void glob_array_index1() {
   clang_analyzer_eval(glob_arr1[0] == 0); // expected-warning{{TRUE}}
@@ -60,23 +53,18 @@
   return glob_arr3[0]; // no-warning (garbage or undefined)
 }
 
-// TODO: Support multidimensional array.
 int const glob_arr4[4][2] = {};
 void glob_array_index2() {
-  // FIXME: Should be TRUE.
-  clang_analyzer_eval(glob_arr4[1][0] == 0); // expected-warning{{UNKNOWN}}
-  // FIXME: Should be TRUE.
-  clang_analyzer_eval(glob_arr4[1][1] == 0); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(glob_arr4[0][0] == 0); // expected-warning{{TRUE}}
+  clang_analyzer_eval(glob_arr4[1][0] == 0); // expected-warning{{TRUE}}
+  clang_analyzer_eval(glob_arr4[1][1] == 0); // expected-warning{{TRUE}}
 }
 
-// TODO: Support multidimensional array.
 void glob_invalid_index3() {
   int idx = -42;
-  // FIXME: Should warn {{garbage or undefined}}.
-  auto x = glob_arr4[1][idx]; // no-warning
+  auto x = glob_arr4[1][idx]; // expected-warning{{garbage or undefined}}
 }
 
-// TODO: Support multidimensional array.
 void glob_invalid_index4() {
   const int *ptr = glob_arr4[1];
   int idx = -42;
@@ -84,28 +72,18 @@
   auto x = ptr[idx]; // no-warning
 }
 
-// TODO: Support multidimensional array.
 int const glob_arr5[4][2] = {{1}, 3, 4, 5};
 void glob_array_index3() {
-  // FIXME: Should be TRUE.
-  clang_analyzer_eval(glob_arr5[0][0] == 1); // expected-warning{{UNKNOWN}}
-  // FIXME: Should be TRUE.
-  clang_analyzer_eval(glob_arr5[0][1] == 0); // expected-warning{{UNKNOWN}}
-  // FIXME: Should be TRUE.
-  clang_analyzer_eval(glob_arr5[1][0] == 3); // expected-warning{{UNKNOWN}}
-  // FIXME: Should be TRUE.
-  clang_analyzer_eval(glob_arr5[1][1] == 4); // expected-warning{{UNKNOWN}}
-  // FIXME: Should be TRUE.
-  clang_analyzer_eval(glob_arr5[2][0] == 5); // expected-warning{{UNKNOWN}}
-  // FIXME: Should be TRUE.
-  clang_analyzer_eval(glob_arr5[2][1] == 0); // expected-warning{{UNKNOWN}}
-  // FIXME: Should be TRUE.
-  clang_analyzer_eval(glob_arr5[3][0] == 0); // expected-warning{{UNKNOWN}}
-  // FIXME: Should be TRUE.
-  clang_analyzer_eval(glob_arr5[3][1] == 0); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(glob_arr5[0][0] == 1); // expected-warning{{TRUE}}
+  clang_analyzer_eval(glob_arr5[0][1] == 0); // expected-warning{{TRUE}}
+  clang_analyzer_eval(glob_arr5[1][0] == 3); // expected-warning{{TRUE}}
+  clang_analyzer_eval(glob_arr5[1][1] == 4); // expected-warning{{TRUE}}
+  clang_analyzer_eval(glob_arr5[2][0] == 5); // expected-warning{{TRUE}}
+  clang_analyzer_eval(glob_arr5[2][1] == 0); // expected-warning{{TRUE}}
+  clang_analyzer_eval(glob_arr5[3][0] == 0); // expected-warning{{TRUE}}
+  clang_analyzer_eval(glob_arr5[3][1] == 0); // expected-warning{{TRUE}}
 }
 
-// TODO: Support multidimensional array.
 void glob_ptr_index2() {
   int const *ptr = glob_arr5[1];
   // FIXME: Should be TRUE.
@@ -120,19 +98,16 @@
   clang_analyzer_eval(ptr[4] == 0); // expected-warning{{UNKNOWN}}
 }
 
-// TODO: Support multidimensional array.
 void glob_invalid_index5() {
   int idx = -42;
-  // FIXME: Should warn {{garbage or undefined}}.
-  auto x = glob_arr5[1][idx]; // no-warning
+  auto x = glob_arr5[1][idx]; // expected-warning{{garbage or undefined}}
 }
 
-// TODO: Support multidimensional array.
 void glob_invalid_index6() {
   int const *ptr = &glob_arr5[1][0];
   int idx = 42;
   // FIXME: Should warn {{garbage or undefined}}.
-  auto x = ptr[idx]; // // no-warning
+  auto x = ptr[idx]; // no-warning
 }
 
 extern const int glob_arr_no_init[10];
@@ -253,3 +228,31 @@
   clang_analyzer_eval(glob_ptr12[2] == 'c');  // expected-warning{{TRUE}}
   clang_analyzer_eval(glob_ptr12[3] == '\0'); // expected-warning{{TRUE}}
 }
+
+typedef int Int;
+typedef Int const CInt;
+typedef CInt Arr[2];
+typedef Arr Arr2[4];
+Arr2 glob_arr8 = {{1}, 3, 4, 5}; // const int[4][2]
+void glob_array_typedef1() {
+  clang_analyzer_eval(glob_arr8[0][0] == 1); // expected-warning{{TRUE}}
+  clang_analyzer_eval(glob_arr8[0][1] == 0); // expected-warn

[PATCH] D113391: [Modules] Don't support clang module and c++20 module at the same time

2021-11-08 Thread Thorsten via Phabricator via cfe-commits
tschuett added a comment.

It would enforce that there is exactly module mode live.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113391

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


[PATCH] D110184: [OpenCL] Constructor address space test adjusted for C++ for OpenCL 2021

2021-11-08 Thread Justas Janickas via Phabricator via cfe-commits
Topotuna added a comment.

In D110184#3115361 , @Anastasia wrote:

> Ping, @Topotuna do you still plan to commit this?

Ah, yes. I will commit it in the next couple of days as well as D110155 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110184

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


[clang] c3b15b7 - [NFC] Inclusive Language: change master to main for .chm files

2021-11-08 Thread Quinn Pham via cfe-commits

Author: Quinn Pham
Date: 2021-11-08T08:23:04-06:00
New Revision: c3b15b71ce009b3dff9fb3bd664d087057b8376e

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

LOG: [NFC] Inclusive Language: change master to main for .chm files

[NFC] As part of using inclusive language within the llvm project,
this patch replaces master with main when referring to `.chm` files.

Reviewed By: teemperor

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

Added: 


Modified: 
clang-tools-extra/docs/doxygen.cfg.in
clang/docs/doxygen.cfg.in
flang/docs/doxygen.cfg.in
lldb/docs/doxygen.cfg.in
llvm/docs/doxygen.cfg.in
mlir/docs/doxygen.cfg.in
openmp/docs/doxygen.cfg.in
openmp/runtime/doc/doxygen/config
polly/docs/doxygen.cfg.in

Removed: 




diff  --git a/clang-tools-extra/docs/doxygen.cfg.in 
b/clang-tools-extra/docs/doxygen.cfg.in
index d778be30b63e..7e1d47a7a95a 100644
--- a/clang-tools-extra/docs/doxygen.cfg.in
+++ b/clang-tools-extra/docs/doxygen.cfg.in
@@ -1230,7 +1230,7 @@ CHM_FILE   =
 HHC_LOCATION   =
 
 # The GENERATE_CHI flag controls if a separate .chi index file is generated (
-# YES) or that it should be included in the master .chm file ( NO).
+# YES) or that it should be included in the main .chm file ( NO).
 # The default value is: NO.
 # This tag requires that the tag GENERATE_HTMLHELP is set to YES.
 

diff  --git a/clang/docs/doxygen.cfg.in b/clang/docs/doxygen.cfg.in
index 449552d99d46..39a346409b93 100644
--- a/clang/docs/doxygen.cfg.in
+++ b/clang/docs/doxygen.cfg.in
@@ -1219,7 +1219,7 @@ CHM_FILE   =
 HHC_LOCATION   =
 
 # The GENERATE_CHI flag controls if a separate .chi index file is generated (
-# YES) or that it should be included in the master .chm file ( NO).
+# YES) or that it should be included in the main .chm file ( NO).
 # The default value is: NO.
 # This tag requires that the tag GENERATE_HTMLHELP is set to YES.
 

diff  --git a/flang/docs/doxygen.cfg.in b/flang/docs/doxygen.cfg.in
index 7ede0b0a8b3b..6ee771c23d2b 100644
--- a/flang/docs/doxygen.cfg.in
+++ b/flang/docs/doxygen.cfg.in
@@ -1222,7 +1222,7 @@ CHM_FILE   =
 HHC_LOCATION   =
 
 # The GENERATE_CHI flag controls if a separate .chi index file is generated (
-# YES) or that it should be included in the master .chm file ( NO).
+# YES) or that it should be included in the main .chm file ( NO).
 # The default value is: NO.
 # This tag requires that the tag GENERATE_HTMLHELP is set to YES.
 

diff  --git a/lldb/docs/doxygen.cfg.in b/lldb/docs/doxygen.cfg.in
index 7750d89fd267..5712779e6b2c 100644
--- a/lldb/docs/doxygen.cfg.in
+++ b/lldb/docs/doxygen.cfg.in
@@ -916,7 +916,7 @@ HHC_LOCATION   =
 
 # If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag
 # controls if a separate .chi index file is generated (YES) or that
-# it should be included in the master .chm file (NO).
+# it should be included in the main .chm file (NO).
 
 GENERATE_CHI   = NO
 

diff  --git a/llvm/docs/doxygen.cfg.in b/llvm/docs/doxygen.cfg.in
index 7a6d531ad255..b19ca6d21580 100644
--- a/llvm/docs/doxygen.cfg.in
+++ b/llvm/docs/doxygen.cfg.in
@@ -1220,7 +1220,7 @@ CHM_FILE   =
 HHC_LOCATION   =
 
 # The GENERATE_CHI flag controls if a separate .chi index file is generated (
-# YES) or that it should be included in the master .chm file ( NO).
+# YES) or that it should be included in the main .chm file ( NO).
 # The default value is: NO.
 # This tag requires that the tag GENERATE_HTMLHELP is set to YES.
 

diff  --git a/mlir/docs/doxygen.cfg.in b/mlir/docs/doxygen.cfg.in
index 307981eed5f2..a0e4465c7dec 100644
--- a/mlir/docs/doxygen.cfg.in
+++ b/mlir/docs/doxygen.cfg.in
@@ -1220,7 +1220,7 @@ CHM_FILE   =
 HHC_LOCATION   =
 
 # The GENERATE_CHI flag controls if a separate .chi index file is generated (
-# YES) or that it should be included in the master .chm file ( NO).
+# YES) or that it should be included in the main .chm file ( NO).
 # The default value is: NO.
 # This tag requires that the tag GENERATE_HTMLHELP is set to YES.
 

diff  --git a/openmp/docs/doxygen.cfg.in b/openmp/docs/doxygen.cfg.in
index f02c70336040..f52c234da05d 100644
--- a/openmp/docs/doxygen.cfg.in
+++ b/openmp/docs/doxygen.cfg.in
@@ -1220,7 +1220,7 @@ CHM_FILE   =
 HHC_LOCATION   =
 
 # The GENERATE_CHI flag controls if a separate .chi index file is generated (
-# YES) or that it should be included in the master .chm file ( NO).
+# YES) or that it should be included in the main .chm file ( NO).
 # The default value is: NO.
 # This tag requires that the tag GENERATE_HTMLHELP is set to YES.
 

diff  --git a/openmp/runtime/doc/doxygen/config 
b/openmp/runtime/doc/doxygen/config
index cd1eca

[clang-tools-extra] c3b15b7 - [NFC] Inclusive Language: change master to main for .chm files

2021-11-08 Thread Quinn Pham via cfe-commits

Author: Quinn Pham
Date: 2021-11-08T08:23:04-06:00
New Revision: c3b15b71ce009b3dff9fb3bd664d087057b8376e

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

LOG: [NFC] Inclusive Language: change master to main for .chm files

[NFC] As part of using inclusive language within the llvm project,
this patch replaces master with main when referring to `.chm` files.

Reviewed By: teemperor

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

Added: 


Modified: 
clang-tools-extra/docs/doxygen.cfg.in
clang/docs/doxygen.cfg.in
flang/docs/doxygen.cfg.in
lldb/docs/doxygen.cfg.in
llvm/docs/doxygen.cfg.in
mlir/docs/doxygen.cfg.in
openmp/docs/doxygen.cfg.in
openmp/runtime/doc/doxygen/config
polly/docs/doxygen.cfg.in

Removed: 




diff  --git a/clang-tools-extra/docs/doxygen.cfg.in 
b/clang-tools-extra/docs/doxygen.cfg.in
index d778be30b63e..7e1d47a7a95a 100644
--- a/clang-tools-extra/docs/doxygen.cfg.in
+++ b/clang-tools-extra/docs/doxygen.cfg.in
@@ -1230,7 +1230,7 @@ CHM_FILE   =
 HHC_LOCATION   =
 
 # The GENERATE_CHI flag controls if a separate .chi index file is generated (
-# YES) or that it should be included in the master .chm file ( NO).
+# YES) or that it should be included in the main .chm file ( NO).
 # The default value is: NO.
 # This tag requires that the tag GENERATE_HTMLHELP is set to YES.
 

diff  --git a/clang/docs/doxygen.cfg.in b/clang/docs/doxygen.cfg.in
index 449552d99d46..39a346409b93 100644
--- a/clang/docs/doxygen.cfg.in
+++ b/clang/docs/doxygen.cfg.in
@@ -1219,7 +1219,7 @@ CHM_FILE   =
 HHC_LOCATION   =
 
 # The GENERATE_CHI flag controls if a separate .chi index file is generated (
-# YES) or that it should be included in the master .chm file ( NO).
+# YES) or that it should be included in the main .chm file ( NO).
 # The default value is: NO.
 # This tag requires that the tag GENERATE_HTMLHELP is set to YES.
 

diff  --git a/flang/docs/doxygen.cfg.in b/flang/docs/doxygen.cfg.in
index 7ede0b0a8b3b..6ee771c23d2b 100644
--- a/flang/docs/doxygen.cfg.in
+++ b/flang/docs/doxygen.cfg.in
@@ -1222,7 +1222,7 @@ CHM_FILE   =
 HHC_LOCATION   =
 
 # The GENERATE_CHI flag controls if a separate .chi index file is generated (
-# YES) or that it should be included in the master .chm file ( NO).
+# YES) or that it should be included in the main .chm file ( NO).
 # The default value is: NO.
 # This tag requires that the tag GENERATE_HTMLHELP is set to YES.
 

diff  --git a/lldb/docs/doxygen.cfg.in b/lldb/docs/doxygen.cfg.in
index 7750d89fd267..5712779e6b2c 100644
--- a/lldb/docs/doxygen.cfg.in
+++ b/lldb/docs/doxygen.cfg.in
@@ -916,7 +916,7 @@ HHC_LOCATION   =
 
 # If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag
 # controls if a separate .chi index file is generated (YES) or that
-# it should be included in the master .chm file (NO).
+# it should be included in the main .chm file (NO).
 
 GENERATE_CHI   = NO
 

diff  --git a/llvm/docs/doxygen.cfg.in b/llvm/docs/doxygen.cfg.in
index 7a6d531ad255..b19ca6d21580 100644
--- a/llvm/docs/doxygen.cfg.in
+++ b/llvm/docs/doxygen.cfg.in
@@ -1220,7 +1220,7 @@ CHM_FILE   =
 HHC_LOCATION   =
 
 # The GENERATE_CHI flag controls if a separate .chi index file is generated (
-# YES) or that it should be included in the master .chm file ( NO).
+# YES) or that it should be included in the main .chm file ( NO).
 # The default value is: NO.
 # This tag requires that the tag GENERATE_HTMLHELP is set to YES.
 

diff  --git a/mlir/docs/doxygen.cfg.in b/mlir/docs/doxygen.cfg.in
index 307981eed5f2..a0e4465c7dec 100644
--- a/mlir/docs/doxygen.cfg.in
+++ b/mlir/docs/doxygen.cfg.in
@@ -1220,7 +1220,7 @@ CHM_FILE   =
 HHC_LOCATION   =
 
 # The GENERATE_CHI flag controls if a separate .chi index file is generated (
-# YES) or that it should be included in the master .chm file ( NO).
+# YES) or that it should be included in the main .chm file ( NO).
 # The default value is: NO.
 # This tag requires that the tag GENERATE_HTMLHELP is set to YES.
 

diff  --git a/openmp/docs/doxygen.cfg.in b/openmp/docs/doxygen.cfg.in
index f02c70336040..f52c234da05d 100644
--- a/openmp/docs/doxygen.cfg.in
+++ b/openmp/docs/doxygen.cfg.in
@@ -1220,7 +1220,7 @@ CHM_FILE   =
 HHC_LOCATION   =
 
 # The GENERATE_CHI flag controls if a separate .chi index file is generated (
-# YES) or that it should be included in the master .chm file ( NO).
+# YES) or that it should be included in the main .chm file ( NO).
 # The default value is: NO.
 # This tag requires that the tag GENERATE_HTMLHELP is set to YES.
 

diff  --git a/openmp/runtime/doc/doxygen/config 
b/openmp/runtime/doc/doxygen/config
index cd1eca

[PATCH] D113189: [clang] Inclusive language: change instances of blacklist/whitelist to allowlist/ignorelist

2021-11-08 Thread Zarko Todorovski via Phabricator via cfe-commits
ZarkoCA updated this revision to Diff 385478.
ZarkoCA retitled this revision from "[clang] Inclusive language: change 
instances of blacklist/whitelist to allowlist/ignorelist " to "[clang] 
Inclusive language: change instances of blacklist/whitelist to 
allowlist/ignorelist".
ZarkoCA added a comment.

- Address review: reworded comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113189

Files:
  clang/include/clang/AST/CommentHTMLTags.td
  clang/include/clang/Basic/DiagnosticASTKinds.td
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/HeaderIncludeGen.cpp
  clang/test/CodeGen/sanitize-address-field-padding.cpp

Index: clang/test/CodeGen/sanitize-address-field-padding.cpp
===
--- clang/test/CodeGen/sanitize-address-field-padding.cpp
+++ clang/test/CodeGen/sanitize-address-field-padding.cpp
@@ -1,9 +1,9 @@
 // Test -fsanitize-address-field-padding
-// RUN: echo 'type:SomeNamespace::BlacklistedByName=field-padding' > %t.type.blacklist
-// RUN: echo 'src:*sanitize-address-field-padding.cpp=field-padding' > %t.file.blacklist
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsanitize=address -fsanitize-address-field-padding=1 -fsanitize-blacklist=%t.type.blacklist -Rsanitize-address -emit-llvm -o - %s 2>&1 | FileCheck %s
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsanitize=address -fsanitize-address-field-padding=1 -fsanitize-blacklist=%t.type.blacklist -Rsanitize-address -emit-llvm -o - %s -O1 -fno-experimental-new-pass-manager -mconstructor-aliases 2>&1 | FileCheck %s --check-prefix=WITH_CTOR_ALIASES
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsanitize=address -fsanitize-address-field-padding=1 -fsanitize-blacklist=%t.file.blacklist -Rsanitize-address -emit-llvm -o - %s 2>&1 | FileCheck %s --check-prefix=FILE_BLACKLIST
+// RUN: echo 'type:SomeNamespace::IgnorelistedByName=field-padding' > %t.type.ignorelist
+// RUN: echo 'src:*sanitize-address-field-padding.cpp=field-padding' > %t.file.ignorelist
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsanitize=address -fsanitize-address-field-padding=1 -fsanitize-ignorelist=%t.type.ignorelist -Rsanitize-address -emit-llvm -o - %s 2>&1 | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsanitize=address -fsanitize-address-field-padding=1 -fsanitize-ignorelist=%t.type.ignorelist -Rsanitize-address -emit-llvm -o - %s -O1 -fno-experimental-new-pass-manager -mconstructor-aliases 2>&1 | FileCheck %s --check-prefix=WITH_CTOR_ALIASES
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsanitize=address -fsanitize-address-field-padding=1 -fsanitize-ignorelist=%t.file.ignorelist -Rsanitize-address -emit-llvm -o - %s 2>&1 | FileCheck %s --check-prefix=FILE_IGNORELIST
 // RUN: %clang_cc1 -fsanitize=address -emit-llvm -o - %s 2>&1 | FileCheck %s --check-prefix=NO_PADDING
 // Try to emulate -save-temps option and make sure -disable-llvm-passes will not run sanitize instrumentation.
 // RUN: %clang_cc1 -fsanitize=address -emit-llvm -disable-llvm-passes -o - %s | %clang_cc1 -fsanitize=address -emit-llvm -o - -x ir | FileCheck %s --check-prefix=NO_PADDING
@@ -17,11 +17,11 @@
 // CHECK: -fsanitize-address-field-padding ignored for Negative3 because it is a union
 // CHECK: -fsanitize-address-field-padding ignored for Negative4 because it is trivially copyable
 // CHECK: -fsanitize-address-field-padding ignored for Negative5 because it is packed
-// CHECK: -fsanitize-address-field-padding ignored for SomeNamespace::BlacklistedByName because it is blacklisted
+// CHECK: -fsanitize-address-field-padding ignored for SomeNamespace::IgnorelistedByName because it is ignorelisted
 // CHECK: -fsanitize-address-field-padding ignored for ExternCStruct because it is not C++
 //
-// FILE_BLACKLIST: -fsanitize-address-field-padding ignored for Positive1 because it is in a blacklisted file
-// FILE_BLACKLIST-NOT: __asan_poison_intra_object_redzone
+// FILE_IGNORELIST: -fsanitize-address-field-padding ignored for Positive1 because it is in a ignorelisted file
+// FILE_IGNORELIST-NOT: __asan_poison_intra_object_redzone
 // NO_PADDING-NOT: __asan_poison_intra_object_redzone
 
 
@@ -141,10 +141,10 @@
 
 
 namespace SomeNamespace {
-class BlacklistedByName {
+class IgnorelistedByName {
  public:
-  BlacklistedByName() {}
-  ~BlacklistedByName() {}
+  IgnorelistedByName() {}
+  ~IgnorelistedByName() {}
   int make_it_non_standard_layout;
  private:
   char private1;
@@ -152,7 +152,7 @@
 };
 }  // SomeNamespace
 
-SomeNamespace::BlacklistedByName blacklisted_by_name;
+SomeNamespace::IgnorelistedByName ignorelisted_by_name;
 
 extern "C" {
 class ExternCStruct {
Index: clang/lib/Frontend/HeaderIncludeGen.cpp
===
--- clang/lib/Frontend/HeaderIncludeGen.cpp
+++ clang/lib/Frontend/HeaderIncludeGen.cpp
@@ -119,7 +119,7 @@
   // Print header in

[PATCH] D113189: [clang] Inclusive language: change instances of blacklist/whitelist to allowlist/ignorelist

2021-11-08 Thread Zarko Todorovski via Phabricator via cfe-commits
ZarkoCA updated this revision to Diff 385479.
ZarkoCA added a comment.

- Fix typo


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113189

Files:
  clang/include/clang/AST/CommentHTMLTags.td
  clang/include/clang/Basic/DiagnosticASTKinds.td
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/HeaderIncludeGen.cpp
  clang/test/CodeGen/sanitize-address-field-padding.cpp

Index: clang/test/CodeGen/sanitize-address-field-padding.cpp
===
--- clang/test/CodeGen/sanitize-address-field-padding.cpp
+++ clang/test/CodeGen/sanitize-address-field-padding.cpp
@@ -1,9 +1,9 @@
 // Test -fsanitize-address-field-padding
-// RUN: echo 'type:SomeNamespace::BlacklistedByName=field-padding' > %t.type.blacklist
-// RUN: echo 'src:*sanitize-address-field-padding.cpp=field-padding' > %t.file.blacklist
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsanitize=address -fsanitize-address-field-padding=1 -fsanitize-blacklist=%t.type.blacklist -Rsanitize-address -emit-llvm -o - %s 2>&1 | FileCheck %s
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsanitize=address -fsanitize-address-field-padding=1 -fsanitize-blacklist=%t.type.blacklist -Rsanitize-address -emit-llvm -o - %s -O1 -fno-experimental-new-pass-manager -mconstructor-aliases 2>&1 | FileCheck %s --check-prefix=WITH_CTOR_ALIASES
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsanitize=address -fsanitize-address-field-padding=1 -fsanitize-blacklist=%t.file.blacklist -Rsanitize-address -emit-llvm -o - %s 2>&1 | FileCheck %s --check-prefix=FILE_BLACKLIST
+// RUN: echo 'type:SomeNamespace::IgnorelistedByName=field-padding' > %t.type.ignorelist
+// RUN: echo 'src:*sanitize-address-field-padding.cpp=field-padding' > %t.file.ignorelist
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsanitize=address -fsanitize-address-field-padding=1 -fsanitize-ignorelist=%t.type.ignorelist -Rsanitize-address -emit-llvm -o - %s 2>&1 | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsanitize=address -fsanitize-address-field-padding=1 -fsanitize-ignorelist=%t.type.ignorelist -Rsanitize-address -emit-llvm -o - %s -O1 -fno-experimental-new-pass-manager -mconstructor-aliases 2>&1 | FileCheck %s --check-prefix=WITH_CTOR_ALIASES
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsanitize=address -fsanitize-address-field-padding=1 -fsanitize-ignorelist=%t.file.ignorelist -Rsanitize-address -emit-llvm -o - %s 2>&1 | FileCheck %s --check-prefix=FILE_IGNORELIST
 // RUN: %clang_cc1 -fsanitize=address -emit-llvm -o - %s 2>&1 | FileCheck %s --check-prefix=NO_PADDING
 // Try to emulate -save-temps option and make sure -disable-llvm-passes will not run sanitize instrumentation.
 // RUN: %clang_cc1 -fsanitize=address -emit-llvm -disable-llvm-passes -o - %s | %clang_cc1 -fsanitize=address -emit-llvm -o - -x ir | FileCheck %s --check-prefix=NO_PADDING
@@ -17,11 +17,11 @@
 // CHECK: -fsanitize-address-field-padding ignored for Negative3 because it is a union
 // CHECK: -fsanitize-address-field-padding ignored for Negative4 because it is trivially copyable
 // CHECK: -fsanitize-address-field-padding ignored for Negative5 because it is packed
-// CHECK: -fsanitize-address-field-padding ignored for SomeNamespace::BlacklistedByName because it is blacklisted
+// CHECK: -fsanitize-address-field-padding ignored for SomeNamespace::IgnorelistedByName because it is ignorelisted
 // CHECK: -fsanitize-address-field-padding ignored for ExternCStruct because it is not C++
 //
-// FILE_BLACKLIST: -fsanitize-address-field-padding ignored for Positive1 because it is in a blacklisted file
-// FILE_BLACKLIST-NOT: __asan_poison_intra_object_redzone
+// FILE_IGNORELIST: -fsanitize-address-field-padding ignored for Positive1 because it is in a ignorelisted file
+// FILE_IGNORELIST-NOT: __asan_poison_intra_object_redzone
 // NO_PADDING-NOT: __asan_poison_intra_object_redzone
 
 
@@ -141,10 +141,10 @@
 
 
 namespace SomeNamespace {
-class BlacklistedByName {
+class IgnorelistedByName {
  public:
-  BlacklistedByName() {}
-  ~BlacklistedByName() {}
+  IgnorelistedByName() {}
+  ~IgnorelistedByName() {}
   int make_it_non_standard_layout;
  private:
   char private1;
@@ -152,7 +152,7 @@
 };
 }  // SomeNamespace
 
-SomeNamespace::BlacklistedByName blacklisted_by_name;
+SomeNamespace::IgnorelistedByName ignorelisted_by_name;
 
 extern "C" {
 class ExternCStruct {
Index: clang/lib/Frontend/HeaderIncludeGen.cpp
===
--- clang/lib/Frontend/HeaderIncludeGen.cpp
+++ clang/lib/Frontend/HeaderIncludeGen.cpp
@@ -119,7 +119,7 @@
   // Print header info for extra headers, pretending they were discovered by
   // the regular preprocessor. The primary use case is to support proper
   // generation of Make / Ninja file dependencies for implicit includes, such
-  // as sanitizer blacklists. It's only import

[PATCH] D113168: [clang-tblgen] Fix non-determinism in generating AttrSubMatchRulesParserStringSwitches.inc

2021-11-08 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D113168#3114626 , @ikudrin wrote:

> We've noticed binary differences in `clang` in several builds on our local 
> build bots, and the patch fixed that.
>
> As for generating the documentation, the issue can be seen, for example, in 
> Clang-12 
>   
> and Clang-13 
>  
> documentation, where the section "Nullable Attributes" is placed differently. 
> Maybe it'll be better to sort the categories alphabetically. Anyway, that is 
> a similar but still a different issue.

FWIW, I consider the documentation issue to be more of a problem than the one 
being fixed here. The fix for this means code we generate will be generated in 
the same order every time, which has nice properties in terms of doing 
incremental builds, but is largely unimportant as far as users are concerned. 
The documentation is user facing, so there's more of a chance to notice 
positional changes there.

I'm happy enough with the changes, but please fix the other nondeterminism at 
the same time so that we don't have to play whack-a-mole in this file.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113168

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


[PATCH] D113397: [analyzer][docs] Fix the incorrect structure of the checker docs

2021-11-08 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus updated this revision to Diff 385481.
Szelethus added a comment.

Fix incorrect sectioning.


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

https://reviews.llvm.org/D113397

Files:
  clang/docs/analyzer/checkers.rst

Index: clang/docs/analyzer/checkers.rst
===
--- clang/docs/analyzer/checkers.rst
+++ clang/docs/analyzer/checkers.rst
@@ -2048,90 +2048,6 @@
 alpha.security
 ^^
 
-
-alpha.security.cert
-^^^
-
-SEI CERT checkers which tries to find errors based on their `C coding rules `_.
-
-.. _alpha-security-cert-pos-checkers:
-
-alpha.security.cert.pos
-^^^
-
-SEI CERT checkers of `POSIX C coding rules `_.
-
-.. _alpha-security-cert-pos-34c:
-
-alpha.security.cert.pos.34c
-"""
-Finds calls to the ``putenv`` function which pass a pointer to an automatic variable as the argument.
-
-.. code-block:: c
-
-  int func(const char *var) {
-char env[1024];
-int retval = snprintf(env, sizeof(env),"TEST=%s", var);
-if (retval < 0 || (size_t)retval >= sizeof(env)) {
-/* Handle error */
-}
-
-return putenv(env); // putenv function should not be called with auto variables
-  }
-
-alpha.security.cert.env
-^^^
-
-SEI CERT checkers of `POSIX C coding rules `_.
-
-.. _alpha-security-cert-env-InvalidPtr:
-
-alpha.security.cert.env.InvalidPtr
-"""
-
-Corresponds to SEI CERT Rules ENV31-C and ENV34-C.
-
-ENV31-C:
-Rule is about the possible problem with `main` function's third argument, environment pointer,
-"envp". When enviornment array is modified using some modification function
-such as putenv, setenv or others, It may happen that memory is reallocated,
-however "envp" is not updated to reflect the changes and points to old memory
-region.
-
-ENV34-C:
-Some functions return a pointer to a statically allocated buffer.
-Consequently, subsequent call of these functions will invalidate previous
-pointer. These functions include: getenv, localeconv, asctime, setlocale, strerror
-
-.. code-block:: c
-
-  int main(int argc, const char *argv[], const char *envp[]) {
-if (setenv("MY_NEW_VAR", "new_value", 1) != 0) {
-  // setenv call may invalidate 'envp'
-  /* Handle error */
-}
-if (envp != NULL) {
-  for (size_t i = 0; envp[i] != NULL; ++i) {
-puts(envp[i]);
-// envp may no longer point to the current environment
-// this program has unanticipated behavior, since envp
-// does not reflect changes made by setenv function.
-  }
-}
-return 0;
-  }
-
-  void previous_call_invalidation() {
-char *p, *pp;
-
-p = getenv("VAR");
-pp = getenv("VAR2");
-// subsequent call to 'getenv' invalidated previous one
-
-*p;
-// dereferencing invalid pointer
-  }
-
 .. _alpha-security-ArrayBound:
 
 alpha.security.ArrayBound (C)
@@ -2283,6 +2199,95 @@
return x; // warn: undefined or garbage returned
  }
 
+
+alpha.security.cert
+^^^
+
+SEI CERT checkers which tries to find errors based on their `C coding rules `_.
+
+.. _alpha-security-cert-pos-checkers:
+
+alpha.security.cert.pos
+^^^
+
+SEI CERT checkers of `POSIX C coding rules `_.
+
+.. _alpha-security-cert-pos-34c:
+
+alpha.security.cert.pos.34c
+"""
+Finds calls to the ``putenv`` function which pass a pointer to an automatic variable as the argument.
+
+.. code-block:: c
+
+  int func(const char *var) {
+char env[1024];
+int retval = snprintf(env, sizeof(env),"TEST=%s", var);
+if (retval < 0 || (size_t)retval >= sizeof(env)) {
+/* Handle error */
+}
+
+return putenv(env); // putenv function should not be called with auto variables
+  }
+
+alpha.security.cert.env
+^^^
+
+SEI CERT checkers of `Environment C coding rules `_.
+
+.. _alpha-security-cert-env-InvalidPtr:
+
+alpha.security.cert.env.InvalidPtr
+""
+
+Corresponds to SEI CERT Rules ENV31-C and ENV34-C.
+
+ENV31-C:
+Rule is about the possible problem with `main` function's third argument, environment pointer,
+"envp". When enviornment array is modified using some modification function
+such as putenv, setenv or others, It may happen that memory is reallocated,
+however "envp" is not updated to reflect the changes and points to old memory
+region.
+
+ENV34-C:
+Some functions return a pointer to a statically allocated buffer.
+Consequently, subsequent call of these functions will invalidate previous
+pointer. These functions in

[PATCH] D112041: [InferAddressSpaces] Support assumed addrspaces from addrspace predicates.

2021-11-08 Thread Michael Liao via Phabricator via cfe-commits
hliao updated this revision to Diff 385483.
hliao added a comment.

Rebase and kindly PING for review.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112041

Files:
  clang/test/CodeGen/thinlto-distributed-newpm.ll
  llvm/include/llvm/Analysis/AssumptionCache.h
  llvm/include/llvm/Analysis/TargetTransformInfo.h
  llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
  llvm/include/llvm/CodeGen/BasicTTIImpl.h
  llvm/include/llvm/Target/TargetMachine.h
  llvm/lib/Analysis/AssumptionCache.cpp
  llvm/lib/Analysis/TargetTransformInfo.cpp
  llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
  llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.h
  llvm/lib/Target/NVPTX/NVPTXTargetMachine.cpp
  llvm/lib/Target/NVPTX/NVPTXTargetMachine.h
  llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp
  llvm/test/Other/loop-pm-invalidation.ll
  llvm/test/Other/new-pass-manager.ll
  llvm/test/Other/new-pm-lto-defaults.ll
  llvm/test/Other/new-pm-thinlto-prelink-pgo-defaults.ll
  llvm/test/Transforms/InferAddressSpaces/AMDGPU/builtin-assumed-addrspace.ll
  llvm/test/Transforms/InferAddressSpaces/NVPTX/builtin-assumed-addrspace.ll
  llvm/test/Transforms/LoopRotate/pr35210.ll
  llvm/unittests/Analysis/AssumeBundleQueriesTest.cpp

Index: llvm/unittests/Analysis/AssumeBundleQueriesTest.cpp
===
--- llvm/unittests/Analysis/AssumeBundleQueriesTest.cpp
+++ llvm/unittests/Analysis/AssumeBundleQueriesTest.cpp
@@ -518,8 +518,7 @@
   BasicBlock::iterator First = F->begin()->begin();
   BasicBlock::iterator Second = F->begin()->begin();
   Second++;
-  AssumptionCacheTracker ACT;
-  AssumptionCache &AC = ACT.getAssumptionCache(*F);
+  AssumptionCache AC(*F);
   auto AR = AC.assumptionsFor(F->getArg(3));
   ASSERT_EQ(AR.size(), 0u);
   AR = AC.assumptionsFor(F->getArg(1));
Index: llvm/test/Transforms/LoopRotate/pr35210.ll
===
--- llvm/test/Transforms/LoopRotate/pr35210.ll
+++ llvm/test/Transforms/LoopRotate/pr35210.ll
@@ -11,11 +11,11 @@
 ; CHECK-NEXT: Running analysis: LoopAnalysis on f
 ; CHECK-NEXT: Running analysis: DominatorTreeAnalysis on f
 ; CHECK-NEXT: Running analysis: AssumptionAnalysis on f
+; CHECK-NEXT: Running analysis: TargetIRAnalysis on f
 ; CHECK-NEXT: Running pass: LCSSAPass on f
 ; CHECK-NEXT: Running analysis: AAManager on f
 ; CHECK-NEXT: Running analysis: TargetLibraryAnalysis on f
 ; CHECK-NEXT: Running analysis: ScalarEvolutionAnalysis on f
-; CHECK-NEXT: Running analysis: TargetIRAnalysis on f
 ; CHECK-NEXT: Running analysis: InnerAnalysisManagerProxy{{.*}} on f
 ; CHECK-NEXT: Running pass: LoopRotatePass on Loop at depth 1 containing: %bb,%bb4
 ; CHECK-NEXT: Folding loop latch bb4 into bb
@@ -29,12 +29,12 @@
 ; MSSA-NEXT: Running analysis: LoopAnalysis on f
 ; MSSA-NEXT: Running analysis: DominatorTreeAnalysis on f
 ; MSSA-NEXT: Running analysis: AssumptionAnalysis on f
+; MSSA-NEXT: Running analysis: TargetIRAnalysis on f
 ; MSSA-NEXT: Running pass: LCSSAPass on f
 ; MSSA-NEXT: Running analysis: MemorySSAAnalysis on f
 ; MSSA-NEXT: Running analysis: AAManager on f
 ; MSSA-NEXT: Running analysis: TargetLibraryAnalysis on f
 ; MSSA-NEXT: Running analysis: ScalarEvolutionAnalysis on f
-; MSSA-NEXT: Running analysis: TargetIRAnalysis on f
 ; MSSA-NEXT: Running analysis: InnerAnalysisManagerProxy{{.*}} on f
 ; MSSA-NEXT: Running pass: LoopRotatePass on Loop at depth 1 containing: %bb,%bb4
 ; MSSA-NEXT: Folding loop latch bb4 into bb
Index: llvm/test/Transforms/InferAddressSpaces/NVPTX/builtin-assumed-addrspace.ll
===
--- /dev/null
+++ llvm/test/Transforms/InferAddressSpaces/NVPTX/builtin-assumed-addrspace.ll
@@ -0,0 +1,107 @@
+; RUN: opt -S -mtriple=nvptx64-nvidia-cuda -infer-address-spaces -o - %s | FileCheck %s
+
+; CHECK-LABEL: @f0
+; CHECK: addrspacecast float* {{%.*}} to float addrspace(4)*
+; CHECK: getelementptr inbounds float, float addrspace(4)*
+; CHECK: load float, float addrspace(4)*
+define float @f0(float* %p) {
+entry:
+  %0 = bitcast float* %p to i8*
+  %1 = call i1 @llvm.nvvm.isspacep.const(i8* %0)
+  tail call void @llvm.assume(i1 %1)
+  %2 = tail call i32 @llvm.nvvm.read.ptx.sreg.tid.x()
+  %idxprom = zext i32 %2 to i64
+  %arrayidx = getelementptr inbounds float, float* %p, i64 %idxprom
+  %3 = load float, float* %arrayidx, align 4
+  ret float %3
+}
+
+; CHECK-LABEL: @f1
+; CHECK: addrspacecast float* {{%.*}} to float addrspace(1)*
+; CHECK: getelementptr inbounds float, float addrspace(1)*
+; CHECK: load float, float addrspace(1)*
+define float @f1(float* %p) {
+entry:
+  %0 = bitcast float* %p to i8*
+  %1 = call i1 @llvm.nvvm.isspacep.global(i8* %0)
+  tail call void @llvm.assume(i1 %1)
+  %2 = tail call i32 @llvm.nvvm.read.ptx.sreg.tid.x()
+  %idxprom = zext i32 %2 to i64
+  %arrayidx = getelementptr inbounds float, float* %p, i64 %id

[PATCH] D112707: [clangd] IncludeCleaner: Be more conservative in marking RecordDecl usage

2021-11-08 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev planned changes to this revision.
kbobyrev added a comment.

Will split the patch in two, as suggested.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112707

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


[clang] 2c37ae6 - [nfc] Refactor CGGPUBuiltin to help review D112680

2021-11-08 Thread Jon Chesterfield via cfe-commits

Author: Jon Chesterfield
Date: 2021-11-08T15:00:08Z
New Revision: 2c37ae6d14cf263724720f56fc34b4579a6e5c1c

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

LOG: [nfc] Refactor CGGPUBuiltin to help review D112680

Added: 


Modified: 
clang/lib/CodeGen/CGGPUBuiltin.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGGPUBuiltin.cpp 
b/clang/lib/CodeGen/CGGPUBuiltin.cpp
index afbebd070c05..43192c587e26 100644
--- a/clang/lib/CodeGen/CGGPUBuiltin.cpp
+++ b/clang/lib/CodeGen/CGGPUBuiltin.cpp
@@ -66,39 +66,22 @@ static llvm::Function *GetVprintfDeclaration(llvm::Module 
&M) {
 //
 // Note that by the time this function runs, E's args have already undergone 
the
 // standard C vararg promotion (short -> int, float -> double, etc.).
-RValue
-CodeGenFunction::EmitNVPTXDevicePrintfCallExpr(const CallExpr *E,
-   ReturnValueSlot ReturnValue) {
-  assert(getTarget().getTriple().isNVPTX());
-  assert(E->getBuiltinCallee() == Builtin::BIprintf);
-  assert(E->getNumArgs() >= 1); // printf always has at least one arg.
-
-  const llvm::DataLayout &DL = CGM.getDataLayout();
-  llvm::LLVMContext &Ctx = CGM.getLLVMContext();
-
-  CallArgList Args;
-  EmitCallArgs(Args,
-   E->getDirectCallee()->getType()->getAs(),
-   E->arguments(), E->getDirectCallee(),
-   /* ParamsToSkip = */ 0);
 
-  // We don't know how to emit non-scalar varargs.
-  if (llvm::any_of(llvm::drop_begin(Args), [&](const CallArg &A) {
-return !A.getRValue(*this).isScalar();
-  })) {
-CGM.ErrorUnsupported(E, "non-scalar arg to printf");
-return RValue::get(llvm::ConstantInt::get(IntTy, 0));
-  }
+namespace {
+llvm::Value *packArgsIntoNVPTXFormatBuffer(CodeGenFunction *CGF,
+   const CallArgList &Args) {
+  const llvm::DataLayout &DL = CGF->CGM.getDataLayout();
+  llvm::LLVMContext &Ctx = CGF->CGM.getLLVMContext();
+  CGBuilderTy &Builder = CGF->Builder;
 
   // Construct and fill the args buffer that we'll pass to vprintf.
-  llvm::Value *BufferPtr;
   if (Args.size() <= 1) {
 // If there are no args, pass a null pointer to vprintf.
-BufferPtr = llvm::ConstantPointerNull::get(llvm::Type::getInt8PtrTy(Ctx));
+return llvm::ConstantPointerNull::get(llvm::Type::getInt8PtrTy(Ctx));
   } else {
 llvm::SmallVector ArgTypes;
 for (unsigned I = 1, NumArgs = Args.size(); I < NumArgs; ++I)
-  ArgTypes.push_back(Args[I].getRValue(*this).getScalarVal()->getType());
+  ArgTypes.push_back(Args[I].getRValue(*CGF).getScalarVal()->getType());
 
 // Using llvm::StructType is correct only because printf doesn't accept
 // aggregates.  If we had to handle aggregates here, we'd have to manually
@@ -106,15 +89,40 @@ CodeGenFunction::EmitNVPTXDevicePrintfCallExpr(const 
CallExpr *E,
 // that the alignment of the llvm type was the same as the alignment of the
 // clang type.
 llvm::Type *AllocaTy = llvm::StructType::create(ArgTypes, "printf_args");
-llvm::Value *Alloca = CreateTempAlloca(AllocaTy);
+llvm::Value *Alloca = CGF->CreateTempAlloca(AllocaTy);
 
 for (unsigned I = 1, NumArgs = Args.size(); I < NumArgs; ++I) {
   llvm::Value *P = Builder.CreateStructGEP(AllocaTy, Alloca, I - 1);
-  llvm::Value *Arg = Args[I].getRValue(*this).getScalarVal();
+  llvm::Value *Arg = Args[I].getRValue(*CGF).getScalarVal();
   Builder.CreateAlignedStore(Arg, P, DL.getPrefTypeAlign(Arg->getType()));
 }
-BufferPtr = Builder.CreatePointerCast(Alloca, 
llvm::Type::getInt8PtrTy(Ctx));
+return Builder.CreatePointerCast(Alloca, llvm::Type::getInt8PtrTy(Ctx));
   }
+}
+} // namespace
+
+RValue
+CodeGenFunction::EmitNVPTXDevicePrintfCallExpr(const CallExpr *E,
+   ReturnValueSlot ReturnValue) {
+  assert(getTarget().getTriple().isNVPTX());
+  assert(E->getBuiltinCallee() == Builtin::BIprintf);
+  assert(E->getNumArgs() >= 1); // printf always has at least one arg.
+
+  CallArgList Args;
+  EmitCallArgs(Args,
+   E->getDirectCallee()->getType()->getAs(),
+   E->arguments(), E->getDirectCallee(),
+   /* ParamsToSkip = */ 0);
+
+  // We don't know how to emit non-scalar varargs.
+  if (llvm::any_of(llvm::drop_begin(Args), [&](const CallArg &A) {
+return !A.getRValue(*this).isScalar();
+  })) {
+CGM.ErrorUnsupported(E, "non-scalar arg to printf");
+return RValue::get(llvm::ConstantInt::get(IntTy, 0));
+  }
+
+  llvm::Value *BufferPtr = packArgsIntoNVPTXFormatBuffer(this, Args);
 
   // Invoke vprintf and return.
   llvm::Function* VprintfFunc = GetVprintfDeclaration(CGM.getModule());



___
cfe-commits mai

[PATCH] D113397: [analyzer][docs] Fix the incorrect structure of the checker docs

2021-11-08 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus updated this revision to Diff 385486.
Szelethus added a comment.

Add context.


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

https://reviews.llvm.org/D113397

Files:
  clang/docs/analyzer/checkers.rst

Index: clang/docs/analyzer/checkers.rst
===
--- clang/docs/analyzer/checkers.rst
+++ clang/docs/analyzer/checkers.rst
@@ -2048,90 +2048,6 @@
 alpha.security
 ^^
 
-
-alpha.security.cert
-^^^
-
-SEI CERT checkers which tries to find errors based on their `C coding rules `_.
-
-.. _alpha-security-cert-pos-checkers:
-
-alpha.security.cert.pos
-^^^
-
-SEI CERT checkers of `POSIX C coding rules `_.
-
-.. _alpha-security-cert-pos-34c:
-
-alpha.security.cert.pos.34c
-"""
-Finds calls to the ``putenv`` function which pass a pointer to an automatic variable as the argument.
-
-.. code-block:: c
-
-  int func(const char *var) {
-char env[1024];
-int retval = snprintf(env, sizeof(env),"TEST=%s", var);
-if (retval < 0 || (size_t)retval >= sizeof(env)) {
-/* Handle error */
-}
-
-return putenv(env); // putenv function should not be called with auto variables
-  }
-
-alpha.security.cert.env
-^^^
-
-SEI CERT checkers of `POSIX C coding rules `_.
-
-.. _alpha-security-cert-env-InvalidPtr:
-
-alpha.security.cert.env.InvalidPtr
-"""
-
-Corresponds to SEI CERT Rules ENV31-C and ENV34-C.
-
-ENV31-C:
-Rule is about the possible problem with `main` function's third argument, environment pointer,
-"envp". When enviornment array is modified using some modification function
-such as putenv, setenv or others, It may happen that memory is reallocated,
-however "envp" is not updated to reflect the changes and points to old memory
-region.
-
-ENV34-C:
-Some functions return a pointer to a statically allocated buffer.
-Consequently, subsequent call of these functions will invalidate previous
-pointer. These functions include: getenv, localeconv, asctime, setlocale, strerror
-
-.. code-block:: c
-
-  int main(int argc, const char *argv[], const char *envp[]) {
-if (setenv("MY_NEW_VAR", "new_value", 1) != 0) {
-  // setenv call may invalidate 'envp'
-  /* Handle error */
-}
-if (envp != NULL) {
-  for (size_t i = 0; envp[i] != NULL; ++i) {
-puts(envp[i]);
-// envp may no longer point to the current environment
-// this program has unanticipated behavior, since envp
-// does not reflect changes made by setenv function.
-  }
-}
-return 0;
-  }
-
-  void previous_call_invalidation() {
-char *p, *pp;
-
-p = getenv("VAR");
-pp = getenv("VAR2");
-// subsequent call to 'getenv' invalidated previous one
-
-*p;
-// dereferencing invalid pointer
-  }
-
 .. _alpha-security-ArrayBound:
 
 alpha.security.ArrayBound (C)
@@ -2283,6 +2199,95 @@
return x; // warn: undefined or garbage returned
  }
 
+
+alpha.security.cert
+^^^
+
+SEI CERT checkers which tries to find errors based on their `C coding rules `_.
+
+.. _alpha-security-cert-pos-checkers:
+
+alpha.security.cert.pos
+^^^
+
+SEI CERT checkers of `POSIX C coding rules `_.
+
+.. _alpha-security-cert-pos-34c:
+
+alpha.security.cert.pos.34c
+"""
+Finds calls to the ``putenv`` function which pass a pointer to an automatic variable as the argument.
+
+.. code-block:: c
+
+  int func(const char *var) {
+char env[1024];
+int retval = snprintf(env, sizeof(env),"TEST=%s", var);
+if (retval < 0 || (size_t)retval >= sizeof(env)) {
+/* Handle error */
+}
+
+return putenv(env); // putenv function should not be called with auto variables
+  }
+
+alpha.security.cert.env
+^^^
+
+SEI CERT checkers of `Environment C coding rules `_.
+
+.. _alpha-security-cert-env-InvalidPtr:
+
+alpha.security.cert.env.InvalidPtr
+""
+
+Corresponds to SEI CERT Rules ENV31-C and ENV34-C.
+
+ENV31-C:
+Rule is about the possible problem with `main` function's third argument, environment pointer,
+"envp". When enviornment array is modified using some modification function
+such as putenv, setenv or others, It may happen that memory is reallocated,
+however "envp" is not updated to reflect the changes and points to old memory
+region.
+
+ENV34-C:
+Some functions return a pointer to a statically allocated buffer.
+Consequently, subsequent call of these functions will invalidate previous
+pointer. These functions include: getenv

[PATCH] D113195: [clang-tidy] Add check for initialization of `absl::Cleanup`.

2021-11-08 Thread CJ Johnson via Phabricator via cfe-commits
CJ-Johnson marked 4 inline comments as done.
CJ-Johnson added a comment.

Thanks for the review! I'll apply the same fixes to the string_view diff as well


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113195

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


[PATCH] D113195: [clang-tidy] Add check for initialization of `absl::Cleanup`.

2021-11-08 Thread CJ Johnson via Phabricator via cfe-commits
CJ-Johnson updated this revision to Diff 385487.
CJ-Johnson added a comment.

Address nits and update the absl::Cleanup stub to be accurate with the real 
interface (with associated changes to the AST matcher)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113195

Files:
  clang-tools-extra/clang-tidy/abseil/AbseilTidyModule.cpp
  clang-tools-extra/clang-tidy/abseil/CMakeLists.txt
  clang-tools-extra/clang-tidy/abseil/CleanupCtadCheck.cpp
  clang-tools-extra/clang-tidy/abseil/CleanupCtadCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/abseil-cleanup-ctad.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/test/clang-tidy/checkers/abseil-cleanup-ctad.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/abseil-cleanup-ctad.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/abseil-cleanup-ctad.cpp
@@ -0,0 +1,115 @@
+// RUN: %check_clang_tidy %s abseil-cleanup-ctad -std=c++17 %t
+
+namespace std {
+
+template 
+struct is_same {
+  static const bool value = false;
+};
+
+template 
+struct is_same { static const bool value = true; };
+
+template 
+class function {
+public:
+  template 
+  function(T) {}
+  function(const function &) {}
+};
+
+} // namespace std
+
+namespace absl {
+
+namespace cleanup_internal {
+
+struct Tag {};
+
+template 
+class Storage {
+public:
+  Storage() = delete;
+
+  explicit Storage(Callback callback) {}
+
+  Storage(Storage &&other) {}
+
+  Storage(const Storage &other) = delete;
+
+  Storage &operator=(Storage &&other) = delete;
+
+  Storage &operator=(const Storage &other) = delete;
+
+private:
+  bool is_callback_engaged_;
+  alignas(Callback) char callback_buffer_[sizeof(Callback)];
+};
+
+} // namespace cleanup_internal
+
+template 
+class Cleanup final {
+public:
+  Cleanup(Callback callback) // NOLINT
+  : storage_(static_cast(callback)) {}
+
+  Cleanup(Cleanup &&other) = default;
+
+  void Cancel() &&;
+
+  void Invoke() &&;
+
+  ~Cleanup();
+
+private:
+  cleanup_internal::Storage storage_;
+};
+
+template 
+Cleanup(Callback callback) -> Cleanup;
+
+template 
+absl::Cleanup MakeCleanup(Callback callback) {
+  return {static_cast(callback)};
+}
+
+} // namespace absl
+
+void test() {
+  auto a = absl::MakeCleanup([] {});
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: prefer absl::Cleanup's class template argument deduction pattern in C++17 and higher
+  // CHECK-FIXES: {{^}}  absl::Cleanup a = [] {};{{$}}
+
+  // Removes extra parens
+  auto b = absl::MakeCleanup(([] {}));
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: prefer absl::Cleanup{{.*}}C++17 and higher
+  // CHECK-FIXES: {{^}}  absl::Cleanup b = [] {};{{$}}
+
+  auto c = absl::MakeCleanup(std::function([] {}));
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: prefer absl::Cleanup{{.*}}C++17 and higher
+  // CHECK-FIXES: {{^}}  absl::Cleanup c = std::function([] {});{{$}}
+
+  // Removes extra parens
+  auto d = absl::MakeCleanup((std::function([] {})));
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: prefer absl::Cleanup{{.*}}C++17 and higher
+  // CHECK-FIXES: {{^}}  absl::Cleanup d = std::function([] {});{{$}}
+
+  const auto e = absl::MakeCleanup([] {});
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: prefer absl::Cleanup{{.*}}C++17 and higher
+  // CHECK-FIXES: {{^}}  const absl::Cleanup e = [] {};{{$}}
+
+  // Removes extra parens
+  const auto f = absl::MakeCleanup(([] {}));
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: prefer absl::Cleanup{{.*}}C++17 and higher
+  // CHECK-FIXES: {{^}}  const absl::Cleanup f = [] {};{{$}}
+
+  const auto g = absl::MakeCleanup(std::function([] {}));
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: prefer absl::Cleanup{{.*}}C++17 and higher
+  // CHECK-FIXES: {{^}}  const absl::Cleanup g = std::function([] {});{{$}}
+
+  // Removes extra parens
+  const auto h = absl::MakeCleanup((std::function([] {})));
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: prefer absl::Cleanup{{.*}}C++17 and higher
+  // CHECK-FIXES: {{^}}  const absl::Cleanup h = std::function([] {});{{$}}
+}
Index: clang-tools-extra/docs/clang-tidy/checks/list.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/list.rst
+++ clang-tools-extra/docs/clang-tidy/checks/list.rst
@@ -12,6 +12,7 @@
 .. csv-table::
:header: "Name", "Offers fixes"
 
+   `abseil-cleanup-ctad `_, "Yes"
`abseil-duration-addition `_, "Yes"
`abseil-duration-comparison `_, "Yes"
`abseil-duration-conversion-cast `_, "Yes"
@@ -448,3 +449,4 @@
`hicpp-vararg `_, `cppcoreguidelines-pro-type-vararg `_,
`llvm-else-after-return `_, `readability-else-after-return `_, "Yes"
`llvm-qualified-auto `_, `readability-qualified-auto `_, "Yes"
+   
\ No newline at end of file
Index: clang-tools-extra/docs/clang-tidy/checks/abseil-cleanup-c

[PATCH] D113397: [analyzer][docs] Fix the incorrect structure of the checker docs

2021-11-08 Thread Balázs Benics via Phabricator via cfe-commits
steakhal accepted this revision.
steakhal added a comment.
This revision is now accepted and ready to land.

Looks great. Thanks.


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

https://reviews.llvm.org/D113397

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


[PATCH] D113195: [clang-tidy] Add check for initialization of `absl::Cleanup`.

2021-11-08 Thread CJ Johnson via Phabricator via cfe-commits
CJ-Johnson updated this revision to Diff 385489.
CJ-Johnson added a comment.

Fix documentation nit


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113195

Files:
  clang-tools-extra/clang-tidy/abseil/AbseilTidyModule.cpp
  clang-tools-extra/clang-tidy/abseil/CMakeLists.txt
  clang-tools-extra/clang-tidy/abseil/CleanupCtadCheck.cpp
  clang-tools-extra/clang-tidy/abseil/CleanupCtadCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/abseil-cleanup-ctad.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/test/clang-tidy/checkers/abseil-cleanup-ctad.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/abseil-cleanup-ctad.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/abseil-cleanup-ctad.cpp
@@ -0,0 +1,115 @@
+// RUN: %check_clang_tidy %s abseil-cleanup-ctad -std=c++17 %t
+
+namespace std {
+
+template 
+struct is_same {
+  static const bool value = false;
+};
+
+template 
+struct is_same { static const bool value = true; };
+
+template 
+class function {
+public:
+  template 
+  function(T) {}
+  function(const function &) {}
+};
+
+} // namespace std
+
+namespace absl {
+
+namespace cleanup_internal {
+
+struct Tag {};
+
+template 
+class Storage {
+public:
+  Storage() = delete;
+
+  explicit Storage(Callback callback) {}
+
+  Storage(Storage &&other) {}
+
+  Storage(const Storage &other) = delete;
+
+  Storage &operator=(Storage &&other) = delete;
+
+  Storage &operator=(const Storage &other) = delete;
+
+private:
+  bool is_callback_engaged_;
+  alignas(Callback) char callback_buffer_[sizeof(Callback)];
+};
+
+} // namespace cleanup_internal
+
+template 
+class Cleanup final {
+public:
+  Cleanup(Callback callback) // NOLINT
+  : storage_(static_cast(callback)) {}
+
+  Cleanup(Cleanup &&other) = default;
+
+  void Cancel() &&;
+
+  void Invoke() &&;
+
+  ~Cleanup();
+
+private:
+  cleanup_internal::Storage storage_;
+};
+
+template 
+Cleanup(Callback callback) -> Cleanup;
+
+template 
+absl::Cleanup MakeCleanup(Callback callback) {
+  return {static_cast(callback)};
+}
+
+} // namespace absl
+
+void test() {
+  auto a = absl::MakeCleanup([] {});
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: prefer absl::Cleanup's class template argument deduction pattern in C++17 and higher
+  // CHECK-FIXES: {{^}}  absl::Cleanup a = [] {};{{$}}
+
+  // Removes extra parens
+  auto b = absl::MakeCleanup(([] {}));
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: prefer absl::Cleanup{{.*}}C++17 and higher
+  // CHECK-FIXES: {{^}}  absl::Cleanup b = [] {};{{$}}
+
+  auto c = absl::MakeCleanup(std::function([] {}));
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: prefer absl::Cleanup{{.*}}C++17 and higher
+  // CHECK-FIXES: {{^}}  absl::Cleanup c = std::function([] {});{{$}}
+
+  // Removes extra parens
+  auto d = absl::MakeCleanup((std::function([] {})));
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: prefer absl::Cleanup{{.*}}C++17 and higher
+  // CHECK-FIXES: {{^}}  absl::Cleanup d = std::function([] {});{{$}}
+
+  const auto e = absl::MakeCleanup([] {});
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: prefer absl::Cleanup{{.*}}C++17 and higher
+  // CHECK-FIXES: {{^}}  const absl::Cleanup e = [] {};{{$}}
+
+  // Removes extra parens
+  const auto f = absl::MakeCleanup(([] {}));
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: prefer absl::Cleanup{{.*}}C++17 and higher
+  // CHECK-FIXES: {{^}}  const absl::Cleanup f = [] {};{{$}}
+
+  const auto g = absl::MakeCleanup(std::function([] {}));
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: prefer absl::Cleanup{{.*}}C++17 and higher
+  // CHECK-FIXES: {{^}}  const absl::Cleanup g = std::function([] {});{{$}}
+
+  // Removes extra parens
+  const auto h = absl::MakeCleanup((std::function([] {})));
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: prefer absl::Cleanup{{.*}}C++17 and higher
+  // CHECK-FIXES: {{^}}  const absl::Cleanup h = std::function([] {});{{$}}
+}
Index: clang-tools-extra/docs/clang-tidy/checks/list.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/list.rst
+++ clang-tools-extra/docs/clang-tidy/checks/list.rst
@@ -12,6 +12,7 @@
 .. csv-table::
:header: "Name", "Offers fixes"
 
+   `abseil-cleanup-ctad `_, "Yes"
`abseil-duration-addition `_, "Yes"
`abseil-duration-comparison `_, "Yes"
`abseil-duration-conversion-cast `_, "Yes"
@@ -448,3 +449,4 @@
`hicpp-vararg `_, `cppcoreguidelines-pro-type-vararg `_,
`llvm-else-after-return `_, `readability-else-after-return `_, "Yes"
`llvm-qualified-auto `_, `readability-qualified-auto `_, "Yes"
+   
\ No newline at end of file
Index: clang-tools-extra/docs/clang-tidy/checks/abseil-cleanup-ctad.rst
===
--- /dev/null
+++ clang-tools-extr

RE: [PATCH] D112577: [clang][OpenMP] Initial parsing/sema for 'align' clause

2021-11-08 Thread Pagan, David via cfe-commits
Thanks, Aaron. I'll check this out.

-Original Message-
From: Aaron Ballman via Phabricator  
Sent: Monday, November 8, 2021 3:48 AM
To: Pagan, David ; a.bat...@hotmail.com; 
jdoerf...@anl.gov
Cc: stefomeis...@gmail.com; cfe-commits@lists.llvm.org; 
llvm-comm...@lists.llvm.org; yaxun@amd.com; zhang.guans...@gmail.com; 
arpha...@gmail.com; bhuvanendra.kum...@amd.com; Mu, Yanliang 
; dougp...@gmail.com; mlek...@skidmore.edu; 
blitzrak...@gmail.com; shen...@google.com; michael.hl...@gmail.com; 
david.gr...@arm.com; ruiling.s...@amd.com
Subject: [PATCH] D112577: [clang][OpenMP] Initial parsing/sema for 'align' 
clause

aaron.ballman added a comment.

Before I land this, it looks like precommit CI is failing with what possibly is 
a related failure:

  [9094/9117] Linking CXX executable 
tools/flang/unittests/Frontend/FlangFrontendTests
  FAILED: tools/flang/unittests/Frontend/FlangFrontendTests
  : && /usr/bin/clang++ -gmlt -fPIC -fvisibility-inlines-hidden 
-Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra 
-Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers 
-pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough 
-Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor 
-Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion 
-Wmisleading-indentation -fdiagnostics-color -ffunction-sections 
-fdata-sections -Wno-deprecated-copy -Wno-string-conversion 
-Wno-unused-command-line-argument -Wstring-conversion   
-Wcovered-switch-default -Wno-nested-anon-types -O3 -DNDEBUG -fuse-ld=lld 
-Wl,--color-diagnostics-Wl,-O3 -Wl,--gc-sections 
tools/flang/unittests/Frontend/CMakeFiles/FlangFrontendTests.dir/CompilerInstanceTest.cpp.o
 
tools/flang/unittests/Frontend/CMakeFiles/FlangFrontendTests.dir/FrontendActionTest.cpp.o
 -o tools/flang/unittests/Frontend/FlangFrontendTests  lib/libLLVMSupport.a  
-lpthread  lib/libgtest_main.a  lib/libgtest.a  -lpthread  lib/libclangBasic.a  
lib/libflangFrontend.a  lib/libflangFrontendTool.a  lib/libFortranParser.a  
lib/libFortranSemantics.a  lib/libFortranCommon.a  lib/libFortranEvaluate.a  
-lpthread  lib/libflangFrontend.a  lib/libFortranLower.a  
lib/libFortranSemantics.a  lib/libFortranEvaluate.a  lib/libFortranParser.a  
lib/libFortranCommon.a  lib/libFortranDecimal.a  lib/libFIRTransforms.a  
lib/libFIRDialect.a  lib/libMLIROpenMPToLLVM.a  lib/libMLIRMemRefToLLVM.a  
lib/libFIRSupport.a  lib/libMLIROpenMPToLLVMIRTranslation.a  
lib/libMLIRAffineTransforms.a  lib/libMLIRAsyncTransforms.a  lib/libMLIREmitC.a 
 lib/libMLIRGPUTransforms.a  lib/libMLIRAsync.a  lib/libMLIRGPUOps.a  
lib/libMLIRDLTI.a  lib/libMLIRLLVMToLLVMIRTranslation.a  
lib/libLLVMNVPTXCodeGen.a  lib/libLLVMNVPTXDesc.a  lib/libLLVMNVPTXInfo.a  
lib/libLLVMAMDGPUAsmParser.a  lib/libLLVMAMDGPUCodeGen.a  
lib/libLLVMAsmPrinter.a  lib/libLLVMDebugInfoDWARF.a  lib/libLLVMDebugInfoMSF.a 
 lib/libLLVMPasses.a  lib/libLLVMCoroutines.a  lib/libLLVMipo.a  
lib/libLLVMVectorize.a  lib/libLLVMIRReader.a  lib/libLLVMLinker.a  
lib/libLLVMInstrumentation.a  lib/libLLVMObjCARCOpts.a  lib/libLLVMGlobalISel.a 
 lib/libLLVMSelectionDAG.a  lib/libLLVMMIRParser.a  lib/libLLVMCodeGen.a  
lib/libLLVMTarget.a  lib/libLLVMAMDGPUDesc.a  lib/libLLVMAMDGPUUtils.a  
lib/libLLVMAMDGPUInfo.a  lib/libMLIRNVVMIR.a  lib/libMLIRROCDLIR.a  
lib/libMLIRVectorToLLVM.a  lib/libMLIRArmNeon.a  lib/libMLIRArmSVETransforms.a  
lib/libMLIRArmSVE.a  lib/libMLIRAMXTransforms.a  lib/libMLIRAMX.a  
lib/libMLIRTargetLLVMIRExport.a  lib/libMLIRLLVMIRTransforms.a  
lib/libMLIRTranslation.a  lib/libMLIRMathTransforms.a  
lib/libMLIRMemRefTransforms.a  lib/libMLIROpenACC.a  lib/libMLIROpenMP.a  
lib/libMLIRShapeOpsTransforms.a  lib/libMLIRShape.a  
lib/libMLIRSparseTensorTransforms.a  lib/libMLIRLinalgTransforms.a  
lib/libMLIRComplex.a  lib/libMLIRLinalgAnalysis.a  
lib/libMLIRComprehensiveBufferize.a  lib/libMLIRBufferizableOpInterface.a  
lib/libMLIRLinalgUtils.a  lib/libMLIRSCFTransforms.a  
lib/libMLIRStandardToLLVM.a  lib/libMLIRArithmeticToLLVM.a  
lib/libMLIRVectorToSCF.a  lib/libMLIRSparseTensor.a  
lib/libMLIRSparseTensorUtils.a  lib/libMLIRSPIRVModuleCombiner.a  
lib/libMLIRSPIRVTransforms.a  lib/libMLIRSPIRVConversion.a  
lib/libMLIRSPIRVUtils.a  lib/libMLIRSPIRV.a  lib/libMLIRStandardOpsTransforms.a 
 lib/libMLIRArithmeticTransforms.a  lib/libMLIRTensorTransforms.a  
lib/libMLIRTosaTransforms.a  lib/libMLIRX86VectorTransforms.a  
lib/libMLIRX86Vector.a  lib/libMLIRLLVMCommonConversion.a  lib/libMLIRLLVMIR.a  
lib/libLLVMAsmParser.a  lib/libLLVMBitWriter.a  lib/libMLIRTosaTestPasses.a  
lib/libMLIRTosa.a  lib/libMLIRQuant.a  lib/libMLIRAffineToStandard.a  
lib/libMLIRSCFToStandard.a  lib/libMLIRTransforms.a  lib/libMLIRVector.a  
lib/libMLIRAffineUtils.a  lib/libMLIRLinalg.a  lib/libMLIRMath.a  
lib/libMLIRParser.a  lib/libMLIRTilingInterface.a  lib/libMLIRTransformUtils.a  
lib/libMLIRLoopAnalysis.a  lib/libMLIRAffine.a  lib/libMLIRSCF.a  
lib/libMLIR

[PATCH] D112680: [OpenMP] Lower printf to __llvm_omp_vprintf

2021-11-08 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert accepted this revision.
jdoerfert added a comment.
This revision is now accepted and ready to land.

LG, one nit.




Comment at: clang/lib/CodeGen/CGGPUBuiltin.cpp:231
+  VprintfFunc, {Args[0].getRValue(*this).getScalarVal(), BufferPtr, 
Size}));
+}

Suggestion: I feel this could be in a helper to avoid the duplication with the 
nvptx version. All but the extra argument is the same, no?



Comment at: openmp/libomptarget/DeviceRTL/src/Debug.cpp:61
+}
 }
 

Namespace above should include _OMP, be anonymous or the functions should be 
static.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112680

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


[PATCH] D113148: Add new clang-tidy check for string_view(nullptr)

2021-11-08 Thread CJ Johnson via Phabricator via cfe-commits
CJ-Johnson updated this revision to Diff 385495.
CJ-Johnson added a comment.

Update test file to use truncated messages


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113148

Files:
  clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
  clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
  clang-tools-extra/clang-tidy/bugprone/StringviewNullptrCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/StringviewNullptrCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/bugprone-stringview-nullptr.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/test/clang-tidy/checkers/bugprone-stringview-nullptr.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-stringview-nullptr.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-stringview-nullptr.cpp
@@ -0,0 +1,1030 @@
+// RUN: %check_clang_tidy %s bugprone-stringview-nullptr -std=c++17 %t
+
+namespace std {
+
+using nullptr_t = decltype(nullptr);
+
+template 
+T &&declval();
+
+template 
+struct type_identity { using type = T; };
+template 
+using type_identity_t = typename type_identity::type;
+
+template 
+class basic_string_view {
+public:
+  basic_string_view();
+  basic_string_view(const C *);
+  basic_string_view(const basic_string_view &);
+  basic_string_view &operator=(const basic_string_view &);
+};
+
+template 
+bool operator<(basic_string_view, basic_string_view);
+template 
+bool operator<(type_identity_t>, basic_string_view);
+template 
+bool operator<(basic_string_view, type_identity_t>);
+
+template 
+bool operator<=(basic_string_view, basic_string_view);
+template 
+bool operator<=(type_identity_t>, basic_string_view);
+template 
+bool operator<=(basic_string_view, type_identity_t>);
+
+template 
+bool operator>(basic_string_view, basic_string_view);
+template 
+bool operator>(type_identity_t>, basic_string_view);
+template 
+bool operator>(basic_string_view, type_identity_t>);
+
+template 
+bool operator>=(basic_string_view, basic_string_view);
+template 
+bool operator>=(type_identity_t>, basic_string_view);
+template 
+bool operator>=(basic_string_view, type_identity_t>);
+
+template 
+bool operator==(basic_string_view, basic_string_view);
+template 
+bool operator==(type_identity_t>, basic_string_view);
+template 
+bool operator==(basic_string_view, type_identity_t>);
+
+template 
+bool operator!=(basic_string_view, basic_string_view);
+template 
+bool operator!=(type_identity_t>, basic_string_view);
+template 
+bool operator!=(basic_string_view, type_identity_t>);
+
+using string_view = basic_string_view;
+
+} // namespace std
+
+void function(std::string_view);
+void function(std::string_view, std::string_view);
+
+void temporary_construction() /* a */ {
+  // Functional Cast
+  {
+(void)(std::string_view(nullptr)) /* a1 */;
+// CHECK-MESSAGES: :[[@LINE-1]]:29: warning: constructing basic_string_view from null is undefined; replace with the default constructor
+// CHECK-FIXES: {{^}}(void)(std::string_view()) /* a1 */;{{$}}
+
+(void)(std::string_view((nullptr))) /* a2 */;
+// CHECK-MESSAGES: :[[@LINE-1]]:29: warning: constructing{{.*}}default
+// CHECK-FIXES: {{^}}(void)(std::string_view()) /* a2 */;{{$}}
+
+(void)(std::string_view({nullptr})) /* a3 */;
+// CHECK-MESSAGES: :[[@LINE-1]]:29: warning: constructing{{.*}}default
+// CHECK-FIXES: {{^}}(void)(std::string_view()) /* a3 */;{{$}}
+
+(void)(std::string_view({(nullptr)})) /* a4 */;
+// CHECK-MESSAGES: :[[@LINE-1]]:29: warning: constructing{{.*}}default
+// CHECK-FIXES: {{^}}(void)(std::string_view()) /* a4 */;{{$}}
+
+// (void)(const std::string_view(nullptr)) /* a5 */;
+// CV qualifiers do not compile in this context
+
+// (void)(const std::string_view((nullptr))) /* a6 */;
+// CV qualifiers do not compile in this context
+
+// (void)(const std::string_view({nullptr})) /* a7 */;
+// CV qualifiers do not compile in this context
+
+// (void)(const std::string_view({(nullptr)})) /* a8 */;
+// CV qualifiers do not compile in this context
+  }
+
+  // Temporary Object
+  {
+(void)(std::string_view{nullptr}) /* a9 */;
+// CHECK-MESSAGES: :[[@LINE-1]]:29: warning: constructing{{.*}}default
+// CHECK-FIXES: {{^}}(void)(std::string_view{}) /* a9 */;{{$}}
+
+(void)(std::string_view{(nullptr)}) /* a10 */;
+// CHECK-MESSAGES: :[[@LINE-1]]:29: warning: constructing{{.*}}default
+// CHECK-FIXES: {{^}}(void)(std::string_view{}) /* a10 */;{{$}}
+
+(void)(std::string_view{{nullptr}}) /* a11 */;
+// CHECK-MESSAGES: :[[@LINE-1]]:29: warning: constructing{{.*}}default
+// CHECK-FIXES: {{^}}(void)(std::string_view{}) /* a11 */;{{$}}
+
+(void)(std::string_view{{(nullptr)}}) /* a12 */;
+// CHECK-MESSAGES: :

[PATCH] D112680: [OpenMP] Lower printf to __llvm_omp_vprintf

2021-11-08 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield added a comment.

Thanks for the review! Couple of helpers to split out and the rebase on main is 
messy, retesting now




Comment at: clang/lib/CodeGen/CGGPUBuiltin.cpp:231
+  VprintfFunc, {Args[0].getRValue(*this).getScalarVal(), BufferPtr, 
Size}));
+}

jdoerfert wrote:
> Suggestion: I feel this could be in a helper to avoid the duplication with 
> the nvptx version. All but the extra argument is the same, no?
Nice spot, yes - the tails of the two functions can fold.

> // We don't know how to emit non-scalar varargs.
the block starting with that occurs three times in the files as of this diff, 
probably also worth splitting out



Comment at: openmp/libomptarget/DeviceRTL/src/Debug.cpp:61
+}
 }
 

jdoerfert wrote:
> Namespace above should include _OMP, be anonymous or the functions should be 
> static.
Sure, will patch. I thought the DeviceRTL had an internalize call as part of 
the build process which cuts out all the internal symbols but I might be 
imagining that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112680

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


[PATCH] D107994: Making the code compliant to the documentation about Floating Point support default values for C/C++. FPP-MODEL=PRECISE enables FFP-CONTRACT (FMA is enabled).

2021-11-08 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

This fixes tests on macOS, but I don't know if the space is there intentionally 
to check for presence of any attributes:

  % git diff
  diff --git a/clang/test/CodeGen/ffp-contract-option.c 
b/clang/test/CodeGen/ffp-contract-option.c
  index 04d23d5f90b7..327722f56f4e 100644
  --- a/clang/test/CodeGen/ffp-contract-option.c
  +++ b/clang/test/CodeGen/ffp-contract-option.c
  @@ -63,7 +63,7 @@
   // RUN: --check-prefixes=CHECK,CHECK-FPC-ON
  
   float mymuladd(float x, float y, float z) {
  -  // CHECK: define {{.*}} float @mymuladd(float noundef %x, float noundef 
%y, float noundef %z)
  +  // CHECK: define{{.*}} float @mymuladd(float noundef %x, float noundef %y, 
float noundef %z)
 return x * y + z;
 // expected-warning{{overriding '-ffp-contract=fast' option with 
'-ffp-contract=on'}}
  
  diff --git a/clang/test/CodeGen/ffp-model.c b/clang/test/CodeGen/ffp-model.c
  index ee0eedb2718f..98d31106a119 100644
  --- a/clang/test/CodeGen/ffp-model.c
  +++ b/clang/test/CodeGen/ffp-model.c
  @@ -19,7 +19,7 @@
   // RUN: --check-prefixes CHECK,CHECK-FAST1
  
   float mymuladd(float x, float y, float z) {
  -  // CHECK: define {{.*}} float @mymuladd(float noundef %x, float noundef 
%y, float noundef %z)
  +  // CHECK: define{{.*}} float @mymuladd(float noundef %x, float noundef %y, 
float noundef %z)
 return x * y + z;
 // CHECK-FAST: fmul fast float

If this is the right fix, please land it. Else I'll revert again in 30 min or 
so; bots have been broken for hours by now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107994

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


[PATCH] D113359: [Libomptarget][WIP] Introduce VGPU Plugin

2021-11-08 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added inline comments.



Comment at: clang/lib/CodeGen/CGOpenMPRuntimeVirtualGPU.cpp:54
+  CGOpenMPRuntime::createOffloadEntry(ID, Addr, Size, Flags, Linkage);
+}

We should be able to get rid of this file (and the cuda/hip) version. Might be 
the right time now as a precommit.



Comment at: llvm/include/llvm/ADT/Triple.h:166
+VGPU,
+LastVendorType = VGPU
   };

Let's call it OpenMP_VGPU or something like that to make it clear.



Comment at: llvm/lib/Transforms/IPO/OpenMPOpt.cpp:2177
+}
+
 /// Abstract Attribute for tracking ICV values.

@tianshilei1992 This needs a test.



Comment at: openmp/libomptarget/DeviceRTL/src/Kernel.cpp:107
+  synchronize::threads();
+
   // Signal the workers to exit the state machine and exit the kernel.

I don't think we should do this. Instead, the plugin should signal as threads 
finish the kernel.



Comment at: openmp/libomptarget/DeviceRTL/src/Mapping.cpp:171
+#pragma omp begin declare variant match(   
\
+device = {arch(x86, x86_64)}, implementation = {extension(match_any)})
+

We probably should use kind(CPU) or something instead. Nothing x86 specific 
about it I think.



Comment at: openmp/libomptarget/include/DeviceEnvironment.h:83
+
+ThreadEnvironmentTy *getThreadEnvironment(void);
+

This should go into a new file (ThreadEnvironment)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113359

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


[clang-tools-extra] 16b07c8 - [clang-tidy] Add check for initialization of `absl::Cleanup`.

2021-11-08 Thread Yitzhak Mandelbaum via cfe-commits

Author: CJ Johnson
Date: 2021-11-08T15:57:32Z
New Revision: 16b07c866ae74e0d02038574fe1c37a6cb55e233

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

LOG: [clang-tidy] Add check for initialization of `absl::Cleanup`.

Suggests switching the initialization pattern of `absl::Cleanup` instances from 
the factory function to class template argument deduction (CTAD) in C++17 and 
higher.

Reviewed By: ymandel

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

Added: 
clang-tools-extra/clang-tidy/abseil/CleanupCtadCheck.cpp
clang-tools-extra/clang-tidy/abseil/CleanupCtadCheck.h
clang-tools-extra/docs/clang-tidy/checks/abseil-cleanup-ctad.rst
clang-tools-extra/test/clang-tidy/checkers/abseil-cleanup-ctad.cpp

Modified: 
clang-tools-extra/clang-tidy/abseil/AbseilTidyModule.cpp
clang-tools-extra/clang-tidy/abseil/CMakeLists.txt
clang-tools-extra/docs/ReleaseNotes.rst
clang-tools-extra/docs/clang-tidy/checks/list.rst

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/abseil/AbseilTidyModule.cpp 
b/clang-tools-extra/clang-tidy/abseil/AbseilTidyModule.cpp
index 7d592d7e3e55..5d99e6b50075 100644
--- a/clang-tools-extra/clang-tidy/abseil/AbseilTidyModule.cpp
+++ b/clang-tools-extra/clang-tidy/abseil/AbseilTidyModule.cpp
@@ -9,6 +9,7 @@
 #include "../ClangTidy.h"
 #include "../ClangTidyModule.h"
 #include "../ClangTidyModuleRegistry.h"
+#include "CleanupCtadCheck.h"
 #include "DurationAdditionCheck.h"
 #include "DurationComparisonCheck.h"
 #include "DurationConversionCastCheck.h"
@@ -35,6 +36,7 @@ namespace abseil {
 class AbseilModule : public ClangTidyModule {
 public:
   void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
+CheckFactories.registerCheck("abseil-cleanup-ctad");
 CheckFactories.registerCheck(
 "abseil-duration-addition");
 CheckFactories.registerCheck(

diff  --git a/clang-tools-extra/clang-tidy/abseil/CMakeLists.txt 
b/clang-tools-extra/clang-tidy/abseil/CMakeLists.txt
index b6ea21879daf..e7c86fc8107d 100644
--- a/clang-tools-extra/clang-tidy/abseil/CMakeLists.txt
+++ b/clang-tools-extra/clang-tidy/abseil/CMakeLists.txt
@@ -5,6 +5,7 @@ set(LLVM_LINK_COMPONENTS
 
 add_clang_library(clangTidyAbseilModule
   AbseilTidyModule.cpp
+  CleanupCtadCheck.cpp
   DurationAdditionCheck.cpp
   DurationComparisonCheck.cpp
   DurationConversionCastCheck.cpp

diff  --git a/clang-tools-extra/clang-tidy/abseil/CleanupCtadCheck.cpp 
b/clang-tools-extra/clang-tidy/abseil/CleanupCtadCheck.cpp
new file mode 100644
index ..bc152f1dafa7
--- /dev/null
+++ b/clang-tools-extra/clang-tidy/abseil/CleanupCtadCheck.cpp
@@ -0,0 +1,49 @@
+//===--- CleanupCtadCheck.cpp - clang-tidy 
===//
+//
+// 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 "CleanupCtadCheck.h"
+#include "../utils/TransformerClangTidyCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
+#include "clang/Tooling/Transformer/RangeSelector.h"
+#include "clang/Tooling/Transformer/RewriteRule.h"
+#include "clang/Tooling/Transformer/Stencil.h"
+#include "llvm/ADT/StringRef.h"
+
+using namespace ::clang::ast_matchers;
+using namespace ::clang::transformer;
+
+namespace clang {
+namespace tidy {
+namespace abseil {
+
+RewriteRule CleanupCtadCheckImpl() {
+  auto warning_message = cat("prefer absl::Cleanup's class template argument "
+ "deduction pattern in C++17 and higher");
+
+  return makeRule(
+  declStmt(has(varDecl(
+  hasType(autoType()), hasTypeLoc(typeLoc().bind("auto_type_loc")),
+  hasInitializer(traverse(
+  clang::TK_IgnoreUnlessSpelledInSource,
+  callExpr(callee(functionDecl(hasName("absl::MakeCleanup"))),
+   argumentCountIs(1),
+   hasArgument(0, expr().bind("make_cleanup_argument")))
+  .bind("make_cleanup_call")),
+  {changeTo(node("auto_type_loc"), cat("absl::Cleanup")),
+   changeTo(node("make_cleanup_call"), 
cat(node("make_cleanup_argument")))},
+  warning_message);
+}
+
+CleanupCtadCheck::CleanupCtadCheck(StringRef Name, ClangTidyContext *Context)
+: utils::TransformerClangTidyCheck(CleanupCtadCheckImpl(), Name, Context) 
{}
+
+} // namespace abseil
+} // namespace tidy
+} // namespace clang

diff  --git a/clang-tools-extra/clang-tidy/abseil/CleanupCtadCheck.h 
b/clang-tools-extra/clang-tidy/abseil/CleanupCtadCheck.h
new file mod

[PATCH] D113195: [clang-tidy] Add check for initialization of `absl::Cleanup`.

2021-11-08 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG16b07c866ae7: [clang-tidy] Add check for initialization of 
`absl::Cleanup`. (authored by CJ-Johnson, committed by ymandel).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113195

Files:
  clang-tools-extra/clang-tidy/abseil/AbseilTidyModule.cpp
  clang-tools-extra/clang-tidy/abseil/CMakeLists.txt
  clang-tools-extra/clang-tidy/abseil/CleanupCtadCheck.cpp
  clang-tools-extra/clang-tidy/abseil/CleanupCtadCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/abseil-cleanup-ctad.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/test/clang-tidy/checkers/abseil-cleanup-ctad.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/abseil-cleanup-ctad.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/abseil-cleanup-ctad.cpp
@@ -0,0 +1,115 @@
+// RUN: %check_clang_tidy %s abseil-cleanup-ctad -std=c++17 %t
+
+namespace std {
+
+template 
+struct is_same {
+  static const bool value = false;
+};
+
+template 
+struct is_same { static const bool value = true; };
+
+template 
+class function {
+public:
+  template 
+  function(T) {}
+  function(const function &) {}
+};
+
+} // namespace std
+
+namespace absl {
+
+namespace cleanup_internal {
+
+struct Tag {};
+
+template 
+class Storage {
+public:
+  Storage() = delete;
+
+  explicit Storage(Callback callback) {}
+
+  Storage(Storage &&other) {}
+
+  Storage(const Storage &other) = delete;
+
+  Storage &operator=(Storage &&other) = delete;
+
+  Storage &operator=(const Storage &other) = delete;
+
+private:
+  bool is_callback_engaged_;
+  alignas(Callback) char callback_buffer_[sizeof(Callback)];
+};
+
+} // namespace cleanup_internal
+
+template 
+class Cleanup final {
+public:
+  Cleanup(Callback callback) // NOLINT
+  : storage_(static_cast(callback)) {}
+
+  Cleanup(Cleanup &&other) = default;
+
+  void Cancel() &&;
+
+  void Invoke() &&;
+
+  ~Cleanup();
+
+private:
+  cleanup_internal::Storage storage_;
+};
+
+template 
+Cleanup(Callback callback) -> Cleanup;
+
+template 
+absl::Cleanup MakeCleanup(Callback callback) {
+  return {static_cast(callback)};
+}
+
+} // namespace absl
+
+void test() {
+  auto a = absl::MakeCleanup([] {});
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: prefer absl::Cleanup's class template argument deduction pattern in C++17 and higher
+  // CHECK-FIXES: {{^}}  absl::Cleanup a = [] {};{{$}}
+
+  // Removes extra parens
+  auto b = absl::MakeCleanup(([] {}));
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: prefer absl::Cleanup{{.*}}C++17 and higher
+  // CHECK-FIXES: {{^}}  absl::Cleanup b = [] {};{{$}}
+
+  auto c = absl::MakeCleanup(std::function([] {}));
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: prefer absl::Cleanup{{.*}}C++17 and higher
+  // CHECK-FIXES: {{^}}  absl::Cleanup c = std::function([] {});{{$}}
+
+  // Removes extra parens
+  auto d = absl::MakeCleanup((std::function([] {})));
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: prefer absl::Cleanup{{.*}}C++17 and higher
+  // CHECK-FIXES: {{^}}  absl::Cleanup d = std::function([] {});{{$}}
+
+  const auto e = absl::MakeCleanup([] {});
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: prefer absl::Cleanup{{.*}}C++17 and higher
+  // CHECK-FIXES: {{^}}  const absl::Cleanup e = [] {};{{$}}
+
+  // Removes extra parens
+  const auto f = absl::MakeCleanup(([] {}));
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: prefer absl::Cleanup{{.*}}C++17 and higher
+  // CHECK-FIXES: {{^}}  const absl::Cleanup f = [] {};{{$}}
+
+  const auto g = absl::MakeCleanup(std::function([] {}));
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: prefer absl::Cleanup{{.*}}C++17 and higher
+  // CHECK-FIXES: {{^}}  const absl::Cleanup g = std::function([] {});{{$}}
+
+  // Removes extra parens
+  const auto h = absl::MakeCleanup((std::function([] {})));
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: prefer absl::Cleanup{{.*}}C++17 and higher
+  // CHECK-FIXES: {{^}}  const absl::Cleanup h = std::function([] {});{{$}}
+}
Index: clang-tools-extra/docs/clang-tidy/checks/list.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/list.rst
+++ clang-tools-extra/docs/clang-tidy/checks/list.rst
@@ -12,6 +12,7 @@
 .. csv-table::
:header: "Name", "Offers fixes"
 
+   `abseil-cleanup-ctad `_, "Yes"
`abseil-duration-addition `_, "Yes"
`abseil-duration-comparison `_, "Yes"
`abseil-duration-conversion-cast `_, "Yes"
@@ -448,3 +449,4 @@
`hicpp-vararg `_, `cppcoreguidelines-pro-type-vararg `_,
`llvm-else-after-return `_, `readability-else-after-return `_, "Yes"
`llvm-qualified-auto `_, `readability-qualified-auto `_, "Yes"
+   
\ No newline at end of file
Index: clang-tools-extra/docs/clang-tidy/checks/abseil-cl

[PATCH] D112680: [OpenMP] Lower printf to __llvm_omp_vprintf

2021-11-08 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield updated this revision to Diff 385505.
JonChesterfield added a comment.

- rebase, static functions


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112680

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CGGPUBuiltin.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  openmp/libomptarget/DeviceRTL/include/Debug.h
  openmp/libomptarget/DeviceRTL/src/Debug.cpp
  openmp/libomptarget/deviceRTLs/amdgcn/src/target_impl.hip
  openmp/libomptarget/deviceRTLs/nvptx/src/target_impl.cu
  openmp/libomptarget/test/mapping/data_member_ref.cpp
  openmp/libomptarget/test/mapping/declare_mapper_nested_default_mappers.cpp
  openmp/libomptarget/test/mapping/declare_mapper_nested_mappers.cpp
  openmp/libomptarget/test/mapping/lambda_by_value.cpp
  openmp/libomptarget/test/mapping/ompx_hold/struct.c
  openmp/libomptarget/test/mapping/ptr_and_obj_motion.c
  openmp/libomptarget/test/mapping/reduction_implicit_map.cpp
  openmp/libomptarget/test/offloading/bug49021.cpp
  openmp/libomptarget/test/offloading/bug50022.cpp
  openmp/libomptarget/test/offloading/host_as_target.c
  openmp/libomptarget/test/unified_shared_memory/api.c
  openmp/libomptarget/test/unified_shared_memory/close_enter_exit.c
  openmp/libomptarget/test/unified_shared_memory/close_modifier.c
  openmp/libomptarget/test/unified_shared_memory/shared_update.c

Index: openmp/libomptarget/test/unified_shared_memory/shared_update.c
===
--- openmp/libomptarget/test/unified_shared_memory/shared_update.c
+++ openmp/libomptarget/test/unified_shared_memory/shared_update.c
@@ -2,9 +2,8 @@
 
 // REQUIRES: unified_shared_memory
 
-// amdgcn does not have printf definition
-// XFAIL: amdgcn-amd-amdhsa
-// XFAIL: amdgcn-amd-amdhsa-newRTL
+// amdgpu runtime crash
+// UNSUPPORTED: amdgcn-amd-amdhsa
 
 #include 
 #include 
Index: openmp/libomptarget/test/unified_shared_memory/close_modifier.c
===
--- openmp/libomptarget/test/unified_shared_memory/close_modifier.c
+++ openmp/libomptarget/test/unified_shared_memory/close_modifier.c
@@ -3,9 +3,9 @@
 // REQUIRES: unified_shared_memory
 // UNSUPPORTED: clang-6, clang-7, clang-8, clang-9
 
-// amdgcn does not have printf definition
-// XFAIL: amdgcn-amd-amdhsa
-// XFAIL: amdgcn-amd-amdhsa-newRTL
+// amdgpu runtime crash
+// UNSUPPORTED: amdgcn-amd-amdhsa
+
 
 #include 
 #include 
Index: openmp/libomptarget/test/unified_shared_memory/close_enter_exit.c
===
--- openmp/libomptarget/test/unified_shared_memory/close_enter_exit.c
+++ openmp/libomptarget/test/unified_shared_memory/close_enter_exit.c
@@ -3,7 +3,7 @@
 // REQUIRES: unified_shared_memory
 // UNSUPPORTED: clang-6, clang-7, clang-8, clang-9
 
-// Fails on amdgcn with error: GPU Memory Error
+// Fails on amdgpu with error: GPU Memory Error
 // XFAIL: amdgcn-amd-amdhsa
 // XFAIL: amdgcn-amd-amdhsa-newRTL
 
Index: openmp/libomptarget/test/unified_shared_memory/api.c
===
--- openmp/libomptarget/test/unified_shared_memory/api.c
+++ openmp/libomptarget/test/unified_shared_memory/api.c
@@ -2,7 +2,7 @@
 // XFAIL: nvptx64-nvidia-cuda
 // XFAIL: nvptx64-nvidia-cuda-newRTL
 
-// Fails on amdgcn with error: GPU Memory Error
+// Fails on amdgpu with error: GPU Memory Error
 // XFAIL: amdgcn-amd-amdhsa
 // XFAIL: amdgcn-amd-amdhsa-newRTL
 
Index: openmp/libomptarget/test/offloading/host_as_target.c
===
--- openmp/libomptarget/test/offloading/host_as_target.c
+++ openmp/libomptarget/test/offloading/host_as_target.c
@@ -7,7 +7,7 @@
 
 // RUN: %libomptarget-compile-run-and-check-generic
 
-// amdgcn does not have printf definition
+// amdgpu does not have a working printf definition
 // XFAIL: amdgcn-amd-amdhsa
 // XFAIL: amdgcn-amd-amdhsa-newRTL
 
Index: openmp/libomptarget/test/offloading/bug50022.cpp
===
--- openmp/libomptarget/test/offloading/bug50022.cpp
+++ openmp/libomptarget/test/offloading/bug50022.cpp
@@ -1,8 +1,5 @@
 // RUN: %libomptarget-compilexx-and-run-generic
 
-// UNSUPPORTED: amdgcn-amd-amdhsa
-// UNSUPPORTED: amdgcn-amd-amdhsa-newRTL
-
 #include 
 #include 
 #include 
Index: openmp/libomptarget/test/offloading/bug49021.cpp
===
--- openmp/libomptarget/test/offloading/bug49021.cpp
+++ openmp/libomptarget/test/offloading/bug49021.cpp
@@ -1,8 +1,7 @@
 // RUN: %libomptarget-compilexx-generic -O3 && %libomptarget-run-generic
 
-// Wrong results on amdgcn
-// UNSUPPORTED: amdgcn-amd-amdhsa
-// UNSUPPORTED: amdgcn-amd-amdhsa-newRTL
+// Wrong results on amdgpu
+// XFAIL: amdgcn-amd-amdhsa
 
 #include 
 
Index: openmp/libomptarget/test/mapping/reducti

[PATCH] D111443: [Driver] Fix ToolChain::getSanitizerArgs

2021-11-08 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

@tra Any further concerns? Thanks.


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

https://reviews.llvm.org/D111443

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


[PATCH] D99134: Lambdas are not necessarily locals. This resolves DR48250.

2021-11-08 Thread David Stone via Phabricator via cfe-commits
davidstone updated this revision to Diff 385508.
davidstone added a comment.

Take into account Richard's comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99134

Files:
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/test/SemaCXX/lambdas-implicit-explicit-template.cpp


Index: clang/test/SemaCXX/lambdas-implicit-explicit-template.cpp
===
--- clang/test/SemaCXX/lambdas-implicit-explicit-template.cpp
+++ clang/test/SemaCXX/lambdas-implicit-explicit-template.cpp
@@ -39,3 +39,10 @@
   const auto lambda = [&](auto arg1) {};
   [&](auto arg2) { lambda.operator()(arg2); }(0);
 }
+
+auto d = [](auto) {};
+
+template 
+void d1(T x) { d.operator()(x); }
+
+void d2() { d1(0); }
Index: clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -6001,7 +6001,9 @@
   (ParentDependsOnArgs && (ParentDC->isFunctionOrMethod() ||
isa(ParentDC) ||
isa(ParentDC))) ||
-  (isa(D) && cast(D)->isLambda())) {
+  (isa(D) && cast(D)->isLambda() &&
+   cast(D)->getTemplateDepth() >
+   TemplateArgs.getNumRetainedOuterLevels())) {
 // D is a local of some kind. Look into the map of local
 // declarations to their instantiations.
 if (CurrentInstantiationScope) {


Index: clang/test/SemaCXX/lambdas-implicit-explicit-template.cpp
===
--- clang/test/SemaCXX/lambdas-implicit-explicit-template.cpp
+++ clang/test/SemaCXX/lambdas-implicit-explicit-template.cpp
@@ -39,3 +39,10 @@
   const auto lambda = [&](auto arg1) {};
   [&](auto arg2) { lambda.operator()(arg2); }(0);
 }
+
+auto d = [](auto) {};
+
+template 
+void d1(T x) { d.operator()(x); }
+
+void d2() { d1(0); }
Index: clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -6001,7 +6001,9 @@
   (ParentDependsOnArgs && (ParentDC->isFunctionOrMethod() ||
isa(ParentDC) ||
isa(ParentDC))) ||
-  (isa(D) && cast(D)->isLambda())) {
+  (isa(D) && cast(D)->isLambda() &&
+   cast(D)->getTemplateDepth() >
+   TemplateArgs.getNumRetainedOuterLevels())) {
 // D is a local of some kind. Look into the map of local
 // declarations to their instantiations.
 if (CurrentInstantiationScope) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D112680: [OpenMP] Lower printf to __llvm_omp_vprintf

2021-11-08 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield updated this revision to Diff 385512.
JonChesterfield added a comment.

- helper for nonscalars


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112680

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CGGPUBuiltin.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  openmp/libomptarget/DeviceRTL/include/Debug.h
  openmp/libomptarget/DeviceRTL/src/Debug.cpp
  openmp/libomptarget/deviceRTLs/amdgcn/src/target_impl.hip
  openmp/libomptarget/deviceRTLs/nvptx/src/target_impl.cu
  openmp/libomptarget/test/mapping/data_member_ref.cpp
  openmp/libomptarget/test/mapping/declare_mapper_nested_default_mappers.cpp
  openmp/libomptarget/test/mapping/declare_mapper_nested_mappers.cpp
  openmp/libomptarget/test/mapping/lambda_by_value.cpp
  openmp/libomptarget/test/mapping/ompx_hold/struct.c
  openmp/libomptarget/test/mapping/ptr_and_obj_motion.c
  openmp/libomptarget/test/mapping/reduction_implicit_map.cpp
  openmp/libomptarget/test/offloading/bug49021.cpp
  openmp/libomptarget/test/offloading/bug50022.cpp
  openmp/libomptarget/test/offloading/host_as_target.c
  openmp/libomptarget/test/unified_shared_memory/api.c
  openmp/libomptarget/test/unified_shared_memory/close_enter_exit.c
  openmp/libomptarget/test/unified_shared_memory/close_modifier.c
  openmp/libomptarget/test/unified_shared_memory/shared_update.c

Index: openmp/libomptarget/test/unified_shared_memory/shared_update.c
===
--- openmp/libomptarget/test/unified_shared_memory/shared_update.c
+++ openmp/libomptarget/test/unified_shared_memory/shared_update.c
@@ -2,9 +2,8 @@
 
 // REQUIRES: unified_shared_memory
 
-// amdgcn does not have printf definition
-// XFAIL: amdgcn-amd-amdhsa
-// XFAIL: amdgcn-amd-amdhsa-newRTL
+// amdgpu runtime crash
+// UNSUPPORTED: amdgcn-amd-amdhsa
 
 #include 
 #include 
Index: openmp/libomptarget/test/unified_shared_memory/close_modifier.c
===
--- openmp/libomptarget/test/unified_shared_memory/close_modifier.c
+++ openmp/libomptarget/test/unified_shared_memory/close_modifier.c
@@ -3,9 +3,9 @@
 // REQUIRES: unified_shared_memory
 // UNSUPPORTED: clang-6, clang-7, clang-8, clang-9
 
-// amdgcn does not have printf definition
-// XFAIL: amdgcn-amd-amdhsa
-// XFAIL: amdgcn-amd-amdhsa-newRTL
+// amdgpu runtime crash
+// UNSUPPORTED: amdgcn-amd-amdhsa
+
 
 #include 
 #include 
Index: openmp/libomptarget/test/unified_shared_memory/close_enter_exit.c
===
--- openmp/libomptarget/test/unified_shared_memory/close_enter_exit.c
+++ openmp/libomptarget/test/unified_shared_memory/close_enter_exit.c
@@ -3,7 +3,7 @@
 // REQUIRES: unified_shared_memory
 // UNSUPPORTED: clang-6, clang-7, clang-8, clang-9
 
-// Fails on amdgcn with error: GPU Memory Error
+// Fails on amdgpu with error: GPU Memory Error
 // XFAIL: amdgcn-amd-amdhsa
 // XFAIL: amdgcn-amd-amdhsa-newRTL
 
Index: openmp/libomptarget/test/unified_shared_memory/api.c
===
--- openmp/libomptarget/test/unified_shared_memory/api.c
+++ openmp/libomptarget/test/unified_shared_memory/api.c
@@ -2,7 +2,7 @@
 // XFAIL: nvptx64-nvidia-cuda
 // XFAIL: nvptx64-nvidia-cuda-newRTL
 
-// Fails on amdgcn with error: GPU Memory Error
+// Fails on amdgpu with error: GPU Memory Error
 // XFAIL: amdgcn-amd-amdhsa
 // XFAIL: amdgcn-amd-amdhsa-newRTL
 
Index: openmp/libomptarget/test/offloading/host_as_target.c
===
--- openmp/libomptarget/test/offloading/host_as_target.c
+++ openmp/libomptarget/test/offloading/host_as_target.c
@@ -7,7 +7,7 @@
 
 // RUN: %libomptarget-compile-run-and-check-generic
 
-// amdgcn does not have printf definition
+// amdgpu does not have a working printf definition
 // XFAIL: amdgcn-amd-amdhsa
 // XFAIL: amdgcn-amd-amdhsa-newRTL
 
Index: openmp/libomptarget/test/offloading/bug50022.cpp
===
--- openmp/libomptarget/test/offloading/bug50022.cpp
+++ openmp/libomptarget/test/offloading/bug50022.cpp
@@ -1,8 +1,5 @@
 // RUN: %libomptarget-compilexx-and-run-generic
 
-// UNSUPPORTED: amdgcn-amd-amdhsa
-// UNSUPPORTED: amdgcn-amd-amdhsa-newRTL
-
 #include 
 #include 
 #include 
Index: openmp/libomptarget/test/offloading/bug49021.cpp
===
--- openmp/libomptarget/test/offloading/bug49021.cpp
+++ openmp/libomptarget/test/offloading/bug49021.cpp
@@ -1,8 +1,7 @@
 // RUN: %libomptarget-compilexx-generic -O3 && %libomptarget-run-generic
 
-// Wrong results on amdgcn
-// UNSUPPORTED: amdgcn-amd-amdhsa
-// UNSUPPORTED: amdgcn-amd-amdhsa-newRTL
+// Wrong results on amdgpu
+// XFAIL: amdgcn-amd-amdhsa
 
 #include 
 
Index: openmp/libomptarget/test/mapping/reduction_

[PATCH] D112680: [OpenMP] Lower printf to __llvm_omp_vprintf

2021-11-08 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield added a subscriber: ronlieb.
JonChesterfield added a comment.

Updated. Left Builder.CreateCall alone as I've failed to think of a clean way 
to handle the sometimes present size argument. Tests pass locally and are a 
credible guess at what will pass the CI bot, but may need to roll back if 
there's a difference between local and CI


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112680

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


[clang] 190bde4 - Revert "Making the code compliant to the documentation about Floating Point"

2021-11-08 Thread Aaron Ballman via cfe-commits

Author: Aaron Ballman
Date: 2021-11-08T11:43:49-05:00
New Revision: 190bde404c67527c0a15b1ccbcb5af025aadcdd7

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

LOG: Revert "Making the code compliant to the documentation about Floating 
Point"

This reverts commit 438437cbb61a39ce27b3d6218ac426b8f8a0132e.

There are still broken bots from this:

https://lab.llvm.org/buildbot/#/builders/188/builds/5495
https://lab.llvm.org/buildbot/#/builders/171/builds/5710

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/docs/UsersManual.rst
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/CodeGen/ffp-contract-option.c
clang/test/CodeGen/ppc-emmintrin.c
clang/test/CodeGen/ppc-xmmintrin.c
clang/test/Driver/fp-model.c

Removed: 
clang/test/CodeGen/ffp-model.c
clang/test/Misc/ffp-contract.c



diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index fe4b563a6d2c..ba15803e6f48 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -202,16 +202,6 @@ Arm and AArch64 Support in Clang
   architecture features, but will enable certain optimizations specific to
   Cortex-A57 CPUs and enable the use of a more accurate scheduling model.
 
-
-Floating Point Support in Clang

-- The -ffp-model=precise now implies -ffp-contract=on rather than
-  -ffp-contract=fast, and the documentation of these features has been
-  clarified. Previously, the documentation claimed that -ffp-model=precise was
-  the default, but this was incorrect because the precise model implied
-  -ffp-contract=fast, whereas the default behavior is -ffp-contract=on.
-  -ffp-model=precise is now exactly the default mode of the compiler.
-
 Internal API Changes
 
 

diff  --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst
index 406efb093d55..8c6922db6b37 100644
--- a/clang/docs/UsersManual.rst
+++ b/clang/docs/UsersManual.rst
@@ -1260,49 +1260,8 @@ installed.
 Controlling Floating Point Behavior
 ---
 
-Clang provides a number of ways to control floating point behavior, including
-with command line options and source pragmas. This section
-describes the various floating point semantic modes and the corresponding 
options.
-
-.. csv-table:: Floating Point Semantic Modes
-  :header: "Mode", "Values"
-  :widths: 15, 30, 30
-
-  "ffp-exception-behavior", "{ignore, strict, may_trap}",
-  "fenv_access", "{off, on}", "(none)"
-  "frounding-math", "{dynamic, tonearest, downward, upward, towardzero}"
-  "ffp-contract", "{on, off, fast, fast-honor-pragmas}"
-  "fdenormal-fp-math", "{IEEE, PreserveSign, PositiveZero}"
-  "fdenormal-fp-math-fp32", "{IEEE, PreserveSign, PositiveZero}"
-  "fmath-errno", "{on, off}"
-  "fhonor-nans", "{on, off}"
-  "fhonor-infinities", "{on, off}"
-  "fsigned-zeros", "{on, off}"
-  "freciprocal-math", "{on, off}"
-  "allow_approximate_fns", "{on, off}"
-  "fassociative-math", "{on, off}"
-
-This table describes the option settings that correspond to the three
-floating point semantic models: precise (the default), strict, and fast.
-
-
-.. csv-table:: Floating Point Models
-  :header: "Mode", "Precise", "Strict", "Fast"
-  :widths: 25, 15, 15, 15
-
-  "except_behavior", "ignore", "strict", "ignore"
-  "fenv_access", "off", "on", "off"
-  "rounding_mode", "tonearest", "dynamic", "tonearest"
-  "contract", "on", "off", "fast"
-  "denormal_fp_math", "IEEE", "IEEE", "PreserveSign"
-  "denormal_fp32_math", "IEEE","IEEE", "PreserveSign"
-  "support_math_errno", "on", "on", "off"
-  "no_honor_nans", "off", "off", "on"
-  "no_honor_infinities", "off", "off", "on"
-  "no_signed_zeros", "off", "off", "on"
-  "allow_reciprocal", "off", "off", "on"
-  "allow_approximate_fns", "off", "off", "on"
-  "allow_reassociation", "off", "off", "on"
+Clang provides a number of ways to control floating point behavior. The options
+are listed below.
 
 .. option:: -ffast-math
 
@@ -1508,7 +1467,7 @@ Note that floating-point operations performed as part of 
constant initialization
and ``fast``.
Details:
 
-   * ``precise`` Disables optimizations that are not value-safe on 
floating-point data, although FP contraction (FMA) is enabled 
(``-ffp-contract=on``).  This is the default behavior.
+   * ``precise`` Disables optimizations that are not value-safe on 
floating-point data, although FP contraction (FMA) is enabled 
(``-ffp-contract=fast``).  This is the default behavior.
* ``strict`` Enables ``-frounding-math`` and 
``-ffp-exception-behavior=strict``, and disables contractions (FMA).  All of 
the ``-ffast-math`` enablements are disabled. Enables ``STDC FENV_ACCESS``: by 
default ``FENV_ACCESS`` is disabled. This option setting behaves as though 
``#pragma STDC FE

Re: [clang] 438437c - Making the code compliant to the documentation about Floating Point

2021-11-08 Thread Aaron Ballman via cfe-commits
FWIW, I reverted this in 190bde404c67527c0a15b1ccbcb5af025aadcdd7 as
it didn't fix the bots fully.

~Aaron

On Mon, Nov 8, 2021 at 8:35 AM Zahira Ammarguellat via cfe-commits
 wrote:
>
>
> Author: Zahira Ammarguellat
> Date: 2021-11-08T08:35:19-05:00
> New Revision: 438437cbb61a39ce27b3d6218ac426b8f8a0132e
>
> URL: 
> https://github.com/llvm/llvm-project/commit/438437cbb61a39ce27b3d6218ac426b8f8a0132e
> DIFF: 
> https://github.com/llvm/llvm-project/commit/438437cbb61a39ce27b3d6218ac426b8f8a0132e.diff
>
> LOG: Making the code compliant to the documentation about Floating Point
> support default values for C/C++. FPP-MODEL=PRECISE enables FFP-CONTRACT
> FMA is enabled.
>
> Fix for https://bugs.llvm.org/show_bug.cgi?id=50222
>
> Added:
> clang/test/CodeGen/ffp-model.c
> clang/test/Misc/ffp-contract.c
>
> Modified:
> clang/docs/ReleaseNotes.rst
> clang/docs/UsersManual.rst
> clang/lib/Driver/ToolChains/Clang.cpp
> clang/test/CodeGen/ffp-contract-option.c
> clang/test/CodeGen/ppc-emmintrin.c
> clang/test/CodeGen/ppc-xmmintrin.c
> clang/test/Driver/fp-model.c
>
> Removed:
>
>
>
> 
> diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
> index ba15803e6f48..fe4b563a6d2c 100644
> --- a/clang/docs/ReleaseNotes.rst
> +++ b/clang/docs/ReleaseNotes.rst
> @@ -202,6 +202,16 @@ Arm and AArch64 Support in Clang
>architecture features, but will enable certain optimizations specific to
>Cortex-A57 CPUs and enable the use of a more accurate scheduling model.
>
> +
> +Floating Point Support in Clang
> +---
> +- The -ffp-model=precise now implies -ffp-contract=on rather than
> +  -ffp-contract=fast, and the documentation of these features has been
> +  clarified. Previously, the documentation claimed that -ffp-model=precise 
> was
> +  the default, but this was incorrect because the precise model implied
> +  -ffp-contract=fast, whereas the default behavior is -ffp-contract=on.
> +  -ffp-model=precise is now exactly the default mode of the compiler.
> +
>  Internal API Changes
>  
>
>
> diff  --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst
> index 8c6922db6b37..406efb093d55 100644
> --- a/clang/docs/UsersManual.rst
> +++ b/clang/docs/UsersManual.rst
> @@ -1260,8 +1260,49 @@ installed.
>  Controlling Floating Point Behavior
>  ---
>
> -Clang provides a number of ways to control floating point behavior. The 
> options
> -are listed below.
> +Clang provides a number of ways to control floating point behavior, including
> +with command line options and source pragmas. This section
> +describes the various floating point semantic modes and the corresponding 
> options.
> +
> +.. csv-table:: Floating Point Semantic Modes
> +  :header: "Mode", "Values"
> +  :widths: 15, 30, 30
> +
> +  "ffp-exception-behavior", "{ignore, strict, may_trap}",
> +  "fenv_access", "{off, on}", "(none)"
> +  "frounding-math", "{dynamic, tonearest, downward, upward, towardzero}"
> +  "ffp-contract", "{on, off, fast, fast-honor-pragmas}"
> +  "fdenormal-fp-math", "{IEEE, PreserveSign, PositiveZero}"
> +  "fdenormal-fp-math-fp32", "{IEEE, PreserveSign, PositiveZero}"
> +  "fmath-errno", "{on, off}"
> +  "fhonor-nans", "{on, off}"
> +  "fhonor-infinities", "{on, off}"
> +  "fsigned-zeros", "{on, off}"
> +  "freciprocal-math", "{on, off}"
> +  "allow_approximate_fns", "{on, off}"
> +  "fassociative-math", "{on, off}"
> +
> +This table describes the option settings that correspond to the three
> +floating point semantic models: precise (the default), strict, and fast.
> +
> +
> +.. csv-table:: Floating Point Models
> +  :header: "Mode", "Precise", "Strict", "Fast"
> +  :widths: 25, 15, 15, 15
> +
> +  "except_behavior", "ignore", "strict", "ignore"
> +  "fenv_access", "off", "on", "off"
> +  "rounding_mode", "tonearest", "dynamic", "tonearest"
> +  "contract", "on", "off", "fast"
> +  "denormal_fp_math", "IEEE", "IEEE", "PreserveSign"
> +  "denormal_fp32_math", "IEEE","IEEE", "PreserveSign"
> +  "support_math_errno", "on", "on", "off"
> +  "no_honor_nans", "off", "off", "on"
> +  "no_honor_infinities", "off", "off", "on"
> +  "no_signed_zeros", "off", "off", "on"
> +  "allow_reciprocal", "off", "off", "on"
> +  "allow_approximate_fns", "off", "off", "on"
> +  "allow_reassociation", "off", "off", "on"
>
>  .. option:: -ffast-math
>
> @@ -1467,7 +1508,7 @@ Note that floating-point operations performed as part 
> of constant initialization
> and ``fast``.
> Details:
>
> -   * ``precise`` Disables optimizations that are not value-safe on 
> floating-point data, although FP contraction (FMA) is enabled 
> (``-ffp-contract=fast``).  This is the default behavior.
> +   * ``precise`` Disables optimizations that are not value-safe on 
> floating-point data, although FP contraction (FMA) is enabled 
> (``-ffp-contract=on``).  Th

[PATCH] D110927: [analyzer] Access stored value of a constant array through a pointer to another type

2021-11-08 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added a comment.

Ping.
Does anyone know how to check the status of`-fno-strict-aliasing` flag from CSA 
side?


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

https://reviews.llvm.org/D110927

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


[PATCH] D105169: [Clang/Test]: Rename enable_noundef_analysis to disable-noundef-analysis and turn it off by default

2021-11-08 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

Either this or D108453  (which were committed 
together!) caused this assert according to my git-bisect: 
https://godbolt.org/z/4rqYKfW7K

NOTE that this fails in a lit-test for me, clang CodeGen/ifunc.c (though my 
downstream seems to run the verifier even with -emit-llvm, so you might need to 
just swap it to an -emit-obj to get this to repro).

If you cannot fix this quickly, let me know and I can revert it.

IR for this looks like:

  [ekeane1@scsel-clx-24 llvm]$ 
/localdisk2/ekeane1/workspaces/xmain-web/builds/xmainefi2linux_debug/llvm/bin/clang
 -cc1 -internal-isystem 
/localdisk2/ekeane1/workspaces/xmain-web/builds/xmainefi2linux_debug/llvm/lib/clang/14.0.0/include
 -nostdsysteminc -triple i386-unknown-linux-gnu -emit-llvm -o - 
/localdisk2/ekeane1/workspaces/xmain-web/llvm/clang/test/CodeGen/ifunc.c 
-disable-llvm-passes
  ; ModuleID = 
'/localdisk2/ekeane1/workspaces/xmain-web/llvm/clang/test/CodeGen/ifunc.c'
  source_filename = 
"/localdisk2/ekeane1/workspaces/xmain-web/llvm/clang/test/CodeGen/ifunc.c"
  target datalayout = 
"e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-f64:32:64-f80:32-n8:16:32-S128"
  target triple = "i386-unknown-linux-gnu"
  
  @global = global i32 0, align 4
  
  @foo = ifunc i32 (i32), i32 (i32)* ()* @foo_ifunc
  @goo = ifunc void (), bitcast (i8* ()* @goo_ifunc to void ()* ()*)
  
  ; Function Attrs: noinline nounwind optnone
  define internal i32 (i32)* @foo_ifunc() #0 {
  entry:
%0 = load i32, i32* @global, align 4
%tobool = icmp ne i32 %0, 0
%1 = zext i1 %tobool to i64
%cond = select i1 %tobool, i32 (i32)* @f1, i32 (i32)* @f2
ret i32 (i32)* %cond
  }
  
  ; Function Attrs: noinline nounwind optnone
  define dso_local i32 @bar() #0 {
  entry:
%call = call i32 @foo(i32 noundef 1)
ret i32 %call
  }
  
  ; Function Attrs: noinline nounwind optnone
  define dso_local void @bar2() #0 {
  entry:
call void @goo()
ret void
  }
  
  ; Function Attrs: noinline nounwind optnone
  define dso_local i8* @goo_ifunc() #0 {
  entry:
ret i8* null
  }
  
  ; Function Attrs: noinline nounwind optnone
  define internal i32 @f1(i32 noundef %i) #0 {
  entry:
%i.addr = alloca i32, align 4
store i32 %i, i32* %i.addr, align 4
%0 = load i32, i32* %i.addr, align 4
%add = add nsw i32 %0, 1
ret i32 %add
  }
  
  ; Function Attrs: noinline nounwind optnone
  define internal i32 @f2(i32 noundef %i) #0 {
  entry:
%i.addr = alloca i32, align 4
store i32 %i, i32* %i.addr, align 4
%0 = load i32, i32* %i.addr, align 4
%add = add nsw i32 %0, 2
ret i32 %add
  }
  
  attributes #0 = { noinline nounwind optnone "frame-pointer"="none" 
"min-legal-vector-width"="0" "no-trapping-math"="true" 
"stack-protector-buffer-size"="8" "target-features"="+cx8,+x87" }
  
  !llvm.module.flags = !{!0, !1}
  !llvm.ident = !{!2}
  
  !0 = !{i32 1, !"NumRegisterParameters", i32 0}
  !1 = !{i32 1, !"wchar_size", i32 4}
  !2 = !{!"Intel(R) oneAPI DPC++/C++ Compiler 2022.1.0 (2022.x.0.MMDD)"}




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105169

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


[PATCH] D105169: [Clang/Test]: Rename enable_noundef_analysis to disable-noundef-analysis and turn it off by default

2021-11-08 Thread Hyeongyu Kim via Phabricator via cfe-commits
hyeongyukim added a comment.

In D105169#3115814 , @erichkeane 
wrote:

> Either this or D108453  (which were 
> committed together!) caused this assert according to my git-bisect: 
> https://godbolt.org/z/4rqYKfW7K
>
> NOTE that this fails in a lit-test for me, clang CodeGen/ifunc.c (though my 
> downstream seems to run the verifier even with -emit-llvm, so you might need 
> to just swap it to an -emit-obj to get this to repro).
>
> If you cannot fix this quickly, let me know and I can revert it.
>
> IR for this looks like:
>
>   [ekeane1@scsel-clx-24 llvm]$ 
> /localdisk2/ekeane1/workspaces/xmain-web/builds/xmainefi2linux_debug/llvm/bin/clang
>  -cc1 -internal-isystem 
> /localdisk2/ekeane1/workspaces/xmain-web/builds/xmainefi2linux_debug/llvm/lib/clang/14.0.0/include
>  -nostdsysteminc -triple i386-unknown-linux-gnu -emit-llvm -o - 
> /localdisk2/ekeane1/workspaces/xmain-web/llvm/clang/test/CodeGen/ifunc.c 
> -disable-llvm-passes
>   ; ModuleID = 
> '/localdisk2/ekeane1/workspaces/xmain-web/llvm/clang/test/CodeGen/ifunc.c'
>   source_filename = 
> "/localdisk2/ekeane1/workspaces/xmain-web/llvm/clang/test/CodeGen/ifunc.c"
>   target datalayout = 
> "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-f64:32:64-f80:32-n8:16:32-S128"
>   target triple = "i386-unknown-linux-gnu"
>   
>   @global = global i32 0, align 4
>   
>   @foo = ifunc i32 (i32), i32 (i32)* ()* @foo_ifunc
>   @goo = ifunc void (), bitcast (i8* ()* @goo_ifunc to void ()* ()*)
>   
>   ; Function Attrs: noinline nounwind optnone
>   define internal i32 (i32)* @foo_ifunc() #0 {
>   entry:
> %0 = load i32, i32* @global, align 4
> %tobool = icmp ne i32 %0, 0
> %1 = zext i1 %tobool to i64
> %cond = select i1 %tobool, i32 (i32)* @f1, i32 (i32)* @f2
> ret i32 (i32)* %cond
>   }
>   
>   ; Function Attrs: noinline nounwind optnone
>   define dso_local i32 @bar() #0 {
>   entry:
> %call = call i32 @foo(i32 noundef 1)
> ret i32 %call
>   }
>   
>   ; Function Attrs: noinline nounwind optnone
>   define dso_local void @bar2() #0 {
>   entry:
> call void @goo()
> ret void
>   }
>   
>   ; Function Attrs: noinline nounwind optnone
>   define dso_local i8* @goo_ifunc() #0 {
>   entry:
> ret i8* null
>   }
>   
>   ; Function Attrs: noinline nounwind optnone
>   define internal i32 @f1(i32 noundef %i) #0 {
>   entry:
> %i.addr = alloca i32, align 4
> store i32 %i, i32* %i.addr, align 4
> %0 = load i32, i32* %i.addr, align 4
> %add = add nsw i32 %0, 1
> ret i32 %add
>   }
>   
>   ; Function Attrs: noinline nounwind optnone
>   define internal i32 @f2(i32 noundef %i) #0 {
>   entry:
> %i.addr = alloca i32, align 4
> store i32 %i, i32* %i.addr, align 4
> %0 = load i32, i32* %i.addr, align 4
> %add = add nsw i32 %0, 2
> ret i32 %add
>   }
>   
>   attributes #0 = { noinline nounwind optnone "frame-pointer"="none" 
> "min-legal-vector-width"="0" "no-trapping-math"="true" 
> "stack-protector-buffer-size"="8" "target-features"="+cx8,+x87" }
>   
>   !llvm.module.flags = !{!0, !1}
>   !llvm.ident = !{!2}
>   
>   !0 = !{i32 1, !"NumRegisterParameters", i32 0}
>   !1 = !{i32 1, !"wchar_size", i32 4}
>   !2 = !{!"Intel(R) oneAPI DPC++/C++ Compiler 2022.1.0 (2022.x.0.MMDD)"}

Hmm.. I'll revert it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105169

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


[PATCH] D112680: [OpenMP] Lower printf to __llvm_omp_vprintf

2021-11-08 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield updated this revision to Diff 385525.
JonChesterfield added a comment.

- fold nvptx and openmp printf into one call
- Drop ReturnValue argument


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112680

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CGGPUBuiltin.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  openmp/libomptarget/DeviceRTL/include/Debug.h
  openmp/libomptarget/DeviceRTL/src/Debug.cpp
  openmp/libomptarget/deviceRTLs/amdgcn/src/target_impl.hip
  openmp/libomptarget/deviceRTLs/nvptx/src/target_impl.cu
  openmp/libomptarget/test/mapping/data_member_ref.cpp
  openmp/libomptarget/test/mapping/declare_mapper_nested_default_mappers.cpp
  openmp/libomptarget/test/mapping/declare_mapper_nested_mappers.cpp
  openmp/libomptarget/test/mapping/lambda_by_value.cpp
  openmp/libomptarget/test/mapping/ompx_hold/struct.c
  openmp/libomptarget/test/mapping/ptr_and_obj_motion.c
  openmp/libomptarget/test/mapping/reduction_implicit_map.cpp
  openmp/libomptarget/test/offloading/bug49021.cpp
  openmp/libomptarget/test/offloading/bug50022.cpp
  openmp/libomptarget/test/offloading/host_as_target.c
  openmp/libomptarget/test/unified_shared_memory/api.c
  openmp/libomptarget/test/unified_shared_memory/close_enter_exit.c
  openmp/libomptarget/test/unified_shared_memory/close_modifier.c
  openmp/libomptarget/test/unified_shared_memory/shared_update.c

Index: openmp/libomptarget/test/unified_shared_memory/shared_update.c
===
--- openmp/libomptarget/test/unified_shared_memory/shared_update.c
+++ openmp/libomptarget/test/unified_shared_memory/shared_update.c
@@ -2,9 +2,8 @@
 
 // REQUIRES: unified_shared_memory
 
-// amdgcn does not have printf definition
-// XFAIL: amdgcn-amd-amdhsa
-// XFAIL: amdgcn-amd-amdhsa-newRTL
+// amdgpu runtime crash
+// UNSUPPORTED: amdgcn-amd-amdhsa
 
 #include 
 #include 
Index: openmp/libomptarget/test/unified_shared_memory/close_modifier.c
===
--- openmp/libomptarget/test/unified_shared_memory/close_modifier.c
+++ openmp/libomptarget/test/unified_shared_memory/close_modifier.c
@@ -3,9 +3,9 @@
 // REQUIRES: unified_shared_memory
 // UNSUPPORTED: clang-6, clang-7, clang-8, clang-9
 
-// amdgcn does not have printf definition
-// XFAIL: amdgcn-amd-amdhsa
-// XFAIL: amdgcn-amd-amdhsa-newRTL
+// amdgpu runtime crash
+// UNSUPPORTED: amdgcn-amd-amdhsa
+
 
 #include 
 #include 
Index: openmp/libomptarget/test/unified_shared_memory/close_enter_exit.c
===
--- openmp/libomptarget/test/unified_shared_memory/close_enter_exit.c
+++ openmp/libomptarget/test/unified_shared_memory/close_enter_exit.c
@@ -3,7 +3,7 @@
 // REQUIRES: unified_shared_memory
 // UNSUPPORTED: clang-6, clang-7, clang-8, clang-9
 
-// Fails on amdgcn with error: GPU Memory Error
+// Fails on amdgpu with error: GPU Memory Error
 // XFAIL: amdgcn-amd-amdhsa
 // XFAIL: amdgcn-amd-amdhsa-newRTL
 
Index: openmp/libomptarget/test/unified_shared_memory/api.c
===
--- openmp/libomptarget/test/unified_shared_memory/api.c
+++ openmp/libomptarget/test/unified_shared_memory/api.c
@@ -2,7 +2,7 @@
 // XFAIL: nvptx64-nvidia-cuda
 // XFAIL: nvptx64-nvidia-cuda-newRTL
 
-// Fails on amdgcn with error: GPU Memory Error
+// Fails on amdgpu with error: GPU Memory Error
 // XFAIL: amdgcn-amd-amdhsa
 // XFAIL: amdgcn-amd-amdhsa-newRTL
 
Index: openmp/libomptarget/test/offloading/host_as_target.c
===
--- openmp/libomptarget/test/offloading/host_as_target.c
+++ openmp/libomptarget/test/offloading/host_as_target.c
@@ -7,7 +7,7 @@
 
 // RUN: %libomptarget-compile-run-and-check-generic
 
-// amdgcn does not have printf definition
+// amdgpu does not have a working printf definition
 // XFAIL: amdgcn-amd-amdhsa
 // XFAIL: amdgcn-amd-amdhsa-newRTL
 
Index: openmp/libomptarget/test/offloading/bug50022.cpp
===
--- openmp/libomptarget/test/offloading/bug50022.cpp
+++ openmp/libomptarget/test/offloading/bug50022.cpp
@@ -1,8 +1,5 @@
 // RUN: %libomptarget-compilexx-and-run-generic
 
-// UNSUPPORTED: amdgcn-amd-amdhsa
-// UNSUPPORTED: amdgcn-amd-amdhsa-newRTL
-
 #include 
 #include 
 #include 
Index: openmp/libomptarget/test/offloading/bug49021.cpp
===
--- openmp/libomptarget/test/offloading/bug49021.cpp
+++ openmp/libomptarget/test/offloading/bug49021.cpp
@@ -1,8 +1,7 @@
 // RUN: %libomptarget-compilexx-generic -O3 && %libomptarget-run-generic
 
-// Wrong results on amdgcn
-// UNSUPPORTED: amdgcn-amd-amdhsa
-// UNSUPPORTED: amdgcn-amd-amdhsa-newRTL
+// Wrong results on amdgpu
+// XFAIL: amdgcn-amd-amdhsa
 
 #include 
 
I

[PATCH] D112680: [OpenMP] Lower printf to __llvm_omp_vprintf

2021-11-08 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield added a comment.

Folded EmitOpenMPDevicePrintfCallExpr and EmitNVPTXDevicePrintfCallExpr into 
asserts plus one line call into a common function. Leaving amdgpu alone in this 
patch as it's doing something odd with getScalarVal and I don't want to run 
this through the internal CI stack.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112680

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


[PATCH] D113148: Add new clang-tidy check for string_view(nullptr)

2021-11-08 Thread CJ Johnson via Phabricator via cfe-commits
CJ-Johnson added inline comments.



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/bugprone-stringview-nullptr.cpp:84
+
+(void)(std::string_view({nullptr})) /* a3 */;
+// CHECK-MESSAGES: :[[@LINE-1]]:29: warning: constructing 
basic_string_view from null is undefined; replace with the default constructor

CJ-Johnson wrote:
> aaron.ballman wrote:
> > This (and many others) also generates `-Wbraced-scalar-init`, is that 
> > intentional?
> My goal was just to be thorough in the cases tested. It's not an endorsement 
> of the source patterns. :)
As a followup to this: I've added additional test cases and a minor change to 
the AST matchers to catch another form of the `-Wbraced-scalar-init` pattern.

This: `accepts_string_view({{}});`

This pattern will select the `const CharT*` constructor overload and then 
value-initialize the argument, causing a null deref. It happens to not include 
the `nullptr` literal but it has the exact same effect as 
`accepts_string_view(nullptr);` and `accepts_string_view({nullptr});`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113148

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


[PATCH] D113148: Add new clang-tidy check for string_view(nullptr)

2021-11-08 Thread CJ Johnson via Phabricator via cfe-commits
CJ-Johnson updated this revision to Diff 385530.
CJ-Johnson added a comment.

Add AST matcher support and tests for {{}} case where a null pointer is 
implicitly created


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113148

Files:
  clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
  clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
  clang-tools-extra/clang-tidy/bugprone/StringviewNullptrCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/StringviewNullptrCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/bugprone-stringview-nullptr.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/test/clang-tidy/checkers/bugprone-stringview-nullptr.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-stringview-nullptr.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-stringview-nullptr.cpp
@@ -0,0 +1,1221 @@
+// RUN: %check_clang_tidy %s bugprone-stringview-nullptr -std=c++17 %t
+
+namespace std {
+
+using nullptr_t = decltype(nullptr);
+
+template 
+T &&declval();
+
+template 
+struct type_identity { using type = T; };
+template 
+using type_identity_t = typename type_identity::type;
+
+template 
+class basic_string_view {
+public:
+  basic_string_view();
+  basic_string_view(const C *);
+  basic_string_view(const basic_string_view &);
+  basic_string_view &operator=(const basic_string_view &);
+};
+
+template 
+bool operator<(basic_string_view, basic_string_view);
+template 
+bool operator<(type_identity_t>, basic_string_view);
+template 
+bool operator<(basic_string_view, type_identity_t>);
+
+template 
+bool operator<=(basic_string_view, basic_string_view);
+template 
+bool operator<=(type_identity_t>, basic_string_view);
+template 
+bool operator<=(basic_string_view, type_identity_t>);
+
+template 
+bool operator>(basic_string_view, basic_string_view);
+template 
+bool operator>(type_identity_t>, basic_string_view);
+template 
+bool operator>(basic_string_view, type_identity_t>);
+
+template 
+bool operator>=(basic_string_view, basic_string_view);
+template 
+bool operator>=(type_identity_t>, basic_string_view);
+template 
+bool operator>=(basic_string_view, type_identity_t>);
+
+template 
+bool operator==(basic_string_view, basic_string_view);
+template 
+bool operator==(type_identity_t>, basic_string_view);
+template 
+bool operator==(basic_string_view, type_identity_t>);
+
+template 
+bool operator!=(basic_string_view, basic_string_view);
+template 
+bool operator!=(type_identity_t>, basic_string_view);
+template 
+bool operator!=(basic_string_view, type_identity_t>);
+
+using string_view = basic_string_view;
+
+} // namespace std
+
+void function(std::string_view);
+void function(std::string_view, std::string_view);
+
+void temporary_construction() /* a */ {
+  // Functional Cast
+  {
+(void)(std::string_view(nullptr)) /* a1 */;
+// CHECK-MESSAGES: :[[@LINE-1]]:29: warning: constructing basic_string_view from null is undefined; replace with the default constructor
+// CHECK-FIXES: {{^}}(void)(std::string_view()) /* a1 */;
+
+(void)(std::string_view((nullptr))) /* a2 */;
+// CHECK-MESSAGES: :[[@LINE-1]]:29: warning: constructing{{.*}}default
+// CHECK-FIXES: {{^}}(void)(std::string_view()) /* a2 */;
+
+(void)(std::string_view({nullptr})) /* a3 */;
+// CHECK-MESSAGES: :[[@LINE-1]]:29: warning: constructing{{.*}}default
+// CHECK-FIXES: {{^}}(void)(std::string_view()) /* a3 */;
+
+(void)(std::string_view({(nullptr)})) /* a4 */;
+// CHECK-MESSAGES: :[[@LINE-1]]:29: warning: constructing{{.*}}default
+// CHECK-FIXES: {{^}}(void)(std::string_view()) /* a4 */;
+
+(void)(std::string_view({})) /* a5 */; // Default `const CharT*`
+// CHECK-MESSAGES: :[[@LINE-1]]:29: warning: constructing{{.*}}default
+// CHECK-FIXES: {{^}}(void)(std::string_view()) /* a5 */;
+
+// (void)(const std::string_view(nullptr)) /* a6 */;
+// CV qualifiers do not compile in this context
+
+// (void)(const std::string_view((nullptr))) /* a7 */;
+// CV qualifiers do not compile in this context
+
+// (void)(const std::string_view({nullptr})) /* a8 */;
+// CV qualifiers do not compile in this context
+
+// (void)(const std::string_view({(nullptr)})) /* a9 */;
+// CV qualifiers do not compile in this context
+
+// (void)(const std::string_view({})) /* a10 */; // Default `const CharT*`
+// CV qualifiers do not compile in this context
+  }
+
+  // Temporary Object
+  {
+(void)(std::string_view{nullptr}) /* a11 */;
+// CHECK-MESSAGES: :[[@LINE-1]]:29: warning: constructing{{.*}}default
+// CHECK-FIXES: {{^}}(void)(std::string_view{}) /* a11 */;
+
+(void)(std::string_view{(nullptr)}) /* a12 */;
+// CHECK-MESSAGES: :[[@LINE-1]]:29: warning: constru

[PATCH] D113148: Add new clang-tidy check for string_view(nullptr)

2021-11-08 Thread CJ Johnson via Phabricator via cfe-commits
CJ-Johnson updated this revision to Diff 385531.
CJ-Johnson added a comment.

Add missing newline


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113148

Files:
  clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
  clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
  clang-tools-extra/clang-tidy/bugprone/StringviewNullptrCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/StringviewNullptrCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/bugprone-stringview-nullptr.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/test/clang-tidy/checkers/bugprone-stringview-nullptr.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-stringview-nullptr.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-stringview-nullptr.cpp
@@ -0,0 +1,1221 @@
+// RUN: %check_clang_tidy %s bugprone-stringview-nullptr -std=c++17 %t
+
+namespace std {
+
+using nullptr_t = decltype(nullptr);
+
+template 
+T &&declval();
+
+template 
+struct type_identity { using type = T; };
+template 
+using type_identity_t = typename type_identity::type;
+
+template 
+class basic_string_view {
+public:
+  basic_string_view();
+  basic_string_view(const C *);
+  basic_string_view(const basic_string_view &);
+  basic_string_view &operator=(const basic_string_view &);
+};
+
+template 
+bool operator<(basic_string_view, basic_string_view);
+template 
+bool operator<(type_identity_t>, basic_string_view);
+template 
+bool operator<(basic_string_view, type_identity_t>);
+
+template 
+bool operator<=(basic_string_view, basic_string_view);
+template 
+bool operator<=(type_identity_t>, basic_string_view);
+template 
+bool operator<=(basic_string_view, type_identity_t>);
+
+template 
+bool operator>(basic_string_view, basic_string_view);
+template 
+bool operator>(type_identity_t>, basic_string_view);
+template 
+bool operator>(basic_string_view, type_identity_t>);
+
+template 
+bool operator>=(basic_string_view, basic_string_view);
+template 
+bool operator>=(type_identity_t>, basic_string_view);
+template 
+bool operator>=(basic_string_view, type_identity_t>);
+
+template 
+bool operator==(basic_string_view, basic_string_view);
+template 
+bool operator==(type_identity_t>, basic_string_view);
+template 
+bool operator==(basic_string_view, type_identity_t>);
+
+template 
+bool operator!=(basic_string_view, basic_string_view);
+template 
+bool operator!=(type_identity_t>, basic_string_view);
+template 
+bool operator!=(basic_string_view, type_identity_t>);
+
+using string_view = basic_string_view;
+
+} // namespace std
+
+void function(std::string_view);
+void function(std::string_view, std::string_view);
+
+void temporary_construction() /* a */ {
+  // Functional Cast
+  {
+(void)(std::string_view(nullptr)) /* a1 */;
+// CHECK-MESSAGES: :[[@LINE-1]]:29: warning: constructing basic_string_view from null is undefined; replace with the default constructor
+// CHECK-FIXES: {{^}}(void)(std::string_view()) /* a1 */;
+
+(void)(std::string_view((nullptr))) /* a2 */;
+// CHECK-MESSAGES: :[[@LINE-1]]:29: warning: constructing{{.*}}default
+// CHECK-FIXES: {{^}}(void)(std::string_view()) /* a2 */;
+
+(void)(std::string_view({nullptr})) /* a3 */;
+// CHECK-MESSAGES: :[[@LINE-1]]:29: warning: constructing{{.*}}default
+// CHECK-FIXES: {{^}}(void)(std::string_view()) /* a3 */;
+
+(void)(std::string_view({(nullptr)})) /* a4 */;
+// CHECK-MESSAGES: :[[@LINE-1]]:29: warning: constructing{{.*}}default
+// CHECK-FIXES: {{^}}(void)(std::string_view()) /* a4 */;
+
+(void)(std::string_view({})) /* a5 */; // Default `const CharT*`
+// CHECK-MESSAGES: :[[@LINE-1]]:29: warning: constructing{{.*}}default
+// CHECK-FIXES: {{^}}(void)(std::string_view()) /* a5 */;
+
+// (void)(const std::string_view(nullptr)) /* a6 */;
+// CV qualifiers do not compile in this context
+
+// (void)(const std::string_view((nullptr))) /* a7 */;
+// CV qualifiers do not compile in this context
+
+// (void)(const std::string_view({nullptr})) /* a8 */;
+// CV qualifiers do not compile in this context
+
+// (void)(const std::string_view({(nullptr)})) /* a9 */;
+// CV qualifiers do not compile in this context
+
+// (void)(const std::string_view({})) /* a10 */; // Default `const CharT*`
+// CV qualifiers do not compile in this context
+  }
+
+  // Temporary Object
+  {
+(void)(std::string_view{nullptr}) /* a11 */;
+// CHECK-MESSAGES: :[[@LINE-1]]:29: warning: constructing{{.*}}default
+// CHECK-FIXES: {{^}}(void)(std::string_view{}) /* a11 */;
+
+(void)(std::string_view{(nullptr)}) /* a12 */;
+// CHECK-MESSAGES: :[[@LINE-1]]:29: warning: constructing{{.*}}default
+// CHECK-FIXES: {{^}}(void)(std::string_view

[PATCH] D113148: Add new clang-tidy check for string_view(nullptr)

2021-11-08 Thread CJ Johnson via Phabricator via cfe-commits
CJ-Johnson updated this revision to Diff 385532.
CJ-Johnson added a comment.

Rebase on head


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113148

Files:
  clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
  clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
  clang-tools-extra/clang-tidy/bugprone/StringviewNullptrCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/StringviewNullptrCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/bugprone-stringview-nullptr.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/test/clang-tidy/checkers/bugprone-stringview-nullptr.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-stringview-nullptr.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-stringview-nullptr.cpp
@@ -0,0 +1,1221 @@
+// RUN: %check_clang_tidy %s bugprone-stringview-nullptr -std=c++17 %t
+
+namespace std {
+
+using nullptr_t = decltype(nullptr);
+
+template 
+T &&declval();
+
+template 
+struct type_identity { using type = T; };
+template 
+using type_identity_t = typename type_identity::type;
+
+template 
+class basic_string_view {
+public:
+  basic_string_view();
+  basic_string_view(const C *);
+  basic_string_view(const basic_string_view &);
+  basic_string_view &operator=(const basic_string_view &);
+};
+
+template 
+bool operator<(basic_string_view, basic_string_view);
+template 
+bool operator<(type_identity_t>, basic_string_view);
+template 
+bool operator<(basic_string_view, type_identity_t>);
+
+template 
+bool operator<=(basic_string_view, basic_string_view);
+template 
+bool operator<=(type_identity_t>, basic_string_view);
+template 
+bool operator<=(basic_string_view, type_identity_t>);
+
+template 
+bool operator>(basic_string_view, basic_string_view);
+template 
+bool operator>(type_identity_t>, basic_string_view);
+template 
+bool operator>(basic_string_view, type_identity_t>);
+
+template 
+bool operator>=(basic_string_view, basic_string_view);
+template 
+bool operator>=(type_identity_t>, basic_string_view);
+template 
+bool operator>=(basic_string_view, type_identity_t>);
+
+template 
+bool operator==(basic_string_view, basic_string_view);
+template 
+bool operator==(type_identity_t>, basic_string_view);
+template 
+bool operator==(basic_string_view, type_identity_t>);
+
+template 
+bool operator!=(basic_string_view, basic_string_view);
+template 
+bool operator!=(type_identity_t>, basic_string_view);
+template 
+bool operator!=(basic_string_view, type_identity_t>);
+
+using string_view = basic_string_view;
+
+} // namespace std
+
+void function(std::string_view);
+void function(std::string_view, std::string_view);
+
+void temporary_construction() /* a */ {
+  // Functional Cast
+  {
+(void)(std::string_view(nullptr)) /* a1 */;
+// CHECK-MESSAGES: :[[@LINE-1]]:29: warning: constructing basic_string_view from null is undefined; replace with the default constructor
+// CHECK-FIXES: {{^}}(void)(std::string_view()) /* a1 */;
+
+(void)(std::string_view((nullptr))) /* a2 */;
+// CHECK-MESSAGES: :[[@LINE-1]]:29: warning: constructing{{.*}}default
+// CHECK-FIXES: {{^}}(void)(std::string_view()) /* a2 */;
+
+(void)(std::string_view({nullptr})) /* a3 */;
+// CHECK-MESSAGES: :[[@LINE-1]]:29: warning: constructing{{.*}}default
+// CHECK-FIXES: {{^}}(void)(std::string_view()) /* a3 */;
+
+(void)(std::string_view({(nullptr)})) /* a4 */;
+// CHECK-MESSAGES: :[[@LINE-1]]:29: warning: constructing{{.*}}default
+// CHECK-FIXES: {{^}}(void)(std::string_view()) /* a4 */;
+
+(void)(std::string_view({})) /* a5 */; // Default `const CharT*`
+// CHECK-MESSAGES: :[[@LINE-1]]:29: warning: constructing{{.*}}default
+// CHECK-FIXES: {{^}}(void)(std::string_view()) /* a5 */;
+
+// (void)(const std::string_view(nullptr)) /* a6 */;
+// CV qualifiers do not compile in this context
+
+// (void)(const std::string_view((nullptr))) /* a7 */;
+// CV qualifiers do not compile in this context
+
+// (void)(const std::string_view({nullptr})) /* a8 */;
+// CV qualifiers do not compile in this context
+
+// (void)(const std::string_view({(nullptr)})) /* a9 */;
+// CV qualifiers do not compile in this context
+
+// (void)(const std::string_view({})) /* a10 */; // Default `const CharT*`
+// CV qualifiers do not compile in this context
+  }
+
+  // Temporary Object
+  {
+(void)(std::string_view{nullptr}) /* a11 */;
+// CHECK-MESSAGES: :[[@LINE-1]]:29: warning: constructing{{.*}}default
+// CHECK-FIXES: {{^}}(void)(std::string_view{}) /* a11 */;
+
+(void)(std::string_view{(nullptr)}) /* a12 */;
+// CHECK-MESSAGES: :[[@LINE-1]]:29: warning: constructing{{.*}}default
+// CHECK-FIXES: {{^}}(void)(std::string_view{}) /

[PATCH] D113264: [clang] [DirectoryWatcher] Remove leading \\?\ from GetFinalPathNameByHandleW

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

LGTM, though I'd appreciate if you'd fix the clang-format issues when landing.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113264

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


[PATCH] D113269: [clang-move] Fix unit tests with forward slash as separator on windows

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

LGTM aside from commenting nit.




Comment at: clang-tools-extra/unittests/clang-move/ClangMoveTests.cpp:235
 
- // std::string IncludeArg = Twine("-I" + WorkingDir;
+ // std::string IncludeArg = Twine("-I" + Dir;
   tooling::runToolOnCodeWithArgs(

Might as well remove this comment entirely? I don't think it adds any value, it 
looks like debug code that was left in by accident.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113269

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


[PATCH] D111833: [clang] Fortify warning for scanf calls with field width too big.

2021-11-08 Thread Michael Benfield via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG2db66f8d48be: [clang] Fortify warning for scanf calls with 
field width too big. (authored by mbenfield).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111833

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaChecking.cpp
  clang/test/Sema/warn-fortify-scanf.c

Index: clang/test/Sema/warn-fortify-scanf.c
===
--- /dev/null
+++ clang/test/Sema/warn-fortify-scanf.c
@@ -0,0 +1,68 @@
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.14.0 %s -verify
+
+typedef struct _FILE FILE;
+extern int scanf(const char *format, ...);
+extern int fscanf(FILE *f, const char *format, ...);
+extern int sscanf(const char *input, const char *format, ...);
+
+void call_scanf() {
+  char buf10[10];
+  char buf20[20];
+  char buf30[30];
+  scanf("%4s %5s %10s", buf20, buf30, buf10); // expected-warning {{'scanf' may overflow; destination buffer in argument 4 has size 10, but the corresponding specifier may require size 11}}
+  scanf("%4s %5s %11s", buf20, buf30, buf10); // expected-warning {{'scanf' may overflow; destination buffer in argument 4 has size 10, but the corresponding specifier may require size 12}}
+  scanf("%4s %5s %9s", buf20, buf30, buf10);
+  scanf("%20s %5s %9s", buf20, buf30, buf10); // expected-warning {{'scanf' may overflow; destination buffer in argument 2 has size 20, but the corresponding specifier may require size 21}}
+  scanf("%21s %5s %9s", buf20, buf30, buf10); // expected-warning {{'scanf' may overflow; destination buffer in argument 2 has size 20, but the corresponding specifier may require size 22}}
+  scanf("%19s %5s %9s", buf20, buf30, buf10);
+  scanf("%19s %29s %9s", buf20, buf30, buf10);
+
+  scanf("%*21s %*30s %10s", buf10); // expected-warning {{'scanf' may overflow; destination buffer in argument 2 has size 10, but the corresponding specifier may require size 11}}
+  scanf("%*21s %5s", buf10);
+  scanf("%10s %*30s", buf10); // expected-warning {{'scanf' may overflow; destination buffer in argument 2 has size 10, but the corresponding specifier may require size 11}}
+  scanf("%9s %*30s", buf10);
+
+  scanf("%4[a] %5[a] %10[a]", buf20, buf30, buf10); // expected-warning {{'scanf' may overflow; destination buffer in argument 4 has size 10, but the corresponding specifier may require size 11}}
+  scanf("%4[a] %5[a] %11[a]", buf20, buf30, buf10); // expected-warning {{'scanf' may overflow; destination buffer in argument 4 has size 10, but the corresponding specifier may require size 12}}
+  scanf("%4[a] %5[a] %9[a]", buf20, buf30, buf10);
+  scanf("%20[a] %5[a] %9[a]", buf20, buf30, buf10); // expected-warning {{'scanf' may overflow; destination buffer in argument 2 has size 20, but the corresponding specifier may require size 21}}
+  scanf("%21[a] %5[a] %9[a]", buf20, buf30, buf10); // expected-warning {{'scanf' may overflow; destination buffer in argument 2 has size 20, but the corresponding specifier may require size 22}}
+  scanf("%19[a] %5[a] %9[a]", buf20, buf30, buf10);
+  scanf("%19[a] %29[a] %9[a]", buf20, buf30, buf10);
+
+  scanf("%4c %5c %10c", buf20, buf30, buf10);
+  scanf("%4c %5c %11c", buf20, buf30, buf10); // expected-warning {{'scanf' may overflow; destination buffer in argument 4 has size 10, but the corresponding specifier may require size 11}}
+  scanf("%4c %5c %9c", buf20, buf30, buf10);
+  scanf("%20c %5c %9c", buf20, buf30, buf10);
+  scanf("%21c %5c %9c", buf20, buf30, buf10); // expected-warning {{'scanf' may overflow; destination buffer in argument 2 has size 20, but the corresponding specifier may require size 21}}
+
+  // Don't warn for other specifiers.
+  int x;
+  scanf("%12d", &x);
+}
+
+void call_sscanf() {
+  char buf10[10];
+  char buf20[20];
+  char buf30[30];
+  sscanf("a b c", "%4s %5s %10s", buf20, buf30, buf10); // expected-warning {{'sscanf' may overflow; destination buffer in argument 5 has size 10, but the corresponding specifier may require size 11}}
+  sscanf("a b c", "%4s %5s %11s", buf20, buf30, buf10); // expected-warning {{'sscanf' may overflow; destination buffer in argument 5 has size 10, but the corresponding specifier may require size 12}}
+  sscanf("a b c", "%4s %5s %9s", buf20, buf30, buf10);
+  sscanf("a b c", "%20s %5s %9s", buf20, buf30, buf10); // expected-warning {{'sscanf' may overflow; destination buffer in argument 3 has size 20, but the corresponding specifier may require size 21}}
+  sscanf("a b c", "%21s %5s %9s", buf20, buf30, buf10); // expected-warning {{'sscanf' may overflow; destination buffer in argument 3 has size 20, but the corresponding specifier may require size 22}}
+  sscanf("a b c", "%19s %5s %9s", buf20, buf30, buf10);
+  sscanf("a b c", "%19s %29s %9s", buf20, buf30, buf10);
+}
+
+void call_fscanf() {
+  char buf10[10];
+  char buf20[20];
+  char 

[clang] 2db66f8 - [clang] Fortify warning for scanf calls with field width too big.

2021-11-08 Thread Michael Benfield via cfe-commits

Author: Michael Benfield
Date: 2021-11-08T17:43:51Z
New Revision: 2db66f8d48beeea835cb9a6940e25bc04ab5d941

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

LOG: [clang] Fortify warning for scanf calls with field width too big.

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

Added: 
clang/test/Sema/warn-fortify-scanf.c

Modified: 
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/Sema/SemaChecking.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 3f887309825a5..76d4f9286d371 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -833,6 +833,10 @@ def warn_fortify_source_format_overflow : Warning<
   " but format string expands to at least %2">,
   InGroup;
 
+def warn_fortify_scanf_overflow : Warning<
+  "'%0' may overflow; destination buffer in argument %1 has size "
+  "%2, but the corresponding specifier may require size %3">,
+  InGroup;
 
 /// main()
 // static main() is not an error in C, just in C++.

diff  --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index 172357be9d862..e7b2a118bdaf4 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -408,6 +408,64 @@ static bool SemaBuiltinCallWithStaticChain(Sema &S, 
CallExpr *BuiltinCall) {
 
 namespace {
 
+class ScanfDiagnosticFormatHandler
+: public analyze_format_string::FormatStringHandler {
+  // Accepts the argument index (relative to the first destination index) of 
the
+  // argument whose size we want.
+  using ComputeSizeFunction =
+  llvm::function_ref(unsigned)>;
+
+  // Accepts the argument index (relative to the first destination index), the
+  // destination size, and the source size).
+  using DiagnoseFunction =
+  llvm::function_ref;
+
+  ComputeSizeFunction ComputeSizeArgument;
+  DiagnoseFunction Diagnose;
+
+public:
+  ScanfDiagnosticFormatHandler(ComputeSizeFunction ComputeSizeArgument,
+   DiagnoseFunction Diagnose)
+  : ComputeSizeArgument(ComputeSizeArgument), Diagnose(Diagnose) {}
+
+  bool HandleScanfSpecifier(const analyze_scanf::ScanfSpecifier &FS,
+const char *StartSpecifier,
+unsigned specifierLen) override {
+if (!FS.consumesDataArgument())
+  return true;
+
+unsigned NulByte = 0;
+switch ((FS.getConversionSpecifier().getKind())) {
+default:
+  return true;
+case analyze_format_string::ConversionSpecifier::sArg:
+case analyze_format_string::ConversionSpecifier::ScanListArg:
+  NulByte = 1;
+  break;
+case analyze_format_string::ConversionSpecifier::cArg:
+  break;
+}
+
+auto OptionalFW = FS.getFieldWidth();
+if (OptionalFW.getHowSpecified() !=
+analyze_format_string::OptionalAmount::HowSpecified::Constant)
+  return true;
+
+unsigned SourceSize = OptionalFW.getConstantAmount() + NulByte;
+
+auto DestSizeAPS = ComputeSizeArgument(FS.getArgIndex());
+if (!DestSizeAPS)
+  return true;
+
+unsigned DestSize = DestSizeAPS->getZExtValue();
+
+if (DestSize < SourceSize)
+  Diagnose(FS.getArgIndex(), DestSize, SourceSize);
+
+return true;
+  }
+};
+
 class EstimateSizeFormatHandler
 : public analyze_format_string::FormatStringHandler {
   size_t Size;
@@ -615,9 +673,12 @@ void 
Sema::checkFortifiedBuiltinMemoryFunction(FunctionDecl *FD,
 // (potentially) more strict checking mode. Otherwise, conservatively 
assume
 // type 0.
 int BOSType = 0;
-if (const auto *POS =
-FD->getParamDecl(Index)->getAttr())
-  BOSType = POS->getType();
+// This check can fail for variadic functions.
+if (Index < FD->getNumParams()) {
+  if (const auto *POS =
+  FD->getParamDecl(Index)->getAttr())
+BOSType = POS->getType();
+}
 
 const Expr *ObjArg = TheCall->getArg(Index);
 uint64_t Result;
@@ -642,6 +703,20 @@ void 
Sema::checkFortifiedBuiltinMemoryFunction(FunctionDecl *FD,
   unsigned DiagID = 0;
   bool IsChkVariant = false;
 
+  auto GetFunctionName = [&]() {
+StringRef FunctionName = getASTContext().BuiltinInfo.getName(BuiltinID);
+// Skim off the details of whichever builtin was called to produce a better
+// diagnostic, as it's unlikely that the user wrote the __builtin
+// explicitly.
+if (IsChkVariant) {
+  FunctionName = FunctionName.drop_front(std::strlen("__builtin___"));
+  FunctionName = FunctionName.drop_back(std::strlen("_chk"));
+} else if (FunctionName.startswith("__builtin_")) {
+  FunctionName = FunctionName.drop_front(std::strlen("__builtin_"));
+}
+

[clang] 8d3b28e - [NFC] Fix lit test failures for clang/CodegenCoroutines

2021-11-08 Thread hyeongyu kim via cfe-commits

Author: hyeongyu kim
Date: 2021-11-09T02:47:16+09:00
New Revision: 8d3b28e7547aac842ed177050ac2a9d25de0f2e9

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

LOG: [NFC] Fix lit test failures for clang/CodegenCoroutines

Added: 


Modified: 
clang/test/CodeGenCoroutines/coro-await.cpp
clang/test/CodeGenCoroutines/coro-ret-void.cpp

Removed: 




diff  --git a/clang/test/CodeGenCoroutines/coro-await.cpp 
b/clang/test/CodeGenCoroutines/coro-await.cpp
index b2baf0964768..158d55323377 100644
--- a/clang/test/CodeGenCoroutines/coro-await.cpp
+++ b/clang/test/CodeGenCoroutines/coro-await.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -disable-noundef-analysis -triple x86_64-unknown-linux-gnu 
-std=c++20 \
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -std=c++20 \
 // RUN:   -emit-llvm %s -o - -disable-llvm-passes -Wno-coroutine -Wno-unused | 
FileCheck %s
 
 namespace std {

diff  --git a/clang/test/CodeGenCoroutines/coro-ret-void.cpp 
b/clang/test/CodeGenCoroutines/coro-ret-void.cpp
index 16d0c3ca2137..53b200df127b 100644
--- a/clang/test/CodeGenCoroutines/coro-ret-void.cpp
+++ b/clang/test/CodeGenCoroutines/coro-ret-void.cpp
@@ -48,4 +48,4 @@ coro2 g() {
 
 // CHECK-LABEL: define{{.*}} void @_Z1gv(
 // CHECK: call void 
@_ZNSt13suspend_never12await_resumeEv(%"struct.std::suspend_never"*
-// CHECK: call void 
@_ZN5coro212promise_type12return_valueEi(%"struct.coro2::promise_type"* 
{{[^,]*}} %__promise, i32 noundef 42)
\ No newline at end of file
+// CHECK: call void 
@_ZN5coro212promise_type12return_valueEi(%"struct.coro2::promise_type"* 
{{[^,]*}} %__promise, i32 42)
\ No newline at end of file



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


[PATCH] D113304: [NewPM] Only invalidate modified functions' analyses in CGSCC passes + turn on eagerly invalidate analyses

2021-11-08 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks added inline comments.



Comment at: llvm/lib/Transforms/IPO/FunctionAttrs.cpp:1845
+  if (auto *Call = dyn_cast(U))
+FAM.invalidate(*Call->getParent()->getParent(), FuncPA);
+}

nikic wrote:
> Do we need to worry about indirect references here, like a call through a 
> bitcast? For the ArgPromotion case that's not possible, but I'm not so sure 
> here.
I suppose it's possible for analyses to look at all references to other 
functions and look at attributes of those functions, but I can't really imagine 
that happening in practice. AFAICT everything that looks at function attributes 
only does so for direct calls.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113304

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


[PATCH] D113304: [NewPM] Only invalidate modified functions' analyses in CGSCC passes + turn on eagerly invalidate analyses

2021-11-08 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks updated this revision to Diff 385539.
aeubanks added a comment.

address comments
[argpromo] only invalidate direct callers that call the function, not if the 
function is a parameter


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113304

Files:
  clang/test/CodeGen/thinlto-distributed-newpm.ll
  llvm/lib/Analysis/CGSCCPassManager.cpp
  llvm/lib/Passes/PassBuilderPipelines.cpp
  llvm/lib/Transforms/IPO/ArgumentPromotion.cpp
  llvm/lib/Transforms/IPO/FunctionAttrs.cpp
  llvm/lib/Transforms/IPO/Inliner.cpp
  llvm/test/Other/new-pm-defaults.ll
  llvm/test/Other/new-pm-eager-invalidate.ll
  llvm/test/Other/new-pm-lto-defaults.ll
  llvm/test/Other/new-pm-pgo-preinline.ll
  llvm/test/Other/new-pm-thinlto-defaults.ll
  llvm/test/Other/new-pm-thinlto-postlink-pgo-defaults.ll
  llvm/test/Other/new-pm-thinlto-postlink-samplepgo-defaults.ll
  llvm/test/Other/new-pm-thinlto-prelink-pgo-defaults.ll
  llvm/test/Other/new-pm-thinlto-prelink-samplepgo-defaults.ll
  llvm/test/Transforms/FunctionAttrs/invalidate.ll
  llvm/test/Transforms/Inline/analysis-invalidation.ll
  llvm/test/Transforms/Inline/cgscc-incremental-invalidate.ll

Index: llvm/test/Transforms/Inline/cgscc-incremental-invalidate.ll
===
--- llvm/test/Transforms/Inline/cgscc-incremental-invalidate.ll
+++ llvm/test/Transforms/Inline/cgscc-incremental-invalidate.ll
@@ -8,11 +8,11 @@
 ;
 ; CHECK: Running pass: InlinerPass on (test1_f, test1_g, test1_h)
 ; CHECK: Running analysis: DominatorTreeAnalysis on test1_f
-; CHECK: Running analysis: DominatorTreeAnalysis on test1_g
 ; CHECK: Invalidating analysis: DominatorTreeAnalysis on test1_f
 ; CHECK: Invalidating analysis: LoopAnalysis on test1_f
 ; CHECK: Invalidating analysis: BranchProbabilityAnalysis on test1_f
 ; CHECK: Invalidating analysis: BlockFrequencyAnalysis on test1_f
+; CHECK: Running analysis: DominatorTreeAnalysis on test1_g
 ; CHECK: Invalidating analysis: DominatorTreeAnalysis on test1_g
 ; CHECK: Invalidating analysis: LoopAnalysis on test1_g
 ; CHECK: Invalidating analysis: BranchProbabilityAnalysis on test1_g
@@ -29,7 +29,6 @@
 ; CHECK-NEXT: Running analysis: DominatorTreeAnalysis on test1_h
 ; CHECK-NOT: Invalidating analysis:
 ; CHECK: Running pass: DominatorTreeVerifierPass on test1_f
-; CHECK-NEXT: Running analysis: DominatorTreeAnalysis on test1_f
 
 ; An external function used to control branches.
 declare i1 @flag()
Index: llvm/test/Transforms/Inline/analysis-invalidation.ll
===
--- /dev/null
+++ llvm/test/Transforms/Inline/analysis-invalidation.ll
@@ -0,0 +1,17 @@
+; RUN: opt -passes=inline < %s -disable-output -debug-pass-manager 2>&1 | FileCheck %s
+
+; We shouldn't invalidate any function analyses on g since it's never modified.
+
+; CHECK-NOT: Invalidating{{.*}} on g
+; CHECK: Invalidating{{.*}} on f
+; CHECK-NOT: Invalidating{{.*}} on g
+
+define void @f() noinline {
+  call void @g()
+  ret void
+}
+
+define void @g() alwaysinline {
+  call void @f()
+  ret void
+}
Index: llvm/test/Transforms/FunctionAttrs/invalidate.ll
===
--- /dev/null
+++ llvm/test/Transforms/FunctionAttrs/invalidate.ll
@@ -0,0 +1,25 @@
+; RUN: opt -passes='function(require),cgscc(function-attrs)' -disable-output < %s -debug-pass-manager 2>&1 | FileCheck %s
+
+; CHECK: Running pass: PostOrderFunctionAttrsPass on (f)
+; CHECK: Invalidating analysis: NoOpFunctionAnalysis on f
+; CHECK-NOT: Invalidating analysis: NoOpFunctionAnalysis on h
+; CHECK: Invalidating analysis: NoOpFunctionAnalysis on g
+; CHECK-NOT: Invalidating analysis: NoOpFunctionAnalysis on h
+; CHECK: Running pass: PostOrderFunctionAttrsPass on (g)
+; CHECK: Running pass: PostOrderFunctionAttrsPass on (h)
+
+declare i32 @e(i32(i32)*)
+
+define i32 @f(i32 %a) {
+  ret i32 %a
+}
+
+define i32 @g(i32 %b) {
+  %c = call i32 @f(i32 %b)
+  ret i32 %c
+}
+
+define i32 @h(i32 %b) {
+  %c = call i32 @e(i32(i32)* @f)
+  ret i32 %c
+}
Index: llvm/test/Other/new-pm-thinlto-prelink-samplepgo-defaults.ll
===
--- llvm/test/Other/new-pm-thinlto-prelink-samplepgo-defaults.ll
+++ llvm/test/Other/new-pm-thinlto-prelink-samplepgo-defaults.ll
@@ -1,26 +1,26 @@
 ; Validate ThinLTO prelink pipeline when we have Sample PGO
 ;
-; RUN: opt -disable-verify -verify-cfg-preserved=0 -debug-pass-manager \
+; RUN: opt -disable-verify -verify-cfg-preserved=0 -eagerly-invalidate-analyses=0 -debug-pass-manager \
 ; RUN: -pgo-kind=pgo-sample-use-pipeline -profile-file='%S/Inputs/new-pm-thinlto-samplepgo-defaults.prof' \
 ; RUN: -passes='thinlto-pre-link' -S %s 2>&1 \
 ; RUN: | FileCheck %s --check-prefixes=CHECK-O,CHECK-O1
-; RUN: opt -disable-verify -verify-cfg-preserved=0 -debug-pass-manager \
+; RUN: opt -disable-verify -veri

[PATCH] D112868: [Sema] Diagnose and reject non-function ifunc resolvers

2021-11-08 Thread Itay Bookstein via Phabricator via cfe-commits
ibookstein updated this revision to Diff 385541.
ibookstein added a comment.

clang-format + fastforward rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112868

Files:
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/test/Sema/attr-ifunc.c

Index: clang/test/Sema/attr-ifunc.c
===
--- clang/test/Sema/attr-ifunc.c
+++ clang/test/Sema/attr-ifunc.c
@@ -13,8 +13,7 @@
 void f1() __attribute__((ifunc("f1_ifunc")));
 //expected-error@-1 {{ifunc must point to a defined function}}
 
-void* f2_a() __attribute__((ifunc("f2_b")));
-//expected-error@-1 {{ifunc definition is part of a cycle}}
+void *f2_a() __attribute__((alias("f2_b")));
 void* f2_b() __attribute__((ifunc("f2_a")));
 //expected-error@-1 {{ifunc definition is part of a cycle}}
 
@@ -27,6 +26,15 @@
 void f4() __attribute__((ifunc("f4_ifunc")));
 //expected-error@-1 {{ifunc resolver function must return a pointer}}
 
+int f5_resolver_gvar;
+void f5() __attribute__((ifunc("f5_resolver_gvar")));
+// expected-error@-1 {{ifunc must point to a defined function}}
+
+void *f6_resolver_resolver() { return 0; }
+void *f6_resolver() __attribute__((ifunc("f6_resolver_resolver")));
+void f6() __attribute__((ifunc("f6_resolver")));
+// expected-error@-1 {{ifunc must point to a defined function}}
+
 #else
 void f1a() __asm("f1");
 void f1a() {}
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -318,21 +318,57 @@
 // This is only used in aliases that we created and we know they have a
 // linear structure.
 static const llvm::GlobalValue *getAliasedGlobal(const llvm::GlobalValue *GV) {
-  llvm::SmallPtrSet Visited;
-  for (;;) {
-if (!GV || !Visited.insert(GV).second)
-  return nullptr;
-
-const llvm::Constant *C;
-if (auto *GA = dyn_cast(GV))
-  C = GA->getAliasee();
-else if (auto *GI = dyn_cast(GV))
-  C = GI->getResolver();
-else
-  return GV;
+  const llvm::Constant *C;
+  if (auto *GA = dyn_cast(GV))
+C = GA->getAliasee();
+  else if (auto *GI = dyn_cast(GV))
+C = GI->getResolver();
+  else
+return GV;
+
+  const auto *AliaseeGV = dyn_cast(C->stripPointerCasts());
+  if (!AliaseeGV)
+return nullptr;
+
+  const llvm::GlobalValue *FinalGV = AliaseeGV->getAliaseeObject();
+  if (FinalGV == GV)
+return nullptr;
+
+  return FinalGV;
+}
+
+static bool checkAliasedGlobal(DiagnosticsEngine &Diags,
+   SourceLocation Location, bool IsIFunc,
+   const llvm::GlobalValue *Alias,
+   const llvm::GlobalValue *&GV) {
+  GV = getAliasedGlobal(Alias);
+  if (!GV) {
+Diags.Report(Location, diag::err_cyclic_alias) << IsIFunc;
+return false;
+  }
+
+  if (GV->isDeclaration()) {
+Diags.Report(Location, diag::err_alias_to_undefined) << IsIFunc << IsIFunc;
+return false;
+  }
+
+  if (IsIFunc) {
+// Check resolver function type.
+const auto *F = dyn_cast(GV);
+if (!F) {
+  Diags.Report(Location, diag::err_alias_to_undefined)
+  << IsIFunc << IsIFunc;
+  return false;
+}
 
-GV = dyn_cast(C->stripPointerCasts());
+llvm::FunctionType *FTy = F->getFunctionType();
+if (!FTy->getReturnType()->isPointerTy()) {
+  Diags.Report(Location, diag::err_ifunc_resolver_return);
+  return false;
+}
   }
+
+  return true;
 }
 
 void CodeGenModule::checkAliases() {
@@ -349,23 +385,13 @@
   Location = A->getLocation();
 else
   llvm_unreachable("Not an alias or ifunc?");
+
 StringRef MangledName = getMangledName(GD);
 llvm::GlobalValue *Alias = GetGlobalValue(MangledName);
-const llvm::GlobalValue *GV = getAliasedGlobal(Alias);
-if (!GV) {
-  Error = true;
-  Diags.Report(Location, diag::err_cyclic_alias) << IsIFunc;
-} else if (GV->isDeclaration()) {
+const llvm::GlobalValue *GV = nullptr;
+if (!checkAliasedGlobal(Diags, Location, IsIFunc, Alias, GV)) {
   Error = true;
-  Diags.Report(Location, diag::err_alias_to_undefined)
-  << IsIFunc << IsIFunc;
-} else if (IsIFunc) {
-  // Check resolver function type.
-  llvm::FunctionType *FTy = dyn_cast(
-  GV->getType()->getPointerElementType());
-  assert(FTy);
-  if (!FTy->getReturnType()->isPointerTy())
-Diags.Report(Location, diag::err_ifunc_resolver_return);
+  continue;
 }
 
 llvm::Constant *Aliasee =
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D112890: headers: optionalise some generated resource headers

2021-11-08 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd added a comment.

@craig.topper - ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112890

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


  1   2   >