-
Notifications
You must be signed in to change notification settings - Fork 54
Шульпин Илья. Лабораторная работа 2: LLVM. Вариант 3. #147
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
base: course-spring-2025
Are you sure you want to change the base?
Шульпин Илья. Лабораторная работа 2: LLVM. Вариант 3. #147
Conversation
for (auto It = BB.begin(), End = BB.end(); It != End;) { | ||
llvm::Instruction *I = &*It++; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use make_early_inc_range
for this iterating.
llvm::Instruction *I = &*It++; | ||
if (auto *BI = llvm::dyn_cast<llvm::BinaryOperator>(I)) { | ||
if (BI->getOpcode() == llvm::Instruction::Add) { | ||
if (addFunc && addFunc->arg_size() == 2) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please check addFunc
's arg_size
once before all loops.
auto argIt = addFunc->arg_begin(); | ||
llvm::Type *paramTy0 = argIt->getType(); | ||
++argIt; | ||
llvm::Type *paramTy1 = argIt->getType(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The same, add function arg types may be initialized before all loops. And if they are equal, one variable is enough.
; CHECK: %result = add i32 %a, %b | ||
; CHECK: ret i32 %result | ||
; CHECK-NOT: add i32 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, add testing for the cases when add
function is not present in LLVM IR module
Описание будет добавленно после зеленого CI