Kaleidoscope tutorial failed at Chapter 4...

Hi everyone. I am using LLVM 2.4 release to practise the tutorial at Kaleidoscope Chapter 4.
I built the LLVM library, and created my own project, and then paste the code from the tutorial into my own project. Then after compiled and built it, I passed the built stage. (I am using visual studio 2005 )

However, when I tried to input some code in the command line window, the sample program crashed. And the Visual Studio 2005 debugger told me that “Access violation reading location 0x00000008.”
And then it jumped to the code:
" const TargetData *getTargetData() const { return TD; }"
Actually, these codes are suspicous:

TheExecutionEngine = ExecutionEngine::create(TheModule);
// Set up the optimizer pipeline. Start with registering info about how the
// target lays out data structures.
OurFPM.add(new TargetData(*TheExecutionEngine->getTargetData()));

There is nothing to initialize the TD variable, so the exception is quite understandable. But how to eliminate this problem? Can anyone give me a help?

Thank you very much for any guidance.

The tutorial is not always up-to-date when a new release arrives.

I had similar problems (not exactly the same cases) when learning through the tutorials using LLVM-2.3.

My best suggestion is to read through part of the source code and figure out why it is behaving strangely.
And, use Linux (gcc) rather than Windows (visual studio) compilers for the learning purpose.

In the end, I think the tutorials are still pretty good, though some minus updates are always needed.


Alex.Wang wrote: