Reflective execution on LLVM

Hello everyone:

I am new to LLVM, and now investigating the feasibility of
using LLVM to implement several “hybrid” program analysis
techniques, which use both static source code and dynamic
execution information.

A particular question to me is “how well can LLVM
preserve RTTI information in its compiled bytecode (it can
be binary, IR, or other form)”? or “is there are support for
reflectively execute a piece of simple code (a sequence of
method invocations)”?

For example, suppose we are going to build a test generation
tool, which executes a test immediately after the test is generated.
The obtained execution information can guide the further test
generation, towards certain goals. So, the key question is "
how to execute a chuck of code in the same process"?

Assume the tool is going to create tests for the following piece
of code:

struct C* createStruct(int i) {
assert i > 0;

//return a new created struct C
}

char* printStruct(struct* C) {

//do something here

}

A possible test created can be:

Test 1:

int i = 10;
struct C* c = createStruct(int i)
char* result = printStruct(c);

For Test1, is it possible to obtain the value of "char* result"
before creating new tests?

This has many benefits: it can be used to prune search
space. For example, in Test 1, if i = -10, the execution of
createStruct(int i) will not succeed, thus, there is no need to
further extend an erroneousness test (call printStruct(c); ) any more.
This is in contrast to “executing tests when all of them are created”!

In Java, such information can be easily obtained via
its Reflection API, e.g., calling “Method.invoke(…)”. So, I
am wondering is LLVM has a similar mechanism to achieve
this purpose? If not, what is the most feasible way to work around
this? Adding type information to IR, or invoke a interpreter?

It would be tremendously helpful if anyone can kindly share
some experience, or point me to the right resource! Any
comments are highly appreciated!

Thanks

-Sai