Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invariant load hoisting causes LNT miscompiles #29355

Open
tobiasgrosser opened this issue Aug 15, 2016 · 2 comments
Open

Invariant load hoisting causes LNT miscompiles #29355

tobiasgrosser opened this issue Aug 15, 2016 · 2 comments
Labels
bugzilla Issues migrated from bugzilla polly

Comments

@tobiasgrosser
Copy link
Contributor

Bugzilla Link 28985
Version unspecified
OS Linux
CC @jdoerfert

Extended Description

With 278673 -polly -polly-process-unprofitable LNT shows the following miscompile:

FAIL: lencod.execution_time

This miscompile disappears when disabling invariant load hoisting. It is not yet confirmed that this is due to invariant load hoisting. More investigation is needed to confirm this.

@tobiasgrosser
Copy link
Contributor Author

I managed to pinpoint further. LNT fails with the following command line:

mysandbox/bin/lnt runtest nt --sandbox /tmp/bar --cc /home/grosser/Projects/polly/build/bin/clang --cxx /home/grosser/Projects/polly/build/bin/clang++ --test-suite test-suite/ -j4 --only-test MultiSource/Applications/JM/lencod --mllvm=-polly --multisample=1 --mllvm=-polly-process-unprofitable --mllvm=-polly-invariant-load-hoisting --mllvm=-debug-only=polly-scops --mllvm=-polly-only-func=dct_luma_16x16 --mllvm=-polly-only-region=for.body32

The scop in question has the following invariant loads:

Function: dct_luma_16x16
Region: %for.body32---%for.inc64
Max Loop Depth:  1
Invariant Accesses: {
        ReadAccess :=	[Reduction Type: NONE] [Scalar: 0]
            [p_0, p_1, p_2, p_3, new_intra_mode, p_5] -> { Stmt_for_body32[i0] -> MemRef_imgY_org[0] };
        Execution Context: [p_0, p_1, p_2, p_3, new_intra_mode, p_5] -> {  :  }
        ReadAccess :=	[Reduction Type: NONE] [Scalar: 0]
            [p_0, p_1, p_2, p_3, new_intra_mode, p_5] -> { Stmt_for_body32[i0] -> MemRef_27[o0] : 96 <= o0 <= 97 };
        Execution Context: [p_0, p_1, p_2, p_3, new_intra_mode, p_5] -> {  : 1 = 0 }
        ReadAccess :=	[Reduction Type: NONE] [Scalar: 0]
            [p_0, p_1, p_2, p_3, new_intra_mode, p_5] -> { Stmt_for_body32[i0] -> MemRef_32[p_0 + p_1] };
        Execution Context: [p_0, p_1, p_2, p_3, new_intra_mode, p_5] -> {  : 1 = 0 }
}

Interestingly, the scop itself just consists of a single basic block, which is always executed at least once. So the only situation under which the execution context could be empty without us loading garbage from memory is a situation where we fall back to the original code. However, the run-time check only contains (besides the alias checks) a couple of overflow conditions that are unlikely to trigger:

0 == (p_0 + p_1 <= -2147483649 || p_0 + p_1 >= 2147483648 || p_2 >= 2147483633 || p_0 <= -1)

#29354 showed also an empty execution context, such that the fix we applied at this point (https://llvm.org/svn/llvm-project/polly/trunk@279047) could have caused a regression here. However, I confirmed this is not the case, as the empty execution context remains even with r279047 reverted.

https://llvm.org/svn/llvm-project/polly/trunk@279047

@tobiasgrosser
Copy link
Contributor Author

With r286781 we see at the following compile-time crash:

#​1 0x00007fd8d41d2626 SignalHandler(int) (/home/grosser/.data-unbackupped/polly-build/bin/../lib/libLLVMSupport.so.40+0xf1626)
#​2 0x00007fd8d76d4670 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x11670)
#​3 0x00007fd8d1e7b7ef gsignal /build/glibc-DfDqKW/glibc-2.24/signal/../sysdeps/unix/sysv/linux/raise.c:58:0
#​4 0x00007fd8d1e7d3ea abort /build/glibc-DfDqKW/glibc-2.24/stdlib/abort.c:91:0
#​5 0x00007fd8d1e73bb7 __assert_fail_base /build/glibc-DfDqKW/glibc-2.24/assert/assert.c:92:0
#​6 0x00007fd8d1e73c62 (/lib/x86_64-linux-gnu/libc.so.6+0x2dc62)
#​7 0x00007fd8d5f53a0b polly::Scop::getNonHoistableCtx(polly::MemoryAccess*, isl_union_map*) (/home/grosser/.data-unbackupped/polly-build/bin/../lib/libPolly.so+0x86a0b)
#​8 0x00007fd8d5f56ef3 polly::Scop::hoistInvariantLoads() (/home/grosser/.data-unbackupped/polly-build/bin/../lib/libPolly.so+0x89ef3)
#​9 0x00007fd8d5f55e5f polly::Scop::init(llvm::AAResults&, llvm::AssumptionCache&, llvm::DominatorTree&, llvm::LoopInfo&) (/home/grosser/.data-unbackupped/polly-build/bin/../lib/libPolly.so+0x88e5f)
#​10 0x00007fd8d5f6e0fb polly::ScopBuilder::buildScop(llvm::Region&, llvm::AssumptionCache&) (/home/grosser/.data-unbackupped/polly-build/bin/../lib/libPolly.so+0xa10fb)
#​11 0x00007fd8d5f6e3b0 polly::ScopBuilder::ScopBuilder(llvm::Region*, llvm::AssumptionCache&, llvm::AAResults&, llvm::DataLayout const&, llvm::DominatorTree&, llvm::LoopInfo&, polly::ScopDetection&, llvm::ScalarEvolution&) (/home/grosser/.data-unbackupped/polly-build/bin/../lib/libPolly.so+0xa13b0)
#​12 0x00007fd8d5f5ccb4 polly::ScopInfoRegionPass::runOnRegion(llvm::Region*, llvm::RGPassManager&) (/home/grosser/.data-unbackupped/polly-build/bin/../lib/libPolly.so+0x8fcb4)
#​13 0x00007fd8d5af944f llvm::RGPassManager::runOnFunction(llvm::Function&) (/home/grosser/.data-unbackupped/polly-build/bin/../lib/libLLVMAnalysis.so.40+0x1d144f)

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla polly
Projects
None yet
Development

No branches or pull requests

1 participant