summaryrefslogtreecommitdiffstats
path: root/llvm/test/CodeGen
diff options
context:
space:
mode:
authorHans Wennborg <hans@hanshq.net>2016-05-19 20:15:33 +0000
committerHans Wennborg <hans@hanshq.net>2016-05-19 20:15:33 +0000
commit172eee9cfc1a7963aded8b29784b9d9190c1d6b0 (patch)
tree1391607593abb6402e3cfd9c83f9dd7f076fceef /llvm/test/CodeGen
parent3650bbeebc07f3d4cfd026bbb5088432bb1766e6 (diff)
downloadbcm5719-llvm-172eee9cfc1a7963aded8b29784b9d9190c1d6b0.tar.gz
bcm5719-llvm-172eee9cfc1a7963aded8b29784b9d9190c1d6b0.zip
X86: Don't reset the stack after calls that don't return (PR27117)
Since the calls don't return, the instruction afterwards will never run, and is just taking up unnecessary space in the binary. Differential Revision: http://reviews.llvm.org/D20406 llvm-svn: 270109
Diffstat (limited to 'llvm/test/CodeGen')
-rw-r--r--llvm/test/CodeGen/X86/noreturn-call.ll48
1 files changed, 48 insertions, 0 deletions
diff --git a/llvm/test/CodeGen/X86/noreturn-call.ll b/llvm/test/CodeGen/X86/noreturn-call.ll
new file mode 100644
index 00000000000..89781816de8
--- /dev/null
+++ b/llvm/test/CodeGen/X86/noreturn-call.ll
@@ -0,0 +1,48 @@
+; RUN: llc < %s -mtriple=i686-pc-win32 | FileCheck %s
+
+define void @test1(i32 %c) {
+; CHECK-LABEL: test1:
+entry:
+ %0 = alloca i8, i32 %c
+ %tobool = icmp eq i32 %c, 0
+ br i1 %tobool, label %if.end, label %if.then
+
+if.end:
+ call void @g(i8* %0)
+ ret void
+
+if.then:
+ call void @crash(i8* %0)
+ unreachable
+; CHECK: calll _crash
+; There is no need to adjust the stack after the call, since
+; the function is noreturn and that code will therefore never run.
+; CHECK-NOT: add
+; CHECK-NOT: pop
+}
+
+define void @test2(i32 %c) {
+; CHECK-LABEL: test2:
+entry:
+ %0 = alloca i8, i32 %c
+ %tobool = icmp eq i32 %c, 0
+ br i1 %tobool, label %if.end, label %if.then
+
+if.end:
+ call void @g(i8* %0)
+ ret void
+
+if.then:
+ call void @crash2(i8* %0)
+ unreachable
+; CHECK: calll _crash2
+; Even though _crash2 is not marked noreturn, it is in practice because
+; of the "unreachable" right after it. This happens e.g. when falling off
+; a non-void function after a call.
+; CHECK-NOT: add
+; CHECK-NOT: pop
+}
+
+declare void @crash(i8*) noreturn
+declare void @crash2(i8*)
+declare void @g(i8*)
OpenPOWER on IntegriCloud