[llvm-bugs] [Bug 50009] New: clang -Os crash in llvm/lib/Transforms/Vectorize/VPlan.cpp:269: llvm::Value* llvm::VPTransformState::get(llvm::VPValue*, const llvm::VPIteration&): Assertion `hasVectorValue(Def, Instance.Part)' failed

via llvm-bugs llvm-bugs at lists.llvm.org
Sat Apr 17 00:52:15 PDT 2021


https://bugs.llvm.org/show_bug.cgi?id=50009

            Bug ID: 50009
           Summary: clang -Os crash in
                    llvm/lib/Transforms/Vectorize/VPlan.cpp:269:
                    llvm::Value*
                    llvm::VPTransformState::get(llvm::VPValue*, const
                    llvm::VPIteration&): Assertion `hasVectorValue(Def,
                    Instance.Part)' failed
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Scalar Optimizations
          Assignee: unassignedbugs at nondot.org
          Reporter: haoxintu at gmail.com
                CC: llvm-bugs at lists.llvm.org

Hi all.

This small case makes the current trunk of clang crash only at -Os.

$cat small.c
#include <stdint.h>
int a, b, d, e;
int8_t c;
void f() {
  int32_t *g = &a;
  static i = 0;
  uint32_t *j;
  for (; b; b++) {
    j = &i;
    *j &= *g % e >= (a = c);
    c -= 0 >= 0;
  }
  d = j;
}


$clang -w -Os small.c
clang-13:
/home/haoxin/haoxin-data/dut-research/compilers/llvm-project/llvm/lib/Transforms/Vectorize/VPlan.cpp:269:
llvm::Value* llvm::VPTransformState::get(llvm::VPValue*, const
llvm::VPIteration&): Assertion `hasVectorValue(Def, Instance.Part)' failed.
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash
backtrace, preprocessed source, and associated run script.
Stack dump:
0.      Program arguments:
/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210416/bin/clang-13
-cc1 -triple x86_64-unknown-linux-gnu -emit-obj --mrelax-relocations
-disable-free -main-file-name small.c -mrelocation-model static
-mframe-pointer=none -fmath-errno -fno-rounding-math -mconstructor-aliases
-munwind-tables -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb
-fcoverage-compilation-dir=/home/haoxin/haoxin-data/dut-research/covsmith-test/test-0416-clang
-resource-dir
/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210416/lib/clang/13.0.0
-c-isystem /usr/local/include/csmith-2.3.0 -cxx-isystem
/usr/local/include/csmith-2.3.0 -internal-isystem
/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210416/lib/clang/13.0.0/include
-internal-isystem /usr/local/include -internal-isystem
/usr/lib/gcc/x86_64-linux-gnu/8/../../../../x86_64-linux-gnu/include
-internal-externc-isystem /usr/include/x86_64-linux-gnu
-internal-externc-isystem /include -internal-externc-isystem /usr/include -Os
-w
-fdebug-compilation-dir=/home/haoxin/haoxin-data/dut-research/covsmith-test/test-0416-clang
-ferror-limit 19 -fgnuc-version=4.2.1 -fcolor-diagnostics -vectorize-loops
-vectorize-slp -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/small-f43b2f.o
-x c small.c
1.      <eof> parser at end of file
2.      Optimizer
 #0 0x0000555bb03ad5cc llvm::sys::PrintStackTrace(llvm::raw_ostream&, int)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210416/bin/clang-13+0x35935cc)
 #1 0x0000555bb03ab3d4 llvm::sys::RunSignalHandlers()
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210416/bin/clang-13+0x35913d4)
 #2 0x0000555bb03ab543 SignalHandler(int) Signals.cpp:0:0
 #3 0x00007f5f31e9c980 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x12980)
 #4 0x00007f5f30ac4fb7 raise
/build/glibc-S9d2JN/glibc-2.27/signal/../sysdeps/unix/sysv/linux/raise.c:51:0
 #5 0x00007f5f30ac6921 abort /build/glibc-S9d2JN/glibc-2.27/stdlib/abort.c:81:0
 #6 0x00007f5f30ab648a __assert_fail_base
/build/glibc-S9d2JN/glibc-2.27/assert/assert.c:89:0
 #7 0x00007f5f30ab6502 (/lib/x86_64-linux-gnu/libc.so.6+0x30502)
 #8 0x0000555bb06066a7 llvm::VPTransformState::get(llvm::VPValue*,
llvm::VPIteration const&)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210416/bin/clang-13+0x37ec6a7)
 #9 0x0000555bb058fa1c
llvm::VPPredInstPHIRecipe::execute(llvm::VPTransformState&)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210416/bin/clang-13+0x3775a1c)
#10 0x0000555bb06069d1 llvm::VPBasicBlock::execute(llvm::VPTransformState*)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210416/bin/clang-13+0x37ec9d1)
#11 0x0000555bb05fed00 llvm::VPRegionBlock::execute(llvm::VPTransformState*)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210416/bin/clang-13+0x37e4d00)
#12 0x0000555bb060532d llvm::VPlan::execute(llvm::VPTransformState*)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210416/bin/clang-13+0x37eb32d)
#13 0x0000555bb05a2395
llvm::LoopVectorizationPlanner::executePlan(llvm::InnerLoopVectorizer&,
llvm::DominatorTree*)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210416/bin/clang-13+0x3788395)
#14 0x0000555bb05b3f42 llvm::LoopVectorizePass::processLoop(llvm::Loop*)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210416/bin/clang-13+0x3799f42)
#15 0x0000555bb05b4586 llvm::LoopVectorizePass::runImpl(llvm::Function&,
llvm::ScalarEvolution&, llvm::LoopInfo&, llvm::TargetTransformInfo&,
llvm::DominatorTree&, llvm::BlockFrequencyInfo&, llvm::TargetLibraryInfo*,
llvm::DemandedBits&, llvm::AAResults&, llvm::AssumptionCache&,
std::function<llvm::LoopAccessInfo const& (llvm::Loop&)>&,
llvm::OptimizationRemarkEmitter&, llvm::ProfileSummaryInfo*)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210416/bin/clang-13+0x379a586)
#16 0x0000555bb05b519d llvm::LoopVectorizePass::run(llvm::Function&,
llvm::AnalysisManager<llvm::Function>&)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210416/bin/clang-13+0x379b19d)
#17 0x0000555bb1378f61 llvm::detail::PassModel<llvm::Function,
llvm::LoopVectorizePass, llvm::PreservedAnalyses,
llvm::AnalysisManager<llvm::Function> >::run(llvm::Function&,
llvm::AnalysisManager<llvm::Function>&)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210416/bin/clang-13+0x455ef61)
#18 0x0000555bafbb5fb5 llvm::PassManager<llvm::Function,
llvm::AnalysisManager<llvm::Function> >::run(llvm::Function&,
llvm::AnalysisManager<llvm::Function>&)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210416/bin/clang-13+0x2d9bfb5)
#19 0x0000555bae220de1 llvm::detail::PassModel<llvm::Function,
llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function> >,
llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Function>
>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210416/bin/clang-13+0x1406de1)
#20 0x0000555bafbb5a50 llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&,
llvm::AnalysisManager<llvm::Module>&)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210416/bin/clang-13+0x2d9ba50)
#21 0x0000555bae221431 llvm::detail::PassModel<llvm::Module,
llvm::ModuleToFunctionPassAdaptor, llvm::PreservedAnalyses,
llvm::AnalysisManager<llvm::Module> >::run(llvm::Module&,
llvm::AnalysisManager<llvm::Module>&)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210416/bin/clang-13+0x1407431)
#22 0x0000555bafbb4e75 llvm::PassManager<llvm::Module,
llvm::AnalysisManager<llvm::Module> >::run(llvm::Module&,
llvm::AnalysisManager<llvm::Module>&)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210416/bin/clang-13+0x2d9ae75)
#23 0x0000555bb0683b71 (anonymous
namespace)::EmitAssemblyHelper::EmitAssemblyWithNewPassManager(clang::BackendAction,
std::unique_ptr<llvm::raw_pwrite_stream,
std::default_delete<llvm::raw_pwrite_stream> >) BackendUtil.cpp:0:0
#24 0x0000555bb068832d clang::EmitBackendOutput(clang::DiagnosticsEngine&,
clang::HeaderSearchOptions const&, clang::CodeGenOptions const&,
clang::TargetOptions const&, clang::LangOptions const&, llvm::DataLayout
const&, llvm::Module*, clang::BackendAction,
std::unique_ptr<llvm::raw_pwrite_stream,
std::default_delete<llvm::raw_pwrite_stream> >)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210416/bin/clang-13+0x386e32d)
#25 0x0000555bb1319326
clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210416/bin/clang-13+0x44ff326)
#26 0x0000555bb1e8a149 clang::ParseAST(clang::Sema&, bool, bool)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210416/bin/clang-13+0x5070149)
#27 0x0000555bb13180e8 clang::CodeGenAction::ExecuteAction()
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210416/bin/clang-13+0x44fe0e8)
#28 0x0000555bb0ca2619 clang::FrontendAction::Execute()
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210416/bin/clang-13+0x3e88619)
#29 0x0000555bb0c405a1
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210416/bin/clang-13+0x3e265a1)
#30 0x0000555bb0d6a440
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210416/bin/clang-13+0x3f50440)
#31 0x0000555badf8c574 cc1_main(llvm::ArrayRef<char const*>, char const*,
void*)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210416/bin/clang-13+0x1172574)
#32 0x0000555badf88a77 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&)
driver.cpp:0:0
#33 0x0000555badeb60f4 main
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210416/bin/clang-13+0x109c0f4)
#34 0x00007f5f30aa7bf7 __libc_start_main
/build/glibc-S9d2JN/glibc-2.27/csu/../csu/libc-start.c:344:0
#35 0x0000555badf884da _start
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210416/bin/clang-13+0x116e4da)
clang-13: error: unable to execute command: Aborted (core dumped)
clang-13: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 13.0.0 (https://github.com/llvm/llvm-project
f7c9de0de5804498085af973dc6bfc934a18f000)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir:
/home/haoxin/haoxin-data/dut-research/compilers/llvm-project/build-20210416/bin
clang-13: note: diagnostic msg: 
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang-13: note: diagnostic msg: /tmp/small-114d8e.c
clang-13: note: diagnostic msg: /tmp/small-114d8e.sh
clang-13: note: diagnostic msg: 

********************

Reproduced on Godbolt: https://godbolt.org/z/TcnGaWKKT

Thanks,
Haoxin


-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210417/8fd19733/attachment-0001.html>


More information about the llvm-bugs mailing list