[PATCH] D20973: [esan] Specify which tool via a global variable

Derek Bruening via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 3 12:47:14 PDT 2016


This revision was automatically updated to reflect the committed changes.
Closed by commit rL271715: [esan] Specify which tool via a global variable (authored by bruening).

Changed prior to commit:
  http://reviews.llvm.org/D20973?vs=59584&id=59604#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D20973

Files:
  llvm/trunk/lib/Transforms/Instrumentation/EfficiencySanitizer.cpp

Index: llvm/trunk/lib/Transforms/Instrumentation/EfficiencySanitizer.cpp
===================================================================
--- llvm/trunk/lib/Transforms/Instrumentation/EfficiencySanitizer.cpp
+++ llvm/trunk/lib/Transforms/Instrumentation/EfficiencySanitizer.cpp
@@ -72,6 +72,10 @@
 static const char *const EsanInitName = "__esan_init";
 static const char *const EsanExitName = "__esan_exit";
 
+// We need to specify the tool to the runtime earlier than
+// the ctor is called in some cases, so we set a global variable.
+static const char *const EsanWhichToolName = "__esan_which_tool";
+
 // We must keep these Shadow* constants consistent with the esan runtime.
 // FIXME: Try to place these shadow constants, the names of the __esan_*
 // interface functions, and the ToolType enum into a header shared between
@@ -430,14 +434,23 @@
   // Create the variable passed to EsanInit and EsanExit.
   Constant *ToolInfoArg = createEsanInitToolInfoArg(M);
   // Constructor
+  // We specify the tool type both in the EsanWhichToolName global
+  // and as an arg to the init routine as a sanity check.
   std::tie(EsanCtorFunction, std::ignore) = createSanitizerCtorAndInitFunctions(
       M, EsanModuleCtorName, EsanInitName, /*InitArgTypes=*/{OrdTy, Int8PtrTy},
       /*InitArgs=*/{
         ConstantInt::get(OrdTy, static_cast<int>(Options.ToolType)),
         ToolInfoArg});
   appendToGlobalCtors(M, EsanCtorFunction, EsanCtorAndDtorPriority);
 
   createDestructor(M, ToolInfoArg);
+
+  new GlobalVariable(M, OrdTy, true,
+                     GlobalValue::WeakAnyLinkage,
+                     ConstantInt::get(OrdTy,
+                                      static_cast<int>(Options.ToolType)),
+                     EsanWhichToolName);
+
   return true;
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D20973.59604.patch
Type: text/x-patch
Size: 1784 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160603/5c9674a4/attachment.bin>


More information about the llvm-commits mailing list