[PATCH] MSan: Use `createSanitizerCtor` to create ctor, and call `__msan_init`
Ismail Pazarbasi
ismail.pazarbasi at gmail.com
Wed Apr 1 09:55:27 PDT 2015
Hi kcc, eugenis,
http://reviews.llvm.org/D8781
Files:
lib/Transforms/Instrumentation/MemorySanitizer.cpp
Index: lib/Transforms/Instrumentation/MemorySanitizer.cpp
===================================================================
--- lib/Transforms/Instrumentation/MemorySanitizer.cpp
+++ lib/Transforms/Instrumentation/MemorySanitizer.cpp
@@ -191,6 +191,9 @@
cl::desc("Insert checks for constant shadow values"),
cl::Hidden, cl::init(false));
+static const char *const kMsanModuleCtorName = "msan.module_ctor";
+static const char *const kMsanInitName = "__msan_init";
+
namespace {
// Memory map parameters used in application-to-shadow address calculation.
@@ -332,6 +335,7 @@
MDNode *OriginStoreWeights;
/// \brief An empty volatile inline asm that prevents callback merge.
InlineAsm *EmptyAsm;
+ Function *MsanCtorFunction;
friend struct MemorySanitizerVisitor;
friend struct VarArgAMD64Helper;
@@ -491,9 +495,9 @@
ColdCallWeights = MDBuilder(*C).createBranchWeights(1, 1000);
OriginStoreWeights = MDBuilder(*C).createBranchWeights(1, 1000);
- // Insert a call to __msan_init/__msan_track_origins into the module's CTORs.
- appendToGlobalCtors(M, cast<Function>(M.getOrInsertFunction(
- "__msan_init", IRB.getVoidTy(), nullptr)), 0);
+ MsanCtorFunction = createSanitizerCtor(M, kMsanModuleCtorName, kMsanInitName);
+
+ appendToGlobalCtors(M, MsanCtorFunction, 0);
if (TrackOrigins)
new GlobalVariable(M, IRB.getInt32Ty(), true, GlobalValue::WeakODRLinkage,
@@ -2981,6 +2985,8 @@
} // namespace
bool MemorySanitizer::runOnFunction(Function &F) {
+ if (&F == MsanCtorFunction)
+ return false;
MemorySanitizerVisitor Visitor(F, *this);
// Clear out readonly/readnone attributes.
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D8781.23073.patch
Type: text/x-patch
Size: 1676 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150401/a17e6ca0/attachment.bin>
More information about the llvm-commits
mailing list