[llvm-branch-commits] [llvm-branch] r119234 - in /llvm/branches/Apple/whitney: include/llvm/Analysis/DebugInfo.h lib/Analysis/DebugInfo.cpp lib/CodeGen/AsmPrinter/DwarfDebug.cpp
Daniel Dunbar
daniel at zuster.org
Mon Nov 15 13:45:02 PST 2010
Author: ddunbar
Date: Mon Nov 15 15:45:02 2010
New Revision: 119234
URL: http://llvm.org/viewvc/llvm-project?rev=119234&view=rev
Log:
Merge r118726:
--
Author: Devang Patel <dpatel at apple.com>
Date: Wed Nov 10 22:19:21 2010 +0000
Take care of special characters while creating named MDNode name to hold function specific local variable's info.
This fixes radar 8653152. I am checking in testcase as a separate check-in.
Modified:
llvm/branches/Apple/whitney/include/llvm/Analysis/DebugInfo.h
llvm/branches/Apple/whitney/lib/Analysis/DebugInfo.cpp
llvm/branches/Apple/whitney/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
Modified: llvm/branches/Apple/whitney/include/llvm/Analysis/DebugInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/whitney/include/llvm/Analysis/DebugInfo.h?rev=119234&r1=119233&r2=119234&view=diff
==============================================================================
--- llvm/branches/Apple/whitney/include/llvm/Analysis/DebugInfo.h (original)
+++ llvm/branches/Apple/whitney/include/llvm/Analysis/DebugInfo.h Mon Nov 15 15:45:02 2010
@@ -33,6 +33,7 @@
class DbgDeclareInst;
class Instruction;
class MDNode;
+ class NamedMDNode;
class LLVMContext;
class raw_ostream;
@@ -845,6 +846,14 @@
/// getDICompositeType - Find underlying composite type.
DICompositeType getDICompositeType(DIType T);
+ /// getOrInsertFnSpecificMDNode - Return a NameMDNode that is suitable
+ /// to hold function specific information.
+ NamedMDNode *getOrInsertFnSpecificMDNode(Module &M, StringRef Name);
+
+ /// getFnSpecificMDNode - Return a NameMDNode, if available, that is
+ /// suitable to hold function specific information.
+ NamedMDNode *getFnSpecificMDNode(const Module &M, StringRef Name);
+
class DebugInfoFinder {
public:
/// processModule - Process entire module and collect debug info
Modified: llvm/branches/Apple/whitney/lib/Analysis/DebugInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/whitney/lib/Analysis/DebugInfo.cpp?rev=119234&r1=119233&r2=119234&view=diff
==============================================================================
--- llvm/branches/Apple/whitney/lib/Analysis/DebugInfo.cpp (original)
+++ llvm/branches/Apple/whitney/lib/Analysis/DebugInfo.cpp Mon Nov 15 15:45:02 2010
@@ -1155,6 +1155,39 @@
return DIGlobalVariable(Node);
}
+/// fixupObjcLikeName - Replace contains special characters used
+/// in a typical Objective-C names with '.' in a given string.
+static void fixupObjcLikeName(std::string &Str) {
+ for (size_t i = 0, e = Str.size(); i < e; ++i) {
+ char C = Str[i];
+ if (C == '[' || C == ']' || C == ' ' || C == ':')
+ Str[i] = '.';
+ }
+}
+
+/// getOrInsertFnSpecificMDNode - Return a NameMDNode that is suitable
+/// to hold function specific information.
+NamedMDNode *llvm::getOrInsertFnSpecificMDNode(Module &M, StringRef FuncName) {
+ SmallString<32> Out;
+ if (FuncName.find('[') == StringRef::npos)
+ return M.getOrInsertNamedMetadata(Twine("llvm.dbg.lv.", FuncName)
+ .toStringRef(Out));
+ std::string Name = FuncName;
+ fixupObjcLikeName(Name);
+ return M.getOrInsertNamedMetadata(Twine("llvm.dbg.lv.", Name)
+ .toStringRef(Out));
+}
+
+/// getFnSpecificMDNode - Return a NameMDNode, if available, that is
+/// suitable to hold function specific information.
+NamedMDNode *llvm::getFnSpecificMDNode(const Module &M, StringRef FuncName) {
+ if (FuncName.find('[') == StringRef::npos)
+ return M.getNamedMetadata(Twine("llvm.dbg.lv.", FuncName));
+ std::string Name = FuncName;
+ fixupObjcLikeName(Name);
+ return M.getNamedMetadata(Twine("llvm.dbg.lv.", Name));
+}
+
/// CreateVariable - Create a new descriptor for the specified variable.
DIVariable DIFactory::CreateVariable(unsigned Tag, DIDescriptor Context,
StringRef Name,
@@ -1184,9 +1217,8 @@
if (FName.startswith(StringRef(&One, 1)))
FName = FName.substr(1);
- SmallString<32> Out;
- NamedMDNode *FnLocals =
- M.getOrInsertNamedMetadata(Twine("llvm.dbg.lv.", FName).toStringRef(Out));
+
+ NamedMDNode *FnLocals = getOrInsertFnSpecificMDNode(M, FName);
FnLocals->addOperand(Node);
}
return DIVariable(Node);
Modified: llvm/branches/Apple/whitney/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/whitney/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=119234&r1=119233&r2=119234&view=diff
==============================================================================
--- llvm/branches/Apple/whitney/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original)
+++ llvm/branches/Apple/whitney/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Mon Nov 15 15:45:02 2010
@@ -2129,8 +2129,7 @@
StringRef FName = SP.getLinkageName();
if (FName.empty())
FName = SP.getName();
- NamedMDNode *NMD =
- M->getNamedMetadata(Twine("llvm.dbg.lv.", getRealLinkageName(FName)));
+ NamedMDNode *NMD = getFnSpecificMDNode(*(MMI->getModule()), FName);
if (!NMD) continue;
unsigned E = NMD->getNumOperands();
if (!E) continue;
@@ -2423,10 +2422,7 @@
// Collect info for variables that were optimized out.
const Function *F = MF->getFunction();
- const Module *M = F->getParent();
- if (NamedMDNode *NMD =
- M->getNamedMetadata(Twine("llvm.dbg.lv.",
- getRealLinkageName(F->getName())))) {
+ if (NamedMDNode *NMD = getFnSpecificMDNode(*(F->getParent()), F->getName())) {
for (unsigned i = 0, e = NMD->getNumOperands(); i != e; ++i) {
DIVariable DV(cast<MDNode>(NMD->getOperand(i)));
if (!DV || !Processed.insert(DV))
@@ -2913,10 +2909,8 @@
StringRef FName = SP.getLinkageName();
if (FName.empty())
FName = SP.getName();
- const Module *M = MF->getFunction()->getParent();
- if (NamedMDNode *NMD =
- M->getNamedMetadata(Twine("llvm.dbg.lv.",
- getRealLinkageName(FName)))) {
+ if (NamedMDNode *NMD =
+ getFnSpecificMDNode(*(MF->getFunction()->getParent()), FName)) {
for (unsigned i = 0, e = NMD->getNumOperands(); i != e; ++i) {
DIVariable DV(cast<MDNode>(NMD->getOperand(i)));
if (!DV || !ProcessedVars.insert(DV))
More information about the llvm-branch-commits
mailing list