[PATCH] D64672: [X86] Prevent passing vectors of __int128 as in llvm IR

2019-09-01 Thread Craig Topper via Phabricator via cfe-commits
craig.topper updated this revision to Diff 218284.
craig.topper added a comment.

Add more tests. Clarify which platforms are affected in LangOptions.h


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64672

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/LangOptions.h
  clang/lib/CodeGen/TargetInfo.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/pr42607.c

Index: clang/test/CodeGen/pr42607.c
===
--- /dev/null
+++ clang/test/CodeGen/pr42607.c
@@ -0,0 +1,52 @@
+// RUN: %clang_cc1 -triple x86_64-linux-gnu %s -target-feature +sse2 -S -emit-llvm -o - | FileCheck %s --check-prefixes=NEWABI128,MEM256ALIGN32,MEM512ALIGN64
+// RUN: %clang_cc1 -triple x86_64-netbsd %s -target-feature +sse2 -S -emit-llvm -o - | FileCheck %s --check-prefixes=NEWABI128,MEM256ALIGN32,MEM512ALIGN64
+// RUN: %clang_cc1 -triple x86_64-apple-darwin %s -target-feature +sse2 -S -emit-llvm -o - | FileCheck %s --check-prefixes=OLDABI128,MEM256ALIGN16,MEM512ALIGN16
+// RUN: %clang_cc1 -triple x86_64-scei-ps4 %s -target-feature +sse2 -S -emit-llvm -o - | FileCheck %s --check-prefixes=OLDABI128,MEM256ALIGN32,MEM512ALIGN64
+// RUN: %clang_cc1 -triple x86_64-unknown-freebsd10.0 %s -target-feature +sse2 -S -emit-llvm -o - | FileCheck %s --check-prefixes=OLDABI128,MEM256ALIGN32,MEM512ALIGN64
+// RUN: %clang_cc1 -triple x86_64-linux-gnu %s -target-feature +sse2 -S -emit-llvm -o - -fclang-abi-compat=9 | FileCheck %s --check-prefixes=OLDABI128,MEM256ALIGN32,MEM512ALIGN64
+
+// RUN: %clang_cc1 -triple x86_64-linux-gnu %s -target-feature +avx -S -emit-llvm -o - | FileCheck %s --check-prefixes=NEWABI128,NEWABI256,MEM512ALIGN64
+// RUN: %clang_cc1 -triple x86_64-netbsd %s -target-feature +avx -S -emit-llvm -o - | FileCheck %s --check-prefixes=NEWABI128,NEWABI256,MEM512ALIGN64
+// RUN: %clang_cc1 -triple x86_64-apple-darwin %s -target-feature +avx -S -emit-llvm -o - | FileCheck %s --check-prefixes=OLDABI128,OLDABI256,MEM512ALIGN32
+// RUN: %clang_cc1 -triple x86_64-scei-ps4 %s -target-feature +avx -S -emit-llvm -o - | FileCheck %s --check-prefixes=OLDABI128,OLDABI256,MEM512ALIGN64
+// RUN: %clang_cc1 -triple x86_64-unknown-freebsd10.0 %s -target-feature +avx -S -emit-llvm -o - | FileCheck %s --check-prefixes=OLDABI128,OLDABI256,MEM512ALIGN64
+// RUN: %clang_cc1 -triple x86_64-linux-gnu %s -target-feature +avx -S -emit-llvm -o - -fclang-abi-compat=9 | FileCheck %s --check-prefixes=OLDABI128,OLDABI256,MEM512ALIGN64
+
+// RUN: %clang_cc1 -triple x86_64-linux-gnu %s -target-feature +avx512f -S -emit-llvm -o - | FileCheck %s --check-prefixes=NEWABI128,NEWABI256,NEWABI512
+// RUN: %clang_cc1 -triple x86_64-netbsd %s -target-feature +avx512f -S -emit-llvm -o - | FileCheck %s --check-prefixes=NEWABI128,NEWABI256,NEWABI512
+// RUN: %clang_cc1 -triple x86_64-apple-darwin %s -target-feature +avx512f -S -emit-llvm -o - | FileCheck %s --check-prefixes=OLDABI128,OLDABI256,OLDABI512
+// RUN: %clang_cc1 -triple x86_64-scei-ps4 %s -target-feature +avx512f -S -emit-llvm -o - | FileCheck %s --check-prefixes=OLDABI128,OLDABI256,OLDABI512
+// RUN: %clang_cc1 -triple x86_64-unknown-freebsd10.0 %s -target-feature +avx512f -S -emit-llvm -o - | FileCheck %s --check-prefixes=OLDABI128,OLDABI256,OLDABI512
+// RUN: %clang_cc1 -triple x86_64-linux-gnu %s -target-feature +avx512f -S -emit-llvm -o - -fclang-abi-compat=9 | FileCheck %s --check-prefixes=OLDABI128,OLDABI256,OLDABI512
+
+typedef unsigned long long v16u64 __attribute__((vector_size(16)));
+typedef unsigned __int128 v16u128 __attribute__((vector_size(16)));
+
+v16u64 test_v16u128(v16u64 a, v16u128 b) {
+// NEWABI128: define <2 x i64> @test_v16u128(<2 x i64> %{{.*}}, <2 x i64> %{{.*}})
+// OLDABI128: define <2 x i64> @test_v16u128(<2 x i64> %{{.*}}, <1 x i128> %{{.*}})
+  return a + (v16u64)b;
+}
+
+typedef unsigned long long v32u64 __attribute__((vector_size(32)));
+typedef unsigned __int128 v32u128 __attribute__((vector_size(32)));
+
+v32u64 test_v32u128(v32u64 a, v32u128 b) {
+// MEM256ALIGN16: define <4 x i64> @test_v32u128(<4 x i64>* byval(<4 x i64>) align 16 %{{.*}}, <2 x i128>* byval(<2 x i128>) align 16 %{{.*}})
+// MEM256ALIGN32: define <4 x i64> @test_v32u128(<4 x i64>* byval(<4 x i64>) align 32 %{{.*}}, <2 x i128>* byval(<2 x i128>) align 32 %{{.*}})
+// NEWABI256: define <4 x i64> @test_v32u128(<4 x i64> %{{.*}}, <2 x i128>* byval(<2 x i128>) align 32 %{{.*}})
+// OLDABI256: define <4 x i64> @test_v32u128(<4 x i64> %{{.*}}, <2 x i128> %{{.*}})
+  return a + (v32u64)b;
+}
+
+typedef unsigned long long v64u64 __attribute__((vector_size(64)));
+typedef unsigned __int128 v64u128 __attribute__((vector_size(64)));
+
+v64u64 test_v64u128(v64u64 a, v64u128 b) {
+// MEM512ALIGN16: define <8 x i64> @test_v64u128(<8 x i64>* byval(<8 x i64>) align 16 %{{.*}}, <4 x i128>* byval(<4 x i128>) align 16 %{{.*}})
+// MEM512ALIGN32: define <8 x i64> 

[PATCH] D67058: [clang][CodeGen] Add alias for cpu_dispatch function with IFunc

2019-09-01 Thread Sr.Zhang via Phabricator via cfe-commits
zsrkmyn created this revision.
zsrkmyn added a reviewer: erichkeane.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Multi-versioned functions defined by cpu_dispatch and implemented with IFunc
can not be called outside the translation units where they are defined due to
lack of symbols. This patch add function aliases for these functions and thus
make them visible outside.


Repository:
  rC Clang

https://reviews.llvm.org/D67058

Files:
  clang/lib/CodeGen/CodeGenModule.cpp


Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -2948,6 +2948,25 @@
 
   CodeGenFunction CGF(*this);
   CGF.EmitMultiVersionResolver(ResolverFunc, Options);
+
+  if (getTarget().supportsIFunc()) {
+std::string AliasName = getMangledNameImpl(
+*this, GD, FD, /*OmitMultiVersionMangling=*/true);
+llvm::Constant *AliasFunc = GetGlobalValue(AliasName);
+if (!AliasFunc) {
+  auto *IFunc = cast(GetOrCreateLLVMFunction(
+  AliasName, DeclTy, GD, /*ForVTable=*/false, /*DontDefer=*/true,
+  /*IsThunk=*/false, llvm::AttributeList(), NotForDefinition));
+  auto *GA = llvm::GlobalAlias::create(
+ DeclTy, 0, getFunctionLinkage(GD), AliasName, IFunc, ());
+  const auto *D = GD.getDecl();
+  if (D->hasAttr() || D->hasAttr() ||
+  D->isWeakImported()) {
+GA->setLinkage(llvm::Function::WeakAnyLinkage);
+  }
+  SetCommonAttributes(GD, GA);
+}
+  }
 }
 
 /// If a dispatcher for the specified mangled name is not in the module, create


Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -2948,6 +2948,25 @@
 
   CodeGenFunction CGF(*this);
   CGF.EmitMultiVersionResolver(ResolverFunc, Options);
+
+  if (getTarget().supportsIFunc()) {
+std::string AliasName = getMangledNameImpl(
+*this, GD, FD, /*OmitMultiVersionMangling=*/true);
+llvm::Constant *AliasFunc = GetGlobalValue(AliasName);
+if (!AliasFunc) {
+  auto *IFunc = cast(GetOrCreateLLVMFunction(
+  AliasName, DeclTy, GD, /*ForVTable=*/false, /*DontDefer=*/true,
+  /*IsThunk=*/false, llvm::AttributeList(), NotForDefinition));
+  auto *GA = llvm::GlobalAlias::create(
+ DeclTy, 0, getFunctionLinkage(GD), AliasName, IFunc, ());
+  const auto *D = GD.getDecl();
+  if (D->hasAttr() || D->hasAttr() ||
+  D->isWeakImported()) {
+GA->setLinkage(llvm::Function::WeakAnyLinkage);
+  }
+  SetCommonAttributes(GD, GA);
+}
+  }
 }
 
 /// If a dispatcher for the specified mangled name is not in the module, create
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D67057: [AST][JSON] Generate parent context id from Decl* instead of DeclContext*

2019-09-01 Thread Bert Belder via Phabricator via cfe-commits
piscisaureus created this revision.
piscisaureus added a reviewer: aaron.ballman.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Because of multiple inheritance, a DeclContext pointer does not produce
the same pointer representation as a Decl pointer that references the
same AST Node.

When dumping the parentDeclContextId field of a node, convert the pointer
to Decl* first, so the id can be used to find the AST node it references.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D67057

Files:
  clang/lib/AST/JSONNodeDumper.cpp
  clang/test/AST/ast-dump-decl-context-json.cpp
  clang/test/AST/ast-dump-decl-json.c
  clang/test/AST/ast-dump-funcs-json.cpp
  clang/test/AST/ast-dump-template-decls-json.cpp

Index: clang/test/AST/ast-dump-template-decls-json.cpp
===
--- clang/test/AST/ast-dump-template-decls-json.cpp
+++ clang/test/AST/ast-dump-template-decls-json.cpp
@@ -2217,7 +2217,7 @@
 // CHECK-NEXT:  "tokLen": 1
 // CHECK-NEXT: }
 // CHECK-NEXT:},
-// CHECK-NEXT:"parentDeclContext": "0x{{.*}}",
+// CHECK-NEXT:"parentDeclContextId": "0x{{.*}}",
 // CHECK-NEXT:"previousDecl": "0x{{.*}}",
 // CHECK-NEXT:"name": "f",
 // CHECK-NEXT:"inner": [
@@ -2264,7 +2264,7 @@
 // CHECK-NEXT:"tokLen": 1
 // CHECK-NEXT:   }
 // CHECK-NEXT:  },
-// CHECK-NEXT:  "parentDeclContext": "0x{{.*}}",
+// CHECK-NEXT:  "parentDeclContextId": "0x{{.*}}",
 // CHECK-NEXT:  "previousDecl": "0x{{.*}}",
 // CHECK-NEXT:  "name": "f",
 // CHECK-NEXT:  "type": {
Index: clang/test/AST/ast-dump-funcs-json.cpp
===
--- clang/test/AST/ast-dump-funcs-json.cpp
+++ clang/test/AST/ast-dump-funcs-json.cpp
@@ -426,7 +426,7 @@
 // CHECK-NEXT:"tokLen": 1
 // CHECK-NEXT:   }
 // CHECK-NEXT:  },
-// CHECK-NEXT:  "parentDeclContext": "0x{{.*}}",
+// CHECK-NEXT:  "parentDeclContextId": "0x{{.*}}",
 // CHECK-NEXT:  "previousDecl": "0x{{.*}}",
 // CHECK-NEXT:  "name": "Test1",
 // CHECK-NEXT:  "type": {
Index: clang/test/AST/ast-dump-decl-json.c
===
--- clang/test/AST/ast-dump-decl-json.c
+++ clang/test/AST/ast-dump-decl-json.c
@@ -226,7 +226,7 @@
 // CHECK-NEXT:  "tokLen": 1
 // CHECK-NEXT: }
 // CHECK-NEXT:},
-// CHECK-NEXT:"parentDeclContext": "0x{{.*}}",
+// CHECK-NEXT:"parentDeclContextId": "0x{{.*}}",
 // CHECK-NEXT:"name": "y",
 // CHECK-NEXT:"tagUsed": "struct",
 // CHECK-NEXT:"completeDefinition": true,
Index: clang/test/AST/ast-dump-decl-context-json.cpp
===
--- /dev/null
+++ clang/test/AST/ast-dump-decl-context-json.cpp
@@ -0,0 +1,286 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -ast-dump=json -ast-dump-filter Test %s | FileCheck %s
+
+namespace Test {
+
+namespace NS {
+void Function();
+}
+void NS::Function() {}
+
+struct S {
+  void Method();
+};
+void S::Method() {}
+
+} // namespace Test
+
+// CHECK:  "kind": "NamespaceDecl",
+// CHECK-NEXT:  "loc": {
+// CHECK-NEXT:   "file": "{{.*}}",
+// CHECK-NEXT:   "line": 3,
+// CHECK-NEXT:   "col": 11,
+// CHECK-NEXT:   "tokLen": 4
+// CHECK-NEXT:  },
+// CHECK-NEXT:  "range": {
+// CHECK-NEXT:   "begin": {
+// CHECK-NEXT:"col": 1,
+// CHECK-NEXT:"tokLen": 9
+// CHECK-NEXT:   },
+// CHECK-NEXT:   "end": {
+// CHECK-NEXT:"line": 15,
+// CHECK-NEXT:"col": 1,
+// CHECK-NEXT:"tokLen": 1
+// CHECK-NEXT:   }
+// CHECK-NEXT:  },
+// CHECK-NEXT:  "name": "Test",
+// CHECK-NEXT:  "inner": [
+// CHECK-NEXT:   {
+// CHECK-NEXT:"id": "0x[[NS_ID:.*]]",
+// CHECK-NEXT:"kind": "NamespaceDecl",
+// CHECK-NEXT:"loc": {
+// CHECK-NEXT: "line": 5,
+// CHECK-NEXT: "col": 11,
+// CHECK-NEXT: "tokLen": 2
+// CHECK-NEXT:},
+// CHECK-NEXT:"range": {
+// CHECK-NEXT: "begin": {
+// CHECK-NEXT:  "col": 1,
+// CHECK-NEXT:  "tokLen": 9
+// CHECK-NEXT: },
+// CHECK-NEXT: "end": {
+// CHECK-NEXT:  "line": 7,
+// CHECK-NEXT:  "col": 1,
+// CHECK-NEXT:  "tokLen": 1
+// CHECK-NEXT: }
+// CHECK-NEXT:},
+// CHECK-NEXT:"name": "NS",
+// CHECK-NEXT:"inner": [
+// CHECK-NEXT: {
+// CHECK-NEXT:  "id": "0x[[FUNCTION_ID:.*]]",
+// CHECK-NEXT:  "kind": "FunctionDecl",
+// CHECK-NEXT:  "loc": {
+// CHECK-NEXT:   "line": 6,
+// CHECK-NEXT:   "col": 6,
+// CHECK-NEXT:   "tokLen": 8
+// CHECK-NEXT:  },
+// CHECK-NEXT:  "range": {
+// CHECK-NEXT:   "begin": {
+// CHECK-NEXT:"col": 1,
+// CHECK-NEXT:"tokLen": 4
+// CHECK-NEXT:   },
+// CHECK-NEXT:   "end": {
+// CHECK-NEXT:"col": 15,
+// CHECK-NEXT:"tokLen": 1
+// CHECK-NEXT:   }
+// CHECK-NEXT:  },
+// CHECK-NEXT:  "name": "Function",
+// CHECK-NEXT:  "type": {
+// CHECK-NEXT:   "qualType": "void ()"

[PATCH] D67056: Add a bugprone-argument-comment option: IgnoreSingleArgument.

2019-09-01 Thread Yubo Xie via Phabricator via cfe-commits
xyb created this revision.
xyb added a reviewer: alexfh.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Add bugprone-argument-comment option: IgnoreSingleArgument.
When true, the check will ignore the single argument.

Sometimes, it's not necessary to add comment to single argument.
For example:

> std::string name("Yubo Xie");
>  pScreen->SetWidth(1920);
>  pScreen->SetHeight(1080);

This option can ignore such single argument in bugprone-argument-comment check.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D67056

Files:
  clang-tools-extra/clang-tidy/bugprone/ArgumentCommentCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/ArgumentCommentCheck.h
  clang-tools-extra/docs/clang-tidy/checks/bugprone-argument-comment.rst
  
clang-tools-extra/test/clang-tidy/bugprone-argument-comment-ignore-single-argument.cpp

Index: clang-tools-extra/test/clang-tidy/bugprone-argument-comment-ignore-single-argument.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/bugprone-argument-comment-ignore-single-argument.cpp
@@ -0,0 +1,97 @@
+// RUN: %check_clang_tidy %s bugprone-argument-comment %t -- \
+// RUN:   -config="{CheckOptions: [{key: IgnoreSingleArgument, value: 1}, {key: CommentBoolLiterals, value: 1},{key: CommentIntegerLiterals, value: 1}, {key: CommentFloatLiterals, value: 1}, {key: CommentUserDefinedLiterals, value: 1}, {key: CommentStringLiterals, value: 1}, {key: CommentNullPtrs, value: 1}, {key: CommentCharacterLiterals, value: 1}]}" --
+
+struct A {
+  void foo(bool abc);
+  void foo(bool abc, bool cde);
+  void foo(const char *, bool abc);
+  void foo(int iabc);
+  void foo(float fabc);
+  void foo(double dabc);
+  void foo(const char *strabc);
+  void fooW(const wchar_t *wstrabc);
+  void fooPtr(A *ptrabc);
+  void foo(char chabc);
+};
+
+#define FOO 1
+
+void g(int a);
+void h(double b);
+void i(const char *c);
+
+double operator"" _km(long double);
+
+void test() {
+  A a;
+
+  a.foo(true);
+
+  a.foo(false);
+
+  a.foo(true, false);
+  // CHECK-MESSAGES: [[@LINE-1]]:9: warning: argument comment missing for literal argument 'abc' [bugprone-argument-comment]
+  // CHECK-MESSAGES: [[@LINE-2]]:15: warning: argument comment missing for literal argument 'cde' [bugprone-argument-comment]
+  // CHECK-FIXES: a.foo(/*abc=*/true, /*cde=*/false);
+
+  a.foo(false, true);
+  // CHECK-MESSAGES: [[@LINE-1]]:9: warning: argument comment missing for literal argument 'abc' [bugprone-argument-comment]
+  // CHECK-MESSAGES: [[@LINE-2]]:16: warning: argument comment missing for literal argument 'cde' [bugprone-argument-comment]
+  // CHECK-FIXES: a.foo(/*abc=*/false, /*cde=*/true);
+
+  a.foo(/*abc=*/false, true);
+  // CHECK-MESSAGES: [[@LINE-1]]:24: warning: argument comment missing for literal argument 'cde' [bugprone-argument-comment]
+  // CHECK-FIXES: a.foo(/*abc=*/false, /*cde=*/true);
+
+  a.foo(false, /*cde=*/true);
+  // CHECK-MESSAGES: [[@LINE-1]]:9: warning: argument comment missing for literal argument 'abc' [bugprone-argument-comment]
+  // CHECK-FIXES: a.foo(/*abc=*/false, /*cde=*/true);
+
+  bool val1 = true;
+  bool val2 = false;
+  a.foo(val1, val2);
+
+  a.foo("", true);
+  // CHECK-MESSAGES: [[@LINE-1]]:13: warning: argument comment missing for literal argument 'abc' [bugprone-argument-comment]
+  // CHECK-FIXES: a.foo("", /*abc=*/true);
+
+  a.foo(0);
+
+  a.foo(1.0f);
+
+  a.foo(1.0);
+
+  int val3 = 10;
+  a.foo(val3);
+
+  float val4 = 10.0;
+  a.foo(val4);
+
+  double val5 = 10.0;
+  a.foo(val5);
+
+  a.foo("Hello World");
+
+  a.fooW(L"Hello World");
+
+  a.fooPtr(nullptr);
+
+  a.foo(402.0_km);
+
+  a.foo('A');
+
+  g(FOO);
+
+  h(1.0f);
+
+  i(__FILE__);
+
+  g((1));
+}
+
+void f(bool _with_underscores_);
+void ignores_underscores() {
+  f(false);
+
+  f(true);
+}
Index: clang-tools-extra/docs/clang-tidy/checks/bugprone-argument-comment.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/bugprone-argument-comment.rst
+++ clang-tools-extra/docs/clang-tidy/checks/bugprone-argument-comment.rst
@@ -28,6 +28,9 @@
underscores and case when comparing names -- otherwise they are taken into
account.
 
+.. option:: IgnoreSingleArgument
+   When true, the check will ignore the single argument.
+
 .. option:: CommentBoolLiterals
 
When true, the check will add argument comments in the format
Index: clang-tools-extra/clang-tidy/bugprone/ArgumentCommentCheck.h
===
--- clang-tools-extra/clang-tidy/bugprone/ArgumentCommentCheck.h
+++ clang-tools-extra/clang-tidy/bugprone/ArgumentCommentCheck.h
@@ -41,6 +41,7 @@
 
 private:
   const unsigned StrictMode : 1;
+  const unsigned IgnoreSingleArgument : 1;
   const unsigned CommentBoolLiterals : 1;
   const unsigned CommentIntegerLiterals : 1;
   const unsigned CommentFloatLiterals : 1;
Index: 

[PATCH] D67023: Diagnose use of ATOMIC_VAR_INIT

2019-09-01 Thread JF Bastien via Phabricator via cfe-commits
jfb added a comment.

I refer you to http://wg21.link/p0883
I don’t think this diagnostic should be added to clang until p0883 is fully 
implemented, even just for C. Otherwise we leave users with no portable way to 
do the right thing without diagnostic.


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

https://reviews.llvm.org/D67023



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


[PATCH] D67052: Add reference type transformation builtins

2019-09-01 Thread Zoe Carver via Phabricator via cfe-commits
zoecarver updated this revision to Diff 218276.
zoecarver added a comment.

- remove accedentally added file


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67052

Files:
  clang/include/clang/AST/Type.h
  clang/include/clang/Basic/Specifiers.h
  clang/include/clang/Basic/TokenKinds.def
  clang/include/clang/Parse/Parser.h
  clang/include/clang/Sema/DeclSpec.h
  clang/lib/Format/FormatToken.cpp
  clang/lib/Lex/PPMacroExpansion.cpp
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/lib/Sema/DeclSpec.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaTemplateVariadic.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/SemaCXX/add_reference.cpp
  
libcxx/test/libcxx/utilities/meta/stress_tests/stress_test_add_lvalue_reference.sh.cpp
  
libcxx/test/libcxx/utilities/meta/stress_tests/stress_test_add_rvalue_reference.sh.cpp
  
libcxx/test/libcxx/utilities/meta/stress_tests/stress_test_remove_reference.sh.cpp

Index: libcxx/test/libcxx/utilities/meta/stress_tests/stress_test_remove_reference.sh.cpp
===
--- /dev/null
+++ libcxx/test/libcxx/utilities/meta/stress_tests/stress_test_remove_reference.sh.cpp
@@ -0,0 +1,63 @@
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This is a dummy feature that prevents this test from running by default.
+
+// The table below compares the compile time and object size for each of the
+// variants listed in the RUN script.
+//
+//  Impl   Compile Time  Object Size
+// --
+// new_remove_reference:   22.849 s  121 K
+// std::remove_reference:  25.643 s  121 K
+//
+// RUN: %cxx %flags %compile_flags -c %s -o %S/orig.o -ggdb  -ggnu-pubnames -ftemplate-depth=5000 -ftime-trace -std=c++17
+// RUN: %cxx %flags %compile_flags -c %s -o %S/new.o -ggdb  -ggnu-pubnames -ftemplate-depth=5000 -ftime-trace -std=c++17 -DTEST_NEW
+
+#include 
+#include 
+
+#include "test_macros.h"
+#include "template_cost_testing.h"
+
+template  struct Arg { enum { value = 1 }; };
+
+#ifdef TEST_NEW
+
+template 
+struct new_remove_reference
+{
+  typedef __remove_reference(T) type;
+};
+
+#define TEST_CASE_NOP()  new_remove_reference< Arg< __COUNTER__ > >{},
+#define TEST_CASE_TYPE() typename new_remove_reference< Arg< __COUNTER__ > >::type,
+
+#else
+
+#define TEST_CASE_NOP()  std::remove_reference< Arg< __COUNTER__ > >{},
+#define TEST_CASE_TYPE() typename std::remove_reference< Arg< __COUNTER__ > >::type,
+
+#endif
+
+int sink(...);
+
+int x = sink(
+  REPEAT_1(TEST_CASE_NOP)
+  REPEAT_1(TEST_CASE_NOP) 42
+);
+
+void Foo( REPEAT_1(TEST_CASE_TYPE) int) { }
+
+void escape() {
+
+sink();
+sink();
+}
+
+
Index: libcxx/test/libcxx/utilities/meta/stress_tests/stress_test_add_rvalue_reference.sh.cpp
===
--- /dev/null
+++ libcxx/test/libcxx/utilities/meta/stress_tests/stress_test_add_rvalue_reference.sh.cpp
@@ -0,0 +1,63 @@
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This is a dummy feature that prevents this test from running by default.
+
+// The table below compares the compile time and object size for each of the
+// variants listed in the RUN script.
+//
+//  Impl   Compile Time  Object Size
+// --
+// new_add_rvalue_reference:   56.398 s  171 K
+// std::add_rvalue_reference:  114.59 s  271 K
+//
+// RUN: %cxx %flags %compile_flags -c %s -o %S/orig.o -ggdb  -ggnu-pubnames -ftemplate-depth=5000 -ftime-trace -std=c++17
+// RUN: %cxx %flags %compile_flags -c %s -o %S/new.o -ggdb  -ggnu-pubnames -ftemplate-depth=5000 -ftime-trace -std=c++17 -DTEST_NEW
+
+#include 
+#include 
+
+#include "test_macros.h"
+#include "template_cost_testing.h"
+
+template  struct Arg { enum { value = 1 }; };
+
+#ifdef TEST_NEW
+
+template 
+struct new_add_rvalue_reference
+{
+  typedef __add_rvalue_reference(T) type;
+};
+
+#define TEST_CASE_NOP()  new_add_rvalue_reference< Arg< __COUNTER__ > >{},
+#define TEST_CASE_TYPE() typename new_add_rvalue_reference< Arg< __COUNTER__ > >::type,
+
+#else
+
+#define TEST_CASE_NOP()  

[PATCH] D67052: Add reference type transformation builtins

2019-09-01 Thread Zoe Carver via Phabricator via cfe-commits
zoecarver marked an inline comment as done.
zoecarver added inline comments.



Comment at: 
libcxx/test/libcxx/utilities/meta/stress_tests/stress_test_remove_reference.sh.cpp:13
+// variants listed in the RUN script.
+//
+//  Impl   Compile Time  Object Size

I think there is a good chance the reason that my added builtin isn't 
significantly faster is that `std::remove_reference` is already optimized 
somewhere.  Thoughts?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67052



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


[PATCH] D67052: Add reference type transformation builtins

2019-09-01 Thread Zoe Carver via Phabricator via cfe-commits
zoecarver created this revision.
zoecarver added reviewers: EricWF, eli.friedman, rsmith, craig.topper.
Herald added subscribers: libcxx-commits, cfe-commits, jfb, christof.
Herald added projects: clang, libc++.

This patch adds builtin type traits to transform reference types. Specifically, 
it adds `__add_lvalue_reference`, `__add_rvalue_reference`, and 
`__remove_reference`. The first two builtins speed up builds by around 3x while 
the last builtin only sees small improvements (we may be able to optimize it 
more, though). Once added to the standard library, this should make libc++ (and 
other code) much faster to compile.

I tried to generalize as much of the builtin as possible so, the only 
functional difference between the three builtins is in the file 
`BuildUnaryTransformType`.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D67052

Files:
  clang/include/clang/AST/Type.h
  clang/include/clang/Basic/Specifiers.h
  clang/include/clang/Basic/TokenKinds.def
  clang/include/clang/Parse/Parser.h
  clang/include/clang/Sema/DeclSpec.h
  clang/lib/Format/FormatToken.cpp
  clang/lib/Lex/PPMacroExpansion.cpp
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/lib/Sema/DeclSpec.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaTemplateVariadic.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/SemaCXX/add_reference.cpp
  libcxx/test/libcxx/utilities/meta/stress_tests/lit.site.cfg
  
libcxx/test/libcxx/utilities/meta/stress_tests/stress_test_add_lvalue_reference.sh.cpp
  
libcxx/test/libcxx/utilities/meta/stress_tests/stress_test_add_rvalue_reference.sh.cpp
  
libcxx/test/libcxx/utilities/meta/stress_tests/stress_test_remove_reference.sh.cpp

Index: libcxx/test/libcxx/utilities/meta/stress_tests/stress_test_remove_reference.sh.cpp
===
--- /dev/null
+++ libcxx/test/libcxx/utilities/meta/stress_tests/stress_test_remove_reference.sh.cpp
@@ -0,0 +1,63 @@
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This is a dummy feature that prevents this test from running by default.
+
+// The table below compares the compile time and object size for each of the
+// variants listed in the RUN script.
+//
+//  Impl   Compile Time  Object Size
+// --
+// new_remove_reference:   22.849 s  121 K
+// std::remove_reference:  25.643 s  121 K
+//
+// RUN: %cxx %flags %compile_flags -c %s -o %S/orig.o -ggdb  -ggnu-pubnames -ftemplate-depth=5000 -ftime-trace -std=c++17
+// RUN: %cxx %flags %compile_flags -c %s -o %S/new.o -ggdb  -ggnu-pubnames -ftemplate-depth=5000 -ftime-trace -std=c++17 -DTEST_NEW
+
+#include 
+#include 
+
+#include "test_macros.h"
+#include "template_cost_testing.h"
+
+template  struct Arg { enum { value = 1 }; };
+
+#ifdef TEST_NEW
+
+template 
+struct new_remove_reference
+{
+  typedef __remove_reference(T) type;
+};
+
+#define TEST_CASE_NOP()  new_remove_reference< Arg< __COUNTER__ > >{},
+#define TEST_CASE_TYPE() typename new_remove_reference< Arg< __COUNTER__ > >::type,
+
+#else
+
+#define TEST_CASE_NOP()  std::remove_reference< Arg< __COUNTER__ > >{},
+#define TEST_CASE_TYPE() typename std::remove_reference< Arg< __COUNTER__ > >::type,
+
+#endif
+
+int sink(...);
+
+int x = sink(
+  REPEAT_1(TEST_CASE_NOP)
+  REPEAT_1(TEST_CASE_NOP) 42
+);
+
+void Foo( REPEAT_1(TEST_CASE_TYPE) int) { }
+
+void escape() {
+
+sink();
+sink();
+}
+
+
Index: libcxx/test/libcxx/utilities/meta/stress_tests/stress_test_add_rvalue_reference.sh.cpp
===
--- /dev/null
+++ libcxx/test/libcxx/utilities/meta/stress_tests/stress_test_add_rvalue_reference.sh.cpp
@@ -0,0 +1,63 @@
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This is a dummy feature that prevents this test from running by default.
+
+// The table below compares the compile time and object size for each of the
+// variants listed in the RUN script.
+//
+//  Impl   Compile Time  Object Size
+// --
+// new_add_rvalue_reference:   56.398 s  171 K
+// std::add_rvalue_reference:  114.59 s  271 K
+//
+// RUN: %cxx %flags %compile_flags -c %s -o 

[PATCH] D64672: [X86] Prevent passing vectors of __int128 as in llvm IR

2019-09-01 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

In D64672#1653847 , @RKSimon wrote:

> Please can you extend the test coverage to cover more vector sizes and cpu 
> target features, not just avx512, and also add x86_64-scei-ps4 triple tests. 
> Maybe 32-bit tests as well?


Other than 256-bit what other size do you want?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64672



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


[PATCH] D66866: [ASTImporter] At import of records re-order indirect fields too.

2019-09-01 Thread Aleksei Sidorin via Phabricator via cfe-commits
a_sidorin accepted this revision.
a_sidorin added a comment.

LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66866



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


[PATCH] D67023: Diagnose use of ATOMIC_VAR_INIT

2019-09-01 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D67023#1653425 , @jfb wrote:

> Is atomic initialization now correct in all modes (including C++) without 
> this macro?


My understanding is yes, but I am not an expert in atomics. However, the 
diagnostic is currently tied to C and hasn't been introduced for C++.

> I don’t think we should diagnose until such a time because some code uses to 
> macro to be portably correct.

I think that time is now, but more importantly, I think we should diagnose 
anything the standard deprecates because that code will not be portable for 
long and this is the way we indicate that to users. This is no different than 
any of our other deprecation diagnostics in that regard. Is there a reason to 
deviate with this specific macro?

> IIRC we only ended up fixing C++ in 20 with Nico’s paper (after Olivier and I 
> failed repeatedly to do so.

I don't believe this macro is (reasonably) implementable in C++ any more than 
it is in C, so I'm skeptical that *everything* was fixed with it. Do you know 
of implementations where this macro is required in order to properly handle 
initialization? Has SG1 had any discussions about deprecating it?


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

https://reviews.llvm.org/D67023



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


[PATCH] D66706: [Wdocumentation] fixes an assertion failure with typedefed function and block pointer

2019-09-01 Thread Mark de Wever via Phabricator via cfe-commits
Mordante updated this revision to Diff 218264.
Mordante marked an inline comment as done.
Mordante added a comment.

As discussed on IRC no longer allow `\return` on a `typedef`'ed type. This is 
consistent with `\param`.

- Reverts all prior changes in `lib/AST/Comment.cpp`
- Adds extra tests in `Sema::isFunctionOrBlockPointerVarLikeDecl`
- Updates unit tests


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

https://reviews.llvm.org/D66706

Files:
  clang/lib/AST/CommentSema.cpp
  clang/test/Sema/warn-documentation.cpp
  clang/test/Sema/warn-documentation.m


Index: clang/test/Sema/warn-documentation.m
===
--- clang/test/Sema/warn-documentation.m
+++ clang/test/Sema/warn-documentation.m
@@ -310,3 +310,11 @@
  * now should work too.
  */
 typedef void (^VariadicBlockType)(int a, ...);
+
+// PR42844 - Assertion failures when using typedefed block pointers
+typedef void(^VoidBlockType)();
+typedef VoidBlockType VoidBlockTypeCall();
+VoidBlockTypeCall *d; ///< \return none
+// expected-warning@-1 {{'\return' command used in a comment that is not 
attached to a function or method declaration}}
+VoidBlockTypeCall ^e; ///< \return none
+// expected-warning@-1 {{'\return' command used in a comment that is not 
attached to a function or method declaration}}
Index: clang/test/Sema/warn-documentation.cpp
===
--- clang/test/Sema/warn-documentation.cpp
+++ clang/test/Sema/warn-documentation.cpp
@@ -1360,3 +1360,24 @@
  */
 class EmptyNoteNoCrash {
 };
+
+namespace PR42844 { // Assertion failures when using typedefed function 
pointers
+typedef void (*AA)();
+typedef AA A();
+A *a; ///< \return none
+// expected-warning@-1 {{'\return' command used in a comment that is not 
attached to a function or method declaration}}
+
+typedef void B();
+B *b; ///< \return none
+// expected-warning@-1 {{'\return' command used in a comment that is not 
attached to a function or method declaration}}
+
+using CC = void(*)();
+using C = CC();
+C *c; ///< \return none
+// expected-warning@-1 {{'\return' command used in a comment that is not 
attached to a function or method declaration}}
+
+using D = void();
+D *d; ///< \return none
+// expected-warning@-1 {{'\return' command used in a comment that is not 
attached to a function or method declaration}}
+
+} // namespace PR42844
Index: clang/lib/AST/CommentSema.cpp
===
--- clang/lib/AST/CommentSema.cpp
+++ clang/lib/AST/CommentSema.cpp
@@ -588,6 +588,8 @@
   if (isObjCPropertyDecl())
 return;
   if (isFunctionDecl() || isFunctionOrBlockPointerVarLikeDecl()) {
+assert(!ThisDeclInfo->ReturnType.isNull() &&
+   "should have a valid return type");
 if (ThisDeclInfo->ReturnType->isVoidType()) {
   unsigned DiagKind;
   switch (ThisDeclInfo->CommentDecl->getKind()) {
@@ -873,6 +875,12 @@
   // can be ignored.
   if (QT->getAs())
 return false;
+  if (const auto *P = QT->getAs())
+if (P->getPointeeType()->getAs())
+  return false;
+  if (const auto *P = QT->getAs())
+if (P->getPointeeType()->getAs())
+  return false;
   return QT->isFunctionPointerType() || QT->isBlockPointerType();
 }
 


Index: clang/test/Sema/warn-documentation.m
===
--- clang/test/Sema/warn-documentation.m
+++ clang/test/Sema/warn-documentation.m
@@ -310,3 +310,11 @@
  * now should work too.
  */
 typedef void (^VariadicBlockType)(int a, ...);
+
+// PR42844 - Assertion failures when using typedefed block pointers
+typedef void(^VoidBlockType)();
+typedef VoidBlockType VoidBlockTypeCall();
+VoidBlockTypeCall *d; ///< \return none
+// expected-warning@-1 {{'\return' command used in a comment that is not attached to a function or method declaration}}
+VoidBlockTypeCall ^e; ///< \return none
+// expected-warning@-1 {{'\return' command used in a comment that is not attached to a function or method declaration}}
Index: clang/test/Sema/warn-documentation.cpp
===
--- clang/test/Sema/warn-documentation.cpp
+++ clang/test/Sema/warn-documentation.cpp
@@ -1360,3 +1360,24 @@
  */
 class EmptyNoteNoCrash {
 };
+
+namespace PR42844 { // Assertion failures when using typedefed function pointers
+typedef void (*AA)();
+typedef AA A();
+A *a; ///< \return none
+// expected-warning@-1 {{'\return' command used in a comment that is not attached to a function or method declaration}}
+
+typedef void B();
+B *b; ///< \return none
+// expected-warning@-1 {{'\return' command used in a comment that is not attached to a function or method declaration}}
+
+using CC = void(*)();
+using C = CC();
+C *c; ///< \return none
+// expected-warning@-1 {{'\return' command used in a comment that is not attached to a function or method declaration}}
+
+using D = void();
+D *d; ///< 

[PATCH] D67048: [AMDGPU] Set default flat work group size to (1, 256) for HIP

2019-09-01 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm accepted this revision.
arsenm added a comment.
This revision is now accepted and ready to land.

LGTM


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

https://reviews.llvm.org/D67048



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


[PATCH] D67048: [AMDGPU] Set default flat work group size to (1, 256) for HIP

2019-09-01 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 218261.
yaxunl added a comment.
Herald added a subscriber: jvesely.

add test


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

https://reviews.llvm.org/D67048

Files:
  lib/CodeGen/TargetInfo.cpp
  test/CodeGenCUDA/kernel-amdgcn.cu


Index: test/CodeGenCUDA/kernel-amdgcn.cu
===
--- test/CodeGenCUDA/kernel-amdgcn.cu
+++ test/CodeGenCUDA/kernel-amdgcn.cu
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple amdgcn -fcuda-is-device -emit-llvm %s -o - | 
FileCheck %s
+// RUN: %clang_cc1 -triple amdgcn -fcuda-is-device -emit-llvm -x hip %s -o - | 
FileCheck %s
 #include "Inputs/cuda.h"
 
 // CHECK: define amdgpu_kernel void @_ZN1A6kernelEv
@@ -25,7 +25,7 @@
   EmptyKernelPtr Empty() { return EmptyKernel; } 
 };
 
-// CHECK: define amdgpu_kernel void @_Z15template_kernelI1AEvT_
+// CHECK: define amdgpu_kernel void @_Z15template_kernelI1AEvT_{{.*}} 
#[[ATTR:[0-9][0-9]*]]
 template
 __global__ void template_kernel(T x) {}
 
@@ -39,3 +39,4 @@
   launch((void*)D.Empty());
   return 0;
 }
+// CHECK: attributes #[[ATTR]] = {{.*}}"amdgpu-flat-work-group-size"="1,256"
Index: lib/CodeGen/TargetInfo.cpp
===
--- lib/CodeGen/TargetInfo.cpp
+++ lib/CodeGen/TargetInfo.cpp
@@ -7922,8 +7922,9 @@
 
   const bool IsOpenCLKernel = M.getLangOpts().OpenCL &&
   FD->hasAttr();
-  if ((IsOpenCLKernel ||
-   (M.getLangOpts().HIP && FD->hasAttr())) &&
+  const bool IsHIPKernel = M.getLangOpts().HIP &&
+   FD->hasAttr();
+  if ((IsOpenCLKernel || IsHIPKernel) &&
   (M.getTriple().getOS() == llvm::Triple::AMDHSA))
 F->addFnAttr("amdgpu-implicitarg-num-bytes", "56");
 
@@ -7949,7 +7950,7 @@
   F->addFnAttr("amdgpu-flat-work-group-size", AttrVal);
 } else
   assert(Max == 0 && "Max must be zero");
-  } else if (IsOpenCLKernel) {
+  } else if (IsOpenCLKernel || IsHIPKernel) {
 // By default, restrict the maximum size to 256.
 F->addFnAttr("amdgpu-flat-work-group-size", "1,256");
   }


Index: test/CodeGenCUDA/kernel-amdgcn.cu
===
--- test/CodeGenCUDA/kernel-amdgcn.cu
+++ test/CodeGenCUDA/kernel-amdgcn.cu
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple amdgcn -fcuda-is-device -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -triple amdgcn -fcuda-is-device -emit-llvm -x hip %s -o - | FileCheck %s
 #include "Inputs/cuda.h"
 
 // CHECK: define amdgpu_kernel void @_ZN1A6kernelEv
@@ -25,7 +25,7 @@
   EmptyKernelPtr Empty() { return EmptyKernel; } 
 };
 
-// CHECK: define amdgpu_kernel void @_Z15template_kernelI1AEvT_
+// CHECK: define amdgpu_kernel void @_Z15template_kernelI1AEvT_{{.*}} #[[ATTR:[0-9][0-9]*]]
 template
 __global__ void template_kernel(T x) {}
 
@@ -39,3 +39,4 @@
   launch((void*)D.Empty());
   return 0;
 }
+// CHECK: attributes #[[ATTR]] = {{.*}}"amdgpu-flat-work-group-size"="1,256"
Index: lib/CodeGen/TargetInfo.cpp
===
--- lib/CodeGen/TargetInfo.cpp
+++ lib/CodeGen/TargetInfo.cpp
@@ -7922,8 +7922,9 @@
 
   const bool IsOpenCLKernel = M.getLangOpts().OpenCL &&
   FD->hasAttr();
-  if ((IsOpenCLKernel ||
-   (M.getLangOpts().HIP && FD->hasAttr())) &&
+  const bool IsHIPKernel = M.getLangOpts().HIP &&
+   FD->hasAttr();
+  if ((IsOpenCLKernel || IsHIPKernel) &&
   (M.getTriple().getOS() == llvm::Triple::AMDHSA))
 F->addFnAttr("amdgpu-implicitarg-num-bytes", "56");
 
@@ -7949,7 +7950,7 @@
   F->addFnAttr("amdgpu-flat-work-group-size", AttrVal);
 } else
   assert(Max == 0 && "Max must be zero");
-  } else if (IsOpenCLKernel) {
+  } else if (IsOpenCLKernel || IsHIPKernel) {
 // By default, restrict the maximum size to 256.
 F->addFnAttr("amdgpu-flat-work-group-size", "1,256");
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D67048: [AMDGPU] Set default flat work group size to (1, 256) for HIP

2019-09-01 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl created this revision.
yaxunl added reviewers: arsenm, rampitec, b-sumner.
Herald added subscribers: t-tye, tpr, dstuttard, wdng, kzhuravl.

https://reviews.llvm.org/D67048

Files:
  lib/CodeGen/TargetInfo.cpp


Index: lib/CodeGen/TargetInfo.cpp
===
--- lib/CodeGen/TargetInfo.cpp
+++ lib/CodeGen/TargetInfo.cpp
@@ -7922,8 +7922,9 @@
 
   const bool IsOpenCLKernel = M.getLangOpts().OpenCL &&
   FD->hasAttr();
-  if ((IsOpenCLKernel ||
-   (M.getLangOpts().HIP && FD->hasAttr())) &&
+  const bool IsHIPKernel = M.getLangOpts().HIP &&
+   FD->hasAttr();
+  if ((IsOpenCLKernel || IsHIPKernel) &&
   (M.getTriple().getOS() == llvm::Triple::AMDHSA))
 F->addFnAttr("amdgpu-implicitarg-num-bytes", "56");
 
@@ -7949,7 +7950,7 @@
   F->addFnAttr("amdgpu-flat-work-group-size", AttrVal);
 } else
   assert(Max == 0 && "Max must be zero");
-  } else if (IsOpenCLKernel) {
+  } else if (IsOpenCLKernel || IsHIPKernel) {
 // By default, restrict the maximum size to 256.
 F->addFnAttr("amdgpu-flat-work-group-size", "1,256");
   }


Index: lib/CodeGen/TargetInfo.cpp
===
--- lib/CodeGen/TargetInfo.cpp
+++ lib/CodeGen/TargetInfo.cpp
@@ -7922,8 +7922,9 @@
 
   const bool IsOpenCLKernel = M.getLangOpts().OpenCL &&
   FD->hasAttr();
-  if ((IsOpenCLKernel ||
-   (M.getLangOpts().HIP && FD->hasAttr())) &&
+  const bool IsHIPKernel = M.getLangOpts().HIP &&
+   FD->hasAttr();
+  if ((IsOpenCLKernel || IsHIPKernel) &&
   (M.getTriple().getOS() == llvm::Triple::AMDHSA))
 F->addFnAttr("amdgpu-implicitarg-num-bytes", "56");
 
@@ -7949,7 +7950,7 @@
   F->addFnAttr("amdgpu-flat-work-group-size", AttrVal);
 } else
   assert(Max == 0 && "Max must be zero");
-  } else if (IsOpenCLKernel) {
+  } else if (IsOpenCLKernel || IsHIPKernel) {
 // By default, restrict the maximum size to 256.
 F->addFnAttr("amdgpu-flat-work-group-size", "1,256");
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r370609 - Fix variable HasArrayDesignator set but not used warning. NFCI.

2019-09-01 Thread Simon Pilgrim via cfe-commits
Author: rksimon
Date: Sun Sep  1 06:10:08 2019
New Revision: 370609

URL: http://llvm.org/viewvc/llvm-project?rev=370609=rev
Log:
Fix variable HasArrayDesignator set but not used warning. NFCI.

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

Modified: cfe/trunk/lib/Sema/SemaInit.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaInit.cpp?rev=370609=370608=370609=diff
==
--- cfe/trunk/lib/Sema/SemaInit.cpp (original)
+++ cfe/trunk/lib/Sema/SemaInit.cpp Sun Sep  1 06:10:08 2019
@@ -3132,7 +3132,6 @@ ExprResult Sema::ActOnDesignatedInitiali
   bool Invalid = false;
   SmallVector Designators;
   SmallVector InitExpressions;
-  bool HasArrayDesignator = false;
 
   // Build designators and check array designator expressions.
   for (unsigned Idx = 0; Idx < Desig.getNumDesignators(); ++Idx) {
@@ -3156,7 +3155,6 @@ ExprResult Sema::ActOnDesignatedInitiali
 D.getRBracketLoc()));
 InitExpressions.push_back(Index);
   }
-  HasArrayDesignator = true;
   break;
 }
 
@@ -3200,7 +3198,6 @@ ExprResult Sema::ActOnDesignatedInitiali
   InitExpressions.push_back(EndIndex);
 }
   }
-  HasArrayDesignator = true;
   break;
 }
 }


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


[PATCH] D66397: [Diagnostics] Improve -Wxor-used-as-pow

2019-09-01 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 marked an inline comment as done.
xbolva00 added inline comments.



Comment at: lib/Sema/SemaExpr.cpp:11031-11032
   // Do not diagnose macros.
-  if (Loc.isMacroID())
+  if (Loc.isMacroID() || XorLHS.get()->getBeginLoc().isMacroID() ||
+  XorRHS.get()->getBeginLoc().isMacroID())
 return;

aaron.ballman wrote:
> I would appreciate it if this patch didn't also change the behavior for 
> macros. That seems like a larger discussion that can happen in a separate 
> patch.
+1, agree.


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

https://reviews.llvm.org/D66397



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


[PATCH] D66397: [Diagnostics] Improve -Wxor-used-as-pow

2019-09-01 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 updated this revision to Diff 218258.
xbolva00 added a comment.

Fixed review comments


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

https://reviews.llvm.org/D66397

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaExpr.cpp
  test/SemaCXX/warn-xor-as-pow.cpp

Index: test/SemaCXX/warn-xor-as-pow.cpp
===
--- test/SemaCXX/warn-xor-as-pow.cpp
+++ test/SemaCXX/warn-xor-as-pow.cpp
@@ -10,8 +10,10 @@
 #define XOR(x, y) (x ^ y)
 #define TWO 2
 #define TEN 10
+#define IOP 64
 #define TWO_ULL 2ULL
 #define EPSILON 10 ^ -300
+#define ALPHA_OFFSET 3
 
 #define flexor 7
 
@@ -21,7 +23,7 @@
 constexpr long long operator"" _0b(unsigned long long v) { return v; }
 constexpr long long operator"" _0X(unsigned long long v) { return v; }
 #else
-#define xor^ // iso646.h
+#define xor ^ // iso646.h
 #endif
 
 void test(unsigned a, unsigned b) {
@@ -32,25 +34,31 @@
   res = 2 ^ -1;
   res = 2 ^ 0; // expected-warning {{result of '2 ^ 0' is 2; did you mean '1 << 0' (1)?}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:9-[[@LINE-1]]:14}:"1"
-   // expected-note@-2 {{replace expression with '0x2 ^ 0' to silence this warning}}
+   // expected-note@-2 {{replace expression with '0x2 ^ 0' or use 'xor' instead of '^' to silence this warning}}
   res = 2 ^ 1; // expected-warning {{result of '2 ^ 1' is 3; did you mean '1 << 1' (2)?}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:9-[[@LINE-1]]:14}:"1 << 1"
-   // expected-note@-2 {{replace expression with '0x2 ^ 1' to silence this warning}}
+   // expected-note@-2 {{replace expression with '0x2 ^ 1' or use 'xor' instead of '^' to silence this warning}}
   res = 2 ^ 2; // expected-warning {{result of '2 ^ 2' is 0; did you mean '1 << 2' (4)?}}
   // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:9-[[@LINE-1]]:14}:"1 << 2"
-  // expected-note@-2 {{replace expression with '0x2 ^ 2' to silence this warning}}
+  // expected-note@-2 {{replace expression with '0x2 ^ 2' or use 'xor' instead of '^' to silence this warning}}
   res = 2 ^ 8; // expected-warning {{result of '2 ^ 8' is 10; did you mean '1 << 8' (256)?}}
   // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:9-[[@LINE-1]]:14}:"1 << 8"
-  // expected-note@-2 {{replace expression with '0x2 ^ 8' to silence this warning}}
+  // expected-note@-2 {{replace expression with '0x2 ^ 8' or use 'xor' instead of '^' to silence this warning}}
+  res = 2 ^ +8; // expected-warning {{result of '2 ^ +8' is 10; did you mean '1 << +8' (256)?}}
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:9-[[@LINE-1]]:15}:"1 << +8"
+  // expected-note@-2 {{replace expression with '0x2 ^ +8' or use 'xor' instead of '^' to silence this warning}}
   res = TWO ^ 8; // expected-warning {{result of 'TWO ^ 8' is 10; did you mean '1 << 8' (256)?}}
   // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:9-[[@LINE-1]]:16}:"1 << 8"
-  // expected-note@-2 {{replace expression with '0x2 ^ 8' to silence this warning}}
+  // expected-note@-2 {{replace expression with '0x2 ^ 8' or use 'xor' instead of '^' to silence this warning}}
   res = 2 ^ 16; // expected-warning {{result of '2 ^ 16' is 18; did you mean '1 << 16' (65536)?}}
   // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:9-[[@LINE-1]]:15}:"1 << 16"
-  // expected-note@-2 {{replace expression with '0x2 ^ 16' to silence this warning}}
+  // expected-note@-2 {{replace expression with '0x2 ^ 16' or use 'xor' instead of '^' to silence this warning}}
   res = 2 ^ TEN; // expected-warning {{result of '2 ^ TEN' is 8; did you mean '1 << TEN' (1024)?}}
   // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:9-[[@LINE-1]]:16}:"1 << TEN"
-  // expected-note@-2 {{replace expression with '0x2 ^ TEN' to silence this warning}}
+  // expected-note@-2 {{replace expression with '0x2 ^ TEN' or use 'xor' instead of '^' to silence this warning}}
+  res = res + (2 ^ ALPHA_OFFSET); // expected-warning {{result of '2 ^ ALPHA_OFFSET' is 1; did you mean '1 << ALPHA_OFFSET' (8)?}}
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:16-[[@LINE-1]]:32}:"1 << ALPHA_OFFSET"
+  // expected-note@-2 {{replace expression with '0x2 ^ ALPHA_OFFSET' or use 'xor' instead of '^' to silence this warning}}
   res = 0x2 ^ 16;
   res = 2 xor 16;
 
@@ -69,31 +77,56 @@
   res = TWO_ULL ^ 16;
   res = 2 ^ 32; // expected-warning {{result of '2 ^ 32' is 34; did you mean '1LL << 32'?}}
   // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:9-[[@LINE-1]]:15}:"1LL << 32"
-  // expected-note@-2 {{replace expression with '0x2 ^ 32' to silence this warning}}
-  res = 2 ^ 64;
+  // expected-note@-2 {{replace expression with '0x2 ^ 32' or use 'xor' instead of '^' to silence this warning}}
+  res = (2 ^ 64) - 1; // expected-warning {{result of '2 ^ 64' is 66; did you mean '~0ULL'?}}
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:9-[[@LINE-1]]:21}:"~0ULL"
+  // expected-note@-2 {{replace expression with '0x2 ^ 64' or use 'xor' instead of '^' to silence this warning}}
+#define ULLONG_MAX 

[PATCH] D65694: Properly instantiate a decltype in argument's default initializer

2019-09-01 Thread Mark de Wever via Phabricator via cfe-commits
Mordante updated this revision to Diff 218256.
Mordante added a comment.

Changed the approach to use `addInstantiatedParametersToScope` as suggested by 
@rsmith. Since the function was `static` in another file I made it a member of 
`LocalInstantiationScope` and adjusted all callers.

Minor changes:

- Unit test remove link to Bugzilla
- MutiLevelArgList -> Mu__l__tiLevelArgList


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

https://reviews.llvm.org/D65694

Files:
  clang/include/clang/Sema/Template.h
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaTemplateInstantiate.cpp
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/test/SemaTemplate/default-arguments-cxx0x.cpp

Index: clang/test/SemaTemplate/default-arguments-cxx0x.cpp
===
--- clang/test/SemaTemplate/default-arguments-cxx0x.cpp
+++ clang/test/SemaTemplate/default-arguments-cxx0x.cpp
@@ -114,3 +114,33 @@
 S _a{};
   };
 }
+
+// Failure to resolve the decltype part during instantiation caused an
+// assertion failure
+namespace PR28500 {
+namespace original {
+template 
+void bar(T t = [](decltype(t) i) { return 0; }(0)) {}
+void foo() {
+  bar();
+}
+} // namespace original
+
+namespace cast {
+template 
+void bar(T t = decltype(t)(0)) {}
+void foo() {
+  bar();
+  bar();
+}
+} // namespace cast
+
+namespace value {
+template 
+void bar(T t = decltype(t)()) {}
+void foo() {
+  bar();
+  bar();
+}
+} // namespace value
+} // namespace PR28500
Index: clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -3823,70 +3823,6 @@
   return NewTInfo;
 }
 
-/// Introduce the instantiated function parameters into the local
-/// instantiation scope, and set the parameter names to those used
-/// in the template.
-static bool addInstantiatedParametersToScope(Sema , FunctionDecl *Function,
- const FunctionDecl *PatternDecl,
- LocalInstantiationScope ,
-   const MultiLevelTemplateArgumentList ) {
-  unsigned FParamIdx = 0;
-  for (unsigned I = 0, N = PatternDecl->getNumParams(); I != N; ++I) {
-const ParmVarDecl *PatternParam = PatternDecl->getParamDecl(I);
-if (!PatternParam->isParameterPack()) {
-  // Simple case: not a parameter pack.
-  assert(FParamIdx < Function->getNumParams());
-  ParmVarDecl *FunctionParam = Function->getParamDecl(FParamIdx);
-  FunctionParam->setDeclName(PatternParam->getDeclName());
-  // If the parameter's type is not dependent, update it to match the type
-  // in the pattern. They can differ in top-level cv-qualifiers, and we want
-  // the pattern's type here. If the type is dependent, they can't differ,
-  // per core issue 1668. Substitute into the type from the pattern, in case
-  // it's instantiation-dependent.
-  // FIXME: Updating the type to work around this is at best fragile.
-  if (!PatternDecl->getType()->isDependentType()) {
-QualType T = S.SubstType(PatternParam->getType(), TemplateArgs,
- FunctionParam->getLocation(),
- FunctionParam->getDeclName());
-if (T.isNull())
-  return true;
-FunctionParam->setType(T);
-  }
-
-  Scope.InstantiatedLocal(PatternParam, FunctionParam);
-  ++FParamIdx;
-  continue;
-}
-
-// Expand the parameter pack.
-Scope.MakeInstantiatedLocalArgPack(PatternParam);
-Optional NumArgumentsInExpansion
-  = S.getNumArgumentsInExpansion(PatternParam->getType(), TemplateArgs);
-if (NumArgumentsInExpansion) {
-  QualType PatternType =
-  PatternParam->getType()->castAs()->getPattern();
-  for (unsigned Arg = 0; Arg < *NumArgumentsInExpansion; ++Arg) {
-ParmVarDecl *FunctionParam = Function->getParamDecl(FParamIdx);
-FunctionParam->setDeclName(PatternParam->getDeclName());
-if (!PatternDecl->getType()->isDependentType()) {
-  Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(S, Arg);
-  QualType T = S.SubstType(PatternType, TemplateArgs,
-   FunctionParam->getLocation(),
-   FunctionParam->getDeclName());
-  if (T.isNull())
-return true;
-  FunctionParam->setType(T);
-}
-
-Scope.InstantiatedLocalPackArg(PatternParam, FunctionParam);
-++FParamIdx;
-  }
-}
-  }
-
-  return false;
-}
-
 void Sema::InstantiateExceptionSpec(SourceLocation PointOfInstantiation,
 FunctionDecl *Decl) {
   const FunctionProtoType *Proto = Decl->getType()->castAs();
@@ -3918,8 +3854,7 @@
 getTemplateInstantiationArgs(Decl, nullptr, /*RelativeToPrimary*/true);
 

[PATCH] D64672: [X86] Prevent passing vectors of __int128 as in llvm IR

2019-09-01 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon added a comment.

Please can you extend the test coverage to cover more vector sizes and cpu 
target features, not just avx512, and also add x86_64-scei-ps4 triple tests. 
Maybe 32-bit tests as well?




Comment at: clang/include/clang/Basic/LangOptions.h:143
+/// (SVN r351319). This causes vectors of __int128 to be passed in memory
+/// instead of passing in multiple scalar registers.
+Ver9,

Add that this is just for Linux and NetBSD


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64672



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