Upgrading from OLLVM4.0.0 to LLVM8.0.1, and to increase the LLVM Pass plug-in system

 

Version is too low, and must be this worried me.

On Sunday he decided to hand ollvm upgrade from 4.0.0 to LLVM8.0.1.

Inside Pass, then decided to migrate to 8.0.1 inside.

 

I'm used to from the code up hands

1: Download LLVM https://github.com/llvm/llvm-project/releases/download/llvmorg-8.0.1/llvm-8.0.1.src.tar.xz

2: Download CLang https://github.com/llvm/llvm-project/releases/download/llvmorg-8.0.1/cfe-8.0.1.src.tar.xz

After both decompression,

Then unzip into the directory after the clang llvm directory tools directory, then you can create a project vs2017 directly with cmake.

Full no errors, then created a project, you can direct a full compilation.

 

In front are simple, followed by the issue of migration pass.

I am going to add a little drama, as the clang Pass integrated inside, which will lead to a problem,

That is, clang too big, too slow to compile, change the pass to toss a sum of 20 minutes to compile, trouble.

So I'm going to write a plug-in system, all pass both written plug-ins,

clang which directly supports plug-in interface.

After compiling this time only compiler plugin just fine. clang do not need to build.

* I do not know how I'm going on this compiler, obviously I did not choose rebuild, the file did not change, but it is to bring all the project will check it again.

* Too lazy to ignore it.

 

Write plug-ins question is, where clang inside the plug-in is written.

You can create plug-in interface actually works in the same directory LLVMipo project,

ipo project is actually Pass entrance of the total project includes PassManagerBuilder internal documents, namely PassManagerBuilder.cpp,

All Pass are registered here, to see the details of my previous articles.

After the plug-in interface engineering to create finished, add it to the inside ipo project dependencies,

Then you can define a good plug-in interface. I like this definition,

Currently relatively simple.

Deriving a function of each internal module,

This function returns a pointer to an array of structures, the structure is defined as follows

Very simple, it is an element which is a function pointer defined function to create a pass, super simple.

 

The interface is resolved, but how to solve it startup parameters, a good solution, I wrote a simple template to solve this problem

 

How to use also how to use, anyway, so it was, Oh Oh Oh.

It is also very simple to use

Hardly change habits, which is almost the same.

 

But there is one last question, that is, LLVM primary requirement parameter must be registered in advance, otherwise it will prompt an error, as follows

Talia solved, in fact, easy to handle, in fact, Talia is not important, it is important that the process is directly behind Talia exit (1), so long as Talia position, and then the end of the process to find the exit on it .

Process will continue, if unhappy to see this error, you can put Talia deleted.

 

After these have been resolved, there is a small problem is where to put the plug-in project.

This problem easy to solve,

You can create the project in the same directory libclong project, and then here to write plug-ins, you can.

 

So far, all the problems solved.

 

LLVM framework upgrade is complete, before the old ollvm do not.

 

Feeling regarded as a simple solution to the problem are also the perfect solution.

 

Guess you like

Origin www.cnblogs.com/suanguade/p/11415993.html