From 2698f0de7a07cd3b0e978c9b4f16bb27a29aa1da Mon Sep 17 00:00:00 2001 From: Jim Laskey Date: Wed, 8 Mar 2006 18:11:07 +0000 Subject: Get rid of the multiple copies of getStringValue. Now a Constant:: method. llvm-svn: 26616 --- llvm/lib/CodeGen/MachineDebugInfo.cpp | 43 ++--------------------------------- 1 file changed, 2 insertions(+), 41 deletions(-) (limited to 'llvm/lib/CodeGen/MachineDebugInfo.cpp') diff --git a/llvm/lib/CodeGen/MachineDebugInfo.cpp b/llvm/lib/CodeGen/MachineDebugInfo.cpp index 45ded8e426e..e18a2430b63 100644 --- a/llvm/lib/CodeGen/MachineDebugInfo.cpp +++ b/llvm/lib/CodeGen/MachineDebugInfo.cpp @@ -67,45 +67,6 @@ getGlobalVariablesUsing(Module &M, const std::string &RootName) { return Result; } -/// getStringValue - Turn an LLVM constant pointer that eventually points to a -/// global into a string value. Return an empty string if we can't do it. -/// -static const std::string getStringValue(Value *V, unsigned Offset = 0) { - if (GlobalVariable *GV = dyn_cast(V)) { - if (GV->hasInitializer() && isa(GV->getInitializer())) { - ConstantArray *Init = cast(GV->getInitializer()); - if (Init->isString()) { - std::string Result = Init->getAsString(); - if (Offset < Result.size()) { - // If we are pointing INTO The string, erase the beginning... - Result.erase(Result.begin(), Result.begin()+Offset); - - // Take off the null terminator, and any string fragments after it. - std::string::size_type NullPos = Result.find_first_of((char)0); - if (NullPos != std::string::npos) - Result.erase(Result.begin()+NullPos, Result.end()); - return Result; - } - } - } - } else if (Constant *C = dyn_cast(V)) { - if (GlobalValue *GV = dyn_cast(C)) - return getStringValue(GV, Offset); - else if (ConstantExpr *CE = dyn_cast(C)) { - if (CE->getOpcode() == Instruction::GetElementPtr) { - // Turn a gep into the specified offset. - if (CE->getNumOperands() == 3 && - cast(CE->getOperand(1))->isNullValue() && - isa(CE->getOperand(2))) { - return getStringValue(CE->getOperand(0), - Offset+cast(CE->getOperand(2))->getRawValue()); - } - } - } - } - return ""; -} - /// isStringValue - Return true if the given value can be coerced to a string. /// static bool isStringValue(Value *V) { @@ -250,7 +211,7 @@ public: } virtual void Apply(std::string &Field) { Constant *C = CI->getOperand(I++); - Field = getStringValue(C); + Field = C->getStringValue(); } virtual void Apply(DebugInfoDesc *&Field) { Constant *C = CI->getOperand(I++); @@ -571,7 +532,7 @@ void AnchorDesc::ApplyToFields(DIVisitor *Visitor) { /// getDescString - Return a string used to compose global names and labels. A /// A global variable name needs to be defined for each debug descriptor that is -/// anchored. NOTE: that each global variable name here also needs to be added +/// anchored. NOTE: that each global variable named here also needs to be added /// to the list of names left external in the internalizer. /// ExternalNames.insert("llvm.dbg.compile_units"); /// ExternalNames.insert("llvm.dbg.global_variables"); -- cgit v1.2.3