diff options
author | Dan Gohman <gohman@apple.com> | 2012-01-17 20:52:24 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2012-01-17 20:52:24 +0000 |
commit | 2f6263c96a6ed234b8d314cc35c8e2fcc3e81ccc (patch) | |
tree | 733a5e75a9f22e0e7399e6ed3170acb22c2cb95f /test | |
parent | 7d4c87ef6eea424b7a28392ea11137ed77b44b57 (diff) | |
download | llvm-2f6263c96a6ed234b8d314cc35c8e2fcc3e81ccc.tar.gz llvm-2f6263c96a6ed234b8d314cc35c8e2fcc3e81ccc.tar.bz2 llvm-2f6263c96a6ed234b8d314cc35c8e2fcc3e81ccc.tar.xz |
Add a new ObjC ARC optimization pass to eliminate unneeded
autorelease push+pop pairs.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@148330 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test')
-rw-r--r-- | test/Transforms/ObjCARC/apelim.ll | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/test/Transforms/ObjCARC/apelim.ll b/test/Transforms/ObjCARC/apelim.ll new file mode 100644 index 0000000000..5fefe53551 --- /dev/null +++ b/test/Transforms/ObjCARC/apelim.ll @@ -0,0 +1,51 @@ +; RUN: opt -S -objc-arc-apelim < %s | FileCheck %s +; rdar://10227311 + +@x = global i32 0 + +declare i32 @bar() nounwind + +define i32 @foo() nounwind { +entry: + ret i32 5 +} + +define internal void @__cxx_global_var_init() { +entry: + %call = call i32 @foo() + store i32 %call, i32* @x, align 4 + ret void +} + +define internal void @__dxx_global_var_init() { +entry: + %call = call i32 @bar() + store i32 %call, i32* @x, align 4 + ret void +} + +; CHECK: define internal void @_GLOBAL__I_x() +; CHECK-NOT: @objc +; CHECK: } +define internal void @_GLOBAL__I_x() { +entry: + %0 = call i8* @objc_autoreleasePoolPush() nounwind + call void @__cxx_global_var_init() + call void @objc_autoreleasePoolPop(i8* %0) nounwind + ret void +} + +; CHECK: define internal void @_GLOBAL__I_y() +; CHECK: %0 = call i8* @objc_autoreleasePoolPush() nounwind +; CHECK: call void @objc_autoreleasePoolPop(i8* %0) nounwind +; CHECK: } +define internal void @_GLOBAL__I_y() { +entry: + %0 = call i8* @objc_autoreleasePoolPush() nounwind + call void @__dxx_global_var_init() + call void @objc_autoreleasePoolPop(i8* %0) nounwind + ret void +} + +declare i8* @objc_autoreleasePoolPush() +declare void @objc_autoreleasePoolPop(i8*) |