[PATCH] D110017: [clang] Removes leak sanitizer support on FreeBSD since it is unsupported

2021-09-17 Thread David CARLIER via Phabricator via cfe-commits
devnexen created this revision.
devnexen added a reviewer: emaste.
devnexen requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D110017

Files:
  clang/lib/Driver/ToolChains/FreeBSD.cpp


Index: clang/lib/Driver/ToolChains/FreeBSD.cpp
===
--- clang/lib/Driver/ToolChains/FreeBSD.cpp
+++ clang/lib/Driver/ToolChains/FreeBSD.cpp
@@ -480,7 +480,6 @@
   Res |= SanitizerKind::PointerSubtract;
   Res |= SanitizerKind::Vptr;
   if (IsX86_64 || IsMIPS64) {
-Res |= SanitizerKind::Leak;
 Res |= SanitizerKind::Thread;
   }
   if (IsX86 || IsX86_64) {


Index: clang/lib/Driver/ToolChains/FreeBSD.cpp
===
--- clang/lib/Driver/ToolChains/FreeBSD.cpp
+++ clang/lib/Driver/ToolChains/FreeBSD.cpp
@@ -480,7 +480,6 @@
   Res |= SanitizerKind::PointerSubtract;
   Res |= SanitizerKind::Vptr;
   if (IsX86_64 || IsMIPS64) {
-Res |= SanitizerKind::Leak;
 Res |= SanitizerKind::Thread;
   }
   if (IsX86 || IsX86_64) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D103938: Diagnose -Wunused-value in constant evaluation context

2021-09-17 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added a comment.

Thanks for the review.




Comment at: clang/test/Sema/exprs.c:19
   if (0) {
-0 / (0 ? 1 : 0); // expected-warning {{expression result unused}}
   }

ychen wrote:
> aaron.ballman wrote:
> > Why did we lose this diagnostic (and the above comment about not changing 
> > the test)?
> Because the behavior change here is that only reachable code is diagnosed. I 
> should have kept the comment. 
I've put it back.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103938

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


[PATCH] D103938: Diagnose -Wunused-value in constant evaluation context

2021-09-17 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen updated this revision to Diff 373390.
ychen added a comment.

- Restore an useful comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103938

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaStmt.cpp
  clang/test/Analysis/dead-stores.c
  clang/test/CXX/basic/basic.link/p8.cpp
  clang/test/CXX/drs/dr14xx.cpp
  clang/test/CXX/drs/dr20xx.cpp
  clang/test/CXX/drs/dr7xx.cpp
  clang/test/CXX/temp/temp.constr/temp.constr.constr/partial-specializations.cpp
  clang/test/CodeCompletion/pragma-macro-token-caching.c
  clang/test/Frontend/fixed_point_crash.c
  clang/test/PCH/cxx-explicit-specifier.cpp
  clang/test/Parser/cxx-ambig-decl-expr.cpp
  clang/test/Parser/cxx0x-ambig.cpp
  clang/test/Parser/cxx1z-init-statement.cpp
  clang/test/Parser/objc-messaging-1.m
  clang/test/Parser/objc-try-catch-1.m
  clang/test/Parser/objcxx11-attributes.mm
  clang/test/Sema/const-eval.c
  clang/test/Sema/exprs.c
  clang/test/Sema/i-c-e.c
  clang/test/Sema/sizeless-1.c
  clang/test/Sema/switch-1.c
  clang/test/Sema/vla-2.c
  clang/test/Sema/warn-type-safety.c
  clang/test/Sema/warn-unused-value.c
  clang/test/SemaCXX/attr-annotate.cpp
  clang/test/SemaCXX/builtin-constant-p.cpp
  clang/test/SemaCXX/constant-expression-cxx2a.cpp
  clang/test/SemaCXX/constant-expression.cpp
  clang/test/SemaCXX/expression-traits.cpp
  clang/test/SemaCXX/matrix-type-operators.cpp
  clang/test/SemaCXX/overloaded-operator.cpp
  clang/test/SemaCXX/sizeless-1.cpp
  clang/test/SemaCXX/vector.cpp
  clang/test/SemaCXX/warn-comma-operator.cpp
  clang/test/SemaCXX/warn-unused-value.cpp
  clang/test/SemaTemplate/derived.cpp
  clang/test/SemaTemplate/lambda-capture-pack.cpp

Index: clang/test/SemaTemplate/lambda-capture-pack.cpp
===
--- clang/test/SemaTemplate/lambda-capture-pack.cpp
+++ clang/test/SemaTemplate/lambda-capture-pack.cpp
@@ -18,7 +18,7 @@
 namespace PR41576 {
   template  constexpr int f(Xs ...xs) {
 return [&](auto ...ys) { // expected-note {{instantiation}}
-  return ((xs + ys), ...); // expected-warning {{unused}}
+  return ((xs + ys), ...); // expected-warning {{left operand of comma operator has no effect}}
 }(1, 2);
   }
   static_assert(f(3, 4) == 6); // expected-note {{instantiation}}
Index: clang/test/SemaTemplate/derived.cpp
===
--- clang/test/SemaTemplate/derived.cpp
+++ clang/test/SemaTemplate/derived.cpp
@@ -49,6 +49,6 @@
 
   class A {
 TFP m_p;
-void Enable() { 0, A(); } // expected-warning {{unused}}
+void Enable() { 0, A(); } // expected-warning {{left operand of comma operator has no effect}}
   };
 }
Index: clang/test/SemaCXX/warn-unused-value.cpp
===
--- clang/test/SemaCXX/warn-unused-value.cpp
+++ clang/test/SemaCXX/warn-unused-value.cpp
@@ -1,6 +1,7 @@
 // RUN: %clang_cc1 -fsyntax-only -verify -Wunused-value %s
 // RUN: %clang_cc1 -fsyntax-only -verify -Wunused-value -std=c++98 %s
 // RUN: %clang_cc1 -fsyntax-only -verify -Wunused-value -std=c++11 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wunused-value -std=c++17 %s
 
 // PR4806
 namespace test0 {
@@ -138,3 +139,26 @@
   (void)arr3;
   (void)arr4;
 }
+
+#if __cplusplus >= 201103L // C++11 or later
+namespace test5 {
+int v[(5, 6)]; // expected-warning {{left operand of comma operator has no effect}}
+void foo() {
+  new double[false ? (1, 2) : 3]
+// FIXME: We shouldn't diagnose the unreachable constant expression
+// here.
+[false ? (1, 2) : 3]; // expected-warning {{left operand of comma operator has no effect}}
+}
+} // namespace test5
+#endif
+
+#if __cplusplus >= 201703L // C++11 or later
+namespace test6 {
+auto b() {
+  if constexpr (false)
+return (1,0);
+  else
+return (1.0,0.0); // expected-warning {{left operand of comma operator has no effect}}
+}
+} // namespace test6
+#endif
Index: clang/test/SemaCXX/warn-comma-operator.cpp
===
--- clang/test/SemaCXX/warn-comma-operator.cpp
+++ clang/test/SemaCXX/warn-comma-operator.cpp
@@ -242,8 +242,8 @@
 
 template 
 class Foo {
-  typedef bool_seq<(xs::value, true)...> all_true;
-  typedef bool_seq<(xs::value, false)...> all_false;
+  typedef bool_seq<((void)xs::value, true)...> all_true;
+  typedef bool_seq<((void)xs::value, false)...> all_false;
   typedef bool_seq seq;
 };
 
Index: clang/test/SemaCXX/vector.cpp
===
--- clang/test/SemaCXX/vector.cpp
+++ clang/test/SemaCXX/vector.cpp
@@ -381,8 +381,8 @@
 typedef int inte2 __attribute__((__ext_vector_type__(2)));
 
 void test_vector_literal(inte4 res) {
-  inte2 a = 

[PATCH] D103938: Diagnose -Wunused-value in constant evaluation context

2021-09-17 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added a comment.

In D103938#3006540 , @aaron.ballman 
wrote:

> There were a few behavioral changes to tests that I had questions about. 
> Also, can you add an additional test case that shows the behavior when the 
> left operand of the comma expression is volatile (or do we already have that 
> covered and I missed it)? e.g.,
>
>   int func() {
> volatile int *ip = (volatile int *)0xFEEDFACE;
> return (*ip, 1);
>   }
>
> (In this case, we shouldn't diagnose that the left operand has no effect 
> because reading a volatile variable is an operation with a side effect.)

It seems this is covered by svn157362.




Comment at: clang/test/CodeCompletion/pragma-macro-token-caching.c:15
 Outer(__extension__({ _Pragma(2) })); // expected-error {{_Pragma takes a 
parenthesized string literal}}
-param; // expected-warning {{expression result unused}}
 }

aaron.ballman wrote:
> Why did we lose this diagnostic?
CFG analysis thinks it is unreachable, so it is not diagnosed.



Comment at: clang/test/Sema/exprs.c:19
   if (0) {
-0 / (0 ? 1 : 0); // expected-warning {{expression result unused}}
   }

aaron.ballman wrote:
> Why did we lose this diagnostic (and the above comment about not changing the 
> test)?
Because the behavior change here is that only reachable code is diagnosed. I 
should have kept the comment. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103938

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


[PATCH] D91944: OpenMP 5.0 metadirective

2021-09-17 Thread Petr Hosek via Phabricator via cfe-commits
phosek added a comment.

We started seeing a test failure in `Clang :: 
OpenMP/metadirective_device_kind_codegen.c` on our macOS bot after this change 
landed (we aren't seeing it on other systems):

  Script:
  --
  : 'RUN: at line 1';   /opt/s/w/ir/x/w/staging/llvm_build/bin/clang -cc1 
-internal-isystem /opt/s/w/ir/x/w/staging/llvm_build/lib/clang/14.0.0/include 
-nostdsysteminc -verify -fopenmp -x c -std=c99 -emit-llvm 
/opt/s/w/ir/x/w/llvm-project/clang/test/OpenMP/metadirective_device_kind_codegen.c
 -o - | /opt/s/w/ir/x/w/staging/llvm_build/bin/FileCheck 
--allow-unused-prefixes 
/opt/s/w/ir/x/w/llvm-project/clang/test/OpenMP/metadirective_device_kind_codegen.c
  : 'RUN: at line 2';   /opt/s/w/ir/x/w/staging/llvm_build/bin/clang -cc1 
-internal-isystem /opt/s/w/ir/x/w/staging/llvm_build/lib/clang/14.0.0/include 
-nostdsysteminc -verify -fopenmp -x c -triple x86_64-unknown-linux -emit-llvm 
/opt/s/w/ir/x/w/llvm-project/clang/test/OpenMP/metadirective_device_kind_codegen.c
 -o - | /opt/s/w/ir/x/w/staging/llvm_build/bin/FileCheck 
--allow-unused-prefixes 
/opt/s/w/ir/x/w/llvm-project/clang/test/OpenMP/metadirective_device_kind_codegen.c
  : 'RUN: at line 3';   /opt/s/w/ir/x/w/staging/llvm_build/bin/clang -cc1 
-internal-isystem /opt/s/w/ir/x/w/staging/llvm_build/lib/clang/14.0.0/include 
-nostdsysteminc -verify -fopenmp -x c -triple aarch64-unknown-linux -emit-llvm 
/opt/s/w/ir/x/w/llvm-project/clang/test/OpenMP/metadirective_device_kind_codegen.c
 -o - | /opt/s/w/ir/x/w/staging/llvm_build/bin/FileCheck 
--allow-unused-prefixes 
/opt/s/w/ir/x/w/llvm-project/clang/test/OpenMP/metadirective_device_kind_codegen.c
  : 'RUN: at line 4';   /opt/s/w/ir/x/w/staging/llvm_build/bin/clang -cc1 
-internal-isystem /opt/s/w/ir/x/w/staging/llvm_build/lib/clang/14.0.0/include 
-nostdsysteminc -verify -fopenmp -x c -triple ppc64le-unknown-linux -emit-llvm 
/opt/s/w/ir/x/w/llvm-project/clang/test/OpenMP/metadirective_device_kind_codegen.c
 -o - | /opt/s/w/ir/x/w/staging/llvm_build/bin/FileCheck 
--allow-unused-prefixes 
/opt/s/w/ir/x/w/llvm-project/clang/test/OpenMP/metadirective_device_kind_codegen.c
  --
  Exit Code: 1
  
  Command Output (stderr):
  --
  
/opt/s/w/ir/x/w/llvm-project/clang/test/OpenMP/metadirective_device_kind_codegen.c:39:17:
 error: CHECK-LABEL: expected string not found in input
  // CHECK-LABEL: define {{.+}} void @foo()
  ^
  :1:1: note: scanning from here
  ; ModuleID = 
'/opt/s/w/ir/x/w/llvm-project/clang/test/OpenMP/metadirective_device_kind_codegen.c'
  ^
  :13:1: note: possible intended match here
  define void @foo() #0 {
  ^
  
  Input file: 
  Check file: 
/opt/s/w/ir/x/w/llvm-project/clang/test/OpenMP/metadirective_device_kind_codegen.c
  
  -dump-input=help explains the following input dump.
  
  Input was:
  <<
  1: ; ModuleID = 
'/opt/s/w/ir/x/w/llvm-project/clang/test/OpenMP/metadirective_device_kind_codegen.c'
 
  label:39'0 
X~
 error: no match found
  2: source_filename = 
"/opt/s/w/ir/x/w/llvm-project/clang/test/OpenMP/metadirective_device_kind_codegen.c"
 
  label:39'0 
~~~
  3: target datalayout = 
"e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" 
  label:39'0 
~
  4: target triple = "x86_64-apple-darwin19.6.0" 
  label:39'0 
  5:  
  label:39'0 ~
  6: %struct.ident_t = type { i32, i32, i32, i32, i8* } 
  label:39'0 ~~~
  7:  
  label:39'0 ~
  8: @0 = private unnamed_addr constant [23 x i8] 
c";unknown;unknown;0;0;;\00", align 1 
  label:39'0 
~~~
  9: @1 = private unnamed_addr constant %struct.ident_t { i32 0, 
i32 2, i32 0, i32 0, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @0, i32 
0, i32 0) }, align 8 
  label:39'0 

 10: @2 = private unnamed_addr constant %struct.ident_t { i32 0, 
i32 514, i32 0, i32 0, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @0, 
i32 0, i32 0) }, align 8 
  label:39'0 
~~
 11:  
  label:39'0 ~
 12: ; Function Attrs: noinline nounwind optnone 
  label:39'0 
 13: define void @foo() #0 { 
 

[PATCH] D109997: [OpenMP] Change debugging symbol to weak_odr linkage

2021-09-17 Thread Joseph Huber via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc30d7730ebde: [OpenMP] Change debugging symbol to weak_odr 
linkage (authored by jhuber6).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109997

Files:
  clang/test/OpenMP/target_debug_codegen.cpp
  llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp


Index: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
===
--- llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
+++ llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
@@ -249,11 +249,9 @@
   IntegerType *I32Ty = Type::getInt32Ty(M.getContext());
   auto *GV = new GlobalVariable(
   M, I32Ty,
-  /* isConstant = */ true, GlobalValue::PrivateLinkage,
+  /* isConstant = */ true, GlobalValue::WeakODRLinkage,
   ConstantInt::get(I32Ty, DebugKind), "__omp_rtl_debug_kind");
 
-  llvm::appendToUsed(M, {GV});
-
   return GV;
 }
 
Index: clang/test/OpenMP/target_debug_codegen.cpp
===
--- clang/test/OpenMP/target_debug_codegen.cpp
+++ clang/test/OpenMP/target_debug_codegen.cpp
@@ -1,4 +1,4 @@
-// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --check-globals --global-value-regex 
"(__omp_rtl_debug_kind|llvm\.used)"
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --check-globals --global-value-regex "__omp_rtl_debug_kind"
 // Test target codegen - host bc file has to be created first.
 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown 
-fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc
 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-unknown-unknown 
-fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-target-new-runtime 
-fopenmp-target-debug -fopenmp-is-device -fopenmp-host-ir-file-path 
%t-ppc-host.bc -o - | FileCheck %s --check-prefix=CHECK
@@ -10,14 +10,11 @@
 #define HEADER
 
 //.
-// CHECK: @__omp_rtl_debug_kind = private constant i32 1
-// CHECK: @llvm.used = appending global [1 x i8*] [i8* bitcast (i32* 
@__omp_rtl_debug_kind to i8*)], section "llvm.metadata"
+// CHECK: @__omp_rtl_debug_kind = weak_odr constant i32 1
 //.
-// CHECK-EQ: @__omp_rtl_debug_kind = private constant i32 111
-// CHECK-EQ: @llvm.used = appending global [1 x i8*] [i8* bitcast (i32* 
@__omp_rtl_debug_kind to i8*)], section "llvm.metadata"
+// CHECK-EQ: @__omp_rtl_debug_kind = weak_odr constant i32 111
 //.
-// CHECK-DEFAULT: @__omp_rtl_debug_kind = private constant i32 0
-// CHECK-DEFAULT: @llvm.used = appending global [1 x i8*] [i8* bitcast (i32* 
@__omp_rtl_debug_kind to i8*)], section "llvm.metadata"
+// CHECK-DEFAULT: @__omp_rtl_debug_kind = weak_odr constant i32 0
 //.
 void foo() {
 #pragma omp target


Index: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
===
--- llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
+++ llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
@@ -249,11 +249,9 @@
   IntegerType *I32Ty = Type::getInt32Ty(M.getContext());
   auto *GV = new GlobalVariable(
   M, I32Ty,
-  /* isConstant = */ true, GlobalValue::PrivateLinkage,
+  /* isConstant = */ true, GlobalValue::WeakODRLinkage,
   ConstantInt::get(I32Ty, DebugKind), "__omp_rtl_debug_kind");
 
-  llvm::appendToUsed(M, {GV});
-
   return GV;
 }
 
Index: clang/test/OpenMP/target_debug_codegen.cpp
===
--- clang/test/OpenMP/target_debug_codegen.cpp
+++ clang/test/OpenMP/target_debug_codegen.cpp
@@ -1,4 +1,4 @@
-// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --check-globals --global-value-regex "(__omp_rtl_debug_kind|llvm\.used)"
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --check-globals --global-value-regex "__omp_rtl_debug_kind"
 // Test target codegen - host bc file has to be created first.
 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc
 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-target-new-runtime -fopenmp-target-debug -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s --check-prefix=CHECK
@@ -10,14 +10,11 @@
 #define HEADER
 
 //.
-// CHECK: @__omp_rtl_debug_kind = private constant i32 1
-// CHECK: @llvm.used = appending global [1 x i8*] [i8* bitcast (i32* @__omp_rtl_debug_kind to i8*)], section "llvm.metadata"
+// CHECK: @__omp_rtl_debug_kind = weak_odr constant i32 1
 //.
-// CHECK-EQ: @__omp_rtl_debug_kind = private constant i32 111
-// CHECK-EQ: @llvm.used = appending global [1 x i8*] [i8* bitcast (i32* @__omp_rtl_debug_kind to i8*)], section 

[clang] c30d773 - [OpenMP] Change debugging symbol to weak_odr linkage

2021-09-17 Thread Joseph Huber via cfe-commits

Author: Joseph Huber
Date: 2021-09-17T21:25:24-04:00
New Revision: c30d7730ebde18d61b33ae1de9ded69dac6ea6be

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

LOG: [OpenMP] Change debugging symbol to weak_odr linkage

The new device runtime uses an internal variable to set debugging. This
variable was originally privately linked because every module will have
a copy of it. This caused problems with merging the device bitcode
library because it would get renamed and there was not a way to refer to
an external, private symbol. This changes the symbol to weak_odr so it
can be defined multiply, but will not be renamed.

Reviewed By: jdoerfert

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

Added: 


Modified: 
clang/test/OpenMP/target_debug_codegen.cpp
llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp

Removed: 




diff  --git a/clang/test/OpenMP/target_debug_codegen.cpp 
b/clang/test/OpenMP/target_debug_codegen.cpp
index aa9e1a618773..5932e12a4d5d 100644
--- a/clang/test/OpenMP/target_debug_codegen.cpp
+++ b/clang/test/OpenMP/target_debug_codegen.cpp
@@ -1,4 +1,4 @@
-// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --check-globals --global-value-regex 
"(__omp_rtl_debug_kind|llvm\.used)"
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --check-globals --global-value-regex "__omp_rtl_debug_kind"
 // Test target codegen - host bc file has to be created first.
 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown 
-fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc
 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-unknown-unknown 
-fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-target-new-runtime 
-fopenmp-target-debug -fopenmp-is-device -fopenmp-host-ir-file-path 
%t-ppc-host.bc -o - | FileCheck %s --check-prefix=CHECK
@@ -10,14 +10,11 @@
 #define HEADER
 
 //.
-// CHECK: @__omp_rtl_debug_kind = private constant i32 1
-// CHECK: @llvm.used = appending global [1 x i8*] [i8* bitcast (i32* 
@__omp_rtl_debug_kind to i8*)], section "llvm.metadata"
+// CHECK: @__omp_rtl_debug_kind = weak_odr constant i32 1
 //.
-// CHECK-EQ: @__omp_rtl_debug_kind = private constant i32 111
-// CHECK-EQ: @llvm.used = appending global [1 x i8*] [i8* bitcast (i32* 
@__omp_rtl_debug_kind to i8*)], section "llvm.metadata"
+// CHECK-EQ: @__omp_rtl_debug_kind = weak_odr constant i32 111
 //.
-// CHECK-DEFAULT: @__omp_rtl_debug_kind = private constant i32 0
-// CHECK-DEFAULT: @llvm.used = appending global [1 x i8*] [i8* bitcast (i32* 
@__omp_rtl_debug_kind to i8*)], section "llvm.metadata"
+// CHECK-DEFAULT: @__omp_rtl_debug_kind = weak_odr constant i32 0
 //.
 void foo() {
 #pragma omp target

diff  --git a/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp 
b/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
index fc4580eacacd..fdedea54a897 100644
--- a/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
+++ b/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
@@ -249,11 +249,9 @@ GlobalValue *OpenMPIRBuilder::createDebugKind(unsigned 
DebugKind) {
   IntegerType *I32Ty = Type::getInt32Ty(M.getContext());
   auto *GV = new GlobalVariable(
   M, I32Ty,
-  /* isConstant = */ true, GlobalValue::PrivateLinkage,
+  /* isConstant = */ true, GlobalValue::WeakODRLinkage,
   ConstantInt::get(I32Ty, DebugKind), "__omp_rtl_debug_kind");
 
-  llvm::appendToUsed(M, {GV});
-
   return GV;
 }
 



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


[PATCH] D109632: [clang] de-duplicate methods from AST files

2021-09-17 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai added a comment.

In D109632#3006520 , @rmaz wrote:

> The case we have is more like:
>
>   .m   -> A -> long list of partially shared deps -> Foundation
>-> B -> long list of partially shared deps -> Foundation
>-> C -> long list of partially shared deps -> Foundation
> * a few hundred
>
> So we have a file that imports a lot of modules, in the hundreds. Each of 
> those modules has multiple ObjC interfaces with `-(id)init NS_UNAVAILABLE` 
> and imports Foundation, UIKit and also a large number of libraries that are 
> shared across the top level imports. This will result in A.pcm, B.pcm and 
> C.pcm including hundreds or thousands of init decls that are the same, from 
> system frameworks or whatever modules are shared between the top level 
> imports.
>
> IIUC the code currently serializes the entire ObjCMethodList for a module for 
> every declared method, including the methods that are not part of that 
> module. When deserializing we don't descend into module dependencies as the 
> entire method list would already be deserialized, but that doesn't help for 
> modules that aren't directly dependent. Is this right? If so it seems another 
> approach could be to only serialize the methods declared in that module 
> itself, and during deserialization we would have to load the methods from all 
> dependent modules.

I have created a different test synthesizer 
synthesize-shared-framework-chain-test.py to reproduce the described framework 
layout. In `addMethodsToPool` added a set `seen` to count how many methods we 
can skip and we don't skip anything in the modules but there are a lot of 
duplicates in .m file compilation. Also I've noticed that the size of .pcm 
increases the longer chain of modules is reachable from the module (19K for 
Shared0.pcm vs 38K for Shared49.pcm). Haven't checked if it is because of 
ObjCMethodList or for another reason.

I don't remember for sure but I don't think there is a consistent policy about 
a module storing transitive data or only data it owns. I suspect we might be 
using both approaches and need to check each case separately.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109632

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


[PATCH] D109951: [clang-format] Constructor initializer lists format with pp directives

2021-09-17 Thread Josh Learn via Phabricator via cfe-commits
guitard0g updated this revision to Diff 373366.
guitard0g added a comment.

Fix failing tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109951

Files:
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/unittests/Format/FormatTest.cpp


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -19268,6 +19268,59 @@
Style);
 }
 
+TEST_F(FormatTest, ConstructorInitializersWithPreprocessorDirective) {
+  FormatStyle Style = getLLVMStyle();
+  Style.BreakConstructorInitializers = FormatStyle::BCIS_BeforeComma;
+  Style.ConstructorInitializerIndentWidth = 4;
+  verifyFormat("SomeClass::Constructor()\n"
+   ": a{a}\n"
+   ", b{b} {}",
+   Style);
+  verifyFormat("SomeClass::Constructor()\n"
+   ": a{a}\n"
+   "#if CONDITION\n"
+   ", b{b}\n"
+   "#endif\n"
+   "{\n}",
+   Style);
+  Style.ConstructorInitializerIndentWidth = 2;
+  verifyFormat("SomeClass::Constructor()\n"
+   "#if CONDITION\n"
+   "  : a{a}\n"
+   "#endif\n"
+   "  , b{b}\n"
+   "  , c{c} {\n}",
+   Style);
+  Style.ConstructorInitializerIndentWidth = 0;
+  verifyFormat("SomeClass::Constructor()\n"
+   ": a{a}\n"
+   "#ifdef CONDITION\n"
+   ", b{b}\n"
+   "#else\n"
+   ", c{c}\n"
+   "#endif\n"
+   ", d{d} {\n}",
+   Style);
+  Style.ConstructorInitializerIndentWidth = 4;
+  verifyFormat("SomeClass::Constructor()\n"
+   ": a{a}\n"
+   "#if WINDOWS\n"
+   "#if DEBUG\n"
+   ", b{0}\n"
+   "#else\n"
+   ", b{1}\n"
+   "#endif\n"
+   "#else\n"
+   "#if DEBUG\n"
+   ", b{2}\n"
+   "#else\n"
+   ", b{3}\n"
+   "#endif\n"
+   "#endif\n"
+   "{\n}",
+   Style);
+}
+
 TEST_F(FormatTest, Destructors) {
   verifyFormat("void F(int ) { i.~int(); }");
   verifyFormat("void F(int ) { i->~int(); }");
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -489,6 +489,17 @@
 if (Style.Language == FormatStyle::LK_Proto) {
   ProbablyBracedList = NextTok->isOneOf(tok::comma, tok::r_square);
 } else {
+  // Skip NextTok over preprocessor lines, otherwise we may not
+  // properly diagnose the block as a braced intializer
+  // if the comma separator appears after the pp directive.
+  while (NextTok->is(tok::hash)) {
+ScopedMacroState MacroState(*Line, Tokens, NextTok);
+do {
+  NextTok = Tokens->getNextToken();
+  ++ReadTokens;
+} while (NextTok->isNot(tok::eof));
+  }
+
   // Using OriginalColumn to distinguish between ObjC methods and
   // binary operators is a bit hacky.
   bool NextIsObjCMethod = NextTok->isOneOf(tok::plus, tok::minus) &&


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -19268,6 +19268,59 @@
Style);
 }
 
+TEST_F(FormatTest, ConstructorInitializersWithPreprocessorDirective) {
+  FormatStyle Style = getLLVMStyle();
+  Style.BreakConstructorInitializers = FormatStyle::BCIS_BeforeComma;
+  Style.ConstructorInitializerIndentWidth = 4;
+  verifyFormat("SomeClass::Constructor()\n"
+   ": a{a}\n"
+   ", b{b} {}",
+   Style);
+  verifyFormat("SomeClass::Constructor()\n"
+   ": a{a}\n"
+   "#if CONDITION\n"
+   ", b{b}\n"
+   "#endif\n"
+   "{\n}",
+   Style);
+  Style.ConstructorInitializerIndentWidth = 2;
+  verifyFormat("SomeClass::Constructor()\n"
+   "#if CONDITION\n"
+   "  : a{a}\n"
+   "#endif\n"
+   "  , b{b}\n"
+   "  , c{c} {\n}",
+   Style);
+  Style.ConstructorInitializerIndentWidth = 0;
+  verifyFormat("SomeClass::Constructor()\n"
+   ": a{a}\n"
+   "#ifdef CONDITION\n"
+   ", b{b}\n"
+   "#else\n"
+   ", c{c}\n"
+   "#endif\n"
+   ", d{d} {\n}",
+   Style);
+  Style.ConstructorInitializerIndentWidth = 4;
+  verifyFormat("SomeClass::Constructor()\n"
+ 

[PATCH] D109951: [clang-format] Constructor initializer lists format with pp directives

2021-09-17 Thread Josh Learn via Phabricator via cfe-commits
guitard0g added a comment.

When looking at test case suggestions, I happened upon another problem that 
occurs when handling preprocessor directives. The following code is properly 
formatted (following llvm style, with ColumnLimit=0):

  SomeClass::SomeClass()
: a{a},
  b{b} {}

However this code:

  Foo::Foo()
  : x{x},
  #if DEBUG
y{y},
  #endif
z{z} {}

Is transformed by clang-format (under the same style guidelines) into this:

  Foo::Foo()
  : x{x},
  #if DEBUG
y{y},
  #endif
z{z} {
  }

It seems there is some wonkiness with how it handles preprocessor statements 
here. I can address this in a another patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109951

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


[PATCH] D109951: [clang-format] Constructor initializer lists format with pp directives

2021-09-17 Thread Josh Learn via Phabricator via cfe-commits
guitard0g updated this revision to Diff 373351.
guitard0g added a comment.

Add test case suggestions from reviewers.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109951

Files:
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/unittests/Format/FormatTest.cpp


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -19268,6 +19268,59 @@
Style);
 }
 
+TEST_F(FormatTest, ConstructorInitializersWithPreprocessorDirective) {
+  FormatStyle Style = getLLVMStyle();
+  Style.BreakConstructorInitializers = FormatStyle::BCIS_BeforeComma;
+  Style.ConstructorInitializerIndentWidth = 4;
+  verifyFormat("SomeClass::Constructor()\n"
+   ": a{a}\n"
+   ", b{b} {}",
+   Style);
+  verifyFormat("SomeClass::Constructor()\n"
+   ": a{a}\n"
+   "#if CONDITION\n"
+   ", b{b}\n"
+   "#endif\n"
+   "{\n}",
+   Style);
+  Style.ConstructorInitializerIndentWidth = 2;
+  verifyFormat("SomeClass::Constructor()\n"
+   "#if CONDITION\n"
+   "  : a{a}\n"
+   "#endif\n"
+   "  , b{b}\n"
+   "  , c{c} {\n}",
+   Style);
+  Style.ConstructorInitializerIndentWidth = 0;
+  verifyFormat("SomeClass::Constructor()\n"
+   ": a{a}\n"
+   "#ifdef CONDITION\n"
+   ", b{b}\n"
+   "#else\n"
+   ", c{c}\n"
+   "#endif\n"
+   ", d{d} {\n}",
+   Style);
+  Style.ConstructorInitializerIndentWidth = 4;
+  verifyFormat("SomeClass::Constructor()\n"
+   ": a{a}\n"
+   "#if WINDOWS\n"
+   "#if DEBUG\n"
+   ", b{0}\n"
+   "#else\n"
+   ", b{1}\n"
+   "#endif\n"
+   "#else\n"
+   "#if DEBUG\n"
+   ", b{2}\n"
+   "#else\n"
+   ", b{3}\n"
+   "#endif\n"
+   "#endif\n"
+   "{\n}",
+   Style);
+}
+
 TEST_F(FormatTest, Destructors) {
   verifyFormat("void F(int ) { i.~int(); }");
   verifyFormat("void F(int ) { i->~int(); }");
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -489,6 +489,17 @@
 if (Style.Language == FormatStyle::LK_Proto) {
   ProbablyBracedList = NextTok->isOneOf(tok::comma, tok::r_square);
 } else {
+  // Skip NextTok over preprocessor lines, otherwise we may not
+  // properly diagnose the block as a braced intializer
+  // if the comma separator appears after the pp directive.
+  if (NextTok->is(tok::hash)) {
+ScopedMacroState MacroState(*Line, Tokens, NextTok);
+do {
+  NextTok = Tokens->getNextToken();
+  ++ReadTokens;
+} while (NextTok->isNot(tok::eof));
+  }
+
   // Using OriginalColumn to distinguish between ObjC methods and
   // binary operators is a bit hacky.
   bool NextIsObjCMethod = NextTok->isOneOf(tok::plus, tok::minus) &&


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -19268,6 +19268,59 @@
Style);
 }
 
+TEST_F(FormatTest, ConstructorInitializersWithPreprocessorDirective) {
+  FormatStyle Style = getLLVMStyle();
+  Style.BreakConstructorInitializers = FormatStyle::BCIS_BeforeComma;
+  Style.ConstructorInitializerIndentWidth = 4;
+  verifyFormat("SomeClass::Constructor()\n"
+   ": a{a}\n"
+   ", b{b} {}",
+   Style);
+  verifyFormat("SomeClass::Constructor()\n"
+   ": a{a}\n"
+   "#if CONDITION\n"
+   ", b{b}\n"
+   "#endif\n"
+   "{\n}",
+   Style);
+  Style.ConstructorInitializerIndentWidth = 2;
+  verifyFormat("SomeClass::Constructor()\n"
+   "#if CONDITION\n"
+   "  : a{a}\n"
+   "#endif\n"
+   "  , b{b}\n"
+   "  , c{c} {\n}",
+   Style);
+  Style.ConstructorInitializerIndentWidth = 0;
+  verifyFormat("SomeClass::Constructor()\n"
+   ": a{a}\n"
+   "#ifdef CONDITION\n"
+   ", b{b}\n"
+   "#else\n"
+   ", c{c}\n"
+   "#endif\n"
+   ", d{d} {\n}",
+   Style);
+  Style.ConstructorInitializerIndentWidth = 4;
+  

[PATCH] D109977: LLVM Driver Multicall tool

2021-09-17 Thread Chris Bieneman via Phabricator via cfe-commits
beanz added inline comments.



Comment at: llvm/tools/llvm-objcopy/llvm-objcopy.cpp:404
 
-int main(int argc, char **argv) {
+int llvm_objcopy_main(int argc, char **argv) {
   InitLLVM X(argc, argv);

aganea wrote:
> Shouldn't we say:
> ```
> int objcopy_main(int argc, char **argv) {
> ```
> here and the other places + all supporting code, if we want `llvm objcopy` 
> (without the dash) like @phosek suggests?
I had a different thought for that. I think we want the tools to respond to 
llvm-objcopy since we will want them to exist in parallel to binutils tools 
just like the current tools do today.

Many of the current tools also support symlink-redirection, to support that 
we'll need to have a multiplex where multiple tool names point to the same 
`main` function.

Handling that was my point (1) in the `main` commit message, and I intended to 
work on it in a follow-on commit.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109977

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


[PATCH] D109940: Apply proper source location to fallthrough switch cases

2021-09-17 Thread Adrian Prantl via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG843390c58ae6: Apply proper source location to fallthrough 
switch cases. (authored by aprantl).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Changed prior to commit:
  https://reviews.llvm.org/D109940?vs=373263=373344#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109940

Files:
  clang/lib/CodeGen/CGStmt.cpp
  clang/test/CodeGen/debug-info-switch-fallthrough.c


Index: clang/test/CodeGen/debug-info-switch-fallthrough.c
===
--- /dev/null
+++ clang/test/CodeGen/debug-info-switch-fallthrough.c
@@ -0,0 +1,17 @@
+// RUN:  %clang_cc1 -triple x86_64-apple-macosx11.0.0 
-debug-info-kind=standalone -emit-llvm %s -o - | FileCheck %s
+// CHECK: ], !dbg !{{[0-9]+}}
+// CHECK-EMPTY:
+// CHECK-NEXT: {{.+}}
+// CHECK-NEXT: br {{.+}}, !dbg !{{[0-9+]}}
+// CHECK-EMPTY:
+// CHECK-NEXT: {{.+}}
+// CHECK-NEXT: br {{.+}}, !dbg ![[LOC:[0-9]+]]
+void test(int num) {
+  switch (num) {
+  case 0:
+break;
+  case 10: // CHECK: ![[LOC]] = !DILocation(line: [[@LINE]], column:{{.+}}, 
scope: {{.+}})
+  default:
+break;
+  }
+}
Index: clang/lib/CodeGen/CGStmt.cpp
===
--- clang/lib/CodeGen/CGStmt.cpp
+++ clang/lib/CodeGen/CGStmt.cpp
@@ -1521,6 +1521,12 @@
 NextCase = dyn_cast(CurCase->getSubStmt());
   }
 
+  // Generate a stop point for debug info if the case statement is
+  // followed by a default statement. A fallthrough case before a
+  // default case gets its own branch target.
+  if (CurCase->getSubStmt()->getStmtClass() == Stmt::DefaultStmtClass)
+EmitStopPoint(CurCase);
+
   // Normal default recursion for non-cases.
   EmitStmt(CurCase->getSubStmt());
 }


Index: clang/test/CodeGen/debug-info-switch-fallthrough.c
===
--- /dev/null
+++ clang/test/CodeGen/debug-info-switch-fallthrough.c
@@ -0,0 +1,17 @@
+// RUN:  %clang_cc1 -triple x86_64-apple-macosx11.0.0 -debug-info-kind=standalone -emit-llvm %s -o - | FileCheck %s
+// CHECK: ], !dbg !{{[0-9]+}}
+// CHECK-EMPTY:
+// CHECK-NEXT: {{.+}}
+// CHECK-NEXT: br {{.+}}, !dbg !{{[0-9+]}}
+// CHECK-EMPTY:
+// CHECK-NEXT: {{.+}}
+// CHECK-NEXT: br {{.+}}, !dbg ![[LOC:[0-9]+]]
+void test(int num) {
+  switch (num) {
+  case 0:
+break;
+  case 10: // CHECK: ![[LOC]] = !DILocation(line: [[@LINE]], column:{{.+}}, scope: {{.+}})
+  default:
+break;
+  }
+}
Index: clang/lib/CodeGen/CGStmt.cpp
===
--- clang/lib/CodeGen/CGStmt.cpp
+++ clang/lib/CodeGen/CGStmt.cpp
@@ -1521,6 +1521,12 @@
 NextCase = dyn_cast(CurCase->getSubStmt());
   }
 
+  // Generate a stop point for debug info if the case statement is
+  // followed by a default statement. A fallthrough case before a
+  // default case gets its own branch target.
+  if (CurCase->getSubStmt()->getStmtClass() == Stmt::DefaultStmtClass)
+EmitStopPoint(CurCase);
+
   // Normal default recursion for non-cases.
   EmitStmt(CurCase->getSubStmt());
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 843390c - Apply proper source location to fallthrough switch cases.

2021-09-17 Thread Adrian Prantl via cfe-commits

Author: Adrian Prantl
Date: 2021-09-17T14:45:04-07:00
New Revision: 843390c58ae660fa356c534fdc8b19756f8d175c

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

LOG: Apply proper source location to fallthrough switch cases.

This fixes a bug in clang where, when clang sees a switch with a
fallthrough to a default like this:

static void funcA(void) {}
static void funcB(void) {}

int main(int argc, char **argv) {

switch (argc) {
case 0:
funcA();
break;
case 10:
default:
funcB();
break;
}
}

It does not add a proper debug location for that switch case, such as
case 10: above.

Patch by Shubham Rastogi!

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

Added: 
clang/test/CodeGen/debug-info-switch-fallthrough.c

Modified: 
clang/lib/CodeGen/CGStmt.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGStmt.cpp b/clang/lib/CodeGen/CGStmt.cpp
index 08a4a6751083..373179349fb0 100644
--- a/clang/lib/CodeGen/CGStmt.cpp
+++ b/clang/lib/CodeGen/CGStmt.cpp
@@ -1521,6 +1521,12 @@ void CodeGenFunction::EmitCaseStmt(const CaseStmt ,
 NextCase = dyn_cast(CurCase->getSubStmt());
   }
 
+  // Generate a stop point for debug info if the case statement is
+  // followed by a default statement. A fallthrough case before a
+  // default case gets its own branch target.
+  if (CurCase->getSubStmt()->getStmtClass() == Stmt::DefaultStmtClass)
+EmitStopPoint(CurCase);
+
   // Normal default recursion for non-cases.
   EmitStmt(CurCase->getSubStmt());
 }

diff  --git a/clang/test/CodeGen/debug-info-switch-fallthrough.c 
b/clang/test/CodeGen/debug-info-switch-fallthrough.c
new file mode 100644
index ..36ac371d8270
--- /dev/null
+++ b/clang/test/CodeGen/debug-info-switch-fallthrough.c
@@ -0,0 +1,17 @@
+// RUN:  %clang_cc1 -triple x86_64-apple-macosx11.0.0 
-debug-info-kind=standalone -emit-llvm %s -o - | FileCheck %s
+// CHECK: ], !dbg !{{[0-9]+}}
+// CHECK-EMPTY:
+// CHECK-NEXT: {{.+}}
+// CHECK-NEXT: br {{.+}}, !dbg !{{[0-9+]}}
+// CHECK-EMPTY:
+// CHECK-NEXT: {{.+}}
+// CHECK-NEXT: br {{.+}}, !dbg ![[LOC:[0-9]+]]
+void test(int num) {
+  switch (num) {
+  case 0:
+break;
+  case 10: // CHECK: ![[LOC]] = !DILocation(line: [[@LINE]], column:{{.+}}, 
scope: {{.+}})
+  default:
+break;
+  }
+}



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


[clang] 9ff848c - Revert "[OpenMP] Use irbuilder as default for masked and master construct"

2021-09-17 Thread via cfe-commits

Author: cchen
Date: 2021-09-17T16:44:09-05:00
New Revision: 9ff848c5cd88947714f3d9bf03a3adbb84066736

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

LOG: Revert "[OpenMP] Use irbuilder as default for masked and master construct"

This reverts commit 2908fc0d3f16f873b5019f1c62a24482c2b75e36.

Added: 


Modified: 
clang/lib/CodeGen/CGStmtOpenMP.cpp
clang/test/OpenMP/masked_codegen.cpp
clang/test/OpenMP/master_codegen.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGStmtOpenMP.cpp 
b/clang/lib/CodeGen/CGStmtOpenMP.cpp
index b36fb702af83..68ab1362a454 100644
--- a/clang/lib/CodeGen/CGStmtOpenMP.cpp
+++ b/clang/lib/CodeGen/CGStmtOpenMP.cpp
@@ -4034,56 +4034,82 @@ static void emitMaster(CodeGenFunction , const 
OMPExecutableDirective ) {
 }
 
 void CodeGenFunction::EmitOMPMasterDirective(const OMPMasterDirective ) {
-  llvm::OpenMPIRBuilder  = CGM.getOpenMPRuntime().getOMPBuilder();
-  using InsertPointTy = llvm::OpenMPIRBuilder::InsertPointTy;
+  if (CGM.getLangOpts().OpenMPIRBuilder) {
+llvm::OpenMPIRBuilder  = CGM.getOpenMPRuntime().getOMPBuilder();
+using InsertPointTy = llvm::OpenMPIRBuilder::InsertPointTy;
 
-  const Stmt *MasterRegionBodyStmt = S.getAssociatedStmt();
+const Stmt *MasterRegionBodyStmt = S.getAssociatedStmt();
 
-  auto FiniCB = [this](InsertPointTy IP) {
-OMPBuilderCBHelpers::FinalizeOMPRegion(*this, IP);
-  };
+auto FiniCB = [this](InsertPointTy IP) {
+  OMPBuilderCBHelpers::FinalizeOMPRegion(*this, IP);
+};
 
-  auto BodyGenCB = [MasterRegionBodyStmt, this](InsertPointTy AllocaIP,
-InsertPointTy CodeGenIP,
-llvm::BasicBlock ) {
-OMPBuilderCBHelpers::InlinedRegionBodyRAII IRB(*this, AllocaIP, FiniBB);
-OMPBuilderCBHelpers::EmitOMPRegionBody(*this, MasterRegionBodyStmt,
-   CodeGenIP, FiniBB);
-  };
+auto BodyGenCB = [MasterRegionBodyStmt, this](InsertPointTy AllocaIP,
+  InsertPointTy CodeGenIP,
+  llvm::BasicBlock ) {
+  OMPBuilderCBHelpers::InlinedRegionBodyRAII IRB(*this, AllocaIP, FiniBB);
+  OMPBuilderCBHelpers::EmitOMPRegionBody(*this, MasterRegionBodyStmt,
+ CodeGenIP, FiniBB);
+};
 
+LexicalScope Scope(*this, S.getSourceRange());
+EmitStopPoint();
+Builder.restoreIP(OMPBuilder.createMaster(Builder, BodyGenCB, FiniCB));
+
+return;
+  }
   LexicalScope Scope(*this, S.getSourceRange());
   EmitStopPoint();
-  Builder.restoreIP(OMPBuilder.createMaster(Builder, BodyGenCB, FiniCB));
+  emitMaster(*this, S);
 }
 
-void CodeGenFunction::EmitOMPMaskedDirective(const OMPMaskedDirective ) {
-  llvm::OpenMPIRBuilder  = CGM.getOpenMPRuntime().getOMPBuilder();
-  using InsertPointTy = llvm::OpenMPIRBuilder::InsertPointTy;
-
-  const Stmt *MaskedRegionBodyStmt = S.getAssociatedStmt();
-  const Expr *Filter = nullptr;
+static void emitMasked(CodeGenFunction , const OMPExecutableDirective ) {
+  auto & = [](CodeGenFunction , PrePostActionTy ) {
+Action.Enter(CGF);
+CGF.EmitStmt(S.getRawStmt());
+  };
+  Expr *Filter = nullptr;
   if (const auto *FilterClause = S.getSingleClause())
 Filter = FilterClause->getThreadID();
-  llvm::Value *FilterVal = Filter
-   ? EmitScalarExpr(Filter, CGM.Int32Ty)
-   : llvm::ConstantInt::get(CGM.Int32Ty, /*V=*/0);
+  CGF.CGM.getOpenMPRuntime().emitMaskedRegion(CGF, CodeGen, S.getBeginLoc(),
+  Filter);
+}
 
-  auto FiniCB = [this](InsertPointTy IP) {
-OMPBuilderCBHelpers::FinalizeOMPRegion(*this, IP);
-  };
+void CodeGenFunction::EmitOMPMaskedDirective(const OMPMaskedDirective ) {
+  if (CGM.getLangOpts().OpenMPIRBuilder) {
+llvm::OpenMPIRBuilder  = CGM.getOpenMPRuntime().getOMPBuilder();
+using InsertPointTy = llvm::OpenMPIRBuilder::InsertPointTy;
 
-  auto BodyGenCB = [MaskedRegionBodyStmt, this](InsertPointTy AllocaIP,
-InsertPointTy CodeGenIP,
-llvm::BasicBlock ) {
-OMPBuilderCBHelpers::InlinedRegionBodyRAII IRB(*this, AllocaIP, FiniBB);
-OMPBuilderCBHelpers::EmitOMPRegionBody(*this, MaskedRegionBodyStmt,
-   CodeGenIP, FiniBB);
-  };
+const Stmt *MaskedRegionBodyStmt = S.getAssociatedStmt();
+const Expr *Filter = nullptr;
+if (const auto *FilterClause = S.getSingleClause())
+  Filter = FilterClause->getThreadID();
+llvm::Value *FilterVal = Filter
+ ? 

[PATCH] D91944: OpenMP 5.0 metadirective

2021-09-17 Thread Chi Chun Chen via Phabricator via cfe-commits
cchen added a comment.

I reapplied the patch since I forgot to add author's name in the commit


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91944

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


[clang] 347f3c1 - OpenMP 5.0 metadirective

2021-09-17 Thread via cfe-commits

Author: alokmishra.besu
Date: 2021-09-17T16:30:06-05:00
New Revision: 347f3c186d3fd86628904450d2f4ee0ffd428150

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

LOG: OpenMP 5.0 metadirective

This patch supports OpenMP 5.0 metadirective features.
It is implemented keeping the OpenMP 5.1 features like dynamic user condition 
in mind.

A new function, getBestWhenMatchForContext, is defined in 
llvm/Frontend/OpenMP/OMPContext.h

Currently this function return the index of the when clause with the highest 
score from the ones applicable in the Context.
But this function is declared with an array which can be used in OpenMP 5.1 
implementation to select all the valid when clauses which can be resolved in 
runtime. Currently this array is set to null by default and its implementation 
is left for future.

Reviewed By: jdoerfert

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

Added: 
clang/test/OpenMP/metadirective_ast_print.c
clang/test/OpenMP/metadirective_device_kind_codegen.c
clang/test/OpenMP/metadirective_device_kind_codegen.cpp
clang/test/OpenMP/metadirective_empty.cpp
clang/test/OpenMP/metadirective_implementation_codegen.c
clang/test/OpenMP/metadirective_implementation_codegen.cpp
clang/test/OpenMP/metadirective_messages.cpp

Modified: 
clang/include/clang-c/Index.h
clang/include/clang/AST/RecursiveASTVisitor.h
clang/include/clang/AST/StmtOpenMP.h
clang/include/clang/Basic/DiagnosticParseKinds.td
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/include/clang/Basic/StmtNodes.td
clang/include/clang/Sema/Sema.h
clang/include/clang/Serialization/ASTBitCodes.h
clang/lib/AST/OpenMPClause.cpp
clang/lib/AST/StmtOpenMP.cpp
clang/lib/AST/StmtPrinter.cpp
clang/lib/AST/StmtProfile.cpp
clang/lib/Basic/OpenMPKinds.cpp
clang/lib/CodeGen/CGOpenMPRuntime.cpp
clang/lib/CodeGen/CGStmt.cpp
clang/lib/CodeGen/CGStmtOpenMP.cpp
clang/lib/CodeGen/CodeGenFunction.h
clang/lib/Parse/ParseOpenMP.cpp
clang/lib/Sema/SemaExceptionSpec.cpp
clang/lib/Sema/SemaOpenMP.cpp
clang/lib/Sema/TreeTransform.h
clang/lib/Serialization/ASTReaderStmt.cpp
clang/lib/Serialization/ASTWriterStmt.cpp
clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
clang/tools/libclang/CIndex.cpp
clang/tools/libclang/CXCursor.cpp
flang/lib/Semantics/check-omp-structure.cpp
llvm/include/llvm/Frontend/OpenMP/OMP.td

Removed: 




diff  --git a/clang/include/clang-c/Index.h b/clang/include/clang-c/Index.h
index 8afd4c9ff1d05..b49acf6b58543 100644
--- a/clang/include/clang-c/Index.h
+++ b/clang/include/clang-c/Index.h
@@ -2592,7 +2592,11 @@ enum CXCursorKind {
*/
   CXCursor_OMPUnrollDirective = 293,
 
-  CXCursor_LastStmt = CXCursor_OMPUnrollDirective,
+  /** OpenMP metadirective directive.
+   */
+  CXCursor_OMPMetaDirective = 294,
+
+  CXCursor_LastStmt = CXCursor_OMPMetaDirective,
 
   /**
* Cursor that represents the translation unit itself.

diff  --git a/clang/include/clang/AST/RecursiveASTVisitor.h 
b/clang/include/clang/AST/RecursiveASTVisitor.h
index 9bfa5b9c23260..9b261e8540dac 100644
--- a/clang/include/clang/AST/RecursiveASTVisitor.h
+++ b/clang/include/clang/AST/RecursiveASTVisitor.h
@@ -2842,6 +2842,9 @@ 
RecursiveASTVisitor::TraverseOMPLoopDirective(OMPLoopDirective *S) {
   return TraverseOMPExecutableDirective(S);
 }
 
+DEF_TRAVERSE_STMT(OMPMetaDirective,
+  { TRY_TO(TraverseOMPExecutableDirective(S)); })
+
 DEF_TRAVERSE_STMT(OMPParallelDirective,
   { TRY_TO(TraverseOMPExecutableDirective(S)); })
 

diff  --git a/clang/include/clang/AST/StmtOpenMP.h 
b/clang/include/clang/AST/StmtOpenMP.h
index cd5fa2b94c317..f028c3b323986 100644
--- a/clang/include/clang/AST/StmtOpenMP.h
+++ b/clang/include/clang/AST/StmtOpenMP.h
@@ -5379,6 +5379,44 @@ class OMPMaskedDirective final : public 
OMPExecutableDirective {
   }
 };
 
+/// This represents '#pragma omp metadirective' directive.
+///
+/// \code
+/// #pragma omp metadirective when(user={condition(N>10)}: parallel for)
+/// \endcode
+/// In this example directive '#pragma omp metadirective' has clauses 'when'
+/// with a dynamic user condition to check if a variable 'N > 10'
+///
+class OMPMetaDirective final : public OMPExecutableDirective {
+  friend class ASTStmtReader;
+  friend class OMPExecutableDirective;
+  Stmt *IfStmt;
+
+  OMPMetaDirective(SourceLocation StartLoc, SourceLocation EndLoc)
+  : OMPExecutableDirective(OMPMetaDirectiveClass,
+   llvm::omp::OMPD_metadirective, StartLoc,
+   EndLoc) {}
+  explicit OMPMetaDirective()
+  : OMPExecutableDirective(OMPMetaDirectiveClass,
+   

[clang] 7efb825 - Revert "OpenMP 5.0 metadirective"

2021-09-17 Thread via cfe-commits

Author: cchen
Date: 2021-09-17T16:14:16-05:00
New Revision: 7efb825382c0a8372597aaf75a319fa379573fd4

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

LOG: Revert "OpenMP 5.0 metadirective"

This reverts commit c7d7b98e5263472f05b2f3cb767b5d16e1349e9a.

Added: 


Modified: 
clang/include/clang-c/Index.h
clang/include/clang/AST/RecursiveASTVisitor.h
clang/include/clang/AST/StmtOpenMP.h
clang/include/clang/Basic/DiagnosticParseKinds.td
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/include/clang/Basic/StmtNodes.td
clang/include/clang/Sema/Sema.h
clang/include/clang/Serialization/ASTBitCodes.h
clang/lib/AST/OpenMPClause.cpp
clang/lib/AST/StmtOpenMP.cpp
clang/lib/AST/StmtPrinter.cpp
clang/lib/AST/StmtProfile.cpp
clang/lib/Basic/OpenMPKinds.cpp
clang/lib/CodeGen/CGOpenMPRuntime.cpp
clang/lib/CodeGen/CGStmt.cpp
clang/lib/CodeGen/CGStmtOpenMP.cpp
clang/lib/CodeGen/CodeGenFunction.h
clang/lib/Parse/ParseOpenMP.cpp
clang/lib/Sema/SemaExceptionSpec.cpp
clang/lib/Sema/SemaOpenMP.cpp
clang/lib/Sema/TreeTransform.h
clang/lib/Serialization/ASTReaderStmt.cpp
clang/lib/Serialization/ASTWriterStmt.cpp
clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
clang/tools/libclang/CIndex.cpp
clang/tools/libclang/CXCursor.cpp
flang/lib/Semantics/check-omp-structure.cpp
llvm/include/llvm/Frontend/OpenMP/OMP.td

Removed: 
clang/test/OpenMP/metadirective_ast_print.c
clang/test/OpenMP/metadirective_device_kind_codegen.c
clang/test/OpenMP/metadirective_device_kind_codegen.cpp
clang/test/OpenMP/metadirective_empty.cpp
clang/test/OpenMP/metadirective_implementation_codegen.c
clang/test/OpenMP/metadirective_implementation_codegen.cpp
clang/test/OpenMP/metadirective_messages.cpp



diff  --git a/clang/include/clang-c/Index.h b/clang/include/clang-c/Index.h
index b49acf6b58543..8afd4c9ff1d05 100644
--- a/clang/include/clang-c/Index.h
+++ b/clang/include/clang-c/Index.h
@@ -2592,11 +2592,7 @@ enum CXCursorKind {
*/
   CXCursor_OMPUnrollDirective = 293,
 
-  /** OpenMP metadirective directive.
-   */
-  CXCursor_OMPMetaDirective = 294,
-
-  CXCursor_LastStmt = CXCursor_OMPMetaDirective,
+  CXCursor_LastStmt = CXCursor_OMPUnrollDirective,
 
   /**
* Cursor that represents the translation unit itself.

diff  --git a/clang/include/clang/AST/RecursiveASTVisitor.h 
b/clang/include/clang/AST/RecursiveASTVisitor.h
index 9b261e8540dac..9bfa5b9c23260 100644
--- a/clang/include/clang/AST/RecursiveASTVisitor.h
+++ b/clang/include/clang/AST/RecursiveASTVisitor.h
@@ -2842,9 +2842,6 @@ 
RecursiveASTVisitor::TraverseOMPLoopDirective(OMPLoopDirective *S) {
   return TraverseOMPExecutableDirective(S);
 }
 
-DEF_TRAVERSE_STMT(OMPMetaDirective,
-  { TRY_TO(TraverseOMPExecutableDirective(S)); })
-
 DEF_TRAVERSE_STMT(OMPParallelDirective,
   { TRY_TO(TraverseOMPExecutableDirective(S)); })
 

diff  --git a/clang/include/clang/AST/StmtOpenMP.h 
b/clang/include/clang/AST/StmtOpenMP.h
index f028c3b323986..cd5fa2b94c317 100644
--- a/clang/include/clang/AST/StmtOpenMP.h
+++ b/clang/include/clang/AST/StmtOpenMP.h
@@ -5379,44 +5379,6 @@ class OMPMaskedDirective final : public 
OMPExecutableDirective {
   }
 };
 
-/// This represents '#pragma omp metadirective' directive.
-///
-/// \code
-/// #pragma omp metadirective when(user={condition(N>10)}: parallel for)
-/// \endcode
-/// In this example directive '#pragma omp metadirective' has clauses 'when'
-/// with a dynamic user condition to check if a variable 'N > 10'
-///
-class OMPMetaDirective final : public OMPExecutableDirective {
-  friend class ASTStmtReader;
-  friend class OMPExecutableDirective;
-  Stmt *IfStmt;
-
-  OMPMetaDirective(SourceLocation StartLoc, SourceLocation EndLoc)
-  : OMPExecutableDirective(OMPMetaDirectiveClass,
-   llvm::omp::OMPD_metadirective, StartLoc,
-   EndLoc) {}
-  explicit OMPMetaDirective()
-  : OMPExecutableDirective(OMPMetaDirectiveClass,
-   llvm::omp::OMPD_metadirective, SourceLocation(),
-   SourceLocation()) {}
-
-  void setIfStmt(Stmt *S) { IfStmt = S; }
-
-public:
-  static OMPMetaDirective *Create(const ASTContext , SourceLocation StartLoc,
-  SourceLocation EndLoc,
-  ArrayRef Clauses,
-  Stmt *AssociatedStmt, Stmt *IfStmt);
-  static OMPMetaDirective *CreateEmpty(const ASTContext , unsigned 
NumClauses,
-   EmptyShell);
-  Stmt *getIfStmt() const { return IfStmt; }
-
-  static bool classof(const Stmt *T) {
-return 

[PATCH] D109997: [OpenMP] Change debugging symbol to weak_odr linkage

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

LG, and yes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109997

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


[PATCH] D109997: [OpenMP] Change debugging symbol to weak_odr linkage

2021-09-17 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 added a comment.

In D109997#3007216 , @jdoerfert wrote:

> You checked that this works with the usage in the RT, right?

Worked when I tested it. Want me to make a patch for it off of this?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109997

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


[PATCH] D91944: OpenMP 5.0 metadirective

2021-09-17 Thread Chi Chun Chen via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc7d7b98e5263: OpenMP 5.0 metadirective (authored by cchen).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91944

Files:
  clang/include/clang-c/Index.h
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/AST/StmtOpenMP.h
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/StmtNodes.td
  clang/include/clang/Sema/Sema.h
  clang/include/clang/Serialization/ASTBitCodes.h
  clang/lib/AST/OpenMPClause.cpp
  clang/lib/AST/StmtOpenMP.cpp
  clang/lib/AST/StmtPrinter.cpp
  clang/lib/AST/StmtProfile.cpp
  clang/lib/Basic/OpenMPKinds.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CGStmt.cpp
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/Parse/ParseOpenMP.cpp
  clang/lib/Sema/SemaExceptionSpec.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReaderStmt.cpp
  clang/lib/Serialization/ASTWriterStmt.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
  clang/test/OpenMP/metadirective_ast_print.c
  clang/test/OpenMP/metadirective_device_kind_codegen.c
  clang/test/OpenMP/metadirective_device_kind_codegen.cpp
  clang/test/OpenMP/metadirective_empty.cpp
  clang/test/OpenMP/metadirective_implementation_codegen.c
  clang/test/OpenMP/metadirective_implementation_codegen.cpp
  clang/test/OpenMP/metadirective_messages.cpp
  clang/tools/libclang/CIndex.cpp
  clang/tools/libclang/CXCursor.cpp
  flang/lib/Semantics/check-omp-structure.cpp
  llvm/include/llvm/Frontend/OpenMP/OMP.td

Index: llvm/include/llvm/Frontend/OpenMP/OMP.td
===
--- llvm/include/llvm/Frontend/OpenMP/OMP.td
+++ llvm/include/llvm/Frontend/OpenMP/OMP.td
@@ -339,6 +339,7 @@
   let clangClass = "OMPFilterClause";
   let flangClass = "ScalarIntExpr";
 }
+def OMPC_When: Clause<"when"> {}
 
 //===--===//
 // Definition of OpenMP directives
@@ -1703,6 +1704,10 @@
 VersionedClause
   ];
 }
+def OMP_Metadirective : Directive<"metadirective"> {
+  let allowedClauses = [VersionedClause];
+  let allowedOnceClauses = [VersionedClause];
+}
 def OMP_Unknown : Directive<"unknown"> {
   let isDefault = true;
 }
Index: flang/lib/Semantics/check-omp-structure.cpp
===
--- flang/lib/Semantics/check-omp-structure.cpp
+++ flang/lib/Semantics/check-omp-structure.cpp
@@ -1391,6 +1391,7 @@
 CHECK_SIMPLE_CLAUSE(Novariants, OMPC_novariants)
 CHECK_SIMPLE_CLAUSE(Nocontext, OMPC_nocontext)
 CHECK_SIMPLE_CLAUSE(Filter, OMPC_filter)
+CHECK_SIMPLE_CLAUSE(When, OMPC_when)
 
 CHECK_REQ_SCALAR_INT_CLAUSE(Grainsize, OMPC_grainsize)
 CHECK_REQ_SCALAR_INT_CLAUSE(NumTasks, OMPC_num_tasks)
Index: clang/tools/libclang/CXCursor.cpp
===
--- clang/tools/libclang/CXCursor.cpp
+++ clang/tools/libclang/CXCursor.cpp
@@ -643,6 +643,9 @@
   case Stmt::OMPCanonicalLoopClass:
 K = CXCursor_OMPCanonicalLoop;
 break;
+  case Stmt::OMPMetaDirectiveClass:
+K = CXCursor_OMPMetaDirective;
+break;
   case Stmt::OMPParallelDirectiveClass:
 K = CXCursor_OMPParallelDirective;
 break;
Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -5582,6 +5582,8 @@
 return cxstring::createRef("ModuleImport");
   case CXCursor_OMPCanonicalLoop:
 return cxstring::createRef("OMPCanonicalLoop");
+  case CXCursor_OMPMetaDirective:
+return cxstring::createRef("OMPMetaDirective");
   case CXCursor_OMPParallelDirective:
 return cxstring::createRef("OMPParallelDirective");
   case CXCursor_OMPSimdDirective:
Index: clang/test/OpenMP/metadirective_messages.cpp
===
--- /dev/null
+++ clang/test/OpenMP/metadirective_messages.cpp
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -std=c++14 -emit-llvm %s
+
+void foo() {
+#pragma omp metadirective // expected-error {{expected expression}}
+  ;
+#pragma omp metadirective when() // expected-error {{expected valid context selector in when clause}} expected-error {{expected expression}} expected-warning {{expected identifier or string literal describing a context set; set skipped}} expected-note {{context set options are: 'construct' 'device' 'implementation' 'user'}} expected-note {{the ignored set spans until here}}
+  ;
+#pragma omp metadirective when(device{}) // expected-warning {{expected '=' after the context set name "device"; '=' assumed}} expected-warning {{expected identifier or string literal describing a context selector; 

[clang] c7d7b98 - OpenMP 5.0 metadirective

2021-09-17 Thread via cfe-commits

Author: cchen
Date: 2021-09-17T16:03:13-05:00
New Revision: c7d7b98e5263472f05b2f3cb767b5d16e1349e9a

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

LOG: OpenMP 5.0 metadirective

This patch supports OpenMP 5.0 metadirective features.
It is implemented keeping the OpenMP 5.1 features like dynamic user condition 
in mind.

A new function, getBestWhenMatchForContext, is defined in 
llvm/Frontend/OpenMP/OMPContext.h

Currently this function return the index of the when clause with the highest 
score from the ones applicable in the Context.
But this function is declared with an array which can be used in OpenMP 5.1 
implementation to select all the valid when clauses which can be resolved in 
runtime. Currently this array is set to null by default and its implementation 
is left for future.

Reviewed By: jdoerfert

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

Added: 
clang/test/OpenMP/metadirective_ast_print.c
clang/test/OpenMP/metadirective_device_kind_codegen.c
clang/test/OpenMP/metadirective_device_kind_codegen.cpp
clang/test/OpenMP/metadirective_empty.cpp
clang/test/OpenMP/metadirective_implementation_codegen.c
clang/test/OpenMP/metadirective_implementation_codegen.cpp
clang/test/OpenMP/metadirective_messages.cpp

Modified: 
clang/include/clang-c/Index.h
clang/include/clang/AST/RecursiveASTVisitor.h
clang/include/clang/AST/StmtOpenMP.h
clang/include/clang/Basic/DiagnosticParseKinds.td
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/include/clang/Basic/StmtNodes.td
clang/include/clang/Sema/Sema.h
clang/include/clang/Serialization/ASTBitCodes.h
clang/lib/AST/OpenMPClause.cpp
clang/lib/AST/StmtOpenMP.cpp
clang/lib/AST/StmtPrinter.cpp
clang/lib/AST/StmtProfile.cpp
clang/lib/Basic/OpenMPKinds.cpp
clang/lib/CodeGen/CGOpenMPRuntime.cpp
clang/lib/CodeGen/CGStmt.cpp
clang/lib/CodeGen/CGStmtOpenMP.cpp
clang/lib/CodeGen/CodeGenFunction.h
clang/lib/Parse/ParseOpenMP.cpp
clang/lib/Sema/SemaExceptionSpec.cpp
clang/lib/Sema/SemaOpenMP.cpp
clang/lib/Sema/TreeTransform.h
clang/lib/Serialization/ASTReaderStmt.cpp
clang/lib/Serialization/ASTWriterStmt.cpp
clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
clang/tools/libclang/CIndex.cpp
clang/tools/libclang/CXCursor.cpp
flang/lib/Semantics/check-omp-structure.cpp
llvm/include/llvm/Frontend/OpenMP/OMP.td

Removed: 




diff  --git a/clang/include/clang-c/Index.h b/clang/include/clang-c/Index.h
index 8afd4c9ff1d05..b49acf6b58543 100644
--- a/clang/include/clang-c/Index.h
+++ b/clang/include/clang-c/Index.h
@@ -2592,7 +2592,11 @@ enum CXCursorKind {
*/
   CXCursor_OMPUnrollDirective = 293,
 
-  CXCursor_LastStmt = CXCursor_OMPUnrollDirective,
+  /** OpenMP metadirective directive.
+   */
+  CXCursor_OMPMetaDirective = 294,
+
+  CXCursor_LastStmt = CXCursor_OMPMetaDirective,
 
   /**
* Cursor that represents the translation unit itself.

diff  --git a/clang/include/clang/AST/RecursiveASTVisitor.h 
b/clang/include/clang/AST/RecursiveASTVisitor.h
index 9bfa5b9c23260..9b261e8540dac 100644
--- a/clang/include/clang/AST/RecursiveASTVisitor.h
+++ b/clang/include/clang/AST/RecursiveASTVisitor.h
@@ -2842,6 +2842,9 @@ 
RecursiveASTVisitor::TraverseOMPLoopDirective(OMPLoopDirective *S) {
   return TraverseOMPExecutableDirective(S);
 }
 
+DEF_TRAVERSE_STMT(OMPMetaDirective,
+  { TRY_TO(TraverseOMPExecutableDirective(S)); })
+
 DEF_TRAVERSE_STMT(OMPParallelDirective,
   { TRY_TO(TraverseOMPExecutableDirective(S)); })
 

diff  --git a/clang/include/clang/AST/StmtOpenMP.h 
b/clang/include/clang/AST/StmtOpenMP.h
index cd5fa2b94c317..f028c3b323986 100644
--- a/clang/include/clang/AST/StmtOpenMP.h
+++ b/clang/include/clang/AST/StmtOpenMP.h
@@ -5379,6 +5379,44 @@ class OMPMaskedDirective final : public 
OMPExecutableDirective {
   }
 };
 
+/// This represents '#pragma omp metadirective' directive.
+///
+/// \code
+/// #pragma omp metadirective when(user={condition(N>10)}: parallel for)
+/// \endcode
+/// In this example directive '#pragma omp metadirective' has clauses 'when'
+/// with a dynamic user condition to check if a variable 'N > 10'
+///
+class OMPMetaDirective final : public OMPExecutableDirective {
+  friend class ASTStmtReader;
+  friend class OMPExecutableDirective;
+  Stmt *IfStmt;
+
+  OMPMetaDirective(SourceLocation StartLoc, SourceLocation EndLoc)
+  : OMPExecutableDirective(OMPMetaDirectiveClass,
+   llvm::omp::OMPD_metadirective, StartLoc,
+   EndLoc) {}
+  explicit OMPMetaDirective()
+  : OMPExecutableDirective(OMPMetaDirectiveClass,
+   llvm::omp::OMPD_metadirective, 

[PATCH] D100874: [OpenMP] Use irbuilder as default for masked and master construct

2021-09-17 Thread Chi Chun Chen 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 rG2908fc0d3f16: [OpenMP] Use irbuilder as default for masked 
and master construct (authored by cchen).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100874

Files:
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/test/OpenMP/masked_codegen.cpp
  clang/test/OpenMP/master_codegen.cpp

Index: clang/test/OpenMP/master_codegen.cpp
===
--- clang/test/OpenMP/master_codegen.cpp
+++ clang/test/OpenMP/master_codegen.cpp
@@ -1,10 +1,7 @@
-// RUN: %clang_cc1 -verify -fopenmp -x c++ -emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck %s --check-prefixes=ALL,NORMAL
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck %s
 // RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -emit-pch -o %t %s
-// RUN: %clang_cc1 -fopenmp -x c++ -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefixes=ALL,NORMAL
+// RUN: %clang_cc1 -fopenmp -x c++ -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s
 // RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -fopenmp -fexceptions -fcxx-exceptions -debug-info-kind=line-tables-only -x c++ -emit-llvm %s -o - | FileCheck %s --check-prefix=TERM_DEBUG
-// RUN: %clang_cc1 -verify -fopenmp -fopenmp-enable-irbuilder -x c++ -emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck %s --check-prefixes=ALL,IRBUILDER
-// RUN: %clang_cc1 -fopenmp -fopenmp-enable-irbuilder -x c++ -std=c++11 -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -emit-pch -o %t %s
-// RUN: %clang_cc1 -fopenmp -fopenmp-enable-irbuilder -x c++ -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefixes=ALL,IRBUILDER
 
 // RUN: %clang_cc1 -verify -fopenmp-simd -x c++ -emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck --check-prefix SIMD-ONLY0 %s
 // RUN: %clang_cc1 -fopenmp-simd -x c++ -std=c++11 -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -emit-pch -o %t %s
@@ -15,53 +12,52 @@
 #ifndef HEADER
 #define HEADER
 
-// ALL:   [[IDENT_T_TY:%.+]] = type { i32, i32, i32, i32, i8* }
+// CHECK:   [[IDENT_T_TY:%.+]] = type { i32, i32, i32, i32, i8* }
 
-// ALL:   define {{.*}}void [[FOO:@.+]]()
+// CHECK:   define {{.*}}void [[FOO:@.+]]()
 
 void foo() { extern void mayThrow(); mayThrow(); }
 
-// ALL-LABEL: @main
+// CHECK-LABEL: @main
 // TERM_DEBUG-LABEL: @main
 int main() {
-  // ALL:  			[[A_ADDR:%.+]] = alloca i8
+  // CHECK:  			[[A_ADDR:%.+]] = alloca i8
   char a;
 
-// ALL:   			[[GTID:%.+]] = call {{.*}}i32 @__kmpc_global_thread_num([[IDENT_T_TY]]* [[DEFAULT_LOC:@.+]])
-// ALL:   			[[RES:%.+]] = call {{.*}}i32 @__kmpc_master([[IDENT_T_TY]]* [[DEFAULT_LOC]], i32 [[GTID]])
-// ALL-NEXT:  			[[IS_MASTER:%.+]] = icmp ne i32 [[RES]], 0
-// ALL-NEXT:  			br i1 [[IS_MASTER]], label {{%?}}[[THEN:.+]], label {{%?}}[[EXIT:.+]]
-// ALL:   			[[THEN]]
-// ALL-NEXT:  			store i8 2, i8* [[A_ADDR]]
-// ALL-NEXT:  			call {{.*}}void @__kmpc_end_master([[IDENT_T_TY]]* [[DEFAULT_LOC]], i32 [[GTID]])
-// ALL-NEXT:  			br label {{%?}}[[EXIT]]
-// ALL:   			[[EXIT]]
+// CHECK:   			[[GTID:%.+]] = call {{.*}}i32 @__kmpc_global_thread_num([[IDENT_T_TY]]* [[DEFAULT_LOC:@.+]])
+// CHECK:   			[[RES:%.+]] = call {{.*}}i32 @__kmpc_master([[IDENT_T_TY]]* [[DEFAULT_LOC]], i32 [[GTID]])
+// CHECK-NEXT:  			[[IS_MASTER:%.+]] = icmp ne i32 [[RES]], 0
+// CHECK-NEXT:  			br i1 [[IS_MASTER]], label {{%?}}[[THEN:.+]], label {{%?}}[[EXIT:.+]]
+// CHECK:   			[[THEN]]
+// CHECK-NEXT:  			store i8 2, i8* [[A_ADDR]]
+// CHECK-NEXT:  			call {{.*}}void @__kmpc_end_master([[IDENT_T_TY]]* [[DEFAULT_LOC]], i32 [[GTID]])
+// CHECK-NEXT:  			br label {{%?}}[[EXIT]]
+// CHECK:   			[[EXIT]]
 #pragma omp master
   a = 2;
-// IRBUILDER: 			[[GTID:%.+]] = call {{.*}}i32 @__kmpc_global_thread_num([[IDENT_T_TY]]* [[DEFAULT_LOC:@.+]])
-// ALL:   			[[RES:%.+]] = call {{.*}}i32 @__kmpc_master([[IDENT_T_TY]]* [[DEFAULT_LOC]], i32 [[GTID]])
-// ALL-NEXT:  			[[IS_MASTER:%.+]] = icmp ne i32 [[RES]], 0
-// ALL-NEXT:  			br i1 [[IS_MASTER]], label {{%?}}[[THEN:.+]], label {{%?}}[[EXIT:.+]]
-// ALL:   			[[THEN]]
-// IRBUILDER-NEXT:  call {{.*}}void [[FOO]]()
-// NORMAL-NEXT:  		invoke {{.*}}void [[FOO]]()
-// ALL:   			call {{.*}}void @__kmpc_end_master([[IDENT_T_TY]]* [[DEFAULT_LOC]], i32 [[GTID]])
-// ALL-NEXT:  			br label {{%?}}[[EXIT]]
-// ALL:   			[[EXIT]]
+// CHECK: 			[[GTID:%.+]] = call {{.*}}i32 

[clang] 2908fc0 - [OpenMP] Use irbuilder as default for masked and master construct

2021-09-17 Thread via cfe-commits

Author: cchen
Date: 2021-09-17T15:54:11-05:00
New Revision: 2908fc0d3f16f873b5019f1c62a24482c2b75e36

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

LOG: [OpenMP] Use irbuilder as default for masked and master construct

Use irbuilder as default and remove redundant Clang codegen for masked 
construct and master construct.

Reviewed By: jdoerfert

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

Added: 


Modified: 
clang/lib/CodeGen/CGStmtOpenMP.cpp
clang/test/OpenMP/masked_codegen.cpp
clang/test/OpenMP/master_codegen.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGStmtOpenMP.cpp 
b/clang/lib/CodeGen/CGStmtOpenMP.cpp
index 55c4822387d0e..fa198335f2c84 100644
--- a/clang/lib/CodeGen/CGStmtOpenMP.cpp
+++ b/clang/lib/CodeGen/CGStmtOpenMP.cpp
@@ -4030,82 +4030,56 @@ static void emitMaster(CodeGenFunction , const 
OMPExecutableDirective ) {
 }
 
 void CodeGenFunction::EmitOMPMasterDirective(const OMPMasterDirective ) {
-  if (CGM.getLangOpts().OpenMPIRBuilder) {
-llvm::OpenMPIRBuilder  = CGM.getOpenMPRuntime().getOMPBuilder();
-using InsertPointTy = llvm::OpenMPIRBuilder::InsertPointTy;
-
-const Stmt *MasterRegionBodyStmt = S.getAssociatedStmt();
+  llvm::OpenMPIRBuilder  = CGM.getOpenMPRuntime().getOMPBuilder();
+  using InsertPointTy = llvm::OpenMPIRBuilder::InsertPointTy;
 
-auto FiniCB = [this](InsertPointTy IP) {
-  OMPBuilderCBHelpers::FinalizeOMPRegion(*this, IP);
-};
+  const Stmt *MasterRegionBodyStmt = S.getAssociatedStmt();
 
-auto BodyGenCB = [MasterRegionBodyStmt, this](InsertPointTy AllocaIP,
-  InsertPointTy CodeGenIP,
-  llvm::BasicBlock ) {
-  OMPBuilderCBHelpers::InlinedRegionBodyRAII IRB(*this, AllocaIP, FiniBB);
-  OMPBuilderCBHelpers::EmitOMPRegionBody(*this, MasterRegionBodyStmt,
- CodeGenIP, FiniBB);
-};
+  auto FiniCB = [this](InsertPointTy IP) {
+OMPBuilderCBHelpers::FinalizeOMPRegion(*this, IP);
+  };
 
-LexicalScope Scope(*this, S.getSourceRange());
-EmitStopPoint();
-Builder.restoreIP(OMPBuilder.createMaster(Builder, BodyGenCB, FiniCB));
+  auto BodyGenCB = [MasterRegionBodyStmt, this](InsertPointTy AllocaIP,
+InsertPointTy CodeGenIP,
+llvm::BasicBlock ) {
+OMPBuilderCBHelpers::InlinedRegionBodyRAII IRB(*this, AllocaIP, FiniBB);
+OMPBuilderCBHelpers::EmitOMPRegionBody(*this, MasterRegionBodyStmt,
+   CodeGenIP, FiniBB);
+  };
 
-return;
-  }
   LexicalScope Scope(*this, S.getSourceRange());
   EmitStopPoint();
-  emitMaster(*this, S);
-}
-
-static void emitMasked(CodeGenFunction , const OMPExecutableDirective ) {
-  auto & = [](CodeGenFunction , PrePostActionTy ) {
-Action.Enter(CGF);
-CGF.EmitStmt(S.getRawStmt());
-  };
-  Expr *Filter = nullptr;
-  if (const auto *FilterClause = S.getSingleClause())
-Filter = FilterClause->getThreadID();
-  CGF.CGM.getOpenMPRuntime().emitMaskedRegion(CGF, CodeGen, S.getBeginLoc(),
-  Filter);
+  Builder.restoreIP(OMPBuilder.createMaster(Builder, BodyGenCB, FiniCB));
 }
 
 void CodeGenFunction::EmitOMPMaskedDirective(const OMPMaskedDirective ) {
-  if (CGM.getLangOpts().OpenMPIRBuilder) {
-llvm::OpenMPIRBuilder  = CGM.getOpenMPRuntime().getOMPBuilder();
-using InsertPointTy = llvm::OpenMPIRBuilder::InsertPointTy;
-
-const Stmt *MaskedRegionBodyStmt = S.getAssociatedStmt();
-const Expr *Filter = nullptr;
-if (const auto *FilterClause = S.getSingleClause())
-  Filter = FilterClause->getThreadID();
-llvm::Value *FilterVal = Filter
- ? EmitScalarExpr(Filter, CGM.Int32Ty)
- : llvm::ConstantInt::get(CGM.Int32Ty, 
/*V=*/0);
+  llvm::OpenMPIRBuilder  = CGM.getOpenMPRuntime().getOMPBuilder();
+  using InsertPointTy = llvm::OpenMPIRBuilder::InsertPointTy;
 
-auto FiniCB = [this](InsertPointTy IP) {
-  OMPBuilderCBHelpers::FinalizeOMPRegion(*this, IP);
-};
+  const Stmt *MaskedRegionBodyStmt = S.getAssociatedStmt();
+  const Expr *Filter = nullptr;
+  if (const auto *FilterClause = S.getSingleClause())
+Filter = FilterClause->getThreadID();
+  llvm::Value *FilterVal = Filter
+   ? EmitScalarExpr(Filter, CGM.Int32Ty)
+   : llvm::ConstantInt::get(CGM.Int32Ty, /*V=*/0);
 
-auto BodyGenCB = [MaskedRegionBodyStmt, this](InsertPointTy AllocaIP,
-  InsertPointTy CodeGenIP,
- 

[PATCH] D109997: [OpenMP] Change debugging symbol to weak_odr linkage

2021-09-17 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

You checked that this works with the usage in the RT, right?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109997

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


[PATCH] D109800: [clang] don't mark as Elidable CXXConstruct expressions used in NRVO

2021-09-17 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov updated this revision to Diff 373323.
mizvekov edited the summary of this revision.
mizvekov added a comment.

add a couple more FIXMEs and a couple of asserts in the constexpr path for 
rvalue copy elision.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109800

Files:
  clang/include/clang/Sema/Initialization.h
  clang/lib/AST/ExprConstant.cpp
  clang/lib/CodeGen/CGExprCXX.cpp
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaCoroutine.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaLambda.cpp
  clang/lib/Sema/SemaObjCProperty.cpp
  clang/lib/Sema/SemaStmt.cpp
  clang/test/CodeGen/nrvo-tracking.cpp
  clang/test/CodeGenCXX/copy-elision.cpp

Index: clang/test/CodeGenCXX/copy-elision.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/copy-elision.cpp
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown-gnu -emit-llvm -O1 -fexperimental-new-pass-manager -o - %s | FileCheck %s
+
+template  T test() {
+  return T();
+}
+
+struct A {
+  A();
+  A(A &);
+  A(int);
+  operator int();
+};
+
+// FIXME: There should be copy elision here.
+// CHECK-LABEL: define{{.*}} void @_Z4testI1AET_v
+// CHECK:   call void @_ZN1AC1Ev
+// CHECK-NEXT:  call i32 @_ZN1AcviEv
+// CHECK-NEXT:  call void @_ZN1AC1Ei
+// CHECK-NEXT:  call void @llvm.lifetime.end
+template A test();
+
+struct BSub {};
+struct B : BSub {
+  B();
+  B(B &);
+  B(const BSub &);
+};
+
+// FIXME: There should be copy elision here.
+// CHECK-LABEL: define{{.*}} void @_Z4testI1BET_v
+// CHECK:   call void @_ZN1BC1Ev
+// CHECK:   call void @_ZN1BC1ERK4BSub
+// CHECK-NEXT:  call void @llvm.lifetime.end
+template B test();
Index: clang/test/CodeGen/nrvo-tracking.cpp
===
--- clang/test/CodeGen/nrvo-tracking.cpp
+++ clang/test/CodeGen/nrvo-tracking.cpp
@@ -282,3 +282,40 @@
 }
 
 } // namespace test_alignas
+
+namespace PR51862 {
+
+template  T test() {
+  T a;
+  T b;
+  if (0)
+return a;
+  return b;
+}
+
+struct A {
+  A();
+  A(A &);
+  A(int);
+  operator int();
+};
+
+// CHECK-LABEL: define{{.*}} void @_ZN7PR518624testINS_1AEEET_v
+// CHECK:   call i32 @_ZN7PR518621AcviEv
+// CHECK-NEXT:  call void @_ZN7PR518621AC1Ei
+// CHECK-NEXT:  call void @llvm.lifetime.end
+template A test();
+
+struct BSub {};
+struct B : BSub {
+  B();
+  B(B &);
+  B(const BSub &);
+};
+
+// CHECK-LABEL: define{{.*}} void @_ZN7PR518624testINS_1BEEET_v
+// CHECK:   call void @_ZN7PR518621BC1ERKNS_4BSubE
+// CHECK-NEXT:  call void @llvm.lifetime.end
+template B test();
+
+} // namespace PR51862
Index: clang/lib/Sema/SemaStmt.cpp
===
--- clang/lib/Sema/SemaStmt.cpp
+++ clang/lib/Sema/SemaStmt.cpp
@@ -3653,8 +3653,8 @@
 
 // In C++ the return statement is handled via a copy initialization.
 // the C version of which boils down to CheckSingleAssignmentConstraints.
-InitializedEntity Entity = InitializedEntity::InitializeResult(
-ReturnLoc, FnRetType, NRVOCandidate != nullptr);
+InitializedEntity Entity =
+InitializedEntity::InitializeResult(ReturnLoc, FnRetType);
 ExprResult Res = PerformMoveOrCopyInitialization(
 Entity, NRInfo, RetValExp, SupressSimplerImplicitMoves);
 if (Res.isInvalid()) {
@@ -4085,8 +4085,8 @@
 // the C version of which boils down to CheckSingleAssignmentConstraints.
 if (!HasDependentReturnType && !RetValExp->isTypeDependent()) {
   // we have a non-void function with an expression, continue checking
-  InitializedEntity Entity = InitializedEntity::InitializeResult(
-  ReturnLoc, RetType, NRVOCandidate != nullptr);
+  InitializedEntity Entity =
+  InitializedEntity::InitializeResult(ReturnLoc, RetType);
   ExprResult Res = PerformMoveOrCopyInitialization(
   Entity, NRInfo, RetValExp, SupressSimplerImplicitMoves);
   if (Res.isInvalid()) {
Index: clang/lib/Sema/SemaObjCProperty.cpp
===
--- clang/lib/Sema/SemaObjCProperty.cpp
+++ clang/lib/Sema/SemaObjCProperty.cpp
@@ -1467,8 +1467,7 @@
   LoadSelfExpr, true, true);
   ExprResult Res = PerformCopyInitialization(
   InitializedEntity::InitializeResult(PropertyDiagLoc,
-  getterMethod->getReturnType(),
-  /*NRVO=*/false),
+  getterMethod->getReturnType()),
   PropertyDiagLoc, IvarRefExpr);
   if (!Res.isInvalid()) {
 Expr *ResExpr = Res.getAs();
Index: clang/lib/Sema/SemaLambda.cpp
===
--- 

[PATCH] D109977: LLVM Driver Multicall tool

2021-09-17 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea added a comment.

This is really a great change, thanks @beanz!




Comment at: llvm/tools/llvm-objcopy/llvm-objcopy.cpp:404
 
-int main(int argc, char **argv) {
+int llvm_objcopy_main(int argc, char **argv) {
   InitLLVM X(argc, argv);

Shouldn't we say:
```
int objcopy_main(int argc, char **argv) {
```
here and the other places + all supporting code, if we want `llvm objcopy` 
(without the dash) like @phosek suggests?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109977

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


[PATCH] D109847: [DFSan] Add force_zero_label abilist option to DFSan. This can be used as a work-around for overtainting.

2021-09-17 Thread Andrew 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 rGc533b88a6dc9: [DFSan] Add force_zero_label abilist option to 
DFSan. This can be used as a… (authored by browneee).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109847

Files:
  clang/docs/DataFlowSanitizer.rst
  compiler-rt/test/dfsan/Inputs/flags_abilist.txt
  compiler-rt/test/dfsan/force_zero.c
  llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
  llvm/test/Instrumentation/DataFlowSanitizer/Inputs/abilist.txt
  llvm/test/Instrumentation/DataFlowSanitizer/force_zero.ll

Index: llvm/test/Instrumentation/DataFlowSanitizer/force_zero.ll
===
--- /dev/null
+++ llvm/test/Instrumentation/DataFlowSanitizer/force_zero.ll
@@ -0,0 +1,16 @@
+; RUN: opt < %s -dfsan -dfsan-abilist=%S/Inputs/abilist.txt -S | FileCheck %s -DSHADOW_XOR_MASK=87960930222080
+target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-pc-linux-gnu"
+
+define i32 @function_to_force_zero(i32 %0, i32* %1) {
+  ; CHECK-LABEL: define i32 @function_to_force_zero.dfsan
+  ; CHECK: %[[#SHADOW_XOR:]] = xor i64 {{.*}}, [[SHADOW_XOR_MASK]]
+  ; CHECK: %[[#SHADOW_PTR:]] = inttoptr i64 %[[#SHADOW_XOR]] to i8*
+  ; CHECK: %[[#SHADOW_BITCAST:]] = bitcast i8* %[[#SHADOW_PTR]] to i32*
+  ; CHECK: store i32 0, i32* %[[#SHADOW_BITCAST]]
+  ; CHECK: store i32 %{{.*}}
+  store i32 %0, i32* %1, align 4
+  ; CHECK: store i8 0, {{.*}}@__dfsan_retval_tls
+  ; CHECK: ret i32
+  ret i32 %0
+}
Index: llvm/test/Instrumentation/DataFlowSanitizer/Inputs/abilist.txt
===
--- llvm/test/Instrumentation/DataFlowSanitizer/Inputs/abilist.txt
+++ llvm/test/Instrumentation/DataFlowSanitizer/Inputs/abilist.txt
@@ -8,3 +8,5 @@
 fun:custom*=custom
 
 fun:uninstrumented*=uninstrumented
+
+fun:function_to_force_zero=force_zero_labels
Index: llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
===
--- llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
+++ llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
@@ -144,8 +144,17 @@
 // to the "native" (i.e. unsanitized) ABI.  Unless the ABI list contains
 // additional annotations for those functions, a call to one of those functions
 // will produce a warning message, as the labelling behaviour of the function is
-// unknown.  The other supported annotations are "functional" and "discard",
-// which are described below under DataFlowSanitizer::WrapperKind.
+// unknown. The other supported annotations for uninstrumented functions are
+// "functional" and "discard", which are described below under
+// DataFlowSanitizer::WrapperKind.
+// Functions will often be labelled with both "uninstrumented" and one of
+// "functional" or "discard". This will leave the function unchanged by this
+// pass, and create a wrapper function that will call the original.
+//
+// Instrumented functions can also be annotated as "force_zero_labels", which
+// will make all shadow and return values set zero labels.
+// Functions should never be labelled with both "force_zero_labels" and
+// "uninstrumented" or any of the unistrumented wrapper kinds.
 static cl::list ClABIListFiles(
 "dfsan-abilist",
 cl::desc("File listing native ABI functions and how the pass treats them"),
@@ -469,6 +478,7 @@
   getShadowOriginAddress(Value *Addr, Align InstAlignment, Instruction *Pos);
   bool isInstrumented(const Function *F);
   bool isInstrumented(const GlobalAlias *GA);
+  bool isForceZeroLabels(const Function *F);
   FunctionType *getArgsFunctionType(FunctionType *T);
   FunctionType *getTrampolineFunctionType(FunctionType *T);
   TransformedFunction getCustomFunctionType(FunctionType *T);
@@ -541,6 +551,7 @@
   DominatorTree DT;
   DataFlowSanitizer::InstrumentedABI IA;
   bool IsNativeABI;
+  bool IsForceZeroLabels;
   AllocaInst *LabelReturnAlloca = nullptr;
   AllocaInst *OriginReturnAlloca = nullptr;
   DenseMap ValShadowMap;
@@ -571,8 +582,10 @@
   DenseMap CachedCollapsedShadows;
   DenseMap> ShadowElements;
 
-  DFSanFunction(DataFlowSanitizer , Function *F, bool IsNativeABI)
-  : DFS(DFS), F(F), IA(DFS.getInstrumentedABI()), IsNativeABI(IsNativeABI) {
+  DFSanFunction(DataFlowSanitizer , Function *F, bool IsNativeABI,
+bool IsForceZeroLabels)
+  : DFS(DFS), F(F), IA(DFS.getInstrumentedABI()), IsNativeABI(IsNativeABI),
+IsForceZeroLabels(IsForceZeroLabels) {
 DT.recalculate(*F);
   }
 
@@ -1107,6 +1120,10 @@
   return !ABIList.isIn(*GA, "uninstrumented");
 }
 
+bool DataFlowSanitizer::isForceZeroLabels(const Function *F) {
+  return ABIList.isIn(*F, "force_zero_labels");
+}
+
 DataFlowSanitizer::InstrumentedABI 

[PATCH] D109997: [OpenMP] Change debugging symbol to weak_odr linkage

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

The new device runtime uses an internal variable to set debugging. This
variable was originally privately linked because every module will have
a copy of it. This caused problems with merging the device bitcode
library because it would get renamed and there was not a way to refer to
an external, private symbol. This changes the symbol to weak_odr so it
can be defined multiply, but will not be renamed.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D109997

Files:
  clang/test/OpenMP/target_debug_codegen.cpp
  llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp


Index: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
===
--- llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
+++ llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
@@ -249,11 +249,9 @@
   IntegerType *I32Ty = Type::getInt32Ty(M.getContext());
   auto *GV = new GlobalVariable(
   M, I32Ty,
-  /* isConstant = */ true, GlobalValue::PrivateLinkage,
+  /* isConstant = */ true, GlobalValue::WeakODRLinkage,
   ConstantInt::get(I32Ty, DebugKind), "__omp_rtl_debug_kind");
 
-  llvm::appendToUsed(M, {GV});
-
   return GV;
 }
 
Index: clang/test/OpenMP/target_debug_codegen.cpp
===
--- clang/test/OpenMP/target_debug_codegen.cpp
+++ clang/test/OpenMP/target_debug_codegen.cpp
@@ -1,4 +1,4 @@
-// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --check-globals --global-value-regex 
"(__omp_rtl_debug_kind|llvm\.used)"
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --check-globals --global-value-regex "__omp_rtl_debug_kind"
 // Test target codegen - host bc file has to be created first.
 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown 
-fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc
 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-unknown-unknown 
-fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-target-new-runtime 
-fopenmp-target-debug -fopenmp-is-device -fopenmp-host-ir-file-path 
%t-ppc-host.bc -o - | FileCheck %s --check-prefix=CHECK
@@ -10,14 +10,11 @@
 #define HEADER
 
 //.
-// CHECK: @__omp_rtl_debug_kind = private constant i32 1
-// CHECK: @llvm.used = appending global [1 x i8*] [i8* bitcast (i32* 
@__omp_rtl_debug_kind to i8*)], section "llvm.metadata"
+// CHECK: @__omp_rtl_debug_kind = weak_odr constant i32 1
 //.
-// CHECK-EQ: @__omp_rtl_debug_kind = private constant i32 111
-// CHECK-EQ: @llvm.used = appending global [1 x i8*] [i8* bitcast (i32* 
@__omp_rtl_debug_kind to i8*)], section "llvm.metadata"
+// CHECK-EQ: @__omp_rtl_debug_kind = weak_odr constant i32 111
 //.
-// CHECK-DEFAULT: @__omp_rtl_debug_kind = private constant i32 0
-// CHECK-DEFAULT: @llvm.used = appending global [1 x i8*] [i8* bitcast (i32* 
@__omp_rtl_debug_kind to i8*)], section "llvm.metadata"
+// CHECK-DEFAULT: @__omp_rtl_debug_kind = weak_odr constant i32 0
 //.
 void foo() {
 #pragma omp target


Index: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
===
--- llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
+++ llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
@@ -249,11 +249,9 @@
   IntegerType *I32Ty = Type::getInt32Ty(M.getContext());
   auto *GV = new GlobalVariable(
   M, I32Ty,
-  /* isConstant = */ true, GlobalValue::PrivateLinkage,
+  /* isConstant = */ true, GlobalValue::WeakODRLinkage,
   ConstantInt::get(I32Ty, DebugKind), "__omp_rtl_debug_kind");
 
-  llvm::appendToUsed(M, {GV});
-
   return GV;
 }
 
Index: clang/test/OpenMP/target_debug_codegen.cpp
===
--- clang/test/OpenMP/target_debug_codegen.cpp
+++ clang/test/OpenMP/target_debug_codegen.cpp
@@ -1,4 +1,4 @@
-// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --check-globals --global-value-regex "(__omp_rtl_debug_kind|llvm\.used)"
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --check-globals --global-value-regex "__omp_rtl_debug_kind"
 // Test target codegen - host bc file has to be created first.
 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc
 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-target-new-runtime -fopenmp-target-debug -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s --check-prefix=CHECK
@@ -10,14 +10,11 @@
 #define HEADER
 
 //.
-// 

[PATCH] D109800: [clang] don't mark as Elidable CXXConstruct expressions used in NRVO

2021-09-17 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov added a comment.

In D109800#3004288 , @Quuxplusone 
wrote:

> Getting rid of that extra bool parameter throughout //looks// awesome, 
> though. :)

It will come back later, this patch is just a quick thing we need in order to 
ship clang-13.
But perhaps we bring it back in enum class form? :)

> I do think it might be a good idea to include one or two tests that actually 
> run all the way through codegen, e.g. https://godbolt.org/z/54eTrj54M

I think in that case, if we pursue that direction, what we would want is to 
have these tests that only go until LLVM IR, and then another set of tests that 
go from IR to arch specific LL, or perhaps just to optimized IR.
To be frank, I don't see how anything interesting here would happen after clang 
CodeGen (except in UB cases), but I am not very familiar with that side of the 
project.

> The scary failure mode here (if you are like me and don't really understand 
> why this is impossible ;)) would be if the compiler somehow elided one of the 
> implicit conversions without eliding the other one (like how compiler bugs 
> have in the past led to eliding a constructor without eliding the matching 
> destructor).

Right, when we get to that point where we can elide that double conversion 
sequence, we got to add tests, but I suspect they don't need to go further than 
clang CodeGen.

> Also, is it worth testing anything in constexpr functions? My understanding 
> is that constexpr functions never do copy elision, although maybe(?) they're 
> permitted to?

We do have analogous situation to CodeGen there, we step over a 
MaterializeTemporary in the isElidable case, and if we improve in this area to 
support double conversions, that has to be fixed too.
But this patch should not be changing anything in the rvalue path, only the 
NRVO one, which again I could not find anything that uses it anywhere in LLVM 
tree.
I will add an assert and FIXME there though.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109800

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


[PATCH] D109996: [PowerPC] Fix signature of lxvp and stxvp builtins

2021-09-17 Thread Quinn Pham via Phabricator via cfe-commits
quinnp created this revision.
Herald added subscribers: shchenz, kbarton, nemanjai.
quinnp requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This patch changes the signature of the load and store vector pair
builtins to match their documentation. The type of the `signed long long`
argument is changed to `signed long`. This patch also changes existing testcases
to match the signature change.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D109996

Files:
  clang/include/clang/Basic/BuiltinsPPC.def
  clang/test/CodeGen/builtins-ppc-pair-mma.c
  clang/test/Sema/ppc-pair-mma-types.c

Index: clang/test/Sema/ppc-pair-mma-types.c
===
--- clang/test/Sema/ppc-pair-mma-types.c
+++ clang/test/Sema/ppc-pair-mma-types.c
@@ -322,16 +322,16 @@
 }
 
 void testBuiltinTypes1(const __vector_pair *vpp, const __vector_pair *vp2, float f) {
-  __vector_pair vp = __builtin_vsx_lxvp(f, vpp); // expected-error {{passing 'float' to parameter of incompatible type 'long long'}}
-  __builtin_vsx_stxvp(vp, 32799, vp2);   // expected-error {{passing 'int' to parameter of incompatible type 'long long'}}
+  __vector_pair vp = __builtin_vsx_lxvp(f, vpp); // expected-error {{passing 'float' to parameter of incompatible type 'long'}}
+  __builtin_vsx_stxvp(vp, 32799, vp2);   // expected-error {{passing 'int' to parameter of incompatible type 'long'}}
 }
 
 void testBuiltinTypes2(__vector_pair *vpp, const __vector_pair *vp2, unsigned char c) {
-  __vector_pair vp = __builtin_vsx_lxvp(6LL, vpp); // expected-error {{passing '__vector_pair *' to parameter of incompatible type 'const __vector_pair *'}}
-  __builtin_vsx_stxvp(vp, c, vp2); // expected-error {{passing 'unsigned char' to parameter of incompatible type 'long long'}}
+  __vector_pair vp = __builtin_vsx_lxvp(6L, vpp); // expected-error {{passing '__vector_pair *' to parameter of incompatible type 'const __vector_pair *'}}
+  __builtin_vsx_stxvp(vp, c, vp2);// expected-error {{passing 'unsigned char' to parameter of incompatible type 'long'}}
 }
 
-void testBuiltinTypes3(vector int v, __vector_pair *vp2, signed long long ll, unsigned short s) {
-  __vector_pair vp = __builtin_vsx_lxvp(ll, v); // expected-error {{passing '__vector int' (vector of 4 'int' values) to parameter of incompatible type 'const __vector_pair *'}}
-  __builtin_vsx_stxvp(vp, ll, s);   // expected-error {{passing 'unsigned short' to parameter of incompatible type 'const __vector_pair *'}}
+void testBuiltinTypes3(vector int v, __vector_pair *vp2, signed long l, unsigned short s) {
+  __vector_pair vp = __builtin_vsx_lxvp(l, v); // expected-error {{passing '__vector int' (vector of 4 'int' values) to parameter of incompatible type 'const __vector_pair *'}}
+  __builtin_vsx_stxvp(vp, l, s);   // expected-error {{passing 'unsigned short' to parameter of incompatible type 'const __vector_pair *'}}
 }
Index: clang/test/CodeGen/builtins-ppc-pair-mma.c
===
--- clang/test/CodeGen/builtins-ppc-pair-mma.c
+++ clang/test/CodeGen/builtins-ppc-pair-mma.c
@@ -1049,8 +1049,8 @@
 // CHECK-NEXT:ret void
 //
 void test66(const __vector_pair *vpp, const __vector_pair *vp2) {
-  __vector_pair vp = __builtin_vsx_lxvp(0LL, vpp);
-  __builtin_vsx_stxvp(vp, 0LL, vp2);
+  __vector_pair vp = __builtin_vsx_lxvp(0L, vpp);
+  __builtin_vsx_stxvp(vp, 0L, vp2);
 }
 
 // CHECK-LABEL: @test67(
@@ -1063,7 +1063,7 @@
 // CHECK-NEXT:tail call void @llvm.ppc.vsx.stxvp(<256 x i1> [[TMP2]], i8* [[TMP4]])
 // CHECK-NEXT:ret void
 //
-void test67(const __vector_pair *vpp, signed long long offset, const __vector_pair *vp2) {
+void test67(const __vector_pair *vpp, signed long offset, const __vector_pair *vp2) {
   __vector_pair vp = __builtin_vsx_lxvp(offset, vpp);
   __builtin_vsx_stxvp(vp, offset, vp2);
 }
@@ -1079,8 +1079,8 @@
 // CHECK-NEXT:ret void
 //
 void test68(const __vector_pair *vpp, const __vector_pair *vp2) {
-  __vector_pair vp = __builtin_vsx_lxvp(18LL, vpp);
-  __builtin_vsx_stxvp(vp, 18LL, vp2);
+  __vector_pair vp = __builtin_vsx_lxvp(18L, vpp);
+  __builtin_vsx_stxvp(vp, 18L, vp2);
 }
 
 // CHECK-LABEL: @test69(
@@ -1094,8 +1094,8 @@
 // CHECK-NEXT:ret void
 //
 void test69(const __vector_pair *vpp, const __vector_pair *vp2) {
-  __vector_pair vp = __builtin_vsx_lxvp(1LL, vpp);
-  __builtin_vsx_stxvp(vp, 1LL, vp2);
+  __vector_pair vp = __builtin_vsx_lxvp(1L, vpp);
+  __builtin_vsx_stxvp(vp, 1L, vp2);
 }
 
 // CHECK-LABEL: @test70(
@@ -1109,8 +1109,8 @@
 // CHECK-NEXT:ret void
 //
 void test70(const __vector_pair *vpp, const __vector_pair *vp2) {
-  __vector_pair vp = __builtin_vsx_lxvp(42LL, vpp);
-  __builtin_vsx_stxvp(vp, 42LL, vp2);
+  __vector_pair vp = __builtin_vsx_lxvp(42L, vpp);
+  __builtin_vsx_stxvp(vp, 42L, vp2);
 }
 
 // CHECK-LABEL: 

[PATCH] D91944: OpenMP 5.0 metadirective

2021-09-17 Thread Chi Chun Chen via Phabricator via cfe-commits
cchen updated this revision to Diff 373312.
cchen added a comment.

Fix tests and coding style


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91944

Files:
  clang/include/clang-c/Index.h
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/AST/StmtOpenMP.h
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/StmtNodes.td
  clang/include/clang/Sema/Sema.h
  clang/include/clang/Serialization/ASTBitCodes.h
  clang/lib/AST/OpenMPClause.cpp
  clang/lib/AST/StmtOpenMP.cpp
  clang/lib/AST/StmtPrinter.cpp
  clang/lib/AST/StmtProfile.cpp
  clang/lib/Basic/OpenMPKinds.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CGStmt.cpp
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/Parse/ParseOpenMP.cpp
  clang/lib/Sema/SemaExceptionSpec.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReaderStmt.cpp
  clang/lib/Serialization/ASTWriterStmt.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
  clang/test/OpenMP/metadirective_ast_print.c
  clang/test/OpenMP/metadirective_device_kind_codegen.c
  clang/test/OpenMP/metadirective_device_kind_codegen.cpp
  clang/test/OpenMP/metadirective_empty.cpp
  clang/test/OpenMP/metadirective_implementation_codegen.c
  clang/test/OpenMP/metadirective_implementation_codegen.cpp
  clang/test/OpenMP/metadirective_messages.cpp
  clang/tools/libclang/CIndex.cpp
  clang/tools/libclang/CXCursor.cpp
  flang/lib/Semantics/check-omp-structure.cpp
  llvm/include/llvm/Frontend/OpenMP/OMP.td

Index: llvm/include/llvm/Frontend/OpenMP/OMP.td
===
--- llvm/include/llvm/Frontend/OpenMP/OMP.td
+++ llvm/include/llvm/Frontend/OpenMP/OMP.td
@@ -339,6 +339,7 @@
   let clangClass = "OMPFilterClause";
   let flangClass = "ScalarIntExpr";
 }
+def OMPC_When: Clause<"when"> {}
 
 //===--===//
 // Definition of OpenMP directives
@@ -1703,6 +1704,10 @@
 VersionedClause
   ];
 }
+def OMP_Metadirective : Directive<"metadirective"> {
+  let allowedClauses = [VersionedClause];
+  let allowedOnceClauses = [VersionedClause];
+}
 def OMP_Unknown : Directive<"unknown"> {
   let isDefault = true;
 }
Index: flang/lib/Semantics/check-omp-structure.cpp
===
--- flang/lib/Semantics/check-omp-structure.cpp
+++ flang/lib/Semantics/check-omp-structure.cpp
@@ -1391,6 +1391,7 @@
 CHECK_SIMPLE_CLAUSE(Novariants, OMPC_novariants)
 CHECK_SIMPLE_CLAUSE(Nocontext, OMPC_nocontext)
 CHECK_SIMPLE_CLAUSE(Filter, OMPC_filter)
+CHECK_SIMPLE_CLAUSE(When, OMPC_when)
 
 CHECK_REQ_SCALAR_INT_CLAUSE(Grainsize, OMPC_grainsize)
 CHECK_REQ_SCALAR_INT_CLAUSE(NumTasks, OMPC_num_tasks)
Index: clang/tools/libclang/CXCursor.cpp
===
--- clang/tools/libclang/CXCursor.cpp
+++ clang/tools/libclang/CXCursor.cpp
@@ -643,6 +643,9 @@
   case Stmt::OMPCanonicalLoopClass:
 K = CXCursor_OMPCanonicalLoop;
 break;
+  case Stmt::OMPMetaDirectiveClass:
+K = CXCursor_OMPMetaDirective;
+break;
   case Stmt::OMPParallelDirectiveClass:
 K = CXCursor_OMPParallelDirective;
 break;
Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -5582,6 +5582,8 @@
 return cxstring::createRef("ModuleImport");
   case CXCursor_OMPCanonicalLoop:
 return cxstring::createRef("OMPCanonicalLoop");
+  case CXCursor_OMPMetaDirective:
+return cxstring::createRef("OMPMetaDirective");
   case CXCursor_OMPParallelDirective:
 return cxstring::createRef("OMPParallelDirective");
   case CXCursor_OMPSimdDirective:
Index: clang/test/OpenMP/metadirective_messages.cpp
===
--- /dev/null
+++ clang/test/OpenMP/metadirective_messages.cpp
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -std=c++14 -emit-llvm %s
+
+void foo() {
+#pragma omp metadirective // expected-error {{expected expression}}
+  ;
+#pragma omp metadirective when() // expected-error {{expected valid context selector in when clause}} expected-error {{expected expression}} expected-warning {{expected identifier or string literal describing a context set; set skipped}} expected-note {{context set options are: 'construct' 'device' 'implementation' 'user'}} expected-note {{the ignored set spans until here}}
+  ;
+#pragma omp metadirective when(device{}) // expected-warning {{expected '=' after the context set name "device"; '=' assumed}} expected-warning {{expected identifier or string literal describing a context selector; selector skipped}} expected-note {{context selector 

[PATCH] D91944: OpenMP 5.0 metadirective

2021-09-17 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: clang/include/clang/AST/StmtOpenMP.h:5412
+
+  void setIfStmt(Stmt *stmt) { IfStmt = stmt; }
+  Stmt *getIfStmt() const { return IfStmt; }

cchen wrote:
> ABataev wrote:
> > cchen wrote:
> > > ABataev wrote:
> > > > 1. Make it private, please
> > > > 2. Var names must start from capital letter `stmt`->`S`
> > > I'm going to fix it. By the way, do you know how to fix those failing 
> > > Windows tests? I tried to fix it by adding `ifndef HEADER` to test files 
> > > and also replace var names with regex, but those Windows tests still 
> > > fail. Thanks
> > No idea. Need a bit of context (I mean, would be good to see the test log 
> > etc.).
> I think the run line might be so general, I update it and see if that helps.
Just provide target triple in all test runs commands for linux and make a 
separate test for windows (if required), it should fix the issue with the 
testing.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91944

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


[PATCH] D91944: OpenMP 5.0 metadirective

2021-09-17 Thread Chi Chun Chen via Phabricator via cfe-commits
cchen added inline comments.



Comment at: clang/include/clang/AST/StmtOpenMP.h:5412
+
+  void setIfStmt(Stmt *stmt) { IfStmt = stmt; }
+  Stmt *getIfStmt() const { return IfStmt; }

ABataev wrote:
> cchen wrote:
> > ABataev wrote:
> > > 1. Make it private, please
> > > 2. Var names must start from capital letter `stmt`->`S`
> > I'm going to fix it. By the way, do you know how to fix those failing 
> > Windows tests? I tried to fix it by adding `ifndef HEADER` to test files 
> > and also replace var names with regex, but those Windows tests still fail. 
> > Thanks
> No idea. Need a bit of context (I mean, would be good to see the test log 
> etc.).
I think the run line might be so general, I update it and see if that helps.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91944

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


[PATCH] D91944: OpenMP 5.0 metadirective

2021-09-17 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: clang/include/clang/AST/StmtOpenMP.h:5412
+
+  void setIfStmt(Stmt *stmt) { IfStmt = stmt; }
+  Stmt *getIfStmt() const { return IfStmt; }

cchen wrote:
> ABataev wrote:
> > 1. Make it private, please
> > 2. Var names must start from capital letter `stmt`->`S`
> I'm going to fix it. By the way, do you know how to fix those failing Windows 
> tests? I tried to fix it by adding `ifndef HEADER` to test files and also 
> replace var names with regex, but those Windows tests still fail. Thanks
No idea. Need a bit of context (I mean, would be good to see the test log etc.).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91944

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


[PATCH] D109461: [clang][darwin] Add support for --emit-static-lib

2021-09-17 Thread Keith Smiley via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG80d62993d072: [clang][darwin] Add support for 
--emit-static-lib (authored by keith).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109461

Files:
  clang/lib/Driver/ToolChain.cpp
  clang/lib/Driver/ToolChains/Darwin.cpp
  clang/lib/Driver/ToolChains/Darwin.h
  clang/test/Driver/bindings.c
  clang/test/Driver/darwin-static-lib.c

Index: clang/test/Driver/darwin-static-lib.c
===
--- /dev/null
+++ clang/test/Driver/darwin-static-lib.c
@@ -0,0 +1,5 @@
+// RUN: %clang -target i386-apple-darwin9 %s -### --emit-static-lib 2>&1 | FileCheck %s
+// CHECK: "{{.*}}libtool" "-static" "-D" "-no_warning_for_no_symbols" "-o" "a.out" "{{.*o}}"
+
+// RUN: %clang -target i386-apple-darwin9 %s -### --emit-static-lib -o libfoo.a 2>&1 | FileCheck %s --check-prefix=OUTPUT
+// OUTPUT: "{{.*}}libtool" "-static" "-D" "-no_warning_for_no_symbols" "-o" "libfoo.a" "{{.*o}}"
Index: clang/test/Driver/bindings.c
===
--- clang/test/Driver/bindings.c
+++ clang/test/Driver/bindings.c
@@ -27,3 +27,7 @@
 // GNU StaticLibTool binding
 // RUN: %clang -target x86_64-linux-gnu -ccc-print-bindings --emit-static-lib %s 2>&1 | FileCheck %s --check-prefix=CHECK15
 // CHECK15: "x86_64-unknown-linux-gnu" - "GNU::StaticLibTool", inputs: ["{{.*}}.o"], output: "a.out"
+
+// Darwin StaticLibTool binding
+// RUN: %clang -target i386-apple-darwin9 -ccc-print-bindings --emit-static-lib %s 2>&1 | FileCheck %s --check-prefix=CHECK16
+// CHECK16: "i386-apple-darwin9" - "darwin::StaticLibTool", inputs: ["{{.*}}.o"], output: "a.out"
Index: clang/lib/Driver/ToolChains/Darwin.h
===
--- clang/lib/Driver/ToolChains/Darwin.h
+++ clang/lib/Driver/ToolChains/Darwin.h
@@ -78,6 +78,20 @@
 const char *LinkingOutput) const override;
 };
 
+class LLVM_LIBRARY_VISIBILITY StaticLibTool : public MachOTool {
+public:
+  StaticLibTool(const ToolChain )
+  : MachOTool("darwin::StaticLibTool", "static-lib-linker", TC) {}
+
+  bool hasIntegratedCPP() const override { return false; }
+  bool isLinkJob() const override { return true; }
+
+  void ConstructJob(Compilation , const JobAction ,
+const InputInfo , const InputInfoList ,
+const llvm::opt::ArgList ,
+const char *LinkingOutput) const override;
+};
+
 class LLVM_LIBRARY_VISIBILITY Lipo : public MachOTool {
 public:
   Lipo(const ToolChain ) : MachOTool("darwin::Lipo", "lipo", TC) {}
@@ -125,6 +139,7 @@
 protected:
   Tool *buildAssembler() const override;
   Tool *buildLinker() const override;
+  Tool *buildStaticLibTool() const override;
   Tool *getTool(Action::ActionClass AC) const override;
 
 private:
Index: clang/lib/Driver/ToolChains/Darwin.cpp
===
--- clang/lib/Driver/ToolChains/Darwin.cpp
+++ clang/lib/Driver/ToolChains/Darwin.cpp
@@ -729,6 +729,54 @@
   C.addCommand(std::move(Cmd));
 }
 
+void darwin::StaticLibTool::ConstructJob(Compilation , const JobAction ,
+ const InputInfo ,
+ const InputInfoList ,
+ const ArgList ,
+ const char *LinkingOutput) const {
+  const Driver  = getToolChain().getDriver();
+
+  // Silence warning for "clang -g foo.o -o foo"
+  Args.ClaimAllArgs(options::OPT_g_Group);
+  // and "clang -emit-llvm foo.o -o foo"
+  Args.ClaimAllArgs(options::OPT_emit_llvm);
+  // and for "clang -w foo.o -o foo". Other warning options are already
+  // handled somewhere else.
+  Args.ClaimAllArgs(options::OPT_w);
+  // Silence warnings when linking C code with a C++ '-stdlib' argument.
+  Args.ClaimAllArgs(options::OPT_stdlib_EQ);
+
+  // libtool   
+  ArgStringList CmdArgs;
+  // Create and insert file members with a deterministic index.
+  CmdArgs.push_back("-static");
+  CmdArgs.push_back("-D");
+  CmdArgs.push_back("-no_warning_for_no_symbols");
+  CmdArgs.push_back("-o");
+  CmdArgs.push_back(Output.getFilename());
+
+  for (const auto  : Inputs) {
+if (II.isFilename()) {
+  CmdArgs.push_back(II.getFilename());
+}
+  }
+
+  // Delete old output archive file if it already exists before generating a new
+  // archive file.
+  const auto *OutputFileName = Output.getFilename();
+  if (Output.isFilename() && llvm::sys::fs::exists(OutputFileName)) {
+if (std::error_code EC = llvm::sys::fs::remove(OutputFileName)) {
+  D.Diag(diag::err_drv_unable_to_remove_file) << EC.message();
+  return;
+}
+  }
+
+  const char *Exec = Args.MakeArgString(getToolChain().GetStaticLibToolPath());
+  C.addCommand(std::make_unique(JA, 

[PATCH] D91944: OpenMP 5.0 metadirective

2021-09-17 Thread Chi Chun Chen via Phabricator via cfe-commits
cchen added inline comments.



Comment at: clang/include/clang/AST/StmtOpenMP.h:5412
+
+  void setIfStmt(Stmt *stmt) { IfStmt = stmt; }
+  Stmt *getIfStmt() const { return IfStmt; }

ABataev wrote:
> 1. Make it private, please
> 2. Var names must start from capital letter `stmt`->`S`
I'm going to fix it. By the way, do you know how to fix those failing Windows 
tests? I tried to fix it by adding `ifndef HEADER` to test files and also 
replace var names with regex, but those Windows tests still fail. Thanks


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91944

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


[clang] 80d6299 - [clang][darwin] Add support for --emit-static-lib

2021-09-17 Thread Keith Smiley via cfe-commits

Author: Keith Smiley
Date: 2021-09-17T12:11:05-07:00
New Revision: 80d62993d0720bc36523e39e64cc36da6e445e64

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

LOG: [clang][darwin] Add support for --emit-static-lib

This uses darwin's default libtool since llvm-ar isn't normally
available.

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

Added: 
clang/test/Driver/darwin-static-lib.c

Modified: 
clang/lib/Driver/ToolChain.cpp
clang/lib/Driver/ToolChains/Darwin.cpp
clang/lib/Driver/ToolChains/Darwin.h
clang/test/Driver/bindings.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp
index 6c1b88141c45..7272cc29cc7c 100644
--- a/clang/lib/Driver/ToolChain.cpp
+++ b/clang/lib/Driver/ToolChain.cpp
@@ -618,6 +618,8 @@ std::string ToolChain::GetLinkerPath(bool *LinkerIsLLD,
 
 std::string ToolChain::GetStaticLibToolPath() const {
   // TODO: Add support for static lib archiving on Windows
+  if (Triple.isOSDarwin())
+return GetProgramPath("libtool");
   return GetProgramPath("llvm-ar");
 }
 

diff  --git a/clang/lib/Driver/ToolChains/Darwin.cpp 
b/clang/lib/Driver/ToolChains/Darwin.cpp
index 15c885fa6507..8f3b6336d59d 100644
--- a/clang/lib/Driver/ToolChains/Darwin.cpp
+++ b/clang/lib/Driver/ToolChains/Darwin.cpp
@@ -729,6 +729,54 @@ void darwin::Linker::ConstructJob(Compilation , const 
JobAction ,
   C.addCommand(std::move(Cmd));
 }
 
+void darwin::StaticLibTool::ConstructJob(Compilation , const JobAction ,
+ const InputInfo ,
+ const InputInfoList ,
+ const ArgList ,
+ const char *LinkingOutput) const {
+  const Driver  = getToolChain().getDriver();
+
+  // Silence warning for "clang -g foo.o -o foo"
+  Args.ClaimAllArgs(options::OPT_g_Group);
+  // and "clang -emit-llvm foo.o -o foo"
+  Args.ClaimAllArgs(options::OPT_emit_llvm);
+  // and for "clang -w foo.o -o foo". Other warning options are already
+  // handled somewhere else.
+  Args.ClaimAllArgs(options::OPT_w);
+  // Silence warnings when linking C code with a C++ '-stdlib' argument.
+  Args.ClaimAllArgs(options::OPT_stdlib_EQ);
+
+  // libtool   
+  ArgStringList CmdArgs;
+  // Create and insert file members with a deterministic index.
+  CmdArgs.push_back("-static");
+  CmdArgs.push_back("-D");
+  CmdArgs.push_back("-no_warning_for_no_symbols");
+  CmdArgs.push_back("-o");
+  CmdArgs.push_back(Output.getFilename());
+
+  for (const auto  : Inputs) {
+if (II.isFilename()) {
+  CmdArgs.push_back(II.getFilename());
+}
+  }
+
+  // Delete old output archive file if it already exists before generating a 
new
+  // archive file.
+  const auto *OutputFileName = Output.getFilename();
+  if (Output.isFilename() && llvm::sys::fs::exists(OutputFileName)) {
+if (std::error_code EC = llvm::sys::fs::remove(OutputFileName)) {
+  D.Diag(diag::err_drv_unable_to_remove_file) << EC.message();
+  return;
+}
+  }
+
+  const char *Exec = Args.MakeArgString(getToolChain().GetStaticLibToolPath());
+  C.addCommand(std::make_unique(JA, *this,
+ ResponseFileSupport::AtFileUTF8(),
+ Exec, CmdArgs, Inputs, Output));
+}
+
 void darwin::Lipo::ConstructJob(Compilation , const JobAction ,
 const InputInfo ,
 const InputInfoList ,
@@ -982,6 +1030,10 @@ Tool *MachO::getTool(Action::ActionClass AC) const {
 
 Tool *MachO::buildLinker() const { return new tools::darwin::Linker(*this); }
 
+Tool *MachO::buildStaticLibTool() const {
+  return new tools::darwin::StaticLibTool(*this);
+}
+
 Tool *MachO::buildAssembler() const {
   return new tools::darwin::Assembler(*this);
 }

diff  --git a/clang/lib/Driver/ToolChains/Darwin.h 
b/clang/lib/Driver/ToolChains/Darwin.h
index 4de122c8d513..e46ff52a23a9 100644
--- a/clang/lib/Driver/ToolChains/Darwin.h
+++ b/clang/lib/Driver/ToolChains/Darwin.h
@@ -78,6 +78,20 @@ class LLVM_LIBRARY_VISIBILITY Linker : public MachOTool {
 const char *LinkingOutput) const override;
 };
 
+class LLVM_LIBRARY_VISIBILITY StaticLibTool : public MachOTool {
+public:
+  StaticLibTool(const ToolChain )
+  : MachOTool("darwin::StaticLibTool", "static-lib-linker", TC) {}
+
+  bool hasIntegratedCPP() const override { return false; }
+  bool isLinkJob() const override { return true; }
+
+  void ConstructJob(Compilation , const JobAction ,
+const InputInfo , const InputInfoList ,
+const llvm::opt::ArgList ,
+const char *LinkingOutput) const override;
+};
+
 class 

[PATCH] D109990: [OpenMP][Docs] Update clang support based on community discussion

2021-09-17 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev accepted this revision.
ABataev added a comment.
This revision is now accepted and ready to land.

LG


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109990

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


[PATCH] D109977: LLVM Driver Multicall tool

2021-09-17 Thread Chris Bieneman via Phabricator via cfe-commits
beanz updated this revision to Diff 373300.
beanz added a comment.

Renaming llvm-driver binary to llvm.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109977

Files:
  clang/cmake/modules/AddClang.cmake
  clang/tools/driver/CMakeLists.txt
  clang/tools/driver/driver.cpp
  llvm/cmake/driver-template.cpp.in
  llvm/cmake/modules/AddLLVM.cmake
  llvm/test/CMakeLists.txt
  llvm/test/lit.cfg.py
  llvm/test/lit.site.cfg.py.in
  llvm/test/tools/llvm-driver/help-passthrough.test
  llvm/test/tools/llvm-driver/help.test
  llvm/test/tools/llvm-driver/symlink-call.test
  llvm/tools/CMakeLists.txt
  llvm/tools/dsymutil/CMakeLists.txt
  llvm/tools/dsymutil/dsymutil.cpp
  llvm/tools/llvm-ar/CMakeLists.txt
  llvm/tools/llvm-ar/llvm-ar.cpp
  llvm/tools/llvm-cxxfilt/CMakeLists.txt
  llvm/tools/llvm-cxxfilt/llvm-cxxfilt.cpp
  llvm/tools/llvm-driver/CMakeLists.txt
  llvm/tools/llvm-driver/llvm-driver.cpp
  llvm/tools/llvm-objcopy/CMakeLists.txt
  llvm/tools/llvm-objcopy/llvm-objcopy.cpp

Index: llvm/tools/llvm-objcopy/llvm-objcopy.cpp
===
--- llvm/tools/llvm-objcopy/llvm-objcopy.cpp
+++ llvm/tools/llvm-objcopy/llvm-objcopy.cpp
@@ -401,7 +401,7 @@
   return Error::success();
 }
 
-int main(int argc, char **argv) {
+int llvm_objcopy_main(int argc, char **argv) {
   InitLLVM X(argc, argv);
   ToolName = argv[0];
 
Index: llvm/tools/llvm-objcopy/CMakeLists.txt
===
--- llvm/tools/llvm-objcopy/CMakeLists.txt
+++ llvm/tools/llvm-objcopy/CMakeLists.txt
@@ -43,6 +43,7 @@
   ObjcopyOptsTableGen
   InstallNameToolOptsTableGen
   StripOptsTableGen
+  GENERATE_DRIVER
   )
 
 add_llvm_tool_symlink(llvm-install-name-tool llvm-objcopy)
Index: llvm/tools/llvm-driver/llvm-driver.cpp
===
--- /dev/null
+++ llvm/tools/llvm-driver/llvm-driver.cpp
@@ -0,0 +1,61 @@
+//===-- llvm-driver.cpp ---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "llvm/ADT/StringRef.h"
+#include "llvm/ADT/StringSwitch.h"
+#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/ErrorHandling.h"
+#include "llvm/Support/Path.h"
+#include "llvm/Support/WithColor.h"
+
+using namespace llvm;
+
+#define LLVM_DRIVER_TOOL(tool, entry) int entry##_main(int argc, char **argv);
+#include "LLVMDriverTools.def"
+
+// This function handles the case of not recognizing the tool requested, or if
+// --help or --version are passed directly to the llvm driver.
+int UnknownMain(int Argc, char **Argv) {
+  cl::OptionCategory LLVMDriverCategory("llvm options");
+#define LLVM_DRIVER_TOOL(tool, entry)  \
+  cl::SubCommand entry##Subcommand(tool, tool);
+#include "LLVMDriverTools.def"
+
+  cl::HideUnrelatedOptions(LLVMDriverCategory);
+  cl::ParseCommandLineOptions(Argc, Argv, "llvm compiler driver\n");
+  llvm_unreachable("We should never get here, parsing should always exit.");
+  return 1;
+}
+
+int main(int Argc, char **Argv) {
+  llvm::StringRef LaunchedTool = sys::path::stem(Argv[0]);
+  // If the driver is launched directly.
+  int PassThroughArgC = Argc;
+  char **PassThroughArgV = Argv;
+  bool ConsumeFirstArg = false;
+  if (LaunchedTool == "llvm") {
+LaunchedTool = Argv[1];
+ConsumeFirstArg = true;
+  }
+
+  // if it is launched through a symlink that is the tool name.
+  typedef int (*MainFunction)(int, char **);
+  MainFunction Func = StringSwitch(LaunchedTool)
+
+#define LLVM_DRIVER_TOOL(tool, entry) .Case(tool, entry##_main)
+#include "LLVMDriverTools.def"
+  .Default(UnknownMain);
+  // If the main function is unknown we don't consume any args, so that we can
+  // print the appropriate help spew.
+  if (Func != UnknownMain && ConsumeFirstArg) {
+--PassThroughArgC;
+++PassThroughArgV;
+  }
+
+  return Func(PassThroughArgC, PassThroughArgV);
+}
Index: llvm/tools/llvm-driver/CMakeLists.txt
===
--- /dev/null
+++ llvm/tools/llvm-driver/CMakeLists.txt
@@ -0,0 +1,28 @@
+get_property(LLVM_COMMON_DEPENDS GLOBAL PROPERTY LLVM_DRIVER_DEPS)
+get_property(LLVM_DRIVER_OBJLIBS GLOBAL PROPERTY LLVM_DRIVER_OBJLIBS)
+
+get_property(LLVM_DRIVER_TOOLS GLOBAL PROPERTY LLVM_DRIVER_TOOLS)
+
+foreach(tool ${LLVM_DRIVER_TOOLS})
+  string(REPLACE "-" "_" tool_entry ${tool})
+  set(def_decl "${def_decl}LLVM_DRIVER_TOOL(\"${tool}\", ${tool_entry})\n")
+endforeach()
+
+file(WRITE
+  "${CMAKE_CURRENT_BINARY_DIR}/LLVMDriverTools.def"
+  "${def_decl}#undef 

[PATCH] D109951: [clang-format] Constructor initializer lists format with pp directives

2021-09-17 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks added inline comments.



Comment at: clang/unittests/Format/FormatTest.cpp:19271
 
+TEST_F(FormatTest, ConstructorInitializersWithPreprocessorDirective) {
+  FormatStyle Style = getLLVMStyle();

From the name I would expect also to check
```SomeClass::SomeClass()
  : a{a},
b{b}
...
```
With and without the PP directive.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109951

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


[PATCH] D109990: [OpenMP][Docs] Update clang support based on community discussion

2021-09-17 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert created this revision.
jdoerfert added reviewers: ABataev, grokos, JonChesterfield, gregrodgers, ronl, 
RaviNarayanaswamy, dreachem.
Herald added subscribers: guansong, bollu, yaxunl.
jdoerfert requested review of this revision.
Herald added subscribers: cfe-commits, sstefan1.
Herald added a project: clang.

In the last meeting nobody could tell what was problematic for some of
the points so we mark them as done until we realize otherwise.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D109990

Files:
  clang/docs/OpenMPSupport.rst


Index: clang/docs/OpenMPSupport.rst
===
--- clang/docs/OpenMPSupport.rst
+++ clang/docs/OpenMPSupport.rst
@@ -187,7 +187,7 @@
 
+--+--+--+---+
 | device extension | omp_get_device_num()  
   | :part:`worked on`| D54342  
  |
 
+--+--+--+---+
-| device extension | structure mapping of references   
   | :none:`unclaimed`| 
  |
+| device extension | structure mapping of references   
   | :part:`worked on`| 
  |
 
+--+--+--+---+
 | device extension | nested target declare 
   | :good:`done` | D51378  
  |
 
+--+--+--+---+
@@ -201,13 +201,13 @@
 
+--+--+--+---+
 | device extension | clause: unified_address   
   | :part:`partial`  | 
  |
 
+--+--+--+---+
-| device extension | clause: reverse_offload   
   | :none:`unclaimed parts`  | D52780  
  |
+| device extension | clause: reverse_offload   
   | :part:`unclaimed parts`  | D52780  
  |
 
+--+--+--+---+
 | device extension | clause: atomic_default_mem_order  
   | :good:`done` | D53513  
  |
 
+--+--+--+---+
 | device extension | clause: dynamic_allocators
   | :part:`unclaimed parts`  | D53079  
  |
 
+--+--+--+---+
-| device extension | user-defined mappers  
   | :part:`worked on`| 
D56326,D58638,D58523,D58074,D60972,D59474 |
+| device extension | user-defined mappers  
   | :good:`done` | 
D56326,D58638,D58523,D58074,D60972,D59474 |
 
+--+--+--+---+
 | device extension | mapping lambda expression   

[PATCH] D109960: [clang] [ARM] Don't set the strict alignment flag for armv7 on Windows

2021-09-17 Thread Martin Storsjö via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd13d9da1fbe1: [clang] [ARM] Dont set the strict 
alignment flag for armv7 on Windows (authored by mstorsjo).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109960

Files:
  clang/lib/Driver/ToolChains/Arch/ARM.cpp
  clang/test/Driver/arm-alignment.c


Index: clang/test/Driver/arm-alignment.c
===
--- clang/test/Driver/arm-alignment.c
+++ clang/test/Driver/arm-alignment.c
@@ -19,6 +19,9 @@
 // RUN: %clang -target armv7-unknown-nacl-gnueabihf -### %s 2> %t
 // RUN: FileCheck --check-prefix=CHECK-UNALIGNED-ARM < %t %s
 
+// RUN: %clang -target armv7-windows -### %s 2> %t
+// RUN: FileCheck --check-prefix=CHECK-UNALIGNED-ARM < %t %s
+
 // RUN: %clang -target aarch64-none-gnueabi -munaligned-access -### %s 2> %t
 // RUN: FileCheck --check-prefix=CHECK-UNALIGNED-AARCH64 < %t %s
 
Index: clang/lib/Driver/ToolChains/Arch/ARM.cpp
===
--- clang/lib/Driver/ToolChains/Arch/ARM.cpp
+++ clang/lib/Driver/ToolChains/Arch/ARM.cpp
@@ -779,7 +779,8 @@
 // which raises an alignment fault on unaligned accesses. Linux
 // defaults this bit to 0 and handles it as a system-wide (not
 // per-process) setting. It is therefore safe to assume that ARMv7+
-// Linux targets support unaligned accesses. The same goes for NaCl.
+// Linux targets support unaligned accesses. The same goes for NaCl
+// and Windows.
 //
 // The above behavior is consistent with GCC.
 int VersionNum = getARMSubArchVersionNumber(Triple);
@@ -787,7 +788,8 @@
   if (VersionNum < 6 ||
   Triple.getSubArch() == llvm::Triple::SubArchType::ARMSubArch_v6m)
 Features.push_back("+strict-align");
-} else if (Triple.isOSLinux() || Triple.isOSNaCl()) {
+} else if (Triple.isOSLinux() || Triple.isOSNaCl() ||
+   Triple.isOSWindows()) {
   if (VersionNum < 7)
 Features.push_back("+strict-align");
 } else


Index: clang/test/Driver/arm-alignment.c
===
--- clang/test/Driver/arm-alignment.c
+++ clang/test/Driver/arm-alignment.c
@@ -19,6 +19,9 @@
 // RUN: %clang -target armv7-unknown-nacl-gnueabihf -### %s 2> %t
 // RUN: FileCheck --check-prefix=CHECK-UNALIGNED-ARM < %t %s
 
+// RUN: %clang -target armv7-windows -### %s 2> %t
+// RUN: FileCheck --check-prefix=CHECK-UNALIGNED-ARM < %t %s
+
 // RUN: %clang -target aarch64-none-gnueabi -munaligned-access -### %s 2> %t
 // RUN: FileCheck --check-prefix=CHECK-UNALIGNED-AARCH64 < %t %s
 
Index: clang/lib/Driver/ToolChains/Arch/ARM.cpp
===
--- clang/lib/Driver/ToolChains/Arch/ARM.cpp
+++ clang/lib/Driver/ToolChains/Arch/ARM.cpp
@@ -779,7 +779,8 @@
 // which raises an alignment fault on unaligned accesses. Linux
 // defaults this bit to 0 and handles it as a system-wide (not
 // per-process) setting. It is therefore safe to assume that ARMv7+
-// Linux targets support unaligned accesses. The same goes for NaCl.
+// Linux targets support unaligned accesses. The same goes for NaCl
+// and Windows.
 //
 // The above behavior is consistent with GCC.
 int VersionNum = getARMSubArchVersionNumber(Triple);
@@ -787,7 +788,8 @@
   if (VersionNum < 6 ||
   Triple.getSubArch() == llvm::Triple::SubArchType::ARMSubArch_v6m)
 Features.push_back("+strict-align");
-} else if (Triple.isOSLinux() || Triple.isOSNaCl()) {
+} else if (Triple.isOSLinux() || Triple.isOSNaCl() ||
+   Triple.isOSWindows()) {
   if (VersionNum < 7)
 Features.push_back("+strict-align");
 } else
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] d13d9da - [clang] [ARM] Don't set the strict alignment flag for armv7 on Windows

2021-09-17 Thread Martin Storsjö via cfe-commits

Author: Martin Storsjö
Date: 2021-09-17T21:39:25+03:00
New Revision: d13d9da1fbe1a750f9c4fc3f4da31c9d16a530d3

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

LOG: [clang] [ARM] Don't set the strict alignment flag for armv7 on Windows

Windows on armv7 is as alignment tolerant as Linux.

The alignment considerations in the Windows on ARM ABI are documented
at 
https://docs.microsoft.com/en-us/cpp/build/overview-of-arm-abi-conventions?view=msvc-160#alignment.

The document doesn't explicitly say in which state the OS configures
the SCTLR.A register (and it's not accessible from user space to
inspect), but in practice, unaligned loads/stores do work and seem
to be as fast as aligned loads and stores. (Unaligned strd also does
seem to work, contrary to Linux, but significantly slower, as they're
handled by the kernel - exactly as the document describes.)

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/Arch/ARM.cpp
clang/test/Driver/arm-alignment.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Arch/ARM.cpp 
b/clang/lib/Driver/ToolChains/Arch/ARM.cpp
index a64fc30858748..05d83c91ba0ef 100644
--- a/clang/lib/Driver/ToolChains/Arch/ARM.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/ARM.cpp
@@ -779,7 +779,8 @@ void arm::getARMTargetFeatures(const Driver , const 
llvm::Triple ,
 // which raises an alignment fault on unaligned accesses. Linux
 // defaults this bit to 0 and handles it as a system-wide (not
 // per-process) setting. It is therefore safe to assume that ARMv7+
-// Linux targets support unaligned accesses. The same goes for NaCl.
+// Linux targets support unaligned accesses. The same goes for NaCl
+// and Windows.
 //
 // The above behavior is consistent with GCC.
 int VersionNum = getARMSubArchVersionNumber(Triple);
@@ -787,7 +788,8 @@ void arm::getARMTargetFeatures(const Driver , const 
llvm::Triple ,
   if (VersionNum < 6 ||
   Triple.getSubArch() == llvm::Triple::SubArchType::ARMSubArch_v6m)
 Features.push_back("+strict-align");
-} else if (Triple.isOSLinux() || Triple.isOSNaCl()) {
+} else if (Triple.isOSLinux() || Triple.isOSNaCl() ||
+   Triple.isOSWindows()) {
   if (VersionNum < 7)
 Features.push_back("+strict-align");
 } else

diff  --git a/clang/test/Driver/arm-alignment.c 
b/clang/test/Driver/arm-alignment.c
index b2bc8a35dfc6f..41dbb35b1c2c2 100644
--- a/clang/test/Driver/arm-alignment.c
+++ b/clang/test/Driver/arm-alignment.c
@@ -19,6 +19,9 @@
 // RUN: %clang -target armv7-unknown-nacl-gnueabihf -### %s 2> %t
 // RUN: FileCheck --check-prefix=CHECK-UNALIGNED-ARM < %t %s
 
+// RUN: %clang -target armv7-windows -### %s 2> %t
+// RUN: FileCheck --check-prefix=CHECK-UNALIGNED-ARM < %t %s
+
 // RUN: %clang -target aarch64-none-gnueabi -munaligned-access -### %s 2> %t
 // RUN: FileCheck --check-prefix=CHECK-UNALIGNED-AARCH64 < %t %s
 



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


[PATCH] D109632: [clang] de-duplicate methods from AST files

2021-09-17 Thread Richard Howell via Phabricator via cfe-commits
rmaz added inline comments.



Comment at: clang/include/clang/Sema/Sema.h:1434-1436
+bool addMethod(ObjCMethodDecl *Method) {
+  return AddedMethods.insert(Method).second;
+}

rmaz wrote:
> dexonsmith wrote:
> > Hmm, I was imagining that the set would be more encapsulated than this, not 
> > just stored in the same place.
> > 
> > I'm wondering if the following could be done in a prep commit:
> > 
> > - Change Sema::addMethodToGlobalList to a private member function of 
> > GlobalMethodPool.
> > - Make GlobalMethodPool::insert private
> > - Add `GlobalMethodPool::addMethod(ObjCMethodDecl*,bool,bool)`, which does 
> > the second half of Sema::AddMethodToGlobalPool (the parts that don't need 
> > Sema's other fields), and change the latter to call the former.
> > 
> > WDYT?
> Definitely neater, will take a look at this later today.
This might need a slightly different approach, as for the insert use case we 
have:

```lang=cxx
Sema  = *getSema();
  Sema::GlobalMethodPool::iterator Pos =
  S.MethodPool.insert(std::make_pair(Sel, Sema::GlobalMethodPool::Lists()))
  .first;

  Pos->second.first.setBits(Visitor.getInstanceBits());
  Pos->second.first.setHasMoreThanOneDecl(Visitor.instanceHasMoreThanOneDecl());
  Pos->second.second.setBits(Visitor.getFactoryBits());
  Pos->second.second.setHasMoreThanOneDecl(Visitor.factoryHasMoreThanOneDecl());

  // Add methods to the global pool *after* setting hasMoreThanOneDecl, since
  // when building a module we keep every method individually and may need to
  // update hasMoreThanOneDecl as we add the methods.
  addMethodsToPool(S, Visitor.getInstanceMethods(), Pos->second.first);
  addMethodsToPool(S, Visitor.getFactoryMethods(), Pos->second.second);
```

At the moment we fetch a method list, modify its state and then start inserting 
the methods. If we move to something like `MethodPool.addMethod(ObjCMethodDecl 
*)` we will have to look up the method list for each insert, and we would need 
extra methods to set the state first on the method list. How about something 
like `MethodPool.addMethods(ArrayRef methods, unsigned 
instanceBits, bool hasMoreThanOneDecl)`? Then we only need two list lookups per 
selector as before and we can handle the list state update before insert.
 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109632

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


[PATCH] D109437: [PowerPC] FP compare and test XL compat builtins.

2021-09-17 Thread Albion Fung via Phabricator via cfe-commits
Conanap added inline comments.



Comment at: clang/lib/Sema/SemaChecking.cpp:3490
+   SemaBuiltinConstantArgRange(TheCall, 1, 0, 127) ||
+   CheckPPCTestDataClassType(TheCall);
 #define CUSTOM_BUILTIN(Name, Intr, Types, Acc) \

If you're making a function anyways, it may be a good idea to just have a 
function with all the sema checking in it


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109437

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


[PATCH] D102449: [WIP][Clang][OpenMP] Add the support for compare clause in atomic directive

2021-09-17 Thread Carlo Bertolli via Phabricator via cfe-commits
carlo.bertolli added a comment.

In D102449#2977711 , @tianshilei1992 
wrote:

> Another thing is how we deal with a corner case. Say the OpenMP code is 
> written in the following way:
>
>   #pragma omp atomic compare
> x = e < x ? e : x;
>
> That's how OpenMP spec defines the atomic operation. `x` is always in "else 
> statement" of a conditional statement.
>
> Now we need to lower it to LLVM IR, which is `atomicrmw` operation. Based on 
> the LLVM IR reference, it only supports the atomic operations that `x` is in 
> the "then statement". For example: `x = x > e ? x : e`. See the `x` here is 
> before `:`. In order to lower the OpenMP statement, we have to do a 
> transformation. In order to swap `e` and `x`, we need to transform it to `x = 
> e >= x : x : e`, a.k.a. `x = x <= e : x : e`. However, we don't have an 
> atomic operation for `<=`. We only have `<`. So if `x != e`, the result is 
> good.
>
> The incorrectness happens if `x == e`. Recall at the OpenMP statement, when 
> `x == e`, the result should be `x = x`. But if we look at our lowered LLVM 
> IR, `x = x < e : x : e`, when `x == e`, it becomes `x = e`, which doesn't 
> conform with OpenMP spec.
>
> What should we do here?

There seems to be an imbalance in the OpenMP specs, where I would have written 
something like the followin (page 268 or 5.1 spec's):

> x = expr ordop x ? expr : x;
> x = x ordop expr ? **x : expr**;

I tried thinking about a compact solution to your problem, including trying to 
take advantage of the fact that when x == e we don't need to actually do the 
assignment (page 272 line 17 of 5.1 spec's and see below), but I was 
unsuccessful.
Did you consider special casing this transforming it into the equivalent:
#pragma omp critical
{ if (x > e) x = e; }
?

Remember:

> For forms where statement is cond-expr-stmt, if the result of the condition 
> implies that the value of x
> does not change then the update may not occur.

The right thing to do would be to fix the spec's, but that can't happen until 
5.2.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102449

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


[PATCH] D109977: LLVM Driver Multicall tool

2021-09-17 Thread Chris Bieneman via Phabricator via cfe-commits
beanz added inline comments.



Comment at: llvm/tools/llvm-driver/CMakeLists.txt:17
+
+add_llvm_tool(llvm-driver
+  llvm-driver.cpp

phosek wrote:
> As was already suggested on D104686, I'd prefer naming this just `llvm` so 
> you can invoke tools with `llvm name` which doesn't require any additional 
> typing compared to `llvm-name`.
Can do


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109977

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


[PATCH] D109977: LLVM Driver Multicall tool

2021-09-17 Thread Chris Bieneman via Phabricator via cfe-commits
beanz added a comment.

In D109977#3006687 , @mehdi_amini 
wrote:

> That's pretty nice! Have you thought about looking into a lit option 
> (triggered by a cmake flag maybe) that would change the substitution for the 
> tools that are enabled by llvm-driver to use the latter instead when running 
> the tests?

That's an awesome idea. I had been thinking about having a CMake option to 
generate symlinks instead of the tools, but you could totally bake this into 
the lit substitutions. I'll take a look at that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109977

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


[clang] 101c3de - Add information about C99 to the C status page.

2021-09-17 Thread Aaron Ballman via cfe-commits

Author: Aaron Ballman
Date: 2021-09-17T13:49:17-04:00
New Revision: 101c3de39fbcdd7d47b25aaf6d972e435f017077

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

LOG: Add information about C99 to the C status page.

Added: 


Modified: 
clang/www/c_status.html

Removed: 




diff  --git a/clang/www/c_status.html b/clang/www/c_status.html
index 4fb3764233fda..386859125a82a 100644
--- a/clang/www/c_status.html
+++ b/clang/www/c_status.html
@@ -84,8 +84,251 @@ C89 implementation status
 C99 implementation status
 
 Clang implements a significant portion of the ISO 9899:1999 (C99) standard, 
but the status of individual proposals is still under investigation.
+Note, the list of C99 features comes from the C99 committee draft. A list 
of N-numbered documents for these features does not appear in either the 
standard or in any available editor's report, so this section does not track 
document numbers currently.
 You can use Clang in C99 mode with the -std=c99 option.
 
+
+List of features and minimum Clang version with support
+
+
+ 
+Language Feature
+
+Available in Clang?
+ 
+
+  restricted character set support via digraphs and 
iso646.h
+
+  Unknown
+
+
+  more precise aliasing rules via effective type
+
+  Unknown
+
+
+  restricted pointers
+
+  Unknown
+
+
+  variable length arrays
+
+  Yes
+
+
+  flexible array members
+
+  Yes
+
+
+  static and type qualifiers in parameter array declarators
+
+  Yes
+
+
+  more precise aliasing rules via effective type
+
+  Unknown
+
+
+  complex and imaginary support in complex.h
+
+  Unknown
+
+
+  type-generic math macros in tgmath.h
+
+  Yes
+
+
+  the long long int type
+
+  Yes
+
+
+  increase minimum translation limits
+
+  Unknown
+
+
+  additional floating-point characteristics in float.h
+
+  Unknown
+
+
+  remove implicit int
+
+  Unknown
+
+
+  reliable integer division
+
+  Unknown
+
+
+  universal character names (\u and \U)
+
+  Yes
+
+
+  extended identifiers
+
+  Unknown
+
+
+  hexadecimal floating-point constants
+
+  Yes
+
+
+  compound literals
+
+  Yes
+
+
+  designated initializers
+
+  Yes
+
+
+  // comments
+
+  Yes
+
+
+  extended integer types and library functions in inttypes.h 
and stdint.h
+
+  Yes
+
+
+  remove implicit function declaration
+
+  Unknown
+
+
+  preprocessor arithmetic done in intmax_t/uintmax_t
+
+  Unknown
+
+
+  mixed declarations and code
+
+  Yes
+
+
+  new block scopes for selection and iteration statements
+
+  Unknown
+
+
+  integer constant type rules
+
+  Unknown
+
+
+  integer promotion rules
+
+  Unknown
+
+
+  macros with a variable number of arguments
+
+  Yes
+
+
+  IEC 60559 support
+
+  Unknown
+
+
+  trailing comma allowed in enum declaration
+
+  Yes
+
+
+  inline functions
+
+  Yes
+
+
+  boolean type in stdbool.h
+
+  Yes
+
+
+  idempotent type qualifiers
+
+  Unknown
+
+
+  empty macro arguments
+
+  Unknown
+
+
+  new structure type compatibility (tag compatibility)
+
+  Unknown
+
+
+  additional predefined macro names
+
+  Unknown
+
+
+  _Pragma preprocessing operator
+
+  Yes
+
+
+  standard pragmas
+
+  Unknown
+
+
+  __func__ predefined identifier
+
+  Yes
+
+
+  va_copy macro
+
+  Yes
+
+
+  LIA compatibility annex
+
+  No
+
+
+  remove deprecation of aliased array parameters
+
+  Unknown
+
+
+  conversion of array to pointer not limited to lvalues
+
+  Unknown
+
+
+  relaxed constraints on aggregate and union initialization
+
+  Unknown
+
+
+  relaxed restrictions on portable header names
+
+  Unknown
+
+
+  return without an expression not permitted in function that returns 
a value
+
+  Yes
+
+
+
+
 C11 implementation status
 
 Clang implements a significant portion of the ISO 9899:2011 (C11) standard, 
but the status of individual proposals is still under investigation.



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


[PATCH] D109975: [CMake] Consistently use the LibXml2::LibXml2 target instead of LIBXML2_LIBRARIES

2021-09-17 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone added a comment.

I was inspired to dig down and find the `LLVM_ENABLE_LIBXML2` option (which is 
on by default) and turn it off, so now I can build clang with the following 
commands:

  cmake -G Ninja -DLLVM_ENABLE_LIBXML2=0 -DDEFAULT_SYSROOT="$(xcrun 
--show-sdk-path)" -DLLVM_ENABLE_PROJECTS="clang;libcxx;libcxxabi" 
-DCMAKE_BUILD_TYPE=Release ../llvm
  ninja clang

I suspect that my `/usr/lib/libxml2.2.dylib` is simply outdated/has been borked 
by my OS upgrade; unfortunately I still haven't figured out how to install a 
newer version of it.
Anyway, never mind me, then. :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109975

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


[PATCH] D91944: OpenMP 5.0 metadirective

2021-09-17 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: clang/include/clang/AST/StmtOpenMP.h:5412
+
+  void setIfStmt(Stmt *stmt) { IfStmt = stmt; }
+  Stmt *getIfStmt() const { return IfStmt; }

1. Make it private, please
2. Var names must start from capital letter `stmt`->`S`



Comment at: clang/lib/Parse/ParseOpenMP.cpp:2389
+
+int idx = 0;
+// In OpenMP 5.0 metadirective is either replaced by another directive or

Please, fix var names.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91944

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


[PATCH] D91944: OpenMP 5.0 metadirective

2021-09-17 Thread Chi Chun Chen via Phabricator via cfe-commits
cchen updated this revision to Diff 373277.
cchen added a comment.

Fix tests for Windows


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91944

Files:
  clang/include/clang-c/Index.h
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/AST/StmtOpenMP.h
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/StmtNodes.td
  clang/include/clang/Sema/Sema.h
  clang/include/clang/Serialization/ASTBitCodes.h
  clang/lib/AST/OpenMPClause.cpp
  clang/lib/AST/StmtOpenMP.cpp
  clang/lib/AST/StmtPrinter.cpp
  clang/lib/AST/StmtProfile.cpp
  clang/lib/Basic/OpenMPKinds.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CGStmt.cpp
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/Parse/ParseOpenMP.cpp
  clang/lib/Sema/SemaExceptionSpec.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReaderStmt.cpp
  clang/lib/Serialization/ASTWriterStmt.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
  clang/test/OpenMP/metadirective_ast_print.c
  clang/test/OpenMP/metadirective_device_kind_codegen.c
  clang/test/OpenMP/metadirective_device_kind_codegen.cpp
  clang/test/OpenMP/metadirective_empty.cpp
  clang/test/OpenMP/metadirective_implementation_codegen.c
  clang/test/OpenMP/metadirective_implementation_codegen.cpp
  clang/test/OpenMP/metadirective_messages.cpp
  clang/tools/libclang/CIndex.cpp
  clang/tools/libclang/CXCursor.cpp
  flang/lib/Semantics/check-omp-structure.cpp
  llvm/include/llvm/Frontend/OpenMP/OMP.td

Index: llvm/include/llvm/Frontend/OpenMP/OMP.td
===
--- llvm/include/llvm/Frontend/OpenMP/OMP.td
+++ llvm/include/llvm/Frontend/OpenMP/OMP.td
@@ -339,6 +339,7 @@
   let clangClass = "OMPFilterClause";
   let flangClass = "ScalarIntExpr";
 }
+def OMPC_When: Clause<"when"> {}
 
 //===--===//
 // Definition of OpenMP directives
@@ -1701,6 +1702,10 @@
 VersionedClause
   ];
 }
+def OMP_Metadirective : Directive<"metadirective"> {
+  let allowedClauses = [VersionedClause];
+  let allowedOnceClauses = [VersionedClause];
+}
 def OMP_Unknown : Directive<"unknown"> {
   let isDefault = true;
 }
Index: flang/lib/Semantics/check-omp-structure.cpp
===
--- flang/lib/Semantics/check-omp-structure.cpp
+++ flang/lib/Semantics/check-omp-structure.cpp
@@ -1322,6 +1322,7 @@
 CHECK_SIMPLE_CLAUSE(Novariants, OMPC_novariants)
 CHECK_SIMPLE_CLAUSE(Nocontext, OMPC_nocontext)
 CHECK_SIMPLE_CLAUSE(Filter, OMPC_filter)
+CHECK_SIMPLE_CLAUSE(When, OMPC_when)
 
 CHECK_REQ_SCALAR_INT_CLAUSE(Grainsize, OMPC_grainsize)
 CHECK_REQ_SCALAR_INT_CLAUSE(NumTasks, OMPC_num_tasks)
Index: clang/tools/libclang/CXCursor.cpp
===
--- clang/tools/libclang/CXCursor.cpp
+++ clang/tools/libclang/CXCursor.cpp
@@ -643,6 +643,9 @@
   case Stmt::OMPCanonicalLoopClass:
 K = CXCursor_OMPCanonicalLoop;
 break;
+  case Stmt::OMPMetaDirectiveClass:
+K = CXCursor_OMPMetaDirective;
+break;
   case Stmt::OMPParallelDirectiveClass:
 K = CXCursor_OMPParallelDirective;
 break;
Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -5582,6 +5582,8 @@
 return cxstring::createRef("ModuleImport");
   case CXCursor_OMPCanonicalLoop:
 return cxstring::createRef("OMPCanonicalLoop");
+  case CXCursor_OMPMetaDirective:
+return cxstring::createRef("OMPMetaDirective");
   case CXCursor_OMPParallelDirective:
 return cxstring::createRef("OMPParallelDirective");
   case CXCursor_OMPSimdDirective:
Index: clang/test/OpenMP/metadirective_messages.cpp
===
--- /dev/null
+++ clang/test/OpenMP/metadirective_messages.cpp
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -std=c++14 -emit-llvm %s
+
+void foo() {
+#pragma omp metadirective // expected-error {{expected expression}}
+  ;
+#pragma omp metadirective when() // expected-error {{expected valid context selector in when clause}} expected-error {{expected expression}} expected-warning {{expected identifier or string literal describing a context set; set skipped}} expected-note {{context set options are: 'construct' 'device' 'implementation' 'user'}} expected-note {{the ignored set spans until here}}
+  ;
+#pragma omp metadirective when(device{}) // expected-warning {{expected '=' after the context set name "device"; '=' assumed}} expected-warning {{expected identifier or string literal describing a context selector; selector skipped}} expected-note {{context selector options 

[PATCH] D99439: Update @llvm.powi to handle different int sizes for the exponent

2021-09-17 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 added a comment.
Herald added a subscriber: ctetreau.

Just to mention, 'llvm.experimental.constrained.powi' uses i32. Probably not a 
big deal, just small inconsistency with llvm.powi.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99439

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


[PATCH] D109977: LLVM Driver Multicall tool

2021-09-17 Thread Petr Hosek via Phabricator via cfe-commits
phosek added inline comments.



Comment at: llvm/tools/llvm-driver/CMakeLists.txt:17
+
+add_llvm_tool(llvm-driver
+  llvm-driver.cpp

As was already suggested on D104686, I'd prefer naming this just `llvm` so you 
can invoke tools with `llvm name` which doesn't require any additional typing 
compared to `llvm-name`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109977

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


[PATCH] D109847: [DFSan] Add force_zero_label abilist option to DFSan. This can be used as a work-around for overtainting.

2021-09-17 Thread Andrew via Phabricator via cfe-commits
browneee updated this revision to Diff 373274.
browneee marked 3 inline comments as done.
browneee added a comment.

Update comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109847

Files:
  clang/docs/DataFlowSanitizer.rst
  compiler-rt/test/dfsan/Inputs/flags_abilist.txt
  compiler-rt/test/dfsan/force_zero.c
  llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
  llvm/test/Instrumentation/DataFlowSanitizer/Inputs/abilist.txt
  llvm/test/Instrumentation/DataFlowSanitizer/force_zero.ll

Index: llvm/test/Instrumentation/DataFlowSanitizer/force_zero.ll
===
--- /dev/null
+++ llvm/test/Instrumentation/DataFlowSanitizer/force_zero.ll
@@ -0,0 +1,16 @@
+; RUN: opt < %s -dfsan -dfsan-abilist=%S/Inputs/abilist.txt -S | FileCheck %s -DSHADOW_XOR_MASK=87960930222080
+target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-pc-linux-gnu"
+
+define i32 @function_to_force_zero(i32 %0, i32* %1) {
+  ; CHECK-LABEL: define i32 @function_to_force_zero.dfsan
+  ; CHECK: %[[#SHADOW_XOR:]] = xor i64 {{.*}}, [[SHADOW_XOR_MASK]]
+  ; CHECK: %[[#SHADOW_PTR:]] = inttoptr i64 %[[#SHADOW_XOR]] to i8*
+  ; CHECK: %[[#SHADOW_BITCAST:]] = bitcast i8* %[[#SHADOW_PTR]] to i32*
+  ; CHECK: store i32 0, i32* %[[#SHADOW_BITCAST]]
+  ; CHECK: store i32 %{{.*}}
+  store i32 %0, i32* %1, align 4
+  ; CHECK: store i8 0, {{.*}}@__dfsan_retval_tls
+  ; CHECK: ret i32
+  ret i32 %0
+}
Index: llvm/test/Instrumentation/DataFlowSanitizer/Inputs/abilist.txt
===
--- llvm/test/Instrumentation/DataFlowSanitizer/Inputs/abilist.txt
+++ llvm/test/Instrumentation/DataFlowSanitizer/Inputs/abilist.txt
@@ -8,3 +8,5 @@
 fun:custom*=custom
 
 fun:uninstrumented*=uninstrumented
+
+fun:function_to_force_zero=force_zero_labels
Index: llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
===
--- llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
+++ llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
@@ -144,8 +144,17 @@
 // to the "native" (i.e. unsanitized) ABI.  Unless the ABI list contains
 // additional annotations for those functions, a call to one of those functions
 // will produce a warning message, as the labelling behaviour of the function is
-// unknown.  The other supported annotations are "functional" and "discard",
-// which are described below under DataFlowSanitizer::WrapperKind.
+// unknown. The other supported annotations for uninstrumented functions are
+// "functional" and "discard", which are described below under
+// DataFlowSanitizer::WrapperKind.
+// Functions will often be labelled with both "uninstrumented" and one of
+// "functional" or "discard". This will leave the function unchanged by this
+// pass, and create a wrapper function that will call the original.
+//
+// Instrumented functions can also be annotated as "force_zero_labels", which
+// will make all shadow and return values set zero labels.
+// Functions should never be labelled with both "force_zero_labels" and
+// "uninstrumented" or any of the unistrumented wrapper kinds.
 static cl::list ClABIListFiles(
 "dfsan-abilist",
 cl::desc("File listing native ABI functions and how the pass treats them"),
@@ -469,6 +478,7 @@
   getShadowOriginAddress(Value *Addr, Align InstAlignment, Instruction *Pos);
   bool isInstrumented(const Function *F);
   bool isInstrumented(const GlobalAlias *GA);
+  bool isForceZeroLabels(const Function *F);
   FunctionType *getArgsFunctionType(FunctionType *T);
   FunctionType *getTrampolineFunctionType(FunctionType *T);
   TransformedFunction getCustomFunctionType(FunctionType *T);
@@ -541,6 +551,7 @@
   DominatorTree DT;
   DataFlowSanitizer::InstrumentedABI IA;
   bool IsNativeABI;
+  bool IsForceZeroLabels;
   AllocaInst *LabelReturnAlloca = nullptr;
   AllocaInst *OriginReturnAlloca = nullptr;
   DenseMap ValShadowMap;
@@ -571,8 +582,10 @@
   DenseMap CachedCollapsedShadows;
   DenseMap> ShadowElements;
 
-  DFSanFunction(DataFlowSanitizer , Function *F, bool IsNativeABI)
-  : DFS(DFS), F(F), IA(DFS.getInstrumentedABI()), IsNativeABI(IsNativeABI) {
+  DFSanFunction(DataFlowSanitizer , Function *F, bool IsNativeABI,
+bool IsForceZeroLabels)
+  : DFS(DFS), F(F), IA(DFS.getInstrumentedABI()), IsNativeABI(IsNativeABI),
+IsForceZeroLabels(IsForceZeroLabels) {
 DT.recalculate(*F);
   }
 
@@ -1107,6 +1120,10 @@
   return !ABIList.isIn(*GA, "uninstrumented");
 }
 
+bool DataFlowSanitizer::isForceZeroLabels(const Function *F) {
+  return ABIList.isIn(*F, "force_zero_labels");
+}
+
 DataFlowSanitizer::InstrumentedABI DataFlowSanitizer::getInstrumentedABI() {
   return ClArgsABI ? IA_Args : IA_TLS;
 }
@@ -1197,7 +1214,8 @@
 
 // F is called by a 

[PATCH] D109847: [DFSan] Add force_zero_label abilist option to DFSan. This can be used as a work-around for overtainting.

2021-09-17 Thread Andrew via Phabricator via cfe-commits
browneee updated this revision to Diff 373271.
browneee added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109847

Files:
  clang/docs/DataFlowSanitizer.rst
  compiler-rt/test/dfsan/Inputs/flags_abilist.txt
  compiler-rt/test/dfsan/force_zero.c
  llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
  llvm/test/Instrumentation/DataFlowSanitizer/Inputs/abilist.txt
  llvm/test/Instrumentation/DataFlowSanitizer/force_zero.ll

Index: llvm/test/Instrumentation/DataFlowSanitizer/force_zero.ll
===
--- /dev/null
+++ llvm/test/Instrumentation/DataFlowSanitizer/force_zero.ll
@@ -0,0 +1,16 @@
+; RUN: opt < %s -dfsan -dfsan-abilist=%S/Inputs/abilist.txt -S | FileCheck %s -DSHADOW_XOR_MASK=87960930222080
+target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-pc-linux-gnu"
+
+define i32 @function_to_force_zero(i32 %0, i32* %1) {
+  ; CHECK-LABEL: define i32 @function_to_force_zero.dfsan
+  ; CHECK: %[[#SHADOW_XOR:]] = xor i64 {{.*}}, [[SHADOW_XOR_MASK]]
+  ; CHECK: %[[#SHADOW_PTR:]] = inttoptr i64 %[[#SHADOW_XOR]] to i8*
+  ; CHECK: %[[#SHADOW_BITCAST:]] = bitcast i8* %[[#SHADOW_PTR]] to i32*
+  ; CHECK: store i32 0, i32* %[[#SHADOW_BITCAST]]
+  ; CHECK: store i32 %{{.*}}
+  store i32 %0, i32* %1, align 4
+  ; CHECK: store i8 0, {{.*}}@__dfsan_retval_tls
+  ; CHECK: ret i32
+  ret i32 %0
+}
Index: llvm/test/Instrumentation/DataFlowSanitizer/Inputs/abilist.txt
===
--- llvm/test/Instrumentation/DataFlowSanitizer/Inputs/abilist.txt
+++ llvm/test/Instrumentation/DataFlowSanitizer/Inputs/abilist.txt
@@ -8,3 +8,5 @@
 fun:custom*=custom
 
 fun:uninstrumented*=uninstrumented
+
+fun:function_to_force_zero=force_zero_labels
Index: llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
===
--- llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
+++ llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
@@ -144,8 +144,17 @@
 // to the "native" (i.e. unsanitized) ABI.  Unless the ABI list contains
 // additional annotations for those functions, a call to one of those functions
 // will produce a warning message, as the labelling behaviour of the function is
-// unknown.  The other supported annotations are "functional" and "discard",
-// which are described below under DataFlowSanitizer::WrapperKind.
+// unknown. The other supported annotations for uninstrumented functions are
+// "functional" and "discard", which are described below under
+// DataFlowSanitizer::WrapperKind.
+// Functions will often be labelled with both "uninstrumented" and one of
+// "functional" or "discard". This will leave the function unchanged by this
+// pass, and create a wrapper function with that will call the original.
+//
+// Instrumented functions can also be annotated as "force_zero_labels", which
+// will make all shadow stores and label for return values set zero labels.
+// Functions should never be labelled with both "force_zero_labels" and
+// "uninstrumented" or any of the unistrumented wrapper kinds.
 static cl::list ClABIListFiles(
 "dfsan-abilist",
 cl::desc("File listing native ABI functions and how the pass treats them"),
@@ -469,6 +478,7 @@
   getShadowOriginAddress(Value *Addr, Align InstAlignment, Instruction *Pos);
   bool isInstrumented(const Function *F);
   bool isInstrumented(const GlobalAlias *GA);
+  bool isForceZeroLabels(const Function *F);
   FunctionType *getArgsFunctionType(FunctionType *T);
   FunctionType *getTrampolineFunctionType(FunctionType *T);
   TransformedFunction getCustomFunctionType(FunctionType *T);
@@ -541,6 +551,7 @@
   DominatorTree DT;
   DataFlowSanitizer::InstrumentedABI IA;
   bool IsNativeABI;
+  bool IsForceZeroLabels;
   AllocaInst *LabelReturnAlloca = nullptr;
   AllocaInst *OriginReturnAlloca = nullptr;
   DenseMap ValShadowMap;
@@ -571,8 +582,10 @@
   DenseMap CachedCollapsedShadows;
   DenseMap> ShadowElements;
 
-  DFSanFunction(DataFlowSanitizer , Function *F, bool IsNativeABI)
-  : DFS(DFS), F(F), IA(DFS.getInstrumentedABI()), IsNativeABI(IsNativeABI) {
+  DFSanFunction(DataFlowSanitizer , Function *F, bool IsNativeABI,
+bool IsForceZeroLabels)
+  : DFS(DFS), F(F), IA(DFS.getInstrumentedABI()), IsNativeABI(IsNativeABI),
+IsForceZeroLabels(IsForceZeroLabels) {
 DT.recalculate(*F);
   }
 
@@ -1107,6 +1120,10 @@
   return !ABIList.isIn(*GA, "uninstrumented");
 }
 
+bool DataFlowSanitizer::isForceZeroLabels(const Function *F) {
+  return ABIList.isIn(*F, "force_zero_labels");
+}
+
 DataFlowSanitizer::InstrumentedABI DataFlowSanitizer::getInstrumentedABI() {
   return ClArgsABI ? IA_Args : IA_TLS;
 }
@@ -1197,7 +1214,8 @@
 
 // F is called by a wrapped custom function with 

[PATCH] D109981: [Diagnostics] Don't drop a statically set NoWarningAsError flag during option processing

2021-09-17 Thread Wolfgang Pieb via Phabricator via cfe-commits
wolfgangp created this revision.
wolfgangp added a reviewer: dexonsmith.
wolfgangp requested review of this revision.

Fixes PR 51837.

When a -W option is given on the command line, and the corresponding 
diangostic has the NoWarnOnError flag set, the flag is dropped when the 
severity is reevaluated, possibly as a result of a pragma or of command line 
processing.


https://reviews.llvm.org/D109981

Files:
  clang/lib/Basic/Diagnostic.cpp
  clang/test/Lexer/pragma-message.c


Index: clang/test/Lexer/pragma-message.c
===
--- clang/test/Lexer/pragma-message.c
+++ clang/test/Lexer/pragma-message.c
@@ -8,24 +8,25 @@
 // #pragma message messagestring
 //
 // RUN: %clang_cc1 -fsyntax-only -verify -Werror %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Werror -W#pragma-messages %s
 #define STRING2(x) #x
 #define STRING(x) STRING2(x)
-#pragma message(":O I'm a message! " STRING(__LINE__)) // expected-warning 
{{:O I'm a message! 13}}
-#pragma message ":O gcc accepts this! " STRING(__LINE__) // expected-warning 
{{:O gcc accepts this! 14}}
+#pragma message(":O I'm a message! " STRING(__LINE__)) // expected-warning 
{{:O I'm a message! 14}}
+#pragma message ":O gcc accepts this! " STRING(__LINE__) // expected-warning 
{{:O gcc accepts this! 15}}
 
 #pragma message(invalid) // expected-error {{expected string literal in pragma 
message}}
 
 // GCC supports a similar pragma, #pragma GCC warning (which generates a 
warning
 // message) and #pragma GCC error (which generates an error message).
 
-#pragma GCC warning(":O I'm a message! " STRING(__LINE__)) // expected-warning 
{{:O I'm a message! 21}}
-#pragma GCC warning ":O gcc accepts this! " STRING(__LINE__) // 
expected-warning {{:O gcc accepts this! 22}}
+#pragma GCC warning(":O I'm a message! " STRING(__LINE__)) // expected-warning 
{{:O I'm a message! 22}}
+#pragma GCC warning ":O gcc accepts this! " STRING(__LINE__) // 
expected-warning {{:O gcc accepts this! 23}}
 
-#pragma GCC error(":O I'm a message! " STRING(__LINE__)) // expected-error 
{{:O I'm a message! 24}}
-#pragma GCC error ":O gcc accepts this! " STRING(__LINE__) // expected-error 
{{:O gcc accepts this! 25}}
+#pragma GCC error(":O I'm a message! " STRING(__LINE__)) // expected-error 
{{:O I'm a message! 25}}
+#pragma GCC error ":O gcc accepts this! " STRING(__LINE__) // expected-error 
{{:O gcc accepts this! 26}}
 
 #define COMPILE_ERROR(x) _Pragma(STRING2(GCC error(x)))
-COMPILE_ERROR("Compile error at line " STRING(__LINE__) "!"); // 
expected-error {{Compile error at line 28!}}
+COMPILE_ERROR("Compile error at line " STRING(__LINE__) "!"); // 
expected-error {{Compile error at line 29!}}
 
 #pragma message // expected-error {{pragma message requires parenthesized 
string}}
 #pragma GCC warning("" // expected-error {{pragma warning requires 
parenthesized string}}
Index: clang/lib/Basic/Diagnostic.cpp
===
--- clang/lib/Basic/Diagnostic.cpp
+++ clang/lib/Basic/Diagnostic.cpp
@@ -374,6 +374,12 @@
   DiagnosticMapping Mapping = makeUserMapping(Map, L);
   Mapping.setUpgradedFromWarning(WasUpgradedFromWarning);
 
+  // Make sure we propagate the NoWarningAsError flag from an existing
+  // mapping (which may be the default mapping).
+  DiagnosticMapping  = GetCurDiagState()->getOrAddMapping(Diag);
+  Mapping.setNoWarningAsError(Info.hasNoWarningAsError() ||
+  Mapping.hasNoWarningAsError());
+
   // Common case; setting all the diagnostics of a group in one place.
   if ((L.isInvalid() || L == DiagStatesByLoc.getCurDiagStateLoc()) &&
   DiagStatesByLoc.getCurDiagState()) {


Index: clang/test/Lexer/pragma-message.c
===
--- clang/test/Lexer/pragma-message.c
+++ clang/test/Lexer/pragma-message.c
@@ -8,24 +8,25 @@
 // #pragma message messagestring
 //
 // RUN: %clang_cc1 -fsyntax-only -verify -Werror %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Werror -W#pragma-messages %s
 #define STRING2(x) #x
 #define STRING(x) STRING2(x)
-#pragma message(":O I'm a message! " STRING(__LINE__)) // expected-warning {{:O I'm a message! 13}}
-#pragma message ":O gcc accepts this! " STRING(__LINE__) // expected-warning {{:O gcc accepts this! 14}}
+#pragma message(":O I'm a message! " STRING(__LINE__)) // expected-warning {{:O I'm a message! 14}}
+#pragma message ":O gcc accepts this! " STRING(__LINE__) // expected-warning {{:O gcc accepts this! 15}}
 
 #pragma message(invalid) // expected-error {{expected string literal in pragma message}}
 
 // GCC supports a similar pragma, #pragma GCC warning (which generates a warning
 // message) and #pragma GCC error (which generates an error message).
 
-#pragma GCC warning(":O I'm a message! " STRING(__LINE__)) // expected-warning {{:O I'm a message! 21}}
-#pragma GCC warning ":O gcc accepts this! " STRING(__LINE__) // expected-warning {{:O gcc accepts this! 

[PATCH] D109967: Simplify handling of builtin with inline redefinition

2021-09-17 Thread serge via Phabricator via cfe-commits
serge-sans-paille added a comment.

@kees this does fix https://bugs.llvm.org/show_bug.cgi?id=50322  , but only if 
the memcpy "inline definition" is flagged as a `__attribute__((always_inline))`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109967

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


[PATCH] D109977: LLVM Driver Multicall tool

2021-09-17 Thread Mehdi AMINI via Phabricator via cfe-commits
mehdi_amini added a comment.

That's pretty nice! Have you thought about looking into a lit option (triggered 
by a cmake flag maybe) that would change the substitution for the tools that 
are enabled by llvm-driver to use the latter instead when running the tests?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109977

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


[PATCH] D109975: [CMake] Consistently use the LibXml2::LibXml2 target instead of LIBXML2_LIBRARIES

2021-09-17 Thread Markus Böck via Phabricator via cfe-commits
zero9178 added a comment.

In D109975#3006580 , @Quuxplusone 
wrote:

> Serendipitously, I just yesterday upgraded from OSX 10.14 to 10.15, and have 
> been unable to build clang because, even with a totally-empty-and-brand-new 
> build directory, CMake says:
>
>   CMake Error in lib/WindowsManifest/CMakeLists.txt:
> Imported target "LibXml2::LibXml2" includes non-existent path
>   
> "/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/libxml2"
> in its INTERFACE_INCLUDE_DIRECTORIES.  Possible reasons include:
> * The path was deleted, renamed, or moved to another location.
> * An install or uninstall procedure did not complete successfully.
> * The installation package was faulty and references files it does not
> provide.
>   -- Generating done
>   CMake Generate step failed.  Build files cannot be regenerated correctly.
>
> Do you think this PR would fix that issue on OSX 10.15?
> (IMHO it's also weird that OSX would even be trying to build anything with 
> `Windows` in the name.)

Since there is nothing platform specific in the code of WindowsManifest it'd 
make sense to build it on any OS; At the very least for cross compile setups.

I sadly am not very accustomed to Macs so I don't know the details, but I don't 
think this patch would change anything about your situation.

Could it maybe be related to the `CMAKE_OSX_SYSROOT` variable somehow? CMake 
seems to use it to lookup packages from the platform SDK.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109975

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


[PATCH] D109632: [clang] de-duplicate methods from AST files

2021-09-17 Thread Richard Howell via Phabricator via cfe-commits
rmaz added inline comments.



Comment at: clang/include/clang/Sema/Sema.h:1434-1436
+bool addMethod(ObjCMethodDecl *Method) {
+  return AddedMethods.insert(Method).second;
+}

dexonsmith wrote:
> Hmm, I was imagining that the set would be more encapsulated than this, not 
> just stored in the same place.
> 
> I'm wondering if the following could be done in a prep commit:
> 
> - Change Sema::addMethodToGlobalList to a private member function of 
> GlobalMethodPool.
> - Make GlobalMethodPool::insert private
> - Add `GlobalMethodPool::addMethod(ObjCMethodDecl*,bool,bool)`, which does 
> the second half of Sema::AddMethodToGlobalPool (the parts that don't need 
> Sema's other fields), and change the latter to call the former.
> 
> WDYT?
Definitely neater, will take a look at this later today.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109632

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


[PATCH] D109979: [Clang] [Fix] Clang build fails when build directory contains space character

2021-09-17 Thread Shivam Gupta via Phabricator via cfe-commits
xgupta created this revision.
xgupta added reviewers: aaron.ballman, t.p.northover.
Herald added a subscriber: mgorny.
xgupta requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Clang build fails when build directory contains space character.

Error messages:

[ 95%] Linking CXX executable ../../../../bin/clang
clang: error: no such file or directory: 
'Space/Net/llvm/Build/tools/clang/tools/driver/Info.plist'
make[2]: *** [bin/clang-14] Error 1
make[1]: *** [tools/clang/tools/driver/CMakeFiles/clang.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs

The path name is actually:

  'Dev Space/Net/llvm/Build/tools/clang/tools/driver/Info.plist'

Bugzilla issue - https://bugs.llvm.org/show_bug.cgi?id=51884
Reporter and patch author - Brain Swift 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D109979

Files:
  clang/tools/driver/CMakeLists.txt


Index: clang/tools/driver/CMakeLists.txt
===
--- clang/tools/driver/CMakeLists.txt
+++ clang/tools/driver/CMakeLists.txt
@@ -82,7 +82,7 @@
   set(TOOL_INFO_PLIST_OUT "${CMAKE_CURRENT_BINARY_DIR}/${TOOL_INFO_PLIST}")
   target_link_libraries(clang
 PRIVATE
-"-Wl,-sectcreate,__TEXT,__info_plist,${TOOL_INFO_PLIST_OUT}")
+"-Wl,-sectcreate,__TEXT,__info_plist,\"${TOOL_INFO_PLIST_OUT}\"")
   configure_file("${TOOL_INFO_PLIST}.in" "${TOOL_INFO_PLIST_OUT}" @ONLY)
 
   set(TOOL_INFO_UTI)


Index: clang/tools/driver/CMakeLists.txt
===
--- clang/tools/driver/CMakeLists.txt
+++ clang/tools/driver/CMakeLists.txt
@@ -82,7 +82,7 @@
   set(TOOL_INFO_PLIST_OUT "${CMAKE_CURRENT_BINARY_DIR}/${TOOL_INFO_PLIST}")
   target_link_libraries(clang
 PRIVATE
-"-Wl,-sectcreate,__TEXT,__info_plist,${TOOL_INFO_PLIST_OUT}")
+"-Wl,-sectcreate,__TEXT,__info_plist,\"${TOOL_INFO_PLIST_OUT}\"")
   configure_file("${TOOL_INFO_PLIST}.in" "${TOOL_INFO_PLIST_OUT}" @ONLY)
 
   set(TOOL_INFO_UTI)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D109707: [HIP] [AlwaysInliner] Disable AlwaysInliner to eliminate undefined symbols

2021-09-17 Thread Anshil Gandhi via Phabricator via cfe-commits
gandhi21299 updated this revision to Diff 373257.
gandhi21299 marked an inline comment as done.
gandhi21299 added a comment.

- Prevent removing alias if the GlobalAlias does not have internal linkage


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109707

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/CodeGenCUDA/amdgpu-alias-undef-symbols.cu
  llvm/lib/Target/AMDGPU/AMDGPUAlwaysInlinePass.cpp


Index: llvm/lib/Target/AMDGPU/AMDGPUAlwaysInlinePass.cpp
===
--- llvm/lib/Target/AMDGPU/AMDGPUAlwaysInlinePass.cpp
+++ llvm/lib/Target/AMDGPU/AMDGPUAlwaysInlinePass.cpp
@@ -93,6 +93,8 @@
 
   for (GlobalAlias  : M.aliases()) {
 if (Function* F = dyn_cast(A.getAliasee())) {
+  if (!A.hasInternalLinkage())
+continue;
   A.replaceAllUsesWith(F);
   AliasesToRemove.push_back();
 }
Index: clang/test/CodeGenCUDA/amdgpu-alias-undef-symbols.cu
===
--- /dev/null
+++ clang/test/CodeGenCUDA/amdgpu-alias-undef-symbols.cu
@@ -0,0 +1,16 @@
+// RUN: %clang --offload-arch=gfx906 --cuda-device-only -x hip -emit-llvm -S 
-o - %s \
+// RUN:   -fgpu-rdc -O3 -mllvm -amdgpu-early-inline-all=true -mllvm 
-amdgpu-function-calls=false | \
+// RUN:   FileCheck %s
+
+#include "Inputs/cuda.h"
+
+// CHECK: %struct.B = type { i8 }
+struct B {
+
+  // CHECK: @_ZN1BC1Ei = hidden unnamed_addr alias void (%struct.B*, i32), 
void (%struct.B*, i32)* @_ZN1BC2Ei
+  __device__ B(int x);
+};
+
+__device__ B::B(int x) {
+
+}
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -5084,9 +5084,9 @@
   }
 
   // Enable -mconstructor-aliases except on darwin, where we have to work 
around
-  // a linker bug (see ), and CUDA/AMDGPU device code,
-  // where aliases aren't supported.
-  if (!RawTriple.isOSDarwin() && !RawTriple.isNVPTX() && !RawTriple.isAMDGPU())
+  // a linker bug (see ), and CUDA device code, where
+  // aliases aren't supported.
+  if (!RawTriple.isOSDarwin() && !RawTriple.isNVPTX())
 CmdArgs.push_back("-mconstructor-aliases");
 
   // Darwin's kernel doesn't support guard variables; just die if we


Index: llvm/lib/Target/AMDGPU/AMDGPUAlwaysInlinePass.cpp
===
--- llvm/lib/Target/AMDGPU/AMDGPUAlwaysInlinePass.cpp
+++ llvm/lib/Target/AMDGPU/AMDGPUAlwaysInlinePass.cpp
@@ -93,6 +93,8 @@
 
   for (GlobalAlias  : M.aliases()) {
 if (Function* F = dyn_cast(A.getAliasee())) {
+  if (!A.hasInternalLinkage())
+continue;
   A.replaceAllUsesWith(F);
   AliasesToRemove.push_back();
 }
Index: clang/test/CodeGenCUDA/amdgpu-alias-undef-symbols.cu
===
--- /dev/null
+++ clang/test/CodeGenCUDA/amdgpu-alias-undef-symbols.cu
@@ -0,0 +1,16 @@
+// RUN: %clang --offload-arch=gfx906 --cuda-device-only -x hip -emit-llvm -S -o - %s \
+// RUN:   -fgpu-rdc -O3 -mllvm -amdgpu-early-inline-all=true -mllvm -amdgpu-function-calls=false | \
+// RUN:   FileCheck %s
+
+#include "Inputs/cuda.h"
+
+// CHECK: %struct.B = type { i8 }
+struct B {
+
+  // CHECK: @_ZN1BC1Ei = hidden unnamed_addr alias void (%struct.B*, i32), void (%struct.B*, i32)* @_ZN1BC2Ei
+  __device__ B(int x);
+};
+
+__device__ B::B(int x) {
+
+}
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -5084,9 +5084,9 @@
   }
 
   // Enable -mconstructor-aliases except on darwin, where we have to work around
-  // a linker bug (see ), and CUDA/AMDGPU device code,
-  // where aliases aren't supported.
-  if (!RawTriple.isOSDarwin() && !RawTriple.isNVPTX() && !RawTriple.isAMDGPU())
+  // a linker bug (see ), and CUDA device code, where
+  // aliases aren't supported.
+  if (!RawTriple.isOSDarwin() && !RawTriple.isNVPTX())
 CmdArgs.push_back("-mconstructor-aliases");
 
   // Darwin's kernel doesn't support guard variables; just die if we
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D109707: [HIP] [AlwaysInliner] Disable AlwaysInliner to eliminate undefined symbols

2021-09-17 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added a comment.

In D109707#3004869 , @gandhi21299 
wrote:

> Internal linkage detection works great for our purposes but it causes a 
> failure in llvm/test/CodeGen/AMDGPU/inline-calls.ll due to `@func_alias` 
> unable to be casted into a `Function`. If we pass through that, the 
> `@kernel3` causes the error: `scalar registers (98) exceeds limit (96) in 
> function 'kernel3'`.

That almost sounds like using the wrong subtarget for the alias




Comment at: llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp:694
 if (EarlyInlineAll && !EnableFunctionCalls)
-  PM.addPass(AMDGPUAlwaysInlinePass());
+  PM.addPass(AMDGPUAlwaysInlinePass(false));
   });

This needs a backend test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109707

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


[PATCH] D109975: [CMake] Consistently use the LibXml2::LibXml2 target instead of LIBXML2_LIBRARIES

2021-09-17 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone added a comment.
Herald added a subscriber: JDevlieghere.

Serendipitously, I just yesterday upgraded from OSX 10.14 to 10.15, and have 
been unable to build clang because, even with a totally-empty-and-brand-new 
build directory, CMake says:

  CMake Error in lib/WindowsManifest/CMakeLists.txt:
Imported target "LibXml2::LibXml2" includes non-existent path
  
"/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/libxml2"
in its INTERFACE_INCLUDE_DIRECTORIES.  Possible reasons include:
* The path was deleted, renamed, or moved to another location.
* An install or uninstall procedure did not complete successfully.
* The installation package was faulty and references files it does not
provide.
  -- Generating done
  CMake Generate step failed.  Build files cannot be regenerated correctly.

Do you think this PR would fix that issue on OSX 10.15?
(IMHO it's also weird that OSX would even be trying to build anything with 
`Windows` in the name.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109975

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


[PATCH] D109977: LLVM Driver Multicall tool

2021-09-17 Thread Chris Bieneman via Phabricator via cfe-commits
beanz created this revision.
beanz added reviewers: leonardchan, phosek, MaskRay, compnerd, mehdi_amini.
Herald added subscribers: rupprecht, mgorny.
Herald added a reviewer: JDevlieghere.
Herald added a reviewer: alexander-shaposhnikov.
Herald added a reviewer: rupprecht.
Herald added a reviewer: jhenderson.
beanz requested review of this revision.
Herald added projects: clang, LLVM.
Herald added a subscriber: cfe-commits.

This patch adds an llvm-driver multicall tool that can combine multiple
LLVM-based tools. The build infrastructure is enabled for a tool by
adding the `GENERATE_DRIVER` option to the `add_llvm_executable` CMake
call, and changing the tool's `main` function to a canonicalized
`tool_name_main` format (i.e. llvm_ar_main, clang_main, etc...).

As currently implemented llvm-driver contains dsymutil, llvm-ar,
llvm-cxxfilt, llvm-objcopy, and clang (if clang is included in the
build).

llvm-driver can be disabled from builds by setting
LLVM_TOOL_LLVM_DRIVER_BUILD=Off.

There are several limitations in the current implementation, which can
be addressed in subsequent patches:

(1) the multicall binary cannot currently properly handle
multi-dispatch tools. This means symlinking llvm-ranlib to llvm-driver
will not properly result in llvm-ar's main being called.
(2) the multicall binary cannot be comprised of tools containing
conflicting cl::opt options as the global cl::opt option list cannot
contain duplicates.

These limitations can be addressed in subsequent patches.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D109977

Files:
  clang/cmake/modules/AddClang.cmake
  clang/tools/driver/CMakeLists.txt
  clang/tools/driver/driver.cpp
  llvm/cmake/driver-template.cpp
  llvm/cmake/modules/AddLLVM.cmake
  llvm/test/CMakeLists.txt
  llvm/test/lit.cfg.py
  llvm/test/lit.site.cfg.py.in
  llvm/test/tools/llvm-driver/help-passthrough.test
  llvm/test/tools/llvm-driver/help.test
  llvm/test/tools/llvm-driver/symlink-call.test
  llvm/tools/CMakeLists.txt
  llvm/tools/dsymutil/CMakeLists.txt
  llvm/tools/dsymutil/dsymutil.cpp
  llvm/tools/llvm-ar/CMakeLists.txt
  llvm/tools/llvm-ar/llvm-ar.cpp
  llvm/tools/llvm-cxxfilt/CMakeLists.txt
  llvm/tools/llvm-cxxfilt/llvm-cxxfilt.cpp
  llvm/tools/llvm-driver/CMakeLists.txt
  llvm/tools/llvm-driver/llvm-driver.cpp
  llvm/tools/llvm-objcopy/CMakeLists.txt
  llvm/tools/llvm-objcopy/llvm-objcopy.cpp

Index: llvm/tools/llvm-objcopy/llvm-objcopy.cpp
===
--- llvm/tools/llvm-objcopy/llvm-objcopy.cpp
+++ llvm/tools/llvm-objcopy/llvm-objcopy.cpp
@@ -401,7 +401,7 @@
   return Error::success();
 }
 
-int main(int argc, char **argv) {
+int llvm_objcopy_main(int argc, char **argv) {
   InitLLVM X(argc, argv);
   ToolName = argv[0];
 
Index: llvm/tools/llvm-objcopy/CMakeLists.txt
===
--- llvm/tools/llvm-objcopy/CMakeLists.txt
+++ llvm/tools/llvm-objcopy/CMakeLists.txt
@@ -43,6 +43,7 @@
   ObjcopyOptsTableGen
   InstallNameToolOptsTableGen
   StripOptsTableGen
+  GENERATE_DRIVER
   )
 
 add_llvm_tool_symlink(llvm-install-name-tool llvm-objcopy)
Index: llvm/tools/llvm-driver/llvm-driver.cpp
===
--- /dev/null
+++ llvm/tools/llvm-driver/llvm-driver.cpp
@@ -0,0 +1,61 @@
+//===-- llvm-driver.cpp ---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "llvm/ADT/StringRef.h"
+#include "llvm/ADT/StringSwitch.h"
+#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/ErrorHandling.h"
+#include "llvm/Support/Path.h"
+#include "llvm/Support/WithColor.h"
+
+using namespace llvm;
+
+#define LLVM_DRIVER_TOOL(tool, entry) int entry##_main(int argc, char **argv);
+#include "LLVMDriverTools.def"
+
+// This function handles the case of not recognizing the tool requested, or if
+// --help or --version are passed directly to llvm-driver.
+int UnknownMain(int Argc, char **Argv) {
+  cl::OptionCategory LLVMDriverCategory("llvm-driver options");
+#define LLVM_DRIVER_TOOL(tool, entry)  \
+  cl::SubCommand entry##Subcommand(tool, tool);
+#include "LLVMDriverTools.def"
+
+  cl::HideUnrelatedOptions(LLVMDriverCategory);
+  cl::ParseCommandLineOptions(Argc, Argv, "llvm compiler driver\n");
+  llvm_unreachable("We should never get here, parsing should always exit.");
+  return 1;
+}
+
+int main(int Argc, char **Argv) {
+  llvm::StringRef LaunchedTool = sys::path::stem(Argv[0]);
+  // If the driver is launched directly.
+  int PassThroughArgC = Argc;
+  char **PassThroughArgV = Argv;
+  bool ConsumeFirstArg = false;
+  if (LaunchedTool == "llvm-driver") {

[PATCH] D103938: Diagnose -Wunused-value in constant evaluation context

2021-09-17 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

There were a few behavioral changes to tests that I had questions about. Also, 
can you add an additional test case that shows the behavior when the left 
operand of the comma expression is volatile (or do we already have that covered 
and I missed it)? e.g.,

  int func() {
volatile int *ip = (volatile int *)0xFEEDFACE;
return (*ip, 1);
  }

(In this case, we shouldn't diagnose that the left operand has no effect 
because reading a volatile variable is an operation with a side effect.)




Comment at: clang/test/CodeCompletion/pragma-macro-token-caching.c:15
 Outer(__extension__({ _Pragma(2) })); // expected-error {{_Pragma takes a 
parenthesized string literal}}
-param; // expected-warning {{expression result unused}}
 }

Why did we lose this diagnostic?



Comment at: clang/test/Sema/exprs.c:19
   if (0) {
-0 / (0 ? 1 : 0); // expected-warning {{expression result unused}}
   }

Why did we lose this diagnostic (and the above comment about not changing the 
test)?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103938

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


[PATCH] D109632: [clang] de-duplicate methods from AST files

2021-09-17 Thread Richard Howell via Phabricator via cfe-commits
rmaz added a comment.

In D109632#3005512 , @vsapsai wrote:

> Thanks for the explanation! I'm still curious to reproduce the problem 
> locally and have created a test case generator 
> https://gist.github.com/vsapsai/f9d3603dde95eebd23248da4d7b4f5ec It creates a 
> chain of .m -> Synthesized9 -> Synthesized8 -> Synthesized7 ->... Does it 
> represent the structure of the code you are dealing with?

The case we have is more like:

  .m   -> A -> long list of partially shared deps -> Foundation
   -> B -> long list of partially shared deps -> Foundation
   -> C -> long list of partially shared deps -> Foundation
    * a few hundred

So we have a file that imports a lot of modules, in the hundreds. Each of those 
modules has multiple ObjC interfaces with `-(id)init NS_UNAVAILABLE` and 
imports Foundation, UIKit and also a large number of libraries that are shared 
across the top level imports. This will result in A.pcm, B.pcm and C.pcm 
including hundreds or thousands of init decls that are the same, from system 
frameworks or whatever modules are shared between the top level imports.

IIUC the code currently serializes the entire ObjCMethodList for a module for 
every declared method, including the methods that are not part of that module. 
When deserializing we don't descend into module dependencies as the entire 
method list would already be deserialized, but that doesn't help for modules 
that aren't directly dependent. Is this right? If so it seems another approach 
could be to only serialize the methods declared in that module itself, and 
during deserialization we would have to load the methods from all dependent 
modules.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109632

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


[PATCH] D109967: Simplify handling of builtin with inline redefinition

2021-09-17 Thread Kees Cook via Phabricator via cfe-commits
kees added a comment.

Does this address https://bugs.llvm.org/show_bug.cgi?id=50322 ? (I assume this 
is a new version of https://reviews.llvm.org/D92657 ?)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109967

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


[PATCH] D109707: [HIP] [AlwaysInliner] Disable AlwaysInliner to eliminate undefined symbols

2021-09-17 Thread Anshil Gandhi via Phabricator via cfe-commits
gandhi21299 added a comment.

@yaxunl I think we have two ways to go from here:

1. If appropriate, reset the maximum number of scalar registers allowed in 
`@kernel3` (inline-calls.ll) to fix the test.
2. Determine a stronger condition for inlining.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109707

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


[PATCH] D109975: [CMake] Consistently use the LibXml2::LibXml2 target instead of LIBXML2_LIBRARIES

2021-09-17 Thread Markus Böck via Phabricator via cfe-commits
zero9178 created this revision.
zero9178 added reviewers: phosek, hans, MaskRay, compnerd.
Herald added subscribers: arphaman, mgorny.
zero9178 requested review of this revision.
Herald added projects: clang, LLDB.
Herald added subscribers: lldb-commits, cfe-commits.

Linking against the LibXml2::LibXml2 target has the advantage of not only 
importing the library, but also adding the include path as well as any 
definitions the library requires. In case of a static build of libxml2, eg. a 
define is set on Windows to remove any DLL imports and export.

LLVM already makes use of the target, but c-index-test and lldb were still 
linking against the library only.

The workaround for Mac OS-X that I removed seems to have also been made 
redundant since https://reviews.llvm.org/D84563 I believe


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D109975

Files:
  clang/tools/c-index-test/CMakeLists.txt
  lldb/source/Host/CMakeLists.txt


Index: lldb/source/Host/CMakeLists.txt
===
--- lldb/source/Host/CMakeLists.txt
+++ lldb/source/Host/CMakeLists.txt
@@ -137,7 +137,7 @@
   list(APPEND EXTRA_LIBS kvm)
 endif()
 if (LLDB_ENABLE_LIBXML2)
-  list(APPEND EXTRA_LIBS ${LIBXML2_LIBRARIES})
+  list(APPEND EXTRA_LIBS LibXml2::LibXml2)
 endif()
 if (HAVE_LIBDL)
   list(APPEND EXTRA_LIBS ${CMAKE_DL_LIBS})
Index: clang/tools/c-index-test/CMakeLists.txt
===
--- clang/tools/c-index-test/CMakeLists.txt
+++ clang/tools/c-index-test/CMakeLists.txt
@@ -40,12 +40,7 @@
 
 # If libxml2 is available, make it available for c-index-test.
 if (CLANG_HAVE_LIBXML)
-  if ((CMAKE_OSX_SYSROOT) AND (EXISTS 
${CMAKE_OSX_SYSROOT}/${LIBXML2_INCLUDE_DIR}))
-include_directories(SYSTEM ${CMAKE_OSX_SYSROOT}/${LIBXML2_INCLUDE_DIR})
-  else()
-include_directories(SYSTEM ${LIBXML2_INCLUDE_DIR})
-  endif()
-  target_link_libraries(c-index-test PRIVATE ${LIBXML2_LIBRARIES})
+  target_link_libraries(c-index-test PRIVATE LibXml2::LibXml2)
 endif()
 
 if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)


Index: lldb/source/Host/CMakeLists.txt
===
--- lldb/source/Host/CMakeLists.txt
+++ lldb/source/Host/CMakeLists.txt
@@ -137,7 +137,7 @@
   list(APPEND EXTRA_LIBS kvm)
 endif()
 if (LLDB_ENABLE_LIBXML2)
-  list(APPEND EXTRA_LIBS ${LIBXML2_LIBRARIES})
+  list(APPEND EXTRA_LIBS LibXml2::LibXml2)
 endif()
 if (HAVE_LIBDL)
   list(APPEND EXTRA_LIBS ${CMAKE_DL_LIBS})
Index: clang/tools/c-index-test/CMakeLists.txt
===
--- clang/tools/c-index-test/CMakeLists.txt
+++ clang/tools/c-index-test/CMakeLists.txt
@@ -40,12 +40,7 @@
 
 # If libxml2 is available, make it available for c-index-test.
 if (CLANG_HAVE_LIBXML)
-  if ((CMAKE_OSX_SYSROOT) AND (EXISTS ${CMAKE_OSX_SYSROOT}/${LIBXML2_INCLUDE_DIR}))
-include_directories(SYSTEM ${CMAKE_OSX_SYSROOT}/${LIBXML2_INCLUDE_DIR})
-  else()
-include_directories(SYSTEM ${LIBXML2_INCLUDE_DIR})
-  endif()
-  target_link_libraries(c-index-test PRIVATE ${LIBXML2_LIBRARIES})
+  target_link_libraries(c-index-test PRIVATE LibXml2::LibXml2)
 endif()
 
 if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D109847: [DFSan] Add force_zero_label abilist option to DFSan. This can be used as a work-around for overtainting.

2021-09-17 Thread Matt Morehouse via Phabricator via cfe-commits
morehouse accepted this revision.
morehouse added inline comments.
This revision is now accepted and ready to land.



Comment at: clang/docs/DataFlowSanitizer.rst:141
+For instrumented functions, the ABI list supports a ``force_zero_labels``
+category, which will make all shadow stores and label for return values set
+zero labels. Functions should never be labelled with both ``force_zero_labels``




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109847

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


[PATCH] D109862: Don't diagnose unused but set when the Cleanup attribute is used.

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

LGTM, thank you!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109862

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


[PATCH] D109609: [C++4OpenCL] Add support for multiple address spaced destructors

2021-09-17 Thread Ronan Keryell via Phabricator via cfe-commits
keryell added a comment.

In D109609#3006225 , @olestrohm wrote:

> 



> re: @keryell 
> This might work, though I have no idea how that `SomeAPIReturningAddrSpace` 
> would work, since at this point the variable would likely be cast to be in 
> __generic addrspace.
> Also I'm not sure how that would interact with deleted destructors.

You mean for example say that the constructor in `global` address-space would 
have some definition but the constructor in `constant` is deleted?
Ouch. You are killing my suggestion. :-)


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

https://reviews.llvm.org/D109609

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


[PATCH] D109967: Simplify handling of builtin with inline redefinition

2021-09-17 Thread serge via Phabricator via cfe-commits
serge-sans-paille created this revision.
serge-sans-paille added reviewers: rnk, nickdesaulniers, efriedma.
serge-sans-paille requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

It is a common practice in glibc header to provide an inline redefinition of an
existing function. It is especially the case for fortified function.

Clang currently has an imperfect approach to the problem, using a combination of
trivially recursive function detection and noinline attribute.

Simplify the logic by suffixing these functions by `.inline` during codegen, so
that they are not recognized as builtin by llvm.

After that patch, clang passes all tests from:

  https://github.com/serge-sans-paille/fortify-test-suite


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D109967

Files:
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/test/CodeGen/memcpy-inline-builtin.c
  clang/test/CodeGen/memcpy-no-nobuiltin-if-not-emitted.c
  clang/test/CodeGen/memcpy-nobuiltin.c
  clang/test/CodeGen/pr9614.c

Index: clang/test/CodeGen/pr9614.c
===
--- clang/test/CodeGen/pr9614.c
+++ clang/test/CodeGen/pr9614.c
@@ -32,14 +32,14 @@
 
 // CHECK-LABEL: define{{.*}} void @f()
 // CHECK: call void @foo()
-// CHECK: call i32 @abs(i32 0)
+// CHECK: call i32 @abs(i32 %0)
 // CHECK: call i8* @strrchr(
 // CHECK: call void @llvm.prefetch.p0i8(
 // CHECK: call i8* @memchr(
 // CHECK: ret void
 
 // CHECK: declare void @foo()
-// CHECK: declare i32 @abs(i32
 // CHECK: declare i8* @strrchr(i8*, i32)
 // CHECK: declare i8* @memchr(
+// CHECK: declare i32 @abs(i32
 // CHECK: declare void @llvm.prefetch.p0i8(
Index: clang/test/CodeGen/memcpy-nobuiltin.c
===
--- clang/test/CodeGen/memcpy-nobuiltin.c
+++ clang/test/CodeGen/memcpy-nobuiltin.c
@@ -4,7 +4,8 @@
 //
 // CHECK-WITH-DECL-NOT: @llvm.memcpy
 // CHECK-NO-DECL: @llvm.memcpy
-// CHECK-SELF-REF-DECL: @llvm.memcpy
+// CHECK-SELF-REF-DECL-LABEL: define dso_local i8* @memcpy.inline
+// CHECK-SELF-REF-DECL:   @memcpy(
 //
 #include 
 void test(void *dest, void const *from, size_t n) {
Index: clang/test/CodeGen/memcpy-no-nobuiltin-if-not-emitted.c
===
--- clang/test/CodeGen/memcpy-no-nobuiltin-if-not-emitted.c
+++ /dev/null
@@ -1,25 +0,0 @@
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown -S -emit-llvm -o - %s | FileCheck %s
-//
-// Verifies that clang doesn't mark an inline builtin definition as `nobuiltin`
-// if the builtin isn't emittable.
-
-typedef unsigned long size_t;
-
-// always_inline is used so clang will emit this body. Otherwise, we need >=
-// -O1.
-#define AVAILABLE_EXTERNALLY extern inline __attribute__((always_inline)) \
-__attribute__((gnu_inline))
-
-AVAILABLE_EXTERNALLY void *memcpy(void *a, const void *b, size_t c) {
-  return __builtin_memcpy(a, b, c);
-}
-
-// CHECK-LABEL: define{{.*}} void @foo
-void foo(void *a, const void *b, size_t c) {
-  // Clang will always _emit_ this as memcpy. LLVM turns it into @llvm.memcpy
-  // later on if optimizations are enabled.
-  // CHECK: call i8* @memcpy
-  memcpy(a, b, c);
-}
-
-// CHECK-NOT: nobuiltin
Index: clang/test/CodeGen/memcpy-inline-builtin.c
===
--- /dev/null
+++ clang/test/CodeGen/memcpy-inline-builtin.c
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -S -emit-llvm -o - %s -disable-llvm-passes | FileCheck %s
+//
+// Verifies that clang detects memcpy inline version and use it correctly.
+
+typedef unsigned long size_t;
+
+// always_inline is used so clang will emit this body. Otherwise, we need >= -O1.
+#define AVAILABLE_EXTERNALLY extern inline __attribute__((always_inline)) \
+__attribute__((gnu_inline))
+
+// Clang recognizes an inline builtin and renames it to prevent conflict with
+// builtins.
+
+AVAILABLE_EXTERNALLY void *memcpy(void *a, const void *b, size_t c) {
+  return __builtin_memcpy(a, b, c);
+}
+
+// CHECK-LABEL: define{{.*}} void @foo
+void foo(void *a, const void *b, size_t c) {
+  // CHECK: call i8* @memcpy.inline
+  memcpy(a, b, c);
+}
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -1293,8 +1293,10 @@
   case MultiVersionKind::None:
 llvm_unreachable("None multiversion type isn't valid here");
   }
+
 }
 
+
   // Make unique name for device side static file-scope variable for HIP.
   if (CGM.getContext().shouldExternalizeStaticVar(ND) &&
   CGM.getLangOpts().GPURelocatableDeviceCode &&
@@ -3146,6 +3148,7 @@
   if (getFunctionLinkage(GD) != llvm::Function::AvailableExternallyLinkage)
 return true;
   const auto *F = cast(GD.getDecl());
+
   if 

[PATCH] D109609: [C++4OpenCL] Add support for multiple address spaced destructors

2021-09-17 Thread Ole Strohm via Phabricator via cfe-commits
olestrohm updated this revision to Diff 373225.

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

https://reviews.llvm.org/D109609

Files:
  clang/include/clang/AST/DeclCXX.h
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/DeclCXX.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaLookup.cpp
  clang/test/SemaOpenCLCXX/addrspace-destructors.clcpp

Index: clang/test/SemaOpenCLCXX/addrspace-destructors.clcpp
===
--- /dev/null
+++ clang/test/SemaOpenCLCXX/addrspace-destructors.clcpp
@@ -0,0 +1,50 @@
+// RUN: %clang_cc1 %s -pedantic -ast-dump | FileCheck %s
+
+// CHECK: CXXDestructorDecl {{.*}} used ~ExactDtor 'void () __private noexcept'
+struct ExactDtor {
+ ~ExactDtor() __private;
+};
+
+// CHECK: CXXDestructorDecl
+// CHECK-NOT: used
+// CHECK-SAME: ~OverloadedDtor 'void () __generic'
+// CHECK: CXXDestructorDecl {{.*}} used ~OverloadedDtor 'void () __private noexcept'
+struct OverloadedDtor {
+ ~OverloadedDtor() __generic;
+ ~OverloadedDtor() __private;
+};
+
+// CHECK: CXXDestructorDecl
+// CHECK-NOT: used
+// CHECK-SAME: ~ImplicitDtor 'void () __global'
+// CHECK: CXXDestructorDecl {{.*}} implicit used ~ImplicitDtor 'void () __generic noexcept'
+struct ImplicitDtor {
+~ImplicitDtor() __global;
+};
+
+// CHECK: CXXDestructorDecl {{.*}} used ~Templated 'void () __generic noexcept'
+// CHECK: CXXDestructorDecl
+// CHECK-NOT: used
+// CHECK-SAME: ~Templated 'void () __global'
+template 
+struct Templated {
+~Templated() __generic;
+~Templated() __global;
+};
+
+// CHECK: CXXDestructorDecl {{.*}} used ~BothUsed 'void () __private noexcept'
+// CHECK: CXXDestructorDecl {{.*}} used ~BothUsed 'void () __global noexcept'
+struct BothUsed {
+~BothUsed() __private;
+~BothUsed() __global;
+};
+
+__global BothUsed g_inheriting;
+
+kernel void k() {
+__private ExactDtor exact;
+__private OverloadedDtor overloaded;
+__private ImplicitDtor implicit;
+__private Templated templated;
+__private BothUsed inheriting;
+}
Index: clang/lib/Sema/SemaLookup.cpp
===
--- clang/lib/Sema/SemaLookup.cpp
+++ clang/lib/Sema/SemaLookup.cpp
@@ -3054,13 +3054,10 @@
   Functions.append(Operators.begin(), Operators.end());
 }
 
-Sema::SpecialMemberOverloadResult Sema::LookupSpecialMember(CXXRecordDecl *RD,
-   CXXSpecialMember SM,
-   bool ConstArg,
-   bool VolatileArg,
-   bool RValueThis,
-   bool ConstThis,
-   bool VolatileThis) {
+Sema::SpecialMemberOverloadResult
+Sema::LookupSpecialMember(CXXRecordDecl *RD, CXXSpecialMember SM, bool ConstArg,
+  bool VolatileArg, bool RValueThis, bool ConstThis,
+  bool VolatileThis, LangAS ASThis) {
   assert(CanDeclareSpecialMemberFunction(RD) &&
  "doing special member lookup into record that isn't fully complete");
   RD = RD->getDefinition();
@@ -3082,6 +3079,7 @@
   ID.AddInteger(RValueThis);
   ID.AddInteger(ConstThis);
   ID.AddInteger(VolatileThis);
+  ID.AddInteger((unsigned)ASThis);
 
   void *InsertPoint;
   SpecialMemberOverloadResultEntry *Result =
@@ -3096,12 +3094,12 @@
   SpecialMemberCache.InsertNode(Result, InsertPoint);
 
   if (SM == CXXDestructor) {
-if (RD->needsImplicitDestructor()) {
+if (RD->needsImplicitDestructor(ASThis)) {
   runWithSufficientStackSpace(RD->getLocation(), [&] {
 DeclareImplicitDestructor(RD);
   });
 }
-CXXDestructorDecl *DD = RD->getDestructor();
+CXXDestructorDecl *DD = RD->getDestructor(ASThis);
 Result->setMethod(DD);
 Result->setKind(DD && !DD->isDeleted()
 ? SpecialMemberOverloadResult::Success
@@ -3362,10 +3360,11 @@
 /// CXXRecordDecl::getDestructor().
 ///
 /// \returns The destructor for this class.
-CXXDestructorDecl *Sema::LookupDestructor(CXXRecordDecl *Class) {
+CXXDestructorDecl *Sema::LookupDestructor(CXXRecordDecl *Class, LangAS AS) {
   return cast(LookupSpecialMember(Class, CXXDestructor,
- false, false, false,
- false, false).getMethod());
+ false, false, false, false,
+ false, AS)
+ .getMethod());
 }
 
 /// LookupLiteralOperator - Determine which literal operator should be used for
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ 

[PATCH] D109609: [C++4OpenCL] Add support for multiple address spaced destructors

2021-09-17 Thread Ole Strohm via Phabricator via cfe-commits
olestrohm marked 2 inline comments as done.
olestrohm added inline comments.



Comment at: clang/lib/Sema/SemaLookup.cpp:3082
   ID.AddInteger(VolatileThis);
+  ID.AddInteger((unsigned)AS);
 

Anastasia wrote:
> Btw ctors and assignments don't seem to need this but they seem to work fine 
> though... 
> 
> 
> For example here the right assignment overload with `__local` address space 
> is selected
> https://godbolt.org/z/aYKj4W6rc
> or ctor overload with `__global` is selected here correctly:
> https://godbolt.org/z/1frheezE5
> 
> So it seems like there is some other logic to handle address spaces for 
> special members elsewhere? Although it is very strange and rather confusing.
Yes, it seems other special members are handled somewhere else according to my 
preliminary investigations, so that might explain why address spaces where 
never introduced into this function.


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

https://reviews.llvm.org/D109609

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


[PATCH] D109609: [C++4OpenCL] Add support for multiple address spaced destructors

2021-09-17 Thread Ole Strohm via Phabricator via cfe-commits
olestrohm updated this revision to Diff 373218.
olestrohm added a comment.

I made the implicit destructor always be created in __generic address space.

I couldn't manage to properly figure a case that would trigger 
`LookupSpecialMember`,
so I couldn't figure out how or if address spaces are handled there.

re: @keryell 
This might work, though I have no idea how that `SomeAPIReturningAddrSpace` 
would work, since at this point the variable would likely be cast to be in 
__generic addrspace.
Also I'm not sure how that would interact with deleted destructors.


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

https://reviews.llvm.org/D109609

Files:
  clang/include/clang/AST/DeclCXX.h
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/DeclCXX.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaLookup.cpp
  clang/test/SemaOpenCLCXX/addrspace-destructors.clcpp

Index: clang/test/SemaOpenCLCXX/addrspace-destructors.clcpp
===
--- /dev/null
+++ clang/test/SemaOpenCLCXX/addrspace-destructors.clcpp
@@ -0,0 +1,50 @@
+// RUN: %clang_cc1 %s -pedantic -ast-dump | FileCheck %s
+
+// CHECK: CXXDestructorDecl {{.*}} used ~ExactDtor 'void () __private noexcept'
+struct ExactDtor {
+ ~ExactDtor() __private;
+};
+
+// CHECK: CXXDestructorDecl
+// CHECK-NOT: used
+// CHECK-SAME: ~OverloadedDtor 'void () __generic'
+// CHECK: CXXDestructorDecl {{.*}} used ~OverloadedDtor 'void () __private noexcept'
+struct OverloadedDtor {
+ ~OverloadedDtor() __generic;
+ ~OverloadedDtor() __private;
+};
+
+// CHECK: CXXDestructorDecl
+// CHECK-NOT: used
+// CHECK-SAME: ~ImplicitDtor 'void () __global'
+// CHECK: CXXDestructorDecl {{.*}} implicit used ~ImplicitDtor 'void () __generic noexcept'
+struct ImplicitDtor {
+~ImplicitDtor() __global;
+};
+
+// CHECK: CXXDestructorDecl {{.*}} used ~Templated 'void () __generic noexcept'
+// CHECK: CXXDestructorDecl
+// CHECK-NOT: used
+// CHECK-SAME: ~Templated 'void () __global'
+template 
+struct Templated {
+~Templated() __generic;
+~Templated() __global;
+};
+
+// CHECK: CXXDestructorDecl {{.*}} used ~BothUsed 'void () __private noexcept'
+// CHECK: CXXDestructorDecl {{.*}} used ~BothUsed 'void () __global noexcept'
+struct BothUsed {
+~BothUsed() __private;
+~BothUsed() __global;
+};
+
+__global BothUsed g_inheriting;
+
+kernel void k() {
+__private ExactDtor exact;
+__private OverloadedDtor overloaded;
+__private ImplicitDtor implicit;
+__private Templated templated;
+__private BothUsed inheriting;
+}
Index: clang/lib/Sema/SemaLookup.cpp
===
--- clang/lib/Sema/SemaLookup.cpp
+++ clang/lib/Sema/SemaLookup.cpp
@@ -3054,13 +3054,10 @@
   Functions.append(Operators.begin(), Operators.end());
 }
 
-Sema::SpecialMemberOverloadResult Sema::LookupSpecialMember(CXXRecordDecl *RD,
-   CXXSpecialMember SM,
-   bool ConstArg,
-   bool VolatileArg,
-   bool RValueThis,
-   bool ConstThis,
-   bool VolatileThis) {
+Sema::SpecialMemberOverloadResult
+Sema::LookupSpecialMember(CXXRecordDecl *RD, CXXSpecialMember SM, bool ConstArg,
+  bool VolatileArg, bool RValueThis, bool ConstThis,
+  bool VolatileThis, LangAS AS) {
   assert(CanDeclareSpecialMemberFunction(RD) &&
  "doing special member lookup into record that isn't fully complete");
   RD = RD->getDefinition();
@@ -3082,6 +3079,7 @@
   ID.AddInteger(RValueThis);
   ID.AddInteger(ConstThis);
   ID.AddInteger(VolatileThis);
+  ID.AddInteger((unsigned)AS);
 
   void *InsertPoint;
   SpecialMemberOverloadResultEntry *Result =
@@ -3096,12 +3094,12 @@
   SpecialMemberCache.InsertNode(Result, InsertPoint);
 
   if (SM == CXXDestructor) {
-if (RD->needsImplicitDestructor()) {
+if (RD->needsImplicitDestructor(AS)) {
   runWithSufficientStackSpace(RD->getLocation(), [&] {
 DeclareImplicitDestructor(RD);
   });
 }
-CXXDestructorDecl *DD = RD->getDestructor();
+CXXDestructorDecl *DD = RD->getDestructor(AS);
 Result->setMethod(DD);
 Result->setKind(DD && !DD->isDeleted()
 ? SpecialMemberOverloadResult::Success
@@ -3362,10 +3360,11 @@
 /// CXXRecordDecl::getDestructor().
 ///
 /// \returns The destructor for this class.
-CXXDestructorDecl *Sema::LookupDestructor(CXXRecordDecl *Class) {
+CXXDestructorDecl *Sema::LookupDestructor(CXXRecordDecl *Class, LangAS AS) {
   return cast(LookupSpecialMember(Class, CXXDestructor,
- false, false, false,
- 

[PATCH] D109956: Fix CodeGen/pgo-sample-thinlto-summary.c with old PM

2021-09-17 Thread Thomas Preud'homme 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 rG8a7a28075b7f: Fix CodeGen/pgo-sample-thinlto-summary.c with 
old PM (authored by thopre).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109956

Files:
  clang/test/CodeGen/pgo-sample-thinlto-summary.c


Index: clang/test/CodeGen/pgo-sample-thinlto-summary.c
===
--- clang/test/CodeGen/pgo-sample-thinlto-summary.c
+++ clang/test/CodeGen/pgo-sample-thinlto-summary.c
@@ -1,7 +1,5 @@
-// RUN: %clang_cc1 -mllvm -debug-pass=Structure -O2 
-fno-experimental-new-pass-manager 
-fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm -o 
- 2>&1 | FileCheck %s -check-prefix=SAMPLEPGO-OLDPM
-// RUN: %clang_cc1 -mllvm -debug-pass=Structure -O2 
-fno-experimental-new-pass-manager 
-fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm 
-flto=thin -o - 2>&1 | FileCheck %s -check-prefix=THINLTO-OLDPM
-// RUN: %clang_cc1 -fdebug-pass-manager -O2 
-fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm -o 
- 2>&1 | FileCheck %s -check-prefix=SAMPLEPGO
-// RUN: %clang_cc1 -fdebug-pass-manager -O2 
-fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm 
-flto=thin -o - 2>&1 | FileCheck %s -check-prefix=THINLTO
+// RUN: %clang_cc1 -fexperimental-new-pass-manager -fdebug-pass-manager -O2 
-fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm -o 
- 2>&1 | FileCheck %s -check-prefix=SAMPLEPGO
+// RUN: %clang_cc1 -fexperimental-new-pass-manager -fdebug-pass-manager -O2 
-fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm 
-flto=thin -o - 2>&1 | FileCheck %s -check-prefix=THINLTO
 
 int baz(int);
 int g;
@@ -39,4 +37,4 @@
 void bar(int n) {
   for (int i = 0; i < n; i++)
 foo(i);
-}
\ No newline at end of file
+}


Index: clang/test/CodeGen/pgo-sample-thinlto-summary.c
===
--- clang/test/CodeGen/pgo-sample-thinlto-summary.c
+++ clang/test/CodeGen/pgo-sample-thinlto-summary.c
@@ -1,7 +1,5 @@
-// RUN: %clang_cc1 -mllvm -debug-pass=Structure -O2 -fno-experimental-new-pass-manager -fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm -o - 2>&1 | FileCheck %s -check-prefix=SAMPLEPGO-OLDPM
-// RUN: %clang_cc1 -mllvm -debug-pass=Structure -O2 -fno-experimental-new-pass-manager -fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm -flto=thin -o - 2>&1 | FileCheck %s -check-prefix=THINLTO-OLDPM
-// RUN: %clang_cc1 -fdebug-pass-manager -O2 -fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm -o - 2>&1 | FileCheck %s -check-prefix=SAMPLEPGO
-// RUN: %clang_cc1 -fdebug-pass-manager -O2 -fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm -flto=thin -o - 2>&1 | FileCheck %s -check-prefix=THINLTO
+// RUN: %clang_cc1 -fexperimental-new-pass-manager -fdebug-pass-manager -O2 -fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm -o - 2>&1 | FileCheck %s -check-prefix=SAMPLEPGO
+// RUN: %clang_cc1 -fexperimental-new-pass-manager -fdebug-pass-manager -O2 -fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm -flto=thin -o - 2>&1 | FileCheck %s -check-prefix=THINLTO
 
 int baz(int);
 int g;
@@ -39,4 +37,4 @@
 void bar(int n) {
   for (int i = 0; i < n; i++)
 foo(i);
-}
\ No newline at end of file
+}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 8a7a280 - Fix CodeGen/pgo-sample-thinlto-summary.c with old PM

2021-09-17 Thread Thomas Preud'homme via cfe-commits

Author: Thomas Preud'homme
Date: 2021-09-17T15:21:22+01:00
New Revision: 8a7a28075b7fa70d56b131c10a4d1add777d5830

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

LOG: Fix CodeGen/pgo-sample-thinlto-summary.c with old PM

Re-add -fexperimental-new-pass-manager to
Clang::CodeGen/pgo-sample-thinlto-summary.c for the test to work on
builds that still default to the old pass manager.

Reviewed By: tejohnson

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

Added: 


Modified: 
clang/test/CodeGen/pgo-sample-thinlto-summary.c

Removed: 




diff  --git a/clang/test/CodeGen/pgo-sample-thinlto-summary.c 
b/clang/test/CodeGen/pgo-sample-thinlto-summary.c
index 1de2298320e5..9eee0f6df457 100644
--- a/clang/test/CodeGen/pgo-sample-thinlto-summary.c
+++ b/clang/test/CodeGen/pgo-sample-thinlto-summary.c
@@ -1,7 +1,5 @@
-// RUN: %clang_cc1 -mllvm -debug-pass=Structure -O2 
-fno-experimental-new-pass-manager 
-fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm -o 
- 2>&1 | FileCheck %s -check-prefix=SAMPLEPGO-OLDPM
-// RUN: %clang_cc1 -mllvm -debug-pass=Structure -O2 
-fno-experimental-new-pass-manager 
-fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm 
-flto=thin -o - 2>&1 | FileCheck %s -check-prefix=THINLTO-OLDPM
-// RUN: %clang_cc1 -fdebug-pass-manager -O2 
-fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm -o 
- 2>&1 | FileCheck %s -check-prefix=SAMPLEPGO
-// RUN: %clang_cc1 -fdebug-pass-manager -O2 
-fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm 
-flto=thin -o - 2>&1 | FileCheck %s -check-prefix=THINLTO
+// RUN: %clang_cc1 -fexperimental-new-pass-manager -fdebug-pass-manager -O2 
-fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm -o 
- 2>&1 | FileCheck %s -check-prefix=SAMPLEPGO
+// RUN: %clang_cc1 -fexperimental-new-pass-manager -fdebug-pass-manager -O2 
-fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm 
-flto=thin -o - 2>&1 | FileCheck %s -check-prefix=THINLTO
 
 int baz(int);
 int g;
@@ -39,4 +37,4 @@ void foo(int n) {
 void bar(int n) {
   for (int i = 0; i < n; i++)
 foo(i);
-}
\ No newline at end of file
+}



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


[PATCH] D109956: Fix CodeGen/pgo-sample-thinlto-summary.c with old PM

2021-09-17 Thread Thomas Preud'homme via Phabricator via cfe-commits
thopre updated this revision to Diff 373214.
thopre added a comment.

Remove old PM tests


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109956

Files:
  clang/test/CodeGen/pgo-sample-thinlto-summary.c


Index: clang/test/CodeGen/pgo-sample-thinlto-summary.c
===
--- clang/test/CodeGen/pgo-sample-thinlto-summary.c
+++ clang/test/CodeGen/pgo-sample-thinlto-summary.c
@@ -1,7 +1,5 @@
-// RUN: %clang_cc1 -mllvm -debug-pass=Structure -O2 
-fno-experimental-new-pass-manager 
-fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm -o 
- 2>&1 | FileCheck %s -check-prefix=SAMPLEPGO-OLDPM
-// RUN: %clang_cc1 -mllvm -debug-pass=Structure -O2 
-fno-experimental-new-pass-manager 
-fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm 
-flto=thin -o - 2>&1 | FileCheck %s -check-prefix=THINLTO-OLDPM
-// RUN: %clang_cc1 -fdebug-pass-manager -O2 
-fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm -o 
- 2>&1 | FileCheck %s -check-prefix=SAMPLEPGO
-// RUN: %clang_cc1 -fdebug-pass-manager -O2 
-fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm 
-flto=thin -o - 2>&1 | FileCheck %s -check-prefix=THINLTO
+// RUN: %clang_cc1 -fexperimental-new-pass-manager -fdebug-pass-manager -O2 
-fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm -o 
- 2>&1 | FileCheck %s -check-prefix=SAMPLEPGO
+// RUN: %clang_cc1 -fexperimental-new-pass-manager -fdebug-pass-manager -O2 
-fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm 
-flto=thin -o - 2>&1 | FileCheck %s -check-prefix=THINLTO
 
 int baz(int);
 int g;
@@ -39,4 +37,4 @@
 void bar(int n) {
   for (int i = 0; i < n; i++)
 foo(i);
-}
\ No newline at end of file
+}


Index: clang/test/CodeGen/pgo-sample-thinlto-summary.c
===
--- clang/test/CodeGen/pgo-sample-thinlto-summary.c
+++ clang/test/CodeGen/pgo-sample-thinlto-summary.c
@@ -1,7 +1,5 @@
-// RUN: %clang_cc1 -mllvm -debug-pass=Structure -O2 -fno-experimental-new-pass-manager -fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm -o - 2>&1 | FileCheck %s -check-prefix=SAMPLEPGO-OLDPM
-// RUN: %clang_cc1 -mllvm -debug-pass=Structure -O2 -fno-experimental-new-pass-manager -fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm -flto=thin -o - 2>&1 | FileCheck %s -check-prefix=THINLTO-OLDPM
-// RUN: %clang_cc1 -fdebug-pass-manager -O2 -fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm -o - 2>&1 | FileCheck %s -check-prefix=SAMPLEPGO
-// RUN: %clang_cc1 -fdebug-pass-manager -O2 -fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm -flto=thin -o - 2>&1 | FileCheck %s -check-prefix=THINLTO
+// RUN: %clang_cc1 -fexperimental-new-pass-manager -fdebug-pass-manager -O2 -fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm -o - 2>&1 | FileCheck %s -check-prefix=SAMPLEPGO
+// RUN: %clang_cc1 -fexperimental-new-pass-manager -fdebug-pass-manager -O2 -fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm -flto=thin -o - 2>&1 | FileCheck %s -check-prefix=THINLTO
 
 int baz(int);
 int g;
@@ -39,4 +37,4 @@
 void bar(int n) {
   for (int i = 0; i < n; i++)
 foo(i);
-}
\ No newline at end of file
+}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D109956: Fix CodeGen/pgo-sample-thinlto-summary.c with old PM

2021-09-17 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson accepted this revision.
tejohnson added a comment.
This revision is now accepted and ready to land.

lgtm. And I just was informed in a recent review of one of my patches that we 
are now removing old PM tests, so if you want you could also go ahead and 
remove the first 2 lines here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109956

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


[PATCH] D105516: [clang][PassManager] Add -falways-mem2reg CC1 flag to run mem2reg at -O0

2021-09-17 Thread Jessica Clarke via Phabricator via cfe-commits
jrtc27 added a comment.

@rjmccall Ping?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105516

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


[clang] 197a3d1 - Fix test failure from e3b10525b489b604d6a1e540be78bda80afb5868

2021-09-17 Thread Erich Keane via cfe-commits

Author: Erich Keane
Date: 2021-09-17T06:21:55-07:00
New Revision: 197a3d183b8b2a8452d816a1b0fcfc1093ef76ab

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

LOG: Fix test failure from e3b10525b489b604d6a1e540be78bda80afb5868

Seemingly, names in anonymous namespaces are ALWAYS given the unique
internal linkage name on windows, and I was not aware of this when I put
the names in my test!  Replaced them with a wildcard.

Added: 


Modified: 
clang/test/CodeGenCXX/multi-versioning-internal-linkage.cpp

Removed: 




diff  --git a/clang/test/CodeGenCXX/multi-versioning-internal-linkage.cpp 
b/clang/test/CodeGenCXX/multi-versioning-internal-linkage.cpp
index 246599a591a7..c835a8f1624b 100644
--- a/clang/test/CodeGenCXX/multi-versioning-internal-linkage.cpp
+++ b/clang/test/CodeGenCXX/multi-versioning-internal-linkage.cpp
@@ -42,8 +42,8 @@ int usage() {
 // LINUX: define internal i32 ()* @_ZL15static_dispatchv.resolver()
 // WINDOWS: define internal i32 @"?static_dispatch@@YAHXZ"()
 // LINUX: define internal i32 ()* 
@_ZN12_GLOBAL__N_113anon_dispatchEv.resolver()
-// WINDOWS: define internal i32 @"?anon_dispatch@?A0x7F72A7FB@@YAHXZ"()
+// WINDOWS: define internal i32 @"?anon_dispatch{{.*}}@@YAHXZ"()
 // LINUX: define internal i32 ()* @_ZL13static_targetv.resolver()
 // WINDOWS: define internal i32 @"?static_target@@YAHXZ.resolver"()
 // LINUX: define internal i32 ()* @_ZN12_GLOBAL__N_111anon_targetEv.resolver()
-// WINDOWS: define internal i32 @"?anon_target@?A0x7F72A7FB@@YAHXZ.resolver"()
+// WINDOWS: define internal i32 @"?anon_target{{.*}}@@YAHXZ.resolver"()



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


[PATCH] D109307: [OpenCL] Supports optional same image reads and writes in C++ for OpenCL 2021

2021-09-17 Thread Justas Janickas 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 rGb7e9d203c679: [OpenCL] Supports optional same image reads 
and writes in C++ for OpenCL 2021 (authored by Topotuna).

Changed prior to commit:
  https://reviews.llvm.org/D109307?vs=370855=373203#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109307

Files:
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/Misc/opencl-c-3.0.incorrect_options.cl
  clang/test/SemaOpenCL/access-qualifier.cl

Index: clang/test/SemaOpenCL/access-qualifier.cl
===
--- clang/test/SemaOpenCL/access-qualifier.cl
+++ clang/test/SemaOpenCL/access-qualifier.cl
@@ -2,24 +2,38 @@
 // RUN: %clang_cc1 -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-std=CL2.0 %s
 // RUN: %clang_cc1 -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-std=CL3.0 %s
 // RUN: %clang_cc1 -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-std=CL3.0 %s -cl-ext=-__opencl_c_read_write_images
+// RUN: %clang_cc1 -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-std=clc++2021 %s
+// RUN: %clang_cc1 -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-std=clc++2021 %s -cl-ext=-__opencl_c_read_write_images
 
 typedef image1d_t img1d_ro_default; // expected-note {{previously declared 'read_only' here}}
 
 typedef write_only image1d_t img1d_wo; // expected-note {{previously declared 'write_only' here}}
 typedef read_only image1d_t img1d_ro;
 
-#if (__OPENCL_C_VERSION__ == 200) || (__OPENCL_C_VERSION__ == 300 && defined(__opencl_c_read_write_images))
+#if (__OPENCL_C_VERSION__ == 200) || ((__OPENCL_CPP_VERSION__ == 202100 || __OPENCL_C_VERSION__ == 300) && defined(__opencl_c_read_write_images))
 typedef read_write image1d_t img1d_rw;
 #endif
 
 typedef int Int;
 typedef read_only int IntRO; // expected-error {{access qualifier can only be used for pipe and image type}}
 
+void myWrite(write_only image1d_t);
+#if !defined(__OPENCL_CPP_VERSION__)
+// expected-note@-2 {{passing argument to parameter here}}
+// expected-note@-3 {{passing argument to parameter here}}
+#else
+// expected-note@-5 {{candidate function not viable: no known conversion from '__private img1d_ro' (aka '__private __read_only image1d_t') to '__private __write_only image1d_t' for 1st argument}}
+// expected-note@-6 {{candidate function not viable: no known conversion from '__private img1d_ro_default' (aka '__private __read_only image1d_t') to '__private __write_only image1d_t' for 1st argument}}
+#endif
 
-void myWrite(write_only image1d_t); // expected-note {{passing argument to parameter here}} expected-note {{passing argument to parameter here}}
-void myRead(read_only image1d_t); // expected-note {{passing argument to parameter here}}
+void myRead(read_only image1d_t);
+#if !defined(__OPENCL_CPP_VERSION__)
+// expected-note@-2 {{passing argument to parameter here}}
+#else
+// expected-note@-4 {{candidate function not viable: no known conversion from '__private img1d_wo' (aka '__private __write_only image1d_t') to '__private __read_only image1d_t' for 1st argument}}
+#endif
 
-#if (__OPENCL_C_VERSION__ == 200) || (__OPENCL_C_VERSION__ == 300 && defined(__opencl_c_read_write_images))
+#if (__OPENCL_C_VERSION__ == 200) || ((__OPENCL_CPP_VERSION__ == 202100 || __OPENCL_C_VERSION__ == 300) && defined(__opencl_c_read_write_images))
 void myReadWrite(read_write image1d_t);
 #else
 void myReadWrite(read_write image1d_t); // expected-error {{access qualifier 'read_write' can not be used for '__read_write image1d_t' prior to OpenCL C version 2.0 or in version 3.0 and without __opencl_c_read_write_images feature}}
@@ -27,25 +41,40 @@
 
 
 kernel void k1(img1d_wo img) {
-  myRead(img); // expected-error {{passing '__private img1d_wo' (aka '__private __write_only image1d_t') to parameter of incompatible type '__read_only image1d_t'}}
+  myRead(img);
+#if !defined(__OPENCL_CPP_VERSION__)
+// expected-error@-2 {{passing '__private img1d_wo' (aka '__private __write_only image1d_t') to parameter of incompatible type '__read_only image1d_t'}}
+#else
+// expected-error@-4 {{no matching function for call to 'myRead'}}
+#endif
 }
 
 kernel void k2(img1d_ro img) {
-  myWrite(img); // expected-error {{passing '__private img1d_ro' (aka '__private __read_only image1d_t') to parameter of incompatible type '__write_only image1d_t'}}
+  myWrite(img);
+#if !defined(__OPENCL_CPP_VERSION__)
+// expected-error@-2 {{passing '__private img1d_ro' (aka '__private __read_only image1d_t') to parameter of incompatible type '__write_only image1d_t'}}
+#else
+// expected-error@-4 {{no matching function for call to 'myWrite'}}
+#endif
 }
 
 kernel void k3(img1d_wo img) {
   myWrite(img);
 }
 
-#if (__OPENCL_C_VERSION__ == 200) || (__OPENCL_C_VERSION__ == 300 && 

[clang] b7e9d20 - [OpenCL] Supports optional same image reads and writes in C++ for OpenCL 2021

2021-09-17 Thread Justas Janickas via cfe-commits

Author: Justas Janickas
Date: 2021-09-17T14:14:31+01:00
New Revision: b7e9d203c6793873f72dd3ffaf7c9365ce03007e

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

LOG: [OpenCL] Supports optional same image reads and writes in C++ for OpenCL 
2021

Adds support for a feature macro `__opencl_c_read_write_images` in
C++ for OpenCL 2021 enabling a respective optional core feature
from OpenCL 3.0.

This change aims to achieve compatibility between C++ for OpenCL
2021 and OpenCL 3.0.

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

Added: 


Modified: 
clang/lib/Sema/SemaDeclAttr.cpp
clang/test/Misc/opencl-c-3.0.incorrect_options.cl
clang/test/SemaOpenCL/access-qualifier.cl

Removed: 




diff  --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index 35c32043e377..8092aeb21ada 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -7552,18 +7552,17 @@ static void handleOpenCLAccessAttr(Sema , Decl *D, 
const ParsedAttr ) {
   // OpenCL v3.0 s6.8 - For OpenCL C 2.0, or with the
   // __opencl_c_read_write_images feature, image objects specified as arguments
   // to a kernel can additionally be declared to be read-write.
-  // C++ for OpenCL inherits rule from OpenCL C v2.0.
+  // C++ for OpenCL 1.0 inherits rule from OpenCL C v2.0.
+  // C++ for OpenCL 2021 inherits rule from OpenCL C v3.0.
   if (const auto *PDecl = dyn_cast(D)) {
 const Type *DeclTy = PDecl->getType().getCanonicalType().getTypePtr();
 if (AL.getAttrName()->getName().find("read_write") != StringRef::npos) {
-  bool ReadWriteImagesUnsupportedForOCLC =
-  (S.getLangOpts().OpenCLVersion < 200) ||
-  (S.getLangOpts().OpenCLVersion == 300 &&
+  bool ReadWriteImagesUnsupported =
+  (S.getLangOpts().getOpenCLCompatibleVersion() < 200) ||
+  (S.getLangOpts().getOpenCLCompatibleVersion() == 300 &&
!S.getOpenCLOptions().isSupported("__opencl_c_read_write_images",
  S.getLangOpts()));
-  if ((!S.getLangOpts().OpenCLCPlusPlus &&
-   ReadWriteImagesUnsupportedForOCLC) ||
-  DeclTy->isPipeType()) {
+  if (ReadWriteImagesUnsupported || DeclTy->isPipeType()) {
 S.Diag(AL.getLoc(), diag::err_opencl_invalid_read_write)
 << AL << PDecl->getType() << DeclTy->isImageType();
 D->setInvalidDecl(true);

diff  --git a/clang/test/Misc/opencl-c-3.0.incorrect_options.cl 
b/clang/test/Misc/opencl-c-3.0.incorrect_options.cl
index 3ce0f325ce91..6232806c5c6d 100644
--- a/clang/test/Misc/opencl-c-3.0.incorrect_options.cl
+++ b/clang/test/Misc/opencl-c-3.0.incorrect_options.cl
@@ -3,6 +3,7 @@
 // RUN: not %clang_cc1 -cl-std=clc++2021 -triple spir-unknown-unknown 
-cl-ext=-__opencl_c_fp64,+cl_khr_fp64 %s 2>&1 | FileCheck 
-check-prefix=CHECK-FP64 %s
 // RUN: not %clang_cc1 -cl-std=clc++2021 -triple spir-unknown-unknown 
-cl-ext=+__opencl_c_fp64,-cl_khr_fp64 %s 2>&1 | FileCheck 
-check-prefix=CHECK-FP64 %s
 // RUN: not %clang_cc1 -cl-std=CL3.0 -triple spir-unknown-unknown 
-cl-ext=+__opencl_c_read_write_images,-__opencl_c_images %s 2>&1 | FileCheck 
-check-prefix=CHECK-READ-WRITE-IMAGES %s
+// RUN: not %clang_cc1 -cl-std=clc++2021 -triple spir-unknown-unknown 
-cl-ext=+__opencl_c_read_write_images,-__opencl_c_images %s 2>&1 | FileCheck 
-check-prefix=CHECK-READ-WRITE-IMAGES %s
 // RUN: not %clang_cc1 -cl-std=CL3.0 -triple spir-unknown-unknown 
-cl-ext=+__opencl_c_pipes,-__opencl_c_generic_address_space %s 2>&1 | FileCheck 
-check-prefix=CHECK-PIPES %s
 // RUN: not %clang_cc1 -cl-std=clc++2021 -triple spir-unknown-unknown 
-cl-ext=+__opencl_c_pipes,-__opencl_c_generic_address_space %s 2>&1 | FileCheck 
-check-prefix=CHECK-PIPES %s
 // RUN: not %clang_cc1 -cl-std=CL3.0 -triple spir-unknown-unknown 
-cl-ext=+__opencl_c_3d_image_writes,+__opencl_c_images,-cl_khr_3d_image_writes 
%s 2>&1 | FileCheck -check-prefix=CHECK-3D-WRITE-IMAGES-DIFF %s

diff  --git a/clang/test/SemaOpenCL/access-qualifier.cl 
b/clang/test/SemaOpenCL/access-qualifier.cl
index fc6ad750e717..726253c0b1a2 100644
--- a/clang/test/SemaOpenCL/access-qualifier.cl
+++ b/clang/test/SemaOpenCL/access-qualifier.cl
@@ -2,24 +2,38 @@
 // RUN: %clang_cc1 -triple spir-unknown-unknown -verify -pedantic 
-fsyntax-only -cl-std=CL2.0 %s
 // RUN: %clang_cc1 -triple spir-unknown-unknown -verify -pedantic 
-fsyntax-only -cl-std=CL3.0 %s
 // RUN: %clang_cc1 -triple spir-unknown-unknown -verify -pedantic 
-fsyntax-only -cl-std=CL3.0 %s -cl-ext=-__opencl_c_read_write_images
+// RUN: %clang_cc1 -triple spir-unknown-unknown -verify -pedantic 
-fsyntax-only -cl-std=clc++2021 %s
+// RUN: %clang_cc1 -triple spir-unknown-unknown -verify -pedantic 
-fsyntax-only -cl-std=clc++2021 %s 

[PATCH] D109960: [clang] [ARM] Don't set the strict alignment flag for armv7 on Windows

2021-09-17 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo updated this revision to Diff 373201.
mstorsjo added a comment.

Updated the comment too.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109960

Files:
  clang/lib/Driver/ToolChains/Arch/ARM.cpp
  clang/test/Driver/arm-alignment.c


Index: clang/test/Driver/arm-alignment.c
===
--- clang/test/Driver/arm-alignment.c
+++ clang/test/Driver/arm-alignment.c
@@ -19,6 +19,9 @@
 // RUN: %clang -target armv7-unknown-nacl-gnueabihf -### %s 2> %t
 // RUN: FileCheck --check-prefix=CHECK-UNALIGNED-ARM < %t %s
 
+// RUN: %clang -target armv7-windows -### %s 2> %t
+// RUN: FileCheck --check-prefix=CHECK-UNALIGNED-ARM < %t %s
+
 // RUN: %clang -target aarch64-none-gnueabi -munaligned-access -### %s 2> %t
 // RUN: FileCheck --check-prefix=CHECK-UNALIGNED-AARCH64 < %t %s
 
Index: clang/lib/Driver/ToolChains/Arch/ARM.cpp
===
--- clang/lib/Driver/ToolChains/Arch/ARM.cpp
+++ clang/lib/Driver/ToolChains/Arch/ARM.cpp
@@ -767,7 +767,8 @@
 // which raises an alignment fault on unaligned accesses. Linux
 // defaults this bit to 0 and handles it as a system-wide (not
 // per-process) setting. It is therefore safe to assume that ARMv7+
-// Linux targets support unaligned accesses. The same goes for NaCl.
+// Linux targets support unaligned accesses. The same goes for NaCl
+// and Windows.
 //
 // The above behavior is consistent with GCC.
 int VersionNum = getARMSubArchVersionNumber(Triple);
@@ -775,7 +776,8 @@
   if (VersionNum < 6 ||
   Triple.getSubArch() == llvm::Triple::SubArchType::ARMSubArch_v6m)
 Features.push_back("+strict-align");
-} else if (Triple.isOSLinux() || Triple.isOSNaCl()) {
+} else if (Triple.isOSLinux() || Triple.isOSNaCl() ||
+   Triple.isOSWindows()) {
   if (VersionNum < 7)
 Features.push_back("+strict-align");
 } else


Index: clang/test/Driver/arm-alignment.c
===
--- clang/test/Driver/arm-alignment.c
+++ clang/test/Driver/arm-alignment.c
@@ -19,6 +19,9 @@
 // RUN: %clang -target armv7-unknown-nacl-gnueabihf -### %s 2> %t
 // RUN: FileCheck --check-prefix=CHECK-UNALIGNED-ARM < %t %s
 
+// RUN: %clang -target armv7-windows -### %s 2> %t
+// RUN: FileCheck --check-prefix=CHECK-UNALIGNED-ARM < %t %s
+
 // RUN: %clang -target aarch64-none-gnueabi -munaligned-access -### %s 2> %t
 // RUN: FileCheck --check-prefix=CHECK-UNALIGNED-AARCH64 < %t %s
 
Index: clang/lib/Driver/ToolChains/Arch/ARM.cpp
===
--- clang/lib/Driver/ToolChains/Arch/ARM.cpp
+++ clang/lib/Driver/ToolChains/Arch/ARM.cpp
@@ -767,7 +767,8 @@
 // which raises an alignment fault on unaligned accesses. Linux
 // defaults this bit to 0 and handles it as a system-wide (not
 // per-process) setting. It is therefore safe to assume that ARMv7+
-// Linux targets support unaligned accesses. The same goes for NaCl.
+// Linux targets support unaligned accesses. The same goes for NaCl
+// and Windows.
 //
 // The above behavior is consistent with GCC.
 int VersionNum = getARMSubArchVersionNumber(Triple);
@@ -775,7 +776,8 @@
   if (VersionNum < 6 ||
   Triple.getSubArch() == llvm::Triple::SubArchType::ARMSubArch_v6m)
 Features.push_back("+strict-align");
-} else if (Triple.isOSLinux() || Triple.isOSNaCl()) {
+} else if (Triple.isOSLinux() || Triple.isOSNaCl() ||
+   Triple.isOSWindows()) {
   if (VersionNum < 7)
 Features.push_back("+strict-align");
 } else
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] e3b1052 - Make multiversioning work with internal linkage

2021-09-17 Thread Erich Keane via cfe-commits

Author: Erich Keane
Date: 2021-09-17T05:56:38-07:00
New Revision: e3b10525b489b604d6a1e540be78bda80afb5868

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

LOG: Make multiversioning work with internal linkage

We previously made all multiversioning resolvers/ifuncs have weak
ODR linkage in IR, since we NEED to emit the whole resolver every time
we see a call, but it is not necessarily the place where all the
definitions live.

HOWEVER, when doing so, we neglected the case where the versions have
internal linkage.  This patch ensures we do this, so you don't get weird
behavior with static functions.

Added: 
clang/test/CodeGenCXX/multi-versioning-internal-linkage.cpp

Modified: 
clang/lib/CodeGen/CodeGenModule.cpp
clang/test/CodeGen/unique-internal-linkage-names.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index b274edb8470c..9715657b4c6e 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -3258,6 +3258,19 @@ TargetMVPriority(const TargetInfo ,
   return Priority;
 }
 
+// Multiversion functions should be at most 'WeakODRLinkage' so that a 
diff erent
+// TU can forward declare the function without causing problems.  Particularly
+// in the cases of CPUDispatch, this causes issues. This also makes sure we
+// work with internal linkage functions, so that the same function name can be
+// used with internal linkage in multiple TUs.
+llvm::GlobalValue::LinkageTypes getMultiversionLinkage(CodeGenModule ,
+   GlobalDecl GD) {
+  const FunctionDecl *FD = cast(GD.getDecl());
+  if (FD->getFormalLinkage() == InternalLinkage)
+return llvm::GlobalValue::InternalLinkage;
+  return llvm::GlobalValue::WeakODRLinkage;
+}
+
 void CodeGenModule::emitMultiVersionFunctions() {
   std::vector MVFuncsToEmit;
   MultiVersionFuncs.swap(MVFuncsToEmit);
@@ -3298,7 +3311,7 @@ void CodeGenModule::emitMultiVersionFunctions() {
 if (TI.supportsIFunc() || FD->isTargetMultiVersion()) {
   ResolverFunc = cast(
   GetGlobalValue((getMangledName(GD) + ".resolver").str()));
-  ResolverFunc->setLinkage(llvm::Function::WeakODRLinkage);
+  ResolverFunc->setLinkage(getMultiversionLinkage(*this, GD));
 } else {
   ResolverFunc = cast(GetGlobalValue(getMangledName(GD)));
 }
@@ -3356,7 +3369,7 @@ void CodeGenModule::emitCPUDispatchDefinition(GlobalDecl 
GD) {
 
   auto *ResolverFunc = cast(GetOrCreateLLVMFunction(
   ResolverName, ResolverType, ResolverGD, /*ForVTable=*/false));
-  ResolverFunc->setLinkage(llvm::Function::WeakODRLinkage);
+  ResolverFunc->setLinkage(getMultiversionLinkage(*this, GD));
   if (supportsCOMDAT())
 ResolverFunc->setComdat(
 getModule().getOrInsertComdat(ResolverFunc->getName()));
@@ -3433,9 +3446,9 @@ void CodeGenModule::emitCPUDispatchDefinition(GlobalDecl 
GD) {
   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, ());
-  GA->setLinkage(llvm::Function::WeakODRLinkage);
+  auto *GA = llvm::GlobalAlias::create(DeclTy, 0,
+   getMultiversionLinkage(*this, GD),
+   AliasName, IFunc, ());
   SetCommonAttributes(GD, GA);
 }
   }
@@ -3474,8 +3487,9 @@ llvm::Constant 
*CodeGenModule::GetOrCreateMultiVersionResolver(
 llvm::Constant *Resolver = GetOrCreateLLVMFunction(
 MangledName + ".resolver", ResolverType, GlobalDecl{},
 /*ForVTable=*/false);
-llvm::GlobalIFunc *GIF = llvm::GlobalIFunc::create(
-DeclTy, 0, llvm::Function::WeakODRLinkage, "", Resolver, ());
+llvm::GlobalIFunc *GIF =
+llvm::GlobalIFunc::create(DeclTy, 0, getMultiversionLinkage(*this, GD),
+  "", Resolver, ());
 GIF->setName(ResolverName);
 SetCommonAttributes(FD, GIF);
 

diff  --git a/clang/test/CodeGen/unique-internal-linkage-names.cpp 
b/clang/test/CodeGen/unique-internal-linkage-names.cpp
index 95591de308d3..65069c049b63 100644
--- a/clang/test/CodeGen/unique-internal-linkage-names.cpp
+++ b/clang/test/CodeGen/unique-internal-linkage-names.cpp
@@ -59,7 +59,7 @@ void test() {
 // PLAIN: @_ZN12_GLOBAL__N_16anon_mE = internal global
 // PLAIN: define internal i32 @_ZL3foov()
 // PLAIN: define internal i32 @_ZN12_GLOBAL__N_14getMEv
-// PLAIN: define weak_odr i32 ()* @_ZL4mverv.resolver()
+// PLAIN: define internal i32 ()* @_ZL4mverv.resolver()
 // PLAIN: define internal void 

[PATCH] D109234: [PGO] Change ThinLTO test for targets with loop unrolling disabled

2021-09-17 Thread greg miller via Phabricator via cfe-commits
gregmiller added a comment.

The test patch worked and test is now passing again.  Thanks for the quick help 
on this!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109234

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


[PATCH] D109960: [clang] [ARM] Don't set the strict alignment flag for armv7 on Windows

2021-09-17 Thread David Spickett via Phabricator via cfe-commits
DavidSpickett accepted this revision.
DavidSpickett added a comment.
This revision is now accepted and ready to land.

LGTM with the comment updated.




Comment at: clang/lib/Driver/ToolChains/Arch/ARM.cpp:771
 // Linux targets support unaligned accesses. The same goes for NaCl.
 //
 // The above behavior is consistent with GCC.

Might as well update this comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109960

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


[PATCH] D106804: [test-suite] Add tests for FP classification intrinsics

2021-09-17 Thread Serge Pavlov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rTb983131b7e46: [test-suite] Add tests for FP classification 
intrinsics (authored by sepavloff).

Repository:
  rT test-suite

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

https://reviews.llvm.org/D106804

Files:
  SingleSource/UnitTests/CMakeLists.txt
  SingleSource/UnitTests/Float/CMakeLists.txt
  SingleSource/UnitTests/Float/Makefile
  SingleSource/UnitTests/Float/check-helper.h
  SingleSource/UnitTests/Float/classify-f32.h
  SingleSource/UnitTests/Float/classify-f64.h
  SingleSource/UnitTests/Float/classify-ldouble.h
  SingleSource/UnitTests/Float/classify.c
  SingleSource/UnitTests/Float/classify.reference_output
  SingleSource/UnitTests/Float/fformat.h

Index: SingleSource/UnitTests/Float/fformat.h
===
--- /dev/null
+++ SingleSource/UnitTests/Float/fformat.h
@@ -0,0 +1,65 @@
+//===--- fformat.h - Descriptions of floating point formats ---*- C -*-===//
+//
+// 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 header file contains some macro definitions useful for working with bit
+// accurate floating point representations.
+//
+//===--===//
+#ifndef _FFORMAT_H_
+#define _FFORMAT_H_
+
+#define F32_SIGN_BIT0x8000U
+#define F32_EXP_MASK0x7F80U
+#define F32_MANTISSA_MASK   0x007FU
+#define F32_MANTISSA_MSB0x0040U
+#define F32_QNAN_BITF32_MANTISSA_MSB
+#define F32_PAYLOAD_MASK(F32_MANTISSA_MASK & ~F32_QNAN_BIT)
+#define F32_SIGN_SHIFT  31
+#define F32_EXP_SHIFT   23
+#define F32_EXP_SIZE(F32_SIGN_SHIFT - F32_EXP_SHIFT)
+#define F32_MANTISSA_SIZE   F32_EXP_SHIFT
+#define F32_EXP_BIAS127
+#define F32_EXP_MIN (-126)
+#define F32_EXP_MAX 127
+#define F32_EXP(e)  (((e) + F32_EXP_BIAS) << F32_EXP_SHIFT)
+#define F32_MANTISSA(b1, b2, b3)   \
+(((b1) ? F32_MANTISSA_MSB : 0) |   \
+ ((b2) ? (F32_MANTISSA_MSB >> 1) : 0) |\
+ ((b3) ? (F32_MANTISSA_MSB >> 2) : 0))
+#define F32_MAKE(s, e, m)  \
+(((s) ? F32_SIGN_BIT : 0) |\
+ ((e) & F32_EXP_MASK) |\
+ ((m) & F32_MANTISSA_MASK))
+#define F32_NORMAL(s, e, m) F32_MAKE((s), F32_EXP(e), (m))
+
+
+#define F64_SIGN_BIT0x8000ULL
+#define F64_EXP_MASK0x7FF0ULL
+#define F64_MANTISSA_MASK   0x000FULL
+#define F64_MANTISSA_MSB0x0008ULL
+#define F64_QNAN_BITF64_MANTISSA_MSB
+#define F64_PAYLOAD_MASK(F64_MANTISSA_MASK & ~F64_QNAN_BIT)
+#define F64_SIGN_SHIFT  63
+#define F64_EXP_SHIFT   52
+#define F64_EXP_SIZE(F64_SIGN_SHIFT - F64_EXP_SHIFT)
+#define F64_MANTISSA_SIZE   F64_EXP_SHIFT
+#define F64_EXP_BIAS1023
+#define F64_EXP_MIN (-1022)
+#define F64_EXP_MAX 1023
+#define F64_EXP(e)  (((uint64_t)(e) + F64_EXP_BIAS) << F64_EXP_SHIFT)
+#define F64_MANTISSA(b1, b2, b3)   \
+(((b1) ? F64_MANTISSA_MSB : 0) |   \
+ ((b2) ? (F64_MANTISSA_MSB >> 1) : 0) |\
+ ((b3) ? (F64_MANTISSA_MSB >> 2) : 0))
+#define F64_MAKE(s, e, m)  \
+(((s) ? F64_SIGN_BIT : 0) |\
+ ((e) & F64_EXP_MASK) |\
+ ((m) & F64_MANTISSA_MASK))
+#define F64_NORMAL(s, e, m) F64_MAKE((s), F64_EXP(e), (m))
+
+#endif
Index: SingleSource/UnitTests/Float/classify.reference_output
===
--- /dev/null
+++ SingleSource/UnitTests/Float/classify.reference_output
@@ -0,0 +1 @@
+exit 0
Index: SingleSource/UnitTests/Float/classify.c
===
--- /dev/null
+++ SingleSource/UnitTests/Float/classify.c
@@ -0,0 +1,26 @@
+//===--- classify.cpp - Tess for FP classification intrinsics ---*- C++ -*-===//
+//
+// 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 general test for floating 

[PATCH] D106804: [test-suite] Add tests for FP classification intrinsics

2021-09-17 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff added a comment.

Thanks!


Repository:
  rT test-suite

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

https://reviews.llvm.org/D106804

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


[PATCH] D109951: [clang-format] Constructor initializer lists format with pp directives

2021-09-17 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added inline comments.



Comment at: clang/unittests/Format/FormatTest.cpp:19299
+   ", d{d} {\n}",
+   Style);
+}

MyDeveloperDay wrote:
> I think its good to add what you expect without the CONDITION too!
Can you add doubly nested test

```
SomeClass::Constructor()
: x {
  x
}
#if WINDOWS
#if DEBUG
, y { 0 }
#else
, y { 1 }
#endif
#else
#if DEBUG
, y { 2 }
#else
, y { 3 }
#endif
#endif
{}
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109951

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


[PATCH] D109608: [clang][ASTImporter] Generic attribute import handling (first step).

2021-09-17 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added a comment.

I like the adapter layer idea. However, I agree with @martong that it should be 
more 'abstract' ~ terse.
It's remarkable how compact the test is. Good job.




Comment at: clang/lib/AST/ASTImporter.cpp:8417-8418
+template  struct AttrArgImporter {
+  AttrArgImporter(const AttrArgImporter &) = delete;
+  AttrArgImporter(AttrArgImporter &&) = default;
+

What about the rest of the special member functions like assignment operators?

All the rest of the code mentions this template parameter using the `AT` name.  
Could you please consolidate this? It would make it more readable.



Comment at: clang/lib/AST/ASTImporter.cpp:8425
+
+  const T () { return To; }
+};

So, the `value()` sometimes returns const ref, and other times it returns a 
mutable raw pointer...

I suspect, attribute constructors expect simple reference arguments and 
pointers for lists. And this is why it behaves like this. Am I right about this?



Comment at: clang/lib/AST/ASTImporter.cpp:8439
+  return;
+} else {
+  To.reserve(ArraySize);

Please fix this.



Comment at: clang/lib/AST/ASTImporter.cpp:8460-8462
+  template 
+  AttrArgArrayImporter
+  importArrayArg(const llvm::iterator_range , unsigned ArraySize) {

The name `AT` suggests to me that you expect the template type parameter to be 
a subtype of `class Attr`. However, I suspect it's not always the case.
For example in case of the `OwnershipAttr` the `args()` returns a sequence of 
`ParamIdx*` objects. So, in that sense, the `AT` name is not properly justified.

Restricting template parameter types makes the code cleaner, so I would suggest 
introducing a metafunction, that you could use in a `static_assert` that you 
could use to check this requirement as the first instruction in the function.

```lang=C++
template 
constexpr static bool AttrOrParamIdx = std::is_base_of::value || 
std::is_same_v;

static_assert(AttrOrParamIdx);
```



Comment at: clang/lib/AST/ASTImporter.cpp:8466
+
+  template 
+  Expected createImportedAttr(const T *FromAttr, Arg &&...ImportedArg) 
{

I think you should be consistently using `typename` or `class`. I'm generally 
in favor of using `typename` though.



Comment at: clang/lib/AST/ASTImporter.cpp:8467
+  template 
+  Expected createImportedAttr(const T *FromAttr, Arg &&...ImportedArg) 
{
+const IdentifierInfo *ToAttrName;

So, this accepts universal references, shouldn't we `std::forward` when we 
consume them?
If not, why do you use `&&` ?



Comment at: clang/lib/AST/ASTImporter.cpp:8473-8474
+
+ToAttrName = Importer.Import(FromAttr->getAttrName());
+ToScopeName = Importer.Import(FromAttr->getScopeName());
+ToAttrRange = NImporter.importChecked(Err, FromAttr->getRange());

balazske wrote:
> martong wrote:
> > Why can't we use `importChecked` here?
> For `Identifier*` no error is possible and `importChecked` does not work 
> (could be added to have uniform code).
Why don't you initialize the variables directly? Same for the other variables. 
This way they could be const as well.



Comment at: clang/lib/AST/ASTImporter.cpp:8547-8548
+Expected ToAttrOrErr = AI.createImportedAttr(
+From, AI.importArrayArg(From->args(), From->args_size()).value(),
+From->args_size());
+if (ToAttrOrErr)

balazske wrote:
> martong wrote:
> > Could we hide these arguments?
> > I mean we probably need a higher abstraction, something like
> > ```
> > Expected ToAttrOrErr = AI.createImportedAttr(From);
> > ```
> > should be sufficient, isn't it. We do want to import all arguments of all 
> > kind of attributes, don't we?
> It should be possible to pass every kind of needed arguments (after it is 
> imported) to the constructor of the newly created `Attr` object. The problem 
> is solved here by the `AttrArgImporter` that imports the object and can store 
> it in a temporary value until it is passed to the constructor. The temporary 
> value is important if an array is imported. To import the array the size must 
> be passed to the array importer before, and the size must be passed to the 
> constructor of the `Attr` too, therefore it exists 2 times in the code. An 
> `AttrArgImporter` can provide only one value to the constructor of the new 
> `Attr` object. (Probably other solution is possible with `std::tuple` and 
> `std::apply` but not sure if it is better.)
What about having two implementations. One for any T that has `args()` and one 
for anything else and using SFINAE choosing the right one.
In this context, we should have the appropriate dynamic type, so by using 
template type deduction on `From` could achieve this dispatch.

Internally it could do the `AI.importArrayArg(From->args(), 
From->args_size()).value()` for the `args()` 

[PATCH] D109951: [clang-format] Constructor initializer lists format with pp directives

2021-09-17 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added inline comments.



Comment at: clang/unittests/Format/FormatTest.cpp:19299
+   ", d{d} {\n}",
+   Style);
+}

I think its good to add what you expect without the CONDITION too!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109951

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


[PATCH] D109951: [clang-format] Constructor initializer lists format with pp directives

2021-09-17 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

I see, let me add some other prominent reviewers

I do see what you mean

  SomeClass::Constructor()
  : x {
x
  }
  #if DEBUG
  , y { 0 }
  #endif
  {}
  
  SomeClass::Constructor()
  : x{x}
  , y{0} {}


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109951

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


[PATCH] D109960: [clang] [ARM] Don't set the strict alignment flag for armv7 on Windows

2021-09-17 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo created this revision.
mstorsjo added reviewers: DavidSpickett, simon_tatham.
Herald added subscribers: kristof.beyls, dschuff.
mstorsjo requested review of this revision.
Herald added a project: clang.

Windows on armv7 is as alignment tolerant as Linux.

The alignment considerations in the Windows on ARM ABI are documented
at 
https://docs.microsoft.com/en-us/cpp/build/overview-of-arm-abi-conventions?view=msvc-160#alignment.

The document doesn't explicitly say in which state the OS configures
the SCTLR.A register (and it's not accessible from user space to
inspect), but in practice, unaligned loads/stores do work and seem
to be as fast as aligned loads and stores. (Unaligned strd also does
seem to work, contrary to Linux, but significantly slower, as they're
handled by the kernel - exactly as the document describes.)


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D109960

Files:
  clang/lib/Driver/ToolChains/Arch/ARM.cpp
  clang/test/Driver/arm-alignment.c


Index: clang/test/Driver/arm-alignment.c
===
--- clang/test/Driver/arm-alignment.c
+++ clang/test/Driver/arm-alignment.c
@@ -19,6 +19,9 @@
 // RUN: %clang -target armv7-unknown-nacl-gnueabihf -### %s 2> %t
 // RUN: FileCheck --check-prefix=CHECK-UNALIGNED-ARM < %t %s
 
+// RUN: %clang -target armv7-windows -### %s 2> %t
+// RUN: FileCheck --check-prefix=CHECK-UNALIGNED-ARM < %t %s
+
 // RUN: %clang -target aarch64-none-gnueabi -munaligned-access -### %s 2> %t
 // RUN: FileCheck --check-prefix=CHECK-UNALIGNED-AARCH64 < %t %s
 
Index: clang/lib/Driver/ToolChains/Arch/ARM.cpp
===
--- clang/lib/Driver/ToolChains/Arch/ARM.cpp
+++ clang/lib/Driver/ToolChains/Arch/ARM.cpp
@@ -775,7 +775,8 @@
   if (VersionNum < 6 ||
   Triple.getSubArch() == llvm::Triple::SubArchType::ARMSubArch_v6m)
 Features.push_back("+strict-align");
-} else if (Triple.isOSLinux() || Triple.isOSNaCl()) {
+} else if (Triple.isOSLinux() || Triple.isOSNaCl() ||
+   Triple.isOSWindows()) {
   if (VersionNum < 7)
 Features.push_back("+strict-align");
 } else


Index: clang/test/Driver/arm-alignment.c
===
--- clang/test/Driver/arm-alignment.c
+++ clang/test/Driver/arm-alignment.c
@@ -19,6 +19,9 @@
 // RUN: %clang -target armv7-unknown-nacl-gnueabihf -### %s 2> %t
 // RUN: FileCheck --check-prefix=CHECK-UNALIGNED-ARM < %t %s
 
+// RUN: %clang -target armv7-windows -### %s 2> %t
+// RUN: FileCheck --check-prefix=CHECK-UNALIGNED-ARM < %t %s
+
 // RUN: %clang -target aarch64-none-gnueabi -munaligned-access -### %s 2> %t
 // RUN: FileCheck --check-prefix=CHECK-UNALIGNED-AARCH64 < %t %s
 
Index: clang/lib/Driver/ToolChains/Arch/ARM.cpp
===
--- clang/lib/Driver/ToolChains/Arch/ARM.cpp
+++ clang/lib/Driver/ToolChains/Arch/ARM.cpp
@@ -775,7 +775,8 @@
   if (VersionNum < 6 ||
   Triple.getSubArch() == llvm::Triple::SubArchType::ARMSubArch_v6m)
 Features.push_back("+strict-align");
-} else if (Triple.isOSLinux() || Triple.isOSNaCl()) {
+} else if (Triple.isOSLinux() || Triple.isOSNaCl() ||
+   Triple.isOSWindows()) {
   if (VersionNum < 7)
 Features.push_back("+strict-align");
 } else
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D109943: [Clang] Fix long double availability check

2021-09-17 Thread Qiu Chaofan via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG0195f8621f18: [Clang] Fix long double availability check 
(authored by qiucf).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109943

Files:
  clang/lib/Sema/Sema.cpp
  clang/test/OpenMP/amdgcn_ldbl_check.cpp


Index: clang/test/OpenMP/amdgcn_ldbl_check.cpp
===
--- /dev/null
+++ clang/test/OpenMP/amdgcn_ldbl_check.cpp
@@ -0,0 +1,27 @@
+// REQUIRES: amdgpu-registered-target
+
+// RUN: %clang_cc1 -triple x86_64-mingw64 -emit-llvm-bc -target-cpu x86-64 
-fopenmp -fopenmp-targets=amdgcn-amd-amdhsa -o %t.bc -x c++ %s
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -aux-triple x86_64-mingw64 
-fsyntax-only -target-cpu gfx900 -fopenmp -fopenmp-is-device 
-fopenmp-host-ir-file-path %t.bc -x c++ %s
+// expected-no-diagnostics
+
+void print(double);
+
+constexpr double operator"" _X (long double a)
+{
+   return (double)a;
+}
+
+int main()
+{
+   auto a = 1._X;
+  print(a);
+#pragma omp target map(tofrom: a)
+   {
+#pragma omp teams num_teams(1) thread_limit(4)
+   {
+   a += 1._X;
+   }
+   }
+  print(a);
+   return 0;
+}
Index: clang/lib/Sema/Sema.cpp
===
--- clang/lib/Sema/Sema.cpp
+++ clang/lib/Sema/Sema.cpp
@@ -1892,8 +1892,10 @@
 bool LongDoubleMismatched = false;
 if (Ty->isRealFloatingType() && Context.getTypeSize(Ty) == 128) {
   const llvm::fltSemantics  = Context.getFloatTypeSemantics(Ty);
-  if (!Ty->isIbm128Type() && !Ty->isFloat128Type() &&
-   != ().getLongDoubleFormat())
+  if (( != ::APFloat::PPCDoubleDouble() &&
+   !Context.getTargetInfo().hasFloat128Type()) ||
+  ( == ::APFloat::PPCDoubleDouble() &&
+   !Context.getTargetInfo().hasIbm128Type()))
 LongDoubleMismatched = true;
 }
 


Index: clang/test/OpenMP/amdgcn_ldbl_check.cpp
===
--- /dev/null
+++ clang/test/OpenMP/amdgcn_ldbl_check.cpp
@@ -0,0 +1,27 @@
+// REQUIRES: amdgpu-registered-target
+
+// RUN: %clang_cc1 -triple x86_64-mingw64 -emit-llvm-bc -target-cpu x86-64 -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa -o %t.bc -x c++ %s
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -aux-triple x86_64-mingw64 -fsyntax-only -target-cpu gfx900 -fopenmp -fopenmp-is-device -fopenmp-host-ir-file-path %t.bc -x c++ %s
+// expected-no-diagnostics
+
+void print(double);
+
+constexpr double operator"" _X (long double a)
+{
+	return (double)a;
+}
+
+int main()
+{
+	auto a = 1._X;
+  print(a);
+#pragma omp target map(tofrom: a)
+	{
+#pragma omp teams num_teams(1) thread_limit(4)
+		{
+			a += 1._X;
+		}
+	}
+  print(a);
+	return 0;
+}
Index: clang/lib/Sema/Sema.cpp
===
--- clang/lib/Sema/Sema.cpp
+++ clang/lib/Sema/Sema.cpp
@@ -1892,8 +1892,10 @@
 bool LongDoubleMismatched = false;
 if (Ty->isRealFloatingType() && Context.getTypeSize(Ty) == 128) {
   const llvm::fltSemantics  = Context.getFloatTypeSemantics(Ty);
-  if (!Ty->isIbm128Type() && !Ty->isFloat128Type() &&
-   != ().getLongDoubleFormat())
+  if (( != ::APFloat::PPCDoubleDouble() &&
+   !Context.getTargetInfo().hasFloat128Type()) ||
+  ( == ::APFloat::PPCDoubleDouble() &&
+   !Context.getTargetInfo().hasIbm128Type()))
 LongDoubleMismatched = true;
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D109943: [Clang] Fix long double availability check

2021-09-17 Thread Ron Lieberman via Phabricator via cfe-commits
ronlieb accepted this revision.
ronlieb added a comment.
This revision is now accepted and ready to land.

thank you for the fix.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109943

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


  1   2   >