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

Provide provenance info for llvm::Uses #246

Merged
merged 16 commits into from
Mar 29, 2022
Merged

Conversation

frabert
Copy link
Collaborator

@frabert frabert commented Mar 23, 2022

Also fixes #194 and #205

@frabert
Copy link
Collaborator Author

frabert commented Mar 24, 2022

Needs #247 to pass AnghaBench

@frabert frabert linked an issue Mar 25, 2022 that may be closed by this pull request
@frabert frabert marked this pull request as ready for review March 26, 2022 10:07
Copy link
Contributor

@surovic surovic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally looks okay and I get what you're trying to do with the "SSAification" of the AST.

What I have qualms about is the mingling of "IR-to-C translation code" and "structurization code". IRToASTVisitor.(h|cpp) was meant to be the place where the IR translation code lived. GenerateAST.(h|cpp) was for structurization. The BlockVisitor class I think breaks this distinction. Personally, I would like for this kind of distinction to exist. One reason, because it makes it easy to reference the No More Gotos paper back and forth. Another reason is purely for conceptual partitioning of the code.

The distinctions don't have to be "translation" and "structurization". If you can come up and describe (optionally document) the conceptual distinctions and they make sense, anything is fine by me.

lib/AST/GenerateAST.cpp Outdated Show resolved Hide resolved
include/rellic/AST/Util.h Outdated Show resolved Hide resolved
lib/AST/GenerateAST.cpp Outdated Show resolved Hide resolved
lib/AST/GenerateAST.cpp Outdated Show resolved Hide resolved
lib/AST/GenerateAST.cpp Outdated Show resolved Hide resolved
lib/AST/GenerateAST.cpp Outdated Show resolved Hide resolved
lib/AST/IRToASTVisitor.cpp Outdated Show resolved Hide resolved
lib/AST/IRToASTVisitor.cpp Outdated Show resolved Hide resolved
lib/AST/GenerateAST.cpp Outdated Show resolved Hide resolved
lib/AST/GenerateAST.cpp Outdated Show resolved Hide resolved
@frabert
Copy link
Collaborator Author

frabert commented Mar 29, 2022

I've put BlockVisitor in its own header/file, and added a comment on top of it describing how it relates to IRToASTVisitor

Copy link
Contributor

@surovic surovic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As much as I don't like to bloat up IRToASTVisitor.(h|cpp) I think it makes most sense to put BlockVisitor there. Maybe even move clang::Expr *visitXYZ methods into a separate class, named something like ExprGen. Move clang::Stmt *visitXYZ methods from BlockVisitor into StmtGen. And finally make the IRToASTVisitor class use both. The logic from BlockVisitor::visitBasicBlock could be put into a StmtVec IRToASTVisitor::CreateBasicBlockStmts(llvm::BasicBlock&) or similar. What do you think?

include/rellic/AST/IRToASTVisitor.h Outdated Show resolved Hide resolved
lib/AST/IRToASTVisitor.cpp Outdated Show resolved Hide resolved
ExprGen(clang::ASTUnit &unit, Provenance &provenance)
: ast_ctx(unit.getASTContext()), ast(unit), provenance(provenance) {}

clang::QualType GetQualType(llvm::Type *type) {
Copy link
Contributor

@surovic surovic Mar 29, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we factor out method bodies like GetQualType out of the class declaration? Again, no other but for consistency and/or neatness's sake. This concerns both ExprGen and StmtGen. I promise this is the last piece of annoyance 👀

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean making them static or separating all the declarations of ExprGen and StmtGen from their definitions?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just separating. The class declarations would only have method declarations and outside of the class declaration, you would have the definitions, i.e. clang::Expr *ExprGen::visitBinaryOperator(llvm::Instruction &inst) {...}.

@frabert
Copy link
Collaborator Author

frabert commented Mar 29, 2022

Had to put VisitGlobalVar inside ExprGen so that when recursively visiting the initializers for global variables we "automagically" get topologically sorted declarations

@surovic
Copy link
Contributor

surovic commented Mar 29, 2022

Had to put VisitGlobalVar inside ExprGen so that when recursively visiting the initializers for global variables we "automagically" get topologically sorted declarations

Neat! Think we can merge?

@frabert
Copy link
Collaborator Author

frabert commented Mar 29, 2022

Yep, tests are passing!

@frabert frabert merged commit 76beb1f into master Mar 29, 2022
@frabert frabert deleted the frabert/uses-provenance branch March 29, 2022 17:57
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.

Unsound condition transformation Double call when decompiling optimized bitcode?
3 participants