Insert function definition at the top of the module

Hi,

Just have a question here,

Short:

How would you insert a function definition at the top of the LLVM Module?

Long:

I’m trying to create monomorphic functions , so when I encounter a function call ,

I create concrete types for the template function.

While I’m doing this , i need to codegen the function definition at the top of the module ,

in order for my function call to execute correctly.

Any clue as to how this can be done ?

Thanks ,

Malhar

Why do you think your function has to be at the top? LLVM IR doesn't
care about seeing declarations before uses and you shouldn't be able
to write anything well-defined to even know what order the functions
are in at runtime (the linker might reorder them on a whim for
example).

Cheers.

Tim.