[PATCH] D96572: [Clang][ASan] Introduce `-fsanitize-address-destructor-kind=` driver & frontend option.

Vitaly Buka via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 12 13:09:12 PST 2021


vitalybuka added inline comments.


================
Comment at: clang/include/clang/Driver/Options.td:1485
+def sanitize_address_destructor_kind_EQ : Joined<["-"], "fsanitize-address-destructor-kind=">,
+  MetaVarName<"<kind>">,
+  Flags<[CC1Option]>,
----------------
delcypher wrote:
> delcypher wrote:
> > vitalybuka wrote:
> > > What is the difference between them and why it's need to be configured from outside?
> > Good questions. 
> > 
> > > What is the difference between them
> > 
> > I'll add some documentation to explain this. But the two different modes are introduced by https://reviews.llvm.org/D96571. Basically the default ("global") emits ASan module destructor calls via `llvm.global_dtors` which was the previous behaviour. The other mode "none" simply causes no ASan module destructors to be emitted. I plan to introduce another mode in a future patch.
> > 
> > > why it's need to be configured from outside?
> > 
> > At the bare minimum this option needs to be controllable by the driver so that we can do the next patch (https://reviews.llvm.org/D96573) where based on target details and other flags we set the ASan destructor kind. This means that the frontend needs to be able to consume to option too.
> > 
> > It is technically not necessary for this new option to be a driver option. However, I made it a driver option too to match the existing ASan clang frontend options which are also driver options (e.g. `-fsanitize-address-use-odr-indicator`).
> @vitalybuka To expand on my answer a little more. `-fsanitize-address-destructor-kind=` is needed because we need to able to control how ASan's module are emitted and unfortunately the information required to make the decision on which kind to emit **is not available at the level of LLVM IR**. The information we need to be able to make the decision is only available in the Clang driver. This is why this patch wires everything up so that the driver can change how ASan module destructors are emitted.
> @vitalybuka To expand on my answer a little more. `-fsanitize-address-destructor-kind=` is needed because we need to able to control how ASan's module are emitted and unfortunately the information required to make the decision on which kind to emit **is not available at the level of LLVM IR**. The information we need to be able to make the decision is only available in the Clang driver. This is why this patch wires everything up so that the driver can change how ASan module destructors are emitted.

I didn't check all patches yet, but we have -fsanitize=kernel-address and I noticed that your patches mentioned kernel. Could be possible just use -fsanitize=kernel-address and let ASan decide how to handle dtors for this platform?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D96572/new/

https://reviews.llvm.org/D96572



More information about the llvm-commits mailing list