[clang] 4fc69ab - Revert "[OpenMP][FIX] Verify compatible types for declare variant calls"

2020-09-28 Thread Johannes Doerfert via cfe-commits

Author: Johannes Doerfert
Date: 2020-09-29T00:37:11-05:00
New Revision: 4fc69ab002382675d84f611f22599cb3cb4a0787

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

LOG: Revert "[OpenMP][FIX] Verify compatible types for declare variant calls"

This reverts commit c942095790decf525a445f3bd68fb9bcc9aa43c6.

One of the tests broke, revert to investigate.

Added: 


Modified: 
clang/lib/Sema/SemaOpenMP.cpp
clang/lib/Sema/SemaTemplateInstantiateDecl.cpp

Removed: 
clang/test/AST/ast-dump-openmp-begin-declare-variant_template_3.cpp



diff  --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index d0b5a0d03e2d..91897cbe25b4 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -5921,6 +5921,7 @@ void 
Sema::ActOnStartOfFunctionDefinitionInOpenMPDeclareVariantScope(
   continue;
 
 QualType UDeclTy = UDecl->getType();
+// TODO: Verify types for templates eventually.
 if (!UDeclTy->isDependentType()) {
   QualType NewType = Context.mergeFunctionTypes(
   FType, UDeclTy, /* OfBlockPointer */ false,
@@ -6008,8 +6009,6 @@ ExprResult Sema::ActOnOpenMPCall(ExprResult Call, Scope 
*Scope,
   TargetOMPContext OMPCtx(Context, std::move(DiagUnknownTrait),
   getCurFunctionDecl());
 
-  QualType CalleeFnType = CalleeFnDecl->getType();
-
   SmallVector Exprs;
   SmallVector VMIs;
   while (CalleeFnDecl) {
@@ -6062,19 +6061,8 @@ ExprResult Sema::ActOnOpenMPCall(ExprResult Call, Scope 
*Scope,
   }
   NewCall = BuildCallExpr(Scope, BestExpr, LParenLoc, ArgExprs, RParenLoc,
   ExecConfig);
-  if (NewCall.isUsable()) {
-if (CallExpr *NCE = dyn_cast(NewCall.get())) {
-  FunctionDecl *NewCalleeFnDecl = NCE->getDirectCallee();
-  QualType NewType = Context.mergeFunctionTypes(
-  CalleeFnType, NewCalleeFnDecl->getType(),
-  /* OfBlockPointer */ false,
-  /* Unqualified */ false, /* AllowCXX */ true);
-  if (!NewType.isNull())
-break;
-  // Don't use the call if the function type was not compatible.
-  NewCall = nullptr;
-}
-  }
+  if (NewCall.isUsable())
+break;
 }
 
 VMIs.erase(VMIs.begin() + BestIdx);

diff  --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp 
b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
index 9420bd04b7a9..cbbb44b82adc 100644
--- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -444,12 +444,6 @@ static void instantiateOMPDeclareVariantAttr(
  New->getLocation());
 if (!SubstFD)
   return;
-QualType NewType = S.Context.mergeFunctionTypes(
-SubstFD->getType(), FD->getType(),
-/* OfBlockPointer */ false,
-/* Unqualified */ false, /* AllowCXX */ true);
-if (NewType.isNull())
-  return;
 S.InstantiateFunctionDefinition(
 New->getLocation(), SubstFD, /* Recursive */ true,
 /* DefinitionRequired */ false, /* AtEndOfTU */ false);

diff  --git 
a/clang/test/AST/ast-dump-openmp-begin-declare-variant_template_3.cpp 
b/clang/test/AST/ast-dump-openmp-begin-declare-variant_template_3.cpp
deleted file mode 100644
index 153764490c0d..
--- a/clang/test/AST/ast-dump-openmp-begin-declare-variant_template_3.cpp
+++ /dev/null
@@ -1,258 +0,0 @@
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fopenmp -verify -ast-dump 
%s -x c++| FileCheck %s
-// expected-no-diagnostics
-// PR47655
-
-template  struct S {
-  S(int, T *) {}
-};
-
-template 
-int also_before(T s) {
-  return 0;
-}
-
-#pragma omp begin declare variant match(implementation = 
{extension(allow_templates)})
-template 
-int also_before(S s) {
-  // Ensure there is no error because this is never instantiated.
-  double t;
-  S q(1, );
-  return 1;
-}
-template 
-int special(S s) {
-  T t;
-  S q(0, );
-  return 0;
-}
-template 
-int also_after(S s) {
-  // Ensure there is no error because this is never instantiated.
-  double t;
-  S q(2.0, );
-  return 2;
-}
-#pragma omp end declare variant
-
-template 
-int also_after(T s) {
-  return 0;
-}
-
-int test() {
-  // Should return 0.
-  return also_before(0) + also_after(0) + also_before(0.) + also_after(0.) + 
special(S(0, 0));
-}
-
-// CHECK:  |-ClassTemplateDecl [[ADDR_0:0x[a-z0-9]*]] <{{.*}}, line:7:1> 
line:5:30 S
-// CHECK-NEXT: | |-TemplateTypeParmDecl [[ADDR_1:0x[a-z0-9]*]]  col:20 referenced typename depth 0 index 0 T
-// CHECK-NEXT: | |-CXXRecordDecl [[ADDR_2:0x[a-z0-9]*]]  
line:5:30 struct S definition
-// CHECK-NEXT: | | |-DefinitionData empty standard_layout trivially_copyable 

[PATCH] D88384: [OpenMP][FIX] Verify compatible types for declare variant calls

2020-09-28 Thread Johannes Doerfert 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 rGc942095790de: [OpenMP][FIX] Verify compatible types for 
declare variant calls (authored by jdoerfert).

Changed prior to commit:
  https://reviews.llvm.org/D88384?vs=294596=294878#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88384

Files:
  clang/lib/Sema/SemaOpenMP.cpp
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/test/AST/ast-dump-openmp-begin-declare-variant_template_3.cpp

Index: clang/test/AST/ast-dump-openmp-begin-declare-variant_template_3.cpp
===
--- /dev/null
+++ clang/test/AST/ast-dump-openmp-begin-declare-variant_template_3.cpp
@@ -0,0 +1,258 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fopenmp -verify -ast-dump %s -x c++| FileCheck %s
+// expected-no-diagnostics
+// PR47655
+
+template  struct S {
+  S(int, T *) {}
+};
+
+template 
+int also_before(T s) {
+  return 0;
+}
+
+#pragma omp begin declare variant match(implementation = {extension(allow_templates)})
+template 
+int also_before(S s) {
+  // Ensure there is no error because this is never instantiated.
+  double t;
+  S q(1, );
+  return 1;
+}
+template 
+int special(S s) {
+  T t;
+  S q(0, );
+  return 0;
+}
+template 
+int also_after(S s) {
+  // Ensure there is no error because this is never instantiated.
+  double t;
+  S q(2.0, );
+  return 2;
+}
+#pragma omp end declare variant
+
+template 
+int also_after(T s) {
+  return 0;
+}
+
+int test() {
+  // Should return 0.
+  return also_before(0) + also_after(0) + also_before(0.) + also_after(0.) + special(S(0, 0));
+}
+
+// CHECK:  |-ClassTemplateDecl [[ADDR_0:0x[a-z0-9]*]] <{{.*}}, line:7:1> line:5:30 S
+// CHECK-NEXT: | |-TemplateTypeParmDecl [[ADDR_1:0x[a-z0-9]*]]  col:20 referenced typename depth 0 index 0 T
+// CHECK-NEXT: | |-CXXRecordDecl [[ADDR_2:0x[a-z0-9]*]]  line:5:30 struct S definition
+// CHECK-NEXT: | | |-DefinitionData empty standard_layout trivially_copyable has_user_declared_ctor can_const_default_init
+// CHECK-NEXT: | | | |-DefaultConstructor defaulted_is_constexpr
+// CHECK-NEXT: | | | |-CopyConstructor simple trivial has_const_param needs_implicit implicit_has_const_param
+// CHECK-NEXT: | | | |-MoveConstructor exists simple trivial needs_implicit
+// CHECK-NEXT: | | | |-CopyAssignment simple trivial has_const_param needs_implicit implicit_has_const_param
+// CHECK-NEXT: | | | |-MoveAssignment exists simple trivial needs_implicit
+// CHECK-NEXT: | | | `-Destructor simple irrelevant trivial needs_implicit
+// CHECK-NEXT: | | |-CXXRecordDecl [[ADDR_3:0x[a-z0-9]*]]  col:30 implicit referenced struct S
+// CHECK-NEXT: | | `-CXXConstructorDecl [[ADDR_4:0x[a-z0-9]*]]  col:3 S 'void (int, T *)'
+// CHECK-NEXT: | |   |-ParmVarDecl [[ADDR_5:0x[a-z0-9]*]]  col:8 'int'
+// CHECK-NEXT: | |   |-ParmVarDecl [[ADDR_6:0x[a-z0-9]*]]  col:13 'T *'
+// CHECK-NEXT: | |   `-CompoundStmt [[ADDR_7:0x[a-z0-9]*]] 
+// CHECK-NEXT: | |-ClassTemplateSpecializationDecl [[ADDR_8:0x[a-z0-9]*]]  line:5:30 struct S definition
+// CHECK-NEXT: | | |-DefinitionData pass_in_registers empty standard_layout trivially_copyable has_user_declared_ctor can_const_default_init
+// CHECK-NEXT: | | | |-DefaultConstructor defaulted_is_constexpr
+// CHECK-NEXT: | | | |-CopyConstructor simple trivial has_const_param implicit_has_const_param
+// CHECK-NEXT: | | | |-MoveConstructor exists simple trivial
+// CHECK-NEXT: | | | |-CopyAssignment simple trivial has_const_param needs_implicit implicit_has_const_param
+// CHECK-NEXT: | | | |-MoveAssignment exists simple trivial needs_implicit
+// CHECK-NEXT: | | | `-Destructor simple irrelevant trivial
+// CHECK-NEXT: | | |-TemplateArgument type 'int'
+// CHECK-NEXT: | | | `-BuiltinType [[ADDR_9:0x[a-z0-9]*]] 'int'
+// CHECK-NEXT: | | |-CXXRecordDecl [[ADDR_10:0x[a-z0-9]*]] prev [[ADDR_8]]  col:30 implicit struct S
+// CHECK-NEXT: | | |-CXXConstructorDecl [[ADDR_11:0x[a-z0-9]*]]  col:3 used S 'void (int, int *)'
+// CHECK-NEXT: | | | |-ParmVarDecl [[ADDR_12:0x[a-z0-9]*]]  col:8 'int'
+// CHECK-NEXT: | | | |-ParmVarDecl [[ADDR_13:0x[a-z0-9]*]]  col:13 'int *'
+// CHECK-NEXT: | | | `-CompoundStmt [[ADDR_7]] 
+// CHECK-NEXT: | | |-CXXConstructorDecl [[ADDR_14:0x[a-z0-9]*]]  col:30 implicit constexpr S 'void (const S &)' inline default trivial noexcept-unevaluated [[ADDR_14]]
+// CHECK-NEXT: | | | `-ParmVarDecl [[ADDR_15:0x[a-z0-9]*]]  col:30 'const S &'
+// CHECK-NEXT: | | |-CXXConstructorDecl [[ADDR_16:0x[a-z0-9]*]]  col:30 implicit used constexpr S 'void (S &&) noexcept' inline default trivial
+// CHECK-NEXT: | | | |-ParmVarDecl [[ADDR_17:0x[a-z0-9]*]]  col:30 'S &&'
+// CHECK-NEXT: | | | `-CompoundStmt [[ADDR_18:0x[a-z0-9]*]] 
+// CHECK-NEXT: | | `-CXXDestructorDecl [[ADDR_19:0x[a-z0-9]*]]  col:30 implicit referenced ~S 'void ({{.*}}) noexcept' 

[clang] c942095 - [OpenMP][FIX] Verify compatible types for declare variant calls

2020-09-28 Thread Johannes Doerfert via cfe-commits

Author: Johannes Doerfert
Date: 2020-09-28T23:26:21-05:00
New Revision: c942095790decf525a445f3bd68fb9bcc9aa43c6

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

LOG: [OpenMP][FIX] Verify compatible types for declare variant calls

Especially for templates we need to check at some point if the base
function matches the specialization we might call instead. Before this
lead to the replacement of `std::sqrt(int(2))` calls with one that
converts the argument to a `std::complex`, clearly not the desired
behavior.

Reported as PR47655

Reviewed By: JonChesterfield

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

Added: 
clang/test/AST/ast-dump-openmp-begin-declare-variant_template_3.cpp

Modified: 
clang/lib/Sema/SemaOpenMP.cpp
clang/lib/Sema/SemaTemplateInstantiateDecl.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index 91897cbe25b4..d0b5a0d03e2d 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -5921,7 +5921,6 @@ void 
Sema::ActOnStartOfFunctionDefinitionInOpenMPDeclareVariantScope(
   continue;
 
 QualType UDeclTy = UDecl->getType();
-// TODO: Verify types for templates eventually.
 if (!UDeclTy->isDependentType()) {
   QualType NewType = Context.mergeFunctionTypes(
   FType, UDeclTy, /* OfBlockPointer */ false,
@@ -6009,6 +6008,8 @@ ExprResult Sema::ActOnOpenMPCall(ExprResult Call, Scope 
*Scope,
   TargetOMPContext OMPCtx(Context, std::move(DiagUnknownTrait),
   getCurFunctionDecl());
 
+  QualType CalleeFnType = CalleeFnDecl->getType();
+
   SmallVector Exprs;
   SmallVector VMIs;
   while (CalleeFnDecl) {
@@ -6061,8 +6062,19 @@ ExprResult Sema::ActOnOpenMPCall(ExprResult Call, Scope 
*Scope,
   }
   NewCall = BuildCallExpr(Scope, BestExpr, LParenLoc, ArgExprs, RParenLoc,
   ExecConfig);
-  if (NewCall.isUsable())
-break;
+  if (NewCall.isUsable()) {
+if (CallExpr *NCE = dyn_cast(NewCall.get())) {
+  FunctionDecl *NewCalleeFnDecl = NCE->getDirectCallee();
+  QualType NewType = Context.mergeFunctionTypes(
+  CalleeFnType, NewCalleeFnDecl->getType(),
+  /* OfBlockPointer */ false,
+  /* Unqualified */ false, /* AllowCXX */ true);
+  if (!NewType.isNull())
+break;
+  // Don't use the call if the function type was not compatible.
+  NewCall = nullptr;
+}
+  }
 }
 
 VMIs.erase(VMIs.begin() + BestIdx);

diff  --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp 
b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
index cbbb44b82adc..9420bd04b7a9 100644
--- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -444,6 +444,12 @@ static void instantiateOMPDeclareVariantAttr(
  New->getLocation());
 if (!SubstFD)
   return;
+QualType NewType = S.Context.mergeFunctionTypes(
+SubstFD->getType(), FD->getType(),
+/* OfBlockPointer */ false,
+/* Unqualified */ false, /* AllowCXX */ true);
+if (NewType.isNull())
+  return;
 S.InstantiateFunctionDefinition(
 New->getLocation(), SubstFD, /* Recursive */ true,
 /* DefinitionRequired */ false, /* AtEndOfTU */ false);

diff  --git 
a/clang/test/AST/ast-dump-openmp-begin-declare-variant_template_3.cpp 
b/clang/test/AST/ast-dump-openmp-begin-declare-variant_template_3.cpp
new file mode 100644
index ..153764490c0d
--- /dev/null
+++ b/clang/test/AST/ast-dump-openmp-begin-declare-variant_template_3.cpp
@@ -0,0 +1,258 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fopenmp -verify -ast-dump 
%s -x c++| FileCheck %s
+// expected-no-diagnostics
+// PR47655
+
+template  struct S {
+  S(int, T *) {}
+};
+
+template 
+int also_before(T s) {
+  return 0;
+}
+
+#pragma omp begin declare variant match(implementation = 
{extension(allow_templates)})
+template 
+int also_before(S s) {
+  // Ensure there is no error because this is never instantiated.
+  double t;
+  S q(1, );
+  return 1;
+}
+template 
+int special(S s) {
+  T t;
+  S q(0, );
+  return 0;
+}
+template 
+int also_after(S s) {
+  // Ensure there is no error because this is never instantiated.
+  double t;
+  S q(2.0, );
+  return 2;
+}
+#pragma omp end declare variant
+
+template 
+int also_after(T s) {
+  return 0;
+}
+
+int test() {
+  // Should return 0.
+  return also_before(0) + also_after(0) + also_before(0.) + also_after(0.) + 
special(S(0, 0));
+}
+
+// CHECK:  |-ClassTemplateDecl [[ADDR_0:0x[a-z0-9]*]] <{{.*}}, line:7:1> 
line:5:30 S
+// 

[PATCH] D87901: [Driver] Filter out /gcc and /gcc-cross if they do not exists

2020-09-28 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay accepted this revision.
MaskRay added a comment.
This revision is now accepted and ready to land.

> For my installation configured with 
> -DCMAKE_INSTALL_PREFIX=/home/antipov/.local/llvm-12.0.0, it's possible to 
> filter out 80 of 200 VFS lookups, from:

The strace dump is too long. Please don't include it in the message


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87901

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


[PATCH] D86629: [AVR][clang] Pass the address of the data section to the linker for ATmega328

2020-09-28 Thread Ben Shi via Phabricator via cfe-commits
benshi001 added a comment.

I think this patch is OK to be committed.

And I hope

1. Temporarily using an array for more devices, before a solution of getting 
info from the tblgen.

2. Distinghuish the arguments for "-L" and "-m". It is correct for atmega328 
that avr-ld needs "-L/usr/lib/avr/lib/avr5" ... "-latmega328p" "-mavr5" But for 
some special devices, such as attiny24, the following options is needed by 
avr-ld "-L/usr/lib/avr/lib/avr25/tiny-stack" ... "-lattiny24" "-mavr25", since 
the avr-lib's file organization.

I am glad to maintain an array before a formal tblgen solution, which includes 
device family (-m), 
lib file sub path (-L), data segment address (-T)




Comment at: clang/lib/Driver/ToolChains/AVR.cpp:40
 
+llvm::Optional GetMcuSectionAddressData(StringRef MCU) {
+  return llvm::StringSwitch>(MCU)

aykevl wrote:
> I don't think the LLVM coding style says something about this, but coming 
> from Go I'm more used to capitalized abbreviations (`MCU`, 
> `GetMCUSectionAddressData`).
> 
> However, this is just a superficial thing, feel free to ignore.
I prefer to "Mcu"


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86629

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


[PATCH] D87901: [Driver] Filter out /gcc and /gcc-cross if they do not exists

2020-09-28 Thread Dmitry Antipov via Phabricator via cfe-commits
dmantipov added a comment.

Thanks @MaskRay for the method, some of my numbers are shown below.

Before:

  # strace -fc -e file /home/antipov/.local/llvm-12.0.0/bin/clang++ test.cc 
  % time seconds  usecs/call callserrors syscall
  -- --- --- - - 
  100.000.004000  12   333   254 openat
0.000.00   060   open
0.000.00   0   12078 stat
0.000.00   0 8   lstat
0.000.00   06853 access
0.000.00   0 3   execve
0.000.00   0 1   rename
0.000.00   0 4   unlink
0.000.00   0 7   readlink
0.000.00   0 1   chmod
  -- --- --- - - 
  100.000.004000   6   605   385 total
  
  # strace -fc -e file /home/antipov/.local/llvm-12.0.0/bin/clang++ -target 
mips-img-linux-gnu 
--gcc-toolchain=/home/antipov/.local/mips-img-linux-gnu/2017.10-05 
--sysroot=/home/antipov/.local/mips-img-linux-gnu/2017.10-05/sysroot/mips-r6-hard
 test.cc 
  % time seconds  usecs/call callserrors syscall
  -- --- --- - - 
0.000.00   060   open
0.000.00   0   12576 stat
0.000.00   093   lstat
0.000.00   07256 access
0.000.00   0 3   execve
0.000.00   0 1   rename
0.000.00   0 4   unlink
0.000.00   0 7   readlink
0.000.00   0 1   chmod
0.000.00   0   234   157 openat
  -- --- --- - - 
  100.000.00   0   600   289 total

After:

  # strace -fc -e file /home/antipov/.local/llvm-12.0.0/bin/clang++ test.cc 
  % time seconds  usecs/call callserrors syscall
  -- --- --- - - 
0.000.00   060   open
0.000.00   0   12884 stat
0.000.00   0 8   lstat
0.000.00   06853 access
0.000.00   0 3   execve
0.000.00   0 1   rename
0.000.00   0 4   unlink
0.000.00   0 7   readlink
0.000.00   0 1   chmod
0.000.00   0   245   166 openat
  -- --- --- - - 
  100.000.00   0   525   303 total
  
  # strace -fc -e file /home/antipov/.local/llvm-12.0.0/bin/clang++ -target 
mips-img-linux-gnu 
--gcc-toolchain=/home/antipov/.local/mips-img-linux-gnu/2017.10-05 
--sysroot=/home/antipov/.local/mips-img-linux-gnu/2017.10-05/sysroot/mips-r6-hard
 test.cc 
  % time seconds  usecs/call callserrors syscall
  -- --- --- - - 
0.000.00   060   open
0.000.00   0   13180 stat
0.000.00   093   lstat
0.000.00   07256 access
0.000.00   0 3   execve
0.000.00   0 1   rename
0.000.00   0 4   unlink
0.000.00   0 7   readlink
0.000.00   0 1   chmod
0.000.00   0   200   123 openat
  -- --- --- - - 
  100.000.00   0   572   259 total


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87901

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


[clang] 5a3023a - [HIP] Return non-zero value for invalid target ID

2020-09-28 Thread Yaxun Liu via cfe-commits

Author: Yaxun (Sam) Liu
Date: 2020-09-28T23:07:39-04:00
New Revision: 5a3023a91c0ec82e7272569c5ca7a6eb372b129f

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

LOG: [HIP] Return non-zero value for invalid target ID

This is part of https://reviews.llvm.org/D60620

Added: 


Modified: 
clang/lib/Driver/Driver.cpp
clang/test/Driver/hip-invalid-target-id.hip

Removed: 




diff  --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index 69336f6f94b66..9cc4b8212981b 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -2790,6 +2790,7 @@ class OffloadingActionBuilder final {
   parseTargetID(getHIPOffloadTargetTriple(), IdStr, );
   if (!ArchStr) {
 C.getDriver().Diag(clang::diag::err_drv_bad_target_id) << IdStr;
+C.setContainsError();
 return StringRef();
   }
   auto CanId = getCanonicalTargetID(ArchStr.getValue(), Features);

diff  --git a/clang/test/Driver/hip-invalid-target-id.hip 
b/clang/test/Driver/hip-invalid-target-id.hip
index aad29c555b581..cbd6f59b08543 100644
--- a/clang/test/Driver/hip-invalid-target-id.hip
+++ b/clang/test/Driver/hip-invalid-target-id.hip
@@ -2,7 +2,7 @@
 // REQUIRES: x86-registered-target
 // REQUIRES: amdgpu-registered-target
 
-// RUN: %clang -### -target x86_64-linux-gnu \
+// RUN: not %clang -### -target x86_64-linux-gnu \
 // RUN:   -x hip --offload-arch=gfx908 \
 // RUN:   --offload-arch=gfx908xnack \
 // RUN:   --rocm-path=%S/Inputs/rocm \
@@ -10,7 +10,7 @@
 
 // NOPLUS: error: Invalid target ID: gfx908xnack
 
-// RUN: %clang -### -target x86_64-linux-gnu \
+// RUN: not %clang -### -target x86_64-linux-gnu \
 // RUN:   -x hip --offload-arch=gfx900 \
 // RUN:   --offload-arch=gfx908:xnack+:xnack+ \
 // RUN:   --rocm-path=%S/Inputs/rocm \
@@ -18,7 +18,7 @@
 
 // ORDER: error: Invalid target ID: gfx908:xnack+:xnack+
 
-// RUN: %clang -### -target x86_64-linux-gnu \
+// RUN: not %clang -### -target x86_64-linux-gnu \
 // RUN:   -x hip --offload-arch=gfx908 \
 // RUN:   --offload-arch=gfx908:unknown+ \
 // RUN:   --offload-arch=gfx908+sram-ecc+unknown \
@@ -28,7 +28,7 @@
 
 // UNK: error: Invalid target ID: gfx908:unknown+
 
-// RUN: %clang -### -target x86_64-linux-gnu \
+// RUN: not %clang -### -target x86_64-linux-gnu \
 // RUN:   -x hip --offload-arch=gfx908 \
 // RUN:   --offload-arch=gfx908:sram-ecc+:unknown+ \
 // RUN:   --offload-arch=gfx900+xnack \
@@ -37,7 +37,7 @@
 
 // MIXED: error: Invalid target ID: gfx908:sram-ecc+:unknown+
 
-// RUN: %clang -### -target x86_64-linux-gnu \
+// RUN: not %clang -### -target x86_64-linux-gnu \
 // RUN:   -x hip --offload-arch=gfx908 \
 // RUN:   --offload-arch=gfx900:sram-ecc+ \
 // RUN:   --rocm-path=%S/Inputs/rocm \
@@ -45,7 +45,7 @@
 
 // UNSUP: error: Invalid target ID: gfx900:sram-ecc+
 
-/ RUN: %clang -### -target x86_64-linux-gnu \
+/ RUN: not %clang -### -target x86_64-linux-gnu \
 // RUN:   -x hip --offload-arch=gfx908 \
 // RUN:   --offload-arch=gfx900:xnack \
 // RUN:   --rocm-path=%S/Inputs/rocm \
@@ -53,7 +53,7 @@
 
 // NOSIGN: error: Invalid target ID: gfx900:xnack
 
-// RUN: %clang -### -target x86_64-linux-gnu \
+// RUN: not %clang -### -target x86_64-linux-gnu \
 // RUN:   -x hip --offload-arch=gfx908 \
 // RUN:   --offload-arch=gfx900+xnack \
 // RUN:   --rocm-path=%S/Inputs/rocm \



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


[PATCH] D87901: [Driver] Filter out /gcc and /gcc-cross if they do not exists

2020-09-28 Thread Dmitry Antipov via Phabricator via cfe-commits
dmantipov updated this revision to Diff 294873.
dmantipov added a comment.

Prefer locals and function parameters to class members.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87901

Files:
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/lib/Driver/ToolChains/Gnu.h


Index: clang/lib/Driver/ToolChains/Gnu.h
===
--- clang/lib/Driver/ToolChains/Gnu.h
+++ clang/lib/Driver/ToolChains/Gnu.h
@@ -270,7 +270,8 @@
 const llvm::opt::ArgList ,
 const std::string ,
 StringRef CandidateTriple,
-bool NeedsBiarchSuffix = false);
+bool NeedsBiarchSuffix, bool GCCDirExists,
+bool GCCCrossDirExists);
 
 bool ScanGentooConfigs(const llvm::Triple ,
const llvm::opt::ArgList ,
Index: clang/lib/Driver/ToolChains/Gnu.cpp
===
--- clang/lib/Driver/ToolChains/Gnu.cpp
+++ clang/lib/Driver/ToolChains/Gnu.cpp
@@ -1939,27 +1939,36 @@
   // installation available. GCC installs are ranked by version number.
   Version = GCCVersion::Parse("0.0.0");
   for (const std::string  : Prefixes) {
-if (!D.getVFS().exists(Prefix))
+auto  = D.getVFS();
+if (!VFS.exists(Prefix))
   continue;
 for (StringRef Suffix : CandidateLibDirs) {
   const std::string LibDir = Prefix + Suffix.str();
-  if (!D.getVFS().exists(LibDir))
+  if (!VFS.exists(LibDir))
 continue;
+  // Maybe filter out /gcc and /gcc-cross.
+  bool GCCDirExists = VFS.exists(LibDir + "/gcc");
+  bool GCCCrossDirExists = VFS.exists(LibDir + "/gcc-cross");
   // Try to match the exact target triple first.
-  ScanLibDirForGCCTriple(TargetTriple, Args, LibDir, TargetTriple.str());
+  ScanLibDirForGCCTriple(TargetTriple, Args, LibDir, TargetTriple.str(),
+ false, GCCDirExists, GCCCrossDirExists);
   // Try rest of possible triples.
   for (StringRef Candidate : ExtraTripleAliases) // Try these first.
-ScanLibDirForGCCTriple(TargetTriple, Args, LibDir, Candidate);
+ScanLibDirForGCCTriple(TargetTriple, Args, LibDir, Candidate, false,
+   GCCDirExists, GCCCrossDirExists);
   for (StringRef Candidate : CandidateTripleAliases)
-ScanLibDirForGCCTriple(TargetTriple, Args, LibDir, Candidate);
+ScanLibDirForGCCTriple(TargetTriple, Args, LibDir, Candidate, false,
+   GCCDirExists, GCCCrossDirExists);
 }
 for (StringRef Suffix : CandidateBiarchLibDirs) {
   const std::string LibDir = Prefix + Suffix.str();
-  if (!D.getVFS().exists(LibDir))
+  if (!VFS.exists(LibDir))
 continue;
+  bool GCCDirExists = VFS.exists(LibDir + "/gcc");
+  bool GCCCrossDirExists = VFS.exists(LibDir + "/gcc-cross");
   for (StringRef Candidate : CandidateBiarchTripleAliases)
-ScanLibDirForGCCTriple(TargetTriple, Args, LibDir, Candidate,
-   /*NeedsBiarchSuffix=*/ true);
+ScanLibDirForGCCTriple(TargetTriple, Args, LibDir, Candidate, true,
+   GCCDirExists, GCCCrossDirExists);
 }
   }
 }
@@ -2450,7 +2459,7 @@
 void Generic_GCC::GCCInstallationDetector::ScanLibDirForGCCTriple(
 const llvm::Triple , const ArgList ,
 const std::string , StringRef CandidateTriple,
-bool NeedsBiarchSuffix) {
+bool NeedsBiarchSuffix, bool GCCDirExists, bool GCCCrossDirExists) {
   llvm::Triple::ArchType TargetArch = TargetTriple.getArch();
   // Locations relative to the system lib directory where GCC's triple-specific
   // directories might reside.
@@ -2464,11 +2473,10 @@
 bool Active;
   } Suffixes[] = {
   // This is the normal place.
-  {"gcc/" + CandidateTriple.str(), "../..", true},
+  {"gcc/" + CandidateTriple.str(), "../..", GCCDirExists},
 
   // Debian puts cross-compilers in gcc-cross.
-  {"gcc-cross/" + CandidateTriple.str(), "../..",
-   TargetTriple.getOS() != llvm::Triple::Solaris},
+  {"gcc-cross/" + CandidateTriple.str(), "../..", GCCCrossDirExists},
 
   // The Freescale PPC SDK has the gcc libraries in
   // /usr/lib//x.y.z so have a look there as well. Only do


Index: clang/lib/Driver/ToolChains/Gnu.h
===
--- clang/lib/Driver/ToolChains/Gnu.h
+++ clang/lib/Driver/ToolChains/Gnu.h
@@ -270,7 +270,8 @@
 const llvm::opt::ArgList ,
 const std::string ,
 StringRef CandidateTriple,
-bool NeedsBiarchSuffix = false);
+bool 

[PATCH] D88410: [clang][AVR] Improve avr-ld command line options

2020-09-28 Thread Ben Shi via Phabricator via cfe-commits
benshi001 updated this revision to Diff 294872.

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

https://reviews.llvm.org/D88410

Files:
  clang/lib/Driver/ToolChains/AVR.cpp
  clang/test/Driver/avr-link-mcu-family-unimplemented.c
  clang/test/Driver/avr-mmcu.c

Index: clang/test/Driver/avr-mmcu.c
===
--- clang/test/Driver/avr-mmcu.c
+++ clang/test/Driver/avr-mmcu.c
@@ -1,5 +1,81 @@
 // A test for the propagation of the -mmcu option to -cc1 and -cc1as
 
-// RUN: %clang -### -target avr -no-canonical-prefixes -mmcu=atmega328p -save-temps %s 2>&1 | FileCheck %s
-// CHECK: clang{{.*}} "-cc1" {{.*}} "-target-cpu" "atmega328p"
-// CHECK: clang{{.*}} "-cc1as" {{.*}} "-target-cpu" "atmega328p"
+// RUN: %clang -### -target avr -no-canonical-prefixes -mmcu=attiny11 -save-temps %s 2>&1 | FileCheck -check-prefix=CHECK0 %s
+// CHECK0: clang{{.*}} "-cc1" {{.*}} "-target-cpu" "attiny11"
+// CHECK0: clang{{.*}} "-cc1as" {{.*}} "-target-cpu" "attiny11"
+
+// RUN: %clang -### -target avr -no-canonical-prefixes -mmcu=at90s2313 -save-temps %s 2>&1 | FileCheck -check-prefix=CHECK1 %s
+// CHECK1: clang{{.*}} "-cc1" {{.*}} "-target-cpu" "at90s2313"
+// CHECK1: clang{{.*}} "-cc1as" {{.*}} "-target-cpu" "at90s2313"
+
+// RUN: %clang -### -target avr -no-canonical-prefixes -mmcu=at90s8515 -save-temps %s 2>&1 | FileCheck -check-prefix=CHECK2 %s
+// CHECK2: clang{{.*}} "-cc1" {{.*}} "-target-cpu" "at90s8515"
+// CHECK2: clang{{.*}} "-cc1as" {{.*}} "-target-cpu" "at90s8515"
+
+// RUN: %clang -### -target avr -no-canonical-prefixes -mmcu=attiny13a -save-temps %s 2>&1 | FileCheck -check-prefix=CHECK3 %s
+// CHECK3: clang{{.*}} "-cc1" {{.*}} "-target-cpu" "attiny13a"
+// CHECK3: clang{{.*}} "-cc1as" {{.*}} "-target-cpu" "attiny13a"
+
+// RUN: %clang -### -target avr -no-canonical-prefixes -mmcu=attiny88 -save-temps %s 2>&1 | FileCheck -check-prefix=CHECK4 %s
+// CHECK4: clang{{.*}} "-cc1" {{.*}} "-target-cpu" "attiny88"
+// CHECK4: clang{{.*}} "-cc1as" {{.*}} "-target-cpu" "attiny88"
+
+// RUN: %clang -### -target avr -no-canonical-prefixes -mmcu=attiny88 -save-temps %s 2>&1 | FileCheck -check-prefix=CHECK5 %s
+// CHECK5: clang{{.*}} "-cc1" {{.*}} "-target-cpu" "attiny88"
+// CHECK5: clang{{.*}} "-cc1as" {{.*}} "-target-cpu" "attiny88"
+
+// RUN: %clang -### -target avr -no-canonical-prefixes -mmcu=atmega8u2 -save-temps %s 2>&1 | FileCheck -check-prefix=CHECK6 %s
+// CHECK6: clang{{.*}} "-cc1" {{.*}} "-target-cpu" "atmega8u2"
+// CHECK6: clang{{.*}} "-cc1as" {{.*}} "-target-cpu" "atmega8u2"
+
+// RUN: %clang -### -target avr -no-canonical-prefixes -mmcu=atmega8u2 -save-temps %s 2>&1 | FileCheck -check-prefix=CHECK7 %s
+// CHECK7: clang{{.*}} "-cc1" {{.*}} "-target-cpu" "atmega8u2"
+// CHECK7: clang{{.*}} "-cc1as" {{.*}} "-target-cpu" "atmega8u2"
+
+// RUN: %clang -### -target avr -no-canonical-prefixes -mmcu=atmega8a -save-temps %s 2>&1 | FileCheck -check-prefix=CHECK8 %s
+// CHECK8: clang{{.*}} "-cc1" {{.*}} "-target-cpu" "atmega8a"
+// CHECK8: clang{{.*}} "-cc1as" {{.*}} "-target-cpu" "atmega8a"
+
+// RUN: %clang -### -target avr -no-canonical-prefixes -mmcu=atmega8a -save-temps %s 2>&1 | FileCheck -check-prefix=CHECK9 %s
+// CHECK9: clang{{.*}} "-cc1" {{.*}} "-target-cpu" "atmega8a"
+// CHECK9: clang{{.*}} "-cc1as" {{.*}} "-target-cpu" "atmega8a"
+
+// RUN: %clang -### -target avr -no-canonical-prefixes -mmcu=atmega16a -save-temps %s 2>&1 | FileCheck -check-prefix=CHECKa %s
+// CHECKa: clang{{.*}} "-cc1" {{.*}} "-target-cpu" "atmega16a"
+// CHECKa: clang{{.*}} "-cc1as" {{.*}} "-target-cpu" "atmega16a"
+
+// RUN: %clang -### -target avr -no-canonical-prefixes -mmcu=atmega16a -save-temps %s 2>&1 | FileCheck -check-prefix=CHECKb %s
+// CHECKb: clang{{.*}} "-cc1" {{.*}} "-target-cpu" "atmega16a"
+// CHECKb: clang{{.*}} "-cc1as" {{.*}} "-target-cpu" "atmega16a"
+
+// RUN: %clang -### -target avr -no-canonical-prefixes -mmcu=atmega128a -save-temps %s 2>&1 | FileCheck -check-prefix=CHECKc %s
+// CHECKc: clang{{.*}} "-cc1" {{.*}} "-target-cpu" "atmega128a"
+// CHECKc: clang{{.*}} "-cc1as" {{.*}} "-target-cpu" "atmega128a"
+
+// RUN: %clang -### -target avr -no-canonical-prefixes -mmcu=atmega2560 -save-temps %s 2>&1 | FileCheck -check-prefix=CHECKd %s
+// CHECKd: clang{{.*}} "-cc1" {{.*}} "-target-cpu" "atmega2560"
+// CHECKd: clang{{.*}} "-cc1as" {{.*}} "-target-cpu" "atmega2560"
+
+// RUN: %clang -### -target avr -no-canonical-prefixes -mmcu=attiny10 -save-temps %s 2>&1 | FileCheck -check-prefix=CHECKe %s
+// CHECKe: clang{{.*}} "-cc1" {{.*}} "-target-cpu" "attiny10"
+// CHECKe: clang{{.*}} "-cc1as" {{.*}} "-target-cpu" "attiny10"
+
+// RUN: %clang -### -target avr -no-canonical-prefixes -mmcu=atxmega16a4 -save-temps %s 2>&1 | FileCheck -check-prefix=CHECKf %s
+// CHECKf: clang{{.*}} "-cc1" {{.*}} "-target-cpu" "atxmega16a4"
+// CHECKf: clang{{.*}} "-cc1as" {{.*}} "-target-cpu" "atxmega16a4"
+
+// RUN: %clang -### -target avr -no-canonical-prefixes 

[clang] 187658b - Recommit "[HIP] Change default --gpu-max-threads-per-block value to 1024"

2020-09-28 Thread Yaxun Liu via cfe-commits

Author: Yaxun (Sam) Liu
Date: 2020-09-28T22:43:17-04:00
New Revision: 187658b8a6112446d9e7797d495bc7542ac83905

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

LOG: Recommit "[HIP] Change default --gpu-max-threads-per-block value to 1024"

Recommit 04abbb3a78186aa92809866b43217c32cba90b71

Added: 


Modified: 
clang/include/clang/Basic/LangOptions.def
clang/lib/CodeGen/TargetInfo.cpp
clang/test/CodeGenCUDA/amdgpu-kernel-attrs.cu
clang/test/CodeGenCUDA/kernel-amdgcn.cu

Removed: 




diff  --git a/clang/include/clang/Basic/LangOptions.def 
b/clang/include/clang/Basic/LangOptions.def
index 9846809763f8..3132e7635418 100644
--- a/clang/include/clang/Basic/LangOptions.def
+++ b/clang/include/clang/Basic/LangOptions.def
@@ -240,7 +240,7 @@ LANGOPT(CUDAHostDeviceConstexpr, 1, 1, "treating 
unattributed constexpr function
 LANGOPT(CUDADeviceApproxTranscendentals, 1, 0, "using approximate 
transcendental functions")
 LANGOPT(GPURelocatableDeviceCode, 1, 0, "generate relocatable device code")
 LANGOPT(GPUAllowDeviceInit, 1, 0, "allowing device side global init functions 
for HIP")
-LANGOPT(GPUMaxThreadsPerBlock, 32, 256, "default max threads per block for 
kernel launch bounds for HIP")
+LANGOPT(GPUMaxThreadsPerBlock, 32, 1024, "default max threads per block for 
kernel launch bounds for HIP")
 
 LANGOPT(SYCL  , 1, 0, "SYCL")
 LANGOPT(SYCLIsDevice  , 1, 0, "Generate code for SYCL device")

diff  --git a/clang/lib/CodeGen/TargetInfo.cpp 
b/clang/lib/CodeGen/TargetInfo.cpp
index 6e15cac7359e..5c052b7fb84b 100644
--- a/clang/lib/CodeGen/TargetInfo.cpp
+++ b/clang/lib/CodeGen/TargetInfo.cpp
@@ -9060,9 +9060,13 @@ void AMDGPUTargetCodeGenInfo::setTargetAttributes(
   assert(Max == 0 && "Max must be zero");
   } else if (IsOpenCLKernel || IsHIPKernel) {
 // By default, restrict the maximum size to a value specified by
-// --gpu-max-threads-per-block=n or its default value.
+// --gpu-max-threads-per-block=n or its default value for HIP.
+const unsigned OpenCLDefaultMaxWorkGroupSize = 256;
+const unsigned DefaultMaxWorkGroupSize =
+IsOpenCLKernel ? OpenCLDefaultMaxWorkGroupSize
+   : M.getLangOpts().GPUMaxThreadsPerBlock;
 std::string AttrVal =
-std::string("1,") + 
llvm::utostr(M.getLangOpts().GPUMaxThreadsPerBlock);
+std::string("1,") + llvm::utostr(DefaultMaxWorkGroupSize);
 F->addFnAttr("amdgpu-flat-work-group-size", AttrVal);
   }
 

diff  --git a/clang/test/CodeGenCUDA/amdgpu-kernel-attrs.cu 
b/clang/test/CodeGenCUDA/amdgpu-kernel-attrs.cu
index 5415bddffc89..7a9fd2527272 100644
--- a/clang/test/CodeGenCUDA/amdgpu-kernel-attrs.cu
+++ b/clang/test/CodeGenCUDA/amdgpu-kernel-attrs.cu
@@ -39,7 +39,7 @@ __global__ void num_vgpr_64() {
 // NAMD-NOT: "amdgpu-num-vgpr"
 // NAMD-NOT: "amdgpu-num-sgpr"
 
-// DEFAULT-DAG: attributes [[FLAT_WORK_GROUP_SIZE_DEFAULT]] = 
{{.*}}"amdgpu-flat-work-group-size"="1,256"{{.*}}"uniform-work-group-size"="true"
+// DEFAULT-DAG: attributes [[FLAT_WORK_GROUP_SIZE_DEFAULT]] = 
{{.*}}"amdgpu-flat-work-group-size"="1,1024"{{.*}}"uniform-work-group-size"="true"
 // MAX1024-DAG: attributes [[FLAT_WORK_GROUP_SIZE_DEFAULT]] = 
{{.*}}"amdgpu-flat-work-group-size"="1,1024"
 // CHECK-DAG: attributes [[FLAT_WORK_GROUP_SIZE_32_64]] = 
{{.*}}"amdgpu-flat-work-group-size"="32,64"
 // CHECK-DAG: attributes [[WAVES_PER_EU_2]] = {{.*}}"amdgpu-waves-per-eu"="2"

diff  --git a/clang/test/CodeGenCUDA/kernel-amdgcn.cu 
b/clang/test/CodeGenCUDA/kernel-amdgcn.cu
index 135d3030480c..6066469f7647 100644
--- a/clang/test/CodeGenCUDA/kernel-amdgcn.cu
+++ b/clang/test/CodeGenCUDA/kernel-amdgcn.cu
@@ -39,4 +39,4 @@ int main() {
   launch((void*)D.Empty());
   return 0;
 }
-// CHECK: attributes #[[ATTR]] = {{.*}}"amdgpu-flat-work-group-size"="1,256"
+// CHECK: attributes #[[ATTR]] = {{.*}}"amdgpu-flat-work-group-size"="1,1024"



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


[PATCH] D88463: [clangd] Try harder to get accurate ranges for documentSymbols in macros

2020-09-28 Thread Nathan Ridge via Phabricator via cfe-commits
nridge created this revision.
Herald added subscribers: cfe-commits, usaxena95, kadircet, arphaman.
Herald added a project: clang.
nridge requested review of this revision.
Herald added subscribers: MaskRay, ilya-biryukov.

Fixes https://github.com/clangd/clangd/issues/500


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D88463

Files:
  clang-tools-extra/clangd/FindSymbols.cpp
  clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp

Index: clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
+++ clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
@@ -36,6 +36,7 @@
 MATCHER_P(WithName, N, "") { return arg.name == N; }
 MATCHER_P(WithKind, Kind, "") { return arg.kind == Kind; }
 MATCHER_P(SymRange, Range, "") { return arg.range == Range; }
+MATCHER_P(SymRangeContains, Range, "") { return arg.range.contains(Range); }
 
 // GMock helpers for matching DocumentSymbol.
 MATCHER_P(SymNameRange, Range, "") { return arg.selectionRange == Range; }
@@ -613,19 +614,28 @@
 #define FF(name) \
   class name##_Test {};
 
-$expansion[[FF]](abc);
+$expansion1[[FF]](abc);
 
 #define FF2() \
-  class $spelling[[Test]] {};
+  class Test {};
 
-FF2();
+$expansion2[[FF2]]();
+
+#define FF3() \
+  void waldo()
+
+FF3() {
+  $bodyStatement[[int var = 42;]]
+}  
   )");
   TU.Code = Main.code().str();
   EXPECT_THAT(
   getSymbols(TU.build()),
   ElementsAre(
-  AllOf(WithName("abc_Test"), SymNameRange(Main.range("expansion"))),
-  AllOf(WithName("Test"), SymNameRange(Main.range("spelling");
+  AllOf(WithName("abc_Test"), SymNameRange(Main.range("expansion1"))),
+  AllOf(WithName("Test"), SymNameRange(Main.range("expansion2"))),
+  AllOf(WithName("waldo"),
+SymRangeContains(Main.range("bodyStatement");
 }
 
 TEST(DocumentSymbols, FuncTemplates) {
Index: clang-tools-extra/clangd/FindSymbols.cpp
===
--- clang-tools-extra/clangd/FindSymbols.cpp
+++ clang-tools-extra/clangd/FindSymbols.cpp
@@ -132,7 +132,6 @@
 llvm::Optional declToSym(ASTContext , const NamedDecl ) {
   auto  = Ctx.getSourceManager();
 
-  SourceLocation NameLoc = nameLocation(ND, SM);
   SourceLocation BeginLoc = SM.getSpellingLoc(SM.getFileLoc(ND.getBeginLoc()));
   SourceLocation EndLoc = SM.getSpellingLoc(SM.getFileLoc(ND.getEndLoc()));
   const auto SymbolRange =
@@ -140,10 +139,6 @@
   if (!SymbolRange)
 return llvm::None;
 
-  Position NameBegin = sourceLocToPosition(SM, NameLoc);
-  Position NameEnd = sourceLocToPosition(
-  SM, Lexer::getLocForEndOfToken(NameLoc, 0, SM, Ctx.getLangOpts()));
-
   index::SymbolInfo SymInfo = index::getSymbolInfo();
   // FIXME: this is not classifying constructors, destructors and operators
   //correctly (they're all "methods").
@@ -155,10 +150,34 @@
   SI.deprecated = ND.isDeprecated();
   SI.range = Range{sourceLocToPosition(SM, SymbolRange->getBegin()),
sourceLocToPosition(SM, SymbolRange->getEnd())};
-  SI.selectionRange = Range{NameBegin, NameEnd};
+
+  SourceLocation Loc = ND.getLocation();
+  SourceLocation NameLoc;
+  SourceLocation FallbackNameLoc;
+  if (isSpelledInSource(Loc, SM)) {
+// Prefer the spelling loc, but save the expansion loc as a fallback.
+NameLoc = SM.getSpellingLoc(Loc);
+FallbackNameLoc = SM.getExpansionLoc(Loc);
+  } else {
+NameLoc = SM.getExpansionLoc(Loc);
+  }
+  auto ComputeSelectionRange = [&](SourceLocation L) -> Range {
+Position NameBegin = sourceLocToPosition(SM, L);
+Position NameEnd = sourceLocToPosition(
+SM, Lexer::getLocForEndOfToken(L, 0, SM, Ctx.getLangOpts()));
+return Range{NameBegin, NameEnd};
+  };
+
+  SI.selectionRange = ComputeSelectionRange(NameLoc);
+  if (!SI.range.contains(SI.selectionRange) && FallbackNameLoc.isValid()) {
+// 'selectionRange' must be contained in 'range'. In cases where clang
+// reports unrelated ranges, we first try falling back to the expansion
+// loc for the selection range.
+SI.selectionRange = ComputeSelectionRange(FallbackNameLoc);
+  }
   if (!SI.range.contains(SI.selectionRange)) {
-// 'selectionRange' must be contained in 'range', so in cases where clang
-// reports unrelated ranges we need to reconcile somehow.
+// If the containment relationship still doesn't hold, throw away
+// 'range' and use 'selectionRange' for both.
 SI.range = SI.selectionRange;
   }
   return SI;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 10eb3bf - Skip -fPIE for AMDGPU and HIP toolchain

2020-09-28 Thread Yaxun Liu via cfe-commits

Author: Yaxun (Sam) Liu
Date: 2020-09-28T22:03:18-04:00
New Revision: 10eb3bf2d430825195bf092d3a75c4745d463826

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

LOG: Skip -fPIE for AMDGPU and HIP toolchain

AMDGPU toolchain does not support -fPIE, therefore skip it if specified by 
driver.

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

Added: 
clang/test/Driver/hip-fpie-option.hip

Modified: 
clang/lib/Driver/ToolChains/AMDGPU.cpp
clang/lib/Driver/ToolChains/AMDGPU.h
clang/lib/Driver/ToolChains/HIP.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/AMDGPU.cpp 
b/clang/lib/Driver/ToolChains/AMDGPU.cpp
index 3616310c37bf..61254e3eeaef 100644
--- a/clang/lib/Driver/ToolChains/AMDGPU.cpp
+++ b/clang/lib/Driver/ToolChains/AMDGPU.cpp
@@ -427,8 +427,11 @@ AMDGPUToolChain::TranslateArgs(const DerivedArgList , 
StringRef BoundArch,
 
   if (!DAL)
 DAL = new DerivedArgList(Args.getBaseArgs());
-  for (auto *A : Args)
-DAL->append(A);
+
+  for (Arg *A : Args) {
+if (!shouldSkipArgument(A))
+  DAL->append(A);
+  }
 
   if (!Args.getLastArgValue(options::OPT_x).equals("cl"))
 return DAL;
@@ -644,3 +647,10 @@ void RocmInstallationDetector::addCommonBitcodeLibCC1Args(
   CC1Args.push_back(LinkBitcodeFlag);
   CC1Args.push_back(DriverArgs.MakeArgString(LibDeviceFile));
 }
+
+bool AMDGPUToolChain::shouldSkipArgument(const llvm::opt::Arg *A) const {
+  Option O = A->getOption();
+  if (O.matches(options::OPT_fPIE) || O.matches(options::OPT_fpie))
+return true;
+  return false;
+}

diff  --git a/clang/lib/Driver/ToolChains/AMDGPU.h 
b/clang/lib/Driver/ToolChains/AMDGPU.h
index 751116f2471f..0a91499c0cbf 100644
--- a/clang/lib/Driver/ToolChains/AMDGPU.h
+++ b/clang/lib/Driver/ToolChains/AMDGPU.h
@@ -90,6 +90,9 @@ class LLVM_LIBRARY_VISIBILITY AMDGPUToolChain : public 
Generic_ELF {
   /// Needed for translating LTO options.
   const char *getDefaultLinker() const override { return "ld.lld"; }
 
+  /// Should skip argument.
+  bool shouldSkipArgument(const llvm::opt::Arg *Arg) const;
+
 protected:
   /// Translate -mcpu option containing target ID to cc1 options.
   /// Returns the GPU name.

diff  --git a/clang/lib/Driver/ToolChains/HIP.cpp 
b/clang/lib/Driver/ToolChains/HIP.cpp
index 43e557c98050..78f53204bd8c 100644
--- a/clang/lib/Driver/ToolChains/HIP.cpp
+++ b/clang/lib/Driver/ToolChains/HIP.cpp
@@ -341,7 +341,8 @@ HIPToolChain::TranslateArgs(const llvm::opt::DerivedArgList 
,
   const OptTable  = getDriver().getOpts();
 
   for (Arg *A : Args) {
-DAL->append(A);
+if (!shouldSkipArgument(A))
+  DAL->append(A);
   }
 
   if (!BoundArch.empty()) {

diff  --git a/clang/test/Driver/hip-fpie-option.hip 
b/clang/test/Driver/hip-fpie-option.hip
new file mode 100644
index ..2b433cd5a2c2
--- /dev/null
+++ b/clang/test/Driver/hip-fpie-option.hip
@@ -0,0 +1,38 @@
+// REQUIRES: clang-driver, amdgpu-registered-target
+
+// -fPIC and -fPIE only affects host relocation model.
+// device compilation always uses PIC. 
+
+// RUN: %clang -### -target x86_64-unknown-linux-gnu \
+// RUN:   --offload-arch=gfx906 %s -nogpulib -nogpuinc \
+// RUN:   2>&1 | FileCheck -check-prefixes=DEV,HOST-STATIC %s
+
+// RUN: %clang -### -target x86_64-unknown-linux-gnu \
+// RUN:   -fgpu-rdc --offload-arch=gfx906 %s -nogpulib -nogpuinc \
+// RUN:   2>&1 | FileCheck -check-prefixes=DEV,HOST-STATIC %s
+
+// RUN: %clang -### -target x86_64-unknown-linux-gnu \
+// RUN:   --offload-arch=gfx906 %s -nogpulib -nogpuinc \
+// RUN:   -fPIC \
+// RUN:   2>&1 | FileCheck -check-prefixes=DEV,HOST-PIC %s
+
+// RUN: %clang -### -target x86_64-unknown-linux-gnu \
+// RUN:   -fgpu-rdc --offload-arch=gfx906 %s -nogpulib -nogpuinc \
+// RUN:   -fPIC \
+// RUN:   2>&1 | FileCheck -check-prefixes=DEV,HOST-PIC %s
+
+// RUN: %clang -### -target x86_64-unknown-linux-gnu \
+// RUN:   --offload-arch=gfx906 %s -nogpulib -nogpuinc \
+// RUN:   -fPIE \
+// RUN:   2>&1 | FileCheck -check-prefixes=DEV,HOST-PIE %s
+
+// RUN: %clang -### -target x86_64-unknown-linux-gnu \
+// RUN:   -fgpu-rdc --offload-arch=gfx906 %s -nogpulib -nogpuinc \
+// RUN:   -fPIE \
+// RUN:   2>&1 | FileCheck -check-prefixes=DEV,HOST-PIE %s
+
+// DEV-DAG: {{".*clang.*".* "-triple" "amdgcn-amd-amdhsa".* 
"-mrelocation-model" "pic" "-pic-level" "[1|2]" "-mframe-pointer=all"}}
+// HOST-STATIC-DAG: {{".*clang.*".* "-triple" "x86_64-unknown-linux-gnu".* 
"-mrelocation-model" "static"}}
+// HOST-PIC-DAG: {{".*clang.*".* "-triple" "x86_64-unknown-linux-gnu".* 
"-mrelocation-model" "pic" "-pic-level" "2" "-mframe-pointer=all"}}
+// HOST-PIE-DAG: {{".*clang.*".* "-triple" "x86_64-unknown-linux-gnu".* 
"-mrelocation-model" "pic" "-pic-level" "2" "-pic-is-pie"}}
+// DEV-NOT: {{".*clang.*".* "-triple" "amdgcn-amd-amdhsa".* 

[PATCH] D88425: Skip -fPIE for AMDGPU and HIP toolchain

2020-09-28 Thread Yaxun Liu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
yaxunl marked an inline comment as done.
Closed by commit rG10eb3bf2d430: Skip -fPIE for AMDGPU and HIP toolchain 
(authored by yaxunl).
Herald added a project: clang.

Changed prior to commit:
  https://reviews.llvm.org/D88425?vs=294724=294867#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88425

Files:
  clang/lib/Driver/ToolChains/AMDGPU.cpp
  clang/lib/Driver/ToolChains/AMDGPU.h
  clang/lib/Driver/ToolChains/HIP.cpp
  clang/test/Driver/hip-fpie-option.hip


Index: clang/test/Driver/hip-fpie-option.hip
===
--- /dev/null
+++ clang/test/Driver/hip-fpie-option.hip
@@ -0,0 +1,38 @@
+// REQUIRES: clang-driver, amdgpu-registered-target
+
+// -fPIC and -fPIE only affects host relocation model.
+// device compilation always uses PIC. 
+
+// RUN: %clang -### -target x86_64-unknown-linux-gnu \
+// RUN:   --offload-arch=gfx906 %s -nogpulib -nogpuinc \
+// RUN:   2>&1 | FileCheck -check-prefixes=DEV,HOST-STATIC %s
+
+// RUN: %clang -### -target x86_64-unknown-linux-gnu \
+// RUN:   -fgpu-rdc --offload-arch=gfx906 %s -nogpulib -nogpuinc \
+// RUN:   2>&1 | FileCheck -check-prefixes=DEV,HOST-STATIC %s
+
+// RUN: %clang -### -target x86_64-unknown-linux-gnu \
+// RUN:   --offload-arch=gfx906 %s -nogpulib -nogpuinc \
+// RUN:   -fPIC \
+// RUN:   2>&1 | FileCheck -check-prefixes=DEV,HOST-PIC %s
+
+// RUN: %clang -### -target x86_64-unknown-linux-gnu \
+// RUN:   -fgpu-rdc --offload-arch=gfx906 %s -nogpulib -nogpuinc \
+// RUN:   -fPIC \
+// RUN:   2>&1 | FileCheck -check-prefixes=DEV,HOST-PIC %s
+
+// RUN: %clang -### -target x86_64-unknown-linux-gnu \
+// RUN:   --offload-arch=gfx906 %s -nogpulib -nogpuinc \
+// RUN:   -fPIE \
+// RUN:   2>&1 | FileCheck -check-prefixes=DEV,HOST-PIE %s
+
+// RUN: %clang -### -target x86_64-unknown-linux-gnu \
+// RUN:   -fgpu-rdc --offload-arch=gfx906 %s -nogpulib -nogpuinc \
+// RUN:   -fPIE \
+// RUN:   2>&1 | FileCheck -check-prefixes=DEV,HOST-PIE %s
+
+// DEV-DAG: {{".*clang.*".* "-triple" "amdgcn-amd-amdhsa".* 
"-mrelocation-model" "pic" "-pic-level" "[1|2]" "-mframe-pointer=all"}}
+// HOST-STATIC-DAG: {{".*clang.*".* "-triple" "x86_64-unknown-linux-gnu".* 
"-mrelocation-model" "static"}}
+// HOST-PIC-DAG: {{".*clang.*".* "-triple" "x86_64-unknown-linux-gnu".* 
"-mrelocation-model" "pic" "-pic-level" "2" "-mframe-pointer=all"}}
+// HOST-PIE-DAG: {{".*clang.*".* "-triple" "x86_64-unknown-linux-gnu".* 
"-mrelocation-model" "pic" "-pic-level" "2" "-pic-is-pie"}}
+// DEV-NOT: {{".*clang.*".* "-triple" "amdgcn-amd-amdhsa".* "-pic-is-pie"}}
Index: clang/lib/Driver/ToolChains/HIP.cpp
===
--- clang/lib/Driver/ToolChains/HIP.cpp
+++ clang/lib/Driver/ToolChains/HIP.cpp
@@ -341,7 +341,8 @@
   const OptTable  = getDriver().getOpts();
 
   for (Arg *A : Args) {
-DAL->append(A);
+if (!shouldSkipArgument(A))
+  DAL->append(A);
   }
 
   if (!BoundArch.empty()) {
Index: clang/lib/Driver/ToolChains/AMDGPU.h
===
--- clang/lib/Driver/ToolChains/AMDGPU.h
+++ clang/lib/Driver/ToolChains/AMDGPU.h
@@ -90,6 +90,9 @@
   /// Needed for translating LTO options.
   const char *getDefaultLinker() const override { return "ld.lld"; }
 
+  /// Should skip argument.
+  bool shouldSkipArgument(const llvm::opt::Arg *Arg) const;
+
 protected:
   /// Translate -mcpu option containing target ID to cc1 options.
   /// Returns the GPU name.
Index: clang/lib/Driver/ToolChains/AMDGPU.cpp
===
--- clang/lib/Driver/ToolChains/AMDGPU.cpp
+++ clang/lib/Driver/ToolChains/AMDGPU.cpp
@@ -427,8 +427,11 @@
 
   if (!DAL)
 DAL = new DerivedArgList(Args.getBaseArgs());
-  for (auto *A : Args)
-DAL->append(A);
+
+  for (Arg *A : Args) {
+if (!shouldSkipArgument(A))
+  DAL->append(A);
+  }
 
   if (!Args.getLastArgValue(options::OPT_x).equals("cl"))
 return DAL;
@@ -644,3 +647,10 @@
   CC1Args.push_back(LinkBitcodeFlag);
   CC1Args.push_back(DriverArgs.MakeArgString(LibDeviceFile));
 }
+
+bool AMDGPUToolChain::shouldSkipArgument(const llvm::opt::Arg *A) const {
+  Option O = A->getOption();
+  if (O.matches(options::OPT_fPIE) || O.matches(options::OPT_fpie))
+return true;
+  return false;
+}


Index: clang/test/Driver/hip-fpie-option.hip
===
--- /dev/null
+++ clang/test/Driver/hip-fpie-option.hip
@@ -0,0 +1,38 @@
+// REQUIRES: clang-driver, amdgpu-registered-target
+
+// -fPIC and -fPIE only affects host relocation model.
+// device compilation always uses PIC. 
+
+// RUN: %clang -### -target x86_64-unknown-linux-gnu \
+// RUN:   --offload-arch=gfx906 %s -nogpulib -nogpuinc \
+// RUN:   2>&1 | FileCheck 

[PATCH] D88462: FP math settings for static duration initialization - work in progress

2020-09-28 Thread Melanie Blower via Phabricator via cfe-commits
mibintc created this revision.
mibintc added a reviewer: sepavloff.
mibintc added a project: clang.
mibintc requested review of this revision.

When compiling this C test case with -frounding-math there is an error 
diagnostic due to the rounding

  float F3d = 0x1.01p0;

This patch resets the FP settings around the initialization expression


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D88462

Files:
  clang/lib/Parse/ParseDecl.cpp


Index: clang/lib/Parse/ParseDecl.cpp
===
--- clang/lib/Parse/ParseDecl.cpp
+++ clang/lib/Parse/ParseDecl.cpp
@@ -2178,8 +2178,23 @@
 }
 P.Actions.ActOnCXXEnterDeclInitializer(S, ThisDecl);
   }
+  auto ThisVarDecl = dyn_cast_or_null(ThisDecl);
+  if (ThisVarDecl) {
+FPOptionsOverride NewFPFeatures;
+
NewFPFeatures.setRoundingModeOverride(llvm::RoundingMode::NearestTiesToEven);
+P.Actions.FpPragmaStack.Act(ThisDecl->getLocation(),
+  Sema::PSK_Push_Set, StringRef(), NewFPFeatures);
+  }
+}
+~InitializerScopeRAII() {
+  pop();
+  auto ThisVarDecl = dyn_cast_or_null(ThisDecl);
+  if (ThisVarDecl) {
+FPOptionsOverride NewFPFeatures;
+P.Actions.FpPragmaStack.Act(SourceLocation(),
+Sema::PSK_Pop, StringRef(), NewFPFeatures);
+  }
 }
-~InitializerScopeRAII() { pop(); }
 void pop() {
   if (ThisDecl && P.getLangOpts().CPlusPlus) {
 Scope *S = nullptr;


Index: clang/lib/Parse/ParseDecl.cpp
===
--- clang/lib/Parse/ParseDecl.cpp
+++ clang/lib/Parse/ParseDecl.cpp
@@ -2178,8 +2178,23 @@
 }
 P.Actions.ActOnCXXEnterDeclInitializer(S, ThisDecl);
   }
+  auto ThisVarDecl = dyn_cast_or_null(ThisDecl);
+  if (ThisVarDecl) {
+FPOptionsOverride NewFPFeatures;
+NewFPFeatures.setRoundingModeOverride(llvm::RoundingMode::NearestTiesToEven);
+P.Actions.FpPragmaStack.Act(ThisDecl->getLocation(),
+  Sema::PSK_Push_Set, StringRef(), NewFPFeatures);
+  }
+}
+~InitializerScopeRAII() {
+  pop();
+  auto ThisVarDecl = dyn_cast_or_null(ThisDecl);
+  if (ThisVarDecl) {
+FPOptionsOverride NewFPFeatures;
+P.Actions.FpPragmaStack.Act(SourceLocation(),
+Sema::PSK_Pop, StringRef(), NewFPFeatures);
+  }
 }
-~InitializerScopeRAII() { pop(); }
 void pop() {
   if (ThisDecl && P.getLangOpts().CPlusPlus) {
 Scope *S = nullptr;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D86841: [clang] Add mustprogress and llvm.loop.mustprogress attribute deduction

2020-09-28 Thread Atmn Patel via Phabricator via cfe-commits
atmnpatel updated this revision to Diff 294864.
atmnpatel added a comment.

more fixes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86841

Files:
  clang/lib/CodeGen/CGLoopInfo.cpp
  clang/lib/CodeGen/CGLoopInfo.h
  clang/lib/CodeGen/CGStmt.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/test/CodeGen/address-safety-attr-flavors.cpp
  clang/test/CodeGen/address-safety-attr.cpp
  clang/test/CodeGen/attr-mustprogress-0.c
  clang/test/CodeGen/attr-mustprogress-0.cpp
  clang/test/CodeGen/attr-mustprogress-1.c
  clang/test/CodeGen/attr-mustprogress-1.cpp
  clang/test/CodeGen/memtag-attr.cpp
  clang/test/CodeGen/no-builtin.cpp
  clang/test/CodeGen/pragma-do-while.cpp
  clang/test/CodeGenCXX/cxx11-trivial-initializer-struct.cpp
  clang/test/CodeGenCXX/debug-info-line-if.cpp
  clang/test/CodeGenCXX/debug-info-loops.cpp
  clang/test/CodeGenCXX/fno-unroll-loops-metadata.cpp
  clang/test/CodeGenCXX/pragma-followup_inner.cpp
  clang/test/CodeGenCXX/pragma-followup_outer.cpp
  clang/test/CodeGenCXX/pragma-loop-distribute.cpp
  clang/test/CodeGenCXX/pragma-loop-pr27643.cpp
  clang/test/CodeGenCXX/pragma-loop-predicate.cpp
  clang/test/CodeGenCXX/pragma-loop-safety-imperfectly_nested.cpp
  clang/test/CodeGenCXX/pragma-loop-safety-nested.cpp
  clang/test/CodeGenCXX/pragma-loop-safety-outer.cpp
  clang/test/CodeGenCXX/pragma-loop-safety.cpp
  clang/test/CodeGenCXX/pragma-loop.cpp
  clang/test/CodeGenCXX/pragma-pipeline.cpp
  clang/test/CodeGenCXX/pragma-unroll-and-jam.cpp
  clang/test/CodeGenCXX/pragma-unroll.cpp
  clang/test/CodeGenCXX/thunks-ehspec.cpp
  clang/test/CodeGenCXX/thunks.cpp
  clang/test/OpenMP/simd_metadata.c
  clang/test/Profile/c-unprofiled-blocks.c
  clang/test/utils/update_cc_test_checks/Inputs/basic-cplusplus.cpp.expected
  
clang/test/utils/update_cc_test_checks/Inputs/check-attributes.cpp.funcattrs.expected
  
clang/test/utils/update_cc_test_checks/Inputs/generated-funcs.c.generated.expected
  
clang/test/utils/update_cc_test_checks/Inputs/generated-funcs.c.no-generated.expected

Index: clang/test/utils/update_cc_test_checks/Inputs/generated-funcs.c.no-generated.expected
===
--- clang/test/utils/update_cc_test_checks/Inputs/generated-funcs.c.no-generated.expected
+++ clang/test/utils/update_cc_test_checks/Inputs/generated-funcs.c.no-generated.expected
@@ -41,7 +41,7 @@
 // NOOMP-NEXT:[[TMP2:%.*]] = load i32, i32* [[I]], align 4
 // NOOMP-NEXT:[[INC:%.*]] = add nsw i32 [[TMP2]], 1
 // NOOMP-NEXT:store i32 [[INC]], i32* [[I]], align 4
-// NOOMP-NEXT:br label [[FOR_COND]]
+// NOOMP-NEXT:br label [[FOR_COND]], [[LOOP2:!llvm.loop !.*]]
 // NOOMP:   for.end:
 // NOOMP-NEXT:call void @foo()
 // NOOMP-NEXT:ret i32 0
@@ -86,7 +86,7 @@
 // NOOMP-NEXT:[[TMP2:%.*]] = load i32, i32* [[I]], align 4
 // NOOMP-NEXT:[[INC:%.*]] = add nsw i32 [[TMP2]], 1
 // NOOMP-NEXT:store i32 [[INC]], i32* [[I]], align 4
-// NOOMP-NEXT:br label [[FOR_COND]]
+// NOOMP-NEXT:br label [[FOR_COND]], [[LOOP4:!llvm.loop !.*]]
 // NOOMP:   for.end:
 // NOOMP-NEXT:ret void
 //
Index: clang/test/utils/update_cc_test_checks/Inputs/generated-funcs.c.generated.expected
===
--- clang/test/utils/update_cc_test_checks/Inputs/generated-funcs.c.generated.expected
+++ clang/test/utils/update_cc_test_checks/Inputs/generated-funcs.c.generated.expected
@@ -197,7 +197,7 @@
 // NOOMP-NEXT:[[TMP2:%.*]] = load i32, i32* [[I]], align 4
 // NOOMP-NEXT:[[INC:%.*]] = add nsw i32 [[TMP2]], 1
 // NOOMP-NEXT:store i32 [[INC]], i32* [[I]], align 4
-// NOOMP-NEXT:br label [[FOR_COND]]
+// NOOMP-NEXT:br label [[FOR_COND]], [[LOOP2:!llvm.loop !.*]]
 // NOOMP:   for.end:
 // NOOMP-NEXT:call void @foo()
 // NOOMP-NEXT:ret i32 0
@@ -223,7 +223,7 @@
 // NOOMP-NEXT:[[TMP2:%.*]] = load i32, i32* [[I]], align 4
 // NOOMP-NEXT:[[INC:%.*]] = add nsw i32 [[TMP2]], 1
 // NOOMP-NEXT:store i32 [[INC]], i32* [[I]], align 4
-// NOOMP-NEXT:br label [[FOR_COND]]
+// NOOMP-NEXT:br label [[FOR_COND]], [[LOOP4:!llvm.loop !.*]]
 // NOOMP:   for.end:
 // NOOMP-NEXT:ret void
 //
Index: clang/test/utils/update_cc_test_checks/Inputs/check-attributes.cpp.funcattrs.expected
===
--- clang/test/utils/update_cc_test_checks/Inputs/check-attributes.cpp.funcattrs.expected
+++ clang/test/utils/update_cc_test_checks/Inputs/check-attributes.cpp.funcattrs.expected
@@ -11,7 +11,7 @@
   struct RT Z;
 };
 
-// CHECK: Function Attrs: noinline nounwind optnone
+// CHECK: Function Attrs: noinline nounwind optnone mustprogress
 // CHECK-LABEL: @_Z3fooP2ST(
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:[[S_ADDR:%.*]] = alloca %struct.ST*, align 8
Index: 

[PATCH] D88410: [clang][AVR] Improve avr-ld command line options

2020-09-28 Thread Ben Shi via Phabricator via cfe-commits
benshi001 updated this revision to Diff 294854.
benshi001 edited the summary of this revision.

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

https://reviews.llvm.org/D88410

Files:
  clang/lib/Driver/ToolChains/AVR.cpp
  clang/test/Driver/avr-link-mcu-family-unimplemented.c
  clang/test/Driver/avr-mmcu.c

Index: clang/test/Driver/avr-mmcu.c
===
--- clang/test/Driver/avr-mmcu.c
+++ clang/test/Driver/avr-mmcu.c
@@ -1,5 +1,81 @@
 // A test for the propagation of the -mmcu option to -cc1 and -cc1as
 
-// RUN: %clang -### -target avr -no-canonical-prefixes -mmcu=atmega328p -save-temps %s 2>&1 | FileCheck %s
-// CHECK: clang{{.*}} "-cc1" {{.*}} "-target-cpu" "atmega328p"
-// CHECK: clang{{.*}} "-cc1as" {{.*}} "-target-cpu" "atmega328p"
+// RUN: %clang -### -target avr -no-canonical-prefixes -mmcu=attiny11 -save-temps %s 2>&1 | FileCheck -check-prefix=CHECK0 %s
+// CHECK0: clang{{.*}} "-cc1" {{.*}} "-target-cpu" "attiny11"
+// CHECK0: clang{{.*}} "-cc1as" {{.*}} "-target-cpu" "attiny11"
+
+// RUN: %clang -### -target avr -no-canonical-prefixes -mmcu=at90s2313 -save-temps %s 2>&1 | FileCheck -check-prefix=CHECK1 %s
+// CHECK1: clang{{.*}} "-cc1" {{.*}} "-target-cpu" "at90s2313"
+// CHECK1: clang{{.*}} "-cc1as" {{.*}} "-target-cpu" "at90s2313"
+
+// RUN: %clang -### -target avr -no-canonical-prefixes -mmcu=at90s8515 -save-temps %s 2>&1 | FileCheck -check-prefix=CHECK2 %s
+// CHECK2: clang{{.*}} "-cc1" {{.*}} "-target-cpu" "at90s8515"
+// CHECK2: clang{{.*}} "-cc1as" {{.*}} "-target-cpu" "at90s8515"
+
+// RUN: %clang -### -target avr -no-canonical-prefixes -mmcu=attiny13a -save-temps %s 2>&1 | FileCheck -check-prefix=CHECK3 %s
+// CHECK3: clang{{.*}} "-cc1" {{.*}} "-target-cpu" "attiny13a"
+// CHECK3: clang{{.*}} "-cc1as" {{.*}} "-target-cpu" "attiny13a"
+
+// RUN: %clang -### -target avr -no-canonical-prefixes -mmcu=attiny88 -save-temps %s 2>&1 | FileCheck -check-prefix=CHECK4 %s
+// CHECK4: clang{{.*}} "-cc1" {{.*}} "-target-cpu" "attiny88"
+// CHECK4: clang{{.*}} "-cc1as" {{.*}} "-target-cpu" "attiny88"
+
+// RUN: %clang -### -target avr -no-canonical-prefixes -mmcu=attiny88 -save-temps %s 2>&1 | FileCheck -check-prefix=CHECK5 %s
+// CHECK5: clang{{.*}} "-cc1" {{.*}} "-target-cpu" "attiny88"
+// CHECK5: clang{{.*}} "-cc1as" {{.*}} "-target-cpu" "attiny88"
+
+// RUN: %clang -### -target avr -no-canonical-prefixes -mmcu=atmega8u2 -save-temps %s 2>&1 | FileCheck -check-prefix=CHECK6 %s
+// CHECK6: clang{{.*}} "-cc1" {{.*}} "-target-cpu" "atmega8u2"
+// CHECK6: clang{{.*}} "-cc1as" {{.*}} "-target-cpu" "atmega8u2"
+
+// RUN: %clang -### -target avr -no-canonical-prefixes -mmcu=atmega8u2 -save-temps %s 2>&1 | FileCheck -check-prefix=CHECK7 %s
+// CHECK7: clang{{.*}} "-cc1" {{.*}} "-target-cpu" "atmega8u2"
+// CHECK7: clang{{.*}} "-cc1as" {{.*}} "-target-cpu" "atmega8u2"
+
+// RUN: %clang -### -target avr -no-canonical-prefixes -mmcu=atmega8a -save-temps %s 2>&1 | FileCheck -check-prefix=CHECK8 %s
+// CHECK8: clang{{.*}} "-cc1" {{.*}} "-target-cpu" "atmega8a"
+// CHECK8: clang{{.*}} "-cc1as" {{.*}} "-target-cpu" "atmega8a"
+
+// RUN: %clang -### -target avr -no-canonical-prefixes -mmcu=atmega8a -save-temps %s 2>&1 | FileCheck -check-prefix=CHECK9 %s
+// CHECK9: clang{{.*}} "-cc1" {{.*}} "-target-cpu" "atmega8a"
+// CHECK9: clang{{.*}} "-cc1as" {{.*}} "-target-cpu" "atmega8a"
+
+// RUN: %clang -### -target avr -no-canonical-prefixes -mmcu=atmega16a -save-temps %s 2>&1 | FileCheck -check-prefix=CHECKa %s
+// CHECKa: clang{{.*}} "-cc1" {{.*}} "-target-cpu" "atmega16a"
+// CHECKa: clang{{.*}} "-cc1as" {{.*}} "-target-cpu" "atmega16a"
+
+// RUN: %clang -### -target avr -no-canonical-prefixes -mmcu=atmega16a -save-temps %s 2>&1 | FileCheck -check-prefix=CHECKb %s
+// CHECKb: clang{{.*}} "-cc1" {{.*}} "-target-cpu" "atmega16a"
+// CHECKb: clang{{.*}} "-cc1as" {{.*}} "-target-cpu" "atmega16a"
+
+// RUN: %clang -### -target avr -no-canonical-prefixes -mmcu=atmega128a -save-temps %s 2>&1 | FileCheck -check-prefix=CHECKc %s
+// CHECKc: clang{{.*}} "-cc1" {{.*}} "-target-cpu" "atmega128a"
+// CHECKc: clang{{.*}} "-cc1as" {{.*}} "-target-cpu" "atmega128a"
+
+// RUN: %clang -### -target avr -no-canonical-prefixes -mmcu=atmega2560 -save-temps %s 2>&1 | FileCheck -check-prefix=CHECKd %s
+// CHECKd: clang{{.*}} "-cc1" {{.*}} "-target-cpu" "atmega2560"
+// CHECKd: clang{{.*}} "-cc1as" {{.*}} "-target-cpu" "atmega2560"
+
+// RUN: %clang -### -target avr -no-canonical-prefixes -mmcu=attiny10 -save-temps %s 2>&1 | FileCheck -check-prefix=CHECKe %s
+// CHECKe: clang{{.*}} "-cc1" {{.*}} "-target-cpu" "attiny10"
+// CHECKe: clang{{.*}} "-cc1as" {{.*}} "-target-cpu" "attiny10"
+
+// RUN: %clang -### -target avr -no-canonical-prefixes -mmcu=atxmega16a4 -save-temps %s 2>&1 | FileCheck -check-prefix=CHECKf %s
+// CHECKf: clang{{.*}} "-cc1" {{.*}} "-target-cpu" "atxmega16a4"
+// CHECKf: clang{{.*}} "-cc1as" {{.*}} "-target-cpu" "atxmega16a4"
+
+// RUN: %clang 

[clang-tools-extra] cc6d1f8 - [clangd] When finding refs for a renaming alias, do not return refs to underlying decls

2020-09-28 Thread Nathan Ridge via cfe-commits

Author: Nathan Ridge
Date: 2020-09-28T21:18:31-04:00
New Revision: cc6d1f8029b05cd747c46ad3244a1b31ae970c61

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

LOG: [clangd] When finding refs for a renaming alias, do not return refs to 
underlying decls

Fixes https://github.com/clangd/clangd/issues/515

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

Added: 


Modified: 
clang-tools-extra/clangd/XRefs.cpp
clang-tools-extra/clangd/unittests/XRefsTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/XRefs.cpp 
b/clang-tools-extra/clangd/XRefs.cpp
index b4487453847c..9e8791c2a765 100644
--- a/clang-tools-extra/clangd/XRefs.cpp
+++ b/clang-tools-extra/clangd/XRefs.cpp
@@ -1140,11 +1140,21 @@ ReferencesResult findReferences(ParsedAST , 
Position Pos, uint32_t Limit,
   } else {
 // Handle references to Decls.
 
-// We also show references to the targets of using-decls, so we include
-// DeclRelation::Underlying.
-DeclRelationSet Relations = DeclRelation::TemplatePattern |
-DeclRelation::Alias | DeclRelation::Underlying;
-auto Decls = getDeclAtPosition(AST, *CurLoc, Relations);
+DeclRelationSet Relations =
+DeclRelation::TemplatePattern | DeclRelation::Alias;
+std::vector Decls =
+getDeclAtPosition(AST, *CurLoc, Relations);
+std::vector NonrenamingAliasUnderlyingDecls;
+// If the results include a *non-renaming* alias, get its
+// underlying decls as well. (See similar logic in locateASTReferent()).
+for (const NamedDecl *D : Decls) {
+  if (llvm::isa(D) || llvm::isa(D)) {
+for (const NamedDecl *AD :
+ getDeclAtPosition(AST, *CurLoc, DeclRelation::Underlying))
+  NonrenamingAliasUnderlyingDecls.push_back(AD);
+  }
+}
+llvm::copy(NonrenamingAliasUnderlyingDecls, std::back_inserter(Decls));
 
 // We traverse the AST to find references in the main file.
 auto MainFileRefs = findRefs(Decls, AST);

diff  --git a/clang-tools-extra/clangd/unittests/XRefsTests.cpp 
b/clang-tools-extra/clangd/unittests/XRefsTests.cpp
index 2176b59ab9ed..a48bb9c8c182 100644
--- a/clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ b/clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -1588,6 +1588,13 @@ TEST(FindReferences, WithinAST) {
   auto lambda = [x = [[waldo]]](){};
 }
   )cpp",
+  R"cpp(// Renaming alias
+template  class Vector {};
+using [[^X]] = Vector;
+[[X]] x1;
+Vector x2;
+Vector y;
+  )cpp",
   };
   for (const char *Test : Tests) {
 Annotations T(Test);



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


[PATCH] D87225: [clangd] When finding refs for a renaming alias, do not return refs to underlying decls

2020-09-28 Thread Nathan Ridge 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 rGcc6d1f8029b0: [clangd] When finding refs for a renaming 
alias, do not return refs to… (authored by nridge).

Changed prior to commit:
  https://reviews.llvm.org/D87225?vs=294851=294853#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87225

Files:
  clang-tools-extra/clangd/XRefs.cpp
  clang-tools-extra/clangd/unittests/XRefsTests.cpp


Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -1588,6 +1588,13 @@
   auto lambda = [x = [[waldo]]](){};
 }
   )cpp",
+  R"cpp(// Renaming alias
+template  class Vector {};
+using [[^X]] = Vector;
+[[X]] x1;
+Vector x2;
+Vector y;
+  )cpp",
   };
   for (const char *Test : Tests) {
 Annotations T(Test);
Index: clang-tools-extra/clangd/XRefs.cpp
===
--- clang-tools-extra/clangd/XRefs.cpp
+++ clang-tools-extra/clangd/XRefs.cpp
@@ -1140,11 +1140,21 @@
   } else {
 // Handle references to Decls.
 
-// We also show references to the targets of using-decls, so we include
-// DeclRelation::Underlying.
-DeclRelationSet Relations = DeclRelation::TemplatePattern |
-DeclRelation::Alias | DeclRelation::Underlying;
-auto Decls = getDeclAtPosition(AST, *CurLoc, Relations);
+DeclRelationSet Relations =
+DeclRelation::TemplatePattern | DeclRelation::Alias;
+std::vector Decls =
+getDeclAtPosition(AST, *CurLoc, Relations);
+std::vector NonrenamingAliasUnderlyingDecls;
+// If the results include a *non-renaming* alias, get its
+// underlying decls as well. (See similar logic in locateASTReferent()).
+for (const NamedDecl *D : Decls) {
+  if (llvm::isa(D) || llvm::isa(D)) {
+for (const NamedDecl *AD :
+ getDeclAtPosition(AST, *CurLoc, DeclRelation::Underlying))
+  NonrenamingAliasUnderlyingDecls.push_back(AD);
+  }
+}
+llvm::copy(NonrenamingAliasUnderlyingDecls, std::back_inserter(Decls));
 
 // We traverse the AST to find references in the main file.
 auto MainFileRefs = findRefs(Decls, AST);


Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -1588,6 +1588,13 @@
   auto lambda = [x = [[waldo]]](){};
 }
   )cpp",
+  R"cpp(// Renaming alias
+template  class Vector {};
+using [[^X]] = Vector;
+[[X]] x1;
+Vector x2;
+Vector y;
+  )cpp",
   };
   for (const char *Test : Tests) {
 Annotations T(Test);
Index: clang-tools-extra/clangd/XRefs.cpp
===
--- clang-tools-extra/clangd/XRefs.cpp
+++ clang-tools-extra/clangd/XRefs.cpp
@@ -1140,11 +1140,21 @@
   } else {
 // Handle references to Decls.
 
-// We also show references to the targets of using-decls, so we include
-// DeclRelation::Underlying.
-DeclRelationSet Relations = DeclRelation::TemplatePattern |
-DeclRelation::Alias | DeclRelation::Underlying;
-auto Decls = getDeclAtPosition(AST, *CurLoc, Relations);
+DeclRelationSet Relations =
+DeclRelation::TemplatePattern | DeclRelation::Alias;
+std::vector Decls =
+getDeclAtPosition(AST, *CurLoc, Relations);
+std::vector NonrenamingAliasUnderlyingDecls;
+// If the results include a *non-renaming* alias, get its
+// underlying decls as well. (See similar logic in locateASTReferent()).
+for (const NamedDecl *D : Decls) {
+  if (llvm::isa(D) || llvm::isa(D)) {
+for (const NamedDecl *AD :
+ getDeclAtPosition(AST, *CurLoc, DeclRelation::Underlying))
+  NonrenamingAliasUnderlyingDecls.push_back(AD);
+  }
+}
+llvm::copy(NonrenamingAliasUnderlyingDecls, std::back_inserter(Decls));
 
 // We traverse the AST to find references in the main file.
 auto MainFileRefs = findRefs(Decls, AST);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D87225: [clangd] When finding refs for a renaming alias, do not return refs to underlying decls

2020-09-28 Thread Nathan Ridge via Phabricator via cfe-commits
nridge updated this revision to Diff 294851.
nridge marked 2 inline comments as done.
nridge added a comment.

Address final review comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87225

Files:
  clang-tools-extra/clangd/XRefs.cpp
  clang-tools-extra/clangd/unittests/XRefsTests.cpp


Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -1582,6 +1582,13 @@
   f.[[^~]]Foo();
 }
   )cpp",
+  R"cpp(// Renaming alias
+template  class Vector {};
+using [[^X]] = Vector;
+[[X]] x1;
+Vector x2;
+Vector y;
+  )cpp",
   };
   for (const char *Test : Tests) {
 Annotations T(Test);
Index: clang-tools-extra/clangd/XRefs.cpp
===
--- clang-tools-extra/clangd/XRefs.cpp
+++ clang-tools-extra/clangd/XRefs.cpp
@@ -1140,11 +1140,21 @@
   } else {
 // Handle references to Decls.
 
-// We also show references to the targets of using-decls, so we include
-// DeclRelation::Underlying.
-DeclRelationSet Relations = DeclRelation::TemplatePattern |
-DeclRelation::Alias | DeclRelation::Underlying;
-auto Decls = getDeclAtPosition(AST, *CurLoc, Relations);
+DeclRelationSet Relations =
+DeclRelation::TemplatePattern | DeclRelation::Alias;
+std::vector Decls =
+getDeclAtPosition(AST, *CurLoc, Relations);
+std::vector NonrenamingAliasUnderlyingDecls;
+// If the results include a *non-renaming* alias, get its
+// underlying decls as well. (See similar logic in locateASTReferent()).
+for (const NamedDecl *D : Decls) {
+  if (llvm::isa(D) || llvm::isa(D)) {
+for (const NamedDecl *AD :
+ getDeclAtPosition(AST, *CurLoc, DeclRelation::Underlying))
+  NonrenamingAliasUnderlyingDecls.push_back(AD);
+  }
+}
+llvm::copy(NonrenamingAliasUnderlyingDecls, std::back_inserter(Decls));
 
 // We traverse the AST to find references in the main file.
 auto MainFileRefs = findRefs(Decls, AST);


Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -1582,6 +1582,13 @@
   f.[[^~]]Foo();
 }
   )cpp",
+  R"cpp(// Renaming alias
+template  class Vector {};
+using [[^X]] = Vector;
+[[X]] x1;
+Vector x2;
+Vector y;
+  )cpp",
   };
   for (const char *Test : Tests) {
 Annotations T(Test);
Index: clang-tools-extra/clangd/XRefs.cpp
===
--- clang-tools-extra/clangd/XRefs.cpp
+++ clang-tools-extra/clangd/XRefs.cpp
@@ -1140,11 +1140,21 @@
   } else {
 // Handle references to Decls.
 
-// We also show references to the targets of using-decls, so we include
-// DeclRelation::Underlying.
-DeclRelationSet Relations = DeclRelation::TemplatePattern |
-DeclRelation::Alias | DeclRelation::Underlying;
-auto Decls = getDeclAtPosition(AST, *CurLoc, Relations);
+DeclRelationSet Relations =
+DeclRelation::TemplatePattern | DeclRelation::Alias;
+std::vector Decls =
+getDeclAtPosition(AST, *CurLoc, Relations);
+std::vector NonrenamingAliasUnderlyingDecls;
+// If the results include a *non-renaming* alias, get its
+// underlying decls as well. (See similar logic in locateASTReferent()).
+for (const NamedDecl *D : Decls) {
+  if (llvm::isa(D) || llvm::isa(D)) {
+for (const NamedDecl *AD :
+ getDeclAtPosition(AST, *CurLoc, DeclRelation::Underlying))
+  NonrenamingAliasUnderlyingDecls.push_back(AD);
+  }
+}
+llvm::copy(NonrenamingAliasUnderlyingDecls, std::back_inserter(Decls));
 
 // We traverse the AST to find references in the main file.
 auto MainFileRefs = findRefs(Decls, AST);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D87225: [clangd] When finding refs for a renaming alias, do not return refs to underlying decls

2020-09-28 Thread Nathan Ridge via Phabricator via cfe-commits
nridge added inline comments.



Comment at: clang-tools-extra/clangd/XRefs.cpp:1155
+  AdditionalDecls.push_back(AD);
+break;
+  }

hokein wrote:
> I think the `break` is not necessarily needed. In practice we should just 
> have one non-renaming alias at the current position. If not, that probably 
> means we likely have a bug, `break` seems to just hide the bug.
Agreed, the `break` was left over from the previous approach and shouldn't be 
there any more.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87225

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


[PATCH] D70378: [LLD][COFF] Cover usage of LLD as a library

2020-09-28 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea added inline comments.



Comment at: lld/ELF/Driver.cpp:895
   const char *argv[] = {config->progName.data(), opt.data()};
+  cl::ResetAllOptionOccurrences();
   if (cl::ParseCommandLineOptions(2, argv, "", ))

ayrivera wrote:
> MaskRay wrote:
> > ayrivera wrote:
> > > Hi,
> > > 
> > > I built locally lld and came across an issue. The ELF driver isn't 
> > > recognizing multiple -mllvm options. It only process the last -mllvm 
> > > option that was entered in the command line. For example, I can add 
> > > -mllvm -print-after-all -debug-pass=Arguments and it only prints the 
> > > information from -debug-pass=Arguments, and not the IR and the debug 
> > > data. If I swap the order, then the IR is printed and not the debug 
> > > information.
> > > 
> > > I noticed that this change set added a call to 
> > > cl:ResetAllOptionOccurrences() (line 895) inside parseClangOption. The 
> > > function parseClangOption is called inside the loop that process the 
> > > -mllvm options. If I comment this line, then everything works correctly 
> > > and I can pass multiple -mllvm options through the command.
> > > 
> > > Is this an intended behavior or an actual issue? Thanks for your time.
> > Hi,
> > 
> > > For example, I can add -mllvm -print-after-all -debug-pass=Arguments
> > 
> > You need two -mllvm, i.e. `-mllvm -print-after-all -mllvm 
> > -debug-pass=Arguments`. And with the option, I see the print-after-all dump.
> Hi,
> 
> 
> > You need two -mllvm, i.e. -mllvm -print-after-all -mllvm 
> > -debug-pass=Arguments. And with the option, I see the print-after-all dump.
> 
> 
> Thanks for the quick reply. Sorry, this is a typo. I'm using both -mllvm and 
> still got the issue.
> Is this an intended behavior or an actual issue?
At first sight, this is an actual issue. Normally, 
`cl::ResetAllOptionOccurrences()` should be called only once per compiler or 
linker instance, to reset the internal counters for the `cl::opt`s. I would 
move it somewhere at the begining of `readConfigs()`. Can you try that see if 
that solves your issue?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70378

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


[PATCH] D70378: [LLD][COFF] Cover usage of LLD as a library

2020-09-28 Thread Axel Y. Rivera via Phabricator via cfe-commits
ayrivera added inline comments.



Comment at: lld/ELF/Driver.cpp:895
   const char *argv[] = {config->progName.data(), opt.data()};
+  cl::ResetAllOptionOccurrences();
   if (cl::ParseCommandLineOptions(2, argv, "", ))

MaskRay wrote:
> ayrivera wrote:
> > Hi,
> > 
> > I built locally lld and came across an issue. The ELF driver isn't 
> > recognizing multiple -mllvm options. It only process the last -mllvm option 
> > that was entered in the command line. For example, I can add -mllvm 
> > -print-after-all -debug-pass=Arguments and it only prints the information 
> > from -debug-pass=Arguments, and not the IR and the debug data. If I swap 
> > the order, then the IR is printed and not the debug information.
> > 
> > I noticed that this change set added a call to 
> > cl:ResetAllOptionOccurrences() (line 895) inside parseClangOption. The 
> > function parseClangOption is called inside the loop that process the -mllvm 
> > options. If I comment this line, then everything works correctly and I can 
> > pass multiple -mllvm options through the command.
> > 
> > Is this an intended behavior or an actual issue? Thanks for your time.
> Hi,
> 
> > For example, I can add -mllvm -print-after-all -debug-pass=Arguments
> 
> You need two -mllvm, i.e. `-mllvm -print-after-all -mllvm 
> -debug-pass=Arguments`. And with the option, I see the print-after-all dump.
Hi,


> You need two -mllvm, i.e. -mllvm -print-after-all -mllvm 
> -debug-pass=Arguments. And with the option, I see the print-after-all dump.


Thanks for the quick reply. Sorry, this is a typo. I'm using both -mllvm and 
still got the issue.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70378

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


[PATCH] D70378: [LLD][COFF] Cover usage of LLD as a library

2020-09-28 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: lld/ELF/Driver.cpp:895
   const char *argv[] = {config->progName.data(), opt.data()};
+  cl::ResetAllOptionOccurrences();
   if (cl::ParseCommandLineOptions(2, argv, "", ))

ayrivera wrote:
> Hi,
> 
> I built locally lld and came across an issue. The ELF driver isn't 
> recognizing multiple -mllvm options. It only process the last -mllvm option 
> that was entered in the command line. For example, I can add -mllvm 
> -print-after-all -debug-pass=Arguments and it only prints the information 
> from -debug-pass=Arguments, and not the IR and the debug data. If I swap the 
> order, then the IR is printed and not the debug information.
> 
> I noticed that this change set added a call to cl:ResetAllOptionOccurrences() 
> (line 895) inside parseClangOption. The function parseClangOption is called 
> inside the loop that process the -mllvm options. If I comment this line, then 
> everything works correctly and I can pass multiple -mllvm options through the 
> command.
> 
> Is this an intended behavior or an actual issue? Thanks for your time.
Hi,

> For example, I can add -mllvm -print-after-all -debug-pass=Arguments

You need two -mllvm, i.e. `-mllvm -print-after-all -mllvm 
-debug-pass=Arguments`. And with the option, I see the print-after-all dump.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70378

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


[PATCH] D68364: Implement C++20's P0784 (More constexpr containers)

2020-09-28 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

In D68364#2299336 , @ldionne wrote:

> In D68364#2294569 , @jwakely wrote:
>
>> I don't think your implementation is valid. I think P0784 only allows 
>> new-expressions and calls to `std::allocator::allocate` in constexpr 
>> functions, not calls to `operator new`.
>
> Hmm, right. It's actually impossible to implement `__libcpp_allocate` in a 
> constexpr-friendly manner, since it's just allocating bytes.

Right, we need to rely on implementation magic. I wrote up a document proposing 
how to do this 

 a year or so ago, and shared it with some GCC folks (I don't remember whether 
it was mailed to the GCC mailing list or just to Jason or what) suggesting that 
we follow option 3 of that doc -- in particular, this permits calls to 
`operator new` "//transitively// within a member of `std::allocator`" 
(emphasis mine), precisely so that stdlib implementations can pull out helper 
functions as libc++ does, and don't need to branch on `is_constant_evaluated()` 
for this at all. That said, this is all vendor extension territory, and GCC is 
of course under no obligation to follow my proposal, and indeed seems not to 
have followed this detail of it. So be it.

But... there's no question of "valid" here :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68364

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


[clang] c375635 - Ensure that we don't compute linkage for an anonymous class too early if

2020-09-28 Thread Richard Smith via cfe-commits

Author: Richard Smith
Date: 2020-09-28T17:22:40-07:00
New Revision: c375635d05f6f10c7c95ecc74a0569213d176d8e

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

LOG: Ensure that we don't compute linkage for an anonymous class too early if
it has a member whose name is the same as a builtin.

Fixes a regression from the introduction of BuiltinAttr.

Added: 


Modified: 
clang/lib/Sema/SemaDecl.cpp
clang/test/SemaCXX/anonymous-struct.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 2599e3b46e4e..aff49b7ddb90 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -9644,7 +9644,8 @@ Sema::ActOnFunctionDeclarator(Scope *S, Declarator , 
DeclContext *DC,
 
   // In C builtins get merged with implicitly lazily created declarations.
   // In C++ we need to check if it's a builtin and add the BuiltinAttr here.
-  if (getLangOpts().CPlusPlus) {
+  if (getLangOpts().CPlusPlus &&
+  NewFD->getDeclContext()->getRedeclContext()->isFileContext()) {
 if (IdentifierInfo *II = Previous.getLookupName().getAsIdentifierInfo()) {
   if (unsigned BuiltinID = II->getBuiltinID()) {
 if (NewFD->getLanguageLinkage() == CLanguageLinkage) {

diff  --git a/clang/test/SemaCXX/anonymous-struct.cpp 
b/clang/test/SemaCXX/anonymous-struct.cpp
index 333b8f724f4e..f85b00bc8bce 100644
--- a/clang/test/SemaCXX/anonymous-struct.cpp
+++ b/clang/test/SemaCXX/anonymous-struct.cpp
@@ -171,3 +171,12 @@ union {
 } x;
   } x;
 } static_member_3;
+
+// Ensure we don't compute the linkage of a member function just because it
+// happens to have the same name as a builtin.
+namespace BuiltinName {
+  // Note that this is not an error: we didn't trigger linkage computation in 
this example.
+  typedef struct { // expected-warning {{anonymous non-C-compatible type}}
+void memcpy(); // expected-note {{due to this member}}
+  } A; // expected-note {{given name 'A' for linkage purposes by this typedef}}
+}



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


[PATCH] D70378: [LLD][COFF] Cover usage of LLD as a library

2020-09-28 Thread Axel Y. Rivera via Phabricator via cfe-commits
ayrivera added inline comments.



Comment at: lld/ELF/Driver.cpp:895
   const char *argv[] = {config->progName.data(), opt.data()};
+  cl::ResetAllOptionOccurrences();
   if (cl::ParseCommandLineOptions(2, argv, "", ))

Hi,

I built locally lld and came across an issue. The ELF driver isn't recognizing 
multiple -mllvm options. It only process the last -mllvm option that was 
entered in the command line. For example, I can add -mllvm -print-after-all 
-debug-pass=Arguments and it only prints the information from 
-debug-pass=Arguments, and not the IR and the debug data. If I swap the order, 
then the IR is printed and not the debug information.

I noticed that this change set added a call to cl:ResetAllOptionOccurrences() 
(line 895) inside parseClangOption. The function parseClangOption is called 
inside the loop that process the -mllvm options. If I comment this line, then 
everything works correctly and I can pass multiple -mllvm options through the 
command.

Is this an intended behavior or an actual issue? Thanks for your time.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70378

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


[PATCH] D87176: [clang] Enable selectively turning on/off format-insufficient-args warning

2020-09-28 Thread Jan Korous via Phabricator via cfe-commits
jkorous added a comment.

Had to fix the order of expected warnings in warning-wall.c
6fd8c69049a8 
 [clang] 
Update warning-wall.c test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87176

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


[clang] 6fd8c69 - [clang] Update warning-wall.c test

2020-09-28 Thread Jan Korous via cfe-commits

Author: Jan Korous
Date: 2020-09-28T17:19:51-07:00
New Revision: 6fd8c69049a8fc119278097be6d0bdc3e781f1ba

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

LOG: [clang] Update warning-wall.c test

Follow-up to 1e86d637eb4f:
[clang] Selectively ena/disa-ble format-insufficient-args warning

Added: 


Modified: 
clang/test/Misc/warning-wall.c

Removed: 




diff  --git a/clang/test/Misc/warning-wall.c b/clang/test/Misc/warning-wall.c
index 9975323f7028..ac2b124e3312 100644
--- a/clang/test/Misc/warning-wall.c
+++ b/clang/test/Misc/warning-wall.c
@@ -9,13 +9,13 @@ CHECK-NEXT:-Wdelete-non-virtual-dtor
 CHECK-NEXT:  -Wdelete-non-abstract-non-virtual-dtor
 CHECK-NEXT:  -Wdelete-abstract-non-virtual-dtor
 CHECK-NEXT:-Wformat
-CHECK-NEXT:  -Wformat-insufficient-args
 CHECK-NEXT:  -Wformat-extra-args
 CHECK-NEXT:  -Wformat-zero-length
 CHECK-NEXT:  -Wnonnull
 CHECK-NEXT:  -Wformat-security
 CHECK-NEXT:  -Wformat-y2k
 CHECK-NEXT:  -Wformat-invalid-specifier
+CHECK-NEXT:  -Wformat-insufficient-args
 CHECK-NEXT:-Wfor-loop-analysis
 CHECK-NEXT:-Wframe-address
 CHECK-NEXT:-Wimplicit



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


[PATCH] D88150: BuildVectorType with a dependent (array) type is crashing the compiler - Fix for PR-47542

2020-09-28 Thread Reid Kleckner via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGefd04721c9a2: BuildVectorType with a dependent (array) type 
is crashing the compiler  - Fix… (authored by zahiraam, committed by rnk).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88150

Files:
  clang/lib/Sema/SemaType.cpp
  clang/test/SemaCXX/attr-gnu.cpp


Index: clang/test/SemaCXX/attr-gnu.cpp
===
--- clang/test/SemaCXX/attr-gnu.cpp
+++ clang/test/SemaCXX/attr-gnu.cpp
@@ -12,6 +12,13 @@
 
 void g(int a[static [[]] 5]); // expected-error {{static array size is a C99 
feature, not permitted in C++}}
 
+template struct A {
+  int x[sizeof(T)] __attribute((vector_size(8))); // expected-error {{invalid 
vector element type 'int [sizeof(T)]'}}
+};
+
+typedef int myvect[4] __attribute__((vector_size(16))); // expected-error 
{{invalid vector element type 'int [4]'}}
+void foo(myvect *in, myvect *out) { (*out)[0] = (*in)[0]; }
+
 namespace {
 class B {
 public:
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -2517,9 +2517,10 @@
SourceLocation AttrLoc) {
   // The base type must be integer (not Boolean or enumeration) or float, and
   // can't already be a vector.
-  if (!CurType->isDependentType() &&
-  (!CurType->isBuiltinType() || CurType->isBooleanType() ||
-   (!CurType->isIntegerType() && !CurType->isRealFloatingType( {
+  if ((!CurType->isDependentType() &&
+   (!CurType->isBuiltinType() || CurType->isBooleanType() ||
+(!CurType->isIntegerType() && !CurType->isRealFloatingType( ||
+  CurType->isArrayType()) {
 Diag(AttrLoc, diag::err_attribute_invalid_vector_type) << CurType;
 return QualType();
   }


Index: clang/test/SemaCXX/attr-gnu.cpp
===
--- clang/test/SemaCXX/attr-gnu.cpp
+++ clang/test/SemaCXX/attr-gnu.cpp
@@ -12,6 +12,13 @@
 
 void g(int a[static [[]] 5]); // expected-error {{static array size is a C99 feature, not permitted in C++}}
 
+template struct A {
+  int x[sizeof(T)] __attribute((vector_size(8))); // expected-error {{invalid vector element type 'int [sizeof(T)]'}}
+};
+
+typedef int myvect[4] __attribute__((vector_size(16))); // expected-error {{invalid vector element type 'int [4]'}}
+void foo(myvect *in, myvect *out) { (*out)[0] = (*in)[0]; }
+
 namespace {
 class B {
 public:
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -2517,9 +2517,10 @@
SourceLocation AttrLoc) {
   // The base type must be integer (not Boolean or enumeration) or float, and
   // can't already be a vector.
-  if (!CurType->isDependentType() &&
-  (!CurType->isBuiltinType() || CurType->isBooleanType() ||
-   (!CurType->isIntegerType() && !CurType->isRealFloatingType( {
+  if ((!CurType->isDependentType() &&
+   (!CurType->isBuiltinType() || CurType->isBooleanType() ||
+(!CurType->isIntegerType() && !CurType->isRealFloatingType( ||
+  CurType->isArrayType()) {
 Diag(AttrLoc, diag::err_attribute_invalid_vector_type) << CurType;
 return QualType();
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] efd0472 - BuildVectorType with a dependent (array) type is crashing the compiler - Fix for PR-47542

2020-09-28 Thread Reid Kleckner via cfe-commits

Author: Zahira Ammarguellat
Date: 2020-09-28T17:10:32-07:00
New Revision: efd04721c9a2a856dd47e47a08c42d21efd5dd2b

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

LOG: BuildVectorType with a dependent (array) type is crashing the compiler  - 
Fix for PR-47542

Reviewed By: rnk

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

Added: 


Modified: 
clang/lib/Sema/SemaType.cpp
clang/test/SemaCXX/attr-gnu.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp
index d8ea9c037259..b823c962f21d 100644
--- a/clang/lib/Sema/SemaType.cpp
+++ b/clang/lib/Sema/SemaType.cpp
@@ -2517,9 +2517,10 @@ QualType Sema::BuildVectorType(QualType CurType, Expr 
*SizeExpr,
SourceLocation AttrLoc) {
   // The base type must be integer (not Boolean or enumeration) or float, and
   // can't already be a vector.
-  if (!CurType->isDependentType() &&
-  (!CurType->isBuiltinType() || CurType->isBooleanType() ||
-   (!CurType->isIntegerType() && !CurType->isRealFloatingType( {
+  if ((!CurType->isDependentType() &&
+   (!CurType->isBuiltinType() || CurType->isBooleanType() ||
+(!CurType->isIntegerType() && !CurType->isRealFloatingType( ||
+  CurType->isArrayType()) {
 Diag(AttrLoc, diag::err_attribute_invalid_vector_type) << CurType;
 return QualType();
   }

diff  --git a/clang/test/SemaCXX/attr-gnu.cpp b/clang/test/SemaCXX/attr-gnu.cpp
index 9eb42342df31..83e58bbcd5e2 100644
--- a/clang/test/SemaCXX/attr-gnu.cpp
+++ b/clang/test/SemaCXX/attr-gnu.cpp
@@ -12,6 +12,13 @@ void f() {
 
 void g(int a[static [[]] 5]); // expected-error {{static array size is a C99 
feature, not permitted in C++}}
 
+template struct A {
+  int x[sizeof(T)] __attribute((vector_size(8))); // expected-error {{invalid 
vector element type 'int [sizeof(T)]'}}
+};
+
+typedef int myvect[4] __attribute__((vector_size(16))); // expected-error 
{{invalid vector element type 'int [4]'}}
+void foo(myvect *in, myvect *out) { (*out)[0] = (*in)[0]; }
+
 namespace {
 class B {
 public:



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


[PATCH] D26418: [clang-tidy] Add '-suppress-checks-filter' option to suppress diagnostics from certain files

2020-09-28 Thread Josh via Phabricator via cfe-commits
davidsj2 added a comment.

I too am interested in this patch.  In addition to the use cases already 
described, this would be helpful for projects that use several different static 
analysis tools and don't want to clutter code with a bunch of different 
suppression comments to satisfy each tool.


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

https://reviews.llvm.org/D26418

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


[PATCH] D87528: Enable '#pragma STDC FENV_ACCESS' in frontend cf. D69272 - Work in Progress

2020-09-28 Thread Melanie Blower via Phabricator via cfe-commits
mibintc added a comment.

In D87528#2297647 , @sepavloff wrote:

> In D87528#2295015 , @mibintc wrote:
>
>> I tried using the 0924 version of the patch on an internal workload SPEC 
>> "cpu2017" and found that a few files failed to compile because of an error 
>> message on static initializer, like this: struct s { float f; }; static 
>> struct s x = {0.63};   Compiled with ffp-model=strict "initializer..is not a 
>> compile-time constant"
>
> Thank you for trying this.
>
> The error happens because static variable initializer gets rounding mode 
> calculated from command-line options (`dynamic`), but this is wrong because 
> such initializers must be calculated using constant rounding mode 
> (`tonearest` in this case). Either we must force default FP mode in such 
> initializers, or we are wrong when using 
> `FPOptions::defaultWithoutTrailingStorage`. Need to analyze this problem more.

@sepavloff Please provide precise reference to support the claim "but this is 
wrong because such initializers must be calculated using constant rounding 
mode..."  many thanks!


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

https://reviews.llvm.org/D87528

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


[clang] ee80615 - [clang][driver][AIX] Set compiler-rt as default rtlib

2020-09-28 Thread David Tenty via cfe-commits

Author: David Tenty
Date: 2020-09-28T19:45:43-04:00
New Revision: ee80615b5c1c5b15c90a92d6954007b3a82825b0

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

LOG: [clang][driver][AIX] Set compiler-rt as default rtlib

Reviewed By: hubert.reinterpretcast

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

Added: 
clang/test/Driver/aix-rtlib.c

Modified: 
clang/lib/Driver/ToolChain.cpp
clang/lib/Driver/ToolChains/AIX.cpp
clang/lib/Driver/ToolChains/AIX.h
clang/test/Driver/aix-ld.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp
index 0831791c8d06..8991216da676 100644
--- a/clang/lib/Driver/ToolChain.cpp
+++ b/clang/lib/Driver/ToolChain.cpp
@@ -391,6 +391,8 @@ StringRef ToolChain::getOSLibName() const {
 return "openbsd";
   case llvm::Triple::Solaris:
 return "sunos";
+  case llvm::Triple::AIX:
+return "aix";
   default:
 return getOS();
   }

diff  --git a/clang/lib/Driver/ToolChains/AIX.cpp 
b/clang/lib/Driver/ToolChains/AIX.cpp
index 0d4d7e3dbf9f..b56ddf55cb30 100644
--- a/clang/lib/Driver/ToolChains/AIX.cpp
+++ b/clang/lib/Driver/ToolChains/AIX.cpp
@@ -156,6 +156,8 @@ void aix::Linker::ConstructJob(Compilation , const 
JobAction ,
 getToolChain().AddCXXStdlibLibArgs(Args, CmdArgs);
 
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
+AddRunTimeLibs(ToolChain, D, CmdArgs, Args);
+
 // Support POSIX threads if "-pthreads" or "-pthread" is present.
 if (Args.hasArg(options::OPT_pthreads, options::OPT_pthread))
   CmdArgs.push_back("-lpthreads");
@@ -228,6 +230,10 @@ ToolChain::CXXStdlibType AIX::GetDefaultCXXStdlibType() 
const {
   return ToolChain::CST_Libcxx;
 }
 
+ToolChain::RuntimeLibType AIX::GetDefaultRuntimeLibType() const {
+  return ToolChain::RLT_CompilerRT;
+}
+
 auto AIX::buildAssembler() const -> Tool * { return new aix::Assembler(*this); 
}
 
 auto AIX::buildLinker() const -> Tool * { return new aix::Linker(*this); }

diff  --git a/clang/lib/Driver/ToolChains/AIX.h 
b/clang/lib/Driver/ToolChains/AIX.h
index f63b20da969e..d4e593255736 100644
--- a/clang/lib/Driver/ToolChains/AIX.h
+++ b/clang/lib/Driver/ToolChains/AIX.h
@@ -72,6 +72,8 @@ class LLVM_LIBRARY_VISIBILITY AIX : public ToolChain {
 
   CXXStdlibType GetDefaultCXXStdlibType() const override;
 
+  RuntimeLibType GetDefaultRuntimeLibType() const override;
+
 protected:
   Tool *buildAssembler() const override;
   Tool *buildLinker() const override;

diff  --git a/clang/test/Driver/aix-ld.c b/clang/test/Driver/aix-ld.c
index 6dd14dc164df..224e355aac13 100644
--- a/clang/test/Driver/aix-ld.c
+++ b/clang/test/Driver/aix-ld.c
@@ -3,11 +3,13 @@
 
 // Check powerpc-ibm-aix7.1.0.0, 32-bit.
 // RUN: %clang -no-canonical-prefixes %s -### 2>&1 \
+// RUN:-resource-dir=%S/Inputs/resource_dir \
 // RUN:-target powerpc-ibm-aix7.1.0.0 \
 // RUN:--sysroot %S/Inputs/aix_ppc_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-LD32 %s
 // CHECK-LD32-NOT: warning:
 // CHECK-LD32: {{.*}}clang{{(.exe)?}}" "-cc1" "-triple" 
"powerpc-ibm-aix7.1.0.0"
+// CHECK-LD32: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
 // CHECK-LD32: "-isysroot" "[[SYSROOT:[^"]+]]"
 // CHECK-LD32: "{{.*}}ld{{(.exe)?}}"
 // CHECK-LD32-NOT: "-bnso"
@@ -17,15 +19,18 @@
 // CHECK-LD32-NOT: "[[SYSROOT]]/usr/lib{{/|}}crti.o"
 // CHECK-LD32: "-L[[SYSROOT]]/usr/lib"
 // CHECK-LD32-NOT: "-lc++"
+// CHECK-LD32: 
"[[RESOURCE_DIR]]{{/|}}lib{{/|}}aix{{/|}}libclang_rt.builtins-powerpc.a"
 // CHECK-LD32: "-lc"
 
 // Check powerpc64-ibm-aix7.1.0.0, 64-bit.
 // RUN: %clang -no-canonical-prefixes %s -### 2>&1 \
+// RUN:-resource-dir=%S/Inputs/resource_dir \
 // RUN:-target powerpc64-ibm-aix7.1.0.0 \
 // RUN:--sysroot %S/Inputs/aix_ppc_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-LD64 %s
 // CHECK-LD64-NOT: warning:
 // CHECK-LD64: {{.*}}clang{{(.exe)?}}" "-cc1" "-triple" 
"powerpc64-ibm-aix7.1.0.0"
+// CHECK-LD64: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
 // CHECK-LD64: "-isysroot" "[[SYSROOT:[^"]+]]"
 // CHECK-LD64: "{{.*}}ld{{(.exe)?}}"
 // CHECK-LD64-NOT: "-bnso"
@@ -35,16 +40,19 @@
 // CHECK-LD64-NOT: "[[SYSROOT]]/usr/lib{{/|}}crti_64.o"
 // CHECK-LD64: "-L[[SYSROOT]]/usr/lib"
 // CHECK-LD64-NOT: "-lc++"
+// CHECK-LD64: 
"[[RESOURCE_DIR]]{{/|}}lib{{/|}}aix{{/|}}libclang_rt.builtins-powerpc64.a"
 // CHECK-LD64: "-lc"
 
 // Check powerpc-ibm-aix7.1.0.0, 32-bit. Enable POSIX thread support.
 // RUN: %clang -no-canonical-prefixes %s -### 2>&1 \
+// RUN:-resource-dir=%S/Inputs/resource_dir \
 // RUN:-pthread \
 // RUN:-target powerpc-ibm-aix7.1.0.0 \
 // RUN:--sysroot 

[PATCH] D88182: [clang][driver][AIX] Set compiler-rt as default rtlib

2020-09-28 Thread David Tenty via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGee80615b5c1c: [clang][driver][AIX] Set compiler-rt as 
default rtlib (authored by daltenty).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88182

Files:
  clang/lib/Driver/ToolChain.cpp
  clang/lib/Driver/ToolChains/AIX.cpp
  clang/lib/Driver/ToolChains/AIX.h
  clang/test/Driver/aix-ld.c
  clang/test/Driver/aix-rtlib.c

Index: clang/test/Driver/aix-rtlib.c
===
--- /dev/null
+++ clang/test/Driver/aix-rtlib.c
@@ -0,0 +1,10 @@
+// Check the default rtlib for AIX.
+// RUN: %clang -target powerpc-ibm-aix -print-libgcc-file-name -no-canonical-prefixes \
+// RUN:-resource-dir=%S/Inputs/resource_dir \
+// RUN:   | FileCheck -check-prefix=CHECK32 %s
+// RUN: %clang -target powerpc64-ibm-aix -print-libgcc-file-name -no-canonical-prefixes \
+// RUN:-resource-dir=%S/Inputs/resource_dir \
+// RUN:   | FileCheck -check-prefix=CHECK64 %s
+
+// CHECK32: resource_dir{{/|\\}}lib{{/|\\}}aix{{/|\\}}libclang_rt.builtins-powerpc.a
+// CHECK64: resource_dir{{/|\\}}lib{{/|\\}}aix{{/|\\}}libclang_rt.builtins-powerpc64.a
Index: clang/test/Driver/aix-ld.c
===
--- clang/test/Driver/aix-ld.c
+++ clang/test/Driver/aix-ld.c
@@ -3,11 +3,13 @@
 
 // Check powerpc-ibm-aix7.1.0.0, 32-bit.
 // RUN: %clang -no-canonical-prefixes %s -### 2>&1 \
+// RUN:-resource-dir=%S/Inputs/resource_dir \
 // RUN:-target powerpc-ibm-aix7.1.0.0 \
 // RUN:--sysroot %S/Inputs/aix_ppc_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-LD32 %s
 // CHECK-LD32-NOT: warning:
 // CHECK-LD32: {{.*}}clang{{(.exe)?}}" "-cc1" "-triple" "powerpc-ibm-aix7.1.0.0"
+// CHECK-LD32: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
 // CHECK-LD32: "-isysroot" "[[SYSROOT:[^"]+]]"
 // CHECK-LD32: "{{.*}}ld{{(.exe)?}}"
 // CHECK-LD32-NOT: "-bnso"
@@ -17,15 +19,18 @@
 // CHECK-LD32-NOT: "[[SYSROOT]]/usr/lib{{/|}}crti.o"
 // CHECK-LD32: "-L[[SYSROOT]]/usr/lib"
 // CHECK-LD32-NOT: "-lc++"
+// CHECK-LD32: "[[RESOURCE_DIR]]{{/|}}lib{{/|}}aix{{/|}}libclang_rt.builtins-powerpc.a"
 // CHECK-LD32: "-lc"
 
 // Check powerpc64-ibm-aix7.1.0.0, 64-bit.
 // RUN: %clang -no-canonical-prefixes %s -### 2>&1 \
+// RUN:-resource-dir=%S/Inputs/resource_dir \
 // RUN:-target powerpc64-ibm-aix7.1.0.0 \
 // RUN:--sysroot %S/Inputs/aix_ppc_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-LD64 %s
 // CHECK-LD64-NOT: warning:
 // CHECK-LD64: {{.*}}clang{{(.exe)?}}" "-cc1" "-triple" "powerpc64-ibm-aix7.1.0.0"
+// CHECK-LD64: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
 // CHECK-LD64: "-isysroot" "[[SYSROOT:[^"]+]]"
 // CHECK-LD64: "{{.*}}ld{{(.exe)?}}"
 // CHECK-LD64-NOT: "-bnso"
@@ -35,16 +40,19 @@
 // CHECK-LD64-NOT: "[[SYSROOT]]/usr/lib{{/|}}crti_64.o"
 // CHECK-LD64: "-L[[SYSROOT]]/usr/lib"
 // CHECK-LD64-NOT: "-lc++"
+// CHECK-LD64: "[[RESOURCE_DIR]]{{/|}}lib{{/|}}aix{{/|}}libclang_rt.builtins-powerpc64.a"
 // CHECK-LD64: "-lc"
 
 // Check powerpc-ibm-aix7.1.0.0, 32-bit. Enable POSIX thread support.
 // RUN: %clang -no-canonical-prefixes %s -### 2>&1 \
+// RUN:-resource-dir=%S/Inputs/resource_dir \
 // RUN:-pthread \
 // RUN:-target powerpc-ibm-aix7.1.0.0 \
 // RUN:--sysroot %S/Inputs/aix_ppc_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-LD32-PTHREAD %s
 // CHECK-LD32-PTHREAD-NOT: warning:
 // CHECK-LD32-PTHREAD: {{.*}}clang{{(.exe)?}}" "-cc1" "-triple" "powerpc-ibm-aix7.1.0.0"
+// CHECK-LD32-PTHREAD: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
 // CHECK-LD32-PTHREAD: "-isysroot" "[[SYSROOT:[^"]+]]"
 // CHECK-LD32-PTHREAD: "{{.*}}ld{{(.exe)?}}"
 // CHECK-LD32-PTHREAD-NOT: "-bnso"
@@ -54,17 +62,20 @@
 // CHECK-LD32-PTHREAD-NOT: "[[SYSROOT]]/usr/lib{{/|}}crti.o"
 // CHECK-LD32-PTHREAD: "-L[[SYSROOT]]/usr/lib"
 // CHECK-LD32-PTHREAD-NOT: "-lc++"
+// CHECK-LD32-PTHREAD: "[[RESOURCE_DIR]]{{/|}}lib{{/|}}aix{{/|}}libclang_rt.builtins-powerpc.a"
 // CHECK-LD32-PTHREAD: "-lpthreads"
 // CHECK-LD32-PTHREAD: "-lc"
 
 // Check powerpc64-ibm-aix7.1.0.0, 64-bit. POSIX thread alias.
 // RUN: %clang -no-canonical-prefixes %s -### 2>&1 \
+// RUN:-resource-dir=%S/Inputs/resource_dir \
 // RUN:-pthreads \
 // RUN:-target powerpc64-ibm-aix7.1.0.0 \
 // RUN:--sysroot %S/Inputs/aix_ppc_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-LD64-PTHREAD %s
 // CHECK-LD64-PTHREAD-NOT: warning:
 // CHECK-LD64-PTHREAD: {{.*}}clang{{(.exe)?}}" "-cc1" "-triple" "powerpc64-ibm-aix7.1.0.0"
+// CHECK-LD64-PTHREAD: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
 // CHECK-LD64-PTHREAD: "-isysroot" "[[SYSROOT:[^"]+]]"
 // CHECK-LD64-PTHREAD: "{{.*}}ld{{(.exe)?}}"
 // 

[PATCH] D78938: Make LLVM build in C++20 mode

2020-09-28 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added inline comments.



Comment at: llvm/include/llvm/IR/BasicBlock.h:324-325
+template ::value>>
 phi_iterator_impl(const phi_iterator_impl )

Quuxplusone wrote:
> dblaikie wrote:
> > BRevzin wrote:
> > > dblaikie wrote:
> > > > What tripped over/required this SFINAE?
> > > There's somewhere which compared a const iterator to a non-const 
> > > iterator, that ends up doing conversions in both directions under C++20 
> > > rules, one direction of which is perfectly fine and the other was a hard 
> > > error. Need to make the non-const iterator not constructible from a const 
> > > iterator.
> > Is this true for all iterators? Or some quirk of how this one is 
> > written/used (that could be fixed/changed there instead)?
> IMO there is a (much) bigger task hiding here, which is to audit every type 
> in the codebase whose name contains the string "Iterator" and compare them to 
> the C++20 Ranges `std::forward_iterator` concept. My impression is that the 
> vast majority of real-world "iterator types" are not iterators according to 
> C++20 Ranges, and that this can have arbitrarily weird effects when you mix 
> them with the C++20 STL.
> 
> However, that is //massive// scope creep re this particular patch. I think 
> the larger question of "do all our iterators need X / are all our iterators 
> written wrong" should be scoped-outside-of this patch.
Sorry, not suggesting that kind of scope creep - but do want to understand 
whether this is representative of the way code should generally be written, or 
whether this is working around some other issue/different fix.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78938

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


[PATCH] D88345: [CUDA] Allow local `static const {__constant__, __device__}` variables.

2020-09-28 Thread Justin Lebar via Phabricator via cfe-commits
jlebar added a comment.

> It should. I did mention in a previous comment that > Looks like the 
> const-ness check should not be there, either. I need to revise the patch.

Heh, okay.  Sorry I missed that, somehow this patch was confusing to me.

> Except that NVCC allows non-const __constant__, too. Generally speaking, C++ 
> does not care about the attributes. While technically __constant__ is not 
> changeable from the device code, not specifying const is a missed 
> optimization/diagnostic opportunity, but not an error per se. It does not 
> affect how the variable is emitted, but rather what user can do with it and 
> that's beyond the scope of this patch. I don't think it warrants a hard 
> error. A warning, perhaps, that non-const __constant__ is probably an error?

Sure, that makes sense to me.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88345

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


[PATCH] D88345: [CUDA] Allow local `static const {__constant__, __device__}` variables.

2020-09-28 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

In D88345#2298879 , @jlebar wrote:

> OK, now I'm starting to I understand this change..
>
> Before, in function scope, we allow static const/non-const `__shared__`, and 
> allow static const so long as it's not `__device__` or `__constant__`.
>
> - `static` -> error?  (I understood us saying above that it is, but now that 
> I read the code, isn't it saying it's an error?)
> - `static const` -> allowed
> - `static __device__` -> error
> - `static const __device__` -> error
> - `static __constant__` -> error
> - `static const __constant__` -> error
>
> After, in function scope, the rule is, allow static const/non-const 
> `__shared__` or anything that's `static const`.
>
> - `static` -> error, must be const
> - `static const` -> allowed
> - `static __device__` -> error, must be const
> - `static const __device__` -> allowed
> - `static __constant__` -> error, must be const
> - `static const __constant__` -> allowed
>
> I guess my question when I write out this table is, why shouldn't it be like 
> this?
>
> - `static` -> allowed
> - `static const` -> allowed
> - `static __device__` -> allowed
> - `const static __device__` -> allowed
> - `static __constant__` -> error, must be const
> - `const static __constant__` -> allowed

It should. I did mention in a previous comment that `> Looks like the 
const-ness check should not be there, either`.
I need to revise the patch.

> This makes some sense to me because we're saying, "`__constant__` must be 
> const", otherwise, anything goes.

Except that NVCC allows non-const `__constant__`, too. Generally speaking, C++ 
does not care about the attributes. While technically `__constant__` is not 
changeable from the device code, not specifying `const` is a missed 
optimization/diagnostic opportunity, but not an error per se. It does not 
affect how the variable is emitted, but rather what user can do with it and 
that's beyond the scope of this patch. I don't think it warrants a hard error. 
A warning, perhaps, that non-const `__constant__` is probably an error?

> Or here's another way of thinking about it.  You're saying that `static` and 
> `static __device__` in function scope are the same as a `__device__` variable 
> in block scope.  And a `__device__` variable in block scope doesn't have to 
> be const (right?).  So why the extra restriction on function-scope static?

Something like that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88345

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


[PATCH] D78938: Make LLVM build in C++20 mode

2020-09-28 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone added inline comments.



Comment at: llvm/include/llvm/IR/BasicBlock.h:324-325
+template ::value>>
 phi_iterator_impl(const phi_iterator_impl )

dblaikie wrote:
> BRevzin wrote:
> > dblaikie wrote:
> > > What tripped over/required this SFINAE?
> > There's somewhere which compared a const iterator to a non-const iterator, 
> > that ends up doing conversions in both directions under C++20 rules, one 
> > direction of which is perfectly fine and the other was a hard error. Need 
> > to make the non-const iterator not constructible from a const iterator.
> Is this true for all iterators? Or some quirk of how this one is written/used 
> (that could be fixed/changed there instead)?
IMO there is a (much) bigger task hiding here, which is to audit every type in 
the codebase whose name contains the string "Iterator" and compare them to the 
C++20 Ranges `std::forward_iterator` concept. My impression is that the vast 
majority of real-world "iterator types" are not iterators according to C++20 
Ranges, and that this can have arbitrarily weird effects when you mix them with 
the C++20 STL.

However, that is //massive// scope creep re this particular patch. I think the 
larger question of "do all our iterators need X / are all our iterators written 
wrong" should be scoped-outside-of this patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78938

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


[PATCH] D87176: [clang] Enable selectively turning on/off format-insufficient-args warning

2020-09-28 Thread Jan Korous via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG1e86d637eb4f: [clang] Selectively ena/disa-ble 
format-insufficient-args warning (authored by jkorous).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87176

Files:
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/test/Misc/warning-wall.c
  clang/test/Sema/warn-printf-insufficient-data-args.c


Index: clang/test/Sema/warn-printf-insufficient-data-args.c
===
--- /dev/null
+++ clang/test/Sema/warn-printf-insufficient-data-args.c
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -fsyntax-only -verify=WARNING-ON %s
+// RUN: %clang_cc1 -fsyntax-only -Wno-format-insufficient-args 
-verify=WARNING-OFF %s
+
+
+int printf(const char * format, ...);
+
+int main(void) {
+  int patatino = 42;
+  printf("%i %i", patatino); // WARNING-ON-warning {{more '%' conversions than 
data arguments}}
+  // WARNING-OFF-no-diagnostics
+}
Index: clang/test/Misc/warning-wall.c
===
--- clang/test/Misc/warning-wall.c
+++ clang/test/Misc/warning-wall.c
@@ -9,6 +9,7 @@
 CHECK-NEXT:  -Wdelete-non-abstract-non-virtual-dtor
 CHECK-NEXT:  -Wdelete-abstract-non-virtual-dtor
 CHECK-NEXT:-Wformat
+CHECK-NEXT:  -Wformat-insufficient-args
 CHECK-NEXT:  -Wformat-extra-args
 CHECK-NEXT:  -Wformat-zero-length
 CHECK-NEXT:  -Wnonnull
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -8921,7 +8921,7 @@
   "array %0 declared here">;
 
 def warn_printf_insufficient_data_args : Warning<
-  "more '%%' conversions than data arguments">, InGroup;
+  "more '%%' conversions than data arguments">, 
InGroup;
 def warn_printf_data_arg_not_used : Warning<
   "data argument not used by format string">, InGroup;
 def warn_format_invalid_conversion : Warning<
Index: clang/include/clang/Basic/DiagnosticGroups.td
===
--- clang/include/clang/Basic/DiagnosticGroups.td
+++ clang/include/clang/Basic/DiagnosticGroups.td
@@ -239,6 +239,7 @@
 def GNUFlexibleArrayInitializer : DiagGroup<"gnu-flexible-array-initializer">;
 def GNUFlexibleArrayUnionMember : DiagGroup<"gnu-flexible-array-union-member">;
 def GNUFoldingConstant : DiagGroup<"gnu-folding-constant">;
+def FormatInsufficientArgs : DiagGroup<"format-insufficient-args">;
 def FormatExtraArgs : DiagGroup<"format-extra-args">;
 def FormatZeroLength : DiagGroup<"format-zero-length">;
 
@@ -849,7 +850,8 @@
 def FormatTypeConfusion : DiagGroup<"format-type-confusion">;
 def Format : DiagGroup<"format",
[FormatExtraArgs, FormatZeroLength, NonNull,
-FormatSecurity, FormatY2K, FormatInvalidSpecifier]>,
+FormatSecurity, FormatY2K, FormatInvalidSpecifier,
+FormatInsufficientArgs]>,
  DiagCategory<"Format String Issue">;
 def FormatNonLiteral : DiagGroup<"format-nonliteral">;
 def Format2 : DiagGroup<"format=2",


Index: clang/test/Sema/warn-printf-insufficient-data-args.c
===
--- /dev/null
+++ clang/test/Sema/warn-printf-insufficient-data-args.c
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -fsyntax-only -verify=WARNING-ON %s
+// RUN: %clang_cc1 -fsyntax-only -Wno-format-insufficient-args -verify=WARNING-OFF %s
+
+
+int printf(const char * format, ...);
+
+int main(void) {
+  int patatino = 42;
+  printf("%i %i", patatino); // WARNING-ON-warning {{more '%' conversions than data arguments}}
+  // WARNING-OFF-no-diagnostics
+}
Index: clang/test/Misc/warning-wall.c
===
--- clang/test/Misc/warning-wall.c
+++ clang/test/Misc/warning-wall.c
@@ -9,6 +9,7 @@
 CHECK-NEXT:  -Wdelete-non-abstract-non-virtual-dtor
 CHECK-NEXT:  -Wdelete-abstract-non-virtual-dtor
 CHECK-NEXT:-Wformat
+CHECK-NEXT:  -Wformat-insufficient-args
 CHECK-NEXT:  -Wformat-extra-args
 CHECK-NEXT:  -Wformat-zero-length
 CHECK-NEXT:  -Wnonnull
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -8921,7 +8921,7 @@
   "array %0 declared here">;
 
 def warn_printf_insufficient_data_args : Warning<
-  "more '%%' conversions than data arguments">, InGroup;
+  "more '%%' conversions than data arguments">, InGroup;
 def warn_printf_data_arg_not_used : Warning<
   

[clang] 1e86d63 - [clang] Selectively ena/disa-ble format-insufficient-args warning

2020-09-28 Thread Jan Korous via cfe-commits

Author: Jan Korous
Date: 2020-09-28T16:24:50-07:00
New Revision: 1e86d637eb4f88e03fcd4b9fd78192487dc2a302

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

LOG: [clang] Selectively ena/disa-ble format-insufficient-args warning

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

Added: 
clang/test/Sema/warn-printf-insufficient-data-args.c

Modified: 
clang/include/clang/Basic/DiagnosticGroups.td
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/test/Misc/warning-wall.c

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticGroups.td 
b/clang/include/clang/Basic/DiagnosticGroups.td
index a2f5aeafd457..d8e66bdefca1 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -239,6 +239,7 @@ def ExtraSemi : DiagGroup<"extra-semi", 
[CXX98CompatExtraSemi,
 def GNUFlexibleArrayInitializer : DiagGroup<"gnu-flexible-array-initializer">;
 def GNUFlexibleArrayUnionMember : DiagGroup<"gnu-flexible-array-union-member">;
 def GNUFoldingConstant : DiagGroup<"gnu-folding-constant">;
+def FormatInsufficientArgs : DiagGroup<"format-insufficient-args">;
 def FormatExtraArgs : DiagGroup<"format-extra-args">;
 def FormatZeroLength : DiagGroup<"format-zero-length">;
 
@@ -849,7 +850,8 @@ def FormatPedantic : DiagGroup<"format-pedantic">;
 def FormatTypeConfusion : DiagGroup<"format-type-confusion">;
 def Format : DiagGroup<"format",
[FormatExtraArgs, FormatZeroLength, NonNull,
-FormatSecurity, FormatY2K, FormatInvalidSpecifier]>,
+FormatSecurity, FormatY2K, FormatInvalidSpecifier,
+FormatInsufficientArgs]>,
  DiagCategory<"Format String Issue">;
 def FormatNonLiteral : DiagGroup<"format-nonliteral">;
 def Format2 : DiagGroup<"format=2",

diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 0cb817df9db3..42d50426ccd8 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -8921,7 +8921,7 @@ def note_array_declared_here : Note<
   "array %0 declared here">;
 
 def warn_printf_insufficient_data_args : Warning<
-  "more '%%' conversions than data arguments">, InGroup;
+  "more '%%' conversions than data arguments">, 
InGroup;
 def warn_printf_data_arg_not_used : Warning<
   "data argument not used by format string">, InGroup;
 def warn_format_invalid_conversion : Warning<

diff  --git a/clang/test/Misc/warning-wall.c b/clang/test/Misc/warning-wall.c
index c63d4beecff0..9975323f7028 100644
--- a/clang/test/Misc/warning-wall.c
+++ b/clang/test/Misc/warning-wall.c
@@ -9,6 +9,7 @@ CHECK-NEXT:-Wdelete-non-virtual-dtor
 CHECK-NEXT:  -Wdelete-non-abstract-non-virtual-dtor
 CHECK-NEXT:  -Wdelete-abstract-non-virtual-dtor
 CHECK-NEXT:-Wformat
+CHECK-NEXT:  -Wformat-insufficient-args
 CHECK-NEXT:  -Wformat-extra-args
 CHECK-NEXT:  -Wformat-zero-length
 CHECK-NEXT:  -Wnonnull

diff  --git a/clang/test/Sema/warn-printf-insufficient-data-args.c 
b/clang/test/Sema/warn-printf-insufficient-data-args.c
new file mode 100644
index ..a8de7118e8b1
--- /dev/null
+++ b/clang/test/Sema/warn-printf-insufficient-data-args.c
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -fsyntax-only -verify=WARNING-ON %s
+// RUN: %clang_cc1 -fsyntax-only -Wno-format-insufficient-args 
-verify=WARNING-OFF %s
+
+
+int printf(const char * format, ...);
+
+int main(void) {
+  int patatino = 42;
+  printf("%i %i", patatino); // WARNING-ON-warning {{more '%' conversions than 
data arguments}}
+  // WARNING-OFF-no-diagnostics
+}



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


[PATCH] D87043: [Analyzer] Fix for dereferece of smart pointer after branching on unknown inner pointer

2020-09-28 Thread Nithin VR via Phabricator via cfe-commits
vrnithinkumar added a comment.

In D87043#2294531 , @Szelethus wrote:

> Congrats on your GSoC! Unless I missed it, it seems like you haven't posted 
> your final report on cfe-dev, even though its an amazing looking document 
> with a lot of examples and explanations. I think it would be great to spread 
> the message, its a work to be proud of!

I am sorry,  I took a break and I forgot about sharing the final report. 
Thanks for the reminder.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87043

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


[PATCH] D88182: [clang][driver][AIX] Set compiler-rt as default rtlib

2020-09-28 Thread David Tenty via Phabricator via cfe-commits
daltenty updated this revision to Diff 294822.
daltenty added a comment.

- Remove blankline
- Fix path seperators in second test as well


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88182

Files:
  clang/lib/Driver/ToolChain.cpp
  clang/lib/Driver/ToolChains/AIX.cpp
  clang/lib/Driver/ToolChains/AIX.h
  clang/test/Driver/aix-ld.c
  clang/test/Driver/aix-rtlib.c

Index: clang/test/Driver/aix-rtlib.c
===
--- /dev/null
+++ clang/test/Driver/aix-rtlib.c
@@ -0,0 +1,10 @@
+// Check the default rtlib for AIX.
+// RUN: %clang -target powerpc-ibm-aix -print-libgcc-file-name -no-canonical-prefixes \
+// RUN:-resource-dir=%S/Inputs/resource_dir \
+// RUN:   | FileCheck -check-prefix=CHECK32 %s
+// RUN: %clang -target powerpc64-ibm-aix -print-libgcc-file-name -no-canonical-prefixes \
+// RUN:-resource-dir=%S/Inputs/resource_dir \
+// RUN:   | FileCheck -check-prefix=CHECK64 %s
+
+// CHECK32: resource_dir{{/|\\}}lib{{/|\\}}aix{{/|\\}}libclang_rt.builtins-powerpc.a
+// CHECK64: resource_dir{{/|\\}}lib{{/|\\}}aix{{/|\\}}libclang_rt.builtins-powerpc64.a
Index: clang/test/Driver/aix-ld.c
===
--- clang/test/Driver/aix-ld.c
+++ clang/test/Driver/aix-ld.c
@@ -3,11 +3,13 @@
 
 // Check powerpc-ibm-aix7.1.0.0, 32-bit.
 // RUN: %clang -no-canonical-prefixes %s -### 2>&1 \
+// RUN:-resource-dir=%S/Inputs/resource_dir \
 // RUN:-target powerpc-ibm-aix7.1.0.0 \
 // RUN:--sysroot %S/Inputs/aix_ppc_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-LD32 %s
 // CHECK-LD32-NOT: warning:
 // CHECK-LD32: {{.*}}clang{{(.exe)?}}" "-cc1" "-triple" "powerpc-ibm-aix7.1.0.0"
+// CHECK-LD32: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
 // CHECK-LD32: "-isysroot" "[[SYSROOT:[^"]+]]"
 // CHECK-LD32: "{{.*}}ld{{(.exe)?}}"
 // CHECK-LD32-NOT: "-bnso"
@@ -17,15 +19,18 @@
 // CHECK-LD32-NOT: "[[SYSROOT]]/usr/lib{{/|}}crti.o"
 // CHECK-LD32: "-L[[SYSROOT]]/usr/lib"
 // CHECK-LD32-NOT: "-lc++"
+// CHECK-LD32: "[[RESOURCE_DIR]]{{/|}}lib{{/|}}aix{{/|}}libclang_rt.builtins-powerpc.a"
 // CHECK-LD32: "-lc"
 
 // Check powerpc64-ibm-aix7.1.0.0, 64-bit.
 // RUN: %clang -no-canonical-prefixes %s -### 2>&1 \
+// RUN:-resource-dir=%S/Inputs/resource_dir \
 // RUN:-target powerpc64-ibm-aix7.1.0.0 \
 // RUN:--sysroot %S/Inputs/aix_ppc_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-LD64 %s
 // CHECK-LD64-NOT: warning:
 // CHECK-LD64: {{.*}}clang{{(.exe)?}}" "-cc1" "-triple" "powerpc64-ibm-aix7.1.0.0"
+// CHECK-LD64: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
 // CHECK-LD64: "-isysroot" "[[SYSROOT:[^"]+]]"
 // CHECK-LD64: "{{.*}}ld{{(.exe)?}}"
 // CHECK-LD64-NOT: "-bnso"
@@ -35,16 +40,19 @@
 // CHECK-LD64-NOT: "[[SYSROOT]]/usr/lib{{/|}}crti_64.o"
 // CHECK-LD64: "-L[[SYSROOT]]/usr/lib"
 // CHECK-LD64-NOT: "-lc++"
+// CHECK-LD64: "[[RESOURCE_DIR]]{{/|}}lib{{/|}}aix{{/|}}libclang_rt.builtins-powerpc64.a"
 // CHECK-LD64: "-lc"
 
 // Check powerpc-ibm-aix7.1.0.0, 32-bit. Enable POSIX thread support.
 // RUN: %clang -no-canonical-prefixes %s -### 2>&1 \
+// RUN:-resource-dir=%S/Inputs/resource_dir \
 // RUN:-pthread \
 // RUN:-target powerpc-ibm-aix7.1.0.0 \
 // RUN:--sysroot %S/Inputs/aix_ppc_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-LD32-PTHREAD %s
 // CHECK-LD32-PTHREAD-NOT: warning:
 // CHECK-LD32-PTHREAD: {{.*}}clang{{(.exe)?}}" "-cc1" "-triple" "powerpc-ibm-aix7.1.0.0"
+// CHECK-LD32-PTHREAD: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
 // CHECK-LD32-PTHREAD: "-isysroot" "[[SYSROOT:[^"]+]]"
 // CHECK-LD32-PTHREAD: "{{.*}}ld{{(.exe)?}}"
 // CHECK-LD32-PTHREAD-NOT: "-bnso"
@@ -54,17 +62,20 @@
 // CHECK-LD32-PTHREAD-NOT: "[[SYSROOT]]/usr/lib{{/|}}crti.o"
 // CHECK-LD32-PTHREAD: "-L[[SYSROOT]]/usr/lib"
 // CHECK-LD32-PTHREAD-NOT: "-lc++"
+// CHECK-LD32-PTHREAD: "[[RESOURCE_DIR]]{{/|}}lib{{/|}}aix{{/|}}libclang_rt.builtins-powerpc.a"
 // CHECK-LD32-PTHREAD: "-lpthreads"
 // CHECK-LD32-PTHREAD: "-lc"
 
 // Check powerpc64-ibm-aix7.1.0.0, 64-bit. POSIX thread alias.
 // RUN: %clang -no-canonical-prefixes %s -### 2>&1 \
+// RUN:-resource-dir=%S/Inputs/resource_dir \
 // RUN:-pthreads \
 // RUN:-target powerpc64-ibm-aix7.1.0.0 \
 // RUN:--sysroot %S/Inputs/aix_ppc_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-LD64-PTHREAD %s
 // CHECK-LD64-PTHREAD-NOT: warning:
 // CHECK-LD64-PTHREAD: {{.*}}clang{{(.exe)?}}" "-cc1" "-triple" "powerpc64-ibm-aix7.1.0.0"
+// CHECK-LD64-PTHREAD: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
 // CHECK-LD64-PTHREAD: "-isysroot" "[[SYSROOT:[^"]+]]"
 // CHECK-LD64-PTHREAD: "{{.*}}ld{{(.exe)?}}"
 // CHECK-LD64-PTHREAD-NOT: "-bnso"
@@ -74,17 +85,20 @@
 // 

[PATCH] D88430: [OpenMP] Replace OpenMP RTL Functions With OMPIRBuilder and OMPKinds.def

2020-09-28 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 updated this revision to Diff 294819.
jhuber6 added a comment.

Removed now unused function for generating convergent runtime functions. 
Updated Clang to print an error message if the user attempts to specify 
incompatible architectures due to a difference in pointer sizes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88430

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/lib/CodeGen/CGOpenMPRuntime.h
  clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
  clang/lib/CodeGen/CodeGenModule.h
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/OpenMP/nvptx_parallel_codegen.cpp
  clang/test/OpenMP/nvptx_target_parallel_reduction_codegen_tbaa_PR46146.cpp
  llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
  llvm/test/Transforms/OpenMP/add_attributes.ll

Index: llvm/test/Transforms/OpenMP/add_attributes.ll
===
--- llvm/test/Transforms/OpenMP/add_attributes.ll
+++ llvm/test/Transforms/OpenMP/add_attributes.ll
@@ -888,313 +888,313 @@
 ; CHECK: declare dso_local i32 @omp_pause_resource_all(i32)
 
 ; CHECK: ; Function Attrs: nounwind
-; CHECK-NEXT: declare dso_local i32 @omp_get_supported_active_levels() #0
+; CHECK-NEXT: declare dso_local i32 @omp_get_supported_active_levels()
 
-; CHECK: ; Function Attrs: nounwind
-; CHECK-NEXT: declare void @__kmpc_barrier(%struct.ident_t*, i32) #0
+; CHECK: ; Function Attrs: convergent nounwind
+; CHECK-NEXT: declare void @__kmpc_barrier(%struct.ident_t*, i32)
 
 ; CHECK: ; Function Attrs: nounwind
-; CHECK-NEXT: declare i32 @__kmpc_cancel(%struct.ident_t*, i32, i32) #0
+; CHECK-NEXT: declare i32 @__kmpc_cancel(%struct.ident_t*, i32, i32)
 
-; CHECK: ; Function Attrs: nounwind
-; CHECK-NEXT: declare i32 @__kmpc_cancel_barrier(%struct.ident_t*, i32) #0
+; CHECK: ; Function Attrs: convergent nounwind
+; CHECK-NEXT: declare i32 @__kmpc_cancel_barrier(%struct.ident_t*, i32)
 
-; CHECK: ; Function Attrs: nounwind
-; CHECK-NEXT: declare void @__kmpc_flush(%struct.ident_t*) #0
+; CHECK: ; Function Attrs: convergent nounwind
+; CHECK-NEXT: declare void @__kmpc_flush(%struct.ident_t*)
 
 ; CHECK: ; Function Attrs: nounwind
-; CHECK-NEXT: declare i32 @__kmpc_global_thread_num(%struct.ident_t*) #0
+; CHECK-NEXT: declare i32 @__kmpc_global_thread_num(%struct.ident_t*)
 
 ; CHECK: ; Function Attrs: nounwind
-; CHECK-NEXT: declare void @__kmpc_fork_call(%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...) #0
+; CHECK-NEXT: declare void @__kmpc_fork_call(%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...)
 
-; CHECK: ; Function Attrs: nounwind
-; CHECK-NEXT: declare i32 @__kmpc_omp_taskwait(%struct.ident_t*, i32) #0
+; CHECK: ; Function Attrs: convergent nounwind
+; CHECK-NEXT: declare i32 @__kmpc_omp_taskwait(%struct.ident_t*, i32)
 
 ; CHECK: ; Function Attrs: nounwind
-; CHECK-NEXT: declare i32 @__kmpc_omp_taskyield(%struct.ident_t*, i32, i32) #0
+; CHECK-NEXT: declare i32 @__kmpc_omp_taskyield(%struct.ident_t*, i32, i32)
 
 ; CHECK: ; Function Attrs: nounwind
-; CHECK-NEXT: declare void @__kmpc_push_num_threads(%struct.ident_t*, i32, i32) #0
+; CHECK-NEXT: declare void @__kmpc_push_num_threads(%struct.ident_t*, i32, i32)
 
 ; CHECK: ; Function Attrs: nounwind
-; CHECK-NEXT: declare void @__kmpc_push_proc_bind(%struct.ident_t*, i32, i32) #0
+; CHECK-NEXT: declare void @__kmpc_push_proc_bind(%struct.ident_t*, i32, i32)
 
 ; CHECK: ; Function Attrs: nounwind
-; CHECK-NEXT: declare void @__kmpc_serialized_parallel(%struct.ident_t*, i32) #0
+; CHECK-NEXT: declare void @__kmpc_serialized_parallel(%struct.ident_t*, i32)
 
 ; CHECK: ; Function Attrs: nounwind
-; CHECK-NEXT: declare void @__kmpc_end_serialized_parallel(%struct.ident_t*, i32) #0
+; CHECK-NEXT: declare void @__kmpc_end_serialized_parallel(%struct.ident_t*, i32)
 
 ; CHECK: ; Function Attrs: nounwind
-; CHECK-NEXT: declare i32 @__kmpc_master(%struct.ident_t*, i32) #0
+; CHECK-NEXT: declare i32 @__kmpc_master(%struct.ident_t*, i32)
 
 ; CHECK: ; Function Attrs: nounwind
-; CHECK-NEXT: declare void @__kmpc_end_master(%struct.ident_t*, i32) #0
+; CHECK-NEXT: declare void @__kmpc_end_master(%struct.ident_t*, i32)
 
-; CHECK: ; Function Attrs: nounwind
-; CHECK-NEXT: declare void @__kmpc_critical(%struct.ident_t*, i32, [8 x i32]*) #0
+; CHECK: ; Function Attrs: convergent nounwind
+; CHECK-NEXT: declare void @__kmpc_critical(%struct.ident_t*, i32, [8 x i32]*)
 
-; CHECK: ; Function Attrs: nounwind
-; CHECK-NEXT: declare void @__kmpc_critical_with_hint(%struct.ident_t*, i32, [8 x i32]*, i32) #0
+; CHECK: ; Function Attrs: convergent nounwind
+; CHECK-NEXT: declare void @__kmpc_critical_with_hint(%struct.ident_t*, i32, [8 x i32]*, i32)
 
-; CHECK: ; Function Attrs: nounwind
-; CHECK-NEXT: declare void @__kmpc_end_critical(%struct.ident_t*, i32, [8 x i32]*) #0
+; CHECK: ; Function Attrs: convergent nounwind
+; CHECK-NEXT: declare void 

[PATCH] D88452: [Driver] Move detectLibcxxIncludePath to ToolChain

2020-09-28 Thread Petr Hosek via Phabricator via cfe-commits
phosek created this revision.
phosek added reviewers: kristina, leonardchan.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
phosek requested review of this revision.

This helper method is useful even outside of Gnu toolchains, so move
it to ToolChain so it can be reused in other toolchains such as Fuchsia.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D88452

Files:
  clang/include/clang/Driver/ToolChain.h
  clang/lib/Driver/ToolChain.cpp
  clang/lib/Driver/ToolChains/Fuchsia.cpp
  clang/lib/Driver/ToolChains/Gnu.cpp

Index: clang/lib/Driver/ToolChains/Gnu.cpp
===
--- clang/lib/Driver/ToolChains/Gnu.cpp
+++ clang/lib/Driver/ToolChains/Gnu.cpp
@@ -2866,31 +2866,11 @@
   }
 }
 
-static std::string DetectLibcxxIncludePath(llvm::vfs::FileSystem ,
-   StringRef base) {
-  std::error_code EC;
-  int MaxVersion = 0;
-  std::string MaxVersionString;
-  for (llvm::vfs::directory_iterator LI = vfs.dir_begin(base, EC), LE;
-   !EC && LI != LE; LI = LI.increment(EC)) {
-StringRef VersionText = llvm::sys::path::filename(LI->path());
-int Version;
-if (VersionText[0] == 'v' &&
-!VersionText.slice(1, StringRef::npos).getAsInteger(10, Version)) {
-  if (Version > MaxVersion) {
-MaxVersion = Version;
-MaxVersionString = std::string(VersionText);
-  }
-}
-  }
-  return MaxVersion ? (base + "/" + MaxVersionString).str() : "";
-}
-
 void
 Generic_GCC::addLibCxxIncludePaths(const llvm::opt::ArgList ,
llvm::opt::ArgStringList ) const {
   auto AddIncludePath = [&](std::string Path) {
-std::string IncludePath = DetectLibcxxIncludePath(getVFS(), Path);
+std::string IncludePath = detectLibcxxIncludePath(Path);
 if (IncludePath.empty() || !getVFS().exists(IncludePath))
   return false;
 addSystemInclude(DriverArgs, CC1Args, IncludePath);
Index: clang/lib/Driver/ToolChains/Fuchsia.cpp
===
--- clang/lib/Driver/ToolChains/Fuchsia.cpp
+++ clang/lib/Driver/ToolChains/Fuchsia.cpp
@@ -319,8 +319,8 @@
   switch (GetCXXStdlibType(DriverArgs)) {
   case ToolChain::CST_Libcxx: {
 SmallString<128> P(getDriver().Dir);
-llvm::sys::path::append(P, "..", "include", "c++", "v1");
-addSystemInclude(DriverArgs, CC1Args, P.str());
+llvm::sys::path::append(P, "..", "include", "c++");
+addSystemInclude(DriverArgs, CC1Args, detectLibcxxIncludePath(P.str()));
 break;
   }
 
Index: clang/lib/Driver/ToolChain.cpp
===
--- clang/lib/Driver/ToolChain.cpp
+++ clang/lib/Driver/ToolChain.cpp
@@ -922,6 +922,29 @@
   }
 }
 
+std::string ToolChain::detectLibcxxIncludePath(StringRef Base) const {
+  std::error_code EC;
+  int MaxVersion = 0;
+  std::string MaxVersionString;
+  for (llvm::vfs::directory_iterator LI = getVFS().dir_begin(Base, EC), LE;
+   !EC && LI != LE; LI = LI.increment(EC)) {
+StringRef VersionText = llvm::sys::path::filename(LI->path());
+int Version;
+if (VersionText[0] == 'v' &&
+!VersionText.slice(1, StringRef::npos).getAsInteger(10, Version)) {
+  if (Version > MaxVersion) {
+MaxVersion = Version;
+MaxVersionString = std::string(VersionText);
+  }
+}
+  }
+  if (!MaxVersion)
+return "";
+  SmallString<128> P(Base);
+  llvm::sys::path::append(P, MaxVersionString);
+  return std::string(P.str());
+}
+
 void ToolChain::AddClangCXXStdlibIncludeArgs(const ArgList ,
  ArgStringList ) const {
   // Header search paths should be handled by each of the subclasses.
Index: clang/include/clang/Driver/ToolChain.h
===
--- clang/include/clang/Driver/ToolChain.h
+++ clang/include/clang/Driver/ToolChain.h
@@ -575,6 +575,10 @@
   // given compilation arguments.
   virtual UnwindLibType GetUnwindLibType(const llvm::opt::ArgList ) const;
 
+  // Detect the highest available version of libc++ in base path.
+  virtual std::string
+  detectLibcxxIncludePath(StringRef Base) const;
+
   /// AddClangCXXStdlibIncludeArgs - Add the clang -cc1 level arguments to set
   /// the include paths to use for the given C++ standard library type.
   virtual void
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D68364: Implement C++20's P0784 (More constexpr containers)

2020-09-28 Thread Louis Dionne via Phabricator via cfe-commits
ldionne added a comment.

In D68364#2294569 , @jwakely wrote:

> In D68364#2293971 , @leonardchan 
> wrote:
>
>> Is there a recommended way for working around this? We're using GCC 10.2.1. 
>> Thanks.
>
> I don't think your implementation is valid. I think P0784 only allows 
> new-expressions and calls to `std::allocator::allocate` in constexpr 
> functions, not calls to `operator new`.

Hmm, right. It's actually impossible to implement `__libcpp_allocate` in a 
constexpr-friendly manner, since it's just allocating bytes.

> Can you use something like `if (__builtin_is_constant_evaluated()) return new 
> unsigned char[n];` and the equivalent in the corresponding deallocation 
> function?

That doesn't work, since we can't use `unsigned char`s as storage for arbitrary 
`T`s in `constexpr`.

I fixed it by marking `__libcpp_allocate` as non-`constexpr` and calling 
`operator new` in `allocator::allocate`, which seems to work on GCC.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68364

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


[PATCH] D85808: [Remarks][2/2] Expand remarks hotness threshold option support in more tools

2020-09-28 Thread Wei Wang via Phabricator via cfe-commits
weiwang added a comment.

@tejohnson @MaskRay Do you have other comments to the change?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85808

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


[PATCH] D87853: [SemaTemplate] Stop passing insertion position around during VarTemplate instantiation

2020-09-28 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno added a comment.

Ping!


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

https://reviews.llvm.org/D87853

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


[PATCH] D88333: Better diagnostics for anonymous bit-fields with attributes or an initializer

2020-09-28 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith accepted this revision.
rsmith added a comment.
This revision is now accepted and ready to land.

Thanks!




Comment at: clang/lib/Parse/ParseDecl.cpp:4126
 /// struct-declarator: declarator[opt] ':' constant-expression
-if (Tok.isNot(tok::colon)) {
+if (Tok.isNot(tok::colon) && !isCXX11AttributeSpecifier()) {
   // Don't parse FOO:BAR as if it were a typo for FOO::BAR.

I think this change is redundant now.



Comment at: clang/lib/Parse/ParseDeclCXX.cpp:2317
+  // current grammar rules as of C++20.
+  if (Tok.isNot(tok::colon) && !isCXX11AttributeSpecifier())
 ParseDeclarator(DeclaratorInfo);

Similarly here, I think the check for an attribute specifier is now redundant.


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

https://reviews.llvm.org/D88333

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


[PATCH] D87822: [FPEnv] Evaluate constant expressions under non-default rounding modes

2020-09-28 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan added a comment.

Hi! It looks like this is causing a test failure on our aach64 builders 
(https://luci-milo.appspot.com/p/fuchsia/builders/ci/clang-linux-arm64/b8868095822628984976?):

  [1113/1114] Running the Clang regression tests
  llvm-lit: 
/b/s/w/ir/k/staging/llvm_build/bin/../../../llvm-project/llvm/utils/lit/lit/llvm/config.py:379:
 note: using clang: /b/s/w/ir/k/staging/llvm_build/bin/clang
  -- Testing: 26708 tests, 256 workers --
  Testing: 
  FAIL: Clang :: AST/const-fpfeatures-diag.c (269 of 26708)
   TEST 'Clang :: AST/const-fpfeatures-diag.c' FAILED 

  Script:
  --
  : 'RUN: at line 1';   /b/s/w/ir/k/staging/llvm_build/bin/clang -cc1 
-internal-isystem /b/s/w/ir/k/staging/llvm_build/lib/clang/12.0.0/include 
-nostdsysteminc -verify -ffp-exception-behavior=strict -Wno-unknown-pragmas 
/b/s/w/ir/k/llvm-project/clang/test/AST/const-fpfeatures-diag.c
  --
  Exit Code: 1
  
  Command Output (stderr):
  --
  error: 'error' diagnostics expected but not seen: 
File /b/s/w/ir/k/llvm-project/clang/test/AST/const-fpfeatures-diag.c Line 
8: initializer element is not a compile-time constant
  error: 'warning' diagnostics seen but not expected: 
(frontend): overriding currently unsupported use of floating point 
exceptions on this target
  2 errors generated.
  
  --
  
  
  Testing:  0.. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90.. 
  
  Failed Tests (1):
Clang :: AST/const-fpfeatures-diag.c

Would you mind taking a look and sending out a fix? Thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87822

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


[PATCH] D80344: [Windows SEH]: HARDWARE EXCEPTION HANDLING (MSVC -EHa) - Part 1

2020-09-28 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

Sounds good to me, thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80344

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


[PATCH] D88445: Use "default member initializer" instead of "in-class initializer" for diagnostics

2020-09-28 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

Thanks!




Comment at: clang/include/clang/Basic/DiagnosticParseKinds.td:864-867
+  "default member initialization of non-static data member is a C++11 "
+  "extension">, InGroup;
 def warn_cxx98_compat_nonstatic_member_init : Warning<
+  "default member initialization of non-static data members is incompatible "

Consider "initialization of" -> "initializer for", so we use the standard term 
in full.



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:8506-8524
+def err_default_member_initializer_non_const : Error<
   "non-const static data member must be initialized out of line">;
-def err_in_class_initializer_volatile : Error<
+def err_default_member_initializer_volatile : Error<
   "static const volatile data member must be initialized out of line">;
-def err_in_class_initializer_bad_type : Error<
+def err_default_member_initializer_bad_type : Error<
   "static data member of type %0 must be initialized out of line">;
+def ext_default_member_initializer_float_type : ExtWarn<

For a static member, it's just an initializer, not a default member 
initializer. I think "in-class initializer" is probably the best we can say 
here.



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:8533-8536
+def ext_default_member_initializer_non_constant : Extension<
+  "default member initializer for static data member is not a constant "
+  "expression; folding it to a constant is a GNU extension">,
+  InGroup;

Likewise, this case is an initializer for a static member, and is not a default 
member initializer.


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

https://reviews.llvm.org/D88445

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


[PATCH] D78938: Make LLVM build in C++20 mode

2020-09-28 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added inline comments.



Comment at: llvm/include/llvm/IR/BasicBlock.h:324-325
+template ::value>>
 phi_iterator_impl(const phi_iterator_impl )

BRevzin wrote:
> dblaikie wrote:
> > What tripped over/required this SFINAE?
> There's somewhere which compared a const iterator to a non-const iterator, 
> that ends up doing conversions in both directions under C++20 rules, one 
> direction of which is perfectly fine and the other was a hard error. Need to 
> make the non-const iterator not constructible from a const iterator.
Is this true for all iterators? Or some quirk of how this one is written/used 
(that could be fixed/changed there instead)?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78938

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


Re: [clang] af1d3e6 - Allow init_priority values <= 100 and > 65535 within system headers.

2020-09-28 Thread Aaron Ballman via cfe-commits
On Mon, Sep 28, 2020 at 4:46 PM Robinson, Paul  wrote:
> > -Original Message-
> > From: cfe-commits  On Behalf Of Aaron
> > Ballman via cfe-commits
> > Sent: Wednesday, September 23, 2020 3:27 PM
> > To: cfe-commits@lists.llvm.org
> > Subject: [clang] af1d3e6 - Allow init_priority values <= 100 and > 65535
> > within system headers.
> >
> >
> > Author: Aaron Ballman
> > Date: 2020-09-23T15:26:50-04:00
> > New Revision: af1d3e655991e5f0c86df372b8583a60d20268e0
> >
> > URL: https://urldefense.com/v3/__https://github.com/llvm/llvm-
> > project/commit/af1d3e655991e5f0c86df372b8583a60d20268e0__;!!JmoZiZGBv3RvKR
> > Sx!uCGMaNBytzj1FhG349bRMYFleWUAIQwiwZLW4mUe1SfbBjKnJvDM4dGzlplaS-cftQ$
> > DIFF: https://urldefense.com/v3/__https://github.com/llvm/llvm-
> > project/commit/af1d3e655991e5f0c86df372b8583a60d20268e0.diff__;!!JmoZiZGBv
> > 3RvKRSx!uCGMaNBytzj1FhG349bRMYFleWUAIQwiwZLW4mUe1SfbBjKnJvDM4dGzlpn6UUxJFg
> > $
> >
> > LOG: Allow init_priority values <= 100 and > 65535 within system headers.
> >
> > This also adds some bare-bones documentation for the attribute rather
> > than leaving it undocumented.
> >
> > Added:
> >
> >
> > Modified:
> > clang/include/clang/Basic/Attr.td
> > clang/include/clang/Basic/AttrDocs.td
> > clang/lib/Sema/SemaDeclAttr.cpp
> > clang/test/SemaCXX/init-priority-attr.cpp
> >
> > Removed:
> >
> >
> >
> > ##
> > ##
> > diff  --git a/clang/include/clang/Basic/Attr.td
> > b/clang/include/clang/Basic/Attr.td
> > index e8ac819c8b556..7222f396089e0 100644
> > --- a/clang/include/clang/Basic/Attr.td
> > +++ b/clang/include/clang/Basic/Attr.td
> > @@ -2196,7 +2196,7 @@ def InitPriority : InheritableAttr {
> >let Spellings = [GCC<"init_priority", /*AllowInC*/0>];
> >let Args = [UnsignedArgument<"Priority">];
> >let Subjects = SubjectList<[Var], ErrorDiag>;
> > -  let Documentation = [Undocumented];
> > +  let Documentation = [InitPriorityDocs];
> >  }
> >
> >  def Section : InheritableAttr {
> >
> > diff  --git a/clang/include/clang/Basic/AttrDocs.td
> > b/clang/include/clang/Basic/AttrDocs.td
> > index 9c119218656d8..3e27924589e4a 100644
> > --- a/clang/include/clang/Basic/AttrDocs.td
> > +++ b/clang/include/clang/Basic/AttrDocs.td
> > @@ -57,6 +57,32 @@ global variable or function should be in after
> > translation.
> >let Heading = "section, __declspec(allocate)";
> >  }
> >
> > +def InitPriorityDocs : Documentation {
> > +  let Category = DocCatVariable;
> > +  let Content = [{
> > +In C++, the order in which global variables are initialized across
> > translation
> > +units is unspecified, unlike the ordering within a single translation
> > unit. The
> > +``init_priority`` attribute allows you to specify a relative ordering for
> > the
> > +initialization of objects declared at namespace scope in C++. The
> > priority is
> > +given as an integer constant expression between 101 and 65535
> > (inclusive).
> > +Priorities outside of that range are reserved for use by the
> > implementation. A
> > +lower value indicates a higher priority of initialization. Note that only
> > the
> > +relative ordering of values is important. For example:
> > +
> > +.. code-block:: c++
> > +
> > +  struct SomeType { SomeType(); };
> > +  __attribute__((init_priority(200))) SomeType Obj1;
> > +  __attribute__((init_priority(101))) SomeType Obj2;
> > +
> > +``Obj1`` will be initialized *before* ``Obj2`` despite the usual order of
> > +initialization being the opposite.
>
> I think here ``Obj2`` will be initialized before ``Obj1``
> despite the usual order?  (Usual order would be in order of
> declaration, and init_priority goes from low to high.)

You are absolutely correct -- I fat-fingered the example with a late
change to the numerical suffixes. Thank you for catching this! I've
corrected it in e7549dafcd33ced4280a81ca1d1ee4cc78ed253f.

~Aaron

> --paulr
>
> > +
> > +This attribute is only supported for C++ and Objective-C++ and is ignored
> > in
> > +other language modes.
> > +  }];
> > +}
> > +
> >  def InitSegDocs : Documentation {
> >let Category = DocCatVariable;
> >let Content = [{
> >
> > diff  --git a/clang/lib/Sema/SemaDeclAttr.cpp
> > b/clang/lib/Sema/SemaDeclAttr.cpp
> > index 6edeb79396296..3babbe05ca8f9 100644
> > --- a/clang/lib/Sema/SemaDeclAttr.cpp
> > +++ b/clang/lib/Sema/SemaDeclAttr.cpp
> > @@ -3313,7 +3313,11 @@ static void handleInitPriorityAttr(Sema , Decl
> > *D, const ParsedAttr ) {
> >  return;
> >}
> >
> > -  if (prioritynum < 101 || prioritynum > 65535) {
> > +  // Only perform the priority check if the attribute is outside of a
> > system
> > +  // header. Values <= 100 are reserved for the implementation, and
> > libc++
> > +  // benefits from being able to specify values in that range.
> > +  if ((prioritynum < 101 || prioritynum > 65535) &&
> > +  !S.getSourceManager().isInSystemHeader(AL.getLoc())) {
> >  S.Diag(AL.getLoc(), 

[PATCH] D86790: [FE] Use preferred alignment instead of ABI alignment for complete object when applicable

2020-09-28 Thread Jason Liu via Phabricator via cfe-commits
jasonliu accepted this revision.
jasonliu added a comment.
This revision is now accepted and ready to land.

LGTM.


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

https://reviews.llvm.org/D86790

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


[clang] e7549da - Fix a think-o with the numerical suffixes in the docs for init_priority.

2020-09-28 Thread Aaron Ballman via cfe-commits

Author: Aaron Ballman
Date: 2020-09-28T16:52:58-04:00
New Revision: e7549dafcd33ced4280a81ca1d1ee4cc78ed253f

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

LOG: Fix a think-o with the numerical suffixes in the docs for init_priority.

Added: 


Modified: 
clang/include/clang/Basic/AttrDocs.td

Removed: 




diff  --git a/clang/include/clang/Basic/AttrDocs.td 
b/clang/include/clang/Basic/AttrDocs.td
index 46b6b643e3de..8c236796546c 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -75,7 +75,7 @@ relative ordering of values is important. For example:
   __attribute__((init_priority(200))) SomeType Obj1;
   __attribute__((init_priority(101))) SomeType Obj2;
 
-``Obj1`` will be initialized *before* ``Obj2`` despite the usual order of
+``Obj2`` will be initialized *before* ``Obj1`` despite the usual order of
 initialization being the opposite.
 
 This attribute is only supported for C++ and Objective-C++ and is ignored in



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


[PATCH] D88446: docs: add documentation describing API Notes

2020-09-28 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd created this revision.
compnerd added reviewers: MForster, gribozavr2, rsmith.
Herald added a subscriber: jfb.
Herald added a project: clang.
compnerd requested review of this revision.

API Notes are a feature which allows annotation of headers by an
auxiliary file that contains metadata for declarations pertaining to the
associated module.  This enables adding attributes to declarations
without requiring modification of the headers, enabling finer grained
control for library headers for consumers without having to modify
external headers.

Based on the work from 
https://github.com/llvm/llvm-project-staging/commit/d238492fd3a82160955d0642b85d8ce620fa3258


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D88446

Files:
  clang/docs/APINotes.rst
  
clang/test/APINotes/Inputs/Frameworks/SomeKit.framework/Headers/SomeKit.apinotes
  clang/test/APINotes/Inputs/Frameworks/SomeKit.framework/Headers/SomeKit.h
  
clang/test/APINotes/Inputs/Frameworks/SomeKit.framework/Headers/SomeKitExplicitNullability.h
  
clang/test/APINotes/Inputs/Frameworks/SomeKit.framework/Headers/SomeKit_private.apinotes

Index: clang/test/APINotes/Inputs/Frameworks/SomeKit.framework/Headers/SomeKit_private.apinotes
===
--- /dev/null
+++ clang/test/APINotes/Inputs/Frameworks/SomeKit.framework/Headers/SomeKit_private.apinotes
@@ -0,0 +1,15 @@
+Name: SomeKit
+Classes:
+  - Name: A
+Methods:
+  - Selector: "privateTransform:input:"
+MethodKind:  Instance
+NullabilityOfRet: N
+Nullability:  [ N, S ]
+Properties:
+  - Name: internalProperty
+Nullability: N
+Protocols:
+  - Name: InternalProtocol
+Availability: none
+AvailabilityMsg: "not for you"
Index: clang/test/APINotes/Inputs/Frameworks/SomeKit.framework/Headers/SomeKitExplicitNullability.h
===
--- /dev/null
+++ clang/test/APINotes/Inputs/Frameworks/SomeKit.framework/Headers/SomeKitExplicitNullability.h
@@ -0,0 +1,4 @@
+@interface A(ExplicitNullabilityProperties)
+@property (nonatomic, readwrite, retain, nonnull) A *explicitNonnullInstance;
+@property (nonatomic, readwrite, retain, nullable) A *explicitNullableInstance;
+@end
Index: clang/test/APINotes/Inputs/Frameworks/SomeKit.framework/Headers/SomeKit.h
===
--- /dev/null
+++ clang/test/APINotes/Inputs/Frameworks/SomeKit.framework/Headers/SomeKit.h
@@ -0,0 +1,60 @@
+#ifndef SOMEKIT_H
+#define SOMEKIT_H
+
+__attribute__((objc_root_class))
+@interface A
+-(A*)transform:(A*)input;
+-(A*)transform:(A*)input integer:(int)integer;
+
+@property (nonatomic, readonly, retain) A* someA;
+@property (nonatomic, retain) A* someOtherA;
+
+@property (nonatomic) int intValue;
+@end
+
+@interface B : A
+@end
+
+@interface C : A
+- (instancetype)init;
+- (instancetype)initWithA:(A*)a;
+@end
+
+@interface ProcessInfo : A
++(instancetype)processInfo;
+@end
+
+@interface A(NonNullProperties)
+@property (nonatomic, readwrite, retain) A *nonnullAInstance;
+@property (class, nonatomic, readwrite, retain) A *nonnullAInstance;
+
+@property (nonatomic, readwrite, retain) A *nonnullAClass;
+@property (class, nonatomic, readwrite, retain) A *nonnullAClass;
+
+@property (nonatomic, readwrite, retain) A *nonnullABoth;
+@property (class, nonatomic, readwrite, retain) A *nonnullABoth;
+@end
+
+#import 
+
+extern int *global_int_ptr;
+
+int *global_int_fun(int *ptr, int *ptr2);
+
+#define SOMEKIT_DOUBLE double
+
+__attribute__((objc_root_class))
+@interface OverriddenTypes
+-(int *)methodToMangle:(int *)ptr1 second:(int *)ptr2;
+@property int *intPropertyToMangle;
+@end
+
+@interface A(ImplicitGetterSetters)
+@property (nonatomic, readonly, retain) A *implicitGetOnlyInstance;
+@property (class, nonatomic, readonly, retain) A *implicitGetOnlyClass;
+
+@property (nonatomic, readwrite, retain) A *implicitGetSetInstance;
+@property (class, nonatomic, readwrite, retain) A *implicitGetSetClass;
+@end
+
+#endif
Index: clang/test/APINotes/Inputs/Frameworks/SomeKit.framework/Headers/SomeKit.apinotes
===
--- /dev/null
+++ clang/test/APINotes/Inputs/Frameworks/SomeKit.framework/Headers/SomeKit.apinotes
@@ -0,0 +1,98 @@
+Name: SomeKit
+Classes:
+  - Name: A
+Methods:
+  - Selector:"transform:"
+MethodKind:  Instance
+Availability:none
+AvailabilityMsg: "anything but this"
+  - Selector: "transform:integer:"
+MethodKind:  Instance
+NullabilityOfRet: N
+Nullability:  [ N, S ]
+  - Selector: "implicitGetOnlyInstance"
+MethodKind:  Instance
+Availability:none
+AvailabilityMsg: "getter gone"
+  - Selector: "implicitGetOnlyClass"
+MethodKind:  Class
+Availability:none
+AvailabilityMsg: "getter gone"

RE: [clang] af1d3e6 - Allow init_priority values <= 100 and > 65535 within system headers.

2020-09-28 Thread Robinson, Paul via cfe-commits


> -Original Message-
> From: cfe-commits  On Behalf Of Aaron
> Ballman via cfe-commits
> Sent: Wednesday, September 23, 2020 3:27 PM
> To: cfe-commits@lists.llvm.org
> Subject: [clang] af1d3e6 - Allow init_priority values <= 100 and > 65535
> within system headers.
> 
> 
> Author: Aaron Ballman
> Date: 2020-09-23T15:26:50-04:00
> New Revision: af1d3e655991e5f0c86df372b8583a60d20268e0
> 
> URL: https://urldefense.com/v3/__https://github.com/llvm/llvm-
> project/commit/af1d3e655991e5f0c86df372b8583a60d20268e0__;!!JmoZiZGBv3RvKR
> Sx!uCGMaNBytzj1FhG349bRMYFleWUAIQwiwZLW4mUe1SfbBjKnJvDM4dGzlplaS-cftQ$
> DIFF: https://urldefense.com/v3/__https://github.com/llvm/llvm-
> project/commit/af1d3e655991e5f0c86df372b8583a60d20268e0.diff__;!!JmoZiZGBv
> 3RvKRSx!uCGMaNBytzj1FhG349bRMYFleWUAIQwiwZLW4mUe1SfbBjKnJvDM4dGzlpn6UUxJFg
> $
> 
> LOG: Allow init_priority values <= 100 and > 65535 within system headers.
> 
> This also adds some bare-bones documentation for the attribute rather
> than leaving it undocumented.
> 
> Added:
> 
> 
> Modified:
> clang/include/clang/Basic/Attr.td
> clang/include/clang/Basic/AttrDocs.td
> clang/lib/Sema/SemaDeclAttr.cpp
> clang/test/SemaCXX/init-priority-attr.cpp
> 
> Removed:
> 
> 
> 
> ##
> ##
> diff  --git a/clang/include/clang/Basic/Attr.td
> b/clang/include/clang/Basic/Attr.td
> index e8ac819c8b556..7222f396089e0 100644
> --- a/clang/include/clang/Basic/Attr.td
> +++ b/clang/include/clang/Basic/Attr.td
> @@ -2196,7 +2196,7 @@ def InitPriority : InheritableAttr {
>let Spellings = [GCC<"init_priority", /*AllowInC*/0>];
>let Args = [UnsignedArgument<"Priority">];
>let Subjects = SubjectList<[Var], ErrorDiag>;
> -  let Documentation = [Undocumented];
> +  let Documentation = [InitPriorityDocs];
>  }
> 
>  def Section : InheritableAttr {
> 
> diff  --git a/clang/include/clang/Basic/AttrDocs.td
> b/clang/include/clang/Basic/AttrDocs.td
> index 9c119218656d8..3e27924589e4a 100644
> --- a/clang/include/clang/Basic/AttrDocs.td
> +++ b/clang/include/clang/Basic/AttrDocs.td
> @@ -57,6 +57,32 @@ global variable or function should be in after
> translation.
>let Heading = "section, __declspec(allocate)";
>  }
> 
> +def InitPriorityDocs : Documentation {
> +  let Category = DocCatVariable;
> +  let Content = [{
> +In C++, the order in which global variables are initialized across
> translation
> +units is unspecified, unlike the ordering within a single translation
> unit. The
> +``init_priority`` attribute allows you to specify a relative ordering for
> the
> +initialization of objects declared at namespace scope in C++. The
> priority is
> +given as an integer constant expression between 101 and 65535
> (inclusive).
> +Priorities outside of that range are reserved for use by the
> implementation. A
> +lower value indicates a higher priority of initialization. Note that only
> the
> +relative ordering of values is important. For example:
> +
> +.. code-block:: c++
> +
> +  struct SomeType { SomeType(); };
> +  __attribute__((init_priority(200))) SomeType Obj1;
> +  __attribute__((init_priority(101))) SomeType Obj2;
> +
> +``Obj1`` will be initialized *before* ``Obj2`` despite the usual order of
> +initialization being the opposite.

I think here ``Obj2`` will be initialized before ``Obj1``
despite the usual order?  (Usual order would be in order of
declaration, and init_priority goes from low to high.)
--paulr

> +
> +This attribute is only supported for C++ and Objective-C++ and is ignored
> in
> +other language modes.
> +  }];
> +}
> +
>  def InitSegDocs : Documentation {
>let Category = DocCatVariable;
>let Content = [{
> 
> diff  --git a/clang/lib/Sema/SemaDeclAttr.cpp
> b/clang/lib/Sema/SemaDeclAttr.cpp
> index 6edeb79396296..3babbe05ca8f9 100644
> --- a/clang/lib/Sema/SemaDeclAttr.cpp
> +++ b/clang/lib/Sema/SemaDeclAttr.cpp
> @@ -3313,7 +3313,11 @@ static void handleInitPriorityAttr(Sema , Decl
> *D, const ParsedAttr ) {
>  return;
>}
> 
> -  if (prioritynum < 101 || prioritynum > 65535) {
> +  // Only perform the priority check if the attribute is outside of a
> system
> +  // header. Values <= 100 are reserved for the implementation, and
> libc++
> +  // benefits from being able to specify values in that range.
> +  if ((prioritynum < 101 || prioritynum > 65535) &&
> +  !S.getSourceManager().isInSystemHeader(AL.getLoc())) {
>  S.Diag(AL.getLoc(), diag::err_attribute_argument_out_of_range)
>  << E->getSourceRange() << AL << 101 << 65535;
>  AL.setInvalid();
> 
> diff  --git a/clang/test/SemaCXX/init-priority-attr.cpp
> b/clang/test/SemaCXX/init-priority-attr.cpp
> index 8f31e2fd62d00..5b5e3b9eb940e 100644
> --- a/clang/test/SemaCXX/init-priority-attr.cpp
> +++ b/clang/test/SemaCXX/init-priority-attr.cpp
> @@ -1,4 +1,9 @@
>  // RUN: %clang_cc1 -fsyntax-only -verify %s
> +// RUN: %clang_cc1 -fsyntax-only -DSYSTEM -verify %s
> +
> +#if 

[PATCH] D83296: [clang-format] Add a MacroExpander.

2020-09-28 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

In D83296#2299062 , @nridge wrote:

> What does this change mean for users of clang-format -- better formatting of 
> complicated (e.g. multi-line) macro invocations?

Nothing from this change is exposed yet, it's part of a series.
The end goal is as you say: perfect formatting of code in and around arbitrary 
macros, by passing (simplified) macro definitions as configuration.

D88299  is next, Manuel assures me it gets 
easier from there :-)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83296

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


[PATCH] D80344: [Windows SEH]: HARDWARE EXCEPTION HANDLING (MSVC -EHa) - Part 1

2020-09-28 Thread Ten Tzen via Phabricator via cfe-commits
tentzen added a comment.

OK, great.  
Summarize our discussion above, I will follow up with:

- rename intrinsic eha.scope.begin() with seh.scope.begin().
- update LangRef.rst with detailed explanation
- not to allow inlining under SEH direct lexical scope
- add conditional cleanup test case and make sure that eha.scope.begin() is 
emitted in the right place
- add sideEntry label support in AST-dumper and de/serialization.

thank you for your thorough review and valuable feedbacks.  I'm in the middle 
of something else. I will post another patch latter.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80344

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


[PATCH] D88445: Use "default member initializer" instead of "in-class initializer" for diagnostics

2020-09-28 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman created this revision.
aaron.ballman added a reviewer: rsmith.
aaron.ballman requested review of this revision.

This changes some diagnostics to use terminology from the standard rather than 
invented terminology, which improves consistency with other diagnostics as 
well. There are no functional changes intended other than wording and naming.


https://reviews.llvm.org/D88445

Files:
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaTemplateInstantiate.cpp
  clang/test/Parser/MicrosoftExtensions.cpp
  clang/test/Parser/cxx-class.cpp
  clang/test/SemaCXX/PR9572.cpp
  clang/test/SemaCXX/class.cpp
  clang/test/SemaCXX/cxx0x-class.cpp
  clang/test/SemaCXX/cxx98-compat.cpp
  clang/test/SemaCXX/gnu-flags.cpp
  clang/test/SemaCXX/member-init.cpp
  clang/test/SemaCXX/warn-static-const-float.cpp
  clang/test/SemaTemplate/instantiate-static-var.cpp

Index: clang/test/SemaTemplate/instantiate-static-var.cpp
===
--- clang/test/SemaTemplate/instantiate-static-var.cpp
+++ clang/test/SemaTemplate/instantiate-static-var.cpp
@@ -5,7 +5,7 @@
 template
 class X {
 public:
-  static const T value = 10 / Divisor; // expected-error{{in-class initializer for static data member is not a constant expression}}
+  static const T value = 10 / Divisor; // expected-error{{default member initializer for static data member is not a constant expression}}
 };
 
 int array1[X::value == 5? 1 : -1];
@@ -14,11 +14,11 @@
 
 template
 class Y {
-  static const T value = 0; 
+  static const T value = 0;
 #if __cplusplus <= 199711L
-// expected-warning@-2 {{in-class initializer for static data member of type 'const float' is a GNU extension}}
+// expected-warning@-2 {{default member initializer for static data member of type 'const float' is a GNU extension}}
 #else
-// expected-error@-4 {{in-class initializer for static data member of type 'const float' requires 'constexpr' specifier}}
+// expected-error@-4 {{default member initializer for static data member of type 'const float' requires 'constexpr' specifier}}
 // expected-note@-5 {{add 'constexpr'}}
 #endif
 };
@@ -38,7 +38,7 @@
 
 struct DefCon {};
 
-struct NoDefCon { 
+struct NoDefCon {
   NoDefCon(const NoDefCon&); // expected-note{{candidate constructor}}
 };
 
@@ -103,7 +103,7 @@
 }
 
 namespace PR6449 {
-  template
+  template
   struct X0  {
 static const bool var = false;
   };
@@ -116,7 +116,7 @@
 static const bool var = false;
   };
 
-  template  
+  template
   const bool X1::var;
 
   template class X0;
Index: clang/test/SemaCXX/warn-static-const-float.cpp
===
--- clang/test/SemaCXX/warn-static-const-float.cpp
+++ clang/test/SemaCXX/warn-static-const-float.cpp
@@ -10,10 +10,10 @@
 #if NONE
 // expected-no-diagnostics
 #elif ERR
-// expected-error@20 {{in-class initializer for static data member of type 'const double' requires 'constexpr' specifier}}
+// expected-error@20 {{default member initializer for static data member of type 'const double' requires 'constexpr' specifier}}
 // expected-note@20 {{add 'constexpr'}}
 #elif EXT
-// expected-warning@20 {{in-class initializer for static data member of type 'const double' is a GNU extension}}
+// expected-warning@20 {{default member initializer for static data member of type 'const double' is a GNU extension}}
 #endif
 
 struct X {
Index: clang/test/SemaCXX/member-init.cpp
===
--- clang/test/SemaCXX/member-init.cpp
+++ clang/test/SemaCXX/member-init.cpp
@@ -21,20 +21,20 @@
 };
 
 struct UnknownBound {
-  int as[] = { 1, 2, 3 }; // expected-error {{array bound cannot be deduced from an in-class initializer}}
+  int as[] = { 1, 2, 3 }; // expected-error {{array bound cannot be deduced from a default member initializer}}
   int bs[4] = { 4, 5, 6, 7 };
-  int cs[] = { 8, 9, 10 }; // expected-error {{array bound cannot be deduced from an in-class initializer}}
+  int cs[] = { 8, 9, 10 }; // expected-error {{array bound cannot be deduced from a default member initializer}}
 };
 
 template struct T { static const int B; };
 template<> struct T<2> { template using B = int; };
 const int C = 0, D = 0;
 struct S {
-  int as[] = { decltype(x)::B(0) }; // expected-error {{array bound cannot be deduced from an in-class initializer}}
+  int as[] = { decltype(x)::B(0) }; // expected-error {{array bound cannot be deduced from a default member initializer}}
   T x;
   // test that we handle invalid array bound deductions without crashing when the declarator name is itself invalid
   operator int[](){}; // expected-error {{'operator int' cannot be the name of a variable or data member}} \
-  // expected-error {{array bound cannot be deduced from an in-class initializer}}
+

[PATCH] D88430: [OpenMP] Replace OpenMP RTL Functions With OMPIRBuilder and OMPKinds.def

2020-09-28 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 updated this revision to Diff 294798.
jhuber6 added a comment.
Herald added a subscriber: aaron.ballman.

Reusing OMPBuilder from CGOpenMPRuntime. Altered the failing test case. This 
case failed when compiling for a 32 bit device on a 64 bit host. This case 
should be considered an error because the host and device have incompatible 
pointer sizes and shouldn't be able to communicate. The test has been changed 
to only compile for hosts and devices that have compatible pointer sizes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88430

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.h
  clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
  clang/test/OpenMP/nvptx_parallel_codegen.cpp
  clang/test/OpenMP/nvptx_target_parallel_reduction_codegen_tbaa_PR46146.cpp
  llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
  llvm/test/Transforms/OpenMP/add_attributes.ll

Index: llvm/test/Transforms/OpenMP/add_attributes.ll
===
--- llvm/test/Transforms/OpenMP/add_attributes.ll
+++ llvm/test/Transforms/OpenMP/add_attributes.ll
@@ -888,313 +888,313 @@
 ; CHECK: declare dso_local i32 @omp_pause_resource_all(i32)
 
 ; CHECK: ; Function Attrs: nounwind
-; CHECK-NEXT: declare dso_local i32 @omp_get_supported_active_levels() #0
+; CHECK-NEXT: declare dso_local i32 @omp_get_supported_active_levels()
 
-; CHECK: ; Function Attrs: nounwind
-; CHECK-NEXT: declare void @__kmpc_barrier(%struct.ident_t*, i32) #0
+; CHECK: ; Function Attrs: convergent nounwind
+; CHECK-NEXT: declare void @__kmpc_barrier(%struct.ident_t*, i32)
 
 ; CHECK: ; Function Attrs: nounwind
-; CHECK-NEXT: declare i32 @__kmpc_cancel(%struct.ident_t*, i32, i32) #0
+; CHECK-NEXT: declare i32 @__kmpc_cancel(%struct.ident_t*, i32, i32)
 
-; CHECK: ; Function Attrs: nounwind
-; CHECK-NEXT: declare i32 @__kmpc_cancel_barrier(%struct.ident_t*, i32) #0
+; CHECK: ; Function Attrs: convergent nounwind
+; CHECK-NEXT: declare i32 @__kmpc_cancel_barrier(%struct.ident_t*, i32)
 
-; CHECK: ; Function Attrs: nounwind
-; CHECK-NEXT: declare void @__kmpc_flush(%struct.ident_t*) #0
+; CHECK: ; Function Attrs: convergent nounwind
+; CHECK-NEXT: declare void @__kmpc_flush(%struct.ident_t*)
 
 ; CHECK: ; Function Attrs: nounwind
-; CHECK-NEXT: declare i32 @__kmpc_global_thread_num(%struct.ident_t*) #0
+; CHECK-NEXT: declare i32 @__kmpc_global_thread_num(%struct.ident_t*)
 
 ; CHECK: ; Function Attrs: nounwind
-; CHECK-NEXT: declare void @__kmpc_fork_call(%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...) #0
+; CHECK-NEXT: declare void @__kmpc_fork_call(%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...)
 
-; CHECK: ; Function Attrs: nounwind
-; CHECK-NEXT: declare i32 @__kmpc_omp_taskwait(%struct.ident_t*, i32) #0
+; CHECK: ; Function Attrs: convergent nounwind
+; CHECK-NEXT: declare i32 @__kmpc_omp_taskwait(%struct.ident_t*, i32)
 
 ; CHECK: ; Function Attrs: nounwind
-; CHECK-NEXT: declare i32 @__kmpc_omp_taskyield(%struct.ident_t*, i32, i32) #0
+; CHECK-NEXT: declare i32 @__kmpc_omp_taskyield(%struct.ident_t*, i32, i32)
 
 ; CHECK: ; Function Attrs: nounwind
-; CHECK-NEXT: declare void @__kmpc_push_num_threads(%struct.ident_t*, i32, i32) #0
+; CHECK-NEXT: declare void @__kmpc_push_num_threads(%struct.ident_t*, i32, i32)
 
 ; CHECK: ; Function Attrs: nounwind
-; CHECK-NEXT: declare void @__kmpc_push_proc_bind(%struct.ident_t*, i32, i32) #0
+; CHECK-NEXT: declare void @__kmpc_push_proc_bind(%struct.ident_t*, i32, i32)
 
 ; CHECK: ; Function Attrs: nounwind
-; CHECK-NEXT: declare void @__kmpc_serialized_parallel(%struct.ident_t*, i32) #0
+; CHECK-NEXT: declare void @__kmpc_serialized_parallel(%struct.ident_t*, i32)
 
 ; CHECK: ; Function Attrs: nounwind
-; CHECK-NEXT: declare void @__kmpc_end_serialized_parallel(%struct.ident_t*, i32) #0
+; CHECK-NEXT: declare void @__kmpc_end_serialized_parallel(%struct.ident_t*, i32)
 
 ; CHECK: ; Function Attrs: nounwind
-; CHECK-NEXT: declare i32 @__kmpc_master(%struct.ident_t*, i32) #0
+; CHECK-NEXT: declare i32 @__kmpc_master(%struct.ident_t*, i32)
 
 ; CHECK: ; Function Attrs: nounwind
-; CHECK-NEXT: declare void @__kmpc_end_master(%struct.ident_t*, i32) #0
+; CHECK-NEXT: declare void @__kmpc_end_master(%struct.ident_t*, i32)
 
-; CHECK: ; Function Attrs: nounwind
-; CHECK-NEXT: declare void @__kmpc_critical(%struct.ident_t*, i32, [8 x i32]*) #0
+; CHECK: ; Function Attrs: convergent nounwind
+; CHECK-NEXT: declare void @__kmpc_critical(%struct.ident_t*, i32, [8 x i32]*)
 
-; CHECK: ; Function Attrs: nounwind
-; CHECK-NEXT: declare void @__kmpc_critical_with_hint(%struct.ident_t*, i32, [8 x i32]*, i32) #0
+; CHECK: ; Function Attrs: convergent nounwind
+; CHECK-NEXT: declare void @__kmpc_critical_with_hint(%struct.ident_t*, i32, [8 x i32]*, i32)
 
-; CHECK: ; Function Attrs: nounwind
-; CHECK-NEXT: declare void @__kmpc_end_critical(%struct.ident_t*, i32, [8 x i32]*) #0
+; CHECK: ; Function Attrs: 

[clang] 288c577 - [X86] Use inlineasm flag output for the _bittest* intrinsics.

2020-09-28 Thread Craig Topper via cfe-commits

Author: Craig Topper
Date: 2020-09-28T13:33:22-07:00
New Revision: 288c5776c9d3cb14abe1c86f961c8ff166772d28

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

LOG: [X86] Use inlineasm flag output for the _bittest* intrinsics.

Instead of expliciting emitting a setc in the inline asm instructions,
we can use flag output. This allows the backend to use the flag
directly if it is needed by a branch. Previously we needed a test
instruction to convert the register back to a flag.

If the flag can't be used directly, the backend will emit a setcc.

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

Added: 
llvm/test/CodeGen/X86/bittest-intrin.ll

Modified: 
clang/lib/CodeGen/CGBuiltin.cpp
clang/test/CodeGen/bittest-intrin.c

Removed: 




diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 102b5aefe8ff..57804494d9a5 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -805,10 +805,10 @@ static llvm::Value 
*EmitX86BitTestIntrinsic(CodeGenFunction ,
   AsmOS << "bt";
   if (Action)
 AsmOS << Action;
-  AsmOS << SizeSuffix << " $2, ($1)\n\tsetc ${0:b}";
+  AsmOS << SizeSuffix << " $2, ($1)";
 
   // Build the constraints. FIXME: We should support immediates when possible.
-  std::string Constraints = "=r,r,r,~{cc},~{memory}";
+  std::string Constraints = "={@ccc},r,r,~{cc},~{memory}";
   std::string MachineClobbers = CGF.getTarget().getClobbers();
   if (!MachineClobbers.empty()) {
 Constraints += ',';

diff  --git a/clang/test/CodeGen/bittest-intrin.c 
b/clang/test/CodeGen/bittest-intrin.c
index ddc2af5454d7..25e367384d78 100644
--- a/clang/test/CodeGen/bittest-intrin.c
+++ b/clang/test/CodeGen/bittest-intrin.c
@@ -34,20 +34,20 @@ void test_arm(long *base, long idx) {
 #endif
 
 // X64-LABEL: define dso_local void @test32(i32* %base, i32 %idx)
-// X64: call i8 asm sideeffect "btl $2, ($1)\0A\09setc ${0:b}", 
"=r,r,r,~{cc},~{memory},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}}, i32 {{.*}})
-// X64: call i8 asm sideeffect "btcl $2, ($1)\0A\09setc ${0:b}", 
"=r,r,r,~{cc},~{memory},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}}, i32 {{.*}})
-// X64: call i8 asm sideeffect "btrl $2, ($1)\0A\09setc ${0:b}", 
"=r,r,r,~{cc},~{memory},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}}, i32 {{.*}})
-// X64: call i8 asm sideeffect "btsl $2, ($1)\0A\09setc ${0:b}", 
"=r,r,r,~{cc},~{memory},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}}, i32 {{.*}})
-// X64: call i8 asm sideeffect "lock btrl $2, ($1)\0A\09setc ${0:b}", 
"=r,r,r,~{cc},~{memory},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}}, i32 {{.*}})
-// X64: call i8 asm sideeffect "lock btsl $2, ($1)\0A\09setc ${0:b}", 
"=r,r,r,~{cc},~{memory},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}}, i32 {{.*}})
+// X64: call i8 asm sideeffect "btl $2, ($1)", 
"={@ccc},r,r,~{cc},~{memory},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}}, i32 
{{.*}})
+// X64: call i8 asm sideeffect "btcl $2, ($1)", 
"={@ccc},r,r,~{cc},~{memory},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}}, i32 
{{.*}})
+// X64: call i8 asm sideeffect "btrl $2, ($1)", 
"={@ccc},r,r,~{cc},~{memory},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}}, i32 
{{.*}})
+// X64: call i8 asm sideeffect "btsl $2, ($1)", 
"={@ccc},r,r,~{cc},~{memory},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}}, i32 
{{.*}})
+// X64: call i8 asm sideeffect "lock btrl $2, ($1)", 
"={@ccc},r,r,~{cc},~{memory},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}}, i32 
{{.*}})
+// X64: call i8 asm sideeffect "lock btsl $2, ($1)", 
"={@ccc},r,r,~{cc},~{memory},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}}, i32 
{{.*}})
 
 // X64-LABEL: define dso_local void @test64(i64* %base, i64 %idx)
-// X64: call i8 asm sideeffect "btq $2, ($1)\0A\09setc ${0:b}", 
"=r,r,r,~{cc},~{memory},~{dirflag},~{fpsr},~{flags}"(i64* %{{.*}}, i64 {{.*}})
-// X64: call i8 asm sideeffect "btcq $2, ($1)\0A\09setc ${0:b}", 
"=r,r,r,~{cc},~{memory},~{dirflag},~{fpsr},~{flags}"(i64* %{{.*}}, i64 {{.*}})
-// X64: call i8 asm sideeffect "btrq $2, ($1)\0A\09setc ${0:b}", 
"=r,r,r,~{cc},~{memory},~{dirflag},~{fpsr},~{flags}"(i64* %{{.*}}, i64 {{.*}})
-// X64: call i8 asm sideeffect "btsq $2, ($1)\0A\09setc ${0:b}", 
"=r,r,r,~{cc},~{memory},~{dirflag},~{fpsr},~{flags}"(i64* %{{.*}}, i64 {{.*}})
-// X64: call i8 asm sideeffect "lock btrq $2, ($1)\0A\09setc ${0:b}", 
"=r,r,r,~{cc},~{memory},~{dirflag},~{fpsr},~{flags}"(i64* %{{.*}}, i64 {{.*}})
-// X64: call i8 asm sideeffect "lock btsq $2, ($1)\0A\09setc ${0:b}", 
"=r,r,r,~{cc},~{memory},~{dirflag},~{fpsr},~{flags}"(i64* %{{.*}}, i64 {{.*}})
+// X64: call i8 asm sideeffect "btq $2, ($1)", 
"={@ccc},r,r,~{cc},~{memory},~{dirflag},~{fpsr},~{flags}"(i64* %{{.*}}, i64 
{{.*}})
+// X64: call i8 asm sideeffect "btcq $2, ($1)", 
"={@ccc},r,r,~{cc},~{memory},~{dirflag},~{fpsr},~{flags}"(i64* %{{.*}}, 

[PATCH] D87888: [X86] Use inlineasm flag output for the _bittest* intrinsics.

2020-09-28 Thread Craig Topper via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG288c5776c9d3: [X86] Use inlineasm flag output for the 
_bittest* intrinsics. (authored by craig.topper).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87888

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/bittest-intrin.c
  llvm/test/CodeGen/X86/bittest-intrin.ll

Index: llvm/test/CodeGen/X86/bittest-intrin.ll
===
--- /dev/null
+++ llvm/test/CodeGen/X86/bittest-intrin.ll
@@ -0,0 +1,101 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc < %s -mtriple=x86_64-unknown-windows-msvc19.11.0 | FileCheck %s
+
+; This matches the code produced by clang/lib/CodeGen/bittest-intrin.c
+
+@sink = global i8 0, align 1
+
+define void @test32(i32* %base, i32 %idx) {
+; CHECK-LABEL: test32:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:#APP
+; CHECK-NEXT:btl %edx, (%rcx)
+; CHECK-NEXT:#NO_APP
+; CHECK-NEXT:setb {{.*}}(%rip)
+; CHECK-NEXT:#APP
+; CHECK-NEXT:btcl %edx, (%rcx)
+; CHECK-NEXT:#NO_APP
+; CHECK-NEXT:setb {{.*}}(%rip)
+; CHECK-NEXT:#APP
+; CHECK-NEXT:btrl %edx, (%rcx)
+; CHECK-NEXT:#NO_APP
+; CHECK-NEXT:setb {{.*}}(%rip)
+; CHECK-NEXT:#APP
+; CHECK-NEXT:btsl %edx, (%rcx)
+; CHECK-NEXT:#NO_APP
+; CHECK-NEXT:setb {{.*}}(%rip)
+; CHECK-NEXT:#APP
+; CHECK-NEXT:lock btrl %edx, (%rcx)
+; CHECK-NEXT:#NO_APP
+; CHECK-NEXT:setb {{.*}}(%rip)
+; CHECK-NEXT:#APP
+; CHECK-NEXT:lock btsl %edx, (%rcx)
+; CHECK-NEXT:#NO_APP
+; CHECK-NEXT:setb {{.*}}(%rip)
+; CHECK-NEXT:#APP
+; CHECK-NEXT:lock btsl %edx, (%rcx)
+; CHECK-NEXT:#NO_APP
+; CHECK-NEXT:setb {{.*}}(%rip)
+; CHECK-NEXT:retq
+entry:
+  %0 = tail call i8 asm sideeffect "btl $2, ($1)", "={@ccc},r,r,~{cc},~{memory},~{dirflag},~{fpsr},~{flags}"(i32* %base, i32 %idx)
+  store volatile i8 %0, i8* @sink, align 1
+  %1 = tail call i8 asm sideeffect "btcl $2, ($1)", "={@ccc},r,r,~{cc},~{memory},~{dirflag},~{fpsr},~{flags}"(i32* %base, i32 %idx)
+  store volatile i8 %1, i8* @sink, align 1
+  %2 = tail call i8 asm sideeffect "btrl $2, ($1)", "={@ccc},r,r,~{cc},~{memory},~{dirflag},~{fpsr},~{flags}"(i32* %base, i32 %idx)
+  store volatile i8 %2, i8* @sink, align 1
+  %3 = tail call i8 asm sideeffect "btsl $2, ($1)", "={@ccc},r,r,~{cc},~{memory},~{dirflag},~{fpsr},~{flags}"(i32* %base, i32 %idx)
+  store volatile i8 %3, i8* @sink, align 1
+  %4 = tail call i8 asm sideeffect "lock btrl $2, ($1)", "={@ccc},r,r,~{cc},~{memory},~{dirflag},~{fpsr},~{flags}"(i32* %base, i32 %idx)
+  store volatile i8 %4, i8* @sink, align 1
+  %5 = tail call i8 asm sideeffect "lock btsl $2, ($1)", "={@ccc},r,r,~{cc},~{memory},~{dirflag},~{fpsr},~{flags}"(i32* %base, i32 %idx)
+  store volatile i8 %5, i8* @sink, align 1
+  %6 = tail call i8 asm sideeffect "lock btsl $2, ($1)", "={@ccc},r,r,~{cc},~{memory},~{dirflag},~{fpsr},~{flags}"(i32* %base, i32 %idx)
+  store volatile i8 %6, i8* @sink, align 1
+  ret void
+}
+
+; Function Attrs: nounwind uwtable
+define void @test64(i64* %base, i64 %idx) {
+; CHECK-LABEL: test64:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:#APP
+; CHECK-NEXT:btq %rdx, (%rcx)
+; CHECK-NEXT:#NO_APP
+; CHECK-NEXT:setb {{.*}}(%rip)
+; CHECK-NEXT:#APP
+; CHECK-NEXT:btcq %rdx, (%rcx)
+; CHECK-NEXT:#NO_APP
+; CHECK-NEXT:setb {{.*}}(%rip)
+; CHECK-NEXT:#APP
+; CHECK-NEXT:btrq %rdx, (%rcx)
+; CHECK-NEXT:#NO_APP
+; CHECK-NEXT:setb {{.*}}(%rip)
+; CHECK-NEXT:#APP
+; CHECK-NEXT:btsq %rdx, (%rcx)
+; CHECK-NEXT:#NO_APP
+; CHECK-NEXT:setb {{.*}}(%rip)
+; CHECK-NEXT:#APP
+; CHECK-NEXT:lock btrq %rdx, (%rcx)
+; CHECK-NEXT:#NO_APP
+; CHECK-NEXT:setb {{.*}}(%rip)
+; CHECK-NEXT:#APP
+; CHECK-NEXT:lock btsq %rdx, (%rcx)
+; CHECK-NEXT:#NO_APP
+; CHECK-NEXT:setb {{.*}}(%rip)
+; CHECK-NEXT:retq
+entry:
+  %0 = tail call i8 asm sideeffect "btq $2, ($1)", "={@ccc},r,r,~{cc},~{memory},~{dirflag},~{fpsr},~{flags}"(i64* %base, i64 %idx)
+  store volatile i8 %0, i8* @sink, align 1
+  %1 = tail call i8 asm sideeffect "btcq $2, ($1)", "={@ccc},r,r,~{cc},~{memory},~{dirflag},~{fpsr},~{flags}"(i64* %base, i64 %idx)
+  store volatile i8 %1, i8* @sink, align 1
+  %2 = tail call i8 asm sideeffect "btrq $2, ($1)", "={@ccc},r,r,~{cc},~{memory},~{dirflag},~{fpsr},~{flags}"(i64* %base, i64 %idx)
+  store volatile i8 %2, i8* @sink, align 1
+  %3 = tail call i8 asm sideeffect "btsq $2, ($1)", "={@ccc},r,r,~{cc},~{memory},~{dirflag},~{fpsr},~{flags}"(i64* %base, i64 %idx)
+  store volatile i8 %3, i8* @sink, align 1
+  %4 = tail call i8 asm sideeffect "lock btrq $2, ($1)", "={@ccc},r,r,~{cc},~{memory},~{dirflag},~{fpsr},~{flags}"(i64* %base, i64 %idx)
+  store volatile i8 %4, i8* @sink, align 1
+  %5 = tail call i8 asm 

[PATCH] D86841: [clang] Add mustprogress and llvm.loop.mustprogress attribute deduction

2020-09-28 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added inline comments.



Comment at: clang/test/CodeGen/attr-mustprogress-1.cpp:24
+  }
+}
+

Now here, and below with `while(1)` I would *not* expect `mustprogress`.



Comment at: clang/test/CodeGen/attr-mustprogress-1.cpp:185
+  do {
+  } while (a == b);
+}

Here I would not expect the function attr but the metadata on the second loop. 
I guess we might want to add the metadata always for loops w/o a constant 
condition especially because the order of the two loops might be swapped 
(please add a test).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86841

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


[PATCH] D86841: [clang] Add mustprogress and llvm.loop.mustprogress attribute deduction

2020-09-28 Thread Atmn Patel via Phabricator via cfe-commits
atmnpatel updated this revision to Diff 294794.
atmnpatel added a comment.

attempt 3


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86841

Files:
  clang/lib/CodeGen/CGLoopInfo.cpp
  clang/lib/CodeGen/CGLoopInfo.h
  clang/lib/CodeGen/CGStmt.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/test/CodeGen/address-safety-attr-flavors.cpp
  clang/test/CodeGen/address-safety-attr.cpp
  clang/test/CodeGen/attr-mustprogress-0.c
  clang/test/CodeGen/attr-mustprogress-0.cpp
  clang/test/CodeGen/attr-mustprogress-1.c
  clang/test/CodeGen/attr-mustprogress-1.cpp
  clang/test/CodeGen/memtag-attr.cpp
  clang/test/CodeGen/no-builtin.cpp
  clang/test/CodeGenCXX/cxx11-trivial-initializer-struct.cpp
  clang/test/CodeGenCXX/fno-unroll-loops-metadata.cpp
  clang/test/CodeGenCXX/thunks-ehspec.cpp
  clang/test/CodeGenCXX/thunks.cpp
  clang/test/OpenMP/simd_metadata.c
  clang/test/Profile/c-unprofiled-blocks.c
  clang/test/utils/update_cc_test_checks/Inputs/basic-cplusplus.cpp.expected
  
clang/test/utils/update_cc_test_checks/Inputs/check-attributes.cpp.funcattrs.expected
  
clang/test/utils/update_cc_test_checks/Inputs/generated-funcs.c.generated.expected
  
clang/test/utils/update_cc_test_checks/Inputs/generated-funcs.c.no-generated.expected

Index: clang/test/utils/update_cc_test_checks/Inputs/generated-funcs.c.no-generated.expected
===
--- clang/test/utils/update_cc_test_checks/Inputs/generated-funcs.c.no-generated.expected
+++ clang/test/utils/update_cc_test_checks/Inputs/generated-funcs.c.no-generated.expected
@@ -41,7 +41,7 @@
 // NOOMP-NEXT:[[TMP2:%.*]] = load i32, i32* [[I]], align 4
 // NOOMP-NEXT:[[INC:%.*]] = add nsw i32 [[TMP2]], 1
 // NOOMP-NEXT:store i32 [[INC]], i32* [[I]], align 4
-// NOOMP-NEXT:br label [[FOR_COND]]
+// NOOMP-NEXT:br label [[FOR_COND]], [[LOOP2:!llvm.loop !.*]]
 // NOOMP:   for.end:
 // NOOMP-NEXT:call void @foo()
 // NOOMP-NEXT:ret i32 0
@@ -86,7 +86,7 @@
 // NOOMP-NEXT:[[TMP2:%.*]] = load i32, i32* [[I]], align 4
 // NOOMP-NEXT:[[INC:%.*]] = add nsw i32 [[TMP2]], 1
 // NOOMP-NEXT:store i32 [[INC]], i32* [[I]], align 4
-// NOOMP-NEXT:br label [[FOR_COND]]
+// NOOMP-NEXT:br label [[FOR_COND]], [[LOOP4:!llvm.loop !.*]]
 // NOOMP:   for.end:
 // NOOMP-NEXT:ret void
 //
Index: clang/test/utils/update_cc_test_checks/Inputs/generated-funcs.c.generated.expected
===
--- clang/test/utils/update_cc_test_checks/Inputs/generated-funcs.c.generated.expected
+++ clang/test/utils/update_cc_test_checks/Inputs/generated-funcs.c.generated.expected
@@ -197,7 +197,7 @@
 // NOOMP-NEXT:[[TMP2:%.*]] = load i32, i32* [[I]], align 4
 // NOOMP-NEXT:[[INC:%.*]] = add nsw i32 [[TMP2]], 1
 // NOOMP-NEXT:store i32 [[INC]], i32* [[I]], align 4
-// NOOMP-NEXT:br label [[FOR_COND]]
+// NOOMP-NEXT:br label [[FOR_COND]], [[LOOP2:!llvm.loop !.*]]
 // NOOMP:   for.end:
 // NOOMP-NEXT:call void @foo()
 // NOOMP-NEXT:ret i32 0
@@ -223,7 +223,7 @@
 // NOOMP-NEXT:[[TMP2:%.*]] = load i32, i32* [[I]], align 4
 // NOOMP-NEXT:[[INC:%.*]] = add nsw i32 [[TMP2]], 1
 // NOOMP-NEXT:store i32 [[INC]], i32* [[I]], align 4
-// NOOMP-NEXT:br label [[FOR_COND]]
+// NOOMP-NEXT:br label [[FOR_COND]], [[LOOP4:!llvm.loop !.*]]
 // NOOMP:   for.end:
 // NOOMP-NEXT:ret void
 //
Index: clang/test/utils/update_cc_test_checks/Inputs/check-attributes.cpp.funcattrs.expected
===
--- clang/test/utils/update_cc_test_checks/Inputs/check-attributes.cpp.funcattrs.expected
+++ clang/test/utils/update_cc_test_checks/Inputs/check-attributes.cpp.funcattrs.expected
@@ -11,7 +11,7 @@
   struct RT Z;
 };
 
-// CHECK: Function Attrs: noinline nounwind optnone
+// CHECK: Function Attrs: noinline nounwind optnone mustprogress
 // CHECK-LABEL: @_Z3fooP2ST(
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:[[S_ADDR:%.*]] = alloca %struct.ST*, align 8
Index: clang/test/utils/update_cc_test_checks/Inputs/basic-cplusplus.cpp.expected
===
--- clang/test/utils/update_cc_test_checks/Inputs/basic-cplusplus.cpp.expected
+++ clang/test/utils/update_cc_test_checks/Inputs/basic-cplusplus.cpp.expected
@@ -44,7 +44,7 @@
 // CHECK-NEXT:[[THIS_ADDR:%.*]] = alloca %class.Foo*, align 8
 // CHECK-NEXT:store %class.Foo* [[THIS:%.*]], %class.Foo** [[THIS_ADDR]], align 8
 // CHECK-NEXT:[[THIS1:%.*]] = load %class.Foo*, %class.Foo** [[THIS_ADDR]], align 8
-// CHECK-NEXT:call void @_ZN3FooD2Ev(%class.Foo* [[THIS1]]) [[ATTR2:#.*]]
+// CHECK-NEXT:call void @_ZN3FooD2Ev(%class.Foo* [[THIS1]]) [[ATTR3:#.*]]
 // CHECK-NEXT:ret void
 //
 Foo::~Foo() {}
@@ -70,7 +70,7 @@
 // CHECK-NEXT:call void @_ZN3FooC1Ei(%class.Foo* [[F]], 

[PATCH] D83296: [clang-format] Add a MacroExpander.

2020-09-28 Thread Nathan Ridge via Phabricator via cfe-commits
nridge added a comment.

What does this change mean for users of clang-format -- better formatting of 
complicated (e.g. multi-line) macro invocations?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83296

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


[PATCH] D86790: [FE] Use preferred alignment instead of ABI alignment for complete object when applicable

2020-09-28 Thread Xiangling Liao via Phabricator via cfe-commits
Xiangling_L updated this revision to Diff 294787.
Xiangling_L added a comment.

Add delete[] function to the testcase;


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

https://reviews.llvm.org/D86790

Files:
  clang/include/clang/AST/ASTContext.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/CodeGen/CGExprCXX.cpp
  clang/lib/CodeGen/ItaniumCXXABI.cpp
  clang/lib/CodeGen/TargetInfo.cpp
  clang/test/CodeGen/aix-alignment.c
  clang/test/CodeGenCXX/aix-alignment.cpp

Index: clang/test/CodeGenCXX/aix-alignment.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/aix-alignment.cpp
@@ -0,0 +1,40 @@
+// REQUIRES: powerpc-registered-target
+// RUN: %clang_cc1 -triple powerpc-unknown-aix \
+// RUN: -emit-llvm -o - -x c++ %s | \
+// RUN:   FileCheck %s --check-prefixes=AIX,AIX32
+// RUN: %clang_cc1 -triple powerpc64-unknown-aix \
+// RUN: -emit-llvm -o - %s -x c++| \
+// RUN:   FileCheck %s --check-prefixes=AIX,AIX64
+
+struct B {
+  double d;
+  ~B() {}
+};
+
+// AIX32: %call = call noalias nonnull i8* @_Znam(i32 8)
+// AIX64: %call = call noalias nonnull i8* @_Znam(i64 8)
+B *allocBp() { return new B[0]; }
+
+// AIX-LABEL: delete.notnull:
+// AIX32: %0 = bitcast %struct.B* %call to i8*
+// AIX32: %1 = getelementptr inbounds i8, i8* %0, i32 -8
+// AIX32: %2 = getelementptr inbounds i8, i8* %1, i32 4
+// AIX32: %3 = bitcast i8* %2 to i32*
+// AIX64: %0 = bitcast %struct.B* %call to i8*
+// AIX64: %1 = getelementptr inbounds i8, i8* %0, i64 -8
+// AIX64: %2 = bitcast i8* %1 to i64*
+void bar() { delete[] allocBp(); }
+
+typedef struct D {
+  double d;
+  int i;
+
+  ~D(){};
+} D;
+
+// AIX: define void @_Z3foo1D(%struct.D* noalias sret align 4 %agg.result, %struct.D* %x)
+// AIX:   %1 = bitcast %struct.D* %agg.result to i8*
+// AIX:   %2 = bitcast %struct.D* %x to i8*
+// AIX32  call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %1, i8* align 4 %2, i32 16, i1 false)
+// AIX64: call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %1, i8* align 4 %2, i64 16, i1 false)
+D foo(D x) { return x; }
Index: clang/test/CodeGen/aix-alignment.c
===
--- /dev/null
+++ clang/test/CodeGen/aix-alignment.c
@@ -0,0 +1,41 @@
+// REQUIRES: powerpc-registered-target
+// RUN: %clang_cc1 -triple powerpc-unknown-aix -emit-llvm -o - %s | \
+// RUN:   FileCheck %s --check-prefixes=AIX,AIX32
+// RUN: %clang_cc1 -triple powerpc64-unknown-aix -emit-llvm -o - %s | \
+// RUN:   FileCheck %s --check-prefixes=AIX,AIX64
+
+// AIX: @d = global double 0.00e+00, align 8
+double d;
+
+typedef struct {
+  double d;
+  int i;
+} StructDouble;
+
+// AIX: @d1 = global %struct.StructDouble zeroinitializer, align 8
+StructDouble d1;
+
+// AIX: double @retDouble(double %x)
+// AIX: %x.addr = alloca double, align 8
+// AIX: store double %x, double* %x.addr, align 8
+// AIX: load double, double* %x.addr, align 8
+// AIX: ret double %0
+double retDouble(double x) { return x; }
+
+// AIX32: define void @bar(%struct.StructDouble* noalias sret align 4 %agg.result, %struct.StructDouble* byval(%struct.StructDouble) align 4 %x)
+// AIX64: define void @bar(%struct.StructDouble* noalias sret align 4 %agg.result, %struct.StructDouble* byval(%struct.StructDouble) align 8 %x)
+// AIX: %0 = bitcast %struct.StructDouble* %agg.result to i8*
+// AIX: %1 = bitcast %struct.StructDouble* %x to i8*
+// AIX32:   call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %0, i8* align 4 %1, i32 16, i1 false)
+// AIX64:   call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %0, i8* align 8 %1, i64 16, i1 false)
+StructDouble bar(StructDouble x) { return x; }
+
+// AIX:   define void @foo(double* %out, double* %in)
+// AIX32:   %0 = load double*, double** %in.addr, align 4
+// AIX64:   %0 = load double*, double** %in.addr, align 8
+// AIX: %1 = load double, double* %0, align 4
+// AIX: %mul = fmul double %1, 2.00e+00
+// AIX32:   %2 = load double*, double** %out.addr, align 4
+// AIX64:   %2 = load double*, double** %out.addr, align 8
+// AIX: store double %mul, double* %2, align 4
+void foo(double *out, double *in) { *out = *in * 2; }
Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -4512,8 +4512,6 @@
   if (RetTy->isVoidType())
 return ABIArgInfo::getIgnore();
 
-  // TODO:  Evaluate if AIX power alignment rule would have an impact on the
-  // alignment here.
   if (isAggregateTypeForABI(RetTy))
 return getNaturalAlignIndirect(RetTy);
 
@@ -4530,8 +4528,6 @@
   if (Ty->isVectorType())
 llvm::report_fatal_error("vector type is not supported on AIX yet");
 
-  // TODO:  Evaluate if AIX power alignment rule would have an impact on the
-  // alignment here.
   if (isAggregateTypeForABI(Ty)) {
 // Records with non-trivial destructors/copy-constructors should not be
 // passed by 

[PATCH] D88370: Emit predefined macro for wavefront size for amdgcn

2020-09-28 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 294790.
yaxunl added a comment.

revised by Matt's comments.


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

https://reviews.llvm.org/D88370

Files:
  clang/lib/Basic/Targets/AMDGPU.cpp
  clang/lib/Basic/Targets/AMDGPU.h
  clang/test/Driver/amdgpu-macros.cl


Index: clang/test/Driver/amdgpu-macros.cl
===
--- clang/test/Driver/amdgpu-macros.cl
+++ clang/test/Driver/amdgpu-macros.cl
@@ -347,3 +347,37 @@
 // GFX1012-DAG: #define __amdgcn_processor__ "gfx1012"
 // GFX1030-DAG: #define __amdgcn_processor__ "gfx1030"
 // GFX1031-DAG: #define __amdgcn_processor__ "gfx1031"
+
+// GFX600-DAG: #define __AMDGCN_WAVEFRONT_SIZE 64
+// GFX601-DAG: #define __AMDGCN_WAVEFRONT_SIZE 64
+// GFX700-DAG: #define __AMDGCN_WAVEFRONT_SIZE 64
+// GFX701-DAG: #define __AMDGCN_WAVEFRONT_SIZE 64
+// GFX702-DAG: #define __AMDGCN_WAVEFRONT_SIZE 64
+// GFX703-DAG: #define __AMDGCN_WAVEFRONT_SIZE 64
+// GFX704-DAG: #define __AMDGCN_WAVEFRONT_SIZE 64
+// GFX801-DAG: #define __AMDGCN_WAVEFRONT_SIZE 64
+// GFX802-DAG: #define __AMDGCN_WAVEFRONT_SIZE 64
+// GFX803-DAG: #define __AMDGCN_WAVEFRONT_SIZE 64
+// GFX810-DAG: #define __AMDGCN_WAVEFRONT_SIZE 64
+// GFX900-DAG: #define __AMDGCN_WAVEFRONT_SIZE 64
+// GFX902-DAG: #define __AMDGCN_WAVEFRONT_SIZE 64
+// GFX904-DAG: #define __AMDGCN_WAVEFRONT_SIZE 64
+// GFX906-DAG: #define __AMDGCN_WAVEFRONT_SIZE 64
+// GFX908-DAG: #define __AMDGCN_WAVEFRONT_SIZE 64
+// GFX909-DAG: #define __AMDGCN_WAVEFRONT_SIZE 64
+// GFX1010-DAG: #define __AMDGCN_WAVEFRONT_SIZE 32
+// GFX1011-DAG: #define __AMDGCN_WAVEFRONT_SIZE 32
+// GFX1012-DAG: #define __AMDGCN_WAVEFRONT_SIZE 32
+// GFX1030-DAG: #define __AMDGCN_WAVEFRONT_SIZE 32
+// GFX1031-DAG: #define __AMDGCN_WAVEFRONT_SIZE 32
+
+// RUN: %clang -E -dM -target amdgcn -mcpu=gfx906 -mwavefrontsize64 \
+// RUN:   %s 2>&1 | FileCheck --check-prefixes=WAVE64 %s
+// RUN: %clang -E -dM -target amdgcn -mcpu=gfx1010 -mwavefrontsize64 \
+// RUN:   %s 2>&1 | FileCheck --check-prefixes=WAVE64 %s
+// RUN: %clang -E -dM -target amdgcn -mcpu=gfx906 -mwavefrontsize64 \
+// RUN:   -mno-wavefrontsize64 %s 2>&1 | FileCheck --check-prefixes=WAVE64 %s
+// RUN: %clang -E -dM -target amdgcn -mcpu=gfx1010 -mwavefrontsize64 \
+// RUN:   -mno-wavefrontsize64 %s 2>&1 | FileCheck --check-prefixes=WAVE32 %s
+// WAVE64-DAG: #define __AMDGCN_WAVEFRONT_SIZE 64
+// WAVE32-DAG: #define __AMDGCN_WAVEFRONT_SIZE 32
Index: clang/lib/Basic/Targets/AMDGPU.h
===
--- clang/lib/Basic/Targets/AMDGPU.h
+++ clang/lib/Basic/Targets/AMDGPU.h
@@ -41,6 +41,7 @@
 
   llvm::AMDGPU::GPUKind GPUKind;
   unsigned GPUFeatures;
+  unsigned WavefrontSize;
 
   /// Target ID is device name followed by optional feature name postfixed
   /// by plus or minus sign delimitted by colon, e.g. gfx908:xnack+:sram-ecc-.
@@ -407,6 +408,8 @@
 getAllPossibleTargetIDFeatures(getTriple(), 
getArchNameAMDGCN(GPUKind));
 llvm::for_each(Features, [&](const auto ) {
   assert(F.front() == '+' || F.front() == '-');
+  if (F == "+wavefrontsize64")
+WavefrontSize = 64;
   bool IsOn = F.front() == '+';
   StringRef Name = StringRef(F).drop_front();
   if (llvm::find(TargetIDFeatures, Name) == TargetIDFeatures.end())
Index: clang/lib/Basic/Targets/AMDGPU.cpp
===
--- clang/lib/Basic/Targets/AMDGPU.cpp
+++ clang/lib/Basic/Targets/AMDGPU.cpp
@@ -316,6 +316,7 @@
 
   HasLegalHalfType = true;
   HasFloat16 = true;
+  WavefrontSize = GPUFeatures & llvm::AMDGPU::FEATURE_WAVE32 ? 32 : 64;
 
   // Set pointer width and alignment for target address space 0.
   PointerWidth = PointerAlign = DataLayout->getPointerSizeInBits();
@@ -388,6 +389,8 @@
 Builder.defineMacro("__HAS_FP64__");
   if (hasFastFMA())
 Builder.defineMacro("FP_FAST_FMA");
+
+  Builder.defineMacro("__AMDGCN_WAVEFRONT_SIZE", Twine(WavefrontSize));
 }
 
 void AMDGPUTargetInfo::setAuxTarget(const TargetInfo *Aux) {


Index: clang/test/Driver/amdgpu-macros.cl
===
--- clang/test/Driver/amdgpu-macros.cl
+++ clang/test/Driver/amdgpu-macros.cl
@@ -347,3 +347,37 @@
 // GFX1012-DAG: #define __amdgcn_processor__ "gfx1012"
 // GFX1030-DAG: #define __amdgcn_processor__ "gfx1030"
 // GFX1031-DAG: #define __amdgcn_processor__ "gfx1031"
+
+// GFX600-DAG: #define __AMDGCN_WAVEFRONT_SIZE 64
+// GFX601-DAG: #define __AMDGCN_WAVEFRONT_SIZE 64
+// GFX700-DAG: #define __AMDGCN_WAVEFRONT_SIZE 64
+// GFX701-DAG: #define __AMDGCN_WAVEFRONT_SIZE 64
+// GFX702-DAG: #define __AMDGCN_WAVEFRONT_SIZE 64
+// GFX703-DAG: #define __AMDGCN_WAVEFRONT_SIZE 64
+// GFX704-DAG: #define __AMDGCN_WAVEFRONT_SIZE 64
+// GFX801-DAG: #define __AMDGCN_WAVEFRONT_SIZE 64
+// GFX802-DAG: #define __AMDGCN_WAVEFRONT_SIZE 64
+// GFX803-DAG: #define __AMDGCN_WAVEFRONT_SIZE 64
+// 

[PATCH] D88403: Migrate Declarators to use the List API

2020-09-28 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 added inline comments.



Comment at: clang/lib/Tooling/Syntax/BuildTree.cpp:593
 
+/// Shrink \p Range to a subrange that only contains tokens of a list.
+ArrayRef shrinkToFitList(ArrayRef Range) {





Comment at: clang/lib/Tooling/Syntax/BuildTree.cpp:594
+/// Shrink \p Range to a subrange that only contains tokens of a list.
+ArrayRef shrinkToFitList(ArrayRef Range) {
+  auto BeginChildren = Trees.lower_bound(Range.begin());

eduucaldas wrote:
> WDYT about the naming?
Very nice name!



Comment at: clang/unittests/Tooling/Syntax/BuildTreeTest.cpp:2932
   |-'void'
-  |-SimpleDeclarator Declarator
-  | |-'foo'
-  | `-ParametersAndQualifiers
-  |   |-'(' OpenParen
-  |   `-')' CloseParen
+  |-DeclaratorList Declarators
+  | `-SimpleDeclarator ListElement

eduucaldas wrote:
> This sounds weird and is probably the reason why SO many tests failed.
> 
> According to the [[ 
> https://eel.is/c++draft/dcl.fct.def.general#nt:function-definition | grammar 
> ]] a function definition/declaration might only have one declarator:
> ```
> function-definition:
> attribute-specifier-seq_opt decl-specifier-seq_opt declarator 
> virt-specifier-seq_opt function-body
> ...
> ```
> But our implementation calls `processDeclaratorAndDeclaration` for 
> `DeclaratorDecl`, which englobes `FunctionDecl`.
> 
> I also noticed that we seem to have quite extensive support for declarations 
> even rarer ones:
> `StaticAssertDeclaration`, `LinkageSpecificationDeclaration` ... Moreover, 
> their names and definitions seem to adequately follow the grammar. However we 
> don't have a `FunctionDefinition` as defined in the grammar. Was grouping 
> `FunctionDefintion` and `FunctionDeclaration` as `SimpleDeclaration`  a 
> conscious choice? (I looked quickly at commits that added 
> `processDeclaratorAndDeclaration` but couldn't find any clue)
It seemed reasonable for uniformity. However, I can definitely see an argument 
for defining a special kind of tree node for them, especially now that if we 
use SimpleDeclaration for functions we would always get a 1-element list 
wrapper.

On the other hand, the following is a valid declaration:

```
int x, f(int);
```

Wouldn't it be weird if function definitions and declarations were modeled 
differently? I understand they are different in the C++ grammar, but I think it 
would be at least a bit surprising for users.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88403

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


[PATCH] D84968: [PowerPC] Legalize v256i1 and v512i1 and implement load and store of these types

2020-09-28 Thread Baptiste Saleil 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 rG0156914275be: [PowerPC] Legalize v256i1 and v512i1 and 
implement load and store of these types (authored by bsaleil).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84968

Files:
  clang/lib/Basic/Targets/PPC.h
  clang/test/CodeGen/target-data.c
  llvm/lib/Target/PowerPC/PPCISelLowering.cpp
  llvm/lib/Target/PowerPC/PPCISelLowering.h
  llvm/lib/Target/PowerPC/PPCInstrInfo.cpp
  llvm/lib/Target/PowerPC/PPCInstrPrefix.td
  llvm/lib/Target/PowerPC/PPCRegisterInfo.td
  llvm/lib/Target/PowerPC/PPCTargetMachine.cpp
  llvm/test/CodeGen/PowerPC/mma-acc-memops.ll

Index: llvm/test/CodeGen/PowerPC/mma-acc-memops.ll
===
--- /dev/null
+++ llvm/test/CodeGen/PowerPC/mma-acc-memops.ll
@@ -0,0 +1,238 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu \
+; RUN:   -mcpu=pwr10 -ppc-asm-full-reg-names -ppc-vsr-nums-as-vr < %s | \
+; RUN:   FileCheck %s --check-prefix=LE-PAIRED
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-linux-gnu \
+; RUN:   -mcpu=pwr10 -ppc-asm-full-reg-names \
+; RUN:   -ppc-vsr-nums-as-vr < %s | FileCheck %s --check-prefix=BE-PAIRED
+
+@f = common local_unnamed_addr global <512 x i1> zeroinitializer, align 16
+@g = common local_unnamed_addr global <256 x i1> zeroinitializer, align 16
+
+define void @testLdSt(i64 %SrcIdx, i64 %DstIdx) {
+; LE-PAIRED-LABEL: testLdSt:
+; LE-PAIRED:   # %bb.0: # %entry
+; LE-PAIRED-NEXT:plxv vs1, f@PCREL+96(0), 1
+; LE-PAIRED-NEXT:plxv vs0, f@PCREL+112(0), 1
+; LE-PAIRED-NEXT:plxv vs3, f@PCREL+64(0), 1
+; LE-PAIRED-NEXT:plxv vs2, f@PCREL+80(0), 1
+; LE-PAIRED-NEXT:xxmtacc acc0
+; LE-PAIRED-NEXT:xxmfacc acc0
+; LE-PAIRED-NEXT:pstxv vs0, f@PCREL+176(0), 1
+; LE-PAIRED-NEXT:pstxv vs1, f@PCREL+160(0), 1
+; LE-PAIRED-NEXT:pstxv vs2, f@PCREL+144(0), 1
+; LE-PAIRED-NEXT:pstxv vs3, f@PCREL+128(0), 1
+; LE-PAIRED-NEXT:blr
+;
+; BE-PAIRED-LABEL: testLdSt:
+; BE-PAIRED:   # %bb.0: # %entry
+; BE-PAIRED-NEXT:addis r3, r2, .LC0@toc@ha
+; BE-PAIRED-NEXT:ld r3, .LC0@toc@l(r3)
+; BE-PAIRED-NEXT:lxv vs1, 80(r3)
+; BE-PAIRED-NEXT:lxv vs0, 64(r3)
+; BE-PAIRED-NEXT:lxv vs3, 112(r3)
+; BE-PAIRED-NEXT:lxv vs2, 96(r3)
+; BE-PAIRED-NEXT:xxmtacc acc0
+; BE-PAIRED-NEXT:xxmfacc acc0
+; BE-PAIRED-NEXT:stxv vs1, 144(r3)
+; BE-PAIRED-NEXT:stxv vs0, 128(r3)
+; BE-PAIRED-NEXT:stxv vs3, 176(r3)
+; BE-PAIRED-NEXT:stxv vs2, 160(r3)
+; BE-PAIRED-NEXT:blr
+entry:
+  %arrayidx = getelementptr inbounds <512 x i1>, <512 x i1>* @f, i64 1
+  %0 = load <512 x i1>, <512 x i1>* %arrayidx, align 64
+  %arrayidx1 = getelementptr inbounds <512 x i1>, <512 x i1>* @f, i64 2
+  store <512 x i1> %0, <512 x i1>* %arrayidx1, align 64
+  ret void
+}
+
+define void @testXLdSt(i64 %SrcIdx, i64 %DstIdx) {
+; LE-PAIRED-LABEL: testXLdSt:
+; LE-PAIRED:   # %bb.0: # %entry
+; LE-PAIRED-NEXT:sldi r3, r3, 6
+; LE-PAIRED-NEXT:paddi r5, 0, f@PCREL, 1
+; LE-PAIRED-NEXT:add r6, r5, r3
+; LE-PAIRED-NEXT:lxv vs1, 32(r6)
+; LE-PAIRED-NEXT:lxv vs0, 48(r6)
+; LE-PAIRED-NEXT:lxvx vs3, r5, r3
+; LE-PAIRED-NEXT:lxv vs2, 16(r6)
+; LE-PAIRED-NEXT:sldi r3, r4, 6
+; LE-PAIRED-NEXT:xxmtacc acc0
+; LE-PAIRED-NEXT:xxmfacc acc0
+; LE-PAIRED-NEXT:stxvx vs3, r5, r3
+; LE-PAIRED-NEXT:add r3, r5, r3
+; LE-PAIRED-NEXT:stxv vs0, 48(r3)
+; LE-PAIRED-NEXT:stxv vs1, 32(r3)
+; LE-PAIRED-NEXT:stxv vs2, 16(r3)
+; LE-PAIRED-NEXT:blr
+;
+; BE-PAIRED-LABEL: testXLdSt:
+; BE-PAIRED:   # %bb.0: # %entry
+; BE-PAIRED-NEXT:addis r5, r2, .LC0@toc@ha
+; BE-PAIRED-NEXT:sldi r3, r3, 6
+; BE-PAIRED-NEXT:ld r5, .LC0@toc@l(r5)
+; BE-PAIRED-NEXT:add r6, r5, r3
+; BE-PAIRED-NEXT:lxvx vs0, r5, r3
+; BE-PAIRED-NEXT:sldi r3, r4, 6
+; BE-PAIRED-NEXT:lxv vs1, 16(r6)
+; BE-PAIRED-NEXT:lxv vs3, 48(r6)
+; BE-PAIRED-NEXT:lxv vs2, 32(r6)
+; BE-PAIRED-NEXT:xxmtacc acc0
+; BE-PAIRED-NEXT:xxmfacc acc0
+; BE-PAIRED-NEXT:stxvx vs0, r5, r3
+; BE-PAIRED-NEXT:add r3, r5, r3
+; BE-PAIRED-NEXT:stxv vs1, 16(r3)
+; BE-PAIRED-NEXT:stxv vs3, 48(r3)
+; BE-PAIRED-NEXT:stxv vs2, 32(r3)
+; BE-PAIRED-NEXT:blr
+entry:
+  %arrayidx = getelementptr inbounds <512 x i1>, <512 x i1>* @f, i64 %SrcIdx
+  %0 = load <512 x i1>, <512 x i1>* %arrayidx, align 64
+  %arrayidx1 = getelementptr inbounds <512 x i1>, <512 x i1>* @f, i64 %DstIdx
+  store <512 x i1> %0, <512 x i1>* %arrayidx1, align 64
+  ret void
+}
+
+define void @testUnalignedLdSt() {
+; LE-PAIRED-LABEL: testUnalignedLdSt:
+; LE-PAIRED:   # %bb.0: # %entry
+; LE-PAIRED-NEXT:plxv vs1, f@PCREL+43(0), 1
+; 

[clang] 0156914 - [PowerPC] Legalize v256i1 and v512i1 and implement load and store of these types

2020-09-28 Thread Baptiste Saleil via cfe-commits

Author: Baptiste Saleil
Date: 2020-09-28T14:39:37-05:00
New Revision: 0156914275be5b07155ecefe4dc2d58588265abc

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

LOG: [PowerPC] Legalize v256i1 and v512i1 and implement load and store of these 
types

This patch legalizes the v256i1 and v512i1 types that will be used for MMA.

It implements loads and stores of these types.
v256i1 is a pair of VSX registers, so for this type, we load/store the two
underlying registers. v512i1 is used for MMA accumulators. So in addition to
loading and storing the 4 associated VSX registers, we generate instructions to
prime (copy the VSX registers to the accumulator) after loading and unprime
(copy the accumulator back to the VSX registers) before storing.

This patch also adds the UACC register class that is necessary to implement the
loads and stores. This class represents accumulator in their unprimed form and
allow the distinction between primed and unprimed accumulators to avoid invalid
copies of the VSX registers associated with primed accumulators.

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

Added: 
llvm/test/CodeGen/PowerPC/mma-acc-memops.ll

Modified: 
clang/lib/Basic/Targets/PPC.h
clang/test/CodeGen/target-data.c
llvm/lib/Target/PowerPC/PPCISelLowering.cpp
llvm/lib/Target/PowerPC/PPCISelLowering.h
llvm/lib/Target/PowerPC/PPCInstrInfo.cpp
llvm/lib/Target/PowerPC/PPCInstrPrefix.td
llvm/lib/Target/PowerPC/PPCRegisterInfo.td
llvm/lib/Target/PowerPC/PPCTargetMachine.cpp

Removed: 




diff  --git a/clang/lib/Basic/Targets/PPC.h b/clang/lib/Basic/Targets/PPC.h
index ec067d8811fc..597508207ffb 100644
--- a/clang/lib/Basic/Targets/PPC.h
+++ b/clang/lib/Basic/Targets/PPC.h
@@ -404,19 +404,20 @@ class LLVM_LIBRARY_VISIBILITY PPC64TargetInfo : public 
PPCTargetInfo {
 LongWidth = LongAlign = PointerWidth = PointerAlign = 64;
 IntMaxType = SignedLong;
 Int64Type = SignedLong;
+std::string DataLayout = "";
 
 if (Triple.isOSAIX()) {
   // TODO: Set appropriate ABI for AIX platform.
-  resetDataLayout("E-m:a-i64:64-n32:64");
+  DataLayout = "E-m:a-i64:64-n32:64";
   SuitableAlign = 64;
   LongDoubleWidth = 64;
   LongDoubleAlign = DoubleAlign = 32;
   LongDoubleFormat = ::APFloat::IEEEdouble();
 } else if ((Triple.getArch() == llvm::Triple::ppc64le)) {
-  resetDataLayout("e-m:e-i64:64-n32:64");
+  DataLayout = "e-m:e-i64:64-n32:64";
   ABI = "elfv2";
 } else {
-  resetDataLayout("E-m:e-i64:64-n32:64");
+  DataLayout = "E-m:e-i64:64-n32:64";
   ABI = "elfv1";
 }
 
@@ -425,6 +426,10 @@ class LLVM_LIBRARY_VISIBILITY PPC64TargetInfo : public 
PPCTargetInfo {
   LongDoubleFormat = ::APFloat::IEEEdouble();
 }
 
+if (Triple.isOSAIX() || Triple.isOSLinux())
+  DataLayout += "-v256:256:256-v512:512:512";
+resetDataLayout(DataLayout);
+
 // PPC64 supports atomics up to 8 bytes.
 MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 64;
   }

diff  --git a/clang/test/CodeGen/target-data.c 
b/clang/test/CodeGen/target-data.c
index 0ba20d568a08..a8e995d2963a 100644
--- a/clang/test/CodeGen/target-data.c
+++ b/clang/test/CodeGen/target-data.c
@@ -136,11 +136,27 @@
 
 // RUN: %clang_cc1 -triple powerpc64-linux -o - -emit-llvm %s | \
 // RUN: FileCheck %s -check-prefix=PPC64-LINUX
-// PPC64-LINUX: target datalayout = "E-m:e-i64:64-n32:64"
+// PPC64-LINUX: target datalayout = 
"E-m:e-i64:64-n32:64-v256:256:256-v512:512:512"
+
+// RUN: %clang_cc1 -triple powerpc64-linux -o - -emit-llvm -target-cpu future 
%s | \
+// RUN: FileCheck %s -check-prefix=PPC64-FUTURE
+// PPC64-FUTURE: target datalayout = 
"E-m:e-i64:64-n32:64-v256:256:256-v512:512:512"
+
+// RUN: %clang_cc1 -triple powerpc64-linux -o - -emit-llvm -target-cpu pwr10 
%s | \
+// RUN: FileCheck %s -check-prefix=PPC64-P10
+// PPC64-P10: target datalayout = 
"E-m:e-i64:64-n32:64-v256:256:256-v512:512:512"
 
 // RUN: %clang_cc1 -triple powerpc64le-linux -o - -emit-llvm %s | \
 // RUN: FileCheck %s -check-prefix=PPC64LE-LINUX
-// PPC64LE-LINUX: target datalayout = "e-m:e-i64:64-n32:64"
+// PPC64LE-LINUX: target datalayout = 
"e-m:e-i64:64-n32:64-v256:256:256-v512:512:512"
+
+// RUN: %clang_cc1 -triple powerpc64le-linux -o - -emit-llvm -target-cpu 
future %s | \
+// RUN: FileCheck %s -check-prefix=PPC64LE-FUTURE
+// PPC64LE-FUTURE: target datalayout = 
"e-m:e-i64:64-n32:64-v256:256:256-v512:512:512"
+
+// RUN: %clang_cc1 -triple powerpc64le-linux -o - -emit-llvm -target-cpu pwr10 
%s | \
+// RUN: FileCheck %s -check-prefix=PPC64LE-P10
+// PPC64LE-P10: target datalayout = 
"e-m:e-i64:64-n32:64-v256:256:256-v512:512:512"
 
 // RUN: %clang_cc1 -triple nvptx-unknown -o - -emit-llvm %s | \
 // RUN: FileCheck %s 

[PATCH] D87737: Add -fprofile-update={atomic,prefer-atomic,single}

2020-09-28 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay updated this revision to Diff 294781.
MaskRay added a comment.

Add documentation to UserManual.rst


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87737

Files:
  clang/docs/UsersManual.rst
  clang/include/clang/Basic/CodeGenOptions.def
  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/code-coverage-tsan.c
  clang/test/CodeGen/tsan-instrprof-atomic.c
  clang/test/Driver/fprofile-update.c

Index: clang/test/Driver/fprofile-update.c
===
--- /dev/null
+++ clang/test/Driver/fprofile-update.c
@@ -0,0 +1,15 @@
+/// For -fprofile-instr-generate and -fprofile-arcs, increment counters atomically
+/// if -fprofile-update={atomic,prefer-atomic} or -fsanitize=thread is specified.
+// RUN: %clang -### %s -c -target x86_64-linux -fsanitize=thread %s 2>&1 | FileCheck %s
+// RUN: %clang -### %s -c -fprofile-update=atomic 2>&1 | FileCheck %s
+// RUN: %clang -### %s -c -fprofile-update=prefer-atomic 2>&1 | FileCheck %s
+
+// CHECK: "-fprofile-update=atomic"
+
+// RUN: %clang -### %s -c -fprofile-update=atomic -fprofile-update=single 2>&1 | FileCheck %s --check-prefix=SINGLE
+
+// SINGLE-NOT: "-fprofile-update=atomic"
+
+// RUN: not %clang %s -c -fprofile-update=unknown 2>&1 | FileCheck %s --check-prefix=ERROR
+
+// ERROR: error: unsupported argument 'unknown' to option 'fprofile-update='
Index: clang/test/CodeGen/tsan-instrprof-atomic.c
===
--- clang/test/CodeGen/tsan-instrprof-atomic.c
+++ clang/test/CodeGen/tsan-instrprof-atomic.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -emit-llvm -fprofile-instrument=clang -fsanitize=thread -o - | FileCheck %s
+// RUN: %clang_cc1 %s -emit-llvm -fprofile-instrument=clang -fprofile-update=atomic -o - | FileCheck %s
 
 // CHECK: define {{.*}}@foo
 // CHECK-NOT: load {{.*}}foo
Index: clang/test/CodeGen/code-coverage-tsan.c
===
--- clang/test/CodeGen/code-coverage-tsan.c
+++ clang/test/CodeGen/code-coverage-tsan.c
@@ -1,11 +1,12 @@
-/// -fsanitize=thread requires the (potentially concurrent) counter updates to be atomic.
-// RUN: %clang_cc1 %s -triple x86_64 -emit-llvm -fsanitize=thread -femit-coverage-notes -femit-coverage-data \
+/// -fprofile-update=atomic (implied by -fsanitize=thread) requires the
+/// (potentially concurrent) counter updates to be atomic.
+// RUN: %clang_cc1 %s -triple x86_64 -emit-llvm -fprofile-update=atomic -femit-coverage-notes -femit-coverage-data \
 // RUN:   -coverage-notes-file /dev/null -coverage-data-file /dev/null -o - | FileCheck %s
 
 // CHECK-LABEL: void @foo()
 /// Two counters are incremented by __tsan_atomic64_fetch_add.
-// CHECK: call i64 @__tsan_atomic64_fetch_add
-// CHECK-NEXT:call i32 @__tsan_atomic32_fetch_sub
+// CHECK: atomicrmw add i64* {{.*}} @__llvm_gcov_ctr
+// CHECK-NEXT:atomicrmw sub i32*
 
 _Atomic(int) cnt;
 void foo() { cnt--; }
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -884,6 +884,7 @@
   Opts.DebugRangesBaseAddress = Args.hasArg(OPT_fdebug_ranges_base_address);
 
   setPGOInstrumentor(Opts, Args, Diags);
+  Opts.AtomicProfileUpdate = Args.hasArg(OPT_fprofile_update_EQ);
   Opts.InstrProfileOutput =
   std::string(Args.getLastArgValue(OPT_fprofile_instrument_path_EQ));
   Opts.ProfileInstrumentUsePath =
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -868,6 +868,17 @@
 CmdArgs.push_back(Args.MakeArgString(Twine("-fprofile-filter-files=" + v)));
   }
 
+  if (const auto *A = Args.getLastArg(options::OPT_fprofile_update_EQ)) {
+StringRef Val = A->getValue();
+if (Val == "atomic" || Val == "prefer-atomic")
+  CmdArgs.push_back("-fprofile-update=atomic");
+else if (Val != "single")
+  D.Diag(diag::err_drv_unsupported_option_argument)
+  << A->getOption().getName() << Val;
+  } else if (TC.getSanitizerArgs().needsTsanRt()) {
+CmdArgs.push_back("-fprofile-update=atomic");
+  }
+
   // Leave -fprofile-dir= an unused argument unless .gcda emission is
   // enabled. To be polite, with '-fprofile-arcs -fno-profile-arcs' consider
   // the flag used. There is no -fno-profile-dir, so the user has no
Index: clang/lib/CodeGen/BackendUtil.cpp
===
--- clang/lib/CodeGen/BackendUtil.cpp
+++ clang/lib/CodeGen/BackendUtil.cpp
@@ -570,7 +570,7 @@
   Options.NoRedZone = CodeGenOpts.DisableRedZone;
   

[PATCH] D88430: [OpenMP] Replace OpenMP RTL Functions With OMPIRBuilder and OMPKinds.def

2020-09-28 Thread Stefan Stipanovic via Phabricator via cfe-commits
sstefan1 added inline comments.



Comment at: clang/lib/CodeGen/CGOpenMPRuntimeGPU.h:38
+  /// An OpenMP-IR-Builder instance.
+  llvm::OpenMPIRBuilder OMPBuilder;
+

jhuber6 wrote:
> sstefan1 wrote:
> > There's already an instance of `OpenMPIRBuilder` in `CGOpenMPRuntime`.
> > 
> > Maybe just make it protected?
> When it's generating `__kmpc_shuffle_intxx`  around line 2480 it gets an 
> instance of `CGOpenMPRuntimeGPU` indirectly which meant I had to make it 
> public so it could use it. I could probably rewrite all the functions to be 
> inside the class but I'm not sure if that'll break anything. So I just made 
> it public for now.
I think that shouldn't be a problem. There is `getOMPBuilder()` in 
`CGOpenMPRuntime`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88430

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


[PATCH] D84962: [PowerPC] Correct cpsgn's behaviour on PowerPC to match that of the ABI

2020-09-28 Thread Albion Fung via Phabricator via cfe-commits
Conanap updated this revision to Diff 294778.
Conanap marked an inline comment as done.
Conanap added a comment.

Changed the location of fix and added extra test cases


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

https://reviews.llvm.org/D84962

Files:
  clang/lib/Headers/altivec.h
  clang/test/CodeGen/builtins-ppc-vsx.c


Index: clang/test/CodeGen/builtins-ppc-vsx.c
===
--- clang/test/CodeGen/builtins-ppc-vsx.c
+++ clang/test/CodeGen/builtins-ppc-vsx.c
@@ -1,4 +1,4 @@
-// REQUIRES: powerpc-registered-target
+// requires: powerpc-registered-target
 // RUN: %clang_cc1 -target-feature +altivec -target-feature +vsx -triple 
powerpc64-unknown-unknown -emit-llvm %s -o - | FileCheck %s
 // RUN: %clang_cc1 -target-feature +altivec -target-feature +vsx -triple 
powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck %s 
-check-prefix=CHECK-LE
 #include 
@@ -1832,3 +1832,27 @@
 // CHECK-NEXT-LE: %{{[0-9]+}} = extractelement <2 x i64> %[[V1]], i32 0
 
 }
+
+void test_vector_cpsgn_float(vector float a, vector float b) {
+// CHECK-LABEL: test_vector_cpsgn_float
+// CHECK: %6 = call <4 x float> @llvm.copysign.v4f32(<4 x float> %4, <4 x 
float> %5) 
+  vec_cpsgn(a, b);
+}
+
+void test_vector_cpsgn_double(vector double a, vector double b) {
+// CHECK-LABEL: test_vector_cpsgn_double
+// CHECK: %6 = call <2 x double> @llvm.copysign.v2f64(<2 x double> %4, <2 x 
double> %5) #6
+  vec_cpsgn(a, b);
+}
+
+void test_builtin_xvcpsgnsp(vector float a, vector float b) {
+// CHECK-LABEL: test_builtin_xvcpsgnsp
+// CHECK: %4 = call <4 x float> @llvm.copysign.v4f32(<4 x float> %2, <4 x 
float> %3) 
+  __builtin_vsx_xvcpsgnsp(a, b);
+}
+
+void test_builtin_xvcpsgndp(vector double a, vector double b) {
+// CHECK-LABEL: test_builtin_xvcpsgndp
+// CHECK: %4 = call <2 x double> @llvm.copysign.v2f64(<2 x double> %2, <2 x 
double> %3)
+  __builtin_vsx_xvcpsgndp(a, b);
+}
Index: clang/lib/Headers/altivec.h
===
--- clang/lib/Headers/altivec.h
+++ clang/lib/Headers/altivec.h
@@ -2996,12 +2996,12 @@
 #ifdef __VSX__
 static __inline__ vector float __ATTRS_o_ai vec_cpsgn(vector float __a,
   vector float __b) {
-  return __builtin_vsx_xvcpsgnsp(__a, __b);
+  return __builtin_vsx_xvcpsgnsp(__b, __a);
 }
 
 static __inline__ vector double __ATTRS_o_ai vec_cpsgn(vector double __a,
vector double __b) {
-  return __builtin_vsx_xvcpsgndp(__a, __b);
+  return __builtin_vsx_xvcpsgndp(__b, __a);
 }
 #endif
 


Index: clang/test/CodeGen/builtins-ppc-vsx.c
===
--- clang/test/CodeGen/builtins-ppc-vsx.c
+++ clang/test/CodeGen/builtins-ppc-vsx.c
@@ -1,4 +1,4 @@
-// REQUIRES: powerpc-registered-target
+// requires: powerpc-registered-target
 // RUN: %clang_cc1 -target-feature +altivec -target-feature +vsx -triple powerpc64-unknown-unknown -emit-llvm %s -o - | FileCheck %s
 // RUN: %clang_cc1 -target-feature +altivec -target-feature +vsx -triple powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck %s -check-prefix=CHECK-LE
 #include 
@@ -1832,3 +1832,27 @@
 // CHECK-NEXT-LE: %{{[0-9]+}} = extractelement <2 x i64> %[[V1]], i32 0
 
 }
+
+void test_vector_cpsgn_float(vector float a, vector float b) {
+// CHECK-LABEL: test_vector_cpsgn_float
+// CHECK: %6 = call <4 x float> @llvm.copysign.v4f32(<4 x float> %4, <4 x float> %5) 
+  vec_cpsgn(a, b);
+}
+
+void test_vector_cpsgn_double(vector double a, vector double b) {
+// CHECK-LABEL: test_vector_cpsgn_double
+// CHECK: %6 = call <2 x double> @llvm.copysign.v2f64(<2 x double> %4, <2 x double> %5) #6
+  vec_cpsgn(a, b);
+}
+
+void test_builtin_xvcpsgnsp(vector float a, vector float b) {
+// CHECK-LABEL: test_builtin_xvcpsgnsp
+// CHECK: %4 = call <4 x float> @llvm.copysign.v4f32(<4 x float> %2, <4 x float> %3) 
+  __builtin_vsx_xvcpsgnsp(a, b);
+}
+
+void test_builtin_xvcpsgndp(vector double a, vector double b) {
+// CHECK-LABEL: test_builtin_xvcpsgndp
+// CHECK: %4 = call <2 x double> @llvm.copysign.v2f64(<2 x double> %2, <2 x double> %3)
+  __builtin_vsx_xvcpsgndp(a, b);
+}
Index: clang/lib/Headers/altivec.h
===
--- clang/lib/Headers/altivec.h
+++ clang/lib/Headers/altivec.h
@@ -2996,12 +2996,12 @@
 #ifdef __VSX__
 static __inline__ vector float __ATTRS_o_ai vec_cpsgn(vector float __a,
   vector float __b) {
-  return __builtin_vsx_xvcpsgnsp(__a, __b);
+  return __builtin_vsx_xvcpsgnsp(__b, __a);
 }
 
 static __inline__ vector double __ATTRS_o_ai vec_cpsgn(vector double __a,
vector double __b) {
-  return __builtin_vsx_xvcpsgndp(__a, __b);
+  return __builtin_vsx_xvcpsgndp(__b, __a);
 }
 #endif
 

[PATCH] D88430: [OpenMP] Replace OpenMP RTL Functions With OMPIRBuilder and OMPKinds.def

2020-09-28 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 added inline comments.



Comment at: clang/lib/CodeGen/CGOpenMPRuntimeGPU.h:38
+  /// An OpenMP-IR-Builder instance.
+  llvm::OpenMPIRBuilder OMPBuilder;
+

sstefan1 wrote:
> There's already an instance of `OpenMPIRBuilder` in `CGOpenMPRuntime`.
> 
> Maybe just make it protected?
When it's generating `__kmpc_shuffle_intxx`  around line 2480 it gets an 
instance of `CGOpenMPRuntimeGPU` indirectly which meant I had to make it public 
so it could use it. I could probably rewrite all the functions to be inside the 
class but I'm not sure if that'll break anything. So I just made it public for 
now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88430

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


[clang] 0c82fa6 - [python][tests] Fix string comparison with "is"

2020-09-28 Thread Paweł Bylica via cfe-commits

Author: Paweł Bylica
Date: 2020-09-28T21:11:50+02:00
New Revision: 0c82fa677f24d8a9656af41ac9cc64ea4f818bc0

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

LOG: [python][tests] Fix string comparison with "is"

Added: 


Modified: 
clang/bindings/python/tests/cindex/test_cursor_kind.py

Removed: 




diff  --git a/clang/bindings/python/tests/cindex/test_cursor_kind.py 
b/clang/bindings/python/tests/cindex/test_cursor_kind.py
index e6b9558b3cc1..ed245d593d55 100644
--- a/clang/bindings/python/tests/cindex/test_cursor_kind.py
+++ b/clang/bindings/python/tests/cindex/test_cursor_kind.py
@@ -10,7 +10,7 @@
 
 class TestCursorKind(unittest.TestCase):
 def test_name(self):
-self.assertTrue(CursorKind.UNEXPOSED_DECL.name is 'UNEXPOSED_DECL')
+self.assertEqual(CursorKind.UNEXPOSED_DECL.name, 'UNEXPOSED_DECL')
 
 def test_get_all_kinds(self):
 kinds = CursorKind.get_all_kinds()



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


[PATCH] D88430: [OpenMP] Replace OpenMP RTL Functions With OMPIRBuilder and OMPKinds.def

2020-09-28 Thread Stefan Stipanovic via Phabricator via cfe-commits
sstefan1 added inline comments.



Comment at: clang/lib/CodeGen/CGOpenMPRuntimeGPU.h:38
+  /// An OpenMP-IR-Builder instance.
+  llvm::OpenMPIRBuilder OMPBuilder;
+

There's already an instance of `OpenMPIRBuilder` in `CGOpenMPRuntime`.

Maybe just make it protected?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88430

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


[PATCH] D84968: [PowerPC] Legalize v256i1 and v512i1 and implement load and store of these types

2020-09-28 Thread Baptiste Saleil via Phabricator via cfe-commits
bsaleil updated this revision to Diff 294776.
bsaleil added a comment.

Use early exit in lowering functions and extend test case


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84968

Files:
  clang/lib/Basic/Targets/PPC.h
  clang/test/CodeGen/target-data.c
  llvm/lib/Target/PowerPC/PPCISelLowering.cpp
  llvm/lib/Target/PowerPC/PPCISelLowering.h
  llvm/lib/Target/PowerPC/PPCInstrInfo.cpp
  llvm/lib/Target/PowerPC/PPCInstrPrefix.td
  llvm/lib/Target/PowerPC/PPCRegisterInfo.td
  llvm/lib/Target/PowerPC/PPCTargetMachine.cpp
  llvm/test/CodeGen/PowerPC/mma-acc-memops.ll

Index: llvm/test/CodeGen/PowerPC/mma-acc-memops.ll
===
--- /dev/null
+++ llvm/test/CodeGen/PowerPC/mma-acc-memops.ll
@@ -0,0 +1,238 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu \
+; RUN:   -mcpu=pwr10 -ppc-asm-full-reg-names -ppc-vsr-nums-as-vr < %s | \
+; RUN:   FileCheck %s --check-prefix=LE-PAIRED
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-linux-gnu \
+; RUN:   -mcpu=pwr10 -ppc-asm-full-reg-names \
+; RUN:   -ppc-vsr-nums-as-vr < %s | FileCheck %s --check-prefix=BE-PAIRED
+
+@f = common local_unnamed_addr global <512 x i1> zeroinitializer, align 16
+@g = common local_unnamed_addr global <256 x i1> zeroinitializer, align 16
+
+define void @testLdSt(i64 %SrcIdx, i64 %DstIdx) {
+; LE-PAIRED-LABEL: testLdSt:
+; LE-PAIRED:   # %bb.0: # %entry
+; LE-PAIRED-NEXT:plxv vs1, f@PCREL+96(0), 1
+; LE-PAIRED-NEXT:plxv vs0, f@PCREL+112(0), 1
+; LE-PAIRED-NEXT:plxv vs3, f@PCREL+64(0), 1
+; LE-PAIRED-NEXT:plxv vs2, f@PCREL+80(0), 1
+; LE-PAIRED-NEXT:xxmtacc acc0
+; LE-PAIRED-NEXT:xxmfacc acc0
+; LE-PAIRED-NEXT:pstxv vs0, f@PCREL+176(0), 1
+; LE-PAIRED-NEXT:pstxv vs1, f@PCREL+160(0), 1
+; LE-PAIRED-NEXT:pstxv vs2, f@PCREL+144(0), 1
+; LE-PAIRED-NEXT:pstxv vs3, f@PCREL+128(0), 1
+; LE-PAIRED-NEXT:blr
+;
+; BE-PAIRED-LABEL: testLdSt:
+; BE-PAIRED:   # %bb.0: # %entry
+; BE-PAIRED-NEXT:addis r3, r2, .LC0@toc@ha
+; BE-PAIRED-NEXT:ld r3, .LC0@toc@l(r3)
+; BE-PAIRED-NEXT:lxv vs1, 80(r3)
+; BE-PAIRED-NEXT:lxv vs0, 64(r3)
+; BE-PAIRED-NEXT:lxv vs3, 112(r3)
+; BE-PAIRED-NEXT:lxv vs2, 96(r3)
+; BE-PAIRED-NEXT:xxmtacc acc0
+; BE-PAIRED-NEXT:xxmfacc acc0
+; BE-PAIRED-NEXT:stxv vs1, 144(r3)
+; BE-PAIRED-NEXT:stxv vs0, 128(r3)
+; BE-PAIRED-NEXT:stxv vs3, 176(r3)
+; BE-PAIRED-NEXT:stxv vs2, 160(r3)
+; BE-PAIRED-NEXT:blr
+entry:
+  %arrayidx = getelementptr inbounds <512 x i1>, <512 x i1>* @f, i64 1
+  %0 = load <512 x i1>, <512 x i1>* %arrayidx, align 64
+  %arrayidx1 = getelementptr inbounds <512 x i1>, <512 x i1>* @f, i64 2
+  store <512 x i1> %0, <512 x i1>* %arrayidx1, align 64
+  ret void
+}
+
+define void @testXLdSt(i64 %SrcIdx, i64 %DstIdx) {
+; LE-PAIRED-LABEL: testXLdSt:
+; LE-PAIRED:   # %bb.0: # %entry
+; LE-PAIRED-NEXT:sldi r3, r3, 6
+; LE-PAIRED-NEXT:paddi r5, 0, f@PCREL, 1
+; LE-PAIRED-NEXT:add r6, r5, r3
+; LE-PAIRED-NEXT:lxv vs1, 32(r6)
+; LE-PAIRED-NEXT:lxv vs0, 48(r6)
+; LE-PAIRED-NEXT:lxvx vs3, r5, r3
+; LE-PAIRED-NEXT:lxv vs2, 16(r6)
+; LE-PAIRED-NEXT:sldi r3, r4, 6
+; LE-PAIRED-NEXT:xxmtacc acc0
+; LE-PAIRED-NEXT:xxmfacc acc0
+; LE-PAIRED-NEXT:stxvx vs3, r5, r3
+; LE-PAIRED-NEXT:add r3, r5, r3
+; LE-PAIRED-NEXT:stxv vs0, 48(r3)
+; LE-PAIRED-NEXT:stxv vs1, 32(r3)
+; LE-PAIRED-NEXT:stxv vs2, 16(r3)
+; LE-PAIRED-NEXT:blr
+;
+; BE-PAIRED-LABEL: testXLdSt:
+; BE-PAIRED:   # %bb.0: # %entry
+; BE-PAIRED-NEXT:addis r5, r2, .LC0@toc@ha
+; BE-PAIRED-NEXT:sldi r3, r3, 6
+; BE-PAIRED-NEXT:ld r5, .LC0@toc@l(r5)
+; BE-PAIRED-NEXT:add r6, r5, r3
+; BE-PAIRED-NEXT:lxvx vs0, r5, r3
+; BE-PAIRED-NEXT:sldi r3, r4, 6
+; BE-PAIRED-NEXT:lxv vs1, 16(r6)
+; BE-PAIRED-NEXT:lxv vs3, 48(r6)
+; BE-PAIRED-NEXT:lxv vs2, 32(r6)
+; BE-PAIRED-NEXT:xxmtacc acc0
+; BE-PAIRED-NEXT:xxmfacc acc0
+; BE-PAIRED-NEXT:stxvx vs0, r5, r3
+; BE-PAIRED-NEXT:add r3, r5, r3
+; BE-PAIRED-NEXT:stxv vs1, 16(r3)
+; BE-PAIRED-NEXT:stxv vs3, 48(r3)
+; BE-PAIRED-NEXT:stxv vs2, 32(r3)
+; BE-PAIRED-NEXT:blr
+entry:
+  %arrayidx = getelementptr inbounds <512 x i1>, <512 x i1>* @f, i64 %SrcIdx
+  %0 = load <512 x i1>, <512 x i1>* %arrayidx, align 64
+  %arrayidx1 = getelementptr inbounds <512 x i1>, <512 x i1>* @f, i64 %DstIdx
+  store <512 x i1> %0, <512 x i1>* %arrayidx1, align 64
+  ret void
+}
+
+define void @testUnalignedLdSt() {
+; LE-PAIRED-LABEL: testUnalignedLdSt:
+; LE-PAIRED:   # %bb.0: # %entry
+; LE-PAIRED-NEXT:plxv vs1, f@PCREL+43(0), 1
+; LE-PAIRED-NEXT:plxv vs0, f@PCREL+59(0), 1
+; LE-PAIRED-NEXT:plxv vs3, f@PCREL+11(0), 1
+; LE-PAIRED-NEXT:plxv vs2, 

[PATCH] D88345: [CUDA] Allow local `static const {__constant__, __device__}` variables.

2020-09-28 Thread Justin Lebar via Phabricator via cfe-commits
jlebar added a comment.

OK, now I'm starting to I understand this change..

Before, in function scope, we allow static const/non-const `__shared__`, and 
allow static const so long as it's not `__device__` or `__constant__`.

- `static` -> error?  (I understood us saying above that it is, but now that I 
read the code, isn't it saying it's an error?)
- `static const` -> allowed
- `static __device__` -> error
- `static const __device__` -> error
- `static __constant__` -> error
- `static const __constant__` -> error

After, in function scope, the rule is, allow static const/non-const 
`__shared__` or anything that's `static const`.

- `static` -> error, must be const
- `static const` -> allowed
- `static __device__` -> error, must be const
- `static const __device__` -> allowed
- `static __constant__` -> error, must be const
- `static const __constant__` -> allowed

I guess my question when I write out this table is, why shouldn't it be like 
this?

- `static` -> allowed
- `static const` -> allowed
- `static __device__` -> allowed
- `const static __device__` -> allowed
- `static __constant__` -> error, must be const
- `const static __constant__` -> allowed

This makes some sense to me because we're saying, "`__constant__` must be 
const", otherwise, anything goes.

Or here's another way of thinking about it.  You're saying that `static` and 
`static __device__` in function scope are the same as a `__device__` variable 
in block scope.  And a `__device__` variable in block scope doesn't have to be 
const (right?).  So why the extra restriction on function-scope static?




Comment at: clang/lib/Sema/SemaDecl.cpp:13161
   // without device memory qualifier is implemented, therefore only static
   // const variable without device memory qualifier is allowed.
   [&]() {

Update comment?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88345

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


[PATCH] D86841: [clang] Add mustprogress and llvm.loop.mustprogress attribute deduction

2020-09-28 Thread Atmn Patel via Phabricator via cfe-commits
atmnpatel updated this revision to Diff 294773.
atmnpatel added a comment.

rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86841

Files:
  clang/lib/CodeGen/CGLoopInfo.cpp
  clang/lib/CodeGen/CGLoopInfo.h
  clang/lib/CodeGen/CGStmt.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/test/CodeGen/address-safety-attr-flavors.cpp
  clang/test/CodeGen/address-safety-attr.cpp
  clang/test/CodeGen/attr-mustprogress-0.c
  clang/test/CodeGen/attr-mustprogress-0.cpp
  clang/test/CodeGen/attr-mustprogress-1.c
  clang/test/CodeGen/attr-mustprogress-1.cpp
  clang/test/CodeGen/memtag-attr.cpp
  clang/test/CodeGen/no-builtin.cpp
  clang/test/CodeGenCXX/cxx11-trivial-initializer-struct.cpp
  clang/test/CodeGenCXX/fno-unroll-loops-metadata.cpp
  clang/test/CodeGenCXX/thunks-ehspec.cpp
  clang/test/CodeGenCXX/thunks.cpp
  clang/test/OpenMP/simd_metadata.c
  clang/test/Profile/c-unprofiled-blocks.c
  clang/test/utils/update_cc_test_checks/Inputs/basic-cplusplus.cpp.expected
  
clang/test/utils/update_cc_test_checks/Inputs/check-attributes.cpp.funcattrs.expected
  
clang/test/utils/update_cc_test_checks/Inputs/generated-funcs.c.generated.expected
  
clang/test/utils/update_cc_test_checks/Inputs/generated-funcs.c.no-generated.expected

Index: clang/test/utils/update_cc_test_checks/Inputs/generated-funcs.c.no-generated.expected
===
--- clang/test/utils/update_cc_test_checks/Inputs/generated-funcs.c.no-generated.expected
+++ clang/test/utils/update_cc_test_checks/Inputs/generated-funcs.c.no-generated.expected
@@ -41,7 +41,7 @@
 // NOOMP-NEXT:[[TMP2:%.*]] = load i32, i32* [[I]], align 4
 // NOOMP-NEXT:[[INC:%.*]] = add nsw i32 [[TMP2]], 1
 // NOOMP-NEXT:store i32 [[INC]], i32* [[I]], align 4
-// NOOMP-NEXT:br label [[FOR_COND]]
+// NOOMP-NEXT:br label [[FOR_COND]], [[LOOP2:!llvm.loop !.*]]
 // NOOMP:   for.end:
 // NOOMP-NEXT:call void @foo()
 // NOOMP-NEXT:ret i32 0
@@ -86,7 +86,7 @@
 // NOOMP-NEXT:[[TMP2:%.*]] = load i32, i32* [[I]], align 4
 // NOOMP-NEXT:[[INC:%.*]] = add nsw i32 [[TMP2]], 1
 // NOOMP-NEXT:store i32 [[INC]], i32* [[I]], align 4
-// NOOMP-NEXT:br label [[FOR_COND]]
+// NOOMP-NEXT:br label [[FOR_COND]], [[LOOP4:!llvm.loop !.*]]
 // NOOMP:   for.end:
 // NOOMP-NEXT:ret void
 //
Index: clang/test/utils/update_cc_test_checks/Inputs/generated-funcs.c.generated.expected
===
--- clang/test/utils/update_cc_test_checks/Inputs/generated-funcs.c.generated.expected
+++ clang/test/utils/update_cc_test_checks/Inputs/generated-funcs.c.generated.expected
@@ -197,7 +197,7 @@
 // NOOMP-NEXT:[[TMP2:%.*]] = load i32, i32* [[I]], align 4
 // NOOMP-NEXT:[[INC:%.*]] = add nsw i32 [[TMP2]], 1
 // NOOMP-NEXT:store i32 [[INC]], i32* [[I]], align 4
-// NOOMP-NEXT:br label [[FOR_COND]]
+// NOOMP-NEXT:br label [[FOR_COND]], [[LOOP2:!llvm.loop !.*]]
 // NOOMP:   for.end:
 // NOOMP-NEXT:call void @foo()
 // NOOMP-NEXT:ret i32 0
@@ -223,7 +223,7 @@
 // NOOMP-NEXT:[[TMP2:%.*]] = load i32, i32* [[I]], align 4
 // NOOMP-NEXT:[[INC:%.*]] = add nsw i32 [[TMP2]], 1
 // NOOMP-NEXT:store i32 [[INC]], i32* [[I]], align 4
-// NOOMP-NEXT:br label [[FOR_COND]]
+// NOOMP-NEXT:br label [[FOR_COND]], [[LOOP4:!llvm.loop !.*]]
 // NOOMP:   for.end:
 // NOOMP-NEXT:ret void
 //
Index: clang/test/utils/update_cc_test_checks/Inputs/check-attributes.cpp.funcattrs.expected
===
--- clang/test/utils/update_cc_test_checks/Inputs/check-attributes.cpp.funcattrs.expected
+++ clang/test/utils/update_cc_test_checks/Inputs/check-attributes.cpp.funcattrs.expected
@@ -11,7 +11,7 @@
   struct RT Z;
 };
 
-// CHECK: Function Attrs: noinline nounwind optnone
+// CHECK: Function Attrs: noinline nounwind optnone mustprogress
 // CHECK-LABEL: @_Z3fooP2ST(
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:[[S_ADDR:%.*]] = alloca %struct.ST*, align 8
Index: clang/test/utils/update_cc_test_checks/Inputs/basic-cplusplus.cpp.expected
===
--- clang/test/utils/update_cc_test_checks/Inputs/basic-cplusplus.cpp.expected
+++ clang/test/utils/update_cc_test_checks/Inputs/basic-cplusplus.cpp.expected
@@ -44,7 +44,7 @@
 // CHECK-NEXT:[[THIS_ADDR:%.*]] = alloca %class.Foo*, align 8
 // CHECK-NEXT:store %class.Foo* [[THIS:%.*]], %class.Foo** [[THIS_ADDR]], align 8
 // CHECK-NEXT:[[THIS1:%.*]] = load %class.Foo*, %class.Foo** [[THIS_ADDR]], align 8
-// CHECK-NEXT:call void @_ZN3FooD2Ev(%class.Foo* [[THIS1]]) [[ATTR2:#.*]]
+// CHECK-NEXT:call void @_ZN3FooD2Ev(%class.Foo* [[THIS1]]) [[ATTR3:#.*]]
 // CHECK-NEXT:ret void
 //
 Foo::~Foo() {}
@@ -70,7 +70,7 @@
 // CHECK-NEXT:call void @_ZN3FooC1Ei(%class.Foo* [[F]], 

[PATCH] D87888: [X86] Use inlineasm flag output for the _bittest* intrinsics.

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

Yep, neat.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87888

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


[PATCH] D88345: [CUDA] Allow local `static const {__constant__, __device__}` variables.

2020-09-28 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

In D88345#2298688 , @jlebar wrote:

> OK, backing up, what are the semantics of `static` on `__constant__`, 
> `__device__`, and `__shared__`?
>
> - My understanding is that `__shared__` behaves the same whether or not it's 
> static.  It's not equivalent to `namespace a { __shared__ int c = 4; }`, 
> because that's illegal.

Yes. `__shared__` is an odd duck. It is implicitly static, so whether we 
explicitly specify `static` makes no difference.
We're not changing anything about how it's implemented.

> - Does `__constant__` behave the same whether or not it's static?  A static 
> `__constant__` is equivalent to `namespace a { __constant__ int c = 4; }`, 
> and a non-static `__constant__` is *also* equivalent to that?

No. `__constant__` is not allowed on non-static local variables as it can't be 
allocated on stack.

> - And `__device__` does not behave the same whether or not it's static?

Correct.

> In function scope `__device__ int x;` is a variable local to the thread.

Correct. `__device__` in a device function is effectively a no-op and can be 
placed on stack as a regular local variable.

> Whereas in global scope `__device__ int x;` is a global variable that lives 
> in device memory (?).

Correct.

> In function scope `static __device__ int x;` is equivalent to `static int x;` 
> which is equivalent to `int x;` in namespace scope?

Yes, assuming you mean a `__device__` function and `__device__ int x;` in the 
namespace scope.

> Should we mandate that you initialize `static __constant__` variables in 
> function scope?
> That is, if you write `static __constant__ int x;` in a function, then x is 
> always uninitialized (right)?  You should do `static __constant__ int x = 
> 42;`?

No. Accoring to PTX spec:  `Variables in .const and .global state spaces are 
initialized to zero by default.`
Those are the address spaces `__constant__` and `__device__` variables map to.
https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#state-spaces


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88345

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


[PATCH] D88431: [clangd] Rename evaluate() to evaluateHeuristics()

2020-09-28 Thread Utkarsh Saxena via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9b1666f3ce2b: [clangd] Rename evaluate() to 
evaluateHeuristics() (authored by usaxena95).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88431

Files:
  clang-tools-extra/clangd/CodeComplete.cpp
  clang-tools-extra/clangd/FindSymbols.cpp
  clang-tools-extra/clangd/Quality.cpp
  clang-tools-extra/clangd/Quality.h
  clang-tools-extra/clangd/XRefs.cpp
  clang-tools-extra/clangd/index/dex/Dex.cpp
  clang-tools-extra/clangd/unittests/QualityTests.cpp

Index: clang-tools-extra/clangd/unittests/QualityTests.cpp
===
--- clang-tools-extra/clangd/unittests/QualityTests.cpp
+++ clang-tools-extra/clangd/unittests/QualityTests.cpp
@@ -196,25 +196,27 @@
 // Do the signals move the scores in the direction we expect?
 TEST(QualityTests, SymbolQualitySignalsSanity) {
   SymbolQualitySignals Default;
-  EXPECT_EQ(Default.evaluate(), 1);
+  EXPECT_EQ(Default.evaluateHeuristics(), 1);
 
   SymbolQualitySignals Deprecated;
   Deprecated.Deprecated = true;
-  EXPECT_LT(Deprecated.evaluate(), Default.evaluate());
+  EXPECT_LT(Deprecated.evaluateHeuristics(), Default.evaluateHeuristics());
 
   SymbolQualitySignals ReservedName;
   ReservedName.ReservedName = true;
-  EXPECT_LT(ReservedName.evaluate(), Default.evaluate());
+  EXPECT_LT(ReservedName.evaluateHeuristics(), Default.evaluateHeuristics());
 
   SymbolQualitySignals ImplementationDetail;
   ImplementationDetail.ImplementationDetail = true;
-  EXPECT_LT(ImplementationDetail.evaluate(), Default.evaluate());
+  EXPECT_LT(ImplementationDetail.evaluateHeuristics(),
+Default.evaluateHeuristics());
 
   SymbolQualitySignals WithReferences, ManyReferences;
   WithReferences.References = 20;
   ManyReferences.References = 1000;
-  EXPECT_GT(WithReferences.evaluate(), Default.evaluate());
-  EXPECT_GT(ManyReferences.evaluate(), WithReferences.evaluate());
+  EXPECT_GT(WithReferences.evaluateHeuristics(), Default.evaluateHeuristics());
+  EXPECT_GT(ManyReferences.evaluateHeuristics(),
+WithReferences.evaluateHeuristics());
 
   SymbolQualitySignals Keyword, Variable, Macro, Constructor, Function,
   Destructor, Operator;
@@ -226,41 +228,44 @@
   Destructor.Category = SymbolQualitySignals::Destructor;
   Operator.Category = SymbolQualitySignals::Operator;
   Function.Category = SymbolQualitySignals::Function;
-  EXPECT_GT(Variable.evaluate(), Default.evaluate());
-  EXPECT_GT(Keyword.evaluate(), Variable.evaluate());
-  EXPECT_LT(Macro.evaluate(), Default.evaluate());
-  EXPECT_LT(Operator.evaluate(), Default.evaluate());
-  EXPECT_LT(Constructor.evaluate(), Function.evaluate());
-  EXPECT_LT(Destructor.evaluate(), Constructor.evaluate());
+  EXPECT_GT(Variable.evaluateHeuristics(), Default.evaluateHeuristics());
+  EXPECT_GT(Keyword.evaluateHeuristics(), Variable.evaluateHeuristics());
+  EXPECT_LT(Macro.evaluateHeuristics(), Default.evaluateHeuristics());
+  EXPECT_LT(Operator.evaluateHeuristics(), Default.evaluateHeuristics());
+  EXPECT_LT(Constructor.evaluateHeuristics(), Function.evaluateHeuristics());
+  EXPECT_LT(Destructor.evaluateHeuristics(), Constructor.evaluateHeuristics());
 }
 
 TEST(QualityTests, SymbolRelevanceSignalsSanity) {
   SymbolRelevanceSignals Default;
-  EXPECT_EQ(Default.evaluate(), 1);
+  EXPECT_EQ(Default.evaluateHeuristics(), 1);
 
   SymbolRelevanceSignals Forbidden;
   Forbidden.Forbidden = true;
-  EXPECT_LT(Forbidden.evaluate(), Default.evaluate());
+  EXPECT_LT(Forbidden.evaluateHeuristics(), Default.evaluateHeuristics());
 
   SymbolRelevanceSignals PoorNameMatch;
   PoorNameMatch.NameMatch = 0.2f;
-  EXPECT_LT(PoorNameMatch.evaluate(), Default.evaluate());
+  EXPECT_LT(PoorNameMatch.evaluateHeuristics(), Default.evaluateHeuristics());
 
   SymbolRelevanceSignals WithSemaFileProximity;
   WithSemaFileProximity.SemaFileProximityScore = 0.2f;
-  EXPECT_GT(WithSemaFileProximity.evaluate(), Default.evaluate());
+  EXPECT_GT(WithSemaFileProximity.evaluateHeuristics(),
+Default.evaluateHeuristics());
 
   ScopeDistance ScopeProximity({"x::y::"});
 
   SymbolRelevanceSignals WithSemaScopeProximity;
   WithSemaScopeProximity.ScopeProximityMatch = 
   WithSemaScopeProximity.SemaSaysInScope = true;
-  EXPECT_GT(WithSemaScopeProximity.evaluate(), Default.evaluate());
+  EXPECT_GT(WithSemaScopeProximity.evaluateHeuristics(),
+Default.evaluateHeuristics());
 
   SymbolRelevanceSignals WithIndexScopeProximity;
   WithIndexScopeProximity.ScopeProximityMatch = 
   WithIndexScopeProximity.SymbolScope = "x::";
-  EXPECT_GT(WithSemaScopeProximity.evaluate(), Default.evaluate());
+  EXPECT_GT(WithSemaScopeProximity.evaluateHeuristics(),
+Default.evaluateHeuristics());
 
   SymbolRelevanceSignals IndexProximate;
   IndexProximate.SymbolURI = "unittest:/foo/bar.h";

[clang-tools-extra] 9b1666f - [clangd] Rename evaluate() to evaluateHeuristics()

2020-09-28 Thread Utkarsh Saxena via cfe-commits

Author: Utkarsh Saxena
Date: 2020-09-28T20:05:01+02:00
New Revision: 9b1666f3ce2b02be70f8e7f82c3ec5c81262010b

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

LOG: [clangd] Rename evaluate() to evaluateHeuristics()

Since we have 2 scoring functions (heuristics and decision forest),
renaming the existing evaluate() function to be more descriptive of the
Heuristics being evaluated in it.

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

Added: 


Modified: 
clang-tools-extra/clangd/CodeComplete.cpp
clang-tools-extra/clangd/FindSymbols.cpp
clang-tools-extra/clangd/Quality.cpp
clang-tools-extra/clangd/Quality.h
clang-tools-extra/clangd/XRefs.cpp
clang-tools-extra/clangd/index/dex/Dex.cpp
clang-tools-extra/clangd/unittests/QualityTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/CodeComplete.cpp 
b/clang-tools-extra/clangd/CodeComplete.cpp
index 90e793f11564..1d2770823190 100644
--- a/clang-tools-extra/clangd/CodeComplete.cpp
+++ b/clang-tools-extra/clangd/CodeComplete.cpp
@@ -1632,8 +1632,8 @@ class CodeCompleteFlow {
 CodeCompletion::Scores Scores;
 switch (Opts.RankingModel) {
 case RM::Heuristics:
-  Scores.Quality = Quality.evaluate();
-  Scores.Relevance = Relevance.evaluate();
+  Scores.Quality = Quality.evaluateHeuristics();
+  Scores.Relevance = Relevance.evaluateHeuristics();
   Scores.Total =
   evaluateSymbolAndRelevance(Scores.Quality, Scores.Relevance);
   // NameMatch is in fact a multiplier on total score, so rescoring is

diff  --git a/clang-tools-extra/clangd/FindSymbols.cpp 
b/clang-tools-extra/clangd/FindSymbols.cpp
index e37d73103e36..e86c01d4076e 100644
--- a/clang-tools-extra/clangd/FindSymbols.cpp
+++ b/clang-tools-extra/clangd/FindSymbols.cpp
@@ -116,8 +116,8 @@ getWorkspaceSymbols(llvm::StringRef Query, int Limit,
   return;
 }
 Relevance.merge(Sym);
-auto Score =
-evaluateSymbolAndRelevance(Quality.evaluate(), Relevance.evaluate());
+auto Score = evaluateSymbolAndRelevance(Quality.evaluateHeuristics(),
+Relevance.evaluateHeuristics());
 dlog("FindSymbols: {0}{1} = {2}\n{3}{4}\n", Sym.Scope, Sym.Name, Score,
  Quality, Relevance);
 

diff  --git a/clang-tools-extra/clangd/Quality.cpp 
b/clang-tools-extra/clangd/Quality.cpp
index 37f1cf62821a..55b97eef123f 100644
--- a/clang-tools-extra/clangd/Quality.cpp
+++ b/clang-tools-extra/clangd/Quality.cpp
@@ -201,7 +201,7 @@ void SymbolQualitySignals::merge(const Symbol ) 
{
   ReservedName = ReservedName || isReserved(IndexResult.Name);
 }
 
-float SymbolQualitySignals::evaluate() const {
+float SymbolQualitySignals::evaluateHeuristics() const {
   float Score = 1;
 
   // This avoids a sharp gradient for tail symbols, and also neatly avoids the
@@ -253,7 +253,7 @@ float SymbolQualitySignals::evaluate() const {
 
 llvm::raw_ostream <<(llvm::raw_ostream ,
   const SymbolQualitySignals ) {
-  OS << llvm::formatv("=== Symbol quality: {0}\n", S.evaluate());
+  OS << llvm::formatv("=== Symbol quality: {0}\n", S.evaluateHeuristics());
   OS << llvm::formatv("\tReferences: {0}\n", S.References);
   OS << llvm::formatv("\tDeprecated: {0}\n", S.Deprecated);
   OS << llvm::formatv("\tReserved name: {0}\n", S.ReservedName);
@@ -364,7 +364,7 @@ SymbolRelevanceSignals::calculateDerivedSignals() const {
   return Derived;
 }
 
-float SymbolRelevanceSignals::evaluate() const {
+float SymbolRelevanceSignals::evaluateHeuristics() const {
   DerivedSignals Derived = calculateDerivedSignals();
   float Score = 1;
 
@@ -445,7 +445,7 @@ float SymbolRelevanceSignals::evaluate() const {
 
 llvm::raw_ostream <<(llvm::raw_ostream ,
   const SymbolRelevanceSignals ) {
-  OS << llvm::formatv("=== Symbol relevance: {0}\n", S.evaluate());
+  OS << llvm::formatv("=== Symbol relevance: {0}\n", S.evaluateHeuristics());
   OS << llvm::formatv("\tName: {0}\n", S.Name);
   OS << llvm::formatv("\tName match: {0}\n", S.NameMatch);
   if (S.ContextWords)

diff  --git a/clang-tools-extra/clangd/Quality.h 
b/clang-tools-extra/clangd/Quality.h
index 694653e1a714..afbc0f10208f 100644
--- a/clang-tools-extra/clangd/Quality.h
+++ b/clang-tools-extra/clangd/Quality.h
@@ -77,9 +77,8 @@ struct SymbolQualitySignals {
   void merge(const CodeCompletionResult );
   void merge(const Symbol );
 
-  // FIXME(usx): Rename to evaluateHeuristics().
   // Condense these signals down to a single number, higher is better.
-  float evaluate() const;
+  float evaluateHeuristics() const;
 };
 llvm::raw_ostream <<(llvm::raw_ostream &,
   const SymbolQualitySignals &);
@@ -158,7 +157,7 @@ struct SymbolRelevanceSignals {
   

[PATCH] D77062: [analyzer] Improve zero assumption in CStringChecke::assumeZero

2020-09-28 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

Nice, very interesting!

The contract of RegionStore with respect to type punning is that it stores the 
value //as written//, even if its type doesn't match the storage type, but then 
it casts the value to the correct type upon reading by invoking 
`CastRetrievedVal()` on it. That's where the fix should probably be.


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

https://reviews.llvm.org/D77062

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


[PATCH] D88345: [CUDA] Allow local `static const {__constant__, __device__}` variables.

2020-09-28 Thread Justin Lebar via Phabricator via cfe-commits
jlebar added a comment.

OK, backing up, what are the semantics of `static` on `__constant__`, 
`__device__`, and `__shared__`?

- My understanding is that `__shared__` behaves the same whether or not it's 
static.  It's not equivalent to `namespace a { __shared__ int c = 4; }`, 
because that's illegal.
- Does `__constant__` behave the same whether or not it's static?  A static 
`__constant__` is equivalent to `namespace a { __constant__ int c = 4; }`, and 
a non-static `__constant__` is *also* equivalent to that?
- And `__device__` does not behave the same whether or not it's static?  In 
function scope `__device__ int x;` is a variable local to the thread.  Whereas 
in global scope `__device__ int x;` is a global variable that lives in device 
memory (?).  In function scope `static __device__ int x;` is equivalent to 
`static int x;` which is equivalent to `int x;` in namespace scope?

Should we mandate that you initialize `static __constant__` variables in 
function scope?  That is, if you write `static __constant__ int x;` in a 
function, then x is always uninitialized (right)?  You should do `static 
__constant__ int x = 42;`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88345

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


[PATCH] D88434: [clangd] Improve PopulateSwitch tweak to work on non-empty switches

2020-09-28 Thread Tadeo Kondrak via Phabricator via cfe-commits
tdeo created this revision.
tdeo added a reviewer: sammccall.
tdeo added a project: clang-tools-extra.
Herald added subscribers: cfe-commits, usaxena95, kadircet, arphaman.
Herald added a project: clang.
tdeo requested review of this revision.
Herald added subscribers: MaskRay, ilya-biryukov.

Improve the recently-added PopulateSwitch tweak to work on non-empty switches.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D88434

Files:
  clang-tools-extra/clangd/refactor/tweaks/PopulateSwitch.cpp
  clang-tools-extra/clangd/unittests/TweakTests.cpp

Index: clang-tools-extra/clangd/unittests/TweakTests.cpp
===
--- clang-tools-extra/clangd/unittests/TweakTests.cpp
+++ clang-tools-extra/clangd/unittests/TweakTests.cpp
@@ -2829,9 +2829,33 @@
   "unavailable",
   },
   {
-  // Existing enumerators in switch
+  // All enumerators already in switch (single, unscoped)
   Function,
-  R""(enum Enum {A}; ^switch ((Enum)0) {case A:break;})"",
+  R""(enum Enum {A}; ^switch (A) {case A:break;})"",
+  "unavailable",
+  },
+  {
+  // All enumerators already in switch (multiple, unscoped)
+  Function,
+  R""(enum Enum {A,B}; ^switch (A) {case A:break;case B:break;})"",
+  "unavailable",
+  },
+  {
+  // All enumerators already in switch (single, scoped)
+  Function,
+  R""(
+enum class Enum {A};
+^switch (Enum::A) {case Enum::A:break;}
+  )"",
+  "unavailable",
+  },
+  {
+  // All enumerators already in switch (multiple, scoped)
+  Function,
+  R""(
+enum class Enum {A,B};
+^switch (Enum::A) {case Enum::A:break;case Enum::B:break;}
+  )"",
   "unavailable",
   },
   {
@@ -2867,9 +2891,53 @@
   {
   // Scoped enumeration with multiple enumerators
   Function,
-  R""(enum class Enum {A,B}; ^switch (Enum::A) {})"",
-  R""(enum class Enum {A,B}; )""
-  R""(switch (Enum::A) {case Enum::A:case Enum::B:break;})"",
+  R""(
+enum class Enum {A,B};
+^switch (Enum::A) {}
+  )"",
+  R""(
+enum class Enum {A,B};
+switch (Enum::A) {case Enum::A:case Enum::B:break;}
+  )"",
+  },
+  {
+  // Only filling in missing enumerators (unscoped)
+  Function,
+  R""(
+enum Enum {A,B,C};
+^switch (A) {case B:break;}
+  )"",
+  R""(
+enum Enum {A,B,C};
+switch (A) {case B:break;case A:case C:break;}
+  )"",
+  },
+  {
+  // Only filling in missing enumerators,
+  // even when using integer literals
+  Function,
+  R""(
+enum Enum {A,B=1,C};
+^switch (A) {case 1:break;}
+  )"",
+  R""(
+enum Enum {A,B=1,C};
+switch (A) {case 1:break;case A:case C:break;}
+  )"",
+  },
+  {
+  // Only filling in missing enumerators (scoped)
+  Function,
+  R""(
+enum class Enum {A,B,C};
+^switch (Enum::A)
+{case Enum::B:break;}
+  )"",
+  R""(
+enum class Enum {A,B,C};
+switch (Enum::A)
+{case Enum::B:break;case Enum::A:case Enum::C:break;}
+  )"",
   },
   {
   // Scoped enumerations in namespace
Index: clang-tools-extra/clangd/refactor/tweaks/PopulateSwitch.cpp
===
--- clang-tools-extra/clangd/refactor/tweaks/PopulateSwitch.cpp
+++ clang-tools-extra/clangd/refactor/tweaks/PopulateSwitch.cpp
@@ -33,12 +33,14 @@
 #include "AST.h"
 #include "Selection.h"
 #include "refactor/Tweak.h"
+#include "support/Logger.h"
 #include "clang/AST/Decl.h"
 #include "clang/AST/Stmt.h"
 #include "clang/AST/Type.h"
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/Tooling/Core/Replacement.h"
+#include "llvm/ADT/SmallSet.h"
 #include 
 
 namespace clang {
@@ -52,18 +54,16 @@
   Intent intent() const override { return Refactor; }
 
 private:
-  ASTContext *ASTCtx = nullptr;
   const DeclContext *DeclCtx = nullptr;
   const SwitchStmt *Switch = nullptr;
   const CompoundStmt *Body = nullptr;
+  const EnumType *EnumT = nullptr;
   const EnumDecl *EnumD = nullptr;
 };
 
 REGISTER_TWEAK(PopulateSwitch)
 
 bool PopulateSwitch::prepare(const Selection ) {
-  ASTCtx = >getASTContext();
-
   const SelectionTree::Node *CA = Sel.ASTSelection.commonAncestor();
   if (!CA)
 return false;
@@ -94,11 +94,6 @@
   if (!Body)
 return false;
 
-  // Since we currently always insert all enumerators, don't suggest this tweak
-  // if the body is not empty.
-  if (!Body->body_empty())
-   

[PATCH] D87648: [Coverage][NFC] Remove skipped region after added into MappingRegions

2020-09-28 Thread Zequan Wu via Phabricator via cfe-commits
zequanwu abandoned this revision.
zequanwu added inline comments.



Comment at: clang/lib/CodeGen/CoverageMappingGen.cpp:353
+SkippedRanges.erase(
+std::remove_if(
+SkippedRanges.begin(), SkippedRanges.end(),

vsk wrote:
> In the worst case, the work done in gatherSkippedRegions may still be n + 
> (n-1) + ... ~ O(n^2) (I'm subtracting 1 each time the skipped regions for a 
> function are erased).
Yeah, just notice that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87648

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


[PATCH] D77062: [analyzer] Improve zero assumption in CStringChecke::assumeZero

2020-09-28 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added a comment.

@steakhal

> If we get the value of `**b`, we get a //NonLoc// of type //unsigned char//.
> The dump of `**b` confirms this: `reg_$4 Element{SymRegion{reg_$0},0 S64b,unsigned char}>`, which is a 
> `NonLoc` in deed.

Exactly. That's what I've been trying to explaine above!
This happens because of the casts, after which CSA stores operates with the 
symbol (b) as it points to `int*` (though, it really is `char**`).

> IMO we should fix the root cause of this in the Core.

I can't see a direct fix for now and feel quite unconfident in that part of 
code. That's why I suggested to accept this change as what makes CSA codebase 
resistant to current bugs in the Core, which we are not able to fix for now. We 
can change Summary and the name of this revision for acception without 
objections.

@steakhal
You told that you suppose a potential fix. It would be nice, if you share the 
patch to review.


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

https://reviews.llvm.org/D77062

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


[PATCH] D88425: Skip -fPIE for AMDGPU and HIP toolchain

2020-09-28 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl marked an inline comment as done.
yaxunl added inline comments.



Comment at: clang/test/Driver/hip-fpie-option.hip:34
+
+// DEV-DAG: {{".*clang.*".* "-triple" "amdgcn-amd-amdhsa".* 
"-mrelocation-model" "pic" "-pic-level" "[1|2]" "-mframe-pointer=all"}}
+// HOST-STATIC-DAG: {{".*clang.*".* "-triple" "x86_64-unknown-linux-gnu".* 
"-mrelocation-model" "static"}}

tra wrote:
> Should there be some sort of `DEV-NOT: -pic-is-pie` instead? This line seems 
> to implicitly rely on -pic-is-pie` would come before `-mframe-pointer` and 
> it's not at all obvious that the key is the absence of `-pic-is-pie`.
> 
will add when commit


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

https://reviews.llvm.org/D88425

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


[PATCH] D88431: [clangd] Rename evaluate() to evaluateHeuristics()

2020-09-28 Thread Adam Czachorowski via Phabricator via cfe-commits
adamcz accepted this revision.
adamcz 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/D88431/new/

https://reviews.llvm.org/D88431

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


[PATCH] D87901: [Driver] Filter out /gcc and /gcc-cross if they do not exists

2020-09-28 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: clang/lib/Driver/ToolChains/Gnu.cpp:1964
   for (StringRef Candidate : CandidateBiarchTripleAliases)
 ScanLibDirForGCCTriple(TargetTriple, Args, LibDir, Candidate,
/*NeedsBiarchSuffix=*/ true);

MaskRay wrote:
> Its use of GCCDirExists is uninitialized. I suggest that you set GCCDirExists 
> and  GCCCrossDirExists to be conservative.
You may still GCCDirExists = GCCCrossDirExists = true here

If they are set to false by CandidateLibDirs, you don't want them to suppress 
the detection for CandidateBiarchLibDirs.

This probably suggests that the variables should not be member variables.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87901

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


[PATCH] D87901: [Driver] Filter out /gcc and /gcc-cross if they do not exists

2020-09-28 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: clang/lib/Driver/ToolChains/Gnu.cpp:2469
   } Suffixes[] = {
-  // This is the normal place.
-  {"gcc/" + CandidateTriple.str(), "../..", true},
+  // This is the normal place if Clang is installed alongside with GCC,
+  // probably with the same prefix. But it's likely does not exists in

MaskRay wrote:
> > Clang is installed alongside with GCC
> 
> This is not correct. (1) clang does not need to be installed (it can be used 
> in the build directory) (2) You can set --prefix (-B) and --sysroot to affect 
> detected prefixes. Clang does not need to be beside GCC.
My point is about the accuracy of the comment. The choice `"gcc/" + 
CandidateTriple.str()` is unrelated to where Clang is installed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87901

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


[PATCH] D88431: [clangd] Rename evaluate() to evaluateHeuristics()

2020-09-28 Thread Utkarsh Saxena via Phabricator via cfe-commits
usaxena95 created this revision.
Herald added subscribers: cfe-commits, kadircet, arphaman.
Herald added a project: clang.
usaxena95 requested review of this revision.
Herald added subscribers: MaskRay, ilya-biryukov.

Since we have 2 scoring functions (heuristics and decision forest),
renaming the existing evaluate() function to be more descriptive of the
Heuristics being evaluated in it.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D88431

Files:
  clang-tools-extra/clangd/CodeComplete.cpp
  clang-tools-extra/clangd/FindSymbols.cpp
  clang-tools-extra/clangd/Quality.cpp
  clang-tools-extra/clangd/Quality.h
  clang-tools-extra/clangd/XRefs.cpp
  clang-tools-extra/clangd/index/dex/Dex.cpp
  clang-tools-extra/clangd/unittests/QualityTests.cpp

Index: clang-tools-extra/clangd/unittests/QualityTests.cpp
===
--- clang-tools-extra/clangd/unittests/QualityTests.cpp
+++ clang-tools-extra/clangd/unittests/QualityTests.cpp
@@ -196,25 +196,27 @@
 // Do the signals move the scores in the direction we expect?
 TEST(QualityTests, SymbolQualitySignalsSanity) {
   SymbolQualitySignals Default;
-  EXPECT_EQ(Default.evaluate(), 1);
+  EXPECT_EQ(Default.evaluateHeuristics(), 1);
 
   SymbolQualitySignals Deprecated;
   Deprecated.Deprecated = true;
-  EXPECT_LT(Deprecated.evaluate(), Default.evaluate());
+  EXPECT_LT(Deprecated.evaluateHeuristics(), Default.evaluateHeuristics());
 
   SymbolQualitySignals ReservedName;
   ReservedName.ReservedName = true;
-  EXPECT_LT(ReservedName.evaluate(), Default.evaluate());
+  EXPECT_LT(ReservedName.evaluateHeuristics(), Default.evaluateHeuristics());
 
   SymbolQualitySignals ImplementationDetail;
   ImplementationDetail.ImplementationDetail = true;
-  EXPECT_LT(ImplementationDetail.evaluate(), Default.evaluate());
+  EXPECT_LT(ImplementationDetail.evaluateHeuristics(),
+Default.evaluateHeuristics());
 
   SymbolQualitySignals WithReferences, ManyReferences;
   WithReferences.References = 20;
   ManyReferences.References = 1000;
-  EXPECT_GT(WithReferences.evaluate(), Default.evaluate());
-  EXPECT_GT(ManyReferences.evaluate(), WithReferences.evaluate());
+  EXPECT_GT(WithReferences.evaluateHeuristics(), Default.evaluateHeuristics());
+  EXPECT_GT(ManyReferences.evaluateHeuristics(),
+WithReferences.evaluateHeuristics());
 
   SymbolQualitySignals Keyword, Variable, Macro, Constructor, Function,
   Destructor, Operator;
@@ -226,41 +228,44 @@
   Destructor.Category = SymbolQualitySignals::Destructor;
   Operator.Category = SymbolQualitySignals::Operator;
   Function.Category = SymbolQualitySignals::Function;
-  EXPECT_GT(Variable.evaluate(), Default.evaluate());
-  EXPECT_GT(Keyword.evaluate(), Variable.evaluate());
-  EXPECT_LT(Macro.evaluate(), Default.evaluate());
-  EXPECT_LT(Operator.evaluate(), Default.evaluate());
-  EXPECT_LT(Constructor.evaluate(), Function.evaluate());
-  EXPECT_LT(Destructor.evaluate(), Constructor.evaluate());
+  EXPECT_GT(Variable.evaluateHeuristics(), Default.evaluateHeuristics());
+  EXPECT_GT(Keyword.evaluateHeuristics(), Variable.evaluateHeuristics());
+  EXPECT_LT(Macro.evaluateHeuristics(), Default.evaluateHeuristics());
+  EXPECT_LT(Operator.evaluateHeuristics(), Default.evaluateHeuristics());
+  EXPECT_LT(Constructor.evaluateHeuristics(), Function.evaluateHeuristics());
+  EXPECT_LT(Destructor.evaluateHeuristics(), Constructor.evaluateHeuristics());
 }
 
 TEST(QualityTests, SymbolRelevanceSignalsSanity) {
   SymbolRelevanceSignals Default;
-  EXPECT_EQ(Default.evaluate(), 1);
+  EXPECT_EQ(Default.evaluateHeuristics(), 1);
 
   SymbolRelevanceSignals Forbidden;
   Forbidden.Forbidden = true;
-  EXPECT_LT(Forbidden.evaluate(), Default.evaluate());
+  EXPECT_LT(Forbidden.evaluateHeuristics(), Default.evaluateHeuristics());
 
   SymbolRelevanceSignals PoorNameMatch;
   PoorNameMatch.NameMatch = 0.2f;
-  EXPECT_LT(PoorNameMatch.evaluate(), Default.evaluate());
+  EXPECT_LT(PoorNameMatch.evaluateHeuristics(), Default.evaluateHeuristics());
 
   SymbolRelevanceSignals WithSemaFileProximity;
   WithSemaFileProximity.SemaFileProximityScore = 0.2f;
-  EXPECT_GT(WithSemaFileProximity.evaluate(), Default.evaluate());
+  EXPECT_GT(WithSemaFileProximity.evaluateHeuristics(),
+Default.evaluateHeuristics());
 
   ScopeDistance ScopeProximity({"x::y::"});
 
   SymbolRelevanceSignals WithSemaScopeProximity;
   WithSemaScopeProximity.ScopeProximityMatch = 
   WithSemaScopeProximity.SemaSaysInScope = true;
-  EXPECT_GT(WithSemaScopeProximity.evaluate(), Default.evaluate());
+  EXPECT_GT(WithSemaScopeProximity.evaluateHeuristics(),
+Default.evaluateHeuristics());
 
   SymbolRelevanceSignals WithIndexScopeProximity;
   WithIndexScopeProximity.ScopeProximityMatch = 
   WithIndexScopeProximity.SymbolScope = "x::";
-  EXPECT_GT(WithSemaScopeProximity.evaluate(), Default.evaluate());
+  

[PATCH] D88430: [OpenMP] Replace OpenMP RTL Functions With OMPIRBuilder and OMPKinds.def

2020-09-28 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 added a comment.

This currently fails some Clang tests because of an error with how `size_t` is 
handled by Clang versus OMPKinds.def. The compiler will crash when generating 
code for a 32 bit device on a 64 bit host because Clang uses the `size_t` from 
the host while OMPKinds.def uses the `size_t` from the device.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88430

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


[PATCH] D88424: [clang][codegen] Remove the insertion of `correctly-rounded-divide-sqrt-fp-math` fn-attr.

2020-09-28 Thread Alexey Bader via Phabricator via cfe-commits
bader added a comment.

You might need add [OpenCL] tag to the commit message.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88424

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


[PATCH] D87774: [flang] Introduce DiagnosticConsumer classes in libflangFrontend

2020-09-28 Thread Kiran Chandramohan via Phabricator via cfe-commits
kiranchandramohan added a subscriber: rovka.
kiranchandramohan added a comment.

In D87774#2298515 , @awarzynski wrote:

> In D87774#2293283 , @sameeranjoshi 
> wrote:
>
>> Do you know if there are any bots configured to handle out-of-tree changes?
>> That might be helpful to avoid configuration differences and test OFT 
>> patches.
>
> I'm not aware of a buildbot that would test out-of-tree builds. I also don't 
> know how hard it would be to set one up (AFAIK, there's no precedence of 
> out-of-tree LLVM buildbots). Defending every sub-project/feature that people 
> care about with a buildbot is important. Sadly I won't have the bandwidth to 
> set one up for out-of-tree builds any time soon. This my gentle call for 
> volunteers :)

https://reviews.llvm.org/D87085. Thanks @rovka.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87774

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


[PATCH] D88430: [OpenMP] Replace OpenMP RTL Functions With OMPIRBuilder and OMPKinds.def

2020-09-28 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 created this revision.
jhuber6 added a reviewer: jdoerfert.
jhuber6 added projects: OpenMP, LLVM, clang.
Herald added subscribers: llvm-commits, cfe-commits, guansong, yaxunl.
jhuber6 requested review of this revision.
Herald added a subscriber: sstefan1.

Replace the OpenMP Runtime Library functions used in CGOpenMPRuntimeGPU for 
OpenMP device code generation with ones in OMPKinds.def and use OMPIRBuilder 
for generating runtime calls. This allows us to consolidate more OpenMP code 
generation into the OMPIRBuilder.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D88430

Files:
  clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
  clang/lib/CodeGen/CGOpenMPRuntimeGPU.h
  clang/test/OpenMP/nvptx_parallel_codegen.cpp
  llvm/include/llvm/Frontend/OpenMP/OMPKinds.def

Index: llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
===
--- llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
+++ llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
@@ -220,6 +220,9 @@
 __OMP_FUNCTION_TYPE(KmpcCopyCtor, false, VoidPtr, VoidPtr, VoidPtr)
 __OMP_FUNCTION_TYPE(TaskRoutineEntry, false, Int32, Int32,
 /* kmp_task_t */ VoidPtr)
+__OMP_FUNCTION_TYPE(ShuffleReduce, false, Void, VoidPtr, Int16, Int16, Int16)
+__OMP_FUNCTION_TYPE(InterWarpCopy, false, Void, VoidPtr, Int32)
+__OMP_FUNCTION_TYPE(GlobalList, false, Void, VoidPtr, Int32, VoidPtr)
 
 #undef __OMP_FUNCTION_TYPE
 #undef OMP_FUNCTION_TYPE
@@ -295,8 +298,6 @@
 __OMP_RTL(__kmpc_push_num_threads, false, Void, IdentPtr, Int32,
   /* Int */ Int32)
 __OMP_RTL(__kmpc_push_proc_bind, false, Void, IdentPtr, Int32, /* Int */ Int32)
-__OMP_RTL(__kmpc_serialized_parallel, false, Void, IdentPtr, Int32)
-__OMP_RTL(__kmpc_end_serialized_parallel, false, Void, IdentPtr, Int32)
 __OMP_RTL(__kmpc_omp_reg_task_with_affinity, false, Int32, IdentPtr, Int32,
   /* kmp_task_t */ VoidPtr, Int32,
   /* kmp_task_affinity_info_t */ VoidPtr)
@@ -502,17 +503,42 @@
 __OMP_RTL(__kmpc_task_allow_completion_event, false, VoidPtr, IdentPtr,
   /* Int */ Int32, /* kmp_task_t */ VoidPtr)
 
+/// OpenMP Device runtime functions
+__OMP_RTL(__kmpc_kernel_init, false, Void, Int32, Int16)
+__OMP_RTL(__kmpc_kernel_deinit, false, Void, Int16)
+__OMP_RTL(__kmpc_spmd_kernel_init, false, Void, Int32, Int16, Int16)
+__OMP_RTL(__kmpc_spmd_kernel_deinit_v2, false, Void, Int16)
+__OMP_RTL(__kmpc_kernel_prepare_parallel, false, Void, VoidPtr)
+__OMP_RTL(__kmpc_kernel_parallel, false, Int1, VoidPtrPtr)
+__OMP_RTL(__kmpc_kernel_end_parallel, false, Void, )
+__OMP_RTL(__kmpc_serialized_parallel, false, Void, IdentPtr, Int32)
+__OMP_RTL(__kmpc_end_serialized_parallel, false, Void, IdentPtr, Int32)
+__OMP_RTL(__kmpc_shuffle_int32, false, Int32, Int32, Int16, Int16)
+__OMP_RTL(__kmpc_nvptx_parallel_reduce_nowait_v2, false, Int32, IdentPtr, Int32,
+  Int32, SizeTy, VoidPtr, ShuffleReducePtr, InterWarpCopyPtr)
+__OMP_RTL(__kmpc_nvptx_end_reduce_nowait, false, Void, Int32)
+__OMP_RTL(__kmpc_nvptx_teams_reduce_nowait_v2, false, Int32, IdentPtr, Int32,
+  VoidPtr, Int32, VoidPtr, ShuffleReducePtr, InterWarpCopyPtr,
+  GlobalListPtr, GlobalListPtr, GlobalListPtr, GlobalListPtr) 
+
+__OMP_RTL(__kmpc_shuffle_int64, false, Int64, Int64, Int16, Int16)
 __OMP_RTL(__kmpc_data_sharing_init_stack, false, Void, )
-__OMP_RTL(__kmpc_data_sharing_init_stack_spmd, false, Void, ) 
-__OMP_RTL(__kmpc_data_sharing_coalesced_push_stack, false, VoidPtr, SizeTy,
-  Int16)
+__OMP_RTL(__kmpc_data_sharing_init_stack_spmd, false, Void, )
+
+__OMP_RTL(__kmpc_data_sharing_coalesced_push_stack, false, VoidPtr, SizeTy, Int16)
 __OMP_RTL(__kmpc_data_sharing_push_stack, false, VoidPtr, SizeTy, Int16)
 __OMP_RTL(__kmpc_data_sharing_pop_stack, false, Void, VoidPtr)
-
-/// Note that device runtime functions (in the following) do not necessarily
-/// need attributes as we expect to see the definitions.
-__OMP_RTL(__kmpc_kernel_parallel, false, Int1, VoidPtrPtr)
-__OMP_RTL(__kmpc_kernel_prepare_parallel, false, Void, VoidPtr)
+__OMP_RTL(__kmpc_begin_sharing_variables, false, Void, VoidPtrPtrPtr, SizeTy)
+__OMP_RTL(__kmpc_end_sharing_variables, false, Void, )
+__OMP_RTL(__kmpc_get_shared_variables, false, Void, VoidPtrPtrPtr)
+__OMP_RTL(__kmpc_parallel_level, false, Int16, IdentPtr, Int32)
+__OMP_RTL(__kmpc_is_spmd_exec_mode, false, Int8, )
+__OMP_RTL(__kmpc_get_team_static_memory, false, Void, Int16, VoidPtr, SizeTy,
+  Int16, VoidPtrPtr)
+__OMP_RTL(__kmpc_restore_team_static_memory, false, Void, Int16, Int16)
+__OMP_RTL(__kmpc_barrier_simple_spmd, false, Void, IdentPtr, Int32)
+__OMP_RTL(__kmpc_warp_active_thread_mask, false, Int32, )
+__OMP_RTL(__kmpc_syncwarp, false, Void, Int32)
 
 __OMP_RTL(__last, false, Void, )
 
@@ -561,8 +587,8 @@
 
 __OMP_ATTRS_SET(BarrierAttrs,
 OptimisticAttributes
-? AttributeSet(EnumAttr(NoUnwind))
-: 

[PATCH] D88424: [clang][codegen] Remove the insertion of `correctly-rounded-divide-sqrt-fp-math` fn-attr.

2020-09-28 Thread Michael Liao via Phabricator via cfe-commits
hliao updated this revision to Diff 294745.
hliao added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88424

Files:
  clang/lib/CodeGen/CGCall.cpp
  clang/test/CodeGenOpenCL/amdgpu-attrs.cl
  clang/test/CodeGenOpenCL/fpmath.cl


Index: clang/test/CodeGenOpenCL/fpmath.cl
===
--- clang/test/CodeGenOpenCL/fpmath.cl
+++ clang/test/CodeGenOpenCL/fpmath.cl
@@ -7,7 +7,6 @@
 
 float spscalardiv(float a, float b) {
   // CHECK: @spscalardiv
-  // CHECK: #[[ATTR:[0-9]+]]
   // CHECK: fdiv{{.*}},
   // NODIVOPT: !fpmath ![[MD:[0-9]+]]
   // DIVOPT-NOT: !fpmath ![[MD:[0-9]+]]
@@ -16,7 +15,6 @@
 
 float4 spvectordiv(float4 a, float4 b) {
   // CHECK: @spvectordiv
-  // CHECK: #[[ATTR2:[0-9]+]]
   // CHECK: fdiv{{.*}},
   // NODIVOPT: !fpmath ![[MD]]
   // DIVOPT-NOT: !fpmath ![[MD]]
@@ -38,18 +36,9 @@
 #pragma OPENCL EXTENSION cl_khr_fp64 : enable
 double dpscalardiv(double a, double b) {
   // CHECK: @dpscalardiv
-  // CHECK: #[[ATTR]]
   // CHECK-NOT: !fpmath
   return a / b;
 }
 #endif
 
-// CHECK: attributes #[[ATTR]] = {
-// NODIVOPT-SAME: "correctly-rounded-divide-sqrt-fp-math"="false"
-// DIVOPT-SAME: "correctly-rounded-divide-sqrt-fp-math"="true"
-// CHECK-SAME: }
-// CHECK: attributes #[[ATTR2]] = {
-// NODIVOPT-SAME: "correctly-rounded-divide-sqrt-fp-math"="false"
-// DIVOPT-SAME: "correctly-rounded-divide-sqrt-fp-math"="true"
-// CHECK-SAME: }
 // NODIVOPT: ![[MD]] = !{float 2.50e+00}
Index: clang/test/CodeGenOpenCL/amdgpu-attrs.cl
===
--- clang/test/CodeGenOpenCL/amdgpu-attrs.cl
+++ clang/test/CodeGenOpenCL/amdgpu-attrs.cl
@@ -190,5 +190,5 @@
 // CHECK-DAG: attributes 
[[FLAT_WORK_GROUP_SIZE_32_64_WAVES_PER_EU_2_NUM_SGPR_32_NUM_VGPR_64]] = {{.*}} 
"amdgpu-flat-work-group-size"="32,64" "amdgpu-implicitarg-num-bytes"="56" 
"amdgpu-num-sgpr"="32" "amdgpu-num-vgpr"="64" "amdgpu-waves-per-eu"="2"
 // CHECK-DAG: attributes 
[[FLAT_WORK_GROUP_SIZE_32_64_WAVES_PER_EU_2_4_NUM_SGPR_32_NUM_VGPR_64]] = 
{{.*}} "amdgpu-flat-work-group-size"="32,64" 
"amdgpu-implicitarg-num-bytes"="56" "amdgpu-num-sgpr"="32" 
"amdgpu-num-vgpr"="64" "amdgpu-waves-per-eu"="2,4"
 
-// CHECK-DAG: attributes [[A_FUNCTION]] = {{.*}} 
"correctly-rounded-divide-sqrt-fp-math"="false"
+// CHECK-DAG: attributes [[A_FUNCTION]] = {{.*}}
 // CHECK-DAG: attributes [[DEFAULT_KERNEL_ATTRS]] = {{.*}} 
"amdgpu-flat-work-group-size"="1,256" "amdgpu-implicitarg-num-bytes"="56"
Index: clang/lib/CodeGen/CGCall.cpp
===
--- clang/lib/CodeGen/CGCall.cpp
+++ clang/lib/CodeGen/CGCall.cpp
@@ -1794,11 +1794,6 @@
llvm::utostr(CodeGenOpts.SSPBufferSize));
 FuncAttrs.addAttribute("no-signed-zeros-fp-math",
llvm::toStringRef(LangOpts.NoSignedZero));
-if (getLangOpts().OpenCL) {
-  FuncAttrs.addAttribute(
-  "correctly-rounded-divide-sqrt-fp-math",
-  llvm::toStringRef(CodeGenOpts.CorrectlyRoundedDivSqrt));
-}
 
 // TODO: Reciprocal estimate codegen options should apply to instructions?
 const std::vector  = CodeGenOpts.Reciprocals;


Index: clang/test/CodeGenOpenCL/fpmath.cl
===
--- clang/test/CodeGenOpenCL/fpmath.cl
+++ clang/test/CodeGenOpenCL/fpmath.cl
@@ -7,7 +7,6 @@
 
 float spscalardiv(float a, float b) {
   // CHECK: @spscalardiv
-  // CHECK: #[[ATTR:[0-9]+]]
   // CHECK: fdiv{{.*}},
   // NODIVOPT: !fpmath ![[MD:[0-9]+]]
   // DIVOPT-NOT: !fpmath ![[MD:[0-9]+]]
@@ -16,7 +15,6 @@
 
 float4 spvectordiv(float4 a, float4 b) {
   // CHECK: @spvectordiv
-  // CHECK: #[[ATTR2:[0-9]+]]
   // CHECK: fdiv{{.*}},
   // NODIVOPT: !fpmath ![[MD]]
   // DIVOPT-NOT: !fpmath ![[MD]]
@@ -38,18 +36,9 @@
 #pragma OPENCL EXTENSION cl_khr_fp64 : enable
 double dpscalardiv(double a, double b) {
   // CHECK: @dpscalardiv
-  // CHECK: #[[ATTR]]
   // CHECK-NOT: !fpmath
   return a / b;
 }
 #endif
 
-// CHECK: attributes #[[ATTR]] = {
-// NODIVOPT-SAME: "correctly-rounded-divide-sqrt-fp-math"="false"
-// DIVOPT-SAME: "correctly-rounded-divide-sqrt-fp-math"="true"
-// CHECK-SAME: }
-// CHECK: attributes #[[ATTR2]] = {
-// NODIVOPT-SAME: "correctly-rounded-divide-sqrt-fp-math"="false"
-// DIVOPT-SAME: "correctly-rounded-divide-sqrt-fp-math"="true"
-// CHECK-SAME: }
 // NODIVOPT: ![[MD]] = !{float 2.50e+00}
Index: clang/test/CodeGenOpenCL/amdgpu-attrs.cl
===
--- clang/test/CodeGenOpenCL/amdgpu-attrs.cl
+++ clang/test/CodeGenOpenCL/amdgpu-attrs.cl
@@ -190,5 +190,5 @@
 // CHECK-DAG: attributes [[FLAT_WORK_GROUP_SIZE_32_64_WAVES_PER_EU_2_NUM_SGPR_32_NUM_VGPR_64]] = {{.*}} "amdgpu-flat-work-group-size"="32,64" "amdgpu-implicitarg-num-bytes"="56" "amdgpu-num-sgpr"="32" 

[PATCH] D87774: [flang] Introduce DiagnosticConsumer classes in libflangFrontend

2020-09-28 Thread Andrzej Warzynski via Phabricator via cfe-commits
awarzynski updated this revision to Diff 294740.
awarzynski marked an inline comment as done.
awarzynski added a comment.

Address the remaining PR comments, fix test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87774

Files:
  clang/include/clang/Driver/Options.td
  flang/include/flang/Frontend/CompilerInvocation.h
  flang/include/flang/Frontend/TextDiagnostic.h
  flang/include/flang/Frontend/TextDiagnosticBuffer.h
  flang/include/flang/Frontend/TextDiagnosticPrinter.h
  flang/lib/Frontend/CMakeLists.txt
  flang/lib/Frontend/CompilerInstance.cpp
  flang/lib/Frontend/CompilerInvocation.cpp
  flang/lib/Frontend/TextDiagnostic.cpp
  flang/lib/Frontend/TextDiagnosticBuffer.cpp
  flang/lib/Frontend/TextDiagnosticPrinter.cpp
  flang/test/Flang-Driver/driver-error-cc1.c
  flang/test/Flang-Driver/driver-error-cc1.cpp
  flang/test/Flang-Driver/driver-help.f90
  flang/test/Flang-Driver/driver-version.f90
  flang/test/Flang-Driver/missing-input.f90
  flang/tools/flang-driver/driver.cpp
  flang/tools/flang-driver/fc1_main.cpp
  flang/unittests/Frontend/CompilerInstanceTest.cpp

Index: flang/unittests/Frontend/CompilerInstanceTest.cpp
===
--- flang/unittests/Frontend/CompilerInstanceTest.cpp
+++ flang/unittests/Frontend/CompilerInstanceTest.cpp
@@ -7,8 +7,8 @@
 //===--===//
 
 #include "flang/Frontend/CompilerInstance.h"
+#include "flang/Frontend/TextDiagnosticPrinter.h"
 #include "clang/Basic/DiagnosticOptions.h"
-#include "clang/Frontend/TextDiagnosticPrinter.h"
 
 #include "gtest/gtest.h"
 
@@ -21,7 +21,7 @@
   // 1. Set-up a basic DiagnosticConsumer
   std::string diagnosticOutput;
   llvm::raw_string_ostream diagnosticsOS(diagnosticOutput);
-  auto diagPrinter = std::make_unique(
+  auto diagPrinter = std::make_unique(
   diagnosticsOS, new clang::DiagnosticOptions());
 
   // 2. Create a CompilerInstance (to manage a DiagnosticEngine)
Index: flang/tools/flang-driver/fc1_main.cpp
===
--- flang/tools/flang-driver/fc1_main.cpp
+++ flang/tools/flang-driver/fc1_main.cpp
@@ -14,9 +14,9 @@
 
 #include "flang/Frontend/CompilerInstance.h"
 #include "flang/Frontend/CompilerInvocation.h"
+#include "flang/Frontend/TextDiagnosticBuffer.h"
 #include "flang/FrontendTool/Utils.h"
 #include "clang/Driver/DriverDiagnostic.h"
-#include "clang/Frontend/TextDiagnosticBuffer.h"
 #include "llvm/Option/Arg.h"
 #include "llvm/Option/ArgList.h"
 #include "llvm/Option/OptTable.h"
@@ -34,18 +34,22 @@
   if (!flang->HasDiagnostics())
 return 1;
 
+  // We will buffer diagnostics from argument parsing so that we can output
+  // them using a well formed diagnostic object.
+  TextDiagnosticBuffer *diagsBuffer = new TextDiagnosticBuffer;
+
   // Create CompilerInvocation - use a dedicated instance of DiagnosticsEngine
   // for parsing the arguments
   llvm::IntrusiveRefCntPtr diagID(
   new clang::DiagnosticIDs());
   llvm::IntrusiveRefCntPtr diagOpts =
   new clang::DiagnosticOptions();
-  clang::TextDiagnosticBuffer *diagsBuffer = new clang::TextDiagnosticBuffer;
   clang::DiagnosticsEngine diags(diagID, &*diagOpts, diagsBuffer);
   bool success =
   CompilerInvocation::CreateFromArgs(flang->GetInvocation(), argv, diags);
 
   diagsBuffer->FlushDiagnostics(flang->getDiagnostics());
+
   if (!success)
 return 1;
 
Index: flang/tools/flang-driver/driver.cpp
===
--- flang/tools/flang-driver/driver.cpp
+++ flang/tools/flang-driver/driver.cpp
@@ -11,11 +11,12 @@
 //
 //===--===//
 #include "clang/Driver/Driver.h"
+#include "flang/Frontend/CompilerInvocation.h"
+#include "flang/Frontend/TextDiagnosticPrinter.h"
 #include "clang/Basic/Diagnostic.h"
 #include "clang/Basic/DiagnosticIDs.h"
 #include "clang/Basic/DiagnosticOptions.h"
 #include "clang/Driver/Compilation.h"
-#include "clang/Frontend/TextDiagnosticPrinter.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/IntrusiveRefCntPtr.h"
 #include "llvm/Option/ArgList.h"
@@ -23,6 +24,8 @@
 #include "llvm/Support/InitLLVM.h"
 #include "llvm/Support/VirtualFileSystem.h"
 
+using llvm::StringRef;
+
 // main frontend method. Lives inside fc1_main.cpp
 extern int fc1_main(llvm::ArrayRef argv, const char *argv0);
 
@@ -37,6 +40,17 @@
 static clang::DiagnosticOptions *CreateAndPopulateDiagOpts(
 llvm::ArrayRef argv) {
   auto *diagOpts = new clang::DiagnosticOptions;
+
+  // Ignore missingArgCount and the return value of ParseDiagnosticArgs.
+  // Any errors that would be diagnosed here will also be diagnosed later,
+  // when the DiagnosticsEngine actually exists.
+  unsigned missingArgIndex, missingArgCount;
+  llvm::opt::InputArgList args = 

  1   2   >