forked from llvm-mirror/llvm
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ProfileData: Add support for the indexed instrprof format
This adds support for an indexed instrumentation based profiling format, which is just a small header and an on disk hash table. This format will be used by clang's -fprofile-instr-use= for PGO. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@206656 91177308-0d34-0410-b5e6-96231b3b80d8
- Loading branch information
Showing
10 changed files
with
377 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
//=-- InstrProfIndexed.h - Indexed profiling format support -------*- C++ -*-=// | ||
// | ||
// The LLVM Compiler Infrastructure | ||
// | ||
// This file is distributed under the University of Illinois Open Source | ||
// License. See LICENSE.TXT for details. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// Shared header for the instrumented profile data reader and writer. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef LLVM_PROFILEDATA_INSTRPROF_INDEXED_H_ | ||
#define LLVM_PROFILEDATA_INSTRPROF_INDEXED_H_ | ||
|
||
#include "llvm/Support/MD5.h" | ||
|
||
namespace llvm { | ||
|
||
namespace IndexedInstrProf { | ||
enum class HashT : uint32_t { | ||
MD5, | ||
|
||
Last = MD5 | ||
}; | ||
|
||
static inline uint64_t MD5Hash(StringRef Str) { | ||
MD5 Hash; | ||
Hash.update(Str); | ||
llvm::MD5::MD5Result Result; | ||
Hash.final(Result); | ||
// Return the least significant 8 bytes. Our MD5 implementation returns the | ||
// result in little endian, so we may need to swap bytes. | ||
using namespace llvm::support; | ||
return endian::read<uint64_t, little, unaligned>(Result); | ||
} | ||
|
||
uint64_t ComputeHash(HashT Type, StringRef K) { | ||
switch (Type) { | ||
case HashT::MD5: | ||
return IndexedInstrProf::MD5Hash(K); | ||
} | ||
llvm_unreachable("Unhandled hash type"); | ||
} | ||
|
||
const uint64_t Magic = 0x8169666f72706cff; // "\xfflprofi\x81" | ||
const uint64_t Version = 1; | ||
const HashT HashType = HashT::MD5; | ||
} | ||
|
||
} // end namespace llvm | ||
|
||
#endif // LLVM_PROFILEDATA_INSTRPROF_INDEXED_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.