summaryrefslogtreecommitdiffstats
path: root/llvm/test/Transforms/CodeExtractor
diff options
context:
space:
mode:
authorFlorian Hahn <florian.hahn@arm.com>2018-01-07 11:22:25 +0000
committerFlorian Hahn <florian.hahn@arm.com>2018-01-07 11:22:25 +0000
commit55be37e7d4f5af14b7cc5108a5181109b73b0a9a (patch)
tree3fd574641544a58a4f0f19a0034c3175e077b30a /llvm/test/Transforms/CodeExtractor
parenta674416d9072fbaa84b9ff69aa6ac714ee3793f9 (diff)
downloadbcm5719-llvm-55be37e7d4f5af14b7cc5108a5181109b73b0a9a.tar.gz
bcm5719-llvm-55be37e7d4f5af14b7cc5108a5181109b73b0a9a.zip
[CodeExtractor] Use subset of function attributes for extracted function.
In addition to target-dependent attributes, we can also preserve a white-listed subset of target independent function attributes. The white-list excludes problematic attributes, most prominently: * attributes related to memory accesses, as alloca instructions could be moved in/out of the extracted block * control-flow dependent attributes, like no_return or thunk, as the relerelevant instructions might or might not get extracted. Thanks @efriedma and @aemerson for providing a set of attributes that cannot be propagated. Reviewers: efriedma, davidxl, davide, silvas Reviewed By: efriedma Differential Revision: https://reviews.llvm.org/D41334 llvm-svn: 321961
Diffstat (limited to 'llvm/test/Transforms/CodeExtractor')
-rw-r--r--llvm/test/Transforms/CodeExtractor/PartialInlineAttributes.ll85
1 files changed, 85 insertions, 0 deletions
diff --git a/llvm/test/Transforms/CodeExtractor/PartialInlineAttributes.ll b/llvm/test/Transforms/CodeExtractor/PartialInlineAttributes.ll
new file mode 100644
index 00000000000..40170846392
--- /dev/null
+++ b/llvm/test/Transforms/CodeExtractor/PartialInlineAttributes.ll
@@ -0,0 +1,85 @@
+; RUN: opt < %s -S -partial-inliner -skip-partial-inlining-cost-analysis=true | FileCheck %s
+
+
+define i32 @callee_most(i32 %v) unnamed_addr #0 #1 {
+entry:
+ %cmp = icmp sgt i32 %v, 2000
+ br i1 %cmp, label %if.then, label %if.end
+
+if.then:
+ br label %if.then2
+
+if.then2:
+ %sub = sub i32 %v, 10
+ br label %if.end
+
+if.end:
+ %v2 = phi i32 [ %v, %entry ], [ %sub, %if.then2 ]
+ %add = add nsw i32 %v2, 200
+ ret i32 %add
+}
+
+define i32 @callee_noinline(i32 %v) optnone noinline {
+entry:
+ %cmp = icmp sgt i32 %v, 2000
+ br i1 %cmp, label %if.then, label %if.end
+
+if.then:
+ br label %if.then2
+
+if.then2:
+ %sub = sub i32 %v, 10
+ br label %if.end
+
+if.end:
+ %v2 = phi i32 [ %v, %entry ], [ %sub, %if.then2 ]
+ %add = add nsw i32 %v2, 200
+ ret i32 %add
+}
+
+define i32 @callee_writeonly(i32 %v) writeonly {
+entry:
+ %cmp = icmp sgt i32 %v, 2000
+ br i1 %cmp, label %if.then, label %if.end
+
+if.then:
+ br label %if.then2
+
+if.then2:
+ %sub = sub i32 %v, 10
+ br label %if.end
+
+if.end:
+ %v2 = phi i32 [ %v, %entry ], [ %sub, %if.then2 ]
+ %add = add nsw i32 %v2, 200
+ ret i32 %add
+}
+; CHECK-LABEL: @caller
+; CHECK: call void @callee_most.2_if.then(i32 %v
+; CHECK: call i32 @callee_noinline(i32 %v)
+; CHECK: call void @callee_writeonly.1_if.then(i32 %v
+define i32 @caller(i32 %v) {
+entry:
+ %c1 = call i32 @callee_most(i32 %v)
+ %c2 = call i32 @callee_noinline(i32 %v)
+ %c3 = call i32 @callee_writeonly(i32 %v)
+ ret i32 %c3
+}
+
+; CHECK: define internal void @callee_writeonly.1_if.then(i32 %v, i32* %sub.out) {
+; CHECK: define internal void @callee_most.2_if.then(i32 %v, i32* %sub.out) [[FN_ATTRS:#[0-9]+]]
+
+; attributes to preserve
+attributes #0 = {
+ inlinehint minsize noduplicate noimplicitfloat norecurse noredzone nounwind
+ nonlazybind optsize safestack sanitize_address sanitize_hwaddress sanitize_memory
+ sanitize_thread ssp sspreq sspstrong strictfp uwtable "foo"="bar"
+ "patchable-function"="prologue-short-redirect" "probe-stack"="_foo_guard" "stack-probe-size"="4096" }
+
+; CHECK: attributes [[FN_ATTRS]] = { inlinehint minsize noduplicate noimplicitfloat norecurse noredzone nounwind nonlazybind optsize safestack sanitize_address sanitize_hwaddress sanitize_memory sanitize_thread ssp sspreq sspstrong strictfp uwtable "foo"="bar" "patchable-function"="prologue-short-redirect" "probe-stack"="_foo_guard" "stack-probe-size"="4096" }
+
+; attributes to drop
+attributes #1 = {
+ alignstack=16 convergent inaccessiblememonly inaccessiblemem_or_argmemonly naked
+ noreturn readonly argmemonly returns_twice speculatable "thunk"
+}
OpenPOWER on IntegriCloud