[PATCH] D81323: Move *San module passes later in the NPM pipeline
Arthur Eubanks via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Jun 5 18:27:19 PDT 2020
aeubanks created this revision.
aeubanks added reviewers: leonardchan, vitalybuka.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
This fixes pr33372.cpp under the new pass manager.
ASan adds padding to globals. For example, it will change a {i32, i32, i32} to a {{i32, i32, i32}, [52 x i8]}. However, when loading from the {i32, i32, i32}, InstCombine may (after various optimizations) end up loading 16 bytes instead of 12, likely because it thinks the [52 x i8] padding is ok to load from. But ASan checks that padding should not be loaded from.
Ultimately this is an issue of *San passes wanting to be run after all optimizations. This change moves the module passes right next to the corresponding function passes.
Also remove comment that's no longer relevant, this is the last ASan/MSan/TSan failure under the NPM (hopefully...).
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D81323
Files:
clang/lib/CodeGen/BackendUtil.cpp
Index: clang/lib/CodeGen/BackendUtil.cpp
===================================================================
--- clang/lib/CodeGen/BackendUtil.cpp
+++ clang/lib/CodeGen/BackendUtil.cpp
@@ -1265,7 +1265,6 @@
// Register callbacks to schedule sanitizer passes at the appropriate part of
// the pipeline.
- // FIXME: either handle asan/the remaining sanitizers or error out
if (LangOpts.Sanitize.has(SanitizerKind::LocalBounds))
PB.registerScalarOptimizerLateEPCallback(
[](FunctionPassManager &FPM, PassBuilder::OptimizationLevel Level) {
@@ -1288,48 +1287,38 @@
if (LangOpts.Sanitize.has(SanitizerKind::Memory)) {
int TrackOrigins = CodeGenOpts.SanitizeMemoryTrackOrigins;
bool Recover = CodeGenOpts.SanitizeRecover.has(SanitizerKind::Memory);
- PB.registerPipelineStartEPCallback(
- [TrackOrigins, Recover](ModulePassManager &MPM) {
- MPM.addPass(MemorySanitizerPass({TrackOrigins, Recover, false}));
- });
PB.registerOptimizerLastEPCallback(
[TrackOrigins, Recover](ModulePassManager &MPM,
PassBuilder::OptimizationLevel Level) {
+ MPM.addPass(MemorySanitizerPass({TrackOrigins, Recover, false}));
MPM.addPass(createModuleToFunctionPassAdaptor(
MemorySanitizerPass({TrackOrigins, Recover, false})));
});
}
if (LangOpts.Sanitize.has(SanitizerKind::Thread)) {
- PB.registerPipelineStartEPCallback(
- [](ModulePassManager &MPM) { MPM.addPass(ThreadSanitizerPass()); });
PB.registerOptimizerLastEPCallback(
[](ModulePassManager &MPM, PassBuilder::OptimizationLevel Level) {
+ MPM.addPass(ThreadSanitizerPass());
MPM.addPass(
createModuleToFunctionPassAdaptor(ThreadSanitizerPass()));
});
}
if (LangOpts.Sanitize.has(SanitizerKind::Address)) {
- PB.registerPipelineStartEPCallback([&](ModulePassManager &MPM) {
- MPM.addPass(
- RequireAnalysisPass<ASanGlobalsMetadataAnalysis, Module>());
- });
bool Recover = CodeGenOpts.SanitizeRecover.has(SanitizerKind::Address);
bool UseAfterScope = CodeGenOpts.SanitizeAddressUseAfterScope;
- PB.registerOptimizerLastEPCallback(
- [Recover, UseAfterScope](ModulePassManager &MPM,
- PassBuilder::OptimizationLevel Level) {
- MPM.addPass(
- createModuleToFunctionPassAdaptor(AddressSanitizerPass(
- /*CompileKernel=*/false, Recover, UseAfterScope)));
- });
bool ModuleUseAfterScope = asanUseGlobalsGC(TargetTriple, CodeGenOpts);
bool UseOdrIndicator = CodeGenOpts.SanitizeAddressUseOdrIndicator;
- PB.registerPipelineStartEPCallback(
- [Recover, ModuleUseAfterScope,
- UseOdrIndicator](ModulePassManager &MPM) {
+ PB.registerOptimizerLastEPCallback(
+ [Recover, UseAfterScope, ModuleUseAfterScope, UseOdrIndicator](
+ ModulePassManager &MPM, PassBuilder::OptimizationLevel Level) {
+ MPM.addPass(
+ RequireAnalysisPass<ASanGlobalsMetadataAnalysis, Module>());
MPM.addPass(ModuleAddressSanitizerPass(
/*CompileKernel=*/false, Recover, ModuleUseAfterScope,
UseOdrIndicator));
+ MPM.addPass(
+ createModuleToFunctionPassAdaptor(AddressSanitizerPass(
+ /*CompileKernel=*/false, Recover, UseAfterScope)));
});
}
if (Optional<GCOVOptions> Options = getGCOVOptions(CodeGenOpts))
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D81323.268982.patch
Type: text/x-patch
Size: 3781 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200606/b3f6d7c6/attachment-0001.bin>
More information about the cfe-commits
mailing list