Page MenuHomePhabricator

[GlobalISel] Fix enumeration of entry basic blocks when using GlobalISel

Authored by matejam on Sep 18 2020, 6:45 AM.



IRTranslator's method runOnMachineFunction is used to translate from IR to MIR when using GlobalISel as an instruction selector.
When all IR instructions are translated, we move all the instructions from the current entry block to it's only successor, which leaves the current entry block empty and useless, we then delete it from the machine function.
The only issue is that the surviving entry block's number is greater by 1 than the minimal entry block number, which is fixed by assigning the number of the deleted entry block to the surviving entry block's number.
Entry blocks should be serialized (starting from 0) so that an entry block's number wouldn't be greater than the size of the machine function (number of entry blocks in the MF) in which it resides.
Specifically an error will occur in MIRParserImpl::initializeCallSiteInfo when asked if the call site's block number (1 without this patch, 0 with this patch) is greater or equal to the number of entry blocks (1, because the second entry block has been removed).

Diff Detail

Unit TestsFailed

390 mslinux > Clang.OpenMP::declare_simd_aarch64_warning_advsimd.c
Script: -- : 'RUN: at line 2'; /mnt/disks/ssd0/agent/llvm-project/build/bin/clang -cc1 -internal-isystem /mnt/disks/ssd0/agent/llvm-project/build/lib/clang/12.0.0/include -nostdsysteminc -triple aarch64-linux-gnu -target-feature +neon -fopenmp /mnt/disks/ssd0/agent/llvm-project/clang/test/OpenMP/declare_simd_aarch64_warning_advsimd.c -S -o /mnt/disks/ssd0/agent/llvm-project/build/tools/clang/test/OpenMP/Output/declare_simd_aarch64_warning_advsimd.c.tmp -verify
400 mslinux > Clang.OpenMP::declare_simd_aarch64_warning_sve.c
Script: -- : 'RUN: at line 2'; /mnt/disks/ssd0/agent/llvm-project/build/bin/clang -cc1 -internal-isystem /mnt/disks/ssd0/agent/llvm-project/build/lib/clang/12.0.0/include -nostdsysteminc -triple aarch64-linux-gnu -target-feature +sve -fopenmp /mnt/disks/ssd0/agent/llvm-project/clang/test/OpenMP/declare_simd_aarch64_warning_sve.c -S -o /mnt/disks/ssd0/agent/llvm-project/build/tools/clang/test/OpenMP/Output/declare_simd_aarch64_warning_sve.c.tmp -verify
380 mslinux > LLVM.CodeGen/AArch64::addsub-shifted.ll
Script: -- : 'RUN: at line 1'; /mnt/disks/ssd0/agent/llvm-project/build/bin/llc -debugify-and-strip-all-safe -verify-machineinstrs /mnt/disks/ssd0/agent/llvm-project/llvm/test/CodeGen/AArch64/addsub-shifted.ll -o - -mtriple=arm64-apple-ios7.0 | /mnt/disks/ssd0/agent/llvm-project/build/bin/FileCheck /mnt/disks/ssd0/agent/llvm-project/llvm/test/CodeGen/AArch64/addsub-shifted.ll
380 mslinux > LLVM.CodeGen/AArch64::addsub_ext.ll
Script: -- : 'RUN: at line 1'; /mnt/disks/ssd0/agent/llvm-project/build/bin/llc -debugify-and-strip-all-safe -enable-machine-outliner=never -verify-machineinstrs /mnt/disks/ssd0/agent/llvm-project/llvm/test/CodeGen/AArch64/addsub_ext.ll -o - -mtriple=aarch64-linux-gnu -aarch64-enable-atomic-cfg-tidy=0 | /mnt/disks/ssd0/agent/llvm-project/build/bin/FileCheck /mnt/disks/ssd0/agent/llvm-project/llvm/test/CodeGen/AArch64/addsub_ext.ll
250 mslinux > LLVM.CodeGen/AArch64::arm64-call-tailcalls.ll
Script: -- : 'RUN: at line 1'; /mnt/disks/ssd0/agent/llvm-project/build/bin/llc < /mnt/disks/ssd0/agent/llvm-project/llvm/test/CodeGen/AArch64/arm64-call-tailcalls.ll -mtriple=arm64-apple-ios7.0 | /mnt/disks/ssd0/agent/llvm-project/build/bin/FileCheck /mnt/disks/ssd0/agent/llvm-project/llvm/test/CodeGen/AArch64/arm64-call-tailcalls.ll
View Full Test Results (494 Failed)

Event Timeline

matejam created this revision.Sep 18 2020, 6:45 AM
matejam requested review of this revision.Sep 18 2020, 6:45 AM

Why is a new entry block added in the first place?


stop-after=irtranslator. This also doesn't need to use a temporary file and should directly pipe to FIleCheck


Remove these and move triple to llc argument list


Remove these comments


Don't need this metadata

LGTM, thanks. The motivation is D87903?

djtodoro requested changes to this revision.Sep 18 2020, 7:03 AM

Please investigate the test failures.
($ make check-all)

This revision now requires changes to proceed.Sep 18 2020, 7:03 AM
matejam abandoned this revision.Oct 1 2020, 4:45 AM