Index: lib/profile/InstrProfData.inc =================================================================== --- lib/profile/InstrProfData.inc +++ lib/profile/InstrProfData.inc @@ -57,6 +57,15 @@ * \*===----------------------------------------------------------------------===*/ +/* Keep in sync with InstrProfilingPort.h. */ +#ifndef COMPILER_RT_VISIBILITY +#ifdef _MSC_VER +#define COMPILER_RT_VISIBILITY +#elif __GNUC__ +#define COMPILER_RT_VISIBILITY __attribute__((visibility("hidden"))) +#endif +#endif + /* INSTR_PROF_DATA start. */ /* Definition of member fields of the per-function control structure. */ #ifndef INSTR_PROF_DATA @@ -387,11 +396,14 @@ ValueProfData *(*AllocValueProfData)(size_t TotalSizeInBytes); } ValueProfRecordClosure; - -ValueProfRecord *getFirstValueProfRecord(ValueProfData *VPD); -ValueProfRecord *getValueProfRecordNext(ValueProfRecord *VPR); -InstrProfValueData *getValueProfRecordValueData(ValueProfRecord *VPR); -uint32_t getValueProfRecordHeaderSize(uint32_t NumValueSites); +COMPILER_RT_VISIBILITY ValueProfRecord * +getFirstValueProfRecord(ValueProfData *VPD); +COMPILER_RT_VISIBILITY ValueProfRecord * +getValueProfRecordNext(ValueProfRecord *VPR); +COMPILER_RT_VISIBILITY InstrProfValueData * +getValueProfRecordValueData(ValueProfRecord *VPR); +COMPILER_RT_VISIBILITY uint32_t +getValueProfRecordHeaderSize(uint32_t NumValueSites); #undef INSTR_PROF_VALUE_PROF_DATA #endif /* INSTR_PROF_VALUE_PROF_DATA */ @@ -415,7 +427,7 @@ * \brief Return the \c ValueProfRecord header size including the * padding bytes. */ -INSTR_PROF_INLINE +COMPILER_RT_VISIBILITY INSTR_PROF_INLINE uint32_t getValueProfRecordHeaderSize(uint32_t NumValueSites) { uint32_t Size = offsetof(ValueProfRecord, SiteCountArray) + sizeof(uint8_t) * NumValueSites; @@ -428,7 +440,7 @@ * \brief Return the total size of the value profile record including the * header and the value data. */ -INSTR_PROF_INLINE +COMPILER_RT_VISIBILITY INSTR_PROF_INLINE uint32_t getValueProfRecordSize(uint32_t NumValueSites, uint32_t NumValueData) { return getValueProfRecordHeaderSize(NumValueSites) + @@ -438,7 +450,7 @@ /*! * \brief Return the pointer to the start of value data array. */ -INSTR_PROF_INLINE +COMPILER_RT_VISIBILITY INSTR_PROF_INLINE InstrProfValueData *getValueProfRecordValueData(ValueProfRecord *This) { return (InstrProfValueData *)((char *)This + getValueProfRecordHeaderSize( This->NumValueSites)); @@ -447,7 +459,7 @@ /*! * \brief Return the total number of value data for \c This record. */ -INSTR_PROF_INLINE +COMPILER_RT_VISIBILITY INSTR_PROF_INLINE uint32_t getValueProfRecordNumValueData(ValueProfRecord *This) { uint32_t NumValueData = 0; uint32_t I; @@ -459,7 +471,7 @@ /*! * \brief Use this method to advance to the next \c This \c ValueProfRecord. */ -INSTR_PROF_INLINE +COMPILER_RT_VISIBILITY INSTR_PROF_INLINE ValueProfRecord *getValueProfRecordNext(ValueProfRecord *This) { uint32_t NumValueData = getValueProfRecordNumValueData(This); return (ValueProfRecord *)((char *)This + @@ -470,7 +482,7 @@ /*! * \brief Return the first \c ValueProfRecord instance. */ -INSTR_PROF_INLINE +COMPILER_RT_VISIBILITY INSTR_PROF_INLINE ValueProfRecord *getFirstValueProfRecord(ValueProfData *This) { return (ValueProfRecord *)((char *)This + sizeof(ValueProfData)); } @@ -481,7 +493,8 @@ * Return the total size in bytes of the on-disk value profile data * given the data stored in Record. */ -uint32_t getValueProfDataSize(ValueProfRecordClosure *Closure) { +COMPILER_RT_VISIBILITY uint32_t +getValueProfDataSize(ValueProfRecordClosure *Closure) { uint32_t Kind; uint32_t TotalSize = sizeof(ValueProfData); const void *Record = Closure->Record; @@ -500,6 +513,7 @@ * Extract value profile data of a function for the profile kind \c ValueKind * from the \c Closure and serialize the data into \c This record instance. */ +COMPILER_RT_VISIBILITY void serializeValueProfRecordFrom(ValueProfRecord *This, ValueProfRecordClosure *Closure, uint32_t ValueKind, uint32_t NumValueSites) { @@ -524,8 +538,9 @@ * DstData is not null, the caller is expected to set the TotalSize * in DstData. */ -ValueProfData *serializeValueProfDataFrom(ValueProfRecordClosure *Closure, - ValueProfData *DstData) { +COMPILER_RT_VISIBILITY ValueProfData * +serializeValueProfDataFrom(ValueProfRecordClosure *Closure, + ValueProfData *DstData) { uint32_t Kind; uint32_t TotalSize = DstData ? DstData->TotalSize : getValueProfDataSize(Closure); Index: lib/profile/InstrProfilingPort.h =================================================================== --- lib/profile/InstrProfilingPort.h +++ lib/profile/InstrProfilingPort.h @@ -10,14 +10,21 @@ #ifndef PROFILE_INSTRPROFILING_PORT_H_ #define PROFILE_INSTRPROFILING_PORT_H_ +/* Keep in sync with InstrProfData.inc. */ +#ifndef COMPILER_RT_VISIBILITY #ifdef _MSC_VER -#define COMPILER_RT_ALIGNAS(x) __declspec(align(x)) #define COMPILER_RT_VISIBILITY +#elif __GNUC__ +#define COMPILER_RT_VISIBILITY __attribute__((visibility("hidden"))) +#endif +#endif + +#ifdef _MSC_VER +#define COMPILER_RT_ALIGNAS(x) __declspec(align(x)) #define COMPILER_RT_WEAK __declspec(selectany) #define COMPILER_RT_ALLOCA _alloca #elif __GNUC__ #define COMPILER_RT_ALIGNAS(x) __attribute__((aligned(x))) -#define COMPILER_RT_VISIBILITY __attribute__((visibility("hidden"))) #define COMPILER_RT_WEAK __attribute__((weak)) #define COMPILER_RT_ALLOCA __builtin_alloca #endif