[llvm-branch-commits] [clang] d3143a0 - Add `REQUIRES: systemz-registered-target` to test added in #68926 (9a38a72).

2023-11-27 Thread Douglas Yung via llvm-branch-commits

Author: Douglas Yung
Date: 2023-11-27T17:35:24-08:00
New Revision: d3143a09acb30f9d3978373d20d67d2c78ce07a9

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

LOG: Add `REQUIRES: systemz-registered-target` to test added in #68926 
(9a38a72).

Added: 


Modified: 
clang/test/CodeGen/SystemZ/systemz-ppa2.c

Removed: 




diff  --git a/clang/test/CodeGen/SystemZ/systemz-ppa2.c 
b/clang/test/CodeGen/SystemZ/systemz-ppa2.c
index 21ccd0d7b834c19..0ff4cba5edfb6c6 100644
--- a/clang/test/CodeGen/SystemZ/systemz-ppa2.c
+++ b/clang/test/CodeGen/SystemZ/systemz-ppa2.c
@@ -10,6 +10,8 @@
 // .byte (i.e., the one for the 3) would, it seems, also match
 // the .byte line below for the 34.
 
+// REQUIRES: systemz-registered-target
+
 // RUN: %clang_cc1 -triple s390x-ibm-zos -xc -S -o - %s | FileCheck %s 
--check-prefix CHECK-C
 // CHECK-C:[[PPA2:(.L)|(@@)PPA2]]:
 // CHECK-C-NEXT:   .byte3{{[[:space:]]*}}.byte 0



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


[llvm-branch-commits] [clang] d3143a0 - Add `REQUIRES: systemz-registered-target` to test added in #68926 (9a38a72).

2023-11-27 Thread Douglas Yung via llvm-branch-commits

Author: Douglas Yung
Date: 2023-11-27T17:35:24-08:00
New Revision: d3143a09acb30f9d3978373d20d67d2c78ce07a9

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

LOG: Add `REQUIRES: systemz-registered-target` to test added in #68926 
(9a38a72).

Added: 


Modified: 
clang/test/CodeGen/SystemZ/systemz-ppa2.c

Removed: 




diff  --git a/clang/test/CodeGen/SystemZ/systemz-ppa2.c 
b/clang/test/CodeGen/SystemZ/systemz-ppa2.c
index 21ccd0d7b834c19..0ff4cba5edfb6c6 100644
--- a/clang/test/CodeGen/SystemZ/systemz-ppa2.c
+++ b/clang/test/CodeGen/SystemZ/systemz-ppa2.c
@@ -10,6 +10,8 @@
 // .byte (i.e., the one for the 3) would, it seems, also match
 // the .byte line below for the 34.
 
+// REQUIRES: systemz-registered-target
+
 // RUN: %clang_cc1 -triple s390x-ibm-zos -xc -S -o - %s | FileCheck %s 
--check-prefix CHECK-C
 // CHECK-C:[[PPA2:(.L)|(@@)PPA2]]:
 // CHECK-C-NEXT:   .byte3{{[[:space:]]*}}.byte 0



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


[llvm-branch-commits] [clang-tools-extra] f85b153 - Add -fexceptions to test as it uses them and fails on platforms where it is not on by default (like the PS4).

2021-01-14 Thread Douglas Yung via llvm-branch-commits

Author: Douglas Yung
Date: 2021-01-14T13:27:06-08:00
New Revision: f85b1531666d12e6ca9b29217b5c5da30dfd93cf

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

LOG: Add -fexceptions to test as it uses them and fails on platforms where it 
is not on by default (like the PS4).

Added: 


Modified: 

clang-tools-extra/test/clang-tidy/checkers/readability-function-cognitive-complexity.cpp

Removed: 




diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/readability-function-cognitive-complexity.cpp
 
b/clang-tools-extra/test/clang-tidy/checkers/readability-function-cognitive-complexity.cpp
index 0916acd8e675..79bc0c3dc4de 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/readability-function-cognitive-complexity.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/readability-function-cognitive-complexity.cpp
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy %s readability-function-cognitive-complexity %t -- 
-config='{CheckOptions: [{key: 
readability-function-cognitive-complexity.Threshold, value: 0}]}' -- -std=c++11 
-fblocks -w
+// RUN: %check_clang_tidy %s readability-function-cognitive-complexity %t -- 
-config='{CheckOptions: [{key: 
readability-function-cognitive-complexity.Threshold, value: 0}]}' -- -std=c++11 
-fblocks -fexceptions -w
 
 // any function should be checked.
 



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


[llvm-branch-commits] [clang] be68c92 - [NFC] Add -std=c11 to attr-availability.c

2021-01-15 Thread Douglas Yung via llvm-branch-commits

Author: Douglas Yung
Date: 2021-01-15T21:05:49-08:00
New Revision: be68c9222b85815612e6bd8bc606a87e3111a0fb

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

LOG: [NFC] Add -std=c11 to attr-availability.c

This test will fail with any toolchains that don't default to C11.

Adding this switch to the clang invocation in the test fixes the issue.

Patch by Justice Adams!

Reviewed By: dyung

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

Added: 


Modified: 
clang/test/Parser/attr-availability.c

Removed: 




diff  --git a/clang/test/Parser/attr-availability.c 
b/clang/test/Parser/attr-availability.c
index d3b640a2feea..6a5c659ca1c2 100644
--- a/clang/test/Parser/attr-availability.c
+++ b/clang/test/Parser/attr-availability.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -std=c11 -fsyntax-only -verify %s
 
 #if !__has_feature(attribute_availability)
 #  error 'availability' attribute is not available



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


[llvm-branch-commits] [llvm] f20bb85 - Update filename to workers.py file in documentation

2021-01-22 Thread Douglas Yung via llvm-branch-commits

Author: Douglas Yung
Date: 2021-01-22T00:20:26-08:00
New Revision: f20bb857addaf5479d9b1d4ac29e315a3971ff1c

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

LOG: Update filename to workers.py file in documentation

Commit be9f322e8dc530a56f03356aad31fa9031b27e26 moved the list of workers from
slaves.py to workers.py, but the documentation in "How To Add A Builder" was
never updated and now references a non-existing file. This fixes that.

Reviewed By: gkistanova

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

Added: 


Modified: 
llvm/docs/HowToAddABuilder.rst

Removed: 




diff  --git a/llvm/docs/HowToAddABuilder.rst b/llvm/docs/HowToAddABuilder.rst
index 93a289512fe2..608deb2c1ffd 100644
--- a/llvm/docs/HowToAddABuilder.rst
+++ b/llvm/docs/HowToAddABuilder.rst
@@ -86,7 +86,7 @@ Here are the steps you can follow to do so:
`zorg `_. Use the typical LLVM 
`workflow `_.
 
-   * workers are added to ``buildbot/osuosl/master/config/slaves.py``
+   * workers are added to ``buildbot/osuosl/master/config/workers.py``
* builders are added to ``buildbot/osuosl/master/config/builders.py``
 
Please make sure your builder name and its builddir are unique through the



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


[llvm-branch-commits] [llvm] ccc5160 - Fixup test in path to use C:\ instead of D:\ which may be mapped to a removable.

2020-12-07 Thread Douglas Yung via llvm-branch-commits

Author: Douglas Yung
Date: 2020-12-07T16:36:58-08:00
New Revision: ccc5160df100663630329e2e544fc04dd126f88f

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

LOG: Fixup test in path to use C:\ instead of D:\ which may be mapped to a 
removable.

Our internal build bot hit a failure in 
llvm/test/tools/llvm-symbolizer/pdb/missing_pdb.test
because the test was checking for an error message that is emitted when a pdb 
file is
missing. But when the drive is mapped to a removalable drive (such as a DVD 
drive) in
Windows, you get a different error message which causes the test to fail.

This fixes the test by changing the drive the missing pdb is expected to be on 
to C:\
instead of D:\ as that is the drive historically used to install Windows and 
thus
if present should be a hard drive.

Reviewed By: rnk

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

Added: 


Modified: 
llvm/test/tools/llvm-symbolizer/pdb/Inputs/missing_pdb.exe

Removed: 




diff  --git a/llvm/test/tools/llvm-symbolizer/pdb/Inputs/missing_pdb.exe 
b/llvm/test/tools/llvm-symbolizer/pdb/Inputs/missing_pdb.exe
index 320e1f30e582..93aa8a788b96 100644
Binary files a/llvm/test/tools/llvm-symbolizer/pdb/Inputs/missing_pdb.exe and 
b/llvm/test/tools/llvm-symbolizer/pdb/Inputs/missing_pdb.exe 
diff er



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


[llvm-branch-commits] [llvm] 31e4363 - [NVPTX] Disable relative lookup tables (#159748)

2025-10-01 Thread Douglas Yung via llvm-branch-commits

Author: Nikita Popov
Date: 2025-10-01T14:31:21Z
New Revision: 31e4363ba9c2e0582a2b1105fe24dbfff860b7f6

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

LOG: [NVPTX] Disable relative lookup tables (#159748)

Relative lookup tables result in "LLVM ERROR: Circular dependency found
in global variable set", so disable them for this target.

(cherry picked from commit 1ed15374638ecf6046169194b4b3ca34b7cf340f)

Added: 
llvm/test/Transforms/RelLookupTableConverter/nvptx.ll

Modified: 
llvm/lib/Target/NVPTX/NVPTXTargetTransformInfo.h

Removed: 




diff  --git a/llvm/lib/Target/NVPTX/NVPTXTargetTransformInfo.h 
b/llvm/lib/Target/NVPTX/NVPTXTargetTransformInfo.h
index 9a6e261c811a0..437edfb8ffc75 100644
--- a/llvm/lib/Target/NVPTX/NVPTXTargetTransformInfo.h
+++ b/llvm/lib/Target/NVPTX/NVPTXTargetTransformInfo.h
@@ -183,6 +183,11 @@ class NVPTXTTIImpl final : public 
BasicTTIImplBase {
   void collectKernelLaunchBounds(
   const Function &F,
   SmallVectorImpl> &LB) const override;
+
+  bool shouldBuildRelLookupTables() const override {
+// Self-referential globals are not supported.
+return false;
+  }
 };
 
 } // end namespace llvm

diff  --git a/llvm/test/Transforms/RelLookupTableConverter/nvptx.ll 
b/llvm/test/Transforms/RelLookupTableConverter/nvptx.ll
new file mode 100644
index 0..70ebf220c369c
--- /dev/null
+++ b/llvm/test/Transforms/RelLookupTableConverter/nvptx.ll
@@ -0,0 +1,32 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py 
UTC_ARGS: --check-globals all --version 5
+; RUN: opt < %s -passes=rel-lookup-table-converter -relocation-model=pic -S | 
FileCheck %s
+; REQUIRES: nvptx-registered-target
+target triple = "nvptx64-nvidia-cuda"
+
+; Do not produce relative lookup table for nvptx target.
+
+@a1 = internal constant i32 0, align 4
+@b1 = internal constant i32 0, align 4
+@c1 = internal constant i32 0, align 4
+@d1 = internal constant i32 0, align 4
+
+@switch.table = private unnamed_addr constant [3 x ptr] [ptr @a1, ptr @b1, ptr 
@c1], align 8
+
+;.
+; CHECK: @a1 = internal constant i32 0, align 4
+; CHECK: @b1 = internal constant i32 0, align 4
+; CHECK: @c1 = internal constant i32 0, align 4
+; CHECK: @d1 = internal constant i32 0, align 4
+; CHECK: @switch.table = private unnamed_addr constant [3 x ptr] [ptr @a1, ptr 
@b1, ptr @c1], align 8
+;.
+define ptr @internal_linkage(i32 %cond) {
+; CHECK-LABEL: define ptr @internal_linkage(
+; CHECK-SAME: i32 [[COND:%.*]]) {
+; CHECK-NEXT:[[SWITCH_GEP:%.*]] = getelementptr inbounds [3 x ptr], ptr 
@switch.table, i32 0, i32 [[COND]]
+; CHECK-NEXT:[[RELTABLE_INTRINSIC:%.*]] = load ptr, ptr [[SWITCH_GEP]], 
align 8
+; CHECK-NEXT:ret ptr [[RELTABLE_INTRINSIC]]
+;
+  %switch.gep = getelementptr inbounds [3 x ptr], ptr @switch.table, i32 0, 
i32 %cond
+  %switch.load = load ptr, ptr %switch.gep, align 8
+  ret ptr %switch.load
+}



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


[llvm-branch-commits] [clang] 0060034 - [analyzer] Revert #115918, so empty base class optimization works again (#157480)

2025-10-01 Thread Douglas Yung via llvm-branch-commits

Author: Balazs Benics
Date: 2025-10-01T15:10:18Z
New Revision: 0060034c6a0b3735c3f7fd89173884a10fe30206

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

LOG: [analyzer] Revert #115918, so empty base class optimization works again 
(#157480)

Tldr;
We can't unconditionally trivially copy empty classes because that would
clobber the stored entries in the object that the optimized empty class
overlaps with.

This regression was introduced by #115918, which introduced other
clobbering issues, like the handling of `[[no_unique_address]]` fields
in #137252.

Read issue #157467 for the detailed explanation, but in short, I'd
propose reverting the original patch because these was a lot of problems
with it for arguably not much gain.
In particular, that patch was motivated by unifying the handling of
classes so that copy events would be triggered for a class no matter if
it had data members or not.
So in hindsight, it was not worth it.

I plan to backport this to clang-21 as well, and mention in the release
notes that this should fix the regression from clang-20.

PS: Also an interesting read [D43714](https://reviews.llvm.org/D43714)
in hindsight.

Fixes #157467
CPP-6574

(cherry picked from commit 38b948bd4b9bd0ed532c3bea69e0038b3dffe80a)

Added: 
clang/test/Analysis/issue-157467.cpp

Modified: 
clang/docs/ReleaseNotes.rst
clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
clang/test/Analysis/ctor-trivial-copy.cpp
clang/test/Analysis/taint-generic.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index f03a3273c4518..43529b0f28c3d 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -1261,6 +1261,11 @@ New features
 Crash and bug fixes
 ^^^
 
+- Fixed a regression introduced by clang-20 in #GH115918 that lead to false
+  positive reports when ``[[no_unique_address]]`` or empty base class
+  optimization techniques were used. Most notably, some ``std::unique_ptr``
+  implementations. (#GH157467)
+
 - Fixed a crash when C++20 parenthesized initializer lists are used.
   This affected a crash of the well-known lambda overloaded pattern.
   (#GH136041, #GH135665)

diff  --git a/clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp 
b/clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
index 85353848aa124..dc715c7d46d8b 100644
--- a/clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
+++ b/clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
@@ -71,21 +71,30 @@ void ExprEngine::performTrivialCopy(NodeBuilder &Bldr, 
ExplodedNode *Pred,
   Bldr.takeNodes(Pred);
 
   assert(ThisRD);
-  SVal V = Call.getArgSVal(0);
-  const Expr *VExpr = Call.getArgExpr(0);
 
-  // If the value being copied is not unknown, load from its location to get
-  // an aggregate rvalue.
-  if (std::optional L = V.getAs())
-V = Pred->getState()->getSVal(*L);
-  else
-assert(V.isUnknownOrUndef());
+  if (!ThisRD->isEmpty()) {
+SVal V = Call.getArgSVal(0);
+const Expr *VExpr = Call.getArgExpr(0);
 
-  ExplodedNodeSet Tmp;
-  evalLocation(Tmp, CallExpr, VExpr, Pred, Pred->getState(), V,
-   /*isLoad=*/true);
-  for (ExplodedNode *N : Tmp)
-evalBind(Dst, CallExpr, N, ThisVal, V, true);
+// If the value being copied is not unknown, load from its location to get
+// an aggregate rvalue.
+if (std::optional L = V.getAs())
+  V = Pred->getState()->getSVal(*L);
+else
+  assert(V.isUnknownOrUndef());
+
+ExplodedNodeSet Tmp;
+evalLocation(Tmp, CallExpr, VExpr, Pred, Pred->getState(), V,
+ /*isLoad=*/true);
+for (ExplodedNode *N : Tmp)
+  evalBind(Dst, CallExpr, N, ThisVal, V, true);
+  } else {
+// We can't copy empty classes because of empty base class optimization.
+// In that case, copying the empty base class subobject would overwrite the
+// object that it overlaps with - so let's not do that.
+// See issue-157467.cpp for an example.
+Dst.Add(Pred);
+  }
 
   PostStmt PS(CallExpr, LCtx);
   for (ExplodedNode *N : Dst) {

diff  --git a/clang/test/Analysis/ctor-trivial-copy.cpp 
b/clang/test/Analysis/ctor-trivial-copy.cpp
index 45c8ca4c51776..940ff9ba3ed9c 100644
--- a/clang/test/Analysis/ctor-trivial-copy.cpp
+++ b/clang/test/Analysis/ctor-trivial-copy.cpp
@@ -46,15 +46,10 @@ void _01_empty_structs() {
   empty Empty = conjure();
   empty Empty2 = Empty;
   empty Empty3 = Empty2;
-  // All of these should refer to the exact same symbol, because all of
-  // these trivial copies refer to the original conjured value.
-  // There were Unknown before:
-  clang_analyzer_denote(Empty, "$Empty");
-  clang_analyzer_express(Empty);  // expected-warning {{$Empty}}
-  clang_analyzer_express(Empty2); // expected-warning {{$Empty}}
-  clang_analyzer_express(Empt

[llvm-branch-commits] [clang] 41e817a - release/21.x: [clang-format] Fix bugs in annotating arrows and square brackets (#160973)

2025-10-01 Thread Douglas Yung via llvm-branch-commits

Author: owenca
Date: 2025-10-01T15:17:16Z
New Revision: 41e817a1d1f441494cff32175bae407a9cadd8ee

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

LOG: release/21.x: [clang-format] Fix bugs in annotating arrows and square 
brackets (#160973)

Backport 4edda3d78c26b9d928d115b2059d0c719eec237b

Added: 


Modified: 
clang/lib/Format/TokenAnnotator.cpp
clang/lib/Format/UnwrappedLineParser.cpp
clang/unittests/Format/TokenAnnotatorTest.cpp

Removed: 




diff  --git a/clang/lib/Format/TokenAnnotator.cpp 
b/clang/lib/Format/TokenAnnotator.cpp
index cbeb5ef7e4bf4..580996e870f54 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -829,11 +829,6 @@ class AnnotatingParser {
   if (Parent && Parent->is(TT_PointerOrReference))
 Parent->overwriteFixedType(TT_BinaryOperator);
 }
-// An arrow after an ObjC method expression is not a lambda arrow.
-if (CurrentToken->is(TT_ObjCMethodExpr) && CurrentToken->Next &&
-CurrentToken->Next->is(TT_LambdaArrow)) {
-  CurrentToken->Next->overwriteFixedType(TT_Unknown);
-}
 Left->MatchingParen = CurrentToken;
 CurrentToken->MatchingParen = Left;
 // FirstObjCSelectorName is set when a colon is found. This does

diff  --git a/clang/lib/Format/UnwrappedLineParser.cpp 
b/clang/lib/Format/UnwrappedLineParser.cpp
index 91b8fdc8a3c38..934605733542f 100644
--- a/clang/lib/Format/UnwrappedLineParser.cpp
+++ b/clang/lib/Format/UnwrappedLineParser.cpp
@@ -2266,7 +2266,7 @@ bool UnwrappedLineParser::tryToParseLambda() {
   if (!tryToParseLambdaIntroducer())
 return false;
 
-  bool SeenArrow = false;
+  FormatToken *Arrow = nullptr;
   bool InTemplateParameterList = false;
 
   while (FormatTok->isNot(tok::l_brace)) {
@@ -2341,17 +2341,13 @@ bool UnwrappedLineParser::tryToParseLambda() {
 case tok::ellipsis:
 case tok::kw_true:
 case tok::kw_false:
-  if (SeenArrow || InTemplateParameterList) {
+  if (Arrow || InTemplateParameterList) {
 nextToken();
 break;
   }
   return true;
 case tok::arrow:
-  // This might or might not actually be a lambda arrow (this could be an
-  // ObjC method invocation followed by a dereferencing arrow). We might
-  // reset this back to TT_Unknown in TokenAnnotator.
-  FormatTok->setFinalizedType(TT_LambdaArrow);
-  SeenArrow = true;
+  Arrow = FormatTok;
   nextToken();
   break;
 case tok::kw_requires: {
@@ -2373,6 +2369,9 @@ bool UnwrappedLineParser::tryToParseLambda() {
   FormatTok->setFinalizedType(TT_LambdaLBrace);
   LSquare.setFinalizedType(TT_LambdaLSquare);
 
+  if (Arrow)
+Arrow->setFinalizedType(TT_LambdaArrow);
+
   NestedLambdas.push_back(Line->SeenDecltypeAuto);
   parseChildBlock();
   assert(!NestedLambdas.empty());
@@ -2386,11 +2385,6 @@ bool UnwrappedLineParser::tryToParseLambdaIntroducer() {
   const FormatToken *LeftSquare = FormatTok;
   nextToken();
   if (Previous) {
-if (Previous->Tok.getIdentifierInfo() &&
-!Previous->isOneOf(tok::kw_return, tok::kw_co_await, tok::kw_co_yield,
-   tok::kw_co_return)) {
-  return false;
-}
 if (Previous->closesScope()) {
   // Not a potential C-style cast.
   if (Previous->isNot(tok::r_paren))
@@ -2400,6 +2394,13 @@ bool UnwrappedLineParser::tryToParseLambdaIntroducer() {
   // and `int (*)()`.
   if (!BeforeRParen || !BeforeRParen->isOneOf(tok::greater, tok::r_paren))
 return false;
+} else if (Previous->is(tok::star)) {
+  Previous = Previous->getPreviousNonComment();
+}
+if (Previous && Previous->Tok.getIdentifierInfo() &&
+!Previous->isOneOf(tok::kw_return, tok::kw_co_await, tok::kw_co_yield,
+   tok::kw_co_return)) {
+  return false;
 }
   }
   if (LeftSquare->isCppStructuredBinding(IsCpp))

diff  --git a/clang/unittests/Format/TokenAnnotatorTest.cpp 
b/clang/unittests/Format/TokenAnnotatorTest.cpp
index 0a3dc946e8c1c..259d7e54133a1 100644
--- a/clang/unittests/Format/TokenAnnotatorTest.cpp
+++ b/clang/unittests/Format/TokenAnnotatorTest.cpp
@@ -2229,6 +2229,12 @@ TEST_F(TokenAnnotatorTest, UnderstandsLambdas) {
   ASSERT_EQ(Tokens.size(), 21u) << Tokens;
   EXPECT_TOKEN(Tokens[11], tok::l_square, TT_LambdaLSquare);
   EXPECT_TOKEN(Tokens[13], tok::l_brace, TT_LambdaLBrace);
+
+  Tokens = annotate("SomeFunction({[]() -> int *[] { return {}; }});");
+  ASSERT_EQ(Tokens.size(), 22u) << Tokens;
+  EXPECT_TOKEN(Tokens[3], tok::l_square, TT_LambdaLSquare);
+  EXPECT_TOKEN(Tokens[5], tok::l_paren, TT_LambdaDefinitionLParen);
+  EXPECT_TOKEN(Tokens[10], tok::l_square, TT_ArraySubscriptLSquare);
 }
 
 TEST_F(TokenAnnotato

[llvm-branch-commits] [lld] d1e2f89 - [LLD] [COFF] Fix symbol names for import thunks (#160694)

2025-10-01 Thread Douglas Yung via llvm-branch-commits

Author: Martin Storsjö
Date: 2025-10-01T15:13:48Z
New Revision: d1e2f8916128c8c8f402565b0612f6b6e5566702

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

LOG: [LLD] [COFF] Fix symbol names for import thunks (#160694)

9cc9efc483339ece1d52923569bb755db42b69f3 changed LLD to use a
StringTableBuilder for optimizing the string table, used for long
section and symbol names.

That commit had a bug, where the symbol table entry for an import thunk
with a long symbol name wouldn't get fetched from the
StringTableBuilder, if the base symbol name (without the "__imp_"
prefix) wasn't over 8 chars.

This should fix issues with Go, which errors out on reading the
executables with a broken symbol table, as noted in
https://github.com/mstorsjo/llvm-mingw/issues/518 and
https://github.com/golang/go/issues/75219.

(cherry picked from commit 0d6af2db6cd9c964ff300e5b5246c070a57d45e2)

Added: 


Modified: 
lld/COFF/Writer.cpp
lld/test/COFF/strtab.s

Removed: 




diff  --git a/lld/COFF/Writer.cpp b/lld/COFF/Writer.cpp
index 076561807af47..ef9d051bf976e 100644
--- a/lld/COFF/Writer.cpp
+++ b/lld/COFF/Writer.cpp
@@ -1553,7 +1553,7 @@ void Writer::createSymbolAndStringTable() {
 dthunk->wrappedSym->writtenToSymtab = true;
 if (std::optional sym =
 createSymbol(dthunk->wrappedSym)) {
-  if (d->getName().size() > COFF::NameSize)
+  if (dthunk->wrappedSym->getName().size() > COFF::NameSize)
 longNameSymbols.emplace_back(outputSymtab.size(),
  dthunk->wrappedSym->getName());
   outputSymtab.push_back(*sym);

diff  --git a/lld/test/COFF/strtab.s b/lld/test/COFF/strtab.s
index fbdd8df52d540..9edc13e19e825 100644
--- a/lld/test/COFF/strtab.s
+++ b/lld/test/COFF/strtab.s
@@ -1,17 +1,32 @@
 # REQUIRES: x86
 # RUN: llvm-mc -triple=x86_64-windows-msvc %s -filetype=obj -o %t.obj
-# RUN: lld-link -out:%t.exe -entry:main %t.obj -debug:dwarf
+# RUN: lld-link -machine:x64 -def:%S/Inputs/library.def -implib:%t.lib
+# RUN: lld-link -out:%t.exe -entry:main %t.obj %t.lib -debug:dwarf
 # RUN: llvm-readobj --string-table %t.exe | FileCheck %s
+# RUN: llvm-nm %t.exe | FileCheck %s --check-prefix=SYMBOLS
+
+# Note, for this test to have the intended test coverage, the imported symbol
+# "function" needs to be such that the symbol name itself is <= 8 chars, while
+# "__imp_"+name is >8 chars.
 
 # CHECK:  StringTable {
-# CHECK-NEXT:   Length: 87
+# CHECK-NEXT:   Length: 102
 # CHECK-NEXT:   [ 4] .debug_abbrev
 # CHECK-NEXT:   [12] .debug_line
 # CHECK-NEXT:   [1e] long_name_symbolz
 # CHECK-NEXT:   [30] .debug_abbrez
-# CHECK-NEXT:   [3e] __impl_long_name_symbolA
+# CHECK-NEXT:   [3e] __imp_function
+# CHECK-NEXT:   [4d] __impl_long_name_symbolA
 # CHECK-NEXT: }
 
+# SYMBOLS:  140001000 N .debug_abbrez
+# SYMBOLS-NEXT: 140002070 R __imp_function
+# SYMBOLS-NEXT: 140001000 t __impl_long_name_symbolA
+# SYMBOLS-NEXT: 140001010 T function
+# SYMBOLS-NEXT: 140001000 t long_name_symbolA
+# SYMBOLS-NEXT: 140001000 t long_name_symbolz
+# SYMBOLS-NEXT: 140001000 T main
+# SYMBOLS-NEXT: 140001000 t name_symbolA
 
 .global main
 .text
@@ -21,6 +36,7 @@ long_name_symbolA:
 __impl_long_name_symbolA:
 name_symbolA:
 .debug_abbrez:
+  call function
   ret
 
 .section.debug_abbrev,"dr"



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


[llvm-branch-commits] [llvm] 559d966 - [Mips] Fix atomic min/max generate mips4 instructions when compiling for mips2 (#159717)

2025-10-01 Thread Douglas Yung via llvm-branch-commits

Author: yingopq
Date: 2025-10-01T15:15:58Z
New Revision: 559d966bcb54e54d03ff29a2086cbc0f15910683

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

LOG: [Mips] Fix atomic min/max generate mips4 instructions when compiling for 
mips2 (#159717)

Modify instr movn/movz to mixture of beq, move, and sc.

Because atomic-min-max.ll test broken on the expensive builder, I revert
https://github.com/llvm/llvm-project/pull/149983 and resubmit this PR.
The broken reason:
  In i16/i8 function expandAtomicBinOpSubword, we use two successor
after loop2MBB, one does not specify the second parameter, the other
use BranchProbability::getOne() that means 100% probability. This is
contradictory. And the second successor is also specified incorrectly.

The changess:
* llvm/lib/Target/Mips/MipsExpandPseudo.cpp:
  Change loop2MBB`s second successor to correct one and delete the
second parameter BranchProbability::getOne().
* llvm/test/CodeGen/Mips/atomic-min-max.ll:
  Add -verify-machineinstrs option in RUN command;
  Modify i16 test and i8 test according to the changes.

Fix #145411.

(cherry picked from commit 114b3b8b04fe5aae4143e30078637015a9e077ce)

Added: 


Modified: 
llvm/lib/Target/Mips/MipsExpandPseudo.cpp
llvm/test/CodeGen/Mips/atomic-min-max.ll

Removed: 




diff  --git a/llvm/lib/Target/Mips/MipsExpandPseudo.cpp 
b/llvm/lib/Target/Mips/MipsExpandPseudo.cpp
index 34ff41f6e02da..78f2e5db40f9d 100644
--- a/llvm/lib/Target/Mips/MipsExpandPseudo.cpp
+++ b/llvm/lib/Target/Mips/MipsExpandPseudo.cpp
@@ -432,13 +432,24 @@ bool MipsExpandPseudo::expandAtomicBinOpSubword(
   Register OldVal = I->getOperand(6).getReg();
   Register BinOpRes = I->getOperand(7).getReg();
   Register StoreVal = I->getOperand(8).getReg();
+  bool NoMovnInstr = (IsMin || IsMax) && !STI->hasMips4() && !STI->hasMips32();
 
   const BasicBlock *LLVM_BB = BB.getBasicBlock();
   MachineBasicBlock *loopMBB = MF->CreateMachineBasicBlock(LLVM_BB);
+  MachineBasicBlock *loop1MBB = nullptr;
+  MachineBasicBlock *loop2MBB = nullptr;
+  if (NoMovnInstr) {
+loop1MBB = MF->CreateMachineBasicBlock(LLVM_BB);
+loop2MBB = MF->CreateMachineBasicBlock(LLVM_BB);
+  }
   MachineBasicBlock *sinkMBB = MF->CreateMachineBasicBlock(LLVM_BB);
   MachineBasicBlock *exitMBB = MF->CreateMachineBasicBlock(LLVM_BB);
   MachineFunction::iterator It = ++BB.getIterator();
   MF->insert(It, loopMBB);
+  if (NoMovnInstr) {
+MF->insert(It, loop1MBB);
+MF->insert(It, loop2MBB);
+  }
   MF->insert(It, sinkMBB);
   MF->insert(It, exitMBB);
 
@@ -446,9 +457,19 @@ bool MipsExpandPseudo::expandAtomicBinOpSubword(
   exitMBB->transferSuccessorsAndUpdatePHIs(&BB);
 
   BB.addSuccessor(loopMBB, BranchProbability::getOne());
-  loopMBB->addSuccessor(sinkMBB);
-  loopMBB->addSuccessor(loopMBB);
-  loopMBB->normalizeSuccProbs();
+  if (NoMovnInstr) {
+loopMBB->addSuccessor(loop1MBB);
+loopMBB->addSuccessor(loop2MBB);
+  } else {
+loopMBB->addSuccessor(sinkMBB);
+loopMBB->addSuccessor(loopMBB);
+loopMBB->normalizeSuccProbs();
+  }
+  if (NoMovnInstr) {
+loop1MBB->addSuccessor(loop2MBB);
+loop2MBB->addSuccessor(loopMBB);
+loop2MBB->addSuccessor(sinkMBB);
+  }
 
   BuildMI(loopMBB, DL, TII->get(LL), OldVal).addReg(Ptr).addImm(0);
   if (IsNand) {
@@ -525,7 +546,7 @@ bool MipsExpandPseudo::expandAtomicBinOpSubword(
   BuildMI(loopMBB, DL, TII->get(OR), BinOpRes)
   .addReg(BinOpRes)
   .addReg(Scratch4);
-} else {
+} else if (STI->hasMips4() || STI->hasMips32()) {
   // max: move BinOpRes, StoreVal
   //  movn BinOpRes, Incr, Scratch4, BinOpRes
   // min: move BinOpRes, StoreVal
@@ -537,12 +558,59 @@ bool MipsExpandPseudo::expandAtomicBinOpSubword(
   .addReg(Incr)
   .addReg(Scratch4)
   .addReg(BinOpRes);
+} else {
+  // if min:
+  // loopMBB:  move BinOpRes, StoreVal
+  //   beq Scratch4, 0, loop1MBB
+  //   j loop2MBB
+  // loop1MBB: move BinOpRes, Incr
+  // loop2MBB: and BinOpRes, BinOpRes, Mask
+  //   and StoreVal, OlddVal, Mask2
+  //   or StoreVal, StoreVal, BinOpRes
+  //   StoreVal = sc StoreVal, 0(Ptr)
+  //   beq StoreVal, zero, loopMBB
+  //
+  // if max:
+  // loopMBB:  move BinOpRes, Incr
+  //   beq Scratch4, 0, loop1MBB
+  //   j loop2MBB
+  // loop1MBB: move BinOpRes, StoreVal
+  // loop2MBB: and BinOpRes, BinOpRes, Mask
+  //   and StoreVal, OlddVal, Mask2
+  //   or StoreVal, StoreVal, BinOpRes
+  //   StoreVal = sc StoreVal, 0(Ptr)
+  //   beq StoreVal, zero, loopMBB
+  if (IsMin) {
+BuildMI(loopMBB, DL, TII->get(OR), BinOpRes)
+