Skip to content

Commit f425efd

Browse files
committed
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
1 parent b2b0ad4 commit f425efd

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

lib/Transforms/Scalar/PartiallyInlineLibCalls.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,10 @@ bool PartiallyInlineLibCalls::optimizeSQRT(CallInst *Call,
108108
if (Call->onlyReadsMemory())
109109
return false;
110110

111+
// The call must have the expected result type.
112+
if (!Call->getType()->isFloatingPointTy())
113+
return false;
114+
111115
// Do the following transformation:
112116
//
113117
// (before)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
; RUN: opt -S -partially-inline-libcalls < %s | FileCheck %s
2+
3+
target triple = "x86_64-unknown-linux-gnu"
4+
5+
declare i32 @sqrt()
6+
7+
; CHECK-LABEL: @foo
8+
define i32 @foo() {
9+
; CHECK: call{{.*}}@sqrt
10+
; CHECK-NOT: call{{.*}}@sqrt
11+
%r = call i32 @sqrt()
12+
ret i32 %r
13+
}

0 commit comments

Comments
 (0)