From 8321335fd8ae9110f4faaabce6ef62c28b8f16cf Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Tue, 22 Jun 2021 22:29:05 +0200 Subject: [PATCH] [InstCombine] Use getFunctionType() Avoid fetching pointer element type... --- llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp | 3 +-- llvm/test/Transforms/InstCombine/opaque-ptr.ll | 9 +++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) 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 +} -- 2.7.4