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
Assertion `hiBit <= BitWidth && "hiBit out of range"' failed #48057
Comments
Your patch seems right to me - we have to guard against "align 0" because the LangRef says: Do you want to post a patch on Phabricator? Here's a reduced IR testcase that fails with "opt -instsimplify": define i8* @#48713 () { declare void @llvm.assume(i1 noundef) |
Forgot to update the function name in the call instruction: define i8* @#48713 () { |
Thanks, I can. Should I included the reduced IR testcase in the patch? |
Yes - we always try to include a minimal regression test to ensure that a bug doesn't come back to life after being killed. |
Patch is posted here: https://reviews.llvm.org/D94433 |
A possible duplicate here. $ clang-trunk -v $ cat mutant.c $ clang-trunk -O1 mutant.c
PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT: |
I posted a comment on https://reviews.llvm.org/D94433 to see if we can make progress. |
Extended Description
$ cat ~/t.i
void *a(long t) attribute((alloc_align(1)));
void *a(long t) { a(0) == 0; }
$ ./bin/clang -O1 ~/t.i
/home/ryan_mansfield/t.i:2:21: warning: requested alignment is not a power of 2 [-Wnon-power-of-two-alignment]
void *a(long t) { a(0) == 0; }
^
/home/ryan_mansfield/t.i:2:24: warning: equality comparison result unused [-Wunused-comparison]
void *a(long t) { a(0) == 0; }
~~~~~^~~~
/home/ryan_mansfield/t.i:2:30: warning: non-void function does not return a value [-Wreturn-type]
void *a(long t) { a(0) == 0; }
^
clang-12: /home/ryan_mansfield/llvm/llvm-project/llvm/include/llvm/ADT/APInt.h:1482: void llvm::APInt::setBits(unsigned int, unsigned int): Assertion `hiBit <= BitWidth && "hiBit out of range"' 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: /home/ryan_mansfield/llvm/llvm-project/build/bin/clang-12 -cc1 -triple x86_64-unknown-linux-gnu -emit-obj --mrelax-relocations -disable-free -main-file-name t.i -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 /home/ryan_mansfield/llvm/llvm-project/build/lib/clang/12.0.0 -O1 -fdebug-compilation-dir /home/ryan_mansfield/llvm/llvm-project/build -ferror-limit 19 -fgnuc-version=4.2.1 -fcolor-diagnostics -faddrsig -o /tmp/t-dad038.o -x cpp-output /home/ryan_mansfield/t.i
#0 0x0000555559ed013e llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /home/ryan_mansfield/llvm/llvm-project/llvm/lib/Support/Unix/Signals.inc:565:0
#1 0x0000555559ed01f5 PrintStackTraceSignalHandler(void*) /home/ryan_mansfield/llvm/llvm-project/llvm/lib/Support/Unix/Signals.inc:632:0
#2 0x0000555559ecdeb9 llvm::sys::RunSignalHandlers() /home/ryan_mansfield/llvm/llvm-project/llvm/lib/Support/Signals.cpp:71:0
#3 0x0000555559ecfabf SignalHandler(int) /home/ryan_mansfield/llvm/llvm-project/llvm/lib/Support/Unix/Signals.inc:407:0
#4 0x00007ffff7bc6980 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x12980)
#5 0x00007ffff6877fb7 raise /build/glibc-S7xCS9/glibc-2.27/signal/../sysdeps/unix/sysv/linux/raise.c:51:0
#6 0x00007ffff6879921 abort /build/glibc-S7xCS9/glibc-2.27/stdlib/abort.c:81:0
#7 0x00007ffff686948a __assert_fail_base /build/glibc-S7xCS9/glibc-2.27/assert/assert.c:89:0
#8 0x00007ffff6869502 (/lib/x86_64-linux-gnu/libc.so.6+0x30502)
#9 0x0000555557f82b8f llvm::APInt::setBits(unsigned int, unsigned int) /home/ryan_mansfield/llvm/llvm-project/llvm/include/llvm/ADT/APInt.h:1483:0
#10 0x0000555557ffa959 llvm::APInt::setLowBits(unsigned int) /home/ryan_mansfield/llvm/llvm-project/llvm/include/llvm/ADT/APInt.h:1506:0
#11 0x0000555558c3ad14 computeKnownBitsFromAssume(llvm::Value const*, llvm::KnownBits&, unsigned int, (anonymous namespace)::Query const&) /home/ryan_mansfield/llvm/llvm-project/llvm/lib/Analysis/ValueTracking.cpp:676:0
#12 0x0000555558c41e05 computeKnownBits(llvm::Value const*, llvm::APInt const&, llvm::KnownBits&, unsigned int, (anonymous namespace)::Query const&) /home/ryan_mansfield/llvm/llvm-project/llvm/lib/Analysis/ValueTracking.cpp:1904:0
#13 0x0000555558c450ff isKnownNonZero(llvm::Value const*, llvm::APInt const&, unsigned int, (anonymous namespace)::Query const&) /home/ryan_mansfield/llvm/llvm-project/llvm/lib/Analysis/ValueTracking.cpp:2470:0
#14 0x0000555558c45202 isKnownNonZero(llvm::Value const*, unsigned int, (anonymous namespace)::Query const&) /home/ryan_mansfield/llvm/llvm-project/llvm/lib/Analysis/ValueTracking.cpp:2482:0
#15 0x0000555558c393eb llvm::isKnownNonZero(llvm::Value const*, llvm::DataLayout const&, unsigned int, llvm::AssumptionCache*, llvm::Instruction const*, llvm::DominatorTree const*, bool) /home/ryan_mansfield/llvm/llvm-project/llvm/lib/Analysis/ValueTracking.cpp:322:0
#16 0x0000555558cfb1fc simplifyICmpWithZero(llvm::CmpInst::Predicate, llvm::Value*, llvm::Value*, llvm::SimplifyQuery const&) /home/ryan_mansfield/llvm/llvm-project/llvm/lib/Analysis/InstructionSimplify.cpp:2709:0
#17 0x0000555558cfe6b7 SimplifyICmpInst(unsigned int, llvm::Value*, llvm::Value*, llvm::SimplifyQuery const&, unsigned int) /home/ryan_mansfield/llvm/llvm-project/llvm/lib/Analysis/InstructionSimplify.cpp:3352:0
#18 0x0000555558cffc67 llvm::SimplifyICmpInst(unsigned int, llvm::Value*, llvm::Value*, llvm::SimplifyQuery const&) /home/ryan_mansfield/llvm/llvm-project/llvm/lib/Analysis/InstructionSimplify.cpp:3633:0
#19 0x0000555558d09193 llvm::SimplifyInstruction(llvm::Instruction*, llvm::SimplifyQuery const&, llvm::OptimizationRemarkEmitter*) /home/ryan_mansfield/llvm/llvm-project/llvm/lib/Analysis/InstructionSimplify.cpp:5809:0
#20 0x0000555559b73ea2 (anonymous namespace)::EarlyCSE::processNode(llvm::DomTreeNodeBasellvm::BasicBlock) /home/ryan_mansfield/llvm/llvm-project/llvm/lib/Transforms/Scalar/EarlyCSE.cpp:1301:0
#21 0x0000555559b75127 (anonymous namespace)::EarlyCSE::run() /home/ryan_mansfield/llvm/llvm-project/llvm/lib/Transforms/Scalar/EarlyCSE.cpp:1576:0
#22 0x0000555559b7c9af (anonymous namespace)::EarlyCSELegacyCommonPass::runOnFunction(llvm::Function&) /home/ryan_mansfield/llvm/llvm-project/llvm/lib/Transforms/Scalar/EarlyCSE.cpp:1653:0
#23 0x0000555559578eb8 llvm::FPPassManager::runOnFunction(llvm::Function&) /home/ryan_mansfield/llvm/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1440:0
#24 0x0000555559574062 llvm::legacy::FunctionPassManagerImpl::run(llvm::Function&) /home/ryan_mansfield/llvm/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:367:0
#25 0x0000555559578a36 llvm::legacy::FunctionPassManager::run(llvm::Function&) /home/ryan_mansfield/llvm/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1358:0
#26 0x000055555a294a16 (anonymous namespace)::EmitAssemblyHelper::EmitAssembly(clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_deletellvm::raw_pwrite_stream >) /home/ryan_mansfield/llvm/llvm-project/llvm/tools/clang/lib/CodeGen/BackendUtil.cpp:1004:0
#27 0x000055555a298d79 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 >) /home/ryan_mansfield/llvm/llvm-project/llvm/tools/clang/lib/CodeGen/BackendUtil.cpp:1596:0
#28 0x000055555b502078 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) /home/ryan_mansfield/llvm/llvm-project/llvm/tools/clang/lib/CodeGen/CodeGenAction.cpp:344:0
#29 0x000055555d1037e6 clang::ParseAST(clang::Sema&, bool, bool) /home/ryan_mansfield/llvm/llvm-project/llvm/tools/clang/lib/Parse/ParseAST.cpp:178:0
#30 0x000055555ab7f571 clang::ASTFrontendAction::ExecuteAction() /home/ryan_mansfield/llvm/llvm-project/llvm/tools/clang/lib/Frontend/FrontendAction.cpp:1056:0
#31 0x000055555b4feac0 clang::CodeGenAction::ExecuteAction() /home/ryan_mansfield/llvm/llvm-project/llvm/tools/clang/lib/CodeGen/CodeGenAction.cpp:1083:0
#32 0x000055555ab7ee3a clang::FrontendAction::Execute() /home/ryan_mansfield/llvm/llvm-project/llvm/tools/clang/lib/Frontend/FrontendAction.cpp:953:0
#33 0x000055555aad820a clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) /home/ryan_mansfield/llvm/llvm-project/llvm/tools/clang/lib/Frontend/CompilerInstance.cpp:957:0
#34 0x000055555ad0f412 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) /home/ryan_mansfield/llvm/llvm-project/llvm/tools/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:278:0
#35 0x0000555557e41f65 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) /home/ryan_mansfield/llvm/llvm-project/llvm/tools/clang/tools/driver/cc1_main.cpp:240:0
#36 0x0000555557e36666 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&) /home/ryan_mansfield/llvm/llvm-project/llvm/tools/clang/tools/driver/driver.cpp:330:0
#37 0x0000555557e36e38 main /home/ryan_mansfield/llvm/llvm-project/llvm/tools/clang/tools/driver/driver.cpp:407:0
#38 0x00007ffff685abf7 __libc_start_main /build/glibc-S7xCS9/glibc-2.27/csu/../csu/libc-start.c:344:0
#39 0x0000555557e34cea _start (/home/ryan_mansfield/llvm/llvm-project/build/bin/clang-12+0x28e0cea)
clang-12: error: unable to execute command: Aborted (core dumped)
clang-12: error: clang frontend command failed due to signal (use -v to see invocation)
clang version 12.0.0 (https://github.com/llvm/llvm-project.git 4c372a3)
Target: x86_64-unknown-linux-gnu
Thread model: posix
This appears after the following commit.
commit 22e4346 (HEAD -> master)
Author: Shimin Cui scui@ca.ibm.com
Date: Tue Oct 27 09:49:41 2020 +0000
The following avoids the assertion.
diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp
index 1c75c5fbd0db..1b7e95101b83 100644
--- a/llvm/lib/Analysis/ValueTracking.cpp
+++ b/llvm/lib/Analysis/ValueTracking.cpp
@@ -666,7 +666,8 @@ static void computeKnownBitsFromAssume(const Value *V, KnownBits &Known,
if (V->getType()->isPointerTy()) {
if (RetainedKnowledge RK = getKnowledgeValidInContext(
V, {Attribute::Alignment}, Q.CxtI, Q.DT, Q.AC)) {
}
The text was updated successfully, but these errors were encountered: