[llvm] [llvm][GlobalOpt] Remove empty atexit destructors/handlers (PR #88836)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 24 20:11:18 PDT 2024


================
@@ -2340,17 +2343,27 @@ FindCXAAtExit(Module &M, function_ref<TargetLibraryInfo &(Function &)> GetTLI) {
   TLI = &GetTLI(*Fn);
 
   // Make sure that the function has the correct prototype.
-  if (!TLI->getLibFunc(*Fn, F) || F != LibFunc_cxa_atexit)
+  if (!TLI->getLibFunc(*Fn, F) || F != Func)
     return nullptr;
 
   return Fn;
 }
 
-/// Returns whether the given function is an empty C++ destructor and can
-/// therefore be eliminated.
-/// Note that we assume that other optimization passes have already simplified
-/// the code so we simply check for 'ret'.
-static bool cxxDtorIsEmpty(const Function &Fn) {
+static Function *
+FindCXAAtExit(Module &M, function_ref<TargetLibraryInfo &(Function &)> GetTLI) {
+  return FindAtExitLibFunc(M, GetTLI, LibFunc_cxa_atexit);
+}
+
+static Function *
+FindAtExit(Module &M, function_ref<TargetLibraryInfo &(Function &)> GetTLI) {
+  return FindAtExitLibFunc(M, GetTLI, LibFunc_atexit);
+}
----------------
nikic wrote:

These two wrapper functions look unnecessary, given how they are only used once.

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


More information about the llvm-commits mailing list