mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-04-02 15:51:54 +00:00
[msan, NFC] Move option parsing into constructor
llvm-svn: 374480
This commit is contained in:
parent
31229d098c
commit
b6e2d1b8ae
@ -19,12 +19,11 @@
|
||||
namespace llvm {
|
||||
|
||||
struct MemorySanitizerOptions {
|
||||
MemorySanitizerOptions() = default;
|
||||
MemorySanitizerOptions(int TrackOrigins, bool Recover, bool Kernel)
|
||||
: TrackOrigins(TrackOrigins), Recover(Recover), Kernel(Kernel) {}
|
||||
int TrackOrigins = 0;
|
||||
bool Recover = false;
|
||||
bool Kernel = false;
|
||||
MemorySanitizerOptions() : MemorySanitizerOptions(0, false, false){};
|
||||
MemorySanitizerOptions(int TrackOrigins, bool Recover, bool Kernel);
|
||||
bool Kernel;
|
||||
int TrackOrigins;
|
||||
bool Recover;
|
||||
};
|
||||
|
||||
// Insert MemorySanitizer instrumentation (detection of uninitialized reads)
|
||||
|
@ -462,16 +462,9 @@ namespace {
|
||||
/// the module.
|
||||
class MemorySanitizer {
|
||||
public:
|
||||
MemorySanitizer(Module &M, MemorySanitizerOptions Options) {
|
||||
this->CompileKernel =
|
||||
ClEnableKmsan.getNumOccurrences() > 0 ? ClEnableKmsan : Options.Kernel;
|
||||
if (ClTrackOrigins.getNumOccurrences() > 0)
|
||||
this->TrackOrigins = ClTrackOrigins;
|
||||
else
|
||||
this->TrackOrigins = this->CompileKernel ? 2 : Options.TrackOrigins;
|
||||
this->Recover = ClKeepGoing.getNumOccurrences() > 0
|
||||
? ClKeepGoing
|
||||
: (this->CompileKernel | Options.Recover);
|
||||
MemorySanitizer(Module &M, MemorySanitizerOptions Options)
|
||||
: CompileKernel(Options.Kernel), TrackOrigins(Options.TrackOrigins),
|
||||
Recover(Options.Recover) {
|
||||
initializeModule(M);
|
||||
}
|
||||
|
||||
@ -623,8 +616,17 @@ struct MemorySanitizerLegacyPass : public FunctionPass {
|
||||
MemorySanitizerOptions Options;
|
||||
};
|
||||
|
||||
template <class T> T getOptOrDefault(const cl::opt<T> &Opt, T Default) {
|
||||
return (Opt.getNumOccurrences() > 0) ? Opt : Default;
|
||||
}
|
||||
|
||||
} // end anonymous namespace
|
||||
|
||||
MemorySanitizerOptions::MemorySanitizerOptions(int TO, bool R, bool K)
|
||||
: Kernel(getOptOrDefault(ClEnableKmsan, K)),
|
||||
TrackOrigins(getOptOrDefault(ClTrackOrigins, Kernel ? 2 : TO)),
|
||||
Recover(getOptOrDefault(ClKeepGoing, Kernel || R)) {}
|
||||
|
||||
PreservedAnalyses MemorySanitizerPass::run(Function &F,
|
||||
FunctionAnalysisManager &FAM) {
|
||||
MemorySanitizer Msan(*F.getParent(), Options);
|
||||
|
Loading…
x
Reference in New Issue
Block a user