LLVM前端寄存器类错误OpenCL-GPU目标 [英] LLVM front end register class error OpenCL -- GPU target

查看:183
本文介绍了LLVM前端寄存器类错误OpenCL-GPU目标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近通过LLVM_IR传递编译OpenCL内核文件时遇到此错误:

I've recently been encountering this error when compiling OpenCL kernel files with my LLVM_IR pass:

aoc: ../../../TargetRegisterInfo.cpp:89: const llvm::TargetRegisterClass* llvm::TargetRegisterInfo::getMinimalPhysRegClass(unsigned int, llvm::EVT) const: Assertion `BestRC && "Couldn't find the register class"' failed.

我不确定这是什么意思.我从文档中读到的内容没有多大意义.基本上,这意味着后端不知道要在寄存器中放置什么类型?

I'm not sure what this means. What I've read from the documention doesn't make a lot of sense. Basically it means the backend doesn't know what type to place into the register?

有人知道该错误意味着什么吗?

Does anyone know what the error means?

它发生在各种内核中,似乎没有确定的模式,我可以举例说明.我可以根据需要发布更多详细信息,但实际上我只是想知道错误告诉我什么.

It occurs in various kernels and doesn't seem to have a definitive pattern I can show as an example. I can post more details if needed, but really I'd just like to know what the error is telling me.

提前感谢您的帮助.

更新: 看来LLVM中的此命令引起了问题:

UPDATE: It seems this command in LLVM is causing the issue:

AllocaInst* llvm::IRBuilder< preserveNames, T, Inserter >::CreateAlloca(Type * Ty, Value * ArraySize = 0,const Twine &  Name = "")

当我以这种方式进行非特定分配时,它将产生此错误.我使用此命令的原因是,有时在内核中会有一个存储值,它是一个常量.由于LLVM通常需要一个值,因此我需要一种转换它的方法.因此,我使用立即存储和加载进行分配.这是另一位SOF用户建议的.有谁知道在LLVM中将常量转换为值的另一种方法?

It creates this error when I do a nonspecific allocation in this manner. The reason I use this command is that sometimes in a kernel there will be a store value that is a Constant. Since LLVM often requires a Value I needed a way of converting it. So I do a an allocation with an immediate store and load. This was suggested by another SOF user. Does anyone know an alternate method of converting a Constant to a Value in LLVM?

谢谢.

好吧,这似乎很常规:

Value *new_val = dyn_cast<Value>(old_val);

工作正常.希望这些知识可以对其他人有所帮助.

Works perfectly fine. Hopefully this knowledge will help someone else.

UPDATE3:从头开始.动态类型转换不会将Constant转换为Value类型.因此,如果有人知道该怎么做,请告诉我.

UPDATE3: Scratch that. Dynamic cast doesn't convert Constant to a Value type. So if anyone knows how to do that, please let me know.

推荐答案

我承认我不明白您收到的断言错误.但是:

I admit I don't understand the assertion error you get. However:

我使用此命令的原因是,有时在内核中会有一个存储值,它是一个常量.由于LLVM通常需要一个值,因此我需要一种转换它的方法.因此,我使用立即存储和加载进行分配.

The reason I use this command is that sometimes in a kernel there will be a store value that is a Constant. Since LLVM often requires a Value I needed a way of converting it. So I do a an allocation with an immediate store and load.

对我来说这没有意义:

  1. 任何llvm::Constant 已经是llvm::Value
  2. 存储值然后再将其加载回去似乎很昂贵……
  1. Any llvm::Constant is already an llvm::Value
  2. Storing a value and then loading it back seems like an expensive nop...

这篇关于LLVM前端寄存器类错误OpenCL-GPU目标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆