[LLVMdev] How to correlate LLVA with native ISA

John Criswell criswell at uiuc.edu
Mon Dec 15 08:11:23 PST 2008


Keun Soo Yim wrote:
>
>  Thank your for reply.
I know this reply may be somewhat irrelevant because of your next post, 
but I thought I'd answer it anyway to get a better idea of what you're 
doing and to provide insight on the LLVM passes.
>
>  The reason why these information are needed is that I am trying to 
> extract the program signature (e.g., control flow) out side of the 
> binary. Conventional compiler technique adds extra checking code into 
> the target source or target IR in an invasive manner. Since code 
> generator combines the added code with the original one, they don't 
> need to correlate these two information.
I'm not sure I understand what you are saying.  Are you trying to create 
a signature for a program by recording which control-flow paths it takes 
during execution?

Assuming I understand what you are trying to do correctly, how else are 
you doing this besides instrumentation?  It seems to me that you're 
adding instructions to the program, regardless of whether you're doing 
it at the source level, LLVM IR, or machine code level.
>
>   It is being implemented as an LLVM analysis pass by using 
> /MachineFunctionPass/. If it is MachineBasicBlock or 
> MachineInstruction, does it possible to get the starting address of 
> real basic block and the exact (runtime) address of real instruction?
I'm not sure.
>
>   Unlike the FunctionPass, my MachineFunctionPass gets an error when 
> it is loaded by opt. The class has constructor, virtfn, 
> runOnMachineFunction, getPassName, runOnFunction, and getAnalysisUsage 
> methods where body parts of all methods are empty. Does any have a 
> similar problem?
The opt program can only manipulate LLVM IR; it does not do any code 
generation at all.  That is why you cannot load a MachineFunctionPass 
into it.  A MachineFunctionPass (and all of the classes whose name start 
with Machine) are used for code generation, which is done by llc.

You might be able to load MachineFunctionPass'es into llc, but I'm not sure.

-- John T.





More information about the llvm-dev mailing list