[PATCH] D38204: [TargetTransformInfo] Check if function pointer is valid before calling isLoweredToCall
Guozhi Wei via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 4 13:15:52 PDT 2017
This revision was automatically updated to reflect the committed changes.
Closed by commit rL314927: [TargetTransformInfo] Check if function pointer is valid before calling… (authored by Carrot).
Changed prior to commit:
https://reviews.llvm.org/D38204?vs=116574&id=117724#toc
Repository:
rL LLVM
https://reviews.llvm.org/D38204
Files:
llvm/trunk/include/llvm/Analysis/TargetTransformInfoImpl.h
llvm/trunk/test/Analysis/CostModel/X86/costmodel.ll
Index: llvm/trunk/include/llvm/Analysis/TargetTransformInfoImpl.h
===================================================================
--- llvm/trunk/include/llvm/Analysis/TargetTransformInfoImpl.h
+++ llvm/trunk/include/llvm/Analysis/TargetTransformInfoImpl.h
@@ -188,6 +188,8 @@
}
bool isLoweredToCall(const Function *F) {
+ assert(F && "A concrete function must be provided to this routine.");
+
// FIXME: These should almost certainly not be handled here, and instead
// handled with the help of TLI or the target itself. This was largely
// ported from existing analysis heuristics here so that such refactorings
@@ -828,7 +830,7 @@
// A real function call is much slower.
if (auto *CI = dyn_cast<CallInst>(I)) {
const Function *F = CI->getCalledFunction();
- if (static_cast<T *>(this)->isLoweredToCall(F))
+ if (!F || static_cast<T *>(this)->isLoweredToCall(F))
return 40;
// Some intrinsics return a value and a flag, we use the value type
// to decide its latency.
Index: llvm/trunk/test/Analysis/CostModel/X86/costmodel.ll
===================================================================
--- llvm/trunk/test/Analysis/CostModel/X86/costmodel.ll
+++ llvm/trunk/test/Analysis/CostModel/X86/costmodel.ll
@@ -45,6 +45,10 @@
; CODESIZE: cost of 1 {{.*}} call
%uadd = call { i32, i1 } @llvm.uadd.with.overflow.i32(i32 undef, i32 undef)
+ ; LATENCY: cost of 40 {{.*}} call void undef
+ ; CODESIZE: cost of 1 {{.*}} call void undef
+ call void undef()
+
; LATENCY: cost of 1 {{.*}} ret
; CODESIZE: cost of 1 {{.*}} ret
ret i64 undef
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D38204.117724.patch
Type: text/x-patch
Size: 1634 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171004/ba2c87fb/attachment.bin>
More information about the llvm-commits
mailing list