问题
I'm working on fixing some bugs in TinyGo compiler. At the moment, I have a weird problems with bitcasting. The IR code would be as follows:
%structcast.go.A = type { i32, i32, i32, i32 }
%structcast.go.B = type { i32, i32, i32, i32 }
...
%0 = load %structcast.go.B, %structcast.go.B* %b, !dbg !1851
%changetype = bitcast %structcast.go.B %0 to %structcast.go.A, !dbg !1852
call void @structcast.go.foo(%structcast.go.A %changetype, i8* undef, i8* undef), !dbg !1853
But during IR verification I get:
Invalid bitcast
%changetype = bitcast %structcast.go.B %0 to %structcast.go.A, !dbg !1852
I'm wondering, what exactly is illegal about that bitcast?
回答1:
Ok, meself figured it out: the cast must be for a non-aggregate type, and struct is aggregate :(
来源:https://stackoverflow.com/questions/54452189/llvm-invalid-bitcast-when-converting-a-struct-to-identical-struct