Yeah, I can reproduce that. I can't say if this is something that could be triggered without the source change. I don't know that much about this code.
I've been taking a fairly casual approach to this migration, because I just can't actually dig into every line of code/use of pointee types. So if the assertions ever do fire on valid code, I or someone will certainly have to look into them, but I haven't done that work up front, generally. On Wed, May 27, 2015 at 3:45 PM, Gao, Yunzhong < [email protected]> wrote: > Ah, sorry I did not provide more context before pulling you in. > > The assertion is related to GetElementPointer and I thought you may have > worked on this recently; > also there was no assertion before your r234096+r234097. I am not sure if > the assertion indicates > a real problem here because I had to modify the compiler source to show > the problem. You probably > know better. > > > [Step#1] apply the following patch: it comments out an optimization. > > Index: llvm/tools/clang/lib/CodeGen/CGExprCXX.cpp > =================================================================== > --- llvm/tools/clang/lib/CodeGen/CGExprCXX.cpp (revision 238351) > +++ llvm/tools/clang/lib/CodeGen/CGExprCXX.cpp (working copy) > @@ -953,10 +953,12 @@ > assert(getContext().hasSameUnqualifiedType(ElementType, > Init->getType()) && > "got wrong type of element to initialize"); > > +#if 0 > // If we have an empty initializer list, we can usually use memset. > if (auto *ILE = dyn_cast<InitListExpr>(Init)) > if (ILE->getNumInits() == 0 && TryMemsetInitialization()) > return; > +#endif > > // Create the loop blocks. > llvm::BasicBlock *EntryBB = Builder.GetInsertBlock(); > > > [Step#2] Compile the following test case: > > // test.cpp > int n; > struct T { int a; }; > void *r = new T[n][3]{ { 1, 2, 3 }, { 4, 5, 6 } }; > > > $ build/Debug+Asserts/bin/clang -S -std=c++11 -emit-llvm -o - test.cpp > clang: llvm/include/llvm/IR/Instructions.h:842: static > llvm::GetElementPtrInst* llvm::GetElementPtrInst::Create(llvm::Type*, > llvm::Value*, llvm::ArrayRef<llvm::Value*>, const llvm::Twine&, > llvm::Instruction*): Assertion `PointeeType == > cast<PointerType>(Ptr->getType()->getScalarType())->getElementType()' > failed. > 0 clang 0x00000000046113de > llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 44 > 1 clang 0x00000000046116f3 > 2 clang 0x00000000046101f4 > 3 libpthread.so.0 0x00007fedccedf340 > 4 libc.so.6 0x00007fedcc11bf79 gsignal + 57 > 5 libc.so.6 0x00007fedcc11f388 abort + 328 > 6 libc.so.6 0x00007fedcc114e36 > 7 libc.so.6 0x00007fedcc114ee2 > 8 clang 0x00000000017077ff > 9 clang 0x00000000017078af > 10 clang 0x0000000001764c8c > 11 clang 0x00000000018f5662 > clang::CodeGen::CodeGenFunction::EmitNewArrayInitializer(clang::CXXNewExpr > const*, clang::QualType, llvm::Type*, llvm::Value*, llvm::Value*, > llvm::Value*) + 3100 > 12 clang 0x00000000018f57a6 > 13 clang 0x00000000018f6d60 > clang::CodeGen::CodeGenFunction::EmitCXXNewExpr(clang::CXXNewExpr const*) + > 1950 > 14 clang 0x000000000190489c > 15 clang 0x00000000019154af > 16 clang 0x00000000019038d2 > 17 clang 0x00000000019095ba > 18 clang 0x0000000001917257 > 19 clang 0x00000000019156d7 > 20 clang 0x00000000019038d2 > 21 clang 0x00000000019141b2 > clang::CodeGen::CodeGenFunction::EmitScalarExpr(clang::Expr const*, bool) + > 128 > 22 clang 0x00000000018b2e75 > clang::CodeGen::CodeGenFunction::EmitScalarInit(clang::Expr const*, > clang::ValueDecl const*, clang::CodeGen::LValue, bool) + 99 > 23 clang 0x00000000018bb9b2 > 24 clang 0x00000000018bc0b7 > clang::CodeGen::CodeGenFunction::EmitCXXGlobalVarDeclInit(clang::VarDecl > const&, llvm::Constant*, bool) + 437 > 25 clang 0x00000000018bdd1f > clang::CodeGen::CodeGenFunction::GenerateCXXGlobalVarDeclInitFunc(llvm::Function*, > clang::VarDecl const*, llvm::GlobalVariable*, bool) + 501 > 26 clang 0x00000000018bcda1 > clang::CodeGen::CodeGenModule::EmitCXXGlobalVarDeclInitFunc(clang::VarDecl > const*, llvm::GlobalVariable*, bool) + 615 > 27 clang 0x0000000001774193 > clang::CodeGen::CodeGenModule::EmitGlobalVarDefinition(clang::VarDecl > const*) + 2291 > 28 clang 0x000000000177216f > clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, > llvm::GlobalValue*) + 531 > 29 clang 0x00000000017719ca > clang::CodeGen::CodeGenModule::EmitGlobal(clang::GlobalDecl) + 796 > 30 clang 0x00000000017792a2 > clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*) + 438 > 31 clang 0x00000000016c6215 > 32 clang 0x00000000016aabb6 > 33 clang 0x00000000019ac057 clang::ParseAST(clang::Sema&, bool, > bool) + 553 > 34 clang 0x00000000013a8fe2 > clang::ASTFrontendAction::ExecuteAction() + 322 > 35 clang 0x00000000016ad592 > clang::CodeGenAction::ExecuteAction() + 1486 > 36 clang 0x00000000013a8ac1 clang::FrontendAction::Execute() + > 139 > 37 clang 0x000000000136c902 > clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 772 > 38 clang 0x000000000132dadb > clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 993 > 39 clang 0x0000000001318d68 cc1_main(llvm::ArrayRef<char > const*>, char const*, void*) + 770 > 40 clang 0x0000000001327500 > 41 clang 0x0000000001327ae7 main + 1074 > 42 libc.so.6 0x00007fedcc106ec5 __libc_start_main + 245 > 43 clang 0x0000000001317469 > Stack dump: > 0. Program arguments: build/Debug+Asserts/bin/clang -cc1 -triple > x86_64-unknown-linux-gnu -emit-llvm -disable-free -main-file-name test.cpp > -mrelocation-model static -mthread-model posix -mdisable-fp-elim > -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables > -fuse-init-array -target-cpu x86-64 -target-linker-version 2.24 > -dwarf-column-info -coverage-file /tmp/- -resource-dir > build/Debug+Asserts/bin/../lib/clang/3.7.0 -internal-isystem > /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8 > -internal-isystem > /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/x86_64-linux-gnu/c++/4.8 > -internal-isystem > /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/x86_64-linux-gnu/c++/4.8 > -internal-isystem > /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/backward > -internal-isystem /usr/local/include -internal-isystem > build/Debug+Asserts/bin/../lib/clang/3.7.0/include > -internal-externc-isystem /usr/include/x86_64-linux-gnu > -internal-externc-isystem /include -internal-externc-isystem /usr/include > -std=c++11 -fdeprecated-macro -fdebug-compilation-dir /tmp -ferror-limit 19 > -fmessage-length 205 -mstackrealign -fobjc-runtime=gcc -fcxx-exceptions > -fexceptions -fdiagnostics-show-option -o - -x c++ test.cpp > 1. <eof> parser at end of file > 2. test.cpp:4:7: LLVM IR generation of declaration 'r' > 3. test.cpp:4:7: Generating code for declaration 'r' > clang: error: unable to execute command: Aborted (core dumped) > clang: error: clang frontend command failed due to signal (use -v to see > invocation) > clang version 3.7.0 (trunk 238351) > Target: x86_64-unknown-linux-gnu > Thread model: posix > clang: 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: note: diagnostic msg: > ******************** > > PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT: > Preprocessed source(s) and associated run script(s) are located at: > clang: note: diagnostic msg: /tmp/test-d13456.cpp > clang: note: diagnostic msg: /tmp/test-d13456.sh > clang: note: diagnostic msg: > > > ________________________________________ > From: David Blaikie [[email protected]] > Sent: Wednesday, May 27, 2015 3:26 PM > To: [email protected] > Cc: Gao, Yunzhong; Richard Smith; [email protected]; Robinson, Paul; > [email protected]; Anton Korobeynikov; llvm cfe > Subject: Re: [PATCH] C99 partial re-initialization behavior (DR-253) > > On Wed, May 27, 2015 at 1:34 PM, Yunzhong Gao < > [email protected]<mailto:[email protected]>> > wrote: > Ping. > > Also add David Blaikie. He might have some insight on whether > lib/CodeGen/CGExprCXX.cpp#952-953 indicates any actual problem. > > Don't think I have any particular light to shed here... if you/we want to > dive into this deeper, the backtrace from the assertion might be useful. > > http://reviews.llvm.org/D5789?id=22530#inline-76127 > > > http://reviews.llvm.org/D5789 > > EMAIL PREFERENCES > http://reviews.llvm.org/settings/panel/emailpreferences/ > > > >
_______________________________________________ cfe-commits mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
