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

Error when parsing SQLite 3.32.1 with Clang 10: Instruction code 56 is unknown #148

Closed
langston-barrett opened this issue Feb 20, 2021 · 3 comments · Fixed by #159
Closed

Comments

@langston-barrett
Copy link
Contributor

I see that Clang 10 is not yet listed in the README as supported, so this might be known but just wanted to raise it if not.

$ clang --version
clang version 10.0.1                             
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /nix/store/dgpd1y26p9vfs5j382cw6wyblsc0q3cl-clang-10.0.1/bin
      Exception: LLVMParseError (Error {errContext = ["@sqlite3_str_vappendf","FUNCTION_BLOCK","FUNCTION_BLOCK_ID","value symbol table","MODULE_BLOCK","Bitstream"], errMessage = "instruction code 56 is unknown"})

sqlite-3.32.1.bc.zip

@RyanGlScott
Copy link
Contributor

Instruction code 56 corresponds to the fneg instruction. Here is a simpler way to trigger it (using Clang 10.0.0-4ubuntu1):

double negate(double x) {
  return -x;
}

int main() {
  return 0;
}
$ crux-llvm test2.c
instruction code 56 is unknown
from:
        @negate
        FUNCTION_BLOCK
        FUNCTION_BLOCK_ID
        value symbol table
        MODULE_BLOCK
        Bitstream

@kquick
Copy link
Member

kquick commented Aug 19, 2021

See also issue #158 158. There is also active work being done on this by @Ptival .

RyanGlScott added a commit that referenced this issue Aug 20, 2021
This is sufficient to parse the SQLite test case mentioned in #148. I have
added a much more minimal test case which exercises the new `fneg`-related
code paths added in this patch.

Fixes #148.
@RyanGlScott
Copy link
Contributor

Luckily, fneg is the only missing piece needed to parse the original SQLite example. I have submitted #159 with a fix, which includes a more minimal test case.

elliottt pushed a commit to GaloisInc/llvm-pretty that referenced this issue Aug 22, 2021
* Support `fneg` instruction

Recent versions of LLVM represent floating-point negation with a dedicated
`fneg` instruction, as discovered in GaloisInc/llvm-pretty-bc-parser#148.
`fneg` is considered to be a unary operation, much like the `add`, `sub`, etc.
instructions are binary operations. As a result, rather than adding a dedicated
`fneg` instruction, I added a `UnaryArith` instruction, which acts like
(binary) `Arith` but with a single parameter. The `UnaryArithOp` data type,
then, only consists of `FNeg` for now, but there could be additional operations
in future versions of LLVM.

* Text.LLVM.PP: Whitespace only
RyanGlScott added a commit that referenced this issue Aug 23, 2021
This is sufficient to parse the SQLite test case mentioned in #148. I have
added a much more minimal test case which exercises the new `fneg`-related
code paths added in this patch.

Fixes #148.
RyanGlScott added a commit that referenced this issue Aug 23, 2021
This is sufficient to parse the SQLite test case mentioned in #148. I have
added a much more minimal test case which exercises the new `fneg`-related
code paths added in this patch.

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

Successfully merging a pull request may close this issue.

3 participants