<div dir="ltr"><div>Thanks Slava, Joe, and Jordan.<br><br></div><div>With -frontend flag, I was able to parse classdecl.sil.<br></div><div>However,
I still have a problem with another very simple Swift source code which
declares a value initialized with an integer literal.<br><br></div><div>I
am wondering if it is possible to compile some non-trivial Swift code
to SIL and parse the SIL to an executable, we can quickly evaluate our
ideas without serious implementation. I appreciate your comment on the
planned capability and current status of parsing SIL instead of Swift
source code.<br><br></div><div>Thanks,<br></div><div>Mikio Takeuchi<br></div><span class="im"><br>$ cat classdecl.swift<br>class MyObject { }<br></span>$ swiftc -frontend -emit-silgen classdecl.swift > classdecl.sil<br>$ swiftc -parse-sil classdecl.sil<br>$ cat const.swift<br>let sz = 10000<br>$ swiftc -frontend -emit-silgen const.swift > const.sil<br>$ swiftc -parse-sil const.sil<br>Cannot construct Inlined loc from the given location.<br>UNREACHABLE executed at /Users/buildnode/jenkins/workspace/oss-swift-package-osx/swift/lib/SIL/SILLocation.cpp:211!<br>0 swift 0x000000010406d00b llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 43<br>1 swift 0x000000010406c256 llvm::sys::RunSignalHandlers() + 70<br>2 swift 0x000000010406d75f SignalHandler(int) + 383<br>3 libsystem_platform.dylib 0x00007fff9783352a _sigtramp + 26<br>4 libsystem_platform.dylib 0x00007fff642aeac5 _sigtramp + 3433543093<br>5 swift 0x000000010406d4ae abort + 14<br>6 swift 0x000000010400ce77 llvm::llvm_unreachable_internal(char const*, char const*, unsigned int) + 471<br>7 swift 0x0000000101953cdb swift::MandatoryInlinedLocation::getMandatoryInlinedLocation(swift::SILLocation) + 315<br>8 swift 0x00000001016e69ad swift::SILInliner::inlineFunction(swift::FullApplySite, llvm::ArrayRef<swift::SILValue>) + 429<br>9 swift 0x000000010174b4f0 runOnFunctionRecursively(swift::SILFunction*, swift::FullApplySite, swift::SILOptions::LinkingMode, llvm::DenseSet<swift::SILFunction*, llvm::DenseMapInfo<swift::SILFunction*> >&, llvm::ImmutableSet<swift::SILFunction*, llvm::ImutContainerInfo<swift::SILFunction*> >::Factory&, llvm::ImmutableSet<swift::SILFunction*, llvm::ImutContainerInfo<swift::SILFunction*> >, swift::ClassHierarchyAnalysis*) + 3504<br>10 swift 0x000000010174a573 (anonymous namespace)::MandatoryInlining::run() + 419<br>11 swift 0x000000010170025b swift::SILPassManager::runModulePass(swift::SILModuleTransform*) + 1067<br>12 swift 0x0000000101700c63 swift::SILPassManager::runOneIteration() + 1043<br>13 swift 0x00000001017011d3 swift::SILPassManager::run() + 1235<br>14 swift 0x000000010170a8aa swift::runSILDiagnosticPasses(swift::SILModule&) + 314<br>15 swift 0x000000010140793c performCompile(swift::CompilerInstance&,
swift::CompilerInvocation&, llvm::ArrayRef<char const*>,
int&, swift::FrontendObserver*) + 13324<br>16 swift 0x000000010140329f swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 2895<br>17 swift 0x00000001013c5de0 main + 2448<br>18 libdyld.dylib 0x00007fff9a1a95ad start + 1<br>19 libdyld.dylib 0x000000000000000e start + 1709533794<br>Stack dump:<br>0. Program arguments: /Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2016-06-20-a.xctoolchain/usr/bin/swift
-frontend -c -primary-file const.sil -target x86_64-apple-macosx10.9
-enable-objc-interop -color-diagnostics -parse-sil -module-name const -o
/var/folders/_p/g_rb2m816p18wr5145r762qm0000gn/T/const-1efc86.o<br>1. While running SILModuleTransform "Mandatory Inlining".<br><unknown>:0: error: unable to execute command: Illegal instruction: 4<br><unknown>:0: error: compile command failed due to signal (use -v to see invocation)<br>$<div class="gmail_extra"><br><div class="gmail_quote">2016-06-22 6:25 GMT+09:00 Jordan Rose via swift-dev <span dir="ltr"><<a href="mailto:swift-dev@swift.org" target="_blank">swift-dev@swift.org</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class=""><br>
> On Jun 21, 2016, at 14:10, Joe Groff via swift-dev <<a href="mailto:swift-dev@swift.org">swift-dev@swift.org</a>> wrote:<br>
><br>
><br>
>> On Jun 21, 2016, at 2:03 PM, Slava Pestov via swift-dev <<a href="mailto:swift-dev@swift.org">swift-dev@swift.org</a>> wrote:<br>
>><br>
>> Hi Mikio,<br>
>><br>
>> Try this:<br>
>><br>
>> swiftc -frontend -emit-silgen classdecl.swift > classdecl.sil<br>
>> swiftc -parse-sil classdecl.sil<br>
>><br>
>> I'm not sure why -emit-silgen sometimes emits type declarations and other times not. The only difference I can see is what without the -frontend flag, the driver passes in -primary-file, whereas with -frontend, it does not.<br>
>><br>
>> Perhaps Joe or Jordan can chime in.<br>
><br>
> This is clearly a bug, but SIL's parser and printer quality generally doesn't have much pressure on it beyond what's minimally necessary to enable optimizer and codegen debugging.<br>
<br>
</span>We don't try to print ASTs when -primary-file is passed because it would mean merging ASTs from different files, which isn't going to be correct in the presence of 'private'.<br>
<span class="HOEnZb"><font color="#888888"><br>
Jordan<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
_______________________________________________<br>
swift-dev mailing list<br>
<a href="mailto:swift-dev@swift.org">swift-dev@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-dev" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-dev</a><br>
</div></div></blockquote></div><br></div></div>