Enable usage of AddressSanitizer and AddressModuleSanitizer ported from the legacy to the new PassManager.
This patch depends on https://reviews.llvm.org/D52739.
Differential D52814
[PassManager/Sanitizer] Enable usage of ported AddressSanitizer passes with -fsanitize=address leonardchan on Oct 2 2018, 4:53 PM. Authored by
Details
Enable usage of AddressSanitizer and AddressModuleSanitizer ported from the legacy to the new PassManager. This patch depends on https://reviews.llvm.org/D52739.
Diff Detail
Event TimelineComment Actions Is this the right place in the pipeline to put the passes? The legacy PM inserts the asan passes at EP_OptimizerLast, why not do the same thing?
Comment Actions I noticed this also and thought adding this using registerScalarOptimizerLateEPCallback was the initial correct way to add this function pass, but it seems that the vector of callbacks this gets added to (ScalarOptimizerLateEPCallbacks in buildFunctionSimplificationPipeline) doesn't get called unless some sort of optimization is requested (that is I run with -fexperimental-new-pass-manager -fsanitize=address -O1) when the sanitizer should still be applied even without optimization. We could force this pipeline to be run if we run PB.buildPerModuleDefaultPipeline()regardless of the optimization level, but I don't know why it's only called if optimization is zero.
Comment Actions You're right, my bad; I missed the fact that it's EP_OptimizerLast, which has no equivalent in the new PM. Your implementation is actually correct here. Did you run your test in a debug build? Comment Actions Yes, and I tested it on release also in case there were any differences between either builds. |
I dont believe CGSCC is appropriate here.
I would expect to see a simple ModuleToFunction adapter, something like this:
MPM.addPass(AddressSanitizerModulePass());
MPM.addPass(createModuleToFunctionPassAdaptor(AddressSanitizerFunctionPass())
Also, it seems that legacy runs Function sanitizer first and then Module sanitizer after it.
This sequence does it backwards. Is it intentional?