[clang] [CUDA][HIP] Exclude external variables from constant promotion. (PR #73549)

2023-12-20 Thread Levon Ter-Grigoryan via cfe-commits

https://github.com/PatriosTheGreat updated 
https://github.com/llvm/llvm-project/pull/73549

>From 1c24a6774f08c9943cce1a2eee96a6a92b11fd02 Mon Sep 17 00:00:00 2001
From: Levon Ter-Grigoryan 
Date: Mon, 27 Nov 2023 18:09:22 +0100
Subject: [PATCH] [CUDA][HIP] Exclude external variables from constant
 promotion.

Promoting __constant__ to external variables includes them to PTX which then 
leads to nvlinker failure.
See changes at device-use-host-var test.
Befor this change those variables was included to PTX without definition.
---
 clang/lib/Sema/SemaCUDA.cpp   |  1 +
 clang/test/CodeGenCUDA/device-use-host-var.cu | 13 +
 2 files changed, 14 insertions(+)

diff --git a/clang/lib/Sema/SemaCUDA.cpp b/clang/lib/Sema/SemaCUDA.cpp
index 6a66ecf6f94c178..d744f9a8c5109f8 100644
--- a/clang/lib/Sema/SemaCUDA.cpp
+++ b/clang/lib/Sema/SemaCUDA.cpp
@@ -792,6 +792,7 @@ void Sema::MaybeAddCUDAConstantAttr(VarDecl *VD) {
   (VD->isFileVarDecl() || VD->isStaticDataMember()) &&
   !IsDependentVar(VD) &&
   ((VD->isConstexpr() || VD->getType().isConstQualified()) &&
+   VD->getStorageClass() != SC_Extern &&
HasAllowedCUDADeviceStaticInitializer(*this, VD,
  CICK_DeviceOrConstant))) {
 VD->addAttr(CUDAConstantAttr::CreateImplicit(getASTContext()));
diff --git a/clang/test/CodeGenCUDA/device-use-host-var.cu 
b/clang/test/CodeGenCUDA/device-use-host-var.cu
index 64de57e41b4b9f5..65aac2b7eca891c 100644
--- a/clang/test/CodeGenCUDA/device-use-host-var.cu
+++ b/clang/test/CodeGenCUDA/device-use-host-var.cu
@@ -2,6 +2,8 @@
 // RUN:   -fcuda-is-device -emit-llvm -o - -x hip %s | FileCheck %s
 // RUN: %clang_cc1 -std=c++14 -triple amdgcn-amd-amdhsa \
 // RUN:   -fcuda-is-device -emit-llvm -o - -x hip %s | FileCheck 
-check-prefix=NEG %s
+// RUN: %clang_cc1 -std=c++14 -triple nvptx64-nvidia-cuda  \
+// RUN:   -fcuda-is-device -emit-llvm -o - -x hip %s | FileCheck 
-check-prefix=NEG -implicit-check-not=external_ %s
 
 #include "Inputs/cuda.h"
 
@@ -104,3 +106,14 @@ void fun() {
   (void) b;
   (void) var_host_only;
 }
+
+extern __global__ void external_func();
+extern void* const external_dep[] = {
+  (void*)(external_func)
+};
+extern void* const external_arr[] = {};
+
+void* host_fun() {
+  (void) external_dep;
+  (void) external_arr;
+}

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


[clang] [ClangRepl] Reland Semanic Code Completion (PR #75556)

2023-12-20 Thread Vladimir Vereschaka via cfe-commits

vvereschaka wrote:

Works fine on my builder. Thank you. I'm going to land this patch.

https://github.com/llvm/llvm-project/pull/75556
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 7022a24 - [ClangRepl] Fix failed ClangReplInterpreter unit tests (#75556).

2023-12-20 Thread Vladimir Vereschaka via cfe-commits

Author: Vladimir Vereschaka
Date: 2023-12-20T00:11:12-08:00
New Revision: 7022a24771c8404f847abb226735a3ae21794426

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

LOG: [ClangRepl] Fix failed ClangReplInterpreter unit tests (#75556).

See more details: https://lab.llvm.org/buildbot/#/builders/119/builds/16346

Behalf of @vgvassilev

Added: 


Modified: 
clang/unittests/Interpreter/CodeCompletionTest.cpp

Removed: 




diff  --git a/clang/unittests/Interpreter/CodeCompletionTest.cpp 
b/clang/unittests/Interpreter/CodeCompletionTest.cpp
index cd7fdfa588a5d0..873fbda32f0579 100644
--- a/clang/unittests/Interpreter/CodeCompletionTest.cpp
+++ b/clang/unittests/Interpreter/CodeCompletionTest.cpp
@@ -50,16 +50,9 @@ static std::vector runComp(clang::Interpreter 
&MainInterp,
   return Comps;
 }
 
-#ifdef _AIX
-TEST(CodeCompletionTest, DISABLED_Sanity) {
-#else
 TEST(CodeCompletionTest, Sanity) {
-#endif
   auto Interp = createInterpreter();
-  if (auto R = Interp->ParseAndExecute("int foo = 12;")) {
-consumeError(std::move(R));
-return;
-  }
+  cantFail(Interp->Parse("int foo = 12;"));
   auto Err = llvm::Error::success();
   auto comps = runComp(*Interp, "f", Err);
   EXPECT_EQ((size_t)2, comps.size()); // float and foo
@@ -68,36 +61,19 @@ TEST(CodeCompletionTest, Sanity) {
   EXPECT_EQ((bool)Err, false);
 }
 
-#ifdef _AIX
-TEST(CodeCompletionTest, DISABLED_SanityNoneValid) {
-#else
 TEST(CodeCompletionTest, SanityNoneValid) {
-#endif
   auto Interp = createInterpreter();
-  if (auto R = Interp->ParseAndExecute("int foo = 12;")) {
-consumeError(std::move(R));
-return;
-  }
+  cantFail(Interp->Parse("int foo = 12;"));
   auto Err = llvm::Error::success();
   auto comps = runComp(*Interp, "babanana", Err);
   EXPECT_EQ((size_t)0, comps.size()); // foo and float
   EXPECT_EQ((bool)Err, false);
 }
 
-#ifdef _AIX
-TEST(CodeCompletionTest, DISABLED_TwoDecls) {
-#else
 TEST(CodeCompletionTest, TwoDecls) {
-#endif
   auto Interp = createInterpreter();
-  if (auto R = Interp->ParseAndExecute("int application = 12;")) {
-consumeError(std::move(R));
-return;
-  }
-  if (auto R = Interp->ParseAndExecute("int apple = 12;")) {
-consumeError(std::move(R));
-return;
-  }
+  cantFail(Interp->Parse("int application = 12;"));
+  cantFail(Interp->Parse("int apple = 12;"));
   auto Err = llvm::Error::success();
   auto comps = runComp(*Interp, "app", Err);
   EXPECT_EQ((size_t)2, comps.size());
@@ -113,18 +89,9 @@ TEST(CodeCompletionTest, CompFunDeclsNoError) {
 
 TEST(CodeCompletionTest, TypedDirected) {
   auto Interp = createInterpreter();
-  if (auto R = Interp->ParseAndExecute("int application = 12;")) {
-consumeError(std::move(R));
-return;
-  }
-  if (auto R = Interp->ParseAndExecute("char apple = '2';")) {
-consumeError(std::move(R));
-return;
-  }
-  if (auto R = Interp->ParseAndExecute("void add(int &SomeInt){}")) {
-consumeError(std::move(R));
-return;
-  }
+  cantFail(Interp->Parse("int application = 12;"));
+  cantFail(Interp->Parse("char apple = '2';"));
+  cantFail(Interp->Parse("void add(int &SomeInt){}"));
   {
 auto Err = llvm::Error::success();
 auto comps = runComp(*Interp, std::string("add("), Err);
@@ -132,10 +99,7 @@ TEST(CodeCompletionTest, TypedDirected) {
 EXPECT_EQ((bool)Err, false);
   }
 
-  if (auto R = Interp->ParseAndExecute("int banana = 42;")) {
-consumeError(std::move(R));
-return;
-  }
+  cantFail(Interp->Parse("int banana = 42;"));
 
   {
 auto Err = llvm::Error::success();
@@ -157,22 +121,10 @@ TEST(CodeCompletionTest, TypedDirected) {
 
 TEST(CodeCompletionTest, SanityClasses) {
   auto Interp = createInterpreter();
-  if (auto R = Interp->ParseAndExecute("struct Apple{};")) {
-consumeError(std::move(R));
-return;
-  }
-  if (auto R = Interp->ParseAndExecute("void takeApple(Apple &a1){}")) {
-consumeError(std::move(R));
-return;
-  }
-  if (auto R = Interp->ParseAndExecute("Apple a1;")) {
-consumeError(std::move(R));
-return;
-  }
-  if (auto R = Interp->ParseAndExecute("void takeAppleCopy(Apple a1){}")) {
-consumeError(std::move(R));
-return;
-  }
+  cantFail(Interp->Parse("struct Apple{};"));
+  cantFail(Interp->Parse("void takeApple(Apple &a1){}"));
+  cantFail(Interp->Parse("Apple a1;"));
+  cantFail(Interp->Parse("void takeAppleCopy(Apple a1){}"));
 
   {
 auto Err = llvm::Error::success();
@@ -192,26 +144,11 @@ TEST(CodeCompletionTest, SanityClasses) {
 
 TEST(CodeCompletionTest, SubClassing) {
   auto Interp = createInterpreter();
-  if (auto R = Interp->ParseAndExecute("struct Fruit {};")) {
-consumeError(std::move(R));
-return;
-  }
-  if (auto R = Interp->ParseAndExecute("struct Apple : Fruit{};")) {
-consumeError(std::move(R));
-

[clang] [flang] [Flang, Clang] Enable and test 'rdynamic' flag (PR #75598)

2023-12-20 Thread Radu Salavat via cfe-commits


@@ -7,13 +7,17 @@
 ! RUN: %flang -### --target=x86_64-windows-msvc -rpath /path/to/dir -shared \
 ! RUN: -static %s 2>&1 | FileCheck \
 ! RUN: --check-prefixes=MSVC-LINKER-OPTIONS %s
+! RUN: %flang -### --target=aarch64-linux-none -rdynamic %s 2>&1 | FileCheck 
--check-prefixes=AARCH-LINKER-OPTIONS %s

Radu2k wrote:

Sounds reasonable, will update soon. Thanks! 

https://github.com/llvm/llvm-project/pull/75598
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [flang] [flang][Driver] Let the linker fail on multiple definitions of main() (PR #73124)

2023-12-20 Thread Andrzej Warzyński via cfe-commits

banach-space wrote:

@kkwli and @DanielCChen - could you review 
https://github.com/llvm/llvm-project/pull/75816 and see whether that makes 
sense to you? I am referring specifically to the documentation that @mjklemm is 
kindly adding. Hopefully that will help folks avoid similar issues in the 
future.

https://github.com/llvm/llvm-project/pull/73124
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[llvm] [clang-tools-extra] [compiler-rt] [clang] [OpenMP] atomic compare fail : Codegen support (PR #75709)

2023-12-20 Thread via cfe-commits

https://github.com/SunilKuravinakop updated 
https://github.com/llvm/llvm-project/pull/75709

>From fe931d64741f427629407bca3e68a61bec6f2b67 Mon Sep 17 00:00:00 2001
From: Sunil Kuravinakop 
Date: Sat, 16 Dec 2023 11:43:35 -0600
Subject: [PATCH 1/2] Adding parameter to fail clause (i.e. memory order
 clause) for codegen.

  Changes to be committed:
modified:   clang/lib/CodeGen/CGStmtOpenMP.cpp
---
 clang/lib/CodeGen/CGStmtOpenMP.cpp | 51 +++---
 1 file changed, 47 insertions(+), 4 deletions(-)

diff --git a/clang/lib/CodeGen/CGStmtOpenMP.cpp 
b/clang/lib/CodeGen/CGStmtOpenMP.cpp
index 478d6dbf9ca81d..a502db7ac3a5e0 100644
--- a/clang/lib/CodeGen/CGStmtOpenMP.cpp
+++ b/clang/lib/CodeGen/CGStmtOpenMP.cpp
@@ -6516,10 +6516,6 @@ static void emitOMPAtomicExpr(CodeGenFunction &CGF, 
OpenMPClauseKind Kind,
  IsPostfixUpdate, IsFailOnly, Loc);
 break;
   }
-  case OMPC_fail: {
-//TODO
-break;
-  }
   default:
 llvm_unreachable("Clause is not allowed in 'omp atomic'.");
   }
@@ -6527,6 +6523,8 @@ static void emitOMPAtomicExpr(CodeGenFunction &CGF, 
OpenMPClauseKind Kind,
 
 void CodeGenFunction::EmitOMPAtomicDirective(const OMPAtomicDirective &S) {
   llvm::AtomicOrdering AO = llvm::AtomicOrdering::Monotonic;
+  // Fail Memory Clause Ordering.
+  llvm::AtomicOrdering FO = llvm::AtomicOrdering::Monotonic;
   bool MemOrderingSpecified = false;
   if (S.getSingleClause()) {
 AO = llvm::AtomicOrdering::SequentiallyConsistent;
@@ -6580,6 +6578,51 @@ void CodeGenFunction::EmitOMPAtomicDirective(const 
OMPAtomicDirective &S) {
 }
   }
 
+  if (KindsEncountered.contains(OMPC_compare) &&
+  KindsEncountered.contains(OMPC_fail)) {
+Kind = OMPC_compare;
+const OMPFailClause *fC = S.getSingleClause();
+if (fC) {
+  OpenMPClauseKind fP = fC->getFailParameter();
+  if (fP == llvm::omp::OMPC_relaxed)
+FO = llvm::AtomicOrdering::Monotonic;
+  else if (fP == llvm::omp::OMPC_acquire)
+FO = llvm::AtomicOrdering::Acquire;
+  else if (fP == llvm::omp::OMPC_seq_cst)
+FO = llvm::AtomicOrdering::SequentiallyConsistent;
+}
+
+// Logic for 2 memory order clauses in the atomic directive.
+// e.g. #pragma omp atomic compare capture release fail(seq_cst)
+//  if(x > e) { x = j; } else { k = x; }
+// To provide the Memory Order clause in atomic directive
+// there are 2 instructions in LLVM IR atomicrmw & cmpxchgl.
+// 1) atomicrmw can use only 1 memory order clause and can contain the
+//operator in if condition.
+// 2) cmpxchgl can use 2 memory order clauses : Success memory order clause
+//& fail parameter memory clause. However, cmpxchgl uses only equality
+//operator.
+// We need to change atomicrmw to contain the fail parameter clause or add
+// a new instruction in LLVM IR. Changes in LLVM IR need to be done
+// seperately and at present we will use the logic of using the more strict
+// memory order clause of success or fail memory order clauses for the
+// atomicrmw. The following logic takes care of this change in the memory
+// order clause.
+if (AO == llvm::AtomicOrdering::Monotonic)
+  AO = FO;
+else if (FO == llvm::AtomicOrdering::Monotonic)
+  AO = AO;
+else if (AO == llvm::AtomicOrdering::SequentiallyConsistent ||
+ FO == llvm::AtomicOrdering::SequentiallyConsistent)
+  AO = llvm::AtomicOrdering::SequentiallyConsistent;
+else if (AO == llvm::AtomicOrdering::Acquire)
+  AO = llvm::AtomicOrdering::Acquire;
+else if (AO == llvm::AtomicOrdering::Release)
+  AO = llvm::AtomicOrdering::AcquireRelease;
+else if (AO == llvm::AtomicOrdering::AcquireRelease)
+  AO = llvm::AtomicOrdering::AcquireRelease;
+  }
+
   LexicalScope Scope(*this, S.getSourceRange());
   EmitStopPoint(S.getAssociatedStmt());
   emitOMPAtomicExpr(*this, Kind, AO, S.isPostfixUpdate(), S.getX(), S.getV(),

>From 9cc33631c89c4fd4dce8a274fed700febe5dfa90 Mon Sep 17 00:00:00 2001
From: Sunil Kuravinakop 
Date: Tue, 19 Dec 2023 23:49:03 -0600
Subject: [PATCH 2/2] 1) Since the{if(x == e) {x = v;} else {d = x;}}
 results in generation of cmpxchg in the LLVM IR, the memory order clause in
 "fail" clause is now being added.In case of other operators ">" & "<"
 e.g.dx = dx > de ? de : dx; result in atomicrmw in the LLVM IR.
 "atomicrmw" can have only one memory order clause. Currently, the memory
 order clause is ignored. 2) Test cases for codegen 3) In SemaOpenMP.cpp,
 addedEncounteredAtomicKinds.contains(OMPC_compare) instead of AtomicKind
 == OMPC_compare. This was to accomodate where AtomicKind is OMPC_capture.

  Changes to be committed:
modified:   clang/lib/CodeGen/CGStmtOpenMP.cpp
modified:   clang/lib/Sema/SemaOpenMP.cpp
modified:   clang/test/OpenMP/atomic_compare_codegen.cpp
modified:   llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
  

[compiler-rt] [clang] [AIX] Undefine __STDC_NO_ATOMICS__ to enable c11 atomics functionality (PR #76025)

2023-12-20 Thread Kai Luo via cfe-commits

https://github.com/bzEq created https://github.com/llvm/llvm-project/pull/76025

This is copied from https://reviews.llvm.org/D109139.

`__STDC_NO_ATOMICS__` is predefined to indicate clang on AIX doesn't support 
`_Atomic` and not shipped with `stdatomic.h` yet. Actually `_Atomic` is already 
supported. For `stdatomic.h`, clang has implemented one in 
`clang/lib/Headers/stdatomic.h`.

For missing libc implementations,
```
atomic_flag_test_and_set
atomic_flag_test_and_set_explicit
atomic_flag_clear
atomic_flag_clear_explicit
atomic_thread_fence
atomic_signal_fence
```
Provide them via compiler-rt.

>From 326b21d8e822f52733388d411a06cc85109a3208 Mon Sep 17 00:00:00 2001
From: Kai Luo 
Date: Wed, 20 Dec 2023 08:38:40 +
Subject: [PATCH] Undefine __STDC_NO_ATOMICS__ to enable c11 atomics
 functionality

---
 clang/lib/Basic/Targets/OSTargets.h | 4 +---
 clang/test/Preprocessor/init-ppc.c  | 2 --
 compiler-rt/lib/builtins/CMakeLists.txt | 2 +-
 3 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/clang/lib/Basic/Targets/OSTargets.h 
b/clang/lib/Basic/Targets/OSTargets.h
index 342af4bbc42b7b..f76afad947cb7f 100644
--- a/clang/lib/Basic/Targets/OSTargets.h
+++ b/clang/lib/Basic/Targets/OSTargets.h
@@ -645,10 +645,8 @@ class AIXTargetInfo : public OSTargetInfo {
 Builder.defineMacro("__TOS_AIX__");
 Builder.defineMacro("__HOS_AIX__");
 
-if (Opts.C11) {
-  Builder.defineMacro("__STDC_NO_ATOMICS__");
+if (Opts.C11)
   Builder.defineMacro("__STDC_NO_THREADS__");
-}
 
 if (Opts.EnableAIXExtendedAltivecABI)
   Builder.defineMacro("__EXTABI__");
diff --git a/clang/test/Preprocessor/init-ppc.c 
b/clang/test/Preprocessor/init-ppc.c
index 3fb642af9d7420..8cdb2c6d3d350d 100644
--- a/clang/test/Preprocessor/init-ppc.c
+++ b/clang/test/Preprocessor/init-ppc.c
@@ -756,11 +756,9 @@
 // RUN: %clang_cc1 -x c -std=c11 -E -dM -ffreestanding 
-triple=powerpc-ibm-aix7.1.0.0 -fno-signed-char < /dev/null | FileCheck 
-match-full-lines -check-prefix PPC-AIX-STDC %s
 // RUN: %clang_cc1 -x c -std=gnu11 -E -dM -ffreestanding 
-triple=powerpc-ibm-aix7.1.0.0 -fno-signed-char < /dev/null | FileCheck 
-match-full-lines -check-prefix PPC-AIX-STDC %s
 // RUN: %clang_cc1 -x c -std=c17 -E -dM -ffreestanding 
-triple=powerpc-ibm-aix7.1.0.0 -fno-signed-char < /dev/null | FileCheck 
-match-full-lines -check-prefix PPC-AIX-STDC %s
-// PPC-AIX-STDC:#define __STDC_NO_ATOMICS__ 1
 // PPC-AIX-STDC:#define __STDC_NO_THREADS__ 1
 
 // RUN: %clang_cc1 -x c -std=c99 -E -dM -ffreestanding 
-triple=powerpc-ibm-aix7.1.0.0 -fno-signed-char < /dev/null | FileCheck 
-match-full-lines -check-prefix PPC-AIX-STDC-N %s
-// PPC-AIX-STDC-N-NOT:#define __STDC_NO_ATOMICS__ 1
 // PPC-AIX-STDC-N-NOT:#define __STDC_NO_THREADS__ 1
 
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc-ibm-aix7.1.0.0 
-mlong-double-64 < /dev/null | FileCheck -match-full-lines -check-prefix 
PPC-AIX-LD64 %s
diff --git a/compiler-rt/lib/builtins/CMakeLists.txt 
b/compiler-rt/lib/builtins/CMakeLists.txt
index e5b52db175d960..f57cd36eccd453 100644
--- a/compiler-rt/lib/builtins/CMakeLists.txt
+++ b/compiler-rt/lib/builtins/CMakeLists.txt
@@ -243,7 +243,7 @@ if(COMPILER_RT_HAS_ATOMIC_KEYWORD AND NOT 
COMPILER_RT_EXCLUDE_ATOMIC_BUILTIN)
   )
 endif()
 
-if(APPLE)
+if(APPLE OR OS_NAME MATCHES "AIX")
   set(GENERIC_SOURCES
 ${GENERIC_SOURCES}
 atomic_flag_clear.c

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


[clang] [compiler-rt] [mlir] [llvm] [libc] [clang-tools-extra] [OpenMP] atomic compare fail : Codegen support (PR #75709)

2023-12-20 Thread via cfe-commits

https://github.com/SunilKuravinakop updated 
https://github.com/llvm/llvm-project/pull/75709

>From fe931d64741f427629407bca3e68a61bec6f2b67 Mon Sep 17 00:00:00 2001
From: Sunil Kuravinakop 
Date: Sat, 16 Dec 2023 11:43:35 -0600
Subject: [PATCH 1/2] Adding parameter to fail clause (i.e. memory order
 clause) for codegen.

  Changes to be committed:
modified:   clang/lib/CodeGen/CGStmtOpenMP.cpp
---
 clang/lib/CodeGen/CGStmtOpenMP.cpp | 51 +++---
 1 file changed, 47 insertions(+), 4 deletions(-)

diff --git a/clang/lib/CodeGen/CGStmtOpenMP.cpp 
b/clang/lib/CodeGen/CGStmtOpenMP.cpp
index 478d6dbf9ca81d..a502db7ac3a5e0 100644
--- a/clang/lib/CodeGen/CGStmtOpenMP.cpp
+++ b/clang/lib/CodeGen/CGStmtOpenMP.cpp
@@ -6516,10 +6516,6 @@ static void emitOMPAtomicExpr(CodeGenFunction &CGF, 
OpenMPClauseKind Kind,
  IsPostfixUpdate, IsFailOnly, Loc);
 break;
   }
-  case OMPC_fail: {
-//TODO
-break;
-  }
   default:
 llvm_unreachable("Clause is not allowed in 'omp atomic'.");
   }
@@ -6527,6 +6523,8 @@ static void emitOMPAtomicExpr(CodeGenFunction &CGF, 
OpenMPClauseKind Kind,
 
 void CodeGenFunction::EmitOMPAtomicDirective(const OMPAtomicDirective &S) {
   llvm::AtomicOrdering AO = llvm::AtomicOrdering::Monotonic;
+  // Fail Memory Clause Ordering.
+  llvm::AtomicOrdering FO = llvm::AtomicOrdering::Monotonic;
   bool MemOrderingSpecified = false;
   if (S.getSingleClause()) {
 AO = llvm::AtomicOrdering::SequentiallyConsistent;
@@ -6580,6 +6578,51 @@ void CodeGenFunction::EmitOMPAtomicDirective(const 
OMPAtomicDirective &S) {
 }
   }
 
+  if (KindsEncountered.contains(OMPC_compare) &&
+  KindsEncountered.contains(OMPC_fail)) {
+Kind = OMPC_compare;
+const OMPFailClause *fC = S.getSingleClause();
+if (fC) {
+  OpenMPClauseKind fP = fC->getFailParameter();
+  if (fP == llvm::omp::OMPC_relaxed)
+FO = llvm::AtomicOrdering::Monotonic;
+  else if (fP == llvm::omp::OMPC_acquire)
+FO = llvm::AtomicOrdering::Acquire;
+  else if (fP == llvm::omp::OMPC_seq_cst)
+FO = llvm::AtomicOrdering::SequentiallyConsistent;
+}
+
+// Logic for 2 memory order clauses in the atomic directive.
+// e.g. #pragma omp atomic compare capture release fail(seq_cst)
+//  if(x > e) { x = j; } else { k = x; }
+// To provide the Memory Order clause in atomic directive
+// there are 2 instructions in LLVM IR atomicrmw & cmpxchgl.
+// 1) atomicrmw can use only 1 memory order clause and can contain the
+//operator in if condition.
+// 2) cmpxchgl can use 2 memory order clauses : Success memory order clause
+//& fail parameter memory clause. However, cmpxchgl uses only equality
+//operator.
+// We need to change atomicrmw to contain the fail parameter clause or add
+// a new instruction in LLVM IR. Changes in LLVM IR need to be done
+// seperately and at present we will use the logic of using the more strict
+// memory order clause of success or fail memory order clauses for the
+// atomicrmw. The following logic takes care of this change in the memory
+// order clause.
+if (AO == llvm::AtomicOrdering::Monotonic)
+  AO = FO;
+else if (FO == llvm::AtomicOrdering::Monotonic)
+  AO = AO;
+else if (AO == llvm::AtomicOrdering::SequentiallyConsistent ||
+ FO == llvm::AtomicOrdering::SequentiallyConsistent)
+  AO = llvm::AtomicOrdering::SequentiallyConsistent;
+else if (AO == llvm::AtomicOrdering::Acquire)
+  AO = llvm::AtomicOrdering::Acquire;
+else if (AO == llvm::AtomicOrdering::Release)
+  AO = llvm::AtomicOrdering::AcquireRelease;
+else if (AO == llvm::AtomicOrdering::AcquireRelease)
+  AO = llvm::AtomicOrdering::AcquireRelease;
+  }
+
   LexicalScope Scope(*this, S.getSourceRange());
   EmitStopPoint(S.getAssociatedStmt());
   emitOMPAtomicExpr(*this, Kind, AO, S.isPostfixUpdate(), S.getX(), S.getV(),

>From 9cc33631c89c4fd4dce8a274fed700febe5dfa90 Mon Sep 17 00:00:00 2001
From: Sunil Kuravinakop 
Date: Tue, 19 Dec 2023 23:49:03 -0600
Subject: [PATCH 2/2] 1) Since the{if(x == e) {x = v;} else {d = x;}}
 results in generation of cmpxchg in the LLVM IR, the memory order clause in
 "fail" clause is now being added.In case of other operators ">" & "<"
 e.g.dx = dx > de ? de : dx; result in atomicrmw in the LLVM IR.
 "atomicrmw" can have only one memory order clause. Currently, the memory
 order clause is ignored. 2) Test cases for codegen 3) In SemaOpenMP.cpp,
 addedEncounteredAtomicKinds.contains(OMPC_compare) instead of AtomicKind
 == OMPC_compare. This was to accomodate where AtomicKind is OMPC_capture.

  Changes to be committed:
modified:   clang/lib/CodeGen/CGStmtOpenMP.cpp
modified:   clang/lib/Sema/SemaOpenMP.cpp
modified:   clang/test/OpenMP/atomic_compare_codegen.cpp
modified:   llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
  

[compiler-rt] [clang] [AIX] Undefine __STDC_NO_ATOMICS__ to enable c11 atomics functionality (PR #76025)

2023-12-20 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Kai Luo (bzEq)


Changes

This is copied from https://reviews.llvm.org/D109139.

`__STDC_NO_ATOMICS__` is predefined to indicate clang on AIX doesn't support 
`_Atomic` and not shipped with `stdatomic.h` yet. Actually `_Atomic` is already 
supported. For `stdatomic.h`, clang has implemented one in 
`clang/lib/Headers/stdatomic.h`.

For missing libc implementations,
```
atomic_flag_test_and_set
atomic_flag_test_and_set_explicit
atomic_flag_clear
atomic_flag_clear_explicit
atomic_thread_fence
atomic_signal_fence
```
Provide them via compiler-rt.

---
Full diff: https://github.com/llvm/llvm-project/pull/76025.diff


3 Files Affected:

- (modified) clang/lib/Basic/Targets/OSTargets.h (+1-3) 
- (modified) clang/test/Preprocessor/init-ppc.c (-2) 
- (modified) compiler-rt/lib/builtins/CMakeLists.txt (+1-1) 


``diff
diff --git a/clang/lib/Basic/Targets/OSTargets.h 
b/clang/lib/Basic/Targets/OSTargets.h
index 342af4bbc42b7b..f76afad947cb7f 100644
--- a/clang/lib/Basic/Targets/OSTargets.h
+++ b/clang/lib/Basic/Targets/OSTargets.h
@@ -645,10 +645,8 @@ class AIXTargetInfo : public OSTargetInfo {
 Builder.defineMacro("__TOS_AIX__");
 Builder.defineMacro("__HOS_AIX__");
 
-if (Opts.C11) {
-  Builder.defineMacro("__STDC_NO_ATOMICS__");
+if (Opts.C11)
   Builder.defineMacro("__STDC_NO_THREADS__");
-}
 
 if (Opts.EnableAIXExtendedAltivecABI)
   Builder.defineMacro("__EXTABI__");
diff --git a/clang/test/Preprocessor/init-ppc.c 
b/clang/test/Preprocessor/init-ppc.c
index 3fb642af9d7420..8cdb2c6d3d350d 100644
--- a/clang/test/Preprocessor/init-ppc.c
+++ b/clang/test/Preprocessor/init-ppc.c
@@ -756,11 +756,9 @@
 // RUN: %clang_cc1 -x c -std=c11 -E -dM -ffreestanding 
-triple=powerpc-ibm-aix7.1.0.0 -fno-signed-char < /dev/null | FileCheck 
-match-full-lines -check-prefix PPC-AIX-STDC %s
 // RUN: %clang_cc1 -x c -std=gnu11 -E -dM -ffreestanding 
-triple=powerpc-ibm-aix7.1.0.0 -fno-signed-char < /dev/null | FileCheck 
-match-full-lines -check-prefix PPC-AIX-STDC %s
 // RUN: %clang_cc1 -x c -std=c17 -E -dM -ffreestanding 
-triple=powerpc-ibm-aix7.1.0.0 -fno-signed-char < /dev/null | FileCheck 
-match-full-lines -check-prefix PPC-AIX-STDC %s
-// PPC-AIX-STDC:#define __STDC_NO_ATOMICS__ 1
 // PPC-AIX-STDC:#define __STDC_NO_THREADS__ 1
 
 // RUN: %clang_cc1 -x c -std=c99 -E -dM -ffreestanding 
-triple=powerpc-ibm-aix7.1.0.0 -fno-signed-char < /dev/null | FileCheck 
-match-full-lines -check-prefix PPC-AIX-STDC-N %s
-// PPC-AIX-STDC-N-NOT:#define __STDC_NO_ATOMICS__ 1
 // PPC-AIX-STDC-N-NOT:#define __STDC_NO_THREADS__ 1
 
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc-ibm-aix7.1.0.0 
-mlong-double-64 < /dev/null | FileCheck -match-full-lines -check-prefix 
PPC-AIX-LD64 %s
diff --git a/compiler-rt/lib/builtins/CMakeLists.txt 
b/compiler-rt/lib/builtins/CMakeLists.txt
index e5b52db175d960..f57cd36eccd453 100644
--- a/compiler-rt/lib/builtins/CMakeLists.txt
+++ b/compiler-rt/lib/builtins/CMakeLists.txt
@@ -243,7 +243,7 @@ if(COMPILER_RT_HAS_ATOMIC_KEYWORD AND NOT 
COMPILER_RT_EXCLUDE_ATOMIC_BUILTIN)
   )
 endif()
 
-if(APPLE)
+if(APPLE OR OS_NAME MATCHES "AIX")
   set(GENERIC_SOURCES
 ${GENERIC_SOURCES}
 atomic_flag_clear.c

``




https://github.com/llvm/llvm-project/pull/76025
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [flang] [llvm] [clang-tools-extra] [flang] Pass to add frame pointer attribute (PR #74598)

2023-12-20 Thread Radu Salavat via cfe-commits

https://github.com/Radu2k updated 
https://github.com/llvm/llvm-project/pull/74598

>From fda39a4d196c6cdafe3ee42358c962ef0173aaca Mon Sep 17 00:00:00 2001
From: Radu2k 
Date: Wed, 6 Dec 2023 14:39:24 +
Subject: [PATCH 01/12] Pass to add frame pointer attribute

---
 .../include/flang/Frontend/CodeGenOptions.def |  1 +
 .../flang/Optimizer/Transforms/Passes.h   |  8 ++
 .../flang/Optimizer/Transforms/Passes.td  | 17 
 flang/include/flang/Tools/CLOptions.inc   |  4 +
 flang/include/flang/Tools/CrossToolHelpers.h  |  2 +
 flang/lib/Frontend/CompilerInvocation.cpp | 13 +++
 flang/lib/Optimizer/Transforms/CMakeLists.txt |  1 +
 .../lib/Optimizer/Transforms/FunctionAttr.cpp | 97 +++
 flang/test/Driver/func-attr.f90   | 12 +++
 .../test/Driver/mlir-debug-pass-pipeline.f90  |  2 +
 flang/test/Driver/mlir-pass-pipeline.f90  |  2 +
 flang/test/Driver/save-mlir-temps.f90 |  4 +-
 flang/test/Fir/basic-program.fir  |  2 +
 flang/test/Fir/box-offset-codegen.fir |  8 +-
 flang/test/Fir/polymorphic.fir|  8 +-
 flang/test/Fir/tbaa-codegen.fir   |  2 +-
 flang/test/Fir/tbaa-codegen2.fir  |  2 +-
 17 files changed, 173 insertions(+), 12 deletions(-)
 create mode 100644 flang/lib/Optimizer/Transforms/FunctionAttr.cpp
 create mode 100644 flang/test/Driver/func-attr.f90

diff --git a/flang/include/flang/Frontend/CodeGenOptions.def 
b/flang/include/flang/Frontend/CodeGenOptions.def
index 72e7bdab12a14d..774f225974d7ea 100644
--- a/flang/include/flang/Frontend/CodeGenOptions.def
+++ b/flang/include/flang/Frontend/CodeGenOptions.def
@@ -38,6 +38,7 @@ CODEGENOPT(Underscoring, 1, 1)
 ENUM_CODEGENOPT(RelocationModel, llvm::Reloc::Model, 3, llvm::Reloc::PIC_) 
///< Name of the relocation model to use.
 ENUM_CODEGENOPT(DebugInfo,  llvm::codegenoptions::DebugInfoKind, 4,  
llvm::codegenoptions::NoDebugInfo) ///< Level of debug info to generate
 ENUM_CODEGENOPT(VecLib, llvm::driver::VectorLibrary, 3, 
llvm::driver::VectorLibrary::NoLibrary) ///< Vector functions library to use
+ENUM_CODEGENOPT(FramePointer, llvm::FramePointerKind, 2, 
llvm::FramePointerKind::None) /// frame-pointer: all,non-leaf,none
 
 #undef CODEGENOPT
 #undef ENUM_CODEGENOPT
diff --git a/flang/include/flang/Optimizer/Transforms/Passes.h 
b/flang/include/flang/Optimizer/Transforms/Passes.h
index 92bc7246eca700..c5f09fc2581bd3 100644
--- a/flang/include/flang/Optimizer/Transforms/Passes.h
+++ b/flang/include/flang/Optimizer/Transforms/Passes.h
@@ -12,6 +12,7 @@
 #include "flang/Optimizer/Dialect/FIROps.h"
 #include "mlir/Pass/Pass.h"
 #include "mlir/Pass/PassRegistry.h"
+#include "llvm/Support/CodeGen.h"
 #include 
 
 namespace mlir {
@@ -83,6 +84,13 @@ std::unique_ptr createVScaleAttrPass();
 std::unique_ptr
 createVScaleAttrPass(std::pair vscaleAttr);
 
+struct FunctionAttrTypes{
+llvm::FramePointerKind framePointerKind;
+};
+
+std::unique_ptr createFunctionAttrPass();
+std::unique_ptr createFunctionAttrPass(FunctionAttrTypes 
&functionAttr);
+
 // declarative passes
 #define GEN_PASS_REGISTRATION
 #include "flang/Optimizer/Transforms/Passes.h.inc"
diff --git a/flang/include/flang/Optimizer/Transforms/Passes.td 
b/flang/include/flang/Optimizer/Transforms/Passes.td
index c3768fd2d689c1..eddf94e162e9c9 100644
--- a/flang/include/flang/Optimizer/Transforms/Passes.td
+++ b/flang/include/flang/Optimizer/Transforms/Passes.td
@@ -349,4 +349,21 @@ def VScaleAttr : Pass<"vscale-attr", "mlir::func::FuncOp"> 
{
   let constructor = "::fir::createVScaleAttrPass()";
 }
 
+def FunctionAttr : Pass<"function-attr", "mlir::func::FuncOp"> {
+  let summary = "Enhance functions with different attributes";
+  let description = [{ This feature introduces a general attribute aimed at 
customizing function characteristics. 
+ Options include:
+ Add "frame-pointer" attribute to functions: Set an attribute for the 
frame pointer on functions, to enable 
+ the compiler, to avoid saving the frame pointer in a register in 
functions where it is unnecessary. 
+ This eliminates the need for instructions to save, establish, and restore 
frame pointers, while also freeing up an additional register in numerous 
functions. 
+ However, this approach can make debugging unfeasible on certain machines.
+  }];
+  let options = [
+Option<"framePointerKind", "frame-pointer",
+   "mlir::LLVM::framePointerKind::FramePointerKind", 
/*default=*/"mlir::LLVM::framePointerKind::FramePointerKind{}",
+   "frame pointer">,
+  ];
+  let constructor = "::fir::createFunctionAttrPass()";
+}
+
 #endif // FLANG_OPTIMIZER_TRANSFORMS_PASSES
diff --git a/flang/include/flang/Tools/CLOptions.inc 
b/flang/include/flang/Tools/CLOptions.inc
index d3e4dc6cd4a243..3494e588b34606 100644
--- a/flang/include/flang/Tools/CLOptions.inc
+++ b/flang/include/flang/Tools/CLOptions.inc
@@ -311,6 +311,10 @@ inline void createDefaultFIRCodeGenPassPipeline(
   if (config.VScaleMin

[clang] [flang] [llvm] [clang-tools-extra] [flang] Pass to add frame pointer attribute (PR #74598)

2023-12-20 Thread Radu Salavat via cfe-commits


@@ -245,6 +245,24 @@ static void 
parseCodeGenArgs(Fortran::frontend::CodeGenOptions &opts,
 
   opts.AliasAnalysis = opts.OptimizationLevel > 0;
 
+  if (const llvm::opt::Arg *a =
+  args.getLastArg(clang::driver::options::OPT_mframe_pointer_EQ)) {
+llvm::StringRef s = a->getValue();
+
+if (!(s == "none" || s == "non-leaf" || s == "all")) {
+  const auto debugWarningId = diags.getCustomDiagID(
+  clang::DiagnosticsEngine::Error, "Frame pointer: %0");

Radu2k wrote:

Just added, thanks for pointing it out!

https://github.com/llvm/llvm-project/pull/74598
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [compiler-rt] [mlir] [llvm] [libc] [clang-tools-extra] [OpenMP] atomic compare fail : Codegen support (PR #75709)

2023-12-20 Thread via cfe-commits

https://github.com/SunilKuravinakop ready_for_review 
https://github.com/llvm/llvm-project/pull/75709
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[llvm] [clang-tools-extra] [flang] [clang] [flang] Pass to add frame pointer attribute (PR #74598)

2023-12-20 Thread Andrzej Warzyński via cfe-commits


@@ -245,6 +245,24 @@ static void 
parseCodeGenArgs(Fortran::frontend::CodeGenOptions &opts,
 
   opts.AliasAnalysis = opts.OptimizationLevel > 0;
 
+  if (const llvm::opt::Arg *a =
+  args.getLastArg(clang::driver::options::OPT_mframe_pointer_EQ)) {
+llvm::StringRef s = a->getValue();
+
+if (!(s == "none" || s == "non-leaf" || s == "all")) {
+  const auto debugWarningId = diags.getCustomDiagID(
+  clang::DiagnosticsEngine::Error, "Frame pointer: %0");
+  diags.Report(debugWarningId).AddString(a->getValue());
+}
+
+if (s == "none")
+  opts.setFramePointer(llvm::FramePointerKind::None);
+else if (s == "non-leaf")
+  opts.setFramePointer(llvm::FramePointerKind::NonLeaf);
+else
+  opts.setFramePointer(llvm::FramePointerKind::All);

banach-space wrote:

1. You don't need `else` in this block.
2. You could use `llvm::StringSwitch` and use the default value to mark a 
failure (as opposed to `if (!(s == "none" || s == "non-leaf" || s == "all"))` 
above)

https://github.com/llvm/llvm-project/pull/74598
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [flang] [llvm] [clang-tools-extra] [flang] Pass to add frame pointer attribute (PR #74598)

2023-12-20 Thread Andrzej Warzyński via cfe-commits


@@ -51,9 +51,9 @@
 ! Content to check from the MLIR outputs
 !--
 ! MLIR-FIR-NOT: llvm.func
-! MLIR-FIR: func.func @{{.*}}main() {
+! MLIR-FIR: func.func @{{.*}}main(){{.*}}{

banach-space wrote:

What do these extra braces capture?

https://github.com/llvm/llvm-project/pull/74598
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clang] [llvm] [flang] [flang] Pass to add frame pointer attribute (PR #74598)

2023-12-20 Thread Andrzej Warzyński via cfe-commits


@@ -245,6 +245,24 @@ static void 
parseCodeGenArgs(Fortran::frontend::CodeGenOptions &opts,
 
   opts.AliasAnalysis = opts.OptimizationLevel > 0;
 
+  if (const llvm::opt::Arg *a =
+  args.getLastArg(clang::driver::options::OPT_mframe_pointer_EQ)) {
+llvm::StringRef s = a->getValue();
+
+if (!(s == "none" || s == "non-leaf" || s == "all")) {
+  const auto debugWarningId = diags.getCustomDiagID(
+  clang::DiagnosticsEngine::Error, "Frame pointer: %0");

banach-space wrote:

I couldn't find it - which one is it?

https://github.com/llvm/llvm-project/pull/74598
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [AST] RecursiveASTVisitor: traverse the require clause for partial template specializations. (PR #75795)

2023-12-20 Thread via cfe-commits

https://github.com/jensmassberg approved this pull request.

Thanks for the fix!

https://github.com/llvm/llvm-project/pull/75795
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][dataflow] Add `Environment::get<>()`. (PR #76027)

2023-12-20 Thread via cfe-commits

https://github.com/martinboehme created 
https://github.com/llvm/llvm-project/pull/76027

This template function casts the result of `getValue()` or
`getStorageLocation()` to a given subclass of `Value` or `StorageLocation`
(using `cast_or_null`).

It's a common pattern to do something like this:

```cxx
auto *Val = cast_or_null(Env.getValue(E));
```

This can now be expressed more concisely like this:

```cxx
auto *Val = Env.get(E);
```

Instead of adding a new method `get()`, I had originally considered simply
adding a template parameter to `getValue()` and `getStorageLocation()` (with a
default argument of `Value` or `StorageLocation`), but this results in an
undesirable repetition at the callsite, e.g.
`getStorageLocation(...)`. The `Value` and
`StorageLocation` in the method name adds nothing of value when the template
argument already contains this information, so it seemed best to shorten the
method name to simply `get()`.


>From e8f269ba41f4471c24050a0902be1f8b183725e9 Mon Sep 17 00:00:00 2001
From: Martin Braenne 
Date: Wed, 20 Dec 2023 09:06:33 +
Subject: [PATCH] [clang][dataflow] Add `Environment::get<>()`.

This template function casts the result of `getValue()` or
`getStorageLocation()` to a given subclass of `Value` or `StorageLocation`
(using `cast_or_null`).

It's a common pattern to do something like this:

```cxx
auto *Val = cast_or_null(Env.getValue(E));
```

This can now be expressed more concisely like this:

```cxx
auto *Val = Env.get(E);
```

Instead of adding a new method `get()`, I had originally considered simply
adding a template parameter to `getValue()` and `getStorageLocation()` (with a
default argument of `Value` or `StorageLocation`), but this results in an
undesirable repetition at the callsite, e.g.
`getStorageLocation(...)`. The `Value` and
`StorageLocation` in the method name adds nothing of value when the template
argument already contains this information, so it seemed best to shorten the
method name to simply `get()`.
---
 .../FlowSensitive/DataflowEnvironment.h   | 36 +++
 .../FlowSensitive/DataflowEnvironment.cpp | 14 
 .../Models/UncheckedOptionalAccessModel.cpp   | 31 +++-
 .../lib/Analysis/FlowSensitive/RecordOps.cpp  |  8 ++---
 clang/lib/Analysis/FlowSensitive/Transfer.cpp | 16 -
 .../TypeErasedDataflowAnalysis.cpp|  2 +-
 .../FlowSensitive/SignAnalysisTest.cpp|  2 +-
 7 files changed, 66 insertions(+), 43 deletions(-)

diff --git a/clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h 
b/clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
index 5943af50b6ad8f..73827a7ef7f424 100644
--- a/clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
+++ b/clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
@@ -289,6 +289,22 @@ class Environment {
   ///  `E` must be a glvalue or a `BuiltinType::BuiltinFn`
   StorageLocation *getStorageLocation(const Expr &E) const;
 
+  /// Returns the result of casting `getStorageLocation(...)` to a subclass of
+  /// `StorageLocation` (using `cast_or_null`).
+  /// This assert-fails if the result of `getStorageLocation(...)` is not of
+  /// type `T *`; if the storage location is not guaranteed to have type `T *`,
+  /// consider using `dyn_cast_or_null(getStorageLocation(...))` instead.
+  template 
+  std::enable_if_t, T *>
+  get(const ValueDecl &D) const {
+return cast_or_null(getStorageLocation(D));
+  }
+  template 
+  std::enable_if_t, T *>
+  get(const Expr &E) const {
+return cast_or_null(getStorageLocation(E));
+  }
+
   /// Returns the storage location assigned to the `this` pointee in the
   /// environment or null if the `this` pointee has no assigned storage 
location
   /// in the environment.
@@ -457,6 +473,26 @@ class Environment {
   /// storage location in the environment, otherwise returns null.
   Value *getValue(const Expr &E) const;
 
+  /// Returns the result of casting `getValue(...)` to a subclass of `Value`
+  /// (using `cast_or_null`).
+  /// This assert-fails if the result of `getValue(...)` is not of type `T *`;
+  /// if the value is not guaranteed to have type `T * `, consider using
+  /// `dyn_cast_or_null(getValue(...))` instead.
+  template 
+  std::enable_if_t, T *>
+  get(const StorageLocation &Loc) const {
+return cast_or_null(getValue(Loc));
+  }
+  template 
+  std::enable_if_t, T *>
+  get(const ValueDecl &D) const {
+return cast_or_null(getValue(D));
+  }
+  template 
+  std::enable_if_t, T *> get(const Expr &E) const {
+return cast_or_null(getValue(E));
+  }
+
   // FIXME: should we deprecate the following & call arena().create() directly?
 
   /// Creates a `T` (some subclass of `Value`), forwarding `args` to the
diff --git a/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp 
b/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
index 93919cd0243d0c..46841bac35ccb3 100644
--- a/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp

[clang] [clang][dataflow] Add `Environment::get<>()`. (PR #76027)

2023-12-20 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-analysis

Author: None (martinboehme)


Changes

This template function casts the result of `getValue()` or
`getStorageLocation()` to a given subclass of `Value` or `StorageLocation`
(using `cast_or_null`).

It's a common pattern to do something like this:

```cxx
auto *Val = cast_or_null(Env.getValue(E));
```

This can now be expressed more concisely like this:

```cxx
auto *Val = Env.get(E);
```

Instead of adding a new method `get()`, I had originally considered simply
adding a template parameter to `getValue()` and `getStorageLocation()` (with a
default argument of `Value` or `StorageLocation`), but this results in an
undesirable repetition at the callsite, e.g.
`getStorageLocation(...)`. The `Value` and
`StorageLocation` in the method name adds nothing of value when the template
argument already contains this information, so it seemed best to shorten the
method name to simply `get()`.


---
Full diff: https://github.com/llvm/llvm-project/pull/76027.diff


7 Files Affected:

- (modified) clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h 
(+36) 
- (modified) clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp (+6-8) 
- (modified) 
clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp 
(+12-19) 
- (modified) clang/lib/Analysis/FlowSensitive/RecordOps.cpp (+4-4) 
- (modified) clang/lib/Analysis/FlowSensitive/Transfer.cpp (+6-10) 
- (modified) clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp 
(+1-1) 
- (modified) clang/unittests/Analysis/FlowSensitive/SignAnalysisTest.cpp (+1-1) 


``diff
diff --git a/clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h 
b/clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
index 5943af50b6ad8f..73827a7ef7f424 100644
--- a/clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
+++ b/clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
@@ -289,6 +289,22 @@ class Environment {
   ///  `E` must be a glvalue or a `BuiltinType::BuiltinFn`
   StorageLocation *getStorageLocation(const Expr &E) const;
 
+  /// Returns the result of casting `getStorageLocation(...)` to a subclass of
+  /// `StorageLocation` (using `cast_or_null`).
+  /// This assert-fails if the result of `getStorageLocation(...)` is not of
+  /// type `T *`; if the storage location is not guaranteed to have type `T *`,
+  /// consider using `dyn_cast_or_null(getStorageLocation(...))` instead.
+  template 
+  std::enable_if_t, T *>
+  get(const ValueDecl &D) const {
+return cast_or_null(getStorageLocation(D));
+  }
+  template 
+  std::enable_if_t, T *>
+  get(const Expr &E) const {
+return cast_or_null(getStorageLocation(E));
+  }
+
   /// Returns the storage location assigned to the `this` pointee in the
   /// environment or null if the `this` pointee has no assigned storage 
location
   /// in the environment.
@@ -457,6 +473,26 @@ class Environment {
   /// storage location in the environment, otherwise returns null.
   Value *getValue(const Expr &E) const;
 
+  /// Returns the result of casting `getValue(...)` to a subclass of `Value`
+  /// (using `cast_or_null`).
+  /// This assert-fails if the result of `getValue(...)` is not of type `T *`;
+  /// if the value is not guaranteed to have type `T * `, consider using
+  /// `dyn_cast_or_null(getValue(...))` instead.
+  template 
+  std::enable_if_t, T *>
+  get(const StorageLocation &Loc) const {
+return cast_or_null(getValue(Loc));
+  }
+  template 
+  std::enable_if_t, T *>
+  get(const ValueDecl &D) const {
+return cast_or_null(getValue(D));
+  }
+  template 
+  std::enable_if_t, T *> get(const Expr &E) const {
+return cast_or_null(getValue(E));
+  }
+
   // FIXME: should we deprecate the following & call arena().create() directly?
 
   /// Creates a `T` (some subclass of `Value`), forwarding `args` to the
diff --git a/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp 
b/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
index 93919cd0243d0c..46841bac35ccb3 100644
--- a/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
+++ b/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
@@ -489,8 +489,7 @@ Environment Environment::pushCall(const CallExpr *Call) 
const {
   if (const auto *MethodCall = dyn_cast(Call)) {
 if (const Expr *Arg = MethodCall->getImplicitObjectArgument()) {
   if (!isa(Arg))
-  Env.ThisPointeeLoc =
-  cast(getStorageLocation(*Arg));
+Env.ThisPointeeLoc = get(*Arg);
   // Otherwise (when the argument is `this`), retain the current
   // environment's `ThisPointeeLoc`.
 }
@@ -1034,7 +1033,7 @@ RecordStorageLocation *getImplicitObjectLocation(const 
CXXMemberCallExpr &MCE,
   if (ImplicitObject == nullptr)
 return nullptr;
   if (ImplicitObject->getType()->isPointerType()) {
-if (auto *Val = cast_or_null(Env.getValue(*ImplicitObject)))
+if

[clang] [clang][dataflow] Add `Environment::get<>()`. (PR #76027)

2023-12-20 Thread via cfe-commits

https://github.com/martinboehme edited 
https://github.com/llvm/llvm-project/pull/76027
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 3b1f06e - [AST] RecursiveASTVisitor: traverse the require clause for partial template specializations. (#75795)

2023-12-20 Thread via cfe-commits

Author: Haojian Wu
Date: 2023-12-20T10:08:43+01:00
New Revision: 3b1f06e52712a56bf33757d596482c60013d63fd

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

LOG: [AST] RecursiveASTVisitor: traverse the require clause for partial 
template specializations. (#75795)

This fixes tooling (clangd, include-cleaner) bugs where we miss
functionalities on concept AST nodes.

Added: 


Modified: 
clang/include/clang/AST/RecursiveASTVisitor.h
clang/unittests/Tooling/RecursiveASTVisitorTests/Concept.cpp

Removed: 




diff  --git a/clang/include/clang/AST/RecursiveASTVisitor.h 
b/clang/include/clang/AST/RecursiveASTVisitor.h
index c501801b95bd95..8f2714e142bbe3 100644
--- a/clang/include/clang/AST/RecursiveASTVisitor.h
+++ b/clang/include/clang/AST/RecursiveASTVisitor.h
@@ -2036,12 +2036,7 @@ bool 
RecursiveASTVisitor::TraverseTemplateArgumentLocsHelper(
 #define DEF_TRAVERSE_TMPL_PART_SPEC_DECL(TMPLDECLKIND, DECLKIND)   
\
   DEF_TRAVERSE_DECL(TMPLDECLKIND##TemplatePartialSpecializationDecl, { 
\
 /* The partial specialization. */  
\
-if (TemplateParameterList *TPL = D->getTemplateParameters()) { 
\
-  for (TemplateParameterList::iterator I = TPL->begin(), E = TPL->end();   
\
-   I != E; ++I) {  
\
-TRY_TO(TraverseDecl(*I));  
\
-  }
\
-}  
\
+TRY_TO(TraverseTemplateParameterListHelper(D->getTemplateParameters()));   
\
 /* The args that remains unspecialized. */ 
\
 TRY_TO(TraverseTemplateArgumentLocsHelper( 
\
 D->getTemplateArgsAsWritten()->getTemplateArgs(),  
\

diff  --git a/clang/unittests/Tooling/RecursiveASTVisitorTests/Concept.cpp 
b/clang/unittests/Tooling/RecursiveASTVisitorTests/Concept.cpp
index 594b299b543694..6a8d91672f1d93 100644
--- a/clang/unittests/Tooling/RecursiveASTVisitorTests/Concept.cpp
+++ b/clang/unittests/Tooling/RecursiveASTVisitorTests/Concept.cpp
@@ -86,6 +86,25 @@ TEST(RecursiveASTVisitor, Concepts) {
   EXPECT_EQ(3, Visitor.ConceptRequirementsTraversed);
   EXPECT_EQ(1, Visitor.ConceptReferencesTraversed);
   EXPECT_EQ(1, Visitor.ConceptReferencesVisited);
+
+  Visitor = {};
+  llvm::StringRef Code =
+  R"cpp(
+template concept True = false;
+template  struct Foo {};
+
+template 
+  requires requires { requires True; }
+struct Foo {};
+
+template  requires True
+struct Foo  {};
+  )cpp";
+  EXPECT_TRUE(Visitor.runOver(Code, ConceptVisitor::Lang_CXX2a));
+  // Check that the concept references from the partial specializations are
+  // visited.
+  EXPECT_EQ(2, Visitor.ConceptReferencesTraversed);
+  EXPECT_EQ(2, Visitor.ConceptReferencesVisited);
 }
 
 struct VisitDeclOnlyOnce : ExpectedLocationVisitor {



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


[clang] [AST] RecursiveASTVisitor: traverse the require clause for partial template specializations. (PR #75795)

2023-12-20 Thread Haojian Wu via cfe-commits

https://github.com/hokein closed https://github.com/llvm/llvm-project/pull/75795
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][Sema] Fix Wswitch-default bad warning in template (PR #76007)

2023-12-20 Thread via cfe-commits

https://github.com/cor3ntin approved this pull request.

LGTM, thanks

https://github.com/llvm/llvm-project/pull/76007
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[llvm] [clang] [AArch64] Update target feature requirements of SVE bfloat instructions (PR #75596)

2023-12-20 Thread via cfe-commits

https://github.com/CarolineConcatto approved this pull request.


https://github.com/llvm/llvm-project/pull/75596
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][Parser] Fix crash of clang when using C++ constructs like :: in C code (PR #74926)

2023-12-20 Thread via cfe-commits


@@ -2679,6 +2679,8 @@ Parser::ParseCXXClassMemberDeclaration(AccessSpecifier AS,
ParsedAttributes &AccessAttrs,
const ParsedTemplateInfo &TemplateInfo,
ParsingDeclRAIIObject *TemplateDiags) {
+  assert(getLangOpts().CPlusPlus &&
+ "Call sites of this function should be guarded by checking for C++");

cor3ntin wrote:

```suggestion
 "ParseCXXClassMemberDeclaration should only be called in C++ mode");
```

https://github.com/llvm/llvm-project/pull/74926
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[compiler-rt] [lld] [lldb] [flang] [clang] [mlir] [llvm] [libcxx] [builtins] Refactor cpu_model support to reduce #if nesting. NFCI (PR #75635)

2023-12-20 Thread Petr Hosek via cfe-commits

petrhosek wrote:

I have discovered another issue, on Fuchsia `libclang_rt.builtins.a` now has a 
reference to `getauxval` which it didn't have before. This is really 
undesirable because on Fuchsia, there's no `auxv` to begin with. I believe this 
is because before, the `__init_cpu_features` definition was guarded by:

```
#if defined(__has_include)
#if __has_include()
#include 
...
#if __has_include()
#include 
```
These `#if __has_include(...)` conditionals would evaluate to false on Fuchsia 
since we don't have those headers, but they have been moved in the refactored 
version.

https://github.com/llvm/llvm-project/pull/75635
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][Parser] Fix crash of clang when using C++ constructs like :: in C code (PR #74926)

2023-12-20 Thread via cfe-commits

https://github.com/cor3ntin commented:

Thanks for fixing this bug.
LGTM modulo nit

https://github.com/llvm/llvm-project/pull/74926
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][SME] Add IsStreamingOrSVE2p1 (PR #75958)

2023-12-20 Thread Sander de Smalen via cfe-commits

https://github.com/sdesmalen-arm edited 
https://github.com/llvm/llvm-project/pull/75958
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][SME] Add IsStreamingOrSVE2p1 (PR #75958)

2023-12-20 Thread Sander de Smalen via cfe-commits

https://github.com/sdesmalen-arm commented:

I also noticed that a number of tests are failing with your patch at the moment.

https://github.com/llvm/llvm-project/pull/75958
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][SME] Add IsStreamingOrSVE2p1 (PR #75958)

2023-12-20 Thread Sander de Smalen via cfe-commits


@@ -679,6 +679,7 @@ bool AArch64TargetInfo::hasFeature(StringRef Feature) const 
{
   .Case("f32mm", FPU & SveMode && HasMatmulFP32)
   .Case("f64mm", FPU & SveMode && HasMatmulFP64)
   .Case("sve2", FPU & SveMode && HasSVE2)
+  .Case("sve2p1", HasSVE2p1)

sdesmalen-arm wrote:

It seems the changes for `HasSVE2p1` in this patch are not required for the 
tests to pass. I think the `hasFeature` method returns the value set by the 
Clang command rather than whatever is on the attribute. The 
`evaluateRequiredTargetFeatures` gets its information from elsewhere (not using 
this interface).

https://github.com/llvm/llvm-project/pull/75958
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][SME] Add IsStreamingOrSVE2p1 (PR #75958)

2023-12-20 Thread Sander de Smalen via cfe-commits


@@ -8,7 +8,7 @@
 // RUN: %clang_cc1 -fclang-abi-compat=latest -DSVE_OVERLOADED_FORMS -triple 
aarch64-none-linux-gnu -target-feature +sve2p1 -S -disable-O0-optnone -Werror 
-Wall -emit-llvm -o - %s | opt -S -p mem2reg,instcombine,tailcallelim | 
FileCheck %s
 // RUN: %clang_cc1 -fclang-abi-compat=latest -DSVE_OVERLOADED_FORMS -triple 
aarch64-none-linux-gnu -target-feature +sve2p1 -S -disable-O0-optnone -Werror 
-Wall -emit-llvm -o - -x c++ %s | opt -S -p mem2reg,instcombine,tailcallelim | 
FileCheck %s -check-prefix=CPP-CHECK
 // RUN: %clang_cc1 -fclang-abi-compat=latest -triple aarch64-none-linux-gnu 
-target-feature +sve2p1 -target-feature -S -disable-O0-optnone -Werror -Wall -o 
/dev/null %s
-// RUN: %clang_cc1 -fclang-abi-compat=latest -triple aarch64-none-linux-gnu 
-target-feature +sme2 -target-feature +sve -target-feature -S -DTEST_SME2 
-disable-O0-optnone -Werror -Wall -o /dev/null %s
+// RUN: %clang_cc1 -fclang-abi-compat=latest -triple aarch64-none-linux-gnu 
-target-feature +sme2 -target-feature -S -DTEST_SME2 -disable-O0-optnone 
-Werror -Wall -o /dev/null %s

sdesmalen-arm wrote:

`-target-feature -S` is not a target feature.

https://github.com/llvm/llvm-project/pull/75958
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][SME] Add IsStreamingOrSVE2p1 (PR #75958)

2023-12-20 Thread Sander de Smalen via cfe-commits


@@ -1,78 +0,0 @@
-// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py

sdesmalen-arm wrote:

Why is this file removed? (same question for `acle_sve2p1_sclamp.c`)

https://github.com/llvm/llvm-project/pull/75958
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Cygwin] Value.h consider Cygwin (PR #75395)

2023-12-20 Thread 徐持恒 Xu Chiheng via cfe-commits

https://github.com/xu-chiheng closed 
https://github.com/llvm/llvm-project/pull/75395
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][SME2] Enable multi-vector loads & stores for SME2 (PR #75821)

2023-12-20 Thread via cfe-commits


@@ -1990,79 +1990,61 @@ def SVWHILELO_COUNT  : SInst<"svwhilelo_{d}",  "}nni", 
"QcQsQiQl", MergeNone, "a
 def SVWHILELS_COUNT  : SInst<"svwhilels_{d}",  "}nni", "QcQsQiQl", MergeNone, 
"aarch64_sve_whilels_{d}", [IsOverloadNone], [ImmCheck<2, ImmCheck2_4_Mul2>]>;
 def SVWHILEHI_COUNT  : SInst<"svwhilehi_{d}",  "}nni", "QcQsQiQl", MergeNone, 
"aarch64_sve_whilehi_{d}", [IsOverloadNone], [ImmCheck<2, ImmCheck2_4_Mul2>]>;
 def SVWHILEHS_COUNT  : SInst<"svwhilehs_{d}",  "}nni", "QcQsQiQl", MergeNone, 
"aarch64_sve_whilehs_{d}", [IsOverloadNone], [ImmCheck<2, ImmCheck2_4_Mul2>]>;
+}
+
+multiclass MultiVecLoad {
+  // FIXME: Replace IsStreamingCompatible with IsStreamingOrHasSVE2p1 when 
available (SME2 requires __arm_streaming)

CarolineConcatto wrote:

I believe sme2 requires __arm_streaming_compatible instead of arm_streaming

https://github.com/llvm/llvm-project/pull/75821
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[llvm] [libc] [clang] [libcxx] [compiler-rt] [flang] [clang-tools-extra] [RISCV][MC] Add support for experimental Zimop extension (PR #75182)

2023-12-20 Thread via cfe-commits

https://github.com/ln8-8 updated https://github.com/llvm/llvm-project/pull/75182

>From e6bf0819c96fcfbd73d711acc951065e2ed22d8c Mon Sep 17 00:00:00 2001
From: ln8-8 
Date: Tue, 12 Dec 2023 12:47:32 +0400
Subject: [PATCH 1/3] [RISCV][MC] Add support for experimental Zimop extension

This implements experimental support for the Zimop extension as specified here: 
https://github.com/riscv/riscv-isa-manual/blob/main/src/zimop.adoc.

This change adds only assembly support.
---
 llvm/docs/RISCVUsage.rst|  3 ++
 llvm/include/llvm/IR/IntrinsicsRISCV.td | 23 +++
 llvm/lib/Support/RISCVISAInfo.cpp   |  2 +
 llvm/lib/Target/RISCV/RISCVFeatures.td  |  5 +++
 llvm/lib/Target/RISCV/RISCVInstrFormats.td  | 21 ++
 llvm/lib/Target/RISCV/RISCVInstrInfo.td | 45 +
 llvm/test/CodeGen/RISCV/attributes.ll   |  4 ++
 llvm/test/MC/RISCV/rv32zimop-invalid.s  |  6 +++
 llvm/test/MC/RISCV/rvzimop-valid.s  | 26 
 llvm/unittests/Support/RISCVISAInfoTest.cpp |  1 +
 10 files changed, 136 insertions(+)
 create mode 100644 llvm/test/MC/RISCV/rv32zimop-invalid.s
 create mode 100644 llvm/test/MC/RISCV/rvzimop-valid.s

diff --git a/llvm/docs/RISCVUsage.rst b/llvm/docs/RISCVUsage.rst
index 65dd0d83448ed1..bd2f81fba186df 100644
--- a/llvm/docs/RISCVUsage.rst
+++ b/llvm/docs/RISCVUsage.rst
@@ -208,6 +208,9 @@ The primary goal of experimental support is to assist in 
the process of ratifica
 ``experimental-zvbb``, ``experimental-zvbc``, ``experimental-zvkb``, 
``experimental-zvkg``, ``experimental-zvkn``, ``experimental-zvknc``, 
``experimental-zvkned``, ``experimental-zvkng``, ``experimental-zvknha``, 
``experimental-zvknhb``, ``experimental-zvks``, ``experimental-zvksc``, 
``experimental-zvksed``, ``experimental-zvksg``, ``experimental-zvksh``, 
``experimental-zvkt``
   LLVM implements the `1.0.0-rc2 specification 
`__.
 Note that current vector crypto extension version can be found in: 
.
 
+``experimental-zimop``
+  LLVM implements the `v0.1 proposed specification 
`__.
+
 To use an experimental extension from `clang`, you must add 
`-menable-experimental-extensions` to the command line, and specify the exact 
version of the experimental extension you are using.  To use an experimental 
extension with LLVM's internal developer tools (e.g. `llc`, `llvm-objdump`, 
`llvm-mc`), you must prefix the extension name with `experimental-`.  Note that 
you don't need to specify the version with internal tools, and shouldn't 
include the `experimental-` prefix with `clang`.
 
 Vendor Extensions
diff --git a/llvm/include/llvm/IR/IntrinsicsRISCV.td 
b/llvm/include/llvm/IR/IntrinsicsRISCV.td
index 20c6a525a86ba7..fcb11c8c51398d 100644
--- a/llvm/include/llvm/IR/IntrinsicsRISCV.td
+++ b/llvm/include/llvm/IR/IntrinsicsRISCV.td
@@ -108,6 +108,29 @@ let TargetPrefix = "riscv" in {
   def int_riscv_xperm8  : BitManipGPRGPRIntrinsics;
 } // TargetPrefix = "riscv"
 
+//===--===//
+// May-Be-Operations
+
+let TargetPrefix = "riscv" in {
+
+  class MOPGPRIntrinsics
+  : DefaultAttrsIntrinsic<[llvm_any_ty],
+  [LLVMMatchType<0>],
+  [IntrNoMem, IntrSpeculatable]>;
+  class MOPGPRGPRIntrinsics
+  : DefaultAttrsIntrinsic<[llvm_any_ty],
+  [LLVMMatchType<0>, LLVMMatchType<0>],
+  [IntrNoMem, IntrSpeculatable]>;
+
+  // Zimop
+   foreach i = 0...31 in {
+def int_riscv_mopr#i : MOPGPRIntrinsics;
+   }
+  foreach i = 0...7 in {
+def int_riscv_moprr#i : MOPGPRGPRIntrinsics;
+  }
+} // TargetPrefix = "riscv"
+
 
//===--===//
 // Vectors
 
diff --git a/llvm/lib/Support/RISCVISAInfo.cpp 
b/llvm/lib/Support/RISCVISAInfo.cpp
index 6322748430063c..1b303ba1e9431d 100644
--- a/llvm/lib/Support/RISCVISAInfo.cpp
+++ b/llvm/lib/Support/RISCVISAInfo.cpp
@@ -177,6 +177,8 @@ static const RISCVSupportedExtension 
SupportedExperimentalExtensions[] = {
 {"zicfilp", RISCVExtensionVersion{0, 2}},
 {"zicond", RISCVExtensionVersion{1, 0}},
 
+{"zimop", RISCVExtensionVersion{0, 1}},
+
 {"ztso", RISCVExtensionVersion{0, 1}},
 
 {"zvbb", RISCVExtensionVersion{1, 0}},
diff --git a/llvm/lib/Target/RISCV/RISCVFeatures.td 
b/llvm/lib/Target/RISCV/RISCVFeatures.td
index 294927aecb94b8..5b642090b7b9eb 100644
--- a/llvm/lib/Target/RISCV/RISCVFeatures.td
+++ b/llvm/lib/Target/RISCV/RISCVFeatures.td
@@ -687,6 +687,11 @@ def HasStdExtZicond : 
Predicate<"Subtarget->hasStdExtZicond()">,
 AssemblerPredicate<(all_of 
FeatureStdExtZicond),
 "'Zicond' (Integer Conditional Op

[llvm] [libc] [mlir] [lldb] [clang] [flang] Make 'UnrollMaxUpperBound' to be overridable by target. (PR #76029)

2023-12-20 Thread via cfe-commits

https://github.com/boxu-zhang updated 
https://github.com/llvm/llvm-project/pull/76029

>From 60030d96d27d23ef2049a3888d65721be51c4481 Mon Sep 17 00:00:00 2001
From: "boxu.zhang" 
Date: Wed, 20 Dec 2023 17:35:25 +0800
Subject: [PATCH] Make 'UnrollMaxUpperBound' to be overridable by target. The
 default value is still 8 and the command line argument
 '--unroll-max-upperbound' takes final effect if provided.

---
 llvm/include/llvm/Analysis/TargetTransformInfo.h | 4 
 llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp| 9 ++---
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/llvm/include/llvm/Analysis/TargetTransformInfo.h 
b/llvm/include/llvm/Analysis/TargetTransformInfo.h
index f5114fa40c70ad..6fc697c37c3c33 100644
--- a/llvm/include/llvm/Analysis/TargetTransformInfo.h
+++ b/llvm/include/llvm/Analysis/TargetTransformInfo.h
@@ -560,6 +560,10 @@ class TargetTransformInfo {
 // (set to UINT_MAX to disable). This does not apply in cases where the
 // loop is being fully unrolled.
 unsigned MaxCount;
+/// Set the maximum upper bound of trip count. Allowing the MaxUpperBound
+/// to be overrided by a target gives more flexiblity on certain cases. 
+/// By default, MaxUpperBound uses UnrollMaxUpperBound which value is 8.
+unsigned MaxUpperBound;
 /// Set the maximum unrolling factor for full unrolling. Like MaxCount, but
 /// applies even if full unrolling is selected. This allows a target to 
fall
 /// back to Partial unrolling if full unrolling is above 
FullUnrollMaxCount.
diff --git a/llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp 
b/llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp
index f14541a1a037e6..ddc532ea24e275 100644
--- a/llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp
+++ b/llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp
@@ -200,6 +200,7 @@ TargetTransformInfo::UnrollingPreferences 
llvm::gatherUnrollingPreferences(
   UP.Count = 0;
   UP.DefaultUnrollRuntimeCount = 8;
   UP.MaxCount = std::numeric_limits::max();
+  UP.MaxUpperBound = UnrollMaxUpperBound; 
   UP.FullUnrollMaxCount = std::numeric_limits::max();
   UP.BEInsns = 2;
   UP.Partial = false;
@@ -237,6 +238,8 @@ TargetTransformInfo::UnrollingPreferences 
llvm::gatherUnrollingPreferences(
 UP.MaxPercentThresholdBoost = UnrollMaxPercentThresholdBoost;
   if (UnrollMaxCount.getNumOccurrences() > 0)
 UP.MaxCount = UnrollMaxCount;
+  if (UnrollMaxUpperBound.getNumOccurrences() > 0)
+UP.MaxUpperBound = UnrollMaxUpperBound;
   if (UnrollFullMaxCount.getNumOccurrences() > 0)
 UP.FullUnrollMaxCount = UnrollFullMaxCount;
   if (UnrollAllowPartial.getNumOccurrences() > 0)
@@ -777,7 +780,7 @@ shouldPragmaUnroll(Loop *L, const PragmaInfo &PInfo,
 return TripCount;
 
   if (PInfo.PragmaEnableUnroll && !TripCount && MaxTripCount &&
-  MaxTripCount <= UnrollMaxUpperBound)
+  MaxTripCount <= UP.MaxUpperBound)
 return MaxTripCount;
 
   // if didn't return until here, should continue to other priorties
@@ -952,7 +955,7 @@ bool llvm::computeUnrollCount(
   // cost of exact full unrolling.  As such, if we have an exact count and
   // found it unprofitable, we'll never chose to bounded unroll.
   if (!TripCount && MaxTripCount && (UP.UpperBound || MaxOrZero) &&
-  MaxTripCount <= UnrollMaxUpperBound) {
+  MaxTripCount <= UP.MaxUpperBound) {
 UP.Count = MaxTripCount;
 if (auto UnrollFactor = shouldFullUnroll(L, TTI, DT, SE, EphValues,
  MaxTripCount, UCE, UP)) {
@@ -1026,7 +1029,7 @@ bool llvm::computeUnrollCount(
   }
 
   // Don't unroll a small upper bound loop unless user or TTI asked to do so.
-  if (MaxTripCount && !UP.Force && MaxTripCount < UnrollMaxUpperBound) {
+  if (MaxTripCount && !UP.Force && MaxTripCount < UP.MaxUpperBound) {
 UP.Count = 0;
 return false;
   }

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


[clang] Avoid printing overly large integer. (PR #75902)

2023-12-20 Thread via cfe-commits

cor3ntin wrote:

I agree with @tbaederr, fixing the underlying issue - either by optimizing 
divide (good luck!) or printing in hexadecimal, seems like a better solution. 
At the minimum, we should have a fixme comment to explain the restriction

@tbaederr @erichkeane @shafik opinion?


https://github.com/llvm/llvm-project/pull/75902
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][ASTImporter] Support Importer of BuiltinBitCastExpr (PR #74813)

2023-12-20 Thread Qizhi Hu via cfe-commits

https://github.com/jcsxky updated 
https://github.com/llvm/llvm-project/pull/74813

>From d1f48502c1ec7a58ca18a19dc3631265e5c1b137 Mon Sep 17 00:00:00 2001
From: huqizhi 
Date: Fri, 8 Dec 2023 15:26:01 +0800
Subject: [PATCH] [clang][ASTImporter] Support Importer of BuiltinBitCastExpr

---
 clang/lib/AST/ASTImporter.cpp   | 12 
 clang/unittests/AST/ASTImporterTest.cpp | 12 
 2 files changed, 24 insertions(+)

diff --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp
index f1f335118f37a4..0edb6930ed0a00 100644
--- a/clang/lib/AST/ASTImporter.cpp
+++ b/clang/lib/AST/ASTImporter.cpp
@@ -7820,6 +7820,18 @@ ExpectedStmt 
ASTNodeImporter::VisitExplicitCastExpr(ExplicitCastExpr *E) {
 *ToLParenLocOrErr, OCE->getBridgeKind(), E->getCastKind(),
 *ToBridgeKeywordLocOrErr, ToTypeInfoAsWritten, ToSubExpr);
   }
+  case Stmt::BuiltinBitCastExprClass: {
+auto *BBC = cast(E);
+ExpectedSLoc ToKWLocOrErr = import(BBC->getBeginLoc());
+if (!ToKWLocOrErr)
+  return ToKWLocOrErr.takeError();
+ExpectedSLoc ToRParenLocOrErr = import(BBC->getEndLoc());
+if (!ToRParenLocOrErr)
+  return ToRParenLocOrErr.takeError();
+return new (Importer.getToContext()) BuiltinBitCastExpr(
+ToType, E->getValueKind(), E->getCastKind(), ToSubExpr,
+ToTypeInfoAsWritten, *ToKWLocOrErr, *ToRParenLocOrErr);
+  }
   default:
 llvm_unreachable("Cast expression of unsupported type!");
 return make_error(ASTImportError::UnsupportedConstruct);
diff --git a/clang/unittests/AST/ASTImporterTest.cpp 
b/clang/unittests/AST/ASTImporterTest.cpp
index 4dd7510bf8ddf8..0941417bd3cfb4 100644
--- a/clang/unittests/AST/ASTImporterTest.cpp
+++ b/clang/unittests/AST/ASTImporterTest.cpp
@@ -561,6 +561,18 @@ TEST_P(ImportExpr, ImportVAArgExpr) {
  cStyleCastExpr(hasSourceExpression(vaArgExpr());
 }
 
+const internal::VariadicDynCastAllOfMatcher
+builtinBitCastExpr;
+
+TEST_P(ImportExpr, ImportBuiltinBitCastExpr) {
+  MatchVerifier Verifier;
+  testImport("void declToImport(int X) {"
+ "  (void)__builtin_bit_cast(float, X); }",
+ Lang_CXX20, "", Lang_CXX20, Verifier,
+ functionDecl(hasDescendant(
+ cStyleCastExpr(hasSourceExpression(builtinBitCastExpr());
+}
+
 TEST_P(ImportExpr, CXXTemporaryObjectExpr) {
   MatchVerifier Verifier;
   testImport(

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


[clang] [clang][ASTImporter] Support Importer of BuiltinBitCastExpr (PR #74813)

2023-12-20 Thread Qizhi Hu via cfe-commits


@@ -3220,6 +3220,12 @@ TEST_P(ImportExpr, UnresolvedMemberExpr) {
  compoundStmt(has(callExpr(has(unresolvedMemberExpr());
 }
 
+TEST_P(ImportExpr, BuiltinBitCastExpr) {
+  MatchVerifier Verifier;
+  testImport("void declToImport(int T) { (void)__builtin_bit_cast(float, T); 
}",
+ Lang_CXX20, "", Lang_CXX20, Verifier, functionDecl());
+}
+

jcsxky wrote:

Oh, I see. The code has been fixed.

https://github.com/llvm/llvm-project/pull/74813
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clangd] Perform self-containedness check at EOF (PR #75965)

2023-12-20 Thread Ilya Biryukov via cfe-commits

ilya-biryukov wrote:

Thanks a lot! This fixes the problem we encountered with ranking includes.

https://github.com/llvm/llvm-project/pull/75965
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clangd] Perform self-containedness check at EOF (PR #75965)

2023-12-20 Thread Ilya Biryukov via cfe-commits

https://github.com/ilya-biryukov approved this pull request.


https://github.com/llvm/llvm-project/pull/75965
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] cf048e1 - [clangd] Perform self-containedness check at EOF (#75965)

2023-12-20 Thread via cfe-commits

Author: kadir çetinkaya
Date: 2023-12-20T10:48:18+01:00
New Revision: cf048e16a7c682a3ed5abb32702c3048fcad7638

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

LOG: [clangd] Perform self-containedness check at EOF (#75965)

Header gurads are not detected until we hit EOF. Make sure we postpone
any such detection until then.

Added: 


Modified: 
clang-tools-extra/clangd/index/SymbolCollector.cpp
clang-tools-extra/clangd/index/SymbolCollector.h
clang-tools-extra/clangd/unittests/IndexActionTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/index/SymbolCollector.cpp 
b/clang-tools-extra/clangd/index/SymbolCollector.cpp
index cf6102db8dd317..7ef4b15febad22 100644
--- a/clang-tools-extra/clangd/index/SymbolCollector.cpp
+++ b/clang-tools-extra/clangd/index/SymbolCollector.cpp
@@ -826,22 +826,8 @@ void SymbolCollector::setIncludeLocation(const Symbol &S, 
SourceLocation DefLoc,
   // We update providers for a symbol with each occurence, as SymbolCollector
   // might run while parsing, rather than at the end of a translation unit.
   // Hence we see more and more redecls over time.
-  auto [It, Inserted] = SymbolProviders.try_emplace(S.ID);
-  auto Headers =
+  SymbolProviders[S.ID] =
   include_cleaner::headersForSymbol(Sym, SM, Opts.PragmaIncludes);
-  if (Headers.empty())
-return;
-
-  auto *HeadersIter = Headers.begin();
-  include_cleaner::Header H = *HeadersIter;
-  while (HeadersIter != Headers.end() &&
- H.kind() == include_cleaner::Header::Physical &&
- !tooling::isSelfContainedHeader(H.physical(), SM,
- PP->getHeaderSearchInfo())) {
-H = *HeadersIter;
-HeadersIter++;
-  }
-  It->second = H;
 }
 
 llvm::StringRef getStdHeader(const Symbol *S, const LangOptions &LangOpts) {
@@ -889,7 +875,7 @@ void SymbolCollector::finish() {
   llvm::DenseMap HeaderSpelling;
   // Fill in IncludeHeaders.
   // We delay this until end of TU so header guards are all resolved.
-  for (const auto &[SID, OptionalProvider] : SymbolProviders) {
+  for (const auto &[SID, Providers] : SymbolProviders) {
 const Symbol *S = Symbols.find(SID);
 if (!S)
   continue;
@@ -931,9 +917,27 @@ void SymbolCollector::finish() {
   continue;
 }
 
-assert(Directives == Symbol::Include);
 // For #include's, use the providers computed by the include-cleaner
 // library.
+assert(Directives == Symbol::Include);
+// Ignore providers that are not self-contained, this is especially
+// important for symbols defined in the main-file. We want to prefer the
+// header, if possible.
+// TODO: Limit this to specifically ignore main file, when we're indexing a
+// non-header file?
+auto SelfContainedProvider =
+[this](llvm::ArrayRef Providers)
+-> std::optional {
+  for (const auto &H : Providers) {
+if (H.kind() != include_cleaner::Header::Physical)
+  return H;
+if (tooling::isSelfContainedHeader(H.physical(), 
PP->getSourceManager(),
+   PP->getHeaderSearchInfo()))
+  return H;
+  }
+  return std::nullopt;
+};
+const auto OptionalProvider = SelfContainedProvider(Providers);
 if (!OptionalProvider)
   continue;
 const auto &H = *OptionalProvider;

diff  --git a/clang-tools-extra/clangd/index/SymbolCollector.h 
b/clang-tools-extra/clangd/index/SymbolCollector.h
index 10765020de518b..20116fca7c51e3 100644
--- a/clang-tools-extra/clangd/index/SymbolCollector.h
+++ b/clang-tools-extra/clangd/index/SymbolCollector.h
@@ -15,18 +15,25 @@
 #include "index/Relation.h"
 #include "index/Symbol.h"
 #include "index/SymbolID.h"
+#include "index/SymbolLocation.h"
 #include "index/SymbolOrigin.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/Decl.h"
+#include "clang/Basic/LLVM.h"
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/Index/IndexDataConsumer.h"
 #include "clang/Index/IndexSymbol.h"
 #include "clang/Sema/CodeCompleteConsumer.h"
 #include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/DenseSet.h"
+#include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/StringRef.h"
 #include 
 #include 
 #include 
+#include 
+#include 
 
 namespace clang {
 namespace clangd {
@@ -177,7 +184,7 @@ class SymbolCollector : public index::IndexDataConsumer {
 
   // Providers for Symbol.IncludeHeaders.
   // The final spelling is calculated in finish().
-  llvm::DenseMap>
+  llvm::DenseMap>
   SymbolProviders;
   // Files which contain ObjC symbols.
   // This is finalized and used in finish().

diff  --git a/clang-tools-extra/clangd/unittests/IndexActionTests.cpp 
b/clang-tools-extra/clangd/unittests/IndexActionTests.cpp
index fa3

[clang-tools-extra] [clangd] Perform self-containedness check at EOF (PR #75965)

2023-12-20 Thread Ilya Biryukov via cfe-commits

https://github.com/ilya-biryukov closed 
https://github.com/llvm/llvm-project/pull/75965
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [AArch64][SME2] Add SME2 MLA/MLS builtins. (PR #75584)

2023-12-20 Thread Sander de Smalen via cfe-commits

https://github.com/sdesmalen-arm approved this pull request.


https://github.com/llvm/llvm-project/pull/75584
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [AST] Add dump() method to TypeLoc (PR #65484)

2023-12-20 Thread via cfe-commits

cor3ntin wrote:

@sam-mccall are you still working on this?

https://github.com/llvm/llvm-project/pull/65484
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][dataflow] Add `Environment::get<>()`. (PR #76027)

2023-12-20 Thread via cfe-commits

https://github.com/martinboehme updated 
https://github.com/llvm/llvm-project/pull/76027

>From 9fd1ed96c1b7934754b6fefd7b01a62d4a391d73 Mon Sep 17 00:00:00 2001
From: Martin Braenne 
Date: Wed, 20 Dec 2023 10:01:10 +
Subject: [PATCH] [clang][dataflow] Add `Environment::get<>()`.

This template function casts the result of `getValue()` or
`getStorageLocation()` to a given subclass of `Value` or `StorageLocation`
(using `cast_or_null`).

It's a common pattern to do something like this:

```cxx
auto *Val = cast_or_null(Env.getValue(E));
```

This can now be expressed more concisely like this:

```cxx
auto *Val = Env.get(E);
```

Instead of adding a new method `get()`, I had originally considered simply
adding a template parameter to `getValue()` and `getStorageLocation()` (with a
default argument of `Value` or `StorageLocation`), but this results in an
undesirable repetition at the callsite, e.g.
`getStorageLocation(...)`. The `Value` and
`StorageLocation` in the method name adds nothing of value when the template
argument already contains this information, so it seemed best to shorten the
method name to simply `get()`.
---
 .../FlowSensitive/DataflowEnvironment.h   | 36 +++
 .../FlowSensitive/DataflowEnvironment.cpp | 14 
 .../Models/UncheckedOptionalAccessModel.cpp   | 31 +++-
 .../lib/Analysis/FlowSensitive/RecordOps.cpp  |  8 ++---
 clang/lib/Analysis/FlowSensitive/Transfer.cpp | 16 -
 .../TypeErasedDataflowAnalysis.cpp|  2 +-
 .../FlowSensitive/SignAnalysisTest.cpp|  2 +-
 7 files changed, 66 insertions(+), 43 deletions(-)

diff --git a/clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h 
b/clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
index 5943af50b6ad8f..2a9f8dce74c0a1 100644
--- a/clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
+++ b/clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
@@ -289,6 +289,22 @@ class Environment {
   ///  `E` must be a glvalue or a `BuiltinType::BuiltinFn`
   StorageLocation *getStorageLocation(const Expr &E) const;
 
+  /// Returns the result of casting `getStorageLocation(...)` to a subclass of
+  /// `StorageLocation` (using `cast_or_null`).
+  /// This assert-fails if the result of `getStorageLocation(...)` is not of
+  /// type `T *`; if the storage location is not guaranteed to have type `T *`,
+  /// consider using `dyn_cast_or_null(getStorageLocation(...))` instead.
+  template 
+  std::enable_if_t, T *>
+  get(const ValueDecl &D) const {
+return cast_or_null(getStorageLocation(D));
+  }
+  template 
+  std::enable_if_t, T *>
+  get(const Expr &E) const {
+return cast_or_null(getStorageLocation(E));
+  }
+
   /// Returns the storage location assigned to the `this` pointee in the
   /// environment or null if the `this` pointee has no assigned storage 
location
   /// in the environment.
@@ -457,6 +473,26 @@ class Environment {
   /// storage location in the environment, otherwise returns null.
   Value *getValue(const Expr &E) const;
 
+  /// Returns the result of casting `getValue(...)` to a subclass of `Value`
+  /// (using `cast_or_null`).
+  /// This assert-fails if the result of `getValue(...)` is not of type `T *`;
+  /// if the value is not guaranteed to have type `T *`, consider using
+  /// `dyn_cast_or_null(getValue(...))` instead.
+  template 
+  std::enable_if_t, T *>
+  get(const StorageLocation &Loc) const {
+return cast_or_null(getValue(Loc));
+  }
+  template 
+  std::enable_if_t, T *>
+  get(const ValueDecl &D) const {
+return cast_or_null(getValue(D));
+  }
+  template 
+  std::enable_if_t, T *> get(const Expr &E) const {
+return cast_or_null(getValue(E));
+  }
+
   // FIXME: should we deprecate the following & call arena().create() directly?
 
   /// Creates a `T` (some subclass of `Value`), forwarding `args` to the
diff --git a/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp 
b/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
index 93919cd0243d0c..46841bac35ccb3 100644
--- a/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
+++ b/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
@@ -489,8 +489,7 @@ Environment Environment::pushCall(const CallExpr *Call) 
const {
   if (const auto *MethodCall = dyn_cast(Call)) {
 if (const Expr *Arg = MethodCall->getImplicitObjectArgument()) {
   if (!isa(Arg))
-  Env.ThisPointeeLoc =
-  cast(getStorageLocation(*Arg));
+Env.ThisPointeeLoc = get(*Arg);
   // Otherwise (when the argument is `this`), retain the current
   // environment's `ThisPointeeLoc`.
 }
@@ -1034,7 +1033,7 @@ RecordStorageLocation *getImplicitObjectLocation(const 
CXXMemberCallExpr &MCE,
   if (ImplicitObject == nullptr)
 return nullptr;
   if (ImplicitObject->getType()->isPointerType()) {
-if (auto *Val = cast_or_null(Env.getValue(*ImplicitObject)))
+if (auto *Val = Env.get(*ImplicitObject))
 

[lld] [llvm] [libc] [clang] [clang-tools-extra] [lldb] [compiler-rt] [libcxx] [mlir] [flang] Don't emit relax relocs like R_X86_64_REX_GOTPCRELX on X86 target for OPENMP internal vars. (PR #75564)

2023-12-20 Thread via cfe-commits

https://github.com/UmeshKalappa0 updated 
https://github.com/llvm/llvm-project/pull/75564

>From 4125e4a709c594562fa6c52f045ba7442e3cb523 Mon Sep 17 00:00:00 2001
From: Umesh Kalappa 
Date: Fri, 15 Dec 2023 11:52:52 +0530
Subject: [PATCH 1/4] Problem :For Kernel Modules ,emitting the relocs like
 R_X86_64_REX_GOTPCRELX  for the OPENMP internal vars like
 https://godbolt.org/z/hhh7ozojz.

Solution : Mark the OpenMP internal variables with dso_local
conditionally for no-pic and no-pie ,then
a)reset the dso_local for thread_local and weak linkage vars.
---
 .../test/OpenMP/gomp_critical_dso_local_var.c | 23 +++
 1 file changed, 23 insertions(+)
 create mode 100644 clang/test/OpenMP/gomp_critical_dso_local_var.c

diff --git a/clang/test/OpenMP/gomp_critical_dso_local_var.c 
b/clang/test/OpenMP/gomp_critical_dso_local_var.c
new file mode 100644
index 00..915f6773bf67bf
--- /dev/null
+++ b/clang/test/OpenMP/gomp_critical_dso_local_var.c
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -fopenmp -x c -emit-llvm %s -o - | FileCheck %s 
--check-prefix=DSO_LOCAL
+
+// DSO_LOCAL-DAG: @.gomp_critical_user_.var = common dso_local global [8 x 
i32] zeroinitializer, align 8
+int omp_critical_test()
+{
+  int sum;
+  int known_sum;
+
+  sum=0;
+#pragma omp parallel
+  {
+int mysum=0;
+int i;
+#pragma omp for
+for (i = 0; i < 1000; i++)
+  mysum = mysum + i;
+#pragma omp critical
+sum = mysum +sum;
+  }
+  known_sum = 999 * 1000 / 2;
+  return (known_sum == sum);
+}
+

>From 842245de490ab15f8a901b94576ae4539c760e1e Mon Sep 17 00:00:00 2001
From: Umesh Kalappa 
Date: Fri, 15 Dec 2023 12:49:48 +0530
Subject: [PATCH 2/4] testcases are changed accordignly.

---
 clang/lib/CodeGen/CGOpenMPRuntime.cpp   | 2 ++
 clang/test/OpenMP/critical_codegen.cpp  | 6 +++---
 clang/test/OpenMP/critical_codegen_attr.cpp | 6 +++---
 clang/test/OpenMP/for_reduction_codegen.cpp | 8 
 clang/test/OpenMP/gomp_critical_dso_local_var.c | 1 -
 clang/test/OpenMP/simd_codegen.cpp  | 4 ++--
 llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp   | 8 
 7 files changed, 22 insertions(+), 13 deletions(-)

diff --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp 
b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
index 7f7e6f53066644..183c757d72b8a7 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -1793,6 +1793,8 @@ Address 
CGOpenMPRuntime::getAddrOfArtificialThreadPrivate(CodeGenFunction &CGF,
   if (CGM.getLangOpts().OpenMP && CGM.getLangOpts().OpenMPUseTLS &&
   CGM.getTarget().isTLSSupported()) {
 GAddr->setThreadLocal(/*Val=*/true);
+/// reset the dso_local for thread_local.
+GAddr->setDSOLocal(/*Val=*/false);
 return Address(GAddr, GAddr->getValueType(),
CGM.getContext().getTypeAlignInChars(VarType));
   }
diff --git a/clang/test/OpenMP/critical_codegen.cpp 
b/clang/test/OpenMP/critical_codegen.cpp
index 24145d44d962e5..9a613161ac294a 100644
--- a/clang/test/OpenMP/critical_codegen.cpp
+++ b/clang/test/OpenMP/critical_codegen.cpp
@@ -16,9 +16,9 @@
 #define HEADER
 
 // ALL:   [[IDENT_T_TY:%.+]] = type { i32, i32, i32, i32, ptr }
-// ALL:   [[UNNAMED_LOCK:@.+]] = common global [8 x i32] zeroinitializer
-// ALL:   [[THE_NAME_LOCK:@.+]] = common global [8 x i32] zeroinitializer
-// ALL:   [[THE_NAME_LOCK1:@.+]] = common global [8 x i32] zeroinitializer
+// ALL:   [[UNNAMED_LOCK:@.+]] = common dso_local global [8 x i32] 
zeroinitializer
+// ALL:   [[THE_NAME_LOCK:@.+]] = common dso_local global [8 x i32] 
zeroinitializer
+// ALL:   [[THE_NAME_LOCK1:@.+]] = common dso_local global [8 x i32] 
zeroinitializer
 
 // ALL:   define {{.*}}void [[FOO:@.+]]()
 
diff --git a/clang/test/OpenMP/critical_codegen_attr.cpp 
b/clang/test/OpenMP/critical_codegen_attr.cpp
index 34d90a9e3a6e48..5f1a76e2ad0f1f 100644
--- a/clang/test/OpenMP/critical_codegen_attr.cpp
+++ b/clang/test/OpenMP/critical_codegen_attr.cpp
@@ -16,9 +16,9 @@
 #define HEADER
 
 // ALL:   [[IDENT_T_TY:%.+]] = type { i32, i32, i32, i32, ptr }
-// ALL:   [[UNNAMED_LOCK:@.+]] = common global [8 x i32] zeroinitializer
-// ALL:   [[THE_NAME_LOCK:@.+]] = common global [8 x i32] zeroinitializer
-// ALL:   [[THE_NAME_LOCK1:@.+]] = common global [8 x i32] zeroinitializer
+// ALL:   [[UNNAMED_LOCK:@.+]] = common dso_local global [8 x i32] 
zeroinitializer
+// ALL:   [[THE_NAME_LOCK:@.+]] = common dso_local global [8 x i32] 
zeroinitializer
+// ALL:   [[THE_NAME_LOCK1:@.+]] = common dso_local global [8 x i32] 
zeroinitializer
 
 // ALL:   define {{.*}}void [[FOO:@.+]]()
 
diff --git a/clang/test/OpenMP/for_reduction_codegen.cpp 
b/clang/test/OpenMP/for_reduction_codegen.cpp
index 893c606f8d7b9f..b128bd5d79c251 100644
--- a/clang/test/OpenMP/for_reduction_codegen.cpp
+++ b/clang/test/OpenMP/for_reduction_codegen.cpp
@@ -528,12 +528,12 @@ int main() {
 
 #endif
 //.
-// CHECK1: @.gomp_critical_user_.red

[llvm] [libc] [clang] [clang-tools-extra] [libcxx] [compiler-rt] [mlir] [flang] [AsmWriter] Ensure getMnemonic doesn't return invalid pointers (PR #75783)

2023-12-20 Thread Lucas Duarte Prates via cfe-commits

https://github.com/pratlucas closed 
https://github.com/llvm/llvm-project/pull/75783
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][SME] Add IsStreamingOrSVE2p1 (PR #75958)

2023-12-20 Thread via cfe-commits


@@ -227,6 +227,7 @@ def IsPreservesZA : FlagType<0x100>;
 def IsReadZA  : FlagType<0x200>;
 def IsWriteZA : FlagType<0x400>;
 def IsReductionQV : FlagType<0x800>;
+def IsStreamingOrSVE2p1   : FlagType<0x800>; // Use for intrinsics 
that are common between sme/sme2 and sve2p1.

CarolineConcatto wrote:

Hey Sam, 
Just in case, this is just a nit.
But maybe  we should have IsStreamingOrSVE instead of IsStreamingOrSVE2p1.
Because we can use the same flag if we have more instructions under a different 
version of  sve.

https://github.com/llvm/llvm-project/pull/75958
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [AArch64] Update target feature requirements of SVE bfloat instructions (PR #75596)

2023-12-20 Thread Momchil Velikov via cfe-commits

https://github.com/momchil-velikov closed 
https://github.com/llvm/llvm-project/pull/75596
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [AArch64][SME2] Add builtins for FDOT, BFDOT, SUDOT, USDOT, SDOT, UDOT. (PR #75737)

2023-12-20 Thread Sander de Smalen via cfe-commits

https://github.com/sdesmalen-arm approved this pull request.


https://github.com/llvm/llvm-project/pull/75737
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Separate Intel ADC instrinsics from ADX intrinsics (PR #75992)

2023-12-20 Thread Simon Pilgrim via cfe-commits


@@ -14,9 +14,6 @@
 #ifndef __ADXINTRIN_H
 #define __ADXINTRIN_H
 
-/* Define the default attributes for the functions in this file. */
-#define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__))

RKSimon wrote:

(minor) You could put this back with `__attribute__((__always_inline__, 
__nodebug__, __target__("adx")))` and now use it for the ADX intrinsics.

https://github.com/llvm/llvm-project/pull/75992
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[llvm] [clang] [clang-tools-extra] [ISel] Add pattern matching for depositing subreg value (PR #75978)

2023-12-20 Thread Simon Pilgrim via cfe-commits


@@ -0,0 +1,93 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py 
UTC_ARGS: --version 4
+; RUN: llc < %s -mtriple=i386-unknown-unknown | FileCheck %s 
--check-prefixes=I386
+; RUN: llc < %s -mtriple=x86_64-unknown-unknown | FileCheck %s 
--check-prefixes=X86_64

RKSimon wrote:

(style) We try to use 'X86' for 32-bit triple checks and 'X64' for 64-bit 
triple checks.

https://github.com/llvm/llvm-project/pull/75978
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [flang] [Flang] remove whole-archive option for AIX linker (PR #76039)

2023-12-20 Thread via cfe-commits

https://github.com/madanial0 created 
https://github.com/llvm/llvm-project/pull/76039

The AIX linker does not support the `--whole-archive` option, removing the 
option if the OS is AIX.

>From 30f511b804d7a1a5a5f80daf0bef928ff7643971 Mon Sep 17 00:00:00 2001
From: Mark Danial 
Date: Wed, 20 Dec 2023 05:38:28 -0500
Subject: [PATCH] [Flang] remove whole-archive option for AIX linker

---
 clang/lib/Driver/ToolChains/CommonArgs.cpp | 3 ++-
 flang/test/Driver/no-duplicate-main.f90| 2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp 
b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index 4f4bdac793bea7..e9bd8f2b2aff48 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -1175,7 +1175,8 @@ static void addFortranMain(const ToolChain &TC, const 
ArgList &Args,
   // sure that the main() function from Fortran_main.a is pulled in by the
   // linker. However, it shouldn't be used if it's already active.
   // TODO: Find an equivalent of `--whole-archive` for Darwin.
-  if (!isWholeArchivePresent(Args) && !TC.getTriple().isMacOSX()) {
+  if (!isWholeArchivePresent(Args) && !TC.getTriple().isMacOSX() &&
+  !TC.getTriple().isOSAIX()) {
 CmdArgs.push_back("--whole-archive");
 CmdArgs.push_back("-lFortran_main");
 CmdArgs.push_back("--no-whole-archive");
diff --git a/flang/test/Driver/no-duplicate-main.f90 
b/flang/test/Driver/no-duplicate-main.f90
index b884e7ecd7f12a..88f4430828e090 100644
--- a/flang/test/Driver/no-duplicate-main.f90
+++ b/flang/test/Driver/no-duplicate-main.f90
@@ -1,4 +1,4 @@
-! UNSUPPORTED: system-windows, system-darwin
+! UNSUPPORTED: system-windows, system-darwin, system-aix
 
 ! RUN: %flang -x ir -o %t.c-object -c %S/Inputs/no_duplicate_main.ll
 ! RUN: %flang -o %t -c %s

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


[clang] [flang] [Flang] remove whole-archive option for AIX linker (PR #76039)

2023-12-20 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-flang-driver

Author: None (madanial0)


Changes

The AIX linker does not support the `--whole-archive` option, removing the 
option if the OS is AIX.

---
Full diff: https://github.com/llvm/llvm-project/pull/76039.diff


2 Files Affected:

- (modified) clang/lib/Driver/ToolChains/CommonArgs.cpp (+2-1) 
- (modified) flang/test/Driver/no-duplicate-main.f90 (+1-1) 


``diff
diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp 
b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index 4f4bdac793bea7..e9bd8f2b2aff48 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -1175,7 +1175,8 @@ static void addFortranMain(const ToolChain &TC, const 
ArgList &Args,
   // sure that the main() function from Fortran_main.a is pulled in by the
   // linker. However, it shouldn't be used if it's already active.
   // TODO: Find an equivalent of `--whole-archive` for Darwin.
-  if (!isWholeArchivePresent(Args) && !TC.getTriple().isMacOSX()) {
+  if (!isWholeArchivePresent(Args) && !TC.getTriple().isMacOSX() &&
+  !TC.getTriple().isOSAIX()) {
 CmdArgs.push_back("--whole-archive");
 CmdArgs.push_back("-lFortran_main");
 CmdArgs.push_back("--no-whole-archive");
diff --git a/flang/test/Driver/no-duplicate-main.f90 
b/flang/test/Driver/no-duplicate-main.f90
index b884e7ecd7f12a..88f4430828e090 100644
--- a/flang/test/Driver/no-duplicate-main.f90
+++ b/flang/test/Driver/no-duplicate-main.f90
@@ -1,4 +1,4 @@
-! UNSUPPORTED: system-windows, system-darwin
+! UNSUPPORTED: system-windows, system-darwin, system-aix
 
 ! RUN: %flang -x ir -o %t.c-object -c %S/Inputs/no_duplicate_main.ll
 ! RUN: %flang -o %t -c %s

``




https://github.com/llvm/llvm-project/pull/76039
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[flang] [clang] [Flang] remove whole-archive option for AIX linker (PR #76039)

2023-12-20 Thread via cfe-commits

llvmbot wrote:



@llvm/pr-subscribers-clang-driver

@llvm/pr-subscribers-clang

Author: None (madanial0)


Changes

The AIX linker does not support the `--whole-archive` option, removing the 
option if the OS is AIX.

---
Full diff: https://github.com/llvm/llvm-project/pull/76039.diff


2 Files Affected:

- (modified) clang/lib/Driver/ToolChains/CommonArgs.cpp (+2-1) 
- (modified) flang/test/Driver/no-duplicate-main.f90 (+1-1) 


``diff
diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp 
b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index 4f4bdac793bea7..e9bd8f2b2aff48 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -1175,7 +1175,8 @@ static void addFortranMain(const ToolChain &TC, const 
ArgList &Args,
   // sure that the main() function from Fortran_main.a is pulled in by the
   // linker. However, it shouldn't be used if it's already active.
   // TODO: Find an equivalent of `--whole-archive` for Darwin.
-  if (!isWholeArchivePresent(Args) && !TC.getTriple().isMacOSX()) {
+  if (!isWholeArchivePresent(Args) && !TC.getTriple().isMacOSX() &&
+  !TC.getTriple().isOSAIX()) {
 CmdArgs.push_back("--whole-archive");
 CmdArgs.push_back("-lFortran_main");
 CmdArgs.push_back("--no-whole-archive");
diff --git a/flang/test/Driver/no-duplicate-main.f90 
b/flang/test/Driver/no-duplicate-main.f90
index b884e7ecd7f12a..88f4430828e090 100644
--- a/flang/test/Driver/no-duplicate-main.f90
+++ b/flang/test/Driver/no-duplicate-main.f90
@@ -1,4 +1,4 @@
-! UNSUPPORTED: system-windows, system-darwin
+! UNSUPPORTED: system-windows, system-darwin, system-aix
 
 ! RUN: %flang -x ir -o %t.c-object -c %S/Inputs/no_duplicate_main.ll
 ! RUN: %flang -o %t -c %s

``




https://github.com/llvm/llvm-project/pull/76039
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [Clang][IR] add TBAA metadata on pointer, union and array types. (PR #75177)

2023-12-20 Thread Bushev Dmitry via cfe-commits


@@ -1,7 +1,7 @@
-// RUN: %clang_cc1 -triple x86_64-linux -std=c++98 %s -O3 -disable-llvm-passes 
-pedantic-errors -emit-llvm -o - | FileCheck %s

dybv-sc wrote:

I am sure that level 3 optimization should cut out all stack manipulation here 
leaving only one necessary load(const int *x = *p) and one necessary store(*q = 
0). This test checks only presence of that load/store and metadata information, 
so I don't think it could be disrupted by unrelated patches.

https://github.com/llvm/llvm-project/pull/75177
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][SME] Add IsStreamingOrSVE2p1 (PR #75958)

2023-12-20 Thread Sander de Smalen via cfe-commits


@@ -227,6 +227,7 @@ def IsPreservesZA : FlagType<0x100>;
 def IsReadZA  : FlagType<0x200>;
 def IsWriteZA : FlagType<0x400>;
 def IsReductionQV : FlagType<0x800>;
+def IsStreamingOrSVE2p1   : FlagType<0x800>; // Use for intrinsics 
that are common between sme/sme2 and sve2p1.

sdesmalen-arm wrote:

I don't think that will work. For a bulitin defined under `let TargetGuard = 
"sve2p1|sme2"`; if this builtin is used in conjunction with 
`-mattr=+sve2,+sme2` then it should not assume that the builtin is available 
outside of Streaming-SVE mode because that would have required `sve2p1`.

https://github.com/llvm/llvm-project/pull/75958
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [InstCombine] Canonicalize constant GEPs to i8 source element type (PR #68882)

2023-12-20 Thread Nikita Popov via cfe-commits

https://github.com/nikic edited https://github.com/llvm/llvm-project/pull/68882
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [InstCombine] Canonicalize constant GEPs to i8 source element type (PR #68882)

2023-12-20 Thread Nikita Popov via cfe-commits

https://github.com/nikic ready_for_review 
https://github.com/llvm/llvm-project/pull/68882
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [InstCombine] Canonicalize constant GEPs to i8 source element type (PR #68882)

2023-12-20 Thread via cfe-commits

llvmbot wrote:



@llvm/pr-subscribers-backend-risc-v
@llvm/pr-subscribers-backend-amdgpu

@llvm/pr-subscribers-clang

Author: Nikita Popov (nikic)


Changes

This patch canonicalizes getelementptr instructions with constant indices to 
use the `i8` source element type. This makes it easier for optimizations to 
recognize that two GEPs are identical, because they don't need to see past many 
different ways to express the same offset.

This is a first step towards 
https://discourse.llvm.org/t/rfc-replacing-getelementptr-with-ptradd/68699. 
This is limited to constant GEPs only for now, as they have a clear canonical 
form, while we're not yet sure how exactly to deal with variable indices.

The test llvm/test/Transforms/PhaseOrdering/switch_with_geps.ll gives two 
representative examples of the kind of optimization improvement we expect from 
this change. In the first test SimplifyCFG can now realize that all switch 
branches are actually the same. In the second test it can convert it into 
simple arithmetic. These are representative of common enum optimization 
failures we see in Rust.

---

Patch is 775.99 KiB, truncated to 20.00 KiB below, full version: 
https://github.com/llvm/llvm-project/pull/68882.diff


174 Files Affected:

- (modified) clang/test/CodeGen/PowerPC/builtins-ppc-pair-mma.c (+5-5) 
- (modified) clang/test/CodeGen/aarch64-ls64-inline-asm.c (+9-9) 
- (modified) clang/test/CodeGen/attr-arm-sve-vector-bits-bitcast.c (+24-24) 
- (modified) clang/test/CodeGen/attr-riscv-rvv-vector-bits-bitcast.c (+12-12) 
- (modified) clang/test/CodeGen/cleanup-destslot-simple.c (+2-2) 
- (modified) clang/test/CodeGen/hexagon-brev-ld-ptr-incdec.c (+3-3) 
- (modified) clang/test/CodeGen/ms-intrinsics.c (+6-6) 
- (modified) clang/test/CodeGen/nofpclass.c (+4-4) 
- (modified) clang/test/CodeGen/union-tbaa1.c (+2-2) 
- (modified) clang/test/CodeGenCXX/RelativeVTablesABI/dynamic-cast.cpp (+1-1) 
- (modified) clang/test/CodeGenCXX/RelativeVTablesABI/type-info.cpp (+1-3) 
- (modified) clang/test/CodeGenCXX/microsoft-abi-dynamic-cast.cpp (+6-6) 
- (modified) clang/test/CodeGenCXX/microsoft-abi-typeid.cpp (+1-1) 
- (modified) clang/test/CodeGenObjC/arc-foreach.m (+2-2) 
- (modified) clang/test/CodeGenObjCXX/arc-cxx11-init-list.mm (+1-1) 
- (modified) clang/test/Headers/__clang_hip_math.hip (+12-12) 
- (modified) clang/test/OpenMP/bug57757.cpp (+6-6) 
- (modified) llvm/lib/Transforms/InstCombine/InstructionCombining.cpp (+9) 
- (modified) llvm/test/Analysis/BasicAA/featuretest.ll (+3-3) 
- (modified) llvm/test/CodeGen/AMDGPU/vector-alloca-bitcast.ll (+6-6) 
- (modified) llvm/test/CodeGen/BPF/preserve-static-offset/load-inline.ll (+2-2) 
- (modified) llvm/test/CodeGen/BPF/preserve-static-offset/load-unroll-inline.ll 
(+2-2) 
- (modified) llvm/test/CodeGen/BPF/preserve-static-offset/load-unroll.ll (+4-4) 
- (modified) 
llvm/test/CodeGen/BPF/preserve-static-offset/store-unroll-inline.ll (+2-2) 
- (modified) llvm/test/CodeGen/Hexagon/autohvx/vector-align-tbaa.ll (+27-27) 
- (modified) llvm/test/Transforms/Coroutines/coro-async.ll (+1-1) 
- (modified) llvm/test/Transforms/Coroutines/coro-retcon-alloca-opaque-ptr.ll 
(+1-1) 
- (modified) llvm/test/Transforms/Coroutines/coro-retcon-alloca.ll (+1-1) 
- (modified) llvm/test/Transforms/Coroutines/coro-retcon-once-value.ll (+3-3) 
- (modified) llvm/test/Transforms/Coroutines/coro-retcon-resume-values.ll 
(+4-4) 
- (modified) llvm/test/Transforms/Coroutines/coro-swifterror.ll (+1-1) 
- (modified) llvm/test/Transforms/InstCombine/2007-03-25-BadShiftMask.ll (+1-1) 
- (modified) llvm/test/Transforms/InstCombine/2009-01-08-AlignAlloca.ll (+1-1) 
- (modified) llvm/test/Transforms/InstCombine/2009-02-20-InstCombine-SROA.ll 
(+16-16) 
- (modified) llvm/test/Transforms/InstCombine/X86/x86-addsub-inseltpoison.ll 
(+1-1) 
- (modified) llvm/test/Transforms/InstCombine/X86/x86-addsub.ll (+1-1) 
- (modified) llvm/test/Transforms/InstCombine/add3.ll (+1-1) 
- (modified) llvm/test/Transforms/InstCombine/array.ll (+1-1) 
- (modified) llvm/test/Transforms/InstCombine/assume.ll (+1-1) 
- (modified) llvm/test/Transforms/InstCombine/cast_phi.ll (+2-2) 
- (modified) llvm/test/Transforms/InstCombine/catchswitch-phi.ll (+2-2) 
- (modified) llvm/test/Transforms/InstCombine/compare-alloca.ll (+1-1) 
- (modified) llvm/test/Transforms/InstCombine/extractvalue.ll (+2-2) 
- (modified) llvm/test/Transforms/InstCombine/gep-addrspace.ll (+1-1) 
- (modified) 
llvm/test/Transforms/InstCombine/gep-canonicalize-constant-indices.ll (+9-9) 
- (modified) llvm/test/Transforms/InstCombine/gep-combine-loop-invariant.ll 
(+3-3) 
- (modified) llvm/test/Transforms/InstCombine/gep-custom-dl.ll (+2-2) 
- (modified) llvm/test/Transforms/InstCombine/gep-merge-constant-indices.ll 
(+7-7) 
- (modified) llvm/test/Transforms/InstCombine/gep-vector-indices.ll (+4-4) 
- (modified) llvm/test/Transforms/InstCombine/gep-vector.ll (+1-1) 
- (modified) llvm/test/Transforms/InstCombine/gepphigep.ll (+1-1) 
- (modified) llvm/test/Transform

[clang] [llvm] [InstCombine] Canonicalize constant GEPs to i8 source element type (PR #68882)

2023-12-20 Thread Nikita Popov via cfe-commits


@@ -560,14 +560,15 @@ define i32 @test28() nounwind  {
 ; CHECK-NEXT:  entry:
 ; CHECK-NEXT:[[ORIENTATIONS:%.*]] = alloca [1 x [1 x %struct.x]], align 8
 ; CHECK-NEXT:[[T3:%.*]] = call i32 @puts(ptr noundef nonnull 
dereferenceable(1) @.str) #[[ATTR0]]
+; CHECK-NEXT:[[T45:%.*]] = getelementptr inbounds i8, ptr 
[[ORIENTATIONS]], i64 1
 ; CHECK-NEXT:br label [[BB10:%.*]]
 ; CHECK:   bb10:
 ; CHECK-NEXT:[[INDVAR:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ 
[[INDVAR_NEXT:%.*]], [[BB10]] ]
 ; CHECK-NEXT:[[T12_REC:%.*]] = xor i32 [[INDVAR]], -1
 ; CHECK-NEXT:[[TMP0:%.*]] = sext i32 [[T12_REC]] to i64
-; CHECK-NEXT:[[T12:%.*]] = getelementptr inbounds [1 x [1 x %struct.x]], 
ptr [[ORIENTATIONS]], i64 1, i64 0, i64 [[TMP0]]
+; CHECK-NEXT:[[T12:%.*]] = getelementptr inbounds [[STRUCT_X:%.*]], ptr 
[[T45]], i64 [[TMP0]]
 ; CHECK-NEXT:[[T16:%.*]] = call i32 (ptr, ...) @printf(ptr noundef nonnull 
dereferenceable(1) @.str1, ptr nonnull [[T12]]) #[[ATTR0]]
-; CHECK-NEXT:[[T84:%.*]] = icmp eq i32 [[INDVAR]], 0
+; CHECK-NEXT:[[T84:%.*]] = icmp eq ptr [[T12]], [[ORIENTATIONS]]

nikic wrote:

(I still plan to fix this remaining regression, but I don't think it needs to 
block this PR.)

https://github.com/llvm/llvm-project/pull/68882
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[llvm] [clang] [InstCombine] Canonicalize constant GEPs to i8 source element type (PR #68882)

2023-12-20 Thread Nikita Popov via cfe-commits

https://github.com/nikic edited https://github.com/llvm/llvm-project/pull/68882
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[llvm] [clang] [InstCombine] Canonicalize constant GEPs to i8 source element type (PR #68882)

2023-12-20 Thread Nikita Popov via cfe-commits

https://github.com/nikic edited https://github.com/llvm/llvm-project/pull/68882
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[llvm] [clang] [AArch64] Support for 9.5-A PAuthLR (PR #75947)

2023-12-20 Thread Jonathan Thackray via cfe-commits

jthackray wrote:

Long diff! Looks good to me, great work.

https://github.com/llvm/llvm-project/pull/75947
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[llvm] [clang] [AArch64] Support for 9.5-A PAuthLR (PR #75947)

2023-12-20 Thread Jonathan Thackray via cfe-commits

https://github.com/jthackray approved this pull request.

+2

https://github.com/llvm/llvm-project/pull/75947
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][dataflow] Disallow setting properties on `RecordValue`s. (PR #76042)

2023-12-20 Thread via cfe-commits

https://github.com/martinboehme created 
https://github.com/llvm/llvm-project/pull/76042

Instead, synthetic fields should now be used for the same purpose. These have a
number of advantages, as described in
https://github.com/llvm/llvm-project/pull/73860, and longer-term, we want to
eliminate `RecordValue` entirely.

As `RecordValue`s cannot have properties any more, I have replaced the
`OptionalIntAnalysis` with an equivalent analysis that tracks nullness of
pointers (instead of whether an optional has a value). This serves the same
purpose, namely to check whether the framework applies a custom `merge()`
operation to widen properties.


>From 86a00577bcdb78b7d119579df1fa74ce66022d66 Mon Sep 17 00:00:00 2001
From: Martin Braenne 
Date: Wed, 20 Dec 2023 11:54:49 +
Subject: [PATCH] [clang][dataflow] Disallow setting properties on
 `RecordValue`s.

Instead, synthetic fields should now be used for the same purpose. These have a
number of advantages, as described in
https://github.com/llvm/llvm-project/pull/73860, and longer-term, we want to
eliminate `RecordValue` entirely.

As `RecordValue`s cannot have properties any more, I have replaced the
`OptionalIntAnalysis` with an equivalent analysis that tracks nullness of
pointers (instead of whether an optional has a value). This serves the same
purpose, namely to check whether the framework applies a custom `merge()`
operation to widen properties.
---
 .../FlowSensitive/DataflowEnvironment.h   |  11 --
 .../clang/Analysis/FlowSensitive/RecordOps.h  |  12 +-
 .../clang/Analysis/FlowSensitive/Value.h  |  40 ++---
 .../lib/Analysis/FlowSensitive/RecordOps.cpp  |  33 +---
 .../Analysis/FlowSensitive/RecordOpsTest.cpp  |  37 -
 .../TypeErasedDataflowAnalysisTest.cpp| 150 --
 6 files changed, 88 insertions(+), 195 deletions(-)

diff --git a/clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h 
b/clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
index 5943af50b6ad8f..47064e1898142d 100644
--- a/clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
+++ b/clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
@@ -691,20 +691,9 @@ RecordStorageLocation *getBaseObjectLocation(const 
MemberExpr &ME,
 std::vector getFieldsForInitListExpr(const RecordDecl *RD);
 
 /// Associates a new `RecordValue` with `Loc` and returns the new value.
-/// It is not defined whether the field values remain the same or not.
-///
-/// This function is primarily intended for use by checks that set custom
-/// properties on `RecordValue`s to model the state of these values. Such 
checks
-/// should avoid modifying the properties of an existing `RecordValue` because
-/// these changes would be visible to other `Environment`s that share the same
-/// `RecordValue`. Instead, call `refreshRecordValue()`, then set the 
properties
-/// on the new `RecordValue` that it returns. Typical usage:
-///
-///   refreshRecordValue(Loc, Env).setProperty("my_prop", MyPropValue);
 RecordValue &refreshRecordValue(RecordStorageLocation &Loc, Environment &Env);
 
 /// Associates a new `RecordValue` with `Expr` and returns the new value.
-/// See also documentation for the overload above.
 RecordValue &refreshRecordValue(const Expr &Expr, Environment &Env);
 
 } // namespace dataflow
diff --git a/clang/include/clang/Analysis/FlowSensitive/RecordOps.h 
b/clang/include/clang/Analysis/FlowSensitive/RecordOps.h
index 7b87840d626b4b..783e53e980aa2c 100644
--- a/clang/include/clang/Analysis/FlowSensitive/RecordOps.h
+++ b/clang/include/clang/Analysis/FlowSensitive/RecordOps.h
@@ -22,19 +22,13 @@ namespace dataflow {
 /// Copies a record (struct, class, or union) from `Src` to `Dst`.
 ///
 /// This performs a deep copy, i.e. it copies every field (including synthetic
-/// fields) and recurses on fields of record type. It also copies properties
-/// from the `RecordValue` associated with `Src` to the `RecordValue` 
associated
-/// with `Dst` (if these `RecordValue`s exist).
+/// fields) and recurses on fields of record type.
 ///
 /// If there is a `RecordValue` associated with `Dst` in the environment, this
 /// function creates a new `RecordValue` and associates it with `Dst`; clients
 /// need to be aware of this and must not assume that the `RecordValue`
 /// associated with `Dst` remains the same after the call.
 ///
-/// We create a new `RecordValue` rather than modifying properties on the old
-/// `RecordValue` because the old `RecordValue` may be shared with other
-/// `Environment`s, and we don't want changes to properties to be visible 
there.
-///
 /// Requirements:
 ///
 ///  `Src` and `Dst` must have the same canonical unqualified type.
@@ -49,9 +43,7 @@ void copyRecord(RecordStorageLocation &Src, 
RecordStorageLocation &Dst,
 ///
 /// This performs a deep comparison, i.e. it compares every field (including
 /// synthetic fields) and recurses on fields of record type. Fields of 
reference
-/// type compare equal if they refe

[clang] [clang][dataflow] Disallow setting properties on `RecordValue`s. (PR #76042)

2023-12-20 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-analysis

Author: None (martinboehme)


Changes

Instead, synthetic fields should now be used for the same purpose. These have a
number of advantages, as described in
https://github.com/llvm/llvm-project/pull/73860, and longer-term, we want to
eliminate `RecordValue` entirely.

As `RecordValue`s cannot have properties any more, I have replaced the
`OptionalIntAnalysis` with an equivalent analysis that tracks nullness of
pointers (instead of whether an optional has a value). This serves the same
purpose, namely to check whether the framework applies a custom `merge()`
operation to widen properties.


---

Patch is 21.32 KiB, truncated to 20.00 KiB below, full version: 
https://github.com/llvm/llvm-project/pull/76042.diff


6 Files Affected:

- (modified) clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h 
(-11) 
- (modified) clang/include/clang/Analysis/FlowSensitive/RecordOps.h (+2-10) 
- (modified) clang/include/clang/Analysis/FlowSensitive/Value.h (+17-23) 
- (modified) clang/lib/Analysis/FlowSensitive/RecordOps.cpp (+1-32) 
- (modified) clang/unittests/Analysis/FlowSensitive/RecordOpsTest.cpp (-37) 
- (modified) 
clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp 
(+68-82) 


``diff
diff --git a/clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h 
b/clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
index 5943af50b6ad8f..47064e1898142d 100644
--- a/clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
+++ b/clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
@@ -691,20 +691,9 @@ RecordStorageLocation *getBaseObjectLocation(const 
MemberExpr &ME,
 std::vector getFieldsForInitListExpr(const RecordDecl *RD);
 
 /// Associates a new `RecordValue` with `Loc` and returns the new value.
-/// It is not defined whether the field values remain the same or not.
-///
-/// This function is primarily intended for use by checks that set custom
-/// properties on `RecordValue`s to model the state of these values. Such 
checks
-/// should avoid modifying the properties of an existing `RecordValue` because
-/// these changes would be visible to other `Environment`s that share the same
-/// `RecordValue`. Instead, call `refreshRecordValue()`, then set the 
properties
-/// on the new `RecordValue` that it returns. Typical usage:
-///
-///   refreshRecordValue(Loc, Env).setProperty("my_prop", MyPropValue);
 RecordValue &refreshRecordValue(RecordStorageLocation &Loc, Environment &Env);
 
 /// Associates a new `RecordValue` with `Expr` and returns the new value.
-/// See also documentation for the overload above.
 RecordValue &refreshRecordValue(const Expr &Expr, Environment &Env);
 
 } // namespace dataflow
diff --git a/clang/include/clang/Analysis/FlowSensitive/RecordOps.h 
b/clang/include/clang/Analysis/FlowSensitive/RecordOps.h
index 7b87840d626b4b..783e53e980aa2c 100644
--- a/clang/include/clang/Analysis/FlowSensitive/RecordOps.h
+++ b/clang/include/clang/Analysis/FlowSensitive/RecordOps.h
@@ -22,19 +22,13 @@ namespace dataflow {
 /// Copies a record (struct, class, or union) from `Src` to `Dst`.
 ///
 /// This performs a deep copy, i.e. it copies every field (including synthetic
-/// fields) and recurses on fields of record type. It also copies properties
-/// from the `RecordValue` associated with `Src` to the `RecordValue` 
associated
-/// with `Dst` (if these `RecordValue`s exist).
+/// fields) and recurses on fields of record type.
 ///
 /// If there is a `RecordValue` associated with `Dst` in the environment, this
 /// function creates a new `RecordValue` and associates it with `Dst`; clients
 /// need to be aware of this and must not assume that the `RecordValue`
 /// associated with `Dst` remains the same after the call.
 ///
-/// We create a new `RecordValue` rather than modifying properties on the old
-/// `RecordValue` because the old `RecordValue` may be shared with other
-/// `Environment`s, and we don't want changes to properties to be visible 
there.
-///
 /// Requirements:
 ///
 ///  `Src` and `Dst` must have the same canonical unqualified type.
@@ -49,9 +43,7 @@ void copyRecord(RecordStorageLocation &Src, 
RecordStorageLocation &Dst,
 ///
 /// This performs a deep comparison, i.e. it compares every field (including
 /// synthetic fields) and recurses on fields of record type. Fields of 
reference
-/// type compare equal if they refer to the same storage location. If
-/// `RecordValue`s are associated with `Loc1` and Loc2`, it also compares the
-/// properties on those `RecordValue`s.
+/// type compare equal if they refer to the same storage location.
 ///
 /// Note on how to interpret the result:
 /// - If this returns true, the records are guaranteed to be equal at runtime.
diff --git a/clang/include/clang/Analysis/FlowSensitive/Value.h 
b/clang/include/clang/Analysis/FlowSensitive/Value.h
index e6c68e5b4e93e1..021acc14ca15a7 100644
--- a/clang/include/clang/Anal

[clang] [clang][dataflow] Disallow setting properties on `RecordValue`s. (PR #76042)

2023-12-20 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: None (martinboehme)


Changes

Instead, synthetic fields should now be used for the same purpose. These have a
number of advantages, as described in
https://github.com/llvm/llvm-project/pull/73860, and longer-term, we want to
eliminate `RecordValue` entirely.

As `RecordValue`s cannot have properties any more, I have replaced the
`OptionalIntAnalysis` with an equivalent analysis that tracks nullness of
pointers (instead of whether an optional has a value). This serves the same
purpose, namely to check whether the framework applies a custom `merge()`
operation to widen properties.


---

Patch is 21.32 KiB, truncated to 20.00 KiB below, full version: 
https://github.com/llvm/llvm-project/pull/76042.diff


6 Files Affected:

- (modified) clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h 
(-11) 
- (modified) clang/include/clang/Analysis/FlowSensitive/RecordOps.h (+2-10) 
- (modified) clang/include/clang/Analysis/FlowSensitive/Value.h (+17-23) 
- (modified) clang/lib/Analysis/FlowSensitive/RecordOps.cpp (+1-32) 
- (modified) clang/unittests/Analysis/FlowSensitive/RecordOpsTest.cpp (-37) 
- (modified) 
clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp 
(+68-82) 


``diff
diff --git a/clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h 
b/clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
index 5943af50b6ad8f..47064e1898142d 100644
--- a/clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
+++ b/clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
@@ -691,20 +691,9 @@ RecordStorageLocation *getBaseObjectLocation(const 
MemberExpr &ME,
 std::vector getFieldsForInitListExpr(const RecordDecl *RD);
 
 /// Associates a new `RecordValue` with `Loc` and returns the new value.
-/// It is not defined whether the field values remain the same or not.
-///
-/// This function is primarily intended for use by checks that set custom
-/// properties on `RecordValue`s to model the state of these values. Such 
checks
-/// should avoid modifying the properties of an existing `RecordValue` because
-/// these changes would be visible to other `Environment`s that share the same
-/// `RecordValue`. Instead, call `refreshRecordValue()`, then set the 
properties
-/// on the new `RecordValue` that it returns. Typical usage:
-///
-///   refreshRecordValue(Loc, Env).setProperty("my_prop", MyPropValue);
 RecordValue &refreshRecordValue(RecordStorageLocation &Loc, Environment &Env);
 
 /// Associates a new `RecordValue` with `Expr` and returns the new value.
-/// See also documentation for the overload above.
 RecordValue &refreshRecordValue(const Expr &Expr, Environment &Env);
 
 } // namespace dataflow
diff --git a/clang/include/clang/Analysis/FlowSensitive/RecordOps.h 
b/clang/include/clang/Analysis/FlowSensitive/RecordOps.h
index 7b87840d626b4b..783e53e980aa2c 100644
--- a/clang/include/clang/Analysis/FlowSensitive/RecordOps.h
+++ b/clang/include/clang/Analysis/FlowSensitive/RecordOps.h
@@ -22,19 +22,13 @@ namespace dataflow {
 /// Copies a record (struct, class, or union) from `Src` to `Dst`.
 ///
 /// This performs a deep copy, i.e. it copies every field (including synthetic
-/// fields) and recurses on fields of record type. It also copies properties
-/// from the `RecordValue` associated with `Src` to the `RecordValue` 
associated
-/// with `Dst` (if these `RecordValue`s exist).
+/// fields) and recurses on fields of record type.
 ///
 /// If there is a `RecordValue` associated with `Dst` in the environment, this
 /// function creates a new `RecordValue` and associates it with `Dst`; clients
 /// need to be aware of this and must not assume that the `RecordValue`
 /// associated with `Dst` remains the same after the call.
 ///
-/// We create a new `RecordValue` rather than modifying properties on the old
-/// `RecordValue` because the old `RecordValue` may be shared with other
-/// `Environment`s, and we don't want changes to properties to be visible 
there.
-///
 /// Requirements:
 ///
 ///  `Src` and `Dst` must have the same canonical unqualified type.
@@ -49,9 +43,7 @@ void copyRecord(RecordStorageLocation &Src, 
RecordStorageLocation &Dst,
 ///
 /// This performs a deep comparison, i.e. it compares every field (including
 /// synthetic fields) and recurses on fields of record type. Fields of 
reference
-/// type compare equal if they refer to the same storage location. If
-/// `RecordValue`s are associated with `Loc1` and Loc2`, it also compares the
-/// properties on those `RecordValue`s.
+/// type compare equal if they refer to the same storage location.
 ///
 /// Note on how to interpret the result:
 /// - If this returns true, the records are guaranteed to be equal at runtime.
diff --git a/clang/include/clang/Analysis/FlowSensitive/Value.h 
b/clang/include/clang/Analysis/FlowSensitive/Value.h
index e6c68e5b4e93e1..021acc14ca15a7 100644
--- a/clang/include/clang/Analysis/Flow

[llvm] [lldb] [clang-tools-extra] [flang] [clang] [IndVars] Add check of loop invariant for trunc instructions (PR #71072)

2023-12-20 Thread Markos Horro via cfe-commits

markoshorro wrote:

@fhahn yeah, thanks. I'm investigating this.

https://github.com/llvm/llvm-project/pull/71072
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[llvm] [lldb] [clang-tools-extra] [flang] [clang] [IndVars] Add check of loop invariant for trunc instructions (PR #71072)

2023-12-20 Thread Florian Hahn via cfe-commits

fhahn wrote:

@markoshorro Great thanks. Please revert the patch if you won't be able to fix 
this today.

https://github.com/llvm/llvm-project/pull/71072
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [flang] [Flang] remove whole-archive option for AIX linker (PR #76039)

2023-12-20 Thread via cfe-commits

https://github.com/madanial0 updated 
https://github.com/llvm/llvm-project/pull/76039

>From a61a1c050612493d17b5ec199d00c38afdee8663 Mon Sep 17 00:00:00 2001
From: Mark Danial 
Date: Wed, 20 Dec 2023 05:38:28 -0500
Subject: [PATCH] [Flang] remove whole-archive option for AIX linker

---
 clang/lib/Driver/ToolChains/CommonArgs.cpp | 3 ++-
 flang/test/Driver/no-duplicate-main.f90| 2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp 
b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index 4f4bdac793bea7..e9bd8f2b2aff48 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -1175,7 +1175,8 @@ static void addFortranMain(const ToolChain &TC, const 
ArgList &Args,
   // sure that the main() function from Fortran_main.a is pulled in by the
   // linker. However, it shouldn't be used if it's already active.
   // TODO: Find an equivalent of `--whole-archive` for Darwin.
-  if (!isWholeArchivePresent(Args) && !TC.getTriple().isMacOSX()) {
+  if (!isWholeArchivePresent(Args) && !TC.getTriple().isMacOSX() &&
+  !TC.getTriple().isOSAIX()) {
 CmdArgs.push_back("--whole-archive");
 CmdArgs.push_back("-lFortran_main");
 CmdArgs.push_back("--no-whole-archive");
diff --git a/flang/test/Driver/no-duplicate-main.f90 
b/flang/test/Driver/no-duplicate-main.f90
index b884e7ecd7f12a..88f4430828e090 100644
--- a/flang/test/Driver/no-duplicate-main.f90
+++ b/flang/test/Driver/no-duplicate-main.f90
@@ -1,4 +1,4 @@
-! UNSUPPORTED: system-windows, system-darwin
+! UNSUPPORTED: system-windows, system-darwin, system-aix
 
 ! RUN: %flang -x ir -o %t.c-object -c %S/Inputs/no_duplicate_main.ll
 ! RUN: %flang -o %t -c %s

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


[clang] [Sema] Provide `-fno-/-fvisibility-global-new-delete` option (PR #75364)

2023-12-20 Thread via cfe-commits

bd1976bris wrote:

Thanks for the responses.

> The meaning that we want to make clear is that this toggles the special 
> behavior of forcing the visibility of these symbols despite all the other 
> mechanisms that usually control visibility for all other symbols.

Agreed. I'm in favour of your suggestion of 
`-f[no-]forced-global-new-delete-visibility`. Including "forced" in the option 
name makes it clear that something unusual is going on here and hints that this 
is going to take precedence over other sources of visibility. I did consider 
that it might be better to rearrange your suggested option name a bit to 
`-f[no-]visibility-global-new-delete-forced` to group with other visibility 
options that start with `-fvisibility`, but 
`-f[no-]forced-global-new-delete-visibility` is much clearer.  @petrhosek I did 
consider `-f[no-]visibility-attribute-global-new-delete` but that naming is 
possibly tied a bit too strongly to the current implementation in the complier 
- so I think I like the `forced` suggestion better?

>  (The `=...` variant of the positive form would permit forcing to a different 
> visibility than `default`, though I'm not sure there's a real need for that 
> capability since in `-fno-forced-...` state the usual pragmas et al can 
> arrange for that.)

Indeed and the use of the usual pragmas etc is preferable, IMO, as users are 
already familiar with those - as opposed to the effects of an unusual/niche 
option.

https://github.com/llvm/llvm-project/pull/75364
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clang] [flang] [llvm] [flang] Pass to add frame pointer attribute (PR #74598)

2023-12-20 Thread Radu Salavat via cfe-commits


@@ -245,6 +245,24 @@ static void 
parseCodeGenArgs(Fortran::frontend::CodeGenOptions &opts,
 
   opts.AliasAnalysis = opts.OptimizationLevel > 0;
 
+  if (const llvm::opt::Arg *a =
+  args.getLastArg(clang::driver::options::OPT_mframe_pointer_EQ)) {
+llvm::StringRef s = a->getValue();
+
+if (!(s == "none" || s == "non-leaf" || s == "all")) {
+  const auto debugWarningId = diags.getCustomDiagID(
+  clang::DiagnosticsEngine::Error, "Frame pointer: %0");

Radu2k wrote:

[flang/test/Driver/frame-pointer-forwarding.f90](https://github.com/llvm/llvm-project/pull/74598/files#diff-fad5151400801da3763ab30d3470d69a748b236f0793afc41a9a94f6432a7c78)

https://github.com/llvm/llvm-project/pull/74598
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][Sema] Add -Wswitch-default warning option (PR #73077)

2023-12-20 Thread via cfe-commits

gendalph wrote:

In real projects mix enum class with old int switch. Try to update defaults and 
have noise from enum class case.
My be mix options -Wswitch  -Wswitch-default can disable warning in enum class 
case without default if full covered?

https://godbolt.org/z/xrdafn6WK

https://github.com/llvm/llvm-project/pull/73077
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][CodeGen] Always use CLANG_VENDOR as a quoted string (PR #75935)

2023-12-20 Thread Dimitry Andric via cfe-commits

https://github.com/DimitryAndric updated 
https://github.com/llvm/llvm-project/pull/75935

>From 4b3db6bdaf9f94277f23bf9a796f474a353e4d73 Mon Sep 17 00:00:00 2001
From: Dimitry Andric 
Date: Tue, 19 Dec 2023 13:37:37 +0100
Subject: [PATCH] [clang] Add getClangVendor() and use it in CodeGenModule.cpp

In 9a38a72f1d482 `ProductId` was assigned from the stringified value of
`CLANG_VENDOR`, if that macro was defined. However, `CLANG_VENDOR` is
supposed to be a string, as it is defined (optionally) as such in the
top-level clang `CMakeLists.txt`.

Furthermore, `CLANG_VENDOR` is only passed as a build-time define when
compiling `Version.cpp`, so add a `getClangVendor()` function to
`Version.h`, and use it in `CodegGenModule.cpp`, instead of relying on
the macro.

Fixes: 9a38a72f1d482
---
 clang/include/clang/Basic/Version.h |  3 +++
 clang/lib/Basic/Version.cpp | 19 +++
 clang/lib/CodeGen/CodeGenModule.cpp |  7 +--
 3 files changed, 15 insertions(+), 14 deletions(-)

diff --git a/clang/include/clang/Basic/Version.h 
b/clang/include/clang/Basic/Version.h
index 2881d8db954e0b..8e4e6928fded50 100644
--- a/clang/include/clang/Basic/Version.h
+++ b/clang/include/clang/Basic/Version.h
@@ -40,6 +40,9 @@ namespace clang {
   /// string as getClangRevision.
   std::string getLLVMRevision();
 
+  /// Retrieves the Clang vendor tag.
+  std::string getClangVendor();
+
   /// Retrieves the full repository version that is an amalgamation of
   /// the information in getClangRepositoryPath() and getClangRevision().
   std::string getClangFullRepositoryVersion();
diff --git a/clang/lib/Basic/Version.cpp b/clang/lib/Basic/Version.cpp
index e205da7adec1d8..67aa653770df93 100644
--- a/clang/lib/Basic/Version.cpp
+++ b/clang/lib/Basic/Version.cpp
@@ -57,6 +57,15 @@ std::string getLLVMRevision() {
 #endif
 }
 
+std::string getClangVendor()
+{
+#ifdef CLANG_VENDOR
+  return CLANG_VENDOR;
+#else
+  return "";
+#endif
+}
+
 std::string getClangFullRepositoryVersion() {
   std::string buf;
   llvm::raw_string_ostream OS(buf);
@@ -92,10 +101,7 @@ std::string getClangFullVersion() {
 std::string getClangToolFullVersion(StringRef ToolName) {
   std::string buf;
   llvm::raw_string_ostream OS(buf);
-#ifdef CLANG_VENDOR
-  OS << CLANG_VENDOR;
-#endif
-  OS << ToolName << " version " CLANG_VERSION_STRING;
+  OS << getClangVendor() << ToolName << " version " CLANG_VERSION_STRING;
 
   std::string repo = getClangFullRepositoryVersion();
   if (!repo.empty()) {
@@ -110,10 +116,7 @@ std::string getClangFullCPPVersion() {
   // the one we report on the command line.
   std::string buf;
   llvm::raw_string_ostream OS(buf);
-#ifdef CLANG_VENDOR
-  OS << CLANG_VENDOR;
-#endif
-  OS << "Clang " CLANG_VERSION_STRING;
+  OS << getClangVendor() << "Clang " CLANG_VERSION_STRING;
 
   std::string repo = getClangFullRepositoryVersion();
   if (!repo.empty()) {
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index 7ad26ace328ab2..b2e173d0d6949e 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -995,12 +995,7 @@ void CodeGenModule::Release() {
   uint32_t(CLANG_VERSION_MINOR));
 getModule().addModuleFlag(llvm::Module::Warning, "zos_product_patchlevel",
   uint32_t(CLANG_VERSION_PATCHLEVEL));
-std::string ProductId;
-#ifdef CLANG_VENDOR
-ProductId = #CLANG_VENDOR;
-#else
-ProductId = "clang";
-#endif
+std::string ProductId = getClangVendor() + "clang";
 getModule().addModuleFlag(llvm::Module::Error, "zos_product_id",
   llvm::MDString::get(VMContext, ProductId));
 

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


[clang] [clang] Add getClangVendor() and use it in CodeGenModule.cpp (PR #75935)

2023-12-20 Thread Dimitry Andric via cfe-commits

https://github.com/DimitryAndric edited 
https://github.com/llvm/llvm-project/pull/75935
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Add getClangVendor() and use it in CodeGenModule.cpp (PR #75935)

2023-12-20 Thread via cfe-commits

github-actions[bot] wrote:




:warning: C/C++ code formatter, clang-format found issues in your code. 
:warning:



You can test this locally with the following command:


``bash
git-clang-format --diff b01adc6bed7e5b924dd8a097be0aa893f4823905 
4b3db6bdaf9f94277f23bf9a796f474a353e4d73 -- clang/include/clang/Basic/Version.h 
clang/lib/Basic/Version.cpp clang/lib/CodeGen/CodeGenModule.cpp
``





View the diff from clang-format here.


``diff
diff --git a/clang/lib/Basic/Version.cpp b/clang/lib/Basic/Version.cpp
index 67aa653770..4823f566bd 100644
--- a/clang/lib/Basic/Version.cpp
+++ b/clang/lib/Basic/Version.cpp
@@ -57,8 +57,7 @@ std::string getLLVMRevision() {
 #endif
 }
 
-std::string getClangVendor()
-{
+std::string getClangVendor() {
 #ifdef CLANG_VENDOR
   return CLANG_VENDOR;
 #else

``




https://github.com/llvm/llvm-project/pull/75935
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [flang] [flang][driver] Remove Fortain_main static library from linking stages (PR #75816)

2023-12-20 Thread Kiran Chandramohan via cfe-commits

kiranchandramohan wrote:

Looks reasonable to me.

I guess the environment settings that are there in the EnvironmentDefaults 
apply only when the main program is compiled with some flags. It would be good 
to check the options in EnvironmentDefaults and see that they are all 
applicable only when compiled for the main program.



https://github.com/llvm/llvm-project/pull/75816
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Add getClangVendor() and use it in CodeGenModule.cpp (PR #75935)

2023-12-20 Thread Dimitry Andric via cfe-commits

https://github.com/DimitryAndric updated 
https://github.com/llvm/llvm-project/pull/75935

>From ab5263e77e19ede918faf517dd348018c1982590 Mon Sep 17 00:00:00 2001
From: Dimitry Andric 
Date: Tue, 19 Dec 2023 13:37:37 +0100
Subject: [PATCH] [clang] Add getClangVendor() and use it in CodeGenModule.cpp

In 9a38a72f1d482 `ProductId` was assigned from the stringified value of
`CLANG_VENDOR`, if that macro was defined. However, `CLANG_VENDOR` is
supposed to be a string, as it is defined (optionally) as such in the
top-level clang `CMakeLists.txt`.

Furthermore, `CLANG_VENDOR` is only passed as a build-time define when
compiling `Version.cpp`, so add a `getClangVendor()` function to
`Version.h`, and use it in `CodegGenModule.cpp`, instead of relying on
the macro.

Fixes: 9a38a72f1d482
---
 clang/include/clang/Basic/Version.h |  3 +++
 clang/lib/Basic/Version.cpp | 18 ++
 clang/lib/CodeGen/CodeGenModule.cpp |  7 +--
 3 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/clang/include/clang/Basic/Version.h 
b/clang/include/clang/Basic/Version.h
index 2881d8db954e0b..8e4e6928fded50 100644
--- a/clang/include/clang/Basic/Version.h
+++ b/clang/include/clang/Basic/Version.h
@@ -40,6 +40,9 @@ namespace clang {
   /// string as getClangRevision.
   std::string getLLVMRevision();
 
+  /// Retrieves the Clang vendor tag.
+  std::string getClangVendor();
+
   /// Retrieves the full repository version that is an amalgamation of
   /// the information in getClangRepositoryPath() and getClangRevision().
   std::string getClangFullRepositoryVersion();
diff --git a/clang/lib/Basic/Version.cpp b/clang/lib/Basic/Version.cpp
index e205da7adec1d8..4823f566bd7732 100644
--- a/clang/lib/Basic/Version.cpp
+++ b/clang/lib/Basic/Version.cpp
@@ -57,6 +57,14 @@ std::string getLLVMRevision() {
 #endif
 }
 
+std::string getClangVendor() {
+#ifdef CLANG_VENDOR
+  return CLANG_VENDOR;
+#else
+  return "";
+#endif
+}
+
 std::string getClangFullRepositoryVersion() {
   std::string buf;
   llvm::raw_string_ostream OS(buf);
@@ -92,10 +100,7 @@ std::string getClangFullVersion() {
 std::string getClangToolFullVersion(StringRef ToolName) {
   std::string buf;
   llvm::raw_string_ostream OS(buf);
-#ifdef CLANG_VENDOR
-  OS << CLANG_VENDOR;
-#endif
-  OS << ToolName << " version " CLANG_VERSION_STRING;
+  OS << getClangVendor() << ToolName << " version " CLANG_VERSION_STRING;
 
   std::string repo = getClangFullRepositoryVersion();
   if (!repo.empty()) {
@@ -110,10 +115,7 @@ std::string getClangFullCPPVersion() {
   // the one we report on the command line.
   std::string buf;
   llvm::raw_string_ostream OS(buf);
-#ifdef CLANG_VENDOR
-  OS << CLANG_VENDOR;
-#endif
-  OS << "Clang " CLANG_VERSION_STRING;
+  OS << getClangVendor() << "Clang " CLANG_VERSION_STRING;
 
   std::string repo = getClangFullRepositoryVersion();
   if (!repo.empty()) {
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index 7ad26ace328ab2..b2e173d0d6949e 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -995,12 +995,7 @@ void CodeGenModule::Release() {
   uint32_t(CLANG_VERSION_MINOR));
 getModule().addModuleFlag(llvm::Module::Warning, "zos_product_patchlevel",
   uint32_t(CLANG_VERSION_PATCHLEVEL));
-std::string ProductId;
-#ifdef CLANG_VENDOR
-ProductId = #CLANG_VENDOR;
-#else
-ProductId = "clang";
-#endif
+std::string ProductId = getClangVendor() + "clang";
 getModule().addModuleFlag(llvm::Module::Error, "zos_product_id",
   llvm::MDString::get(VMContext, ProductId));
 

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


[flang] [clang] [llvm] [clang-tools-extra] [flang] Pass to add frame pointer attribute (PR #74598)

2023-12-20 Thread Radu Salavat via cfe-commits


@@ -51,9 +51,9 @@
 ! Content to check from the MLIR outputs
 !--
 ! MLIR-FIR-NOT: llvm.func
-! MLIR-FIR: func.func @{{.*}}main() {
+! MLIR-FIR: func.func @{{.*}}main(){{.*}}{

Radu2k wrote:

This was added due to failing the test when it was a default parameter. I do 
not see how  having `{{.*}}` instead of a whitespace should be an issue if no 
parameters are checked.

https://github.com/llvm/llvm-project/pull/74598
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Add getClangVendor() and use it in CodeGenModule.cpp (PR #75935)

2023-12-20 Thread Dimitry Andric via cfe-commits


@@ -995,12 +995,7 @@ void CodeGenModule::Release() {
   uint32_t(CLANG_VERSION_MINOR));
 getModule().addModuleFlag(llvm::Module::Warning, "zos_product_patchlevel",
   uint32_t(CLANG_VERSION_PATCHLEVEL));
-std::string ProductId;
-#ifdef CLANG_VENDOR
-ProductId = #CLANG_VENDOR;
-#else
-ProductId = "clang";
-#endif
+std::string ProductId = getClangVendor() + "clang";

DimitryAndric wrote:

Note that this is the way you are supposed to get a "product-id-with-vendor", 
as the vendor tag itself normally does not contain the word "clang". For 
example, FreeBSD uses "FreeBSD " (so with a trailing space), and Apple uses 
"Apple " (also with trailing space). If any space is desired between the vendor 
tag and the word "clang", it has to be specified in the vendor tag, and not 
appended here in the string concatenation.

https://github.com/llvm/llvm-project/pull/75935
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][Sema] Add -Wswitch-default warning option (PR #73077)

2023-12-20 Thread via cfe-commits

gendalph wrote:

Using an enum class without default is a good opportunity to get a warning in 
all places of use in the switch construct when adding new elements to the enum

https://github.com/llvm/llvm-project/pull/73077
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[flang] [clang] [Flang, Clang] Enable and test 'rdynamic' flag (PR #75598)

2023-12-20 Thread Radu Salavat via cfe-commits

https://github.com/Radu2k updated 
https://github.com/llvm/llvm-project/pull/75598

>From 6180787f9bc9449ce90999c3c5f9c96cfd057a50 Mon Sep 17 00:00:00 2001
From: Radu2k 
Date: Fri, 15 Dec 2023 12:11:04 +
Subject: [PATCH 1/3] Enable and test 'rdynamic' flag

---
 clang/include/clang/Driver/Options.td |  3 ++-
 flang/test/Driver/rdynamic-check.f90  | 10 ++
 2 files changed, 12 insertions(+), 1 deletion(-)
 create mode 100644 flang/test/Driver/rdynamic-check.f90

diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 1b02087425b751..9678165bfd98e8 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -5308,7 +5308,8 @@ def rewrite_objc : Flag<["-"], "rewrite-objc">, 
Flags<[NoXarchOption]>,
 def rewrite_legacy_objc : Flag<["-"], "rewrite-legacy-objc">,
   Flags<[NoXarchOption]>,
   HelpText<"Rewrite Legacy Objective-C source to C++">;
-def rdynamic : Flag<["-"], "rdynamic">, Group;
+def rdynamic : Flag<["-"], "rdynamic">, Group,
+  Visibility<[ClangOption, FlangOption]>;
 def resource_dir : Separate<["-"], "resource-dir">,
   Flags<[NoXarchOption, HelpHidden]>,
   Visibility<[ClangOption, CC1Option, CLOption, DXCOption]>,
diff --git a/flang/test/Driver/rdynamic-check.f90 
b/flang/test/Driver/rdynamic-check.f90
new file mode 100644
index 00..6892d8ac67f212
--- /dev/null
+++ b/flang/test/Driver/rdynamic-check.f90
@@ -0,0 +1,10 @@
+! Verify that rdynamic flag adds -export-dynamic flag and passes it on to the 
linker.
+
+! RUN: %flang -### --target=x86_64-linux-gnu -rdynamic %s 2>&1 | FileCheck 
--check-prefixes=GNU-LINKER-OPTIONS %s
+! RUN: %flang -### --target=aarch64-linux-none -rdynamic %s 2>&1 | FileCheck 
--check-prefixes=AARCH-LINKER-OPTIONS %s
+
+! GNU-LINKER-OPTIONS: "{{.*}}ld"
+! GNU-LINKER-OPTIONS-SAME: "-export-dynamic"
+
+! AARCH-LINKER-OPTIONS: "{{.*}}ld"
+! AARCH-LINKER-OPTIONS-SAME: "-export-dynamic"

>From e2990df14e2432f9e607d0431e2bb4e97dba24b8 Mon Sep 17 00:00:00 2001
From: Radu2k 
Date: Tue, 19 Dec 2023 09:00:40 +
Subject: [PATCH 2/3] Remove dedicated test file

---
 flang/test/Driver/dynamic-linker.f90 |  4 
 flang/test/Driver/rdynamic-check.f90 | 10 --
 2 files changed, 4 insertions(+), 10 deletions(-)
 delete mode 100644 flang/test/Driver/rdynamic-check.f90

diff --git a/flang/test/Driver/dynamic-linker.f90 
b/flang/test/Driver/dynamic-linker.f90
index df119c22a2ea51..5958ee624f836f 100644
--- a/flang/test/Driver/dynamic-linker.f90
+++ b/flang/test/Driver/dynamic-linker.f90
@@ -7,6 +7,7 @@
 ! RUN: %flang -### --target=x86_64-windows-msvc -rpath /path/to/dir -shared \
 ! RUN: -static %s 2>&1 | FileCheck \
 ! RUN: --check-prefixes=MSVC-LINKER-OPTIONS %s
+! RUN: %flang -### --target=aarch64-linux-none -rdynamic %s 2>&1 | FileCheck 
--check-prefixes=AARCH-LINKER-OPTIONS %s
 
 ! TODO: Could the linker have an extension or a suffix?
 ! GNU-LINKER-OPTIONS: "{{.*}}ld{{(.exe)?}}"
@@ -14,6 +15,9 @@
 ! GNU-LINKER-OPTIONS-SAME: "-static"
 ! GNU-LINKER-OPTIONS-SAME: "-rpath" "/path/to/dir"
 
+! AARCH-LINKER-OPTIONS: "{{.*}}ld"
+! AARCH-LINKER-OPTIONS-SAME: "-export-dynamic"
+
 ! For MSVC, adding -static does not add any additional linker options.
 ! MSVC-LINKER-OPTIONS: "{{.*}}link{{(.exe)?}}"
 ! MSVC-LINKER-OPTIONS-SAME: "-dll"
diff --git a/flang/test/Driver/rdynamic-check.f90 
b/flang/test/Driver/rdynamic-check.f90
deleted file mode 100644
index 6892d8ac67f212..00
--- a/flang/test/Driver/rdynamic-check.f90
+++ /dev/null
@@ -1,10 +0,0 @@
-! Verify that rdynamic flag adds -export-dynamic flag and passes it on to the 
linker.
-
-! RUN: %flang -### --target=x86_64-linux-gnu -rdynamic %s 2>&1 | FileCheck 
--check-prefixes=GNU-LINKER-OPTIONS %s
-! RUN: %flang -### --target=aarch64-linux-none -rdynamic %s 2>&1 | FileCheck 
--check-prefixes=AARCH-LINKER-OPTIONS %s
-
-! GNU-LINKER-OPTIONS: "{{.*}}ld"
-! GNU-LINKER-OPTIONS-SAME: "-export-dynamic"
-
-! AARCH-LINKER-OPTIONS: "{{.*}}ld"
-! AARCH-LINKER-OPTIONS-SAME: "-export-dynamic"

>From 524e92b5fdfee329ada30cdb2adabf7b088ffaa8 Mon Sep 17 00:00:00 2001
From: Radu2k 
Date: Wed, 20 Dec 2023 13:26:03 +
Subject: [PATCH 3/3] Change test prefix to 'RDYNAMIC'

---
 flang/test/Driver/dynamic-linker.f90 | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/flang/test/Driver/dynamic-linker.f90 
b/flang/test/Driver/dynamic-linker.f90
index 5958ee624f836f..1cbd407d21ce09 100644
--- a/flang/test/Driver/dynamic-linker.f90
+++ b/flang/test/Driver/dynamic-linker.f90
@@ -7,7 +7,7 @@
 ! RUN: %flang -### --target=x86_64-windows-msvc -rpath /path/to/dir -shared \
 ! RUN: -static %s 2>&1 | FileCheck \
 ! RUN: --check-prefixes=MSVC-LINKER-OPTIONS %s
-! RUN: %flang -### --target=aarch64-linux-none -rdynamic %s 2>&1 | FileCheck 
--check-prefixes=AARCH-LINKER-OPTIONS %s
+! RUN: %flang -### --target=aarch64-linux-none -rdynamic %s 2>&1 | FileCheck 
--check-prefixes=RDYNAMIC-LINKER-OPTION %s
 
 ! TODO: Could t

[clang-tools-extra] [libc] [compiler-rt] [llvm] [clang] [mlir] [OpenMP] atomic compare fail : Codegen support (PR #75709)

2023-12-20 Thread Alexey Bataev via cfe-commits


@@ -6580,6 +6578,51 @@ void CodeGenFunction::EmitOMPAtomicDirective(const 
OMPAtomicDirective &S) {
 }
   }
 
+  if (KindsEncountered.contains(OMPC_compare) &&
+  KindsEncountered.contains(OMPC_fail)) {
+Kind = OMPC_compare;
+const OMPFailClause *fC = S.getSingleClause();

alexey-bataev wrote:

```suggestion
const auto *FC = S.getSingleClause();
```

https://github.com/llvm/llvm-project/pull/75709
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clang] [libc] [mlir] [llvm] [compiler-rt] [OpenMP] atomic compare fail : Codegen support (PR #75709)

2023-12-20 Thread Alexey Bataev via cfe-commits


@@ -6580,6 +6578,51 @@ void CodeGenFunction::EmitOMPAtomicDirective(const 
OMPAtomicDirective &S) {
 }
   }
 
+  if (KindsEncountered.contains(OMPC_compare) &&
+  KindsEncountered.contains(OMPC_fail)) {
+Kind = OMPC_compare;
+const OMPFailClause *fC = S.getSingleClause();
+if (fC) {
+  OpenMPClauseKind fP = fC->getFailParameter();

alexey-bataev wrote:

```suggestion
  OpenMPClauseKind FP = fC->getFailParameter();
```

https://github.com/llvm/llvm-project/pull/75709
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] e86a02c - Use llvm-config.h in CIndexer.cpp instead of private header (#75928)

2023-12-20 Thread via cfe-commits

Author: Abhina Sree
Date: 2023-12-20T08:44:40-05:00
New Revision: e86a02ce89c33f3fa4061fb4c67c3b05c69a72ab

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

LOG: Use llvm-config.h in CIndexer.cpp instead of private header (#75928)

Use llvm-config.h in CIndexer.cpp instead of private header

Added: 


Modified: 
clang/tools/libclang/CIndexer.cpp
llvm/include/llvm/Config/config.h.cmake
llvm/include/llvm/Config/llvm-config.h.cmake

Removed: 




diff  --git a/clang/tools/libclang/CIndexer.cpp 
b/clang/tools/libclang/CIndexer.cpp
index 0623ae69fe01ed..430147b2aa77af 100644
--- a/clang/tools/libclang/CIndexer.cpp
+++ b/clang/tools/libclang/CIndexer.cpp
@@ -17,7 +17,7 @@
 #include "clang/Driver/Driver.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallString.h"
-#include "llvm/Config/config.h"
+#include "llvm/Config/llvm-config.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/MD5.h"
 #include "llvm/Support/Path.h"

diff  --git a/llvm/include/llvm/Config/config.h.cmake 
b/llvm/include/llvm/Config/config.h.cmake
index fc1f9bf342f8d5..d464263c190a73 100644
--- a/llvm/include/llvm/Config/config.h.cmake
+++ b/llvm/include/llvm/Config/config.h.cmake
@@ -50,15 +50,9 @@
don't. */
 #cmakedefine01 HAVE_DECL_STRERROR_S
 
-/* Define to 1 if you have the  header file. */
-#cmakedefine HAVE_DLFCN_H ${HAVE_DLFCN_H}
-
 /* Define if dlopen() is available on this platform. */
 #cmakedefine HAVE_DLOPEN ${HAVE_DLOPEN}
 
-/* Define if dladdr() is available on this platform. */
-#cmakedefine HAVE_DLADDR ${HAVE_DLADDR}
-
 /* Define to 1 if we can register EH frames on this platform. */
 #cmakedefine HAVE_REGISTER_FRAME ${HAVE_REGISTER_FRAME}
 

diff  --git a/llvm/include/llvm/Config/llvm-config.h.cmake 
b/llvm/include/llvm/Config/llvm-config.h.cmake
index 6605ea60df99e1..483c5adc99ca80 100644
--- a/llvm/include/llvm/Config/llvm-config.h.cmake
+++ b/llvm/include/llvm/Config/llvm-config.h.cmake
@@ -198,4 +198,10 @@
 /* Define if plugins enabled */
 #cmakedefine LLVM_ENABLE_PLUGINS
 
+/* Define to 1 if you have the  header file. */
+#cmakedefine HAVE_DLFCN_H ${HAVE_DLFCN_H}
+
+/* Define if dladdr() is available on this platform. */
+#cmakedefine HAVE_DLADDR ${HAVE_DLADDR}
+
 #endif



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


[llvm] [clang] Use llvm-config.h in CIndexer.cpp instead of private header (PR #75928)

2023-12-20 Thread Abhina Sree via cfe-commits

https://github.com/abhina-sree closed 
https://github.com/llvm/llvm-project/pull/75928
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Add tests for driver to propagate module map flags even without -fmod… (PR #75827)

2023-12-20 Thread Walter Lee via cfe-commits

https://github.com/googlewalt updated 
https://github.com/llvm/llvm-project/pull/75827

>From eefa77a7cc7c671ef1551239e473f0267527dfa3 Mon Sep 17 00:00:00 2001
From: Walter Lee 
Date: Mon, 18 Dec 2023 11:41:43 -0500
Subject: [PATCH 1/2] Add tests for driver to propagate module map flags when
 -fno-modules

We rely on this behavior for layering check.  Xcode 14.3.1 seems to
have dropped these flags so we are creating a unit test to reproduce
the issue.
---
 clang/test/Driver/modules.m | 8 
 1 file changed, 8 insertions(+)

diff --git a/clang/test/Driver/modules.m b/clang/test/Driver/modules.m
index 9eb3569805569a..7b215bb6d870d6 100644
--- a/clang/test/Driver/modules.m
+++ b/clang/test/Driver/modules.m
@@ -57,6 +57,14 @@
 // CHECK-MODULE-MAP-FILES: "-fmodule-map-file=foo.map"
 // CHECK-MODULE-MAP-FILES: "-fmodule-map-file=bar.map"
 
+// Verify that the driver propagates -fmodule-name and -fmodule-map-file flags 
even with
+// -fno-modules.  We rely on this behavior for layering check.
+// RUN: %clang -fno-modules -fmodule-name=foo -c -### %s 2>&1 | FileCheck 
-check-prefix=CHECK-PROPAGATE-MODULE-NAME %s
+// CHECK-PROPAGATE-MODULE-NAME: -fmodule-name=foo
+
+// RUN: %clang -fno-modules -fmodule-map-file=foo.map -c -### %s 2>&1 | 
FileCheck -check-prefix=CHECK-PROPAGATE-MODULE-MAPS %s
+// CHECK-PROPAGATE-MODULE-MAPS: -fmodule-map-file=foo.map
+
 // RUN: %clang -fmodules -fbuiltin-module-map -### %s 2>&1 | FileCheck 
-check-prefix=CHECK-BUILTIN-MODULE-MAP %s
 // CHECK-BUILTIN-MODULE-MAP: "-fmodules"
 // CHECK-BUILTIN-MODULE-MAP: 
"-fmodule-map-file={{.*}}include{{/|}}module.modulemap"

>From 782b6224d6660a243c19a8c9bb58510d6578a64d Mon Sep 17 00:00:00 2001
From: Walter Lee 
Date: Wed, 20 Dec 2023 08:42:49 -0500
Subject: [PATCH 2/2] Change tests to directly test for layering check

---
 clang/test/Driver/modules.m | 20 +---
 1 file changed, 13 insertions(+), 7 deletions(-)

diff --git a/clang/test/Driver/modules.m b/clang/test/Driver/modules.m
index 7b215bb6d870d6..d1a65f5cb07133 100644
--- a/clang/test/Driver/modules.m
+++ b/clang/test/Driver/modules.m
@@ -57,15 +57,21 @@
 // CHECK-MODULE-MAP-FILES: "-fmodule-map-file=foo.map"
 // CHECK-MODULE-MAP-FILES: "-fmodule-map-file=bar.map"
 
-// Verify that the driver propagates -fmodule-name and -fmodule-map-file flags 
even with
-// -fno-modules.  We rely on this behavior for layering check.
-// RUN: %clang -fno-modules -fmodule-name=foo -c -### %s 2>&1 | FileCheck 
-check-prefix=CHECK-PROPAGATE-MODULE-NAME %s
-// CHECK-PROPAGATE-MODULE-NAME: -fmodule-name=foo
+// Verify that the driver propagates -fmodule-name and -fmodule-map-file flags 
when
+// -fmodules-decluse or -fmodules-strict-decluse, as used for layering check.
+// RUN: %clang -fmodules-decluse -fmodule-name=foo -c -### %s 2>&1 | FileCheck 
-check-prefix=CHECK-DECLUSE-PROPAGATE-MODULE-NAME %s
+// CHECK-DECLUSE-PROPAGATE-MODULE-NAME: -fmodule-name=foo
 
-// RUN: %clang -fno-modules -fmodule-map-file=foo.map -c -### %s 2>&1 | 
FileCheck -check-prefix=CHECK-PROPAGATE-MODULE-MAPS %s
-// CHECK-PROPAGATE-MODULE-MAPS: -fmodule-map-file=foo.map
+// RUN: %clang -fmodules-decluse -fmodule-map-file=foo.map -c -### %s 2>&1 | 
FileCheck -check-prefix=CHECK-DECLUSE-PROPAGATE-MODULE-MAPS %s
+// CHECK-DECLUSE-PROPAGATE-MODULE-MAPS: -fmodule-map-file=foo.map
 
-// RUN: %clang -fmodules -fbuiltin-module-map -### %s 2>&1 | FileCheck 
-check-prefix=CHECK-BUILTIN-MODULE-MAP %s
+// RUN: %clang -fmodules-strict-decluse -fmodule-name=foo -c -### %s 2>&1 | 
FileCheck -check-prefix=CHECK-STRICT-DECLUSE-PROPAGATE-MODULE-NAME %s
+// CHECK-STRICT-DECLUSE-PROPAGATE-MODULE-NAME: -fmodule-name=foo
+
+// RUN: %clang -fmodules-strict-decluse -fmodule-map-file=foo.map -c -### %s 
2>&1 | FileCheck -check-prefix=CHECK-STRICT-DECLUSE-PROPAGATE-MODULE-MAPS %s
+// CHECK-STRICT-DECLUSE-PROPAGATE-MODULE-MAPS: -fmodule-map-file=foo.map
+
+// RUN: %clang -fmodules -fbuiltin-module-map -### %s 2>&1 | FileCheck 
-check-prefix=CHECK-BUILTIN-MODULE-MAP %s
 // CHECK-BUILTIN-MODULE-MAP: "-fmodules"
 // CHECK-BUILTIN-MODULE-MAP: 
"-fmodule-map-file={{.*}}include{{/|}}module.modulemap"
 

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


[clang] Add tests for driver to propagate module map flags even without -fmod… (PR #75827)

2023-12-20 Thread Walter Lee via cfe-commits


@@ -57,6 +57,14 @@
 // CHECK-MODULE-MAP-FILES: "-fmodule-map-file=foo.map"
 // CHECK-MODULE-MAP-FILES: "-fmodule-map-file=bar.map"
 
+// RUN: %clang -fno-modules -fmodule-name=foo -c -### %s 2>&1 | FileCheck 
-check-prefix=CHECK-PROPAGATE-MODULE-NAME %s

googlewalt wrote:

I changed the tests to directly test for layering check, since that's what I 
care about.  I don't see analogous tests for c/c++.  Should I add them?

https://github.com/llvm/llvm-project/pull/75827
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [flang] [flang][driver] Remove Fortain_main static library from linking stages (PR #75816)

2023-12-20 Thread Michael Klemm via cfe-commits


@@ -163,6 +163,40 @@ forward compiler options to the frontend driver, 
`flang-new -fc1`.
 You can read more on the design of `clangDriver` in Clang's [Driver Design &
 Internals](https://clang.llvm.org/docs/DriverInternals.html).
 
+## Linker Driver
+When used as a linker, Flang's frontend driver assembles the command line for 
an
+external linker command (e.g., LLVM's `lld`) and invokes it to create the final
+executable by linking static and shared libraries together with all the
+translation units supplied as object files.
+
+By default, the Flang linker driver adds several libraries to the linker
+invocation to make sure that all entrypoints for program start
+(Fortran's program unit) and runtime routines can be resolved by the linker.
+The libraries are:
+
+* `Fortran_main`: Provides the main entry point `main` that then invokes
+  `_QQmain` with the Fortran program unit.  This library has a dependency to
+  the `FortranRuntime` library.
+* `FortranRuntime`: Provides most of the Flang runtime library.
+* `FortranDecimal`: Provides operations for decimal numbers.
+
+The default is that, when using Flang as the linker, one of the Fortran
+translation units provides the program unit and therefore it is assumed that
+Fortran is the main code part (calling into C/C++ routines via `BIND
+(C)` interfaces).  When composing the linker commandline, Flang uses
+`--whole-archive` and `--no-whole-archive` (Windows: `/WHOLEARCHIVE:`,
+Darwin: *not implemented yet*) to make sure that all for `Fortran_main` is
+processed by the linker.  This is done to issue a proper error message when
+multiple definitions of `main` occur.  This happens, for instance, when linking
+a code that has a Fortran program unit with a C/C++ code that also defines a
+`main` function.
+
+If the code is C/C++ based and invokes Fortran routines, either use Clang as 
the
+linker driver (supplying `FortranRuntime` and/or `FortranDecimal` to the linker

mjklemm wrote:

Yes.  Similar to what one would have to do if not using an MPI wrapper to 
compile an MPI program.  I'll make this is a bit clearer.

https://github.com/llvm/llvm-project/pull/75816
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-format] Support of TableGen formatting. (PR #76059)

2023-12-20 Thread via cfe-commits

https://github.com/hnakamura5 created 
https://github.com/llvm/llvm-project/pull/76059

Currently, TableGen has its language style but the it does not works well. This 
patch adds total support of TableGen formatting including the support for the 
code (multi line string), DAG args, bang operators, the cond operator, and the 
paste operators.

## Options

### TableGenAllowBreakBeforeInheritColon (Boolean)

Allows break before the colon of inheritance.

```
def Def
: Parent {};
```

By default this is false.

### TableGenAllowBreakAfterInheritColon (Boolean)

Allows break after the colon of inheritance.

```
def Def :
Parent {};
```

By default this is true.

### TableGenBreakInsideCondOperator (Boolean)

Insert the line break after each case of !cond operator.

```
  let CondOpe1 = !cond(!eq(size, 1): 1,
   !eq(size, 16): 1,
   true: 0);
```

By default this is true.

### TableGenBreakInsideDAGArgList (Boolean)

Insert the line break after each element of DAGArg list.

```
  let DAGArgIns = (ins
  i32:$src1,
  i32:$src2
  );
```

By default this is false.

### TableGenPreferBreakInsideSquareBracket (Boolean)

For whom likes such a style.

```
def Def : Parent<"Def",[
a, b, c
]> {
  ...
}
```

By default this is false.

### TableGenSpaceAroundDAGArgColon (Boolean)

Insert the space around the colon inside a DAGArg list.

```
  let DAGArgIns = (ins i32 : $src1, i32 : $src2);
```

By default this is false.

### TableGenBreakingDAGArgOperators (List of Strings)

Works only when TableGenBreakInsideDAGArgList is true.
The list needs to be consists of identifiers.
If any identifier is specified, this limits the effect of 
TableGenBreakInsideDAGArgList only on DAGArgs beginning with the specified 
identifiers.

For example the configuration,

```
TableGenBreakingDAGArgOperators: ['ins', 'outs']
```

makes the line break only occurs inside DAGArgs beginning with the specified 
identifiers 'ins' and 'outs'.

```
let DAGArgIns = (ins
i32:$src1,
i32:$src2
);

let DAGArgOthers = (others i32:$other1, i32:$other2);

let DAGArgBang = (!cast("Some") i32:$src1, i32:$src2)
```

### AlignConsecutiveTableGenCondOperatorColons

Supports AlignConsecutiveStyle configuration.
Align the colons inside !cond operators.

```
let CondOpe1 = !cond(!eq(size, 1) : 1,
 !eq(size, 16): 1,
 true : 0);
```

### AlignConsecutiveTableGenBreakingDAGArgColons

Supports AlignConsecutiveStyle configuration.
This works only when TableGenBreakInsideDAGArgList is true and the DAGArg is 
not excepted by TableGenBreakingDAGArgOperators's effect.
Align the colon inside DAGArg which have line break inside.

```
let dagarg = (ins
a  :$src1```
aa :$src2
aaa:$src3
)
```

### AlignConsecutiveTableGenDefinitions

Supports AlignConsecutiveStyle configuration.
This aligns the inherits colons of consecutive definitions.

```
def Def   : Parent {}
def DefDef: Parent {}
def DefDefDef : Parent {}
```


>From 562f79268e6af386ef923c70216c2781dcb47a29 Mon Sep 17 00:00:00 2001
From: hnakamura5 
Date: Fri, 3 Nov 2023 20:58:17 +0900
Subject: [PATCH] [clang-format] Support of TableGen formatting.

Currently, TableGen has its language style but the it does not works
well. This patch adds total support of TableGen formatting including
the support for the code (multi line string), DAG args, bang operators,
the cond operator, and the paste operators.
---
 clang/include/clang/Format/Format.h   |  47 ++
 clang/lib/Format/ContinuationIndenter.cpp |  18 +-
 clang/lib/Format/Format.cpp   |  29 ++
 clang/lib/Format/FormatToken.h|  98 
 clang/lib/Format/FormatTokenLexer.cpp | 141 ++
 clang/lib/Format/FormatTokenLexer.h   |   6 +
 clang/lib/Format/TokenAnnotator.cpp   | 436 +-
 clang/lib/Format/UnwrappedLineParser.cpp  |  56 ++-
 clang/lib/Format/WhitespaceManager.cpp|  31 +-
 clang/lib/Format/WhitespaceManager.h  |  14 +
 clang/unittests/Format/FormatTestTableGen.cpp | 307 
 clang/unittests/Format/TokenAnnotatorTest.cpp |  50 ++
 12 files changed, 1207 insertions(+), 26 deletions(-)

diff --git a/clang/include/clang/Format/Format.h 
b/clang/include/clang/Format/Format.h
index 8604dea689f937..30a38aed99866e 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -396,6 +396,36 @@ struct FormatStyle {
   /// \version 17
   ShortCaseStatementsAlignmentStyle AlignConsecutiveShortCaseStatements;
 
+  /// Style of aligning consecutive TableGen cond operator colons.
+  /// \code
+  ///   !cond(!eq(size, 1) : 1,
+  /// !eq(size, 16): 1,
+  /// true : 0)
+  /// \endcode
+  /// \version 18
+  AlignConsecutiveStyle AlignConsecutiveTableGenCondOperatorColons;
+
+  /// Style of aligning consecutive TableGen DAGArg operator colons.
+  /// Intended to be used with TableGenBreakInsid

[clang] [clang-format] Support of TableGen formatting. (PR #76059)

2023-12-20 Thread via cfe-commits

github-actions[bot] wrote:

Thank you for submitting a Pull Request (PR) to the LLVM Project!

This PR will be automatically labeled and the relevant teams will be
notified.

If you wish to, you can add reviewers by using the "Reviewers" section on this 
page.

If this is not working for you, it is probably because you do not have write
permissions for the repository. In which case you can instead tag reviewers by
name in a comment by using `@` followed by their GitHub username.

If you have received no comments on your PR for a week, you can request a review
by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate
is once a week. Please remember that you are asking for valuable time from 
other developers.

If you have further questions, they may be answered by the [LLVM GitHub User 
Guide](https://llvm.org/docs/GitHub.html).

You can also ask questions in a comment on this PR, on the [LLVM 
Discord](https://discord.com/invite/xS7Z362) or on the 
[forums](https://discourse.llvm.org/).

https://github.com/llvm/llvm-project/pull/76059
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-format] Support of TableGen formatting. (PR #76059)

2023-12-20 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-format

Author: H.Nakamura (hnakamura5)


Changes

Currently, TableGen has its language style but the it does not works well. This 
patch adds total support of TableGen formatting including the support for the 
code (multi line string), DAG args, bang operators, the cond operator, and the 
paste operators.

## Options

### TableGenAllowBreakBeforeInheritColon (Boolean)

Allows break before the colon of inheritance.

```
def Def
: Parent {};
```

By default this is false.

### TableGenAllowBreakAfterInheritColon (Boolean)

Allows break after the colon of inheritance.

```
def Def :
Parent {};
```

By default this is true.

### TableGenBreakInsideCondOperator (Boolean)

Insert the line break after each case of !cond operator.

```
  let CondOpe1 = !cond(!eq(size, 1): 1,
   !eq(size, 16): 1,
   true: 0);
```

By default this is true.

### TableGenBreakInsideDAGArgList (Boolean)

Insert the line break after each element of DAGArg list.

```
  let DAGArgIns = (ins
  i32:$src1,
  i32:$src2
  );
```

By default this is false.

### TableGenPreferBreakInsideSquareBracket (Boolean)

For whom likes such a style.

```
def Def : Parent<"Def",[
a, b, c
]> {
  ...
}
```

By default this is false.

### TableGenSpaceAroundDAGArgColon (Boolean)

Insert the space around the colon inside a DAGArg list.

```
  let DAGArgIns = (ins i32 : $src1, i32 : $src2);
```

By default this is false.

### TableGenBreakingDAGArgOperators (List of Strings)

Works only when TableGenBreakInsideDAGArgList is true.
The list needs to be consists of identifiers.
If any identifier is specified, this limits the effect of 
TableGenBreakInsideDAGArgList only on DAGArgs beginning with the specified 
identifiers.

For example the configuration,

```
TableGenBreakingDAGArgOperators: ['ins', 'outs']
```

makes the line break only occurs inside DAGArgs beginning with the specified 
identifiers 'ins' and 'outs'.

```
let DAGArgIns = (ins
i32:$src1,
i32:$src2
);

let DAGArgOthers = (others i32:$other1, i32:$other2);

let DAGArgBang = (!cast("Some") i32:$src1, i32:$src2)
```

### AlignConsecutiveTableGenCondOperatorColons

Supports AlignConsecutiveStyle configuration.
Align the colons inside !cond operators.

```
let CondOpe1 = !cond(!eq(size, 1) : 1,
 !eq(size, 16): 1,
 true : 0);
```

### AlignConsecutiveTableGenBreakingDAGArgColons

Supports AlignConsecutiveStyle configuration.
This works only when TableGenBreakInsideDAGArgList is true and the DAGArg is 
not excepted by TableGenBreakingDAGArgOperators's effect.
Align the colon inside DAGArg which have line break inside.

```
let dagarg = (ins
a  :$src1```
aa :$src2
aaa:$src3
)
```

### AlignConsecutiveTableGenDefinitions

Supports AlignConsecutiveStyle configuration.
This aligns the inherits colons of consecutive definitions.

```
def Def   : Parent {}
def DefDef: Parent {}
def DefDefDef : Parent {}
```


---

Patch is 68.04 KiB, truncated to 20.00 KiB below, full version: 
https://github.com/llvm/llvm-project/pull/76059.diff


12 Files Affected:

- (modified) clang/include/clang/Format/Format.h (+47) 
- (modified) clang/lib/Format/ContinuationIndenter.cpp (+16-2) 
- (modified) clang/lib/Format/Format.cpp (+29) 
- (modified) clang/lib/Format/FormatToken.h (+98) 
- (modified) clang/lib/Format/FormatTokenLexer.cpp (+141) 
- (modified) clang/lib/Format/FormatTokenLexer.h (+6) 
- (modified) clang/lib/Format/TokenAnnotator.cpp (+432-4) 
- (modified) clang/lib/Format/UnwrappedLineParser.cpp (+40-16) 
- (modified) clang/lib/Format/WhitespaceManager.cpp (+27-4) 
- (modified) clang/lib/Format/WhitespaceManager.h (+14) 
- (modified) clang/unittests/Format/FormatTestTableGen.cpp (+307) 
- (modified) clang/unittests/Format/TokenAnnotatorTest.cpp (+50) 


``diff
diff --git a/clang/include/clang/Format/Format.h 
b/clang/include/clang/Format/Format.h
index 8604dea689f937..30a38aed99866e 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -396,6 +396,36 @@ struct FormatStyle {
   /// \version 17
   ShortCaseStatementsAlignmentStyle AlignConsecutiveShortCaseStatements;
 
+  /// Style of aligning consecutive TableGen cond operator colons.
+  /// \code
+  ///   !cond(!eq(size, 1) : 1,
+  /// !eq(size, 16): 1,
+  /// true : 0)
+  /// \endcode
+  /// \version 18
+  AlignConsecutiveStyle AlignConsecutiveTableGenCondOperatorColons;
+
+  /// Style of aligning consecutive TableGen DAGArg operator colons.
+  /// Intended to be used with TableGenBreakInsideDAGArgList
+  /// \code
+  ///   let dagarg = (ins
+  ///   a  :$src1,
+  ///   aa :$src2,
+  ///   aaa:$src3
+  ///   )
+  /// \endcode
+  /// \version 18
+  AlignConsecutiveStyle AlignConsecutiveTableGenBreakingDAGArgColons;
+
+  /// Style of aligning consecutive TableGen def colons.
+  /// \code
+  ///  

[clang] [Clang][SME] Add IsStreamingOrSVE2p1 (PR #75958)

2023-12-20 Thread Sam Tebbs via cfe-commits


@@ -679,6 +679,7 @@ bool AArch64TargetInfo::hasFeature(StringRef Feature) const 
{
   .Case("f32mm", FPU & SveMode && HasMatmulFP32)
   .Case("f64mm", FPU & SveMode && HasMatmulFP64)
   .Case("sve2", FPU & SveMode && HasSVE2)
+  .Case("sve2p1", HasSVE2p1)

SamTebbs33 wrote:

Yep, you're right. I've removed these changes now.

https://github.com/llvm/llvm-project/pull/75958
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][SME] Add IsStreamingOrSVE2p1 (PR #75958)

2023-12-20 Thread Sam Tebbs via cfe-commits


@@ -8,7 +8,7 @@
 // RUN: %clang_cc1 -fclang-abi-compat=latest -DSVE_OVERLOADED_FORMS -triple 
aarch64-none-linux-gnu -target-feature +sve2p1 -S -disable-O0-optnone -Werror 
-Wall -emit-llvm -o - %s | opt -S -p mem2reg,instcombine,tailcallelim | 
FileCheck %s
 // RUN: %clang_cc1 -fclang-abi-compat=latest -DSVE_OVERLOADED_FORMS -triple 
aarch64-none-linux-gnu -target-feature +sve2p1 -S -disable-O0-optnone -Werror 
-Wall -emit-llvm -o - -x c++ %s | opt -S -p mem2reg,instcombine,tailcallelim | 
FileCheck %s -check-prefix=CPP-CHECK
 // RUN: %clang_cc1 -fclang-abi-compat=latest -triple aarch64-none-linux-gnu 
-target-feature +sve2p1 -target-feature -S -disable-O0-optnone -Werror -Wall -o 
/dev/null %s
-// RUN: %clang_cc1 -fclang-abi-compat=latest -triple aarch64-none-linux-gnu 
-target-feature +sme2 -target-feature +sve -target-feature -S -DTEST_SME2 
-disable-O0-optnone -Werror -Wall -o /dev/null %s
+// RUN: %clang_cc1 -fclang-abi-compat=latest -triple aarch64-none-linux-gnu 
-target-feature +sme2 -target-feature -S -DTEST_SME2 -disable-O0-optnone 
-Werror -Wall -o /dev/null %s

SamTebbs33 wrote:

Removed, thanks!

https://github.com/llvm/llvm-project/pull/75958
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][ASTImporter] Support Importer of BuiltinBitCastExpr (PR #74813)

2023-12-20 Thread Balázs Kéri via cfe-commits

https://github.com/balazske approved this pull request.


https://github.com/llvm/llvm-project/pull/74813
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][SME] Add IsStreamingOrSVE2p1 (PR #75958)

2023-12-20 Thread Kerry McLaughlin via cfe-commits


@@ -11,10 +11,16 @@
 // RUN: %clang_cc1 -fclang-abi-compat=latest -triple aarch64-none-linux-gnu 
-target-feature +sve2p1 \
 // RUN:   -S -disable-O0-optnone -Werror -Wall -o /dev/null %s
 // RUN: %clang_cc1 -fclang-abi-compat=latest -triple aarch64-none-linux-gnu 
-target-feature +sme2 -target-feature +sve \
-// RUN:   -S -disable-O0-optnone -Werror -Wall -o /dev/null %s
+// RUN:   -S -DTEST_SME2 -disable-O0-optnone -Werror -Wall -o /dev/null %s
 
 #include 
 
+#ifndef TEST_SME2
+#define ATTR
+#else
+#define ATTR __arm_streaming

kmclaughlin-arm wrote:

I think this should be __arm_streaming_compatible?

https://github.com/llvm/llvm-project/pull/75958
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-format] Support of TableGen formatting. (PR #76059)

2023-12-20 Thread via cfe-commits

hnakamura5 wrote:

The failure in Check code formatting seems to be caused by the commit 
(replacing to clang-format style)
https://github.com/llvm/llvm-project/commit/5c60e2ce78e79c2d15152e08d9e28fcf3a1d4e51

I avoid this by using clang-format binary from main branch in my local.
What should I do with this failure?

https://github.com/llvm/llvm-project/pull/76059
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][dataflow] Add `Environment::get<>()`. (PR #76027)

2023-12-20 Thread Yitzhak Mandelbaum via cfe-commits

https://github.com/ymand edited https://github.com/llvm/llvm-project/pull/76027
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][dataflow] Add `Environment::get<>()`. (PR #76027)

2023-12-20 Thread Yitzhak Mandelbaum via cfe-commits

https://github.com/ymand approved this pull request.


https://github.com/llvm/llvm-project/pull/76027
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


  1   2   3   >