[PATCH] D107130: [clangd] Enable relative configs in check mode

2021-07-29 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 362972.
kadircet added a comment.

- Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107130

Files:
  clang-tools-extra/clangd/test/check-fail.test
  clang-tools-extra/clangd/test/check-lines.test
  clang-tools-extra/clangd/test/check.test
  clang-tools-extra/clangd/tool/Check.cpp


Index: clang-tools-extra/clangd/tool/Check.cpp
===
--- clang-tools-extra/clangd/tool/Check.cpp
+++ clang-tools-extra/clangd/tool/Check.cpp
@@ -272,7 +272,7 @@
 
   auto ContextProvider = ClangdServer::createConfiguredContextProvider(
   Opts.ConfigProvider, nullptr);
-  WithContext Ctx(ContextProvider(""));
+  WithContext Ctx(ContextProvider(File));
   Checker C(File, Opts);
   if (!C.buildCommand(TFS) || !C.buildInvocation(TFS, Contents) ||
   !C.buildAST())
Index: clang-tools-extra/clangd/test/check.test
===
--- clang-tools-extra/clangd/test/check.test
+++ clang-tools-extra/clangd/test/check.test
@@ -1,5 +1,5 @@
 // RUN: cp %s %t.cpp
-// RUN: clangd -log=verbose -check=%t.cpp 2>&1 | FileCheck -strict-whitespace 
%s
+// RUN: clangd -enable-config=0 -log=verbose -check=%t.cpp 2>&1 | FileCheck 
-strict-whitespace %s
 
 // CHECK: Testing on source file
 // CHECK: internal (cc1) args are: -cc1
Index: clang-tools-extra/clangd/test/check-lines.test
===
--- clang-tools-extra/clangd/test/check-lines.test
+++ clang-tools-extra/clangd/test/check-lines.test
@@ -1,6 +1,6 @@
 // RUN: cp %s %t.cpp
-// RUN: not clangd -check=%t.cpp -check-lines=6-14 2>&1 | FileCheck 
-strict-whitespace %s
-// RUN: not clangd -check=%t.cpp -check-lines=14 2>&1 | FileCheck 
-strict-whitespace %s
+// RUN: not clangd -enable-config=0 -check=%t.cpp -check-lines=6-14 2>&1 | 
FileCheck -strict-whitespace %s
+// RUN: not clangd -enable-config=0 -check=%t.cpp -check-lines=14 2>&1 | 
FileCheck -strict-whitespace %s
 
 // CHECK: Testing on source file {{.*}}check-lines.test
 // CHECK: internal (cc1) args are: -cc1
Index: clang-tools-extra/clangd/test/check-fail.test
===
--- clang-tools-extra/clangd/test/check-fail.test
+++ clang-tools-extra/clangd/test/check-fail.test
@@ -1,5 +1,5 @@
 // RUN: cp %s %t.cpp
-// RUN: not clangd -check=%t.cpp 2>&1 | FileCheck -strict-whitespace %s
+// RUN: not clangd -enable-config=0 -check=%t.cpp 2>&1 | FileCheck 
-strict-whitespace %s
 
 // CHECK: Testing on source file {{.*}}check-fail.test
 // CHECK: internal (cc1) args are: -cc1


Index: clang-tools-extra/clangd/tool/Check.cpp
===
--- clang-tools-extra/clangd/tool/Check.cpp
+++ clang-tools-extra/clangd/tool/Check.cpp
@@ -272,7 +272,7 @@
 
   auto ContextProvider = ClangdServer::createConfiguredContextProvider(
   Opts.ConfigProvider, nullptr);
-  WithContext Ctx(ContextProvider(""));
+  WithContext Ctx(ContextProvider(File));
   Checker C(File, Opts);
   if (!C.buildCommand(TFS) || !C.buildInvocation(TFS, Contents) ||
   !C.buildAST())
Index: clang-tools-extra/clangd/test/check.test
===
--- clang-tools-extra/clangd/test/check.test
+++ clang-tools-extra/clangd/test/check.test
@@ -1,5 +1,5 @@
 // RUN: cp %s %t.cpp
-// RUN: clangd -log=verbose -check=%t.cpp 2>&1 | FileCheck -strict-whitespace %s
+// RUN: clangd -enable-config=0 -log=verbose -check=%t.cpp 2>&1 | FileCheck -strict-whitespace %s
 
 // CHECK: Testing on source file
 // CHECK: internal (cc1) args are: -cc1
Index: clang-tools-extra/clangd/test/check-lines.test
===
--- clang-tools-extra/clangd/test/check-lines.test
+++ clang-tools-extra/clangd/test/check-lines.test
@@ -1,6 +1,6 @@
 // RUN: cp %s %t.cpp
-// RUN: not clangd -check=%t.cpp -check-lines=6-14 2>&1 | FileCheck -strict-whitespace %s
-// RUN: not clangd -check=%t.cpp -check-lines=14 2>&1 | FileCheck -strict-whitespace %s
+// RUN: not clangd -enable-config=0 -check=%t.cpp -check-lines=6-14 2>&1 | FileCheck -strict-whitespace %s
+// RUN: not clangd -enable-config=0 -check=%t.cpp -check-lines=14 2>&1 | FileCheck -strict-whitespace %s
 
 // CHECK: Testing on source file {{.*}}check-lines.test
 // CHECK: internal (cc1) args are: -cc1
Index: clang-tools-extra/clangd/test/check-fail.test
===
--- clang-tools-extra/clangd/test/check-fail.test
+++ clang-tools-extra/clangd/test/check-fail.test
@@ -1,5 +1,5 @@
 // RUN: cp %s %t.cpp
-// RUN: not clangd -check=%t.cpp 2>&1 | FileCheck -strict-whitespace %s
+// RUN: not clangd -enable-config=0 -check=%t.cpp 2>&1 | FileCheck -strict-whitespace %s
 
 // CHECK: Testing on source file 

[PATCH] D107130: [clangd] Enable relative configs in check mode

2021-07-29 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet created this revision.
kadircet added a reviewer: sammccall.
Herald added subscribers: usaxena95, arphaman.
kadircet requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang-tools-extra.

See https://github.com/clangd/clangd/issues/649#issuecomment-885903316.
Also disables config support in lit tests to make sure tests are not affected by
clangd config files lying around.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D107130

Files:
  clang-tools-extra/clangd/test/check-fail.test
  clang-tools-extra/clangd/test/check-lines.test
  clang-tools-extra/clangd/test/check.test
  clang-tools-extra/clangd/tool/Check.cpp


Index: clang-tools-extra/clangd/tool/Check.cpp
===
--- clang-tools-extra/clangd/tool/Check.cpp
+++ clang-tools-extra/clangd/tool/Check.cpp
@@ -272,7 +272,7 @@
 
   auto ContextProvider = ClangdServer::createConfiguredContextProvider(
   Opts.ConfigProvider, nullptr);
-  WithContext Ctx(ContextProvider(""));
+  WithContext Ctx(ContextProvider(File));
   Checker C(File, Opts);
   if (!C.buildCommand(TFS) || !C.buildInvocation(TFS, Contents) ||
   !C.buildAST())
Index: clang-tools-extra/clangd/test/check.test
===
--- clang-tools-extra/clangd/test/check.test
+++ clang-tools-extra/clangd/test/check.test
@@ -1,5 +1,5 @@
 // RUN: cp %s %t.cpp
-// RUN: clangd -log=verbose -check=%t.cpp 2>&1 | FileCheck -strict-whitespace 
%s
+// RUN: clangd -enable-config=0 -log=verbose -check=%t.cpp 2>&1 | FileCheck 
-strict-whitespace %s
 
 // CHECK: Testing on source file
 // CHECK: internal (cc1) args are: -cc1
Index: clang-tools-extra/clangd/test/check-lines.test
===
--- clang-tools-extra/clangd/test/check-lines.test
+++ clang-tools-extra/clangd/test/check-lines.test
@@ -1,6 +1,6 @@
 // RUN: cp %s %t.cpp
-// RUN: not clangd -check=%t.cpp -check-lines=6-14 2>&1 | FileCheck 
-strict-whitespace %s
-// RUN: not clangd -check=%t.cpp -check-lines=14 2>&1 | FileCheck 
-strict-whitespace %s
+// RUN: not clangd -enable-config=0 -check=%t.cpp -check-lines=6-14 2>&1 | 
FileCheck -strict-whitespace %s
+// RUN: not clangd -enable-config=0 -check=%t.cpp -check-lines=14 2>&1 | 
FileCheck -strict-whitespace %s
 
 // CHECK: Testing on source file {{.*}}check-lines.test
 // CHECK: internal (cc1) args are: -cc1
Index: clang-tools-extra/clangd/test/check-fail.test
===
--- clang-tools-extra/clangd/test/check-fail.test
+++ clang-tools-extra/clangd/test/check-fail.test
@@ -1,5 +1,5 @@
 // RUN: cp %s %t.cpp
-// RUN: not clangd -check=%t.cpp 2>&1 | FileCheck -strict-whitespace %s
+// RUN: not clangd -enable-config=0 -check=%t.cpp 2>&1 | FileCheck 
-strict-whitespace %s
 
 // CHECK: Testing on source file {{.*}}check-fail.test
 // CHECK: internal (cc1) args are: -cc1


Index: clang-tools-extra/clangd/tool/Check.cpp
===
--- clang-tools-extra/clangd/tool/Check.cpp
+++ clang-tools-extra/clangd/tool/Check.cpp
@@ -272,7 +272,7 @@
 
   auto ContextProvider = ClangdServer::createConfiguredContextProvider(
   Opts.ConfigProvider, nullptr);
-  WithContext Ctx(ContextProvider(""));
+  WithContext Ctx(ContextProvider(File));
   Checker C(File, Opts);
   if (!C.buildCommand(TFS) || !C.buildInvocation(TFS, Contents) ||
   !C.buildAST())
Index: clang-tools-extra/clangd/test/check.test
===
--- clang-tools-extra/clangd/test/check.test
+++ clang-tools-extra/clangd/test/check.test
@@ -1,5 +1,5 @@
 // RUN: cp %s %t.cpp
-// RUN: clangd -log=verbose -check=%t.cpp 2>&1 | FileCheck -strict-whitespace %s
+// RUN: clangd -enable-config=0 -log=verbose -check=%t.cpp 2>&1 | FileCheck -strict-whitespace %s
 
 // CHECK: Testing on source file
 // CHECK: internal (cc1) args are: -cc1
Index: clang-tools-extra/clangd/test/check-lines.test
===
--- clang-tools-extra/clangd/test/check-lines.test
+++ clang-tools-extra/clangd/test/check-lines.test
@@ -1,6 +1,6 @@
 // RUN: cp %s %t.cpp
-// RUN: not clangd -check=%t.cpp -check-lines=6-14 2>&1 | FileCheck -strict-whitespace %s
-// RUN: not clangd -check=%t.cpp -check-lines=14 2>&1 | FileCheck -strict-whitespace %s
+// RUN: not clangd -enable-config=0 -check=%t.cpp -check-lines=6-14 2>&1 | FileCheck -strict-whitespace %s
+// RUN: not clangd -enable-config=0 -check=%t.cpp -check-lines=14 2>&1 | FileCheck -strict-whitespace %s
 
 // CHECK: Testing on source file {{.*}}check-lines.test
 // CHECK: internal (cc1) args are: -cc1
Index: clang-tools-extra/clangd/test/check-fail.test
===
--- 

[PATCH] D107025: Take OptimizationLevel class out of Pass Builder

2021-07-29 Thread Mircea Trofin via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG7a797b290299: Take OptimizationLevel class out of Pass 
Builder (authored by tarinduj, committed by mtrofin).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107025

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  llvm/examples/Bye/Bye.cpp
  llvm/include/llvm/Passes/OptimizationLevel.h
  llvm/include/llvm/Passes/PassBuilder.h
  llvm/lib/LTO/LTOBackend.cpp
  llvm/lib/LTO/ThinLTOCodeGenerator.cpp
  llvm/lib/Passes/PassBuilder.cpp
  llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
  llvm/lib/Target/BPF/BPFTargetMachine.cpp
  llvm/lib/Target/Hexagon/HexagonTargetMachine.cpp
  llvm/lib/Target/NVPTX/NVPTXTargetMachine.cpp
  llvm/tools/opt/NewPMDriver.cpp
  polly/include/polly/Canonicalization.h
  polly/lib/Support/RegisterPasses.cpp
  polly/lib/Transform/Canonicalization.cpp

Index: polly/lib/Transform/Canonicalization.cpp
===
--- polly/lib/Transform/Canonicalization.cpp
+++ polly/lib/Transform/Canonicalization.cpp
@@ -64,7 +64,7 @@
 
 /// Adapted from llvm::PassBuilder::buildInlinerPipeline
 static ModuleInlinerWrapperPass
-buildInlinePasses(llvm::PassBuilder::OptimizationLevel Level) {
+buildInlinePasses(llvm::OptimizationLevel Level) {
   InlineParams IP = getInlineParams(200);
   ModuleInlinerWrapperPass MIWP(IP);
 
@@ -92,8 +92,9 @@
   return MIWP;
 }
 
-FunctionPassManager polly::buildCanonicalicationPassesForNPM(
-llvm::ModulePassManager , llvm::PassBuilder::OptimizationLevel Level) {
+FunctionPassManager
+polly::buildCanonicalicationPassesForNPM(llvm::ModulePassManager ,
+ llvm::OptimizationLevel Level) {
   FunctionPassManager FPM;
 
   bool UseMemSSA = true;
@@ -107,7 +108,7 @@
   FPM.addPass(ReassociatePass());
   {
 LoopPassManager LPM;
-LPM.addPass(LoopRotatePass(Level != PassBuilder::OptimizationLevel::Oz));
+LPM.addPass(LoopRotatePass(Level != OptimizationLevel::Oz));
 FPM.addPass(createFunctionToLoopPassAdaptor(
 std::move(LPM), /*UseMemorySSA=*/false,
 /*UseBlockFrequencyInfo=*/false));
Index: polly/lib/Support/RegisterPasses.cpp
===
--- polly/lib/Support/RegisterPasses.cpp
+++ polly/lib/Support/RegisterPasses.cpp
@@ -474,7 +474,7 @@
 /// the analysis passes are added, skipping Polly itself.
 /// The IR may still be modified.
 static void buildCommonPollyPipeline(FunctionPassManager ,
- PassBuilder::OptimizationLevel Level,
+ OptimizationLevel Level,
  bool EnableForOpt) {
   PassBuilder PB;
   ScopPassManager SPM;
@@ -574,7 +574,7 @@
 }
 
 static void buildEarlyPollyPipeline(ModulePassManager ,
-PassBuilder::OptimizationLevel Level) {
+OptimizationLevel Level) {
   bool EnableForOpt =
   shouldEnablePollyForOptimization() && Level.isOptimizingForSpeed();
   if (!shouldEnablePollyForDiagnostic() && !EnableForOpt)
@@ -603,7 +603,7 @@
 }
 
 static void buildLatePollyPipeline(FunctionPassManager ,
-   PassBuilder::OptimizationLevel Level) {
+   OptimizationLevel Level) {
   bool EnableForOpt =
   shouldEnablePollyForOptimization() && Level.isOptimizingForSpeed();
   if (!shouldEnablePollyForDiagnostic() && !EnableForOpt)
Index: polly/include/polly/Canonicalization.h
===
--- polly/include/polly/Canonicalization.h
+++ polly/include/polly/Canonicalization.h
@@ -30,7 +30,7 @@
 
 llvm::FunctionPassManager
 buildCanonicalicationPassesForNPM(llvm::ModulePassManager ,
-  llvm::PassBuilder::OptimizationLevel Level);
+  llvm::OptimizationLevel Level);
 
 } // namespace polly
 
Index: llvm/tools/opt/NewPMDriver.cpp
===
--- llvm/tools/opt/NewPMDriver.cpp
+++ llvm/tools/opt/NewPMDriver.cpp
@@ -173,58 +173,58 @@
 static void registerEPCallbacks(PassBuilder ) {
   if (tryParsePipelineText(PB, PeepholeEPPipeline))
 PB.registerPeepholeEPCallback(
-[](FunctionPassManager , PassBuilder::OptimizationLevel Level) {
+[](FunctionPassManager , OptimizationLevel Level) {
   ExitOnError Err("Unable to parse PeepholeEP pipeline: ");
   Err(PB.parsePassPipeline(PM, PeepholeEPPipeline));
 });
   if (tryParsePipelineText(PB,
 LateLoopOptimizationsEPPipeline))
 PB.registerLateLoopOptimizationsEPCallback(
-[](LoopPassManager , 

[PATCH] D106778: [OpenCL] opencl-c.h: add CL 3.0 non-generic address space atomics

2021-07-29 Thread Dave Airlie via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3c7d2f1b67d1: [OpenCL] opencl-c.h: add CL 3.0 non-generic 
address space atomics (authored by airlied).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106778

Files:
  clang/lib/Headers/opencl-c.h

Index: clang/lib/Headers/opencl-c.h
===
--- clang/lib/Headers/opencl-c.h
+++ clang/lib/Headers/opencl-c.h
@@ -13289,6 +13289,7 @@
 #endif
 
 // atomic_init()
+#if defined(__opencl_c_generic_address_space)
 void __ovld atomic_init(volatile atomic_int *object, int value);
 void __ovld atomic_init(volatile atomic_uint *object, uint value);
 void __ovld atomic_init(volatile atomic_float *object, float value);
@@ -13299,6 +13300,24 @@
 void __ovld atomic_init(volatile atomic_double *object, double value);
 #endif //cl_khr_fp64
 #endif
+#elif __OPENCL_C_VERSION__ >= CL_VERSION_3_0
+void __ovld atomic_init(volatile __global atomic_int *object, int value);
+void __ovld atomic_init(volatile __local atomic_int *object, int value);
+void __ovld atomic_init(volatile __global atomic_uint *object, uint value);
+void __ovld atomic_init(volatile __local atomic_uint *object, uint value);
+void __ovld atomic_init(volatile __global atomic_float *object, float value);
+void __ovld atomic_init(volatile __local atomic_float *object, float value);
+#if defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics)
+void __ovld atomic_init(volatile __global atomic_long *object, long value);
+void __ovld atomic_init(volatile __local atomic_long *object, long value);
+void __ovld atomic_init(volatile __global atomic_ulong *object, ulong value);
+void __ovld atomic_init(volatile __local atomic_ulong *object, ulong value);
+#ifdef cl_khr_fp64
+void __ovld atomic_init(volatile __global atomic_double *object, double value);
+void __ovld atomic_init(volatile __local atomic_double *object, double value);
+#endif //cl_khr_fp64
+#endif
+#endif //__OPENCL_C_VERSION__ >= CL_VERSION_3_0
 
 // atomic_work_item_fence()
 void __ovld atomic_work_item_fence(cl_mem_fence_flags flags, memory_order order, memory_scope scope);
@@ -13308,6 +13327,7 @@
 // add/sub: atomic type argument can be uintptr_t/intptr_t, value type argument can be ptrdiff_t.
 
 #if defined(__opencl_c_atomic_order_seq_cst) && defined(__opencl_c_atomic_scope_device)
+#if defined(__opencl_c_generic_address_space)
 int __ovld atomic_fetch_add(volatile atomic_int *object, int operand);
 uint __ovld atomic_fetch_add(volatile atomic_uint *object, uint operand);
 int __ovld atomic_fetch_sub(volatile atomic_int *object, int operand);
@@ -13322,7 +13342,6 @@
 uint __ovld atomic_fetch_min(volatile atomic_uint *object, uint operand);
 int __ovld atomic_fetch_max(volatile atomic_int *object, int operand);
 uint __ovld atomic_fetch_max(volatile atomic_uint *object, uint operand);
-
 #if defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics)
 long __ovld atomic_fetch_add(volatile atomic_long *object, long operand);
 ulong __ovld atomic_fetch_add(volatile atomic_ulong *object, ulong operand);
@@ -13341,9 +13360,92 @@
 uintptr_t __ovld atomic_fetch_add(volatile atomic_uintptr_t *object, ptrdiff_t operand);
 uintptr_t __ovld atomic_fetch_sub(volatile atomic_uintptr_t *object, ptrdiff_t operand);
 #endif //defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics)
+#elif __OPENCL_C_VERSION__ >= CL_VERSION_3_0
+int __ovld atomic_fetch_add(volatile __global atomic_int *object, int operand);
+int __ovld atomic_fetch_add(volatile __local atomic_int *object, int operand);
+uint __ovld atomic_fetch_add(volatile __global atomic_uint *object, uint operand);
+uint __ovld atomic_fetch_add(volatile __local atomic_uint *object, uint operand);
+int __ovld atomic_fetch_sub(volatile __global atomic_int *object, int operand);
+int __ovld atomic_fetch_sub(volatile __local atomic_int *object, int operand);
+uint __ovld atomic_fetch_sub(volatile __global atomic_uint *object, uint operand);
+uint __ovld atomic_fetch_sub(volatile __local atomic_uint *object, uint operand);
+int __ovld atomic_fetch_or(volatile __global atomic_int *object, int operand);
+int __ovld atomic_fetch_or(volatile __local atomic_int *object, int operand);
+uint __ovld atomic_fetch_or(volatile __global atomic_uint *object, uint operand);
+uint __ovld atomic_fetch_or(volatile __local atomic_uint *object, uint operand);
+int __ovld atomic_fetch_xor(volatile __global atomic_int *object, int operand);
+int __ovld atomic_fetch_xor(volatile __local atomic_int *object, int operand);
+uint __ovld atomic_fetch_xor(volatile __global atomic_uint *object, uint operand);
+uint __ovld atomic_fetch_xor(volatile __local atomic_uint *object, uint operand);i
+int __ovld atomic_fetch_and(volatile __global atomic_int 

[clang] 3c7d2f1 - [OpenCL] opencl-c.h: add CL 3.0 non-generic address space atomics

2021-07-29 Thread Dave Airlie via cfe-commits

Author: Dave Airlie
Date: 2021-07-30T14:46:47+10:00
New Revision: 3c7d2f1b67d123b748beabc91a5ca041b102b065

URL: 
https://github.com/llvm/llvm-project/commit/3c7d2f1b67d123b748beabc91a5ca041b102b065
DIFF: 
https://github.com/llvm/llvm-project/commit/3c7d2f1b67d123b748beabc91a5ca041b102b065.diff

LOG: [OpenCL] opencl-c.h: add CL 3.0 non-generic address space atomics

CL 2.0 introduced atomics and generic address space so there were
only one set of APIs for doing atomics, however since CL 3.0
makes generic address space optional, there has to be new sets
of atomic interfaces to handle that cases.

Reviewed By: Anastasia

Differential Revision: https://reviews.llvm.org/D106778

Added: 


Modified: 
clang/lib/Headers/opencl-c.h

Removed: 




diff  --git a/clang/lib/Headers/opencl-c.h b/clang/lib/Headers/opencl-c.h
index fc50dd718c4e4..fa39bf2261f5b 100644
--- a/clang/lib/Headers/opencl-c.h
+++ b/clang/lib/Headers/opencl-c.h
@@ -13289,6 +13289,7 @@ unsigned long __ovld atom_xor(volatile __local unsigned 
long *p, unsigned long v
 #endif
 
 // atomic_init()
+#if defined(__opencl_c_generic_address_space)
 void __ovld atomic_init(volatile atomic_int *object, int value);
 void __ovld atomic_init(volatile atomic_uint *object, uint value);
 void __ovld atomic_init(volatile atomic_float *object, float value);
@@ -13299,6 +13300,24 @@ void __ovld atomic_init(volatile atomic_ulong *object, 
ulong value);
 void __ovld atomic_init(volatile atomic_double *object, double value);
 #endif //cl_khr_fp64
 #endif
+#elif __OPENCL_C_VERSION__ >= CL_VERSION_3_0
+void __ovld atomic_init(volatile __global atomic_int *object, int value);
+void __ovld atomic_init(volatile __local atomic_int *object, int value);
+void __ovld atomic_init(volatile __global atomic_uint *object, uint value);
+void __ovld atomic_init(volatile __local atomic_uint *object, uint value);
+void __ovld atomic_init(volatile __global atomic_float *object, float value);
+void __ovld atomic_init(volatile __local atomic_float *object, float value);
+#if defined(cl_khr_int64_base_atomics) && 
defined(cl_khr_int64_extended_atomics)
+void __ovld atomic_init(volatile __global atomic_long *object, long value);
+void __ovld atomic_init(volatile __local atomic_long *object, long value);
+void __ovld atomic_init(volatile __global atomic_ulong *object, ulong value);
+void __ovld atomic_init(volatile __local atomic_ulong *object, ulong value);
+#ifdef cl_khr_fp64
+void __ovld atomic_init(volatile __global atomic_double *object, double value);
+void __ovld atomic_init(volatile __local atomic_double *object, double value);
+#endif //cl_khr_fp64
+#endif
+#endif //__OPENCL_C_VERSION__ >= CL_VERSION_3_0
 
 // atomic_work_item_fence()
 void __ovld atomic_work_item_fence(cl_mem_fence_flags flags, memory_order 
order, memory_scope scope);
@@ -13308,6 +13327,7 @@ void __ovld atomic_work_item_fence(cl_mem_fence_flags 
flags, memory_order order,
 // add/sub: atomic type argument can be uintptr_t/intptr_t, value type 
argument can be ptr
diff _t.
 
 #if defined(__opencl_c_atomic_order_seq_cst) && 
defined(__opencl_c_atomic_scope_device)
+#if defined(__opencl_c_generic_address_space)
 int __ovld atomic_fetch_add(volatile atomic_int *object, int operand);
 uint __ovld atomic_fetch_add(volatile atomic_uint *object, uint operand);
 int __ovld atomic_fetch_sub(volatile atomic_int *object, int operand);
@@ -13322,7 +13342,6 @@ int __ovld atomic_fetch_min(volatile atomic_int 
*object, int operand);
 uint __ovld atomic_fetch_min(volatile atomic_uint *object, uint operand);
 int __ovld atomic_fetch_max(volatile atomic_int *object, int operand);
 uint __ovld atomic_fetch_max(volatile atomic_uint *object, uint operand);
-
 #if defined(cl_khr_int64_base_atomics) && 
defined(cl_khr_int64_extended_atomics)
 long __ovld atomic_fetch_add(volatile atomic_long *object, long operand);
 ulong __ovld atomic_fetch_add(volatile atomic_ulong *object, ulong operand);
@@ -13341,9 +13360,92 @@ ulong __ovld atomic_fetch_max(volatile atomic_ulong 
*object, ulong operand);
 uintptr_t __ovld atomic_fetch_add(volatile atomic_uintptr_t *object, ptr
diff _t operand);
 uintptr_t __ovld atomic_fetch_sub(volatile atomic_uintptr_t *object, ptr
diff _t operand);
 #endif //defined(cl_khr_int64_base_atomics) && 
defined(cl_khr_int64_extended_atomics)
+#elif __OPENCL_C_VERSION__ >= CL_VERSION_3_0
+int __ovld atomic_fetch_add(volatile __global atomic_int *object, int operand);
+int __ovld atomic_fetch_add(volatile __local atomic_int *object, int operand);
+uint __ovld atomic_fetch_add(volatile __global atomic_uint *object, uint 
operand);
+uint __ovld atomic_fetch_add(volatile __local atomic_uint *object, uint 
operand);
+int __ovld atomic_fetch_sub(volatile __global atomic_int *object, int operand);
+int __ovld atomic_fetch_sub(volatile __local atomic_int *object, int operand);
+uint __ovld atomic_fetch_sub(volatile __global atomic_uint 

[PATCH] D106748: [OpenCL] Add support of __opencl_c_pipes feature macro.

2021-07-29 Thread Anton Zabaznov via Phabricator via cfe-commits
azabaznov added a comment.

Reverted it due too suspicious failing:

  error: 'error' diagnostics expected but not seen: 
File 
/home/tcwg-buildslave/worker/clang-armv7-2stage/llvm/clang/test/SemaOpenCL/invalid-pipes-cl2.0.cl
 Line 8: type '__global write_only pipe int ({{(void)?}})' can only be used as 
a function parameter in OpenCL
  error: 'error' diagnostics seen but not expected: 
File 
/home/tcwg-buildslave/worker/clang-armv7-2stage/llvm/clang/test/SemaOpenCL/invalid-pipes-cl2.0.cl
 Line 8: type '__private write_only pipe int (void)' can only be used as a 
function parameter in OpenCL
  2 errors generated.

I don't think that's because of triple was unset, I think the main reason was 
that program scope variables were not supported, but need to have a look closely


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106748

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


[clang] da6626d - Revert "[OpenCL] Add support of __opencl_c_pipes feature macro."

2021-07-29 Thread Anton Zabaznov via cfe-commits

Author: Anton Zabaznov
Date: 2021-07-30T06:34:29+03:00
New Revision: da6626d12624675c46a73e8545fecc572695efeb

URL: 
https://github.com/llvm/llvm-project/commit/da6626d12624675c46a73e8545fecc572695efeb
DIFF: 
https://github.com/llvm/llvm-project/commit/da6626d12624675c46a73e8545fecc572695efeb.diff

LOG: Revert "[OpenCL] Add support of __opencl_c_pipes feature macro."

This reverts commit d1e4b25756730576996457ba7324e9bf210e3693.

Added: 


Modified: 
clang/include/clang/Basic/LangOptions.def
clang/lib/Basic/OpenCLOptions.cpp
clang/lib/Basic/TargetInfo.cpp
clang/lib/Frontend/CompilerInvocation.cpp
clang/lib/Parse/ParseDecl.cpp
clang/lib/Sema/Sema.cpp
clang/test/CodeGenOpenCL/address-spaces-mangling.cl
clang/test/CodeGenOpenCL/address-spaces.cl
clang/test/CodeGenOpenCL/pipe_builtin.cl
clang/test/CodeGenOpenCL/pipe_types.cl
clang/test/CodeGenOpenCL/pipe_types_mangling.cl
clang/test/Misc/opencl-c-3.0.incorrect_options.cl
clang/test/SemaOpenCL/invalid-pipes-cl1.2.cl
clang/test/SemaOpenCL/invalid-pipes-cl2.0.cl
clang/test/SemaOpenCL/storageclass.cl

Removed: 




diff  --git a/clang/include/clang/Basic/LangOptions.def 
b/clang/include/clang/Basic/LangOptions.def
index 61a4dbdf856a..5c3d534c9b11 100644
--- a/clang/include/clang/Basic/LangOptions.def
+++ b/clang/include/clang/Basic/LangOptions.def
@@ -224,7 +224,7 @@ LANGOPT(OpenCLVersion , 32, 0, "OpenCL C version")
 LANGOPT(OpenCLCPlusPlus   , 1, 0, "C++ for OpenCL")
 LANGOPT(OpenCLCPlusPlusVersion , 32, 0, "C++ for OpenCL version")
 LANGOPT(OpenCLGenericAddressSpace, 1, 0, "OpenCL generic keyword")
-LANGOPT(OpenCLPipes  , 1, 0, "OpenCL pipes language constructs and 
built-ins")
+LANGOPT(OpenCLPipe   , 1, 0, "OpenCL pipe keyword")
 LANGOPT(NativeHalfType, 1, 0, "Native half type support")
 LANGOPT(NativeHalfArgsAndReturns, 1, 0, "Native half args and returns")
 LANGOPT(HalfArgsAndReturns, 1, 0, "half args and returns")

diff  --git a/clang/lib/Basic/OpenCLOptions.cpp 
b/clang/lib/Basic/OpenCLOptions.cpp
index b7408f39bdab..f4f474fade4d 100644
--- a/clang/lib/Basic/OpenCLOptions.cpp
+++ b/clang/lib/Basic/OpenCLOptions.cpp
@@ -112,8 +112,7 @@ bool OpenCLOptions::diagnoseUnsupportedFeatureDependencies(
   // supported.
   static const llvm::StringMap DependentFeaturesMap = {
   {"__opencl_c_read_write_images", "__opencl_c_images"},
-  {"__opencl_c_3d_image_writes", "__opencl_c_images"},
-  {"__opencl_c_pipes", "__opencl_c_generic_address_space"}};
+  {"__opencl_c_3d_image_writes", "__opencl_c_images"}};
 
   auto OpenCLFeaturesMap = TI.getSupportedOpenCLOpts();
 

diff  --git a/clang/lib/Basic/TargetInfo.cpp b/clang/lib/Basic/TargetInfo.cpp
index 5f8e04c2bd6c..b647a2fb8a67 100644
--- a/clang/lib/Basic/TargetInfo.cpp
+++ b/clang/lib/Basic/TargetInfo.cpp
@@ -400,18 +400,14 @@ void TargetInfo::adjust(DiagnosticsEngine , 
LangOptions ) {
 // OpenCL C v3.0 s6.7.5 - The generic address space requires support for
 // OpenCL C 2.0 or OpenCL C 3.0 with the __opencl_c_generic_address_space
 // feature
-// OpenCL C v3.0 s6.2.1 - OpenCL pipes require support of OpenCL C 2.0
-// or later and __opencl_c_pipes feature
-// FIXME: These language options are also defined in setLangDefaults()
+// FIXME: OpenCLGenericAddressSpace is also defined in setLangDefaults()
 // for OpenCL C 2.0 but with no access to target capabilities. Target
-// should be immutable once created and thus these language options need
+// should be immutable once created and thus this language option needs
 // to be defined only once.
-if (Opts.OpenCLVersion == 300) {
+if (Opts.OpenCLVersion >= 300) {
   const auto  = getSupportedOpenCLOpts();
   Opts.OpenCLGenericAddressSpace = hasFeatureEnabled(
   OpenCLFeaturesMap, "__opencl_c_generic_address_space");
-  Opts.OpenCLPipes =
-  hasFeatureEnabled(OpenCLFeaturesMap, "__opencl_c_pipes");
 }
   }
 

diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index 02f08c69ca7a..63436b7aebe1 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -3173,7 +3173,7 @@ void CompilerInvocation::setLangDefaults(LangOptions 
, InputKind IK,
 Opts.ZVector = 0;
 Opts.setDefaultFPContractMode(LangOptions::FPM_On);
 Opts.OpenCLCPlusPlus = Opts.CPlusPlus;
-Opts.OpenCLPipes = Opts.OpenCLCPlusPlus || Opts.OpenCLVersion == 200;
+Opts.OpenCLPipe = Opts.OpenCLCPlusPlus || Opts.OpenCLVersion == 200;
 Opts.OpenCLGenericAddressSpace =
 Opts.OpenCLCPlusPlus || Opts.OpenCLVersion == 200;
 

diff  --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp
index 939323517b4d..f4f5f461e3b6 100644
--- a/clang/lib/Parse/ParseDecl.cpp
+++ b/clang/lib/Parse/ParseDecl.cpp
@@ 

[PATCH] D107025: Take OptimizationLevel class out of Pass Builder

2021-07-29 Thread Tarindu Jayatilaka via Phabricator via cfe-commits
tarinduj updated this revision to Diff 362962.
tarinduj added a comment.

added newline at the end to OptimizationLevel.h


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

https://reviews.llvm.org/D107025

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  llvm/examples/Bye/Bye.cpp
  llvm/include/llvm/Passes/OptimizationLevel.h
  llvm/include/llvm/Passes/PassBuilder.h
  llvm/lib/LTO/LTOBackend.cpp
  llvm/lib/LTO/ThinLTOCodeGenerator.cpp
  llvm/lib/Passes/PassBuilder.cpp
  llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
  llvm/lib/Target/BPF/BPFTargetMachine.cpp
  llvm/lib/Target/Hexagon/HexagonTargetMachine.cpp
  llvm/lib/Target/NVPTX/NVPTXTargetMachine.cpp
  llvm/tools/opt/NewPMDriver.cpp
  polly/include/polly/Canonicalization.h
  polly/lib/Support/RegisterPasses.cpp
  polly/lib/Transform/Canonicalization.cpp

Index: polly/lib/Transform/Canonicalization.cpp
===
--- polly/lib/Transform/Canonicalization.cpp
+++ polly/lib/Transform/Canonicalization.cpp
@@ -64,7 +64,7 @@
 
 /// Adapted from llvm::PassBuilder::buildInlinerPipeline
 static ModuleInlinerWrapperPass
-buildInlinePasses(llvm::PassBuilder::OptimizationLevel Level) {
+buildInlinePasses(llvm::OptimizationLevel Level) {
   InlineParams IP = getInlineParams(200);
   ModuleInlinerWrapperPass MIWP(IP);
 
@@ -92,8 +92,9 @@
   return MIWP;
 }
 
-FunctionPassManager polly::buildCanonicalicationPassesForNPM(
-llvm::ModulePassManager , llvm::PassBuilder::OptimizationLevel Level) {
+FunctionPassManager
+polly::buildCanonicalicationPassesForNPM(llvm::ModulePassManager ,
+ llvm::OptimizationLevel Level) {
   FunctionPassManager FPM;
 
   bool UseMemSSA = true;
@@ -107,7 +108,7 @@
   FPM.addPass(ReassociatePass());
   {
 LoopPassManager LPM;
-LPM.addPass(LoopRotatePass(Level != PassBuilder::OptimizationLevel::Oz));
+LPM.addPass(LoopRotatePass(Level != OptimizationLevel::Oz));
 FPM.addPass(createFunctionToLoopPassAdaptor(
 std::move(LPM), /*UseMemorySSA=*/false,
 /*UseBlockFrequencyInfo=*/false));
Index: polly/lib/Support/RegisterPasses.cpp
===
--- polly/lib/Support/RegisterPasses.cpp
+++ polly/lib/Support/RegisterPasses.cpp
@@ -474,7 +474,7 @@
 /// the analysis passes are added, skipping Polly itself.
 /// The IR may still be modified.
 static void buildCommonPollyPipeline(FunctionPassManager ,
- PassBuilder::OptimizationLevel Level,
+ OptimizationLevel Level,
  bool EnableForOpt) {
   PassBuilder PB;
   ScopPassManager SPM;
@@ -574,7 +574,7 @@
 }
 
 static void buildEarlyPollyPipeline(ModulePassManager ,
-PassBuilder::OptimizationLevel Level) {
+OptimizationLevel Level) {
   bool EnableForOpt =
   shouldEnablePollyForOptimization() && Level.isOptimizingForSpeed();
   if (!shouldEnablePollyForDiagnostic() && !EnableForOpt)
@@ -603,7 +603,7 @@
 }
 
 static void buildLatePollyPipeline(FunctionPassManager ,
-   PassBuilder::OptimizationLevel Level) {
+   OptimizationLevel Level) {
   bool EnableForOpt =
   shouldEnablePollyForOptimization() && Level.isOptimizingForSpeed();
   if (!shouldEnablePollyForDiagnostic() && !EnableForOpt)
Index: polly/include/polly/Canonicalization.h
===
--- polly/include/polly/Canonicalization.h
+++ polly/include/polly/Canonicalization.h
@@ -30,7 +30,7 @@
 
 llvm::FunctionPassManager
 buildCanonicalicationPassesForNPM(llvm::ModulePassManager ,
-  llvm::PassBuilder::OptimizationLevel Level);
+  llvm::OptimizationLevel Level);
 
 } // namespace polly
 
Index: llvm/tools/opt/NewPMDriver.cpp
===
--- llvm/tools/opt/NewPMDriver.cpp
+++ llvm/tools/opt/NewPMDriver.cpp
@@ -173,58 +173,58 @@
 static void registerEPCallbacks(PassBuilder ) {
   if (tryParsePipelineText(PB, PeepholeEPPipeline))
 PB.registerPeepholeEPCallback(
-[](FunctionPassManager , PassBuilder::OptimizationLevel Level) {
+[](FunctionPassManager , OptimizationLevel Level) {
   ExitOnError Err("Unable to parse PeepholeEP pipeline: ");
   Err(PB.parsePassPipeline(PM, PeepholeEPPipeline));
 });
   if (tryParsePipelineText(PB,
 LateLoopOptimizationsEPPipeline))
 PB.registerLateLoopOptimizationsEPCallback(
-[](LoopPassManager , PassBuilder::OptimizationLevel Level) {
+[](LoopPassManager , OptimizationLevel Level) {
   ExitOnError Err("Unable to parse LateLoopOptimizationsEP pipeline: ");
 

[PATCH] D106778: [OpenCL] opencl-c.h: add CL 3.0 non-generic address space atomics

2021-07-29 Thread Anton Zabaznov via Phabricator via cfe-commits
azabaznov added inline comments.



Comment at: clang/lib/Headers/opencl-c.h:13303
 #endif
+#elif __OPENCL_C_VERSION__ >= CL_VERSION_3_0
+void __ovld atomic_init(volatile __global atomic_int *object, int value);

Sorry, I overlooked that. Not //elif//, just //if// as these are available in 
3.0 even with generic address space feature 
(https://www.khronos.org/registry/OpenCL/specs/3.0-unified/html/OpenCL_C.html#the-atomic_init-function):

```
// Requires OpenCL C 3.0 or newer.
void atomic_init(volatile __global A *obj, C value)
void atomic_init(volatile __local A *obj, C value)

// Requires OpenCL C 2.0, or OpenCL C 3.0 or newer and the
// __opencl_c_generic_address_space feature.
void atomic_init(volatile A *obj, C value)
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106778

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


[PATCH] D106898: Revert "Revert "[clang][pp] adds '#pragma include_instead'""

2021-07-29 Thread Tom Stellard via Phabricator via cfe-commits
tstellar added a comment.

I've backported this as 6eaf46beb4628abf8f5b09a333bcd44d2fb2aff9 
.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106898

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


[PATCH] D106860: [clang][AArch64][SVE] Avoid going through memory for fixed/scalable predicate casts

2021-07-29 Thread JunMa via Phabricator via cfe-commits
junparser added inline comments.



Comment at: clang/lib/CodeGen/CGExprScalar.cpp:2102
+  Src = Builder.CreateBitCast(Src, SrcTy);
+}
 if (ScalableSrc->getElementType() == FixedDst->getElementType()) {

bsmith wrote:
> junparser wrote:
> > I think this may also works for casting between vectors with different 
> > element types.
> A similar argument applies here as the other related ticket, in principal we 
> could, however it's not clear that there is a good use case for writing code 
> that would make use of this. So for now it's probably best to just deal with 
> predicates which are definitely a problem and other cases as they arise.
Although i believe this generates better code than using memory load/store.  
Thanks for explaining this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106860

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


[PATCH] D106748: [OpenCL] Add support of __opencl_c_pipes feature macro.

2021-07-29 Thread Anton Zabaznov via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd1e4b2575673: [OpenCL] Add support of __opencl_c_pipes 
feature macro. (authored by azabaznov).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106748

Files:
  clang/include/clang/Basic/LangOptions.def
  clang/lib/Basic/OpenCLOptions.cpp
  clang/lib/Basic/TargetInfo.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Sema/Sema.cpp
  clang/test/CodeGenOpenCL/address-spaces-mangling.cl
  clang/test/CodeGenOpenCL/address-spaces.cl
  clang/test/CodeGenOpenCL/pipe_builtin.cl
  clang/test/CodeGenOpenCL/pipe_types.cl
  clang/test/CodeGenOpenCL/pipe_types_mangling.cl
  clang/test/Misc/opencl-c-3.0.incorrect_options.cl
  clang/test/SemaOpenCL/invalid-pipes-cl1.2.cl
  clang/test/SemaOpenCL/invalid-pipes-cl2.0.cl
  clang/test/SemaOpenCL/storageclass.cl

Index: clang/test/SemaOpenCL/storageclass.cl
===
--- clang/test/SemaOpenCL/storageclass.cl
+++ clang/test/SemaOpenCL/storageclass.cl
@@ -1,6 +1,6 @@
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL1.2
-// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL3.0 -cl-ext=-__opencl_c_program_scope_global_variables,-__opencl_c_generic_address_space
-// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL3.0 -cl-ext=+__opencl_c_program_scope_global_variables,-__opencl_c_generic_address_space
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL3.0 -cl-ext=-__opencl_c_program_scope_global_variables,-__opencl_c_generic_address_space,-__opencl_c_pipes
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL3.0 -cl-ext=+__opencl_c_program_scope_global_variables,-__opencl_c_generic_address_space,-__opencl_c_pipes
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL3.0 -cl-ext=-__opencl_c_program_scope_global_variables,+__opencl_c_generic_address_space
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL3.0 -cl-ext=+__opencl_c_program_scope_global_variables,+__opencl_c_generic_address_space
 static constant int G1 = 0;
Index: clang/test/SemaOpenCL/invalid-pipes-cl2.0.cl
===
--- clang/test/SemaOpenCL/invalid-pipes-cl2.0.cl
+++ clang/test/SemaOpenCL/invalid-pipes-cl2.0.cl
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL2.0
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL3.0 -cl-ext=+__opencl_c_pipes,+__opencl_c_generic_address_space
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=clc++
 
 global pipe int gp;// expected-error {{type '__global read_only pipe int' can only be used as a function parameter in OpenCL}}
Index: clang/test/SemaOpenCL/invalid-pipes-cl1.2.cl
===
--- clang/test/SemaOpenCL/invalid-pipes-cl1.2.cl
+++ clang/test/SemaOpenCL/invalid-pipes-cl1.2.cl
@@ -1,9 +1,23 @@
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL1.2
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL3.0 -cl-ext=-__opencl_c_pipes,-__opencl_c_generic_address_space
 
 void foo(read_only pipe int p);
-// expected-warning@-1 {{type specifier missing, defaults to 'int'}}
-// expected-error@-2 {{access qualifier can only be used for pipe and image type}}
-// expected-error@-3 {{expected ')'}} expected-note@-3 {{to match this '('}}
+#if __OPENCL_C_VERSION__ > 120
+// expected-error@-2 {{OpenCL C version 3.0 does not support the 'pipe' type qualifier}}
+// expected-error@-3 {{access qualifier can only be used for pipe and image type}}
+#else
+// expected-warning@-5 {{type specifier missing, defaults to 'int'}}
+// expected-error@-6 {{access qualifier can only be used for pipe and image type}}
+// expected-error@-7 {{expected ')'}} expected-note@-7 {{to match this '('}}
+#endif
 
 // 'pipe' should be accepted as an identifier.
 typedef int pipe;
+#if __OPENCL_C_VERSION__ > 120
+// expected-error@-2 {{OpenCL C version 3.0 does not support the 'pipe' type qualifier}}
+// expected-warning@-3 {{typedef requires a name}}
+#endif
+
+void bar() {
+ reserve_id_t r; // expected-error {{use of undeclared identifier 'reserve_id_t'}}
+}
Index: clang/test/Misc/opencl-c-3.0.incorrect_options.cl
===
--- clang/test/Misc/opencl-c-3.0.incorrect_options.cl
+++ clang/test/Misc/opencl-c-3.0.incorrect_options.cl
@@ -1,8 +1,7 @@
 // RUN: not %clang_cc1 -cl-std=CL3.0 -triple spir-unknown-unknown -cl-ext=-__opencl_c_fp64,+cl_khr_fp64 %s 2>&1 | FileCheck -check-prefix=CHECK-FP64 %s
 // RUN: not %clang_cc1 -cl-std=CL3.0 -triple spir-unknown-unknown -cl-ext=+__opencl_c_fp64,-cl_khr_fp64 %s 2>&1 | FileCheck 

[clang] d1e4b25 - [OpenCL] Add support of __opencl_c_pipes feature macro.

2021-07-29 Thread Anton Zabaznov via cfe-commits

Author: Anton Zabaznov
Date: 2021-07-30T05:27:55+03:00
New Revision: d1e4b25756730576996457ba7324e9bf210e3693

URL: 
https://github.com/llvm/llvm-project/commit/d1e4b25756730576996457ba7324e9bf210e3693
DIFF: 
https://github.com/llvm/llvm-project/commit/d1e4b25756730576996457ba7324e9bf210e3693.diff

LOG: [OpenCL] Add support of __opencl_c_pipes feature macro.

'pipe' keyword is introduced in OpenCL C 2.0: so do checks for OpenCL C version 
while
parsing and then later on check for language options to construct actual pipe. 
This feature
requires support of __opencl_c_generic_address_space, so diagnostics for that 
is provided as well.

Reviewed By: Anastasia

Differential Revision: https://reviews.llvm.org/D106748

Added: 


Modified: 
clang/include/clang/Basic/LangOptions.def
clang/lib/Basic/OpenCLOptions.cpp
clang/lib/Basic/TargetInfo.cpp
clang/lib/Frontend/CompilerInvocation.cpp
clang/lib/Parse/ParseDecl.cpp
clang/lib/Sema/Sema.cpp
clang/test/CodeGenOpenCL/address-spaces-mangling.cl
clang/test/CodeGenOpenCL/address-spaces.cl
clang/test/CodeGenOpenCL/pipe_builtin.cl
clang/test/CodeGenOpenCL/pipe_types.cl
clang/test/CodeGenOpenCL/pipe_types_mangling.cl
clang/test/Misc/opencl-c-3.0.incorrect_options.cl
clang/test/SemaOpenCL/invalid-pipes-cl1.2.cl
clang/test/SemaOpenCL/invalid-pipes-cl2.0.cl
clang/test/SemaOpenCL/storageclass.cl

Removed: 




diff  --git a/clang/include/clang/Basic/LangOptions.def 
b/clang/include/clang/Basic/LangOptions.def
index 5c3d534c9b11..61a4dbdf856a 100644
--- a/clang/include/clang/Basic/LangOptions.def
+++ b/clang/include/clang/Basic/LangOptions.def
@@ -224,7 +224,7 @@ LANGOPT(OpenCLVersion , 32, 0, "OpenCL C version")
 LANGOPT(OpenCLCPlusPlus   , 1, 0, "C++ for OpenCL")
 LANGOPT(OpenCLCPlusPlusVersion , 32, 0, "C++ for OpenCL version")
 LANGOPT(OpenCLGenericAddressSpace, 1, 0, "OpenCL generic keyword")
-LANGOPT(OpenCLPipe   , 1, 0, "OpenCL pipe keyword")
+LANGOPT(OpenCLPipes  , 1, 0, "OpenCL pipes language constructs and 
built-ins")
 LANGOPT(NativeHalfType, 1, 0, "Native half type support")
 LANGOPT(NativeHalfArgsAndReturns, 1, 0, "Native half args and returns")
 LANGOPT(HalfArgsAndReturns, 1, 0, "half args and returns")

diff  --git a/clang/lib/Basic/OpenCLOptions.cpp 
b/clang/lib/Basic/OpenCLOptions.cpp
index f4f474fade4d..b7408f39bdab 100644
--- a/clang/lib/Basic/OpenCLOptions.cpp
+++ b/clang/lib/Basic/OpenCLOptions.cpp
@@ -112,7 +112,8 @@ bool OpenCLOptions::diagnoseUnsupportedFeatureDependencies(
   // supported.
   static const llvm::StringMap DependentFeaturesMap = {
   {"__opencl_c_read_write_images", "__opencl_c_images"},
-  {"__opencl_c_3d_image_writes", "__opencl_c_images"}};
+  {"__opencl_c_3d_image_writes", "__opencl_c_images"},
+  {"__opencl_c_pipes", "__opencl_c_generic_address_space"}};
 
   auto OpenCLFeaturesMap = TI.getSupportedOpenCLOpts();
 

diff  --git a/clang/lib/Basic/TargetInfo.cpp b/clang/lib/Basic/TargetInfo.cpp
index b647a2fb8a67..5f8e04c2bd6c 100644
--- a/clang/lib/Basic/TargetInfo.cpp
+++ b/clang/lib/Basic/TargetInfo.cpp
@@ -400,14 +400,18 @@ void TargetInfo::adjust(DiagnosticsEngine , 
LangOptions ) {
 // OpenCL C v3.0 s6.7.5 - The generic address space requires support for
 // OpenCL C 2.0 or OpenCL C 3.0 with the __opencl_c_generic_address_space
 // feature
-// FIXME: OpenCLGenericAddressSpace is also defined in setLangDefaults()
+// OpenCL C v3.0 s6.2.1 - OpenCL pipes require support of OpenCL C 2.0
+// or later and __opencl_c_pipes feature
+// FIXME: These language options are also defined in setLangDefaults()
 // for OpenCL C 2.0 but with no access to target capabilities. Target
-// should be immutable once created and thus this language option needs
+// should be immutable once created and thus these language options need
 // to be defined only once.
-if (Opts.OpenCLVersion >= 300) {
+if (Opts.OpenCLVersion == 300) {
   const auto  = getSupportedOpenCLOpts();
   Opts.OpenCLGenericAddressSpace = hasFeatureEnabled(
   OpenCLFeaturesMap, "__opencl_c_generic_address_space");
+  Opts.OpenCLPipes =
+  hasFeatureEnabled(OpenCLFeaturesMap, "__opencl_c_pipes");
 }
   }
 

diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index 63436b7aebe1..02f08c69ca7a 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -3173,7 +3173,7 @@ void CompilerInvocation::setLangDefaults(LangOptions 
, InputKind IK,
 Opts.ZVector = 0;
 Opts.setDefaultFPContractMode(LangOptions::FPM_On);
 Opts.OpenCLCPlusPlus = Opts.CPlusPlus;
-Opts.OpenCLPipe = Opts.OpenCLCPlusPlus || Opts.OpenCLVersion == 200;
+Opts.OpenCLPipes = Opts.OpenCLCPlusPlus || Opts.OpenCLVersion == 200;
 

[PATCH] D106748: [OpenCL] Add support of __opencl_c_pipes feature macro.

2021-07-29 Thread Anton Zabaznov via Phabricator via cfe-commits
azabaznov updated this revision to Diff 362955.
azabaznov added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106748

Files:
  clang/include/clang/Basic/LangOptions.def
  clang/lib/Basic/OpenCLOptions.cpp
  clang/lib/Basic/TargetInfo.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Sema/Sema.cpp
  clang/test/CodeGenOpenCL/address-spaces-mangling.cl
  clang/test/CodeGenOpenCL/address-spaces.cl
  clang/test/CodeGenOpenCL/pipe_builtin.cl
  clang/test/CodeGenOpenCL/pipe_types.cl
  clang/test/CodeGenOpenCL/pipe_types_mangling.cl
  clang/test/Misc/opencl-c-3.0.incorrect_options.cl
  clang/test/SemaOpenCL/invalid-pipes-cl1.2.cl
  clang/test/SemaOpenCL/invalid-pipes-cl2.0.cl
  clang/test/SemaOpenCL/storageclass.cl

Index: clang/test/SemaOpenCL/storageclass.cl
===
--- clang/test/SemaOpenCL/storageclass.cl
+++ clang/test/SemaOpenCL/storageclass.cl
@@ -1,6 +1,6 @@
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL1.2
-// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL3.0 -cl-ext=-__opencl_c_program_scope_global_variables,-__opencl_c_generic_address_space
-// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL3.0 -cl-ext=+__opencl_c_program_scope_global_variables,-__opencl_c_generic_address_space
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL3.0 -cl-ext=-__opencl_c_program_scope_global_variables,-__opencl_c_generic_address_space,-__opencl_c_pipes
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL3.0 -cl-ext=+__opencl_c_program_scope_global_variables,-__opencl_c_generic_address_space,-__opencl_c_pipes
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL3.0 -cl-ext=-__opencl_c_program_scope_global_variables,+__opencl_c_generic_address_space
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL3.0 -cl-ext=+__opencl_c_program_scope_global_variables,+__opencl_c_generic_address_space
 static constant int G1 = 0;
Index: clang/test/SemaOpenCL/invalid-pipes-cl2.0.cl
===
--- clang/test/SemaOpenCL/invalid-pipes-cl2.0.cl
+++ clang/test/SemaOpenCL/invalid-pipes-cl2.0.cl
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL2.0
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL3.0 -cl-ext=+__opencl_c_pipes,+__opencl_c_generic_address_space
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=clc++
 
 global pipe int gp;// expected-error {{type '__global read_only pipe int' can only be used as a function parameter in OpenCL}}
Index: clang/test/SemaOpenCL/invalid-pipes-cl1.2.cl
===
--- clang/test/SemaOpenCL/invalid-pipes-cl1.2.cl
+++ clang/test/SemaOpenCL/invalid-pipes-cl1.2.cl
@@ -1,9 +1,23 @@
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL1.2
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL3.0 -cl-ext=-__opencl_c_pipes,-__opencl_c_generic_address_space
 
 void foo(read_only pipe int p);
-// expected-warning@-1 {{type specifier missing, defaults to 'int'}}
-// expected-error@-2 {{access qualifier can only be used for pipe and image type}}
-// expected-error@-3 {{expected ')'}} expected-note@-3 {{to match this '('}}
+#if __OPENCL_C_VERSION__ > 120
+// expected-error@-2 {{OpenCL C version 3.0 does not support the 'pipe' type qualifier}}
+// expected-error@-3 {{access qualifier can only be used for pipe and image type}}
+#else
+// expected-warning@-5 {{type specifier missing, defaults to 'int'}}
+// expected-error@-6 {{access qualifier can only be used for pipe and image type}}
+// expected-error@-7 {{expected ')'}} expected-note@-7 {{to match this '('}}
+#endif
 
 // 'pipe' should be accepted as an identifier.
 typedef int pipe;
+#if __OPENCL_C_VERSION__ > 120
+// expected-error@-2 {{OpenCL C version 3.0 does not support the 'pipe' type qualifier}}
+// expected-warning@-3 {{typedef requires a name}}
+#endif
+
+void bar() {
+ reserve_id_t r; // expected-error {{use of undeclared identifier 'reserve_id_t'}}
+}
Index: clang/test/Misc/opencl-c-3.0.incorrect_options.cl
===
--- clang/test/Misc/opencl-c-3.0.incorrect_options.cl
+++ clang/test/Misc/opencl-c-3.0.incorrect_options.cl
@@ -1,8 +1,7 @@
 // RUN: not %clang_cc1 -cl-std=CL3.0 -triple spir-unknown-unknown -cl-ext=-__opencl_c_fp64,+cl_khr_fp64 %s 2>&1 | FileCheck -check-prefix=CHECK-FP64 %s
 // RUN: not %clang_cc1 -cl-std=CL3.0 -triple spir-unknown-unknown -cl-ext=+__opencl_c_fp64,-cl_khr_fp64 %s 2>&1 | FileCheck -check-prefix=CHECK-FP64 %s
-
 // RUN: not %clang_cc1 -cl-std=CL3.0 -triple spir-unknown-unknown -cl-ext=+__opencl_c_read_write_images,-__opencl_c_images %s 2>&1 | FileCheck 

[PATCH] D106260: [OpenCL] Add support of __opencl_c_3d_image_writes feature macro

2021-07-29 Thread Anton Zabaznov via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf16a4fcbe510: [OpenCL] Add support of 
__opencl_c_3d_image_writes feature macro (authored by azabaznov).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106260

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Basic/OpenCLOptions.cpp
  clang/lib/Basic/Targets/AMDGPU.h
  clang/lib/Sema/SemaType.cpp
  clang/test/Misc/opencl-c-3.0.incorrect_options.cl
  clang/test/SemaOpenCL/unsupported-image.cl

Index: clang/test/SemaOpenCL/unsupported-image.cl
===
--- clang/test/SemaOpenCL/unsupported-image.cl
+++ clang/test/SemaOpenCL/unsupported-image.cl
@@ -1,7 +1,8 @@
-// RUN: %clang_cc1 -triple spir-unknown-unknown -verify -cl-std=CL3.0 -cl-ext=-__opencl_c_images,-__opencl_c_read_write_images %s
-// RUN: %clang_cc1 -triple spir-unknown-unknown -verify -cl-std=CL3.0 -cl-ext=+__opencl_c_images %s
+// RUN: %clang_cc1 -triple spir-unknown-unknown -verify -cl-std=CL3.0 -cl-ext=-__opencl_c_images,-__opencl_c_read_write_images,-cl_khr_3d_image_writes,-__opencl_c_3d_image_writes %s
+// RUN: %clang_cc1 -triple spir-unknown-unknown -verify -cl-std=CL3.0 -cl-ext=+__opencl_c_images,+__opencl_c_read_write_images,+cl_khr_3d_image_writes,+__opencl_c_3d_image_writes %s
+// RUN: %clang_cc1 -triple spir-unknown-unknown -verify -cl-std=CL3.0 -cl-ext=+__opencl_c_images,+__opencl_c_read_write_images,-cl_khr_3d_image_writes,-__opencl_c_3d_image_writes %s
 
-#ifdef __opencl_c_images
+#if defined(__opencl_c_images) && defined(__opencl_c_3d_image_writes)
 //expected-no-diagnostics
 #endif
 
@@ -59,3 +60,10 @@
 #if !defined(__opencl_c_images)
 // expected-error@-2{{use of type 'sampler_t' requires __opencl_c_images support}}
 #endif
+
+void test12(write_only image3d_t i) {}
+#if !defined(__opencl_c_images)
+// expected-error@-2{{use of type '__write_only image3d_t' requires __opencl_c_images support}}
+#elif !defined(__opencl_c_3d_image_writes)
+// expected-error@-4{{use of type '__write_only image3d_t' requires cl_khr_3d_image_writes and __opencl_c_3d_image_writes support}}
+#endif
Index: clang/test/Misc/opencl-c-3.0.incorrect_options.cl
===
--- clang/test/Misc/opencl-c-3.0.incorrect_options.cl
+++ clang/test/Misc/opencl-c-3.0.incorrect_options.cl
@@ -1,6 +1,14 @@
 // RUN: not %clang_cc1 -cl-std=CL3.0 -triple spir-unknown-unknown -cl-ext=-__opencl_c_fp64,+cl_khr_fp64 %s 2>&1 | FileCheck -check-prefix=CHECK-FP64 %s
 // RUN: not %clang_cc1 -cl-std=CL3.0 -triple spir-unknown-unknown -cl-ext=+__opencl_c_fp64,-cl_khr_fp64 %s 2>&1 | FileCheck -check-prefix=CHECK-FP64 %s
+
 // RUN: not %clang_cc1 -cl-std=CL3.0 -triple spir-unknown-unknown -cl-ext=+__opencl_c_read_write_images,-__opencl_c_images %s 2>&1 | FileCheck -check-prefix=CHECK-READ-WRITE-IMAGES %s
 
+// RUN: not %clang_cc1 -cl-std=CL3.0 -triple spir-unknown-unknown -cl-ext=+__opencl_c_3d_image_writes,+__opencl_c_images,-cl_khr_3d_image_writes %s 2>&1 | FileCheck -check-prefix=CHECK-3D-WRITE-IMAGES-DIFF %s
+// RUN: not %clang_cc1 -cl-std=CL3.0 -triple spir-unknown-unknown -cl-ext=+__opencl_c_3d_image_writes,-__opencl_c_images %s 2>&1 | FileCheck -check-prefix=CHECK-3D-WRITE-IMAGES-DEPS %s
+
 // CHECK-FP64: error: options cl_khr_fp64 and __opencl_c_fp64 are set to different values
+
 // CHECK-READ-WRITE-IMAGES: error: feature __opencl_c_read_write_images requires support of __opencl_c_images feature
+
+// CHECK-3D-WRITE-IMAGES-DIFF: options cl_khr_3d_image_writes and __opencl_c_3d_image_writes are set to different values
+// CHECK-3D-WRITE-IMAGES-DEPS: error: feature __opencl_c_3d_image_writes requires support of __opencl_c_images feature
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -1525,18 +1525,20 @@
 break;
   case DeclSpec::TST_float:   Result = Context.FloatTy; break;
   case DeclSpec::TST_double:
+if (DS.getTypeSpecWidth() == TypeSpecifierWidth::Long)
+  Result = Context.LongDoubleTy;
+else
+  Result = Context.DoubleTy;
 if (S.getLangOpts().OpenCL) {
   if (!S.getOpenCLOptions().isSupported("cl_khr_fp64", S.getLangOpts()))
-S.Diag(DS.getTypeSpecTypeLoc(),
-   diag::err_opencl_double_requires_extension)
-<< (S.getLangOpts().OpenCLVersion >= 300);
+S.Diag(DS.getTypeSpecTypeLoc(), diag::err_opencl_requires_extension)
+<< 0 << Result
+<< (S.getLangOpts().OpenCLVersion == 300
+? "cl_khr_fp64 and __opencl_c_fp64"
+: "cl_khr_fp64");
   else if (!S.getOpenCLOptions().isAvailableOption("cl_khr_fp64", S.getLangOpts()))
 S.Diag(DS.getTypeSpecTypeLoc(), 

[clang] f16a4fc - [OpenCL] Add support of __opencl_c_3d_image_writes feature macro

2021-07-29 Thread Anton Zabaznov via cfe-commits

Author: Anton Zabaznov
Date: 2021-07-30T04:54:28+03:00
New Revision: f16a4fcbe510d17b3f361d446eaf223208ded2bd

URL: 
https://github.com/llvm/llvm-project/commit/f16a4fcbe510d17b3f361d446eaf223208ded2bd
DIFF: 
https://github.com/llvm/llvm-project/commit/f16a4fcbe510d17b3f361d446eaf223208ded2bd.diff

LOG: [OpenCL] Add support of __opencl_c_3d_image_writes feature macro

This feature requires support of __opencl_c_images, so diagnostics for that is 
provided as well.
Also, ensure that cl_khr_3d_image_writes feature macro is set to the same value.

Reviewed By: Anastasia

Differential Revision: https://reviews.llvm.org/D106260

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/Basic/OpenCLOptions.cpp
clang/lib/Basic/Targets/AMDGPU.h
clang/lib/Sema/SemaType.cpp
clang/test/Misc/opencl-c-3.0.incorrect_options.cl
clang/test/SemaOpenCL/unsupported-image.cl

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index a777f08de890..71e7ffdbe8a0 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -10106,8 +10106,6 @@ def err_opencl_requires_extension : Error<
 def ext_opencl_double_without_pragma : Extension<
   "Clang permits use of type 'double' regardless pragma if 'cl_khr_fp64' is"
   " supported">;
-def err_opencl_double_requires_extension :  Error<
-"use of type 'double' requires %select{cl_khr_fp64|cl_khr_fp64 and 
__opencl_c_fp64}0 support">;
 def warn_opencl_generic_address_space_arg : Warning<
   "passing non-generic address space pointer to %0"
   " may cause dynamic conversion affecting performance">,

diff  --git a/clang/lib/Basic/OpenCLOptions.cpp 
b/clang/lib/Basic/OpenCLOptions.cpp
index 2e215b185f66..f4f474fade4d 100644
--- a/clang/lib/Basic/OpenCLOptions.cpp
+++ b/clang/lib/Basic/OpenCLOptions.cpp
@@ -111,7 +111,8 @@ bool OpenCLOptions::diagnoseUnsupportedFeatureDependencies(
   // Feature pairs. First feature in a pair requires the second one to be
   // supported.
   static const llvm::StringMap DependentFeaturesMap = {
-  {"__opencl_c_read_write_images", "__opencl_c_images"}};
+  {"__opencl_c_read_write_images", "__opencl_c_images"},
+  {"__opencl_c_3d_image_writes", "__opencl_c_images"}};
 
   auto OpenCLFeaturesMap = TI.getSupportedOpenCLOpts();
 
@@ -130,7 +131,8 @@ bool OpenCLOptions::diagnoseFeatureExtensionDifferences(
 const TargetInfo , DiagnosticsEngine ) {
   // Extensions and equivalent feature pairs.
   static const llvm::StringMap FeatureExtensionMap = {
-  {"cl_khr_fp64", "__opencl_c_fp64"}};
+  {"cl_khr_fp64", "__opencl_c_fp64"},
+  {"cl_khr_3d_image_writes", "__opencl_c_3d_image_writes"}};
 
   auto OpenCLFeaturesMap = TI.getSupportedOpenCLOpts();
 

diff  --git a/clang/lib/Basic/Targets/AMDGPU.h 
b/clang/lib/Basic/Targets/AMDGPU.h
index 244a6e044690..2e580ecf2425 100644
--- a/clang/lib/Basic/Targets/AMDGPU.h
+++ b/clang/lib/Basic/Targets/AMDGPU.h
@@ -310,9 +310,12 @@ class LLVM_LIBRARY_VISIBILITY AMDGPUTargetInfo final : 
public TargetInfo {
   Opts["cl_khr_mipmap_image"] = true;
   Opts["cl_khr_mipmap_image_writes"] = true;
   Opts["cl_khr_subgroups"] = true;
-  Opts["cl_khr_3d_image_writes"] = true;
   Opts["cl_amd_media_ops"] = true;
   Opts["cl_amd_media_ops2"] = true;
+
+  Opts["__opencl_c_images"] = true;
+  Opts["__opencl_c_3d_image_writes"] = true;
+  Opts["cl_khr_3d_image_writes"] = true;
 }
   }
 

diff  --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp
index 058c22936dbe..173f61aeb95a 100644
--- a/clang/lib/Sema/SemaType.cpp
+++ b/clang/lib/Sema/SemaType.cpp
@@ -1525,18 +1525,20 @@ static QualType 
ConvertDeclSpecToType(TypeProcessingState ) {
 break;
   case DeclSpec::TST_float:   Result = Context.FloatTy; break;
   case DeclSpec::TST_double:
+if (DS.getTypeSpecWidth() == TypeSpecifierWidth::Long)
+  Result = Context.LongDoubleTy;
+else
+  Result = Context.DoubleTy;
 if (S.getLangOpts().OpenCL) {
   if (!S.getOpenCLOptions().isSupported("cl_khr_fp64", S.getLangOpts()))
-S.Diag(DS.getTypeSpecTypeLoc(),
-   diag::err_opencl_double_requires_extension)
-<< (S.getLangOpts().OpenCLVersion >= 300);
+S.Diag(DS.getTypeSpecTypeLoc(), diag::err_opencl_requires_extension)
+<< 0 << Result
+<< (S.getLangOpts().OpenCLVersion == 300
+? "cl_khr_fp64 and __opencl_c_fp64"
+: "cl_khr_fp64");
   else if (!S.getOpenCLOptions().isAvailableOption("cl_khr_fp64", 
S.getLangOpts()))
 S.Diag(DS.getTypeSpecTypeLoc(), 
diag::ext_opencl_double_without_pragma);
 }
-if (DS.getTypeSpecWidth() == TypeSpecifierWidth::Long)
-  Result = Context.LongDoubleTy;
-else
-  Result = 

[PATCH] D106900: [PowerPC][AIX] Packed zero-width bitfields do not affect alignment.

2021-07-29 Thread Zarko Todorovski via Phabricator via cfe-commits
ZarkoCA accepted this revision.
ZarkoCA added a comment.

LGTM also. Just a comment typo.




Comment at: clang/lib/AST/RecordLayoutBuilder.cpp:1779
+  // On AIX, zero-width bitfields pad out to the natural alignment boundary,
+  // but dont increase the alignment greater than the MaxFieldAlignment, or 1
+  // if packed.





Comment at: clang/lib/AST/RecordLayoutBuilder.cpp:1779
+  // On AIX, zero-width bitfields pad out to the natural alignment boundary,
+  // but dont increase the alignment greater than the MaxFieldAlignment, or 1
+  // if packed.

ZarkoCA wrote:
> 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106900

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


[PATCH] D98709: [clang-tidy] New feature --skip-headers, part 1, LocFilter

2021-07-29 Thread Chih-Hung Hsieh via Phabricator via cfe-commits
chh added a comment.

This is enhanced implementation over D98710 , 
to handle the new found failed test cases.


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

https://reviews.llvm.org/D98709

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


[PATCH] D106900: [PowerPC][AIX] Packed zero-width bitfields do not affect alignment.

2021-07-29 Thread Steven Wan via Phabricator via cfe-commits
stevewan accepted this revision.
stevewan added a comment.
This revision is now accepted and ready to land.

LGTM with some nits.




Comment at: clang/lib/AST/RecordLayoutBuilder.cpp:1781
-  // pragma align(packed).
-  if (isAIXLayout(Context) && !MaxFieldAlignment.isZero() && !FieldSize)
-FieldAlign = std::min(FieldAlign, MaxFieldAlignmentInBits);

Just noting that the comment says `MaxFieldAlignment - The maximum allowed 
field alignment. This is set by #pragma pack`, but `__attribute__(packed)` also 
seems to set it to some large value that is at least as large as the 
FieldAlign. Maybe edit the comment accordingly for now, and a future follow-on 
patch if necessary.



Comment at: clang/test/Layout/aix-packed-bitfields.c:95
+
+#pragma pack(2)
+struct __attribute__((packed)) PackedAttrAndPragma {

nit: might be helpful to use a different type for the zero-width bitfield here. 
(e.g., `long long : 0`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106900

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


[PATCH] D107082: [X86][RFC] Enable `_Float16` type support on X86 following the psABI

2021-07-29 Thread Pengfei Wang via Phabricator via cfe-commits
pengfei added a comment.

In D107082#2913881 , @craig.topper 
wrote:

> I haven't had a chance to look at this patch in detail, but I wanted to ask 
> if you considered doing what ARM and RISCV do for this. They pass the f16 in 
> the lower bits on an f32 by only changing the ABI handling code in the 
> backend. The type legalizer takes care of the rest. That seems simpler than 
> this patch. See for example https://reviews.llvm.org/D98670

Thanks Craig for the information. I referenced implementation in AArch64. I 
think we have to add a legal f16 type in this way because:

1. We will support `_Float16` type in Clang on SSE2 and above to keep the same 
behavior with GCC. So a legal type is a must.
2. Using lower 16bits of f32 may not satisfice the requirment from calling 
conversion of aggregation type and complex type defined by psABI.
3. We have some optimizations to leverage F16C or AVX512 ps2ph/ph2ps 
instructions. A legal type is easy to customize.

Besides, we have full arithmatic f16 support in AVX512FP16. Most of the code 
here are shared and served for both scenarios. We just need to promote for most 
FP operations and expand or customize `FP_ROUND` and `FP_EXTEND` here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107082

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


[PATCH] D107125: [Diagnostic] Split 'qualifier on reference type has no effect' out into a new flag

2021-07-29 Thread Luna Kirkby via Phabricator via cfe-commits
lunasorcery created this revision.
lunasorcery added a reviewer: rsmith.
lunasorcery added a project: clang.
lunasorcery requested review of this revision.
Herald added a subscriber: cfe-commits.

This introduces a new flag `ignored-reference-qualifiers` for the existing "'A' 
qualifier on reference type B has no effect" diagnostic, as a child of 
`ignored-qualifiers`.

Rationale:
This particular diagnostic is enabled by default, but other parts of 
`ignored-qualifiers` are not. Anecdotally, a user may encounter this diagnostic 
in the wild, and, seeing it to be valuable, might try to raise it to error with 
`-Werror=ignored-qualifiers`, whereupon the //other// diagnostics the flag 
covers will also be raised, to the user's surprise and confusion. By splitting 
this diagnostic out into a separate flag, and marking it as a child of 
`ignored-qualifiers`, we maintain backwards compatibility with existing build 
scripts, while allowing the user more granular control of the diagnostics they 
care about.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D107125

Files:
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td


Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -5733,7 +5733,7 @@
   "'%0' qualifier on function type %1 has unspecified behavior">;
 def warn_typecheck_reference_qualifiers : Warning<
   "'%0' qualifier on reference type %1 has no effect">,
-  InGroup;
+  InGroup;
 def err_typecheck_invalid_restrict_not_pointer : Error<
   "restrict requires a pointer or reference (%0 is invalid)">;
 def err_typecheck_invalid_restrict_not_pointer_noarg : Error<
Index: clang/include/clang/Basic/DiagnosticGroups.td
===
--- clang/include/clang/Basic/DiagnosticGroups.td
+++ clang/include/clang/Basic/DiagnosticGroups.td
@@ -400,7 +400,8 @@
 def InfiniteRecursion : DiagGroup<"infinite-recursion">;
 def PureVirtualCallFromCtorDtor: 
DiagGroup<"call-to-pure-virtual-from-ctor-dtor">;
 def GNUImaginaryConstant : DiagGroup<"gnu-imaginary-constant">;
-def IgnoredQualifiers : DiagGroup<"ignored-qualifiers">;
+def IgnoredReferenceQualifiers : DiagGroup<"ignored-reference-qualifiers">;
+def IgnoredQualifiers : DiagGroup<"ignored-qualifiers", 
[IgnoredReferenceQualifiers]>;
 def : DiagGroup<"import">;
 def GNUIncludeNext : DiagGroup<"gnu-include-next">;
 def IncompatibleMSStruct : DiagGroup<"incompatible-ms-struct">;


Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -5733,7 +5733,7 @@
   "'%0' qualifier on function type %1 has unspecified behavior">;
 def warn_typecheck_reference_qualifiers : Warning<
   "'%0' qualifier on reference type %1 has no effect">,
-  InGroup;
+  InGroup;
 def err_typecheck_invalid_restrict_not_pointer : Error<
   "restrict requires a pointer or reference (%0 is invalid)">;
 def err_typecheck_invalid_restrict_not_pointer_noarg : Error<
Index: clang/include/clang/Basic/DiagnosticGroups.td
===
--- clang/include/clang/Basic/DiagnosticGroups.td
+++ clang/include/clang/Basic/DiagnosticGroups.td
@@ -400,7 +400,8 @@
 def InfiniteRecursion : DiagGroup<"infinite-recursion">;
 def PureVirtualCallFromCtorDtor: DiagGroup<"call-to-pure-virtual-from-ctor-dtor">;
 def GNUImaginaryConstant : DiagGroup<"gnu-imaginary-constant">;
-def IgnoredQualifiers : DiagGroup<"ignored-qualifiers">;
+def IgnoredReferenceQualifiers : DiagGroup<"ignored-reference-qualifiers">;
+def IgnoredQualifiers : DiagGroup<"ignored-qualifiers", [IgnoredReferenceQualifiers]>;
 def : DiagGroup<"import">;
 def GNUIncludeNext : DiagGroup<"gnu-include-next">;
 def IncompatibleMSStruct : DiagGroup<"incompatible-ms-struct">;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D106854: Pass `--start-group` and `--end-group` to the linker when using the AVR toolchain

2021-07-29 Thread Ben Shi via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG1e6a93f15c7e: [AVR][clang] Pass --start-group 
and --end-group options to avr-ld (authored by mhjacobson, 
committed by benshi001).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106854

Files:
  clang/lib/Driver/ToolChains/AVR.cpp
  clang/test/Driver/avr-ld.c


Index: clang/test/Driver/avr-ld.c
===
--- clang/test/Driver/avr-ld.c
+++ clang/test/Driver/avr-ld.c
@@ -1,44 +1,44 @@
 // RUN: %clang -### --target=avr -mmcu=at90s2313 --sysroot 
%S/Inputs/basic_avr_tree %s 2>&1 | FileCheck -check-prefix LINKA %s
-// LINKA: {{".*ld.*"}} {{.*}} {{"-L.*tiny-stack"}} {{.*}} "-Tdata=0x800060" 
{{.*}} "-lat90s2313" "-mavr2"
+// LINKA: {{".*ld.*"}} {{.*}} {{"-L.*tiny-stack"}} {{.*}} "-Tdata=0x800060" 
"--start-group" {{.*}} "-lat90s2313" "--end-group" "-mavr2"
 
 // RUN: %clang -### --target=avr -mmcu=at90s8515 --sysroot 
%S/Inputs/basic_avr_tree %s 2>&1 | FileCheck -check-prefix LINKB %s
-// LINKB: {{".*ld.*"}} {{.*}} "-Tdata=0x800060" {{.*}} "-lat90s8515" "-mavr2"
+// LINKB: {{".*ld.*"}} {{.*}} "-Tdata=0x800060" "--start-group" {{.*}} 
"-lat90s8515" "--end-group" "-mavr2"
 
 // RUN: %clang -### --target=avr -mmcu=attiny13 --sysroot 
%S/Inputs/basic_avr_tree %s 2>&1 | FileCheck -check-prefix LINKC %s
-// LINKC: {{".*ld.*"}} {{.*}} {{"-L.*avr25/tiny-stack"}} {{.*}} 
"-Tdata=0x800060" {{.*}} "-lattiny13" "-mavr25"
+// LINKC: {{".*ld.*"}} {{.*}} {{"-L.*avr25/tiny-stack"}} {{.*}} 
"-Tdata=0x800060" "--start-group" {{.*}} "-lattiny13" "--end-group" "-mavr25"
 
 // RUN: %clang -### --target=avr -mmcu=attiny44 --sysroot 
%S/Inputs/basic_avr_tree %s 2>&1 | FileCheck -check-prefix LINKD %s
-// LINKD: {{".*ld.*"}} {{.*}} {{"-L.*avr25"}} {{.*}} "-Tdata=0x800060" {{.*}} 
"-lattiny44" "-mavr25"
+// LINKD: {{".*ld.*"}} {{.*}} {{"-L.*avr25"}} {{.*}} "-Tdata=0x800060" 
"--start-group" {{.*}} "-lattiny44" "--end-group" "-mavr25"
 
 // RUN: %clang -### --target=avr -mmcu=atmega103 --sysroot 
%S/Inputs/basic_avr_tree %s 2>&1 | FileCheck -check-prefix LINKE %s
-// LINKE: {{".*ld.*"}} {{.*}} {{"-L.*avr31"}} {{.*}} "-Tdata=0x800060" {{.*}} 
"-latmega103" "-mavr31"
+// LINKE: {{".*ld.*"}} {{.*}} {{"-L.*avr31"}} {{.*}} "-Tdata=0x800060" 
"--start-group" {{.*}} "-latmega103" "--end-group" "-mavr31"
 
 // RUN: %clang -### --target=avr -mmcu=atmega8u2 --sysroot 
%S/Inputs/basic_avr_tree %s 2>&1 | FileCheck -check-prefix LINKF %s
-// LINKF: {{".*ld.*"}} {{.*}} {{"-L.*avr35"}} {{.*}} "-Tdata=0x800100" {{.*}} 
"-latmega8u2" "-mavr35"
+// LINKF: {{".*ld.*"}} {{.*}} {{"-L.*avr35"}} {{.*}} "-Tdata=0x800100" 
"--start-group" {{.*}} "-latmega8u2" "--end-group" "-mavr35"
 
 // RUN: %clang -### --target=avr -mmcu=atmega48pa --sysroot 
%S/Inputs/basic_avr_tree %s 2>&1 | FileCheck -check-prefix LINKG %s
-// LINKG: {{".*ld.*"}} {{.*}} {{"-L.*avr4"}} {{.*}} "-Tdata=0x800100" {{.*}} 
"-latmega48pa" "-mavr4"
+// LINKG: {{".*ld.*"}} {{.*}} {{"-L.*avr4"}} {{.*}} "-Tdata=0x800100" 
"--start-group" {{.*}} "-latmega48pa" "--end-group" "-mavr4"
 
 // RUN: %clang -### --target=avr -mmcu=atmega328 --sysroot 
%S/Inputs/basic_avr_tree %s 2>&1 | FileCheck -check-prefix LINKH %s
-// LINKH: {{".*ld.*"}} {{.*}} {{"-L.*avr5"}} {{.*}} "-Tdata=0x800100" {{.*}} 
"-latmega328" "-mavr5"
+// LINKH: {{".*ld.*"}} {{.*}} {{"-L.*avr5"}} {{.*}} "-Tdata=0x800100" 
"--start-group" {{.*}} "-latmega328" "--end-group" "-mavr5"
 
 // RUN: %clang -### --target=avr -mmcu=atmega1281 --sysroot 
%S/Inputs/basic_avr_tree %s 2>&1 | FileCheck -check-prefix LINKI %s
-// LINKI: {{".*ld.*"}} {{.*}} {{"-L.*avr51"}} {{.*}} "-Tdata=0x800200" {{.*}} 
"-latmega1281" "-mavr51"
+// LINKI: {{".*ld.*"}} {{.*}} {{"-L.*avr51"}} {{.*}} "-Tdata=0x800200" 
"--start-group" {{.*}} "-latmega1281" "--end-group" "-mavr51"
 
 // RUN: %clang -### --target=avr -mmcu=atmega2560 --sysroot 
%S/Inputs/basic_avr_tree %s 2>&1 | FileCheck -check-prefix LINKJ %s
-// LINKJ: {{".*ld.*"}} {{.*}} {{"-L.*avr6"}} {{.*}} "-Tdata=0x800200" {{.*}} 
"-latmega2560" "-mavr6"
+// LINKJ: {{".*ld.*"}} {{.*}} {{"-L.*avr6"}} {{.*}} "-Tdata=0x800200" 
"--start-group" {{.*}} "-latmega2560" "--end-group" "-mavr6"
 
 // RUN: %clang -### --target=avr -mmcu=attiny10 --sysroot 
%S/Inputs/basic_avr_tree %s 2>&1 | FileCheck -check-prefix LINKK %s
-// LINKK: {{".*ld.*"}} {{.*}} {{"-L.*avrtiny"}} {{.*}} "-Tdata=0x800040" 
{{.*}} "-lattiny10" "-mavrtiny"
+// LINKK: {{".*ld.*"}} {{.*}} {{"-L.*avrtiny"}} {{.*}} "-Tdata=0x800040" 
"--start-group" {{.*}} "-lattiny10" "--end-group" "-mavrtiny"
 
 // RUN: %clang -### --target=avr -mmcu=atxmega16a4 --sysroot 
%S/Inputs/basic_avr_tree %s 2>&1 | FileCheck -check-prefix LINKL %s
-// LINKL: {{".*ld.*"}} {{.*}} {{"-L.*avrxmega2"}} {{.*}} "-Tdata=0x802000" 
{{.*}} "-latxmega16a4" "-mavrxmega2"
+// LINKL: {{".*ld.*"}} {{.*}} {{"-L.*avrxmega2"}} {{.*}} "-Tdata=0x802000" 
"--start-group" 

[clang] 1e6a93f - [AVR][clang] Pass '--start-group' and '--end-group' options to avr-ld

2021-07-29 Thread Ben Shi via cfe-commits

Author: Matt Jacobson
Date: 2021-07-30T08:25:14+08:00
New Revision: 1e6a93f15c7ea890c876a3a10c7e3970a1710dff

URL: 
https://github.com/llvm/llvm-project/commit/1e6a93f15c7ea890c876a3a10c7e3970a1710dff
DIFF: 
https://github.com/llvm/llvm-project/commit/1e6a93f15c7ea890c876a3a10c7e3970a1710dff.diff

LOG: [AVR][clang] Pass '--start-group' and '--end-group' options to avr-ld

Reviewed By: Ben Shi

Differential Revision: https://reviews.llvm.org/D106854

Added: 


Modified: 
clang/lib/Driver/ToolChains/AVR.cpp
clang/test/Driver/avr-ld.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/AVR.cpp 
b/clang/lib/Driver/ToolChains/AVR.cpp
index f147292038a8..5b097f9b2ed9 100644
--- a/clang/lib/Driver/ToolChains/AVR.cpp
+++ b/clang/lib/Driver/ToolChains/AVR.cpp
@@ -414,6 +414,8 @@ void AVR::Linker::ConstructJob(Compilation , const 
JobAction ,
   if (LinkStdlib) {
 assert(!CPU.empty() && "CPU name must be known in order to link stdlibs");
 
+CmdArgs.push_back("--start-group");
+
 // Add the object file for the CRT.
 std::string CrtFileName = std::string("-l:crt") + CPU + std::string(".o");
 CmdArgs.push_back(Args.MakeArgString(CrtFileName));
@@ -425,6 +427,8 @@ void AVR::Linker::ConstructJob(Compilation , const 
JobAction ,
 // Add the link library specific to the MCU.
 CmdArgs.push_back(Args.MakeArgString(std::string("-l") + CPU));
 
+CmdArgs.push_back("--end-group");
+
 // Specify the family name as the emulation mode to use.
 // This is almost always required because otherwise avr-ld
 // will assume 'avr2' and warn about the program being larger

diff  --git a/clang/test/Driver/avr-ld.c b/clang/test/Driver/avr-ld.c
index 535990bf9570..aa530651152c 100644
--- a/clang/test/Driver/avr-ld.c
+++ b/clang/test/Driver/avr-ld.c
@@ -1,44 +1,44 @@
 // RUN: %clang -### --target=avr -mmcu=at90s2313 --sysroot 
%S/Inputs/basic_avr_tree %s 2>&1 | FileCheck -check-prefix LINKA %s
-// LINKA: {{".*ld.*"}} {{.*}} {{"-L.*tiny-stack"}} {{.*}} "-Tdata=0x800060" 
{{.*}} "-lat90s2313" "-mavr2"
+// LINKA: {{".*ld.*"}} {{.*}} {{"-L.*tiny-stack"}} {{.*}} "-Tdata=0x800060" 
"--start-group" {{.*}} "-lat90s2313" "--end-group" "-mavr2"
 
 // RUN: %clang -### --target=avr -mmcu=at90s8515 --sysroot 
%S/Inputs/basic_avr_tree %s 2>&1 | FileCheck -check-prefix LINKB %s
-// LINKB: {{".*ld.*"}} {{.*}} "-Tdata=0x800060" {{.*}} "-lat90s8515" "-mavr2"
+// LINKB: {{".*ld.*"}} {{.*}} "-Tdata=0x800060" "--start-group" {{.*}} 
"-lat90s8515" "--end-group" "-mavr2"
 
 // RUN: %clang -### --target=avr -mmcu=attiny13 --sysroot 
%S/Inputs/basic_avr_tree %s 2>&1 | FileCheck -check-prefix LINKC %s
-// LINKC: {{".*ld.*"}} {{.*}} {{"-L.*avr25/tiny-stack"}} {{.*}} 
"-Tdata=0x800060" {{.*}} "-lattiny13" "-mavr25"
+// LINKC: {{".*ld.*"}} {{.*}} {{"-L.*avr25/tiny-stack"}} {{.*}} 
"-Tdata=0x800060" "--start-group" {{.*}} "-lattiny13" "--end-group" "-mavr25"
 
 // RUN: %clang -### --target=avr -mmcu=attiny44 --sysroot 
%S/Inputs/basic_avr_tree %s 2>&1 | FileCheck -check-prefix LINKD %s
-// LINKD: {{".*ld.*"}} {{.*}} {{"-L.*avr25"}} {{.*}} "-Tdata=0x800060" {{.*}} 
"-lattiny44" "-mavr25"
+// LINKD: {{".*ld.*"}} {{.*}} {{"-L.*avr25"}} {{.*}} "-Tdata=0x800060" 
"--start-group" {{.*}} "-lattiny44" "--end-group" "-mavr25"
 
 // RUN: %clang -### --target=avr -mmcu=atmega103 --sysroot 
%S/Inputs/basic_avr_tree %s 2>&1 | FileCheck -check-prefix LINKE %s
-// LINKE: {{".*ld.*"}} {{.*}} {{"-L.*avr31"}} {{.*}} "-Tdata=0x800060" {{.*}} 
"-latmega103" "-mavr31"
+// LINKE: {{".*ld.*"}} {{.*}} {{"-L.*avr31"}} {{.*}} "-Tdata=0x800060" 
"--start-group" {{.*}} "-latmega103" "--end-group" "-mavr31"
 
 // RUN: %clang -### --target=avr -mmcu=atmega8u2 --sysroot 
%S/Inputs/basic_avr_tree %s 2>&1 | FileCheck -check-prefix LINKF %s
-// LINKF: {{".*ld.*"}} {{.*}} {{"-L.*avr35"}} {{.*}} "-Tdata=0x800100" {{.*}} 
"-latmega8u2" "-mavr35"
+// LINKF: {{".*ld.*"}} {{.*}} {{"-L.*avr35"}} {{.*}} "-Tdata=0x800100" 
"--start-group" {{.*}} "-latmega8u2" "--end-group" "-mavr35"
 
 // RUN: %clang -### --target=avr -mmcu=atmega48pa --sysroot 
%S/Inputs/basic_avr_tree %s 2>&1 | FileCheck -check-prefix LINKG %s
-// LINKG: {{".*ld.*"}} {{.*}} {{"-L.*avr4"}} {{.*}} "-Tdata=0x800100" {{.*}} 
"-latmega48pa" "-mavr4"
+// LINKG: {{".*ld.*"}} {{.*}} {{"-L.*avr4"}} {{.*}} "-Tdata=0x800100" 
"--start-group" {{.*}} "-latmega48pa" "--end-group" "-mavr4"
 
 // RUN: %clang -### --target=avr -mmcu=atmega328 --sysroot 
%S/Inputs/basic_avr_tree %s 2>&1 | FileCheck -check-prefix LINKH %s
-// LINKH: {{".*ld.*"}} {{.*}} {{"-L.*avr5"}} {{.*}} "-Tdata=0x800100" {{.*}} 
"-latmega328" "-mavr5"
+// LINKH: {{".*ld.*"}} {{.*}} {{"-L.*avr5"}} {{.*}} "-Tdata=0x800100" 
"--start-group" {{.*}} "-latmega328" "--end-group" "-mavr5"
 
 // RUN: %clang -### --target=avr -mmcu=atmega1281 --sysroot 
%S/Inputs/basic_avr_tree %s 2>&1 | FileCheck -check-prefix LINKI %s
-// LINKI: {{".*ld.*"}} {{.*}} 

[PATCH] D106862: [clang][modules] Avoid creating partial FullSourceLoc for explicit modules imports

2021-07-29 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added a comment.

In D106862#2913815 , @arphaman wrote:

> I think this approach makes sense for now. It's unfortunate that the 
> constructor of FullSourceLoc is unable to validate this requirement, do you 
> know how many clients that you describe as modifying their ID to make them 
> valid are there?

(Maybe an `Optional` would work for those clients?)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106862

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


[PATCH] D105907: [CallGraphSection] Add call graph section options and documentation

2021-07-29 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

My previous feeling still applies. It seems to me that the clang driver patch 
should be the last.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105907

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


[PATCH] D106753: ConvertUTF: Created wrapper convertUTF32ToUTF8String

2021-07-29 Thread Marcus Johnson via Phabricator via cfe-commits
MarcusJohnson91 updated this revision to Diff 362923.

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

https://reviews.llvm.org/D106753

Files:
  llvm/include/llvm/Support/ConvertUTF.h
  llvm/lib/Support/ConvertUTFWrapper.cpp
  llvm/unittests/Support/ConvertUTFTest.cpp

Index: llvm/unittests/Support/ConvertUTFTest.cpp
===
--- llvm/unittests/Support/ConvertUTFTest.cpp
+++ llvm/unittests/Support/ConvertUTFTest.cpp
@@ -25,6 +25,17 @@
   EXPECT_EQ(Expected, Result);
 }
 
+TEST(ConvertUTFTest, ConvertUTF32LittleEndianToUTF8String) {
+  // Src is a crystal ball.
+  alignas(UTF32) static const char Src[] = "\x2E\xF5\x01\x00";
+  ArrayRef Ref(Src, sizeof(Src) - 1);
+  std::string Result;
+  bool Success = convertUTF32ToUTF8String(Ref, Result);
+  EXPECT_TRUE(Success);
+  std::string Expected("\xF0\x9F\x94\xAE");
+  EXPECT_EQ(Expected, Result);
+}
+
 TEST(ConvertUTFTest, ConvertUTF16BigEndianToUTF8String) {
   // Src is the look of disapproval.
   alignas(UTF16) static const char Src[] = "\xfe\xff\x0c\xa0\x00_\x0c\xa0";
@@ -36,6 +47,17 @@
   EXPECT_EQ(Expected, Result);
 }
 
+TEST(ConvertUTFTest, ConvertUTF32BigEndianToUTF8String) {
+  // Src is a crystal ball.
+  alignas(UTF32) static const char Src[] = "\x00\x00\xfe\xff\x00\x01\xF5\x2E";
+  ArrayRef Ref(Src, sizeof(Src) - 1);
+  std::string Result;
+  bool Success = convertUTF32ToUTF8String(Ref, Result);
+  EXPECT_TRUE(Success);
+  std::string Expected("\xF0\x9F\x94\xAE");
+  EXPECT_EQ(Expected, Result);
+}
+
 TEST(ConvertUTFTest, ConvertUTF8ToUTF16String) {
   // Src is the look of disapproval.
   static const char Src[] = "\xe0\xb2\xa0_\xe0\xb2\xa0";
Index: llvm/lib/Support/ConvertUTFWrapper.cpp
===
--- llvm/lib/Support/ConvertUTFWrapper.cpp
+++ llvm/lib/Support/ConvertUTFWrapper.cpp
@@ -141,6 +141,60 @@
   Src.size() * sizeof(UTF16)), Out);
 }
 
+bool convertUTF32ToUTF8String(ArrayRef SrcBytes, std::string ) {
+  assert(Out.empty());
+
+  // Avoid OOB by returning early on empty input.
+  if (SrcBytes.empty())
+return true;
+
+  const UTF32 *Src = reinterpret_cast(SrcBytes.begin());
+  const UTF32 *SrcEnd = reinterpret_cast(SrcBytes.end());
+
+  assert((uintptr_t)Src % sizeof(UTF32) == 0);
+
+  // Byteswap if necessary.
+  std::vector ByteSwapped;
+  if (Src[0] == UNI_UTF32_BYTE_ORDER_MARK_SWAPPED) {
+ByteSwapped.insert(ByteSwapped.end(), Src, SrcEnd);
+for (unsigned I = 0, E = ByteSwapped.size(); I != E; ++I)
+  ByteSwapped[I] = llvm::ByteSwap_32(ByteSwapped[I]);
+Src = [0];
+SrcEnd = [ByteSwapped.size() - 1] + 1;
+  }
+
+  // Skip the BOM for conversion.
+  if (Src[0] == UNI_UTF32_BYTE_ORDER_MARK_NATIVE)
+Src++;
+
+  // Just allocate enough space up front.  We'll shrink it later.  Allocate
+  // enough that we can fit a null terminator without reallocating.
+  Out.resize(SrcBytes.size() * UNI_MAX_UTF8_BYTES_PER_CODE_POINT + 1);
+  UTF8 *Dst = reinterpret_cast([0]);
+  UTF8 *DstEnd = Dst + Out.size();
+
+  ConversionResult CR =
+  ConvertUTF32toUTF8(, SrcEnd, , DstEnd, strictConversion);
+  assert(CR != targetExhausted);
+
+  if (CR != conversionOK) {
+Out.clear();
+return false;
+  }
+
+  Out.resize(reinterpret_cast(Dst) - [0]);
+  Out.push_back(0);
+  Out.pop_back();
+  return true;
+}
+
+bool convertUTF32ToUTF8String(ArrayRef Src, std::string ) {
+  return convertUTF32ToUTF8String(
+  llvm::ArrayRef(reinterpret_cast(Src.data()),
+   Src.size() * sizeof(UTF32)),
+  Out);
+}
+
 bool convertUTF8ToUTF16String(StringRef SrcUTF8,
   SmallVectorImpl ) {
   assert(DstUTF16.empty());
Index: llvm/include/llvm/Support/ConvertUTF.h
===
--- llvm/include/llvm/Support/ConvertUTF.h
+++ llvm/include/llvm/Support/ConvertUTF.h
@@ -123,6 +123,9 @@
 #define UNI_UTF16_BYTE_ORDER_MARK_NATIVE  0xFEFF
 #define UNI_UTF16_BYTE_ORDER_MARK_SWAPPED 0xFFFE
 
+#define UNI_UTF32_BYTE_ORDER_MARK_NATIVE 0xFEFF
+#define UNI_UTF32_BYTE_ORDER_MARK_SWAPPED 0xFFFE
+
 typedef enum {
   conversionOK,   /* conversion successful */
   sourceExhausted,/* partial character in source, but hit end */
@@ -278,6 +281,24 @@
 */
 bool convertUTF16ToUTF8String(ArrayRef Src, std::string );
 
+/**
+ * Converts a stream of raw bytes assumed to be UTF32 into a UTF8 std::string.
+ *
+ * \param [in] SrcBytes A buffer of what is assumed to be UTF-32 encoded text.
+ * \param [out] Out Converted UTF-8 is stored here on success.
+ * \returns true on success
+ */
+bool convertUTF32ToUTF8String(ArrayRef SrcBytes, std::string );
+
+/**
+ * Converts a UTF32 string into a UTF8 std::string.
+ *
+ * \param [in] Src A buffer of UTF-32 encoded text.
+ * \param [out] Out Converted UTF-8 is stored here on success.
+ * \returns true on success
+ */
+bool convertUTF32ToUTF8String(ArrayRef Src, 

[PATCH] D106939: [RISCV] If the maskedoff is vundefined(), use ta, ma for vsetvli.

2021-07-29 Thread Hsiangkai Wang via Phabricator via cfe-commits
HsiangKai added a comment.

In D106939#2912807 , @frasercrmck 
wrote:

> LGTM but there are test failures. Is that just a whole load of `mu->ma` 
> changes that have been omitted for a smaller diff?

Updated test cases are put in https://reviews.llvm.org/D107022.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106939

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


[PATCH] D106939: [RISCV] If the maskedoff is vundefined(), use ta, ma for vsetvli.

2021-07-29 Thread Hsiangkai Wang via Phabricator via cfe-commits
HsiangKai updated this revision to Diff 362920.
HsiangKai added a comment.

- Add more comments.
- Remove unnecessary `--riscv-no-aliases` in the test case.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106939

Files:
  clang/test/CodeGen/RISCV/rvv-intrinsics/maskedoff-undefined.c
  llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp
  llvm/test/CodeGen/RISCV/rvv/maskedoff-undef.ll


Index: llvm/test/CodeGen/RISCV/rvv/maskedoff-undef.ll
===
--- /dev/null
+++ llvm/test/CodeGen/RISCV/rvv/maskedoff-undef.ll
@@ -0,0 +1,27 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=riscv64 -mattr=+experimental-v -verify-machineinstrs < %s \
+; RUN:   | FileCheck %s
+
+declare  @llvm.riscv.vadd.mask.nxv8i8.nxv8i8(
+  ,
+  ,
+  ,
+  ,
+  i64);
+
+define  @intrinsic_vadd_maskedoff_undef( %0, 
 %1,  %2, i64 %3) nounwind {
+; CHECK-LABEL: intrinsic_vadd_maskedoff_undef:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:vsetvli zero, a0, e8, m1, ta, ma
+; CHECK-NEXT:vadd.vv v8, v8, v9, v0.t
+; CHECK-NEXT:jalr zero, 0(ra)
+entry:
+  %a = call  @llvm.riscv.vadd.mask.nxv8i8.nxv8i8(
+ undef,
+ %0,
+ %1,
+ %2,
+i64 %3)
+
+  ret  %a
+}
Index: llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp
===
--- llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp
+++ llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp
@@ -377,16 +377,25 @@
   // despite having a tied def.
   bool ForceTailAgnostic = RISCVII::doesForceTailAgnostic(TSFlags);
   bool TailAgnostic = true;
+  // Default to mask agnostic unless the operation is masked and the 
destination
+  // is tied to a source. If the source is undef, keep it as mask agnostic.
+  bool MaskAgnostic = true;
   unsigned UseOpIdx;
-  if (!ForceTailAgnostic && MI.isRegTiedToUseOperand(0, )) {
-TailAgnostic = false;
-// If the tied operand is an IMPLICIT_DEF we can keep TailAgnostic.
+  if (MI.isRegTiedToUseOperand(0, )) {
+// hasDummyMaskOp(TSFlags) == true means it is a non-masked instruction.
+MaskAgnostic = RISCVII::hasDummyMaskOp(TSFlags);
+if (!ForceTailAgnostic)
+  TailAgnostic = false;
+// If the tied operand is an IMPLICIT_DEF we can keep MaskAgnostic and
+// TailAgnostic.
 const MachineOperand  = MI.getOperand(UseOpIdx);
 MachineInstr *UseMI = MRI->getVRegDef(UseMO.getReg());
 if (UseMI) {
   UseMI = elideCopies(UseMI, MRI);
-  if (UseMI && UseMI->isImplicitDef())
+  if (UseMI && UseMI->isImplicitDef()) {
+MaskAgnostic = true;
 TailAgnostic = true;
+  }
 }
   }
 
@@ -398,8 +407,7 @@
   InstrInfo.setAVLReg(VLOp.getReg());
   } else
 InstrInfo.setAVLReg(RISCV::NoRegister);
-  InstrInfo.setVTYPE(VLMul, SEW, /*TailAgnostic*/ TailAgnostic,
- /*MaskAgnostic*/ false, MaskRegOp);
+  InstrInfo.setVTYPE(VLMul, SEW, TailAgnostic, MaskAgnostic, MaskRegOp);
 
   return InstrInfo;
 }
Index: clang/test/CodeGen/RISCV/rvv-intrinsics/maskedoff-undefined.c
===
--- /dev/null
+++ clang/test/CodeGen/RISCV/rvv-intrinsics/maskedoff-undefined.c
@@ -0,0 +1,16 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// REQUIRES: riscv-registered-target
+// RUN: %clang_cc1 -triple riscv64 -target-feature +experimental-v \
+// RUN:   -disable-O0-optnone -emit-llvm %s -o - | opt -S -mem2reg \
+// RUN:   | FileCheck --check-prefix=CHECK-RV64 %s
+
+#include 
+
+// CHECK-RV64-LABEL: @test_vadd_vv_i8m1_m(
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  
@llvm.riscv.vadd.mask.nxv8i8.nxv8i8.i64( undef,  [[OP1:%.*]],  [[OP2:%.*]],  [[MASK:%.*]], 
i64 [[VL:%.*]])
+// CHECK-RV64-NEXT:ret  [[TMP0]]
+//
+vint8m1_t test_vadd_vv_i8m1_m (vbool8_t mask, vint8m1_t op1, vint8m1_t op2, 
size_t vl) {
+  return vadd_vv_i8m1_m(mask, vundefined_i8m1(), op1, op2, vl);
+}


Index: llvm/test/CodeGen/RISCV/rvv/maskedoff-undef.ll
===
--- /dev/null
+++ llvm/test/CodeGen/RISCV/rvv/maskedoff-undef.ll
@@ -0,0 +1,27 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=riscv64 -mattr=+experimental-v -verify-machineinstrs < %s \
+; RUN:   | FileCheck %s
+
+declare  @llvm.riscv.vadd.mask.nxv8i8.nxv8i8(
+  ,
+  ,
+  ,
+  ,
+  i64);
+
+define  @intrinsic_vadd_maskedoff_undef( %0,  %1,  %2, i64 %3) nounwind {
+; CHECK-LABEL: intrinsic_vadd_maskedoff_undef:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:vsetvli zero, a0, e8, m1, ta, ma
+; CHECK-NEXT:vadd.vv v8, v8, v9, v0.t
+; CHECK-NEXT:jalr zero, 0(ra)
+entry:
+  %a = call  @llvm.riscv.vadd.mask.nxv8i8.nxv8i8(
+ undef,
+ %0,
+ %1,
+ %2,
+i64 %3)
+
+  ret  %a
+}
Index: 

[PATCH] D104601: [Preprocessor] Implement -fminimize-whitespace.

2021-07-29 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment.

In D104601#2915102 , @alexfh wrote:

> This commit changes the behavior of clang -E -P even when no 
> -fminimize-whitespace is used. This breaks certain use cases like using clang 
> to preprocess files for flex, which turns out to be sensitive to the presence 
> of line breaks in places where C++ compilers aren't.
>
> An isolated test case:
>
>   $ clang-old -E -x c++ -P - -o /tmp/pp.good
>   #define I(x, ...) \
>x { return X##x; }
>   
>   
>   
>   #ifndef A
>   #define A(op, x) I(op, x)
>   #endif
>   
>   A(foo, {
>   
>   
>   
>   
>   
>   
>   
>   })
>   A(bar, {})
>   $ cat /tmp/pp.good
>   foo { return Xfoo; }
>   bar { return Xbar; }
>   $ clang-new -E -x c++ -P - -o /tmp/pp.bad
>   #define I(x, ...) \
>x { return X##x; }
>   
>   
>   
>   #ifndef A
>   #define A(op, x) I(op, x)
>   #endif
>   
>   A(foo, {
>   
>   
>   
>   
>   
>   
>   
>   })
>   A(bar, {})
>   $ cat /tmp/pp.bad
>   foo { return Xfoo; }bar { return Xbar; }
>
> Please fix or revert the commit.
>
> Thanks!

IIUC, c6b0b16c0f55c34f4eaa05184815bbbe97f4b750 
 was aimed 
to fix a similar issue, but it doesn't fix this specific case. If providing a 
proper fix quickly isn't feasible, consider reverting these patches.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104601

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


[PATCH] D104601: [Preprocessor] Implement -fminimize-whitespace.

2021-07-29 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment.

This commit changes the behavior of clang -E -P even when no 
-fminimize-whitespace is used. This breaks certain use cases like using clang 
to preprocess files for flex, which turns out to be sensitive to the presence 
of line breaks in places where C++ compilers aren't.

An isolated test case:

  $ clang-old -E -x c++ -P - -o /tmp/pp.good
  #define I(x, ...) \
   x { return X##x; }
  
  
  
  #ifndef A
  #define A(op, x) I(op, x)
  #endif
  
  A(foo, {
  
  
  
  
  
  
  
  })
  A(bar, {})
  $ cat /tmp/pp.good
  foo { return Xfoo; }
  bar { return Xbar; }
  $ clang-new -E -x c++ -P - -o /tmp/pp.bad
  #define I(x, ...) \
   x { return X##x; }
  
  
  
  #ifndef A
  #define A(op, x) I(op, x)
  #endif
  
  A(foo, {
  
  
  
  
  
  
  
  })
  A(bar, {})
  $ cat /tmp/pp.bad
  foo { return Xfoo; }bar { return Xbar; }

Please fix or revert the commit.

Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104601

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


[PATCH] D107115: [CMake][Fuchsia] Use standalone unwinder in Fuchsia toolchain

2021-07-29 Thread Petr Hosek via Phabricator via cfe-commits
phosek created this revision.
phosek added a reviewer: leonardchan.
Herald added a subscriber: mgorny.
phosek requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Rather than merging the unwinder into libc++, keep it separate so it
can be used standalone.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D107115

Files:
  clang/cmake/caches/Fuchsia-stage2.cmake
  clang/cmake/caches/Fuchsia.cmake


Index: clang/cmake/caches/Fuchsia.cmake
===
--- clang/cmake/caches/Fuchsia.cmake
+++ clang/cmake/caches/Fuchsia.cmake
@@ -28,6 +28,7 @@
   set(CLANG_DEFAULT_OBJCOPY llvm-objcopy CACHE STRING "")
 endif()
 set(CLANG_DEFAULT_RTLIB compiler-rt CACHE STRING "")
+set(CLANG_DEFAULT_UNWINDLIB libunwind CACHE STRING "")
 set(CLANG_ENABLE_ARCMT OFF CACHE BOOL "")
 set(CLANG_ENABLE_STATIC_ANALYZER ON CACHE BOOL "")
 set(CLANG_PLUGIN_SUPPORT OFF CACHE BOOL "")
@@ -89,11 +90,9 @@
 set(RUNTIMES_${target}_COMPILER_RT_USE_BUILTINS_LIBRARY ON CACHE BOOL "")
 set(RUNTIMES_${target}_LIBUNWIND_ENABLE_SHARED OFF CACHE BOOL "")
 set(RUNTIMES_${target}_LIBUNWIND_USE_COMPILER_RT ON CACHE BOOL "")
-set(RUNTIMES_${target}_LIBUNWIND_INSTALL_LIBRARY OFF CACHE BOOL "")
 set(RUNTIMES_${target}_LIBCXXABI_USE_COMPILER_RT ON CACHE BOOL "")
 set(RUNTIMES_${target}_LIBCXXABI_ENABLE_SHARED OFF CACHE BOOL "")
 set(RUNTIMES_${target}_LIBCXXABI_USE_LLVM_UNWINDER ON CACHE BOOL "")
-set(RUNTIMES_${target}_LIBCXXABI_ENABLE_STATIC_UNWINDER ON CACHE BOOL "")
 set(RUNTIMES_${target}_LIBCXXABI_INSTALL_LIBRARY OFF CACHE BOOL "")
 set(RUNTIMES_${target}_LIBCXX_USE_COMPILER_RT ON CACHE BOOL "")
 set(RUNTIMES_${target}_LIBCXX_ENABLE_SHARED OFF CACHE BOOL "")
Index: clang/cmake/caches/Fuchsia-stage2.cmake
===
--- clang/cmake/caches/Fuchsia-stage2.cmake
+++ clang/cmake/caches/Fuchsia-stage2.cmake
@@ -37,6 +37,7 @@
   set(CLANG_DEFAULT_OBJCOPY llvm-objcopy CACHE STRING "")
 endif()
 set(CLANG_DEFAULT_RTLIB compiler-rt CACHE STRING "")
+set(CLANG_DEFAULT_UNWINDLIB libunwind CACHE STRING "")
 set(CLANG_ENABLE_ARCMT OFF CACHE BOOL "")
 set(CLANG_ENABLE_STATIC_ANALYZER ON CACHE BOOL "")
 set(CLANG_PLUGIN_SUPPORT OFF CACHE BOOL "")
@@ -124,11 +125,9 @@
 set(RUNTIMES_${target}_COMPILER_RT_USE_BUILTINS_LIBRARY ON CACHE BOOL "")
 set(RUNTIMES_${target}_LIBUNWIND_ENABLE_SHARED OFF CACHE BOOL "")
 set(RUNTIMES_${target}_LIBUNWIND_USE_COMPILER_RT ON CACHE BOOL "")
-set(RUNTIMES_${target}_LIBUNWIND_INSTALL_LIBRARY OFF CACHE BOOL "")
 set(RUNTIMES_${target}_LIBCXXABI_USE_COMPILER_RT ON CACHE BOOL "")
 set(RUNTIMES_${target}_LIBCXXABI_ENABLE_SHARED OFF CACHE BOOL "")
 set(RUNTIMES_${target}_LIBCXXABI_USE_LLVM_UNWINDER ON CACHE BOOL "")
-set(RUNTIMES_${target}_LIBCXXABI_ENABLE_STATIC_UNWINDER ON CACHE BOOL "")
 set(RUNTIMES_${target}_LIBCXXABI_INSTALL_LIBRARY OFF CACHE BOOL "")
 set(RUNTIMES_${target}_LIBCXX_USE_COMPILER_RT ON CACHE BOOL "")
 set(RUNTIMES_${target}_LIBCXX_ENABLE_SHARED OFF CACHE BOOL "")
@@ -185,13 +184,10 @@
 set(RUNTIMES_${target}_COMPILER_RT_USE_BUILTINS_LIBRARY ON CACHE BOOL "")
 set(RUNTIMES_${target}_LIBUNWIND_USE_COMPILER_RT ON CACHE BOOL "")
 set(RUNTIMES_${target}_LIBUNWIND_HIDE_SYMBOLS ON CACHE BOOL "")
-set(RUNTIMES_${target}_LIBUNWIND_INSTALL_STATIC_LIBRARY OFF CACHE BOOL "")
 set(RUNTIMES_${target}_LIBCXXABI_USE_COMPILER_RT ON CACHE BOOL "")
 set(RUNTIMES_${target}_LIBCXXABI_USE_LLVM_UNWINDER ON CACHE BOOL "")
-set(RUNTIMES_${target}_LIBCXXABI_ENABLE_STATIC_UNWINDER ON CACHE BOOL "")
 set(RUNTIMES_${target}_LIBCXXABI_HERMETIC_STATIC_LIBRARY ON CACHE BOOL "")
 set(RUNTIMES_${target}_LIBCXXABI_INSTALL_STATIC_LIBRARY OFF CACHE BOOL "")
-
set(RUNTIMES_${target}_LIBCXXABI_STATICALLY_LINK_UNWINDER_IN_SHARED_LIBRARY OFF 
CACHE BOOL "")
 set(RUNTIMES_${target}_LIBCXX_USE_COMPILER_RT ON CACHE BOOL "")
 set(RUNTIMES_${target}_LIBCXX_ENABLE_STATIC_ABI_LIBRARY ON CACHE BOOL "")
 set(RUNTIMES_${target}_LIBCXX_HERMETIC_STATIC_LIBRARY ON CACHE BOOL "")


Index: clang/cmake/caches/Fuchsia.cmake
===
--- clang/cmake/caches/Fuchsia.cmake
+++ clang/cmake/caches/Fuchsia.cmake
@@ -28,6 +28,7 @@
   set(CLANG_DEFAULT_OBJCOPY llvm-objcopy CACHE STRING "")
 endif()
 set(CLANG_DEFAULT_RTLIB compiler-rt CACHE STRING "")
+set(CLANG_DEFAULT_UNWINDLIB libunwind CACHE STRING "")
 set(CLANG_ENABLE_ARCMT OFF CACHE BOOL "")
 set(CLANG_ENABLE_STATIC_ANALYZER ON CACHE BOOL "")
 set(CLANG_PLUGIN_SUPPORT OFF CACHE BOOL "")
@@ -89,11 +90,9 @@
 set(RUNTIMES_${target}_COMPILER_RT_USE_BUILTINS_LIBRARY ON CACHE BOOL "")
 set(RUNTIMES_${target}_LIBUNWIND_ENABLE_SHARED OFF CACHE BOOL "")
 set(RUNTIMES_${target}_LIBUNWIND_USE_COMPILER_RT ON CACHE BOOL "")
-

[PATCH] D99840: [clang-format] Correctly attach enum braces with ShortEnums disabled

2021-07-29 Thread Luna Kirkby via Phabricator via cfe-commits
lunasorcery added a comment.

Looking at this again I think the change is flawed. The `InitialToken` is taken 
*after* the enum token, and additionally the invocation of 
`ShouldBreakBeforeBrace` is falling through to the `return false;` case every 
time. As such the call to `addUnwrappedLine()` is _always_ skipped. This 
removes the newline for both the Attach and Break styles - but the Break style 
is then fixed up by some code in `TokenAnnotator.cpp` that I don't fully 
understand, which adds the newline back in.

So this change _works_, but not quite for the right reasons.

D106349  appears to implement this in a 
slightly more correct manner, taking the `InitialToken` _before_ we've advanced 
past the enum token, and handling the enum case inside `ShouldBreakBeforeBrace`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99840

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


[PATCH] D106994: [modules] Fix miscompilation when using two RecordDecl definitions with the same name.

2021-07-29 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai planned changes to this revision.
vsapsai added a comment.

Discovered ambiguous name lookup for IndirectFieldDecl in anonymous structs.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106994

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


[PATCH] D106994: [modules] Fix miscompilation when using two RecordDecl definitions with the same name.

2021-07-29 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai added a comment.

>> Are there any known signs for mixing lexical and semantic `DeclContext`? I 
>> plan to test the change on our internal codebase, hopefully it'll help to 
>> catch any remaining issues.
>
> The kinds of things I saw go wrong when we were bringing this up on the C++ 
> side were generally in code that would walk the list of (say) fields of a 
> record building up some information, and then attempt to look up a given 
> `FieldDecl*` in that data structure. That can fail if fields get merged, 
> because the lookup key may be a different redeclaration of the same field 
> than the one found by walking the class's members.  The fix is usually to add 
> `getCanonicalDecl` calls in the right places. The sign of this kind of bug 
> happening was usually a crash or assert, usually pretty close to where the 
> problem was.

Thanks, that's helpful.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106994

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


[PATCH] D104285: [analyzer][AST] Retrieve value by direct index from list initialization of constant array declaration.

2021-07-29 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added a comment.

@martong
I've added new reviewers, thanks for the prompt.

> E.g. could we have a free function outside of the `InitListExpr` to implement 
> `getExprForConstArrayByRawIndex`

It is possible, but I think this is more naturaly for the instance of 
`InitListExpr` to be responsible for such traversion.


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

https://reviews.llvm.org/D104285

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


[PATCH] D106753: ConvertUTF: Created wrapper convertUTF32ToUTF8String

2021-07-29 Thread Marcus Johnson via Phabricator via cfe-commits
MarcusJohnson91 updated this revision to Diff 362907.
MarcusJohnson91 added a comment.

Formatted the diff


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

https://reviews.llvm.org/D106753

Files:
  llvm/include/llvm/Support/ConvertUTF.h
  llvm/lib/Support/ConvertUTFWrapper.cpp
  llvm/unittests/Support/ConvertUTFTest.cpp

Index: llvm/unittests/Support/ConvertUTFTest.cpp
===
--- llvm/unittests/Support/ConvertUTFTest.cpp
+++ llvm/unittests/Support/ConvertUTFTest.cpp
@@ -25,6 +25,17 @@
   EXPECT_EQ(Expected, Result);
 }
 
+TEST(ConvertUTFTest, ConvertUTF32LittleEndianToUTF8String) {
+  // Src is a crystal ball.
+  alignas(UTF32) static const char Src[] = "\x2E\xF5\x01\x00";
+  ArrayRef Ref(Src, sizeof(Src) - 1);
+  std::string Result;
+  bool Success = convertUTF32ToUTF8String(Ref, Result);
+  EXPECT_TRUE(Success);
+  std::string Expected("\xF0\x9F\x94\xAE");
+  EXPECT_EQ(Expected, Result);
+}
+
 TEST(ConvertUTFTest, ConvertUTF16BigEndianToUTF8String) {
   // Src is the look of disapproval.
   alignas(UTF16) static const char Src[] = "\xfe\xff\x0c\xa0\x00_\x0c\xa0";
@@ -36,6 +47,17 @@
   EXPECT_EQ(Expected, Result);
 }
 
+TEST(ConvertUTFTest, ConvertUTF32BigEndianToUTF8String) {
+  // Src is a crystal ball.
+  alignas(UTF32) static const char Src[] = "\x00\x00\xfe\xff\x00\x01\xF5\x2E";
+  ArrayRef Ref(Src, sizeof(Src) - 1);
+  std::string Result;
+  bool Success = convertUTF32ToUTF8String(Ref, Result);
+  EXPECT_TRUE(Success);
+  std::string Expected("\xF0\x9F\x94\xAE");
+  EXPECT_EQ(Expected, Result);
+}
+
 TEST(ConvertUTFTest, ConvertUTF8ToUTF16String) {
   // Src is the look of disapproval.
   static const char Src[] = "\xe0\xb2\xa0_\xe0\xb2\xa0";
@@ -89,6 +111,8 @@
   EXPECT_EQ(Expected, Result);
 }
 
+
+
 TEST(ConvertUTFTest, ConvertUTF8toWide) {
   // Src is the look of disapproval.
   static const char Src[] = "\xe0\xb2\xa0_\xe0\xb2\xa0";
Index: llvm/lib/Support/ConvertUTFWrapper.cpp
===
--- llvm/lib/Support/ConvertUTFWrapper.cpp
+++ llvm/lib/Support/ConvertUTFWrapper.cpp
@@ -141,6 +141,60 @@
   Src.size() * sizeof(UTF16)), Out);
 }
 
+bool convertUTF32ToUTF8String(ArrayRef SrcBytes, std::string ) {
+  assert(Out.empty());
+
+  // Avoid OOB by returning early on empty input.
+  if (SrcBytes.empty())
+return true;
+
+  const UTF32 *Src = reinterpret_cast(SrcBytes.begin());
+  const UTF32 *SrcEnd = reinterpret_cast(SrcBytes.end());
+
+  assert((uintptr_t)Src % sizeof(UTF32) == 0);
+
+  // Byteswap if necessary.
+  std::vector ByteSwapped;
+  if (Src[0] == UNI_UTF32_BYTE_ORDER_MARK_SWAPPED) {
+ByteSwapped.insert(ByteSwapped.end(), Src, SrcEnd);
+for (unsigned I = 0, E = ByteSwapped.size(); I != E; ++I)
+  ByteSwapped[I] = llvm::ByteSwap_32(ByteSwapped[I]);
+Src = [0];
+SrcEnd = [ByteSwapped.size() - 1] + 1;
+  }
+
+  // Skip the BOM for conversion.
+  if (Src[0] == UNI_UTF32_BYTE_ORDER_MARK_NATIVE)
+Src++;
+
+  // Just allocate enough space up front.  We'll shrink it later.  Allocate
+  // enough that we can fit a null terminator without reallocating.
+  Out.resize(SrcBytes.size() * UNI_MAX_UTF8_BYTES_PER_CODE_POINT + 1);
+  UTF8 *Dst = reinterpret_cast([0]);
+  UTF8 *DstEnd = Dst + Out.size();
+
+  ConversionResult CR =
+  ConvertUTF32toUTF8(, SrcEnd, , DstEnd, strictConversion);
+  assert(CR != targetExhausted);
+
+  if (CR != conversionOK) {
+Out.clear();
+return false;
+  }
+
+  Out.resize(reinterpret_cast(Dst) - [0]);
+  Out.push_back(0);
+  Out.pop_back();
+  return true;
+}
+
+bool convertUTF32ToUTF8String(ArrayRef Src, std::string ) {
+  return convertUTF32ToUTF8String(
+  llvm::ArrayRef(reinterpret_cast(Src.data()),
+   Src.size() * sizeof(UTF32)),
+  Out);
+}
+
 bool convertUTF8ToUTF16String(StringRef SrcUTF8,
   SmallVectorImpl ) {
   assert(DstUTF16.empty());
Index: llvm/include/llvm/Support/ConvertUTF.h
===
--- llvm/include/llvm/Support/ConvertUTF.h
+++ llvm/include/llvm/Support/ConvertUTF.h
@@ -123,6 +123,9 @@
 #define UNI_UTF16_BYTE_ORDER_MARK_NATIVE  0xFEFF
 #define UNI_UTF16_BYTE_ORDER_MARK_SWAPPED 0xFFFE
 
+#define UNI_UTF32_BYTE_ORDER_MARK_NATIVE 0xFEFF
+#define UNI_UTF32_BYTE_ORDER_MARK_SWAPPED 0xFFFE
+
 typedef enum {
   conversionOK,   /* conversion successful */
   sourceExhausted,/* partial character in source, but hit end */
@@ -278,6 +281,24 @@
 */
 bool convertUTF16ToUTF8String(ArrayRef Src, std::string );
 
+/**
+ * Converts a stream of raw bytes assumed to be UTF32 into a UTF8 std::string.
+ *
+ * \param [in] SrcBytes A buffer of what is assumed to be UTF-32 encoded text.
+ * \param [out] Out Converted UTF-8 is stored here on success.
+ * \returns true on success
+ */
+bool convertUTF32ToUTF8String(ArrayRef SrcBytes, std::string );
+
+/**
+ * 

[PATCH] D107105: [AIX] Pass the -b option to linker on AIX (with fix to build break)

2021-07-29 Thread Zarko Todorovski via Phabricator via cfe-commits
ZarkoCA added a comment.

Thanks for the quick turn around and fix @anjankgk, LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107105

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


[PATCH] D107105: [AIX] Pass the -b option to linker on AIX (with fix to build break)

2021-07-29 Thread Anjan Kumar via Phabricator via cfe-commits
anjankgk created this revision.
anjankgk added reviewers: ZarkoCA, cebowleratibm, hubert.reinterpretcast.
Herald added a subscriber: dang.
anjankgk requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This patch will re-enable the patch posted under 
https://reviews.llvm.org/D106688 originally which was reverted due to 
buildbreak that was caused by mismatched diagnostic message arguments.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D107105

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/test/Driver/Xlinker-args.c


Index: clang/test/Driver/Xlinker-args.c
===
--- clang/test/Driver/Xlinker-args.c
+++ clang/test/Driver/Xlinker-args.c
@@ -11,10 +11,20 @@
 // RUN:   -e _start -T a.lds -Xlinker one -Xlinker --no-demangle \
 // RUN:   -Wl,two,--no-demangle,three -Xlinker four -z five -r %s 2> %t
 // RUN: FileCheck -check-prefix=LINUX < %t %s
-//
+
+// RUN: %clang -target powerpc-unknown-aix -### \
+// RUN:   -b one %s 2> %t
+// RUN: FileCheck -check-prefix=AIX < %t %s
+
+// RUN: %clang -target powerpc-unknown-linux -### \
+// RUN:   -b one %s 2> %t
+// RUN: FileCheck -check-prefix=NOT-AIX < %t %s
+
 // DARWIN-NOT: --no-demangle
 // DARWIN: "one" "two" "three" "four" "-z" "five" "-r"
 // LINUX: "--no-demangle" "-e" "_start" "one" "two" "three" "four" "-z" "five" 
"-r" {{.*}} "-T" "a.lds"
+// AIX: "-b" "one" 
+// NOT-AIX: error: unsupported option '-b' for target 'powerpc-unknown-linux'
 
 // Check that we forward '-Xlinker' and '-Wl,' on Windows.
 // RUN: %clang -target i686-pc-win32 -fuse-ld=link -### \
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -257,6 +257,16 @@
 // Otherwise, this is a linker input argument.
 const Arg  = II.getInputArg();
 
+if (A.getOption().matches(options::OPT_b)) {
+  const llvm::Triple  = TC.getTriple();
+  if (!T.isOSAIX()) {
+TC.getDriver().Diag(diag::err_drv_unsupported_opt_for_target)
+  << A.getSpelling() << T.str();
+  }
+  // Pass -b prefix for AIX linker.
+  A.claim();
+  A.render(Args, CmdArgs);
+}
 // Handle reserved library options.
 if (A.getOption().matches(options::OPT_Z_reserved_lib_stdcxx))
   TC.AddCXXStdlibLibArgs(Args, CmdArgs);
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -815,7 +815,9 @@
 def bind__at__load : Flag<["-"], "bind_at_load">;
 def bundle__loader : Separate<["-"], "bundle_loader">;
 def bundle : Flag<["-"], "bundle">;
-def b : JoinedOrSeparate<["-"], "b">, Flags<[Unsupported]>;
+def b : JoinedOrSeparate<["-"], "b">, Flags<[LinkerInput, RenderAsInput]>,
+  HelpText<"Pass -b  to the linker on AIX (only).">, MetaVarName<"">,
+  Group;
 def cl_opt_disable : Flag<["-"], "cl-opt-disable">, Group, 
Flags<[CC1Option]>,
   HelpText<"OpenCL only. This option disables all optimizations. By default 
optimizations are enabled.">;
 def cl_strict_aliasing : Flag<["-"], "cl-strict-aliasing">, 
Group, Flags<[CC1Option]>,


Index: clang/test/Driver/Xlinker-args.c
===
--- clang/test/Driver/Xlinker-args.c
+++ clang/test/Driver/Xlinker-args.c
@@ -11,10 +11,20 @@
 // RUN:   -e _start -T a.lds -Xlinker one -Xlinker --no-demangle \
 // RUN:   -Wl,two,--no-demangle,three -Xlinker four -z five -r %s 2> %t
 // RUN: FileCheck -check-prefix=LINUX < %t %s
-//
+
+// RUN: %clang -target powerpc-unknown-aix -### \
+// RUN:   -b one %s 2> %t
+// RUN: FileCheck -check-prefix=AIX < %t %s
+
+// RUN: %clang -target powerpc-unknown-linux -### \
+// RUN:   -b one %s 2> %t
+// RUN: FileCheck -check-prefix=NOT-AIX < %t %s
+
 // DARWIN-NOT: --no-demangle
 // DARWIN: "one" "two" "three" "four" "-z" "five" "-r"
 // LINUX: "--no-demangle" "-e" "_start" "one" "two" "three" "four" "-z" "five" "-r" {{.*}} "-T" "a.lds"
+// AIX: "-b" "one" 
+// NOT-AIX: error: unsupported option '-b' for target 'powerpc-unknown-linux'
 
 // Check that we forward '-Xlinker' and '-Wl,' on Windows.
 // RUN: %clang -target i686-pc-win32 -fuse-ld=link -### \
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -257,6 +257,16 @@
 // Otherwise, this is a linker input argument.
 const Arg  = II.getInputArg();
 
+if (A.getOption().matches(options::OPT_b)) {
+  const llvm::Triple  = TC.getTriple();
+  if (!T.isOSAIX()) {
+TC.getDriver().Diag(diag::err_drv_unsupported_opt_for_target)
+  << 

[PATCH] D106753: ConvertUTF: Created wrapper convertUTF32ToUTF8String

2021-07-29 Thread Marcus Johnson via Phabricator via cfe-commits
MarcusJohnson91 updated this revision to Diff 362882.
MarcusJohnson91 added a comment.

The tests work on my machine now, turns out the Big endian one needs a BOM, 
pretty obvious in hindsight.


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

https://reviews.llvm.org/D106753

Files:
  llvm/include/llvm/Support/ConvertUTF.h
  llvm/lib/Support/ConvertUTFWrapper.cpp
  llvm/unittests/Support/ConvertUTFTest.cpp

Index: llvm/unittests/Support/ConvertUTFTest.cpp
===
--- llvm/unittests/Support/ConvertUTFTest.cpp
+++ llvm/unittests/Support/ConvertUTFTest.cpp
@@ -25,6 +25,17 @@
   EXPECT_EQ(Expected, Result);
 }
 
+TEST(ConvertUTFTest, ConvertUTF32LittleEndianToUTF8String) {
+  // Src is a crystal ball.
+  alignas(UTF32) static const char Src[] = "\x2E\xF5\x01\x00";
+  ArrayRef Ref(Src, sizeof(Src) - 1);
+  std::string Result;
+  bool Success = convertUTF32ToUTF8String(Ref, Result);
+  EXPECT_TRUE(Success);
+  std::string Expected("\xF0\x9F\x94\xAE");
+  EXPECT_EQ(Expected, Result);
+}
+
 TEST(ConvertUTFTest, ConvertUTF16BigEndianToUTF8String) {
   // Src is the look of disapproval.
   alignas(UTF16) static const char Src[] = "\xfe\xff\x0c\xa0\x00_\x0c\xa0";
@@ -36,6 +47,17 @@
   EXPECT_EQ(Expected, Result);
 }
 
+TEST(ConvertUTFTest, ConvertUTF32BigEndianToUTF8String) {
+  // Src is a crystal ball.
+  alignas(UTF32) static const char Src[] = "\x00\x00\xfe\xff\x00\x01\xF5\x2E";
+  ArrayRef Ref(Src, sizeof(Src) - 1);
+  std::string Result;
+  bool Success = convertUTF32ToUTF8String(Ref, Result);
+  EXPECT_TRUE(Success);
+  std::string Expected("\xF0\x9F\x94\xAE");
+  EXPECT_EQ(Expected, Result);
+}
+
 TEST(ConvertUTFTest, ConvertUTF8ToUTF16String) {
   // Src is the look of disapproval.
   static const char Src[] = "\xe0\xb2\xa0_\xe0\xb2\xa0";
@@ -89,6 +111,8 @@
   EXPECT_EQ(Expected, Result);
 }
 
+
+
 TEST(ConvertUTFTest, ConvertUTF8toWide) {
   // Src is the look of disapproval.
   static const char Src[] = "\xe0\xb2\xa0_\xe0\xb2\xa0";
Index: llvm/lib/Support/ConvertUTFWrapper.cpp
===
--- llvm/lib/Support/ConvertUTFWrapper.cpp
+++ llvm/lib/Support/ConvertUTFWrapper.cpp
@@ -141,6 +141,60 @@
   Src.size() * sizeof(UTF16)), Out);
 }
 
+bool convertUTF32ToUTF8String(ArrayRef SrcBytes, std::string ) {
+  assert(Out.empty());
+
+  // Avoid OOB by returning early on empty input.
+  if (SrcBytes.empty())
+return true;
+
+  const UTF32 *Src = reinterpret_cast(SrcBytes.begin());
+  const UTF32 *SrcEnd = reinterpret_cast(SrcBytes.end());
+
+  assert((uintptr_t)Src % sizeof(UTF32) == 0);
+
+  // Byteswap if necessary.
+  std::vector ByteSwapped;
+  if (Src[0] == UNI_UTF32_BYTE_ORDER_MARK_SWAPPED) {
+ByteSwapped.insert(ByteSwapped.end(), Src, SrcEnd);
+for (unsigned I = 0, E = ByteSwapped.size(); I != E; ++I)
+  ByteSwapped[I] = llvm::ByteSwap_32(ByteSwapped[I]);
+Src = [0];
+SrcEnd = [ByteSwapped.size() - 1] + 1;
+  }
+
+  // Skip the BOM for conversion.
+  if (Src[0] == UNI_UTF32_BYTE_ORDER_MARK_NATIVE)
+Src++;
+
+  // Just allocate enough space up front.  We'll shrink it later.  Allocate
+  // enough that we can fit a null terminator without reallocating.
+  Out.resize(SrcBytes.size() * UNI_MAX_UTF8_BYTES_PER_CODE_POINT + 1);
+  UTF8 *Dst = reinterpret_cast([0]);
+  UTF8 *DstEnd = Dst + Out.size();
+
+  ConversionResult CR =
+  ConvertUTF32toUTF8(, SrcEnd, , DstEnd, strictConversion);
+  assert(CR != targetExhausted);
+
+  if (CR != conversionOK) {
+Out.clear();
+return false;
+  }
+
+  Out.resize(reinterpret_cast(Dst) - [0]);
+  Out.push_back(0);
+  Out.pop_back();
+  return true;
+}
+
+bool convertUTF32ToUTF8String(ArrayRef Src, std::string ) {
+  return convertUTF32ToUTF8String(
+  llvm::ArrayRef(reinterpret_cast(Src.data()),
+   Src.size() * sizeof(UTF32)),
+  Out);
+}
+
 bool convertUTF8ToUTF16String(StringRef SrcUTF8,
   SmallVectorImpl ) {
   assert(DstUTF16.empty());
Index: llvm/include/llvm/Support/ConvertUTF.h
===
--- llvm/include/llvm/Support/ConvertUTF.h
+++ llvm/include/llvm/Support/ConvertUTF.h
@@ -123,6 +123,9 @@
 #define UNI_UTF16_BYTE_ORDER_MARK_NATIVE  0xFEFF
 #define UNI_UTF16_BYTE_ORDER_MARK_SWAPPED 0xFFFE
 
+#define UNI_UTF32_BYTE_ORDER_MARK_NATIVE 0xFEFF
+#define UNI_UTF32_BYTE_ORDER_MARK_SWAPPED 0xFFFE
+
 typedef enum {
   conversionOK,   /* conversion successful */
   sourceExhausted,/* partial character in source, but hit end */
@@ -278,6 +281,24 @@
 */
 bool convertUTF16ToUTF8String(ArrayRef Src, std::string );
 
+/**
+ * Converts a stream of raw bytes assumed to be UTF32 into a UTF8 std::string.
+ *
+ * \param [in] SrcBytes A buffer of what is assumed to be UTF-32 encoded text.
+ * \param [out] Out Converted UTF-8 is stored here on success.
+ * \returns true on 

[PATCH] D107026: [Clang] Add support for attribute 'escape'

2021-07-29 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko accepted this revision.
vsavchenko added a comment.
This revision is now accepted and ready to land.

Awesome, I have nothing to add at this point!
Let's still wait for @aaron.ballman to check it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107026

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


[PATCH] D107054: [Clang][CUDA] Add descriptors, mappings, and features for missing CUDA and PTX versions

2021-07-29 Thread Artem Belevich via Phabricator via cfe-commits
tra added inline comments.



Comment at: clang/include/clang/Basic/BuiltinsNVPTX.def:821
 #pragma pop_macro("PTX71")
 #pragma pop_macro("PTX72")

You need to pop new macros here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107054

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


[PATCH] D106349: [clang-format] respect AfterEnum for enums

2021-07-29 Thread Luna Kirkby via Phabricator via cfe-commits
lunasorcery added a comment.

Note also there's significant overlap with the now-committed D99840 
, though that's missing the change inside 
ShouldBreakBeforeBrace().
In retrospect I'm a little confused as to why D99840 
 appears to work without it.


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

https://reviews.llvm.org/D106349

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


[PATCH] D107095: Implement #pragma clang header_unsafe

2021-07-29 Thread Chris Bieneman via Phabricator via cfe-commits
beanz updated this revision to Diff 362856.
beanz added a comment.

Re-adding a newline that was inadvertently remvoed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107095

Files:
  clang/docs/LanguageExtensions.rst
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticLexKinds.td
  clang/include/clang/Basic/IdentifierTable.h
  clang/include/clang/Lex/Preprocessor.h
  clang/lib/Lex/Pragma.cpp
  clang/lib/Lex/Preprocessor.cpp
  clang/test/Lexer/Inputs/unsafe-macro-2.h
  clang/test/Lexer/Inputs/unsafe-macro.h
  clang/test/Lexer/unsafe-macro.c

Index: clang/test/Lexer/unsafe-macro.c
===
--- /dev/null
+++ clang/test/Lexer/unsafe-macro.c
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -Wpedantic-macros %s -fsyntax-only -verify
+#include "Inputs/unsafe-macro.h"
+#include "Inputs/unsafe-macro-2.h"
+
+// not-expected-warning@+1{{macro 'UNSAFE_MACRO' has been marked as unsafe for use in headers: Don't use this!}}
+#if UNSAFE_MACRO
+#endif
Index: clang/test/Lexer/Inputs/unsafe-macro.h
===
--- /dev/null
+++ clang/test/Lexer/Inputs/unsafe-macro.h
@@ -0,0 +1,18 @@
+// expected-error@+1{{expected (}}
+#pragma clang header_unsafe
+
+// expected-error@+1{{expected identifier}}
+#pragma clang header_unsafe(4
+
+// expected-error@+1{{no macro named foo}}
+#pragma clang header_unsafe(foo)
+
+
+#define UNSAFE_MACRO 1
+#pragma clang header_unsafe(UNSAFE_MACRO, "Don't use this!")
+
+#define UNSAFE_MACRO_2 2
+#pragma clang header_unsafe(UNSAFE_MACRO_2)
+
+// expected-error@+1{{expected )}}
+#pragma clang deprecated(UNSAFE_MACRO
Index: clang/test/Lexer/Inputs/unsafe-macro-2.h
===
--- /dev/null
+++ clang/test/Lexer/Inputs/unsafe-macro-2.h
@@ -0,0 +1,70 @@
+// expected-warning@+1{{macro 'UNSAFE_MACRO' has been marked as unsafe for use in headers: Don't use this!}}
+#if UNSAFE_MACRO
+#endif
+
+// expected-warning@+1{{macro 'UNSAFE_MACRO' has been marked as unsafe for use in headers: Don't use this!}}
+#if defined(UNSAFE_MACRO)
+#endif
+
+// expected-warning@+1{{macro 'UNSAFE_MACRO' has been marked as unsafe for use in headers: Don't use this!}}
+#ifdef UNSAFE_MACRO
+#endif
+
+// expected-warning@+1{{macro 'UNSAFE_MACRO' has been marked as unsafe for use in headers: Don't use this!}}
+#ifndef UNSAFE_MACRO
+#endif
+
+// expected-warning@+1{{macro 'UNSAFE_MACRO' has been marked as unsafe for use in headers: Don't use this!}}
+const int x = UNSAFE_MACRO;
+
+// expected-warning@+1{{macro 'UNSAFE_MACRO_2' has been marked as unsafe for use in headers}}
+const int y = UNSAFE_MACRO_2;
+
+// not-expected-warning@+1{{macro 'UNSAFE_MACRO_2' has been marked as unsafe for use in headers}}
+#undef UNSAFE_MACRO_2
+// not-expected-warning@+1{{macro 'UNSAFE_MACRO_2' has been marked as unsafe for use in headers}}
+#define UNSAFE_MACRO_2 2
+
+// not-expected-warning@+1{{macro 'UNSAFE_MACRO_2' has been marked as unsafe for use in headers}}
+const int z = UNSAFE_MACRO_2;
+
+
+// Test that we diagnose on #elif.
+#if 0
+#elif UNSAFE_MACRO
+// expected-warning@-1{{macro 'UNSAFE_MACRO' has been marked as unsafe for use in headers: Don't use this!}}
+#endif
+
+
+// Test that we diagnose on #elifdef.
+#ifdef baz
+#elifdef UNSAFE_MACRO
+// expected-warning@-1{{macro 'UNSAFE_MACRO' has been marked as unsafe for use in headers: Don't use this!}}
+#endif
+
+// Test that we diagnose on #elifndef.
+#ifdef baz
+#elifndef UNSAFE_MACRO
+#endif
+// expected-warning@-2{{macro 'UNSAFE_MACRO' has been marked as unsafe for use in headers: Don't use this!}}
+
+// FIXME: These cases are currently not handled because clang doesn't expand
+// conditions on skipped #elif* blocks. See the FIXME notes in
+// Preprocessor::SkipExcludedConditionalBlock.
+
+#define frobble
+
+#ifdef frobble
+// not-expected-warning@+1{{macro 'UNSAFE_MACRO' has been marked as unsafe for use in headers: Don't use this!}}
+#elifndef UNSAFE_MACRO
+#endif
+
+#ifdef frobble
+// not-expected-warning@+1{{macro 'UNSAFE_MACRO' has been marked as unsafe for use in headers: Don't use this!}}
+#elifdef UNSAFE_MACRO
+#endif
+
+#if 1
+// not-expected-warning@+1{{macro 'UNSAFE_MACRO' has been marked as unsafe for use in headers: Don't use this!}}
+#elif UNSAFE_MACRO
+#endif
Index: clang/lib/Lex/Preprocessor.cpp
===
--- clang/lib/Lex/Preprocessor.cpp
+++ clang/lib/Lex/Preprocessor.cpp
@@ -1423,6 +1423,17 @@
   Diag(Identifier, diag::warn_pragma_deprecated_macro_use)
   << Identifier.getIdentifierInfo() << 1 << *DepMsg;
   }
+
+  if (Identifier.getIdentifierInfo()->isHeaderUnsafe() &&
+  !SourceMgr.isInMainFile(Identifier.getLocation())) {
+auto DepMsg = getHeaderUnsafeMsg(Identifier.getIdentifierInfo());
+if (!DepMsg)
+  

[PATCH] D106349: [clang-format] respect AfterEnum for enums

2021-07-29 Thread Michael Zimmermann via Phabricator via cfe-commits
m1cha added a comment.

I don't have commit access. How does that even work? The documentation is very 
scarce about this but for security reasons I'd expect there to be a very 
limited set of people with commit access

Here's my author info:
`Michael Zimmermann `


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

https://reviews.llvm.org/D106349

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


[PATCH] D106349: [clang-format] respect AfterEnum for enums

2021-07-29 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks added a comment.

No one objects, you can push it. Or if you don't have commit access (and don't 
want to, or don't want to wait for it) we can push it, then please state name 
and email for the commit.


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

https://reviews.llvm.org/D106349

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


[PATCH] D106773: [clang-format] Fix aligning with linebreaks #2

2021-07-29 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks added a comment.

It's picked: 0e3777bb0ad94ecd1429dc96409177cdccf39bdd 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106773

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


[PATCH] D107026: [Clang] Add support for attribute 'escape'

2021-07-29 Thread Josh Learn via Phabricator via cfe-commits
guitard0g added a comment.

@vsavchenko

> I see that the "applies to pointer arguments only" warning is not tested for 
> `noescape`, but I still find it to be a good practice to write a test with a 
> bunch of cases with attributes applied in wrong places.

Updated with some tests for this!

> Additionally, I believe that `escape` and `noescape` convey the same 
> information, and it is totally okay to have two attributes because the user 
> has to have a choice to say either "I do escape it" or "I definitely do not 
> escape it" when the default is unspecified at all.  But I do think that we 
> should add a check disallowing both of these attributes to be used at the 
> same time for the same parameter, since they directly contradict one another.

Ah that's a great point, most recent update makes these two mutually exclusive.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107026

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


[clang] 7645cdc - Revert "[AIX] Pass the -b option to linker on AIX"

2021-07-29 Thread Anjan Kumar via cfe-commits

Author: Anjan Kumar
Date: 2021-07-29T19:40:25Z
New Revision: 7645cdcb482694d30771c3409e43ebf2a448211f

URL: 
https://github.com/llvm/llvm-project/commit/7645cdcb482694d30771c3409e43ebf2a448211f
DIFF: 
https://github.com/llvm/llvm-project/commit/7645cdcb482694d30771c3409e43ebf2a448211f.diff

LOG: Revert "[AIX] Pass the -b option to linker on AIX"

This reverts commit 109954410c34434a181f5eb48cbd14f4122101c7.

Added: 


Modified: 
clang/include/clang/Driver/Options.td
clang/lib/Driver/ToolChains/CommonArgs.cpp
clang/test/Driver/Xlinker-args.c

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 7ae775c2e00b..7e2397c4192f 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -815,9 +815,7 @@ def autocomplete : Joined<["--"], "autocomplete=">;
 def bind__at__load : Flag<["-"], "bind_at_load">;
 def bundle__loader : Separate<["-"], "bundle_loader">;
 def bundle : Flag<["-"], "bundle">;
-def b : JoinedOrSeparate<["-"], "b">, Flags<[LinkerInput, RenderAsInput]>,
-  HelpText<"Pass -b  to the linker on AIX (only).">, MetaVarName<"">,
-  Group;
+def b : JoinedOrSeparate<["-"], "b">, Flags<[Unsupported]>;
 def cl_opt_disable : Flag<["-"], "cl-opt-disable">, Group, 
Flags<[CC1Option]>,
   HelpText<"OpenCL only. This option disables all optimizations. By default 
optimizations are enabled.">;
 def cl_strict_aliasing : Flag<["-"], "cl-strict-aliasing">, 
Group, Flags<[CC1Option]>,

diff  --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp 
b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index 5905b241aa51..d9a6599a2416 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -257,16 +257,6 @@ void tools::AddLinkerInputs(const ToolChain , const 
InputInfoList ,
 // Otherwise, this is a linker input argument.
 const Arg  = II.getInputArg();
 
-if (A.getOption().matches(options::OPT_b)) {
-  const llvm::Triple  = TC.getTriple();
-  if (!T.isOSAIX()) {
-TC.getDriver().Diag(diag::err_drv_unsupported_opt_for_target)
-<< A.getAsString(Args);
-  }
-  // Pass -b prefix for AIX linker.
-  A.claim();
-  A.render(Args, CmdArgs);
-}
 // Handle reserved library options.
 if (A.getOption().matches(options::OPT_Z_reserved_lib_stdcxx))
   TC.AddCXXStdlibLibArgs(Args, CmdArgs);

diff  --git a/clang/test/Driver/Xlinker-args.c 
b/clang/test/Driver/Xlinker-args.c
index 5eff8a0748ff..cb045a1d40ac 100644
--- a/clang/test/Driver/Xlinker-args.c
+++ b/clang/test/Driver/Xlinker-args.c
@@ -11,20 +11,10 @@
 // RUN:   -e _start -T a.lds -Xlinker one -Xlinker --no-demangle \
 // RUN:   -Wl,two,--no-demangle,three -Xlinker four -z five -r %s 2> %t
 // RUN: FileCheck -check-prefix=LINUX < %t %s
-
-// RUN: %clang -target powerpc-unknown-aix -### \
-// RUN:   -b one %s 2> %t
-// RUN: FileCheck -check-prefix=AIX < %t %s
-
-// RUN: %clang -target powerpc-unknown-linux -### \
-// RUN:   -b one %s 2> %t
-// RUN: FileCheck -check-prefix=NOT-AIX < %t %s
-
+//
 // DARWIN-NOT: --no-demangle
 // DARWIN: "one" "two" "three" "four" "-z" "five" "-r"
 // LINUX: "--no-demangle" "-e" "_start" "one" "two" "three" "four" "-z" "five" 
"-r" {{.*}} "-T" "a.lds"
-// AIX: "-b" "one" 
-// NOT-AIX: error: unsupported option '-b one'
 
 // Check that we forward '-Xlinker' and '-Wl,' on Windows.
 // RUN: %clang -target i686-pc-win32 -fuse-ld=link -### \



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


[PATCH] D107026: [Clang] Add support for attribute 'escape'

2021-07-29 Thread Josh Learn via Phabricator via cfe-commits
guitard0g updated this revision to Diff 362849.
guitard0g marked an inline comment as done.
guitard0g added a comment.

Add tests for diagnostics of incorrect usage. Diagnose when escape and noescape 
are used on the same parameter.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107026

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/AST/ast-dump-attr.cpp
  clang/test/AST/ast-dump-attr.m
  clang/test/Misc/pragma-attribute-supported-attributes-list.test
  clang/test/SemaObjCXX/escape.mm

Index: clang/test/SemaObjCXX/escape.mm
===
--- /dev/null
+++ clang/test/SemaObjCXX/escape.mm
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -fblocks -std=c++11 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -fblocks -std=c++1z %s
+
+struct S {};
+
+template 
+void escapeFunc0(__attribute__((noescape)) T); // expected-warning {{'noescape' attribute only applies to pointer arguments}}
+template 
+void escapeFunc1(__attribute__((escape)) const T &);
+template 
+void escapeFunc2(__attribute__((escape)) T &&);
+
+void escapeFunc3(__attribute__((escape)) int *);
+void escapeFunc4(__attribute__((escape)) void *);
+void escapeFunc5(__attribute__((escape)) int **);
+
+void invalidFunc0(int __attribute__((escape))); // expected-warning {{'escape' attribute only applies to pointer arguments}}
+void invalidFunc1(int __attribute__((escape(0; // expected-error {{'escape' attribute takes no arguments}}
+void invalidFunc2(__attribute__((escape)) int (S::*Ty)); // expected-warning {{'escape' attribute only applies to pointer arguments}}
+void invalidFunc3(__attribute__((escape)) void (S::*Ty)()); // expected-warning {{'escape' attribute only applies to pointer arguments}}
+
+void invalidFunc4(__attribute__((escape)) __attribute__((noescape)) int *); // expected-error {{'noescape' and 'escape' attributes are not compatible}} \
+// expected-note {{conflicting attribute is here}}
+void invalidFunc5(__attribute__((noescape)) __attribute__((escape)) int *); // expected-error {{'escape' and 'noescape' attributes are not compatible}} \
+// expected-note {{conflicting attribute is here}}
+
+int __attribute__((escape)) g; // expected-warning {{'escape' attribute only applies to parameters}}
+int * __attribute__((escape)) h; // expected-warning {{'escape' attribute only applies to parameters}}
Index: clang/test/Misc/pragma-attribute-supported-attributes-list.test
===
--- clang/test/Misc/pragma-attribute-supported-attributes-list.test
+++ clang/test/Misc/pragma-attribute-supported-attributes-list.test
@@ -61,6 +61,7 @@
 // CHECK-NEXT: EnforceTCB (SubjectMatchRule_function)
 // CHECK-NEXT: EnforceTCBLeaf (SubjectMatchRule_function)
 // CHECK-NEXT: EnumExtensibility (SubjectMatchRule_enum)
+// CHECK-NEXT: Escape (SubjectMatchRule_variable_is_parameter)
 // CHECK-NEXT: ExcludeFromExplicitInstantiation (SubjectMatchRule_variable, SubjectMatchRule_function, SubjectMatchRule_record)
 // CHECK-NEXT: ExternalSourceSymbol ((SubjectMatchRule_record, SubjectMatchRule_enum, SubjectMatchRule_enum_constant, SubjectMatchRule_field, SubjectMatchRule_function, SubjectMatchRule_namespace, SubjectMatchRule_objc_category, SubjectMatchRule_objc_implementation, SubjectMatchRule_objc_interface, SubjectMatchRule_objc_method, SubjectMatchRule_objc_property, SubjectMatchRule_objc_protocol, SubjectMatchRule_record, SubjectMatchRule_type_alias, SubjectMatchRule_variable))
 // CHECK-NEXT: FlagEnum (SubjectMatchRule_enum)
Index: clang/test/AST/ast-dump-attr.m
===
--- clang/test/AST/ast-dump-attr.m
+++ clang/test/AST/ast-dump-attr.m
@@ -65,4 +65,8 @@
 // CHECK-NEXT: | `-NoEscapeAttr
 // CHECK-NEXT: |-ParmVarDecl{{.*}} Test14 'int'
 // CHECK-NEXT: `-NSConsumesSelfAttr
+-(void)Test15: (int *) [[clang::escape]] Test16;
+// CHECK: ObjCMethodDecl{{.*}} Test15: 'void'
+// CHECK-NEXT: -ParmVarDecl{{.*}} Test16 'int *'
+// CHECK-NEXT: `-EscapeAttr
 @end
Index: clang/test/AST/ast-dump-attr.cpp
===
--- clang/test/AST/ast-dump-attr.cpp
+++ clang/test/AST/ast-dump-attr.cpp
@@ -200,6 +200,15 @@
   // CHECK-NEXT: NoEscapeAttr
 }
 
+namespace TestEscape {
+  void escapeFunc(int *p0, __attribute__((escape)) int *p1) {}
+  // CHECK: NamespaceDecl{{.*}} TestEscape
+  // CHECK-NEXT: `-FunctionDecl{{.*}} escapeFunc 'void (int *, int *)'
+  // CHECK-NEXT: ParmVarDecl
+  // CHECK-NEXT: ParmVarDecl
+  // CHECK-NEXT: EscapeAttr
+}
+
 namespace TestSuppress {
   [[gsl::suppress("at-namespace")]];
   // CHECK: NamespaceDecl{{.*}} TestSuppress
Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- 

[PATCH] D106688: [AIX] Pass the -b option to linker on AIX

2021-07-29 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

This seems to break tests everywhere, see e.g. 
https://lab.llvm.org/buildbot/#/builders/109/builds/19680

PTAL.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106688

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


[PATCH] D106898: Revert "Revert "[clang][pp] adds '#pragma include_instead'""

2021-07-29 Thread Christopher Di Bella via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG087195419719: Revert Revert [clang][pp] adds 
#pragma include_instead (authored by cjdb).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106898

Files:
  clang/include/clang/Basic/DiagnosticLexKinds.td
  clang/include/clang/Lex/HeaderSearch.h
  clang/include/clang/Lex/Preprocessor.h
  clang/include/clang/Lex/PreprocessorLexer.h
  clang/lib/Lex/Lexer.cpp
  clang/lib/Lex/PPDirectives.cpp
  clang/lib/Lex/PPLexerChange.cpp
  clang/lib/Lex/Pragma.cpp
  clang/test/PCH/ms-pch-macro-include_instead-regression.c
  clang/test/Preprocessor/Inputs/include_instead/bad-syntax.h
  clang/test/Preprocessor/Inputs/include_instead/file-not-found.h
  clang/test/Preprocessor/Inputs/include_instead/non-system-header.h
  clang/test/Preprocessor/Inputs/include_instead/private-x.h
  clang/test/Preprocessor/Inputs/include_instead/private1.h
  clang/test/Preprocessor/Inputs/include_instead/private2.h
  clang/test/Preprocessor/Inputs/include_instead/private3.h
  clang/test/Preprocessor/Inputs/include_instead/public-after.h
  clang/test/Preprocessor/Inputs/include_instead/public-before.h
  clang/test/Preprocessor/Inputs/include_instead/public-empty.h
  clang/test/Preprocessor/include_instead.cpp
  clang/test/Preprocessor/include_instead_file_not_found.cpp

Index: clang/test/Preprocessor/include_instead_file_not_found.cpp
===
--- /dev/null
+++ clang/test/Preprocessor/include_instead_file_not_found.cpp
@@ -0,0 +1,2 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -I %S/Inputs %s
+#include 
Index: clang/test/Preprocessor/include_instead.cpp
===
--- /dev/null
+++ clang/test/Preprocessor/include_instead.cpp
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -I %S/Inputs %s
+
+#include 
+#include 
+
+#include 
+// expected-error@-1{{header '' is an implementation detail; #include '' instead}}
+
+#include "include_instead/private2.h"
+// expected-error@-1{{header '"include_instead/private2.h"' is an implementation detail; #include either '' or '"include_instead/public-after.h"' instead}}
+
+#include 
+// expected-error@-1{{header '' is an implementation detail; #include one of {'', '', '"include_instead/public-before.h"'} instead}}
+
+#include 
+#include 
Index: clang/test/Preprocessor/Inputs/include_instead/public-empty.h
===
--- /dev/null
+++ clang/test/Preprocessor/Inputs/include_instead/public-empty.h
@@ -0,0 +1 @@
+// This file simply needs to exist.
Index: clang/test/Preprocessor/Inputs/include_instead/public-before.h
===
--- /dev/null
+++ clang/test/Preprocessor/Inputs/include_instead/public-before.h
@@ -0,0 +1,5 @@
+#pragma GCC system_header
+
+#include  // no warning expected
+#include  // no warning expected
+#include  // no warning expected
Index: clang/test/Preprocessor/Inputs/include_instead/public-after.h
===
--- /dev/null
+++ clang/test/Preprocessor/Inputs/include_instead/public-after.h
@@ -0,0 +1,2 @@
+#include 
+#pragma GCC system_header
Index: clang/test/Preprocessor/Inputs/include_instead/private3.h
===
--- /dev/null
+++ clang/test/Preprocessor/Inputs/include_instead/private3.h
@@ -0,0 +1,5 @@
+#pragma GCC system_header
+
+#pragma clang include_instead()
+#pragma clang include_instead()
+#pragma clang include_instead("include_instead/public-before.h")
Index: clang/test/Preprocessor/Inputs/include_instead/private2.h
===
--- /dev/null
+++ clang/test/Preprocessor/Inputs/include_instead/private2.h
@@ -0,0 +1,4 @@
+#pragma GCC system_header
+
+#pragma clang include_instead()
+#pragma clang include_instead("include_instead/public-after.h")
Index: clang/test/Preprocessor/Inputs/include_instead/private1.h
===
--- /dev/null
+++ clang/test/Preprocessor/Inputs/include_instead/private1.h
@@ -0,0 +1,2 @@
+#pragma GCC system_header
+#pragma clang include_instead()
Index: clang/test/Preprocessor/Inputs/include_instead/private-x.h
===
--- /dev/null
+++ clang/test/Preprocessor/Inputs/include_instead/private-x.h
@@ -0,0 +1,4 @@
+#include 
+
+#pragma GCC system_header
+#pragma clang include_instead()
Index: clang/test/Preprocessor/Inputs/include_instead/non-system-header.h
===
--- /dev/null
+++ clang/test/Preprocessor/Inputs/include_instead/non-system-header.h
@@ -0,0 +1,2 @@
+#pragma clang include_instead()
+// 

[clang] 0871954 - Revert "Revert "[clang][pp] adds '#pragma include_instead'""

2021-07-29 Thread Christopher Di Bella via cfe-commits

Author: Christopher Di Bella
Date: 2021-07-29T19:21:43Z
New Revision: 087195419719e908394081b4cc6f365170b9882c

URL: 
https://github.com/llvm/llvm-project/commit/087195419719e908394081b4cc6f365170b9882c
DIFF: 
https://github.com/llvm/llvm-project/commit/087195419719e908394081b4cc6f365170b9882c.diff

LOG: Revert "Revert "[clang][pp] adds '#pragma include_instead'""

Includes regression test for problem noted by @hans.
This reverts commit 973de7185606a21fd5e9d5e8c014fbf898c0e72f.

Differential Revision: https://reviews.llvm.org/D106898

Added: 
clang/test/PCH/ms-pch-macro-include_instead-regression.c
clang/test/Preprocessor/Inputs/include_instead/bad-syntax.h
clang/test/Preprocessor/Inputs/include_instead/file-not-found.h
clang/test/Preprocessor/Inputs/include_instead/non-system-header.h
clang/test/Preprocessor/Inputs/include_instead/private-x.h
clang/test/Preprocessor/Inputs/include_instead/private1.h
clang/test/Preprocessor/Inputs/include_instead/private2.h
clang/test/Preprocessor/Inputs/include_instead/private3.h
clang/test/Preprocessor/Inputs/include_instead/public-after.h
clang/test/Preprocessor/Inputs/include_instead/public-before.h
clang/test/Preprocessor/Inputs/include_instead/public-empty.h
clang/test/Preprocessor/include_instead.cpp
clang/test/Preprocessor/include_instead_file_not_found.cpp

Modified: 
clang/include/clang/Basic/DiagnosticLexKinds.td
clang/include/clang/Lex/HeaderSearch.h
clang/include/clang/Lex/Preprocessor.h
clang/include/clang/Lex/PreprocessorLexer.h
clang/lib/Lex/Lexer.cpp
clang/lib/Lex/PPDirectives.cpp
clang/lib/Lex/PPLexerChange.cpp
clang/lib/Lex/Pragma.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticLexKinds.td 
b/clang/include/clang/Basic/DiagnosticLexKinds.td
index 174f6c3dfd4c6..f621cdb466560 100644
--- a/clang/include/clang/Basic/DiagnosticLexKinds.td
+++ b/clang/include/clang/Basic/DiagnosticLexKinds.td
@@ -300,6 +300,13 @@ def pp_pragma_once_in_main_file : Warning<"#pragma once in 
main file">,
 def pp_pragma_sysheader_in_main_file : Warning<
   "#pragma system_header ignored in main file">,
   InGroup>;
+
+def err_pragma_include_instead_not_sysheader : Error<
+  "'#pragma clang include_instead' cannot be used outside of system headers">;
+def err_pragma_include_instead_system_reserved : Error<
+  "header '%0' is an implementation detail; #include %select{'%2'|either '%2' "
+  "or '%3'|one of %2}1 instead">;
+
 def pp_poisoning_existing_macro : Warning<"poisoning existing macro">;
 def pp_out_of_date_dependency : Warning<
   "current file is older than dependency %0">;

diff  --git a/clang/include/clang/Lex/HeaderSearch.h 
b/clang/include/clang/Lex/HeaderSearch.h
index 93d6ea72270aa..a35a394f719b0 100644
--- a/clang/include/clang/Lex/HeaderSearch.h
+++ b/clang/include/clang/Lex/HeaderSearch.h
@@ -20,9 +20,12 @@
 #include "clang/Lex/ModuleMap.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/SetVector.h"
+#include "llvm/ADT/SmallSet.h"
+#include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/StringMap.h"
-#include "llvm/ADT/StringSet.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/ADT/StringSet.h"
 #include "llvm/Support/Allocator.h"
 #include 
 #include 
@@ -110,6 +113,14 @@ struct HeaderFileInfo {
   /// of the framework.
   StringRef Framework;
 
+  /// List of aliases that this header is known as.
+  /// Most headers should only have at most one alias, but a handful
+  /// have two.
+  llvm::SetVector,
+  llvm::SmallVector, 2>,
+  llvm::SmallSet, 2>>
+  Aliases;
+
   HeaderFileInfo()
   : isImport(false), isPragmaOnce(false), DirInfo(SrcMgr::C_User),
 External(false), isModuleHeader(false), isCompilingModuleHeader(false),
@@ -453,6 +464,10 @@ class HeaderSearch {
 getFileInfo(File).DirInfo = SrcMgr::C_System;
   }
 
+  void AddFileAlias(const FileEntry *File, StringRef Alias) {
+getFileInfo(File).Aliases.insert(Alias);
+  }
+
   /// Mark the specified file as part of a module.
   void MarkFileModuleHeader(const FileEntry *FE,
 ModuleMap::ModuleHeaderRole Role,

diff  --git a/clang/include/clang/Lex/Preprocessor.h 
b/clang/include/clang/Lex/Preprocessor.h
index 45ee0ad9fd21e..8ecd6a965cf86 100644
--- a/clang/include/clang/Lex/Preprocessor.h
+++ b/clang/include/clang/Lex/Preprocessor.h
@@ -1961,7 +1961,8 @@ class Preprocessor {
   /// This either returns the EOF token and returns true, or
   /// pops a level off the include stack and returns false, at which point the
   /// client should call lex again.
-  bool HandleEndOfFile(Token , bool isEndOfMacro = false);
+  bool HandleEndOfFile(Token , SourceLocation Loc,
+   bool isEndOfMacro = false);
 
   /// Callback invoked when the current TokenLexer hits the end of its
   /// token stream.
@@ 

[PATCH] D105819: [analyzer] MallocChecker: Add a visitor to leave a note on functions that could have, but did not change ownership on leaked memory

2021-07-29 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added a comment.

Thanks! Here are some results:

All runs can be found here: 
https://codechecker-demo.eastus.cloudapp.azure.com/Default/runs

Protobuf, Bitcoin, Xerces, TinyXML, PostgreSQL, FFMPEG, OpenSSL, Vim, Redis, 
Twin, curl:


Nothing changed.

libWebM:


Ignoring the fact that at both places where memory was allocated there is a `// 
NOLINT` comment, I think these bug reports have improved greatly. A function is 
highlighted where each of those memory region could have been added to a 
container, but were not. Not that I wrote any code to look for this, this is 
purely luck ;)

No1. 
,
 No2. 


SQLite:
---

This one isn't as great. I wouldn't expect a function called `buildshifts` to 
do any sort of dynamic memory management, and its contents support this claim. 
`stp` is only referencing to retrieve one of its members. More worrying is the 
fact that `State_insert` seems like the function (or macro, as they are not 
always capitalized in this project) to deal with this, yet it isn't noted at 
all in the bug report.

No1. 



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

https://reviews.llvm.org/D105819

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


[PATCH] D107095: This patch adds `#pragma clang header_unsafe` to enable flagging macros as unsafe for header use. This is to allow macros that may have ABI implications to be avoided in headers that

2021-07-29 Thread Chris Bieneman via Phabricator via cfe-commits
beanz updated this revision to Diff 362840.
beanz added a comment.

Fixing an inadvertant change.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107095

Files:
  clang/docs/LanguageExtensions.rst
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticLexKinds.td
  clang/include/clang/Basic/IdentifierTable.h
  clang/include/clang/Lex/Preprocessor.h
  clang/lib/Lex/Pragma.cpp
  clang/lib/Lex/Preprocessor.cpp
  clang/test/Lexer/Inputs/unsafe-macro-2.h
  clang/test/Lexer/Inputs/unsafe-macro.h
  clang/test/Lexer/unsafe-macro.c

Index: clang/test/Lexer/unsafe-macro.c
===
--- /dev/null
+++ clang/test/Lexer/unsafe-macro.c
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -Wpedantic-macros %s -fsyntax-only -verify
+#include "Inputs/unsafe-macro.h"
+#include "Inputs/unsafe-macro-2.h"
+
+// not-expected-warning@+1{{macro 'UNSAFE_MACRO' has been marked as unsafe for use in headers: Don't use this!}}
+#if UNSAFE_MACRO
+#endif
Index: clang/test/Lexer/Inputs/unsafe-macro.h
===
--- /dev/null
+++ clang/test/Lexer/Inputs/unsafe-macro.h
@@ -0,0 +1,18 @@
+// expected-error@+1{{expected (}}
+#pragma clang header_unsafe
+
+// expected-error@+1{{expected identifier}}
+#pragma clang header_unsafe(4
+
+// expected-error@+1{{no macro named foo}}
+#pragma clang header_unsafe(foo)
+
+
+#define UNSAFE_MACRO 1
+#pragma clang header_unsafe(UNSAFE_MACRO, "Don't use this!")
+
+#define UNSAFE_MACRO_2 2
+#pragma clang header_unsafe(UNSAFE_MACRO_2)
+
+// expected-error@+1{{expected )}}
+#pragma clang deprecated(UNSAFE_MACRO
Index: clang/test/Lexer/Inputs/unsafe-macro-2.h
===
--- /dev/null
+++ clang/test/Lexer/Inputs/unsafe-macro-2.h
@@ -0,0 +1,70 @@
+// expected-warning@+1{{macro 'UNSAFE_MACRO' has been marked as unsafe for use in headers: Don't use this!}}
+#if UNSAFE_MACRO
+#endif
+
+// expected-warning@+1{{macro 'UNSAFE_MACRO' has been marked as unsafe for use in headers: Don't use this!}}
+#if defined(UNSAFE_MACRO)
+#endif
+
+// expected-warning@+1{{macro 'UNSAFE_MACRO' has been marked as unsafe for use in headers: Don't use this!}}
+#ifdef UNSAFE_MACRO
+#endif
+
+// expected-warning@+1{{macro 'UNSAFE_MACRO' has been marked as unsafe for use in headers: Don't use this!}}
+#ifndef UNSAFE_MACRO
+#endif
+
+// expected-warning@+1{{macro 'UNSAFE_MACRO' has been marked as unsafe for use in headers: Don't use this!}}
+const int x = UNSAFE_MACRO;
+
+// expected-warning@+1{{macro 'UNSAFE_MACRO_2' has been marked as unsafe for use in headers}}
+const int y = UNSAFE_MACRO_2;
+
+// not-expected-warning@+1{{macro 'UNSAFE_MACRO_2' has been marked as unsafe for use in headers}}
+#undef UNSAFE_MACRO_2
+// not-expected-warning@+1{{macro 'UNSAFE_MACRO_2' has been marked as unsafe for use in headers}}
+#define UNSAFE_MACRO_2 2
+
+// not-expected-warning@+1{{macro 'UNSAFE_MACRO_2' has been marked as unsafe for use in headers}}
+const int z = UNSAFE_MACRO_2;
+
+
+// Test that we diagnose on #elif.
+#if 0
+#elif UNSAFE_MACRO
+// expected-warning@-1{{macro 'UNSAFE_MACRO' has been marked as unsafe for use in headers: Don't use this!}}
+#endif
+
+
+// Test that we diagnose on #elifdef.
+#ifdef baz
+#elifdef UNSAFE_MACRO
+// expected-warning@-1{{macro 'UNSAFE_MACRO' has been marked as unsafe for use in headers: Don't use this!}}
+#endif
+
+// Test that we diagnose on #elifndef.
+#ifdef baz
+#elifndef UNSAFE_MACRO
+#endif
+// expected-warning@-2{{macro 'UNSAFE_MACRO' has been marked as unsafe for use in headers: Don't use this!}}
+
+// FIXME: These cases are currently not handled because clang doesn't expand
+// conditions on skipped #elif* blocks. See the FIXME notes in
+// Preprocessor::SkipExcludedConditionalBlock.
+
+#define frobble
+
+#ifdef frobble
+// not-expected-warning@+1{{macro 'UNSAFE_MACRO' has been marked as unsafe for use in headers: Don't use this!}}
+#elifndef UNSAFE_MACRO
+#endif
+
+#ifdef frobble
+// not-expected-warning@+1{{macro 'UNSAFE_MACRO' has been marked as unsafe for use in headers: Don't use this!}}
+#elifdef UNSAFE_MACRO
+#endif
+
+#if 1
+// not-expected-warning@+1{{macro 'UNSAFE_MACRO' has been marked as unsafe for use in headers: Don't use this!}}
+#elif UNSAFE_MACRO
+#endif
Index: clang/lib/Lex/Preprocessor.cpp
===
--- clang/lib/Lex/Preprocessor.cpp
+++ clang/lib/Lex/Preprocessor.cpp
@@ -1423,6 +1423,17 @@
   Diag(Identifier, diag::warn_pragma_deprecated_macro_use)
   << Identifier.getIdentifierInfo() << 1 << *DepMsg;
   }
+
+  if (Identifier.getIdentifierInfo()->isHeaderUnsafe() &&
+  !SourceMgr.isInMainFile(Identifier.getLocation())) {
+auto DepMsg = getHeaderUnsafeMsg(Identifier.getIdentifierInfo());
+if (!DepMsg)
+  Diag(Identifier, 

[PATCH] D107095: This patch adds `#pragma clang header_unsafe` to enable flagging macros as unsafe for header use. This is to allow macros that may have ABI implications to be avoided in headers that

2021-07-29 Thread Chris Bieneman via Phabricator via cfe-commits
beanz created this revision.
beanz added reviewers: aaron.ballman, rsmith, lgerbarg, pete.
Herald added a subscriber: dexonsmith.
beanz requested review of this revision.
Herald added a project: clang.

Using macros in headers (particularly public headers) can cause a
variety of issues relating to ABI and modules. This new pragma logs
warnings when using annotated macros outside the main source file.

This warning is added under a new diagnostics group -Wpedantic-macros.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D107095

Files:
  clang/docs/LanguageExtensions.rst
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticLexKinds.td
  clang/include/clang/Basic/IdentifierTable.h
  clang/include/clang/Lex/Preprocessor.h
  clang/lib/Lex/Pragma.cpp
  clang/lib/Lex/Preprocessor.cpp
  clang/test/Lexer/Inputs/unsafe-macro-2.h
  clang/test/Lexer/Inputs/unsafe-macro.h
  clang/test/Lexer/unsafe-macro.c

Index: clang/test/Lexer/unsafe-macro.c
===
--- /dev/null
+++ clang/test/Lexer/unsafe-macro.c
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -Wpedantic-macros %s -fsyntax-only -verify
+#include "Inputs/unsafe-macro.h"
+#include "Inputs/unsafe-macro-2.h"
+
+// not-expected-warning@+1{{macro 'UNSAFE_MACRO' has been marked as unsafe for use in headers: Don't use this!}}
+#if UNSAFE_MACRO
+#endif
Index: clang/test/Lexer/Inputs/unsafe-macro.h
===
--- /dev/null
+++ clang/test/Lexer/Inputs/unsafe-macro.h
@@ -0,0 +1,18 @@
+// expected-error@+1{{expected (}}
+#pragma clang header_unsafe
+
+// expected-error@+1{{expected identifier}}
+#pragma clang header_unsafe(4
+
+// expected-error@+1{{no macro named foo}}
+#pragma clang header_unsafe(foo)
+
+
+#define UNSAFE_MACRO 1
+#pragma clang header_unsafe(UNSAFE_MACRO, "Don't use this!")
+
+#define UNSAFE_MACRO_2 2
+#pragma clang header_unsafe(UNSAFE_MACRO_2)
+
+// expected-error@+1{{expected )}}
+#pragma clang deprecated(UNSAFE_MACRO
Index: clang/test/Lexer/Inputs/unsafe-macro-2.h
===
--- /dev/null
+++ clang/test/Lexer/Inputs/unsafe-macro-2.h
@@ -0,0 +1,70 @@
+// expected-warning@+1{{macro 'UNSAFE_MACRO' has been marked as unsafe for use in headers: Don't use this!}}
+#if UNSAFE_MACRO
+#endif
+
+// expected-warning@+1{{macro 'UNSAFE_MACRO' has been marked as unsafe for use in headers: Don't use this!}}
+#if defined(UNSAFE_MACRO)
+#endif
+
+// expected-warning@+1{{macro 'UNSAFE_MACRO' has been marked as unsafe for use in headers: Don't use this!}}
+#ifdef UNSAFE_MACRO
+#endif
+
+// expected-warning@+1{{macro 'UNSAFE_MACRO' has been marked as unsafe for use in headers: Don't use this!}}
+#ifndef UNSAFE_MACRO
+#endif
+
+// expected-warning@+1{{macro 'UNSAFE_MACRO' has been marked as unsafe for use in headers: Don't use this!}}
+const int x = UNSAFE_MACRO;
+
+// expected-warning@+1{{macro 'UNSAFE_MACRO_2' has been marked as unsafe for use in headers}}
+const int y = UNSAFE_MACRO_2;
+
+// not-expected-warning@+1{{macro 'UNSAFE_MACRO_2' has been marked as unsafe for use in headers}}
+#undef UNSAFE_MACRO_2
+// not-expected-warning@+1{{macro 'UNSAFE_MACRO_2' has been marked as unsafe for use in headers}}
+#define UNSAFE_MACRO_2 2
+
+// not-expected-warning@+1{{macro 'UNSAFE_MACRO_2' has been marked as unsafe for use in headers}}
+const int z = UNSAFE_MACRO_2;
+
+
+// Test that we diagnose on #elif.
+#if 0
+#elif UNSAFE_MACRO
+// expected-warning@-1{{macro 'UNSAFE_MACRO' has been marked as unsafe for use in headers: Don't use this!}}
+#endif
+
+
+// Test that we diagnose on #elifdef.
+#ifdef baz
+#elifdef UNSAFE_MACRO
+// expected-warning@-1{{macro 'UNSAFE_MACRO' has been marked as unsafe for use in headers: Don't use this!}}
+#endif
+
+// Test that we diagnose on #elifndef.
+#ifdef baz
+#elifndef UNSAFE_MACRO
+#endif
+// expected-warning@-2{{macro 'UNSAFE_MACRO' has been marked as unsafe for use in headers: Don't use this!}}
+
+// FIXME: These cases are currently not handled because clang doesn't expand
+// conditions on skipped #elif* blocks. See the FIXME notes in
+// Preprocessor::SkipExcludedConditionalBlock.
+
+#define frobble
+
+#ifdef frobble
+// not-expected-warning@+1{{macro 'UNSAFE_MACRO' has been marked as unsafe for use in headers: Don't use this!}}
+#elifndef UNSAFE_MACRO
+#endif
+
+#ifdef frobble
+// not-expected-warning@+1{{macro 'UNSAFE_MACRO' has been marked as unsafe for use in headers: Don't use this!}}
+#elifdef UNSAFE_MACRO
+#endif
+
+#if 1
+// not-expected-warning@+1{{macro 'UNSAFE_MACRO' has been marked as unsafe for use in headers: Don't use this!}}
+#elif UNSAFE_MACRO
+#endif
Index: clang/lib/Lex/Preprocessor.cpp
===
--- clang/lib/Lex/Preprocessor.cpp
+++ clang/lib/Lex/Preprocessor.cpp
@@ -1423,6 +1423,17 @@
   Diag(Identifier, diag::warn_pragma_deprecated_macro_use)
 

[PATCH] D106867: [scan-build] Fix a typo in the manual page: s/contraint/constraint.

2021-07-29 Thread Michał Górny via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG1862ffe25a2e: [clang] Fix a typo in the manual page: 
s/contraint/constraint. (authored by fcambus, committed by mgorny).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106867

Files:
  clang/tools/scan-build/man/scan-build.1


Index: clang/tools/scan-build/man/scan-build.1
===
--- clang/tools/scan-build/man/scan-build.1
+++ clang/tools/scan-build/man/scan-build.1
@@ -2,9 +2,9 @@
 .\" See https://llvm.org/LICENSE.txt for license information.
 .\" SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 .\" $Id$
-.Dd May 25, 2012
+.Dd Jul 27, 2021
 .Dt SCAN-BUILD 1
-.Os "clang" "3.5"
+.Os "clang" "13"
 .Sh NAME
 .Nm scan-build
 .Nd Clang static analyzer
@@ -110,7 +110,7 @@
 .It Fl V , Fl Fl view
 View analysis results in a web browser when the build completes.
 .It Fl constraints Op Ar model
-Specify the contraint engine used by the analyzer.  By default the
+Specify the constraint engine used by the analyzer.  By default the
 .Ql range
 model is used.  Specifying
 .Ql basic


Index: clang/tools/scan-build/man/scan-build.1
===
--- clang/tools/scan-build/man/scan-build.1
+++ clang/tools/scan-build/man/scan-build.1
@@ -2,9 +2,9 @@
 .\" See https://llvm.org/LICENSE.txt for license information.
 .\" SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 .\" $Id$
-.Dd May 25, 2012
+.Dd Jul 27, 2021
 .Dt SCAN-BUILD 1
-.Os "clang" "3.5"
+.Os "clang" "13"
 .Sh NAME
 .Nm scan-build
 .Nd Clang static analyzer
@@ -110,7 +110,7 @@
 .It Fl V , Fl Fl view
 View analysis results in a web browser when the build completes.
 .It Fl constraints Op Ar model
-Specify the contraint engine used by the analyzer.  By default the
+Specify the constraint engine used by the analyzer.  By default the
 .Ql range
 model is used.  Specifying
 .Ql basic
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D106664: [clang][docs] Fix typos in Options.td and regen ClangCommandLineReference.rst.

2021-07-29 Thread Michał Górny via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGbc96aa9f2c9b: [clang] Fix typos in Options.td and regen 
ClangCommandLineReference.rst. (authored by fcambus, committed by mgorny).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106664

Files:
  clang/docs/ClangCommandLineReference.rst
  clang/include/clang/Driver/Options.td


Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -1006,7 +1006,7 @@
"offloading languages CUDA and HIP: 'hash' (ID's generated by 
hashing "
"file path and command line options) | 'random' (ID's generated as "
"random numbers) | 'none' (disabled). Default is 'hash'. This 
option "
-   "will be overriden by option '-cuid=[ID]' if it is specified." >;
+   "will be overridden by option '-cuid=[ID]' if it is specified." >;
 def libomptarget_amdgcn_bc_path_EQ : Joined<["--"], 
"libomptarget-amdgcn-bc-path=">, Group,
   HelpText<"Path to libomptarget-amdgcn bitcode library">;
 def libomptarget_nvptx_bc_path_EQ : Joined<["--"], 
"libomptarget-nvptx-bc-path=">, Group,
@@ -2693,10 +2693,10 @@
 def dA : Flag<["-"], "dA">, Alias;
 defm visibility_from_dllstorageclass : 
BoolFOption<"visibility-from-dllstorageclass",
   LangOpts<"VisibilityFromDLLStorageClass">, DefaultFalse,
-  PosFlag,
+  PosFlag,
   NegFlag>;
 def fvisibility_dllexport_EQ : Joined<["-"], "fvisibility-dllexport=">, 
Group, Flags<[CC1Option]>,
-  HelpText<"The visibility for dllexport defintions 
[-fvisibility-from-dllstorageclass]">,
+  HelpText<"The visibility for dllexport definitions 
[-fvisibility-from-dllstorageclass]">,
   MarshallingInfoVisibility, 
"DefaultVisibility">,
   ShouldParseIf;
 def fvisibility_nodllstorageclass_EQ : Joined<["-"], 
"fvisibility-nodllstorageclass=">, Group, Flags<[CC1Option]>,
Index: clang/docs/ClangCommandLineReference.rst
===
--- clang/docs/ClangCommandLineReference.rst
+++ clang/docs/ClangCommandLineReference.rst
@@ -263,7 +263,7 @@
 
 .. option:: -fuse-cuid=
 
-Method to generate ID's for compilation units for single source offloading 
languages CUDA and HIP: 'hash' (ID's generated by hashing file path and command 
line options) \| 'random' (ID's generated as random numbers) \| 'none' 
(disabled). Default is 'hash'. This option will be overriden by option 
'-cuid=\[ID\]' if it is specified.
+Method to generate ID's for compilation units for single source offloading 
languages CUDA and HIP: 'hash' (ID's generated by hashing file path and command 
line options) \| 'random' (ID's generated as random numbers) \| 'none' 
(disabled). Default is 'hash'. This option will be overridden by option 
'-cuid=\[ID\]' if it is specified.
 
 .. option:: --gcc-toolchain=, -gcc-toolchain 
 
@@ -2507,7 +2507,7 @@
 
 .. option:: -fvisibility-dllexport=
 
-The visibility for dllexport defintions \[-fvisibility-from-dllstorageclass\]
+The visibility for dllexport definitions \[-fvisibility-from-dllstorageclass\]
 
 .. option:: -fvisibility-externs-dllimport=
 
@@ -2519,7 +2519,7 @@
 
 .. option:: -fvisibility-from-dllstorageclass, 
-fno-visibility-from-dllstorageclass
 
-Set the visiblity of symbols in the generated code from their DLL storage class
+Set the visibility of symbols in the generated code from their DLL storage 
class
 
 .. option:: -fvisibility-global-new-delete-hidden
 


Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -1006,7 +1006,7 @@
"offloading languages CUDA and HIP: 'hash' (ID's generated by hashing "
"file path and command line options) | 'random' (ID's generated as "
"random numbers) | 'none' (disabled). Default is 'hash'. This option "
-   "will be overriden by option '-cuid=[ID]' if it is specified." >;
+   "will be overridden by option '-cuid=[ID]' if it is specified." >;
 def libomptarget_amdgcn_bc_path_EQ : Joined<["--"], "libomptarget-amdgcn-bc-path=">, Group,
   HelpText<"Path to libomptarget-amdgcn bitcode library">;
 def libomptarget_nvptx_bc_path_EQ : Joined<["--"], "libomptarget-nvptx-bc-path=">, Group,
@@ -2693,10 +2693,10 @@
 def dA : Flag<["-"], "dA">, Alias;
 defm visibility_from_dllstorageclass : BoolFOption<"visibility-from-dllstorageclass",
   LangOpts<"VisibilityFromDLLStorageClass">, DefaultFalse,
-  PosFlag,
+  PosFlag,
   NegFlag>;
 def fvisibility_dllexport_EQ : Joined<["-"], "fvisibility-dllexport=">, Group, Flags<[CC1Option]>,
-  HelpText<"The visibility for dllexport defintions [-fvisibility-from-dllstorageclass]">,
+  

[clang] 1862ffe - [clang] Fix a typo in the manual page: s/contraint/constraint.

2021-07-29 Thread Michał Górny via cfe-commits

Author: Frederic Cambus
Date: 2021-07-29T20:34:43+02:00
New Revision: 1862ffe25a2e927ecae012f5f0c4cdf7c3fc1b67

URL: 
https://github.com/llvm/llvm-project/commit/1862ffe25a2e927ecae012f5f0c4cdf7c3fc1b67
DIFF: 
https://github.com/llvm/llvm-project/commit/1862ffe25a2e927ecae012f5f0c4cdf7c3fc1b67.diff

LOG: [clang] Fix a typo in the manual page: s/contraint/constraint.

While there, update hardcoded Clang version from 3.5 to 13.

Differential Revision: https://reviews.llvm.org/D106867

Added: 


Modified: 
clang/tools/scan-build/man/scan-build.1

Removed: 




diff  --git a/clang/tools/scan-build/man/scan-build.1 
b/clang/tools/scan-build/man/scan-build.1
index 4f3cd8d10333a..824037f3b30cb 100644
--- a/clang/tools/scan-build/man/scan-build.1
+++ b/clang/tools/scan-build/man/scan-build.1
@@ -2,9 +2,9 @@
 .\" See https://llvm.org/LICENSE.txt for license information.
 .\" SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 .\" $Id$
-.Dd May 25, 2012
+.Dd Jul 27, 2021
 .Dt SCAN-BUILD 1
-.Os "clang" "3.5"
+.Os "clang" "13"
 .Sh NAME
 .Nm scan-build
 .Nd Clang static analyzer
@@ -110,7 +110,7 @@ increases verbosity.
 .It Fl V , Fl Fl view
 View analysis results in a web browser when the build completes.
 .It Fl constraints Op Ar model
-Specify the contraint engine used by the analyzer.  By default the
+Specify the constraint engine used by the analyzer.  By default the
 .Ql range
 model is used.  Specifying
 .Ql basic



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


[clang] bc96aa9 - [clang] Fix typos in Options.td and regen ClangCommandLineReference.rst.

2021-07-29 Thread Michał Górny via cfe-commits

Author: Frederic Cambus
Date: 2021-07-29T20:33:39+02:00
New Revision: bc96aa9f2c9b25ae65a7e05dbbff8c28079db9c9

URL: 
https://github.com/llvm/llvm-project/commit/bc96aa9f2c9b25ae65a7e05dbbff8c28079db9c9
DIFF: 
https://github.com/llvm/llvm-project/commit/bc96aa9f2c9b25ae65a7e05dbbff8c28079db9c9.diff

LOG: [clang] Fix typos in Options.td and regen ClangCommandLineReference.rst.

Differential Revision: https://reviews.llvm.org/D106664

Added: 


Modified: 
clang/docs/ClangCommandLineReference.rst
clang/include/clang/Driver/Options.td

Removed: 




diff  --git a/clang/docs/ClangCommandLineReference.rst 
b/clang/docs/ClangCommandLineReference.rst
index 35a3fdd382b41..41f2dc70c052f 100644
--- a/clang/docs/ClangCommandLineReference.rst
+++ b/clang/docs/ClangCommandLineReference.rst
@@ -263,7 +263,7 @@ Build this module as a system module. Only used with 
-emit-module
 
 .. option:: -fuse-cuid=
 
-Method to generate ID's for compilation units for single source offloading 
languages CUDA and HIP: 'hash' (ID's generated by hashing file path and command 
line options) \| 'random' (ID's generated as random numbers) \| 'none' 
(disabled). Default is 'hash'. This option will be overriden by option 
'-cuid=\[ID\]' if it is specified.
+Method to generate ID's for compilation units for single source offloading 
languages CUDA and HIP: 'hash' (ID's generated by hashing file path and command 
line options) \| 'random' (ID's generated as random numbers) \| 'none' 
(disabled). Default is 'hash'. This option will be overridden by option 
'-cuid=\[ID\]' if it is specified.
 
 .. option:: --gcc-toolchain=, -gcc-toolchain 
 
@@ -2507,7 +2507,7 @@ Enables dead virtual function elimination optimization. 
Requires -flto=full
 
 .. option:: -fvisibility-dllexport=
 
-The visibility for dllexport defintions \[-fvisibility-from-dllstorageclass\]
+The visibility for dllexport definitions \[-fvisibility-from-dllstorageclass\]
 
 .. option:: -fvisibility-externs-dllimport=
 
@@ -2519,7 +2519,7 @@ The visibility for external declarations without an 
explicit DLL dllstorageclass
 
 .. option:: -fvisibility-from-dllstorageclass, 
-fno-visibility-from-dllstorageclass
 
-Set the visiblity of symbols in the generated code from their DLL storage class
+Set the visibility of symbols in the generated code from their DLL storage 
class
 
 .. option:: -fvisibility-global-new-delete-hidden
 

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 6284fde4d52df..7ae775c2e00ba 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -1006,7 +1006,7 @@ def fuse_cuid_EQ : Joined<["-"], "fuse-cuid=">,
"offloading languages CUDA and HIP: 'hash' (ID's generated by 
hashing "
"file path and command line options) | 'random' (ID's generated as "
"random numbers) | 'none' (disabled). Default is 'hash'. This 
option "
-   "will be overriden by option '-cuid=[ID]' if it is specified." >;
+   "will be overridden by option '-cuid=[ID]' if it is specified." >;
 def libomptarget_amdgcn_bc_path_EQ : Joined<["--"], 
"libomptarget-amdgcn-bc-path=">, Group,
   HelpText<"Path to libomptarget-amdgcn bitcode library">;
 def libomptarget_nvptx_bc_path_EQ : Joined<["--"], 
"libomptarget-nvptx-bc-path=">, Group,
@@ -2693,10 +2693,10 @@ def fverbose_asm : Flag<["-"], "fverbose-asm">, 
Group,
 def dA : Flag<["-"], "dA">, Alias;
 defm visibility_from_dllstorageclass : 
BoolFOption<"visibility-from-dllstorageclass",
   LangOpts<"VisibilityFromDLLStorageClass">, DefaultFalse,
-  PosFlag,
+  PosFlag,
   NegFlag>;
 def fvisibility_dllexport_EQ : Joined<["-"], "fvisibility-dllexport=">, 
Group, Flags<[CC1Option]>,
-  HelpText<"The visibility for dllexport defintions 
[-fvisibility-from-dllstorageclass]">,
+  HelpText<"The visibility for dllexport definitions 
[-fvisibility-from-dllstorageclass]">,
   MarshallingInfoVisibility, 
"DefaultVisibility">,
   ShouldParseIf;
 def fvisibility_nodllstorageclass_EQ : Joined<["-"], 
"fvisibility-nodllstorageclass=">, Group, Flags<[CC1Option]>,



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


[PATCH] D106815: Update: clang/test/Profile/gcc-flag-compatibility.c to have -flto on AIX

2021-07-29 Thread Mark Danial via Phabricator via cfe-commits
madanial updated this revision to Diff 362829.
madanial added a comment.

Adding comment in gcc-flag-compatibility.c indicating that testing for AIX is 
done in gcc-flag-compatibility-aix.c as suggested


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106815

Files:
  clang/test/Profile/gcc-flag-compatibility-aix.c
  clang/test/Profile/gcc-flag-compatibility.c


Index: clang/test/Profile/gcc-flag-compatibility.c
===
--- clang/test/Profile/gcc-flag-compatibility.c
+++ clang/test/Profile/gcc-flag-compatibility.c
@@ -7,6 +7,8 @@
 // -fprofile-use=Uses the profile file /default.profdata
 // -fprofile-use=/file   Uses the profile file /file
 
+// On AIX, -flto is required with -fprofile-generate. 
gcc-flag-compatibility-aix.c is used to do the testing on AIX with -flto
+// XFAIL: aix
 // RUN: %clang %s -c -S -o - -emit-llvm -fprofile-generate 
-fno-experimental-new-pass-manager | FileCheck -check-prefix=PROFILE-GEN %s
 // RUN: %clang %s -c -S -o - -emit-llvm -fprofile-generate 
-fexperimental-new-pass-manager | FileCheck -check-prefix=PROFILE-GEN %s
 // PROFILE-GEN: @__profc_main = {{(private|internal)}} global [2 x i64] 
zeroinitializer, section
Index: clang/test/Profile/gcc-flag-compatibility-aix.c
===
--- /dev/null
+++ clang/test/Profile/gcc-flag-compatibility-aix.c
@@ -0,0 +1,68 @@
+// Tests for -fprofile-generate and -fprofile-use flag compatibility. These two
+// flags behave similarly to their GCC counterparts:
+//
+// -fprofile-generate Generates the profile file ./default.profraw
+// -fprofile-generate=   Generates the profile file /default.profraw
+// -fprofile-use  Uses the profile file ./default.profdata
+// -fprofile-use=Uses the profile file /default.profdata
+// -fprofile-use=/file   Uses the profile file /file
+
+// On AIX, -flto is required with -fprofile-generate
+
+// RUN: %clang %s -c -S -o - -emit-llvm -target powerpc64-unknown-aix -flto 
-fprofile-generate -fno-experimental-new-pass-manager | FileCheck 
-check-prefix=PROFILE-GEN %s
+// RUN: %clang %s -c -S -o - -emit-llvm -target powerpc64-unknown-aix -flto 
-fprofile-generate -fexperimental-new-pass-manager | FileCheck 
-check-prefix=PROFILE-GEN %s
+// PROFILE-GEN: @__profc_main = {{(private|internal)}} global [2 x i64] 
zeroinitializer, section
+// PROFILE-GEN: @__profd_main =
+
+// Check that -fprofile-generate=/path/to generates /path/to/default.profraw
+// RUN: %clang %s -c -S -o - -emit-llvm -target powerpc64-unknown-aix -flto 
-fprofile-generate=/path/to -fno-experimental-new-pass-manager | FileCheck 
-check-prefixes=PROFILE-GEN,PROFILE-GEN-EQ %s
+// RxUN: %clang %s -c -S -o - -emit-llvm -target powerpc64-unknown-aix -flto 
-fprofile-generate=/path/to -fexperimental-new-pass-manager | FileCheck 
-check-prefixes=PROFILE-GEN,PROFILE-GEN-EQ %s
+// PROFILE-GEN-EQ: constant [{{.*}} x i8] c"/path/to{{/|}}{{.*}}\00"
+
+// Check that -fprofile-use=some/path reads some/path/default.profdata
+// This uses Clang FE format profile.
+// RUN: rm -rf %t.dir
+// RUN: mkdir -p %t.dir/some/path
+// RUN: llvm-profdata merge %S/Inputs/gcc-flag-compatibility.proftext -o 
%t.dir/some/path/default.profdata
+// RUN: %clang %s -o - -Xclang -disable-llvm-passes -emit-llvm -S 
-fprofile-use=%t.dir/some/path -fno-experimental-new-pass-manager | FileCheck 
-check-prefix=PROFILE-USE %s
+// RUN: %clang %s -o - -Xclang -disable-llvm-passes -emit-llvm -S 
-fprofile-use=%t.dir/some/path -fexperimental-new-pass-manager | FileCheck 
-check-prefix=PROFILE-USE %s
+
+// Check that -fprofile-use=some/path/file.prof reads some/path/file.prof
+// This uses Clang FE format profile.
+// RUN: rm -rf %t.dir
+// RUN: mkdir -p %t.dir/some/path
+// RUN: llvm-profdata merge %S/Inputs/gcc-flag-compatibility.proftext -o 
%t.dir/some/path/file.prof
+// RUN: %clang %s -o - -Xclang -disable-llvm-passes -emit-llvm -S 
-fprofile-use=%t.dir/some/path/file.prof -fno-experimental-new-pass-manager | 
FileCheck -check-prefix=PROFILE-USE %s
+// RUN: %clang %s -o - -Xclang -disable-llvm-passes -emit-llvm -S 
-fprofile-use=%t.dir/some/path/file.prof -fexperimental-new-pass-manager | 
FileCheck -check-prefix=PROFILE-USE %s
+// PROFILE-USE: = !{!"branch_weights", i32 101, i32 2}
+
+// Check that -fprofile-use=some/path reads some/path/default.profdata
+// This uses LLVM IR format profile.
+// RUN: rm -rf %t.dir
+// RUN: mkdir -p %t.dir/some/path
+// RUN: llvm-profdata merge %S/Inputs/gcc-flag-compatibility_IR.proftext -o 
%t.dir/some/path/default.profdata
+// RUN: %clang %s -o - -emit-llvm -S -fprofile-use=%t.dir/some/path 
-fno-experimental-new-pass-manager | FileCheck -check-prefix=PROFILE-USE-IR %s
+// RUN: %clang %s -o - -emit-llvm -S -fprofile-use=%t.dir/some/path 
-fexperimental-new-pass-manager | FileCheck -check-prefix=PROFILE-USE-IR %s
+

[PATCH] D106891: [AMDGPU] [Remarks] Emit optimization remarks when an FP atomic instruction is converted into a CAS loop or unsafe hardware instruction for GFX90A

2021-07-29 Thread Anshil Gandhi via Phabricator via cfe-commits
gandhi21299 added a comment.

ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106891

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


[PATCH] D106688: [AIX] Pass the -b option to linker on AIX

2021-07-29 Thread Anjan Kumar via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG109954410c34: [AIX] Pass the -b option to linker on AIX 
(authored by anjankgk).

Changed prior to commit:
  https://reviews.llvm.org/D106688?vs=362622=362828#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106688

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/test/Driver/Xlinker-args.c


Index: clang/test/Driver/Xlinker-args.c
===
--- clang/test/Driver/Xlinker-args.c
+++ clang/test/Driver/Xlinker-args.c
@@ -11,10 +11,20 @@
 // RUN:   -e _start -T a.lds -Xlinker one -Xlinker --no-demangle \
 // RUN:   -Wl,two,--no-demangle,three -Xlinker four -z five -r %s 2> %t
 // RUN: FileCheck -check-prefix=LINUX < %t %s
-//
+
+// RUN: %clang -target powerpc-unknown-aix -### \
+// RUN:   -b one %s 2> %t
+// RUN: FileCheck -check-prefix=AIX < %t %s
+
+// RUN: %clang -target powerpc-unknown-linux -### \
+// RUN:   -b one %s 2> %t
+// RUN: FileCheck -check-prefix=NOT-AIX < %t %s
+
 // DARWIN-NOT: --no-demangle
 // DARWIN: "one" "two" "three" "four" "-z" "five" "-r"
 // LINUX: "--no-demangle" "-e" "_start" "one" "two" "three" "four" "-z" "five" 
"-r" {{.*}} "-T" "a.lds"
+// AIX: "-b" "one" 
+// NOT-AIX: error: unsupported option '-b one'
 
 // Check that we forward '-Xlinker' and '-Wl,' on Windows.
 // RUN: %clang -target i686-pc-win32 -fuse-ld=link -### \
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -257,6 +257,16 @@
 // Otherwise, this is a linker input argument.
 const Arg  = II.getInputArg();
 
+if (A.getOption().matches(options::OPT_b)) {
+  const llvm::Triple  = TC.getTriple();
+  if (!T.isOSAIX()) {
+TC.getDriver().Diag(diag::err_drv_unsupported_opt_for_target)
+<< A.getAsString(Args);
+  }
+  // Pass -b prefix for AIX linker.
+  A.claim();
+  A.render(Args, CmdArgs);
+}
 // Handle reserved library options.
 if (A.getOption().matches(options::OPT_Z_reserved_lib_stdcxx))
   TC.AddCXXStdlibLibArgs(Args, CmdArgs);
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -815,7 +815,9 @@
 def bind__at__load : Flag<["-"], "bind_at_load">;
 def bundle__loader : Separate<["-"], "bundle_loader">;
 def bundle : Flag<["-"], "bundle">;
-def b : JoinedOrSeparate<["-"], "b">, Flags<[Unsupported]>;
+def b : JoinedOrSeparate<["-"], "b">, Flags<[LinkerInput, RenderAsInput]>,
+  HelpText<"Pass -b  to the linker on AIX (only).">, MetaVarName<"">,
+  Group;
 def cl_opt_disable : Flag<["-"], "cl-opt-disable">, Group, 
Flags<[CC1Option]>,
   HelpText<"OpenCL only. This option disables all optimizations. By default 
optimizations are enabled.">;
 def cl_strict_aliasing : Flag<["-"], "cl-strict-aliasing">, 
Group, Flags<[CC1Option]>,


Index: clang/test/Driver/Xlinker-args.c
===
--- clang/test/Driver/Xlinker-args.c
+++ clang/test/Driver/Xlinker-args.c
@@ -11,10 +11,20 @@
 // RUN:   -e _start -T a.lds -Xlinker one -Xlinker --no-demangle \
 // RUN:   -Wl,two,--no-demangle,three -Xlinker four -z five -r %s 2> %t
 // RUN: FileCheck -check-prefix=LINUX < %t %s
-//
+
+// RUN: %clang -target powerpc-unknown-aix -### \
+// RUN:   -b one %s 2> %t
+// RUN: FileCheck -check-prefix=AIX < %t %s
+
+// RUN: %clang -target powerpc-unknown-linux -### \
+// RUN:   -b one %s 2> %t
+// RUN: FileCheck -check-prefix=NOT-AIX < %t %s
+
 // DARWIN-NOT: --no-demangle
 // DARWIN: "one" "two" "three" "four" "-z" "five" "-r"
 // LINUX: "--no-demangle" "-e" "_start" "one" "two" "three" "four" "-z" "five" "-r" {{.*}} "-T" "a.lds"
+// AIX: "-b" "one" 
+// NOT-AIX: error: unsupported option '-b one'
 
 // Check that we forward '-Xlinker' and '-Wl,' on Windows.
 // RUN: %clang -target i686-pc-win32 -fuse-ld=link -### \
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -257,6 +257,16 @@
 // Otherwise, this is a linker input argument.
 const Arg  = II.getInputArg();
 
+if (A.getOption().matches(options::OPT_b)) {
+  const llvm::Triple  = TC.getTriple();
+  if (!T.isOSAIX()) {
+TC.getDriver().Diag(diag::err_drv_unsupported_opt_for_target)
+<< A.getAsString(Args);
+  }
+  // Pass -b prefix for AIX linker.
+  A.claim();
+  A.render(Args, CmdArgs);
+}
 // Handle 

[clang] 1099544 - [AIX] Pass the -b option to linker on AIX

2021-07-29 Thread Anjan Kumar via cfe-commits

Author: Anjan Kumar
Date: 2021-07-29T18:14:41Z
New Revision: 109954410c34434a181f5eb48cbd14f4122101c7

URL: 
https://github.com/llvm/llvm-project/commit/109954410c34434a181f5eb48cbd14f4122101c7
DIFF: 
https://github.com/llvm/llvm-project/commit/109954410c34434a181f5eb48cbd14f4122101c7.diff

LOG: [AIX] Pass the -b option to linker on AIX

Parse the -b option in the driver and pass it to the linker if the target OS is 
AIX. This will establish compatibility with the other AIX compilers.

Reviewed By: Zarko Todorovski

Differential Revision: https://reviews.llvm.org/D106688

Added: 


Modified: 
clang/include/clang/Driver/Options.td
clang/lib/Driver/ToolChains/CommonArgs.cpp
clang/test/Driver/Xlinker-args.c

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 4efb4786f9083..6284fde4d52df 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -815,7 +815,9 @@ def autocomplete : Joined<["--"], "autocomplete=">;
 def bind__at__load : Flag<["-"], "bind_at_load">;
 def bundle__loader : Separate<["-"], "bundle_loader">;
 def bundle : Flag<["-"], "bundle">;
-def b : JoinedOrSeparate<["-"], "b">, Flags<[Unsupported]>;
+def b : JoinedOrSeparate<["-"], "b">, Flags<[LinkerInput, RenderAsInput]>,
+  HelpText<"Pass -b  to the linker on AIX (only).">, MetaVarName<"">,
+  Group;
 def cl_opt_disable : Flag<["-"], "cl-opt-disable">, Group, 
Flags<[CC1Option]>,
   HelpText<"OpenCL only. This option disables all optimizations. By default 
optimizations are enabled.">;
 def cl_strict_aliasing : Flag<["-"], "cl-strict-aliasing">, 
Group, Flags<[CC1Option]>,

diff  --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp 
b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index d9a6599a24160..5905b241aa510 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -257,6 +257,16 @@ void tools::AddLinkerInputs(const ToolChain , const 
InputInfoList ,
 // Otherwise, this is a linker input argument.
 const Arg  = II.getInputArg();
 
+if (A.getOption().matches(options::OPT_b)) {
+  const llvm::Triple  = TC.getTriple();
+  if (!T.isOSAIX()) {
+TC.getDriver().Diag(diag::err_drv_unsupported_opt_for_target)
+<< A.getAsString(Args);
+  }
+  // Pass -b prefix for AIX linker.
+  A.claim();
+  A.render(Args, CmdArgs);
+}
 // Handle reserved library options.
 if (A.getOption().matches(options::OPT_Z_reserved_lib_stdcxx))
   TC.AddCXXStdlibLibArgs(Args, CmdArgs);

diff  --git a/clang/test/Driver/Xlinker-args.c 
b/clang/test/Driver/Xlinker-args.c
index cb045a1d40ac1..5eff8a0748ff9 100644
--- a/clang/test/Driver/Xlinker-args.c
+++ b/clang/test/Driver/Xlinker-args.c
@@ -11,10 +11,20 @@
 // RUN:   -e _start -T a.lds -Xlinker one -Xlinker --no-demangle \
 // RUN:   -Wl,two,--no-demangle,three -Xlinker four -z five -r %s 2> %t
 // RUN: FileCheck -check-prefix=LINUX < %t %s
-//
+
+// RUN: %clang -target powerpc-unknown-aix -### \
+// RUN:   -b one %s 2> %t
+// RUN: FileCheck -check-prefix=AIX < %t %s
+
+// RUN: %clang -target powerpc-unknown-linux -### \
+// RUN:   -b one %s 2> %t
+// RUN: FileCheck -check-prefix=NOT-AIX < %t %s
+
 // DARWIN-NOT: --no-demangle
 // DARWIN: "one" "two" "three" "four" "-z" "five" "-r"
 // LINUX: "--no-demangle" "-e" "_start" "one" "two" "three" "four" "-z" "five" 
"-r" {{.*}} "-T" "a.lds"
+// AIX: "-b" "one" 
+// NOT-AIX: error: unsupported option '-b one'
 
 // Check that we forward '-Xlinker' and '-Wl,' on Windows.
 // RUN: %clang -target i686-pc-win32 -fuse-ld=link -### \



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


[PATCH] D102343: [clang][patch][FPEnv] Make Initialization of C++ globals strictfp aware

2021-07-29 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: clang/lib/Sema/SemaExpr.cpp:19531
+SC_None, S.getCurFPFeatures().isFPConstrained(),
+false /*isInlineSpecified*/, FD->hasPrototype(),
 /*ConstexprKind*/ ConstexprSpecKind::Unspecified);

canonical form is `/*XXX=*/YYY`



Comment at: clang/test/CodeGen/fp-floatcontrol-stack.cpp:226
+float y();
+// CHECK-DDEFAULT Function Attrs: noinline nounwind optnone mustprogress
+// CHECK-DEBSTRICT Function Attrs: noinline nounwind optnone strictfp 
mustprogress

Missing colon



Comment at: clang/test/CodeGen/fp-floatcontrol-stack.cpp:249
 #pragma float_control(except, off)
+// CHECK-DDEFAULT Function Attrs: noinline nounwind optnone
+// CHECK-DEBSTRICT Function Attrs: noinline nounwind optnone

Missing colon?



Comment at: clang/test/CodeGen/fp-floatcontrol-stack.cpp:282
+
+// CHECK-DDEFAULT Function Attrs: noinline nounwind
+// CHECK-DEBSTRICT Function Attrs: noinline nounwind strictfp

You need `{{$}}` to check there is no `strictfp` at the end.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102343

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


[PATCH] D106733: [clang/darwin] Pass libclang_rt.profile last on linker command

2021-07-29 Thread Vedant Kumar via Phabricator via cfe-commits
vsk added a comment.

@thakis thanks for doing this, lgtm as well.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106733

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


[PATCH] D104904: [OpenMP][AMDGCN] Initial math headers support

2021-07-29 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield reopened this revision.
JonChesterfield added a comment.
This revision is now accepted and ready to land.

Landing ocml side first seems reasonable as it's less likely to be broken and 
makes testing this more straightforward


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104904

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


[clang] f8819c1 - Fixing broken docs build

2021-07-29 Thread Chris Bieneman via cfe-commits

Author: Chris Bieneman
Date: 2021-07-29T12:45:56-05:00
New Revision: f8819c109e4afcad19407ceb54e28ef77e1c57e9

URL: 
https://github.com/llvm/llvm-project/commit/f8819c109e4afcad19407ceb54e28ef77e1c57e9
DIFF: 
https://github.com/llvm/llvm-project/commit/f8819c109e4afcad19407ceb54e28ef77e1c57e9.diff

LOG: Fixing broken docs build

Need an empty line after the code-block directive.

Added: 


Modified: 
clang/docs/LanguageExtensions.rst

Removed: 




diff  --git a/clang/docs/LanguageExtensions.rst 
b/clang/docs/LanguageExtensions.rst
index 8dafcb2f9a724..aaee136530fef 100644
--- a/clang/docs/LanguageExtensions.rst
+++ b/clang/docs/LanguageExtensions.rst
@@ -3894,6 +3894,7 @@ Clang supports the pragma ``#pragma clang deprecated``, 
which can be used to
 provide deprecation warnings for macro uses. For example:
 
 .. code-block:: c
+
#define MIN(x, y) x < y ? x : y
#pragma clang deprecated(MIN, "use std::min instead")
 



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


[clang] 26c695b - Support macro deprecation #pragma clang deprecated

2021-07-29 Thread Chris Bieneman via cfe-commits

Author: Chris Bieneman
Date: 2021-07-29T12:40:53-05:00
New Revision: 26c695b7893071d5e69afbaa70c4850ab2e468be

URL: 
https://github.com/llvm/llvm-project/commit/26c695b7893071d5e69afbaa70c4850ab2e468be
DIFF: 
https://github.com/llvm/llvm-project/commit/26c695b7893071d5e69afbaa70c4850ab2e468be.diff

LOG: Support macro deprecation #pragma clang deprecated

This patch adds `#pragma clang deprecated` to enable deprecation of
preprocessor macros.

The macro must be defined before `#pragma clang deprecated`. When
deprecating a macro a custom message may be optionally provided.

Warnings are emitted at the use site of a deprecated macro, and can be
controlled via the `-Wdeprecated` warning group.

This patch takes some rough inspiration and a few lines of code from
https://reviews.llvm.org/D67935.

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D106732

Added: 
clang/test/Lexer/deprecate-macro.c

Modified: 
clang/docs/LanguageExtensions.rst
clang/include/clang/Basic/DiagnosticGroups.td
clang/include/clang/Basic/DiagnosticLexKinds.td
clang/include/clang/Basic/IdentifierTable.h
clang/include/clang/Lex/Preprocessor.h
clang/lib/Lex/PPDirectives.cpp
clang/lib/Lex/PPExpressions.cpp
clang/lib/Lex/PPMacroExpansion.cpp
clang/lib/Lex/Pragma.cpp
clang/lib/Lex/Preprocessor.cpp

Removed: 




diff  --git a/clang/docs/LanguageExtensions.rst 
b/clang/docs/LanguageExtensions.rst
index 462aa89ea789a..8dafcb2f9a724 100644
--- a/clang/docs/LanguageExtensions.rst
+++ b/clang/docs/LanguageExtensions.rst
@@ -3887,6 +3887,24 @@ Since the size of ``buffer`` can't be known at compile 
time, Clang will fold
 as ``__builtin_dynamic_object_size(buffer, 0)``, Clang will fold it into
 ``size``, providing some extra runtime safety.
 
+Deprecating Macros
+==
+
+Clang supports the pragma ``#pragma clang deprecated``, which can be used to
+provide deprecation warnings for macro uses. For example:
+
+.. code-block:: c
+   #define MIN(x, y) x < y ? x : y
+   #pragma clang deprecated(MIN, "use std::min instead")
+
+   void min(int a, int b) {
+ return MIN(a, b); // warning: MIN is deprecated: use std::min instead
+   }
+
+``#pragma clang deprecated`` should be preferred for this purpose over
+``#pragma GCC warning`` because the warning can be controlled with
+``-Wdeprecated``.
+
 Extended Integer Types
 ==
 

diff  --git a/clang/include/clang/Basic/DiagnosticGroups.td 
b/clang/include/clang/Basic/DiagnosticGroups.td
index 4b4928a7a00e6..6857c889b72b6 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -184,6 +184,7 @@ def DeprecatedThisCapture : 
DiagGroup<"deprecated-this-capture">;
 def DeprecatedVolatile : DiagGroup<"deprecated-volatile">;
 def DeprecatedWritableStr : DiagGroup<"deprecated-writable-strings",
   [CXX11CompatDeprecatedWritableStr]>;
+def DeprecatedPragma : DiagGroup<"deprecated-pragma">;
 // FIXME: Why is DeprecatedImplementations not in this group?
 def Deprecated : DiagGroup<"deprecated", [DeprecatedAnonEnumEnumConversion,
   DeprecatedArrayCompare,
@@ -198,6 +199,7 @@ def Deprecated : DiagGroup<"deprecated", 
[DeprecatedAnonEnumEnumConversion,
   DeprecatedEnumEnumConversion,
   DeprecatedEnumFloatConversion,
   DeprecatedIncrementBool,
+  DeprecatedPragma,
   DeprecatedRegister,
   DeprecatedThisCapture,
   DeprecatedVolatile,

diff  --git a/clang/include/clang/Basic/DiagnosticLexKinds.td 
b/clang/include/clang/Basic/DiagnosticLexKinds.td
index ce6d0d0394b48..174f6c3dfd4c6 100644
--- a/clang/include/clang/Basic/DiagnosticLexKinds.td
+++ b/clang/include/clang/Basic/DiagnosticLexKinds.td
@@ -519,6 +519,11 @@ def warn_pragma_warning_expected_number :
   ExtWarn<"#pragma warning expected a warning number">,
   InGroup;
 
+// - #pragma deprecated(...)
+def warn_pragma_deprecated_macro_use :
+  ExtWarn<"macro %0 has been marked as deprecated%select{|: %2}1">,
+  InGroup;
+
 // - #pragma execution_character_set(...)
 def warn_pragma_exec_charset_expected :
   ExtWarn<"#pragma execution_character_set expected '%0'">,

diff  --git a/clang/include/clang/Basic/IdentifierTable.h 
b/clang/include/clang/Basic/IdentifierTable.h
index f2379c7ddfbd1..d75d43f0398d7 100644
--- a/clang/include/clang/Basic/IdentifierTable.h
+++ b/clang/include/clang/Basic/IdentifierTable.h
@@ -121,7 +121,10 @@ class alignas(IdentifierInfoAlignment) IdentifierInfo {
   // True if this is a mangled OpenMP variant name.
   unsigned IsMangledOpenMPVariantName : 1;

[PATCH] D106732: Support macro deprecation #pragma clang deprecated

2021-07-29 Thread Chris Bieneman via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG26c695b78930: Support macro deprecation #pragma clang 
deprecated (authored by beanz).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106732

Files:
  clang/docs/LanguageExtensions.rst
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticLexKinds.td
  clang/include/clang/Basic/IdentifierTable.h
  clang/include/clang/Lex/Preprocessor.h
  clang/lib/Lex/PPDirectives.cpp
  clang/lib/Lex/PPExpressions.cpp
  clang/lib/Lex/PPMacroExpansion.cpp
  clang/lib/Lex/Pragma.cpp
  clang/lib/Lex/Preprocessor.cpp
  clang/test/Lexer/deprecate-macro.c

Index: clang/test/Lexer/deprecate-macro.c
===
--- /dev/null
+++ clang/test/Lexer/deprecate-macro.c
@@ -0,0 +1,98 @@
+// RUN: %clang_cc1 -Wdeprecated %s -fsyntax-only -verify
+
+// expected-error@+1{{expected (}}
+#pragma clang deprecated
+
+// expected-error@+1{{expected identifier}}
+#pragma clang deprecated(4
+
+// expected-error@+1{{no macro named foo}}
+#pragma clang deprecated(foo)
+
+#define bar 1
+#pragma clang deprecated(bar, "bar is deprecated use 1")
+
+// expected-warning@+1{{macro 'bar' has been marked as deprecated: bar is deprecated use 1}}
+#if bar
+#endif
+
+#define foo 1
+#pragma clang deprecated(foo)
+
+// expected-error@+1{{expected )}}
+#pragma clang deprecated(foo
+
+// expected-warning@+1{{macro 'foo' has been marked as deprecated}}
+#if foo
+#endif
+
+// expected-warning@+1{{macro 'foo' has been marked as deprecated}}
+#if defined(foo)
+#endif
+
+// expected-warning@+1{{macro 'foo' has been marked as deprecated}}
+#ifdef foo
+#endif
+
+// expected-warning@+1{{macro 'foo' has been marked as deprecated}}
+#ifndef foo
+#endif
+
+int main(int argc, char** argv) {
+  // expected-error@+1{{no macro named main}}
+#pragma clang deprecated(main)
+
+  // expected-warning@+1{{macro 'foo' has been marked as deprecated}}
+  return foo;
+}
+
+#define frobble 1
+#pragma clang deprecated(frobble)
+
+// not-expected-warning@+1{{macro 'frobble' has been marked as deprecated}}
+#undef frobble // Expect no diagnostics here
+
+// not-expected-warning@+1{{macro 'frobble' has been marked as deprecated}}
+#define frobble 1 // How about here given that this was undefined?
+
+// not-expected-warning@+1{{macro 'frobble' has been marked as deprecated}}
+#if defined(frobble)
+#endif
+
+// Test that we diagnose on #elif.
+#if 0
+#elif foo
+// expected-warning@-1{{macro 'foo' has been marked as deprecated}}
+#endif
+
+
+// Test that we diagnose on #elifdef.
+#ifdef baz
+#elifdef foo
+// expected-warning@-1{{macro 'foo' has been marked as deprecated}}
+#endif
+
+// Test that we diagnose on #elifndef.
+#ifdef baz
+#elifndef foo
+#endif
+// expected-warning@-2{{macro 'foo' has been marked as deprecated}}
+
+// FIXME: These cases are currently not handled because clang doesn't expand
+// conditions on skipped #elif* blocks. See the FIXME notes in
+// Preprocessor::SkipExcludedConditionalBlock.
+
+#ifdef frobble
+// not-expected-warning@+1{{macro 'foo' has been marked as deprecated}}
+#elifndef foo
+#endif
+
+#ifdef frobble
+// not-expected-warning@+1{{macro 'foo' has been marked as deprecated}}
+#elifdef foo
+#endif
+
+#if 1
+// not-expected-warning@+1{{macro 'foo' has been marked as deprecated}}
+#elif foo
+#endif
Index: clang/lib/Lex/Preprocessor.cpp
===
--- clang/lib/Lex/Preprocessor.cpp
+++ clang/lib/Lex/Preprocessor.cpp
@@ -1413,6 +1413,18 @@
   return true;
 }
 
+void Preprocessor::emitMacroExpansionWarnings(const Token ) {
+  if (Identifier.getIdentifierInfo()->isDeprecatedMacro()) {
+auto DepMsg = getMacroDeprecationMsg(Identifier.getIdentifierInfo());
+if (!DepMsg)
+  Diag(Identifier, diag::warn_pragma_deprecated_macro_use)
+  << Identifier.getIdentifierInfo() << 0;
+else
+  Diag(Identifier, diag::warn_pragma_deprecated_macro_use)
+  << Identifier.getIdentifierInfo() << 1 << *DepMsg;
+  }
+}
+
 ModuleLoader::~ModuleLoader() = default;
 
 CommentHandler::~CommentHandler() = default;
Index: clang/lib/Lex/Pragma.cpp
===
--- clang/lib/Lex/Pragma.cpp
+++ clang/lib/Lex/Pragma.cpp
@@ -1911,6 +1911,57 @@
   }
 };
 
+/// "\#pragma clang deprecated(...)"
+///
+/// The syntax is
+/// \code
+///   #pragma clang deprecate(MACRO_NAME [, Message])
+/// \endcode
+struct PragmaDeprecatedHandler : public PragmaHandler {
+  PragmaDeprecatedHandler() : PragmaHandler("deprecated") {}
+
+  void HandlePragma(Preprocessor , PragmaIntroducer Introducer,
+Token ) override {
+std::string Macro, MessageString;
+
+PP.Lex(Tok);
+if (Tok.isNot(tok::l_paren)) {
+  PP.Diag(Tok, diag::err_expected) << "(";
+  return;
+}
+
+

[PATCH] D102343: [clang][patch][FPEnv] Make Initialization of C++ globals strictfp aware

2021-07-29 Thread Melanie Blower via Phabricator via cfe-commits
mibintc added a comment.

@MaskRay Thanks a lot -- yes!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102343

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


[PATCH] D106732: Support macro deprecation #pragma clang deprecated

2021-07-29 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM, thank you! I am excited to start using this shortly. :-)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106732

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


[PATCH] D106898: Revert "Revert "[clang][pp] adds '#pragma include_instead'""

2021-07-29 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D106898#2913951 , @cjdb wrote:

> fixes up formatting and testing
>
> Will merge post-CI. @aaron.ballman do you approve this to be cherry-picked 
> into LLVM 13? (cc @tstellar)

Thanks for checking! I do approve it -- it was intended to make it before the 
branch point from the previous review.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106898

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


[PATCH] D106899: [Support] Remove LLVM_ATTRIBUTE_NORETURN

2021-07-29 Thread Alf via Phabricator via cfe-commits
gAlfonso-bit added a comment.

Ok thanks


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106899

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


[PATCH] D106899: [Support] Remove LLVM_ATTRIBUTE_NORETURN

2021-07-29 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

In D106899#2913925 , @gAlfonso-bit 
wrote:

> Still not passing (what is going on?)

If you click a harbomaster URI, sometimes the builds are good

  x64 debian passed
  x64 windows passed

and sometimes there may be failures apparently unrelated to your patch.
Some discretion is needed.

I ended up making the refactoring by myself. Your change included some 
whole-file clang-format formatting which wasn't suitable.
I usually run `git diff -U0 --no-color 'HEAD^' | 
clang/tools/clang-format/clang-format-diff.py -i -p1` to only format related 
lines.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106899

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


[PATCH] D106899: [LLVM][NFC] Replace LLVM_ATTRIBUTE_NORETURN with [[noreturn]]

2021-07-29 Thread Fangrui Song via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG09529892b518: [Support] Remove LLVM_ATTRIBUTE_NORETURN 
(authored by gAlfonso-bit, committed by MaskRay).

Changed prior to commit:
  https://reviews.llvm.org/D106899?vs=362780=362815#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106899

Files:
  llvm/include/llvm/Support/Compiler.h


Index: llvm/include/llvm/Support/Compiler.h
===
--- llvm/include/llvm/Support/Compiler.h
+++ llvm/include/llvm/Support/Compiler.h
@@ -242,14 +242,6 @@
 #define LLVM_ATTRIBUTE_ALWAYS_INLINE inline
 #endif
 
-#ifdef __GNUC__
-#define LLVM_ATTRIBUTE_NORETURN __attribute__((noreturn))
-#elif defined(_MSC_VER)
-#define LLVM_ATTRIBUTE_NORETURN __declspec(noreturn)
-#else
-#define LLVM_ATTRIBUTE_NORETURN
-#endif
-
 #if __has_attribute(returns_nonnull) || LLVM_GNUC_PREREQ(4, 9, 0)
 #define LLVM_ATTRIBUTE_RETURNS_NONNULL __attribute__((returns_nonnull))
 #elif defined(_MSC_VER)


Index: llvm/include/llvm/Support/Compiler.h
===
--- llvm/include/llvm/Support/Compiler.h
+++ llvm/include/llvm/Support/Compiler.h
@@ -242,14 +242,6 @@
 #define LLVM_ATTRIBUTE_ALWAYS_INLINE inline
 #endif
 
-#ifdef __GNUC__
-#define LLVM_ATTRIBUTE_NORETURN __attribute__((noreturn))
-#elif defined(_MSC_VER)
-#define LLVM_ATTRIBUTE_NORETURN __declspec(noreturn)
-#else
-#define LLVM_ATTRIBUTE_NORETURN
-#endif
-
 #if __has_attribute(returns_nonnull) || LLVM_GNUC_PREREQ(4, 9, 0)
 #define LLVM_ATTRIBUTE_RETURNS_NONNULL __attribute__((returns_nonnull))
 #elif defined(_MSC_VER)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D105821: [analyzer] [WIP] Model destructor for std::unique_ptr

2021-07-29 Thread Deep Majumder via Phabricator via cfe-commits
RedDocMD added a comment.

On running this patch on the `projects` directory, a bunch of projects emit 
false-positives: mostly of the form `Potential memory leak`. This points to the 
fact that without calling the destructor of the pointee type, we are going to 
have a lot of false positives (408 for //one// project is the worst I have 
seen). I have attached the result file.F18215302: destructor1.txt 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105821

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


[PATCH] D107078: [analyzer] Catch leaking stack addresses via stack variables

2021-07-29 Thread Balázs Benics via Phabricator via cfe-commits
steakhal requested review of this revision.
steakhal added inline comments.



Comment at: clang/lib/StaticAnalyzer/Checkers/StackAddrEscapeChecker.cpp:397-399
+  Report->addNote("The temporary object gets destroyed at the end of the "
+  "full expression",
+  L);

steakhal wrote:
> I'm actually not sure about this. We the `genName()` returns the appropriate 
> `SourceRange` for `CXXTempObject`s, which will be added to the bug report 
> regardless. That might be enough. I'm going to check that.
> 
`getName()` operates on the `Referred` memregion, although I'm highlighting the 
`Referrer` memregion. So, the note is not redundant.


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

https://reviews.llvm.org/D107078

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


[PATCH] D102343: [clang][patch][FPEnv] Make Initialization of C++ globals strictfp aware

2021-07-29 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

If you upload a diff via "Upload Diff" on webUI or `arc diff 'HEAD^'`, by 
default the subject/summary are not updated.

After editing your local commit message, please update the review as well to be 
synchronized.

The patch changed the signature of `FunctionDecl::Create`. When changing 
clang/include/clang headers, it's a good idea to test `check-lldb 
check-clang-tools` (`-DLLVM_ENABLE_PROJECTS='...;clang-tools-extra;lldb'` in 
case clang-tools-extra/ and lldb/ have code needing updates.
In this case there was an lldb build failure I just fixed. I assume that 
passing false (`/*UsesFPIntrin=*/false`) is safe.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102343

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


[PATCH] D106891: [AMDGPU] [Remarks] Emit optimization remarks when an FP atomic instruction is converted into a CAS loop or unsafe hardware instruction for GFX90A

2021-07-29 Thread Anshil Gandhi via Phabricator via cfe-commits
gandhi21299 updated this revision to Diff 362807.
gandhi21299 added a comment.

applied clang-format


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106891

Files:
  clang/test/CodeGenCUDA/fp-atomics-optremarks.cu
  clang/test/CodeGenOpenCL/fp-atomics-optremarks-gfx90a.cl
  llvm/lib/Target/AMDGPU/SIISelLowering.cpp
  llvm/lib/Target/AMDGPU/SIISelLowering.h

Index: llvm/lib/Target/AMDGPU/SIISelLowering.h
===
--- llvm/lib/Target/AMDGPU/SIISelLowering.h
+++ llvm/lib/Target/AMDGPU/SIISelLowering.h
@@ -30,6 +30,7 @@
 class SITargetLowering final : public AMDGPUTargetLowering {
 private:
   const GCNSubtarget *Subtarget;
+  OptimizationRemarkEmitter *ORE;
 
 public:
   MVT getRegisterTypeForCallingConv(LLVMContext ,
Index: llvm/lib/Target/AMDGPU/SIISelLowering.cpp
===
--- llvm/lib/Target/AMDGPU/SIISelLowering.cpp
+++ llvm/lib/Target/AMDGPU/SIISelLowering.cpp
@@ -19,6 +19,7 @@
 #include "SIRegisterInfo.h"
 #include "llvm/ADT/Statistic.h"
 #include "llvm/Analysis/LegacyDivergenceAnalysis.h"
+#include "llvm/Analysis/OptimizationRemarkEmitter.h"
 #include "llvm/BinaryFormat/ELF.h"
 #include "llvm/CodeGen/Analysis.h"
 #include "llvm/CodeGen/FunctionLoweringInfo.h"
@@ -12079,6 +12080,27 @@
   return DenormMode == DenormalMode::getIEEE();
 }
 
+static TargetLowering::AtomicExpansionKind
+atomicExpandReturn(OptimizationRemarkEmitter *ORE, AtomicRMWInst *RMW,
+   TargetLowering::AtomicExpansionKind Kind, bool UnsafeFlag) {
+  ORE = new OptimizationRemarkEmitter(RMW->getFunction());
+  if (Kind == TargetLowering::AtomicExpansionKind::CmpXChg) {
+ORE->emit([&]() {
+  OptimizationRemark Remark(DEBUG_TYPE, "Passed", RMW->getFunction());
+  Remark << "An FP atomic instruction was expanded into a CAS loop.";
+  return Remark;
+});
+  } else if (Kind == TargetLowering::AtomicExpansionKind::None && UnsafeFlag) {
+ORE->emit([&]() {
+  OptimizationRemark Remark(DEBUG_TYPE, "Passed", RMW->getFunction());
+  Remark << "An unsafe hardware instruction was generated.";
+  return Remark;
+});
+  }
+  delete ORE;
+  return Kind;
+}
+
 TargetLowering::AtomicExpansionKind
 SITargetLowering::shouldExpandAtomicRMWInIR(AtomicRMWInst *RMW) const {
   switch (RMW->getOperation()) {
@@ -12094,35 +12116,43 @@
   return AtomicExpansionKind::CmpXChg;
 
 unsigned AS = RMW->getPointerAddressSpace();
-
+bool UnsafeFPAtomicFlag = RMW->getFunction()
+  ->getFnAttribute("amdgpu-unsafe-fp-atomics")
+  .getValueAsBool();
 if ((AS == AMDGPUAS::GLOBAL_ADDRESS || AS == AMDGPUAS::FLAT_ADDRESS) &&
  Subtarget->hasAtomicFaddInsts()) {
   // The amdgpu-unsafe-fp-atomics attribute enables generation of unsafe
   // floating point atomic instructions. May generate more efficient code,
   // but may not respect rounding and denormal modes, and may give incorrect
   // results for certain memory destinations.
-  if (RMW->getFunction()
-  ->getFnAttribute("amdgpu-unsafe-fp-atomics")
-  .getValueAsString() != "true")
-return AtomicExpansionKind::CmpXChg;
+  if (!UnsafeFPAtomicFlag)
+return atomicExpandReturn(ORE, RMW, AtomicExpansionKind::CmpXChg,
+  UnsafeFPAtomicFlag);
+  atomicExpandReturn(ORE, RMW, AtomicExpansionKind::None,
+ UnsafeFPAtomicFlag);
 
   if (Subtarget->hasGFX90AInsts()) {
 if (Ty->isFloatTy() && AS == AMDGPUAS::FLAT_ADDRESS)
-  return AtomicExpansionKind::CmpXChg;
+  return atomicExpandReturn(ORE, RMW, AtomicExpansionKind::CmpXChg,
+UnsafeFPAtomicFlag);
 
 auto SSID = RMW->getSyncScopeID();
 if (SSID == SyncScope::System ||
 SSID == RMW->getContext().getOrInsertSyncScopeID("one-as"))
-  return AtomicExpansionKind::CmpXChg;
+  return atomicExpandReturn(ORE, RMW, AtomicExpansionKind::CmpXChg,
+UnsafeFPAtomicFlag);
 
-return AtomicExpansionKind::None;
+return atomicExpandReturn(ORE, RMW, AtomicExpansionKind::None,
+  UnsafeFPAtomicFlag);
   }
 
   if (AS == AMDGPUAS::FLAT_ADDRESS)
-return AtomicExpansionKind::CmpXChg;
+return atomicExpandReturn(ORE, RMW, AtomicExpansionKind::CmpXChg,
+  UnsafeFPAtomicFlag);
 
-  return RMW->use_empty() ? AtomicExpansionKind::None
-  : AtomicExpansionKind::CmpXChg;
+  auto Kind = RMW->use_empty() ? AtomicExpansionKind::None
+   : AtomicExpansionKind::CmpXChg;
+  return atomicExpandReturn(ORE, RMW, Kind, UnsafeFPAtomicFlag);
 }
 
 

[PATCH] D106909: [clang] Add clang builtins support for gfx90a

2021-07-29 Thread Anshil Gandhi via Phabricator via cfe-commits
gandhi21299 updated this revision to Diff 362804.
gandhi21299 added a comment.

fixed tests by replacing checks for the functions with generic-qualified 
arguments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106909

Files:
  clang/include/clang/Basic/BuiltinsAMDGPU.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGenOpenCL/builtins-fp-atomics.cl

Index: clang/test/CodeGenOpenCL/builtins-fp-atomics.cl
===
--- /dev/null
+++ clang/test/CodeGenOpenCL/builtins-fp-atomics.cl
@@ -0,0 +1,131 @@
+// RUN: %clang_cc1 -cl-std=CL2.0 -triple amdgcn-amd-amdhsa -target-cpu gfx90a \
+// RUN:   %s -S -emit-llvm -o - | FileCheck %s -check-prefix=CHECK
+
+// RUN: %clang_cc1 -cl-std=CL2.0 -triple amdgcn-amd-amdhsa -target-cpu gfx90a \
+// RUN:   -S -o - %s | FileCheck -check-prefix=GFX90A %s
+
+
+typedef enum memory_order {
+  memory_order_relaxed = __ATOMIC_RELAXED,
+  memory_order_acquire = __ATOMIC_ACQUIRE,
+  memory_order_release = __ATOMIC_RELEASE,
+  memory_order_acq_rel = __ATOMIC_ACQ_REL,
+  memory_order_seq_cst = __ATOMIC_SEQ_CST
+} memory_order;
+
+typedef half __attribute__((ext_vector_type(2))) half2;
+
+// CHECK-LABEL: test_global_add
+// CHECK: tail call double @llvm.amdgcn.global.atomic.fadd.f64.p1f64.f64(double addrspace(1)* %{{.*}}, double %{{.*}})
+// GFX90A:  test_global_add
+// GFX90A:  global_atomic_add_f64 v2, v[0:1], s[0:1]
+// GFX90A:  s_endpgm
+kernel void test_global_add(__global double *addr, double x) {
+  __builtin_amdgcn_global_atomic_fadd_f64(addr, x, memory_order_relaxed);
+}
+
+// CHECK-LABEL: test_global_addf
+// CHECK: tail call float @llvm.amdgcn.global.atomic.fadd.f32.p1f32.f32(float addrspace(1)* %{{.*}}, float %{{.*}})
+// GFX90A-LABEL: test_global_addf
+// GFX90A: global_atomic_add_f32 v0, v1, s[0:1]
+// GFX90A: s_endpgm
+kernel void test_global_addf(__global float *addr, float x) {
+  __builtin_amdgcn_global_atomic_fadd_f32(addr, x, memory_order_relaxed);
+}
+
+// CHECK-LABEL: test_global_add2h
+// CHECK: tail call <2 x half> @llvm.amdgcn.global.atomic.fadd.v2f16.p1v2f16.v2f16(<2 x half> addrspace(1)* %{{.*}}, <2 x half> %{{.*}})
+// GFX90A-LABEL: test_global_add2h
+// GFX90A: global_atomic_pk_add_f16 v0, v1, s[0:1]
+// GFX90A: s_endpgm
+kernel void test_global_add2h(__global half2 *addr, half2 x){
+  __builtin_amdgcn_global_atomic_fadd_2f16(addr, x, memory_order_relaxed);
+}
+
+// CHECK-LABEL: test_global_global_min
+// CHECK: tail call double @llvm.amdgcn.global.atomic.fmin.f64.p1f64.f64(double addrspace(1)* %{{.*}}, double %{{.*}})
+// GFX90A-LABEL:  test_global_global_min
+// GFX90A:  global_atomic_min_f64 v2, v[0:1], s[0:1]
+// GFX90A:  s_endpgm
+kernel void test_global_global_min(__global double *addr, double x){
+  __builtin_amdgcn_global_atomic_fmin_f64(addr, x, memory_order_relaxed);
+}
+
+// CHECK-LABEL: test_global_max
+// CHECK: tail call double @llvm.amdgcn.global.atomic.fmax.f64.p1f64.f64(double addrspace(1)* %{{.*}}, double %{{.*}})
+// GFX90A:  test_global_max
+// GFX90A:  global_atomic_max_f64 v2, v[0:1], s[0:1]
+// GFX90A:  s_endpgm
+kernel void test_global_max(__global double *addr, double x){
+  __builtin_amdgcn_global_atomic_fmax_f64(addr, x, memory_order_relaxed);
+}
+
+// CHECK-LABEL: test_flat_add_local
+// CHECK: tail call double @llvm.amdgcn.flat.atomic.fadd.f64.p3f64.f64(double addrspace(3)* %{{.*}}, double %{{.*}})
+// GFX90A:  test_flat_add_local
+// GFX90A:  ds_add_f64 v2, v[0:1]
+// GFX90A:  s_endpgm
+kernel void test_flat_add_local(__local double *addr, double x){
+  __builtin_amdgcn_flat_atomic_fadd_f64(addr, x, memory_order_relaxed);
+}
+
+// CHECK-LABEL: test_flat_global_add
+// CHECK: tail call double @llvm.amdgcn.flat.atomic.fadd.f64.p1f64.f64(double addrspace(1)* %{{.*}}, double %{{.*}})
+// GFX90A:  test_flat_global_add
+// GFX90A:  global_atomic_add_f64
+// GFX90A:  s_endpgm
+kernel void test_flat_global_add(__global double *addr, double x){
+  __builtin_amdgcn_flat_atomic_fadd_f64(addr, x, memory_order_relaxed);
+}
+
+// CHECK-LABEL: test_flat_min_constant
+// CHECK: tail call double @llvm.amdgcn.flat.atomic.fmin.f64.p0f64.f64(double* %{{.*}}, double %{{.*}})
+// GFX90A-LABEL:  test_flat_min_constant
+// GFX90A:  flat_atomic_min_f64
+void test_flat_min_constant(__generic double *addr, double x){
+  __builtin_amdgcn_flat_atomic_fmin_f64(addr, x, memory_order_relaxed);
+}
+
+// CHECK-LABEL: test_flat_global_min
+// CHECK: tail call double @llvm.amdgcn.flat.atomic.fmin.f64.p1f64.f64(double addrspace(1)* %{{.*}}, double %{{.*}})
+// GFX90A:  test_flat_global_min
+// GFX90A:  global_atomic_min_f64
+// GFX90A:  s_endpgm
+kernel void test_flat_global_min(__global double *addr, double x){
+  __builtin_amdgcn_flat_atomic_fmin_f64(addr, x, memory_order_relaxed);
+}
+
+// CHECK-LABEL: test_flat_max_constant
+// CHECK: tail call double @llvm.amdgcn.flat.atomic.fmax.f64.p0f64.f64(double* %{{.*}}, 

[PATCH] D106899: [LLVM][NFC] Replace LLVM_ATTRIBUTE_NORETURN with [[noreturn]]

2021-07-29 Thread Alf via Phabricator via cfe-commits
gAlfonso-bit added a comment.

Still not passing (what is going on?)


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

https://reviews.llvm.org/D106899

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


[clang-tools-extra] 72a8367 - Replace LLVM_ATTRIBUTE_NORETURN with C++11 [[noreturn]]. NFC

2021-07-29 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2021-07-29T09:59:45-07:00
New Revision: 72a83674dd3a13b59442cd7cb07b53902f7d6a33

URL: 
https://github.com/llvm/llvm-project/commit/72a83674dd3a13b59442cd7cb07b53902f7d6a33
DIFF: 
https://github.com/llvm/llvm-project/commit/72a83674dd3a13b59442cd7cb07b53902f7d6a33.diff

LOG: Replace LLVM_ATTRIBUTE_NORETURN with C++11 [[noreturn]]. NFC

[[noreturn]] can be used since Oct 2016 when the minimum compiler requirement 
was bumped to GCC 4.8/MSVC 2015.

Added: 


Modified: 
clang-tools-extra/pp-trace/PPTrace.cpp
clang/utils/TableGen/ClangDiagnosticsEmitter.cpp
flang/include/flang/Optimizer/Support/FatalError.h
lldb/source/Host/posix/ProcessLauncherPosixFork.cpp
lldb/source/Plugins/Process/Linux/SingleStepCheck.cpp

Removed: 




diff  --git a/clang-tools-extra/pp-trace/PPTrace.cpp 
b/clang-tools-extra/pp-trace/PPTrace.cpp
index 3fa16498fbefc..0b078c49a55b7 100644
--- a/clang-tools-extra/pp-trace/PPTrace.cpp
+++ b/clang-tools-extra/pp-trace/PPTrace.cpp
@@ -69,7 +69,7 @@ static cl::opt OutputFileName(
 cl::desc("Output trace to the given file name or '-' for stdout."),
 cl::cat(Cat));
 
-LLVM_ATTRIBUTE_NORETURN static void error(Twine Message) {
+[[noreturn]] static void error(Twine Message) {
   WithColor::error() << Message << '\n';
   exit(1);
 }

diff  --git a/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp 
b/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp
index 014c1adcd8092..ad4bb8d78ced3 100644
--- a/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp
+++ b/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp
@@ -614,7 +614,7 @@ struct DiagnosticTextBuilder {
 return It->second.Root;
   }
 
-  LLVM_ATTRIBUTE_NORETURN void PrintFatalError(llvm::Twine const ) const {
+  [[noreturn]] void PrintFatalError(llvm::Twine const ) const {
 assert(EvaluatingRecord && "not evaluating a record?");
 llvm::PrintFatalError(EvaluatingRecord->getLoc(), Msg);
   }

diff  --git a/flang/include/flang/Optimizer/Support/FatalError.h 
b/flang/include/flang/Optimizer/Support/FatalError.h
index 602045346587c..8450b16a5baf4 100644
--- a/flang/include/flang/Optimizer/Support/FatalError.h
+++ b/flang/include/flang/Optimizer/Support/FatalError.h
@@ -20,8 +20,8 @@ namespace fir {
 
 /// Fatal error reporting helper. Report a fatal error with a source location
 /// and immediately abort flang.
-LLVM_ATTRIBUTE_NORETURN inline void emitFatalError(mlir::Location loc,
-   const llvm::Twine ) 
{
+[[noreturn]] inline void emitFatalError(mlir::Location loc,
+const llvm::Twine ) {
   mlir::emitError(loc, message);
   llvm::report_fatal_error("aborting");
 }

diff  --git a/lldb/source/Host/posix/ProcessLauncherPosixFork.cpp 
b/lldb/source/Host/posix/ProcessLauncherPosixFork.cpp
index 25dcf1e592c57..b49b541927afe 100644
--- a/lldb/source/Host/posix/ProcessLauncherPosixFork.cpp
+++ b/lldb/source/Host/posix/ProcessLauncherPosixFork.cpp
@@ -46,8 +46,8 @@ static void FixupEnvironment(Environment ) {
 #endif
 }
 
-static void LLVM_ATTRIBUTE_NORETURN ExitWithError(int error_fd,
-  const char *operation) {
+[[noreturn]] static void ExitWithError(int error_fd,
+   const char *operation) {
   int err = errno;
   llvm::raw_fd_ostream os(error_fd, true);
   os << operation << " failed: " << llvm::sys::StrError(err);
@@ -88,8 +88,8 @@ static void DupDescriptor(int error_fd, const FileSpec 
_spec, int fd,
   return;
 }
 
-static void LLVM_ATTRIBUTE_NORETURN ChildFunc(int error_fd,
-  const ProcessLaunchInfo ) {
+[[noreturn]] static void ChildFunc(int error_fd,
+   const ProcessLaunchInfo ) {
   if (info.GetFlags().Test(eLaunchFlagLaunchInSeparateProcessGroup)) {
 if (setpgid(0, 0) != 0)
   ExitWithError(error_fd, "setpgid");

diff  --git a/lldb/source/Plugins/Process/Linux/SingleStepCheck.cpp 
b/lldb/source/Plugins/Process/Linux/SingleStepCheck.cpp
index 5b337f1974ea5..5f8057d2fef63 100644
--- a/lldb/source/Plugins/Process/Linux/SingleStepCheck.cpp
+++ b/lldb/source/Plugins/Process/Linux/SingleStepCheck.cpp
@@ -29,7 +29,7 @@ using namespace lldb_private::process_linux;
 #if defined(__arm64__) || defined(__aarch64__)
 namespace {
 
-void LLVM_ATTRIBUTE_NORETURN Child() {
+[[noreturn]] void Child() {
   if (ptrace(PTRACE_TRACEME, 0, nullptr, nullptr) == -1)
 _exit(1);
 



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


[clang] 72a8367 - Replace LLVM_ATTRIBUTE_NORETURN with C++11 [[noreturn]]. NFC

2021-07-29 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2021-07-29T09:59:45-07:00
New Revision: 72a83674dd3a13b59442cd7cb07b53902f7d6a33

URL: 
https://github.com/llvm/llvm-project/commit/72a83674dd3a13b59442cd7cb07b53902f7d6a33
DIFF: 
https://github.com/llvm/llvm-project/commit/72a83674dd3a13b59442cd7cb07b53902f7d6a33.diff

LOG: Replace LLVM_ATTRIBUTE_NORETURN with C++11 [[noreturn]]. NFC

[[noreturn]] can be used since Oct 2016 when the minimum compiler requirement 
was bumped to GCC 4.8/MSVC 2015.

Added: 


Modified: 
clang-tools-extra/pp-trace/PPTrace.cpp
clang/utils/TableGen/ClangDiagnosticsEmitter.cpp
flang/include/flang/Optimizer/Support/FatalError.h
lldb/source/Host/posix/ProcessLauncherPosixFork.cpp
lldb/source/Plugins/Process/Linux/SingleStepCheck.cpp

Removed: 




diff  --git a/clang-tools-extra/pp-trace/PPTrace.cpp 
b/clang-tools-extra/pp-trace/PPTrace.cpp
index 3fa16498fbefc..0b078c49a55b7 100644
--- a/clang-tools-extra/pp-trace/PPTrace.cpp
+++ b/clang-tools-extra/pp-trace/PPTrace.cpp
@@ -69,7 +69,7 @@ static cl::opt OutputFileName(
 cl::desc("Output trace to the given file name or '-' for stdout."),
 cl::cat(Cat));
 
-LLVM_ATTRIBUTE_NORETURN static void error(Twine Message) {
+[[noreturn]] static void error(Twine Message) {
   WithColor::error() << Message << '\n';
   exit(1);
 }

diff  --git a/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp 
b/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp
index 014c1adcd8092..ad4bb8d78ced3 100644
--- a/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp
+++ b/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp
@@ -614,7 +614,7 @@ struct DiagnosticTextBuilder {
 return It->second.Root;
   }
 
-  LLVM_ATTRIBUTE_NORETURN void PrintFatalError(llvm::Twine const ) const {
+  [[noreturn]] void PrintFatalError(llvm::Twine const ) const {
 assert(EvaluatingRecord && "not evaluating a record?");
 llvm::PrintFatalError(EvaluatingRecord->getLoc(), Msg);
   }

diff  --git a/flang/include/flang/Optimizer/Support/FatalError.h 
b/flang/include/flang/Optimizer/Support/FatalError.h
index 602045346587c..8450b16a5baf4 100644
--- a/flang/include/flang/Optimizer/Support/FatalError.h
+++ b/flang/include/flang/Optimizer/Support/FatalError.h
@@ -20,8 +20,8 @@ namespace fir {
 
 /// Fatal error reporting helper. Report a fatal error with a source location
 /// and immediately abort flang.
-LLVM_ATTRIBUTE_NORETURN inline void emitFatalError(mlir::Location loc,
-   const llvm::Twine ) 
{
+[[noreturn]] inline void emitFatalError(mlir::Location loc,
+const llvm::Twine ) {
   mlir::emitError(loc, message);
   llvm::report_fatal_error("aborting");
 }

diff  --git a/lldb/source/Host/posix/ProcessLauncherPosixFork.cpp 
b/lldb/source/Host/posix/ProcessLauncherPosixFork.cpp
index 25dcf1e592c57..b49b541927afe 100644
--- a/lldb/source/Host/posix/ProcessLauncherPosixFork.cpp
+++ b/lldb/source/Host/posix/ProcessLauncherPosixFork.cpp
@@ -46,8 +46,8 @@ static void FixupEnvironment(Environment ) {
 #endif
 }
 
-static void LLVM_ATTRIBUTE_NORETURN ExitWithError(int error_fd,
-  const char *operation) {
+[[noreturn]] static void ExitWithError(int error_fd,
+   const char *operation) {
   int err = errno;
   llvm::raw_fd_ostream os(error_fd, true);
   os << operation << " failed: " << llvm::sys::StrError(err);
@@ -88,8 +88,8 @@ static void DupDescriptor(int error_fd, const FileSpec 
_spec, int fd,
   return;
 }
 
-static void LLVM_ATTRIBUTE_NORETURN ChildFunc(int error_fd,
-  const ProcessLaunchInfo ) {
+[[noreturn]] static void ChildFunc(int error_fd,
+   const ProcessLaunchInfo ) {
   if (info.GetFlags().Test(eLaunchFlagLaunchInSeparateProcessGroup)) {
 if (setpgid(0, 0) != 0)
   ExitWithError(error_fd, "setpgid");

diff  --git a/lldb/source/Plugins/Process/Linux/SingleStepCheck.cpp 
b/lldb/source/Plugins/Process/Linux/SingleStepCheck.cpp
index 5b337f1974ea5..5f8057d2fef63 100644
--- a/lldb/source/Plugins/Process/Linux/SingleStepCheck.cpp
+++ b/lldb/source/Plugins/Process/Linux/SingleStepCheck.cpp
@@ -29,7 +29,7 @@ using namespace lldb_private::process_linux;
 #if defined(__arm64__) || defined(__aarch64__)
 namespace {
 
-void LLVM_ATTRIBUTE_NORETURN Child() {
+[[noreturn]] void Child() {
   if (ptrace(PTRACE_TRACEME, 0, nullptr, nullptr) == -1)
 _exit(1);
 



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


[PATCH] D106854: Pass `--start-group` and `--end-group` to the linker when using the AVR toolchain

2021-07-29 Thread Matt Jacobson via Phabricator via cfe-commits
mhjacobson added a comment.

Thanks, Ben.  Yes, would you mind to land the patch for me?  Name and e-mail are

Matt Jacobson 

And yes, please do change the title as appropriate.  I wasn't sure what the 
proper naming convention was.

Thanks again!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106854

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


[clang] fd251d9 - [clang][patch] Remove erroneous run line committed in D102343

2021-07-29 Thread Melanie Blower via cfe-commits

Author: Melanie Blower
Date: 2021-07-29T12:42:04-04:00
New Revision: fd251d903b9b1bc8305736fc78764521cd86f8d3

URL: 
https://github.com/llvm/llvm-project/commit/fd251d903b9b1bc8305736fc78764521cd86f8d3
DIFF: 
https://github.com/llvm/llvm-project/commit/fd251d903b9b1bc8305736fc78764521cd86f8d3.diff

LOG: [clang][patch] Remove erroneous run line committed in D102343

Added: 


Modified: 
clang/test/CodeGen/fp-floatcontrol-class.cpp

Removed: 




diff  --git a/clang/test/CodeGen/fp-floatcontrol-class.cpp 
b/clang/test/CodeGen/fp-floatcontrol-class.cpp
index 8c2e60c2a9c3..83a27cb206eb 100644
--- a/clang/test/CodeGen/fp-floatcontrol-class.cpp
+++ b/clang/test/CodeGen/fp-floatcontrol-class.cpp
@@ -1,4 +1,3 @@
-// RUN: %clang_cc1 -ffp-contract=on -triple %itanium_abi_triple -emit-llvm -o 
- %s | FileCheck %s
 // RUN: %clang_cc1 -ffp-contract=on -triple x86_64-linux-gnu -emit-llvm -o - 
%s | FileCheck %s
 // Verify that float_control does not pertain to initializer expressions
 



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


[PATCH] D104904: [OpenMP][AMDGCN] Initial math headers support

2021-07-29 Thread Ethan Stewart via Phabricator via cfe-commits
estewart08 added a comment.

In D104904#2913983 , @ye-luo wrote:

> how to get this moving?

We are working on some additions to this patch. The lit failure noted above has 
been fixed locally. I would expect an update here very soon.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104904

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


[PATCH] D107078: [analyzer] Catch leaking stack addresses via stack variables

2021-07-29 Thread Balázs Benics via Phabricator via cfe-commits
steakhal planned changes to this revision.
steakhal marked an inline comment as done.
steakhal added a comment.

I'm going to check how the notes look like on real code.




Comment at: clang/lib/StaticAnalyzer/Checkers/StackAddrEscapeChecker.cpp:397-399
+  Report->addNote("The temporary object gets destroyed at the end of the "
+  "full expression",
+  L);

I'm actually not sure about this. We the `genName()` returns the appropriate 
`SourceRange` for `CXXTempObject`s, which will be added to the bug report 
regardless. That might be enough. I'm going to check that.




Comment at: clang/test/Analysis/copy-elision.cpp:400-419
+struct Foo {
+  Foo(Foo **q) {
+*q = this;
+  }
+};
+
+Foo make1(Foo **r) {

I'm going to move this somewhere else.
Probably outside of the namespace `address_vector_tests` to the end of this 
file.



Comment at: clang/test/Analysis/copy-elision.cpp:195
+  // expected-warning@-1 {{Address of stack memory associated with local \
+variable 'c' is still referred to by the stack variable 'v' upon returning \
+to the caller}}

martong wrote:
> It would be useful to have a test with `// RUN:   -analyzer-output=text \` to 
> make sure that we have a note placed for `v` at `consume(make3(v))`. Do we 
> have such a note? This could be done perhaps in another test file.
I could do that, but we should consider the size of the test file.
The notes will duplicate each `expected-warning` and add even more besides 
those.

Should I add them to this file or to another test file covering the same?
If we decide to have that I think it would be valuable to do that in a 
follow-up patch IMO.
The size of this is already hitting the limit.


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

https://reviews.llvm.org/D107078

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


[PATCH] D104904: [OpenMP][AMDGCN] Initial math headers support

2021-07-29 Thread Ye Luo via Phabricator via cfe-commits
ye-luo added a comment.

how to get this moving?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104904

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


[PATCH] D106792: [clang-tidy] Always open files using UTF-8 encoding

2021-07-29 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev requested changes to this revision.
kbobyrev added a comment.
This revision now requires changes to proceed.

It's certainly doable but looks like a complete overkill for this kind of 
problem :) The patch is fine, I'm okay with landing it if you're expecting 
similar problem to arise in the future, I'll accept with the comment next to 
the first usage, everything else is OK.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106792

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


[PATCH] D106939: [RISCV] If the maskedoff is vundefined(), use ta, ma for vsetvli.

2021-07-29 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: llvm/test/CodeGen/RISCV/rvv/maskedoff-undef.ll:3
+; RUN: llc -mtriple=riscv64 -mattr=+experimental-v -verify-machineinstrs \
+; RUN:   --riscv-no-aliases < %s | FileCheck %s
+

frasercrmck wrote:
> I don't think we're typically using `--riscv-no-aliases` in our CodeGen tests?
We were at one point using that on rvv tests, but I think it's been removed now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106939

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


[PATCH] D106898: Revert "Revert "[clang][pp] adds '#pragma include_instead'""

2021-07-29 Thread Christopher Di Bella via Phabricator via cfe-commits
cjdb added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticLexKinds.td:307
+def err_pragma_include_instead_system_reserved : Error<
+  "header '%0' is an implementation detail; #include %select{'%2'|either '%2' 
or '%3'|one of %2}1 instead">;
+

aaron.ballman wrote:
> 80-col wrapping.
Surprised this made it past the first time.



Comment at: clang/test/PCH/ms-pch-macro-include_instead-regression.c:2
+// Enabling MS extensions should allow us to add BAR definitions.
+// RUN: %clang_cc1 -DMSEXT -fms-extensions -DBAZ=\"Inputs/pch-through1.h\" 
-emit-pch -o %t1.pch
+// RUN: %clang_cc1 -DMSEXT -fms-extensions -include-pch %t1.pch -verify %s

aaron.ballman wrote:
> This fixes the shell issue when I try it out locally on Windows.
Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106898

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


[PATCH] D106898: Revert "Revert "[clang][pp] adds '#pragma include_instead'""

2021-07-29 Thread Christopher Di Bella via Phabricator via cfe-commits
cjdb updated this revision to Diff 362806.
cjdb marked an inline comment as done.
cjdb added a subscriber: tstellar.
cjdb added a comment.

fixes up formatting and testing

Will merge post-CI. @aaron.ballman do you approve this to be cherry-picked into 
LLVM 13? (cc @tstellar)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106898

Files:
  clang/include/clang/Basic/DiagnosticLexKinds.td
  clang/include/clang/Lex/HeaderSearch.h
  clang/include/clang/Lex/Preprocessor.h
  clang/include/clang/Lex/PreprocessorLexer.h
  clang/lib/Lex/Lexer.cpp
  clang/lib/Lex/PPDirectives.cpp
  clang/lib/Lex/PPLexerChange.cpp
  clang/lib/Lex/Pragma.cpp
  clang/test/PCH/ms-pch-macro-include_instead-regression.c
  clang/test/Preprocessor/Inputs/include_instead/bad-syntax.h
  clang/test/Preprocessor/Inputs/include_instead/file-not-found.h
  clang/test/Preprocessor/Inputs/include_instead/non-system-header.h
  clang/test/Preprocessor/Inputs/include_instead/private-x.h
  clang/test/Preprocessor/Inputs/include_instead/private1.h
  clang/test/Preprocessor/Inputs/include_instead/private2.h
  clang/test/Preprocessor/Inputs/include_instead/private3.h
  clang/test/Preprocessor/Inputs/include_instead/public-after.h
  clang/test/Preprocessor/Inputs/include_instead/public-before.h
  clang/test/Preprocessor/Inputs/include_instead/public-empty.h
  clang/test/Preprocessor/include_instead.cpp
  clang/test/Preprocessor/include_instead_file_not_found.cpp

Index: clang/test/Preprocessor/include_instead_file_not_found.cpp
===
--- /dev/null
+++ clang/test/Preprocessor/include_instead_file_not_found.cpp
@@ -0,0 +1,2 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -I %S/Inputs %s
+#include 
Index: clang/test/Preprocessor/include_instead.cpp
===
--- /dev/null
+++ clang/test/Preprocessor/include_instead.cpp
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -I %S/Inputs %s
+
+#include 
+#include 
+
+#include 
+// expected-error@-1{{header '' is an implementation detail; #include '' instead}}
+
+#include "include_instead/private2.h"
+// expected-error@-1{{header '"include_instead/private2.h"' is an implementation detail; #include either '' or '"include_instead/public-after.h"' instead}}
+
+#include 
+// expected-error@-1{{header '' is an implementation detail; #include one of {'', '', '"include_instead/public-before.h"'} instead}}
+
+#include 
+#include 
Index: clang/test/Preprocessor/Inputs/include_instead/public-empty.h
===
--- /dev/null
+++ clang/test/Preprocessor/Inputs/include_instead/public-empty.h
@@ -0,0 +1 @@
+// This file simply needs to exist.
Index: clang/test/Preprocessor/Inputs/include_instead/public-before.h
===
--- /dev/null
+++ clang/test/Preprocessor/Inputs/include_instead/public-before.h
@@ -0,0 +1,5 @@
+#pragma GCC system_header
+
+#include  // no warning expected
+#include  // no warning expected
+#include  // no warning expected
Index: clang/test/Preprocessor/Inputs/include_instead/public-after.h
===
--- /dev/null
+++ clang/test/Preprocessor/Inputs/include_instead/public-after.h
@@ -0,0 +1,2 @@
+#include 
+#pragma GCC system_header
Index: clang/test/Preprocessor/Inputs/include_instead/private3.h
===
--- /dev/null
+++ clang/test/Preprocessor/Inputs/include_instead/private3.h
@@ -0,0 +1,5 @@
+#pragma GCC system_header
+
+#pragma clang include_instead()
+#pragma clang include_instead()
+#pragma clang include_instead("include_instead/public-before.h")
Index: clang/test/Preprocessor/Inputs/include_instead/private2.h
===
--- /dev/null
+++ clang/test/Preprocessor/Inputs/include_instead/private2.h
@@ -0,0 +1,4 @@
+#pragma GCC system_header
+
+#pragma clang include_instead()
+#pragma clang include_instead("include_instead/public-after.h")
Index: clang/test/Preprocessor/Inputs/include_instead/private1.h
===
--- /dev/null
+++ clang/test/Preprocessor/Inputs/include_instead/private1.h
@@ -0,0 +1,2 @@
+#pragma GCC system_header
+#pragma clang include_instead()
Index: clang/test/Preprocessor/Inputs/include_instead/private-x.h
===
--- /dev/null
+++ clang/test/Preprocessor/Inputs/include_instead/private-x.h
@@ -0,0 +1,4 @@
+#include 
+
+#pragma GCC system_header
+#pragma clang include_instead()
Index: clang/test/Preprocessor/Inputs/include_instead/non-system-header.h
===
--- /dev/null
+++ 

[PATCH] D106410: [PowerPC] Emit error for Altivec vector initializations when -faltivec-src-compat=gcc is specified

2021-07-29 Thread Amy Kwan via Phabricator via cfe-commits
amyk added a comment.

Ping.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106410

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


[PATCH] D106891: [AMDGPU] [Remarks] Emit optimization remarks when an FP atomic instruction is converted into a CAS loop or unsafe hardware instruction for GFX90A

2021-07-29 Thread Anshil Gandhi via Phabricator via cfe-commits
gandhi21299 updated this revision to Diff 362795.
gandhi21299 added a comment.

- refreshing patch


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106891

Files:
  clang/test/CodeGenCUDA/fp-atomics-optremarks.cu
  clang/test/CodeGenOpenCL/fp-atomics-optremarks-gfx90a.cl
  llvm/lib/Target/AMDGPU/SIISelLowering.cpp
  llvm/lib/Target/AMDGPU/SIISelLowering.h

Index: llvm/lib/Target/AMDGPU/SIISelLowering.h
===
--- llvm/lib/Target/AMDGPU/SIISelLowering.h
+++ llvm/lib/Target/AMDGPU/SIISelLowering.h
@@ -30,6 +30,7 @@
 class SITargetLowering final : public AMDGPUTargetLowering {
 private:
   const GCNSubtarget *Subtarget;
+  OptimizationRemarkEmitter *ORE;
 
 public:
   MVT getRegisterTypeForCallingConv(LLVMContext ,
Index: llvm/lib/Target/AMDGPU/SIISelLowering.cpp
===
--- llvm/lib/Target/AMDGPU/SIISelLowering.cpp
+++ llvm/lib/Target/AMDGPU/SIISelLowering.cpp
@@ -19,6 +19,7 @@
 #include "SIRegisterInfo.h"
 #include "llvm/ADT/Statistic.h"
 #include "llvm/Analysis/LegacyDivergenceAnalysis.h"
+#include "llvm/Analysis/OptimizationRemarkEmitter.h"
 #include "llvm/BinaryFormat/ELF.h"
 #include "llvm/CodeGen/Analysis.h"
 #include "llvm/CodeGen/FunctionLoweringInfo.h"
@@ -12079,6 +12080,27 @@
   return DenormMode == DenormalMode::getIEEE();
 }
 
+static TargetLowering::AtomicExpansionKind
+atomicExpandReturn(OptimizationRemarkEmitter *ORE, AtomicRMWInst *RMW,
+   TargetLowering::AtomicExpansionKind Kind, bool UnsafeFlag) {
+  ORE = new OptimizationRemarkEmitter(RMW->getFunction());
+  if (Kind == TargetLowering::AtomicExpansionKind::CmpXChg) {
+ORE->emit([&]() {
+  OptimizationRemark Remark(DEBUG_TYPE, "Passed", RMW->getFunction());
+  Remark << "An FP atomic instruction was expanded into a CAS loop.";
+  return Remark;
+});
+  } else if (Kind == TargetLowering::AtomicExpansionKind::None && UnsafeFlag) {
+ORE->emit([&]() {
+  OptimizationRemark Remark(DEBUG_TYPE, "Passed", RMW->getFunction());
+  Remark << "An unsafe hardware instruction was generated.";
+  return Remark;
+});
+  }
+  delete ORE;
+  return Kind;
+}
+
 TargetLowering::AtomicExpansionKind
 SITargetLowering::shouldExpandAtomicRMWInIR(AtomicRMWInst *RMW) const {
   switch (RMW->getOperation()) {
@@ -12094,35 +12116,43 @@
   return AtomicExpansionKind::CmpXChg;
 
 unsigned AS = RMW->getPointerAddressSpace();
-
+bool UnsafeFPAtomicFlag = RMW->getFunction()
+  ->getFnAttribute("amdgpu-unsafe-fp-atomics")
+  .getValueAsBool();
 if ((AS == AMDGPUAS::GLOBAL_ADDRESS || AS == AMDGPUAS::FLAT_ADDRESS) &&
  Subtarget->hasAtomicFaddInsts()) {
   // The amdgpu-unsafe-fp-atomics attribute enables generation of unsafe
   // floating point atomic instructions. May generate more efficient code,
   // but may not respect rounding and denormal modes, and may give incorrect
   // results for certain memory destinations.
-  if (RMW->getFunction()
-  ->getFnAttribute("amdgpu-unsafe-fp-atomics")
-  .getValueAsString() != "true")
-return AtomicExpansionKind::CmpXChg;
+  if (!UnsafeFPAtomicFlag)
+return atomicExpandReturn(ORE, RMW, AtomicExpansionKind::CmpXChg,
+  UnsafeFPAtomicFlag);
+  atomicExpandReturn(ORE, RMW, AtomicExpansionKind::None, 
+UnsafeFPAtomicFlag);
 
   if (Subtarget->hasGFX90AInsts()) {
 if (Ty->isFloatTy() && AS == AMDGPUAS::FLAT_ADDRESS)
-  return AtomicExpansionKind::CmpXChg;
+  return atomicExpandReturn(ORE, RMW, AtomicExpansionKind::CmpXChg,
+UnsafeFPAtomicFlag);
 
 auto SSID = RMW->getSyncScopeID();
 if (SSID == SyncScope::System ||
 SSID == RMW->getContext().getOrInsertSyncScopeID("one-as"))
-  return AtomicExpansionKind::CmpXChg;
+  return atomicExpandReturn(ORE, RMW, AtomicExpansionKind::CmpXChg,
+UnsafeFPAtomicFlag);
 
-return AtomicExpansionKind::None;
+return atomicExpandReturn(ORE, RMW, AtomicExpansionKind::None,
+  UnsafeFPAtomicFlag);
   }
 
   if (AS == AMDGPUAS::FLAT_ADDRESS)
-return AtomicExpansionKind::CmpXChg;
+return atomicExpandReturn(ORE, RMW, AtomicExpansionKind::CmpXChg,
+  UnsafeFPAtomicFlag);
 
-  return RMW->use_empty() ? AtomicExpansionKind::None
-  : AtomicExpansionKind::CmpXChg;
+  auto Kind = RMW->use_empty() ? AtomicExpansionKind::None
+   : AtomicExpansionKind::CmpXChg;
+  return atomicExpandReturn(ORE, RMW, Kind, UnsafeFPAtomicFlag);
 }
 
 // DS FP 

[PATCH] D102343: [clang][patch][FPEnv} Initialization of C++ globals not strictfp aware

2021-07-29 Thread Melanie Blower via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGbc5b5ea037db: [clang][patch][FPEnv] Make initialization of 
C++ globals strictfp aware (authored by mibintc).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102343

Files:
  clang/include/clang/AST/Decl.h
  clang/include/clang/AST/DeclCXX.h
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/Decl.cpp
  clang/lib/AST/DeclCXX.cpp
  clang/lib/CodeGen/CGObjC.cpp
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaLambda.cpp
  clang/lib/Sema/SemaLookup.cpp
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/test/CodeGen/fp-floatcontrol-class.cpp
  clang/test/CodeGen/fp-floatcontrol-stack.cpp
  clang/unittests/Sema/ExternalSemaSourceTest.cpp

Index: clang/unittests/Sema/ExternalSemaSourceTest.cpp
===
--- clang/unittests/Sema/ExternalSemaSourceTest.cpp
+++ clang/unittests/Sema/ExternalSemaSourceTest.cpp
@@ -163,7 +163,8 @@
   CurrentSema->getPreprocessor().getIdentifierInfo(CorrectTo);
   auto *NewFunction = FunctionDecl::Create(
   Context, DestContext, SourceLocation(), SourceLocation(), ToIdent,
-  Context.getFunctionType(Context.VoidTy, {}, {}), nullptr, SC_Static);
+  Context.getFunctionType(Context.VoidTy, {}, {}), nullptr, SC_Static,
+  /*UsesFPIntrin*/ false);
   DestContext->addDecl(NewFunction);
   TypoCorrection Correction(ToIdent);
   Correction.addCorrectionDecl(NewFunction);
Index: clang/test/CodeGen/fp-floatcontrol-stack.cpp
===
--- clang/test/CodeGen/fp-floatcontrol-stack.cpp
+++ clang/test/CodeGen/fp-floatcontrol-stack.cpp
@@ -6,6 +6,10 @@
 #define FUN(n) \
   (float z) { return n * z + n; }
 
+// CHECK-DDEFAULT Function Attrs: noinline nounwind optnone mustprogress
+// CHECK-DEBSTRICT Function Attrs: noinline nounwind optnone strictfp mustprogress
+// CHECK-FAST: Function Attrs: mustprogress noinline nounwind optnone
+// CHECK-NOHONOR Function Attrs: noinline nounwind optnone mustprogress
 float fun_default FUN(1)
 //CHECK-LABEL: define {{.*}} @_Z11fun_defaultf{{.*}}
 #if DEFAULT
@@ -28,6 +32,10 @@
 // Rule: precise must be enabled
 #pragma float_control(except, on)
 #endif
+// CHECK-FAST: Function Attrs: mustprogress noinline nounwind optnone
+// CHECK-DDEFAULT Function Attrs: noinline nounwind optnone strictfp mustprogress
+// CHECK-DEBSTRICT Function Attrs: noinline nounwind optnone strictfp mustprogress
+// CHECK-NOHONOR Function Attrs: noinline nounwind optnone strictfp mustprogress
 float exc_on FUN(2)
 //CHECK-LABEL: define {{.*}} @_Z6exc_onf{{.*}}
 #if DEFAULT
@@ -46,7 +54,11 @@
 #endif
 
 #pragma float_control(pop)
-float exc_pop FUN(5)
+// CHECK-DDEFAULT Function Attrs: noinline nounwind optnone mustprogress
+// CHECK-DEBSTRICT Function Attrs: noinline nounwind optnone strictfp mustprogress
+// CHECK-FAST: Function Attrs: mustprogress noinline nounwind optnone
+// CHECK-NOHONOR Function Attrs: noinline nounwind optnone mustprogress
+float exc_pop FUN(5)
 //CHECK-LABEL: define {{.*}} @_Z7exc_popf{{.*}}
 #if DEFAULT
 //CHECK-DDEFAULT: call float @llvm.fmuladd{{.*}}
@@ -63,7 +75,7 @@
 #endif
 
 #pragma float_control(except, off)
-float exc_off FUN(5)
+float exc_off FUN(5)
 //CHECK-LABEL: define {{.*}} @_Z7exc_offf{{.*}}
 #if DEFAULT
 //CHECK-DDEFAULT: call float @llvm.fmuladd{{.*}}
@@ -80,7 +92,7 @@
 #endif
 
 #pragma float_control(precise, on, push)
-float precise_on FUN(3)
+float precise_on FUN(3)
 //CHECK-LABEL: define {{.*}} @_Z10precise_onf{{.*}}
 #if DEFAULT
 //CHECK-DDEFAULT: float {{.*}}llvm.fmuladd{{.*}}
@@ -97,7 +109,7 @@
 #endif
 
 #pragma float_control(pop)
-float precise_pop FUN(3)
+float precise_pop FUN(3)
 //CHECK-LABEL: define {{.*}} @_Z11precise_popf{{.*}}
 #if DEFAULT
 //CHECK-DDEFAULT: float {{.*}}llvm.fmuladd{{.*}}
@@ -113,7 +125,7 @@
 //CHECK-FAST: fadd fast float
 #endif
 #pragma float_control(precise, off)
-float precise_off FUN(4)
+float precise_off FUN(4)
 //CHECK-LABEL: define {{.*}} @_Z11precise_offf{{.*}}
 #if DEFAULT
 // Note: precise_off enables fp_contract=fast and the instructions
@@ -137,7 +149,7 @@
 #endif
 
 #pragma float_control(precise, on)
-float precise_on2 FUN(3)
+float precise_on2 FUN(3)
 //CHECK-LABEL: define {{.*}} @_Z11precise_on2f{{.*}}
 #if DEFAULT
 //CHECK-DDEFAULT: 

[clang] bc5b5ea - [clang][patch][FPEnv] Make initialization of C++ globals strictfp aware

2021-07-29 Thread Melanie Blower via cfe-commits

Author: Melanie Blower
Date: 2021-07-29T12:02:37-04:00
New Revision: bc5b5ea037dbadd281c59248ae9d2742b51c69ed

URL: 
https://github.com/llvm/llvm-project/commit/bc5b5ea037dbadd281c59248ae9d2742b51c69ed
DIFF: 
https://github.com/llvm/llvm-project/commit/bc5b5ea037dbadd281c59248ae9d2742b51c69ed.diff

LOG: [clang][patch][FPEnv] Make initialization of C++ globals strictfp aware

@kpn pointed out that the global variable initialization functions didn't
have the "strictfp" metadata set correctly, and @rjmccall said that there
was buggy code in SetFPModel and StartFunction, this patch is to solve
those problems. When Sema creates a FunctionDecl, it sets the
FunctionDeclBits.UsesFPIntrin to "true" if the lexical FP settings
(i.e. a combination of command line options and #pragma float_control
settings) correspond to ConstrainedFP mode. That bit is used when CodeGen
starts codegen for a llvm function, and it translates into the
"strictfp" function attribute. See bugs.llvm.org/show_bug.cgi?id=44571

Reviewed By: Aaron Ballman

Differential Revision: https://reviews.llvm.org/D102343

Added: 


Modified: 
clang/include/clang/AST/Decl.h
clang/include/clang/AST/DeclCXX.h
clang/lib/AST/ASTImporter.cpp
clang/lib/AST/Decl.cpp
clang/lib/AST/DeclCXX.cpp
clang/lib/CodeGen/CGObjC.cpp
clang/lib/CodeGen/CGStmtOpenMP.cpp
clang/lib/CodeGen/CodeGenFunction.cpp
clang/lib/CodeGen/CodeGenFunction.h
clang/lib/Sema/SemaDecl.cpp
clang/lib/Sema/SemaDeclAttr.cpp
clang/lib/Sema/SemaDeclCXX.cpp
clang/lib/Sema/SemaExpr.cpp
clang/lib/Sema/SemaExprCXX.cpp
clang/lib/Sema/SemaLambda.cpp
clang/lib/Sema/SemaLookup.cpp
clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
clang/test/CodeGen/fp-floatcontrol-class.cpp
clang/test/CodeGen/fp-floatcontrol-stack.cpp
clang/unittests/Sema/ExternalSemaSourceTest.cpp

Removed: 




diff  --git a/clang/include/clang/AST/Decl.h b/clang/include/clang/AST/Decl.h
index 510bf89789851..30923a4fa05c9 100644
--- a/clang/include/clang/AST/Decl.h
+++ b/clang/include/clang/AST/Decl.h
@@ -1990,8 +1990,8 @@ class FunctionDecl : public DeclaratorDecl,
 protected:
   FunctionDecl(Kind DK, ASTContext , DeclContext *DC, SourceLocation 
StartLoc,
const DeclarationNameInfo , QualType T,
-   TypeSourceInfo *TInfo, StorageClass S, bool isInlineSpecified,
-   ConstexprSpecKind ConstexprKind,
+   TypeSourceInfo *TInfo, StorageClass S, bool UsesFPIntrin,
+   bool isInlineSpecified, ConstexprSpecKind ConstexprKind,
Expr *TrailingRequiresClause = nullptr);
 
   using redeclarable_base = Redeclarable;
@@ -2025,23 +2025,23 @@ class FunctionDecl : public DeclaratorDecl,
   static FunctionDecl *
   Create(ASTContext , DeclContext *DC, SourceLocation StartLoc,
  SourceLocation NLoc, DeclarationName N, QualType T,
- TypeSourceInfo *TInfo, StorageClass SC, bool isInlineSpecified = 
false,
- bool hasWrittenPrototype = true,
+ TypeSourceInfo *TInfo, StorageClass SC, bool UsesFPIntrin = false,
+ bool isInlineSpecified = false, bool hasWrittenPrototype = true,
  ConstexprSpecKind ConstexprKind = ConstexprSpecKind::Unspecified,
  Expr *TrailingRequiresClause = nullptr) {
 DeclarationNameInfo NameInfo(N, NLoc);
 return FunctionDecl::Create(C, DC, StartLoc, NameInfo, T, TInfo, SC,
-isInlineSpecified, hasWrittenPrototype,
-ConstexprKind, TrailingRequiresClause);
+UsesFPIntrin, isInlineSpecified,
+hasWrittenPrototype, ConstexprKind,
+TrailingRequiresClause);
   }
 
-  static FunctionDecl *Create(ASTContext , DeclContext *DC,
-  SourceLocation StartLoc,
-  const DeclarationNameInfo , QualType T,
-  TypeSourceInfo *TInfo, StorageClass SC,
-  bool isInlineSpecified, bool hasWrittenPrototype,
-  ConstexprSpecKind ConstexprKind,
-  Expr *TrailingRequiresClause);
+  static FunctionDecl *
+  Create(ASTContext , DeclContext *DC, SourceLocation StartLoc,
+ const DeclarationNameInfo , QualType T, TypeSourceInfo 
*TInfo,
+ StorageClass SC, bool UsesFPIntrin, bool isInlineSpecified,
+ bool hasWrittenPrototype, ConstexprSpecKind ConstexprKind,
+ Expr *TrailingRequiresClause);
 
   static FunctionDecl *CreateDeserialized(ASTContext , unsigned ID);
 
@@ -2594,6 +2594,14 @@ class FunctionDecl : public DeclaratorDecl,
 FunctionDeclBits.IsInline = I;
   }
 
+  /// Determine whether the function was declared in source context
+  /// that requires constrained FP intrinsics
+  bool UsesFPIntrin() const { return 

[PATCH] D107082: [X86][RFC] Enable `_Float16` type support on X86 following the psABI

2021-07-29 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

I haven't had a chance to look at this patch in detail, but I wanted to ask if 
you considered doing what ARM and RISCV do for this. They pass the f16 in the 
lower bits on an f32 by only changing the ABI handling code in the backend. The 
type legalizer takes care of the rest. That eems simpler than this patch. See 
for example https://reviews.llvm.org/D98670


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107082

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


[PATCH] D106860: [clang][AArch64][SVE] Avoid going through memory for fixed/scalable predicate casts

2021-07-29 Thread Bradley Smith via Phabricator via cfe-commits
bsmith added inline comments.



Comment at: clang/lib/CodeGen/CGExprScalar.cpp:2102
+  Src = Builder.CreateBitCast(Src, SrcTy);
+}
 if (ScalableSrc->getElementType() == FixedDst->getElementType()) {

junparser wrote:
> I think this may also works for casting between vectors with different 
> element types.
A similar argument applies here as the other related ticket, in principal we 
could, however it's not clear that there is a good use case for writing code 
that would make use of this. So for now it's probably best to just deal with 
predicates which are definitely a problem and other cases as they arise.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106860

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


[PATCH] D107078: [analyzer] Catch leaking stack addresses via stack variables

2021-07-29 Thread Balázs Benics via Phabricator via cfe-commits
steakhal marked an inline comment as done.
steakhal added a comment.

Thanks for the quick response.




Comment at: clang/test/Analysis/copy-elision.cpp:9-10
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection 
-std=c++17 \
+// RUN:-analyzer-config elide-constructors=false -DNO_ELIDE_FLAG   
   \
+// RUN:-analyzer-config eagerly-assume=false -verify %s
 

martong wrote:
> Should we use `-verify=no-elide` here as well? Since we set the 
> `DNO_ELIDE_FLAG`?
According to  the comment a few lines below:
> Copy elision always occurs in C++17, otherwise it's under an on-by-default 
> flag.

So I think even though one passes the `elide-constructors=false` analyzer 
config, we follow the language semantics, which requires us to elide those 
copies, thus no copy should happen.


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

https://reviews.llvm.org/D107078

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


[PATCH] D107082: [X86][RFC] Enable `_Float16` type support on X86 following the psABI

2021-07-29 Thread Pengfei Wang via Phabricator via cfe-commits
pengfei added inline comments.



Comment at: llvm/include/llvm/IR/RuntimeLibcalls.def:293-294
 HANDLE_LIBCALL(FPEXT_F16_F64, "__extendhfdf2")
 HANDLE_LIBCALL(FPEXT_F16_F32, "__gnu_h2f_ieee")
 HANDLE_LIBCALL(FPROUND_F32_F16, "__gnu_f2h_ieee")
 HANDLE_LIBCALL(FPROUND_F64_F16, "__truncdfhf2")

GCC12 will provide functions `__extendhfsf2` and `__truncsfhf2`. I wonder if I 
can change it directly here or do extra customization for ARM/AArch64? Other 
targets?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107082

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


  1   2   3   >