[LLVMdev] Prevent instruction elimination

Xinfinity
Mon, 25 Oct 2010 14:49:26 -0000

Hi,


John Criswell-4 wrote:
>
>
> You may want to use LLVM Metadata features.  Search for MDNode in the
> doxygen docs for some information on how to create metadata.
>
>

I use metadata information in this way:
     unsigned mk = Context.getMDKindID(mdtype);
     Value  *V = MDString::get(Context,StringRef(str));
     MDNode* n = MDNode::get(Context, &V, 1);
     inst->setMetadata(mk, n);

Maybe it is a deprecated way of handling metadata, as I started with this
code from LLVM 2.6.
But what I need is a dummy instruction ("inst" in the above example),
that
has a minimal impact. I want the code to be optimized (almost) as this
instruction would not exist.



John Criswell-4 wrote:
>
>
> Alternatively, you can use calls to external functions.  These are
> seldomly optimized since optimizations assume that external functions
> can have undetermined side effects.
>
> -- John T.
>
>

I should avoid calls to some functions, as they would be considered a
dependence if they are inserted in the body of a loop, and would definitely
affect the optimization step. I also thought about inserting an inline
assembly that only contains a comment and carries metadata info. But this is
also a call, so it influences the optimizers.

Alexandra

--
View this message in context: