Skip to content

[DenseMap] Do not align pointer sentinel values (NFC) #146595

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 7, 2025

Conversation

nikic
Copy link
Contributor

@nikic nikic commented Jul 1, 2025

DenseMapInfo for pointers currently uses empty/tombstone values that are aligned (by assuming a very conservative alignment). However, this means that we have to work with larger immediates.

This patch proposes to use the values -1 and -2 instead, without caring about pointer alignment. (Non-roundtrip) integer to pointer casts are implementation-defined in C++, but the general implementer consensus (including Clang) is that raw pointers do not carry alignment requirements, only memory accesses do.

We already have lots of places that rely on this using variations on reinterpret_cast<T*>(-1), so it seems odd to insist on properly aligned pointers in this one place.

It is necessary to adjust a few other places after this change, which currently assume that DenseMapInfo<void *> returns a highly-aligned pointer.

This is a small improvement for both compile-time and clang binary size: https://llvm-compile-time-tracker.com/compare.php?from=b8b74945514358f1ebeac0874172f37fc7bfa38e&to=3c83bf05608d720d6ff88adfaca7191331eeb30f&stat=instructions:u

@nikic nikic requested review from kuhar and dwblaikie July 1, 2025 20:15
@llvmbot
Copy link
Member

llvmbot commented Jul 1, 2025

@llvm/pr-subscribers-mlir
@llvm/pr-subscribers-clang

@llvm/pr-subscribers-llvm-adt

Author: Nikita Popov (nikic)

Changes

DenseMapInfo for pointers currently uses empty/tombstone values that are aligned (by assuming a very conservative alignment). However, this means that we have to work with larger immediates.

This patch proposes to use the values -1 and -2 instead, without caring about pointer alignment. This puts us into unspecified territory from the perspective of the C standard, but general implementer consensus (including Clang) is that raw pointers do not carry alignment guarantees, only memory accesses do.

We already have lots of places that rely on this using variations on reinterpret_cast&lt;T*&gt;(-1), so it seems odd to insist on strict standard conformance in this one place.

This is a small improvement for both compile-time and clang binary size: https://llvm-compile-time-tracker.com/compare.php?from=b8b74945514358f1ebeac0874172f37fc7bfa38e&amp;to=3c83bf05608d720d6ff88adfaca7191331eeb30f&amp;stat=instructions:u


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

2 Files Affected:

  • (modified) llvm/include/llvm/ADT/DenseMapInfo.h (+4-21)
  • (modified) llvm/include/llvm/ADT/PointerUnion.h (+10-4)
diff --git a/llvm/include/llvm/ADT/DenseMapInfo.h b/llvm/include/llvm/ADT/DenseMapInfo.h
index 07c37e353a40b..b371611e7d948 100644
--- a/llvm/include/llvm/ADT/DenseMapInfo.h
+++ b/llvm/include/llvm/ADT/DenseMapInfo.h
@@ -56,30 +56,13 @@ struct DenseMapInfo {
   //static bool isEqual(const T &LHS, const T &RHS);
 };
 
-// Provide DenseMapInfo for all pointers. Come up with sentinel pointer values
-// that are aligned to alignof(T) bytes, but try to avoid requiring T to be
-// complete. This allows clients to instantiate DenseMap<T*, ...> with forward
-// declared key types. Assume that no pointer key type requires more than 4096
-// bytes of alignment.
-template<typename T>
-struct DenseMapInfo<T*> {
-  // The following should hold, but it would require T to be complete:
-  // static_assert(alignof(T) <= (1 << Log2MaxAlign),
-  //               "DenseMap does not support pointer keys requiring more than "
-  //               "Log2MaxAlign bits of alignment");
-  static constexpr uintptr_t Log2MaxAlign = 12;
-
+template <typename T> struct DenseMapInfo<T *> {
   static inline T* getEmptyKey() {
-    uintptr_t Val = static_cast<uintptr_t>(-1);
-    Val <<= Log2MaxAlign;
-    return reinterpret_cast<T*>(Val);
+    // We assume that raw pointers do not carry alignment requirements.
+    return reinterpret_cast<T *>(-1);
   }
 
-  static inline T* getTombstoneKey() {
-    uintptr_t Val = static_cast<uintptr_t>(-2);
-    Val <<= Log2MaxAlign;
-    return reinterpret_cast<T*>(Val);
-  }
+  static inline T *getTombstoneKey() { return reinterpret_cast<T *>(-2); }
 
   static unsigned getHashValue(const T *PtrVal) {
     return (unsigned((uintptr_t)PtrVal) >> 4) ^
diff --git a/llvm/include/llvm/ADT/PointerUnion.h b/llvm/include/llvm/ADT/PointerUnion.h
index cdbd76d7f505b..86248a2cf836f 100644
--- a/llvm/include/llvm/ADT/PointerUnion.h
+++ b/llvm/include/llvm/ADT/PointerUnion.h
@@ -286,13 +286,19 @@ struct PointerLikeTypeTraits<PointerUnion<PTs...>> {
 // Teach DenseMap how to use PointerUnions as keys.
 template <typename ...PTs> struct DenseMapInfo<PointerUnion<PTs...>> {
   using Union = PointerUnion<PTs...>;
-  using FirstInfo =
-      DenseMapInfo<typename pointer_union_detail::GetFirstType<PTs...>::type>;
+  using FirstTypeTraits = PointerLikeTypeTraits<
+      typename pointer_union_detail::GetFirstType<PTs...>::type>;
 
-  static inline Union getEmptyKey() { return Union(FirstInfo::getEmptyKey()); }
+  static inline Union getEmptyKey() {
+    uintptr_t Val = static_cast<uintptr_t>(-1);
+    Val <<= FirstTypeTraits::NumLowBitsAvailable;
+    return FirstTypeTraits::getFromVoidPointer(reinterpret_cast<void *>(Val));
+  }
 
   static inline Union getTombstoneKey() {
-    return Union(FirstInfo::getTombstoneKey());
+    uintptr_t Val = static_cast<uintptr_t>(-2);
+    Val <<= FirstTypeTraits::NumLowBitsAvailable;
+    return FirstTypeTraits::getFromVoidPointer(reinterpret_cast<void *>(Val));
   }
 
   static unsigned getHashValue(const Union &UnionVal) {

Copy link
Member

@kuhar kuhar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you know if this runs into issues with undefined behavior? I don't know the exact rules, but remember reading something along the lines that some OOB pointers cannot even be compared without running into UB. Having pointers that don't respect type alignment sounds like walking on thin ice to me...

@llvmbot llvmbot added clang Clang issues not falling into any other category clang:frontend Language frontend issues, e.g. anything involving "Sema" labels Jul 2, 2025
@nikic
Copy link
Contributor Author

nikic commented Jul 2, 2025

Do you know if this runs into issues with undefined behavior? I don't know the exact rules, but remember reading something along the lines that some OOB pointers cannot even be compared without running into UB. Having pointers that don't respect type alignment sounds like walking on thin ice to me...

I think the relevant parts are https://eel.is/c++draft/expr.eq#3 (which does not specify UB for equality comparisons) and https://eel.is/c++draft/expr.reinterpret.cast#5 (which makes all non-roundtrip integer to pointer reinterpret_casts implementation-defined.)

I think there are some more complexities here, but I think the gist is that as soon as we do a reinterpret_cast from an integer to a pointer we're in implementation-defined territory regardless of whether the resulting pointer is aligned or not.

@llvmbot llvmbot added mlir:core MLIR Core Infrastructure mlir labels Jul 2, 2025
Copy link
Member

@kuhar kuhar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SG

nikic added 3 commits July 7, 2025 09:27
DenseMapInfo for pointers currently uses empty/tombstone values
that are aligned (by assuming a very conservative alignment).
However, this means that we have to work with large immediates.

This patch proposed to use the values -1 and -2 instead, without
caring about pointer alignment. This puts us into unspecified
territory from the perspective of the C standard, but it is
Clang's explicit position that raw pointers do not carry alignment
guarantees (only accesses do).

We already have lots of places that do variations on
`reinterpret_cast<T*>(-1)` and assume that to work, so I'm not
sure it's worthwhile to be strictly standards conforming in this
single place.
@nikic nikic force-pushed the densemap-sentinels branch from 8687bd8 to a7d8fe3 Compare July 7, 2025 07:43
@nikic nikic merged commit 7a6435b into llvm:main Jul 7, 2025
9 checks passed
@nikic nikic deleted the densemap-sentinels branch July 7, 2025 10:47
@llvm-ci
Copy link
Collaborator

llvm-ci commented Jul 7, 2025

LLVM Buildbot has detected a new failure on builder sanitizer-x86_64-linux running on sanitizer-buildbot2 while building clang,llvm,mlir at step 2 "annotate".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/66/builds/16366

Here is the relevant piece of the build log for the reference
Step 2 (annotate) failure: 'python ../sanitizer_buildbot/sanitizers/zorg/buildbot/builders/sanitizers/buildbot_selector.py' (failure)
...
llvm-lit: /home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/lit.common.cfg.py:248: warning: COMPILER_RT_TEST_STANDALONE_BUILD_LIBS=ON, but this test suite does not support testing the just-built runtime libraries when the test compiler is configured to use different runtime libraries. Either modify this test suite to support this test configuration, or set COMPILER_RT_TEST_STANDALONE_BUILD_LIBS=OFF to test the runtime libraries included in the compiler instead.
llvm-lit: /home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/lit.common.cfg.py:259: note: Testing using libraries in "/home/b/sanitizer-x86_64-linux/build/build_default/./lib/../lib/clang/21/lib/i386-unknown-linux-gnu"
llvm-lit: /home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/lit.common.cfg.py:237: warning: Compiler lib dir != compiler-rt lib dir
Compiler libdir:     "/home/b/sanitizer-x86_64-linux/build/build_default/lib/clang/21/lib/i386-unknown-linux-gnu"
compiler-rt libdir:  "/home/b/sanitizer-x86_64-linux/build/build_default/lib/clang/21/lib/x86_64-unknown-linux-gnu"
llvm-lit: /home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/lit.common.cfg.py:248: warning: COMPILER_RT_TEST_STANDALONE_BUILD_LIBS=ON, but this test suite does not support testing the just-built runtime libraries when the test compiler is configured to use different runtime libraries. Either modify this test suite to support this test configuration, or set COMPILER_RT_TEST_STANDALONE_BUILD_LIBS=OFF to test the runtime libraries included in the compiler instead.
llvm-lit: /home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/lit.common.cfg.py:259: note: Testing using libraries in "/home/b/sanitizer-x86_64-linux/build/build_default/./lib/../lib/clang/21/lib/x86_64-unknown-linux-gnu"
llvm-lit: /home/b/sanitizer-x86_64-linux/build/llvm-project/llvm/utils/lit/lit/main.py:73: note: The test suite configuration requested an individual test timeout of 0 seconds but a timeout of 900 seconds was requested on the command line. Forcing timeout to be 900 seconds.
-- Testing: 11109 tests, 96 workers --
Testing:  0.. 10.. 20.. 
FAIL: LeakSanitizer-Standalone-i386 :: TestCases/leak_check_at_exit.cpp (3424 of 11109)
******************** TEST 'LeakSanitizer-Standalone-i386 :: TestCases/leak_check_at_exit.cpp' FAILED ********************
Exit Code: 1

Command Output (stderr):
--
/home/b/sanitizer-x86_64-linux/build/build_default/./bin/clang  --driver-mode=g++ -O0  -m32  -gline-tables-only -fsanitize=leak -I/home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/lsan/../ /home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/lsan/TestCases/leak_check_at_exit.cpp -o /home/b/sanitizer-x86_64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/lsan/I386LsanConfig/TestCases/Output/leak_check_at_exit.cpp.tmp # RUN: at line 2
+ /home/b/sanitizer-x86_64-linux/build/build_default/./bin/clang --driver-mode=g++ -O0 -m32 -gline-tables-only -fsanitize=leak -I/home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/lsan/../ /home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/lsan/TestCases/leak_check_at_exit.cpp -o /home/b/sanitizer-x86_64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/lsan/I386LsanConfig/TestCases/Output/leak_check_at_exit.cpp.tmp
env LSAN_OPTIONS=:detect_leaks=1:use_stacks=0:use_registers=0 not  /home/b/sanitizer-x86_64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/lsan/I386LsanConfig/TestCases/Output/leak_check_at_exit.cpp.tmp foo 2>&1 | FileCheck /home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/lsan/TestCases/leak_check_at_exit.cpp --check-prefix=CHECK-do # RUN: at line 3
+ env LSAN_OPTIONS=:detect_leaks=1:use_stacks=0:use_registers=0 not /home/b/sanitizer-x86_64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/lsan/I386LsanConfig/TestCases/Output/leak_check_at_exit.cpp.tmp foo
+ FileCheck /home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/lsan/TestCases/leak_check_at_exit.cpp --check-prefix=CHECK-do
env LSAN_OPTIONS=:detect_leaks=1:use_stacks=0:use_registers=0 not  /home/b/sanitizer-x86_64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/lsan/I386LsanConfig/TestCases/Output/leak_check_at_exit.cpp.tmp 2>&1 | FileCheck /home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/lsan/TestCases/leak_check_at_exit.cpp --check-prefix=CHECK-do # RUN: at line 4
+ env LSAN_OPTIONS=:detect_leaks=1:use_stacks=0:use_registers=0 not /home/b/sanitizer-x86_64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/lsan/I386LsanConfig/TestCases/Output/leak_check_at_exit.cpp.tmp
+ FileCheck /home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/lsan/TestCases/leak_check_at_exit.cpp --check-prefix=CHECK-do
env LSAN_OPTIONS=:detect_leaks=1:use_stacks=0:use_registers=0:leak_check_at_exit=0 not  /home/b/sanitizer-x86_64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/lsan/I386LsanConfig/TestCases/Output/leak_check_at_exit.cpp.tmp foo 2>&1 | FileCheck /home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/lsan/TestCases/leak_check_at_exit.cpp --check-prefix=CHECK-do # RUN: at line 5
+ env LSAN_OPTIONS=:detect_leaks=1:use_stacks=0:use_registers=0:leak_check_at_exit=0 not /home/b/sanitizer-x86_64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/lsan/I386LsanConfig/TestCases/Output/leak_check_at_exit.cpp.tmp foo
+ FileCheck /home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/lsan/TestCases/leak_check_at_exit.cpp --check-prefix=CHECK-do
/home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/lsan/TestCases/leak_check_at_exit.cpp:19:14: error: CHECK-do: expected string not found in input
// CHECK-do: SUMMARY: {{.*}}Sanitizer:
             ^
<stdin>:1:1: note: scanning from here
Test alloc: 0xe8403600.
^
<stdin>:1:4: note: possible intended match here
Test alloc: 0xe8403600.
   ^

Input file: <stdin>
Check file: /home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/lsan/TestCases/leak_check_at_exit.cpp

-dump-input=help explains the following input dump.

Input was:
<<<<<<
            1: Test alloc: 0xe8403600. 
check:19'0     X~~~~~~~~~~~~~~~~~~~~~~~ error: no match found
check:19'1        ?                     possible intended match
>>>>>>

Step 9 (test compiler-rt symbolizer) failure: test compiler-rt symbolizer (failure)
...
llvm-lit: /home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/lit.common.cfg.py:248: warning: COMPILER_RT_TEST_STANDALONE_BUILD_LIBS=ON, but this test suite does not support testing the just-built runtime libraries when the test compiler is configured to use different runtime libraries. Either modify this test suite to support this test configuration, or set COMPILER_RT_TEST_STANDALONE_BUILD_LIBS=OFF to test the runtime libraries included in the compiler instead.
llvm-lit: /home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/lit.common.cfg.py:259: note: Testing using libraries in "/home/b/sanitizer-x86_64-linux/build/build_default/./lib/../lib/clang/21/lib/i386-unknown-linux-gnu"
llvm-lit: /home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/lit.common.cfg.py:237: warning: Compiler lib dir != compiler-rt lib dir
Compiler libdir:     "/home/b/sanitizer-x86_64-linux/build/build_default/lib/clang/21/lib/i386-unknown-linux-gnu"
compiler-rt libdir:  "/home/b/sanitizer-x86_64-linux/build/build_default/lib/clang/21/lib/x86_64-unknown-linux-gnu"
llvm-lit: /home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/lit.common.cfg.py:248: warning: COMPILER_RT_TEST_STANDALONE_BUILD_LIBS=ON, but this test suite does not support testing the just-built runtime libraries when the test compiler is configured to use different runtime libraries. Either modify this test suite to support this test configuration, or set COMPILER_RT_TEST_STANDALONE_BUILD_LIBS=OFF to test the runtime libraries included in the compiler instead.
llvm-lit: /home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/lit.common.cfg.py:259: note: Testing using libraries in "/home/b/sanitizer-x86_64-linux/build/build_default/./lib/../lib/clang/21/lib/x86_64-unknown-linux-gnu"
llvm-lit: /home/b/sanitizer-x86_64-linux/build/llvm-project/llvm/utils/lit/lit/main.py:73: note: The test suite configuration requested an individual test timeout of 0 seconds but a timeout of 900 seconds was requested on the command line. Forcing timeout to be 900 seconds.
-- Testing: 11109 tests, 96 workers --
Testing:  0.. 10.. 20.. 
FAIL: LeakSanitizer-Standalone-i386 :: TestCases/leak_check_at_exit.cpp (3424 of 11109)
******************** TEST 'LeakSanitizer-Standalone-i386 :: TestCases/leak_check_at_exit.cpp' FAILED ********************
Exit Code: 1

Command Output (stderr):
--
/home/b/sanitizer-x86_64-linux/build/build_default/./bin/clang  --driver-mode=g++ -O0  -m32  -gline-tables-only -fsanitize=leak -I/home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/lsan/../ /home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/lsan/TestCases/leak_check_at_exit.cpp -o /home/b/sanitizer-x86_64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/lsan/I386LsanConfig/TestCases/Output/leak_check_at_exit.cpp.tmp # RUN: at line 2
+ /home/b/sanitizer-x86_64-linux/build/build_default/./bin/clang --driver-mode=g++ -O0 -m32 -gline-tables-only -fsanitize=leak -I/home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/lsan/../ /home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/lsan/TestCases/leak_check_at_exit.cpp -o /home/b/sanitizer-x86_64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/lsan/I386LsanConfig/TestCases/Output/leak_check_at_exit.cpp.tmp
env LSAN_OPTIONS=:detect_leaks=1:use_stacks=0:use_registers=0 not  /home/b/sanitizer-x86_64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/lsan/I386LsanConfig/TestCases/Output/leak_check_at_exit.cpp.tmp foo 2>&1 | FileCheck /home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/lsan/TestCases/leak_check_at_exit.cpp --check-prefix=CHECK-do # RUN: at line 3
+ env LSAN_OPTIONS=:detect_leaks=1:use_stacks=0:use_registers=0 not /home/b/sanitizer-x86_64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/lsan/I386LsanConfig/TestCases/Output/leak_check_at_exit.cpp.tmp foo
+ FileCheck /home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/lsan/TestCases/leak_check_at_exit.cpp --check-prefix=CHECK-do
env LSAN_OPTIONS=:detect_leaks=1:use_stacks=0:use_registers=0 not  /home/b/sanitizer-x86_64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/lsan/I386LsanConfig/TestCases/Output/leak_check_at_exit.cpp.tmp 2>&1 | FileCheck /home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/lsan/TestCases/leak_check_at_exit.cpp --check-prefix=CHECK-do # RUN: at line 4
+ env LSAN_OPTIONS=:detect_leaks=1:use_stacks=0:use_registers=0 not /home/b/sanitizer-x86_64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/lsan/I386LsanConfig/TestCases/Output/leak_check_at_exit.cpp.tmp
+ FileCheck /home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/lsan/TestCases/leak_check_at_exit.cpp --check-prefix=CHECK-do
env LSAN_OPTIONS=:detect_leaks=1:use_stacks=0:use_registers=0:leak_check_at_exit=0 not  /home/b/sanitizer-x86_64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/lsan/I386LsanConfig/TestCases/Output/leak_check_at_exit.cpp.tmp foo 2>&1 | FileCheck /home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/lsan/TestCases/leak_check_at_exit.cpp --check-prefix=CHECK-do # RUN: at line 5
+ env LSAN_OPTIONS=:detect_leaks=1:use_stacks=0:use_registers=0:leak_check_at_exit=0 not /home/b/sanitizer-x86_64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/lsan/I386LsanConfig/TestCases/Output/leak_check_at_exit.cpp.tmp foo
+ FileCheck /home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/lsan/TestCases/leak_check_at_exit.cpp --check-prefix=CHECK-do
/home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/lsan/TestCases/leak_check_at_exit.cpp:19:14: error: CHECK-do: expected string not found in input
// CHECK-do: SUMMARY: {{.*}}Sanitizer:
             ^
<stdin>:1:1: note: scanning from here
Test alloc: 0xe8403600.
^
<stdin>:1:4: note: possible intended match here
Test alloc: 0xe8403600.
   ^

Input file: <stdin>
Check file: /home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/lsan/TestCases/leak_check_at_exit.cpp

-dump-input=help explains the following input dump.

Input was:
<<<<<<
            1: Test alloc: 0xe8403600. 
check:19'0     X~~~~~~~~~~~~~~~~~~~~~~~ error: no match found
check:19'1        ?                     possible intended match
>>>>>>


@llvm-ci
Copy link
Collaborator

llvm-ci commented Jul 7, 2025

LLVM Buildbot has detected a new failure on builder sanitizer-x86_64-linux-fast running on sanitizer-buildbot4 while building clang,llvm,mlir at step 2 "annotate".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/169/builds/12913

Here is the relevant piece of the build log for the reference
Step 2 (annotate) failure: 'python ../sanitizer_buildbot/sanitizers/zorg/buildbot/builders/sanitizers/buildbot_selector.py' (failure)
...
llvm-lit: /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:520: note: using lld-link: /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/lld-link
llvm-lit: /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:520: note: using ld64.lld: /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/ld64.lld
llvm-lit: /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:520: note: using wasm-ld: /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/wasm-ld
llvm-lit: /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:520: note: using ld.lld: /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/ld.lld
llvm-lit: /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:520: note: using lld-link: /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/lld-link
llvm-lit: /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:520: note: using ld64.lld: /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/ld64.lld
llvm-lit: /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:520: note: using wasm-ld: /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/wasm-ld
llvm-lit: /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/main.py:73: note: The test suite configuration requested an individual test timeout of 0 seconds but a timeout of 900 seconds was requested on the command line. Forcing timeout to be 900 seconds.
-- Testing: 91041 tests, 96 workers --
Testing: 
FAIL: LLVM :: CodeGen/AMDGPU/global_atomics_scan_fsub.ll (1 of 91041)
******************** TEST 'LLVM :: CodeGen/AMDGPU/global_atomics_scan_fsub.ll' FAILED ********************
Exit Code: 2

Command Output (stderr):
--
/home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/llc -mtriple=amdgcn -amdgpu-atomic-optimizer-strategy=Iterative -verify-machineinstrs < /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/test/CodeGen/AMDGPU/global_atomics_scan_fsub.ll | /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/FileCheck -enable-var-scope -check-prefix=GFX7LESS /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/test/CodeGen/AMDGPU/global_atomics_scan_fsub.ll # RUN: at line 2
+ /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/llc -mtriple=amdgcn -amdgpu-atomic-optimizer-strategy=Iterative -verify-machineinstrs
+ /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/FileCheck -enable-var-scope -check-prefix=GFX7LESS /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/test/CodeGen/AMDGPU/global_atomics_scan_fsub.ll
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.	Program arguments: /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/llc -mtriple=amdgcn -amdgpu-atomic-optimizer-strategy=Iterative -verify-machineinstrs
1.	Running pass 'Function Pass Manager' on module '<stdin>'.
2.	Running pass 'Block Frequency Analysis' on function '@global_atomic_fsub_uni_address_uni_value_agent_scope_unsafe'
 #0 0x00006471b2a47bf6 ___interceptor_backtrace /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/compiler-rt/lib/asan/../sanitizer_common/sanitizer_common_interceptors.inc:4497:13
 #1 0x00006471babe68a8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/lib/Support/Unix/Signals.inc:819:13
 #2 0x00006471babe0509 llvm::sys::RunSignalHandlers() /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/lib/Support/Signals.cpp:0:5
 #3 0x00006471babe87a7 SignalHandler(int, siginfo_t*, void*) /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/lib/Support/Unix/Signals.inc:0:3
 #4 0x000079343ae45250 (/lib/x86_64-linux-gnu/libc.so.6+0x45250)
 #5 0x000079343aea3f1c pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0xa3f1c)
 #6 0x000079343ae4519e raise (/lib/x86_64-linux-gnu/libc.so.6+0x4519e)
 #7 0x000079343ae28902 abort (/lib/x86_64-linux-gnu/libc.so.6+0x28902)
 #8 0x00006471b2aca5ac (/home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/llc+0xbd7d5ac)
 #9 0x00006471b2ac83de __sanitizer::Die() /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_termination.cpp:52:5
#10 0x00006471b2ae0a69 (/home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/llc+0xbd93a69)
#11 0x00006471b71484d2 llvm::DenseMap<llvm::AssertingVH<llvm::BasicBlock const>, std::__1::pair<llvm::BlockFrequencyInfoImplBase::BlockNode, llvm::bfi_detail::BFICallbackVH<llvm::BasicBlock, llvm::BlockFrequencyInfoImpl<llvm::BasicBlock>>>, llvm::DenseMapInfo<llvm::AssertingVH<llvm::BasicBlock const>, void>, llvm::detail::DenseMapPair<llvm::AssertingVH<llvm::BasicBlock const>, std::__1::pair<llvm::BlockFrequencyInfoImplBase::BlockNode, llvm::bfi_detail::BFICallbackVH<llvm::BasicBlock, llvm::BlockFrequencyInfoImpl<llvm::BasicBlock>>>>>::grow(unsigned int) /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/include/llvm/ADT/DenseMap.h:0:0
#12 0x00006471b7148259 getNumBuckets /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/include/llvm/ADT/DenseMap.h:903:43
#13 0x00006471b7148259 getNumBuckets /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/include/llvm/ADT/DenseMap.h:578:49
#14 0x00006471b7148259 LookupBucketFor<llvm::AssertingVH<const llvm::BasicBlock> > /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/include/llvm/ADT/DenseMap.h:685:33
#15 0x00006471b7148259 llvm::detail::DenseMapPair<llvm::AssertingVH<llvm::BasicBlock const>, std::__1::pair<llvm::BlockFrequencyInfoImplBase::BlockNode, llvm::bfi_detail::BFICallbackVH<llvm::BasicBlock, llvm::BlockFrequencyInfoImpl<llvm::BasicBlock>>>>* llvm::DenseMapBase<llvm::DenseMap<llvm::AssertingVH<llvm::BasicBlock const>, std::__1::pair<llvm::BlockFrequencyInfoImplBase::BlockNode, llvm::bfi_detail::BFICallbackVH<llvm::BasicBlock, llvm::BlockFrequencyInfoImpl<llvm::BasicBlock>>>, llvm::DenseMapInfo<llvm::AssertingVH<llvm::BasicBlock const>, void>, llvm::detail::DenseMapPair<llvm::AssertingVH<llvm::BasicBlock const>, std::__1::pair<llvm::BlockFrequencyInfoImplBase::BlockNode, llvm::bfi_detail::BFICallbackVH<llvm::BasicBlock, llvm::BlockFrequencyInfoImpl<llvm::BasicBlock>>>>>, llvm::AssertingVH<llvm::BasicBlock const>, std::__1::pair<llvm::BlockFrequencyInfoImplBase::BlockNode, llvm::bfi_detail::BFICallbackVH<llvm::BasicBlock, llvm::BlockFrequencyInfoImpl<llvm::BasicBlock>>>, llvm::DenseMapInfo<llvm::AssertingVH<llvm::BasicBlock const>, void>, llvm::detail::DenseMapPair<llvm::AssertingVH<llvm::BasicBlock const>, std::__1::pair<llvm::BlockFrequencyInfoImplBase::BlockNode, llvm::bfi_detail::BFICallbackVH<llvm::BasicBlock, llvm::BlockFrequencyInfoImpl<llvm::BasicBlock>>>>>::InsertIntoBucketImpl<llvm::AssertingVH<llvm::BasicBlock const>>(llvm::AssertingVH<llvm::BasicBlock const> const&, llvm::detail::DenseMapPair<llvm::AssertingVH<llvm::BasicBlock const>, std::__1::pair<llvm::BlockFrequencyInfoImplBase::BlockNode, llvm::bfi_detail::BFICallbackVH<llvm::BasicBlock, llvm::BlockFrequencyInfoImpl<llvm::BasicBlock>>>>*) /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/include/llvm/ADT/DenseMap.h:628:7
#16 0x00006471b7147f79 llvm::detail::DenseMapPair<llvm::AssertingVH<llvm::BasicBlock const>, std::__1::pair<llvm::BlockFrequencyInfoImplBase::BlockNode, llvm::bfi_detail::BFICallbackVH<llvm::BasicBlock, llvm::BlockFrequencyInfoImpl<llvm::BasicBlock>>>>* llvm::DenseMapBase<llvm::DenseMap<llvm::AssertingVH<llvm::BasicBlock const>, std::__1::pair<llvm::BlockFrequencyInfoImplBase::BlockNode, llvm::bfi_detail::BFICallbackVH<llvm::BasicBlock, llvm::BlockFrequencyInfoImpl<llvm::BasicBlock>>>, llvm::DenseMapInfo<llvm::AssertingVH<llvm::BasicBlock const>, void>, llvm::detail::DenseMapPair<llvm::AssertingVH<llvm::BasicBlock const>, std::__1::pair<llvm::BlockFrequencyInfoImplBase::BlockNode, llvm::bfi_detail::BFICallbackVH<llvm::BasicBlock, llvm::BlockFrequencyInfoImpl<llvm::BasicBlock>>>>>, llvm::AssertingVH<llvm::BasicBlock const>, std::__1::pair<llvm::BlockFrequencyInfoImplBase::BlockNode, llvm::bfi_detail::BFICallbackVH<llvm::BasicBlock, llvm::BlockFrequencyInfoImpl<llvm::BasicBlock>>>, llvm::DenseMapInfo<llvm::AssertingVH<llvm::BasicBlock const>, void>, llvm::detail::DenseMapPair<llvm::AssertingVH<llvm::BasicBlock const>, std::__1::pair<llvm::BlockFrequencyInfoImplBase::BlockNode, llvm::bfi_detail::BFICallbackVH<llvm::BasicBlock, llvm::BlockFrequencyInfoImpl<llvm::BasicBlock>>>>>::InsertIntoBucket<llvm::AssertingVH<llvm::BasicBlock const>>(llvm::detail::DenseMapPair<llvm::AssertingVH<llvm::BasicBlock const>, std::__1::pair<llvm::BlockFrequencyInfoImplBase::BlockNode, llvm::bfi_detail::BFICallbackVH<llvm::BasicBlock, llvm::BlockFrequencyInfoImpl<llvm::BasicBlock>>>>*, llvm::AssertingVH<llvm::BasicBlock const>&&) /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/include/llvm/ADT/DenseMap.h:594:17
#17 0x00006471b713e945 operator[] /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/include/llvm/ADT/DenseMap.h:404:57
#18 0x00006471b713e945 llvm::BlockFrequencyInfoImpl<llvm::BasicBlock>::initializeRPOT() /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/include/llvm/Analysis/BlockFrequencyInfoImpl.h:1168:5
#19 0x00006471b713152c llvm::BlockFrequencyInfoImpl<llvm::BasicBlock>::calculate(llvm::Function const&, llvm::BranchProbabilityInfo const&, llvm::LoopInfo const&) /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/include/llvm/Analysis/BlockFrequencyInfoImpl.h:1114:3
#20 0x00006471b71302ca getValue /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/include/llvm/Support/CommandLine.h:1412:38
#21 0x00006471b71302ca operator llvm::GVDAGType /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/include/llvm/Support/CommandLine.h:1416:38
#22 0x00006471b71302ca llvm::BlockFrequencyInfo::calculate(llvm::Function const&, llvm::BranchProbabilityInfo const&, llvm::LoopInfo const&) /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/lib/Analysis/BlockFrequencyInfo.cpp:190:7
#23 0x00006471b7135def llvm::BlockFrequencyInfoWrapperPass::runOnFunction(llvm::Function&) /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/lib/Analysis/BlockFrequencyInfo.cpp:327:3
#24 0x00006471b9027793 llvm::FPPassManager::runOnFunction(llvm::Function&) /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:0:27
Step 10 (stage2/asan_ubsan check) failure: stage2/asan_ubsan check (failure)
...
llvm-lit: /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:520: note: using lld-link: /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/lld-link
llvm-lit: /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:520: note: using ld64.lld: /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/ld64.lld
llvm-lit: /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:520: note: using wasm-ld: /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/wasm-ld
llvm-lit: /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:520: note: using ld.lld: /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/ld.lld
llvm-lit: /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:520: note: using lld-link: /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/lld-link
llvm-lit: /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:520: note: using ld64.lld: /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/ld64.lld
llvm-lit: /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:520: note: using wasm-ld: /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/wasm-ld
llvm-lit: /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/main.py:73: note: The test suite configuration requested an individual test timeout of 0 seconds but a timeout of 900 seconds was requested on the command line. Forcing timeout to be 900 seconds.
-- Testing: 91041 tests, 96 workers --
Testing: 
FAIL: LLVM :: CodeGen/AMDGPU/global_atomics_scan_fsub.ll (1 of 91041)
******************** TEST 'LLVM :: CodeGen/AMDGPU/global_atomics_scan_fsub.ll' FAILED ********************
Exit Code: 2

Command Output (stderr):
--
/home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/llc -mtriple=amdgcn -amdgpu-atomic-optimizer-strategy=Iterative -verify-machineinstrs < /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/test/CodeGen/AMDGPU/global_atomics_scan_fsub.ll | /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/FileCheck -enable-var-scope -check-prefix=GFX7LESS /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/test/CodeGen/AMDGPU/global_atomics_scan_fsub.ll # RUN: at line 2
+ /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/llc -mtriple=amdgcn -amdgpu-atomic-optimizer-strategy=Iterative -verify-machineinstrs
+ /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/FileCheck -enable-var-scope -check-prefix=GFX7LESS /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/test/CodeGen/AMDGPU/global_atomics_scan_fsub.ll
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.	Program arguments: /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/llc -mtriple=amdgcn -amdgpu-atomic-optimizer-strategy=Iterative -verify-machineinstrs
1.	Running pass 'Function Pass Manager' on module '<stdin>'.
2.	Running pass 'Block Frequency Analysis' on function '@global_atomic_fsub_uni_address_uni_value_agent_scope_unsafe'
 #0 0x00006471b2a47bf6 ___interceptor_backtrace /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/compiler-rt/lib/asan/../sanitizer_common/sanitizer_common_interceptors.inc:4497:13
 #1 0x00006471babe68a8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/lib/Support/Unix/Signals.inc:819:13
 #2 0x00006471babe0509 llvm::sys::RunSignalHandlers() /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/lib/Support/Signals.cpp:0:5
 #3 0x00006471babe87a7 SignalHandler(int, siginfo_t*, void*) /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/lib/Support/Unix/Signals.inc:0:3
 #4 0x000079343ae45250 (/lib/x86_64-linux-gnu/libc.so.6+0x45250)
 #5 0x000079343aea3f1c pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0xa3f1c)
 #6 0x000079343ae4519e raise (/lib/x86_64-linux-gnu/libc.so.6+0x4519e)
 #7 0x000079343ae28902 abort (/lib/x86_64-linux-gnu/libc.so.6+0x28902)
 #8 0x00006471b2aca5ac (/home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/llc+0xbd7d5ac)
 #9 0x00006471b2ac83de __sanitizer::Die() /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_termination.cpp:52:5
#10 0x00006471b2ae0a69 (/home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/llc+0xbd93a69)
#11 0x00006471b71484d2 llvm::DenseMap<llvm::AssertingVH<llvm::BasicBlock const>, std::__1::pair<llvm::BlockFrequencyInfoImplBase::BlockNode, llvm::bfi_detail::BFICallbackVH<llvm::BasicBlock, llvm::BlockFrequencyInfoImpl<llvm::BasicBlock>>>, llvm::DenseMapInfo<llvm::AssertingVH<llvm::BasicBlock const>, void>, llvm::detail::DenseMapPair<llvm::AssertingVH<llvm::BasicBlock const>, std::__1::pair<llvm::BlockFrequencyInfoImplBase::BlockNode, llvm::bfi_detail::BFICallbackVH<llvm::BasicBlock, llvm::BlockFrequencyInfoImpl<llvm::BasicBlock>>>>>::grow(unsigned int) /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/include/llvm/ADT/DenseMap.h:0:0
#12 0x00006471b7148259 getNumBuckets /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/include/llvm/ADT/DenseMap.h:903:43
#13 0x00006471b7148259 getNumBuckets /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/include/llvm/ADT/DenseMap.h:578:49
#14 0x00006471b7148259 LookupBucketFor<llvm::AssertingVH<const llvm::BasicBlock> > /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/include/llvm/ADT/DenseMap.h:685:33
#15 0x00006471b7148259 llvm::detail::DenseMapPair<llvm::AssertingVH<llvm::BasicBlock const>, std::__1::pair<llvm::BlockFrequencyInfoImplBase::BlockNode, llvm::bfi_detail::BFICallbackVH<llvm::BasicBlock, llvm::BlockFrequencyInfoImpl<llvm::BasicBlock>>>>* llvm::DenseMapBase<llvm::DenseMap<llvm::AssertingVH<llvm::BasicBlock const>, std::__1::pair<llvm::BlockFrequencyInfoImplBase::BlockNode, llvm::bfi_detail::BFICallbackVH<llvm::BasicBlock, llvm::BlockFrequencyInfoImpl<llvm::BasicBlock>>>, llvm::DenseMapInfo<llvm::AssertingVH<llvm::BasicBlock const>, void>, llvm::detail::DenseMapPair<llvm::AssertingVH<llvm::BasicBlock const>, std::__1::pair<llvm::BlockFrequencyInfoImplBase::BlockNode, llvm::bfi_detail::BFICallbackVH<llvm::BasicBlock, llvm::BlockFrequencyInfoImpl<llvm::BasicBlock>>>>>, llvm::AssertingVH<llvm::BasicBlock const>, std::__1::pair<llvm::BlockFrequencyInfoImplBase::BlockNode, llvm::bfi_detail::BFICallbackVH<llvm::BasicBlock, llvm::BlockFrequencyInfoImpl<llvm::BasicBlock>>>, llvm::DenseMapInfo<llvm::AssertingVH<llvm::BasicBlock const>, void>, llvm::detail::DenseMapPair<llvm::AssertingVH<llvm::BasicBlock const>, std::__1::pair<llvm::BlockFrequencyInfoImplBase::BlockNode, llvm::bfi_detail::BFICallbackVH<llvm::BasicBlock, llvm::BlockFrequencyInfoImpl<llvm::BasicBlock>>>>>::InsertIntoBucketImpl<llvm::AssertingVH<llvm::BasicBlock const>>(llvm::AssertingVH<llvm::BasicBlock const> const&, llvm::detail::DenseMapPair<llvm::AssertingVH<llvm::BasicBlock const>, std::__1::pair<llvm::BlockFrequencyInfoImplBase::BlockNode, llvm::bfi_detail::BFICallbackVH<llvm::BasicBlock, llvm::BlockFrequencyInfoImpl<llvm::BasicBlock>>>>*) /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/include/llvm/ADT/DenseMap.h:628:7
#16 0x00006471b7147f79 llvm::detail::DenseMapPair<llvm::AssertingVH<llvm::BasicBlock const>, std::__1::pair<llvm::BlockFrequencyInfoImplBase::BlockNode, llvm::bfi_detail::BFICallbackVH<llvm::BasicBlock, llvm::BlockFrequencyInfoImpl<llvm::BasicBlock>>>>* llvm::DenseMapBase<llvm::DenseMap<llvm::AssertingVH<llvm::BasicBlock const>, std::__1::pair<llvm::BlockFrequencyInfoImplBase::BlockNode, llvm::bfi_detail::BFICallbackVH<llvm::BasicBlock, llvm::BlockFrequencyInfoImpl<llvm::BasicBlock>>>, llvm::DenseMapInfo<llvm::AssertingVH<llvm::BasicBlock const>, void>, llvm::detail::DenseMapPair<llvm::AssertingVH<llvm::BasicBlock const>, std::__1::pair<llvm::BlockFrequencyInfoImplBase::BlockNode, llvm::bfi_detail::BFICallbackVH<llvm::BasicBlock, llvm::BlockFrequencyInfoImpl<llvm::BasicBlock>>>>>, llvm::AssertingVH<llvm::BasicBlock const>, std::__1::pair<llvm::BlockFrequencyInfoImplBase::BlockNode, llvm::bfi_detail::BFICallbackVH<llvm::BasicBlock, llvm::BlockFrequencyInfoImpl<llvm::BasicBlock>>>, llvm::DenseMapInfo<llvm::AssertingVH<llvm::BasicBlock const>, void>, llvm::detail::DenseMapPair<llvm::AssertingVH<llvm::BasicBlock const>, std::__1::pair<llvm::BlockFrequencyInfoImplBase::BlockNode, llvm::bfi_detail::BFICallbackVH<llvm::BasicBlock, llvm::BlockFrequencyInfoImpl<llvm::BasicBlock>>>>>::InsertIntoBucket<llvm::AssertingVH<llvm::BasicBlock const>>(llvm::detail::DenseMapPair<llvm::AssertingVH<llvm::BasicBlock const>, std::__1::pair<llvm::BlockFrequencyInfoImplBase::BlockNode, llvm::bfi_detail::BFICallbackVH<llvm::BasicBlock, llvm::BlockFrequencyInfoImpl<llvm::BasicBlock>>>>*, llvm::AssertingVH<llvm::BasicBlock const>&&) /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/include/llvm/ADT/DenseMap.h:594:17
#17 0x00006471b713e945 operator[] /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/include/llvm/ADT/DenseMap.h:404:57
#18 0x00006471b713e945 llvm::BlockFrequencyInfoImpl<llvm::BasicBlock>::initializeRPOT() /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/include/llvm/Analysis/BlockFrequencyInfoImpl.h:1168:5
#19 0x00006471b713152c llvm::BlockFrequencyInfoImpl<llvm::BasicBlock>::calculate(llvm::Function const&, llvm::BranchProbabilityInfo const&, llvm::LoopInfo const&) /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/include/llvm/Analysis/BlockFrequencyInfoImpl.h:1114:3
#20 0x00006471b71302ca getValue /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/include/llvm/Support/CommandLine.h:1412:38
#21 0x00006471b71302ca operator llvm::GVDAGType /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/include/llvm/Support/CommandLine.h:1416:38
#22 0x00006471b71302ca llvm::BlockFrequencyInfo::calculate(llvm::Function const&, llvm::BranchProbabilityInfo const&, llvm::LoopInfo const&) /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/lib/Analysis/BlockFrequencyInfo.cpp:190:7
#23 0x00006471b7135def llvm::BlockFrequencyInfoWrapperPass::runOnFunction(llvm::Function&) /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/lib/Analysis/BlockFrequencyInfo.cpp:327:3
#24 0x00006471b9027793 llvm::FPPassManager::runOnFunction(llvm::Function&) /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:0:27

nikic added a commit that referenced this pull request Jul 7, 2025
This reverts commit 7a6435b.

This causes ubsan failures when the sentinel pointers are upcast
using static_cast<>, which checks alignment.
@nikic
Copy link
Contributor Author

nikic commented Jul 7, 2025

Reverted this due to ubsan errors like:

/home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/include/llvm/IR/ValueHandle.h:286:64: runtime error: upcast of misaligned address 0xffffffffffffffff for type 'llvm::BasicBlock', which requires 8 byte alignment

The problem is basically code like this:

class Foo {
    unsigned x;
};

class Bar : public Foo {};

Bar *test(Foo *ptr) {
    return static_cast<Bar *>(reinterpret_cast<Foo *>(-1));
}

Where ubsan doesn't like the static_cast.

While DenseMap itself doesn't need the aligned pointers, it seems like too many other places end up depending on this.

@kuhar
Copy link
Member

kuhar commented Jul 7, 2025

Good catch, now we have an example of what I suspected might be an issue in #146595 (review)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema" clang Clang issues not falling into any other category llvm:adt mlir:core MLIR Core Infrastructure mlir
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants