jsji created this revision.
Herald added subscribers: steven.zhang, kbarton, nemanjai.
jsji requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

It turns out that AIX kernerl are definiing int instead of unsing int
for fectch_and_add.

Legacy XL also define this to be signed.

https://www.ibm.com/docs/en/aix/7.2?topic=f-fetch-add-kernel-services

So update the type for compat.

Reviewere: hubert.reinterpretcast, Whitney, #PowerPC 
<https://reviews.llvm.org/tag/powerpc/>


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D106920

Files:
  clang/include/clang/Basic/BuiltinsPPC.def
  clang/test/CodeGen/builtins-ppc-xlcompat-fetch-error.c
  clang/test/CodeGen/builtins-ppc-xlcompat-fetch.c


Index: clang/test/CodeGen/builtins-ppc-xlcompat-fetch.c
===================================================================
--- clang/test/CodeGen/builtins-ppc-xlcompat-fetch.c
+++ clang/test/CodeGen/builtins-ppc-xlcompat-fetch.c
@@ -16,7 +16,7 @@
 // CHECK-NEXT:    [[TMP2:%.*]] = atomicrmw add i32* [[A_ADDR]], i32 [[TMP1]] 
monotonic, align 4
 // CHECK-NEXT:    ret void
 //
-void test_builtin_ppc_fetch_and_add(unsigned int a, unsigned int b) {
+void test_builtin_ppc_fetch_and_add(int a, unsigned int b) {
   __fetch_and_add(&a, b);
 }
 
@@ -31,7 +31,7 @@
 // CHECK-NEXT:    [[TMP2:%.*]] = atomicrmw add i64* [[A_ADDR]], i64 [[TMP1]] 
monotonic, align 8
 // CHECK-NEXT:    ret void
 //
-void test_builtin_ppc_fetch_and_addlp(unsigned long a, unsigned long b) {
+void test_builtin_ppc_fetch_and_addlp(long a, unsigned long b) {
   __fetch_and_addlp(&a, b);
 }
 // CHECK-LABEL: @test_builtin_ppc_fetch_and_and(
Index: clang/test/CodeGen/builtins-ppc-xlcompat-fetch-error.c
===================================================================
--- clang/test/CodeGen/builtins-ppc-xlcompat-fetch-error.c
+++ clang/test/CodeGen/builtins-ppc-xlcompat-fetch-error.c
@@ -1,17 +1,18 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
 // REQUIRES: powerpc-registered-target
 // RUN: %clang_cc1 -triple powerpc64-unknown-aix -target-cpu pwr8 \
 // RUN:  -verify %s
 
 void test_builtin_ppc_fetch_and_add2() {
-  volatile int a = 0;
+  volatile unsigned int a = 0;
   unsigned int b = 0;
 
-  __fetch_and_add(&a, b); // expected-warning {{passing 'volatile int *' to 
parameter of type 'volatile unsigned int *' converts between pointers to 
integer types with different sign}}
+  __fetch_and_add(&a, b); // expected-warning {{passing 'volatile unsigned int 
*' to parameter of type 'volatile int *' converts between pointers to integer 
types with different sign}}
 }
 
 void test_builtin_ppc_fetch_and_addlp() {
-  volatile long a = 0;
+  volatile unsigned long a = 0;
   unsigned long b = 0;
 
-  __fetch_and_addlp(&a, b); // expected-warning {{passing 'volatile long *' to 
parameter of type 'volatile unsigned long *' converts between pointers to 
integer types with different sign}}
+  __fetch_and_addlp(&a, b); // expected-warning {{passing 'volatile unsigned 
long *' to parameter of type 'volatile long *' converts between pointers to 
integer types with different sign}}
 }
Index: clang/include/clang/Basic/BuiltinsPPC.def
===================================================================
--- clang/include/clang/Basic/BuiltinsPPC.def
+++ clang/include/clang/Basic/BuiltinsPPC.def
@@ -64,8 +64,8 @@
 BUILTIN(__builtin_ppc_fsqrts, "ff", "")
 BUILTIN(__builtin_ppc_compare_and_swap, "iiD*i*i", "")
 BUILTIN(__builtin_ppc_compare_and_swaplp, "iLiD*Li*Li", "")
-BUILTIN(__builtin_ppc_fetch_and_add, "UiUiD*Ui", "")
-BUILTIN(__builtin_ppc_fetch_and_addlp, "ULiULiD*ULi", "")
+BUILTIN(__builtin_ppc_fetch_and_add, "iiD*i", "")
+BUILTIN(__builtin_ppc_fetch_and_addlp, "LiLiD*Li", "")
 BUILTIN(__builtin_ppc_fetch_and_and, "UiUiD*Ui", "")
 BUILTIN(__builtin_ppc_fetch_and_andlp, "ULiULiD*ULi", "")
 BUILTIN(__builtin_ppc_fetch_and_or, "UiUiD*Ui", "")


Index: clang/test/CodeGen/builtins-ppc-xlcompat-fetch.c
===================================================================
--- clang/test/CodeGen/builtins-ppc-xlcompat-fetch.c
+++ clang/test/CodeGen/builtins-ppc-xlcompat-fetch.c
@@ -16,7 +16,7 @@
 // CHECK-NEXT:    [[TMP2:%.*]] = atomicrmw add i32* [[A_ADDR]], i32 [[TMP1]] monotonic, align 4
 // CHECK-NEXT:    ret void
 //
-void test_builtin_ppc_fetch_and_add(unsigned int a, unsigned int b) {
+void test_builtin_ppc_fetch_and_add(int a, unsigned int b) {
   __fetch_and_add(&a, b);
 }
 
@@ -31,7 +31,7 @@
 // CHECK-NEXT:    [[TMP2:%.*]] = atomicrmw add i64* [[A_ADDR]], i64 [[TMP1]] monotonic, align 8
 // CHECK-NEXT:    ret void
 //
-void test_builtin_ppc_fetch_and_addlp(unsigned long a, unsigned long b) {
+void test_builtin_ppc_fetch_and_addlp(long a, unsigned long b) {
   __fetch_and_addlp(&a, b);
 }
 // CHECK-LABEL: @test_builtin_ppc_fetch_and_and(
Index: clang/test/CodeGen/builtins-ppc-xlcompat-fetch-error.c
===================================================================
--- clang/test/CodeGen/builtins-ppc-xlcompat-fetch-error.c
+++ clang/test/CodeGen/builtins-ppc-xlcompat-fetch-error.c
@@ -1,17 +1,18 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
 // REQUIRES: powerpc-registered-target
 // RUN: %clang_cc1 -triple powerpc64-unknown-aix -target-cpu pwr8 \
 // RUN:  -verify %s
 
 void test_builtin_ppc_fetch_and_add2() {
-  volatile int a = 0;
+  volatile unsigned int a = 0;
   unsigned int b = 0;
 
-  __fetch_and_add(&a, b); // expected-warning {{passing 'volatile int *' to parameter of type 'volatile unsigned int *' converts between pointers to integer types with different sign}}
+  __fetch_and_add(&a, b); // expected-warning {{passing 'volatile unsigned int *' to parameter of type 'volatile int *' converts between pointers to integer types with different sign}}
 }
 
 void test_builtin_ppc_fetch_and_addlp() {
-  volatile long a = 0;
+  volatile unsigned long a = 0;
   unsigned long b = 0;
 
-  __fetch_and_addlp(&a, b); // expected-warning {{passing 'volatile long *' to parameter of type 'volatile unsigned long *' converts between pointers to integer types with different sign}}
+  __fetch_and_addlp(&a, b); // expected-warning {{passing 'volatile unsigned long *' to parameter of type 'volatile long *' converts between pointers to integer types with different sign}}
 }
Index: clang/include/clang/Basic/BuiltinsPPC.def
===================================================================
--- clang/include/clang/Basic/BuiltinsPPC.def
+++ clang/include/clang/Basic/BuiltinsPPC.def
@@ -64,8 +64,8 @@
 BUILTIN(__builtin_ppc_fsqrts, "ff", "")
 BUILTIN(__builtin_ppc_compare_and_swap, "iiD*i*i", "")
 BUILTIN(__builtin_ppc_compare_and_swaplp, "iLiD*Li*Li", "")
-BUILTIN(__builtin_ppc_fetch_and_add, "UiUiD*Ui", "")
-BUILTIN(__builtin_ppc_fetch_and_addlp, "ULiULiD*ULi", "")
+BUILTIN(__builtin_ppc_fetch_and_add, "iiD*i", "")
+BUILTIN(__builtin_ppc_fetch_and_addlp, "LiLiD*Li", "")
 BUILTIN(__builtin_ppc_fetch_and_and, "UiUiD*Ui", "")
 BUILTIN(__builtin_ppc_fetch_and_andlp, "ULiULiD*ULi", "")
 BUILTIN(__builtin_ppc_fetch_and_or, "UiUiD*Ui", "")
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to