Qin Zhao | 7e4933f | 2016-05-25 17:49:00 +0000 | [diff] [blame] | 1 | //===-- cache_frag.cpp ----------------------------------------------------===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This file is a part of EfficiencySanitizer, a family of performance tuners. |
| 11 | // |
| 12 | // This file contains cache fragmentation-specific code. |
| 13 | //===----------------------------------------------------------------------===// |
| 14 | |
| 15 | #include "esan.h" |
| 16 | |
| 17 | namespace __esan { |
| 18 | |
Qin Zhao | 9e39638 | 2016-05-31 21:27:39 +0000 | [diff] [blame^] | 19 | // This should be kept consistent with LLVM's EfficiencySanitizer StructInfo. |
| 20 | struct StructInfo { |
| 21 | const char *StructName; |
| 22 | u32 NumOfFields; |
| 23 | u64 *FieldCounters; |
| 24 | const char **FieldTypeNames; |
| 25 | }; |
| 26 | |
| 27 | // This should be kept consistent with LLVM's EfficiencySanitizer CacheFragInfo. |
| 28 | // The tool-specific information per compilation unit (module). |
| 29 | struct CacheFragInfo { |
| 30 | const char *UnitName; |
| 31 | u32 NumOfStructs; |
| 32 | StructInfo *Structs; |
| 33 | }; |
| 34 | |
Qin Zhao | 7e4933f | 2016-05-25 17:49:00 +0000 | [diff] [blame] | 35 | //===-- Init/exit functions -----------------------------------------------===// |
| 36 | |
| 37 | void processCacheFragCompilationUnitInit(void *Ptr) { |
Qin Zhao | 9e39638 | 2016-05-31 21:27:39 +0000 | [diff] [blame^] | 38 | CacheFragInfo *CacheFrag = (CacheFragInfo *)Ptr; |
| 39 | VPrintf(2, "in esan::%s: %s with %u class(es)/struct(s)\n", |
| 40 | __FUNCTION__, CacheFrag->UnitName, CacheFrag->NumOfStructs); |
Qin Zhao | 7e4933f | 2016-05-25 17:49:00 +0000 | [diff] [blame] | 41 | } |
| 42 | |
| 43 | void processCacheFragCompilationUnitExit(void *Ptr) { |
Qin Zhao | 9e39638 | 2016-05-31 21:27:39 +0000 | [diff] [blame^] | 44 | CacheFragInfo *CacheFrag = (CacheFragInfo *)Ptr; |
| 45 | VPrintf(2, "in esan::%s: %s with %u class(es)/struct(s)\n", |
| 46 | __FUNCTION__, CacheFrag->UnitName, CacheFrag->NumOfStructs); |
Qin Zhao | 7e4933f | 2016-05-25 17:49:00 +0000 | [diff] [blame] | 47 | } |
| 48 | |
| 49 | void initializeCacheFrag() { |
| 50 | VPrintf(2, "in esan::%s\n", __FUNCTION__); |
| 51 | } |
| 52 | |
| 53 | int finalizeCacheFrag() { |
| 54 | VPrintf(2, "in esan::%s\n", __FUNCTION__); |
| 55 | // FIXME: add the cache fragmentation final report. |
| 56 | Report("%s is not finished: nothing yet to report\n", SanitizerToolName); |
| 57 | return 0; |
| 58 | } |
| 59 | |
| 60 | } // namespace __esan |