[llvm] 8321335 - [InstCombine] Use getFunctionType()
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 23 11:29:34 PDT 2021
Author: Nikita Popov
Date: 2021-06-23T20:28:34+02:00
New Revision: 8321335fd8ae9110f4faaabce6ef62c28b8f16cf
URL: https://github.com/llvm/llvm-project/commit/8321335fd8ae9110f4faaabce6ef62c28b8f16cf
DIFF: https://github.com/llvm/llvm-project/commit/8321335fd8ae9110f4faaabce6ef62c28b8f16cf.diff
LOG: [InstCombine] Use getFunctionType()
Avoid fetching pointer element type...
Added:
Modified:
llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
llvm/test/Transforms/InstCombine/opaque-ptr.ll
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
index e211b42747dd..ece98ffe39f4 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
@@ -2310,8 +2310,7 @@ Instruction *InstCombinerImpl::visitCallBase(CallBase &Call) {
if (IntrinsicInst *II = findInitTrampoline(Callee))
return transformCallThroughTrampoline(Call, *II);
- PointerType *PTy = cast<PointerType>(Callee->getType());
- FunctionType *FTy = cast<FunctionType>(PTy->getElementType());
+ FunctionType *FTy = Call.getFunctionType();
if (FTy->isVarArg()) {
int ix = FTy->getNumParams();
// See if we can optimize any arguments passed through the varargs area of
diff --git a/llvm/test/Transforms/InstCombine/opaque-ptr.ll b/llvm/test/Transforms/InstCombine/opaque-ptr.ll
index 0249b9686cf2..45b699855dd7 100644
--- a/llvm/test/Transforms/InstCombine/opaque-ptr.ll
+++ b/llvm/test/Transforms/InstCombine/opaque-ptr.ll
@@ -108,3 +108,12 @@ define ptr @load_bitcast_2(ptr %a) {
%d = bitcast i8* %c to ptr
ret ptr %d
}
+
+define void @call(ptr %a) {
+; CHECK-LABEL: @call(
+; CHECK-NEXT: call void [[A:%.*]]()
+; CHECK-NEXT: ret void
+;
+ call void %a()
+ ret void
+}
More information about the llvm-commits
mailing list