diff options
author | Xin Tong <trent.xin.tong@gmail.com> | 2017-05-20 22:40:25 +0000 |
---|---|---|
committer | Xin Tong <trent.xin.tong@gmail.com> | 2017-05-20 22:40:25 +0000 |
commit | 75af3af95780e1c379409bf56c516a272c4fa961 (patch) | |
tree | df81d93ee10bd76a5be14744ff2ef967f0ddfeb8 /llvm/test/Transforms | |
parent | 36af8f4d42a0d4c5191450f5b729749b56bcc0e7 (diff) | |
download | bcm5719-llvm-75af3af95780e1c379409bf56c516a272c4fa961.tar.gz bcm5719-llvm-75af3af95780e1c379409bf56c516a272c4fa961.zip |
Add pthread_self function prototype and make it speculatable.
Summary: This allows pthread_self to be pulled out of a loop by LICM.
Reviewers: hfinkel, arsenm, davide
Reviewed By: davide
Subscribers: davide, wdng, llvm-commits
Differential Revision: https://reviews.llvm.org/D32782
llvm-svn: 303495
Diffstat (limited to 'llvm/test/Transforms')
-rw-r--r-- | llvm/test/Transforms/LICM/pthread.ll | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/llvm/test/Transforms/LICM/pthread.ll b/llvm/test/Transforms/LICM/pthread.ll new file mode 100644 index 00000000000..6a7aa499b5a --- /dev/null +++ b/llvm/test/Transforms/LICM/pthread.ll @@ -0,0 +1,38 @@ +; RUN: opt < %s -S -inferattrs -licm | FileCheck %s + +; CHECK-LABEL: define void @pthread_self_safe( +; CHECK-NEXT: call i64 @pthread_self() +define void @pthread_self_safe(i32) { + br label %2 + +; <label>:2: ; preds = %7, %1 + %idx = phi i32 [ 0, %1 ], [ %8, %7 ] + %3 = icmp slt i32 %idx, %0 + br i1 %3, label %4, label %9 + +; <label>:4: ; preds = %2 + call void @external_func_that_could_do_anything() + %5 = call i64 @pthread_self() #1 + %6 = trunc i64 %5 to i32 + call void @use_pthread_self(i32 %6) + br label %7 + +; <label>:7: ; preds = %4 + %8 = add nsw i32 %idx, 1 + br label %2 + +; <label>:9: ; preds = %2 + ret void +} + +; CHECK: declare i64 @pthread_self() #0 +; CHECK: attributes #0 = { nounwind readnone speculatable } +; Function Attrs: nounwind readnone +declare i64 @pthread_self() #1 + +declare void @external_func_that_could_do_anything() + +declare void @use_pthread_self(i32) + +attributes #1 = { nounwind readnone } + |