LLVM: “Invalid bitcast” when converting a struct to identical struct

旧城冷巷雨未停 提交于 2020-01-06 05:22:10

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!