[llvm] r277521 - [lli] Add the ability for OrcLazyJIT to accept multiple input modules.

Lang Hames via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 8 11:41:17 PDT 2016


Hi Dave,

Does this only enable functionality for weak symbol handling?
> (or does it, say, make it possible to have a simple two module unlinked
> situation (one module declares and calls a function, the other module
> defines that function)? That could be tested without the weak symbol
> handling)


Interesting. We have basic multi-module tests for MCJIT and
OrcMCJITReplacement, but we don't have one for OrcLazy yet. I didn't think
to add one for this patch because multi-module functionality will be
implicitly tested by the weak symbol test: To test weak symbols you have
two modules M1 and M2 that each contain a definition of a weak symbol A. M1
also contains a main function, and M2 contains a non-weak function
'foo' that returns the address of 'A'. To test weak symbol support you
verify that 'main' and 'foo' agree on the address of 'A'. If they agree
then everything works. If they disagree then weak symbol support is broken,
but multi-module support works. If multi-module support is broken the test
will refuse to run at all (returning an "symbol 'foo' not found" error).
Given that the failure mode is clear I'd be inclined to just have the one
test case with a comment explaining that. What do you think?

- Lang.


On Mon, Aug 8, 2016 at 10:29 AM, David Blaikie <dblaikie at gmail.com> wrote:

>
>
> On Tue, Aug 2, 2016 at 2:08 PM Lang Hames via llvm-commits <
> llvm-commits at lists.llvm.org> wrote:
>
>> Author: lhames
>> Date: Tue Aug  2 16:00:40 2016
>> New Revision: 277521
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=277521&view=rev
>> Log:
>> [lli] Add the ability for OrcLazyJIT to accept multiple input modules.
>>
>> LLI already supported passing multiple input modules to MCJIT via the
>> -extra-module option. This patch adds the plumbing to pass these modules
>> to
>> the OrcLazy JIT too.
>>
>> This functionality will be used in an upcoming test case for weak symbol
>> handling.
>>
>
> Does this only enable functionality for weak symbol handling?
>
> (or does it, say, make it possible to have a simple two module unlinked
> situation (one module declares and calls a function, the other module
> defines that function)? That could be tested without the weak symbol
> handling)
>
>
>>
>>
>> Modified:
>>     llvm/trunk/tools/lli/OrcLazyJIT.cpp
>>     llvm/trunk/tools/lli/OrcLazyJIT.h
>>     llvm/trunk/tools/lli/lli.cpp
>>
>> Modified: llvm/trunk/tools/lli/OrcLazyJIT.cpp
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lli/
>> OrcLazyJIT.cpp?rev=277521&r1=277520&r2=277521&view=diff
>> ============================================================
>> ==================
>> --- llvm/trunk/tools/lli/OrcLazyJIT.cpp (original)
>> +++ llvm/trunk/tools/lli/OrcLazyJIT.cpp Tue Aug  2 16:00:40 2016
>> @@ -105,7 +105,8 @@ static PtrTy fromTargetAddress(JITTarget
>>    return reinterpret_cast<PtrTy>(static_cast<uintptr_t>(Addr));
>>  }
>>
>> -int llvm::runOrcLazyJIT(std::unique_ptr<Module> M, int ArgC, char*
>> ArgV[]) {
>> +int llvm::runOrcLazyJIT(std::vector<std::unique_ptr<Module>> Ms, int
>> ArgC,
>> +                        char* ArgV[]) {
>>    // Add the program's symbols into the JIT's search space.
>>    if (sys::DynamicLibrary::LoadLibraryPermanently(nullptr)) {
>>      errs() << "Error loading program symbols.\n";
>> @@ -143,8 +144,9 @@ int llvm::runOrcLazyJIT(std::unique_ptr<
>>                 OrcInlineStubs);
>>
>>    // Add the module, look up main and run it.
>> -  auto MainHandle = J.addModule(std::move(M));
>> -  auto MainSym = J.findSymbolIn(MainHandle, "main");
>> +  for (auto &M : Ms)
>> +    J.addModule(std::move(M));
>> +  auto MainSym = J.findSymbol("main");
>>
>>    if (!MainSym) {
>>      errs() << "Could not find main function.\n";
>>
>> Modified: llvm/trunk/tools/lli/OrcLazyJIT.h
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lli/
>> OrcLazyJIT.h?rev=277521&r1=277520&r2=277521&view=diff
>> ============================================================
>> ==================
>> --- llvm/trunk/tools/lli/OrcLazyJIT.h (original)
>> +++ llvm/trunk/tools/lli/OrcLazyJIT.h Tue Aug  2 16:00:40 2016
>> @@ -156,7 +156,8 @@ private:
>>    std::vector<orc::CtorDtorRunner<CODLayerT>> IRStaticDestructorRunners;
>>  };
>>
>> -int runOrcLazyJIT(std::unique_ptr<Module> M, int ArgC, char* ArgV[]);
>> +int runOrcLazyJIT(std::vector<std::unique_ptr<Module>> Ms, int ArgC,
>> +                  char* ArgV[]);
>>
>>  } // end namespace llvm
>>
>>
>> Modified: llvm/trunk/tools/lli/lli.cpp
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lli/
>> lli.cpp?rev=277521&r1=277520&r2=277521&view=diff
>> ============================================================
>> ==================
>> --- llvm/trunk/tools/lli/lli.cpp (original)
>> +++ llvm/trunk/tools/lli/lli.cpp Tue Aug  2 16:00:40 2016
>> @@ -397,8 +397,18 @@ int main(int argc, char **argv, char * c
>>      return 1;
>>    }
>>
>> -  if (UseJITKind == JITKind::OrcLazy)
>> -    return runOrcLazyJIT(std::move(Owner), argc, argv);
>> +  if (UseJITKind == JITKind::OrcLazy) {
>> +    std::vector<std::unique_ptr<Module>> Ms;
>> +    Ms.push_back(std::move(Owner));
>> +    for (auto &ExtraMod : ExtraModules) {
>> +      Ms.push_back(parseIRFile(ExtraMod, Err, Context));
>> +      if (!Ms.back()) {
>> +        Err.print(argv[0], errs());
>> +        return 1;
>> +      }
>> +    }
>> +    return runOrcLazyJIT(std::move(Ms), argc, argv);
>> +  }
>>
>>    if (EnableCacheManager) {
>>      std::string CacheName("file:");
>>
>>
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160808/76cc0137/attachment.html>


More information about the llvm-commits mailing list