[llvm-dev] ARM - TargetStreamer is null

David Daniel via llvm-dev llvm-dev at lists.llvm.org
Tue Aug 29 08:21:32 PDT 2017


Dear LLVM developers

I have a problem generating ARM code with LLVM 3.7.1. Whereas with the
same application it works to create object files for x86 and x86_64 elf
little endian, my application crashes during the generation of the ARM
object file.

During debugging I can see that within ARMAsmPrinter::emitAttributes the
target streamer from OutStreamer->getTargetStreamer() is null, causing a
segfault. I spent about two days searching, also for a hint of a bug
within LLVM, maybe in this particular version but I didn't find anything.

The reason for using 3.7.1 is that we are moving the application from
LLVM 3.5 to a newer version, trying to keep the effort of changes
concerning the usage of LLVM as small as possible. Since I haven't found
a bug nor a single hint that someone else also had this problem, I
assume we are doing something wrong.

I also cannot find anything related to changes concerning the ARM
backend (or at least nothing that would affect initializing and usage of
the ARM backend) within the changelogs from 3.5 to 3.7.

Am I something missing in the initialization? As before with 3.5 we
simply initialize the LLVM libraries with the following code:

    LLVMInitializeX86Target();
    LLVMInitializeX86TargetMC();
    LLVMInitializeX86AsmPrinter();
    LLVMInitializeX86AsmParser();
    LLVMInitializeX86TargetInfo();

    LLVMInitializeARMTarget();
    LLVMInitializeARMTargetMC();
    LLVMInitializeARMAsmPrinter();
    LLVMInitializeARMAsmParser();
    LLVMInitializeARMTargetInfo();

    PassRegistry *Registry = PassRegistry::getPassRegistry();
    initializeCore(*Registry);
    initializeCodeGen(*Registry);
    initializeLoopStrengthReducePass(*Registry);
    initializeLowerIntrinsicsPass(*Registry);
    initializeUnreachableBlockElimPass(*Registry);

That's it, later on we populate the passmanager (now being the legacy
passmanager), create the target machine, call addPassesToEmitFile on the
target machine and then call run on the passmanager. Crash.

I know that this information is not really much, I simply don't know how
to go on, picking newer versions with prior adjusting all the code for
trial and error is not really an option. Of course it is possible that
there are errors within the applications code, but I have some little
hope that someone has an idea what could be wrong here in terms of using
the LLVM libraries.

Do I need to initialize something particular regarding the ARM target
streamer?

Huge thankfulness for any hints!

Best Regards
Dave


More information about the llvm-dev mailing list