[llvm-bugs] [Bug 50238] New: clang crashes at -O1 to -Os in llvm/lib/Transforms/Scalar/SROA.cpp:3997: Assertion `LoadSize == Offsets.S->endOffset() - Offsets.S->beginOffset() && "Slice size should always match load size exactly!"' failed

via llvm-bugs llvm-bugs at lists.llvm.org
Wed May 5 23:02:49 PDT 2021


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

            Bug ID: 50238
           Summary: clang crashes at -O1 to -Os in
                    llvm/lib/Transforms/Scalar/SROA.cpp:3997:  Assertion
                    `LoadSize == Offsets.S->endOffset() -
                    Offsets.S->beginOffset() && "Slice size should always
                    match load size exactly!"' failed
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            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.

$cat small.c
#include <stdint.h>
void a() {
  signed b;
  int64_t *c = &b;
  uint16_t *d;
  for (;;) {
    b = *d;
    d = c;
    int64_t *e = &b;
    *e;
  }
}

$clang -O1 small.c (the same output while adding -O2 to -Os)
clang-13:
/home/haoxin/haoxin-data/dut-research/compilers/llvm-project/llvm/lib/Transforms/Scalar/SROA.cpp:3997:
bool llvm::SROA::presplitLoadsAndStores(llvm::AllocaInst&, llvm::sroa:
:AllocaSlices&): Assertion `LoadSize == Offsets.S->endOffset() -
Offsets.S->beginOffset() && "Slice size should always match load size
exactly!"' 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-20210502/bin/clang-13
-cc1 -triple x86_64-unknown-linux-gnu -emit-obj --mrel
ax-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 x
86-64 -tune-cpu generic -debugger-tuning=gdb
-fcoverage-compilation-dir=/home/haoxin/haoxin-data/dut-research/covsmith-test/test-0505
-resource-dir /media/haoxin/SeagateData/haoxin-da
ta/dut-research/compilers/llvm-project/build-20210502/lib/clang/13.0.0
-c-isystem /usr/local/include/csmith-2.3.0/ -internal-isystem
/media/haoxin/SeagateData/haoxin-data/dut-research
/compilers/llvm-project/build-20210502/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/inc
lude -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/haox
in-data/dut-research/covsmith-test/test-0505 -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-91ff4d.o -x c small.c
1.      <eof> parser at end of file
2.      Optimizer
 #0 0x0000561f44a5781c llvm::sys::PrintStackTrace(llvm::raw_ostream&, int)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210502/bin/clang-13+0x363
681c)
 #1 0x0000561f44a556d4 llvm::sys::RunSignalHandlers()
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210502/bin/clang-13+0x36346d4)
 #2 0x0000561f44a55843 SignalHandler(int) Signals.cpp:0:0
 #3 0x00007f6077cf3980 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x12980)
 #4 0x00007f60769a4fb7 raise
/build/glibc-S9d2JN/glibc-2.27/signal/../sysdeps/unix/sysv/linux/raise.c:51:0
 #5 0x00007f60769a6921 abort /build/glibc-S9d2JN/glibc-2.27/stdlib/abort.c:81:0
 #6 0x00007f607699648a __assert_fail_base
/build/glibc-S9d2JN/glibc-2.27/assert/assert.c:89:0
 #7 0x00007f6076996502 (/lib/x86_64-linux-gnu/libc.so.6+0x30502)
 #8 0x0000561f4491f021 llvm::SROA::presplitLoadsAndStores(llvm::AllocaInst&,
llvm::sroa::AllocaSlices&)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/buil
d-20210502/bin/clang-13+0x34fe021)
 #9 0x0000561f4492364d llvm::SROA::splitAlloca(llvm::AllocaInst&,
llvm::sroa::AllocaSlices&) (.part.1110) SROA.cpp:0:0
#10 0x0000561f449254fe llvm::SROA::runOnAlloca(llvm::AllocaInst&)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210502/bin/clang-13+0x35044fe)
#11 0x0000561f44927c79 llvm::SROA::runImpl(llvm::Function&,
llvm::DominatorTree&, llvm::AssumptionCache&)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/bu
ild-20210502/bin/clang-13+0x3506c79)
#12 0x0000561f449288bb llvm::SROA::run(llvm::Function&,
llvm::AnalysisManager<llvm::Function>&)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-202105
02/bin/clang-13+0x35078bb)
#13 0x0000561f45a19a31 llvm::detail::PassModel<llvm::Function, llvm::SROA,
llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Function>
>::run(llvm::Function&, llvm::AnalysisManager
<llvm::Function>&)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210502/bin/clang-13+0x45f8a31)
#14 0x0000561f44292415 llvm::PassManager<llvm::Function,
llvm::AnalysisManager<llvm::Function> >::run(llvm::Function&,
llvm::AnalysisManager<llvm::Function>&) (/media/haoxin/SeagateDa
ta/haoxin-data/dut-research/compilers/llvm-project/build-20210502/bin/clang-13+0x2e71415)
#15 0x0000561f4296d291 llvm::detail::PassModel<llvm::Function,
llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function> >,
llvm::PreservedAnalyses, llvm::AnalysisManage
r<llvm::Function> >::run(llvm::Function&,
llvm::AnalysisManager<llvm::Function>&)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210502/bin/clang-1
3+0x154c291)
#16 0x0000561f44291c24 llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&,
llvm::AnalysisManager<llvm::Module>&)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-p
roject/build-20210502/bin/clang-13+0x2e70c24)
#17 0x0000561f4296da21 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-20210502/bin/clang-13+0x154ca21)
#18 0x0000561f442904c3 llvm::PassManager<llvm::Module,
llvm::AnalysisManager<llvm::Module> >::run(llvm::Module&,
llvm::AnalysisManager<llvm::Module>&) (/media/haoxin/SeagateData/haoxi
n-data/dut-research/compilers/llvm-project/build-20210502/bin/clang-13+0x2e6f4c3)
#19 0x0000561f44d289c7 (anonymous
namespace)::EmitAssemblyHelper::EmitAssemblyWithNewPassManager(clang::BackendAction,
std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llv
m::raw_pwrite_stream> >) BackendUtil.cpp:0:0
#20 0x0000561f44d2d8dc clang::EmitBackendOutput(clang::DiagnosticsEngine&,
clang::HeaderSearchOptions const&, clang::CodeGenOptions const&,
clang::TargetOptions const&, clang::LangOpt
ions const&, llvm::DataLayout const&, llvm::Module*, clang::BackendAction,
std::unique_ptr<llvm::raw_pwrite_stream,
std::default_delete<llvm::raw_pwrite_stream> >) (/media/haoxin/Seag
ateData/haoxin-data/dut-research/compilers/llvm-project/build-20210502/bin/clang-13+0x390c8dc)
#21 0x0000561f459b180e
clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210502/bin/
clang-13+0x459080e)
#22 0x0000561f46526f59 clang::ParseAST(clang::Sema&, bool, bool)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210502/bin/clang-13+0x5105f59)
#23 0x0000561f459b19a8 clang::CodeGenAction::ExecuteAction()
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210502/bin/clang-13+0x45909a8)
#24 0x0000561f45339eb1 clang::FrontendAction::Execute()
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210502/bin/clang-13+0x3f18eb1)
#25 0x0000561f452d6ff2
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210502/bin/cla
ng-13+0x3eb5ff2)
#26 0x0000561f45404b8a
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210502/bin/clang-1
3+0x3fe3b8a)
#27 0x0000561f426f9c9c cc1_main(llvm::ArrayRef<char const*>, char const*,
void*)
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210502/bin/clang-13
+0x12d8c9c)
#28 0x0000561f426f4f99 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&)
driver.cpp:0:0
#29 0x0000561f4261bf87 main
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210502/bin/clang-13+0x11faf87)
#30 0x00007f6076987bf7 __libc_start_main
/build/glibc-S9d2JN/glibc-2.27/csu/../csu/libc-start.c:344:0
#31 0x0000561f426f4b0a _start
(/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210502/bin/clang-13+0x12d3b0a)
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
e5984a3680bef22d422beaafa73bf131d7197973)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir:
/home/haoxin/haoxin-data/dut-research/compilers/llvm-project/build-20210502/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-dab2f1.c
clang-13: note: diagnostic msg: /tmp/small-dab2f1.sh
clang-13: note: diagnostic msg: 

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

By the way, this issue may relate to Bug 49374 but I guess they are not the
same? Because it only crashes at -O3 and the test case is also different with
reported small.c.


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/20210506/c97aac43/attachment-0001.html>


More information about the llvm-bugs mailing list