Skip to content

Commit

Permalink
asm mode: remove calls to llvm.sideeffect in src since asm doesn't ha…
Browse files Browse the repository at this point in the history
…ve those
  • Loading branch information
nunoplopes committed Dec 14, 2023
1 parent 65e98d2 commit 2c53cb3
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions tools/transform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1624,6 +1624,7 @@ void Transform::preprocess() {
// all memory blocks are considered to have a size multiple of alignment
// since asm memory accesses won't trap as it won't cross the page boundary
vector<pair<const Instr*, unique_ptr<Instr>>> to_add;
vector<Instr*> to_remove;
for (auto &bb : src.getBBs()) {
for (auto &i : bb->instrs()) {
if (auto *load = dynamic_cast<const Load*>(&i)) {
Expand All @@ -1636,12 +1637,20 @@ void Transform::preprocess() {
Assume::Dereferenceable));
src.addConstant(std::move(bytes));
}
} else if (auto *call = dynamic_cast<const FnCall*>(&i)) {
if (call->getFnName() == "#sideeffect") {
to_remove.emplace_back(const_cast<Instr*>(&i));
}
}
}
for (auto &[i, assume] : to_add) {
bb->addInstrAt(std::move(assume), i, false);
}
for (auto &i : to_remove) {
bb->delInstr(i);
}
to_add.clear();
to_remove.clear();
}
}

Expand Down

0 comments on commit 2c53cb3

Please sign in to comment.