Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parse error for lines starting with carets #183

Closed
jeshan opened this issue May 27, 2021 · 4 comments
Closed

Parse error for lines starting with carets #183

jeshan opened this issue May 27, 2021 · 4 comments

Comments

@jeshan
Copy link

jeshan commented May 27, 2021

Not sure what the syntax means (or if we're tracking this issue elsewhere)

On calling the following file with asm.ParseString:

; ModuleID = 'crt1.o'
source_filename = "crt/crt1.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-alpine-linux-musl"

... trimmed

!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "Alpine clang version 10.0.1 ", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, retainedTypes: !3, splitDebugInlining: false, nameTableKind: None)
!1 = !DIFile(filename: "crt/crt1.c", directory: "/app/aports-3.13-stable/main/musl/src/v1.2.2")
... trimmed
!35 = !DILocation(line: 19, column: 1, scope: !13)

^0 = module: (path: "crt1.o", hash: (0, 0, 0, 0, 0))
^1 = gv: (name: "_init") ; guid = 3788571788581730100
^2 = gv: (name: "_fini") ; guid = 12847049297108431452
^3 = gv: (name: "_start_c", summaries: (function: (module: ^0, flags: (linkage: external, notEligibleToImport: 1, live: 0, dsoLocal: 1, canAutoHide: 0), insts: 18, funcFlags: (readNone: 0, readOnly: 0, noRecurse: 0, returnDoesNotAlias: 0, noInline: 1, alwaysInline: 0), calls: ((callee: ^5)), refs: (^6, ^1, ^2)))) ; guid = 12876309325424598481
^4 = gv: (name: "llvm.dbg.declare") ; guid = 13513223491971101989
^5 = gv: (name: "__libc_start_main") ; guid = 13749316503500873128
^6 = gv: (name: "main") ; guid = 15822663052811949562

I get an error that says:

unable to parse "crt1.o.ll" into an AST: syntax error at line 99

Full text in this gist: https://gist.github.com/jeshan/e81bfc8fc34d79b692416528486f68ce

If I remove the lines starting with carets, i.e all of these:

^0 = module: (path: "crt1.o", hash: (0, 0, 0, 0, 0))
^1 = gv: (name: "_init") ; guid = 3788571788581730100
^2 = gv: (name: "_fini") ; guid = 12847049297108431452
^3 = gv: (name: "_start_c", summaries: (function: (module: ^0, flags: (linkage: external, notEligibleToImport: 1, live: 0, dsoLocal: 1, canAutoHide: 0), insts: 18, funcFlags: (readNone: 0, readOnly: 0, noRecurse: 0, returnDoesNotAlias: 0, noInline: 1, alwaysInline: 0), calls: ((callee: ^5)), refs: (^6, ^1, ^2)))) ; guid = 12876309325424598481
^4 = gv: (name: "llvm.dbg.declare") ; guid = 13513223491971101989
^5 = gv: (name: "__libc_start_main") ; guid = 13749316503500873128
^6 = gv: (name: "main") ; guid = 15822663052811949562

Then the parsing completes.

@jeshan
Copy link
Author

jeshan commented May 27, 2021

Note that the file I mentioned was disassembled with llvm-dis version 10.0.0

@mewmew
Copy link
Member

mewmew commented May 27, 2021

Hi @jeshan,

Glad to see you exploring the world of LLVM IR :)

You've stumbled on module summaries, a concept introduced in LLVM quite some time ago. It is the only concept we know of (as of LLVM 11.0) which has not yet been covered by the grammar of llir/grammar, and is thus not yet implemented in llir/llvm.

For reference, this is covered by issue #43.

Should you feel up for the challenge, we warm heartedly welcome you to join us at the llir/llvm project. @dannypsnl has been working hard on updating llir/llvm to cover the new language features of LLVM. And module summaries is the last big chunk remaining.

If you want to join, just let us know and we'll send an invite to Discord where we can get you up to speed.

Wish you a happy summer and the best of hacking!
Cheers,
Robin

@mewmew
Copy link
Member

mewmew commented May 27, 2021

Marking this as duplicate of #43 for now, as they both refer to module summaries. Feel free to close this issue, and send us a ping if you feel like joining us on developing llir/llvm :)

@jeshan
Copy link
Author

jeshan commented May 27, 2021

Thanks, Robin.

It is the only concept we know of (as of LLVM 11.0) which has not yet been covered by the grammar

I'm glad you all have managed to get so much work done so far

if you feel like joining us on developing llir/llvm

That is definitely outside of my skill set!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants