From: Nikita Popov Date: Tue, 22 Jun 2021 20:29:05 +0000 (+0200) Subject: [InstCombine] Use getFunctionType() X-Git-Tag: llvmorg-14-init~3198 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8321335fd8ae9110f4faaabce6ef62c28b8f16cf;p=platform%2Fupstream%2Fllvm.git [InstCombine] Use getFunctionType() Avoid fetching pointer element type... --- diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp index e211b42..ece98ff 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(Callee->getType()); - FunctionType *FTy = cast(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 0249b96..45b6998 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 +}