Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ICE with LDC >= 1.16.0 #3094

Closed
PetarKirov opened this issue Jun 23, 2019 · 8 comments · Fixed by #3095
Closed

ICE with LDC >= 1.16.0 #3094

PetarKirov opened this issue Jun 23, 2019 · 8 comments · Fixed by #3095

Comments

@PetarKirov
Copy link
Contributor

PetarKirov commented Jun 23, 2019

With ldc-1.16.0 and ldc-latest-ci = ldc-3f2a9303 I get the following ICE:

uname -a                                                                                                                                                                                  19:01:37 2019-06-23 (Sun)
Linux archlinux 5.1.7-arch1-1-ARCH #1 SMP PREEMPT Tue Jun 4 15:47:45 UTC 2019 x86_64 GNU/Linux
/home/zombinedev/dlang/ldc-1.16.0/bin/ldc2(_ZN4llvm3sys15PrintStackTraceERNS_11raw_ostreamE+0x2a)[0x2d7be5a]
/home/zombinedev/dlang/ldc-1.16.0/bin/ldc2(_ZN4llvm3sys17RunSignalHandlersEv+0x4c)[0x2d79ddc]
/home/zombinedev/dlang/ldc-1.16.0/bin/ldc2[0x2d79f47]
/usr/lib/libpthread.so.0(+0x13cb0)[0x7f54def51cb0]
/home/zombinedev/dlang/ldc-1.16.0/bin/ldc2(_Z9DtoAssignR3LocP6DValueS2_ib+0xb4)[0xdd3dc4]
/home/zombinedev/dlang/ldc-1.16.0/bin/ldc2[0xe07a2e]
/home/zombinedev/dlang/ldc-1.16.0/bin/ldc2[0xe08899]
/home/zombinedev/dlang/ldc-1.16.0/bin/ldc2(_Z14Statement_toIRP9StatementP7IRState+0x2a)[0xe05dba]
/home/zombinedev/dlang/ldc-1.16.0/bin/ldc2(_Z17DtoDefineFunctionP15FuncDeclarationb+0xd04)[0xdca8d4]
/home/zombinedev/dlang/ldc-1.16.0/bin/ldc2(_Z19Declaration_codegenP7DsymbolP7IRState+0x2a)[0xdbc27a]
/home/zombinedev/dlang/ldc-1.16.0/bin/ldc2[0xe1a8fc]
/home/zombinedev/dlang/ldc-1.16.0/bin/ldc2(_Z6toElemP10Expression+0x74)[0xe18eb4]
/home/zombinedev/dlang/ldc-1.16.0/bin/ldc2[0xe1fdea]
/home/zombinedev/dlang/ldc-1.16.0/bin/ldc2(_Z6toElemP10Expression+0x74)[0xe18eb4]
/home/zombinedev/dlang/ldc-1.16.0/bin/ldc2(_Z17DtoVarDeclarationP14VarDeclaration+0x95)[0xdd4925]
/home/zombinedev/dlang/ldc-1.16.0/bin/ldc2(_Z17DtoDeclarationExpP7Dsymbol+0x1d9)[0xdd4ff9]
/home/zombinedev/dlang/ldc-1.16.0/bin/ldc2[0xe1d3ac]
/home/zombinedev/dlang/ldc-1.16.0/bin/ldc2(_Z10toElemDtorP10Expression+0x74)[0xe190f4]
/home/zombinedev/dlang/ldc-1.16.0/bin/ldc2[0xe065d6]
/home/zombinedev/dlang/ldc-1.16.0/bin/ldc2[0xe08899]
/home/zombinedev/dlang/ldc-1.16.0/bin/ldc2[0xe08899]
/home/zombinedev/dlang/ldc-1.16.0/bin/ldc2(_Z14Statement_toIRP9StatementP7IRState+0x2a)[0xe05dba]
/home/zombinedev/dlang/ldc-1.16.0/bin/ldc2(_Z17DtoDefineFunctionP15FuncDeclarationb+0xd04)[0xdca8d4]
/home/zombinedev/dlang/ldc-1.16.0/bin/ldc2[0xdbce18]
/home/zombinedev/dlang/ldc-1.16.0/bin/ldc2(_Z19Declaration_codegenP7Dsymbol+0x31)[0xdbc231]
/home/zombinedev/dlang/ldc-1.16.0/bin/ldc2(_Z13codegenModuleP7IRStateP6Module+0xe5)[0xde0de5]
/home/zombinedev/dlang/ldc-1.16.0/bin/ldc2(_ZN3ldc13CodeGenerator4emitEP6Module+0xdc)[0xe9d75c]
/home/zombinedev/dlang/ldc-1.16.0/bin/ldc2(_Z14codegenModulesR5ArrayIP6ModuleE+0x14c)[0xe6e01c]
/home/zombinedev/dlang/ldc-1.16.0/bin/ldc2(_Z13mars_mainBodyR5ParamR5ArrayIPKcES5_+0x1507)[0xc4bd27]
/home/zombinedev/dlang/ldc-1.16.0/bin/ldc2(_Z7cppmainiPPc+0x17e6)[0xe6ca16]
/home/zombinedev/dlang/ldc-1.16.0/bin/ldc2(_D2rt6dmain211_d_run_mainUiPPaPUAAaZiZ6runAllMFZv+0x50)[0x2fbf240]
/home/zombinedev/dlang/ldc-1.16.0/bin/ldc2(_d_run_main+0x218)[0x2fbf058]
/usr/lib/libc.so.6(__libc_start_main+0xf3)[0x7f54dead7ee3]
/home/zombinedev/dlang/ldc-1.16.0/bin/ldc2(_start+0x29)[0xb5ba09]
/home/zombinedev/dlang/ldc-1.16.0/bin/ldc2 failed with exit code -11.
ldc2: /home/vsts/work/1/s/gen/statements.cpp:112: virtual void ToIRVisitor::visit(ReturnStatement*): Assertion `sretPointer' failed.
/home/zombinedev/dlang/ldc-3f2a9303/bin/ldc2(_ZN4llvm3sys15PrintStackTraceERNS_11raw_ostreamE+0x2a)[0x2fefcca]
/home/zombinedev/dlang/ldc-3f2a9303/bin/ldc2(_ZN4llvm3sys17RunSignalHandlersEv+0x4c)[0x2fedacc]
/home/zombinedev/dlang/ldc-3f2a9303/bin/ldc2[0x2fedc37]
/usr/lib/libpthread.so.0(+0x13cb0)[0x7f3768067cb0]
/usr/lib/libc.so.6(gsignal+0x145)[0x7f3767c01755]
/usr/lib/libc.so.6(abort+0x125)[0x7f3767bec851]
/usr/lib/libc.so.6(+0x25727)[0x7f3767bec727]
/usr/lib/libc.so.6(+0x33026)[0x7f3767bfa026]
/home/zombinedev/dlang/ldc-3f2a9303/bin/ldc2[0xe46674]
/home/zombinedev/dlang/ldc-3f2a9303/bin/ldc2[0xe44719]
/home/zombinedev/dlang/ldc-3f2a9303/bin/ldc2(_Z14Statement_toIRP9StatementP7IRState+0x2a)[0xe429fa]
/home/zombinedev/dlang/ldc-3f2a9303/bin/ldc2(_Z17DtoDefineFunctionP15FuncDeclarationb+0xcdd)[0xe02bcd]
/home/zombinedev/dlang/ldc-3f2a9303/bin/ldc2(_Z19Declaration_codegenP7DsymbolP7IRState+0x2a)[0xdf38ea]
/home/zombinedev/dlang/ldc-3f2a9303/bin/ldc2[0xe57735]
/home/zombinedev/dlang/ldc-3f2a9303/bin/ldc2(_Z6toElemP10Expression+0x74)[0xe558d4]
/home/zombinedev/dlang/ldc-3f2a9303/bin/ldc2[0xe5e197]
/home/zombinedev/dlang/ldc-3f2a9303/bin/ldc2(_Z6toElemP10Expression+0x74)[0xe558d4]
/home/zombinedev/dlang/ldc-3f2a9303/bin/ldc2(_Z17DtoVarDeclarationP14VarDeclaration+0xa3)[0xe0ac13]
/home/zombinedev/dlang/ldc-3f2a9303/bin/ldc2(_Z17DtoDeclarationExpP7Dsymbol+0x1c1)[0xe0ebd1]
/home/zombinedev/dlang/ldc-3f2a9303/bin/ldc2[0xe5dfcc]
/home/zombinedev/dlang/ldc-3f2a9303/bin/ldc2(_Z10toElemDtorP10Expression+0x74)[0xe55b14]
/home/zombinedev/dlang/ldc-3f2a9303/bin/ldc2[0xe43006]
/home/zombinedev/dlang/ldc-3f2a9303/bin/ldc2[0xe44719]
/home/zombinedev/dlang/ldc-3f2a9303/bin/ldc2[0xe44719]
/home/zombinedev/dlang/ldc-3f2a9303/bin/ldc2(_Z14Statement_toIRP9StatementP7IRState+0x2a)[0xe429fa]
/home/zombinedev/dlang/ldc-3f2a9303/bin/ldc2(_Z17DtoDefineFunctionP15FuncDeclarationb+0xcdd)[0xe02bcd]
/home/zombinedev/dlang/ldc-3f2a9303/bin/ldc2[0xdf47a8]
/home/zombinedev/dlang/ldc-3f2a9303/bin/ldc2(_Z19Declaration_codegenP7Dsymbol+0x31)[0xdf38a1]
/home/zombinedev/dlang/ldc-3f2a9303/bin/ldc2(_Z13codegenModuleP7IRStateP6Module+0x11e)[0xe1870e]
/home/zombinedev/dlang/ldc-3f2a9303/bin/ldc2(_ZN3ldc13CodeGenerator4emitEP6Module+0xd8)[0xee0f28]
/home/zombinedev/dlang/ldc-3f2a9303/bin/ldc2(_Z14codegenModulesR5ArrayIP6ModuleE+0x14c)[0xeaf8bc]
/home/zombinedev/dlang/ldc-3f2a9303/bin/ldc2(_Z13mars_mainBodyR5ParamR5ArrayIPKcES5_+0x145f)[0xc8b95f]
/home/zombinedev/dlang/ldc-3f2a9303/bin/ldc2(_Z7cppmainiPPc+0x192d)[0xeae5fd]
/home/zombinedev/dlang/ldc-3f2a9303/bin/ldc2(_D2rt6dmain211_d_run_mainUiPPaPUAAaZiZ6runAllMFZv+0x50)[0x3245eb0]
/home/zombinedev/dlang/ldc-3f2a9303/bin/ldc2(_d_run_main+0x218)[0x3245cc8]
/usr/lib/libc.so.6(__libc_start_main+0xf3)[0x7f3767bedee3]
/home/zombinedev/dlang/ldc-3f2a9303/bin/ldc2(_start+0x29)[0xb92869]
/home/zombinedev/dlang/ldc-3f2a9303/bin/ldc2 failed with exit code -6.

ldc-1.15.0 and earlier compile the same code without problems. dmd-2.087.0-beta.1 dmd-2.086.1 and earlier also seem to work fine.

Sorry for the lack of a test case right now, I'll work on a reduced one soon.

@PetarKirov PetarKirov changed the title ICE [working on a reduced test case] ICE with LDC > 1.16.0 [working on a reduced test case] Jun 23, 2019
@PetarKirov PetarKirov changed the title ICE with LDC > 1.16.0 [working on a reduced test case] ICE with LDC >= 1.16.0 [working on a reduced test case] Jun 23, 2019
@kinke
Copy link
Member

kinke commented Jun 23, 2019

👍 for using a CI build to check for earlier assertions. :)

@PetarKirov
Copy link
Contributor Author

Yes, that was the idea 😉 As soon as I figure out the right way to cast a dustmite spell, you'll have also have a test case...

@kinke
Copy link
Member

kinke commented Jun 23, 2019

dustmite

It might be simpler/faster to use -vv and work your way up from the function containing the faulty (?) return statement (last lines before the crash).

@PetarKirov
Copy link
Contributor Author

PetarKirov commented Jun 23, 2019

So far Dustmite reduced my 6.4k LOC / 39 *.d (not including 6 indirect dub dependencies) files project to 1206 LOC (while still reproducing the same ICE). I'm looking at the --vv output but it's 25959 lines, so I think it may be easier to simply wait another hour or so.

@PetarKirov
Copy link
Contributor Author

[..]

Done in 7863 tests and 1 hour, 32 minutes, 2 secs, and 661 ms; reduced version is in ../dustmite.reduced

$ find $proj/ -type f -name '*.d' | wc -l
39

$ find $proj/ -type f -name '*.d' -exec cat '{}' ';' | wc -l
6394

$ find dustmite.reduced/ -type f -name '*.d' | wc -l
3

$ find dustmite.reduced/ -type f -name '*.d' -exec cat '{}' ';' | wc -l
31

😉

@PetarKirov
Copy link
Contributor Author

PetarKirov commented Jun 23, 2019

Final test case:

void printMembers(T, alias sink)(T)
{
    typeof(sink) inner_sink = msg => (sink, sink(msg));
}

class Node
{
    void toString(void delegate(const(char)) sink)
    {
        printMembers!(typeof(this), sink)(this);
    }
}
$ ldc2 --vv node.d
Targeting 'x86_64-unknown-linux-gnu' (CPU 'x86-64' with features '+cx16')
Building type: real
Building type: uint
Building type: ulong
CodeGenerator::emit(node)
* resetting 2384 Dsymbols
* *** Initializing D runtime declarations ***
* * building runtime module
* Import::codegen for node.object
* Ignoring Dsymbol::codegen for node.printMembers(T, alias sink)(T)
* ClassDeclaration::codegen: 'node.Node'
* * DtoResolveClass(node.Node): node.d(6)
* * * DtoResolveClass(object.Object): /home/zombinedev/dlang/ldc-3f2a9303/bin/../import/object.d(1038)
* * * * Building type: object.Object
* * * * * Building class type object.Object @ /home/zombinedev/dlang/ldc-3f2a9303/bin/../import/object.d(1038)
* * * * * * Instance size: 16
* * * * * * class type: %object.Object = type { [5 x i8*]*, i8* }
* * * Building type: node.Node
* * * * Building class type node.Node @ node.d(6)
* * * * * Instance size: 16
* * * * * class type: %node.Node = type { [6 x i8*]*, i8* }
* * DtoDefineFunction(node.Node.toString): node.d(8)
* * * isMember = this is: node.Node
* * * DtoFunctionType(void(void delegate(const(char)) sink))
* * * * Building type: void
* * * * Building type: void delegate(const(char))
* * * * * DtoFunctionType(void(const(char)))
* * * * * * Building type: void*
* * * * * * Building type: char
* * * * * * x86-64 ABI: Transforming argument types
* * * * * * Final function type: void (i8*, i8)
* * * * x86-64 ABI: Transforming argument types
* * * * Final function type: void (%node.Node*, { i8*, void (i8*, i8)* })
* * * DtoResolveFunction(node.Node.toString): node.d(8)
* * * * DtoDeclareFunction(node.Node.toString): node.d(8)
* * * * * Enter defineAsExternallyAvailable
* * * * * * Commandline flags indicate no inlining
* * * * * isMember = this is: node.Node
* * * * * DtoFunctionType(void(void delegate(const(char)) sink))
* * * * * func = 
declare void @_D4node4Node8toStringMFDFxaZvZv(%node.Node*, { i8*, void (i8*, i8)* })

* * * Doing function body for: toString
* * * DtoCreateNestedContext for node.Node.toString
* * * * DtoCreateNestedContextType for node.Node.toString
* * * * * has nested frame
* * * * * Function toString has depth 0
* * * * * Nested var 'sink' of type { i8*, void (i8*, i8)* }
* * * * * frameType = %nest.toString = type { { i8*, void (i8*, i8)* } }
* * * * Needs closure (GC) flag: 1
* * * * Building type: extern (C) void*(ulong)
* * * * * DtoFunctionType(extern (C) void*(ulong))
* * * * * * x86-64 ABI: Transforming return type
* * * * * * x86-64 ABI: Transforming argument types
* * * * * * Final function type: i8* (i64)
* * * * nested param: sink
* * * * * Copying to nested frame
* * * CompoundStatement::toIR(): 
* * * * ExpStatement::toIR(): node.d(10)
* * * * * CallExp::toElem: printMembers(this) @ void
* * * * * * VarExp::toElem: printMembers @ pure nothrow @nogc @safe void(Node _param_0)
* * * * * * * DtoSymbolAddress ('printMembers' of type 'pure nothrow @nogc @safe void(Node _param_0)')
* * * * * * * * FuncDeclaration
* * * * * * * * DtoFunctionType(pure nothrow @nogc @safe void(Node _param_0))
* * * * * * * * * x86-64 ABI: Transforming argument types
* * * * * * * * * Final function type: void (i8*, %node.Node*)
* * * * * * * * DtoResolveFunction(node.Node.toString.printMembers!(Node, sink).printMembers): node.d(1)
* * * * * * * * * DtoDeclareFunction(node.Node.toString.printMembers!(Node, sink).printMembers): node.d(1)
* * * * * * * * * * Enter defineAsExternallyAvailable
* * * * * * * * * * * Commandline flags indicate no inlining
* * * * * * * * * * DtoFunctionType(pure nothrow @nogc @safe void(Node _param_0))
* * * * * * * * * * func = 
declare void @_D4node__T12printMembersTCQy4NodeS_DQBiQl8toStringMFDFxaZvZ4sinkQmZQCfMFNaNbNiNfQCdZv(i8*, %node.Node*)

* * * * * * DtoCallFunction()
* * * * * * * Building type: pure nothrow @nogc @safe void(Node _param_0)
* * * * * * * * DtoFunctionType(pure nothrow @nogc @safe void(Node _param_0))
* * * * * * * * * x86-64 ABI: Transforming argument types
* * * * * * * * * Final function type: void (%node.Node*)
* * * * * * * DtoNestedContext for node.Node.toString.printMembers!(Node, sink).printMembers
* * * * * * * * DtoCreateNestedContextType for node.Node.toString.printMembers!(Node, sink).printMembers
* * * * * * * * * DtoCreateNestedContextType for node.Node.toString
* * * * * * * * * * already done
* * * * * * * * for function of depth 0
* * * * * * * * Parent frame is from toString
* * * * * * * * Current function is toString
* * * * * * * * Context is from toString
* * * * * * * * Needed depth: 0
* * * * * * * * Context depth: 0
* * * * * * * * Calling sibling function or directly nested function
* * * * * * * * result =   %7 = bitcast i8* %6 to %nest.toString*
* * * * * * * * of type %nest.toString*
* * * * * * * doing normal arguments
* * * * * * * Arguments so far: (1)
* * * * * * * *   %11 = bitcast %nest.toString* %7 to i8*
* * * * * * * Function type: pure nothrow @nogc @safe void(Node _param_0)
* * * * * * * DtoArgument
* * * * * * * * ThisExp::toElem: this @ node.Node
* * * * * * * * * normal this exp
* * Building default initializer for node.Node
* * * Creating initializer constant for Node
* * * * final initializer: %node.Node { [6 x i8*]* @_D4node4Node6__vtblZ, i8* null }
* * Building vtbl initializer
* * * Building type: object.TypeInfo_Class
* * * * Building class type object.TypeInfo_Class @ /home/zombinedev/dlang/ldc-3f2a9303/bin/../import/object.d(1964)
* * * * * Instance size: 152
* * * * * Field priority for m_init: 1
* * * * * Field priority for name: 1
* * * * * Field priority for vtbl: 1
* * * * * Field priority for interfaces: 1
* * * * * Field priority for base: 1
* * * * * Field priority for destructor: 1
* * * * * Field priority for classInvariant: 1
* * * * * Field priority for m_flags: 1
* * * * * Field priority for deallocator: 1
* * * * * Field priority for m_offTi: 1
* * * * * Field priority for defaultConstructor: 1
* * * * * Field priority for m_RTInfo: 1
* * * * * Building type: byte[]
* * * * * * Building type: byte
* * * * * Building type: string
* * * * * Building type: void*[]
* * * * * Building type: Interface[]
* * * * * * Building type: Interface
* * * * * * * Building struct type object.Interface @ /home/zombinedev/dlang/ldc-3f2a9303/bin/../import/object.d(1261)
* * * * * * * * Field priority for classinfo: 1
* * * * * * * * Field priority for vtbl: 1
* * * * * * * * Field priority for offset: 1
* * * * * * * * final struct type: %object.Interface = type { %object.TypeInfo_Class*, { i64, i8** }, i64 }
* * * * * Building type: void function(Object)
* * * * * * Building type: void(Object)
* * * * * * * DtoFunctionType(void(Object))
* * * * * * * * x86-64 ABI: Transforming argument types
* * * * * * * * Final function type: void (%object.Object*)
* * * * * Building type: ClassFlags
* * * * * Building type: ClassFlags
* * * * * Building type: OffsetTypeInfo[]
* * * * * * Building type: OffsetTypeInfo
* * * * * * * Building struct type object.OffsetTypeInfo @ /home/zombinedev/dlang/ldc-3f2a9303/bin/../import/object.d(1272)
* * * * * * * * Field priority for offset: 1
* * * * * * * * Field priority for ti: 1
* * * * * * * * Building type: object.TypeInfo
* * * * * * * * * Building class type object.TypeInfo @ /home/zombinedev/dlang/ldc-3f2a9303/bin/../import/object.d(1283)
* * * * * * * * * * Instance size: 16
* * * * * * * * * * class type: %object.TypeInfo = type { [19 x i8*]*, i8* }
* * * * * * * * final struct type: %object.OffsetTypeInfo = type { i64, %object.TypeInfo* }
* * * * * Building type: void function(Object)
* * * * * * Building type: void(Object)
* * * * * * * DtoFunctionType(void(Object))
* * * * * * * * x86-64 ABI: Transforming argument types
* * * * * * * * Final function type: void (%object.Object*)
* * * * * Building type: immutable(void)*
* * * * * class type: %object.TypeInfo_Class = type { [22 x i8*]*, i8*, { i64, i8* }, { i64, i8* }, { i64, i8** }, { i64, %object.Interface* }, %object.TypeInfo_Class*, i8*, void (%object.Object*)*, i32, [4 x i8], i8*, { i64, %object.OffsetTypeInfo* }, void (%object.Object*)*, i8* }
* * * isMember = this is: object.Object
* * * DtoFunctionType(string())
* * * * x86-64 ABI: Transforming return type
* * * * x86-64 ABI: Transforming argument types
* * * * Final function type: { i64, i8* } (%object.Object*)
* * * DtoResolveFunction(object.Object.toString): /home/zombinedev/dlang/ldc-3f2a9303/bin/../import/object.d(1043)
* * * * DtoDeclareFunction(object.Object.toString): /home/zombinedev/dlang/ldc-3f2a9303/bin/../import/object.d(1043)
* * * * * Enter defineAsExternallyAvailable
* * * * * * Commandline flags indicate no inlining
* * * * * isMember = this is: object.Object
* * * * * DtoFunctionType(string())
* * * * * func = 
declare { i64, i8* } @_D6object6Object8toStringMFZAya(%object.Object*)

* * * isMember = this is: object.Object
* * * DtoFunctionType(nothrow @trusted ulong())
* * * * x86-64 ABI: Transforming return type
* * * * x86-64 ABI: Transforming argument types
* * * * Final function type: i64 (%object.Object*)
* * * DtoResolveFunction(object.Object.toHash): /home/zombinedev/dlang/ldc-3f2a9303/bin/../import/object.d(1051)
* * * * DtoDeclareFunction(object.Object.toHash): /home/zombinedev/dlang/ldc-3f2a9303/bin/../import/object.d(1051)
* * * * * Enter defineAsExternallyAvailable
* * * * * * Commandline flags indicate no inlining
* * * * * isMember = this is: object.Object
* * * * * DtoFunctionType(nothrow @trusted ulong())
* * * * * func = 
declare i64 @_D6object6Object6toHashMFNbNeZm(%object.Object*)

* * * isMember = this is: object.Object
* * * DtoFunctionType(int(Object o))
* * * * Building type: int
* * * * x86-64 ABI: Transforming return type
* * * * x86-64 ABI: Transforming argument types
* * * * Final function type: i32 (%object.Object*, %object.Object*)
* * * DtoResolveFunction(object.Object.opCmp): /home/zombinedev/dlang/ldc-3f2a9303/bin/../import/object.d(1074)
* * * * DtoDeclareFunction(object.Object.opCmp): /home/zombinedev/dlang/ldc-3f2a9303/bin/../import/object.d(1074)
* * * * * Enter defineAsExternallyAvailable
* * * * * * Commandline flags indicate no inlining
* * * * * isMember = this is: object.Object
* * * * * DtoFunctionType(int(Object o))
* * * * * func = 
declare i32 @_D6object6Object5opCmpMFCQqZi(%object.Object*, %object.Object*)

* * * isMember = this is: object.Object
* * * DtoFunctionType(bool(Object o))
* * * * Building type: bool
* * * * x86-64 ABI: Transforming return type
* * * * x86-64 ABI: Transforming argument types
* * * * Final function type: i1 (%object.Object*, %object.Object*)
* * * DtoResolveFunction(object.Object.opEquals): /home/zombinedev/dlang/ldc-3f2a9303/bin/../import/object.d(1088)
* * * * DtoDeclareFunction(object.Object.opEquals): /home/zombinedev/dlang/ldc-3f2a9303/bin/../import/object.d(1088)
* * * * * Enter defineAsExternallyAvailable
* * * * * * Commandline flags indicate no inlining
* * * * * isMember = this is: object.Object
* * * * * DtoFunctionType(bool(Object o))
* * * * * func = 
declare i1 @_D6object6Object8opEqualsMFCQtZb(%object.Object*, %object.Object*)

* * DtoDefineClassInfo(Node)
* * * DtoResolveClass(object.TypeInfo_Class): /home/zombinedev/dlang/ldc-3f2a9303/bin/../import/object.d(1964)
* * * * DtoResolveClass(object.TypeInfo): /home/zombinedev/dlang/ldc-3f2a9303/bin/../import/object.d(1283)
* * * Building type: char[]
* * * Building ClassInfo.interfaces
* * * NullExp::toConstElem(type=immutable(void)*): null
* TemplateInstance::codegen: 'node.Node.toString.printMembers!(Node, sink)'
* * DtoDefineFunction(node.Node.toString.printMembers!(Node, sink).printMembers): node.d(1)
* * * Doing function body for: printMembers
* * * DtoCreateNestedContext for node.Node.toString.printMembers!(Node, sink).printMembers
* * * * DtoCreateNestedContextType for node.Node.toString.printMembers!(Node, sink).printMembers
* * * * * already done
* * * CompoundStatement::toIR(): 
* * * * ExpStatement::toIR(): node.d(3)
* * * * * DeclarationExp::toElem: (void delegate(const(char)) inner_sink = delegate void(const(char)) => sink , sink(msg);) | T=void
* * * * * * DtoDeclarationExp: inner_sink
* * * * * * * VarDeclaration
* * * * * * * DtoVarDeclaration(vdtype = void delegate(const(char)))
* * * * * * * * llvm value for decl:   %4 = alloca { i8*, void (i8*, i8)* }, align 8
* * * * * * * * expression initializer
* * * * * * * * AssignExp::toElem: inner_sink = delegate void(const(char)) => sink , sink(msg) | (void delegate(const(char)))(void delegate(const(char)) = void delegate(const(char)))
* * * * * * * * * VarExp::toElem: inner_sink @ void delegate(const(char))
* * * * * * * * * * DtoSymbolAddress ('inner_sink' of type 'void delegate(const(char))')
* * * * * * * * * * * a normal variable
* * * * * * * * * attempting in-place construction
* * * * * * * * * FuncExp::toElem: __lambda2 @ void delegate(const(char))
* * * * * * * * * * nested
* * * * * * * * * * kind = delegate
* * * * * * * * * * DtoDefineFunction(node.Node.toString.printMembers!(Node, sink).printMembers.__lambda2): node.d(3)
* * * * * * * * * * * DtoFunctionType(void(const(char)))
* * * * * * * * * * * * x86-64 ABI: Transforming argument types
* * * * * * * * * * * * Final function type: void (i8*, i8)
* * * * * * * * * * * DtoResolveFunction(node.Node.toString.printMembers!(Node, sink).printMembers.__lambda2): node.d(3)
* * * * * * * * * * * * DtoDeclareFunction(node.Node.toString.printMembers!(Node, sink).printMembers.__lambda2): node.d(3)
* * * * * * * * * * * * * Enter defineAsExternallyAvailable
* * * * * * * * * * * * * * Commandline flags indicate no inlining
* * * * * * * * * * * * * DtoFunctionType(void(const(char)))
* * * * * * * * * * * * * func = 
declare void @_D4node__T12printMembersTCQy4NodeS_DQBiQl8toStringMFDFxaZvZ4sinkQmZQCfMFQBvZ__T9__lambda2TxaZQoMQBr(i8*, i8)

* * * * * * * * * * * Doing function body for: __lambda2
* * * * * * * * * * * DtoCreateNestedContext for node.Node.toString.printMembers!(Node, sink).printMembers.__lambda2
* * * * * * * * * * * * DtoCreateNestedContextType for node.Node.toString.printMembers!(Node, sink).printMembers.__lambda2
* * * * * * * * * * * * * DtoCreateNestedContextType for node.Node.toString.printMembers!(Node, sink).printMembers
* * * * * * * * * * * * * * already done
* * * * * * * * * * * CompoundStatement::toIR(): 
* * * * * * * * * * * * ReturnStatement::toIR(): node.d(3)
ldc2: /home/vsts/work/1/s/gen/statements.cpp:112: virtual void ToIRVisitor::visit(ReturnStatement*): Assertion `sretPointer' failed.
ldc2(_ZN4llvm3sys15PrintStackTraceERNS_11raw_ostreamE+0x2a)[0x2fefcca]
ldc2(_ZN4llvm3sys17RunSignalHandlersEv+0x4c)[0x2fedacc]
ldc2[0x2fedc37]
/usr/lib/libpthread.so.0(+0x13cb0)[0x7f9d7f949cb0]
/usr/lib/libc.so.6(gsignal+0x145)[0x7f9d7f4e3755]
/usr/lib/libc.so.6(abort+0x125)[0x7f9d7f4ce851]
/usr/lib/libc.so.6(+0x25727)[0x7f9d7f4ce727]
/usr/lib/libc.so.6(+0x33026)[0x7f9d7f4dc026]
ldc2[0xe46674]
ldc2[0xe44719]
ldc2(_Z14Statement_toIRP9StatementP7IRState+0x2a)[0xe429fa]
ldc2(_Z17DtoDefineFunctionP15FuncDeclarationb+0xcdd)[0xe02bcd]
ldc2(_Z19Declaration_codegenP7DsymbolP7IRState+0x2a)[0xdf38ea]
ldc2[0xe57735]
ldc2(_Z6toElemP10Expression+0x74)[0xe558d4]
ldc2[0xe5e197]
ldc2(_Z6toElemP10Expression+0x74)[0xe558d4]
ldc2(_Z17DtoVarDeclarationP14VarDeclaration+0xa3)[0xe0ac13]
ldc2(_Z17DtoDeclarationExpP7Dsymbol+0x1c1)[0xe0ebd1]
ldc2[0xe5dfcc]
ldc2(_Z10toElemDtorP10Expression+0x74)[0xe55b14]
ldc2[0xe43006]
ldc2[0xe44719]
ldc2(_Z14Statement_toIRP9StatementP7IRState+0x2a)[0xe429fa]
ldc2(_Z17DtoDefineFunctionP15FuncDeclarationb+0xcdd)[0xe02bcd]
ldc2[0xdf47a8]
ldc2(_Z19Declaration_codegenP7Dsymbol+0x31)[0xdf38a1]
ldc2(_Z13codegenModuleP7IRStateP6Module+0x11e)[0xe1870e]
ldc2(_ZN3ldc13CodeGenerator4emitEP6Module+0xd8)[0xee0f28]
ldc2(_Z14codegenModulesR5ArrayIP6ModuleE+0x14c)[0xeaf8bc]
ldc2(_Z13mars_mainBodyR5ParamR5ArrayIPKcES5_+0x145f)[0xc8b95f]
ldc2(_Z7cppmainiPPc+0x192d)[0xeae5fd]
ldc2(_D2rt6dmain211_d_run_mainUiPPaPUAAaZiZ6runAllMFZv+0x50)[0x3245eb0]
ldc2(_d_run_main+0x218)[0x3245cc8]
/usr/lib/libc.so.6(__libc_start_main+0xf3)[0x7f9d7f4cfee3]
ldc2(_start+0x29)[0xb92869]

$ ldc2 --version
LDC - the LLVM D compiler (1.16.0-git-3f2a930):
  based on DMD v2.086.1 and LLVM 8.0.0
  built with LDC - the LLVM D compiler (1.16.0-git-3f2a930)
  Default target: x86_64-unknown-linux-gnu
  Host CPU: ivybridge
  http://dlang.org - http://wiki.dlang.org/LDC
[..]

@PetarKirov PetarKirov changed the title ICE with LDC >= 1.16.0 [working on a reduced test case] ICE with LDC >= 1.16.0 Jun 23, 2019
@PetarKirov
Copy link
Contributor Author

PetarKirov commented Jun 23, 2019

From the reduced test case:

typeof(sink) inner_sink = msg => (sink, sink(msg));

From original the source:

typeof(sink) inner_sink = msg => (sink(nest_ws), sink(msg));

Wow, it looks like I was trying to use the side effect and the result of a comma expression 😮
I initially wrote this code before it was deprecated from the language...

Changing my code to:

typeof(sink) inner_sink = (msg) { sink(nest_ws); sink(msg); };

Fixed the problem.

@kinke
Copy link
Member

kinke commented Jun 23, 2019

I'm looking at the --vv output but it's 25959 lines, so I think it may be easier to simply wait another hour or so.

[I meant looking at the last few lines to get source file and line number of the offending function and starting manually from there.]

Anyway, the problem is a new AST ugliness - return sink, sink(msg); of type void [and only valid because of void, as using the result of a comma exp is deprecated...], instead of sink, sink(msg); return; with v1.15. The latter compound statement is still used for stuff like:

void foo();
void bar()
{
    return foo(); // rewritten as `foo(); return;`
}

PetarKirov added a commit to PetarKirov/Chess2RT that referenced this issue Jun 23, 2019
Fixes an ICE with LDC 1.16.0.
See ldc-developers/ldc#3094 for more details.
kinke added a commit to kinke/ldc that referenced this issue Jun 24, 2019
Fixes ldc-developers#3094, a regression introduced in v1.16 due to AST changes.
kinke added a commit to kinke/ldc that referenced this issue Jun 24, 2019
Fixes ldc-developers#3094, a regression introduced in v1.16 due to AST changes.
kinke added a commit that referenced this issue Jul 1, 2019
Fixes #3094, a regression introduced in v1.16 due to AST changes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants