[llvm-branch-commits] [NFC][sanitizer] Consolidate version checking branches of ThreadDescriptorSizeFallback (PR #108912)

via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Mon Sep 16 19:20:48 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

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

Author: Vitaly Buka (vitalybuka)

<details>
<summary>Changes</summary>



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


1 Files Affected:

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


``````````diff
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp
index 4ed8b4f0825bba..2c64509d578b94 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp
@@ -283,6 +283,22 @@ static uptr ThreadDescriptorSizeFallback() {
   return 0;
 #    endif
 
+#    if SANITIZER_RISCV64
+  int major;
+  int minor;
+  int patch;
+  if (GetLibcVersion(&major, &minor, &patch) && major == 2) {
+    // TODO: consider adding an optional runtime check for an unknown (untested)
+    // glibc version
+    if (minor <= 28)  // WARNING: the highest tested version is 2.29
+      return 1772;    // no guarantees for this one
+    if (minor <= 31)
+      return 1772;  // tested against glibc 2.29, 2.31
+    return 1936;    // tested against glibc 2.32
+  }
+  return 0;
+#    endif
+
 #    if defined(__s390__) || defined(__sparc__)
   // The size of a prefix of TCB including pthread::{specific_1stblock,specific}
   // suffices. Just return offsetof(struct pthread, specific_used), which hasn't
@@ -301,22 +317,6 @@ static uptr ThreadDescriptorSizeFallback() {
   return 1856;  // from glibc 2.36
 #    endif
 
-#    if SANITIZER_RISCV64
-  int major;
-  int minor;
-  int patch;
-  if (GetLibcVersion(&major, &minor, &patch) && major == 2) {
-    // TODO: consider adding an optional runtime check for an unknown (untested)
-    // glibc version
-    if (minor <= 28)  // WARNING: the highest tested version is 2.29
-      return 1772;    // no guarantees for this one
-    if (minor <= 31)
-      return 1772;  // tested against glibc 2.29, 2.31
-    return 1936;    // tested against glibc 2.32
-  }
-  return 0;
-#    endif
-
 #    if defined(__aarch64__)
   // The sizeof (struct pthread) is the same from GLIBC 2.17 to 2.22.
   return 1776;

``````````

</details>


https://github.com/llvm/llvm-project/pull/108912


More information about the llvm-branch-commits mailing list