-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[RISCV] Support --symbolize-operands #166656
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| # RUN: llvm-mc -triple=riscv32 < %s -mattr=-relax -filetype=obj -o - \ | ||
| # RUN: | llvm-objdump -d --no-leading-addr --no-show-raw-insn --symbolize-operands - \ | ||
| # RUN: | FileCheck %s | ||
|
|
||
| # CHECK-LABEL: <.text>: | ||
| .text | ||
| .p2align 2 | ||
| # CHECK: blez a0, <L3> | ||
| blez a0, .LBB0_6 | ||
| li a3, 0 | ||
| li a2, 0 | ||
| # CHECK: j <L1> | ||
| j .LBB0_3 | ||
|
Comment on lines
+12
to
+13
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @arichardson this includes a
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh I missed that one, so looks like we do handle jalr (at least for local symbols?). Could add another one calling a non-local symbol? |
||
| # CHECK-NEXT: <L0>: | ||
| .LBB0_2: | ||
| addi a3, a3, 1 | ||
| # CHECK: beq a3, a0, <L4> | ||
| beq a3, a0, .LBB0_7 | ||
| # CHECK-NEXT: <L1>: | ||
| .LBB0_3: | ||
| slli a4, a3, 2 | ||
| add a4, a1, a4 | ||
| lw a5, 0(a4) | ||
| lbu a4, 0(a5) | ||
| # CHECK: beqz a4, <L0> | ||
| beqz a4, .LBB0_2 | ||
| addi a5, a5, 1 | ||
| # CHECK: <L2> | ||
| .LBB0_5: | ||
| add a2, a2, a4 | ||
| lbu a4, 0(a5) | ||
| addi a5, a5, 1 | ||
| # CHECK: bnez a4, <L2> | ||
| bnez a4, .LBB0_5 | ||
| # CHECK-NEXT: j <L0> | ||
| j .LBB0_2 | ||
| # CHECK-NEXT: <L3>: | ||
| .LBB0_6: | ||
| li a2, 0 | ||
| # CHECK: <L4>: | ||
| .LBB0_7: | ||
| mv a0, a2 | ||
| ret | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this currently only support branches or also instructions like jalr/ld?
Would be good to add a test showing how those behave as well. And maybe one test case where symbolization fails? something like
blez a0, 0x123?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Based on the diff below it looks like this only affects branches, but I think it might still be good to have something like
in the test?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't yet have support for
addi/loads/stores, as far as I understand. That is in #144620.I will look at the cases where symbolization might fail, but I'm not sure they're covered well in other architectures either. LLVM would interpret
blez a0, 0x122(0x123is not encodable) as a branch topc+0x122, which it might still create a symbol for even if it's not dumped for that function, so I don't know what the answer is there.I will try some cases, but I think the "don't print the number" signal doesn't depend on whether something symbolized correctly, which might be good or bad.
I also don't mind if we print both the number and the symbol - it does make it harder to diff the output, but post-processing is normally needed before a dump can be diffed well anyway.