Hello I've got a Problem. I try to use a built-in Pass from LLVM. Just to try it I used the Pass "DeadStoreElimination" dse. For that I wrote a simple code:
#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;
}
after running:
clang -c -o Spectre.bc Spectre.c
I use:
opt -passes=dse Spectre.bc -o Spectre.bc
which results to the Error:
opt: Spectre.bc:1:1: error: expected top-level entity
ELF>�@@ UH���E��E�
Or when I run:
opt -passes=dce Spectre.c -o Spectre.bc
it creates:
opt: Spectre.c:1:1: error: expected top-level entity
#include <stdio.h>
^
Can anyone help me? What am I doing wrong?
As written above I am not getting what I want to get. Other Posts on stackoverflow wouldn't solve my Problem
You need to use --emit-llvm
for clang to produce LLVM IR. Still, for DSE likely few other pre-requisite passes would be necessary.