[PATCH] D102094: [AIX][PowerPC] Remove error when specifying mabi=vec-default on AIX

2021-05-10 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 added inline comments.



Comment at: clang/lib/Frontend/CompilerInvocation.cpp:1854
 const Option &O = A->getOption();
-if (O.matches(OPT_mabi_EQ_vec_default))
-  Diags.Report(diag::err_aix_default_altivec_abi)
-  << A->getSpelling() << T.str();
-else {
-  assert(O.matches(OPT_mabi_EQ_vec_extabi));
+if (O.matches(OPT_mabi_EQ_vec_extabi))
   Opts.EnableAIXExtendedAltivecABI = 1;

Can we simplify this to `Opts.EnableAIXExtendedAltivecABI = 
O.matches(OPT_mabi_EQ_vec_extabi);`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102094

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


[PATCH] D101608: [WebAssembly] Support for WebAssembly globals in LLVM IR

2021-05-10 Thread Andy Wingo via Phabricator via cfe-commits
wingo added inline comments.



Comment at: llvm/lib/Target/WebAssembly/Utils/WebAssemblyUtilities.h:39
+  // pointers are lowered to global.get / global.set or local.get / local.set,
+  // as appropriate.
+  WASM_ADDRESS_SPACE_MANAGED = 1

sunfish wrote:
> tlively wrote:
> > sunfish wrote:
> > > tlively wrote:
> > > > sunfish wrote:
> > > > > Sorry to throw more paint at the bikeshed here, but as someone who's 
> > > > > only following along at a high-level here, I found it confusing 
> > > > > whether this is talking about the wasm globals themselves, or the 
> > > > > objects referred to by reference values in the wasm globals. I think 
> > > > > the feature here is talking about the wasm globals themselves, but 
> > > > > "managed" initially made me think it might be talking about the 
> > > > > objects they reference, which in a browser context especially are 
> > > > > "managed" in every sense of the word.
> > > > Fair point. What does everyone think about `INDEXED`, because it is 
> > > > used to represent objects given static indexes (in the WebAssembly 
> > > > sense) in the final binary.
> > > Do I understand correctly that global variables and local variables are 
> > > being assigned addresses within the same conceptual address space here?
> > > 
> > > How about `WASM_VARIABLES` or `WASM_VARS`? The wasm spec terms for these 
> > > are global variables and local variables.
> > > 
> > > 
> > Sure, that works for me. We may want to rename it in the future if we end 
> > up using the same address space for tables and memories, but we can cross 
> > that bridge when we get there.
> Tables and memories have their own index spaces in wasm, so it seems like 
> they'd want their own address spaces here, perhaps 2 and 3, respectively? I 
> also agree that we can figure this out later.
`WASM_VARS` is fine with me, with one caveat -- in 
https://reviews.llvm.org/D101140  where we add support for locals, we add a new 
"core" TargetStackID enum which describes static `alloca` that is actually a 
wasm local.  Really this enum describes objects allocated on a parallel stack, 
outside of linear memory.  It was nice to use the same name to describe the 
address space and the stack id, but I don't think `variable` or `wasm-var` are 
good core enum names.  It feels like there is a core concept here for systems 
that have two stacks -- one of named objects and one of linear-memory bytes.  I 
thought `object` or `managed` could be a good name for the former, but 
evidently not :)

I will let this one sit overnight; if there are no other good ideas before 
tomorrow I will do `WASM_ADDRESS_SPACE_WASM_VARS` and either find a new name 
for `TargetStackID` or attempt to use a target-specific definition.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101608

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


[clang] c711aa0 - [amdgpu-arch] Guard hsa.h with __has_include

2021-05-10 Thread Pushpinder Singh via cfe-commits

Author: Pushpinder Singh
Date: 2021-05-10T07:33:30Z
New Revision: c711aa0f6f9d9400fbe619c7f0d6d4aa723b3a64

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

LOG: [amdgpu-arch] Guard hsa.h with __has_include

This patch is suppose to fix the issue of hsa.h not found.
Issue was reported in D99949

Reviewed By: JonChesterfield

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

Added: 


Modified: 
clang/tools/amdgpu-arch/AMDGPUArch.cpp

Removed: 




diff  --git a/clang/tools/amdgpu-arch/AMDGPUArch.cpp 
b/clang/tools/amdgpu-arch/AMDGPUArch.cpp
index 29f9c8bc23974..4fae78b4f121c 100644
--- a/clang/tools/amdgpu-arch/AMDGPUArch.cpp
+++ b/clang/tools/amdgpu-arch/AMDGPUArch.cpp
@@ -11,7 +11,24 @@
 //
 
//===--===//
 
-#include 
+#if defined(__has_include)
+#if __has_include("hsa.h")
+#define HSA_HEADER_FOUND 1
+#include "hsa.h"
+#elif __has_include("hsa/hsa.h")
+#define HSA_HEADER_FOUND 1
+#include "hsa/hsa.h"
+#else
+#define HSA_HEADER_FOUND 0
+#endif
+#else
+#define HSA_HEADER_FOUND 0
+#endif
+
+#if !HSA_HEADER_FOUND
+int main() { return 1; }
+#else
+
 #include 
 #include 
 
@@ -57,3 +74,5 @@ int main() {
   hsa_shut_down();
   return 0;
 }
+
+#endif



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


[PATCH] D102067: [amdgpu-arch] Guard hsa.h with __has_include

2021-05-10 Thread Pushpinder Singh via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc711aa0f6f9d: [amdgpu-arch] Guard hsa.h with __has_include 
(authored by pdhaliwal).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102067

Files:
  clang/tools/amdgpu-arch/AMDGPUArch.cpp


Index: clang/tools/amdgpu-arch/AMDGPUArch.cpp
===
--- clang/tools/amdgpu-arch/AMDGPUArch.cpp
+++ clang/tools/amdgpu-arch/AMDGPUArch.cpp
@@ -11,7 +11,24 @@
 //
 
//===--===//
 
-#include 
+#if defined(__has_include)
+#if __has_include("hsa.h")
+#define HSA_HEADER_FOUND 1
+#include "hsa.h"
+#elif __has_include("hsa/hsa.h")
+#define HSA_HEADER_FOUND 1
+#include "hsa/hsa.h"
+#else
+#define HSA_HEADER_FOUND 0
+#endif
+#else
+#define HSA_HEADER_FOUND 0
+#endif
+
+#if !HSA_HEADER_FOUND
+int main() { return 1; }
+#else
+
 #include 
 #include 
 
@@ -57,3 +74,5 @@
   hsa_shut_down();
   return 0;
 }
+
+#endif


Index: clang/tools/amdgpu-arch/AMDGPUArch.cpp
===
--- clang/tools/amdgpu-arch/AMDGPUArch.cpp
+++ clang/tools/amdgpu-arch/AMDGPUArch.cpp
@@ -11,7 +11,24 @@
 //
 //===--===//
 
-#include 
+#if defined(__has_include)
+#if __has_include("hsa.h")
+#define HSA_HEADER_FOUND 1
+#include "hsa.h"
+#elif __has_include("hsa/hsa.h")
+#define HSA_HEADER_FOUND 1
+#include "hsa/hsa.h"
+#else
+#define HSA_HEADER_FOUND 0
+#endif
+#else
+#define HSA_HEADER_FOUND 0
+#endif
+
+#if !HSA_HEADER_FOUND
+int main() { return 1; }
+#else
+
 #include 
 #include 
 
@@ -57,3 +74,5 @@
   hsa_shut_down();
   return 0;
 }
+
+#endif
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 7f78e40 - [AMDGPU][OpenMP] Emit textual IR for -emit-llvm -S

2021-05-10 Thread Pushpinder Singh via cfe-commits

Author: Pushpinder Singh
Date: 2021-05-10T07:54:23Z
New Revision: 7f78e409d0280c62209e1a7dc8c6d1409acc9184

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

LOG: [AMDGPU][OpenMP] Emit textual IR for -emit-llvm -S

Previously clang would print a binary blob into the bundled file
for amdgcn. With this patch, it will instead print textual IR as
expected.

Reviewed By: JonChesterfield

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/Driver/amdgpu-openmp-toolchain.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 2b3934fc25418..97a92e69419fa 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -4394,7 +4394,13 @@ void Clang::ConstructJob(Compilation &C, const JobAction 
&JA,
   CmdArgs.push_back("-emit-llvm");
 } else if (JA.getType() == types::TY_LLVM_BC ||
JA.getType() == types::TY_LTO_BC) {
-  CmdArgs.push_back("-emit-llvm-bc");
+  // Emit textual llvm IR for AMDGPU offloading for -emit-llvm -S
+  if (Triple.isAMDGCN() && IsOpenMPDevice) {
+if (Args.hasArg(options::OPT_S) && Args.hasArg(options::OPT_emit_llvm))
+  CmdArgs.push_back("-emit-llvm");
+  } else {
+CmdArgs.push_back("-emit-llvm-bc");
+  }
 } else if (JA.getType() == types::TY_IFS ||
JA.getType() == types::TY_IFS_CPP) {
   StringRef ArgStr =

diff  --git a/clang/test/Driver/amdgpu-openmp-toolchain.c 
b/clang/test/Driver/amdgpu-openmp-toolchain.c
index 5f2bdff549607..12067c4c0739d 100644
--- a/clang/test/Driver/amdgpu-openmp-toolchain.c
+++ b/clang/test/Driver/amdgpu-openmp-toolchain.c
@@ -71,3 +71,6 @@
 // CHECK-C: "x86_64-unknown-linux-gnu" - "clang"
 // CHECK-C: "x86_64-unknown-linux-gnu" - "clang::as"
 // CHECK-C: "x86_64-unknown-linux-gnu" - "offload bundler"
+
+// RUN:   %clang -### --target=x86_64-unknown-linux-gnu -emit-llvm -S -fopenmp 
-fopenmp-targets=amdgcn-amd-amdhsa -Xopenmp-target=amdgcn-amd-amdhsa 
-march=gfx803 -nogpulib %s 2>&1 | FileCheck %s --check-prefix=CHECK-EMIT-LLVM-IR
+// CHECK-EMIT-LLVM-IR: {{.*}}clang-13" "-cc1" "-triple" 
"amdgcn-amd-amdhsa"{{.*}}"-emit-llvm"



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


[PATCH] D102065: [AMDGPU][OpenMP] Emit textual IR for -emit-llvm -S

2021-05-10 Thread Pushpinder Singh 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 rG7f78e409d028: [AMDGPU][OpenMP] Emit textual IR for 
-emit-llvm -S (authored by pdhaliwal).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102065

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/amdgpu-openmp-toolchain.c


Index: clang/test/Driver/amdgpu-openmp-toolchain.c
===
--- clang/test/Driver/amdgpu-openmp-toolchain.c
+++ clang/test/Driver/amdgpu-openmp-toolchain.c
@@ -71,3 +71,6 @@
 // CHECK-C: "x86_64-unknown-linux-gnu" - "clang"
 // CHECK-C: "x86_64-unknown-linux-gnu" - "clang::as"
 // CHECK-C: "x86_64-unknown-linux-gnu" - "offload bundler"
+
+// RUN:   %clang -### --target=x86_64-unknown-linux-gnu -emit-llvm -S -fopenmp 
-fopenmp-targets=amdgcn-amd-amdhsa -Xopenmp-target=amdgcn-amd-amdhsa 
-march=gfx803 -nogpulib %s 2>&1 | FileCheck %s --check-prefix=CHECK-EMIT-LLVM-IR
+// CHECK-EMIT-LLVM-IR: {{.*}}clang-13" "-cc1" "-triple" 
"amdgcn-amd-amdhsa"{{.*}}"-emit-llvm"
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -4394,7 +4394,13 @@
   CmdArgs.push_back("-emit-llvm");
 } else if (JA.getType() == types::TY_LLVM_BC ||
JA.getType() == types::TY_LTO_BC) {
-  CmdArgs.push_back("-emit-llvm-bc");
+  // Emit textual llvm IR for AMDGPU offloading for -emit-llvm -S
+  if (Triple.isAMDGCN() && IsOpenMPDevice) {
+if (Args.hasArg(options::OPT_S) && Args.hasArg(options::OPT_emit_llvm))
+  CmdArgs.push_back("-emit-llvm");
+  } else {
+CmdArgs.push_back("-emit-llvm-bc");
+  }
 } else if (JA.getType() == types::TY_IFS ||
JA.getType() == types::TY_IFS_CPP) {
   StringRef ArgStr =


Index: clang/test/Driver/amdgpu-openmp-toolchain.c
===
--- clang/test/Driver/amdgpu-openmp-toolchain.c
+++ clang/test/Driver/amdgpu-openmp-toolchain.c
@@ -71,3 +71,6 @@
 // CHECK-C: "x86_64-unknown-linux-gnu" - "clang"
 // CHECK-C: "x86_64-unknown-linux-gnu" - "clang::as"
 // CHECK-C: "x86_64-unknown-linux-gnu" - "offload bundler"
+
+// RUN:   %clang -### --target=x86_64-unknown-linux-gnu -emit-llvm -S -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa -Xopenmp-target=amdgcn-amd-amdhsa -march=gfx803 -nogpulib %s 2>&1 | FileCheck %s --check-prefix=CHECK-EMIT-LLVM-IR
+// CHECK-EMIT-LLVM-IR: {{.*}}clang-13" "-cc1" "-triple" "amdgcn-amd-amdhsa"{{.*}}"-emit-llvm"
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -4394,7 +4394,13 @@
   CmdArgs.push_back("-emit-llvm");
 } else if (JA.getType() == types::TY_LLVM_BC ||
JA.getType() == types::TY_LTO_BC) {
-  CmdArgs.push_back("-emit-llvm-bc");
+  // Emit textual llvm IR for AMDGPU offloading for -emit-llvm -S
+  if (Triple.isAMDGCN() && IsOpenMPDevice) {
+if (Args.hasArg(options::OPT_S) && Args.hasArg(options::OPT_emit_llvm))
+  CmdArgs.push_back("-emit-llvm");
+  } else {
+CmdArgs.push_back("-emit-llvm-bc");
+  }
 } else if (JA.getType() == types::TY_IFS ||
JA.getType() == types::TY_IFS_CPP) {
   StringRef ArgStr =
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D102069: [clang][PreProcessor] Cutoff parsing after hitting completion point

2021-05-10 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 343993.
kadircet added a comment.

- Fix typo in comment
- Handle the \#elif case too.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102069

Files:
  clang/lib/Lex/PPDirectives.cpp
  clang/test/CodeCompletion/crash-if-directive.cpp


Index: clang/test/CodeCompletion/crash-if-directive.cpp
===
--- /dev/null
+++ clang/test/CodeCompletion/crash-if-directive.cpp
@@ -0,0 +1,6 @@
+#define FOO(X) X
+#if FOO(
+#elif FOO(
+#endif
+// RUN: not %clang_cc1 -fsyntax-only -code-completion-at=%s:2:9 %s
+// RUN: not %clang_cc1 -fsyntax-only -code-completion-at=%s:3:11 %s
Index: clang/lib/Lex/PPDirectives.cpp
===
--- clang/lib/Lex/PPDirectives.cpp
+++ clang/lib/Lex/PPDirectives.cpp
@@ -595,6 +595,9 @@
   CurPPLexer->LexingRawMode = false;
   IdentifierInfo *IfNDefMacro = nullptr;
   DirectiveEvalResult DER = EvaluateDirectiveExpression(IfNDefMacro);
+  // Stop if Lexer became invalid after hitting code completion token.
+  if (!CurPPLexer)
+return;
   const bool CondValue = DER.Conditional;
   CurPPLexer->LexingRawMode = true;
   if (Callbacks) {
@@ -3023,6 +3026,10 @@
   IdentifierInfo *IfNDefMacro = nullptr;
   const DirectiveEvalResult DER = EvaluateDirectiveExpression(IfNDefMacro);
   const bool ConditionalTrue = DER.Conditional;
+  // Lexer might become invalid if we hit code completion point while 
evaluating
+  // expression.
+  if (!CurPPLexer)
+return;
 
   // If this condition is equivalent to #ifndef X, and if this is the first
   // directive seen, handle it for the multiple-include optimization.


Index: clang/test/CodeCompletion/crash-if-directive.cpp
===
--- /dev/null
+++ clang/test/CodeCompletion/crash-if-directive.cpp
@@ -0,0 +1,6 @@
+#define FOO(X) X
+#if FOO(
+#elif FOO(
+#endif
+// RUN: not %clang_cc1 -fsyntax-only -code-completion-at=%s:2:9 %s
+// RUN: not %clang_cc1 -fsyntax-only -code-completion-at=%s:3:11 %s
Index: clang/lib/Lex/PPDirectives.cpp
===
--- clang/lib/Lex/PPDirectives.cpp
+++ clang/lib/Lex/PPDirectives.cpp
@@ -595,6 +595,9 @@
   CurPPLexer->LexingRawMode = false;
   IdentifierInfo *IfNDefMacro = nullptr;
   DirectiveEvalResult DER = EvaluateDirectiveExpression(IfNDefMacro);
+  // Stop if Lexer became invalid after hitting code completion token.
+  if (!CurPPLexer)
+return;
   const bool CondValue = DER.Conditional;
   CurPPLexer->LexingRawMode = true;
   if (Callbacks) {
@@ -3023,6 +3026,10 @@
   IdentifierInfo *IfNDefMacro = nullptr;
   const DirectiveEvalResult DER = EvaluateDirectiveExpression(IfNDefMacro);
   const bool ConditionalTrue = DER.Conditional;
+  // Lexer might become invalid if we hit code completion point while evaluating
+  // expression.
+  if (!CurPPLexer)
+return;
 
   // If this condition is equivalent to #ifndef X, and if this is the first
   // directive seen, handle it for the multiple-include optimization.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D102069: [clang][PreProcessor] Cutoff parsing after hitting completion point

2021-05-10 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 343996.
kadircet added a comment.

- Fix lit


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102069

Files:
  clang/lib/Lex/PPDirectives.cpp
  clang/test/CodeCompletion/crash-if-directive.cpp


Index: clang/test/CodeCompletion/crash-if-directive.cpp
===
--- /dev/null
+++ clang/test/CodeCompletion/crash-if-directive.cpp
@@ -0,0 +1,6 @@
+#define FOO(X) X
+#if FOO(
+#elif FOO(
+#endif
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:2:9 %s
+// RUN: not %clang_cc1 -fsyntax-only -code-completion-at=%s:3:11 %s
Index: clang/lib/Lex/PPDirectives.cpp
===
--- clang/lib/Lex/PPDirectives.cpp
+++ clang/lib/Lex/PPDirectives.cpp
@@ -595,6 +595,9 @@
   CurPPLexer->LexingRawMode = false;
   IdentifierInfo *IfNDefMacro = nullptr;
   DirectiveEvalResult DER = EvaluateDirectiveExpression(IfNDefMacro);
+  // Stop if Lexer became invalid after hitting code completion token.
+  if (!CurPPLexer)
+return;
   const bool CondValue = DER.Conditional;
   CurPPLexer->LexingRawMode = true;
   if (Callbacks) {
@@ -3023,6 +3026,10 @@
   IdentifierInfo *IfNDefMacro = nullptr;
   const DirectiveEvalResult DER = EvaluateDirectiveExpression(IfNDefMacro);
   const bool ConditionalTrue = DER.Conditional;
+  // Lexer might become invalid if we hit code completion point while 
evaluating
+  // expression.
+  if (!CurPPLexer)
+return;
 
   // If this condition is equivalent to #ifndef X, and if this is the first
   // directive seen, handle it for the multiple-include optimization.


Index: clang/test/CodeCompletion/crash-if-directive.cpp
===
--- /dev/null
+++ clang/test/CodeCompletion/crash-if-directive.cpp
@@ -0,0 +1,6 @@
+#define FOO(X) X
+#if FOO(
+#elif FOO(
+#endif
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:2:9 %s
+// RUN: not %clang_cc1 -fsyntax-only -code-completion-at=%s:3:11 %s
Index: clang/lib/Lex/PPDirectives.cpp
===
--- clang/lib/Lex/PPDirectives.cpp
+++ clang/lib/Lex/PPDirectives.cpp
@@ -595,6 +595,9 @@
   CurPPLexer->LexingRawMode = false;
   IdentifierInfo *IfNDefMacro = nullptr;
   DirectiveEvalResult DER = EvaluateDirectiveExpression(IfNDefMacro);
+  // Stop if Lexer became invalid after hitting code completion token.
+  if (!CurPPLexer)
+return;
   const bool CondValue = DER.Conditional;
   CurPPLexer->LexingRawMode = true;
   if (Callbacks) {
@@ -3023,6 +3026,10 @@
   IdentifierInfo *IfNDefMacro = nullptr;
   const DirectiveEvalResult DER = EvaluateDirectiveExpression(IfNDefMacro);
   const bool ConditionalTrue = DER.Conditional;
+  // Lexer might become invalid if we hit code completion point while evaluating
+  // expression.
+  if (!CurPPLexer)
+return;
 
   // If this condition is equivalent to #ifndef X, and if this is the first
   // directive seen, handle it for the multiple-include optimization.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D101873: [clang] Support clang -fpic -fno-semantic-interposition for AArch64

2021-05-10 Thread Peter Smith via Phabricator via cfe-commits
peter.smith accepted this revision.
peter.smith added a comment.
This revision is now accepted and ready to land.

LGTM as this is opt in with a command line option.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101873

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


[PATCH] D101239: [clang-tidy] Enable the use of IgnoreArray flag in pro-type-member-init rule

2021-05-10 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment.

In D101239#2746675 , @h-joo wrote:

> In D101239#2746644 , @njames93 
> wrote:
>
>> LGTM, thanks.
>
> @njames93, I appreciate your time for the review.  May I ask one more thing? 
> I do not have commit rights. Would it be possible for you to make the commit? 
> Thank you!!

No problem, Can you please provide your GitHub username and email so I can mark 
you as the author of the patch.


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

https://reviews.llvm.org/D101239

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


[PATCH] D102069: [clang][PreProcessor] Cutoff parsing after hitting completion point

2021-05-10 Thread Haojian Wu via Phabricator via cfe-commits
hokein accepted this revision.
hokein added a comment.
This revision is now accepted and ready to land.

thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102069

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


[PATCH] D101239: [clang-tidy] Enable the use of IgnoreArray flag in pro-type-member-init rule

2021-05-10 Thread Hana Joo via Phabricator via cfe-commits
h-joo added a comment.

In D101239#2747370 , @njames93 wrote:

> In D101239#2746675 , @h-joo wrote:
>
>> In D101239#2746644 , @njames93 
>> wrote:
>>
>>> LGTM, thanks.
>>
>> @njames93, I appreciate your time for the review.  May I ask one more thing? 
>> I do not have commit rights. Would it be possible for you to make the 
>> commit? Thank you!!
>
> No problem, Can you please provide your GitHub username and email so I can 
> mark you as the author of the patch.

My username is `Hana Joo` and email is `hana...@google.com`, thank you for your 
help!


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

https://reviews.llvm.org/D101239

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


[PATCH] D91949: [clang-format] Add BeforeStructInitialization option in BraceWrapping configuration

2021-05-10 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir added a comment.

Do we have some widely used code style that requires the new option 
(https://clang.llvm.org/docs/ClangFormatStyleOptions.html#adding-additional-style-options)?
I agree with @MyDeveloperDay that this option as-is is likely not addressing 
all the cases where we would want this to apply.

I don't think we should later be adding something like `BreakBeforeClassInit` 
-- IMO whichever mechanism is used to control `struct` cases should also apply 
to `class` cases (modulo commonly used style guide rules).

Note that there is a big difference in context between this and, e.g., 
`AfterStruct`: when you're defining a `struct`, generally the struct keyword is 
required, and that's why the check `Line.startsWith(tok::kw_struct)` in that 
context is appropriate. In the context of initialization this is not the case, 
so, as a user I'd expect `BreakBeforeStructInit` to work in cases like this 
where the `struct` keyword is not present:

  struct point {
int x, y;
  };
  
  int f() {
// here:
point p =
{
  x = 1,
  y = 2,
};
  }

Since clang-format doesn't really do any semantic analysis, it might be more 
appropriate to generalize this concept in a way that more closely matches the 
C++ syntax structures, e.g., to something that controls the breaking behavior 
before `{` in appropriate cases of some copy-list-initialization forms 
(https://en.cppreference.com/w/cpp/language/list_initialization), but without 
some style guide to drive the design it's hard to tell what would make sense.




Comment at: clang/unittests/Format/FormatTest.cpp:5063
+   "a = 1,\n"
+   "b = 2,\n"
+   "};",

anastasiia_lukianenko wrote:
> MyDeveloperDay wrote:
> > anastasiia_lukianenko wrote:
> > > MyDeveloperDay wrote:
> > > > could you add an additional test without the trailing `,`
> > > Yes, I can add the test, but before I want to discuss the expected result.
> > > Now with my patch and BeforeStructInitialization = false the behavior is 
> > > the following:
> > > 
> > > ```
> > > struct new_struct struct_name = {a = 1};
> > > struct new_struct struct_name = {a = 1, b = 2};
> > > ```
> > > And with BeforeStructInitialization = true:
> > > 
> > > ```
> > > struct new_struct struct_name =
> > > {a = 1};
> > > struct new_struct struct_name =
> > > {a = 1, b = 2};
> > > ```
> > > Is it okay?
> > that is kind of what I expected, and adding the `,` is a known trick to 
> > cause it to expand the struct out.
> > 
> > I think its worth putting a test in, but I'll ask the same question what do 
> > you think it should look like?
> I agree with you. And I'll add these tests to patch.
I'd expect the lines starting with `{` to be indented in those cases, probably 
by +4 spaces in LLVM-like style (ContinuationIndent), consistently with other 
places where the RHS of a binary expression gets wrapped on a new line:
Not:
```
struct new_struct struct_name =
{a = 1};
struct new_struct struct_name =
{a = 1, b = 2};
```
But:
```
struct new_struct struct_name =
{a = 1};
struct new_struct struct_name =
{a = 1, b = 2};
```



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

https://reviews.llvm.org/D91949

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


[clang] 761f3d1 - [clang][PreProcessor] Cutoff parsing after hitting completion point

2021-05-10 Thread Kadir Cetinkaya via cfe-commits

Author: Kadir Cetinkaya
Date: 2021-05-10T11:24:27+02:00
New Revision: 761f3d16753ecea625173729dd8c53df022cd4ab

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

LOG: [clang][PreProcessor] Cutoff parsing after hitting completion point

This fixes a crash caused by Lexers being invalidated at code
completion points in
https://github.com/llvm/llvm-project/blob/main/clang/lib/Lex/PPLexerChange.cpp#L520.

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

Added: 
clang/test/CodeCompletion/crash-if-directive.cpp

Modified: 
clang/lib/Lex/PPDirectives.cpp

Removed: 




diff  --git a/clang/lib/Lex/PPDirectives.cpp b/clang/lib/Lex/PPDirectives.cpp
index a771b7c5d122d..d5cb46f75aec3 100644
--- a/clang/lib/Lex/PPDirectives.cpp
+++ b/clang/lib/Lex/PPDirectives.cpp
@@ -595,6 +595,9 @@ void 
Preprocessor::SkipExcludedConditionalBlock(SourceLocation HashTokenLoc,
   CurPPLexer->LexingRawMode = false;
   IdentifierInfo *IfNDefMacro = nullptr;
   DirectiveEvalResult DER = EvaluateDirectiveExpression(IfNDefMacro);
+  // Stop if Lexer became invalid after hitting code completion token.
+  if (!CurPPLexer)
+return;
   const bool CondValue = DER.Conditional;
   CurPPLexer->LexingRawMode = true;
   if (Callbacks) {
@@ -3023,6 +3026,10 @@ void Preprocessor::HandleIfDirective(Token &IfToken,
   IdentifierInfo *IfNDefMacro = nullptr;
   const DirectiveEvalResult DER = EvaluateDirectiveExpression(IfNDefMacro);
   const bool ConditionalTrue = DER.Conditional;
+  // Lexer might become invalid if we hit code completion point while 
evaluating
+  // expression.
+  if (!CurPPLexer)
+return;
 
   // If this condition is equivalent to #ifndef X, and if this is the first
   // directive seen, handle it for the multiple-include optimization.

diff  --git a/clang/test/CodeCompletion/crash-if-directive.cpp 
b/clang/test/CodeCompletion/crash-if-directive.cpp
new file mode 100644
index 0..0878c5c871e0c
--- /dev/null
+++ b/clang/test/CodeCompletion/crash-if-directive.cpp
@@ -0,0 +1,6 @@
+#define FOO(X) X
+#if FOO(
+#elif FOO(
+#endif
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:2:9 %s
+// RUN: not %clang_cc1 -fsyntax-only -code-completion-at=%s:3:11 %s



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


[PATCH] D102069: [clang][PreProcessor] Cutoff parsing after hitting completion point

2021-05-10 Thread Kadir Cetinkaya 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 rG761f3d16753e: [clang][PreProcessor] Cutoff parsing after 
hitting completion point (authored by kadircet).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102069

Files:
  clang/lib/Lex/PPDirectives.cpp
  clang/test/CodeCompletion/crash-if-directive.cpp


Index: clang/test/CodeCompletion/crash-if-directive.cpp
===
--- /dev/null
+++ clang/test/CodeCompletion/crash-if-directive.cpp
@@ -0,0 +1,6 @@
+#define FOO(X) X
+#if FOO(
+#elif FOO(
+#endif
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:2:9 %s
+// RUN: not %clang_cc1 -fsyntax-only -code-completion-at=%s:3:11 %s
Index: clang/lib/Lex/PPDirectives.cpp
===
--- clang/lib/Lex/PPDirectives.cpp
+++ clang/lib/Lex/PPDirectives.cpp
@@ -595,6 +595,9 @@
   CurPPLexer->LexingRawMode = false;
   IdentifierInfo *IfNDefMacro = nullptr;
   DirectiveEvalResult DER = EvaluateDirectiveExpression(IfNDefMacro);
+  // Stop if Lexer became invalid after hitting code completion token.
+  if (!CurPPLexer)
+return;
   const bool CondValue = DER.Conditional;
   CurPPLexer->LexingRawMode = true;
   if (Callbacks) {
@@ -3023,6 +3026,10 @@
   IdentifierInfo *IfNDefMacro = nullptr;
   const DirectiveEvalResult DER = EvaluateDirectiveExpression(IfNDefMacro);
   const bool ConditionalTrue = DER.Conditional;
+  // Lexer might become invalid if we hit code completion point while 
evaluating
+  // expression.
+  if (!CurPPLexer)
+return;
 
   // If this condition is equivalent to #ifndef X, and if this is the first
   // directive seen, handle it for the multiple-include optimization.


Index: clang/test/CodeCompletion/crash-if-directive.cpp
===
--- /dev/null
+++ clang/test/CodeCompletion/crash-if-directive.cpp
@@ -0,0 +1,6 @@
+#define FOO(X) X
+#if FOO(
+#elif FOO(
+#endif
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:2:9 %s
+// RUN: not %clang_cc1 -fsyntax-only -code-completion-at=%s:3:11 %s
Index: clang/lib/Lex/PPDirectives.cpp
===
--- clang/lib/Lex/PPDirectives.cpp
+++ clang/lib/Lex/PPDirectives.cpp
@@ -595,6 +595,9 @@
   CurPPLexer->LexingRawMode = false;
   IdentifierInfo *IfNDefMacro = nullptr;
   DirectiveEvalResult DER = EvaluateDirectiveExpression(IfNDefMacro);
+  // Stop if Lexer became invalid after hitting code completion token.
+  if (!CurPPLexer)
+return;
   const bool CondValue = DER.Conditional;
   CurPPLexer->LexingRawMode = true;
   if (Callbacks) {
@@ -3023,6 +3026,10 @@
   IdentifierInfo *IfNDefMacro = nullptr;
   const DirectiveEvalResult DER = EvaluateDirectiveExpression(IfNDefMacro);
   const bool ConditionalTrue = DER.Conditional;
+  // Lexer might become invalid if we hit code completion point while evaluating
+  // expression.
+  if (!CurPPLexer)
+return;
 
   // If this condition is equivalent to #ifndef X, and if this is the first
   // directive seen, handle it for the multiple-include optimization.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D99646: [clang-tidy] misc-avoid-std-io-outside-main: a new check

2021-05-10 Thread Marco Gartmann via Phabricator via cfe-commits
mgartmann updated this revision to Diff 344013.
mgartmann added a comment.

Remove trailing whitespaces from documentation file.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99646

Files:
  clang-tools-extra/clang-tidy/misc/AvoidStdIoOutsideMainCheck.cpp
  clang-tools-extra/clang-tidy/misc/AvoidStdIoOutsideMainCheck.h
  clang-tools-extra/clang-tidy/misc/CMakeLists.txt
  clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/docs/clang-tidy/checks/misc-avoid-std-io-outside-main.rst
  clang-tools-extra/test/clang-tidy/checkers/misc-avoid-std-io-outside-main.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/misc-avoid-std-io-outside-main.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/misc-avoid-std-io-outside-main.cpp
@@ -0,0 +1,138 @@
+// RUN: %check_clang_tidy %s misc-avoid-std-io-outside-main %t
+
+namespace std {
+struct string {
+  string(const char *);
+  ~string();
+};
+
+struct Ostream {
+  Ostream &operator<<(string Message);
+};
+
+struct Istream {
+  Istream &operator>>(string Message);
+};
+
+Ostream cout{}, wcout{}, cerr{}, wcerr{};
+Istream cin{}, wcin{};
+
+int printf(const char *Format, ...);
+int vprintf(const char *const, ...);
+int puts(const char *Str);
+int putchar(int Character);
+int scanf(const char *Format, ...);
+int getchar(void);
+char *gets(char *Str);
+} // namespace std
+
+int printf(const char *Format, ...);
+int vprintf(const char *const, ...);
+int puts(const char *Str);
+int putchar(int Character);
+int scanf(const char *Format, ...);
+int getchar(void);
+char *gets(char *Str);
+
+namespace arbitrary_namespace {
+std::Ostream cout{};
+std::Istream cin{};
+} // namespace arbitrary_namespace
+
+void anyNonMainFunction() {
+  // CHECK-MESSAGES: :[[@LINE+1]]:8: warning: predefined standard stream objects should not be used outside the main function [misc-avoid-std-io-outside-main]
+  std::cout << "This should trigger the check";
+
+  // CHECK-MESSAGES: :[[@LINE+1]]:8: warning: predefined standard stream objects should not be used outside the main function [misc-avoid-std-io-outside-main]
+  std::wcout << "This should trigger the check";
+
+  // CHECK-MESSAGES: :[[@LINE+1]]:8: warning: predefined standard stream objects should not be used outside the main function [misc-avoid-std-io-outside-main]
+  std::cerr << "This should trigger the check";
+
+  // CHECK-MESSAGES: :[[@LINE+1]]:8: warning: predefined standard stream objects should not be used outside the main function [misc-avoid-std-io-outside-main]
+  std::wcerr << "This should trigger the check";
+
+  arbitrary_namespace::cout << "This should not trigger the check"; // OK
+
+  std::string Foo{"bar"};
+
+  // CHECK-MESSAGES: :[[@LINE+1]]:8: warning: predefined standard stream objects should not be used outside the main function [misc-avoid-std-io-outside-main]
+  std::cin >> Foo;
+
+  // CHECK-MESSAGES: :[[@LINE+1]]:8: warning: predefined standard stream objects should not be used outside the main function [misc-avoid-std-io-outside-main]
+  std::wcin >> Foo;
+
+  arbitrary_namespace::cin >> Foo; // OK
+
+  // CHECK-MESSAGES: :[[@LINE+1]]:8: warning: cstdio functions should not be used outside the main function [misc-avoid-std-io-outside-main]
+  std::printf("This should trigger the check");
+  // CHECK-MESSAGES: :[[@LINE+1]]:3: warning: cstdio functions should not be used outside the main function [misc-avoid-std-io-outside-main]
+  printf("This should trigger the check");
+
+  // CHECK-MESSAGES: :[[@LINE+1]]:8: warning: cstdio functions should not be used outside the main function [misc-avoid-std-io-outside-main]
+  std::puts("This should trigger the check");
+  // CHECK-MESSAGES: :[[@LINE+1]]:3: warning: cstdio functions should not be used outside the main function [misc-avoid-std-io-outside-main]
+  puts("This should trigger the check");
+
+  // CHECK-MESSAGES: :[[@LINE+1]]:8: warning: cstdio functions should not be used outside the main function [misc-avoid-std-io-outside-main]
+  std::putchar('m');
+  // CHECK-MESSAGES: :[[@LINE+1]]:3: warning: cstdio functions should not be used outside the main function [misc-avoid-std-io-outside-main]
+  putchar('m');
+
+  char Input[5];
+  // CHECK-MESSAGES: :[[@LINE+1]]:8: warning: cstdio functions should not be used outside the main function [misc-avoid-std-io-outside-main]
+  std::scanf("%s", Input);
+  // CHECK-MESSAGES: :[[@LINE+1]]:3: warning: cstdio functions should not be used outside the main function [misc-avoid-std-io-outside-main]
+  scanf("%s", Input);
+
+  // CHECK-MESSAGES: :[[@LINE+1]]:8: warning: cstdio functions should not be used outside the main function [misc-avoid-std-io-outside-main]
+  std::getchar();
+  // CHECK-MESSAGES: :[[@LINE+1]]:3: warning: cstdio functions should n

[PATCH] D69560: [clang-tidy] Add 'bugprone-easily-swappable-parameters' check

2021-05-10 Thread Whisperity via Phabricator via cfe-commits
whisperity added a comment.

In D69560#2747092 , @alexfh wrote:

> BTW, any ideas why "patch application failed"? (See the Build status in the 
> Diff Detail section)
>
> It would be really nice to get pre-merge checks to work for the patch.

Put simply, I think I haven't rebased the patch since a few changes ago. The 
past few changes were NFC/lint stuff only.




Comment at: 
clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp:113-120
+#define FB(Name, K) MIX_##Name = (1ull << (K##ull - 1ull))
+
+  FB(None, 1),  //< Mix between the two parameters is not possible.
+  FB(Trivial, 2),   //< The two mix trivially, and are the exact same type.
+  FB(Canonical, 3), //< The two mix because the types refer to the same
+// CanonicalType, but we do not elaborate as to how.
+

alexfh wrote:
> I'd switch to scoped enums (`enum class`), remove the macro, and use simpler 
> code like `None = 0x1, Trivial = 0x2, Canonical = 0x4`, etc.
`enum class` is a good idea!

Unfortunately, I'm not really sold on the hexa literals... It makes the code 
confusing the read, because you have to keep in mind which range the hexa 
literals mean, and when there is a shift in position, e.g. if you read `0x20` 
you have to count out that okay, that's 2nd position, so at least 16, so at 
least the 4th bit, but it is two, so you shift it again to the right, so in the 
bit pattern it turns on the 5th bit actually.
It makes it very easy to misread or misinterpret things, especially when trying 
to work on the source code.
(In the last extension patch, the number of elements in the bit mask go up to 
the 8th or the 9th bit, I don't remember exactly at the top of my head.)

Compared to this, the current text when read immediately tells you which 
"decimal" position you should expect the appropriate bit to be toggled on, if 
the flag is there.

Binary literals, on the other hand, would be amazing to use here, sadly we're 
only in C++14.



Comment at: 
clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp:133
+
+  void sanitize() {
+assert(Flags != MIX_Invalid && "sanitize() called on invalid bitvec");

alexfh wrote:
> What should this method do and how it should be used? Same for Mix::sanitize()
Once there are more flags in the bitmask (not just "None" and "Trivial"), this 
method deals with sanitising the flags that are toggled on and off by the 
recursive descent on the type tree.

For example, if there is a typedef involved (see D95736), it will toggle on the 
typedef flag, and start investigating the aliased type. This subsequent 
investigation might figure out that the aliased type is trivial, or it is 
distinct. In case it is distinct, that level of the recursion will turn on the 
"Not mixable" flag. In this case, when the investigation returns completely, we 
will have "Typedef" and "None" both turned on. This method will throw away 
everything but the "None" bit, so when the data is returned to the 
diagnostic-generating part of the check, it will know what to do.



Comment at: 
clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp:313-320
+if (B.isMacroID()) {
+  LLVM_DEBUG(llvm::dbgs() << "\t\tBeginning is macro.\n");
+  B = SM.getTopMacroCallerLoc(B);
+}
+if (E.isMacroID()) {
+  LLVM_DEBUG(llvm::dbgs() << "\t\tEnding is macro.\n");
+  E = Lexer::getLocForEndOfToken(SM.getTopMacroCallerLoc(E), 0, SM, LO);

alexfh wrote:
> Is there a chance that you're trying to reimplement a part of 
> Lexer::makeFileCharRange functionality here?
Does that expand the token length properly? I took this idiom of 
`getLocForEndOfToken` from various other Tidy checks... basically, anything 
that deals with replacing some sort of textual range in the code calls to this 
function. I need to have the exact ending location so I can obtain the full 
text, as appears in the source file. In this case, to compare against the 
user's input.

E.g. here is one example from `utils/UsingInserter.cpp`:

```
  32   │ Optional UsingInserter::createUsingDeclaration(
  33   │ ASTContext &Context, const Stmt &Statement, StringRef 
QualifiedName) {
/* ... */
  42   │   SourceLocation InsertLoc = Lexer::getLocForEndOfToken(
  43   │   Function->getBody()->getBeginLoc(), 0, SourceMgr, 
Context.getLangOpts());
```

A quick grep for `makeCharRange` in the repository didn't turn up any 
significant result, apart from one unit test.



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-len2.cpp:129
+
+void qualified1(int I, const int CI) {} // NO-WARN: Not the same type.
+

alexfh wrote:
> Does the top-level const change anything with regard to the "mixability"? 
> It's a purely implementation-side difference, callers could still swap 
> parameters.
Un

[PATCH] D102159: [index][analyzer][ctu] Eliminate white spaces in the CTU lookup name.

2021-05-10 Thread Ella Ma via Phabricator via cfe-commits
OikawaKirie created this revision.
OikawaKirie added reviewers: akyrtzi, martong, steakhal.
OikawaKirie added a project: clang.
Herald added subscribers: ASDenysPetrov, dkrupp, donat.nagy, Szelethus, 
arphaman, mikhail.ramalho, a.sidorin, rnkovacs, szepet, baloghadamsoftware, 
xazax.hun.
OikawaKirie requested review of this revision.
Herald added a subscriber: cfe-commits.

In the analyzer, the CTU definition index file requires there are no white 
spaces in the CTU lookup name, aka. the USR of a function decl or a global 
variable decl. Otherwise, the index file will be wrongly parsed.
However, it is difficult for the analyzer to know whether a white space `' '` 
is the separator between the index string and the file path, or it is just a 
part of the index string or the path. It means that using either the first or 
the last white space as the separator could not be a good idea. As it is valid 
for a file path to have white spaces, a better choice seems to be eliminating 
all the white spaces in the index string.
In this patch, the white space `' '` for an unsupported type is replaced with a 
question mark `'?'`, which solves the problem as well as makes the index more 
reasonable as far as I am thinking.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D102159

Files:
  clang/lib/Index/USRGeneration.cpp
  clang/test/Index/unsupported.cpp


Index: clang/test/Index/unsupported.cpp
===
--- /dev/null
+++ clang/test/Index/unsupported.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_extdef_map %s -- | FileCheck %s
+
+struct X {
+  bool f(char *);
+};
+
+typedef bool (X::*XFP)(char *);
+
+// CHECK-NOT: {{ [^ ]+ }}
+void f(XFP xfp) {}
Index: clang/lib/Index/USRGeneration.cpp
===
--- clang/lib/Index/USRGeneration.cpp
+++ clang/lib/Index/USRGeneration.cpp
@@ -895,7 +895,7 @@
 }
 
 // Unhandled type.
-Out << ' ';
+Out << '?';
 break;
   } while (true);
 }


Index: clang/test/Index/unsupported.cpp
===
--- /dev/null
+++ clang/test/Index/unsupported.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_extdef_map %s -- | FileCheck %s
+
+struct X {
+  bool f(char *);
+};
+
+typedef bool (X::*XFP)(char *);
+
+// CHECK-NOT: {{ [^ ]+ }}
+void f(XFP xfp) {}
Index: clang/lib/Index/USRGeneration.cpp
===
--- clang/lib/Index/USRGeneration.cpp
+++ clang/lib/Index/USRGeneration.cpp
@@ -895,7 +895,7 @@
 }
 
 // Unhandled type.
-Out << ' ';
+Out << '?';
 break;
   } while (true);
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D100630: [Debug-Info][DBX] DW_TAG_rvalue_reference_type should not be generated when dwarf version is smaller than 4

2021-05-10 Thread ChenZheng via Phabricator via cfe-commits
shchenz updated this revision to Diff 343983.
shchenz added a comment.
Herald added subscribers: llvm-commits, hiraditya, nemanjai.
Herald added a project: LLVM.

update according to @dblaikie comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100630

Files:
  llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
  llvm/test/DebugInfo/PowerPC/strict-dwarf-tags.ll


Index: llvm/test/DebugInfo/PowerPC/strict-dwarf-tags.ll
===
--- /dev/null
+++ llvm/test/DebugInfo/PowerPC/strict-dwarf-tags.ll
@@ -0,0 +1,43 @@
+; RUN: llc -filetype=obj -mtriple=powerpc64le-unknown-linux-gnu < %s | \
+; RUN:   llvm-dwarfdump -debug-info - | FileCheck %s
+; RUN: llc -filetype=obj -mtriple=powerpc64le-unknown-linux-gnu \
+; RUN:   -strict-dwarf=true < %s | llvm-dwarfdump -debug-info - | \
+; RUN:   FileCheck %s -check-prefix=STRICT
+
+; If not strict DWARF mode, we expect DW_TAG_rvalue_reference_type at DWARF 3.
+; If strict DWARF mode, we expect DW_TAG_reference_type at DWARF 3 as 
DW_TAG_rvalue_reference_type
+; is a DWARF 4 tag.
+
+; CHECK: DW_TAG_rvalue_reference_type
+; STRICT: DW_TAG_reference_type
+
+define void @_Z3fooOi(i32* dereferenceable(4) %i) !dbg !8 {
+entry:
+  call void @llvm.dbg.value(metadata i32* %i, metadata !14, metadata 
!DIExpression()), !dbg !15
+  ret void, !dbg !16
+}
+
+; Function Attrs: nofree nosync nounwind readnone speculatable willreturn
+declare void @llvm.dbg.value(metadata, metadata, metadata) #1
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!3, !4, !5, !6}
+!llvm.ident = !{!7}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, 
producer: "clang version 13.0.0", isOptimized: true, runtimeVersion: 0, 
emissionKind: FullDebug, enums: !2, splitDebugInlining: false, nameTableKind: 
None)
+!1 = !DIFile(filename: "1.cpp", directory: "./")
+!2 = !{}
+!3 = !{i32 7, !"Dwarf Version", i32 3}
+!4 = !{i32 2, !"Debug Info Version", i32 3}
+!5 = !{i32 1, !"wchar_size", i32 4}
+!6 = !{i32 7, !"uwtable", i32 1}
+!7 = !{!"clang version 13.0.0"}
+!8 = distinct !DISubprogram(name: "foo", linkageName: "_Z3fooOi", scope: !1, 
file: !1, line: 1, type: !9, scopeLine: 2, flags: DIFlagPrototyped | 
DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: 
!0, retainedNodes: !13)
+!9 = !DISubroutineType(types: !10)
+!10 = !{null, !11}
+!11 = !DIDerivedType(tag: DW_TAG_rvalue_reference_type, baseType: !12, size: 
64)
+!12 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
+!13 = !{!14}
+!14 = !DILocalVariable(name: "i", arg: 1, scope: !8, file: !1, line: 1, type: 
!11)
+!15 = !DILocation(line: 0, scope: !8)
+!16 = !DILocation(line: 3, column: 1, scope: !8)
Index: llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
===
--- llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
+++ llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
@@ -386,7 +386,20 @@
 }
 
 DIE &DwarfUnit::createAndAddDIE(unsigned Tag, DIE &Parent, const DINode *N) {
-  DIE &Die = Parent.addChild(DIE::get(DIEValueAllocator, (dwarf::Tag)Tag));
+  // For strict DWARF mode, only generate tags available to current DWARF
+  // version.
+  dwarf::Tag FixedTag = (dwarf::Tag)Tag;
+  if (Asm->TM.Options.DebugStrictDwarf &&
+  DD->getDwarfVersion() < dwarf::TagVersion(FixedTag)) {
+// See if there is any replacement for some tags.
+if (FixedTag == dwarf::DW_TAG_rvalue_reference_type &&
+DD->getDwarfVersion() >= 3)
+  FixedTag = dwarf::DW_TAG_reference_type;
+
+// Assertion for other cases.
+assert(true && "Tag is generated not following strict DWARF!");
+  }
+  DIE &Die = Parent.addChild(DIE::get(DIEValueAllocator, FixedTag));
   if (N)
 insertDIE(N, &Die);
   return Die;


Index: llvm/test/DebugInfo/PowerPC/strict-dwarf-tags.ll
===
--- /dev/null
+++ llvm/test/DebugInfo/PowerPC/strict-dwarf-tags.ll
@@ -0,0 +1,43 @@
+; RUN: llc -filetype=obj -mtriple=powerpc64le-unknown-linux-gnu < %s | \
+; RUN:   llvm-dwarfdump -debug-info - | FileCheck %s
+; RUN: llc -filetype=obj -mtriple=powerpc64le-unknown-linux-gnu \
+; RUN:   -strict-dwarf=true < %s | llvm-dwarfdump -debug-info - | \
+; RUN:   FileCheck %s -check-prefix=STRICT
+
+; If not strict DWARF mode, we expect DW_TAG_rvalue_reference_type at DWARF 3.
+; If strict DWARF mode, we expect DW_TAG_reference_type at DWARF 3 as DW_TAG_rvalue_reference_type
+; is a DWARF 4 tag.
+
+; CHECK: DW_TAG_rvalue_reference_type
+; STRICT: DW_TAG_reference_type
+
+define void @_Z3fooOi(i32* dereferenceable(4) %i) !dbg !8 {
+entry:
+  call void @llvm.dbg.value(metadata i32* %i, metadata !14, metadata !DIExpression()), !dbg !15
+  ret void, !dbg !16
+}
+
+; Function Attrs: nofree nosync nounwind readnone speculatable willreturn
+declare void @llvm.dbg.value(metadata, metadata, metadata) #1
+
+!llvm.dbg.cu = !{!

[PATCH] D100630: [Debug-Info][DBX] DW_TAG_rvalue_reference_type should not be generated when dwarf version is smaller than 4

2021-05-10 Thread ChenZheng via Phabricator via cfe-commits
shchenz added a comment.

In D100630#2745272 , @dblaikie wrote:

> Mixed feelings - is this the only place where we're changing behavior for 
> strict-DWARF in the frontend/clang? (maybe it'd be better to do it all in the 
> same place, down in the backend when the IR is mapped to actual DWARF)

Update the patch to do the check down in the backend. Seems we already have one 
centralized interface for TAGs generation.

> @aprantl @probinson - you two have any thoughts on this layering aspect?
>
> I think for CodeView we make some different choices up in the frontend (& 
> completely different implementations in the backend), so it's not totally 
> unreasonable, but curious how folks feel.

Welcome your comments! @aprantl @probinson


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100630

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


[PATCH] D100782: [PowerPC] Improve f32 to i32 bitcast code gen

2021-05-10 Thread Nemanja Ivanovic via Phabricator via cfe-commits
nemanjai accepted this revision.
nemanjai added a comment.
This revision is now accepted and ready to land.

LGTM.


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

https://reviews.llvm.org/D100782

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


[PATCH] D102070: [AIX][TLS] Diagnose use of unimplemented TLS models

2021-05-10 Thread Nemanja Ivanovic via Phabricator via cfe-commits
nemanjai accepted this revision.
nemanjai added a comment.
This revision is now accepted and ready to land.

LGTM. Maybe give this a couple of days to see if any other reviewers have 
further input.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102070

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


[PATCH] D102064: Parse vector bool when stdbool.h and altivec.h are included

2021-05-10 Thread Nemanja Ivanovic via Phabricator via cfe-commits
nemanjai added a comment.

This seems fine to me now but I'll defer to front end experts for approval.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102064

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


[PATCH] D102147: [Clang][Coroutines] Implement P2014R0 Option 1 behind -fcoroutines-aligned-alloc

2021-05-10 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu added a comment.

Since D97915  would fix the problem that the 
variables in the frame may not be aligned, I think this option 
`fcoroutines-aligned-alloc` won't affect normal programmers other than language 
lawyers. Do you think so?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102147

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


[PATCH] D99646: [clang-tidy] misc-avoid-std-io-outside-main: a new check

2021-05-10 Thread Marco Gartmann via Phabricator via cfe-commits
mgartmann updated this revision to Diff 344023.
mgartmann added a comment.

Updated diff to fix the build.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99646

Files:
  clang-tools-extra/clang-tidy/misc/AvoidStdIoOutsideMainCheck.cpp
  clang-tools-extra/clang-tidy/misc/AvoidStdIoOutsideMainCheck.h
  clang-tools-extra/clang-tidy/misc/CMakeLists.txt
  clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/docs/clang-tidy/checks/misc-avoid-std-io-outside-main.rst
  clang-tools-extra/test/clang-tidy/checkers/misc-avoid-std-io-outside-main.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/misc-avoid-std-io-outside-main.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/misc-avoid-std-io-outside-main.cpp
@@ -0,0 +1,138 @@
+// RUN: %check_clang_tidy %s misc-avoid-std-io-outside-main %t
+
+namespace std {
+struct string {
+  string(const char *);
+  ~string();
+};
+
+struct Ostream {
+  Ostream &operator<<(string Message);
+};
+
+struct Istream {
+  Istream &operator>>(string Message);
+};
+
+Ostream cout{}, wcout{}, cerr{}, wcerr{};
+Istream cin{}, wcin{};
+
+int printf(const char *Format, ...);
+int vprintf(const char *const, ...);
+int puts(const char *Str);
+int putchar(int Character);
+int scanf(const char *Format, ...);
+int getchar(void);
+char *gets(char *Str);
+} // namespace std
+
+int printf(const char *Format, ...);
+int vprintf(const char *const, ...);
+int puts(const char *Str);
+int putchar(int Character);
+int scanf(const char *Format, ...);
+int getchar(void);
+char *gets(char *Str);
+
+namespace arbitrary_namespace {
+std::Ostream cout{};
+std::Istream cin{};
+} // namespace arbitrary_namespace
+
+void anyNonMainFunction() {
+  // CHECK-MESSAGES: :[[@LINE+1]]:8: warning: predefined standard stream objects should not be used outside the main function [misc-avoid-std-io-outside-main]
+  std::cout << "This should trigger the check";
+
+  // CHECK-MESSAGES: :[[@LINE+1]]:8: warning: predefined standard stream objects should not be used outside the main function [misc-avoid-std-io-outside-main]
+  std::wcout << "This should trigger the check";
+
+  // CHECK-MESSAGES: :[[@LINE+1]]:8: warning: predefined standard stream objects should not be used outside the main function [misc-avoid-std-io-outside-main]
+  std::cerr << "This should trigger the check";
+
+  // CHECK-MESSAGES: :[[@LINE+1]]:8: warning: predefined standard stream objects should not be used outside the main function [misc-avoid-std-io-outside-main]
+  std::wcerr << "This should trigger the check";
+
+  arbitrary_namespace::cout << "This should not trigger the check"; // OK
+
+  std::string Foo{"bar"};
+
+  // CHECK-MESSAGES: :[[@LINE+1]]:8: warning: predefined standard stream objects should not be used outside the main function [misc-avoid-std-io-outside-main]
+  std::cin >> Foo;
+
+  // CHECK-MESSAGES: :[[@LINE+1]]:8: warning: predefined standard stream objects should not be used outside the main function [misc-avoid-std-io-outside-main]
+  std::wcin >> Foo;
+
+  arbitrary_namespace::cin >> Foo; // OK
+
+  // CHECK-MESSAGES: :[[@LINE+1]]:8: warning: cstdio functions should not be used outside the main function [misc-avoid-std-io-outside-main]
+  std::printf("This should trigger the check");
+  // CHECK-MESSAGES: :[[@LINE+1]]:3: warning: cstdio functions should not be used outside the main function [misc-avoid-std-io-outside-main]
+  printf("This should trigger the check");
+
+  // CHECK-MESSAGES: :[[@LINE+1]]:8: warning: cstdio functions should not be used outside the main function [misc-avoid-std-io-outside-main]
+  std::puts("This should trigger the check");
+  // CHECK-MESSAGES: :[[@LINE+1]]:3: warning: cstdio functions should not be used outside the main function [misc-avoid-std-io-outside-main]
+  puts("This should trigger the check");
+
+  // CHECK-MESSAGES: :[[@LINE+1]]:8: warning: cstdio functions should not be used outside the main function [misc-avoid-std-io-outside-main]
+  std::putchar('m');
+  // CHECK-MESSAGES: :[[@LINE+1]]:3: warning: cstdio functions should not be used outside the main function [misc-avoid-std-io-outside-main]
+  putchar('m');
+
+  char Input[5];
+  // CHECK-MESSAGES: :[[@LINE+1]]:8: warning: cstdio functions should not be used outside the main function [misc-avoid-std-io-outside-main]
+  std::scanf("%s", Input);
+  // CHECK-MESSAGES: :[[@LINE+1]]:3: warning: cstdio functions should not be used outside the main function [misc-avoid-std-io-outside-main]
+  scanf("%s", Input);
+
+  // CHECK-MESSAGES: :[[@LINE+1]]:8: warning: cstdio functions should not be used outside the main function [misc-avoid-std-io-outside-main]
+  std::getchar();
+  // CHECK-MESSAGES: :[[@LINE+1]]:3: warning: cstdio functions should not be used outside the

[PATCH] D101616: [clangd] Fix data type of WorkDoneProgressReport::percentage

2021-05-10 Thread Christian Kandeler via Phabricator via cfe-commits
ckandeler added a comment.

ping. Any chance of getting this pushed?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101616

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


[PATCH] D101519: [C++4OpenCL] Fix reinterpret_cast of vectors

2021-05-10 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added inline comments.



Comment at: clang/test/SemaOpenCLCXX/reinterpret-cast.clcpp:15
+  int4 i4;
+  auto i4_to_i3 = reinterpret_cast(i4); // 
expected-error{{reinterpret_cast from vector 'int4' (vector of 4 'int' values) 
to vector 'int3' (vector of 3 'int' values) of different size}}
+

I think in OpenCL vector 3 should be setup as vector 4 in memory with the 4th 
component being `undef` value. So this conversion should be permitted.

For example you can reinterpret cast between 3 and 4 components vectors using 
as_typen functions.

https://godbolt.org/z/sKqnYhnGe

I don't think we have a comprehensive description but these are the quotes from 
OpenCL C:

>For 3-component vector data types, the size of the data type is 4 * 
>sizeof(component). This means that a 3-component vector data type will be 
>aligned to a 4 * sizeof(component) boundary. The vload3 and vstore3 built-in 
>functions can be used to read and write, respectively, 3-component vector data 
>types from an array of packed scalar data type.

> When the operand and result type contain a different number of elements, the 
> result shall be implementation-defined except if the operand is a 4-component 
> vector and the result is a 3-component vector. In this case, the bits in the 
> operand shall be returned directly without modification as the new type. 

> The suffixes .lo (or .even) and .hi (or .odd) for a 3-component vector type 
> operate as if the 3-component vector type is a 4-component vector type with 
> the value in the w component undefined.




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101519

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


[PATCH] D101030: [OpenMP] Overhaul `declare target` handling

2021-05-10 Thread greg miller via Phabricator via cfe-commits
gregmiller added a comment.

In D101030#2746957 , @jdoerfert wrote:

> In D101030#2746770 , @gregmiller 
> wrote:
>
>> In D101030#2745513 , @jdoerfert 
>> wrote:
>>
>>> In D101030#2745429 , @gregmiller 
>>> wrote:
>>>
 Hello, We are maintaining a downstream version of the monorepo based on 
 the LLVM main branch. We have not transitioned to the new PM yet. In a 
 recent attempt to merge the latest upstream commits into our monorepo we 
 came across the following test failures after your commit.
 F16720091: failed_report.txt 
 For below test cases:

   remarks_parallel_in_multiple_target_state_machines.c
   remarks_parallel_in_target_state_machine.c

 Thanks
 greg
>>>
>>> Can you add (and if you want upstream) a change that forces the use of the 
>>> new pass manager for those tests?
>>
>> Since the old pass manager is still supported upstream, I think it would 
>> make more sense for you to update your changes to the failing tests instead.
>
> Sure. I'll do that when I find a minute.
> Given that you have a setup with the old PM set as default I figured it might 
> be easier for you to test the minimal change to the run lines but I am happy 
> to do it myself next chance I get to setup everything and such.

Thanks.  That would be much appreciated.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101030

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


[PATCH] D98799: [UniqueLinkageName] Use consistent checks when mangling symbo linkage name and debug linkage name.

2021-05-10 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/test/CodeGen/unique-internal-linkage-names-dwarf.c:34-39
+static int go(a) int a;
+{
+  return glob + a;
+}
+
+

dblaikie wrote:
> hoy wrote:
> > dblaikie wrote:
> > > dblaikie wrote:
> > > > hoy wrote:
> > > > > dblaikie wrote:
> > > > > > hoy wrote:
> > > > > > > dblaikie wrote:
> > > > > > > > hoy wrote:
> > > > > > > > > dblaikie wrote:
> > > > > > > > > > hoy wrote:
> > > > > > > > > > > dblaikie wrote:
> > > > > > > > > > > > hoy wrote:
> > > > > > > > > > > > > dblaikie wrote:
> > > > > > > > > > > > > > hoy wrote:
> > > > > > > > > > > > > > > dblaikie wrote:
> > > > > > > > > > > > > > > > Does this need to be down here? Or would the 
> > > > > > > > > > > > > > > > code be a well exercised if it was up next to 
> > > > > > > > > > > > > > > > the go declaration above?
> > > > > > > > > > > > > > > Yes, it needs to be here. Otherwise it will just 
> > > > > > > > > > > > > > > like the function `bar` above that doesn't get a 
> > > > > > > > > > > > > > > uniquefied name. I think moving the definition up 
> > > > > > > > > > > > > > > to right after the declaration hides the 
> > > > > > > > > > > > > > > declaration.
> > > > > > > > > > > > > > Not sure I follow - do you mean that if the go 
> > > > > > > > > > > > > > declaration and go definition were next to each 
> > > > > > > > > > > > > > other, this test would (mechanically speaking) not 
> > > > > > > > > > > > > > validate what the patch? Or that it would be less 
> > > > > > > > > > > > > > legible, but still mechanically correct?
> > > > > > > > > > > > > > 
> > > > > > > > > > > > > > I think it would be (assuming it's still 
> > > > > > > > > > > > > > mechanically correct) more legible to put the 
> > > > > > > > > > > > > > declaration next to the definition - the comment 
> > > > > > > > > > > > > > describes why the declaration is significant/why 
> > > > > > > > > > > > > > the definition is weird, and seeing all that 
> > > > > > > > > > > > > > together would be clearer to me than spreading it 
> > > > > > > > > > > > > > out/having to look further away to see what's going 
> > > > > > > > > > > > > > on.
> > > > > > > > > > > > > When the `go` declaration and `go` definition were 
> > > > > > > > > > > > > next to each other, the go function won't get a 
> > > > > > > > > > > > > uniqufied name at all. The declaration will be 
> > > > > > > > > > > > > overwritten by the definition. Only when the 
> > > > > > > > > > > > > declaration is seen by others, such the callsite in 
> > > > > > > > > > > > > `baz`, the declaration makes a difference by having 
> > > > > > > > > > > > > the callsite use a uniqufied name.
> > > > > > > > > > > > > 
> > > > > > > > > > > > > 
> > > > > > > > > > > > Ah! Interesting, good to know. 
> > > > > > > > > > > > 
> > > > > > > > > > > > Is that worth supporting, I wonder? I guess it falls 
> > > > > > > > > > > > out for free/without significant additional complexity. 
> > > > > > > > > > > > I worry about the subtlety of the additional 
> > > > > > > > > > > > declaration changing the behavior here... might be a 
> > > > > > > > > > > > bit surprising/subtle. But maybe no nice way to avoid 
> > > > > > > > > > > > it either.
> > > > > > > > > > > It would be ideal if user never writes code like that. 
> > > > > > > > > > > Unfortunately it exists with legacy code (such as mysql). 
> > > > > > > > > > > I think it's worth supporting it from AutoFDO point of 
> > > > > > > > > > > view to avoid a silent mismatch between debug linkage 
> > > > > > > > > > > name and real linkage name.
> > > > > > > > > > Oh, I agree that we shouldn't mismatch debug info and the 
> > > > > > > > > > actual symbol name - what I meant was whether code like 
> > > > > > > > > > this should get mangled or not when using 
> > > > > > > > > > unique-internal-linkage names.
> > > > > > > > > > 
> > > > > > > > > > I'm now more curious about this:
> > > > > > > > > > 
> > > > > > > > > > > When the `go` declaration and `go` definition were next 
> > > > > > > > > > > to each other, the go function won't get a uniqufied name 
> > > > > > > > > > > at all.
> > > > > > > > > > 
> > > > > > > > > > This doesn't seem to happen with the 
> > > > > > > > > > `__attribute__((overloadable))` attribute, for instance - 
> > > > > > > > > > so any idea what's different about uniquification that's 
> > > > > > > > > > working differently than overloadable?
> > > > > > > > > > 
> > > > > > > > > > ```
> > > > > > > > > > $ cat test.c
> > > > > > > > > > __attribute__((overloadable)) static int go(a) int a; {
> > > > > > > > > >   return 3 + a;
> > > > > > > > > > }
> > > > > > > > > > void baz() {
> > > > > > > > > >   go(2);
> > > > > > > > > > }
> > > > > > > > > > $ clang-tot test.c -emit-llvm -S -o - | grep go
> > > > > > > > > >   %call = call i32 @_ZL2goi(i32 2)
> > > > > > > > > > define internal i32 @_ZL2goi(i32 %a) #0 {
> > > > > > > > > 

[PATCH] D102134: [docs]Updated the AMD GPU Attributes documentation

2021-05-10 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman requested changes to this revision.
aaron.ballman added a comment.
This revision now requires changes to proceed.

Minor wordsmithing on the documentation changes, but more importantly: why is 
the correct fix to the documentation as opposed to changing the default max 
working group size?




Comment at: clang/include/clang/Basic/AttrDocs.td:2244-2247
+and is an optimization hint. It is mandatory to use this attribute in some 
+situations. Because when the attribute is absent, the compiler assumes the 
+default maximum workgroup size of 256 but nowadays the workgroup size can 
legally go 
+to 1024. 




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102134

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


[clang] 08de6e3 - clang: Fix tests after 7f78e409d028 if clang is not called clang-13

2021-05-10 Thread Nico Weber via cfe-commits

Author: Nico Weber
Date: 2021-05-10T08:49:26-04:00
New Revision: 08de6e3adaf6e991f5a40357f4634e5b70ec3fde

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

LOG: clang: Fix tests after 7f78e409d028 if clang is not called clang-13

We might release a new version at some point after all.
In fact, use the same pattern the other CHECK lines in this test
use, for consistency.

Added: 


Modified: 
clang/test/Driver/amdgpu-openmp-toolchain.c

Removed: 




diff  --git a/clang/test/Driver/amdgpu-openmp-toolchain.c 
b/clang/test/Driver/amdgpu-openmp-toolchain.c
index 12067c4c0739..e4b89dcedf01 100644
--- a/clang/test/Driver/amdgpu-openmp-toolchain.c
+++ b/clang/test/Driver/amdgpu-openmp-toolchain.c
@@ -73,4 +73,4 @@
 // CHECK-C: "x86_64-unknown-linux-gnu" - "offload bundler"
 
 // RUN:   %clang -### --target=x86_64-unknown-linux-gnu -emit-llvm -S -fopenmp 
-fopenmp-targets=amdgcn-amd-amdhsa -Xopenmp-target=amdgcn-amd-amdhsa 
-march=gfx803 -nogpulib %s 2>&1 | FileCheck %s --check-prefix=CHECK-EMIT-LLVM-IR
-// CHECK-EMIT-LLVM-IR: {{.*}}clang-13" "-cc1" "-triple" 
"amdgcn-amd-amdhsa"{{.*}}"-emit-llvm"
+// CHECK-EMIT-LLVM-IR: clang{{.*}}"-cc1"{{.*}}"-triple" 
"amdgcn-amd-amdhsa"{{.*}}"-emit-llvm"



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


[PATCH] D99646: [clang-tidy] misc-avoid-std-io-outside-main: a new check

2021-05-10 Thread Marco Gartmann via Phabricator via cfe-commits
mgartmann updated this revision to Diff 344030.
mgartmann added a comment.

Change encoding of patch to UTF-8 in order to fix build.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99646

Files:
  clang-tools-extra/clang-tidy/misc/AvoidStdIoOutsideMainCheck.cpp
  clang-tools-extra/clang-tidy/misc/AvoidStdIoOutsideMainCheck.h
  clang-tools-extra/clang-tidy/misc/CMakeLists.txt
  clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/docs/clang-tidy/checks/misc-avoid-std-io-outside-main.rst
  clang-tools-extra/test/clang-tidy/checkers/misc-avoid-std-io-outside-main.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/misc-avoid-std-io-outside-main.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/misc-avoid-std-io-outside-main.cpp
@@ -0,0 +1,138 @@
+// RUN: %check_clang_tidy %s misc-avoid-std-io-outside-main %t
+
+namespace std {
+struct string {
+  string(const char *);
+  ~string();
+};
+
+struct Ostream {
+  Ostream &operator<<(string Message);
+};
+
+struct Istream {
+  Istream &operator>>(string Message);
+};
+
+Ostream cout{}, wcout{}, cerr{}, wcerr{};
+Istream cin{}, wcin{};
+
+int printf(const char *Format, ...);
+int vprintf(const char *const, ...);
+int puts(const char *Str);
+int putchar(int Character);
+int scanf(const char *Format, ...);
+int getchar(void);
+char *gets(char *Str);
+} // namespace std
+
+int printf(const char *Format, ...);
+int vprintf(const char *const, ...);
+int puts(const char *Str);
+int putchar(int Character);
+int scanf(const char *Format, ...);
+int getchar(void);
+char *gets(char *Str);
+
+namespace arbitrary_namespace {
+std::Ostream cout{};
+std::Istream cin{};
+} // namespace arbitrary_namespace
+
+void anyNonMainFunction() {
+  // CHECK-MESSAGES: :[[@LINE+1]]:8: warning: predefined standard stream objects should not be used outside the main function [misc-avoid-std-io-outside-main]
+  std::cout << "This should trigger the check";
+
+  // CHECK-MESSAGES: :[[@LINE+1]]:8: warning: predefined standard stream objects should not be used outside the main function [misc-avoid-std-io-outside-main]
+  std::wcout << "This should trigger the check";
+
+  // CHECK-MESSAGES: :[[@LINE+1]]:8: warning: predefined standard stream objects should not be used outside the main function [misc-avoid-std-io-outside-main]
+  std::cerr << "This should trigger the check";
+
+  // CHECK-MESSAGES: :[[@LINE+1]]:8: warning: predefined standard stream objects should not be used outside the main function [misc-avoid-std-io-outside-main]
+  std::wcerr << "This should trigger the check";
+
+  arbitrary_namespace::cout << "This should not trigger the check"; // OK
+
+  std::string Foo{"bar"};
+
+  // CHECK-MESSAGES: :[[@LINE+1]]:8: warning: predefined standard stream objects should not be used outside the main function [misc-avoid-std-io-outside-main]
+  std::cin >> Foo;
+
+  // CHECK-MESSAGES: :[[@LINE+1]]:8: warning: predefined standard stream objects should not be used outside the main function [misc-avoid-std-io-outside-main]
+  std::wcin >> Foo;
+
+  arbitrary_namespace::cin >> Foo; // OK
+
+  // CHECK-MESSAGES: :[[@LINE+1]]:8: warning: cstdio functions should not be used outside the main function [misc-avoid-std-io-outside-main]
+  std::printf("This should trigger the check");
+  // CHECK-MESSAGES: :[[@LINE+1]]:3: warning: cstdio functions should not be used outside the main function [misc-avoid-std-io-outside-main]
+  printf("This should trigger the check");
+
+  // CHECK-MESSAGES: :[[@LINE+1]]:8: warning: cstdio functions should not be used outside the main function [misc-avoid-std-io-outside-main]
+  std::puts("This should trigger the check");
+  // CHECK-MESSAGES: :[[@LINE+1]]:3: warning: cstdio functions should not be used outside the main function [misc-avoid-std-io-outside-main]
+  puts("This should trigger the check");
+
+  // CHECK-MESSAGES: :[[@LINE+1]]:8: warning: cstdio functions should not be used outside the main function [misc-avoid-std-io-outside-main]
+  std::putchar('m');
+  // CHECK-MESSAGES: :[[@LINE+1]]:3: warning: cstdio functions should not be used outside the main function [misc-avoid-std-io-outside-main]
+  putchar('m');
+
+  char Input[5];
+  // CHECK-MESSAGES: :[[@LINE+1]]:8: warning: cstdio functions should not be used outside the main function [misc-avoid-std-io-outside-main]
+  std::scanf("%s", Input);
+  // CHECK-MESSAGES: :[[@LINE+1]]:3: warning: cstdio functions should not be used outside the main function [misc-avoid-std-io-outside-main]
+  scanf("%s", Input);
+
+  // CHECK-MESSAGES: :[[@LINE+1]]:8: warning: cstdio functions should not be used outside the main function [misc-avoid-std-io-outside-main]
+  std::getchar();
+  // CHECK-MESSAGES: :[[@LINE+1]]:3: warning: cstdio functions shou

[clang-tools-extra] f088af3 - [clangd] Fix data type of WorkDoneProgressReport::percentage

2021-05-10 Thread Kadir Cetinkaya via cfe-commits

Author: Christian Kandeler
Date: 2021-05-10T14:57:20+02:00
New Revision: f088af37e6b570dd070ae4e6fc14e22d21cda3be

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

LOG: [clangd] Fix data type of WorkDoneProgressReport::percentage

According to the specification, this should be an unsigned integer.

Reviewed By: sammccall

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

Added: 


Modified: 
clang-tools-extra/clangd/ClangdLSPServer.cpp
clang-tools-extra/clangd/Protocol.h

Removed: 




diff  --git a/clang-tools-extra/clangd/ClangdLSPServer.cpp 
b/clang-tools-extra/clangd/ClangdLSPServer.cpp
index 913c5c3219a5..c25195cd338f 100644
--- a/clang-tools-extra/clangd/ClangdLSPServer.cpp
+++ b/clang-tools-extra/clangd/ClangdLSPServer.cpp
@@ -1606,7 +1606,7 @@ void ClangdLSPServer::onBackgroundIndexProgress(
 if (Stats.Completed < Stats.Enqueued) {
   assert(Stats.Enqueued > Stats.LastIdle);
   WorkDoneProgressReport Report;
-  Report.percentage = 100.0 * (Stats.Completed - Stats.LastIdle) /
+  Report.percentage = 100 * (Stats.Completed - Stats.LastIdle) /
   (Stats.Enqueued - Stats.LastIdle);
   Report.message =
   llvm::formatv("{0}/{1}", Stats.Completed - Stats.LastIdle,

diff  --git a/clang-tools-extra/clangd/Protocol.h 
b/clang-tools-extra/clangd/Protocol.h
index 2ae60910639e..f0d46ab8a010 100644
--- a/clang-tools-extra/clangd/Protocol.h
+++ b/clang-tools-extra/clangd/Protocol.h
@@ -631,7 +631,7 @@ struct WorkDoneProgressReport {
   ///
   /// The value should be steadily rising. Clients are free to ignore values
   /// that are not following this rule.
-  llvm::Optional percentage;
+  llvm::Optional percentage;
 };
 llvm::json::Value toJSON(const WorkDoneProgressReport &);
 //



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


[PATCH] D101616: [clangd] Fix data type of WorkDoneProgressReport::percentage

2021-05-10 Thread Kadir Cetinkaya 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 rGf088af37e6b5: [clangd] Fix data type of 
WorkDoneProgressReport::percentage (authored by ckandeler, committed by 
kadircet).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101616

Files:
  clang-tools-extra/clangd/ClangdLSPServer.cpp
  clang-tools-extra/clangd/Protocol.h


Index: clang-tools-extra/clangd/Protocol.h
===
--- clang-tools-extra/clangd/Protocol.h
+++ clang-tools-extra/clangd/Protocol.h
@@ -631,7 +631,7 @@
   ///
   /// The value should be steadily rising. Clients are free to ignore values
   /// that are not following this rule.
-  llvm::Optional percentage;
+  llvm::Optional percentage;
 };
 llvm::json::Value toJSON(const WorkDoneProgressReport &);
 //
Index: clang-tools-extra/clangd/ClangdLSPServer.cpp
===
--- clang-tools-extra/clangd/ClangdLSPServer.cpp
+++ clang-tools-extra/clangd/ClangdLSPServer.cpp
@@ -1606,7 +1606,7 @@
 if (Stats.Completed < Stats.Enqueued) {
   assert(Stats.Enqueued > Stats.LastIdle);
   WorkDoneProgressReport Report;
-  Report.percentage = 100.0 * (Stats.Completed - Stats.LastIdle) /
+  Report.percentage = 100 * (Stats.Completed - Stats.LastIdle) /
   (Stats.Enqueued - Stats.LastIdle);
   Report.message =
   llvm::formatv("{0}/{1}", Stats.Completed - Stats.LastIdle,


Index: clang-tools-extra/clangd/Protocol.h
===
--- clang-tools-extra/clangd/Protocol.h
+++ clang-tools-extra/clangd/Protocol.h
@@ -631,7 +631,7 @@
   ///
   /// The value should be steadily rising. Clients are free to ignore values
   /// that are not following this rule.
-  llvm::Optional percentage;
+  llvm::Optional percentage;
 };
 llvm::json::Value toJSON(const WorkDoneProgressReport &);
 //
Index: clang-tools-extra/clangd/ClangdLSPServer.cpp
===
--- clang-tools-extra/clangd/ClangdLSPServer.cpp
+++ clang-tools-extra/clangd/ClangdLSPServer.cpp
@@ -1606,7 +1606,7 @@
 if (Stats.Completed < Stats.Enqueued) {
   assert(Stats.Enqueued > Stats.LastIdle);
   WorkDoneProgressReport Report;
-  Report.percentage = 100.0 * (Stats.Completed - Stats.LastIdle) /
+  Report.percentage = 100 * (Stats.Completed - Stats.LastIdle) /
   (Stats.Enqueued - Stats.LastIdle);
   Report.message =
   llvm::formatv("{0}/{1}", Stats.Completed - Stats.LastIdle,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D101616: [clangd] Fix data type of WorkDoneProgressReport::percentage

2021-05-10 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added a comment.

done, sorry for the delay!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101616

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


[PATCH] D101616: [clangd] Fix data type of WorkDoneProgressReport::percentage

2021-05-10 Thread Christian Kandeler via Phabricator via cfe-commits
ckandeler added a comment.

No problem, thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101616

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


[PATCH] D99646: [clang-tidy] misc-avoid-std-io-outside-main: a new check

2021-05-10 Thread Marco Gartmann via Phabricator via cfe-commits
mgartmann updated this revision to Diff 344043.
mgartmann added a comment.

Revert `ReleaseNotes.rst` to a point where the build worked.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99646

Files:
  clang-tools-extra/clang-tidy/misc/AvoidStdIoOutsideMainCheck.cpp
  clang-tools-extra/clang-tidy/misc/AvoidStdIoOutsideMainCheck.h
  clang-tools-extra/clang-tidy/misc/CMakeLists.txt
  clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/docs/clang-tidy/checks/misc-avoid-std-io-outside-main.rst
  clang-tools-extra/test/clang-tidy/checkers/misc-avoid-std-io-outside-main.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/misc-avoid-std-io-outside-main.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/misc-avoid-std-io-outside-main.cpp
@@ -0,0 +1,138 @@
+// RUN: %check_clang_tidy %s misc-avoid-std-io-outside-main %t
+
+namespace std {
+struct string {
+  string(const char *);
+  ~string();
+};
+
+struct Ostream {
+  Ostream &operator<<(string Message);
+};
+
+struct Istream {
+  Istream &operator>>(string Message);
+};
+
+Ostream cout{}, wcout{}, cerr{}, wcerr{};
+Istream cin{}, wcin{};
+
+int printf(const char *Format, ...);
+int vprintf(const char *const, ...);
+int puts(const char *Str);
+int putchar(int Character);
+int scanf(const char *Format, ...);
+int getchar(void);
+char *gets(char *Str);
+} // namespace std
+
+int printf(const char *Format, ...);
+int vprintf(const char *const, ...);
+int puts(const char *Str);
+int putchar(int Character);
+int scanf(const char *Format, ...);
+int getchar(void);
+char *gets(char *Str);
+
+namespace arbitrary_namespace {
+std::Ostream cout{};
+std::Istream cin{};
+} // namespace arbitrary_namespace
+
+void anyNonMainFunction() {
+  // CHECK-MESSAGES: :[[@LINE+1]]:8: warning: predefined standard stream objects should not be used outside the main function [misc-avoid-std-io-outside-main]
+  std::cout << "This should trigger the check";
+
+  // CHECK-MESSAGES: :[[@LINE+1]]:8: warning: predefined standard stream objects should not be used outside the main function [misc-avoid-std-io-outside-main]
+  std::wcout << "This should trigger the check";
+
+  // CHECK-MESSAGES: :[[@LINE+1]]:8: warning: predefined standard stream objects should not be used outside the main function [misc-avoid-std-io-outside-main]
+  std::cerr << "This should trigger the check";
+
+  // CHECK-MESSAGES: :[[@LINE+1]]:8: warning: predefined standard stream objects should not be used outside the main function [misc-avoid-std-io-outside-main]
+  std::wcerr << "This should trigger the check";
+
+  arbitrary_namespace::cout << "This should not trigger the check"; // OK
+
+  std::string Foo{"bar"};
+
+  // CHECK-MESSAGES: :[[@LINE+1]]:8: warning: predefined standard stream objects should not be used outside the main function [misc-avoid-std-io-outside-main]
+  std::cin >> Foo;
+
+  // CHECK-MESSAGES: :[[@LINE+1]]:8: warning: predefined standard stream objects should not be used outside the main function [misc-avoid-std-io-outside-main]
+  std::wcin >> Foo;
+
+  arbitrary_namespace::cin >> Foo; // OK
+
+  // CHECK-MESSAGES: :[[@LINE+1]]:8: warning: cstdio functions should not be used outside the main function [misc-avoid-std-io-outside-main]
+  std::printf("This should trigger the check");
+  // CHECK-MESSAGES: :[[@LINE+1]]:3: warning: cstdio functions should not be used outside the main function [misc-avoid-std-io-outside-main]
+  printf("This should trigger the check");
+
+  // CHECK-MESSAGES: :[[@LINE+1]]:8: warning: cstdio functions should not be used outside the main function [misc-avoid-std-io-outside-main]
+  std::puts("This should trigger the check");
+  // CHECK-MESSAGES: :[[@LINE+1]]:3: warning: cstdio functions should not be used outside the main function [misc-avoid-std-io-outside-main]
+  puts("This should trigger the check");
+
+  // CHECK-MESSAGES: :[[@LINE+1]]:8: warning: cstdio functions should not be used outside the main function [misc-avoid-std-io-outside-main]
+  std::putchar('m');
+  // CHECK-MESSAGES: :[[@LINE+1]]:3: warning: cstdio functions should not be used outside the main function [misc-avoid-std-io-outside-main]
+  putchar('m');
+
+  char Input[5];
+  // CHECK-MESSAGES: :[[@LINE+1]]:8: warning: cstdio functions should not be used outside the main function [misc-avoid-std-io-outside-main]
+  std::scanf("%s", Input);
+  // CHECK-MESSAGES: :[[@LINE+1]]:3: warning: cstdio functions should not be used outside the main function [misc-avoid-std-io-outside-main]
+  scanf("%s", Input);
+
+  // CHECK-MESSAGES: :[[@LINE+1]]:8: warning: cstdio functions should not be used outside the main function [misc-avoid-std-io-outside-main]
+  std::getchar();
+  // CHECK-MESSAGES: :[[@LINE+1]]:3: warning: cstdio functions 

[clang] 230953d - [OPENMP]Fix PR48851: the locals are not globalized in SPMD mode.

2021-05-10 Thread Alexey Bataev via cfe-commits

Author: Alexey Bataev
Date: 2021-05-10T06:34:11-07:00
New Revision: 230953d5771f6f3ce6bf86b8bb6ae4d5eb75a218

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

LOG: [OPENMP]Fix PR48851: the locals are not globalized in SPMD mode.

Follow the more general patch for now, do not try to SPMDize the kernel
if the variable is used and local.

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

Added: 


Modified: 
clang/lib/CodeGen/CGOpenMPRuntime.cpp
clang/test/OpenMP/nvptx_SPMD_codegen.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp 
b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
index 38341cb3288e..fc315b24687c 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -6561,7 +6561,7 @@ const Stmt 
*CGOpenMPRuntime::getSingleCompoundChild(ASTContext &Ctx,
 continue;
   // Analyze declarations.
   if (const auto *DS = dyn_cast(S)) {
-if (llvm::all_of(DS->decls(), [&Ctx](const Decl *D) {
+if (llvm::all_of(DS->decls(), [](const Decl *D) {
   if (isa(D) || isa(D) ||
   isa(D) || isa(D) ||
   isa(D) || isa(D) ||
@@ -6572,10 +6572,7 @@ const Stmt 
*CGOpenMPRuntime::getSingleCompoundChild(ASTContext &Ctx,
   const auto *VD = dyn_cast(D);
   if (!VD)
 return false;
-  return VD->isConstexpr() ||
- ((VD->getType().isTrivialType(Ctx) ||
-   VD->getType()->isReferenceType()) &&
-  (!VD->hasInit() || isTrivial(Ctx, VD->getInit(;
+  return VD->hasGlobalStorage() || !VD->isUsed();
 }))
   continue;
   }

diff  --git a/clang/test/OpenMP/nvptx_SPMD_codegen.cpp 
b/clang/test/OpenMP/nvptx_SPMD_codegen.cpp
index 6c54818e23d5..e000c818c9c2 100644
--- a/clang/test/OpenMP/nvptx_SPMD_codegen.cpp
+++ b/clang/test/OpenMP/nvptx_SPMD_codegen.cpp
@@ -120,10 +120,7 @@ int a;
 // CHECK-DAG: [[DISTR_LIGHT]]
 // CHECK-DAG: [[FOR_LIGHT]]
 // CHECK-DAG: [[LIGHT]]
-// CHECK: call void @__kmpc_spmd_kernel_init(i32 {{.+}}, i16 0)
-// CHECK-DAG: [[DISTR_LIGHT]]
-// CHECK-DAG: [[FOR_LIGHT]]
-// CHECK-DAG: [[LIGHT]]
+// CHECK: call void @__kmpc_kernel_init(
 // CHECK: call void @__kmpc_spmd_kernel_init(i32 {{.+}}, i16 1)
 // CHECK-DAG: [[DISTR_FULL]]
 // CHECK-DAG: [[FULL]]



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


[PATCH] D101911: [OPENMP]Fix PR48851: the locals are not globalized in SPMD mode.

2021-05-10 Thread Alexey Bataev 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 rG230953d5771f: [OPENMP]Fix PR48851: the locals are not 
globalized in SPMD mode. (authored by ABataev).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101911

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/test/OpenMP/nvptx_SPMD_codegen.cpp


Index: clang/test/OpenMP/nvptx_SPMD_codegen.cpp
===
--- clang/test/OpenMP/nvptx_SPMD_codegen.cpp
+++ clang/test/OpenMP/nvptx_SPMD_codegen.cpp
@@ -120,10 +120,7 @@
 // CHECK-DAG: [[DISTR_LIGHT]]
 // CHECK-DAG: [[FOR_LIGHT]]
 // CHECK-DAG: [[LIGHT]]
-// CHECK: call void @__kmpc_spmd_kernel_init(i32 {{.+}}, i16 0)
-// CHECK-DAG: [[DISTR_LIGHT]]
-// CHECK-DAG: [[FOR_LIGHT]]
-// CHECK-DAG: [[LIGHT]]
+// CHECK: call void @__kmpc_kernel_init(
 // CHECK: call void @__kmpc_spmd_kernel_init(i32 {{.+}}, i16 1)
 // CHECK-DAG: [[DISTR_FULL]]
 // CHECK-DAG: [[FULL]]
Index: clang/lib/CodeGen/CGOpenMPRuntime.cpp
===
--- clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -6561,7 +6561,7 @@
 continue;
   // Analyze declarations.
   if (const auto *DS = dyn_cast(S)) {
-if (llvm::all_of(DS->decls(), [&Ctx](const Decl *D) {
+if (llvm::all_of(DS->decls(), [](const Decl *D) {
   if (isa(D) || isa(D) ||
   isa(D) || isa(D) ||
   isa(D) || isa(D) ||
@@ -6572,10 +6572,7 @@
   const auto *VD = dyn_cast(D);
   if (!VD)
 return false;
-  return VD->isConstexpr() ||
- ((VD->getType().isTrivialType(Ctx) ||
-   VD->getType()->isReferenceType()) &&
-  (!VD->hasInit() || isTrivial(Ctx, VD->getInit(;
+  return VD->hasGlobalStorage() || !VD->isUsed();
 }))
   continue;
   }


Index: clang/test/OpenMP/nvptx_SPMD_codegen.cpp
===
--- clang/test/OpenMP/nvptx_SPMD_codegen.cpp
+++ clang/test/OpenMP/nvptx_SPMD_codegen.cpp
@@ -120,10 +120,7 @@
 // CHECK-DAG: [[DISTR_LIGHT]]
 // CHECK-DAG: [[FOR_LIGHT]]
 // CHECK-DAG: [[LIGHT]]
-// CHECK: call void @__kmpc_spmd_kernel_init(i32 {{.+}}, i16 0)
-// CHECK-DAG: [[DISTR_LIGHT]]
-// CHECK-DAG: [[FOR_LIGHT]]
-// CHECK-DAG: [[LIGHT]]
+// CHECK: call void @__kmpc_kernel_init(
 // CHECK: call void @__kmpc_spmd_kernel_init(i32 {{.+}}, i16 1)
 // CHECK-DAG: [[DISTR_FULL]]
 // CHECK-DAG: [[FULL]]
Index: clang/lib/CodeGen/CGOpenMPRuntime.cpp
===
--- clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -6561,7 +6561,7 @@
 continue;
   // Analyze declarations.
   if (const auto *DS = dyn_cast(S)) {
-if (llvm::all_of(DS->decls(), [&Ctx](const Decl *D) {
+if (llvm::all_of(DS->decls(), [](const Decl *D) {
   if (isa(D) || isa(D) ||
   isa(D) || isa(D) ||
   isa(D) || isa(D) ||
@@ -6572,10 +6572,7 @@
   const auto *VD = dyn_cast(D);
   if (!VD)
 return false;
-  return VD->isConstexpr() ||
- ((VD->getType().isTrivialType(Ctx) ||
-   VD->getType()->isReferenceType()) &&
-  (!VD->hasInit() || isTrivial(Ctx, VD->getInit(;
+  return VD->hasGlobalStorage() || !VD->isUsed();
 }))
   continue;
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D101775: Fix for Bug 50033 - -fno-temp-file is not respected when creating a pch in clang 12

2021-05-10 Thread Zachary Henkel via Phabricator via cfe-commits
zahen added a comment.

> If no one has ideas in the next few days, I'll "accept" and commit for you. 
> (Feel free to ping me; there's a good chance I'll lose track of this 
> otherwise; usual ping rate is 1x/week, but happy for you to ping me sooner on 
> this...)

@dexonsmith Ping as requested.  Unfortunately I haven't come up with any way to 
get this tested in a cross-platform manner.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101775

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


[PATCH] D96524: [OpenCL] Add support of OpenCL C 3.0 __opencl_c_fp64

2021-05-10 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticCommonKinds.td:369
+def err_opencl_extension_and_feature_differs : Error<
+  "Options %0 and %1 are set to different values which is illegal in OpenCL C 
3.0">;
 }

We don't normally start from the upper case:

`Options` -> `options`

I am thinking we could drop "which is illegal in OpenCL C 3.0" because the fact 
that compiler gives an error indicates that it is illegal. So I find it a bit 
redundant.



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:121
 def warn_double_const_requires_fp64 : Warning<
-  "double precision constant requires cl_khr_fp64, casting to single 
precision">;
+  "double precision constant requires %select{cl_khr_fp64|__opencl_c_fp64}0, "
+  "casting to single precision">;

I am thinking that in OpenCL 3 both `cl_khr_fp64` and `__opencl_c_fp64` are 
required. Maybe we should re-word this as follows?




Comment at: clang/lib/Sema/Sema.cpp:306
+// Set conditionally to provide correct diagnostics for 'double' type
+llvm::StringRef FP64Feature(
+getLangOpts().OpenCLVersion >= 300 ? "__opencl_c_fp64" : 
"cl_khr_fp64");

Technically both "__opencl_c_fp64" and "cl_khr_fp64" are required in OpenCL, 
perhaps we should report both in OpenCL 3?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96524

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


[PATCH] D102168: Use an allow list on reserved macro identifiers

2021-05-10 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a subscriber: cfe-commits.
aaron.ballman added a comment.

Adding cfe-commits.


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

https://reviews.llvm.org/D102168

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


[PATCH] D102168: Use an allow list on reserved macro identifiers

2021-05-10 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

Some additional ones to allow from MSDN: `_CRT_SECURE_NO_WARNINGS`, 
`_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES`, `_CRT_NONSTDC_NO_WARNINGS`,  
(https://docs.microsoft.com/en-us/cpp/c-runtime-library/security-features-in-the-crt?view=msvc-160).




Comment at: clang/lib/Lex/PPDirectives.cpp:125
+  if (II->isReserved(Lang) != ReservedIdentifierStatus::NotReserved) {
+static constexpr std::array ReservedMacro = {
+"_ATFILE_SOURCE",   "_BSD_SOURCE","_FILE_OFFSET_BITS",




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

https://reviews.llvm.org/D102168

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


[PATCH] D102168: Use an allow list on reserved macro identifiers

2021-05-10 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/lib/Lex/PPDirectives.cpp:125
+  if (II->isReserved(Lang) != ReservedIdentifierStatus::NotReserved) {
+static constexpr std::array ReservedMacro = {
+"_ATFILE_SOURCE",   "_BSD_SOURCE","_FILE_OFFSET_BITS",

aaron.ballman wrote:
> 
Can you add a comment that this list is required to remain in alphabetical 
order (due to the use of `binary_search`) and list the identifiers in long-form 
rather than columns of three (this makes it easier for folks inserting new 
elements into the list)?


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

https://reviews.llvm.org/D102168

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


[PATCH] D102164: [NFC] Syndicate reserved identifier code between macro and variables / symbols

2021-05-10 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a subscriber: cfe-commits.
aaron.ballman added a comment.

Adding cfe-commits


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

https://reviews.llvm.org/D102164

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


[PATCH] D102147: [Clang][Coroutines] Implement P2014R0 Option 1 behind -fcoroutines-aligned-alloc

2021-05-10 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added a comment.

In D102147#2747611 , @ChuanqiXu wrote:

> Since D97915  would fix the problem that the 
> variables in the frame may not be aligned, I think this option 
> `fcoroutines-aligned-alloc` won't affect normal programmers other than 
> language lawyers. Do you think so?

I think that's right that if all a user want is alignment, then 
`fcoroutines-aligned-alloc` may not be necessay. However if they define 
customed aligned allocators/dealllocators, this is needed to make it work.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102147

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


[clang] 5c7b43a - [clang][AArch32] Correctly align HA arguments when passed on the stack

2021-05-10 Thread Momchil Velikov via cfe-commits

Author: Momchil Velikov
Date: 2021-05-10T16:28:46+01:00
New Revision: 5c7b43aa8298a389b906d72c792941a0ce57782e

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

LOG: [clang][AArch32] Correctly align HA arguments when passed on the stack

Analogously to https://reviews.llvm.org/D98794 this patch uses the
`alignstack` attribute to fix incorrect passing of homogeneous
aggregate (HA) arguments on AArch32. The EABI/AAPCS was recently
updated to clarify how VFP co-processor candidates are aligned:
https://github.com/ARM-software/abi-aa/commit/4488e34998514dc7af5507236f279f6881eede62

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

Added: 
clang/test/CodeGen/arm-ha-alignstack.c
llvm/test/CodeGen/ARM/ha-alignstack-call.ll
llvm/test/CodeGen/ARM/ha-alignstack.ll

Modified: 
clang/lib/CodeGen/TargetInfo.cpp
llvm/lib/Target/ARM/ARMCallingConv.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/TargetInfo.cpp 
b/clang/lib/CodeGen/TargetInfo.cpp
index 633b963965ed6..af516bbc8d312 100644
--- a/clang/lib/CodeGen/TargetInfo.cpp
+++ b/clang/lib/CodeGen/TargetInfo.cpp
@@ -6440,7 +6440,16 @@ ABIArgInfo 
ARMABIInfo::classifyHomogeneousAggregate(QualType Ty,
   return ABIArgInfo::getDirect(Ty, 0, nullptr, false);
 }
   }
-  return ABIArgInfo::getDirect(nullptr, 0, nullptr, false);
+  unsigned Align = 0;
+  if (getABIKind() == ARMABIInfo::AAPCS ||
+  getABIKind() == ARMABIInfo::AAPCS_VFP) {
+// For alignment adjusted HFAs, cap the argument alignment to 8, leave it
+// default otherwise.
+Align = getContext().getTypeUnadjustedAlignInChars(Ty).getQuantity();
+unsigned BaseAlign = getContext().getTypeAlignInChars(Base).getQuantity();
+Align = (Align > BaseAlign && Align >= 8) ? 8 : 0;
+  }
+  return ABIArgInfo::getDirect(nullptr, 0, nullptr, false, Align);
 }
 
 ABIArgInfo ARMABIInfo::classifyArgumentType(QualType Ty, bool isVariadic,

diff  --git a/clang/test/CodeGen/arm-ha-alignstack.c 
b/clang/test/CodeGen/arm-ha-alignstack.c
new file mode 100644
index 0..a4f7e4af2f13a
--- /dev/null
+++ b/clang/test/CodeGen/arm-ha-alignstack.c
@@ -0,0 +1,114 @@
+// RUN: %clang_cc1 -triple armv7-eabi
-emit-llvm %s -o - | \
+// RUN: FileCheck %s --check-prefixes=CHECK,CHECK-SOFT
+// RUN: %clang_cc1 -triple armv7-eabi -target-abi aapcs -mfloat-abi hard 
-emit-llvm %s -o - | \
+// RUN:FileCheck %s --check-prefixes=CHECK,CHECK-HARD
+// REQUIRES: arm-registered-target
+
+// CHECK: %struct.S0 = type { [4 x float] }
+// CHECK: %struct.S1 = type { [2 x float] }
+// CHECK: %struct.S2 = type { [4 x float] }
+// CHECK: %struct.D0 = type { [2 x double] }
+// CHECK: %struct.D1 = type { [2 x double] }
+// CHECK: %struct.D2 = type { [4 x double] }
+
+typedef struct {
+  float v[4];
+} S0;
+
+float f0(S0 s) {
+// CHECK-SOFT: define{{.*}} float @f0([4 x i32]  %s.coerce)
+// CHECK-HARD: define{{.*}} arm_aapcs_vfpcc float @f0(%struct.S0 %s.coerce)
+  return s.v[0];
+}
+
+float f0call() {
+  S0 s = {0.0f, };
+  return f0(s);
+// CHECK-SOFT: call float @f0([4 x i32]
+// CHECK-HARD: call arm_aapcs_vfpcc float @f0(%struct.S0
+}
+
+typedef struct {
+  __attribute__((aligned(8))) float v[2];
+} S1;
+
+float f1(S1 s) {
+// CHECK-SOFT: define{{.*}} float @f1([1 x i64]
+// CHECK-HARD: define{{.*}} arm_aapcs_vfpcc float @f1(%struct.S1 alignstack(8)
+  return s.v[0];
+}
+
+float f1call() {
+  S1 s = {0.0f, };
+  return f1(s);
+// CHECK-SOFT: call float @f1([1 x i64
+// CHECK-HARD: call arm_aapcs_vfpcc float @f1(%struct.S1 alignstack(8)
+}
+
+typedef struct {
+  __attribute__((aligned(16))) float v[4];
+} S2;
+
+float f2(S2 s) {
+// CHECK-SOFT: define{{.*}} float @f2([2 x i64]
+// CHECK-HARD: define{{.*}} arm_aapcs_vfpcc float @f2(%struct.S2 alignstack(8)
+  return s.v[0];
+}
+
+float f2call() {
+  S2 s = {0.0f, };
+  return f2(s);
+// CHECK-SOFT: call float @f2([2 x i64]
+// CHECK-HARD: call arm_aapcs_vfpcc float @f2(%struct.S2 alignstack(8)
+}
+
+typedef struct {
+  double v[2];
+} D0;
+
+double g0(D0 d) {
+// CHECK-SOFT: define{{.*}} double @g0([2 x i64]
+// CHECK-HARD: define{{.*}} arm_aapcs_vfpcc double @g0(%struct.D0 %d.coerce
+  return d.v[0];
+}
+
+double g0call() {
+  D0 d = {0.0, };
+  return g0(d);
+// CHECK-SOFT: call double @g0([2 x i64]
+// CHECK-HARD: call arm_aapcs_vfpcc double @g0(%struct.D0 %1
+}
+
+typedef struct {
+  __attribute__((aligned(16))) double v[2];
+} D1;
+
+double g1(D1 d) {
+// CHECK-SOFT: define{{.*}} double @g1([2 x i64]
+// CHECK-HARD: define{{.*}} arm_aapcs_vfpcc double @g1(%struct.D1 alignstack(8)
+  return d.v[0];
+}
+
+double g1call() {
+  D1 d = {0.0, };
+  return g1(d);
+// CHECK-SOFT: call double @g1([2 x i64]
+// CHECK-HARD: call arm_aapcs_vfpcc double @g1(%struct.D1 alignstack(8)
+}
+
+typedef struc

[PATCH] D100853: [clang][AArch32] Correctly align HA arguments when passed on the stack

2021-05-10 Thread Momchil Velikov 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 rG5c7b43aa8298: [clang][AArch32] Correctly align HA arguments 
when passed on the stack (authored by chill).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100853

Files:
  clang/lib/CodeGen/TargetInfo.cpp
  clang/test/CodeGen/arm-ha-alignstack.c
  llvm/lib/Target/ARM/ARMCallingConv.cpp
  llvm/test/CodeGen/ARM/ha-alignstack-call.ll
  llvm/test/CodeGen/ARM/ha-alignstack.ll

Index: llvm/test/CodeGen/ARM/ha-alignstack.ll
===
--- /dev/null
+++ llvm/test/CodeGen/ARM/ha-alignstack.ll
@@ -0,0 +1,190 @@
+; RUN: llc --mtriple armv7-eabihf %s -o - | FileCheck %s
+
+%struct.S0 = type { [4 x float] }
+%struct.S1 = type { [2 x float] }
+%struct.S2 = type { [4 x float] }
+%struct.D0 = type { [2 x double] }
+%struct.D1 = type { [2 x double] }
+%struct.D2 = type { [4 x double] }
+
+; pass in registers
+define dso_local float @f0_0(double %d0, double %d1, double %d2, double %d3, double %d4, double %d5, %struct.S0 %s.coerce) local_unnamed_addr #0 {
+entry:
+  %s.coerce.fca.0.0.extract = extractvalue %struct.S0 %s.coerce, 0, 0
+  ret float %s.coerce.fca.0.0.extract
+}
+; CHECK-LABEL: f0_0:
+; CHECK:   vmov.f32 s0, s12
+; CHECK-NEXT:  bx   lr
+
+; pass in memory, no memory/regs split
+define dso_local float @f0_1(double %d0, double %d1, double %d2, double %d3, double %d4, double %d5, float %x, %struct.S0 %s.coerce) local_unnamed_addr #0 {
+entry:
+  %s.coerce.fca.0.0.extract = extractvalue %struct.S0 %s.coerce, 0, 0
+  ret float %s.coerce.fca.0.0.extract
+}
+; CHECK-LABEL: f0_1:
+; CHECK:   vldr s0, [sp]
+; CHECK-NEXT:  bx   lr
+
+; pass in memory, alignment 4
+define dso_local float @f0_2(double %d0, double %d1, double %d2, double %d3, double %d4, double %d5, double %d6, double %d7, float %x, %struct.S0 %s.coerce) local_unnamed_addr #0 {
+entry:
+  %s.coerce.fca.0.0.extract = extractvalue %struct.S0 %s.coerce, 0, 0
+  ret float %s.coerce.fca.0.0.extract
+}
+; CHECK-LABEL: f0_2:
+; CHECK:   vldr s0, [sp, #4]
+; CHECK-NEXT:  bx   lr
+
+; pass in registers
+define dso_local float @f1_0(double %d0, double %d1, double %d2, double %d3, double %d4, double %d5, double %d6, %struct.S1 alignstack(8) %s.coerce) local_unnamed_addr #0 {
+entry:
+  %s.coerce.fca.0.0.extract = extractvalue %struct.S1 %s.coerce, 0, 0
+  ret float %s.coerce.fca.0.0.extract
+}
+; CHECK-LABEL: f1_0:
+; CHECK:   vmov.f32 s0, s14
+; CHECK-NEXT:  bx   lr
+
+; pass in memory, no memory/regs split
+define dso_local float @f1_1(double %d0, double %d1, double %d2, double %d3, double %d4, double %d5, double %d6, float %x, %struct.S1 alignstack(8) %s.coerce) local_unnamed_addr #0 {
+entry:
+  %s.coerce.fca.0.0.extract = extractvalue %struct.S1 %s.coerce, 0, 0
+  ret float %s.coerce.fca.0.0.extract
+}
+; CHECK-LABEL: f1_1:
+; CHECK:   vldr s0, [sp]
+; CHECK-NEXT:  bx   lr
+
+; pass in memory, alignment 8
+define dso_local float @f1_2(double %d0, double %d1, double %d2, double %d3, double %d4, double %d5, double %d6, double %d7, float %x, %struct.S1 alignstack(8) %s.coerce) local_unnamed_addr #0 {
+entry:
+  %s.coerce.fca.0.0.extract = extractvalue %struct.S1 %s.coerce, 0, 0
+  ret float %s.coerce.fca.0.0.extract
+}
+; CHECK-LABEL: f1_2:
+; CHECK:   vldr s0, [sp, #8]
+; CHECK-NEXT:  bx   lr
+
+; pass in registers
+define dso_local float @f2_0(double %d0, double %d1, double %d2, double %d3, double %d4, double %d5, %struct.S2 alignstack(8) %s.coerce) local_unnamed_addr #0 {
+entry:
+  %s.coerce.fca.0.0.extract = extractvalue %struct.S2 %s.coerce, 0, 0
+  ret float %s.coerce.fca.0.0.extract
+}
+; CHECK-LABEL: f2_0:
+; CHECK:   vmov.f32 s0, s12
+; CHECK-NEXT:  bx   lr
+
+; pass in memory, no memory/regs split
+define dso_local float @f2_1(double %d0, double %d1, double %d2, double %d3, double %d4, double %d5, float %x, %struct.S2 alignstack(8) %s.coerce) local_unnamed_addr #0 {
+entry:
+  %s.coerce.fca.0.0.extract = extractvalue %struct.S2 %s.coerce, 0, 0
+  ret float %s.coerce.fca.0.0.extract
+}
+; CHECK-LABEL: f2_1:
+; CHECK:   vldr s0, [sp]
+; CHECK-NEXT:  bx   lr
+
+; pass in memory, alignment 8
+define dso_local float @f2_2(double %d0, double %d1, double %d2, double %d3, double %d4, double %d5, double %d6, double %d7, float %x, %struct.S2 alignstack(8) %s.coerce) local_unnamed_addr #0 {
+entry:
+  %s.coerce.fca.0.0.extract = extractvalue %struct.S2 %s.coerce, 0, 0
+  ret float %s.coerce.fca.0.0.extract
+}
+; CHECK-LABEL: f2_2:
+; CHECK:   vldr s0, [sp, #8]
+; CHECK-NEXT:  bx   lr
+
+; pass in registers
+define dso_local double @g0_0(double %d0, double %d1, double %d2, double %d3, double %d4, double %d5, %struct.D0 %s.coerce) local_unnamed_addr #0 {
+entry:
+  %s

[PATCH] D102164: [NFC] Syndicate reserved identifier code between macro and variables / symbols

2021-05-10 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! You probably should change `Syndicate` to `Synchronize` in the commit 
message when you land it, though.


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

https://reviews.llvm.org/D102164

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


[PATCH] D102070: [AIX][TLS] Diagnose use of unimplemented TLS models

2021-05-10 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.

LGTM aside from the single quotes in the diagnostic.




Comment at: clang/include/clang/Basic/DiagnosticDriverKinds.td:548
 
+def err_aix_unsupported_tls_model : Error<"The tls model %0 is not yet 
supported on AIX">;
+

aaron.ballman wrote:
> This neatly avoids the problem of diagnostics not starting with a capital 
> letter (it looks like we have other diagnostics to update, but that's not 
> your problem to deal with).
Can you also add the single quotes around the %0 so that the diagnostic is 
properly quoted?



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:3154
 
+def err_aix_attr_unsupported_tls_model : Error<"The tls model %0 is not yet 
supported on AIX">;
+

aaron.ballman wrote:
> 
Same here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102070

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


Re: [clang] 4a47da2 - [Sema] turns -Wfree-nonheap-object on by default

2021-05-10 Thread David Blaikie via cfe-commits
Christopher - had a chance to look into this any further?

Roman - I'm OK either way on that. I don't think it's the most costly
false positive - not too much code is probably freeing via a reference
(rather than a pointer) to allocated memory.


On Fri, Apr 30, 2021 at 10:08 AM Roman Lebedev  wrote:
>
> Should the diagnostic be backed out until then?
>
> Roman
>
> On Fri, Apr 30, 2021 at 7:52 PM Christopher Di Bella via cfe-commits
>  wrote:
> >
> > Sorry, not yet. I'll talk with my TL to see if I can get some time allotted 
> > for this in the next few weeks.
> >
> > On Thu, 29 Apr 2021 at 16:13, David Blaikie  wrote:
> >>
> >> Ping on this - have you had a chance to look at this false positive?
> >>
> >> On Sat, Apr 3, 2021 at 4:29 PM David Blaikie  wrote:
> >> >
> >> > Looks like this has a false positive (that's firing on some mlir code,
> >> > committed a workaround in  499571ea835daf786626a0db1e12f890b6cd8f8d )
> >> > like this:
> >> >
> >> > $ cat test.cpp
> >> > #include 
> >> > void f1(int & x) { free(&x); }
> >> > int main() { f1(*(int*)malloc(sizeof(int))); }
> >> >
> >> > Could you fix that? (& then revert the workaround)
> >> >
> >> > On Fri, Jan 15, 2021 at 1:44 PM Christopher Di Bella via cfe-commits
> >> >  wrote:
> >> > >
> >> > >
> >> > > Author: Christopher Di Bella
> >> > > Date: 2021-01-15T21:38:47Z
> >> > > New Revision: 4a47da2cf440c2f2006d9b04acfef4292de1e263
> >> > >
> >> > > URL: 
> >> > > https://github.com/llvm/llvm-project/commit/4a47da2cf440c2f2006d9b04acfef4292de1e263
> >> > > DIFF: 
> >> > > https://github.com/llvm/llvm-project/commit/4a47da2cf440c2f2006d9b04acfef4292de1e263.diff
> >> > >
> >> > > LOG: [Sema] turns -Wfree-nonheap-object on by default
> >> > >
> >> > > We'd discussed adding the warning to -Wall in D89988. This patch 
> >> > > honours that.
> >> > >
> >> > > Added:
> >> > >
> >> > >
> >> > > Modified:
> >> > > clang/include/clang/Basic/DiagnosticGroups.td
> >> > > clang/include/clang/Basic/DiagnosticSemaKinds.td
> >> > > clang/test/Analysis/NewDelete-intersections.mm
> >> > > clang/test/Analysis/free.c
> >> > >
> >> > > Removed:
> >> > >
> >> > >
> >> > >
> >> > > 
> >> > > diff  --git a/clang/include/clang/Basic/DiagnosticGroups.td 
> >> > > b/clang/include/clang/Basic/DiagnosticGroups.td
> >> > > index d500ab321058..04ba89aa457e 100644
> >> > > --- a/clang/include/clang/Basic/DiagnosticGroups.td
> >> > > +++ b/clang/include/clang/Basic/DiagnosticGroups.td
> >> > > @@ -110,6 +110,7 @@ def FloatConversion :
> >> > >   FloatZeroConversion]>;
> >> > >
> >> > >  def FrameAddress : DiagGroup<"frame-address">;
> >> > > +def FreeNonHeapObject : DiagGroup<"free-nonheap-object">;
> >> > >  def DoublePromotion : DiagGroup<"double-promotion">;
> >> > >  def EnumTooLarge : DiagGroup<"enum-too-large">;
> >> > >  def UnsupportedNan : DiagGroup<"unsupported-nan">;
> >> > >
> >> > > diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
> >> > > b/clang/include/clang/Basic/DiagnosticSemaKinds.td
> >> > > index 7d36397a7993..e93657898f58 100644
> >> > > --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
> >> > > +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
> >> > > @@ -7609,7 +7609,7 @@ def err_no_typeid_with_fno_rtti : Error<
> >> > >  def err_no_dynamic_cast_with_fno_rtti : Error<
> >> > >"use of dynamic_cast requires -frtti">;
> >> > >  def warn_no_dynamic_cast_with_rtti_disabled: Warning<
> >> > > -  "dynamic_cast will not work since RTTI data is disabled by "
> >> > > +  "dynamic_cast will not work since RTTI data is disabled by "
> >> > >"%select{-fno-rtti-data|/GR-}0">, InGroup;
> >> > >  def warn_no_typeid_with_rtti_disabled: Warning<
> >> > >"typeid will not work since RTTI data is disabled by "
> >> > > @@ -7625,8 +7625,7 @@ def warn_condition_is_assignment : 
> >> > > Warning<"using the result of an "
> >> > >InGroup;
> >> > >  def warn_free_nonheap_object
> >> > >: Warning<"attempt to call %0 on non-heap object %1">,
> >> > > -InGroup>,
> >> > > -DefaultIgnore; // FIXME: add to -Wall after sufficient testing
> >> > > +InGroup;
> >> > >
> >> > >  // Completely identical except off by default.
> >> > >  def warn_condition_is_idiomatic_assignment : Warning<"using the 
> >> > > result "
> >> > >
> >> > > diff  --git a/clang/test/Analysis/NewDelete-intersections.mm 
> >> > > b/clang/test/Analysis/NewDelete-intersections.mm
> >> > > index f01d62f8d365..6f81034ee349 100644
> >> > > --- a/clang/test/Analysis/NewDelete-intersections.mm
> >> > > +++ b/clang/test/Analysis/NewDelete-intersections.mm
> >> > > @@ -24,9 +24,6 @@
> >> > >  extern "C" void free(void *);
> >> > >
> >> > >  void testMallocFreeNoWarn() {
> >> > > -  int i;
> >> > > -  free(&i); // no warn
> >> > > -
> >> > >int *p1 = (int *)malloc(sizeof(int));
> >> > >free(++p1); // no warn
> >> > >
> >> > > @@ -51,7 +48,7 @@ v

[PATCH] D99903: [Clang][Sema] better -Wcast-function-type diagnose for pointer parameters and parameters with cv-qualifiers

2021-05-10 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added a comment.

ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99903

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


[PATCH] D102175: [clang-tidy] performance-unnecessary-copy-initialization: Remove the complete statement when the copied variable is unused.

2021-05-10 Thread Felix Berger via Phabricator via cfe-commits
flx created this revision.
flx added reviewers: aaron.ballman, ymandel, hokein.
Herald added a subscriber: xazax.hun.
flx requested review of this revision.
Herald added a project: clang-tools-extra.
Herald added a subscriber: cfe-commits.

It is not useful to keep the statement around and can lead to compiler
warnings when -Wall (-Wunused-variable specifically) turned on.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D102175

Files:
  clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp
  clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.h
  
clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp
@@ -38,60 +38,88 @@
   const auto AutoAssigned = ExpensiveTypeReference();
   // CHECK-MESSAGES: [[@LINE-1]]:14: warning: the const qualified variable 'AutoAssigned' is copy-constructed from a const reference; consider making it a const reference [performance-unnecessary-copy-initialization]
   // CHECK-FIXES: const auto& AutoAssigned = ExpensiveTypeReference();
+  AutoAssigned.constMethod();
+
   const auto AutoCopyConstructed(ExpensiveTypeReference());
   // CHECK-MESSAGES: [[@LINE-1]]:14: warning: the const qualified variable 'AutoCopyConstructed'
   // CHECK-FIXES: const auto& AutoCopyConstructed(ExpensiveTypeReference());
+  AutoCopyConstructed.constMethod();
+
   const ExpensiveToCopyType VarAssigned = ExpensiveTypeReference();
   // CHECK-MESSAGES: [[@LINE-1]]:29: warning: the const qualified variable 'VarAssigned'
   // CHECK-FIXES:   const ExpensiveToCopyType& VarAssigned = ExpensiveTypeReference();
+  VarAssigned.constMethod();
+
   const ExpensiveToCopyType VarCopyConstructed(ExpensiveTypeReference());
   // CHECK-MESSAGES: [[@LINE-1]]:29: warning: the const qualified variable 'VarCopyConstructed'
   // CHECK-FIXES: const ExpensiveToCopyType& VarCopyConstructed(ExpensiveTypeReference());
+  VarCopyConstructed.constMethod();
 }
 
 void PositiveMethodCallConstReferenceParam(const ExpensiveToCopyType &Obj) {
   const auto AutoAssigned = Obj.reference();
   // CHECK-MESSAGES: [[@LINE-1]]:14: warning: the const qualified variable 'AutoAssigned'
   // CHECK-FIXES: const auto& AutoAssigned = Obj.reference();
+  AutoAssigned.constMethod();
+
   const auto AutoCopyConstructed(Obj.reference());
   // CHECK-MESSAGES: [[@LINE-1]]:14: warning: the const qualified variable 'AutoCopyConstructed'
   // CHECK-FIXES: const auto& AutoCopyConstructed(Obj.reference());
+  AutoCopyConstructed.constMethod();
+
   const ExpensiveToCopyType VarAssigned = Obj.reference();
   // CHECK-MESSAGES: [[@LINE-1]]:29: warning: the const qualified variable 'VarAssigned'
   // CHECK-FIXES: const ExpensiveToCopyType& VarAssigned = Obj.reference();
+  VarAssigned.constMethod();
+
   const ExpensiveToCopyType VarCopyConstructed(Obj.reference());
   // CHECK-MESSAGES: [[@LINE-1]]:29: warning: the const qualified variable 'VarCopyConstructed'
   // CHECK-FIXES: const ExpensiveToCopyType& VarCopyConstructed(Obj.reference());
+  VarCopyConstructed.constMethod();
 }
 
 void PositiveMethodCallConstParam(const ExpensiveToCopyType Obj) {
   const auto AutoAssigned = Obj.reference();
   // CHECK-MESSAGES: [[@LINE-1]]:14: warning: the const qualified variable 'AutoAssigned'
   // CHECK-FIXES: const auto& AutoAssigned = Obj.reference();
+  AutoAssigned.constMethod();
+
   const auto AutoCopyConstructed(Obj.reference());
   // CHECK-MESSAGES: [[@LINE-1]]:14: warning: the const qualified variable 'AutoCopyConstructed'
   // CHECK-FIXES: const auto& AutoCopyConstructed(Obj.reference());
+  AutoCopyConstructed.constMethod();
+
   const ExpensiveToCopyType VarAssigned = Obj.reference();
   // CHECK-MESSAGES: [[@LINE-1]]:29: warning: the const qualified variable 'VarAssigned'
   // CHECK-FIXES: const ExpensiveToCopyType& VarAssigned = Obj.reference();
+  VarAssigned.constMethod();
+
   const ExpensiveToCopyType VarCopyConstructed(Obj.reference());
   // CHECK-MESSAGES: [[@LINE-1]]:29: warning: the const qualified variable 'VarCopyConstructed'
   // CHECK-FIXES: const ExpensiveToCopyType& VarCopyConstructed(Obj.reference());
+  VarCopyConstructed.constMethod();
 }
 
 void PositiveMethodCallConstPointerParam(const ExpensiveToCopyType *const Obj) {
   const auto AutoAssigned = Obj->reference();
   // CHECK-MESSAGES: [[@LINE-1]]:14: warning: the const qualified variable 'AutoAssigned'
   // CHECK-FIXES: const auto& AutoAssigned = Obj->reference();
+  AutoAssigned.constMethod();
+
   const auto AutoCopyConstructed(Obj->reference());
   // CHECK-MESSAGES: [[@LINE-1]]:14: warning: the const qualified variable 'AutoCop

[clang] 91a919e - [NFC] Synchronize reserved identifier code between macro and variables / symbols

2021-05-10 Thread via cfe-commits

Author: serge-sans-paille
Date: 2021-05-10T17:46:51+02:00
New Revision: 91a919e8994a2c47b3feaf906f83122776ae2cae

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

LOG: [NFC] Synchronize reserved identifier code between macro and variables / 
symbols

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

Added: 


Modified: 
clang/lib/Lex/PPDirectives.cpp

Removed: 




diff  --git a/clang/lib/Lex/PPDirectives.cpp b/clang/lib/Lex/PPDirectives.cpp
index d5cb46f75aec3..469c4e48525cc 100644
--- a/clang/lib/Lex/PPDirectives.cpp
+++ b/clang/lib/Lex/PPDirectives.cpp
@@ -100,26 +100,6 @@ enum MacroDiag {
   MD_ReservedMacro  //> #define of #undef reserved id, disabled by default
 };
 
-/// Checks if the specified identifier is reserved in the specified
-/// language.
-/// This function does not check if the identifier is a keyword.
-static bool isReservedId(StringRef Text, const LangOptions &Lang) {
-  // C++ [macro.names], C11 7.1.3:
-  // All identifiers that begin with an underscore and either an uppercase
-  // letter or another underscore are always reserved for any use.
-  if (Text.size() >= 2 && Text[0] == '_' &&
-  (isUppercase(Text[1]) || Text[1] == '_'))
-  return true;
-  // C++ [global.names]
-  // Each name that contains a double underscore ... is reserved to the
-  // implementation for any use.
-  if (Lang.CPlusPlus) {
-if (Text.find("__") != StringRef::npos)
-  return true;
-  }
-  return false;
-}
-
 // The -fmodule-name option tells the compiler to textually include headers in
 // the specified module, meaning clang won't build the specified module. This 
is
 // useful in a number of situations, for instance, when building a library that
@@ -141,9 +121,9 @@ static bool isForModuleBuilding(Module *M, StringRef 
CurrentModule,
 
 static MacroDiag shouldWarnOnMacroDef(Preprocessor &PP, IdentifierInfo *II) {
   const LangOptions &Lang = PP.getLangOpts();
-  StringRef Text = II->getName();
-  if (isReservedId(Text, Lang))
+  if (II->isReserved(Lang) != ReservedIdentifierStatus::NotReserved)
 return MD_ReservedMacro;
+  StringRef Text = II->getName();
   if (II->isKeyword(Lang))
 return MD_KeywordDef;
   if (Lang.CPlusPlus11 && (Text.equals("override") || Text.equals("final")))
@@ -153,9 +133,8 @@ static MacroDiag shouldWarnOnMacroDef(Preprocessor &PP, 
IdentifierInfo *II) {
 
 static MacroDiag shouldWarnOnMacroUndef(Preprocessor &PP, IdentifierInfo *II) {
   const LangOptions &Lang = PP.getLangOpts();
-  StringRef Text = II->getName();
   // Do not warn on keyword undef.  It is generally harmless and widely used.
-  if (isReservedId(Text, Lang))
+  if (II->isReserved(Lang) != ReservedIdentifierStatus::NotReserved)
 return MD_ReservedMacro;
   return MD_NoWarn;
 }



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


[PATCH] D102164: [NFC] Syndicate reserved identifier code between macro and variables / symbols

2021-05-10 Thread serge 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 rG91a919e8994a: [NFC] Synchronize reserved identifier code 
between macro and variables / symbols (authored by serge-sans-paille).
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102164

Files:
  clang/lib/Lex/PPDirectives.cpp


Index: clang/lib/Lex/PPDirectives.cpp
===
--- clang/lib/Lex/PPDirectives.cpp
+++ clang/lib/Lex/PPDirectives.cpp
@@ -100,26 +100,6 @@
   MD_ReservedMacro  //> #define of #undef reserved id, disabled by default
 };
 
-/// Checks if the specified identifier is reserved in the specified
-/// language.
-/// This function does not check if the identifier is a keyword.
-static bool isReservedId(StringRef Text, const LangOptions &Lang) {
-  // C++ [macro.names], C11 7.1.3:
-  // All identifiers that begin with an underscore and either an uppercase
-  // letter or another underscore are always reserved for any use.
-  if (Text.size() >= 2 && Text[0] == '_' &&
-  (isUppercase(Text[1]) || Text[1] == '_'))
-  return true;
-  // C++ [global.names]
-  // Each name that contains a double underscore ... is reserved to the
-  // implementation for any use.
-  if (Lang.CPlusPlus) {
-if (Text.find("__") != StringRef::npos)
-  return true;
-  }
-  return false;
-}
-
 // The -fmodule-name option tells the compiler to textually include headers in
 // the specified module, meaning clang won't build the specified module. This 
is
 // useful in a number of situations, for instance, when building a library that
@@ -141,9 +121,9 @@
 
 static MacroDiag shouldWarnOnMacroDef(Preprocessor &PP, IdentifierInfo *II) {
   const LangOptions &Lang = PP.getLangOpts();
-  StringRef Text = II->getName();
-  if (isReservedId(Text, Lang))
+  if (II->isReserved(Lang) != ReservedIdentifierStatus::NotReserved)
 return MD_ReservedMacro;
+  StringRef Text = II->getName();
   if (II->isKeyword(Lang))
 return MD_KeywordDef;
   if (Lang.CPlusPlus11 && (Text.equals("override") || Text.equals("final")))
@@ -153,9 +133,8 @@
 
 static MacroDiag shouldWarnOnMacroUndef(Preprocessor &PP, IdentifierInfo *II) {
   const LangOptions &Lang = PP.getLangOpts();
-  StringRef Text = II->getName();
   // Do not warn on keyword undef.  It is generally harmless and widely used.
-  if (isReservedId(Text, Lang))
+  if (II->isReserved(Lang) != ReservedIdentifierStatus::NotReserved)
 return MD_ReservedMacro;
   return MD_NoWarn;
 }


Index: clang/lib/Lex/PPDirectives.cpp
===
--- clang/lib/Lex/PPDirectives.cpp
+++ clang/lib/Lex/PPDirectives.cpp
@@ -100,26 +100,6 @@
   MD_ReservedMacro  //> #define of #undef reserved id, disabled by default
 };
 
-/// Checks if the specified identifier is reserved in the specified
-/// language.
-/// This function does not check if the identifier is a keyword.
-static bool isReservedId(StringRef Text, const LangOptions &Lang) {
-  // C++ [macro.names], C11 7.1.3:
-  // All identifiers that begin with an underscore and either an uppercase
-  // letter or another underscore are always reserved for any use.
-  if (Text.size() >= 2 && Text[0] == '_' &&
-  (isUppercase(Text[1]) || Text[1] == '_'))
-  return true;
-  // C++ [global.names]
-  // Each name that contains a double underscore ... is reserved to the
-  // implementation for any use.
-  if (Lang.CPlusPlus) {
-if (Text.find("__") != StringRef::npos)
-  return true;
-  }
-  return false;
-}
-
 // The -fmodule-name option tells the compiler to textually include headers in
 // the specified module, meaning clang won't build the specified module. This is
 // useful in a number of situations, for instance, when building a library that
@@ -141,9 +121,9 @@
 
 static MacroDiag shouldWarnOnMacroDef(Preprocessor &PP, IdentifierInfo *II) {
   const LangOptions &Lang = PP.getLangOpts();
-  StringRef Text = II->getName();
-  if (isReservedId(Text, Lang))
+  if (II->isReserved(Lang) != ReservedIdentifierStatus::NotReserved)
 return MD_ReservedMacro;
+  StringRef Text = II->getName();
   if (II->isKeyword(Lang))
 return MD_KeywordDef;
   if (Lang.CPlusPlus11 && (Text.equals("override") || Text.equals("final")))
@@ -153,9 +133,8 @@
 
 static MacroDiag shouldWarnOnMacroUndef(Preprocessor &PP, IdentifierInfo *II) {
   const LangOptions &Lang = PP.getLangOpts();
-  StringRef Text = II->getName();
   // Do not warn on keyword undef.  It is generally harmless and widely used.
-  if (isReservedId(Text, Lang))
+  if (II->isReserved(Lang) != ReservedIdentifierStatus::NotReserved)
 return MD_ReservedMacro;
   return MD_NoWarn;
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi

[PATCH] D102094: [AIX][PowerPC] Remove error when specifying mabi=vec-default on AIX

2021-05-10 Thread Zarko Todorovski via Phabricator via cfe-commits
ZarkoCA updated this revision to Diff 344078.
ZarkoCA edited the summary of this revision.
ZarkoCA added a comment.

- Simplify option logic


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102094

Files:
  clang/lib/Frontend/CompilerInvocation.cpp


Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -1851,12 +1851,7 @@
   << A->getSpelling() << T.str();
 
 const Option &O = A->getOption();
-if (O.matches(OPT_mabi_EQ_vec_extabi))
-  Opts.EnableAIXExtendedAltivecABI = 1;
-else if (O.matches(OPT_mabi_EQ_vec_default))
-  Opts.EnableAIXExtendedAltivecABI = 0;
-else
-  Opts.EnableAIXExtendedAltivecABI = 0;
+Opts.EnableAIXExtendedAltivecABI = O.matches(OPT_mabi_EQ_vec_extabi);
   }
 
   bool NeedLocTracking = false;


Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -1851,12 +1851,7 @@
   << A->getSpelling() << T.str();
 
 const Option &O = A->getOption();
-if (O.matches(OPT_mabi_EQ_vec_extabi))
-  Opts.EnableAIXExtendedAltivecABI = 1;
-else if (O.matches(OPT_mabi_EQ_vec_default))
-  Opts.EnableAIXExtendedAltivecABI = 0;
-else
-  Opts.EnableAIXExtendedAltivecABI = 0;
+Opts.EnableAIXExtendedAltivecABI = O.matches(OPT_mabi_EQ_vec_extabi);
   }
 
   bool NeedLocTracking = false;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D102094: [AIX][PowerPC] Remove error when specifying mabi=vec-default on AIX

2021-05-10 Thread Zarko Todorovski via Phabricator via cfe-commits
ZarkoCA updated this revision to Diff 344080.
ZarkoCA added a comment.

- Fix previous diff


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

https://reviews.llvm.org/D102094

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/altivec.c
  clang/test/Driver/aix-vec-extabi.c
  clang/test/Preprocessor/aix-vec_extabi.c

Index: clang/test/Preprocessor/aix-vec_extabi.c
===
--- clang/test/Preprocessor/aix-vec_extabi.c
+++ clang/test/Preprocessor/aix-vec_extabi.c
@@ -2,11 +2,11 @@
 // RUN:   | FileCheck %s -check-prefix=EXTABI
 // RUN: %clang  -target powerpc64-ibm-aix-xcoff -mcpu=pwr8 -E -dM -maltivec -mabi=vec-extabi %s -o - 2>&1 \
 // RUN:   | FileCheck %s -check-prefix=EXTABI
-// RUN: not %clang  -target powerpc-ibm-aix-xcoff -mcpu=pwr8 -E -dM -maltivec -mabi=vec-default %s 2>&1 \
+// RUN: %clang  -target powerpc-ibm-aix-xcoff -mcpu=pwr8 -E -dM -maltivec -mabi=vec-default %s 2>&1 \
 // RUN:   | FileCheck %s -check-prefix=DFLTABI
-// RUN: not %clang -target powerpc64-ibm-aix-xcoff -mcpu=pwr8 -E -dM -maltivec -mabi=vec-default %s 2>&1 \
+// RUN: %clang -target powerpc64-ibm-aix-xcoff -mcpu=pwr8 -E -dM -maltivec -mabi=vec-default %s 2>&1 \
 // RUN:   | FileCheck %s -check-prefix=DFLTABI
 
 
-// EXTABI:  #define __EXTABI__
-// DFLTABI: The default Altivec ABI on AIX is not yet supported, use '-mabi=vec-extabi' for the extended Altivec ABI
+// EXTABI:  #define __EXTABI__
+// DFLTABI-NOT: #define __EXTABI__
Index: clang/test/Driver/aix-vec-extabi.c
===
--- clang/test/Driver/aix-vec-extabi.c
+++ clang/test/Driver/aix-vec-extabi.c
@@ -1,10 +1,11 @@
 // RUN:  %clang -### -target powerpc-unknown-aix -S -maltivec -mabi=vec-extabi %s 2>&1 | \
-// RUN:  FileCheck %s
-
-// CHECK: "-cc1"
-// CHECK-SAME: "-mabi=vec-extabi"
-
+// RUN:  FileCheck %s --check-prefix=EXTABI
 // RUN:  %clang -### -target powerpc-unknown-aix -S -maltivec -mabi=vec-default %s 2>&1 | \
-// RUN:  FileCheck %s --check-prefix=ERROR
+// RUN:  FileCheck %s --check-prefix=DFLTABI
+
+// EXTABI:   "-cc1"
+// EXTABI-SAME:  "-mabi=vec-extabi"
 
-// ERROR: The default Altivec ABI on AIX is not yet supported, use '-mabi=vec-extabi' for the extended Altivec ABI
+// DFLTABI:  "-cc1"
+// DFLTABI-SAME: "-mabi=vec-default"
+// DFLTABI-NOT:  "-mabi=vec-default"
Index: clang/test/CodeGen/altivec.c
===
--- clang/test/CodeGen/altivec.c
+++ clang/test/CodeGen/altivec.c
@@ -4,12 +4,12 @@
 // RUN: %clang_cc1 -target-feature +altivec -triple powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck %s --check-prefixes=CHECK,CHECK-LE
 // RUN: %clang_cc1 -target-feature +altivec -mabi=vec-extabi -target-cpu pwr8 -triple powerpc-unknown-aix -emit-llvm %s -o - | FileCheck %s --check-prefixes=CHECK,CHECK-BE
 // RUN: %clang_cc1 -target-feature +altivec -mabi=vec-extabi -target-cpu pwr8 -triple powerpc64-unknown-aix -emit-llvm %s -o - | FileCheck %s --check-prefixes=CHECK,CHECK-BE
-// RUN: not %clang_cc1 -target-feature +altivec -mabi=vec-default -target-cpu pwr8 -triple powerpc-unknown-aix -emit-llvm %s 2>&1 | FileCheck %s --check-prefix=AIX-ERROR
-// RUN: not %clang_cc1 -target-feature +altivec -mabi=vec-default -target-cpu pwr8 -triple powerpc64-unknown-aix -emit-llvm %s 2>&1 | FileCheck %s --check-prefix=AIX-ERROR
-// RUN: %clang -S -emit-llvm -maltivec -mabi=vec-extabi -mcpu=pwr8 -target powerpc-unknown-aix %s -o - | FileCheck %s --check-prefixes=CHECK,CHECK-BE
-// RUN: %clang -S -emit-llvm -maltivec -mabi=vec-extabi -mcpu=pwr8 -target powerpc64-unknown-aix %s -o - | FileCheck %s --check-prefixes=CHECK,CHECK-BE
-// RUN: not %clang -S -emit-llvm -maltivec -mabi=vec-default -mcpu=pwr8 -triple powerpc-unknown-aix -emit-llvm %s 2>&1 | FileCheck %s --check-prefix=AIX-ERROR
-// RUN: not %clang -S -emit-llvm -maltivec -mabi=vec-default -mcpu=pwr8 -triple powerpc64-unknown-aix -emit-llvm %s 2>&1 | FileCheck %s --check-prefix=AIX-ERROR
+// RUN: %clang_cc1 -target-feature +altivec -mabi=vec-default -target-cpu pwr8 -triple powerpc-unknown-aix -emit-llvm %s -o - | FileCheck %s --check-prefixes=CHECK,CHECK-BE
+// RUN: %clang_cc1 -target-feature +altivec -mabi=vec-default -target-cpu pwr8 -triple powerpc64-unknown-aix -emit-llvm %s -o - | FileCheck %s --check-prefixes=CHECK,CHECK-BE
+// RUN: %clang -S -emit-llvm -maltivec -mabi=vec-extabi -mcpu=pwr8 --target=powerpc-unknown-aix %s -o - | FileCheck %s --check-prefixes=CHECK,CHECK-BE
+// RUN: %clang -S -emit-llvm -maltivec -mabi=vec-extabi -mcpu=pwr8 --target=powerpc64-unknown-aix %s -o - | FileCheck %s --check-prefixes=CHECK,CHECK-BE
+// RUN: %clang -S -emit-llvm -maltivec -mabi=vec-default -mcpu=pwr8 --target=powerpc-unknown-aix -emit-llvm %s -o - | FileCheck %s --check-prefixes=CHECK,CHECK-BE
+// RUN: %clang

[PATCH] D102094: [AIX][PowerPC] Remove error when specifying mabi=vec-default on AIX

2021-05-10 Thread Zarko Todorovski via Phabricator via cfe-commits
ZarkoCA marked an inline comment as done.
ZarkoCA added inline comments.



Comment at: clang/lib/Frontend/CompilerInvocation.cpp:1854
 const Option &O = A->getOption();
-if (O.matches(OPT_mabi_EQ_vec_default))
-  Diags.Report(diag::err_aix_default_altivec_abi)
-  << A->getSpelling() << T.str();
-else {
-  assert(O.matches(OPT_mabi_EQ_vec_extabi));
+if (O.matches(OPT_mabi_EQ_vec_extabi))
   Opts.EnableAIXExtendedAltivecABI = 1;

jansvoboda11 wrote:
> Can we simplify this to `Opts.EnableAIXExtendedAltivecABI = 
> O.matches(OPT_mabi_EQ_vec_extabi);`?
Thanks, that works well. 


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

https://reviews.llvm.org/D102094

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


[PATCH] D100509: Support GCC's -fstack-usage flag

2021-05-10 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: clang/include/clang/Basic/CodeGenOptions.def:110
 CODEGENOPT(StackSizeSection  , 1, 0) ///< Set when -fstack-size-section is 
enabled.
+CODEGENOPT(StackUsage, 1, 0) ///< Set when -fstack-usage is enabled.
 CODEGENOPT(ForceDwarfFrameSection , 1, 0) ///< Set when -fforce-dwarf-frame is

Unneeded



Comment at: clang/test/CodeGen/stack-usage.c:7
+
+// CHECK: stack-usage.c:8:foo  {{[0-9]+}}  static
+int foo() {

`8` -> `[[#@LINE+1]]`



Comment at: llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp:1212
+
+  *StackUsageStream << ":" << MF.getName() << "\t" << StackSize << "\t";
+  if (FrameInfo.hasVarSizedObjects())

`""` -> `''`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100509

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


[PATCH] D101479: [Driver] Support libc++ in MSVC

2021-05-10 Thread Adrian McCarthy via Phabricator via cfe-commits
amccarth added a comment.

In D101479#2733354 , @mstorsjo wrote:

> Not sure if we want the desicion between static and shared libc++ be coupled 
> with `/MT` and `/MD`, as one can quite plausibly want to use e.g. a static 
> libc++ with `/MD`.

I don't understand this.  When would someone want to use `/MD` and not get the 
DLL version of the run-time libraries?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101479

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


[clang] 68a20c7 - [clang] Support -fpic -fno-semantic-interposition for AArch64

2021-05-10 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2021-05-10T09:43:33-07:00
New Revision: 68a20c7f36d1d51cc46c0bd17384c16bc7818fa2

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

LOG: [clang] Support -fpic -fno-semantic-interposition for AArch64

-fno-semantic-interposition (only effective with -fpic) can optimize default
visibility external linkage (non-ifunc-non-COMDAT) variable access and function
calls to avoid GOT/PLT, by using local aliases, e.g.
```
int var;
__attribute__((optnone)) int fun(int x) { return x * x; }
int test() { return fun(var); }
```

-fpic (var and fun are dso_preemptable)
```
test:   // @test
adrpx8, :got:var
ldr x8, [x8, :got_lo12:var]
ldr w0, [x8]
// fun is preemptible by default in ld -shared mode. ld will create a PLT.
b   fun
```

vs -fpic -fno-semantic-interposition (var and fun are dso_local)
```
test:   // @test
.Ltest$local:
adrpx8, .Lvar$local
ldr w0, [x8, :lo12:.Lvar$local]
// The assembler either resolves .Lfun$local at assembly time, or produces a
// relocation referencing a non-preemptible section symbol (which can avoid 
PLT).
b   .Lfun$local
```

Note: Clang's default -fpic is more aggressive than GCC -fpic: interprocedural
optimizations (including inlining) are available but local aliases are not used.
-fpic -fsemantic-interposition can disable interprocedural optimizations.

Depends on D101872

Reviewed By: peter.smith

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/Driver/fsemantic-interposition.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 97a92e69419fa..c4ea67ea93660 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -4722,7 +4722,7 @@ void Clang::ConstructJob(Compilation &C, const JobAction 
&JA,
  options::OPT_fno_semantic_interposition);
 if (RelocationModel != llvm::Reloc::Static && !IsPIE) {
   // The supported targets need to call AsmPrinter::getSymbolPreferLocal.
-  bool SupportsLocalAlias = Triple.isX86();
+  bool SupportsLocalAlias = Triple.isAArch64() || Triple.isX86();
   if (!A)
 CmdArgs.push_back("-fhalf-no-semantic-interposition");
   else if (A->getOption().matches(options::OPT_fsemantic_interposition))

diff  --git a/clang/test/Driver/fsemantic-interposition.c 
b/clang/test/Driver/fsemantic-interposition.c
index af76daf7e1be4..3060e8a49b20a 100644
--- a/clang/test/Driver/fsemantic-interposition.c
+++ b/clang/test/Driver/fsemantic-interposition.c
@@ -10,6 +10,7 @@
 
 /// If -fno-semantic-interposition is specified and the target supports local
 /// aliases, neither CC1 option is set.
+// RUN: %clang -target aarch64 %s -Werror -fPIC -fno-semantic-interposition -c 
-### 2>&1 | FileCheck --check-prefix=NO %s
 // RUN: %clang -target i386 %s -Werror -fPIC -fno-semantic-interposition -c 
-### 2>&1 | FileCheck --check-prefix=NO %s
 // RUN: %clang -target x86_64 %s -Werror -fPIC -fno-semantic-interposition -c 
-### 2>&1 | FileCheck --check-prefix=NO %s
 // NO-NOT: "-fsemantic-interposition"
@@ -20,8 +21,8 @@
 /// local aliases, use the traditional half-baked behavor: interprocedural
 /// optimizations are allowed but local aliases are not used. If references are
 /// not optimized out, semantic interposition at runtime is possible.
-// RUN: %clang -target aarch64 %s -Werror -fPIC -fno-semantic-interposition -c 
-### 2>&1 | FileCheck --check-prefix=HALF %s
 // RUN: %clang -target ppc64le %s -Werror -fPIC -fno-semantic-interposition -c 
-### 2>&1 | FileCheck --check-prefix=HALF %s
+// RUN: %clang -target riscv64 %s -Werror -fPIC -fno-semantic-interposition -c 
-### 2>&1 | FileCheck --check-prefix=HALF %s
 
 // RUN: %clang -target x86_64 %s -Werror -fPIC -c -### 2>&1 | FileCheck 
--check-prefix=HALF %s
 //



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


[PATCH] D101873: [clang] Support clang -fpic -fno-semantic-interposition for AArch64

2021-05-10 Thread Fangrui Song via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG68a20c7f36d1: [clang] Support -fpic 
-fno-semantic-interposition for AArch64 (authored by MaskRay).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101873

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/fsemantic-interposition.c


Index: clang/test/Driver/fsemantic-interposition.c
===
--- clang/test/Driver/fsemantic-interposition.c
+++ clang/test/Driver/fsemantic-interposition.c
@@ -10,6 +10,7 @@
 
 /// If -fno-semantic-interposition is specified and the target supports local
 /// aliases, neither CC1 option is set.
+// RUN: %clang -target aarch64 %s -Werror -fPIC -fno-semantic-interposition -c 
-### 2>&1 | FileCheck --check-prefix=NO %s
 // RUN: %clang -target i386 %s -Werror -fPIC -fno-semantic-interposition -c 
-### 2>&1 | FileCheck --check-prefix=NO %s
 // RUN: %clang -target x86_64 %s -Werror -fPIC -fno-semantic-interposition -c 
-### 2>&1 | FileCheck --check-prefix=NO %s
 // NO-NOT: "-fsemantic-interposition"
@@ -20,8 +21,8 @@
 /// local aliases, use the traditional half-baked behavor: interprocedural
 /// optimizations are allowed but local aliases are not used. If references are
 /// not optimized out, semantic interposition at runtime is possible.
-// RUN: %clang -target aarch64 %s -Werror -fPIC -fno-semantic-interposition -c 
-### 2>&1 | FileCheck --check-prefix=HALF %s
 // RUN: %clang -target ppc64le %s -Werror -fPIC -fno-semantic-interposition -c 
-### 2>&1 | FileCheck --check-prefix=HALF %s
+// RUN: %clang -target riscv64 %s -Werror -fPIC -fno-semantic-interposition -c 
-### 2>&1 | FileCheck --check-prefix=HALF %s
 
 // RUN: %clang -target x86_64 %s -Werror -fPIC -c -### 2>&1 | FileCheck 
--check-prefix=HALF %s
 //
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -4722,7 +4722,7 @@
  options::OPT_fno_semantic_interposition);
 if (RelocationModel != llvm::Reloc::Static && !IsPIE) {
   // The supported targets need to call AsmPrinter::getSymbolPreferLocal.
-  bool SupportsLocalAlias = Triple.isX86();
+  bool SupportsLocalAlias = Triple.isAArch64() || Triple.isX86();
   if (!A)
 CmdArgs.push_back("-fhalf-no-semantic-interposition");
   else if (A->getOption().matches(options::OPT_fsemantic_interposition))


Index: clang/test/Driver/fsemantic-interposition.c
===
--- clang/test/Driver/fsemantic-interposition.c
+++ clang/test/Driver/fsemantic-interposition.c
@@ -10,6 +10,7 @@
 
 /// If -fno-semantic-interposition is specified and the target supports local
 /// aliases, neither CC1 option is set.
+// RUN: %clang -target aarch64 %s -Werror -fPIC -fno-semantic-interposition -c -### 2>&1 | FileCheck --check-prefix=NO %s
 // RUN: %clang -target i386 %s -Werror -fPIC -fno-semantic-interposition -c -### 2>&1 | FileCheck --check-prefix=NO %s
 // RUN: %clang -target x86_64 %s -Werror -fPIC -fno-semantic-interposition -c -### 2>&1 | FileCheck --check-prefix=NO %s
 // NO-NOT: "-fsemantic-interposition"
@@ -20,8 +21,8 @@
 /// local aliases, use the traditional half-baked behavor: interprocedural
 /// optimizations are allowed but local aliases are not used. If references are
 /// not optimized out, semantic interposition at runtime is possible.
-// RUN: %clang -target aarch64 %s -Werror -fPIC -fno-semantic-interposition -c -### 2>&1 | FileCheck --check-prefix=HALF %s
 // RUN: %clang -target ppc64le %s -Werror -fPIC -fno-semantic-interposition -c -### 2>&1 | FileCheck --check-prefix=HALF %s
+// RUN: %clang -target riscv64 %s -Werror -fPIC -fno-semantic-interposition -c -### 2>&1 | FileCheck --check-prefix=HALF %s
 
 // RUN: %clang -target x86_64 %s -Werror -fPIC -c -### 2>&1 | FileCheck --check-prefix=HALF %s
 //
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -4722,7 +4722,7 @@
  options::OPT_fno_semantic_interposition);
 if (RelocationModel != llvm::Reloc::Static && !IsPIE) {
   // The supported targets need to call AsmPrinter::getSymbolPreferLocal.
-  bool SupportsLocalAlias = Triple.isX86();
+  bool SupportsLocalAlias = Triple.isAArch64() || Triple.isX86();
   if (!A)
 CmdArgs.push_back("-fhalf-no-semantic-interposition");
   else if (A->getOption().matches(options::OPT_fsemantic_interposition))
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D102122: Support warn_unused_result on typedefs

2021-05-10 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

Let me start off by saying: thanks, I think this is really useful 
functionality. As a ridiculously obvious example, Annex K has an integer type 
alias `errno_t` and it would incredibly handy to be able to mark that as 
`[[nodiscard]]` to strongly encourage checking for errors for functions that 
return that type (not that we support Annex K, but the general idea extends to 
any integer-based error type).

That said, there are multiple different ways to spell the same semantic 
attribute, and it's not clear to me that we want to change them all the same 
way.

`[[clang::warn_unused_result]]` is ours to do with as we please, so there's no 
issue changing that behavior.

`__attribute__((warn_unused_result))` and `[[gnu::warn_unused_result]]` are 
governed by GCC and we try to be compatible with their behavior. GCC does not 
appear to support the attribute on typedefs from my testing, so we'd want to 
coordinate with the GCC folks to see if there's an appetite for the change.

`[[nodiscard]]` is governed by both the C++ and C standards and we should not 
be changing its behavior without some extra diagnostics about extensions (and, 
preferably, some sort of attempt to standardize the behavior with WG14/WG21).

Do you have an appetite to talk to the GCC and standards folks? If not, then I 
think the safest bet is to only change the behavior for the 
`[[clang::warn_unused_result]]` and to leave the other forms alone for now.

In D102122#2746426 , @dblaikie wrote:

> Fixes for a few other test cases (though I wonder if these tests are 
> overconstrained - do we need to be testing the list of things this attribute 
> can be applied to in so many places?)

If the semantics of the attribute are identical regardless of how it's spelled, 
then we probably don't need the tests all spread out in multiple files. 
However, I don't think there's an intention to keep all of the spellings with 
identical semantics, so the different tests might still make sense (but could 
perhaps be cleaned up).

In D102122#2746424 , @dblaikie wrote:

> Oh, one question: If we do move forward with this patch, how would we detect 
> that the compiler supports this new use of warn_unused_result? (so that the 
> feature detection macros in LLVM properly make the attribute a no-op unless 
> we have a version of clang that supports it)

`__has_[c|cpp]_attribute` returns a value, so we'd likely wind up using that 
return value to distinguish between versions.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102122

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


[PATCH] D100798: [clangd][ObjC] Fix issue completing a method decl by name

2021-05-10 Thread David Goldman via Phabricator via cfe-commits
dgoldman added a comment.

Friendly ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100798

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


[PATCH] D102122: Support warn_unused_result on typedefs

2021-05-10 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

In D102122#2748206 , @aaron.ballman 
wrote:

> Let me start off by saying: thanks, I think this is really useful 
> functionality. As a ridiculously obvious example, Annex K has an integer type 
> alias `errno_t` and it would incredibly handy to be able to mark that as 
> `[[nodiscard]]` to strongly encourage checking for errors for functions that 
> return that type (not that we support Annex K, but the general idea extends 
> to any integer-based error type).
>
> That said, there are multiple different ways to spell the same semantic 
> attribute, and it's not clear to me that we want to change them all the same 
> way.
>
> `[[clang::warn_unused_result]]` is ours to do with as we please, so there's 
> no issue changing that behavior.
>
> `__attribute__((warn_unused_result))` and `[[gnu::warn_unused_result]]` are 
> governed by GCC and we try to be compatible with their behavior. GCC does not 
> appear to support the attribute on typedefs from my testing, so we'd want to 
> coordinate with the GCC folks to see if there's an appetite for the change.

FWIW, looks like we already diverge from GCC's behavior - GCC doesn't seem to 
support this attribute on types at all: https://godbolt.org/z/8YjqnE4cv (but 
does support [[nodiscard]] in that place)

> `[[nodiscard]]` is governed by both the C++ and C standards and we should not 
> be changing its behavior without some extra diagnostics about extensions 
> (and, preferably, some sort of attempt to standardize the behavior with 
> WG14/WG21).

Might be a compatible extension, though - to use a standard attribute in a 
non-standard context? (at least clang and gcc only warn on putting 
[[nodiscard]] in non-standard places, they don't error)

> Do you have an appetite to talk to the GCC and standards folks?

Medium interest.

> If not, then I think the safest bet is to only change the behavior for the 
> `[[clang::warn_unused_result]]` and to leave the other forms alone for now.

Happy to go either way.

Is there an easy/recommended way to split these things up? Duplicate the 
records in the td/come up with separate names, etc?)

> In D102122#2746426 , @dblaikie 
> wrote:
>
>> Fixes for a few other test cases (though I wonder if these tests are 
>> overconstrained - do we need to be testing the list of things this attribute 
>> can be applied to in so many places?)
>
> If the semantics of the attribute are identical regardless of how it's 
> spelled, then we probably don't need the tests all spread out in multiple 
> files. However, I don't think there's an intention to keep all of the 
> spellings with identical semantics, so the different tests might still make 
> sense (but could perhaps be cleaned up).
>
> In D102122#2746424 , @dblaikie 
> wrote:
>
>> Oh, one question: If we do move forward with this patch, how would we detect 
>> that the compiler supports this new use of warn_unused_result? (so that the 
>> feature detection macros in LLVM properly make the attribute a no-op unless 
>> we have a version of clang that supports it)
>
> `__has_[c|cpp]_attribute` returns a value, so we'd likely wind up using that 
> return value to distinguish between versions.

Hmm - what if we end up with different behavior for the different spellings of 
the attribute (as GCC does)? Can we check them separately?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102122

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


[PATCH] D102180: [Clang][OpenMP] Emit dependent PreInits before directive.

2021-05-10 Thread Michael Kruse via Phabricator via cfe-commits
Meinersbur created this revision.
Meinersbur added a reviewer: ABataev.
Meinersbur added projects: OpenMP, clang.
Herald added subscribers: guansong, yaxunl.
Meinersbur requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added a subscriber: sstefan1.

The PreInits of a loop transformation (atm moment only tile) include the 
computation of the trip count. The trip count is needed by any loop-associated 
directives that consumes the transformation-generated loop. Hence, we must 
ensure that the PreInits of consumed loop transformations are emitted with the 
consuming directive.

This is done by addinging the inner loop transformation's PreInits to the outer 
loop-directive's PreInits. The outer loop-directive will consume the de-sugared 
AST such that the inner PreInits are not emitted twice. The PreInits of a loop 
transformation are still emitted directly if its generated loop(s) are not 
associated with another loop-associated directive.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D102180

Files:
  clang/include/clang/AST/StmtOpenMP.h
  clang/lib/AST/StmtOpenMP.cpp
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/tile_codegen.cpp
  clang/test/OpenMP/tile_codegen_for_dependent.cpp
  clang/test/OpenMP/tile_codegen_for_multiple.cpp

Index: clang/test/OpenMP/tile_codegen_for_multiple.cpp
===
--- /dev/null
+++ clang/test/OpenMP/tile_codegen_for_multiple.cpp
@@ -0,0 +1,248 @@
+// Check code generation
+// RUN: %clang_cc1 -verify -triple x86_64-pc-linux-gnu -fopenmp -fopenmp-version=51 -emit-llvm %s -o - | FileCheck %s --check-prefix=IR
+
+// Check same results after serialization round-trip
+// RUN: %clang_cc1 -verify -triple x86_64-pc-linux-gnu -fopenmp -fopenmp-version=51 -emit-pch -o %t %s
+// RUN: %clang_cc1 -verify -triple x86_64-pc-linux-gnu -fopenmp -fopenmp-version=51 -include-pch %t -emit-llvm %s -o - | FileCheck %s --check-prefix=IR
+// expected-no-diagnostics
+
+// Account for multiple transformations of a loop before consumed by
+// #pragma omp for.
+
+#ifndef HEADER
+#define HEADER
+
+// placeholder for loop body code.
+extern "C" void body(...) {}
+
+
+// IR-LABEL: @func(
+// IR-NEXT:  [[ENTRY:.*]]:
+// IR-NEXT:%[[START_ADDR:.+]] = alloca i32, align 4
+// IR-NEXT:%[[END_ADDR:.+]] = alloca i32, align 4
+// IR-NEXT:%[[STEP_ADDR:.+]] = alloca i32, align 4
+// IR-NEXT:%[[DOTOMP_IV:.+]] = alloca i32, align 4
+// IR-NEXT:%[[TMP:.+]] = alloca i32, align 4
+// IR-NEXT:%[[DOTCAPTURE_EXPR_:.+]] = alloca i32, align 4
+// IR-NEXT:%[[DOTCAPTURE_EXPR_1:.+]] = alloca i32, align 4
+// IR-NEXT:%[[DOTCAPTURE_EXPR_2:.+]] = alloca i32, align 4
+// IR-NEXT:%[[DOTCAPTURE_EXPR_3:.+]] = alloca i32, align 4
+// IR-NEXT:%[[I:.+]] = alloca i32, align 4
+// IR-NEXT:%[[DOTCAPTURE_EXPR_6:.+]] = alloca i32, align 4
+// IR-NEXT:%[[DOTCAPTURE_EXPR_8:.+]] = alloca i32, align 4
+// IR-NEXT:%[[DOTFLOOR_0_IV_I:.+]] = alloca i32, align 4
+// IR-NEXT:%[[DOTCAPTURE_EXPR_12:.+]] = alloca i32, align 4
+// IR-NEXT:%[[DOTCAPTURE_EXPR_14:.+]] = alloca i32, align 4
+// IR-NEXT:%[[DOTFLOOR_0_IV__FLOOR_0_IV_I:.+]] = alloca i32, align 4
+// IR-NEXT:%[[DOTOMP_LB:.+]] = alloca i32, align 4
+// IR-NEXT:%[[DOTOMP_UB:.+]] = alloca i32, align 4
+// IR-NEXT:%[[DOTOMP_STRIDE:.+]] = alloca i32, align 4
+// IR-NEXT:%[[DOTOMP_IS_LAST:.+]] = alloca i32, align 4
+// IR-NEXT:%[[DOTFLOOR_0_IV__FLOOR_0_IV_I18:.+]] = alloca i32, align 4
+// IR-NEXT:%[[DOTTILE_0_IV__FLOOR_0_IV_I:.+]] = alloca i32, align 4
+// IR-NEXT:%[[DOTTILE_0_IV_I:.+]] = alloca i32, align 4
+// IR-NEXT:%[[TMP0:.+]] = call i32 @__kmpc_global_thread_num(%struct.ident_t* @2)
+// IR-NEXT:store i32 %[[START:.+]], i32* %[[START_ADDR]], align 4
+// IR-NEXT:store i32 %[[END:.+]], i32* %[[END_ADDR]], align 4
+// IR-NEXT:store i32 %[[STEP:.+]], i32* %[[STEP_ADDR]], align 4
+// IR-NEXT:%[[TMP1:.+]] = load i32, i32* %[[START_ADDR]], align 4
+// IR-NEXT:store i32 %[[TMP1]], i32* %[[DOTCAPTURE_EXPR_]], align 4
+// IR-NEXT:%[[TMP2:.+]] = load i32, i32* %[[END_ADDR]], align 4
+// IR-NEXT:store i32 %[[TMP2]], i32* %[[DOTCAPTURE_EXPR_1]], align 4
+// IR-NEXT:%[[TMP3:.+]] = load i32, i32* %[[STEP_ADDR]], align 4
+// IR-NEXT:store i32 %[[TMP3]], i32* %[[DOTCAPTURE_EXPR_2]], align 4
+// IR-NEXT:%[[TMP4:.+]] = load i32, i32* %[[DOTCAPTURE_EXPR_1]], align 4
+// IR-NEXT:%[[TMP5:.+]] = load i32, i32* %[[DOTCAPTURE_EXPR_]], align 4
+// IR-NEXT:%[[SUB:.+]] = sub i32 %[[TMP4]], %[[TMP5]]
+// IR-NEXT:%[[SUB4:.+]] = sub i32 %[[SUB]], 1
+// IR-NEXT:%[[TMP6:.+]] = load i32, i32* %[[DOTCAPTURE_EXPR_2]], align 4
+// IR-NEXT:%[[ADD:.+]] = add i32 %[[SUB4]], %[[TMP6]]
+// IR-NEXT:%[[TMP7:.+]] = load i32, i32* %[[DOTCAPTURE_EXPR_2]], align 4
+// IR-NEXT:%[[DIV:.+]] = udiv i32 %[[ADD]], %[[TMP7]]
+// IR-NEXT:%[[SUB5

[PATCH] D102180: [Clang][OpenMP] Emit dependent PreInits before directive.

2021-05-10 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: clang/lib/AST/StmtOpenMP.cpp:128-129
+llvm::function_ref Callback,
+llvm::function_ref
+OnTransformationCallback) {
   CurStmt = CurStmt->IgnoreContainers();

Do we need `bool` return in the callback? I see that it returns `false` always.



Comment at: clang/lib/AST/StmtOpenMP.cpp:132-140
+while (true) {
+  if (auto *Dir = dyn_cast(CurStmt)) {
+if (OnTransformationCallback(Dir))
+  return false;
+CurStmt = Dir->getTransformedStmt();
+continue;
+  }

```
while (auto *Dir = dyn_cast(CurStmt)) {
  if (OnTransformationCallback(Dir))
return false;
  CurStmt = Dir->getTransformedStmt();
}
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102180

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


[PATCH] D102180: [Clang][OpenMP] Emit dependent PreInits before directive.

2021-05-10 Thread Michael Kruse via Phabricator via cfe-commits
Meinersbur added inline comments.



Comment at: clang/lib/AST/StmtOpenMP.cpp:128-129
+llvm::function_ref Callback,
+llvm::function_ref
+OnTransformationCallback) {
   CurStmt = CurStmt->IgnoreContainers();

ABataev wrote:
> Do we need `bool` return in the callback? I see that it returns `false` 
> always.
I added it to be consistent with the other callback. Going to remove it.



Comment at: clang/lib/AST/StmtOpenMP.cpp:132-140
+while (true) {
+  if (auto *Dir = dyn_cast(CurStmt)) {
+if (OnTransformationCallback(Dir))
+  return false;
+CurStmt = Dir->getTransformedStmt();
+continue;
+  }

ABataev wrote:
> ```
> while (auto *Dir = dyn_cast(CurStmt)) {
>   if (OnTransformationCallback(Dir))
> return false;
>   CurStmt = Dir->getTransformedStmt();
> }
> ```
With OMPUnrollDirective added, there are two conditions of the while loop. Of 
course, I can change the structure again with the unroll patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102180

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


[PATCH] D102180: [Clang][OpenMP] Emit dependent PreInits before directive.

2021-05-10 Thread Michael Kruse via Phabricator via cfe-commits
Meinersbur updated this revision to Diff 344119.
Meinersbur added a comment.

- Address review comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102180

Files:
  clang/include/clang/AST/StmtOpenMP.h
  clang/lib/AST/StmtOpenMP.cpp
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/tile_codegen.cpp
  clang/test/OpenMP/tile_codegen_for_dependent.cpp
  clang/test/OpenMP/tile_codegen_for_multiple.cpp

Index: clang/test/OpenMP/tile_codegen_for_multiple.cpp
===
--- /dev/null
+++ clang/test/OpenMP/tile_codegen_for_multiple.cpp
@@ -0,0 +1,248 @@
+// Check code generation
+// RUN: %clang_cc1 -verify -triple x86_64-pc-linux-gnu -fopenmp -fopenmp-version=51 -emit-llvm %s -o - | FileCheck %s --check-prefix=IR
+
+// Check same results after serialization round-trip
+// RUN: %clang_cc1 -verify -triple x86_64-pc-linux-gnu -fopenmp -fopenmp-version=51 -emit-pch -o %t %s
+// RUN: %clang_cc1 -verify -triple x86_64-pc-linux-gnu -fopenmp -fopenmp-version=51 -include-pch %t -emit-llvm %s -o - | FileCheck %s --check-prefix=IR
+// expected-no-diagnostics
+
+// Account for multiple transformations of a loop before consumed by
+// #pragma omp for.
+
+#ifndef HEADER
+#define HEADER
+
+// placeholder for loop body code.
+extern "C" void body(...) {}
+
+
+// IR-LABEL: @func(
+// IR-NEXT:  [[ENTRY:.*]]:
+// IR-NEXT:%[[START_ADDR:.+]] = alloca i32, align 4
+// IR-NEXT:%[[END_ADDR:.+]] = alloca i32, align 4
+// IR-NEXT:%[[STEP_ADDR:.+]] = alloca i32, align 4
+// IR-NEXT:%[[DOTOMP_IV:.+]] = alloca i32, align 4
+// IR-NEXT:%[[TMP:.+]] = alloca i32, align 4
+// IR-NEXT:%[[DOTCAPTURE_EXPR_:.+]] = alloca i32, align 4
+// IR-NEXT:%[[DOTCAPTURE_EXPR_1:.+]] = alloca i32, align 4
+// IR-NEXT:%[[DOTCAPTURE_EXPR_2:.+]] = alloca i32, align 4
+// IR-NEXT:%[[DOTCAPTURE_EXPR_3:.+]] = alloca i32, align 4
+// IR-NEXT:%[[I:.+]] = alloca i32, align 4
+// IR-NEXT:%[[DOTCAPTURE_EXPR_6:.+]] = alloca i32, align 4
+// IR-NEXT:%[[DOTCAPTURE_EXPR_8:.+]] = alloca i32, align 4
+// IR-NEXT:%[[DOTFLOOR_0_IV_I:.+]] = alloca i32, align 4
+// IR-NEXT:%[[DOTCAPTURE_EXPR_12:.+]] = alloca i32, align 4
+// IR-NEXT:%[[DOTCAPTURE_EXPR_14:.+]] = alloca i32, align 4
+// IR-NEXT:%[[DOTFLOOR_0_IV__FLOOR_0_IV_I:.+]] = alloca i32, align 4
+// IR-NEXT:%[[DOTOMP_LB:.+]] = alloca i32, align 4
+// IR-NEXT:%[[DOTOMP_UB:.+]] = alloca i32, align 4
+// IR-NEXT:%[[DOTOMP_STRIDE:.+]] = alloca i32, align 4
+// IR-NEXT:%[[DOTOMP_IS_LAST:.+]] = alloca i32, align 4
+// IR-NEXT:%[[DOTFLOOR_0_IV__FLOOR_0_IV_I18:.+]] = alloca i32, align 4
+// IR-NEXT:%[[DOTTILE_0_IV__FLOOR_0_IV_I:.+]] = alloca i32, align 4
+// IR-NEXT:%[[DOTTILE_0_IV_I:.+]] = alloca i32, align 4
+// IR-NEXT:%[[TMP0:.+]] = call i32 @__kmpc_global_thread_num(%struct.ident_t* @2)
+// IR-NEXT:store i32 %[[START:.+]], i32* %[[START_ADDR]], align 4
+// IR-NEXT:store i32 %[[END:.+]], i32* %[[END_ADDR]], align 4
+// IR-NEXT:store i32 %[[STEP:.+]], i32* %[[STEP_ADDR]], align 4
+// IR-NEXT:%[[TMP1:.+]] = load i32, i32* %[[START_ADDR]], align 4
+// IR-NEXT:store i32 %[[TMP1]], i32* %[[DOTCAPTURE_EXPR_]], align 4
+// IR-NEXT:%[[TMP2:.+]] = load i32, i32* %[[END_ADDR]], align 4
+// IR-NEXT:store i32 %[[TMP2]], i32* %[[DOTCAPTURE_EXPR_1]], align 4
+// IR-NEXT:%[[TMP3:.+]] = load i32, i32* %[[STEP_ADDR]], align 4
+// IR-NEXT:store i32 %[[TMP3]], i32* %[[DOTCAPTURE_EXPR_2]], align 4
+// IR-NEXT:%[[TMP4:.+]] = load i32, i32* %[[DOTCAPTURE_EXPR_1]], align 4
+// IR-NEXT:%[[TMP5:.+]] = load i32, i32* %[[DOTCAPTURE_EXPR_]], align 4
+// IR-NEXT:%[[SUB:.+]] = sub i32 %[[TMP4]], %[[TMP5]]
+// IR-NEXT:%[[SUB4:.+]] = sub i32 %[[SUB]], 1
+// IR-NEXT:%[[TMP6:.+]] = load i32, i32* %[[DOTCAPTURE_EXPR_2]], align 4
+// IR-NEXT:%[[ADD:.+]] = add i32 %[[SUB4]], %[[TMP6]]
+// IR-NEXT:%[[TMP7:.+]] = load i32, i32* %[[DOTCAPTURE_EXPR_2]], align 4
+// IR-NEXT:%[[DIV:.+]] = udiv i32 %[[ADD]], %[[TMP7]]
+// IR-NEXT:%[[SUB5:.+]] = sub i32 %[[DIV]], 1
+// IR-NEXT:store i32 %[[SUB5]], i32* %[[DOTCAPTURE_EXPR_3]], align 4
+// IR-NEXT:%[[TMP8:.+]] = load i32, i32* %[[START_ADDR]], align 4
+// IR-NEXT:store i32 %[[TMP8]], i32* %[[I]], align 4
+// IR-NEXT:%[[TMP9:.+]] = load i32, i32* %[[DOTCAPTURE_EXPR_3]], align 4
+// IR-NEXT:%[[ADD7:.+]] = add i32 %[[TMP9]], 1
+// IR-NEXT:store i32 %[[ADD7]], i32* %[[DOTCAPTURE_EXPR_6]], align 4
+// IR-NEXT:%[[TMP10:.+]] = load i32, i32* %[[DOTCAPTURE_EXPR_6]], align 4
+// IR-NEXT:%[[SUB9:.+]] = sub i32 %[[TMP10]], -3
+// IR-NEXT:%[[DIV10:.+]] = udiv i32 %[[SUB9]], 4
+// IR-NEXT:%[[SUB11:.+]] = sub i32 %[[DIV10]], 1
+// IR-NEXT:store i32 %[[SUB11]], i32* %[[DOTCAPTURE_EXPR_8]], align 4
+// IR-NEXT:store i32 0, i32* %[[DOTFLOOR_0_IV_I]], a

[PATCH] D102015: [clang CodeGen] Don't crash on large atomic function parameter.

2021-05-10 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

In D102015#2743634 , @rjmccall wrote:

> Objective-C object types also have aggregate evaluation kind.  Those can only 
> be used as value types in an old, fragile ObjC ABI, but I believe we haven't 
> yet formally decided to remove support for that.  Fortunately, however, 
> there's a much better simplification available: this 
> `hasAggregateEvaluationKind(Ty)` call is literally doing nothing that 
> couldn't just be a `getAs()` call, and then we don't need to 
> worry about it.

If you're confident that only RecordTypes need to be destroyed, sure.

Did some grepping, and there's some other places using 
isParamDestroyedInCallee(); I'll make sure they're also okay.

> ...I'm confused about why this code is doing what it's doing with cleanups, 
> though.  Why does it only apply when the parameter is indirect?  I believe 
> `isParamDestroyedInCallee()` can apply to types that are passed in other 
> ways, so where we pushing the destructor for those, and why isn't it good 
> enough to handle this case as well?

Objects with a non-trivial destructor end up indirect anyway under the normal 
ABI rules.  Not sure how it interacts with trivial_abi; I'll look into it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102015

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


[PATCH] D102030: [clang][Fuchsia] Introduce compat multilibs

2021-05-10 Thread Petr Hosek via Phabricator via cfe-commits
phosek accepted this revision.
phosek added a comment.
This revision is now accepted and ready to land.

LGTM




Comment at: clang/lib/Driver/ToolChains/Fuchsia.cpp:245
   .flag("+fno-exceptions"));
+  // Use the default Itanium C++ ABI.
+  Multilibs.push_back(Multilib("compat", {}, {}, 
12).flag("+fc++-abi=itanium"));




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102030

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


[PATCH] D102185: Widen `name` stencil to support `TypeLoc` nodes.

2021-05-10 Thread Weston Carvalho via Phabricator via cfe-commits
SilensAngelusNex created this revision.
SilensAngelusNex requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D102185

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


Index: clang/unittests/Tooling/RangeSelectorTest.cpp
===
--- clang/unittests/Tooling/RangeSelectorTest.cpp
+++ clang/unittests/Tooling/RangeSelectorTest.cpp
@@ -457,6 +457,35 @@
   EXPECT_THAT_EXPECTED(select(name(Init), Match), HasValue("field"));
 }
 
+TEST(RangeSelectorTest, NameOpTypeLoc) {
+  StringRef Code = R"cc(
+namespace ns {
+struct Foo {
+  Foo();
+  Foo(int);
+  Foo(int, int);
+};
+}  // namespace ns
+
+ns::Foo a;
+auto b = ns::Foo(3);
+auto c = ns::Foo(1, 2);
+  )cc";
+  const char *CtorTy = "ctor_ty";
+  // Matches declaration of `a`
+  TestMatch MatchA = matchCode(
+  Code, varDecl(hasName("a"), hasTypeLoc(typeLoc().bind(CtorTy;
+  EXPECT_THAT_EXPECTED(select(name(CtorTy), MatchA), HasValue("Foo"));
+  // Matches call of Foo(int)
+  TestMatch MatchB = matchCode(
+  Code, cxxFunctionalCastExpr(hasTypeLoc(typeLoc().bind(CtorTy;
+  EXPECT_THAT_EXPECTED(select(name(CtorTy), MatchB), HasValue("Foo"));
+  // Matches call of Foo(int, int)
+  TestMatch MatchC = matchCode(
+  Code, cxxTemporaryObjectExpr(hasTypeLoc(typeLoc().bind(CtorTy;
+  EXPECT_THAT_EXPECTED(select(name(CtorTy), MatchC), HasValue("Foo"));
+}
+
 TEST(RangeSelectorTest, NameOpErrors) {
   EXPECT_THAT_EXPECTED(selectFromTrivial(name("unbound_id")),
Failed(withUnboundNodeMessage()));
Index: clang/lib/Tooling/Transformer/RangeSelector.cpp
===
--- clang/lib/Tooling/Transformer/RangeSelector.cpp
+++ clang/lib/Tooling/Transformer/RangeSelector.cpp
@@ -8,6 +8,7 @@
 
 #include "clang/Tooling/Transformer/RangeSelector.h"
 #include "clang/AST/Expr.h"
+#include "clang/AST/TypeLoc.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Lex/Lexer.h"
@@ -228,6 +229,14 @@
   SourceLocation L = I->getMemberLocation();
   return CharSourceRange::getTokenRange(L, L);
 }
+if (const auto *T = Node.get()) {
+  TypeLoc Loc = *T;
+  auto ET = T->getAs();
+  if (!ET.isNull()) {
+Loc = ET.getNamedTypeLoc();
+  }
+  return CharSourceRange::getTokenRange(Loc.getSourceRange());
+}
 return typeError(ID, Node.getNodeKind(),
  "DeclRefExpr, NamedDecl, CXXCtorInitializer");
   };
Index: clang/include/clang/Tooling/Transformer/RangeSelector.h
===
--- clang/include/clang/Tooling/Transformer/RangeSelector.h
+++ clang/include/clang/Tooling/Transformer/RangeSelector.h
@@ -73,9 +73,9 @@
 /// binding in the match result.
 RangeSelector member(std::string ID);
 
-/// Given a node with a "name", (like \c NamedDecl, \c DeclRefExpr or \c
-/// CxxCtorInitializer) selects the name's token.  Only selects the final
-/// identifier of a qualified name, but not any qualifiers or template
+/// Given a node with a "name", (like \c NamedDecl, \c DeclRefExpr, \c
+/// CxxCtorInitializer, and \c TypeLoc) selects the name's token.  Only 
selects\
+/// the final identifier of a qualified name, but not any qualifiers or 
template
 /// arguments.  For example, for `::foo::bar::baz` and `::foo::bar::baz`,
 /// it selects only `baz`.
 ///


Index: clang/unittests/Tooling/RangeSelectorTest.cpp
===
--- clang/unittests/Tooling/RangeSelectorTest.cpp
+++ clang/unittests/Tooling/RangeSelectorTest.cpp
@@ -457,6 +457,35 @@
   EXPECT_THAT_EXPECTED(select(name(Init), Match), HasValue("field"));
 }
 
+TEST(RangeSelectorTest, NameOpTypeLoc) {
+  StringRef Code = R"cc(
+namespace ns {
+struct Foo {
+  Foo();
+  Foo(int);
+  Foo(int, int);
+};
+}  // namespace ns
+
+ns::Foo a;
+auto b = ns::Foo(3);
+auto c = ns::Foo(1, 2);
+  )cc";
+  const char *CtorTy = "ctor_ty";
+  // Matches declaration of `a`
+  TestMatch MatchA = matchCode(
+  Code, varDecl(hasName("a"), hasTypeLoc(typeLoc().bind(CtorTy;
+  EXPECT_THAT_EXPECTED(select(name(CtorTy), MatchA), HasValue("Foo"));
+  // Matches call of Foo(int)
+  TestMatch MatchB = matchCode(
+  Code, cxxFunctionalCastExpr(hasTypeLoc(typeLoc().bind(CtorTy;
+  EXPECT_THAT_EXPECTED(select(name(CtorTy), MatchB), HasValue("Foo"));
+  // Matches call of Foo(int, int)
+  TestMatch MatchC = matchCode(
+  Code, cxxTemporaryObjectExpr(hasTypeLoc(typeLoc().bind(CtorTy;
+  EXPECT_THAT_EXPECTED(select(name(CtorTy), MatchC), HasValue("Foo"));
+}
+
 TEST(RangeSelector

[PATCH] D101790: [clang-tidy] Aliasing: Add support for passing the variable into a function by reference.

2021-05-10 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

I completely agree with that as well, these are 100% true positives, which is 
why I left them as fixmes. The reason why I think we can't have them is that we 
don't have an appropriate alias analysis implemented. Namely, we have two 
analyses, one inside the checker that leaves out false positives like the one 
in `negative_by_val()`, the other is the universal/reusable analysis in Utils 
that i'm patching up that doesn't support happens-before relation.

I believe the right way forward is to unify these analysis by making the 
analysis in Utils account for happens-before relation. Ideally this means 
re-implementing it over the CFG which probably isn't even that hard, it's just 
a simple graph traversal problem. I may look into it in June or so.


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

https://reviews.llvm.org/D101790

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


[PATCH] D101479: [Driver] Support libc++ in MSVC

2021-05-10 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added a comment.

In D101479#2748189 , @amccarth wrote:

> In D101479#2733354 , @mstorsjo 
> wrote:
>
>> Not sure if we want the desicion between static and shared libc++ be coupled 
>> with `/MT` and `/MD`, as one can quite plausibly want to use e.g. a static 
>> libc++ with `/MD`.
>
> I don't understand this.  When would someone want to use `/MD` and not get 
> the DLL version of the run-time libraries?

Whether one wants to link against the CRT statically or dynamically, and libc++ 
statically or dynamically, are two entirely separate things. I would e.g. 
expect that Chrome is built with a statically linked libc++ but linked against 
the dynamic CRT.

In any case, as the libc++ headers supply autolinking directives that match the 
declarations (whether they're doing dllimport or not), the driver shouldn't 
really need to decide, but it's all up to the libc++ installation.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101479

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


[PATCH] D102185: Widen `name` stencil to support `TypeLoc` nodes.

2021-05-10 Thread Weston Carvalho via Phabricator via cfe-commits
SilensAngelusNex updated this revision to Diff 344132.
SilensAngelusNex added a comment.

Fix typo in `name`'s doc comment and add `TypeLoc` to the list of expected 
types in `name`'s `typeError`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102185

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


Index: clang/unittests/Tooling/RangeSelectorTest.cpp
===
--- clang/unittests/Tooling/RangeSelectorTest.cpp
+++ clang/unittests/Tooling/RangeSelectorTest.cpp
@@ -457,6 +457,35 @@
   EXPECT_THAT_EXPECTED(select(name(Init), Match), HasValue("field"));
 }
 
+TEST(RangeSelectorTest, NameOpTypeLoc) {
+  StringRef Code = R"cc(
+namespace ns {
+struct Foo {
+  Foo();
+  Foo(int);
+  Foo(int, int);
+};
+}  // namespace ns
+
+ns::Foo a;
+auto b = ns::Foo(3);
+auto c = ns::Foo(1, 2);
+  )cc";
+  const char *CtorTy = "ctor_ty";
+  // Matches declaration of `a`
+  TestMatch MatchA = matchCode(
+  Code, varDecl(hasName("a"), hasTypeLoc(typeLoc().bind(CtorTy;
+  EXPECT_THAT_EXPECTED(select(name(CtorTy), MatchA), HasValue("Foo"));
+  // Matches call of Foo(int)
+  TestMatch MatchB = matchCode(
+  Code, cxxFunctionalCastExpr(hasTypeLoc(typeLoc().bind(CtorTy;
+  EXPECT_THAT_EXPECTED(select(name(CtorTy), MatchB), HasValue("Foo"));
+  // Matches call of Foo(int, int)
+  TestMatch MatchC = matchCode(
+  Code, cxxTemporaryObjectExpr(hasTypeLoc(typeLoc().bind(CtorTy;
+  EXPECT_THAT_EXPECTED(select(name(CtorTy), MatchC), HasValue("Foo"));
+}
+
 TEST(RangeSelectorTest, NameOpErrors) {
   EXPECT_THAT_EXPECTED(selectFromTrivial(name("unbound_id")),
Failed(withUnboundNodeMessage()));
Index: clang/lib/Tooling/Transformer/RangeSelector.cpp
===
--- clang/lib/Tooling/Transformer/RangeSelector.cpp
+++ clang/lib/Tooling/Transformer/RangeSelector.cpp
@@ -8,6 +8,7 @@
 
 #include "clang/Tooling/Transformer/RangeSelector.h"
 #include "clang/AST/Expr.h"
+#include "clang/AST/TypeLoc.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Lex/Lexer.h"
@@ -228,8 +229,16 @@
   SourceLocation L = I->getMemberLocation();
   return CharSourceRange::getTokenRange(L, L);
 }
+if (const auto *T = Node.get()) {
+  TypeLoc Loc = *T;
+  auto ET = T->getAs();
+  if (!ET.isNull()) {
+Loc = ET.getNamedTypeLoc();
+  }
+  return CharSourceRange::getTokenRange(Loc.getSourceRange());
+}
 return typeError(ID, Node.getNodeKind(),
- "DeclRefExpr, NamedDecl, CXXCtorInitializer");
+ "DeclRefExpr, NamedDecl, CXXCtorInitializer, TypeLoc");
   };
 }
 
Index: clang/include/clang/Tooling/Transformer/RangeSelector.h
===
--- clang/include/clang/Tooling/Transformer/RangeSelector.h
+++ clang/include/clang/Tooling/Transformer/RangeSelector.h
@@ -73,9 +73,9 @@
 /// binding in the match result.
 RangeSelector member(std::string ID);
 
-/// Given a node with a "name", (like \c NamedDecl, \c DeclRefExpr or \c
-/// CxxCtorInitializer) selects the name's token.  Only selects the final
-/// identifier of a qualified name, but not any qualifiers or template
+/// Given a node with a "name", (like \c NamedDecl, \c DeclRefExpr, \c
+/// CxxCtorInitializer, and \c TypeLoc) selects the name's token.  Only selects
+/// the final identifier of a qualified name, but not any qualifiers or 
template
 /// arguments.  For example, for `::foo::bar::baz` and `::foo::bar::baz`,
 /// it selects only `baz`.
 ///


Index: clang/unittests/Tooling/RangeSelectorTest.cpp
===
--- clang/unittests/Tooling/RangeSelectorTest.cpp
+++ clang/unittests/Tooling/RangeSelectorTest.cpp
@@ -457,6 +457,35 @@
   EXPECT_THAT_EXPECTED(select(name(Init), Match), HasValue("field"));
 }
 
+TEST(RangeSelectorTest, NameOpTypeLoc) {
+  StringRef Code = R"cc(
+namespace ns {
+struct Foo {
+  Foo();
+  Foo(int);
+  Foo(int, int);
+};
+}  // namespace ns
+
+ns::Foo a;
+auto b = ns::Foo(3);
+auto c = ns::Foo(1, 2);
+  )cc";
+  const char *CtorTy = "ctor_ty";
+  // Matches declaration of `a`
+  TestMatch MatchA = matchCode(
+  Code, varDecl(hasName("a"), hasTypeLoc(typeLoc().bind(CtorTy;
+  EXPECT_THAT_EXPECTED(select(name(CtorTy), MatchA), HasValue("Foo"));
+  // Matches call of Foo(int)
+  TestMatch MatchB = matchCode(
+  Code, cxxFunctionalCastExpr(hasTypeLoc(typeLoc().bind(CtorTy;
+  EXPECT_THAT_EXPECTED(select(name(CtorTy), MatchB), HasValue("Foo"));
+  // Matches call of Foo(int, int)
+  TestMatch MatchC 

[PATCH] D102180: [Clang][OpenMP] Emit dependent PreInits before directive.

2021-05-10 Thread Michael Kruse via Phabricator via cfe-commits
Meinersbur updated this revision to Diff 344134.
Meinersbur added a comment.

- Don't return false for void lambda


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102180

Files:
  clang/include/clang/AST/StmtOpenMP.h
  clang/lib/AST/StmtOpenMP.cpp
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/tile_codegen.cpp
  clang/test/OpenMP/tile_codegen_for_dependent.cpp
  clang/test/OpenMP/tile_codegen_for_multiple.cpp

Index: clang/test/OpenMP/tile_codegen_for_multiple.cpp
===
--- /dev/null
+++ clang/test/OpenMP/tile_codegen_for_multiple.cpp
@@ -0,0 +1,248 @@
+// Check code generation
+// RUN: %clang_cc1 -verify -triple x86_64-pc-linux-gnu -fopenmp -fopenmp-version=51 -emit-llvm %s -o - | FileCheck %s --check-prefix=IR
+
+// Check same results after serialization round-trip
+// RUN: %clang_cc1 -verify -triple x86_64-pc-linux-gnu -fopenmp -fopenmp-version=51 -emit-pch -o %t %s
+// RUN: %clang_cc1 -verify -triple x86_64-pc-linux-gnu -fopenmp -fopenmp-version=51 -include-pch %t -emit-llvm %s -o - | FileCheck %s --check-prefix=IR
+// expected-no-diagnostics
+
+// Account for multiple transformations of a loop before consumed by
+// #pragma omp for.
+
+#ifndef HEADER
+#define HEADER
+
+// placeholder for loop body code.
+extern "C" void body(...) {}
+
+
+// IR-LABEL: @func(
+// IR-NEXT:  [[ENTRY:.*]]:
+// IR-NEXT:%[[START_ADDR:.+]] = alloca i32, align 4
+// IR-NEXT:%[[END_ADDR:.+]] = alloca i32, align 4
+// IR-NEXT:%[[STEP_ADDR:.+]] = alloca i32, align 4
+// IR-NEXT:%[[DOTOMP_IV:.+]] = alloca i32, align 4
+// IR-NEXT:%[[TMP:.+]] = alloca i32, align 4
+// IR-NEXT:%[[DOTCAPTURE_EXPR_:.+]] = alloca i32, align 4
+// IR-NEXT:%[[DOTCAPTURE_EXPR_1:.+]] = alloca i32, align 4
+// IR-NEXT:%[[DOTCAPTURE_EXPR_2:.+]] = alloca i32, align 4
+// IR-NEXT:%[[DOTCAPTURE_EXPR_3:.+]] = alloca i32, align 4
+// IR-NEXT:%[[I:.+]] = alloca i32, align 4
+// IR-NEXT:%[[DOTCAPTURE_EXPR_6:.+]] = alloca i32, align 4
+// IR-NEXT:%[[DOTCAPTURE_EXPR_8:.+]] = alloca i32, align 4
+// IR-NEXT:%[[DOTFLOOR_0_IV_I:.+]] = alloca i32, align 4
+// IR-NEXT:%[[DOTCAPTURE_EXPR_12:.+]] = alloca i32, align 4
+// IR-NEXT:%[[DOTCAPTURE_EXPR_14:.+]] = alloca i32, align 4
+// IR-NEXT:%[[DOTFLOOR_0_IV__FLOOR_0_IV_I:.+]] = alloca i32, align 4
+// IR-NEXT:%[[DOTOMP_LB:.+]] = alloca i32, align 4
+// IR-NEXT:%[[DOTOMP_UB:.+]] = alloca i32, align 4
+// IR-NEXT:%[[DOTOMP_STRIDE:.+]] = alloca i32, align 4
+// IR-NEXT:%[[DOTOMP_IS_LAST:.+]] = alloca i32, align 4
+// IR-NEXT:%[[DOTFLOOR_0_IV__FLOOR_0_IV_I18:.+]] = alloca i32, align 4
+// IR-NEXT:%[[DOTTILE_0_IV__FLOOR_0_IV_I:.+]] = alloca i32, align 4
+// IR-NEXT:%[[DOTTILE_0_IV_I:.+]] = alloca i32, align 4
+// IR-NEXT:%[[TMP0:.+]] = call i32 @__kmpc_global_thread_num(%struct.ident_t* @2)
+// IR-NEXT:store i32 %[[START:.+]], i32* %[[START_ADDR]], align 4
+// IR-NEXT:store i32 %[[END:.+]], i32* %[[END_ADDR]], align 4
+// IR-NEXT:store i32 %[[STEP:.+]], i32* %[[STEP_ADDR]], align 4
+// IR-NEXT:%[[TMP1:.+]] = load i32, i32* %[[START_ADDR]], align 4
+// IR-NEXT:store i32 %[[TMP1]], i32* %[[DOTCAPTURE_EXPR_]], align 4
+// IR-NEXT:%[[TMP2:.+]] = load i32, i32* %[[END_ADDR]], align 4
+// IR-NEXT:store i32 %[[TMP2]], i32* %[[DOTCAPTURE_EXPR_1]], align 4
+// IR-NEXT:%[[TMP3:.+]] = load i32, i32* %[[STEP_ADDR]], align 4
+// IR-NEXT:store i32 %[[TMP3]], i32* %[[DOTCAPTURE_EXPR_2]], align 4
+// IR-NEXT:%[[TMP4:.+]] = load i32, i32* %[[DOTCAPTURE_EXPR_1]], align 4
+// IR-NEXT:%[[TMP5:.+]] = load i32, i32* %[[DOTCAPTURE_EXPR_]], align 4
+// IR-NEXT:%[[SUB:.+]] = sub i32 %[[TMP4]], %[[TMP5]]
+// IR-NEXT:%[[SUB4:.+]] = sub i32 %[[SUB]], 1
+// IR-NEXT:%[[TMP6:.+]] = load i32, i32* %[[DOTCAPTURE_EXPR_2]], align 4
+// IR-NEXT:%[[ADD:.+]] = add i32 %[[SUB4]], %[[TMP6]]
+// IR-NEXT:%[[TMP7:.+]] = load i32, i32* %[[DOTCAPTURE_EXPR_2]], align 4
+// IR-NEXT:%[[DIV:.+]] = udiv i32 %[[ADD]], %[[TMP7]]
+// IR-NEXT:%[[SUB5:.+]] = sub i32 %[[DIV]], 1
+// IR-NEXT:store i32 %[[SUB5]], i32* %[[DOTCAPTURE_EXPR_3]], align 4
+// IR-NEXT:%[[TMP8:.+]] = load i32, i32* %[[START_ADDR]], align 4
+// IR-NEXT:store i32 %[[TMP8]], i32* %[[I]], align 4
+// IR-NEXT:%[[TMP9:.+]] = load i32, i32* %[[DOTCAPTURE_EXPR_3]], align 4
+// IR-NEXT:%[[ADD7:.+]] = add i32 %[[TMP9]], 1
+// IR-NEXT:store i32 %[[ADD7]], i32* %[[DOTCAPTURE_EXPR_6]], align 4
+// IR-NEXT:%[[TMP10:.+]] = load i32, i32* %[[DOTCAPTURE_EXPR_6]], align 4
+// IR-NEXT:%[[SUB9:.+]] = sub i32 %[[TMP10]], -3
+// IR-NEXT:%[[DIV10:.+]] = udiv i32 %[[SUB9]], 4
+// IR-NEXT:%[[SUB11:.+]] = sub i32 %[[DIV10]], 1
+// IR-NEXT:store i32 %[[SUB11]], i32* %[[DOTCAPTURE_EXPR_8]], align 4
+// IR-NEXT:store i32 0, i32* %[[DOTFLOOR_

[PATCH] D101630: [HIP] Fix device-only compilation

2021-05-10 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

In D101630#2744861 , @yaxunl wrote:

> [snip] it is the convention for compiler to have one output. 
> The compilation is like a pipeline. If we break it into stages, users would 
> expect to use the output from one stage as input for the next stage. This is 
> possible only if there is one output. 
> Also, when users do not want the output to be bundled, it is usually for 
> debugging or special purposes. Users need to know the naming convention of 
> the multiple outputs. I think it is justifiable to enable this by an option.

So in the end it's a trade-off between tools like ccache working out of the box 
vs additional option that would need to be used by users we do need specific 
intermediate output. 
Considering that intermediate output already need special handling, I'll agree 
that bundling by default is likely more useful.

Now the question is how to make it work without breaking existing users.

There are some tools that rely on clang `--cuda-host-only` and 
`--cuda-device-only` to work as if it was a regular C++ compilation. E.g. 
godbolt.org. 
It may be useful to do bundling **only** if we're dealing with multiple 
outputs. 
On the other hand, it may puzzle users why they get a bundle with `clang -S 
--offload_arch=X --offload_arch=Y` but plain text assembly with `clang -S 
--offload_arch=X`.

How about this:
If the user explicitly specified `--cuda-host-only` or `--cuda-device-only`, 
then by default only allow producing the natural output format, unless a 
bundled output is requested by an option. This should keep existing users 
working.
If the compilation is done without explicitly requested sub-compilation(s), 
then bundle the output by default. This should keep the GPU-unaware tools like 
ccache happy as they would always get the single output they expect.

WDYT?


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

https://reviews.llvm.org/D101630

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


[PATCH] D100509: Support GCC's -fstack-usage flag

2021-05-10 Thread Pengxuan Zheng via Phabricator via cfe-commits
pzheng updated this revision to Diff 344135.
pzheng added a comment.

Address a few more comments from @MaskRay.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100509

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Basic/CodeGenOptions.h
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/stack-usage.c
  clang/test/Driver/stack-usage.c
  llvm/include/llvm/CodeGen/AsmPrinter.h
  llvm/include/llvm/Target/TargetOptions.h
  llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp

Index: llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
===
--- llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
+++ llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
@@ -1185,6 +1185,37 @@
   OutStreamer->PopSection();
 }
 
+void AsmPrinter::emitStackUsage(const MachineFunction &MF) {
+  auto OutputFilename = MF.getTarget().Options.StackUsageOutput;
+
+  // OutputFilename empty implies -fstack-usage is not passed.
+  if (OutputFilename.empty())
+return;
+
+  const MachineFrameInfo &FrameInfo = MF.getFrameInfo();
+  uint64_t StackSize = FrameInfo.getStackSize();
+
+  if (StackUsageStream == nullptr) {
+std::error_code EC;
+StackUsageStream =
+std::make_unique(OutputFilename, EC, sys::fs::OF_Text);
+if (EC) {
+  errs() << "Could not open file: " << EC.message();
+  return;
+}
+  }
+
+  *StackUsageStream << MF.getFunction().getParent()->getName();
+  if (const DISubprogram *DSP = MF.getFunction().getSubprogram())
+*StackUsageStream << ':' << DSP->getLine();
+
+  *StackUsageStream << ':' << MF.getName() << '\t' << StackSize << '\t';
+  if (FrameInfo.hasVarSizedObjects())
+*StackUsageStream << "dynamic\n";
+  else
+*StackUsageStream << "static\n";
+}
+
 static bool needFuncLabelsForEHOrDebugInfo(const MachineFunction &MF) {
   MachineModuleInfo &MMI = MF.getMMI();
   if (!MF.getLandingPads().empty() || MF.hasEHFunclets() || MMI.hasDebugInfo())
@@ -1469,6 +1500,9 @@
   // Emit section containing stack size metadata.
   emitStackSizeSection(*MF);
 
+  // Emit .su file containing function stack size information.
+  emitStackUsage(*MF);
+
   emitPatchableFunctionEntries();
 
   if (isVerbose())
Index: llvm/include/llvm/Target/TargetOptions.h
===
--- llvm/include/llvm/Target/TargetOptions.h
+++ llvm/include/llvm/Target/TargetOptions.h
@@ -337,6 +337,11 @@
 /// Stack protector guard reg to use, e.g. usually fs or gs in X86.
 std::string StackProtectorGuardReg = "None";
 
+/// Name of the stack usage file (i.e., .su file) if user passes
+/// -fstack-usage. If empty, it can be implied that -fstack-usage is not
+/// passed on the command line.
+std::string StackUsageOutput;
+
 /// FloatABIType - This setting is set by -float-abi=xxx option is specfied
 /// on the command line. This setting may either be Default, Soft, or Hard.
 /// Default selects the target's default behavior. Soft selects the ABI for
Index: llvm/include/llvm/CodeGen/AsmPrinter.h
===
--- llvm/include/llvm/CodeGen/AsmPrinter.h
+++ llvm/include/llvm/CodeGen/AsmPrinter.h
@@ -182,6 +182,9 @@
   /// Emit comments in assembly output if this is true.
   bool VerboseAsm;
 
+  /// Output stream for the stack usage file (i.e., .su file).
+  std::unique_ptr StackUsageStream;
+
   static char ID;
 
 protected:
@@ -358,6 +361,8 @@
 
   void emitStackSizeSection(const MachineFunction &MF);
 
+  void emitStackUsage(const MachineFunction &MF);
+
   void emitBBAddrMapSection(const MachineFunction &MF);
 
   void emitPseudoProbe(const MachineInstr &MI);
Index: clang/test/Driver/stack-usage.c
===
--- /dev/null
+++ clang/test/Driver/stack-usage.c
@@ -0,0 +1,7 @@
+// RUN: %clang -target aarch64-unknown %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-ABSENT
+// CHECK-ABSENT-NOT: -fstack-usage
+
+// RUN: %clang -target aarch64-unknown -fstack-usage %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-PRESENT
+// CHECK-PRESENT: "-fstack-usage"
+
+int foo() { return 42; }
Index: clang/test/CodeGen/stack-usage.c
===
--- /dev/null
+++ clang/test/CodeGen/stack-usage.c
@@ -0,0 +1,19 @@
+// REQUIRES: aarch64-registered-target
+
+// RUN: rm -rf %t && mkdir %t
+// RUN: %clang_cc1 -triple aarch64-unknown -fstack-usage -emit-obj %s -o %t/b.o
+// RUN: FileCheck %s < %t/b.su
+
+// CHECK: stack-usage.c:[[#@LINE+1]]:foo	{{[0-9]+}}	static
+int foo() {
+  char a[8];
+
+  return 0;
+}
+
+// CHECK: stack-usage.c:[[#@LINE+1]]:bar	{{[0-9]+}}	dynamic
+int bar(int len) {
+  char a[len];
+
+  r

[PATCH] D102122: Support warn_unused_result on typedefs

2021-05-10 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a reviewer: rsmith.
aaron.ballman added a comment.

In D102122#2748271 , @dblaikie wrote:

> In D102122#2748206 , @aaron.ballman 
> wrote:
>
>> Let me start off by saying: thanks, I think this is really useful 
>> functionality. As a ridiculously obvious example, Annex K has an integer 
>> type alias `errno_t` and it would incredibly handy to be able to mark that 
>> as `[[nodiscard]]` to strongly encourage checking for errors for functions 
>> that return that type (not that we support Annex K, but the general idea 
>> extends to any integer-based error type).
>>
>> That said, there are multiple different ways to spell the same semantic 
>> attribute, and it's not clear to me that we want to change them all the same 
>> way.
>>
>> `[[clang::warn_unused_result]]` is ours to do with as we please, so there's 
>> no issue changing that behavior.
>>
>> `__attribute__((warn_unused_result))` and `[[gnu::warn_unused_result]]` are 
>> governed by GCC and we try to be compatible with their behavior. GCC does 
>> not appear to support the attribute on typedefs from my testing, so we'd 
>> want to coordinate with the GCC folks to see if there's an appetite for the 
>> change.
>
> FWIW, looks like we already diverge from GCC's behavior - GCC doesn't seem to 
> support this attribute on types at all: https://godbolt.org/z/8YjqnE4cv (but 
> does support [[nodiscard]] in that place)

Whomp whomp! :-(

>> `[[nodiscard]]` is governed by both the C++ and C standards and we should 
>> not be changing its behavior without some extra diagnostics about extensions 
>> (and, preferably, some sort of attempt to standardize the behavior with 
>> WG14/WG21).
>
> Might be a compatible extension, though - to use a standard attribute in a 
> non-standard context? (at least clang and gcc only warn on putting 
> [[nodiscard]] in non-standard places, they don't error)

It's a bit unclear -- there's a list of things the attribute applies to, and 
typedef is not on the list, so it would be reasonable to think that means the 
attribute can't be written on anything else. But because the standard doesn't 
say what happens if you DO apply it to a typedef, perhaps that's sufficiently 
undefined to allow us to call it a conforming extension. Given that you're fine 
trying to get this standardized and it seems like it shouldn't be contentious, 
I think we aren't behaving badly if we accept `[[nodiscard]]` on a typedef so 
long as we give an extension warning.

>> Do you have an appetite to talk to the GCC and standards folks?
>
> Medium interest.
>
>> If not, then I think the safest bet is to only change the behavior for the 
>> `[[clang::warn_unused_result]]` and to leave the other forms alone for now.
>
> Happy to go either way.
>
> Is there an easy/recommended way to split these things up? Duplicate the 
> records in the td/come up with separate names, etc?)

Given that we already diverge from GCC for `warn_unused_result`, and because 
you're willing to give the standardization bit a shot and that seems highly 
likely to succeed, I say let's try to keep the same semantic effects for all of 
the spellings in terms of what the attribute does. If that's reasonable to 
everyone, then in SemaDeclAttr.cpp, when we see the standard spelling on a 
typedef declaration (`using` as well as `typedef`), we can issue a Clang 
extension warning on that particular use so that it's clear this is not yet 
standardized behavior for that spelling.

Btw, if you ever find yourself needing to distinguish between various spellings 
for the semantics of an attribute, you can use an `Accessors` list in the .td 
file (e.g., 
https://github.com/llvm/llvm-project/blob/main/clang/include/clang/Basic/Attr.td#L665).

>> In D102122#2746426 , @dblaikie 
>> wrote:
>>
>>> Fixes for a few other test cases (though I wonder if these tests are 
>>> overconstrained - do we need to be testing the list of things this 
>>> attribute can be applied to in so many places?)
>>
>> If the semantics of the attribute are identical regardless of how it's 
>> spelled, then we probably don't need the tests all spread out in multiple 
>> files. However, I don't think there's an intention to keep all of the 
>> spellings with identical semantics, so the different tests might still make 
>> sense (but could perhaps be cleaned up).
>>
>> In D102122#2746424 , @dblaikie 
>> wrote:
>>
>>> Oh, one question: If we do move forward with this patch, how would we 
>>> detect that the compiler supports this new use of warn_unused_result? (so 
>>> that the feature detection macros in LLVM properly make the attribute a 
>>> no-op unless we have a version of clang that supports it)
>>
>> `__has_[c|cpp]_attribute` returns a value, so we'd likely wind up using that 
>> return value to distinguish between versions.
>
> Hmm - what if 

[PATCH] D100509: Support GCC's -fstack-usage flag

2021-05-10 Thread Pengxuan Zheng via Phabricator via cfe-commits
pzheng marked 2 inline comments as done.
pzheng added inline comments.



Comment at: clang/include/clang/Basic/CodeGenOptions.def:110
 CODEGENOPT(StackSizeSection  , 1, 0) ///< Set when -fstack-size-section is 
enabled.
+CODEGENOPT(StackUsage, 1, 0) ///< Set when -fstack-usage is enabled.
 CODEGENOPT(ForceDwarfFrameSection , 1, 0) ///< Set when -fforce-dwarf-frame is

MaskRay wrote:
> Unneeded
I tried removing this line, but TableGen doesn't seem to generate the 
fstack_usage flag anymore. Looks like this needs to be kept. Thoughts?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100509

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


[PATCH] D102180: [Clang][OpenMP] Emit dependent PreInits before directive.

2021-05-10 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: clang/lib/Sema/SemaOpenMP.cpp:8975
+}
+return false;
   }))

No need for `return false;`



Comment at: clang/lib/Sema/SemaOpenMP.cpp:12607
+  PreInits.push_back(C);
+return false;
   }))

Same, no need for `return`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102180

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


[clang] 18f3a14 - [RISCV] Validate the SEW and LMUL operands to __builtin_rvv_vsetvli(max)

2021-05-10 Thread Craig Topper via cfe-commits

Author: Craig Topper
Date: 2021-05-10T12:11:13-07:00
New Revision: 18f3a14e1328c813fa5dbacc9bb931d22f0669cd

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

LOG: [RISCV] Validate the SEW and LMUL operands to __builtin_rvv_vsetvli(max)

These are required to be constants, this patch makes sure they
are in the accepted range of values.

These are usually created by wrappers in the riscv_vector.h header
which should always be correct. This patch protects against a user
using the builtin directly.

Reviewed By: khchen

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

Added: 
clang/test/CodeGen/RISCV/rvv_errors.c

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

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 99b41692688e7..f78940a6e6fad 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -11267,4 +11267,6 @@ def warn_tcb_enforcement_violation : Warning<
 // RISC-V builtin required extension warning
 def err_riscv_builtin_requires_extension : Error<
   "builtin requires '%0' extension support to be enabled">;
+def err_riscv_builtin_invalid_lmul : Error<
+  "LMUL argument must be in the range [0,3] or [5,7]">;
 } // end of sema component.

diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index d2a07450d9361..53ff0f1e634df 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -12539,6 +12539,7 @@ class Sema final {
   bool CheckPPCBuiltinFunctionCall(const TargetInfo &TI, unsigned BuiltinID,
CallExpr *TheCall);
   bool CheckAMDGCNBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall);
+  bool CheckRISCVLMUL(CallExpr *TheCall, unsigned ArgNum);
   bool CheckRISCVBuiltinFunctionCall(const TargetInfo &TI, unsigned BuiltinID,
  CallExpr *TheCall);
 

diff  --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index fec02b85a03b3..f3f1ccd775285 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -3417,6 +3417,26 @@ bool Sema::CheckAMDGCNBuiltinFunctionCall(unsigned 
BuiltinID,
   return false;
 }
 
+bool Sema::CheckRISCVLMUL(CallExpr *TheCall, unsigned ArgNum) {
+  llvm::APSInt Result;
+
+  // We can't check the value of a dependent argument.
+  Expr *Arg = TheCall->getArg(ArgNum);
+  if (Arg->isTypeDependent() || Arg->isValueDependent())
+return false;
+
+  // Check constant-ness first.
+  if (SemaBuiltinConstantArg(TheCall, ArgNum, Result))
+return true;
+
+  int64_t Val = Result.getSExtValue();
+  if ((Val >= 0 && Val <= 3) || (Val >= 5 && Val <= 7))
+return false;
+
+  return Diag(TheCall->getBeginLoc(), diag::err_riscv_builtin_invalid_lmul)
+ << Arg->getSourceRange();
+}
+
 bool Sema::CheckRISCVBuiltinFunctionCall(const TargetInfo &TI,
  unsigned BuiltinID,
  CallExpr *TheCall) {
@@ -3448,7 +3468,19 @@ bool Sema::CheckRISCVBuiltinFunctionCall(const 
TargetInfo &TI,
 << TheCall->getSourceRange() << StringRef(FeatureStr);
   }
 
-  return FeatureMissing;
+  if (FeatureMissing)
+return true;
+
+  switch (BuiltinID) {
+  case RISCV::BI__builtin_rvv_vsetvli:
+return SemaBuiltinConstantArgRange(TheCall, 1, 0, 3) ||
+   CheckRISCVLMUL(TheCall, 2);
+  case RISCV::BI__builtin_rvv_vsetvlimax:
+return SemaBuiltinConstantArgRange(TheCall, 0, 0, 3) ||
+   CheckRISCVLMUL(TheCall, 1);
+  }
+
+  return false;
 }
 
 bool Sema::CheckSystemZBuiltinFunctionCall(unsigned BuiltinID,

diff  --git a/clang/test/CodeGen/RISCV/rvv_errors.c 
b/clang/test/CodeGen/RISCV/rvv_errors.c
new file mode 100644
index 0..40ec544d0b76b
--- /dev/null
+++ b/clang/test/CodeGen/RISCV/rvv_errors.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 %s -triple=riscv64 -target-feature +experimental-v 
-fsyntax-only -verify
+
+void test() {
+  __builtin_rvv_vsetvli(1, 7, 0); // expected-error {{argument value 7 is 
outside the valid range [0, 3]}}
+  __builtin_rvv_vsetvlimax(-1, 0); // expected-error {{argument value 
18446744073709551615 is outside the valid range [0, 3]}}
+  __builtin_rvv_vsetvli(1, 0, 4); // expected-error {{LMUL argument must be in 
the range [0,3] or [5,7]}}
+  __builtin_rvv_vsetvlimax(0, 4); // expected-error {{LMUL argument must be in 
the range [0,3] or [5,7]}}
+  __builtin_rvv_vsetvli(1, 0, 8); // expected-error {{LMUL argument must be in 
the range [0,3] or [5,7]}}
+  __builtin_rvv_vsetvlimax(0, -1); // expected-error {{LMUL argument must be 

[PATCH] D102086: [RISCV] Validate the SEW and LMUL operands to __builtin_rvv_vsetvli(max)

2021-05-10 Thread Craig Topper via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG18f3a14e1328: [RISCV] Validate the SEW and LMUL operands to 
__builtin_rvv_vsetvli(max) (authored by craig.topper).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102086

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/RISCV/rvv_errors.c


Index: clang/test/CodeGen/RISCV/rvv_errors.c
===
--- /dev/null
+++ clang/test/CodeGen/RISCV/rvv_errors.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 %s -triple=riscv64 -target-feature +experimental-v 
-fsyntax-only -verify
+
+void test() {
+  __builtin_rvv_vsetvli(1, 7, 0); // expected-error {{argument value 7 is 
outside the valid range [0, 3]}}
+  __builtin_rvv_vsetvlimax(-1, 0); // expected-error {{argument value 
18446744073709551615 is outside the valid range [0, 3]}}
+  __builtin_rvv_vsetvli(1, 0, 4); // expected-error {{LMUL argument must be in 
the range [0,3] or [5,7]}}
+  __builtin_rvv_vsetvlimax(0, 4); // expected-error {{LMUL argument must be in 
the range [0,3] or [5,7]}}
+  __builtin_rvv_vsetvli(1, 0, 8); // expected-error {{LMUL argument must be in 
the range [0,3] or [5,7]}}
+  __builtin_rvv_vsetvlimax(0, -1); // expected-error {{LMUL argument must be 
in the range [0,3] or [5,7]}}
+}
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -3417,6 +3417,26 @@
   return false;
 }
 
+bool Sema::CheckRISCVLMUL(CallExpr *TheCall, unsigned ArgNum) {
+  llvm::APSInt Result;
+
+  // We can't check the value of a dependent argument.
+  Expr *Arg = TheCall->getArg(ArgNum);
+  if (Arg->isTypeDependent() || Arg->isValueDependent())
+return false;
+
+  // Check constant-ness first.
+  if (SemaBuiltinConstantArg(TheCall, ArgNum, Result))
+return true;
+
+  int64_t Val = Result.getSExtValue();
+  if ((Val >= 0 && Val <= 3) || (Val >= 5 && Val <= 7))
+return false;
+
+  return Diag(TheCall->getBeginLoc(), diag::err_riscv_builtin_invalid_lmul)
+ << Arg->getSourceRange();
+}
+
 bool Sema::CheckRISCVBuiltinFunctionCall(const TargetInfo &TI,
  unsigned BuiltinID,
  CallExpr *TheCall) {
@@ -3448,7 +3468,19 @@
 << TheCall->getSourceRange() << StringRef(FeatureStr);
   }
 
-  return FeatureMissing;
+  if (FeatureMissing)
+return true;
+
+  switch (BuiltinID) {
+  case RISCV::BI__builtin_rvv_vsetvli:
+return SemaBuiltinConstantArgRange(TheCall, 1, 0, 3) ||
+   CheckRISCVLMUL(TheCall, 2);
+  case RISCV::BI__builtin_rvv_vsetvlimax:
+return SemaBuiltinConstantArgRange(TheCall, 0, 0, 3) ||
+   CheckRISCVLMUL(TheCall, 1);
+  }
+
+  return false;
 }
 
 bool Sema::CheckSystemZBuiltinFunctionCall(unsigned BuiltinID,
Index: clang/include/clang/Sema/Sema.h
===
--- clang/include/clang/Sema/Sema.h
+++ clang/include/clang/Sema/Sema.h
@@ -12539,6 +12539,7 @@
   bool CheckPPCBuiltinFunctionCall(const TargetInfo &TI, unsigned BuiltinID,
CallExpr *TheCall);
   bool CheckAMDGCNBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall);
+  bool CheckRISCVLMUL(CallExpr *TheCall, unsigned ArgNum);
   bool CheckRISCVBuiltinFunctionCall(const TargetInfo &TI, unsigned BuiltinID,
  CallExpr *TheCall);
 
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -11267,4 +11267,6 @@
 // RISC-V builtin required extension warning
 def err_riscv_builtin_requires_extension : Error<
   "builtin requires '%0' extension support to be enabled">;
+def err_riscv_builtin_invalid_lmul : Error<
+  "LMUL argument must be in the range [0,3] or [5,7]">;
 } // end of sema component.


Index: clang/test/CodeGen/RISCV/rvv_errors.c
===
--- /dev/null
+++ clang/test/CodeGen/RISCV/rvv_errors.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 %s -triple=riscv64 -target-feature +experimental-v -fsyntax-only -verify
+
+void test() {
+  __builtin_rvv_vsetvli(1, 7, 0); // expected-error {{argument value 7 is outside the valid range [0, 3]}}
+  __builtin_rvv_vsetvlimax(-1, 0); // expected-error {{argument value 18446744073709551615 is outside the valid range [0, 3]}}
+  __builtin_rvv_vsetvli(1, 0, 4); // expected-error {{LMUL argument must be in the range [0,3] or [5,7]}}
+  __builtin_rvv_vsetvlimax(0, 4); // expected-error {{LMUL argument must be in the range [0,3] or [5,7]}}
+  __builtin_r

[PATCH] D102180: [Clang][OpenMP] Emit dependent PreInits before directive.

2021-05-10 Thread Michael Kruse via Phabricator via cfe-commits
Meinersbur updated this revision to Diff 344145.
Meinersbur added a comment.

- Remove unused 'this' capture


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102180

Files:
  clang/include/clang/AST/StmtOpenMP.h
  clang/lib/AST/StmtOpenMP.cpp
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/tile_codegen.cpp
  clang/test/OpenMP/tile_codegen_for_dependent.cpp
  clang/test/OpenMP/tile_codegen_for_multiple.cpp

Index: clang/test/OpenMP/tile_codegen_for_multiple.cpp
===
--- /dev/null
+++ clang/test/OpenMP/tile_codegen_for_multiple.cpp
@@ -0,0 +1,248 @@
+// Check code generation
+// RUN: %clang_cc1 -verify -triple x86_64-pc-linux-gnu -fopenmp -fopenmp-version=51 -emit-llvm %s -o - | FileCheck %s --check-prefix=IR
+
+// Check same results after serialization round-trip
+// RUN: %clang_cc1 -verify -triple x86_64-pc-linux-gnu -fopenmp -fopenmp-version=51 -emit-pch -o %t %s
+// RUN: %clang_cc1 -verify -triple x86_64-pc-linux-gnu -fopenmp -fopenmp-version=51 -include-pch %t -emit-llvm %s -o - | FileCheck %s --check-prefix=IR
+// expected-no-diagnostics
+
+// Account for multiple transformations of a loop before consumed by
+// #pragma omp for.
+
+#ifndef HEADER
+#define HEADER
+
+// placeholder for loop body code.
+extern "C" void body(...) {}
+
+
+// IR-LABEL: @func(
+// IR-NEXT:  [[ENTRY:.*]]:
+// IR-NEXT:%[[START_ADDR:.+]] = alloca i32, align 4
+// IR-NEXT:%[[END_ADDR:.+]] = alloca i32, align 4
+// IR-NEXT:%[[STEP_ADDR:.+]] = alloca i32, align 4
+// IR-NEXT:%[[DOTOMP_IV:.+]] = alloca i32, align 4
+// IR-NEXT:%[[TMP:.+]] = alloca i32, align 4
+// IR-NEXT:%[[DOTCAPTURE_EXPR_:.+]] = alloca i32, align 4
+// IR-NEXT:%[[DOTCAPTURE_EXPR_1:.+]] = alloca i32, align 4
+// IR-NEXT:%[[DOTCAPTURE_EXPR_2:.+]] = alloca i32, align 4
+// IR-NEXT:%[[DOTCAPTURE_EXPR_3:.+]] = alloca i32, align 4
+// IR-NEXT:%[[I:.+]] = alloca i32, align 4
+// IR-NEXT:%[[DOTCAPTURE_EXPR_6:.+]] = alloca i32, align 4
+// IR-NEXT:%[[DOTCAPTURE_EXPR_8:.+]] = alloca i32, align 4
+// IR-NEXT:%[[DOTFLOOR_0_IV_I:.+]] = alloca i32, align 4
+// IR-NEXT:%[[DOTCAPTURE_EXPR_12:.+]] = alloca i32, align 4
+// IR-NEXT:%[[DOTCAPTURE_EXPR_14:.+]] = alloca i32, align 4
+// IR-NEXT:%[[DOTFLOOR_0_IV__FLOOR_0_IV_I:.+]] = alloca i32, align 4
+// IR-NEXT:%[[DOTOMP_LB:.+]] = alloca i32, align 4
+// IR-NEXT:%[[DOTOMP_UB:.+]] = alloca i32, align 4
+// IR-NEXT:%[[DOTOMP_STRIDE:.+]] = alloca i32, align 4
+// IR-NEXT:%[[DOTOMP_IS_LAST:.+]] = alloca i32, align 4
+// IR-NEXT:%[[DOTFLOOR_0_IV__FLOOR_0_IV_I18:.+]] = alloca i32, align 4
+// IR-NEXT:%[[DOTTILE_0_IV__FLOOR_0_IV_I:.+]] = alloca i32, align 4
+// IR-NEXT:%[[DOTTILE_0_IV_I:.+]] = alloca i32, align 4
+// IR-NEXT:%[[TMP0:.+]] = call i32 @__kmpc_global_thread_num(%struct.ident_t* @2)
+// IR-NEXT:store i32 %[[START:.+]], i32* %[[START_ADDR]], align 4
+// IR-NEXT:store i32 %[[END:.+]], i32* %[[END_ADDR]], align 4
+// IR-NEXT:store i32 %[[STEP:.+]], i32* %[[STEP_ADDR]], align 4
+// IR-NEXT:%[[TMP1:.+]] = load i32, i32* %[[START_ADDR]], align 4
+// IR-NEXT:store i32 %[[TMP1]], i32* %[[DOTCAPTURE_EXPR_]], align 4
+// IR-NEXT:%[[TMP2:.+]] = load i32, i32* %[[END_ADDR]], align 4
+// IR-NEXT:store i32 %[[TMP2]], i32* %[[DOTCAPTURE_EXPR_1]], align 4
+// IR-NEXT:%[[TMP3:.+]] = load i32, i32* %[[STEP_ADDR]], align 4
+// IR-NEXT:store i32 %[[TMP3]], i32* %[[DOTCAPTURE_EXPR_2]], align 4
+// IR-NEXT:%[[TMP4:.+]] = load i32, i32* %[[DOTCAPTURE_EXPR_1]], align 4
+// IR-NEXT:%[[TMP5:.+]] = load i32, i32* %[[DOTCAPTURE_EXPR_]], align 4
+// IR-NEXT:%[[SUB:.+]] = sub i32 %[[TMP4]], %[[TMP5]]
+// IR-NEXT:%[[SUB4:.+]] = sub i32 %[[SUB]], 1
+// IR-NEXT:%[[TMP6:.+]] = load i32, i32* %[[DOTCAPTURE_EXPR_2]], align 4
+// IR-NEXT:%[[ADD:.+]] = add i32 %[[SUB4]], %[[TMP6]]
+// IR-NEXT:%[[TMP7:.+]] = load i32, i32* %[[DOTCAPTURE_EXPR_2]], align 4
+// IR-NEXT:%[[DIV:.+]] = udiv i32 %[[ADD]], %[[TMP7]]
+// IR-NEXT:%[[SUB5:.+]] = sub i32 %[[DIV]], 1
+// IR-NEXT:store i32 %[[SUB5]], i32* %[[DOTCAPTURE_EXPR_3]], align 4
+// IR-NEXT:%[[TMP8:.+]] = load i32, i32* %[[START_ADDR]], align 4
+// IR-NEXT:store i32 %[[TMP8]], i32* %[[I]], align 4
+// IR-NEXT:%[[TMP9:.+]] = load i32, i32* %[[DOTCAPTURE_EXPR_3]], align 4
+// IR-NEXT:%[[ADD7:.+]] = add i32 %[[TMP9]], 1
+// IR-NEXT:store i32 %[[ADD7]], i32* %[[DOTCAPTURE_EXPR_6]], align 4
+// IR-NEXT:%[[TMP10:.+]] = load i32, i32* %[[DOTCAPTURE_EXPR_6]], align 4
+// IR-NEXT:%[[SUB9:.+]] = sub i32 %[[TMP10]], -3
+// IR-NEXT:%[[DIV10:.+]] = udiv i32 %[[SUB9]], 4
+// IR-NEXT:%[[SUB11:.+]] = sub i32 %[[DIV10]], 1
+// IR-NEXT:store i32 %[[SUB11]], i32* %[[DOTCAPTURE_EXPR_8]], align 4
+// IR-NEXT:store i32 0, i32* %[[DOTFLOOR_0_IV_I

[PATCH] D102015: [clang CodeGen] Don't crash on large atomic function parameter.

2021-05-10 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

In D102015#2748441 , @efriedma wrote:

>> ...I'm confused about why this code is doing what it's doing with cleanups, 
>> though.  Why does it only apply when the parameter is indirect?  I believe 
>> `isParamDestroyedInCallee()` can apply to types that are passed in other 
>> ways, so where we pushing the destructor for those, and why isn't it good 
>> enough to handle this case as well?
>
> Objects with a non-trivial destructor end up indirect anyway under the normal 
> ABI rules.  Not sure how it interacts with trivial_abi; I'll look into it.

Figured it out.  "isIndirect()" here doesn't mean the same thing that it means 
in ABIArgInfo.  If `hasScalarEvaluationKind(Ty)` is false, the caller ensures 
the value is "isIndirect()", i.e. on the stack.  It doesn't matter if the value 
was actually passed in registers.

It's not immediately obvious to me why the responsibility for creating stack 
temporaries was split this way, but it's not really relevant to this patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102015

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


[PATCH] D102175: [clang-tidy] performance-unnecessary-copy-initialization: Remove the complete statement when the copied variable is unused.

2021-05-10 Thread Felix Berger via Phabricator via cfe-commits
flx updated this revision to Diff 344149.
flx added a comment.

Fix test case.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102175

Files:
  clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp
  clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.h
  
clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization-allowed-types.cpp
  
clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp
@@ -38,60 +38,88 @@
   const auto AutoAssigned = ExpensiveTypeReference();
   // CHECK-MESSAGES: [[@LINE-1]]:14: warning: the const qualified variable 'AutoAssigned' is copy-constructed from a const reference; consider making it a const reference [performance-unnecessary-copy-initialization]
   // CHECK-FIXES: const auto& AutoAssigned = ExpensiveTypeReference();
+  AutoAssigned.constMethod();
+
   const auto AutoCopyConstructed(ExpensiveTypeReference());
   // CHECK-MESSAGES: [[@LINE-1]]:14: warning: the const qualified variable 'AutoCopyConstructed'
   // CHECK-FIXES: const auto& AutoCopyConstructed(ExpensiveTypeReference());
+  AutoCopyConstructed.constMethod();
+
   const ExpensiveToCopyType VarAssigned = ExpensiveTypeReference();
   // CHECK-MESSAGES: [[@LINE-1]]:29: warning: the const qualified variable 'VarAssigned'
   // CHECK-FIXES:   const ExpensiveToCopyType& VarAssigned = ExpensiveTypeReference();
+  VarAssigned.constMethod();
+
   const ExpensiveToCopyType VarCopyConstructed(ExpensiveTypeReference());
   // CHECK-MESSAGES: [[@LINE-1]]:29: warning: the const qualified variable 'VarCopyConstructed'
   // CHECK-FIXES: const ExpensiveToCopyType& VarCopyConstructed(ExpensiveTypeReference());
+  VarCopyConstructed.constMethod();
 }
 
 void PositiveMethodCallConstReferenceParam(const ExpensiveToCopyType &Obj) {
   const auto AutoAssigned = Obj.reference();
   // CHECK-MESSAGES: [[@LINE-1]]:14: warning: the const qualified variable 'AutoAssigned'
   // CHECK-FIXES: const auto& AutoAssigned = Obj.reference();
+  AutoAssigned.constMethod();
+
   const auto AutoCopyConstructed(Obj.reference());
   // CHECK-MESSAGES: [[@LINE-1]]:14: warning: the const qualified variable 'AutoCopyConstructed'
   // CHECK-FIXES: const auto& AutoCopyConstructed(Obj.reference());
+  AutoCopyConstructed.constMethod();
+
   const ExpensiveToCopyType VarAssigned = Obj.reference();
   // CHECK-MESSAGES: [[@LINE-1]]:29: warning: the const qualified variable 'VarAssigned'
   // CHECK-FIXES: const ExpensiveToCopyType& VarAssigned = Obj.reference();
+  VarAssigned.constMethod();
+
   const ExpensiveToCopyType VarCopyConstructed(Obj.reference());
   // CHECK-MESSAGES: [[@LINE-1]]:29: warning: the const qualified variable 'VarCopyConstructed'
   // CHECK-FIXES: const ExpensiveToCopyType& VarCopyConstructed(Obj.reference());
+  VarCopyConstructed.constMethod();
 }
 
 void PositiveMethodCallConstParam(const ExpensiveToCopyType Obj) {
   const auto AutoAssigned = Obj.reference();
   // CHECK-MESSAGES: [[@LINE-1]]:14: warning: the const qualified variable 'AutoAssigned'
   // CHECK-FIXES: const auto& AutoAssigned = Obj.reference();
+  AutoAssigned.constMethod();
+
   const auto AutoCopyConstructed(Obj.reference());
   // CHECK-MESSAGES: [[@LINE-1]]:14: warning: the const qualified variable 'AutoCopyConstructed'
   // CHECK-FIXES: const auto& AutoCopyConstructed(Obj.reference());
+  AutoCopyConstructed.constMethod();
+
   const ExpensiveToCopyType VarAssigned = Obj.reference();
   // CHECK-MESSAGES: [[@LINE-1]]:29: warning: the const qualified variable 'VarAssigned'
   // CHECK-FIXES: const ExpensiveToCopyType& VarAssigned = Obj.reference();
+  VarAssigned.constMethod();
+
   const ExpensiveToCopyType VarCopyConstructed(Obj.reference());
   // CHECK-MESSAGES: [[@LINE-1]]:29: warning: the const qualified variable 'VarCopyConstructed'
   // CHECK-FIXES: const ExpensiveToCopyType& VarCopyConstructed(Obj.reference());
+  VarCopyConstructed.constMethod();
 }
 
 void PositiveMethodCallConstPointerParam(const ExpensiveToCopyType *const Obj) {
   const auto AutoAssigned = Obj->reference();
   // CHECK-MESSAGES: [[@LINE-1]]:14: warning: the const qualified variable 'AutoAssigned'
   // CHECK-FIXES: const auto& AutoAssigned = Obj->reference();
+  AutoAssigned.constMethod();
+
   const auto AutoCopyConstructed(Obj->reference());
   // CHECK-MESSAGES: [[@LINE-1]]:14: warning: the const qualified variable 'AutoCopyConstructed'
   // CHECK-FIXES: const auto& AutoCopyConstructed(Obj->reference());
+  AutoCopyConstructed.constMethod();

[PATCH] D77598: Integral template argument suffix and cast printing

2021-05-10 Thread Pratyush Das via Phabricator via cfe-commits
reikdas updated this revision to Diff 344161.
reikdas added a comment.

Fix failing test on windows triple and do some code cleanup.


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

https://reviews.llvm.org/D77598

Files:
  clang-tools-extra/clangd/Hover.cpp
  clang/include/clang/AST/DeclTemplate.h
  clang/include/clang/AST/Expr.h
  clang/include/clang/AST/StmtDataCollectors.td
  clang/include/clang/AST/TemplateBase.h
  clang/lib/AST/ASTTypeTraits.cpp
  clang/lib/AST/DeclPrinter.cpp
  clang/lib/AST/DeclTemplate.cpp
  clang/lib/AST/Expr.cpp
  clang/lib/AST/NestedNameSpecifier.cpp
  clang/lib/AST/StmtPrinter.cpp
  clang/lib/AST/TemplateBase.cpp
  clang/lib/AST/TypePrinter.cpp
  clang/lib/Analysis/PathDiagnostic.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/lib/Sema/SemaTemplateInstantiate.cpp
  clang/test/Analysis/eval-predefined-exprs.cpp
  clang/test/CXX/lex/lex.literal/lex.ext/p12.cpp
  clang/test/CXX/lex/lex.literal/lex.ext/p13.cpp
  clang/test/CXX/lex/lex.literal/lex.ext/p14.cpp
  clang/test/CodeGenCXX/debug-info-codeview-template-literal.cpp
  clang/test/CodeGenCXX/debug-info-codeview-template-type.cpp
  clang/test/SemaCXX/builtin-align-cxx.cpp
  clang/test/SemaCXX/cxx11-ast-print.cpp
  clang/test/SemaCXX/cxx1z-ast-print.cpp
  clang/test/SemaCXX/matrix-type-builtins.cpp
  clang/test/SemaCXX/matrix-type-operators.cpp
  clang/test/SemaTemplate/address_space-dependent.cpp
  clang/test/SemaTemplate/default-arguments-ast-print.cpp
  clang/test/SemaTemplate/delegating-constructors.cpp
  clang/test/SemaTemplate/matrix-type.cpp
  clang/test/SemaTemplate/temp_arg_enum_printing.cpp
  clang/test/SemaTemplate/temp_arg_nontype.cpp
  clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp
  clang/tools/libclang/CIndex.cpp
  
clang/unittests/Tooling/RecursiveASTVisitorTests/TemplateArgumentLocTraverser.cpp

Index: clang/unittests/Tooling/RecursiveASTVisitorTests/TemplateArgumentLocTraverser.cpp
===
--- clang/unittests/Tooling/RecursiveASTVisitorTests/TemplateArgumentLocTraverser.cpp
+++ clang/unittests/Tooling/RecursiveASTVisitorTests/TemplateArgumentLocTraverser.cpp
@@ -20,7 +20,7 @@
 llvm::raw_string_ostream Stream(ArgStr);
 const TemplateArgument &Arg = ArgLoc.getArgument();
 
-Arg.print(Context->getPrintingPolicy(), Stream);
+Arg.print(Context->getPrintingPolicy(), Stream, /*IncludeType*/ true);
 Match(Stream.str(), ArgLoc.getLocation());
 return ExpectedLocationVisitor::
   TraverseTemplateArgumentLoc(ArgLoc);
Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -5185,8 +5185,9 @@
 SmallString<128> Str;
 llvm::raw_svector_ostream OS(Str);
 OS << *ClassSpec;
-printTemplateArgumentList(OS, ClassSpec->getTemplateArgs().asArray(),
-  Policy);
+printTemplateArgumentList(
+OS, ClassSpec->getTemplateArgs().asArray(), Policy,
+ClassSpec->getSpecializedTemplate()->getTemplateParameters());
 return cxstring::createDup(OS.str());
   }
 
Index: clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp
===
--- clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp
+++ clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp
@@ -528,3 +528,33 @@
 x1.f(x2);
   }
 }
+
+namespace TypeSuffix {
+  template  struct A {};
+  template <> struct A<1> { using type = int; }; // expected-note {{'A<1>::type' declared here}}
+  A<1L>::type a; // expected-error {{no type named 'type' in 'TypeSuffix::A<1L>'; did you mean 'A<1>::type'?}}
+
+  template  struct B {};
+  template <> struct B<1> { using type = int; }; // expected-note {{'B<1>::type' declared here}}
+  B<2>::type b;  // expected-error {{no type named 'type' in 'TypeSuffix::B<2>'; did you mean 'B<1>::type'?}}
+
+  template  struct C {};
+  template <> struct C<'a'> { using type = signed char; }; // expected-note {{'C<'a'>::type' declared here}}
+  C<(signed char)'a'>::type c; // expected-error {{no type named 'type' in 'TypeSuffix::C<(signed char)'a'>'; did you mean 'C<'a'>::type'?}}
+
+  template  struct D {};
+  template <> struct D<'a'> { using type = signed char; }; // expected-note {{'D<'a'>::type' declared here}}
+  D<'b'>::type d;  // expected-error {{no type named 'type' in 'TypeSuffix::D<'b'>'; did you mean 'D<'a'>::type'?}}
+
+  template  struct E {};
+  template <> struct E<'a'> { using type = unsigned char; }; // expected-note {{'E<'a'>::type' declared here}}
+  E<(unsigned char)'a'>::type e; // expected-error {{no type named 'type' in 'TypeSuffix::E<(unsigned char)'a'>'; did you mean 'E<'a'

[PATCH] D102191: [PowerPC] Add clang option -m[no-]prefixed

2021-05-10 Thread Lei Huang via Phabricator via cfe-commits
lei created this revision.
lei added reviewers: stefanp, nemanjai, power-llvm-team.
Herald added subscribers: dang, shchenz.
lei requested review of this revision.
Herald added a project: clang.

Add user-facing front end option to turn off power10 prefixed instructions.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D102191

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Basic/Targets/PPC.cpp
  clang/lib/Basic/Targets/PPC.h
  clang/test/Driver/ppc-prefixed.cpp


Index: clang/test/Driver/ppc-prefixed.cpp
===
--- /dev/null
+++ clang/test/Driver/ppc-prefixed.cpp
@@ -0,0 +1,12 @@
+// RUN: %clang -target powerpc64-unknown-linux-gnu %s -### -mcpu=pwr10 
-mprefixed -o %t.o 2>&1 | FileCheck -check-prefix=CHECK-PREFIXED %s
+// RUN: %clang -target powerpc64-unknown-linux-gnu %s -### -mcpu=pwr10 
-mno-prefixed -o %t.o 2>&1 | FileCheck -check-prefix=CHECK-NOPREFIXED %s
+// CHECK-NOPREFIXED: "-target-feature" "-prefixed"
+// CHECK-PREFIXED: "-target-feature" "+prefixed"
+
+// RUN: %clang -target powerpc64-unknown-linux-gnu -mcpu=pwr10 -emit-llvm -S 
%s -o - | grep "attributes.*+prefix-instrs"
+// RUN: %clang -target powerpc64-unknown-linux-gnu -mcpu=pwr10 -mprefixed 
-emit-llvm -S %s -o - | grep "attributes.*+prefix-instrs"
+// RUN: %clang -target powerpc64-unknown-linux-gnu -mcpu=pwr10 -mno-prefixed 
-emit-llvm -S %s -o - | grep "attributes.*\-prefix-instrs"
+
+int main(int argc, char *argv[]) {
+  return 0;
+}
Index: clang/lib/Basic/Targets/PPC.h
===
--- clang/lib/Basic/Targets/PPC.h
+++ clang/lib/Basic/Targets/PPC.h
@@ -73,6 +73,7 @@
   bool PairedVectorMemops = false;
   bool HasP10Vector = false;
   bool HasPCRelativeMemops = false;
+  bool HasPrefixInstrs = false;
 
 protected:
   std::string ABI;
Index: clang/lib/Basic/Targets/PPC.cpp
===
--- clang/lib/Basic/Targets/PPC.cpp
+++ clang/lib/Basic/Targets/PPC.cpp
@@ -56,6 +56,8 @@
   HasP10Vector = true;
 } else if (Feature == "+pcrelative-memops") {
   HasPCRelativeMemops = true;
+} else if (Feature == "+prefix-instrs") {
+  HasPrefixInstrs = true;
 } else if (Feature == "+spe" || Feature == "+efpu2") {
   HasSPE = true;
   LongDoubleWidth = LongDoubleAlign = 64;
@@ -394,6 +396,7 @@
   Features["mma"] = true;
   Features["power10-vector"] = true;
   Features["pcrelative-memops"] = true;
+  Features["prefix-instrs"] = true;
   return;
 }
 
@@ -419,6 +422,7 @@
   .Case("paired-vector-memops", PairedVectorMemops)
   .Case("power10-vector", HasP10Vector)
   .Case("pcrelative-memops", HasPCRelativeMemops)
+  .Case("prefix-instrs", HasPrefixInstrs)
   .Case("spe", HasSPE)
   .Case("mma", HasMMA)
   .Case("rop-protect", HasROPProtect)
@@ -451,6 +455,8 @@
   Features["power8-vector"] = Features["power9-vector"] = true;
 if (Name == "pcrel")
   Features["pcrelative-memops"] = true;
+else if (Name == "prefixed")
+  Features["prefix-instrs"] = true;
 else
   Features[Name] = true;
   } else {
@@ -471,6 +477,8 @@
   Features["power10-vector"] = false;
 if (Name == "pcrel")
   Features["pcrelative-memops"] = false;
+else if (Name == "prefixed")
+  Features["prefix-instrs"] = false;
 else
   Features[Name] = false;
   }
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -3254,6 +3254,8 @@
 def mno_altivec : Flag<["-"], "mno-altivec">, Group;
 def mpcrel: Flag<["-"], "mpcrel">, Group;
 def mno_pcrel: Flag<["-"], "mno-pcrel">, Group;
+def mprefixed: Flag<["-"], "mprefixed">, Group;
+def mno_prefixed: Flag<["-"], "mno-prefixed">, Group;
 def mspe : Flag<["-"], "mspe">, Group;
 def mno_spe : Flag<["-"], "mno-spe">, Group;
 def mefpu2 : Flag<["-"], "mefpu2">, Group;


Index: clang/test/Driver/ppc-prefixed.cpp
===
--- /dev/null
+++ clang/test/Driver/ppc-prefixed.cpp
@@ -0,0 +1,12 @@
+// RUN: %clang -target powerpc64-unknown-linux-gnu %s -### -mcpu=pwr10 -mprefixed -o %t.o 2>&1 | FileCheck -check-prefix=CHECK-PREFIXED %s
+// RUN: %clang -target powerpc64-unknown-linux-gnu %s -### -mcpu=pwr10 -mno-prefixed -o %t.o 2>&1 | FileCheck -check-prefix=CHECK-NOPREFIXED %s
+// CHECK-NOPREFIXED: "-target-feature" "-prefixed"
+// CHECK-PREFIXED: "-target-feature" "+prefixed"
+
+// RUN: %clang -target powerpc64-unknown-linux-gnu -mcpu=pwr10 -emit-llvm -S %s -o - | grep "attributes.*+prefix-instrs"
+// RUN: %clang -target powerpc64-unknown-linux-gnu -mcpu=pwr10 -mprefixed -emit-llvm -S %s -o - | grep "attributes.*+prefix-instrs"
+// RUN: %clang -target powerpc64-unknown-linux-gnu -mcpu=pwr10 -mno-prefixed -emit-llvm -S %s -o - | grep "attributes.*\-pref

[PATCH] D100630: [Debug-Info][DBX] DW_TAG_rvalue_reference_type should not be generated when dwarf version is smaller than 4

2021-05-10 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

Does this cause duplicate DW_TAG_reference_types in the output, if the input IR 
Has both DW_TAG_reference_type and DW_TAG_rvalue_reference_types?




Comment at: llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp:391
+  // version.
+  dwarf::Tag FixedTag = (dwarf::Tag)Tag;
+  if (Asm->TM.Options.DebugStrictDwarf &&

Rather than adding a cast here, perhaps the parameter type could be updated? 
(maybe in a separate preliminary commit, though, so as not to muddy this one)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100630

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


[PATCH] D98799: [UniqueLinkageName] Use consistent checks when mangling symbo linkage name and debug linkage name.

2021-05-10 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added inline comments.



Comment at: clang/test/CodeGen/unique-internal-linkage-names-dwarf.c:34-39
+static int go(a) int a;
+{
+  return glob + a;
+}
+
+

aaron.ballman wrote:
> dblaikie wrote:
> > hoy wrote:
> > > dblaikie wrote:
> > > > dblaikie wrote:
> > > > > hoy wrote:
> > > > > > dblaikie wrote:
> > > > > > > hoy wrote:
> > > > > > > > dblaikie wrote:
> > > > > > > > > hoy wrote:
> > > > > > > > > > dblaikie wrote:
> > > > > > > > > > > hoy wrote:
> > > > > > > > > > > > dblaikie wrote:
> > > > > > > > > > > > > hoy wrote:
> > > > > > > > > > > > > > dblaikie wrote:
> > > > > > > > > > > > > > > hoy wrote:
> > > > > > > > > > > > > > > > dblaikie wrote:
> > > > > > > > > > > > > > > > > Does this need to be down here? Or would the 
> > > > > > > > > > > > > > > > > code be a well exercised if it was up next to 
> > > > > > > > > > > > > > > > > the go declaration above?
> > > > > > > > > > > > > > > > Yes, it needs to be here. Otherwise it will 
> > > > > > > > > > > > > > > > just like the function `bar` above that doesn't 
> > > > > > > > > > > > > > > > get a uniquefied name. I think moving the 
> > > > > > > > > > > > > > > > definition up to right after the declaration 
> > > > > > > > > > > > > > > > hides the declaration.
> > > > > > > > > > > > > > > Not sure I follow - do you mean that if the go 
> > > > > > > > > > > > > > > declaration and go definition were next to each 
> > > > > > > > > > > > > > > other, this test would (mechanically speaking) 
> > > > > > > > > > > > > > > not validate what the patch? Or that it would be 
> > > > > > > > > > > > > > > less legible, but still mechanically correct?
> > > > > > > > > > > > > > > 
> > > > > > > > > > > > > > > I think it would be (assuming it's still 
> > > > > > > > > > > > > > > mechanically correct) more legible to put the 
> > > > > > > > > > > > > > > declaration next to the definition - the comment 
> > > > > > > > > > > > > > > describes why the declaration is significant/why 
> > > > > > > > > > > > > > > the definition is weird, and seeing all that 
> > > > > > > > > > > > > > > together would be clearer to me than spreading it 
> > > > > > > > > > > > > > > out/having to look further away to see what's 
> > > > > > > > > > > > > > > going on.
> > > > > > > > > > > > > > When the `go` declaration and `go` definition were 
> > > > > > > > > > > > > > next to each other, the go function won't get a 
> > > > > > > > > > > > > > uniqufied name at all. The declaration will be 
> > > > > > > > > > > > > > overwritten by the definition. Only when the 
> > > > > > > > > > > > > > declaration is seen by others, such the callsite in 
> > > > > > > > > > > > > > `baz`, the declaration makes a difference by having 
> > > > > > > > > > > > > > the callsite use a uniqufied name.
> > > > > > > > > > > > > > 
> > > > > > > > > > > > > > 
> > > > > > > > > > > > > Ah! Interesting, good to know. 
> > > > > > > > > > > > > 
> > > > > > > > > > > > > Is that worth supporting, I wonder? I guess it falls 
> > > > > > > > > > > > > out for free/without significant additional 
> > > > > > > > > > > > > complexity. I worry about the subtlety of the 
> > > > > > > > > > > > > additional declaration changing the behavior here... 
> > > > > > > > > > > > > might be a bit surprising/subtle. But maybe no nice 
> > > > > > > > > > > > > way to avoid it either.
> > > > > > > > > > > > It would be ideal if user never writes code like that. 
> > > > > > > > > > > > Unfortunately it exists with legacy code (such as 
> > > > > > > > > > > > mysql). I think it's worth supporting it from AutoFDO 
> > > > > > > > > > > > point of view to avoid a silent mismatch between debug 
> > > > > > > > > > > > linkage name and real linkage name.
> > > > > > > > > > > Oh, I agree that we shouldn't mismatch debug info and the 
> > > > > > > > > > > actual symbol name - what I meant was whether code like 
> > > > > > > > > > > this should get mangled or not when using 
> > > > > > > > > > > unique-internal-linkage names.
> > > > > > > > > > > 
> > > > > > > > > > > I'm now more curious about this:
> > > > > > > > > > > 
> > > > > > > > > > > > When the `go` declaration and `go` definition were next 
> > > > > > > > > > > > to each other, the go function won't get a uniqufied 
> > > > > > > > > > > > name at all.
> > > > > > > > > > > 
> > > > > > > > > > > This doesn't seem to happen with the 
> > > > > > > > > > > `__attribute__((overloadable))` attribute, for instance - 
> > > > > > > > > > > so any idea what's different about uniquification that's 
> > > > > > > > > > > working differently than overloadable?
> > > > > > > > > > > 
> > > > > > > > > > > ```
> > > > > > > > > > > $ cat test.c
> > > > > > > > > > > __attribute__((overloadable)) static int go(a) int a; {
> > > > > > > > > > >   return 3 + a;
> > > > > > > > > > > }
> > > > > > > > > > > void baz() {
> > > > > > > > > > >   go(2);
> > > > > > > > > > > }
> > > > > > > > > >

[PATCH] D99409: [clang] Speedup line offset mapping computation

2021-05-10 Thread Paul Robinson via Phabricator via cfe-commits
probinson added inline comments.



Comment at: clang/lib/Basic/SourceManager.cpp:1255
 
-#ifdef __SSE2__
-#include 
-#endif
+// Check if mutli-byte word x has bytes between m and n, included. This may 
also
+// catch bytes equal to n + 1.

Typo: multi-byte.  Also, I think "inclusive" rather than "included" assuming 
you mean the range `[m, n]` rather than `(m, n)`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99409

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


[PATCH] D102015: [clang CodeGen] Don't crash on large atomic function parameter.

2021-05-10 Thread Eli Friedman via Phabricator via cfe-commits
efriedma updated this revision to Diff 344193.
efriedma added a comment.

Use isRecordType() instead of checking for an atomic type.  Fix the caller side 
as well.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102015

Files:
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CGDecl.cpp
  clang/test/CodeGen/big-atomic-ops.c


Index: clang/test/CodeGen/big-atomic-ops.c
===
--- clang/test/CodeGen/big-atomic-ops.c
+++ clang/test/CodeGen/big-atomic-ops.c
@@ -311,4 +311,10 @@
   // CHECK: }
 }
 
+// Check this doesn't crash
+// CHECK: @test_atomic_array_param(
+void test_atomic_array_param(_Atomic(struct foo) a) {
+  test_atomic_array_param(a);
+}
+
 #endif
Index: clang/lib/CodeGen/CGDecl.cpp
===
--- clang/lib/CodeGen/CGDecl.cpp
+++ clang/lib/CodeGen/CGDecl.cpp
@@ -2473,7 +2473,7 @@
 // Push a destructor cleanup for this parameter if the ABI requires it.
 // Don't push a cleanup in a thunk for a method that will also emit a
 // cleanup.
-if (hasAggregateEvaluationKind(Ty) && !CurFuncIsThunk &&
+if (Ty->isRecordType() && !CurFuncIsThunk &&
 Ty->castAs()->getDecl()->isParamDestroyedInCallee()) {
   if (QualType::DestructionKind DtorKind =
   D.needsDestruction(getContext())) {
Index: clang/lib/CodeGen/CGCall.cpp
===
--- clang/lib/CodeGen/CGCall.cpp
+++ clang/lib/CodeGen/CGCall.cpp
@@ -3698,7 +3698,7 @@
   }
 
   // Deactivate the cleanup for the callee-destructed param that was pushed.
-  if (hasAggregateEvaluationKind(type) && !CurFuncIsThunk &&
+  if (type->isRecordType() && !CurFuncIsThunk &&
   type->castAs()->getDecl()->isParamDestroyedInCallee() &&
   param->needsDestruction(getContext())) {
 EHScopeStack::stable_iterator cleanup =
@@ -4269,7 +4269,7 @@
   // In the Microsoft C++ ABI, aggregate arguments are destructed by the 
callee.
   // However, we still have to push an EH-only cleanup in case we unwind before
   // we make it to the call.
-  if (HasAggregateEvalKind &&
+  if (type->isRecordType() &&
   type->castAs()->getDecl()->isParamDestroyedInCallee()) {
 // If we're using inalloca, use the argument memory.  Otherwise, use a
 // temporary.


Index: clang/test/CodeGen/big-atomic-ops.c
===
--- clang/test/CodeGen/big-atomic-ops.c
+++ clang/test/CodeGen/big-atomic-ops.c
@@ -311,4 +311,10 @@
   // CHECK: }
 }
 
+// Check this doesn't crash
+// CHECK: @test_atomic_array_param(
+void test_atomic_array_param(_Atomic(struct foo) a) {
+  test_atomic_array_param(a);
+}
+
 #endif
Index: clang/lib/CodeGen/CGDecl.cpp
===
--- clang/lib/CodeGen/CGDecl.cpp
+++ clang/lib/CodeGen/CGDecl.cpp
@@ -2473,7 +2473,7 @@
 // Push a destructor cleanup for this parameter if the ABI requires it.
 // Don't push a cleanup in a thunk for a method that will also emit a
 // cleanup.
-if (hasAggregateEvaluationKind(Ty) && !CurFuncIsThunk &&
+if (Ty->isRecordType() && !CurFuncIsThunk &&
 Ty->castAs()->getDecl()->isParamDestroyedInCallee()) {
   if (QualType::DestructionKind DtorKind =
   D.needsDestruction(getContext())) {
Index: clang/lib/CodeGen/CGCall.cpp
===
--- clang/lib/CodeGen/CGCall.cpp
+++ clang/lib/CodeGen/CGCall.cpp
@@ -3698,7 +3698,7 @@
   }
 
   // Deactivate the cleanup for the callee-destructed param that was pushed.
-  if (hasAggregateEvaluationKind(type) && !CurFuncIsThunk &&
+  if (type->isRecordType() && !CurFuncIsThunk &&
   type->castAs()->getDecl()->isParamDestroyedInCallee() &&
   param->needsDestruction(getContext())) {
 EHScopeStack::stable_iterator cleanup =
@@ -4269,7 +4269,7 @@
   // In the Microsoft C++ ABI, aggregate arguments are destructed by the callee.
   // However, we still have to push an EH-only cleanup in case we unwind before
   // we make it to the call.
-  if (HasAggregateEvalKind &&
+  if (type->isRecordType() &&
   type->castAs()->getDecl()->isParamDestroyedInCallee()) {
 // If we're using inalloca, use the argument memory.  Otherwise, use a
 // temporary.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D102196: [NewPM] Add options to PrintPassInstrumentation

2021-05-10 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks created this revision.
Herald added subscribers: nikic, hiraditya.
aeubanks requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added subscribers: llvm-commits, cfe-commits, sstefan1.
Herald added projects: clang, LLVM.

To bring D99599 's implementation in line with 
the existing
PrintPassInstrumentation, and to fix a FIXME, add more customizability
to PrintPassInstrumentation.

Introduce three new options. The first takes over the existing
"-debug-pass-manager-verbose" cl::opt.

The second and third option are specific to -fdebug-pass-structure. They
allow indentation, and also don't print analysis queries.

To avoid more golden file tests than necessary, prune down the
-fdebug-pass-structure tests.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D102196

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  clang/test/Driver/debug-pass-structure.c
  llvm/include/llvm/Passes/StandardInstrumentations.h
  llvm/lib/Passes/StandardInstrumentations.cpp
  llvm/test/Other/new-pass-manager-cgscc-fct-proxy.ll
  llvm/test/Other/opt-O3-pipeline.ll
  llvm/test/Other/pass-pipeline-parsing.ll
  llvm/tools/opt/NewPMDriver.cpp

Index: llvm/tools/opt/NewPMDriver.cpp
===
--- llvm/tools/opt/NewPMDriver.cpp
+++ llvm/tools/opt/NewPMDriver.cpp
@@ -52,9 +52,17 @@
cl::value_desc("filename"));
 } // namespace llvm
 
-static cl::opt
-DebugPM("debug-pass-manager", cl::Hidden,
-cl::desc("Print pass management debugging information"));
+enum class DebugLogging { None, Normal, Verbose };
+
+static cl::opt DebugPM(
+"debug-pass-manager", cl::Hidden, cl::ValueOptional,
+cl::desc("Print pass management debugging information"),
+cl::init(DebugLogging::None),
+cl::values(
+clEnumValN(DebugLogging::Normal, "", ""),
+clEnumValN(
+DebugLogging::Verbose, "verbose",
+"Print extra information about adaptors and pass managers")));
 
 static cl::list
 PassPlugins("load-pass-plugin",
@@ -283,7 +291,10 @@
   ModuleAnalysisManager MAM;
 
   PassInstrumentationCallbacks PIC;
-  StandardInstrumentations SI(DebugPM, VerifyEachPass);
+  PrintPassOptions PrintPassOpts;
+  PrintPassOpts.Verbose = DebugPM == DebugLogging::Verbose;
+  StandardInstrumentations SI(DebugPM != DebugLogging::None, VerifyEachPass,
+  PrintPassOpts);
   SI.registerCallbacks(PIC, &FAM);
   DebugifyEachInstrumentation Debugify;
   if (DebugifyEach)
Index: llvm/test/Other/pass-pipeline-parsing.ll
===
--- llvm/test/Other/pass-pipeline-parsing.ll
+++ llvm/test/Other/pass-pipeline-parsing.ll
@@ -142,7 +142,7 @@
 ; RUN: | FileCheck %s --check-prefix=CHECK-NESTED-FP-LP
 ; CHECK-NESTED-FP-LP: Running pass: NoOpLoopPass
 
-; RUN: opt -disable-output -debug-pass-manager -debug-pass-manager-verbose \
+; RUN: opt -disable-output -debug-pass-manager=verbose \
 ; RUN: -passes='module(no-op-function,no-op-loop,no-op-cgscc,cgscc(no-op-function,no-op-loop),function(no-op-loop))' %s 2>&1 \
 ; RUN: | FileCheck %s --check-prefix=CHECK-ADAPTORS
 ; CHECK-ADAPTORS: Running pass: ModuleToFunctionPassAdaptor
@@ -167,7 +167,7 @@
 ; RUN: opt -disable-output -debug-pass-manager \
 ; RUN: -passes='module(function(no-op-function,loop(no-op-loop,no-op-loop)))' %s 2>&1 \
 ; RUN: | FileCheck %s --check-prefix=CHECK-MANAGERS-NO-VERBOSE
-; RUN: opt -disable-output -debug-pass-manager -debug-pass-manager-verbose \
+; RUN: opt -disable-output -debug-pass-manager=verbose \
 ; RUN: -passes='module(function(no-op-function,loop(no-op-loop,no-op-loop)))' %s 2>&1 \
 ; RUN: | FileCheck %s --check-prefix=CHECK-MANAGERS
 ; CHECK-MANAGERS: Running pass: PassManager{{.*}}Function
Index: llvm/test/Other/opt-O3-pipeline.ll
===
--- llvm/test/Other/opt-O3-pipeline.ll
+++ llvm/test/Other/opt-O3-pipeline.ll
@@ -1,5 +1,4 @@
 ; RUN: opt -enable-new-pm=0 -mtriple=x86_64-- -O3 -debug-pass=Structure < %s -o /dev/null 2>&1 | FileCheck --check-prefixes=CHECK,%llvmcheckext %s
-; RUN: opt -enable-new-pm=1 -mtriple=x86_64-- -O3 -debug-pass-structure < %s -o /dev/null 2>&1 | FileCheck --check-prefixes=NEWPM,%llvmcheckext %s
 
 ; REQUIRES: asserts
 
@@ -336,169 +335,6 @@
 ; CHECK-NEXT: Branch Probability Analysis
 ; CHECK-NEXT: Block Frequency Analysis
 
-; NEWPM:  VerifierPass on [module]
-; NEWPM-NEXT:   VerifierAnalysis analysis on [module]
-; NEWPM-NEXT: Annotation2MetadataPass on [module]
-; NEWPM-NEXT: ForceFunctionAttrsPass on [module]
-; NEWPM-NEXT: InferFunctionAttrsPass on [module]
-; NEWPM-NEXT:   InnerAnalysisManagerProxy<{{.*}}> analysis on [module]
-; NEWPM-NEXT: ModuleToFunctionPassAdaptor on [module]
-; NEWPM-NEXT:   PassManager<{{.*}}> on f
-; NEWPM-NEXT: PreservedCFGCheckerAnalysis analysis on f
-; N

[clang-tools-extra] 43f4331 - [clang-tidy] Aliasing: Add support for captures.

2021-05-10 Thread Artem Dergachev via cfe-commits

Author: Artem Dergachev
Date: 2021-05-10T14:00:30-07:00
New Revision: 43f4331edfb595979f6854351d24f9a9219595fa

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

LOG: [clang-tidy] Aliasing: Add support for captures.

The utility function clang::tidy::utils::hasPtrOrReferenceInFunc() scans the
function for pointer/reference aliases to a given variable. It currently scans
for operator & over that variable and for declarations of references to that
variable.

This patch makes it also scan for C++ lambda captures by reference
and for Objective-C block captures.

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

Added: 


Modified: 
clang-tools-extra/clang-tidy/utils/Aliasing.cpp
clang-tools-extra/test/clang-tidy/checkers/bugprone-infinite-loop.cpp

clang-tools-extra/test/clang-tidy/checkers/bugprone-redundant-branch-condition.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/utils/Aliasing.cpp 
b/clang-tools-extra/clang-tidy/utils/Aliasing.cpp
index 3a88126a9ee6a..f9eb147ce6720 100644
--- a/clang-tools-extra/clang-tidy/utils/Aliasing.cpp
+++ b/clang-tools-extra/clang-tidy/utils/Aliasing.cpp
@@ -9,6 +9,7 @@
 #include "Aliasing.h"
 
 #include "clang/AST/Expr.h"
+#include "clang/AST/ExprCXX.h"
 
 namespace clang {
 namespace tidy {
@@ -24,6 +25,10 @@ static bool isAccessForVar(const Stmt *S, const VarDecl 
*Var) {
 
 /// Return whether \p Var has a pointer or reference in \p S.
 static bool isPtrOrReferenceForVar(const Stmt *S, const VarDecl *Var) {
+  // Treat block capture by reference as a form of taking a reference.
+  if (Var->isEscapingByref())
+return true;
+
   if (const auto *DS = dyn_cast(S)) {
 for (const Decl *D : DS->getDeclGroup()) {
   if (const auto *LeftVar = dyn_cast(D)) {
@@ -35,6 +40,12 @@ static bool isPtrOrReferenceForVar(const Stmt *S, const 
VarDecl *Var) {
   } else if (const auto *UnOp = dyn_cast(S)) {
 if (UnOp->getOpcode() == UO_AddrOf)
   return isAccessForVar(UnOp->getSubExpr(), Var);
+  } else if (const auto *LE = dyn_cast(S)) {
+// Treat lambda capture by reference as a form of taking a reference.
+return llvm::any_of(LE->captures(), [Var](const LambdaCapture &C) {
+  return C.capturesVariable() && C.getCaptureKind() == LCK_ByRef &&
+ C.getCapturedVar() == Var;
+});
   }
 
   return false;

diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/bugprone-infinite-loop.cpp 
b/clang-tools-extra/test/clang-tidy/checkers/bugprone-infinite-loop.cpp
index 0b1baf04fee2f..d6cb954a3beb6 100644
--- a/clang-tools-extra/test/clang-tidy/checkers/bugprone-infinite-loop.cpp
+++ b/clang-tools-extra/test/clang-tidy/checkers/bugprone-infinite-loop.cpp
@@ -1,4 +1,5 @@
-// RUN: %check_clang_tidy %s bugprone-infinite-loop %t -- -- -fexceptions
+// RUN: %check_clang_tidy %s bugprone-infinite-loop %t \
+// RUN:   -- -- -fexceptions -fblocks
 
 void simple_infinite_loop1() {
   int i = 0;
@@ -378,6 +379,84 @@ void lambda_capture() {
   } while (i < Limit);
 }
 
+template  void accept_callback(T t) {
+  // Potentially call the callback.
+  // Possibly on a background thread or something.
+}
+
+void accept_block(void (^)(void)) {
+  // Potentially call the callback.
+  // Possibly on a background thread or something.
+}
+
+void wait(void) {
+  // Wait for the previously passed callback to be called.
+}
+
+void lambda_capture_from_outside() {
+  bool finished = false;
+  accept_callback([&]() {
+finished = true;
+  });
+  while (!finished) {
+wait();
+  }
+}
+
+void lambda_capture_from_outside_by_value() {
+  bool finished = false;
+  accept_callback([finished]() {
+if (finished) {}
+  });
+  while (!finished) {
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: this loop is infinite; none of 
its condition variables (finished) are updated in the loop body 
[bugprone-infinite-loop]
+wait();
+  }
+}
+
+void lambda_capture_from_outside_but_unchanged() {
+  bool finished = false;
+  accept_callback([&finished]() {
+if (finished) {}
+  });
+  while (!finished) {
+// FIXME: Should warn.
+wait();
+  }
+}
+
+void block_capture_from_outside() {
+  __block bool finished = false;
+  accept_block(^{
+finished = true;
+  });
+  while (!finished) {
+wait();
+  }
+}
+
+void block_capture_from_outside_by_value() {
+  bool finished = false;
+  accept_block(^{
+if (finished) {}
+  });
+  while (!finished) {
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: this loop is infinite; none of 
its condition variables (finished) are updated in the loop body 
[bugprone-infinite-loop]
+wait();
+  }
+}
+
+void block_capture_from_outside_but_unchanged() {
+  __block bool finished = false;
+  accept_block(^{
+if (finished) {}
+  });
+  while (!finished) {
+// FIXME: Shou

[clang-tools-extra] 9b292e0 - [clang-tidy] Aliasing: Add more support for captures.

2021-05-10 Thread Artem Dergachev via cfe-commits

Author: Artem Dergachev
Date: 2021-05-10T14:00:30-07:00
New Revision: 9b292e0edcd4e889dbcf4bbaad6c1cc80fffcfd1

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

LOG: [clang-tidy] Aliasing: Add more support for captures.

D96215 takes care of the situation where the variable is captured into
a nearby lambda. This patch takes care of the situation where
the current function is the lambda and the variable is one of its captures
from an enclosing scope.

The analogous problem for ^{blocks} is already handled automagically
by D96215.

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

Added: 


Modified: 
clang-tools-extra/clang-tidy/utils/Aliasing.cpp
clang-tools-extra/test/clang-tidy/checkers/bugprone-infinite-loop.cpp

clang-tools-extra/test/clang-tidy/checkers/bugprone-redundant-branch-condition.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/utils/Aliasing.cpp 
b/clang-tools-extra/clang-tidy/utils/Aliasing.cpp
index f9eb147ce6720..12a8ca8185b0f 100644
--- a/clang-tools-extra/clang-tidy/utils/Aliasing.cpp
+++ b/clang-tools-extra/clang-tidy/utils/Aliasing.cpp
@@ -23,6 +23,13 @@ static bool isAccessForVar(const Stmt *S, const VarDecl 
*Var) {
   return false;
 }
 
+static bool capturesByRef(const CXXRecordDecl *RD, const VarDecl *Var) {
+  return llvm::any_of(RD->captures(), [Var](const LambdaCapture &C) {
+return C.capturesVariable() && C.getCaptureKind() == LCK_ByRef &&
+   C.getCapturedVar() == Var;
+  });
+}
+
 /// Return whether \p Var has a pointer or reference in \p S.
 static bool isPtrOrReferenceForVar(const Stmt *S, const VarDecl *Var) {
   // Treat block capture by reference as a form of taking a reference.
@@ -42,10 +49,7 @@ static bool isPtrOrReferenceForVar(const Stmt *S, const 
VarDecl *Var) {
   return isAccessForVar(UnOp->getSubExpr(), Var);
   } else if (const auto *LE = dyn_cast(S)) {
 // Treat lambda capture by reference as a form of taking a reference.
-return llvm::any_of(LE->captures(), [Var](const LambdaCapture &C) {
-  return C.capturesVariable() && C.getCaptureKind() == LCK_ByRef &&
- C.getCapturedVar() == Var;
-});
+return capturesByRef(LE->getLambdaClass(), Var);
   }
 
   return false;
@@ -67,8 +71,22 @@ static bool hasPtrOrReferenceInStmt(const Stmt *S, const 
VarDecl *Var) {
   return false;
 }
 
+static bool refersToEnclosingLambdaCaptureByRef(const FunctionDecl *Func,
+const VarDecl *Var) {
+  const auto *MD = dyn_cast(Func);
+  if (!MD)
+return false;
+
+  const CXXRecordDecl *RD = MD->getParent();
+  if (!RD->isLambda())
+return false;
+
+  return capturesByRef(RD, Var);
+}
+
 bool hasPtrOrReferenceInFunc(const FunctionDecl *Func, const VarDecl *Var) {
-  return hasPtrOrReferenceInStmt(Func->getBody(), Var);
+  return hasPtrOrReferenceInStmt(Func->getBody(), Var) ||
+ refersToEnclosingLambdaCaptureByRef(Func, Var);
 }
 
 } // namespace utils

diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/bugprone-infinite-loop.cpp 
b/clang-tools-extra/test/clang-tidy/checkers/bugprone-infinite-loop.cpp
index d6cb954a3beb6..5b477130a7b01 100644
--- a/clang-tools-extra/test/clang-tidy/checkers/bugprone-infinite-loop.cpp
+++ b/clang-tools-extra/test/clang-tidy/checkers/bugprone-infinite-loop.cpp
@@ -457,6 +457,92 @@ void block_capture_from_outside_but_unchanged() {
   }
 }
 
+void finish_at_any_time(bool *finished);
+
+void lambda_capture_with_loop_inside_lambda_bad() {
+  bool finished = false;
+  auto lambda = [=]() {
+while (!finished) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: this loop is infinite; none 
of its condition variables (finished) are updated in the loop body 
[bugprone-infinite-loop]
+  wait();
+}
+  };
+  finish_at_any_time(&finished);
+  lambda();
+}
+
+void lambda_capture_with_loop_inside_lambda_bad_init_capture() {
+  bool finished = false;
+  auto lambda = [captured_finished=finished]() {
+while (!captured_finished) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: this loop is infinite; none 
of its condition variables (captured_finished) are updated in the loop body 
[bugprone-infinite-loop]
+  wait();
+}
+  };
+  finish_at_any_time(&finished);
+  lambda();
+}
+
+void lambda_capture_with_loop_inside_lambda_good() {
+  bool finished = false;
+  auto lambda = [&]() {
+while (!finished) {
+  wait(); // No warning: the variable may be updated
+  // from outside the lambda.
+}
+  };
+  finish_at_any_time(&finished);
+  lambda();
+}
+
+void lambda_capture_with_loop_inside_lambda_good_init_capture() {
+  bool finished = false;
+  auto lambda = [&captured_finished=finished]() {
+while (!captured_finished) {
+  wait(); // No warning: 

[clang-tools-extra] 91ca326 - [clang-tidy] Aliasing: Add support for aggregates with references.

2021-05-10 Thread Artem Dergachev via cfe-commits

Author: Artem Dergachev
Date: 2021-05-10T14:00:31-07:00
New Revision: 91ca3269a1b544db1303b496101fd9d6fe953277

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

LOG: [clang-tidy] Aliasing: Add support for aggregates with references.

When a variable is used in an initializer of an aggregate
for its reference-type field this counts as aliasing.

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

Added: 


Modified: 
clang-tools-extra/clang-tidy/utils/Aliasing.cpp
clang-tools-extra/test/clang-tidy/checkers/bugprone-infinite-loop.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/utils/Aliasing.cpp 
b/clang-tools-extra/clang-tidy/utils/Aliasing.cpp
index 12a8ca8185b0f..69aea1145de50 100644
--- a/clang-tools-extra/clang-tidy/utils/Aliasing.cpp
+++ b/clang-tools-extra/clang-tidy/utils/Aliasing.cpp
@@ -50,6 +50,13 @@ static bool isPtrOrReferenceForVar(const Stmt *S, const 
VarDecl *Var) {
   } else if (const auto *LE = dyn_cast(S)) {
 // Treat lambda capture by reference as a form of taking a reference.
 return capturesByRef(LE->getLambdaClass(), Var);
+  } else if (const auto *ILE = dyn_cast(S)) {
+return llvm::any_of(ILE->inits(), [Var](const Expr *ChildE) {
+  // If the child expression is a reference to Var, this means that it's
+  // used as an initializer of a reference-typed field. Otherwise
+  // it would have been surrounded with an implicit lvalue-to-rvalue cast.
+  return isAccessForVar(ChildE, Var);
+});
   }
 
   return false;

diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/bugprone-infinite-loop.cpp 
b/clang-tools-extra/test/clang-tidy/checkers/bugprone-infinite-loop.cpp
index 5b477130a7b01..2765b181db2c5 100644
--- a/clang-tools-extra/test/clang-tidy/checkers/bugprone-infinite-loop.cpp
+++ b/clang-tools-extra/test/clang-tidy/checkers/bugprone-infinite-loop.cpp
@@ -566,3 +566,29 @@ int foo(void) {
   }
   return 0;
 }
+
+struct AggregateWithReference {
+  int &y;
+};
+
+void test_structured_bindings_good() {
+  int x = 0;
+  AggregateWithReference ref { x };
+  auto &[y] = ref;
+  for (; x < 10; ++y) {
+// No warning. The loop is finite because 'y' is a reference to 'x'.
+  }
+}
+
+struct AggregateWithValue {
+  int y;
+};
+
+void test_structured_bindings_bad() {
+  int x = 0;
+  AggregateWithValue val { x };
+  auto &[y] = val;
+  for (; x < 10; ++y) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: this loop is infinite; none 
of its condition variables (x) are updated in the loop body 
[bugprone-infinite-loop]
+  }
+}



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


[PATCH] D96215: [clang-tidy] Aliasing: Add support for lambda captures.

2021-05-10 Thread Artem Dergachev 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 rG43f4331edfb5: [clang-tidy] Aliasing: Add support for 
captures. (authored by dergachev.a).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96215

Files:
  clang-tools-extra/clang-tidy/utils/Aliasing.cpp
  clang-tools-extra/test/clang-tidy/checkers/bugprone-infinite-loop.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-redundant-branch-condition.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-redundant-branch-condition.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/bugprone-redundant-branch-condition.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-redundant-branch-condition.cpp
@@ -1,4 +1,5 @@
-// RUN: %check_clang_tidy %s bugprone-redundant-branch-condition %t
+// RUN: %check_clang_tidy %s bugprone-redundant-branch-condition %t \
+// RUN:   -- -- -fblocks
 
 extern unsigned peopleInTheBuilding;
 extern unsigned fireFighters;
@@ -1179,6 +1180,86 @@
   }
 }
 
+// Lambda / block captures.
+
+template  void accept_callback(T t) {
+  // Potentially call the callback.
+  // Possibly on a background thread or something.
+}
+
+void accept_block(void (^)(void)) {
+  // Potentially call the callback.
+  // Possibly on a background thread or something.
+}
+
+void wait(void) {
+  // Wait for the previously passed callback to be called.
+}
+
+void capture_and_mutate_by_lambda() {
+  bool x = true;
+  accept_callback([&]() { x = false; });
+  if (x) {
+wait();
+if (x) {
+}
+  }
+}
+
+void lambda_capture_by_value() {
+  bool x = true;
+  accept_callback([x]() { if (x) {} });
+  if (x) {
+wait();
+if (x) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: redundant condition 'x' [bugprone-redundant-branch-condition]
+}
+  }
+}
+
+void capture_by_lambda_but_not_mutate() {
+  bool x = true;
+  accept_callback([&]() { if (x) {} });
+  if (x) {
+wait();
+// FIXME: Should warn.
+if (x) {
+}
+  }
+}
+
+void capture_and_mutate_by_block() {
+  __block bool x = true;
+  accept_block(^{ x = false; });
+  if (x) {
+wait();
+if (x) {
+}
+  }
+}
+
+void block_capture_by_value() {
+  bool x = true;
+  accept_block(^{ if (x) {} });
+  if (x) {
+wait();
+if (x) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: redundant condition 'x' [bugprone-redundant-branch-condition]
+}
+  }
+}
+
+void capture_by_block_but_not_mutate() {
+  __block bool x = true;
+  accept_callback(^{ if (x) {} });
+  if (x) {
+wait();
+// FIXME: Should warn.
+if (x) {
+}
+  }
+}
+
 // GNU Expression Statements
 
 void negative_gnu_expression_statement() {
Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-infinite-loop.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/bugprone-infinite-loop.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-infinite-loop.cpp
@@ -1,4 +1,5 @@
-// RUN: %check_clang_tidy %s bugprone-infinite-loop %t -- -- -fexceptions
+// RUN: %check_clang_tidy %s bugprone-infinite-loop %t \
+// RUN:   -- -- -fexceptions -fblocks
 
 void simple_infinite_loop1() {
   int i = 0;
@@ -378,6 +379,84 @@
   } while (i < Limit);
 }
 
+template  void accept_callback(T t) {
+  // Potentially call the callback.
+  // Possibly on a background thread or something.
+}
+
+void accept_block(void (^)(void)) {
+  // Potentially call the callback.
+  // Possibly on a background thread or something.
+}
+
+void wait(void) {
+  // Wait for the previously passed callback to be called.
+}
+
+void lambda_capture_from_outside() {
+  bool finished = false;
+  accept_callback([&]() {
+finished = true;
+  });
+  while (!finished) {
+wait();
+  }
+}
+
+void lambda_capture_from_outside_by_value() {
+  bool finished = false;
+  accept_callback([finished]() {
+if (finished) {}
+  });
+  while (!finished) {
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: this loop is infinite; none of its condition variables (finished) are updated in the loop body [bugprone-infinite-loop]
+wait();
+  }
+}
+
+void lambda_capture_from_outside_but_unchanged() {
+  bool finished = false;
+  accept_callback([&finished]() {
+if (finished) {}
+  });
+  while (!finished) {
+// FIXME: Should warn.
+wait();
+  }
+}
+
+void block_capture_from_outside() {
+  __block bool finished = false;
+  accept_block(^{
+finished = true;
+  });
+  while (!finished) {
+wait();
+  }
+}
+
+void block_capture_from_outside_by_value() {
+  bool finished = false;
+  accept_block(^{
+if (finished) {}
+  });
+  while (!finished) {
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: this loop is infinite; none of its condition variables (finished) are updated in the

[PATCH] D101787: [clang-tidy] Aliasing: Add more support for lambda captures.

2021-05-10 Thread Artem Dergachev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9b292e0edcd4: [clang-tidy] Aliasing: Add more support for 
captures. (authored by dergachev.a).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101787

Files:
  clang-tools-extra/clang-tidy/utils/Aliasing.cpp
  clang-tools-extra/test/clang-tidy/checkers/bugprone-infinite-loop.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-redundant-branch-condition.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-redundant-branch-condition.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/bugprone-redundant-branch-condition.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-redundant-branch-condition.cpp
@@ -1260,6 +1260,71 @@
   }
 }
 
+void mutate_at_any_time(bool *x);
+
+void capture_with_branches_inside_lambda_bad() {
+  bool x = true;
+  accept_callback([=]() {
+if (x) {
+  wait();
+  if (x) {
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: redundant condition 'x' [bugprone-redundant-branch-condition]
+  }
+}
+  });
+  mutate_at_any_time(&x);
+}
+
+void capture_with_branches_inside_lambda_good() {
+  bool x = true;
+  accept_callback([&]() {
+if (x) {
+  wait();
+  if (x) {
+  }
+}
+  });
+  mutate_at_any_time(&x);
+}
+
+void capture_with_branches_inside_block_bad() {
+  bool x = true;
+  accept_callback(^{
+if (x) {
+  wait();
+  if (x) {
+ // FIXME: Should warn. It currently reacts to &x outside the block
+ // which ideally shouldn't have any effect.
+  }
+}
+  });
+  mutate_at_any_time(&x);
+}
+
+void capture_with_branches_inside_block_bad_simpler() {
+  bool x = true;
+  accept_callback(^{
+if (x) {
+  wait();
+  if (x) {
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: redundant condition 'x' [bugprone-redundant-branch-condition]
+  }
+}
+  });
+}
+
+void capture_with_branches_inside_block_good() {
+  __block bool x = true;
+  accept_callback(^{
+if (x) {
+  wait();
+  if (x) {
+  }
+}
+  });
+  mutate_at_any_time(&x);
+}
+
 // GNU Expression Statements
 
 void negative_gnu_expression_statement() {
Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-infinite-loop.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/bugprone-infinite-loop.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-infinite-loop.cpp
@@ -457,6 +457,92 @@
   }
 }
 
+void finish_at_any_time(bool *finished);
+
+void lambda_capture_with_loop_inside_lambda_bad() {
+  bool finished = false;
+  auto lambda = [=]() {
+while (!finished) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: this loop is infinite; none of its condition variables (finished) are updated in the loop body [bugprone-infinite-loop]
+  wait();
+}
+  };
+  finish_at_any_time(&finished);
+  lambda();
+}
+
+void lambda_capture_with_loop_inside_lambda_bad_init_capture() {
+  bool finished = false;
+  auto lambda = [captured_finished=finished]() {
+while (!captured_finished) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: this loop is infinite; none of its condition variables (captured_finished) are updated in the loop body [bugprone-infinite-loop]
+  wait();
+}
+  };
+  finish_at_any_time(&finished);
+  lambda();
+}
+
+void lambda_capture_with_loop_inside_lambda_good() {
+  bool finished = false;
+  auto lambda = [&]() {
+while (!finished) {
+  wait(); // No warning: the variable may be updated
+  // from outside the lambda.
+}
+  };
+  finish_at_any_time(&finished);
+  lambda();
+}
+
+void lambda_capture_with_loop_inside_lambda_good_init_capture() {
+  bool finished = false;
+  auto lambda = [&captured_finished=finished]() {
+while (!captured_finished) {
+  wait(); // No warning: the variable may be updated
+  // from outside the lambda.
+}
+  };
+  finish_at_any_time(&finished);
+  lambda();
+}
+
+void block_capture_with_loop_inside_block_bad() {
+  bool finished = false;
+  auto block = ^() {
+while (!finished) {
+  // FIXME: This should warn. It currently reacts to &finished
+  // outside the block which ideally shouldn't have any effect.
+  wait();
+}
+  };
+  finish_at_any_time(&finished);
+  block();
+}
+
+void block_capture_with_loop_inside_block_bad_simpler() {
+  bool finished = false;
+  auto block = ^() {
+while (!finished) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: this loop is infinite; none of its condition variables (finished) are updated in the loop body [bugprone-infinite-loop]
+  wait();
+}
+  };
+  block();
+}
+
+void block_capture_with_loop_inside_block_good() {
+  __block bool finished = false;
+  auto block = ^() {
+while (!finished) {
+  wait(); // No 

[PATCH] D101791: [clang-tidy] Aliasing: Add support for aggregates with references.

2021-05-10 Thread Artem Dergachev 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 rG91ca3269a1b5: [clang-tidy] Aliasing: Add support for 
aggregates with references. (authored by dergachev.a).

Changed prior to commit:
  https://reviews.llvm.org/D101791?vs=342568&id=344197#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101791

Files:
  clang-tools-extra/clang-tidy/utils/Aliasing.cpp
  clang-tools-extra/test/clang-tidy/checkers/bugprone-infinite-loop.cpp


Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-infinite-loop.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/bugprone-infinite-loop.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-infinite-loop.cpp
@@ -566,3 +566,29 @@
   }
   return 0;
 }
+
+struct AggregateWithReference {
+  int &y;
+};
+
+void test_structured_bindings_good() {
+  int x = 0;
+  AggregateWithReference ref { x };
+  auto &[y] = ref;
+  for (; x < 10; ++y) {
+// No warning. The loop is finite because 'y' is a reference to 'x'.
+  }
+}
+
+struct AggregateWithValue {
+  int y;
+};
+
+void test_structured_bindings_bad() {
+  int x = 0;
+  AggregateWithValue val { x };
+  auto &[y] = val;
+  for (; x < 10; ++y) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: this loop is infinite; none 
of its condition variables (x) are updated in the loop body 
[bugprone-infinite-loop]
+  }
+}
Index: clang-tools-extra/clang-tidy/utils/Aliasing.cpp
===
--- clang-tools-extra/clang-tidy/utils/Aliasing.cpp
+++ clang-tools-extra/clang-tidy/utils/Aliasing.cpp
@@ -50,6 +50,13 @@
   } else if (const auto *LE = dyn_cast(S)) {
 // Treat lambda capture by reference as a form of taking a reference.
 return capturesByRef(LE->getLambdaClass(), Var);
+  } else if (const auto *ILE = dyn_cast(S)) {
+return llvm::any_of(ILE->inits(), [Var](const Expr *ChildE) {
+  // If the child expression is a reference to Var, this means that it's
+  // used as an initializer of a reference-typed field. Otherwise
+  // it would have been surrounded with an implicit lvalue-to-rvalue cast.
+  return isAccessForVar(ChildE, Var);
+});
   }
 
   return false;


Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-infinite-loop.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/bugprone-infinite-loop.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-infinite-loop.cpp
@@ -566,3 +566,29 @@
   }
   return 0;
 }
+
+struct AggregateWithReference {
+  int &y;
+};
+
+void test_structured_bindings_good() {
+  int x = 0;
+  AggregateWithReference ref { x };
+  auto &[y] = ref;
+  for (; x < 10; ++y) {
+// No warning. The loop is finite because 'y' is a reference to 'x'.
+  }
+}
+
+struct AggregateWithValue {
+  int y;
+};
+
+void test_structured_bindings_bad() {
+  int x = 0;
+  AggregateWithValue val { x };
+  auto &[y] = val;
+  for (; x < 10; ++y) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: this loop is infinite; none of its condition variables (x) are updated in the loop body [bugprone-infinite-loop]
+  }
+}
Index: clang-tools-extra/clang-tidy/utils/Aliasing.cpp
===
--- clang-tools-extra/clang-tidy/utils/Aliasing.cpp
+++ clang-tools-extra/clang-tidy/utils/Aliasing.cpp
@@ -50,6 +50,13 @@
   } else if (const auto *LE = dyn_cast(S)) {
 // Treat lambda capture by reference as a form of taking a reference.
 return capturesByRef(LE->getLambdaClass(), Var);
+  } else if (const auto *ILE = dyn_cast(S)) {
+return llvm::any_of(ILE->inits(), [Var](const Expr *ChildE) {
+  // If the child expression is a reference to Var, this means that it's
+  // used as an initializer of a reference-typed field. Otherwise
+  // it would have been surrounded with an implicit lvalue-to-rvalue cast.
+  return isAccessForVar(ChildE, Var);
+});
   }
 
   return false;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D102196: [NewPM] Add options to PrintPassInstrumentation

2021-05-10 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks updated this revision to Diff 344201.
aeubanks added a comment.

assert Indent >= 0


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102196

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  clang/test/Driver/debug-pass-structure.c
  llvm/include/llvm/Passes/StandardInstrumentations.h
  llvm/lib/Passes/StandardInstrumentations.cpp
  llvm/test/Other/new-pass-manager-cgscc-fct-proxy.ll
  llvm/test/Other/opt-O3-pipeline.ll
  llvm/test/Other/pass-pipeline-parsing.ll
  llvm/tools/opt/NewPMDriver.cpp

Index: llvm/tools/opt/NewPMDriver.cpp
===
--- llvm/tools/opt/NewPMDriver.cpp
+++ llvm/tools/opt/NewPMDriver.cpp
@@ -52,9 +52,17 @@
cl::value_desc("filename"));
 } // namespace llvm
 
-static cl::opt
-DebugPM("debug-pass-manager", cl::Hidden,
-cl::desc("Print pass management debugging information"));
+enum class DebugLogging { None, Normal, Verbose };
+
+static cl::opt DebugPM(
+"debug-pass-manager", cl::Hidden, cl::ValueOptional,
+cl::desc("Print pass management debugging information"),
+cl::init(DebugLogging::None),
+cl::values(
+clEnumValN(DebugLogging::Normal, "", ""),
+clEnumValN(
+DebugLogging::Verbose, "verbose",
+"Print extra information about adaptors and pass managers")));
 
 static cl::list
 PassPlugins("load-pass-plugin",
@@ -283,7 +291,10 @@
   ModuleAnalysisManager MAM;
 
   PassInstrumentationCallbacks PIC;
-  StandardInstrumentations SI(DebugPM, VerifyEachPass);
+  PrintPassOptions PrintPassOpts;
+  PrintPassOpts.Verbose = DebugPM == DebugLogging::Verbose;
+  StandardInstrumentations SI(DebugPM != DebugLogging::None, VerifyEachPass,
+  PrintPassOpts);
   SI.registerCallbacks(PIC, &FAM);
   DebugifyEachInstrumentation Debugify;
   if (DebugifyEach)
Index: llvm/test/Other/pass-pipeline-parsing.ll
===
--- llvm/test/Other/pass-pipeline-parsing.ll
+++ llvm/test/Other/pass-pipeline-parsing.ll
@@ -142,7 +142,7 @@
 ; RUN: | FileCheck %s --check-prefix=CHECK-NESTED-FP-LP
 ; CHECK-NESTED-FP-LP: Running pass: NoOpLoopPass
 
-; RUN: opt -disable-output -debug-pass-manager -debug-pass-manager-verbose \
+; RUN: opt -disable-output -debug-pass-manager=verbose \
 ; RUN: -passes='module(no-op-function,no-op-loop,no-op-cgscc,cgscc(no-op-function,no-op-loop),function(no-op-loop))' %s 2>&1 \
 ; RUN: | FileCheck %s --check-prefix=CHECK-ADAPTORS
 ; CHECK-ADAPTORS: Running pass: ModuleToFunctionPassAdaptor
@@ -167,7 +167,7 @@
 ; RUN: opt -disable-output -debug-pass-manager \
 ; RUN: -passes='module(function(no-op-function,loop(no-op-loop,no-op-loop)))' %s 2>&1 \
 ; RUN: | FileCheck %s --check-prefix=CHECK-MANAGERS-NO-VERBOSE
-; RUN: opt -disable-output -debug-pass-manager -debug-pass-manager-verbose \
+; RUN: opt -disable-output -debug-pass-manager=verbose \
 ; RUN: -passes='module(function(no-op-function,loop(no-op-loop,no-op-loop)))' %s 2>&1 \
 ; RUN: | FileCheck %s --check-prefix=CHECK-MANAGERS
 ; CHECK-MANAGERS: Running pass: PassManager{{.*}}Function
Index: llvm/test/Other/opt-O3-pipeline.ll
===
--- llvm/test/Other/opt-O3-pipeline.ll
+++ llvm/test/Other/opt-O3-pipeline.ll
@@ -1,5 +1,4 @@
 ; RUN: opt -enable-new-pm=0 -mtriple=x86_64-- -O3 -debug-pass=Structure < %s -o /dev/null 2>&1 | FileCheck --check-prefixes=CHECK,%llvmcheckext %s
-; RUN: opt -enable-new-pm=1 -mtriple=x86_64-- -O3 -debug-pass-structure < %s -o /dev/null 2>&1 | FileCheck --check-prefixes=NEWPM,%llvmcheckext %s
 
 ; REQUIRES: asserts
 
@@ -336,169 +335,6 @@
 ; CHECK-NEXT: Branch Probability Analysis
 ; CHECK-NEXT: Block Frequency Analysis
 
-; NEWPM:  VerifierPass on [module]
-; NEWPM-NEXT:   VerifierAnalysis analysis on [module]
-; NEWPM-NEXT: Annotation2MetadataPass on [module]
-; NEWPM-NEXT: ForceFunctionAttrsPass on [module]
-; NEWPM-NEXT: InferFunctionAttrsPass on [module]
-; NEWPM-NEXT:   InnerAnalysisManagerProxy<{{.*}}> analysis on [module]
-; NEWPM-NEXT: ModuleToFunctionPassAdaptor on [module]
-; NEWPM-NEXT:   PassManager<{{.*}}> on f
-; NEWPM-NEXT: PreservedCFGCheckerAnalysis analysis on f
-; NEWPM-NEXT: LowerExpectIntrinsicPass on f
-; NEWPM-NEXT: SimplifyCFGPass on f
-; NEWPM-NEXT:   TargetIRAnalysis analysis on f
-; NEWPM-NEXT:   AssumptionAnalysis analysis on f
-; NEWPM-NEXT: SROA on f
-; NEWPM-NEXT:   DominatorTreeAnalysis analysis on f
-; NEWPM-NEXT: EarlyCSEPass on f
-; NEWPM-NEXT:   TargetLibraryAnalysis analysis on f
-; NEWPM-NEXT: CallSiteSplittingPass on f
-; NEWPM-NEXT: OpenMPOptPass on [module]
-; NEWPM-NEXT: IPSCCPPass on [module]
-; NEWPM-NEXT: CalledValuePropagationPass on [module]
-; NEWPM-NEXT: GlobalOptPass on [module]
-; NEWPM-NEXT: ModuleToFunct

  1   2   >