[LLVMdev] LLVM bytecode simulator/emulator?

Chris Lattner sabre at nondot.org
Fri Jul 14 10:44:29 PDT 2006


On Fri, 14 Jul 2006, Kenneth Hoste wrote:
>> I don't really understand what you mean by this, but a ModulePass is fully 
>> general, it can do anything.  Can you explain what you're trying to do?
>
> The way we're characterizing programs now, is adding our own code after every 
> instruction. When that instruction gets executed (which can happen several 
> times, for example inside a loop), we update our state. A simple example is

Right.

> counting the number of dynamic instructions executed, or the instruction mix 
> (% loads, % stores, ...) in the dynamic execution.
> If I was able to do that using LLVM, we would have characteristics on a 
> higher level of abstraction. The documentation on the BasicBlock pass 
> mentions not to keep state over different basic blocks, but I do want that. 
> Also, I need a way to iterate over the _dynamic_ instruction stream. Is there 
> a way to do that?

You can't iterate over dynamic instructions without running the program. 
Optimization passes happen at compile time, not runtime.  If you want 
information about the dynamic behavior of the program, either modify the 
interpreter, or insert code that computes the properties you care about.

-Chris

> Example static vs dynamic:
>
> static:
> L: add x, y
>   sub y, z
>   jmpif z>100
>   mul x, z
>
> dynamic:
> add x, y
> sub y, z
> jmpif z>100
> add x, y
> sub y, z
> jmpif z>100
> ...
> jmpif z>100
> mul x, z
>
>
> If my problem still isn't clear, it's because I didn't explain it well. Feel 
> free to ask further questions. I'll look into the documentation/examples 
> today, to see if I can find some kind of dynamic analysis.
>
> greetings,
>
> Kennneth
>
>
>

-Chris

-- 
http://nondot.org/sabre/
http://llvm.org/



More information about the llvm-dev mailing list