[ASan] Introduce a flag -asan-constructor-kind to control the generation of the Asan...
authorusama hameed <u_hameed@apple.com>
Tue, 24 Jan 2023 22:03:26 +0000 (14:03 -0800)
committerusama hameed <u_hameed@apple.com>
Tue, 24 Jan 2023 23:36:21 +0000 (15:36 -0800)
commit2b02df781928897beb640df24078dc3c4eb2eb14
tree5674cb0efbde68d5dce928558acb61e15edaa9c3
parent5b6dbdecba0b033e6a64593062cf87cd6c8a66ee
[ASan] Introduce a flag -asan-constructor-kind to control the generation of the Asan module constructor.

By default, ASan generates an asan.module_ctor function that initializes asan and
registers the globals in the module. This function is added to the
@llvm.global_ctors array. Previously, there was no way to control the
generation of this function.

This patch adds a way to control the generation of this function. The
flag -asan-constructor-kind has two options:

global: This is the default option and the default behavior of ASan. It generates an
asan.module_ctor function.
none: This skips the generation of the asan.module_ctor function.

rdar://104448572

Differential revision: https://reviews.llvm.org/D142505
llvm/include/llvm/Transforms/Instrumentation/AddressSanitizer.h
llvm/include/llvm/Transforms/Instrumentation/AddressSanitizerOptions.h
llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
llvm/test/Instrumentation/AddressSanitizer/no-global-ctors.ll [new file with mode: 0644]