[llvm-bugs] [Bug 48713] New: Assertion `hiBit <= BitWidth && "hiBit out of range"' failed

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Jan 11 06:36:09 PST 2021


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

            Bug ID: 48713
           Summary: Assertion `hiBit <= BitWidth && "hiBit out of range"'
                    failed
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Global Analyses
          Assignee: unassignedbugs at nondot.org
          Reporter: rmansfield at gmail.com
                CC: llvm-bugs at lists.llvm.org

$ 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
1.      <eof> parser at end of file
2.      Per-function optimization
3.      Running pass 'Early CSE' on function '@a'
 #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::DomTreeNodeBase<llvm::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<false>::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_delete<llvm::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_delete<llvm::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
4c372a35cd892c0847da45540057447633a31d99)
Target: x86_64-unknown-linux-gnu
Thread model: posix

This appears after the following commit.


commit 22e4346e054a4474a68fd293324db295fffed34c (HEAD -> master)
Author: Shimin Cui <scui at ca.ibm.com>
Date:   Tue Oct 27 09:49:41 2020 +0000

    [ValueTracking] Add tracking of the alignment assume bundle

    This patch is to add the support of the value tracking of the alignment
assume bundle.

    Reviewed By: jdoerfert

    Differential Revision: https://reviews.llvm.org/D88669


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)) {
-      Known.Zero.setLowBits(Log2_32(RK.ArgValue));
+      if (RK.ArgValue)
+        Known.Zero.setLowBits(Log2_32(RK.ArgValue));
     }
   }

-- 
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/20210111/6e5bdb58/attachment.html>


More information about the llvm-bugs mailing list