As pointed out in https://reviews.llvm.org/D66979 post-commit, making
this test textual would make it more maintainable.
Details
Details
Diff Detail
Diff Detail
Event Timeline
Comment Actions
Hi Vedant, thanks for the quick fix.
The test file works, and I'm able to patch it when I add more value profiles.
I think the comments should be rearranged like so (basically I fixed the placement of the Counter and Name sections):
// Header // // INSTR_PROF_RAW_HEADER(uint64_t, Magic, __llvm_profile_get_magic()) // INSTR_PROF_RAW_HEADER(uint64_t, Version, __llvm_profile_get_version()) // INSTR_PROF_RAW_HEADER(uint64_t, DataSize, DataSize) // INSTR_PROF_RAW_HEADER(uint64_t, CountersSize, CountersSize) // INSTR_PROF_RAW_HEADER(uint64_t, NamesSize, NamesSize) // INSTR_PROF_RAW_HEADER(uint64_t, CountersDelta, (uintptr_t)CountersBegin) // INSTR_PROF_RAW_HEADER(uint64_t, NamesDelta, (uintptr_t)NamesBegin) // INSTR_PROF_RAW_HEADER(uint64_t, ValueKindLast, IPVK_Last) RUN: printf '\201rforpl\377' > %t.profraw RUN: printf '\4\0\0\0\0\0\0\0' >> %t.profraw RUN: printf '\1\0\0\0\0\0\0\0' >> %t.profraw RUN: printf '\2\0\0\0\0\0\0\0' >> %t.profraw RUN: printf '\10\0\0\0\0\0\0\0' >> %t.profraw RUN: printf '\0\0\6\0\1\0\0\0' >> %t.profraw RUN: printf '\0\0\6\0\2\0\0\0' >> %t.profraw RUN: printf '\0\0\0\0\0\0\0\0' >> %t.profraw // Data Section // // INSTR_PROF_DATA(const uint64_t, llvm::Type::getInt64Ty(Ctx), NameRef, \ // ConstantInt::get(llvm::Type::getInt64Ty(Ctx), \ // IndexedInstrProf::ComputeHash(getPGOFuncNameVarInitializer(Inc->getName())))) // INSTR_PROF_DATA(const uint64_t, llvm::Type::getInt64Ty(Ctx), FuncHash, \ // ConstantInt::get(llvm::Type::getInt64Ty(Ctx), \ // Inc->getHash()->getZExtValue())) // INSTR_PROF_DATA(const IntPtrT, llvm::Type::getInt64PtrTy(Ctx), CounterPtr, \ // ConstantExpr::getBitCast(CounterPtr, \ // llvm::Type::getInt64PtrTy(Ctx))) // INSTR_PROF_DATA(const IntPtrT, llvm::Type::getInt8PtrTy(Ctx), FunctionPointer, \ // FunctionAddr) // INSTR_PROF_DATA(IntPtrT, llvm::Type::getInt8PtrTy(Ctx), Values, \ // ValuesPtrExpr) // INSTR_PROF_DATA(const uint32_t, llvm::Type::getInt32Ty(Ctx), NumCounters, \ // ConstantInt::get(llvm::Type::getInt32Ty(Ctx), NumCounters)) // INSTR_PROF_DATA(const uint16_t, Int16ArrayTy, NumValueSites[IPVK_Last+1], \ // ConstantArray::get(Int16ArrayTy, Int16ArrayVals) RUN: printf '\067\265\035\031\112\165\023\344' >> %t.profraw RUN: printf '\02\0\0\0\0\0\0\0' >> %t.profraw // Note: The CounterPtr here is off-by-one. This should trigger a malformed profile error. RUN: printf '\0\0\6\0\1\0\0\1' >> %t.profraw RUN: printf '\0\0\0\0\0\0\0\0' >> %t.profraw RUN: printf '\0\0\0\0\0\0\0\0' >> %t.profraw RUN: printf '\02\0\0\0\0\0\0\0' >> %t.profraw // Counter Section RUN: printf '\067\0\0\0\0\0\0\0' >> %t.profraw RUN: printf '\101\0\0\0\0\0\0\0' >> %t.profraw // Name Section RUN: printf '\3\0bar\0\0\0' >> %t.profraw RUN: not llvm-profdata merge -o /dev/null %t.profraw 2>&1 | FileCheck %s CHECK: Malformed instrumentation profile data
Also, an alternative to listing the fields of the ProfData struct, is to use this comment or something similar to indicate that an array of ProfData (or __llvm_profile_data) objects follow:
struct ProfData { #define INSTR_PROF_DATA(Type, LLVMType, Name, Initializer) \ Type Name; #include "llvm/ProfileData/InstrProfData.inc" };
that way the comment doesn't have to be updated everytime we update ProfData.
Either way is fine.