diff options
author | Max Winkler <max.enrico.winkler@gmail.com> | 2024-04-29 20:29:34 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-29 20:29:34 -0400 |
commit | ce3485a0cd12b45c725f008a7836e71a1d72df49 (patch) | |
tree | 30db0c5838e6be22022ef52ba6f7547c8aa00e67 /llvm/unittests/Analysis/TargetLibraryInfoTest.cpp | |
parent | 6566ffdf8a543f50b75e9b3c66d771a3a9eb1560 (diff) | |
download | llvm-ce3485a0cd12b45c725f008a7836e71a1d72df49.zip llvm-ce3485a0cd12b45c725f008a7836e71a1d72df49.tar.gz llvm-ce3485a0cd12b45c725f008a7836e71a1d72df49.tar.bz2 |
[llvm][GlobalOpt] Remove empty atexit destructors/handlers (#88836)
https://godbolt.org/z/frjhqMKqc for an example.
Removal of allocations due to empty `__cxa_atexit` destructor calls is
done by the following globalopt pass.
This pass currently does not look for `atexit` handlers generated for
platforms that do not use `__cxa_atexit`.
By default Win32 and AIX use `atexit`.
I don't see an easy way to only remove `atexit` calls that the compiler
generated without looking at the generated mangled name of the atexit
handler that is being registered.
However we can easily remove all `atexit` calls that register empty
handlers since it is trivial to ensure the removed call still returns
`0` which is the value for success.
Diffstat (limited to 'llvm/unittests/Analysis/TargetLibraryInfoTest.cpp')
-rw-r--r-- | llvm/unittests/Analysis/TargetLibraryInfoTest.cpp | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/llvm/unittests/Analysis/TargetLibraryInfoTest.cpp b/llvm/unittests/Analysis/TargetLibraryInfoTest.cpp index 8e3fe3b..1fe94e2 100644 --- a/llvm/unittests/Analysis/TargetLibraryInfoTest.cpp +++ b/llvm/unittests/Analysis/TargetLibraryInfoTest.cpp @@ -495,6 +495,8 @@ TEST_F(TargetLibraryInfoTest, ValidProto) { "declare i32 @__cxa_guard_acquire(%struct*)\n" "declare void @__cxa_guard_release(%struct*)\n" + "declare i32 @atexit(void ()*)\n" + "declare i32 @__nvvm_reflect(i8*)\n" "declare i8* @__memcpy_chk(i8*, i8*, i64, i64)\n" |