This is an archive of the discontinued LLVM Phabricator instance.

enable msan-eager-checks with -fsanitize-memory-param-retval.
AbandonedPublic

Authored by kda on Jan 4 2022, 5:00 PM.

Details

Reviewers
vitalybuka
Summary

Diff Detail

Event Timeline

kda created this revision.Jan 4 2022, 5:00 PM
kda requested review of this revision.Jan 4 2022, 5:00 PM
Herald added projects: Restricted Project, Restricted Project, Restricted Project. · View Herald TranscriptJan 4 2022, 5:00 PM
Herald added subscribers: llvm-commits, Restricted Project, cfe-commits. · View Herald Transcript

this patch depends on D116633, but D116633 is useless without this one
a better patch order is :

  1. llvm
  2. clang
  3. compiler-rt (but if it's just test which uses clang flag it should be OK merge with no.2 )

let's do just llvm here, and move clang stuff into D116633 with the rest

we should update third_party/llvm/llvm-project/llvm/lib/Passes/PassBuilder.cpp:640
after that we can update third_party/llvm/llvm-project/llvm/test/Instrumentation/MemorySanitizer/msan_eager.ll
with additional ; RUN: line with "-passes='module(msan-module<OPTION_NAME->),function(msan<OPTION_NAME>)" instead of -msan-eager-checks

compiler-rt/test/msan/noundef_analysis.cpp
5 ↗(On Diff #397427)

we can land it with driver patch

llvm/include/llvm/Transforms/Instrumentation/MemorySanitizer.h
30

maybe we should use CheckParamRetVal something here?

llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
496

mllvm is lower level flag, so it should be opposite
-mllvm flag should override MemorySanitizerOptions

with getOptOrDefault below you don't need anything here

676

EagerChecks(getOptOrDefault(ClEagerChecks, EagerChecks))

kda updated this revision to Diff 398303.Jan 7 2022, 9:52 PM
kda marked 2 inline comments as done.

Reworked for comments and to be llvm only.

kda added inline comments.Jan 7 2022, 10:19 PM
llvm/include/llvm/Transforms/Instrumentation/MemorySanitizer.h
30

How about EagerChecksRequested?

llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
496

I disagree. The variable ClEagerChecks is referenced in the code. If it is not configured based on EagerChecksRequested, there is no way to change the behavior based on the presence of the flag.

I will admit that with the change below, it is a bit circular, because Options.EagerChecksRequested prefers the -msan-eager-checks flag, but may default to EagerChecksRequested parameter, and then here the flag variable (ClEagerChecks) is set based on Options.EagerChecksRequested.

An alternative is to have a member variable of MemorySanitizer that is consulted in the code. It is configured based on Options.EagerChecksRequested. The flag (-msan-eager-checks) is only consulted below with the call to getOptOrDefault. (I coded this up: https://reviews.llvm.org/D116855)

kda updated this revision to Diff 398310.Jan 7 2022, 10:25 PM

add 3 parameter constructor for MemorySanitizerOptions

kda abandoned this revision.Jan 11 2022, 2:35 PM