[llvm-bugs] [Bug 32045] New: clang crashes on valid code at -O2 and -O3 on x86_64-linux-gnu: Assertion `shiftAmt <= BitWidth && "Invalid shift amount"' failed

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Feb 22 21:13:06 PST 2017


http://bugs.llvm.org/show_bug.cgi?id=32045

            Bug ID: 32045
           Summary: clang crashes on valid code at -O2 and -O3 on
                    x86_64-linux-gnu: Assertion `shiftAmt <= BitWidth &&
                    "Invalid shift amount"' failed
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: su at cs.ucdavis.edu
                CC: llvm-bugs at lists.llvm.org

This appears to be a recent regression. 

$ clang -v
clang version 5.0.0 (trunk 295749) (llvm/trunk 295748)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/clang-trunk/bin
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/5
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/5.4.0
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/6
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/6.0.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.4
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.4.7
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.6
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.6.4
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.7
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.7.4
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8.5
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9.3
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5.4.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6.0.0
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5.4.0
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Candidate multilib: x32;@mx32
Selected multilib: .;@m64
$ 
$ clang -Os -w small.c
$ 
$ clang -O2 -w small.c
clang-5.0: /tmp/llvm-builder/llvm-source-trunk/lib/Support/APInt.cpp:1044:
llvm::APInt llvm::APInt::ashr(unsigned int) const: Assertion `shiftAmt <=
BitWidth && "Invalid shift amount"' failed.
#0 0x0000000001f2293a llvm::sys::PrintStackTrace(llvm::raw_ostream&)
(/usr/local/clang-trunk/bin/clang-5.0+0x1f2293a)
#1 0x0000000001f205de llvm::sys::RunSignalHandlers()
(/usr/local/clang-trunk/bin/clang-5.0+0x1f205de)
#2 0x0000000001f20752 SignalHandler(int)
(/usr/local/clang-trunk/bin/clang-5.0+0x1f20752)
#3 0x00007f3f29d8b390 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x11390)
#4 0x00007f3f28afe428 gsignal
/build/glibc-t3gR2i/glibc-2.23/signal/../sysdeps/unix/sysv/linux/raise.c:54:0
#5 0x00007f3f28b0002a abort /build/glibc-t3gR2i/glibc-2.23/stdlib/abort.c:91:0
#6 0x00007f3f28af6bd7 __assert_fail_base
/build/glibc-t3gR2i/glibc-2.23/assert/assert.c:92:0
#7 0x00007f3f28af6c82 (/lib/x86_64-linux-gnu/libc.so.6+0x2dc82)
#8 0x0000000001ea35aa llvm::APInt::ashr(unsigned int) const
(/usr/local/clang-trunk/bin/clang-5.0+0x1ea35aa)
#9 0x00000000016490d3 llvm::ScalarEvolution::getRange(llvm::SCEV const*,
llvm::ScalarEvolution::RangeSignHint)
(/usr/local/clang-trunk/bin/clang-5.0+0x16490d3)
#10 0x0000000001648e94 llvm::ScalarEvolution::getRange(llvm::SCEV const*,
llvm::ScalarEvolution::RangeSignHint)
(/usr/local/clang-trunk/bin/clang-5.0+0x1648e94)
#11 0x000000000165424e llvm::ScalarEvolution::getMinusSCEV(llvm::SCEV const*,
llvm::SCEV const*, llvm::SCEV::NoWrapFlags)
(/usr/local/clang-trunk/bin/clang-5.0+0x165424e)
#12 0x0000000001665002 llvm::ScalarEvolution::createSCEV(llvm::Value*) [clone
.part.1371] [clone .constprop.1442]
(/usr/local/clang-trunk/bin/clang-5.0+0x1665002)
#13 0x0000000001642dd0 llvm::ScalarEvolution::getSCEV(llvm::Value*)
(/usr/local/clang-trunk/bin/clang-5.0+0x1642dd0)
#14 0x000000000166469c
llvm::ScalarEvolution::createNodeFromSelectLikePHI(llvm::PHINode*)
(/usr/local/clang-trunk/bin/clang-5.0+0x166469c)
#15 0x0000000001664893 llvm::ScalarEvolution::createNodeForPHI(llvm::PHINode*)
(/usr/local/clang-trunk/bin/clang-5.0+0x1664893)
#16 0x0000000001665445 llvm::ScalarEvolution::createSCEV(llvm::Value*) [clone
.part.1371] [clone .constprop.1442]
(/usr/local/clang-trunk/bin/clang-5.0+0x1665445)
#17 0x0000000001642dd0 llvm::ScalarEvolution::getSCEV(llvm::Value*)
(/usr/local/clang-trunk/bin/clang-5.0+0x1642dd0)
#18 0x00000000016633c9
llvm::ScalarEvolution::createAddRecFromPHI(llvm::PHINode*)
(/usr/local/clang-trunk/bin/clang-5.0+0x16633c9)
#19 0x0000000001664859 llvm::ScalarEvolution::createNodeForPHI(llvm::PHINode*)
(/usr/local/clang-trunk/bin/clang-5.0+0x1664859)
#20 0x0000000001665445 llvm::ScalarEvolution::createSCEV(llvm::Value*) [clone
.part.1371] [clone .constprop.1442]
(/usr/local/clang-trunk/bin/clang-5.0+0x1665445)
#21 0x0000000001642dd0 llvm::ScalarEvolution::getSCEV(llvm::Value*)
(/usr/local/clang-trunk/bin/clang-5.0+0x1642dd0)
#22 0x0000000001664666
llvm::ScalarEvolution::createNodeFromSelectLikePHI(llvm::PHINode*)
(/usr/local/clang-trunk/bin/clang-5.0+0x1664666)
#23 0x0000000001664893 llvm::ScalarEvolution::createNodeForPHI(llvm::PHINode*)
(/usr/local/clang-trunk/bin/clang-5.0+0x1664893)
#24 0x0000000001665445 llvm::ScalarEvolution::createSCEV(llvm::Value*) [clone
.part.1371] [clone .constprop.1442]
(/usr/local/clang-trunk/bin/clang-5.0+0x1665445)
#25 0x0000000001642dd0 llvm::ScalarEvolution::getSCEV(llvm::Value*)
(/usr/local/clang-trunk/bin/clang-5.0+0x1642dd0)
#26 0x000000000200f609 llvm::simplifyUsersOfIV(llvm::PHINode*,
llvm::ScalarEvolution*, llvm::DominatorTree*, llvm::LoopInfo*,
llvm::SmallVectorImpl<llvm::WeakVH>&, llvm::IVVisitor*)
(/usr/local/clang-trunk/bin/clang-5.0+0x200f609)
#27 0x0000000001d67057 (anonymous
namespace)::IndVarSimplify::simplifyAndExtend(llvm::Loop*, llvm::SCEVExpander&,
llvm::LoopInfo*) [clone .constprop.468]
(/usr/local/clang-trunk/bin/clang-5.0+0x1d67057)
#28 0x0000000001d696bb (anonymous namespace)::IndVarSimplify::run(llvm::Loop*)
[clone .part.440] (/usr/local/clang-trunk/bin/clang-5.0+0x1d696bb)
#29 0x0000000001d6b3ee (anonymous
namespace)::IndVarSimplifyLegacyPass::runOnLoop(llvm::Loop*,
llvm::LPPassManager&) [clone .part.441] [clone .constprop.453]
(/usr/local/clang-trunk/bin/clang-5.0+0x1d6b3ee)
#30 0x00000000015ec00b llvm::LPPassManager::runOnFunction(llvm::Function&)
(/usr/local/clang-trunk/bin/clang-5.0+0x15ec00b)
#31 0x0000000001a9d923 llvm::FPPassManager::runOnFunction(llvm::Function&)
(/usr/local/clang-trunk/bin/clang-5.0+0x1a9d923)
#32 0x00000000028cfb6e (anonymous
namespace)::CGPassManager::runOnModule(llvm::Module&)
(/usr/local/clang-trunk/bin/clang-5.0+0x28cfb6e)
#33 0x0000000001a9d48d llvm::legacy::PassManagerImpl::run(llvm::Module&)
(/usr/local/clang-trunk/bin/clang-5.0+0x1a9d48d)
#34 0x00000000020d2f1f 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> >)
(/usr/local/clang-trunk/bin/clang-5.0+0x20d2f1f)
#35 0x000000000275feea
clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&)
(/usr/local/clang-trunk/bin/clang-5.0+0x275feea)
#36 0x0000000002afdc08 clang::ParseAST(clang::Sema&, bool, bool)
(/usr/local/clang-trunk/bin/clang-5.0+0x2afdc08)
#37 0x000000000275f24a clang::CodeGenAction::ExecuteAction()
(/usr/local/clang-trunk/bin/clang-5.0+0x275f24a)
#38 0x00000000024338f6 clang::FrontendAction::Execute()
(/usr/local/clang-trunk/bin/clang-5.0+0x24338f6)
#39 0x00000000024062a6
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/usr/local/clang-trunk/bin/clang-5.0+0x24062a6)
#40 0x00000000024bb47a
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/usr/local/clang-trunk/bin/clang-5.0+0x24bb47a)
#41 0x0000000000a613e8 cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) (/usr/local/clang-trunk/bin/clang-5.0+0xa613e8)
#42 0x00000000009f8acc main (/usr/local/clang-trunk/bin/clang-5.0+0x9f8acc)
#43 0x00007f3f28ae9830 __libc_start_main
/build/glibc-t3gR2i/glibc-2.23/csu/../csu/libc-start.c:325:0
#44 0x0000000000a5da89 _start (/usr/local/clang-trunk/bin/clang-5.0+0xa5da89)
Stack dump:
0.      Program arguments: /usr/local/clang-trunk/bin/clang-5.0 -cc1 -triple
x86_64-unknown-linux-gnu -emit-obj -disable-free -main-file-name small.c
-mrelocation-model static -mthread-model posix -fmath-errno -masm-verbose
-mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64
-momit-leaf-frame-pointer -dwarf-column-info -debugger-tuning=gdb -resource-dir
/usr/local/clang-trunk/bin/../lib/clang/5.0.0 -internal-isystem
/usr/local/include -internal-isystem
/usr/local/clang-trunk/bin/../lib/clang/5.0.0/include -internal-externc-isystem
/usr/include/x86_64-linux-gnu -internal-externc-isystem /include
-internal-externc-isystem /usr/include -O2 -w -fdebug-compilation-dir /home/su/
-ferror-limit 19 -fmessage-length 172 -fobjc-runtime=gcc
-fdiagnostics-show-option -fcolor-diagnostics -vectorize-loops -vectorize-slp
-o /tmp/small-b9e942.o -x c small.c 
1.      <eof> parser at end of file
2.      Per-module optimization passes
3.      Running pass 'CallGraph Pass Manager' on module 'small.c'.
4.      Running pass 'Loop Pass Manager' on function '@main'
5.      Running pass 'Induction Variable Simplification' on basic block
'%for.cond.preheader'
clang-5.0: error: unable to execute command: Aborted (core dumped)
clang-5.0: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 5.0.0 (trunk 295749) (llvm/trunk 295748)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/clang-trunk/bin
clang-5.0: note: diagnostic msg: PLEASE submit a bug report to
http://llvm.org/bugs/ and include the crash backtrace, preprocessed source, and
associated run script.
clang-5.0: note: diagnostic msg: 
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang-5.0: note: diagnostic msg: /tmp/small-0bd522.c
clang-5.0: note: diagnostic msg: /tmp/small-0bd522.sh
clang-5.0: note: diagnostic msg: 

********************
$ 


------------------------------------------


short a;
int b;
int volatile c;

int main ()
{
  short e;
  while (a)
    {
      a = 1;
      for (a; a >= 0; a--)
        c;
      int f = 0x40000000 ^ a;
      if (b)
        e = ~(-(f >> a) >> e);
      b = e;
    }
  return 0;
}

-- 
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/20170223/9cb4ba22/attachment-0001.html>


More information about the llvm-bugs mailing list