From 4045ad6b0ccd35fe990d51b9bfdd9e7de109bdf5 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Thu, 18 Feb 2021 21:25:14 +0100 Subject: [PATCH] [DCE] Add tests for non-willreturn function being removed (NFC) --- llvm/test/Transforms/ADCE/willreturn.ll | 17 +++++++++++++++++ llvm/test/Transforms/BDCE/willreturn.ll | 17 +++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 llvm/test/Transforms/ADCE/willreturn.ll create mode 100644 llvm/test/Transforms/BDCE/willreturn.ll diff --git a/llvm/test/Transforms/ADCE/willreturn.ll b/llvm/test/Transforms/ADCE/willreturn.ll new file mode 100644 index 000000000000..c3482a417cb0 --- /dev/null +++ b/llvm/test/Transforms/ADCE/willreturn.ll @@ -0,0 +1,17 @@ +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py +; RUN: opt -adce -S < %s | FileCheck %s + +declare void @may_not_return(i32) nounwind readnone +declare void @will_return(i32) nounwind readnone willreturn + +; FIXME: This is a miscompile. +define void @test(i32 %a) { +; CHECK-LABEL: @test( +; CHECK-NEXT: ret void +; + %b = add i32 %a, 1 + call void @may_not_return(i32 %b) + %c = add i32 %b, 1 + call void @will_return(i32 %c) + ret void +} diff --git a/llvm/test/Transforms/BDCE/willreturn.ll b/llvm/test/Transforms/BDCE/willreturn.ll new file mode 100644 index 000000000000..b87ab0050e7a --- /dev/null +++ b/llvm/test/Transforms/BDCE/willreturn.ll @@ -0,0 +1,17 @@ +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py +; RUN: opt -bdce -S < %s | FileCheck %s + +declare void @may_not_return(i32) nounwind readnone +declare void @will_return(i32) nounwind readnone willreturn + +; FIXME: This is a miscompile. +define void @test(i32 %a) { +; CHECK-LABEL: @test( +; CHECK-NEXT: ret void +; + %b = add i32 %a, 1 + call void @may_not_return(i32 %b) + %c = add i32 %b, 1 + call void @will_return(i32 %c) + ret void +} -- 2.34.1