ABI incompatibility between POWER and Z HTM builtins and intrinsics
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
gcc-4.8 (Ubuntu) |
Fix Released
|
Undecided
|
Unassigned | ||
Trusty |
Fix Released
|
Undecided
|
Unassigned | ||
Utopic |
Fix Released
|
Undecided
|
Unassigned | ||
gcc-4.9 (Ubuntu) |
Fix Released
|
Undecided
|
Unassigned | ||
Trusty |
Invalid
|
Undecided
|
Unassigned | ||
Utopic |
Fix Released
|
Undecided
|
Unassigned | ||
gccgo-4.9 (Ubuntu) |
Invalid
|
Undecided
|
Unassigned | ||
Trusty |
Fix Released
|
Undecided
|
Unassigned | ||
Utopic |
Invalid
|
Undecided
|
Unassigned |
Bug Description
The IBM XL team defined a set of HTM intrinsic functions that were supposed
to be API compatible across the XL and GCC compilers on both Power and S390.
PR61193 describes an issue where the functions that begin a transaction
are incompatible. The Power intrinsics return non-zero on success, while
the S390 intrinsics return zero on success.
After discussing this with the XL compiler team, the S390 GCC team and
the Power GCC team, we have decided to leave the incompatibility between
Power and S390. However, the XL and GCC compilers will be compatible
with each other when targeting the same processor target. To mitigate
the incompatibility somewhat, we have decided to add a macro to the
powerpc*-linux's htmintrin.h file that defines what the "successful"
return status value of the __TM_simple_begin() and __TM_begin() intrinsic
function is. This macro is already defined in the S390's htmintrin.h
header file and is used by the S390 to determine whether the transaction
was successfully started or not. By adding the same macro on Power, we
allow users to write common code between Power and S390, even though our
successful return status values are different.
For example, the following code can be used on Power and S390, even
though the actual value returned by __TM_simple_begin() is different.
if ((tx_state = __TM_simple_begin ()) == _HTM_TBEGIN_
{
/* Transaction State Initiated. */
...
}
else
{
/* Transaction State Failed. */
...
}
David approved this offline, so I'm committing this to GCC mainline as revision 210486, as well as the 4.9 (210487) and 4.8 (210488) branches.
Peter
PR target/61193
* config/
(__TM_
(__TM_begin): Likewise.
Index: gcc/config/
=======
--- gcc/config/
+++ gcc/config/
@@ -46,12 +46,17 @@ extern "C" {
typedef char TM_buff_type[16];
+/* Compatibility macro with s390. This macro can be used to determine
+ whether a transaction was successfully started from the __TM_begin()
+ and __TM_simple_begin() intrinsic functions below. */
+#define _HTM_TBEGIN_STARTED 1
+
extern __inline long
__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
__TM_simple_begin (void)
{
if (__builtin_expect (__builtin_tbegin (0), 1))
- return 1;
+ return _HTM_TBEGIN_
return 0;
}
@@ -61,7 +66,7 @@ __TM_begin (void* const TM_buff)
{
*_TEXASRL_PTR (TM_buff) = 0;
if (__builtin_expect (__builtin_tbegin (0), 1))
- return 1;
+ return _HTM_TBEGIN_
#ifdef __powerpc64__
*_TEXASR_PTR (TM_buff) = __builtin_
#else
The attachment "Patch to mitigate API incompatibility between Power and S390" seems to be a patch. If it isn't, please remove the "patch" flag from the attachment, remove the "patch" tag, and if you are a member of the ~ubuntu-reviewers, unsubscribe the team.
[This is an automated message performed by a Launchpad user owned by ~brian-murray, for any issues please contact him.]