This is an archive of the discontinued LLVM Phabricator instance.

[ASan] Process functions in Asan module pass
ClosedPublic

Authored by kstoimenov on Oct 28 2021, 9:45 AM.

Diff Detail

Event Timeline

kstoimenov created this revision.Oct 28 2021, 9:45 AM
kstoimenov requested review of this revision.Oct 28 2021, 9:45 AM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptOct 28 2021, 9:45 AM

Removed unrelated files.

kstoimenov edited the summary of this revision. (Show Details)

Reverted pass builder.

Added AddressSanitizerOptions back.

kstoimenov planned changes to this revision.Oct 28 2021, 10:43 AM

Tests are not passing. Hold off the review.

Tests are not passing. Hold off the review.

Yep, removed FUNCTION_PASS_WITH_PARAMS("asan", must affect some tests

llvm/include/llvm/Transforms/Instrumentation/AddressSanitizer.h
113 ↗(On Diff #383072)

please run check-all
it was used in as well llvm-project/llvm/tools/opt/NewPMDriver.cpp

llvm/lib/Passes/PassRegistry.def
396 ↗(On Diff #383072)

you should also rename MODULE_PASS_WITH_PARAMS("asan-module", to just MODULE_PASS_WITH_PARAMS("asan",

kstoimenov marked 2 inline comments as done.

Fixed test failures and crashes.

kstoimenov added inline comments.Oct 29 2021, 4:55 PM
llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
1315

At first I had module sanitizer run first, but some tests failed. Is it possible that the function pass has some side effects, which are used by the module pass?

2857

This was a pain to figure out. Maybe we should apply the same check in HWAsan?

kstoimenov updated this revision to Diff 383819.Nov 1 2021, 9:17 AM

Fixed remaing 2 tests.

vitalybuka added inline comments.Nov 1 2021, 11:38 AM
llvm/include/llvm/Transforms/Instrumentation/AddressSanitizer.h
92 ↗(On Diff #383819)

Why do we need to remove AddressSanitizerOptions?

llvm/lib/Passes/PassRegistry.def
139 ↗(On Diff #383819)

And I guess now we need to use parseASanPassOptions here?

396 ↗(On Diff #383072)

I still see asan-module here

kstoimenov updated this revision to Diff 383921.Nov 1 2021, 4:38 PM
kstoimenov marked an inline comment as done.

Update after discussing with vitalybuka@.

kstoimenov added inline comments.Nov 1 2021, 4:40 PM
llvm/include/llvm/Transforms/Instrumentation/AddressSanitizer.h
92 ↗(On Diff #383819)

Adding it back in as discussed offline.

llvm/lib/Passes/PassRegistry.def
139 ↗(On Diff #383819)

I must have reverted by an accident. Should be done now.

146 ↗(On Diff #383819)

I think parseModuleAddressSanitizerPassOptions does exactly the same thing as parseASanPassOptions, which is to look for the "kernel" param.

vitalybuka retitled this revision from [ASan] Removed AddressSanitizerPass function pass class and rolled it into the module pass for the new pass mangager only. to [ASan] Process functions in Asan module pass as well.Nov 2 2021, 5:25 PM
vitalybuka retitled this revision from [ASan] Process functions in Asan module pass as well to [ASan] Process functions in Asan module pass.
vitalybuka accepted this revision.Nov 2 2021, 7:14 PM

Lets keep AddressSanitizerPass for a while, we don't have to remove it in the same patch

llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
1315

That's OK.

NewPMDriver.cpp was wrong, BackendUtil.cpp was wrong

if we put module in-front of function the following with disable globals instrumentation:

if (G && (!ClInitializers || GlobalIsLinkerInitialized(G)) &&
       isSafeAccess(ObjSizeVis, Addr, O.TypeSize)) {
2857

I looks like should be the first "if" in the function

This revision is now accepted and ready to land.Nov 2 2021, 7:15 PM
kstoimenov updated this revision to Diff 384465.Nov 3 2021, 8:45 AM

Moved module instumentation back ahead of function instrumentation.

kstoimenov updated this revision to Diff 384467.Nov 3 2021, 8:47 AM

Moved empty check to the top of the function.

kstoimenov updated this revision to Diff 384488.Nov 3 2021, 9:29 AM
kstoimenov marked 3 inline comments as done.

Moved module after function.

After rebase.

This revision was landed with ongoing or failed builds.Nov 3 2021, 10:51 AM
This revision was automatically updated to reflect the committed changes.
rupprecht added inline comments.
clang/lib/CodeGen/BackendUtil.cpp
1190

I'm seeing build errors here, and I'm not sure what this is supposed to be?

/home/rupprecht/src/llvm-project/clang/lib/CodeGen/BackendUtil.cpp:1189:37: error: use of undeclared identifier 'ModuleUseAfterScope'; did you mean 'UseAfterScope'?
            CompileKernel, Recover, ModuleUseAfterScope, UseOdrIndicator,
                                    ^~~~~~~~~~~~~~~~~~~
                                    UseAfterScope

https://buildkite.com/llvm-project/upstream-bazel-rbe/builds/11193#bbebbf99-a2c1-4959-b6f7-f7fb816591c0

rupprecht added inline comments.Nov 3 2021, 11:05 AM
clang/lib/CodeGen/BackendUtil.cpp
1190

I see it was reverted already, sorry!

kstoimenov added inline comments.Nov 3 2021, 11:08 AM
clang/lib/CodeGen/BackendUtil.cpp
1190

Sorry about breaking the build. I can't understand how my local tests passed. Functions with a long list of boolean params are so error prone. The downside of not using the builder pattern :-(

vitalybuka reopened this revision.Nov 3 2021, 11:18 AM
This revision is now accepted and ready to land.Nov 3 2021, 11:18 AM

After merging D113072.

vitalybuka accepted this revision.Nov 3 2021, 11:45 AM
This revision was automatically updated to reflect the committed changes.

can we rename "asan-module" to "asan" after this change? and remove the extra "asan-pipeline"/"asan-function-pipeline" parsing callbacks in NewPMDriver.cpp? and previously we had -passes=require<asan-globals-md> because a function pass couldn't invoke a module analysis, but that's no longer relevant, so cleaning those up from RUN lines would also be good

vitalybuka added inline comments.Nov 4 2021, 11:46 AM
llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
1315

Fixing typo in the comment.

NewPMDriver.cpp was wrong, BackendUtil.cpp was wrong

NewPMDriver.cpp was correct, BackendUtil.cpp was wrong

can we rename "asan-module" to "asan" after this change? and remove the extra "asan-pipeline"/"asan-function-pipeline" parsing callbacks in NewPMDriver.cpp? and previously we had -passes=require<asan-globals-md> because a function pass couldn't invoke a module analysis, but that's no longer relevant, so cleaning those up from RUN lines would also be good

That was idea, but I changed my mind and recommended to do that in a separate patch.