This is an archive of the discontinued LLVM Phabricator instance.

[OMPT][test] Fix mismatch error between the current address and the return address for LoongArch
ClosedPublic

Authored by Ami-zhang on Nov 28 2022, 3:22 AM.

Diff Detail

Event Timeline

Ami-zhang created this revision.Nov 28 2022, 3:22 AM
Herald added a project: Restricted Project. · View Herald TranscriptNov 28 2022, 3:22 AM
Herald added a subscriber: StephenFan. · View Herald Transcript
Ami-zhang requested review of this revision.Nov 28 2022, 3:22 AM
Herald added a project: Restricted Project. · View Herald TranscriptNov 28 2022, 3:22 AM

Your change only allows offsets of 8 and 12 byte. But the comment indicates that 4 byte offset might still be possible? I think, you should just print the 12 byte offset in addition.

On LoongArch64, the following failures happened when i perform check-openmp:

            4: 0: ompt_event_master_end: codeptr_ra=0x555556134c40
check:89'0                                                        X error: no match found
check:89'1                                                          with "MASTER_ID" equal to "0"
check:89'2                                                          with "RETURN_ADDRESS_END" equal to "0x555556134c40"
            5: 0: current_address=0x555556134c48 or 0x555556134c44

The macro print_current_address(id) prints the exact address that a previously called runtime function returns to.
As the above shown, the values of curren_address can not match the value of codeptr_ra (that is return address ) .
Disassemble it and generate the following codes:

0000000000000b98 <.omp_outlined.>:
...
 c3c:   57fc97ff        bl              -876(0xffffc94) # 8d0 <__kmpc_end_master@plt>
 c40:   50000400        b               4(0x4)  # c44 <.omp_outlined.+0xac>
 c44:   03400000        andi            $zero, $zero, 0x0
 c48:   50000400        b               4(0x4)  # c4c <.omp_outlined.+0xb4>
 c4c:   1a000104        pcalau12i       $a0, 8(0x8)
 c50:   02c2c084        addi.d          $a0, $a0, 176(0xb0)

And here the value of codeptr_ra is c40, the value of current_address is c48 or c44 caused by previously ((char *)addr) - 4 or ((char *)addr) - 8) wrong calculation.
But in D132925 which follows D59880 for RISCV64, why doesn't the current_address follow ((char *)addr) - 8 or ((char *)addr) - 12 in RISCV64? @prcups

I did not argue against adding ((char *)addr) - 12. But following the description in the comment, I think, ((char *)addr) - 4 should stay there, as this might still be valid for other cases (e.g., compiling with other optimization constraints?).

Ami-zhang added a comment.EditedNov 30 2022, 12:18 AM

I did not argue against adding ((char *)addr) - 12. But following the description in the comment, I think, ((char *)addr) - 4 should stay there, as this might still be valid for other cases (e.g., compiling with other optimization constraints?).

Yes, when compiling with optimization, ((char *)addr) - 4 is valid.
I have added it.
Thank you.

Ami-zhang updated this revision to Diff 478833.EditedNov 30 2022, 12:20 AM

Addressed @protze.joachim's comment.

Ami-zhang edited the summary of this revision. (Show Details)Nov 30 2022, 12:52 AM
xen0n added a comment.Nov 30 2022, 7:38 PM

Looks good from LoongArch side. Thanks!

SixWeining retitled this revision from [OMPT][test] Fix mismatch error between the current address and the return address to [OMPT][test] Fix mismatch error between the current address and the return address for LoongArch.Dec 1 2022, 2:00 AM

I just added for LoongArch to the title since this change is LoongArch specific.

I just added for LoongArch to the title since this change is LoongArch specific.

Thank you.

SixWeining accepted this revision.Dec 4 2022, 11:18 PM

LGTM from the LoongArch side.

This revision is now accepted and ready to land.Dec 4 2022, 11:18 PM