Page MenuHomePhabricator

[LoopInterchange] Prevent interchange when affine load result is branch condition
Needs ReviewPublic

Authored by geng on Nov 10 2020, 7:27 PM.

Details

Summary

This patch prevent the the loop interchanging when the affine load result is the branch condtions.

In the following case, the loop interchange will change store order of the global variable.

char b[][8] = {{}, {}, {}, {}, {5}, {}, 2, 3};

int c, d;

short e;

static char f() {

for (; c <= 7; c++) {

  d = 4;

  for (; d; d--)

    b[d + 2][c] && (e = b[d][0]);

}

}

We forbid these cases when control flow depends on the affine load value.

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
80 mslinux > LLVM.Transforms/LoopInterchange::affine-load-condition-no-interchange.ll
Script: -- : 'RUN: at line 2'; /mnt/disks/ssd0/agent/llvm-project/build/bin/opt < /mnt/disks/ssd0/agent/llvm-project/llvm/test/Transforms/LoopInterchange/affine-load-condition-no-interchange.ll -basicaa -loop-interchange -S -debug 2>&1 | /mnt/disks/ssd0/agent/llvm-project/build/bin/FileCheck /mnt/disks/ssd0/agent/llvm-project/llvm/test/Transforms/LoopInterchange/affine-load-condition-no-interchange.ll
310 mslinux > MemProfiler-x86_64-linux-dynamic.TestCases::test_terse.cpp
Script: -- : 'RUN: at line 5'; /mnt/disks/ssd0/agent/llvm-project/build/./bin/clang --driver-mode=g++ -fmemory-profile -mno-omit-leaf-frame-pointer -fno-omit-frame-pointer -fno-optimize-sibling-calls -gline-tables-only -m64 -shared-libsan -O0 /mnt/disks/ssd0/agent/llvm-project/compiler-rt/test/memprof/TestCases/test_terse.cpp -o /mnt/disks/ssd0/agent/llvm-project/build/projects/compiler-rt/test/memprof/X86_64LinuxDynamicConfig/TestCases/Output/test_terse.cpp.tmp
90 mswindows > LLVM.Transforms/LoopInterchange::affine-load-condition-no-interchange.ll
Script: -- : 'RUN: at line 2'; c:\ws\w32-1\llvm-project\premerge-checks\build\bin\opt.exe < C:\ws\w32-1\llvm-project\premerge-checks\llvm\test\Transforms\LoopInterchange\affine-load-condition-no-interchange.ll -basicaa -loop-interchange -S -debug 2>&1 | c:\ws\w32-1\llvm-project\premerge-checks\build\bin\filecheck.exe C:\ws\w32-1\llvm-project\premerge-checks\llvm\test\Transforms\LoopInterchange\affine-load-condition-no-interchange.ll

Event Timeline

geng created this revision.Nov 10 2020, 7:27 PM
Herald added a project: Restricted Project. · View Herald TranscriptNov 10 2020, 7:27 PM
geng requested review of this revision.Nov 10 2020, 7:27 PM
geng changed the visibility from "Public (No Login Required)" to "No One".Nov 10 2020, 11:03 PM
geng changed the visibility from "No One" to "Public (No Login Required)".Nov 12 2020, 12:37 AM