[llvm] 067dd9c - [GlobalISel][CallLowering] Use stripPointerCasts().

Amara Emerson via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 10 15:44:05 PST 2020


Author: Amara Emerson
Date: 2020-02-10T15:43:57-08:00
New Revision: 067dd9c6b12adb3ace20b46203cff9031c7dd6a4

URL: https://github.com/llvm/llvm-project/commit/067dd9c6b12adb3ace20b46203cff9031c7dd6a4
DIFF: https://github.com/llvm/llvm-project/commit/067dd9c6b12adb3ace20b46203cff9031c7dd6a4.diff

LOG: [GlobalISel][CallLowering] Use stripPointerCasts().

A downstream test exposed a simple logic bug with the manual pointer
stripping code, fix that by just using stripPointerCasts() on the value.

I don't think there's a way to expose this issue upstream.

Added: 
    

Modified: 
    llvm/lib/CodeGen/GlobalISel/CallLowering.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp b/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp
index 65b588013667..2aea679e8243 100644
--- a/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp
@@ -50,21 +50,13 @@ bool CallLowering::lowerCall(MachineIRBuilder &MIRBuilder, ImmutableCallSite CS,
     ++i;
   }
 
-  if (const Function *F = CS.getCalledFunction())
+  // Try looking through a bitcast from one function type to another.
+  // Commonly happens with calls to objc_msgSend().
+  const Value *CalleeV = CS.getCalledValue()->stripPointerCasts();
+  if (const Function *F = dyn_cast<Function>(CalleeV))
     Info.Callee = MachineOperand::CreateGA(F, 0);
-  else {
-    // Try looking through a bitcast from one function type to another.
-    // Commonly happens with calls to objc_msgSend().
-    const Value *CalleeV = CS.getCalledValue();
-    auto *BC = dyn_cast<ConstantExpr>(CalleeV);
-    if (BC && BC->getOpcode() == Instruction::BitCast) {
-      if (const auto *F = dyn_cast<Function>(BC->getOperand(0))) {
-        Info.Callee = MachineOperand::CreateGA(F, 0);
-      }
-    } else {
-      Info.Callee = MachineOperand::CreateReg(GetCalleeReg(), false);
-    }
-  }
+  else
+    Info.Callee = MachineOperand::CreateReg(GetCalleeReg(), false);
 
   Info.OrigRet = ArgInfo{ResRegs, CS.getType(), ISD::ArgFlagsTy{}};
   if (!Info.OrigRet.Ty->isVoidTy())


        


More information about the llvm-commits mailing list