<div dir="ltr"><div>Anyone have any clues as to what could be causing this? With llvm assertions off it works fine.</div><div><br></div><div><br></div><div><br></div>llvm-3.9.1.src/lib/IR/Metadata.cpp:540: void llvm::MDNode::resolve(): Assertion `isUniqued() && "Expected this to be uniqued"' failed.<br><div><br></div><div><div>#3  0x00007ffff6936c82 in __GI___assert_fail (assertion=0x658a598 "isUniqued() && \"Expected this to be uniqued\"", </div><div>    file=0x6589d50 "/home/andy/Downloads/llvm-3.9.1.src/lib/IR/Metadata.cpp", line=540, </div><div>    function=0x6596850 <llvm::MDNode::resolve()::__PRETTY_FUNCTION__> "void llvm::MDNode::resolve()") at assert.c:101</div><div>#4  0x0000000004757368 in llvm::MDNode::resolve (this=0x79ebaa0)</div><div>    at /home/andy/Downloads/llvm-3.9.1.src/lib/IR/Metadata.cpp:540</div><div>#5  0x0000000004757679 in llvm::MDNode::resolveCycles (this=0x79ebaa0)</div><div>    at /home/andy/Downloads/llvm-3.9.1.src/lib/IR/Metadata.cpp:589</div><div>#6  0x0000000004699c2d in llvm::DIBuilder::finalize (this=0x79c71b0)</div><div>    at /home/andy/Downloads/llvm-3.9.1.src/lib/IR/DIBuilder.cpp:97</div><div>#7  0x000000000150f2ee in ZigLLVMDIBuilderFinalize (dibuilder=0x79c71b0) at /home/andy/dev/zig/src/zig_llvm.cpp:496</div></div><div><br></div><div>Here's the LLVMDumpModule output:</div><div><br></div><div><div>; ModuleID = './test.zig'</div><div>source_filename = "./test.zig"</div><div>target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"</div><div>target triple = "x86_64-unknown-linux-gnu"</div><div><br></div><div>@0 = internal unnamed_addr constant i64 4</div><div><br></div><div>; Function Attrs: nounwind</div><div>declare void @llvm.debugtrap() #0</div><div><br></div><div>; Function Attrs: argmemonly nounwind</div><div>declare void @llvm.memcpy.p0i8.p0i8.i64(i8* nocapture writeonly, i8* nocapture readonly, i64, i32, i1) #1</div><div><br></div><div>; Function Attrs: argmemonly nounwind</div><div>declare void @llvm.memset.p0i8.i64(i8* nocapture writeonly, i8, i64, i32, i1) #1</div><div><br></div><div>; Function Attrs: nounwind</div><div>define internal fastcc void @_constDeclsInStruct() #2 !dbg !9 {</div><div>Entry:</div><div>  call fastcc void @_assert(i1 true), !dbg !12</div><div>  ret void, !dbg !14</div><div>}</div><div><br></div><div>; Function Attrs: nounwind</div><div>define internal fastcc void @_assert(i1) #2 !dbg !15 {</div><div>Entry:</div><div>  %b = alloca i1, align 1</div><div>  store i1 %0, i1* %b</div><div>  call void @llvm.dbg.declare(metadata i1* %b, metadata !20, metadata !21), !dbg !22</div><div>  %1 = load i1, i1* %b, !dbg !23</div><div>  %2 = icmp eq i1 %1, false, !dbg !26</div><div>  br i1 %2, label %Then, label %Else, !dbg !26</div><div><br></div><div>Then:                                             ; preds = %Entry</div><div>  call void @llvm.debugtrap(), !dbg !27</div><div>  unreachable, !dbg !27</div><div><br></div><div>Else:                                             ; preds = %Entry</div><div>  ret void, !dbg !28</div><div>}</div><div><br></div><div>; Function Attrs: nounwind readnone</div><div>declare void @llvm.dbg.declare(metadata, metadata, metadata) #3</div><div><br></div><div>attributes #0 = { nounwind }</div><div>attributes #1 = { argmemonly nounwind }</div><div>attributes #2 = { nounwind "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" }</div><div>attributes #3 = { nounwind readnone }</div><div><br></div><div>!llvm.module.flags = !{!0}</div><div>!<a href="http://llvm.dbg.cu">llvm.dbg.cu</a> = !{!1}</div><div><br></div><div>!0 = !{i32 2, !"Debug Info Version", i32 3}</div><div>!1 = distinct !DICompileUnit(language: DW_LANG_C99, file: !2, producer: "zig 0.0.0", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !3, globals: !4)</div><div>!2 = !DIFile(filename: "./test.zig", directory: ".")</div><div>!3 = !{}</div><div>!4 = !{!5}</div><div>!5 = distinct !DIGlobalVariable(name: "count_plus_one", linkageName: "count_plus_one", scope: !6, file: !7, line: 6, type: !8, isLocal: true, isDefinition: true, variable: i64 4)</div><div>!6 = !DIBasicType(name: "void", encoding: DW_ATE_unsigned)</div><div>!7 = !DIFile(filename: "test.zig", directory: ".")</div><div>!8 = !DIBasicType(name: "isize", size: 64, align: 64, encoding: DW_ATE_signed)</div><div>!9 = distinct !DISubprogram(name: "constDeclsInStruct", scope: !7, file: !7, line: 1, type: !10, isLocal: true, isDefinition: true, scopeLine: 1, isOptimized: false, unit: !1, variables: !3)</div><div>!10 = !DISubroutineType(types: !11)</div><div>!11 = !{!6}</div><div>!12 = !DILocation(line: 2, column: 11, scope: !13)</div><div>!13 = distinct !DILexicalBlock(scope: !9, file: !7, line: 1, column: 25)</div><div>!14 = !DILocation(line: 2, column: 52, scope: !9)</div><div>!15 = distinct !DISubprogram(name: "assert", scope: !7, file: !7, line: 10, type: !16, isLocal: true, isDefinition: true, scopeLine: 10, isOptimized: false, unit: !1, variables: !19)</div><div>!16 = !DISubroutineType(types: !17)</div><div>!17 = !{!6, !18}</div><div>!18 = !DIBasicType(name: "bool", size: 8, align: 8, encoding: DW_ATE_boolean)</div><div>!19 = !{!20}</div><div>!20 = !DILocalVariable(name: "b", arg: 1, scope: !15, file: !7, line: 10, type: !18)</div><div>!21 = !DIExpression()</div><div>!22 = !DILocation(line: 10, column: 15, scope: !15)</div><div>!23 = !DILocation(line: 11, column: 10, scope: !24)</div><div>!24 = distinct !DILexicalBlock(scope: !25, file: !7, line: 10, column: 24)</div><div>!25 = distinct !DILexicalBlock(scope: !15, file: !7, line: 10, column: 15)</div><div>!26 = !DILocation(line: 11, column: 9, scope: !24)</div><div>!27 = !DILocation(line: 11, column: 13, scope: !24)</div><div>!28 = !DILocation(line: 11, column: 5, scope: !25)</div></div><div><br></div><div><br></div><div><br></div><div><br></div><div>It's reproducible. Is there anything I can print about this MDNode to find out why it's not uniqued?</div><div><br></div><div><br></div><div><br></div><div><div>(gdb) print this</div><div>$2 = (llvm::MDNode * const) 0x79ebaa0</div><div>(gdb) print this[0]</div><div>$3 = {<llvm::Metadata> = {SubclassID = 12 '\f', Storage = 2 '\002', SubclassData16 = 19, SubclassData32 = 0}, </div><div>  NumOperands = 8, NumUnresolved = 0, Context = {Ptr = {Val = {Value = 127843060}}}}</div></div><div><br></div><div><br></div><div><br></div><div><br></div><div>Is there any way to tell which node in the printed IR this MDNode corresponds to?</div><div><br></div><div>One more piece of data, I'm not sure this will be meaningful but here's the source that caused this problem:</div><div><br></div><div><br></div><div><br></div><div><br></div><div><div>fn constDeclsInStruct() {</div><div>    assert(GenericDataThing(3).count_plus_one == 4);</div><div>}</div><div>fn GenericDataThing(inline count: isize) -> type {</div><div>    struct {</div><div>        const count_plus_one = count + 1;</div><div>    }</div><div>}</div><div><br></div><div>pub fn assert(b: bool) {</div><div>    if (!b) @unreachable()</div><div>}</div><div><br></div></div><div><br></div><div>Regards,</div><div>Andrew</div></div>