This is an archive of the discontinued LLVM Phabricator instance.

[InstCombine] Preserve inbounds when merging with zero-index GEP (PR44423)
ClosedPublic

Authored by nikic on Jan 1 2020, 1:18 PM.

Details

Summary

This addresses https://bugs.llvm.org/show_bug.cgi?id=44423. If one of the GEPs is inbounds and the other is zero-index, we can also preserve inbounds.

Diff Detail

Event Timeline

nikic created this revision.Jan 1 2020, 1:18 PM
Herald added a project: Restricted Project. · View Herald TranscriptJan 1 2020, 1:18 PM
nikic retitled this revision from [InstCombine] Preseve inbounds when merging with zero-index GEP (PR44423) to [InstCombine] Preserve inbounds when merging with zero-index GEP (PR44423).
lebedev.ri accepted this revision.Jan 1 2020, 1:59 PM
This revision is now accepted and ready to land.Jan 1 2020, 1:59 PM
This revision was automatically updated to reflect the committed changes.

Bisecting identifies this change as breaking stage two testing on my Fedora 31 machine. Can we revert this?

FAIL: LLVM :: Transforms/Attributor/liveness.ll (44058 of 60349)
******************** TEST 'LLVM :: Transforms/Attributor/liveness.ll' FAILED ********************
Script:
--
: 'RUN: at line 2';   /tmp/_update_lc/t/bin/opt -attributor --attributor-disable=false -attributor-max-iterations-verify -attributor-annotate-decl-cs -attributor-max-iterations=4 -S < /home/dave/s/lp/llvm/test/Transforms/Attributor/liveness.ll | /tmp/_update_lc/t/bin/FileCheck /home/dave/s/lp/llvm/test/Transforms/Attributor/liveness.ll --check-prefixes=CHECK,OLDPM
: 'RUN: at line 3';   /tmp/_update_lc/t/bin/opt -passes=attributor --attributor-disable=false -attributor-max-iterations-verify -attributor-annotate-decl-cs -attributor-max-iterations=4 -S < /home/dave/s/lp/llvm/test/Transforms/Attributor/liveness.ll | /tmp/_update_lc/t/bin/FileCheck /home/dave/s/lp/llvm/test/Transforms/Attributor/liveness.ll --check-prefixes=CHECK,NEWPM
--
Exit Code: 2

Command Output (stderr):
--
opt: /home/dave/s/lp/llvm/lib/Transforms/IPO/Attributor.cpp:6475: llvm::ChangeStatus llvm::Attributor::rewriteFunctionSignatures(): Assertion `OldFn->getNumUses() == 0 && "Unexpected leftover uses!"' failed.
Stack dump:
0.  Program arguments: /tmp/_update_lc/t/bin/opt -attributor --attributor-disable=false -attributor-max-iterations-verify -attributor-annotate-decl-cs -attributor-max-iterations=4 -S
1.  Running pass 'Deduce and propagate attributes' on module '<stdin>'.
 #0 0x00000000023d387f llvm::sys::PrintStackTrace(llvm::raw_ostream&) (/tmp/_update_lc/t/bin/opt+0x23d387f)
 #1 0x00000000023d1ad2 llvm::sys::RunSignalHandlers() (/tmp/_update_lc/t/bin/opt+0x23d1ad2)
 #2 0x00000000023d3e05 SignalHandler(int) (/tmp/_update_lc/t/bin/opt+0x23d3e05)
 #3 0x00007ffff7fa8b20 __restore_rt (/lib64/libpthread.so.0+0x14b20)
 #4 0x00007ffff616d625 raise (/lib64/libc.so.6+0x3c625)
 #5 0x00007ffff61568d9 abort (/lib64/libc.so.6+0x258d9)
 #6 0x00007ffff61567a9 _nl_load_domain.cold (/lib64/libc.so.6+0x257a9)
 #7 0x00007ffff6165a66 (/lib64/libc.so.6+0x34a66)
 #8 0x0000000001dc276c llvm::Attributor::rewriteFunctionSignatures() (/tmp/_update_lc/t/bin/opt+0x1dc276c)
 #9 0x0000000001dc0c60 llvm::Attributor::run(llvm::Module&) (/tmp/_update_lc/t/bin/opt+0x1dc0c60)
#10 0x0000000001dc6e5f runAttributorOnModule(llvm::Module&, llvm::AnalysisGetter&) (/tmp/_update_lc/t/bin/opt+0x1dc6e5f)
#11 0x0000000001dca1fb (anonymous namespace)::AttributorLegacyPass::runOnModule(llvm::Module&) (/tmp/_update_lc/t/bin/opt+0x1dca1fb)
#12 0x0000000001d06a63 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/tmp/_update_lc/t/bin/opt+0x1d06a63)
#13 0x0000000001374e67 main (/tmp/_update_lc/t/bin/opt+0x1374e67)
#14 0x00007ffff61581a3 __libc_start_main (/lib64/libc.so.6+0x271a3)
#15 0x000000000135f7ee _start (/tmp/_update_lc/t/bin/opt+0x135f7ee)
FileCheck error: '-' is empty.
FileCheck command line:  /tmp/_update_lc/t/bin/FileCheck /home/dave/s/lp/llvm/test/Transforms/Attributor/liveness.ll --check-prefixes=CHECK,OLDPM

Bisecting identifies this change as breaking stage two testing on my Fedora 31 machine. Can we revert this?

FAIL: LLVM :: Transforms/Attributor/liveness.ll (44058 of 60349)
******************** TEST 'LLVM :: Transforms/Attributor/liveness.ll' FAILED ********************
Script:
--
: 'RUN: at line 2';   /tmp/_update_lc/t/bin/opt -attributor --attributor-disable=false -attributor-max-iterations-verify -attributor-annotate-decl-cs -attributor-max-iterations=4 -S < /home/dave/s/lp/llvm/test/Transforms/Attributor/liveness.ll | /tmp/_update_lc/t/bin/FileCheck /home/dave/s/lp/llvm/test/Transforms/Attributor/liveness.ll --check-prefixes=CHECK,OLDPM
: 'RUN: at line 3';   /tmp/_update_lc/t/bin/opt -passes=attributor --attributor-disable=false -attributor-max-iterations-verify -attributor-annotate-decl-cs -attributor-max-iterations=4 -S < /home/dave/s/lp/llvm/test/Transforms/Attributor/liveness.ll | /tmp/_update_lc/t/bin/FileCheck /home/dave/s/lp/llvm/test/Transforms/Attributor/liveness.ll --check-prefixes=CHECK,NEWPM
--
Exit Code: 2

Command Output (stderr):
--
opt: /home/dave/s/lp/llvm/lib/Transforms/IPO/Attributor.cpp:6475: llvm::ChangeStatus llvm::Attributor::rewriteFunctionSignatures(): Assertion `OldFn->getNumUses() == 0 && "Unexpected leftover uses!"' failed.
Stack dump:
0.  Program arguments: /tmp/_update_lc/t/bin/opt -attributor --attributor-disable=false -attributor-max-iterations-verify -attributor-annotate-decl-cs -attributor-max-iterations=4 -S
1.  Running pass 'Deduce and propagate attributes' on module '<stdin>'.
 #0 0x00000000023d387f llvm::sys::PrintStackTrace(llvm::raw_ostream&) (/tmp/_update_lc/t/bin/opt+0x23d387f)
 #1 0x00000000023d1ad2 llvm::sys::RunSignalHandlers() (/tmp/_update_lc/t/bin/opt+0x23d1ad2)
 #2 0x00000000023d3e05 SignalHandler(int) (/tmp/_update_lc/t/bin/opt+0x23d3e05)
 #3 0x00007ffff7fa8b20 __restore_rt (/lib64/libpthread.so.0+0x14b20)
 #4 0x00007ffff616d625 raise (/lib64/libc.so.6+0x3c625)
 #5 0x00007ffff61568d9 abort (/lib64/libc.so.6+0x258d9)
 #6 0x00007ffff61567a9 _nl_load_domain.cold (/lib64/libc.so.6+0x257a9)
 #7 0x00007ffff6165a66 (/lib64/libc.so.6+0x34a66)
 #8 0x0000000001dc276c llvm::Attributor::rewriteFunctionSignatures() (/tmp/_update_lc/t/bin/opt+0x1dc276c)
 #9 0x0000000001dc0c60 llvm::Attributor::run(llvm::Module&) (/tmp/_update_lc/t/bin/opt+0x1dc0c60)
#10 0x0000000001dc6e5f runAttributorOnModule(llvm::Module&, llvm::AnalysisGetter&) (/tmp/_update_lc/t/bin/opt+0x1dc6e5f)
#11 0x0000000001dca1fb (anonymous namespace)::AttributorLegacyPass::runOnModule(llvm::Module&) (/tmp/_update_lc/t/bin/opt+0x1dca1fb)
#12 0x0000000001d06a63 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/tmp/_update_lc/t/bin/opt+0x1d06a63)
#13 0x0000000001374e67 main (/tmp/_update_lc/t/bin/opt+0x1374e67)
#14 0x00007ffff61581a3 __libc_start_main (/lib64/libc.so.6+0x271a3)
#15 0x000000000135f7ee _start (/tmp/_update_lc/t/bin/opt+0x135f7ee)
FileCheck error: '-' is empty.
FileCheck command line:  /tmp/_update_lc/t/bin/FileCheck /home/dave/s/lp/llvm/test/Transforms/Attributor/liveness.ll --check-prefixes=CHECK,OLDPM

Is there a reproducer in progress?

Is there a reproducer in progress?

Never mind. This may or may not be the root cause, but I can't be sure due to an unrelated race condition in LLVM's thread pool logic making my bisects unreliable (see D72090 for the fix). I'm re-bisecting with the patch from D72090.