From 7b020b12baeeed096f6a9ac7ae8ea069a802969a Mon Sep 17 00:00:00 2001 From: Luke Lau Date: Tue, 18 Jun 2024 15:32:12 +0800 Subject: [PATCH 1/2] [Profile] Add CFG support for RISC-V The control transfer instructions are the same for both RV32 and RV64, so we only need one set of regexps. I think this covers all instructions and pseudo-instructions, although I'm not sure if all of them disassembled by objdump. --- lnt/server/ui/static/lnt_profile.js | 13 +++++++++++++ lnt/server/ui/templates/v4_profile.html | 1 + 2 files changed, 14 insertions(+) diff --git a/lnt/server/ui/static/lnt_profile.js b/lnt/server/ui/static/lnt_profile.js index 7e7ee8a9..b01b633e 100644 --- a/lnt/server/ui/static/lnt_profile.js +++ b/lnt/server/ui/static/lnt_profile.js @@ -100,6 +100,16 @@ InstructionSetParser.prototype = { // TODO: add all control-flow-changing instructions. ], + RISCVJumpTargetRegexps: [ + // (regexp, noFallThru?) + // branch conditional: + [new RegExp("^\\s*b[a-z]+\\s+.*(0x[0-9a-f]+)\\s+<.+>"), false], + // jumps: + [new RegExp("^\\s*(?:jal|j|call|tail)\\s+.+(0x[0-9a-f]+)\\s+<.+>"), true], + // indirect jumps: + [new RegExp("^\\s*(?:jalr|jr|ret)"), true] + ], + X86_64JumpTargetRegexps: [ // (regexp, noFallThru?) // branch conditional: @@ -513,6 +523,9 @@ Profile.prototype = { else if (this.instructionSet == 'aarch32t32') instructionParser = new InstructionSetParser( InstructionSetParser.prototype.AArch32T32JumpTargetRegexps); + if (this.instructionSet == 'riscv') + instructionParser = new InstructionSetParser( + InstructionSetParser.prototype.RISCVJumpTargetRegexps); else if (this.instructionSet == 'x86_64') instructionParser = new InstructionSetParser( InstructionSetParser.prototype.X86_64JumpTargetRegexps); diff --git a/lnt/server/ui/templates/v4_profile.html b/lnt/server/ui/templates/v4_profile.html index 43fc3f09..e4efb252 100644 --- a/lnt/server/ui/templates/v4_profile.html +++ b/lnt/server/ui/templates/v4_profile.html @@ -93,6 +93,7 @@

Performance profile: {{ test.name }} + From 10466ce478ce2bf93ffaff56568895bcade9af5e Mon Sep 17 00:00:00 2001 From: Luke Lau Date: Mon, 30 Sep 2024 19:37:09 +0800 Subject: [PATCH 2/2] Fix jump regexp quantifier --- lnt/server/ui/static/lnt_profile.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lnt/server/ui/static/lnt_profile.js b/lnt/server/ui/static/lnt_profile.js index b01b633e..6dee750d 100644 --- a/lnt/server/ui/static/lnt_profile.js +++ b/lnt/server/ui/static/lnt_profile.js @@ -105,7 +105,7 @@ InstructionSetParser.prototype = { // branch conditional: [new RegExp("^\\s*b[a-z]+\\s+.*(0x[0-9a-f]+)\\s+<.+>"), false], // jumps: - [new RegExp("^\\s*(?:jal|j|call|tail)\\s+.+(0x[0-9a-f]+)\\s+<.+>"), true], + [new RegExp("^\\s*(?:jal|j|call|tail)\\s+.*(0x[0-9a-f]+)\\s+<.+>"), true], // indirect jumps: [new RegExp("^\\s*(?:jalr|jr|ret)"), true] ],