[llvm-dev] [ORC] SimpleCompiler and module transformations

Alex Denisov via llvm-dev llvm-dev at lists.llvm.org
Thu Nov 10 07:32:24 PST 2016


Thank you guys, now the picture is much cleaner :)
I decided to go with clone of an original module and everything works just great.

> On 9 Nov 2016, at 18:31, Mehdi Amini <mehdi.amini at apple.com> wrote:
> 
>> On Nov 9, 2016, at 9:02 AM, David Blaikie via llvm-dev <llvm-dev at lists.llvm.org> wrote:
>> 
>> 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).
>> 
> 
> That could be solved by "pre-optimizing”. 
> However that wouldn’t be enough: there are IR transformations that are done as part of the codegen (codegenprepare for instance).
> 
> Right now in LLVM there is no other safe way (that I know of) than cloning before processing a module.
> 
>> Mehdi
> 
>> On Wed, Nov 9, 2016 at 1:32 AM Alex Denisov via llvm-dev <llvm-dev at lists.llvm.org> wrote:
>> Hi devs, hi Lang,
>> 
>> I use ORC’s SimpleCompiler to compile modules into object files and it works just great, however I’m having an issue:
>> a module gets changed a bit when I compile it (some transformations/optimizations applied).
>> I tried to set optimization level of a TargetMachine to None, but the module gets changed anyway.
>> 
>> The question is: how can I prevent a module from being modified during compilation?
>> I can make a clone of a module, but I’m curious if there are other ways to achieve the same goal.
>> 
>> More context:
>> 
>> When I run a program I try to get object file for a module from a cache.
>> If the object file exists, then I just proceed to a module analysis phase.
>> 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.
>> In other words:
>> 
>>   let object = cache.getObject(module);
>>   if object == null {
>>     object = compile(module)
>>     cache.putObject(object, module)
>>   }
>>   processModule(module)
>> 
>> When I run my program two times, then I basically analyze two different modules, even though they are loaded from the same bitcode file.
>> 
>> Please, let me know if more information/clarification is needed.
>> 
>> Any hints, suggestions, and recommendations are more than welcome :)
>> 
>> --
>> AlexDenisov
>> Software Engineer, http://lowlevelbits.org
>> 
>> _______________________________________________
>> LLVM Developers mailing list
>> llvm-dev at lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>> _______________________________________________
>> LLVM Developers mailing list
>> llvm-dev at lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev



More information about the llvm-dev mailing list