This is an archive of the discontinued LLVM Phabricator instance.

[ASan] Workaround for a performance problem in StackSafetyAnalysis pass.
AbandonedPublic

Authored by kstoimenov on Sep 27 2022, 3:14 PM.

Details

Reviewers
vitalybuka
Summary

There is a performance problem in StackLifetime::calculateLocalLiveness when a function has a lot of allocas. The stack-safety-max-allocas flag prevents this algorithm from being invoked for such functions.

Diff Detail

Event Timeline

kstoimenov created this revision.Sep 27 2022, 3:14 PM
Herald added a project: Restricted Project. · View Herald TranscriptSep 27 2022, 3:14 PM
Herald added a subscriber: hiraditya. · View Herald Transcript
kstoimenov requested review of this revision.Sep 27 2022, 3:14 PM
Herald added a project: Restricted Project. · View Herald TranscriptSep 27 2022, 3:14 PM
kstoimenov retitled this revision from [ASan] Workaround for a performance problem in StackLifetime::calculateLocalLiveness. The stack-safety-max-allocas flag prevents the algorithm from being invoked for functions with a lot of allocas. to [ASan] Workaround for a performance problem in StackSafetyAnalysis pass. .Sep 27 2022, 3:16 PM
kstoimenov edited the summary of this revision. (Show Details)
vitalybuka added inline comments.Sep 27 2022, 3:35 PM
llvm/test/Instrumentation/AddressSanitizer/asan-stack-safety.ll
3 ↗(On Diff #463348)

don't break lines, line len is not enforced in tests

7 ↗(On Diff #463348)

you are fixing StackSafetyAnalysis.cpp, so the test must be in those tests

vitalybuka added inline comments.Sep 27 2022, 3:37 PM
llvm/lib/Analysis/StackSafetyAnalysis.cpp
62

int is enough

kstoimenov marked an inline comment as done.
kstoimenov retitled this revision from [ASan] Workaround for a performance problem in StackSafetyAnalysis pass. to [ASan] Workaround for a performance problem in StackSafetyAnalysis pass..

Addressed comments.

llvm/lib/Analysis/StackSafetyAnalysis.cpp
62

Yeah, but it produces a warning when I compare it with .size().

llvm/test/Instrumentation/AddressSanitizer/asan-stack-safety.ll
3 ↗(On Diff #463348)

I prefer that for readability.

vitalybuka added inline comments.Sep 27 2022, 4:57 PM
llvm/test/Analysis/StackSafetyAnalysis/stack-safety-max-allocas.ll
1

not needed?

3

broken lines hard to read when you have many of them, all RUNs looks the same them
long lines not nice in some editors, but very convenient to compare RUNs

so I prefer long RUN line exactly for readability

3

instead of asan please directly use the pass: -passes="print-stack-safety"

example local.ll

4

can you do at least =1 and have one function with 1 and one function with 2 allocas

vitalybuka added inline comments.Sep 27 2022, 4:59 PM
llvm/test/Analysis/StackSafetyAnalysis/stack-safety-max-allocas.ll
3

it changes function local part, so please check -passes="print<stack-safety-local>"as well

I guess I understand the problem. Algorithm is O(A*B*B) for ::Must case, where A-num allocas, B is num of basic blocks. But it should be O(A*B) as of ::May case.
ll try to create a patch.

If we do a limiter, it should be by B.

kstoimenov abandoned this revision.Sep 30 2022, 1:26 PM
kstoimenov marked 4 inline comments as done.