Skip to content

Commit c809da7

Browse files
committed
Revert "[InstrProf] Attach debug info to counters"
This reverts commit 800bf8e. The `Instrumentation/InstrProfiling/debug-info-correlate.ll` test was failing because I forgot the `llc` commands are architecture specific. I'll follow up with a fix. Differential Revision: https://reviews.llvm.org/D115689
1 parent 800bf8e commit c809da7

File tree

13 files changed

+24
-199
lines changed

13 files changed

+24
-199
lines changed

clang/lib/CodeGen/BackendUtil.cpp

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -94,17 +94,10 @@ using namespace llvm;
9494
llvm::PassPluginLibraryInfo get##Ext##PluginInfo();
9595
#include "llvm/Support/Extension.def"
9696

97-
namespace llvm {
98-
extern cl::opt<bool> DebugInfoCorrelate;
99-
}
100-
10197
namespace {
10298

10399
// Default filename used for profile generation.
104-
Twine getDefaultProfileGenName() {
105-
const Twine Extension = DebugInfoCorrelate ? "proflite" : "profraw";
106-
return "default_%m." + Extension;
107-
}
100+
static constexpr StringLiteral DefaultProfileGenName = "default_%m.profraw";
108101

109102
class EmitAssemblyHelper {
110103
DiagnosticsEngine &Diags;
@@ -893,7 +886,7 @@ void EmitAssemblyHelper::CreatePasses(legacy::PassManager &MPM,
893886
if (!CodeGenOpts.InstrProfileOutput.empty())
894887
PMBuilder.PGOInstrGen = CodeGenOpts.InstrProfileOutput;
895888
else
896-
PMBuilder.PGOInstrGen = getDefaultProfileGenName().str();
889+
PMBuilder.PGOInstrGen = std::string(DefaultProfileGenName);
897890
}
898891
if (CodeGenOpts.hasProfileIRUse()) {
899892
PMBuilder.PGOInstrUse = CodeGenOpts.ProfileInstrumentUsePath;
@@ -1238,7 +1231,7 @@ void EmitAssemblyHelper::RunOptimizationPipeline(
12381231
if (CodeGenOpts.hasProfileIRInstr())
12391232
// -fprofile-generate.
12401233
PGOOpt = PGOOptions(CodeGenOpts.InstrProfileOutput.empty()
1241-
? getDefaultProfileGenName().str()
1234+
? std::string(DefaultProfileGenName)
12421235
: CodeGenOpts.InstrProfileOutput,
12431236
"", "", PGOOptions::IRInstr, PGOOptions::NoCSAction,
12441237
CodeGenOpts.DebugInfoForProfiling);
@@ -1276,13 +1269,13 @@ void EmitAssemblyHelper::RunOptimizationPipeline(
12761269
"Cannot run CSProfileGen pass with ProfileGen or SampleUse "
12771270
" pass");
12781271
PGOOpt->CSProfileGenFile = CodeGenOpts.InstrProfileOutput.empty()
1279-
? getDefaultProfileGenName().str()
1272+
? std::string(DefaultProfileGenName)
12801273
: CodeGenOpts.InstrProfileOutput;
12811274
PGOOpt->CSAction = PGOOptions::CSIRInstr;
12821275
} else
12831276
PGOOpt = PGOOptions("",
12841277
CodeGenOpts.InstrProfileOutput.empty()
1285-
? getDefaultProfileGenName().str()
1278+
? std::string(DefaultProfileGenName)
12861279
: CodeGenOpts.InstrProfileOutput,
12871280
"", PGOOptions::NoAction, PGOOptions::CSIRInstr,
12881281
CodeGenOpts.DebugInfoForProfiling);

compiler-rt/include/profile/InstrProfData.inc

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -653,17 +653,15 @@ serializeValueProfDataFrom(ValueProfRecordClosure *Closure,
653653

654654
/* Profile version is always of type uint64_t. Reserve the upper 8 bits in the
655655
* version for other variants of profile. We set the lowest bit of the upper 8
656-
* bits (i.e. bit 56) to 1 to indicate if this is an IR-level instrumentation
656+
* bits (i.e. bit 56) to 1 to indicate if this is an IR-level instrumentaiton
657657
* generated profile, and 0 if this is a Clang FE generated profile.
658658
* 1 in bit 57 indicates there are context-sensitive records in the profile.
659-
* The 59th bit indicates whether to use debug info to correlate profiles.
660659
*/
661660
#define VARIANT_MASKS_ALL 0xff00000000000000ULL
662661
#define GET_VERSION(V) ((V) & ~VARIANT_MASKS_ALL)
663662
#define VARIANT_MASK_IR_PROF (0x1ULL << 56)
664663
#define VARIANT_MASK_CSIR_PROF (0x1ULL << 57)
665664
#define VARIANT_MASK_INSTR_ENTRY (0x1ULL << 58)
666-
#define VARIANT_MASK_DBG_CORRELATE (0x1ULL << 59)
667665
#define INSTR_PROF_RAW_VERSION_VAR __llvm_profile_raw_version
668666
#define INSTR_PROF_PROFILE_RUNTIME_VAR __llvm_profile_runtime
669667
#define INSTR_PROF_PROFILE_COUNTER_BIAS_VAR __llvm_profile_counter_bias

compiler-rt/lib/profile/InstrProfiling.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ __llvm_profile_get_num_padding_bytes(uint64_t SizeInBytes) {
3838
}
3939

4040
COMPILER_RT_VISIBILITY uint64_t __llvm_profile_get_version(void) {
41-
return INSTR_PROF_RAW_VERSION_VAR;
41+
return __llvm_profile_raw_version;
4242
}
4343

4444
COMPILER_RT_VISIBILITY void __llvm_profile_reset_counters(void) {

compiler-rt/lib/profile/InstrProfilingMerge.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,6 @@ static uintptr_t signextIfWin64(void *V) {
9595
COMPILER_RT_VISIBILITY
9696
int __llvm_profile_merge_from_buffer(const char *ProfileData,
9797
uint64_t ProfileSize) {
98-
int DebugInfoCorrelate =
99-
(__llvm_profile_get_version() & VARIANT_MASK_DBG_CORRELATE) != 0ULL;
100-
if (DebugInfoCorrelate)
101-
return 1;
102-
10398
__llvm_profile_data *SrcDataStart, *SrcDataEnd, *SrcData, *DstData;
10499
__llvm_profile_header *Header = (__llvm_profile_header *)ProfileData;
105100
uint64_t *SrcCountersStart;

compiler-rt/lib/profile/InstrProfilingWriter.c

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -259,19 +259,16 @@ lprofWriteDataImpl(ProfDataWriter *Writer, const __llvm_profile_data *DataBegin,
259259
const uint64_t *CountersBegin, const uint64_t *CountersEnd,
260260
VPDataReaderType *VPDataReader, const char *NamesBegin,
261261
const char *NamesEnd, int SkipNameDataWrite) {
262-
int DebugInfoCorrelate =
263-
(__llvm_profile_get_version() & VARIANT_MASK_DBG_CORRELATE) != 0ULL;
264262

265263
/* Calculate size of sections. */
266-
const uint64_t DataSize =
267-
DebugInfoCorrelate ? 0 : __llvm_profile_get_data_size(DataBegin, DataEnd);
264+
const uint64_t DataSize = __llvm_profile_get_data_size(DataBegin, DataEnd);
268265
const uint64_t CountersSize = CountersEnd - CountersBegin;
269-
const uint64_t NamesSize = DebugInfoCorrelate ? 0 : NamesEnd - NamesBegin;
266+
const uint64_t NamesSize = NamesEnd - NamesBegin;
270267

271268
/* Create the header. */
272269
__llvm_profile_header Header;
273270

274-
if (!DataSize && (!DebugInfoCorrelate || !CountersSize))
271+
if (!DataSize)
275272
return 0;
276273

277274
/* Determine how much padding is needed before/after the counters and after
@@ -292,12 +289,6 @@ lprofWriteDataImpl(ProfDataWriter *Writer, const __llvm_profile_data *DataBegin,
292289
Header.CountersDelta = (uint32_t)Header.CountersDelta;
293290
#endif
294291

295-
/* The data and names sections are omitted in lightweight mode. */
296-
if (DebugInfoCorrelate) {
297-
Header.CountersDelta = 0;
298-
Header.NamesDelta = 0;
299-
}
300-
301292
/* Write the profile header. */
302293
ProfDataIOVec IOVec[] = {{&Header, sizeof(__llvm_profile_header), 1, 0}};
303294
if (Writer->Write(Writer, IOVec, sizeof(IOVec) / sizeof(*IOVec)))
@@ -309,13 +300,11 @@ lprofWriteDataImpl(ProfDataWriter *Writer, const __llvm_profile_data *DataBegin,
309300

310301
/* Write the profile data. */
311302
ProfDataIOVec IOVecData[] = {
312-
{DebugInfoCorrelate ? NULL : DataBegin, sizeof(__llvm_profile_data),
313-
DataSize, 0},
303+
{DataBegin, sizeof(__llvm_profile_data), DataSize, 0},
314304
{NULL, sizeof(uint8_t), PaddingBytesBeforeCounters, 1},
315305
{CountersBegin, sizeof(uint64_t), CountersSize, 0},
316306
{NULL, sizeof(uint8_t), PaddingBytesAfterCounters, 1},
317-
{(SkipNameDataWrite || DebugInfoCorrelate) ? NULL : NamesBegin,
318-
sizeof(uint8_t), NamesSize, 0},
307+
{SkipNameDataWrite ? NULL : NamesBegin, sizeof(uint8_t), NamesSize, 0},
319308
{NULL, sizeof(uint8_t), PaddingBytesAfterNames, 1}};
320309
if (Writer->Write(Writer, IOVecData, sizeof(IOVecData) / sizeof(*IOVecData)))
321310
return -1;

llvm/include/llvm/ProfileData/InstrProf.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1149,8 +1149,7 @@ void getMemOPSizeRangeFromOption(StringRef Str, int64_t &RangeStart,
11491149
// Create a COMDAT variable INSTR_PROF_RAW_VERSION_VAR to make the runtime
11501150
// aware this is an ir_level profile so it can set the version flag.
11511151
GlobalVariable *createIRLevelProfileFlagVar(Module &M, bool IsCS,
1152-
bool InstrEntryBBEnabled,
1153-
bool DebugInfoCorrelate);
1152+
bool InstrEntryBBEnabled);
11541153

11551154
// Create the variable for the profile file name.
11561155
void createProfileFileNameVar(Module &M, StringRef InstrProfileOutput);

llvm/include/llvm/ProfileData/InstrProfData.inc

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -653,17 +653,15 @@ serializeValueProfDataFrom(ValueProfRecordClosure *Closure,
653653

654654
/* Profile version is always of type uint64_t. Reserve the upper 8 bits in the
655655
* version for other variants of profile. We set the lowest bit of the upper 8
656-
* bits (i.e. bit 56) to 1 to indicate if this is an IR-level instrumentation
656+
* bits (i.e. bit 56) to 1 to indicate if this is an IR-level instrumentaiton
657657
* generated profile, and 0 if this is a Clang FE generated profile.
658658
* 1 in bit 57 indicates there are context-sensitive records in the profile.
659-
* The 59th bit indicates whether to use debug info to correlate profiles.
660659
*/
661660
#define VARIANT_MASKS_ALL 0xff00000000000000ULL
662661
#define GET_VERSION(V) ((V) & ~VARIANT_MASKS_ALL)
663662
#define VARIANT_MASK_IR_PROF (0x1ULL << 56)
664663
#define VARIANT_MASK_CSIR_PROF (0x1ULL << 57)
665664
#define VARIANT_MASK_INSTR_ENTRY (0x1ULL << 58)
666-
#define VARIANT_MASK_DBG_CORRELATE (0x1ULL << 59)
667665
#define INSTR_PROF_RAW_VERSION_VAR __llvm_profile_raw_version
668666
#define INSTR_PROF_PROFILE_RUNTIME_VAR __llvm_profile_runtime
669667
#define INSTR_PROF_PROFILE_COUNTER_BIAS_VAR __llvm_profile_counter_bias

llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -842,17 +842,13 @@ void DwarfUnit::addAnnotation(DIE &Buffer, DINodeArray Annotations) {
842842
for (const Metadata *Annotation : Annotations->operands()) {
843843
const MDNode *MD = cast<MDNode>(Annotation);
844844
const MDString *Name = cast<MDString>(MD->getOperand(0));
845-
const auto &Value = MD->getOperand(1);
845+
846+
// Currently, only MDString is supported with btf_decl_tag attribute.
847+
const MDString *Value = cast<MDString>(MD->getOperand(1));
846848

847849
DIE &AnnotationDie = createAndAddDIE(dwarf::DW_TAG_LLVM_annotation, Buffer);
848850
addString(AnnotationDie, dwarf::DW_AT_name, Name->getString());
849-
if (const auto *Data = dyn_cast<MDString>(Value))
850-
addString(AnnotationDie, dwarf::DW_AT_const_value, Data->getString());
851-
else if (const auto *Data = dyn_cast<ConstantAsMetadata>(Value))
852-
addConstantValue(AnnotationDie, Data->getValue()->getUniqueInteger(),
853-
/*Unsigned=*/true);
854-
else
855-
assert(false && "Unsupported annotation value type");
851+
addString(AnnotationDie, dwarf::DW_AT_const_value, Value->getString());
856852
}
857853
}
858854

llvm/lib/ProfileData/InstrProf.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1175,17 +1175,14 @@ bool canRenameComdatFunc(const Function &F, bool CheckAddressTaken) {
11751175
// Create a COMDAT variable INSTR_PROF_RAW_VERSION_VAR to make the runtime
11761176
// aware this is an ir_level profile so it can set the version flag.
11771177
GlobalVariable *createIRLevelProfileFlagVar(Module &M, bool IsCS,
1178-
bool InstrEntryBBEnabled,
1179-
bool DebugInfoCorrelate) {
1178+
bool InstrEntryBBEnabled) {
11801179
const StringRef VarName(INSTR_PROF_QUOTE(INSTR_PROF_RAW_VERSION_VAR));
11811180
Type *IntTy64 = Type::getInt64Ty(M.getContext());
11821181
uint64_t ProfileVersion = (INSTR_PROF_RAW_VERSION | VARIANT_MASK_IR_PROF);
11831182
if (IsCS)
11841183
ProfileVersion |= VARIANT_MASK_CSIR_PROF;
11851184
if (InstrEntryBBEnabled)
11861185
ProfileVersion |= VARIANT_MASK_INSTR_ENTRY;
1187-
if (DebugInfoCorrelate)
1188-
ProfileVersion |= VARIANT_MASK_DBG_CORRELATE;
11891186
auto IRLevelVersionVariable = new GlobalVariable(
11901187
M, IntTy64, true, GlobalValue::WeakAnyLinkage,
11911188
Constant::getIntegerValue(IntTy64, APInt(64, ProfileVersion)), VarName);

llvm/lib/ProfileData/InstrProfWriter.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
#include <vector>
3333

3434
using namespace llvm;
35-
extern cl::opt<bool> DebugInfoCorrelate;
3635

3736
// A struct to define how the data stream should be patched. For Indexed
3837
// profiling, only uint64_t data type is needed.

0 commit comments

Comments
 (0)