diff --git a/lib/CodeGen/MachineDebugInfo.cpp b/lib/CodeGen/MachineDebugInfo.cpp index 9e76daa4b78..45ded8e426e 100644 --- a/lib/CodeGen/MachineDebugInfo.cpp +++ b/lib/CodeGen/MachineDebugInfo.cpp @@ -263,12 +263,15 @@ public: virtual void Apply(std::vector &Field) { Constant *C = CI->getOperand(I++); GlobalVariable *GV = getGlobalVariable(C); - ConstantArray *CA = cast(GV->getInitializer()); Field.resize(0); - for (unsigned i = 0, N = CA->getNumOperands(); i < N; ++i) { - GlobalVariable *GVE = getGlobalVariable(CA->getOperand(i)); - DebugInfoDesc *DE = DR.Deserialize(GVE); - Field.push_back(DE); + // Have to be able to deal with the empty array case (zero initializer) + if (!GV->hasInitializer()) return; + if (ConstantArray *CA = dyn_cast(GV->getInitializer())) { + for (unsigned i = 0, N = CA->getNumOperands(); i < N; ++i) { + GlobalVariable *GVE = getGlobalVariable(CA->getOperand(i)); + DebugInfoDesc *DE = DR.Deserialize(GVE); + Field.push_back(DE); + } } } };