diff options
| author | Eric Christopher <echristo@gmail.com> | 2015-07-02 01:11:50 +0000 |
|---|---|---|
| committer | Eric Christopher <echristo@gmail.com> | 2015-07-02 01:11:50 +0000 |
| commit | e1002268798ecedadaa9cdf6cc52b26e446ef3a7 (patch) | |
| tree | 3ea1e0fe0e95d9ef62e37e2004eaae56481489ee /llvm/test/Transforms | |
| parent | 4371b13937ecdd881da0eb3550af370ec4c3d5a2 (diff) | |
| download | bcm5719-llvm-e1002268798ecedadaa9cdf6cc52b26e446ef3a7.tar.gz bcm5719-llvm-e1002268798ecedadaa9cdf6cc52b26e446ef3a7.zip | |
Implement TargetTransformInfo::hasCompatibleFunctionAttributes for X86.
This checks subtarget feature compatibility for inlining by verifying
that the callee is a strict subset of the caller's features. This includes
the cpu as part of the subtarget we can get via the incoming functions as
the backend takes CPUs as feature sets.
This allows us to inline things like:
int foo() { return baz(); }
int __attribute__((target("sse4.2"))) bar() {
return foo();
}
so that generic code can be inlined into specialized functions.
llvm-svn: 241221
Diffstat (limited to 'llvm/test/Transforms')
| -rw-r--r-- | llvm/test/Transforms/Inline/inline-target-attr.ll | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/llvm/test/Transforms/Inline/inline-target-attr.ll b/llvm/test/Transforms/Inline/inline-target-attr.ll new file mode 100644 index 00000000000..90b393212e5 --- /dev/null +++ b/llvm/test/Transforms/Inline/inline-target-attr.ll @@ -0,0 +1,35 @@ +; RUN: opt < %s -S -inline | FileCheck %s +; Check that we only inline when we have compatible target attributes. +; X86 has implemented a target attribute that will verify that the attribute +; sets are compatible. + +target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-unknown-linux-gnu" + +define i32 @foo() #0 { +entry: + %call = call i32 (...) @baz() + ret i32 %call +; CHECK-LABEL: foo +; CHECK: call i32 (...) @baz() +} +declare i32 @baz(...) #0 + +define i32 @bar() #1 { +entry: + %call = call i32 @foo() + ret i32 %call +; CHECK-LABEL: bar +; CHECK: call i32 (...) @baz() +} + +define i32 @qux() #0 { +entry: + %call = call i32 @bar() + ret i32 %call +; CHECK-LABEL: qux +; CHECK: call i32 @bar() +} + +attributes #0 = { "target-cpu"="x86-64" "target-features"="+sse,+sse2" } +attributes #1 = { "target-cpu"="x86-64" "target-features"="+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3" } |

