LLVM:无法选择:内部%llvm.spu.si.sf [英] LLVM: Cannot select: intrinsic %llvm.spu.si.sf

查看:140
本文介绍了LLVM:无法选择:内部%llvm.spu.si.sf的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到此错误

> clang -std=c99 -c derivative.c -o derivative.a
fatal error: error in backend: Cannot select: intrinsic %llvm.spu.si.sf

当我尝试使用Clang编译这个简单的C程序

when I try to compile this simple C program with Clang

#include <stdio.h>
#include <math.h>

int N = 100;
double H = 0.001;
double PI = 3.14159265;

void derive(double* input, long elements, double* output) {
  for (int i = 1; i < elements - 1; i++) {
    output[i - 1] = (input[i + 1] - input[i - 1])/ (2 * H);
  }
}

int main() {
  double f[N];
  double f_prime[N - 2];

  for (int i = 0; i < N; i++) {
    f[i] = sin(i * 2 * PI / (double)N);
  }

  derive(f, N, f_prime);

  for (int i = 0; i < N - 2; i++) {
    printf("%f  %f\n", i * 2 * PI / (double)N, f_prime[i]);
  }
}

我已经搜索了Internet,但还无法找到解决方案.

I already searched the Internet, but was not (yet) able to find a solution.

当我编译为Bitcode时,它会编译,但是执行会转储核心.

When I compile to Bitcode, it compiles but the execution dumps core.

> clang -emit-llvm -c derivative.c -o derivative.bc
> lli derivative.bc
lli: BitcodeReader.cpp:283: llvm::Value* llvm::BitcodeReaderValueList::getValueFwdRef(unsigned int, llvm::Type*): Assertion `(Ty == 0 || Ty == V->getType()) && "Type mismatch in value table!"' failed.
0  lli             0x0000000000c6fb02
1  lli             0x0000000000c6ff93
2  libpthread.so.0 0x00007f304d7dbbd0
3  libc.so.6       0x00007f304ca19037 gsignal + 55
4  libc.so.6       0x00007f304ca1c698 abort + 328
5  libc.so.6       0x00007f304ca11e03
6  libc.so.6       0x00007f304ca11eb2
7  lli             0x000000000052eeb0 llvm::BitcodeReaderValueList::getConstantFwdRef(unsigned int, llvm::Type*) + 0
8  lli             0x0000000000538943 llvm::BitcodeReader::ParseFunctionBody(llvm::Function*) + 10275
9  lli             0x000000000053acb1 llvm::BitcodeReader::Materialize(llvm::GlobalValue*, std::string*) + 241
10 lli             0x0000000000535195 llvm::BitcodeReader::MaterializeModule(llvm::Module*, std::string*) + 85
11 lli             0x0000000000c0a82f llvm::Module::MaterializeAllPermanently(std::string*) + 31
12 lli             0x00000000005360fc llvm::ParseBitcodeFile(llvm::MemoryBuffer*, llvm::LLVMContext&, std::string*) + 44
13 lli             0x00000000004f70b7
14 lli             0x00000000004e74f3 main + 339
15 libc.so.6       0x00007f304ca03ea5 __libc_start_main + 245
16 lli             0x00000000004f0f41
Stack dump:
0.  Program arguments: lli derivative.bc 
Aborted (core dumped)

在bc文件上尝试 llvm-dis 会产生几乎相同的核心转储.

Trying llvm-dis on the bc-file yields an almost identical core dump.

编辑:我试图找到最小的失败示例,看来问题是通过常量定义数组大小.

EDIT: I tried to find the minimal failing example, and it seems, the problem is defining the array size via the constant.

这失败了:

int main() {
  int N = 100;
  double f[N];
}

这有效:

int main() {
  double f[100];
}

EDIT2 :

int N = 100 更改为 const int N = 100 可使程序使用Clang进行编译.有意义的是,该变量应为 const ,但另一方面, gcc -std = c99 -Wall衍生物.c -lm 不会抱怨 const .

Changing int N = 100 to const int N = 100 makes the program compile with Clang. It makes sense that the variable should be const, but on the other hand, gcc -std=c99 -Wall derivative.c -lm does not complain if it is not const.

推荐答案

这是ubuntu错误:

This is ubuntu bug: https://bugs.launchpad.net/ubuntu/+source/llvm-3.2/+bug/1131614. Looks like they patched llvm+clang blindly, without understanding what they are doing.

这篇关于LLVM:无法选择:内部%llvm.spu.si.sf的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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