-
Notifications
You must be signed in to change notification settings - Fork 12.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
clang crashes under -O3 in llvm-project/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp:516: void {anonymous}::Formula::canonicalize(const llvm::Loop&): Assertion `!BaseRegs.empty() && "1*reg => reg, should not be needed."' failed. #49041
Comments
This case also still crashes, too. $clang -w -O3 samll.c
PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT: |
It looks like this has been fixed recently. It passes with current I extracted the IR before LoopStrengthReduce. It also crashes when running |
Extended Description
Hi all.
Clang crashes on the valid code under -O3. Note that this issue only occurs in the current trunk version of clang while released versions of clang handle it well.
$cat small.c
#include <stdint.h>
int a;
int8_t b;
void c() {
for (b = 8; b <= 6;)
;
int d = -4;
while (d < 20) {
d += 5;
int e = 7;
do {
int f = 7;
a = b;
while (f--)
for (b = 20; b <= 30; b++) {
int8_t *g = &b;
(*g -= a) || 0 > g < g;
}
} while (e--);
}
}
$clang -w -O3 small.c
clang: /home/haoxin/haoxin-data/dut-research/compilers/llvm-project/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp:516: void {anonymous}::Formula::canonicalize(const llvm::Loop&): Assertion `!BaseRegs.empty() && "1*reg => reg, should not be needed."' 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: clang -w -c -O3 small.c
#0 0x00005629c94918ac llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210321/bin/clang-13+0x345f8ac)
#1 0x00005629c948f4e4 llvm::sys::RunSignalHandlers() (/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210321/bin/clang-13+0x345d4e4)
#2 0x00005629c948f77b llvm::sys::CleanupOnSignal(unsigned long) (/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210321/bin/clang-13+0x345d77b)
#3 0x00005629c93ec738 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
#4 0x00007f6a94406980 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x12980)
#5 0x00007f6a9302efb7 raise /build/glibc-S9d2JN/glibc-2.27/signal/../sysdeps/unix/sysv/linux/raise.c:51:0
#6 0x00007f6a93030921 abort /build/glibc-S9d2JN/glibc-2.27/stdlib/abort.c:81:0
#7 0x00007f6a9302048a __assert_fail_base /build/glibc-S9d2JN/glibc-2.27/assert/assert.c:89:0
#8 0x00007f6a93020502 (/lib/x86_64-linux-gnu/libc.so.6+0x30502)
#9 0x00005629c926a39a (/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210321/bin/clang-13+0x323839a)
#10 0x00005629c9274c95 (anonymous namespace)::LSRInstance::GenerateReassociationsImpl((anonymous namespace)::LSRUse&, unsigned int, (anonymous namespace)::Formula const&, unsigned int, unsigned long, bool) LoopStrengthReduce.cpp:0:0
#11 0x00005629c9274d6d (anonymous namespace)::LSRInstance::GenerateReassociationsImpl((anonymous namespace)::LSRUse&, unsigned int, (anonymous namespace)::Formula const&, unsigned int, unsigned long, bool) LoopStrengthReduce.cpp:0:0
#12 0x00005629c927e57a (anonymous namespace)::LSRInstance::GenerateAllReuseFormulae() LoopStrengthReduce.cpp:0:0
#13 0x00005629c9287652 (anonymous namespace)::LSRInstance::LSRInstance(llvm::Loop*, llvm::IVUsers&, llvm::ScalarEvolution&, llvm::DominatorTree&, llvm::LoopInfo&, llvm::TargetTransformInfo const&, llvm::AssumptionCache&, llvm::TargetLibraryInfo&, llvm::MemorySSAUpdater*) LoopStrengthReduce.cpp:0:0
#14 0x00005629c928a267 ReduceLoopStrength(llvm::Loop*, llvm::IVUsers&, llvm::ScalarEvolution&, llvm::DominatorTree&, llvm::LoopInfo&, llvm::TargetTransformInfo const&, llvm::AssumptionCache&, llvm::TargetLibraryInfo&, llvm::MemorySSA*) LoopStrengthReduce.cpp:0:0
#15 0x00005629c928cdba (anonymous namespace)::LoopStrengthReduce::runOnLoop(llvm::Loop*, llvm::LPPassManager&) LoopStrengthReduce.cpp:0:0
#16 0x00005629c8521833 llvm::LPPassManager::runOnFunction(llvm::Function&) (/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210321/bin/clang-13+0x24ef833)
#17 0x00005629c8c4eca4 llvm::FPPassManager::runOnFunction(llvm::Function&) (/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210321/bin/clang-13+0x2c1cca4)
#18 0x00005629c8c4f7e9 llvm::FPPassManager::runOnModule(llvm::Module&) (/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210321/bin/clang-13+0x2c1d7e9)
#19 0x00005629c8c4e5c1 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210321/bin/clang-13+0x2c1c5c1)
#20 0x00005629c975422b (anonymous namespace)::EmitAssemblyHelper::EmitAssemblyWithNewPassManager(clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_deletellvm::raw_pwrite_stream >) BackendUtil.cpp:0:0
#21 0x00005629c97574f5 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_deletellvm::raw_pwrite_stream >) (/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210321/bin/clang-13+0x37254f5)
#22 0x00005629ca3d3816 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210321/bin/clang-13+0x43a1816)
#23 0x00005629caf38969 clang::ParseAST(clang::Sema&, bool, bool) (/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210321/bin/clang-13+0x4f06969)
#24 0x00005629ca3d25d8 clang::CodeGenAction::ExecuteAction() (/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210321/bin/clang-13+0x43a05d8)
#25 0x00005629c9d60ab9 clang::FrontendAction::Execute() (/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210321/bin/clang-13+0x3d2eab9)
#26 0x00005629c9cfe6f1 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210321/bin/clang-13+0x3ccc6f1)
#27 0x00005629c9e28df0 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210321/bin/clang-13+0x3df6df0)
#28 0x00005629c70800f4 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210321/bin/clang-13+0x104e0f4)
#29 0x00005629c707c657 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&) driver.cpp:0:0
#30 0x00005629c9bb00a5 void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optionalllvm::StringRef >, std::__cxx11::basic_string<char, std::char_traits, std::allocator >, bool) const::'lambda'()>(long) Job.cpp:0:0
#31 0x00005629c93ec8b2 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210321/bin/clang-13+0x33ba8b2)
#32 0x00005629c9bb13ec clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optionalllvm::StringRef >, std::__cxx11::basic_string<char, std::char_traits, std::allocator >, bool) const (.part.186) Job.cpp:0:0
#33 0x00005629c9b89309 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&) const (/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210321/bin/clang-13+0x3b57309)
#34 0x00005629c9b89de7 clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&) const (/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210321/bin/clang-13+0x3b57de7)
#35 0x00005629c9b92c49 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&) (/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210321/bin/clang-13+0x3b60c49)
#36 0x00005629c6faaf8e main (/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210321/bin/clang-13+0xf78f8e)
#37 0x00007f6a93011bf7 __libc_start_main /build/glibc-S9d2JN/glibc-2.27/csu/../csu/libc-start.c:344:0
#38 0x00005629c707c0da _start (/media/haoxin/SeagateData/haoxin-data/dut-research/compilers/llvm-project/build-20210321/bin/clang-13+0x104a0da)
clang-13: error: clang frontend command failed with exit code 134 (use -v to see invocation)
clang version 13.0.0 (https://github.com/llvm/llvm-project 613157d)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/haoxin/haoxin-data/dut-research/compilers/llvm-project/build-20210321/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-d37230.c
clang-13: note: diagnostic msg: /tmp/small-d37230.sh
clang-13: note: diagnostic msg:
Thanks,
Haoxin
The text was updated successfully, but these errors were encountered: