[llvm-bugs] [Bug 49166] New: Assertion `V->getType()->isIntOrIntVectorTy() && DestTy->isIntOrIntVectorTy() && "Can only zero extend/truncate integers!"' failed

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Feb 12 12:37:08 PST 2021


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

            Bug ID: 49166
           Summary: Assertion `V->getType()->isIntOrIntVectorTy() &&
                    DestTy->isIntOrIntVectorTy() && "Can only zero
                    extend/truncate integers!"' failed
           Product: clang
           Version: 11.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: zhan3299 at purdue.edu
                CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org,
                    neeilans at live.com, richard-llvm at metafoo.co.uk

Hi, 

There is an assertion failure on version 11.1.0. But it also affects other
versions (I additionally test it with 12.0.0 and my apt-installed 6.0.0). 

Details of version 11.1.0 are attached below. With version 6.0.0 (w/o
assertion), it encounters a fatal error in backend.

I suspect it is due to the inlined asm. Additionally, the poc file can be
successfully compiled by gcc. 

My system is Ubuntu 18.04, x86-64. Please let me know if there is anything I
can help with. Thanks!

==== detailed information ====

$ ./clang poc.c
clang-11:
/home/xxx/data/git/llvm-project/llvm/include/llvm/IR/IRBuilder.h:1976:
llvm::Value *llvm::IRBuilderBase::CreateZExtOrTrunc(llvm::Value *, llvm::Type
*, const llvm::Twine &): Assertion `V->getType()->isIntOrIntVectorTy() &&
DestTy->isIntOrIntVectorTy() && "Can only zero extend/truncate integers!"'
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: /data/xxx/git/llvm-project/build/bin/clang-11 -cc1
-triple x86_64-unknown-linux-gnu -emit-obj -mrelax-all -disable-free
-main-file-name poc.c -mrelocation-model static -mframe-pointer=all
-fmath-errno -fno-rounding-math -mconstructor-aliases -munwind-tables
-target-cpu x86-64 -fno-split-dwarf-inlining -debugger-tuning=gdb -resource-dir
/data/xxx/git/llvm-project/build/lib/clang/11.1.0 -internal-isystem
/usr/local/include -internal-isystem
/data/xxx/git/llvm-project/build/lib/clang/11.1.0/include
-internal-externc-isystem /usr/include/x86_64-linux-gnu
-internal-externc-isystem /include -internal-externc-isystem /usr/include
-fdebug-compilation-dir /data/xxx/docker_share/clang/11.x -ferror-limit 19
-fgnuc-version=4.2.1 -fcolor-diagnostics -faddrsig -o /tmp/poc-00c026.o -x c
poc.c
1.      <eof> parser at end of file
2.      poc.c:2:5: LLVM IR generation of declaration 'main'
3.      poc.c:2:5: Generating code for declaration 'main'
 #0 0x0000000006e97306 llvm::sys::PrintStackTrace(llvm::raw_ostream&)
/home/xxx/data/git/llvm-project/llvm/lib/Support/Unix/Signals.inc:560:7
 #1 0x0000000006e9266e llvm::sys::RunSignalHandlers()
/home/xxx/data/git/llvm-project/llvm/lib/Support/Signals.cpp:69:18
 #2 0x0000000006e97caa SignalHandler(int)
/home/xxx/data/git/llvm-project/llvm/lib/Support/Unix/Signals.inc:396:3
 #3 0x00007f1f2d9698a0 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x128a0)
 #4 0x00007f1f2c62ff47 gsignal
/build/glibc-2ORdQG/glibc-2.27/signal/../sysdeps/unix/sysv/linux/raise.c:51:0
 #5 0x00007f1f2c6318b1 abort /build/glibc-2ORdQG/glibc-2.27/stdlib/abort.c:81:0
 #6 0x00007f1f2c62142a __assert_fail_base
/build/glibc-2ORdQG/glibc-2.27/assert/assert.c:89:0
 #7 0x00007f1f2c6214a2 (/lib/x86_64-linux-gnu/libc.so.6+0x304a2)
 #8 0x0000000000f20fa0 std::_Rb_tree_iterator<std::pair<unsigned long const,
llvm::Value*> > std::_Rb_tree<unsigned long, std::pair<unsigned long const,
llvm::Value*>, std::_Select1st<std::pair<unsigned long const, llvm::Value*> >,
std::less<unsigned long>, std::allocator<std::pair<unsigned long const,
llvm::Value*> > >::_M_emplace_hint_unique<std::piecewise_construct_t const&,
std::tuple<unsigned long&&>, std::tuple<>
>(std::_Rb_tree_const_iterator<std::pair<unsigned long const, llvm::Value*> >,
std::piecewise_construct_t const&, std::tuple<unsigned long&&>&&,
std::tuple<>&&)
/usr/bin/../lib/gcc/x86_64-linux-gnu/7.5.0/../../../../include/c++/7.5.0/bits/stl_tree.h:2397:0
 #9 0x00000000077320ef
clang::CodeGen::CodeGenFunction::EmitAsmStmt(clang::AsmStmt const&)
/home/xxx/data/git/llvm-project/clang/lib/CodeGen/CGStmt.cpp:0:23
#10 0x000000000771e287 clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt
const*, llvm::ArrayRef<clang::Attr const*>)
/home/xxx/data/git/llvm-project/clang/lib/CodeGen/CGStmt.cpp:152:32
#11 0x00000000077367c8
clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt
const&, bool, clang::CodeGen::AggValueSlot)
/home/xxx/data/git/llvm-project/clang/lib/CodeGen/CGStmt.cpp:416:11
#12 0x0000000007841dec
clang::CodeGen::CodeGenFunction::EmitFunctionBody(clang::Stmt const*)
/home/xxx/data/git/llvm-project/clang/lib/CodeGen/CodeGenFunction.cpp:1147:5
#13 0x0000000007843de2
clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl,
llvm::Function*, clang::CodeGen::CGFunctionInfo const&)
/home/xxx/data/git/llvm-project/clang/lib/CodeGen/CodeGenFunction.cpp:1322:7
#14 0x00000000078a5878
clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl,
llvm::GlobalValue*)
/home/xxx/data/git/llvm-project/clang/lib/CodeGen/CodeGenModule.cpp:4528:3
#15 0x000000000788f7dc
clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl,
llvm::GlobalValue*)
/home/xxx/data/git/llvm-project/clang/lib/CodeGen/CodeGenModule.cpp:2891:3
#16 0x0000000007899c6a
clang::CodeGen::CodeGenModule::EmitGlobal(clang::GlobalDecl)
/home/xxx/data/git/llvm-project/clang/lib/CodeGen/CodeGenModule.cpp:2642:5
#17 0x00000000078ae3ef
clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*)
/home/xxx/data/git/llvm-project/clang/lib/CodeGen/CodeGenModule.cpp:5342:5
#18 0x00000000099efef7 (anonymous
namespace)::CodeGeneratorImpl::HandleTopLevelDecl(clang::DeclGroupRef)
/home/xxx/data/git/llvm-project/clang/lib/CodeGen/ModuleBuilder.cpp:169:35
#19 0x00000000099e69f6
clang::BackendConsumer::HandleTopLevelDecl(clang::DeclGroupRef)
/home/xxx/data/git/llvm-project/clang/lib/CodeGen/CodeGenAction.cpp:216:11
#20 0x000000000c81d02d clang::ParseAST(clang::Sema&, bool, bool)
/home/xxx/data/git/llvm-project/clang/lib/Parse/ParseAST.cpp:162:31
#21 0x000000000861c2a2 clang::ASTFrontendAction::ExecuteAction()
/home/xxx/data/git/llvm-project/clang/lib/Frontend/FrontendAction.cpp:1059:1
#22 0x00000000099decd8 clang::CodeGenAction::ExecuteAction()
/home/xxx/data/git/llvm-project/clang/lib/CodeGen/CodeGenAction.cpp:1184:28
#23 0x000000000861a51a clang::FrontendAction::Execute()
/home/xxx/data/git/llvm-project/clang/lib/Frontend/FrontendAction.cpp:954:10
#24 0x000000000854eaa7 llvm::Error::operator bool()
/home/xxx/data/git/llvm-project/llvm/include/llvm/Support/Error.h:0:0
#25 0x000000000854eaa7
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
/home/xxx/data/git/llvm-project/clang/lib/Frontend/CompilerInstance.cpp:984:0
#26 0x00000000088f183f clang::CompilerInstance::getFrontendOpts()
/home/xxx/data/git/llvm-project/clang/include/clang/Frontend/CompilerInstance.h:0:0
#27 0x00000000088f183f
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
/home/xxx/data/git/llvm-project/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:279:0
#28 0x0000000000b094cc llvm::TimeTraceScope::~TimeTraceScope()
/home/xxx/data/git/llvm-project/llvm/include/llvm/Support/TimeProfiler.h:0:0
#29 0x0000000000b094cc cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) /home/xxx/data/git/llvm-project/clang/tools/driver/cc1_main.cpp:241:0
#30 0x0000000000afaf3b ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&)
/home/xxx/data/git/llvm-project/clang/tools/driver/driver.cpp:330:12
#31 0x0000000000af6966 main
/home/xxx/data/git/llvm-project/clang/tools/driver/driver.cpp:407:12
#32 0x00007f1f2c612b97 __libc_start_main
/build/glibc-2ORdQG/glibc-2.27/csu/../csu/libc-start.c:344:0
#33 0x0000000000af38ea _start
(/data/xxx/git/llvm-project/build/bin/clang-11+0xaf38ea)
clang-11: error: unable to execute command: Aborted (core dumped)
clang-11: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 11.1.0 (https://github.com/llvm/llvm-project.git
1fdec59bffc11ae37eb51a1b9869f0696bfd5312)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /data/xxx/git/llvm-project/build/bin
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/poc-e50460.c
clang-11: note: diagnostic msg: /tmp/poc-e50460.sh
clang-11: note: diagnostic msg:

********************


$ cat /tmp/poc-e50460.c

# 1 "<built-in>"
# 1 "poc.c"
int a;
int main() { asm("" : "=a"(a), "=d"(a) : "1"(.1)); }

$ cat /tmp/poc-e50460.sh

# Crash reproducer for clang version 11.1.0
(https://github.com/llvm/llvm-project.git
1fdec59bffc11ae37eb51a1b9869f0696bfd5312)
# Driver args: "poc.c"
# Original command:  "/data/zhan3299/git/llvm-project/build/bin/clang-11"
"-cc1" "-triple" "x86_64-unknown-linux-gnu" "-emit-obj" "-mrelax-all"
"-disable-free" "-main-file-name" "poc.c" "-mrelocation-model" "static"
"-mframe-pointer=all" "-fmath-errno" "-fno-rounding-math"
"-mconstructor-aliases" "-munwind-tables" "-target-cpu" "x86-64"
"-fno-split-dwarf-inlining" "-debugger-tuning=gdb" "-resource-dir"
"/data/zhan3299/git/llvm-project/build/lib/clang/11.1.0" "-internal-isystem"
"/usr/local/include" "-internal-isystem"
"/data/zhan3299/git/llvm-project/build/lib/clang/11.1.0/include"
"-internal-externc-isystem" "/usr/include/x86_64-linux-gnu"
"-internal-externc-isystem" "/include" "-internal-externc-isystem"
"/usr/include" "-fdebug-compilation-dir"
"/data/zhan3299/docker_share/clang/11.x" "-ferror-limit" "19"
"-fgnuc-version=4.2.1" "-fcolor-diagnostics" "-faddrsig" "-o"
"/tmp/poc-00c026.o" "-x" "c" "poc.c"
 "/data/zhan3299/git/llvm-project/build/bin/clang-11" "-cc1" "-triple"
"x86_64-unknown-linux-gnu" "-emit-obj" "-mrelax-all" "-disable-free"
"-main-file-name" "poc.c" "-mrelocation-model" "static" "-mframe-pointer=all"
"-fmath-errno" "-fno-rounding-math" "-mconstructor-aliases" "-munwind-tables"
"-target-cpu" "x86-64" "-fno-split-dwarf-inlining" "-debugger-tuning=gdb"
"-ferror-limit" "19" "-fgnuc-version=4.2.1" "-fcolor-diagnostics" "-faddrsig"
"-x" "c" "poc-e50460.c"

-- 
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/20210212/43bec780/attachment.html>


More information about the llvm-bugs mailing list