diff options
author | Ramkumar Ramachandra <artagnon@gmail.com> | 2015-02-14 19:37:54 +0000 |
---|---|---|
committer | Ramkumar Ramachandra <artagnon@gmail.com> | 2015-02-14 19:37:54 +0000 |
commit | 8fcb498a9a0825c7f6fd114f4832a5f875a05db4 (patch) | |
tree | c289569a2f5dbb8d40b419d17ff422393b65de56 /llvm/test/Transforms | |
parent | 320fc2657bf4567a495e9ce02adf6de9e97721cc (diff) | |
download | bcm5719-llvm-8fcb498a9a0825c7f6fd114f4832a5f875a05db4.tar.gz bcm5719-llvm-8fcb498a9a0825c7f6fd114f4832a5f875a05db4.zip |
InstCombine: propagate deref via new addDereferenceableAttr
The "dereferenceable" attribute cannot be added via .addAttribute(),
since it also expects a size in bytes. AttrBuilder#addAttribute or
AttributeSet#addAttribute is wrapped by classes Function, InvokeInst,
and CallInst. Add corresponding wrappers to
AttrBuilder#addDereferenceableAttr.
Having done this, propagate the dereferenceable attribute via
gc.relocate, adding a test to exercise it. Note that -datalayout is
required during execution over and above -instcombine, because
InstCombine only optionally requires DataLayoutPass.
Differential Revision: http://reviews.llvm.org/D7510
llvm-svn: 229265
Diffstat (limited to 'llvm/test/Transforms')
-rw-r--r-- | llvm/test/Transforms/InstCombine/gc.relocate.ll | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/llvm/test/Transforms/InstCombine/gc.relocate.ll b/llvm/test/Transforms/InstCombine/gc.relocate.ll new file mode 100644 index 00000000000..d10ef5fcfa2 --- /dev/null +++ b/llvm/test/Transforms/InstCombine/gc.relocate.ll @@ -0,0 +1,20 @@ +; RUN: opt < %s -datalayout -instcombine -S | FileCheck %s + +; Uses InstCombine with DataLayout to propagate dereferenceable +; attribute via gc.relocate: if the derived ptr is dereferenceable(N), +; then the return attribute of gc.relocate is dereferenceable(N). + +declare zeroext i1 @return_i1() +declare i32 @llvm.experimental.gc.statepoint.p0f_i1f(i1 ()*, i32, i32, ...) +declare i32 addrspace(1)* @llvm.experimental.gc.relocate.p1i32(i32, i32, i32) + +define i32 addrspace(1)* @deref(i32 addrspace(1)* dereferenceable(8) %dparam) { +; Checks that a dereferenceabler pointer +; CHECK-LABEL: @deref +; CHECK: call dereferenceable(8) +entry: + %load = load i32 addrspace(1)* %dparam + %tok = tail call i32 (i1 ()*, i32, i32, ...)* @llvm.experimental.gc.statepoint.p0f_i1f(i1 ()* @return_i1, i32 0, i32 0, i32 0, i32 addrspace(1)* %dparam) + %relocate = call i32 addrspace(1)* @llvm.experimental.gc.relocate.p1i32(i32 %tok, i32 4, i32 4) + ret i32 addrspace(1)* %relocate +}
\ No newline at end of file |