[PATCH] D61392: [clang] Handle lround/llround builtins

2019-05-01 Thread Adhemerval Zanella via Phabricator via cfe-commits
zatrazz created this revision.
zatrazz added reviewers: efriedma, rengolin, javed.absar, huntergr, 
SjoerdMeijer, t.p.northover, echristo, evandro.
zatrazz added a project: clang.
Herald added subscribers: kristina, kristof.beyls.

As for other floating-point rounding builtins that can be optimized
when build with -fno-math-errno, this patch adds support for lround
and llround.  It currently only optimized for AArch64 backend.

This patch depends on https://reviews.llvm.org/D61390


Repository:
  rC Clang

https://reviews.llvm.org/D61392

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/builtins.c
  clang/test/CodeGen/math-builtins.c
  clang/test/CodeGen/math-libcalls.c

Index: clang/test/CodeGen/math-libcalls.c
===
--- clang/test/CodeGen/math-libcalls.c
+++ clang/test/CodeGen/math-libcalls.c
@@ -317,9 +317,9 @@
 
   llround(f);llroundf(f);   llroundl(f);
 
-// NO__ERRNO: declare i64 @llround(double) [[READNONE]]
-// NO__ERRNO: declare i64 @llroundf(float) [[READNONE]]
-// NO__ERRNO: declare i64 @llroundl(x86_fp80) [[READNONE]]
+// NO__ERRNO: declare i64 @llvm.llround.f64(double) [[READNONE_INTRINSIC]]
+// NO__ERRNO: declare i64 @llvm.llround.f32(float) [[READNONE_INTRINSIC]]
+// NO__ERRNO: declare i64 @llvm.llround.f80(x86_fp80) [[READNONE_INTRINSIC]]
 // HAS_ERRNO: declare i64 @llround(double) [[NOT_READNONE]]
 // HAS_ERRNO: declare i64 @llroundf(float) [[NOT_READNONE]]
 // HAS_ERRNO: declare i64 @llroundl(x86_fp80) [[NOT_READNONE]]
@@ -380,9 +380,9 @@
 
   lround(f); lroundf(f);lroundl(f);
 
-// NO__ERRNO: declare i64 @lround(double) [[READNONE]]
-// NO__ERRNO: declare i64 @lroundf(float) [[READNONE]]
-// NO__ERRNO: declare i64 @lroundl(x86_fp80) [[READNONE]]
+// NO__ERRNO: declare i64 @llvm.lround.i64.f64(double) [[READNONE_INTRINSIC]]
+// NO__ERRNO: declare i64 @llvm.lround.i64.f32(float) [[READNONE_INTRINSIC]]
+// NO__ERRNO: declare i64 @llvm.lround.i64.f80(x86_fp80) [[READNONE_INTRINSIC]]
 // HAS_ERRNO: declare i64 @lround(double) [[NOT_READNONE]]
 // HAS_ERRNO: declare i64 @lroundf(float) [[NOT_READNONE]]
 // HAS_ERRNO: declare i64 @lroundl(x86_fp80) [[NOT_READNONE]]
Index: clang/test/CodeGen/math-builtins.c
===
--- clang/test/CodeGen/math-builtins.c
+++ clang/test/CodeGen/math-builtins.c
@@ -362,9 +362,9 @@
 
   __builtin_llround(f);__builtin_llroundf(f);   __builtin_llroundl(f);
 
-// NO__ERRNO: declare i64 @llround(double) [[READNONE]]
-// NO__ERRNO: declare i64 @llroundf(float) [[READNONE]]
-// NO__ERRNO: declare i64 @llroundl(x86_fp80) [[READNONE]]
+// NO__ERRNO: declare i64 @llvm.llround.f64(double) [[READNONE_INTRINSIC]]
+// NO__ERRNO: declare i64 @llvm.llround.f32(float) [[READNONE_INTRINSIC]]
+// NO__ERRNO: declare i64 @llvm.llround.f80(x86_fp80) [[READNONE_INTRINSIC]]
 // HAS_ERRNO: declare i64 @llround(double) [[NOT_READNONE]]
 // HAS_ERRNO: declare i64 @llroundf(float) [[NOT_READNONE]]
 // HAS_ERRNO: declare i64 @llroundl(x86_fp80) [[NOT_READNONE]]
@@ -425,9 +425,9 @@
 
   __builtin_lround(f); __builtin_lroundf(f);__builtin_lroundl(f);
 
-// NO__ERRNO: declare i64 @lround(double) [[READNONE]]
-// NO__ERRNO: declare i64 @lroundf(float) [[READNONE]]
-// NO__ERRNO: declare i64 @lroundl(x86_fp80) [[READNONE]]
+// NO__ERRNO: declare i64 @llvm.lround.i64.f64(double) [[READNONE_INTRINSIC]]
+// NO__ERRNO: declare i64 @llvm.lround.i64.f32(float) [[READNONE_INTRINSIC]]
+// NO__ERRNO: declare i64 @llvm.lround.i64.f80(x86_fp80) [[READNONE_INTRINSIC]]
 // HAS_ERRNO: declare i64 @lround(double) [[NOT_READNONE]]
 // HAS_ERRNO: declare i64 @lroundf(float) [[NOT_READNONE]]
 // HAS_ERRNO: declare i64 @lroundl(x86_fp80) [[NOT_READNONE]]
Index: clang/test/CodeGen/builtins.c
===
--- clang/test/CodeGen/builtins.c
+++ clang/test/CodeGen/builtins.c
@@ -256,6 +256,8 @@
   volatile float resf;
   volatile double resd;
   volatile long double resld;
+  volatile long int resli;
+  volatile long long int reslli;
 
   resf = __builtin_fmodf(F,F);
   // CHECK: frem float
@@ -380,6 +382,14 @@
   resld = __builtin_roundl(LD);
   // CHECK: call x86_fp80 @llvm.round.f80
 
+  resli = __builtin_lroundf (F);
+  // CHECK: call i64 @llvm.lround.i64.f32
+
+  resli = __builtin_lround (D);
+  // CHECK: call i64 @llvm.lround.i64.f64
+
+  resli = __builtin_lroundl (LD);
+  // CHECK: call i64 @llvm.lround.i64.f80
 }
 
 // __builtin_longjmp isn't supported on all platforms, so only test it on X86.
Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -1721,6 +1721,27 @@
 case Builtin::BI__builtin_truncl:
   return RValue::get(emitUnaryBuiltin(*this, E, Intrinsic::trunc));
 
+case Builtin::BIlround:
+case Builtin::BIlroundf:
+case Builtin::BIlroundl:
+case Bui

[PATCH] D62019: [clang] Handle lrint/llrint builtins

2019-05-16 Thread Adhemerval Zanella via Phabricator via cfe-commits
zatrazz created this revision.
zatrazz added reviewers: efriedma, rengolin, javed.absar, huntergr, 
SjoerdMeijer, t.p.northover, echristo, evandro.
zatrazz added a project: clang.
Herald added subscribers: kristina, kristof.beyls.

As for other floating-point rounding builtins that can be optimized
when build with -fno-math-errno, this patch adds support for lrint
and llrint.  It currently only optimize for AArch64 backend.

This patch depends on https://reviews.llvm.org/D62017.


Repository:
  rC Clang

https://reviews.llvm.org/D62019

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/builtins.c
  clang/test/CodeGen/math-builtins.c
  clang/test/CodeGen/math-libcalls.c

Index: clang/test/CodeGen/math-libcalls.c
===
--- clang/test/CodeGen/math-libcalls.c
+++ clang/test/CodeGen/math-libcalls.c
@@ -308,9 +308,9 @@
 
   llrint(f); llrintf(f);llrintl(f);
 
-// NO__ERRNO: declare i64 @llrint(double) [[READNONE]]
-// NO__ERRNO: declare i64 @llrintf(float) [[READNONE]]
-// NO__ERRNO: declare i64 @llrintl(x86_fp80) [[READNONE]]
+// NO__ERRNO: declare i64 @llvm.llrint.f64(double) [[READNONE_INTRINSIC]]
+// NO__ERRNO: declare i64 @llvm.llrint.f32(float) [[READNONE_INTRINSIC]]
+// NO__ERRNO: declare i64 @llvm.llrint.f80(x86_fp80) [[READNONE_INTRINSIC]]
 // HAS_ERRNO: declare i64 @llrint(double) [[NOT_READNONE]]
 // HAS_ERRNO: declare i64 @llrintf(float) [[NOT_READNONE]]
 // HAS_ERRNO: declare i64 @llrintl(x86_fp80) [[NOT_READNONE]]
@@ -371,9 +371,9 @@
 
   lrint(f);  lrintf(f); lrintl(f);
 
-// NO__ERRNO: declare i64 @lrint(double) [[READNONE]]
-// NO__ERRNO: declare i64 @lrintf(float) [[READNONE]]
-// NO__ERRNO: declare i64 @lrintl(x86_fp80) [[READNONE]]
+// NO__ERRNO: declare i64 @llvm.lrint.i64.f64(double) [[READNONE_INTRINSIC]]
+// NO__ERRNO: declare i64 @llvm.lrint.i64.f32(float) [[READNONE_INTRINSIC]]
+// NO__ERRNO: declare i64 @llvm.lrint.i64.f80(x86_fp80) [[READNONE_INTRINSIC]]
 // HAS_ERRNO: declare i64 @lrint(double) [[NOT_READNONE]]
 // HAS_ERRNO: declare i64 @lrintf(float) [[NOT_READNONE]]
 // HAS_ERRNO: declare i64 @lrintl(x86_fp80) [[NOT_READNONE]]
Index: clang/test/CodeGen/math-builtins.c
===
--- clang/test/CodeGen/math-builtins.c
+++ clang/test/CodeGen/math-builtins.c
@@ -353,9 +353,9 @@
 
   __builtin_llrint(f); __builtin_llrintf(f);__builtin_llrintl(f);
 
-// NO__ERRNO: declare i64 @llrint(double) [[READNONE]]
-// NO__ERRNO: declare i64 @llrintf(float) [[READNONE]]
-// NO__ERRNO: declare i64 @llrintl(x86_fp80) [[READNONE]]
+// NO__ERRNO: declare i64 @llvm.llrint.f64(double) [[READNONE_INTRINSIC]]
+// NO__ERRNO: declare i64 @llvm.llrint.f32(float) [[READNONE_INTRINSIC]]
+// NO__ERRNO: declare i64 @llvm.llrint.f80(x86_fp80) [[READNONE_INTRINSIC]]
 // HAS_ERRNO: declare i64 @llrint(double) [[NOT_READNONE]]
 // HAS_ERRNO: declare i64 @llrintf(float) [[NOT_READNONE]]
 // HAS_ERRNO: declare i64 @llrintl(x86_fp80) [[NOT_READNONE]]
@@ -416,9 +416,9 @@
 
   __builtin_lrint(f);  __builtin_lrintf(f); __builtin_lrintl(f);
 
-// NO__ERRNO: declare i64 @lrint(double) [[READNONE]]
-// NO__ERRNO: declare i64 @lrintf(float) [[READNONE]]
-// NO__ERRNO: declare i64 @lrintl(x86_fp80) [[READNONE]]
+// NO__ERRNO: declare i64 @llvm.lrint.i64.f64(double) [[READNONE_INTRINSIC]]
+// NO__ERRNO: declare i64 @llvm.lrint.i64.f32(float) [[READNONE_INTRINSIC]]
+// NO__ERRNO: declare i64 @llvm.lrint.i64.f80(x86_fp80) [[READNONE_INTRINSIC]]
 // HAS_ERRNO: declare i64 @lrint(double) [[NOT_READNONE]]
 // HAS_ERRNO: declare i64 @lrintf(float) [[NOT_READNONE]]
 // HAS_ERRNO: declare i64 @lrintl(x86_fp80) [[NOT_READNONE]]
Index: clang/test/CodeGen/builtins.c
===
--- clang/test/CodeGen/builtins.c
+++ clang/test/CodeGen/builtins.c
@@ -390,6 +390,15 @@
 
   resli = __builtin_lroundl (LD);
   // CHECK: call i64 @llvm.lround.i64.f80
+
+  resli = __builtin_lrintf (F);
+  // CHECK: call i64 @llvm.lrint.i64.f32
+
+  resli = __builtin_lrint (D);
+  // CHECK: call i64 @llvm.lrint.i64.f64
+
+  resli = __builtin_lrintl (LD);
+  // CHECK: call i64 @llvm.lrint.i64.f80
 }
 
 // __builtin_longjmp isn't supported on all platforms, so only test it on X86.
Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -1742,6 +1742,27 @@
 case Builtin::BI__builtin_llroundl:
   return RValue::get(emitUnaryBuiltin(*this, E, Intrinsic::llround));
 
+case Builtin::BIlrint:
+case Builtin::BIlrintf:
+case Builtin::BIlrintl:
+case Builtin::BI__builtin_lrint:
+case Builtin::BI__builtin_lrintf:
+case Builtin::BI__builtin_lrintl: {
+  llvm::Type *ResultType = ConvertType(E->getType());
+  int Width = ResultType->getPrimitiveSizeInBits();
+  return RValue::get(emitUnaryBuiltin

[PATCH] D62019: [clang] Handle lrint/llrint builtins

2019-05-20 Thread Adhemerval Zanella via Phabricator via cfe-commits
zatrazz updated this revision to Diff 200291.
zatrazz added a comment.

Updated patch based on D62026 .


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D62019/new/

https://reviews.llvm.org/D62019

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/builtins.c
  clang/test/CodeGen/math-builtins.c
  clang/test/CodeGen/math-libcalls.c

Index: clang/test/CodeGen/math-libcalls.c
===
--- clang/test/CodeGen/math-libcalls.c
+++ clang/test/CodeGen/math-libcalls.c
@@ -308,9 +308,9 @@
 
   llrint(f); llrintf(f);llrintl(f);
 
-// NO__ERRNO: declare i64 @llrint(double) [[READNONE]]
-// NO__ERRNO: declare i64 @llrintf(float) [[READNONE]]
-// NO__ERRNO: declare i64 @llrintl(x86_fp80) [[READNONE]]
+// NO__ERRNO: declare i64 @llvm.llrint.i64.f64(double) [[READNONE_INTRINSIC]]
+// NO__ERRNO: declare i64 @llvm.llrint.i64.f32(float) [[READNONE_INTRINSIC]]
+// NO__ERRNO: declare i64 @llvm.llrint.i64.f80(x86_fp80) [[READNONE_INTRINSIC]]
 // HAS_ERRNO: declare i64 @llrint(double) [[NOT_READNONE]]
 // HAS_ERRNO: declare i64 @llrintf(float) [[NOT_READNONE]]
 // HAS_ERRNO: declare i64 @llrintl(x86_fp80) [[NOT_READNONE]]
@@ -371,9 +371,9 @@
 
   lrint(f);  lrintf(f); lrintl(f);
 
-// NO__ERRNO: declare i64 @lrint(double) [[READNONE]]
-// NO__ERRNO: declare i64 @lrintf(float) [[READNONE]]
-// NO__ERRNO: declare i64 @lrintl(x86_fp80) [[READNONE]]
+// NO__ERRNO: declare i64 @llvm.lrint.i64.f64(double) [[READNONE_INTRINSIC]]
+// NO__ERRNO: declare i64 @llvm.lrint.i64.f32(float) [[READNONE_INTRINSIC]]
+// NO__ERRNO: declare i64 @llvm.lrint.i64.f80(x86_fp80) [[READNONE_INTRINSIC]]
 // HAS_ERRNO: declare i64 @lrint(double) [[NOT_READNONE]]
 // HAS_ERRNO: declare i64 @lrintf(float) [[NOT_READNONE]]
 // HAS_ERRNO: declare i64 @lrintl(x86_fp80) [[NOT_READNONE]]
Index: clang/test/CodeGen/math-builtins.c
===
--- clang/test/CodeGen/math-builtins.c
+++ clang/test/CodeGen/math-builtins.c
@@ -353,9 +353,9 @@
 
   __builtin_llrint(f); __builtin_llrintf(f);__builtin_llrintl(f);
 
-// NO__ERRNO: declare i64 @llrint(double) [[READNONE]]
-// NO__ERRNO: declare i64 @llrintf(float) [[READNONE]]
-// NO__ERRNO: declare i64 @llrintl(x86_fp80) [[READNONE]]
+// NO__ERRNO: declare i64 @llvm.llrint.i64.f64(double) [[READNONE_INTRINSIC]]
+// NO__ERRNO: declare i64 @llvm.llrint.i64.f32(float) [[READNONE_INTRINSIC]]
+// NO__ERRNO: declare i64 @llvm.llrint.i64.f80(x86_fp80) [[READNONE_INTRINSIC]]
 // HAS_ERRNO: declare i64 @llrint(double) [[NOT_READNONE]]
 // HAS_ERRNO: declare i64 @llrintf(float) [[NOT_READNONE]]
 // HAS_ERRNO: declare i64 @llrintl(x86_fp80) [[NOT_READNONE]]
@@ -416,9 +416,9 @@
 
   __builtin_lrint(f);  __builtin_lrintf(f); __builtin_lrintl(f);
 
-// NO__ERRNO: declare i64 @lrint(double) [[READNONE]]
-// NO__ERRNO: declare i64 @lrintf(float) [[READNONE]]
-// NO__ERRNO: declare i64 @lrintl(x86_fp80) [[READNONE]]
+// NO__ERRNO: declare i64 @llvm.lrint.i64.f64(double) [[READNONE_INTRINSIC]]
+// NO__ERRNO: declare i64 @llvm.lrint.i64.f32(float) [[READNONE_INTRINSIC]]
+// NO__ERRNO: declare i64 @llvm.lrint.i64.f80(x86_fp80) [[READNONE_INTRINSIC]]
 // HAS_ERRNO: declare i64 @lrint(double) [[NOT_READNONE]]
 // HAS_ERRNO: declare i64 @lrintf(float) [[NOT_READNONE]]
 // HAS_ERRNO: declare i64 @lrintl(x86_fp80) [[NOT_READNONE]]
Index: clang/test/CodeGen/builtins.c
===
--- clang/test/CodeGen/builtins.c
+++ clang/test/CodeGen/builtins.c
@@ -390,6 +390,15 @@
 
   resli = __builtin_lroundl (LD);
   // CHECK: call i64 @llvm.lround.i64.f80
+
+  resli = __builtin_lrintf (F);
+  // CHECK: call i64 @llvm.lrint.i64.f32
+
+  resli = __builtin_lrint (D);
+  // CHECK: call i64 @llvm.lrint.i64.f64
+
+  resli = __builtin_lrintl (LD);
+  // CHECK: call i64 @llvm.lrint.i64.f80
 }
 
 // __builtin_longjmp isn't supported on all platforms, so only test it on X86.
Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -1749,6 +1749,22 @@
 case Builtin::BI__builtin_llroundl:
   return RValue::get(emitFPToIntRoundBuiltin(*this, E, Intrinsic::llround));
 
+case Builtin::BIlrint:
+case Builtin::BIlrintf:
+case Builtin::BIlrintl:
+case Builtin::BI__builtin_lrint:
+case Builtin::BI__builtin_lrintf:
+case Builtin::BI__builtin_lrintl:
+  return RValue::get(emitFPToIntRoundBuiltin(*this, E, Intrinsic::lrint));
+
+case Builtin::BIllrint:
+case Builtin::BIllrintf:
+case Builtin::BIllrintl:
+case Builtin::BI__builtin_llrint:
+case Builtin::BI__builtin_llrintf:
+case Builtin::BI__builtin_llrintl:
+  return RValue::get(emitFPToIntRoundBuiltin(*this, E, Intrinsic::llrint));
+
 default:
   break;
 }
__

[PATCH] D131307: [Clang] Allow downgrading to a warning the diagnostic for setting a non fixed enum to a value outside the range of the enumeration values

2022-08-09 Thread Adhemerval Zanella via Phabricator via cfe-commits
zatrazz added a comment.

This commit seems to have broken test-suite on aarch64 [1]. The warning shows:

  FAILED: MultiSource/Benchmarks/PAQ8p/CMakeFiles/paq8p.dir/paq8p.cpp.o
  /home/adhemerval.zanella/projects/llvm/test-suite-build/tools/timeit 
--summary MultiSource/Benchmarks/PAQ8p/CMakeFiles/paq8p.dir/paq8p.cpp.o.time 
/home/adhemerval.zanella/projects/llvm/llvm-src-build-stage1-buildbot/bin/clang++
 -DNDEBUG  -O3 -DNDEBUG   -w -Werror=date-time -DNOASM -DLLVM -MD -MT 
MultiSource/Benchmarks/PAQ8p/CMakeFiles/paq8p.dir/paq8p.cpp.o -MF 
MultiSource/Benchmarks/PAQ8p/CMakeFiles/paq8p.dir/paq8p.cpp.o.d -o 
MultiSource/Benchmarks/PAQ8p/CMakeFiles/paq8p.dir/paq8p.cpp.o -c 
/home/adhemerval.zanella/projects/llvm/test-suite/MultiSource/Benchmarks/PAQ8p/paq8p.cpp
  
/home/adhemerval.zanella/projects/llvm/test-suite/MultiSource/Benchmarks/PAQ8p/paq8p.cpp:3606:24:
 error: integer value -1 is outside the valid range of values [0, 15] for this 
enumeration type [-Wenum-constexpr-conversion]
  if (c==EOF) return (Filetype)(-1);
 ^
  1 error generated.

I am not sure if this is an existing issue with test-suite.

[1] https://lab.llvm.org/staging/#/builders/158/builds/344


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D131307/new/

https://reviews.llvm.org/D131307

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D131528: [Clang] Restrict non fixed enum to a value outside the range of the enumeration values warning to context requiring a constant expression

2022-08-10 Thread Adhemerval Zanella via Phabricator via cfe-commits
zatrazz added a comment.

It does help on test-suite, thanks.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D131528/new/

https://reviews.llvm.org/D131528

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D71111: [Sema] Improve diagnostic about addr spaces for overload candidates

2019-12-30 Thread Adhemerval Zanella via Phabricator via cfe-commits
zatrazz added a comment.

Hi,

I am investigating a recurring regression on aarch64-linux bots and bisecting 
the commits on the build [1] that introduced the regression it points to this 
one. I don't understand exactly what is triggering the issue, but it only 
happen on the stage2 build with stage1 clang built with different compilers 
(gcc 5.4, gcc-7.4.0, and gcc-8.3.0). The issue is on clang itself while trying 
to execute the Analysis/uninit-sometimes.cpp test:

   TEST 'Clang :: Analysis/uninit-sometimes.cpp' FAILED 

  Script:
  --
  : 'RUN: at line 1';   
/home/buildslave/buildslave/clang-cmake-aarch64-full/stage2/bin/clang -cc1 
-internal-isystem 
/home/buildslave/buildslave/clang-cmake-aarch64-full/stage2/lib/clang/10.0.0/include
 -nostdsysteminc -std=gnu++11 -Wsometimes-uninitialized -verify 
/home/buildslave/buildslave/clang-cmake-aarch64-full/llvm/clang/test/Analysis/uninit-sometimes.cpp
  : 'RUN: at line 2';   
/home/buildslave/buildslave/clang-cmake-aarch64-full/stage2/bin/clang -cc1 
-internal-isystem 
/home/buildslave/buildslave/clang-cmake-aarch64-full/stage2/lib/clang/10.0.0/include
 -nostdsysteminc -std=gnu++11 -Wsometimes-uninitialized 
-fdiagnostics-parseable-fixits 
/home/buildslave/buildslave/clang-cmake-aarch64-full/llvm/clang/test/Analysis/uninit-sometimes.cpp
 2>&1 | 
/home/buildslave/buildslave/clang-cmake-aarch64-full/stage2/bin/FileCheck 
/home/buildslave/buildslave/clang-cmake-aarch64-full/llvm/clang/test/Analysis/uninit-sometimes.cpp
  --
  Exit Code: 134
  
  Command Output (stderr):
  --
  clang: 
/home/buildslave/buildslave/clang-cmake-aarch64-full/llvm/clang/lib/Basic/Diagnostic.cpp:591:
 void HandleSelectModifier(const clang::Diagnostic &, unsigned int, const char 
*, unsigned int, SmallVectorImpl &): Assertion `NextVal != ArgumentEnd && 
"Value for integer select modifier was" " larger than the number of options in 
the diagnostic string!"' failed.
  Stack dump:
  0.Program arguments: 
/home/buildslave/buildslave/clang-cmake-aarch64-full/stage2/bin/clang -cc1 
-internal-isystem 
/home/buildslave/buildslave/clang-cmake-aarch64-full/stage2/lib/clang/10.0.0/include
 -nostdsysteminc -std=gnu++11 -Wsometimes-uninitialized -verify 
/home/buildslave/buildslave/clang-cmake-aarch64-full/llvm/clang/test/Analysis/uninit-sometimes.cpp
 
  1.
/home/buildslave/buildslave/clang-cmake-aarch64-full/llvm/clang/test/Analysis/uninit-sometimes.cpp:161:1:
 current parser token 'int'
  2.
/home/buildslave/buildslave/clang-cmake-aarch64-full/llvm/clang/test/Analysis/uninit-sometimes.cpp:146:32:
 parsing function body 'test_for_range_true'
  #0 0x0182be04 PrintStackTraceSignalHandler(void*) 
(/home/buildslave/buildslave/clang-cmake-aarch64-full/stage2/bin/clang+0x182be04)
  
/home/buildslave/buildslave/clang-cmake-aarch64-full/stage2/tools/clang/test/Analysis/Output/uninit-sometimes.cpp.script:
 line 2: 63297 Aborted (core dumped) 
/home/buildslave/buildslave/clang-cmake-aarch64-full/stage2/bin/clang -cc1 
-internal-isystem 
/home/buildslave/buildslave/clang-cmake-aarch64-full/stage2/lib/clang/10.0.0/include
 -nostdsysteminc -std=gnu++11 -Wsometimes-uninitialized -verify 
/home/buildslave/buildslave/clang-cmake-aarch64-full/llvm/clang/test/Analysis/uninit-sometimes.cpp

The bots run a ubuntu 16.04 container and I can't reproduce on a different one, 
I am still trying to come up with a better reproduce case. Also, moving the 
both DiagnosticBuilder::AddString and DiagnosticBuilder::AddTaggedVal outside 
clang/include/clang/Basic/Diagnostic.h to clang/lib/Basic/Diagnostic.cpp 
"fixes" the issue (indicating the something is wrong at code generation). This 
issue has been shown for some time on aarch64-linux bot [2]. Any idea if this 
is an environmental issue or a real issue?

[1] http://lab.llvm.org:8011/builders/clang-cmake-aarch64-full/builds/8562
[2] http://lab.llvm.org:8011/builders/clang-cmake-aarch64-full


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D7/new/

https://reviews.llvm.org/D7



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D72449: [PATCH] [llvm-ranlib] Take in consideration UTC offset for D-flag.test

2020-01-09 Thread Adhemerval Zanella via Phabricator via cfe-commits
zatrazz created this revision.
zatrazz added reviewers: arichardson, emaste, rupprecht.
Herald added a subscriber: kristof.beyls.
Herald added a project: LLVM.

The llvm-ar uses localtime to print the object timestamp and it is
subject to UTC offset (daylight for instance).  The patch changes
the test to check against output of a 'date' command.

It fixes the D-flag.test failure on some aarch64 and arm bots,
which are situated on GMT with currently BST timezone.


https://reviews.llvm.org/D72449

Files:
  llvm/test/tools/llvm-ranlib/D-flag.test


Index: llvm/test/tools/llvm-ranlib/D-flag.test
===
--- llvm/test/tools/llvm-ranlib/D-flag.test
+++ llvm/test/tools/llvm-ranlib/D-flag.test
@@ -10,7 +10,7 @@
 
 ## Check that the -D flag clears the timestamps:
 # RUN: cp %t-no-index.a %t.a && llvm-ranlib -D %t.a
-# RUN: env TZ=UTC llvm-ar tv %t.a | FileCheck %s 
--check-prefix=DETERMINISTIC-VALUES
+# RUN: (env TZ=UTC date -d '@0' +%H:%M; env TZ=UTC llvm-ar tv %t.a) | 
FileCheck %s --check-prefix=DETERMINISTIC-VALUES
 
 ## Check that the -U flag maintains the timestamps:
 # RUN: cp %t-no-index.a %t.a && llvm-ranlib -U %t.a
@@ -41,5 +41,8 @@
 # RUN: not llvm-ranlib -DxD %t.a 2>&1 | FileCheck %s --check-prefix=BAD-OPT-xD
 # BAD-OPT-xD: error: Invalid option: '-xD'
 
-# DETERMINISTIC-VALUES: {{[rwx-]+}} 0/0712 Jan  1 00:00 1970 
D-flag.test.tmp.o
+## llvm-ar uses localtime to print the object timestamp and it is subject to
+## UTC offset (daylight for instance).
+# DETERMINISTIC-VALUES: [[HHMM:[0-9]+:[0-9]+]]
+# DETERMINISTIC-VALUES: {{[rwx-]+}} 0/0712 Jan  1 [[HHMM]] 1970 
D-flag.test.tmp.o
 # REAL-VALUES: {{[rwx-]+}} {{[0-9]+}}/{{[0-9]+}} 712 Jan  2 03:04 2000 
D-flag.test.tmp.o


Index: llvm/test/tools/llvm-ranlib/D-flag.test
===
--- llvm/test/tools/llvm-ranlib/D-flag.test
+++ llvm/test/tools/llvm-ranlib/D-flag.test
@@ -10,7 +10,7 @@
 
 ## Check that the -D flag clears the timestamps:
 # RUN: cp %t-no-index.a %t.a && llvm-ranlib -D %t.a
-# RUN: env TZ=UTC llvm-ar tv %t.a | FileCheck %s --check-prefix=DETERMINISTIC-VALUES
+# RUN: (env TZ=UTC date -d '@0' +%H:%M; env TZ=UTC llvm-ar tv %t.a) | FileCheck %s --check-prefix=DETERMINISTIC-VALUES
 
 ## Check that the -U flag maintains the timestamps:
 # RUN: cp %t-no-index.a %t.a && llvm-ranlib -U %t.a
@@ -41,5 +41,8 @@
 # RUN: not llvm-ranlib -DxD %t.a 2>&1 | FileCheck %s --check-prefix=BAD-OPT-xD
 # BAD-OPT-xD: error: Invalid option: '-xD'
 
-# DETERMINISTIC-VALUES: {{[rwx-]+}} 0/0712 Jan  1 00:00 1970 D-flag.test.tmp.o
+## llvm-ar uses localtime to print the object timestamp and it is subject to
+## UTC offset (daylight for instance).
+# DETERMINISTIC-VALUES: [[HHMM:[0-9]+:[0-9]+]]
+# DETERMINISTIC-VALUES: {{[rwx-]+}} 0/0712 Jan  1 [[HHMM]] 1970 D-flag.test.tmp.o
 # REAL-VALUES: {{[rwx-]+}} {{[0-9]+}}/{{[0-9]+}} 712 Jan  2 03:04 2000 D-flag.test.tmp.o
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D72449: [PATCH] [llvm-ranlib] Take in consideration UTC offset for D-flag.test

2020-01-09 Thread Adhemerval Zanella via Phabricator via cfe-commits
zatrazz marked 2 inline comments as done.
zatrazz added inline comments.



Comment at: llvm/test/tools/llvm-ranlib/D-flag.test:13
 # RUN: cp %t-no-index.a %t.a && llvm-ranlib -D %t.a
-# RUN: env TZ=UTC llvm-ar tv %t.a | FileCheck %s 
--check-prefix=DETERMINISTIC-VALUES
+# RUN: (env TZ=UTC date -d '@0' +%H:%M; env TZ=UTC llvm-ar tv %t.a) | 
FileCheck %s --check-prefix=DETERMINISTIC-VALUES
 

kristof.beyls wrote:
> I wonder if 'date' is available on all platforms that LLVM builds on. For 
> example, is it available on Windows (with GnuWin32 installed, as per the 
> requirements listed at https://llvm.org/docs/GettingStartedVS.html)? 
> http://gnuwin32.sourceforge.net/packages.html doesn't seem to list "date" 
> explicitly?
It is provided by coreutils 
(http://gnuwin32.sourceforge.net/packages/coreutils.htm).



Comment at: llvm/test/tools/llvm-ranlib/D-flag.test:23
 # RUN: cp %t-no-index.a %t.a && llvm-ranlib -UUD %t.a
 # RUN: env TZ=UTC llvm-ar tv %t.a | FileCheck %s 
--check-prefix=DETERMINISTIC-VALUES
 

arichardson wrote:
> Wouldn't this line also have to change?
It does and I updated the patch.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72449/new/

https://reviews.llvm.org/D72449



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D72449: [PATCH] [llvm-ranlib] Take in consideration UTC offset for D-flag.test

2020-01-09 Thread Adhemerval Zanella via Phabricator via cfe-commits
zatrazz updated this revision to Diff 237134.
zatrazz added a comment.

Updated patch based on previous comments.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72449/new/

https://reviews.llvm.org/D72449

Files:
  llvm/test/tools/llvm-ranlib/D-flag.test


Index: llvm/test/tools/llvm-ranlib/D-flag.test
===
--- llvm/test/tools/llvm-ranlib/D-flag.test
+++ llvm/test/tools/llvm-ranlib/D-flag.test
@@ -10,7 +10,7 @@
 
 ## Check that the -D flag clears the timestamps:
 # RUN: cp %t-no-index.a %t.a && llvm-ranlib -D %t.a
-# RUN: env TZ=UTC llvm-ar tv %t.a | FileCheck %s 
--check-prefix=DETERMINISTIC-VALUES
+# RUN: (env TZ=UTC date -d '@0' +%H:%M; env TZ=UTC llvm-ar tv %t.a) | 
FileCheck %s --check-prefix=DETERMINISTIC-VALUES
 
 ## Check that the -U flag maintains the timestamps:
 # RUN: cp %t-no-index.a %t.a && llvm-ranlib -U %t.a
@@ -20,7 +20,7 @@
 # RUN: cp %t-no-index.a %t.a && llvm-ranlib -UDU %t.a
 # RUN: env TZ=UTC llvm-ar tv %t.a | FileCheck %s --check-prefix=REAL-VALUES
 # RUN: cp %t-no-index.a %t.a && llvm-ranlib -UUD %t.a
-# RUN: env TZ=UTC llvm-ar tv %t.a | FileCheck %s 
--check-prefix=DETERMINISTIC-VALUES
+# RUN: (env TZ=UTC date -d '@0' +%H:%M; env TZ=UTC llvm-ar tv %t.a) | 
FileCheck %s --check-prefix=DETERMINISTIC-VALUES
 
 ## Check arguments can be passed before and after the file name
 # RUN: cp %t-no-index.a %t.a && llvm-ranlib -U %t.a -D -U
@@ -41,5 +41,8 @@
 # RUN: not llvm-ranlib -DxD %t.a 2>&1 | FileCheck %s --check-prefix=BAD-OPT-xD
 # BAD-OPT-xD: error: Invalid option: '-xD'
 
-# DETERMINISTIC-VALUES: {{[rwx-]+}} 0/0712 Jan  1 00:00 1970 
D-flag.test.tmp.o
+## llvm-ar uses localtime to print the object timestamp and it is subject to
+## UTC offset (daylight for instance).
+# DETERMINISTIC-VALUES: [[HHMM:[0-9]+:[0-9]+]]
+# DETERMINISTIC-VALUES: {{[rwx-]+}} 0/0712 Jan  1 [[HHMM]] 1970 
D-flag.test.tmp.o
 # REAL-VALUES: {{[rwx-]+}} {{[0-9]+}}/{{[0-9]+}} 712 Jan  2 03:04 2000 
D-flag.test.tmp.o


Index: llvm/test/tools/llvm-ranlib/D-flag.test
===
--- llvm/test/tools/llvm-ranlib/D-flag.test
+++ llvm/test/tools/llvm-ranlib/D-flag.test
@@ -10,7 +10,7 @@
 
 ## Check that the -D flag clears the timestamps:
 # RUN: cp %t-no-index.a %t.a && llvm-ranlib -D %t.a
-# RUN: env TZ=UTC llvm-ar tv %t.a | FileCheck %s --check-prefix=DETERMINISTIC-VALUES
+# RUN: (env TZ=UTC date -d '@0' +%H:%M; env TZ=UTC llvm-ar tv %t.a) | FileCheck %s --check-prefix=DETERMINISTIC-VALUES
 
 ## Check that the -U flag maintains the timestamps:
 # RUN: cp %t-no-index.a %t.a && llvm-ranlib -U %t.a
@@ -20,7 +20,7 @@
 # RUN: cp %t-no-index.a %t.a && llvm-ranlib -UDU %t.a
 # RUN: env TZ=UTC llvm-ar tv %t.a | FileCheck %s --check-prefix=REAL-VALUES
 # RUN: cp %t-no-index.a %t.a && llvm-ranlib -UUD %t.a
-# RUN: env TZ=UTC llvm-ar tv %t.a | FileCheck %s --check-prefix=DETERMINISTIC-VALUES
+# RUN: (env TZ=UTC date -d '@0' +%H:%M; env TZ=UTC llvm-ar tv %t.a) | FileCheck %s --check-prefix=DETERMINISTIC-VALUES
 
 ## Check arguments can be passed before and after the file name
 # RUN: cp %t-no-index.a %t.a && llvm-ranlib -U %t.a -D -U
@@ -41,5 +41,8 @@
 # RUN: not llvm-ranlib -DxD %t.a 2>&1 | FileCheck %s --check-prefix=BAD-OPT-xD
 # BAD-OPT-xD: error: Invalid option: '-xD'
 
-# DETERMINISTIC-VALUES: {{[rwx-]+}} 0/0712 Jan  1 00:00 1970 D-flag.test.tmp.o
+## llvm-ar uses localtime to print the object timestamp and it is subject to
+## UTC offset (daylight for instance).
+# DETERMINISTIC-VALUES: [[HHMM:[0-9]+:[0-9]+]]
+# DETERMINISTIC-VALUES: {{[rwx-]+}} 0/0712 Jan  1 [[HHMM]] 1970 D-flag.test.tmp.o
 # REAL-VALUES: {{[rwx-]+}} {{[0-9]+}}/{{[0-9]+}} 712 Jan  2 03:04 2000 D-flag.test.tmp.o
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D72449: [PATCH] [llvm-ranlib] Take in consideration UTC offset for D-flag.test

2020-01-09 Thread Adhemerval Zanella via Phabricator via cfe-commits
zatrazz added a comment.

In D72449#1812130 , @arichardson wrote:

> I was careful in the test to use `TZ=UTC` for all commands printing dates and 
> it works fine for me in UTC+1 and in the UK which is currently UTC. Does the 
> bot in question ignore the TZ variable?


The issue is setting TZ=UTC still might use internal database with UTC offsets. 
For instance, on the buildbot
that accused the regression, setting TZ=UTC make it use the tz database 
/usr/share/zoneinfo/UTC. At least
on Linux with glibc one way to actually use UTC without transit changes are to 
set TZ=":", it won't try to
access either the default '/etc/localtime'. However, I am not sure how portable 
it is and it might be in fact
an glibc issue (https://sourceware.org/bugzilla/show_bug.cgi?id=24004).


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72449/new/

https://reviews.llvm.org/D72449



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D72449: [PATCH] [llvm-ranlib] Take in consideration UTC offset for D-flag.test

2020-01-09 Thread Adhemerval Zanella via Phabricator via cfe-commits
zatrazz added a comment.

In D72449#1812818 , @arichardson wrote:

> I'm fine with this workaround although I'm very surprised that the test is 
> not working. Especially since `deterministic-archive.test` and 
> `replace-update.test` also set TZ to get reproducible output
>
> Do you have access to any of the failing bots? If so what happens there if 
> you change the TZ variable?
>  I get the following on all systems I have access to when I run something 
> like `date && date -u && env TZ=CET date && env TZ=CET date -u && env TZ=BST 
> date && env TZ=BST date -u` I get the following output:
>
>   Thu  9 Jan 2020 20:18:10 GMT
>   Thu  9 Jan 2020 20:18:10 UTC
>   Thu  9 Jan 2020 21:18:10 CET
>   Thu  9 Jan 2020 20:18:10 UTC
>   Thu  9 Jan 2020 20:18:10 UTC
>   Thu  9 Jan 2020 20:18:10 UTC
>


I am not sure now if it was something wrong with the bot tzdata, I reinstalled 
the tzdata packages
and reconfigured the timezone and now 'TZ=UTC date -d '@0' +%H:%M' does show 
the expected
00:00.

Indeed, although the workaround shouldn't change the expected result, the issue 
I am observing
on some machine does not make sense (TZ=UTC date -d '@0' +%H:%M' not showing 
00:00).

I will hold this and investigate further.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72449/new/

https://reviews.llvm.org/D72449



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D96803: EntryExitInstrumenter: Move to a module pass and enable at all optimization levels (PR49143)

2021-02-16 Thread Adhemerval Zanella via Phabricator via cfe-commits
zatrazz created this revision.
zatrazz added reviewers: lenary, ostannard, aeubanks.
Herald added a subscriber: hiraditya.
zatrazz requested review of this revision.
Herald added projects: clang, LLVM.

The function passes are disabled by default for optnone with the new
pass manager.  The pass is now enabled in clang backend if the
-finstrument-functions, -finstrument-function-entry-bare, or
-finstrument-functions-after-inlining instead of just for
optimization level different than -O0.

It fixes PR49143 and allows re-enable the eeprof-1.c test from
test-suite (disabled by D96521 ).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D96803

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  llvm/include/llvm/Transforms/Utils/EntryExitInstrumenter.h
  llvm/lib/Passes/PassRegistry.def
  llvm/lib/Transforms/Utils/EntryExitInstrumenter.cpp
  llvm/test/Transforms/EntryExitInstrumenter/debug-info.ll
  llvm/test/Transforms/EntryExitInstrumenter/mcount.ll

Index: llvm/test/Transforms/EntryExitInstrumenter/mcount.ll
===
--- llvm/test/Transforms/EntryExitInstrumenter/mcount.ll
+++ llvm/test/Transforms/EntryExitInstrumenter/mcount.ll
@@ -1,7 +1,10 @@
-; RUN: opt -passes="function(ee-instrument),cgscc(inline),function(post-inline-ee-instrument)" -S < %s | FileCheck %s
+; RUN: opt --O0 --ee-instrument --inline --post-inline-ee-instrument -S < %s | FileCheck %s
+
+; Check if the pass is enabbled on both -O0 and higher optimization levels
+; RUN: opt --O2 --ee-instrument --post-inline-ee-instrument -S < %s | FileCheck --check-prefix=OPT %s
 
 ; Running the passes twice should not result in more instrumentation.
-; RUN: opt -passes="function(ee-instrument),function(ee-instrument),cgscc(inline),function(post-inline-ee-instrument),function(post-inline-ee-instrument)" -S < %s | FileCheck %s
+; RUN: opt -passes="ee-instrument,ee-instrument,cgscc(inline),post-inline-ee-instrument,post-inline-ee-instrument" -S < %s | FileCheck %s
 
 target datalayout = "E-m:e-i64:64-n32:64"
 target triple = "powerpc64le-unknown-linux"
@@ -18,6 +21,15 @@
 ; CHECK-NEXT: %1 = call i8* @llvm.returnaddress(i32 0)
 ; CHECK-NEXT: call void @__cyg_profile_func_exit(i8* bitcast (void ()* @leaf_function to i8*), i8* %1)
 ; CHECK-NEXT: ret void
+
+; OPT-LABEL: define void @leaf_function()
+; OPT: entry:
+; OPT-NEXT: call void @mcount()
+; OPT-NEXT: %0 = call i8* @llvm.returnaddress(i32 0)
+; OPT-NEXT: call void @__cyg_profile_func_enter(i8* bitcast (void ()* @leaf_function to i8*), i8* %0)
+; OPT-NEXT: %1 = call i8* @llvm.returnaddress(i32 0)
+; OPT-NEXT: call void @__cyg_profile_func_exit(i8* bitcast (void ()* @leaf_function to i8*), i8* %1)
+; OPT-NEXT: ret void
 }
 
 
@@ -42,6 +54,16 @@
 
 ; CHECK-NEXT: call void @__cyg_profile_func_exit(i8* bitcast (void ()* @root_function to i8*), i8* %3)
 ; CHECK-NEXT: ret void
+
+; OPT-LABEL: define void @root_function()
+; OPT: entry:
+; OPT-NEXT: call void @mcount()
+
+; OPT-NEXT: %0 = call i8* @llvm.returnaddress(i32 0)
+; OPT-NEXT: call void @__cyg_profile_func_enter(i8* bitcast (void ()* @root_function to i8*), i8* %0)
+; OPT-NEXT: %1 = call i8* @llvm.returnaddress(i32 0)
+; OPT-NEXT: call void @__cyg_profile_func_exit(i8* bitcast (void ()* @root_function to i8*), i8* %1)
+; OPT-NEXT: ret void
 }
 
 
Index: llvm/test/Transforms/EntryExitInstrumenter/debug-info.ll
===
--- llvm/test/Transforms/EntryExitInstrumenter/debug-info.ll
+++ llvm/test/Transforms/EntryExitInstrumenter/debug-info.ll
@@ -1,4 +1,4 @@
-; RUN: opt -passes="function(ee-instrument),cgscc(inline),function(post-inline-ee-instrument)" -S < %s | FileCheck %s
+; RUN: opt -passes="ee-instrument,cgscc(inline),post-inline-ee-instrument" -S < %s | FileCheck %s
 
 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
 target triple = "x86_64-unknown-linux-gnu"
Index: llvm/lib/Transforms/Utils/EntryExitInstrumenter.cpp
===
--- llvm/lib/Transforms/Utils/EntryExitInstrumenter.cpp
+++ llvm/lib/Transforms/Utils/EntryExitInstrumenter.cpp
@@ -176,9 +176,12 @@
   return new PostInlineEntryExitInstrumenter();
 }
 
-PreservedAnalyses
-llvm::EntryExitInstrumenterPass::run(Function &F, FunctionAnalysisManager &AM) {
-  runOnFunction(F, PostInlining);
+PreservedAnalyses llvm::EntryExitInstrumenterPass::run(Module &M,
+   ModuleAnalysisManager &MAM) {
+  for (Function &F : M) {
+runOnFunction(F, PostInlining);
+  }
+
   PreservedAnalyses PA;
   PA.preserveSet();
   return PA;
Index: llvm/lib/Passes/PassRegistry.def
===
--- llvm/lib/Passes/PassRegistry.def
+++ llvm/lib/Passes/PassRegistry.def
@@ -120,6 +120,8 @@
 MODULE_PASS("memprof-module", ModuleMemProfilerPass())
 MODULE_PASS("poison-checking", PoisonCheckingPas

[PATCH] D96803: EntryExitInstrumenter: Move to a module pass and enable at all optimization levels (PR49143)

2021-02-17 Thread Adhemerval Zanella via Phabricator via cfe-commits
zatrazz added a comment.

In D96803#2566322 , @aeubanks wrote:

> why is this now a module pass?

Mainly to avoid the default rule from new pass manager to *not* apply any 
FunctionPass for optnone (which is the main issue for PR49143). Is there a 
better way to accomplish it? I noted also that 
createModuleToFunctionPassAdaptor basically creates a adaptor that applies the 
pass to all function on the module.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D96803/new/

https://reviews.llvm.org/D96803

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D96803: EntryExitInstrumenter: Move to a module pass and enable at all optimization levels (PR49143)

2021-02-18 Thread Adhemerval Zanella via Phabricator via cfe-commits
zatrazz added a comment.

In D96803#2569436 , @aeubanks wrote:

> In D96803#2568179 , @zatrazz wrote:
>
>> In D96803#2566322 , @aeubanks wrote:
>>
>>> why is this now a module pass?
>>
>> Mainly to avoid the default rule from new pass manager to *not* apply any 
>> FunctionPass for optnone (which is the main issue for PR49143). Is there a 
>> better way to accomplish it? I noted also that 
>> createModuleToFunctionPassAdaptor basically creates a adaptor that applies 
>> the pass to all function on the module.
>
> It's always good to make the pass as specific as possible (e.g. prefer a 
> function pass rather than a module pass) so it doesn't have to worry about 
> infra. For example, just iterating over functions doesn't skip declarations.

I modeled it after AlwaysInlinerPass, since it seems that it was enabled at -O0 
as well. To keep EntryExitInstrumenterPass a function pass and enable it with 
-O0 I think we will need a way to communicate to the pass manager that the pass 
should be run even with optnone, my understanding was that a ModulePass will 
the way to do it. Do we have a way to advertise that a function pass should be 
run regardless of ' optnone' ?

> The whole point of `isRequired()` is to make the pass always run when it's 
> added to the pipeline, so making it a module pass shouldn't be necessary with 
> that line.

Indeed, I have added to fix a testcase but it does seem unrequired. I will 
remove it.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D96803/new/

https://reviews.llvm.org/D96803

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D96803: EntryExitInstrumenter: Enable at all optimization levels (PR49143)

2021-02-19 Thread Adhemerval Zanella via Phabricator via cfe-commits
zatrazz updated this revision to Diff 325004.
zatrazz retitled this revision from "EntryExitInstrumenter: Move to a module 
pass and enable at all optimization levels (PR49143)" to 
"EntryExitInstrumenter: Enable at all optimization levels (PR49143)".
zatrazz edited the summary of this revision.
zatrazz added a comment.

Updated patch based on previous comments.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D96803/new/

https://reviews.llvm.org/D96803

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  llvm/include/llvm/Transforms/Utils/EntryExitInstrumenter.h
  llvm/test/Transforms/EntryExitInstrumenter/mcount.ll


Index: llvm/test/Transforms/EntryExitInstrumenter/mcount.ll
===
--- llvm/test/Transforms/EntryExitInstrumenter/mcount.ll
+++ llvm/test/Transforms/EntryExitInstrumenter/mcount.ll
@@ -1,4 +1,7 @@
-; RUN: opt 
-passes="function(ee-instrument),cgscc(inline),function(post-inline-ee-instrument)"
 -S < %s | FileCheck %s
+; RUN: opt --O0 --ee-instrument --inline --post-inline-ee-instrument -S < %s | 
FileCheck %s
+
+; Check if the pass is enabbled on both -O0 and higher optimization levels
+; RUN: opt --O2 --ee-instrument --post-inline-ee-instrument -S < %s | 
FileCheck --check-prefix=OPT %s
 
 ; Running the passes twice should not result in more instrumentation.
 ; RUN: opt 
-passes="function(ee-instrument),function(ee-instrument),cgscc(inline),function(post-inline-ee-instrument),function(post-inline-ee-instrument)"
 -S < %s | FileCheck %s
@@ -18,6 +21,15 @@
 ; CHECK-NEXT: %1 = call i8* @llvm.returnaddress(i32 0)
 ; CHECK-NEXT: call void @__cyg_profile_func_exit(i8* bitcast (void ()* 
@leaf_function to i8*), i8* %1)
 ; CHECK-NEXT: ret void
+
+; OPT-LABEL: define void @leaf_function()
+; OPT: entry:
+; OPT-NEXT: call void @mcount()
+; OPT-NEXT: %0 = call i8* @llvm.returnaddress(i32 0)
+; OPT-NEXT: call void @__cyg_profile_func_enter(i8* bitcast (void ()* 
@leaf_function to i8*), i8* %0)
+; OPT-NEXT: %1 = call i8* @llvm.returnaddress(i32 0)
+; OPT-NEXT: call void @__cyg_profile_func_exit(i8* bitcast (void ()* 
@leaf_function to i8*), i8* %1)
+; OPT-NEXT: ret void
 }
 
 
@@ -42,6 +54,16 @@
 
 ; CHECK-NEXT: call void @__cyg_profile_func_exit(i8* bitcast (void ()* 
@root_function to i8*), i8* %3)
 ; CHECK-NEXT: ret void
+
+; OPT-LABEL: define void @root_function()
+; OPT: entry:
+; OPT-NEXT: call void @mcount()
+
+; OPT-NEXT: %0 = call i8* @llvm.returnaddress(i32 0)
+; OPT-NEXT: call void @__cyg_profile_func_enter(i8* bitcast (void ()* 
@root_function to i8*), i8* %0)
+; OPT-NEXT: %1 = call i8* @llvm.returnaddress(i32 0)
+; OPT-NEXT: call void @__cyg_profile_func_exit(i8* bitcast (void ()* 
@root_function to i8*), i8* %1)
+; OPT-NEXT: ret void
 }
 
 
Index: llvm/include/llvm/Transforms/Utils/EntryExitInstrumenter.h
===
--- llvm/include/llvm/Transforms/Utils/EntryExitInstrumenter.h
+++ llvm/include/llvm/Transforms/Utils/EntryExitInstrumenter.h
@@ -19,8 +19,6 @@
 
 namespace llvm {
 
-class Function;
-
 struct EntryExitInstrumenterPass
 : public PassInfoMixin {
   EntryExitInstrumenterPass(bool PostInlining) : PostInlining(PostInlining) {}
@@ -28,6 +26,8 @@
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
 
   bool PostInlining;
+
+  static bool isRequired() { return true; }
 };
 
 } // namespace llvm
Index: clang/lib/CodeGen/BackendUtil.cpp
===
--- clang/lib/CodeGen/BackendUtil.cpp
+++ clang/lib/CodeGen/BackendUtil.cpp
@@ -1312,7 +1312,9 @@
/*DropTypeTests=*/true));
   });
 
-if (Level != PassBuilder::OptimizationLevel::O0) {
+if (CodeGenOpts.InstrumentFunctions ||
+CodeGenOpts.InstrumentFunctionsAfterInlining ||
+CodeGenOpts.InstrumentFunctionEntryBare) {
   PB.registerPipelineStartEPCallback(
   [](ModulePassManager &MPM, PassBuilder::OptimizationLevel Level) {
 MPM.addPass(createModuleToFunctionPassAdaptor(


Index: llvm/test/Transforms/EntryExitInstrumenter/mcount.ll
===
--- llvm/test/Transforms/EntryExitInstrumenter/mcount.ll
+++ llvm/test/Transforms/EntryExitInstrumenter/mcount.ll
@@ -1,4 +1,7 @@
-; RUN: opt -passes="function(ee-instrument),cgscc(inline),function(post-inline-ee-instrument)" -S < %s | FileCheck %s
+; RUN: opt --O0 --ee-instrument --inline --post-inline-ee-instrument -S < %s | FileCheck %s
+
+; Check if the pass is enabbled on both -O0 and higher optimization levels
+; RUN: opt --O2 --ee-instrument --post-inline-ee-instrument -S < %s | FileCheck --check-prefix=OPT %s
 
 ; Running the passes twice should not result in more instrumentation.
 ; RUN: opt -passes="function(ee-instrument),function(ee-instrument),cgscc(inline),function(post-inline-ee-instrument),function(post-inline-ee-instrument)" -S < %s | FileCheck 

[PATCH] D137267: [clang][Headers] Only define FLT_EVAL_METHOD for C99 and later

2022-11-02 Thread Adhemerval Zanella via Phabricator via cfe-commits
zatrazz created this revision.
zatrazz added reviewers: jfb, eli.friedman, MaskRay.
Herald added a subscriber: StephenFan.
Herald added a project: All.
zatrazz requested review of this revision.
Herald added a project: clang.

It was reported by glibc conform test [1].

[1] 
https://sourceware.org/git/?p=glibc.git;a=blob;f=conform/data/float.h-data;h=7b98fc03447b8918da4a0cf47d41fb3e17f4f791;hb=HEAD


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D137267

Files:
  clang/lib/Headers/float.h


Index: clang/lib/Headers/float.h
===
--- clang/lib/Headers/float.h
+++ clang/lib/Headers/float.h
@@ -86,7 +86,10 @@
 
 /* Characteristics of floating point types, C99 5.2.4.2.2 */
 
+#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) ||  
\
+(defined(__cplusplus) && __cplusplus >= 201103L)
 #define FLT_EVAL_METHOD __FLT_EVAL_METHOD__
+#endif
 #define FLT_ROUNDS (__builtin_flt_rounds())
 #define FLT_RADIX __FLT_RADIX__
 


Index: clang/lib/Headers/float.h
===
--- clang/lib/Headers/float.h
+++ clang/lib/Headers/float.h
@@ -86,7 +86,10 @@
 
 /* Characteristics of floating point types, C99 5.2.4.2.2 */
 
+#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) ||  \
+(defined(__cplusplus) && __cplusplus >= 201103L)
 #define FLT_EVAL_METHOD __FLT_EVAL_METHOD__
+#endif
 #define FLT_ROUNDS (__builtin_flt_rounds())
 #define FLT_RADIX __FLT_RADIX__
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D137268: [clang][Headers] Do not define varargs macros for __need___va_list

2022-11-02 Thread Adhemerval Zanella via Phabricator via cfe-commits
zatrazz created this revision.
zatrazz added reviewers: jfb, eli.friedman, MaskRay.
Herald added subscribers: Enna1, StephenFan.
Herald added a project: All.
zatrazz requested review of this revision.
Herald added projects: clang, Sanitizers.
Herald added a subscriber: Sanitizers.

The glibc uses the define to avoid namespace polution on headers
that requires variadic argument, where the inclusion of stdarg.h is
required to obtain the va_list definition.

For such cases only __gnuc_va_list is required.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D137268

Files:
  clang/lib/Headers/stdarg.h
  compiler-rt/test/sanitizer_common/TestCases/Linux/signal_send.cpp


Index: compiler-rt/test/sanitizer_common/TestCases/Linux/signal_send.cpp
===
--- compiler-rt/test/sanitizer_common/TestCases/Linux/signal_send.cpp
+++ compiler-rt/test/sanitizer_common/TestCases/Linux/signal_send.cpp
@@ -5,6 +5,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
Index: clang/lib/Headers/stdarg.h
===
--- clang/lib/Headers/stdarg.h
+++ clang/lib/Headers/stdarg.h
@@ -8,7 +8,17 @@
  */
 
 #ifndef __STDARG_H
+#ifndef __need___va_list
 #define __STDARG_H
+#endif /* __need___va_list */
+#undef __need___va_list
+
+#ifndef __GNUC_VA_LIST
+#define __GNUC_VA_LIST 1
+typedef __builtin_va_list __gnuc_va_list;
+#endif
+
+#ifdef __STDARG_H
 
 #ifndef _VA_LIST
 typedef __builtin_va_list va_list;
@@ -29,9 +39,6 @@
 #define va_copy(dest, src)  __builtin_va_copy(dest, src)
 #endif
 
-#ifndef __GNUC_VA_LIST
-#define __GNUC_VA_LIST 1
-typedef __builtin_va_list __gnuc_va_list;
-#endif
-
 #endif /* __STDARG_H */
+
+#endif /* not __STDARG_H */


Index: compiler-rt/test/sanitizer_common/TestCases/Linux/signal_send.cpp
===
--- compiler-rt/test/sanitizer_common/TestCases/Linux/signal_send.cpp
+++ compiler-rt/test/sanitizer_common/TestCases/Linux/signal_send.cpp
@@ -5,6 +5,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
Index: clang/lib/Headers/stdarg.h
===
--- clang/lib/Headers/stdarg.h
+++ clang/lib/Headers/stdarg.h
@@ -8,7 +8,17 @@
  */
 
 #ifndef __STDARG_H
+#ifndef __need___va_list
 #define __STDARG_H
+#endif /* __need___va_list */
+#undef __need___va_list
+
+#ifndef __GNUC_VA_LIST
+#define __GNUC_VA_LIST 1
+typedef __builtin_va_list __gnuc_va_list;
+#endif
+
+#ifdef __STDARG_H
 
 #ifndef _VA_LIST
 typedef __builtin_va_list va_list;
@@ -29,9 +39,6 @@
 #define va_copy(dest, src)  __builtin_va_copy(dest, src)
 #endif
 
-#ifndef __GNUC_VA_LIST
-#define __GNUC_VA_LIST 1
-typedef __builtin_va_list __gnuc_va_list;
-#endif
-
 #endif /* __STDARG_H */
+
+#endif /* not __STDARG_H */
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D137267: [clang][Headers] Only define FLT_EVAL_METHOD for C99 and later

2022-11-08 Thread Adhemerval Zanella via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG92e172309cf6: [clang][Headers] Only define FLT_EVAL_METHOD 
for C99 and later (authored by zatrazz).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137267/new/

https://reviews.llvm.org/D137267

Files:
  clang/lib/Headers/float.h


Index: clang/lib/Headers/float.h
===
--- clang/lib/Headers/float.h
+++ clang/lib/Headers/float.h
@@ -86,7 +86,10 @@
 
 /* Characteristics of floating point types, C99 5.2.4.2.2 */
 
+#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) ||  
\
+(defined(__cplusplus) && __cplusplus >= 201103L)
 #define FLT_EVAL_METHOD __FLT_EVAL_METHOD__
+#endif
 #define FLT_ROUNDS (__builtin_flt_rounds())
 #define FLT_RADIX __FLT_RADIX__
 


Index: clang/lib/Headers/float.h
===
--- clang/lib/Headers/float.h
+++ clang/lib/Headers/float.h
@@ -86,7 +86,10 @@
 
 /* Characteristics of floating point types, C99 5.2.4.2.2 */
 
+#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) ||  \
+(defined(__cplusplus) && __cplusplus >= 201103L)
 #define FLT_EVAL_METHOD __FLT_EVAL_METHOD__
+#endif
 #define FLT_ROUNDS (__builtin_flt_rounds())
 #define FLT_RADIX __FLT_RADIX__
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D137268: [clang][Headers] Do not define varargs macros for __need___va_list

2022-11-08 Thread Adhemerval Zanella via Phabricator via cfe-commits
zatrazz marked 2 inline comments as done.
zatrazz added inline comments.



Comment at: clang/lib/Headers/stdarg.h:17
+#ifndef __GNUC_VA_LIST
+#define __GNUC_VA_LIST 1
+typedef __builtin_va_list __gnuc_va_list;

MaskRay wrote:
> To match gcc stdarg.h, `#define __GNUC_VA_LIST`
Ack.



Comment at: clang/lib/Headers/stdarg.h:21
+
+#ifdef __STDARG_H
 

efriedma wrote:
> Maybe the following is a little more readable?
> 
> ```
> #ifndef __STDARG_H
> 
> #ifndef __GNUC_VA_LIST
> #define __GNUC_VA_LIST 1
> typedef __builtin_va_list __gnuc_va_list;
> #endif
> 
> #ifdef __need___va_list
> #undef __need___va_list
> #else
> #define __STDARG_H
> [...]
> ```
Ack.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137268/new/

https://reviews.llvm.org/D137268

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D137268: [clang][Headers] Do not define varargs macros for __need___va_list

2022-11-08 Thread Adhemerval Zanella via Phabricator via cfe-commits
zatrazz updated this revision to Diff 474028.
zatrazz marked 2 inline comments as done.
zatrazz added a comment.

Update review based on reviewers comments.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137268/new/

https://reviews.llvm.org/D137268

Files:
  clang/lib/Headers/stdarg.h
  compiler-rt/test/sanitizer_common/TestCases/Linux/signal_send.cpp


Index: compiler-rt/test/sanitizer_common/TestCases/Linux/signal_send.cpp
===
--- compiler-rt/test/sanitizer_common/TestCases/Linux/signal_send.cpp
+++ compiler-rt/test/sanitizer_common/TestCases/Linux/signal_send.cpp
@@ -5,6 +5,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
Index: clang/lib/Headers/stdarg.h
===
--- clang/lib/Headers/stdarg.h
+++ clang/lib/Headers/stdarg.h
@@ -8,8 +8,16 @@
  */
 
 #ifndef __STDARG_H
-#define __STDARG_H
 
+#ifndef __GNUC_VA_LIST
+#define __GNUC_VA_LIST
+typedef __builtin_va_list __gnuc_va_list;
+#endif
+
+#ifdef __need___va_list
+#undef __need___va_list
+#else
+#define __STDARG_H
 #ifndef _VA_LIST
 typedef __builtin_va_list va_list;
 #define _VA_LIST
@@ -29,9 +37,6 @@
 #define va_copy(dest, src)  __builtin_va_copy(dest, src)
 #endif
 
-#ifndef __GNUC_VA_LIST
-#define __GNUC_VA_LIST 1
-typedef __builtin_va_list __gnuc_va_list;
-#endif
-
 #endif /* __STDARG_H */
+
+#endif /* not __STDARG_H */


Index: compiler-rt/test/sanitizer_common/TestCases/Linux/signal_send.cpp
===
--- compiler-rt/test/sanitizer_common/TestCases/Linux/signal_send.cpp
+++ compiler-rt/test/sanitizer_common/TestCases/Linux/signal_send.cpp
@@ -5,6 +5,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
Index: clang/lib/Headers/stdarg.h
===
--- clang/lib/Headers/stdarg.h
+++ clang/lib/Headers/stdarg.h
@@ -8,8 +8,16 @@
  */
 
 #ifndef __STDARG_H
-#define __STDARG_H
 
+#ifndef __GNUC_VA_LIST
+#define __GNUC_VA_LIST
+typedef __builtin_va_list __gnuc_va_list;
+#endif
+
+#ifdef __need___va_list
+#undef __need___va_list
+#else
+#define __STDARG_H
 #ifndef _VA_LIST
 typedef __builtin_va_list va_list;
 #define _VA_LIST
@@ -29,9 +37,6 @@
 #define va_copy(dest, src)  __builtin_va_copy(dest, src)
 #endif
 
-#ifndef __GNUC_VA_LIST
-#define __GNUC_VA_LIST 1
-typedef __builtin_va_list __gnuc_va_list;
-#endif
-
 #endif /* __STDARG_H */
+
+#endif /* not __STDARG_H */
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D137268: [clang][Headers] Do not define varargs macros for __need___va_list

2022-11-08 Thread Adhemerval Zanella via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9e956995db1f: [clang][Headers] Do not define varargs macros 
for __need___va_list (authored by zatrazz).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137268/new/

https://reviews.llvm.org/D137268

Files:
  clang/lib/Headers/stdarg.h
  compiler-rt/test/sanitizer_common/TestCases/Linux/signal_send.cpp


Index: compiler-rt/test/sanitizer_common/TestCases/Linux/signal_send.cpp
===
--- compiler-rt/test/sanitizer_common/TestCases/Linux/signal_send.cpp
+++ compiler-rt/test/sanitizer_common/TestCases/Linux/signal_send.cpp
@@ -5,6 +5,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
Index: clang/lib/Headers/stdarg.h
===
--- clang/lib/Headers/stdarg.h
+++ clang/lib/Headers/stdarg.h
@@ -8,8 +8,16 @@
  */
 
 #ifndef __STDARG_H
-#define __STDARG_H
 
+#ifndef __GNUC_VA_LIST
+#define __GNUC_VA_LIST
+typedef __builtin_va_list __gnuc_va_list;
+#endif
+
+#ifdef __need___va_list
+#undef __need___va_list
+#else
+#define __STDARG_H
 #ifndef _VA_LIST
 typedef __builtin_va_list va_list;
 #define _VA_LIST
@@ -29,9 +37,6 @@
 #define va_copy(dest, src)  __builtin_va_copy(dest, src)
 #endif
 
-#ifndef __GNUC_VA_LIST
-#define __GNUC_VA_LIST 1
-typedef __builtin_va_list __gnuc_va_list;
-#endif
-
 #endif /* __STDARG_H */
+
+#endif /* not __STDARG_H */


Index: compiler-rt/test/sanitizer_common/TestCases/Linux/signal_send.cpp
===
--- compiler-rt/test/sanitizer_common/TestCases/Linux/signal_send.cpp
+++ compiler-rt/test/sanitizer_common/TestCases/Linux/signal_send.cpp
@@ -5,6 +5,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
Index: clang/lib/Headers/stdarg.h
===
--- clang/lib/Headers/stdarg.h
+++ clang/lib/Headers/stdarg.h
@@ -8,8 +8,16 @@
  */
 
 #ifndef __STDARG_H
-#define __STDARG_H
 
+#ifndef __GNUC_VA_LIST
+#define __GNUC_VA_LIST
+typedef __builtin_va_list __gnuc_va_list;
+#endif
+
+#ifdef __need___va_list
+#undef __need___va_list
+#else
+#define __STDARG_H
 #ifndef _VA_LIST
 typedef __builtin_va_list va_list;
 #define _VA_LIST
@@ -29,9 +37,6 @@
 #define va_copy(dest, src)  __builtin_va_copy(dest, src)
 #endif
 
-#ifndef __GNUC_VA_LIST
-#define __GNUC_VA_LIST 1
-typedef __builtin_va_list __gnuc_va_list;
-#endif
-
 #endif /* __STDARG_H */
+
+#endif /* not __STDARG_H */
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D137268: [clang][Headers] Do not define varargs macros for __need___va_list

2023-01-20 Thread Adhemerval Zanella via Phabricator via cfe-commits
zatrazz added a comment.

In D137268#4069779 , @enh wrote:

> is there a corresponding glibc change so that `va_list` is exported for 
> `_POSIX_SOURCE` cases? see 
> https://android-review.git.corp.google.com/c/platform/bionic/+/2397313 where 
> i'm having to disable some bionic testing against glibc because the glibc 
> (2.17!)  now no longer exports `va_list`. i did look for a ToT glibc 
> patch to backport (until we've _actually_ switched from glibc to musl for the 
> host), but couldn't obviously find it?
>
> https://pubs.opengroup.org/onlinepubs/9699919799.2018edition/basedefs/wchar.h.html
>  says:
> """
> The  header shall define the following types:
> ...
> va_list
> [CX] As described in .
> """
> which is why i think our " exports `va_list`" test is correct. 
> (Android doesn't support an "ISO only" mode --- you're effectively always in 
> `_POSIX_SOURCE` mode, so we build the test against glibc with `_POSIX_SOURCE` 
> defined.)

I think I have caught this because your standard conformance tests checks for 
__gnuc_va_list 
on wchar.h, wich is always defined on on GCC (git log shows it was changed to 
fix XPG7 
tests, but I am not sure exactly why the author has changed the va_list to 
__gnuc_va_list).

And it seems that glibc seems broken also using GCC stdarg.h if I fix the test 
to check for
va_list instead. I will take a look at this.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137268/new/

https://reviews.llvm.org/D137268

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D137268: [clang][Headers] Do not define varargs macros for __need___va_list

2023-01-20 Thread Adhemerval Zanella via Phabricator via cfe-commits
zatrazz added a comment.

In D137268#4069935 , @enh wrote:

> In D137268#4069856 , @zatrazz wrote:
>
>> I think I have caught this because your standard conformance tests checks 
>> for __gnuc_va_list 
>> on wchar.h, wich is always defined on on GCC (git log shows it was changed 
>> to fix XPG7 
>> tests, but I am not sure exactly why the author has changed the va_list to 
>> __gnuc_va_list).
>
> bionic's tests check for `va_list`, because that's what POSIX says will be 
> visible. ISO C doesn't say that, so i think the _intention_ for glibc -- musl 
> seems to do this correctly -- is to say "if we're only compiling C source, 
> you don't get `va_list`, but if we're compiling POSIX source, you do get 
> `va_list`". so i think this `__gnuc_va_list` thing is their workaround to 
> still export the _functions_ without exporting the _type_ for ISO C?

Indeed the __gnuc_va_list is used when building for c99/c11, since va_list 
should not be defined in such cases. It seems also that glibc stdio.h does 
handle it by defining __gnuc_va_list to va_list if POSIX2001 or POSIX2008 is 
used (-D_XOPEN_SOURCE=600 or -D_XOPEN_SOURCE=700), so I think we should do the 
same for wchar.h

> here's the bionic *POSIX* test: 
> https://cs.android.com/android/platform/superproject/+/master:bionic/tests/headers/posix/wchar_h.c;l=38
>  (but note that you'll have to look at the corresponding Android.bp file to 
> see us define `_POSIX_SOURCE`.) note that our tests pass against _bionic_ 
> (and, i think, musl). it's just old-glibc-with-new-llvm they fail against.
>
>> And it seems that glibc seems broken also using GCC stdarg.h if I fix the 
>> test to check for
>> va_list instead. I will take a look at this.
>
> thanks!

Could you check if this fixes your issue? I am not sure if if applies cleans to 
the ancient glibc 2.17 you are using:

  diff --git a/conform/data/wchar.h-data b/conform/data/wchar.h-data
  index e414651a33..582a99c00b 100644
  --- a/conform/data/wchar.h-data
  +++ b/conform/data/wchar.h-data
  @@ -15,6 +15,9 @@ type size_t
   type locale_t
   # endif
   tag {struct tm}
  +#if !defined ISO && !defined ISO99 && !defined ISO11 && !defined POSIX && 
!defined UNIX98
  +type va_list
  +#endif
  
   function wint_t btowc (int)
   function int fwprintf (FILE*, const wchar_t*, ...)
  diff --git a/wcsmbs/wchar.h b/wcsmbs/wchar.h
  index 69e920b8c2..ca145bb8d2 100644
  --- a/wcsmbs/wchar.h
  +++ b/wcsmbs/wchar.h
  @@ -37,6 +37,17 @@
   #define __need___va_list
   #include 
  
  +#if defined __USE_XOPEN2K || defined __USE_XOPEN2K8
  +# ifdef __GNUC__
  +#  ifndef _VA_LIST_DEFINED
  +typedef __gnuc_va_list va_list;
  +#   define _VA_LIST_DEFINED
  +#  endif
  +# else
  +#  include 
  +# endif
  +#endif
  +
   #include 
   #include 
   #include 

In any case, I will open a bug report on glibc fix on our side.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137268/new/

https://reviews.llvm.org/D137268

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits