mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-18 13:34:04 +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:
parent
2bdae13eff
commit
db5cc208f2
@ -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.
|
||||
|
@ -4,8 +4,7 @@
|
||||
target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
|
||||
target triple = "x86_64-unknown-linux-gnu"
|
||||
|
||||
; Check the presence of __msan_init
|
||||
; CHECK: @llvm.global_ctors {{.*}} @__msan_init
|
||||
; CHECK: @llvm.global_ctors {{.*}} @msan.module_ctor
|
||||
|
||||
; Check the presence and the linkage type of __msan_track_origins and
|
||||
; other interface symbols.
|
||||
@ -878,3 +877,6 @@ define void @MismatchedReturnTypeTailCall(i32 %a) sanitize_memory {
|
||||
; CHECK-LABEL: define void @MismatchedReturnTypeTailCall
|
||||
; CHECK: tail call i32 @InnerTailCall
|
||||
; CHECK: ret void
|
||||
|
||||
; CHECK: define internal void @msan.module_ctor
|
||||
; CHECK: call void @__msan_init()
|
||||
|
Loading…
x
Reference in New Issue
Block a user