I am writing my register allocator directly in the LLVM tree, and I am
having trouble linking my project on windows msvc 10.0 compiler. The
error are below, but let me say what I have changed.
1. I added "(void) llvm::createJDKunkRegisterAllocator();" to the
struct ForcePassLinking::ForcePassLinking() method in
"llvm\include\llvm\LinkAllPasses.h"
2. I added "FunctionPass* createJDKunkRegisterAllocator();" to header
"llvm\CodeGen\Passes.h."
3. I implemented "FunctionPass* createJDKunkRegisterAllocator()" in my cpp file.
I know the api change said some items were changed, and it has worked
until the api change e-mail came out. However, I cannot figure out
what I need to change to have this project link.
2> Creating library C:/Users/JDKunk/Documents/Visual Studio
2010/Projects/VSllvm/lib/Debug/bugpoint.lib and object
C:/Users/JDKunk/Documents/Visual Studio
2010/Projects/VSllvm/lib/Debug/bugpoint.exp
2>bugpoint.obj : error LNK2019: unresolved external symbol "class
llvm::FunctionPass * __cdecl
llvm::createJDKunkRegisterAllocator(void)"
(?createJDKunkRegisterAllocator@llvm@@YAPAVFunctionPass@1@XZ)
referenced in function "public: __thiscall `anonymous
namespace'::ForcePassLinking::ForcePassLinking(void)"
(??0ForcePassLinking@?A0xb2143f5b@@QAE@XZ)
4> Creating library C:/Users/JDKunk/Documents/Visual Studio
2010/Projects/VSllvm/lib/Debug/opt.lib and object
C:/Users/JDKunk/Documents/Visual Studio
2010/Projects/VSllvm/lib/Debug/opt.exp
4>opt.obj : error LNK2019: unresolved external symbol "class
llvm::FunctionPass * __cdecl
llvm::createJDKunkRegisterAllocator(void)"
(?createJDKunkRegisterAllocator@llvm@@YAPAVFunctionPass@1@XZ)
referenced in function "public: __thiscall `anonymous
namespace'::ForcePassLinking::ForcePassLinking(void)"
(??0ForcePassLinking@?A0x853fd888@@QAE@XZ)
Thanks,
Jeff Kunkel
Jeff Kunkel <jdkunk3@gmail.com> writes:
I am writing my register allocator directly in the LLVM tree, and I am
having trouble linking my project on windows msvc 10.0 compiler. The
error are below, but let me say what I have changed.
1. I added "(void) llvm::createJDKunkRegisterAllocator();" to the
struct ForcePassLinking::ForcePassLinking() method in
"llvm\include\llvm\LinkAllPasses.h"
2. I added "FunctionPass* createJDKunkRegisterAllocator();" to header
"llvm\CodeGen\Passes.h."
3. I implemented "FunctionPass* createJDKunkRegisterAllocator()" in my cpp file.
I know the api change said some items were changed, and it has worked
until the api change e-mail came out. However, I cannot figure out
what I need to change to have this project link.
Is you register allocator on an existing LLVM library? Which one?
Or did you create a new library for it?
Have you added the new source files to the corresponding CMakeLists.txt
file ?
[snip]
- I placed my code in the the existing CodeGen library.
- No, it is not in the CMakeLists.txt. The code is separate from the
rest of the CodeGen code, but it is linked into the code gen library
automatically through the visual studio linker. Perhaps something
funny is going on here. I will try placing the code directly in the
library, and I will include it to the CMakeLists.txt.
- Thanks
- Jeff Kunkel
Jeff Kunkel <jdkunk3@gmail.com> writes:
- I placed my code in the the existing CodeGen library.
Ok.
- No, it is not in the CMakeLists.txt. The code is separate from the
rest of the CodeGen code, but it is linked into the code gen library
automatically through the visual studio linker.
If your source code is on a separate file, and that file is not listed
on the CMakeLists.txt file, it is not being compiled.
Perhaps something
funny is going on here. I will try placing the code directly in the
library, and I will include it to the CMakeLists.txt.
I'm confused. What means "placing the code directly in the library"?
Please describe where you wrote your code, specifying file names and
directories.
I ran cmake to build the visual studio projects. Then I included my
code under the Visual Studio interface, but I placed my code separate
from the CodeGen code. Visual studio was smart enough to compile and
link in my code into the CodeGen library. Thus, I did not need to add
my code into the same directory as the CodeGen files, and I did not
need to change the CMakeList.txt.
The offical name is LLVMCodeGen.
However, the "opt.obj" and "bugpoint.obj" cannot find the reference
function "llvm::createJDKunkRegisterAllocator." I added this file to
the header described previously. I implemented it, in my
RegAllocJDKunk.cpp file.
Jeff Kunkel
So, how do I now link in a custom register allocator now? I am missing
a call to the new API initializePass in opt and bugpoint because I am
lost.
Thanks,
Jeff Kunkel
Jeff Kunkel <jdkunk3@gmail.com> writes:
I ran cmake to build the visual studio projects. Then I included my
code under the Visual Studio interface, but I placed my code separate
from the CodeGen code. Visual studio was smart enough to compile and
link in my code into the CodeGen library. Thus, I did not need to add
my code into the same directory as the CodeGen files, and I did not
need to change the CMakeList.txt.
Next time you update your LLVM sources, that VS solution will be
overwritten.
The offical name is LLVMCodeGen.
However, the "opt.obj" and "bugpoint.obj" cannot find the reference
function "llvm::createJDKunkRegisterAllocator." I added this file to
the header described previously. I implemented it, in my
RegAllocJDKunk.cpp file.
As you do not provide the information I asked for, I can't help you
anymore.
I'm sorry, I don't know what you were looking for. The first 5 were
scattered amidst different e-mails. The others have to do with
following what "RAFast" and "RALinScan" as examples. It's a linker
error, and I do not know why only opt and bugpoint does not compiler,
and why llc does not show my reg alloc pass anymore. It worked before
the API change e-mail was released.
1) I created my .cpp file RegAllocJDKunk.cpp in llvm/lib/CodeGen/ directory.
2) I updated the CMakeList.txt in the directory llvm/lib/CodeGen/ to
include RegAllocJDKunk.cpp.
3) I added "(void) llvm::createJDKunkRegisterAllocator();" to the
struct ForcePassLinking::ForcePassLinking() method in
"llvm\include\llvm\LinkAllPasses.h"
4) I added "FunctionPass* createJDKunkRegisterAllocator();" to header
"llvm\CodeGen\Passes.h."
5) I implemented "FunctionPass* createJDKunkRegisterAllocator()" in my cpp file.
6) I added "initializeRAJDKunk(Registry);" to
llvm/lib/CodeGen/CodeGen.cpp in the "void
llvm::initializeCodeGen(PassRegistry &Registry)"
7) I added "void initializeRAJDKunk(PassRegistry&);" to the header
file "llvm\include\llvm\InitializePasses.h."
8) Cmake ran, and Visaul Studio build all but opt and bugpoint because
of the errors at the bottom of this message.
9) I don't know why this does not link anymore. I remember it worked
before the API change e-mail was sent, so I assumed I missed something
with the api change. This is the only reason I can see.
2> Creating library C:/Users/JDKunk/Documents/Visual Studio
2010/Projects/VSllvm/lib/Debug/bugpoint.lib and object
C:/Users/JDKunk/Documents/Visual Studio
2010/Projects/VSllvm/lib/Debug/bugpoint.exp
2>bugpoint.obj : error LNK2019: unresolved external symbol "class
llvm::FunctionPass * __cdecl
llvm::createJDKunkRegisterAllocator(void)"
(?createJDKunkRegisterAllocator@llvm@@YAPAVFunctionPass@1@XZ)
referenced in function "public: __thiscall `anonymous
namespace'::ForcePassLinking::ForcePassLinking(void)"
(??0ForcePassLinking@?A0xb2143f5b@@QAE@XZ)
4> Creating library C:/Users/JDKunk/Documents/Visual Studio
2010/Projects/VSllvm/lib/Debug/opt.lib and object
C:/Users/JDKunk/Documents/Visual Studio
2010/Projects/VSllvm/lib/Debug/opt.exp
4>opt.obj : error LNK2019: unresolved external symbol "class
llvm::FunctionPass * __cdecl
llvm::createJDKunkRegisterAllocator(void)"
(?createJDKunkRegisterAllocator@llvm@@YAPAVFunctionPass@1@XZ)
referenced in function "public: __thiscall `anonymous
namespace'::ForcePassLinking::ForcePassLinking(void)"
(??0ForcePassLinking@?A0x853fd888@@QAE@XZ)
Jeff Kunkel <jdkunk3@gmail.com> writes:
I'm sorry, I don't know what you were looking for. The first 5 were
scattered amidst different e-mails. The others have to do with
following what "RAFast" and "RALinScan" as examples. It's a linker
error, and I do not know why only opt and bugpoint does not compiler,
and why llc does not show my reg alloc pass anymore. It worked before
the API change e-mail was released.
1) I created my .cpp file RegAllocJDKunk.cpp in llvm/lib/CodeGen/ directory.
2) I updated the CMakeList.txt in the directory llvm/lib/CodeGen/ to
include RegAllocJDKunk.cpp.
3) I added "(void) llvm::createJDKunkRegisterAllocator();" to the
struct ForcePassLinking::ForcePassLinking() method in
"llvm\include\llvm\LinkAllPasses.h"
4) I added "FunctionPass* createJDKunkRegisterAllocator();" to header
"llvm\CodeGen\Passes.h."
5) I implemented "FunctionPass* createJDKunkRegisterAllocator()" in my cpp file.
6) I added "initializeRAJDKunk(Registry);" to
llvm/lib/CodeGen/CodeGen.cpp in the "void
llvm::initializeCodeGen(PassRegistry &Registry)"
7) I added "void initializeRAJDKunk(PassRegistry&);" to the header
file "llvm\include\llvm\InitializePasses.h."
8) Cmake ran, and Visaul Studio build all but opt and bugpoint because
of the errors at the bottom of this message.
9) I don't know why this does not link anymore. I remember it worked
before the API change e-mail was sent, so I assumed I missed something
with the api change. This is the only reason I can see.
Thanks, that's much better.
If you can provide a patch comprising all those changes I'll take a look
at it.
[snip]
Ah,HA! Solution!
Step 3 is incorrect. I should not add it to the file
"llvm\include\llvm\LinkAllPasses.h" but to the file
"C:\llvm\include\llvm\CodeGen\LinkAllCodegenComponents.h."
It was a simple linker error.
As for visual studio and cmake, yes cmake does overwrite my solutions
when I update my sources. However, svn, cmake and visual studio does a
very good job of not overwriting my code. There was no harm or
problems in keeping my code up to date and developing my code out of
the tree and linking into the tree.
Thanks,
Jeff Kunkel