Hi,
I want to know few things:
1) is LLVM IR (obtained from -emit-llvm option) an in-memory CFG?
Say, I have hello.c and I generate bit-code using:
clang -O3 -emit-llvm hello.c -c -o hello.bc
Next, I redirect this bit code to opt:
opt -load ../../Release+Asserts/lib/Hello.so -hello < hello.bc >
/dev/null
I have attached a example.tar.gz with one simple iterator.cpp and
output from opt command and clang analyzer-checker.
Are these two - LLVM IR and CFG from clang analyzer-checker equivalent?
2) how to get/print original program back from this LLVM IR?
3) what about `clang -emit-llvm hello.c -c -o hello.bc'
- without using -O3 optimization flag, is this LLVM IR an in-memory
CFG?
These queries may be trivial but I need this info to proceed further.
Thank you.
Rajendra
http://www.cse.iitb.ac.in/~rks
-------- Original Message --------
Subject: LLVMdev Digest, Vol 99, Issue 65
Date: 28-09-2012 10:26 PM
From: llvmdev-request at cs.uiuc.edu
To: llvmdev at cs.uiuc.edu
Reply-To: llvmdev at cs.uiuc.edu
Message: 8
Date: Fri, 28 Sep 2012 17:45:23 +0200
From: Duncan Sands <baldrick at free.fr>
To: llvmdev at cs.uiuc.edu
Subject: Re: [LLVMdev] [LLVM-Clang CFG] - generating CFG of a C
program and llvm iterators
Hi Rajendra, you want to get hold of the LLVM IR produced by clang (use
the
-flto option to have clang produce LLVM IR), and pipe it to the "opt"
command
line tool, into which you will have loaded your logic as a plugin pass.
So I
suggest you read about writing plugins for opt.
Ciao, Duncan.
> Hi,
>
> I want to generate Control Flow Graph (in memory CFG object) of any
> given C program and then iterate over this CFG (all function, basic
> blocks and instructions) using llvm iterators.
>
> I can see text output of CFG on screen, using following command:
> `clang -cc1 -Idummyh -analyze -analyzer-checker=debug.DumpCFG
> hello/hello.c'
> where dummyh has en empty stdio.h to remove this error:
> `fatal error: 'stdio.h' file not found'
>
> I see CFG.h and CFG.cpp that clang uses and have seen some docs on
> ModulePass, FunctionPass, BasicBlockPass, etc. But I have not figured
> out how to put together things to generate CFG and then write
> iterators.
>
> All help is much appreciated.
>
> Thank you.
>
> Rajendra
-------------- next part --------------
A non-text attachment was scrubbed...
Name: iterator.tar.gz
Type: application/x-gzip
Size: 9630 bytes
Desc: not available
URL:
<http://lists.llvm.org/pipermail/llvm-dev/attachments/20121002/dbde9a05/attachment.bin>