Skip to content

Commit

Permalink
fixed ADDri to ADDmi
Browse files Browse the repository at this point in the history
  • Loading branch information
KrYackI committed May 19, 2024
1 parent 86aff78 commit 4320e44
Show file tree
Hide file tree
Showing 2 changed files with 118 additions and 115 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,19 @@ class X86KruglovCntPass : public MachineFunctionPass {
X86KruglovCntPass() : MachineFunctionPass(ID) {}

bool runOnMachineFunction(MachineFunction &MF) override {
// Get the global variable 'ic'
auto *GV = MF.getFunction().getParent()->getNamedGlobal("ic");
if (!GV) {
// If 'ic' does not exist, create it
LLVMContext &context = MF.getFunction().getParent()->getContext();
GV = new GlobalVariable(*MF.getFunction().getParent(),
IntegerType::get(context, 64), false,
GlobalValue::ExternalLinkage, nullptr, "ic");
GV->setAlignment(Align(8));
// If the global variable 'ic' cannot be created, return false
if (!GV) {
LLVMContext &context = MF.getFunction().getParent()->getContext();
GV = new GlobalVariable(*MF.getFunction().getParent(),
IntegerType::get(context, 64), false,
GlobalValue::ExternalLinkage, nullptr, "ic");
GV->setAlignment(Align(8));
if (!GV) {
return false;
}
}
}
DebugLoc DebugLocation = MF.front().begin()->getDebugLoc();
const TargetInstrInfo *InstrInfo = MF.getSubtarget().getInstrInfo();

for (auto &MBB : MF) {
BuildMI(MBB, MBB.getFirstTerminator(), DebugLocation,
InstrInfo->get(X86::ADD64mi32))
Expand All @@ -40,13 +36,6 @@ class X86KruglovCntPass : public MachineFunctionPass {
.addGlobalAddress(GV)
.addReg(0)
.addImm(MBB.size());

// if (!MBB.isReturnBlock())
// continue;
// BuildMI(MBB, MBB.getFirstTerminator(), DebugLocation,
// InstrInfo->get(X86::MOV64mr))
// .addImm(MBB.size())
// .addGlobalAddress(GV);
}
return true;
}
Expand Down
Loading

0 comments on commit 4320e44

Please sign in to comment.