diff options
author | Bill Wendling <isanbard@gmail.com> | 2008-07-09 06:02:33 +0000 |
---|---|---|
committer | Bill Wendling <isanbard@gmail.com> | 2008-07-09 06:02:33 +0000 |
commit | 5591f60c580b221eede1f019d3a0d877a6d61a94 (patch) | |
tree | 3b7e27aeed3b4229ffd0ba12bead7c33d64009e5 /lib/CodeGen/MachineModuleInfo.cpp | |
parent | 311caae0a49042318dd5fbc6c31aa0dffe926128 (diff) | |
download | external_llvm-5591f60c580b221eede1f019d3a0d877a6d61a94.zip external_llvm-5591f60c580b221eede1f019d3a0d877a6d61a94.tar.gz external_llvm-5591f60c580b221eede1f019d3a0d877a6d61a94.tar.bz2 |
Make the DICountVisitor not a visitor. This keeps us from calling virtual
functions and junk.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53279 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/MachineModuleInfo.cpp')
-rw-r--r-- | lib/CodeGen/MachineModuleInfo.cpp | 187 |
1 files changed, 154 insertions, 33 deletions
diff --git a/lib/CodeGen/MachineModuleInfo.cpp b/lib/CodeGen/MachineModuleInfo.cpp index 5c826b5..2010d17 100644 --- a/lib/CodeGen/MachineModuleInfo.cpp +++ b/lib/CodeGen/MachineModuleInfo.cpp @@ -150,6 +150,157 @@ static ConstantInt *getUIntOperand(GlobalVariable *GV, unsigned i) { //===----------------------------------------------------------------------===// +static unsigned CountFields(DebugInfoDesc *DD) { + unsigned Count = 0; + + switch (DD->getTag()) { + case DW_TAG_anchor: // AnchorDesc + // Tag + // AnchorTag + Count = 2; + break; + case DW_TAG_compile_unit: // CompileUnitDesc + // [DW_TAG_anchor] + // if (Version == 0) DebugVersion + // Language + // FileName + // Directory + // Producer + Count = 6; + + // Handle cases out of sync with compiler. + if (DD->getVersion() == 0) + ++Count; + + break; + case DW_TAG_variable: // GlobalVariableDesc + // [DW_TAG_anchor] + // Context + // Name + // FullName + // LinkageName + // File + // Line + // TyDesc + // IsStatic + // IsDefinition + // Global + Count = 12; + break; + case DW_TAG_subprogram: // SubprogramDesc + // [DW_TAG_anchor] + // Context + // Name + // FullName + // LinkageName + // File + // Line + // TyDesc + // IsStatic + // IsDefinition + Count = 11; + break; + case DW_TAG_lexical_block: // BlockDesc + // Tag + // Context + Count = 2; + break; + case DW_TAG_base_type: // BasicTypeDesc + // Tag + // Context + // Name + // File + // Line + // Size + // Align + // Offset + // if (Version > LLVMDebugVersion4) Flags + // Encoding + Count = 9; + + if (DD->getVersion() > LLVMDebugVersion4) + ++Count; + + break; + case DW_TAG_typedef: + case DW_TAG_pointer_type: + case DW_TAG_reference_type: + case DW_TAG_const_type: + case DW_TAG_volatile_type: + case DW_TAG_restrict_type: + case DW_TAG_member: + case DW_TAG_inheritance: // DerivedTypeDesc + // Tag + // Context + // Name + // File + // Line + // Size + // Align + // Offset + // if (Version > LLVMDebugVersion4) Flags + // FromType + Count = 9; + + if (DD->getVersion() > LLVMDebugVersion4) + ++Count; + + break; + case DW_TAG_array_type: + case DW_TAG_structure_type: + case DW_TAG_union_type: + case DW_TAG_enumeration_type: + case DW_TAG_vector_type: + case DW_TAG_subroutine_type: // CompositeTypeDesc + // Tag + // Context + // Name + // File + // Line + // Size + // Align + // Offset + // if (Version > LLVMDebugVersion4) Flags + // FromType + // Elements + Count = 10; + + if (DD->getVersion() > LLVMDebugVersion4) + ++Count; + + break; + case DW_TAG_subrange_type: // SubrangeDesc + // Tag + // Lo + // Hi + Count = 3; + break; + case DW_TAG_enumerator: // EnumeratorDesc + // Tag + // Name + // Value + Count = 3; + break; + case DW_TAG_return_variable: + case DW_TAG_arg_variable: + case DW_TAG_auto_variable: // VariableDesc + // Tag + // Context + // Name + // File + // Line + // TyDesc + Count = 6; + break; + default: + break; + } + + return Count; +} + +//===----------------------------------------------------------------------===// + /// ApplyToFields - Target the visitor to each field of the debug information /// descriptor. void DIVisitor::ApplyToFields(DebugInfoDesc *DD) { @@ -159,34 +310,6 @@ void DIVisitor::ApplyToFields(DebugInfoDesc *DD) { namespace { //===----------------------------------------------------------------------===// -/// DICountVisitor - This DIVisitor counts all the fields in the supplied debug -/// the supplied DebugInfoDesc. -class DICountVisitor : public DIVisitor { -private: - unsigned Count; // Running count of fields. - -public: - DICountVisitor() : DIVisitor(), Count(0) {} - - // Accessors. - unsigned getCount() const { return Count; } - - /// Apply - Count each of the fields. - /// - virtual void Apply(int &Field) { ++Count; } - virtual void Apply(unsigned &Field) { ++Count; } - virtual void Apply(int64_t &Field) { ++Count; } - virtual void Apply(uint64_t &Field) { ++Count; } - virtual void Apply(bool &Field) { ++Count; } - virtual void Apply(std::string &Field) { ++Count; } - virtual void Apply(DebugInfoDesc *&Field) { ++Count; } - virtual void Apply(GlobalVariable *&Field) { ++Count; } - virtual void Apply(std::vector<DebugInfoDesc *> &Field) { - ++Count; - } -}; - -//===----------------------------------------------------------------------===// /// DIDeserializeVisitor - This DIVisitor deserializes all the fields in the /// supplied DebugInfoDesc. class DIDeserializeVisitor : public DIVisitor { @@ -1443,12 +1566,10 @@ bool DIVerifier::Verify(GlobalVariable *GV) { // Get the field count. unsigned &CountSlot = Counts[Tag]; - if (!CountSlot) { + + if (!CountSlot) // Check the operand count to the field count - DICountVisitor CTAM; - CTAM.ApplyToFields(DD); - CountSlot = CTAM.getCount(); - } + CountSlot = CountFields(DD); // Field count must be at most equal operand count. if (CountSlot > N) { |