1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 11:02:59 +02:00

Do not rely on Twine temporaries to survive.

llvm-svn: 106515
This commit is contained in:
Devang Patel 2010-06-22 01:01:58 +00:00
parent 3de7445da3
commit dee41b010a
2 changed files with 8 additions and 7 deletions

View File

@ -1059,14 +1059,14 @@ DIVariable DIFactory::CreateVariable(unsigned Tag, DIDescriptor Context,
StringRef FName = "fn";
if (Fn.getFunction())
FName = Fn.getFunction()->getName();
const Twine FnLVName = Twine("llvm.dbg.lv.", FName);
char One = '\1';
if (FName.startswith(StringRef(&One, 1)))
FName = FName.substr(1);
NamedMDNode *FnLocals = M.getNamedMetadataUsingTwine(FnLVName);
NamedMDNode *FnLocals =
M.getNamedMetadataUsingTwine(Twine("llvm.dbg.lv.", FName));
if (!FnLocals)
FnLocals = NamedMDNode::Create(VMContext, FnLVName, NULL, 0, &M);
FnLocals = NamedMDNode::Create(VMContext, Twine("llvm.dbg.lv.", FName),
NULL, 0, &M);
FnLocals->addOperand(Node);
}
return DIVariable(Node);

View File

@ -2257,9 +2257,10 @@ void DwarfDebug::collectVariableInfo(const MachineFunction *MF) {
}
// Collect info for variables that were optimized out.
const Twine FnLVName = Twine("llvm.dbg.lv.", MF->getFunction()->getName());
if (NamedMDNode *NMD =
MF->getFunction()->getParent()->getNamedMetadataUsingTwine(FnLVName)) {
const Function *F = MF->getFunction();
const Module *M = F->getParent();
if (NamedMDNode *NMD =
M->getNamedMetadataUsingTwine(Twine("llvm.dbg.lv.", F->getName()))) {
for (unsigned i = 0, e = NMD->getNumOperands(); i != e; ++i) {
DIVariable DV(cast_or_null<MDNode>(NMD->getOperand(i)));
if (!DV || !Processed.insert(DV))