[InstCombine] Use getFunctionType()
authorNikita Popov <nikita.ppv@gmail.com>
Tue, 22 Jun 2021 20:29:05 +0000 (22:29 +0200)
committerNikita Popov <nikita.ppv@gmail.com>
Wed, 23 Jun 2021 18:28:34 +0000 (20:28 +0200)
Avoid fetching pointer element type...

llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
llvm/test/Transforms/InstCombine/opaque-ptr.ll

index e211b42..ece98ff 100644 (file)
@@ -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
index 0249b96..45b6998 100644 (file)
@@ -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
+}