Page MenuHomePhabricator

[SelectionDAG] Avoid aliasing analysis if the object size is unknown.

Authored by HsiangKai on Nov 19 2020, 5:22 PM.



If the size of memory access is unknown, do not use it to analysis. One example of unknown size memory access is to load/store scalable vector objects on the stack.

Diff Detail

Unit TestsFailed

390 mslinux > HWAddressSanitizer-x86_64.TestCases::sizes.cpp
Script: -- : 'RUN: at line 3'; /mnt/disks/ssd0/agent/llvm-project/build/./bin/clang --driver-mode=g++ -m64 -gline-tables-only -fsanitize=hwaddress -fuse-ld=lld -mcmodel=large -mllvm -hwasan-globals -mllvm -hwasan-use-short-granules -mllvm -hwasan-instrument-landing-pads=0 -mllvm -hwasan-instrument-personality-functions /mnt/disks/ssd0/agent/llvm-project/compiler-rt/test/hwasan/TestCases/sizes.cpp -nostdlib++ -lstdc++ -o /mnt/disks/ssd0/agent/llvm-project/build/projects/compiler-rt/test/hwasan/X86_64/TestCases/Output/sizes.cpp.tmp
70 mslinux > LLVM.Transforms/LowerMatrixIntrinsics::multiply-minimal.ll
Script: -- : 'RUN: at line 2'; /mnt/disks/ssd0/agent/llvm-project/build/bin/opt -lower-matrix-intrinsics-minimal -fuse-matrix-tile-size=2 -matrix-allow-contract -force-fuse-matrix -instcombine -verify-dom-info /mnt/disks/ssd0/agent/llvm-project/llvm/test/Transforms/LowerMatrixIntrinsics/multiply-minimal.ll -S | /mnt/disks/ssd0/agent/llvm-project/build/bin/FileCheck /mnt/disks/ssd0/agent/llvm-project/llvm/test/Transforms/LowerMatrixIntrinsics/multiply-minimal.ll
140 mswindows > LLVM.Transforms/LowerMatrixIntrinsics::multiply-minimal.ll
Script: -- : 'RUN: at line 2'; c:\ws\w16n2-1\llvm-project\premerge-checks\build\bin\opt.exe -lower-matrix-intrinsics-minimal -fuse-matrix-tile-size=2 -matrix-allow-contract -force-fuse-matrix -instcombine -verify-dom-info C:\ws\w16n2-1\llvm-project\premerge-checks\llvm\test\Transforms\LowerMatrixIntrinsics\multiply-minimal.ll -S | c:\ws\w16n2-1\llvm-project\premerge-checks\build\bin\filecheck.exe C:\ws\w16n2-1\llvm-project\premerge-checks\llvm\test\Transforms\LowerMatrixIntrinsics\multiply-minimal.ll

Event Timeline

HsiangKai created this revision.Nov 19 2020, 5:22 PM
Herald added a project: Restricted Project. · View Herald TranscriptNov 19 2020, 5:22 PM
HsiangKai requested review of this revision.Nov 19 2020, 5:22 PM
HsiangKai updated this revision to Diff 306576.Nov 19 2020, 5:57 PM

clang format.

Thanks, could you please add a unit test for this ?

niravd requested changes to this revision.Nov 20 2020, 6:42 AM
This revision now requires changes to proceed.Nov 20 2020, 6:42 AM
niravd added inline comments.Nov 20 2020, 6:44 AM

This is too aggressive. We can still determine that a two addresses are non-aliasing even if one is unknown size. (e.g. FrameIndex vs. Global)

HsiangKai added inline comments.Nov 22 2020, 7:30 PM

The checking is under the condition that BasePtr0.equalBaseIndex(BasePtr1, ...) equals true. It would not be the case you considered.

HsiangKai updated this revision to Diff 306984.Nov 23 2020, 1:32 AM

Add unit tests.

niravd added inline comments.Nov 23 2020, 6:10 AM

What about the case where equalBaseIndex returns true, and the lowered addressed access has a known size smaller than the difference? In that case, we should be able to determine that they are do not alias.

HsiangKai added inline comments.Nov 23 2020, 7:20 PM

I doubt there is a such scenario to share the same base between fixed and scalable types. I could add an assertion here.

HsiangKai added inline comments.Nov 23 2020, 11:07 PM

I could not exclude the case that one fixed object is fixed length type and another fixed object is scalable vector type. Sorry for that. I will update the patch.

dmgreen added a subscriber: nikic.Nov 23 2020, 11:51 PM
niravd accepted this revision.Nov 24 2020, 6:31 AM

LGTM modulo minor nit. Thanks!


nit: These bools are single use and can be inlined.

This revision is now accepted and ready to land.Nov 24 2020, 6:31 AM