[all-commits] [llvm/llvm-project] 7d3ef1: [ASan] Introduce a way set different ways of emitt...

Dan Liew via All-commits all-commits at lists.llvm.org
Tue Feb 23 20:38:48 PST 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 7d3ef103b55a28a5ca6983dcef63f24ddc3986f1
      https://github.com/llvm/llvm-project/commit/7d3ef103b55a28a5ca6983dcef63f24ddc3986f1
  Author: Dan Liew <dliew at apple.com>
  Date:   2021-02-23 (Tue, 23 Feb 2021)

  Changed paths:
    M llvm/include/llvm/Transforms/Instrumentation/AddressSanitizer.h
    A llvm/include/llvm/Transforms/Instrumentation/AddressSanitizerOptions.h
    M llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
    A llvm/test/Instrumentation/AddressSanitizer/no_global_dtors.ll

  Log Message:
  -----------
  [ASan] Introduce a way set different ways of emitting module destructors.

Previously there was no way to control how module destructors were emitted
by `ModuleAddressSanitizerPass`. However, we want language frontends (e.g. Clang)
to be able to decide how to emit these destructors (if at all).

This patch introduces the `AsanDtorKind` enum that represents the different ways
destructors can be emitted. There are currently only two valid ways to emit destructors.

* `Global` - Use `llvm.global_dtors`. This was the previous behavior and is the default.
* `None`   - Do not emit module destructors.

The `ModuleAddressSanitizerPass` and the various wrappers around it have been updated
to take the `AsanDtorKind` as an argument.

The `-asan-destructor-kind=` command line argument has been introduced to make this
easy to test from `opt`. If this argument is specified it overrides the value passed
to the `ModuleAddressSanitizerPass` constructor.

Note that `AsanDtorKind` is not `bool` because we will introduce a new way to
emit destructors in a subsequent patch.

Note that `AsanDtorKind` is given its own header file because if it is declared
in `Transforms/Instrumentation/AddressSanitizer.h` it leads to compile error
(Module is ambiguous) when trying to use it in
`clang/Basic/CodeGenOptions.def`.

rdar://71609176

Differential Revision: https://reviews.llvm.org/D96571




More information about the All-commits mailing list