Skip to content

Commit 76f040b

Browse files
committed
[BOLT] Provide generic implementations for isLoad/isStore
`MCInstrDesc` provides the `mayLoad` and `mayStore` flags that seem appropriate to use as a target-independent way to implement `isLoad` and `isStore`. I believe this is currently good enough to use for the RISC-V target as well. I've provided a test for this that checks the generated dyno stats (which seems to be the only thing both `isLoad` and `isStore` are used for). Reviewed By: maksfb Differential Revision: https://reviews.llvm.org/D159266
1 parent 9f53354 commit 76f040b

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

bolt/include/bolt/Core/MCPlusBuilder.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -614,13 +614,11 @@ class MCPlusBuilder {
614614
virtual bool isMoveMem2Reg(const MCInst &Inst) const { return false; }
615615

616616
virtual bool isLoad(const MCInst &Inst) const {
617-
llvm_unreachable("not implemented");
618-
return false;
617+
return Info->get(Inst.getOpcode()).mayLoad();
619618
}
620619

621620
virtual bool isStore(const MCInst &Inst) const {
622-
llvm_unreachable("not implemented");
623-
return false;
621+
return Info->get(Inst.getOpcode()).mayStore();
624622
}
625623

626624
virtual bool isCleanRegXOR(const MCInst &Inst) const {

bolt/test/RISCV/load-store.s

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// RUN: %clang %cflags -o %t %s
2+
// RUN: link_fdata --no-lbr %s %t %t.fdata
3+
// RUN: llvm-bolt %t -o /dev/null --data=%t.fdata --dyno-stats | FileCheck %s
4+
5+
// CHECK: BOLT-INFO: program-wide dynostats after all optimizations before SCTC and FOP (no change):
6+
// CHECK: 3000 : executed instructions
7+
// CHECK: 1000 : executed load instructions
8+
// CHECK: 1000 : executed store instructions
9+
10+
.globl _start
11+
_start:
12+
# FDATA: 1 _start #_start# 1
13+
ld t0, (gp)
14+
sd t0, (gp)
15+
ret
16+
.size _start, .-_start

0 commit comments

Comments
 (0)