[llvm-branch-commits] [Hashing] Use a non-deterministic seed (PR #96282)

2024-06-22 Thread Fangrui Song via llvm-branch-commits

https://github.com/MaskRay edited 
https://github.com/llvm/llvm-project/pull/96282
___
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] [Hashing] Use a non-deterministic seed (PR #96282)

2024-06-22 Thread Fangrui Song via llvm-branch-commits

https://github.com/MaskRay updated 
https://github.com/llvm/llvm-project/pull/96282


___
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] [Hashing] Use a non-deterministic seed (PR #96282)

2024-06-22 Thread Fangrui Song via llvm-branch-commits

https://github.com/MaskRay updated 
https://github.com/llvm/llvm-project/pull/96282


___
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] [Hashing] Use a non-deterministic seed (PR #96282)

2024-06-21 Thread Fangrui Song via llvm-branch-commits

MaskRay wrote:

Due to ASLR and malloc non-determinism, `DenseMap` already introduces a 
lot of non-determinism to release builds.
`DenseMap` issues are less pronounced compared with `DenseMap`.

> I'm a little concerned that doing this in release builds is going to lead to 
> weird bug reports

I understand the concern. If we receive 10 weird bug reports root caused to 
`DenseMap`,
the number of `DenseMap` bug reports might just be 1.

---

The next step is to make integer type keys (e.g. `DenseMap`) 
non-deterministic.
IIRC the recent uint64_t getHashKey changes does not require any test update.
The number of `DenseMap` bug reports might be small.

As my previous comment says:

> we could consider restrict the nondeterminism to LLVM_ENABLE_ASSERTIONS=on.

but I haven't found it necessary.

https://github.com/llvm/llvm-project/pull/96282
___
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] [Hashing] Use a non-deterministic seed (PR #96282)

2024-06-21 Thread Fangrui Song via llvm-branch-commits

MaskRay wrote:

> I like the idea, but I'm not sure this should be always enabled. This sounds 
> like a lot of debugging fun when a seed-dependent case is not caught in 
> testing.
> 
> Can we have this part of LLVM_REVERSE_ITERATION instead, which is used to 
> detect similar hash iteration stability issues? We have a build bot for it.

I have fixed a lot of non-determinism bugs in the past few years.
In my experience, non-determinism caused by `DenseMap` is a more 
frequent issue than overuse of `DenseMap`.
`DenseMap` non-determinism issues could have a low failure rate with 
certain malloc implementations, especially when the bucket count is small.

Potential non-determinism concerns are outweighed by the benefits.
The argument in https://github.com/abseil/abseil-cpp/issues/339 might be useful:

> Part of Abseil's philosophy is engineering at scale. In addition to making it 
> harder to execute a hash flooding attack, another reason we randomize 
> iteration order is that is makes it easier for use to change the underlying 
> implementation if we need to. When we wanted to change our hash function (for 
> example), we found thousands of unit tests that depended on iteration order. 
> We could not just break these tests and say "sorry, you are violating Hyrum's 
> Law" since we would have thousands of angry Google developers. So instead, we 
> fixed the tests and implemented randomization so that next time we wanted to 
> change something in the implementation, this would not be an issue. The need 
> for iteration order determinism is relatively rare compared to the potential 
> wins we get by being free to change the implementation (maybe to make the 
> hash table faster, which could save millions of cycles at scale, for 
> example). By giving users a knob to disable the randomness, we'd be in the 
> same situation all over again.

While -DLLVM_ENABLE_REVERSE_ITERATION=on helps, it adds complexity for bot 
maintainers and configurations.
This PR allows easier detection of `DenseMap` overuse by all 
contributors.
Eventually, perhaps we can extend this to all `DenseMap` for 
LLVM_ENABLE_ASSERTIONS=on.


https://github.com/llvm/llvm-project/pull/96282
___
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] [Hashing] Use a non-deterministic seed (PR #96282)

2024-06-21 Thread Fangrui Song via llvm-branch-commits

https://github.com/MaskRay created 
https://github.com/llvm/llvm-project/pull/96282

Hashing.h provides hash_value/hash_combine/hash_combine_range, which are
primarily used by

* `DenseMap`
* `FoldingSetNodeIDRef::ComputeHash` (will be fixed by #96136)

Users shouldn't rely on specific hash values due to potential algorithm
changes. `set_fixed_execution_hash_seed` is provided but it has never
been used.

Take the the address of a static storage duration variable as the seed
like absl/hash/internal/hash.h `kSeed`.
(See https://reviews.llvm.org/D93931 for workaround for older Clang.
Mach-O x86-64 forces PIC, so absl's `__apple_build_version__` check is
unnecessary.)

A few users relying on the iteration order of `DenseMap`
have been fixed (e.g., f8f4235612b9 c025bd1fdbbd 89e8e63f47ff
86eb6bf6715c eb8d03656549 0ea6b8e476c2 58d7a6e0e636 8ea31db27211
255986e27fcf).
>From my experience fixing `DenseMap` and
[`StringMap`](https://discourse.llvm.org/t/reverse-iteration-bots/72224)
iteration order issues, the scale of breakage is smaller.



___
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] [nsan] Fix style issue (PR #96142)

2024-06-20 Thread Fangrui Song via llvm-branch-commits

https://github.com/MaskRay updated 
https://github.com/llvm/llvm-project/pull/96142

>From 54357a77702361abf1044d1ee5d0dee3e4fa407c Mon Sep 17 00:00:00 2001
From: Fangrui Song 
Date: Thu, 20 Jun 2024 00:23:01 -0700
Subject: [PATCH 1/4] more

Created using spr 1.3.5-bogner
---
 compiler-rt/lib/nsan/nsan.cpp  |  59 ++--
 compiler-rt/lib/nsan/nsan_flags.cpp|   2 -
 compiler-rt/lib/nsan/nsan_stats.cpp| 107 ++---
 compiler-rt/lib/nsan/nsan_stats.h  |  43 +
 compiler-rt/lib/nsan/nsan_suppressions.cpp |  48 +
 5 files changed, 124 insertions(+), 135 deletions(-)

diff --git a/compiler-rt/lib/nsan/nsan.cpp b/compiler-rt/lib/nsan/nsan.cpp
index ece1130f73d14..fd5390e20a029 100644
--- a/compiler-rt/lib/nsan/nsan.cpp
+++ b/compiler-rt/lib/nsan/nsan.cpp
@@ -71,7 +71,6 @@ __nsan_set_value_unknown(const u8 *addr, uptr size) {
   internal_memset((void *)getShadowTypeAddrFor(addr), 0, size);
 }
 
-namespace __nsan {
 
 const char *FTInfo::kCppTypeName = "float";
 const char *FTInfo::kCppTypeName = "double";
@@ -177,8 +176,6 @@ template  T max(T a, T b) { return a < b ? b : 
a; }
 
 } // end anonymous namespace
 
-} // end namespace __nsan
-
 void __sanitizer::BufferedStackTrace::UnwindImpl(uptr pc, uptr bp,
  void *context,
  bool request_fast,
@@ -189,7 +186,7 @@ void __sanitizer::BufferedStackTrace::UnwindImpl(uptr pc, 
uptr bp,
 
 extern "C" SANITIZER_INTERFACE_ATTRIBUTE void __nsan_print_accumulated_stats() 
{
   if (nsan_stats)
-nsan_stats->print();
+nsan_stats->Print();
 }
 
 static void NsanAtexit() {
@@ -228,18 +225,18 @@ __nsan_get_shadow_ptr_for_longdouble_store(u8 
*store_addr, uptr n) {
   return getShadowPtrForStore(store_addr, n);
 }
 
-template  static bool isValidShadowType(const u8 *shadow_type) {
+template  static bool IsValidShadowType(const u8 *shadow_type) {
   return __builtin_memcmp(shadow_type, FTInfo::kTypePattern, sizeof(FT)) ==
  0;
 }
 
-template  static bool isZero(const T *ptr) {
+template  static bool IsZero(const T *ptr) {
   constexpr const char kZeros[kSize] = {}; // Zero initialized.
   return __builtin_memcmp(ptr, kZeros, kSize) == 0;
 }
 
-template  static bool isUnknownShadowType(const u8 *shadow_type) {
-  return isZero::kTypePattern)>(shadow_type);
+template  static bool IsUnknownShadowType(const u8 *shadow_type) {
+  return IsZero::kTypePattern)>(shadow_type);
 }
 
 // The three folowing functions check that the address stores a complete
@@ -249,21 +246,21 @@ template 
 static const u8 *getShadowPtrForLoad(const u8 *load_addr, uptr n) {
   const u8 *const shadow_type = getShadowTypeAddrFor(load_addr);
   for (uptr i = 0; i < n; ++i) {
-if (!isValidShadowType(shadow_type + i * sizeof(FT))) {
+if (!IsValidShadowType(shadow_type + i * sizeof(FT))) {
   // If loadtracking stats are enabled, log loads with invalid types
   // (tampered with through type punning).
   if (flags().enable_loadtracking_stats) {
-if (isUnknownShadowType(shadow_type + i * sizeof(FT))) {
+if (IsUnknownShadowType(shadow_type + i * sizeof(FT))) {
   // Warn only if the value is non-zero. Zero is special because
   // applications typically initialize large buffers to zero in an
   // untyped way.
-  if (!isZero(load_addr)) {
+  if (!IsZero(load_addr)) {
 GET_CALLER_PC_BP;
-nsan_stats->addUnknownLoadTrackingEvent(pc, bp);
+nsan_stats->AddUnknownLoadTrackingEvent(pc, bp);
   }
 } else {
   GET_CALLER_PC_BP;
-  nsan_stats->addInvalidLoadTrackingEvent(pc, bp);
+  nsan_stats->AddInvalidLoadTrackingEvent(pc, bp);
 }
   }
   return nullptr;
@@ -442,7 +439,7 @@ int32_t checkFT(const FT value, ShadowFT Shadow, CheckTypeT 
CheckType,
 // want to avoid having to move the computation of `largest` before the
 // absolute value check when this branch is not taken.
 const InternalFT largest = max(ftAbs(check_value), ftAbs(check_shadow));
-nsan_stats->addCheck(CheckType, pc, bp, abs_err / largest);
+nsan_stats->AddCheck(CheckType, pc, bp, abs_err / largest);
   }
 
   // Note: writing the comparison that way ensures that when `abs_err` is Nan
@@ -534,7 +531,7 @@ int32_t checkFT(const FT value, ShadowFT Shadow, CheckTypeT 
CheckType,
 
   if (flags().enable_warning_stats) {
 GET_CALLER_PC_BP;
-nsan_stats->addWarning(CheckType, pc, bp, abs_err / largest);
+nsan_stats->AddWarning(CheckType, pc, bp, abs_err / largest);
   }
 
   if (flags().halt_on_error) {
@@ -565,10 +562,10 @@ __nsan_internal_check_longdouble_q(long double value, 
__float128 shadow,
   return checkFT(value, shadow, static_cast(check_type), 
check_arg);
 }
 
-static const char *getTruthValueName(bool v) { return v ? "true" : "false"; }
+static const char *GetTruthValueName(bool v) { 

[llvm-branch-commits] [compiler-rt] [nsan] Fix style issue (PR #96142)

2024-06-20 Thread Fangrui Song via llvm-branch-commits

https://github.com/MaskRay updated 
https://github.com/llvm/llvm-project/pull/96142

>From 54357a77702361abf1044d1ee5d0dee3e4fa407c Mon Sep 17 00:00:00 2001
From: Fangrui Song 
Date: Thu, 20 Jun 2024 00:23:01 -0700
Subject: [PATCH 1/3] more

Created using spr 1.3.5-bogner
---
 compiler-rt/lib/nsan/nsan.cpp  |  59 ++--
 compiler-rt/lib/nsan/nsan_flags.cpp|   2 -
 compiler-rt/lib/nsan/nsan_stats.cpp| 107 ++---
 compiler-rt/lib/nsan/nsan_stats.h  |  43 +
 compiler-rt/lib/nsan/nsan_suppressions.cpp |  48 +
 5 files changed, 124 insertions(+), 135 deletions(-)

diff --git a/compiler-rt/lib/nsan/nsan.cpp b/compiler-rt/lib/nsan/nsan.cpp
index ece1130f73d14..fd5390e20a029 100644
--- a/compiler-rt/lib/nsan/nsan.cpp
+++ b/compiler-rt/lib/nsan/nsan.cpp
@@ -71,7 +71,6 @@ __nsan_set_value_unknown(const u8 *addr, uptr size) {
   internal_memset((void *)getShadowTypeAddrFor(addr), 0, size);
 }
 
-namespace __nsan {
 
 const char *FTInfo::kCppTypeName = "float";
 const char *FTInfo::kCppTypeName = "double";
@@ -177,8 +176,6 @@ template  T max(T a, T b) { return a < b ? b : 
a; }
 
 } // end anonymous namespace
 
-} // end namespace __nsan
-
 void __sanitizer::BufferedStackTrace::UnwindImpl(uptr pc, uptr bp,
  void *context,
  bool request_fast,
@@ -189,7 +186,7 @@ void __sanitizer::BufferedStackTrace::UnwindImpl(uptr pc, 
uptr bp,
 
 extern "C" SANITIZER_INTERFACE_ATTRIBUTE void __nsan_print_accumulated_stats() 
{
   if (nsan_stats)
-nsan_stats->print();
+nsan_stats->Print();
 }
 
 static void NsanAtexit() {
@@ -228,18 +225,18 @@ __nsan_get_shadow_ptr_for_longdouble_store(u8 
*store_addr, uptr n) {
   return getShadowPtrForStore(store_addr, n);
 }
 
-template  static bool isValidShadowType(const u8 *shadow_type) {
+template  static bool IsValidShadowType(const u8 *shadow_type) {
   return __builtin_memcmp(shadow_type, FTInfo::kTypePattern, sizeof(FT)) ==
  0;
 }
 
-template  static bool isZero(const T *ptr) {
+template  static bool IsZero(const T *ptr) {
   constexpr const char kZeros[kSize] = {}; // Zero initialized.
   return __builtin_memcmp(ptr, kZeros, kSize) == 0;
 }
 
-template  static bool isUnknownShadowType(const u8 *shadow_type) {
-  return isZero::kTypePattern)>(shadow_type);
+template  static bool IsUnknownShadowType(const u8 *shadow_type) {
+  return IsZero::kTypePattern)>(shadow_type);
 }
 
 // The three folowing functions check that the address stores a complete
@@ -249,21 +246,21 @@ template 
 static const u8 *getShadowPtrForLoad(const u8 *load_addr, uptr n) {
   const u8 *const shadow_type = getShadowTypeAddrFor(load_addr);
   for (uptr i = 0; i < n; ++i) {
-if (!isValidShadowType(shadow_type + i * sizeof(FT))) {
+if (!IsValidShadowType(shadow_type + i * sizeof(FT))) {
   // If loadtracking stats are enabled, log loads with invalid types
   // (tampered with through type punning).
   if (flags().enable_loadtracking_stats) {
-if (isUnknownShadowType(shadow_type + i * sizeof(FT))) {
+if (IsUnknownShadowType(shadow_type + i * sizeof(FT))) {
   // Warn only if the value is non-zero. Zero is special because
   // applications typically initialize large buffers to zero in an
   // untyped way.
-  if (!isZero(load_addr)) {
+  if (!IsZero(load_addr)) {
 GET_CALLER_PC_BP;
-nsan_stats->addUnknownLoadTrackingEvent(pc, bp);
+nsan_stats->AddUnknownLoadTrackingEvent(pc, bp);
   }
 } else {
   GET_CALLER_PC_BP;
-  nsan_stats->addInvalidLoadTrackingEvent(pc, bp);
+  nsan_stats->AddInvalidLoadTrackingEvent(pc, bp);
 }
   }
   return nullptr;
@@ -442,7 +439,7 @@ int32_t checkFT(const FT value, ShadowFT Shadow, CheckTypeT 
CheckType,
 // want to avoid having to move the computation of `largest` before the
 // absolute value check when this branch is not taken.
 const InternalFT largest = max(ftAbs(check_value), ftAbs(check_shadow));
-nsan_stats->addCheck(CheckType, pc, bp, abs_err / largest);
+nsan_stats->AddCheck(CheckType, pc, bp, abs_err / largest);
   }
 
   // Note: writing the comparison that way ensures that when `abs_err` is Nan
@@ -534,7 +531,7 @@ int32_t checkFT(const FT value, ShadowFT Shadow, CheckTypeT 
CheckType,
 
   if (flags().enable_warning_stats) {
 GET_CALLER_PC_BP;
-nsan_stats->addWarning(CheckType, pc, bp, abs_err / largest);
+nsan_stats->AddWarning(CheckType, pc, bp, abs_err / largest);
   }
 
   if (flags().halt_on_error) {
@@ -565,10 +562,10 @@ __nsan_internal_check_longdouble_q(long double value, 
__float128 shadow,
   return checkFT(value, shadow, static_cast(check_type), 
check_arg);
 }
 
-static const char *getTruthValueName(bool v) { return v ? "true" : "false"; }
+static const char *GetTruthValueName(bool v) { 

[llvm-branch-commits] [compiler-rt] [nsan] Fix style issue (PR #96142)

2024-06-20 Thread Fangrui Song via llvm-branch-commits

https://github.com/MaskRay updated 
https://github.com/llvm/llvm-project/pull/96142

>From 54357a77702361abf1044d1ee5d0dee3e4fa407c Mon Sep 17 00:00:00 2001
From: Fangrui Song 
Date: Thu, 20 Jun 2024 00:23:01 -0700
Subject: [PATCH 1/3] more

Created using spr 1.3.5-bogner
---
 compiler-rt/lib/nsan/nsan.cpp  |  59 ++--
 compiler-rt/lib/nsan/nsan_flags.cpp|   2 -
 compiler-rt/lib/nsan/nsan_stats.cpp| 107 ++---
 compiler-rt/lib/nsan/nsan_stats.h  |  43 +
 compiler-rt/lib/nsan/nsan_suppressions.cpp |  48 +
 5 files changed, 124 insertions(+), 135 deletions(-)

diff --git a/compiler-rt/lib/nsan/nsan.cpp b/compiler-rt/lib/nsan/nsan.cpp
index ece1130f73d14..fd5390e20a029 100644
--- a/compiler-rt/lib/nsan/nsan.cpp
+++ b/compiler-rt/lib/nsan/nsan.cpp
@@ -71,7 +71,6 @@ __nsan_set_value_unknown(const u8 *addr, uptr size) {
   internal_memset((void *)getShadowTypeAddrFor(addr), 0, size);
 }
 
-namespace __nsan {
 
 const char *FTInfo::kCppTypeName = "float";
 const char *FTInfo::kCppTypeName = "double";
@@ -177,8 +176,6 @@ template  T max(T a, T b) { return a < b ? b : 
a; }
 
 } // end anonymous namespace
 
-} // end namespace __nsan
-
 void __sanitizer::BufferedStackTrace::UnwindImpl(uptr pc, uptr bp,
  void *context,
  bool request_fast,
@@ -189,7 +186,7 @@ void __sanitizer::BufferedStackTrace::UnwindImpl(uptr pc, 
uptr bp,
 
 extern "C" SANITIZER_INTERFACE_ATTRIBUTE void __nsan_print_accumulated_stats() 
{
   if (nsan_stats)
-nsan_stats->print();
+nsan_stats->Print();
 }
 
 static void NsanAtexit() {
@@ -228,18 +225,18 @@ __nsan_get_shadow_ptr_for_longdouble_store(u8 
*store_addr, uptr n) {
   return getShadowPtrForStore(store_addr, n);
 }
 
-template  static bool isValidShadowType(const u8 *shadow_type) {
+template  static bool IsValidShadowType(const u8 *shadow_type) {
   return __builtin_memcmp(shadow_type, FTInfo::kTypePattern, sizeof(FT)) ==
  0;
 }
 
-template  static bool isZero(const T *ptr) {
+template  static bool IsZero(const T *ptr) {
   constexpr const char kZeros[kSize] = {}; // Zero initialized.
   return __builtin_memcmp(ptr, kZeros, kSize) == 0;
 }
 
-template  static bool isUnknownShadowType(const u8 *shadow_type) {
-  return isZero::kTypePattern)>(shadow_type);
+template  static bool IsUnknownShadowType(const u8 *shadow_type) {
+  return IsZero::kTypePattern)>(shadow_type);
 }
 
 // The three folowing functions check that the address stores a complete
@@ -249,21 +246,21 @@ template 
 static const u8 *getShadowPtrForLoad(const u8 *load_addr, uptr n) {
   const u8 *const shadow_type = getShadowTypeAddrFor(load_addr);
   for (uptr i = 0; i < n; ++i) {
-if (!isValidShadowType(shadow_type + i * sizeof(FT))) {
+if (!IsValidShadowType(shadow_type + i * sizeof(FT))) {
   // If loadtracking stats are enabled, log loads with invalid types
   // (tampered with through type punning).
   if (flags().enable_loadtracking_stats) {
-if (isUnknownShadowType(shadow_type + i * sizeof(FT))) {
+if (IsUnknownShadowType(shadow_type + i * sizeof(FT))) {
   // Warn only if the value is non-zero. Zero is special because
   // applications typically initialize large buffers to zero in an
   // untyped way.
-  if (!isZero(load_addr)) {
+  if (!IsZero(load_addr)) {
 GET_CALLER_PC_BP;
-nsan_stats->addUnknownLoadTrackingEvent(pc, bp);
+nsan_stats->AddUnknownLoadTrackingEvent(pc, bp);
   }
 } else {
   GET_CALLER_PC_BP;
-  nsan_stats->addInvalidLoadTrackingEvent(pc, bp);
+  nsan_stats->AddInvalidLoadTrackingEvent(pc, bp);
 }
   }
   return nullptr;
@@ -442,7 +439,7 @@ int32_t checkFT(const FT value, ShadowFT Shadow, CheckTypeT 
CheckType,
 // want to avoid having to move the computation of `largest` before the
 // absolute value check when this branch is not taken.
 const InternalFT largest = max(ftAbs(check_value), ftAbs(check_shadow));
-nsan_stats->addCheck(CheckType, pc, bp, abs_err / largest);
+nsan_stats->AddCheck(CheckType, pc, bp, abs_err / largest);
   }
 
   // Note: writing the comparison that way ensures that when `abs_err` is Nan
@@ -534,7 +531,7 @@ int32_t checkFT(const FT value, ShadowFT Shadow, CheckTypeT 
CheckType,
 
   if (flags().enable_warning_stats) {
 GET_CALLER_PC_BP;
-nsan_stats->addWarning(CheckType, pc, bp, abs_err / largest);
+nsan_stats->AddWarning(CheckType, pc, bp, abs_err / largest);
   }
 
   if (flags().halt_on_error) {
@@ -565,10 +562,10 @@ __nsan_internal_check_longdouble_q(long double value, 
__float128 shadow,
   return checkFT(value, shadow, static_cast(check_type), 
check_arg);
 }
 
-static const char *getTruthValueName(bool v) { return v ? "true" : "false"; }
+static const char *GetTruthValueName(bool v) { 

[llvm-branch-commits] [compiler-rt] [nsan] Fix style issue (PR #96142)

2024-06-20 Thread Fangrui Song via llvm-branch-commits

https://github.com/MaskRay updated 
https://github.com/llvm/llvm-project/pull/96142

>From 54357a77702361abf1044d1ee5d0dee3e4fa407c Mon Sep 17 00:00:00 2001
From: Fangrui Song 
Date: Thu, 20 Jun 2024 00:23:01 -0700
Subject: [PATCH 1/3] more

Created using spr 1.3.5-bogner
---
 compiler-rt/lib/nsan/nsan.cpp  |  59 ++--
 compiler-rt/lib/nsan/nsan_flags.cpp|   2 -
 compiler-rt/lib/nsan/nsan_stats.cpp| 107 ++---
 compiler-rt/lib/nsan/nsan_stats.h  |  43 +
 compiler-rt/lib/nsan/nsan_suppressions.cpp |  48 +
 5 files changed, 124 insertions(+), 135 deletions(-)

diff --git a/compiler-rt/lib/nsan/nsan.cpp b/compiler-rt/lib/nsan/nsan.cpp
index ece1130f73d14..fd5390e20a029 100644
--- a/compiler-rt/lib/nsan/nsan.cpp
+++ b/compiler-rt/lib/nsan/nsan.cpp
@@ -71,7 +71,6 @@ __nsan_set_value_unknown(const u8 *addr, uptr size) {
   internal_memset((void *)getShadowTypeAddrFor(addr), 0, size);
 }
 
-namespace __nsan {
 
 const char *FTInfo::kCppTypeName = "float";
 const char *FTInfo::kCppTypeName = "double";
@@ -177,8 +176,6 @@ template  T max(T a, T b) { return a < b ? b : 
a; }
 
 } // end anonymous namespace
 
-} // end namespace __nsan
-
 void __sanitizer::BufferedStackTrace::UnwindImpl(uptr pc, uptr bp,
  void *context,
  bool request_fast,
@@ -189,7 +186,7 @@ void __sanitizer::BufferedStackTrace::UnwindImpl(uptr pc, 
uptr bp,
 
 extern "C" SANITIZER_INTERFACE_ATTRIBUTE void __nsan_print_accumulated_stats() 
{
   if (nsan_stats)
-nsan_stats->print();
+nsan_stats->Print();
 }
 
 static void NsanAtexit() {
@@ -228,18 +225,18 @@ __nsan_get_shadow_ptr_for_longdouble_store(u8 
*store_addr, uptr n) {
   return getShadowPtrForStore(store_addr, n);
 }
 
-template  static bool isValidShadowType(const u8 *shadow_type) {
+template  static bool IsValidShadowType(const u8 *shadow_type) {
   return __builtin_memcmp(shadow_type, FTInfo::kTypePattern, sizeof(FT)) ==
  0;
 }
 
-template  static bool isZero(const T *ptr) {
+template  static bool IsZero(const T *ptr) {
   constexpr const char kZeros[kSize] = {}; // Zero initialized.
   return __builtin_memcmp(ptr, kZeros, kSize) == 0;
 }
 
-template  static bool isUnknownShadowType(const u8 *shadow_type) {
-  return isZero::kTypePattern)>(shadow_type);
+template  static bool IsUnknownShadowType(const u8 *shadow_type) {
+  return IsZero::kTypePattern)>(shadow_type);
 }
 
 // The three folowing functions check that the address stores a complete
@@ -249,21 +246,21 @@ template 
 static const u8 *getShadowPtrForLoad(const u8 *load_addr, uptr n) {
   const u8 *const shadow_type = getShadowTypeAddrFor(load_addr);
   for (uptr i = 0; i < n; ++i) {
-if (!isValidShadowType(shadow_type + i * sizeof(FT))) {
+if (!IsValidShadowType(shadow_type + i * sizeof(FT))) {
   // If loadtracking stats are enabled, log loads with invalid types
   // (tampered with through type punning).
   if (flags().enable_loadtracking_stats) {
-if (isUnknownShadowType(shadow_type + i * sizeof(FT))) {
+if (IsUnknownShadowType(shadow_type + i * sizeof(FT))) {
   // Warn only if the value is non-zero. Zero is special because
   // applications typically initialize large buffers to zero in an
   // untyped way.
-  if (!isZero(load_addr)) {
+  if (!IsZero(load_addr)) {
 GET_CALLER_PC_BP;
-nsan_stats->addUnknownLoadTrackingEvent(pc, bp);
+nsan_stats->AddUnknownLoadTrackingEvent(pc, bp);
   }
 } else {
   GET_CALLER_PC_BP;
-  nsan_stats->addInvalidLoadTrackingEvent(pc, bp);
+  nsan_stats->AddInvalidLoadTrackingEvent(pc, bp);
 }
   }
   return nullptr;
@@ -442,7 +439,7 @@ int32_t checkFT(const FT value, ShadowFT Shadow, CheckTypeT 
CheckType,
 // want to avoid having to move the computation of `largest` before the
 // absolute value check when this branch is not taken.
 const InternalFT largest = max(ftAbs(check_value), ftAbs(check_shadow));
-nsan_stats->addCheck(CheckType, pc, bp, abs_err / largest);
+nsan_stats->AddCheck(CheckType, pc, bp, abs_err / largest);
   }
 
   // Note: writing the comparison that way ensures that when `abs_err` is Nan
@@ -534,7 +531,7 @@ int32_t checkFT(const FT value, ShadowFT Shadow, CheckTypeT 
CheckType,
 
   if (flags().enable_warning_stats) {
 GET_CALLER_PC_BP;
-nsan_stats->addWarning(CheckType, pc, bp, abs_err / largest);
+nsan_stats->AddWarning(CheckType, pc, bp, abs_err / largest);
   }
 
   if (flags().halt_on_error) {
@@ -565,10 +562,10 @@ __nsan_internal_check_longdouble_q(long double value, 
__float128 shadow,
   return checkFT(value, shadow, static_cast(check_type), 
check_arg);
 }
 
-static const char *getTruthValueName(bool v) { return v ? "true" : "false"; }
+static const char *GetTruthValueName(bool v) { 

[llvm-branch-commits] [compiler-rt] [nsan] Fix style issue (PR #96142)

2024-06-20 Thread Fangrui Song via llvm-branch-commits

https://github.com/MaskRay updated 
https://github.com/llvm/llvm-project/pull/96142

>From 54357a77702361abf1044d1ee5d0dee3e4fa407c Mon Sep 17 00:00:00 2001
From: Fangrui Song 
Date: Thu, 20 Jun 2024 00:23:01 -0700
Subject: [PATCH 1/2] more

Created using spr 1.3.5-bogner
---
 compiler-rt/lib/nsan/nsan.cpp  |  59 ++--
 compiler-rt/lib/nsan/nsan_flags.cpp|   2 -
 compiler-rt/lib/nsan/nsan_stats.cpp| 107 ++---
 compiler-rt/lib/nsan/nsan_stats.h  |  43 +
 compiler-rt/lib/nsan/nsan_suppressions.cpp |  48 +
 5 files changed, 124 insertions(+), 135 deletions(-)

diff --git a/compiler-rt/lib/nsan/nsan.cpp b/compiler-rt/lib/nsan/nsan.cpp
index ece1130f73d14..fd5390e20a029 100644
--- a/compiler-rt/lib/nsan/nsan.cpp
+++ b/compiler-rt/lib/nsan/nsan.cpp
@@ -71,7 +71,6 @@ __nsan_set_value_unknown(const u8 *addr, uptr size) {
   internal_memset((void *)getShadowTypeAddrFor(addr), 0, size);
 }
 
-namespace __nsan {
 
 const char *FTInfo::kCppTypeName = "float";
 const char *FTInfo::kCppTypeName = "double";
@@ -177,8 +176,6 @@ template  T max(T a, T b) { return a < b ? b : 
a; }
 
 } // end anonymous namespace
 
-} // end namespace __nsan
-
 void __sanitizer::BufferedStackTrace::UnwindImpl(uptr pc, uptr bp,
  void *context,
  bool request_fast,
@@ -189,7 +186,7 @@ void __sanitizer::BufferedStackTrace::UnwindImpl(uptr pc, 
uptr bp,
 
 extern "C" SANITIZER_INTERFACE_ATTRIBUTE void __nsan_print_accumulated_stats() 
{
   if (nsan_stats)
-nsan_stats->print();
+nsan_stats->Print();
 }
 
 static void NsanAtexit() {
@@ -228,18 +225,18 @@ __nsan_get_shadow_ptr_for_longdouble_store(u8 
*store_addr, uptr n) {
   return getShadowPtrForStore(store_addr, n);
 }
 
-template  static bool isValidShadowType(const u8 *shadow_type) {
+template  static bool IsValidShadowType(const u8 *shadow_type) {
   return __builtin_memcmp(shadow_type, FTInfo::kTypePattern, sizeof(FT)) ==
  0;
 }
 
-template  static bool isZero(const T *ptr) {
+template  static bool IsZero(const T *ptr) {
   constexpr const char kZeros[kSize] = {}; // Zero initialized.
   return __builtin_memcmp(ptr, kZeros, kSize) == 0;
 }
 
-template  static bool isUnknownShadowType(const u8 *shadow_type) {
-  return isZero::kTypePattern)>(shadow_type);
+template  static bool IsUnknownShadowType(const u8 *shadow_type) {
+  return IsZero::kTypePattern)>(shadow_type);
 }
 
 // The three folowing functions check that the address stores a complete
@@ -249,21 +246,21 @@ template 
 static const u8 *getShadowPtrForLoad(const u8 *load_addr, uptr n) {
   const u8 *const shadow_type = getShadowTypeAddrFor(load_addr);
   for (uptr i = 0; i < n; ++i) {
-if (!isValidShadowType(shadow_type + i * sizeof(FT))) {
+if (!IsValidShadowType(shadow_type + i * sizeof(FT))) {
   // If loadtracking stats are enabled, log loads with invalid types
   // (tampered with through type punning).
   if (flags().enable_loadtracking_stats) {
-if (isUnknownShadowType(shadow_type + i * sizeof(FT))) {
+if (IsUnknownShadowType(shadow_type + i * sizeof(FT))) {
   // Warn only if the value is non-zero. Zero is special because
   // applications typically initialize large buffers to zero in an
   // untyped way.
-  if (!isZero(load_addr)) {
+  if (!IsZero(load_addr)) {
 GET_CALLER_PC_BP;
-nsan_stats->addUnknownLoadTrackingEvent(pc, bp);
+nsan_stats->AddUnknownLoadTrackingEvent(pc, bp);
   }
 } else {
   GET_CALLER_PC_BP;
-  nsan_stats->addInvalidLoadTrackingEvent(pc, bp);
+  nsan_stats->AddInvalidLoadTrackingEvent(pc, bp);
 }
   }
   return nullptr;
@@ -442,7 +439,7 @@ int32_t checkFT(const FT value, ShadowFT Shadow, CheckTypeT 
CheckType,
 // want to avoid having to move the computation of `largest` before the
 // absolute value check when this branch is not taken.
 const InternalFT largest = max(ftAbs(check_value), ftAbs(check_shadow));
-nsan_stats->addCheck(CheckType, pc, bp, abs_err / largest);
+nsan_stats->AddCheck(CheckType, pc, bp, abs_err / largest);
   }
 
   // Note: writing the comparison that way ensures that when `abs_err` is Nan
@@ -534,7 +531,7 @@ int32_t checkFT(const FT value, ShadowFT Shadow, CheckTypeT 
CheckType,
 
   if (flags().enable_warning_stats) {
 GET_CALLER_PC_BP;
-nsan_stats->addWarning(CheckType, pc, bp, abs_err / largest);
+nsan_stats->AddWarning(CheckType, pc, bp, abs_err / largest);
   }
 
   if (flags().halt_on_error) {
@@ -565,10 +562,10 @@ __nsan_internal_check_longdouble_q(long double value, 
__float128 shadow,
   return checkFT(value, shadow, static_cast(check_type), 
check_arg);
 }
 
-static const char *getTruthValueName(bool v) { return v ? "true" : "false"; }
+static const char *GetTruthValueName(bool v) { 

[llvm-branch-commits] [compiler-rt] [nsan] Fix style issue (PR #96142)

2024-06-20 Thread Fangrui Song via llvm-branch-commits

https://github.com/MaskRay updated 
https://github.com/llvm/llvm-project/pull/96142

>From 54357a77702361abf1044d1ee5d0dee3e4fa407c Mon Sep 17 00:00:00 2001
From: Fangrui Song 
Date: Thu, 20 Jun 2024 00:23:01 -0700
Subject: [PATCH] more

Created using spr 1.3.5-bogner
---
 compiler-rt/lib/nsan/nsan.cpp  |  59 ++--
 compiler-rt/lib/nsan/nsan_flags.cpp|   2 -
 compiler-rt/lib/nsan/nsan_stats.cpp| 107 ++---
 compiler-rt/lib/nsan/nsan_stats.h  |  43 +
 compiler-rt/lib/nsan/nsan_suppressions.cpp |  48 +
 5 files changed, 124 insertions(+), 135 deletions(-)

diff --git a/compiler-rt/lib/nsan/nsan.cpp b/compiler-rt/lib/nsan/nsan.cpp
index ece1130f73d14..fd5390e20a029 100644
--- a/compiler-rt/lib/nsan/nsan.cpp
+++ b/compiler-rt/lib/nsan/nsan.cpp
@@ -71,7 +71,6 @@ __nsan_set_value_unknown(const u8 *addr, uptr size) {
   internal_memset((void *)getShadowTypeAddrFor(addr), 0, size);
 }
 
-namespace __nsan {
 
 const char *FTInfo::kCppTypeName = "float";
 const char *FTInfo::kCppTypeName = "double";
@@ -177,8 +176,6 @@ template  T max(T a, T b) { return a < b ? b : 
a; }
 
 } // end anonymous namespace
 
-} // end namespace __nsan
-
 void __sanitizer::BufferedStackTrace::UnwindImpl(uptr pc, uptr bp,
  void *context,
  bool request_fast,
@@ -189,7 +186,7 @@ void __sanitizer::BufferedStackTrace::UnwindImpl(uptr pc, 
uptr bp,
 
 extern "C" SANITIZER_INTERFACE_ATTRIBUTE void __nsan_print_accumulated_stats() 
{
   if (nsan_stats)
-nsan_stats->print();
+nsan_stats->Print();
 }
 
 static void NsanAtexit() {
@@ -228,18 +225,18 @@ __nsan_get_shadow_ptr_for_longdouble_store(u8 
*store_addr, uptr n) {
   return getShadowPtrForStore(store_addr, n);
 }
 
-template  static bool isValidShadowType(const u8 *shadow_type) {
+template  static bool IsValidShadowType(const u8 *shadow_type) {
   return __builtin_memcmp(shadow_type, FTInfo::kTypePattern, sizeof(FT)) ==
  0;
 }
 
-template  static bool isZero(const T *ptr) {
+template  static bool IsZero(const T *ptr) {
   constexpr const char kZeros[kSize] = {}; // Zero initialized.
   return __builtin_memcmp(ptr, kZeros, kSize) == 0;
 }
 
-template  static bool isUnknownShadowType(const u8 *shadow_type) {
-  return isZero::kTypePattern)>(shadow_type);
+template  static bool IsUnknownShadowType(const u8 *shadow_type) {
+  return IsZero::kTypePattern)>(shadow_type);
 }
 
 // The three folowing functions check that the address stores a complete
@@ -249,21 +246,21 @@ template 
 static const u8 *getShadowPtrForLoad(const u8 *load_addr, uptr n) {
   const u8 *const shadow_type = getShadowTypeAddrFor(load_addr);
   for (uptr i = 0; i < n; ++i) {
-if (!isValidShadowType(shadow_type + i * sizeof(FT))) {
+if (!IsValidShadowType(shadow_type + i * sizeof(FT))) {
   // If loadtracking stats are enabled, log loads with invalid types
   // (tampered with through type punning).
   if (flags().enable_loadtracking_stats) {
-if (isUnknownShadowType(shadow_type + i * sizeof(FT))) {
+if (IsUnknownShadowType(shadow_type + i * sizeof(FT))) {
   // Warn only if the value is non-zero. Zero is special because
   // applications typically initialize large buffers to zero in an
   // untyped way.
-  if (!isZero(load_addr)) {
+  if (!IsZero(load_addr)) {
 GET_CALLER_PC_BP;
-nsan_stats->addUnknownLoadTrackingEvent(pc, bp);
+nsan_stats->AddUnknownLoadTrackingEvent(pc, bp);
   }
 } else {
   GET_CALLER_PC_BP;
-  nsan_stats->addInvalidLoadTrackingEvent(pc, bp);
+  nsan_stats->AddInvalidLoadTrackingEvent(pc, bp);
 }
   }
   return nullptr;
@@ -442,7 +439,7 @@ int32_t checkFT(const FT value, ShadowFT Shadow, CheckTypeT 
CheckType,
 // want to avoid having to move the computation of `largest` before the
 // absolute value check when this branch is not taken.
 const InternalFT largest = max(ftAbs(check_value), ftAbs(check_shadow));
-nsan_stats->addCheck(CheckType, pc, bp, abs_err / largest);
+nsan_stats->AddCheck(CheckType, pc, bp, abs_err / largest);
   }
 
   // Note: writing the comparison that way ensures that when `abs_err` is Nan
@@ -534,7 +531,7 @@ int32_t checkFT(const FT value, ShadowFT Shadow, CheckTypeT 
CheckType,
 
   if (flags().enable_warning_stats) {
 GET_CALLER_PC_BP;
-nsan_stats->addWarning(CheckType, pc, bp, abs_err / largest);
+nsan_stats->AddWarning(CheckType, pc, bp, abs_err / largest);
   }
 
   if (flags().halt_on_error) {
@@ -565,10 +562,10 @@ __nsan_internal_check_longdouble_q(long double value, 
__float128 shadow,
   return checkFT(value, shadow, static_cast(check_type), 
check_arg);
 }
 
-static const char *getTruthValueName(bool v) { return v ? "true" : "false"; }
+static const char *GetTruthValueName(bool v) { 

[llvm-branch-commits] [nsan] Fix style issue (PR #96142)

2024-06-20 Thread Fangrui Song via llvm-branch-commits

https://github.com/MaskRay created 
https://github.com/llvm/llvm-project/pull/96142

The initial check-in of compiler-rt/lib/nsan #94322 has a lot of style
issues. Fix them before the history becomes more useful.



___
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] [ELF] Orphan placement: remove hasInputSections condition (PR #93761)

2024-06-06 Thread Fangrui Song via llvm-branch-commits

https://github.com/MaskRay updated 
https://github.com/llvm/llvm-project/pull/93761

>From 316e0a1effb50b15fa1df54a43d02704f735309d Mon Sep 17 00:00:00 2001
From: Fangrui Song 
Date: Wed, 29 May 2024 20:14:18 -0700
Subject: [PATCH] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20initia?=
 =?UTF-8?q?l=20version?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Created using spr 1.3.5-bogner
---
 lld/ELF/Writer.cpp| 18 ++
 .../linkerscript/memory-nonalloc-no-warn.test | 19 +--
 lld/test/ELF/linkerscript/nobits-offset.s |  2 +-
 lld/test/ELF/linkerscript/orphan-live-only.s  |  6 +++---
 .../ELF/linkerscript/symbol-only-align.test   | 11 ++-
 lld/test/ELF/linkerscript/tls-nobits-offset.s |  2 +-
 6 files changed, 26 insertions(+), 32 deletions(-)

diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp
index c498153f3348b..4add995c93458 100644
--- a/lld/ELF/Writer.cpp
+++ b/lld/ELF/Writer.cpp
@@ -890,9 +890,7 @@ template  void 
Writer::setReservedSymbolSections() {
 // countLeadingZeros.
 static int getRankProximity(OutputSection *a, SectionCommand *b) {
   auto *osd = dyn_cast(b);
-  return (osd && osd->osec.hasInputSections)
- ? llvm::countl_zero(a->sortRank ^ osd->osec.sortRank)
- : -1;
+  return osd ? llvm::countl_zero(a->sortRank ^ osd->osec.sortRank) : -1;
 }
 
 // When placing orphan sections, we want to place them after symbol assignments
@@ -958,20 +956,16 @@ findOrphanPos(SmallVectorImpl::iterator 
b,
 sortRank = std::max(sortRank, foundSec->sortRank);
   for (; i != e; ++i) {
 auto *curSecDesc = dyn_cast(*i);
-if (!curSecDesc || !curSecDesc->osec.hasInputSections)
+if (!curSecDesc)
   continue;
 if (getRankProximity(sec, curSecDesc) != proximity ||
 sortRank < curSecDesc->osec.sortRank)
   break;
   }
 
-  auto isOutputSecWithInputSections = [](SectionCommand *cmd) {
-auto *osd = dyn_cast(cmd);
-return osd && osd->osec.hasInputSections;
-  };
-  auto j =
-  std::find_if(std::make_reverse_iterator(i), 
std::make_reverse_iterator(b),
-   isOutputSecWithInputSections);
+  auto isOutputSec = [](SectionCommand *cmd) { return isa(cmd); };
+  auto j = std::find_if(std::make_reverse_iterator(i),
+std::make_reverse_iterator(b), isOutputSec);
   i = j.base();
 
   // As a special case, if the orphan section is the last section, put
@@ -979,7 +973,7 @@ findOrphanPos(SmallVectorImpl::iterator b,
   // This matches bfd's behavior and is convenient when the linker script fully
   // specifies the start of the file, but doesn't care about the end (the non
   // alloc sections for example).
-  auto nextSec = std::find_if(i, e, isOutputSecWithInputSections);
+  auto nextSec = std::find_if(i, e, isOutputSec);
   if (nextSec == e)
 return e;
 
diff --git a/lld/test/ELF/linkerscript/memory-nonalloc-no-warn.test 
b/lld/test/ELF/linkerscript/memory-nonalloc-no-warn.test
index 2dcd0f8d6ce2f..9c6111008c818 100644
--- a/lld/test/ELF/linkerscript/memory-nonalloc-no-warn.test
+++ b/lld/test/ELF/linkerscript/memory-nonalloc-no-warn.test
@@ -16,22 +16,21 @@
 ## The output file must include all sections.
 # RUN: llvm-readelf -S %t/a.elf | FileCheck %s
 
-# CHECK:  There are 12 section headers, starting at offset 0x2140:
+# CHECK:  There are 12 section headers, starting at offset 0x2138:
 # CHECK:  [Nr] Name Type  Address  OffSize   ES 
Flg Lk Inf Al
 # CHECK-NEXT: [ 0]  NULL   00 00 00
 0  0   0
 # CHECK-NEXT: [ 1] .nonallocPROGBITS   001064 001000 00 W  
 0  0   1
-# CHECK-NEXT: [ 2] .comment PROGBITS   {{.*}} {{.*}} 01 MS 
 0  0   1
-# CHECK-NEXT: [ 3] .symtab  SYMTAB {{.*}} {{.*}} 18
 5  1   8
-# CHECK-NEXT: [ 4] .shstrtabSTRTAB {{.*}} {{.*}} 00
 0  0   1
-# CHECK-NEXT: [ 5] .strtab  STRTAB {{.*}} {{.*}} 00
 0  0   1
-# CHECK-NEXT: [ 6] .dat PROGBITS   002137 04 00 W  
 0  0   1
-# CHECK-NEXT: [ 7] .intvec0_out PROGBITS   00213b 00 00 W  
 0  0   1
-# CHECK-NEXT: [ 8] .intvec1_out PROGBITS   00213b 00 00 W  
 0  0   1
-# CHECK-NEXT: [ 9] .intvec2_out PROGBITS   00213b 00 00 W  
 0  0   1
+# CHECK-NEXT: [ 2] .dat PROGBITS   002064 04 00 W  
 0  0   1
+# CHECK-NEXT: [ 3] .intvec0_out PROGBITS   002068 00 00 W  
 0  0   1
+# CHECK-NEXT: [ 4] .intvec1_out PROGBITS   002068 00 00 W  
 0  0   1
+# CHECK-NEXT: [ 5] .intvec2_out PROGBITS   002068 00 00 W  
 0  0   1
+# CHECK-NEXT: [ 6] .comment PROGBITS   {{.*}} {{.*}} 01 MS 
 0  0   1
+# CHECK-NEXT: [ 7] .symtab  SYMTAB {{.*}} {{.*}} 18   

[llvm-branch-commits] [lld] [ELF] Orphan placement: remove hasInputSections condition (PR #93761)

2024-06-06 Thread Fangrui Song via llvm-branch-commits

https://github.com/MaskRay updated 
https://github.com/llvm/llvm-project/pull/93761

>From 316e0a1effb50b15fa1df54a43d02704f735309d Mon Sep 17 00:00:00 2001
From: Fangrui Song 
Date: Wed, 29 May 2024 20:14:18 -0700
Subject: [PATCH] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20initia?=
 =?UTF-8?q?l=20version?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Created using spr 1.3.5-bogner
---
 lld/ELF/Writer.cpp| 18 ++
 .../linkerscript/memory-nonalloc-no-warn.test | 19 +--
 lld/test/ELF/linkerscript/nobits-offset.s |  2 +-
 lld/test/ELF/linkerscript/orphan-live-only.s  |  6 +++---
 .../ELF/linkerscript/symbol-only-align.test   | 11 ++-
 lld/test/ELF/linkerscript/tls-nobits-offset.s |  2 +-
 6 files changed, 26 insertions(+), 32 deletions(-)

diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp
index c498153f3348b..4add995c93458 100644
--- a/lld/ELF/Writer.cpp
+++ b/lld/ELF/Writer.cpp
@@ -890,9 +890,7 @@ template  void 
Writer::setReservedSymbolSections() {
 // countLeadingZeros.
 static int getRankProximity(OutputSection *a, SectionCommand *b) {
   auto *osd = dyn_cast(b);
-  return (osd && osd->osec.hasInputSections)
- ? llvm::countl_zero(a->sortRank ^ osd->osec.sortRank)
- : -1;
+  return osd ? llvm::countl_zero(a->sortRank ^ osd->osec.sortRank) : -1;
 }
 
 // When placing orphan sections, we want to place them after symbol assignments
@@ -958,20 +956,16 @@ findOrphanPos(SmallVectorImpl::iterator 
b,
 sortRank = std::max(sortRank, foundSec->sortRank);
   for (; i != e; ++i) {
 auto *curSecDesc = dyn_cast(*i);
-if (!curSecDesc || !curSecDesc->osec.hasInputSections)
+if (!curSecDesc)
   continue;
 if (getRankProximity(sec, curSecDesc) != proximity ||
 sortRank < curSecDesc->osec.sortRank)
   break;
   }
 
-  auto isOutputSecWithInputSections = [](SectionCommand *cmd) {
-auto *osd = dyn_cast(cmd);
-return osd && osd->osec.hasInputSections;
-  };
-  auto j =
-  std::find_if(std::make_reverse_iterator(i), 
std::make_reverse_iterator(b),
-   isOutputSecWithInputSections);
+  auto isOutputSec = [](SectionCommand *cmd) { return isa(cmd); };
+  auto j = std::find_if(std::make_reverse_iterator(i),
+std::make_reverse_iterator(b), isOutputSec);
   i = j.base();
 
   // As a special case, if the orphan section is the last section, put
@@ -979,7 +973,7 @@ findOrphanPos(SmallVectorImpl::iterator b,
   // This matches bfd's behavior and is convenient when the linker script fully
   // specifies the start of the file, but doesn't care about the end (the non
   // alloc sections for example).
-  auto nextSec = std::find_if(i, e, isOutputSecWithInputSections);
+  auto nextSec = std::find_if(i, e, isOutputSec);
   if (nextSec == e)
 return e;
 
diff --git a/lld/test/ELF/linkerscript/memory-nonalloc-no-warn.test 
b/lld/test/ELF/linkerscript/memory-nonalloc-no-warn.test
index 2dcd0f8d6ce2f..9c6111008c818 100644
--- a/lld/test/ELF/linkerscript/memory-nonalloc-no-warn.test
+++ b/lld/test/ELF/linkerscript/memory-nonalloc-no-warn.test
@@ -16,22 +16,21 @@
 ## The output file must include all sections.
 # RUN: llvm-readelf -S %t/a.elf | FileCheck %s
 
-# CHECK:  There are 12 section headers, starting at offset 0x2140:
+# CHECK:  There are 12 section headers, starting at offset 0x2138:
 # CHECK:  [Nr] Name Type  Address  OffSize   ES 
Flg Lk Inf Al
 # CHECK-NEXT: [ 0]  NULL   00 00 00
 0  0   0
 # CHECK-NEXT: [ 1] .nonallocPROGBITS   001064 001000 00 W  
 0  0   1
-# CHECK-NEXT: [ 2] .comment PROGBITS   {{.*}} {{.*}} 01 MS 
 0  0   1
-# CHECK-NEXT: [ 3] .symtab  SYMTAB {{.*}} {{.*}} 18
 5  1   8
-# CHECK-NEXT: [ 4] .shstrtabSTRTAB {{.*}} {{.*}} 00
 0  0   1
-# CHECK-NEXT: [ 5] .strtab  STRTAB {{.*}} {{.*}} 00
 0  0   1
-# CHECK-NEXT: [ 6] .dat PROGBITS   002137 04 00 W  
 0  0   1
-# CHECK-NEXT: [ 7] .intvec0_out PROGBITS   00213b 00 00 W  
 0  0   1
-# CHECK-NEXT: [ 8] .intvec1_out PROGBITS   00213b 00 00 W  
 0  0   1
-# CHECK-NEXT: [ 9] .intvec2_out PROGBITS   00213b 00 00 W  
 0  0   1
+# CHECK-NEXT: [ 2] .dat PROGBITS   002064 04 00 W  
 0  0   1
+# CHECK-NEXT: [ 3] .intvec0_out PROGBITS   002068 00 00 W  
 0  0   1
+# CHECK-NEXT: [ 4] .intvec1_out PROGBITS   002068 00 00 W  
 0  0   1
+# CHECK-NEXT: [ 5] .intvec2_out PROGBITS   002068 00 00 W  
 0  0   1
+# CHECK-NEXT: [ 6] .comment PROGBITS   {{.*}} {{.*}} 01 MS 
 0  0   1
+# CHECK-NEXT: [ 7] .symtab  SYMTAB {{.*}} {{.*}} 18   

[llvm-branch-commits] [lld] [ELF] Orphan placement: remove hasInputSections condition (PR #93761)

2024-06-05 Thread Fangrui Song via llvm-branch-commits


@@ -16,22 +16,21 @@
 ## The output file must include all sections.
 # RUN: llvm-readelf -S %t/a.elf | FileCheck %s
 
-# CHECK:  There are 12 section headers, starting at offset 0x2140:
+# CHECK:  There are 12 section headers, starting at offset 0x2138:
 # CHECK:  [Nr] Name Type  Address  OffSize   ES 
Flg Lk Inf Al
 # CHECK-NEXT: [ 0]  NULL   00 00 00
 0  0   0
 # CHECK-NEXT: [ 1] .nonallocPROGBITS   001064 001000 00 W  
 0  0   1

MaskRay wrote:

With #93761 , this patch will not need to modify this test file, but GitHub PR 
doesn't seem to make it clear.

https://github.com/llvm/llvm-project/pull/93761
___
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] [ELF] Orphan placement: remove hasInputSections condition (PR #93761)

2024-06-05 Thread Fangrui Song via llvm-branch-commits

https://github.com/MaskRay edited 
https://github.com/llvm/llvm-project/pull/93761
___
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] [ELF] Orphan placement: remove hasInputSections condition (PR #93761)

2024-06-05 Thread Fangrui Song via llvm-branch-commits

https://github.com/MaskRay edited 
https://github.com/llvm/llvm-project/pull/93761
___
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] [ELF] Orphan placement: remove hasInputSections condition (PR #93761)

2024-06-05 Thread Fangrui Song via llvm-branch-commits

https://github.com/MaskRay updated 
https://github.com/llvm/llvm-project/pull/93761

>From 316e0a1effb50b15fa1df54a43d02704f735309d Mon Sep 17 00:00:00 2001
From: Fangrui Song 
Date: Wed, 29 May 2024 20:14:18 -0700
Subject: [PATCH] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20initia?=
 =?UTF-8?q?l=20version?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Created using spr 1.3.5-bogner
---
 lld/ELF/Writer.cpp| 18 ++
 .../linkerscript/memory-nonalloc-no-warn.test | 19 +--
 lld/test/ELF/linkerscript/nobits-offset.s |  2 +-
 lld/test/ELF/linkerscript/orphan-live-only.s  |  6 +++---
 .../ELF/linkerscript/symbol-only-align.test   | 11 ++-
 lld/test/ELF/linkerscript/tls-nobits-offset.s |  2 +-
 6 files changed, 26 insertions(+), 32 deletions(-)

diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp
index c498153f3348b..4add995c93458 100644
--- a/lld/ELF/Writer.cpp
+++ b/lld/ELF/Writer.cpp
@@ -890,9 +890,7 @@ template  void 
Writer::setReservedSymbolSections() {
 // countLeadingZeros.
 static int getRankProximity(OutputSection *a, SectionCommand *b) {
   auto *osd = dyn_cast(b);
-  return (osd && osd->osec.hasInputSections)
- ? llvm::countl_zero(a->sortRank ^ osd->osec.sortRank)
- : -1;
+  return osd ? llvm::countl_zero(a->sortRank ^ osd->osec.sortRank) : -1;
 }
 
 // When placing orphan sections, we want to place them after symbol assignments
@@ -958,20 +956,16 @@ findOrphanPos(SmallVectorImpl::iterator 
b,
 sortRank = std::max(sortRank, foundSec->sortRank);
   for (; i != e; ++i) {
 auto *curSecDesc = dyn_cast(*i);
-if (!curSecDesc || !curSecDesc->osec.hasInputSections)
+if (!curSecDesc)
   continue;
 if (getRankProximity(sec, curSecDesc) != proximity ||
 sortRank < curSecDesc->osec.sortRank)
   break;
   }
 
-  auto isOutputSecWithInputSections = [](SectionCommand *cmd) {
-auto *osd = dyn_cast(cmd);
-return osd && osd->osec.hasInputSections;
-  };
-  auto j =
-  std::find_if(std::make_reverse_iterator(i), 
std::make_reverse_iterator(b),
-   isOutputSecWithInputSections);
+  auto isOutputSec = [](SectionCommand *cmd) { return isa(cmd); };
+  auto j = std::find_if(std::make_reverse_iterator(i),
+std::make_reverse_iterator(b), isOutputSec);
   i = j.base();
 
   // As a special case, if the orphan section is the last section, put
@@ -979,7 +973,7 @@ findOrphanPos(SmallVectorImpl::iterator b,
   // This matches bfd's behavior and is convenient when the linker script fully
   // specifies the start of the file, but doesn't care about the end (the non
   // alloc sections for example).
-  auto nextSec = std::find_if(i, e, isOutputSecWithInputSections);
+  auto nextSec = std::find_if(i, e, isOutputSec);
   if (nextSec == e)
 return e;
 
diff --git a/lld/test/ELF/linkerscript/memory-nonalloc-no-warn.test 
b/lld/test/ELF/linkerscript/memory-nonalloc-no-warn.test
index 2dcd0f8d6ce2f..9c6111008c818 100644
--- a/lld/test/ELF/linkerscript/memory-nonalloc-no-warn.test
+++ b/lld/test/ELF/linkerscript/memory-nonalloc-no-warn.test
@@ -16,22 +16,21 @@
 ## The output file must include all sections.
 # RUN: llvm-readelf -S %t/a.elf | FileCheck %s
 
-# CHECK:  There are 12 section headers, starting at offset 0x2140:
+# CHECK:  There are 12 section headers, starting at offset 0x2138:
 # CHECK:  [Nr] Name Type  Address  OffSize   ES 
Flg Lk Inf Al
 # CHECK-NEXT: [ 0]  NULL   00 00 00
 0  0   0
 # CHECK-NEXT: [ 1] .nonallocPROGBITS   001064 001000 00 W  
 0  0   1
-# CHECK-NEXT: [ 2] .comment PROGBITS   {{.*}} {{.*}} 01 MS 
 0  0   1
-# CHECK-NEXT: [ 3] .symtab  SYMTAB {{.*}} {{.*}} 18
 5  1   8
-# CHECK-NEXT: [ 4] .shstrtabSTRTAB {{.*}} {{.*}} 00
 0  0   1
-# CHECK-NEXT: [ 5] .strtab  STRTAB {{.*}} {{.*}} 00
 0  0   1
-# CHECK-NEXT: [ 6] .dat PROGBITS   002137 04 00 W  
 0  0   1
-# CHECK-NEXT: [ 7] .intvec0_out PROGBITS   00213b 00 00 W  
 0  0   1
-# CHECK-NEXT: [ 8] .intvec1_out PROGBITS   00213b 00 00 W  
 0  0   1
-# CHECK-NEXT: [ 9] .intvec2_out PROGBITS   00213b 00 00 W  
 0  0   1
+# CHECK-NEXT: [ 2] .dat PROGBITS   002064 04 00 W  
 0  0   1
+# CHECK-NEXT: [ 3] .intvec0_out PROGBITS   002068 00 00 W  
 0  0   1
+# CHECK-NEXT: [ 4] .intvec1_out PROGBITS   002068 00 00 W  
 0  0   1
+# CHECK-NEXT: [ 5] .intvec2_out PROGBITS   002068 00 00 W  
 0  0   1
+# CHECK-NEXT: [ 6] .comment PROGBITS   {{.*}} {{.*}} 01 MS 
 0  0   1
+# CHECK-NEXT: [ 7] .symtab  SYMTAB {{.*}} {{.*}} 18   

[llvm-branch-commits] [lld] [lld] Discard SHT_LLVM_LTO sections in relocatable links (PR #92825)

2024-05-21 Thread Fangrui Song via llvm-branch-commits

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


https://github.com/llvm/llvm-project/pull/92825
___
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] Discard SHT_LLVM_LTO sections in relocatable links (PR #92825)

2024-05-20 Thread Fangrui Song via llvm-branch-commits

https://github.com/MaskRay edited 
https://github.com/llvm/llvm-project/pull/92825
___
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] Discard SHT_LLVM_LTO sections in relocatable links (PR #92825)

2024-05-20 Thread Fangrui Song via llvm-branch-commits


@@ -832,6 +832,15 @@ void ObjFile::initializeSections(bool ignoreComdats,
   this->sections[i] =
   createInputSection(i, sec, check(obj.getSectionName(sec, shstrtab)));
   break;
+case SHT_LLVM_LTO:
+  // When doing a relocatable link with FatLTO objects, if we're not using

MaskRay wrote:

// Discard .llvm.lto in a relocatable link that does not use the bitcode. The 
concatenated output does not reflect the semantics. In addition, since we do 
not use the bitcode wrapper format, the concatenated raw bitcode would be 
invalid.

https://github.com/llvm/llvm-project/pull/92825
___
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] Discard SHT_LLVM_LTO sections in relocatable links (PR #92825)

2024-05-20 Thread Fangrui Song via llvm-branch-commits


@@ -832,6 +832,15 @@ void ObjFile::initializeSections(bool ignoreComdats,
   this->sections[i] =
   createInputSection(i, sec, check(obj.getSectionName(sec, shstrtab)));
   break;
+case SHT_LLVM_LTO:
+  // When doing a relocatable link with FatLTO objects, if we're not using
+  // the bitcode, discard it, since it will be concatenated together when
+  // handling orphan sections, and which will be an invalid bitcode object.
+  if (config->relocatable && !config->fatLTOObjects) {
+sections[i] = ::discarded;
+break;
+  }
+  LLVM_FALLTHROUGH;

MaskRay wrote:

`[[fallthrough]]` since C++17

https://github.com/llvm/llvm-project/pull/92825
___
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] Discard SHT_LLVM_LTO sections in relocatable links (PR #92825)

2024-05-20 Thread Fangrui Song via llvm-branch-commits

MaskRay wrote:

There is a bitcode wrapper (see discussions at 
https://reviews.llvm.org/D86847), but I agree that discarding `.llvm.lto` is 
better since concatenated `.llvm.lto` does not reflect the `ld.lld -r 
` semantics.

https://github.com/llvm/llvm-project/pull/92825
___
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] [llvm] release/18.x: [llvm][lld] Pre-commit tests for RISCV TLSDESC symbols (PR #91632)

2024-05-10 Thread Fangrui Song via llvm-branch-commits

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


https://github.com/llvm/llvm-project/pull/91632
___
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] [llvm] release/18.x: [RISCV][lld] Set the type of TLSDESC relocation's referenced local symbol to STT_NOTYPE (PR #91678)

2024-05-10 Thread Fangrui Song via llvm-branch-commits

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


https://github.com/llvm/llvm-project/pull/91678
___
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] [llvm] release/18.x: [RISCV][lld] Set the type of TLSDESC relocation's referenced local symbol to STT_NOTYPE (PR #91678)

2024-05-09 Thread Fangrui Song via llvm-branch-commits

MaskRay wrote:

LGTM

https://github.com/llvm/llvm-project/pull/91678
___
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] [llvm] release/18.x: [llvm][lld] Pre-commit tests for RISCV TLSDESC symbols (PR #91632)

2024-05-09 Thread Fangrui Song via llvm-branch-commits

MaskRay wrote:

LGTM

https://github.com/llvm/llvm-project/pull/91632
___
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] [LoongArch][Codegen] Add support for TLSDESC (PR #90159)

2024-04-29 Thread Fangrui Song via llvm-branch-commits

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


https://github.com/llvm/llvm-project/pull/90159
___
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] [LoongArch][Codegen] Add support for TLSDESC (PR #90159)

2024-04-29 Thread Fangrui Song via llvm-branch-commits

MaskRay wrote:

Add a test to clang/test/Driver/tls-dialect.c

https://github.com/llvm/llvm-project/pull/90159
___
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] [llvm] release/18.x: [LoongArch] Use R_LARCH_ALIGN with section symbol (#84741) (PR #88891)

2024-04-19 Thread Fangrui Song via llvm-branch-commits

https://github.com/MaskRay requested changes to this pull request.

Sorry, NAK.

I objected to https://sourceware.org/pipermail/binutils/2024-April/133725.html 
as well. This requires more discussion.

https://github.com/llvm/llvm-project/pull/88891
___
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] [llvm] release/18.x: [LoongArch] Use R_LARCH_ALIGN with section symbol (#84741) (PR #88891)

2024-04-18 Thread Fangrui Song via llvm-branch-commits

MaskRay wrote:

LGTM for GCC/binutils compatibility

https://github.com/llvm/llvm-project/pull/88891
___
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] ReleaseNote: Mention SpecialCaseList change (PR #89141)

2024-04-18 Thread Fangrui Song via llvm-branch-commits

https://github.com/MaskRay updated 
https://github.com/llvm/llvm-project/pull/89141

>From a562fa55380991c37b0ec3ace83a98715795517a Mon Sep 17 00:00:00 2001
From: Fangrui Song 
Date: Wed, 17 Apr 2024 13:51:25 -0700
Subject: [PATCH 1/3] ReleaseNote: Mention SpecialCaseList change

---
 llvm/docs/ReleaseNotes.rst | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/llvm/docs/ReleaseNotes.rst b/llvm/docs/ReleaseNotes.rst
index ecfcd2c983ce5e..453abc63397764 100644
--- a/llvm/docs/ReleaseNotes.rst
+++ b/llvm/docs/ReleaseNotes.rst
@@ -435,6 +435,12 @@ Changes to Sanitizers
 -
 * HWASan now defaults to detecting use-after-scope bugs.
 
+* ``SpecialCaseList`` used by sanitizer ignore lists (e.g. ``*_ignorelist.txt``
+  in the Clang resource directory) now uses glob patterns instead of a variant
+  of POSIX Extended Regular Expression (where ``*`` is translated to ``.*``) by
+  default. Search for ``|`` to find patterns that may have different meanings
+  now.
+
 Changes to the Profile Runtime
 --
 

>From ac705f3426a08296b3125beb68ac941d1d7266fd Mon Sep 17 00:00:00 2001
From: Fangrui Song 
Date: Wed, 17 Apr 2024 23:37:28 -0700
Subject: [PATCH 2/3] Add a link

---
 llvm/docs/ReleaseNotes.rst | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/llvm/docs/ReleaseNotes.rst b/llvm/docs/ReleaseNotes.rst
index 453abc63397764..7c08935af385d2 100644
--- a/llvm/docs/ReleaseNotes.rst
+++ b/llvm/docs/ReleaseNotes.rst
@@ -435,11 +435,11 @@ Changes to Sanitizers
 -
 * HWASan now defaults to detecting use-after-scope bugs.
 
-* ``SpecialCaseList`` used by sanitizer ignore lists (e.g. ``*_ignorelist.txt``
-  in the Clang resource directory) now uses glob patterns instead of a variant
-  of POSIX Extended Regular Expression (where ``*`` is translated to ``.*``) by
-  default. Search for ``|`` to find patterns that may have different meanings
-  now.
+* `SpecialCaseList 
`_
+  used by sanitizer ignore lists (e.g. ``*_ignorelist.txt`` in the Clang
+  resource directory) now uses glob patterns instead of a variant of POSIX
+  Extended Regular Expression (where ``*`` is translated to ``.*``) by default.
+  Search for ``|`` to find patterns that may have different meanings now.
 
 Changes to the Profile Runtime
 --

>From e27af1095a716e09e1f005808e2d279867689306 Mon Sep 17 00:00:00 2001
From: Fangrui Song 
Date: Thu, 18 Apr 2024 10:27:09 -0700
Subject: [PATCH 3/3] Update llvm/docs/ReleaseNotes.rst

Co-authored-by: Paul T Robinson 
---
 llvm/docs/ReleaseNotes.rst | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/llvm/docs/ReleaseNotes.rst b/llvm/docs/ReleaseNotes.rst
index 7c08935af385d2..ff929b0bc5e15b 100644
--- a/llvm/docs/ReleaseNotes.rst
+++ b/llvm/docs/ReleaseNotes.rst
@@ -439,7 +439,8 @@ Changes to Sanitizers
   used by sanitizer ignore lists (e.g. ``*_ignorelist.txt`` in the Clang
   resource directory) now uses glob patterns instead of a variant of POSIX
   Extended Regular Expression (where ``*`` is translated to ``.*``) by default.
-  Search for ``|`` to find patterns that may have different meanings now.
+  Search for ``|`` to find patterns that may have different meanings now, and
+  replace ``a|b`` with ``{a,b}``.
 
 Changes to the Profile Runtime
 --

___
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] ReleaseNote: Mention SpecialCaseList change (PR #89141)

2024-04-18 Thread Fangrui Song via llvm-branch-commits

MaskRay wrote:

> Should we add a link to the docs?
> 
> [clang.llvm.org/docs/SanitizerSpecialCaseList.html#format](https://clang.llvm.org/docs/SanitizerSpecialCaseList.html#format)

Thanks for the suggestion. Added

https://github.com/llvm/llvm-project/pull/89141
___
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] ReleaseNote: Mention SpecialCaseList change (PR #89141)

2024-04-18 Thread Fangrui Song via llvm-branch-commits

https://github.com/MaskRay updated 
https://github.com/llvm/llvm-project/pull/89141

>From a562fa55380991c37b0ec3ace83a98715795517a Mon Sep 17 00:00:00 2001
From: Fangrui Song 
Date: Wed, 17 Apr 2024 13:51:25 -0700
Subject: [PATCH 1/2] ReleaseNote: Mention SpecialCaseList change

---
 llvm/docs/ReleaseNotes.rst | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/llvm/docs/ReleaseNotes.rst b/llvm/docs/ReleaseNotes.rst
index ecfcd2c983ce5e..453abc63397764 100644
--- a/llvm/docs/ReleaseNotes.rst
+++ b/llvm/docs/ReleaseNotes.rst
@@ -435,6 +435,12 @@ Changes to Sanitizers
 -
 * HWASan now defaults to detecting use-after-scope bugs.
 
+* ``SpecialCaseList`` used by sanitizer ignore lists (e.g. ``*_ignorelist.txt``
+  in the Clang resource directory) now uses glob patterns instead of a variant
+  of POSIX Extended Regular Expression (where ``*`` is translated to ``.*``) by
+  default. Search for ``|`` to find patterns that may have different meanings
+  now.
+
 Changes to the Profile Runtime
 --
 

>From ac705f3426a08296b3125beb68ac941d1d7266fd Mon Sep 17 00:00:00 2001
From: Fangrui Song 
Date: Wed, 17 Apr 2024 23:37:28 -0700
Subject: [PATCH 2/2] Add a link

---
 llvm/docs/ReleaseNotes.rst | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/llvm/docs/ReleaseNotes.rst b/llvm/docs/ReleaseNotes.rst
index 453abc63397764..7c08935af385d2 100644
--- a/llvm/docs/ReleaseNotes.rst
+++ b/llvm/docs/ReleaseNotes.rst
@@ -435,11 +435,11 @@ Changes to Sanitizers
 -
 * HWASan now defaults to detecting use-after-scope bugs.
 
-* ``SpecialCaseList`` used by sanitizer ignore lists (e.g. ``*_ignorelist.txt``
-  in the Clang resource directory) now uses glob patterns instead of a variant
-  of POSIX Extended Regular Expression (where ``*`` is translated to ``.*``) by
-  default. Search for ``|`` to find patterns that may have different meanings
-  now.
+* `SpecialCaseList 
`_
+  used by sanitizer ignore lists (e.g. ``*_ignorelist.txt`` in the Clang
+  resource directory) now uses glob patterns instead of a variant of POSIX
+  Extended Regular Expression (where ``*`` is translated to ``.*``) by default.
+  Search for ``|`` to find patterns that may have different meanings now.
 
 Changes to the Profile Runtime
 --

___
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] [CIR] Add options to emit ClangIR and enable the ClangIR pipeline (PR #89030)

2024-04-17 Thread Fangrui Song via llvm-branch-commits


@@ -2876,6 +2876,15 @@ def flax_vector_conversions : Flag<["-"], 
"flax-vector-conversions">, Group, Group,
   HelpText<"Force linking the clang builtins runtime library">;
+
+/// ClangIR-specific options - BEGIN
+def fclangir_enable : Flag<["-"], "fclangir-enable">, Visibility<[ClangOption, 
CC1Option]>,

MaskRay wrote:

+1 to -fclangir and -fno-clangir.

You can use `BoolFOption` to define two options at one time. Ensure that only 
the positive form gets a `CC1Option` (so that `clang -cc1 -fno-clangir` is 
invalid`)

https://github.com/llvm/llvm-project/pull/89030
___
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] release/18.x: [X86] Always use 64-bit relocations in no-PIC large code model (#89101) (PR #89124)

2024-04-17 Thread Fangrui Song via llvm-branch-commits

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


https://github.com/llvm/llvm-project/pull/89124
___
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] ReleaseNote: Mention SpecialCaseList change (PR #89141)

2024-04-17 Thread Fangrui Song via llvm-branch-commits

https://github.com/MaskRay updated 
https://github.com/llvm/llvm-project/pull/89141

>From a562fa55380991c37b0ec3ace83a98715795517a Mon Sep 17 00:00:00 2001
From: Fangrui Song 
Date: Wed, 17 Apr 2024 13:51:25 -0700
Subject: [PATCH] ReleaseNote: Mention SpecialCaseList change

---
 llvm/docs/ReleaseNotes.rst | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/llvm/docs/ReleaseNotes.rst b/llvm/docs/ReleaseNotes.rst
index ecfcd2c983ce5e..453abc63397764 100644
--- a/llvm/docs/ReleaseNotes.rst
+++ b/llvm/docs/ReleaseNotes.rst
@@ -435,6 +435,12 @@ Changes to Sanitizers
 -
 * HWASan now defaults to detecting use-after-scope bugs.
 
+* ``SpecialCaseList`` used by sanitizer ignore lists (e.g. ``*_ignorelist.txt``
+  in the Clang resource directory) now uses glob patterns instead of a variant
+  of POSIX Extended Regular Expression (where ``*`` is translated to ``.*``) by
+  default. Search for ``|`` to find patterns that may have different meanings
+  now.
+
 Changes to the Profile Runtime
 --
 

___
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] ReleaseNote: Mention SpecialCaseList change (PR #89141)

2024-04-17 Thread Fangrui Song via llvm-branch-commits

https://github.com/MaskRay milestoned 
https://github.com/llvm/llvm-project/pull/89141
___
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] ReleaseNote: Mention SpecialCaseList change (PR #89141)

2024-04-17 Thread Fangrui Song via llvm-branch-commits

https://github.com/MaskRay created 
https://github.com/llvm/llvm-project/pull/89141

None

>From 34afd4aa3c44d65f66edfc9e568890fd16d81a59 Mon Sep 17 00:00:00 2001
From: Fangrui Song 
Date: Wed, 17 Apr 2024 13:51:25 -0700
Subject: [PATCH] ReleaseNote: Mention SpecialCaseList change

---
 llvm/docs/ReleaseNotes.rst | 5 +
 1 file changed, 5 insertions(+)

diff --git a/llvm/docs/ReleaseNotes.rst b/llvm/docs/ReleaseNotes.rst
index ecfcd2c983ce5e..e049689adc703c 100644
--- a/llvm/docs/ReleaseNotes.rst
+++ b/llvm/docs/ReleaseNotes.rst
@@ -435,6 +435,11 @@ Changes to Sanitizers
 -
 * HWASan now defaults to detecting use-after-scope bugs.
 
+* ``SpecialCaseList`` used by sanitizer ignore lists now uses glob patterns
+  instead of a variant of POSIX Extended Regular Expression (where ``*`` is
+  translated to ``.*``) by default. Search for ``|`` to find patterns that may
+  have different meanings now.
+
 Changes to the Profile Runtime
 --
 

___
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/18.x: [lld/ELF][X86] Respect outSecOff when checking if GOTPCREL can be relaxed (#86334) (PR #86688)

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

MaskRay wrote:

The patch in question fixed a regression (assert in certain cases) introduced 
by https://reviews.llvm.org/D157020

https://github.com/llvm/llvm-project/pull/86688
___
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/18.x: [lld/ELF][X86] Respect outSecOff when checking if GOTPCREL can be relaxed (#86334) (PR #86688)

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

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


https://github.com/llvm/llvm-project/pull/86688
___
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] [lld] Fix handling of RISCV TLSDESC relocations (PR #85817)

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

MaskRay wrote:

The title is not descriptive. This is primarily a RISC-V side MC issue. Perhaps

`[RISCV,lld] Set the type of TLSDESC relocations referenced local symbol to 
STT_NOTYPE`

https://github.com/llvm/llvm-project/pull/85817
___
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] [lld] Fix handling of RISCV TLSDESC relocations (PR #85817)

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


@@ -1480,7 +1480,13 @@ template  void 
RelocationScanner::scanOne(RelTy *) {
 
   // Process TLS relocations, including TLS optimizations. Note that
   // R_TPREL and R_TPREL_NEG relocations are resolved in processAux.
-  if (sym.isTls()) {
+  if (sym.isTls() ||

MaskRay wrote:

Attach this diff
```
-  if (sym.isTls() ||
-  // These RISCV TLSDESC relocations reference a local symbol that won't be
-  // a TLS symbol, but we need to process them in handleTlsRelocation the
-  // same as other TLS relocations.
-  (config->emachine == EM_RISCV &&
-   (type == R_RISCV_TLSDESC_CALL || type == R_RISCV_TLSDESC_LOAD_LO12 ||
-type == R_RISCV_TLSDESC_ADD_LO12))) {
+  //
+  // Some RISCV TLSDESC relocations reference a local NOTYPE symbol, but we
+  // need to process them in handleTlsRelocation.
+  if (sym.isTls() || oneof(expr)) {
```

https://github.com/llvm/llvm-project/pull/85817
___
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] [lld] Fix handling of RISCV TLSDESC relocations (PR #85817)

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

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


https://github.com/llvm/llvm-project/pull/85817
___
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] [lld] Fix handling of RISCV TLSDESC relocations (PR #85817)

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


@@ -136,28 +140,30 @@
 
 # IE32:   .got 0008 00012248
 
-# IE32-LABEL: <.text>:
+# IE32-LABEL: <.Ltlsdesc_hi0>:
 ## st_value(a) = 8
 # IE32-NEXT: addizero, zero, 0x0
 # IE32-NEXT: addizero, zero, 0x0
 # IE32-NEXT: addizero, zero, 0x0
 # IE32-NEXT: addia0, zero, 0x8
 # IE32-NEXT: add a0, a0, tp
 ## st_value(b) = 2047
+# IE32-LABEL: <.Ltlsdesc_hi1>:
 # IE32-NEXT: addizero, zero, 0x0
 # IE32-NEXT: addizero, zero, 0x0
 # IE32-NEXT: addizero, zero, 0x0
 # IE32-NEXT: addia0, zero, 0x7ff
 # IE32-NEXT: add a0, a0, tp
 ## &.got[c]-. = 0x12248+4 - 0x111cc = 0x1080
+# IE32-LABEL: <.Ltlsdesc_hi2>:
 # IE32-NEXT: addizero, zero, 0x0
 # IE32-NEXT: addizero, zero, 0x0
 # IE32-NEXT:  111cc: auipc   a0, 0x1
 # IE32-NEXT: lw  a0, 0x80(a0)
 # IE32-NEXT: add a0, a0, tp
 
-## FIXME This should not pass, but the code MC layer needs a fix to prevent 
this.
-# BADTLSLABEL: error: d.{{.*}}.o has an STT_TLS symbol but doesn't have an 
SHF_TLS section
+# At one point the local TLSDESC labels would be marked STT_TLS, so make sure 
we don't regress
+# BADTLSLABEL-NOT: error: d.{{.*}}.o has an STT_TLS symbol but doesn't have an 
SHF_TLS section

MaskRay wrote:

Delete the NOT pattern. If the diagnostic changes, the NOT pattern may likely 
not get updated.

`# ` => `## Before #85817`

https://github.com/llvm/llvm-project/pull/85817
___
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] [lld] Fix handling of RISCV TLSDESC relocations (PR #85817)

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


@@ -30,10 +30,10 @@
 # RUN: llvm-objdump --no-show-raw-insn -M no-aliases -h -d a.32.ie | FileCheck 
%s --check-prefix=IE32
 
 # RUN: llvm-mc -triple=riscv64 -filetype=obj d.s -o d.64.o
-# RUN: not ld.lld -shared -soname=d.64.so -o d.64.so d.64.o 2>&1 | FileCheck 
%s --check-prefix=BADTLSLABEL
+# RUN: ld.lld -shared -soname=d.64.so -o d.64.so d.64.o 2>&1 | FileCheck %s 
--check-prefix=BADTLSLABEL --allow-empty

MaskRay wrote:

--allow-empty is an anti-pattern. Avoid.

Replace `2>&1 | ...` with --fatal-warnings

https://github.com/llvm/llvm-project/pull/85817
___
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/18.x: [ELF] Eliminate symbols demoted due to /DISCARD/ discarded sections (#85167) (PR #85266)

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

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


https://github.com/llvm/llvm-project/pull/85266
___
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-objcopy] Add --compress-sections (PR #85036)

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

https://github.com/MaskRay updated 
https://github.com/llvm/llvm-project/pull/85036


___
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-objcopy] Add --compress-sections (PR #85036)

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

https://github.com/MaskRay updated 
https://github.com/llvm/llvm-project/pull/85036


___
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] [libcxxabi] [libunwind] release/18.x: [runtimes] Prefer -fvisibility-global-new-delete=force-hidden (#84917) (PR #85126)

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

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


https://github.com/llvm/llvm-project/pull/85126
___
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][ubsan] Switch UBSAN optimization to `llvm.experimental.hot` (PR #84858)

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


@@ -100,9 +100,9 @@ using namespace llvm;
 namespace llvm {
 extern cl::opt PrintPipelinePasses;
 
-cl::opt ClRemoveTraps("clang-remove-traps", cl::Optional,
-cl::desc("Insert remove-traps pass."),
-cl::init(false));
+static cl::opt ClRemoveTraps("clang-remove-traps", cl::Optional,
+   cl::desc("Insert remove-traps pass."),
+   cl::init(false));

MaskRay wrote:

We usually omit `cl::init(false)`

https://github.com/llvm/llvm-project/pull/84858
___
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-objcopy] --[de]compress-debug-sections: don't compress SHF_ALLOC sections, only decompress .debug sections (PR #84885)

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

https://github.com/MaskRay updated 
https://github.com/llvm/llvm-project/pull/84885


___
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-objcopy] --[de]compress-debug-sections: don't compress SHF_ALLOC sections, only decompress .debug sections (PR #84885)

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

https://github.com/MaskRay edited 
https://github.com/llvm/llvm-project/pull/84885
___
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-objcopy] --[de]compress-debug-sections: don't compress SHF_ALLOC sections, only decompress .debug sections (PR #84885)

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

https://github.com/MaskRay updated 
https://github.com/llvm/llvm-project/pull/84885


___
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-objcopy] Simplify --[de]compress-debug-sections and don't compress SHF_ALLOC sections (PR #84885)

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


@@ -214,33 +214,34 @@ static Error dumpSectionToFile(StringRef SecName, 
StringRef Filename,
SecName.str().c_str());
 }
 
-static bool isCompressable(const SectionBase ) {
-  return !(Sec.Flags & ELF::SHF_COMPRESSED) &&
- StringRef(Sec.Name).starts_with(".debug");
-}
-
-static Error replaceDebugSections(
-Object , function_ref ShouldReplace,
-function_ref(const SectionBase *)> AddSection) {
+Error Object::compressOrDecompressSections(const CommonConfig ) {
   // Build a list of the debug sections we are going to replace.
   // We can't call `AddSection` while iterating over sections,
   // because it would mutate the sections array.
-  SmallVector ToReplace;
-  for (auto  : Obj.sections())
-if (ShouldReplace(Sec))
-  ToReplace.push_back();
-
-  // Build a mapping from original section to a new one.
-  DenseMap FromTo;
-  for (SectionBase *S : ToReplace) {
-Expected NewSection = AddSection(S);
-if (!NewSection)
-  return NewSection.takeError();
-
-FromTo[S] = *NewSection;
+  SmallVector>, 0>

MaskRay wrote:

The default is a smart value to keep `sizeof(SmallVector)` around 64 bytes. 
Someone might send a RFC to change the default to 0 and have another mechanism 
to use the default. I believe `, 0` is used much more than the smart default, 
since in many cases people don't care about extra heap allocations at runtime, 
but I care about code size and the smaller structure of `SmallVector`.

https://github.com/llvm/llvm-project/pull/84885
___
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] [llvm][lld][RISCV] Support x3_reg_usage (PR #84598)

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


@@ -1135,11 +1135,34 @@ static void mergeAtomic(DenseMap::iterator it,
   };
 }
 
+static void mergeX3RegUse(DenseMap::iterator it,
+  const InputSectionBase *oldSection,
+  const InputSectionBase *newSection,
+  unsigned int oldTag, unsigned int newTag) {
+  // X3/GP register usage ar incompatible and cannot be merged, with the
+  // exception of the UNKNOWN or 0 value
+  using RISCVAttrs::RISCVX3RegUse::X3RegUsage;
+  if (newTag == X3RegUsage::UNKNOWN)
+return;
+  if (oldTag == X3RegUsage::UNKNOWN) {
+it->getSecond() = newTag;
+return;
+  }
+  if (oldTag != newTag) {
+errorOrWarn(toString(oldSection) + " has x3_reg_usage=" + Twine(oldTag) +

MaskRay wrote:

We seem to use errors for parsing errors. This is probably a warning.

https://github.com/llvm/llvm-project/pull/84598
___
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] [llvm][lld][RISCV] Support x3_reg_usage (PR #84598)

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


@@ -412,6 +429,36 @@
 # A6S_A7:   }
 # A6S_A7: }
 
+#--- x3_reg_usage_unknown.s
+.attribute x3_reg_usage, 0
+
+#--- x3_reg_usage_gp.s
+.attribute x3_reg_usage, 1
+
+#--- x3_reg_usage_scs.s
+.attribute x3_reg_usage, 2
+
+#--- x3_reg_usage_tmp.s
+.attribute x3_reg_usage, 3
+
+# X3_REG_SCS_UKNOWN: BuildAttributes {
+# X3_REG_SCS_UKNOWN:   FormatVersion: 0x41

MaskRay wrote:

Add `-NEXT:` whenever appropriate

https://github.com/llvm/llvm-project/pull/84598
___
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] [llvm][lld][RISCV] Support x3_reg_usage (PR #84598)

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

https://github.com/MaskRay edited 
https://github.com/llvm/llvm-project/pull/84598
___
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] [llvm][lld][RISCV] Support x3_reg_usage (PR #84598)

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


@@ -50,6 +54,13 @@ Error RISCVAttributeParser::atomicAbi(unsigned Tag) {
   return Error::success();
 }
 
+Error RISCVAttributeParser::x3RegUsage(unsigned Tag) {
+  uint64_t Value = de.getULEB128(cursor);
+  std::string Description = "X3 reg usage is " + utostr(Value);

MaskRay wrote:

`printAttribute(..., "..." + Twine(Value)`.str())`

https://github.com/llvm/llvm-project/pull/84598
___
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-objcopy] Simplify --[de]compress-debug-sections and don't compress SHF_ALLOC sections (PR #84885)

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

https://github.com/MaskRay created 
https://github.com/llvm/llvm-project/pull/84885

Make it easier to add custom section [de]compression. In GNU ld,
--compress-debug-sections doesn't compress SHF_ALLOC sections. Match its
behavior.



___
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] ReleaseNotes for LLVM binary utilities (PR #83751)

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

MaskRay wrote:

@tstellar ready for merge!

https://github.com/llvm/llvm-project/pull/83751
___
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] ReleaseNotes for LLVM binary utilities (PR #83751)

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


@@ -344,21 +344,26 @@ Changes to the LLVM tools
 * Fixed big-endian support in llvm-symbolizer's DWARF location parser.
 * llvm-readelf now supports ``--extra-sym-info`` (``-X``) to display extra
   information (section name) when showing symbols.
-
-* ``llvm-nm`` now supports the ``--line-numbers`` (``-l``) option to use
-  debugging information to print symbols' filenames and line numbers.
+* ``llvm-readobj``/``llvm-readelf`` now supports ``--decompress``/``-z`` with

MaskRay wrote:

[added more 
backticks](https://github.com/llvm/llvm-project/pull/83751/commits/8ba9bed8210bf7bce320f589b1243f19cd7e9c6c)

https://github.com/llvm/llvm-project/pull/83751
___
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] ReleaseNotes for LLVM binary utilities (PR #83751)

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

https://github.com/MaskRay updated 
https://github.com/llvm/llvm-project/pull/83751

>From 5a9f6cf96b1fb4c9f16f59e6c4847b61da46c6b7 Mon Sep 17 00:00:00 2001
From: Fangrui Song 
Date: Sun, 3 Mar 2024 17:03:04 -0800
Subject: [PATCH 1/2] ReleaseNotes for LLVM binary utilities

---
 llvm/docs/ReleaseNotes.rst | 11 ---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/llvm/docs/ReleaseNotes.rst b/llvm/docs/ReleaseNotes.rst
index 5b3210138f2f89..b845b57b4e4af6 100644
--- a/llvm/docs/ReleaseNotes.rst
+++ b/llvm/docs/ReleaseNotes.rst
@@ -344,21 +344,26 @@ Changes to the LLVM tools
 * Fixed big-endian support in llvm-symbolizer's DWARF location parser.
 * llvm-readelf now supports ``--extra-sym-info`` (``-X``) to display extra
   information (section name) when showing symbols.
-
-* ``llvm-nm`` now supports the ``--line-numbers`` (``-l``) option to use
-  debugging information to print symbols' filenames and line numbers.
+* ``llvm-readobj``/``llvm-readelf`` now supports ``--decompress``/``-z`` with
+  string and hex dump for ELF object files.
 
 * llvm-symbolizer and llvm-addr2line now support addresses specified as symbol 
names.
 
 * llvm-objcopy now supports ``--gap-fill`` and ``--pad-to`` options, for
   ELF input and binary output files only.
+* ``llvm-objcopy`` now supports ``-O elf64-s390`` for SystemZ.
 
 * Supported parsing XCOFF auxiliary symbols in obj2yaml.
 
 * ``llvm-ranlib`` now supports ``-X`` on AIX to specify the type of object file
   ranlib should examine.
 
+* ``llvm-cxxfilt`` now supports ``--no-params``/``-p`` to skip function
+  parameters.
+
 * ``llvm-nm`` now supports ``--export-symbol`` to ignore the import symbol 
file.
+* ``llvm-nm`` now supports the ``--line-numbers`` (``-l``) option to use
+  debugging information to print symbols' filenames and line numbers.
 
 * llvm-rc and llvm-windres now accept file path references in ``.rc`` files
   concatenated from multiple string literals.

>From 8ba9bed8210bf7bce320f589b1243f19cd7e9c6c Mon Sep 17 00:00:00 2001
From: Fangrui Song 
Date: Mon, 4 Mar 2024 00:36:53 -0800
Subject: [PATCH 2/2] add more backticks

---
 llvm/docs/ReleaseNotes.rst | 20 ++--
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/llvm/docs/ReleaseNotes.rst b/llvm/docs/ReleaseNotes.rst
index b845b57b4e4af6..bfa8e93da05cb8 100644
--- a/llvm/docs/ReleaseNotes.rst
+++ b/llvm/docs/ReleaseNotes.rst
@@ -339,21 +339,21 @@ Changes to the Debug Info
 Changes to the LLVM tools
 -
 
-* llvm-symbolizer now treats invalid input as an address for which source
+* ``llvm-symbolizer`` now treats invalid input as an address for which source
   information is not found.
-* Fixed big-endian support in llvm-symbolizer's DWARF location parser.
-* llvm-readelf now supports ``--extra-sym-info`` (``-X``) to display extra
+* Fixed big-endian support in ``llvm-symbolizer``'s DWARF location parser.
+* ``llvm-readelf`` now supports ``--extra-sym-info`` (``-X``) to display extra
   information (section name) when showing symbols.
 * ``llvm-readobj``/``llvm-readelf`` now supports ``--decompress``/``-z`` with
   string and hex dump for ELF object files.
 
-* llvm-symbolizer and llvm-addr2line now support addresses specified as symbol 
names.
+* ``llvm-symbolizer`` and ``llvm-addr2line`` now support addresses specified 
as symbol names.
 
-* llvm-objcopy now supports ``--gap-fill`` and ``--pad-to`` options, for
+* ``llvm-objcopy`` now supports ``--gap-fill`` and ``--pad-to`` options, for
   ELF input and binary output files only.
 * ``llvm-objcopy`` now supports ``-O elf64-s390`` for SystemZ.
 
-* Supported parsing XCOFF auxiliary symbols in obj2yaml.
+* Supported parsing XCOFF auxiliary symbols in ``obj2yaml``.
 
 * ``llvm-ranlib`` now supports ``-X`` on AIX to specify the type of object file
   ranlib should examine.
@@ -365,15 +365,15 @@ Changes to the LLVM tools
 * ``llvm-nm`` now supports the ``--line-numbers`` (``-l``) option to use
   debugging information to print symbols' filenames and line numbers.
 
-* llvm-rc and llvm-windres now accept file path references in ``.rc`` files
+* ``llvm-rc`` and ``llvm-windres`` now accept file path references in ``.rc`` 
files
   concatenated from multiple string literals.
 
-* The llvm-windres option ``--preprocessor`` now resolves its argument
-  in the PATH environment variable as expected, and options passed with
+* The ``llvm-windres`` option ``--preprocessor`` now resolves its argument
+  in the ``PATH`` environment variable as expected, and options passed with
   ``--preprocessor-arg`` are placed before the input file as they should
   be.
 
-* The llvm-windres option ``--preprocessor`` has been updated with the
+* The ``llvm-windres`` option ``--preprocessor`` has been updated with the
   breaking behaviour change from GNU windres from binutils 2.36, where
   the whole argument is considered as one path, not considered as a
   sequence of tool name and parameters.


[llvm-branch-commits] [llvm] ReleaseNotes for LLVM binary utilities (PR #83751)

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

https://github.com/MaskRay created 
https://github.com/llvm/llvm-project/pull/83751

None

>From 5a9f6cf96b1fb4c9f16f59e6c4847b61da46c6b7 Mon Sep 17 00:00:00 2001
From: Fangrui Song 
Date: Sun, 3 Mar 2024 17:03:04 -0800
Subject: [PATCH] ReleaseNotes for LLVM binary utilities

---
 llvm/docs/ReleaseNotes.rst | 11 ---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/llvm/docs/ReleaseNotes.rst b/llvm/docs/ReleaseNotes.rst
index 5b3210138f2f89..b845b57b4e4af6 100644
--- a/llvm/docs/ReleaseNotes.rst
+++ b/llvm/docs/ReleaseNotes.rst
@@ -344,21 +344,26 @@ Changes to the LLVM tools
 * Fixed big-endian support in llvm-symbolizer's DWARF location parser.
 * llvm-readelf now supports ``--extra-sym-info`` (``-X``) to display extra
   information (section name) when showing symbols.
-
-* ``llvm-nm`` now supports the ``--line-numbers`` (``-l``) option to use
-  debugging information to print symbols' filenames and line numbers.
+* ``llvm-readobj``/``llvm-readelf`` now supports ``--decompress``/``-z`` with
+  string and hex dump for ELF object files.
 
 * llvm-symbolizer and llvm-addr2line now support addresses specified as symbol 
names.
 
 * llvm-objcopy now supports ``--gap-fill`` and ``--pad-to`` options, for
   ELF input and binary output files only.
+* ``llvm-objcopy`` now supports ``-O elf64-s390`` for SystemZ.
 
 * Supported parsing XCOFF auxiliary symbols in obj2yaml.
 
 * ``llvm-ranlib`` now supports ``-X`` on AIX to specify the type of object file
   ranlib should examine.
 
+* ``llvm-cxxfilt`` now supports ``--no-params``/``-p`` to skip function
+  parameters.
+
 * ``llvm-nm`` now supports ``--export-symbol`` to ignore the import symbol 
file.
+* ``llvm-nm`` now supports the ``--line-numbers`` (``-l``) option to use
+  debugging information to print symbols' filenames and line numbers.
 
 * llvm-rc and llvm-windres now accept file path references in ``.rc`` files
   concatenated from multiple string literals.

___
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] ReleaseNotes for LLVM binary utilities (PR #83751)

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

https://github.com/MaskRay milestoned 
https://github.com/llvm/llvm-project/pull/83751
___
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] release/18.x: Allow .alt_entry symbols to pass the .cfi nesting check (#82268) (PR #83336)

2024-02-28 Thread Fangrui Song via llvm-branch-commits

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


https://github.com/llvm/llvm-project/pull/83336
___
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] release/18.x: MIPS: fix emitDirectiveCpsetup on N32 (#80534) (PR #83198)

2024-02-27 Thread Fangrui Song via llvm-branch-commits

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


https://github.com/llvm/llvm-project/pull/83198
___
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] Allow running tests without installing first (PR #83088)

2024-02-27 Thread Fangrui Song via llvm-branch-commits

https://github.com/MaskRay edited 
https://github.com/llvm/llvm-project/pull/83088
___
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] Allow running tests without installing first (PR #83088)

2024-02-27 Thread Fangrui Song via llvm-branch-commits

https://github.com/MaskRay edited 
https://github.com/llvm/llvm-project/pull/83088
___
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] Allow running tests without installing first (PR #83088)

2024-02-27 Thread Fangrui Song via llvm-branch-commits


@@ -168,10 +168,43 @@ def push_dynamic_library_lookup_path(config, new_path):
 r"/i386(?=-[^/]+$)", "/x86_64", config.compiler_rt_libdir
 )
 
+
+# Check if the test compiler resource dir matches the local build directory
+# (which happens with -DLLVM_ENABLE_PROJECTS=clang;compiler-rt) or if we are
+# using an installed clang to test compiler-rt standalone. In the latter case
+# we may need to override the resource dir to match the path of the just-built
+# compiler-rt libraries.
+test_cc_resource_dir, _ = get_path_from_clang(
+shlex.split(config.target_cflags) + ["-print-resource-dir"], 
allow_failure=True
+)
+# Normalize the path for comparison
+if test_cc_resource_dir is not None:
+test_cc_resource_dir = os.path.realpath(test_cc_resource_dir)
+if lit_config.debug:
+lit_config.note(f"Resource dir for {config.clang} is 
{test_cc_resource_dir}")
+local_build_resource_dir = os.path.realpath(config.compiler_rt_output_dir)
+if test_cc_resource_dir != local_build_resource_dir:
+if config.test_standalone_build_libs and config.compiler_id == "Clang":
+if lit_config.debug:
+lit_config.note(f'Overriding test compiler resource dir to use '
+f'libraries in "{config.compiler_rt_libdir}"')
+# Ensure that we use the just-built static libraries when linking by
+# overriding the Clang resource directory. Additionally, we want to use
+# the builtin headers shipped with clang (e.g. stdint.h), so we
+# explicitly add this as an include path (since the headers are not
+# going to be in the current compiler-rt build directory).
+# We also tell the linker to add an RPATH entry for the local library
+# directory so that the just-built shared libraries are used.
+config.target_cflags += f" -nobuiltininc"

MaskRay wrote:

Can `target_cflags` be made to a `list` instead of space-separate `str`?

https://github.com/llvm/llvm-project/pull/83088
___
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] Allow running tests without installing first (PR #83088)

2024-02-27 Thread Fangrui Song via llvm-branch-commits

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

I have a regular clang build at /tmp/Rel. If I create a standalone compiler-rt 
build at /tmp/out/crt, I see that with this PR, clang invoked by llvm-lit will 
get `-resource-dir=/tmp/out/crt -Wl,-rpath,/tmp/out/crt/lib/linux`, which 
utilizes `include/sanitizer/*_interface.h` (used by certain asan tests) and 
runtime libraries.

```
#include 
#include "sanitizer/asan_interface.h"
```

https://github.com/llvm/llvm-project/pull/83088
___
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] Allow running tests without installing first (PR #83088)

2024-02-27 Thread Fangrui Song via llvm-branch-commits

MaskRay wrote:

> wants to merge 2 commits into 
> [users/arichardson/spr/main.compiler-rt-allow-running-tests-without-installing-first](https://github.com/llvm/llvm-project/tree/users/arichardson/spr/main.compiler-rt-allow-running-tests-without-installing-first)

Note: since the base branch is not `main`, "Squash and merge" will not merge 
the patch to "main", but you can manually push it to `main` after approved. You 
can still click "Squash and merge" so that the PR shows "merged".

https://github.com/llvm/llvm-project/pull/83088
___
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] [llvm] release/18.x: MIPS: Fix asm constraints "f" and "r" for softfloat (#79116) (PR #83105)

2024-02-26 Thread Fangrui Song via llvm-branch-commits

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


https://github.com/llvm/llvm-project/pull/83105
___
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] [openmp] release/18.x: Fix build on musl by including stdint.h (#81434) (PR #82897)

2024-02-24 Thread Fangrui Song via llvm-branch-commits

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


https://github.com/llvm/llvm-project/pull/82897
___
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] ReleaseNotes: mention -mtls-dialect=desc (PR #82731)

2024-02-22 Thread Fangrui Song via llvm-branch-commits

https://github.com/MaskRay created 
https://github.com/llvm/llvm-project/pull/82731

None

>From 9e42ddc522436a1129ba5a5e014035ca00262cc0 Mon Sep 17 00:00:00 2001
From: Fangrui Song 
Date: Thu, 22 Feb 2024 19:57:15 -0800
Subject: [PATCH] ReleaseNotes: mention -mtls-dialect=desc

---
 clang/docs/ReleaseNotes.rst | 1 +
 1 file changed, 1 insertion(+)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 93a67e7a895592..6121ef7fa98c04 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -1286,6 +1286,7 @@ RISC-V Support
   for RV64.
 
 - ``__attribute__((rvv_vector_bits(N)))`` is now supported for RVV vbool*_t 
types.
+- ``-mtls-dialect=desc`` is now supported to enable TLS descriptors (TLSDESC).
 
 CUDA/HIP Language Changes
 ^

___
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] ReleaseNotes: mention -mtls-dialect=desc (PR #82731)

2024-02-22 Thread Fangrui Song via llvm-branch-commits

https://github.com/MaskRay milestoned 
https://github.com/llvm/llvm-project/pull/82731
___
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] release/18.x: [llvm-readobj, ELF] Support --decompress/-z (#82594) (PR #82718)

2024-02-22 Thread Fangrui Song via llvm-branch-commits

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

LGTM since this helps at least FreeBSD. Does OpenBSD want to try llvm binary 
utilities?

https://github.com/llvm/llvm-project/pull/82718
___
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] [llvm-readobj, ELF] Support --decompress/-z (#82594) (PR #82713)

2024-02-22 Thread Fangrui Song via llvm-branch-commits

MaskRay wrote:

Does `/cherry-pick $commit_id` work? I think it's the preferred way to backport 
a commit.

https://github.com/llvm/llvm-project/pull/82713
___
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] release/18.x: Extend GCC workaround to GCC < 8.4 for llvm::iterator_range ctor (#82643) (PR #82688)

2024-02-22 Thread Fangrui Song via llvm-branch-commits

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


https://github.com/llvm/llvm-project/pull/82688
___
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] [ARM, MC] Support FDPIC relocations (PR #82187)

2024-02-21 Thread Fangrui Song via llvm-branch-commits

https://github.com/MaskRay closed 
https://github.com/llvm/llvm-project/pull/82187
___
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] [ARM, MC] Support FDPIC relocations (PR #82187)

2024-02-21 Thread Fangrui Song via llvm-branch-commits

MaskRay wrote:

> Thanks for the update, I'm happy with the changes. I would like to see more 
> options for position independent code in embedded systems.
> 
> The other related embedded position independent option for microcontrollers 
> that I'm aware of is `-fropi` and `-frwpi` which is already implemented in 
> clang. This is relocation free with just one static data area accessed as an 
> offset from r9. It works quite well for C code, but doesn't support C++ 
> (vtables and RTTI need relocations) and some forms of static initialisation.

Thanks for the comment. 
[ROPI/RWPI](https://lists.llvm.org/pipermail/llvm-dev/2015-December/093022.html)
 seems similar to -mno-pic-data-is-text-relative.

In 2013, -mno-pic-data-is-text-relative, generalized from the ARM [VxWorks 
RTP](https://gcc.gnu.org/pipermail/gcc-patches/2007-May/217111.html) port, was 
[added](https://inbox.sourceware.org/gcc-patches/01cedf74$bd1bf710$3753e530$@arm.com/)
 to assume that text and data segments don't have a fixed displacement. On 
non-VxWorks-RTP targets, -mno-pic-data-is-text-relative implies 
[-msingle-pic-base](https://gcc.gnu.org/onlinedocs/gcc/ARM-Options.html#index-msingle-pic-base):

Treat the register used for PIC addressing as read-only, rather than loading it 
in the prologue for each function. The runtime system is responsible for 
initializing this register with an appropriate value before execution begins.

r9 is used as the static base (`arm_pic_register) in the position-independent 
data model to access the data segment. Since r9 is not changed, dynamic linking 
seems unsupported as a DSO needs a different data segment.

https://github.com/llvm/llvm-project/pull/82187
___
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] [RISCV] Support llvm.readsteadycounter intrinsic (PR #82322)

2024-02-20 Thread Fangrui Song via llvm-branch-commits

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


https://github.com/llvm/llvm-project/pull/82322
___
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] [RISCV] Support llvm.readsteadycounter intrinsic (PR #82322)

2024-02-20 Thread Fangrui Song via llvm-branch-commits


@@ -126,9 +126,9 @@ enum NodeType : unsigned {
   // Floating point fmax and fmin matching the RISC-V instruction semantics.
   FMAX, FMIN,
 
-  // READ_CYCLE_WIDE - A read of the 64-bit cycle CSR on a 32-bit target
+  // READ_COUNTER_WIDE - A read of the 64-bit counter CSR on a 32-bit target

MaskRay wrote:

For new code, we don't replicate the variable/function name.

https://github.com/llvm/llvm-project/pull/82322
___
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] release/18.x: [llvm-objcopy] Add SystemZ support (#81841) (PR #82324)

2024-02-20 Thread Fangrui Song via llvm-branch-commits

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


https://github.com/llvm/llvm-project/pull/82324
___
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] release/18.x: [llvm-objcopy] Add SystemZ support (#81841) (PR #82324)

2024-02-20 Thread Fangrui Song via llvm-branch-commits

MaskRay wrote:

This is fairly safe to cherry pick and it will help ClangBuiltLinux. I'm in 
favor of merging it if there is still time.

https://github.com/llvm/llvm-project/pull/82324
___
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] [ELF] Support placing .lbss/.lrodata/.ldata after .bss (PR #81224)

2024-02-20 Thread Fangrui Song via llvm-branch-commits

MaskRay wrote:

```
Merged
merged 5 commits into 
[users/MaskRay/spr/main.elf-place-lbsslrodataldata-after-bss](https://github.com/llvm/llvm-project/tree/users/MaskRay/spr/main.elf-place-lbsslrodataldata-after-bss)
 from 
[users/MaskRay/spr/elf-place-lbsslrodataldata-after-bss](https://github.com/llvm/llvm-project/tree/users/MaskRay/spr/elf-place-lbsslrodataldata-after-bss)
```

Since the base branch is not main, it seems that "merge" in the web UI merges 
this to the `/users/MaskRay/spr/...` branch instead of `main`. I guess I need 
to push this squashed commit to `main` manually.

https://github.com/llvm/llvm-project/pull/81224
___
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] [ELF] Support placing .lbss/.lrodata/.ldata after .bss (PR #81224)

2024-02-20 Thread Fangrui Song via llvm-branch-commits

https://github.com/MaskRay closed 
https://github.com/llvm/llvm-project/pull/81224
___
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] [ELF] Support placing .lbss/.lrodata/.ldata after .bss (PR #81224)

2024-02-20 Thread Fangrui Song via llvm-branch-commits


@@ -1436,6 +1436,8 @@ static void readConfigs(opt::InputArgList ) {
   config->zInterpose = hasZOption(args, "interpose");
   config->zKeepTextSectionPrefix = getZFlag(
   args, "keep-text-section-prefix", "nokeep-text-section-prefix", false);
+  config->zLrodataAfterBss =
+  getZFlag(args, "lrodata-after-bss", "nolrodata-after-bss", false);

MaskRay wrote:

Thanks for understanding. I think I am fairly strong in keeping the stance that 
layout decisions should not magically change due to -no-pie/-pie. If we ever 
decide to deviate from the policy, we can re-consider. But having `-z 
lrodata-after-bss` should make these possible.

https://github.com/llvm/llvm-project/pull/81224
___
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] [ARM, MC] Support FDPIC relocations (PR #82187)

2024-02-20 Thread Fangrui Song via llvm-branch-commits

https://github.com/MaskRay updated 
https://github.com/llvm/llvm-project/pull/82187


___
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] [ARM, MC] Support FDPIC relocations (PR #82187)

2024-02-20 Thread Fangrui Song via llvm-branch-commits

https://github.com/MaskRay updated 
https://github.com/llvm/llvm-project/pull/82187


___
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] [ARM, MC] Support FDPIC relocations (PR #82187)

2024-02-20 Thread Fangrui Song via llvm-branch-commits

MaskRay wrote:

> I've checked over the implementation with binutils. Out of interest are you 
> planning on implementing all of fdpic or just enough to get assembler/linker 
> support working?

Yes, I plan to implement the codegen part to help me understand FDPIC better 
and the codegen part of LLVM...
(I need to study PPC ELFv1 function descriptors.)

> If you are there are some other GNU options that may be useful to look at as 
> possible intermediate steps. In particular -mno-pic-data-is-text-relative 
> [gcc.gnu.org/onlinedocs/gcc/ARM-Options.html#index-mpic-data-is-text-relative](https://gcc.gnu.org/onlinedocs/gcc/ARM-Options.html#index-mpic-data-is-text-relative)
>  this uses a single static base for the GOT which is sufficient for position 
> independent executables but no shared library support.

Thanks for the pointers. Yes, it looks like ARM added 
`-mpic-data-is-text-relative` first then s390x ported it.
The option is similar to `-msep-data` (m68k/bfin) and probably used for 
MMU-less systems without dynamic linking support. I have work-in-progress notes 
at https://maskray.me/blog/2024-02-20-mmu-less-systems-and-fdpic

https://github.com/llvm/llvm-project/pull/82187
___
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] [ARM, MC] Support FDPIC relocations (PR #82187)

2024-02-20 Thread Fangrui Song via llvm-branch-commits

https://github.com/MaskRay edited 
https://github.com/llvm/llvm-project/pull/82187
___
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] [ARM, MC] Support FDPIC relocations (PR #82187)

2024-02-20 Thread Fangrui Song via llvm-branch-commits

https://github.com/MaskRay edited 
https://github.com/llvm/llvm-project/pull/82187
___
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] [ARM, MC] Support FDPIC relocations (PR #82187)

2024-02-20 Thread Fangrui Song via llvm-branch-commits


@@ -11358,6 +11361,37 @@ bool ARMAsmParser::parseDirectiveARM(SMLoc L) {
   return false;
 }
 
+MCSymbolRefExpr::VariantKind
+ARMAsmParser::getVariantKindForName(StringRef Name) const {

MaskRay wrote:

> Ideally we could refactor so that MCSymbolRefExpr::getVariantKindForName 
> contains only generic and no target specific variant kinds.

I agree with this. I believe that binutils doesn't have a generic operand 
modifier, so ideally `MCSymbolRefExpr::getVariantKindForName` should be a pure 
virtual function. Unfortunately, many architectures add arch-specific modifiers 
in this list. We should eventually move them to respective lib/Target/XXX files.

In this patch I am only focusing on the ARM specific operand modifiers.

https://github.com/llvm/llvm-project/pull/82187
___
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] [ARM, MC] Support FDPIC relocations (PR #82187)

2024-02-20 Thread Fangrui Song via llvm-branch-commits

https://github.com/MaskRay edited 
https://github.com/llvm/llvm-project/pull/82187
___
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] [ARM, MC] Support FDPIC relocations (PR #82187)

2024-02-20 Thread Fangrui Song via llvm-branch-commits


@@ -11358,6 +11361,37 @@ bool ARMAsmParser::parseDirectiveARM(SMLoc L) {
   return false;
 }
 
+MCSymbolRefExpr::VariantKind
+ARMAsmParser::getVariantKindForName(StringRef Name) const {
+  return StringSwitch(Name.lower())
+  .Case("funcdesc", MCSymbolRefExpr::VK_FUNCDESC)
+  .Case("got", MCSymbolRefExpr::VK_GOT)
+  .Case("got_prel", MCSymbolRefExpr::VK_ARM_GOT_PREL)
+  .Case("gotfuncdesc", MCSymbolRefExpr::VK_GOTFUNCDESC)
+  .Case("gotoff", MCSymbolRefExpr::VK_GOTOFF)
+  .Case("gotofffuncdesc", MCSymbolRefExpr::VK_GOTOFFFUNCDESC)
+  .Case("gottpoff", MCSymbolRefExpr::VK_GOTTPOFF)
+  .Case("gottpoff_fdpic", MCSymbolRefExpr::VK_GOTTPOFF_FDPIC)
+  .Case("imgrel", MCSymbolRefExpr::VK_COFF_IMGREL32)
+  .Case("none", MCSymbolRefExpr::VK_ARM_NONE)
+  .Case("plt", MCSymbolRefExpr::VK_PLT)
+  .Case("prel31", MCSymbolRefExpr::VK_ARM_PREL31)
+  .Case("sbrel", MCSymbolRefExpr::VK_ARM_SBREL)
+  .Case("secrel32", MCSymbolRefExpr::VK_SECREL)
+  .Case("target1", MCSymbolRefExpr::VK_ARM_TARGET1)
+  .Case("target2", MCSymbolRefExpr::VK_ARM_TARGET2)
+  .Case("tlscall", MCSymbolRefExpr::VK_TLSCALL)
+  .Case("tlsdesc", MCSymbolRefExpr::VK_TLSDESC)
+  .Case("tlsgd", MCSymbolRefExpr::VK_TLSGD)
+  .Case("tlsgd_fdpic", MCSymbolRefExpr::VK_TLSGD_FDPIC)
+  .Case("tlsld", MCSymbolRefExpr::VK_TLSLD)
+  .Case("tlsldm", MCSymbolRefExpr::VK_TLSLDM)
+  .Case("tlsldm_fdpic", MCSymbolRefExpr::VK_TLSLDM_FDPIC)
+  .Case("tlsldo", MCSymbolRefExpr::VK_ARM_TLSLDO)
+  .Case("tpoff", MCSymbolRefExpr::VK_TPOFF)
+  .Default(MCSymbolRefExpr::VK_Invalid);

MaskRay wrote:

Yes, the binutils contains `tlsdescseq`, but there is no `(tlsdescseq)` 
occurrence. GCC doesn't emit `(tlsdescseq)`, either.
I suspect that the entry in binutils is not used.

There is a directive named `.tlsdescseq`  
(https://www.fsfla.org/~lxoliva/writeups/TLS/RFC-TLSDESC-ARM.txt), which is for 
TLS optimization. But GCC doesn't emit this directive.

Clang doesn't support `-mtls-dialect=gnu2` for ARM.

https://github.com/llvm/llvm-project/pull/82187
___
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] [ARM, MC] Support FDPIC relocations (PR #82187)

2024-02-19 Thread Fangrui Song via llvm-branch-commits


@@ -143,3 +143,10 @@ ELF_RELOC(R_ARM_THM_BF16,   0x88)
 ELF_RELOC(R_ARM_THM_BF12,   0x89)
 ELF_RELOC(R_ARM_THM_BF18,   0x8a)
 ELF_RELOC(R_ARM_IRELATIVE,  0xa0)
+ELF_RELOC(R_ARM_GOTFUNCDESC,0xa1)
+ELF_RELOC(R_ARM_GOTOFFFUNCDESC, 0xa2)
+ELF_RELOC(R_ARM_FUNCDESC,   0xa3)
+ELF_RELOC(R_ARM_FUNCDESC_VALUE, 0xa4)
+ELF_RELOC(R_ARM_TLS_GD32_FDPIC, 0xa5)
+ELF_RELOC(R_ARM_TLS_LDM32_FDPIC,0xa6)
+ELF_RELOC(R_ARM_TLS_IE32_FDPIC, 0xa7)

MaskRay wrote:

Thanks for checking. https://github.com/mickael-guene/fdpic_doc doesn't define 
these values, but binutils-gdb defines the values (also referenced by projects 
like https://github.com/cutty/uld-fdpic/blob/master/include/elf.h). I've 
checked that `llvm-readelf -r` output matches `readelf -r`.

https://github.com/llvm/llvm-project/pull/82187
___
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] [ARM, MC] Support FDPIC relocations (PR #82187)

2024-02-18 Thread Fangrui Song via llvm-branch-commits

https://github.com/MaskRay created 
https://github.com/llvm/llvm-project/pull/82187

Linux kernel fs/binfmt_elf_fdpic.c supports FDPIC for MMU-less systems.
GCC/binutils/qemu support FDPIC ABI for ARM
(https://github.com/mickael-guene/fdpic_doc).
_ARM FDPIC Toolchain and ABI_ provides a summary.

This patch implements FDPIC relocations to the integrated assembler.
There are 6 static relocations and 2 dynamic relocations, with
R_ARM_FUNCDESC as both static and dynamic.

gas requires `--fdpic` to assemble data relocations like `.word f(FUNCDESC)`.
This patch adds `MCTargetOptions::FDPIC` and reports an error if FDPIC
is not set.



___
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] [Driver] Support -Wa, --fdpic for ARM FDPIC ABI (PR #82188)

2024-02-18 Thread Fangrui Song via llvm-branch-commits

https://github.com/MaskRay created 
https://github.com/llvm/llvm-project/pull/82188

`arm-linux-gnueabihf-gcc -c -fpic -mfdpic -Wa,--fdpic a.c` compiles
a.c with FDPIC codegen and assembles the assembly file with `--fdpic`.
This patch implements -Wa,--fdpic for the driver when using the
integrated assembler.



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


  1   2   3   4   5   >