我得到"无效字段'子程序'"解析Rust生成的LLVM-IR时。它立即发生在!0
。
用于解析的代码:
MemoryBuffer* buf = MemoryBuffer::getMemBuffer(StringRef(fC)).release();
SMDiagnostic err;
LLVMContext *Context=new LLVMContext();
Module* module = parseIR(buf->getMemBufferRef(), err, *Context).release();
if(!module){
NSString* errorMsg=[NSString stringWithFormat:@"%@ at line:%@ col:%@\n>>%@",[NSString stringWithCString:err.getMessage().str().c_str() encoding:NSUTF8StringEncoding], @(err.getLineNo()), @(err.getColumnNo()), [NSString stringWithCString:err.getLineContents().str().c_str() encoding:NSUTF8StringEncoding]];
NSError* error=[[NSError alloc] initWithDomain:errorMsg code:-1 userInfo:nil];
//Deal with NSError later
}
DebugInfoFinder* dif = new DebugInfoFinder();
dif->processModule(*module);
发生的地方:
!0 = distinct !DICompileUnit(language: 36864, file: !1, producer: "rustc version 1.7.0 (a5d1e7a59 2016-02-29)", isOptimized: true, runtimeVersion: 0, emissionKind: 1, enums: !2, retainedTypes: !10, subprograms: !29)
引用只是一个对子程序的引用数组,如预期的那样:
!29 = !{!30, !47, !55, !65, !77, !83, !92, !99, !113, !114}
!30 = !DISubprogram(name: "main", linkageName: "_ZN8fizzbuzz4mainE", scope: !32, file: !31, line: 3, type: !33, isLocal: true, isDefinition: true, scopeLine: 3, flags: DIFlagPrototyped, isOptimized: true, function: void ()* @_ZN4main20hbe8861d85740ed2deaaE, templateParams: !35, variables: !36)
我认为IR代码看起来不错;这可能是Rust使用的LLVM版本与llvm-ir解析代码段使用的版本之间的问题吗?