Skip to content

Commit 23b1971

Browse files
authored
i#3544 RV64: Port client.flush to riscv64 (#7438)
Marking the interested basic block with one uncompressed NOP (4 bytes) and two compressed NOPs (2 x 2 bytes). This pattern should happen rarely in compiler-generated code, since two compressed NOPs could always be replaced with a compressed one. Issue: #3544
1 parent 24a7f15 commit 23b1971

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

suite/tests/CMakeLists.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2832,12 +2832,12 @@ if (NOT APPLE OR NOT AARCH64 AND NOT MUSL)
28322832
tobuild_ci(client.file_io client-interface/file_io.c
28332833
"${CMAKE_CURRENT_SOURCE_DIR}/client-interface/file_io_data.txt" "" "")
28342834
endif ()
2835-
if (X86 OR AARCH64) # FIXME i#1551: port asm to ARM
2835+
if (X86 OR AARCH64 OR RISCV64) # FIXME i#1551: port asm to ARM
28362836
if (DEBUG) # FIXME i#1806: fails in release; also in OSX list below.
28372837
# we add custom option to flush test based on dr ops in torun_ci()
28382838
tobuild_ci(client.flush client-interface/flush.c "" "" "")
28392839
endif ()
2840-
endif (X86 OR AARCH64)
2840+
endif (X86 OR AARCH64 OR RISCV64)
28412841
if (X86 OR AARCH64) # FIXME i#1551: port asm to ARM
28422842
tobuild_ci(client.strace client-interface/strace.c "" "" "")
28432843
use_DynamoRIO_extension(client.strace.dll drmgr)
@@ -6674,6 +6674,7 @@ if (RISCV64)
66746674
code_api|client.crashmsg
66756675
code_api|client.drwrap-test-callconv
66766676
code_api|client.execfault
6677+
code_api|client.flush
66776678
code_api|client.mangle_suspend
66786679
code_api|client.null_instrument
66796680
code_api|client.option_parse

suite/tests/client-interface/flush.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,13 @@ GLOBAL_LABEL(marker:)
8383
yield
8484
yield
8585
ret
86+
#elif defined (RISCV64)
87+
nop
88+
.option arch, +c
89+
c.nop
90+
c.nop
91+
.option arch, -c
92+
ret
8693
#endif
8794
END_FUNC(marker)
8895
END_FILE

suite/tests/client-interface/flush.dll.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,14 @@ check_for_marker(instr_t *first_inst)
263263
if (third != NULL && instr_get_opcode(third) == OP_yield)
264264
return true;
265265
}
266+
#elif defined(RISCV64)
267+
/* For RISCV64 look for an uncompressed nop followed by two compressed
268+
* ones */
269+
if (instr_get_opcode(second) == OP_c_nop) {
270+
instr_t *third = instr_get_next(second);
271+
if (third != NULL && instr_get_opcode(third) == OP_c_nop)
272+
return true;
273+
}
266274
#endif
267275
}
268276
}

0 commit comments

Comments
 (0)