<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class=""><div><blockquote type="cite" class=""><div class="">On Nov 9, 2016, at 9:02 AM, David Blaikie via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" class="">llvm-dev@lists.llvm.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">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 class=""><br class=""></div></div></blockquote><div><br class=""></div><div>That could be solved by "pre-optimizing”. </div><div>However that wouldn’t be enough: there are IR transformations that are done as part of the codegen (codegenprepare for instance).<div class=""><br class=""></div><div class="">Right now in LLVM there is no other safe way (that I know of) than cloning before processing a module.<br class=""><div><blockquote type="cite" class=""></blockquote></div></div><div class=""><br class=""></div><div class="">— </div><div class="">Mehdi</div></div><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class="gmail_quote"><div dir="ltr" class="">On Wed, Nov 9, 2016 at 1:32 AM Alex Denisov via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" class="">llvm-dev@lists.llvm.org</a>> wrote:<br class=""></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>
_______________________________________________<br class="">LLVM Developers mailing list<br class=""><a href="mailto:llvm-dev@lists.llvm.org" class="">llvm-dev@lists.llvm.org</a><br class="">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev<br class=""></div></blockquote></div><br class=""></div></body></html>