Currently sanitizer metadata is stored in a global LLVM metadata table,
generally "llvm.asan.globals". This contains certain attributes relevant
to the sanitizers that need to be carried around.
A while ago, when working on MTE globals, I discovered that some of the
GlobalOpt passes would delete a global variable, and replace it with
a new global variable. These optimisation passes clean up all the
general references, but don't clean up the sanitizer-specific metadata
because that wasn't associated well with the original global.
I could have just fixed that, but decided to actually fix the
outstanding N-year-old comment of "this should really be part of the
GlobalValue itself". So, remove the old sanitizer-specific global
descriptions, and move the information about sanitization to be on the
Because we don't want to carry around too much information on the
GlobalValue, I also made it so that we don't carry around the line
number and column information for each global variable in the binary in
an ASan-specific way. Instead, this patch (along with some dependencies
that add support in llvm-symbolizer and friends) changes ASan to look
for debuginfo to get this information. This mean that without debuginfo,
global-buffer-overflows and ODR reports now say "variable 'foo' defined
in 'my_source_file.cpp'" instead of "variable 'foo' defined in
'my_source_file.cpp:123:2'" (note that we still have the source line
from the file descriptions). I think this is a reasonable change.
This also provides binary savings of 0.275% when building clang under