[llvm-bugs] [Bug 45259] New: When compiling with -O2: Assertion `getTypeSizeInBits(SrcTy) <= getTypeSizeInBits(Ty) && "getNoopOrZeroExtend cannot truncate!"' failed.

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Mar 19 22:11:45 PDT 2020


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

            Bug ID: 45259
           Summary: When compiling with -O2: Assertion
                    `getTypeSizeInBits(SrcTy) <= getTypeSizeInBits(Ty) &&
                    "getNoopOrZeroExtend cannot truncate!"' failed.
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: david at doublewise.net
                CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org,
                    neeilans at live.com, richard-llvm at metafoo.co.uk

When compiling the following code

```
struct string {
        string() {
                init();
        }
        ~string();
        void init();
};
struct runtime_error {
        explicit runtime_error();
};
int value(char x) {
        __builtin_assume(x <= 1);
        return x;
}
template <typename = int>
int assignment(int value) {
        auto foo = string();
        throw runtime_error();
}
struct s {
        char m_storage;
        char m_size;
};
void f() {
        s container;
        int adjusted = assignment(0);
        *(&container.m_storage + adjusted) = container.m_storage;
        char * it = &container.m_storage;
        for (int x = 0; x != container.m_size; ++x) {
                ++it;
        }
        while (it != &container.m_storage + value(container.m_size)) {
                --container.m_size;
        }
}
```

with `clang++ -w -Wfatal-errors -o /dev/null -c file.cpp -O2` the compiler
crashes with

```
clang++: /home/david/llvm/llvm/lib/Analysis/ScalarEvolution.cpp:4120: const
llvm::SCEV* llvm::ScalarEvolution::getNoopOrZeroExtend(const llvm::SCEV*,
llvm::Type*): Assertion `getTypeSizeInBits(SrcTy) <= getTypeSizeInBits(Ty) &&
"getNoopOrZeroExtend cannot truncate!"' failed.
Stack dump:
0.      Program arguments: /home/david/llvm/build/bin/clang++ -w -Wfatal-errors
-o /dev/null -c file.cpp -O2 
1.      <eof> parser at end of file
2.      Per-module optimization passes
3.      Running pass 'Function Pass Manager' on module 'file.cpp'.
4.      Running pass 'Loop Vectorization' on function '@_Z1fv'
 #0 0x000055707118916a llvm::sys::PrintStackTrace(llvm::raw_ostream&)
(/home/david/llvm/build/bin/clang+++0x1bb616a)
 #1 0x0000557071186e04 llvm::sys::RunSignalHandlers()
(/home/david/llvm/build/bin/clang+++0x1bb3e04)
 #2 0x0000557071187079 llvm::sys::CleanupOnSignal(unsigned long)
(/home/david/llvm/build/bin/clang+++0x1bb4079)
 #3 0x00005570710fa2e8 CrashRecoverySignalHandler(int)
(/home/david/llvm/build/bin/clang+++0x1b272e8)
 #4 0x00007f4b44317800 __restore_rt (/usr/lib/libpthread.so.0+0x14800)
 #5 0x00007f4b43d92ce5 raise (/usr/lib/libc.so.6+0x3bce5)
 #6 0x00007f4b43d7c857 abort (/usr/lib/libc.so.6+0x25857)
 #7 0x00007f4b43d7c727 _nl_load_domain.cold (/usr/lib/libc.so.6+0x25727)
 #8 0x00007f4b43d8b426 (/usr/lib/libc.so.6+0x34426)
 #9 0x0000557070474fcb (/home/david/llvm/build/bin/clang+++0xea1fcb)
#10 0x00005570712ec2ed
llvm::InnerLoopVectorizer::getOrCreateTripCount(llvm::Loop*) (.part.0)
(/home/david/llvm/build/bin/clang+++0x1d192ed)
#11 0x0000557071309045
llvm::InnerLoopVectorizer::createVectorizedLoopSkeleton()
(/home/david/llvm/build/bin/clang+++0x1d36045)
#12 0x0000557071317b77
llvm::LoopVectorizationPlanner::executePlan(llvm::InnerLoopVectorizer&,
llvm::DominatorTree*) (/home/david/llvm/build/bin/clang+++0x1d44b77)
#13 0x000055707132316b llvm::LoopVectorizePass::processLoop(llvm::Loop*)
(/home/david/llvm/build/bin/clang+++0x1d5016b)
#14 0x00005570713247c0 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*)
(/home/david/llvm/build/bin/clang+++0x1d517c0)
#15 0x0000557071324c0f (anonymous
namespace)::LoopVectorize::runOnFunction(llvm::Function&)
(/home/david/llvm/build/bin/clang+++0x1d51c0f)
#16 0x0000557070af8f94 llvm::FPPassManager::runOnFunction(llvm::Function&)
(/home/david/llvm/build/bin/clang+++0x1525f94)
#17 0x0000557070af9611 llvm::FPPassManager::runOnModule(llvm::Module&)
(/home/david/llvm/build/bin/clang+++0x1526611)
#18 0x0000557070af99a9 llvm::legacy::PassManagerImpl::run(llvm::Module&)
(/home/david/llvm/build/bin/clang+++0x15269a9)
#19 0x0000557071400719 (anonymous
namespace)::EmitAssemblyHelper::EmitAssembly(clang::BackendAction,
std::unique_ptr<llvm::raw_pwrite_stream,
std::default_delete<llvm::raw_pwrite_stream> >)
(/home/david/llvm/build/bin/clang+++0x1e2d719)
#20 0x0000557071402122 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/david/llvm/build/bin/clang+++0x1e2f122)
#21 0x00005570720acf59
clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&)
(/home/david/llvm/build/bin/clang+++0x2ad9f59)
#22 0x0000557072d795c9 clang::ParseAST(clang::Sema&, bool, bool)
(/home/david/llvm/build/bin/clang+++0x37a65c9)
#23 0x00005570720ab9d8 clang::CodeGenAction::ExecuteAction()
(/home/david/llvm/build/bin/clang+++0x2ad89d8)
#24 0x0000557071a1c8c9 clang::FrontendAction::Execute()
(/home/david/llvm/build/bin/clang+++0x24498c9)
#25 0x00005570719d3ffe
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/home/david/llvm/build/bin/clang+++0x2400ffe)
#26 0x0000557071aef644
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/home/david/llvm/build/bin/clang+++0x251c644)
#27 0x000055706fffa45c cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) (/home/david/llvm/build/bin/clang+++0xa2745c)
#28 0x000055706fff6687 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&)
(/home/david/llvm/build/bin/clang+++0xa23687)
#29 0x000055707189c765 void llvm::function_ref<void
()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional<llvm::StringRef>
>, std::__cxx11::basic_string<char, std::char_traits<char>,
std::allocator<char> >*, bool*) const::'lambda'()>(long)
(/home/david/llvm/build/bin/clang+++0x22c9765)
#30 0x00005570710fa464
llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>)
(/home/david/llvm/build/bin/clang+++0x1b27464)
#31 0x000055707189d216
clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional<llvm::StringRef>
>, std::__cxx11::basic_string<char, std::char_traits<char>,
std::allocator<char> >*, bool*) const (.part.0)
(/home/david/llvm/build/bin/clang+++0x22ca216)
#32 0x00005570718756d8
clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&,
clang::driver::Command const*&) const
(/home/david/llvm/build/bin/clang+++0x22a26d8)
#33 0x0000557071876019
clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&,
llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&) const
(/home/david/llvm/build/bin/clang+++0x22a3019)
#34 0x000055707187fb71
clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&,
llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&)
(/home/david/llvm/build/bin/clang+++0x22acb71)
#35 0x000055706ff7c62f main (/home/david/llvm/build/bin/clang+++0x9a962f)
#36 0x00007f4b43d7e023 __libc_start_main (/usr/lib/libc.so.6+0x27023)
#37 0x000055706fff621e _start (/home/david/llvm/build/bin/clang+++0xa2321e)
clang-11: fatal error: clang frontend command failed due to signal (use -v to
see invocation)
clang version 11.0.0 (https://github.com/llvm/llvm-project.git
e7a811b3193ace664e02e07924305e0b9e3c3fd7)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/david/llvm/build/bin
clang-11: note: diagnostic msg: PLEASE submit a bug report to
https://bugs.llvm.org/ and include the crash backtrace, preprocessed source,
and associated run script.
clang-11: note: diagnostic msg: 
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang-11: note: diagnostic msg: /tmp/file-0cb6dc.cpp
clang-11: note: diagnostic msg: /tmp/file-0cb6dc.sh
clang-11: 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/20200320/b4cf5adf/attachment-0001.html>


More information about the llvm-bugs mailing list