本文整理匯總了Golang中github.com/axw/gollvm/llvm.Module.NamedGlobal方法的典型用法代碼示例。如果您正苦於以下問題:Golang Module.NamedGlobal方法的具體用法?Golang Module.NamedGlobal怎麽用?Golang Module.NamedGlobal使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/axw/gollvm/llvm.Module
的用法示例。
在下文中一共展示了Module.NamedGlobal方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: reorderGlobalConstructors
func reorderGlobalConstructors(m llvm.Module) error {
ctors := m.NamedGlobal("llvm.global_ctors")
if ctors.IsNil() {
// No global constructors.
return nil
}
init := ctors.Initializer()
arraylength := init.Type().ArrayLength()
zeroindex := []uint32{0}
// The constructors are ordered within each package, but the packages
// are in reverse order. We must go backwards through the constructors,
// reassigning priorities.
ceiling, npackagectors := -1, -1
for i := arraylength - 1; i >= 0; i-- {
indices := []uint32{uint32(i)}
ctor := llvm.ConstExtractValue(init, indices)
priority := int(llvm.ConstExtractValue(ctor, zeroindex).ZExtValue())
if npackagectors == -1 {
ceiling = arraylength - (i + 1) + priority
npackagectors = priority
}
newpriority := ceiling - (npackagectors - priority)
newpriorityvalue := llvm.ConstInt(llvm.Int32Type(), uint64(newpriority), false)
ctor = llvm.ConstInsertValue(ctor, newpriorityvalue, zeroindex)
if priority == 1 {
npackagectors = -1
}
init = llvm.ConstInsertValue(init, ctor, indices)
}
ctors.SetInitializer(init)
return nil
}