Index: lib/esan/cache_frag.cpp =================================================================== --- lib/esan/cache_frag.cpp +++ 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 *CFI = (CacheFragInfo *)Ptr; + VPrintf(2, "in esan::%s: %s with %u class(es)/struct(s)\n", + __FUNCTION__, CFI->UnitName, CFI->NumOfStructs); } void processCacheFragCompilationUnitExit(void *Ptr) { - VPrintf(2, "in esan::%s\n", __FUNCTION__); + CacheFragInfo *CFI = (CacheFragInfo *)Ptr; + VPrintf(2, "in esan::%s: %s with %u class(es)/struct(s)\n", + __FUNCTION__, CFI->UnitName, CFI->NumOfStructs); } void initializeCacheFrag() { Index: lib/esan/esan.cpp =================================================================== --- lib/esan/esan.cpp +++ lib/esan/esan.cpp @@ -197,7 +197,10 @@ void processCompilationUnitInit(void *Ptr) { VPrintf(2, "in esan::%s\n", __FUNCTION__); if (WhichTool == ESAN_CacheFrag) { + DCHECK(Ptr != nullptr); processCacheFragCompilationUnitInit(Ptr); + } else { + DCHECK(Ptr == nullptr); } } @@ -206,7 +209,10 @@ void processCompilationUnitExit(void *Ptr) { VPrintf(2, "in esan::%s\n", __FUNCTION__); if (WhichTool == ESAN_CacheFrag) { + DCHECK(Ptr != nullptr); processCacheFragCompilationUnitExit(Ptr); + } else { + DCHECK(Ptr == nullptr); } } Index: test/esan/TestCases/struct-simple.cpp =================================================================== --- test/esan/TestCases/struct-simple.cpp +++ test/esan/TestCases/struct-simple.cpp @@ -28,17 +28,17 @@ // 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