【发布时间】:2017-08-16 09:47:57
【问题描述】:
我有两个全局结构类型声明,其中一个是另一个的“子类型”。我想定义一个更具体类型的全局变量,但让全局变量有更通用的类型:
我试过了:
%hs = type { %hs* (%hs*)* }
%dc = type { %hs* (%hs*)*, i64, [1 x %hs*] }
@boring = constant %hs { %hs* (%hs*)* null }
; this works, but has type %dc* instead of %hs*
@foo = constant %dc { %hs* (%hs*)* null, i64 1, [1 x %hs*] [ %hs* @boring ] }
; this does not
@bar = constant %hs bitcast (%dc @foo to %hs)
; this tests that @bar indeed has the desired type
@test = constant %dc { %hs* (%hs*)* null, i64 1, [1 x %hs*] [ %hs* @bar ] }
但这失败了
llc-4.0: foo.ll:10:34: error: global variable reference must have pointer type
@bar = constant %hs bitcast (%dc @foo to %hs)
有没有办法像上面那样定义@bar,但类型为hs*?
理想情况下是一个定义?
【问题讨论】: