This is an archive of the discontinued LLVM Phabricator instance.

[msan] Allow using a MemorySanitizer instance for functions across different modules
Needs ReviewPublic

Authored by loladiro on Apr 9 2015, 8:36 PM.

Details

Reviewers
eugenis
Summary

We use MemorySanitizer in a JIT setting where we run all of our functions through a function pass manager to apply some of our own lowering passes before passing everything off to MCJIT. I tried adding MemorySanitizer to this setup, but the current implementation assumes that all functions MemorySanitizer will run on belong to the same module. Address this by reinitializing MemorySanitizer if the passed function is in a different module and looking or creating the correct globals in that module.

Diff Detail

Repository
rL LLVM

Event Timeline

loladiro updated this revision to Diff 23556.Apr 9 2015, 8:36 PM
loladiro retitled this revision from to [msan] Allow using a MemorySanitizer instance for functions across different modules.
loladiro updated this object.
loladiro edited the test plan for this revision. (Show Details)
loladiro added a reviewer: eugenis.
loladiro set the repository for this revision to rL LLVM.
loladiro added a subscriber: Unknown Object (MLST).
eugenis added inline comments.Apr 10 2015, 2:19 AM
lib/Transforms/Instrumentation/MemorySanitizer.cpp
370

Do we need to reinit C as well? What about things like DataLayout, TargetTriple (I'm looking at MemorySanitizer::doInitialization) etc? Where do we stop?

Perhaps it would be cleaner to detect the change of ModuleID and reinit everything?

eugenis edited edge metadata.Apr 10 2015, 3:27 AM

Is it possible to test this?

loladiro added inline comments.Apr 11 2015, 5:09 PM
lib/Transforms/Instrumentation/MemorySanitizer.cpp
370

Hmm, I'm not sure. This was the only changes I needed to make it work for my use case, which is a single FunctionPassManager running over all my Functions independent of which module they're in. That works fine for every pass but msan, but perhaps somebody more familiar with the pass manager can chime in here what the actual expectation for a function pass is.