From be73337ad20ffd28bd8d4e5473091603ab04166b Mon Sep 17 00:00:00 2001 From: Kostya Serebryany Date: Tue, 12 Feb 2013 11:11:02 +0000 Subject: [PATCH] [asan] change the default mapping offset on x86_64 to 0x7fff8000. This gives roughly 5% speedup. Since this is an ABI change, bump the asan ABI version by renaming __asan_init to __asan_init_v1. llvm part, compiler-rt part will follow llvm-svn: 174957 --- llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp index c5f77ec..02a8680 100644 --- a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp +++ b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp @@ -68,7 +68,7 @@ static const char *kAsanRegisterGlobalsName = "__asan_register_globals"; static const char *kAsanUnregisterGlobalsName = "__asan_unregister_globals"; static const char *kAsanPoisonGlobalsName = "__asan_before_dynamic_init"; static const char *kAsanUnpoisonGlobalsName = "__asan_after_dynamic_init"; -static const char *kAsanInitName = "__asan_init"; +static const char *kAsanInitName = "__asan_init_v1"; static const char *kAsanHandleNoReturnName = "__asan_handle_no_return"; static const char *kAsanMappingOffsetName = "__asan_mapping_offset"; static const char *kAsanMappingScaleName = "__asan_mapping_scale"; @@ -136,7 +136,7 @@ static cl::opt ClMappingOffsetLog("asan-mapping-offset-log", cl::desc("offset of asan shadow mapping"), cl::Hidden, cl::init(-1)); static cl::opt ClShort64BitOffset("asan-short-64bit-mapping-offset", cl::desc("Use short immediate constant as the mapping offset for 64bit"), - cl::Hidden, cl::init(false)); + cl::Hidden, cl::init(true)); // Optimization flags. Not user visible, used mostly for testing // and benchmarking the tool. @@ -203,6 +203,7 @@ static ShadowMapping getShadowMapping(const Module &M, int LongSize, llvm::Triple TargetTriple(M.getTargetTriple()); bool IsAndroid = TargetTriple.getEnvironment() == llvm::Triple::Android; bool IsPPC64 = TargetTriple.getArch() == llvm::Triple::ppc64; + bool IsX86_64 = TargetTriple.getArch() == llvm::Triple::x86_64; ShadowMapping Mapping; @@ -214,7 +215,8 @@ static ShadowMapping getShadowMapping(const Module &M, int LongSize, Mapping.Offset = (IsAndroid || ZeroBaseShadow) ? 0 : (LongSize == 32 ? kDefaultShadowOffset32 : IsPPC64 ? kPPC64_ShadowOffset64 : kDefaultShadowOffset64); - if (!ZeroBaseShadow && ClShort64BitOffset && LongSize == 64) { + if (!ZeroBaseShadow && ClShort64BitOffset && IsX86_64) { + assert(LongSize == 64); Mapping.Offset = kDefaultShort64bitShadowOffset; } if (!ZeroBaseShadow && ClMappingOffsetLog >= 0) { // Zero offset log is the special case. -- 2.7.4