From d04c159ac13abbf15de719de1637c59dc38d4216 Mon Sep 17 00:00:00 2001 From: Jim Laskey Date: Thu, 13 Jul 2006 15:27:42 +0000 Subject: Fixed a bug handling void function types. Requires rebuild of llvm-gcc4 (touch llvm-debug.cpp.) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@29131 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/MachineDebugInfo.cpp | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) (limited to 'lib/CodeGen/MachineDebugInfo.cpp') diff --git a/lib/CodeGen/MachineDebugInfo.cpp b/lib/CodeGen/MachineDebugInfo.cpp index 54fb1b923c..fa2f57f0e0 100644 --- a/lib/CodeGen/MachineDebugInfo.cpp +++ b/lib/CodeGen/MachineDebugInfo.cpp @@ -223,16 +223,21 @@ public: Field = getGlobalVariable(C); } virtual void Apply(std::vector &Field) { + Field.resize(0); Constant *C = CI->getOperand(I++); GlobalVariable *GV = getGlobalVariable(C); - Field.resize(0); - // 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); + if (GV->hasInitializer()) { + 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); + } + } else if (GV->getInitializer()->isNullValue()) { + if (const ArrayType *T = + dyn_cast(GV->getType()->getElementType())) { + Field.resize(T->getNumElements()); + } } } } @@ -305,9 +310,13 @@ public: std::vector ArrayElements; for (unsigned i = 0, N = Field.size(); i < N; ++i) { - GlobalVariable *GVE = SR.Serialize(Field[i]); - Constant *CE = ConstantExpr::getCast(GVE, EmptyTy); - ArrayElements.push_back(cast(CE)); + if (DebugInfoDesc *Element = Field[i]) { + GlobalVariable *GVE = SR.Serialize(Element); + Constant *CE = ConstantExpr::getCast(GVE, EmptyTy); + ArrayElements.push_back(cast(CE)); + } else { + ArrayElements.push_back(ConstantPointerNull::get(EmptyTy)); + } } Constant *CA = ConstantArray::get(AT, ArrayElements); -- cgit v1.2.3-18-g5258