Skip to content

Commit 9fa9f82

Browse files
committed
opt(compile): allow aggressive inline
this allows get_effective_address() and isa_mmu_check() to be inlined. this improves about 10% of speed on zen4
1 parent c627904 commit 9fa9f82

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

Makefile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,12 @@ CFLAGS_BUILD += $(call remove_quote,$(CONFIG_CC_OPT))
8585
CFLAGS_BUILD += $(if $(CONFIG_CC_LTO),-flto=auto,)
8686
CFLAGS_BUILD += $(if $(CONFIG_CC_DEBUG),-ggdb3,)
8787
CFLAGS_BUILD += $(if $(CONFIG_CC_ASAN),-fsanitize=address,)
88+
89+
# Fine-tuned compiler options
90+
ifeq ($(CC), gcc)
91+
CFLAGS_BUILD += --param max-inline-insns-single=256 -falign-labels=32:9:64:15
92+
endif
93+
8894
CFLAGS += $(CFLAGS_BUILD)
8995
LDFLAGS += $(CFLAGS_BUILD)
9096

src/isa/riscv64/system/mmu.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ static inline bool check_permission(PTE *pte, bool ok, vaddr_t vaddr, int type)
145145
}
146146

147147
#ifndef CONFIG_RVH
148-
vaddr_t get_effective_address(vaddr_t vaddr, int type) {
148+
inline vaddr_t get_effective_address(vaddr_t vaddr, int type) {
149149
return vaddr;
150150
}
151151
#endif
@@ -183,7 +183,7 @@ void raise_guest_excep(paddr_t gpaddr, vaddr_t vaddr, int type, bool is_support_
183183
longjmp_exception(ex);
184184
}
185185

186-
vaddr_t get_effective_address(vaddr_t vaddr, int type) {
186+
inline vaddr_t get_effective_address(vaddr_t vaddr, int type) {
187187
if (type == MEM_TYPE_IFETCH || hlvx) {
188188
return vaddr;
189189
}
@@ -540,7 +540,7 @@ int update_mmu_state() {
540540

541541
void isa_misalign_data_addr_check(vaddr_t vaddr, int len, int type);
542542

543-
int isa_mmu_check(vaddr_t vaddr, int len, int type) {
543+
inline int isa_mmu_check(vaddr_t vaddr, int len, int type) {
544544
Logtr("MMU checking addr %lx", vaddr);
545545
bool is_ifetch = type == MEM_TYPE_IFETCH;
546546

0 commit comments

Comments
 (0)