<div dir="ltr">i've changed lli arguments to the next (instead of default):<div><br><div><div><font face="courier new, monospace">return llvm_interpret(</font></div><div><font face="courier new, monospace">    InputFile,</font></div><div><font face="courier new, monospace">    std::vector<std::string>(),</font></div><div><font face="courier new, monospace">    false, // ForceInterpreter</font></div><div><font face="courier new, monospace">    false, // UseMCJIT</font></div><div><font face="courier new, monospace">    false, // DebugIR</font></div><div><font face="courier new, monospace">    false, // RemoteMCJIT</font></div><div><font face="courier new, monospace">    "", // MCJITRemoteProcess</font></div><div><font face="courier new, monospace">    ' ', // OptLevel</font></div><div><font face="courier new, monospace">    std::string("thumbv7-apple-ios7.1.0"), // TargetTriple</font></div><div><font face="courier new, monospace">    std::string("thumb"), // MArch</font></div><div><font face="courier new, monospace">    std::string("cortex-a8"), // MCPU</font></div><div><font face="courier new, monospace">    std::vector<std::string>(), // MAttrs</font></div><div><font face="courier new, monospace">    "main", // EntryFunc</font></div><div><font face="courier new, monospace">    std::vector<std::string>(), // ExtraModules</font></div><div><font face="courier new, monospace">    std::string(), // FakeArgv0</font></div><div><font face="courier new, monospace">    false, // DisableCoreFiles</font></div><div><font face="courier new, monospace">    false, // NoLazyCompilation</font></div><div><font face="courier new, monospace">    Reloc::PIC_, // RelocModel</font></div><div><font face="courier new, monospace">    CodeModel::JITDefault, // CMModel</font></div><div><font face="courier new, monospace">    true, // GenerateSoftFloatCalls</font></div><div><font face="courier new, monospace">    FloatABI::Soft, // FloatABIForCalls</font></div><div><font face="courier new, monospace">    false, // EmitJitDebugInfo</font></div><div><font face="courier new, monospace">    false, // EmitJitDebugInfoToDisk</font></div><div><font face="courier new, monospace">    envp // envp</font></div><div><font face="courier new, monospace">    );</font></div></div><div><br></div><div>Now i'm having:</div><div><br></div><div><div><b>Unhandled instruction encoding format!</b></div><div>UNREACHABLE executed at /Users/asmirnov/Documents/dev/src/llvm_34_ios/lib/Target/ARM/ARMCodeEmitter.cpp:547!</div><div>0  iCode                    0x01f7e591 llvm::sys::PrintStackTrace(__sFILE*) + 44</div><div>1  iCode                    0x01f7e807 PrintStackTraceSignalHandler(void*) + 26</div><div>2  iCode                    0x01f7eb09 SignalHandler(int) + 356</div><div>3  libsystem_platform.dylib 0x397e171b _sigtramp + 34</div><div>4  libsystem_pthread.dylib  0x397e67b7 pthread_kill + 58</div><div>5  iCode                    0x01f7e81f raise + 18</div><div>6  iCode                    0x01f7e8b5 abort + 16</div><div>7  iCode                    0x01f6d395 llvm::SmallVector<char, 64u>::SmallVector() + 0</div><div>8  iCode                    0x01410bd5 (anonymous namespace)::ARMCodeEmitter::emitInstruction(llvm::MachineInstr const&) + 1652</div><div>9  iCode                    0x01410521 (anonymous namespace)::ARMCodeEmitter::runOnMachineFunction(llvm::MachineFunction&) + 556</div><div>10 iCode                    0x016788f5 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) + 72</div><div>11 iCode                    0x018749ad llvm::FPPassManager::runOnFunction(llvm::Function&) + 252</div><div>12 iCode                    0x018744ab llvm::legacy::FunctionPassManagerImpl::run(llvm::Function&) + 78</div><div>13 iCode                    0x01874455 llvm::legacy::FunctionPassManager::run(llvm::Function&) + 200</div><div>14 iCode                    0x01a36d9d llvm::JIT::jitTheFunction(llvm::Function*, llvm::MutexGuard const&) + 44</div><div>15 iCode                    0x01a36c31 llvm::JIT::runJITOnFunctionUnlocked(llvm::Function*, llvm::MutexGuard const&) + 112</div><div>16 iCode                    0x01a36f7f llvm::JIT::getPointerToFunction(llvm::Function*) + 450</div><div>17 iCode                    0x000da28d llvm_interpret(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > >, bool, bool, bool, bool, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, bool, llvm::Reloc::Model, llvm::CodeModel::Model, bool, llvm::FloatABI::ABIType, bool, bool, char*) + 4364</div><div>18 iCode                    0x000db8c7 llvm_interpret(char const*, char*) + 1346</div><div>19 iCode                    0x000dbb83 llvm_interpret(char const*, char*, char const*) + 134</div><div>20 iCode                    0x000b0973 -[ASMainController didClickCompile:] + 2446</div><div>21 UIKit                    0x30f656a7 <redacted> + 90</div><div>22 UIKit                    0x310cc56d <redacted> + 120</div><div>23 UIKit                    0x30f656a7 <redacted> + 90</div><div>24 UIKit                    0x30f65643 <redacted> + 38</div><div>25 UIKit                    0x30f65613 <redacted> + 46</div><div>26 UIKit                    0x30f50d5b <redacted> + 374</div><div>27 UIKit                    0x30f6505b <redacted> + 594</div><div>28 UIKit                    0x30f28521 <redacted> + 5528</div><div>29 CoreFoundation           0x2e6c9ff9 <redacted> + 20</div><div>30 CoreFoundation           0x2e6c7987 <redacted> + 286</div><div>31 CoreFoundation           0x2e6c7cd3 <redacted> + 738</div><div>32 CoreFoundation           0x2e632729 CFRunLoopRunSpecific + 524</div><div>33 CoreFoundation           0x2e63250b CFRunLoopRunInMode + 106</div><div>34 GraphicsServices         0x3355e6d3 GSEventRunModal + 138</div><div>35 UIKit                    0x30f93871 UIApplicationMain + 1136</div><div>36 iCode                    0x000d0829 main + 116</div><div>37 libdyld.dylib            0x396c7ab7 <redacted> + 2</div><div>Stack dump:</div><div>0.<span class="" style="white-space:pre">     </span>Running pass 'ARM Machine Code Emitter' on function '@main'</div><div>0  iCode                    0x01f7e591 llvm::sys::PrintStackTrace(__sFILE*) + 44</div><div>1  iCode                    0x01f7e807 PrintStackTraceSignalHandler(void*) + 26</div><div>2  iCode                    0x01f7eb09 SignalHandler(int) + 356</div><div>3  libsystem_platform.dylib 0x397e171b _sigtramp + 34</div><div>4  libsystem_pthread.dylib  0x397e67b7 pthread_kill + 58</div><div>5  iCode                    0x01f7e81f raise + 18</div><div>6  iCode                    0x01f7e8b5 abort + 16</div><div>7  iCode                    0x01f6d395 llvm::SmallVector<char, 64u>::SmallVector() + 0</div><div>8  iCode                    0x01410bd5 (anonymous namespace)::ARMCodeEmitter::emitInstruction(llvm::MachineInstr const&) + 1652</div><div>9  iCode                    0x01410521 (anonymous namespace)::ARMCodeEmitter::runOnMachineFunction(llvm::MachineFunction&) + 556</div><div>10 iCode                    0x016788f5 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) + 72</div><div>11 iCode                    0x018749ad llvm::FPPassManager::runOnFunction(llvm::Function&) + 252</div><div>12 iCode                    0x018744ab llvm::legacy::FunctionPassManagerImpl::run(llvm::Function&) + 78</div><div>13 iCode                    0x01874455 llvm::legacy::FunctionPassManager::run(llvm::Function&) + 200</div><div>14 iCode                    0x01a36d9d llvm::JIT::jitTheFunction(llvm::Function*, llvm::MutexGuard const&) + 44</div><div>15 iCode                    0x01a36c31 llvm::JIT::runJITOnFunctionUnlocked(llvm::Function*, llvm::MutexGuard const&) + 112</div><div>16 iCode                    0x01a36f7f llvm::JIT::getPointerToFunction(llvm::Function*) + 450</div><div>17 iCode                    0x000da28d llvm_interpret(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > >, bool, bool, bool, bool, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, bool, llvm::Reloc::Model, llvm::CodeModel::Model, bool, llvm::FloatABI::ABIType, bool, bool, char*) + 4364</div><div>18 iCode                    0x000db8c7 llvm_interpret(char const*, char*) + 1346</div><div>19 iCode                    0x000dbb83 llvm_interpret(char const*, char*, char const*) + 134</div><div><br></div></div></div><div>this seems to be different arguments between compile and interpret or bitcode was generated incorrectly?</div></div><div class="gmail_extra"><br><div class="gmail_quote">2014-09-17 11:58 GMT+06:00 Anton Smirnov <span dir="ltr"><<a href="mailto:dev@antonsmirnov.name" target="_blank">dev@antonsmirnov.name</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">correction: triple for compilation was "thumbv7-apple-ios7.1.0" - see compiled .ll code</div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">2014-09-17 11:56 GMT+06:00 Anton Smirnov <span dir="ltr"><<a href="mailto:dev@antonsmirnov.name" target="_blank">dev@antonsmirnov.name</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">hi.<div><br></div><div>i'm trying to compile (seems to be sucessfully) and execute code on arm (ios apple ipad air) and i'm having <b>exc_bad_instruction (code=exc_arm_undefined, subcode=0x8458b00)</b> exception.</div><div><br></div><div>source code:</div><div><br></div><div><font face="courier new, monospace">int main(int count, const char **args) {</font></div><div><font face="courier new, monospace">  const char *c = "hello world";</font></div><div><font face="courier new, monospace">  return 1 + 5;</font></div><div><font face="courier new, monospace">}</font></div><div><br></div><div>generate bit-code cmd:</div><div><br></div><div><div>const char *cmd[] = {</div><div>        "clang",</div><div>        "-cc1",</div><div>        "-triple",</div><div>            "arm-apple-macosx10.10.0", //"thumbv7-apple-ios7.1.0", //"arm-apple-macosx10.10.0", // "i386-apple-macosx10.10.0",</div><div>        "-emit-llvm",</div><div>        "-disable-free",</div><div>        "-main-file-name",</div><div>            [cppShortFile UTF8String],</div><div>        "-mrelocation-model",</div><div>            "pic",</div><div>        "-pic-level",</div><div>            "2",</div><div>        "-mdisable-fp-elim",</div><div>        "-masm-verbose",</div><div>        "-target-cpu",</div><div>            "cortex-a8", //"yonah",</div><div>        "-target-linker-version",</div><div>            "236.3",</div><div>        "-v",</div><div>        "-coverage-file",</div><div>            [llFile UTF8String], //"/private/var/mobile/Applications/175ECA7F-3175-4AC9-971C-85272F5492C4/tmp/hw.ll"</div><div>        "-resource-dir",</div><div>            [[[ASPathHolder sharedHolder] tempFolder] UTF8String],</div><div>        "-stdlib=libc++",</div><div>        "-fdeprecated-macro",</div><div>        "-fdebug-compilation-dir",</div><div>            [[[ASPathHolder sharedHolder] tempFolder] UTF8String],</div><div>        "-ferror-limit",</div><div>            "19",</div><div>        "-fmessage-length",</div><div>            "0",</div><div>        //"-I",</div><div>        //    [[[[ASPathHolder sharedHolder] includeFolder] stringByAppendingString:@"/libc"] UTF8String], // libc include folder</div><div>        //"-I",</div><div>        //    [[[[ASPathHolder sharedHolder] includeFolder] stringByAppendingString:@"/libcxx"] UTF8String], // libc++ include folder</div><div>        "-stack-protector",</div><div>            "1",</div><div>        "-mstackrealign",</div><div>        //"-fblocks", // Apple "blocks" extensions</div><div>        //"-fobjc-runtime=macosx-fragile-10.10.0", // object-c runtime</div><div>        //"-fobjc-subscripting-legacy-runtime",</div><div>        "-fencode-extended-block-signature",</div><div>        "-fcxx-exceptions",</div><div>        "-fexceptions",</div><div>        "-fdiagnostics-show-option",</div><div>        "-vectorize-slp",</div><div>        "-target-feature",</div><div>            "+soft-float-abi",</div><div>        "-target-abi",</div><div>            "apcs-gnu",</div><div>        "-mfloat-abi",</div><div>            "soft",</div><div>        "-o",</div><div>            [llFile UTF8String], // /private/var/mobile/Applications/175ECA7F-3175-4AC9-971C-85272F5492C4/tmp/hw.ll</div><div>        "-x",</div><div>        "c++",</div><div>            [cppFile UTF8String] //"/private/var/mobile/Applications/175ECA7F-3175-4AC9-971C-85272F5492C4/tmp/hw.cpp"</div><div>    };</div></div><div><br></div><div>i'm not sure i'm using correct triple, target cpu and target features but i used xcodes ones (when targeting ios device).</div><div><br></div><div>compilation was successfull and i'm having .ll file:</div><div><div><font face="courier new, monospace">; ModuleID = '/var/mobile/Applications/53D60D11-DF93-4129-AD97-B96424D165B5/Documents/projects/calc/calc.cpp'</font></div><div><font face="courier new, monospace">target datalayout = "e-p:32:32:32-i1:8:32-i8:8:32-i16:16:32-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:32:64-v128:32:128-a0:0:32-n32-S32"</font></div><div><font face="courier new, monospace">target triple = "thumbv7-apple-ios7.1.0"</font></div><div><font face="courier new, monospace"><br></font></div><div><font face="courier new, monospace">@.str = private unnamed_addr constant [12 x i8] c"hello world\00", align 1</font></div><div><font face="courier new, monospace"><br></font></div><div><font face="courier new, monospace">; Function Attrs: nounwind ssp</font></div><div><font face="courier new, monospace">define i32 @main(i32 %count, i8** %args) #0 {</font></div><div><font face="courier new, monospace">entry:</font></div><div><font face="courier new, monospace">  %retval = alloca i32, align 4</font></div><div><font face="courier new, monospace">  %count.addr = alloca i32, align 4</font></div><div><font face="courier new, monospace">  %args.addr = alloca i8**, align 4</font></div><div><font face="courier new, monospace">  %c = alloca i8*, align 4</font></div><div><font face="courier new, monospace">  store i32 0, i32* %retval</font></div><div><font face="courier new, monospace">  store i32 %count, i32* %count.addr, align 4</font></div><div><font face="courier new, monospace">  store i8** %args, i8*** %args.addr, align 4</font></div><div><font face="courier new, monospace">  store i8* getelementptr inbounds ([12 x i8]* @.str, i32 0, i32 0), i8** %c, align 4</font></div><div><font face="courier new, monospace">  ret i32 6</font></div><div><font face="courier new, monospace">}</font></div><div><font face="courier new, monospace"><br></font></div><div><font face="courier new, monospace">attributes #0 = { nounwind ssp "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }</font></div><div><font face="courier new, monospace"><br></font></div><div><font face="courier new, monospace">!llvm.ident = !{!0}</font></div><div><font face="courier new, monospace"><br></font></div><div><font face="courier new, monospace">!0 = metadata !{metadata !"clang version 3.4 (tags/RELEASE_34/final 212412)"}</font></div></div><div><br></div><div>is it correct or can you see obvious errors?</div><div><br></div><div>then i'm trying to interpret .ll file.</div><div>i've copied lli tool source code and launching it from my ios app (created static lib instead of executable) with default arguments (like triple and cpu and so on - this can probably be wrong!).</div><div><br></div><div>Then i'm having exception in ExecutionEngine.cpp in line:</div><div>







<p><font face="courier new, monospace"><span>return</span> runFunction(Fn, GVArgs).IntVal.getZExtValue();</font></p><p><b>exc_bad_instruction (code=exc_arm_undefined, subcode=0x8458b00)</b></p><p>Any thoughts? What does this subcode mean?</p><p>Any help is highly appreciated.</p><p>Regards, Anton.</p></div></div>
</blockquote></div><br></div>
</div></div></blockquote></div><br></div>