mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-24 22:24:54 +00:00
MSan: Use createSanitizerCtor
to create ctor, and call __msan_init
Reviewers: kcc, eugenis Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D8781 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@236779 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -191,6 +191,9 @@ static cl::opt<bool> ClCheckConstantShadow("msan-check-constant-shadow",
|
||||
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 @@ class MemorySanitizer : public FunctionPass {
|
||||
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,12 @@ bool MemorySanitizer::doInitialization(Module &M) {
|
||||
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);
|
||||
std::tie(MsanCtorFunction, std::ignore) =
|
||||
createSanitizerCtorAndInitFunctions(M, kMsanModuleCtorName, kMsanInitName,
|
||||
/*InitArgTypes=*/{},
|
||||
/*InitArgs=*/{});
|
||||
|
||||
appendToGlobalCtors(M, MsanCtorFunction, 0);
|
||||
|
||||
if (TrackOrigins)
|
||||
new GlobalVariable(M, IRB.getInt32Ty(), true, GlobalValue::WeakODRLinkage,
|
||||
@@ -2983,6 +2990,8 @@ VarArgHelper *CreateVarArgHelper(Function &Func, MemorySanitizer &Msan,
|
||||
} // namespace
|
||||
|
||||
bool MemorySanitizer::runOnFunction(Function &F) {
|
||||
if (&F == MsanCtorFunction)
|
||||
return false;
|
||||
MemorySanitizerVisitor Visitor(F, *this);
|
||||
|
||||
// Clear out readonly/readnone attributes.
|
||||
|
Reference in New Issue
Block a user