From 60ef25bd545c9c3b917d007462188819dfcc81cd Mon Sep 17 00:00:00 2001 From: Kostya Serebryany Date: Fri, 21 Nov 2014 22:34:29 +0000 Subject: [PATCH] [asan] remove old experimental code llvm-svn: 222586 --- .../Instrumentation/AddressSanitizer.cpp | 38 ---------------------- .../keep-instrumented_functions.ll | 23 ------------- 2 files changed, 61 deletions(-) delete mode 100644 llvm/test/Instrumentation/AddressSanitizer/keep-instrumented_functions.ll diff --git a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp index 414fb65..c2166d3 100644 --- a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp +++ b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp @@ -162,19 +162,6 @@ static cl::opt ClMemoryAccessCallbackPrefix( static cl::opt ClInstrumentAllocas("asan-instrument-allocas", cl::desc("instrument dynamic allocas"), cl::Hidden, cl::init(false)); -// This is an experimental feature that will allow to choose between -// instrumented and non-instrumented code at link-time. -// If this option is on, just before instrumenting a function we create its -// clone; if the function is not changed by asan the clone is deleted. -// If we end up with a clone, we put the instrumented function into a section -// called "ASAN" and the uninstrumented function into a section called "NOASAN". -// -// This is still a prototype, we need to figure out a way to keep two copies of -// a function so that the linker can easily choose one of them. -static cl::opt ClKeepUninstrumented("asan-keep-uninstrumented-functions", - cl::desc("Keep uninstrumented copies of functions"), - cl::Hidden, cl::init(false)); - // These flags allow to change the shadow mapping. // The shadow mapping looks like // Shadow = (Mem >> scale) + (1 << offset_log) @@ -1425,17 +1412,6 @@ bool AddressSanitizer::runOnFunction(Function &F) { } } - Function *UninstrumentedDuplicate = nullptr; - bool LikelyToInstrument = - !NoReturnCalls.empty() || !ToInstrument.empty() || (NumAllocas > 0); - if (ClKeepUninstrumented && LikelyToInstrument) { - ValueToValueMapTy VMap; - UninstrumentedDuplicate = CloneFunction(&F, VMap, false); - UninstrumentedDuplicate->removeFnAttr(Attribute::SanitizeAddress); - UninstrumentedDuplicate->setName("NOASAN_" + F.getName()); - F.getParent()->getFunctionList().push_back(UninstrumentedDuplicate); - } - bool UseCalls = false; if (ClInstrumentationWithCallsThreshold >= 0 && ToInstrument.size() > (unsigned)ClInstrumentationWithCallsThreshold) @@ -1473,20 +1449,6 @@ bool AddressSanitizer::runOnFunction(Function &F) { DEBUG(dbgs() << "ASAN done instrumenting: " << res << " " << F << "\n"); - if (ClKeepUninstrumented) { - if (!res) { - // No instrumentation is done, no need for the duplicate. - if (UninstrumentedDuplicate) - UninstrumentedDuplicate->eraseFromParent(); - } else { - // The function was instrumented. We must have the duplicate. - assert(UninstrumentedDuplicate); - UninstrumentedDuplicate->setSection("NOASAN"); - assert(!F.hasSection()); - F.setSection("ASAN"); - } - } - return res; } diff --git a/llvm/test/Instrumentation/AddressSanitizer/keep-instrumented_functions.ll b/llvm/test/Instrumentation/AddressSanitizer/keep-instrumented_functions.ll deleted file mode 100644 index 8726b8e..0000000 --- a/llvm/test/Instrumentation/AddressSanitizer/keep-instrumented_functions.ll +++ /dev/null @@ -1,23 +0,0 @@ -; Test the -asan-keep-uninstrumented-functions flag: FOO should get cloned -; RUN: opt < %s -asan -asan-module -asan-keep-uninstrumented-functions -S | FileCheck %s -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" - -@a = global i32 0, align 4 - -define i32 @main() sanitize_address { -entry: - tail call void @FOO(i32* @a) - ret i32 0 -} - -define void @FOO(i32* nocapture %x) sanitize_address { -entry: - store i32 1, i32* %x, align 4 - ret void -} - -; main should not be cloned since it is not being instrumented by asan. -; CHECK-NOT: NOASAN_main -; CHECK: define void @FOO{{.*}} section "ASAN" -; CHECK: define void @NOASAN_FOO{{.*}} section "NOASAN" -- 2.7.4