[llvm-bugs] [Bug 49374] New: Under O3, assertion failure `LoadSize == Offsets.S->endOffset() - Offsets.S->beginOffset() && "Slice size should always match load size exactly!"'

via llvm-bugs llvm-bugs at lists.llvm.org
Sun Feb 28 08:08:16 PST 2021


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

            Bug ID: 49374
           Summary: Under O3, assertion failure `LoadSize ==
                    Offsets.S->endOffset() - Offsets.S->beginOffset() &&
                    "Slice size should always match load size exactly!"'
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: zhan3299 at purdue.edu
                CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org,
                    neeilans at live.com, richard-llvm at metafoo.co.uk

Following code triggers an assertion failure under O3 optimization, but works
well under O0.


$ cat test.c
#include <stdio.h>

int main() {
    short a = 0;
    unsigned int b = *(unsigned int *)&a;
    volatile char c = *(volatile char *)&a;
    printf("%hd %u %hhd\n", a, b, c);
}


$ cat /tmp/test-088e90.sh
# Crash reproducer for clang version 13.0.0
(https://github.com/llvm/llvm-project.git
b006902b2dfac792e8ade73798ca1b216654faf7)
# Driver args: "-O3" "-x" "c" "-o" "a.out" "test.c"
# Original command:  "/data/xxx/git/llvm-project/build_trunk/bin/clang-13"
"-cc1" "-triple" "x86_64-unknown-linux-gnu" "-emit-obj" "--mrelax-relocations"
"-disable-free" "-main-file-name" "test.c" "-mrelocation-model" "static"
"-mframe-pointer=none" "-fmath-errno" "-fno-rounding-math"
"-mconstructor-aliases" "-munwind-tables" "-target-cpu" "x86-64" "-tune-cpu"
"generic" "-fno-split-dwarf-inlining" "-debugger-tuning=gdb" "-resource-dir"
"/data/xxx/git/llvm-project/build_trunk/lib/clang/13.0.0" "-internal-isystem"
"/usr/local/include" "-internal-isystem"
"/data/xxx/git/llvm-project/build_trunk/lib/clang/13.0.0/include"
"-internal-externc-isystem" "/usr/include/x86_64-linux-gnu"
"-internal-externc-isystem" "/include" "-internal-externc-isystem"
"/usr/include" "-O3"
"-fdebug-compilation-dir=/home/xxx/data/docker_share/clang" "-ferror-limit"
"19" "-fgnuc-version=4.2.1" "-fcolor-diagnostics" "-vectorize-loops"
"-vectorize-slp" "-faddrsig" "-o" "/tmp/test-26edf0.o" "-x" "c" "test.c"
 "/data/xxx/git/llvm-project/build_trunk/bin/clang-13" "-cc1" "-triple"
"x86_64-unknown-linux-gnu" "-emit-obj" "--mrelax-relocations" "-disable-free"
"-main-file-name" "test.c" "-mrelocation-model" "static" "-mframe-pointer=none"
"-fmath-errno" "-fno-rounding-math" "-mconstructor-aliases" "-munwind-tables"
"-target-cpu" "x86-64" "-tune-cpu" "generic" "-fno-split-dwarf-inlining"
"-debugger-tuning=gdb" "-O3"
"-fdebug-compilation-dir=/home/xxx/data/docker_share/clang" "-ferror-limit"
"19" "-fgnuc-version=4.2.1" "-fcolor-diagnostics" "-vectorize-loops"
"-vectorize-slp" "-faddrsig" "-x" "c" "test-088e90.c"


$ clang -O3 -x c -o a.out test.c
clang-13:
/home/xxx/data/git/llvm-project/llvm/lib/Transforms/Scalar/SROA.cpp:3988: 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: /data/xxx/git/llvm-project/build_trunk/bin/clang-13
-cc1 -triple x86_64-unknown-linux-gnu -emit-obj --mrelax-relocations
-disable-free -main-file-name test.c -mrelocation-model static
-mframe-pointer=none -fmath-errno -fno-rounding-math -mconstructor-aliases
-munwind-tables -target-cpu x86-64 -tune-cpu generic -fno-split-dwarf-inlining
-debugger-tuning=gdb -resource-dir
/data/xxx/git/llvm-project/build_trunk/lib/clang/13.0.0 -internal-isystem
/usr/local/include -internal-isystem
/data/xxx/git/llvm-project/build_trunk/lib/clang/13.0.0/include
-internal-externc-isystem /usr/include/x86_64-linux-gnu
-internal-externc-isystem /include -internal-externc-isystem /usr/include -O3
-fdebug-compilation-dir=/home/xxx/data/docker_share/clang -ferror-limit 19
-fgnuc-version=4.2.1 -fcolor-diagnostics -vectorize-loops -vectorize-slp
-faddrsig -o /tmp/test-128566.o -x c test.c
1.      <eof> parser at end of file
2.      Optimizer
 #0 0x0000000000dfd0a1 __interceptor_backtrace.part.117
asan_interceptors.cc.o:0:0
 #1 0x000000000d7fb43a llvm::sys::PrintStackTrace(llvm::raw_ostream&, int)
/home/xxx/data/git/llvm-project/llvm/lib/Support/Unix/Signals.inc:561:7
 #2 0x000000000d7f1bc1 llvm::sys::RunSignalHandlers()
/home/xxx/data/git/llvm-project/llvm/lib/Support/Signals.cpp:72:18
 #3 0x000000000d7fc5b7 SignalHandler(int)
/home/xxx/data/git/llvm-project/llvm/lib/Support/Unix/Signals.inc:407:1
 #4 0x00007f3b15d578a0 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x128a0)
 #5 0x00007f3b1577af47 raise
/build/glibc-2ORdQG/glibc-2.27/signal/../sysdeps/unix/sysv/linux/raise.c:51:0
 #6 0x00007f3b1577c8b1 abort /build/glibc-2ORdQG/glibc-2.27/stdlib/abort.c:81:0
 #7 0x00007f3b1576c42a __assert_fail_base
/build/glibc-2ORdQG/glibc-2.27/assert/assert.c:89:0
 #8 0x00007f3b1576c4a2 (/lib/x86_64-linux-gnu/libc.so.6+0x304a2)
 #9 0x000000000d16b42e
llvm::DenseMapBase<llvm::SmallDenseMap<llvm::Instruction*,
llvm::SROA::presplitLoadsAndStores(llvm::AllocaInst&,
llvm::sroa::AllocaSlices&)::SplitOffsets, 8u,
llvm::DenseMapInfo<llvm::Instruction*>,
llvm::detail::DenseMapPair<llvm::Instruction*,
llvm::SROA::presplitLoadsAndStores(llvm::AllocaInst&,
llvm::sroa::AllocaSlices&)::SplitOffsets> >, llvm::Instruction*,
llvm::SROA::presplitLoadsAndStores(llvm::AllocaInst&,
llvm::sroa::AllocaSlices&)::SplitOffsets,
llvm::DenseMapInfo<llvm::Instruction*>,
llvm::detail::DenseMapPair<llvm::Instruction*,
llvm::SROA::presplitLoadsAndStores(llvm::AllocaInst&,
llvm::sroa::AllocaSlices&)::SplitOffsets> >::destroyAll()
/home/xxx/data/git/llvm-project/llvm/include/llvm/ADT/DenseMap.h:366:33
#10 0x000000000d16b42e llvm::SmallDenseMap<llvm::Instruction*,
llvm::SROA::presplitLoadsAndStores(llvm::AllocaInst&,
llvm::sroa::AllocaSlices&)::SplitOffsets, 8u,
llvm::DenseMapInfo<llvm::Instruction*>,
llvm::detail::DenseMapPair<llvm::Instruction*,
llvm::SROA::presplitLoadsAndStores(llvm::AllocaInst&,
llvm::sroa::AllocaSlices&)::SplitOffsets> >::~SmallDenseMap()
/home/xxx/data/git/llvm-project/llvm/include/llvm/ADT/DenseMap.h:928:0
#11 0x000000000d16b42e llvm::SROA::presplitLoadsAndStores(llvm::AllocaInst&,
llvm::sroa::AllocaSlices&)
/home/xxx/data/git/llvm-project/llvm/lib/Transforms/Scalar/SROA.cpp:4243:0
#12 0x000000000d182e0c llvm::AllocaInst::getAllocatedType() const
/home/xxx/data/git/llvm-project/llvm/include/llvm/IR/Instructions.h:0:0
#13 0x000000000d182e0c llvm::SROA::splitAlloca(llvm::AllocaInst&,
llvm::sroa::AllocaSlices&)
/home/xxx/data/git/llvm-project/llvm/lib/Transforms/Scalar/SROA.cpp:4427:0
#14 0x000000000d189acb llvm::SROA::runOnAlloca(llvm::AllocaInst&)
/home/xxx/data/git/llvm-project/llvm/lib/Transforms/Scalar/SROA.cpp:4649:11
#15 0x000000000d192116 llvm::SROA::runImpl(llvm::Function&,
llvm::DominatorTree&, llvm::AssumptionCache&)
/home/xxx/data/git/llvm-project/llvm/lib/Transforms/Scalar/SROA.cpp:4749:18
#16 0x000000000d1956a5 llvm::SROA::run(llvm::Function&,
llvm::AnalysisManager<llvm::Function>&)
/home/xxx/data/git/llvm-project/llvm/lib/Transforms/Scalar/SROA.cpp:4779:3
#17 0x00000000132042fa llvm::detail::PassModel<llvm::Function, llvm::SROA,
llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Function>
>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&)
/home/xxx/data/git/llvm-project/llvm/include/llvm/IR/PassManagerInternal.h:85:5
#18 0x000000000acc89a0 llvm::PassManager<llvm::Function,
llvm::AnalysisManager<llvm::Function> >::run(llvm::Function&,
llvm::AnalysisManager<llvm::Function>&)
/home/xxx/data/git/llvm-project/llvm/include/llvm/IR/PassManager.h:517:16
#19 0x0000000001f4803a 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>&)
/home/xxx/data/git/llvm-project/llvm/include/llvm/IR/PassManagerInternal.h:85:5
#20 0x000000000acc2e2c llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&,
llvm::AnalysisManager<llvm::Module>&)
/home/xxx/data/git/llvm-project/llvm/lib/IR/PassManager.cpp:117:14
#21 0x0000000001f4610a llvm::detail::PassModel<llvm::Module,
llvm::ModuleToFunctionPassAdaptor, llvm::PreservedAnalyses,
llvm::AnalysisManager<llvm::Module> >::run(llvm::Module&,
llvm::AnalysisManager<llvm::Module>&)
/home/xxx/data/git/llvm-project/llvm/include/llvm/IR/PassManagerInternal.h:85:5
#22 0x000000000acc42a8 llvm::PassManager<llvm::Module,
llvm::AnalysisManager<llvm::Module> >::run(llvm::Module&,
llvm::AnalysisManager<llvm::Module>&)
/home/xxx/data/git/llvm-project/llvm/include/llvm/IR/PassManager.h:517:16
#23 0x000000000e67fdfb (anonymous
namespace)::EmitAssemblyHelper::EmitAssemblyWithNewPassManager(clang::BackendAction,
std::unique_ptr<llvm::raw_pwrite_stream,
std::default_delete<llvm::raw_pwrite_stream> >)
/home/xxx/data/git/llvm-project/clang/lib/CodeGen/BackendUtil.cpp:1432:5
#24 0x000000000e672229 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> >)
/home/xxx/data/git/llvm-project/clang/lib/CodeGen/BackendUtil.cpp:1601:5
#25 0x0000000012d0e5de
clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&)
/home/xxx/data/git/llvm-project/clang/lib/CodeGen/CodeGenAction.cpp:344:7
#26 0x0000000018304cb5 clang::ParseAST(clang::Sema&, bool, bool)
/home/xxx/data/git/llvm-project/clang/lib/Parse/ParseAST.cpp:178:3
#27 0x00000000105c90c3 clang::ASTFrontendAction::ExecuteAction()
/home/xxx/data/git/llvm-project/clang/lib/Frontend/FrontendAction.cpp:1058:1
#28 0x0000000012cff7d9 clang::CodeGenAction::ExecuteAction()
/home/xxx/data/git/llvm-project/clang/lib/CodeGen/CodeGenAction.cpp:1082:30
#29 0x00000000105c5efd clang::FrontendAction::Execute()
/home/xxx/data/git/llvm-project/clang/lib/Frontend/FrontendAction.cpp:0:8
#30 0x0000000010394e0a llvm::Error::operator bool()
/home/xxx/data/git/llvm-project/llvm/include/llvm/Support/Error.h:0:0
#31 0x0000000010394e0a
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
/home/xxx/data/git/llvm-project/clang/lib/Frontend/CompilerInstance.cpp:949:0
#32 0x0000000010ac5a2e
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
/home/xxx/data/git/llvm-project/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:278:25
#33 0x0000000000e9b85d cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) /home/xxx/data/git/llvm-project/clang/tools/driver/cc1_main.cpp:246:15
#34 0x0000000000e82e17 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&)
/home/xxx/data/git/llvm-project/clang/tools/driver/driver.cpp:330:12
#35 0x0000000000e7af13 main
/home/xxx/data/git/llvm-project/clang/tools/driver/driver.cpp:407:12
#36 0x00007f3b1575db97 __libc_start_main
/build/glibc-2ORdQG/glibc-2.27/csu/../csu/libc-start.c:344:0
#37 0x0000000000d7aada _start
(/data/xxx/git/llvm-project/build_trunk/bin/clang-13+0xd7aada)
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.git
b006902b2dfac792e8ade73798ca1b216654faf7)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /data/xxx/git/llvm-project/build_trunk/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/test-088e90.c
clang-13: note: diagnostic msg: /tmp/test-088e90.sh
clang-13: note: diagnostic msg:

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

-- 
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/20210228/503481b8/attachment-0001.html>


More information about the llvm-bugs mailing list