mirror of
https://github.com/RPCSX/llvm.git
synced 2025-01-08 21:10:31 +00:00
Revert part of r74873 that broke Clang's debug info generation.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74910 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
640dd26f7d
commit
e277fed6eb
@ -18,7 +18,6 @@
|
||||
#include "llvm/Intrinsics.h"
|
||||
#include "llvm/IntrinsicInst.h"
|
||||
#include "llvm/Instructions.h"
|
||||
#include "llvm/LLVMContext.h"
|
||||
#include "llvm/Module.h"
|
||||
#include "llvm/Analysis/ValueTracking.h"
|
||||
#include "llvm/Support/Dwarf.h"
|
||||
@ -456,15 +455,14 @@ void DIVariable::dump() const {
|
||||
DIFactory::DIFactory(Module &m)
|
||||
: M(m), StopPointFn(0), FuncStartFn(0), RegionStartFn(0), RegionEndFn(0),
|
||||
DeclareFn(0) {
|
||||
EmptyStructPtr =
|
||||
M.getContext().getPointerTypeUnqual(M.getContext().getStructType());
|
||||
EmptyStructPtr = PointerType::getUnqual(StructType::get());
|
||||
}
|
||||
|
||||
/// getCastToEmpty - Return this descriptor as a Constant* with type '{}*'.
|
||||
/// This is only valid when the descriptor is non-null.
|
||||
Constant *DIFactory::getCastToEmpty(DIDescriptor D) {
|
||||
if (D.isNull()) return M.getContext().getNullValue(EmptyStructPtr);
|
||||
return M.getContext().getConstantExprBitCast(D.getGV(), EmptyStructPtr);
|
||||
if (D.isNull()) return Constant::getNullValue(EmptyStructPtr);
|
||||
return ConstantExpr::getBitCast(D.getGV(), EmptyStructPtr);
|
||||
}
|
||||
|
||||
Constant *DIFactory::GetTagConstant(unsigned TAG) {
|
||||
@ -480,21 +478,21 @@ Constant *DIFactory::GetStringConstant(const std::string &String) {
|
||||
// Return Constant if previously defined.
|
||||
if (Slot) return Slot;
|
||||
|
||||
const PointerType *DestTy = M.getContext().getPointerTypeUnqual(Type::Int8Ty);
|
||||
const PointerType *DestTy = PointerType::getUnqual(Type::Int8Ty);
|
||||
|
||||
// If empty string then use a i8* null instead.
|
||||
if (String.empty())
|
||||
return Slot = M.getContext().getConstantPointerNull(DestTy);
|
||||
return Slot = ConstantPointerNull::get(DestTy);
|
||||
|
||||
// Construct string as an llvm constant.
|
||||
Constant *ConstStr = M.getContext().getConstantArray(String);
|
||||
Constant *ConstStr = ConstantArray::get(String);
|
||||
|
||||
// Otherwise create and return a new string global.
|
||||
GlobalVariable *StrGV = new GlobalVariable(ConstStr->getType(), true,
|
||||
GlobalVariable::InternalLinkage,
|
||||
ConstStr, ".str", &M);
|
||||
StrGV->setSection("llvm.metadata");
|
||||
return Slot = M.getContext().getConstantExprBitCast(StrGV, DestTy);
|
||||
return Slot = ConstantExpr::getBitCast(StrGV, DestTy);
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
@ -506,12 +504,10 @@ Constant *DIFactory::GetStringConstant(const std::string &String) {
|
||||
DIArray DIFactory::GetOrCreateArray(DIDescriptor *Tys, unsigned NumTys) {
|
||||
SmallVector<Constant*, 16> Elts;
|
||||
|
||||
LLVMContext& Ctxt = M.getContext();
|
||||
|
||||
for (unsigned i = 0; i != NumTys; ++i)
|
||||
Elts.push_back(getCastToEmpty(Tys[i]));
|
||||
|
||||
Constant *Init = Ctxt.getConstantArray(Ctxt.getArrayType(EmptyStructPtr,
|
||||
Constant *Init = ConstantArray::get(ArrayType::get(EmptyStructPtr,
|
||||
Elts.size()),
|
||||
Elts.data(), Elts.size());
|
||||
// If we already have this array, just return the uniqued version.
|
||||
@ -531,12 +527,11 @@ DIArray DIFactory::GetOrCreateArray(DIDescriptor *Tys, unsigned NumTys) {
|
||||
DISubrange DIFactory::GetOrCreateSubrange(int64_t Lo, int64_t Hi) {
|
||||
Constant *Elts[] = {
|
||||
GetTagConstant(dwarf::DW_TAG_subrange_type),
|
||||
M.getContext().getConstantInt(Type::Int64Ty, Lo),
|
||||
M.getContext().getConstantInt(Type::Int64Ty, Hi)
|
||||
ConstantInt::get(Type::Int64Ty, Lo),
|
||||
ConstantInt::get(Type::Int64Ty, Hi)
|
||||
};
|
||||
|
||||
Constant *Init =
|
||||
M.getContext().getConstantStruct(Elts, sizeof(Elts)/sizeof(Elts[0]));
|
||||
Constant *Init = ConstantStruct::get(Elts, sizeof(Elts)/sizeof(Elts[0]));
|
||||
|
||||
// If we already have this range, just return the uniqued version.
|
||||
DIDescriptor &Entry = SimpleConstantCache[Init];
|
||||
@ -564,22 +559,20 @@ DICompileUnit DIFactory::CreateCompileUnit(unsigned LangID,
|
||||
bool isOptimized,
|
||||
const char *Flags,
|
||||
unsigned RunTimeVer) {
|
||||
LLVMContext& Ctxt = M.getContext();
|
||||
Constant *Elts[] = {
|
||||
GetTagConstant(dwarf::DW_TAG_compile_unit),
|
||||
Ctxt.getNullValue(EmptyStructPtr),
|
||||
Ctxt.getConstantInt(Type::Int32Ty, LangID),
|
||||
Constant::getNullValue(EmptyStructPtr),
|
||||
ConstantInt::get(Type::Int32Ty, LangID),
|
||||
GetStringConstant(Filename),
|
||||
GetStringConstant(Directory),
|
||||
GetStringConstant(Producer),
|
||||
Ctxt.getConstantInt(Type::Int1Ty, isMain),
|
||||
Ctxt.getConstantInt(Type::Int1Ty, isOptimized),
|
||||
ConstantInt::get(Type::Int1Ty, isMain),
|
||||
ConstantInt::get(Type::Int1Ty, isOptimized),
|
||||
GetStringConstant(Flags),
|
||||
Ctxt.getConstantInt(Type::Int32Ty, RunTimeVer)
|
||||
ConstantInt::get(Type::Int32Ty, RunTimeVer)
|
||||
};
|
||||
|
||||
Constant *Init =
|
||||
Ctxt.getConstantStruct(Elts, sizeof(Elts)/sizeof(Elts[0]));
|
||||
Constant *Init = ConstantStruct::get(Elts, sizeof(Elts)/sizeof(Elts[0]));
|
||||
|
||||
M.addTypeName("llvm.dbg.compile_unit.type", Init->getType());
|
||||
GlobalVariable *GV = new GlobalVariable(Init->getType(), true,
|
||||
@ -594,11 +587,10 @@ DIEnumerator DIFactory::CreateEnumerator(const std::string &Name, uint64_t Val){
|
||||
Constant *Elts[] = {
|
||||
GetTagConstant(dwarf::DW_TAG_enumerator),
|
||||
GetStringConstant(Name),
|
||||
M.getContext().getConstantInt(Type::Int64Ty, Val)
|
||||
ConstantInt::get(Type::Int64Ty, Val)
|
||||
};
|
||||
|
||||
Constant *Init =
|
||||
M.getContext().getConstantStruct(Elts, sizeof(Elts)/sizeof(Elts[0]));
|
||||
Constant *Init = ConstantStruct::get(Elts, sizeof(Elts)/sizeof(Elts[0]));
|
||||
|
||||
M.addTypeName("llvm.dbg.enumerator.type", Init->getType());
|
||||
GlobalVariable *GV = new GlobalVariable(Init->getType(), true,
|
||||
@ -618,23 +610,20 @@ DIBasicType DIFactory::CreateBasicType(DIDescriptor Context,
|
||||
uint64_t AlignInBits,
|
||||
uint64_t OffsetInBits, unsigned Flags,
|
||||
unsigned Encoding) {
|
||||
|
||||
LLVMContext& Ctxt = M.getContext();
|
||||
Constant *Elts[] = {
|
||||
GetTagConstant(dwarf::DW_TAG_base_type),
|
||||
getCastToEmpty(Context),
|
||||
GetStringConstant(Name),
|
||||
getCastToEmpty(CompileUnit),
|
||||
Ctxt.getConstantInt(Type::Int32Ty, LineNumber),
|
||||
Ctxt.getConstantInt(Type::Int64Ty, SizeInBits),
|
||||
Ctxt.getConstantInt(Type::Int64Ty, AlignInBits),
|
||||
Ctxt.getConstantInt(Type::Int64Ty, OffsetInBits),
|
||||
Ctxt.getConstantInt(Type::Int32Ty, Flags),
|
||||
Ctxt.getConstantInt(Type::Int32Ty, Encoding)
|
||||
ConstantInt::get(Type::Int32Ty, LineNumber),
|
||||
ConstantInt::get(Type::Int64Ty, SizeInBits),
|
||||
ConstantInt::get(Type::Int64Ty, AlignInBits),
|
||||
ConstantInt::get(Type::Int64Ty, OffsetInBits),
|
||||
ConstantInt::get(Type::Int32Ty, Flags),
|
||||
ConstantInt::get(Type::Int32Ty, Encoding)
|
||||
};
|
||||
|
||||
Constant *Init =
|
||||
Ctxt.getConstantStruct(Elts, sizeof(Elts)/sizeof(Elts[0]));
|
||||
Constant *Init = ConstantStruct::get(Elts, sizeof(Elts)/sizeof(Elts[0]));
|
||||
|
||||
M.addTypeName("llvm.dbg.basictype.type", Init->getType());
|
||||
GlobalVariable *GV = new GlobalVariable(Init->getType(), true,
|
||||
@ -656,23 +645,20 @@ DIDerivedType DIFactory::CreateDerivedType(unsigned Tag,
|
||||
uint64_t OffsetInBits,
|
||||
unsigned Flags,
|
||||
DIType DerivedFrom) {
|
||||
|
||||
LLVMContext& Ctxt = M.getContext();
|
||||
Constant *Elts[] = {
|
||||
GetTagConstant(Tag),
|
||||
getCastToEmpty(Context),
|
||||
GetStringConstant(Name),
|
||||
getCastToEmpty(CompileUnit),
|
||||
Ctxt.getConstantInt(Type::Int32Ty, LineNumber),
|
||||
Ctxt.getConstantInt(Type::Int64Ty, SizeInBits),
|
||||
Ctxt.getConstantInt(Type::Int64Ty, AlignInBits),
|
||||
Ctxt.getConstantInt(Type::Int64Ty, OffsetInBits),
|
||||
Ctxt.getConstantInt(Type::Int32Ty, Flags),
|
||||
ConstantInt::get(Type::Int32Ty, LineNumber),
|
||||
ConstantInt::get(Type::Int64Ty, SizeInBits),
|
||||
ConstantInt::get(Type::Int64Ty, AlignInBits),
|
||||
ConstantInt::get(Type::Int64Ty, OffsetInBits),
|
||||
ConstantInt::get(Type::Int32Ty, Flags),
|
||||
getCastToEmpty(DerivedFrom)
|
||||
};
|
||||
|
||||
Constant *Init =
|
||||
Ctxt.getConstantStruct(Elts, sizeof(Elts)/sizeof(Elts[0]));
|
||||
Constant *Init = ConstantStruct::get(Elts, sizeof(Elts)/sizeof(Elts[0]));
|
||||
|
||||
M.addTypeName("llvm.dbg.derivedtype.type", Init->getType());
|
||||
GlobalVariable *GV = new GlobalVariable(Init->getType(), true,
|
||||
@ -695,24 +681,23 @@ DICompositeType DIFactory::CreateCompositeType(unsigned Tag,
|
||||
DIType DerivedFrom,
|
||||
DIArray Elements,
|
||||
unsigned RuntimeLang) {
|
||||
LLVMContext& Ctxt = M.getContext();
|
||||
|
||||
Constant *Elts[] = {
|
||||
GetTagConstant(Tag),
|
||||
getCastToEmpty(Context),
|
||||
GetStringConstant(Name),
|
||||
getCastToEmpty(CompileUnit),
|
||||
Ctxt.getConstantInt(Type::Int32Ty, LineNumber),
|
||||
Ctxt.getConstantInt(Type::Int64Ty, SizeInBits),
|
||||
Ctxt.getConstantInt(Type::Int64Ty, AlignInBits),
|
||||
Ctxt.getConstantInt(Type::Int64Ty, OffsetInBits),
|
||||
Ctxt.getConstantInt(Type::Int32Ty, Flags),
|
||||
ConstantInt::get(Type::Int32Ty, LineNumber),
|
||||
ConstantInt::get(Type::Int64Ty, SizeInBits),
|
||||
ConstantInt::get(Type::Int64Ty, AlignInBits),
|
||||
ConstantInt::get(Type::Int64Ty, OffsetInBits),
|
||||
ConstantInt::get(Type::Int32Ty, Flags),
|
||||
getCastToEmpty(DerivedFrom),
|
||||
getCastToEmpty(Elements),
|
||||
Ctxt.getConstantInt(Type::Int32Ty, RuntimeLang)
|
||||
ConstantInt::get(Type::Int32Ty, RuntimeLang)
|
||||
};
|
||||
|
||||
Constant *Init =
|
||||
Ctxt.getConstantStruct(Elts, sizeof(Elts)/sizeof(Elts[0]));
|
||||
Constant *Init = ConstantStruct::get(Elts, sizeof(Elts)/sizeof(Elts[0]));
|
||||
|
||||
M.addTypeName("llvm.dbg.composite.type", Init->getType());
|
||||
GlobalVariable *GV = new GlobalVariable(Init->getType(), true,
|
||||
@ -735,23 +720,21 @@ DISubprogram DIFactory::CreateSubprogram(DIDescriptor Context,
|
||||
bool isLocalToUnit,
|
||||
bool isDefinition) {
|
||||
|
||||
LLVMContext& Ctxt = M.getContext();
|
||||
Constant *Elts[] = {
|
||||
GetTagConstant(dwarf::DW_TAG_subprogram),
|
||||
Ctxt.getNullValue(EmptyStructPtr),
|
||||
Constant::getNullValue(EmptyStructPtr),
|
||||
getCastToEmpty(Context),
|
||||
GetStringConstant(Name),
|
||||
GetStringConstant(DisplayName),
|
||||
GetStringConstant(LinkageName),
|
||||
getCastToEmpty(CompileUnit),
|
||||
Ctxt.getConstantInt(Type::Int32Ty, LineNo),
|
||||
ConstantInt::get(Type::Int32Ty, LineNo),
|
||||
getCastToEmpty(Type),
|
||||
Ctxt.getConstantInt(Type::Int1Ty, isLocalToUnit),
|
||||
Ctxt.getConstantInt(Type::Int1Ty, isDefinition)
|
||||
ConstantInt::get(Type::Int1Ty, isLocalToUnit),
|
||||
ConstantInt::get(Type::Int1Ty, isDefinition)
|
||||
};
|
||||
|
||||
Constant *Init =
|
||||
Ctxt.getConstantStruct(Elts, sizeof(Elts)/sizeof(Elts[0]));
|
||||
Constant *Init = ConstantStruct::get(Elts, sizeof(Elts)/sizeof(Elts[0]));
|
||||
|
||||
M.addTypeName("llvm.dbg.subprogram.type", Init->getType());
|
||||
GlobalVariable *GV = new GlobalVariable(Init->getType(), true,
|
||||
@ -769,25 +752,22 @@ DIFactory::CreateGlobalVariable(DIDescriptor Context, const std::string &Name,
|
||||
DICompileUnit CompileUnit,
|
||||
unsigned LineNo, DIType Type,bool isLocalToUnit,
|
||||
bool isDefinition, llvm::GlobalVariable *Val) {
|
||||
|
||||
LLVMContext& Ctxt = M.getContext();
|
||||
Constant *Elts[] = {
|
||||
GetTagConstant(dwarf::DW_TAG_variable),
|
||||
Ctxt.getNullValue(EmptyStructPtr),
|
||||
Constant::getNullValue(EmptyStructPtr),
|
||||
getCastToEmpty(Context),
|
||||
GetStringConstant(Name),
|
||||
GetStringConstant(DisplayName),
|
||||
GetStringConstant(LinkageName),
|
||||
getCastToEmpty(CompileUnit),
|
||||
Ctxt.getConstantInt(Type::Int32Ty, LineNo),
|
||||
ConstantInt::get(Type::Int32Ty, LineNo),
|
||||
getCastToEmpty(Type),
|
||||
Ctxt.getConstantInt(Type::Int1Ty, isLocalToUnit),
|
||||
Ctxt.getConstantInt(Type::Int1Ty, isDefinition),
|
||||
Ctxt.getConstantExprBitCast(Val, EmptyStructPtr)
|
||||
ConstantInt::get(Type::Int1Ty, isLocalToUnit),
|
||||
ConstantInt::get(Type::Int1Ty, isDefinition),
|
||||
ConstantExpr::getBitCast(Val, EmptyStructPtr)
|
||||
};
|
||||
|
||||
Constant *Init =
|
||||
Ctxt.getConstantStruct(Elts, sizeof(Elts)/sizeof(Elts[0]));
|
||||
Constant *Init = ConstantStruct::get(Elts, sizeof(Elts)/sizeof(Elts[0]));
|
||||
|
||||
M.addTypeName("llvm.dbg.global_variable.type", Init->getType());
|
||||
GlobalVariable *GV = new GlobalVariable(Init->getType(), true,
|
||||
@ -803,19 +783,16 @@ DIVariable DIFactory::CreateVariable(unsigned Tag, DIDescriptor Context,
|
||||
const std::string &Name,
|
||||
DICompileUnit CompileUnit, unsigned LineNo,
|
||||
DIType Type) {
|
||||
LLVMContext& Ctxt = M.getContext();
|
||||
|
||||
Constant *Elts[] = {
|
||||
GetTagConstant(Tag),
|
||||
getCastToEmpty(Context),
|
||||
GetStringConstant(Name),
|
||||
getCastToEmpty(CompileUnit),
|
||||
Ctxt.getConstantInt(Type::Int32Ty, LineNo),
|
||||
ConstantInt::get(Type::Int32Ty, LineNo),
|
||||
getCastToEmpty(Type)
|
||||
};
|
||||
|
||||
Constant *Init =
|
||||
Ctxt.getConstantStruct(Elts, sizeof(Elts)/sizeof(Elts[0]));
|
||||
Constant *Init = ConstantStruct::get(Elts, sizeof(Elts)/sizeof(Elts[0]));
|
||||
|
||||
M.addTypeName("llvm.dbg.variable.type", Init->getType());
|
||||
GlobalVariable *GV = new GlobalVariable(Init->getType(), true,
|
||||
@ -834,8 +811,7 @@ DIBlock DIFactory::CreateBlock(DIDescriptor Context) {
|
||||
getCastToEmpty(Context)
|
||||
};
|
||||
|
||||
Constant *Init =
|
||||
M.getContext().getConstantStruct(Elts, sizeof(Elts)/sizeof(Elts[0]));
|
||||
Constant *Init = ConstantStruct::get(Elts, sizeof(Elts)/sizeof(Elts[0]));
|
||||
|
||||
M.addTypeName("llvm.dbg.block.type", Init->getType());
|
||||
GlobalVariable *GV = new GlobalVariable(Init->getType(), true,
|
||||
@ -862,8 +838,8 @@ void DIFactory::InsertStopPoint(DICompileUnit CU, unsigned LineNo,
|
||||
|
||||
// Invoke llvm.dbg.stoppoint
|
||||
Value *Args[] = {
|
||||
M.getContext().getConstantInt(llvm::Type::Int32Ty, LineNo),
|
||||
M.getContext().getConstantInt(llvm::Type::Int32Ty, ColNo),
|
||||
llvm::ConstantInt::get(llvm::Type::Int32Ty, LineNo),
|
||||
llvm::ConstantInt::get(llvm::Type::Int32Ty, ColNo),
|
||||
getCastToEmpty(CU)
|
||||
};
|
||||
CallInst::Create(StopPointFn, Args, Args+3, "", BB);
|
||||
@ -966,7 +942,7 @@ namespace llvm {
|
||||
const Type *Ty = M->getTypeByName("llvm.dbg.global_variable.type");
|
||||
if (!Ty) return 0;
|
||||
|
||||
Ty = V->getParent()->getContext().getPointerType(Ty, 0);
|
||||
Ty = PointerType::get(Ty, 0);
|
||||
|
||||
Value *Val = V->stripPointerCasts();
|
||||
for (Value::use_iterator I = Val->use_begin(), E = Val->use_end();
|
||||
|
Loading…
Reference in New Issue
Block a user