[compiler-rt] r270737 - [esan][cfrag] Add skeleton for cache fragmentation tool support

Qin Zhao via llvm-commits llvm-commits at lists.llvm.org
Wed May 25 10:49:01 PDT 2016


Author: zhaoqin
Date: Wed May 25 12:49:00 2016
New Revision: 270737

URL: http://llvm.org/viewvc/llvm-project?rev=270737&view=rev
Log:
[esan][cfrag] Add skeleton for cache fragmentation tool support

Summary:
Adds cache_frag.h and cache_frag.cpp for the cache fragmentation tool.

Updates test struct-simple.cpp.

Reviewers: aizatsky

Subscribers: filcab, zhaoqin, llvm-commits, eugenis, vitalybuka, kcc, bruening, kubabrecka

Differential Revision: http://reviews.llvm.org/D20538

Added:
    compiler-rt/trunk/lib/esan/cache_frag.cpp
    compiler-rt/trunk/lib/esan/cache_frag.h
Modified:
    compiler-rt/trunk/lib/esan/CMakeLists.txt
    compiler-rt/trunk/lib/esan/esan.cpp
    compiler-rt/trunk/test/esan/TestCases/struct-simple.cpp

Modified: compiler-rt/trunk/lib/esan/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/esan/CMakeLists.txt?rev=270737&r1=270736&r2=270737&view=diff
==============================================================================
--- compiler-rt/trunk/lib/esan/CMakeLists.txt (original)
+++ compiler-rt/trunk/lib/esan/CMakeLists.txt Wed May 25 12:49:00 2016
@@ -12,6 +12,7 @@ set(ESAN_SOURCES
   esan_flags.cpp
   esan_interface.cpp
   esan_interceptors.cpp
+  cache_frag.cpp
   working_set.cpp)
 
 foreach (arch ${ESAN_SUPPORTED_ARCH})

Added: compiler-rt/trunk/lib/esan/cache_frag.cpp
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/esan/cache_frag.cpp?rev=270737&view=auto
==============================================================================
--- compiler-rt/trunk/lib/esan/cache_frag.cpp (added)
+++ compiler-rt/trunk/lib/esan/cache_frag.cpp Wed May 25 12:49:00 2016
@@ -0,0 +1,40 @@
+//===-- cache_frag.cpp ----------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file is a part of EfficiencySanitizer, a family of performance tuners.
+//
+// This file contains cache fragmentation-specific code.
+//===----------------------------------------------------------------------===//
+
+#include "esan.h"
+
+namespace __esan {
+
+//===-- Init/exit functions -----------------------------------------------===//
+
+void processCacheFragCompilationUnitInit(void *Ptr) {
+  VPrintf(2, "in esan::%s\n", __FUNCTION__);
+}
+
+void processCacheFragCompilationUnitExit(void *Ptr) {
+  VPrintf(2, "in esan::%s\n", __FUNCTION__);
+}
+
+void initializeCacheFrag() {
+  VPrintf(2, "in esan::%s\n", __FUNCTION__);
+}
+
+int finalizeCacheFrag() {
+  VPrintf(2, "in esan::%s\n", __FUNCTION__);
+  // FIXME: add the cache fragmentation final report.
+  Report("%s is not finished: nothing yet to report\n", SanitizerToolName);
+  return 0;
+}
+
+} // namespace __esan

Added: compiler-rt/trunk/lib/esan/cache_frag.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/esan/cache_frag.h?rev=270737&view=auto
==============================================================================
--- compiler-rt/trunk/lib/esan/cache_frag.h (added)
+++ compiler-rt/trunk/lib/esan/cache_frag.h Wed May 25 12:49:00 2016
@@ -0,0 +1,28 @@
+//===-- cache_frag.h --------------------------------------------*- C++ -*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file is a part of EfficiencySanitizer, a family of performance tuners.
+//
+// Header for cache-fragmentation-specific code.
+//===----------------------------------------------------------------------===//
+
+#ifndef CACHE_FRAG_H
+#define CACHE_FRAG_H
+
+namespace __esan {
+
+void processCacheFragCompilationUnitInit(void *Ptr);
+void processCacheFragCompilationUnitExit(void *Ptr);
+
+void initializeCacheFrag();
+int finalizeCacheFrag();
+
+} // namespace __esan
+
+#endif  // CACHE_FRAG_H

Modified: compiler-rt/trunk/lib/esan/esan.cpp
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/esan/esan.cpp?rev=270737&r1=270736&r2=270737&view=diff
==============================================================================
--- compiler-rt/trunk/lib/esan/esan.cpp (original)
+++ compiler-rt/trunk/lib/esan/esan.cpp Wed May 25 12:49:00 2016
@@ -16,6 +16,7 @@
 #include "esan_flags.h"
 #include "esan_interface_internal.h"
 #include "esan_shadow.h"
+#include "cache_frag.h"
 #include "sanitizer_common/sanitizer_common.h"
 #include "sanitizer_common/sanitizer_flag_parser.h"
 #include "sanitizer_common/sanitizer_flags.h"
@@ -175,7 +176,7 @@ void initializeLibrary(ToolType Tool) {
   initializeInterceptors();
 
   if (WhichTool == ESAN_CacheFrag) {
-    // FIXME: add runtime code for this tool
+    initializeCacheFrag();
   } else if (WhichTool == ESAN_WorkingSet) {
     initializeWorkingSet();
   }
@@ -186,10 +187,7 @@ void initializeLibrary(ToolType Tool) {
 int finalizeLibrary() {
   VPrintf(1, "in esan::%s\n", __FUNCTION__);
   if (WhichTool == ESAN_CacheFrag) {
-    // FIXME NYI: we need to add sampling + callstack gathering and have a
-    // strategy for how to generate a final report.
-    // We'll move this to cache_frag.cpp once we have something.
-    Report("%s is not finished: nothing yet to report\n", SanitizerToolName);
+    return finalizeCacheFrag();
   } else if (WhichTool == ESAN_WorkingSet) {
     return finalizeWorkingSet();
   }
@@ -198,12 +196,18 @@ int finalizeLibrary() {
 
 void processCompilationUnitInit(void *Ptr) {
   VPrintf(2, "in esan::%s\n", __FUNCTION__);
+  if (WhichTool == ESAN_CacheFrag) {
+    processCacheFragCompilationUnitInit(Ptr);
+  }
 }
 
 // This is called when the containing module is unloaded.
 // For the main executable module, this is called after finalizeLibrary.
 void processCompilationUnitExit(void *Ptr) {
   VPrintf(2, "in esan::%s\n", __FUNCTION__);
+  if (WhichTool == ESAN_CacheFrag) {
+    processCacheFragCompilationUnitExit(Ptr);
+  }
 }
 
 } // namespace __esan

Modified: compiler-rt/trunk/test/esan/TestCases/struct-simple.cpp
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/esan/TestCases/struct-simple.cpp?rev=270737&r1=270736&r2=270737&view=diff
==============================================================================
--- compiler-rt/trunk/test/esan/TestCases/struct-simple.cpp (original)
+++ compiler-rt/trunk/test/esan/TestCases/struct-simple.cpp Wed May 25 12:49:00 2016
@@ -26,13 +26,19 @@ void part()
 #ifdef MAIN
 int main(int argc, char **argv) {
   // CHECK:      in esan::initializeLibrary
-  // CHECK:      in esan::processCompilationUnitInit
-  // CHECK:      in esan::processCompilationUnitInit
+  // CHECK:      in esan::initializeCacheFrag
+  // CHECK-NEXT: in esan::processCompilationUnitInit
+  // CHECK-NEXT: in esan::processCacheFragCompilationUnitInit
+  // CHECK-NEXT: in esan::processCompilationUnitInit
+  // CHECK-NEXT: in esan::processCacheFragCompilationUnitInit
   part();
   return 0;
-  // CHECK-NEXT: in esan::finalizeLibrary
+  // CHECK:      in esan::finalizeLibrary
+  // CHECK-NEXT: in esan::finalizeCacheFrag
   // CHECK-NEXT: {{.*}}EfficiencySanitizer is not finished: nothing yet to report
-  // CHECK:      in esan::processCompilationUnitExit
-  // CHECK:      in esan::processCompilationUnitExit
+  // CHECK-NEXT: in esan::processCompilationUnitExit
+  // CHECK-NEXT: in esan::processCacheFragCompilationUnitExit
+  // CHECK-NEXT: in esan::processCompilationUnitExit
+  // CHECK-NEXT: in esan::processCacheFragCompilationUnitExit
 }
 #endif // MAIN




More information about the llvm-commits mailing list