[llvm] [llvm][GlobalOpt] Remove empty atexit destructors/handlers (PR #88836)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 25 21:44:27 PDT 2024
================
@@ -0,0 +1,25 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 4
+; RUN: opt < %s -S -passes=globalopt | FileCheck %s
+
+declare dso_local i32 @atexit(ptr)
+
+define dso_local void @atexit_handler() {
+; CHECK-LABEL: define dso_local void @atexit_handler() local_unnamed_addr {
+; CHECK-NEXT: ret void
+;
+ ret void
+}
+
+; Check that `atexit` is removed if the handler is empty.
+; Check that a removed `atexit` call returns `0` which is the value that denotes success.
+define dso_local noundef i32 @register_atexit_handler() {
+; CHECK-LABEL: define dso_local noundef i32 @register_atexit_handler() local_unnamed_addr {
+; CHECK-NEXT: [[TMP1:%.*]] = alloca i32, align 4
+; CHECK-NEXT: store i32 0, ptr [[TMP1]], align 4
+; CHECK-NEXT: ret i32 0
+;
+ %1 = alloca i32, align 4
+ store i32 0, ptr %1, align 4
----------------
nikic wrote:
Can drop the alloca and store? They don't look related...
https://github.com/llvm/llvm-project/pull/88836
More information about the llvm-commits
mailing list