[PATCH] D39381: [PartialInlineLibCalls] Teach PartialInlineLibCalls to honor nobuiltin, properly check the function signature, and check TLI::has
Phabricator via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 27 17:37:33 PDT 2017
This revision was automatically updated to reflect the committed changes.
Closed by commit rL316819: [PartialInlineLibCalls] Teach PartialInlineLibCalls to honor nobuiltin… (authored by ctopper).
Changed prior to commit:
https://reviews.llvm.org/D39381?vs=120677&id=120724#toc
Repository:
rL LLVM
https://reviews.llvm.org/D39381
Files:
llvm/trunk/lib/Transforms/Scalar/PartiallyInlineLibCalls.cpp
llvm/trunk/test/Transforms/PartiallyInlineLibCalls/bad-prototype.ll
llvm/trunk/test/Transforms/PartiallyInlineLibCalls/nobuiltin.ll
Index: llvm/trunk/lib/Transforms/Scalar/PartiallyInlineLibCalls.cpp
===================================================================
--- llvm/trunk/lib/Transforms/Scalar/PartiallyInlineLibCalls.cpp
+++ llvm/trunk/lib/Transforms/Scalar/PartiallyInlineLibCalls.cpp
@@ -32,10 +32,6 @@
if (Call->onlyReadsMemory())
return false;
- // The call must have the expected result type.
- if (!Call->getType()->isFloatingPointTy())
- return false;
-
// Do the following transformation:
//
// (before)
@@ -96,11 +92,14 @@
if (!Call || !(CalledFunc = Call->getCalledFunction()))
continue;
+ if (Call->isNoBuiltin())
+ continue;
+
// Skip if function either has local linkage or is not a known library
// function.
LibFunc LF;
- if (CalledFunc->hasLocalLinkage() || !CalledFunc->hasName() ||
- !TLI->getLibFunc(CalledFunc->getName(), LF))
+ if (CalledFunc->hasLocalLinkage() ||
+ !TLI->getLibFunc(*CalledFunc, LF) || !TLI->has(LF))
continue;
switch (LF) {
Index: llvm/trunk/test/Transforms/PartiallyInlineLibCalls/nobuiltin.ll
===================================================================
--- llvm/trunk/test/Transforms/PartiallyInlineLibCalls/nobuiltin.ll
+++ llvm/trunk/test/Transforms/PartiallyInlineLibCalls/nobuiltin.ll
@@ -0,0 +1,12 @@
+; RUN: opt -S -partially-inline-libcalls -mtriple=x86_64-unknown-linux-gnu < %s | FileCheck %s
+; RUN: opt -S -passes=partially-inline-libcalls -mtriple=x86_64-unknown-linux-gnu < %s | FileCheck %s
+
+define float @f(float %val) {
+; CHECK-LABEL: @f
+; CHECK: call{{.*}}@sqrtf
+; CHECK-NOT: call{{.*}}@sqrtf
+ %res = tail call float @sqrtf(float %val) nobuiltin
+ ret float %res
+}
+
+declare float @sqrtf(float)
Index: llvm/trunk/test/Transforms/PartiallyInlineLibCalls/bad-prototype.ll
===================================================================
--- llvm/trunk/test/Transforms/PartiallyInlineLibCalls/bad-prototype.ll
+++ llvm/trunk/test/Transforms/PartiallyInlineLibCalls/bad-prototype.ll
@@ -4,11 +4,20 @@
target triple = "x86_64-unknown-linux-gnu"
declare i32 @sqrt()
+declare float @sqrtf()
; CHECK-LABEL: @foo
define i32 @foo() {
; CHECK: call{{.*}}@sqrt
; CHECK-NOT: call{{.*}}@sqrt
%r = call i32 @sqrt()
ret i32 %r
}
+
+; CHECK-LABEL: @bar
+define float @bar() {
+ ; CHECK: call{{.*}}@sqrtf
+ ; CHECK-NOT: call{{.*}}@sqrtf
+ %r = call float @sqrtf()
+ ret float %r
+}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D39381.120724.patch
Type: text/x-patch
Size: 2470 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171028/e7ad7ff6/attachment.bin>
More information about the llvm-commits
mailing list