[llvm-branch-commits] [lldb] ba6e663 - Revert "[lldb] Do not use LC_FUNCTION_STARTS data to determine symbol size as…"

2024-09-14 Thread via llvm-branch-commits

Author: Jonas Devlieghere
Date: 2024-09-14T10:49:27-07:00
New Revision: ba6e663299e1d7b54a3ac4a7c647d44f66d8699d

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

LOG: Revert "[lldb] Do not use LC_FUNCTION_STARTS data to determine symbol size 
as…"

This reverts commit 0351dc522a25df0473a63b414a5bfde5814d3dc3.

Added: 


Modified: 
lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp

Removed: 




diff  --git a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp 
b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
index c36748963db37b..06da83e26a26a5 100644
--- a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
+++ b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
@@ -3768,6 +3768,7 @@ void ObjectFileMachO::ParseSymtab(Symtab &symtab) {
 
   SymbolType type = eSymbolTypeInvalid;
   SectionSP symbol_section;
+  lldb::addr_t symbol_byte_size = 0;
   bool add_nlist = true;
   bool is_gsym = false;
   bool demangled_is_synthesized = false;
@@ -4353,6 +4354,47 @@ void ObjectFileMachO::ParseSymtab(Symtab &symtab) {
 
   if (symbol_section) {
 const addr_t section_file_addr = symbol_section->GetFileAddress();
+if (symbol_byte_size == 0 && function_starts_count > 0) {
+  addr_t symbol_lookup_file_addr = nlist.n_value;
+  // Do an exact address match for non-ARM addresses, else get the
+  // closest since the symbol might be a thumb symbol which has an
+  // address with bit zero set.
+  FunctionStarts::Entry *func_start_entry =
+  function_starts.FindEntry(symbol_lookup_file_addr, !is_arm);
+  if (is_arm && func_start_entry) {
+// Verify that the function start address is the symbol address
+// (ARM) or the symbol address + 1 (thumb).
+if (func_start_entry->addr != symbol_lookup_file_addr &&
+func_start_entry->addr != (symbol_lookup_file_addr + 1)) {
+  // Not the right entry, NULL it out...
+  func_start_entry = nullptr;
+}
+  }
+  if (func_start_entry) {
+func_start_entry->data = true;
+
+addr_t symbol_file_addr = func_start_entry->addr;
+if (is_arm)
+  symbol_file_addr &= THUMB_ADDRESS_BIT_MASK;
+
+const FunctionStarts::Entry *next_func_start_entry =
+function_starts.FindNextEntry(func_start_entry);
+const addr_t section_end_file_addr =
+section_file_addr + symbol_section->GetByteSize();
+if (next_func_start_entry) {
+  addr_t next_symbol_file_addr = next_func_start_entry->addr;
+  // Be sure the clear the Thumb address bit when we calculate the
+  // size from the current and next address
+  if (is_arm)
+next_symbol_file_addr &= THUMB_ADDRESS_BIT_MASK;
+  symbol_byte_size = std::min(
+  next_symbol_file_addr - symbol_file_addr,
+  section_end_file_addr - symbol_file_addr);
+} else {
+  symbol_byte_size = section_end_file_addr - symbol_file_addr;
+}
+  }
+}
 symbol_value -= section_file_addr;
   }
 
@@ -4459,6 +4501,9 @@ void ObjectFileMachO::ParseSymtab(Symtab &symtab) {
   if (nlist.n_desc & N_WEAK_REF)
 sym[sym_idx].SetIsWeak(true);
 
+  if (symbol_byte_size > 0)
+sym[sym_idx].SetByteSize(symbol_byte_size);
+
   if (demangled_is_synthesized)
 sym[sym_idx].SetDemangledNameIsSynthesized(true);
 
@@ -4577,7 +4622,23 @@ void ObjectFileMachO::ParseSymtab(Symtab &symtab) {
   Address symbol_addr;
   if (module_sp->ResolveFileAddress(symbol_file_addr, symbol_addr)) {
 SectionSP symbol_section(symbol_addr.GetSection());
+uint32_t symbol_byte_size = 0;
 if (symbol_section) {
+  const addr_t section_file_addr = 
symbol_section->GetFileAddress();
+  const FunctionStarts::Entry *next_func_start_entry =
+  function_starts.FindNextEntry(func_start_entry);
+  const addr_t section_end_file_addr =
+  section_file_addr + symbol_section->GetByteSize();
+  if (next_func_start_entry) {
+addr_t next_symbol_file_addr = next_func_start_entry->addr;
+if (is_arm)
+  next_symbol_file_addr &= THUMB_ADDRESS_BIT_MASK;
+symbol_byte_size = std::min(
+next_symbol_file_addr - symbol_file_addr,
+section_end_file_addr - symbol_file_addr);
+  } else {
+symbol_byte_size = section_end_file_addr - sy

[llvm-branch-commits] [llvm] [Attributor] Take the address space from addrspacecast directly (PR #108258)

2024-09-14 Thread Shilei Tian via llvm-branch-commits

https://github.com/shiltian edited 
https://github.com/llvm/llvm-project/pull/108258
___
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] [Attributor] Take the address space from addrspacecast directly (PR #108258)

2024-09-14 Thread Shilei Tian via llvm-branch-commits

https://github.com/shiltian updated 
https://github.com/llvm/llvm-project/pull/108258

>From 5f9e01b93c02d5951d399258c12381de6f1c8626 Mon Sep 17 00:00:00 2001
From: Shilei Tian 
Date: Wed, 11 Sep 2024 12:23:32 -0400
Subject: [PATCH] [Attributor] Take the address space from addrspacecast
 directly

If the value to be analyzed is directly from addrspacecast, we take the source
address space directly. This is to improve the case where in
`AMDGPUPromoteKernelArgumentsPass`, the kernel argument is promoted by
insertting an addrspacecast directly from a generic pointer. However, during the
analysis, the underlying object will be the generic pointer, instead of the
addrspacecast, thus the inferred address space is the generic one, which is not
ideal.
---
 .../Transforms/IPO/AttributorAttributes.cpp   | 54 ++-
 llvm/test/CodeGen/AMDGPU/aa-as-infer.ll   | 35 
 2 files changed, 76 insertions(+), 13 deletions(-)

diff --git a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp 
b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
index 9c775e48f28195..749c5ea0bfcf6c 100644
--- a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
+++ b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
@@ -12589,15 +12589,37 @@ struct AAAddressSpaceImpl : public AAAddressSpace {
 
   ChangeStatus updateImpl(Attributor &A) override {
 uint32_t OldAddressSpace = AssumedAddressSpace;
-auto *AUO = A.getOrCreateAAFor(getIRPosition(), this,
-DepClassTy::REQUIRED);
-auto Pred = [&](Value &Obj) {
+
+auto CheckAddressSpace = [&](Value &Obj) {
   if (isa(&Obj))
 return true;
+  // If an argument in flat address space has addrspace cast uses, and 
those
+  // casts are same, then we take the dst addrspace.
+  if (auto *Arg = dyn_cast(&Obj)) {
+unsigned FlatAS =
+A.getInfoCache().getFlatAddressSpace(Arg->getParent());
+if (FlatAS != InvalidAddressSpace &&
+Arg->getType()->getPointerAddressSpace() == FlatAS) {
+  unsigned CastAddrSpace = FlatAS;
+  for (auto *U : Arg->users()) {
+auto *ASCI = dyn_cast(U);
+if (!ASCI)
+  continue;
+if (CastAddrSpace != FlatAS &&
+CastAddrSpace != ASCI->getDestAddressSpace())
+  return false;
+CastAddrSpace = ASCI->getDestAddressSpace();
+  }
+  if (CastAddrSpace != FlatAS)
+return takeAddressSpace(CastAddrSpace);
+}
+  }
   return takeAddressSpace(Obj.getType()->getPointerAddressSpace());
 };
 
-if (!AUO->forallUnderlyingObjects(Pred))
+auto *AUO = A.getOrCreateAAFor(getIRPosition(), this,
+DepClassTy::REQUIRED);
+if (!AUO->forallUnderlyingObjects(CheckAddressSpace))
   return indicatePessimisticFixpoint();
 
 return OldAddressSpace == AssumedAddressSpace ? ChangeStatus::UNCHANGED
@@ -12606,17 +12628,18 @@ struct AAAddressSpaceImpl : public AAAddressSpace {
 
   /// See AbstractAttribute::manifest(...).
   ChangeStatus manifest(Attributor &A) override {
-if (getAddressSpace() == InvalidAddressSpace ||
-getAddressSpace() == getAssociatedType()->getPointerAddressSpace())
+unsigned NewAS = getAddressSpace();
+
+if (NewAS == InvalidAddressSpace ||
+NewAS == getAssociatedType()->getPointerAddressSpace())
   return ChangeStatus::UNCHANGED;
 
 Value *AssociatedValue = &getAssociatedValue();
 Value *OriginalValue = peelAddrspacecast(AssociatedValue);
-
 PointerType *NewPtrTy =
-PointerType::get(getAssociatedType()->getContext(), getAddressSpace());
+PointerType::get(getAssociatedType()->getContext(), NewAS);
 bool UseOriginalValue =
-OriginalValue->getType()->getPointerAddressSpace() == 
getAddressSpace();
+OriginalValue->getType()->getPointerAddressSpace() == NewAS;
 
 bool Changed = false;
 
@@ -12677,11 +12700,16 @@ struct AAAddressSpaceImpl : public AAAddressSpace {
   }
 
   static Value *peelAddrspacecast(Value *V) {
-if (auto *I = dyn_cast(V))
-  return peelAddrspacecast(I->getPointerOperand());
+if (auto *I = dyn_cast(V)) {
+  assert(I->getSrcAddressSpace() && "there should not be AS 0 -> AS X");
+  return I->getPointerOperand();
+}
 if (auto *C = dyn_cast(V))
-  if (C->getOpcode() == Instruction::AddrSpaceCast)
-return peelAddrspacecast(C->getOperand(0));
+  if (C->getOpcode() == Instruction::AddrSpaceCast) {
+assert(C->getOperand(0)->getType()->getPointerAddressSpace() &&
+   "there should not be AS 0 -> AS X");
+return C->getOperand(0);
+  }
 return V;
   }
 };
diff --git a/llvm/test/CodeGen/AMDGPU/aa-as-infer.ll 
b/llvm/test/CodeGen/AMDGPU/aa-as-infer.ll
index fdc5debb18915c..d1a6414fe49ae1 100644
--- a/llvm/test/CodeGen/AMDGPU/aa-as-infer.ll
+++ b/llvm/test/CodeGen/AMD

[llvm-branch-commits] [llvm] [Attributor] Take the address space from addrspacecast directly (PR #108258)

2024-09-14 Thread Shilei Tian via llvm-branch-commits

https://github.com/shiltian updated 
https://github.com/llvm/llvm-project/pull/108258

>From d16be3fc2a2d1d572c25a76ee297dd0f4f8e37ed Mon Sep 17 00:00:00 2001
From: Shilei Tian 
Date: Wed, 11 Sep 2024 12:23:32 -0400
Subject: [PATCH] [Attributor] Take the address space from addrspacecast
 directly

If the value to be analyzed is directly from addrspacecast, we take the source
address space directly. This is to improve the case where in
`AMDGPUPromoteKernelArgumentsPass`, the kernel argument is promoted by
insertting an addrspacecast directly from a generic pointer. However, during the
analysis, the underlying object will be the generic pointer, instead of the
addrspacecast, thus the inferred address space is the generic one, which is not
ideal.
---
 .../Transforms/IPO/AttributorAttributes.cpp   | 54 ++-
 llvm/test/CodeGen/AMDGPU/aa-as-infer.ll   | 35 
 2 files changed, 76 insertions(+), 13 deletions(-)

diff --git a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp 
b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
index 9c775e48f28195..749c5ea0bfcf6c 100644
--- a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
+++ b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
@@ -12589,15 +12589,37 @@ struct AAAddressSpaceImpl : public AAAddressSpace {
 
   ChangeStatus updateImpl(Attributor &A) override {
 uint32_t OldAddressSpace = AssumedAddressSpace;
-auto *AUO = A.getOrCreateAAFor(getIRPosition(), this,
-DepClassTy::REQUIRED);
-auto Pred = [&](Value &Obj) {
+
+auto CheckAddressSpace = [&](Value &Obj) {
   if (isa(&Obj))
 return true;
+  // If an argument in flat address space has addrspace cast uses, and 
those
+  // casts are same, then we take the dst addrspace.
+  if (auto *Arg = dyn_cast(&Obj)) {
+unsigned FlatAS =
+A.getInfoCache().getFlatAddressSpace(Arg->getParent());
+if (FlatAS != InvalidAddressSpace &&
+Arg->getType()->getPointerAddressSpace() == FlatAS) {
+  unsigned CastAddrSpace = FlatAS;
+  for (auto *U : Arg->users()) {
+auto *ASCI = dyn_cast(U);
+if (!ASCI)
+  continue;
+if (CastAddrSpace != FlatAS &&
+CastAddrSpace != ASCI->getDestAddressSpace())
+  return false;
+CastAddrSpace = ASCI->getDestAddressSpace();
+  }
+  if (CastAddrSpace != FlatAS)
+return takeAddressSpace(CastAddrSpace);
+}
+  }
   return takeAddressSpace(Obj.getType()->getPointerAddressSpace());
 };
 
-if (!AUO->forallUnderlyingObjects(Pred))
+auto *AUO = A.getOrCreateAAFor(getIRPosition(), this,
+DepClassTy::REQUIRED);
+if (!AUO->forallUnderlyingObjects(CheckAddressSpace))
   return indicatePessimisticFixpoint();
 
 return OldAddressSpace == AssumedAddressSpace ? ChangeStatus::UNCHANGED
@@ -12606,17 +12628,18 @@ struct AAAddressSpaceImpl : public AAAddressSpace {
 
   /// See AbstractAttribute::manifest(...).
   ChangeStatus manifest(Attributor &A) override {
-if (getAddressSpace() == InvalidAddressSpace ||
-getAddressSpace() == getAssociatedType()->getPointerAddressSpace())
+unsigned NewAS = getAddressSpace();
+
+if (NewAS == InvalidAddressSpace ||
+NewAS == getAssociatedType()->getPointerAddressSpace())
   return ChangeStatus::UNCHANGED;
 
 Value *AssociatedValue = &getAssociatedValue();
 Value *OriginalValue = peelAddrspacecast(AssociatedValue);
-
 PointerType *NewPtrTy =
-PointerType::get(getAssociatedType()->getContext(), getAddressSpace());
+PointerType::get(getAssociatedType()->getContext(), NewAS);
 bool UseOriginalValue =
-OriginalValue->getType()->getPointerAddressSpace() == 
getAddressSpace();
+OriginalValue->getType()->getPointerAddressSpace() == NewAS;
 
 bool Changed = false;
 
@@ -12677,11 +12700,16 @@ struct AAAddressSpaceImpl : public AAAddressSpace {
   }
 
   static Value *peelAddrspacecast(Value *V) {
-if (auto *I = dyn_cast(V))
-  return peelAddrspacecast(I->getPointerOperand());
+if (auto *I = dyn_cast(V)) {
+  assert(I->getSrcAddressSpace() && "there should not be AS 0 -> AS X");
+  return I->getPointerOperand();
+}
 if (auto *C = dyn_cast(V))
-  if (C->getOpcode() == Instruction::AddrSpaceCast)
-return peelAddrspacecast(C->getOperand(0));
+  if (C->getOpcode() == Instruction::AddrSpaceCast) {
+assert(C->getOperand(0)->getType()->getPointerAddressSpace() &&
+   "there should not be AS 0 -> AS X");
+return C->getOperand(0);
+  }
 return V;
   }
 };
diff --git a/llvm/test/CodeGen/AMDGPU/aa-as-infer.ll 
b/llvm/test/CodeGen/AMDGPU/aa-as-infer.ll
index fdc5debb18915c..d1a6414fe49ae1 100644
--- a/llvm/test/CodeGen/AMDGPU/aa-as-infer.ll
+++ b/llvm/test/CodeGen/AMD

[llvm-branch-commits] [compiler-rt] [TySan] Fix struct access with different bases (PR #108385)

2024-09-14 Thread Tavian Barnes via llvm-branch-commits

tavianator wrote:

I have consulted with an expert in the strict aliasing rules and we came to the 
horrifying (to me) conclusion that TySan is actually **correct** in this case, 
at least according to the C standard.

https://github.com/llvm/llvm-project/pull/108385
___
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] [Attributor] Take the address space from addrspacecast directly (PR #108258)

2024-09-14 Thread Shilei Tian via llvm-branch-commits

https://github.com/shiltian updated 
https://github.com/llvm/llvm-project/pull/108258

>From 9beeba09cd35aa78d6ebb90bb98bde0b4113554e Mon Sep 17 00:00:00 2001
From: Shilei Tian 
Date: Wed, 11 Sep 2024 12:23:32 -0400
Subject: [PATCH] [Attributor] Take the address space from addrspacecast
 directly

If the value to be analyzed is directly from addrspacecast, we take the source
address space directly. This is to improve the case where in
`AMDGPUPromoteKernelArgumentsPass`, the kernel argument is promoted by
insertting an addrspacecast directly from a generic pointer. However, during the
analysis, the underlying object will be the generic pointer, instead of the
addrspacecast, thus the inferred address space is the generic one, which is not
ideal.
---
 .../Transforms/IPO/AttributorAttributes.cpp   | 63 ++-
 llvm/test/CodeGen/AMDGPU/aa-as-infer.ll   | 35 +++
 2 files changed, 84 insertions(+), 14 deletions(-)

diff --git a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp 
b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
index 9c775e48f28195..aa5cedd13413d6 100644
--- a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
+++ b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
@@ -12589,15 +12589,37 @@ struct AAAddressSpaceImpl : public AAAddressSpace {
 
   ChangeStatus updateImpl(Attributor &A) override {
 uint32_t OldAddressSpace = AssumedAddressSpace;
-auto *AUO = A.getOrCreateAAFor(getIRPosition(), this,
-DepClassTy::REQUIRED);
-auto Pred = [&](Value &Obj) {
+
+auto CheckAddressSpace = [&](Value &Obj) {
   if (isa(&Obj))
 return true;
+  // If an argument in flat address space has addrspace cast uses, and 
those
+  // casts are same, then we take the dst addrspace.
+  if (auto *Arg = dyn_cast(&Obj)) {
+unsigned FlatAS =
+A.getInfoCache().getFlatAddressSpace(Arg->getParent());
+if (FlatAS != InvalidAddressSpace &&
+Arg->getType()->getPointerAddressSpace() == FlatAS) {
+  unsigned CastAddrSpace = FlatAS;
+  for (auto *U : Arg->users()) {
+auto *ASCI = dyn_cast(U);
+if (!ASCI)
+  continue;
+if (CastAddrSpace != FlatAS &&
+CastAddrSpace != ASCI->getDestAddressSpace())
+  return false;
+CastAddrSpace = ASCI->getDestAddressSpace();
+  }
+  if (CastAddrSpace != FlatAS)
+return takeAddressSpace(CastAddrSpace);
+}
+  }
   return takeAddressSpace(Obj.getType()->getPointerAddressSpace());
 };
 
-if (!AUO->forallUnderlyingObjects(Pred))
+auto *AUO = A.getOrCreateAAFor(getIRPosition(), this,
+DepClassTy::REQUIRED);
+if (!AUO->forallUnderlyingObjects(CheckAddressSpace))
   return indicatePessimisticFixpoint();
 
 return OldAddressSpace == AssumedAddressSpace ? ChangeStatus::UNCHANGED
@@ -12606,17 +12628,23 @@ struct AAAddressSpaceImpl : public AAAddressSpace {
 
   /// See AbstractAttribute::manifest(...).
   ChangeStatus manifest(Attributor &A) override {
-if (getAddressSpace() == InvalidAddressSpace ||
-getAddressSpace() == getAssociatedType()->getPointerAddressSpace())
+unsigned NewAS = getAddressSpace();
+
+if (NewAS == InvalidAddressSpace ||
+NewAS == getAssociatedType()->getPointerAddressSpace())
   return ChangeStatus::UNCHANGED;
 
+unsigned FlatAS =
+A.getInfoCache().getFlatAddressSpace(getAssociatedFunction());
+assert(FlatAS != InvalidAddressSpace);
+
 Value *AssociatedValue = &getAssociatedValue();
-Value *OriginalValue = peelAddrspacecast(AssociatedValue);
+Value *OriginalValue = peelAddrspacecast(AssociatedValue, FlatAS);
 
 PointerType *NewPtrTy =
-PointerType::get(getAssociatedType()->getContext(), getAddressSpace());
+PointerType::get(getAssociatedType()->getContext(), NewAS);
 bool UseOriginalValue =
-OriginalValue->getType()->getPointerAddressSpace() == 
getAddressSpace();
+OriginalValue->getType()->getPointerAddressSpace() == NewAS;
 
 bool Changed = false;
 
@@ -12676,12 +12704,19 @@ struct AAAddressSpaceImpl : public AAAddressSpace {
 return AssumedAddressSpace == AS;
   }
 
-  static Value *peelAddrspacecast(Value *V) {
-if (auto *I = dyn_cast(V))
-  return peelAddrspacecast(I->getPointerOperand());
+  static Value *peelAddrspacecast(Value *V, unsigned FlatAS) {
+if (auto *I = dyn_cast(V)) {
+  assert(I->getSrcAddressSpace() != FlatAS &&
+ "there should not be flat AS -> non-flat AS");
+  return I->getPointerOperand();
+}
 if (auto *C = dyn_cast(V))
-  if (C->getOpcode() == Instruction::AddrSpaceCast)
-return peelAddrspacecast(C->getOperand(0));
+  if (C->getOpcode() == Instruction::AddrSpaceCast) {
+assert(C->getOperand(0)->getType()->getPointerAd

[llvm-branch-commits] [NFC][sanitizer] Use RTLD_DEFAULT for _dl_get_tls_static_info (PR #108723)

2024-09-14 Thread Vitaly Buka via llvm-branch-commits

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

We don't intercept this one, no reason to use RTLD_NEXT.



___
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][sanitizer] Switch to `gnu_get_libc_version` (PR #108724)

2024-09-14 Thread Vitaly Buka via llvm-branch-commits

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

`gnu_get_libc_version` unlike `confstr` is not
intercepted. We should be able to use this
function earier.

Looks like we use `confstr` staring from
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60038
but there is no specific reason to refer it over
`gnu_get_libc_version`.



___
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][sanitizer] Use RTLD_DEFAULT for _dl_get_tls_static_info (PR #108723)

2024-09-14 Thread via llvm-branch-commits

llvmbot wrote:




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

Author: Vitaly Buka (vitalybuka)


Changes

We don't intercept this one, no reason to use RTLD_NEXT.


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


1 Files Affected:

- (modified) compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp 
(+1-1) 


``diff
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp 
b/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp
index 6e1092be569c9f..071ecc4516e0f0 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp
@@ -234,7 +234,7 @@ void InitTlsSize() {
 
 #if defined(__aarch64__) || defined(__x86_64__) || \
 defined(__powerpc64__) || defined(__loongarch__)
-  void *get_tls_static_info = dlsym(RTLD_NEXT, "_dl_get_tls_static_info");
+  void *get_tls_static_info = dlsym(RTLD_DEFAULT, "_dl_get_tls_static_info");
   size_t tls_align;
   ((void (*)(size_t *, size_t *))get_tls_static_info)(&g_tls_size, &tls_align);
 #endif

``




https://github.com/llvm/llvm-project/pull/108723
___
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][sanitizer] Switch to `gnu_get_libc_version` (PR #108724)

2024-09-14 Thread via llvm-branch-commits

llvmbot wrote:




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

Author: Vitaly Buka (vitalybuka)


Changes

`gnu_get_libc_version` unlike `confstr` is not
intercepted. We should be able to use this
function earier.

Looks like we use `confstr` staring from
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60038
but there is no specific reason to refer it over
`gnu_get_libc_version`.


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


1 Files Affected:

- (modified) compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp 
(+8-10) 


``diff
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp 
b/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp
index 071ecc4516e0f0..bc3a41bba03fc1 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp
@@ -40,6 +40,10 @@
 #  include 
 #  include 
 
+#  ifdef SANITIZER_GLIBC
+#include 
+#  endif
+
 #  if !defined(ElfW)
 #define ElfW(type) Elf_##type
 #  endif
@@ -198,17 +202,11 @@ bool SetEnv(const char *name, const char *value) {
 
 __attribute__((unused)) static bool GetLibcVersion(int *major, int *minor,
int *patch) {
-#  ifdef _CS_GNU_LIBC_VERSION
-  char buf[64];
-  uptr len = confstr(_CS_GNU_LIBC_VERSION, buf, sizeof(buf));
-  if (len >= sizeof(buf))
-return false;
-  buf[len] = 0;
-  static const char kGLibC[] = "glibc ";
-  if (internal_strncmp(buf, kGLibC, sizeof(kGLibC) - 1) != 0)
-return false;
-  const char *p = buf + sizeof(kGLibC) - 1;
+#  ifdef SANITIZER_GLIBC
+  const char *p = gnu_get_libc_version();
   *major = internal_simple_strtoll(p, &p, 10);
+  // Caller do not expect anything else.
+  CHECK_EQ(*major, 2);
   *minor = (*p == '.') ? internal_simple_strtoll(p + 1, &p, 10) : 0;
   *patch = (*p == '.') ? internal_simple_strtoll(p + 1, &p, 10) : 0;
   return true;

``




https://github.com/llvm/llvm-project/pull/108724
___
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] [ADT] Use range-based helper functions in SmallSet (PR #108585)

2024-09-14 Thread Sergei Barannikov via llvm-branch-commits

https://github.com/s-barannikov commented:

I'm slightly opposed to this change because it pulls in STLExtras.h.
Yes, it is already included, but it would be better to avoid including it.


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