[llvm] r236777 - ASan: Use `createSanitizerCtor` to create ctor, and call `__asan_init`
Ismail Pazarbasi
ismail.pazarbasi at gmail.com
Thu May 7 14:40:47 PDT 2015
Author: ismailp
Date: Thu May 7 16:40:46 2015
New Revision: 236777
URL: http://llvm.org/viewvc/llvm-project?rev=236777&view=rev
Log:
ASan: Use `createSanitizerCtor` to create ctor, and call `__asan_init`
Reviewers: kcc, samsonov
Subscribers: llvm-commits
Differential Revision: http://reviews.llvm.org/D8778
Modified:
llvm/trunk/lib/Transforms/Instrumentation/AddressSanitizer.cpp
llvm/trunk/test/Instrumentation/AddressSanitizer/basic.ll
Modified: llvm/trunk/lib/Transforms/Instrumentation/AddressSanitizer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/AddressSanitizer.cpp?rev=236777&r1=236776&r2=236777&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Instrumentation/AddressSanitizer.cpp (original)
+++ llvm/trunk/lib/Transforms/Instrumentation/AddressSanitizer.cpp Thu May 7 16:40:46 2015
@@ -1452,16 +1452,10 @@ bool AddressSanitizer::doInitialization(
IntptrTy = Type::getIntNTy(*C, LongSize);
TargetTriple = Triple(M.getTargetTriple());
- AsanCtorFunction =
- Function::Create(FunctionType::get(Type::getVoidTy(*C), false),
- GlobalValue::InternalLinkage, kAsanModuleCtorName, &M);
- BasicBlock *AsanCtorBB = BasicBlock::Create(*C, "", AsanCtorFunction);
- // call __asan_init in the module ctor.
- IRBuilder<> IRB(ReturnInst::Create(*C, AsanCtorBB));
- AsanInitFunction = checkSanitizerInterfaceFunction(
- M.getOrInsertFunction(kAsanInitName, IRB.getVoidTy(), nullptr));
- AsanInitFunction->setLinkage(Function::ExternalLinkage);
- IRB.CreateCall(AsanInitFunction);
+ std::tie(AsanCtorFunction, AsanInitFunction) =
+ createSanitizerCtorAndInitFunctions(M, kAsanModuleCtorName, kAsanInitName,
+ /*InitArgTypes=*/{},
+ /*InitArgs=*/{});
Mapping = getShadowMapping(TargetTriple, LongSize);
Modified: llvm/trunk/test/Instrumentation/AddressSanitizer/basic.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Instrumentation/AddressSanitizer/basic.ll?rev=236777&r1=236776&r2=236777&view=diff
==============================================================================
--- llvm/trunk/test/Instrumentation/AddressSanitizer/basic.ll (original)
+++ llvm/trunk/test/Instrumentation/AddressSanitizer/basic.ll Thu May 7 16:40:46 2015
@@ -4,6 +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"
target triple = "x86_64-unknown-linux-gnu"
+; CHECK: @llvm.global_ctors = {{.*}}@asan.module_ctor
define i32 @test_load(i32* %a) sanitize_address {
; CHECK-LABEL: @test_load
@@ -169,5 +170,8 @@ define void @memintr_test(i8* %a, i8* %b
; CHECK: __asan_memcpy
; CHECK: ret void
+; CHECK: define internal void @asan.module_ctor()
+; CHECK: call void @__asan_init_v5()
+
; PROF
; CHECK: ![[PROF]] = !{!"branch_weights", i32 1, i32 100000}
More information about the llvm-commits
mailing list