<div dir="ltr">Naively, I suspect you'd have to clone it - there are some optimizations that must be done for correctness on the IR (such as the always inlining pass that inlines any functions that specify they /must/ be inlined).<br><br><div class="gmail_quote"><div dir="ltr">On Wed, Nov 9, 2016 at 1:32 AM Alex Denisov via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi devs, hi Lang,<br class="gmail_msg">
<br class="gmail_msg">
I use ORC’s SimpleCompiler to compile modules into object files and it works just great, however I’m having an issue:<br class="gmail_msg">
a module gets changed a bit when I compile it (some transformations/optimizations applied).<br class="gmail_msg">
I tried to set optimization level of a TargetMachine to None, but the module gets changed anyway.<br class="gmail_msg">
<br class="gmail_msg">
The question is: how can I prevent a module from being modified during compilation?<br class="gmail_msg">
I can make a clone of a module, but I’m curious if there are other ways to achieve the same goal.<br class="gmail_msg">
<br class="gmail_msg">
More context:<br class="gmail_msg">
<br class="gmail_msg">
When I run a program I try to get object file for a module from a cache.<br class="gmail_msg">
If the object file exists, then I just proceed to a module analysis phase.<br class="gmail_msg">
If the object does not exist, then I compile the module, put object file into a cache, and then proceed to a module analysis phase.<br class="gmail_msg">
In other words:<br class="gmail_msg">
<br class="gmail_msg">
  let object = cache.getObject(module);<br class="gmail_msg">
  if object == null {<br class="gmail_msg">
    object = compile(module)<br class="gmail_msg">
    cache.putObject(object, module)<br class="gmail_msg">
  }<br class="gmail_msg">
  processModule(module)<br class="gmail_msg">
<br class="gmail_msg">
When I run my program two times, then I basically analyze two different modules, even though they are loaded from the same bitcode file.<br class="gmail_msg">
<br class="gmail_msg">
Please, let me know if more information/clarification is needed.<br class="gmail_msg">
<br class="gmail_msg">
Any hints, suggestions, and recommendations are more than welcome :)<br class="gmail_msg">
<br class="gmail_msg">
--<br class="gmail_msg">
AlexDenisov<br class="gmail_msg">
Software Engineer, <a href="http://lowlevelbits.org" rel="noreferrer" class="gmail_msg" target="_blank">http://lowlevelbits.org</a><br class="gmail_msg">
<br class="gmail_msg">
_______________________________________________<br class="gmail_msg">
LLVM Developers mailing list<br class="gmail_msg">
<a href="mailto:llvm-dev@lists.llvm.org" class="gmail_msg" target="_blank">llvm-dev@lists.llvm.org</a><br class="gmail_msg">
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" class="gmail_msg" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br class="gmail_msg">
</blockquote></div></div>