[llvm] r250574 - Instroduce a template file to define InstrPGO core data structures.

Sean Silva via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 16 16:33:36 PDT 2015


On Fri, Oct 16, 2015 at 4:27 PM, Xinliang David Li <davidxl at google.com>
wrote:

> First use will come shortly (as in today).
>

No big deal, but it would be nice to mention that in the commit message
(usually we phrase it as "an upcoming commit will ...").

-- Sean Silva


>
> David
>
> On Fri, Oct 16, 2015 at 4:26 PM, Sean Silva <chisophugis at gmail.com> wrote:
>
>> In LLVM we typically add code with its first use, so for consistency this
>> should probably be reverted and introduced with its first use.
>>
>> -- Sean Silva
>>
>> On Fri, Oct 16, 2015 at 4:17 PM, Xinliang David Li via llvm-commits <
>> llvm-commits at lists.llvm.org> wrote:
>>
>>> Author: davidxl
>>> Date: Fri Oct 16 18:17:34 2015
>>> New Revision: 250574
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=250574&view=rev
>>> Log:
>>> Instroduce a template file to define InstrPGO core data structures.
>>>
>>> Changing PGO data format layout can be a pain. Many different places need
>>> to be touched and kept in sync. Failing to do so usually results in
>>> errors
>>> very time consuming to debug.
>>>
>>> This file is intended to be the master file that defines the layout of
>>> the
>>> core runtime data structures. Currently only two structure is covered:
>>> Per
>>> function ProfData structure and the function record structure used in
>>> coverage mapping.
>>>
>>> No client code has been made yet, so this commit is NFC.
>>>
>>>
>>>
>>> Added:
>>>     llvm/trunk/include/llvm/ProfileData/InstrProfData.inc
>>>
>>> Added: llvm/trunk/include/llvm/ProfileData/InstrProfData.inc
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ProfileData/InstrProfData.inc?rev=250574&view=auto
>>>
>>> ==============================================================================
>>> --- llvm/trunk/include/llvm/ProfileData/InstrProfData.inc (added)
>>> +++ llvm/trunk/include/llvm/ProfileData/InstrProfData.inc Fri Oct 16
>>> 18:17:34 2015
>>> @@ -0,0 +1,88 @@
>>> +//===-- InstrProfData.inc - instr profiling runtime structures-----===//
>>> +//
>>> +//                     The LLVM Compiler Infrastructure
>>> +//
>>> +// This file is distributed under the University of Illinois Open Source
>>> +// License. See LICENSE.TXT for details.
>>> +//
>>>
>>> +//===----------------------------------------------------------------------===//
>>> +//
>>> +// This file defines templates for core runtime data structures used by
>>> +// instrumentation based profiling and coverage mapping. The
>>> instrumentation
>>> +// runtime library, the compiler IR lowering, and profile reader/writer
>>> need
>>> +// to use the same template to make sure the same data structure is
>>> defined
>>> +// consistently.
>>> +//
>>> +// Examples of how the template is used:
>>> +// 1. To declare a structure:
>>> +//
>>> +// struct ProfData {
>>> +// #define INSTR_PROF_DATA(Type, LLVMTypeVar, LLVMType, Name,
>>> Initializer) \
>>> +//    Type Name;
>>> +// #include "ProfileData/InstrProfData.inc"
>>> +// };
>>> +//
>>> +// 2. To define local variables for struct member's LLVM types"
>>> +//
>>> +// #define INSTR_PROF_DATA(Type, LLVMTypeVar, LLVMType, Name,
>>> Initializer) \
>>> +//   LLVMTypeVar = LLVMType;
>>> +// #include "ProfileData/InstrProfData.inc"
>>> +//
>>> +// 3. To construct LLVM type arrays for the struct type:
>>> +//
>>> +// Type *DataTypes[] = {
>>> +// #define INSTR_PROF_DATA(Type, LLVMTypeVar, LLVMType, Name,
>>> Initializer) \
>>> +//   LLVMTypeVar,
>>> +// #include "ProfileData/InstrProfData.inc"
>>> +// };
>>> +//
>>> +// 4. To construct constant array for the initializers:
>>> +// #define INSTR_PROF_DATA(Type, LLVMTypeVar, LLVMType, Name,
>>> Initializer) \
>>> +//   Initializer,
>>> +// Constant *ConstantVals[] = {
>>> +// #include "ProfileData/InstrProfData.inc"
>>> +// };
>>>
>>> +//===----------------------------------------------------------------------===//
>>> +
>>> +#ifndef INSTR_PROF_DATA
>>> +#define INSTR_PROF_DATA(Type, LLVMTypeVar, LLVMType, Name, Initializer)
>>> +#endif
>>> +
>>> +// INSTR_PROF_DATA_START
>>> +INSTR_PROF_DATA(const uint32_t, Int32Ty, llvm::Type::getInt32Ty(Ctx),
>>> NameSize, \
>>> +                ConstantInt::get(Int32Ty, NameSize))
>>> +INSTR_PROF_DATA(const uint32_t, Int32Ty, llvm::Type::getInt32Ty(Ctx),
>>> NumCounters, \
>>> +                ConstantInt::get(Int32Ty, NumCounters))
>>> +INSTR_PROF_DATA(const uint64_t, Int64Ty, llvm::Type::getInt64Ty(Ctx),
>>> FuncHash, \
>>> +                ConstantInt::get(Int64Ty, FuncHash))
>>> +INSTR_PROF_DATA(const IntPtrT, Int8PtrTy,llvm::Type::getInt8PtrTy(Ctx),
>>> NamePtr, \
>>> +                ConstantExpr::getBitCast(Name, Int8PtrTy))
>>> +INSTR_PROF_DATA(const IntPtrT, Int64PtrTy,
>>> llvm::Type::getInt64PtrTy(Ctx), CounterPtr, \
>>> +                ConstantExpr::getBitCast(CounterPtr, Int8PtrTy))
>>> +// INSTR_PROF_DATA_END
>>> +
>>> +#ifdef INSTR_PROF_DATA
>>> +#undef INSTR_PROF_DATA
>>> +#endif
>>> +
>>> +
>>> +#ifndef COVMAP_FUNC_RECORD
>>> +#define COVMAP_FUNC_RECORD(Type, LLVMTypeVar, LLVMType, Name,
>>> Initializer)
>>> +#endif
>>> +
>>> +// COVMAP_FUNC_RECORD_START
>>> +COVMAP_FUNC_RECORD(const IntPtrT, Int8PtrTy,
>>> llvm::Type::getInt8PtrTy(Ctx), \
>>> +                   NamePtr, llvm::ConstantExpr::getBitCast(NamePtr,
>>> Int8PtrTy))
>>> +COVMAP_FUNC_RECORD(const uint32_t, Int32Ty,
>>> llvm::Type::getInt32Ty(Ctx), \
>>> +                   NameSize, llvm::ConstantInt::get(Int32Ty, NameSize))
>>> +COVMAP_FUNC_RECORD(const uint32_t, Int32Ty,
>>> llvm::Type::getInt32Ty(Ctx), \
>>> +                   DataSize, llvm::ConstantInt::get(Int32Ty, DataSize))
>>> +COVMAP_FUNC_RECORD(const uint64_t, Int64Ty,
>>> llvm::Type::getInt64Ty(Ctx), \
>>> +                   FuncHash, llvm::ConstantInt::get(Int64Ty, FuncSize))
>>> +// COVMAP_FUNC_RECORD_END
>>> +
>>> +#ifdef COVMAP_FUNC_RECORD
>>> +#undef COVMAP_FUNC_RECORD
>>> +#endif
>>> +
>>> +
>>>
>>>
>>> _______________________________________________
>>> llvm-commits mailing list
>>> llvm-commits at lists.llvm.org
>>> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>>>
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151016/f1f97b50/attachment-0001.html>


More information about the llvm-commits mailing list