Skip to content

Commit

Permalink
[NFC-ish] Finish MSAN handling (#6516)
Browse files Browse the repository at this point in the history
Somehow, initially i missed that there was MSan support,
so it might be good to actually mention that we don't need to run
any MSan passes here, and that we didn't forget to run them.

Secondly, it seems inconsistent not annotate the functions
with `Attribute::SanitizeMemory`, like we do for others.

I suppose it isn't strictly required, since they are used
to actually drive the instrumentation passes, and we don't
run MSan pass, but they are also used to disable some LLVM optimizations,
and that //might// be important. Or not, but then i suppose
there should be a comment about it?

Co-authored-by: Steven Johnson <srj@google.com>
  • Loading branch information
LebedevRI and steven-johnson authored Jan 4, 2022
1 parent 5c33902 commit 7eb9949
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/CodeGen_LLVM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1171,6 +1171,9 @@ void CodeGen_LLVM::optimize_module() {
});
}

// Target::MSAN handling is sprinkled throughout the codebase,
// there is no need to run MemorySanitizerPass here.

if (get_target().has_feature(Target::TSAN)) {
pb.registerOptimizerLastEPCallback(
[](ModulePassManager &mpm, OptimizationLevel level) {
Expand All @@ -1183,6 +1186,9 @@ void CodeGen_LLVM::optimize_module() {
if (get_target().has_feature(Target::ASAN)) {
function.addFnAttr(Attribute::SanitizeAddress);
}
if (get_target().has_feature(Target::MSAN)) {
function.addFnAttr(Attribute::SanitizeMemory);
}
if (get_target().has_feature(Target::TSAN)) {
// Do not annotate any of Halide's low-level synchronization code as it has
// tsan interface calls to mark its behavior and is much faster if
Expand Down

0 comments on commit 7eb9949

Please sign in to comment.