DIBuilder: Use Constant instead of Value

Make explicit the requirement that most IR values in `DIBuilder` are
`Constant`.  This requires a follow-up change in clang.

Part of PR21532.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@222070 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Duncan P. N. Exon Smith 2014-11-15 00:23:49 +00:00
parent d7e69b2a86
commit e7873018b5
2 changed files with 37 additions and 47 deletions

View File

@ -27,6 +27,7 @@ namespace llvm {
class Function;
class Module;
class Value;
class Constant;
class LLVMContext;
class MDNode;
class StringRef;
@ -211,10 +212,10 @@ namespace llvm {
/// @param Ty Type of the static member.
/// @param Flags Flags to encode member attribute, e.g. private.
/// @param Val Const initializer of the member.
DIDerivedType
createStaticMemberType(DIDescriptor Scope, StringRef Name,
DIFile File, unsigned LineNo, DIType Ty,
unsigned Flags, llvm::Value *Val);
DIDerivedType createStaticMemberType(DIDescriptor Scope, StringRef Name,
DIFile File, unsigned LineNo,
DIType Ty, unsigned Flags,
llvm::Constant *Val);
/// createObjCIVar - Create debugging information entry for Objective-C
/// instance variable.
@ -333,8 +334,8 @@ namespace llvm {
/// @param LineNo Line number.
/// @param ColumnNo Column Number.
DITemplateValueParameter
createTemplateValueParameter(DIDescriptor Scope, StringRef Name,
DIType Ty, Value *Val, MDNode *File = nullptr,
createTemplateValueParameter(DIDescriptor Scope, StringRef Name, DIType Ty,
Constant *Val, MDNode *File = nullptr,
unsigned LineNo = 0, unsigned ColumnNo = 0);
/// \brief Create debugging information for a template template parameter.
@ -458,21 +459,19 @@ namespace llvm {
/// externally visible or not.
/// @param Val llvm::Value of the variable.
/// @param Decl Reference to the corresponding declaration.
DIGlobalVariable
createGlobalVariable(DIDescriptor Context, StringRef Name,
StringRef LinkageName, DIFile File, unsigned LineNo,
DITypeRef Ty, bool isLocalToUnit, llvm::Value *Val,
MDNode *Decl = nullptr);
DIGlobalVariable createGlobalVariable(DIDescriptor Context, StringRef Name,
StringRef LinkageName, DIFile File,
unsigned LineNo, DITypeRef Ty,
bool isLocalToUnit,
llvm::Constant *Val,
MDNode *Decl = nullptr);
/// createTempGlobalVariableFwdDecl - Identical to createGlobalVariable
/// except that the resulting DbgNode is temporary and meant to be RAUWed.
DIGlobalVariable
createTempGlobalVariableFwdDecl(DIDescriptor Context, StringRef Name,
StringRef LinkageName, DIFile File,
unsigned LineNo, DITypeRef Ty,
bool isLocalToUnit, llvm::Value *Val,
MDNode *Decl = nullptr);
DIGlobalVariable createTempGlobalVariableFwdDecl(
DIDescriptor Context, StringRef Name, StringRef LinkageName,
DIFile File, unsigned LineNo, DITypeRef Ty, bool isLocalToUnit,
llvm::Constant *Val, MDNode *Decl = nullptr);
/// createLocalVariable - Create a new descriptor for the specified
/// local variable.

View File

@ -406,11 +406,11 @@ DIDerivedType DIBuilder::createMemberType(DIDescriptor Scope, StringRef Name,
return DIDerivedType(MDNode::get(VMContext, Elts));
}
DIDerivedType
DIBuilder::createStaticMemberType(DIDescriptor Scope, StringRef Name,
DIFile File, unsigned LineNumber,
DIType Ty, unsigned Flags,
llvm::Value *Val) {
DIDerivedType DIBuilder::createStaticMemberType(DIDescriptor Scope,
StringRef Name, DIFile File,
unsigned LineNumber, DIType Ty,
unsigned Flags,
llvm::Constant *Val) {
// TAG_member is encoded in DIDerivedType format.
Flags |= DIDescriptor::FlagStaticMember;
Value *Elts[] = {HeaderBuilder::get(dwarf::DW_TAG_member)
@ -489,9 +489,8 @@ static DITemplateValueParameter createTemplateValueParameterHelper(
DITemplateValueParameter
DIBuilder::createTemplateValueParameter(DIDescriptor Context, StringRef Name,
DIType Ty, Value *Val,
MDNode *File, unsigned LineNo,
unsigned ColumnNo) {
DIType Ty, Constant *Val, MDNode *File,
unsigned LineNo, unsigned ColumnNo) {
return createTemplateValueParameterHelper(
VMContext, dwarf::DW_TAG_template_value_parameter, Context, Name, Ty, Val,
File, LineNo, ColumnNo);
@ -832,12 +831,11 @@ DISubrange DIBuilder::getOrCreateSubrange(int64_t Lo, int64_t Count) {
return DISubrange(MDNode::get(VMContext, Elts));
}
static DIGlobalVariable
createGlobalVariableHelper(LLVMContext &VMContext, DIDescriptor Context,
StringRef Name, StringRef LinkageName, DIFile F,
unsigned LineNumber, DITypeRef Ty, bool isLocalToUnit,
Value *Val, MDNode *Decl, bool isDefinition,
std::function<MDNode *(ArrayRef<Value *>)> CreateFunc) {
static DIGlobalVariable createGlobalVariableHelper(
LLVMContext &VMContext, DIDescriptor Context, StringRef Name,
StringRef LinkageName, DIFile F, unsigned LineNumber, DITypeRef Ty,
bool isLocalToUnit, Constant *Val, MDNode *Decl, bool isDefinition,
std::function<MDNode *(ArrayRef<Value *>)> CreateFunc) {
Value *Elts[] = {HeaderBuilder::get(dwarf::DW_TAG_variable)
.concat(Name)
.concat(Name)
@ -852,13 +850,10 @@ createGlobalVariableHelper(LLVMContext &VMContext, DIDescriptor Context,
return DIGlobalVariable(CreateFunc(Elts));
}
DIGlobalVariable DIBuilder::createGlobalVariable(DIDescriptor Context,
StringRef Name,
StringRef LinkageName,
DIFile F, unsigned LineNumber,
DITypeRef Ty,
bool isLocalToUnit,
Value *Val, MDNode *Decl) {
DIGlobalVariable DIBuilder::createGlobalVariable(
DIDescriptor Context, StringRef Name, StringRef LinkageName, DIFile F,
unsigned LineNumber, DITypeRef Ty, bool isLocalToUnit, Constant *Val,
MDNode *Decl) {
return createGlobalVariableHelper(VMContext, Context, Name, LinkageName, F,
LineNumber, Ty, isLocalToUnit, Val, Decl, true,
[&] (ArrayRef<Value *> Elts) -> MDNode * {
@ -868,14 +863,10 @@ DIGlobalVariable DIBuilder::createGlobalVariable(DIDescriptor Context,
});
}
DIGlobalVariable
DIBuilder::createTempGlobalVariableFwdDecl(DIDescriptor Context,
StringRef Name,
StringRef LinkageName,
DIFile F, unsigned LineNumber,
DITypeRef Ty,
bool isLocalToUnit,
Value *Val, MDNode *Decl) {
DIGlobalVariable DIBuilder::createTempGlobalVariableFwdDecl(
DIDescriptor Context, StringRef Name, StringRef LinkageName, DIFile F,
unsigned LineNumber, DITypeRef Ty, bool isLocalToUnit, Constant *Val,
MDNode *Decl) {
return createGlobalVariableHelper(VMContext, Context, Name, LinkageName, F,
LineNumber, Ty, isLocalToUnit, Val, Decl, false,
[&] (ArrayRef<Value *> Elts) {