Reputation: 767
Hello I have to parse some LLVM IR code for a compiler course. I am very new to LLVM. I have clang and LLVM on my computer, and when I compile a simple C program:
#include <stdio.h>
int main(int argc, char *argv[])
{
for (int i = 0; i < 10; i++) {
printf("Stuff!\n");
}
return 0;
}
using command: clang -cc1 test.c -emit-llvm
I get llvm IR with what I believe are called implicit blocks:
; <label>:4 ; preds = %9, %0
However my parser also needs to handle llvm IR with textual labels:
for.cond: ; preds = %for.inc, %entry
My problem is that I do not know how to generate such IR and was hoping someone show me how. I tried Google and such, but I couldn't find appropriate information. Thanks in advance.
Upvotes: 0
Views: 1349
Reputation: 341
The accepted answer is no longer valid. Nor is it a good way to achieve the stated.
In case someone stumbles upon this question, like I did, I'm providing the answer.
clang-8 -S -fno-discard-value-names -emit-llvm test.c
Upvotes: 1
Reputation: 767
use this site with Show detailed bytecode analysis
checked
http://ellcc.org/demo/index.cgi
Upvotes: 1