brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.9 KiB · bf78fd3 Raw
55 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 42; RUN: opt < %s -S -passes=globalopt | FileCheck %s3 4declare dso_local i32 @atexit(ptr)5 6define dso_local void @empty_atexit_handler() {7; CHECK-LABEL: define dso_local void @empty_atexit_handler() local_unnamed_addr {8; CHECK-NEXT:    ret void9;10  ret void11}12 13; Check that `atexit` is removed if the handler is empty.14; Check that a removed `atexit` call returns `0` which is the value that denotes success.15define dso_local noundef i32 @register_atexit_handler() {16; CHECK-LABEL: define dso_local noundef i32 @register_atexit_handler() local_unnamed_addr {17; CHECK-NEXT:    ret i32 018;19  %1 = call i32 @atexit(ptr @empty_atexit_handler)20  ret i32 %121}22 23declare dso_local void @declared_atexit_handler()24 25; Check that an atexit handler with only a declaration is not removed.26define dso_local noundef i32 @register_declared_atexit_handler() {27; CHECK-LABEL: define dso_local noundef i32 @register_declared_atexit_handler() local_unnamed_addr {28; CHECK-NEXT:    [[TMP1:%.*]] = call i32 @atexit(ptr @declared_atexit_handler)29; CHECK-NEXT:    ret i32 [[TMP1]]30;31  %1 = call i32 @atexit(ptr @declared_atexit_handler)32  ret i32 %133}34 35declare dso_local void @external_exit_func()36 37define dso_local void @nonempty_atexit_handler() {38; CHECK-LABEL: define dso_local void @nonempty_atexit_handler() {39; CHECK-NEXT:    call void @external_exit_func()40; CHECK-NEXT:    ret void41;42  call void @external_exit_func()43  ret void44}45 46; Check that an atexit handler that consists of any instructions other than `ret` is considered nonempty and not removed.47define dso_local noundef i32 @register_nonempty_atexit_handler() {48; CHECK-LABEL: define dso_local noundef i32 @register_nonempty_atexit_handler() local_unnamed_addr {49; CHECK-NEXT:    [[TMP1:%.*]] = call i32 @atexit(ptr @nonempty_atexit_handler)50; CHECK-NEXT:    ret i32 [[TMP1]]51;52  %1 = call i32 @atexit(ptr @nonempty_atexit_handler)53  ret i32 %154}55