mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-25 16:24:23 +00:00
The debugger sometimes lookup dynamically in the runtime to find ivar info of any Objective-C classes. It would be very helpful to debugger if the compiler encodes runtime version number in DWARF.
Add support for two additional DWARF attributes to encode Objective-C runtime version number. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@64834 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -118,9 +118,11 @@ namespace llvm {
|
|||||||
/// code generator accepts maximum one main compile unit per module. If a
|
/// code generator accepts maximum one main compile unit per module. If a
|
||||||
/// module does not contain any main compile unit then the code generator
|
/// module does not contain any main compile unit then the code generator
|
||||||
/// will emit multiple compile units in the output object file.
|
/// will emit multiple compile units in the output object file.
|
||||||
|
|
||||||
bool isMain() const { return getUnsignedField(6); }
|
bool isMain() const { return getUnsignedField(6); }
|
||||||
bool isOptimized() const { return getUnsignedField(7); }
|
bool isOptimized() const { return getUnsignedField(7); }
|
||||||
std::string getFlags() const { return getStringField(8); }
|
std::string getFlags() const { return getStringField(8); }
|
||||||
|
unsigned getRunTimeVersion() const { return getUnsignedField(9); }
|
||||||
|
|
||||||
/// Verify - Verify that a compile unit is well formed.
|
/// Verify - Verify that a compile unit is well formed.
|
||||||
bool Verify() const;
|
bool Verify() const;
|
||||||
@ -231,6 +233,7 @@ namespace llvm {
|
|||||||
public:
|
public:
|
||||||
explicit DICompositeType(GlobalVariable *GV);
|
explicit DICompositeType(GlobalVariable *GV);
|
||||||
DIArray getTypeArray() const { return getFieldAs<DIArray>(10); }
|
DIArray getTypeArray() const { return getFieldAs<DIArray>(10); }
|
||||||
|
unsigned getRunTimeLang() const { return getUnsignedField(11); }
|
||||||
|
|
||||||
/// Verify - Verify that a composite type descriptor is well formed.
|
/// Verify - Verify that a composite type descriptor is well formed.
|
||||||
bool Verify() const;
|
bool Verify() const;
|
||||||
@ -381,7 +384,8 @@ namespace llvm {
|
|||||||
const std::string &Producer,
|
const std::string &Producer,
|
||||||
bool isMain = false,
|
bool isMain = false,
|
||||||
bool isOptimized = false,
|
bool isOptimized = false,
|
||||||
const char *Flags = "");
|
const char *Flags = "",
|
||||||
|
unsigned RunTimeVer = 0);
|
||||||
|
|
||||||
/// CreateEnumerator - Create a single enumerator value.
|
/// CreateEnumerator - Create a single enumerator value.
|
||||||
DIEnumerator CreateEnumerator(const std::string &Name, uint64_t Val);
|
DIEnumerator CreateEnumerator(const std::string &Name, uint64_t Val);
|
||||||
@ -412,7 +416,8 @@ namespace llvm {
|
|||||||
uint64_t AlignInBits,
|
uint64_t AlignInBits,
|
||||||
uint64_t OffsetInBits, unsigned Flags,
|
uint64_t OffsetInBits, unsigned Flags,
|
||||||
DIType DerivedFrom,
|
DIType DerivedFrom,
|
||||||
DIArray Elements);
|
DIArray Elements,
|
||||||
|
unsigned RunTimeLang = 0);
|
||||||
|
|
||||||
/// CreateSubprogram - Create a new descriptor for the specified subprogram.
|
/// CreateSubprogram - Create a new descriptor for the specified subprogram.
|
||||||
/// See comments in DISubprogram for descriptions of these fields.
|
/// See comments in DISubprogram for descriptions of these fields.
|
||||||
|
@ -225,6 +225,8 @@ enum dwarf_constants {
|
|||||||
// Apple extensions.
|
// Apple extensions.
|
||||||
DW_AT_APPLE_optimized = 0x3fe1,
|
DW_AT_APPLE_optimized = 0x3fe1,
|
||||||
DW_AT_APPLE_flags = 0x3fe2,
|
DW_AT_APPLE_flags = 0x3fe2,
|
||||||
|
DW_AT_APPLE_major_runtime_vers = 0x3fe5,
|
||||||
|
DW_AT_APPLE_runtime_class = 0x3fe6,
|
||||||
|
|
||||||
// Attribute form encodings
|
// Attribute form encodings
|
||||||
DW_FORM_addr = 0x01,
|
DW_FORM_addr = 0x01,
|
||||||
|
@ -453,7 +453,8 @@ DICompileUnit DIFactory::CreateCompileUnit(unsigned LangID,
|
|||||||
const std::string &Producer,
|
const std::string &Producer,
|
||||||
bool isMain,
|
bool isMain,
|
||||||
bool isOptimized,
|
bool isOptimized,
|
||||||
const char *Flags) {
|
const char *Flags,
|
||||||
|
unsigned RunTimeVer) {
|
||||||
Constant *Elts[] = {
|
Constant *Elts[] = {
|
||||||
GetTagConstant(dwarf::DW_TAG_compile_unit),
|
GetTagConstant(dwarf::DW_TAG_compile_unit),
|
||||||
getCastToEmpty(GetOrCreateCompileUnitAnchor()),
|
getCastToEmpty(GetOrCreateCompileUnitAnchor()),
|
||||||
@ -463,7 +464,8 @@ DICompileUnit DIFactory::CreateCompileUnit(unsigned LangID,
|
|||||||
GetStringConstant(Producer),
|
GetStringConstant(Producer),
|
||||||
ConstantInt::get(Type::Int1Ty, isMain),
|
ConstantInt::get(Type::Int1Ty, isMain),
|
||||||
ConstantInt::get(Type::Int1Ty, isOptimized),
|
ConstantInt::get(Type::Int1Ty, isOptimized),
|
||||||
GetStringConstant(Flags)
|
GetStringConstant(Flags),
|
||||||
|
ConstantInt::get(Type::Int32Ty, RunTimeVer)
|
||||||
};
|
};
|
||||||
|
|
||||||
Constant *Init = ConstantStruct::get(Elts, sizeof(Elts)/sizeof(Elts[0]));
|
Constant *Init = ConstantStruct::get(Elts, sizeof(Elts)/sizeof(Elts[0]));
|
||||||
@ -573,7 +575,8 @@ DICompositeType DIFactory::CreateCompositeType(unsigned Tag,
|
|||||||
uint64_t OffsetInBits,
|
uint64_t OffsetInBits,
|
||||||
unsigned Flags,
|
unsigned Flags,
|
||||||
DIType DerivedFrom,
|
DIType DerivedFrom,
|
||||||
DIArray Elements) {
|
DIArray Elements,
|
||||||
|
unsigned RuntimeLang) {
|
||||||
|
|
||||||
Constant *Elts[] = {
|
Constant *Elts[] = {
|
||||||
GetTagConstant(Tag),
|
GetTagConstant(Tag),
|
||||||
@ -586,7 +589,8 @@ DICompositeType DIFactory::CreateCompositeType(unsigned Tag,
|
|||||||
ConstantInt::get(Type::Int64Ty, OffsetInBits),
|
ConstantInt::get(Type::Int64Ty, OffsetInBits),
|
||||||
ConstantInt::get(Type::Int32Ty, Flags),
|
ConstantInt::get(Type::Int32Ty, Flags),
|
||||||
getCastToEmpty(DerivedFrom),
|
getCastToEmpty(DerivedFrom),
|
||||||
getCastToEmpty(Elements)
|
getCastToEmpty(Elements),
|
||||||
|
ConstantInt::get(Type::Int32Ty, RuntimeLang)
|
||||||
};
|
};
|
||||||
|
|
||||||
Constant *Init = ConstantStruct::get(Elts, sizeof(Elts)/sizeof(Elts[0]));
|
Constant *Init = ConstantStruct::get(Elts, sizeof(Elts)/sizeof(Elts[0]));
|
||||||
|
@ -1770,6 +1770,9 @@ private:
|
|||||||
DIDerivedType(Element.getGV()));
|
DIDerivedType(Element.getGV()));
|
||||||
Buffer.AddChild(ElemDie);
|
Buffer.AddChild(ElemDie);
|
||||||
}
|
}
|
||||||
|
unsigned RLang = CTy.getRunTimeLang();
|
||||||
|
if (RLang)
|
||||||
|
AddUInt(&Buffer, DW_AT_APPLE_runtime_class, DW_FORM_data1, RLang);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -2800,6 +2803,9 @@ private:
|
|||||||
const std::string &Flags = DIUnit.getFlags();
|
const std::string &Flags = DIUnit.getFlags();
|
||||||
if (!Flags.empty())
|
if (!Flags.empty())
|
||||||
AddString(Die, DW_AT_APPLE_flags, DW_FORM_string, Flags);
|
AddString(Die, DW_AT_APPLE_flags, DW_FORM_string, Flags);
|
||||||
|
unsigned RVer = DIUnit.getRunTimeVersion();
|
||||||
|
if (RVer)
|
||||||
|
AddUInt(Die, DW_AT_APPLE_major_runtime_vers, DW_FORM_data1, RVer);
|
||||||
|
|
||||||
CompileUnit *Unit = new CompileUnit(ID, Die);
|
CompileUnit *Unit = new CompileUnit(ID, Die);
|
||||||
if (DIUnit.isMain()) {
|
if (DIUnit.isMain()) {
|
||||||
|
@ -200,6 +200,8 @@ const char *AttributeString(unsigned Attribute) {
|
|||||||
case DW_AT_hi_user: return "DW_AT_hi_user";
|
case DW_AT_hi_user: return "DW_AT_hi_user";
|
||||||
case DW_AT_APPLE_optimized: return "DW_AT_APPLE_optimized";
|
case DW_AT_APPLE_optimized: return "DW_AT_APPLE_optimized";
|
||||||
case DW_AT_APPLE_flags: return "DW_AT_APPLE_flags";
|
case DW_AT_APPLE_flags: return "DW_AT_APPLE_flags";
|
||||||
|
case DW_AT_APPLE_major_runtime_vers: return "DW_AT_APPLE_major_runtime_vers";
|
||||||
|
case DW_AT_APPLE_runtime_class: return "DW_AT_APPLE_runtime_class";
|
||||||
}
|
}
|
||||||
assert(0 && "Unknown Dwarf Attribute");
|
assert(0 && "Unknown Dwarf Attribute");
|
||||||
return "";
|
return "";
|
||||||
|
@ -356,6 +356,10 @@ bool LTOCodeGenerator::generateAssemblyCode(raw_ostream& out,
|
|||||||
// Add an appropriate TargetData instance for this module...
|
// Add an appropriate TargetData instance for this module...
|
||||||
passes.add(new TargetData(*_target->getTargetData()));
|
passes.add(new TargetData(*_target->getTargetData()));
|
||||||
|
|
||||||
|
std::string targetTriple = _linker.getModule()->getTargetTriple();
|
||||||
|
// if ( targetTriple.find("darwin") != targetTriple.size() )
|
||||||
|
passes.add(createStripSymbolsPass(true /* strip debug info only */));
|
||||||
|
|
||||||
// Propagate constants at call sites into the functions they call. This
|
// Propagate constants at call sites into the functions they call. This
|
||||||
// opens opportunities for globalopt (and inlining) by substituting function
|
// opens opportunities for globalopt (and inlining) by substituting function
|
||||||
// pointers passed as arguments to direct uses of functions.
|
// pointers passed as arguments to direct uses of functions.
|
||||||
@ -412,6 +416,8 @@ bool LTOCodeGenerator::generateAssemblyCode(raw_ostream& out,
|
|||||||
// Make sure everything is still good.
|
// Make sure everything is still good.
|
||||||
passes.add(createVerifierPass());
|
passes.add(createVerifierPass());
|
||||||
|
|
||||||
|
setCodeGenDebugOptions("-debug-pass=Structure");
|
||||||
|
|
||||||
FunctionPassManager* codeGenPasses =
|
FunctionPassManager* codeGenPasses =
|
||||||
new FunctionPassManager(new ExistingModuleProvider(mergedModule));
|
new FunctionPassManager(new ExistingModuleProvider(mergedModule));
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user