[clang] [CIR] Upstream initial support for fixed size VectorType (PR #136488)

2025-04-21 Thread Henrich Lauko via cfe-commits


@@ -307,6 +307,26 @@ def CIR_ArrayType : CIR_Type<"Array", "array",
   }];
 }
 
+//===--===//
+// VectorType (fixed size)
+//===--===//
+
+def CIR_VectorType : CIR_Type<"Vector", "vector",

xlauko wrote:

Add missing changes from upstream, specifically custom builders.
```
  let builders = [
TypeBuilderWithInferredContext<(ins
  "mlir::Type":$eltType, "uint64_t":$size
), [{
return $_get(eltType.getContext(), eltType, size);
}]>,
  ];
```

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


[clang] [CIR] Upstream initial support for fixed size VectorType (PR #136488)

2025-04-21 Thread Henrich Lauko via cfe-commits


@@ -399,6 +399,15 @@ mlir::Type CIRGenTypes::convertType(QualType type) {
 break;
   }
 
+  case Type::ExtVector:
+  case Type::Vector: {
+const VectorType *vec = cast(ty);
+const mlir::Type elemTy = convertTypeForMem(vec->getElementType());
+resultType = cir::VectorType::get(builder.getContext(), elemTy,
+  vec->getNumElements());

xlauko wrote:

Reflect changes to builders:


```suggestion
resultType = cir::VectorType::get(elemTy, vec->getNumElements());
```

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


[clang-tools-extra] [clangd] IncludeCleaner include not found error now contains path (PR #136237)

2025-04-21 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder 
`sanitizer-aarch64-linux-bootstrap-asan` running on `sanitizer-buildbot8` while 
building `clang-tools-extra` at step 2 "annotate".

Full details are available at: 
https://lab.llvm.org/buildbot/#/builders/24/builds/7591


Here is the relevant piece of the build log for the reference

```
Step 2 (annotate) failure: 'python 
../sanitizer_buildbot/sanitizers/zorg/buildbot/builders/sanitizers/buildbot_selector.py'
 (failure)
...
llvm-lit: 
/home/b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:520:
 note: using lld-link: 
/home/b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm_build_asan/bin/lld-link
llvm-lit: 
/home/b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:520:
 note: using ld64.lld: 
/home/b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm_build_asan/bin/ld64.lld
llvm-lit: 
/home/b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:520:
 note: using wasm-ld: 
/home/b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm_build_asan/bin/wasm-ld
llvm-lit: 
/home/b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:520:
 note: using ld.lld: 
/home/b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm_build_asan/bin/ld.lld
llvm-lit: 
/home/b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:520:
 note: using lld-link: 
/home/b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm_build_asan/bin/lld-link
llvm-lit: 
/home/b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:520:
 note: using ld64.lld: 
/home/b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm_build_asan/bin/ld64.lld
llvm-lit: 
/home/b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:520:
 note: using wasm-ld: 
/home/b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm_build_asan/bin/wasm-ld
llvm-lit: 
/home/b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm-project/llvm/utils/lit/lit/main.py:72:
 note: The test suite configuration requested an individual test timeout of 0 
seconds but a timeout of 900 seconds was requested on the command line. Forcing 
timeout to be 900 seconds.
-- Testing: 87879 tests, 72 workers --
Testing:  0.. 10.. 20.. 30.. 40.. 50.. 
FAIL: LLVM :: ExecutionEngine/JITLink/x86-64/MachO_weak_references.s (53592 of 
87879)
 TEST 'LLVM :: 
ExecutionEngine/JITLink/x86-64/MachO_weak_references.s' FAILED 

Exit Code: 1

Command Output (stderr):
--
rm -rf 
/home/b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm_build_asan/test/ExecutionEngine/JITLink/x86-64/Output/MachO_weak_references.s.tmp
 && mkdir -p 
/home/b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm_build_asan/test/ExecutionEngine/JITLink/x86-64/Output/MachO_weak_references.s.tmp
 # RUN: at line 1
+ rm -rf 
/home/b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm_build_asan/test/ExecutionEngine/JITLink/x86-64/Output/MachO_weak_references.s.tmp
+ mkdir -p 
/home/b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm_build_asan/test/ExecutionEngine/JITLink/x86-64/Output/MachO_weak_references.s.tmp
/home/b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm_build_asan/bin/llvm-mc
 -triple=x86_64-apple-macosx10.9 -filetype=obj -o 
/home/b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm_build_asan/test/ExecutionEngine/JITLink/x86-64/Output/MachO_weak_references.s.tmp/macho_weak_refs.o
 
/home/b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm-project/llvm/test/ExecutionEngine/JITLink/x86-64/MachO_weak_references.s
 # RUN: at line 2
+ 
/home/b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm_build_asan/bin/llvm-mc
 -triple=x86_64-apple-macosx10.9 -filetype=obj -o 
/home/b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm_build_asan/test/ExecutionEngine/JITLink/x86-64/Output/MachO_weak_references.s.tmp/macho_weak_refs.o
 
/home/b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm-project/llvm/test/ExecutionEngine/JITLink/x86-64/MachO_weak_references.s
/home/b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm_build_asan/bin/llvm-jitlink
 -noexec -check-name=jitlink-check-bar-present -abs bar=0x1 
-check=/home/b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm-project/llvm/test/ExecutionEngine/JITLink/x86-64/MachO_weak_references.s
 
/home/b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm_build_asan/test/ExecutionEngine/JITLink/x86-64/Output/MachO_weak_references.s.tmp/macho_weak_refs.o
 # RUN: at line 3
+ 
/home/b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm_build_asan/bin/llvm-jitlink
 -noexec -check-name=jitlink-check-bar-present -abs bar=0x1 
-check=/home/b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm-project/llvm/test/ExecutionEngine/JITLink/x86-64/MachO_weak_references.s
 
/home/b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm_build_asan/test/ExecutionEngi

[clang] [CIR][NFC] Simplify BoolAttr builders (PR #136366)

2025-04-21 Thread Henrich Lauko via cfe-commits

xlauko wrote:

### Merge activity

* **Apr 21, 3:06 AM EDT**: A user started a stack merge that includes this pull 
request via 
[Graphite](https://app.graphite.dev/github/pr/llvm/llvm-project/136366).


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


[clang] [CIR][NFC] Simplify BoolAttr builders (PR #136366)

2025-04-21 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `lldb-aarch64-ubuntu` 
running on `linaro-lldb-aarch64-ubuntu` while building `clang` at step 6 "test".

Full details are available at: 
https://lab.llvm.org/buildbot/#/builders/59/builds/16358


Here is the relevant piece of the build log for the reference

```
Step 6 (test) failure: build (failure)
...
PASS: lldb-api :: tools/lldb-dap/exception/cpp/TestDAP_exception_cpp.py (1166 
of 2125)
UNSUPPORTED: lldb-api :: 
tools/lldb-dap/extendedStackTrace/TestDAP_extendedStackTrace.py (1167 of 2125)
PASS: lldb-api :: 
tools/lldb-dap/instruction-breakpoint/TestDAP_instruction_breakpoint.py (1168 
of 2125)
PASS: lldb-api :: tools/lldb-dap/databreakpoint/TestDAP_setDataBreakpoints.py 
(1169 of 2125)
PASS: lldb-api :: tools/lldb-dap/io/TestDAP_io.py (1170 of 2125)
PASS: lldb-api :: tools/lldb-dap/locations/TestDAP_locations.py (1171 of 2125)
PASS: lldb-api :: tools/lldb-dap/disconnect/TestDAP_disconnect.py (1172 of 2125)
PASS: lldb-api :: tools/lldb-dap/optimized/TestDAP_optimized.py (1173 of 2125)
PASS: lldb-api :: terminal/TestEditline.py (1174 of 2125)
UNRESOLVED: lldb-api :: tools/lldb-dap/memory/TestDAP_memory.py (1175 of 2125)
 TEST 'lldb-api :: tools/lldb-dap/memory/TestDAP_memory.py' 
FAILED 
Script:
--
/usr/bin/python3.10 
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/llvm-project/lldb/test/API/dotest.py
 -u CXXFLAGS -u CFLAGS --env 
LLVM_LIBS_DIR=/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./lib --env 
LLVM_INCLUDE_DIR=/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/include 
--env LLVM_TOOLS_DIR=/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./bin 
--arch aarch64 --build-dir 
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/lldb-test-build.noindex 
--lldb-module-cache-dir 
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/lldb-test-build.noindex/module-cache-lldb/lldb-api
 --clang-module-cache-dir 
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/lldb-test-build.noindex/module-cache-clang/lldb-api
 --executable /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./bin/lldb 
--compiler /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./bin/clang 
--dsymutil /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./bin/dsymutil 
--make /usr/bin/gmake --llvm-tools-dir 
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./bin --lldb-obj-root 
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/tools/lldb --lldb-libs-dir 
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./lib 
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/llvm-project/lldb/test/API/tools/lldb-dap/memory
 -p TestDAP_memory.py
--
Exit Code: 1

Command Output (stdout):
--
lldb version 21.0.0git (https://github.com/llvm/llvm-project.git revision 
050ca5e27082055f41ad7e3dd2dea2f39364b3ab)
  clang revision 050ca5e27082055f41ad7e3dd2dea2f39364b3ab
  llvm revision 050ca5e27082055f41ad7e3dd2dea2f39364b3ab
Skipping the following test categories: ['libc++', 'dsym', 'gmodules', 
'debugserver', 'objc']

--
Command Output (stderr):
--
= DEBUG ADAPTER PROTOCOL LOGS =
1745219870.051767349 --> (stdin/stdout) 
{"command":"initialize","type":"request","arguments":{"adapterID":"lldb-native","clientID":"vscode","columnsStartAt1":true,"linesStartAt1":true,"locale":"en-us","pathFormat":"path","supportsRunInTerminalRequest":true,"supportsVariablePaging":true,"supportsVariableType":true,"supportsStartDebuggingRequest":true,"supportsProgressReporting":true,"$__lldb_sourceInitFile":false},"seq":1}
1745219870.053774357 <-- (stdin/stdout) {"body":{"$__lldb_version":"lldb 
version 21.0.0git (https://github.com/llvm/llvm-project.git revision 
050ca5e27082055f41ad7e3dd2dea2f39364b3ab)\n  clang revision 
050ca5e27082055f41ad7e3dd2dea2f39364b3ab\n  llvm revision 
050ca5e27082055f41ad7e3dd2dea2f39364b3ab","completionTriggerCharacters":["."," 
","\t"],"exceptionBreakpointFilters":[{"default":false,"filter":"cpp_catch","label":"C++
 Catch"},{"default":false,"filter":"cpp_throw","label":"C++ 
Throw"},{"default":false,"filter":"objc_catch","label":"Objective-C 
Catch"},{"default":false,"filter":"objc_throw","label":"Objective-C 
Throw"}],"supportTerminateDebuggee":true,"supportsBreakpointLocationsRequest":true,"supportsCancelRequest":true,"supportsCompletionsRequest":true,"supportsConditionalBreakpoints":true,"supportsConfigurationDoneRequest":true,"supportsDataBreakpoints":true,"supportsDelayedStackTraceLoading":true,"supportsDisassembleRequest":true,"supportsEvaluateForHovers":true,"supportsExceptionInfoRequest":true,"supportsExceptionOptions":true,"supportsFunctionBreakpoints":true,"supportsHitConditionalBreakpoints":true,"supportsInstructionBreakpoints":true,"supportsLogPoints":true,"supportsModulesRequest":true,"supportsReadMemoryRequest":true,"supportsRestartRequest":true,"supportsSetVariable":true,"supportsStepInTargetsRequest":true,"supportsSteppingGranularity":true,"supportsValueFormattingOptions":true},"comma

[clang-tools-extra] [clangd] Improve `BlockEnd` inlayhint presentation (PR #136106)

2025-04-21 Thread Nathan Ridge via cfe-commits

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


[clang-tools-extra] [clangd] Improve `BlockEnd` inlayhint presentation (PR #136106)

2025-04-21 Thread via cfe-commits


@@ -22,10 +22,16 @@ namespace clang {
 namespace clangd {
 class ParsedAST;
 
+struct InlayHintOptions {
+  // Minimum lines for BlockEnd inlay-hints to be shown
+  int HintMinLineLimit{2};

MythreyaK wrote:

> What we discussed in the original issue was that the default should remain 2 
> for tests, so that we don't have to change a lot of tests / artificially make 
> the blocks long in test code, but that the limit used in production should be 
> increased to 10.

Yep I definitely mixed that up, sorry! Should be fixed now. 

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


[clang-tools-extra] [clangd] Improve `BlockEnd` inlayhint presentation (PR #136106)

2025-04-21 Thread Nathan Ridge via cfe-commits

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


[clang-tools-extra] [clangd] Improve `BlockEnd` inlayhint presentation (PR #136106)

2025-04-21 Thread via cfe-commits


@@ -2305,7 +2335,45 @@ TEST(BlockEndHints, PointerToMemberFunction) {
   $ptrmem[[}]]
 } // suppress
   )cpp",
-  ExpectedHint{" // if", "ptrmem"});
+  ExpectedHint{" // if ()", "ptrmem"});
+}
+
+TEST(BlockEndHints, MinLineLimit) {
+  assertBlockEndHintsWithOpts(
+  R"cpp(
+namespace ns {
+  int Var;
+  int func1();
+  int func2(int, int);
+  struct S {
+int Field;
+int method1() const;
+int method2(int, int) const;
+  $struct[[}]];

MythreyaK wrote:

Very helpful explanation, thank you for the clarification! 

Will push an amended commit soon. 

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


[clang] [Clang] Make the result type of sizeof/pointer subtraction/size_t lit… (PR #136542)

2025-04-21 Thread via cfe-commits

https://github.com/YexuanXiao updated 
https://github.com/llvm/llvm-project/pull/136542

>From b9cc91971469dcf19bb926f6f53ae5a57d1109c3 Mon Sep 17 00:00:00 2001
From: YexuanXiao 
Date: Mon, 21 Apr 2025 14:28:33 +0800
Subject: [PATCH 1/2] [Clang] Make the result type of sizeof/pointer
 subtraction/size_t literals be typedefs instead of built-in types Includeing
 the results of `sizeof`, `sizeof...`, `__datasizeof`, `__alignof`,
 `_Alignof`, `alignof`, `_Countof`, `size_t` literals, and signed `size_t`
 literals, as well as the results of pointer-pointer subtraction. It does not
 affect any program output except for debugging information. The goal is to
 enable clang and downstream tools such as clangd and clang-tidy to provide
 more portable hints and diagnostics.

---
 clang/include/clang/AST/ASTContext.h   |  4 +++
 clang/lib/AST/ASTContext.cpp   | 29 ++
 clang/lib/AST/ComparisonCategories.cpp | 30 ---
 clang/lib/AST/ExprCXX.cpp  |  6 +++--
 clang/lib/Sema/SemaExpr.cpp| 34 --
 5 files changed, 68 insertions(+), 35 deletions(-)

diff --git a/clang/include/clang/AST/ASTContext.h 
b/clang/include/clang/AST/ASTContext.h
index 3c78833a3f069..0c133d45d3f5e 100644
--- a/clang/include/clang/AST/ASTContext.h
+++ b/clang/include/clang/AST/ASTContext.h
@@ -2442,6 +2442,10 @@ class ASTContext : public RefCountedBase {
   QualType GetBuiltinType(unsigned ID, GetBuiltinTypeError &Error,
   unsigned *IntegerConstantArgs = nullptr) const;
 
+  QualType getCGlobalCXXStdNSTypedef(const NamespaceDecl *StdNS,
+ StringRef DefName,
+ QualType FallBack = {}) const;
+
   /// Types and expressions required to build C++2a three-way comparisons
   /// using operator<=>, including the values return by builtin <=> operators.
   ComparisonCategories CompCategories;
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index 2836d68b05ff6..aa8ce0078d4d3 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -12556,6 +12556,35 @@ QualType ASTContext::GetBuiltinType(unsigned Id,
   return getFunctionType(ResType, ArgTypes, EPI);
 }
 
+QualType ASTContext::getCGlobalCXXStdNSTypedef(const NamespaceDecl *StdNS,
+   StringRef DefName,
+   QualType FallBack) const {
+  DeclContextLookupResult Lookup;
+  if (getLangOpts().C99) {
+Lookup = getTranslationUnitDecl()->lookup(&Idents.get(DefName));
+  } else if (getLangOpts().CPlusPlus) {
+if (StdNS == nullptr) {
+  auto LookupStdNS = getTranslationUnitDecl()->lookup(&Idents.get("std"));
+  if (!LookupStdNS.empty()) {
+StdNS = dyn_cast(LookupStdNS.front());
+  }
+}
+if (StdNS) {
+  Lookup = StdNS->lookup(&Idents.get(DefName));
+} else {
+  Lookup = getTranslationUnitDecl()->lookup(&Idents.get(DefName));
+}
+  }
+  if (!Lookup.empty()) {
+if (auto *TD = dyn_cast(Lookup.front())) {
+  if (auto Result = getTypeDeclType(TD); !Result.isNull()) {
+return Result;
+  }
+}
+  }
+  return FallBack;
+}
+
 static GVALinkage basicGVALinkageForFunction(const ASTContext &Context,
  const FunctionDecl *FD) {
   if (!FD->isExternallyVisible())
diff --git a/clang/lib/AST/ComparisonCategories.cpp 
b/clang/lib/AST/ComparisonCategories.cpp
index 28244104d6636..46dcd6ac4261d 100644
--- a/clang/lib/AST/ComparisonCategories.cpp
+++ b/clang/lib/AST/ComparisonCategories.cpp
@@ -87,37 +87,17 @@ ComparisonCategoryInfo::ValueInfo 
*ComparisonCategoryInfo::lookupValueInfo(
   return &Objects.back();
 }
 
-static const NamespaceDecl *lookupStdNamespace(const ASTContext &Ctx,
-   NamespaceDecl *&StdNS) {
-  if (!StdNS) {
-DeclContextLookupResult Lookup =
-Ctx.getTranslationUnitDecl()->lookup(&Ctx.Idents.get("std"));
-if (!Lookup.empty())
-  StdNS = dyn_cast(Lookup.front());
-  }
-  return StdNS;
-}
-
-static const CXXRecordDecl *lookupCXXRecordDecl(const ASTContext &Ctx,
-const NamespaceDecl *StdNS,
-ComparisonCategoryType Kind) {
-  StringRef Name = ComparisonCategories::getCategoryString(Kind);
-  DeclContextLookupResult Lookup = StdNS->lookup(&Ctx.Idents.get(Name));
-  if (!Lookup.empty())
-if (const CXXRecordDecl *RD = dyn_cast(Lookup.front()))
-  return RD;
-  return nullptr;
-}
-
 const ComparisonCategoryInfo *
 ComparisonCategories::lookupInfo(ComparisonCategoryType Kind) const {
   auto It = Data.find(static_cast(Kind));
   if (It != Data.end())
 return &It->second;
-
-  if (const NamespaceDecl *NS = lookupStdNamespace(Ctx, StdNS))
-if (const CXXRecordDecl *RD = lookupCXXRecordDecl(Ctx, NS, Kind))
+  if (auto QT 

[clang-tools-extra] [clangd] Improve `BlockEnd` inlayhint presentation (PR #136106)

2025-04-21 Thread via cfe-commits

https://github.com/MythreyaK updated 
https://github.com/llvm/llvm-project/pull/136106

>From 9d5768eecc0c5b7fda88cc8da3fa798c985d71e4 Mon Sep 17 00:00:00 2001
From: daiyousei-qz 
Date: Tue, 14 Nov 2023 20:42:10 -0800
Subject: [PATCH 1/5] Improve BlockEnd presentation including: 1. Explicitly
 state a function call 2. Print literal nullptr 3. Escape for abbreviated
 string 4. Adjust min line limit to 10

---
 clang-tools-extra/clangd/InlayHints.cpp | 19 +--
 1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/clang-tools-extra/clangd/InlayHints.cpp 
b/clang-tools-extra/clangd/InlayHints.cpp
index 40a824618f782..a1bc9956ec628 100644
--- a/clang-tools-extra/clangd/InlayHints.cpp
+++ b/clang-tools-extra/clangd/InlayHints.cpp
@@ -112,7 +112,9 @@ std::string summarizeExpr(const Expr *E) {
   return getSimpleName(*E->getFoundDecl()).str();
 }
 std::string VisitCallExpr(const CallExpr *E) {
-  return Visit(E->getCallee());
+  std::string Result = Visit(E->getCallee());
+  Result += E->getNumArgs() == 0 ? "()" : "(...)";
+  return Result;
 }
 std::string
 VisitCXXDependentScopeMemberExpr(const CXXDependentScopeMemberExpr *E) {
@@ -147,6 +149,9 @@ std::string summarizeExpr(const Expr *E) {
 }
 
 // Literals are just printed
+std::string VisitCXXNullPtrLiteralExpr(const CXXNullPtrLiteralExpr *E) {
+  return "nullptr";
+}
 std::string VisitCXXBoolLiteralExpr(const CXXBoolLiteralExpr *E) {
   return E->getValue() ? "true" : "false";
 }
@@ -165,12 +170,14 @@ std::string summarizeExpr(const Expr *E) {
   std::string Result = "\"";
   if (E->containsNonAscii()) {
 Result += "...";
-  } else if (E->getLength() > 10) {
-Result += E->getString().take_front(7);
-Result += "...";
   } else {
 llvm::raw_string_ostream OS(Result);
-llvm::printEscapedString(E->getString(), OS);
+if (E->getLength() > 10) {
+  llvm::printEscapedString(E->getString().take_front(7), OS);
+  Result += "...";
+} else {
+  llvm::printEscapedString(E->getString(), OS);
+}
   }
   Result.push_back('"');
   return Result;
@@ -1120,7 +1127,7 @@ class InlayHintVisitor : public 
RecursiveASTVisitor {
   // Otherwise, the hint shouldn't be shown.
   std::optional computeBlockEndHintRange(SourceRange BraceRange,
 StringRef OptionalPunctuation) 
{
-constexpr unsigned HintMinLineLimit = 2;
+constexpr unsigned HintMinLineLimit = 10;
 
 auto &SM = AST.getSourceManager();
 auto [BlockBeginFileId, BlockBeginOffset] =

>From 9d90af1e611e3f033758c7c0b753d0ed3b68f002 Mon Sep 17 00:00:00 2001
From: Mythreya 
Date: Thu, 17 Apr 2025 01:28:53 -0700
Subject: [PATCH 2/5] Add `InlayHintOptions`

---
 clang-tools-extra/clangd/InlayHints.cpp | 16 ++--
 clang-tools-extra/clangd/InlayHints.h   |  8 +++-
 2 files changed, 17 insertions(+), 7 deletions(-)

diff --git a/clang-tools-extra/clangd/InlayHints.cpp 
b/clang-tools-extra/clangd/InlayHints.cpp
index a1bc9956ec628..bdab2b8a9f377 100644
--- a/clang-tools-extra/clangd/InlayHints.cpp
+++ b/clang-tools-extra/clangd/InlayHints.cpp
@@ -415,12 +415,14 @@ struct Callee {
 class InlayHintVisitor : public RecursiveASTVisitor {
 public:
   InlayHintVisitor(std::vector &Results, ParsedAST &AST,
-   const Config &Cfg, std::optional RestrictRange)
+   const Config &Cfg, std::optional RestrictRange,
+   InlayHintOptions HintOptions)
   : Results(Results), AST(AST.getASTContext()), Tokens(AST.getTokens()),
 Cfg(Cfg), RestrictRange(std::move(RestrictRange)),
 MainFileID(AST.getSourceManager().getMainFileID()),
 Resolver(AST.getHeuristicResolver()),
-TypeHintPolicy(this->AST.getPrintingPolicy()) {
+TypeHintPolicy(this->AST.getPrintingPolicy()),
+HintOptions(HintOptions) {
 bool Invalid = false;
 llvm::StringRef Buf =
 AST.getSourceManager().getBufferData(MainFileID, &Invalid);
@@ -1127,7 +1129,6 @@ class InlayHintVisitor : public 
RecursiveASTVisitor {
   // Otherwise, the hint shouldn't be shown.
   std::optional computeBlockEndHintRange(SourceRange BraceRange,
 StringRef OptionalPunctuation) 
{
-constexpr unsigned HintMinLineLimit = 10;
 
 auto &SM = AST.getSourceManager();
 auto [BlockBeginFileId, BlockBeginOffset] =
@@ -1155,7 +1156,7 @@ class InlayHintVisitor : public 
RecursiveASTVisitor {
 auto RBraceLine = SM.getLineNumber(RBraceFileId, RBraceOffset);
 
 // Don't show hint on trivial blocks like `class X {};`
-if (BlockBeginLine + HintMinLineLimit - 1 > RBraceLine)
+if (BlockBeginLine + HintOptions.HintMinLineLimit - 1 > RBraceLine)
   return std::nullopt;
 
 // This is what we attach the hint to, usually "}" or "};".
@@ -1185,17 +1186,20 @@ class I

[clang-tools-extra] [clangd] Improve `BlockEnd` inlayhint presentation (PR #136106)

2025-04-21 Thread via cfe-commits


@@ -147,6 +149,9 @@ std::string summarizeExpr(const Expr *E) {
 }
 
 // Literals are just printed
+std::string VisitCXXNullPtrLiteralExpr(const CXXNullPtrLiteralExpr *E) {
+  return "nullptr";

MythreyaK wrote:

Added it to `TEST(BlockEndHints, If)`

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


[clang-tools-extra] [clangd] Improve `BlockEnd` inlayhint presentation (PR #136106)

2025-04-21 Thread via cfe-commits

https://github.com/MythreyaK updated 
https://github.com/llvm/llvm-project/pull/136106

>From 64410e0c5bbdc3f631e2efecef475768d48ef233 Mon Sep 17 00:00:00 2001
From: daiyousei-qz 
Date: Tue, 14 Nov 2023 20:42:10 -0800
Subject: [PATCH 1/5] Improve BlockEnd presentation including: 1. Explicitly
 state a function call 2. Print literal nullptr 3. Escape for abbreviated
 string 4. Adjust min line limit to 10

---
 clang-tools-extra/clangd/InlayHints.cpp | 19 +--
 1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/clang-tools-extra/clangd/InlayHints.cpp 
b/clang-tools-extra/clangd/InlayHints.cpp
index 40a824618f782..a1bc9956ec628 100644
--- a/clang-tools-extra/clangd/InlayHints.cpp
+++ b/clang-tools-extra/clangd/InlayHints.cpp
@@ -112,7 +112,9 @@ std::string summarizeExpr(const Expr *E) {
   return getSimpleName(*E->getFoundDecl()).str();
 }
 std::string VisitCallExpr(const CallExpr *E) {
-  return Visit(E->getCallee());
+  std::string Result = Visit(E->getCallee());
+  Result += E->getNumArgs() == 0 ? "()" : "(...)";
+  return Result;
 }
 std::string
 VisitCXXDependentScopeMemberExpr(const CXXDependentScopeMemberExpr *E) {
@@ -147,6 +149,9 @@ std::string summarizeExpr(const Expr *E) {
 }
 
 // Literals are just printed
+std::string VisitCXXNullPtrLiteralExpr(const CXXNullPtrLiteralExpr *E) {
+  return "nullptr";
+}
 std::string VisitCXXBoolLiteralExpr(const CXXBoolLiteralExpr *E) {
   return E->getValue() ? "true" : "false";
 }
@@ -165,12 +170,14 @@ std::string summarizeExpr(const Expr *E) {
   std::string Result = "\"";
   if (E->containsNonAscii()) {
 Result += "...";
-  } else if (E->getLength() > 10) {
-Result += E->getString().take_front(7);
-Result += "...";
   } else {
 llvm::raw_string_ostream OS(Result);
-llvm::printEscapedString(E->getString(), OS);
+if (E->getLength() > 10) {
+  llvm::printEscapedString(E->getString().take_front(7), OS);
+  Result += "...";
+} else {
+  llvm::printEscapedString(E->getString(), OS);
+}
   }
   Result.push_back('"');
   return Result;
@@ -1120,7 +1127,7 @@ class InlayHintVisitor : public 
RecursiveASTVisitor {
   // Otherwise, the hint shouldn't be shown.
   std::optional computeBlockEndHintRange(SourceRange BraceRange,
 StringRef OptionalPunctuation) 
{
-constexpr unsigned HintMinLineLimit = 2;
+constexpr unsigned HintMinLineLimit = 10;
 
 auto &SM = AST.getSourceManager();
 auto [BlockBeginFileId, BlockBeginOffset] =

>From fe79c934873f5df8c13ef130adf96a05cc48364f Mon Sep 17 00:00:00 2001
From: Mythreya 
Date: Thu, 17 Apr 2025 01:28:53 -0700
Subject: [PATCH 2/5] Add `InlayHintOptions`

---
 clang-tools-extra/clangd/InlayHints.cpp | 16 ++--
 clang-tools-extra/clangd/InlayHints.h   |  8 +++-
 2 files changed, 17 insertions(+), 7 deletions(-)

diff --git a/clang-tools-extra/clangd/InlayHints.cpp 
b/clang-tools-extra/clangd/InlayHints.cpp
index a1bc9956ec628..bdab2b8a9f377 100644
--- a/clang-tools-extra/clangd/InlayHints.cpp
+++ b/clang-tools-extra/clangd/InlayHints.cpp
@@ -415,12 +415,14 @@ struct Callee {
 class InlayHintVisitor : public RecursiveASTVisitor {
 public:
   InlayHintVisitor(std::vector &Results, ParsedAST &AST,
-   const Config &Cfg, std::optional RestrictRange)
+   const Config &Cfg, std::optional RestrictRange,
+   InlayHintOptions HintOptions)
   : Results(Results), AST(AST.getASTContext()), Tokens(AST.getTokens()),
 Cfg(Cfg), RestrictRange(std::move(RestrictRange)),
 MainFileID(AST.getSourceManager().getMainFileID()),
 Resolver(AST.getHeuristicResolver()),
-TypeHintPolicy(this->AST.getPrintingPolicy()) {
+TypeHintPolicy(this->AST.getPrintingPolicy()),
+HintOptions(HintOptions) {
 bool Invalid = false;
 llvm::StringRef Buf =
 AST.getSourceManager().getBufferData(MainFileID, &Invalid);
@@ -1127,7 +1129,6 @@ class InlayHintVisitor : public 
RecursiveASTVisitor {
   // Otherwise, the hint shouldn't be shown.
   std::optional computeBlockEndHintRange(SourceRange BraceRange,
 StringRef OptionalPunctuation) 
{
-constexpr unsigned HintMinLineLimit = 10;
 
 auto &SM = AST.getSourceManager();
 auto [BlockBeginFileId, BlockBeginOffset] =
@@ -1155,7 +1156,7 @@ class InlayHintVisitor : public 
RecursiveASTVisitor {
 auto RBraceLine = SM.getLineNumber(RBraceFileId, RBraceOffset);
 
 // Don't show hint on trivial blocks like `class X {};`
-if (BlockBeginLine + HintMinLineLimit - 1 > RBraceLine)
+if (BlockBeginLine + HintOptions.HintMinLineLimit - 1 > RBraceLine)
   return std::nullopt;
 
 // This is what we attach the hint to, usually "}" or "};".
@@ -1185,17 +1186,20 @@ class I

[clang-tools-extra] [clangd] Improve `BlockEnd` inlayhint presentation (PR #136106)

2025-04-21 Thread Nathan Ridge via cfe-commits

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


[clang-tools-extra] [clangd] Improve `BlockEnd` inlayhint presentation (PR #136106)

2025-04-21 Thread Nathan Ridge via cfe-commits


@@ -2305,7 +2335,45 @@ TEST(BlockEndHints, PointerToMemberFunction) {
   $ptrmem[[}]]
 } // suppress
   )cpp",
-  ExpectedHint{" // if", "ptrmem"});
+  ExpectedHint{" // if ()", "ptrmem"});
+}
+
+TEST(BlockEndHints, MinLineLimit) {
+  assertBlockEndHintsWithOpts(
+  R"cpp(
+namespace ns {
+  int Var;
+  int func1();
+  int func2(int, int);
+  struct S {
+int Field;
+int method1() const;
+int method2(int, int) const;
+  $struct[[}]];

HighCommander4 wrote:

It's not necessary.

The core assertion the tests make is [this 
one](https://searchfox.org/llvm/rev/bb21a6819b3fb9d689de776f7ee768030dfbacea/clang-tools-extra/clangd/unittests/InlayHintTests.cpp#101-102):

```
  EXPECT_THAT(hintsOfKind(AST, Kind),
  ElementsAre(HintMatcher(Expected, Source)...));
```

`hintsOfKind(AST, Kind)` returns **all** inlay hints of the specified kind in 
the code; its output does not depend on the presence or absence of annotations 
in the code.

`ElementsAre(...)` then assert that these returned hints match the provided 
`ExpectedHint` objects, including how many there are. If in the test case you 
have two `ExpectedHint` objects, and the `hintsOfKind()` starts returning three 
hints, the test will start failing.

The only purpose of the annotations is so that you can name a range passed in 
to an `ExpectedHint`; if you never need to name the range, you don't need the 
annotation.

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


[clang-tools-extra] [clangd] Improve `BlockEnd` inlayhint presentation (PR #136106)

2025-04-21 Thread via cfe-commits

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


[clang] [CIR][NFC] Simplify BoolAttr builders (PR #136366)

2025-04-21 Thread Henrich Lauko via cfe-commits

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


[clang] 050ca5e - [CIR][NFC] Simplify BoolAttr builders (#136366)

2025-04-21 Thread via cfe-commits

Author: Henrich Lauko
Date: 2025-04-21T09:07:57+02:00
New Revision: 050ca5e27082055f41ad7e3dd2dea2f39364b3ab

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

LOG: [CIR][NFC] Simplify BoolAttr builders (#136366)

This mirrors incubator changes from https://github.com/llvm/clangir/pull/1572

Added: 


Modified: 
clang/include/clang/CIR/Dialect/Builder/CIRBaseBuilder.h
clang/include/clang/CIR/Dialect/IR/CIRAttrs.td
clang/include/clang/CIR/Dialect/IR/CIROps.td
clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp
clang/lib/CIR/CodeGen/CIRGenStmt.cpp
clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp

Removed: 




diff  --git a/clang/include/clang/CIR/Dialect/Builder/CIRBaseBuilder.h 
b/clang/include/clang/CIR/Dialect/Builder/CIRBaseBuilder.h
index d2a241964f34f..ee8af62ede0da 100644
--- a/clang/include/clang/CIR/Dialect/Builder/CIRBaseBuilder.h
+++ b/clang/include/clang/CIR/Dialect/Builder/CIRBaseBuilder.h
@@ -57,6 +57,7 @@ class CIRBaseBuilderTy : public mlir::OpBuilder {
 public:
   CIRBaseBuilderTy(mlir::MLIRContext &mlirContext)
   : mlir::OpBuilder(&mlirContext) {}
+  CIRBaseBuilderTy(mlir::OpBuilder &builder) : mlir::OpBuilder(builder) {}
 
   mlir::Value getConstAPInt(mlir::Location loc, mlir::Type typ,
 const llvm::APInt &val) {
@@ -98,13 +99,13 @@ class CIRBaseBuilderTy : public mlir::OpBuilder {
 if (auto recordTy = mlir::dyn_cast(ty))
   return getZeroAttr(recordTy);
 if (mlir::isa(ty)) {
-  return getCIRBoolAttr(false);
+  return getFalseAttr();
 }
 llvm_unreachable("Zero initializer for given type is NYI");
   }
 
   cir::ConstantOp getBool(bool state, mlir::Location loc) {
-return create(loc, getBoolTy(), getCIRBoolAttr(state));
+return create(loc, getCIRBoolAttr(state));
   }
   cir::ConstantOp getFalse(mlir::Location loc) { return getBool(false, loc); }
   cir::ConstantOp getTrue(mlir::Location loc) { return getBool(true, loc); }
@@ -120,9 +121,12 @@ class CIRBaseBuilderTy : public mlir::OpBuilder {
   }
 
   cir::BoolAttr getCIRBoolAttr(bool state) {
-return cir::BoolAttr::get(getContext(), getBoolTy(), state);
+return cir::BoolAttr::get(getContext(), state);
   }
 
+  cir::BoolAttr getTrueAttr() { return getCIRBoolAttr(true); }
+  cir::BoolAttr getFalseAttr() { return getCIRBoolAttr(false); }
+
   mlir::Value createNot(mlir::Value value) {
 return create(value.getLoc(), value.getType(),
 cir::UnaryOpKind::Not, value);

diff  --git a/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td 
b/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td
index 3680ded4afafe..25ceded7e8a5b 100644
--- a/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td
+++ b/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td
@@ -49,6 +49,12 @@ def CIR_BoolAttr : CIR_Attr<"Bool", "bool", 
[TypedAttrInterface]> {
 "", "cir::BoolType">:$type,
 "bool":$value);
 
+  let builders = [
+AttrBuilder<(ins "bool":$value), [{
+  return $_get($_ctxt, cir::BoolType::get($_ctxt), value);
+}]>,
+  ];
+
   let assemblyFormat = [{
 `<` $value `>`
   }];

diff  --git a/clang/include/clang/CIR/Dialect/IR/CIROps.td 
b/clang/include/clang/CIR/Dialect/IR/CIROps.td
index 5ba4b33dc1a12..b526d077a910c 100644
--- a/clang/include/clang/CIR/Dialect/IR/CIROps.td
+++ b/clang/include/clang/CIR/Dialect/IR/CIROps.td
@@ -294,6 +294,12 @@ def ConstantOp : CIR_Op<"const",
   // The constant operation returns a single value of CIR_AnyType.
   let results = (outs CIR_AnyType:$res);
 
+  let builders = [
+OpBuilder<(ins "cir::BoolAttr":$value), [{
+  build($_builder, $_state, value.getType(), value);
+}]>
+  ];
+
   let assemblyFormat = "attr-dict $value";
 
   let hasVerifier = 1;
@@ -844,7 +850,7 @@ def UnaryOp : CIR_Op<"unary", [Pure, 
SameOperandsAndResultType]> {
   let assemblyFormat = [{
   `(` $kind `,` $input `)`
   (`nsw` $no_signed_wrap^)?
-  `:` type($input) `,` type($result) attr-dict 
+  `:` type($input) `,` type($result) attr-dict
   }];
 
   let hasVerifier = 1;

diff  --git a/clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp 
b/clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp
index 1bef1b976a4b5..f1561d1b26fc0 100644
--- a/clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp
@@ -152,10 +152,7 @@ class ScalarExprEmitter : public 
StmtVisitor {
   }
 
   mlir::Value VisitCXXBoolLiteralExpr(const CXXBoolLiteralExpr *e) {
-mlir::Type type = cgf.convertType(e->getType());
-return builder.create(
-cgf.getLoc(e->getExprLoc()), type,
-builder.getCIRBoolAttr(e->getValue()));
+return builder.getBool(e->getValue(), cgf.getLoc(e->getExprLoc()));
   }
 
   mlir::Value VisitCastExpr(CastExpr

[clang] [llvm] [clang][AVR] Improve compatibility of inline assembly with avr-gcc (PR #136534)

2025-04-21 Thread Ben Shi via cfe-commits

https://github.com/benshi001 updated 
https://github.com/llvm/llvm-project/pull/136534

>From 1dcd2d91c37a4e6afc137ff0ad54d25777a1f4b1 Mon Sep 17 00:00:00 2001
From: Ben Shi 
Date: Mon, 21 Apr 2025 11:16:51 +0800
Subject: [PATCH 1/2] [clang][AVR] Improve compitability of inline assembly
 with avr-gcc

Allow the value 64 to be round up to 0 for constraint 'I'.
---
 clang/lib/Basic/Targets/AVR.h   | 2 +-
 clang/test/CodeGen/avr/avr-inline-asm-constraints.c | 2 ++
 clang/test/CodeGen/avr/avr-unsupported-inline-asm-constraints.c | 1 +
 3 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/clang/lib/Basic/Targets/AVR.h b/clang/lib/Basic/Targets/AVR.h
index 2117ab58e6f30..b2f2711c35435 100644
--- a/clang/lib/Basic/Targets/AVR.h
+++ b/clang/lib/Basic/Targets/AVR.h
@@ -124,7 +124,7 @@ class LLVM_LIBRARY_VISIBILITY AVRTargetInfo : public 
TargetInfo {
   Info.setAllowsRegister();
   return true;
 case 'I': // 6-bit positive integer constant
-  Info.setRequiresImmediate(0, 63);
+  Info.setRequiresImmediate(0, 64);
   return true;
 case 'J': // 6-bit negative integer constant
   Info.setRequiresImmediate(-63, 0);
diff --git a/clang/test/CodeGen/avr/avr-inline-asm-constraints.c 
b/clang/test/CodeGen/avr/avr-inline-asm-constraints.c
index 3a956de8db48f..c8d83b4848312 100644
--- a/clang/test/CodeGen/avr/avr-inline-asm-constraints.c
+++ b/clang/test/CodeGen/avr/avr-inline-asm-constraints.c
@@ -71,6 +71,8 @@ void z() {
 void I() {
   // CHECK: call addrspace(0) void asm sideeffect "subi r30, $0", "I"(i16 50)
   asm("subi r30, %0" :: "I"(50));
+  // CHECK: call addrspace(0) void asm sideeffect "subi r30, $0", "I"(i16 64)
+  asm("subi r30, %0" :: "I"(64));
 }
 
 void J() {
diff --git a/clang/test/CodeGen/avr/avr-unsupported-inline-asm-constraints.c 
b/clang/test/CodeGen/avr/avr-unsupported-inline-asm-constraints.c
index 29f0b69285fa8..52b8d1cb044ca 100644
--- a/clang/test/CodeGen/avr/avr-unsupported-inline-asm-constraints.c
+++ b/clang/test/CodeGen/avr/avr-unsupported-inline-asm-constraints.c
@@ -6,4 +6,5 @@ int foo(void) {
   __asm__ volatile("foo %0, 1" : : "fo" (val)); // expected-error {{invalid 
input constraint 'fo' in asm}}
   __asm__ volatile("foo %0, 1" : : "Nd" (val)); // expected-error {{invalid 
input constraint 'Nd' in asm}}
   __asm__ volatile("subi r30, %0" : : "G" (1)); // expected-error {{value '1' 
out of range for constraint 'G'}}
+  __asm__ volatile("out %0, r20" : : "I" (65)); // expected-error {{value '65' 
out of range for constraint 'I'}}
 }

>From c8639a51d8a035644b72211e85f092e0eecd648e Mon Sep 17 00:00:00 2001
From: Ben Shi 
Date: Mon, 21 Apr 2025 15:32:19 +0800
Subject: [PATCH 2/2] [AVR][NFC] Supplement a test for inline assembly
 constraint 'I'

---
 clang/lib/Basic/Targets/AVR.h  | 2 ++
 llvm/test/CodeGen/AVR/inline-asm/inline-asm-invalid.ll | 6 ++
 2 files changed, 8 insertions(+)

diff --git a/clang/lib/Basic/Targets/AVR.h b/clang/lib/Basic/Targets/AVR.h
index b2f2711c35435..dfe64f8fae93f 100644
--- a/clang/lib/Basic/Targets/AVR.h
+++ b/clang/lib/Basic/Targets/AVR.h
@@ -124,6 +124,8 @@ class LLVM_LIBRARY_VISIBILITY AVRTargetInfo : public 
TargetInfo {
   Info.setAllowsRegister();
   return true;
 case 'I': // 6-bit positive integer constant
+  // Due to issue https://github.com/llvm/llvm-project/issues/51513, we
+  // allow value 64 in the frontend and let it be dinied in the backend.
   Info.setRequiresImmediate(0, 64);
   return true;
 case 'J': // 6-bit negative integer constant
diff --git a/llvm/test/CodeGen/AVR/inline-asm/inline-asm-invalid.ll 
b/llvm/test/CodeGen/AVR/inline-asm/inline-asm-invalid.ll
index 416eb19c29db9..be54b4464f08c 100644
--- a/llvm/test/CodeGen/AVR/inline-asm/inline-asm-invalid.ll
+++ b/llvm/test/CodeGen/AVR/inline-asm/inline-asm-invalid.ll
@@ -21,3 +21,9 @@ define void @foo2() {
   call void asm sideeffect "ldd r24, X+2", ""()
   ret void
 }
+
+define void @foo3() {
+  ; AVR6: error: value out of range for constraint 'I'
+  call void asm sideeffect "out $0, r20", "I"(i16 64)
+  ret void
+}

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


[clang] [llvm] [clang][AVR] Improve compatibility of inline assembly with avr-gcc (PR #136534)

2025-04-21 Thread Ben Shi via cfe-commits

https://github.com/benshi001 updated 
https://github.com/llvm/llvm-project/pull/136534

>From 1dcd2d91c37a4e6afc137ff0ad54d25777a1f4b1 Mon Sep 17 00:00:00 2001
From: Ben Shi 
Date: Mon, 21 Apr 2025 11:16:51 +0800
Subject: [PATCH 1/3] [clang][AVR] Improve compitability of inline assembly
 with avr-gcc

Allow the value 64 to be round up to 0 for constraint 'I'.
---
 clang/lib/Basic/Targets/AVR.h   | 2 +-
 clang/test/CodeGen/avr/avr-inline-asm-constraints.c | 2 ++
 clang/test/CodeGen/avr/avr-unsupported-inline-asm-constraints.c | 1 +
 3 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/clang/lib/Basic/Targets/AVR.h b/clang/lib/Basic/Targets/AVR.h
index 2117ab58e6f30..b2f2711c35435 100644
--- a/clang/lib/Basic/Targets/AVR.h
+++ b/clang/lib/Basic/Targets/AVR.h
@@ -124,7 +124,7 @@ class LLVM_LIBRARY_VISIBILITY AVRTargetInfo : public 
TargetInfo {
   Info.setAllowsRegister();
   return true;
 case 'I': // 6-bit positive integer constant
-  Info.setRequiresImmediate(0, 63);
+  Info.setRequiresImmediate(0, 64);
   return true;
 case 'J': // 6-bit negative integer constant
   Info.setRequiresImmediate(-63, 0);
diff --git a/clang/test/CodeGen/avr/avr-inline-asm-constraints.c 
b/clang/test/CodeGen/avr/avr-inline-asm-constraints.c
index 3a956de8db48f..c8d83b4848312 100644
--- a/clang/test/CodeGen/avr/avr-inline-asm-constraints.c
+++ b/clang/test/CodeGen/avr/avr-inline-asm-constraints.c
@@ -71,6 +71,8 @@ void z() {
 void I() {
   // CHECK: call addrspace(0) void asm sideeffect "subi r30, $0", "I"(i16 50)
   asm("subi r30, %0" :: "I"(50));
+  // CHECK: call addrspace(0) void asm sideeffect "subi r30, $0", "I"(i16 64)
+  asm("subi r30, %0" :: "I"(64));
 }
 
 void J() {
diff --git a/clang/test/CodeGen/avr/avr-unsupported-inline-asm-constraints.c 
b/clang/test/CodeGen/avr/avr-unsupported-inline-asm-constraints.c
index 29f0b69285fa8..52b8d1cb044ca 100644
--- a/clang/test/CodeGen/avr/avr-unsupported-inline-asm-constraints.c
+++ b/clang/test/CodeGen/avr/avr-unsupported-inline-asm-constraints.c
@@ -6,4 +6,5 @@ int foo(void) {
   __asm__ volatile("foo %0, 1" : : "fo" (val)); // expected-error {{invalid 
input constraint 'fo' in asm}}
   __asm__ volatile("foo %0, 1" : : "Nd" (val)); // expected-error {{invalid 
input constraint 'Nd' in asm}}
   __asm__ volatile("subi r30, %0" : : "G" (1)); // expected-error {{value '1' 
out of range for constraint 'G'}}
+  __asm__ volatile("out %0, r20" : : "I" (65)); // expected-error {{value '65' 
out of range for constraint 'I'}}
 }

>From c8639a51d8a035644b72211e85f092e0eecd648e Mon Sep 17 00:00:00 2001
From: Ben Shi 
Date: Mon, 21 Apr 2025 15:32:19 +0800
Subject: [PATCH 2/3] [AVR][NFC] Supplement a test for inline assembly
 constraint 'I'

---
 clang/lib/Basic/Targets/AVR.h  | 2 ++
 llvm/test/CodeGen/AVR/inline-asm/inline-asm-invalid.ll | 6 ++
 2 files changed, 8 insertions(+)

diff --git a/clang/lib/Basic/Targets/AVR.h b/clang/lib/Basic/Targets/AVR.h
index b2f2711c35435..dfe64f8fae93f 100644
--- a/clang/lib/Basic/Targets/AVR.h
+++ b/clang/lib/Basic/Targets/AVR.h
@@ -124,6 +124,8 @@ class LLVM_LIBRARY_VISIBILITY AVRTargetInfo : public 
TargetInfo {
   Info.setAllowsRegister();
   return true;
 case 'I': // 6-bit positive integer constant
+  // Due to issue https://github.com/llvm/llvm-project/issues/51513, we
+  // allow value 64 in the frontend and let it be dinied in the backend.
   Info.setRequiresImmediate(0, 64);
   return true;
 case 'J': // 6-bit negative integer constant
diff --git a/llvm/test/CodeGen/AVR/inline-asm/inline-asm-invalid.ll 
b/llvm/test/CodeGen/AVR/inline-asm/inline-asm-invalid.ll
index 416eb19c29db9..be54b4464f08c 100644
--- a/llvm/test/CodeGen/AVR/inline-asm/inline-asm-invalid.ll
+++ b/llvm/test/CodeGen/AVR/inline-asm/inline-asm-invalid.ll
@@ -21,3 +21,9 @@ define void @foo2() {
   call void asm sideeffect "ldd r24, X+2", ""()
   ret void
 }
+
+define void @foo3() {
+  ; AVR6: error: value out of range for constraint 'I'
+  call void asm sideeffect "out $0, r20", "I"(i16 64)
+  ret void
+}

>From 140b24064f1556347ee3971d091397242e1057eb Mon Sep 17 00:00:00 2001
From: Ben Shi 
Date: Mon, 21 Apr 2025 15:36:31 +0800
Subject: [PATCH 3/3] typo

---
 clang/lib/Basic/Targets/AVR.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/lib/Basic/Targets/AVR.h b/clang/lib/Basic/Targets/AVR.h
index dfe64f8fae93f..75c969fd59dc9 100644
--- a/clang/lib/Basic/Targets/AVR.h
+++ b/clang/lib/Basic/Targets/AVR.h
@@ -125,7 +125,7 @@ class LLVM_LIBRARY_VISIBILITY AVRTargetInfo : public 
TargetInfo {
   return true;
 case 'I': // 6-bit positive integer constant
   // Due to issue https://github.com/llvm/llvm-project/issues/51513, we
-  // allow value 64 in the frontend and let it be dinied in the backend.
+  // allow value 64 in the frontend and let it be denied in the backend.
   Info.setRequiresImmed

[clang] [llvm] DO NOT MERGE: Identify places that need reserve. (PR #136543)

2025-04-21 Thread Kazu Hirata via cfe-commits

https://github.com/kazutakahirata created 
https://github.com/llvm/llvm-project/pull/136543

None

>From 2022f8dee6651e99f5c1af1cbb8b89e22dc16916 Mon Sep 17 00:00:00 2001
From: Kazu Hirata 
Date: Sat, 19 Apr 2025 22:42:07 -0700
Subject: [PATCH] DO NOT MERGE: Identify places that need reserve.

---
 clang/lib/Analysis/CFG.cpp|  2 +
 llvm/include/llvm/ADT/STLExtras.h | 51 +++
 llvm/lib/CodeGen/SplitKit.cpp |  1 +
 llvm/lib/IR/Verifier.cpp  |  5 +-
 llvm/lib/Transforms/IPO/ArgumentPromotion.cpp |  2 +
 llvm/lib/Transforms/IPO/FunctionAttrs.cpp |  1 +
 llvm/lib/Transforms/IPO/GlobalOpt.cpp |  6 ++-
 llvm/lib/Transforms/Utils/LoopSimplify.cpp|  4 +-
 llvm/lib/Transforms/Utils/SSAUpdater.cpp  |  6 ++-
 .../Transforms/Vectorize/LoopVectorize.cpp|  1 +
 .../TableGen/Common/CodeGenRegisters.cpp  |  1 +
 llvm/utils/TableGen/GlobalISelEmitter.cpp |  1 +
 12 files changed, 75 insertions(+), 6 deletions(-)

diff --git a/clang/lib/Analysis/CFG.cpp b/clang/lib/Analysis/CFG.cpp
index d03a0a544b016..6ff485049c28e 100644
--- a/clang/lib/Analysis/CFG.cpp
+++ b/clang/lib/Analysis/CFG.cpp
@@ -484,6 +484,8 @@ reverse_children::reverse_children(Stmt *S, ASTContext 
&Ctx) {
   }
 
   // Default case for all other statements.
+  auto R = S->children();
+  childrenBuf.reserve(childrenBuf.size() + std::distance(R.begin(), R.end()));
   llvm::append_range(childrenBuf, S->children());
 
   // This needs to be done *after* childrenBuf has been populated.
diff --git a/llvm/include/llvm/ADT/STLExtras.h 
b/llvm/include/llvm/ADT/STLExtras.h
index dc0443c9244be..ec662594232e2 100644
--- a/llvm/include/llvm/ADT/STLExtras.h
+++ b/llvm/include/llvm/ADT/STLExtras.h
@@ -2113,12 +2113,63 @@ void erase(Container &C, ValueType V) {
   C.erase(std::remove(C.begin(), C.end(), V), C.end());
 }
 
+namespace detail {
+template 
+using check_has_member_iterator_category_t =
+typename decltype(std::declval().begin())::iterator_category;
+
+template 
+static constexpr bool HasMemberIteratorCategory =
+is_detected::value;
+
+template 
+using check_has_member_capacity_t =
+decltype(std::declval().capacity());
+
+template 
+static constexpr bool HasMemberCapacity =
+is_detected::value;
+
+template 
+using check_has_member_reserve_t =
+decltype(std::declval().reserve(1U));
+
+template 
+static constexpr bool HasMemberReserve =
+is_detected::value;
+} // namespace detail
+
 /// Wrapper function to append range `R` to container `C`.
 ///
 /// C.insert(C.end(), R.begin(), R.end());
 template 
 void append_range(Container &C, Range &&R) {
+  size_t Before = 0;
+  size_t After = 0;
+
+  if constexpr (detail::HasMemberReserve) {
+using IteratorType = decltype(adl_begin(R));
+if constexpr (std::is_pointer::value) {
+  C.reserve(C.size() + std::distance(adl_begin(R), adl_end(R)));
+} else if constexpr (detail::HasMemberIteratorCategory) {
+  if constexpr (std::is_convertible<
+typename IteratorType::iterator_category,
+std::random_access_iterator_tag>::value) {
+C.reserve(C.size() + std::distance(adl_begin(R), adl_end(R)));
+  }
+}
+  }
+
+  if constexpr (detail::HasMemberCapacity)
+Before = C.capacity();
+
   C.insert(C.end(), adl_begin(R), adl_end(R));
+
+  if constexpr (detail::HasMemberCapacity)
+After = C.capacity();
+
+  if (Before != After)
+llvm_unreachable("capacity changed");
 }
 
 /// Appends all `Values` to container `C`.
diff --git a/llvm/lib/CodeGen/SplitKit.cpp b/llvm/lib/CodeGen/SplitKit.cpp
index e55dfaebd028e..416dc0fdac2f2 100644
--- a/llvm/lib/CodeGen/SplitKit.cpp
+++ b/llvm/lib/CodeGen/SplitKit.cpp
@@ -1035,6 +1035,7 @@ void SplitEditor::computeRedundantBackCopies(
 }
 if (!DominatedVNIs.empty()) {
   forceRecompute(0, *ParentVNI);
+  BackCopies.reserve(BackCopies.size() + DominatedVNIs.size());
   append_range(BackCopies, DominatedVNIs);
   DominatedVNIs.clear();
 }
diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp
index 8afe360d088bc..5a3bac7f26a75 100644
--- a/llvm/lib/IR/Verifier.cpp
+++ b/llvm/lib/IR/Verifier.cpp
@@ -725,8 +725,11 @@ static void forEachUser(const Value *User,
const Value *Cur = WorkList.pop_back_val();
 if (!Visited.insert(Cur).second)
   continue;
-if (Callback(Cur))
+if (Callback(Cur)) {
+  auto R = Cur->materialized_users();
+  WorkList.reserve(WorkList.size() + std::distance(R.begin(), R.end()));
   append_range(WorkList, Cur->materialized_users());
+}
   }
 }
 
diff --git a/llvm/lib/Transforms/IPO/ArgumentPromotion.cpp 
b/llvm/lib/Transforms/IPO/ArgumentPromotion.cpp
index 0ec5202b8cfe7..a3ef9c4836f31 100644
--- a/llvm/lib/Transforms/IPO/ArgumentPromotion.cpp
+++ b/llvm/lib/Transforms/IPO/ArgumentPromotion.cpp
@@ -388,6 +388,8 @@ doPromotion(Function *F, FunctionAnalysisManager &FAM,
   Value *V = Worklist.

[clang] [llvm] [clang][AVR] Improve compatibility of inline assembly with avr-gcc (PR #136534)

2025-04-21 Thread Ben Shi via cfe-commits

benshi001 wrote:

> > > gcc doesn't seem to allow it? https://godbolt.org/z/4zh8TTPac
> > 
> > 
> > avr-gcc allow value 64 for constraint 'I' in very special case, such as 
> > #51513.
> 
> I guess the test needs to be updated to be representative?
> 
> > And my solution is loosen that check in the frontend, but let the AVR 
> > backend to deny the illegal constraint value 64.
> 
> This deserves a comment in code so that other people don't get confused about 
> this and don't try to change it back to 63.

Thanks.

1. Comment lines are supplemented.
2. A reject test in the backend is added.

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


[clang] [CIR] Upstream initial support for fixed size VectorType (PR #136488)

2025-04-21 Thread Henrich Lauko via cfe-commits


@@ -307,6 +307,26 @@ def CIR_ArrayType : CIR_Type<"Array", "array",
   }];
 }
 
+//===--===//
+// VectorType (fixed size)
+//===--===//
+
+def CIR_VectorType : CIR_Type<"Vector", "vector",
+[DeclareTypeInterfaceMethods]> {
+
+  let summary = "CIR vector type";
+  let description = [{
+`cir.vector' represents fixed-size vector types.  The parameters are the
+element type and the number of elements.
+  }];
+
+  let parameters = (ins "mlir::Type":$eltType, "uint64_t":$size);

xlauko wrote:

CIR uses mix of `eltType`, `elementTy`. Can we standardize one? tbf, I would 
prefer third option `elementType` to mirror similar options in other dialects 
(llvm, builtin, tosa)

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


[clang] [CIR] Upstream initial support for fixed size VectorType (PR #136488)

2025-04-21 Thread Henrich Lauko via cfe-commits


@@ -307,6 +307,26 @@ def CIR_ArrayType : CIR_Type<"Array", "array",
   }];
 }
 
+//===--===//
+// VectorType (fixed size)
+//===--===//
+
+def CIR_VectorType : CIR_Type<"Vector", "vector",
+[DeclareTypeInterfaceMethods]> {
+
+  let summary = "CIR vector type";
+  let description = [{
+`cir.vector' represents fixed-size vector types.  The parameters are the
+element type and the number of elements.

xlauko wrote:

```suggestion
`!cir.vector' represents fixed-size vector types, parameterized 
by the element type and the number of elements.

Example:
```mlir
!cir.vector
!cir.vector
```
```

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


[clang] [CIR] Upstream initial support for fixed size VectorType (PR #136488)

2025-04-21 Thread Henrich Lauko via cfe-commits


@@ -307,6 +307,26 @@ def CIR_ArrayType : CIR_Type<"Array", "array",
   }];
 }
 
+//===--===//
+// VectorType (fixed size)
+//===--===//
+
+def CIR_VectorType : CIR_Type<"Vector", "vector",
+[DeclareTypeInterfaceMethods]> {
+
+  let summary = "CIR vector type";
+  let description = [{
+`cir.vector' represents fixed-size vector types.  The parameters are the
+element type and the number of elements.
+  }];
+
+  let parameters = (ins "mlir::Type":$eltType, "uint64_t":$size);
+
+  let assemblyFormat = [{
+`<` $eltType `x` $size `>`
+  }];
+}

xlauko wrote:

This should probably provide `let genVerifyDecl = 1`, to check that 
`elementType` is supported element type and that size is nonzero? See similar 
implementation of `LLVMFixedVectorType::verify`.

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


[clang] [llvm] [clang][AVR] Improve compatibility of inline assembly with avr-gcc (PR #136534)

2025-04-21 Thread Sergei Barannikov via cfe-commits

https://github.com/s-barannikov approved this pull request.

Thanks, LGTM

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


[clang] [CIR] Upstream initial support for fixed size VectorType (PR #136488)

2025-04-21 Thread Henrich Lauko via cfe-commits


@@ -307,6 +307,26 @@ def CIR_ArrayType : CIR_Type<"Array", "array",
   }];
 }
 
+//===--===//
+// VectorType (fixed size)
+//===--===//
+
+def CIR_VectorType : CIR_Type<"Vector", "vector",
+[DeclareTypeInterfaceMethods]> {
+
+  let summary = "CIR vector type";
+  let description = [{
+`cir.vector' represents fixed-size vector types.  The parameters are the
+element type and the number of elements.
+  }];
+
+  let parameters = (ins "mlir::Type":$eltType, "uint64_t":$size);
+
+  let assemblyFormat = [{
+`<` $eltType `x` $size `>`

xlauko wrote:

nit: also to be more consistent with the rest of mlir, shaped types usually use 
format in reverse order `shape x size` (see llvm vector types and builtin 
tensors)


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


[clang] [CIR] Upstream initial support for fixed size VectorType (PR #136488)

2025-04-21 Thread Henrich Lauko via cfe-commits

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


[clang] [CIR] Upstream StackSave and StackRestoreOp (PR #136426)

2025-04-21 Thread Henrich Lauko via cfe-commits


@@ -1419,6 +1419,48 @@ def CallOp : CIR_CallOpBase<"call", [NoRegionArguments]> 
{
 }]>];
 }
 
+//===--===//
+// StackSave & StackRestoreOp
+//===--===//
+
+def StackSaveOp : CIR_Op<"stack_save"> {

xlauko wrote:

nit: Also any reason not to mirror `llvm` names, i.e. to have `cir.stacksave` 
and `cir.stackrestore`?

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


[clang] [CIR] Upstream StackSave and StackRestoreOp (PR #136426)

2025-04-21 Thread Henrich Lauko via cfe-commits


@@ -1512,6 +1514,22 @@ mlir::LogicalResult 
CIRToLLVMTrapOpLowering::matchAndRewrite(
   return mlir::success();
 }
 
+mlir::LogicalResult CIRToLLVMStackSaveOpLowering::matchAndRewrite(
+cir::StackSaveOp op, OpAdaptor adaptor,
+mlir::ConversionPatternRewriter &rewriter) const {
+  const mlir::Type ptrTy = getTypeConverter()->convertType(op.getType());
+  rewriter.replaceOpWithNewOp(op, ptrTy);
+  return mlir::success();
+}
+
+mlir::LogicalResult CIRToLLVMStackRestoreOpLowering::matchAndRewrite(
+cir::StackRestoreOp op, OpAdaptor adaptor,
+mlir::ConversionPatternRewriter &rewriter) const {
+  rewriter.replaceOpWithNewOp(
+  op, adaptor.getOperands().front());

xlauko wrote:

```suggestion
  op, adaptor.getPtr());
```

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


[clang] [CIR] Upstream StackSave and StackRestoreOp (PR #136426)

2025-04-21 Thread Henrich Lauko via cfe-commits


@@ -1419,6 +1419,48 @@ def CallOp : CIR_CallOpBase<"call", [NoRegionArguments]> 
{
 }]>];
 }
 
+//===--===//
+// StackSave & StackRestoreOp
+//===--===//
+
+def StackSaveOp : CIR_Op<"stack_save"> {

xlauko wrote:

nit: These should probably mention that operations correspond and mirror 
semantics of  `llvm.stacksave` and `llvm.stackrestore` intrinsics.

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


[clang] [CIR] Upstream StackSave and StackRestoreOp (PR #136426)

2025-04-21 Thread Henrich Lauko via cfe-commits


@@ -1419,6 +1419,48 @@ def CallOp : CIR_CallOpBase<"call", [NoRegionArguments]> 
{
 }]>];
 }
 
+//===--===//
+// StackSave & StackRestoreOp
+//===--===//
+
+def StackSaveOp : CIR_Op<"stack_save"> {
+  let summary = "remembers the current state of the function stack";
+  let description = [{
+Remembers the current state of the function stack. Returns a pointer
+that later can be passed into cir.stack_restore.
+Useful for implementing language features like variable length arrays.
+
+```mlir
+%0 = cir.stack_save : 
+```
+  }];
+
+  let results = (outs CIR_PointerType:$result);
+  let assemblyFormat = "attr-dict `:` qualified(type($result))";
+}
+
+def StackRestoreOp : CIR_Op<"stack_restore"> {
+  let summary = "restores the state of the function stack";
+  let description = [{
+Restore the state of the function stack to the state it was
+in when the corresponding cir.stack_save executed.
+Useful for implementing language features like variable length arrays.
+
+```mlir
+%0 = cir.alloca !cir.ptr, !cir.ptr>, ["saved_stack"] 
{alignment = 8 : i64}
+%1 = cir.stack_save : 
+cir.store %1, %0 : !cir.ptr, !cir.ptr>
+%2 = cir.load %0 : !cir.ptr>, !cir.ptr
+cir.stack_restore %2 : !cir.ptr
+```
+  }];
+
+  let arguments = (ins CIR_PointerType:$ptr);
+  let assemblyFormat = "$ptr attr-dict `:` qualified(type($ptr))";
+
+  let llvmOp = "StackRestoreOp";

xlauko wrote:

Why is this here, since it is not used? Also it is only in one of these 
operations.

If used, I would expect not to have explicit `CIRToLLVMStackRestoreOpLowering` 
and `CIRToLLVMStackSaveOpLowering` patterns, but use the generated one.


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


[clang] [CIR] Upstream StackSave and StackRestoreOp (PR #136426)

2025-04-21 Thread Henrich Lauko via cfe-commits


@@ -242,6 +242,26 @@ class CIRToLLVMPtrStrideOpLowering
   matchAndRewrite(cir::PtrStrideOp op, OpAdaptor,
   mlir::ConversionPatternRewriter &) const override;
 };
+
+class CIRToLLVMStackSaveOpLowering
+: public mlir::OpConversionPattern {
+public:
+  using mlir::OpConversionPattern::OpConversionPattern;

xlauko wrote:

```suggestion
  using mlir::OpConversionPattern::OpConversionPattern;

```

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


[clang] [Clang] Make the result type of sizeof/pointer subtraction/size_t lit… (PR #136542)

2025-04-21 Thread via cfe-commits

https://github.com/YexuanXiao updated 
https://github.com/llvm/llvm-project/pull/136542

>From b9cc91971469dcf19bb926f6f53ae5a57d1109c3 Mon Sep 17 00:00:00 2001
From: YexuanXiao 
Date: Mon, 21 Apr 2025 14:28:33 +0800
Subject: [PATCH 1/3] [Clang] Make the result type of sizeof/pointer
 subtraction/size_t literals be typedefs instead of built-in types Includeing
 the results of `sizeof`, `sizeof...`, `__datasizeof`, `__alignof`,
 `_Alignof`, `alignof`, `_Countof`, `size_t` literals, and signed `size_t`
 literals, as well as the results of pointer-pointer subtraction. It does not
 affect any program output except for debugging information. The goal is to
 enable clang and downstream tools such as clangd and clang-tidy to provide
 more portable hints and diagnostics.

---
 clang/include/clang/AST/ASTContext.h   |  4 +++
 clang/lib/AST/ASTContext.cpp   | 29 ++
 clang/lib/AST/ComparisonCategories.cpp | 30 ---
 clang/lib/AST/ExprCXX.cpp  |  6 +++--
 clang/lib/Sema/SemaExpr.cpp| 34 --
 5 files changed, 68 insertions(+), 35 deletions(-)

diff --git a/clang/include/clang/AST/ASTContext.h 
b/clang/include/clang/AST/ASTContext.h
index 3c78833a3f069..0c133d45d3f5e 100644
--- a/clang/include/clang/AST/ASTContext.h
+++ b/clang/include/clang/AST/ASTContext.h
@@ -2442,6 +2442,10 @@ class ASTContext : public RefCountedBase {
   QualType GetBuiltinType(unsigned ID, GetBuiltinTypeError &Error,
   unsigned *IntegerConstantArgs = nullptr) const;
 
+  QualType getCGlobalCXXStdNSTypedef(const NamespaceDecl *StdNS,
+ StringRef DefName,
+ QualType FallBack = {}) const;
+
   /// Types and expressions required to build C++2a three-way comparisons
   /// using operator<=>, including the values return by builtin <=> operators.
   ComparisonCategories CompCategories;
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index 2836d68b05ff6..aa8ce0078d4d3 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -12556,6 +12556,35 @@ QualType ASTContext::GetBuiltinType(unsigned Id,
   return getFunctionType(ResType, ArgTypes, EPI);
 }
 
+QualType ASTContext::getCGlobalCXXStdNSTypedef(const NamespaceDecl *StdNS,
+   StringRef DefName,
+   QualType FallBack) const {
+  DeclContextLookupResult Lookup;
+  if (getLangOpts().C99) {
+Lookup = getTranslationUnitDecl()->lookup(&Idents.get(DefName));
+  } else if (getLangOpts().CPlusPlus) {
+if (StdNS == nullptr) {
+  auto LookupStdNS = getTranslationUnitDecl()->lookup(&Idents.get("std"));
+  if (!LookupStdNS.empty()) {
+StdNS = dyn_cast(LookupStdNS.front());
+  }
+}
+if (StdNS) {
+  Lookup = StdNS->lookup(&Idents.get(DefName));
+} else {
+  Lookup = getTranslationUnitDecl()->lookup(&Idents.get(DefName));
+}
+  }
+  if (!Lookup.empty()) {
+if (auto *TD = dyn_cast(Lookup.front())) {
+  if (auto Result = getTypeDeclType(TD); !Result.isNull()) {
+return Result;
+  }
+}
+  }
+  return FallBack;
+}
+
 static GVALinkage basicGVALinkageForFunction(const ASTContext &Context,
  const FunctionDecl *FD) {
   if (!FD->isExternallyVisible())
diff --git a/clang/lib/AST/ComparisonCategories.cpp 
b/clang/lib/AST/ComparisonCategories.cpp
index 28244104d6636..46dcd6ac4261d 100644
--- a/clang/lib/AST/ComparisonCategories.cpp
+++ b/clang/lib/AST/ComparisonCategories.cpp
@@ -87,37 +87,17 @@ ComparisonCategoryInfo::ValueInfo 
*ComparisonCategoryInfo::lookupValueInfo(
   return &Objects.back();
 }
 
-static const NamespaceDecl *lookupStdNamespace(const ASTContext &Ctx,
-   NamespaceDecl *&StdNS) {
-  if (!StdNS) {
-DeclContextLookupResult Lookup =
-Ctx.getTranslationUnitDecl()->lookup(&Ctx.Idents.get("std"));
-if (!Lookup.empty())
-  StdNS = dyn_cast(Lookup.front());
-  }
-  return StdNS;
-}
-
-static const CXXRecordDecl *lookupCXXRecordDecl(const ASTContext &Ctx,
-const NamespaceDecl *StdNS,
-ComparisonCategoryType Kind) {
-  StringRef Name = ComparisonCategories::getCategoryString(Kind);
-  DeclContextLookupResult Lookup = StdNS->lookup(&Ctx.Idents.get(Name));
-  if (!Lookup.empty())
-if (const CXXRecordDecl *RD = dyn_cast(Lookup.front()))
-  return RD;
-  return nullptr;
-}
-
 const ComparisonCategoryInfo *
 ComparisonCategories::lookupInfo(ComparisonCategoryType Kind) const {
   auto It = Data.find(static_cast(Kind));
   if (It != Data.end())
 return &It->second;
-
-  if (const NamespaceDecl *NS = lookupStdNamespace(Ctx, StdNS))
-if (const CXXRecordDecl *RD = lookupCXXRecordDecl(Ctx, NS, Kind))
+  if (auto QT 

[clang] [llvm] DO NOT MERGE: Identify places that need reserve. (PR #136543)

2025-04-21 Thread Kazu Hirata via cfe-commits

kazutakahirata wrote:

@kuhar I understand that you are working on improving the performance of 
`llvm::append_range`.

I did some experiment with this PR:

- I taught `llvm::append_range` to:
  - automatically call `Container::reserve` if the given range is a pointer or 
`std::random_access_iterator_tag`, and
  - crash on capacity changes after calling `Container::insert`.
- I built a debug version of compiler (for clean stack traces).
- I used the debug version of the compiler to build an optimized version of 
clang while manually adding `reserve` to fix crashes.

One noteworthy point is that I only needed to add a dozen or so calls to 
`reserve`.  Some ranges are of sets like `SmallPtrSet`, so `size()` is 
immediately available.  We might even upstream those calls.  Others require 
linear walk, so we shouldn't upstream those.

I'm wondering if porting those `reserve()` calls on `SmallPtrSet` and such to 
your patch (https://github.com/llvm/llvm-project/pull/136365) might improve the 
performance.  Also, I am wondering if your patch needs to deal with pointer 
ranges like `char *`, which I assume doesn't  have an iterator category.  Note 
that `ArrayRef` uses pointers as iterator types.

We could detect the presence of `size()` on ranges and use that as a hint when 
given ranges are neither pointer nor `std::random_access_iterator_tag`.  
Alternatively, we could manually add calls to `reserve()` just before 
`append_range` where ranges come with `size()`, which we could detect with some 
temporary template meta-programming hacks to `append_range`.


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


[clang] [clang-format] Correctly annotate kw_operator in using decls (PR #136545)

2025-04-21 Thread Owen Pan via cfe-commits

https://github.com/owenca created 
https://github.com/llvm/llvm-project/pull/136545

Fix #136541

>From a0c0686da2d708f2365c4edcf72c8be5dbc0c4a1 Mon Sep 17 00:00:00 2001
From: Owen Pan 
Date: Mon, 21 Apr 2025 01:26:22 -0700
Subject: [PATCH] [clang-format] Correctly annotate kw_operator in using decls

Fix #136541
---
 clang/lib/Format/TokenAnnotator.cpp   | 6 --
 clang/unittests/Format/TokenAnnotatorTest.cpp | 5 +
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/clang/lib/Format/TokenAnnotator.cpp 
b/clang/lib/Format/TokenAnnotator.cpp
index 144983f675828..4827549cf9cec 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -3977,8 +3977,10 @@ void 
TokenAnnotator::calculateFormattingInformation(AnnotatedLine &Line) const {
   FormatToken *AfterLastAttribute = nullptr;
   FormatToken *ClosingParen = nullptr;
 
-  for (auto *Tok = FirstNonComment ? FirstNonComment->Next : nullptr; Tok;
-   Tok = Tok->Next) {
+  for (auto *Tok = FirstNonComment && FirstNonComment->isNot(tok::kw_using)
+   ? FirstNonComment->Next
+   : nullptr;
+   Tok; Tok = Tok->Next) {
 if (Tok->is(TT_StartOfName))
   SeenName = true;
 if (Tok->Previous->EndsCppAttributeGroup)
diff --git a/clang/unittests/Format/TokenAnnotatorTest.cpp 
b/clang/unittests/Format/TokenAnnotatorTest.cpp
index 043ee2e088ddb..64acc00be125f 100644
--- a/clang/unittests/Format/TokenAnnotatorTest.cpp
+++ b/clang/unittests/Format/TokenAnnotatorTest.cpp
@@ -1078,6 +1078,11 @@ TEST_F(TokenAnnotatorTest, 
UnderstandsOverloadedOperators) {
   ASSERT_EQ(Tokens.size(), 11u) << Tokens;
   EXPECT_TOKEN(Tokens[3], tok::identifier, TT_FunctionDeclarationName);
   EXPECT_TOKEN(Tokens[7], tok::l_paren, TT_OverloadedOperatorLParen);
+
+  Tokens = annotate("using std::operator==;");
+  ASSERT_EQ(Tokens.size(), 7u) << Tokens;
+  // Not TT_FunctionDeclarationName.
+  EXPECT_TOKEN(Tokens[3], tok::kw_operator, TT_Unknown);
 }
 
 TEST_F(TokenAnnotatorTest, OverloadedOperatorInTemplate) {

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


[clang] [clang-format] Correctly annotate kw_operator in using decls (PR #136545)

2025-04-21 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-format

Author: Owen Pan (owenca)


Changes

Fix #136541

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


2 Files Affected:

- (modified) clang/lib/Format/TokenAnnotator.cpp (+4-2) 
- (modified) clang/unittests/Format/TokenAnnotatorTest.cpp (+5) 


``diff
diff --git a/clang/lib/Format/TokenAnnotator.cpp 
b/clang/lib/Format/TokenAnnotator.cpp
index 144983f675828..4827549cf9cec 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -3977,8 +3977,10 @@ void 
TokenAnnotator::calculateFormattingInformation(AnnotatedLine &Line) const {
   FormatToken *AfterLastAttribute = nullptr;
   FormatToken *ClosingParen = nullptr;
 
-  for (auto *Tok = FirstNonComment ? FirstNonComment->Next : nullptr; Tok;
-   Tok = Tok->Next) {
+  for (auto *Tok = FirstNonComment && FirstNonComment->isNot(tok::kw_using)
+   ? FirstNonComment->Next
+   : nullptr;
+   Tok; Tok = Tok->Next) {
 if (Tok->is(TT_StartOfName))
   SeenName = true;
 if (Tok->Previous->EndsCppAttributeGroup)
diff --git a/clang/unittests/Format/TokenAnnotatorTest.cpp 
b/clang/unittests/Format/TokenAnnotatorTest.cpp
index 043ee2e088ddb..64acc00be125f 100644
--- a/clang/unittests/Format/TokenAnnotatorTest.cpp
+++ b/clang/unittests/Format/TokenAnnotatorTest.cpp
@@ -1078,6 +1078,11 @@ TEST_F(TokenAnnotatorTest, 
UnderstandsOverloadedOperators) {
   ASSERT_EQ(Tokens.size(), 11u) << Tokens;
   EXPECT_TOKEN(Tokens[3], tok::identifier, TT_FunctionDeclarationName);
   EXPECT_TOKEN(Tokens[7], tok::l_paren, TT_OverloadedOperatorLParen);
+
+  Tokens = annotate("using std::operator==;");
+  ASSERT_EQ(Tokens.size(), 7u) << Tokens;
+  // Not TT_FunctionDeclarationName.
+  EXPECT_TOKEN(Tokens[3], tok::kw_operator, TT_Unknown);
 }
 
 TEST_F(TokenAnnotatorTest, OverloadedOperatorInTemplate) {

``




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


[clang] [clang-format] Correctly annotate kw_operator in using decls (PR #136545)

2025-04-21 Thread Owen Pan via cfe-commits

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


[clang] [Clang] Make the result type of sizeof/pointer subtraction/size_t lit… (PR #136542)

2025-04-21 Thread A. Jiang via cfe-commits


@@ -4026,10 +4026,20 @@ ExprResult Sema::ActOnNumericConstant(const Token &Tok, 
Scope *UDLScope) {
 // Does it fit in size_t?
 if (ResultVal.isIntN(SizeTSize)) {
   // Does it fit in ssize_t?
-  if (!Literal.isUnsigned && ResultVal[SizeTSize - 1] == 0)
-Ty = Context.getSignedSizeType();
-  else if (AllowUnsigned)
-Ty = Context.getSizeType();
+  if (!Literal.isUnsigned && ResultVal[SizeTSize - 1] == 0) {
+auto SignedSize = Context.getSignedSizeType();
+if (auto PtrDiff = Context.getCGlobalCXXStdNSTypedef(
+getStdNamespace(), "ptrdiff_t");
+Context.hasSameType(PtrDiff, SignedSize))
+  Ty = PtrDiff;
+else if (auto SSize = Context.getCGlobalCXXStdNSTypedef(
+ getStdNamespace(), "ssize_t");
+ Context.hasSameType(SSize, SignedSize))
+  Ty = SSize;
+  } else if (AllowUnsigned) {
+Ty = Context.getCGlobalCXXStdNSTypedef(getStdNamespace(), "size_t",

frederick-vs-ja wrote:

Can we add a test file to verify that `size_t` is shown instead of `unsigned 
long`/`unsigned long long`?

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


[clang-tools-extra] [clang-tools-extra] Use llvm::unique (NFC) (PR #136514)

2025-04-21 Thread Carlos Galvez via cfe-commits

carlosgalvezp wrote:

May I ask what is the reason for this change? What problem does std::unique 
have that llvm::unique solves?

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


[libclc] [libclc] Set OpenCL C version for each target (PR #135733)

2025-04-21 Thread Fraser Cormack via cfe-commits

frasercrmck wrote:

> LGTM. That means we compile for the last OpenCL version, which is 3.0, and 
> enable all OpenCL extensions/features, right? libclc is implemented using 
> functions supported by clang, so it is unlikely a target has libclc build 
> error in generic libclc files that are shared for all targets. When libclc is 
> linked to application module, libclc built-ins implementation of unsupported 
> extensions/features won't be linked in because these built-ins won't exist in 
> the user module. If the application code uses an unsupported extension, 
> frontend would report error already. There could be problem if application 
> modules links in a supported libclc built-in function which calls another 
> libclc built-in that belongs to unsupported special extension/feature, but I 
> think this scenario is unlikely and the supported built-in should be fixed to 
> not using unsupported feature. @frasercrmck What do you think?

Sounds good to me. I hope that by having the internal CLC library we can 
largely avoid the last scenario, as CLC should be less dependent on the OpenCL 
C version. An OpenCL 1.2 module could still call a builtin that makes internal 
use of CLC `ctz`, for example.

Anyway, sorry for complicating the PR with my suggestion. I was being 
unnecessarily conservative.

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


[clang] [sanitizer] Fix empty string in unsupported argument error for -fsanitize-trap (PR #136549)

2025-04-21 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-driver

Author: Sinkevich Artem (ArtSin)


Changes

When using `-fsanitize-trap` with a sanitizer group that doesn't support 
trapping, an empty argument is passed to `err_drv_unsupported_option_argument`. 
Expand groups for the diagnostic.

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


2 Files Affected:

- (modified) clang/lib/Driver/SanitizerArgs.cpp (+2-2) 
- (modified) clang/test/Driver/fsanitize.c (+3) 


``diff
diff --git a/clang/lib/Driver/SanitizerArgs.cpp 
b/clang/lib/Driver/SanitizerArgs.cpp
index f27cb813012f2..05ca2656c6522 100644
--- a/clang/lib/Driver/SanitizerArgs.cpp
+++ b/clang/lib/Driver/SanitizerArgs.cpp
@@ -286,7 +286,7 @@ parseSanitizeArgs(const Driver &D, const llvm::opt::ArgList 
&Args,
   Add & AlwaysOut & ~DiagnosedAlwaysOutViolations) {
 if (DiagnoseErrors) {
   SanitizerSet SetToDiagnose;
-  SetToDiagnose.Mask |= KindsToDiagnose;
+  SetToDiagnose.Mask |= expandSanitizerGroups(KindsToDiagnose);
   D.Diag(diag::err_drv_unsupported_option_argument)
   << Arg->getSpelling() << toString(SetToDiagnose);
   DiagnosedAlwaysOutViolations |= KindsToDiagnose;
@@ -302,7 +302,7 @@ parseSanitizeArgs(const Driver &D, const llvm::opt::ArgList 
&Args,
   Remove & AlwaysIn & ~DiagnosedAlwaysInViolations) {
 if (DiagnoseErrors) {
   SanitizerSet SetToDiagnose;
-  SetToDiagnose.Mask |= KindsToDiagnose;
+  SetToDiagnose.Mask |= expandSanitizerGroups(KindsToDiagnose);
   D.Diag(diag::err_drv_unsupported_option_argument)
   << Arg->getSpelling() << toString(SetToDiagnose);
   DiagnosedAlwaysInViolations |= KindsToDiagnose;
diff --git a/clang/test/Driver/fsanitize.c b/clang/test/Driver/fsanitize.c
index c154e339941f2..434e6fd8c4a15 100644
--- a/clang/test/Driver/fsanitize.c
+++ b/clang/test/Driver/fsanitize.c
@@ -259,6 +259,9 @@
 // RUN: not %clang --target=aarch64-linux -fsanitize=memtag -I +mte %s -### 
2>&1 | FileCheck %s --check-prefix=CHECK-SANMT-NOMT-1
 // CHECK-SANMT-NOMT-1: '-fsanitize=memtag-stack' requires hardware support 
(+memtag)
 
+// RUN: not %clang --target=aarch64-linux-android31 -fsanitize-trap=memtag 
-march=armv8-a+memtag -c %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-SANMT-TRAP
+// CHECK-SANMT-TRAP: error: unsupported argument 
'memtag-stack,memtag-heap,memtag-globals' to option '-fsanitize-trap='
+
 // RUN: %clang --target=x86_64-linux-gnu -fsanitize=address 
-fsanitize-address-use-after-scope %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-USE-AFTER-SCOPE
 // RUN: %clang_cl --target=x86_64-windows -fsanitize=address 
-fsanitize-address-use-after-scope -### -- %s 2>&1 | FileCheck %s 
--check-prefix=CHECK-USE-AFTER-SCOPE
 // CHECK-USE-AFTER-SCOPE: -cc1{{.*}}-fsanitize-address-use-after-scope

``




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


[clang] [sanitizer] Fix empty string in unsupported argument error for -fsanitize-trap (PR #136549)

2025-04-21 Thread Sinkevich Artem via cfe-commits

https://github.com/ArtSin created 
https://github.com/llvm/llvm-project/pull/136549

When using `-fsanitize-trap` with a sanitizer group that doesn't support 
trapping, an empty argument is passed to `err_drv_unsupported_option_argument`. 
Expand groups for the diagnostic.

>From 459d375073093ebec33bcac0e824385daeadcf5f Mon Sep 17 00:00:00 2001
From: Artem Sinkevich 
Date: Mon, 21 Apr 2025 12:48:51 +0400
Subject: [PATCH] [sanitizer] Fix empty string in unsupported argument error
 for -fsanitize-trap

When using `-fsanitize-trap` with a sanitizer group that doesn't support
trapping, an empty argument is passed to `err_drv_unsupported_option_argument`.
Expand groups for the diagnostic.
---
 clang/lib/Driver/SanitizerArgs.cpp | 4 ++--
 clang/test/Driver/fsanitize.c  | 3 +++
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/clang/lib/Driver/SanitizerArgs.cpp 
b/clang/lib/Driver/SanitizerArgs.cpp
index f27cb813012f2..05ca2656c6522 100644
--- a/clang/lib/Driver/SanitizerArgs.cpp
+++ b/clang/lib/Driver/SanitizerArgs.cpp
@@ -286,7 +286,7 @@ parseSanitizeArgs(const Driver &D, const llvm::opt::ArgList 
&Args,
   Add & AlwaysOut & ~DiagnosedAlwaysOutViolations) {
 if (DiagnoseErrors) {
   SanitizerSet SetToDiagnose;
-  SetToDiagnose.Mask |= KindsToDiagnose;
+  SetToDiagnose.Mask |= expandSanitizerGroups(KindsToDiagnose);
   D.Diag(diag::err_drv_unsupported_option_argument)
   << Arg->getSpelling() << toString(SetToDiagnose);
   DiagnosedAlwaysOutViolations |= KindsToDiagnose;
@@ -302,7 +302,7 @@ parseSanitizeArgs(const Driver &D, const llvm::opt::ArgList 
&Args,
   Remove & AlwaysIn & ~DiagnosedAlwaysInViolations) {
 if (DiagnoseErrors) {
   SanitizerSet SetToDiagnose;
-  SetToDiagnose.Mask |= KindsToDiagnose;
+  SetToDiagnose.Mask |= expandSanitizerGroups(KindsToDiagnose);
   D.Diag(diag::err_drv_unsupported_option_argument)
   << Arg->getSpelling() << toString(SetToDiagnose);
   DiagnosedAlwaysInViolations |= KindsToDiagnose;
diff --git a/clang/test/Driver/fsanitize.c b/clang/test/Driver/fsanitize.c
index c154e339941f2..434e6fd8c4a15 100644
--- a/clang/test/Driver/fsanitize.c
+++ b/clang/test/Driver/fsanitize.c
@@ -259,6 +259,9 @@
 // RUN: not %clang --target=aarch64-linux -fsanitize=memtag -I +mte %s -### 
2>&1 | FileCheck %s --check-prefix=CHECK-SANMT-NOMT-1
 // CHECK-SANMT-NOMT-1: '-fsanitize=memtag-stack' requires hardware support 
(+memtag)
 
+// RUN: not %clang --target=aarch64-linux-android31 -fsanitize-trap=memtag 
-march=armv8-a+memtag -c %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-SANMT-TRAP
+// CHECK-SANMT-TRAP: error: unsupported argument 
'memtag-stack,memtag-heap,memtag-globals' to option '-fsanitize-trap='
+
 // RUN: %clang --target=x86_64-linux-gnu -fsanitize=address 
-fsanitize-address-use-after-scope %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-USE-AFTER-SCOPE
 // RUN: %clang_cl --target=x86_64-windows -fsanitize=address 
-fsanitize-address-use-after-scope -### -- %s 2>&1 | FileCheck %s 
--check-prefix=CHECK-USE-AFTER-SCOPE
 // CHECK-USE-AFTER-SCOPE: -cc1{{.*}}-fsanitize-address-use-after-scope

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


[libclc] [libclc] only check filename part of the source for avoiding duplication (PR #135710)

2025-04-21 Thread Fraser Cormack via cfe-commits

frasercrmck wrote:

I don't mind this.

Given the current naming scheme, files are named after specific builtins so 
you're unlikely to want to include two `cos.cl`, for instance. I don't think 
the directory name is or should be significant in deciding what to override. I 
suppose you could currently have `fp32/cos.cl` and `fp16/cos.cl` whereas this 
change would prevent that. You could just have `cos_fp32.cl` and `cos_fp16.cl`, 
of course.

I would like to further investigate weak linkage as another means of overriding 
specific builtins down to a finer granularity. That approach might warrant 
another method of file discovery.

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


[libclc] [libclc] only check filename part of the source for avoiding duplication (PR #135710)

2025-04-21 Thread Fraser Cormack via cfe-commits

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


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


[clang] cuda clang: Move nvptx-surface.cu test to CodeGenCUDA (PR #134758)

2025-04-21 Thread Austin Schuh via cfe-commits

https://github.com/AustinSchuh updated 
https://github.com/llvm/llvm-project/pull/134758

>From 1e6367407a4b23b2a85f088ba4b66a0c0afc8faa Mon Sep 17 00:00:00 2001
From: Austin Schuh 
Date: Mon, 7 Apr 2025 17:18:38 -0700
Subject: [PATCH 1/2] cuda clang: Move nvptx-surface.cu test to CodeGenCUDA

Signed-off-by: Austin Schuh 
---
 clang/test/CodeGen/Inputs/cuda.h  | 194 --
 .../{CodeGen => CodeGenCUDA}/nvptx-surface.cu | 164 +++
 2 files changed, 164 insertions(+), 194 deletions(-)
 delete mode 100644 clang/test/CodeGen/Inputs/cuda.h
 rename clang/test/{CodeGen => CodeGenCUDA}/nvptx-surface.cu (98%)

diff --git a/clang/test/CodeGen/Inputs/cuda.h b/clang/test/CodeGen/Inputs/cuda.h
deleted file mode 100644
index 58202442e1f8c..0
--- a/clang/test/CodeGen/Inputs/cuda.h
+++ /dev/null
@@ -1,194 +0,0 @@
-/* Minimal declarations for CUDA support.  Testing purposes only.
- * This should stay in sync with clang/test/Headers/Inputs/include/cuda.h
- */
-#pragma once
-
-// Make this file work with nvcc, for testing compatibility.
-
-#ifndef __NVCC__
-#define __constant__ __attribute__((constant))
-#define __device__ __attribute__((device))
-#define __global__ __attribute__((global))
-#define __host__ __attribute__((host))
-#define __shared__ __attribute__((shared))
-#define __managed__ __attribute__((managed))
-#define __launch_bounds__(...) __attribute__((launch_bounds(__VA_ARGS__)))
-
-struct dim3 {
-  unsigned x, y, z;
-  __host__ __device__ dim3(unsigned x, unsigned y = 1, unsigned z = 1) : x(x), 
y(y), z(z) {}
-};
-
-// Host- and device-side placement new overloads.
-void *operator new(__SIZE_TYPE__, void *p) { return p; }
-void *operator new[](__SIZE_TYPE__, void *p) { return p; }
-__device__ void *operator new(__SIZE_TYPE__, void *p) { return p; }
-__device__ void *operator new[](__SIZE_TYPE__, void *p) { return p; }
-
-#define CUDA_VERSION 10100
-
-struct char1 {
-  char x;
-  __host__ __device__ char1(char x = 0) : x(x) {}
-};
-struct char2 {
-  char x, y;
-  __host__ __device__ char2(char x = 0, char y = 0) : x(x), y(y) {}
-};
-struct char4 {
-  char x, y, z, w;
-  __host__ __device__ char4(char x = 0, char y = 0, char z = 0, char w = 0) : 
x(x), y(y), z(z), w(w) {}
-};
-
-struct uchar1 {
-  unsigned char x;
-  __host__ __device__ uchar1(unsigned char x = 0) : x(x) {}
-};
-struct uchar2 {
-  unsigned char x, y;
-  __host__ __device__ uchar2(unsigned char x = 0, unsigned char y = 0) : x(x), 
y(y) {}
-};
-struct uchar4 {
-  unsigned char x, y, z, w;
-  __host__ __device__ uchar4(unsigned char x = 0, unsigned char y = 0, 
unsigned char z = 0, unsigned char w = 0) : x(x), y(y), z(z), w(w) {}
-};
-
-struct short1 {
-  short x;
-  __host__ __device__ short1(short x = 0) : x(x) {}
-};
-struct short2 {
-  short x, y;
-  __host__ __device__ short2(short x = 0, short y = 0) : x(x), y(y) {}
-};
-struct short4 {
-  short x, y, z, w;
-  __host__ __device__ short4(short x = 0, short y = 0, short z = 0, short w = 
0) : x(x), y(y), z(z), w(w) {}
-};
-
-struct ushort1 {
-  unsigned short x;
-  __host__ __device__ ushort1(unsigned short x = 0) : x(x) {}
-};
-struct ushort2 {
-  unsigned short x, y;
-  __host__ __device__ ushort2(unsigned short x = 0, unsigned short y = 0) : 
x(x), y(y) {}
-};
-struct ushort4 {
-  unsigned short x, y, z, w;
-  __host__ __device__ ushort4(unsigned short x = 0, unsigned short y = 0, 
unsigned short z = 0, unsigned short w = 0) : x(x), y(y), z(z), w(w) {}
-};
-
-struct int1 {
-  int x;
-  __host__ __device__ int1(int x = 0) : x(x) {}
-};
-struct int2 {
-  int x, y;
-  __host__ __device__ int2(int x = 0, int y = 0) : x(x), y(y) {}
-};
-struct int4 {
-  int x, y, z, w;
-  __host__ __device__ int4(int x = 0, int y = 0, int z = 0, int w = 0) : x(x), 
y(y), z(z), w(w) {}
-};
-
-struct uint1 {
-  unsigned x;
-  __host__ __device__ uint1(unsigned x = 0) : x(x) {}
-};
-struct uint2 {
-  unsigned x, y;
-  __host__ __device__ uint2(unsigned x = 0, unsigned y = 0) : x(x), y(y) {}
-};
-struct uint3 {
-  unsigned x, y, z;
-  __host__ __device__ uint3(unsigned x = 0, unsigned y = 0, unsigned z = 0) : 
x(x), y(y), z(z) {}
-};
-struct uint4 {
-  unsigned x, y, z, w;
-  __host__ __device__ uint4(unsigned x = 0, unsigned y = 0, unsigned z = 0, 
unsigned w = 0) : x(x), y(y), z(z), w(w) {}
-};
-
-struct longlong1 {
-  long long x;
-  __host__ __device__ longlong1(long long x = 0) : x(x) {}
-};
-struct longlong2 {
-  long long x, y;
-  __host__ __device__ longlong2(long long x = 0, long long y = 0) : x(x), y(y) 
{}
-};
-struct longlong4 {
-  long long x, y, z, w;
-  __host__ __device__ longlong4(long long x = 0, long long y = 0, long long z 
= 0, long long w = 0) : x(x), y(y), z(z), w(w) {}
-};
-
-struct ulonglong1 {
-  unsigned long long x;
-  __host__ __device__ ulonglong1(unsigned long long x = 0) : x(x) {}
-};
-struct ulonglong2 {
-  unsigned long long x, y;
-  __host__ __device__ ulonglong2(unsigned long long x = 0, unsigned long long 
y = 0) : x(x), y(y) {}
-};
-s

[clang] [llvm] [RISCV] Add smcntrpmf extension (PR #136556)

2025-04-21 Thread Jim Lin via cfe-commits


@@ -1453,6 +1454,14 @@
 // RUN:   -o - | FileCheck --check-prefix=CHECK-SMCSRIND-EXT %s
 // CHECK-SMCSRIND-EXT: __riscv_smcsrind  100{{$}}
 
+// RUN: %clang --target=riscv32 \

tclin914 wrote:

Put the test for  `smcntrpmf` above for `smcsrind`

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


[clang] [Clang] Add support for GCC bound member functions extension (PR #135649)

2025-04-21 Thread Yingwei Zheng via cfe-commits

dtcxzyw wrote:

> > We used this extension to improve virtual function calling performance, 
> > there are simple and small virtual functions which are frequently called 
> > and can not be eliminated and it is in a delegation thus compiler can not 
> > optimize.
> > [toplingdb](https://github.com/topling/toplingdb) and 
> > [topling-zip](https://github.com/topling/topling-zip) used pmf to pre-bind 
> > the functions in several places, like this:
> 
> Can `declcall` (https://wg21.link/p2825) be used for this? It is on track for 
> C++26.

IIRC this feature is orthogonal to GCC bound member functions. `declcall` with 
a virtual method just returns a pmf, and we still need to perform vtable lookup 
at the callsite: https://compiler-explorer.com/z/YrT3nPTEz


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


[clang] [CUDA][HIP] capture possible ODR-used var (PR #136645)

2025-04-21 Thread Yaxun Liu via cfe-commits


@@ -14706,6 +14706,8 @@ ExprResult Sema::BuildOverloadedCallExpr(Scope *S, Expr 
*Fn,
   // the UnresolvedLookupExpr was type-dependent.
   if (OverloadResult == OR_Success) {
 const FunctionDecl *FDecl = Best->Function;
+if (LangOpts.CUDA)

yxsamliu wrote:

LangOpts.CUDA is also true for HIP. same as below

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


[clang] [llvm] [RISCV] Add smcntrpmf extension (PR #136556)

2025-04-21 Thread Craig Topper via cfe-commits

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

LGTM

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


[clang] cuda clang: Move nvptx-surface.cu test to CodeGenCUDA (PR #134758)

2025-04-21 Thread Austin Schuh via cfe-commits

AustinSchuh wrote:

@Artem-B , 2 things.

1) Looks like I was too slow and had to fix merge conflicts.  Please take 
another look.
2) Can you submit?  I don't have submit permission yet, and realistically, 
unless you've got more requests for improvements to surface support, odds are 
low I'll be making enough changes going forward to justify it.

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


[libclc] [libclc] Set OpenCL C version for each target (PR #135733)

2025-04-21 Thread Wenju He via cfe-commits

wenju-he wrote:

> > LGTM. That means we compile for the last OpenCL version, which is 3.0, and 
> > enable all OpenCL extensions/features, right?
> 
> Yes. Otherwise you have to still write the code to work with the lowest 
> common denominator.

done in commit 
https://github.com/llvm/llvm-project/pull/135733/commits/b3653cdcfde00ece9ac929d6c0555c237e87ff86

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


[libclc] [libclc] Set OpenCL C version for each target (PR #135733)

2025-04-21 Thread Wenju He via cfe-commits

wenju-he wrote:

> An OpenCL 1.2 module could still call a builtin that makes internal use of 
> CLC `ctz`, for example.

Yes, you're right.



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


[libclc] [libclc] Build for OpenCL 3.0 and enable all extensions and features (PR #135733)

2025-04-21 Thread Wenju He via cfe-commits

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


[libclc] [libclc] Build for OpenCL 3.0 and enable all extensions and features (PR #135733)

2025-04-21 Thread Wenju He via cfe-commits

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


[clang] [clang] Define convergence in C++ languages such as HIP, CUDA, OpenCL (PR #136280)

2025-04-21 Thread Sameer Sahasrabuddhe via cfe-commits

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


[libclc] [libclc] Build for OpenCL 3.0 and enable all extensions and features (PR #135733)

2025-04-21 Thread Matt Arsenault via cfe-commits

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


[libclc] [libclc] Build for OpenCL 3.0 and enable all extensions and features (PR #135733)

2025-04-21 Thread Matt Arsenault via cfe-commits


@@ -429,7 +411,9 @@ foreach( t ${LIBCLC_TARGETS_TO_BUILD} )
 set( LIBCLC_ARCH_OBJFILE_DIR "${LIBCLC_OBJFILE_DIR}/${arch_suffix}" )
 file( MAKE_DIRECTORY ${LIBCLC_ARCH_OBJFILE_DIR} )
 
-list( APPEND build_flags -cl-std=${opencl_lang_std} )
+# Build for OpenCL 3.0 and enable all extensions and features independently
+# of the target or device.
+list( APPEND build_flags -cl-std=CL3.0 -Xclang -cl-ext=+all )

arsenm wrote:

The extensions should be enabled locally where needed

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


[clang] [CIR] Make ZeroAttr use AttrBuilderWithInferredContext (PR #136604)

2025-04-21 Thread Henrich Lauko via cfe-commits

xlauko wrote:

### Merge activity

* **Apr 22, 2:26 AM EDT**: A user started a stack merge that includes this pull 
request via 
[Graphite](https://app.graphite.dev/github/pr/llvm/llvm-project/136604).


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


[clang] [CIR] Make ZeroAttr use AttrBuilderWithInferredContext (PR #136604)

2025-04-21 Thread Henrich Lauko via cfe-commits

https://github.com/xlauko updated 
https://github.com/llvm/llvm-project/pull/136604

>From 6f59c473e8ecef0aeaa4d9eb02d41d2e97696615 Mon Sep 17 00:00:00 2001
From: xlauko 
Date: Mon, 21 Apr 2025 21:51:06 +0200
Subject: [PATCH] [CIR] Make ZeroAttr use AttrBuilderWithInferredContext

---
 clang/include/clang/CIR/Dialect/Builder/CIRBaseBuilder.h | 8 ++--
 clang/include/clang/CIR/Dialect/IR/CIRAttrs.td   | 7 +++
 clang/lib/CIR/CodeGen/CIRGenExprConstant.cpp | 2 +-
 3 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/clang/include/clang/CIR/Dialect/Builder/CIRBaseBuilder.h 
b/clang/include/clang/CIR/Dialect/Builder/CIRBaseBuilder.h
index ee8af62ede0da..b303aa07838ee 100644
--- a/clang/include/clang/CIR/Dialect/Builder/CIRBaseBuilder.h
+++ b/clang/include/clang/CIR/Dialect/Builder/CIRBaseBuilder.h
@@ -83,21 +83,17 @@ class CIRBaseBuilderTy : public mlir::OpBuilder {
 return getConstPtrAttr(t, 0);
   }
 
-  mlir::TypedAttr getZeroAttr(mlir::Type t) {
-return cir::ZeroAttr::get(getContext(), t);
-  }
-
   mlir::TypedAttr getZeroInitAttr(mlir::Type ty) {
 if (mlir::isa(ty))
   return cir::IntAttr::get(ty, 0);
 if (cir::isAnyFloatingPointType(ty))
   return cir::FPAttr::getZero(ty);
 if (auto arrTy = mlir::dyn_cast(ty))
-  return getZeroAttr(arrTy);
+  return cir::ZeroAttr::get(arrTy);
 if (auto ptrTy = mlir::dyn_cast(ty))
   return getConstNullPtrAttr(ptrTy);
 if (auto recordTy = mlir::dyn_cast(ty))
-  return getZeroAttr(recordTy);
+  return cir::ZeroAttr::get(recordTy);
 if (mlir::isa(ty)) {
   return getFalseAttr();
 }
diff --git a/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td 
b/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td
index 25ceded7e8a5b..214db1b1caeeb 100644
--- a/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td
+++ b/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td
@@ -71,6 +71,13 @@ def ZeroAttr : CIR_Attr<"Zero", "zero", 
[TypedAttrInterface]> {
   }];
 
   let parameters = (ins AttributeSelfTypeParameter<"">:$type);
+
+  let builders = [
+AttrBuilderWithInferredContext<(ins "mlir::Type":$type), [{
+  return $_get(type.getContext(), type);
+}]>
+  ];
+
   let assemblyFormat = [{}];
 }
 
diff --git a/clang/lib/CIR/CodeGen/CIRGenExprConstant.cpp 
b/clang/lib/CIR/CodeGen/CIRGenExprConstant.cpp
index 0caa8961ed0a6..b9a74e90a5960 100644
--- a/clang/lib/CIR/CodeGen/CIRGenExprConstant.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenExprConstant.cpp
@@ -183,7 +183,7 @@ emitArrayConstant(CIRGenModule &cgm, mlir::Type desiredType,
   }
 
   if (nonzeroLength == 0)
-return cir::ZeroAttr::get(builder.getContext(), desiredType);
+return cir::ZeroAttr::get(desiredType);
 
   const unsigned trailingZeroes = arrayBound - nonzeroLength;
 

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


[clang] [Clang] Improve error recovery for invalid calls (PR #136295)

2025-04-21 Thread Younan Zhang via cfe-commits

https://github.com/zyn0217 updated 
https://github.com/llvm/llvm-project/pull/136295

>From 8efadc35d64f2724d5610a7ae66fa70a7c8e3d46 Mon Sep 17 00:00:00 2001
From: Younan Zhang 
Date: Fri, 18 Apr 2025 19:20:49 +0800
Subject: [PATCH 1/2] [Clang] Improve error recovery for invalid calls

It doesn't make sense that we only build a RecoveryExpr for expressions
with invalid trailing commas. This patch extends it so that we now
always build up a RecoveryExpr whenever the call contains anything
invalid. As a result, we can back out HasTrailingComma.

There is only one diagnostic change as to concepts, where a
RecoveryExpr than an ExprError is used to model an invalud requires
clause, for which we now suggest adding parenthesis around it.
---
 clang/docs/ReleaseNotes.rst   |  2 ++
 clang/include/clang/Parse/Parser.h|  3 +-
 clang/lib/Parse/ParseExpr.cpp | 31 +++
 clang/test/AST/ast-dump-recovery.cpp  | 11 ---
 clang/test/AST/new-unknown-type.cpp   |  8 -
 .../Parser/cxx-concepts-requires-clause.cpp   |  3 +-
 6 files changed, 30 insertions(+), 28 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index f5cd1fbeabcfe..613b79ca2c3d8 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -395,6 +395,8 @@ Improvements to Clang's diagnostics
   constructors to initialize their non-modifiable members. The diagnostic is
   not new; being controlled via a warning group is what's new. Fixes #GH41104
 
+- Improved Clang's error recovery for invalid function calls.
+
 Improvements to Clang's time-trace
 --
 
diff --git a/clang/include/clang/Parse/Parser.h 
b/clang/include/clang/Parse/Parser.h
index 662f54d0e8d8a..40dbe23434d04 100644
--- a/clang/include/clang/Parse/Parser.h
+++ b/clang/include/clang/Parse/Parser.h
@@ -1942,8 +1942,7 @@ class Parser : public CodeCompletionHandler {
llvm::function_ref ExpressionStarts =
llvm::function_ref(),
bool FailImmediatelyOnInvalidExpr = false,
-   bool EarlyTypoCorrection = false,
-   bool *HasTrailingComma = nullptr);
+   bool EarlyTypoCorrection = false);
 
   /// ParseSimpleExpressionList - A simple comma-separated list of expressions,
   /// used for misc language extensions.
diff --git a/clang/lib/Parse/ParseExpr.cpp b/clang/lib/Parse/ParseExpr.cpp
index 3e3e7cbcd68b2..df015564849da 100644
--- a/clang/lib/Parse/ParseExpr.cpp
+++ b/clang/lib/Parse/ParseExpr.cpp
@@ -2218,19 +2218,13 @@ Parser::ParsePostfixExpressionSuffix(ExprResult LHS) {
 CalledSignatureHelp = true;
 return PreferredType;
   };
+  bool KnownInvalidCall = false;
   if (OpKind == tok::l_paren || !LHS.isInvalid()) {
 if (Tok.isNot(tok::r_paren)) {
-  bool HasTrailingComma = false;
-  bool HasError = ParseExpressionList(
-  ArgExprs,
-  [&] {
-PreferredType.enterFunctionArgument(Tok.getLocation(),
-RunSignatureHelp);
-  },
-  /*FailImmediatelyOnInvalidExpr*/ false,
-  /*EarlyTypoCorrection*/ false, &HasTrailingComma);
-
-  if (HasError && !HasTrailingComma) {
+  if ((KnownInvalidCall = ParseExpressionList(ArgExprs, [&] {
+ PreferredType.enterFunctionArgument(Tok.getLocation(),
+ RunSignatureHelp);
+   }))) {
 (void)Actions.CorrectDelayedTyposInExpr(LHS);
 // If we got an error when parsing expression list, we don't call
 // the CodeCompleteCall handler inside the parser. So call it here
@@ -2238,7 +2232,6 @@ Parser::ParsePostfixExpressionSuffix(ExprResult LHS) {
 // middle of a parameter.
 if (PP.isCodeCompletionReached() && !CalledSignatureHelp)
   RunSignatureHelp();
-LHS = ExprError();
   } else if (LHS.isInvalid()) {
 for (auto &E : ArgExprs)
   Actions.CorrectDelayedTyposInExpr(E);
@@ -2249,6 +2242,12 @@ Parser::ParsePostfixExpressionSuffix(ExprResult LHS) {
   // Match the ')'.
   if (LHS.isInvalid()) {
 SkipUntil(tok::r_paren, StopAtSemi);
+  } else if (KnownInvalidCall) {
+Expr *Fn = LHS.get();
+ArgExprs.insert(ArgExprs.begin(), Fn);
+LHS = Actions.CreateRecoveryExpr(Fn->getBeginLoc(), Tok.getLocation(),
+ ArgExprs);
+SkipUntil(tok::r_paren, StopAtSemi);
   } else if (Tok.isNot(tok::r_paren)) {
 bool HadDelayedTypo = false;
 if (Actions.CorrectDelayedTyposInExpr(LHS).get() != LHS.get())
@@ -3700,8 +3699,7 @@ void Parser::injectEmbedTokens() {
 bool Parser::ParseExpressionList(SmallVectorIm

[clang] [Clang] Add support for GCC bound member functions extension (PR #135649)

2025-04-21 Thread Hubert Tong via cfe-commits

hubert-reinterpretcast wrote:

> IIRC this feature is orthogonal to GCC bound member functions. `declcall` 
> with a virtual method just returns a pmf, and we still need to perform vtable 
> lookup at the callsite: https://compiler-explorer.com/z/YrT3nPTEz

Try `declcall(p->B::virtual_method())`?: 
https://compiler-explorer.com/z/7d9KPE8zK

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


[clang] [Clang] Add support for GCC bound member functions extension (PR #135649)

2025-04-21 Thread Sirui Mu via cfe-commits


@@ -0,0 +1,105 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --check-globals all --version 5
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -Wno-pmf-conversions %s -O3 
-emit-llvm -o - | FileCheck %s
+
+struct A {
+  int data;
+//.
+// CHECK: @method = local_unnamed_addr global ptr @_ZN1A6methodEv, align 8
+//.
+// CHECK-LABEL: define linkonce_odr noundef i32 @_ZN1A6methodEv(
+// CHECK-SAME: ptr noundef nonnull align 8 dereferenceable(12) [[THIS:%.*]]) 
#[[ATTR0:[0-9]+]] comdat align 2 {
+// CHECK-NEXT:  [[ENTRY:.*:]]
+// CHECK-NEXT:ret i32 0
+//
+  int method() { return 0; }
+  virtual int virtual_method() { return 1; }
+  virtual ~A() = default;
+};
+
+struct C {
+  int data;
+};
+
+struct B : C, A {
+  virtual int virtual_method() override { return 2; }
+};
+
+using pmf_type = int (A::*)();
+using pf_type = int (*)(A*);
+
+pf_type method = reinterpret_cast(&A::method);
+
+// CHECK-LABEL: define dso_local noundef ptr @_Z11convert_pmfP1AMS_FivE(
+// CHECK-SAME: ptr noundef readonly captures(none) [[P:%.*]], i64 
[[METHOD_COERCE0:%.*]], i64 [[METHOD_COERCE1:%.*]]) local_unnamed_addr 
#[[ATTR1:[0-9]+]] {
+// CHECK-NEXT:  [[ENTRY:.*:]]
+// CHECK-NEXT:[[TMP0:%.*]] = and i64 [[METHOD_COERCE0]], 1
+// CHECK-NEXT:[[MEMPTR_ISVIRTUAL_NOT:%.*]] = icmp eq i64 [[TMP0]], 0
+// CHECK-NEXT:br i1 [[MEMPTR_ISVIRTUAL_NOT]], label 
%[[MEMPTR_NONVIRTUAL:.*]], label %[[MEMPTR_VIRTUAL:.*]]
+// CHECK:   [[MEMPTR_VIRTUAL]]:
+// CHECK-NEXT:[[TMP1:%.*]] = getelementptr inbounds i8, ptr [[P]], i64 
[[METHOD_COERCE1]]
+// CHECK-NEXT:[[VTABLE:%.*]] = load ptr, ptr [[TMP1]], align 8, !tbaa 
[[TBAA2:![0-9]+]]
+// CHECK-NEXT:[[TMP2:%.*]] = getelementptr i8, ptr [[VTABLE]], i64 
[[METHOD_COERCE0]]
+// CHECK-NEXT:[[TMP3:%.*]] = getelementptr i8, ptr [[TMP2]], i64 -1
+// CHECK-NEXT:[[MEMPTR_VIRTUALFN:%.*]] = load ptr, ptr [[TMP3]], align 8, 
!nosanitize [[META5:![0-9]+]]
+// CHECK-NEXT:br label %[[MEMPTR_END:.*]]
+// CHECK:   [[MEMPTR_NONVIRTUAL]]:
+// CHECK-NEXT:[[MEMPTR_NONVIRTUALFN:%.*]] = inttoptr i64 
[[METHOD_COERCE0]] to ptr
+// CHECK-NEXT:br label %[[MEMPTR_END]]

Lancern wrote:

Seems like the non-virtual path does not take into account the offset in the 
pmf, and unfortunately this is also what gcc is doing. Although this PR is 
primarily for the virtual path, the erroneous non-virtual path could really 
cause problems very easily.

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


[libclc] [libclc] Set OpenCL C version for each target (PR #135733)

2025-04-21 Thread Wenju He via cfe-commits

https://github.com/wenju-he updated 
https://github.com/llvm/llvm-project/pull/135733

>From 64d7bfdceb5a0a6fbf34bb15cd7d6cbeb9214881 Mon Sep 17 00:00:00 2001
From: Wenju He 
Date: Mon, 14 Apr 2025 19:20:25 -0700
Subject: [PATCH 1/5] [libclc] Set OpenCL version to 3.0

This PR is cherry-pick of https://github.com/intel/llvm/commit/cba338e5fb1c
This allows adding OpenCL 2.0 built-ins, e.g. ctz, and OpenCL 3.0
extension built-ins, including generic address space variants.

llvm-diff shows this PR has no change in amdgcn--amdhsa.bc.
---
 libclc/CMakeLists.txt | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/libclc/CMakeLists.txt b/libclc/CMakeLists.txt
index dbbc29261d3b5..278ae5d777a84 100644
--- a/libclc/CMakeLists.txt
+++ b/libclc/CMakeLists.txt
@@ -411,6 +411,16 @@ foreach( t ${LIBCLC_TARGETS_TO_BUILD} )
 set( LIBCLC_ARCH_OBJFILE_DIR "${LIBCLC_OBJFILE_DIR}/${arch_suffix}" )
 file( MAKE_DIRECTORY ${LIBCLC_ARCH_OBJFILE_DIR} )
 
+# OpenCL 3.0 extensions
+string(CONCAT CL_3_0_EXTENSIONS
+  "-cl-ext="
+  "+cl_khr_fp64,"
+  "+cl_khr_fp16,"
+  "+__opencl_c_3d_image_writes,"
+  "+__opencl_c_images,"
+  "+cl_khr_3d_image_writes")
+list( APPEND build_flags -cl-std=CL3.0 "-Xclang" ${CL_3_0_EXTENSIONS} )
+
 string( TOUPPER "CLC_${MACRO_ARCH}" CLC_TARGET_DEFINE )
 
 list( APPEND build_flags

>From 4facfec781e39a247aba639ea8e080aa79153a12 Mon Sep 17 00:00:00 2001
From: Wenju He 
Date: Tue, 15 Apr 2025 20:56:40 -0700
Subject: [PATCH 2/5] set opencl_c_version per target, remove CL_3_0_EXTENSIONS

---
 libclc/CMakeLists.txt | 32 +---
 1 file changed, 21 insertions(+), 11 deletions(-)

diff --git a/libclc/CMakeLists.txt b/libclc/CMakeLists.txt
index 278ae5d777a84..e3093af57e728 100644
--- a/libclc/CMakeLists.txt
+++ b/libclc/CMakeLists.txt
@@ -387,7 +387,11 @@ foreach( t ${LIBCLC_TARGETS_TO_BUILD} )
 
 message( STATUS "  device: ${d} ( ${${d}_aliases} )" )
 
-if ( ARCH STREQUAL spirv OR ARCH STREQUAL spirv64 )
+# 1.2 is Clang's default OpenCL C language standard to compile for.
+set( opencl_lang_std "CL1.2" )
+
+if ( ${DARCH} STREQUAL spirv )
+  set( opencl_lang_std "CL3.0" )
   set( build_flags -O0 -finline-hint-functions -DCLC_SPIRV )
   set( opt_flags )
   set( spvflags --spirv-max-version=1.1 )
@@ -395,13 +399,27 @@ foreach( t ${LIBCLC_TARGETS_TO_BUILD} )
   if( ARCH STREQUAL spirv64 )
 set( MACRO_ARCH SPIRV64 )
   endif()
-elseif( ARCH STREQUAL clspv OR ARCH STREQUAL clspv64 )
+elseif( ${DARCH} STREQUAL clspv )
+  # Refer to https://github.com/google/clspv for OpenCL version.
+  set( opencl_lang_std "CL3.0" )
   set( build_flags "-Wno-unknown-assumption" -DCLC_CLSPV )
   set( opt_flags -O3 )
   set( MACRO_ARCH CLSPV32 )
   if( ARCH STREQUAL clspv64 )
 set( MACRO_ARCH CLSPV64 )
   endif()
+elseif( ${DARCH} STREQUAL nvptx )
+  # Refer to https://www.khronos.org/opencl/ for OpenCL version in NV 
implementation.
+  set( opencl_lang_std "CL3.0" )
+  set( build_flags )
+  set( opt_flags -O3 )
+  set( MACRO_ARCH ${ARCH} )
+elseif( ${DARCH} STREQUAL amdgcn OR ${DARCH} STREQUAL amdgcn-amdhsa OR 
${DARCH} STREQUAL r600 )
+  # Refer to https://github.com/ROCm/clr/tree/develop/opencl for OpenCL 
version.
+  set( opencl_lang_std "CL2.0" )
+  set( build_flags )
+  set( opt_flags -O3 )
+  set( MACRO_ARCH ${ARCH} )
 else()
   set( build_flags )
   set( opt_flags -O3 )
@@ -411,15 +429,7 @@ foreach( t ${LIBCLC_TARGETS_TO_BUILD} )
 set( LIBCLC_ARCH_OBJFILE_DIR "${LIBCLC_OBJFILE_DIR}/${arch_suffix}" )
 file( MAKE_DIRECTORY ${LIBCLC_ARCH_OBJFILE_DIR} )
 
-# OpenCL 3.0 extensions
-string(CONCAT CL_3_0_EXTENSIONS
-  "-cl-ext="
-  "+cl_khr_fp64,"
-  "+cl_khr_fp16,"
-  "+__opencl_c_3d_image_writes,"
-  "+__opencl_c_images,"
-  "+cl_khr_3d_image_writes")
-list( APPEND build_flags -cl-std=CL3.0 "-Xclang" ${CL_3_0_EXTENSIONS} )
+list( APPEND build_flags -cl-std=${opencl_lang_std} )
 
 string( TOUPPER "CLC_${MACRO_ARCH}" CLC_TARGET_DEFINE )
 

>From 31604df0f2c7337d476878bc3245f452fe2c941b Mon Sep 17 00:00:00 2001
From: Wenju He 
Date: Tue, 15 Apr 2025 21:05:57 -0700
Subject: [PATCH 3/5] use default OpenCL C version for r600

---
 libclc/CMakeLists.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libclc/CMakeLists.txt b/libclc/CMakeLists.txt
index e3093af57e728..07da2466f5e42 100644
--- a/libclc/CMakeLists.txt
+++ b/libclc/CMakeLists.txt
@@ -414,7 +414,7 @@ foreach( t ${LIBCLC_TARGETS_TO_BUILD} )
   set( build_flags )
   set( opt_flags -O3 )
   set( MACRO_ARCH ${ARCH} )
-elseif( ${DARCH} STREQUAL amdgcn OR ${DARCH} STREQUAL amdgcn-amdhsa OR 
${DARCH} STREQUAL r600 )
+elseif( ${DARCH} STREQUAL amdgcn OR ${DARCH} STREQUAL amdgcn-amdhsa )
   # Refer to https://github.com/ROCm/clr/tree/develop/opencl for O

[clang] [Clang] Add support for GCC bound member functions extension (PR #135649)

2025-04-21 Thread via cfe-commits

rockeet wrote:

> > Yes, I'm very eager for this feature, let me investigate the RFC proposal 
> > routine.
> 
> I would recommend you also include details about how the extension meets our 
> [usual criteria](https://clang.llvm.org/get_involved.html#criteria) when you 
> write the RFC.

Thank you for your information, I'm new to llvm project, I've written the 
[[RFC] Implement gcc Bound PMF in clang 
](https://discourse.llvm.org/t/rfc-implement-gcc-pmf-in-clang/85951).

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


[clang] b144258 - [Clang] Improve error recovery for invalid calls (#136295)

2025-04-21 Thread via cfe-commits

Author: Younan Zhang
Date: 2025-04-22T10:41:16+08:00
New Revision: b144258b0c0cc63dffba00a911d6539f00ed07bb

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

LOG: [Clang] Improve error recovery for invalid calls (#136295)

It doesn't make sense that we only build a RecoveryExpr for expressions
with invalid trailing commas. This patch extends it so that we now
always build up a RecoveryExpr whenever the call contains anything
invalid. As a result, we can back out HasTrailingComma.

There is only one diagnostic change as to concepts, where a RecoveryExpr
than an ExprError is now used to model an invalid requires clause, for
which we suggest adding parentheses around it. (This looks like what GCC
diagnoses)

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/include/clang/Parse/Parser.h
clang/lib/Parse/ParseExpr.cpp
clang/test/AST/ast-dump-recovery.cpp
clang/test/AST/new-unknown-type.cpp
clang/test/Parser/cxx-concepts-requires-clause.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 36b528d9e20f8..86d37f5616356 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -398,6 +398,9 @@ Improvements to Clang's diagnostics
   constructors to initialize their non-modifiable members. The diagnostic is
   not new; being controlled via a warning group is what's new. Fixes #GH41104
 
+
+- Improved Clang's error recovery for invalid function calls.
+
 - Improved bit-field diagnostics to consider the type specified by the
   ``preferred_type`` attribute. These diagnostics are controlled by the flags
   ``-Wpreferred-type-bitfield-enum-conversion`` and
@@ -405,7 +408,6 @@ Improvements to Clang's diagnostics
   they're only triggered if the authors are already making the choice to use
   ``preferred_type`` attribute.
 
-
 Improvements to Clang's time-trace
 --
 

diff  --git a/clang/include/clang/Parse/Parser.h 
b/clang/include/clang/Parse/Parser.h
index 7ffe23c73eda9..645df4aabc374 100644
--- a/clang/include/clang/Parse/Parser.h
+++ b/clang/include/clang/Parse/Parser.h
@@ -1942,8 +1942,7 @@ class Parser : public CodeCompletionHandler {
llvm::function_ref ExpressionStarts =
llvm::function_ref(),
bool FailImmediatelyOnInvalidExpr = false,
-   bool EarlyTypoCorrection = false,
-   bool *HasTrailingComma = nullptr);
+   bool EarlyTypoCorrection = false);
 
   /// ParseSimpleExpressionList - A simple comma-separated list of expressions,
   /// used for misc language extensions.

diff  --git a/clang/lib/Parse/ParseExpr.cpp b/clang/lib/Parse/ParseExpr.cpp
index 3e3e7cbcd68b2..59ce8a998969d 100644
--- a/clang/lib/Parse/ParseExpr.cpp
+++ b/clang/lib/Parse/ParseExpr.cpp
@@ -2218,19 +2218,13 @@ Parser::ParsePostfixExpressionSuffix(ExprResult LHS) {
 CalledSignatureHelp = true;
 return PreferredType;
   };
+  bool ExpressionListIsInvalid = false;
   if (OpKind == tok::l_paren || !LHS.isInvalid()) {
 if (Tok.isNot(tok::r_paren)) {
-  bool HasTrailingComma = false;
-  bool HasError = ParseExpressionList(
-  ArgExprs,
-  [&] {
-PreferredType.enterFunctionArgument(Tok.getLocation(),
-RunSignatureHelp);
-  },
-  /*FailImmediatelyOnInvalidExpr*/ false,
-  /*EarlyTypoCorrection*/ false, &HasTrailingComma);
-
-  if (HasError && !HasTrailingComma) {
+  if ((ExpressionListIsInvalid = ParseExpressionList(ArgExprs, [&] {
+ PreferredType.enterFunctionArgument(Tok.getLocation(),
+ RunSignatureHelp);
+   }))) {
 (void)Actions.CorrectDelayedTyposInExpr(LHS);
 // If we got an error when parsing expression list, we don't call
 // the CodeCompleteCall handler inside the parser. So call it here
@@ -2238,7 +2232,6 @@ Parser::ParsePostfixExpressionSuffix(ExprResult LHS) {
 // middle of a parameter.
 if (PP.isCodeCompletionReached() && !CalledSignatureHelp)
   RunSignatureHelp();
-LHS = ExprError();
   } else if (LHS.isInvalid()) {
 for (auto &E : ArgExprs)
   Actions.CorrectDelayedTyposInExpr(E);
@@ -2249,6 +2242,12 @@ Parser::ParsePostfixExpressionSuffix(ExprResult LHS) {
   // Match the ')'.
   if (LHS.isInvalid()) {
 SkipUntil(tok::r_paren, StopAtSemi);
+  } else if (ExpressionListIsInvalid) {
+Expr *Fn = LHS.get();
+ArgExpr

[clang-tools-extra] [clangd] Improve `BlockEnd` inlayhint presentation (PR #136106)

2025-04-21 Thread via cfe-commits

https://github.com/MythreyaK updated 
https://github.com/llvm/llvm-project/pull/136106

>From d03c7afdd497011335590448fef886395cc815d2 Mon Sep 17 00:00:00 2001
From: daiyousei-qz 
Date: Tue, 14 Nov 2023 20:42:10 -0800
Subject: [PATCH 1/5] Improve BlockEnd presentation including: 1. Explicitly
 state a function call 2. Print literal nullptr 3. Escape for abbreviated
 string 4. Adjust min line limit to 10

---
 clang-tools-extra/clangd/InlayHints.cpp | 19 +--
 1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/clang-tools-extra/clangd/InlayHints.cpp 
b/clang-tools-extra/clangd/InlayHints.cpp
index 40a824618f782..a1bc9956ec628 100644
--- a/clang-tools-extra/clangd/InlayHints.cpp
+++ b/clang-tools-extra/clangd/InlayHints.cpp
@@ -112,7 +112,9 @@ std::string summarizeExpr(const Expr *E) {
   return getSimpleName(*E->getFoundDecl()).str();
 }
 std::string VisitCallExpr(const CallExpr *E) {
-  return Visit(E->getCallee());
+  std::string Result = Visit(E->getCallee());
+  Result += E->getNumArgs() == 0 ? "()" : "(...)";
+  return Result;
 }
 std::string
 VisitCXXDependentScopeMemberExpr(const CXXDependentScopeMemberExpr *E) {
@@ -147,6 +149,9 @@ std::string summarizeExpr(const Expr *E) {
 }
 
 // Literals are just printed
+std::string VisitCXXNullPtrLiteralExpr(const CXXNullPtrLiteralExpr *E) {
+  return "nullptr";
+}
 std::string VisitCXXBoolLiteralExpr(const CXXBoolLiteralExpr *E) {
   return E->getValue() ? "true" : "false";
 }
@@ -165,12 +170,14 @@ std::string summarizeExpr(const Expr *E) {
   std::string Result = "\"";
   if (E->containsNonAscii()) {
 Result += "...";
-  } else if (E->getLength() > 10) {
-Result += E->getString().take_front(7);
-Result += "...";
   } else {
 llvm::raw_string_ostream OS(Result);
-llvm::printEscapedString(E->getString(), OS);
+if (E->getLength() > 10) {
+  llvm::printEscapedString(E->getString().take_front(7), OS);
+  Result += "...";
+} else {
+  llvm::printEscapedString(E->getString(), OS);
+}
   }
   Result.push_back('"');
   return Result;
@@ -1120,7 +1127,7 @@ class InlayHintVisitor : public 
RecursiveASTVisitor {
   // Otherwise, the hint shouldn't be shown.
   std::optional computeBlockEndHintRange(SourceRange BraceRange,
 StringRef OptionalPunctuation) 
{
-constexpr unsigned HintMinLineLimit = 2;
+constexpr unsigned HintMinLineLimit = 10;
 
 auto &SM = AST.getSourceManager();
 auto [BlockBeginFileId, BlockBeginOffset] =

>From aedd2ee40b7370eab0cc15e8d80bdc33abe550f0 Mon Sep 17 00:00:00 2001
From: Mythreya 
Date: Thu, 17 Apr 2025 01:28:53 -0700
Subject: [PATCH 2/5] Add `InlayHintOptions`

---
 clang-tools-extra/clangd/InlayHints.cpp | 16 ++--
 clang-tools-extra/clangd/InlayHints.h   |  8 +++-
 2 files changed, 17 insertions(+), 7 deletions(-)

diff --git a/clang-tools-extra/clangd/InlayHints.cpp 
b/clang-tools-extra/clangd/InlayHints.cpp
index a1bc9956ec628..bdab2b8a9f377 100644
--- a/clang-tools-extra/clangd/InlayHints.cpp
+++ b/clang-tools-extra/clangd/InlayHints.cpp
@@ -415,12 +415,14 @@ struct Callee {
 class InlayHintVisitor : public RecursiveASTVisitor {
 public:
   InlayHintVisitor(std::vector &Results, ParsedAST &AST,
-   const Config &Cfg, std::optional RestrictRange)
+   const Config &Cfg, std::optional RestrictRange,
+   InlayHintOptions HintOptions)
   : Results(Results), AST(AST.getASTContext()), Tokens(AST.getTokens()),
 Cfg(Cfg), RestrictRange(std::move(RestrictRange)),
 MainFileID(AST.getSourceManager().getMainFileID()),
 Resolver(AST.getHeuristicResolver()),
-TypeHintPolicy(this->AST.getPrintingPolicy()) {
+TypeHintPolicy(this->AST.getPrintingPolicy()),
+HintOptions(HintOptions) {
 bool Invalid = false;
 llvm::StringRef Buf =
 AST.getSourceManager().getBufferData(MainFileID, &Invalid);
@@ -1127,7 +1129,6 @@ class InlayHintVisitor : public 
RecursiveASTVisitor {
   // Otherwise, the hint shouldn't be shown.
   std::optional computeBlockEndHintRange(SourceRange BraceRange,
 StringRef OptionalPunctuation) 
{
-constexpr unsigned HintMinLineLimit = 10;
 
 auto &SM = AST.getSourceManager();
 auto [BlockBeginFileId, BlockBeginOffset] =
@@ -1155,7 +1156,7 @@ class InlayHintVisitor : public 
RecursiveASTVisitor {
 auto RBraceLine = SM.getLineNumber(RBraceFileId, RBraceOffset);
 
 // Don't show hint on trivial blocks like `class X {};`
-if (BlockBeginLine + HintMinLineLimit - 1 > RBraceLine)
+if (BlockBeginLine + HintOptions.HintMinLineLimit - 1 > RBraceLine)
   return std::nullopt;
 
 // This is what we attach the hint to, usually "}" or "};".
@@ -1185,17 +1186,20 @@ class I

[clang] [Clang] Improve error recovery for invalid calls (PR #136295)

2025-04-21 Thread Younan Zhang via cfe-commits

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


[clang] [Clang] Add support for GCC bound member functions extension (PR #135649)

2025-04-21 Thread Yingwei Zheng via cfe-commits

dtcxzyw wrote:

> > IIRC this feature is orthogonal to GCC bound member functions. `declcall` 
> > with a virtual method just returns a pmf, and we still need to perform 
> > vtable lookup at the callsite: https://compiler-explorer.com/z/YrT3nPTEz
> 
> Try `declcall(p->B::virtual_method())`?: 
> https://compiler-explorer.com/z/7d9KPE8zK

We don't know which function is called until the object `p` is provided.
See case 2 in 
https://discourse.llvm.org/t/rfc-implement-gcc-bound-pmf-in-clang/85951.


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


[clang] [CIR] Make ZeroAttr use AttrBuilderWithInferredContext (PR #136604)

2025-04-21 Thread Henrich Lauko via cfe-commits

https://github.com/xlauko updated 
https://github.com/llvm/llvm-project/pull/136604

>From 7790612aabf4a310328b16551620edf0704d5453 Mon Sep 17 00:00:00 2001
From: xlauko 
Date: Mon, 21 Apr 2025 21:51:06 +0200
Subject: [PATCH] [CIR] Make ZeroAttr use AttrBuilderWithInferredContext

---
 clang/include/clang/CIR/Dialect/Builder/CIRBaseBuilder.h | 8 ++--
 clang/include/clang/CIR/Dialect/IR/CIRAttrs.td   | 7 +++
 clang/lib/CIR/CodeGen/CIRGenExprConstant.cpp | 2 +-
 3 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/clang/include/clang/CIR/Dialect/Builder/CIRBaseBuilder.h 
b/clang/include/clang/CIR/Dialect/Builder/CIRBaseBuilder.h
index ee8af62ede0da..b303aa07838ee 100644
--- a/clang/include/clang/CIR/Dialect/Builder/CIRBaseBuilder.h
+++ b/clang/include/clang/CIR/Dialect/Builder/CIRBaseBuilder.h
@@ -83,21 +83,17 @@ class CIRBaseBuilderTy : public mlir::OpBuilder {
 return getConstPtrAttr(t, 0);
   }
 
-  mlir::TypedAttr getZeroAttr(mlir::Type t) {
-return cir::ZeroAttr::get(getContext(), t);
-  }
-
   mlir::TypedAttr getZeroInitAttr(mlir::Type ty) {
 if (mlir::isa(ty))
   return cir::IntAttr::get(ty, 0);
 if (cir::isAnyFloatingPointType(ty))
   return cir::FPAttr::getZero(ty);
 if (auto arrTy = mlir::dyn_cast(ty))
-  return getZeroAttr(arrTy);
+  return cir::ZeroAttr::get(arrTy);
 if (auto ptrTy = mlir::dyn_cast(ty))
   return getConstNullPtrAttr(ptrTy);
 if (auto recordTy = mlir::dyn_cast(ty))
-  return getZeroAttr(recordTy);
+  return cir::ZeroAttr::get(recordTy);
 if (mlir::isa(ty)) {
   return getFalseAttr();
 }
diff --git a/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td 
b/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td
index 25ceded7e8a5b..214db1b1caeeb 100644
--- a/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td
+++ b/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td
@@ -71,6 +71,13 @@ def ZeroAttr : CIR_Attr<"Zero", "zero", 
[TypedAttrInterface]> {
   }];
 
   let parameters = (ins AttributeSelfTypeParameter<"">:$type);
+
+  let builders = [
+AttrBuilderWithInferredContext<(ins "mlir::Type":$type), [{
+  return $_get(type.getContext(), type);
+}]>
+  ];
+
   let assemblyFormat = [{}];
 }
 
diff --git a/clang/lib/CIR/CodeGen/CIRGenExprConstant.cpp 
b/clang/lib/CIR/CodeGen/CIRGenExprConstant.cpp
index 0caa8961ed0a6..b9a74e90a5960 100644
--- a/clang/lib/CIR/CodeGen/CIRGenExprConstant.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenExprConstant.cpp
@@ -183,7 +183,7 @@ emitArrayConstant(CIRGenModule &cgm, mlir::Type desiredType,
   }
 
   if (nonzeroLength == 0)
-return cir::ZeroAttr::get(builder.getContext(), desiredType);
+return cir::ZeroAttr::get(desiredType);
 
   const unsigned trailingZeroes = arrayBound - nonzeroLength;
 

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


[clang] [lld] [llvm] [X86] Implement disabling APX relocations and EPGR/NDD instrs for relocations (PR #136660)

2025-04-21 Thread via cfe-commits

llvmbot wrote:



@llvm/pr-subscribers-lld-elf

@llvm/pr-subscribers-backend-x86

Author: Feng Zou (fzou1)


Changes

Introduce an option (-mapx-relax-relocations) to control the emission of the 
new APX relocations. It's off by default to keep backward compatibility with 
old version of ld and other linkers without APX support. And EGPR and NDD are 
also suppressed to avoid the instructions updated incorrectly by old version of 
linkers.

---

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


37 Files Affected:

- (modified) clang/CMakeLists.txt (+3) 
- (modified) clang/cmake/caches/Fuchsia-stage2.cmake (+1) 
- (modified) clang/cmake/caches/Fuchsia.cmake (+1) 
- (modified) clang/include/clang/Basic/CodeGenOptions.def (+1) 
- (modified) clang/include/clang/Config/config.h.cmake (+3) 
- (modified) clang/include/clang/Driver/Options.td (+3) 
- (modified) clang/include/clang/Driver/ToolChain.h (+3) 
- (modified) clang/lib/CodeGen/BackendUtil.cpp (+1) 
- (modified) clang/lib/Driver/ToolChain.cpp (+4) 
- (modified) clang/lib/Driver/ToolChains/Clang.cpp (+10) 
- (modified) clang/test/Driver/relax.s (+12-3) 
- (modified) clang/tools/driver/cc1as_main.cpp (+5) 
- (modified) lld/ELF/Arch/X86_64.cpp (+3-3) 
- (modified) lld/test/ELF/tls-opt.s (+78-33) 
- (modified) lld/test/ELF/x86-64-gotpc-no-relax-err.s (+7-2) 
- (modified) lld/test/ELF/x86-64-gotpc-relax-nopic.s (+25-10) 
- (modified) lld/test/ELF/x86-64-gotpc-relax.s (+64-27) 
- (modified) lld/test/ELF/x86-64-tlsdesc-gd.s (+32-5) 
- (modified) llvm/include/llvm/MC/MCTargetOptions.h (+2) 
- (modified) llvm/include/llvm/MC/MCTargetOptionsCommandFlags.h (+2) 
- (modified) llvm/lib/LTO/LTO.cpp (+1) 
- (modified) llvm/lib/MC/MCTargetOptionsCommandFlags.cpp (+10) 
- (modified) llvm/lib/Target/X86/CMakeLists.txt (+1) 
- (modified) llvm/lib/Target/X86/MCTargetDesc/X86BaseInfo.h (+22) 
- (modified) llvm/lib/Target/X86/MCTargetDesc/X86ELFObjectWriter.cpp (+13-7) 
- (modified) llvm/lib/Target/X86/X86.h (+1) 
- (modified) llvm/lib/Target/X86/X86InstrInfo.cpp (+1-16) 
- (added) llvm/lib/Target/X86/X86SuppressEGPRAndNDDForReloc.cpp (+145) 
- (modified) llvm/lib/Target/X86/X86TargetMachine.cpp (+2) 
- (modified) llvm/test/CodeGen/X86/O0-pipeline.ll (+1) 
- (added) llvm/test/CodeGen/X86/apx/tls-desc.ll (+96) 
- (modified) llvm/test/CodeGen/X86/opt-pipeline.ll (+3) 
- (modified) llvm/test/MC/ELF/relocation-alias.s (+7-1) 
- (modified) llvm/test/MC/X86/elf-reloc-tls.s (+15-1) 
- (modified) llvm/test/MC/X86/gotpcrelx.s (+48-1) 
- (modified) llvm/test/MC/X86/tlsdesc-64.s (+7-1) 
- (modified) llvm/tools/gold/gold-plugin.cpp (+2) 


``diff
diff --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt
index c3f30e2a8e9c0..fa3063d6be9a7 100644
--- a/clang/CMakeLists.txt
+++ b/clang/CMakeLists.txt
@@ -219,6 +219,9 @@ set(ENABLE_LINKER_BUILD_ID OFF CACHE BOOL "pass --build-id 
to ld")
 set(ENABLE_X86_RELAX_RELOCATIONS ON CACHE BOOL
 "enable x86 relax relocations by default")
 
+set(ENABLE_X86_APX_RELAX_RELOCATIONS OFF CACHE BOOL
+"Enable x86 APX relax relocations by default")
+
 set(PPC_LINUX_DEFAULT_IEEELONGDOUBLE OFF CACHE BOOL
 "Enable IEEE binary128 as default long double format on PowerPC Linux.")
 
diff --git a/clang/cmake/caches/Fuchsia-stage2.cmake 
b/clang/cmake/caches/Fuchsia-stage2.cmake
index 99890b8246ad7..22eef24b611a8 100644
--- a/clang/cmake/caches/Fuchsia-stage2.cmake
+++ b/clang/cmake/caches/Fuchsia-stage2.cmake
@@ -49,6 +49,7 @@ set(CLANG_PLUGIN_SUPPORT OFF CACHE BOOL "")
 
 set(ENABLE_LINKER_BUILD_ID ON CACHE BOOL "")
 set(ENABLE_X86_RELAX_RELOCATIONS ON CACHE BOOL "")
+set(ENABLE_X86_APX_RELAX_RELOCATIONS OFF CACHE BOOL "")
 
 # TODO(#67176): relative-vtables doesn't play well with different default
 # visibilities. Making everything hidden visibility causes other complications
diff --git a/clang/cmake/caches/Fuchsia.cmake b/clang/cmake/caches/Fuchsia.cmake
index 83336589da305..550d94d1ec6a5 100644
--- a/clang/cmake/caches/Fuchsia.cmake
+++ b/clang/cmake/caches/Fuchsia.cmake
@@ -89,6 +89,7 @@ set(CLANG_PLUGIN_SUPPORT OFF CACHE BOOL "")
 
 set(ENABLE_LINKER_BUILD_ID ON CACHE BOOL "")
 set(ENABLE_X86_RELAX_RELOCATIONS ON CACHE BOOL "")
+set(ENABLE_X86_APX_RELAX_RELOCATIONS OFF CACHE BOOL "")
 
 set(LLVM_ENABLE_ASSERTIONS ON CACHE BOOL "")
 set(LLVM_ENABLE_BACKTRACES ON CACHE BOOL "")
diff --git a/clang/include/clang/Basic/CodeGenOptions.def 
b/clang/include/clang/Basic/CodeGenOptions.def
index c5990fb248689..875facd6cfc63 100644
--- a/clang/include/clang/Basic/CodeGenOptions.def
+++ b/clang/include/clang/Basic/CodeGenOptions.def
@@ -201,6 +201,7 @@ CODEGENOPT(UniqueInternalLinkageNames, 1, 0) ///< Internal 
Linkage symbols get u
 CODEGENOPT(SplitMachineFunctions, 1, 0) ///< Split machine functions using 
profile information.
 CODEGENOPT(PPCUseFullRegisterNames, 1, 0) ///< Print full register names in 
assembly
 CODEGENOPT(X86RelaxRelocations, 1, 1) ///< -Wa,-mrelax-relocations={yes,n

[clang] [lld] [llvm] [X86] Implement disabling APX relocations and EPGR/NDD instrs for relocations (PR #136660)

2025-04-21 Thread Feng Zou via cfe-commits

https://github.com/fzou1 created 
https://github.com/llvm/llvm-project/pull/136660

Introduce an option (-mapx-relax-relocations) to control the emission of the 
new APX relocations. It's off by default to keep backward compatibility with 
old version of ld and other linkers without APX support. And EGPR and NDD are 
also suppressed to avoid the instructions updated incorrectly by old version of 
linkers.

>From a98371ac23728289b7e1b9a1516141158bf7c1e0 Mon Sep 17 00:00:00 2001
From: Feng Zou 
Date: Tue, 22 Apr 2025 11:05:29 +0800
Subject: [PATCH] [X86] Implement disabling APX relocations and EPGR/NDD instrs
 for them

Introduce an option (-mapx-relax-relocations) to control the emission of the
new APX relocations. It's off by default to keep backward compatibility with
older version of ld and other linkers without APX support. And EGPR and NDD are
also suppressed to avoid the instructions updated incorrectly by older version
of linker.
---
 clang/CMakeLists.txt  |   3 +
 clang/cmake/caches/Fuchsia-stage2.cmake   |   1 +
 clang/cmake/caches/Fuchsia.cmake  |   1 +
 clang/include/clang/Basic/CodeGenOptions.def  |   1 +
 clang/include/clang/Config/config.h.cmake |   3 +
 clang/include/clang/Driver/Options.td |   3 +
 clang/include/clang/Driver/ToolChain.h|   3 +
 clang/lib/CodeGen/BackendUtil.cpp |   1 +
 clang/lib/Driver/ToolChain.cpp|   4 +
 clang/lib/Driver/ToolChains/Clang.cpp |  10 ++
 clang/test/Driver/relax.s |  15 +-
 clang/tools/driver/cc1as_main.cpp |   5 +
 lld/ELF/Arch/X86_64.cpp   |   6 +-
 lld/test/ELF/tls-opt.s| 111 ++
 lld/test/ELF/x86-64-gotpc-no-relax-err.s  |   9 +-
 lld/test/ELF/x86-64-gotpc-relax-nopic.s   |  35 +++--
 lld/test/ELF/x86-64-gotpc-relax.s |  91 +++
 lld/test/ELF/x86-64-tlsdesc-gd.s  |  37 -
 llvm/include/llvm/MC/MCTargetOptions.h|   2 +
 .../llvm/MC/MCTargetOptionsCommandFlags.h |   2 +
 llvm/lib/LTO/LTO.cpp  |   1 +
 llvm/lib/MC/MCTargetOptionsCommandFlags.cpp   |  10 ++
 llvm/lib/Target/X86/CMakeLists.txt|   1 +
 .../lib/Target/X86/MCTargetDesc/X86BaseInfo.h |  22 +++
 .../X86/MCTargetDesc/X86ELFObjectWriter.cpp   |  20 ++-
 llvm/lib/Target/X86/X86.h |   1 +
 llvm/lib/Target/X86/X86InstrInfo.cpp  |  17 +-
 .../X86/X86SuppressEGPRAndNDDForReloc.cpp | 145 ++
 llvm/lib/Target/X86/X86TargetMachine.cpp  |   2 +
 llvm/test/CodeGen/X86/O0-pipeline.ll  |   1 +
 llvm/test/CodeGen/X86/apx/tls-desc.ll |  96 
 llvm/test/CodeGen/X86/opt-pipeline.ll |   3 +
 llvm/test/MC/ELF/relocation-alias.s   |   8 +-
 llvm/test/MC/X86/elf-reloc-tls.s  |  16 +-
 llvm/test/MC/X86/gotpcrelx.s  |  49 +-
 llvm/test/MC/X86/tlsdesc-64.s |   8 +-
 llvm/tools/gold/gold-plugin.cpp   |   2 +
 37 files changed, 635 insertions(+), 110 deletions(-)
 create mode 100644 llvm/lib/Target/X86/X86SuppressEGPRAndNDDForReloc.cpp
 create mode 100644 llvm/test/CodeGen/X86/apx/tls-desc.ll

diff --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt
index c3f30e2a8e9c0..fa3063d6be9a7 100644
--- a/clang/CMakeLists.txt
+++ b/clang/CMakeLists.txt
@@ -219,6 +219,9 @@ set(ENABLE_LINKER_BUILD_ID OFF CACHE BOOL "pass --build-id 
to ld")
 set(ENABLE_X86_RELAX_RELOCATIONS ON CACHE BOOL
 "enable x86 relax relocations by default")
 
+set(ENABLE_X86_APX_RELAX_RELOCATIONS OFF CACHE BOOL
+"Enable x86 APX relax relocations by default")
+
 set(PPC_LINUX_DEFAULT_IEEELONGDOUBLE OFF CACHE BOOL
 "Enable IEEE binary128 as default long double format on PowerPC Linux.")
 
diff --git a/clang/cmake/caches/Fuchsia-stage2.cmake 
b/clang/cmake/caches/Fuchsia-stage2.cmake
index 99890b8246ad7..22eef24b611a8 100644
--- a/clang/cmake/caches/Fuchsia-stage2.cmake
+++ b/clang/cmake/caches/Fuchsia-stage2.cmake
@@ -49,6 +49,7 @@ set(CLANG_PLUGIN_SUPPORT OFF CACHE BOOL "")
 
 set(ENABLE_LINKER_BUILD_ID ON CACHE BOOL "")
 set(ENABLE_X86_RELAX_RELOCATIONS ON CACHE BOOL "")
+set(ENABLE_X86_APX_RELAX_RELOCATIONS OFF CACHE BOOL "")
 
 # TODO(#67176): relative-vtables doesn't play well with different default
 # visibilities. Making everything hidden visibility causes other complications
diff --git a/clang/cmake/caches/Fuchsia.cmake b/clang/cmake/caches/Fuchsia.cmake
index 83336589da305..550d94d1ec6a5 100644
--- a/clang/cmake/caches/Fuchsia.cmake
+++ b/clang/cmake/caches/Fuchsia.cmake
@@ -89,6 +89,7 @@ set(CLANG_PLUGIN_SUPPORT OFF CACHE BOOL "")
 
 set(ENABLE_LINKER_BUILD_ID ON CACHE BOOL "")
 set(ENABLE_X86_RELAX_RELOCATIONS ON CACHE BOOL "")
+set(ENABLE_X86_APX_RELAX_RELOCATIONS OFF CACHE BOOL "")
 
 set(LLVM_ENABLE_ASSERTIONS ON CACHE BOOL "")
 set(LLVM_ENABLE_BACKTRACES ON CACHE BOOL "")
diff --git a/clang/include/clang/Basic/CodeGe

[clang] [lld] [llvm] [X86] Implement disabling APX relocations and EPGR/NDD instrs for relocations (PR #136660)

2025-04-21 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-lld

Author: Feng Zou (fzou1)


Changes

Introduce an option (-mapx-relax-relocations) to control the emission of the 
new APX relocations. It's off by default to keep backward compatibility with 
old version of ld and other linkers without APX support. And EGPR and NDD are 
also suppressed to avoid the instructions updated incorrectly by old version of 
linkers.

---

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


37 Files Affected:

- (modified) clang/CMakeLists.txt (+3) 
- (modified) clang/cmake/caches/Fuchsia-stage2.cmake (+1) 
- (modified) clang/cmake/caches/Fuchsia.cmake (+1) 
- (modified) clang/include/clang/Basic/CodeGenOptions.def (+1) 
- (modified) clang/include/clang/Config/config.h.cmake (+3) 
- (modified) clang/include/clang/Driver/Options.td (+3) 
- (modified) clang/include/clang/Driver/ToolChain.h (+3) 
- (modified) clang/lib/CodeGen/BackendUtil.cpp (+1) 
- (modified) clang/lib/Driver/ToolChain.cpp (+4) 
- (modified) clang/lib/Driver/ToolChains/Clang.cpp (+10) 
- (modified) clang/test/Driver/relax.s (+12-3) 
- (modified) clang/tools/driver/cc1as_main.cpp (+5) 
- (modified) lld/ELF/Arch/X86_64.cpp (+3-3) 
- (modified) lld/test/ELF/tls-opt.s (+78-33) 
- (modified) lld/test/ELF/x86-64-gotpc-no-relax-err.s (+7-2) 
- (modified) lld/test/ELF/x86-64-gotpc-relax-nopic.s (+25-10) 
- (modified) lld/test/ELF/x86-64-gotpc-relax.s (+64-27) 
- (modified) lld/test/ELF/x86-64-tlsdesc-gd.s (+32-5) 
- (modified) llvm/include/llvm/MC/MCTargetOptions.h (+2) 
- (modified) llvm/include/llvm/MC/MCTargetOptionsCommandFlags.h (+2) 
- (modified) llvm/lib/LTO/LTO.cpp (+1) 
- (modified) llvm/lib/MC/MCTargetOptionsCommandFlags.cpp (+10) 
- (modified) llvm/lib/Target/X86/CMakeLists.txt (+1) 
- (modified) llvm/lib/Target/X86/MCTargetDesc/X86BaseInfo.h (+22) 
- (modified) llvm/lib/Target/X86/MCTargetDesc/X86ELFObjectWriter.cpp (+13-7) 
- (modified) llvm/lib/Target/X86/X86.h (+1) 
- (modified) llvm/lib/Target/X86/X86InstrInfo.cpp (+1-16) 
- (added) llvm/lib/Target/X86/X86SuppressEGPRAndNDDForReloc.cpp (+145) 
- (modified) llvm/lib/Target/X86/X86TargetMachine.cpp (+2) 
- (modified) llvm/test/CodeGen/X86/O0-pipeline.ll (+1) 
- (added) llvm/test/CodeGen/X86/apx/tls-desc.ll (+96) 
- (modified) llvm/test/CodeGen/X86/opt-pipeline.ll (+3) 
- (modified) llvm/test/MC/ELF/relocation-alias.s (+7-1) 
- (modified) llvm/test/MC/X86/elf-reloc-tls.s (+15-1) 
- (modified) llvm/test/MC/X86/gotpcrelx.s (+48-1) 
- (modified) llvm/test/MC/X86/tlsdesc-64.s (+7-1) 
- (modified) llvm/tools/gold/gold-plugin.cpp (+2) 


``diff
diff --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt
index c3f30e2a8e9c0..fa3063d6be9a7 100644
--- a/clang/CMakeLists.txt
+++ b/clang/CMakeLists.txt
@@ -219,6 +219,9 @@ set(ENABLE_LINKER_BUILD_ID OFF CACHE BOOL "pass --build-id 
to ld")
 set(ENABLE_X86_RELAX_RELOCATIONS ON CACHE BOOL
 "enable x86 relax relocations by default")
 
+set(ENABLE_X86_APX_RELAX_RELOCATIONS OFF CACHE BOOL
+"Enable x86 APX relax relocations by default")
+
 set(PPC_LINUX_DEFAULT_IEEELONGDOUBLE OFF CACHE BOOL
 "Enable IEEE binary128 as default long double format on PowerPC Linux.")
 
diff --git a/clang/cmake/caches/Fuchsia-stage2.cmake 
b/clang/cmake/caches/Fuchsia-stage2.cmake
index 99890b8246ad7..22eef24b611a8 100644
--- a/clang/cmake/caches/Fuchsia-stage2.cmake
+++ b/clang/cmake/caches/Fuchsia-stage2.cmake
@@ -49,6 +49,7 @@ set(CLANG_PLUGIN_SUPPORT OFF CACHE BOOL "")
 
 set(ENABLE_LINKER_BUILD_ID ON CACHE BOOL "")
 set(ENABLE_X86_RELAX_RELOCATIONS ON CACHE BOOL "")
+set(ENABLE_X86_APX_RELAX_RELOCATIONS OFF CACHE BOOL "")
 
 # TODO(#67176): relative-vtables doesn't play well with different default
 # visibilities. Making everything hidden visibility causes other complications
diff --git a/clang/cmake/caches/Fuchsia.cmake b/clang/cmake/caches/Fuchsia.cmake
index 83336589da305..550d94d1ec6a5 100644
--- a/clang/cmake/caches/Fuchsia.cmake
+++ b/clang/cmake/caches/Fuchsia.cmake
@@ -89,6 +89,7 @@ set(CLANG_PLUGIN_SUPPORT OFF CACHE BOOL "")
 
 set(ENABLE_LINKER_BUILD_ID ON CACHE BOOL "")
 set(ENABLE_X86_RELAX_RELOCATIONS ON CACHE BOOL "")
+set(ENABLE_X86_APX_RELAX_RELOCATIONS OFF CACHE BOOL "")
 
 set(LLVM_ENABLE_ASSERTIONS ON CACHE BOOL "")
 set(LLVM_ENABLE_BACKTRACES ON CACHE BOOL "")
diff --git a/clang/include/clang/Basic/CodeGenOptions.def 
b/clang/include/clang/Basic/CodeGenOptions.def
index c5990fb248689..875facd6cfc63 100644
--- a/clang/include/clang/Basic/CodeGenOptions.def
+++ b/clang/include/clang/Basic/CodeGenOptions.def
@@ -201,6 +201,7 @@ CODEGENOPT(UniqueInternalLinkageNames, 1, 0) ///< Internal 
Linkage symbols get u
 CODEGENOPT(SplitMachineFunctions, 1, 0) ///< Split machine functions using 
profile information.
 CODEGENOPT(PPCUseFullRegisterNames, 1, 0) ///< Print full register names in 
assembly
 CODEGENOPT(X86RelaxRelocations, 1, 1) ///< -Wa,-mrelax-relocations={yes,no}
+CODEGENOPT(X86APXRelaxRelocations

[clang] [CIR] Make ZeroAttr use AttrBuilderWithInferredContext (PR #136604)

2025-04-21 Thread Henrich Lauko via cfe-commits

https://github.com/xlauko updated 
https://github.com/llvm/llvm-project/pull/136604

>From a715e75eff27a5b37aca95ef7bbe1c217a1f5463 Mon Sep 17 00:00:00 2001
From: xlauko 
Date: Mon, 21 Apr 2025 21:51:06 +0200
Subject: [PATCH] [CIR] Make ZeroAttr use AttrBuilderWithInferredContext

---
 clang/include/clang/CIR/Dialect/Builder/CIRBaseBuilder.h | 8 ++--
 clang/include/clang/CIR/Dialect/IR/CIRAttrs.td   | 7 +++
 clang/lib/CIR/CodeGen/CIRGenExprConstant.cpp | 2 +-
 3 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/clang/include/clang/CIR/Dialect/Builder/CIRBaseBuilder.h 
b/clang/include/clang/CIR/Dialect/Builder/CIRBaseBuilder.h
index ee8af62ede0da..b303aa07838ee 100644
--- a/clang/include/clang/CIR/Dialect/Builder/CIRBaseBuilder.h
+++ b/clang/include/clang/CIR/Dialect/Builder/CIRBaseBuilder.h
@@ -83,21 +83,17 @@ class CIRBaseBuilderTy : public mlir::OpBuilder {
 return getConstPtrAttr(t, 0);
   }
 
-  mlir::TypedAttr getZeroAttr(mlir::Type t) {
-return cir::ZeroAttr::get(getContext(), t);
-  }
-
   mlir::TypedAttr getZeroInitAttr(mlir::Type ty) {
 if (mlir::isa(ty))
   return cir::IntAttr::get(ty, 0);
 if (cir::isAnyFloatingPointType(ty))
   return cir::FPAttr::getZero(ty);
 if (auto arrTy = mlir::dyn_cast(ty))
-  return getZeroAttr(arrTy);
+  return cir::ZeroAttr::get(arrTy);
 if (auto ptrTy = mlir::dyn_cast(ty))
   return getConstNullPtrAttr(ptrTy);
 if (auto recordTy = mlir::dyn_cast(ty))
-  return getZeroAttr(recordTy);
+  return cir::ZeroAttr::get(recordTy);
 if (mlir::isa(ty)) {
   return getFalseAttr();
 }
diff --git a/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td 
b/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td
index 25ceded7e8a5b..214db1b1caeeb 100644
--- a/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td
+++ b/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td
@@ -71,6 +71,13 @@ def ZeroAttr : CIR_Attr<"Zero", "zero", 
[TypedAttrInterface]> {
   }];
 
   let parameters = (ins AttributeSelfTypeParameter<"">:$type);
+
+  let builders = [
+AttrBuilderWithInferredContext<(ins "mlir::Type":$type), [{
+  return $_get(type.getContext(), type);
+}]>
+  ];
+
   let assemblyFormat = [{}];
 }
 
diff --git a/clang/lib/CIR/CodeGen/CIRGenExprConstant.cpp 
b/clang/lib/CIR/CodeGen/CIRGenExprConstant.cpp
index 0caa8961ed0a6..b9a74e90a5960 100644
--- a/clang/lib/CIR/CodeGen/CIRGenExprConstant.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenExprConstant.cpp
@@ -183,7 +183,7 @@ emitArrayConstant(CIRGenModule &cgm, mlir::Type desiredType,
   }
 
   if (nonzeroLength == 0)
-return cir::ZeroAttr::get(builder.getContext(), desiredType);
+return cir::ZeroAttr::get(desiredType);
 
   const unsigned trailingZeroes = arrayBound - nonzeroLength;
 

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


[clang] [CUDA][HIP] capture possible ODR-used var (PR #136645)

2025-04-21 Thread Yaxun Liu via cfe-commits

https://github.com/yxsamliu created 
https://github.com/llvm/llvm-project/pull/136645

In a lambda function, a call of a function may
resolve to host and device functions with different
signatures. Especially, a constexpr local variable may
be passed by value by the device function and
passed by reference by the host function, which
will cause the constexpr variable captured by
the lambda function in host compilation but
not in the device compilation. The discrepancy
in the lambda captures will violate ODR and
causes UB for kernels using these lambdas.

This PR fixes the issue by identifying
discrepancy of ODR/non-ODR usages of constexpr
local variables passed to host/device functions
and conservatively capture them.

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

>From e614f7c35cb1fb9ca7c57259a66804b15921fa69 Mon Sep 17 00:00:00 2001
From: "Yaxun (Sam) Liu" 
Date: Wed, 16 Apr 2025 11:09:16 -0400
Subject: [PATCH] [CUDA][HIP] capture possible ODR-used var

In a lambda function, a call of a function may
resolve to host and device functions with different
signatures. Especially, a constexpr local variable
may be passed by value by the device function and
passed by reference by the host function, which
will cause the constexpr variable captured by
the lambda function in host compilation but
not in the device compilation. The discrepancy
in the lambda captures will violate ODR and
causes UB for kernels using these lambdas.

This PR fixes the issue by identifying
discrepancy of ODR/non-ODR usages of constexpr
local variables passed to host/device functions
and conservatively capture them.

Fixes: https://github.com/llvm/llvm-project/issues/132068
---
 clang/include/clang/Sema/ScopeInfo.h  |   3 +
 clang/include/clang/Sema/SemaCUDA.h   |   4 +
 clang/lib/Sema/SemaCUDA.cpp   |  47 ++
 clang/lib/Sema/SemaExpr.cpp   |  24 +++-
 clang/lib/Sema/SemaOverload.cpp   |   2 +
 .../CodeGenCUDA/lambda-constexpr-capture.cu   | 135 ++
 6 files changed, 212 insertions(+), 3 deletions(-)
 create mode 100644 clang/test/CodeGenCUDA/lambda-constexpr-capture.cu

diff --git a/clang/include/clang/Sema/ScopeInfo.h 
b/clang/include/clang/Sema/ScopeInfo.h
index 958d65055fa9b..6bf9ae8d074fb 100644
--- a/clang/include/clang/Sema/ScopeInfo.h
+++ b/clang/include/clang/Sema/ScopeInfo.h
@@ -949,6 +949,9 @@ class LambdaScopeInfo final :
 
   SourceLocation PotentialThisCaptureLocation;
 
+  /// Variables that are potentially ODR-used in CUDA/HIP.
+  llvm::SmallPtrSet CUDAPotentialODRUsedVars;
+
   LambdaScopeInfo(DiagnosticsEngine &Diag)
   : CapturingScopeInfo(Diag, ImpCap_None) {
 Kind = SK_Lambda;
diff --git a/clang/include/clang/Sema/SemaCUDA.h 
b/clang/include/clang/Sema/SemaCUDA.h
index 71f05e88fb539..dbc1432860d89 100644
--- a/clang/include/clang/Sema/SemaCUDA.h
+++ b/clang/include/clang/Sema/SemaCUDA.h
@@ -274,6 +274,10 @@ class SemaCUDA : public SemaBase {
   /// parameters specified via <<<>>>.
   std::string getConfigureFuncName() const;
 
+  /// Record variables that are potentially ODR-used in CUDA/HIP.
+  void recordPotentialODRUsedVariable(MultiExprArg Args,
+  OverloadCandidateSet &CandidateSet);
+
 private:
   unsigned ForceHostDeviceDepth = 0;
 
diff --git a/clang/lib/Sema/SemaCUDA.cpp b/clang/lib/Sema/SemaCUDA.cpp
index 0e5fc5e1a40b4..3cee477d5d7ac 100644
--- a/clang/lib/Sema/SemaCUDA.cpp
+++ b/clang/lib/Sema/SemaCUDA.cpp
@@ -18,6 +18,7 @@
 #include "clang/Basic/TargetInfo.h"
 #include "clang/Lex/Preprocessor.h"
 #include "clang/Sema/Lookup.h"
+#include "clang/Sema/Overload.h"
 #include "clang/Sema/ScopeInfo.h"
 #include "clang/Sema/Sema.h"
 #include "clang/Sema/Template.h"
@@ -1100,3 +1101,49 @@ std::string SemaCUDA::getConfigureFuncName() const {
   // Legacy CUDA kernel configuration call
   return "cudaConfigureCall";
 }
+
+// Record any local constexpr variables that are passed one way on the host
+// and another on the device.
+void SemaCUDA::recordPotentialODRUsedVariable(
+MultiExprArg Arguments, OverloadCandidateSet &Candidates) {
+  sema::LambdaScopeInfo *LambdaInfo = SemaRef.getCurLambda();
+  if (!LambdaInfo)
+return;
+
+  for (unsigned I = 0; I < Arguments.size(); ++I) {
+auto *DeclRef = dyn_cast(Arguments[I]);
+if (!DeclRef)
+  continue;
+auto *Variable = dyn_cast(DeclRef->getDecl());
+if (!Variable || !Variable->isLocalVarDecl() || !Variable->isConstexpr())
+  continue;
+
+bool HostByValue = false, HostByRef = false;
+bool DeviceByValue = false, DeviceByRef = false;
+
+for (OverloadCandidate &Candidate : Candidates) {
+  FunctionDecl *Callee = Candidate.Function;
+  if (!Callee || I >= Callee->getNumParams())
+continue;
+
+  CUDAFunctionTarget Target = IdentifyTarget(Callee);
+  if (Target == CUDAFunctionTarget::InvalidTarget ||
+  Target == CUDAFunctionTarget::Global)
+continue;
+
+  bool 

[clang] [CUDA][HIP] capture possible ODR-used var (PR #136645)

2025-04-21 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Yaxun (Sam) Liu (yxsamliu)


Changes

In a lambda function, a call of a function may
resolve to host and device functions with different
signatures. Especially, a constexpr local variable may
be passed by value by the device function and
passed by reference by the host function, which
will cause the constexpr variable captured by
the lambda function in host compilation but
not in the device compilation. The discrepancy
in the lambda captures will violate ODR and
causes UB for kernels using these lambdas.

This PR fixes the issue by identifying
discrepancy of ODR/non-ODR usages of constexpr
local variables passed to host/device functions
and conservatively capture them.

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

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


6 Files Affected:

- (modified) clang/include/clang/Sema/ScopeInfo.h (+3) 
- (modified) clang/include/clang/Sema/SemaCUDA.h (+4) 
- (modified) clang/lib/Sema/SemaCUDA.cpp (+47) 
- (modified) clang/lib/Sema/SemaExpr.cpp (+21-3) 
- (modified) clang/lib/Sema/SemaOverload.cpp (+2) 
- (added) clang/test/CodeGenCUDA/lambda-constexpr-capture.cu (+135) 


``diff
diff --git a/clang/include/clang/Sema/ScopeInfo.h 
b/clang/include/clang/Sema/ScopeInfo.h
index 958d65055fa9b..6bf9ae8d074fb 100644
--- a/clang/include/clang/Sema/ScopeInfo.h
+++ b/clang/include/clang/Sema/ScopeInfo.h
@@ -949,6 +949,9 @@ class LambdaScopeInfo final :
 
   SourceLocation PotentialThisCaptureLocation;
 
+  /// Variables that are potentially ODR-used in CUDA/HIP.
+  llvm::SmallPtrSet CUDAPotentialODRUsedVars;
+
   LambdaScopeInfo(DiagnosticsEngine &Diag)
   : CapturingScopeInfo(Diag, ImpCap_None) {
 Kind = SK_Lambda;
diff --git a/clang/include/clang/Sema/SemaCUDA.h 
b/clang/include/clang/Sema/SemaCUDA.h
index 71f05e88fb539..dbc1432860d89 100644
--- a/clang/include/clang/Sema/SemaCUDA.h
+++ b/clang/include/clang/Sema/SemaCUDA.h
@@ -274,6 +274,10 @@ class SemaCUDA : public SemaBase {
   /// parameters specified via <<<>>>.
   std::string getConfigureFuncName() const;
 
+  /// Record variables that are potentially ODR-used in CUDA/HIP.
+  void recordPotentialODRUsedVariable(MultiExprArg Args,
+  OverloadCandidateSet &CandidateSet);
+
 private:
   unsigned ForceHostDeviceDepth = 0;
 
diff --git a/clang/lib/Sema/SemaCUDA.cpp b/clang/lib/Sema/SemaCUDA.cpp
index 0e5fc5e1a40b4..3cee477d5d7ac 100644
--- a/clang/lib/Sema/SemaCUDA.cpp
+++ b/clang/lib/Sema/SemaCUDA.cpp
@@ -18,6 +18,7 @@
 #include "clang/Basic/TargetInfo.h"
 #include "clang/Lex/Preprocessor.h"
 #include "clang/Sema/Lookup.h"
+#include "clang/Sema/Overload.h"
 #include "clang/Sema/ScopeInfo.h"
 #include "clang/Sema/Sema.h"
 #include "clang/Sema/Template.h"
@@ -1100,3 +1101,49 @@ std::string SemaCUDA::getConfigureFuncName() const {
   // Legacy CUDA kernel configuration call
   return "cudaConfigureCall";
 }
+
+// Record any local constexpr variables that are passed one way on the host
+// and another on the device.
+void SemaCUDA::recordPotentialODRUsedVariable(
+MultiExprArg Arguments, OverloadCandidateSet &Candidates) {
+  sema::LambdaScopeInfo *LambdaInfo = SemaRef.getCurLambda();
+  if (!LambdaInfo)
+return;
+
+  for (unsigned I = 0; I < Arguments.size(); ++I) {
+auto *DeclRef = dyn_cast(Arguments[I]);
+if (!DeclRef)
+  continue;
+auto *Variable = dyn_cast(DeclRef->getDecl());
+if (!Variable || !Variable->isLocalVarDecl() || !Variable->isConstexpr())
+  continue;
+
+bool HostByValue = false, HostByRef = false;
+bool DeviceByValue = false, DeviceByRef = false;
+
+for (OverloadCandidate &Candidate : Candidates) {
+  FunctionDecl *Callee = Candidate.Function;
+  if (!Callee || I >= Callee->getNumParams())
+continue;
+
+  CUDAFunctionTarget Target = IdentifyTarget(Callee);
+  if (Target == CUDAFunctionTarget::InvalidTarget ||
+  Target == CUDAFunctionTarget::Global)
+continue;
+
+  bool CoversHost = (Target == CUDAFunctionTarget::Host ||
+ Target == CUDAFunctionTarget::HostDevice);
+  bool CoversDevice = (Target == CUDAFunctionTarget::Device ||
+   Target == CUDAFunctionTarget::HostDevice);
+
+  bool IsRef = Callee->getParamDecl(I)->getType()->isReferenceType();
+  if (CoversHost)
+IsRef ? HostByRef = true : HostByValue = true;
+  if (CoversDevice)
+IsRef ? DeviceByRef = true : DeviceByValue = true;
+}
+
+if ((HostByValue && DeviceByRef) || (HostByRef && DeviceByValue))
+  LambdaInfo->CUDAPotentialODRUsedVars.insert(Variable);
+  }
+}
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 01a021443c94f..b20dbb544f94a 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -19516,11 +19516,29 @@ static ExprResult 
rebuildPotentialResultsAsNonOdrUsed(Sema &S, Expr *E,

[clang] [clang] Define convergence in C++ languages such as HIP, CUDA, OpenCL (PR #136280)

2025-04-21 Thread Sameer Sahasrabuddhe via cfe-commits

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


[clang-tools-extra] [clang-tidy] Avoid diagnosing std::array initializations for modernize-use-designated-initializers (PR #134774)

2025-04-21 Thread David Rivera via cfe-commits


@@ -122,7 +122,10 @@ void 
UseDesignatedInitializersCheck::registerMatchers(MatchFinder *Finder) {
   Finder->addMatcher(
   initListExpr(
   hasType(cxxRecordDecl(RestrictToPODTypes ? isPOD() : isAggregate(),
-unless(HasBaseWithFields))
+unless(anyOf(HasBaseWithFields,
+ IgnoreSingleElementAggregates
+ ? hasName("::std::array")

RiverDave wrote:

Thanks for clearing out my confusion!. Should be fixed now. 

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


[clang-tools-extra] [clang-tidy] Avoid diagnosing std::array initializations for modernize-use-designated-initializers (PR #134774)

2025-04-21 Thread David Rivera via cfe-commits


@@ -182,6 +182,11 @@ Changes in existing checks
   ``constexpr`` and ``static``` values on member initialization and by 
detecting
   explicit casting of built-in types within member list initialization.
 
+- Improved :doc:`modernize-use-designated-initializers
+  ` check by avoiding
+  diagnosing designated initializers for ``std::array`` initializations when

RiverDave wrote:

Done 

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


[clang-tools-extra] [clang-tidy] Avoid diagnosing std::array initializations for modernize-use-designated-initializers (PR #134774)

2025-04-21 Thread David Rivera via cfe-commits

https://github.com/RiverDave updated 
https://github.com/llvm/llvm-project/pull/134774

>From 5dc7aa51c52b2fd31c182af964152765bed72ec7 Mon Sep 17 00:00:00 2001
From: David Rivera 
Date: Mon, 7 Apr 2025 23:21:50 -0400
Subject: [PATCH] [clang-tidy] Avoid diagnosing std::array initializations for
 modernize-use-designated-initializers

---
 .../modernize/UseDesignatedInitializersCheck.cpp  |  5 +++--
 clang-tools-extra/docs/ReleaseNotes.rst   |  4 
 .../modernize/use-designated-initializers.rst |  3 +++
 .../modernize/use-designated-initializers.cpp | 15 +++
 4 files changed, 25 insertions(+), 2 deletions(-)

diff --git 
a/clang-tools-extra/clang-tidy/modernize/UseDesignatedInitializersCheck.cpp 
b/clang-tools-extra/clang-tidy/modernize/UseDesignatedInitializersCheck.cpp
index 3132067f3d5ec..7ea9676b13ec0 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseDesignatedInitializersCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/UseDesignatedInitializersCheck.cpp
@@ -121,8 +121,9 @@ void 
UseDesignatedInitializersCheck::registerMatchers(MatchFinder *Finder) {
   hasAnyBase(hasType(cxxRecordDecl(has(fieldDecl();
   Finder->addMatcher(
   initListExpr(
-  hasType(cxxRecordDecl(RestrictToPODTypes ? isPOD() : isAggregate(),
-unless(HasBaseWithFields))
+  hasType(cxxRecordDecl(
+  RestrictToPODTypes ? isPOD() : isAggregate(),
+  unless(anyOf(HasBaseWithFields, 
hasName("::std::array"
   .bind("type")),
   IgnoreSingleElementAggregates ? hasMoreThanOneElement() : anything(),
   unless(isFullyDesignated()))
diff --git a/clang-tools-extra/docs/ReleaseNotes.rst 
b/clang-tools-extra/docs/ReleaseNotes.rst
index 761c1d3a80359..ba3774307e392 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -182,6 +182,10 @@ Changes in existing checks
   ``constexpr`` and ``static``` values on member initialization and by 
detecting
   explicit casting of built-in types within member list initialization.
 
+- Improved :doc:`modernize-use-designated-initializers
+  ` check by avoiding
+  diagnosing designated initializers for ``std::array`` initializations.
+
 - Improved :doc:`modernize-use-ranges
   ` check by updating suppress 
   warnings logic for ``nullptr`` in ``std::find``.
diff --git 
a/clang-tools-extra/docs/clang-tidy/checks/modernize/use-designated-initializers.rst
 
b/clang-tools-extra/docs/clang-tidy/checks/modernize/use-designated-initializers.rst
index f101cfc6f3a2b..62ea906d7a029 100644
--- 
a/clang-tools-extra/docs/clang-tidy/checks/modernize/use-designated-initializers.rst
+++ 
b/clang-tools-extra/docs/clang-tidy/checks/modernize/use-designated-initializers.rst
@@ -54,6 +54,9 @@ Options
 
 The value `false` specifies that even initializers for aggregate types with
 only a single element should be checked. The default value is `true`.
+``std::array`` initializations are always excluded, as the type is a
+standard library abstraction and not intended to be initialized with
+designated initializers.
 
 .. option:: RestrictToPODTypes
 
diff --git 
a/clang-tools-extra/test/clang-tidy/checkers/modernize/use-designated-initializers.cpp
 
b/clang-tools-extra/test/clang-tidy/checkers/modernize/use-designated-initializers.cpp
index 048665b2e54ac..cdadeed5bd850 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/modernize/use-designated-initializers.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/modernize/use-designated-initializers.cpp
@@ -209,3 +209,18 @@ struct S15{
   S15(S14& d):d{d}{}
   S14& d;
 };
+
+//Issue #133715
+namespace std {
+  template
+  struct array {
+T __elems[N];
+  };
+template
+array(T, U...) -> array;
+}
+
+std::array a{1,2,3};
+std::array b{10, 11};
+using array = std::array;
+array c{10, 11};

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


[clang-tools-extra] [clang-tidy] Avoid diagnosing std::array initializations for modernize-use-designated-initializers (PR #134774)

2025-04-21 Thread David Rivera via cfe-commits

RiverDave wrote:

> Please add a unit test demonstrating that the related issue is fixed.

Added 👍

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


[clang-tools-extra] [clang-tidy] Avoid diagnosing std::array initializations for modernize-use-designated-initializers (PR #134774)

2025-04-21 Thread David Rivera via cfe-commits

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


[clang] [clang] Fix UEFI Target info (PR #127290)

2025-04-21 Thread Petr Hosek via cfe-commits


@@ -3038,8 +3038,30 @@ static Address EmitX86_64VAArgFromMemory(CodeGenFunction 
&CGF,
   return Address(Res, LTy, Align);
 }
 
+static RValue EmitMSABIVAArg(CodeGenFunction &CGF, Address VAListAddr,
+ QualType Ty, AggValueSlot Slot,
+ ASTContext &context) {
+  // MS x64 ABI requirement: "Any argument that doesn't fit in 8 bytes, or is
+  // not 1, 2, 4, or 8 bytes, must be passed by reference."
+  uint64_t Width = context.getTypeSize(Ty);
+  bool IsIndirect = Width > 64 || !llvm::isPowerOf2_64(Width);
+
+  return emitVoidPtrVAArg(CGF, VAListAddr, Ty, IsIndirect,
+  CGF.getContext().getTypeInfoInChars(Ty),
+  CharUnits::fromQuantity(8),
+  /*allowHigherAlign*/ false, Slot);
+}
+
 RValue X86_64ABIInfo::EmitVAArg(CodeGenFunction &CGF, Address VAListAddr,
 QualType Ty, AggValueSlot Slot) const {
+
+  // Emit MS ABI compliant va_list for X86_64 targets which use Microsoft CXX
+  // ABI and CharPtrBuiltinVaList.
+  if (CGF.getTarget().getCXXABI().isMicrosoft() &&
+  CGF.getTarget().getBuiltinVaListKind() ==
+  clang::TargetInfo::CharPtrBuiltinVaList)
+return EmitMSABIVAArg(CGF, VAListAddr, Ty, Slot, getContext());

petrhosek wrote:

Wouldn't it be cleaner and safer to use `WinX86_64ABIInfo` (and 
`WinX86_64TargetCodeGenInfo`) for UEFI?

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


[clang-tools-extra] [clang-doc] Fix clang-tidy naming diagnostics (PR #136444)

2025-04-21 Thread Petr Hosek via cfe-commits

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


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


[clang] [llvm] [RISCV] Add smcntrpmf extension (PR #136556)

2025-04-21 Thread Liao Chunyu via cfe-commits

https://github.com/ChunyuLiao updated 
https://github.com/llvm/llvm-project/pull/136556

>From 43e266b5a8f51ecd79df3156b20b48762699afd4 Mon Sep 17 00:00:00 2001
From: Liao Chunyu 
Date: Mon, 21 Apr 2025 04:18:56 -0400
Subject: [PATCH] [RISCV] Add smcntrpmf extension

spec: https://github.com/riscvarchive/riscv-smcntrpmf
---
 .../Driver/print-supported-extensions-riscv.c |  1 +
 .../test/Preprocessor/riscv-target-features.c |  9 +++
 llvm/docs/RISCVUsage.rst  |  1 +
 llvm/lib/Target/RISCV/RISCVFeatures.td|  3 +++
 llvm/lib/Target/RISCV/RISCVSystemOperands.td  | 10 
 llvm/test/CodeGen/RISCV/attributes.ll |  4 
 llvm/test/CodeGen/RISCV/features-info.ll  |  1 +
 llvm/test/MC/RISCV/attribute-arch.s   |  3 +++
 llvm/test/MC/RISCV/machine-csr-names.s| 24 +++
 llvm/test/MC/RISCV/rv32-machine-csr-names.s   | 24 +++
 .../TargetParser/RISCVISAInfoTest.cpp |  1 +
 11 files changed, 81 insertions(+)

diff --git a/clang/test/Driver/print-supported-extensions-riscv.c 
b/clang/test/Driver/print-supported-extensions-riscv.c
index 39002d7b4780a..1f83910969221 100644
--- a/clang/test/Driver/print-supported-extensions-riscv.c
+++ b/clang/test/Driver/print-supported-extensions-riscv.c
@@ -123,6 +123,7 @@
 // CHECK-NEXT: shvstvecd1.0   'Shvstvecd' (vstvec supports 
Direct mode)
 // CHECK-NEXT: smaia1.0   'Smaia' (Advanced Interrupt 
Architecture Machine Level)
 // CHECK-NEXT: smcdeleg 1.0   'Smcdeleg' (Counter 
Delegation Machine Level)
+// CHECK-NEXT: smcntrpmf1.0   'Smcntrpmf' (Cycle and 
Instret Privilege Mode Filtering)
 // CHECK-NEXT: smcsrind 1.0   'Smcsrind' (Indirect CSR 
Access Machine Level)
 // CHECK-NEXT: smdbltrp 1.0   'Smdbltrp' (Double Trap 
Machine Level)
 // CHECK-NEXT: smepmp   1.0   'Smepmp' (Enhanced Physical 
Memory Protection)
diff --git a/clang/test/Preprocessor/riscv-target-features.c 
b/clang/test/Preprocessor/riscv-target-features.c
index 253e42419f453..03c291afe19bd 100644
--- a/clang/test/Preprocessor/riscv-target-features.c
+++ b/clang/test/Preprocessor/riscv-target-features.c
@@ -29,6 +29,7 @@
 // CHECK-NOT: __riscv_shvstvecd {{.*$}}
 // CHECK-NOT: __riscv_smaia {{.*$}}
 // CHECK-NOT: __riscv_smcdeleg {{.*$}}
+// CHECK-NOT: __riscv_smcntrpmf {{.*$}}
 // CHECK-NOT: __riscv_smcsrind {{.*$}}
 // CHECK-NOT: __riscv_smdbltrp {{.*$}}
 // CHECK-NOT: __riscv_smepmp {{.*$}}
@@ -1445,6 +1446,14 @@
 // RUN:   -o - | FileCheck --check-prefix=CHECK-SSAIA-EXT %s
 // CHECK-SSAIA-EXT: __riscv_ssaia  100{{$}}
 
+// RUN: %clang --target=riscv32 \
+// RUN:   -march=rv32ismcntrpmf1p0 -E -dM %s \
+// RUN:   -o - | FileCheck --check-prefix=CHECK-SMCNTRPMF-EXT %s
+// RUN: %clang --target=riscv64 \
+// RUN:   -march=rv64ismcntrpmf1p0 -E -dM %s \
+// RUN:   -o - | FileCheck --check-prefix=CHECK-SMCNTRPMF-EXT %s
+// CHECK-SMCNTRPMF-EXT: __riscv_smcntrpmf  100{{$}}
+
 // RUN: %clang --target=riscv32 \
 // RUN:   -march=rv32ismcsrind1p0 -E -dM %s \
 // RUN:   -o - | FileCheck --check-prefix=CHECK-SMCSRIND-EXT %s
diff --git a/llvm/docs/RISCVUsage.rst b/llvm/docs/RISCVUsage.rst
index 137b537f00ea0..1ebe7b57abd7d 100644
--- a/llvm/docs/RISCVUsage.rst
+++ b/llvm/docs/RISCVUsage.rst
@@ -128,6 +128,7 @@ on support follow.
  ``Shvstvecd`` Assembly Support (`See note 
<#riscv-profiles-extensions-note>`__)
  ``Smaia`` Supported
  ``Smcdeleg``  Supported
+ ``Smcntrpmf`` Supported
  ``Smcsrind``  Supported
  ``Smdbltrp``  Supported
  ``Smepmp``Supported
diff --git a/llvm/lib/Target/RISCV/RISCVFeatures.td 
b/llvm/lib/Target/RISCV/RISCVFeatures.td
index f51fcf82077f4..87cab1dafc75b 100644
--- a/llvm/lib/Target/RISCV/RISCVFeatures.td
+++ b/llvm/lib/Target/RISCV/RISCVFeatures.td
@@ -899,6 +899,9 @@ def FeatureStdExtSsaia
 : RISCVExtension<1, 0,
  "Advanced Interrupt Architecture Supervisor Level">;
 
+def FeatureStdExtSmcntrpmf
+: RISCVExtension<1, 0, "Cycle and Instret Privilege Mode Filtering">;
+
 def FeatureStdExtSmcsrind
 : RISCVExtension<1, 0, "Indirect CSR Access Machine Level">;
 def FeatureStdExtSscsrind
diff --git a/llvm/lib/Target/RISCV/RISCVSystemOperands.td 
b/llvm/lib/Target/RISCV/RISCVSystemOperands.td
index 23388c7575e86..79ec8134733e8 100644
--- a/llvm/lib/Target/RISCV/RISCVSystemOperands.td
+++ b/llvm/lib/Target/RISCV/RISCVSystemOperands.td
@@ -482,6 +482,16 @@ def : SysReg<"sctrdepth", 0x15f>;
 def : SysReg<"vsctrctl", 0x24e>;
 def : SysReg<"mctrctl", 0x34e>;
 
+//===---
+// Cycle and Instret Privilege Mode Filtering (Smcntrpmf)
+//===---
+def : SysReg<"mcyclecfg", 0x321>;
+def : SysReg<"minstretcfg", 0x322>;
+let isRV32Only = 1 in {
+def : SysReg<"mcyclecfgh", 0x721>;
+def : SysRe

[clang] 9e26c79 - [RISCV] Add smcntrpmf extension (#136556)

2025-04-21 Thread via cfe-commits

Author: Liao Chunyu
Date: 2025-04-22T12:34:39+08:00
New Revision: 9e26c797ae9699fba8bd62af99ab3ad6f9b16462

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

LOG: [RISCV] Add smcntrpmf extension (#136556)

spec: https://github.com/riscvarchive/riscv-smcntrpmf

Added: 


Modified: 
clang/test/Driver/print-supported-extensions-riscv.c
clang/test/Preprocessor/riscv-target-features.c
llvm/docs/RISCVUsage.rst
llvm/lib/Target/RISCV/RISCVFeatures.td
llvm/lib/Target/RISCV/RISCVSystemOperands.td
llvm/test/CodeGen/RISCV/attributes.ll
llvm/test/CodeGen/RISCV/features-info.ll
llvm/test/MC/RISCV/attribute-arch.s
llvm/test/MC/RISCV/machine-csr-names.s
llvm/test/MC/RISCV/rv32-machine-csr-names.s
llvm/unittests/TargetParser/RISCVISAInfoTest.cpp

Removed: 




diff  --git a/clang/test/Driver/print-supported-extensions-riscv.c 
b/clang/test/Driver/print-supported-extensions-riscv.c
index 39002d7b4780a..1f83910969221 100644
--- a/clang/test/Driver/print-supported-extensions-riscv.c
+++ b/clang/test/Driver/print-supported-extensions-riscv.c
@@ -123,6 +123,7 @@
 // CHECK-NEXT: shvstvecd1.0   'Shvstvecd' (vstvec supports 
Direct mode)
 // CHECK-NEXT: smaia1.0   'Smaia' (Advanced Interrupt 
Architecture Machine Level)
 // CHECK-NEXT: smcdeleg 1.0   'Smcdeleg' (Counter 
Delegation Machine Level)
+// CHECK-NEXT: smcntrpmf1.0   'Smcntrpmf' (Cycle and 
Instret Privilege Mode Filtering)
 // CHECK-NEXT: smcsrind 1.0   'Smcsrind' (Indirect CSR 
Access Machine Level)
 // CHECK-NEXT: smdbltrp 1.0   'Smdbltrp' (Double Trap 
Machine Level)
 // CHECK-NEXT: smepmp   1.0   'Smepmp' (Enhanced Physical 
Memory Protection)

diff  --git a/clang/test/Preprocessor/riscv-target-features.c 
b/clang/test/Preprocessor/riscv-target-features.c
index 253e42419f453..03c291afe19bd 100644
--- a/clang/test/Preprocessor/riscv-target-features.c
+++ b/clang/test/Preprocessor/riscv-target-features.c
@@ -29,6 +29,7 @@
 // CHECK-NOT: __riscv_shvstvecd {{.*$}}
 // CHECK-NOT: __riscv_smaia {{.*$}}
 // CHECK-NOT: __riscv_smcdeleg {{.*$}}
+// CHECK-NOT: __riscv_smcntrpmf {{.*$}}
 // CHECK-NOT: __riscv_smcsrind {{.*$}}
 // CHECK-NOT: __riscv_smdbltrp {{.*$}}
 // CHECK-NOT: __riscv_smepmp {{.*$}}
@@ -1445,6 +1446,14 @@
 // RUN:   -o - | FileCheck --check-prefix=CHECK-SSAIA-EXT %s
 // CHECK-SSAIA-EXT: __riscv_ssaia  100{{$}}
 
+// RUN: %clang --target=riscv32 \
+// RUN:   -march=rv32ismcntrpmf1p0 -E -dM %s \
+// RUN:   -o - | FileCheck --check-prefix=CHECK-SMCNTRPMF-EXT %s
+// RUN: %clang --target=riscv64 \
+// RUN:   -march=rv64ismcntrpmf1p0 -E -dM %s \
+// RUN:   -o - | FileCheck --check-prefix=CHECK-SMCNTRPMF-EXT %s
+// CHECK-SMCNTRPMF-EXT: __riscv_smcntrpmf  100{{$}}
+
 // RUN: %clang --target=riscv32 \
 // RUN:   -march=rv32ismcsrind1p0 -E -dM %s \
 // RUN:   -o - | FileCheck --check-prefix=CHECK-SMCSRIND-EXT %s

diff  --git a/llvm/docs/RISCVUsage.rst b/llvm/docs/RISCVUsage.rst
index 137b537f00ea0..1ebe7b57abd7d 100644
--- a/llvm/docs/RISCVUsage.rst
+++ b/llvm/docs/RISCVUsage.rst
@@ -128,6 +128,7 @@ on support follow.
  ``Shvstvecd`` Assembly Support (`See note 
<#riscv-profiles-extensions-note>`__)
  ``Smaia`` Supported
  ``Smcdeleg``  Supported
+ ``Smcntrpmf`` Supported
  ``Smcsrind``  Supported
  ``Smdbltrp``  Supported
  ``Smepmp``Supported

diff  --git a/llvm/lib/Target/RISCV/RISCVFeatures.td 
b/llvm/lib/Target/RISCV/RISCVFeatures.td
index f51fcf82077f4..87cab1dafc75b 100644
--- a/llvm/lib/Target/RISCV/RISCVFeatures.td
+++ b/llvm/lib/Target/RISCV/RISCVFeatures.td
@@ -899,6 +899,9 @@ def FeatureStdExtSsaia
 : RISCVExtension<1, 0,
  "Advanced Interrupt Architecture Supervisor Level">;
 
+def FeatureStdExtSmcntrpmf
+: RISCVExtension<1, 0, "Cycle and Instret Privilege Mode Filtering">;
+
 def FeatureStdExtSmcsrind
 : RISCVExtension<1, 0, "Indirect CSR Access Machine Level">;
 def FeatureStdExtSscsrind

diff  --git a/llvm/lib/Target/RISCV/RISCVSystemOperands.td 
b/llvm/lib/Target/RISCV/RISCVSystemOperands.td
index 23388c7575e86..79ec8134733e8 100644
--- a/llvm/lib/Target/RISCV/RISCVSystemOperands.td
+++ b/llvm/lib/Target/RISCV/RISCVSystemOperands.td
@@ -482,6 +482,16 @@ def : SysReg<"sctrdepth", 0x15f>;
 def : SysReg<"vsctrctl", 0x24e>;
 def : SysReg<"mctrctl", 0x34e>;
 
+//===---
+// Cycle and Instret Privilege Mode Filtering (Smcntrpmf)
+//===---
+def : SysReg<"mcyclecfg", 0x321>;
+def : SysReg<"minstretcfg", 0x322>;
+let isRV32Only = 1 in {
+def : SysReg<"mcyclecfgh",

[clang] [llvm] [RISCV] Add smcntrpmf extension (PR #136556)

2025-04-21 Thread Liao Chunyu via cfe-commits

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


[clang] [Clang] Improve error recovery for invalid calls (PR #136295)

2025-04-21 Thread Matheus Izvekov via cfe-commits


@@ -34,21 +34,22 @@ void test_invalid_call_1(int s) {
 
 int some_func2(int a, int b);
 void test_invalid_call_2() {
-  // CHECK:   -RecoveryExpr {{.*}} 'int' contains-errors
+  // CHECK:   -RecoveryExpr {{.*}} '' contains-errors

mizvekov wrote:

Okay, since this is a messy pre-existing problem, let's go ahead, hopefully the 
error recovery improvements can continue at some point.

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


[clang] [llvm] [RISCV] Add smcntrpmf extension (PR #136556)

2025-04-21 Thread Craig Topper via cfe-commits


@@ -480,3 +480,51 @@ csrrs t2, 0xC1E, zero
 csrrs t1, hpmcounter31, zero
 # uimm12
 csrrs t2, 0xC1F, zero
+
+# mcyclecfg

topperc wrote:

This is user-csr-names.s, but these are M-mode CSRs so they should be in 
machine-csr-names.s 

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


[clang] [OpenACC][CIR] Lower 'num_workers' for parallel/kernels (PR #136578)

2025-04-21 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Erich Keane (erichkeane)


Changes

This patch also includes the first one to handle 'device_type' properly, which 
is where most of the 'challenge' here comes from.

>From the best I can tell: we must keep two lists of the same size, 1 of all of 
>the 'num_workers' items, and 1 of the 'device_type' value for that 
>'num_workers'.  Additionally, the 'device_type' list can only handle single 
>'device_type' values, so we have to duplicate the 'num_workers' items in cases 
>where there are multiple applicable 'device_type' values.

This patch accomplishes this by keeping the two in sync, and saving the current 
'device_type' in the visitor.

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


3 Files Affected:

- (modified) clang/lib/CIR/CodeGen/CIRGenStmtOpenACC.cpp (+63) 
- (modified) clang/test/CIR/CodeGenOpenACC/kernels.c (+52) 
- (modified) clang/test/CIR/CodeGenOpenACC/parallel.c (+52) 


``diff
diff --git a/clang/lib/CIR/CodeGen/CIRGenStmtOpenACC.cpp 
b/clang/lib/CIR/CodeGen/CIRGenStmtOpenACC.cpp
index 30e840cbfa1f7..c7b5c3348e77d 100644
--- a/clang/lib/CIR/CodeGen/CIRGenStmtOpenACC.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenStmtOpenACC.cpp
@@ -46,10 +46,27 @@ class OpenACCClauseCIREmitter final
   // diagnostics are gone.
   SourceLocation dirLoc;
 
+  const OpenACCDeviceTypeClause *lastDeviceTypeClause = nullptr;
+
   void clauseNotImplemented(const OpenACCClause &c) {
 cgf.cgm.errorNYI(c.getSourceRange(), "OpenACC Clause", c.getClauseKind());
   }
 
+  mlir::Value createIntExpr(const Expr *intExpr) {
+mlir::Value expr = cgf.emitScalarExpr(intExpr);
+mlir::Location exprLoc = cgf.cgm.getLoc(intExpr->getBeginLoc());
+
+mlir::IntegerType targetType = mlir::IntegerType::get(
+&cgf.getMLIRContext(), 
cgf.getContext().getIntWidth(intExpr->getType()),
+intExpr->getType()->isSignedIntegerOrEnumerationType()
+? mlir::IntegerType::SignednessSemantics::Signed
+: mlir::IntegerType::SignednessSemantics::Unsigned);
+
+auto conversionOp = builder.create(
+exprLoc, targetType, expr);
+return conversionOp.getResult(0);
+  }
+
   // 'condition' as an OpenACC grammar production is used for 'if' and (some
   // variants of) 'self'.  It needs to be emitted as a signless-1-bit value, so
   // this function emits the expression, then sets the unrealized conversion
@@ -109,6 +126,7 @@ class OpenACCClauseCIREmitter final
   }
 
   void VisitDeviceTypeClause(const OpenACCDeviceTypeClause &clause) {
+lastDeviceTypeClause = &clause;
 if constexpr (isOneOfTypes) {
   llvm::SmallVector deviceTypes;
   std::optional existingDeviceTypes =
@@ -136,6 +154,51 @@ class OpenACCClauseCIREmitter final
   if (!clause.getArchitectures().empty())
 operation.setDeviceType(
 
decodeDeviceType(clause.getArchitectures()[0].getIdentifierInfo()));
+} else if constexpr (isOneOfTypes) {
+  // Nothing to do here, these constructs don't have any IR for these, as
+  // they just modify the other clauses IR.  So setting of `lastDeviceType`
+  // (done above) is all we need.
+} else {
+  return clauseNotImplemented(clause);
+}
+  }
+
+  void VisitNumWorkersClause(const OpenACCNumWorkersClause &clause) {
+if constexpr (isOneOfTypes) {
+  // Collect the 'existing' device-type attributes so we can re-create them
+  // and insert them.
+  llvm::SmallVector deviceTypes;
+  mlir::ArrayAttr existingDeviceTypes =
+  operation.getNumWorkersDeviceTypeAttr();
+
+  if (existingDeviceTypes) {
+for (const mlir::Attribute &Attr : existingDeviceTypes)
+  deviceTypes.push_back(mlir::acc::DeviceTypeAttr::get(
+  builder.getContext(),
+  cast(Attr).getValue()));
+  }
+
+  // Insert 1 version of the 'int-expr' to the NumWorkers list per-current
+  // device type.
+  mlir::Value intExpr = createIntExpr(clause.getIntExpr());
+  if (lastDeviceTypeClause) {
+for (const DeviceTypeArgument &arg :
+ lastDeviceTypeClause->getArchitectures()) {
+  deviceTypes.push_back(mlir::acc::DeviceTypeAttr::get(
+  builder.getContext(), 
decodeDeviceType(arg.getIdentifierInfo(;
+  operation.getNumWorkersMutable().append(intExpr);
+}
+  } else {
+// Else, we just add a single for 'none'.
+deviceTypes.push_back(mlir::acc::DeviceTypeAttr::get(
+builder.getContext(), mlir::acc::DeviceType::None));
+operation.getNumWorkersMutable().append(intExpr);
+  }
+
+  operation.setNumWorkersDeviceTypeAttr(
+  mlir::ArrayAttr::get(builder.getContext(), deviceTypes));
+} else if constexpr (isOneOfTypes) {
+  llvm_unreachable("num_workers not valid on serial");
 } else {
   return clauseNotImplemented(clause);
 }
diff --git a/clang/test/CIR/CodeGenOpenACC/kernels.c 
b/clang

[clang] [OpenACC][CIR] Lower 'num_workers' for parallel/kernels (PR #136578)

2025-04-21 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clangir

Author: Erich Keane (erichkeane)


Changes

This patch also includes the first one to handle 'device_type' properly, which 
is where most of the 'challenge' here comes from.

>From the best I can tell: we must keep two lists of the same size, 1 of all of 
>the 'num_workers' items, and 1 of the 'device_type' value for that 
>'num_workers'.  Additionally, the 'device_type' list can only handle single 
>'device_type' values, so we have to duplicate the 'num_workers' items in cases 
>where there are multiple applicable 'device_type' values.

This patch accomplishes this by keeping the two in sync, and saving the current 
'device_type' in the visitor.

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


3 Files Affected:

- (modified) clang/lib/CIR/CodeGen/CIRGenStmtOpenACC.cpp (+63) 
- (modified) clang/test/CIR/CodeGenOpenACC/kernels.c (+52) 
- (modified) clang/test/CIR/CodeGenOpenACC/parallel.c (+52) 


``diff
diff --git a/clang/lib/CIR/CodeGen/CIRGenStmtOpenACC.cpp 
b/clang/lib/CIR/CodeGen/CIRGenStmtOpenACC.cpp
index 30e840cbfa1f7..c7b5c3348e77d 100644
--- a/clang/lib/CIR/CodeGen/CIRGenStmtOpenACC.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenStmtOpenACC.cpp
@@ -46,10 +46,27 @@ class OpenACCClauseCIREmitter final
   // diagnostics are gone.
   SourceLocation dirLoc;
 
+  const OpenACCDeviceTypeClause *lastDeviceTypeClause = nullptr;
+
   void clauseNotImplemented(const OpenACCClause &c) {
 cgf.cgm.errorNYI(c.getSourceRange(), "OpenACC Clause", c.getClauseKind());
   }
 
+  mlir::Value createIntExpr(const Expr *intExpr) {
+mlir::Value expr = cgf.emitScalarExpr(intExpr);
+mlir::Location exprLoc = cgf.cgm.getLoc(intExpr->getBeginLoc());
+
+mlir::IntegerType targetType = mlir::IntegerType::get(
+&cgf.getMLIRContext(), 
cgf.getContext().getIntWidth(intExpr->getType()),
+intExpr->getType()->isSignedIntegerOrEnumerationType()
+? mlir::IntegerType::SignednessSemantics::Signed
+: mlir::IntegerType::SignednessSemantics::Unsigned);
+
+auto conversionOp = builder.create(
+exprLoc, targetType, expr);
+return conversionOp.getResult(0);
+  }
+
   // 'condition' as an OpenACC grammar production is used for 'if' and (some
   // variants of) 'self'.  It needs to be emitted as a signless-1-bit value, so
   // this function emits the expression, then sets the unrealized conversion
@@ -109,6 +126,7 @@ class OpenACCClauseCIREmitter final
   }
 
   void VisitDeviceTypeClause(const OpenACCDeviceTypeClause &clause) {
+lastDeviceTypeClause = &clause;
 if constexpr (isOneOfTypes) {
   llvm::SmallVector deviceTypes;
   std::optional existingDeviceTypes =
@@ -136,6 +154,51 @@ class OpenACCClauseCIREmitter final
   if (!clause.getArchitectures().empty())
 operation.setDeviceType(
 
decodeDeviceType(clause.getArchitectures()[0].getIdentifierInfo()));
+} else if constexpr (isOneOfTypes) {
+  // Nothing to do here, these constructs don't have any IR for these, as
+  // they just modify the other clauses IR.  So setting of `lastDeviceType`
+  // (done above) is all we need.
+} else {
+  return clauseNotImplemented(clause);
+}
+  }
+
+  void VisitNumWorkersClause(const OpenACCNumWorkersClause &clause) {
+if constexpr (isOneOfTypes) {
+  // Collect the 'existing' device-type attributes so we can re-create them
+  // and insert them.
+  llvm::SmallVector deviceTypes;
+  mlir::ArrayAttr existingDeviceTypes =
+  operation.getNumWorkersDeviceTypeAttr();
+
+  if (existingDeviceTypes) {
+for (const mlir::Attribute &Attr : existingDeviceTypes)
+  deviceTypes.push_back(mlir::acc::DeviceTypeAttr::get(
+  builder.getContext(),
+  cast(Attr).getValue()));
+  }
+
+  // Insert 1 version of the 'int-expr' to the NumWorkers list per-current
+  // device type.
+  mlir::Value intExpr = createIntExpr(clause.getIntExpr());
+  if (lastDeviceTypeClause) {
+for (const DeviceTypeArgument &arg :
+ lastDeviceTypeClause->getArchitectures()) {
+  deviceTypes.push_back(mlir::acc::DeviceTypeAttr::get(
+  builder.getContext(), 
decodeDeviceType(arg.getIdentifierInfo(;
+  operation.getNumWorkersMutable().append(intExpr);
+}
+  } else {
+// Else, we just add a single for 'none'.
+deviceTypes.push_back(mlir::acc::DeviceTypeAttr::get(
+builder.getContext(), mlir::acc::DeviceType::None));
+operation.getNumWorkersMutable().append(intExpr);
+  }
+
+  operation.setNumWorkersDeviceTypeAttr(
+  mlir::ArrayAttr::get(builder.getContext(), deviceTypes));
+} else if constexpr (isOneOfTypes) {
+  llvm_unreachable("num_workers not valid on serial");
 } else {
   return clauseNotImplemented(clause);
 }
diff --git a/clang/test/CIR/CodeGenOpenACC/kernels.c 
b/cla

[clang] [OpenACC][CIR] Lower 'num_workers' for parallel/kernels (PR #136578)

2025-04-21 Thread Erich Keane via cfe-commits

https://github.com/erichkeane created 
https://github.com/llvm/llvm-project/pull/136578

This patch also includes the first one to handle 'device_type' properly, which 
is where most of the 'challenge' here comes from.

>From the best I can tell: we must keep two lists of the same size, 1 of all of 
>the 'num_workers' items, and 1 of the 'device_type' value for that 
>'num_workers'.  Additionally, the 'device_type' list can only handle single 
>'device_type' values, so we have to duplicate the 'num_workers' items in cases 
>where there are multiple applicable 'device_type' values.

This patch accomplishes this by keeping the two in sync, and saving the current 
'device_type' in the visitor.

>From e12a5016b203446d68019b4f18c19573b481aef7 Mon Sep 17 00:00:00 2001
From: erichkeane 
Date: Wed, 16 Apr 2025 08:33:35 -0700
Subject: [PATCH] [OpenACC][CIR] Lower 'num_workers' for parallel/kernels

This patch also includes the first one to handle 'device_type' properly,
which is where most of the 'challenge' here comes from.

>From the best I can tell: we must keep two lists of the same size, 1 of
all of the 'num_workers' items, and 1 of the 'device_type' value for
that 'num_workers'.  Additionally, the 'device_type' list can only
handle single 'device_type' values, so we have to duplicate the
'num_workers' items in cases where there are multiple applicable
'device_type' values.

This patch accomplishes this by keeping the two in sync, and saving the
current 'device_type' in the visitor.
---
 clang/lib/CIR/CodeGen/CIRGenStmtOpenACC.cpp | 63 +
 clang/test/CIR/CodeGenOpenACC/kernels.c | 52 +
 clang/test/CIR/CodeGenOpenACC/parallel.c| 52 +
 3 files changed, 167 insertions(+)

diff --git a/clang/lib/CIR/CodeGen/CIRGenStmtOpenACC.cpp 
b/clang/lib/CIR/CodeGen/CIRGenStmtOpenACC.cpp
index 30e840cbfa1f7..c7b5c3348e77d 100644
--- a/clang/lib/CIR/CodeGen/CIRGenStmtOpenACC.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenStmtOpenACC.cpp
@@ -46,10 +46,27 @@ class OpenACCClauseCIREmitter final
   // diagnostics are gone.
   SourceLocation dirLoc;
 
+  const OpenACCDeviceTypeClause *lastDeviceTypeClause = nullptr;
+
   void clauseNotImplemented(const OpenACCClause &c) {
 cgf.cgm.errorNYI(c.getSourceRange(), "OpenACC Clause", c.getClauseKind());
   }
 
+  mlir::Value createIntExpr(const Expr *intExpr) {
+mlir::Value expr = cgf.emitScalarExpr(intExpr);
+mlir::Location exprLoc = cgf.cgm.getLoc(intExpr->getBeginLoc());
+
+mlir::IntegerType targetType = mlir::IntegerType::get(
+&cgf.getMLIRContext(), 
cgf.getContext().getIntWidth(intExpr->getType()),
+intExpr->getType()->isSignedIntegerOrEnumerationType()
+? mlir::IntegerType::SignednessSemantics::Signed
+: mlir::IntegerType::SignednessSemantics::Unsigned);
+
+auto conversionOp = builder.create(
+exprLoc, targetType, expr);
+return conversionOp.getResult(0);
+  }
+
   // 'condition' as an OpenACC grammar production is used for 'if' and (some
   // variants of) 'self'.  It needs to be emitted as a signless-1-bit value, so
   // this function emits the expression, then sets the unrealized conversion
@@ -109,6 +126,7 @@ class OpenACCClauseCIREmitter final
   }
 
   void VisitDeviceTypeClause(const OpenACCDeviceTypeClause &clause) {
+lastDeviceTypeClause = &clause;
 if constexpr (isOneOfTypes) {
   llvm::SmallVector deviceTypes;
   std::optional existingDeviceTypes =
@@ -136,6 +154,51 @@ class OpenACCClauseCIREmitter final
   if (!clause.getArchitectures().empty())
 operation.setDeviceType(
 
decodeDeviceType(clause.getArchitectures()[0].getIdentifierInfo()));
+} else if constexpr (isOneOfTypes) {
+  // Nothing to do here, these constructs don't have any IR for these, as
+  // they just modify the other clauses IR.  So setting of `lastDeviceType`
+  // (done above) is all we need.
+} else {
+  return clauseNotImplemented(clause);
+}
+  }
+
+  void VisitNumWorkersClause(const OpenACCNumWorkersClause &clause) {
+if constexpr (isOneOfTypes) {
+  // Collect the 'existing' device-type attributes so we can re-create them
+  // and insert them.
+  llvm::SmallVector deviceTypes;
+  mlir::ArrayAttr existingDeviceTypes =
+  operation.getNumWorkersDeviceTypeAttr();
+
+  if (existingDeviceTypes) {
+for (const mlir::Attribute &Attr : existingDeviceTypes)
+  deviceTypes.push_back(mlir::acc::DeviceTypeAttr::get(
+  builder.getContext(),
+  cast(Attr).getValue()));
+  }
+
+  // Insert 1 version of the 'int-expr' to the NumWorkers list per-current
+  // device type.
+  mlir::Value intExpr = createIntExpr(clause.getIntExpr());
+  if (lastDeviceTypeClause) {
+for (const DeviceTypeArgument &arg :
+ lastDeviceTypeClause->getArchitectures()) {
+  deviceTypes.push_back(mlir::acc::DeviceTypeAttr::get(
+ 

[clang] [HLSL] Make it possible to assign an array from a cbuffer (PR #134174)

2025-04-21 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder 
`sanitizer-aarch64-linux-bootstrap-asan` running on `sanitizer-buildbot7` while 
building `clang` at step 2 "annotate".

Full details are available at: 
https://lab.llvm.org/buildbot/#/builders/24/builds/7603


Here is the relevant piece of the build log for the reference

```
Step 2 (annotate) failure: 'python 
../sanitizer_buildbot/sanitizers/zorg/buildbot/builders/sanitizers/buildbot_selector.py'
 (failure)
...
llvm-lit: 
/home/b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:520:
 note: using lld-link: 
/home/b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm_build_asan/bin/lld-link
llvm-lit: 
/home/b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:520:
 note: using ld64.lld: 
/home/b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm_build_asan/bin/ld64.lld
llvm-lit: 
/home/b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:520:
 note: using wasm-ld: 
/home/b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm_build_asan/bin/wasm-ld
llvm-lit: 
/home/b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:520:
 note: using ld.lld: 
/home/b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm_build_asan/bin/ld.lld
llvm-lit: 
/home/b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:520:
 note: using lld-link: 
/home/b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm_build_asan/bin/lld-link
llvm-lit: 
/home/b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:520:
 note: using ld64.lld: 
/home/b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm_build_asan/bin/ld64.lld
llvm-lit: 
/home/b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:520:
 note: using wasm-ld: 
/home/b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm_build_asan/bin/wasm-ld
llvm-lit: 
/home/b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm-project/llvm/utils/lit/lit/main.py:72:
 note: The test suite configuration requested an individual test timeout of 0 
seconds but a timeout of 900 seconds was requested on the command line. Forcing 
timeout to be 900 seconds.
-- Testing: 87881 tests, 72 workers --
Testing:  0.. 
FAIL: Clang :: CodeGenHLSL/ArrayAssignable.hlsl (9692 of 87881)
 TEST 'Clang :: CodeGenHLSL/ArrayAssignable.hlsl' FAILED 

Exit Code: 2

Command Output (stderr):
--
/home/b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm_build_asan/bin/clang 
-cc1 -internal-isystem 
/home/b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm_build_asan/lib/clang/21/include
 -nostdsysteminc -triple dxil-pc-shadermodel6.3-library 
-finclude-default-header -emit-llvm -disable-llvm-passes -o - 
/home/b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm-project/clang/test/CodeGenHLSL/ArrayAssignable.hlsl
 | 
/home/b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm_build_asan/bin/FileCheck
 
/home/b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm-project/clang/test/CodeGenHLSL/ArrayAssignable.hlsl
 # RUN: at line 1
+ 
/home/b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm_build_asan/bin/FileCheck
 
/home/b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm-project/clang/test/CodeGenHLSL/ArrayAssignable.hlsl
+ 
/home/b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm_build_asan/bin/clang 
-cc1 -internal-isystem 
/home/b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm_build_asan/lib/clang/21/include
 -nostdsysteminc -triple dxil-pc-shadermodel6.3-library 
-finclude-default-header -emit-llvm -disable-llvm-passes -o - 
/home/b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm-project/clang/test/CodeGenHLSL/ArrayAssignable.hlsl
/home/b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm-project/clang/test/CodeGenHLSL/ArrayAssignable.hlsl:15:9:
 error: resource has implicit register binding [-Whlsl-implicit-binding]
   15 | cbuffer CBArrays {
  | ^
1 error generated.
FileCheck error: '' is empty.
FileCheck command line:  
/home/b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm_build_asan/bin/FileCheck
 
/home/b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm-project/clang/test/CodeGenHLSL/ArrayAssignable.hlsl

--


Testing:  0.. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90.. 
Slowest Tests:
--
221.77s: Clang :: Driver/fsanitize.c
175.61s: Clang :: Preprocessor/riscv-target-features.c
149.79s: LLVM :: CodeGen/AMDGPU/sched-group-barrier-pipeline-solver.mir
148.05s: Clang :: Driver/arm-cortex-cpus-2.c
144.39s: Clang :: OpenMP/target_defaultmap_codegen_01.cpp
144.36s: Clang :: Driver/arm-cortex-cpus-1.c
141.27s: Clang :: OpenMP/target_update_codegen.cpp
131.37s: Clang :: Preprocessor/arm-target-features.c
125.47s: Clang :: Preprocessor/aarch64-target-fea

[clang] [Clang] Improve error recovery for invalid calls (PR #136295)

2025-04-21 Thread Matheus Izvekov via cfe-commits

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


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


[clang] [HLSL] Reland; Make it possible to assign an array from a cbuffer (PR #136580)

2025-04-21 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-hlsl

Author: Sarah Spall (spall)


Changes

Reland #134174 
Update Sema Checking to always do an HLSL Array RValue cast in the case we are 
dealing with hlsl constant array types
Instead of comparing canonical types, compare canonical unqualified types
Add a test to show it is possible to assign an array from a cbuffer.
Closes https://github.com/llvm/llvm-project/issues/133767

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


3 Files Affected:

- (modified) clang/lib/Sema/SemaExprCXX.cpp (+4-10) 
- (modified) clang/lib/Sema/SemaOverload.cpp (+5-6) 
- (modified) clang/test/CodeGenHLSL/ArrayAssignable.hlsl (+62-1) 


``diff
diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp
index d46322d75721e..f5a10e0db85ad 100644
--- a/clang/lib/Sema/SemaExprCXX.cpp
+++ b/clang/lib/Sema/SemaExprCXX.cpp
@@ -4745,19 +4745,13 @@ Sema::PerformImplicitConversion(Expr *From, QualType 
ToType,
   case ICK_HLSL_Array_RValue:
 if (ToType->isArrayParameterType()) {
   FromType = Context.getArrayParameterType(FromType);
-  From = ImpCastExprToType(From, FromType, CK_HLSLArrayRValue, VK_PRValue,
-   /*BasePath=*/nullptr, CCK)
- .get();
-} else { // FromType must be ArrayParameterType
-  assert(FromType->isArrayParameterType() &&
- "FromType must be ArrayParameterType in ICK_HLSL_Array_RValue \
-  if it is not ToType");
+} else if (FromType->isArrayParameterType()) {
   const ArrayParameterType *APT = cast(FromType);
   FromType = APT->getConstantArrayType(Context);
-  From = ImpCastExprToType(From, FromType, CK_HLSLArrayRValue, VK_PRValue,
-   /*BasePath=*/nullptr, CCK)
- .get();
 }
+From = ImpCastExprToType(From, FromType, CK_HLSLArrayRValue, VK_PRValue,
+ /*BasePath=*/nullptr, CCK)
+   .get();
 break;
 
   case ICK_Function_To_Pointer:
diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index e4ff8c5489df3..5b224b6c08fef 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -2275,17 +2275,16 @@ static bool IsStandardConversion(Sema &S, Expr* From, 
QualType ToType,
 // handling here.
 if (ToType->isArrayParameterType()) {
   FromType = S.Context.getArrayParameterType(FromType);
-  SCS.First = ICK_HLSL_Array_RValue;
 } else if (FromType->isArrayParameterType()) {
   const ArrayParameterType *APT = cast(FromType);
   FromType = APT->getConstantArrayType(S.Context);
-  SCS.First = ICK_HLSL_Array_RValue;
-} else {
-  SCS.First = ICK_Identity;
 }
 
-if (S.Context.getCanonicalType(FromType) !=
-S.Context.getCanonicalType(ToType))
+SCS.First = ICK_HLSL_Array_RValue;
+
+// Don't consider qualifiers, which include things like address spaces
+if (FromType.getCanonicalType().getUnqualifiedType() !=
+ToType.getCanonicalType().getUnqualifiedType())
   return false;
 
 SCS.setAllToTypes(ToType);
diff --git a/clang/test/CodeGenHLSL/ArrayAssignable.hlsl 
b/clang/test/CodeGenHLSL/ArrayAssignable.hlsl
index e2ff2de68ed99..6374f91230546 100644
--- a/clang/test/CodeGenHLSL/ArrayAssignable.hlsl
+++ b/clang/test/CodeGenHLSL/ArrayAssignable.hlsl
@@ -1,4 +1,23 @@
-// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -emit-llvm 
-disable-llvm-passes -o - %s | FileCheck %s --enable-var-scope
+// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library 
-finclude-default-header -emit-llvm -disable-llvm-passes -o - %s | FileCheck %s
+
+struct S {
+  int x;
+  float f;
+};
+
+// CHECK: [[CBLayout:%.*]] = type <{ [2 x float], [2 x <4 x i32>], [2 x [2 x 
i32]], [1 x target("dx.Layout", %S, 8, 0, 4)] }>
+// CHECK: @CBArrays.cb = global target("dx.CBuffer", target("dx.Layout", 
[[CBLayout]], 136, 0, 32, 64, 128))
+// CHECK: @c1 = external addrspace(2) global [2 x float], align 4
+// CHECK: @c2 = external addrspace(2) global [2 x <4 x i32>], align 16
+// CHECK: @c3 = external addrspace(2) global [2 x [2 x i32]], align 4
+// CHECK: @c4 = external addrspace(2) global [1 x target("dx.Layout", %S, 8, 
0, 4)], align 4
+
+cbuffer CBArrays : register(b0) {
+  float c1[2];
+  int4 c2[2];
+  int c3[2][2];
+  S c4[1];
+}
 
 // CHECK-LABEL: define void {{.*}}arr_assign1
 // CHECK: [[Arr:%.*]] = alloca [2 x i32], align 4
@@ -116,3 +135,45 @@ void arr_assign7() {
   int Arr2[2][2] = {{0, 0}, {1, 1}};
   (Arr = Arr2)[0] = {6, 6};
 }
+
+// Verify you can assign from a cbuffer array
+
+// CHECK-LABEL: define void {{.*}}arr_assign8
+// CHECK: [[C:%.*]] = alloca [2 x float], align 4
+// CHECK-NEXT: call void @llvm.memcpy.p0.p0.i32(ptr align 4 [[C]], ptr align 4 
{{.*}}, i32 8, i1 false)
+// CHECK-NEXT: call void @llvm.memcpy.p0.p2.i32(ptr align 4 [[C]], ptr 
addrspace(2) align 4 @c1, i32 8, i1 false)
+// CHECK-NEXT: ret void
+void arr_assign8() {
+

[clang] [HLSL] Reland; Make it possible to assign an array from a cbuffer (PR #136580)

2025-04-21 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Sarah Spall (spall)


Changes

Reland #134174 
Update Sema Checking to always do an HLSL Array RValue cast in the case we are 
dealing with hlsl constant array types
Instead of comparing canonical types, compare canonical unqualified types
Add a test to show it is possible to assign an array from a cbuffer.
Closes https://github.com/llvm/llvm-project/issues/133767

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


3 Files Affected:

- (modified) clang/lib/Sema/SemaExprCXX.cpp (+4-10) 
- (modified) clang/lib/Sema/SemaOverload.cpp (+5-6) 
- (modified) clang/test/CodeGenHLSL/ArrayAssignable.hlsl (+62-1) 


``diff
diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp
index d46322d75721e..f5a10e0db85ad 100644
--- a/clang/lib/Sema/SemaExprCXX.cpp
+++ b/clang/lib/Sema/SemaExprCXX.cpp
@@ -4745,19 +4745,13 @@ Sema::PerformImplicitConversion(Expr *From, QualType 
ToType,
   case ICK_HLSL_Array_RValue:
 if (ToType->isArrayParameterType()) {
   FromType = Context.getArrayParameterType(FromType);
-  From = ImpCastExprToType(From, FromType, CK_HLSLArrayRValue, VK_PRValue,
-   /*BasePath=*/nullptr, CCK)
- .get();
-} else { // FromType must be ArrayParameterType
-  assert(FromType->isArrayParameterType() &&
- "FromType must be ArrayParameterType in ICK_HLSL_Array_RValue \
-  if it is not ToType");
+} else if (FromType->isArrayParameterType()) {
   const ArrayParameterType *APT = cast(FromType);
   FromType = APT->getConstantArrayType(Context);
-  From = ImpCastExprToType(From, FromType, CK_HLSLArrayRValue, VK_PRValue,
-   /*BasePath=*/nullptr, CCK)
- .get();
 }
+From = ImpCastExprToType(From, FromType, CK_HLSLArrayRValue, VK_PRValue,
+ /*BasePath=*/nullptr, CCK)
+   .get();
 break;
 
   case ICK_Function_To_Pointer:
diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index e4ff8c5489df3..5b224b6c08fef 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -2275,17 +2275,16 @@ static bool IsStandardConversion(Sema &S, Expr* From, 
QualType ToType,
 // handling here.
 if (ToType->isArrayParameterType()) {
   FromType = S.Context.getArrayParameterType(FromType);
-  SCS.First = ICK_HLSL_Array_RValue;
 } else if (FromType->isArrayParameterType()) {
   const ArrayParameterType *APT = cast(FromType);
   FromType = APT->getConstantArrayType(S.Context);
-  SCS.First = ICK_HLSL_Array_RValue;
-} else {
-  SCS.First = ICK_Identity;
 }
 
-if (S.Context.getCanonicalType(FromType) !=
-S.Context.getCanonicalType(ToType))
+SCS.First = ICK_HLSL_Array_RValue;
+
+// Don't consider qualifiers, which include things like address spaces
+if (FromType.getCanonicalType().getUnqualifiedType() !=
+ToType.getCanonicalType().getUnqualifiedType())
   return false;
 
 SCS.setAllToTypes(ToType);
diff --git a/clang/test/CodeGenHLSL/ArrayAssignable.hlsl 
b/clang/test/CodeGenHLSL/ArrayAssignable.hlsl
index e2ff2de68ed99..6374f91230546 100644
--- a/clang/test/CodeGenHLSL/ArrayAssignable.hlsl
+++ b/clang/test/CodeGenHLSL/ArrayAssignable.hlsl
@@ -1,4 +1,23 @@
-// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -emit-llvm 
-disable-llvm-passes -o - %s | FileCheck %s --enable-var-scope
+// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library 
-finclude-default-header -emit-llvm -disable-llvm-passes -o - %s | FileCheck %s
+
+struct S {
+  int x;
+  float f;
+};
+
+// CHECK: [[CBLayout:%.*]] = type <{ [2 x float], [2 x <4 x i32>], [2 x [2 x 
i32]], [1 x target("dx.Layout", %S, 8, 0, 4)] }>
+// CHECK: @CBArrays.cb = global target("dx.CBuffer", target("dx.Layout", 
[[CBLayout]], 136, 0, 32, 64, 128))
+// CHECK: @c1 = external addrspace(2) global [2 x float], align 4
+// CHECK: @c2 = external addrspace(2) global [2 x <4 x i32>], align 16
+// CHECK: @c3 = external addrspace(2) global [2 x [2 x i32]], align 4
+// CHECK: @c4 = external addrspace(2) global [1 x target("dx.Layout", %S, 8, 
0, 4)], align 4
+
+cbuffer CBArrays : register(b0) {
+  float c1[2];
+  int4 c2[2];
+  int c3[2][2];
+  S c4[1];
+}
 
 // CHECK-LABEL: define void {{.*}}arr_assign1
 // CHECK: [[Arr:%.*]] = alloca [2 x i32], align 4
@@ -116,3 +135,45 @@ void arr_assign7() {
   int Arr2[2][2] = {{0, 0}, {1, 1}};
   (Arr = Arr2)[0] = {6, 6};
 }
+
+// Verify you can assign from a cbuffer array
+
+// CHECK-LABEL: define void {{.*}}arr_assign8
+// CHECK: [[C:%.*]] = alloca [2 x float], align 4
+// CHECK-NEXT: call void @llvm.memcpy.p0.p0.i32(ptr align 4 [[C]], ptr align 4 
{{.*}}, i32 8, i1 false)
+// CHECK-NEXT: call void @llvm.memcpy.p0.p2.i32(ptr align 4 [[C]], ptr 
addrspace(2) align 4 @c1, i32 8, i1 false)
+// CHECK-NEXT: ret void
+void arr_assign8() {

[clang] [HLSL] Reland; Make it possible to assign an array from a cbuffer (PR #136580)

2025-04-21 Thread Sarah Spall via cfe-commits

https://github.com/spall created 
https://github.com/llvm/llvm-project/pull/136580

Reland #134174 
Update Sema Checking to always do an HLSL Array RValue cast in the case we are 
dealing with hlsl constant array types
Instead of comparing canonical types, compare canonical unqualified types
Add a test to show it is possible to assign an array from a cbuffer.
Closes https://github.com/llvm/llvm-project/issues/133767

>From 5d81a4b7b034dd5999feb6ab37537270d6bae2a8 Mon Sep 17 00:00:00 2001
From: Sarah Spall 
Date: Wed, 2 Apr 2025 12:04:18 -0700
Subject: [PATCH 1/3] compare unqualified canonical types and add an hlsl array
 rvalue cast

---
 clang/lib/Sema/SemaExprCXX.cpp  | 14 ++---
 clang/lib/Sema/SemaOverload.cpp | 10 ++--
 clang/test/CodeGenHLSL/ArrayAssignable.hlsl | 63 -
 3 files changed, 70 insertions(+), 17 deletions(-)

diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp
index fa492bc124abd..dd4887c0b2878 100644
--- a/clang/lib/Sema/SemaExprCXX.cpp
+++ b/clang/lib/Sema/SemaExprCXX.cpp
@@ -4418,19 +4418,13 @@ Sema::PerformImplicitConversion(Expr *From, QualType 
ToType,
   case ICK_HLSL_Array_RValue:
 if (ToType->isArrayParameterType()) {
   FromType = Context.getArrayParameterType(FromType);
-  From = ImpCastExprToType(From, FromType, CK_HLSLArrayRValue, VK_PRValue,
-   /*BasePath=*/nullptr, CCK)
- .get();
-} else { // FromType must be ArrayParameterType
-  assert(FromType->isArrayParameterType() &&
- "FromType must be ArrayParameterType in ICK_HLSL_Array_RValue \
-  if it is not ToType");
+} else if (FromType->isArrayParameterType()) {
   const ArrayParameterType *APT = cast(FromType);
   FromType = APT->getConstantArrayType(Context);
-  From = ImpCastExprToType(From, FromType, CK_HLSLArrayRValue, VK_PRValue,
-   /*BasePath=*/nullptr, CCK)
- .get();
 }
+From = ImpCastExprToType(From, FromType, CK_HLSLArrayRValue, VK_PRValue,
+ /*BasePath=*/nullptr, CCK)
+   .get();
 break;
 
   case ICK_Function_To_Pointer:
diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index 1802f8f4e1f91..d282fe50e49f1 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -2268,17 +2268,15 @@ static bool IsStandardConversion(Sema &S, Expr* From, 
QualType ToType,
 // handling here.
 if (ToType->isArrayParameterType()) {
   FromType = S.Context.getArrayParameterType(FromType);
-  SCS.First = ICK_HLSL_Array_RValue;
 } else if (FromType->isArrayParameterType()) {
   const ArrayParameterType *APT = cast(FromType);
   FromType = APT->getConstantArrayType(S.Context);
-  SCS.First = ICK_HLSL_Array_RValue;
-} else {
-  SCS.First = ICK_Identity;
 }
 
-if (S.Context.getCanonicalType(FromType) !=
-S.Context.getCanonicalType(ToType))
+SCS.First = ICK_HLSL_Array_RValue;
+
+if (FromType.getCanonicalType().getUnqualifiedType() !=
+ToType.getCanonicalType().getUnqualifiedType())
   return false;
 
 SCS.setAllToTypes(ToType);
diff --git a/clang/test/CodeGenHLSL/ArrayAssignable.hlsl 
b/clang/test/CodeGenHLSL/ArrayAssignable.hlsl
index e2ff2de68ed99..723d521596baf 100644
--- a/clang/test/CodeGenHLSL/ArrayAssignable.hlsl
+++ b/clang/test/CodeGenHLSL/ArrayAssignable.hlsl
@@ -1,4 +1,23 @@
-// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -emit-llvm 
-disable-llvm-passes -o - %s | FileCheck %s --enable-var-scope
+// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library 
-finclude-default-header -emit-llvm -disable-llvm-passes -o - %s | FileCheck %s
+
+struct S {
+  int x;
+  float f;
+};
+
+// CHECK: [[CBLayout:%.*]] = type <{ [2 x float], [2 x <4 x i32>], [2 x [2 x 
i32]], [1 x target("dx.Layout", %S, 8, 0, 4)] }>
+// CHECK: @CBArrays.cb = global target("dx.CBuffer", target("dx.Layout", 
[[CBLayout]], 136, 0, 32, 64, 128))
+// CHECK: @c1 = external addrspace(2) global [2 x float], align 4
+// CHECK: @c2 = external addrspace(2) global [2 x <4 x i32>], align 16
+// CHECK: @c3 = external addrspace(2) global [2 x [2 x i32]], align 4
+// CHECK: @c4 = external addrspace(2) global [1 x target("dx.Layout", %S, 8, 
0, 4)], align 4
+
+cbuffer CBArrays {
+  float c1[2];
+  int4 c2[2];
+  int c3[2][2];
+  S c4[1];
+}
 
 // CHECK-LABEL: define void {{.*}}arr_assign1
 // CHECK: [[Arr:%.*]] = alloca [2 x i32], align 4
@@ -116,3 +135,45 @@ void arr_assign7() {
   int Arr2[2][2] = {{0, 0}, {1, 1}};
   (Arr = Arr2)[0] = {6, 6};
 }
+
+// Verify you can assign from a cbuffer array
+
+// CHECK-LABEL: define void {{.*}}arr_assign8
+// CHECK: [[C:%.*]] = alloca [2 x float], align 4
+// CHECK-NEXT: call void @llvm.memcpy.p0.p0.i32(ptr align 4 [[C]], ptr align 4 
{{.*}}, i32 8, i1 false)
+// CHECK-NEXT: call void @llvm.memcpy.p0.p2.i32(ptr align 4 [[C]], ptr 
a

[clang] [llvm] [HLSL] Implement the `faceforward` intrinsic (PR #135878)

2025-04-21 Thread Farzon Lotfi via cfe-commits


@@ -0,0 +1,63 @@
+; RUN: llc -O0 -verify-machineinstrs -mtriple=spirv-unknown-unknown %s -o - | 
FileCheck %s
+; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv-unknown-unknown %s -o - 
-filetype=obj | spirv-val --target-env vulkan1.3 %}
+
+; TODO(#136344): This test currently fails when --target-env vulkan1.3 is 
specified.
+; XFAIL: spirv-tools

farzonl wrote:

we can't xfail a new test

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


[clang] [llvm] [RISCV] Add Andes XAndesperf (Andes Performance) extension. (PR #135110)

2025-04-21 Thread Jim Lin via cfe-commits

https://github.com/tclin914 updated 
https://github.com/llvm/llvm-project/pull/135110

>From b23dec1163f300189f1a2ce28f20c07d3cb9d5fe Mon Sep 17 00:00:00 2001
From: Jim Lin 
Date: Wed, 9 Apr 2025 09:44:47 +0800
Subject: [PATCH 01/12] [RISCV] Add Andes XAndesperf (Andes Performance)
 extension.

The spec can be found at:
https://github.com/andestech/andes-v5-isa/releases/tag/ast-v5_4_0-release.

This patch only supports assembler.

Relocation and fixup for the branch and gp-implied instructions will be
added in a later patch.
---
 .../Driver/print-supported-extensions-riscv.c |   1 +
 llvm/docs/RISCVUsage.rst  |   3 +
 llvm/docs/ReleaseNotes.md |   1 +
 .../Target/RISCV/AsmParser/RISCVAsmParser.cpp |  41 +-
 .../RISCV/Disassembler/RISCVDisassembler.cpp  |  22 +-
 .../RISCV/MCTargetDesc/RISCVMCCodeEmitter.cpp |  23 +-
 llvm/lib/Target/RISCV/RISCVFeatures.td|   9 +
 llvm/lib/Target/RISCV/RISCVInstrInfo.td   |   1 +
 llvm/lib/Target/RISCV/RISCVInstrInfoXAndes.td | 358 ++
 llvm/test/CodeGen/RISCV/attributes.ll |   4 +
 llvm/test/CodeGen/RISCV/features-info.ll  |   1 +
 llvm/test/MC/RISCV/xandesperf-invalid.s   |  56 +++
 llvm/test/MC/RISCV/xandesperf-rv64-invalid.s  |  20 +
 llvm/test/MC/RISCV/xandesperf-rv64-valid.s|  34 ++
 llvm/test/MC/RISCV/xandesperf-valid.s | 105 +
 .../TargetParser/RISCVISAInfoTest.cpp |   1 +
 16 files changed, 666 insertions(+), 14 deletions(-)
 create mode 100644 llvm/lib/Target/RISCV/RISCVInstrInfoXAndes.td
 create mode 100644 llvm/test/MC/RISCV/xandesperf-invalid.s
 create mode 100644 llvm/test/MC/RISCV/xandesperf-rv64-invalid.s
 create mode 100644 llvm/test/MC/RISCV/xandesperf-rv64-valid.s
 create mode 100644 llvm/test/MC/RISCV/xandesperf-valid.s

diff --git a/clang/test/Driver/print-supported-extensions-riscv.c 
b/clang/test/Driver/print-supported-extensions-riscv.c
index 39002d7b4780a..88b198d0fc795 100644
--- a/clang/test/Driver/print-supported-extensions-riscv.c
+++ b/clang/test/Driver/print-supported-extensions-riscv.c
@@ -154,6 +154,7 @@
 // CHECK-NEXT: svnapot  1.0   'Svnapot' (NAPOT Translation 
Contiguity)
 // CHECK-NEXT: svpbmt   1.0   'Svpbmt' (Page-Based Memory 
Types)
 // CHECK-NEXT: svvptc   1.0   'Svvptc' (Obviating 
Memory-Management Instructions after Marking PTEs Valid)
+// CHECK-NEXT: xandesperf   5.0   'XAndesPerf' (Andes 
Performance Extension)
 // CHECK-NEXT: xcvalu   1.0   'XCValu' (CORE-V ALU 
Operations)
 // CHECK-NEXT: xcvbi1.0   'XCVbi' (CORE-V Immediate 
Branching)
 // CHECK-NEXT: xcvbitmanip  1.0   'XCVbitmanip' (CORE-V Bit 
Manipulation)
diff --git a/llvm/docs/RISCVUsage.rst b/llvm/docs/RISCVUsage.rst
index 137b537f00ea0..e655d9ba02547 100644
--- a/llvm/docs/RISCVUsage.rst
+++ b/llvm/docs/RISCVUsage.rst
@@ -503,6 +503,9 @@ The current vendor extensions supported are:
 ``experimental-XRivosVizip``
   LLVM implements `version 0.1 of the Rivos Vector Register Zips extension 
specification `__.
 
+``XAndesPerf``
+  LLVM implements `version 5.0.0 of the Andes Performance Extension 
specification 
`
 by Andes Technology. All instructions are prefixed with `nds.` as described in 
the specification.
+
 Experimental C Intrinsics
 =
 
diff --git a/llvm/docs/ReleaseNotes.md b/llvm/docs/ReleaseNotes.md
index cc4fd38944ff6..5c10ed65a729c 100644
--- a/llvm/docs/ReleaseNotes.md
+++ b/llvm/docs/ReleaseNotes.md
@@ -168,6 +168,7 @@ Changes to the RISC-V Backend
   and branch and linker relaxation. This can be disabled with ``.option 
noexact``,
   which is also the default.
 * `-mcpu=xiangshan-kunminghu` was added.
+* Adds assembler support for the Andes `XAndesperf` (Andes Performance 
extension).
 
 Changes to the WebAssembly Backend
 --
diff --git a/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp 
b/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
index 6cec11a48d042..3d1076e9a5ae4 100644
--- a/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
+++ b/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
@@ -533,20 +533,26 @@ struct RISCVOperand final : public MCParsedAsmOperand {
   }
 
   // True if operand is a symbol with no modifiers, or a constant with no
-  // modifiers and isShiftedInt(Op).
-  template  bool isBareSimmNLsb0() const {
+  // modifiers and isShiftedInt(Op).
+  template  bool isBareSimmNLsbK() const {
 if (!isImm())
   return false;
 
 int64_t Imm;
 if (evaluateConstantImm(getImm(), Imm))
-  return isShiftedInt(fixImmediateForRV32(Imm, isRV64Imm()));
+  return isShiftedInt(fixImmediateForRV32(Imm, isRV64Imm()));
 
 RISCVMCExpr::Specifier VK = RI

[clang] [HLSL] Reland; Make it possible to assign an array from a cbuffer (PR #136580)

2025-04-21 Thread Justin Bogner via cfe-commits

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


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


  1   2   3   4   >