[llvm-branch-commits] [llvm] d6c763e - [Inline] Precommit tests for dead calls and willreturn.

Florian Hahn via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Fri Jan 22 13:34:55 PST 2021


Author: Florian Hahn
Date: 2021-01-22T21:29:43Z
New Revision: d6c763e0985fb69ceec4d2d3cebfc1910f8cc58d

URL: https://github.com/llvm/llvm-project/commit/d6c763e0985fb69ceec4d2d3cebfc1910f8cc58d
DIFF: https://github.com/llvm/llvm-project/commit/d6c763e0985fb69ceec4d2d3cebfc1910f8cc58d.diff

LOG: [Inline] Precommit tests for dead calls and willreturn.

precommit tests for D94106.

Added: 
    llvm/test/Transforms/Inline/dead-calls-willreturn.ll

Modified: 
    

Removed: 
    


################################################################################
diff  --git a/llvm/test/Transforms/Inline/dead-calls-willreturn.ll b/llvm/test/Transforms/Inline/dead-calls-willreturn.ll
new file mode 100644
index 000000000000..463cc5894bb5
--- /dev/null
+++ b/llvm/test/Transforms/Inline/dead-calls-willreturn.ll
@@ -0,0 +1,53 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt -inline -S %s | FileCheck %s
+
+; readnone but may not return according to attributes.
+define void @readnone_may_not_return() nounwind readnone ssp {
+; CHECK-LABEL: @readnone_may_not_return(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:    br label [[WHILE_BODY:%.*]]
+; CHECK:       while.body:
+; CHECK-NEXT:    br label [[WHILE_BODY]]
+;
+entry:
+  br label %while.body
+
+while.body:
+  br label %while.body
+}
+
+; readnone and guaranteed to return according to attributes.
+define void @readnone_willreturn() willreturn nounwind readnone ssp {
+; CHECK-LABEL: @readnone_willreturn(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:    ret void
+;
+entry:
+  ret void
+}
+
+; Make sure the call to @readnone is not treated as dead, because it is not
+; marked as willreturn.
+define void @caller_may_not_return() ssp {
+; CHECK-LABEL: @caller_may_not_return(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:    ret void
+;
+entry:
+  call void @readnone_may_not_return()
+  call void @readnone_willreturn()
+  ret void
+}
+
+; @caller_willreturn is marked as willreturn, so all called functions also must
+; return. All calls are dead.
+define void @caller_willreturn() ssp willreturn {
+; CHECK-LABEL: @caller_willreturn(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:    ret void
+;
+entry:
+  call void @readnone_may_not_return()
+  call void @readnone_willreturn()
+  ret void
+}


        


More information about the llvm-branch-commits mailing list