你好,我有一个问题。我尝试使用 LLVM 的内置 Pass。为了尝试一下,我使用了 Pass“DeadStoreElimination”dse。为此,我编写了一个简单的代码:
#include <stdio.h>
int main() {
int x = 10;
int y = 20;
// Dead Store: Value of X is overwritten before its used
x = 5;
// Dead Store: Value y is never used
y = 30;
printf("The Value of x is: %d\n", x);
return 0;
}
运行后:
clang -c -o Spectre.bc Spectre.c
我用:
opt -passes=dse Spectre.bc -o Spectre.bc
这会导致错误:
opt: Spectre.bc:1:1: error: expected top-level entity
ELF>�@@ UH���E��E�
或者当我跑步时:
opt -passes=dce Spectre.c -o Spectre.bc
它创造:
opt: Spectre.c:1:1: error: expected top-level entity
#include <stdio.h>
^
有人可以帮助我吗?我做错了什么?
如上所述,我没有得到我想要的东西。 stackoverflow 上的其他帖子无法解决我的问题
您需要使用
--emit-llvm
来 clang 来生成 LLVM IR。尽管如此,对于 DSE 来说,可能不需要其他先决条件通过。
啊,我看到非常感谢解决了这个问题!