|
From: Carl E. L. <ce...@li...> - 2013-07-02 23:59:08
|
I am working on implementing Julian's first proposal for the
Transactional Memory instructions on PPC. Here is my test program:
htm_begin (int r3, int r4)
{
int ret;
if (__builtin_tbegin (0))
{
ret = r3;
__builtin_tend (0);
}
else
{
ret = r4;
}
return ret;
}
int main (void)
{
int ret = htm_begin (10, 20);
printf ("ret = %d, expected = 10\n", ret);
return 0;
}
Note for test purposes the value of ret is 10 if you do the tbegin/tend
path and ret is 20 if you don't.
Here is the power assembly for the htm_begin functiion:
0000000010001370 <.htm_begin>:
10001370: 7c 00 05 1d tbegin.
10001374: 40 82 00 0c bne 10001380 <.htm_begin+0x10>
10001378: 7c 83 23 78 mr r3,r4
1000137c: 4e 80 00 20 blr
10001380: 7c 00 05 5d tend.
10001384: 4e 80 00 20 blr
On input to the function, r3 is equal to 20. The function return value
is returned in r3 as well. The issue is that when I run the test case
on Valgrind it is executing the tbegin/tend code path copying 10 into r3
thus returning 10 from the function. It should jump to the second blr
at address 10001384 thus not changing r3 from the input.
In my Valgrind code, I convert the tbegin to an unconditional jump. The
target address for the unconditional jump is calculated as tgt =
0x10001380. I then have the following Valgrind code for executing the
unconditional jump:
/* The tbegin is being treated as an unconditonal jump to the
* failure handler which presumably will be a new basic block.
*/
dres->whatNext = Dis_ResteerU;
dres->jk_StopHere = Ijk_Boring;
dres->continueAt = tgt;
putGST( PPC_GST_CIA, mkSzImm(ty, tgt) ); /* update the PPC current instruction address register*/
return True;
In my Valgrind code, I set whatNext to Dis_ResteerU since we are taking
an unconditional branch. I set continueAt to the target address
0x10001380. I have tried setting jk_StopHere to Ijk_Call and to
Ijk_Boring. But I don't seem to be able to get Valgrind to do the
unconditional jump to the second blr and thus not execute the
tbegin/tend code. The move is executed setting r3 to 10 as reported by
the print in the test program.
I also get the following messages from Valgrind:
=70522== Conditional jump or move depends on uninitialised value(s)
==70522== at 0x10024F88: write (syscall-template.S:81)
==70522== by 0x1000DDA3: _IO_file_write (fileops.c:1254)
==70522== by 0x1001021B: _IO_file_overflow (fileops.c:860)
==70522== by 0x1000E77B: _IO_file_xsputn (fileops.c:1325)
==70522== by 0x1003D43B: vfprintf (vfprintf.c:1660)
==70522== by 0x10009D47: printf (printf.c:33)
==70522== by 0x10001137: main (in /home/carll/HTM/carll-htm.out)
==70522==
I assume I have something wrong with the dres structure values to get
Valgrind to start fetching and executing a new basic block. Please let
me know if you see what I am missing here to get Valgrind to do the
unconditional branch. Thanks.
Carl Love
|