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

Clean up treatment of fast-math flags during parsing #161

Merged
merged 1 commit into from
Sep 16, 2021
Merged

Conversation

RyanGlScott
Copy link
Contributor

Currently, llvm-pretty-bc-parser skips over fast-math flags when parsing. However, it was doing so incorrectly when parsing FUNC_CODE_INST_CMP2 (i.e., fcmp instructions). Per the LLVM source code here, the fast-math flags are expected to come after all of the other fields, but the code in llvm-pretty-bc-parser was assuming that they would appear in the middle. See #158.

I addresses this issue by parsing all of the other fields upfront and avoiding parsing the last part, which correspond to fast-math flags. While I was in town, I also made sure to add comments in every other place in the parser where we avoid parsing fast-math flags.

@RyanGlScott
Copy link
Contributor Author

RyanGlScott commented Sep 2, 2021

@kquick, can you verify if this PR is sufficient to allow your PX4_Autopilot example from #158 (comment) to be parsed? It works for my (probably much smaller) test case, so I'm curious if that's enough to make your larger example work as well.

@atomb
Copy link
Contributor

atomb commented Sep 14, 2021

I'm happy with this if it solves #158, but I think @kquick is the best person to check whether or not it does.

Currently, `llvm-pretty-bc-parser` skips over fast-math flags when parsing.
However, it was doing so incorrectly when parsing `FUNC_CODE_INST_CMP2` (i.e.,
`fcmp` instructions). Per the LLVM source code
[here](https://github.com/llvm/llvm-project/blob/b0391dfc737ede147e128fe877045f61fc5e4905/llvm/lib/Bitcode/Reader/BitcodeReader.cpp#L4342-L4377),
the fast-math flags are expected to come after all of the other fields, but the
code in `llvm-pretty-bc-parser` was assuming that they would appear in the
middle. See #158.

I addresses this issue by parsing all of the other fields upfront and avoiding
parsing the last part, which correspond to fast-math flags. While I was in
town, I also made sure to add comments in every other place in the parser where
we avoid parsing fast-math flags.
@RyanGlScott
Copy link
Contributor Author

I'd try to check the PX4-Autopilot code myself, but I can't even figure out how to build that repo with clang.

@RyanGlScott
Copy link
Contributor Author

In any case, this definitely fixes the bugs in #158 (comment) and #158 (comment), which are cropping up in SV-COMP benchmarks. In light of this, I'm going to go ahead and merge this. I'll leave #158 open as a reminder to check PX4_Autopilot.

@RyanGlScott RyanGlScott merged commit 24dc69a into master Sep 16, 2021
@RyanGlScott RyanGlScott deleted the T158 branch September 16, 2021 13:10
RyanGlScott added a commit to GaloisInc/crucible that referenced this pull request Sep 16, 2021
This bumps the `llvm-pretty` and `llvm-pretty-bc-parser` submodules to include
the following changes:

* GaloisInc/llvm-pretty#85 and GaloisInc/llvm-pretty-bc-parser#166, which adds
  support for the `freeze` instruction introduced in LLVM 12.
* GaloisInc/llvm-pretty#84 and GaloisInc/llvm-pretty-bc-parser#164, which allows
  parsing `DIEnumerator`s on LLVM 12 or later.
* GaloisInc/llvm-pretty#83 and GaloisInc/llvm-pretty-bc-parser#162, which allows
  parsing `DICompositeType`s on LLVM 12 or later.
* GaloisInc/llvm-pretty-bc-parser#161, which allows parsing `fcmp` instructions
  with fast-math flags.

The `freeze` instruction will require some changes in `crucible-llvm` to
accommodate, but I will do that in a subsequent commit.
@RyanGlScott RyanGlScott mentioned this pull request Oct 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants