[compiler-rt] [AIX][PGO] Handle atexit functions when dlclose'ing shared libraries (PR #102940)

Wael Yehia via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 28 11:09:12 PDT 2024


================
@@ -1259,7 +1259,7 @@ int __llvm_profile_register_write_file_atexit(void) {
   lprofSetupValueProfiler();
 
   HasBeenRegistered = 1;
-  return atexit(writeFileWithoutReturn);
+  return lprofAtExit(writeFileWithoutReturn);
----------------
w2yehia wrote:

True. I left it as is because it's existing code, so I'm not regressing anything. A big chunk of the profile runtime's state is not thread safe (for example the part that's initialized by `__llvm_profile_initialize`). 

The reason the stack was made thread safe is because POSIX `atexit` is thread-safe.
The current uses (2 instances) of `lprofAtExit` do not need to be thread safe AFAICT, but we decided to future-proof it.

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


More information about the llvm-commits mailing list