mirror of
https://github.com/RPCS3/llvm.git
synced 2025-01-01 17:28:21 +00:00
Add DIBuilder functions to build RAUWable DIVariables and DIFunctions.
Summary: These will be used to implement support for useful forward declarartions. Reviewers: echristo, dblaikie, aprantl Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D5328 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@217949 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
c63035aa56
commit
2ca5f03112
@ -521,6 +521,15 @@ namespace llvm {
|
|||||||
DITypeRef Ty, bool isLocalToUnit, llvm::Value *Val,
|
DITypeRef Ty, bool isLocalToUnit, llvm::Value *Val,
|
||||||
MDNode *Decl = nullptr);
|
MDNode *Decl = nullptr);
|
||||||
|
|
||||||
|
/// createTempStaticVariableFwdDecl - Identical to createStaticVariable
|
||||||
|
/// except that the resulting DbgNode is temporary and meant to be RAUWed.
|
||||||
|
DIGlobalVariable
|
||||||
|
createTempStaticVariableFwdDecl(DIDescriptor Context, StringRef Name,
|
||||||
|
StringRef LinkageName, DIFile File,
|
||||||
|
unsigned LineNo, DITypeRef Ty,
|
||||||
|
bool isLocalToUnit, llvm::Value *Val,
|
||||||
|
MDNode *Decl = nullptr);
|
||||||
|
|
||||||
|
|
||||||
/// createLocalVariable - Create a new descriptor for the specified
|
/// createLocalVariable - Create a new descriptor for the specified
|
||||||
/// local variable.
|
/// local variable.
|
||||||
@ -599,6 +608,21 @@ namespace llvm {
|
|||||||
MDNode *TParam = nullptr,
|
MDNode *TParam = nullptr,
|
||||||
MDNode *Decl = nullptr);
|
MDNode *Decl = nullptr);
|
||||||
|
|
||||||
|
/// createTempFunctionFwdDecl - Identical to createFunction,
|
||||||
|
/// except that the resulting DbgNode is meant to be RAUWed.
|
||||||
|
DISubprogram createTempFunctionFwdDecl(DIDescriptor Scope, StringRef Name,
|
||||||
|
StringRef LinkageName,
|
||||||
|
DIFile File, unsigned LineNo,
|
||||||
|
DICompositeType Ty, bool isLocalToUnit,
|
||||||
|
bool isDefinition,
|
||||||
|
unsigned ScopeLine,
|
||||||
|
unsigned Flags = 0,
|
||||||
|
bool isOptimized = false,
|
||||||
|
Function *Fn = nullptr,
|
||||||
|
MDNode *TParam = nullptr,
|
||||||
|
MDNode *Decl = nullptr);
|
||||||
|
|
||||||
|
|
||||||
/// FIXME: this is added for dragonegg. Once we update dragonegg
|
/// FIXME: this is added for dragonegg. Once we update dragonegg
|
||||||
/// to call resolve function, this will be removed.
|
/// to call resolve function, this will be removed.
|
||||||
DISubprogram createFunction(DIScopeRef Scope, StringRef Name,
|
DISubprogram createFunction(DIScopeRef Scope, StringRef Name,
|
||||||
@ -731,7 +755,6 @@ namespace llvm {
|
|||||||
Instruction *insertDbgValueIntrinsic(llvm::Value *Val, uint64_t Offset,
|
Instruction *insertDbgValueIntrinsic(llvm::Value *Val, uint64_t Offset,
|
||||||
DIVariable VarInfo,
|
DIVariable VarInfo,
|
||||||
Instruction *InsertBefore);
|
Instruction *InsertBefore);
|
||||||
|
|
||||||
};
|
};
|
||||||
} // end namespace llvm
|
} // end namespace llvm
|
||||||
|
|
||||||
|
@ -1012,15 +1012,12 @@ DIGlobalVariable DIBuilder::createGlobalVariable(StringRef Name, DIFile F,
|
|||||||
Val);
|
Val);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// createStaticVariable - Create a new descriptor for the specified static
|
static DIGlobalVariable
|
||||||
/// variable.
|
createStaticVariableHelper(LLVMContext &VMContext, DIDescriptor Context,
|
||||||
DIGlobalVariable DIBuilder::createStaticVariable(DIDescriptor Context,
|
StringRef Name, StringRef LinkageName, DIFile F,
|
||||||
StringRef Name,
|
unsigned LineNumber, DITypeRef Ty, bool isLocalToUnit,
|
||||||
StringRef LinkageName,
|
Value *Val, MDNode *Decl, bool isDefinition,
|
||||||
DIFile F, unsigned LineNumber,
|
std::function<MDNode *(ArrayRef<Value *>)> CreateFunc) {
|
||||||
DITypeRef Ty,
|
|
||||||
bool isLocalToUnit,
|
|
||||||
Value *Val, MDNode *Decl) {
|
|
||||||
Value *Elts[] = {
|
Value *Elts[] = {
|
||||||
GetTagConstant(VMContext, dwarf::DW_TAG_variable),
|
GetTagConstant(VMContext, dwarf::DW_TAG_variable),
|
||||||
Constant::getNullValue(Type::getInt32Ty(VMContext)),
|
Constant::getNullValue(Type::getInt32Ty(VMContext)),
|
||||||
@ -1032,13 +1029,47 @@ DIGlobalVariable DIBuilder::createStaticVariable(DIDescriptor Context,
|
|||||||
ConstantInt::get(Type::getInt32Ty(VMContext), LineNumber),
|
ConstantInt::get(Type::getInt32Ty(VMContext), LineNumber),
|
||||||
Ty,
|
Ty,
|
||||||
ConstantInt::get(Type::getInt32Ty(VMContext), isLocalToUnit),
|
ConstantInt::get(Type::getInt32Ty(VMContext), isLocalToUnit),
|
||||||
ConstantInt::get(Type::getInt32Ty(VMContext), 1), /* isDefinition*/
|
ConstantInt::get(Type::getInt32Ty(VMContext), isDefinition),
|
||||||
Val,
|
Val,
|
||||||
DIDescriptor(Decl)
|
DIDescriptor(Decl)
|
||||||
};
|
};
|
||||||
MDNode *Node = MDNode::get(VMContext, Elts);
|
|
||||||
AllGVs.push_back(Node);
|
return DIGlobalVariable(CreateFunc(Elts));
|
||||||
return DIGlobalVariable(Node);
|
}
|
||||||
|
|
||||||
|
/// createStaticVariable - Create a new descriptor for the specified
|
||||||
|
/// variable.
|
||||||
|
DIGlobalVariable DIBuilder::createStaticVariable(DIDescriptor Context,
|
||||||
|
StringRef Name,
|
||||||
|
StringRef LinkageName,
|
||||||
|
DIFile F, unsigned LineNumber,
|
||||||
|
DITypeRef Ty,
|
||||||
|
bool isLocalToUnit,
|
||||||
|
Value *Val, MDNode *Decl) {
|
||||||
|
return createStaticVariableHelper(VMContext, Context, Name, LinkageName, F,
|
||||||
|
LineNumber, Ty, isLocalToUnit, Val, Decl, true,
|
||||||
|
[&] (ArrayRef<Value *> Elts) -> MDNode * {
|
||||||
|
MDNode *Node = MDNode::get(VMContext, Elts);
|
||||||
|
AllGVs.push_back(Node);
|
||||||
|
return Node;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/// createTempStaticVariableFwdDecl - Create a new temporary descriptor for the
|
||||||
|
/// specified variable declarartion.
|
||||||
|
DIGlobalVariable
|
||||||
|
DIBuilder::createTempStaticVariableFwdDecl(DIDescriptor Context,
|
||||||
|
StringRef Name,
|
||||||
|
StringRef LinkageName,
|
||||||
|
DIFile F, unsigned LineNumber,
|
||||||
|
DITypeRef Ty,
|
||||||
|
bool isLocalToUnit,
|
||||||
|
Value *Val, MDNode *Decl) {
|
||||||
|
return createStaticVariableHelper(VMContext, Context, Name, LinkageName, F,
|
||||||
|
LineNumber, Ty, isLocalToUnit, Val, Decl, false,
|
||||||
|
[&] (ArrayRef<Value *> Elts) {
|
||||||
|
return MDNode::getTemporary(VMContext, Elts);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/// createVariable - Create a new descriptor for the specified variable.
|
/// createVariable - Create a new descriptor for the specified variable.
|
||||||
@ -1139,14 +1170,13 @@ DISubprogram DIBuilder::createFunction(DIScopeRef Context, StringRef Name,
|
|||||||
Flags, isOptimized, Fn, TParams, Decl);
|
Flags, isOptimized, Fn, TParams, Decl);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// createFunction - Create a new descriptor for the specified function.
|
static DISubprogram
|
||||||
DISubprogram DIBuilder::createFunction(DIDescriptor Context, StringRef Name,
|
createFunctionHelper(LLVMContext &VMContext, DIDescriptor Context, StringRef Name,
|
||||||
StringRef LinkageName, DIFile File,
|
StringRef LinkageName, DIFile File, unsigned LineNo,
|
||||||
unsigned LineNo, DICompositeType Ty,
|
DICompositeType Ty, bool isLocalToUnit, bool isDefinition,
|
||||||
bool isLocalToUnit, bool isDefinition,
|
unsigned ScopeLine, unsigned Flags, bool isOptimized,
|
||||||
unsigned ScopeLine, unsigned Flags,
|
Function *Fn, MDNode *TParams, MDNode *Decl,
|
||||||
bool isOptimized, Function *Fn,
|
std::function<MDNode *(ArrayRef<Value *>)> CreateFunc) {
|
||||||
MDNode *TParams, MDNode *Decl) {
|
|
||||||
assert(Ty.getTag() == dwarf::DW_TAG_subroutine_type &&
|
assert(Ty.getTag() == dwarf::DW_TAG_subroutine_type &&
|
||||||
"function types should be subroutines");
|
"function types should be subroutines");
|
||||||
Value *TElts[] = { GetTagConstant(VMContext, DW_TAG_base_type) };
|
Value *TElts[] = { GetTagConstant(VMContext, DW_TAG_base_type) };
|
||||||
@ -1172,17 +1202,53 @@ DISubprogram DIBuilder::createFunction(DIDescriptor Context, StringRef Name,
|
|||||||
MDNode::getTemporary(VMContext, TElts),
|
MDNode::getTemporary(VMContext, TElts),
|
||||||
ConstantInt::get(Type::getInt32Ty(VMContext), ScopeLine)
|
ConstantInt::get(Type::getInt32Ty(VMContext), ScopeLine)
|
||||||
};
|
};
|
||||||
MDNode *Node = MDNode::get(VMContext, Elts);
|
|
||||||
|
|
||||||
// Create a named metadata so that we do not lose this mdnode.
|
DISubprogram S(CreateFunc(Elts));
|
||||||
if (isDefinition)
|
|
||||||
AllSubprograms.push_back(Node);
|
|
||||||
DISubprogram S(Node);
|
|
||||||
assert(S.isSubprogram() &&
|
assert(S.isSubprogram() &&
|
||||||
"createFunction should return a valid DISubprogram");
|
"createFunction should return a valid DISubprogram");
|
||||||
return S;
|
return S;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// createFunction - Create a new descriptor for the specified function.
|
||||||
|
DISubprogram DIBuilder::createFunction(DIDescriptor Context, StringRef Name,
|
||||||
|
StringRef LinkageName, DIFile File,
|
||||||
|
unsigned LineNo, DICompositeType Ty,
|
||||||
|
bool isLocalToUnit, bool isDefinition,
|
||||||
|
unsigned ScopeLine, unsigned Flags,
|
||||||
|
bool isOptimized, Function *Fn,
|
||||||
|
MDNode *TParams, MDNode *Decl) {
|
||||||
|
return createFunctionHelper(VMContext, Context, Name, LinkageName, File,
|
||||||
|
LineNo, Ty, isLocalToUnit, isDefinition, ScopeLine,
|
||||||
|
Flags, isOptimized, Fn, TParams, Decl,
|
||||||
|
[&] (ArrayRef<Value *> Elts) -> MDNode *{
|
||||||
|
MDNode *Node = MDNode::get(VMContext, Elts);
|
||||||
|
// Create a named metadata so that we
|
||||||
|
// do not lose this mdnode.
|
||||||
|
if (isDefinition)
|
||||||
|
AllSubprograms.push_back(Node);
|
||||||
|
return Node;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/// createTempFunctionFwdDecl - Create a new temporary descriptor for
|
||||||
|
/// the specified function declaration.
|
||||||
|
DISubprogram
|
||||||
|
DIBuilder::createTempFunctionFwdDecl(DIDescriptor Context, StringRef Name,
|
||||||
|
StringRef LinkageName, DIFile File,
|
||||||
|
unsigned LineNo, DICompositeType Ty,
|
||||||
|
bool isLocalToUnit, bool isDefinition,
|
||||||
|
unsigned ScopeLine, unsigned Flags,
|
||||||
|
bool isOptimized, Function *Fn,
|
||||||
|
MDNode *TParams, MDNode *Decl) {
|
||||||
|
return createFunctionHelper(VMContext, Context, Name, LinkageName, File,
|
||||||
|
LineNo, Ty, isLocalToUnit, isDefinition, ScopeLine,
|
||||||
|
Flags, isOptimized, Fn, TParams, Decl,
|
||||||
|
[&] (ArrayRef<Value *> Elts) {
|
||||||
|
return MDNode::getTemporary(VMContext, Elts);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/// createMethod - Create a new descriptor for the specified C++ method.
|
/// createMethod - Create a new descriptor for the specified C++ method.
|
||||||
DISubprogram DIBuilder::createMethod(DIDescriptor Context, StringRef Name,
|
DISubprogram DIBuilder::createMethod(DIDescriptor Context, StringRef Name,
|
||||||
StringRef LinkageName, DIFile F,
|
StringRef LinkageName, DIFile F,
|
||||||
|
Loading…
Reference in New Issue
Block a user