Index: lib/Target/SystemZ/SystemZInstrInfo.cpp =================================================================== --- lib/Target/SystemZ/SystemZInstrInfo.cpp +++ lib/Target/SystemZ/SystemZInstrInfo.cpp @@ -618,16 +618,25 @@ return true; } if (Opcode == SystemZ::CallJG) { - const GlobalValue *Global = MI.getOperand(0).getGlobal(); + MachineOperand FirstOp = MI.getOperand(0); const uint32_t *RegMask = MI.getOperand(1).getRegMask(); MI.RemoveOperand(1); MI.RemoveOperand(0); MI.setDesc(get(SystemZ::CallBRCL)); - MachineInstrBuilder(*MI.getParent()->getParent(), MI) - .addImm(CCValid).addImm(CCMask) - .addGlobalAddress(Global) - .addRegMask(RegMask) - .addReg(SystemZ::CC, RegState::Implicit); + MachineInstrBuilder MIB = MachineInstrBuilder(*MI.getParent()->getParent(), + MI); + MIB.addImm(CCValid); + MIB.addImm(CCMask); + + if (FirstOp.isGlobal()) + MIB.addGlobalAddress(FirstOp.getGlobal()); + else if (FirstOp.isSymbol()) + MIB.addExternalSymbol(FirstOp.getSymbolName()); + else + llvm_unreachable("Unrecognized operand type for CallJG"); + + MIB.addRegMask(RegMask); + MIB.addReg(SystemZ::CC, RegState::Implicit); return true; } if (Opcode == SystemZ::CallBR) {