llvm.org GIT mirror llvm / 4956e30
[NewPM] Port Msan Summary: Keeping msan a function pass requires replacing the module level initialization: That means, don't define a ctor function which calls __msan_init, instead just declare the init function at the first access, and add that to the global ctors list. Changes: - Pull the actual sanitizer and the wrapper pass apart. - Add a newpm msan pass. The function pass inserts calls to runtime library functions, for which it inserts declarations as necessary. - Update tests. Caveats: - There is one test that I dropped, because it specifically tested the definition of the ctor. Reviewers: chandlerc, fedor.sergeev, leonardchan, vitalybuka Subscribers: sdardis, nemanjai, javed.absar, hiraditya, kbarton, bollu, atanasyan, jsji Differential Revision: https://reviews.llvm.org/D55647 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@350305 91177308-0d34-0410-b5e6-96231b3b80d8 Philip Pfaffe 6 months ago
54 changed file(s) with 353 addition(s) and 134 deletion(s). Raw diff Collapse all Expand all
1515 #include "llvm/IR/LegacyPassManager.h"
1616 #include "llvm/IR/Module.h"
1717 #include "llvm/Transforms/Instrumentation.h"
18 #include "llvm/Transforms/Instrumentation/MemorySanitizer.h"
1819
1920 using namespace llvm;
2021
3031 unwrap(PM)->add(createThreadSanitizerPass());
3132 }
3233
33 void LLVMAddMemorySanitizerPass(LLVMPassManagerRef PM) {
34 unwrap(PM)->add(createMemorySanitizerPass());
34 void LLVMAddMemorySanitizerLegacyPassPass(LLVMPassManagerRef PM) {
35 unwrap(PM)->add(createMemorySanitizerLegacyPassPass());
3536 }
3637
3738 void LLVMAddDataFlowSanitizerPass(LLVMPassManagerRef PM,
2626 void LLVMAddAddressSanitizerFunctionPass(LLVMPassManagerRef PM);
2727 void LLVMAddAddressSanitizerModulePass(LLVMPassManagerRef PM);
2828 void LLVMAddThreadSanitizerPass(LLVMPassManagerRef PM);
29 void LLVMAddMemorySanitizerPass(LLVMPassManagerRef PM);
29 void LLVMAddMemorySanitizerLegacyPassPass(LLVMPassManagerRef PM);
3030 void LLVMAddDataFlowSanitizerPass(LLVMPassManagerRef PM, int ABIListFilesNum,
3131 const char **ABIListFiles);
3232
3131 C.LLVMAddThreadSanitizerPass(pm.C)
3232 }
3333
34 func (pm PassManager) AddMemorySanitizerPass() {
35 C.LLVMAddMemorySanitizerPass(pm.C)
34 func (pm PassManager) AddMemorySanitizerLegacyPassPass() {
35 C.LLVMAddMemorySanitizerLegacyPassPass(pm.C)
3636 }
3737
3838 func (pm PassManager) AddDataFlowSanitizerPass(abilist []string) {
272272 void initializeMemoryDependenceWrapperPassPass(PassRegistry&);
273273 void initializeMemorySSAPrinterLegacyPassPass(PassRegistry&);
274274 void initializeMemorySSAWrapperPassPass(PassRegistry&);
275 void initializeMemorySanitizerPass(PassRegistry&);
275 void initializeMemorySanitizerLegacyPassPass(PassRegistry&);
276276 void initializeMergeFunctionsPass(PassRegistry&);
277277 void initializeMergeICmpsPass(PassRegistry&);
278278 void initializeMergedLoadStoreMotionLegacyPassPass(PassRegistry&);
0 //===- Transforms/Instrumentation/MemorySanitizer.h - MSan Pass -----------===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file defines the memoy sanitizer pass.
10 //
11 //===----------------------------------------------------------------------===//
12
13 #ifndef LLVM_TRANSFORMS_INSTRUMENTATION_MEMORYSANITIZER_H
14 #define LLVM_TRANSFORMS_INSTRUMENTATION_MEMORYSANITIZER_H
15
16 #include "llvm/IR/PassManager.h"
17 #include "llvm/Pass.h"
18
19 namespace llvm {
20
21 // Insert MemorySanitizer instrumentation (detection of uninitialized reads)
22 FunctionPass *createMemorySanitizerLegacyPassPass(int TrackOrigins = 0,
23 bool Recover = false,
24 bool EnableKmsan = false);
25
26 /// A function pass for msan instrumentation.
27 ///
28 /// Instruments functions to detect unitialized reads. This function pass
29 /// inserts calls to runtime library functions. If the functions aren't declared
30 /// yet, the pass inserts the declarations. Otherwise the existing globals are
31 /// used.
32 struct MemorySanitizerPass : public PassInfoMixin {
33 MemorySanitizerPass(int TrackOrigins = 0, bool Recover = false,
34 bool EnableKmsan = false)
35 : TrackOrigins(TrackOrigins), Recover(Recover), EnableKmsan(EnableKmsan) {
36 }
37
38 PreservedAnalyses run(Function &F, FunctionAnalysisManager &FAM);
39
40 private:
41 int TrackOrigins;
42 bool Recover;
43 bool EnableKmsan;
44 };
45 }
46
47 #endif /* LLVM_TRANSFORMS_INSTRUMENTATION_MEMORYSANITIZER_H */
150150 bool Recover = false,
151151 bool UseGlobalsGC = true,
152152 bool UseOdrIndicator = true);
153
154 // Insert MemorySanitizer instrumentation (detection of uninitialized reads)
155 FunctionPass *createMemorySanitizerPass(int TrackOrigins = 0,
156 bool Recover = false,
157 bool EnableKmsan = false);
158153
159154 FunctionPass *createHWAddressSanitizerPass(bool CompileKernel = false,
160155 bool Recover = false);
229224 assert(Scaled <= std::numeric_limits::max() && "overflow 32-bits");
230225 return Scaled;
231226 }
232
233227 } // end namespace llvm
234228
235229 #endif // LLVM_TRANSFORMS_INSTRUMENTATION_H
5757 ArrayRef InitArgTypes, ArrayRef InitArgs,
5858 StringRef VersionCheckName = StringRef());
5959
60 // Creates and returns a sanitizer init function without argument if it doesn't
61 // exist, and adds it to the global constructors list. Otherwise it returns the
62 // existing function.
63 Function *getOrCreateInitFunction(Module &M, StringRef Name);
64
6065 /// Rename all the anon globals in the module using a hash computed from
6166 /// the list of public globals in the module.
6267 bool nameUnamedGlobals(Module &M);
8787 #include "llvm/Transforms/IPO/SyntheticCountsPropagation.h"
8888 #include "llvm/Transforms/IPO/WholeProgramDevirt.h"
8989 #include "llvm/Transforms/InstCombine/InstCombine.h"
90 #include "llvm/Transforms/Instrumentation.h"
9091 #include "llvm/Transforms/Instrumentation/BoundsChecking.h"
9192 #include "llvm/Transforms/Instrumentation/CGProfile.h"
9293 #include "llvm/Transforms/Instrumentation/ControlHeightReduction.h"
9394 #include "llvm/Transforms/Instrumentation/GCOVProfiler.h"
9495 #include "llvm/Transforms/Instrumentation/InstrProfiling.h"
96 #include "llvm/Transforms/Instrumentation/MemorySanitizer.h"
9597 #include "llvm/Transforms/Instrumentation/PGOInstrumentation.h"
9698 #include "llvm/Transforms/Scalar/ADCE.h"
9799 #include "llvm/Transforms/Scalar/AlignmentFromAssumptions.h"
230230 FUNCTION_PASS("view-cfg", CFGViewerPass())
231231 FUNCTION_PASS("view-cfg-only", CFGOnlyViewerPass())
232232 FUNCTION_PASS("transform-warning", WarnMissedTransformationsPass())
233 FUNCTION_PASS("msan", MemorySanitizerPass())
233234 #undef FUNCTION_PASS
234235
235236 #ifndef LOOP_ANALYSIS
110110 initializePGOIndirectCallPromotionLegacyPassPass(Registry);
111111 initializePGOMemOPSizeOptLegacyPassPass(Registry);
112112 initializeInstrProfilingLegacyPassPass(Registry);
113 initializeMemorySanitizerPass(Registry);
113 initializeMemorySanitizerLegacyPassPass(Registry);
114114 initializeHWAddressSanitizerPass(Registry);
115115 initializeThreadSanitizerPass(Registry);
116116 initializeSanitizerCoverageModulePass(Registry);
139139 ///
140140 //===----------------------------------------------------------------------===//
141141
142 #include "llvm/Transforms/Instrumentation/MemorySanitizer.h"
142143 #include "llvm/ADT/APInt.h"
143144 #include "llvm/ADT/ArrayRef.h"
144145 #include "llvm/ADT/DepthFirstIterator.h"
148149 #include "llvm/ADT/StringRef.h"
149150 #include "llvm/ADT/Triple.h"
150151 #include "llvm/Analysis/TargetLibraryInfo.h"
151 #include "llvm/Transforms/Utils/Local.h"
152152 #include "llvm/IR/Argument.h"
153153 #include "llvm/IR/Attributes.h"
154154 #include "llvm/IR/BasicBlock.h"
186186 #include "llvm/Support/raw_ostream.h"
187187 #include "llvm/Transforms/Instrumentation.h"
188188 #include "llvm/Transforms/Utils/BasicBlockUtils.h"
189 #include "llvm/Transforms/Utils/Local.h"
189190 #include "llvm/Transforms/Utils/ModuleUtils.h"
190191 #include
191192 #include
319320 cl::desc("Define custom MSan OriginBase"),
320321 cl::Hidden, cl::init(0));
321322
322 static const char *const kMsanModuleCtorName = "msan.module_ctor";
323323 static const char *const kMsanInitName = "__msan_init";
324324
325325 namespace {
445445
446446 namespace {
447447
448 /// An instrumentation pass implementing detection of uninitialized
449 /// reads.
448 /// Instrument functions of a module to detect uninitialized reads.
450449 ///
451 /// MemorySanitizer: instrument the code in module to find
452 /// uninitialized reads.
453 class MemorySanitizer : public FunctionPass {
450 /// Instantiating MemorySanitizer inserts the msan runtime library API function
451 /// declarations into the module if they don't exist already. Instantiating
452 /// ensures the __msan_init function is in the list of global constructors for
453 /// the module.
454 class MemorySanitizer {
454455 public:
455 // Pass identification, replacement for typeid.
456 static char ID;
457
458 MemorySanitizer(int TrackOrigins = 0, bool Recover = false,
459 bool EnableKmsan = false)
460 : FunctionPass(ID) {
456 MemorySanitizer(Module &M, int TrackOrigins = 0, bool Recover = false,
457 bool EnableKmsan = false) {
461458 this->CompileKernel =
462459 ClEnableKmsan.getNumOccurrences() > 0 ? ClEnableKmsan : EnableKmsan;
463460 if (ClTrackOrigins.getNumOccurrences() > 0)
467464 this->Recover = ClKeepGoing.getNumOccurrences() > 0
468465 ? ClKeepGoing
469466 : (this->CompileKernel | Recover);
470 }
471 StringRef getPassName() const override { return "MemorySanitizer"; }
472
473 void getAnalysisUsage(AnalysisUsage &AU) const override {
474 AU.addRequired();
475 }
476
477 bool runOnFunction(Function &F) override;
478 bool doInitialization(Module &M) override;
467 initializeModule(M);
468 }
469
470 // MSan cannot be moved or copied because of MapParams.
471 MemorySanitizer(MemorySanitizer &&) = delete;
472 MemorySanitizer &operator=(MemorySanitizer &&) = delete;
473 MemorySanitizer(const MemorySanitizer &) = delete;
474 MemorySanitizer &operator=(const MemorySanitizer &) = delete;
475
476 bool sanitizeFunction(Function &F, TargetLibraryInfo &TLI);
479477
480478 private:
481479 friend struct MemorySanitizerVisitor;
484482 friend struct VarArgAArch64Helper;
485483 friend struct VarArgPowerPC64Helper;
486484
485 void initializeModule(Module &M);
487486 void initializeCallbacks(Module &M);
488487 void createKernelApi(Module &M);
489488 void createUserspaceApi(Module &M);
490489
491490 /// True if we're compiling the Linux kernel.
492491 bool CompileKernel;
493
494492 /// Track origins (allocation points) of uninitialized values.
495493 int TrackOrigins;
496494 bool Recover;
587585
588586 /// An empty volatile inline asm that prevents callback merge.
589587 InlineAsm *EmptyAsm;
590
591 Function *MsanCtorFunction;
592588 };
593589
590 /// A legacy function pass for msan instrumentation.
591 ///
592 /// Instruments functions to detect unitialized reads.
593 struct MemorySanitizerLegacyPass : public FunctionPass {
594 // Pass identification, replacement for typeid.
595 static char ID;
596
597 MemorySanitizerLegacyPass(int TrackOrigins = 0, bool Recover = false,
598 bool EnableKmsan = false)
599 : FunctionPass(ID), TrackOrigins(TrackOrigins), Recover(Recover),
600 EnableKmsan(EnableKmsan) {}
601 StringRef getPassName() const override { return "MemorySanitizerLegacyPass"; }
602
603 void getAnalysisUsage(AnalysisUsage &AU) const override {
604 AU.addRequired();
605 }
606
607 bool runOnFunction(Function &F) override {
608 return MSan->sanitizeFunction(
609 F, getAnalysis().getTLI());
610 }
611 bool doInitialization(Module &M) override;
612
613 Optional MSan;
614 int TrackOrigins;
615 bool Recover;
616 bool EnableKmsan;
617 };
618
594619 } // end anonymous namespace
595620
596 char MemorySanitizer::ID = 0;
597
598 INITIALIZE_PASS_BEGIN(
599 MemorySanitizer, "msan",
600 "MemorySanitizer: detects uninitialized reads.", false, false)
621 PreservedAnalyses MemorySanitizerPass::run(Function &F,
622 FunctionAnalysisManager &FAM) {
623 MemorySanitizer Msan(*F.getParent(), TrackOrigins, Recover, EnableKmsan);
624 if (Msan.sanitizeFunction(F, FAM.getResult(F)))
625 return PreservedAnalyses::none();
626 return PreservedAnalyses::all();
627 }
628
629 char MemorySanitizerLegacyPass::ID = 0;
630
631 INITIALIZE_PASS_BEGIN(MemorySanitizerLegacyPass, "msan",
632 "MemorySanitizer: detects uninitialized reads.", false,
633 false)
601634 INITIALIZE_PASS_DEPENDENCY(TargetLibraryInfoWrapperPass)
602 INITIALIZE_PASS_END(
603 MemorySanitizer, "msan",
604 "MemorySanitizer: detects uninitialized reads.", false, false)
605
606 FunctionPass *llvm::createMemorySanitizerPass(int TrackOrigins, bool Recover,
607 bool CompileKernel) {
608 return new MemorySanitizer(TrackOrigins, Recover, CompileKernel);
635 INITIALIZE_PASS_END(MemorySanitizerLegacyPass, "msan",
636 "MemorySanitizer: detects uninitialized reads.", false,
637 false)
638
639 FunctionPass *llvm::createMemorySanitizerLegacyPassPass(int TrackOrigins,
640 bool Recover,
641 bool CompileKernel) {
642 return new MemorySanitizerLegacyPass(TrackOrigins, Recover, CompileKernel);
609643 }
610644
611645 /// Create a non-const global initialized with the given string.
682716 "__msan_unpoison_alloca", IRB.getVoidTy(), IRB.getInt8PtrTy(), IntptrTy);
683717 }
684718
719 static Constant *getOrInsertGlobal(Module &M, StringRef Name, Type *Ty) {
720 return M.getOrInsertGlobal(Name, Ty, [&] {
721 return new GlobalVariable(M, Ty, false, GlobalVariable::ExternalLinkage,
722 nullptr, Name, nullptr,
723 GlobalVariable::InitialExecTLSModel);
724 });
725 }
726
685727 /// Insert declarations for userspace-specific functions and globals.
686728 void MemorySanitizer::createUserspaceApi(Module &M) {
687729 IRBuilder<> IRB(*C);
693735 WarningFn = M.getOrInsertFunction(WarningFnName, IRB.getVoidTy());
694736
695737 // Create the global TLS variables.
696 RetvalTLS = new GlobalVariable(
697 M, ArrayType::get(IRB.getInt64Ty(), kRetvalTLSSize / 8), false,
698 GlobalVariable::ExternalLinkage, nullptr, "__msan_retval_tls", nullptr,
699 GlobalVariable::InitialExecTLSModel);
700
701 RetvalOriginTLS = new GlobalVariable(
702 M, OriginTy, false, GlobalVariable::ExternalLinkage, nullptr,
703 "__msan_retval_origin_tls", nullptr, GlobalVariable::InitialExecTLSModel);
704
705 ParamTLS = new GlobalVariable(
706 M, ArrayType::get(IRB.getInt64Ty(), kParamTLSSize / 8), false,
707 GlobalVariable::ExternalLinkage, nullptr, "__msan_param_tls", nullptr,
708 GlobalVariable::InitialExecTLSModel);
709
710 ParamOriginTLS = new GlobalVariable(
711 M, ArrayType::get(OriginTy, kParamTLSSize / 4), false,
712 GlobalVariable::ExternalLinkage, nullptr, "__msan_param_origin_tls",
713 nullptr, GlobalVariable::InitialExecTLSModel);
714
715 VAArgTLS = new GlobalVariable(
716 M, ArrayType::get(IRB.getInt64Ty(), kParamTLSSize / 8), false,
717 GlobalVariable::ExternalLinkage, nullptr, "__msan_va_arg_tls", nullptr,
718 GlobalVariable::InitialExecTLSModel);
719
720 VAArgOriginTLS = new GlobalVariable(
721 M, ArrayType::get(OriginTy, kParamTLSSize / 4), false,
722 GlobalVariable::ExternalLinkage, nullptr, "__msan_va_arg_origin_tls",
723 nullptr, GlobalVariable::InitialExecTLSModel);
724
725 VAArgOverflowSizeTLS = new GlobalVariable(
726 M, IRB.getInt64Ty(), false, GlobalVariable::ExternalLinkage, nullptr,
727 "__msan_va_arg_overflow_size_tls", nullptr,
728 GlobalVariable::InitialExecTLSModel);
729 OriginTLS = new GlobalVariable(
730 M, IRB.getInt32Ty(), false, GlobalVariable::ExternalLinkage, nullptr,
731 "__msan_origin_tls", nullptr, GlobalVariable::InitialExecTLSModel);
738 RetvalTLS =
739 getOrInsertGlobal(M, "__msan_retval_tls",
740 ArrayType::get(IRB.getInt64Ty(), kRetvalTLSSize / 8));
741
742 RetvalOriginTLS = getOrInsertGlobal(M, "__msan_retval_origin_tls", OriginTy);
743
744 ParamTLS =
745 getOrInsertGlobal(M, "__msan_param_tls",
746 ArrayType::get(IRB.getInt64Ty(), kParamTLSSize / 8));
747
748 ParamOriginTLS =
749 getOrInsertGlobal(M, "__msan_param_origin_tls",
750 ArrayType::get(OriginTy, kParamTLSSize / 4));
751
752 VAArgTLS =
753 getOrInsertGlobal(M, "__msan_va_arg_tls",
754 ArrayType::get(IRB.getInt64Ty(), kParamTLSSize / 8));
755
756 VAArgOriginTLS =
757 getOrInsertGlobal(M, "__msan_va_arg_origin_tls",
758 ArrayType::get(OriginTy, kParamTLSSize / 4));
759
760 VAArgOverflowSizeTLS =
761 getOrInsertGlobal(M, "__msan_va_arg_overflow_size_tls", IRB.getInt64Ty());
762 OriginTLS = getOrInsertGlobal(M, "__msan_origin_tls", IRB.getInt32Ty());
732763
733764 for (size_t AccessSizeIndex = 0; AccessSizeIndex < kNumberOfAccessSizes;
734765 AccessSizeIndex++) {
807838 }
808839
809840 /// Module-level initialization.
810 ///
811 /// inserts a call to __msan_init to the module's constructor list.
812 bool MemorySanitizer::doInitialization(Module &M) {
841 void MemorySanitizer::initializeModule(Module &M) {
813842 auto &DL = M.getDataLayout();
814843
815844 bool ShadowPassed = ClShadowBase.getNumOccurrences() > 0;
883912 OriginStoreWeights = MDBuilder(*C).createBranchWeights(1, 1000);
884913
885914 if (!CompileKernel) {
886 std::tie(MsanCtorFunction, std::ignore) =
887 createSanitizerCtorAndInitFunctions(M, kMsanModuleCtorName,
888 kMsanInitName,
889 /*InitArgTypes=*/{},
890 /*InitArgs=*/{});
891 if (ClWithComdat) {
892 Comdat *MsanCtorComdat = M.getOrInsertComdat(kMsanModuleCtorName);
893 MsanCtorFunction->setComdat(MsanCtorComdat);
894 appendToGlobalCtors(M, MsanCtorFunction, 0, MsanCtorFunction);
895 } else {
896 appendToGlobalCtors(M, MsanCtorFunction, 0);
897 }
915 getOrCreateInitFunction(M, kMsanInitName);
898916
899917 if (TrackOrigins)
900 new GlobalVariable(M, IRB.getInt32Ty(), true, GlobalValue::WeakODRLinkage,
901 IRB.getInt32(TrackOrigins), "__msan_track_origins");
918 M.getOrInsertGlobal("__msan_track_origins", IRB.getInt32Ty(), [&] {
919 return new GlobalVariable(
920 M, IRB.getInt32Ty(), true, GlobalValue::WeakODRLinkage,
921 IRB.getInt32(TrackOrigins), "__msan_track_origins");
922 });
902923
903924 if (Recover)
904 new GlobalVariable(M, IRB.getInt32Ty(), true, GlobalValue::WeakODRLinkage,
905 IRB.getInt32(Recover), "__msan_keep_going");
906 }
925 M.getOrInsertGlobal("__msan_keep_going", IRB.getInt32Ty(), [&] {
926 return new GlobalVariable(M, IRB.getInt32Ty(), true,
927 GlobalValue::WeakODRLinkage,
928 IRB.getInt32(Recover), "__msan_keep_going");
929 });
930 }
931 }
932
933 bool MemorySanitizerLegacyPass::doInitialization(Module &M) {
934 MSan.emplace(M, TrackOrigins, Recover, EnableKmsan);
907935 return true;
908936 }
909937
9841012 SmallVector InstrumentationList;
9851013 SmallVector StoreList;
9861014
987 MemorySanitizerVisitor(Function &F, MemorySanitizer &MS)
988 : F(F), MS(MS), VAHelper(CreateVarArgHelper(F, MS, *this)) {
1015 MemorySanitizerVisitor(Function &F, MemorySanitizer &MS,
1016 const TargetLibraryInfo &TLI)
1017 : F(F), MS(MS), VAHelper(CreateVarArgHelper(F, MS, *this)), TLI(&TLI) {
9891018 bool SanitizeFunction = F.hasFnAttribute(Attribute::SanitizeMemory);
9901019 InsertChecks = SanitizeFunction;
9911020 PropagateShadow = SanitizeFunction;
9941023 // FIXME: Consider using SpecialCaseList to specify a list of functions that
9951024 // must always return fully initialized values. For now, we hardcode "main".
9961025 CheckReturnValue = SanitizeFunction && (F.getName() == "main");
997 TLI = &MS.getAnalysis().getTLI();
9981026
9991027 MS.initializeCallbacks(*F.getParent());
10001028 if (MS.CompileKernel)
44294457 return new VarArgNoOpHelper(Func, Msan, Visitor);
44304458 }
44314459
4432 bool MemorySanitizer::runOnFunction(Function &F) {
4433 if (!CompileKernel && (&F == MsanCtorFunction))
4434 return false;
4435 MemorySanitizerVisitor Visitor(F, *this);
4460 bool MemorySanitizer::sanitizeFunction(Function &F, TargetLibraryInfo &TLI) {
4461 MemorySanitizerVisitor Visitor(F, *this, TLI);
44364462
44374463 // Clear out readonly/readnone attributes.
44384464 AttrBuilder B;
173173 return std::make_pair(Ctor, InitFunction);
174174 }
175175
176 Function *llvm::getOrCreateInitFunction(Module &M, StringRef Name) {
177 assert(!Name.empty() && "Expected init function name");
178 if (Function *F = M.getFunction(Name)) {
179 if (F->arg_size() != 0 ||
180 F->getReturnType() != Type::getVoidTy(M.getContext())) {
181 std::string Err;
182 raw_string_ostream Stream(Err);
183 Stream << "Sanitizer interface function defined with wrong type: " << *F;
184 report_fatal_error(Err);
185 }
186 return F;
187 }
188 Function *F = checkSanitizerInterfaceFunction(M.getOrInsertFunction(
189 Name, AttributeList(), Type::getVoidTy(M.getContext())));
190 F->setLinkage(Function::ExternalLinkage);
191
192 appendToGlobalCtors(M, F, 0);
193
194 return F;
195 }
196
176197 void llvm::filterDeadComdatFunctions(
177198 Module &M, SmallVectorImpl &DeadComdatFunctions) {
178199 // Build a map from the comdat to the number of entries in that comdat we
0 ; RUN: opt < %s -S -passes=msan 2>&1 | FileCheck %s
1 ; RUN: opt < %s -msan -S | FileCheck %s
12
23 target datalayout = "e-m:e-i64:64-i128:128-n32:64-S128"
0 ; RUN: opt < %s -S -passes=msan 2>&1 | FileCheck %s
1 ; RUN: opt < %s -msan -S | FileCheck %s
12
23 target datalayout = "E-m:m-i8:8:32-i16:16:32-i64:64-n32:64-S128"
0 ; RUN: opt < %s -S -passes=msan 2>&1 | FileCheck %s
1 ; RUN: opt < %s -msan -S | FileCheck %s
12
23 target datalayout = "e-m:m-i8:8:32-i16:16:32-i64:64-n32:64-S128"
0 ; RUN: opt < %s -S -passes=msan 2>&1 | FileCheck %s
1 ; RUN: opt < %s -msan -S | FileCheck %s
12
23 target datalayout = "E-m:e-i64:64-n32:64"
0 ; RUN: opt < %s -S -passes=msan 2>&1 | FileCheck %s
1 ; RUN: opt < %s -msan -S | FileCheck %s
12
23 target datalayout = "e-m:e-i64:64-n32:64"
0 ; RUN: opt < %s -msan-check-access-address=0 -S 2>&1 -passes=msan | FileCheck \
1 ; RUN: %s
2 ; RUN: opt < %s -msan -msan-check-access-address=0 -S 2>&1 | FileCheck %s
13
24 ; Test that MSan doesn't generate code overflowing __msan_va_arg_tls when too many arguments are
0 ; RUN: opt < %s -msan-check-access-address=0 -S -passes=msan 2>&1
1 ; RUN: opt < %s -msan -msan-check-access-address=0 -S
12 ; Test that code using va_start can be compiled on i386.
23
0 ; RUN: opt < %s -msan-check-access-address=0 -S -passes=msan 2>&1 | FileCheck \
1 ; RUN: %s
2 ; RUN: opt < %s -msan -msan-check-access-address=0 -S | FileCheck %s
3 ; RUN: opt < %s -msan-check-access-address=0 -msan-track-origins=1 -S \
4 ; RUN: -passes=msan 2>&1 | FileCheck %s "--check-prefixes=CHECK,CHECK-ORIGIN"
15 ; RUN: opt < %s -msan -msan-check-access-address=0 -msan-track-origins=1 -S | FileCheck %s --check-prefixes=CHECK,CHECK-ORIGIN
6 ; RUN: opt < %s -msan-check-access-address=0 -msan-track-origins=2 -S \
7 ; RUN: -passes=msan 2>&1 | FileCheck %s "--check-prefixes=CHECK,CHECK-ORIGIN"
28 ; RUN: opt < %s -msan -msan-check-access-address=0 -msan-track-origins=2 -S | FileCheck %s --check-prefixes=CHECK,CHECK-ORIGIN
39
410 ; Test that shadow and origin are stored for variadic function params.
0 ; RUN: opt < %s -msan-check-access-address=0 -S -passes=msan 2>&1 | FileCheck \
1 ; RUN: %s "--check-prefixes=CHECK,INLINE"
2 ; RUN: opt < %s -msan -msan-check-access-address=0 -S | FileCheck %s --check-prefixes=CHECK,INLINE
3 ; RUN: opt < %s -msan-check-access-address=0 -msan-poison-stack-with-call=1 -S \
4 ; RUN: -passes=msan 2>&1 | FileCheck %s "--check-prefixes=CHECK,CALL"
15 ; RUN: opt < %s -msan -msan-check-access-address=0 -msan-poison-stack-with-call=1 -S | FileCheck %s --check-prefixes=CHECK,CALL
6 ; RUN: opt < %s -msan-check-access-address=0 -msan-track-origins=1 -S \
7 ; RUN: -passes=msan 2>&1 | FileCheck %s "--check-prefixes=CHECK,ORIGIN"
28 ; RUN: opt < %s -msan -msan-check-access-address=0 -msan-track-origins=1 -S | FileCheck %s --check-prefixes=CHECK,ORIGIN
9 ; RUN: opt < %s -msan-check-access-address=0 -msan-track-origins=2 -S \
10 ; RUN: -passes=msan 2>&1 | FileCheck %s "--check-prefixes=CHECK,ORIGIN"
311 ; RUN: opt < %s -msan -msan-check-access-address=0 -msan-track-origins=2 -S | FileCheck %s --check-prefixes=CHECK,ORIGIN
12 ; RUN: opt < %s -msan-kernel=1 -S -passes=msan 2>&1 | FileCheck %s \
13 ; RUN: "--check-prefixes=CHECK,KMSAN"
414 ; RUN: opt < %s -msan -msan-kernel=1 -S | FileCheck %s --check-prefixes=CHECK,KMSAN
515
616 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"
0 ; RUN: opt < %s -msan-check-access-address=0 -S -passes=msan 2>&1 | FileCheck \
1 ; RUN: %s
2 ; RUN: opt < %s -msan -msan-check-access-address=0 -S | FileCheck %s
3 ; RUN: opt < %s -msan-check-access-address=0 -msan-track-origins=1 -S \
4 ; RUN: -passes=msan 2>&1 | FileCheck -check-prefix=CHECK \
5 ; RUN: -check-prefix=CHECK-ORIGINS %s --allow-empty
16 ; RUN: opt < %s -msan -msan-check-access-address=0 -msan-track-origins=1 -S | FileCheck -check-prefix=CHECK -check-prefix=CHECK-ORIGINS %s
27
38 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"
0 ; RUN: opt < %s -msan-check-access-address=0 -S -passes=msan 2>&1 | FileCheck \
1 ; RUN: %s
2 ; RUN: opt < %s -msan -msan-check-access-address=0 -S | FileCheck %s
3 ; RUN: opt < %s -msan-check-access-address=0 -msan-track-origins=1 -S \
4 ; RUN: -passes=msan 2>&1 | FileCheck %s
15 ; RUN: opt < %s -msan -msan-check-access-address=0 -msan-track-origins=1 -S | FileCheck %s
6 ; RUN: opt < %s -msan-check-access-address=0 -msan-track-origins=2 -S \
7 ; RUN: -passes=msan 2>&1 | FileCheck %s
28 ; RUN: opt < %s -msan -msan-check-access-address=0 -msan-track-origins=2 -S | FileCheck %s
39
410 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"
0 ; Test that copy alignment for byval arguments is limited by param-tls slot alignment.
11
2 ; RUN: opt < %s -msan-check-access-address=0 -S -passes=msan 2>&1 | FileCheck \
3 ; RUN: %s
24 ; RUN: opt < %s -msan -msan-check-access-address=0 -S | FileCheck %s
35
46 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
0 ; RUN: opt < %s -msan-check-access-address=0 -msan-check-constant-shadow=1 \
1 ; RUN: -msan-track-origins=1 -S -passes=msan 2>&1 | FileCheck %s
2 ; RUN: opt < %s -msan -msan-check-access-address=0 -msan-check-constant-shadow=1 -msan-track-origins=1 -S | FileCheck %s
13
24 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"
0 ; RUN: opt < %s -msan-check-access-address=1 -S -passes=msan 2>&1 | FileCheck \
1 ; RUN: %s
2 ; RUN: opt < %s -msan -msan-check-access-address=1 -S | FileCheck %s
13
24 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"
0 ; RUN: opt < %s -msan-check-access-address=0 -S -passes=msan 2>&1 | FileCheck \
1 ; RUN: %s
2 ; RUN: opt < %s -msan -msan-check-access-address=0 -S | FileCheck %s
3 ; RUN: opt < %s -msan-check-access-address=1 -S -passes=msan 2>&1 | FileCheck \
4 ; RUN: %s --check-prefix=ADDR
15 ; RUN: opt < %s -msan -msan-check-access-address=1 -S | FileCheck %s --check-prefix=ADDR
26 ; REQUIRES: x86-registered-target
37
+0
-17
test/Instrumentation/MemorySanitizer/global_ctors_2to3.ll less more
None ; MSan converts 2-element global_ctors to 3-element when adding the new entry.
1 ; RUN: opt < %s -msan -msan-with-comdat -S | FileCheck %s
2
3 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
4 target triple = "x86_64-unknown-linux-gnu"
5
6 ; CHECK: $msan.module_ctor = comdat any
7 ; CHECK: @llvm.global_ctors = appending global [2 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @f, i8* null }, { i32, void ()*, i8* } { i32 0, void ()* @msan.module_ctor, i8* bitcast (void ()* @msan.module_ctor to i8*) }]
8
9 @llvm.global_ctors = appending global [1 x { i32, void ()* }] [{ i32, void ()* } { i32 65535, void ()* @f }]
10
11 define internal void @f() {
12 entry:
13 ret void
14 }
15
16 ; CHECK: define internal void @msan.module_ctor() comdat {
11 ; Test that in with-calls mode there are no calls to __msan_chain_origin - they
22 ; are done from __msan_maybe_store_origin_*.
33
4 ; RUN: opt < %s -msan-check-access-address=0 \
5 ; RUN: -msan-instrumentation-with-call-threshold=0 -S -passes=msan 2>&1 | \
6 ; RUN: FileCheck %s
47 ; RUN: opt < %s -msan -msan-check-access-address=0 -msan-instrumentation-with-call-threshold=0 -S | FileCheck %s
8 ; RUN: opt < %s -msan-check-access-address=0 \
9 ; RUN: -msan-instrumentation-with-call-threshold=0 -msan-track-origins=1 -S \
10 ; RUN: -passes=msan 2>&1 | FileCheck -check-prefix=CHECK \
11 ; RUN: -check-prefix=CHECK-ORIGINS %s
512 ; RUN: opt < %s -msan -msan-check-access-address=0 -msan-instrumentation-with-call-threshold=0 -msan-track-origins=1 -S | FileCheck -check-prefix=CHECK -check-prefix=CHECK-ORIGINS %s
13 ; RUN: opt < %s -msan-check-access-address=0 \
14 ; RUN: -msan-instrumentation-with-call-threshold=0 -msan-track-origins=2 -S \
15 ; RUN: -passes=msan 2>&1 | FileCheck -check-prefix=CHECK \
16 ; RUN: -check-prefix=CHECK-ORIGINS %s
617 ; RUN: opt < %s -msan -msan-check-access-address=0 -msan-instrumentation-with-call-threshold=0 -msan-track-origins=2 -S | FileCheck -check-prefix=CHECK -check-prefix=CHECK-ORIGINS %s
718
819 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"
0 ; Test that the msan layout customization options work as expected
11 ;
2 ; RUN: opt < %s -msan-shadow-base 3735928559 -S -passes=msan 2>&1 | FileCheck \
3 ; RUN: --check-prefix=CHECK-BASE %s
24 ; RUN: opt < %s -msan -msan-shadow-base 3735928559 -S | FileCheck --check-prefix=CHECK-BASE %s
5 ; RUN: opt < %s -msan-shadow-base 3735928559 -msan-and-mask 4294901760 -S \
6 ; RUN: -passes=msan 2>&1 | FileCheck --check-prefix=CHECK-AND %s
37 ; RUN: opt < %s -msan -msan-shadow-base 3735928559 -msan-and-mask 4294901760 -S | FileCheck --check-prefix=CHECK-AND %s
8 ; RUN: opt < %s -msan-shadow-base 3735928559 -msan-xor-mask 48879 -S \
9 ; RUN: -passes=msan 2>&1 | FileCheck --check-prefix=CHECK-XOR %s
410 ; RUN: opt < %s -msan -msan-shadow-base 3735928559 -msan-xor-mask 48879 -S | FileCheck --check-prefix=CHECK-XOR %s
11 ; RUN: opt < %s -msan-shadow-base 3735928559 -msan-xor-mask 48879 \
12 ; RUN: -msan-and-mask 4294901760 -S -passes=msan 2>&1 | FileCheck \
13 ; RUN: --check-prefix=CHECK-XOR-AND %s
514 ; RUN: opt < %s -msan -msan-shadow-base 3735928559 -msan-xor-mask 48879 -msan-and-mask 4294901760 -S | FileCheck --check-prefix=CHECK-XOR-AND %s
15 ; RUN: opt < %s -msan-track-origins 1 -msan-origin-base 1777777 -S -passes=msan\
16 ; RUN: 2>&1 | FileCheck --check-prefix=CHECK-ORIGIN-BASE %s
617 ; RUN: opt < %s -msan -msan-track-origins 1 -msan-origin-base 1777777 -S | FileCheck --check-prefix=CHECK-ORIGIN-BASE %s
718
819 target triple = "x86_64-unknown-linux-gnu"
0 ; RUN: opt < %s -msan-check-access-address=0 -S -passes=msan 2>&1 | FileCheck \
1 ; RUN: %s
2 ; RUN: opt < %s -msan -msan-check-access-address=0 -S | FileCheck %s
3 ; RUN: opt < %s -msan-check-access-address=0 -msan-track-origins=1 -S \
4 ; RUN: -passes=msan 2>&1 | FileCheck %s "--check-prefixes=CHECK,CHECK-ORIGIN"
15 ; RUN: opt < %s -msan -msan-check-access-address=0 -msan-track-origins=1 -S | FileCheck %s --check-prefixes=CHECK,CHECK-ORIGIN
6 ; RUN: opt < %s -msan-check-access-address=1 -S -passes=msan 2>&1 | FileCheck \
7 ; RUN: %s --check-prefix=ADDR
28 ; RUN: opt < %s -msan -msan-check-access-address=1 -S | FileCheck %s --check-prefix=ADDR
39
410 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"
0 ; RUN: opt < %s -msan-check-access-address=0 -msan-track-origins=1 -S \
1 ; RUN: -passes=msan 2>&1 | FileCheck %s
2 ; RUN: opt < %s -msan -msan-check-access-address=0 -msan-track-origins=1 -S | FileCheck %s
13
24 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"
0 ; Test for handling of asm constraints in MSan instrumentation.
1 ; RUN: opt < %s -msan-kernel=1 -msan-check-access-address=0 \
2 ; RUN: -msan-handle-asm-conservative=0 -S -passes=msan 2>&1 | FileCheck \
3 ; RUN: "-check-prefixes=CHECK,CHECK-NONCONS" %s
14 ; RUN: opt < %s -msan -msan-kernel=1 -msan-check-access-address=0 -msan-handle-asm-conservative=0 -S | FileCheck -check-prefixes=CHECK,CHECK-NONCONS %s
5 ; RUN: opt < %s -msan-kernel=1 -msan-check-access-address=0 \
6 ; RUN: -msan-handle-asm-conservative=1 -S -passes=msan 2>&1 | FileCheck \
7 ; RUN: "-check-prefixes=CHECK,CHECK-CONS" %s
28 ; RUN: opt < %s -msan -msan-kernel=1 -msan-check-access-address=0 -msan-handle-asm-conservative=1 -S | FileCheck -check-prefixes=CHECK,CHECK-CONS %s
39
410 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
0 ; RUN: opt < %s -msan-check-access-address=0 -S -passes=msan 2>&1 | FileCheck \
1 ; RUN: -allow-deprecated-dag-overlap %s
2 ; RUN: opt < %s -msan -msan-check-access-address=0 -S | FileCheck -allow-deprecated-dag-overlap %s
3 ; RUN: opt < %s -msan-check-access-address=0 -msan-track-origins=1 -S \
4 ; RUN: -passes=msan 2>&1 | FileCheck -allow-deprecated-dag-overlap \
5 ; RUN: -check-prefix=CHECK -check-prefix=CHECK-ORIGINS %s
16 ; RUN: opt < %s -msan -msan-check-access-address=0 -msan-track-origins=1 -S | FileCheck -allow-deprecated-dag-overlap -check-prefix=CHECK -check-prefix=CHECK-ORIGINS %s
27
38 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"
49 target triple = "x86_64-unknown-linux-gnu"
510
6 ; CHECK: @llvm.global_ctors {{.*}} { i32 0, void ()* @msan.module_ctor, i8* null }
11 ; CHECK: @llvm.global_ctors {{.*}} { i32 0, void ()* @__msan_init, i8* null }
712
813 ; Check the presence and the linkage type of __msan_track_origins and
914 ; other interface symbols.
985990 ; CHECK-NEXT: ret i8*
986991
987992
988 ; CHECK-LABEL: define internal void @msan.module_ctor() {
989 ; CHECK: call void @__msan_init()
993 ; CHECK: declare void @__msan_init()
0 ; KMSAN instrumentation tests
1 ; RUN: opt < %s -msan-kernel=1 -S -passes=msan 2>&1 | FileCheck %s \
2 ; RUN: -check-prefixes=CHECK
13 ; RUN: opt < %s -msan -msan-kernel=1 -S | FileCheck %s -check-prefixes=CHECK
24
35 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"
0 ; Test for the conservative assembly handling mode used by KMSAN.
1 ; RUN: opt < %s -msan-kernel=1 -msan-check-access-address=0 \
2 ; RUN: -msan-handle-asm-conservative=0 -S -passes=msan 2>&1 | FileCheck \
3 ; RUN: "-check-prefixes=CHECK,CHECK-NONCONS" %s
14 ; RUN: opt < %s -msan -msan-kernel=1 -msan-check-access-address=0 -msan-handle-asm-conservative=0 -S | FileCheck -check-prefixes=CHECK,CHECK-NONCONS %s
5 ; RUN: opt < %s -msan-kernel=1 -msan-check-access-address=0 \
6 ; RUN: -msan-handle-asm-conservative=1 -S -passes=msan 2>&1 | FileCheck \
7 ; RUN: "-check-prefixes=CHECK,CHECK-CONS" %s
28 ; RUN: opt < %s -msan -msan-kernel=1 -msan-check-access-address=0 -msan-handle-asm-conservative=1 -S | FileCheck -check-prefixes=CHECK,CHECK-CONS %s
39
410 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
0 ; RUN: opt < %s -msan-check-access-address=0 -S -passes=msan 2>&1 | FileCheck \
1 ; RUN: %s
2 ; RUN: opt < %s -msan -msan-check-access-address=0 -S | FileCheck %s
3 ; RUN: opt < %s -msan-check-access-address=0 -msan-track-origins=1 -S \
4 ; RUN: -passes=msan 2>&1 | FileCheck -check-prefix=CHECK \
5 ; RUN: -check-prefix=CHECK-ORIGINS %s
16 ; RUN: opt < %s -msan -msan-check-access-address=0 -msan-track-origins=1 -S | FileCheck -check-prefix=CHECK -check-prefix=CHECK-ORIGINS %s
27 ; REQUIRES: x86-registered-target
38
0 ; RUN: opt < %s -msan-check-access-address=0 -S -passes=msan 2>&1 | FileCheck \
1 ; RUN: %s
2 ; RUN: opt < %s -msan -msan-check-access-address=0 -S | FileCheck %s
13
24 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"
0 ; Verify that calls with !nosanitize are not instrumented by MSan.
1 ; RUN: opt < %s -S -passes=msan 2>&1 | FileCheck %s
12 ; RUN: opt < %s -msan -S | FileCheck %s
3 ; RUN: opt < %s -msan-track-origins=1 -S -passes=msan 2>&1 | FileCheck %s
24 ; RUN: opt < %s -msan -msan-track-origins=1 -S | FileCheck %s
35 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
46 target triple = "x86_64-unknown-linux-gnu"
0 ; RUN: opt < %s -msan-check-access-address=0 -msan-track-origins=1 -S \
1 ; RUN: -passes=msan 2>&1 | FileCheck -check-prefix=CHECK \
2 ; RUN: -check-prefix=CHECK-ORIGINS1 %s
3 ; RUN: opt < %s -msan -msan-check-access-address=0 -msan-track-origins=1 -S | FileCheck -check-prefix=CHECK -check-prefix=CHECK-ORIGINS1 %s
4 ; RUN: opt < %s -msan-check-access-address=0 -msan-track-origins=2 -S \
5 ; RUN: -passes=msan 2>&1 | FileCheck -check-prefix=CHECK \
6 ; RUN: -check-prefix=CHECK-ORIGINS2 %s
17 ; RUN: opt < %s -msan -msan-check-access-address=0 -msan-track-origins=2 -S | FileCheck -check-prefix=CHECK -check-prefix=CHECK-ORIGINS2 %s
28
39 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"
0 ; RUN: opt < %s -msan-check-access-address=0 -msan-track-origins=2 -S \
1 ; RUN: -passes=msan 2>&1 | FileCheck %s
2 ; RUN: opt < %s -msan -msan-check-access-address=0 -msan-track-origins=2 -S | FileCheck %s
13
24 target datalayout = "e-m:e-i64:64-i128:128-n32:64-S128"
0 ; Regression test for https://bugs.llvm.org/show_bug.cgi?id=32842
11 ;
2 ; RUN: opt < %s -S -passes=msan 2>&1 | FileCheck %s
23 ; RUN: opt < %s -msan -S | FileCheck %s
34 ;target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
45 target triple = "x86_64-unknown-linux-gnu"
0 ; RUN: opt < %s -msan-check-access-address=0 -S -passes=msan 2>&1 | FileCheck \
1 ; RUN: %s
2 ; RUN: opt < %s -msan -msan-check-access-address=0 -S | FileCheck %s
13 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"
24 target triple = "x86_64-unknown-linux-gnu"
0 ; RUN: opt < %s -msan-check-access-address=0 -msan-track-origins=1 -S \
1 ; RUN: -passes=msan 2>&1 | FileCheck %s
2 ; RUN: opt < %s -msan -msan-check-access-address=0 -msan-track-origins=1 -S | FileCheck %s
13
24 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"
0 ; RUN: opt < %s -msan-check-access-address=0 -msan-track-origins=1 -S \
1 ; RUN: -passes=msan 2>&1 | FileCheck \
2 ; RUN: "-check-prefixes=CHECK,CHECK-MSAN,CHECK-ORIGINS1" %s
3 ; RUN: opt < %s -msan -msan-check-access-address=0 -msan-track-origins=1 -S | FileCheck -check-prefixes=CHECK,CHECK-MSAN,CHECK-ORIGINS1 %s
4 ; RUN: opt < %s -msan-check-access-address=0 -msan-track-origins=2 -S \
5 ; RUN: -passes=msan 2>&1 | FileCheck \
6 ; RUN: "-check-prefixes=CHECK,CHECK-MSAN,CHECK-ORIGINS2" %s
17 ; RUN: opt < %s -msan -msan-check-access-address=0 -msan-track-origins=2 -S | FileCheck -check-prefixes=CHECK,CHECK-MSAN,CHECK-ORIGINS2 %s
8 ; RUN: opt < %s -msan-kernel=1 -msan-check-access-address=0 -S -passes=msan \
9 ; RUN: 2>&1 | FileCheck "-check-prefixes=CHECK,CHECK-KMSAN,CHECK-ORIGINS2" %s
210 ; RUN: opt < %s -msan -msan-kernel=1 -msan-check-access-address=0 -S | FileCheck -check-prefixes=CHECK,CHECK-KMSAN,CHECK-ORIGINS2 %s
311
412 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"
0 ; Test marking string functions as nobuiltin in memory sanitizer.
11 ;
2 ; RUN: opt < %s -S -passes=msan 2>&1 | FileCheck %s
23 ; RUN: opt < %s -msan -S | FileCheck %s
34 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"
45 target triple = "x86_64-unknown-linux-gnu"
0 ; RUN: opt < %s -S -passes=msan 2>&1 | FileCheck %s
1 ; RUN: opt < %s -msan -S | FileCheck %s
12 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"
23 target triple = "x86_64-unknown-linux-gnu"
0 ; Check that unsized token types used by coroutine intrinsics do not cause
11 ; assertion failures.
2 ; RUN: opt < %s -S 2>&1 -passes=msan | FileCheck %s
23 ; RUN: opt < %s -msan -S 2>&1 | FileCheck %s
34
45 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
0 ; RUN: opt < %s -msan-check-access-address=0 -S -passes=msan 2>&1 | FileCheck \
1 ; RUN: %s
2 ; RUN: opt < %s -msan -msan-check-access-address=0 -S | FileCheck %s
13 ; REQUIRES: x86-registered-target
24
0 ; RUN: opt < %s -msan-check-access-address=0 -S -passes=msan 2>&1 | FileCheck \
1 ; RUN: %s
2 ; RUN: opt < %s -msan -msan-check-access-address=0 -S | FileCheck %s
13 ; REQUIRES: x86-registered-target
24
0 ; RUN: opt < %s -msan-check-access-address=0 -S -passes=msan 2>&1 | FileCheck \
1 ; RUN: %s
2 ; RUN: opt < %s -msan -msan-check-access-address=0 -S | FileCheck %s
13 ; REQUIRES: x86-registered-target
24
0 ; RUN: opt < %s -msan-check-access-address=0 -S -passes=msan 2>&1 | FileCheck \
1 ; RUN: %s
2 ; RUN: opt < %s -msan -msan-check-access-address=0 -S | FileCheck %s
13 ; REQUIRES: x86-registered-target
24
0 ; RUN: opt < %s -msan-check-access-address=0 -S -passes=msan 2>&1 | FileCheck \
1 ; RUN: %s
2 ; RUN: opt < %s -msan -msan-check-access-address=0 -S | FileCheck %s
13 ; REQUIRES: x86-registered-target
24
0 ; RUN: opt < %s -msan-instrumentation-with-call-threshold=0 -S -passes=msan \
1 ; RUN: 2>&1 | FileCheck %s
2 ; RUN: opt < %s -msan -msan-instrumentation-with-call-threshold=0 -S | FileCheck %s
13
24 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"
8183 ; CHECK-NOT: call void @__msan_maybe_warning_
8284 ; CHECK: icmp ne i65 %{{.*}}, 0
8385 ; CHECK-NOT: call void @__msan_maybe_warning_
84 ; CHECK: ret <4 x i32>
86 ; CHECK: ret <4 x i32>