Page MenuHomePhabricator

[SVE][InstCombine] Fix TypeSize warning in canReplaceGEPIdxWithZero
ClosedPublic

Authored by joechrisellis on Oct 22 2020, 8:52 AM.

Details

Summary

The warning would fire when calling canReplaceGEPIdxWithZero on a GEP
whose source element type is a scalable vector. The size of scalable
vector types is not known, so this optimization cannot be performed.

This patch fixes the issue by:

  • bailing out early in this routine if the GEP instruction's source element type is a scalable vector.
  • making use of getFixedSize -- this removes the dependency on the deprecated interface.

Diff Detail

Unit TestsFailed

TimeTest
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
270 mswindows > lld.ELF/invalid::symtab-sh-info.s
Script: -- : 'RUN: at line 4'; c:\ws\w32-1\llvm-project\premerge-checks\build\bin\yaml2obj.exe --docnum=1 C:\ws\w32-1\llvm-project\premerge-checks\lld\test\ELF\invalid\symtab-sh-info.s -o C:\ws\w32-1\llvm-project\premerge-checks\build\tools\lld\test\ELF\invalid\Output\symtab-sh-info.s.tmp.o

Event Timeline

joechrisellis created this revision.Oct 22 2020, 8:52 AM
joechrisellis requested review of this revision.Oct 22 2020, 8:52 AM

Oops -- be sure to use getFixedSize.

fpetrogalli accepted this revision.Oct 23 2020, 6:22 AM

LGTM! Thanks.

This revision is now accepted and ready to land.Oct 23 2020, 6:22 AM
This revision was landed with ongoing or failed builds.Oct 26 2020, 10:41 AM
This revision was automatically updated to reflect the committed changes.
sdesmalen added inline comments.
llvm/test/Transforms/InstCombine/gep-can-replace-gep-idx-with-zero-typesize.ll
2

You should make the tests more specific than running with -O2 because it is not explicitly defined what passes are run at -O2 In this case you're fixing InstCombine, so the test should use opt -S -instcombine.