Page MenuHomePhabricator

[AA] Improve the BasicAA analysis capability base on GEP
AbandonedPublic

Authored by Allen on Sep 14 2022, 1:58 AM.

Details

Summary

Improved effectively for a constant offset GEP if the scalable index is same.

getelementptr <vscale x 4 x i32>, ptr %p, i64 1, i64 %i
getelementptr <vscale x 4 x i32>, ptr %p, i64 1, i64 %j

Diff Detail

Unit TestsFailed

TimeTest
60,030 msx64 debian > libFuzzer.libFuzzer::fuzzer-leak.test
Script: -- : 'RUN: at line 3'; /var/lib/buildkite-agent/builds/llvm-project/build/./bin/clang --driver-mode=g++ -O2 -gline-tables-only -fsanitize=address,fuzzer -I/var/lib/buildkite-agent/builds/llvm-project/compiler-rt/lib/fuzzer -m64 /var/lib/buildkite-agent/builds/llvm-project/compiler-rt/test/fuzzer/LeakTest.cpp -o /var/lib/buildkite-agent/builds/llvm-project/build/projects/compiler-rt/test/fuzzer/X86_64DefaultLinuxConfig/Output/fuzzer-leak.test.tmp-LeakTest

Event Timeline

Allen created this revision.Sep 14 2022, 1:58 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 14 2022, 1:58 AM
Allen requested review of this revision.Sep 14 2022, 1:58 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 14 2022, 1:58 AM
nikic requested changes to this revision.Sep 14 2022, 3:50 AM

If you want to support this, it must be part of GEP decomposition.

If you are only interested in constants for the vscale index, then it's probably possible to support this with relatively low effort by using a VariableGEPIndex with a vscale constant expression. That should allow all the existing modelling to handle it (possibly including range analysis based on vscale_range attributes).

If you are interested in variables for the vscale index, then this won't work, and it would be necessary to add first class vscale support to VariableGEPIndex (i.e. a separate bool, which all code working on decomposed GEPs has to handle in the appropriate way).

This revision now requires changes to proceed.Sep 14 2022, 3:50 AM
Allen updated this revision to Diff 463463.Sep 28 2022, 2:03 AM

Refactor in DecomposeGEPExpression

Allen added a comment.Oct 2 2022, 4:27 PM

If you want to support this, it must be part of GEP decomposition.

If you are only interested in constants for the vscale index, then it's probably possible to support this with relatively low effort by using a VariableGEPIndex with a vscale constant expression. That should allow all the existing modelling to handle it (possibly including range analysis based on vscale_range attributes).

If you are interested in variables for the vscale index, then this won't work, and it would be necessary to add first class vscale support to VariableGEPIndex (i.e. a separate bool, which all code working on decomposed GEPs has to handle in the appropriate way).

Thanks for your suggestion, Firstly I hope to address the constants vscale index only.

nikic added a comment.Oct 8 2022, 1:19 AM

I don't get how this patch is supposed to work. It seems to create a VariableGEPIndex -- but I don't see the vscale factor represented anywhere in there?

Worth noting that https://reviews.llvm.org/D134648 plans to make vscale non-constant, so making the use of vscale constant expressions is likely not going to be possible going forward...

Allen planned changes to this revision.Oct 11 2022, 1:33 AM

I don't get how this patch is supposed to work. It seems to create a VariableGEPIndex -- but I don't see the vscale factor represented anywhere in there?

Worth noting that https://reviews.llvm.org/D134648 plans to make vscale non-constant, so making the use of vscale constant expressions is likely not going to be possible going forward...

Thank @nikic for your guidance. It looks a little more complicated than I expected. Yes, this need more work as the vscale is non-constant in the whole project.

Allen abandoned this revision.Oct 15 2022, 7:36 AM