[llvm-branch-commits] [mlir] [mlir][Transforms] Dialect conversion: Build unresolved materialization for replaced ops (PR #101514)

2024-08-03 Thread Matthias Springer via llvm-branch-commits

https://github.com/matthias-springer updated 
https://github.com/llvm/llvm-project/pull/101514

>From 2d9d1281db99061b212259a60a8bffdfdc800447 Mon Sep 17 00:00:00 2001
From: Matthias Springer 
Date: Thu, 1 Aug 2024 18:24:56 +0200
Subject: [PATCH] [mlir][Transforms] Dialect conversion: Build unresolved
 materialization for replaced ops

When inserting an argument/source/target materialization, the dialect 
conversion framework first inserts a "dummy" `unrealized_conversion_cast` op 
(during the rewrite process) and then (in the "finialize" phase) replaces these 
cast ops with the IR generated by the type converter callback.

This is the case for all materializations, except when ops are being replaced 
with values that have a different type. In that case, the dialect conversion 
currently directly emits a source materialization. This commit changes the 
implementation, such that a temporary `unrealized_conversion_cast` is also 
inserted in this case.

This commit simplifies the code base: all materializations now happen in 
`legalizeUnresolvedMaterialization`. This commit makes it possible to decouple 
source/target/argument materializations from the dialect conversion (to reduce 
the complexity of the code base). Such materializations can then also be 
optional. This will be implemented in a follow-up commit.
---
 .../Transforms/Utils/DialectConversion.cpp| 126 +++---
 .../VectorToSPIRV/vector-to-spirv.mlir|   4 +-
 .../Transforms/finalizing-bufferize.mlir  |   3 +-
 .../test-legalize-type-conversion.mlir|  11 +-
 4 files changed, 57 insertions(+), 87 deletions(-)

diff --git a/mlir/lib/Transforms/Utils/DialectConversion.cpp 
b/mlir/lib/Transforms/Utils/DialectConversion.cpp
index 8f9b21b7ee1e5..b0b5a8247b53f 100644
--- a/mlir/lib/Transforms/Utils/DialectConversion.cpp
+++ b/mlir/lib/Transforms/Utils/DialectConversion.cpp
@@ -2348,6 +2348,12 @@ struct OperationConverter {
   legalizeConvertedArgumentTypes(ConversionPatternRewriter &rewriter,
  ConversionPatternRewriterImpl &rewriterImpl);
 
+  /// Legalize the types of converted op results.
+  LogicalResult legalizeConvertedOpResultTypes(
+  ConversionPatternRewriter &rewriter,
+  ConversionPatternRewriterImpl &rewriterImpl,
+  DenseMap> &inverseMapping);
+
   /// Legalize any unresolved type materializations.
   LogicalResult legalizeUnresolvedMaterializations(
   ConversionPatternRewriter &rewriter,
@@ -2359,14 +2365,6 @@ struct OperationConverter {
   legalizeErasedResult(Operation *op, OpResult result,
ConversionPatternRewriterImpl &rewriterImpl);
 
-  /// Legalize an operation result that was replaced with a value of a 
different
-  /// type.
-  LogicalResult legalizeChangedResultType(
-  Operation *op, OpResult result, Value newValue,
-  const TypeConverter *replConverter, ConversionPatternRewriter &rewriter,
-  ConversionPatternRewriterImpl &rewriterImpl,
-  const DenseMap> &inverseMapping);
-
   /// Dialect conversion configuration.
   ConversionConfig config;
 
@@ -2459,10 +2457,42 @@ OperationConverter::finalize(ConversionPatternRewriter 
&rewriter) {
 return failure();
   DenseMap> inverseMapping =
   rewriterImpl.mapping.getInverse();
+  if (failed(legalizeConvertedOpResultTypes(rewriter, rewriterImpl,
+inverseMapping)))
+return failure();
   if (failed(legalizeUnresolvedMaterializations(rewriter, rewriterImpl,
 inverseMapping)))
 return failure();
+  return success();
+}
 
+/// Finds a user of the given value, or of any other value that the given value
+/// replaced, that was not replaced in the conversion process.
+static Operation *findLiveUserOfReplaced(
+Value initialValue, ConversionPatternRewriterImpl &rewriterImpl,
+const DenseMap> &inverseMapping) {
+  SmallVector worklist(1, initialValue);
+  while (!worklist.empty()) {
+Value value = worklist.pop_back_val();
+
+// Walk the users of this value to see if there are any live users that
+// weren't replaced during conversion.
+auto liveUserIt = llvm::find_if_not(value.getUsers(), [&](Operation *user) 
{
+  return rewriterImpl.isOpIgnored(user);
+});
+if (liveUserIt != value.user_end())
+  return *liveUserIt;
+auto mapIt = inverseMapping.find(value);
+if (mapIt != inverseMapping.end())
+  worklist.append(mapIt->second);
+  }
+  return nullptr;
+}
+
+LogicalResult OperationConverter::legalizeConvertedOpResultTypes(
+ConversionPatternRewriter &rewriter,
+ConversionPatternRewriterImpl &rewriterImpl,
+DenseMap> &inverseMapping) {
   // Process requested operation replacements.
   for (unsigned i = 0; i < rewriterImpl.rewrites.size(); ++i) {
 auto *opReplacement =
@@ -2485,14 +2515,21 @@ OperationConverter::finalize(ConversionPatternRewriter 
&rewriter) {
   if (result.getType() == newValue.getT

[llvm-branch-commits] [libcxx] [libc++][format][2/7] Optimizes c-string arguments. (PR #101805)

2024-08-03 Thread Mark de Wever via llvm-branch-commits

https://github.com/mordante created 
https://github.com/llvm/llvm-project/pull/101805

The formatter specializations for _CharT* and const _CharT* typically write all 
elements in a loop. This format's internal functions are optimized for larger 
writes.

Instead of writing one element at a time conversion the range to a 
basic_string_view and write that instead.

For C string of 6 characters this is a bit slower, but for 60 characters it's 
faster. The improvements for back_inserter> are not as great 
as the others; it just gets as slow as basic_string_view<_CharT>.

Before
---
Benchmark 
Time CPU   Iterations
---
BM_sprintf/C string len = 64.81 
ns 4.80 ns145890280
BM_format/C string len = 6 52.6 
ns 52.4 ns 13252327
BM_format_to_back_inserter/C string len = 6   53.0 
ns 52.8 ns 13262680
BM_format_to_back_inserter>/C string len = 6 69.7 
ns 69.6 ns 10045636
BM_format_to_back_inserter>/C string len = 6   148 
ns  148 ns  4729368
BM_format_to_back_inserter>/C string len = 6127 
ns  126 ns  5538441
BM_format_to_iterator/ C string len = 642.9 
ns 42.8 ns 16367158
BM_format_to_iterator/ C string len = 6   43.5 
ns 43.4 ns 16141644
BM_format_to_iterator/ C string len = 6   42.9 
ns 42.8 ns 16366718
BM_format_to_iterator/ C string len = 647.8 
ns 47.7 ns 14686488
BM_format/string len = 6   55.3 
ns 55.2 ns 12696889
BM_format_to_back_inserter/string len = 6 55.4 
ns 55.2 ns 12660731
BM_format_to_back_inserter>/string len = 6   70.7 
ns 70.5 ns  9927313
BM_format_to_back_inserter>/string len = 6 153 
ns  153 ns  4573936
BM_format_to_back_inserter>/string len = 6  128 
ns  128 ns  5486033
BM_format_to_iterator/ string len = 6  44.6 
ns 44.5 ns 15758122
BM_format_to_iterator/ string len = 6 44.7 
ns 44.6 ns 15690226
BM_format_to_iterator/ string len = 6 44.3 
ns 44.2 ns 15715898
BM_format_to_iterator/ string len = 6  50.3 
ns 50.1 ns 13958635
BM_format/string_view len = 6  54.2 
ns 54.1 ns 12929525
BM_format_to_back_inserter/string_view len = 654.3 
ns 54.1 ns 12929219
BM_format_to_back_inserter>/string_view len = 6  70.0 
ns 69.8 ns 10022355
BM_format_to_back_inserter>/string_view len = 6153 
ns  152 ns  4585749
BM_format_to_back_inserter>/string_view len = 6 128 
ns  128 ns  5489760
BM_format_to_iterator/ string_view len = 6 44.2 
ns 44.1 ns 15884839
BM_format_to_iterator/ string_view len = 644.8 
ns 44.6 ns 15664278
BM_format_to_iterator/ string_view len = 644.7 
ns 44.6 ns 15716983
BM_format_to_iterator/ string_view len = 6 50.3 
ns 50.2 ns 13936091
BM_sprintf/C string len = 60   4.16 
ns 4.15 ns168764227
BM_format/C string len = 60 169 
ns  169 ns  4144060
BM_format_to_back_inserter/C string len = 60   167 
ns  167 ns  4203915
BM_format_to_back_inserter>/C string len = 60 177 
ns  176 ns  3965619
BM_format_to_back_inserter>/C string len = 60  383 
ns  382 ns  1832531
BM_format_to_back_inserter>/C string len = 60  1270 
ns 1267 ns   552686
BM_format_to_iterator/ C string len = 60141 
ns  140 ns  4988441
BM_format_to_iterator/ C string len = 60   141 
ns  141 ns  4956101
BM_format_to_iterator/ C string len = 60   141 
ns  141 ns  4963443
BM_format_to_iterator/ C string len = 60144 
ns  143 ns  4893139
BM_format/string len = 60  73.4 
ns 73.2 ns  9548455
BM_format_to_back_inserter/string len = 6073.2 
ns 73.0 ns  9524524
BM_format_to_back_inserter>/

[llvm-branch-commits] [libcxx] [libc++][format][2/7] Optimizes c-string arguments. (PR #101805)

2024-08-03 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-libcxx

Author: Mark de Wever (mordante)


Changes

The formatter specializations for _CharT* and const _CharT* typically write all 
elements in a loop. This format's internal functions are optimized for larger 
writes.

Instead of writing one element at a time conversion the range to a 
basic_string_view and write that instead.

For C string of 6 characters this is a bit slower, but for 60 characters it's 
faster. The improvements for back_inserter> are 
not as great as the others; it just gets as slow as 
basic_string_view<_CharT>.

Before
---
Benchmark 
Time CPU   Iterations
---
BM_sprintf/C string len = 64.81 
ns 4.80 ns145890280
BM_format/C string len = 6 52.6 
ns 52.4 ns 13252327
BM_format_to_back_inserter/C string len = 6  
 53.0 ns 52.8 ns 13262680
BM_format_to_back_inserter>/C string len = 6  
   69.7 ns 69.6 ns 10045636
BM_format_to_back_inserter>/C string len = 6   
148 ns  148 ns  4729368
BM_format_to_back_inserter>/C string len = 6
127 ns  126 ns  5538441
BM_format_to_iterator/ C string len = 6   
 42.9 ns 42.8 ns 16367158
BM_format_to_iterator/ C string len = 6  
 43.5 ns 43.4 ns 16141644
BM_format_to_iterator/ C string len = 6  
 42.9 ns 42.8 ns 16366718
BM_format_to_iterator/ C string len = 6   
 47.8 ns 47.7 ns 14686488
BM_format/string len = 6   55.3 
ns 55.2 ns 12696889
BM_format_to_back_inserter/string len = 6
 55.4 ns 55.2 ns 12660731
BM_format_to_back_inserter>/string len = 6
   70.7 ns 70.5 ns  9927313
BM_format_to_back_inserter>/string len = 6 
153 ns  153 ns  4573936
BM_format_to_back_inserter>/string len = 6  
128 ns  128 ns  5486033
BM_format_to_iterator/ string len = 6 
 44.6 ns 44.5 ns 15758122
BM_format_to_iterator/ string len = 6
 44.7 ns 44.6 ns 15690226
BM_format_to_iterator/ string len = 6
 44.3 ns 44.2 ns 15715898
BM_format_to_iterator/ string len = 6 
 50.3 ns 50.1 ns 13958635
BM_format/string_view len = 6  54.2 
ns 54.1 ns 12929525
BM_format_to_back_inserter/string_view len = 6   
 54.3 ns 54.1 ns 12929219
BM_format_to_back_inserter>/string_view len = 6   
   70.0 ns 69.8 ns 10022355
BM_format_to_back_inserter>/string_view len = 6
153 ns  152 ns  4585749
BM_format_to_back_inserter>/string_view len = 6 
128 ns  128 ns  5489760
BM_format_to_iterator/ string_view len = 6
 44.2 ns 44.1 ns 15884839
BM_format_to_iterator/ string_view len = 6   
 44.8 ns 44.6 ns 15664278
BM_format_to_iterator/ string_view len = 6   
 44.7 ns 44.6 ns 15716983
BM_format_to_iterator/ string_view len = 6
 50.3 ns 50.2 ns 13936091
BM_sprintf/C string len = 60   4.16 
ns 4.15 ns168764227
BM_format/C string len = 60 169 
ns  169 ns  4144060
BM_format_to_back_inserter/C string len = 60 
  167 ns  167 ns  4203915
BM_format_to_back_inserter>/C string len = 60 
177 ns  176 ns  3965619
BM_format_to_back_inserter>/C string len = 60  
383 ns  382 ns  1832531
BM_format_to_back_inserter>/C string len = 60   
   1270 ns 1267 ns   552686
BM_format_to_iterator/ C string len = 60  
  141 ns  140 ns  4988441
BM_format_to_iterator/ C string len = 60 
  141 ns  141 ns 

[llvm-branch-commits] [libcxx] [libc++][format][3/7] Improves std::format performance. (PR #101817)

2024-08-03 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-libcxx

Author: Mark de Wever (mordante)


Changes

This changes the __output_buffer to a new structure. Since the other formatting 
fucntions std::format_to, std::format_to_n, and std::formatted_size still use 
the old codepaths the class is in a transition state. At the end of the series 
the class should be in its final state.

write_double_comparison:

Before

Benchmark  Time CPU   
Iterations

BM_sprintf   197 ns  196 ns 
 355
BM_to_string 218 ns  218 ns 
 3214000
BM_to_chars 42.4 ns 42.3 ns 
16575000
BM_to_chars_as_string   48.2 ns 48.1 ns 
14542000
BM_format175 ns  175 ns 
 400
BM_format_to_back_inserter  175 ns  175 
ns  3995000
BM_format_to_back_inserter>207 ns 
 206 ns  3393000
BM_format_to_back_inserter>  752 ns 
 750 ns   931000
BM_format_to_iterator/   161 ns  161 
ns  4345000
BM_format_to_iterator/  161 ns  161 
ns  4344000
BM_format_to_iterator/  162 ns  161 
ns  4344000

After

Benchmark  Time CPU   
Iterations

BM_sprintf   197 ns  197 ns 
 355
BM_to_string 219 ns  219 ns 
 3199000
BM_to_chars 42.4 ns 42.4 ns 
16554000
BM_to_chars_as_string   48.1 ns 48.1 ns 
14569000
BM_format167 ns  167 ns 
 4203000
BM_format_to_back_inserter  179 ns  179 
ns  392
BM_format_to_back_inserter>214 ns 
 214 ns  3274000
BM_format_to_back_inserter>  751 ns 
 751 ns   93
BM_format_to_iterator/   164 ns  164 
ns  4258000
BM_format_to_iterator/  165 ns  164 
ns  4247000
BM_format_to_iterator/  165 ns  165 
ns  4248000


Comparison
Benchmark   Time
 CPU  Time Old  Time New   CPU Old   CPU New

BM_sprintf   +0.0013 
+0.0028   197   197   196   197
BM_to_string +0.0023 
+0.0038   218   219   218   219
BM_to_chars  +0.0014 
+0.003042424242
BM_to_chars_as_string-0.0025 
-0.001048484848
BM_format-0.0476 
-0.0462   175   167   175   167
BM_format_to_back_inserter  +0.0190  
   +0.0205   175   179   175   179
BM_format_to_back_inserter>
+0.0348 +0.0363   207   214   206   214
BM_format_to_back_inserter>  
-0.0013 +0.0005   752   751   750   751
BM_format_to_iterator/   +0.0188  
   +0.0203   161   164   161   164
BM_format_to_iterator/  +0.0207  
   +0.0226   161   165   161   164
BM_format_to_iterator/  +0.0197  
   +0.0212   162   165   161   165
OVERALL_GEOMEAN  +0.0058 
+0.0074 0 0 0 0


write_int_comparison:

Before
-

[llvm-branch-commits] [libcxx] [libc++][format][3/7] Improves std::format performance. (PR #101817)

2024-08-03 Thread Mark de Wever via llvm-branch-commits


@@ -58,23 +58,156 @@ namespace __format {
 /// This helper is used together with the @ref back_insert_iterator to offer
 /// type-erasure for the formatting functions. This reduces the number to
 /// template instantiations.
+///
+/// The design of the class is being changed to improve performance and do some
+/// code cleanups.
+/// The original design (as shipped up to LLVM-19) uses the following design:
+/// - There is an external object that connects the buffer to the output.
+/// - The class constructor stores a function pointer to a grow function and a
+///   type-erased pointer to the object that does the grow.
+/// - When writing data to the buffer would exceed the external buffer's
+///   capacity it requests the external buffer to flush its contents.

mordante wrote:

Note the last patch in the series will remove this comment.
The implementation itself is in a transition state too, this also will be 
cleaned in the final patch of the series.

https://github.com/llvm/llvm-project/pull/101817
___
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] [libcxx] [libc++][format][3/7] Improves std::format performance. (PR #101817)

2024-08-03 Thread Mark de Wever via llvm-branch-commits

https://github.com/mordante updated 
https://github.com/llvm/llvm-project/pull/101817

>From a3acb85e3fd8dd9bb4320bf028d9773d018f27b4 Mon Sep 17 00:00:00 2001
From: Mark de Wever 
Date: Sat, 30 Mar 2024 17:35:56 +0100
Subject: [PATCH] [libc++][format][3/7] Improves std::format performance.

This changes the __output_buffer to a new structure. Since the other
formatting fucntions std::format_to, std::format_to_n, and
std::formatted_size still use the old codepaths the class is in a
transition state. At the end of the series the class should be in its
final state.

write_double_comparison:

Before

Benchmark  Time CPU   
Iterations

BM_sprintf   197 ns  196 ns 
 355
BM_to_string 218 ns  218 ns 
 3214000
BM_to_chars 42.4 ns 42.3 ns 
16575000
BM_to_chars_as_string   48.2 ns 48.1 ns 
14542000
BM_format175 ns  175 ns 
 400
BM_format_to_back_inserter  175 ns  175 ns 
 3995000
BM_format_to_back_inserter>207 ns  206 ns 
 3393000
BM_format_to_back_inserter>  752 ns  750 ns 
  931000
BM_format_to_iterator/   161 ns  161 ns 
 4345000
BM_format_to_iterator/  161 ns  161 ns 
 4344000
BM_format_to_iterator/  162 ns  161 ns 
 4344000

After

Benchmark  Time CPU   
Iterations

BM_sprintf   197 ns  197 ns 
 355
BM_to_string 219 ns  219 ns 
 3199000
BM_to_chars 42.4 ns 42.4 ns 
16554000
BM_to_chars_as_string   48.1 ns 48.1 ns 
14569000
BM_format167 ns  167 ns 
 4203000
BM_format_to_back_inserter  179 ns  179 ns 
 392
BM_format_to_back_inserter>214 ns  214 ns 
 3274000
BM_format_to_back_inserter>  751 ns  751 ns 
  93
BM_format_to_iterator/   164 ns  164 ns 
 4258000
BM_format_to_iterator/  165 ns  164 ns 
 4247000
BM_format_to_iterator/  165 ns  165 ns 
 4248000

Comparison
Benchmark   Time
 CPU  Time Old  Time New   CPU Old   CPU New

BM_sprintf   +0.0013 
+0.0028   197   197   196   197
BM_to_string +0.0023 
+0.0038   218   219   218   219
BM_to_chars  +0.0014 
+0.003042424242
BM_to_chars_as_string-0.0025 
-0.001048484848
BM_format-0.0476 
-0.0462   175   167   175   167
BM_format_to_back_inserter  +0.0190 
+0.0205   175   179   175   179
BM_format_to_back_inserter>+0.0348 
+0.0363   207   214   206   214
BM_format_to_back_inserter>  -0.0013 
+0.0005   752   751   750   751
BM_format_to_iterator/   +0.0188 
+0.0203   161   164   161   164
BM_format_to_iterator/  +0.0207 
+0.0226   161   165   161   164
BM_format_to_iterator/  +0.0197 
+0.0212   162   165   161   165
OVERALL_GEOMEAN  +0.0058 
+0.0074 0 0 0 0

write_int_comparison:

Before

Benchmar

[llvm-branch-commits] [libcxx] [libc++][format][4/7] Improves std::format_to performance. (PR #101823)

2024-08-03 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-libcxx

Author: Mark de Wever (mordante)


Changes

This changes the __output_buffer users for format_to to the new structure. It 
also uses the new allocating buffer to improve performance.

write_double_comparison:

Before

Benchmark  Time CPU   
Iterations

BM_sprintf   197 ns  197 ns 
 3537000
BM_to_string 219 ns  219 ns 
 320
BM_to_chars 42.3 ns 42.3 ns 
1649
BM_to_chars_as_string   48.1 ns 48.1 ns 
14508000
BM_format167 ns  167 ns 
 4207000
BM_format_to_back_inserter  179 ns  179 
ns  3914000
BM_format_to_back_inserter>216 ns 
 216 ns  3234000
BM_format_to_back_inserter>  752 ns 
 752 ns   932000
BM_format_to_iterator/   165 ns  165 
ns  4257000
BM_format_to_iterator/  165 ns  165 
ns  4251000
BM_format_to_iterator/  165 ns  165 
ns  4254000

After

Benchmark  Time CPU   
Iterations

BM_sprintf   197 ns  197 ns 
 3548000
BM_to_string 219 ns  219 ns 
 3203000
BM_to_chars 42.3 ns 42.3 ns 
1654
BM_to_chars_as_string   48.2 ns 48.2 ns 
14532000
BM_format167 ns  167 ns 
 419
BM_format_to_back_inserter  176 ns  176 
ns  3959000
BM_format_to_back_inserter>211 ns 
 211 ns  3312000
BM_format_to_back_inserter>  752 ns 
 752 ns   934000
BM_format_to_iterator/   162 ns  162 
ns  4313000
BM_format_to_iterator/  162 ns  162 
ns  4307000
BM_format_to_iterator/  162 ns  162 
ns  4308000

Comparison
Benchmark   Time
 CPU  Time Old  Time New   CPU Old   CPU New

BM_sprintf   +0.0003 
+0.0002   197   197   197   197
BM_to_string -0.0004 
-0.0004   219   219   219   219
BM_to_chars  +0.0003 
+0.000342424242
BM_to_chars_as_string+0.0004 
+0.000448484848
BM_format+0.0016 
+0.0016   167   167   167   167
BM_format_to_back_inserter  -0.0128  
   -0.0127   179   176   179   176
BM_format_to_back_inserter>
-0.0216 -0.0216   216   211   216   211
BM_format_to_back_inserter>  
-0.0008 -0.0008   752   752   752   752
BM_format_to_iterator/   -0.0137  
   -0.0137   165   162   165   162
BM_format_to_iterator/  -0.0154  
   -0.0153   165   162   165   162
BM_format_to_iterator/  -0.0138  
   -0.0138   165   162   165   162
OVERALL_GEOMEAN  -0.0069 
-0.0069 0 0 0 0


write_int_comparison:

Before

Benchmark  Time CPU   
Iterations

[llvm-branch-commits] [clang] release/19.x: [libclang] Fix symbol version of `getBinaryOpcode` functions (#101820) (PR #101824)

2024-08-03 Thread via llvm-branch-commits

https://github.com/llvmbot milestoned 
https://github.com/llvm/llvm-project/pull/101824
___
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] release/19.x: [libclang] Fix symbol version of `getBinaryOpcode` functions (#101820) (PR #101824)

2024-08-03 Thread via llvm-branch-commits

https://github.com/llvmbot created 
https://github.com/llvm/llvm-project/pull/101824

Backport 2bae7aeab42062e61d6f9d6458660d4a5646f7af

Requested by: @Endilll

>From 607f955c9551a6a37592c6ee0e9ec8684bb5b3eb Mon Sep 17 00:00:00 2001
From: Jannick Kremer <51118500+deinalptr...@users.noreply.github.com>
Date: Sat, 3 Aug 2024 14:56:54 +0100
Subject: [PATCH] [libclang] Fix symbol version of `getBinaryOpcode` functions
 (#101820)

#98489 resurrected an [old patch](https://reviews.llvm.org/D10833) that
was adding new libclang functions. That PR got merged with old `LLVM_13`
symbol versions for new functions. This patch fixes this oversight.

(cherry picked from commit 2bae7aeab42062e61d6f9d6458660d4a5646f7af)
---
 clang/tools/libclang/libclang.map | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/clang/tools/libclang/libclang.map 
b/clang/tools/libclang/libclang.map
index 91c329b5765d4..371fe512ce71c 100644
--- a/clang/tools/libclang/libclang.map
+++ b/clang/tools/libclang/libclang.map
@@ -54,8 +54,6 @@ LLVM_13 {
 clang_Cursor_Evaluate;
 clang_Cursor_getArgument;
 clang_Cursor_getBriefCommentText;
-clang_Cursor_getBinaryOpcode;
-clang_Cursor_getBinaryOpcodeStr;
 clang_Cursor_getCXXManglings;
 clang_Cursor_getCommentRange;
 clang_Cursor_getMangling;
@@ -430,6 +428,12 @@ LLVM_17 {
 clang_getCursorUnaryOperatorKind;
 };
 
+LLVM_19 {
+  global:
+clang_Cursor_getBinaryOpcode;
+clang_Cursor_getBinaryOpcodeStr;
+};
+
 # Example of how to add a new symbol version entry.  If you do add a new symbol
 # version, please update the example to depend on the version you added.
 # LLVM_X {

___
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] release/19.x: [libclang] Fix symbol version of `getBinaryOpcode` functions (#101820) (PR #101824)

2024-08-03 Thread via llvm-branch-commits

llvmbot wrote:

@Endilll What do you think about merging this PR to the release branch?

https://github.com/llvm/llvm-project/pull/101824
___
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] release/19.x: [libclang] Fix symbol version of `getBinaryOpcode` functions (#101820) (PR #101824)

2024-08-03 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: None (llvmbot)


Changes

Backport 2bae7aeab42062e61d6f9d6458660d4a5646f7af

Requested by: @Endilll

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


1 Files Affected:

- (modified) clang/tools/libclang/libclang.map (+6-2) 


``diff
diff --git a/clang/tools/libclang/libclang.map 
b/clang/tools/libclang/libclang.map
index 91c329b5765d4..371fe512ce71c 100644
--- a/clang/tools/libclang/libclang.map
+++ b/clang/tools/libclang/libclang.map
@@ -54,8 +54,6 @@ LLVM_13 {
 clang_Cursor_Evaluate;
 clang_Cursor_getArgument;
 clang_Cursor_getBriefCommentText;
-clang_Cursor_getBinaryOpcode;
-clang_Cursor_getBinaryOpcodeStr;
 clang_Cursor_getCXXManglings;
 clang_Cursor_getCommentRange;
 clang_Cursor_getMangling;
@@ -430,6 +428,12 @@ LLVM_17 {
 clang_getCursorUnaryOperatorKind;
 };
 
+LLVM_19 {
+  global:
+clang_Cursor_getBinaryOpcode;
+clang_Cursor_getBinaryOpcodeStr;
+};
+
 # Example of how to add a new symbol version entry.  If you do add a new symbol
 # version, please update the example to depend on the version you added.
 # LLVM_X {

``




https://github.com/llvm/llvm-project/pull/101824
___
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] release/19.x: [libclang] Fix symbol version of `getBinaryOpcode` functions (#101820) (PR #101824)

2024-08-03 Thread via llvm-branch-commits

github-actions[bot] wrote:

⚠️ We detected that you are using a GitHub private e-mail address to contribute 
to the repo. Please turn off [Keep my email addresses 
private](https://github.com/settings/emails) setting in your account. See 
[LLVM 
Discourse](https://discourse.llvm.org/t/hidden-emails-on-github-should-we-do-something-about-it)
 for more information.

https://github.com/llvm/llvm-project/pull/101824
___
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] release/19.x: [libclang] Fix symbol version of `getBinaryOpcode` functions (#101820) (PR #101824)

2024-08-03 Thread Vlad Serebrennikov via llvm-branch-commits

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

I don't consider this critical, but I can see this becoming a source of 
confusion for a long time.

https://github.com/llvm/llvm-project/pull/101824
___
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] [libcxx] [libc++][format][5/7] Improve std::format_to_n (PR #101831)

2024-08-03 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-libcxx

Author: Mark de Wever (mordante)


Changes

__format_to_n_buffer is not used in the public library interface so the changes 
are not an ABI break.

Before
Benchmark   
Time CPU  Time Old  Time New   CPU Old   CPU New

BM_format_to_n_string_back_inserter/1
   -0.0160 -0.0136595859
58
BM_format_to_n_string_back_inserter/2
   +0.0020 +0.0044585958
59
BM_format_to_n_string_back_inserter/4
   +0.0084 +0.0109585958
59
BM_format_to_n_string_back_inserter/8
   -0.0014 +0.0014595958
59
BM_format_to_n_string_back_inserter/16   
   -0.0042 -0.0018595859
58
BM_format_to_n_string_back_inserter/32   
   -0.0136 -0.0112787778
77
BM_format_to_n_string_back_inserter/64   
   -0.0096 -0.0072787777
77
BM_format_to_n_string_back_inserter/128  
   -0.1486 -0.1465917791
77
BM_format_to_n_string_back_inserter/256  
   -0.1215 -0.1191   10290   102
90
BM_format_to_n_string_back_inserter/512  
   -0.1412 -0.1391   158   136   158
   136
BM_format_to_n_string_back_inserter/1024 
   -0.1135 -0.1114   290   257   289
   257
BM_format_to_n_string_back_inserter/2048 
   -0.1551 -0.1530   489   413   488
   413
BM_format_to_n_string_back_inserter/4096 
   -0.1665 -0.1642   801   668   799
   668
BM_format_to_n_string_back_inserter/8192 
   -0.2301 -0.2282  1449  1116  1445
  1116
BM_format_to_n_string_back_inserter/16384
   -0.1988 -0.1965  2942  2357  2933
  2357
BM_format_to_n_string_back_inserter/32768
   -0.2129 -0.2109  5676  4467  5661
  4467
BM_format_to_n_string_back_inserter/65536
   -0.2469 -0.2449 12437  9366 12404
  9366
BM_format_to_n_string_back_inserter/131072   
   -0.2294 -0.2274 25855 19923 25787
 19923
BM_format_to_n_string_back_inserter/262144   
   -0.1906 -0.1885 52880 42798 52739
 42798
BM_format_to_n_string_back_inserter/524288   
   -0.1898 -0.1876107703 87261107410
 87257
BM_format_to_n_string_back_inserter/1048576  
   -0.2162 -0.2139231479181427230781
181426
BM_format_to_n_string_back_inserter>/1
 -0.0035 -0.0007727272  
  72
BM_format_to_n_string_back_inserter>/2
 +0.0104 +0.0128737372  
  73
BM_format_to_n_string_back_inserter>/4
 -0.0022 +0.0003747474  
  74
BM_format_to_n_string_back_inserter>/8
 +0.0092 +0.0116757675  
  76
BM_format_to_n_string_back_inserter>/16   
 -0.0019 +0.0005797979  
  79
BM_format_to_n_string_back_inserter>/32   
 +0.0168 +0.0195899088  
  90
BM_format_to_n_string_back_inserter>/64   
  

[llvm-branch-commits] [libcxx] [libc++][format][6/7] Optimizes formatted_size. (PR #101835)

2024-08-03 Thread Mark de Wever via llvm-branch-commits

https://github.com/mordante created 
https://github.com/llvm/llvm-project/pull/101835

__formatted_size_buffer is not used in the public library interface so the 
changes are not an ABI break.

Before

Benchmark  Time CPU   
Iterations UserCounters...

BM_formatted_size_string/147.6 ns 47.6 ns 
14729701 bytes_per_second=20.055Mi/s
BM_formatted_size_string/223.8 ns 23.8 ns 
29445832 bytes_per_second=80.1657Mi/s
BM_formatted_size_string/411.9 ns 11.9 ns 
58813944 bytes_per_second=320.771Mi/s
BM_formatted_size_string/85.95 ns 5.95 ns
117601928 bytes_per_second=1.25307Gi/s
BM_formatted_size_string/16   2.97 ns 2.97 ns
235800528 bytes_per_second=5.02342Gi/s
BM_formatted_size_string/32   1.49 ns 1.49 ns
471177152 bytes_per_second=20.0428Gi/s
BM_formatted_size_string/64  0.745 ns0.744 ns
942161408 bytes_per_second=80.1172Gi/s
BM_formatted_size_string/128 0.377 ns0.376 ns   
1861005568 bytes_per_second=316.85Gi/s
BM_formatted_size_string/256 0.200 ns0.200 ns   
3503415296 bytes_per_second=1.16508Ti/s
BM_formatted_size_string/512 0.111 ns0.110 ns   
6351184384 bytes_per_second=4.21671Ti/s
BM_formatted_size_string/10240.067 ns0.067 ns   
10441098240 bytes_per_second=13.9409Ti/s
BM_formatted_size_string/20480.045 ns0.045 ns   
15404886016 bytes_per_second=41.0182Ti/s
BM_formatted_size_string/40960.036 ns0.036 ns   
19634089984 bytes_per_second=104.431Ti/s
BM_formatted_size_string/81920.030 ns0.030 ns   
23265501184 bytes_per_second=247.504Ti/s
BM_formatted_size_string/16384   0.027 ns0.027 ns   
25556238336 bytes_per_second=545.066Ti/s
BM_formatted_size_string/32768   0.027 ns0.027 ns   
26036731904 bytes_per_second=1.08282Pi/s
BM_formatted_size_string/65536   0.027 ns0.027 ns   
26192379904 bytes_per_second=2.17753Pi/s
BM_formatted_size_string/131072  0.026 ns0.026 ns   
26622033920 bytes_per_second=4.4243Pi/s
BM_formatted_size_string/262144  0.027 ns0.027 ns   
25452085248 bytes_per_second=8.48295Pi/s
BM_formatted_size_string/524288  0.028 ns0.028 ns   
24593825792 bytes_per_second=16.3639Pi/s
BM_formatted_size_string/1048576 0.028 ns0.028 ns   
24775753728 bytes_per_second=32.8865Pi/s
BM_formatted_size_string/1 47.0 ns 46.9 ns 
14912646 bytes_per_second=81.3132Mi/s
BM_formatted_size_string/2 23.4 ns 23.3 ns 
29964298 bytes_per_second=326.845Mi/s
BM_formatted_size_string/4 11.7 ns 11.7 ns 
59734380 bytes_per_second=1.26993Gi/s
BM_formatted_size_string/8 5.84 ns 5.84 ns
120131824 bytes_per_second=5.10665Gi/s
BM_formatted_size_string/162.92 ns 2.92 ns
239874128 bytes_per_second=20.4273Gi/s
BM_formatted_size_string/321.48 ns 1.48 ns
473672928 bytes_per_second=80.6502Gi/s
BM_formatted_size_string/64   0.797 ns0.796 ns
877660480 bytes_per_second=299.351Gi/s
BM_formatted_size_string/128  0.450 ns0.449 ns   
1568318336 bytes_per_second=1.03679Ti/s
BM_formatted_size_string/256  0.273 ns0.273 ns   
2571588096 bytes_per_second=3.41553Ti/s
BM_formatted_size_string/512  0.181 ns0.181 ns   
3868106240 bytes_per_second=10.2834Ti/s
BM_formatted_size_string/1024 0.143 ns0.143 ns   
4902914048 bytes_per_second=26.0513Ti/s
BM_formatted_size_string/2048 0.121 ns0.121 ns   
5801660416 bytes_per_second=61.775Ti/s
BM_formatted_size_string/4096 0.110 ns0.110 ns   
6380191744 bytes_per_second=135.763Ti/s
BM_formatted_size_string/8192 0.107 ns0.107 ns   
6531432448 bytes_per_second=278.051Ti/s
BM_formatted_size_string/163840.107 ns0.107 ns   
6531842048 bytes_per_second=556.731Ti/s
BM_formatted_size_string/327680.106 ns0.105 ns   
6648430592 bytes_per_second=1.10374Pi/s
BM_formatted_size_string/655360.110 ns0.110 ns   
6352273408 bytes_per_second=2.11267Pi/s
BM_formatted_size_string/131072   0.114 ns0.114 ns   
6139805696 bytes_per_second=4.07511Pi/s
BM_formatted_size_string/262144   0.114 ns0.114 ns   
6169821184 bytes_per_second=8.20475Pi/s
BM_formatted_size_string/524288   0.114 ns0.113 ns   
6168248320 bytes_per_second=16.4288Pi/s
BM_formatted_size_string/1048576  0.120 ns0.120 ns   
5817499648 

[llvm-branch-commits] [libcxx] [libc++][format][6/7] Optimizes formatted_size. (PR #101835)

2024-08-03 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-libcxx

Author: Mark de Wever (mordante)


Changes

__formatted_size_buffer is not used in the public library interface so the 
changes are not an ABI break.

Before

Benchmark  Time CPU   
Iterations UserCounters...

BM_formatted_size_string/147.6 ns 47.6 ns   
  14729701 bytes_per_second=20.055Mi/s
BM_formatted_size_string/223.8 ns 23.8 ns   
  29445832 bytes_per_second=80.1657Mi/s
BM_formatted_size_string/411.9 ns 11.9 ns   
  58813944 bytes_per_second=320.771Mi/s
BM_formatted_size_string/85.95 ns 5.95 ns   
 117601928 bytes_per_second=1.25307Gi/s
BM_formatted_size_string/16   2.97 ns 2.97 ns   
 235800528 bytes_per_second=5.02342Gi/s
BM_formatted_size_string/32   1.49 ns 1.49 ns   
 471177152 bytes_per_second=20.0428Gi/s
BM_formatted_size_string/64  0.745 ns0.744 ns   
 942161408 bytes_per_second=80.1172Gi/s
BM_formatted_size_string/128 0.377 ns0.376 ns   
1861005568 bytes_per_second=316.85Gi/s
BM_formatted_size_string/256 0.200 ns0.200 ns   
3503415296 bytes_per_second=1.16508Ti/s
BM_formatted_size_string/512 0.111 ns0.110 ns   
6351184384 bytes_per_second=4.21671Ti/s
BM_formatted_size_string/10240.067 ns0.067 ns   
10441098240 bytes_per_second=13.9409Ti/s
BM_formatted_size_string/20480.045 ns0.045 ns   
15404886016 bytes_per_second=41.0182Ti/s
BM_formatted_size_string/40960.036 ns0.036 ns   
19634089984 bytes_per_second=104.431Ti/s
BM_formatted_size_string/81920.030 ns0.030 ns   
23265501184 bytes_per_second=247.504Ti/s
BM_formatted_size_string/16384   0.027 ns0.027 ns   
25556238336 bytes_per_second=545.066Ti/s
BM_formatted_size_string/32768   0.027 ns0.027 ns   
26036731904 bytes_per_second=1.08282Pi/s
BM_formatted_size_string/65536   0.027 ns0.027 ns   
26192379904 bytes_per_second=2.17753Pi/s
BM_formatted_size_string/131072  0.026 ns0.026 ns   
26622033920 bytes_per_second=4.4243Pi/s
BM_formatted_size_string/262144  0.027 ns0.027 ns   
25452085248 bytes_per_second=8.48295Pi/s
BM_formatted_size_string/524288  0.028 ns0.028 ns   
24593825792 bytes_per_second=16.3639Pi/s
BM_formatted_size_string/1048576 0.028 ns0.028 ns   
24775753728 bytes_per_second=32.8865Pi/s
BM_formatted_size_string/1 47.0 ns 46.9 ns   
  14912646 bytes_per_second=81.3132Mi/s
BM_formatted_size_string/2 23.4 ns 23.3 ns   
  29964298 bytes_per_second=326.845Mi/s
BM_formatted_size_string/4 11.7 ns 11.7 ns   
  59734380 bytes_per_second=1.26993Gi/s
BM_formatted_size_string/8 5.84 ns 5.84 ns   
 120131824 bytes_per_second=5.10665Gi/s
BM_formatted_size_string/162.92 ns 2.92 ns   
 239874128 bytes_per_second=20.4273Gi/s
BM_formatted_size_string/321.48 ns 1.48 ns   
 473672928 bytes_per_second=80.6502Gi/s
BM_formatted_size_string/64   0.797 ns0.796 ns   
 877660480 bytes_per_second=299.351Gi/s
BM_formatted_size_string/128  0.450 ns0.449 ns   
1568318336 bytes_per_second=1.03679Ti/s
BM_formatted_size_string/256  0.273 ns0.273 ns   
2571588096 bytes_per_second=3.41553Ti/s
BM_formatted_size_string/512  0.181 ns0.181 ns   
3868106240 bytes_per_second=10.2834Ti/s
BM_formatted_size_string/1024 0.143 ns0.143 ns   
4902914048 bytes_per_second=26.0513Ti/s
BM_formatted_size_string/2048 0.121 ns0.121 ns   
5801660416 bytes_per_second=61.775Ti/s
BM_formatted_size_string/4096 0.110 ns0.110 ns   
6380191744 bytes_per_second=135.763Ti/s
BM_formatted_size_string/8192 0.107 ns0.107 ns   
6531432448 bytes_per_second=278.051Ti/s
BM_formatted_size_string/163840.107 ns0.107 ns   
6531842048 bytes_per_second=556.731Ti/s
BM_formatted_size_string/327680.106 ns0.105 ns   
6648430592 bytes_per_second=1.10374Pi/s
BM_formatted_size_string/655360.110 ns0.110 ns   
6352273408 bytes_per_second=2.11267Pi/s
BM_formatted_size_string/131072   0.114 ns0.114 ns   
6139805696 bytes_per_second=4.07511P

[llvm-branch-commits] [clang] [llvm] release/19.x: Workflow fixes for building release binaries (PR #101791)

2024-08-03 Thread Tom Stellard via llvm-branch-commits

https://github.com/tstellar updated 
https://github.com/llvm/llvm-project/pull/101791

>From 3ec814d1bcb7064b907526937ae83f23657394af Mon Sep 17 00:00:00 2001
From: Tom Stellard 
Date: Thu, 1 Aug 2024 07:58:35 -0700
Subject: [PATCH 1/7] workflows: Fix libclc-tests

The old out-of-tree build configuration stopped working and
in tree builds are supported now, so we should use the in
tree configuration. The only downside is we can't run the tests any
more, but at least we will be able to test the build again.
---
 .github/workflows/llvm-project-tests.yml | 7 +++
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/.github/workflows/llvm-project-tests.yml 
b/.github/workflows/llvm-project-tests.yml
index 0a228c41f354e..17a54be16badc 100644
--- a/.github/workflows/llvm-project-tests.yml
+++ b/.github/workflows/llvm-project-tests.yml
@@ -131,6 +131,7 @@ jobs:
 -DCMAKE_BUILD_TYPE=Release \
 -DLLVM_ENABLE_ASSERTIONS=ON \
 -DLLDB_INCLUDE_TESTS=OFF \
+
-DLIBCLC_TARGETS_TO_BUILD="amdgcn--;amdgcn--amdhsa;r600--;nvptx--;nvptx64--;nvptx--nvidiacl;nvptx64--nvidiacl"
 \
 -DCMAKE_C_COMPILER_LAUNCHER=sccache \
 -DCMAKE_CXX_COMPILER_LAUNCHER=sccache \
 $extra_cmake_args \
@@ -142,8 +143,6 @@ jobs:
 env:
   LLVM_BUILDDIR: ${{ steps.build-llvm.outputs.llvm-builddir }}
 run: |
-  # Make sure all of LLVM libraries that llvm-config needs are built.
+  # The libclc tests don't have a generated check target so all we can
+  # do is build it.
   ninja -C "$LLVM_BUILDDIR"
-  cmake -G Ninja -S libclc -B libclc-build 
-DLLVM_DIR="$LLVM_BUILDDIR"/lib/cmake/llvm 
-DLIBCLC_TARGETS_TO_BUILD="amdgcn--;amdgcn--amdhsa;r600--;nvptx--;nvptx64--;nvptx--nvidiacl;nvptx64--nvidiacl"
-  ninja -C libclc-build
-  ninja -C libclc-build test

>From fdd961d5dbd68ca05e64b726e73a149ae67e680d Mon Sep 17 00:00:00 2001
From: Tom Stellard 
Date: Fri, 26 Jul 2024 11:26:34 -0700
Subject: [PATCH 2/7] Build release binaries for multiple targets (#98431)

This adds release binary builds for the 4 platforms currently supported
by the free GitHub Action runners:

* Linux x86_64
* Windows x86_64
* Mac x86_64
* Mac AArch64

The test stages for these are known to fail, but the creating and
upoading of the release binaries should pass.

(cherry picked from commit 247251aee0d4314385a3fea86e31484d3d792ffb)
---
 .github/workflows/release-binaries-all.yml|  94 
 .../release-binaries-save-stage/action.yml|  38 ++
 .../release-binaries-setup-stage/action.yml   |  59 +++
 .github/workflows/release-binaries.yml| 474 --
 .github/workflows/release-tasks.yml   |  10 +
 clang/cmake/caches/Release.cmake  |   6 +-
 6 files changed, 520 insertions(+), 161 deletions(-)
 create mode 100644 .github/workflows/release-binaries-all.yml
 create mode 100644 .github/workflows/release-binaries-save-stage/action.yml
 create mode 100644 .github/workflows/release-binaries-setup-stage/action.yml

diff --git a/.github/workflows/release-binaries-all.yml 
b/.github/workflows/release-binaries-all.yml
new file mode 100644
index 0..73c9d96946e33
--- /dev/null
+++ b/.github/workflows/release-binaries-all.yml
@@ -0,0 +1,94 @@
+name: Release Binaries All
+
+permissions:
+  contents: read # Default everything to read-only
+
+on:
+  workflow_dispatch:
+inputs:
+  release-version:
+description: 'Release Version'
+required: true
+type: string
+  upload:
+description: 'Upload binaries to the release page'
+required: true
+default: false
+type: boolean
+
+  workflow_call:
+inputs:
+  release-version:
+description: 'Release Version'
+required: true
+type: string
+  upload:
+description: 'Upload binaries to the release page'
+required: true
+default: false
+type: boolean
+
+  pull_request:
+types:
+  - opened
+  - synchronize
+  - reopened
+  # When a PR is closed, we still start this workflow, but then skip
+  # all the jobs, which makes it effectively a no-op.  The reason to
+  # do this is that it allows us to take advantage of concurrency groups
+  # to cancel in progress CI jobs whenever the PR is closed.
+  - closed
+paths:
+  - '.github/workflows/release-binaries-all.yml'
+  - '.github/workflows/release-binaries.yml'
+  - '.github/workflows/release-binaries-setup-stage/*'
+  - '.github/workflows/release-binaries-save-stage/*'
+
+concurrency:
+  group: ${{ github.workflow }}-${{ github.event.pull_request.number || 
'dispatch' }}
+  cancel-in-progress: True
+
+jobs:
+  setup-variables:
+if: >-
+  (github.event_name != 'pull_request' || github.event.action != 'closed')
+runs-on: ubuntu-22.04
+outputs:
+  release-version: ${{ steps.var

[llvm-branch-commits] [llvm] workflows: Re-implement the get-llvm-version action as a composite (PR #101554)

2024-08-03 Thread Tom Stellard via llvm-branch-commits

https://github.com/tstellar closed 
https://github.com/llvm/llvm-project/pull/101554
___
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] workflows: Re-implement the get-llvm-version action as a composite (PR #101554)

2024-08-03 Thread Tom Stellard via llvm-branch-commits

tstellar wrote:

Closed in favor of #101793

https://github.com/llvm/llvm-project/pull/101554
___
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] [NFC][asan] Track current dynamic init module (PR #101597)

2024-08-03 Thread Vitaly Buka via llvm-branch-commits

https://github.com/vitalybuka updated 
https://github.com/llvm/llvm-project/pull/101597


___
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] [NFC][asan] Track current dynamic init module (PR #101597)

2024-08-03 Thread Vitaly Buka via llvm-branch-commits

https://github.com/vitalybuka updated 
https://github.com/llvm/llvm-project/pull/101597


___
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] [asan] Optimize initialization order checking (PR #101837)

2024-08-03 Thread Vitaly Buka via llvm-branch-commits

https://github.com/vitalybuka created 
https://github.com/llvm/llvm-project/pull/101837

Before the patch each TU was executing pair
`__asan_before_dynamic_init` and
`__asan_after_dynamic_init`.

`__asan_before_dynamic_init` supports incremental
poisoning, but `__asan_after_dynamic_init`
unpoisons all globals, so
`__asan_before_dynamic_init` must repoison
everything again.

So it's O(N^2) where N is the number of globals
(or TUs). It can be expensive for large binaries.

The patch will make it O(N).

The patch requires LLD and platform with
SANITIZER_CAN_USE_PREINIT_ARRAY. For the rest it
continue to be O(N^2).



___
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] [asan] Optimize initialization order checking (PR #101837)

2024-08-03 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-compiler-rt-sanitizer

Author: Vitaly Buka (vitalybuka)


Changes

Before the patch each TU was executing pair
`__asan_before_dynamic_init` and
`__asan_after_dynamic_init`.

`__asan_before_dynamic_init` supports incremental
poisoning, but `__asan_after_dynamic_init`
unpoisons all globals, so
`__asan_before_dynamic_init` must repoison
everything again.

So it's O(N^2) where N is the number of globals
(or TUs). It can be expensive for large binaries.

The patch will make it O(N).

The patch requires LLD and platform with
SANITIZER_CAN_USE_PREINIT_ARRAY. For the rest it
continue to be O(N^2).


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


3 Files Affected:

- (modified) compiler-rt/lib/asan/asan_globals.cpp (+40) 
- (added) compiler-rt/test/asan/TestCases/initialization-nobug-lld.cpp (+14) 
- (modified) compiler-rt/test/asan/TestCases/initialization-nobug.cpp (+8-5) 


``diff
diff --git a/compiler-rt/lib/asan/asan_globals.cpp 
b/compiler-rt/lib/asan/asan_globals.cpp
index 293e771e1dc06..373b7eaa3c537 100644
--- a/compiler-rt/lib/asan/asan_globals.cpp
+++ b/compiler-rt/lib/asan/asan_globals.cpp
@@ -520,6 +520,44 @@ void __asan_before_dynamic_init(const char *module_name) {
   current_dynamic_init_module_name = module_name;
 }
 
+// Maybe SANITIZER_CAN_USE_PREINIT_ARRAY is to conservative for `.init_array`,
+// however we should not make mistake here. If `AfterDynamicInit` was not
+// executed at all we will have false reports on globals.
+#if SANITIZER_CAN_USE_PREINIT_ARRAY
+// This is optimization. We will ignore all `__asan_after_dynamic_init`, but 
the
+// last `__asan_after_dynamic_init`. We don't need number of
+// `__asan_{before,after}_dynamic_init` matches, but we need that the last call
+// was to `__asan_after_dynamic_init`, as it will unpoison all global preparing
+// program for `main` execution. To run `__asan_after_dynamic_init` later, we
+// will register in `.init_array`.
+static bool allow_after_dynamic_init SANITIZER_GUARDED_BY(mu_for_globals) =
+false;
+
+static void __attribute__((used)) AfterDynamicInit(void) {
+  {
+Lock lock(&mu_for_globals);
+if (allow_after_dynamic_init)
+  return;
+allow_after_dynamic_init = true;
+  }
+  if (flags()->report_globals >= 3)
+Printf("AfterDynamicInit\n");
+  __asan_after_dynamic_init();
+}
+
+// 65537 will make it run after constructors with default priority, but it
+// requires ld.lld. With ld.bfd it can be called to early, and fail the
+// optimization. However, correctness should not be affected, as after the 
first
+// call all subsequent `__asan_after_dynamic_init` will be allowed.
+__attribute__((section(".init_array.65537"), used)) static void (
+*asan_after_init_array)(void) = AfterDynamicInit;
+#else
+// Allow all `__asan_after_dynamic_init` if `AfterDynamicInit` is not set.
+// Compiler still generates `__asan_{before,after}_dynamic_init`in pairs, and
+// it's guaranteed that `__asan_after_dynamic_init` will be the last.
+static constexpr bool allow_after_dynamic_init = true;
+#endif  // SANITIZER_CAN_USE_PREINIT_ARRAY
+
 // This method runs immediately after dynamic initialization in each TU, when
 // all dynamically initialized globals except for those defined in the current
 // TU are poisoned.  It simply unpoisons all dynamically initialized globals.
@@ -528,6 +566,8 @@ void __asan_after_dynamic_init() {
 return;
   CHECK(AsanInited());
   Lock lock(&mu_for_globals);
+  if (!allow_after_dynamic_init)
+return;
   if (!current_dynamic_init_module_name)
 return;
 
diff --git a/compiler-rt/test/asan/TestCases/initialization-nobug-lld.cpp 
b/compiler-rt/test/asan/TestCases/initialization-nobug-lld.cpp
new file mode 100644
index 0..ece3118de4ad9
--- /dev/null
+++ b/compiler-rt/test/asan/TestCases/initialization-nobug-lld.cpp
@@ -0,0 +1,14 @@
+// RUN: %clangxx_asan -O3 %p/initialization-nobug.cpp 
%p/Helpers/initialization-nobug-extra.cpp -fuse-ld=lld -o %t && 
%env_asan_opts=check_initialization_order=true:report_globals=3 %run %t 2>&1 | 
FileCheck %s --implicit-check-not "DynInit"
+
+// Same as initialization-nobug.cpp, but with lld we expect just one
+// `DynInitUnpoison` executed after `AfterDynamicInit` at the end.
+// REQUIRES: lld-available
+
+// With dynamic runtimes `AfterDynamicInit` will called before `executable`
+// contructors, with constructors of dynamic runtime.
+// XFAIL: asan-dynamic-runtime
+
+// CHECK: DynInitPoison module: {{.*}}initialization-nobug.cpp
+// CHECK: DynInitPoison module: {{.*}}initialization-nobug-extra.cpp
+// CHECK: AfterDynamicInit
+// CHECK: DynInitUnpoison
diff --git a/compiler-rt/test/asan/TestCases/initialization-nobug.cpp 
b/compiler-rt/test/asan/TestCases/initialization-nobug.cpp
index 5659db088096b..f58f38203d0b2 100644
--- a/compiler-rt/test/asan/TestCases/initialization-nobug.cpp
+++ b/compiler-rt/test/asan/TestCases/initialization-nobug.cpp
@@ -1,10 +1,10 @@
 // A collectio

[llvm-branch-commits] [NFC][asan] Track current dynamic init module (PR #101597)

2024-08-03 Thread Vitaly Buka via llvm-branch-commits

https://github.com/vitalybuka edited 
https://github.com/llvm/llvm-project/pull/101597
___
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] [NFC][asan] Track current dynamic init module (PR #101597)

2024-08-03 Thread Vitaly Buka via llvm-branch-commits

https://github.com/vitalybuka updated 
https://github.com/llvm/llvm-project/pull/101597


___
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] [asan] Optimize initialization order checking (PR #101837)

2024-08-03 Thread Vitaly Buka via llvm-branch-commits

https://github.com/vitalybuka updated 
https://github.com/llvm/llvm-project/pull/101837


___
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] [NFC][asan] Track current dynamic init module (PR #101597)

2024-08-03 Thread Vitaly Buka via llvm-branch-commits

https://github.com/vitalybuka updated 
https://github.com/llvm/llvm-project/pull/101597


___
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] [asan] Optimize initialization order checking (PR #101837)

2024-08-03 Thread Vitaly Buka via llvm-branch-commits

https://github.com/vitalybuka updated 
https://github.com/llvm/llvm-project/pull/101837


___
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] [asan] Optimize initialization order checking (PR #101837)

2024-08-03 Thread Vitaly Buka via llvm-branch-commits

https://github.com/vitalybuka edited 
https://github.com/llvm/llvm-project/pull/101837
___
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] [lld] release/19.x: [ELF] Move ElfSym into Ctx. NFC (PR #101844)

2024-08-03 Thread via llvm-branch-commits

https://github.com/llvmbot milestoned 
https://github.com/llvm/llvm-project/pull/101844
___
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] [lld] release/19.x: [ELF] Move ElfSym into Ctx. NFC (PR #101844)

2024-08-03 Thread via llvm-branch-commits

https://github.com/llvmbot created 
https://github.com/llvm/llvm-project/pull/101844

Backport fd791f0fe562a41d8569fcb4d1e84b4c1e5719c7 
8e2476e102e8ce3ae496b293bacccb248787404d 
09dd0febbbd59a0c470b3909690cae6618a2416a 
03be619d9434de0a9616660a2119675635239a5b

Requested by: @MaskRay

>From 0fa5e6af74d9339e760365147ba62bd84b4c59e7 Mon Sep 17 00:00:00 2001
From: Fangrui Song 
Date: Sun, 28 Jul 2024 15:32:22 -0700
Subject: [PATCH 1/4] [ELF] Move TarWriter into Ctx. NFC

Similar to e980f16d52196fb2bc672ecb87e0f622253addec.

(cherry picked from commit fd791f0fe562a41d8569fcb4d1e84b4c1e5719c7)
---
 lld/ELF/Config.h   |  4 
 lld/ELF/Driver.cpp | 13 +++--
 lld/ELF/InputFiles.cpp |  7 ++-
 lld/ELF/InputFiles.h   |  3 ---
 4 files changed, 13 insertions(+), 14 deletions(-)

diff --git a/lld/ELF/Config.h b/lld/ELF/Config.h
index 0173be396163e..2f6758743c0d6 100644
--- a/lld/ELF/Config.h
+++ b/lld/ELF/Config.h
@@ -27,6 +27,7 @@
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/GlobPattern.h"
 #include "llvm/Support/PrettyStackTrace.h"
+#include "llvm/Support/TarWriter.h"
 #include 
 #include 
 #include 
@@ -489,6 +490,9 @@ struct Ctx {
  std::pair>
   backwardReferences;
   llvm::SmallSet auxiliaryFiles;
+  // If --reproduce is specified, all input files are written to this tar
+  // archive.
+  std::unique_ptr tar;
   // InputFile for linker created symbols with no source location.
   InputFile *internalFile;
   // True if SHT_LLVM_SYMPART is used.
diff --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp
index 40e095a133d95..810d9b0377adf 100644
--- a/lld/ELF/Driver.cpp
+++ b/lld/ELF/Driver.cpp
@@ -106,6 +106,7 @@ void Ctx::reset() {
   whyExtractRecords.clear();
   backwardReferences.clear();
   auxiliaryFiles.clear();
+  tar.reset();
   internalFile = nullptr;
   hasSympart.store(false, std::memory_order_relaxed);
   hasTlsIe.store(false, std::memory_order_relaxed);
@@ -138,7 +139,6 @@ bool link(ArrayRef args, llvm::raw_ostream 
&stdoutOS,
 outputSections.clear();
 symAux.clear();
 
-tar = nullptr;
 in.reset();
 
 partitions.clear();
@@ -224,14 +224,15 @@ std::vector> static 
getArchiveMembers(
 
   std::vector> v;
   Error err = Error::success();
-  bool addToTar = file->isThin() && tar;
+  bool addToTar = file->isThin() && ctx.tar;
   for (const Archive::Child &c : file->children(err)) {
 MemoryBufferRef mbref =
 CHECK(c.getMemoryBufferRef(),
   mb.getBufferIdentifier() +
   ": could not get the buffer for a child of the archive");
 if (addToTar)
-  tar->append(relativeToRoot(check(c.getFullName())), mbref.getBuffer());
+  ctx.tar->append(relativeToRoot(check(c.getFullName())),
+  mbref.getBuffer());
 v.push_back(std::make_pair(mbref, c.getChildOffset()));
   }
   if (err)
@@ -640,9 +641,9 @@ void LinkerDriver::linkerMain(ArrayRef 
argsArr) {
 Expected> errOrWriter =
 TarWriter::create(path, path::stem(path));
 if (errOrWriter) {
-  tar = std::move(*errOrWriter);
-  tar->append("response.txt", createResponseFile(args));
-  tar->append("version.txt", getLLDVersion() + "\n");
+  ctx.tar = std::move(*errOrWriter);
+  ctx.tar->append("response.txt", createResponseFile(args));
+  ctx.tar->append("version.txt", getLLDVersion() + "\n");
   StringRef ltoSampleProfile = 
args.getLastArgValue(OPT_lto_sample_profile);
   if (!ltoSampleProfile.empty())
 readFile(ltoSampleProfile);
diff --git a/lld/ELF/InputFiles.cpp b/lld/ELF/InputFiles.cpp
index f1c0eb292361b..0e4ba06e9b780 100644
--- a/lld/ELF/InputFiles.cpp
+++ b/lld/ELF/InputFiles.cpp
@@ -28,7 +28,6 @@
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/RISCVAttributeParser.h"
-#include "llvm/Support/TarWriter.h"
 #include "llvm/Support/TimeProfiler.h"
 #include "llvm/Support/raw_ostream.h"
 #include 
@@ -52,8 +51,6 @@ extern template void ObjFile::importCmseSymbols();
 bool InputFile::isInGroup;
 uint32_t InputFile::nextGroupId;
 
-std::unique_ptr elf::tar;
-
 // Returns "", "foo.a(bar.o)" or "baz.o".
 std::string lld::toString(const InputFile *f) {
   static std::mutex mu;
@@ -261,8 +258,8 @@ std::optional elf::readFile(StringRef 
path) {
   MemoryBufferRef mbref = (*mbOrErr)->getMemBufferRef();
   ctx.memoryBuffers.push_back(std::move(*mbOrErr)); // take MB ownership
 
-  if (tar)
-tar->append(relativeToRoot(path), mbref.getBuffer());
+  if (ctx.tar)
+ctx.tar->append(relativeToRoot(path), mbref.getBuffer());
   return mbref;
 }
 
diff --git a/lld/ELF/InputFiles.h b/lld/ELF/InputFiles.h
index 8566baf61e1ab..b0a74877d0aae 100644
--- a/lld/ELF/InputFiles.h
+++ b/lld/ELF/InputFiles.h
@@ -39,9 +39,6 @@ namespace elf {
 class InputSection;
 class Symbol;
 
-// If --reproduce is specified, all input files are written to this tar 
archive.
-extern std::unique_ptr tar;
-
 // Opens a given file.
 std::optional readFile(String

[llvm-branch-commits] [lld] release/19.x: [ELF] Move ElfSym into Ctx. NFC (PR #101844)

2024-08-03 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-lld-elf

Author: None (llvmbot)


Changes

Backport fd791f0fe562a41d8569fcb4d1e84b4c1e5719c7 
8e2476e102e8ce3ae496b293bacccb248787404d 
09dd0febbbd59a0c470b3909690cae6618a2416a 
03be619d9434de0a9616660a2119675635239a5b

Requested by: @MaskRay

---

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


16 Files Affected:

- (modified) lld/ELF/Arch/Mips.cpp (+2-2) 
- (modified) lld/ELF/Arch/RISCV.cpp (+2-2) 
- (modified) lld/ELF/Config.h (+72) 
- (modified) lld/ELF/Driver.cpp (+18-9) 
- (modified) lld/ELF/InputFiles.cpp (+2-5) 
- (modified) lld/ELF/InputFiles.h (-3) 
- (modified) lld/ELF/InputSection.cpp (+2-2) 
- (modified) lld/ELF/LinkerScript.cpp (+8-8) 
- (modified) lld/ELF/OutputSections.cpp (+1-9) 
- (modified) lld/ELF/OutputSections.h (-13) 
- (modified) lld/ELF/Relocations.cpp (+2-2) 
- (modified) lld/ELF/Symbols.cpp (+2-19) 
- (modified) lld/ELF/Symbols.h (+8-58) 
- (modified) lld/ELF/SyntheticSections.cpp (+31-38) 
- (modified) lld/ELF/Target.cpp (+2-2) 
- (modified) lld/ELF/Writer.cpp (+85-87) 


``diff
diff --git a/lld/ELF/Arch/Mips.cpp b/lld/ELF/Arch/Mips.cpp
index e36e9d59a7401..7c7137117d78e 100644
--- a/lld/ELF/Arch/Mips.cpp
+++ b/lld/ELF/Arch/Mips.cpp
@@ -121,9 +121,9 @@ RelExpr MIPS::getRelExpr(RelType type, const Symbol 
&s,
 // offset between start of function and 'gp' value which by default
 // equal to the start of .got section. In that case we consider these
 // relocations as relative.
-if (&s == ElfSym::mipsGpDisp)
+if (&s == ctx.sym.mipsGpDisp)
   return R_MIPS_GOT_GP_PC;
-if (&s == ElfSym::mipsLocalGp)
+if (&s == ctx.sym.mipsLocalGp)
   return R_MIPS_GOT_GP;
 [[fallthrough]];
   case R_MIPS_32:
diff --git a/lld/ELF/Arch/RISCV.cpp b/lld/ELF/Arch/RISCV.cpp
index 56759c28dcf41..8c2db2145f305 100644
--- a/lld/ELF/Arch/RISCV.cpp
+++ b/lld/ELF/Arch/RISCV.cpp
@@ -466,7 +466,7 @@ void RISCV::relocate(uint8_t *loc, const Relocation &rel, 
uint64_t val) const {
 
   case INTERNAL_R_RISCV_GPREL_I:
   case INTERNAL_R_RISCV_GPREL_S: {
-Defined *gp = ElfSym::riscvGlobalPointer;
+Defined *gp = ctx.sym.riscvGlobalPointer;
 int64_t displace = SignExtend64(val - gp->getVA(), bits);
 checkInt(loc, displace, 12, rel);
 uint32_t insn = (read32le(loc) & ~(31 << 15)) | (X_GP << 15);
@@ -789,7 +789,7 @@ static void relaxTlsLe(const InputSection &sec, size_t i, 
uint64_t loc,
 
 static void relaxHi20Lo12(const InputSection &sec, size_t i, uint64_t loc,
   Relocation &r, uint32_t &remove) {
-  const Defined *gp = ElfSym::riscvGlobalPointer;
+  const Defined *gp = ctx.sym.riscvGlobalPointer;
   if (!gp)
 return;
 
diff --git a/lld/ELF/Config.h b/lld/ELF/Config.h
index 0173be396163e..f562985630be4 100644
--- a/lld/ELF/Config.h
+++ b/lld/ELF/Config.h
@@ -27,6 +27,7 @@
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/GlobPattern.h"
 #include "llvm/Support/PrettyStackTrace.h"
+#include "llvm/Support/TarWriter.h"
 #include 
 #include 
 #include 
@@ -41,8 +42,11 @@ class ELFFileBase;
 class SharedFile;
 class InputSectionBase;
 class EhInputSection;
+class Defined;
 class Symbol;
 class BitcodeCompiler;
+class OutputSection;
+struct PhdrEntry;
 
 enum ELFKind : uint8_t {
   ELFNoneKind,
@@ -458,6 +462,15 @@ struct ConfigWrapper {
 
 LLVM_LIBRARY_VISIBILITY extern ConfigWrapper config;
 
+// Some index properties of a symbol are stored separately in this auxiliary
+// struct to decrease sizeof(SymbolUnion) in the majority of cases.
+struct SymbolAux {
+  uint32_t gotIdx = -1;
+  uint32_t pltIdx = -1;
+  uint32_t tlsDescIdx = -1;
+  uint32_t tlsGdIdx = -1;
+};
+
 struct DuplicateSymbol {
   const Symbol *sym;
   const InputFile *file;
@@ -467,6 +480,60 @@ struct DuplicateSymbol {
 
 struct Ctx {
   LinkerDriver driver;
+
+  // These variables are initialized by Writer and should not be used before
+  // Writer is initialized.
+  uint8_t *bufferStart;
+  PhdrEntry *tlsPhdr;
+  struct OutSections {
+OutputSection *elfHeader;
+OutputSection *programHeaders;
+OutputSection *preinitArray;
+OutputSection *initArray;
+OutputSection *finiArray;
+  };
+  OutSections out;
+
+  // Some linker-generated symbols need to be created as
+  // Defined symbols.
+  struct ElfSym {
+// __bss_start
+Defined *bss;
+
+// etext and _etext
+Defined *etext1;
+Defined *etext2;
+
+// edata and _edata
+Defined *edata1;
+Defined *edata2;
+
+// end and _end
+Defined *end1;
+Defined *end2;
+
+// The _GLOBAL_OFFSET_TABLE_ symbol is defined by target convention to
+// be at some offset from the base of the .got section, usually 0 or
+// the end of the .got.
+Defined *globalOffsetTable;
+
+// _gp, _gp_disp and __gnu_local_gp symbols. Only for MIPS.
+Defined *mipsGp;
+Defined *mipsGpDisp;
+Defined *mipsLocalGp;
+
+// __global_pointer$ for R

[llvm-branch-commits] [asan] Optimize initialization order checking (PR #101837)

2024-08-03 Thread Vitaly Buka via llvm-branch-commits

vitalybuka wrote:

FYI @artempyanykh

https://github.com/llvm/llvm-project/pull/101837
___
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] [compiler-rt] release/19.x: [builtins] Fix divtc3.c etc. compilation on Solaris/SPARC with gcc (#101662) (PR #101847)

2024-08-03 Thread via llvm-branch-commits

https://github.com/llvmbot milestoned 
https://github.com/llvm/llvm-project/pull/101847
___
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] [compiler-rt] release/19.x: [builtins] Fix divtc3.c etc. compilation on Solaris/SPARC with gcc (#101662) (PR #101847)

2024-08-03 Thread via llvm-branch-commits

llvmbot wrote:

@arichardson What do you think about merging this PR to the release branch?

https://github.com/llvm/llvm-project/pull/101847
___
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] [compiler-rt] release/19.x: [builtins] Fix divtc3.c etc. compilation on Solaris/SPARC with gcc (#101662) (PR #101847)

2024-08-03 Thread via llvm-branch-commits

https://github.com/llvmbot created 
https://github.com/llvm/llvm-project/pull/101847

Backport 63a7786111c501920afc4cc27a4633f76cdaf803

Requested by: @rorth

>From 8773b58bdbb60fb6c1ae51dff7f8e6e9b221a183 Mon Sep 17 00:00:00 2001
From: Rainer Orth 
Date: Sat, 3 Aug 2024 22:18:11 +0200
Subject: [PATCH] [builtins] Fix divtc3.c etc. compilation on Solaris/SPARC
 with gcc (#101662)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

`compiler-rt/lib/builtins/divtc3.c` and `multc3.c` don't compile on
Solaris/sparcv9 with `gcc -m32`:
```
FAILED: 
projects/compiler-rt/lib/builtins/CMakeFiles/clang_rt.builtins-sparc.dir/divtc3.c.o
[...]
compiler-rt/lib/builtins/divtc3.c: In function ‘__divtc3’:
compiler-rt/lib/builtins/divtc3.c:22:18: error: implicit declaration of 
function ‘__compiler_rt_logbtf’ [-Wimplicit-function-declaration]
   22 |   fp_t __logbw = __compiler_rt_logbtf(
  |  ^~~~
```
and many more. It turns out that while the definition of `__divtc3` is
guarded with `CRT_HAS_F128`, the `__compiler_rt_logbtf` and other
declarations use `CRT_HAS_128BIT && CRT_HAS_F128` as guard. This only
shows up with `gcc` since, as documented in Issue #41838, `clang`
violates the SPARC psABI in not using 128-bit `long double`, so this
code path isn't used.

Fixed by changing the guards to match.

Tested on `sparcv9-sun-solaris2.11`.

(cherry picked from commit 63a7786111c501920afc4cc27a4633f76cdaf803)
---
 compiler-rt/lib/builtins/divtc3.c | 2 +-
 compiler-rt/lib/builtins/multc3.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/compiler-rt/lib/builtins/divtc3.c 
b/compiler-rt/lib/builtins/divtc3.c
index 099de5802daf0..c393de815337e 100644
--- a/compiler-rt/lib/builtins/divtc3.c
+++ b/compiler-rt/lib/builtins/divtc3.c
@@ -13,7 +13,7 @@
 #define QUAD_PRECISION
 #include "fp_lib.h"
 
-#if defined(CRT_HAS_F128)
+#if defined(CRT_HAS_128BIT) && defined(CRT_HAS_F128)
 
 // Returns: the quotient of (a + ib) / (c + id)
 
diff --git a/compiler-rt/lib/builtins/multc3.c 
b/compiler-rt/lib/builtins/multc3.c
index 61a3f45e47279..a89832f0e883e 100644
--- a/compiler-rt/lib/builtins/multc3.c
+++ b/compiler-rt/lib/builtins/multc3.c
@@ -15,7 +15,7 @@
 #include "int_lib.h"
 #include "int_math.h"
 
-#if defined(CRT_HAS_F128)
+#if defined(CRT_HAS_128BIT) && defined(CRT_HAS_F128)
 
 // Returns: the product of a + ib and c + id
 

___
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] [compiler-rt] release/19.x: [sanitizer_common] Fix UnwindFast on SPARC (#101634) (PR #101848)

2024-08-03 Thread via llvm-branch-commits

https://github.com/llvmbot milestoned 
https://github.com/llvm/llvm-project/pull/101848
___
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] [compiler-rt] release/19.x: [sanitizer_common] Fix UnwindFast on SPARC (#101634) (PR #101848)

2024-08-03 Thread via llvm-branch-commits

llvmbot wrote:

@MaskRay What do you think about merging this PR to the release branch?

https://github.com/llvm/llvm-project/pull/101848
___
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] [compiler-rt] release/19.x: [sanitizer_common] Fix UnwindFast on SPARC (#101634) (PR #101848)

2024-08-03 Thread via llvm-branch-commits

https://github.com/llvmbot created 
https://github.com/llvm/llvm-project/pull/101848

Backport 3368a3245ce5049b090d7c1081c2d52a6b6fda68

Requested by: @rorth

>From da5bc0a1d92f201f0debf9ddf67096349b20a9bb Mon Sep 17 00:00:00 2001
From: Rainer Orth 
Date: Sat, 3 Aug 2024 22:19:44 +0200
Subject: [PATCH] [sanitizer_common] Fix UnwindFast on SPARC (#101634)

```
  UBSan-Standalone-sparc :: TestCases/Misc/Linux/diag-stacktrace.cpp
```
`FAIL`s on 32 and 64-bit Linux/sparc64 (and on Solaris/sparcv9, too: the
test isn't Linux-specific at all). With
`UBSAN_OPTIONS=fast_unwind_on_fatal=1`, the stack trace shows a
duplicate innermost frame:
```
compiler-rt/test/ubsan/TestCases/Misc/Linux/diag-stacktrace.cpp:14:31: runtime 
error: execution reached the end of a value-returning function without 
returning a value
#0 0x7003a708 in f() 
compiler-rt/test/ubsan/TestCases/Misc/Linux/diag-stacktrace.cpp:14:35
#1 0x7003a708 in f() 
compiler-rt/test/ubsan/TestCases/Misc/Linux/diag-stacktrace.cpp:14:35
#2 0x7003a714 in g() 
compiler-rt/test/ubsan/TestCases/Misc/Linux/diag-stacktrace.cpp:17:38
```
which isn't seen with `fast_unwind_on_fatal=0`.

This turns out to be another fallout from fixing
`__builtin_return_address`/`__builtin_extract_return_addr` on SPARC. In
`sanitizer_stacktrace_sparc.cpp` (`BufferedStackTrace::UnwindFast`) the
`pc` arg is the return address, while `pc1` from the stack frame
(`fr_savpc`) is the address of the `call` insn, leading to a double
entry for the innermost frame in `trace_buffer[]`.

This patch fixes this by moving the adjustment before all uses.

Tested on `sparc64-unknown-linux-gnu` and `sparcv9-sun-solaris2.11`
(with the `ubsan/TestCases/Misc/Linux` tests enabled).

(cherry picked from commit 3368a3245ce5049b090d7c1081c2d52a6b6fda68)
---
 .../sanitizer_common/sanitizer_stacktrace_sparc.cpp   | 11 +--
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_sparc.cpp 
b/compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_sparc.cpp
index a2000798a3907..74f435287af3c 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_sparc.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_sparc.cpp
@@ -58,17 +58,16 @@ void BufferedStackTrace::UnwindFast(uptr pc, uptr bp, uptr 
stack_top,
   // Avoid infinite loop when frame == frame[0] by using frame > prev_frame.
   while (IsValidFrame(bp, stack_top, bottom) && IsAligned(bp, sizeof(uhwptr)) 
&&
  size < max_depth) {
-uhwptr pc1 = ((uhwptr *)bp)[15];
+// %o7 contains the address of the call instruction and not the
+// return address, so we need to compensate.
+uhwptr pc1 = GetNextInstructionPc(((uhwptr *)bp)[15]);
 // Let's assume that any pointer in the 0th page is invalid and
 // stop unwinding here.  If we're adding support for a platform
 // where this isn't true, we need to reconsider this check.
 if (pc1 < kPageSize)
   break;
-if (pc1 != pc) {
-  // %o7 contains the address of the call instruction and not the
-  // return address, so we need to compensate.
-  trace_buffer[size++] = GetNextInstructionPc((uptr)pc1);
-}
+if (pc1 != pc)
+  trace_buffer[size++] = pc1;
 bottom = bp;
 bp = (uptr)((uhwptr *)bp)[14] + STACK_BIAS;
   }

___
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] [compiler-rt] release/19.x: [sanitizer_common] Fix UnwindFast on SPARC (#101634) (PR #101848)

2024-08-03 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-compiler-rt-sanitizer

Author: None (llvmbot)


Changes

Backport 3368a3245ce5049b090d7c1081c2d52a6b6fda68

Requested by: @rorth

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


1 Files Affected:

- (modified) compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_sparc.cpp 
(+5-6) 


``diff
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_sparc.cpp 
b/compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_sparc.cpp
index a2000798a3907..74f435287af3c 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_sparc.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_sparc.cpp
@@ -58,17 +58,16 @@ void BufferedStackTrace::UnwindFast(uptr pc, uptr bp, uptr 
stack_top,
   // Avoid infinite loop when frame == frame[0] by using frame > prev_frame.
   while (IsValidFrame(bp, stack_top, bottom) && IsAligned(bp, sizeof(uhwptr)) 
&&
  size < max_depth) {
-uhwptr pc1 = ((uhwptr *)bp)[15];
+// %o7 contains the address of the call instruction and not the
+// return address, so we need to compensate.
+uhwptr pc1 = GetNextInstructionPc(((uhwptr *)bp)[15]);
 // Let's assume that any pointer in the 0th page is invalid and
 // stop unwinding here.  If we're adding support for a platform
 // where this isn't true, we need to reconsider this check.
 if (pc1 < kPageSize)
   break;
-if (pc1 != pc) {
-  // %o7 contains the address of the call instruction and not the
-  // return address, so we need to compensate.
-  trace_buffer[size++] = GetNextInstructionPc((uptr)pc1);
-}
+if (pc1 != pc)
+  trace_buffer[size++] = pc1;
 bottom = bp;
 bp = (uptr)((uhwptr *)bp)[14] + STACK_BIAS;
   }

``




https://github.com/llvm/llvm-project/pull/101848
___
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] [lld] release/19.x: [ELF] Move ElfSym into Ctx. NFC (PR #101844)

2024-08-03 Thread via llvm-branch-commits

https://github.com/llvmbot updated 
https://github.com/llvm/llvm-project/pull/101844

>From f27537a5d033642347a8a45a7d6265dd9f94ccea Mon Sep 17 00:00:00 2001
From: Fangrui Song 
Date: Sun, 28 Jul 2024 15:32:22 -0700
Subject: [PATCH 1/4] [ELF] Move TarWriter into Ctx. NFC

Similar to e980f16d52196fb2bc672ecb87e0f622253addec.

(cherry picked from commit fd791f0fe562a41d8569fcb4d1e84b4c1e5719c7)
---
 lld/ELF/Config.h   |  4 
 lld/ELF/Driver.cpp | 13 +++--
 lld/ELF/InputFiles.cpp |  7 ++-
 lld/ELF/InputFiles.h   |  3 ---
 4 files changed, 13 insertions(+), 14 deletions(-)

diff --git a/lld/ELF/Config.h b/lld/ELF/Config.h
index 0173be396163e..2f6758743c0d6 100644
--- a/lld/ELF/Config.h
+++ b/lld/ELF/Config.h
@@ -27,6 +27,7 @@
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/GlobPattern.h"
 #include "llvm/Support/PrettyStackTrace.h"
+#include "llvm/Support/TarWriter.h"
 #include 
 #include 
 #include 
@@ -489,6 +490,9 @@ struct Ctx {
  std::pair>
   backwardReferences;
   llvm::SmallSet auxiliaryFiles;
+  // If --reproduce is specified, all input files are written to this tar
+  // archive.
+  std::unique_ptr tar;
   // InputFile for linker created symbols with no source location.
   InputFile *internalFile;
   // True if SHT_LLVM_SYMPART is used.
diff --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp
index 40e095a133d95..810d9b0377adf 100644
--- a/lld/ELF/Driver.cpp
+++ b/lld/ELF/Driver.cpp
@@ -106,6 +106,7 @@ void Ctx::reset() {
   whyExtractRecords.clear();
   backwardReferences.clear();
   auxiliaryFiles.clear();
+  tar.reset();
   internalFile = nullptr;
   hasSympart.store(false, std::memory_order_relaxed);
   hasTlsIe.store(false, std::memory_order_relaxed);
@@ -138,7 +139,6 @@ bool link(ArrayRef args, llvm::raw_ostream 
&stdoutOS,
 outputSections.clear();
 symAux.clear();
 
-tar = nullptr;
 in.reset();
 
 partitions.clear();
@@ -224,14 +224,15 @@ std::vector> static 
getArchiveMembers(
 
   std::vector> v;
   Error err = Error::success();
-  bool addToTar = file->isThin() && tar;
+  bool addToTar = file->isThin() && ctx.tar;
   for (const Archive::Child &c : file->children(err)) {
 MemoryBufferRef mbref =
 CHECK(c.getMemoryBufferRef(),
   mb.getBufferIdentifier() +
   ": could not get the buffer for a child of the archive");
 if (addToTar)
-  tar->append(relativeToRoot(check(c.getFullName())), mbref.getBuffer());
+  ctx.tar->append(relativeToRoot(check(c.getFullName())),
+  mbref.getBuffer());
 v.push_back(std::make_pair(mbref, c.getChildOffset()));
   }
   if (err)
@@ -640,9 +641,9 @@ void LinkerDriver::linkerMain(ArrayRef 
argsArr) {
 Expected> errOrWriter =
 TarWriter::create(path, path::stem(path));
 if (errOrWriter) {
-  tar = std::move(*errOrWriter);
-  tar->append("response.txt", createResponseFile(args));
-  tar->append("version.txt", getLLDVersion() + "\n");
+  ctx.tar = std::move(*errOrWriter);
+  ctx.tar->append("response.txt", createResponseFile(args));
+  ctx.tar->append("version.txt", getLLDVersion() + "\n");
   StringRef ltoSampleProfile = 
args.getLastArgValue(OPT_lto_sample_profile);
   if (!ltoSampleProfile.empty())
 readFile(ltoSampleProfile);
diff --git a/lld/ELF/InputFiles.cpp b/lld/ELF/InputFiles.cpp
index f1c0eb292361b..0e4ba06e9b780 100644
--- a/lld/ELF/InputFiles.cpp
+++ b/lld/ELF/InputFiles.cpp
@@ -28,7 +28,6 @@
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/RISCVAttributeParser.h"
-#include "llvm/Support/TarWriter.h"
 #include "llvm/Support/TimeProfiler.h"
 #include "llvm/Support/raw_ostream.h"
 #include 
@@ -52,8 +51,6 @@ extern template void ObjFile::importCmseSymbols();
 bool InputFile::isInGroup;
 uint32_t InputFile::nextGroupId;
 
-std::unique_ptr elf::tar;
-
 // Returns "", "foo.a(bar.o)" or "baz.o".
 std::string lld::toString(const InputFile *f) {
   static std::mutex mu;
@@ -261,8 +258,8 @@ std::optional elf::readFile(StringRef 
path) {
   MemoryBufferRef mbref = (*mbOrErr)->getMemBufferRef();
   ctx.memoryBuffers.push_back(std::move(*mbOrErr)); // take MB ownership
 
-  if (tar)
-tar->append(relativeToRoot(path), mbref.getBuffer());
+  if (ctx.tar)
+ctx.tar->append(relativeToRoot(path), mbref.getBuffer());
   return mbref;
 }
 
diff --git a/lld/ELF/InputFiles.h b/lld/ELF/InputFiles.h
index 8566baf61e1ab..b0a74877d0aae 100644
--- a/lld/ELF/InputFiles.h
+++ b/lld/ELF/InputFiles.h
@@ -39,9 +39,6 @@ namespace elf {
 class InputSection;
 class Symbol;
 
-// If --reproduce is specified, all input files are written to this tar 
archive.
-extern std::unique_ptr tar;
-
 // Opens a given file.
 std::optional readFile(StringRef path);
 

>From 34e70988a0aa5ec336126a0d141c058e833e7792 Mon Sep 17 00:00:00 2001
From: Fangrui Song 
Date: Sun, 28 Jul 2024 20:51:33 -0700
Subject: [PATCH 2/4] [ELF] Move SymbolAux into Ctx. NFC


[llvm-branch-commits] [compiler-rt] release/19.x: [sanitizer_common] Fix UnwindFast on SPARC (#101634) (PR #101848)

2024-08-03 Thread Fangrui Song via llvm-branch-commits

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


https://github.com/llvm/llvm-project/pull/101848
___
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] [clang-tools-extra] [lldb] [clang] Reland: Instantiate alias templates with sugar (PR #101858)

2024-08-03 Thread Matheus Izvekov via llvm-branch-commits

https://github.com/mizvekov created 
https://github.com/llvm/llvm-project/pull/101858

This makes use of the changes introduced in D134604, in order to instantiate 
alias templates witn a final sugared substitution.

This comes at no additional relevant cost.
Since we don't track / unique them in specializations, we wouldn't be able to 
resugar them later anyway.

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

>From 4615439837bfcc78fc611e6f8e1aca2d02ac3aa6 Mon Sep 17 00:00:00 2001
From: Matheus Izvekov 
Date: Sun, 23 Oct 2022 16:57:12 +0200
Subject: [PATCH] [clang] Reland: Instantiate alias templates with sugar

This makes use of the changes introduced in D134604, in order to
instantiate alias templates witn a final sugared substitution.

This comes at no additional relevant cost.
Since we don't track / unique them in specializations, we wouldn't be
able to resugar them later anyway.

Differential Revision: https://reviews.llvm.org/D136565
---
 .../clangd/unittests/HoverTests.cpp   |  2 +-
 .../unused-local-non-trivial-variable.cpp |  2 +-
 clang/lib/Sema/SemaTemplate.cpp   |  4 +-
 clang/test/AST/ast-dump-template-decls.cpp| 35 +++---
 clang/test/CXX/temp/temp.deduct.guide/p3.cpp  |  2 +-
 .../test/Misc/diag-template-diffing-cxx11.cpp | 21 +++---
 clang/test/SemaCXX/nullability.cpp|  4 +-
 clang/test/SemaCXX/sizeless-1.cpp |  2 +-
 .../SemaHLSL/VectorOverloadResolution.hlsl| 10 +--
 clang/test/SemaTemplate/deduction-guide.cpp   | 70 +--
 clang/test/SemaTemplate/make_integer_seq.cpp  |  8 +--
 clang/test/SemaTemplate/temp_arg_nontype.cpp  |  2 +-
 .../shared_ptr/TestSharedPtrFromStdModule.py  |  6 +-
 .../TestDbgInfoContentWeakPtrFromStdModule.py |  2 +-
 .../weak_ptr/TestWeakPtrFromStdModule.py  |  6 +-
 15 files changed, 75 insertions(+), 101 deletions(-)

diff --git a/clang-tools-extra/clangd/unittests/HoverTests.cpp 
b/clang-tools-extra/clangd/unittests/HoverTests.cpp
index 8d6d4223d7260..69f6df46c87ce 100644
--- a/clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ b/clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -1325,7 +1325,7 @@ class Foo final {})cpp";
  HI.LocalScope = "";
  HI.Kind = index::SymbolKind::TypeAlias;
  HI.Definition = "template  using AA = A";
- HI.Type = {"A", "type-parameter-0-0"}; // FIXME: should be 'T'
+ HI.Type = {"A", "T"};
  HI.TemplateParameters = {
  {{"typename"}, std::string("T"), std::nullopt}};
}},
diff --git 
a/clang-tools-extra/test/clang-tidy/checkers/bugprone/unused-local-non-trivial-variable.cpp
 
b/clang-tools-extra/test/clang-tidy/checkers/bugprone/unused-local-non-trivial-variable.cpp
index 3fdc24b94a6cb..721c55b1fb538 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/bugprone/unused-local-non-trivial-variable.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/bugprone/unused-local-non-trivial-variable.cpp
@@ -76,7 +76,7 @@ T qux(T Generic) {
 async::Future TemplateType;
 // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: unused local variable 
'TemplateType' of type 'async::Future' 
[bugprone-unused-local-non-trivial-variable]
 a::Future AliasTemplateType;
-// CHECK-MESSAGES: :[[@LINE-1]]:18: warning: unused local variable 
'AliasTemplateType' of type 'a::Future' (aka 'Future') 
[bugprone-unused-local-non-trivial-variable]
+// CHECK-MESSAGES: :[[@LINE-1]]:18: warning: unused local variable 
'AliasTemplateType' of type 'a::Future' (aka 'Future') 
[bugprone-unused-local-non-trivial-variable]
 [[maybe_unused]] async::Future MaybeUnused;
 return Generic;
 }
diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp
index 720862ec0bffa..1346a4a3f0012 100644
--- a/clang/lib/Sema/SemaTemplate.cpp
+++ b/clang/lib/Sema/SemaTemplate.cpp
@@ -3334,8 +3334,8 @@ QualType Sema::CheckTemplateIdType(TemplateName Name,
 
 // Only substitute for the innermost template argument list.
 MultiLevelTemplateArgumentList TemplateArgLists;
-TemplateArgLists.addOuterTemplateArguments(Template, CanonicalConverted,
-   /*Final=*/false);
+TemplateArgLists.addOuterTemplateArguments(Template, SugaredConverted,
+   /*Final=*/true);
 TemplateArgLists.addOuterRetainedLevels(
 AliasTemplate->getTemplateParameters()->getDepth());
 
diff --git a/clang/test/AST/ast-dump-template-decls.cpp 
b/clang/test/AST/ast-dump-template-decls.cpp
index f0a6204ce3cfa..9f578e5afe561 100644
--- a/clang/test/AST/ast-dump-template-decls.cpp
+++ b/clang/test/AST/ast-dump-template-decls.cpp
@@ -123,8 +123,6 @@ using type2 = typename C::type1;
 // CHECK-NEXT: TemplateArgument type 'void'
 // CHECK-NEXT: BuiltinType 0x{{[^ ]*}} 'void'
 // CHECK-NEXT: FunctionProtoType 0x{{[^ ]*}} 'void (int)' cdecl
-// CHECK-NEXT: SubstTemplateTypeParmType 0x{{[^ ]*}} 'void' sugar class depth 
0 index 0 U
-//

[llvm-branch-commits] [clang] [clang-tools-extra] [lldb] [clang] Reland: Instantiate alias templates with sugar (PR #101858)

2024-08-03 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Matheus Izvekov (mizvekov)


Changes

This makes use of the changes introduced in D134604, in order to instantiate 
alias templates witn a final sugared substitution.

This comes at no additional relevant cost.
Since we don't track / unique them in specializations, we wouldn't be able to 
resugar them later anyway.

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

---

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


15 Files Affected:

- (modified) clang-tools-extra/clangd/unittests/HoverTests.cpp (+1-1) 
- (modified) 
clang-tools-extra/test/clang-tidy/checkers/bugprone/unused-local-non-trivial-variable.cpp
 (+1-1) 
- (modified) clang/lib/Sema/SemaTemplate.cpp (+2-2) 
- (modified) clang/test/AST/ast-dump-template-decls.cpp (+8-27) 
- (modified) clang/test/CXX/temp/temp.deduct.guide/p3.cpp (+1-1) 
- (modified) clang/test/Misc/diag-template-diffing-cxx11.cpp (+9-12) 
- (modified) clang/test/SemaCXX/nullability.cpp (+2-2) 
- (modified) clang/test/SemaCXX/sizeless-1.cpp (+1-1) 
- (modified) clang/test/SemaHLSL/VectorOverloadResolution.hlsl (+5-5) 
- (modified) clang/test/SemaTemplate/deduction-guide.cpp (+35-35) 
- (modified) clang/test/SemaTemplate/make_integer_seq.cpp (+2-6) 
- (modified) clang/test/SemaTemplate/temp_arg_nontype.cpp (+1-1) 
- (modified) 
lldb/test/API/commands/expression/import-std-module/shared_ptr/TestSharedPtrFromStdModule.py
 (+3-3) 
- (modified) 
lldb/test/API/commands/expression/import-std-module/weak_ptr-dbg-info-content/TestDbgInfoContentWeakPtrFromStdModule.py
 (+1-1) 
- (modified) 
lldb/test/API/commands/expression/import-std-module/weak_ptr/TestWeakPtrFromStdModule.py
 (+3-3) 


``diff
diff --git a/clang-tools-extra/clangd/unittests/HoverTests.cpp 
b/clang-tools-extra/clangd/unittests/HoverTests.cpp
index 8d6d4223d7260..69f6df46c87ce 100644
--- a/clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ b/clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -1325,7 +1325,7 @@ class Foo final {})cpp";
  HI.LocalScope = "";
  HI.Kind = index::SymbolKind::TypeAlias;
  HI.Definition = "template  using AA = A";
- HI.Type = {"A", "type-parameter-0-0"}; // FIXME: should be 'T'
+ HI.Type = {"A", "T"};
  HI.TemplateParameters = {
  {{"typename"}, std::string("T"), std::nullopt}};
}},
diff --git 
a/clang-tools-extra/test/clang-tidy/checkers/bugprone/unused-local-non-trivial-variable.cpp
 
b/clang-tools-extra/test/clang-tidy/checkers/bugprone/unused-local-non-trivial-variable.cpp
index 3fdc24b94a6cb..721c55b1fb538 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/bugprone/unused-local-non-trivial-variable.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/bugprone/unused-local-non-trivial-variable.cpp
@@ -76,7 +76,7 @@ T qux(T Generic) {
 async::Future TemplateType;
 // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: unused local variable 
'TemplateType' of type 'async::Future' 
[bugprone-unused-local-non-trivial-variable]
 a::Future AliasTemplateType;
-// CHECK-MESSAGES: :[[@LINE-1]]:18: warning: unused local variable 
'AliasTemplateType' of type 'a::Future' (aka 'Future') 
[bugprone-unused-local-non-trivial-variable]
+// CHECK-MESSAGES: :[[@LINE-1]]:18: warning: unused local variable 
'AliasTemplateType' of type 'a::Future' (aka 'Future') 
[bugprone-unused-local-non-trivial-variable]
 [[maybe_unused]] async::Future MaybeUnused;
 return Generic;
 }
diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp
index 720862ec0bffa..1346a4a3f0012 100644
--- a/clang/lib/Sema/SemaTemplate.cpp
+++ b/clang/lib/Sema/SemaTemplate.cpp
@@ -3334,8 +3334,8 @@ QualType Sema::CheckTemplateIdType(TemplateName Name,
 
 // Only substitute for the innermost template argument list.
 MultiLevelTemplateArgumentList TemplateArgLists;
-TemplateArgLists.addOuterTemplateArguments(Template, CanonicalConverted,
-   /*Final=*/false);
+TemplateArgLists.addOuterTemplateArguments(Template, SugaredConverted,
+   /*Final=*/true);
 TemplateArgLists.addOuterRetainedLevels(
 AliasTemplate->getTemplateParameters()->getDepth());
 
diff --git a/clang/test/AST/ast-dump-template-decls.cpp 
b/clang/test/AST/ast-dump-template-decls.cpp
index f0a6204ce3cfa..9f578e5afe561 100644
--- a/clang/test/AST/ast-dump-template-decls.cpp
+++ b/clang/test/AST/ast-dump-template-decls.cpp
@@ -123,8 +123,6 @@ using type2 = typename C::type1;
 // CHECK-NEXT: TemplateArgument type 'void'
 // CHECK-NEXT: BuiltinType 0x{{[^ ]*}} 'void'
 // CHECK-NEXT: FunctionProtoType 0x{{[^ ]*}} 'void (int)' cdecl
-// CHECK-NEXT: SubstTemplateTypeParmType 0x{{[^ ]*}} 'void' sugar class depth 
0 index 0 U
-// CHECK-NEXT: TypeAliasTemplate 0x{{[^ ]*}} 'type1'
 // CHECK-NEXT: BuiltinType 0x{{[^ ]*}} 'void

[llvm-branch-commits] [clang] [clang-tools-extra] [lldb] [clang] Reland: Instantiate alias templates with sugar (PR #101858)

2024-08-03 Thread Matheus Izvekov via llvm-branch-commits

mizvekov wrote:

@alexfh I can't observe anymore the performance regression you reported on the 
original phab DR (q2.cc test case).

The original reduction doesn't compile anymore starting from clang-18, so I 
took the same base test and applied it to current libc++, but the memory usage 
and wall time are pretty close.

Let me know if you have an additional test case.

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