[clang] [clang] AST Visitor: skip empty qualifiers in QualifiedTemplateName (PR #93926)

2024-05-31 Thread Matheus Izvekov via cfe-commits

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


[clang] [llvm] [clang] Introduce target-specific `Sema` components (PR #93179)

2024-05-31 Thread Nikita Popov via cfe-commits

nikic wrote:

> I wonder if compile-time regressions come from new translation units I add, 
> because they definitely include stuff.

Yes, I believe that is the primary contributor. You can see the per-file 
breakdown here: 
https://llvm-compile-time-tracker.com/compare_clang.php?from=59e2a6b08f3e40afea87da3838ba69e1e15b6672&to=8aa80199751b0cd6631d057b0bfb21584acb206f&stat=instructions%3Au&sortBy=absolute-difference

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


[clang-tools-extra] [IncludeCleaner] display overview (PR #93932)

2024-05-31 Thread via cfe-commits

https://github.com/TheHillBright created 
https://github.com/llvm/llvm-project/pull/93932

Overview was written but not displayed. This fixes it.

>From 4c97edfc73754bdcafeeecf09e8c60c6086393f5 Mon Sep 17 00:00:00 2001
From: TheHillBright <150074496+thehillbri...@users.noreply.github.com>
Date: Fri, 31 May 2024 15:00:37 +0800
Subject: [PATCH] IncludeCleaner: display overview

---
 clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp 
b/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp
index 3bc449b0152bb..788ad87b1d4e8 100644
--- a/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp
+++ b/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp
@@ -279,7 +279,7 @@ int main(int argc, const char **argv) {
 
   llvm::sys::PrintStackTraceOnErrorSignal(argv[0]);
   auto OptionsParser =
-  clang::tooling::CommonOptionsParser::create(argc, argv, IncludeCleaner);
+  clang::tooling::CommonOptionsParser::create(argc, argv, IncludeCleaner, 
cl::OneOrMore, Overview);
   if (!OptionsParser) {
 llvm::errs() << toString(OptionsParser.takeError());
 return 1;

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


[clang-tools-extra] [IncludeCleaner] display overview (PR #93932)

2024-05-31 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/93932
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [IncludeCleaner] display overview (PR #93932)

2024-05-31 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-tools-extra

Author: None (TheHillBright)


Changes

Overview was written but not displayed. This fixes it.

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


1 Files Affected:

- (modified) clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp (+1-1) 


``diff
diff --git a/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp 
b/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp
index 3bc449b0152bb..788ad87b1d4e8 100644
--- a/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp
+++ b/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp
@@ -279,7 +279,7 @@ int main(int argc, const char **argv) {
 
   llvm::sys::PrintStackTraceOnErrorSignal(argv[0]);
   auto OptionsParser =
-  clang::tooling::CommonOptionsParser::create(argc, argv, IncludeCleaner);
+  clang::tooling::CommonOptionsParser::create(argc, argv, IncludeCleaner, 
cl::OneOrMore, Overview);
   if (!OptionsParser) {
 llvm::errs() << toString(OptionsParser.takeError());
 return 1;

``




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


[clang] [llvm] AMDGPU: Add gfx12-generic target (PR #93875)

2024-05-31 Thread Pierre van Houtryve via cfe-commits

https://github.com/Pierre-vh approved this pull request.


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


[clang] e1cc9e4 - [ConstantFold] Remove non-trivial gep-of-gep fold (#93823)

2024-05-31 Thread via cfe-commits

Author: Nikita Popov
Date: 2024-05-31T09:25:38+02:00
New Revision: e1cc9e4eaddcc295b4e775512e33b947b1514c17

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

LOG: [ConstantFold] Remove non-trivial gep-of-gep fold (#93823)

This fold is subtly incorrect, because DL-unaware constant folding does
not know the correct index type to use, and just performs the addition
in the type that happens to already be there. This is incorrect, since
sext(X)+sext(Y) is generally not the same as sext(X+Y). See the
`@constexpr_gep_of_gep_with_narrow_type()` for a miscompile with the
current implementation.

One could try to restrict the fold to cases where no overflow occurs,
but I'm not bothering with that here, because the DL-aware constant
folding will take care of this anyway. I've only kept the
straightforward zero-index case, where we just concatenate two GEPs.

Added: 


Modified: 
clang/test/CodeGenCXX/2011-12-19-init-list-ctor.cpp
clang/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist-pr12086.cpp
clang/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist.cpp
clang/test/OpenMP/threadprivate_codegen.cpp
llvm/lib/IR/ConstantFold.cpp
llvm/test/Other/constant-fold-gep.ll
llvm/test/Transforms/InstCombine/gepgep.ll
llvm/test/Transforms/InstCombine/getelementptr.ll
llvm/test/Transforms/InstCombine/ptrtoint-nullgep.ll

Removed: 




diff  --git a/clang/test/CodeGenCXX/2011-12-19-init-list-ctor.cpp 
b/clang/test/CodeGenCXX/2011-12-19-init-list-ctor.cpp
index 4033adc8f0390..e198cb7132ca4 100644
--- a/clang/test/CodeGenCXX/2011-12-19-init-list-ctor.cpp
+++ b/clang/test/CodeGenCXX/2011-12-19-init-list-ctor.cpp
@@ -22,5 +22,5 @@ struct S {
 // CHECK: call void @_ZN1AC1EPKc(ptr {{[^,]*}} getelementptr inbounds 
(%struct.S, ptr @arr, i32 0, i32 1), ptr noundef @.str)
 // CHECK: store i32 1, ptr getelementptr inbounds (%struct.S, ptr @arr, i64 1)
 // CHECK: call void @_ZN1AC1EPKc(ptr {{[^,]*}} getelementptr inbounds 
(%struct.S, ptr @arr, i64 1, i32 1), ptr noundef @.str.1)
-// CHECK: store i32 2, ptr getelementptr inbounds (%struct.S, ptr @arr, i64 2)
-// CHECK: call void @_ZN1AC1EPKc(ptr {{[^,]*}} getelementptr inbounds 
(%struct.S, ptr @arr, i64 2, i32 1), ptr noundef @.str.2)
+// CHECK: store i32 2, ptr getelementptr inbounds (%struct.S, ptr 
getelementptr inbounds (%struct.S, ptr @arr, i64 1), i64 1)
+// CHECK: call void @_ZN1AC1EPKc(ptr {{[^,]*}} getelementptr inbounds 
(%struct.S, ptr getelementptr inbounds (%struct.S, ptr @arr, i64 1), i64 1, i32 
1), ptr noundef @.str.2)

diff  --git 
a/clang/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist-pr12086.cpp 
b/clang/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist-pr12086.cpp
index 6fbe4c7fd17a7..4f4c88d9e96a5 100644
--- a/clang/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist-pr12086.cpp
+++ b/clang/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist-pr12086.cpp
@@ -83,8 +83,8 @@ std::initializer_list> nested = {
 // CHECK-DYNAMIC-BL: store i32 5, ptr @_ZGR6nested2_
 // CHECK-DYNAMIC-BL: store i32 {{.*}}, ptr getelementptr inbounds (i32, ptr 
@_ZGR6nested2_, i64 1)
 // CHECK-DYNAMIC-BL: store ptr @_ZGR6nested2_,
-// CHECK-DYNAMIC-BL:   ptr getelementptr inbounds ({{.*}}, ptr 
@_ZGR6nested_, i64 2), align 8
-// CHECK-DYNAMIC-BL: store i64 2, ptr getelementptr inbounds ({{.*}}, ptr 
@_ZGR6nested_, i64 2, i32 1), align 8
+// CHECK-DYNAMIC-BL:   ptr getelementptr inbounds ({{.*}}, ptr 
getelementptr inbounds ({{.*}}, ptr @_ZGR6nested_, i64 1), i64 1), align 8
+// CHECK-DYNAMIC-BL: store i64 2, ptr getelementptr inbounds ({{.*}}, ptr 
getelementptr inbounds ({{.*}}, ptr @_ZGR6nested_, i64 1), i64 1, i32 1), align 
8
 // CHECK-DYNAMIC-BL: store ptr @_ZGR6nested_,
 // CHECK-DYNAMIC-BL:   ptr @nested, align 8
 // CHECK-DYNAMIC-BL: store i64 3, ptr getelementptr inbounds ({{.*}}, ptr 
@nested, i32 0, i32 1), align 8
@@ -123,9 +123,9 @@ std::initializer_list> nested = {
 // CHECK-DYNAMIC-BE: store i32 5, ptr @_ZGR6nested2_
 // CHECK-DYNAMIC-BE: store i32 {{.*}}, ptr getelementptr inbounds (i32, ptr 
@_ZGR6nested2_, i64 1)
 // CHECK-DYNAMIC-BE: store ptr @_ZGR6nested2_,
-// CHECK-DYNAMIC-BE:   ptr getelementptr inbounds ({{.*}}, ptr 
@_ZGR6nested_, i64 2), align 8
+// CHECK-DYNAMIC-BE:   ptr getelementptr inbounds ({{.*}}, ptr 
getelementptr inbounds ({{.*}}, ptr @_ZGR6nested_, i64 1), i64 1), align 8
 // CHECK-DYNAMIC-BE: store ptr getelementptr inbounds ([2 x i32], ptr 
@_ZGR6nested2_, i64 0, i64 2),
-// CHECK-DYNAMIC-BE:   ptr getelementptr inbounds ({{.*}}, ptr 
@_ZGR6nested_, i64 2, i32 1), align 8
+// CHECK-DYNAMIC-BE:   ptr getelementptr inbounds ({{.*}}, ptr 
getelementptr inbounds ({{.*}}, ptr @_ZGR6nested_, i64 1), i64 1, i32 1), align 
8
 // CHECK-DYNAMIC-BE: store ptr @_ZGR

[clang] [llvm] [ConstantFold] Remove non-trivial gep-of-gep fold (PR #93823)

2024-05-31 Thread Nikita Popov via cfe-commits

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


[clang] [clang] AST Visitor: skip empty qualifiers in QualifiedTemplateName (PR #93926)

2024-05-31 Thread Matheus Izvekov via cfe-commits


@@ -855,10 +855,14 @@ bool 
RecursiveASTVisitor::TraverseDeclarationNameInfo(
 
 template 
 bool RecursiveASTVisitor::TraverseTemplateName(TemplateName Template) 
{
-  if (DependentTemplateName *DTN = Template.getAsDependentTemplateName())
+  if (DependentTemplateName *DTN = Template.getAsDependentTemplateName()) {
 TRY_TO(TraverseNestedNameSpecifier(DTN->getQualifier()));
-  else if (QualifiedTemplateName *QTN = Template.getAsQualifiedTemplateName())
-TRY_TO(TraverseNestedNameSpecifier(QTN->getQualifier()));
+  } else if (QualifiedTemplateName *QTN =
+ Template.getAsQualifiedTemplateName()) {
+if (QTN->getQualifier()) {
+  TRY_TO(TraverseNestedNameSpecifier(QTN->getQualifier()));
+}
+  }

mizvekov wrote:

I am going to merge since this fixes broken build bot.

Let's continue in post.

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


[clang] be566d2 - [clang] AST Visitor: skip empty qualifiers in QualifiedTemplateName (#93926)

2024-05-31 Thread via cfe-commits

Author: Matheus Izvekov
Date: 2024-05-31T04:31:31-03:00
New Revision: be566d2eacdaed972b90d2eeb1e66d732c9fe7c1

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

LOG: [clang] AST Visitor: skip empty qualifiers in QualifiedTemplateName 
(#93926)

Added: 


Modified: 
clang/include/clang/AST/RecursiveASTVisitor.h

Removed: 




diff  --git a/clang/include/clang/AST/RecursiveASTVisitor.h 
b/clang/include/clang/AST/RecursiveASTVisitor.h
index 4bbb4380cdd7f..99093aa17972c 100644
--- a/clang/include/clang/AST/RecursiveASTVisitor.h
+++ b/clang/include/clang/AST/RecursiveASTVisitor.h
@@ -855,10 +855,14 @@ bool 
RecursiveASTVisitor::TraverseDeclarationNameInfo(
 
 template 
 bool RecursiveASTVisitor::TraverseTemplateName(TemplateName Template) 
{
-  if (DependentTemplateName *DTN = Template.getAsDependentTemplateName())
+  if (DependentTemplateName *DTN = Template.getAsDependentTemplateName()) {
 TRY_TO(TraverseNestedNameSpecifier(DTN->getQualifier()));
-  else if (QualifiedTemplateName *QTN = Template.getAsQualifiedTemplateName())
-TRY_TO(TraverseNestedNameSpecifier(QTN->getQualifier()));
+  } else if (QualifiedTemplateName *QTN =
+ Template.getAsQualifiedTemplateName()) {
+if (QTN->getQualifier()) {
+  TRY_TO(TraverseNestedNameSpecifier(QTN->getQualifier()));
+}
+  }
 
   return true;
 }



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


[clang] [clang] AST Visitor: skip empty qualifiers in QualifiedTemplateName (PR #93926)

2024-05-31 Thread Matheus Izvekov via cfe-commits

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


[clang] [X86]Add support for _outp{|w|d} (PR #93774)

2024-05-31 Thread Malay Sanghi via cfe-commits

https://github.com/MalaySanghi updated 
https://github.com/llvm/llvm-project/pull/93774

>From 17c3fc95c0753ec013b22ce0c539992b24b21055 Mon Sep 17 00:00:00 2001
From: Malay Sanghi 
Date: Wed, 29 May 2024 22:40:47 -0700
Subject: [PATCH 1/3] Add support for _outp{|w|d}

---
 clang/lib/Headers/intrin.h | 17 +++
 clang/test/CodeGen/X86/ms-x86-intrinsics.c | 25 +-
 2 files changed, 41 insertions(+), 1 deletion(-)

diff --git a/clang/lib/Headers/intrin.h b/clang/lib/Headers/intrin.h
index 1227f45d5432b..b9d10a6941271 100644
--- a/clang/lib/Headers/intrin.h
+++ b/clang/lib/Headers/intrin.h
@@ -348,6 +348,23 @@ static inline unsigned long _inpd(unsigned short port) {
   return ret;
 }
 
+static inline int _outp(unsigned short port, int data) {
+  __asm__ volatile("outb %b0, %w1" : : "a"(data), "Nd"(port) : "memory");
+  return data;
+}
+
+static inline unsigned short
+_outpw(unsigned short port, unsigned short data) {
+  __asm__ volatile("outw %w0, %w1" : : "a"(data), "Nd"(port) : "memory");
+  return data;
+}
+
+static inline unsigned long _outpd(unsigned short port,
+   unsigned long data) {
+  __asm__ volatile("outl %k0, %w1" : : "a"(data), "Nd"(port) : "memory");
+  return data;
+}
+
 #endif
 
 #if defined(__i386__) || defined(__x86_64__) || defined(__aarch64__)
diff --git a/clang/test/CodeGen/X86/ms-x86-intrinsics.c 
b/clang/test/CodeGen/X86/ms-x86-intrinsics.c
index 9566951b44d2d..79fa7028d8e05 100644
--- a/clang/test/CodeGen/X86/ms-x86-intrinsics.c
+++ b/clang/test/CodeGen/X86/ms-x86-intrinsics.c
@@ -63,7 +63,6 @@ unsigned __int64 test__emulu(unsigned int a, unsigned int b) {
 // CHECK: [[RES:%[0-9]+]] = mul nuw i64 [[Y]], [[X]]
 // CHECK: ret i64 [[RES]]
 
-
 int test_inp(unsigned short port) {
   return _inp(port);
 }
@@ -88,6 +87,30 @@ unsigned long test_inpd(unsigned short port) {
 // CHECK:   [[TMP0:%.*]] = tail call i32 asm sideeffect "inl ${1:w}, 
${0:k}", "={ax},N{dx},~{dirflag},~{fpsr},~{flags}"(i16 [[PORT]])
 // CHECK-NEXT:  ret i32 [[TMP0]]
 
+int test_outp(unsigned short port, int data) {
+return _outp(port, data);
+}
+// CHECK-LABEL: i32 @test_outp(
+// CHECK-SAME:  [[PORT:%.*]], i32 noundef returned [[DATA:%.*]])
+// CHECK-NEXT:  tail call void asm sideeffect "outb ${0:b}, ${1:w}", 
"{ax},N{dx},~{memory},~{dirflag},~{fpsr},~{flags}"(i32 [[DATA]], i16 [[PORT]]
+// CHECK-NEXT:  ret i32 [[DATA]]
+
+unsigned short test_outpw(unsigned short port, unsigned short data) {
+return _outpw(port, data);
+}
+// CHECK-LABEL: i16 @test_outpw(
+// CHECK-SAME:  [[PORT:%.*]], i16 noundef returned zeroext [[DATA:%.*]])
+// CHECK-NEXT:  tail call void asm sideeffect "outw ${0:w}, ${1:w}", 
"{ax},N{dx},~{memory},~{dirflag},~{fpsr},~{flags}"(i16 [[DATA]], i16 [[PORT]])
+// CHECK-NEXT:  ret i16 [[DATA]]
+
+unsigned long test_outpd(unsigned short port, unsigned long data) {
+return _outpd(port, data);
+}
+// CHECK-LABEL: i32 @test_outpd(
+// CHECK-SAME:  [[PORT:%.*]], i32 noundef returned [[DATA:%.*]])
+// CHECK-NEXT:  tail call void asm sideeffect "outl ${0:k}, ${1:w}", 
"{ax},N{dx},~{memory},~{dirflag},~{fpsr},~{flags}"(i32 [[DATA]], i16 [[PORT]])
+// CHECK-NEXT:  ret i32 [[DATA]]
+
 #if defined(__x86_64__)
 
 char test__readgsbyte(unsigned long Offset) {

>From f0f4675c6ef13655a089d78bada9f55bb9ce5123 Mon Sep 17 00:00:00 2001
From: Malay Sanghi 
Date: Thu, 30 May 2024 00:01:45 -0700
Subject: [PATCH 2/3] remove memory constraint and fix definition.

---
 clang/lib/Headers/intrin.h | 9 +++--
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/clang/lib/Headers/intrin.h b/clang/lib/Headers/intrin.h
index b9d10a6941271..92c7aa134c36d 100644
--- a/clang/lib/Headers/intrin.h
+++ b/clang/lib/Headers/intrin.h
@@ -349,25 +349,22 @@ static inline unsigned long _inpd(unsigned short port) {
 }
 
 static inline int _outp(unsigned short port, int data) {
-  __asm__ volatile("outb %b0, %w1" : : "a"(data), "Nd"(port) : "memory");
+  __asm__ volatile("outb %b0, %w1" : : "a"(data), "Nd"(port));
   return data;
 }
 
 static inline unsigned short
 _outpw(unsigned short port, unsigned short data) {
-  __asm__ volatile("outw %w0, %w1" : : "a"(data), "Nd"(port) : "memory");
+  __asm__ volatile("outw %w0, %w1" : : "a"(data), "Nd"(port));
   return data;
 }
 
 static inline unsigned long _outpd(unsigned short port,
unsigned long data) {
-  __asm__ volatile("outl %k0, %w1" : : "a"(data), "Nd"(port) : "memory");
+  __asm__ volatile("outl %k0, %w1" : : "a"(data), "Nd"(port));
   return data;
 }
 
-#endif
-
-#if defined(__i386__) || defined(__x86_64__) || defined(__aarch64__)
 static __inline__ void __DEFAULT_FN_ATTRS __nop(void) {
   __asm__ volatile("nop");
 }

>From 794872bf7fc0ccbe9f2842f8624803f199d1a72f Mon Sep 17 00:00:00 2001
From: Malay Sanghi 
Date: Fri, 31 May 2024 01:06:11 -0700
Subject: [PATCH 3/3] merge checks

---
 clang/lib/Headers/intrin.h |  8 
 clang/test

[clang] [llvm] [AArch64] Support preserve_none calling convention (PR #91046)

2024-05-31 Thread Daniel Kiss via cfe-commits

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

Thanks for the PR, just NITS otherwise LGTM

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


[clang] [llvm] [AArch64] Support preserve_none calling convention (PR #91046)

2024-05-31 Thread Daniel Kiss via cfe-commits


@@ -7949,9 +7966,10 @@ AArch64TargetLowering::LowerCall(CallLoweringInfo &CLI,
   ++NumTailCalls;
   }
 
-  if (!IsTailCall && CLI.CB && CLI.CB->isMustTailCall())
+  if (!IsTailCall && CLI.CB && CLI.CB->isMustTailCall()) {

DanielKristofKiss wrote:

if with 1 statement doesn't need braces.

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


[clang] [llvm] [AArch64] Support preserve_none calling convention (PR #91046)

2024-05-31 Thread Daniel Kiss via cfe-commits


@@ -494,6 +494,32 @@ def CC_AArch64_GHC : CallingConv<[
   CCIfType<[i64], CCAssignToReg<[X19, X20, X21, X22, X23, X24, X25, X26, X27, 
X28]>>
 ]>;
 
+let Entry = 1 in
+def CC_AArch64_Preserve_None : CallingConv<[
+// We can pass arguments in all general registers, except:
+// - X8, used for sret
+// - X16/X17, used by the linker as IP0/IP1
+// - X18, used for the 'nest' parameter

DanielKristofKiss wrote:

X18 is the `Platform Register`

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


[clang] [llvm] [AArch64] Support preserve_none calling convention (PR #91046)

2024-05-31 Thread Daniel Kiss via cfe-commits

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


[clang] [llvm] [AArch64] Support preserve_none calling convention (PR #91046)

2024-05-31 Thread Daniel Kiss via cfe-commits


@@ -0,0 +1,92 @@
+; RUN: sed -e "s/RETTYPE/void/;s/RETVAL//" %s | llc 
-mtriple=aarch64-apple-darwin | FileCheck --check-prefixes=ALL %s
+; RUN: sed -e "s/RETTYPE/i32/;s/RETVAL/undef/" %s | llc 
-mtriple=aarch64-apple-darwin | FileCheck --check-prefixes=ALL %s
+; RUN: sed -e "s/RETTYPE/\{i64\,i64\}/;s/RETVAL/undef/" %s | llc 
-mtriple=aarch64-apple-darwin | FileCheck --check-prefixes=ALL %s
+; RUN: sed -e "s/RETTYPE/double/;s/RETVAL/0./" %s | llc 
-mtriple=aarch64-apple-darwin | FileCheck --check-prefixes=ALL,DOUBLE %s
+
+; We don't need to save registers before using them inside preserve_none 
function.
+define preserve_nonecc RETTYPE @preserve_nonecc1(i64, i64, double, double) 
nounwind {
+entry:
+;ALL-LABEL:   preserve_nonecc1
+;ALL: ; %bb.0:
+;ALL-NEXT:InlineAsm Start
+;ALL-NEXT:InlineAsm End
+;DOUBLE-NEXT: movi d0, #
+;ALL-NEXT:ret
+  call void asm sideeffect "", 
"~{x0},~{x1},~{x2},~{x3},~{x4},~{x5},~{x6},~{x7},~{x8},~{x9},~{x10},~{x11},~{x12},~{x13},~{x14},~{x15},~{x16},~{x17},~{x19},~{x20},~{x21},~{x22},~{x23},~{x24},~{x25},~{x26},~{x27},~{x28},~{d0},~{d1},~{d2},~{d3},~{d4},~{d5},~{d6},~{d7},~{d8},~{d9},~{d10},~{d11},~{d12},~{d13},~{d14},~{d15},~{d16}"()
+  ret RETTYPE RETVAL
+}
+
+; When calling a preserve_none function, all live registers must be saved and
+; restored around the function call.
+declare preserve_nonecc RETTYPE @bar(i64, i64, double, double)

DanielKristofKiss wrote:

NIT: maybe easier to follow like:

```suggestion
declare preserve_nonecc RETTYPE @preserve_nonecc2(i64, i64, double, double)
define void @bar() nounwind {
```

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


[clang] [clang][analyzer][NFC] Improve docs of alpha.unix.BlockInCriticalSection (PR #93812)

2024-05-31 Thread Endre Fülöp via cfe-commits

gamesh411 wrote:

> What's the relationship between this PR and #93799 ?
> 
> Otherwise, the change LGTM, but you might want to either unify these two NFC 
> changes into a single commit or ensure that they're independent.

Thanks for checking this!
To be honest, I started working on this, and then it hit me that a test case 
for the limitation would be nice 😸 
My intention was to ease the review as much as possible by cutting them into 
atomic parts.
They could indeed be independent; I will leave the limitation out of this and 
just introduce it in the other patch.


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


[clang] [clang][analyzer][NFC] Add test for a limitation of alpha.unix.Bloc… (PR #93799)

2024-05-31 Thread Endre Fülöp via cfe-commits

gamesh411 wrote:

> It's good to document this, the commit LGTM. Are you planning to fix this 
> soon?

I have been looking into the 
[alpha.unix.PthreadLock](https://clang.llvm.org/docs/analyzer/checkers.html#alpha-unix-pthreadlock-c)
 checker. By reusing the logic there 
https://github.com/llvm/llvm-project/blob/b86a9c5bf2fab0408a3d549995d6e2449f71a16d/clang/lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp#L454-L472
 that detects whether a lock has indeed been locked or not, we also get rid of 
this limitation "for free" (Aside from the fact that we have to unify the 
implementations because there is enough effective code duplication across these 
checkers as currently stands, but this is the way forward IMO, and I'm 
currently working on this).

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


[clang] [clang][analyzer][NFC] Improve docs of alpha.unix.BlockInCriticalSection (PR #93812)

2024-05-31 Thread Endre Fülöp via cfe-commits

https://github.com/gamesh411 updated 
https://github.com/llvm/llvm-project/pull/93812

From 54f117258b936b9448e2fb93dc2307e23629b85d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Endre=20F=C3=BCl=C3=B6p?= 
Date: Tue, 28 May 2024 23:13:07 +0200
Subject: [PATCH] [clang][analyzer][NFC] Improve docs of
 alpha.unix.BlockInCriticalSection

- Enhanced descriptions for blocking and critical section functions
- Added an additional code sample highlighting interleaved C and C++
style mutexes
---
 clang/docs/analyzer/checkers.rst | 25 +
 1 file changed, 17 insertions(+), 8 deletions(-)

diff --git a/clang/docs/analyzer/checkers.rst b/clang/docs/analyzer/checkers.rst
index 3a31708a1e9de..3881ceceeed6b 100644
--- a/clang/docs/analyzer/checkers.rst
+++ b/clang/docs/analyzer/checkers.rst
@@ -3135,17 +3135,26 @@ alpha.unix
 alpha.unix.BlockInCriticalSection (C)
 "
 Check for calls to blocking functions inside a critical section.
-Applies to: ``lock, unlock, sleep, getc, fgets, read, recv, 
pthread_mutex_lock,``
-`` pthread_mutex_unlock, mtx_lock, mtx_timedlock, mtx_trylock, mtx_unlock, 
lock_guard, unique_lock``
+Blocking functions detected by this checker: ``sleep, getc, fgets, read, 
recv``.
+Critical section handling functions modelled by this checker: ``lock, unlock, 
pthread_mutex_lock, pthread_mutex_trylock, pthread_mutex_unlock, mtx_lock, 
mtx_timedlock, mtx_trylock, mtx_unlock, lock_guard, unique_lock``.
 
 .. code-block:: c
 
- void test() {
-   std::mutex m;
-   m.lock();
-   sleep(3); // warn: a blocking function sleep is called inside a critical
- //   section
-   m.unlock();
+ void pthread_lock_example(pthread_mutex_t *m) {
+   pthread_mutex_lock(m); // note: entering critical section here
+   sleep(10); // warn: Call to blocking function 'sleep' inside of critical 
section
+   pthread_mutex_unlock(m);
+ }
+
+.. code-block:: cpp
+
+ void overlapping_critical_sections(mtx_t *m1, std::mutex &m2) {
+   std::lock_guard lg{m2}; // note: entering critical section here
+   mtx_lock(m1); // note: entering critical section here
+   sleep(10); // warn: Call to blocking function 'sleep' inside of critical 
section
+   mtx_unlock(m1);
+   sleep(10); // warn: Call to blocking function 'sleep' inside of critical 
section
+ // still inside of the critical section of the std::lock_guard
  }
 
 .. _alpha-unix-Chroot:

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


[clang] [Clang] Implement P3034R1 Module Declarations Shouldn’t be Macros (PR #90574)

2024-05-31 Thread via cfe-commits


@@ -1329,6 +1341,100 @@ bool Preprocessor::LexAfterModuleImport(Token &Result) {
   return true;
 }
 
+/// Lex a token following the 'module' contextual keyword.
+///
+/// [cpp.module]/p2:
+/// The pp-tokens, if any, of a pp-module shall be of the form:
+///   pp-module-name pp-module-partition[opt] pp-tokens[opt]
+///
+/// where the pp-tokens (if any) shall not begin with a ( preprocessing token
+/// and the grammar non-terminals are defined as:
+///   pp-module-name:
+/// pp-module-name-qualifierp[opt] identifier
+///   pp-module-partition:
+/// : pp-module-name-qualifier[opt] identifier
+///   pp-module-name-qualifier:
+/// identifier .
+/// pp-module-name-qualifier identifier .
+/// No identifier in the pp-module-name or pp-module-partition shall currently
+/// be defined as an object-like macro.
+///
+/// [cpp.module]/p3:
+/// Any preprocessing tokens after the module preprocessing token in the module
+/// directive are processed just as in normal text.
+bool Preprocessor::LexAfterModuleDecl(Token &Result) {
+  // Figure out what kind of lexer we actually have.
+  recomputeCurLexerKind();
+  LexUnexpandedToken(Result);
+
+  auto EnterTokens = [this](ArrayRef Toks, bool DisableMacroExpansion) {
+auto ToksCopy = std::make_unique(Toks.size());
+std::copy(Toks.begin(), Toks.end(), ToksCopy.get());
+EnterTokenStream(std::move(ToksCopy), Toks.size(), DisableMacroExpansion,
+ /*IsReinject=*/false);
+  };
+
+  // If we don't expect an identifier but got an identifier, it's not a part of
+  // module name.
+  if (!ModuleDeclExpectsIdentifier && Result.is(tok::identifier)) {
+EnterTokens(Result, /*DisableMacroExpansion=*/false);
+return false;
+  }
+
+  // The token sequence
+  //
+  // export[opt] module identifier (. identifier)*
+  //
+  // indicates a module directive. We already saw the 'module'
+  // contextual keyword, so now we're looking for the identifiers.
+  if (ModuleDeclExpectsIdentifier && Result.is(tok::identifier)) {
+auto *MI = getMacroInfo(Result.getIdentifierInfo());
+if (MI && MI->isObjectLike()) {
+  Diag(Result, diag::err_module_decl_cannot_be_macros)
+  << Result.getLocation() << ModuleDeclLexingPartitionName
+  << Result.getIdentifierInfo();
+}
+ModuleDeclExpectsIdentifier = false;
+CurLexerCallback = CLK_LexAfterModuleDecl;
+return true;
+  }
+
+  // If we're expecting a '.', a ':' or a ';', and we got a '.', then wait 
until
+  // we see the next identifier.
+  if (!ModuleDeclExpectsIdentifier && Result.isOneOf(tok::period, tok::colon)) 
{
+ModuleDeclExpectsIdentifier = true;
+ModuleDeclLexingPartitionName = Result.is(tok::colon);
+CurLexerCallback = CLK_LexAfterModuleDecl;
+return true;
+  }
+
+  // [cpp.module]/p2: where the pp-tokens (if any) shall not begin with a (
+  // preprocessing token [...]
+  if (!ModuleDeclExpectsIdentifier && Result.is(tok::l_paren)) {
+ModuleDeclExpectsIdentifier = false;
+Diag(Result, diag::err_unxepected_paren_in_module_decl)
+<< ModuleDeclLexingPartitionName;
+Token Tok;
+// We already have a '('.
+unsigned NumParens = 1;
+while (true) {
+  LexUnexpandedToken(Tok);
+  if (Tok.isOneOf(tok::eod, tok::eof, tok::semi, tok::period, tok::colon)) 
{
+EnterTokens(Tok, /*DisableMacroExpansion=*/true);
+break;
+  }
+  if (Tok.is(tok::l_paren))
+NumParens++;
+  else if (Tok.is(tok::r_paren) && --NumParens == 0)
+break;
+}
+CurLexerCallback = CLK_LexAfterModuleDecl;
+return false;
+  }
+
+  return true;
+}
+

cor3ntin wrote:

> We try to consume all module name tokens and return a token::cxx_module_name, 
> which includes {‘a’, ‘.’, ‘FUNC_LIKE’, ‘.’, ‘:’, ‘c’}, and we also will 
> consumed and stop at ‘ATTRS’, but it’s not a part of module name, and need to 
> be put back to token stream. Current a Lex action cannot both return a token 
> and cache tokens (doing so would corrupt the token cache if the call to Lex 
> comes from CachingLex / PeekAhead).

I've been thinking about that.
I think _both_ the annotation and the peeked token need to be re-entered
and then you can call PP.Lex(Result) again and return.

Is that something you would be willing to explore?

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


[clang] [clang][analyzer][NFC] Improve docs of alpha.unix.BlockInCriticalSection (PR #93812)

2024-05-31 Thread Endre Fülöp via cfe-commits

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


[clang] 51e459a - Revert "[ConstantFold] Remove non-trivial gep-of-gep fold (#93823)"

2024-05-31 Thread Nikita Popov via cfe-commits

Author: Nikita Popov
Date: 2024-05-31T10:37:32+02:00
New Revision: 51e459a561519c8d51e2b4cadddc0d1f99c8b7ef

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

LOG: Revert "[ConstantFold] Remove non-trivial gep-of-gep fold (#93823)"

This reverts commit e1cc9e4eaddcc295b4e775512e33b947b1514c17.

This causes some non-trivial text size increases in unoptimized
builds for Bullet. Revert while I investigate.

Added: 


Modified: 
clang/test/CodeGenCXX/2011-12-19-init-list-ctor.cpp
clang/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist-pr12086.cpp
clang/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist.cpp
clang/test/OpenMP/threadprivate_codegen.cpp
llvm/lib/IR/ConstantFold.cpp
llvm/test/Other/constant-fold-gep.ll
llvm/test/Transforms/InstCombine/gepgep.ll
llvm/test/Transforms/InstCombine/getelementptr.ll
llvm/test/Transforms/InstCombine/ptrtoint-nullgep.ll

Removed: 




diff  --git a/clang/test/CodeGenCXX/2011-12-19-init-list-ctor.cpp 
b/clang/test/CodeGenCXX/2011-12-19-init-list-ctor.cpp
index e198cb7132ca4..4033adc8f0390 100644
--- a/clang/test/CodeGenCXX/2011-12-19-init-list-ctor.cpp
+++ b/clang/test/CodeGenCXX/2011-12-19-init-list-ctor.cpp
@@ -22,5 +22,5 @@ struct S {
 // CHECK: call void @_ZN1AC1EPKc(ptr {{[^,]*}} getelementptr inbounds 
(%struct.S, ptr @arr, i32 0, i32 1), ptr noundef @.str)
 // CHECK: store i32 1, ptr getelementptr inbounds (%struct.S, ptr @arr, i64 1)
 // CHECK: call void @_ZN1AC1EPKc(ptr {{[^,]*}} getelementptr inbounds 
(%struct.S, ptr @arr, i64 1, i32 1), ptr noundef @.str.1)
-// CHECK: store i32 2, ptr getelementptr inbounds (%struct.S, ptr 
getelementptr inbounds (%struct.S, ptr @arr, i64 1), i64 1)
-// CHECK: call void @_ZN1AC1EPKc(ptr {{[^,]*}} getelementptr inbounds 
(%struct.S, ptr getelementptr inbounds (%struct.S, ptr @arr, i64 1), i64 1, i32 
1), ptr noundef @.str.2)
+// CHECK: store i32 2, ptr getelementptr inbounds (%struct.S, ptr @arr, i64 2)
+// CHECK: call void @_ZN1AC1EPKc(ptr {{[^,]*}} getelementptr inbounds 
(%struct.S, ptr @arr, i64 2, i32 1), ptr noundef @.str.2)

diff  --git 
a/clang/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist-pr12086.cpp 
b/clang/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist-pr12086.cpp
index 4f4c88d9e96a5..6fbe4c7fd17a7 100644
--- a/clang/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist-pr12086.cpp
+++ b/clang/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist-pr12086.cpp
@@ -83,8 +83,8 @@ std::initializer_list> nested = {
 // CHECK-DYNAMIC-BL: store i32 5, ptr @_ZGR6nested2_
 // CHECK-DYNAMIC-BL: store i32 {{.*}}, ptr getelementptr inbounds (i32, ptr 
@_ZGR6nested2_, i64 1)
 // CHECK-DYNAMIC-BL: store ptr @_ZGR6nested2_,
-// CHECK-DYNAMIC-BL:   ptr getelementptr inbounds ({{.*}}, ptr 
getelementptr inbounds ({{.*}}, ptr @_ZGR6nested_, i64 1), i64 1), align 8
-// CHECK-DYNAMIC-BL: store i64 2, ptr getelementptr inbounds ({{.*}}, ptr 
getelementptr inbounds ({{.*}}, ptr @_ZGR6nested_, i64 1), i64 1, i32 1), align 
8
+// CHECK-DYNAMIC-BL:   ptr getelementptr inbounds ({{.*}}, ptr 
@_ZGR6nested_, i64 2), align 8
+// CHECK-DYNAMIC-BL: store i64 2, ptr getelementptr inbounds ({{.*}}, ptr 
@_ZGR6nested_, i64 2, i32 1), align 8
 // CHECK-DYNAMIC-BL: store ptr @_ZGR6nested_,
 // CHECK-DYNAMIC-BL:   ptr @nested, align 8
 // CHECK-DYNAMIC-BL: store i64 3, ptr getelementptr inbounds ({{.*}}, ptr 
@nested, i32 0, i32 1), align 8
@@ -123,9 +123,9 @@ std::initializer_list> nested = {
 // CHECK-DYNAMIC-BE: store i32 5, ptr @_ZGR6nested2_
 // CHECK-DYNAMIC-BE: store i32 {{.*}}, ptr getelementptr inbounds (i32, ptr 
@_ZGR6nested2_, i64 1)
 // CHECK-DYNAMIC-BE: store ptr @_ZGR6nested2_,
-// CHECK-DYNAMIC-BE:   ptr getelementptr inbounds ({{.*}}, ptr 
getelementptr inbounds ({{.*}}, ptr @_ZGR6nested_, i64 1), i64 1), align 8
+// CHECK-DYNAMIC-BE:   ptr getelementptr inbounds ({{.*}}, ptr 
@_ZGR6nested_, i64 2), align 8
 // CHECK-DYNAMIC-BE: store ptr getelementptr inbounds ([2 x i32], ptr 
@_ZGR6nested2_, i64 0, i64 2),
-// CHECK-DYNAMIC-BE:   ptr getelementptr inbounds ({{.*}}, ptr 
getelementptr inbounds ({{.*}}, ptr @_ZGR6nested_, i64 1), i64 1, i32 1), align 
8
+// CHECK-DYNAMIC-BE:   ptr getelementptr inbounds ({{.*}}, ptr 
@_ZGR6nested_, i64 2, i32 1), align 8
 // CHECK-DYNAMIC-BE: store ptr @_ZGR6nested_,
 // CHECK-DYNAMIC-BE:   ptr @nested, align 8
 // CHECK-DYNAMIC-BE: store ptr getelementptr inbounds ([3 x {{.*}}], ptr 
@_ZGR6nested_, i64 0, i64 3),

diff  --git a/clang/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist.cpp 
b/clang/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist.cpp
index ac05910151a46..aa2f078a5fb0c 100644
--- a/clang/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist.cpp
+++ b/clang/test/CodeGenCXX/cxx0x-i

[clang] [clang][analyzer] Move unix.BlockInCriticalSection out of alpha (PR #93815)

2024-05-31 Thread Endre Fülöp via cfe-commits

https://github.com/gamesh411 updated 
https://github.com/llvm/llvm-project/pull/93815

From 895ff8779b11294f132604e40572ebec8b6bc4c4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Endre=20F=C3=BCl=C3=B6p?= 
Date: Wed, 29 May 2024 00:38:07 +0200
Subject: [PATCH 1/2] [clang][analyzer] Move unix.BlockInCriticalSection out of
 alpha

After recent improvements, and testing on open source projects, the
checker is ready to move out of the alpha package.
---
 clang/docs/analyzer/checkers.rst  | 37 ++-
 .../clang/StaticAnalyzer/Checkers/Checkers.td |  8 ++--
 .../test/Analysis/block-in-critical-section.c |  2 +-
 .../Analysis/block-in-critical-section.cpp|  2 +-
 .../test/Analysis/block-in-critical-section.m |  2 +-
 clang/www/analyzer/alpha_checks.html  | 33 -
 6 files changed, 26 insertions(+), 58 deletions(-)

diff --git a/clang/docs/analyzer/checkers.rst b/clang/docs/analyzer/checkers.rst
index 3a31708a1e9de..86412bd3b9294 100644
--- a/clang/docs/analyzer/checkers.rst
+++ b/clang/docs/analyzer/checkers.rst
@@ -1235,6 +1235,25 @@ Check calls to various UNIX/Posix functions: ``open, 
pthread_once, calloc, mallo
 .. literalinclude:: checkers/unix_api_example.c
 :language: c
 
+.. _unix-BlockInCriticalSection:
+
+unix.BlockInCriticalSection (C)
+"
+
+Check for calls to blocking functions inside a critical section.
+Applies to: ``lock, unlock, sleep, getc, fgets, read, recv, 
pthread_mutex_lock,``
+`` pthread_mutex_unlock, mtx_lock, mtx_timedlock, mtx_trylock, mtx_unlock, 
lock_guard, unique_lock``
+
+.. code-block:: c
+
+ void test() {
+   std::mutex m;
+   m.lock();
+   sleep(3); // warn: a blocking function sleep is called inside a critical
+ //   section
+   m.unlock();
+ }
+
 .. _unix-Errno:
 
 unix.Errno (C)
@@ -3130,24 +3149,6 @@ For a more detailed description of configuration 
options, please see the
 alpha.unix
 ^^
 
-.. _alpha-unix-BlockInCriticalSection:
-
-alpha.unix.BlockInCriticalSection (C)
-"
-Check for calls to blocking functions inside a critical section.
-Applies to: ``lock, unlock, sleep, getc, fgets, read, recv, 
pthread_mutex_lock,``
-`` pthread_mutex_unlock, mtx_lock, mtx_timedlock, mtx_trylock, mtx_unlock, 
lock_guard, unique_lock``
-
-.. code-block:: c
-
- void test() {
-   std::mutex m;
-   m.lock();
-   sleep(3); // warn: a blocking function sleep is called inside a critical
- //   section
-   m.unlock();
- }
-
 .. _alpha-unix-Chroot:
 
 alpha.unix.Chroot (C)
diff --git a/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td 
b/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
index 40f443047bd4b..668e9f6cf0716 100644
--- a/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
+++ b/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
@@ -509,6 +509,10 @@ def UnixAPIMisuseChecker : Checker<"API">,
   HelpText<"Check calls to various UNIX/Posix functions">,
   Documentation;
 
+def BlockInCriticalSectionChecker : Checker<"BlockInCriticalSection">,
+  HelpText<"Check for calls to blocking functions inside a critical section">,
+  Documentation;
+
 def DynamicMemoryModeling: Checker<"DynamicMemoryModeling">,
   HelpText<"The base of several malloc() related checkers. On it's own it "
"emits no reports, but adds valuable information to the analysis "
@@ -619,10 +623,6 @@ def SimpleStreamChecker : Checker<"SimpleStream">,
   HelpText<"Check for misuses of stream APIs">,
   Documentation;
 
-def BlockInCriticalSectionChecker : Checker<"BlockInCriticalSection">,
-  HelpText<"Check for calls to blocking functions inside a critical section">,
-  Documentation;
-
 } // end "alpha.unix"
 
 
//===--===//
diff --git a/clang/test/Analysis/block-in-critical-section.c 
b/clang/test/Analysis/block-in-critical-section.c
index 1e174af541b18..36ecf9ac55f7d 100644
--- a/clang/test/Analysis/block-in-critical-section.c
+++ b/clang/test/Analysis/block-in-critical-section.c
@@ -1,4 +1,4 @@
-// RUN: %clang_analyze_cc1 
-analyzer-checker=core,alpha.unix.BlockInCriticalSection -verify %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix.BlockInCriticalSection 
-verify %s
 // expected-no-diagnostics
 
 // This should not crash
diff --git a/clang/test/Analysis/block-in-critical-section.cpp 
b/clang/test/Analysis/block-in-critical-section.cpp
index 87c26b9f1b520..238d9a84f5f77 100644
--- a/clang/test/Analysis/block-in-critical-section.cpp
+++ b/clang/test/Analysis/block-in-critical-section.cpp
@@ -1,5 +1,5 @@
 // RUN: %clang_analyze_cc1 \
-// RUN:   -analyzer-checker=alpha.unix.BlockInCriticalSection \
+// RUN:   -analyzer-checker=unix.BlockInCriticalSection \
 // RUN:   -std=c++11 \
 // RUN:   -analyzer-output text \
 // RUN:   -verify %s
diff --git a/clang/test/Analysis/block-in-critical-section.m 
b/clang/test/Analysis/block-in-critical-section.m
index 73

[clang] [llvm] [AMDGPU] Extend readlane, writelane and readfirstlane intrinsic lowering for generic types (PR #89217)

2024-05-31 Thread Matt Arsenault via cfe-commits

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


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


[clang] remove goma support from clang (PR #93942)

2024-05-31 Thread Takuto Ikuta via cfe-commits

https://github.com/atetubou created 
https://github.com/llvm/llvm-project/pull/93942

goma is deprecated and not maintained anymore.

https://chromium.googlesource.com/infra/goma/client/

>From eb50f67d29325ded7bf49834fb9fed0d588b5529 Mon Sep 17 00:00:00 2001
From: Takuto Ikuta 
Date: Fri, 31 May 2024 18:16:17 +0900
Subject: [PATCH] remove goma support from clang

---
 clang/lib/Tooling/JSONCompilationDatabase.cpp   | 5 ++---
 clang/unittests/Tooling/CompilationDatabaseTest.cpp | 1 -
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/clang/lib/Tooling/JSONCompilationDatabase.cpp 
b/clang/lib/Tooling/JSONCompilationDatabase.cpp
index a77686996879f..5ecba5dfece3d 100644
--- a/clang/lib/Tooling/JSONCompilationDatabase.cpp
+++ b/clang/lib/Tooling/JSONCompilationDatabase.cpp
@@ -260,7 +260,7 @@ static llvm::StringRef 
stripExecutableExtension(llvm::StringRef Name) {
   return Name;
 }
 
-// There are compiler-wrappers (ccache, distcc, gomacc) that take the "real"
+// There are compiler-wrappers (ccache, distcc) that take the "real"
 // compiler as an argument, e.g. distcc gcc -O3 foo.c.
 // These end up in compile_commands.json when people set CC="distcc gcc".
 // Clang's driver doesn't understand this, so we need to unwrap.
@@ -269,8 +269,7 @@ static bool unwrapCommand(std::vector &Args) {
 return false;
   StringRef Wrapper =
   stripExecutableExtension(llvm::sys::path::filename(Args.front()));
-  if (Wrapper == "distcc" || Wrapper == "gomacc" || Wrapper == "ccache" ||
-  Wrapper == "sccache") {
+  if (Wrapper == "distcc" || Wrapper == "ccache" || Wrapper == "sccache") {
 // Most of these wrappers support being invoked 3 ways:
 // `distcc g++ file.c` This is the mode we're trying to match.
 // We need to drop `distcc`.
diff --git a/clang/unittests/Tooling/CompilationDatabaseTest.cpp 
b/clang/unittests/Tooling/CompilationDatabaseTest.cpp
index 45062cf7c16f6..2032b13726c45 100644
--- a/clang/unittests/Tooling/CompilationDatabaseTest.cpp
+++ b/clang/unittests/Tooling/CompilationDatabaseTest.cpp
@@ -402,7 +402,6 @@ TEST(findCompileArgsInJsonDatabase, FindsEntry) {
 TEST(findCompileArgsInJsonDatabase, ParsesCompilerWrappers) {
   std::vector> Cases = {
   {"distcc gcc foo.c", "gcc foo.c"},
-  {"gomacc clang++ foo.c", "clang++ foo.c"},
   {"sccache clang++ foo.c", "clang++ foo.c"},
   {"ccache gcc foo.c", "gcc foo.c"},
   {"ccache.exe gcc foo.c", "gcc foo.c"},

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


[clang] remove goma support from clang (PR #93942)

2024-05-31 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Takuto Ikuta (atetubou)


Changes

goma is deprecated and not maintained anymore.

https://chromium.googlesource.com/infra/goma/client/

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


2 Files Affected:

- (modified) clang/lib/Tooling/JSONCompilationDatabase.cpp (+2-3) 
- (modified) clang/unittests/Tooling/CompilationDatabaseTest.cpp (-1) 


``diff
diff --git a/clang/lib/Tooling/JSONCompilationDatabase.cpp 
b/clang/lib/Tooling/JSONCompilationDatabase.cpp
index a77686996879f..5ecba5dfece3d 100644
--- a/clang/lib/Tooling/JSONCompilationDatabase.cpp
+++ b/clang/lib/Tooling/JSONCompilationDatabase.cpp
@@ -260,7 +260,7 @@ static llvm::StringRef 
stripExecutableExtension(llvm::StringRef Name) {
   return Name;
 }
 
-// There are compiler-wrappers (ccache, distcc, gomacc) that take the "real"
+// There are compiler-wrappers (ccache, distcc) that take the "real"
 // compiler as an argument, e.g. distcc gcc -O3 foo.c.
 // These end up in compile_commands.json when people set CC="distcc gcc".
 // Clang's driver doesn't understand this, so we need to unwrap.
@@ -269,8 +269,7 @@ static bool unwrapCommand(std::vector &Args) {
 return false;
   StringRef Wrapper =
   stripExecutableExtension(llvm::sys::path::filename(Args.front()));
-  if (Wrapper == "distcc" || Wrapper == "gomacc" || Wrapper == "ccache" ||
-  Wrapper == "sccache") {
+  if (Wrapper == "distcc" || Wrapper == "ccache" || Wrapper == "sccache") {
 // Most of these wrappers support being invoked 3 ways:
 // `distcc g++ file.c` This is the mode we're trying to match.
 // We need to drop `distcc`.
diff --git a/clang/unittests/Tooling/CompilationDatabaseTest.cpp 
b/clang/unittests/Tooling/CompilationDatabaseTest.cpp
index 45062cf7c16f6..2032b13726c45 100644
--- a/clang/unittests/Tooling/CompilationDatabaseTest.cpp
+++ b/clang/unittests/Tooling/CompilationDatabaseTest.cpp
@@ -402,7 +402,6 @@ TEST(findCompileArgsInJsonDatabase, FindsEntry) {
 TEST(findCompileArgsInJsonDatabase, ParsesCompilerWrappers) {
   std::vector> Cases = {
   {"distcc gcc foo.c", "gcc foo.c"},
-  {"gomacc clang++ foo.c", "clang++ foo.c"},
   {"sccache clang++ foo.c", "clang++ foo.c"},
   {"ccache gcc foo.c", "gcc foo.c"},
   {"ccache.exe gcc foo.c", "gcc foo.c"},

``




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


[clang] [llvm] [AMDGPU] Extend readlane, writelane and readfirstlane intrinsic lowering for generic types (PR #89217)

2024-05-31 Thread Jay Foad via cfe-commits

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


[clang] [llvm] [AMDGPU] Extend readlane, writelane and readfirstlane intrinsic lowering for generic types (PR #89217)

2024-05-31 Thread Jay Foad via cfe-commits


@@ -5496,6 +5496,9 @@ const char* 
AMDGPUTargetLowering::getTargetNodeName(unsigned Opcode) const {
   NODE_NAME_CASE(LDS)
   NODE_NAME_CASE(FPTRUNC_ROUND_UPWARD)
   NODE_NAME_CASE(FPTRUNC_ROUND_DOWNWARD)
+  NODE_NAME_CASE(READLANE)
+  NODE_NAME_CASE(READFIRSTLANE)

jayfoad wrote:

Add these to `AMDGPUTargetLowering::isSDNodeAlwaysUniform`

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


[clang] [llvm] [AMDGPU] Extend readlane, writelane and readfirstlane intrinsic lowering for generic types (PR #89217)

2024-05-31 Thread Jay Foad via cfe-commits


@@ -5496,6 +5496,9 @@ const char* 
AMDGPUTargetLowering::getTargetNodeName(unsigned Opcode) const {
   NODE_NAME_CASE(LDS)
   NODE_NAME_CASE(FPTRUNC_ROUND_UPWARD)
   NODE_NAME_CASE(FPTRUNC_ROUND_DOWNWARD)
+  NODE_NAME_CASE(READLANE)
+  NODE_NAME_CASE(READFIRSTLANE)
+  NODE_NAME_CASE(WRITELANE)

jayfoad wrote:

Add this to `SITargetLowering::isSDNodeSourceOfDivergence`

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


[clang] [llvm] [AMDGPU] Extend readlane, writelane and readfirstlane intrinsic lowering for generic types (PR #89217)

2024-05-31 Thread Jay Foad via cfe-commits

https://github.com/jayfoad commented:

Does this need IR autoupgrade?

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


[clang] Remove dangling conversion to `optional &` (PR #93385)

2024-05-31 Thread via cfe-commits

cor3ntin wrote:

@davidstone you need me to merge that for you?

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


[clang] clang-format: Allow open brace with trailing comment (no line break) (PR #89956)

2024-05-31 Thread via cfe-commits

GertyP wrote:

Ping
... and tweaking the title formatting to use square braces in case it's 
important:  Can someone tell me if it makes a difference to have 
`[clang-format] ...` in title over `clang-format: ...`?  I haven't seen 
anything saying so in any readme but I could have missed something.

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


[clang] [clang-format] Allow open brace with trailing comment (no line break) (PR #89956)

2024-05-31 Thread via cfe-commits

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


[clang] [clang][analyzer][NFC] Improve docs of alpha.unix.BlockInCriticalSection (PR #93812)

2024-05-31 Thread Donát Nagy via cfe-commits

NagyDonat wrote:

> My intention was to ease the review as much as possible by cutting them into 
> atomic parts.

This is a good idea in general, but I feel that these two changes are so 
trivial, that they'd be very easy to review even together. Feel free to merge 
them both in whatever combination you would like. 

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


[clang] [llvm] [AMDGPU] Extend readlane, writelane and readfirstlane intrinsic lowering for generic types (PR #89217)

2024-05-31 Thread Matt Arsenault via cfe-commits

arsenm wrote:

> Does this need IR autoupgrade?

This type of auto upgrade is free, it just happens 

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


[clang] [llvm] Add option to generate additional debug info for expression dereferencing pointer to pointers. (PR #81545)

2024-05-31 Thread William Junda Huang via cfe-commits

huangjd wrote:

How do I reopen the PR after fixing the test case? 

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


[clang-tools-extra] [clang-tidy] Option to ignore anonymous namespaces in avoid-non-const-global-variables (PR #93827)

2024-05-31 Thread Pascal Jungblut via cfe-commits

https://github.com/pascalj updated 
https://github.com/llvm/llvm-project/pull/93827

>From abe862b84fd6915edb281a21e49f1be2aac3a626 Mon Sep 17 00:00:00 2001
From: Pascal Jungblut 
Date: Thu, 30 May 2024 14:28:50 +0200
Subject: [PATCH] Add option to ignore anonymous namespaces in
 avoid-non-const-global-variables

---
 .../AvoidNonConstGlobalVariablesCheck.cpp | 19 +---
 .../AvoidNonConstGlobalVariablesCheck.h   |  7 --
 clang-tools-extra/docs/ReleaseNotes.rst   |  5 +
 .../avoid-non-const-global-variables.rst  |  8 +++
 .../avoid-non-const-global-variables.cpp  | 22 ++-
 5 files changed, 51 insertions(+), 10 deletions(-)

diff --git 
a/clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidNonConstGlobalVariablesCheck.cpp
 
b/clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidNonConstGlobalVariablesCheck.cpp
index ee17b0e014288..a97ec9fe3fe3d 100644
--- 
a/clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidNonConstGlobalVariablesCheck.cpp
+++ 
b/clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidNonConstGlobalVariablesCheck.cpp
@@ -7,7 +7,6 @@
 
//===--===//
 
 #include "AvoidNonConstGlobalVariablesCheck.h"
-#include "clang/AST/ASTContext.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "clang/ASTMatchers/ASTMatchers.h"
 
@@ -15,13 +14,23 @@ using namespace clang::ast_matchers;
 
 namespace clang::tidy::cppcoreguidelines {
 
+AvoidNonConstGlobalVariablesCheck::AvoidNonConstGlobalVariablesCheck(
+StringRef Name, ClangTidyContext *Context)
+: ClangTidyCheck(Name, Context),
+  AllowInternalLinkage(Options.get("AllowInternalLinkage", false)) {}
+
 void AvoidNonConstGlobalVariablesCheck::registerMatchers(MatchFinder *Finder) {
+  auto NamespaceMatcher = AllowInternalLinkage
+  ? namespaceDecl(unless(isAnonymous()))
+  : namespaceDecl();
   auto GlobalContext =
   varDecl(hasGlobalStorage(),
-  hasDeclContext(anyOf(namespaceDecl(), translationUnitDecl(;
+  hasDeclContext(anyOf(NamespaceMatcher, translationUnitDecl(;
 
   auto GlobalVariable = varDecl(
   GlobalContext,
+  AllowInternalLinkage ? varDecl(unless(isStaticStorageClass()))
+   : varDecl(),
   unless(anyOf(
   isConstexpr(), hasType(isConstQualified()),
   hasType(referenceType(); // References can't be changed, only the
@@ -43,7 +52,6 @@ void 
AvoidNonConstGlobalVariablesCheck::registerMatchers(MatchFinder *Finder) {
 
 void AvoidNonConstGlobalVariablesCheck::check(
 const MatchFinder::MatchResult &Result) {
-
   if (const auto *Variable =
   Result.Nodes.getNodeAs("non-const_variable")) {
 diag(Variable->getLocation(), "variable %0 is non-const and globally "
@@ -63,4 +71,9 @@ void AvoidNonConstGlobalVariablesCheck::check(
   }
 }
 
+void AvoidNonConstGlobalVariablesCheck::storeOptions(
+ClangTidyOptions::OptionMap &Opts) {
+  Options.store(Opts, "AllowInternalLinkage", AllowInternalLinkage);
+}
+
 } // namespace clang::tidy::cppcoreguidelines
diff --git 
a/clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidNonConstGlobalVariablesCheck.h
 
b/clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidNonConstGlobalVariablesCheck.h
index e816ca9b47d41..a912763489db9 100644
--- 
a/clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidNonConstGlobalVariablesCheck.h
+++ 
b/clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidNonConstGlobalVariablesCheck.h
@@ -20,10 +20,13 @@ namespace clang::tidy::cppcoreguidelines {
 /// 
http://clang.llvm.org/extra/clang-tidy/checks/cppcoreguidelines/avoid-non-const-global-variables.html
 class AvoidNonConstGlobalVariablesCheck : public ClangTidyCheck {
 public:
-  AvoidNonConstGlobalVariablesCheck(StringRef Name, ClangTidyContext *Context)
-  : ClangTidyCheck(Name, Context) {}
+  AvoidNonConstGlobalVariablesCheck(StringRef Name, ClangTidyContext *Context);
   void registerMatchers(ast_matchers::MatchFinder *Finder) override;
   void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
+  void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
+
+private:
+  const bool AllowInternalLinkage;
 };
 
 } // namespace clang::tidy::cppcoreguidelines
diff --git a/clang-tools-extra/docs/ReleaseNotes.rst 
b/clang-tools-extra/docs/ReleaseNotes.rst
index 4f674d1a4d556..4db476718f775 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -250,6 +250,11 @@ Changes in existing checks
   ` check to also handle
   calls to ``std::forward``.
 
+- Improved :doc:`cppcoreguidelines-avoid-non-const-global-variables
+  ` check
+  with a new option `AllowInternalLinkage` to disable the warning for variables
+  with internal linkage.
+
 - Improved :doc:`cppcoreguidelines-missing-std-forward
   ` check by no longer
   giving false positives for deleted functions, by 

[clang] [clang][analyzer][NFC] Improve docs of alpha.unix.BlockInCriticalSection (PR #93812)

2024-05-31 Thread Balazs Benics via cfe-commits

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


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


[clang] [clang] Lower _BitInt(129+) to a different type in LLVM IR (PR #91364)

2024-05-31 Thread Mariya Podchishchaeva via cfe-commits


@@ -2012,26 +2015,27 @@ llvm::Value *CodeGenFunction::EmitLoadOfScalar(Address 
Addr, bool Volatile,
 }
 
 llvm::Value *CodeGenFunction::EmitToMemory(llvm::Value *Value, QualType Ty) {
-  // Bool has a different representation in memory than in registers.
-  if (hasBooleanRepresentation(Ty)) {
-// This should really always be an i1, but sometimes it's already
-// an i8, and it's awkward to track those cases down.
-if (Value->getType()->isIntegerTy(1))
-  return Builder.CreateZExt(Value, ConvertTypeForMem(Ty), "frombool");
-assert(Value->getType()->isIntegerTy(getContext().getTypeSize(Ty)) &&
-   "wrong value rep of bool");
+  if (hasBooleanRepresentation(Ty) ||
+  (Ty->isBitIntType() && Value->getType()->isIntegerTy())) {

Fznamznon wrote:

`_BitInt` that now has an array of bytes as memory type,  is returned from a 
function via sret(memory type) parameter. Additionally in `EmitFunctionEpilog` 
there is a load and a store (demo of these load an store 
https://godbolt.org/z/K37j4f1jn) of return value emitted that has memory type. 

Same for bool, though its memory type is not an array. I suppose there can be 
more cases, see comment that used to be on lines 2017-2018
```
// This should really always be an i1, but sometimes it's already
// an i8, and it's awkward to track those cases down.
```

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


[clang-tools-extra] [clang-tidy] Option to ignore anonymous namespaces in avoid-non-const-global-variables (PR #93827)

2024-05-31 Thread Pascal Jungblut via cfe-commits


@@ -1,29 +1,39 @@
-// RUN: %check_clang_tidy %s 
cppcoreguidelines-avoid-non-const-global-variables %t
+// RUN: %check_clang_tidy %s -check-suffix=DEFAULT 
cppcoreguidelines-avoid-non-const-global-variables %t
+// RUN: %check_clang_tidy %s -check-suffix=NAMESPACE 
cppcoreguidelines-avoid-non-const-global-variables %t -- \

pascalj wrote:

Thanks for this hint, it made the checks much easier. It now tests only for the 
cases where the configuration differs.

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


[clang-tools-extra] [clang-tidy] Option to ignore anonymous namespaces in avoid-non-const-global-variables (PR #93827)

2024-05-31 Thread Pascal Jungblut via cfe-commits

pascalj wrote:

Thanks for your feedback!

> * what about "static" non const global variables

Good point, forgot about these. If both are allowed, it is more about the 
internal linkage than it is about the namespace. I renamed the option to 
`AllowInternalLinkage` and permit variables in anonymous namespaces and static 
global variables, since they're equivalent (AFAICT). 

> I'm fine for having an options that control behavior of the check. But please 
> note that there are other aspects of "I.2: Avoid non-const global variables" 
> rule that anonymous namespace or static does not solve. Like race-conditions 
> in multithread env. Or even to force developer not to use global objects to 
> pass data between functions.
> 
> Even that I see many times that warnings from this check are being nolinted, 
> I still think that it's doing good job.

I completely agree with both you and @carlosgalvezp: this is neither an option 
that should be enabled by default, nor should people prefer it over nolinting 
without some thought. However, I see not much harm in giving someone the choice 
to do so. In the end, all of clang-tidy's checks are optional to some degree.

Having said that: if the maintainers prefer not to have this option, this is 
also fine with me.

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


[clang] [llvm] Intrinsic: introduce minimumnum and maximumnum (PR #93841)

2024-05-31 Thread Matt Arsenault via cfe-commits

https://github.com/arsenm commented:

> 3. PowerPC: has some interaction with the behavior of `minnum/maxnum`: need 
> define `fcanonicalize`.

AMDGPU has the same handling. This is to break the signaling nan handling from 
IEEE to the broken old glibc libm behavior. If we fix the definition to match 
IEEE, this is no longer necessary and the operation is directly legal 

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


[clang] [llvm] Intrinsic: introduce minimumnum and maximumnum (PR #93841)

2024-05-31 Thread Matt Arsenault via cfe-commits


@@ -3636,6 +3648,22 @@ def Fmin : FPMathTemplate, LibBuiltin<"math.h"> {
   let OnlyBuiltinPrefixedAliasIsConstexpr = 1;
 }
 
+def FmaximumNum : FPMathTemplate, LibBuiltin<"math.h"> {

arsenm wrote:

I'd prefer to split the clang changes into a separate change 

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


[clang] [llvm] Intrinsic: introduce minimumnum and maximumnum (PR #93841)

2024-05-31 Thread Matt Arsenault via cfe-commits

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


[clang] [llvm] Intrinsic: introduce minimumnum and maximumnum (PR #93841)

2024-05-31 Thread Matt Arsenault via cfe-commits


@@ -16049,6 +16094,84 @@ of the two arguments. -0.0 is considered to be less 
than +0.0 for this
 intrinsic. Note that these are the semantics specified in the draft of
 IEEE 754-2019.
 
+.. _i_minimumnum:
+
+'``llvm.minimumnum.*``' Intrinsic
+^
+
+Syntax:
+"""
+
+This is an overloaded intrinsic. You can use ``llvm.minimumnum`` on any
+floating-point or vector of floating-point type. Not all targets support
+all types however.
+
+::
+
+  declare float @llvm.minimumnum.f32(float %Val0, float %Val1)
+  declare double@llvm.minimumnum.f64(double %Val0, double %Val1)
+  declare x86_fp80  @llvm.minimumnum.f80(x86_fp80 %Val0, x86_fp80 %Val1)
+  declare fp128 @llvm.minimumnum.f128(fp128 %Val0, fp128 %Val1)
+  declare ppc_fp128 @llvm.minimumnum.ppcf128(ppc_fp128 %Val0, ppc_fp128 
%Val1)
+
+Overview:
+"
+
+The '``llvm.minimumnum.*``' intrinsics return the minimum of the two
+arguments, not propagating NaNs and treating -0.0 as less than +0.0.
+
+
+Arguments:
+""
+
+The arguments and return value are floating-point numbers of the same
+type.
+
+Semantics:
+""
+If both operands are NaNs, returns qNaN. Otherwise returns the lesser
+of the two arguments. -0.0 is considered to be less than +0.0 for this
+intrinsic. Note that these are the semantics specified in IEEE 754-2019.

arsenm wrote:

Needs to spell out the signaling nan behavior. If we're fixing minnum's snan 
behavior to match IEEE, this is identical except with the stronger guarantee 
for signed zero ordering. The documentation should also explicitly state this 
is the only difference, to help reduce confusion. Alternatively, we could add 
an immediate bool parameter to minnum/maxnum for whether the ordering of 0 is 
guaranteed 

I hate the naming mess we've ended up with here, but I guess C23 has damned us. 
If you're going to match the C23 names, this should be `llvm.minimum.num` with 
an extra _ 

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


[clang] [llvm] Intrinsic: introduce minimumnum and maximumnum (PR #93841)

2024-05-31 Thread Matt Arsenault via cfe-commits


@@ -5005,8 +5007,11 @@ void computeKnownFPClass(const Value *V, const APInt 
&DemandedElts,
   // If either operand is not NaN, the result is not NaN.
   if (NeverNaN && (IID == Intrinsic::minnum || IID == Intrinsic::maxnum))
 Known.knownNot(fcNan);
+  if (NeverNaN &&
+  (IID == Intrinsic::minimumnum || IID == Intrinsic::maximumnum))
+Known.knownNot(fcNan);
 
-  if (IID == Intrinsic::maxnum) {
+  if (IID == Intrinsic::maxnum || IID == Intrinsic::maximumnum) {

arsenm wrote:

Best to keep the value tracking handling in a separate PR. This is missing test 
coverage 

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


[clang] [llvm] [AMDGPU] Extend readlane, writelane and readfirstlane intrinsic lowering for generic types (PR #89217)

2024-05-31 Thread Jay Foad via cfe-commits

jayfoad wrote:

There is a latent problem to do with convergence. If you add a new test case 
like this:
```diff
diff --git a/llvm/test/CodeGen/AMDGPU/convergence-tokens.ll 
b/llvm/test/CodeGen/AMDGPU/convergence-tokens.ll
index 238f6ab39e83..22995083293d 100644
--- a/llvm/test/CodeGen/AMDGPU/convergence-tokens.ll
+++ b/llvm/test/CodeGen/AMDGPU/convergence-tokens.ll
@@ -55,6 +55,21 @@ else:
   ret i32 %p
 }
 
+define i64 @basic_branch_i64(i64 %src, i1 %cond) #0 {
+entry:
+  %t = call token @llvm.experimental.convergence.anchor()
+  %x = add i64 %src, 1
+  br i1 %cond, label %then, label %else
+
+then:
+  %r = call i64 @llvm.amdgcn.readfirstlane.i64(i64 %x) [ 
"convergencectrl"(token %t) ]
+  br label %else
+
+else:
+  %p = phi i64 [%r, %then], [%x, %entry]
+  ret i64 %p
+}
+
 ; CHECK-LABEL: name:basic_loop
 ;   CHECK:[[TOKEN:%[0-9]+]]{{[^ ]*}} = CONVERGENCECTRL_ANCHOR
 ;   CHECK:  bb.[[#]].loop:
```
Then it will fail with:
```
*** Bad machine code: Cannot mix controlled and uncontrolled convergence in the 
same function. ***
```
This is related to #87509. Since the readlane/readfirstlane/writelane 
intrinsics are IntrConvergent, the corresponding ISD nodes should be marked 
with SDNPInGlue or SDNPOptInGlue. @ssahasra FYI

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


[clang] [SPIR-V] Prefer llvm-spirv- tool (PR #77897)

2024-05-31 Thread Henry Linjamäki via cfe-commits

linehill wrote:

Ping, @svenvh. The patch has been rebased, good for landing?

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


[clang] [SPIR-V] Prefer llvm-spirv- tool (PR #77897)

2024-05-31 Thread Sven van Haastregt via cfe-commits
Henry =?utf-8?q?Linjamäki?= 
Message-ID:
In-Reply-To: 


svenvh wrote:

> Ping, @svenvh. The patch has been rebased, good for landing?

Thanks for the ping, it seems github didn't send me a notification when you 
rebased.

Just waiting for the final checks to complete, then I'll merge it.

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


[clang] [llvm] [WIP] Expand variadic functions in IR (PR #89007)

2024-05-31 Thread Matt Arsenault via cfe-commits

arsenm wrote:

> I think the comments here are fed into #93362 successfully, will go through 
> the list again to check.

So #93362 is the replacement, and not the sequential next piece? Can we close 
this one then? 

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


[clang] [Clang][Sema] Push an evaluation context for type constraints (PR #93945)

2024-05-31 Thread Younan Zhang via cfe-commits

https://github.com/zyn0217 created 
https://github.com/llvm/llvm-project/pull/93945

This helps getTemplateInstantiationArgs to properly recover template arguments 
of an enclosing concept Decl.

Fixes https://github.com/llvm/llvm-project/issues/93821

>From 088c4199dd37172a57d965fe1b22f782084e127e Mon Sep 17 00:00:00 2001
From: Younan Zhang 
Date: Fri, 31 May 2024 18:15:54 +0800
Subject: [PATCH] [Clang][Sema] Push an evaluation context for type constraints

This helps getTemplateInstantiationArgs to properly recover template
arguments of an enclosing concept Decl.

Fixes https://github.com/llvm/llvm-project/issues/93821
---
 clang/docs/ReleaseNotes.rst |  1 +
 clang/lib/Sema/SemaTemplateDeduction.cpp| 14 ++
 clang/test/SemaTemplate/concepts-lambda.cpp | 12 
 3 files changed, 27 insertions(+)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 49ab222bec405..83eb285e9ca48 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -710,6 +710,7 @@ Bug Fixes to C++ Support
 - Correctly treat the compound statement of an ``if consteval`` as an 
immediate context. Fixes (#GH91509).
 - When partial ordering alias templates against template template parameters,
   allow pack expansions when the alias has a fixed-size parameter list. Fixes 
(#GH62529).
+- Fixed a type constraint substitution issue involving a generic lambda 
expression. (#GH93821)
 
 Bug Fixes to AST Handling
 ^
diff --git a/clang/lib/Sema/SemaTemplateDeduction.cpp 
b/clang/lib/Sema/SemaTemplateDeduction.cpp
index 853c0e1b50619..56529b4d852e7 100644
--- a/clang/lib/Sema/SemaTemplateDeduction.cpp
+++ b/clang/lib/Sema/SemaTemplateDeduction.cpp
@@ -5004,6 +5004,20 @@ static bool CheckDeducedPlaceholderConstraints(Sema &S, 
const AutoType &Type,
 return true;
   MultiLevelTemplateArgumentList MLTAL(Concept, CanonicalConverted,
/*Final=*/false);
+  // Build up an EvaluationContext with an ImplicitConceptSpecializationDecl so
+  // that the template arguments of the constraint can be preserved. For
+  // example:
+  //
+  //  template 
+  //  concept C = []() { return true; }();
+  //
+  // We need the argument for T while evaluating type constraint D in
+  // building the CallExpr to the lambda.
+  EnterExpressionEvaluationContext EECtx(
+  S, Sema::ExpressionEvaluationContext::ConstantEvaluated,
+  ImplicitConceptSpecializationDecl::Create(
+  S.getASTContext(), Concept->getDeclContext(), Concept->getLocation(),
+  CanonicalConverted));
   if (S.CheckConstraintSatisfaction(Concept, {Concept->getConstraintExpr()},
 MLTAL, TypeLoc.getLocalSourceRange(),
 Satisfaction))
diff --git a/clang/test/SemaTemplate/concepts-lambda.cpp 
b/clang/test/SemaTemplate/concepts-lambda.cpp
index fac790d09f9cf..280be71284f97 100644
--- a/clang/test/SemaTemplate/concepts-lambda.cpp
+++ b/clang/test/SemaTemplate/concepts-lambda.cpp
@@ -225,3 +225,15 @@ void foo() {
   }(x);
 }
 } // namespace GH73418
+
+namespace GH93821 {
+
+template 
+concept C = true;
+
+template 
+concept D = []() { return true; }();
+
+D auto x = 0;
+
+} // namespace GH93821

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


[clang] [Clang][Sema] Push an evaluation context for type constraints (PR #93945)

2024-05-31 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Younan Zhang (zyn0217)


Changes

This helps getTemplateInstantiationArgs to properly recover template arguments 
of an enclosing concept Decl.

Fixes https://github.com/llvm/llvm-project/issues/93821

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


3 Files Affected:

- (modified) clang/docs/ReleaseNotes.rst (+1) 
- (modified) clang/lib/Sema/SemaTemplateDeduction.cpp (+14) 
- (modified) clang/test/SemaTemplate/concepts-lambda.cpp (+12) 


``diff
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 49ab222bec405..83eb285e9ca48 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -710,6 +710,7 @@ Bug Fixes to C++ Support
 - Correctly treat the compound statement of an ``if consteval`` as an 
immediate context. Fixes (#GH91509).
 - When partial ordering alias templates against template template parameters,
   allow pack expansions when the alias has a fixed-size parameter list. Fixes 
(#GH62529).
+- Fixed a type constraint substitution issue involving a generic lambda 
expression. (#GH93821)
 
 Bug Fixes to AST Handling
 ^
diff --git a/clang/lib/Sema/SemaTemplateDeduction.cpp 
b/clang/lib/Sema/SemaTemplateDeduction.cpp
index 853c0e1b50619..56529b4d852e7 100644
--- a/clang/lib/Sema/SemaTemplateDeduction.cpp
+++ b/clang/lib/Sema/SemaTemplateDeduction.cpp
@@ -5004,6 +5004,20 @@ static bool CheckDeducedPlaceholderConstraints(Sema &S, 
const AutoType &Type,
 return true;
   MultiLevelTemplateArgumentList MLTAL(Concept, CanonicalConverted,
/*Final=*/false);
+  // Build up an EvaluationContext with an ImplicitConceptSpecializationDecl so
+  // that the template arguments of the constraint can be preserved. For
+  // example:
+  //
+  //  template 
+  //  concept C = []() { return true; }();
+  //
+  // We need the argument for T while evaluating type constraint D in
+  // building the CallExpr to the lambda.
+  EnterExpressionEvaluationContext EECtx(
+  S, Sema::ExpressionEvaluationContext::ConstantEvaluated,
+  ImplicitConceptSpecializationDecl::Create(
+  S.getASTContext(), Concept->getDeclContext(), Concept->getLocation(),
+  CanonicalConverted));
   if (S.CheckConstraintSatisfaction(Concept, {Concept->getConstraintExpr()},
 MLTAL, TypeLoc.getLocalSourceRange(),
 Satisfaction))
diff --git a/clang/test/SemaTemplate/concepts-lambda.cpp 
b/clang/test/SemaTemplate/concepts-lambda.cpp
index fac790d09f9cf..280be71284f97 100644
--- a/clang/test/SemaTemplate/concepts-lambda.cpp
+++ b/clang/test/SemaTemplate/concepts-lambda.cpp
@@ -225,3 +225,15 @@ void foo() {
   }(x);
 }
 } // namespace GH73418
+
+namespace GH93821 {
+
+template 
+concept C = true;
+
+template 
+concept D = []() { return true; }();
+
+D auto x = 0;
+
+} // namespace GH93821

``




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


[clang] a65771f - [SPIR-V] Prefer llvm-spirv- tool (#77897)

2024-05-31 Thread via cfe-commits

Author: Henry Linjamäki
Date: 2024-05-31T12:21:21+02:00
New Revision: a65771fce4a2f25f16d4b3918ad6a11370637f7b

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

LOG: [SPIR-V] Prefer llvm-spirv- tool (#77897)

Prefer using `llvm-spirv-` tool (i.e.
`llvm-spirv-18`) over plain `llvm-spirv`. If the versioned tool is not
found in PATH, fall back to use the plain `llvm-spirv`.

An issue with the using `llvm-spirv` is that the one found in PATH might
be compiled against older LLVM version which could lead to crashes or
obscure bugs. For example, `llvm-spirv` distributed by Ubuntu links
against different LLVM version depending on the Ubuntu release (LLVM-10
in 20.04LTS, LLVM-13 in 22.04LTS).

Added: 


Modified: 
clang/docs/UsersManual.rst
clang/lib/Driver/ToolChains/SPIRV.cpp
clang/test/Driver/hipspv-toolchain.hip
clang/test/Driver/spirv-toolchain.cl
clang/test/lit.site.cfg.py.in

Removed: 




diff  --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst
index 80ba70f67126f..f954857b0235a 100644
--- a/clang/docs/UsersManual.rst
+++ b/clang/docs/UsersManual.rst
@@ -4430,9 +4430,9 @@ To generate SPIR-V binaries, Clang uses the external 
``llvm-spirv`` tool from th
 Prior to the generation of SPIR-V binary with Clang, ``llvm-spirv``
 should be built or installed. Please refer to `the following instructions
 `_
-for more details. Clang will expect the ``llvm-spirv`` executable to
-be present in the ``PATH`` environment variable. Clang uses ``llvm-spirv``
-with `the widely adopted assembly syntax package
+for more details. Clang will look for ``llvm-spirv-`` and
+``llvm-spirv`` executables, in this order, in the ``PATH`` environment 
variable.
+Clang uses ``llvm-spirv`` with `the widely adopted assembly syntax package
 
`_.
 
 `The versioning

diff  --git a/clang/lib/Driver/ToolChains/SPIRV.cpp 
b/clang/lib/Driver/ToolChains/SPIRV.cpp
index 27de69550853c..ce900600cbee5 100644
--- a/clang/lib/Driver/ToolChains/SPIRV.cpp
+++ b/clang/lib/Driver/ToolChains/SPIRV.cpp
@@ -7,6 +7,7 @@
 
//===--===//
 #include "SPIRV.h"
 #include "CommonArgs.h"
+#include "clang/Basic/Version.h"
 #include "clang/Driver/Compilation.h"
 #include "clang/Driver/Driver.h"
 #include "clang/Driver/InputInfo.h"
@@ -32,8 +33,15 @@ void SPIRV::constructTranslateCommand(Compilation &C, const 
Tool &T,
 
   CmdArgs.append({"-o", Output.getFilename()});
 
-  const char *Exec =
-  C.getArgs().MakeArgString(T.getToolChain().GetProgramPath("llvm-spirv"));
+  // Try to find "llvm-spirv-". Otherwise, fall back to
+  // plain "llvm-spirv".
+  using namespace std::string_literals;
+  auto VersionedTool = "llvm-spirv-"s + std::to_string(LLVM_VERSION_MAJOR);
+  std::string ExeCand = T.getToolChain().GetProgramPath(VersionedTool.c_str());
+  if (!llvm::sys::fs::can_execute(ExeCand))
+ExeCand = T.getToolChain().GetProgramPath("llvm-spirv");
+
+  const char *Exec = C.getArgs().MakeArgString(ExeCand);
   C.addCommand(std::make_unique(JA, T, ResponseFileSupport::None(),
  Exec, CmdArgs, Input, Output));
 }

diff  --git a/clang/test/Driver/hipspv-toolchain.hip 
b/clang/test/Driver/hipspv-toolchain.hip
index 4602cd3fc8d68..4005d9889051f 100644
--- a/clang/test/Driver/hipspv-toolchain.hip
+++ b/clang/test/Driver/hipspv-toolchain.hip
@@ -34,3 +34,16 @@
 // CHECK-SAME: "-o" [[OBJ_HOST:".*o"]] "-x" "hip"
 
 // CHECK: {{".*ld.*"}} {{.*}}[[OBJ_HOST]]
+
+//-
+// Check llvm-spirv- is used if it is found in PATH.
+// RUN: mkdir -p %t/versioned
+// RUN: touch %t/versioned/llvm-spirv-%llvm-version-major \
+// RUN:   && chmod +x %t/versioned/llvm-spirv-%llvm-version-major
+// RUN: env "PATH=%t/versioned" %clang -### -target x86_64-linux-gnu \
+// RUN:   --offload=spirv64 --hip-path=%S/Inputs/hipspv -nohipwrapperinc \
+// RUN:   %s 2>&1 \
+// RUN:   | FileCheck -DVERSION=%llvm-version-major \
+// RUN:   --check-prefix=VERSIONED %s
+
+// VERSIONED: {{.*}}llvm-spirv-[[VERSION]]

diff  --git a/clang/test/Driver/spirv-toolchain.cl 
b/clang/test/Driver/spirv-toolchain.cl
index db3ee4d3fe02f..de818177cb19f 100644
--- a/clang/test/Driver/spirv-toolchain.cl
+++ b/clang/test/Driver/spirv-toolchain.cl
@@ -77,3 +77,13 @@
 
 // XTOR: {{llvm-spirv.*"}}
 // BACKEND-NOT: {{llvm-spirv.*"}}
+
+//-
+// Check llvm-spirv- is used if it is found in PATH.
+// RUN: mkdir -p %t/versioned
+// RUN: touch %t/versioned/llvm-spirv-%llvm-version-ma

[clang] [SPIR-V] Prefer llvm-spirv- tool (PR #77897)

2024-05-31 Thread Sven van Haastregt via cfe-commits
Henry =?utf-8?q?Linjamäki?= 
Message-ID:
In-Reply-To: 


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


[clang] [llvm] Intrinsic: introduce minimumnum and maximumnum (PR #93841)

2024-05-31 Thread Peter Waller via cfe-commits

peterwaller-arm wrote:

> @peterwaller-arm I noticed that in 
> `llvm/test/CodeGen/AArch64/combine_andor_with_cmps.ll`, `FMAXNUM_IEEE` is 
> claimed that it is not supported. While I noticed that `fmaxnm` follows the 
> rules of `maxNUM` of IEEE754-2008. Is there any other limitation of `fmaxnm`?

This is not an area I know a great deal about and I'm about to go on leave, so 
I'm probably not the best person to ask. Perhaps the author of the comment (on 
https://reviews.llvm.org/D159240) @kmitropoulou can help? Could the comment 
mean that it's not currently supported by LLVM rather than not supported by the 
ISA? I see that the details of how NaNs are handled matters. I'm afraid I don't 
have time to get to the bottom of this currently.


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


[clang] 196dca7 - [clang][analyzer][NFC] Improve docs of alpha.unix.BlockInCriticalSection (#93812)

2024-05-31 Thread via cfe-commits

Author: Endre Fülöp
Date: 2024-05-31T12:50:04+02:00
New Revision: 196dca7561b4c3865ef7d5e45c22d215619d7385

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

LOG: [clang][analyzer][NFC] Improve docs of alpha.unix.BlockInCriticalSection 
(#93812)

- Enhanced descriptions for blocking and critical section functions
- Added an additional code sample highlighting interleaved C and C++
style mutexes

Added: 


Modified: 
clang/docs/analyzer/checkers.rst

Removed: 




diff  --git a/clang/docs/analyzer/checkers.rst 
b/clang/docs/analyzer/checkers.rst
index 3a31708a1e9de..3881ceceeed6b 100644
--- a/clang/docs/analyzer/checkers.rst
+++ b/clang/docs/analyzer/checkers.rst
@@ -3135,17 +3135,26 @@ alpha.unix
 alpha.unix.BlockInCriticalSection (C)
 "
 Check for calls to blocking functions inside a critical section.
-Applies to: ``lock, unlock, sleep, getc, fgets, read, recv, 
pthread_mutex_lock,``
-`` pthread_mutex_unlock, mtx_lock, mtx_timedlock, mtx_trylock, mtx_unlock, 
lock_guard, unique_lock``
+Blocking functions detected by this checker: ``sleep, getc, fgets, read, 
recv``.
+Critical section handling functions modelled by this checker: ``lock, unlock, 
pthread_mutex_lock, pthread_mutex_trylock, pthread_mutex_unlock, mtx_lock, 
mtx_timedlock, mtx_trylock, mtx_unlock, lock_guard, unique_lock``.
 
 .. code-block:: c
 
- void test() {
-   std::mutex m;
-   m.lock();
-   sleep(3); // warn: a blocking function sleep is called inside a critical
- //   section
-   m.unlock();
+ void pthread_lock_example(pthread_mutex_t *m) {
+   pthread_mutex_lock(m); // note: entering critical section here
+   sleep(10); // warn: Call to blocking function 'sleep' inside of critical 
section
+   pthread_mutex_unlock(m);
+ }
+
+.. code-block:: cpp
+
+ void overlapping_critical_sections(mtx_t *m1, std::mutex &m2) {
+   std::lock_guard lg{m2}; // note: entering critical section here
+   mtx_lock(m1); // note: entering critical section here
+   sleep(10); // warn: Call to blocking function 'sleep' inside of critical 
section
+   mtx_unlock(m1);
+   sleep(10); // warn: Call to blocking function 'sleep' inside of critical 
section
+ // still inside of the critical section of the std::lock_guard
  }
 
 .. _alpha-unix-Chroot:



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


[clang] [clang][analyzer][NFC] Improve docs of alpha.unix.BlockInCriticalSection (PR #93812)

2024-05-31 Thread Endre Fülöp via cfe-commits

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


[clang] [clang][CodeGen] `used` globals && the payloads for global ctors & dtors are globals (PR #93601)

2024-05-31 Thread Matt Arsenault via cfe-commits


@@ -2928,12 +2928,13 @@ static void emitUsed(CodeGenModule &CGM, StringRef Name,
   for (unsigned i = 0, e = List.size(); i != e; ++i) {
 UsedArray[i] =
 llvm::ConstantExpr::getPointerBitCastOrAddrSpaceCast(
-cast(&*List[i]), CGM.Int8PtrTy);

arsenm wrote:

You aren't emitting a real global, it's this fake special case IR construct. It 
doesn't fit into the boxes provided by the target global/program/alloca address 
spaces 

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


[clang] 46b3145 - [clang][analyzer][NFC] Add test for a limitation of alpha.unix.BlockInCriticalSection checker (#93799)

2024-05-31 Thread via cfe-commits

Author: Endre Fülöp
Date: 2024-05-31T12:51:14+02:00
New Revision: 46b3145b7c6bbe7014f9e790236717e4f8a711d8

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

LOG: [clang][analyzer][NFC] Add test for a limitation of 
alpha.unix.BlockInCriticalSection checker (#93799)

Updated the documentation in `checkers.rst` to include an example of how
`trylock` function is handled.
Added a new test for a scenario where `pthread_mutex_trylock` is used,
demonstrating the current limitation.

Added: 


Modified: 
clang/docs/analyzer/checkers.rst
clang/test/Analysis/block-in-critical-section.cpp

Removed: 




diff  --git a/clang/docs/analyzer/checkers.rst 
b/clang/docs/analyzer/checkers.rst
index 3881ceceeed6b..bbc31832b9c3c 100644
--- a/clang/docs/analyzer/checkers.rst
+++ b/clang/docs/analyzer/checkers.rst
@@ -3157,6 +3157,22 @@ Critical section handling functions modelled by this 
checker: ``lock, unlock, pt
  // still inside of the critical section of the std::lock_guard
  }
 
+**Limitations**
+
+* The ``trylock`` and ``timedlock`` versions of acquiring locks are currently 
assumed to always succeed.
+  This can lead to false positives.
+
+.. code-block:: c
+
+ void trylock_example(pthread_mutex_t *m) {
+   if (pthread_mutex_trylock(m) == 0) { // assume trylock always succeeds
+ sleep(10); // warn: Call to blocking function 'sleep' inside of critical 
section
+ pthread_mutex_unlock(m);
+   } else {
+ sleep(10); // false positive: Incorrect warning about blocking function 
inside critical section.
+   }
+ }
+
 .. _alpha-unix-Chroot:
 
 alpha.unix.Chroot (C)

diff  --git a/clang/test/Analysis/block-in-critical-section.cpp 
b/clang/test/Analysis/block-in-critical-section.cpp
index 87c26b9f1b520..403b7a16726a2 100644
--- a/clang/test/Analysis/block-in-critical-section.cpp
+++ b/clang/test/Analysis/block-in-critical-section.cpp
@@ -36,15 +36,15 @@ ssize_t read(int fd, void *buf, size_t count);
 ssize_t recv(int sockfd, void *buf, size_t len, int flags);
 
 struct pthread_mutex_t;
-void pthread_mutex_lock(pthread_mutex_t *mutex);
-void pthread_mutex_trylock(pthread_mutex_t *mutex);
-void pthread_mutex_unlock(pthread_mutex_t *mutex);
+int pthread_mutex_lock(pthread_mutex_t *mutex);
+int pthread_mutex_trylock(pthread_mutex_t *mutex);
+int pthread_mutex_unlock(pthread_mutex_t *mutex);
 
 struct mtx_t;
-void mtx_lock(mtx_t *mutex);
-void mtx_timedlock(mtx_t *mutex);
-void mtx_trylock(mtx_t *mutex);
-void mtx_unlock(mtx_t *mutex);
+int mtx_lock(mtx_t *mutex);
+int mtx_timedlock(mtx_t *mutex);
+int mtx_trylock(mtx_t *mutex);
+int mtx_unlock(mtx_t *mutex);
 
 // global params for dummy function calls
 FILE *stream;
@@ -292,3 +292,20 @@ void testBlockInCriticalSectionUniqueLockNested() {
   testBlockInCriticalSectionUniqueLock(); // expected-note {{Calling 
'testBlockInCriticalSectionUniqueLock'}}
   sleep(1); // no-warning
 }
+
+void testTrylockCurrentlyFalsePositive(pthread_mutex_t *m) {
+   // expected-note@+4 {{Assuming the 
condition is true}}
+   // expected-note@+3 {{Taking true 
branch}}
+   // expected-note@+2 {{Assuming the 
condition is false}}
+   // expected-note@+1 {{Taking false 
branch}}
+  if (pthread_mutex_trylock(m) == 0) { // expected-note 2 {{Entering critical 
section here}}
+   // FIXME: we are entering the critical 
section only in the true branch
+sleep(10); // expected-warning {{Call to blocking function 'sleep' inside 
of critical section}}
+   // expected-note@-1 {{Call to blocking function 'sleep' inside 
of critical section}}
+pthread_mutex_unlock(m);
+  } else {
+sleep(10); // expected-warning {{Call to blocking function 'sleep' inside 
of critical section}}
+   // expected-note@-1 {{Call to blocking function 'sleep' inside 
of critical section}}
+   // FIXME: this is a false positive, the lock was not acquired
+  }
+}



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


[clang] [clang][analyzer][NFC] Add test for a limitation of alpha.unix.Bloc… (PR #93799)

2024-05-31 Thread Endre Fülöp via cfe-commits

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


[clang] remove goma support from clang (PR #93942)

2024-05-31 Thread Aaron Ballman via cfe-commits

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

LGTM!

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


[clang] [llvm] [clang][CodeGen] Global constructors/destructors are globals (PR #93914)

2024-05-31 Thread Matt Arsenault via cfe-commits

arsenm wrote:

> The third argument here is like for llvm.used, it's a way to associate the 
> entry with a global or function. If the corresponding global or function is 
> omitted from the output then the entry will be removed. It isn't used for 
> anything at run time. So I think there should be a consistent story between 
> llvm.used and llvm.global_[cd]tors.

I briefly skimmed the codegen and as far as I could tell an addrspacecast 
constant expression in global_ctors won't do the right thing, we probably 
should fix that too 

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


[clang] [clang][analyzer] Move unix.BlockInCriticalSection out of alpha (PR #93815)

2024-05-31 Thread Endre Fülöp via cfe-commits

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


[clang] [clang][analyzer] Move unix.BlockInCriticalSection out of alpha (PR #93815)

2024-05-31 Thread Endre Fülöp via cfe-commits

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


[clang] [clang][analyzer] Move unix.BlockInCriticalSection out of alpha (PR #93815)

2024-05-31 Thread via cfe-commits
Endre =?utf-8?q?Fülöp?= 
Message-ID:
In-Reply-To: 


llvmbot wrote:



@llvm/pr-subscribers-clang-static-analyzer-1

@llvm/pr-subscribers-clang

Author: Endre Fülöp (gamesh411)


Changes

After recent improvements, and testing on open source projects, the
checker is ready to move out of the alpha package.

I would like to land #93799 and #93799 first, then this 
modification.

I have ran this checker on multiple OS projects, and found no false positives, 
and only 10 true ones.
The complete set of tested projects:
codechecker, memcached, tmux, curl, twin, vim, openssl, sqlite, ffmpeg, 
postgres, tinyxml2, libwebm, xerces, bitcoin, protobuf, qtbase, openrct2, 
llvm-project.

The results for this checker:

https://codechecker-demo.eastus.cloudapp.azure.com/Default/reports?run=bitcoin_v0.20.1_alpha.unix.BlockInCriticalSection-evaluation&is-unique=on&diff-type=New&checker-name=alpha.unix.BlockInCriticalSection

https://codechecker-demo.eastus.cloudapp.azure.com/Default/reports?run=qtbase_v6.2.0_alpha.unix.BlockInCriticalSection-evaluation&is-unique=on&diff-type=New&checker-name=alpha.unix.BlockInCriticalSection

https://codechecker-demo.eastus.cloudapp.azure.com/Default/reports?run=openrct2_v0.4.8_alpha.unix.BlockInCriticalSection-evaluation&is-unique=on&diff-type=New&checker-name=alpha.unix.BlockInCriticalSection

Also note that even if I just merged a commit admitting to one of this 
checker's limitations (that can lead to false positives), these OS project runs 
did not show any, so it currently does not seem to be a very prominent 
limitation.
Please see this comment 
https://github.com/llvm/llvm-project/pull/93799#issuecomment-2141496323 for my 
plans to deal with this limitation and reduce code duplication.

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


8 Files Affected:

- (modified) clang/docs/analyzer/checkers.rst (+19-18) 
- (modified) clang/include/clang/StaticAnalyzer/Checkers/Checkers.td (+4-4) 
- (modified) clang/test/Analysis/analyzer-enabled-checkers.c (+1) 
- (modified) clang/test/Analysis/block-in-critical-section.c (+1-1) 
- (modified) clang/test/Analysis/block-in-critical-section.cpp (+1-1) 
- (modified) clang/test/Analysis/block-in-critical-section.m (+1-1) 
- (modified) clang/test/Analysis/std-c-library-functions-arg-enabled-checkers.c 
(+1) 
- (modified) clang/www/analyzer/alpha_checks.html (-33) 


``diff
diff --git a/clang/docs/analyzer/checkers.rst b/clang/docs/analyzer/checkers.rst
index 3a31708a1e9de..86412bd3b9294 100644
--- a/clang/docs/analyzer/checkers.rst
+++ b/clang/docs/analyzer/checkers.rst
@@ -1235,6 +1235,25 @@ Check calls to various UNIX/Posix functions: ``open, 
pthread_once, calloc, mallo
 .. literalinclude:: checkers/unix_api_example.c
 :language: c
 
+.. _unix-BlockInCriticalSection:
+
+unix.BlockInCriticalSection (C)
+"
+
+Check for calls to blocking functions inside a critical section.
+Applies to: ``lock, unlock, sleep, getc, fgets, read, recv, 
pthread_mutex_lock,``
+`` pthread_mutex_unlock, mtx_lock, mtx_timedlock, mtx_trylock, mtx_unlock, 
lock_guard, unique_lock``
+
+.. code-block:: c
+
+ void test() {
+   std::mutex m;
+   m.lock();
+   sleep(3); // warn: a blocking function sleep is called inside a critical
+ //   section
+   m.unlock();
+ }
+
 .. _unix-Errno:
 
 unix.Errno (C)
@@ -3130,24 +3149,6 @@ For a more detailed description of configuration 
options, please see the
 alpha.unix
 ^^
 
-.. _alpha-unix-BlockInCriticalSection:
-
-alpha.unix.BlockInCriticalSection (C)
-"
-Check for calls to blocking functions inside a critical section.
-Applies to: ``lock, unlock, sleep, getc, fgets, read, recv, 
pthread_mutex_lock,``
-`` pthread_mutex_unlock, mtx_lock, mtx_timedlock, mtx_trylock, mtx_unlock, 
lock_guard, unique_lock``
-
-.. code-block:: c
-
- void test() {
-   std::mutex m;
-   m.lock();
-   sleep(3); // warn: a blocking function sleep is called inside a critical
- //   section
-   m.unlock();
- }
-
 .. _alpha-unix-Chroot:
 
 alpha.unix.Chroot (C)
diff --git a/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td 
b/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
index 40f443047bd4b..668e9f6cf0716 100644
--- a/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
+++ b/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
@@ -509,6 +509,10 @@ def UnixAPIMisuseChecker : Checker<"API">,
   HelpText<"Check calls to various UNIX/Posix functions">,
   Documentation;
 
+def BlockInCriticalSectionChecker : Checker<"BlockInCriticalSection">,
+  HelpText<"Check for calls to blocking functions inside a critical section">,
+  Documentation;
+
 def DynamicMemoryModeling: Checker<"DynamicMemoryModeling">,
   HelpText<"The base of several malloc() related checkers. On it's own it "
"emits no reports, but adds valuable information to the analysis "
@@ -619,10 +623,6 @@ def SimpleStreamChecker : Check

[clang] [clang] ``README.txt``: Replace the link to the old bug tracker with the new one. (PR #93878)

2024-05-31 Thread Aaron Ballman via cfe-commits

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

LGTM! Do you need someone to land this on your behalf?

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


[clang] [Clang][Sema] Push an evaluation context for type constraints (PR #93945)

2024-05-31 Thread via cfe-commits


@@ -5004,6 +5004,20 @@ static bool CheckDeducedPlaceholderConstraints(Sema &S, 
const AutoType &Type,
 return true;
   MultiLevelTemplateArgumentList MLTAL(Concept, CanonicalConverted,
/*Final=*/false);
+  // Build up an EvaluationContext with an ImplicitConceptSpecializationDecl so
+  // that the template arguments of the constraint can be preserved. For
+  // example:
+  //
+  //  template 
+  //  concept C = []() { return true; }();
+  //
+  // We need the argument for T while evaluating type constraint D in
+  // building the CallExpr to the lambda.
+  EnterExpressionEvaluationContext EECtx(
+  S, Sema::ExpressionEvaluationContext::ConstantEvaluated,

cor3ntin wrote:

Should that not be UnevaluatedContext?
https://eel.is/c++draft/temp.concept#6

(I appreciate the great comment, thanks!)

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


[clang] [clang][analyzer] Move unix.BlockInCriticalSection out of alpha (PR #93815)

2024-05-31 Thread Endre Fülöp via cfe-commits

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


[clang] [llvm] [RISCV] Remove experimental from Zabha (PR #93831)

2024-05-31 Thread via cfe-commits

AlexGhiti wrote:

Damn, I missed it, good catch, thanks.

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


[clang] [llvm] [RISCV] Remove experimental from Zabha (PR #93831)

2024-05-31 Thread via cfe-commits

https://github.com/AlexGhiti updated 
https://github.com/llvm/llvm-project/pull/93831

>From 64a56e792ce57cd807aebd7113a1180275f3547e Mon Sep 17 00:00:00 2001
From: Alexandre Ghiti 
Date: Thu, 30 May 2024 14:39:20 +
Subject: [PATCH] [RISCV] Remove experimental from Zabha

The Zabha extension was ratified in April 2024.
---
 .../test/Preprocessor/riscv-target-features.c  | 18 +-
 llvm/docs/RISCVUsage.rst   |  4 +---
 llvm/docs/ReleaseNotes.rst |  1 +
 llvm/lib/Target/RISCV/RISCVFeatures.td |  4 ++--
 .../RISCV/atomic-cmpxchg-branch-on-result.ll   |  2 +-
 llvm/test/CodeGen/RISCV/atomic-cmpxchg.ll  |  4 ++--
 llvm/test/CodeGen/RISCV/atomic-rmw.ll  |  8 
 llvm/test/CodeGen/RISCV/attributes.ll  |  4 ++--
 llvm/test/MC/RISCV/rvzabha-invalid.s   |  4 ++--
 llvm/test/MC/RISCV/rvzabha-valid.s | 12 ++--
 llvm/test/MC/RISCV/rvzabha-zacas-valid.s   | 16 
 .../TargetParser/RISCVISAInfoTest.cpp  |  2 +-
 12 files changed, 39 insertions(+), 40 deletions(-)

diff --git a/clang/test/Preprocessor/riscv-target-features.c 
b/clang/test/Preprocessor/riscv-target-features.c
index 0865add7e8fb8..09b9ad0a160bb 100644
--- a/clang/test/Preprocessor/riscv-target-features.c
+++ b/clang/test/Preprocessor/riscv-target-features.c
@@ -80,6 +80,7 @@
 // CHECK-NOT: __riscv_za128rs {{.*$}}
 // CHECK-NOT: __riscv_za64rs {{.*$}}
 // CHECK-NOT: __riscv_zaamo {{.*$}}
+// CHECK-NOT: __riscv_zabha {{.*$}}
 // CHECK-NOT: __riscv_zacas {{.*$}}
 // CHECK-NOT: __riscv_zalrsc {{.*$}}
 // CHECK-NOT: __riscv_zama16b {{.*$}}
@@ -176,7 +177,6 @@
 // CHECK-NOT: __riscv_sspm{{.*$}}
 // CHECK-NOT: __riscv_ssqosid{{.*$}}
 // CHECK-NOT: __riscv_supm{{.*$}}
-// CHECK-NOT: __riscv_zabha {{.*$}}
 // CHECK-NOT: __riscv_zalasr {{.*$}}
 // CHECK-NOT: __riscv_zfbfmin {{.*$}}
 // CHECK-NOT: __riscv_zicfilp {{.*$}}
@@ -715,6 +715,14 @@
 // RUN:   -o - | FileCheck --check-prefix=CHECK-ZAAMO-EXT %s
 // CHECK-ZAAMO-EXT: __riscv_zaamo 100{{$}}
 
+// RUN: %clang --target=riscv32 \
+// RUN:   -march=rv32ia_zabha1p0 -E -dM %s \
+// RUN:   -o - | FileCheck --check-prefix=CHECK-ZABHA-EXT %s
+// RUN: %clang --target=riscv64 \
+// RUN:   -march=rv64ia_zabha1p0 -E -dM %s \
+// RUN:   -o - | FileCheck --check-prefix=CHECK-ZABHA-EXT %s
+// CHECK-ZABHA-EXT: __riscv_zabha 100{{$}}
+
 // RUN: %clang --target=riscv32 \
 // RUN:   -march=rv32ia_zacas1p0 -E -dM %s \
 // RUN:   -o - | FileCheck --check-prefix=CHECK-ZACAS-EXT %s
@@ -1570,14 +1578,6 @@
 // CHECK-ZVKT-EXT: __riscv_zvkt 100{{$}}
 
 // Experimental extensions
-// RUN: %clang --target=riscv32 -menable-experimental-extensions \
-// RUN:   -march=rv32ia_zabha1p0 -E -dM %s \
-// RUN:   -o - | FileCheck --check-prefix=CHECK-ZABHA-EXT %s
-// RUN: %clang --target=riscv64 -menable-experimental-extensions \
-// RUN:   -march=rv64ia_zabha1p0 -E -dM %s \
-// RUN:   -o - | FileCheck --check-prefix=CHECK-ZABHA-EXT %s
-// CHECK-ZABHA-EXT: __riscv_zabha 100{{$}}
-
 // RUN: %clang --target=riscv32 -menable-experimental-extensions \
 // RUN:   -march=rv32i_zalasr0p1 -E -dM %s \
 // RUN:   -o - | FileCheck --check-prefix=CHECK-ZALASR-EXT %s
diff --git a/llvm/docs/RISCVUsage.rst b/llvm/docs/RISCVUsage.rst
index 5ecee2a480f7d..35115e67ecf92 100644
--- a/llvm/docs/RISCVUsage.rst
+++ b/llvm/docs/RISCVUsage.rst
@@ -120,6 +120,7 @@ on support follow.
  ``Za128rs``   Supported (`See note 
<#riscv-profiles-extensions-note>`__)
  ``Za64rs``Supported (`See note 
<#riscv-profiles-extensions-note>`__)
  ``Zaamo`` Assembly Support
+ ``Zabha`` Supported
  ``Zacas`` Supported (`See note <#riscv-zacas-note>`__)
  ``Zalrsc``Assembly Support
  ``Zama16b``   Supported (`See note 
<#riscv-profiles-extensions-note>`__)
@@ -262,9 +263,6 @@ The primary goal of experimental support is to assist in 
the process of ratifica
 ``experimental-ssqosid``
   LLVM implements assembler support for the `v1.0-rc1 draft specification 
`_.
 
-``experimental-zabha``
-  LLVM implements the `v1.0-rc1 draft specification 
`__.
-
 ``experimental-zalasr``
   LLVM implements the `0.0.5 draft specification 
`__.
 
diff --git a/llvm/docs/ReleaseNotes.rst b/llvm/docs/ReleaseNotes.rst
index c7c2c2825f58b..32ec26bf1dcb2 100644
--- a/llvm/docs/ReleaseNotes.rst
+++ b/llvm/docs/ReleaseNotes.rst
@@ -136,6 +136,7 @@ Changes to the RISC-V Backend
 * Added smstateen extension to -march. CSR names for smstateen were already 
supported.
 * Zaamo and Zalrsc are no longer experimental.
 * Processors that enable post reg-alloc scheduling (PostMachineScheduler) by 
default should use the `UsePostRAScheduler` subtarget feature. Setting 
`PostRAScheduler = 1` in the scheduler model will have no effect on the 
ena

[clang] [Clang] Implement P3034R1 Module Declarations Shouldn’t be Macros (PR #90574)

2024-05-31 Thread Aaron Ballman via cfe-commits


@@ -1329,6 +1341,100 @@ bool Preprocessor::LexAfterModuleImport(Token &Result) {
   return true;
 }
 
+/// Lex a token following the 'module' contextual keyword.
+///
+/// [cpp.module]/p2:
+/// The pp-tokens, if any, of a pp-module shall be of the form:
+///   pp-module-name pp-module-partition[opt] pp-tokens[opt]
+///
+/// where the pp-tokens (if any) shall not begin with a ( preprocessing token
+/// and the grammar non-terminals are defined as:
+///   pp-module-name:
+/// pp-module-name-qualifierp[opt] identifier
+///   pp-module-partition:
+/// : pp-module-name-qualifier[opt] identifier
+///   pp-module-name-qualifier:
+/// identifier .
+/// pp-module-name-qualifier identifier .
+/// No identifier in the pp-module-name or pp-module-partition shall currently
+/// be defined as an object-like macro.
+///
+/// [cpp.module]/p3:
+/// Any preprocessing tokens after the module preprocessing token in the module
+/// directive are processed just as in normal text.
+bool Preprocessor::LexAfterModuleDecl(Token &Result) {
+  // Figure out what kind of lexer we actually have.
+  recomputeCurLexerKind();
+  LexUnexpandedToken(Result);
+
+  auto EnterTokens = [this](ArrayRef Toks, bool DisableMacroExpansion) {
+auto ToksCopy = std::make_unique(Toks.size());
+std::copy(Toks.begin(), Toks.end(), ToksCopy.get());
+EnterTokenStream(std::move(ToksCopy), Toks.size(), DisableMacroExpansion,
+ /*IsReinject=*/false);
+  };
+
+  // If we don't expect an identifier but got an identifier, it's not a part of
+  // module name.
+  if (!ModuleDeclExpectsIdentifier && Result.is(tok::identifier)) {
+EnterTokens(Result, /*DisableMacroExpansion=*/false);
+return false;
+  }
+
+  // The token sequence
+  //
+  // export[opt] module identifier (. identifier)*
+  //
+  // indicates a module directive. We already saw the 'module'
+  // contextual keyword, so now we're looking for the identifiers.
+  if (ModuleDeclExpectsIdentifier && Result.is(tok::identifier)) {
+auto *MI = getMacroInfo(Result.getIdentifierInfo());
+if (MI && MI->isObjectLike()) {
+  Diag(Result, diag::err_module_decl_cannot_be_macros)
+  << Result.getLocation() << ModuleDeclLexingPartitionName
+  << Result.getIdentifierInfo();
+}
+ModuleDeclExpectsIdentifier = false;
+CurLexerCallback = CLK_LexAfterModuleDecl;
+return true;
+  }
+
+  // If we're expecting a '.', a ':' or a ';', and we got a '.', then wait 
until
+  // we see the next identifier.
+  if (!ModuleDeclExpectsIdentifier && Result.isOneOf(tok::period, tok::colon)) 
{
+ModuleDeclExpectsIdentifier = true;
+ModuleDeclLexingPartitionName = Result.is(tok::colon);
+CurLexerCallback = CLK_LexAfterModuleDecl;
+return true;
+  }
+
+  // [cpp.module]/p2: where the pp-tokens (if any) shall not begin with a (
+  // preprocessing token [...]
+  if (!ModuleDeclExpectsIdentifier && Result.is(tok::l_paren)) {
+ModuleDeclExpectsIdentifier = false;
+Diag(Result, diag::err_unxepected_paren_in_module_decl)
+<< ModuleDeclLexingPartitionName;
+Token Tok;
+// We already have a '('.
+unsigned NumParens = 1;
+while (true) {
+  LexUnexpandedToken(Tok);
+  if (Tok.isOneOf(tok::eod, tok::eof, tok::semi, tok::period, tok::colon)) 
{
+EnterTokens(Tok, /*DisableMacroExpansion=*/true);
+break;
+  }
+  if (Tok.is(tok::l_paren))
+NumParens++;
+  else if (Tok.is(tok::r_paren) && --NumParens == 0)
+break;
+}
+CurLexerCallback = CLK_LexAfterModuleDecl;
+return false;
+  }
+
+  return true;
+}
+

AaronBallman wrote:

> I am not sure I under why we would actually consume ATTRS in either case, but 
> I think I need to think about it more / play with the PR.

I'd like to understand this better, too. I would have (naively and without 
checking in a debugger) that we would have peeked at `ATTRS` rather than 
consumed it.

> @AaronBallman Any opinion?

I think your suggestion makes sense to me; that's a good use of annotation 
tokens to squirrel information from the preprocessor into the parser, and 
keeping the logic consolidated as much as possible is preferred.

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


[clang] [llvm] Add option to generate additional debug info for expression dereferencing pointer to pointers. (PR #81545)

2024-05-31 Thread Aaron Ballman via cfe-commits

AaronBallman wrote:

> How do I reopen the PR after fixing the test case?

AIUI, you cannot reopen a merged PR, you have to start a new PR and mention the 
old one to link the two together.

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


[clang] [llvm] [AMDGPU] Implement variadic functions by IR lowering (PR #93362)

2024-05-31 Thread Matt Arsenault via cfe-commits


@@ -0,0 +1,1023 @@
+//===-- ExpandVariadicsPass.cpp *- C++ -*-=//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This is an optimization pass for variadic functions. If called from codegen,
+// it can serve as the implementation of variadic functions for a given target.
+//
+// The strategy is to turn the ... part of a variadic function into a va_list
+// and fix up the call sites. The majority of the pass is target independent.
+// The exceptions are the va_list type itself and the rules for where to store
+// variables in memory such that va_arg can iterate over them given a va_list.
+//
+// The majority of the plumbing is splitting the variadic function into a
+// single basic block that packs the variadic arguments into a va_list and
+// a second function that does the work of the original. That packing is
+// exactly what is done by va_start. Further, the transform from ... to va_list
+// replaced va_start with an operation to copy a va_list from the new argument,
+// which is exactly a va_copy. This is useful for reducing target-dependence.
+//
+// A va_list instance is a forward iterator, where the primary operation va_arg
+// is dereference-then-increment. This interface forces significant convergent
+// evolution between target specific implementations. The variation in runtime
+// data layout is limited to that representable by the iterator, parameterised
+// by the type passed to the va_arg instruction.
+//
+// Therefore the majority of the target specific subtlety is packing arguments
+// into a stack allocated buffer such that a va_list can be initialised with it
+// and the va_arg expansion for the target will find the arguments at runtime.
+//
+// The aggregate effect is to unblock other transforms, most critically the
+// general purpose inliner. Known calls to variadic functions become zero cost.
+//
+// Consistency with clang is primarily tested by emitting va_arg using clang
+// then expanding the variadic functions using this pass, followed by trying
+// to constant fold the functions to no-ops.
+//
+// Target specific behaviour is tested in IR - mainly checking that values are
+// put into positions in call frames that make sense for that particular 
target.
+//
+// There is one "clever" invariant in use. va_start intrinsics that are not
+// within a varidic functions are an error in the IR verifier. When this
+// transform moves blocks from a variadic function into a fixed arity one, it
+// moves va_start intrinsics along with everything else. That means that the
+// va_start intrinsics that need to be rewritten to use the trailing argument
+// are exactly those that are in non-variadic functions so no further state
+// is needed to distinguish those that need to be rewritten.
+//
+//===--===//
+
+#include "llvm/Transforms/IPO/ExpandVariadics.h"
+#include "llvm/ADT/SmallVector.h"
+#include "llvm/CodeGen/Passes.h"
+#include "llvm/IR/Constants.h"
+#include "llvm/IR/IRBuilder.h"
+#include "llvm/IR/IntrinsicInst.h"
+#include "llvm/IR/Module.h"
+#include "llvm/IR/PassManager.h"
+#include "llvm/InitializePasses.h"
+#include "llvm/Pass.h"
+#include "llvm/Passes/OptimizationLevel.h"
+#include "llvm/Support/CommandLine.h"
+#include "llvm/TargetParser/Triple.h"
+#include "llvm/Transforms/Utils/ModuleUtils.h"
+
+#define DEBUG_TYPE "expand-variadics"
+
+using namespace llvm;
+
+namespace {
+
+cl::opt ExpandVariadicsModeOption(
+DEBUG_TYPE "-override", cl::desc("Override the behaviour of " DEBUG_TYPE),
+cl::init(ExpandVariadicsMode::Unspecified),
+cl::values(clEnumValN(ExpandVariadicsMode::Unspecified, "unspecified",
+  "Use the implementation defaults"),
+   clEnumValN(ExpandVariadicsMode::Disable, "disable",
+  "Disable the pass entirely"),
+   clEnumValN(ExpandVariadicsMode::Optimize, "optimize",
+  "Optimise without changing ABI"),
+   clEnumValN(ExpandVariadicsMode::Lowering, "lowering",
+  "Change variadic calling convention")));
+
+bool commandLineOverride() {
+  return ExpandVariadicsModeOption != ExpandVariadicsMode::Unspecified;
+}
+
+// Instances of this class encapsulate the target-dependant behaviour as a
+// function of triple. Implementing a new ABI is adding a case to the switch
+// in create(llvm::Triple) at the end of this file.
+class VariadicABIInfo {
+protected:
+  VariadicABIInfo() {}
+
+public:
+  static std::unique_ptr create(llvm::Triple const &Triple);
+
+  // Allow overriding whether the pass runs on a per-target basis
+  virtual bool enableForTarget() = 0;
+
+  

[clang] [llvm] [AMDGPU] Implement variadic functions by IR lowering (PR #93362)

2024-05-31 Thread Matt Arsenault via cfe-commits


@@ -0,0 +1,1023 @@
+//===-- ExpandVariadicsPass.cpp *- C++ -*-=//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This is an optimization pass for variadic functions. If called from codegen,
+// it can serve as the implementation of variadic functions for a given target.
+//
+// The strategy is to turn the ... part of a variadic function into a va_list
+// and fix up the call sites. The majority of the pass is target independent.
+// The exceptions are the va_list type itself and the rules for where to store
+// variables in memory such that va_arg can iterate over them given a va_list.
+//
+// The majority of the plumbing is splitting the variadic function into a
+// single basic block that packs the variadic arguments into a va_list and
+// a second function that does the work of the original. That packing is
+// exactly what is done by va_start. Further, the transform from ... to va_list
+// replaced va_start with an operation to copy a va_list from the new argument,
+// which is exactly a va_copy. This is useful for reducing target-dependence.
+//
+// A va_list instance is a forward iterator, where the primary operation va_arg
+// is dereference-then-increment. This interface forces significant convergent
+// evolution between target specific implementations. The variation in runtime
+// data layout is limited to that representable by the iterator, parameterised
+// by the type passed to the va_arg instruction.
+//
+// Therefore the majority of the target specific subtlety is packing arguments
+// into a stack allocated buffer such that a va_list can be initialised with it
+// and the va_arg expansion for the target will find the arguments at runtime.
+//
+// The aggregate effect is to unblock other transforms, most critically the
+// general purpose inliner. Known calls to variadic functions become zero cost.
+//
+// Consistency with clang is primarily tested by emitting va_arg using clang
+// then expanding the variadic functions using this pass, followed by trying
+// to constant fold the functions to no-ops.
+//
+// Target specific behaviour is tested in IR - mainly checking that values are
+// put into positions in call frames that make sense for that particular 
target.
+//
+// There is one "clever" invariant in use. va_start intrinsics that are not
+// within a varidic functions are an error in the IR verifier. When this
+// transform moves blocks from a variadic function into a fixed arity one, it
+// moves va_start intrinsics along with everything else. That means that the
+// va_start intrinsics that need to be rewritten to use the trailing argument
+// are exactly those that are in non-variadic functions so no further state
+// is needed to distinguish those that need to be rewritten.
+//
+//===--===//
+
+#include "llvm/Transforms/IPO/ExpandVariadics.h"
+#include "llvm/ADT/SmallVector.h"
+#include "llvm/CodeGen/Passes.h"
+#include "llvm/IR/Constants.h"
+#include "llvm/IR/IRBuilder.h"
+#include "llvm/IR/IntrinsicInst.h"
+#include "llvm/IR/Module.h"
+#include "llvm/IR/PassManager.h"
+#include "llvm/InitializePasses.h"
+#include "llvm/Pass.h"
+#include "llvm/Passes/OptimizationLevel.h"
+#include "llvm/Support/CommandLine.h"
+#include "llvm/TargetParser/Triple.h"
+#include "llvm/Transforms/Utils/ModuleUtils.h"
+
+#define DEBUG_TYPE "expand-variadics"
+
+using namespace llvm;
+
+namespace {
+
+cl::opt ExpandVariadicsModeOption(
+DEBUG_TYPE "-override", cl::desc("Override the behaviour of " DEBUG_TYPE),
+cl::init(ExpandVariadicsMode::Unspecified),
+cl::values(clEnumValN(ExpandVariadicsMode::Unspecified, "unspecified",
+  "Use the implementation defaults"),
+   clEnumValN(ExpandVariadicsMode::Disable, "disable",
+  "Disable the pass entirely"),
+   clEnumValN(ExpandVariadicsMode::Optimize, "optimize",
+  "Optimise without changing ABI"),
+   clEnumValN(ExpandVariadicsMode::Lowering, "lowering",
+  "Change variadic calling convention")));
+
+bool commandLineOverride() {
+  return ExpandVariadicsModeOption != ExpandVariadicsMode::Unspecified;
+}
+
+// Instances of this class encapsulate the target-dependant behaviour as a
+// function of triple. Implementing a new ABI is adding a case to the switch
+// in create(llvm::Triple) at the end of this file.
+class VariadicABIInfo {
+protected:
+  VariadicABIInfo() {}
+
+public:
+  static std::unique_ptr create(llvm::Triple const &Triple);
+
+  // Allow overriding whether the pass runs on a per-target basis
+  virtual bool enableForTarget() = 0;
+
+  

[clang] [Clang][Sema] Push an evaluation context for type constraints (PR #93945)

2024-05-31 Thread Younan Zhang via cfe-commits


@@ -5004,6 +5004,20 @@ static bool CheckDeducedPlaceholderConstraints(Sema &S, 
const AutoType &Type,
 return true;
   MultiLevelTemplateArgumentList MLTAL(Concept, CanonicalConverted,
/*Final=*/false);
+  // Build up an EvaluationContext with an ImplicitConceptSpecializationDecl so
+  // that the template arguments of the constraint can be preserved. For
+  // example:
+  //
+  //  template 
+  //  concept C = []() { return true; }();
+  //
+  // We need the argument for T while evaluating type constraint D in
+  // building the CallExpr to the lambda.
+  EnterExpressionEvaluationContext EECtx(
+  S, Sema::ExpressionEvaluationContext::ConstantEvaluated,

zyn0217 wrote:

Good question. Honestly, I copied the line from `Sema::CheckConceptTemplateId`:

https://github.com/llvm/llvm-project/blob/f34dedbf44a0578430f81de94f294f4474fee0fb/clang/lib/Sema/SemaTemplate.cpp#L5662-L5670

I'll look into the details later and hopefully get back with an answer. (Of 
course I'd appreciate it if @erichkeane could beat me to it.)

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


[clang] [llvm] Conditionalize use of POSIX features missing on WASI/WebAssembly (PR #92677)

2024-05-31 Thread Aaron Ballman via cfe-commits

AaronBallman wrote:

Ah thank you for pointing that out, I had missed some updates on that thread.

I think `defined(__wasi__)` would address my concerns. @MaskRay asked a good 
question about whether we should tie this to `LLVM_ON_UNIX` as well and I don't 
have a strong intuition there, but my naive thinking is that it would help in 
some cases but be insufficient in others (e.g., within Support/Unix/Path.inc, 
we'd still need to have a conditional for WASI).

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


[clang] [SPIR-V] Prefer llvm-spirv- tool (PR #77897)

2024-05-31 Thread Henry Linjamäki via cfe-commits

linehill wrote:

Thanks, @svenvh.

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


[clang] [clang] require template arg list after template kw (PR #80801)

2024-05-31 Thread Aaron Ballman via cfe-commits

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


[clang] [clang] require template arg list after template kw (PR #80801)

2024-05-31 Thread Aaron Ballman via cfe-commits

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

I think the changes are reasonable, but I'd like to wait a bit before landing 
to give @erichkeane a chance to review as templates code owner.

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


[clang] [clang] require template arg list after template kw (PR #80801)

2024-05-31 Thread Aaron Ballman via cfe-commits


@@ -2995,13 +2996,23 @@ bool Parser::ParseUnqualifiedId(CXXScopeSpec &SS, 
ParsedType ObjectType,
   SS, ObjectType, ObjectHadErrors,
   TemplateKWLoc ? *TemplateKWLoc : SourceLocation(), Id, IdLoc,
   EnteringContext, Result, TemplateSpecified);
-else if (TemplateSpecified &&
- Actions.ActOnTemplateName(
- getCurScope(), SS, *TemplateKWLoc, Result, ObjectType,
- EnteringContext, Template,
- /*AllowInjectedClassName*/ true) == TNK_Non_template)
-  return true;
 
+if (TemplateSpecified) {
+  TemplateNameKind TNK =
+  Actions.ActOnTemplateName(getCurScope(), SS, *TemplateKWLoc, Result,
+ObjectType, EnteringContext, Template,
+/*AllowInjectedClassName*/ true);
+  if (TNK == TNK_Non_template)
+return true;
+
+  // C++ [template.names]p6
+  // A name prefixed by the keyword template shall be followed by a 
template
+  // argument list or refer to a class template or an alias template.
+  if ((TNK == TNK_Function_template || TNK == TNK_Dependent_template_name 
||

AaronBallman wrote:

I think it's reasonable to handle in a follow-up, thanks!

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


[clang] [llvm] Conditionalize use of POSIX features missing on WASI/WebAssembly (PR #92677)

2024-05-31 Thread via cfe-commits

whitequark wrote:

> but my naive thinking is that it would help in some cases but be insufficient 
> in others (e.g., within Support/Unix/Path.inc, we'd still need to have a 
> conditional for WASI).

`LLVM_ON_UNIX` is definitely a mixed bag for WASI and I'll take another look at 
whether it should be defined or not when I rework the patch to use 
`defined(__wasi__)` instead.

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


[clang] [clang] Lower _BitInt(129+) to a different type in LLVM IR (PR #91364)

2024-05-31 Thread Mariya Podchishchaeva via cfe-commits


@@ -761,6 +761,10 @@ bool ConstStructBuilder::Build(const InitListExpr *ILE, 
bool AllowOverwrite) {
   if (Field->hasAttr())
 AllowOverwrite = true;
 } else {
+  llvm::Type *LoadType = CGM.getTypes().convertTypeForLoadStore(

Fznamznon wrote:

In `ConstantEmitter::emitForMemory` we now split constant into individual bytes 
if the target type is a long `_BitInt`. However after an integer constant 
expected by `AppendBitField`, so this just folds individual bytes back to an 
integer. 

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


[clang] [clang] Lower _BitInt(129+) to a different type in LLVM IR (PR #91364)

2024-05-31 Thread Mariya Podchishchaeva via cfe-commits


@@ -1774,6 +1784,22 @@ llvm::Constant 
*ConstantEmitter::emitForMemory(CodeGenModule &CGM,
 return Res;
   }
 
+  if (destType->isBitIntType()) {
+if (!CGM.getTypes().LLVMTypeLayoutMatchesAST(destType, C->getType())) {
+  // Long _BitInt has array of bytes as in-memory type.
+  // So, split constant into individual bytes.
+  ConstantAggregateBuilder Builder(CGM);
+  llvm::Type *DesiredTy = CGM.getTypes().ConvertTypeForMem(destType);
+  // LLVM type doesn't match AST type only for big enough _BitInts, these
+  // types don't appear in constant expressions involving ptrtoint, so it
+  // is safe to expect a constant int here.
+  auto *CI = cast(C);
+  llvm::APInt Value = CI->getValue();
+  Builder.addBits(Value, /*OffsetInBits=*/0, /*AllowOverwrite=*/false);
+  return Builder.build(DesiredTy, /*AllowOversized*/ false);

Fznamznon wrote:

I'm not seeing `undef`s in resulting constants. `zeroinitializer` for all 
unused bytes is emitted instead. The test CodeGen/ext-int.c illustrates this 
behavior.

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


[clang] [clang] Lower _BitInt(129+) to a different type in LLVM IR (PR #91364)

2024-05-31 Thread Mariya Podchishchaeva via cfe-commits

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


[clang] [llvm] [RISCV] Add Smcsrind and Sscsrind extension (PR #93952)

2024-05-31 Thread via cfe-commits

https://github.com/YanWQ-monad created 
https://github.com/llvm/llvm-project/pull/93952

Specification link: https://github.com/riscvarchive/riscv-indirect-csr-access


The CSRs in Smcsrind/Sscsrind extensions are originally defined as part of the 
Smaia/Ssaia extensions, which are already supported in LLVM.

>From 3e0d38aa84506cd364174190893cb62008948a87 Mon Sep 17 00:00:00 2001
From: YanWQ-monad 
Date: Fri, 31 May 2024 16:11:43 +0800
Subject: [PATCH] [RISCV] add smcsrind and sscsrind extension

---
 .../test/Preprocessor/riscv-target-features.c  | 18 ++
 llvm/docs/RISCVUsage.rst   |  2 ++
 llvm/lib/Target/RISCV/RISCVFeatures.td |  7 +++
 llvm/test/CodeGen/RISCV/attributes.ll  |  8 
 llvm/test/MC/RISCV/attribute-arch.s|  6 ++
 .../TargetParser/RISCVISAInfoTest.cpp  |  2 ++
 6 files changed, 43 insertions(+)

diff --git a/clang/test/Preprocessor/riscv-target-features.c 
b/clang/test/Preprocessor/riscv-target-features.c
index 0865add7e8fb8..ed8effd3fe44b 100644
--- a/clang/test/Preprocessor/riscv-target-features.c
+++ b/clang/test/Preprocessor/riscv-target-features.c
@@ -26,12 +26,14 @@
 // CHECK-NOT: __riscv_shvstvala {{.*$}}
 // CHECK-NOT: __riscv_shvstvecd {{.*$}}
 // CHECK-NOT: __riscv_smaia {{.*$}}
+// CHECK-NOT: __riscv_smcsrind {{.*$}}
 // CHECK-NOT: __riscv_smepmp {{.*$}}
 // CHECK-NOT: __riscv_smstateen {{.*$}}
 // CHECK-NOT: __riscv_ssaia {{.*$}}
 // CHECK-NOT: __riscv_ssccptr {{.*$}}
 // CHECK-NOT: __riscv_sscofpmf {{.*$}}
 // CHECK-NOT: __riscv_sscounterenw {{.*$}}
+// CHECK-NOT: __riscv_sscsrind {{.*$}}
 // CHECK-NOT: __riscv_ssstateen {{.*$}}
 // CHECK-NOT: __riscv_ssstrict {{.*$}}
 // CHECK-NOT: __riscv_sstc {{.*$}}
@@ -1373,6 +1375,22 @@
 // RUN:   -o - | FileCheck --check-prefix=CHECK-SSAIA-EXT %s
 // CHECK-SSAIA-EXT: __riscv_ssaia  100{{$}}
 
+// RUN: %clang --target=riscv32 \
+// RUN:   -march=rv32ismcsrind1p0 -E -dM %s \
+// RUN:   -o - | FileCheck --check-prefix=CHECK-SMCSRIND-EXT %s
+// RUN: %clang --target=riscv64 \
+// RUN:   -march=rv64ismcsrind1p0 -E -dM %s \
+// RUN:   -o - | FileCheck --check-prefix=CHECK-SMCSRIND-EXT %s
+// CHECK-SMCSRIND-EXT: __riscv_smcsrind  100{{$}}
+
+// RUN: %clang --target=riscv32 \
+// RUN:   -march=rv32isscsrind1p0 -E -dM %s \
+// RUN:   -o - | FileCheck --check-prefix=CHECK-SSCSRIND-EXT %s
+// RUN: %clang --target=riscv64 \
+// RUN:   -march=rv64isscsrind1p0 -E -dM %s \
+// RUN:   -o - | FileCheck --check-prefix=CHECK-SSCSRIND-EXT %s
+// CHECK-SSCSRIND-EXT: __riscv_sscsrind  100{{$}}
+
 // RUN: %clang --target=riscv32 \
 // RUN:   -march=rv32ismepmp1p0 -E -dM %s \
 // RUN:   -o - | FileCheck --check-prefix=CHECK-SMEPMP-EXT %s
diff --git a/llvm/docs/RISCVUsage.rst b/llvm/docs/RISCVUsage.rst
index 5ecee2a480f7d..9411f1176836c 100644
--- a/llvm/docs/RISCVUsage.rst
+++ b/llvm/docs/RISCVUsage.rst
@@ -98,12 +98,14 @@ on support follow.
  ``Shvstvala`` Assembly Support (`See note 
<#riscv-profiles-extensions-note>`__)
  ``Shvstvecd`` Assembly Support (`See note 
<#riscv-profiles-extensions-note>`__)
  ``Smaia`` Supported
+ ``Smcsrind``  Supported
  ``Smepmp``Supported
  ``Smstateen`` Assembly Support
  ``Ssaia`` Supported
  ``Ssccptr``   Assembly Support (`See note 
<#riscv-profiles-extensions-note>`__)
  ``Sscofpmf``  Assembly Support
  ``Sscounterenw``  Assembly Support (`See note 
<#riscv-profiles-extensions-note>`__)
+ ``Sscsrind``  Supported
  ``Ssstateen`` Assembly Support (`See note 
<#riscv-profiles-extensions-note>`__)
  ``Ssstrict``  Assembly Support (`See note 
<#riscv-profiles-extensions-note>`__)
  ``Sstc``  Assembly Support
diff --git a/llvm/lib/Target/RISCV/RISCVFeatures.td 
b/llvm/lib/Target/RISCV/RISCVFeatures.td
index a78d78946be31..898e46f0e2004 100644
--- a/llvm/lib/Target/RISCV/RISCVFeatures.td
+++ b/llvm/lib/Target/RISCV/RISCVFeatures.td
@@ -847,6 +847,13 @@ def FeatureStdExtSsaia
  "'Ssaia' (Advanced Interrupt Architecture Supervisor "
  "Level)">;
 
+def FeatureStdExtSmcsrind
+: RISCVExtension<"smcsrind", 1, 0,
+ "'Smcsrind' (Indirect CSR Access Machine Level)">;
+def FeatureStdExtSscsrind
+: RISCVExtension<"sscsrind", 1, 0,
+ "'Sscsrind' (Indirect CSR Access Supervisor Level)">;
+
 def FeatureStdExtSmepmp
 : RISCVExtension<"smepmp", 1, 0,
  "'Smepmp' (Enhanced Physical Memory Protection)">;
diff --git a/llvm/test/CodeGen/RISCV/attributes.ll 
b/llvm/test/CodeGen/RISCV/attributes.ll
index c90bb031e082f..ebb3166ced04e 100644
--- a/llvm/test/CodeGen/RISCV/attributes.ll
+++ b/llvm/test/CodeGen/RISCV/attributes.ll
@@ -110,6 +110,8 @@
 ; RUN: llc -mtriple=riscv32 -mattr=+zcmop %s -o - | FileCheck 
--check-prefix=RV32ZCMOP %s
 ; RUN: llc -mtriple=riscv32 -mattr=+smaia %s -o - | FileCheck 
--check-prefixes=CHECK,

[clang] [clang] Lower _BitInt(129+) to a different type in LLVM IR (PR #91364)

2024-05-31 Thread Mariya Podchishchaeva via cfe-commits


@@ -2567,16 +2567,16 @@ int main() {
 // CHECK3-NEXT:[[I:%.*]] = alloca i32, align 4
 // CHECK3-NEXT:[[DOTCAPTURE_EXPR__CASTED:%.*]] = alloca i64, align 8
 // CHECK3-NEXT:[[DOTBOUND_ZERO_ADDR:%.*]] = alloca i32, align 4
-// CHECK3-NEXT:[[DOTCAPTURE_EXPR__CASTED12:%.*]] = alloca i64, align 8

Fznamznon wrote:

They failed due to the change that generalized handling of `bool` and `_BitInt` 
in `EmitToMemory`/`EmitFromMemory`. I will need to revert that change then.

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


[clang] [llvm] [RISCV] Add Smcsrind and Sscsrind extension (PR #93952)

2024-05-31 Thread via cfe-commits

llvmbot wrote:




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

Author: Monad (YanWQ-monad)


Changes

Specification link: https://github.com/riscvarchive/riscv-indirect-csr-access


The CSRs in Smcsrind/Sscsrind extensions are originally defined as part of the 
Smaia/Ssaia extensions, which are already supported in LLVM.

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


6 Files Affected:

- (modified) clang/test/Preprocessor/riscv-target-features.c (+18) 
- (modified) llvm/docs/RISCVUsage.rst (+2) 
- (modified) llvm/lib/Target/RISCV/RISCVFeatures.td (+7) 
- (modified) llvm/test/CodeGen/RISCV/attributes.ll (+8) 
- (modified) llvm/test/MC/RISCV/attribute-arch.s (+6) 
- (modified) llvm/unittests/TargetParser/RISCVISAInfoTest.cpp (+2) 


``diff
diff --git a/clang/test/Preprocessor/riscv-target-features.c 
b/clang/test/Preprocessor/riscv-target-features.c
index 0865add7e8fb8..ed8effd3fe44b 100644
--- a/clang/test/Preprocessor/riscv-target-features.c
+++ b/clang/test/Preprocessor/riscv-target-features.c
@@ -26,12 +26,14 @@
 // CHECK-NOT: __riscv_shvstvala {{.*$}}
 // CHECK-NOT: __riscv_shvstvecd {{.*$}}
 // CHECK-NOT: __riscv_smaia {{.*$}}
+// CHECK-NOT: __riscv_smcsrind {{.*$}}
 // CHECK-NOT: __riscv_smepmp {{.*$}}
 // CHECK-NOT: __riscv_smstateen {{.*$}}
 // CHECK-NOT: __riscv_ssaia {{.*$}}
 // CHECK-NOT: __riscv_ssccptr {{.*$}}
 // CHECK-NOT: __riscv_sscofpmf {{.*$}}
 // CHECK-NOT: __riscv_sscounterenw {{.*$}}
+// CHECK-NOT: __riscv_sscsrind {{.*$}}
 // CHECK-NOT: __riscv_ssstateen {{.*$}}
 // CHECK-NOT: __riscv_ssstrict {{.*$}}
 // CHECK-NOT: __riscv_sstc {{.*$}}
@@ -1373,6 +1375,22 @@
 // RUN:   -o - | FileCheck --check-prefix=CHECK-SSAIA-EXT %s
 // CHECK-SSAIA-EXT: __riscv_ssaia  100{{$}}
 
+// RUN: %clang --target=riscv32 \
+// RUN:   -march=rv32ismcsrind1p0 -E -dM %s \
+// RUN:   -o - | FileCheck --check-prefix=CHECK-SMCSRIND-EXT %s
+// RUN: %clang --target=riscv64 \
+// RUN:   -march=rv64ismcsrind1p0 -E -dM %s \
+// RUN:   -o - | FileCheck --check-prefix=CHECK-SMCSRIND-EXT %s
+// CHECK-SMCSRIND-EXT: __riscv_smcsrind  100{{$}}
+
+// RUN: %clang --target=riscv32 \
+// RUN:   -march=rv32isscsrind1p0 -E -dM %s \
+// RUN:   -o - | FileCheck --check-prefix=CHECK-SSCSRIND-EXT %s
+// RUN: %clang --target=riscv64 \
+// RUN:   -march=rv64isscsrind1p0 -E -dM %s \
+// RUN:   -o - | FileCheck --check-prefix=CHECK-SSCSRIND-EXT %s
+// CHECK-SSCSRIND-EXT: __riscv_sscsrind  100{{$}}
+
 // RUN: %clang --target=riscv32 \
 // RUN:   -march=rv32ismepmp1p0 -E -dM %s \
 // RUN:   -o - | FileCheck --check-prefix=CHECK-SMEPMP-EXT %s
diff --git a/llvm/docs/RISCVUsage.rst b/llvm/docs/RISCVUsage.rst
index 5ecee2a480f7d..9411f1176836c 100644
--- a/llvm/docs/RISCVUsage.rst
+++ b/llvm/docs/RISCVUsage.rst
@@ -98,12 +98,14 @@ on support follow.
  ``Shvstvala`` Assembly Support (`See note 
<#riscv-profiles-extensions-note>`__)
  ``Shvstvecd`` Assembly Support (`See note 
<#riscv-profiles-extensions-note>`__)
  ``Smaia`` Supported
+ ``Smcsrind``  Supported
  ``Smepmp``Supported
  ``Smstateen`` Assembly Support
  ``Ssaia`` Supported
  ``Ssccptr``   Assembly Support (`See note 
<#riscv-profiles-extensions-note>`__)
  ``Sscofpmf``  Assembly Support
  ``Sscounterenw``  Assembly Support (`See note 
<#riscv-profiles-extensions-note>`__)
+ ``Sscsrind``  Supported
  ``Ssstateen`` Assembly Support (`See note 
<#riscv-profiles-extensions-note>`__)
  ``Ssstrict``  Assembly Support (`See note 
<#riscv-profiles-extensions-note>`__)
  ``Sstc``  Assembly Support
diff --git a/llvm/lib/Target/RISCV/RISCVFeatures.td 
b/llvm/lib/Target/RISCV/RISCVFeatures.td
index a78d78946be31..898e46f0e2004 100644
--- a/llvm/lib/Target/RISCV/RISCVFeatures.td
+++ b/llvm/lib/Target/RISCV/RISCVFeatures.td
@@ -847,6 +847,13 @@ def FeatureStdExtSsaia
  "'Ssaia' (Advanced Interrupt Architecture Supervisor "
  "Level)">;
 
+def FeatureStdExtSmcsrind
+: RISCVExtension<"smcsrind", 1, 0,
+ "'Smcsrind' (Indirect CSR Access Machine Level)">;
+def FeatureStdExtSscsrind
+: RISCVExtension<"sscsrind", 1, 0,
+ "'Sscsrind' (Indirect CSR Access Supervisor Level)">;
+
 def FeatureStdExtSmepmp
 : RISCVExtension<"smepmp", 1, 0,
  "'Smepmp' (Enhanced Physical Memory Protection)">;
diff --git a/llvm/test/CodeGen/RISCV/attributes.ll 
b/llvm/test/CodeGen/RISCV/attributes.ll
index c90bb031e082f..ebb3166ced04e 100644
--- a/llvm/test/CodeGen/RISCV/attributes.ll
+++ b/llvm/test/CodeGen/RISCV/attributes.ll
@@ -110,6 +110,8 @@
 ; RUN: llc -mtriple=riscv32 -mattr=+zcmop %s -o - | FileCheck 
--check-prefix=RV32ZCMOP %s
 ; RUN: llc -mtriple=riscv32 -mattr=+smaia %s -o - | FileCheck 
--check-prefixes=CHECK,RV32SMAIA %s
 ; RUN: llc -mtriple=riscv32 -mattr=+ssaia %s -o - | FileCheck 
--check-prefixes=CHECK,RV32SSAIA %s
+; RUN: llc -mtriple=ri

[clang] [llvm] [RISCV] Add Smcsrind and Sscsrind extension (PR #93952)

2024-05-31 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Monad (YanWQ-monad)


Changes

Specification link: https://github.com/riscvarchive/riscv-indirect-csr-access


The CSRs in Smcsrind/Sscsrind extensions are originally defined as part of the 
Smaia/Ssaia extensions, which are already supported in LLVM.

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


6 Files Affected:

- (modified) clang/test/Preprocessor/riscv-target-features.c (+18) 
- (modified) llvm/docs/RISCVUsage.rst (+2) 
- (modified) llvm/lib/Target/RISCV/RISCVFeatures.td (+7) 
- (modified) llvm/test/CodeGen/RISCV/attributes.ll (+8) 
- (modified) llvm/test/MC/RISCV/attribute-arch.s (+6) 
- (modified) llvm/unittests/TargetParser/RISCVISAInfoTest.cpp (+2) 


``diff
diff --git a/clang/test/Preprocessor/riscv-target-features.c 
b/clang/test/Preprocessor/riscv-target-features.c
index 0865add7e8fb8..ed8effd3fe44b 100644
--- a/clang/test/Preprocessor/riscv-target-features.c
+++ b/clang/test/Preprocessor/riscv-target-features.c
@@ -26,12 +26,14 @@
 // CHECK-NOT: __riscv_shvstvala {{.*$}}
 // CHECK-NOT: __riscv_shvstvecd {{.*$}}
 // CHECK-NOT: __riscv_smaia {{.*$}}
+// CHECK-NOT: __riscv_smcsrind {{.*$}}
 // CHECK-NOT: __riscv_smepmp {{.*$}}
 // CHECK-NOT: __riscv_smstateen {{.*$}}
 // CHECK-NOT: __riscv_ssaia {{.*$}}
 // CHECK-NOT: __riscv_ssccptr {{.*$}}
 // CHECK-NOT: __riscv_sscofpmf {{.*$}}
 // CHECK-NOT: __riscv_sscounterenw {{.*$}}
+// CHECK-NOT: __riscv_sscsrind {{.*$}}
 // CHECK-NOT: __riscv_ssstateen {{.*$}}
 // CHECK-NOT: __riscv_ssstrict {{.*$}}
 // CHECK-NOT: __riscv_sstc {{.*$}}
@@ -1373,6 +1375,22 @@
 // RUN:   -o - | FileCheck --check-prefix=CHECK-SSAIA-EXT %s
 // CHECK-SSAIA-EXT: __riscv_ssaia  100{{$}}
 
+// RUN: %clang --target=riscv32 \
+// RUN:   -march=rv32ismcsrind1p0 -E -dM %s \
+// RUN:   -o - | FileCheck --check-prefix=CHECK-SMCSRIND-EXT %s
+// RUN: %clang --target=riscv64 \
+// RUN:   -march=rv64ismcsrind1p0 -E -dM %s \
+// RUN:   -o - | FileCheck --check-prefix=CHECK-SMCSRIND-EXT %s
+// CHECK-SMCSRIND-EXT: __riscv_smcsrind  100{{$}}
+
+// RUN: %clang --target=riscv32 \
+// RUN:   -march=rv32isscsrind1p0 -E -dM %s \
+// RUN:   -o - | FileCheck --check-prefix=CHECK-SSCSRIND-EXT %s
+// RUN: %clang --target=riscv64 \
+// RUN:   -march=rv64isscsrind1p0 -E -dM %s \
+// RUN:   -o - | FileCheck --check-prefix=CHECK-SSCSRIND-EXT %s
+// CHECK-SSCSRIND-EXT: __riscv_sscsrind  100{{$}}
+
 // RUN: %clang --target=riscv32 \
 // RUN:   -march=rv32ismepmp1p0 -E -dM %s \
 // RUN:   -o - | FileCheck --check-prefix=CHECK-SMEPMP-EXT %s
diff --git a/llvm/docs/RISCVUsage.rst b/llvm/docs/RISCVUsage.rst
index 5ecee2a480f7d..9411f1176836c 100644
--- a/llvm/docs/RISCVUsage.rst
+++ b/llvm/docs/RISCVUsage.rst
@@ -98,12 +98,14 @@ on support follow.
  ``Shvstvala`` Assembly Support (`See note 
<#riscv-profiles-extensions-note>`__)
  ``Shvstvecd`` Assembly Support (`See note 
<#riscv-profiles-extensions-note>`__)
  ``Smaia`` Supported
+ ``Smcsrind``  Supported
  ``Smepmp``Supported
  ``Smstateen`` Assembly Support
  ``Ssaia`` Supported
  ``Ssccptr``   Assembly Support (`See note 
<#riscv-profiles-extensions-note>`__)
  ``Sscofpmf``  Assembly Support
  ``Sscounterenw``  Assembly Support (`See note 
<#riscv-profiles-extensions-note>`__)
+ ``Sscsrind``  Supported
  ``Ssstateen`` Assembly Support (`See note 
<#riscv-profiles-extensions-note>`__)
  ``Ssstrict``  Assembly Support (`See note 
<#riscv-profiles-extensions-note>`__)
  ``Sstc``  Assembly Support
diff --git a/llvm/lib/Target/RISCV/RISCVFeatures.td 
b/llvm/lib/Target/RISCV/RISCVFeatures.td
index a78d78946be31..898e46f0e2004 100644
--- a/llvm/lib/Target/RISCV/RISCVFeatures.td
+++ b/llvm/lib/Target/RISCV/RISCVFeatures.td
@@ -847,6 +847,13 @@ def FeatureStdExtSsaia
  "'Ssaia' (Advanced Interrupt Architecture Supervisor "
  "Level)">;
 
+def FeatureStdExtSmcsrind
+: RISCVExtension<"smcsrind", 1, 0,
+ "'Smcsrind' (Indirect CSR Access Machine Level)">;
+def FeatureStdExtSscsrind
+: RISCVExtension<"sscsrind", 1, 0,
+ "'Sscsrind' (Indirect CSR Access Supervisor Level)">;
+
 def FeatureStdExtSmepmp
 : RISCVExtension<"smepmp", 1, 0,
  "'Smepmp' (Enhanced Physical Memory Protection)">;
diff --git a/llvm/test/CodeGen/RISCV/attributes.ll 
b/llvm/test/CodeGen/RISCV/attributes.ll
index c90bb031e082f..ebb3166ced04e 100644
--- a/llvm/test/CodeGen/RISCV/attributes.ll
+++ b/llvm/test/CodeGen/RISCV/attributes.ll
@@ -110,6 +110,8 @@
 ; RUN: llc -mtriple=riscv32 -mattr=+zcmop %s -o - | FileCheck 
--check-prefix=RV32ZCMOP %s
 ; RUN: llc -mtriple=riscv32 -mattr=+smaia %s -o - | FileCheck 
--check-prefixes=CHECK,RV32SMAIA %s
 ; RUN: llc -mtriple=riscv32 -mattr=+ssaia %s -o - | FileCheck 
--check-prefixes=CHECK,RV32SSAIA %s
+; RUN: llc -mtriple=riscv32 -ma

[clang] [llvm] [RISCV] Add Smcsrind and Sscsrind extension (PR #93952)

2024-05-31 Thread Yingwei Zheng via cfe-commits

https://github.com/dtcxzyw commented:

Can you also update `llvm/docs/ReleaseNotes.rst` ?


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


[clang] [llvm] [RISCV] Add Smcsrind and Sscsrind extension (PR #93952)

2024-05-31 Thread via cfe-commits

https://github.com/YanWQ-monad updated 
https://github.com/llvm/llvm-project/pull/93952

>From 3e0d38aa84506cd364174190893cb62008948a87 Mon Sep 17 00:00:00 2001
From: YanWQ-monad 
Date: Fri, 31 May 2024 16:11:43 +0800
Subject: [PATCH 1/2] [RISCV] add smcsrind and sscsrind extension

---
 .../test/Preprocessor/riscv-target-features.c  | 18 ++
 llvm/docs/RISCVUsage.rst   |  2 ++
 llvm/lib/Target/RISCV/RISCVFeatures.td |  7 +++
 llvm/test/CodeGen/RISCV/attributes.ll  |  8 
 llvm/test/MC/RISCV/attribute-arch.s|  6 ++
 .../TargetParser/RISCVISAInfoTest.cpp  |  2 ++
 6 files changed, 43 insertions(+)

diff --git a/clang/test/Preprocessor/riscv-target-features.c 
b/clang/test/Preprocessor/riscv-target-features.c
index 0865add7e8fb8..ed8effd3fe44b 100644
--- a/clang/test/Preprocessor/riscv-target-features.c
+++ b/clang/test/Preprocessor/riscv-target-features.c
@@ -26,12 +26,14 @@
 // CHECK-NOT: __riscv_shvstvala {{.*$}}
 // CHECK-NOT: __riscv_shvstvecd {{.*$}}
 // CHECK-NOT: __riscv_smaia {{.*$}}
+// CHECK-NOT: __riscv_smcsrind {{.*$}}
 // CHECK-NOT: __riscv_smepmp {{.*$}}
 // CHECK-NOT: __riscv_smstateen {{.*$}}
 // CHECK-NOT: __riscv_ssaia {{.*$}}
 // CHECK-NOT: __riscv_ssccptr {{.*$}}
 // CHECK-NOT: __riscv_sscofpmf {{.*$}}
 // CHECK-NOT: __riscv_sscounterenw {{.*$}}
+// CHECK-NOT: __riscv_sscsrind {{.*$}}
 // CHECK-NOT: __riscv_ssstateen {{.*$}}
 // CHECK-NOT: __riscv_ssstrict {{.*$}}
 // CHECK-NOT: __riscv_sstc {{.*$}}
@@ -1373,6 +1375,22 @@
 // RUN:   -o - | FileCheck --check-prefix=CHECK-SSAIA-EXT %s
 // CHECK-SSAIA-EXT: __riscv_ssaia  100{{$}}
 
+// RUN: %clang --target=riscv32 \
+// RUN:   -march=rv32ismcsrind1p0 -E -dM %s \
+// RUN:   -o - | FileCheck --check-prefix=CHECK-SMCSRIND-EXT %s
+// RUN: %clang --target=riscv64 \
+// RUN:   -march=rv64ismcsrind1p0 -E -dM %s \
+// RUN:   -o - | FileCheck --check-prefix=CHECK-SMCSRIND-EXT %s
+// CHECK-SMCSRIND-EXT: __riscv_smcsrind  100{{$}}
+
+// RUN: %clang --target=riscv32 \
+// RUN:   -march=rv32isscsrind1p0 -E -dM %s \
+// RUN:   -o - | FileCheck --check-prefix=CHECK-SSCSRIND-EXT %s
+// RUN: %clang --target=riscv64 \
+// RUN:   -march=rv64isscsrind1p0 -E -dM %s \
+// RUN:   -o - | FileCheck --check-prefix=CHECK-SSCSRIND-EXT %s
+// CHECK-SSCSRIND-EXT: __riscv_sscsrind  100{{$}}
+
 // RUN: %clang --target=riscv32 \
 // RUN:   -march=rv32ismepmp1p0 -E -dM %s \
 // RUN:   -o - | FileCheck --check-prefix=CHECK-SMEPMP-EXT %s
diff --git a/llvm/docs/RISCVUsage.rst b/llvm/docs/RISCVUsage.rst
index 5ecee2a480f7d..9411f1176836c 100644
--- a/llvm/docs/RISCVUsage.rst
+++ b/llvm/docs/RISCVUsage.rst
@@ -98,12 +98,14 @@ on support follow.
  ``Shvstvala`` Assembly Support (`See note 
<#riscv-profiles-extensions-note>`__)
  ``Shvstvecd`` Assembly Support (`See note 
<#riscv-profiles-extensions-note>`__)
  ``Smaia`` Supported
+ ``Smcsrind``  Supported
  ``Smepmp``Supported
  ``Smstateen`` Assembly Support
  ``Ssaia`` Supported
  ``Ssccptr``   Assembly Support (`See note 
<#riscv-profiles-extensions-note>`__)
  ``Sscofpmf``  Assembly Support
  ``Sscounterenw``  Assembly Support (`See note 
<#riscv-profiles-extensions-note>`__)
+ ``Sscsrind``  Supported
  ``Ssstateen`` Assembly Support (`See note 
<#riscv-profiles-extensions-note>`__)
  ``Ssstrict``  Assembly Support (`See note 
<#riscv-profiles-extensions-note>`__)
  ``Sstc``  Assembly Support
diff --git a/llvm/lib/Target/RISCV/RISCVFeatures.td 
b/llvm/lib/Target/RISCV/RISCVFeatures.td
index a78d78946be31..898e46f0e2004 100644
--- a/llvm/lib/Target/RISCV/RISCVFeatures.td
+++ b/llvm/lib/Target/RISCV/RISCVFeatures.td
@@ -847,6 +847,13 @@ def FeatureStdExtSsaia
  "'Ssaia' (Advanced Interrupt Architecture Supervisor "
  "Level)">;
 
+def FeatureStdExtSmcsrind
+: RISCVExtension<"smcsrind", 1, 0,
+ "'Smcsrind' (Indirect CSR Access Machine Level)">;
+def FeatureStdExtSscsrind
+: RISCVExtension<"sscsrind", 1, 0,
+ "'Sscsrind' (Indirect CSR Access Supervisor Level)">;
+
 def FeatureStdExtSmepmp
 : RISCVExtension<"smepmp", 1, 0,
  "'Smepmp' (Enhanced Physical Memory Protection)">;
diff --git a/llvm/test/CodeGen/RISCV/attributes.ll 
b/llvm/test/CodeGen/RISCV/attributes.ll
index c90bb031e082f..ebb3166ced04e 100644
--- a/llvm/test/CodeGen/RISCV/attributes.ll
+++ b/llvm/test/CodeGen/RISCV/attributes.ll
@@ -110,6 +110,8 @@
 ; RUN: llc -mtriple=riscv32 -mattr=+zcmop %s -o - | FileCheck 
--check-prefix=RV32ZCMOP %s
 ; RUN: llc -mtriple=riscv32 -mattr=+smaia %s -o - | FileCheck 
--check-prefixes=CHECK,RV32SMAIA %s
 ; RUN: llc -mtriple=riscv32 -mattr=+ssaia %s -o - | FileCheck 
--check-prefixes=CHECK,RV32SSAIA %s
+; RUN: llc -mtriple=riscv32 -mattr=+smcsrind %s -o - | FileCheck 
--check-prefixes=CHECK,RV32SMCSRIND %s

[clang] [llvm] [clang][CodeGen] Global constructors/destructors are globals (PR #93914)

2024-05-31 Thread Alex Voicu via cfe-commits

AlexVlx wrote:

> llvm datalayout defines
> 
> P - program addr space for functions G - global addr space for global 
> variables
> 
> https://llvm.org/docs/LangRef.html#langref-datalayout
> 
> should we use P for llvm.global_ctors instead of G?



> llvm datalayout defines
> 
> P - program addr space for functions G - global addr space for global 
> variables
> 
> https://llvm.org/docs/LangRef.html#langref-datalayout
> 
> should we use P for llvm.global_ctors instead of G?



> llvm datalayout defines
> 
> P - program addr space for functions G - global addr space for global 
> variables
> 
> https://llvm.org/docs/LangRef.html#langref-datalayout
> 
> should we use P for llvm.global_ctors instead of G?

I'm not sure we can do that for anything but the ctor function (where it's 
already used), since, per langref, the third element can be either a global or 
a function, and whilst all functions are globals not all globals are functions 
(the distinction is arbitrary for many targets and, as @jrtc27 says, it's just 
lifetime ensuring hook, but we should probably stick with doing what we claim 
to do in the public documents).

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


[clang] [CodeGen] Simplify codegen for array initialization (PR #93956)

2024-05-31 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-coroutines

Author: Nikita Popov (nikic)


Changes

This makes codegen for array initialization simpler in two ways:
1. Drop the zero-index GEP at the start, which is no longer needed with opaque 
pointers.
2. Emit GEPs directly to the correct element, instead of having a long chain of 
+1 GEPs. This is more canonical, and also avoids regressions in unoptimized 
builds from #93823.

---

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


76 Files Affected:

- (modified) clang/lib/CodeGen/CGExprAgg.cpp (+9-20) 
- (modified) clang/test/CodeGen/paren-list-agg-init.cpp (+18-26) 
- (modified) clang/test/CodeGenCXX/control-flow-in-stmt-expr.cpp (+15-17) 
- (modified) clang/test/CodeGenCXX/cxx0x-initializer-references.cpp (+1-2) 
- (modified) 
clang/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist-startend.cpp (+1-2) 
- (modified) clang/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist.cpp 
(+1-2) 
- (modified) clang/test/CodeGenCXX/cxx11-initializer-array-new.cpp (+18-24) 
- (modified) clang/test/CodeGenCXX/partial-destruction.cpp (+17-21) 
- (modified) clang/test/CodeGenCXX/temporaries.cpp (+2-3) 
- (modified) clang/test/CodeGenCXX/value-init.cpp (+12-11) 
- (modified) clang/test/CodeGenCoroutines/coro-suspend-cleanups.cpp (+7-10) 
- (modified) clang/test/CodeGenObjC/arc-ternary-op.m (+4-6) 
- (modified) clang/test/CodeGenObjC/arc.m (+2-3) 
- (modified) clang/test/CodeGenObjCXX/arc-exceptions.mm (+8-11) 
- (modified) clang/test/OpenMP/distribute_firstprivate_codegen.cpp (+8-12) 
- (modified) clang/test/OpenMP/distribute_lastprivate_codegen.cpp (+8-12) 
- (modified) clang/test/OpenMP/distribute_parallel_for_firstprivate_codegen.cpp 
(+8-12) 
- (modified) clang/test/OpenMP/distribute_parallel_for_lastprivate_codegen.cpp 
(+8-12) 
- (modified) clang/test/OpenMP/distribute_parallel_for_private_codegen.cpp 
(+8-12) 
- (modified) 
clang/test/OpenMP/distribute_parallel_for_simd_firstprivate_codegen.cpp 
(+16-24) 
- (modified) 
clang/test/OpenMP/distribute_parallel_for_simd_lastprivate_codegen.cpp (+16-24) 
- (modified) clang/test/OpenMP/distribute_parallel_for_simd_private_codegen.cpp 
(+16-24) 
- (modified) clang/test/OpenMP/distribute_private_codegen.cpp (+8-12) 
- (modified) clang/test/OpenMP/distribute_simd_firstprivate_codegen.cpp 
(+16-24) 
- (modified) clang/test/OpenMP/distribute_simd_lastprivate_codegen.cpp (+16-24) 
- (modified) clang/test/OpenMP/distribute_simd_private_codegen.cpp (+16-24) 
- (modified) clang/test/OpenMP/for_firstprivate_codegen.cpp (+2-3) 
- (modified) clang/test/OpenMP/for_lastprivate_codegen.cpp (+8-12) 
- (modified) clang/test/OpenMP/for_private_codegen.cpp (+4-6) 
- (modified) clang/test/OpenMP/for_reduction_codegen.cpp (+6-8) 
- (modified) clang/test/OpenMP/for_reduction_codegen_UDR.cpp (+12-16) 
- (modified) clang/test/OpenMP/parallel_copyin_codegen.cpp (+4-6) 
- (modified) clang/test/OpenMP/parallel_firstprivate_codegen.cpp (+8-12) 
- (modified) 
clang/test/OpenMP/parallel_master_taskloop_firstprivate_codegen.cpp (+12-18) 
- (modified) clang/test/OpenMP/parallel_master_taskloop_lastprivate_codegen.cpp 
(+4-6) 
- (modified) 
clang/test/OpenMP/parallel_master_taskloop_simd_firstprivate_codegen.cpp 
(+12-18) 
- (modified) 
clang/test/OpenMP/parallel_master_taskloop_simd_lastprivate_codegen.cpp (+8-12) 
- (modified) clang/test/OpenMP/parallel_private_codegen.cpp (+4-6) 
- (modified) clang/test/OpenMP/parallel_reduction_codegen.cpp (+4-6) 
- (modified) clang/test/OpenMP/sections_firstprivate_codegen.cpp (+2-3) 
- (modified) clang/test/OpenMP/sections_lastprivate_codegen.cpp (+8-12) 
- (modified) clang/test/OpenMP/sections_private_codegen.cpp (+4-6) 
- (modified) clang/test/OpenMP/sections_reduction_codegen.cpp (+4-6) 
- (modified) clang/test/OpenMP/simd_private_taskloop_codegen.cpp (+16-24) 
- (modified) clang/test/OpenMP/single_firstprivate_codegen.cpp (+2-3) 
- (modified) clang/test/OpenMP/single_private_codegen.cpp (+4-6) 
- (modified) clang/test/OpenMP/target_teams_distribute_firstprivate_codegen.cpp 
(+4-6) 
- (modified) clang/test/OpenMP/target_teams_distribute_lastprivate_codegen.cpp 
(+8-12) 
- (modified) 
clang/test/OpenMP/target_teams_distribute_parallel_for_firstprivate_codegen.cpp 
(+4-6) 
- (modified) 
clang/test/OpenMP/target_teams_distribute_parallel_for_lastprivate_codegen.cpp 
(+8-12) 
- (modified) 
clang/test/OpenMP/target_teams_distribute_parallel_for_private_codegen.cpp 
(+4-6) 
- (modified) 
clang/test/OpenMP/target_teams_distribute_parallel_for_simd_firstprivate_codegen.cpp
 (+8-12) 
- (modified) 
clang/test/OpenMP/target_teams_distribute_parallel_for_simd_lastprivate_codegen.cpp
 (+16-24) 
- (modified) 
clang/test/OpenMP/target_teams_distribute_parallel_for_simd_private_codegen.cpp 
(+8-12) 
- (modified) clang/test/OpenMP/target_teams_distribute_private_codegen.cpp 
(+4-6) 
- (modified) 
clang/test/OpenMP/target_teams_distribute_simd_firstprivate_co

[clang] [CodeGen] Simplify codegen for array initialization (PR #93956)

2024-05-31 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Nikita Popov (nikic)


Changes

This makes codegen for array initialization simpler in two ways:
1. Drop the zero-index GEP at the start, which is no longer needed with opaque 
pointers.
2. Emit GEPs directly to the correct element, instead of having a long chain of 
+1 GEPs. This is more canonical, and also avoids regressions in unoptimized 
builds from #93823.

---

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


76 Files Affected:

- (modified) clang/lib/CodeGen/CGExprAgg.cpp (+9-20) 
- (modified) clang/test/CodeGen/paren-list-agg-init.cpp (+18-26) 
- (modified) clang/test/CodeGenCXX/control-flow-in-stmt-expr.cpp (+15-17) 
- (modified) clang/test/CodeGenCXX/cxx0x-initializer-references.cpp (+1-2) 
- (modified) 
clang/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist-startend.cpp (+1-2) 
- (modified) clang/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist.cpp 
(+1-2) 
- (modified) clang/test/CodeGenCXX/cxx11-initializer-array-new.cpp (+18-24) 
- (modified) clang/test/CodeGenCXX/partial-destruction.cpp (+17-21) 
- (modified) clang/test/CodeGenCXX/temporaries.cpp (+2-3) 
- (modified) clang/test/CodeGenCXX/value-init.cpp (+12-11) 
- (modified) clang/test/CodeGenCoroutines/coro-suspend-cleanups.cpp (+7-10) 
- (modified) clang/test/CodeGenObjC/arc-ternary-op.m (+4-6) 
- (modified) clang/test/CodeGenObjC/arc.m (+2-3) 
- (modified) clang/test/CodeGenObjCXX/arc-exceptions.mm (+8-11) 
- (modified) clang/test/OpenMP/distribute_firstprivate_codegen.cpp (+8-12) 
- (modified) clang/test/OpenMP/distribute_lastprivate_codegen.cpp (+8-12) 
- (modified) clang/test/OpenMP/distribute_parallel_for_firstprivate_codegen.cpp 
(+8-12) 
- (modified) clang/test/OpenMP/distribute_parallel_for_lastprivate_codegen.cpp 
(+8-12) 
- (modified) clang/test/OpenMP/distribute_parallel_for_private_codegen.cpp 
(+8-12) 
- (modified) 
clang/test/OpenMP/distribute_parallel_for_simd_firstprivate_codegen.cpp 
(+16-24) 
- (modified) 
clang/test/OpenMP/distribute_parallel_for_simd_lastprivate_codegen.cpp (+16-24) 
- (modified) clang/test/OpenMP/distribute_parallel_for_simd_private_codegen.cpp 
(+16-24) 
- (modified) clang/test/OpenMP/distribute_private_codegen.cpp (+8-12) 
- (modified) clang/test/OpenMP/distribute_simd_firstprivate_codegen.cpp 
(+16-24) 
- (modified) clang/test/OpenMP/distribute_simd_lastprivate_codegen.cpp (+16-24) 
- (modified) clang/test/OpenMP/distribute_simd_private_codegen.cpp (+16-24) 
- (modified) clang/test/OpenMP/for_firstprivate_codegen.cpp (+2-3) 
- (modified) clang/test/OpenMP/for_lastprivate_codegen.cpp (+8-12) 
- (modified) clang/test/OpenMP/for_private_codegen.cpp (+4-6) 
- (modified) clang/test/OpenMP/for_reduction_codegen.cpp (+6-8) 
- (modified) clang/test/OpenMP/for_reduction_codegen_UDR.cpp (+12-16) 
- (modified) clang/test/OpenMP/parallel_copyin_codegen.cpp (+4-6) 
- (modified) clang/test/OpenMP/parallel_firstprivate_codegen.cpp (+8-12) 
- (modified) 
clang/test/OpenMP/parallel_master_taskloop_firstprivate_codegen.cpp (+12-18) 
- (modified) clang/test/OpenMP/parallel_master_taskloop_lastprivate_codegen.cpp 
(+4-6) 
- (modified) 
clang/test/OpenMP/parallel_master_taskloop_simd_firstprivate_codegen.cpp 
(+12-18) 
- (modified) 
clang/test/OpenMP/parallel_master_taskloop_simd_lastprivate_codegen.cpp (+8-12) 
- (modified) clang/test/OpenMP/parallel_private_codegen.cpp (+4-6) 
- (modified) clang/test/OpenMP/parallel_reduction_codegen.cpp (+4-6) 
- (modified) clang/test/OpenMP/sections_firstprivate_codegen.cpp (+2-3) 
- (modified) clang/test/OpenMP/sections_lastprivate_codegen.cpp (+8-12) 
- (modified) clang/test/OpenMP/sections_private_codegen.cpp (+4-6) 
- (modified) clang/test/OpenMP/sections_reduction_codegen.cpp (+4-6) 
- (modified) clang/test/OpenMP/simd_private_taskloop_codegen.cpp (+16-24) 
- (modified) clang/test/OpenMP/single_firstprivate_codegen.cpp (+2-3) 
- (modified) clang/test/OpenMP/single_private_codegen.cpp (+4-6) 
- (modified) clang/test/OpenMP/target_teams_distribute_firstprivate_codegen.cpp 
(+4-6) 
- (modified) clang/test/OpenMP/target_teams_distribute_lastprivate_codegen.cpp 
(+8-12) 
- (modified) 
clang/test/OpenMP/target_teams_distribute_parallel_for_firstprivate_codegen.cpp 
(+4-6) 
- (modified) 
clang/test/OpenMP/target_teams_distribute_parallel_for_lastprivate_codegen.cpp 
(+8-12) 
- (modified) 
clang/test/OpenMP/target_teams_distribute_parallel_for_private_codegen.cpp 
(+4-6) 
- (modified) 
clang/test/OpenMP/target_teams_distribute_parallel_for_simd_firstprivate_codegen.cpp
 (+8-12) 
- (modified) 
clang/test/OpenMP/target_teams_distribute_parallel_for_simd_lastprivate_codegen.cpp
 (+16-24) 
- (modified) 
clang/test/OpenMP/target_teams_distribute_parallel_for_simd_private_codegen.cpp 
(+8-12) 
- (modified) clang/test/OpenMP/target_teams_distribute_private_codegen.cpp 
(+4-6) 
- (modified) 
clang/test/OpenMP/target_teams_distribute_simd_firstprivate_codegen

[clang] [CodeGen] Simplify codegen for array initialization (PR #93956)

2024-05-31 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-codegen

Author: Nikita Popov (nikic)


Changes

This makes codegen for array initialization simpler in two ways:
1. Drop the zero-index GEP at the start, which is no longer needed with opaque 
pointers.
2. Emit GEPs directly to the correct element, instead of having a long chain of 
+1 GEPs. This is more canonical, and also avoids regressions in unoptimized 
builds from #93823.

---

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


76 Files Affected:

- (modified) clang/lib/CodeGen/CGExprAgg.cpp (+9-20) 
- (modified) clang/test/CodeGen/paren-list-agg-init.cpp (+18-26) 
- (modified) clang/test/CodeGenCXX/control-flow-in-stmt-expr.cpp (+15-17) 
- (modified) clang/test/CodeGenCXX/cxx0x-initializer-references.cpp (+1-2) 
- (modified) 
clang/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist-startend.cpp (+1-2) 
- (modified) clang/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist.cpp 
(+1-2) 
- (modified) clang/test/CodeGenCXX/cxx11-initializer-array-new.cpp (+18-24) 
- (modified) clang/test/CodeGenCXX/partial-destruction.cpp (+17-21) 
- (modified) clang/test/CodeGenCXX/temporaries.cpp (+2-3) 
- (modified) clang/test/CodeGenCXX/value-init.cpp (+12-11) 
- (modified) clang/test/CodeGenCoroutines/coro-suspend-cleanups.cpp (+7-10) 
- (modified) clang/test/CodeGenObjC/arc-ternary-op.m (+4-6) 
- (modified) clang/test/CodeGenObjC/arc.m (+2-3) 
- (modified) clang/test/CodeGenObjCXX/arc-exceptions.mm (+8-11) 
- (modified) clang/test/OpenMP/distribute_firstprivate_codegen.cpp (+8-12) 
- (modified) clang/test/OpenMP/distribute_lastprivate_codegen.cpp (+8-12) 
- (modified) clang/test/OpenMP/distribute_parallel_for_firstprivate_codegen.cpp 
(+8-12) 
- (modified) clang/test/OpenMP/distribute_parallel_for_lastprivate_codegen.cpp 
(+8-12) 
- (modified) clang/test/OpenMP/distribute_parallel_for_private_codegen.cpp 
(+8-12) 
- (modified) 
clang/test/OpenMP/distribute_parallel_for_simd_firstprivate_codegen.cpp 
(+16-24) 
- (modified) 
clang/test/OpenMP/distribute_parallel_for_simd_lastprivate_codegen.cpp (+16-24) 
- (modified) clang/test/OpenMP/distribute_parallel_for_simd_private_codegen.cpp 
(+16-24) 
- (modified) clang/test/OpenMP/distribute_private_codegen.cpp (+8-12) 
- (modified) clang/test/OpenMP/distribute_simd_firstprivate_codegen.cpp 
(+16-24) 
- (modified) clang/test/OpenMP/distribute_simd_lastprivate_codegen.cpp (+16-24) 
- (modified) clang/test/OpenMP/distribute_simd_private_codegen.cpp (+16-24) 
- (modified) clang/test/OpenMP/for_firstprivate_codegen.cpp (+2-3) 
- (modified) clang/test/OpenMP/for_lastprivate_codegen.cpp (+8-12) 
- (modified) clang/test/OpenMP/for_private_codegen.cpp (+4-6) 
- (modified) clang/test/OpenMP/for_reduction_codegen.cpp (+6-8) 
- (modified) clang/test/OpenMP/for_reduction_codegen_UDR.cpp (+12-16) 
- (modified) clang/test/OpenMP/parallel_copyin_codegen.cpp (+4-6) 
- (modified) clang/test/OpenMP/parallel_firstprivate_codegen.cpp (+8-12) 
- (modified) 
clang/test/OpenMP/parallel_master_taskloop_firstprivate_codegen.cpp (+12-18) 
- (modified) clang/test/OpenMP/parallel_master_taskloop_lastprivate_codegen.cpp 
(+4-6) 
- (modified) 
clang/test/OpenMP/parallel_master_taskloop_simd_firstprivate_codegen.cpp 
(+12-18) 
- (modified) 
clang/test/OpenMP/parallel_master_taskloop_simd_lastprivate_codegen.cpp (+8-12) 
- (modified) clang/test/OpenMP/parallel_private_codegen.cpp (+4-6) 
- (modified) clang/test/OpenMP/parallel_reduction_codegen.cpp (+4-6) 
- (modified) clang/test/OpenMP/sections_firstprivate_codegen.cpp (+2-3) 
- (modified) clang/test/OpenMP/sections_lastprivate_codegen.cpp (+8-12) 
- (modified) clang/test/OpenMP/sections_private_codegen.cpp (+4-6) 
- (modified) clang/test/OpenMP/sections_reduction_codegen.cpp (+4-6) 
- (modified) clang/test/OpenMP/simd_private_taskloop_codegen.cpp (+16-24) 
- (modified) clang/test/OpenMP/single_firstprivate_codegen.cpp (+2-3) 
- (modified) clang/test/OpenMP/single_private_codegen.cpp (+4-6) 
- (modified) clang/test/OpenMP/target_teams_distribute_firstprivate_codegen.cpp 
(+4-6) 
- (modified) clang/test/OpenMP/target_teams_distribute_lastprivate_codegen.cpp 
(+8-12) 
- (modified) 
clang/test/OpenMP/target_teams_distribute_parallel_for_firstprivate_codegen.cpp 
(+4-6) 
- (modified) 
clang/test/OpenMP/target_teams_distribute_parallel_for_lastprivate_codegen.cpp 
(+8-12) 
- (modified) 
clang/test/OpenMP/target_teams_distribute_parallel_for_private_codegen.cpp 
(+4-6) 
- (modified) 
clang/test/OpenMP/target_teams_distribute_parallel_for_simd_firstprivate_codegen.cpp
 (+8-12) 
- (modified) 
clang/test/OpenMP/target_teams_distribute_parallel_for_simd_lastprivate_codegen.cpp
 (+16-24) 
- (modified) 
clang/test/OpenMP/target_teams_distribute_parallel_for_simd_private_codegen.cpp 
(+8-12) 
- (modified) clang/test/OpenMP/target_teams_distribute_private_codegen.cpp 
(+4-6) 
- (modified) 
clang/test/OpenMP/target_teams_distribute_simd_firstprivate

[clang] [compiler-rt] [ubsan] Display correct runtime messages for negative _BitInt (PR #93612)

2024-05-31 Thread via cfe-commits

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


[clang] [clang] Fix loss of `dllexport` for exported template specialization (PR #93302)

2024-05-31 Thread via cfe-commits

zmodem wrote:

I looked at this some more. Here's a slightly reduced version of your test case:

```
template  void foo();
template  void f() {
foo();
}
void g() { f(); }
template <> void __declspec(dllexport) foo() {}
```

What happens (when building with `-fno-delayed-template-parsing`) is something 
like:

1. The `f()` template gets parsed. Because the call to `foo` is not 
type-dependent, the call gets resolved to a FunctionDecl for `foo`, which 
isn't dllexport because that happens later.
2. `g()` calls `f()`, so the latter gets queued up for codegen at the end 
of the TU.
3. Codegen for `foo` happens, with dllexport.
4. (End of the TU) Codegen for `f` happens. When generating the call to 
`foo`, it uses the FunctionDecl from step 1). We enter 
`CodeGenModule::GetOrCreateLLVMFunction`, see that the old `Entry` is dllexport 
but the new FunctionDecl isn't, and so the attribute gets dropped.

I think the "surprise" is that the latter call to `GetOrCreateLLVMFunction` is 
using an earlier `FunctionDecl`. Because of that, I'm thinking maybe the fix is 
to call `getMostRecentDecl` on it, something like:

```
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index 489c08a4d481..8fe36305e104 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -4554,10 +4554,13 @@ llvm::Constant *CodeGenModule::GetOrCreateLLVMFunction(
 }
 
 // Handle dropped DLL attributes.
-if (D && !D->hasAttr() && !D->hasAttr() &&
-!shouldMapVisibilityToDLLExport(cast_or_null(D))) {
-  Entry->setDLLStorageClass(llvm::GlobalValue::DefaultStorageClass);
-  setDSOLocal(Entry);
+if (D) {
+  const Decl *MRD = D->getMostRecentDecl();
+  if (!MRD->hasAttr() && !MRD->hasAttr() &&
+  !shouldMapVisibilityToDLLExport(cast(MRD))) {
+Entry->setDLLStorageClass(llvm::GlobalValue::DefaultStorageClass);
+setDSOLocal(Entry);
+  }
 }
 
 // If there are two attempts to define the same mangled name, issue an
```

If we're concerned about the extra function call in a common codepath, we could 
only do this if there is a dll attribute on the `Entry`.

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


[clang] [clang] Catch missing format attributes (PR #70024)

2024-05-31 Thread Budimir Aranđelović via cfe-commits

budimirarandjelovicsyrmia wrote:

Ping @AaronBallman @aaronpuchert Any comment? (except Resolve conflicts)

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


[clang] [llvm] [clang][CodeGen] Global constructors/destructors are globals (PR #93914)

2024-05-31 Thread Alex Voicu via cfe-commits

AlexVlx wrote:

> The third argument here is like for llvm.used, it's a way to associate the 
> entry with a global or function. If the corresponding global or function is 
> omitted from the output then the entry will be removed. It isn't used for 
> anything at run time. So I think there should be a consistent story between 
> llvm.used and llvm.global_[cd]tors.



> The third argument here is like for llvm.used, it's a way to associate the 
> entry with a global or function. If the corresponding global or function is 
> omitted from the output then the entry will be removed. It isn't used for 
> anything at run time. So I think there should be a consistent story between 
> llvm.used and llvm.global_[cd]tors.



> The third argument here is like for llvm.used, it's a way to associate the 
> entry with a global or function. If the corresponding global or function is 
> omitted from the output then the entry will be removed. It isn't used for 
> anything at run time. So I think there should be a consistent story between 
> llvm.used and llvm.global_[cd]tors.

IMHO, and I could be wrong, the key challenge that we have both here and re 
`used`, is that for these we'd really want a truly 
generic/flat/everywhere-usable pointer type - it can be casted to / from any 
other AS etc., essentially a DONTCARE in IR. An unqualified ptr should probably 
have been that, rather than an implicitly AS0 ptr. It's impossible for Clang to 
query that from a target today (AFAICT), the only close equivalent being asking 
for the target's AS corresponding to `LangAS::Default`, and hoping that it's a 
sane mapping.

Emitting these unconditionally as unqualified `ptr`s as is bothers me because 
we're calling the elements out as globals but then not acting accordingly, and 
because unqualified actually means AS0, which then relies on the target not 
being funky with AS0 (some targets are). Perhaps an alternative is to tweak 
LangRef wording to say that that these are always emitted as unqualified ptrs, 
and that their ephemeral nature implies that their AS is meaningless?

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


[clang] [CUDA] Fix a couple of driver tests that really weren't being run (PR #93960)

2024-05-31 Thread Paul T Robinson via cfe-commits

https://github.com/pogo59 created 
https://github.com/llvm/llvm-project/pull/93960

None

>From efbbb7b729ba4a24413f3d2a1769effba3581d8f Mon Sep 17 00:00:00 2001
From: Paul Robinson 
Date: Fri, 31 May 2024 06:11:30 -0700
Subject: [PATCH] [CUDA] Fix a couple of driver tests that really weren't being
 run

---
 clang/test/Driver/offloading-interoperability.c | 5 +
 clang/test/Driver/openmp-offload-gpu.c  | 6 +-
 2 files changed, 2 insertions(+), 9 deletions(-)

diff --git a/clang/test/Driver/offloading-interoperability.c 
b/clang/test/Driver/offloading-interoperability.c
index 6f6daf31a392e..9193e12355024 100644
--- a/clang/test/Driver/offloading-interoperability.c
+++ b/clang/test/Driver/offloading-interoperability.c
@@ -1,10 +1,7 @@
-// REQUIRES: powerpc-registered-target
-// REQUIRES: nvptx-registered-target
-
 //
 // Verify that CUDA device commands do not get OpenMP flags.
 //
-// RUN: not %clang -### -x cuda --target=powerpc64le-linux-gnu -std=c++11 
--cuda-gpu-arch=sm_35 -fopenmp=libomp %s 2>&1 \
+// RUN: %clang -### -x cuda --target=powerpc64le-linux-gnu -std=c++11 
--cuda-gpu-arch=sm_35 --no-cuda-version-check -fopenmp=libomp %s 2>&1 \
 // RUN:   | FileCheck %s --check-prefix NO-OPENMP-FLAGS-FOR-CUDA-DEVICE
 //
 // NO-OPENMP-FLAGS-FOR-CUDA-DEVICE:  "-cc1" "-triple" "nvptx64-nvidia-cuda"
diff --git a/clang/test/Driver/openmp-offload-gpu.c 
b/clang/test/Driver/openmp-offload-gpu.c
index d21db7019a1aa..0b98aaf6ba53c 100644
--- a/clang/test/Driver/openmp-offload-gpu.c
+++ b/clang/test/Driver/openmp-offload-gpu.c
@@ -2,11 +2,6 @@
 /// Perform several driver tests for OpenMP offloading
 ///
 
-// REQUIRES: x86-registered-target
-// REQUIRES: powerpc-registered-target
-// REQUIRES: nvptx-registered-target
-// REQUIRES: amdgpu-registered-target
-
 /// ###
 
 /// Check -Xopenmp-target uses one of the archs provided when several archs 
are used.
@@ -305,6 +300,7 @@
 // CHECK-EMIT-LLVM-IR-BC: "-cc1"{{.*}}"-triple" 
"nvptx64-nvidia-cuda"{{.*}}"-emit-llvm-bc"
 
 // RUN:   %clang -### -fopenmp=libomp --offload-arch=sm_89 \
+// RUN:  --no-cuda-version-check \
 // RUN:  -nogpulib %s -o openmp-offload-gpu 2>&1 \
 // RUN:   | FileCheck -check-prefix=DRIVER_EMBEDDING %s
 

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


  1   2   3   4   5   >