diff --git a/llvm/include/llvm/ProfileData/Coverage/CoverageMapping.h b/llvm/include/llvm/ProfileData/Coverage/CoverageMapping.h index 4fc0133443192..e62ce5e3d8fa6 100644 --- a/llvm/include/llvm/ProfileData/Coverage/CoverageMapping.h +++ b/llvm/include/llvm/ProfileData/Coverage/CoverageMapping.h @@ -71,13 +71,13 @@ enum class coveragemap_error { invalid_or_missing_arch_specifier }; -const std::error_category &coveragemap_category(); +LLVM_ABI const std::error_category &coveragemap_category(); inline std::error_code make_error_code(coveragemap_error E) { return std::error_code(static_cast(E), coveragemap_category()); } -class CoverageMapError : public ErrorInfo { +class LLVM_ABI CoverageMapError : public ErrorInfo { public: CoverageMapError(coveragemap_error Err, const Twine &ErrStr = Twine()) : Err(Err), Msg(ErrStr.str()) { @@ -210,11 +210,11 @@ class CounterExpressionBuilder { ArrayRef getExpressions() const { return Expressions; } /// Return a counter that represents the expression that adds LHS and RHS. - Counter add(Counter LHS, Counter RHS, bool Simplify = true); + LLVM_ABI Counter add(Counter LHS, Counter RHS, bool Simplify = true); /// Return a counter that represents the expression that subtracts RHS from /// LHS. - Counter subtract(Counter LHS, Counter RHS, bool Simplify = true); + LLVM_ABI Counter subtract(Counter LHS, Counter RHS, bool Simplify = true); /// K to V map. K will be Counter in most cases. V may be Counter or /// Expression. @@ -222,7 +222,7 @@ class CounterExpressionBuilder { /// \return A counter equivalent to \C, with each term in its /// expression replaced with term from \p Map. - Counter subst(Counter C, const SubstMap &Map); + LLVM_ABI Counter subst(Counter C, const SubstMap &Map); }; using LineColPair = std::pair; @@ -473,7 +473,7 @@ struct MCDCRecord { // Compare executed test vectors against each other to find an independence // pairs for each condition. This processing takes the most time. - void findIndependencePairs(); + LLVM_ABI void findIndependencePairs(); const CounterMappingRegion &getDecisionRegion() const { return Region; } unsigned getNumConditions() const { @@ -665,7 +665,8 @@ class TVIdxBuilder { /// \param NextIDs The list of {FalseID, TrueID} indexed by ID /// The first element [0] should be the root node. /// \param Offset Offset of index to final decisions. - TVIdxBuilder(const SmallVectorImpl &NextIDs, int Offset = 0); + LLVM_ABI TVIdxBuilder(const SmallVectorImpl &NextIDs, + int Offset = 0); }; } // namespace mcdc @@ -684,21 +685,21 @@ class CounterMappingContext { void setCounts(ArrayRef Counts) { CounterValues = Counts; } void setBitmap(BitVector &&Bitmap_) { Bitmap = std::move(Bitmap_); } - void dump(const Counter &C, raw_ostream &OS) const; + LLVM_ABI void dump(const Counter &C, raw_ostream &OS) const; void dump(const Counter &C) const { dump(C, dbgs()); } /// Return the number of times that a region of code associated with this /// counter was executed. - Expected evaluate(const Counter &C) const; + LLVM_ABI Expected evaluate(const Counter &C) const; /// Return an MCDC record that indicates executed test vectors and condition /// pairs. - Expected + LLVM_ABI Expected evaluateMCDCRegion(const CounterMappingRegion &Region, ArrayRef Branches, bool IsVersion11); - unsigned getMaxCounterID(const Counter &C) const; + LLVM_ABI unsigned getMaxCounterID(const Counter &C) const; }; /// Code coverage information for a single function. @@ -761,7 +762,7 @@ class FunctionRecordIterator StringRef Filename; /// Skip records whose primary file is not \c Filename. - void skipOtherFiles(); + LLVM_ABI void skipOtherFiles(); public: FunctionRecordIterator(ArrayRef Records_, @@ -1007,7 +1008,7 @@ class CoverageMapping { /// defined in the specified file. This is guaranteed to return a superset of /// such records: extra records not in the file may be included if there is /// a hash collision on the filename. Clients must be robust to collisions. - ArrayRef + LLVM_ABI ArrayRef getImpreciseRecordIndicesForFilename(StringRef Filename) const; public: @@ -1015,14 +1016,14 @@ class CoverageMapping { CoverageMapping &operator=(const CoverageMapping &) = delete; /// Load the coverage mapping using the given readers. - static Expected> + LLVM_ABI static Expected> load(ArrayRef> CoverageReaders, IndexedInstrProfReader &ProfileReader); /// Load the coverage mapping from the given object files and profile. If /// \p Arches is non-empty, it must specify an architecture for each object. /// Ignores non-instrumented object files unless all are not instrumented. - static Expected> + LLVM_ABI static Expected> load(ArrayRef ObjectFilenames, StringRef ProfileFilename, vfs::FileSystem &FS, ArrayRef Arches = {}, StringRef CompilationDir = "", @@ -1045,20 +1046,22 @@ class CoverageMapping { /// Returns a lexicographically sorted, unique list of files that are /// covered. - std::vector getUniqueSourceFiles() const; + LLVM_ABI std::vector getUniqueSourceFiles() const; /// Get the coverage for a particular file. /// /// The given filename must be the name as recorded in the coverage /// information. That is, only names returned from getUniqueSourceFiles will /// yield a result. - CoverageData getCoverageForFile(StringRef Filename) const; + LLVM_ABI CoverageData getCoverageForFile(StringRef Filename) const; /// Get the coverage for a particular function. - CoverageData getCoverageForFunction(const FunctionRecord &Function) const; + LLVM_ABI CoverageData + getCoverageForFunction(const FunctionRecord &Function) const; /// Get the coverage for an expansion within a coverage set. - CoverageData getCoverageForExpansion(const ExpansionRecord &Expansion) const; + LLVM_ABI CoverageData + getCoverageForExpansion(const ExpansionRecord &Expansion) const; /// Gets all of the functions covered by this profile. iterator_range getCoveredFunctions() const { @@ -1079,7 +1082,7 @@ class CoverageMapping { /// /// Every instantiation group in a program is attributed to exactly one file: /// the file in which the definition for the common function begins. - std::vector + LLVM_ABI std::vector getInstantiationGroups(StringRef Filename) const; }; @@ -1096,8 +1099,9 @@ class LineCoverageStats { LineCoverageStats() = default; public: - LineCoverageStats(ArrayRef LineSegments, - const CoverageSegment *WrappedSegment, unsigned Line); + LLVM_ABI LineCoverageStats(ArrayRef LineSegments, + const CoverageSegment *WrappedSegment, + unsigned Line); uint64_t getExecutionCount() const { return ExecutionCount; } @@ -1136,7 +1140,7 @@ class LineCoverageIterator const LineCoverageStats &operator*() const { return Stats; } - LineCoverageIterator &operator++(); + LLVM_ABI LineCoverageIterator &operator++(); LineCoverageIterator getEnd() const { auto EndIt = *this; diff --git a/llvm/include/llvm/ProfileData/Coverage/CoverageMappingReader.h b/llvm/include/llvm/ProfileData/Coverage/CoverageMappingReader.h index 886b4d3d6894d..e91ba9147a745 100644 --- a/llvm/include/llvm/ProfileData/Coverage/CoverageMappingReader.h +++ b/llvm/include/llvm/ProfileData/Coverage/CoverageMappingReader.h @@ -18,6 +18,7 @@ #include "llvm/ADT/StringRef.h" #include "llvm/ProfileData/Coverage/CoverageMapping.h" #include "llvm/ProfileData/InstrProf.h" +#include "llvm/Support/Compiler.h" #include "llvm/Support/Error.h" #include "llvm/Support/MemoryBuffer.h" #include @@ -46,7 +47,7 @@ class CoverageMappingIterator { CoverageMappingRecord Record; coveragemap_error ReadErr; - void increment(); + LLVM_ABI void increment(); public: using iterator_category = std::input_iterator_tag; @@ -112,10 +113,10 @@ class RawCoverageReader { RawCoverageReader(StringRef Data) : Data(Data) {} - Error readULEB128(uint64_t &Result); - Error readIntMax(uint64_t &Result, uint64_t MaxPlus1); - Error readSize(uint64_t &Result); - Error readString(StringRef &Result); + LLVM_ABI Error readULEB128(uint64_t &Result); + LLVM_ABI Error readIntMax(uint64_t &Result, uint64_t MaxPlus1); + LLVM_ABI Error readSize(uint64_t &Result); + LLVM_ABI Error readString(StringRef &Result); }; /// Checks if the given coverage mapping data is exported for @@ -125,7 +126,7 @@ class RawCoverageMappingDummyChecker : public RawCoverageReader { RawCoverageMappingDummyChecker(StringRef MappingData) : RawCoverageReader(MappingData) {} - Expected isDummy(); + LLVM_ABI Expected isDummy(); }; /// Reader for the raw coverage mapping data. @@ -149,7 +150,7 @@ class RawCoverageMappingReader : public RawCoverageReader { RawCoverageMappingReader & operator=(const RawCoverageMappingReader &) = delete; - Error read(); + LLVM_ABI Error read(); private: Error decodeCounter(unsigned Value, Counter &C); @@ -161,7 +162,7 @@ class RawCoverageMappingReader : public RawCoverageReader { /// Reader for the coverage mapping data that is emitted by the /// frontend and stored in an object file. -class BinaryCoverageReader : public CoverageMappingReader { +class LLVM_ABI BinaryCoverageReader : public CoverageMappingReader { public: struct ProfileMappingRecord { CovMapVersion Version; @@ -245,7 +246,7 @@ class RawCoverageFilenamesReader : public RawCoverageReader { RawCoverageFilenamesReader & operator=(const RawCoverageFilenamesReader &) = delete; - Error read(CovMapVersion Version); + LLVM_ABI Error read(CovMapVersion Version); }; } // end namespace coverage diff --git a/llvm/include/llvm/ProfileData/Coverage/CoverageMappingWriter.h b/llvm/include/llvm/ProfileData/Coverage/CoverageMappingWriter.h index 02848deaba9db..5341b9879a9fe 100644 --- a/llvm/include/llvm/ProfileData/Coverage/CoverageMappingWriter.h +++ b/llvm/include/llvm/ProfileData/Coverage/CoverageMappingWriter.h @@ -17,6 +17,7 @@ #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/StringRef.h" #include "llvm/ProfileData/Coverage/CoverageMapping.h" +#include "llvm/Support/Compiler.h" namespace llvm { @@ -30,11 +31,11 @@ class CoverageFilenamesSectionWriter { ArrayRef Filenames; public: - CoverageFilenamesSectionWriter(ArrayRef Filenames); + LLVM_ABI CoverageFilenamesSectionWriter(ArrayRef Filenames); /// Write encoded filenames to the given output stream. If \p Compress is /// true, attempt to compress the filenames. - void write(raw_ostream &OS, bool Compress = true); + LLVM_ABI void write(raw_ostream &OS, bool Compress = true); }; /// Writer for instrumentation based coverage mapping data. @@ -51,7 +52,7 @@ class CoverageMappingWriter { MappingRegions(MappingRegions) {} /// Write encoded coverage mapping data to the given output stream. - void write(raw_ostream &OS); + LLVM_ABI void write(raw_ostream &OS); }; /// Writer for the coverage mapping testing format. @@ -70,7 +71,7 @@ class TestingFormatWriter { CoverageRecordsData(CoverageRecordsData) {} /// Encode to the given output stream. - void + LLVM_ABI void write(raw_ostream &OS, TestingFormatVersion Version = TestingFormatVersion::CurrentVersion); }; diff --git a/llvm/include/llvm/ProfileData/DataAccessProf.h b/llvm/include/llvm/ProfileData/DataAccessProf.h index c0f0c6d9c9fc1..f410096d83f5e 100644 --- a/llvm/include/llvm/ProfileData/DataAccessProf.h +++ b/llvm/include/llvm/ProfileData/DataAccessProf.h @@ -24,6 +24,7 @@ #include "llvm/ADT/StringRef.h" #include "llvm/ProfileData/InstrProf.h" #include "llvm/Support/Allocator.h" +#include "llvm/Support/Compiler.h" #include "llvm/Support/Error.h" #include "llvm/Support/StringSaver.h" @@ -138,33 +139,35 @@ class DataAccessProfData { /// - Serialized strings. /// - The encoded hashes. /// - Records. - Error serialize(ProfOStream &OS) const; + LLVM_ABI Error serialize(ProfOStream &OS) const; /// Deserialize this class from the given buffer. - Error deserialize(const unsigned char *&Ptr); + LLVM_ABI Error deserialize(const unsigned char *&Ptr); /// Returns a profile record for \p SymbolID, or std::nullopt if there /// isn't a record. Internally, this function will canonicalize the symbol /// name before the lookup. - std::optional + LLVM_ABI std::optional getProfileRecord(const SymbolHandleRef SymID) const; /// Returns true if \p SymID is seen in profiled binaries and cold. - bool isKnownColdSymbol(const SymbolHandleRef SymID) const; + LLVM_ABI bool isKnownColdSymbol(const SymbolHandleRef SymID) const; /// Methods to set symbolized data access profile. Returns error if /// duplicated symbol names or content hashes are seen. The user of this /// class should aggregate counters that correspond to the same symbol name /// or with the same string literal hash before calling 'set*' methods. - Error setDataAccessProfile(SymbolHandleRef SymbolID, uint64_t AccessCount); + LLVM_ABI Error setDataAccessProfile(SymbolHandleRef SymbolID, + uint64_t AccessCount); /// Similar to the method above, for records with \p Locations representing /// the `filename:line` where this symbol shows up. Note because of linker's /// merge of identical symbols (e.g., unnamed_addr string literals), one /// symbol is likely to have multiple locations. - Error setDataAccessProfile(SymbolHandleRef SymbolID, uint64_t AccessCount, - ArrayRef Locations); + LLVM_ABI Error setDataAccessProfile(SymbolHandleRef SymbolID, + uint64_t AccessCount, + ArrayRef Locations); /// Add a symbol that's seen in the profiled binary without samples. - Error addKnownSymbolWithoutSamples(SymbolHandleRef SymbolID); + LLVM_ABI Error addKnownSymbolWithoutSamples(SymbolHandleRef SymbolID); /// The following methods return array reference for various internal data /// structures. diff --git a/llvm/include/llvm/ProfileData/GCOV.h b/llvm/include/llvm/ProfileData/GCOV.h index c8af71dbf61ef..0dc33d062e4f8 100644 --- a/llvm/include/llvm/ProfileData/GCOV.h +++ b/llvm/include/llvm/ProfileData/GCOV.h @@ -21,6 +21,7 @@ #include "llvm/ADT/StringRef.h" #include "llvm/ADT/iterator.h" #include "llvm/ADT/iterator_range.h" +#include "llvm/Support/Compiler.h" #include "llvm/Support/DataExtractor.h" #include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/raw_ostream.h" @@ -192,11 +193,11 @@ class GCOVFile { public: GCOVFile() = default; - bool readGCNO(GCOVBuffer &Buffer); - bool readGCDA(GCOVBuffer &Buffer); + LLVM_ABI bool readGCNO(GCOVBuffer &Buffer); + LLVM_ABI bool readGCDA(GCOVBuffer &Buffer); GCOV::GCOVVersion getVersion() const { return version; } - void print(raw_ostream &OS) const; - void dump() const; + LLVM_ABI void print(raw_ostream &OS) const; + LLVM_ABI void dump() const; std::vector filenames; StringMap filenameToIdx; @@ -223,7 +224,7 @@ class GCOVFile { struct GCOVArc { GCOVArc(GCOVBlock &src, GCOVBlock &dst, uint32_t flags) : src(src), dst(dst), flags(flags) {} - bool onTree() const; + LLVM_ABI bool onTree() const; GCOVBlock &src; GCOVBlock &dst; @@ -240,18 +241,18 @@ class GCOVFunction { GCOVFunction(GCOVFile &file) : file(file) {} - StringRef getName(bool demangle) const; - StringRef getFilename() const; - uint64_t getEntryCount() const; - GCOVBlock &getExitBlock() const; + LLVM_ABI StringRef getName(bool demangle) const; + LLVM_ABI StringRef getFilename() const; + LLVM_ABI uint64_t getEntryCount() const; + LLVM_ABI GCOVBlock &getExitBlock() const; iterator_range blocksRange() const { return make_range(blocks.begin(), blocks.end()); } - void propagateCounts(const GCOVBlock &v, GCOVArc *pred); - void print(raw_ostream &OS) const; - void dump() const; + LLVM_ABI void propagateCounts(const GCOVBlock &v, GCOVArc *pred); + LLVM_ABI void print(raw_ostream &OS) const; + LLVM_ABI void dump() const; GCOVFile &file; uint32_t ident = 0; @@ -296,14 +297,14 @@ class GCOVBlock { return make_range(succ.begin(), succ.end()); } - void print(raw_ostream &OS) const; - void dump() const; + LLVM_ABI void print(raw_ostream &OS) const; + LLVM_ABI void dump() const; - static uint64_t + LLVM_ABI static uint64_t augmentOneCycle(GCOVBlock *src, std::vector> &stack); - static uint64_t getCyclesCount(const BlockVector &blocks); - static uint64_t getLineCount(const BlockVector &Blocks); + LLVM_ABI static uint64_t getCyclesCount(const BlockVector &blocks); + LLVM_ABI static uint64_t getLineCount(const BlockVector &Blocks); public: uint32_t number; @@ -315,8 +316,8 @@ class GCOVBlock { GCOVArc *incoming = nullptr; }; -void gcovOneInput(const GCOV::Options &options, StringRef filename, - StringRef gcno, StringRef gcda, GCOVFile &file); +LLVM_ABI void gcovOneInput(const GCOV::Options &options, StringRef filename, + StringRef gcno, StringRef gcda, GCOVFile &file); } // end namespace llvm diff --git a/llvm/include/llvm/ProfileData/IndexedMemProfData.h b/llvm/include/llvm/ProfileData/IndexedMemProfData.h index 9af8755281be4..dae0928d50ca7 100644 --- a/llvm/include/llvm/ProfileData/IndexedMemProfData.h +++ b/llvm/include/llvm/ProfileData/IndexedMemProfData.h @@ -18,6 +18,7 @@ #include "llvm/ProfileData/DataAccessProf.h" #include "llvm/ProfileData/InstrProf.h" #include "llvm/ProfileData/MemProf.h" +#include "llvm/Support/Compiler.h" #include #include @@ -87,7 +88,7 @@ struct IndexedMemProfData { } // namespace memprof // Write the MemProf data to OS. -Error writeMemProf( +LLVM_ABI Error writeMemProf( ProfOStream &OS, memprof::IndexedMemProfData &MemProfData, memprof::IndexedVersion MemProfVersionRequested, bool MemProfFullSchema, std::unique_ptr DataAccessProfileData, diff --git a/llvm/include/llvm/ProfileData/InstrProf.h b/llvm/include/llvm/ProfileData/InstrProf.h index 544a59df43ed3..f53602424b583 100644 --- a/llvm/include/llvm/ProfileData/InstrProf.h +++ b/llvm/include/llvm/ProfileData/InstrProf.h @@ -69,18 +69,18 @@ struct PatchItem { // back patching. class ProfOStream { public: - ProfOStream(raw_fd_ostream &FD); - ProfOStream(raw_string_ostream &STR); + LLVM_ABI ProfOStream(raw_fd_ostream &FD); + LLVM_ABI ProfOStream(raw_string_ostream &STR); - [[nodiscard]] uint64_t tell() const; - void write(uint64_t V); - void write32(uint32_t V); - void writeByte(uint8_t V); + [[nodiscard]] LLVM_ABI uint64_t tell() const; + LLVM_ABI void write(uint64_t V); + LLVM_ABI void write32(uint32_t V); + LLVM_ABI void writeByte(uint8_t V); // \c patch can only be called when all data is written and flushed. // For raw_string_ostream, the patch is done on the target string // directly and it won't be reflected in the stream's internal buffer. - void patch(ArrayRef P); + LLVM_ABI void patch(ArrayRef P); // If \c OS is an instance of \c raw_fd_ostream, this field will be // true. Otherwise, \c OS will be an raw_string_ostream. @@ -104,9 +104,9 @@ inline uint64_t getInstrMaxCountValue() { /// The name of the section depends on the object format type \p OF. If /// \p AddSegmentInfo is true, a segment prefix and additional linker hints may /// be added to the section name (this is the default). -std::string getInstrProfSectionName(InstrProfSectKind IPSK, - Triple::ObjectFormatType OF, - bool AddSegmentInfo = true); +LLVM_ABI std::string getInstrProfSectionName(InstrProfSectKind IPSK, + Triple::ObjectFormatType OF, + bool AddSegmentInfo = true); /// Return the name profile runtime entry point to do value profiling /// for a given site. @@ -215,62 +215,64 @@ inline StringRef getInstrProfNameSeparator() { return "\01"; } /// Determines whether module targets a GPU eligable for PGO /// instrumentation -bool isGPUProfTarget(const Module &M); +LLVM_ABI bool isGPUProfTarget(const Module &M); /// Please use getIRPGOFuncName for LLVM IR instrumentation. This function is /// for front-end (Clang, etc) instrumentation. /// Return the modified name for function \c F suitable to be /// used the key for profile lookup. Variable \c InLTO indicates if this /// is called in LTO optimization passes. -std::string getPGOFuncName(const Function &F, bool InLTO = false, - uint64_t Version = INSTR_PROF_INDEX_VERSION); +LLVM_ABI std::string +getPGOFuncName(const Function &F, bool InLTO = false, + uint64_t Version = INSTR_PROF_INDEX_VERSION); /// Return the modified name for a function suitable to be /// used the key for profile lookup. The function's original /// name is \c RawFuncName and has linkage of type \c Linkage. /// The function is defined in module \c FileName. -std::string getPGOFuncName(StringRef RawFuncName, - GlobalValue::LinkageTypes Linkage, - StringRef FileName, - uint64_t Version = INSTR_PROF_INDEX_VERSION); +LLVM_ABI std::string +getPGOFuncName(StringRef RawFuncName, GlobalValue::LinkageTypes Linkage, + StringRef FileName, uint64_t Version = INSTR_PROF_INDEX_VERSION); /// \return the modified name for function \c F suitable to be /// used as the key for IRPGO profile lookup. \c InLTO indicates if this is /// called from LTO optimization passes. -std::string getIRPGOFuncName(const Function &F, bool InLTO = false); +LLVM_ABI std::string getIRPGOFuncName(const Function &F, bool InLTO = false); /// \return the filename and the function name parsed from the output of /// \c getIRPGOFuncName() -std::pair getParsedIRPGOName(StringRef IRPGOName); +LLVM_ABI std::pair +getParsedIRPGOName(StringRef IRPGOName); /// Return the name of the global variable used to store a function /// name in PGO instrumentation. \c FuncName is the IRPGO function name /// (returned by \c getIRPGOFuncName) for LLVM IR instrumentation and PGO /// function name (returned by \c getPGOFuncName) for front-end instrumentation. -std::string getPGOFuncNameVarName(StringRef FuncName, - GlobalValue::LinkageTypes Linkage); +LLVM_ABI std::string getPGOFuncNameVarName(StringRef FuncName, + GlobalValue::LinkageTypes Linkage); /// Create and return the global variable for function name used in PGO /// instrumentation. \c FuncName is the IRPGO function name (returned by /// \c getIRPGOFuncName) for LLVM IR instrumentation and PGO function name /// (returned by \c getPGOFuncName) for front-end instrumentation. -GlobalVariable *createPGOFuncNameVar(Function &F, StringRef PGOFuncName); +LLVM_ABI GlobalVariable *createPGOFuncNameVar(Function &F, + StringRef PGOFuncName); /// Create and return the global variable for function name used in PGO /// instrumentation. \c FuncName is the IRPGO function name (returned by /// \c getIRPGOFuncName) for LLVM IR instrumentation and PGO function name /// (returned by \c getPGOFuncName) for front-end instrumentation. -GlobalVariable *createPGOFuncNameVar(Module &M, - GlobalValue::LinkageTypes Linkage, - StringRef PGOFuncName); +LLVM_ABI GlobalVariable *createPGOFuncNameVar(Module &M, + GlobalValue::LinkageTypes Linkage, + StringRef PGOFuncName); /// Return the initializer in string of the PGO name var \c NameVar. -StringRef getPGOFuncNameVarInitializer(GlobalVariable *NameVar); +LLVM_ABI StringRef getPGOFuncNameVarInitializer(GlobalVariable *NameVar); /// Given a PGO function name, remove the filename prefix and return /// the original (static) function name. -StringRef getFuncNameWithoutPrefix(StringRef PGOFuncName, - StringRef FileName = ""); +LLVM_ABI StringRef getFuncNameWithoutPrefix(StringRef PGOFuncName, + StringRef FileName = ""); /// Given a vector of strings (names of global objects like functions or, /// virtual tables) \c NameStrs, the method generates a combined string \c @@ -281,28 +283,31 @@ StringRef getFuncNameWithoutPrefix(StringRef PGOFuncName, /// third field is the uncompressed strings; otherwise it is the /// compressed string. When the string compression is off, the /// second field will have value zero. -Error collectGlobalObjectNameStrings(ArrayRef NameStrs, - bool doCompression, std::string &Result); +LLVM_ABI Error collectGlobalObjectNameStrings(ArrayRef NameStrs, + bool doCompression, + std::string &Result); /// Produce \c Result string with the same format described above. The input /// is vector of PGO function name variables that are referenced. /// The global variable element in 'NameVars' is a string containing the pgo /// name of a function. See `createPGOFuncNameVar` that creates these global /// variables. -Error collectPGOFuncNameStrings(ArrayRef NameVars, - std::string &Result, bool doCompression = true); +LLVM_ABI Error collectPGOFuncNameStrings(ArrayRef NameVars, + std::string &Result, + bool doCompression = true); -Error collectVTableStrings(ArrayRef VTables, - std::string &Result, bool doCompression); +LLVM_ABI Error collectVTableStrings(ArrayRef VTables, + std::string &Result, bool doCompression); /// Check if INSTR_PROF_RAW_VERSION_VAR is defined. This global is only being /// set in IR PGO compilation. -bool isIRPGOFlagSet(const Module *M); +LLVM_ABI bool isIRPGOFlagSet(const Module *M); /// Check if we can safely rename this Comdat function. Instances of the same /// comdat function may have different control flows thus can not share the /// same counter variable. -bool canRenameComdatFunc(const Function &F, bool CheckAddressTaken = false); +LLVM_ABI bool canRenameComdatFunc(const Function &F, + bool CheckAddressTaken = false); enum InstrProfValueKind : uint32_t { #define VALUE_PROF_KIND(Enumerator, Value, Descr) Enumerator = Value, @@ -312,23 +317,24 @@ enum InstrProfValueKind : uint32_t { /// Get the value profile data for value site \p SiteIdx from \p InstrProfR /// and annotate the instruction \p Inst with the value profile meta data. /// Annotate up to \p MaxMDCount (default 3) number of records per value site. -void annotateValueSite(Module &M, Instruction &Inst, - const InstrProfRecord &InstrProfR, - InstrProfValueKind ValueKind, uint32_t SiteIndx, - uint32_t MaxMDCount = 3); +LLVM_ABI void annotateValueSite(Module &M, Instruction &Inst, + const InstrProfRecord &InstrProfR, + InstrProfValueKind ValueKind, uint32_t SiteIndx, + uint32_t MaxMDCount = 3); /// Same as the above interface but using an ArrayRef, as well as \p Sum. /// This function will not annotate !prof metadata on the instruction if the /// referenced array is empty. -void annotateValueSite(Module &M, Instruction &Inst, - ArrayRef VDs, uint64_t Sum, - InstrProfValueKind ValueKind, uint32_t MaxMDCount); +LLVM_ABI void annotateValueSite(Module &M, Instruction &Inst, + ArrayRef VDs, uint64_t Sum, + InstrProfValueKind ValueKind, + uint32_t MaxMDCount); // TODO: Unify metadata name 'PGOFuncName' and 'PGOName', by supporting read // of this metadata for backward compatibility and generating 'PGOName' only. /// Extract the value profile data from \p Inst and returns them if \p Inst is /// annotated with value profile data. Returns an empty vector otherwise. -SmallVector +LLVM_ABI SmallVector getValueProfDataFromInst(const Instruction &Inst, InstrProfValueKind ValueKind, uint32_t MaxNumValueData, uint64_t &TotalC, bool GetNoICPValue = false); @@ -338,31 +344,31 @@ inline StringRef getPGOFuncNameMetadataName() { return "PGOFuncName"; } inline StringRef getPGONameMetadataName() { return "PGOName"; } /// Return the PGOFuncName meta data associated with a function. -MDNode *getPGOFuncNameMetadata(const Function &F); +LLVM_ABI MDNode *getPGOFuncNameMetadata(const Function &F); -std::string getPGOName(const GlobalVariable &V, bool InLTO = false); +LLVM_ABI std::string getPGOName(const GlobalVariable &V, bool InLTO = false); /// Create the PGOFuncName meta data if PGOFuncName is different from /// function's raw name. This should only apply to internal linkage functions /// declared by users only. /// TODO: Update all callers to 'createPGONameMetadata' and deprecate this /// function. -void createPGOFuncNameMetadata(Function &F, StringRef PGOFuncName); +LLVM_ABI void createPGOFuncNameMetadata(Function &F, StringRef PGOFuncName); /// Create the PGOName metadata if a global object's PGO name is different from /// its mangled name. This should apply to local-linkage global objects only. -void createPGONameMetadata(GlobalObject &GO, StringRef PGOName); +LLVM_ABI void createPGONameMetadata(GlobalObject &GO, StringRef PGOName); /// Check if we can use Comdat for profile variables. This will eliminate /// the duplicated profile variables for Comdat functions. -bool needsComdatForCounter(const GlobalObject &GV, const Module &M); +LLVM_ABI bool needsComdatForCounter(const GlobalObject &GV, const Module &M); /// \c NameStrings is a string composed of one or more possibly encoded /// sub-strings. The substrings are separated by `\01` (returned by /// InstrProf.h:getInstrProfNameSeparator). This method decodes the string and /// calls `NameCallback` for each substring. -Error readAndDecodeStrings(StringRef NameStrings, - std::function NameCallback); +LLVM_ABI Error readAndDecodeStrings( + StringRef NameStrings, std::function NameCallback); /// An enum describing the attributes of an instrumented profile. enum class InstrProfKind { @@ -388,7 +394,7 @@ enum class InstrProfKind { LLVM_MARK_AS_BITMASK_ENUM(/*LargestValue=*/LoopEntriesInstrumentation) }; -const std::error_category &instrprof_category(); +LLVM_ABI const std::error_category &instrprof_category(); enum class instrprof_error { success = 0, @@ -431,16 +437,17 @@ struct TemporalProfTraceTy { /// Use a set of temporal profile traces to create a list of balanced /// partitioning function nodes used by BalancedPartitioning to generate a /// function order that reduces page faults during startup - static void createBPFunctionNodes(ArrayRef Traces, - std::vector &Nodes, - bool RemoveOutlierUNs = true); + LLVM_ABI static void + createBPFunctionNodes(ArrayRef Traces, + std::vector &Nodes, + bool RemoveOutlierUNs = true); }; inline std::error_code make_error_code(instrprof_error E) { return std::error_code(static_cast(E), instrprof_category()); } -class InstrProfError : public ErrorInfo { +class LLVM_ABI InstrProfError : public ErrorInfo { public: InstrProfError(instrprof_error Err, const Twine &ErrStr = Twine()) : Err(Err), Msg(ErrStr.str()) { @@ -503,7 +510,7 @@ class InstrProfSymtab { // Returns the canonical name of the given PGOName. In a canonical name, all // suffixes that begins with "." except ".__uniq." are stripped. // FIXME: Unify this with `FunctionSamples::getCanonicalFnName`. - static StringRef getCanonicalName(StringRef PGOName); + LLVM_ABI static StringRef getCanonicalName(StringRef PGOName); private: using AddrIntervalMap = @@ -577,22 +584,23 @@ class InstrProfSymtab { /// only initialize the symtab with reference to the data and /// the section base address. The decompression will be delayed /// until before it is used. See also \c create(StringRef) method. - Error create(object::SectionRef &Section); + LLVM_ABI Error create(object::SectionRef &Section); /// \c NameStrings is a string composed of one of more sub-strings /// encoded in the format described in \c collectPGOFuncNameStrings. /// This method is a wrapper to \c readAndDecodeStrings method. - Error create(StringRef NameStrings); + LLVM_ABI Error create(StringRef NameStrings); /// Initialize symtab states with function names and vtable names. \c /// FuncNameStrings is a string composed of one or more encoded function name /// strings, and \c VTableNameStrings composes of one or more encoded vtable /// names. This interface is solely used by raw profile reader. - Error create(StringRef FuncNameStrings, StringRef VTableNameStrings); + LLVM_ABI Error create(StringRef FuncNameStrings, StringRef VTableNameStrings); /// Initialize 'this' with the set of vtable names encoded in /// \c CompressedVTableNames. - Error initVTableNamesFromCompressedStrings(StringRef CompressedVTableNames); + LLVM_ABI Error + initVTableNamesFromCompressedStrings(StringRef CompressedVTableNames); /// This interface is used by reader of CoverageMapping test /// format. @@ -604,7 +612,8 @@ class InstrProfSymtab { /// indicates if this is called from LTO optimization passes. /// A canonical name, removing non-__uniq suffixes, is added if /// \c AddCanonical is true. - Error create(Module &M, bool InLTO = false, bool AddCanonical = true); + LLVM_ABI Error create(Module &M, bool InLTO = false, + bool AddCanonical = true); /// Create InstrProfSymtab from a set of names iteratable from /// \p IterRange. This interface is used by IndexedProfReader. @@ -667,15 +676,15 @@ class InstrProfSymtab { } /// Return a function's hash, or 0, if the function isn't in this SymTab. - uint64_t getFunctionHashFromAddress(uint64_t Address); + LLVM_ABI uint64_t getFunctionHashFromAddress(uint64_t Address); /// Return a vtable's hash, or 0 if the vtable doesn't exist in this SymTab. - uint64_t getVTableHashFromAddress(uint64_t Address); + LLVM_ABI uint64_t getVTableHashFromAddress(uint64_t Address); /// Return function's PGO name from the function name's symbol /// address in the object file. If an error occurs, return /// an empty string. - StringRef getFuncName(uint64_t FuncNameAddress, size_t NameSize); + LLVM_ABI StringRef getFuncName(uint64_t FuncNameAddress, size_t NameSize); /// Return name of functions or global variables from the name's md5 hash /// value. If not found, return an empty string. @@ -702,7 +711,7 @@ class InstrProfSymtab { inline StringRef getNameData() const { return Data; } /// Dump the symbols in this table. - void dumpNames(raw_ostream &OS) const; + LLVM_ABI void dumpNames(raw_ostream &OS) const; }; Error InstrProfSymtab::create(StringRef D, uint64_t BaseAddr) { @@ -814,17 +823,17 @@ struct OverlapStats { OverlapStats(OverlapStatsLevel L = ProgramLevel) : Level(L) {} - void dump(raw_fd_ostream &OS) const; + LLVM_ABI void dump(raw_fd_ostream &OS) const; void setFuncInfo(StringRef Name, uint64_t Hash) { FuncName = Name; FuncHash = Hash; } - Error accumulateCounts(const std::string &BaseFilename, - const std::string &TestFilename, bool IsCS); - void addOneMismatch(const CountSumOrPercent &MismatchFunc); - void addOneUnique(const CountSumOrPercent &UniqueFunc); + LLVM_ABI Error accumulateCounts(const std::string &BaseFilename, + const std::string &TestFilename, bool IsCS); + LLVM_ABI void addOneMismatch(const CountSumOrPercent &MismatchFunc); + LLVM_ABI void addOneUnique(const CountSumOrPercent &UniqueFunc); static inline double score(uint64_t Val1, uint64_t Val2, double Sum1, double Sum2) { @@ -861,14 +870,15 @@ struct InstrProfValueSiteRecord { /// Merge data from another InstrProfValueSiteRecord /// Optionally scale merged counts by \p Weight. - void merge(InstrProfValueSiteRecord &Input, uint64_t Weight, - function_ref Warn); + LLVM_ABI void merge(InstrProfValueSiteRecord &Input, uint64_t Weight, + function_ref Warn); /// Scale up value profile data counts by N (Numerator) / D (Denominator). - void scale(uint64_t N, uint64_t D, function_ref Warn); + LLVM_ABI void scale(uint64_t N, uint64_t D, + function_ref Warn); /// Compute the overlap b/w this record and Input record. - void overlap(InstrProfValueSiteRecord &Input, uint32_t ValueKind, - OverlapStats &Overlap, OverlapStats &FuncLevelOverlap); + LLVM_ABI void overlap(InstrProfValueSiteRecord &Input, uint32_t ValueKind, + OverlapStats &Overlap, OverlapStats &FuncLevelOverlap); }; /// Profiling information for a single function. @@ -920,18 +930,19 @@ struct InstrProfRecord { /// Add ValueData for ValueKind at value Site. We do not support adding sites /// out of order. Site must go up from 0 one by one. - void addValueData(uint32_t ValueKind, uint32_t Site, - ArrayRef VData, - InstrProfSymtab *SymTab); + LLVM_ABI void addValueData(uint32_t ValueKind, uint32_t Site, + ArrayRef VData, + InstrProfSymtab *SymTab); /// Merge the counts in \p Other into this one. /// Optionally scale merged counts by \p Weight. - void merge(InstrProfRecord &Other, uint64_t Weight, - function_ref Warn); + LLVM_ABI void merge(InstrProfRecord &Other, uint64_t Weight, + function_ref Warn); /// Scale up profile counts (including value profile data) by /// a factor of (N / D). - void scale(uint64_t N, uint64_t D, function_ref Warn); + LLVM_ABI void scale(uint64_t N, uint64_t D, + function_ref Warn); /// Sort value profile data (per site) by count. void sortValueData() { @@ -950,16 +961,16 @@ struct InstrProfRecord { void clearValueData() { ValueData = nullptr; } /// Compute the sums of all counts and store in Sum. - void accumulateCounts(CountSumOrPercent &Sum) const; + LLVM_ABI void accumulateCounts(CountSumOrPercent &Sum) const; /// Compute the overlap b/w this IntrprofRecord and Other. - void overlap(InstrProfRecord &Other, OverlapStats &Overlap, - OverlapStats &FuncLevelOverlap, uint64_t ValueCutoff); + LLVM_ABI void overlap(InstrProfRecord &Other, OverlapStats &Overlap, + OverlapStats &FuncLevelOverlap, uint64_t ValueCutoff); /// Compute the overlap of value profile counts. - void overlapValueProfData(uint32_t ValueKind, InstrProfRecord &Src, - OverlapStats &Overlap, - OverlapStats &FuncLevelOverlap); + LLVM_ABI void overlapValueProfData(uint32_t ValueKind, InstrProfRecord &Src, + OverlapStats &Overlap, + OverlapStats &FuncLevelOverlap); enum CountPseudoKind { NotPseudo = 0, @@ -1187,15 +1198,15 @@ struct Header { // Reads a header struct from the buffer. Header fields are in machine native // endianness. - static Expected
readFromBuffer(const unsigned char *Buffer); + LLVM_ABI static Expected
readFromBuffer(const unsigned char *Buffer); // Returns the size of the header in bytes for all valid fields based on the // version. I.e a older version header will return a smaller size. - size_t size() const; + LLVM_ABI size_t size() const; // Return the indexed profile version, i.e., the least significant 32 bits // in Header.Version. - uint64_t getIndexedProfileVersion() const; + LLVM_ABI uint64_t getIndexedProfileVersion() const; }; // Profile summary data recorded in the profile data file in indexed @@ -1340,11 +1351,11 @@ struct Header { } // end namespace RawInstrProf // Create the variable for the profile file name. -void createProfileFileNameVar(Module &M, StringRef InstrProfileOutput); +LLVM_ABI void createProfileFileNameVar(Module &M, StringRef InstrProfileOutput); // Whether to compress function names in profile records, and filenames in // code coverage mappings. Used by the Instrumentation library and unit tests. -extern cl::opt DoInstrProfNameCompression; +LLVM_ABI extern cl::opt DoInstrProfNameCompression; } // end namespace llvm #endif // LLVM_PROFILEDATA_INSTRPROF_H diff --git a/llvm/include/llvm/ProfileData/InstrProfCorrelator.h b/llvm/include/llvm/ProfileData/InstrProfCorrelator.h index ed8642495cd74..d460eb1cdf528 100644 --- a/llvm/include/llvm/ProfileData/InstrProfCorrelator.h +++ b/llvm/include/llvm/ProfileData/InstrProfCorrelator.h @@ -16,6 +16,7 @@ #include "llvm/Debuginfod/BuildIDFetcher.h" #include "llvm/Object/BuildID.h" #include "llvm/ProfileData/InstrProf.h" +#include "llvm/Support/Compiler.h" #include "llvm/Support/Error.h" #include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/YAMLTraits.h" @@ -37,7 +38,7 @@ class InstrProfCorrelator { /// correlate. enum ProfCorrelatorKind { NONE, DEBUG_INFO, BINARY }; - static llvm::Expected> + LLVM_ABI static llvm::Expected> get(StringRef Filename, ProfCorrelatorKind FileKind, const object::BuildIDFetcher *BIDFetcher = nullptr, const ArrayRef BIs = {}); @@ -52,7 +53,7 @@ class InstrProfCorrelator { virtual Error dumpYaml(int MaxWarnings, raw_ostream &OS) = 0; /// Return the number of ProfileData elements. - std::optional getDataSize() const; + LLVM_ABI std::optional getDataSize() const; /// Return a pointer to the names string that this class constructs. const char *getNamesPointer() const { return Names.c_str(); } @@ -65,9 +66,9 @@ class InstrProfCorrelator { return Ctx->CountersSectionEnd - Ctx->CountersSectionStart; } - static const char *FunctionNameAttributeName; - static const char *CFGHashAttributeName; - static const char *NumCountersAttributeName; + LLVM_ABI static const char *FunctionNameAttributeName; + LLVM_ABI static const char *CFGHashAttributeName; + LLVM_ABI static const char *NumCountersAttributeName; enum InstrProfCorrelatorKind { CK_32Bit, CK_64Bit }; InstrProfCorrelatorKind getKind() const { return Kind; } @@ -75,7 +76,7 @@ class InstrProfCorrelator { protected: struct Context { - static llvm::Expected> + LLVM_ABI static llvm::Expected> get(std::unique_ptr Buffer, const object::ObjectFile &Obj, ProfCorrelatorKind FileKind); std::unique_ptr Buffer; diff --git a/llvm/include/llvm/ProfileData/InstrProfData.inc b/llvm/include/llvm/ProfileData/InstrProfData.inc index 6d18680f89165..0496f240dc823 100644 --- a/llvm/include/llvm/ProfileData/InstrProfData.inc +++ b/llvm/include/llvm/ProfileData/InstrProfData.inc @@ -405,14 +405,14 @@ typedef struct ValueProfRecord { /*! * Read data from this record and save it to Record. */ - void deserializeTo(InstrProfRecord &Record, + LLVM_ABI void deserializeTo(InstrProfRecord &Record, InstrProfSymtab *SymTab); /* * In-place byte swap: * Do byte swap for this instance. \c Old is the original order before * the swap, and \c New is the New byte order. */ - void swapBytes(llvm::endianness Old, llvm::endianness New); + LLVM_ABI void swapBytes(llvm::endianness Old, llvm::endianness New); #endif } ValueProfRecord; @@ -449,41 +449,41 @@ typedef struct ValueProfData { * Return the total size in bytes of the on-disk value profile data * given the data stored in Record. */ - static uint32_t getSize(const InstrProfRecord &Record); + LLVM_ABI static uint32_t getSize(const InstrProfRecord &Record); /*! * Return a pointer to \c ValueProfData instance ready to be streamed. */ - static std::unique_ptr + LLVM_ABI static std::unique_ptr serializeFrom(const InstrProfRecord &Record); /*! * Check the integrity of the record. */ - Error checkIntegrity(); + LLVM_ABI Error checkIntegrity(); /*! * Return a pointer to \c ValueProfileData instance ready to be read. * All data in the instance are properly byte swapped. The input * data is assumed to be in little endian order. */ - static Expected> + LLVM_ABI static Expected> getValueProfData(const unsigned char *SrcBuffer, const unsigned char *const SrcBufferEnd, llvm::endianness SrcDataEndianness); /*! * Swap byte order from \c Endianness order to host byte order. */ - void swapBytesToHost(llvm::endianness Endianness); + LLVM_ABI void swapBytesToHost(llvm::endianness Endianness); /*! * Swap byte order from host byte order to \c Endianness order. */ - void swapBytesFromHost(llvm::endianness Endianness); + LLVM_ABI void swapBytesFromHost(llvm::endianness Endianness); /*! * Return the total size of \c ValueProfileData. */ - uint32_t getSize() const { return TotalSize; } + LLVM_ABI uint32_t getSize() const { return TotalSize; } /*! * Read data from this data and save it to \c Record. */ - void deserializeTo(InstrProfRecord &Record, + LLVM_ABI void deserializeTo(InstrProfRecord &Record, InstrProfSymtab *SymTab); void operator delete(void *ptr) { ::operator delete(ptr); } #endif diff --git a/llvm/include/llvm/ProfileData/InstrProfReader.h b/llvm/include/llvm/ProfileData/InstrProfReader.h index 99ea3c1808f5e..3b12505d3326c 100644 --- a/llvm/include/llvm/ProfileData/InstrProfReader.h +++ b/llvm/include/llvm/ProfileData/InstrProfReader.h @@ -24,6 +24,7 @@ #include "llvm/ProfileData/MemProf.h" #include "llvm/ProfileData/MemProfSummary.h" #include "llvm/ProfileData/MemProfYAML.h" +#include "llvm/Support/Compiler.h" #include "llvm/Support/Endian.h" #include "llvm/Support/Error.h" #include "llvm/Support/LineIterator.h" @@ -158,7 +159,7 @@ class InstrProfReader { virtual InstrProfSymtab &getSymtab() = 0; /// Compute the sum of counts and return in Sum. - void accumulateCounts(CountSumOrPercent &Sum, bool IsCS); + LLVM_ABI void accumulateCounts(CountSumOrPercent &Sum, bool IsCS); protected: std::unique_ptr Symtab; @@ -203,7 +204,7 @@ class InstrProfReader { /// Factory method to create an appropriately typed reader for the given /// instrprof file. - static Expected> create( + LLVM_ABI static Expected> create( const Twine &Path, vfs::FileSystem &FS, const InstrProfCorrelator *Correlator = nullptr, const object::BuildIDFetcher *BIDFetcher = nullptr, @@ -211,7 +212,7 @@ class InstrProfReader { InstrProfCorrelator::ProfCorrelatorKind::NONE, std::function Warn = nullptr); - static Expected> create( + LLVM_ABI static Expected> create( std::unique_ptr Buffer, const InstrProfCorrelator *Correlator = nullptr, const object::BuildIDFetcher *BIDFetcher = nullptr, @@ -242,7 +243,7 @@ class InstrProfReader { /// /// Each record consists of a function name, a function hash, a number of /// counters, and then each counter value, in that order. -class TextInstrProfReader : public InstrProfReader { +class LLVM_ABI TextInstrProfReader : public InstrProfReader { private: /// The profile data file contents. std::unique_ptr DataBuffer; @@ -535,7 +536,7 @@ class InstrProfLookupTrait { static StringRef GetInternalKey(StringRef K) { return K; } static StringRef GetExternalKey(StringRef K) { return K; } - hash_value_type ComputeHash(StringRef K); + LLVM_ABI hash_value_type ComputeHash(StringRef K); static std::pair ReadKeyDataLength(const unsigned char *&D) { @@ -552,9 +553,10 @@ class InstrProfLookupTrait { return StringRef((const char *)D, N); } - bool readValueProfilingData(const unsigned char *&D, - const unsigned char *const End); - data_type ReadData(StringRef K, const unsigned char *D, offset_type N); + LLVM_ABI bool readValueProfilingData(const unsigned char *&D, + const unsigned char *const End); + LLVM_ABI data_type ReadData(StringRef K, const unsigned char *D, + offset_type N); // Used for testing purpose only. void setValueProfDataEndianness(llvm::endianness Endianness) { @@ -718,22 +720,23 @@ class IndexedMemProfReader { public: IndexedMemProfReader() = default; - Error deserialize(const unsigned char *Start, uint64_t MemProfOffset); + LLVM_ABI Error deserialize(const unsigned char *Start, + uint64_t MemProfOffset); - Expected + LLVM_ABI Expected getMemProfRecord(const uint64_t FuncNameHash) const; - DenseMap> + LLVM_ABI DenseMap> getMemProfCallerCalleePairs() const; // Return the entire MemProf profile. - memprof::AllMemProfData getAllMemProfData() const; + LLVM_ABI memprof::AllMemProfData getAllMemProfData() const; memprof::MemProfSummary *getSummary() const { return MemProfSum.get(); } }; /// Reader for the indexed binary instrprof format. -class IndexedInstrProfReader : public InstrProfReader { +class LLVM_ABI IndexedInstrProfReader : public InstrProfReader { private: /// The profile data file contents. std::unique_ptr DataBuffer; diff --git a/llvm/include/llvm/ProfileData/InstrProfWriter.h b/llvm/include/llvm/ProfileData/InstrProfWriter.h index ee541c465bd16..f339fe2c2a9eb 100644 --- a/llvm/include/llvm/ProfileData/InstrProfWriter.h +++ b/llvm/include/llvm/ProfileData/InstrProfWriter.h @@ -23,6 +23,7 @@ #include "llvm/ProfileData/IndexedMemProfData.h" #include "llvm/ProfileData/InstrProf.h" #include "llvm/ProfileData/MemProfSummaryBuilder.h" +#include "llvm/Support/Compiler.h" #include "llvm/Support/Error.h" #include #include @@ -94,25 +95,25 @@ class InstrProfWriter { // MemprofGenerateRandomHotness is enabled. The random seed can be either // provided by MemprofGenerateRandomHotnessSeed, or if that is 0, one will be // generated in the writer using the current time. - InstrProfWriter(bool Sparse = false, - uint64_t TemporalProfTraceReservoirSize = 0, - uint64_t MaxTemporalProfTraceLength = 0, - bool WritePrevVersion = false, - memprof::IndexedVersion MemProfVersionRequested = - static_cast( - memprof::MinimumSupportedVersion), - bool MemProfFullSchema = false, - bool MemprofGenerateRandomHotness = false, - unsigned MemprofGenerateRandomHotnessSeed = 0); - ~InstrProfWriter(); + LLVM_ABI InstrProfWriter(bool Sparse = false, + uint64_t TemporalProfTraceReservoirSize = 0, + uint64_t MaxTemporalProfTraceLength = 0, + bool WritePrevVersion = false, + memprof::IndexedVersion MemProfVersionRequested = + static_cast( + memprof::MinimumSupportedVersion), + bool MemProfFullSchema = false, + bool MemprofGenerateRandomHotness = false, + unsigned MemprofGenerateRandomHotnessSeed = 0); + LLVM_ABI ~InstrProfWriter(); StringMap &getProfileData() { return FunctionData; } /// Add function counts for the given function. If there are already counts /// for this function and the hash and number of counts match, each counter is /// summed. Optionally scale counts by \p Weight. - void addRecord(NamedInstrProfRecord &&I, uint64_t Weight, - function_ref Warn); + LLVM_ABI void addRecord(NamedInstrProfRecord &&I, uint64_t Weight, + function_ref Warn); void addRecord(NamedInstrProfRecord &&I, function_ref Warn) { addRecord(std::move(I), 1, Warn); } @@ -120,45 +121,47 @@ class InstrProfWriter { /// Add \p SrcTraces using reservoir sampling where \p SrcStreamSize is the /// total number of temporal profiling traces the source has seen. - void addTemporalProfileTraces(SmallVectorImpl &SrcTraces, - uint64_t SrcStreamSize); + LLVM_ABI void + addTemporalProfileTraces(SmallVectorImpl &SrcTraces, + uint64_t SrcStreamSize); /// Add the entire MemProfData \p Incoming to the writer context. - bool addMemProfData(memprof::IndexedMemProfData Incoming, - function_ref Warn); + LLVM_ABI bool addMemProfData(memprof::IndexedMemProfData Incoming, + function_ref Warn); // Add a binary id to the binary ids list. - void addBinaryIds(ArrayRef BIs); + LLVM_ABI void addBinaryIds(ArrayRef BIs); - void addDataAccessProfData( + LLVM_ABI void addDataAccessProfData( std::unique_ptr DataAccessProfile); /// Merge existing function counts from the given writer. - void mergeRecordsFromWriter(InstrProfWriter &&IPW, - function_ref Warn); + LLVM_ABI void mergeRecordsFromWriter(InstrProfWriter &&IPW, + function_ref Warn); /// Write the profile to \c OS - Error write(raw_fd_ostream &OS); + LLVM_ABI Error write(raw_fd_ostream &OS); /// Write the profile to a string output stream \c OS - Error write(raw_string_ostream &OS); + LLVM_ABI Error write(raw_string_ostream &OS); /// Write the profile in text format to \c OS - Error writeText(raw_fd_ostream &OS); + LLVM_ABI Error writeText(raw_fd_ostream &OS); /// Write temporal profile trace data to the header in text format to \c OS - void writeTextTemporalProfTraceData(raw_fd_ostream &OS, - InstrProfSymtab &Symtab); + LLVM_ABI void writeTextTemporalProfTraceData(raw_fd_ostream &OS, + InstrProfSymtab &Symtab); - Error validateRecord(const InstrProfRecord &Func); + LLVM_ABI Error validateRecord(const InstrProfRecord &Func); /// Write \c Record in text format to \c OS - static void writeRecordInText(StringRef Name, uint64_t Hash, - const InstrProfRecord &Counters, - InstrProfSymtab &Symtab, raw_fd_ostream &OS); + LLVM_ABI static void writeRecordInText(StringRef Name, uint64_t Hash, + const InstrProfRecord &Counters, + InstrProfSymtab &Symtab, + raw_fd_ostream &OS); /// Write the profile, returning the raw data. For testing. - std::unique_ptr writeBuffer(); + LLVM_ABI std::unique_ptr writeBuffer(); /// Update the attributes of the current profile from the attributes /// specified. An error is returned if IR and FE profiles are mixed. @@ -206,17 +209,18 @@ class InstrProfWriter { } // Internal interfaces for testing purpose only. - void setValueProfDataEndianness(llvm::endianness Endianness); - void setOutputSparse(bool Sparse); + LLVM_ABI void setValueProfDataEndianness(llvm::endianness Endianness); + LLVM_ABI void setOutputSparse(bool Sparse); void setMemProfVersionRequested(memprof::IndexedVersion Version) { MemProfVersionRequested = Version; } void setMemProfFullSchema(bool Full) { MemProfFullSchema = Full; } // Compute the overlap b/w this object and Other. Program level result is // stored in Overlap and function level result is stored in FuncLevelOverlap. - void overlapRecord(NamedInstrProfRecord &&Other, OverlapStats &Overlap, - OverlapStats &FuncLevelOverlap, - const OverlapFuncFilters &FuncFilter); + LLVM_ABI void overlapRecord(NamedInstrProfRecord &&Other, + OverlapStats &Overlap, + OverlapStats &FuncLevelOverlap, + const OverlapFuncFilters &FuncFilter); private: void addRecord(StringRef Name, uint64_t Hash, InstrProfRecord &&I, diff --git a/llvm/include/llvm/ProfileData/ItaniumManglingCanonicalizer.h b/llvm/include/llvm/ProfileData/ItaniumManglingCanonicalizer.h index e634f9c223e16..bb99710c092c4 100644 --- a/llvm/include/llvm/ProfileData/ItaniumManglingCanonicalizer.h +++ b/llvm/include/llvm/ProfileData/ItaniumManglingCanonicalizer.h @@ -14,6 +14,7 @@ #ifndef LLVM_PROFILEDATA_ITANIUMMANGLINGCANONICALIZER_H #define LLVM_PROFILEDATA_ITANIUMMANGLINGCANONICALIZER_H +#include "llvm/Support/Compiler.h" #include namespace llvm { @@ -34,10 +35,10 @@ class StringRef; /// different manglings. class ItaniumManglingCanonicalizer { public: - ItaniumManglingCanonicalizer(); + LLVM_ABI ItaniumManglingCanonicalizer(); ItaniumManglingCanonicalizer(const ItaniumManglingCanonicalizer &) = delete; void operator=(const ItaniumManglingCanonicalizer &) = delete; - ~ItaniumManglingCanonicalizer(); + LLVM_ABI ~ItaniumManglingCanonicalizer(); enum class EquivalenceError { Success, @@ -65,8 +66,8 @@ class ItaniumManglingCanonicalizer { /// Add an equivalence between \p First and \p Second. Both manglings must /// live at least as long as the canonicalizer. - EquivalenceError addEquivalence(FragmentKind Kind, StringRef First, - StringRef Second); + LLVM_ABI EquivalenceError addEquivalence(FragmentKind Kind, StringRef First, + StringRef Second); using Key = uintptr_t; @@ -78,11 +79,11 @@ class ItaniumManglingCanonicalizer { /// ABI mangling. /// /// The string denoted by Mangling must live as long as the canonicalizer. - Key canonicalize(StringRef Mangling); + LLVM_ABI Key canonicalize(StringRef Mangling); /// Find a canonical key for the specified mangling, if one has already been /// formed. Otherwise returns Key(). - Key lookup(StringRef Mangling); + LLVM_ABI Key lookup(StringRef Mangling); private: struct Impl; diff --git a/llvm/include/llvm/ProfileData/MemProf.h b/llvm/include/llvm/ProfileData/MemProf.h index 683193aa42747..d715c6ce935cb 100644 --- a/llvm/include/llvm/ProfileData/MemProf.h +++ b/llvm/include/llvm/ProfileData/MemProf.h @@ -23,6 +23,7 @@ #include "llvm/IR/GlobalValue.h" #include "llvm/ProfileData/MemProfData.inc" #include "llvm/Support/BLAKE3.h" +#include "llvm/Support/Compiler.h" #include "llvm/Support/Endian.h" #include "llvm/Support/EndianStream.h" #include "llvm/Support/HashBuilder.h" @@ -79,10 +80,10 @@ enum class Meta : uint64_t { using MemProfSchema = llvm::SmallVector(Meta::Size)>; // Returns the full schema currently in use. -MemProfSchema getFullSchema(); +LLVM_ABI MemProfSchema getFullSchema(); // Returns the schema consisting of the fields used for hot cold memory hinting. -MemProfSchema getHotColdSchema(); +LLVM_ABI MemProfSchema getHotColdSchema(); // Holds the actual MemInfoBlock data with all fields. Contents may be read or // written partially by providing an appropriate schema to the serialize and @@ -396,8 +397,8 @@ struct IndexedAllocationInfo { : CSId(CSId), Info(MB) {} // Returns the size in bytes when this allocation info struct is serialized. - size_t serializedSize(const MemProfSchema &Schema, - IndexedVersion Version) const; + LLVM_ABI size_t serializedSize(const MemProfSchema &Schema, + IndexedVersion Version) const; bool operator==(const IndexedAllocationInfo &Other) const { if (Other.Info != Info) @@ -457,8 +458,8 @@ struct IndexedMemProfRecord { AllocSites.append(Other.AllocSites); } - size_t serializedSize(const MemProfSchema &Schema, - IndexedVersion Version) const; + LLVM_ABI size_t serializedSize(const MemProfSchema &Schema, + IndexedVersion Version) const; bool operator==(const IndexedMemProfRecord &Other) const { if (Other.AllocSites != AllocSites) @@ -471,26 +472,26 @@ struct IndexedMemProfRecord { // Serializes the memprof records in \p Records to the ostream \p OS based // on the schema provided in \p Schema. - void serialize(const MemProfSchema &Schema, raw_ostream &OS, - IndexedVersion Version, - llvm::DenseMap - *MemProfCallStackIndexes = nullptr) const; + LLVM_ABI void serialize(const MemProfSchema &Schema, raw_ostream &OS, + IndexedVersion Version, + llvm::DenseMap + *MemProfCallStackIndexes = nullptr) const; // Deserializes memprof records from the Buffer. - static IndexedMemProfRecord deserialize(const MemProfSchema &Schema, - const unsigned char *Buffer, - IndexedVersion Version); + LLVM_ABI static IndexedMemProfRecord deserialize(const MemProfSchema &Schema, + const unsigned char *Buffer, + IndexedVersion Version); // Convert IndexedMemProfRecord to MemProfRecord. Callback is used to // translate CallStackId to call stacks with frames inline. - MemProfRecord toMemProfRecord( + LLVM_ABI MemProfRecord toMemProfRecord( llvm::function_ref(const CallStackId)> Callback) const; }; // Returns the GUID for the function name after canonicalization. For // memprof, we remove any .llvm suffix added by LTO. MemProfRecords are // mapped to functions using this GUID. -GlobalValue::GUID getGUID(const StringRef FunctionName); +LLVM_ABI GlobalValue::GUID getGUID(const StringRef FunctionName); // Holds call site information with frame contents inline. struct CallSiteInfo { @@ -551,7 +552,8 @@ struct MemProfRecord { // ids in the schema. Subsequent entries are integers which map to memprof::Meta // enum class entries. After successfully reading the schema, the pointer is one // byte past the schema contents. -Expected readMemProfSchema(const unsigned char *&Buffer); +LLVM_ABI Expected +readMemProfSchema(const unsigned char *&Buffer); // Trait for reading IndexedMemProfRecord data from the on-disk hash table. class RecordLookupTrait { diff --git a/llvm/include/llvm/ProfileData/MemProfCommon.h b/llvm/include/llvm/ProfileData/MemProfCommon.h index ff2aeee834366..53be4984caa35 100644 --- a/llvm/include/llvm/ProfileData/MemProfCommon.h +++ b/llvm/include/llvm/ProfileData/MemProfCommon.h @@ -14,6 +14,7 @@ #define LLVM_PROFILEDATA_MEMPROFCOMMON_H #include "llvm/IR/ModuleSummaryIndex.h" +#include "llvm/Support/Compiler.h" namespace llvm { namespace memprof { @@ -21,13 +22,14 @@ namespace memprof { struct Frame; /// Return the allocation type for a given set of memory profile values. -AllocationType getAllocType(uint64_t TotalLifetimeAccessDensity, - uint64_t AllocCount, uint64_t TotalLifetime); +LLVM_ABI AllocationType getAllocType(uint64_t TotalLifetimeAccessDensity, + uint64_t AllocCount, + uint64_t TotalLifetime); /// Helper to generate a single hash id for a given callstack, used for emitting /// matching statistics and useful for uniquing such statistics across modules. /// Also used to dedup contexts when computing the summary. -uint64_t computeFullStackId(ArrayRef CallStack); +LLVM_ABI uint64_t computeFullStackId(ArrayRef CallStack); } // namespace memprof } // namespace llvm diff --git a/llvm/include/llvm/ProfileData/MemProfRadixTree.h b/llvm/include/llvm/ProfileData/MemProfRadixTree.h index fd6dce4536c6b..35df7a8f16a6e 100644 --- a/llvm/include/llvm/ProfileData/MemProfRadixTree.h +++ b/llvm/include/llvm/ProfileData/MemProfRadixTree.h @@ -15,6 +15,7 @@ #include "llvm/ProfileData/IndexedMemProfData.h" #include "llvm/ProfileData/MemProf.h" +#include "llvm/Support/Compiler.h" namespace llvm { namespace memprof { @@ -353,6 +354,12 @@ template class CallStackRadixTreeBuilder { return std::move(CallStackPos); } }; + +// Defined in MemProfRadixTree.cpp +extern template class LLVM_TEMPLATE_ABI CallStackRadixTreeBuilder; +extern template class LLVM_TEMPLATE_ABI + CallStackRadixTreeBuilder; + } // namespace memprof } // namespace llvm #endif // LLVM_PROFILEDATA_MEMPROFRADIXTREE_H diff --git a/llvm/include/llvm/ProfileData/MemProfReader.h b/llvm/include/llvm/ProfileData/MemProfReader.h index 3bfcdf0f42cde..4d41d05b1457c 100644 --- a/llvm/include/llvm/ProfileData/MemProfReader.h +++ b/llvm/include/llvm/ProfileData/MemProfReader.h @@ -25,6 +25,7 @@ #include "llvm/ProfileData/InstrProfReader.h" #include "llvm/ProfileData/MemProfData.inc" #include "llvm/ProfileData/MemProfRadixTree.h" +#include "llvm/Support/Compiler.h" #include "llvm/Support/Error.h" #include "llvm/Support/MemoryBuffer.h" @@ -106,7 +107,7 @@ using CallStackMap = llvm::DenseMap>; // Specializes the MemProfReader class to populate the contents from raw binary // memprof profiles from instrumentation based profiling. -class RawMemProfReader final : public MemProfReader { +class LLVM_ABI RawMemProfReader final : public MemProfReader { public: RawMemProfReader(const RawMemProfReader &) = delete; RawMemProfReader &operator=(const RawMemProfReader &) = delete; @@ -217,18 +218,19 @@ class YAMLMemProfReader final : public MemProfReader { // Return true if the \p DataBuffer starts with "---" indicating it is a YAML // file. - static bool hasFormat(const MemoryBuffer &DataBuffer); + LLVM_ABI static bool hasFormat(const MemoryBuffer &DataBuffer); // Wrapper around hasFormat above, reading the file instead of the memory // buffer. - static bool hasFormat(const StringRef Path); + LLVM_ABI static bool hasFormat(const StringRef Path); // Create a YAMLMemProfReader after sanity checking the contents of the file // at \p Path or the \p Buffer. - static Expected> create(const Twine &Path); - static Expected> + LLVM_ABI static Expected> + create(const Twine &Path); + LLVM_ABI static Expected> create(std::unique_ptr Buffer); - void parse(StringRef YAMLData); + LLVM_ABI void parse(StringRef YAMLData); std::unique_ptr takeDataAccessProfData() { return std::move(DataAccessProfileData); diff --git a/llvm/include/llvm/ProfileData/MemProfSummary.h b/llvm/include/llvm/ProfileData/MemProfSummary.h index f1aa818d9ed77..8bf6155bd43e5 100644 --- a/llvm/include/llvm/ProfileData/MemProfSummary.h +++ b/llvm/include/llvm/ProfileData/MemProfSummary.h @@ -14,6 +14,7 @@ #define LLVM_PROFILEDATA_MEMPROFSUMMARY_H #include "llvm/ProfileData/InstrProf.h" +#include "llvm/Support/Compiler.h" namespace llvm { namespace memprof { @@ -46,11 +47,12 @@ class MemProfSummary { uint64_t getMaxColdTotalSize() const { return MaxColdTotalSize; } uint64_t getMaxWarmTotalSize() const { return MaxWarmTotalSize; } uint64_t getMaxHotTotalSize() const { return MaxHotTotalSize; } - void printSummaryYaml(raw_ostream &OS) const; + LLVM_ABI void printSummaryYaml(raw_ostream &OS) const; /// Write to indexed MemProf profile. - void write(ProfOStream &OS) const; + LLVM_ABI void write(ProfOStream &OS) const; /// Read from indexed MemProf profile. - static std::unique_ptr deserialize(const unsigned char *&); + LLVM_ABI static std::unique_ptr + deserialize(const unsigned char *&); }; } // namespace memprof diff --git a/llvm/include/llvm/ProfileData/MemProfSummaryBuilder.h b/llvm/include/llvm/ProfileData/MemProfSummaryBuilder.h index c994f823fb945..1ce0465490951 100644 --- a/llvm/include/llvm/ProfileData/MemProfSummaryBuilder.h +++ b/llvm/include/llvm/ProfileData/MemProfSummaryBuilder.h @@ -15,6 +15,7 @@ #include "llvm/ProfileData/MemProf.h" #include "llvm/ProfileData/MemProfSummary.h" +#include "llvm/Support/Compiler.h" namespace llvm { namespace memprof { @@ -40,9 +41,9 @@ class MemProfSummaryBuilder { MemProfSummaryBuilder() = default; ~MemProfSummaryBuilder() = default; - void addRecord(const IndexedMemProfRecord &); - void addRecord(const MemProfRecord &); - std::unique_ptr getSummary(); + LLVM_ABI void addRecord(const IndexedMemProfRecord &); + LLVM_ABI void addRecord(const MemProfRecord &); + LLVM_ABI std::unique_ptr getSummary(); }; } // namespace memprof diff --git a/llvm/include/llvm/ProfileData/PGOCtxProfReader.h b/llvm/include/llvm/ProfileData/PGOCtxProfReader.h index 5b59a0995045d..cc55886aa6015 100644 --- a/llvm/include/llvm/ProfileData/PGOCtxProfReader.h +++ b/llvm/include/llvm/ProfileData/PGOCtxProfReader.h @@ -18,6 +18,7 @@ #include "llvm/Bitstream/BitstreamReader.h" #include "llvm/IR/GlobalValue.h" #include "llvm/ProfileData/PGOCtxProfWriter.h" +#include "llvm/Support/Compiler.h" #include "llvm/Support/Error.h" #include @@ -219,9 +220,10 @@ class PGOCtxProfileReader final { : Magic(Buffer.substr(0, PGOCtxProfileWriter::ContainerMagic.size())), Cursor(Buffer.substr(PGOCtxProfileWriter::ContainerMagic.size())) {} - Expected loadProfiles(); + LLVM_ABI Expected loadProfiles(); }; -void convertCtxProfToYaml(raw_ostream &OS, const PGOCtxProfile &Profile); +LLVM_ABI void convertCtxProfToYaml(raw_ostream &OS, + const PGOCtxProfile &Profile); } // namespace llvm #endif diff --git a/llvm/include/llvm/ProfileData/PGOCtxProfWriter.h b/llvm/include/llvm/ProfileData/PGOCtxProfWriter.h index 36ad5622a8544..7031728c1e34b 100644 --- a/llvm/include/llvm/ProfileData/PGOCtxProfWriter.h +++ b/llvm/include/llvm/ProfileData/PGOCtxProfWriter.h @@ -17,6 +17,7 @@ #include "llvm/Bitstream/BitCodeEnums.h" #include "llvm/Bitstream/BitstreamWriter.h" #include "llvm/ProfileData/CtxInstrContextNode.h" +#include "llvm/Support/Compiler.h" namespace llvm { enum PGOCtxProfileRecords { @@ -74,7 +75,7 @@ enum PGOCtxProfileBlockIDs { /// like value profiling - which would appear as additional records. For /// example, value profiling would produce a new record with a new record ID, /// containing the profiled values (much like the counters) -class PGOCtxProfileWriter final : public ctx_profile::ProfileWriter { +class LLVM_ABI PGOCtxProfileWriter final : public ctx_profile::ProfileWriter { enum class EmptyContextCriteria { None, EntryIsZero, AllAreZero }; BitstreamWriter Writer; @@ -111,6 +112,6 @@ class PGOCtxProfileWriter final : public ctx_profile::ProfileWriter { static constexpr StringRef ContainerMagic = "CTXP"; }; -Error createCtxProfFromYAML(StringRef Profile, raw_ostream &Out); +LLVM_ABI Error createCtxProfFromYAML(StringRef Profile, raw_ostream &Out); } // namespace llvm #endif diff --git a/llvm/include/llvm/ProfileData/ProfileCommon.h b/llvm/include/llvm/ProfileData/ProfileCommon.h index edd8e1f644ad1..6f71097a94a43 100644 --- a/llvm/include/llvm/ProfileData/ProfileCommon.h +++ b/llvm/include/llvm/ProfileData/ProfileCommon.h @@ -18,6 +18,7 @@ #include "llvm/IR/ProfileSummary.h" #include "llvm/ProfileData/InstrProf.h" #include "llvm/ProfileData/SampleProf.h" +#include "llvm/Support/Compiler.h" #include "llvm/Support/Error.h" #include #include @@ -28,13 +29,13 @@ namespace llvm { -extern cl::opt UseContextLessSummary; -extern cl::opt ProfileSummaryCutoffHot; -extern cl::opt ProfileSummaryCutoffCold; -extern cl::opt ProfileSummaryHugeWorkingSetSizeThreshold; -extern cl::opt ProfileSummaryLargeWorkingSetSizeThreshold; -extern cl::opt ProfileSummaryHotCount; -extern cl::opt ProfileSummaryColdCount; +LLVM_ABI extern cl::opt UseContextLessSummary; +LLVM_ABI extern cl::opt ProfileSummaryCutoffHot; +LLVM_ABI extern cl::opt ProfileSummaryCutoffCold; +LLVM_ABI extern cl::opt ProfileSummaryHugeWorkingSetSizeThreshold; +LLVM_ABI extern cl::opt ProfileSummaryLargeWorkingSetSizeThreshold; +LLVM_ABI extern cl::opt ProfileSummaryHotCount; +LLVM_ABI extern cl::opt ProfileSummaryColdCount; namespace sampleprof { @@ -63,17 +64,17 @@ class ProfileSummaryBuilder { ~ProfileSummaryBuilder() = default; inline void addCount(uint64_t Count); - void computeDetailedSummary(); + LLVM_ABI void computeDetailedSummary(); public: /// A vector of useful cutoff values for detailed summary. - static const ArrayRef DefaultCutoffs; + LLVM_ABI static const ArrayRef DefaultCutoffs; /// Find the summary entry for a desired percentile of counts. - static const ProfileSummaryEntry & + LLVM_ABI static const ProfileSummaryEntry & getEntryForPercentile(const SummaryEntryVector &DS, uint64_t Percentile); - static uint64_t getHotCountThreshold(const SummaryEntryVector &DS); - static uint64_t getColdCountThreshold(const SummaryEntryVector &DS); + LLVM_ABI static uint64_t getHotCountThreshold(const SummaryEntryVector &DS); + LLVM_ABI static uint64_t getColdCountThreshold(const SummaryEntryVector &DS); }; class InstrProfSummaryBuilder final : public ProfileSummaryBuilder { @@ -83,11 +84,11 @@ class InstrProfSummaryBuilder final : public ProfileSummaryBuilder { InstrProfSummaryBuilder(std::vector Cutoffs) : ProfileSummaryBuilder(std::move(Cutoffs)) {} - void addEntryCount(uint64_t Count); - void addInternalCount(uint64_t Count); + LLVM_ABI void addEntryCount(uint64_t Count); + LLVM_ABI void addInternalCount(uint64_t Count); - void addRecord(const InstrProfRecord &); - std::unique_ptr getSummary(); + LLVM_ABI void addRecord(const InstrProfRecord &); + LLVM_ABI std::unique_ptr getSummary(); }; class SampleProfileSummaryBuilder final : public ProfileSummaryBuilder { @@ -95,11 +96,11 @@ class SampleProfileSummaryBuilder final : public ProfileSummaryBuilder { SampleProfileSummaryBuilder(std::vector Cutoffs) : ProfileSummaryBuilder(std::move(Cutoffs)) {} - void addRecord(const sampleprof::FunctionSamples &FS, - bool isCallsiteSample = false); - std::unique_ptr + LLVM_ABI void addRecord(const sampleprof::FunctionSamples &FS, + bool isCallsiteSample = false); + LLVM_ABI std::unique_ptr computeSummaryForProfiles(const sampleprof::SampleProfileMap &Profiles); - std::unique_ptr getSummary(); + LLVM_ABI std::unique_ptr getSummary(); }; /// This is called when a count is seen in the profile. diff --git a/llvm/include/llvm/ProfileData/SampleProf.h b/llvm/include/llvm/ProfileData/SampleProf.h index 3704de6e49f40..09dc7a2944159 100644 --- a/llvm/include/llvm/ProfileData/SampleProf.h +++ b/llvm/include/llvm/ProfileData/SampleProf.h @@ -24,6 +24,7 @@ #include "llvm/ProfileData/FunctionId.h" #include "llvm/ProfileData/HashKeyMap.h" #include "llvm/Support/Allocator.h" +#include "llvm/Support/Compiler.h" #include "llvm/Support/Debug.h" #include "llvm/Support/ErrorOr.h" #include "llvm/Support/MathExtras.h" @@ -43,7 +44,7 @@ namespace llvm { class DILocation; class raw_ostream; -const std::error_category &sampleprof_category(); +LLVM_ABI const std::error_category &sampleprof_category(); enum class sampleprof_error { success = 0, @@ -281,11 +282,11 @@ static inline bool hasSecFlag(const SecHdrTableEntry &Entry, SecFlagType Flag) { struct LineLocation { LineLocation(uint32_t L, uint32_t D) : LineOffset(L), Discriminator(D) {} - void print(raw_ostream &OS) const; - void dump() const; + LLVM_ABI void print(raw_ostream &OS) const; + LLVM_ABI void dump() const; // Serialize the line location to the output stream using ULEB128 encoding. - void serialize(raw_ostream &OS); + LLVM_ABI void serialize(raw_ostream &OS); bool operator<(const LineLocation &O) const { return LineOffset < O.LineOffset || @@ -314,7 +315,7 @@ struct LineLocationHash { } }; -raw_ostream &operator<<(raw_ostream &OS, const LineLocation &Loc); +LLVM_ABI raw_ostream &operator<<(raw_ostream &OS, const LineLocation &Loc); /// Representation of a single sample record. /// @@ -428,12 +429,13 @@ class SampleRecord { /// Merge the samples in \p Other into this record. /// Optionally scale sample counts by \p Weight. - sampleprof_error merge(const SampleRecord &Other, uint64_t Weight = 1); - void print(raw_ostream &OS, unsigned Indent) const; - void dump() const; + LLVM_ABI sampleprof_error merge(const SampleRecord &Other, + uint64_t Weight = 1); + LLVM_ABI void print(raw_ostream &OS, unsigned Indent) const; + LLVM_ABI void dump() const; /// Serialize the sample record to the output stream using ULEB128 encoding. /// The \p NameTable is used to map function names to their IDs. - std::error_code + LLVM_ABI std::error_code serialize(raw_ostream &OS, const MapVector &NameTable) const; @@ -450,7 +452,7 @@ class SampleRecord { CallTargetMap CallTargets; }; -raw_ostream &operator<<(raw_ostream &OS, const SampleRecord &Sample); +LLVM_ABI raw_ostream &operator<<(raw_ostream &OS, const SampleRecord &Sample); // State of context associated with FunctionSamples enum ContextStateMask { @@ -755,8 +757,8 @@ class FunctionSamples { public: FunctionSamples() = default; - void print(raw_ostream &OS = dbgs(), unsigned Indent = 0) const; - void dump() const; + LLVM_ABI void print(raw_ostream &OS = dbgs(), unsigned Indent = 0) const; + LLVM_ABI void dump() const; sampleprof_error addTotalSamples(uint64_t Num, uint64_t Weight = 1) { bool Overflowed; @@ -931,7 +933,7 @@ class FunctionSamples { /// \p Loc with the maximum total sample count. If \p Remapper or \p /// FuncNameToProfNameMap is not nullptr, use them to find FunctionSamples /// with equivalent name as \p CalleeName. - const FunctionSamples *findFunctionSamplesAt( + LLVM_ABI const FunctionSamples *findFunctionSamplesAt( const LineLocation &Loc, StringRef CalleeName, SampleProfileReaderItaniumRemapper *Remapper, const HashKeyMap @@ -1156,14 +1158,14 @@ class FunctionSamples { /// Returns the line offset to the start line of the subprogram. /// We assume that a single function will not exceed 65535 LOC. - static unsigned getOffset(const DILocation *DIL); + LLVM_ABI static unsigned getOffset(const DILocation *DIL); /// Returns a unique call site identifier for a given debug location of a call /// instruction. This is wrapper of two scenarios, the probe-based profile and /// regular profile, to hide implementation details from the sample loader and /// the context tracker. - static LineLocation getCallSiteIdentifier(const DILocation *DIL, - bool ProfileIsFS = false); + LLVM_ABI static LineLocation getCallSiteIdentifier(const DILocation *DIL, + bool ProfileIsFS = false); /// Returns a unique hash code for a combination of a callsite location and /// the callee function name. @@ -1186,30 +1188,30 @@ class FunctionSamples { /// If \p Remapper or \p FuncNameToProfNameMap is not nullptr, it will be used /// to find matching FunctionSamples with not exactly the same but equivalent /// name. - const FunctionSamples *findFunctionSamples( + LLVM_ABI const FunctionSamples *findFunctionSamples( const DILocation *DIL, SampleProfileReaderItaniumRemapper *Remapper = nullptr, const HashKeyMap *FuncNameToProfNameMap = nullptr) const; - static bool ProfileIsProbeBased; + LLVM_ABI static bool ProfileIsProbeBased; - static bool ProfileIsCS; + LLVM_ABI static bool ProfileIsCS; - static bool ProfileIsPreInlined; + LLVM_ABI static bool ProfileIsPreInlined; SampleContext &getContext() const { return Context; } void setContext(const SampleContext &FContext) { Context = FContext; } /// Whether the profile uses MD5 to represent string. - static bool UseMD5; + LLVM_ABI static bool UseMD5; /// Whether the profile contains any ".__uniq." suffix in a name. - static bool HasUniqSuffix; + LLVM_ABI static bool HasUniqSuffix; /// If this profile uses flow sensitive discriminators. - static bool ProfileIsFS; + LLVM_ABI static bool ProfileIsFS; /// GUIDToFuncNameMap saves the mapping from GUID to the symbol name, for /// all the function symbols defined or declared in current module. @@ -1223,7 +1225,7 @@ class FunctionSamples { // Find all the names in the current FunctionSamples including names in // all the inline instances and names of call targets. - void findAllNames(DenseSet &NameSet) const; + LLVM_ABI void findAllNames(DenseSet &NameSet) const; bool operator==(const FunctionSamples &Other) const { return (GUIDToFuncNameMap == Other.GUIDToFuncNameMap || @@ -1311,7 +1313,7 @@ static inline FunctionId getRepInFormat(StringRef Name) { return FunctionId(Function::getGUIDAssumingExternalLinkage(Name)); } -raw_ostream &operator<<(raw_ostream &OS, const FunctionSamples &FS); +LLVM_ABI raw_ostream &operator<<(raw_ostream &OS, const FunctionSamples &FS); /// This class provides operator overloads to the map container using MD5 as the /// key type, so that existing code can still work in most cases using @@ -1352,8 +1354,9 @@ class SampleProfileMap using NameFunctionSamples = std::pair; -void sortFuncProfiles(const SampleProfileMap &ProfileMap, - std::vector &SortedProfiles); +LLVM_ABI void +sortFuncProfiles(const SampleProfileMap &ProfileMap, + std::vector &SortedProfiles); /// Sort a LocationT->SampleT map by LocationT. /// @@ -1391,11 +1394,11 @@ class SampleContextTrimmer { // mainly to honor the preinliner decsion. Note that when MergeColdContext is // true, preinliner decsion is not honored anyway so TrimBaseProfileOnly will // be ignored. - void trimAndMergeColdContextProfiles(uint64_t ColdCountThreshold, - bool TrimColdContext, - bool MergeColdContext, - uint32_t ColdContextFrameLength, - bool TrimBaseProfileOnly); + LLVM_ABI void trimAndMergeColdContextProfiles(uint64_t ColdCountThreshold, + bool TrimColdContext, + bool MergeColdContext, + uint32_t ColdContextFrameLength, + bool TrimBaseProfileOnly); private: SampleProfileMap &ProfileMap; @@ -1407,10 +1410,10 @@ class SampleContextTrimmer { /// nested profile to flatten profile conversion, etc. class ProfileConverter { public: - ProfileConverter(SampleProfileMap &Profiles); + LLVM_ABI ProfileConverter(SampleProfileMap &Profiles); // Convert a full context-sensitive flat sample profile into a nested sample // profile. - void convertCSProfiles(); + LLVM_ABI void convertCSProfiles(); struct FrameNode { FrameNode(FunctionId FName = FunctionId(), FunctionSamples *FSamples = nullptr, @@ -1426,8 +1429,8 @@ class ProfileConverter { // Callsite location in parent context LineLocation CallSiteLoc; - FrameNode *getOrCreateChildFrame(const LineLocation &CallSite, - FunctionId CalleeName); + LLVM_ABI FrameNode *getOrCreateChildFrame(const LineLocation &CallSite, + FunctionId CalleeName); }; static void flattenProfile(SampleProfileMap &ProfileMap, @@ -1543,9 +1546,9 @@ class ProfileSymbolList { void setToCompress(bool TC) { ToCompress = TC; } bool toCompress() { return ToCompress; } - std::error_code read(const uint8_t *Data, uint64_t ListSize); - std::error_code write(raw_ostream &OS); - void dump(raw_ostream &OS = dbgs()) const; + LLVM_ABI std::error_code read(const uint8_t *Data, uint64_t ListSize); + LLVM_ABI std::error_code write(raw_ostream &OS); + LLVM_ABI void dump(raw_ostream &OS = dbgs()) const; private: // Determine whether or not to compress the symbol list when diff --git a/llvm/include/llvm/ProfileData/SampleProfReader.h b/llvm/include/llvm/ProfileData/SampleProfReader.h index 76c7cecded629..bfe079fbe536f 100644 --- a/llvm/include/llvm/ProfileData/SampleProfReader.h +++ b/llvm/include/llvm/ProfileData/SampleProfReader.h @@ -233,6 +233,7 @@ #include "llvm/ProfileData/GCOV.h" #include "llvm/ProfileData/SampleProf.h" #include "llvm/ProfileData/SymbolRemappingReader.h" +#include "llvm/Support/Compiler.h" #include "llvm/Support/Debug.h" #include "llvm/Support/Discriminator.h" #include "llvm/Support/ErrorOr.h" @@ -273,18 +274,18 @@ class SampleProfileReaderItaniumRemapper { /// Create a remapper from the given remapping file. The remapper will /// be used for profile read in by Reader. - static ErrorOr> + LLVM_ABI static ErrorOr> create(StringRef Filename, vfs::FileSystem &FS, SampleProfileReader &Reader, LLVMContext &C); /// Create a remapper from the given Buffer. The remapper will /// be used for profile read in by Reader. - static ErrorOr> + LLVM_ABI static ErrorOr> create(std::unique_ptr &B, SampleProfileReader &Reader, LLVMContext &C); /// Apply remappings to the profile read by Reader. - void applyRemapping(LLVMContext &Ctx); + LLVM_ABI void applyRemapping(LLVMContext &Ctx); bool hasApplied() { return RemappingApplied; } @@ -299,7 +300,7 @@ class SampleProfileReaderItaniumRemapper { /// Return the equivalent name in the profile for \p FunctionName if /// it exists. - std::optional lookUpNameInProfile(StringRef FunctionName); + LLVM_ABI std::optional lookUpNameInProfile(StringRef FunctionName); private: // The buffer holding the content read from remapping file. @@ -395,7 +396,8 @@ class SampleProfileReader { virtual std::error_code readImpl() = 0; /// Print the profile for \p FunctionSamples on stream \p OS. - void dumpFunctionProfile(const FunctionSamples &FS, raw_ostream &OS = dbgs()); + LLVM_ABI void dumpFunctionProfile(const FunctionSamples &FS, + raw_ostream &OS = dbgs()); /// Collect functions with definitions in Module M. For reader which /// support loading function profiles on demand, return true when the @@ -404,10 +406,10 @@ class SampleProfileReader { virtual bool collectFuncsFromModule() { return false; } /// Print all the profiles on stream \p OS. - void dump(raw_ostream &OS = dbgs()); + LLVM_ABI void dump(raw_ostream &OS = dbgs()); /// Print all the profiles on stream \p OS in the JSON format. - void dumpJson(raw_ostream &OS = dbgs()); + LLVM_ABI void dumpJson(raw_ostream &OS = dbgs()); /// Return the samples collected for function \p F. FunctionSamples *getSamplesFor(const Function &F) { @@ -456,7 +458,7 @@ class SampleProfileReader { /// Create a sample profile reader appropriate to the file format. /// Create a remapper underlying if RemapFilename is not empty. /// Parameter P specifies the FSDiscriminatorPass. - static ErrorOr> + LLVM_ABI static ErrorOr> create(StringRef Filename, LLVMContext &C, vfs::FileSystem &FS, FSDiscriminatorPass P = FSDiscriminatorPass::Base, StringRef RemapFilename = ""); @@ -464,7 +466,7 @@ class SampleProfileReader { /// Create a sample profile reader from the supplied memory buffer. /// Create a remapper underlying if RemapFilename is not empty. /// Parameter P specifies the FSDiscriminatorPass. - static ErrorOr> + LLVM_ABI static ErrorOr> create(std::unique_ptr &B, LLVMContext &C, vfs::FileSystem &FS, FSDiscriminatorPass P = FSDiscriminatorPass::Base, StringRef RemapFilename = ""); @@ -544,7 +546,7 @@ class SampleProfileReader { } /// Compute summary for this profile. - void computeSummary(); + LLVM_ABI void computeSummary(); /// Read sample profiles for the given functions and write them to the given /// profile map. Currently it's only used for extended binary format to load @@ -608,7 +610,7 @@ class SampleProfileReader { bool SkipFlatProf = false; }; -class SampleProfileReaderText : public SampleProfileReader { +class LLVM_ABI SampleProfileReaderText : public SampleProfileReader { public: SampleProfileReaderText(std::unique_ptr B, LLVMContext &C) : SampleProfileReader(std::move(B), C, SPF_Text) {} @@ -631,7 +633,7 @@ class SampleProfileReaderText : public SampleProfileReader { std::list CSNameTable; }; -class SampleProfileReaderBinary : public SampleProfileReader { +class LLVM_ABI SampleProfileReaderBinary : public SampleProfileReader { public: SampleProfileReaderBinary(std::unique_ptr B, LLVMContext &C, SampleProfileFormat Format = SPF_None) @@ -730,7 +732,7 @@ class SampleProfileReaderBinary : public SampleProfileReader { virtual std::error_code verifySPMagic(uint64_t Magic) = 0; }; -class SampleProfileReaderRawBinary : public SampleProfileReaderBinary { +class LLVM_ABI SampleProfileReaderRawBinary : public SampleProfileReaderBinary { private: std::error_code verifySPMagic(uint64_t Magic) override; @@ -762,7 +764,8 @@ class SampleProfileReaderRawBinary : public SampleProfileReaderBinary { /// commonly used sections of a profile in extensible binary format. It is /// possible to define other types of profile inherited from /// SampleProfileReaderExtBinaryBase/SampleProfileWriterExtBinaryBase. -class SampleProfileReaderExtBinaryBase : public SampleProfileReaderBinary { +class LLVM_ABI SampleProfileReaderExtBinaryBase + : public SampleProfileReaderBinary { private: std::error_code decompressSection(const uint8_t *SecStart, const uint64_t SecSize, @@ -845,7 +848,8 @@ class SampleProfileReaderExtBinaryBase : public SampleProfileReaderBinary { SampleProfileMap &Profiles) override; }; -class SampleProfileReaderExtBinary : public SampleProfileReaderExtBinaryBase { +class LLVM_ABI SampleProfileReaderExtBinary + : public SampleProfileReaderExtBinaryBase { private: std::error_code verifySPMagic(uint64_t Magic) override; std::error_code readCustomSection(const SecHdrTableEntry &Entry) override { @@ -878,7 +882,7 @@ enum HistType { HIST_TYPE_INDIR_CALL_TOPN }; -class SampleProfileReaderGCC : public SampleProfileReader { +class LLVM_ABI SampleProfileReaderGCC : public SampleProfileReader { public: SampleProfileReaderGCC(std::unique_ptr B, LLVMContext &C) : SampleProfileReader(std::move(B), C, SPF_GCC), diff --git a/llvm/include/llvm/ProfileData/SampleProfWriter.h b/llvm/include/llvm/ProfileData/SampleProfWriter.h index 4b659eaf950b3..146d051f770a3 100644 --- a/llvm/include/llvm/ProfileData/SampleProfWriter.h +++ b/llvm/include/llvm/ProfileData/SampleProfWriter.h @@ -16,6 +16,7 @@ #include "llvm/ADT/StringRef.h" #include "llvm/IR/ProfileSummary.h" #include "llvm/ProfileData/SampleProf.h" +#include "llvm/Support/Compiler.h" #include "llvm/Support/ErrorOr.h" #include "llvm/Support/raw_ostream.h" #include @@ -65,7 +66,7 @@ class FunctionPruningStrategy { virtual void Erase(size_t CurrentOutputSize) = 0; }; -class DefaultFunctionPruningStrategy : public FunctionPruningStrategy { +class LLVM_ABI DefaultFunctionPruningStrategy : public FunctionPruningStrategy { std::vector SortedFunctions; public: @@ -86,7 +87,7 @@ class DefaultFunctionPruningStrategy : public FunctionPruningStrategy { }; /// Sample-based profile writer. Base class. -class SampleProfileWriter { +class LLVM_ABI SampleProfileWriter { public: virtual ~SampleProfileWriter() = default; @@ -163,7 +164,7 @@ class SampleProfileWriter { }; /// Sample-based profile writer (text format). -class SampleProfileWriterText : public SampleProfileWriter { +class LLVM_ABI SampleProfileWriterText : public SampleProfileWriter { public: std::error_code writeSample(const FunctionSamples &S) override; @@ -192,13 +193,13 @@ class SampleProfileWriterText : public SampleProfileWriter { /// cannot be skipped. bool MarkFlatProfiles = false; - friend ErrorOr> + LLVM_ABI_FRIEND friend ErrorOr> SampleProfileWriter::create(std::unique_ptr &OS, SampleProfileFormat Format); }; /// Sample-based profile writer (binary format). -class SampleProfileWriterBinary : public SampleProfileWriter { +class LLVM_ABI SampleProfileWriterBinary : public SampleProfileWriter { public: SampleProfileWriterBinary(std::unique_ptr &OS) : SampleProfileWriter(OS) {} @@ -224,7 +225,7 @@ class SampleProfileWriterBinary : public SampleProfileWriter { void addNames(const FunctionSamples &S); private: - friend ErrorOr> + LLVM_ABI_FRIEND friend ErrorOr> SampleProfileWriter::create(std::unique_ptr &OS, SampleProfileFormat Format); }; @@ -264,7 +265,8 @@ const std::array, NumOfLayout> {SecFuncMetadata, 0, 0, 0, 0}}), }; -class SampleProfileWriterExtBinaryBase : public SampleProfileWriterBinary { +class LLVM_ABI SampleProfileWriterExtBinaryBase + : public SampleProfileWriterBinary { using SampleProfileWriterBinary::SampleProfileWriterBinary; public: std::error_code write(const SampleProfileMap &ProfileMap) override; @@ -407,7 +409,8 @@ class SampleProfileWriterExtBinaryBase : public SampleProfileWriterBinary { ProfileSymbolList *ProfSymList = nullptr; }; -class SampleProfileWriterExtBinary : public SampleProfileWriterExtBinaryBase { +class LLVM_ABI SampleProfileWriterExtBinary + : public SampleProfileWriterExtBinaryBase { public: SampleProfileWriterExtBinary(std::unique_ptr &OS) : SampleProfileWriterExtBinaryBase(OS) {} diff --git a/llvm/include/llvm/ProfileData/SymbolRemappingReader.h b/llvm/include/llvm/ProfileData/SymbolRemappingReader.h index 61d32134e981a..d81b643477456 100644 --- a/llvm/include/llvm/ProfileData/SymbolRemappingReader.h +++ b/llvm/include/llvm/ProfileData/SymbolRemappingReader.h @@ -61,6 +61,7 @@ #include "llvm/ADT/StringRef.h" #include "llvm/ProfileData/ItaniumManglingCanonicalizer.h" +#include "llvm/Support/Compiler.h" #include "llvm/Support/Error.h" namespace llvm { @@ -83,7 +84,7 @@ class SymbolRemappingParseError : public ErrorInfo { int64_t getLineNum() const { return Line; } StringRef getMessage() const { return Message; } - static char ID; + LLVM_ABI static char ID; private: std::string File; @@ -99,7 +100,7 @@ class SymbolRemappingReader { public: /// Read remappings from the given buffer, which must live as long as /// the remapper. - Error read(MemoryBuffer &B); + LLVM_ABI Error read(MemoryBuffer &B); /// A Key represents an equivalence class of symbol names. using Key = uintptr_t; diff --git a/llvm/lib/ProfileData/MemProfCommon.cpp b/llvm/lib/ProfileData/MemProfCommon.cpp index 8c0c93123c82d..a13a291a4cd27 100644 --- a/llvm/lib/ProfileData/MemProfCommon.cpp +++ b/llvm/lib/ProfileData/MemProfCommon.cpp @@ -14,6 +14,7 @@ #include "llvm/ProfileData/MemProf.h" #include "llvm/Support/BLAKE3.h" #include "llvm/Support/CommandLine.h" +#include "llvm/Support/Compiler.h" #include "llvm/Support/HashBuilder.h" using namespace llvm; @@ -21,7 +22,7 @@ using namespace llvm::memprof; // Upper bound on lifetime access density (accesses per byte per lifetime sec) // for marking an allocation cold. -cl::opt MemProfLifetimeAccessDensityColdThreshold( +LLVM_ABI cl::opt MemProfLifetimeAccessDensityColdThreshold( "memprof-lifetime-access-density-cold-threshold", cl::init(0.05), cl::Hidden, cl::desc("The threshold the lifetime access density (accesses per byte per " @@ -29,20 +30,20 @@ cl::opt MemProfLifetimeAccessDensityColdThreshold( // Lower bound on lifetime to mark an allocation cold (in addition to accesses // per byte per sec above). This is to avoid pessimizing short lived objects. -cl::opt MemProfAveLifetimeColdThreshold( +LLVM_ABI cl::opt MemProfAveLifetimeColdThreshold( "memprof-ave-lifetime-cold-threshold", cl::init(200), cl::Hidden, cl::desc("The average lifetime (s) for an allocation to be considered " "cold")); // Lower bound on average lifetime accesses density (total life time access // density / alloc count) for marking an allocation hot. -cl::opt MemProfMinAveLifetimeAccessDensityHotThreshold( +LLVM_ABI cl::opt MemProfMinAveLifetimeAccessDensityHotThreshold( "memprof-min-ave-lifetime-access-density-hot-threshold", cl::init(1000), cl::Hidden, cl::desc("The minimum TotalLifetimeAccessDensity / AllocCount for an " "allocation to be considered hot")); -cl::opt +LLVM_ABI cl::opt MemProfUseHotHints("memprof-use-hot-hints", cl::init(false), cl::Hidden, cl::desc("Enable use of hot hints (only supported for " "unambigously hot allocations)")); diff --git a/llvm/lib/ProfileData/MemProfRadixTree.cpp b/llvm/lib/ProfileData/MemProfRadixTree.cpp index ec3ff2e721e2e..ea9f5bd25534c 100644 --- a/llvm/lib/ProfileData/MemProfRadixTree.cpp +++ b/llvm/lib/ProfileData/MemProfRadixTree.cpp @@ -220,8 +220,8 @@ void CallStackRadixTreeBuilder::build( } // Explicitly instantiate class with the utilized FrameIdTy. -template class CallStackRadixTreeBuilder; -template class CallStackRadixTreeBuilder; +template class LLVM_EXPORT_TEMPLATE CallStackRadixTreeBuilder; +template class LLVM_EXPORT_TEMPLATE CallStackRadixTreeBuilder; template llvm::DenseMap @@ -241,12 +241,13 @@ computeFrameHistogram(llvm::MapVector> } // Explicitly instantiate function with the utilized FrameIdTy. -template llvm::DenseMap computeFrameHistogram( - llvm::MapVector> - &MemProfCallStackData); +template llvm::DenseMap + LLVM_ABI computeFrameHistogram( + llvm::MapVector> + &MemProfCallStackData); template llvm::DenseMap -computeFrameHistogram( - llvm::MapVector> - &MemProfCallStackData); + LLVM_ABI computeFrameHistogram( + llvm::MapVector> + &MemProfCallStackData); } // namespace memprof } // namespace llvm diff --git a/llvm/unittests/ProfileData/MemProfTest.cpp b/llvm/unittests/ProfileData/MemProfTest.cpp index 1dbafea195736..b57567e29f1c8 100644 --- a/llvm/unittests/ProfileData/MemProfTest.cpp +++ b/llvm/unittests/ProfileData/MemProfTest.cpp @@ -19,16 +19,18 @@ #include "llvm/ProfileData/MemProfData.inc" #include "llvm/ProfileData/MemProfRadixTree.h" #include "llvm/ProfileData/MemProfReader.h" +#include "llvm/Support/Compiler.h" #include "llvm/Support/raw_ostream.h" #include "gmock/gmock.h" #include "gtest/gtest.h" #include -extern llvm::cl::opt MemProfLifetimeAccessDensityColdThreshold; -extern llvm::cl::opt MemProfAveLifetimeColdThreshold; -extern llvm::cl::opt MemProfMinAveLifetimeAccessDensityHotThreshold; -extern llvm::cl::opt MemProfUseHotHints; +LLVM_ABI extern llvm::cl::opt MemProfLifetimeAccessDensityColdThreshold; +LLVM_ABI extern llvm::cl::opt MemProfAveLifetimeColdThreshold; +LLVM_ABI extern llvm::cl::opt + MemProfMinAveLifetimeAccessDensityHotThreshold; +LLVM_ABI extern llvm::cl::opt MemProfUseHotHints; namespace llvm { namespace memprof {