[GlobalISel][CallLowering] Tighten constantexpr check for callee.
authorAmara Emerson <aemerson@apple.com>
Sun, 9 Feb 2020 18:09:51 +0000 (10:09 -0800)
committerAmara Emerson <aemerson@apple.com>
Mon, 10 Feb 2020 06:59:48 +0000 (22:59 -0800)
I'm not sure there's a test case for this, but it's better to be safe.

llvm/lib/CodeGen/GlobalISel/CallLowering.cpp

index 752f26b..65b5880 100644 (file)
@@ -56,7 +56,8 @@ bool CallLowering::lowerCall(MachineIRBuilder &MIRBuilder, ImmutableCallSite CS,
     // Try looking through a bitcast from one function type to another.
     // Commonly happens with calls to objc_msgSend().
     const Value *CalleeV = CS.getCalledValue();
-    if (auto *BC = dyn_cast<ConstantExpr>(CalleeV)) {
+    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);
       }