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
520 mslinux > AddressSanitizer-x86_64-linux.TestCases::strcmp.c
Script: -- : 'RUN: at line 1'; /mnt/disks/ssd0/agent/llvm-project/build/./bin/clang -fsanitize=address -mno-omit-leaf-frame-pointer -fno-omit-frame-pointer -fno-optimize-sibling-calls -gline-tables-only -m64 /mnt/disks/ssd0/agent/llvm-project/compiler-rt/test/asan/TestCases/strcmp.c -o /mnt/disks/ssd0/agent/llvm-project/build/projects/compiler-rt/test/asan/X86_64LinuxConfig/TestCases/Output/strcmp.c.tmp
380 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

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.