Skip to content

Commit 1b6663a

Browse files
committed
[FuncSpec] Remove unnecessary function pointer type check
We will check a bit later that the constant is in fact a function, so the separate check for a function pointer type is largely redunant. Also simplify the cast stripping with stripPointerCasts().
1 parent 0f26125 commit 1b6663a

File tree

1 file changed

+2
-13
lines changed

1 file changed

+2
-13
lines changed

llvm/lib/Transforms/IPO/FunctionSpecialization.cpp

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -583,19 +583,8 @@ class FunctionSpecializer {
583583

584584
// The below heuristic is only concerned with exposing inlining
585585
// opportunities via indirect call promotion. If the argument is not a
586-
// function pointer, give up.
587-
if (!isa<PointerType>(A->getType()) ||
588-
!isa<FunctionType>(A->getType()->getPointerElementType()))
589-
return TotalCost;
590-
591-
// Since the argument is a function pointer, its incoming constant values
592-
// should be functions or constant expressions. The code below attempts to
593-
// look through cast expressions to find the function that will be called.
594-
Value *CalledValue = C;
595-
while (isa<ConstantExpr>(CalledValue) &&
596-
cast<ConstantExpr>(CalledValue)->isCast())
597-
CalledValue = cast<User>(CalledValue)->getOperand(0);
598-
Function *CalledFunction = dyn_cast<Function>(CalledValue);
586+
// (potentially casted) function pointer, give up.
587+
Function *CalledFunction = dyn_cast<Function>(C->stripPointerCasts());
599588
if (!CalledFunction)
600589
return TotalCost;
601590

0 commit comments

Comments
 (0)