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

DISubprogram incorrectly parses spFlags on LLVM 8.0+ #211

Closed
RyanGlScott opened this issue Mar 24, 2023 · 0 comments
Closed

DISubprogram incorrectly parses spFlags on LLVM 8.0+ #211

RyanGlScott opened this issue Mar 24, 2023 · 0 comments

Comments

@RyanGlScott
Copy link
Contributor

#137 adapted to changes in the (rather roundabout) way DISubprogram's spFlags field is parsed, which was introduced in LLVM 8.0 (see llvm/llvm-project@adcdc1b). Unfortunately, there is a key mistake in this part of the code:

(diFlags0, spFlags0) <-
if hasSPFlags then
(,) <$> parseField r (11 + 2) numeric <*> pure 0
else
(,) <$> parseField r 11 numeric <*> parseField r 9 numeric

Compare this to the corresponding LLVM code:

    DISubprogram::DISPFlags SPFlags =
        HasSPFlags
            ? static_cast<DISubprogram::DISPFlags>(Record[9])
            : DISubprogram::toSPFlags(
                  /*IsLocalToUnit=*/Record[7], /*IsDefinition=*/Record[8],
                  /*IsOptimized=*/Record[14], /*Virtuality=*/Record[11]);

The llvm-pretty-bc-parser code reverses the order of cases! The LLVM code parses Record[9] if HasSPFlags is true, but in the llvm-pretty-bc-parser code, it's the other way around. This manifests itself by always having the various spFlags fields (e.g., isDefinition) always be set to 0 whenever hasSPFlags is set.

RyanGlScott added a commit that referenced this issue Mar 26, 2023
This corrects an inadvertent mistake introduced in #137 where the order of
cases was reversed.

Fixes #211.
RyanGlScott added a commit that referenced this issue Mar 27, 2023
This corrects an inadvertent mistake introduced in #137 where the order of
cases was reversed.

Fixes #211.
RyanGlScott added a commit that referenced this issue Mar 27, 2023
This corrects an inadvertent mistake introduced in #137 where the order of
cases was reversed.

Fixes #211.
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

1 participant