//===-- AddressSanitizer.cpp - memory error detector ------------*- C++ -*-===////// The LLVM Compiler Infrastructure//// This file is distributed under the University of Illinois Open Source// License. See LICENSE.TXT for details.////===----------------------------------------------------------------------===////// This file is a part of AddressSanitizer, an address sanity checker.// Details of the algorithm:// http://code.google.com/p/address-sanitizer/wiki/AddressSanitizerAlgorithm////===----------------------------------------------------------------------===//#define DEBUG_TYPE "asan"#include"llvm/Transforms/Instrumentation.h"#include"BlackList.h"#include"llvm/ADT/ArrayRef.h"#include"llvm/ADT/DepthFirstIterator.h"#include"llvm/ADT/OwningPtr.h"#include"llvm/ADT/SmallSet.h"#include"llvm/ADT/SmallString.h"#include"llvm/ADT/SmallVector.h"#include"llvm/ADT/StringExtras.h"#include"llvm/ADT/Triple.h"#include"llvm/DataLayout.h"#include"llvm/DIBuilder.h"#include"llvm/Function.h"#include"llvm/IRBuilder.h"#include"llvm/InlineAsm.h"#include"llvm/InstVisitor.h"#include"llvm/IntrinsicInst.h"#include"llvm/LLVMContext.h"#include"llvm/Module.h"#include"llvm/Support/CommandLine.h"#include"llvm/Support/DataTypes.h"#include"llvm/Support/Debug.h"#include"llvm/Support/raw_ostream.h"#include"llvm/Support/system_error.h"#include"llvm/Target/TargetMachine.h"#include"llvm/Transforms/Utils/BasicBlockUtils.h"#include"llvm/Transforms/Utils/Local.h"#include"llvm/Transforms/Utils/ModuleUtils.h"#include"llvm/Type.h"#include<algorithm>#include<string>usingnamespacellvm;staticconstuint64_tkDefaultShadowScale=3;staticconstuint64_tkDefaultShadowOffset32=1ULL<<29;staticconstuint64_tkDefaultShadowOffset64=1ULL<<44;staticconstuint64_tkDefaultShadowOffsetAndroid=0;staticconstsize_tkMaxStackMallocSize=1<<16;// 64Kstaticconstuintptr_tkCurrentStackFrameMagic=0x41B58AB3;staticconstuintptr_tkRetiredStackFrameMagic=0x45E0360E;staticconstchar*kAsanModuleCtorName="asan.module_ctor";staticconstchar*kAsanModuleDtorName="asan.module_dtor";staticconstintkAsanCtorAndCtorPriority=1;staticconstchar*kAsanReportErrorTemplate="__asan_report_";staticconst