diff options
| author | Qin Zhao <zhaoqin@google.com> | 2016-05-31 21:27:39 +0000 |
|---|---|---|
| committer | Qin Zhao <zhaoqin@google.com> | 2016-05-31 21:27:39 +0000 |
| commit | 9e39638375cf8063c878531c004b2b82ff785dba (patch) | |
| tree | 02332603d52d8edfa12e6c915341b0f6492ee741 /compiler-rt | |
| parent | f179364341ef49440757a481b377627d17db3aaa (diff) | |
| download | bcm5719-llvm-9e39638375cf8063c878531c004b2b82ff785dba.tar.gz bcm5719-llvm-9e39638375cf8063c878531c004b2b82ff785dba.zip | |
[esan|cfrag] Add the skeleton to handle the cfrag argument
Summary:
Adds the struct declaration for the cache-fragmentation tool variable
passed to the runtime library.
Updates test struct-simple.cpp.
Reviewers: aizatsky, bruening
Subscribers: filcab, kubabrecka, bruening, kcc, vitalybuka, eugenis, llvm-commits, zhaoqin
Differential Revision: http://reviews.llvm.org/D20542
llvm-svn: 271337
Diffstat (limited to 'compiler-rt')
| -rw-r--r-- | compiler-rt/lib/esan/cache_frag.cpp | 24 | ||||
| -rw-r--r-- | compiler-rt/lib/esan/esan.cpp | 6 | ||||
| -rw-r--r-- | compiler-rt/test/esan/TestCases/struct-simple.cpp | 8 |
3 files changed, 32 insertions, 6 deletions
diff --git a/compiler-rt/lib/esan/cache_frag.cpp b/compiler-rt/lib/esan/cache_frag.cpp index 1ab8699b983..da168dc0c29 100644 --- a/compiler-rt/lib/esan/cache_frag.cpp +++ b/compiler-rt/lib/esan/cache_frag.cpp @@ -16,14 +16,34 @@ namespace __esan { +// This should be kept consistent with LLVM's EfficiencySanitizer StructInfo. +struct StructInfo { + const char *StructName; + u32 NumOfFields; + u64 *FieldCounters; + const char **FieldTypeNames; +}; + +// This should be kept consistent with LLVM's EfficiencySanitizer CacheFragInfo. +// The tool-specific information per compilation unit (module). +struct CacheFragInfo { + const char *UnitName; + u32 NumOfStructs; + StructInfo *Structs; +}; + //===-- Init/exit functions -----------------------------------------------===// void processCacheFragCompilationUnitInit(void *Ptr) { - VPrintf(2, "in esan::%s\n", __FUNCTION__); + CacheFragInfo *CacheFrag = (CacheFragInfo *)Ptr; + VPrintf(2, "in esan::%s: %s with %u class(es)/struct(s)\n", + __FUNCTION__, CacheFrag->UnitName, CacheFrag->NumOfStructs); } void processCacheFragCompilationUnitExit(void *Ptr) { - VPrintf(2, "in esan::%s\n", __FUNCTION__); + CacheFragInfo *CacheFrag = (CacheFragInfo *)Ptr; + VPrintf(2, "in esan::%s: %s with %u class(es)/struct(s)\n", + __FUNCTION__, CacheFrag->UnitName, CacheFrag->NumOfStructs); } void initializeCacheFrag() { diff --git a/compiler-rt/lib/esan/esan.cpp b/compiler-rt/lib/esan/esan.cpp index f0a4965184c..1f116da08db 100644 --- a/compiler-rt/lib/esan/esan.cpp +++ b/compiler-rt/lib/esan/esan.cpp @@ -219,7 +219,10 @@ int finalizeLibrary() { void processCompilationUnitInit(void *Ptr) { VPrintf(2, "in esan::%s\n", __FUNCTION__); if (WhichTool == ESAN_CacheFrag) { + DCHECK(Ptr != nullptr); processCacheFragCompilationUnitInit(Ptr); + } else { + DCHECK(Ptr == nullptr); } } @@ -228,7 +231,10 @@ void processCompilationUnitInit(void *Ptr) { void processCompilationUnitExit(void *Ptr) { VPrintf(2, "in esan::%s\n", __FUNCTION__); if (WhichTool == ESAN_CacheFrag) { + DCHECK(Ptr != nullptr); processCacheFragCompilationUnitExit(Ptr); + } else { + DCHECK(Ptr == nullptr); } } diff --git a/compiler-rt/test/esan/TestCases/struct-simple.cpp b/compiler-rt/test/esan/TestCases/struct-simple.cpp index e3670f2f417..f1dd38534d7 100644 --- a/compiler-rt/test/esan/TestCases/struct-simple.cpp +++ b/compiler-rt/test/esan/TestCases/struct-simple.cpp @@ -28,17 +28,17 @@ int main(int argc, char **argv) { // CHECK: in esan::initializeLibrary // CHECK: in esan::initializeCacheFrag // CHECK-NEXT: in esan::processCompilationUnitInit - // CHECK-NEXT: in esan::processCacheFragCompilationUnitInit + // CHECK-NEXT: in esan::processCacheFragCompilationUnitInit: {{.*}}struct-simple.cpp with 0 class(es)/struct(s) // CHECK-NEXT: in esan::processCompilationUnitInit - // CHECK-NEXT: in esan::processCacheFragCompilationUnitInit + // CHECK-NEXT: in esan::processCacheFragCompilationUnitInit: {{.*}}struct-simple.cpp with 0 class(es)/struct(s) part(); return 0; // CHECK: in esan::finalizeLibrary // CHECK-NEXT: in esan::finalizeCacheFrag // CHECK-NEXT: {{.*}}EfficiencySanitizer is not finished: nothing yet to report // CHECK-NEXT: in esan::processCompilationUnitExit - // CHECK-NEXT: in esan::processCacheFragCompilationUnitExit + // CHECK-NEXT: in esan::processCacheFragCompilationUnitExit: {{.*}}struct-simple.cpp with 0 class(es)/struct(s) // CHECK-NEXT: in esan::processCompilationUnitExit - // CHECK-NEXT: in esan::processCacheFragCompilationUnitExit + // CHECK-NEXT: in esan::processCacheFragCompilationUnitExit: {{.*}}struct-simple.cpp with 0 class(es)/struct(s) } #endif // MAIN |

