[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] [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


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

2024-06-19 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] [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) { retu

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

2024-06-20 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] [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

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-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 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 if LLVM_ENABLE_ABI_BREAKING_CHECKS (PR #96282)

2024-06-27 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 if LLVM_ENABLE_ABI_BREAKING_CHECKS (PR #96282)

2024-06-27 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 if LLVM_ENABLE_ABI_BREAKING_CHECKS (PR #96282)

2024-06-27 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 if LLVM_ENABLE_ABI_BREAKING_CHECKS (PR #96282)

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

MaskRay wrote:

The non-determinism is now restricted to `LLVM_ENABLE_ABI_BREAKING_CHECKS` 
builds.

LLVM_ENABLE_ABI_BREAKING_CHECKS defaults to `WITH_ASSERTS` . Release builds 
that disable assertions disable `LLVM_ENABLE_ABI_BREAKING_CHECKS`. This change 
yields a slight code size/performance advantage by eliminating a variable read.



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

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

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

>From a341e03cb6376d50a4fa219933d3f161e41a567a Mon Sep 17 00:00:00 2001
From: Fangrui Song 
Date: Thu, 27 Jun 2024 14:44:02 -0700
Subject: [PATCH] move seed inside #if

Created using spr 1.3.5-bogner
---
 llvm/include/llvm/ADT/Hashing.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/llvm/include/llvm/ADT/Hashing.h b/llvm/include/llvm/ADT/Hashing.h
index 397109880bb02..177fb0318bf80 100644
--- a/llvm/include/llvm/ADT/Hashing.h
+++ b/llvm/include/llvm/ADT/Hashing.h
@@ -311,11 +311,11 @@ struct hash_state {
 /// hash values. On platforms without ASLR, this is still likely
 /// non-deterministic per build.
 inline uint64_t get_execution_seed() {
-  [[maybe_unused]] static const char seed = 0;
   // Work around x86-64 negative offset folding for old Clang -fno-pic
   // https://reviews.llvm.org/D93931
 #if LLVM_ENABLE_ABI_BREAKING_CHECKS && 
\
 (!defined(__clang__) || __clang_major__ > 11)
+  static const char seed = 0;
   return static_cast(reinterpret_cast(&seed));
 #else
   return 0xff51afd7ed558ccdULL;

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

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

MaskRay wrote:

https://llvm-compile-time-tracker.com/compare.php?from=abfff89b743584d2796000318198bf60d3622a1f&to=5c2a6b5ba62d2b7ed2c0ad3be29fba8558f5627b&stat=instructions:u

stage2-O3: `instruction:u` change (larger than expected):

|Benchmark|Old|New|
|--- |--- |--- |
|kimwitu++|38847M|38705M (-0.37%)|
|sqlite3|35002M|34917M (-0.24%)|
|consumer-typeset|31851M|31794M (-0.18%)|
|Bullet|93072M|92815M (-0.28%)|
|tramp3d-v4|78154M|77899M (-0.33%)|
|mafft|32841M|32718M (-0.37%)|
|ClamAV|50244M|50128M (-0.23%)|
|lencod|60998M|60793M (-0.34%)|
|SPASS|42834M|42725M (-0.25%)|
|7zip|191523M|191032M (-0.26%)|
|geomean|55146M|54990M (-0.28%)|


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

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


@@ -322,24 +306,20 @@ struct hash_state {
   }
 };
 
-
-/// A global, fixed seed-override variable.
-///
-/// This variable can be set using the \see llvm::set_fixed_execution_seed
-/// function. See that function for details. Do not, under any circumstances,
-/// set or read this variable.
-extern uint64_t fixed_seed_override;
-
+/// In LLVM_ENABLE_ABI_BREAKING_CHECKS builds, the seed is non-deterministic
+/// (address of a variable) to prevent having users depend on the particular
+/// hash values. On platforms without ASLR, this is still likely
+/// non-deterministic per build.
 inline uint64_t get_execution_seed() {
-  // FIXME: This needs to be a per-execution seed. This is just a placeholder
-  // implementation. Switching to a per-execution seed is likely to flush out
-  // instability bugs and so will happen as its own commit.
-  //
-  // However, if there is a fixed seed override set the first time this is
-  // called, return that instead of the per-execution seed.
-  const uint64_t seed_prime = 0xff51afd7ed558ccdULL;
-  static uint64_t seed = fixed_seed_override ? fixed_seed_override : 
seed_prime;
-  return seed;
+  // Work around x86-64 negative offset folding for old Clang -fno-pic
+  // https://reviews.llvm.org/D93931
+#if LLVM_ENABLE_ABI_BREAKING_CHECKS && 
\
+(!defined(__clang__) || __clang_major__ > 11)

MaskRay wrote:

The clang condition introduced a slight ABI problem when mixing `clang<11` and 
`clang>=11`. In practice it is rare that the llvm-project build and a 
downstream client exchange the hash values. 

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

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

MaskRay wrote:

Eli is happier now. I plan to land this in a few hours.

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

2024-06-28 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] [llvm] [Hashing] Use a non-deterministic seed if LLVM_ENABLE_ABI_BREAKING_CHECKS (PR #96282)

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

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

>From a341e03cb6376d50a4fa219933d3f161e41a567a Mon Sep 17 00:00:00 2001
From: Fangrui Song 
Date: Thu, 27 Jun 2024 14:44:02 -0700
Subject: [PATCH] move seed inside #if

Created using spr 1.3.5-bogner
---
 llvm/include/llvm/ADT/Hashing.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/llvm/include/llvm/ADT/Hashing.h b/llvm/include/llvm/ADT/Hashing.h
index 397109880bb02..177fb0318bf80 100644
--- a/llvm/include/llvm/ADT/Hashing.h
+++ b/llvm/include/llvm/ADT/Hashing.h
@@ -311,11 +311,11 @@ struct hash_state {
 /// hash values. On platforms without ASLR, this is still likely
 /// non-deterministic per build.
 inline uint64_t get_execution_seed() {
-  [[maybe_unused]] static const char seed = 0;
   // Work around x86-64 negative offset folding for old Clang -fno-pic
   // https://reviews.llvm.org/D93931
 #if LLVM_ENABLE_ABI_BREAKING_CHECKS && 
\
 (!defined(__clang__) || __clang_major__ > 11)
+  static const char seed = 0;
   return static_cast(reinterpret_cast(&seed));
 #else
   return 0xff51afd7ed558ccdULL;

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

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

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

>From a341e03cb6376d50a4fa219933d3f161e41a567a Mon Sep 17 00:00:00 2001
From: Fangrui Song 
Date: Thu, 27 Jun 2024 14:44:02 -0700
Subject: [PATCH] move seed inside #if

Created using spr 1.3.5-bogner
---
 llvm/include/llvm/ADT/Hashing.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/llvm/include/llvm/ADT/Hashing.h b/llvm/include/llvm/ADT/Hashing.h
index 397109880bb02..177fb0318bf80 100644
--- a/llvm/include/llvm/ADT/Hashing.h
+++ b/llvm/include/llvm/ADT/Hashing.h
@@ -311,11 +311,11 @@ struct hash_state {
 /// hash values. On platforms without ASLR, this is still likely
 /// non-deterministic per build.
 inline uint64_t get_execution_seed() {
-  [[maybe_unused]] static const char seed = 0;
   // Work around x86-64 negative offset folding for old Clang -fno-pic
   // https://reviews.llvm.org/D93931
 #if LLVM_ENABLE_ABI_BREAKING_CHECKS && 
\
 (!defined(__clang__) || __clang_major__ > 11)
+  static const char seed = 0;
   return static_cast(reinterpret_cast(&seed));
 #else
   return 0xff51afd7ed558ccdULL;

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

2024-06-28 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] [llvm] [Hashing] Use a non-deterministic seed if LLVM_ENABLE_ABI_BREAKING_CHECKS (PR #96282)

2024-06-28 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] [RISCV][lld] Support merging RISC-V Atomics ABI attributes (PR #97347)

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


@@ -1084,10 +1084,76 @@ static void 
mergeArch(RISCVISAUtils::OrderedExtensionMap &mergedExts,
   }
 }
 
+static void mergeAtomic(DenseMap::iterator it,
+const InputSectionBase *oldSection,
+const InputSectionBase *newSection,
+RISCVAttrs::RISCVAtomicAbiTag oldTag,
+RISCVAttrs::RISCVAtomicAbiTag newTag) {
+  using RISCVAttrs::RISCVAtomicAbiTag;
+  // Same tags stay the same, and UNKNOWN is compatible with anything
+  if (oldTag == newTag || newTag == RISCVAtomicAbiTag::UNKNOWN)
+return;
+
+  auto reportAbiError = [&]() {
+errorOrWarn("atomic abi mismatch for " + oldSection->name + "\n>>> " +
+toString(oldSection) +
+": atomic_abi=" + Twine(static_cast(oldTag)) +
+"\n>>> " + toString(newSection) +
+": atomic_abi=" + Twine(static_cast(newTag)));
+  };
+
+  switch (static_cast(oldTag)) {

MaskRay wrote:

unneeded cast?

https://github.com/llvm/llvm-project/pull/97347
___
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] [RISCV][lld] Support merging RISC-V Atomics ABI attributes (PR #97347)

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


@@ -1084,10 +1084,76 @@ static void 
mergeArch(RISCVISAUtils::OrderedExtensionMap &mergedExts,
   }
 }
 
+static void mergeAtomic(DenseMap::iterator it,
+const InputSectionBase *oldSection,
+const InputSectionBase *newSection,
+RISCVAttrs::RISCVAtomicAbiTag oldTag,
+RISCVAttrs::RISCVAtomicAbiTag newTag) {
+  using RISCVAttrs::RISCVAtomicAbiTag;
+  // Same tags stay the same, and UNKNOWN is compatible with anything
+  if (oldTag == newTag || newTag == RISCVAtomicAbiTag::UNKNOWN)
+return;
+
+  auto reportAbiError = [&]() {
+errorOrWarn("atomic abi mismatch for " + oldSection->name + "\n>>> " +
+toString(oldSection) +
+": atomic_abi=" + Twine(static_cast(oldTag)) +
+"\n>>> " + toString(newSection) +
+": atomic_abi=" + Twine(static_cast(newTag)));
+  };
+
+  switch (static_cast(oldTag)) {
+  case RISCVAtomicAbiTag::UNKNOWN:
+it->getSecond() = static_cast(newTag);
+return;
+  case RISCVAtomicAbiTag::A6C:
+switch (newTag) {
+case RISCVAtomicAbiTag::A6S:
+  it->getSecond() = static_cast(RISCVAtomicAbiTag::A6C);
+  return;
+case RISCVAtomicAbiTag::A7:
+  reportAbiError();
+  return;
+case RISCVAttrs::RISCVAtomicAbiTag::UNKNOWN:
+case RISCVAttrs::RISCVAtomicAbiTag::A6C:
+  return;
+};
+
+  case RISCVAtomicAbiTag::A6S:
+switch (newTag) {
+case RISCVAtomicAbiTag::A6C:
+  it->getSecond() = static_cast(RISCVAtomicAbiTag::A6C);
+  return;
+case RISCVAtomicAbiTag::A7:
+  it->getSecond() = static_cast(RISCVAtomicAbiTag::A7);
+  return;
+case RISCVAttrs::RISCVAtomicAbiTag::UNKNOWN:
+case RISCVAttrs::RISCVAtomicAbiTag::A6S:
+  return;
+};
+
+  case RISCVAtomicAbiTag::A7:
+switch (newTag) {
+case RISCVAtomicAbiTag::A6S:
+  it->getSecond() = static_cast(RISCVAtomicAbiTag::A7);
+  return;
+case RISCVAtomicAbiTag::A6C:
+  reportAbiError();
+  return;
+case RISCVAttrs::RISCVAtomicAbiTag::UNKNOWN:
+case RISCVAttrs::RISCVAtomicAbiTag::A7:
+  return;
+};
+  };
+  llvm_unreachable("unknown AtomicABI");

MaskRay wrote:

If a potentially-corrupted object file may contain an unknown tag, it's 
inappropriate to use unreachable. 

https://github.com/llvm/llvm-project/pull/97347
___
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-objdump] -r: support CREL (PR #97382)

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

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

The decoder code is similar to that for llvm-readelf -r (#91280).

Because the section representation of LLVMObject (`SectionRef`) is
64-bit, insufficient to hold all decoder states, `section_rel_begin` is
modified to decode CREL eagerly and hold the decoded relocations inside
ELFObjectFile.

The test is adapted from llvm/test/tools/llvm-readobj/ELF/crel.test.



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


[llvm-branch-commits] [NFC][RISCV] Simplify the dynamic linker construction logic (PR #97383)

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

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


https://github.com/llvm/llvm-project/pull/97383
___
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-objdump] -r: support CREL (PR #97382)

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


@@ -2687,6 +2687,15 @@ void Dumper::printRelocations() {
<< "VALUE\n";
 
 for (SectionRef Section : P.second) {
+  // CREL requires decoding and has its specific errors.
+  if (O.isELF() && ELFSectionRef(Section).getType() == ELF::SHT_CREL) {
+const ELFObjectFileBase *ELF = cast(&O);
+StringRef Err = ELF->getCrelError(Section);
+if (!Err.empty()) {
+  reportUniqueWarning(Err);

MaskRay wrote:

Adopted `getCrelDecodeProblem`.

> My expectation for a decode error would be that we report it, but continue as 
> best we can. I would expect a non-zero error code though. Please ignore if 
> this isn't llvm-objdump practice.

llvm-readobj tries to continue execution and report warnings. While a lot of 
code in llvm-objdump reports errors, there have been efforts to migrate to 
warnings: https://reviews.llvm.org/D154754

https://github.com/llvm/llvm-project/pull/97382
___
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-objdump] -r: support CREL (PR #97382)

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

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


___
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-objdump] -r: support CREL (PR #97382)

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

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


___
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-objdump] -r: support CREL (PR #97382)

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

https://github.com/MaskRay edited 
https://github.com/llvm/llvm-project/pull/97382
___
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-objdump] -r: support CREL (PR #97382)

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


@@ -1453,6 +1525,15 @@ template  bool 
ELFObjectFile::isRelocatableObject() const {
   return EF.getHeader().e_type == ELF::ET_REL;
 }
 
+template 
+StringRef ELFObjectFile::getCrelError(DataRefImpl Sec) const {
+  uintptr_t SHT = reinterpret_cast(cantFail(EF.sections()).begin());
+  auto I = (Sec.p - SHT) / EF.getHeader().e_shentsize;
+  if (I < CrelErrs.size())
+return CrelErrs[I];
+  return "";

MaskRay wrote:

I have changed `mutable SmallVector CrelErrs;` so that it is 
only non-empty when there is a decoder problem. This is now needed.

https://github.com/llvm/llvm-project/pull/97382
___
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-objdump] -r: support CREL (PR #97382)

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


@@ -0,0 +1,213 @@
+# RUN: yaml2obj --docnum=1 %s -o %t
+# RUN: llvm-objdump -r %t | FileCheck %s --strict-whitespace --match-full-lines
+
+#  CHECK:RELOCATION RECORDS FOR [.text]:
+# CHECK-NEXT:OFFSET   TYPE VALUE
+# CHECK-NEXT:0001 R_X86_64_32  g1+0x1
+# CHECK-NEXT:0002 R_X86_64_64  l1+0x2
+# CHECK-NEXT: R_X86_64_32S g1-0x1
+# CHECK-NEXT:0004 R_X86_64_32S .text-0x8000
+#CHECK-EMPTY:
+# CHECK-NEXT:RELOCATION RECORDS FOR [nonalloc]:
+# CHECK-NEXT:OFFSET   TYPE VALUE
+# CHECK-NEXT:0010 R_X86_64_64  g1+0x1
+# CHECK-NEXT:0020 R_X86_64_64  g2+0x2
+# CHECK-NEXT:0030 R_X86_64_64  *ABS*
+#  CHECK-NOT:{{.}}
+
+--- !ELF
+FileHeader: !FileHeader
+  Class: ELFCLASS64
+  Data: ELFDATA2LSB
+  Type: ET_REL
+  Machine: EM_X86_64
+
+Sections:
+- Name: .text
+  Type: SHT_PROGBITS
+  Content: ""
+  Flags: [SHF_ALLOC]
+- Name: .crel.text
+  Type: SHT_CREL
+  Info: .text
+  Link: .symtab
+  Relocations:
+- Offset: 0x1
+  Symbol: g1
+  Type:   R_X86_64_32
+  Addend: 1
+- Offset: 0x2
+  Symbol: l1
+  Type:   R_X86_64_64
+  Addend: 2
+- Offset: 0x0
+  Symbol: g1
+  Type:   R_X86_64_32S
+  Addend: 0x
+- Offset: 0x4
+  Symbol: .text
+  Type:   R_X86_64_32S
+  Addend: 0x8000
+- Name: nonalloc
+  Type: SHT_PROGBITS
+  Size: 0x30
+- Name: .crelnonalloc
+  Type: SHT_CREL
+  Info: nonalloc
+  Link: .symtab
+  Relocations:
+- Offset: 0x10
+  Symbol: g1
+  Type:   R_X86_64_64
+  Addend: 1
+- Offset: 0x20
+  Symbol: g2
+  Type:   R_X86_64_64
+  Addend: 2
+- Offset: 0x30
+  Symbol: 0
+  Type:   R_X86_64_64
+
+Symbols:
+  - Name: .text
+Type: STT_SECTION
+Section: .text
+  - Name:l1
+  - Name:g1
+Section: .text
+Value:   0x0
+Size:4
+Binding: STB_GLOBAL
+  - Name:g2
+Binding: STB_GLOBAL
+
+## Check relocation formatting on ELFCLASS32 as well.
+# RUN: yaml2obj --docnum=2 %s > %t2
+# RUN: llvm-objdump -r %t2 | FileCheck %s --check-prefix=ELF32 
--strict-whitespace --match-full-lines
+
+#  ELF32:RELOCATION RECORDS FOR [.text]:
+# ELF32-NEXT:OFFSET   TYPE VALUE
+# ELF32-NEXT:0008 R_ARM_REL32  l1+0x1
+# ELF32-NEXT:0004 R_ARM_ABS32  g1
+
+--- !ELF
+FileHeader:
+  Class:   ELFCLASS32
+  Data:ELFDATA2MSB
+  Type:ET_REL
+  Machine: EM_ARM
+Sections:
+- Name: .text
+  Type: SHT_PROGBITS
+  Size: 0x10
+- Name: .crel.text
+  Type: SHT_CREL
+  Info: .text
+  Link: .symtab
+  Relocations:
+- Offset: 0x8
+  Symbol: l1
+  Type:   R_ARM_REL32
+  Addend: 1
+- Offset: 0x4
+  Symbol: g1
+  Type:   R_ARM_ABS32
+Symbols:
+  - Name:l1
+  - Name:g1
+Binding: STB_GLOBAL
+
+## Check CREL with implicit addends.
+# RUN: yaml2obj --docnum=3 %s -o %t3
+# RUN: llvm-objdump -r %t3 | FileCheck %s --check-prefix=IMPLICIT 
--strict-whitespace --match-full-lines
+#  IMPLICIT:RELOCATION RECORDS FOR [.data]:
+# IMPLICIT-NEXT:OFFSET   TYPE VALUE
+# IMPLICIT-NEXT:001f R_X86_64_32  g1
+# IMPLICIT-NEXT:003f R_X86_64_64  g1
+# IMPLICIT-NEXT: R_X86_64_32S l1
+--- !ELF
+FileHeader:
+  Class: ELFCLASS64
+  Data:  ELFDATA2LSB
+  Type:  ET_REL
+  Machine:   EM_X86_64
+Sections:
+  - Name:.text
+Type:SHT_PROGBITS
+  - Name:.data
+Type:SHT_PROGBITS
+  - Name:.crel.data
+Type:SHT_CREL
+Flags:   [ SHF_INFO_LINK ]
+Link:.symtab
+Info:.data
+Content: 187f030a82017787feff077f0a
+Symbols:
+  - Name:.text
+Type:STT_SECTION
+Section: .text
+  - Name:l1
+Section: .text
+  - Name:g1
+Section: .text
+Binding: STB_GLOBAL
+
+## Test errors.
+# RUN: yaml2obj --docnum=4 %s -o %t.err
+# RUN: llvm-objdump -r %t.err 2>&1 | FileCheck %s --check-prefix=ERR 
-DFILE=%t.err
+
+#  ERR:RELOCATION RECORDS FOR [.data]:
+# ERR-NEXT:OFFSET   TYPE VALUE
+# ERR-NEXT:warning: '[[FILE]]': unable to decode LEB128 at offset 0x: 
malformed uleb128, extends past end
+#  ERR-NOT:{{.}}
+
+--- !ELF
+FileHeader:
+  Class: ELFCLASS64
+  Data:  ELFDATA2LSB
+  Type:  ET_REL
+  Machine:   EM_X86_64
+Sections:
+  - Name:.text
+Type:SHT_PROGBITS
+  - Name:.data
+Type:SHT_PROGBITS
+  - Name:.crel.data
+Type:SHT_CREL
+Flags:   []
+Link:.symtab
+Info:.data
+Symbols:
+  - Name:.text
+Type:STT_SECTION
+Section: .text
+
+# RUN: yaml2obj --docnum=5 %s -o %t.err2
+# RUN: llvm-objdump -r %t.err2 2>&1 | FileCheck %s --check-prefix=ERR2 
-DFILE=%t.err

[llvm-branch-commits] [llvm-objcopy] Support CREL (PR #97521)

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

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

llvm-objcopy may modify the symbol table and need to rewrite
relocations. For CREL, while we can reuse the decoder from #91280, we
need an encoder to support CREL.

Since MC/ELFObjectWriter.cpp has an existing encoder, and MC is at a
lower layer than Object, extract the encoder to a new header file
llvm/MC/MCELFExtras.h.

Link: 
https://discourse.llvm.org/t/rfc-crel-a-compact-relocation-format-for-elf/77600



___
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-objdump] -r: support CREL (PR #97382)

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

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


___
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-objdump] -r: support CREL (PR #97382)

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

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


___
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-objdump] -r: support CREL (PR #97382)

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


@@ -207,6 +209,43 @@ bool isSectionInSegment(const typename ELFT::Phdr &Phdr,
  checkSectionVMA(Phdr, Sec);
 }
 
+template 

MaskRay wrote:

thx for the suggestion. adopted

https://github.com/llvm/llvm-project/pull/97382
___
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-objdump] -r: support CREL (PR #97382)

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


@@ -207,6 +209,43 @@ bool isSectionInSegment(const typename ELFT::Phdr &Phdr,
  checkSectionVMA(Phdr, Sec);
 }
 
+template 
+Error decodeCrel(ArrayRef Content,
+ function_ref HdrHandler,

MaskRay wrote:

thx for the suggestion. adopted

https://github.com/llvm/llvm-project/pull/97382
___
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] Support CREL (PR #97521)

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


@@ -0,0 +1,60 @@
+//===- MCELFExtras.h - Extra functions for ELF --*- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLVM_MC_MCELFEXTRAS_H
+#define LLVM_MC_MCELFEXTRAS_H
+
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/BinaryFormat/ELF.h"
+#include "llvm/Support/LEB128.h"
+#include "llvm/Support/raw_ostream.h"
+
+#include 
+#include 
+
+namespace llvm::ELF {

MaskRay wrote:

Thanks for the comment suggestion. Added.

https://github.com/llvm/llvm-project/pull/97521
___
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] Support CREL (PR #97521)

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


@@ -1861,7 +1886,15 @@ template  Error 
ELFBuilder::readSections(bool EnsureSymtab) {
 
   const typename ELFFile::Elf_Shdr *Shdr =
   Sections->begin() + RelSec->Index;
-  if (RelSec->Type == SHT_REL) {
+  if (RelSec->Type == SHT_CREL) {
+auto Rels = ElfFile.crels(*Shdr);

MaskRay wrote:

Agreed. Renamed to `RelsOrRelas`

https://github.com/llvm/llvm-project/pull/97521
___
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] Support CREL (PR #97521)

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

MaskRay wrote:

> [jh7370](https://github.com/jh7370) I've skimmed briefly and the changes look 
> reasonable - will look more in depth on a separate occasion when I have more 
> time.

Thanks!

> Not for this PR, but I wonder if there would be some benefit in a 
> `--decode-crel` and/or `--encode-crel` option that would convert an object 
> file to/from using CREL. I feel like this might be useful for 
> experimentation, or for handling the case where an object was generated with 
> CREL but needs to be usable by an older tool that doesn't understand CREL. 
> Equally, it could be useful for retroactively encoding CREL when the feature 
> wasn't used during original creation of the object. Thoughts?

Agreed that the `CREL => RELA` conversion will be useful to make CREL better 
interchange format - allow old linkers to build new relocatable files and allow 
other tools for analysis tasks.
That is probably a long-term goal.

In the short-term I aim for providing a complete toolchain 
(assembler,linker,objcopy/strip,objdump) for the most important use case 
(compile + assemble + (strip)? + link).

> [smithp35](https://github.com/smithp35) Only a couple of small comments from 
> me. I'll be out of the office till Monday next week, I'm fine for others to 
> progress this wihout me.

Thanks! Take your time.


https://github.com/llvm/llvm-project/pull/97521
___
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] Support CREL (PR #97521)

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

MaskRay wrote:

> Not that the patch is especially long/complicated, but could be split into 
> the refactor/move of the MC function, then the new usage, if you like (usual 
> reasons - smaller patches are easier to root cause, functionality can be 
> reverted without thrashing the refactored code (or refactored code can be 
> reverted if issues are found in that before the usage goes in), etc)

The body of `encodeCrel` is a simple move. Even with a signature change, the 
two parts (extract and adapt assembler + support llvm-objcopy) could still be 
considered separate.
However, some reviewers might prefer seeing both parts together for a better 
understanding of the extracted API.

Based on the comments from jh7370 and smithp35, the extraction seems reasonable.
**How about I landing the extraction part separately after receiving official 
feedback?
I will then rebase this llvm-objcopy patch.**

(I maintain patches in a stack and ensure the final one 
https://github.com/MaskRay/llvm-project/commits/demo-crel/ passes a local 
integration test.
There is some process inconvenience given that the llvm-objdump PR also 
modifies Object and has been approved yet...)


https://github.com/llvm/llvm-project/pull/97521
___
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] Support CREL (PR #97521)

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

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


___
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] Support CREL (PR #97521)

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

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


___
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-objcopy] Support CREL (PR #97521)

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

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

>From 9bedda3fa950fbb418a53945f6e36da9a7582e3b Mon Sep 17 00:00:00 2001
From: Fangrui Song 
Date: Wed, 3 Jul 2024 11:45:26 -0700
Subject: [PATCH] fix header

Created using spr 1.3.5-bogner
---
 llvm/include/llvm/ADT/bit.h| 1 -
 llvm/include/llvm/MC/MCELFExtras.h | 1 +
 2 files changed, 1 insertion(+), 1 deletion(-)

diff --git a/llvm/include/llvm/ADT/bit.h b/llvm/include/llvm/ADT/bit.h
index 1c8bd46648256..c42b5e686bdc9 100644
--- a/llvm/include/llvm/ADT/bit.h
+++ b/llvm/include/llvm/ADT/bit.h
@@ -14,7 +14,6 @@
 #ifndef LLVM_ADT_BIT_H
 #define LLVM_ADT_BIT_H
 
-#include "llvm/ADT/bit.h"
 #include "llvm/Support/Compiler.h"
 #include 
 #include 
diff --git a/llvm/include/llvm/MC/MCELFExtras.h 
b/llvm/include/llvm/MC/MCELFExtras.h
index 0f0c10edca2cf..498d477fbedc4 100644
--- a/llvm/include/llvm/MC/MCELFExtras.h
+++ b/llvm/include/llvm/MC/MCELFExtras.h
@@ -10,6 +10,7 @@
 #define LLVM_MC_MCELFEXTRAS_H
 
 #include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/bit.h"
 #include "llvm/BinaryFormat/ELF.h"
 #include "llvm/Support/LEB128.h"
 #include "llvm/Support/raw_ostream.h"

___
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] Reapply "[llvm][RISCV] Enable trailing fences for seq-cst stores by default (#87376)" (PR #90267)

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

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


https://github.com/llvm/llvm-project/pull/90267
___
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] [RISCV][lld] Support merging RISC-V Atomics ABI attributes (PR #97347)

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

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


https://github.com/llvm/llvm-project/pull/97347
___
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] [RISCV][lld] Support merging RISC-V Atomics ABI attributes (PR #97347)

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

MaskRay wrote:

> [RISCV][lld]  ...

I usually omit `[RISCV]` when the title already contains `RISC-V` or `RISCV`...

https://github.com/llvm/llvm-project/pull/97347
___
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-objdump] -r: support CREL (PR #97382)

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

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


___
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-objdump] -r: support CREL (PR #97382)

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

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


___
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-objdump] -r: support CREL (PR #97382)

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


@@ -1117,9 +1155,11 @@ void ELFObjectFile::getRelocationTypeName(
 template 
 Expected
 ELFObjectFile::getRelocationAddend(DataRefImpl Rel) const {
-  if (getRelSection(Rel)->sh_type != ELF::SHT_RELA)
-return createError("Section is not SHT_RELA");
-  return (int64_t)getRela(Rel)->r_addend;
+  if (getRelSection(Rel)->sh_type == ELF::SHT_RELA)
+return (int64_t)getRela(Rel)->r_addend;
+  if (getRelSection(Rel)->sh_type == ELF::SHT_CREL)
+return (int64_t)getCrel(Rel).r_addend;
+  return createError("Section is not SHT_RELA");

MaskRay wrote:

Error message adjusted. I think this line is dynamically unreachable.

https://github.com/llvm/llvm-project/pull/97382
___
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-objcopy] Support CREL (PR #97521)

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

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

>From 9bedda3fa950fbb418a53945f6e36da9a7582e3b Mon Sep 17 00:00:00 2001
From: Fangrui Song 
Date: Wed, 3 Jul 2024 11:45:26 -0700
Subject: [PATCH] fix header

Created using spr 1.3.5-bogner
---
 llvm/include/llvm/ADT/bit.h| 1 -
 llvm/include/llvm/MC/MCELFExtras.h | 1 +
 2 files changed, 1 insertion(+), 1 deletion(-)

diff --git a/llvm/include/llvm/ADT/bit.h b/llvm/include/llvm/ADT/bit.h
index 1c8bd46648256e..c42b5e686bdc9c 100644
--- a/llvm/include/llvm/ADT/bit.h
+++ b/llvm/include/llvm/ADT/bit.h
@@ -14,7 +14,6 @@
 #ifndef LLVM_ADT_BIT_H
 #define LLVM_ADT_BIT_H
 
-#include "llvm/ADT/bit.h"
 #include "llvm/Support/Compiler.h"
 #include 
 #include 
diff --git a/llvm/include/llvm/MC/MCELFExtras.h 
b/llvm/include/llvm/MC/MCELFExtras.h
index 0f0c10edca2cfe..498d477fbedc4c 100644
--- a/llvm/include/llvm/MC/MCELFExtras.h
+++ b/llvm/include/llvm/MC/MCELFExtras.h
@@ -10,6 +10,7 @@
 #define LLVM_MC_MCELFEXTRAS_H
 
 #include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/bit.h"
 #include "llvm/BinaryFormat/ELF.h"
 #include "llvm/Support/LEB128.h"
 #include "llvm/Support/raw_ostream.h"

___
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-objcopy] Support CREL (PR #97521)

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

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

>From 9bedda3fa950fbb418a53945f6e36da9a7582e3b Mon Sep 17 00:00:00 2001
From: Fangrui Song 
Date: Wed, 3 Jul 2024 11:45:26 -0700
Subject: [PATCH] fix header

Created using spr 1.3.5-bogner
---
 llvm/include/llvm/ADT/bit.h| 1 -
 llvm/include/llvm/MC/MCELFExtras.h | 1 +
 2 files changed, 1 insertion(+), 1 deletion(-)

diff --git a/llvm/include/llvm/ADT/bit.h b/llvm/include/llvm/ADT/bit.h
index 1c8bd46648256..c42b5e686bdc9 100644
--- a/llvm/include/llvm/ADT/bit.h
+++ b/llvm/include/llvm/ADT/bit.h
@@ -14,7 +14,6 @@
 #ifndef LLVM_ADT_BIT_H
 #define LLVM_ADT_BIT_H
 
-#include "llvm/ADT/bit.h"
 #include "llvm/Support/Compiler.h"
 #include 
 #include 
diff --git a/llvm/include/llvm/MC/MCELFExtras.h 
b/llvm/include/llvm/MC/MCELFExtras.h
index 0f0c10edca2cf..498d477fbedc4 100644
--- a/llvm/include/llvm/MC/MCELFExtras.h
+++ b/llvm/include/llvm/MC/MCELFExtras.h
@@ -10,6 +10,7 @@
 #define LLVM_MC_MCELFEXTRAS_H
 
 #include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/bit.h"
 #include "llvm/BinaryFormat/ELF.h"
 #include "llvm/Support/LEB128.h"
 #include "llvm/Support/raw_ostream.h"

___
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-objcopy] Support CREL (PR #97521)

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

MaskRay wrote:

> Is it worth a test to show a user attempting to strip a symbol referenced by 
> a crel section? Similarly, a crel section that is associated with a section 
> that gets stripped? Perhaps not needed, but just a thought.

This case is tested by `strip-reloc-symbol.test`. I've also duplicated some 
SHT_REL tests in reloc-error-remove-symtab.test

https://github.com/llvm/llvm-project/pull/97521
___
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-objcopy] Support CREL (PR #97521)

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

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

>From 9bedda3fa950fbb418a53945f6e36da9a7582e3b Mon Sep 17 00:00:00 2001
From: Fangrui Song 
Date: Wed, 3 Jul 2024 11:45:26 -0700
Subject: [PATCH 1/2] fix header

Created using spr 1.3.5-bogner
---
 llvm/include/llvm/ADT/bit.h| 1 -
 llvm/include/llvm/MC/MCELFExtras.h | 1 +
 2 files changed, 1 insertion(+), 1 deletion(-)

diff --git a/llvm/include/llvm/ADT/bit.h b/llvm/include/llvm/ADT/bit.h
index 1c8bd46648256..c42b5e686bdc9 100644
--- a/llvm/include/llvm/ADT/bit.h
+++ b/llvm/include/llvm/ADT/bit.h
@@ -14,7 +14,6 @@
 #ifndef LLVM_ADT_BIT_H
 #define LLVM_ADT_BIT_H
 
-#include "llvm/ADT/bit.h"
 #include "llvm/Support/Compiler.h"
 #include 
 #include 
diff --git a/llvm/include/llvm/MC/MCELFExtras.h 
b/llvm/include/llvm/MC/MCELFExtras.h
index 0f0c10edca2cf..498d477fbedc4 100644
--- a/llvm/include/llvm/MC/MCELFExtras.h
+++ b/llvm/include/llvm/MC/MCELFExtras.h
@@ -10,6 +10,7 @@
 #define LLVM_MC_MCELFEXTRAS_H
 
 #include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/bit.h"
 #include "llvm/BinaryFormat/ELF.h"
 #include "llvm/Support/LEB128.h"
 #include "llvm/Support/raw_ostream.h"

>From 799485c4797aa0a1dee207988076f628444b9bdd Mon Sep 17 00:00:00 2001
From: Fangrui Song 
Date: Fri, 5 Jul 2024 14:51:26 -0700
Subject: [PATCH 2/2] fix FileHeader: !FileHeader

Created using spr 1.3.5-bogner
---
 llvm/test/tools/llvm-objcopy/ELF/crel.test | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/llvm/test/tools/llvm-objcopy/ELF/crel.test 
b/llvm/test/tools/llvm-objcopy/ELF/crel.test
index 4c84b45d15559..daf4567d0c8a2 100644
--- a/llvm/test/tools/llvm-objcopy/ELF/crel.test
+++ b/llvm/test/tools/llvm-objcopy/ELF/crel.test
@@ -23,7 +23,7 @@
 # CHECK-NEXT: 0030  {{.*}}   R_X86_64_64   
0
 
 --- !ELF
-FileHeader: !FileHeader
+FileHeader:
   Class: ELFCLASS64
   Data: ELFDATA2LSB
   Type: ET_REL

___
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-objcopy] Support CREL (PR #97521)

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

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

>From 9bedda3fa950fbb418a53945f6e36da9a7582e3b Mon Sep 17 00:00:00 2001
From: Fangrui Song 
Date: Wed, 3 Jul 2024 11:45:26 -0700
Subject: [PATCH 1/2] fix header

Created using spr 1.3.5-bogner
---
 llvm/include/llvm/ADT/bit.h| 1 -
 llvm/include/llvm/MC/MCELFExtras.h | 1 +
 2 files changed, 1 insertion(+), 1 deletion(-)

diff --git a/llvm/include/llvm/ADT/bit.h b/llvm/include/llvm/ADT/bit.h
index 1c8bd46648256..c42b5e686bdc9 100644
--- a/llvm/include/llvm/ADT/bit.h
+++ b/llvm/include/llvm/ADT/bit.h
@@ -14,7 +14,6 @@
 #ifndef LLVM_ADT_BIT_H
 #define LLVM_ADT_BIT_H
 
-#include "llvm/ADT/bit.h"
 #include "llvm/Support/Compiler.h"
 #include 
 #include 
diff --git a/llvm/include/llvm/MC/MCELFExtras.h 
b/llvm/include/llvm/MC/MCELFExtras.h
index 0f0c10edca2cf..498d477fbedc4 100644
--- a/llvm/include/llvm/MC/MCELFExtras.h
+++ b/llvm/include/llvm/MC/MCELFExtras.h
@@ -10,6 +10,7 @@
 #define LLVM_MC_MCELFEXTRAS_H
 
 #include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/bit.h"
 #include "llvm/BinaryFormat/ELF.h"
 #include "llvm/Support/LEB128.h"
 #include "llvm/Support/raw_ostream.h"

>From 799485c4797aa0a1dee207988076f628444b9bdd Mon Sep 17 00:00:00 2001
From: Fangrui Song 
Date: Fri, 5 Jul 2024 14:51:26 -0700
Subject: [PATCH 2/2] fix FileHeader: !FileHeader

Created using spr 1.3.5-bogner
---
 llvm/test/tools/llvm-objcopy/ELF/crel.test | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/llvm/test/tools/llvm-objcopy/ELF/crel.test 
b/llvm/test/tools/llvm-objcopy/ELF/crel.test
index 4c84b45d15559..daf4567d0c8a2 100644
--- a/llvm/test/tools/llvm-objcopy/ELF/crel.test
+++ b/llvm/test/tools/llvm-objcopy/ELF/crel.test
@@ -23,7 +23,7 @@
 # CHECK-NEXT: 0030  {{.*}}   R_X86_64_64   
0
 
 --- !ELF
-FileHeader: !FileHeader
+FileHeader:
   Class: ELFCLASS64
   Data: ELFDATA2LSB
   Type: ET_REL

___
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-objcopy] Support CREL (PR #97521)

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

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

>From 9bedda3fa950fbb418a53945f6e36da9a7582e3b Mon Sep 17 00:00:00 2001
From: Fangrui Song 
Date: Wed, 3 Jul 2024 11:45:26 -0700
Subject: [PATCH 1/2] fix header

Created using spr 1.3.5-bogner
---
 llvm/include/llvm/ADT/bit.h| 1 -
 llvm/include/llvm/MC/MCELFExtras.h | 1 +
 2 files changed, 1 insertion(+), 1 deletion(-)

diff --git a/llvm/include/llvm/ADT/bit.h b/llvm/include/llvm/ADT/bit.h
index 1c8bd46648256e..c42b5e686bdc9c 100644
--- a/llvm/include/llvm/ADT/bit.h
+++ b/llvm/include/llvm/ADT/bit.h
@@ -14,7 +14,6 @@
 #ifndef LLVM_ADT_BIT_H
 #define LLVM_ADT_BIT_H
 
-#include "llvm/ADT/bit.h"
 #include "llvm/Support/Compiler.h"
 #include 
 #include 
diff --git a/llvm/include/llvm/MC/MCELFExtras.h 
b/llvm/include/llvm/MC/MCELFExtras.h
index 0f0c10edca2cfe..498d477fbedc4c 100644
--- a/llvm/include/llvm/MC/MCELFExtras.h
+++ b/llvm/include/llvm/MC/MCELFExtras.h
@@ -10,6 +10,7 @@
 #define LLVM_MC_MCELFEXTRAS_H
 
 #include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/bit.h"
 #include "llvm/BinaryFormat/ELF.h"
 #include "llvm/Support/LEB128.h"
 #include "llvm/Support/raw_ostream.h"

>From 799485c4797aa0a1dee207988076f628444b9bdd Mon Sep 17 00:00:00 2001
From: Fangrui Song 
Date: Fri, 5 Jul 2024 14:51:26 -0700
Subject: [PATCH 2/2] fix FileHeader: !FileHeader

Created using spr 1.3.5-bogner
---
 llvm/test/tools/llvm-objcopy/ELF/crel.test | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/llvm/test/tools/llvm-objcopy/ELF/crel.test 
b/llvm/test/tools/llvm-objcopy/ELF/crel.test
index 4c84b45d155597..daf4567d0c8a2b 100644
--- a/llvm/test/tools/llvm-objcopy/ELF/crel.test
+++ b/llvm/test/tools/llvm-objcopy/ELF/crel.test
@@ -23,7 +23,7 @@
 # CHECK-NEXT: 0030  {{.*}}   R_X86_64_64   
0
 
 --- !ELF
-FileHeader: !FileHeader
+FileHeader:
   Class: ELFCLASS64
   Data: ELFDATA2LSB
   Type: ET_REL

___
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] Cleanup use of COMPILER_RT_INCLUDE_TESTS (PR #98246)

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

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

I am not familiar with how the tests cmake work, but this patch indeed improves 
consistency.

For example, `foreach(arch ${MEMPROF_TEST_ARCH})` is at the toplevel while its 
unittest `foreach` is guarded by `COMPILER_RT_INCLUDE_TESTS`. Removing 
`COMPILER_RT_INCLUDE_TESTS` is great.


https://github.com/llvm/llvm-project/pull/98246
___
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] [tsan] Replace ALIGNED with alignas (PR #98959)

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

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

Similar to #98958.



___
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/19.x: [LLVM] [MC] Update frame layout & CFI generation to handle frames larger than 2gb (#99263) (PR #100195)

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

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


https://github.com/llvm/llvm-project/pull/100195
___
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][LoongArch] Support R_LARCH_TLS_{LD, GD, DESC}_PCREL_S2 (PR #100105)

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

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


https://github.com/llvm/llvm-project/pull/100105
___
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] [flang] [llvm] release/19.x: [Flang][Docs] Update information about AArch64 trampolines (#100391) (PR #100471)

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

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


https://github.com/llvm/llvm-project/pull/100471
___
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/19.x: [LoongArch][MC] Support %[ld_/gd_/desc_]pcrel_20 (PR #100704)

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

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


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


[llvm-branch-commits] [lld] release/19.x: [lld][ELF][LoongArch] Support R_LARCH_TLS_{LD, GD, DESC}_PCREL_S2 (PR #100917)

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

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


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


[llvm-branch-commits] [lld] release/19.x: [ELF] Use invokeOnRelocs. NFC (PR #100883)

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

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


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


[llvm-branch-commits] [compiler-rt] release/19.x: [compiler-rt][test] Disable lld tests on SPARC (#100533) (PR #100979)

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

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


https://github.com/llvm/llvm-project/pull/100979
___
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/19.x: Revert "[MC] Compute fragment offsets eagerly" (PR #101254)

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

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


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


[llvm-branch-commits] [compiler-rt] release/19.x: [InstrProf] Remove duplicate definition of IntPtrT (PR #101061)

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

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


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


[llvm-branch-commits] [compiler-rt] release/19.x: [sanitizer_common][test] Fix InternalMmapWithOffset on 32-bit Linux/s… (#101011) (PR #101142)

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

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


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


[llvm-branch-commits] [compiler-rt] release/19.x: [sanitizer_common] Don't use syscall(SYS_clone) on Linux/sparc64 (#100534) (PR #101137)

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


@@ -826,10 +826,16 @@ uptr internal_sigaltstack(const void *ss, void *oss) {
   return internal_syscall(SYSCALL(sigaltstack), (uptr)ss, (uptr)oss);
 }
 
+extern "C" pid_t __fork(void);
+
 int internal_fork() {
 #if SANITIZER_LINUX
 #  if SANITIZER_S390
   return internal_syscall(SYSCALL(clone), 0, SIGCHLD);
+#  elif SANITIZER_SPARC
+  // The clone syscall interface on SPARC differs massively from the rest,
+  // so fall back to __fork.
+  return __fork();

MaskRay wrote:

Does the `return internal_syscall(SYSCALL(fork));` code path work for sparc64?

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


[llvm-branch-commits] [compiler-rt] release/19.x: [sanitizer_common] Fix signal_line.cpp on SPARC (#100535) (PR #101140)

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

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

This is safe.

https://github.com/llvm/llvm-project/pull/101140
___
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/19.x: [VP] Refactor VectorBuilder to avoid layering violation. NFC (#99276) (PR #101102)

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

MaskRay wrote:

> > Suppose Bazel is a good tool to detect broken dependencies. :)
> 
> @chapuni Without this, is Bazel broken?

Layering check with -fmodules-decluse was broken without this fix (removing 
llvm/Analysis include from llvm/IR, as LLVMAnalysis already depends on 
LLVMCore): 
https://maskray.me/blog/2022-09-25-layering-check-with-clang#layering-check

This backport is desired. 

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


[llvm-branch-commits] [compiler-rt] release/19.x: [asan, test] Disable _FORTIFY_SOURCE test incompatible with glibc 2.40 (PR #101728)

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

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


https://github.com/llvm/llvm-project/pull/101728
___
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/19.x: [VP] Refactor VectorBuilder to avoid layering violation. NFC (#99276) (PR #101102)

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

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


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


[llvm-branch-commits] [lld] release/19.x: [ELF] Support relocatable files using CREL with explicit addends (PR #101532)

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

MaskRay wrote:

Experimental CREL relocations with explicit addends are now supported using the 
temporary section type code 0x4020 (`clang -c 
-Wa,--crel,--allow-experimental-crel`). LLVM will change the code and break 
compatibility (Clang and lld of different versions are not guaranteed to 
cooperate, unlike other features). CREL with implicit addends are not supported.

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


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

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

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


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


[llvm-branch-commits] [libunwind] release/19.x: [libunwind] Add GCS support for AArch64 (#99335) (PR #101888)

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

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


https://github.com/llvm/llvm-project/pull/101888
___
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] ReleaseNotes: lld/ELF: mention CREL (PR #101905)

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

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

None

>From 6bb9a6f3e39019bc5cef3284dd77a4bcaa59193a Mon Sep 17 00:00:00 2001
From: Fangrui Song 
Date: Sun, 4 Aug 2024 13:48:22 -0700
Subject: [PATCH] ReleaseNotes: lld/ELF: mention CREL

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

diff --git a/lld/docs/ReleaseNotes.rst b/lld/docs/ReleaseNotes.rst
index 09081e421e905..7e0da84506a8d 100644
--- a/lld/docs/ReleaseNotes.rst
+++ b/lld/docs/ReleaseNotes.rst
@@ -26,6 +26,12 @@ Non-comprehensive list of changes in this release
 ELF Improvements
 
 
+* Experimental CREL relocations with explicit addends are now supported using 
the
+  temporary section type code 0x4020 (``clang -c 
-Wa,--crel,--allow-experimental-crel``).
+  LLVM will change the code and break compatibility (Clang and lld of different
+  versions are not guaranteed to cooperate, unlike other features). CREL with
+  implicit addends are not supported.
+  (`#98115 `_)
 * ``EI_OSABI`` in the output is now inferred from input object files.
   (`#97144 `_)
 * ``--compress-sections ={none,zlib,zstd}[:level]`` is added to 
compress

___
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] ReleaseNotes: lld/ELF: mention CREL (PR #101905)

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

https://github.com/MaskRay milestoned 
https://github.com/llvm/llvm-project/pull/101905
___
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] ReleaseNotes: lld/ELF: mention CREL (PR #101905)

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

https://github.com/MaskRay edited 
https://github.com/llvm/llvm-project/pull/101905
___
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] ReleaseNotes: lld/ELF: mention CREL (PR #101905)

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

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

>From 1bc0172317f37ff4433e97e9b1d38e1b76e7d5a9 Mon Sep 17 00:00:00 2001
From: Fangrui Song 
Date: Sun, 4 Aug 2024 13:48:22 -0700
Subject: [PATCH] ReleaseNotes: lld/ELF: mention CREL

---
 lld/docs/ReleaseNotes.rst | 8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/lld/docs/ReleaseNotes.rst b/lld/docs/ReleaseNotes.rst
index 09081e421e905..589db58f36a81 100644
--- a/lld/docs/ReleaseNotes.rst
+++ b/lld/docs/ReleaseNotes.rst
@@ -26,6 +26,12 @@ Non-comprehensive list of changes in this release
 ELF Improvements
 
 
+* Experimental CREL relocations with explicit addends are now supported using 
the
+  temporary section type code 0x4020 (``clang -c 
-Wa,--crel,--allow-experimental-crel``).
+  LLVM will change the code and break compatibility (Clang and lld of different
+  versions are not guaranteed to cooperate, unlike other features). CREL with
+  implicit addends are not supported.
+  (`#98115 `_)
 * ``EI_OSABI`` in the output is now inferred from input object files.
   (`#97144 `_)
 * ``--compress-sections ={none,zlib,zstd}[:level]`` is added to 
compress
@@ -88,7 +94,7 @@ ELF Improvements
   (`#94099 `_)
   Non-alloc orphan sections are now placed at the end.
   (`#94519 `_)
-* R_X86_64_REX_GOTPCRELX of the addq form is no longer incorrectly optimized 
when the address is larger than 0x8000.
+* `R_X86_64_REX_GOTPCRELX` of the addq form is no longer incorrectly optimized 
when the address is larger than 0x8000.
 
 Breaking 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] [lld] ReleaseNotes: lld/ELF: mention CREL (PR #101905)

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

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

>From 6a01c4cb0b55f7ba98341e3d19c2bf4926696d59 Mon Sep 17 00:00:00 2001
From: Fangrui Song 
Date: Sun, 4 Aug 2024 13:48:22 -0700
Subject: [PATCH] ReleaseNotes: lld/ELF: mention CREL

---
 lld/docs/ReleaseNotes.rst | 8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/lld/docs/ReleaseNotes.rst b/lld/docs/ReleaseNotes.rst
index 09081e421e905..98fddcd7bf7f2 100644
--- a/lld/docs/ReleaseNotes.rst
+++ b/lld/docs/ReleaseNotes.rst
@@ -26,6 +26,12 @@ Non-comprehensive list of changes in this release
 ELF Improvements
 
 
+* Experimental CREL relocations with explicit addends are now supported using 
the
+  temporary section type code 0x4020 (``clang -c 
-Wa,--crel,--allow-experimental-crel``).
+  LLVM will change the code and break compatibility (Clang and lld of different
+  versions are not guaranteed to cooperate, unlike other features). CREL with
+  implicit addends are not supported.
+  (`#98115 `_)
 * ``EI_OSABI`` in the output is now inferred from input object files.
   (`#97144 `_)
 * ``--compress-sections ={none,zlib,zstd}[:level]`` is added to 
compress
@@ -88,7 +94,7 @@ ELF Improvements
   (`#94099 `_)
   Non-alloc orphan sections are now placed at the end.
   (`#94519 `_)
-* R_X86_64_REX_GOTPCRELX of the addq form is no longer incorrectly optimized 
when the address is larger than 0x8000.
+* ``R_X86_64_REX_GOTPCRELX`` of the addq form is no longer incorrectly 
optimized when the address is larger than 0x8000.
 
 Breaking 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] [Driver] Temporarily probe aarch64-linux-gnu GCC installation (PR #102039)

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

https://github.com/MaskRay milestoned 
https://github.com/llvm/llvm-project/pull/102039
___
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] [Driver] Temporarily probe aarch64-linux-gnu GCC installation (PR #102039)

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

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

As the comment explains, `*Triples[]` lists are discouraged and not 
comprehensive anyway (e.g.
aarch64-unknown-linux-gnu/aarch64-unknown-linux-musl/aarch64-amazon-linux do 
not work).

Boost incorrectly specifies --target=arm64-pc-linux ("arm64" should not be used 
for Linux) and expects to probe "aarch64-linux-gnu". Add this temporary 
workaround for the 19.x releases.

Fix #101525

>From 5d45d1a088ad969ef26186c71ee2b782b0cd559e Mon Sep 17 00:00:00 2001
From: Fangrui Song 
Date: Mon, 5 Aug 2024 11:52:52 -0700
Subject: [PATCH] [Driver] Temporarily probe aarch64-linux-gnu GCC installation

As the comment explains, `*Triples[]` lists are discouraged and not
comprehensive anyway (e.g.
aarch64-unknown-linux-gnu/aarch64-unknown-linux-musl/aarch64-amazon-linux
do not work).

Boost incorrectly specifies --target=arm64-pc-linux ("arm64" should not
be used for Linux) and expects to probe "aarch64-linux-gnu". Add this
temporary workaround for the 19.x releases.
---
 clang/lib/Driver/ToolChains/Gnu.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/clang/lib/Driver/ToolChains/Gnu.cpp 
b/clang/lib/Driver/ToolChains/Gnu.cpp
index 52c2ee90b1b28..543f3965dfd4f 100644
--- a/clang/lib/Driver/ToolChains/Gnu.cpp
+++ b/clang/lib/Driver/ToolChains/Gnu.cpp
@@ -2463,7 +2463,8 @@ void 
Generic_GCC::GCCInstallationDetector::AddDefaultGCCPrefixes(
   // lists should shrink over time. Please don't add more elements to *Triples.
   static const char *const AArch64LibDirs[] = {"/lib64", "/lib"};
   static const char *const AArch64Triples[] = {
-  "aarch64-none-linux-gnu", "aarch64-redhat-linux", "aarch64-suse-linux"};
+  "aarch64-none-linux-gnu", "aarch64-linux-gnu", "aarch64-redhat-linux",
+  "aarch64-suse-linux"};
   static const char *const AArch64beLibDirs[] = {"/lib"};
   static const char *const AArch64beTriples[] = {"aarch64_be-none-linux-gnu"};
 

___
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] [Driver] Temporarily probe aarch64-linux-gnu GCC installation (PR #102039)

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

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


[llvm-branch-commits] [lld] release/19.x: [lld][ARM] Fix assertion when mixing ARM and Thumb objects (#101985) (PR #102292)

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

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


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


[llvm-branch-commits] [lld] release/19.x: [ELF] scanRelocations: support .crel.eh_frame (PR #102523)

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

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


https://github.com/llvm/llvm-project/pull/102523
___
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] [nsan] Use sanitizer allocator (PR #102764)

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

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

* The performance is better than the glibc allocator.
* Allocator interface functions, sanitizer allocator options, and
  MallocHooks/FreeHooks are supported.
* Shadow memory has specific memory layout requirement. Using libc
  allocator could lead to conflicts.
* When we intercept mmap for reliability (the VMA could reuse a
  previously released VMA that is poisoned): glibc may invoke an
  internal system call to call unmmap, which cannot be intercepted. We
  will not be able to return the shadow memory to the OS.

Similar to dfsan https://reviews.llvm.org/D101204



___
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] [nsan] Use sanitizer allocator (PR #102764)

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

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


___
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] [nsan] Use sanitizer allocator (PR #102764)

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

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


___
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] [nsan] Use sanitizer allocator (PR #102764)

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

https://github.com/MaskRay edited 
https://github.com/llvm/llvm-project/pull/102764
___
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   6   7   8   >