<div dir="ltr">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.<br><br>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.<br><div class="gmail_extra"><br><div class="gmail_quote">On Wed, May 27, 2015 at 3:45 PM, Gao, Yunzhong <span dir="ltr"><<a href="mailto:yunzhong_gao@playstation.sony.com" target="_blank">yunzhong_gao@playstation.sony.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Ah, sorry I did not provide more context before pulling you in.<br>
<br>
The assertion is related to GetElementPointer and I thought you may have worked on this recently;<br>
also there was no assertion before your r234096+r234097. I am not sure if the assertion indicates<br>
a real problem here because I had to modify the compiler source to show the problem. You probably<br>
know better.<br>
<br>
<br>
[Step#1] apply the following patch: it comments out an optimization.<br>
<br>
Index: llvm/tools/clang/lib/CodeGen/CGExprCXX.cpp<br>
===================================================================<br>
--- llvm/tools/clang/lib/CodeGen/CGExprCXX.cpp (revision 238351)<br>
+++ llvm/tools/clang/lib/CodeGen/CGExprCXX.cpp (working copy)<br>
@@ -953,10 +953,12 @@<br>
assert(getContext().hasSameUnqualifiedType(ElementType, Init->getType()) &&<br>
"got wrong type of element to initialize");<br>
<br>
+#if 0<br>
// If we have an empty initializer list, we can usually use memset.<br>
<span class=""> if (auto *ILE = dyn_cast<InitListExpr>(Init))<br>
</span><span class=""> if (ILE->getNumInits() == 0 && TryMemsetInitialization())<br>
return;<br>
</span>+#endif<br>
<br>
// Create the loop blocks.<br>
llvm::BasicBlock *EntryBB = Builder.GetInsertBlock();<br>
<br>
<br>
[Step#2] Compile the following test case:<br>
<span class=""><br>
// test.cpp<br>
int n;<br>
struct T { int a; };<br>
void *r = new T[n][3]{ { 1, 2, 3 }, { 4, 5, 6 } };<br>
<br>
<br>
</span>$ build/Debug+Asserts/bin/clang -S -std=c++11 -emit-llvm -o - test.cpp<br>
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.<br>
0 clang 0x00000000046113de llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 44<br>
1 clang 0x00000000046116f3<br>
2 clang 0x00000000046101f4<br>
3 libpthread.so.0 0x00007fedccedf340<br>
4 libc.so.6 0x00007fedcc11bf79 gsignal + 57<br>
5 libc.so.6 0x00007fedcc11f388 abort + 328<br>
6 libc.so.6 0x00007fedcc114e36<br>
7 libc.so.6 0x00007fedcc114ee2<br>
8 clang 0x00000000017077ff<br>
9 clang 0x00000000017078af<br>
10 clang 0x0000000001764c8c<br>
11 clang 0x00000000018f5662 clang::CodeGen::CodeGenFunction::EmitNewArrayInitializer(clang::CXXNewExpr const*, clang::QualType, llvm::Type*, llvm::Value*, llvm::Value*, llvm::Value*) + 3100<br>
12 clang 0x00000000018f57a6<br>
13 clang 0x00000000018f6d60 clang::CodeGen::CodeGenFunction::EmitCXXNewExpr(clang::CXXNewExpr const*) + 1950<br>
14 clang 0x000000000190489c<br>
15 clang 0x00000000019154af<br>
16 clang 0x00000000019038d2<br>
17 clang 0x00000000019095ba<br>
18 clang 0x0000000001917257<br>
19 clang 0x00000000019156d7<br>
20 clang 0x00000000019038d2<br>
21 clang 0x00000000019141b2 clang::CodeGen::CodeGenFunction::EmitScalarExpr(clang::Expr const*, bool) + 128<br>
22 clang 0x00000000018b2e75 clang::CodeGen::CodeGenFunction::EmitScalarInit(clang::Expr const*, clang::ValueDecl const*, clang::CodeGen::LValue, bool) + 99<br>
23 clang 0x00000000018bb9b2<br>
24 clang 0x00000000018bc0b7 clang::CodeGen::CodeGenFunction::EmitCXXGlobalVarDeclInit(clang::VarDecl const&, llvm::Constant*, bool) + 437<br>
25 clang 0x00000000018bdd1f clang::CodeGen::CodeGenFunction::GenerateCXXGlobalVarDeclInitFunc(llvm::Function*, clang::VarDecl const*, llvm::GlobalVariable*, bool) + 501<br>
26 clang 0x00000000018bcda1 clang::CodeGen::CodeGenModule::EmitCXXGlobalVarDeclInitFunc(clang::VarDecl const*, llvm::GlobalVariable*, bool) + 615<br>
27 clang 0x0000000001774193 clang::CodeGen::CodeGenModule::EmitGlobalVarDefinition(clang::VarDecl const*) + 2291<br>
28 clang 0x000000000177216f clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, llvm::GlobalValue*) + 531<br>
29 clang 0x00000000017719ca clang::CodeGen::CodeGenModule::EmitGlobal(clang::GlobalDecl) + 796<br>
30 clang 0x00000000017792a2 clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*) + 438<br>
31 clang 0x00000000016c6215<br>
32 clang 0x00000000016aabb6<br>
33 clang 0x00000000019ac057 clang::ParseAST(clang::Sema&, bool, bool) + 553<br>
34 clang 0x00000000013a8fe2 clang::ASTFrontendAction::ExecuteAction() + 322<br>
35 clang 0x00000000016ad592 clang::CodeGenAction::ExecuteAction() + 1486<br>
36 clang 0x00000000013a8ac1 clang::FrontendAction::Execute() + 139<br>
37 clang 0x000000000136c902 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 772<br>
38 clang 0x000000000132dadb clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 993<br>
39 clang 0x0000000001318d68 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) + 770<br>
40 clang 0x0000000001327500<br>
41 clang 0x0000000001327ae7 main + 1074<br>
42 libc.so.6 0x00007fedcc106ec5 __libc_start_main + 245<br>
43 clang 0x0000000001317469<br>
Stack dump:<br>
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<br>
1. <eof> parser at end of file<br>
2. test.cpp:4:7: LLVM IR generation of declaration 'r'<br>
3. test.cpp:4:7: Generating code for declaration 'r'<br>
clang: error: unable to execute command: Aborted (core dumped)<br>
clang: error: clang frontend command failed due to signal (use -v to see invocation)<br>
clang version 3.7.0 (trunk 238351)<br>
Target: x86_64-unknown-linux-gnu<br>
Thread model: posix<br>
clang: note: diagnostic msg: PLEASE submit a bug report to <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_bugs_&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=BSqEv9KvKMW_Ob8SyngJ70KdZISM_ASROnREeq0cCxk&m=d74GpcCvZq1UR6TcoSLT0uRVwrdaraU0YGwVFA26jvA&s=HtrPfch2nLv-Wgj6R-rU79cV6nN_8Q9_DulLgsvylyU&e=" target="_blank">http://llvm.org/bugs/</a> and include the crash backtrace, preprocessed source, and associated run script.<br>
clang: note: diagnostic msg:<br>
********************<br>
<br>
PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:<br>
Preprocessed source(s) and associated run script(s) are located at:<br>
clang: note: diagnostic msg: /tmp/test-d13456.cpp<br>
clang: note: diagnostic msg: /tmp/test-d13456.sh<br>
clang: note: diagnostic msg:<br>
<br>
<br>
________________________________________<br>
From: David Blaikie [<a href="mailto:dblaikie@gmail.com">dblaikie@gmail.com</a>]<br>
Sent: Wednesday, May 27, 2015 3:26 PM<br>
To: <a href="mailto:reviews%2BD5789%2Bpublic%2B1cf6f6f096f4f610@reviews.llvm.org">reviews+D5789+public+1cf6f6f096f4f610@reviews.llvm.org</a><br>
Cc: Gao, Yunzhong; Richard Smith; <a href="mailto:dccitaliano@gmail.com">dccitaliano@gmail.com</a>; Robinson, Paul; <a href="mailto:arthur.j.odwyer%2Bphab%2Bgithub@gmail.com">arthur.j.odwyer+phab+github@gmail.com</a>; Anton Korobeynikov; llvm cfe<br>
Subject: Re: [PATCH] C99 partial re-initialization behavior (DR-253)<br>
<div class="HOEnZb"><div class="h5"><br>
On Wed, May 27, 2015 at 1:34 PM, Yunzhong Gao <<a href="mailto:Yunzhong_Gao@playstation.sony.com">Yunzhong_Gao@playstation.sony.com</a><mailto:<a href="mailto:Yunzhong_Gao@playstation.sony.com">Yunzhong_Gao@playstation.sony.com</a>>> wrote:<br>
Ping.<br>
<br>
Also add David Blaikie. He might have some insight on whether lib/CodeGen/CGExprCXX.cpp#952-953 indicates any actual problem.<br>
<br>
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.<br>
<br>
<a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__reviews.llvm.org_D5789-3Fid-3D22530-23inline-2D76127&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=BSqEv9KvKMW_Ob8SyngJ70KdZISM_ASROnREeq0cCxk&m=d74GpcCvZq1UR6TcoSLT0uRVwrdaraU0YGwVFA26jvA&s=bsfN2gL7lP4yIx-9qCX1p1OkCjLbLgxMcNdvkRuzAaI&e=" target="_blank">http://reviews.llvm.org/D5789?id=22530#inline-76127</a><br>
<br>
<br>
<a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__reviews.llvm.org_D5789&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=BSqEv9KvKMW_Ob8SyngJ70KdZISM_ASROnREeq0cCxk&m=d74GpcCvZq1UR6TcoSLT0uRVwrdaraU0YGwVFA26jvA&s=kO0KjUT47VTWtYVY0Z-dATOQ1qYfOPWRVQrS2cVYlmc&e=" target="_blank">http://reviews.llvm.org/D5789</a><br>
<br>
EMAIL PREFERENCES<br>
<a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__reviews.llvm.org_settings_panel_emailpreferences_&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=BSqEv9KvKMW_Ob8SyngJ70KdZISM_ASROnREeq0cCxk&m=d74GpcCvZq1UR6TcoSLT0uRVwrdaraU0YGwVFA26jvA&s=-G6-s_e0pmDojNIw_MIUTNtvG2zw3YaPHqxY7lQ4wGA&e=" target="_blank">http://reviews.llvm.org/settings/panel/emailpreferences/</a><br>
<br>
<br>
<br>
</div></div></blockquote></div><br></div></div>