[llvm] r214593 - PartiallyInlineLibCalls: Check sqrt result type before transforming it.
Peter Collingbourne
peter at pcc.me.uk
Fri Aug 1 16:21:21 PDT 2014
Author: pcc
Date: Fri Aug 1 18:21:21 2014
New Revision: 214593
URL: http://llvm.org/viewvc/llvm-project?rev=214593&view=rev
Log:
PartiallyInlineLibCalls: Check sqrt result type before transforming it.
Some configure scripts declare this with the wrong prototype, which can lead
to an assertion failure.
Added:
llvm/trunk/test/Transforms/PartiallyInlineLibCalls/
llvm/trunk/test/Transforms/PartiallyInlineLibCalls/bad-prototype.ll
Modified:
llvm/trunk/lib/Transforms/Scalar/PartiallyInlineLibCalls.cpp
Modified: llvm/trunk/lib/Transforms/Scalar/PartiallyInlineLibCalls.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/PartiallyInlineLibCalls.cpp?rev=214593&r1=214592&r2=214593&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/PartiallyInlineLibCalls.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/PartiallyInlineLibCalls.cpp Fri Aug 1 18:21:21 2014
@@ -108,6 +108,10 @@ bool PartiallyInlineLibCalls::optimizeSQ
if (Call->onlyReadsMemory())
return false;
+ // The call must have the expected result type.
+ if (!Call->getType()->isFloatingPointTy())
+ return false;
+
// Do the following transformation:
//
// (before)
Added: llvm/trunk/test/Transforms/PartiallyInlineLibCalls/bad-prototype.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/PartiallyInlineLibCalls/bad-prototype.ll?rev=214593&view=auto
==============================================================================
--- llvm/trunk/test/Transforms/PartiallyInlineLibCalls/bad-prototype.ll (added)
+++ llvm/trunk/test/Transforms/PartiallyInlineLibCalls/bad-prototype.ll Fri Aug 1 18:21:21 2014
@@ -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
+}
More information about the llvm-commits
mailing list