[LLVMdev] ARM opcode format

Jim Grosbach grosbach at apple.com
Mon Feb 20 12:08:23 PST 2012


On Feb 20, 2012, at 8:43 AM, Guillermo Perez <gaperez64 at gmail.com> wrote:

> Hello,
> 
> So the current JIT will be superseded by the MCJIT completely and no further development should be expected for the current JIT?

Yes.


> In any case, I am definitely interested in submitting a patch if you could help me by sending me in the right direction, since I really want this working.
> 
> I managed to reproduce this behavior in LLVM 3.0 by modifying llc to read my .bc file and try to JIT the code for the mentioned Triple.
> 
> The error:
> 
> ARMCodeEmitter::emitPseudoInstruction
> UNREACHABLE executed at /home/guillermo/llvm-3.0.src/lib/Target/ARM/ARMCodeEmitter.cpp:838!
> Stack dump:
> 0.	Program arguments: ./bin/llc -mtriple armv7a-unknown-linux-gnueabi -O3 /home/guillermo/Code/SieveAtom_execute.bc 
> 1.	Running pass 'ARM Machine Code Emitter' on function '@execute'
> Aborted (core dumped)
> 
> The code I modified for llc was:
> 
> //===-- llc.cpp - Implement the LLVM Native Code Generator ----------------===//
> //
> //                     The LLVM Compiler Infrastructure
> //
> // This file is distributed under the University of Illinois Open Source
> // License. See LICENSE.TXT for details.
> //
> //===----------------------------------------------------------------------===//
> //
> // This is the llc code generator driver. It provides a convenient
> // command-line interface for generating native assembly-language code
> // or C code, given LLVM bitcode.
> //
> //===----------------------------------------------------------------------===//
> #include <iostream>
> #include "llvm/LLVMContext.h"
> #include "llvm/Module.h"
> #include "llvm/PassManager.h"
> #include "llvm/Pass.h"
> #include "llvm/ADT/Triple.h"
> #include "llvm/Support/IRReader.h"
> #include "llvm/CodeGen/LinkAllAsmWriterComponents.h"
> #include "llvm/CodeGen/LinkAllCodegenComponents.h"
> #include "llvm/Config/config.h"
> #include "llvm/MC/SubtargetFeature.h"
> #include "llvm/Support/CommandLine.h"
> #include "llvm/Support/Debug.h"
> #include "llvm/Support/FormattedStream.h"
> #include "llvm/Support/ManagedStatic.h"
> #include "llvm/Support/PluginLoader.h"
> #include "llvm/Support/PrettyStackTrace.h"
> #include "llvm/Support/ToolOutputFile.h"
> #include "llvm/Support/Host.h"
> #include "llvm/Support/Signals.h"
> #include "llvm/Support/TargetRegistry.h"
> #include "llvm/Support/TargetSelect.h"
> #include "llvm/Target/TargetData.h"
> #include "llvm/Target/TargetMachine.h"
> #include "llvm/ExecutionEngine/ExecutionEngine.h"
> #include "llvm/ExecutionEngine/JIT.h"
> #include "llvm/Analysis/Passes.h"
> #include "llvm/Transforms/Scalar.h"
> #include <memory>
> using namespace llvm;
> ...
> ...
> ...
>   // Build up all of the passes that we want to do to the module.
>   // PassManager PM;
> 
>   // Add the target data from the target machine, if it exists, or the module.
>   //if (const TargetData *TD = Target.getTargetData())
>   //  PM.add(new TargetData(*TD));
>   //else
>   //  PM.add(new TargetData(&mod));
> 
>   // Override default to generate verbose assembly.
>   //Target.setAsmVerbosityDefault(true);
> 
>   //if (RelaxAll) {
>   //  if (FileType != TargetMachine::CGFT_ObjectFile)
>   //    errs() << argv[0]
>   //           << ": warning: ignoring -mc-relax-all because filetype != obj";
>   //  else
>   //    Target.setMCRelaxAll(true);
>   //}
> 
>   //{
>   //  formatted_raw_ostream FOS(Out->os());
> 
>     // Ask the target to add backend passes as necessary.
>   //  if (Target.addPassesToEmitFile(PM, FOS, FileType, OLvl, NoVerify)) {
>   //    errs() << argv[0] << ": target does not support generation of this"
>   //           << " file type!\n";
>   //    return 1;
>   //  }
> 
>     // Before executing passes, print the final values of the LLVM options.
>   //  cl::PrintOptionValues();
> 
>   //  PM.run(mod);
>   //}
> 
>   // Declare success.
>   //Out->keep();
> 
>   // mods for cryo
>     // create an execution engine to export code later
>     EngineBuilder eBuilder(&mod);
>     std::string error;
>     eBuilder.setErrorStr(&error);
>     ExecutionEngine *TheExecutionEngine = eBuilder.create();
>     if(!TheExecutionEngine) {
>         std::cout<<error.c_str()<<std::endl;
>         return 1;
>     }
> 
>     // compile and return function pointer
>     FunctionPassManager OurFPM(&mod);
>     // Start with registering info about how the
>     // target lays out data structures.
>     OurFPM.add(new TargetData(*TheExecutionEngine->getTargetData()));
>     // Provide basic AliasAnalysis support for GVN.
>     OurFPM.add(createBasicAliasAnalysisPass());
>     // Do simple "peephole" optimizations and bit-twiddling optzns.
>     OurFPM.add(createInstructionCombiningPass());
>     // Reassociate expressions.
>     OurFPM.add(createReassociatePass());
>     // Eliminate Common SubExpressions.
>     OurFPM.add(createGVNPass());
>     // Simplify the control flow graph (deleting unreachable blocks, etc).
>     OurFPM.add(createCFGSimplificationPass());
> 
>     // we run optimizations and return the pointer to the function
>     OurFPM.doInitialization();
>     Function* currentF = mod.getFunction("execute");
>     OurFPM.run(*currentF);
> 
>     TheExecutionEngine->getPointerToFunction(currentF);
> 
>   return 0;
> }
> 
> Thanks again for your help,
> 
> On Mon, Feb 20, 2012 at 11:06 PM, Anton Korobeynikov <anton at korobeynikov.info> wrote:
> Guillermo,
> 
> > I'm sorry I forgot to mention I am compiling the bitcode using the JIT. The
> > actual error, I get when I'm trying to get the function to the pointer. I'm
> > using a custom front end that translates Android's Dalvik bytecode into LLVM
> > bitcode based on Android ICS's modified LLVM version.
> ARM JIT is broken in many ways. So, what you're seeing is perfectly
> expected. You might want to wait until MCJIT will be usable and/or
> provide patches to make this happen sooner :)
> 
> --
> With best regards, Anton Korobeynikov
> Faculty of Mathematics and Mechanics, Saint Petersburg State University
> 
> 
> 
> -- 
> Guillermo A. Pérez (吉耶莫)
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20120220/d117b572/attachment.html>


More information about the llvm-dev mailing list