Index: llvm/include/llvm/Support/JSON.h =================================================================== --- llvm/include/llvm/Support/JSON.h +++ llvm/include/llvm/Support/JSON.h @@ -348,6 +348,10 @@ Value(T I) : Type(T_Integer) { create(int64_t{I}); } + // Unsigned 64-bit long integers. + Value(uint64_t V) : Type(T_UINT64) { + create(uint64_t{V}); + } // Floating point. Must be non-narrowing convertible to double. template ::value>, @@ -382,6 +386,7 @@ return Boolean; case T_Double: case T_Integer: + case T_UINT64: return Number; case T_String: case T_StringRef: @@ -410,12 +415,16 @@ return as(); if (LLVM_LIKELY(Type == T_Integer)) return as(); + if (LLVM_LIKELY(Type == T_UINT64)) + return as(); return llvm::None; } // Succeeds if the Value is a Number, and exactly representable as int64_t. llvm::Optional getAsInteger() const { if (LLVM_LIKELY(Type == T_Integer)) return as(); + if (LLVM_LIKELY(Type == T_UINT64)) + return as(); if (LLVM_LIKELY(Type == T_Double)) { double D = as(); if (LLVM_LIKELY(std::modf(D, &D) == 0.0 && @@ -472,6 +481,7 @@ T_Boolean, T_Double, T_Integer, + T_UINT64, T_StringRef, T_String, T_Object, Index: llvm/lib/Support/JSON.cpp =================================================================== --- llvm/lib/Support/JSON.cpp +++ llvm/lib/Support/JSON.cpp @@ -109,6 +109,7 @@ case T_Boolean: case T_Double: case T_Integer: + case T_UINT64: memcpy(&Union, &M.Union, sizeof(Union)); break; case T_StringRef: @@ -133,6 +134,7 @@ case T_Boolean: case T_Double: case T_Integer: + case T_UINT64: memcpy(&Union, &M.Union, sizeof(Union)); break; case T_StringRef: @@ -159,6 +161,7 @@ case T_Boolean: case T_Double: case T_Integer: + case T_UINT64: break; case T_StringRef: as().~StringRef(); Index: llvm/tools/llvm-dwarfdump/Statistics.cpp =================================================================== --- llvm/tools/llvm-dwarfdump/Statistics.cpp +++ llvm/tools/llvm-dwarfdump/Statistics.cpp @@ -40,18 +40,18 @@ /// contains variables, such as a compile unit). struct PerFunctionStats { /// Number of inlined instances of this function. - unsigned NumFnInlined = 0; + uint64_t NumFnInlined = 0; /// Number of out-of-line instances of this function. - unsigned NumFnOutOfLine = 0; + uint64_t NumFnOutOfLine = 0; /// Number of inlined instances that have abstract origins. - unsigned NumAbstractOrigins = 0; + uint64_t NumAbstractOrigins = 0; /// Number of variables and parameters with location across all inlined /// instances. - unsigned TotalVarWithLoc = 0; + uint64_t TotalVarWithLoc = 0; /// Number of constants with location across all inlined instances. - unsigned ConstantMembers = 0; + uint64_t ConstantMembers = 0; /// Number of arificial variables, parameters or members across all instances. - unsigned NumArtificial = 0; + uint64_t NumArtificial = 0; /// List of all Variables and parameters in this function. StringSet<> VarsInFunction; /// Compile units also cover a PC range, but have this flag set to false. @@ -59,63 +59,63 @@ /// Function has source location information. bool HasSourceLocation = false; /// Number of function parameters. - unsigned NumParams = 0; + uint64_t NumParams = 0; /// Number of function parameters with source location. - unsigned NumParamSourceLocations = 0; + uint64_t NumParamSourceLocations = 0; /// Number of function parameters with type. - unsigned NumParamTypes = 0; + uint64_t NumParamTypes = 0; /// Number of function parameters with a DW_AT_location. - unsigned NumParamLocations = 0; + uint64_t NumParamLocations = 0; /// Number of local variables. - unsigned NumLocalVars = 0; + uint64_t NumLocalVars = 0; /// Number of local variables with source location. - unsigned NumLocalVarSourceLocations = 0; + uint64_t NumLocalVarSourceLocations = 0; /// Number of local variables with type. - unsigned NumLocalVarTypes = 0; + uint64_t NumLocalVarTypes = 0; /// Number of local variables with DW_AT_location. - unsigned NumLocalVarLocations = 0; + uint64_t NumLocalVarLocations = 0; }; /// Holds accumulated global statistics about DIEs. struct GlobalStats { /// Total number of PC range bytes covered by DW_AT_locations. - unsigned TotalBytesCovered = 0; + uint64_t TotalBytesCovered = 0; /// Total number of parent DIE PC range bytes covered by DW_AT_Locations. - unsigned ScopeBytesCovered = 0; + uint64_t ScopeBytesCovered = 0; /// Total number of PC range bytes in each variable's enclosing scope. - unsigned ScopeBytes = 0; + uint64_t ScopeBytes = 0; /// Total number of PC range bytes covered by DW_AT_locations with /// the debug entry values (DW_OP_entry_value). - unsigned ScopeEntryValueBytesCovered = 0; + uint64_t ScopeEntryValueBytesCovered = 0; /// Total number of PC range bytes covered by DW_AT_locations of /// formal parameters. - unsigned ParamScopeBytesCovered = 0; + uint64_t ParamScopeBytesCovered = 0; /// Total number of PC range bytes in each parameter's enclosing scope. - unsigned ParamScopeBytes = 0; + uint64_t ParamScopeBytes = 0; /// Total number of PC range bytes covered by DW_AT_locations with /// the debug entry values (DW_OP_entry_value) (only for parameters). - unsigned ParamScopeEntryValueBytesCovered = 0; + uint64_t ParamScopeEntryValueBytesCovered = 0; /// Total number of PC range bytes covered by DW_AT_locations (only for local /// variables). - unsigned LocalVarScopeBytesCovered = 0; + uint64_t LocalVarScopeBytesCovered = 0; /// Total number of PC range bytes in each local variable's enclosing scope. - unsigned LocalVarScopeBytes = 0; + uint64_t LocalVarScopeBytes = 0; /// Total number of PC range bytes covered by DW_AT_locations with /// the debug entry values (DW_OP_entry_value) (only for local variables). - unsigned LocalVarScopeEntryValueBytesCovered = 0; + uint64_t LocalVarScopeEntryValueBytesCovered = 0; /// Total number of call site entries (DW_AT_call_file & DW_AT_call_line). - unsigned CallSiteEntries = 0; + uint64_t CallSiteEntries = 0; /// Total number of call site DIEs (DW_TAG_call_site). - unsigned CallSiteDIEs = 0; + uint64_t CallSiteDIEs = 0; /// Total number of call site parameter DIEs (DW_TAG_call_site_parameter). - unsigned CallSiteParamDIEs = 0; + uint64_t CallSiteParamDIEs = 0; /// Total byte size of concrete functions. This byte size includes /// inline functions contained in the concrete functions. - unsigned FunctionSize = 0; + uint64_t FunctionSize = 0; /// Total byte size of inlined functions. This is the total number of bytes /// for the top inline functions within concrete functions. This can help /// tune the inline settings when compiling to match user expectations. - unsigned InlineFunctionSize = 0; + uint64_t InlineFunctionSize = 0; }; /// Holds accumulated debug location statistics about local variables and @@ -126,37 +126,37 @@ /// of variables with the no debug location at all, but the last element /// in the vector represents the number of fully covered variables within /// its scope. - std::vector VarParamLocStats{ - std::vector(NumOfCoverageCategories, 0)}; + std::vector VarParamLocStats{ + std::vector(NumOfCoverageCategories, 0)}; /// Map non debug entry values coverage. - std::vector VarParamNonEntryValLocStats{ - std::vector(NumOfCoverageCategories, 0)}; + std::vector VarParamNonEntryValLocStats{ + std::vector(NumOfCoverageCategories, 0)}; /// The debug location statistics for formal parameters. - std::vector ParamLocStats{ - std::vector(NumOfCoverageCategories, 0)}; + std::vector ParamLocStats{ + std::vector(NumOfCoverageCategories, 0)}; /// Map non debug entry values coverage for formal parameters. - std::vector ParamNonEntryValLocStats{ - std::vector(NumOfCoverageCategories, 0)}; + std::vector ParamNonEntryValLocStats{ + std::vector(NumOfCoverageCategories, 0)}; /// The debug location statistics for local variables. - std::vector LocalVarLocStats{ - std::vector(NumOfCoverageCategories, 0)}; + std::vector LocalVarLocStats{ + std::vector(NumOfCoverageCategories, 0)}; /// Map non debug entry values coverage for local variables. - std::vector LocalVarNonEntryValLocStats{ - std::vector(NumOfCoverageCategories, 0)}; + std::vector LocalVarNonEntryValLocStats{ + std::vector(NumOfCoverageCategories, 0)}; /// Total number of local variables and function parameters processed. - unsigned NumVarParam = 0; + uint64_t NumVarParam = 0; /// Total number of formal parameters processed. - unsigned NumParam = 0; + uint64_t NumParam = 0; /// Total number of local variables processed. - unsigned NumVar = 0; + uint64_t NumVar = 0; }; } // namespace /// Collect debug location statistics for one DIE. static void collectLocStats(uint64_t ScopeBytesCovered, uint64_t BytesInScope, - std::vector &VarParamLocStats, - std::vector &ParamLocStats, - std::vector &LocalVarLocStats, + std::vector &VarParamLocStats, + std::vector &ParamLocStats, + std::vector &LocalVarLocStats, bool IsParam, bool IsLocalVar) { auto getCoverageBucket = [ScopeBytesCovered, BytesInScope]() -> unsigned { // No debug location at all for the variable. @@ -377,8 +377,14 @@ GlobalStats.TotalBytesCovered += TotalBytesCovered; if (BytesInScope) { GlobalStats.ScopeBytesCovered += ScopeBytesCovered; + assert(GlobalStats.ScopeBytesCovered <= UINT64_MAX && + "ScopeBytesCovered - overflow"); GlobalStats.ScopeBytes += BytesInScope; + assert(GlobalStats.ScopeBytes <= UINT64_MAX && + "ScopeBytes - overflow"); GlobalStats.ScopeEntryValueBytesCovered += BytesEntryValuesCovered; + assert(GlobalStats.ScopeEntryValueBytesCovered <= UINT64_MAX && + "ScopeEntryValueBytesCovered - overflow"); if (IsParam) { GlobalStats.ParamScopeBytesCovered += ScopeBytesCovered; GlobalStats.ParamScopeBytes += BytesInScope; @@ -608,7 +614,7 @@ } static void printLocationStats(json::OStream &J, const char *Key, - std::vector &LocationStats) { + std::vector &LocationStats) { J.attribute( (Twine(Key) + " with 0% of parent scope covered by DW_AT_location").str(), LocationStats[0]); @@ -751,30 +757,30 @@ /// (including bug fixes). New metrics may be added without increasing the /// version. unsigned Version = 8; - unsigned VarParamTotal = 0; - unsigned VarParamUnique = 0; - unsigned VarParamWithLoc = 0; - unsigned NumFunctions = 0; - unsigned NumInlinedFunctions = 0; - unsigned NumFuncsWithSrcLoc = 0; - unsigned NumAbstractOrigins = 0; - unsigned ParamTotal = 0; - unsigned ParamWithType = 0; - unsigned ParamWithLoc = 0; - unsigned ParamWithSrcLoc = 0; - unsigned LocalVarTotal = 0; - unsigned LocalVarWithType = 0; - unsigned LocalVarWithSrcLoc = 0; - unsigned LocalVarWithLoc = 0; + uint64_t VarParamTotal = 0; + uint64_t VarParamUnique = 0; + uint64_t VarParamWithLoc = 0; + uint64_t NumFunctions = 0; + uint64_t NumInlinedFunctions = 0; + uint64_t NumFuncsWithSrcLoc = 0; + uint64_t NumAbstractOrigins = 0; + uint64_t ParamTotal = 0; + uint64_t ParamWithType = 0; + uint64_t ParamWithLoc = 0; + uint64_t ParamWithSrcLoc = 0; + uint64_t LocalVarTotal = 0; + uint64_t LocalVarWithType = 0; + uint64_t LocalVarWithSrcLoc = 0; + uint64_t LocalVarWithLoc = 0; for (auto &Entry : Statistics) { PerFunctionStats &Stats = Entry.getValue(); - unsigned TotalVars = Stats.VarsInFunction.size() * + uint64_t TotalVars = Stats.VarsInFunction.size() * (Stats.NumFnInlined + Stats.NumFnOutOfLine); // Count variables in global scope. if (!Stats.IsFunction) TotalVars = Stats.NumLocalVars + Stats.ConstantMembers + Stats.NumArtificial; - unsigned Constants = Stats.ConstantMembers; + uint64_t Constants = Stats.ConstantMembers; VarParamWithLoc += Stats.TotalVarWithLoc + Constants; VarParamTotal += TotalVars; VarParamUnique += Stats.VarsInFunction.size();