[PATCH] D20542: [esan|cfrag] Handle the cfrag variable passed to the runtime

Filipe Cabecinhas via llvm-commits llvm-commits at lists.llvm.org
Fri May 27 11:13:40 PDT 2016


If we have a common ToolInfo struct, maybe we can switch __esan_init to
take it instead of a void* so we can do without a few of the casts.

LGTM, anyway.

Thank you,

 Filipe

On Friday, 27 May 2016, Qin Zhao <zhaoqin at google.com> wrote:

> zhaoqin updated this revision to Diff 58796.
> zhaoqin updated the summary for this revision.
> zhaoqin added a comment.
>
> Add ToolInfo and CacheFragInfo
>
>
> http://reviews.llvm.org/D20542
>
> Files:
>   lib/esan/cache_frag.cpp
>   lib/esan/esan.cpp
>   test/esan/TestCases/struct-simple.cpp
>
> Index: test/esan/TestCases/struct-simple.cpp
> ===================================================================
> --- test/esan/TestCases/struct-simple.cpp
> +++ test/esan/TestCases/struct-simple.cpp
> @@ -27,18 +27,18 @@
>  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::processCompilationUnitInit
> -  // CHECK-NEXT: in esan::processCacheFragCompilationUnitInit
> +  // CHECK-NEXT: in esan::processCompilationUnitInit:
> {{.*}}struct-simple.cpp
> +  // CHECK-NEXT: in esan::processCacheFragCompilationUnitInit:
> {{.*}}struct-simple.cpp
> +  // CHECK-NEXT: in esan::processCompilationUnitInit:
> {{.*}}struct-simple.cpp
> +  // CHECK-NEXT: in esan::processCacheFragCompilationUnitInit:
> {{.*}}struct-simple.cpp
>    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::processCompilationUnitExit
> -  // CHECK-NEXT: in esan::processCacheFragCompilationUnitExit
> +  // CHECK-NEXT: in esan::processCompilationUnitExit:
> {{.*}}struct-simple.cpp
> +  // CHECK-NEXT: in esan::processCacheFragCompilationUnitExit:
> {{.*}}struct-simple.cpp
> +  // CHECK-NEXT: in esan::processCompilationUnitExit:
> {{.*}}struct-simple.cpp
> +  // CHECK-NEXT: in esan::processCacheFragCompilationUnitExit:
> {{.*}}struct-simple.cpp
>  }
>  #endif // MAIN
> Index: lib/esan/esan.cpp
> ===================================================================
> --- lib/esan/esan.cpp
> +++ lib/esan/esan.cpp
> @@ -194,17 +194,26 @@
>    return 0;
>  }
>
> +// Struct with general tool information passed to the runtime.
> +// This structure should be kept consistent with the LLVM's
> EfficiencySanitizer
> +// ToolInfo.
> +struct ToolInfo {
> +  const char *UnitName;
> +};
> +
>  void processCompilationUnitInit(void *Ptr) {
> -  VPrintf(2, "in esan::%s\n", __FUNCTION__);
> +  ToolInfo *Info = (ToolInfo *)Ptr;
> +  VPrintf(2, "in esan::%s: %s\n", __FUNCTION__, Info->UnitName);
>    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__);
> +  ToolInfo *Info = (ToolInfo *)Ptr;
> +  VPrintf(2, "in esan::%s: %s\n", __FUNCTION__, Info->UnitName);
>    if (WhichTool == ESAN_CacheFrag) {
>      processCacheFragCompilationUnitExit(Ptr);
>    }
> Index: lib/esan/cache_frag.cpp
> ===================================================================
> --- lib/esan/cache_frag.cpp
> +++ lib/esan/cache_frag.cpp
> @@ -16,14 +16,22 @@
>
>  namespace __esan {
>
> +// This should be kept consistent with LLVM's EfficiencySanitizer
> CacheFragInfo.
> +// The tool-specific information per compilation unit (module).
> +struct CacheFragInfo {
> +  const char *UnitName;
> +};
> +
>  //===-- Init/exit functions
> -----------------------------------------------===//
>
>  void processCacheFragCompilationUnitInit(void *Ptr) {
> -  VPrintf(2, "in esan::%s\n", __FUNCTION__);
> +  CacheFragInfo *CFI = (CacheFragInfo *)Ptr;
> +  VPrintf(2, "in esan::%s: %s\n", __FUNCTION__, CFI->UnitName);
>  }
>
>  void processCacheFragCompilationUnitExit(void *Ptr) {
> -  VPrintf(2, "in esan::%s\n", __FUNCTION__);
> +  CacheFragInfo *CFI = (CacheFragInfo *)Ptr;
> +  VPrintf(2, "in esan::%s: %s\n", __FUNCTION__, CFI->UnitName);
>  }
>
>  void initializeCacheFrag() {
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160527/ecdff736/attachment.html>


More information about the llvm-commits mailing list