<div dir="ltr">I've also tried the next combination:<div><div><font face="courier new, monospace">true, // ForceInterpreter</font></div><div><font face="courier new, monospace">false, // UseMCJIT</font></div></div><div>and ios app just crashed with no output</div></div><div class="gmail_extra"><br><div class="gmail_quote">2014-09-18 0:47 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">Hey.<div><br></div><div>I've checked out LLVM/Clang 3.5 and modified my static libs source code to use the latest llvm/clang sources.</div><div>Also i'm trying triple ""arm64-apple-ios7.0"" now as it's wriiten in 3.5 release notes.</div><div><br></div><div>I'm having simple (and pretty useless) source file:</div><span class=""><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></span><div>i using the next llc params:</div><div><span class=""><div><font face="courier new, monospace">const char *cmd[] = {</font></div><div><font face="courier new, monospace"> "clang",</font></div><div><font face="courier new, monospace"> "-cc1",</font></div><div><font face="courier new, monospace"> "-triple",</font></div></span><div><font face="courier new, monospace"> "arm64-apple-ios7.0",</font></div><span class=""><div><font face="courier new, monospace"> "-emit-llvm",</font></div><div><font face="courier new, monospace"> "-disable-free",</font></div><div><font face="courier new, monospace"> "-main-file-name",</font></div></span><div><font face="courier new, monospace"> [cppShortFile UTF8String], // "hw.cpp"</font></div><span class=""><div><font face="courier new, monospace"> "-mrelocation-model",</font></div><div><font face="courier new, monospace"> "pic",</font></div><div><font face="courier new, monospace"> "-pic-level",</font></div><div><font face="courier new, monospace"> "2",</font></div><div><font face="courier new, monospace"> "-mdisable-fp-elim",</font></div><div><font face="courier new, monospace"> "-masm-verbose",</font></div></span><span class=""><div><font face="courier new, monospace"> "-target-linker-version",</font></div><div><font face="courier new, monospace"> "236.3",</font></div><div><font face="courier new, monospace"> "-v",</font></div><div><font face="courier new, monospace"> "-coverage-file",</font></div><div><font face="courier new, monospace"> [llFile UTF8String], //"/private/var/mobile/Applications/175ECA7F-3175-4AC9-971C-85272F5492C4/tmp/hw.ll"</font></div><div><font face="courier new, monospace"> "-resource-dir",</font></div><div><font face="courier new, monospace"> [[[ASPathHolder sharedHolder] tempFolder] UTF8String],</font></div><div><font face="courier new, monospace"> "-stdlib=libc++",</font></div><div><font face="courier new, monospace"> "-fdeprecated-macro",</font></div><div><font face="courier new, monospace"> "-fdebug-compilation-dir",</font></div><div><font face="courier new, monospace"> [[[ASPathHolder sharedHolder] tempFolder] UTF8String],</font></div><div><font face="courier new, monospace"> "-ferror-limit",</font></div><div><font face="courier new, monospace"> "19",</font></div><div><font face="courier new, monospace"> "-fmessage-length",</font></div><div><font face="courier new, monospace"> "0",</font></div></span><span class=""><div><font face="courier new, monospace"> "-stack-protector",</font></div><div><font face="courier new, monospace"> "1",</font></div><div><font face="courier new, monospace"> "-mstackrealign",</font></div></span><span class=""><div><font face="courier new, monospace"> "-fcxx-exceptions",</font></div><div><font face="courier new, monospace"> "-fexceptions",</font></div><div><font face="courier new, monospace"> "-fdiagnostics-show-option",</font></div><div><font face="courier new, monospace"> "-vectorize-slp",</font></div></span><span class=""><div><font face="courier new, monospace"> "-mfloat-abi",</font></div><div><font face="courier new, monospace"> "soft",</font></div><div><font face="courier new, monospace"> "-o",</font></div><div><font face="courier new, monospace"> [llFile UTF8String], // /private/var/mobile/Applications/175ECA7F-3175-4AC9-971C-85272F5492C4/tmp/hw.ll</font></div><div><font face="courier new, monospace"> "-x",</font></div><div><font face="courier new, monospace"> "c++",</font></div><div><font face="courier new, monospace"> [cppFile UTF8String] //"/private/var/mobile/Applications/175ECA7F-3175-4AC9-971C-85272F5492C4/tmp/hw.cpp"</font></div><div><font face="courier new, monospace"> };</font></div></span></div><div><br></div><div>and i'm getting the next .ll code (which seems to be pretty close or exactly the same as previous one):</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-m:o-i64:64-i128:128-n32:64-S128"</font></div><div><font face="courier new, monospace">target triple = "arm64-apple-ios7.0"</font></div><span class=""><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 8</font></div><div><font face="courier new, monospace"> %c = alloca i8*, align 8</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 8</font></div><div><font face="courier new, monospace"> store i8* getelementptr inbounds ([12 x i8]* @.str, i32 0, i32 0), i8** %c, align 8</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></span><div><font face="courier new, monospace">!0 = metadata !{metadata !"clang version 3.5.0 (tags/RELEASE_350/final 217949)"}</font></div></div><div><br></div><div>(Note changed triple and compiler version. Also note i'm not using "target-cpu" argument now as "cortex-a8" is not supported for this triple).</div><div><br></div><div>Next i'm trying to interpret it (source code is copy-pasted from lli tool source code):</div><div><br></div><div><div>// lli with my default arguments</div><div>int llvm_interpret(const char *ll_filename) {</div><div> std::string InputFile(ll_filename);</div><div><br></div><div> return llvm_interpret(</div><div> InputFile,</div><div> std::vector<std::string>(), // argv</div><span class=""><div> false, // ForceInterpreter</div><div> false, // UseMCJIT</div></span><span class=""><div> false, // DebugIR</div><div> false, // RemoteMCJIT</div></span><div> "", // ChildExecPath</div><div> ' ', // OptLevel</div><div> std::string("arm64-apple-ios7.0"), // TargetTriple</div><div> std::string("arm64"), // MArch</div><div> std::string(), // MCPU</div><span class=""><div> std::vector<std::string>(), // MAttrs</div><div> "main", // EntryFunc</div></span><div> std::vector<std::string>(), // ExtraModules</div><div> std::vector<std::string>(), // ExtraObjects</div><div> std::vector<std::string>(), // ExtraArchives</div><div> false, // EnableCacheManager</div><div> std::string(), // ObjectCacheDir</div><span class=""><div> std::string(), // FakeArgv0</div><div> false, // DisableCoreFiles</div><div> false, // NoLazyCompilation</div><div> Reloc::PIC_, // RelocModel</div><div> CodeModel::JITDefault, // CMModel</div><div> true, // GenerateSoftFloatCalls</div><div> FloatABI::Soft, // FloatABIForCalls</div><div> false, // EmitJitDebugInfo</div></span><div> false // EmitJitDebugInfoToDisk</div><div> );</div></div><div><br></div><div>I'm getting the next error text:</div><div><b>error creating EE: target does not support JIT code generation</b><br></div><div><br></div><div>Ok, let's try using MCJIT as i was suggested.</div><div>Now change default value for "UseMCJIT" to true.</div><div><br></div><div>Then i have <b>EXC_BAD_ACCESS (code=260, address=0xd10083ff)</b> in</div><div>ExecutionEngine.cpp file:</div><div>
<p><font face="courier new, monospace"><span>return</span> runFunction(Fn, GVArgs).IntVal.getZExtValue();</font></p><p><font face="arial, helvetica, sans-serif">Tim? Anyone? I can provide source code and build scripts to reproduce the case.</font></p><p><font face="arial, helvetica, sans-serif">Regards, Anton.</font></p></div></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">2014-09-17 19:02 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"><div>Both Clang/LLVM 3.4 -> Clang/LLVM 3.5<br></div><div>And i will also try using MCJIT.</div></div><div><div><div class="gmail_extra"><br><div class="gmail_quote">2014-09-17 18: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, Tim.<div><br></div><div>I've used Clang 3.4 final release and now i'm going to test it with 3.5 release (since i've read about arm64 improvements).</div><div>I will report my results.</div><div><br></div><div>BTW, is it possible to get smth like "hello world" output even with apple restrictions?</div><div><br></div><div>Regards, Anton.</div></div><div><div><div class="gmail_extra"><br><div class="gmail_quote">2014-09-17 18:42 GMT+06:00 Tim Northover <span dir="ltr"><<a href="mailto:t.p.northover@gmail.com" target="_blank">t.p.northover@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Anton,<br>
<br>
I've added the llvmdev list, since the issues you're seeing are coming<br>
from the backend, which is more their side.<br>
<span><br>
On 17 September 2014 08:43, Anton Smirnov <<a href="mailto:dev@antonsmirnov.name" target="_blank">dev@antonsmirnov.name</a>> wrote:<br>
> i've changed lli arguments to the next (instead of default):<br>
><br>
> return llvm_interpret(<br>
> InputFile,<br>
> std::vector<std::string>(),<br>
> false, // ForceInterpreter<br>
> false, // UseMCJIT<br>
</span>> [...]<br>
<span>> Now i'm having:<br>
><br>
> Unhandled instruction encoding format!<br>
> UNREACHABLE executed at<br>
> /Users/asmirnov/Documents/dev/src/llvm_34_ios/lib/Target/ARM/ARMCodeEmitter.cpp:547!<br>
<br>
</span>This one at least is understandable. Your options imply (I couldn't<br>
find any "llvm_interpret" function, so there's some guesswork) that<br>
you're using the old JIT. That's been discouraged for a while, and<br>
it's been removed completely now in trunk.<br>
<br>
It's entirely possible it could randomly fall over (not all<br>
instructions are supported), and probably not even worth worrying<br>
about why. I'd just flip that "UseMCJIT" option.<br>
<br>
The interpreter failure you were seeing earlier is harder to explain<br>
(there are various options), but if we're lucky it won't happen in<br>
MCJIT mode. Then we don't have to worry about that one either.<br>
<br>
Cheers.<br>
<span><font color="#888888"><br>
Tim.<br>
</font></span></blockquote></div><br></div>
</div></div></blockquote></div><br></div>
</div></div></blockquote></div><br></div>
</div></div></blockquote></div><br></div>