locked instruction testcase failure

From: Paul Floyd <pjfloyd_at_wanadoo.fr>
Date: Sat, 14 May 2022 15:31:02 UTC
Hi

I'm working on updating Valgrind for FreeBSD 13.1.

One of the problems that I see is with the testcase 
none/tests/amd64/amd64locked

Here's a link to the source

https://sourceware.org/git/?p=valgrind.git;a=blob;f=none/tests/amd64/amd64locked.c;h=baf9bbe1eca91ac672e4373d8f58a476cf4de9d5;hb=HEAD


The problem is nor related to Valgrind. If I run the executable alone it 
fails


$ ./amd64locked
amd64locked: FAIL: CRCs actual 0xA248D739 expected 0xDF0656F1
amd64locked: set #define VERBOSE 1 to diagnose

This is on FreeBSD 13.1 RC6 amd64 running on VirtualBox, compiler version

FreeBSD clang version 13.0.0 (git@github.com:llvm/llvm-project.git 
llvmorg-13.0.0-0-gd7b669b3a303)

I'm not familiar with the code. It's a long test for all amd64 
instructions with a lock prefix performing CRC calculations. Compiled 
without optimization it passes

The source contains this comment


   // So there should be 118 lock-prefixed instructions in the
   // disassembly of this compilation unit.
   // confirm with
   // objdump -d ./amd64locked | grep lock | grep -v do_lock | grep -v 
elf64 | wc

This also gives the wrong output.

  $  objdump -d ./amd64locked | grep lock | grep -v do_lock | grep -v 
elf64 | wc
      136    1193    7376

I'll check what this does on Linux.


Any suggestions what can be done? It looks like an issue with the compiler.


A+

Paul