PartiallyInlineLibCalls: Check sqrt result type before transforming it.

Some configure scripts declare this with the wrong prototype, which can lead
to an assertion failure.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@214593 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Peter Collingbourne 2014-08-01 23:21:21 +00:00
parent b2b0ad4c75
commit f425efdbc2
2 changed files with 17 additions and 0 deletions

View File

@ -108,6 +108,10 @@ bool PartiallyInlineLibCalls::optimizeSQRT(CallInst *Call,
if (Call->onlyReadsMemory())
return false;
// The call must have the expected result type.
if (!Call->getType()->isFloatingPointTy())
return false;
// Do the following transformation:
//
// (before)

View File

@ -0,0 +1,13 @@
; RUN: opt -S -partially-inline-libcalls < %s | FileCheck %s
target triple = "x86_64-unknown-linux-gnu"
declare i32 @sqrt()
; CHECK-LABEL: @foo
define i32 @foo() {
; CHECK: call{{.*}}@sqrt
; CHECK-NOT: call{{.*}}@sqrt
%r = call i32 @sqrt()
ret i32 %r
}