[clang] 5fc4828 - [clang] Don't generate warn-stack-size when the warning is ignored

2021-08-25 Thread Yi Kong via cfe-commits

Author: Yi Kong
Date: 2021-08-25T14:58:45+08:00
New Revision: 5fc4828aa6c6df03bd98b1f066e85655383d0cce

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

LOG: [clang] Don't generate warn-stack-size when the warning is ignored

8ace12130526 introduced a regression for code that explicitly ignores the
-Wframe-larger-than= warning. Make sure we don't generate the
warn-stack-size attribute for that case.

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

Added: 
clang/test/Misc/backend-stack-frame-diagnostics-attributes.cpp

Modified: 
clang/lib/CodeGen/CodeGenFunction.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CodeGenFunction.cpp 
b/clang/lib/CodeGen/CodeGenFunction.cpp
index e3a66318c086c..a3c348051c675 100644
--- a/clang/lib/CodeGen/CodeGenFunction.cpp
+++ b/clang/lib/CodeGen/CodeGenFunction.cpp
@@ -1049,7 +1049,8 @@ void CodeGenFunction::StartFunction(GlobalDecl GD, 
QualType RetTy,
 Fn->addFnAttr("packed-stack");
   }
 
-  if (CGM.getCodeGenOpts().WarnStackSize != UINT_MAX)
+  if (CGM.getCodeGenOpts().WarnStackSize != UINT_MAX &&
+  !CGM.getDiags().isIgnored(diag::warn_fe_backend_frame_larger_than, Loc))
 Fn->addFnAttr("warn-stack-size",
   std::to_string(CGM.getCodeGenOpts().WarnStackSize));
 

diff  --git a/clang/test/Misc/backend-stack-frame-diagnostics-attributes.cpp 
b/clang/test/Misc/backend-stack-frame-diagnostics-attributes.cpp
new file mode 100644
index 0..c7d8a23023e9c
--- /dev/null
+++ b/clang/test/Misc/backend-stack-frame-diagnostics-attributes.cpp
@@ -0,0 +1,24 @@
+// Test the warn-stack-size function attribute is not generated when 
-Wframe-larger-than is ignored
+// through pragma.
+
+// RUN: %clang_cc1 -fwarn-stack-size=70 -emit-llvm -o - %s | FileCheck %s
+// CHECK: "warn-stack-size"="70"
+
+// RUN: %clang_cc1 -DIGNORED -fwarn-stack-size=70 -emit-llvm -o - %s | 
FileCheck %s --check-prefix=IGNORED
+// IGNORED-NOT: "warn-stack-size"="70"
+
+extern void doIt(char *);
+
+#ifdef IGNORED
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wframe-larger-than"
+#endif
+
+void frameSizeAttr() {
+  char buffer[80];
+  doIt(buffer);
+}
+
+#ifdef IGNORED
+#pragma GCC diagnostic pop
+#endif



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


[PATCH] D108686: [clang] Don't generate warn-stack-size when the warning is ignored

2021-08-25 Thread Yi Kong via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG5fc4828aa6c6: [clang] Don't generate warn-stack-size 
when the warning is ignored (authored by kongyi).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Changed prior to commit:
  https://reviews.llvm.org/D108686?vs=368560&id=368564#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108686

Files:
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/test/Misc/backend-stack-frame-diagnostics-attributes.cpp


Index: clang/test/Misc/backend-stack-frame-diagnostics-attributes.cpp
===
--- /dev/null
+++ clang/test/Misc/backend-stack-frame-diagnostics-attributes.cpp
@@ -0,0 +1,24 @@
+// Test the warn-stack-size function attribute is not generated when 
-Wframe-larger-than is ignored
+// through pragma.
+
+// RUN: %clang_cc1 -fwarn-stack-size=70 -emit-llvm -o - %s | FileCheck %s
+// CHECK: "warn-stack-size"="70"
+
+// RUN: %clang_cc1 -DIGNORED -fwarn-stack-size=70 -emit-llvm -o - %s | 
FileCheck %s --check-prefix=IGNORED
+// IGNORED-NOT: "warn-stack-size"="70"
+
+extern void doIt(char *);
+
+#ifdef IGNORED
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wframe-larger-than"
+#endif
+
+void frameSizeAttr() {
+  char buffer[80];
+  doIt(buffer);
+}
+
+#ifdef IGNORED
+#pragma GCC diagnostic pop
+#endif
Index: clang/lib/CodeGen/CodeGenFunction.cpp
===
--- clang/lib/CodeGen/CodeGenFunction.cpp
+++ clang/lib/CodeGen/CodeGenFunction.cpp
@@ -1049,7 +1049,8 @@
 Fn->addFnAttr("packed-stack");
   }
 
-  if (CGM.getCodeGenOpts().WarnStackSize != UINT_MAX)
+  if (CGM.getCodeGenOpts().WarnStackSize != UINT_MAX &&
+  !CGM.getDiags().isIgnored(diag::warn_fe_backend_frame_larger_than, Loc))
 Fn->addFnAttr("warn-stack-size",
   std::to_string(CGM.getCodeGenOpts().WarnStackSize));
 


Index: clang/test/Misc/backend-stack-frame-diagnostics-attributes.cpp
===
--- /dev/null
+++ clang/test/Misc/backend-stack-frame-diagnostics-attributes.cpp
@@ -0,0 +1,24 @@
+// Test the warn-stack-size function attribute is not generated when -Wframe-larger-than is ignored
+// through pragma.
+
+// RUN: %clang_cc1 -fwarn-stack-size=70 -emit-llvm -o - %s | FileCheck %s
+// CHECK: "warn-stack-size"="70"
+
+// RUN: %clang_cc1 -DIGNORED -fwarn-stack-size=70 -emit-llvm -o - %s | FileCheck %s --check-prefix=IGNORED
+// IGNORED-NOT: "warn-stack-size"="70"
+
+extern void doIt(char *);
+
+#ifdef IGNORED
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wframe-larger-than"
+#endif
+
+void frameSizeAttr() {
+  char buffer[80];
+  doIt(buffer);
+}
+
+#ifdef IGNORED
+#pragma GCC diagnostic pop
+#endif
Index: clang/lib/CodeGen/CodeGenFunction.cpp
===
--- clang/lib/CodeGen/CodeGenFunction.cpp
+++ clang/lib/CodeGen/CodeGenFunction.cpp
@@ -1049,7 +1049,8 @@
 Fn->addFnAttr("packed-stack");
   }
 
-  if (CGM.getCodeGenOpts().WarnStackSize != UINT_MAX)
+  if (CGM.getCodeGenOpts().WarnStackSize != UINT_MAX &&
+  !CGM.getDiags().isIgnored(diag::warn_fe_backend_frame_larger_than, Loc))
 Fn->addFnAttr("warn-stack-size",
   std::to_string(CGM.getCodeGenOpts().WarnStackSize));
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] ea08c4c - [CUDA] Fix static device variables with -fgpu-rdc

2021-08-25 Thread Jonas Hahnfeld via cfe-commits

Author: Jonas Hahnfeld
Date: 2021-08-25T09:31:22+02:00
New Revision: ea08c4cd1c0869ec5024a8bb3f5cdf06ab03ae83

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

LOG: [CUDA] Fix static device variables with -fgpu-rdc

NVPTX does not allow dots in the identifier, so ptxas errors out with
   fatal   : Parsing error near '.static': syntax error
because it parses .static as a directive. Avoid this problem by using
two underscores, similar to what OpenMP does for outlined functions.

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

Added: 


Modified: 
clang/lib/CodeGen/CodeGenModule.cpp
clang/test/CodeGenCUDA/device-var-linkage.cu
clang/test/CodeGenCUDA/managed-var.cu
clang/test/CodeGenCUDA/static-device-var-rdc.cu

Removed: 




diff  --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index 13d7cce880e09..0940980461cd7 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -6444,5 +6444,5 @@ bool CodeGenModule::stopAutoInit() {
 
 void CodeGenModule::printPostfixForExternalizedStaticVar(
 llvm::raw_ostream &OS) const {
-  OS << ".static." << getContext().getCUIDHash();
+  OS << "__static__" << getContext().getCUIDHash();
 }

diff  --git a/clang/test/CodeGenCUDA/device-var-linkage.cu 
b/clang/test/CodeGenCUDA/device-var-linkage.cu
index d8cd9352e8850..d830802c82061 100644
--- a/clang/test/CodeGenCUDA/device-var-linkage.cu
+++ b/clang/test/CodeGenCUDA/device-var-linkage.cu
@@ -37,15 +37,15 @@ extern __constant__ int ev2;
 extern __managed__ int ev3;
 
 // NORDC-DAG: @_ZL3sv1 = addrspace(1) externally_initialized global i32 0
-// RDC-DAG: @_ZL3sv1.static.[[HASH:.*]] = addrspace(1) externally_initialized 
global i32 0
+// RDC-DAG: @_ZL3sv1__static__[[HASH:.*]] = addrspace(1) 
externally_initialized global i32 0
 // HOST-DAG: @_ZL3sv1 = internal global i32 undef
 static __device__ int sv1;
 // NORDC-DAG: @_ZL3sv2 = addrspace(4) externally_initialized global i32 0
-// RDC-DAG: @_ZL3sv2.static.[[HASH]] = addrspace(4) externally_initialized 
global i32 0
+// RDC-DAG: @_ZL3sv2__static__[[HASH]] = addrspace(4) externally_initialized 
global i32 0
 // HOST-DAG: @_ZL3sv2 = internal global i32 undef
 static __constant__ int sv2;
 // NORDC-DAG: @_ZL3sv3 = addrspace(1) externally_initialized global i32 
addrspace(1)* null
-// RDC-DAG: @_ZL3sv3.static.[[HASH]] = addrspace(1) externally_initialized 
global i32 addrspace(1)* null
+// RDC-DAG: @_ZL3sv3__static__[[HASH]] = addrspace(1) externally_initialized 
global i32 addrspace(1)* null
 // HOST-DAG: @_ZL3sv3 = internal externally_initialized global i32* null
 static __managed__ int sv3;
 

diff  --git a/clang/test/CodeGenCUDA/managed-var.cu 
b/clang/test/CodeGenCUDA/managed-var.cu
index 05a7a69387690..96657f0f7a131 100644
--- a/clang/test/CodeGenCUDA/managed-var.cu
+++ b/clang/test/CodeGenCUDA/managed-var.cu
@@ -52,15 +52,15 @@ extern __managed__ int ex;
 
 // NORDC-D-DAG: @_ZL2sx.managed = addrspace(1) externally_initialized global 
i32 1, align 4
 // NORDC-D-DAG: @_ZL2sx = addrspace(1) externally_initialized global i32 
addrspace(1)* null
-// RDC-D-DAG: @_ZL2sx.static.[[HASH:.*]].managed = addrspace(1) 
externally_initialized global i32 1, align 4
-// RDC-D-DAG: @_ZL2sx.static.[[HASH]] = addrspace(1) externally_initialized 
global i32 addrspace(1)* null
+// RDC-D-DAG: @_ZL2sx__static__[[HASH:.*]].managed = addrspace(1) 
externally_initialized global i32 1, align 4
+// RDC-D-DAG: @_ZL2sx__static__[[HASH]] = addrspace(1) externally_initialized 
global i32 addrspace(1)* null
 // HOST-DAG: @_ZL2sx.managed = internal global i32 1
 // HOST-DAG: @_ZL2sx = internal externally_initialized global i32* null
 // NORDC-DAG: @[[DEVNAMESX:[0-9]+]] = {{.*}}c"_ZL2sx\00"
-// RDC-DAG: @[[DEVNAMESX:[0-9]+]] = {{.*}}c"_ZL2sx.static.[[HASH:.*]]\00"
+// RDC-DAG: @[[DEVNAMESX:[0-9]+]] = {{.*}}c"_ZL2sx__static__[[HASH:.*]]\00"
 
-// POSTFIX:  @_ZL2sx.static.[[HASH:.*]] = addrspace(1) externally_initialized 
global i32 addrspace(1)* null
-// POSTFIX: @[[DEVNAMESX:[0-9]+]] = {{.*}}c"_ZL2sx.static.[[HASH]]\00"
+// POSTFIX:  @_ZL2sx__static__[[HASH:.*]] = addrspace(1) 
externally_initialized global i32 addrspace(1)* null
+// POSTFIX: @[[DEVNAMESX:[0-9]+]] = {{.*}}c"_ZL2sx__static__[[HASH]]\00"
 static __managed__ int sx = 1;
 
 // DEV-DAG: @llvm.compiler.used

diff  --git a/clang/test/CodeGenCUDA/static-device-var-rdc.cu 
b/clang/test/CodeGenCUDA/static-device-var-rdc.cu
index f32e039842990..bb750bd91a928 100644
--- a/clang/test/CodeGenCUDA/static-device-var-rdc.cu
+++ b/clang/test/CodeGenCUDA/static-device-var-rdc.cu
@@ -55,11 +55,11 @@
 // INT-HOST-DAG: @[[DEVNAMEX:[0-9]+]] = {{.*}}c"_ZL1x\00"
 
 // Test externalized static device variables
-// EXT-DEV-DAG: @_ZL1x.static.[[HASH:.*

[PATCH] D108456: [CUDA] Fix static device variables with -fgpu-rdc

2021-08-25 Thread Jonas Hahnfeld via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGea08c4cd1c08: [CUDA] Fix static device variables with 
-fgpu-rdc (authored by Hahnfeld).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108456

Files:
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/test/CodeGenCUDA/device-var-linkage.cu
  clang/test/CodeGenCUDA/managed-var.cu
  clang/test/CodeGenCUDA/static-device-var-rdc.cu


Index: clang/test/CodeGenCUDA/static-device-var-rdc.cu
===
--- clang/test/CodeGenCUDA/static-device-var-rdc.cu
+++ clang/test/CodeGenCUDA/static-device-var-rdc.cu
@@ -55,11 +55,11 @@
 // INT-HOST-DAG: @[[DEVNAMEX:[0-9]+]] = {{.*}}c"_ZL1x\00"
 
 // Test externalized static device variables
-// EXT-DEV-DAG: @_ZL1x.static.[[HASH:.*]] = addrspace(1) 
externally_initialized global i32 0
-// EXT-HOST-DAG: @[[DEVNAMEX:[0-9]+]] = {{.*}}c"_ZL1x.static.[[HASH:.*]]\00"
+// EXT-DEV-DAG: @_ZL1x__static__[[HASH:.*]] = addrspace(1) 
externally_initialized global i32 0
+// EXT-HOST-DAG: @[[DEVNAMEX:[0-9]+]] = {{.*}}c"_ZL1x__static__[[HASH:.*]]\00"
 
-// POSTFIX: @_ZL1x.static.[[HASH:.*]] = addrspace(1) externally_initialized 
global i32 0
-// POSTFIX: @[[DEVNAMEX:[0-9]+]] = {{.*}}c"_ZL1x.static.[[HASH]]\00"
+// POSTFIX: @_ZL1x__static__[[HASH:.*]] = addrspace(1) externally_initialized 
global i32 0
+// POSTFIX: @[[DEVNAMEX:[0-9]+]] = {{.*}}c"_ZL1x__static__[[HASH]]\00"
 
 static __device__ int x;
 
@@ -73,8 +73,8 @@
 // INT-HOST-DAG: @[[DEVNAMEY:[0-9]+]] = {{.*}}c"_ZL1y\00"
 
 // Test externalized static device variables
-// EXT-DEV-DAG: @_ZL1y.static.[[HASH]] = addrspace(4) externally_initialized 
global i32 0
-// EXT-HOST-DAG: @[[DEVNAMEY:[0-9]+]] = {{.*}}c"_ZL1y.static.[[HASH]]\00"
+// EXT-DEV-DAG: @_ZL1y__static__[[HASH]] = addrspace(4) externally_initialized 
global i32 0
+// EXT-HOST-DAG: @[[DEVNAMEY:[0-9]+]] = {{.*}}c"_ZL1y__static__[[HASH]]\00"
 
 static __constant__ int y;
 
Index: clang/test/CodeGenCUDA/managed-var.cu
===
--- clang/test/CodeGenCUDA/managed-var.cu
+++ clang/test/CodeGenCUDA/managed-var.cu
@@ -52,15 +52,15 @@
 
 // NORDC-D-DAG: @_ZL2sx.managed = addrspace(1) externally_initialized global 
i32 1, align 4
 // NORDC-D-DAG: @_ZL2sx = addrspace(1) externally_initialized global i32 
addrspace(1)* null
-// RDC-D-DAG: @_ZL2sx.static.[[HASH:.*]].managed = addrspace(1) 
externally_initialized global i32 1, align 4
-// RDC-D-DAG: @_ZL2sx.static.[[HASH]] = addrspace(1) externally_initialized 
global i32 addrspace(1)* null
+// RDC-D-DAG: @_ZL2sx__static__[[HASH:.*]].managed = addrspace(1) 
externally_initialized global i32 1, align 4
+// RDC-D-DAG: @_ZL2sx__static__[[HASH]] = addrspace(1) externally_initialized 
global i32 addrspace(1)* null
 // HOST-DAG: @_ZL2sx.managed = internal global i32 1
 // HOST-DAG: @_ZL2sx = internal externally_initialized global i32* null
 // NORDC-DAG: @[[DEVNAMESX:[0-9]+]] = {{.*}}c"_ZL2sx\00"
-// RDC-DAG: @[[DEVNAMESX:[0-9]+]] = {{.*}}c"_ZL2sx.static.[[HASH:.*]]\00"
+// RDC-DAG: @[[DEVNAMESX:[0-9]+]] = {{.*}}c"_ZL2sx__static__[[HASH:.*]]\00"
 
-// POSTFIX:  @_ZL2sx.static.[[HASH:.*]] = addrspace(1) externally_initialized 
global i32 addrspace(1)* null
-// POSTFIX: @[[DEVNAMESX:[0-9]+]] = {{.*}}c"_ZL2sx.static.[[HASH]]\00"
+// POSTFIX:  @_ZL2sx__static__[[HASH:.*]] = addrspace(1) 
externally_initialized global i32 addrspace(1)* null
+// POSTFIX: @[[DEVNAMESX:[0-9]+]] = {{.*}}c"_ZL2sx__static__[[HASH]]\00"
 static __managed__ int sx = 1;
 
 // DEV-DAG: @llvm.compiler.used
Index: clang/test/CodeGenCUDA/device-var-linkage.cu
===
--- clang/test/CodeGenCUDA/device-var-linkage.cu
+++ clang/test/CodeGenCUDA/device-var-linkage.cu
@@ -37,15 +37,15 @@
 extern __managed__ int ev3;
 
 // NORDC-DAG: @_ZL3sv1 = addrspace(1) externally_initialized global i32 0
-// RDC-DAG: @_ZL3sv1.static.[[HASH:.*]] = addrspace(1) externally_initialized 
global i32 0
+// RDC-DAG: @_ZL3sv1__static__[[HASH:.*]] = addrspace(1) 
externally_initialized global i32 0
 // HOST-DAG: @_ZL3sv1 = internal global i32 undef
 static __device__ int sv1;
 // NORDC-DAG: @_ZL3sv2 = addrspace(4) externally_initialized global i32 0
-// RDC-DAG: @_ZL3sv2.static.[[HASH]] = addrspace(4) externally_initialized 
global i32 0
+// RDC-DAG: @_ZL3sv2__static__[[HASH]] = addrspace(4) externally_initialized 
global i32 0
 // HOST-DAG: @_ZL3sv2 = internal global i32 undef
 static __constant__ int sv2;
 // NORDC-DAG: @_ZL3sv3 = addrspace(1) externally_initialized global i32 
addrspace(1)* null
-// RDC-DAG: @_ZL3sv3.static.[[HASH]] = addrspace(1) externally_initialized 
global i32 addrspace(1)* null
+// RDC-DAG: @_ZL3sv3__static__[[HASH]] = addrspace(1) externally_initialized 
global i32 addrspace(1)* null
 // HOST-DAG: @_ZL3sv3 = internal externally_initializ

[PATCH] D106924: [Preprocessor] -E -P: Ensure newline after 8 skipped lines.

2021-08-25 Thread Stephan Bergmann via Phabricator via cfe-commits
sberg added a comment.

In D106924#2919406 , @sberg wrote:

> Bisecting shows that this commit causes
>
>   $ echo foo | clang -E -P -
>   
>   foo
>
> to emit a leading newline now.
>
> That breaks e.g. LibreOffice's `configure`, which uses `echo 
> __clang_version__ | clang -E -P -` to obtain the value of that macro, and 
> expects a single line of output.

I now filed https://bugs.llvm.org/show_bug.cgi?id=51616 "Bad newlines in -E -P 
output after https://reviews.llvm.org/D106924 '[Preprocessor] -E -P: Ensure 
newline after 8 skipped lines.'"


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106924

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


[clang] 83c633e - [clang][deps] Collect precompiled deps from submodules too

2021-08-25 Thread Jan Svoboda via cfe-commits

Author: Jan Svoboda
Date: 2021-08-25T10:35:34+02:00
New Revision: 83c633ea1a5b015cf25056aa1855842cd92c077d

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

LOG: [clang][deps] Collect precompiled deps from submodules too

In this patch, the dependency scanner starts collecting precompiled 
dependencies from all encountered submodules, not only from top-level modules.

Reviewed By: dexonsmith

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

Added: 

clang/test/ClangScanDeps/Inputs/modules-pch-common-via-submodule/cdb_pch.json
clang/test/ClangScanDeps/Inputs/modules-pch-common-via-submodule/cdb_tu.json

clang/test/ClangScanDeps/Inputs/modules-pch-common-via-submodule/mod_common.h
clang/test/ClangScanDeps/Inputs/modules-pch-common-via-submodule/mod_tu.h

clang/test/ClangScanDeps/Inputs/modules-pch-common-via-submodule/mod_tu_sub.h

clang/test/ClangScanDeps/Inputs/modules-pch-common-via-submodule/module.modulemap
clang/test/ClangScanDeps/Inputs/modules-pch-common-via-submodule/pch.h
clang/test/ClangScanDeps/Inputs/modules-pch-common-via-submodule/tu.c
clang/test/ClangScanDeps/modules-pch-common-via-submodule.c

Modified: 
clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h
clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp

Removed: 




diff  --git 
a/clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h 
b/clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h
index fbdb34f402d73..c539d7a586476 100644
--- a/clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h
+++ b/clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h
@@ -172,7 +172,11 @@ class ModuleDepCollectorPP final : public PPCallbacks {
 
   /// Adds direct modular dependencies that have already been built to the
   /// ModuleDeps instance.
-  void addDirectPrebuiltModuleDeps(const Module *M, ModuleDeps &MD);
+  void
+  addAllSubmodulePrebuiltDeps(const Module *M, ModuleDeps &MD,
+  llvm::DenseSet &SeenSubmodules);
+  void addModulePrebuiltDeps(const Module *M, ModuleDeps &MD,
+ llvm::DenseSet &SeenSubmodules);
 
   /// Traverses the previously collected direct modular dependencies to 
discover
   /// transitive modular dependencies and fills the parent \c 
ModuleDepCollector

diff  --git a/clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp 
b/clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
index bd2c515ff2905..cc1f64e221ac4 100644
--- a/clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
+++ b/clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
@@ -231,7 +231,8 @@ ModuleID ModuleDepCollectorPP::handleTopLevelModule(const 
Module *M) {
   // Add direct prebuilt module dependencies now, so that we can use them when
   // creating a CompilerInvocation and computing context hash for this
   // ModuleDeps instance.
-  addDirectPrebuiltModuleDeps(M, MD);
+  llvm::DenseSet SeenModules;
+  addAllSubmodulePrebuiltDeps(M, MD, SeenModules);
 
   MD.Invocation = MDC.makeInvocationForModuleBuildWithoutPaths(MD);
   MD.ID.ContextHash = MD.Invocation.getModuleHash();
@@ -242,12 +243,23 @@ ModuleID ModuleDepCollectorPP::handleTopLevelModule(const 
Module *M) {
   return MD.ID;
 }
 
-void ModuleDepCollectorPP::addDirectPrebuiltModuleDeps(const Module *M,
-   ModuleDeps &MD) {
+void ModuleDepCollectorPP::addAllSubmodulePrebuiltDeps(
+const Module *M, ModuleDeps &MD,
+llvm::DenseSet &SeenSubmodules) {
+  addModulePrebuiltDeps(M, MD, SeenSubmodules);
+
+  for (const Module *SubM : M->submodules())
+addAllSubmodulePrebuiltDeps(SubM, MD, SeenSubmodules);
+}
+
+void ModuleDepCollectorPP::addModulePrebuiltDeps(
+const Module *M, ModuleDeps &MD,
+llvm::DenseSet &SeenSubmodules) {
   for (const Module *Import : M->Imports)
 if (Import->getTopLevelModule() != M->getTopLevelModule())
   if (MDC.isPrebuiltModule(Import))
-MD.PrebuiltModuleDeps.emplace_back(Import);
+if (SeenSubmodules.insert(Import).second)
+  MD.PrebuiltModuleDeps.emplace_back(Import);
 }
 
 void ModuleDepCollectorPP::addAllSubmoduleDeps(

diff  --git 
a/clang/test/ClangScanDeps/Inputs/modules-pch-common-via-submodule/cdb_pch.json 
b/clang/test/ClangScanDeps/Inputs/modules-pch-common-via-submodule/cdb_pch.json
new file mode 100644
index 0..dc2fc550b0191
--- /dev/null
+++ 
b/clang/test/ClangScanDeps/Inputs/modules-pch-common-via-submodule/cdb_pch.json
@@ -0,0 +1,7 @@
+[
+  {
+"directory": "DIR",
+"command": "clang -x c-header DIR/pch.h -fmodules -gmodules 
-fimplicit-module-maps -fmodules-cache-path=DIR/cache -o DIR/pch.h.gch",
+"file": "DIR/p

[PATCH] D108540: [clang][deps] Collect precompiled deps from submodules too

2021-08-25 Thread Jan Svoboda via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG83c633ea1a5b: [clang][deps] Collect precompiled deps from 
submodules too (authored by jansvoboda11).

Changed prior to commit:
  https://reviews.llvm.org/D108540?vs=368064&id=368575#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108540

Files:
  clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h
  clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
  clang/test/ClangScanDeps/Inputs/modules-pch-common-via-submodule/cdb_pch.json
  clang/test/ClangScanDeps/Inputs/modules-pch-common-via-submodule/cdb_tu.json
  clang/test/ClangScanDeps/Inputs/modules-pch-common-via-submodule/mod_common.h
  clang/test/ClangScanDeps/Inputs/modules-pch-common-via-submodule/mod_tu.h
  clang/test/ClangScanDeps/Inputs/modules-pch-common-via-submodule/mod_tu_sub.h
  
clang/test/ClangScanDeps/Inputs/modules-pch-common-via-submodule/module.modulemap
  clang/test/ClangScanDeps/Inputs/modules-pch-common-via-submodule/pch.h
  clang/test/ClangScanDeps/Inputs/modules-pch-common-via-submodule/tu.c
  clang/test/ClangScanDeps/modules-pch-common-via-submodule.c

Index: clang/test/ClangScanDeps/modules-pch-common-via-submodule.c
===
--- /dev/null
+++ clang/test/ClangScanDeps/modules-pch-common-via-submodule.c
@@ -0,0 +1,137 @@
+// Check that we discover dependency on a precompiled module (and generate the
+// appropriate `-fmodule-file=` argument) when it's imported by a **submodule**
+// instead of a top-level module.
+
+// RUN: rm -rf %t && mkdir %t
+// RUN: cp %S/Inputs/modules-pch-common-via-submodule/* %t
+
+// Scan dependencies of the PCH:
+//
+// RUN: sed "s|DIR|%/t|g" %S/Inputs/modules-pch-common-via-submodule/cdb_pch.json > %t/cdb.json
+// RUN: echo -%t > %t/result_pch.json
+// RUN: clang-scan-deps -compilation-database %t/cdb.json -format experimental-full \
+// RUN:   -generate-modules-path-args -module-files-dir %t/build >> %t/result_pch.json
+// RUN: cat %t/result_pch.json | sed 's:\?:/:g' | FileCheck %s -check-prefix=CHECK-PCH
+//
+// CHECK-PCH:  -[[PREFIX:.*]]
+// CHECK-PCH-NEXT: {
+// CHECK-PCH-NEXT:   "modules": [
+// CHECK-PCH-NEXT: {
+// CHECK-PCH-NEXT:   "clang-module-deps": [],
+// CHECK-PCH-NEXT:   "clang-modulemap-file": "[[PREFIX]]/module.modulemap",
+// CHECK-PCH-NEXT:   "command-line": [
+// CHECK-PCH-NEXT: "-cc1"
+// CHECK-PCH:  "-emit-module"
+// CHECK-PCH:  "-fmodules"
+// CHECK-PCH:  "-fmodule-name=ModCommon"
+// CHECK-PCH:  "-fno-implicit-modules"
+// CHECK-PCH:],
+// CHECK-PCH-NEXT:   "context-hash": "[[HASH_MOD_COMMON:.*]]",
+// CHECK-PCH-NEXT:   "file-deps": [
+// CHECK-PCH-NEXT: "[[PREFIX]]/mod_common.h",
+// CHECK-PCH-NEXT: "[[PREFIX]]/module.modulemap"
+// CHECK-PCH-NEXT:   ],
+// CHECK-PCH-NEXT:   "name": "ModCommon"
+// CHECK-PCH-NEXT: }
+// CHECK-PCH-NEXT:   ],
+// CHECK-PCH-NEXT:   "translation-units": [
+// CHECK-PCH-NEXT: {
+// CHECK-PCH-NEXT:   "clang-context-hash": "[[HASH_PCH:.*]]",
+// CHECK-PCH-NEXT:   "clang-module-deps": [
+// CHECK-PCH-NEXT: {
+// CHECK-PCH-NEXT:   "context-hash": "[[HASH_MOD_COMMON]]",
+// CHECK-PCH-NEXT:   "module-name": "ModCommon"
+// CHECK-PCH-NEXT: }
+// CHECK-PCH-NEXT:   ],
+// CHECK-PCH-NEXT:   "command-line": [
+// CHECK-PCH-NEXT: "-fno-implicit-modules"
+// CHECK-PCH-NEXT: "-fno-implicit-module-maps"
+// CHECK-PCH-NEXT: "-fmodule-file=[[PREFIX]]/build/[[HASH_MOD_COMMON]]/ModCommon-{{.*}}.pcm"
+// CHECK-PCH-NEXT: "-fmodule-map-file=[[PREFIX]]/module.modulemap"
+// CHECK-PCH-NEXT:   ],
+// CHECK-PCH-NEXT:   "file-deps": [
+// CHECK-PCH-NEXT: "[[PREFIX]]/pch.h"
+// CHECK-PCH-NEXT:   ],
+// CHECK-PCH-NEXT:   "input-file": "[[PREFIX]]/pch.h"
+// CHECK-PCH-NEXT: }
+// CHECK-PCH-NEXT:   ]
+// CHECK-PCH-NEXT: }
+
+// Explicitly build the PCH:
+//
+// RUN: tail -n +2 %t/result_pch.json > %t/result_pch_stripped.json
+// RUN: %python %S/../../utils/module-deps-to-rsp.py %t/result_pch_stripped.json \
+// RUN:   --module-name=ModCommon > %t/mod_common.cc1.rsp
+// RUN: %python %S/../../utils/module-deps-to-rsp.py %t/result_pch_stripped.json \
+// RUN:   --tu-index=0 > %t/pch.rsp
+//
+// RUN: %clang @%t/mod_common.cc1.rsp
+// RUN: %clang -x c-header %t/pch.h -fmodules -gmodules -fimplicit-module-maps \
+// RUN:   -fmodules-cache-path=%t/cache -o %t/pch.h.gch @%t/pch.rsp
+
+// Scan dependencies of the TU:
+//
+// RUN: sed "s|DIR|%/t|g" %S/Inputs/modules-pch-common-via-submodule/cdb_tu.json > %t/cdb.json
+// RUN: echo -%t > %t/result_tu.json
+// RUN: clang-scan-deps -compilation-database %t/cdb.json -format experimental-full \
+// RUN:   -generate-modules-path-args -module-files-dir 

[clang] 3b8f536 - [clang][deps] Use top-level modules as precompiled dependencies

2021-08-25 Thread Jan Svoboda via cfe-commits

Author: Jan Svoboda
Date: 2021-08-25T10:51:34+02:00
New Revision: 3b8f536fec2f7dfd5dc69c6516c20c5b48b38409

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

LOG: [clang][deps] Use top-level modules as precompiled dependencies

The `ASTReader` populates `Module::PresumedModuleMapFile` only for top-level 
modules, not submodules. To avoid generating empty `-fmodule-map-file=` 
arguments, make discovered modules depend on top-level precompiled modules. The 
granularity of submodules is not important here.

The documentation of `Module::PresumedModuleMapFile` says this field is 
non-empty only when building from preprocessed source. This means there can 
still be cases where the dependency scanner generates empty 
`-fmodule-map-file=` arguments. That's being addressed in separate patch: 
D108544.

Reviewed By: dexonsmith

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

Added: 
clang/test/ClangScanDeps/Inputs/modules-pch-common-submodule/cdb_pch.json
clang/test/ClangScanDeps/Inputs/modules-pch-common-submodule/cdb_tu.json
clang/test/ClangScanDeps/Inputs/modules-pch-common-submodule/mod_common.h

clang/test/ClangScanDeps/Inputs/modules-pch-common-submodule/mod_common_sub.h
clang/test/ClangScanDeps/Inputs/modules-pch-common-submodule/mod_tu.h

clang/test/ClangScanDeps/Inputs/modules-pch-common-submodule/module.modulemap
clang/test/ClangScanDeps/Inputs/modules-pch-common-submodule/pch.h
clang/test/ClangScanDeps/Inputs/modules-pch-common-submodule/tu.c
clang/test/ClangScanDeps/modules-pch-common-submodule.c

Modified: 
clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp

Removed: 




diff  --git a/clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp 
b/clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
index cc1f64e221ac4..66f8d97e246e2 100644
--- a/clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
+++ b/clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
@@ -257,9 +257,9 @@ void ModuleDepCollectorPP::addModulePrebuiltDeps(
 llvm::DenseSet &SeenSubmodules) {
   for (const Module *Import : M->Imports)
 if (Import->getTopLevelModule() != M->getTopLevelModule())
-  if (MDC.isPrebuiltModule(Import))
-if (SeenSubmodules.insert(Import).second)
-  MD.PrebuiltModuleDeps.emplace_back(Import);
+  if (MDC.isPrebuiltModule(Import->getTopLevelModule()))
+if (SeenSubmodules.insert(Import->getTopLevelModule()).second)
+  MD.PrebuiltModuleDeps.emplace_back(Import->getTopLevelModule());
 }
 
 void ModuleDepCollectorPP::addAllSubmoduleDeps(

diff  --git 
a/clang/test/ClangScanDeps/Inputs/modules-pch-common-submodule/cdb_pch.json 
b/clang/test/ClangScanDeps/Inputs/modules-pch-common-submodule/cdb_pch.json
new file mode 100644
index 0..dc2fc550b0191
--- /dev/null
+++ b/clang/test/ClangScanDeps/Inputs/modules-pch-common-submodule/cdb_pch.json
@@ -0,0 +1,7 @@
+[
+  {
+"directory": "DIR",
+"command": "clang -x c-header DIR/pch.h -fmodules -gmodules 
-fimplicit-module-maps -fmodules-cache-path=DIR/cache -o DIR/pch.h.gch",
+"file": "DIR/pch.h"
+  }
+]

diff  --git 
a/clang/test/ClangScanDeps/Inputs/modules-pch-common-submodule/cdb_tu.json 
b/clang/test/ClangScanDeps/Inputs/modules-pch-common-submodule/cdb_tu.json
new file mode 100644
index 0..8aad2cc74023e
--- /dev/null
+++ b/clang/test/ClangScanDeps/Inputs/modules-pch-common-submodule/cdb_tu.json
@@ -0,0 +1,7 @@
+[
+  {
+"directory": "DIR",
+"command": "clang -fsyntax-only DIR/tu.c -fmodules -gmodules 
-fimplicit-module-maps -fmodules-cache-path=DIR/cache -include DIR/pch.h -o 
DIR/tu.o",
+"file": "DIR/tu.c"
+  }
+]

diff  --git 
a/clang/test/ClangScanDeps/Inputs/modules-pch-common-submodule/mod_common.h 
b/clang/test/ClangScanDeps/Inputs/modules-pch-common-submodule/mod_common.h
new file mode 100644
index 0..e69de29bb2d1d

diff  --git 
a/clang/test/ClangScanDeps/Inputs/modules-pch-common-submodule/mod_common_sub.h 
b/clang/test/ClangScanDeps/Inputs/modules-pch-common-submodule/mod_common_sub.h
new file mode 100644
index 0..e69de29bb2d1d

diff  --git 
a/clang/test/ClangScanDeps/Inputs/modules-pch-common-submodule/mod_tu.h 
b/clang/test/ClangScanDeps/Inputs/modules-pch-common-submodule/mod_tu.h
new file mode 100644
index 0..30f05b0bd507b
--- /dev/null
+++ b/clang/test/ClangScanDeps/Inputs/modules-pch-common-submodule/mod_tu.h
@@ -0,0 +1 @@
+#include "mod_common_sub.h"

diff  --git 
a/clang/test/ClangScanDeps/Inputs/modules-pch-common-submodule/module.modulemap 
b/clang/test/ClangScanDeps/Inputs/modules-pch-common-submodule/module.modulemap
new file mode 100644
index 0..b7e404e20cef7
--- /dev/null
+++ 
b/clang/test/ClangScanDeps/Inputs/mo

[PATCH] D108647: [clang][deps] Use top-level modules as precompiled dependencies

2021-08-25 Thread Jan Svoboda via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3b8f536fec2f: [clang][deps] Use top-level modules as 
precompiled dependencies (authored by jansvoboda11).

Changed prior to commit:
  https://reviews.llvm.org/D108647?vs=368394&id=368580#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108647

Files:
  clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
  clang/test/ClangScanDeps/Inputs/modules-pch-common-submodule/cdb_pch.json
  clang/test/ClangScanDeps/Inputs/modules-pch-common-submodule/cdb_tu.json
  clang/test/ClangScanDeps/Inputs/modules-pch-common-submodule/mod_common.h
  clang/test/ClangScanDeps/Inputs/modules-pch-common-submodule/mod_common_sub.h
  clang/test/ClangScanDeps/Inputs/modules-pch-common-submodule/mod_tu.h
  clang/test/ClangScanDeps/Inputs/modules-pch-common-submodule/module.modulemap
  clang/test/ClangScanDeps/Inputs/modules-pch-common-submodule/pch.h
  clang/test/ClangScanDeps/Inputs/modules-pch-common-submodule/tu.c
  clang/test/ClangScanDeps/modules-pch-common-submodule.c

Index: clang/test/ClangScanDeps/modules-pch-common-submodule.c
===
--- /dev/null
+++ clang/test/ClangScanDeps/modules-pch-common-submodule.c
@@ -0,0 +1,140 @@
+// Check that when depending on a precompiled module, we depend on the
+// **top-level** module. Submodules don't have some information present (for
+// example the path to the modulemap file) and depending on them might cause
+// problems in the dependency scanner (e.g. generating empty `-fmodule-map-file=`
+// arguments).
+
+// RUN: rm -rf %t && mkdir %t
+// RUN: cp %S/Inputs/modules-pch-common-submodule/* %t
+
+// Scan dependencies of the PCH:
+//
+// RUN: sed "s|DIR|%/t|g" %S/Inputs/modules-pch-common-submodule/cdb_pch.json > %t/cdb.json
+// RUN: echo -%t > %t/result_pch.json
+// RUN: clang-scan-deps -compilation-database %t/cdb.json -format experimental-full \
+// RUN:   -generate-modules-path-args -module-files-dir %t/build >> %t/result_pch.json
+// RUN: cat %t/result_pch.json | sed 's:\?:/:g' | FileCheck %s -check-prefix=CHECK-PCH
+//
+// CHECK-PCH:  -[[PREFIX:.*]]
+// CHECK-PCH-NEXT: {
+// CHECK-PCH-NEXT:   "modules": [
+// CHECK-PCH-NEXT: {
+// CHECK-PCH-NEXT:   "clang-module-deps": [],
+// CHECK-PCH-NEXT:   "clang-modulemap-file": "[[PREFIX]]/module.modulemap",
+// CHECK-PCH-NEXT:   "command-line": [
+// CHECK-PCH-NEXT: "-cc1"
+// CHECK-PCH:  "-emit-module"
+// CHECK-PCH:  "-fmodules"
+// CHECK-PCH:  "-fmodule-name=ModCommon"
+// CHECK-PCH:  "-fno-implicit-modules"
+// CHECK-PCH:],
+// CHECK-PCH-NEXT:   "context-hash": "[[HASH_MOD_COMMON:.*]]",
+// CHECK-PCH-NEXT:   "file-deps": [
+// CHECK-PCH-NEXT: "[[PREFIX]]/mod_common.h",
+// CHECK-PCH-NEXT: "[[PREFIX]]/mod_common_sub.h",
+// CHECK-PCH-NEXT: "[[PREFIX]]/module.modulemap"
+// CHECK-PCH-NEXT:   ],
+// CHECK-PCH-NEXT:   "name": "ModCommon"
+// CHECK-PCH-NEXT: }
+// CHECK-PCH-NEXT:   ],
+// CHECK-PCH-NEXT:   "translation-units": [
+// CHECK-PCH-NEXT: {
+// CHECK-PCH-NEXT:   "clang-context-hash": "[[HASH_PCH:.*]]",
+// CHECK-PCH-NEXT:   "clang-module-deps": [
+// CHECK-PCH-NEXT: {
+// CHECK-PCH-NEXT:   "context-hash": "[[HASH_MOD_COMMON]]",
+// CHECK-PCH-NEXT:   "module-name": "ModCommon"
+// CHECK-PCH-NEXT: }
+// CHECK-PCH-NEXT:   ],
+// CHECK-PCH-NEXT:   "command-line": [
+// CHECK-PCH-NEXT: "-fno-implicit-modules"
+// CHECK-PCH-NEXT: "-fno-implicit-module-maps"
+// CHECK-PCH-NEXT: "-fmodule-file=[[PREFIX]]/build/[[HASH_MOD_COMMON]]/ModCommon-{{.*}}.pcm"
+// CHECK-PCH-NEXT: "-fmodule-map-file=[[PREFIX]]/module.modulemap"
+// CHECK-PCH-NEXT:   ],
+// CHECK-PCH-NEXT:   "file-deps": [
+// CHECK-PCH-NEXT: "[[PREFIX]]/pch.h"
+// CHECK-PCH-NEXT:   ],
+// CHECK-PCH-NEXT:   "input-file": "[[PREFIX]]/pch.h"
+// CHECK-PCH-NEXT: }
+// CHECK-PCH-NEXT:   ]
+// CHECK-PCH-NEXT: }
+
+// Explicitly build the PCH:
+//
+// RUN: tail -n +2 %t/result_pch.json > %t/result_pch_stripped.json
+// RUN: %python %S/../../utils/module-deps-to-rsp.py %t/result_pch_stripped.json \
+// RUN:   --module-name=ModCommon > %t/mod_common.cc1.rsp
+// RUN: %python %S/../../utils/module-deps-to-rsp.py %t/result_pch_stripped.json \
+// RUN:   --tu-index=0 > %t/pch.rsp
+//
+// RUN: %clang @%t/mod_common.cc1.rsp
+// RUN: %clang -x c-header %t/pch.h -fmodules -gmodules -fimplicit-module-maps \
+// RUN:   -fmodules-cache-path=%t/cache -o %t/pch.h.gch @%t/pch.rsp
+
+// Scan dependencies of the TU:
+//
+// RUN: sed "s|DIR|%/t|g" %S/Inputs/modules-pch-common-submodule/cdb_tu.json > %t/cdb.json
+// RUN: echo -%t > %t/result_tu.json
+// RUN: clang-scan-deps -compilation-database %t/cdb.json -format exper

[PATCH] D105168: [RISCV] Unify the arch string parsing logic to RISCVISAInfo.

2021-08-25 Thread Yueh-Ting Chen via Phabricator via cfe-commits
eopXD added inline comments.



Comment at: llvm/lib/Support/RISCVISAInfo.cpp:268
+// omitted from the version string. E.g., rv32i2p0, rv32i2, rv32i2p1.
+static Error getExtensionVersion(StringRef MArch, StringRef Ext, StringRef In,
+ unsigned &Major, unsigned &Minor,

For naming consistency with `parseArchString`, maybe rename `MArch` to `Arch`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105168

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


[PATCH] D108661: The maximal representable alignment in LLVM IR is 1GiB, not 512MiB

2021-08-25 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri updated this revision to Diff 368583.
lebedev.ri added a comment.

In D108661#2963726 , @arsenm wrote:

> Could use some MIR tests to make sure that parser doesn't explode

Added.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108661

Files:
  clang/include/clang/Sema/Sema.h
  clang/test/CXX/drs/dr6xx.cpp
  clang/test/CodeGen/builtin-assume-aligned.c
  
clang/test/CodeGen/catch-alignment-assumption-attribute-align_value-on-paramvar.cpp
  
clang/test/CodeGen/catch-alignment-assumption-builtin_assume_aligned-three-params-variable.cpp
  
clang/test/CodeGen/catch-alignment-assumption-builtin_assume_aligned-three-params.cpp
  
clang/test/CodeGen/catch-alignment-assumption-builtin_assume_aligned-two-params.cpp
  clang/test/CodeGen/catch-alignment-assumption-openmp.cpp
  clang/test/Sema/alloc-align-attr.c
  clang/test/Sema/attr-aligned.c
  clang/test/Sema/builtin-assume-aligned.c
  clang/test/SemaCXX/alloc-align-attr.cpp
  llvm/include/llvm/IR/Instruction.h
  llvm/include/llvm/IR/Value.h
  llvm/test/Assembler/align-inst-alloca.ll
  llvm/test/Assembler/align-inst-load.ll
  llvm/test/Assembler/align-inst-store.ll
  llvm/test/Bitcode/inalloca.ll
  llvm/test/CodeGen/X86/load-with-1gb-alignment.mir
  llvm/test/Transforms/Attributor/ArgumentPromotion/live_called_from_dead.ll
  llvm/test/Transforms/Attributor/ArgumentPromotion/live_called_from_dead_2.ll
  llvm/test/Transforms/Attributor/IPConstantProp/PR26044.ll
  llvm/test/Transforms/Attributor/IPConstantProp/pthreads.ll
  llvm/test/Transforms/Attributor/callbacks.ll
  llvm/test/Transforms/Attributor/liveness.ll
  llvm/test/Transforms/Attributor/memory_locations.ll
  llvm/test/Transforms/Attributor/noalias.ll
  llvm/test/Transforms/Attributor/nocapture-1.ll
  llvm/test/Transforms/Attributor/noundef.ll
  llvm/test/Transforms/Attributor/undefined_behavior.ll
  llvm/test/Transforms/Attributor/value-simplify.ll
  llvm/test/Transforms/GVN/PRE/2017-06-28-pre-load-dbgloc.ll
  llvm/test/Transforms/InstCombine/atomic.ll
  llvm/test/Transforms/InstCombine/getelementptr.ll
  llvm/test/Transforms/InstCombine/load.ll
  llvm/test/Transforms/InstCombine/mempcpy.ll
  llvm/test/Transforms/InstCombine/pr44245.ll
  llvm/test/Transforms/InstCombine/store.ll
  llvm/test/Transforms/OpenMP/parallel_level_fold.ll
  llvm/test/Verifier/align-md.ll
  llvm/unittests/IR/ValueTest.cpp

Index: llvm/unittests/IR/ValueTest.cpp
===
--- llvm/unittests/IR/ValueTest.cpp
+++ llvm/unittests/IR/ValueTest.cpp
@@ -61,9 +61,9 @@
  GlobalVariable::NotThreadLocal,
  1);
 
-  EXPECT_TRUE(Value::MaximumAlignment == 536870912U);
-  Dummy0->setAlignment(Align(536870912));
-  EXPECT_EQ(Dummy0->getAlignment(), 536870912U);
+  EXPECT_TRUE(Value::MaximumAlignment == 1073741824U);
+  Dummy0->setAlignment(Align(1073741824));
+  EXPECT_EQ(Dummy0->getAlignment(), 1073741824U);
 
   // Make sure the address space isn't dropped when returning this.
   Constant *Dummy1 = M->getOrInsertGlobal("dummy", Int32Ty);
@@ -101,7 +101,7 @@
  Constant::getAllOnesValue(Int32Ty), "var", nullptr,
  GlobalVariable::NotThreadLocal, 1);
 
-  EXPECT_DEATH(Var->setAlignment(Align(1073741824U)),
+  EXPECT_DEATH(Var->setAlignment(Align(2147483648U)),
"Alignment is greater than MaximumAlignment");
 }
 #endif
Index: llvm/test/Verifier/align-md.ll
===
--- llvm/test/Verifier/align-md.ll
+++ llvm/test/Verifier/align-md.ll
@@ -52,8 +52,8 @@
 
 define i8* @f7(i8** %x) {
 entry:
-  %y = load i8*, i8** %x, !align !{i64 1073741824}
+  %y = load i8*, i8** %x, !align !{i64 2147483648}
   ret i8* %y
 }
 ; CHECK: alignment is larger that implementation defined limit
-; CHECK-NEXT: load i8*, i8** %x
\ No newline at end of file
+; CHECK-NEXT: load i8*, i8** %x
Index: llvm/test/Transforms/OpenMP/parallel_level_fold.ll
===
--- llvm/test/Transforms/OpenMP/parallel_level_fold.ll
+++ llvm/test/Transforms/OpenMP/parallel_level_fold.ll
@@ -49,9 +49,9 @@
 
 define weak void @parallel() {
 ; CHECK-LABEL: define {{[^@]+}}@parallel() {
-; CHECK-NEXT:[[I:%.*]] = call i32 @__kmpc_target_init(%struct.ident_t* align 536870912 null, i1 true, i1 false, i1 false)
+; CHECK-NEXT:[[I:%.*]] = call i32 @__kmpc_target_init(%struct.ident_t* align 1073741824 null, i1 true, i1 false, i1 false)
 ; CHECK-NEXT:call void @spmd_helper()
-; CHECK-NEXT:call void @__kmpc_parallel_51(%struct.ident_t* noalias noundef align 536870912 null, i32 noundef 0, i32 noundef 0, i32 noundef 0, i32 noundef 0, i8* noalias noundef align 536870912 null, i8* noalias noundef align 536870912 null, i8** noalias noundef align 536870912 null, i64 noundef 0)
+; CHECK-NEX

[clang] b5088cb - [clang][deps] Ensure deterministic order of TU '-fmodule-file=' arguments

2021-08-25 Thread Jan Svoboda via cfe-commits

Author: Jan Svoboda
Date: 2021-08-25T11:14:16+02:00
New Revision: b5088cb408222eba4611e6121293166904ca48e6

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

LOG: [clang][deps] Ensure deterministic order of TU '-fmodule-file=' arguments

Translation units with multiple direct modular dependencies trigger a 
non-deterministic ordering in `clang-scan-deps`. This boils down to usage of 
`std::unordered_map`, which gets replaced by `std::map` in this patch.

Depends on D103526.

Reviewed By: dexonsmith

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

Added: 


Modified: 
clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
clang/test/ClangScanDeps/modules-pch.c

Removed: 




diff  --git a/clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp 
b/clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
index 2fd12f7e12b1..43b6a0c95f04 100644
--- a/clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
+++ b/clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
@@ -180,7 +180,7 @@ DependencyScanningTool::getFullDependencies(
   private:
 std::vector Dependencies;
 std::vector PrebuiltModuleDeps;
-std::unordered_map ClangModuleDeps;
+std::map ClangModuleDeps;
 std::string ContextHash;
 std::vector OutputPaths;
 const llvm::StringSet<> &AlreadySeen;

diff  --git a/clang/test/ClangScanDeps/modules-pch.c 
b/clang/test/ClangScanDeps/modules-pch.c
index b9b7ed7badd1..1f368f9e87fb 100644
--- a/clang/test/ClangScanDeps/modules-pch.c
+++ b/clang/test/ClangScanDeps/modules-pch.c
@@ -90,9 +90,9 @@
 // CHECK-PCH-NEXT:   "command-line": [
 // CHECK-PCH-NEXT: "-fno-implicit-modules",
 // CHECK-PCH-NEXT: "-fno-implicit-module-maps",
-// CHECK-PCH-DAG:  
"-fmodule-file=[[PREFIX]]/build/[[HASH_MOD_COMMON_1]]/ModCommon1-{{.*}}.pcm",
-// CHECK-PCH-DAG:  
"-fmodule-file=[[PREFIX]]/build/[[HASH_MOD_COMMON_2]]/ModCommon2-{{.*}}.pcm",
-// CHECK-PCH-DAG:  
"-fmodule-file=[[PREFIX]]/build/[[HASH_MOD_PCH]]/ModPCH-{{.*}}.pcm",
+// CHECK-PCH-NEXT: 
"-fmodule-file=[[PREFIX]]/build/[[HASH_MOD_COMMON_1]]/ModCommon1-{{.*}}.pcm",
+// CHECK-PCH-NEXT: 
"-fmodule-file=[[PREFIX]]/build/[[HASH_MOD_COMMON_2]]/ModCommon2-{{.*}}.pcm",
+// CHECK-PCH-NEXT: 
"-fmodule-file=[[PREFIX]]/build/[[HASH_MOD_PCH]]/ModPCH-{{.*}}.pcm",
 // CHECK-PCH-NEXT: "-fmodule-map-file=[[PREFIX]]/module.modulemap",
 // CHECK-PCH-NEXT: "-fmodule-map-file=[[PREFIX]]/module.modulemap",
 // CHECK-PCH-NEXT: "-fmodule-map-file=[[PREFIX]]/module.modulemap"



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


[PATCH] D103807: [clang][deps] Ensure deterministic order of TU '-fmodule-file=' arguments

2021-08-25 Thread Jan Svoboda 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 rGb5088cb40822: [clang][deps] Ensure deterministic order of TU 
'-fmodule-file=' arguments (authored by jansvoboda11).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103807

Files:
  clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
  clang/test/ClangScanDeps/modules-pch.c


Index: clang/test/ClangScanDeps/modules-pch.c
===
--- clang/test/ClangScanDeps/modules-pch.c
+++ clang/test/ClangScanDeps/modules-pch.c
@@ -90,9 +90,9 @@
 // CHECK-PCH-NEXT:   "command-line": [
 // CHECK-PCH-NEXT: "-fno-implicit-modules",
 // CHECK-PCH-NEXT: "-fno-implicit-module-maps",
-// CHECK-PCH-DAG:  
"-fmodule-file=[[PREFIX]]/build/[[HASH_MOD_COMMON_1]]/ModCommon1-{{.*}}.pcm",
-// CHECK-PCH-DAG:  
"-fmodule-file=[[PREFIX]]/build/[[HASH_MOD_COMMON_2]]/ModCommon2-{{.*}}.pcm",
-// CHECK-PCH-DAG:  
"-fmodule-file=[[PREFIX]]/build/[[HASH_MOD_PCH]]/ModPCH-{{.*}}.pcm",
+// CHECK-PCH-NEXT: 
"-fmodule-file=[[PREFIX]]/build/[[HASH_MOD_COMMON_1]]/ModCommon1-{{.*}}.pcm",
+// CHECK-PCH-NEXT: 
"-fmodule-file=[[PREFIX]]/build/[[HASH_MOD_COMMON_2]]/ModCommon2-{{.*}}.pcm",
+// CHECK-PCH-NEXT: 
"-fmodule-file=[[PREFIX]]/build/[[HASH_MOD_PCH]]/ModPCH-{{.*}}.pcm",
 // CHECK-PCH-NEXT: "-fmodule-map-file=[[PREFIX]]/module.modulemap",
 // CHECK-PCH-NEXT: "-fmodule-map-file=[[PREFIX]]/module.modulemap",
 // CHECK-PCH-NEXT: "-fmodule-map-file=[[PREFIX]]/module.modulemap"
Index: clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
===
--- clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
+++ clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
@@ -180,7 +180,7 @@
   private:
 std::vector Dependencies;
 std::vector PrebuiltModuleDeps;
-std::unordered_map ClangModuleDeps;
+std::map ClangModuleDeps;
 std::string ContextHash;
 std::vector OutputPaths;
 const llvm::StringSet<> &AlreadySeen;


Index: clang/test/ClangScanDeps/modules-pch.c
===
--- clang/test/ClangScanDeps/modules-pch.c
+++ clang/test/ClangScanDeps/modules-pch.c
@@ -90,9 +90,9 @@
 // CHECK-PCH-NEXT:   "command-line": [
 // CHECK-PCH-NEXT: "-fno-implicit-modules",
 // CHECK-PCH-NEXT: "-fno-implicit-module-maps",
-// CHECK-PCH-DAG:  "-fmodule-file=[[PREFIX]]/build/[[HASH_MOD_COMMON_1]]/ModCommon1-{{.*}}.pcm",
-// CHECK-PCH-DAG:  "-fmodule-file=[[PREFIX]]/build/[[HASH_MOD_COMMON_2]]/ModCommon2-{{.*}}.pcm",
-// CHECK-PCH-DAG:  "-fmodule-file=[[PREFIX]]/build/[[HASH_MOD_PCH]]/ModPCH-{{.*}}.pcm",
+// CHECK-PCH-NEXT: "-fmodule-file=[[PREFIX]]/build/[[HASH_MOD_COMMON_1]]/ModCommon1-{{.*}}.pcm",
+// CHECK-PCH-NEXT: "-fmodule-file=[[PREFIX]]/build/[[HASH_MOD_COMMON_2]]/ModCommon2-{{.*}}.pcm",
+// CHECK-PCH-NEXT: "-fmodule-file=[[PREFIX]]/build/[[HASH_MOD_PCH]]/ModPCH-{{.*}}.pcm",
 // CHECK-PCH-NEXT: "-fmodule-map-file=[[PREFIX]]/module.modulemap",
 // CHECK-PCH-NEXT: "-fmodule-map-file=[[PREFIX]]/module.modulemap",
 // CHECK-PCH-NEXT: "-fmodule-map-file=[[PREFIX]]/module.modulemap"
Index: clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
===
--- clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
+++ clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
@@ -180,7 +180,7 @@
   private:
 std::vector Dependencies;
 std::vector PrebuiltModuleDeps;
-std::unordered_map ClangModuleDeps;
+std::map ClangModuleDeps;
 std::string ContextHash;
 std::vector OutputPaths;
 const llvm::StringSet<> &AlreadySeen;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D105462: [X86] Add CRC32 feature.

2021-08-25 Thread Wang Tianqing via Phabricator via cfe-commits
tianqing updated this revision to Diff 368589.
tianqing added a comment.

- Update behavior of -msse4.2 option.
- Add test for -msse4.2 and -mno-crc32.
- Fix some format error.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105462

Files:
  clang/docs/ClangCommandLineReference.rst
  clang/include/clang/Basic/BuiltinsX86.def
  clang/include/clang/Basic/BuiltinsX86_64.def
  clang/include/clang/Driver/Options.td
  clang/lib/Basic/Targets/X86.cpp
  clang/lib/Basic/Targets/X86.h
  clang/lib/Headers/CMakeLists.txt
  clang/lib/Headers/crc32intrin.h
  clang/lib/Headers/ia32intrin.h
  clang/lib/Headers/immintrin.h
  clang/lib/Headers/smmintrin.h
  clang/lib/Headers/x86gprintrin.h
  clang/test/CodeGen/X86/x86-crc-builtins.c
  clang/test/CodeGen/attr-cpuspecific.c
  clang/test/CodeGen/attr-target-crc32-x86.c
  clang/test/CodeGen/attr-target-x86.c
  clang/test/Driver/x86-mcrc32.c
  clang/test/Driver/x86-mgeneral-regs-only-crc32.c
  clang/test/Driver/x86-target-features.c
  clang/test/Preprocessor/x86_target_features.c
  llvm/include/llvm/Support/X86TargetParser.def
  llvm/lib/Support/Host.cpp
  llvm/lib/Support/X86TargetParser.cpp
  llvm/lib/Target/X86/X86.td
  llvm/lib/Target/X86/X86InstrFormats.td
  llvm/lib/Target/X86/X86InstrInfo.td
  llvm/lib/Target/X86/X86InstrSSE.td
  llvm/lib/Target/X86/X86Subtarget.h
  llvm/test/CodeGen/X86/crc32-intrinsics-fast-isel-x86_64.ll
  llvm/test/CodeGen/X86/crc32-intrinsics-x86.ll
  llvm/test/CodeGen/X86/crc32-intrinsics-x86_64.ll
  llvm/test/CodeGen/X86/crc32-target-feature.ll
  llvm/test/CodeGen/X86/function-subtarget-features.ll
  llvm/test/CodeGen/X86/sse42-intrinsics-fast-isel-x86_64.ll
  llvm/test/CodeGen/X86/sse42-intrinsics-fast-isel.ll
  llvm/test/CodeGen/X86/sse42-intrinsics-x86.ll
  llvm/test/CodeGen/X86/sse42-intrinsics-x86_64.ll
  llvm/test/CodeGen/X86/stack-folding-int-sse42.ll

Index: llvm/test/CodeGen/X86/stack-folding-int-sse42.ll
===
--- llvm/test/CodeGen/X86/stack-folding-int-sse42.ll
+++ llvm/test/CodeGen/X86/stack-folding-int-sse42.ll
@@ -1,5 +1,5 @@
 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
-; RUN: llc -O3 -disable-peephole -mtriple=x86_64-unknown-unknown -mattr=+sse4.2,+aes,+pclmul < %s | FileCheck %s
+; RUN: llc -O3 -disable-peephole -mtriple=x86_64-unknown-unknown -mattr=+sse4.2,+aes,+crc32,+pclmul < %s | FileCheck %s
 
 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
 target triple = "x86_64-unknown-unknown"
Index: llvm/test/CodeGen/X86/sse42-intrinsics-x86.ll
===
--- llvm/test/CodeGen/X86/sse42-intrinsics-x86.ll
+++ llvm/test/CodeGen/X86/sse42-intrinsics-x86.ll
@@ -1,10 +1,12 @@
 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
-; RUN: llc < %s -disable-peephole -mtriple=i386-apple-darwin -mattr=+sse4.2 -show-mc-encoding | FileCheck %s --check-prefixes=X86,SSE,X86-SSE
-; RUN: llc < %s -disable-peephole -mtriple=i386-apple-darwin -mattr=+avx -show-mc-encoding | FileCheck %s --check-prefixes=X86,AVX,X86-AVX,X86-AVX1
-; RUN: llc < %s -disable-peephole -mtriple=i386-apple-darwin -mattr=+avx512f,+avx512bw,+avx512dq,+avx512vl -show-mc-encoding | FileCheck %s --check-prefixes=X86,AVX,X86-AVX,X86-AVX512
-; RUN: llc < %s -disable-peephole -mtriple=x86_64-apple-darwin -mattr=+sse4.2 -show-mc-encoding | FileCheck %s --check-prefixes=X64,SSE,X64-SSE
-; RUN: llc < %s -disable-peephole -mtriple=x86_64-apple-darwin -mattr=+avx -show-mc-encoding | FileCheck %s --check-prefixes=X64,AVX,X64-AVX,X64-AVX1
-; RUN: llc < %s -disable-peephole -mtriple=x86_64-apple-darwin -mattr=+avx512f,+avx512bw,+avx512dq,+avx512vl -show-mc-encoding | FileCheck %s --check-prefixes=X64,AVX,X64-AVX,X64-AVX512
+; RUN: llc < %s -disable-peephole -mtriple=i386-apple-darwin -mattr=+sse4.2 -show-mc-encoding | FileCheck %s --check-prefixes=SSE,X86-SSE
+; RUN: llc < %s -disable-peephole -mtriple=i386-apple-darwin -mattr=+sse4.2,-crc32 -show-mc-encoding | FileCheck %s --check-prefixes=SSE,X86-SSE
+; RUN: llc < %s -disable-peephole -mtriple=i386-apple-darwin -mattr=+avx -show-mc-encoding | FileCheck %s --check-prefixes=AVX,X86-AVX,X86-AVX1
+; RUN: llc < %s -disable-peephole -mtriple=i386-apple-darwin -mattr=+avx512f,+avx512bw,+avx512dq,+avx512vl -show-mc-encoding | FileCheck %s --check-prefixes=AVX,X86-AVX,X86-AVX512
+; RUN: llc < %s -disable-peephole -mtriple=x86_64-apple-darwin -mattr=+sse4.2 -show-mc-encoding | FileCheck %s --check-prefixes=SSE,X64-SSE
+; RUN: llc < %s -disable-peephole -mtriple=x86_64-apple-darwin -mattr=+sse4.2,-crc32 -show-mc-encoding | FileCheck %s --check-prefixes=SSE,X64-SSE
+; RUN: llc < %s -disable-peephole -mtriple=x86_64-apple-darwin -mattr=+avx -show-mc-encoding | FileCheck %s --check-prefixes=AVX,X64-AVX,X64-AVX1
+; RUN: llc < %s -disable-peephole -mtriple=x86_64-apple-darwin -mattr=+av

[PATCH] D105462: [X86] Add CRC32 feature.

2021-08-25 Thread Wang Tianqing via Phabricator via cfe-commits
tianqing marked 2 inline comments as done.
tianqing added inline comments.



Comment at: clang/lib/Headers/crc32intrin.h:31
+static __inline__ unsigned int __DEFAULT_FN_ATTRS
+_mm_crc32_u8(unsigned int __C, unsigned char __D)
+{

pengfei wrote:
> ditto.
Not sure about this one. We've been consistently using this brace placement in 
intrinsic headers.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105462

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


[PATCH] D108621: [HIPSPV] Add CUDA->SPIR-V address space mapping

2021-08-25 Thread Alexey Bader via Phabricator via cfe-commits
bader accepted this revision.
bader added a comment.
This revision is now accepted and ready to land.

LGTM.




Comment at: clang/lib/Basic/Targets/SPIR.h:146
+// See comment on the SPIRDefIsGenMap table.
+bool IsHIPSPV = Opts.HIP && Opts.CUDAIsDevice;
 // FIXME: SYCL specification considers unannotated pointers and references

Minor: in my opinion, Opts.HIP check is unnecessary. I don't think CUDA can be 
compiled to SPIR target today, but when this flow is enabled I think it should 
set `DefaultIsGeneric` flag the same way as HIP.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108621

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


[PATCH] D108621: [HIPSPV] Add CUDA->SPIR-V address space mapping

2021-08-25 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added inline comments.



Comment at: clang/lib/Basic/Targets/SPIR.h:59
+// translation). This mapping is enabled when the language mode is HIP.
+1, // cuda_device
+// cuda_constant pointer can be casted to default/"flat" pointer, but in

I am slightly confused as in the LLVM project those address spaces are for SPIR 
not SPIR-V though. It is however used outside of LLVM project by some tools 
like SPIRV-LLVM Translator as a path to SPIR-V, but it has only been done as a 
workaround since we had no SPIR-V support in the LLVM project yet. And if we 
are adding it let's do it clean to avoid/resolve any confusion.

I think we need to keep both because some vendors do target/use SPIR but not 
SPIR-V.

So if you are interested in SPIR-V and not SPIR you should probably add a new 
target that will make things cleaner.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108621

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


[PATCH] D108367: [NFC] computeSPIRKernelABIInfo(): use SPIRABInfo

2021-08-25 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia accepted this revision.
Anastasia added a comment.
This revision is now accepted and ready to land.

LGTM! Thanks.

Do you think we can test this somehow?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108367

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


[PATCH] D108461: [OpenCL] Supports optional generic address space in C++ for OpenCL 2021

2021-08-25 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

In D108461#2960030 , @Topotuna wrote:

> `__opencl_c_generic_address_space` should not have been chosen as the first 
> feature to be addressed out of all OpenCL 3.0 optional core features. This is 
> because `__opencl_c_device_enqueue` has a dependency on this feature. I will 
> review the order in which OpenCL 3.0 optional features should be introduced 
> to C++ for OpenCL 2021 and return to this revision when all dependencies are 
> resolved.

Ok, although it makes sense to add generic address space as multiple other 
features depend on this and we can unblock more work. Also I think 
`__opencl_c_device_enqueue` is being worked on by someone already but it is 
still not complete.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108461

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


[PATCH] D108392: [OpenCL] Fix parsing of opencl-c.h in CL 3.0 with device-scope atomics enabled

2021-08-25 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a subscriber: azabaznov.
Anastasia added inline comments.



Comment at: clang/include/clang/Basic/OpenCLExtensions.def:113
 OPENCL_OPTIONALCOREFEATURE(__opencl_c_atomic_order_seq_cst, false, 300, 
OCL_C_30)
+OPENCL_OPTIONALCOREFEATURE(__opencl_c_atomic_scope_device, false, 300, 
OCL_C_30)
+OPENCL_OPTIONALCOREFEATURE(__opencl_c_atomic_scope_all_devices, false, 300, 
OCL_C_30)

Do we need to add anything to clang for those features? If not they should just 
go into the headers, see guidelines 
https://clang.llvm.org/docs/OpenCLSupport.html#implementation-guidelines

CC @azabaznov 



Comment at: clang/lib/Headers/opencl-c.h:13381
 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 *object, int operand);

This is a fairly trivial fix. You can just commit it straight away if you like. 
:)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108392

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


[PATCH] D108692: [clang-format] Support TypeScript override keyword

2021-08-25 Thread Jan Kühle via Phabricator via cfe-commits
jankuehle created this revision.
jankuehle requested review of this revision.
Herald added a project: clang.

TypeScript 4.3 added a new "override" keyword for class members. This
lets clang-format know about it, so it can format code using it
properly.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D108692

Files:
  clang/lib/Format/FormatToken.h
  clang/lib/Format/TokenAnnotator.cpp
  clang/lib/Format/UnwrappedLineFormatter.cpp
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/unittests/Format/FormatTestJS.cpp


Index: clang/unittests/Format/FormatTestJS.cpp
===
--- clang/unittests/Format/FormatTestJS.cpp
+++ clang/unittests/Format/FormatTestJS.cpp
@@ -854,6 +854,26 @@
"}\n");
 }
 
+TEST_F(FormatTestJS, OverriddenMembers) {
+  verifyFormat(
+  "class C extends P {\n"
+  "  protected override "
+  "anOverlyLongPropertyNameSoLongItHasToGoInASeparateLineWhenOverriden:\n"
+  "  undefined;\n"
+  "}\n");
+  verifyFormat(
+  "class C extends P {\n"
+  "  protected override "
+  "anOverlyLongMethodNameSoLongItHasToGoInASeparateLineWhenOverriden() {\n"
+  "  }\n"
+  "}\n");
+  verifyFormat("class C extends P {\n"
+   "  protected override aMethodName() {}\n"
+   "}\n");
+}
+
 TEST_F(FormatTestJS, FunctionParametersTrailingComma) {
   verifyFormat("function trailingComma(\n"
"p1,\n"
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -962,8 +962,8 @@
   Keywords.kw_function, Keywords.kw_import, Keywords.kw_is,
   Keywords.kw_let, Keywords.kw_var, tok::kw_const,
   Keywords.kw_abstract, Keywords.kw_extends, 
Keywords.kw_implements,
-  Keywords.kw_instanceof, Keywords.kw_interface, 
Keywords.kw_throws,
-  Keywords.kw_from));
+  Keywords.kw_instanceof, Keywords.kw_interface,
+  Keywords.kw_override, Keywords.kw_throws, Keywords.kw_from));
 }
 
 static bool mustBeJSIdentOrValue(const AdditionalKeywords &Keywords,
Index: clang/lib/Format/UnwrappedLineFormatter.cpp
===
--- clang/lib/Format/UnwrappedLineFormatter.cpp
+++ clang/lib/Format/UnwrappedLineFormatter.cpp
@@ -632,10 +632,11 @@
 FormatToken *RecordTok = Line.First;
 // Skip record modifiers.
 while (RecordTok->Next &&
-   RecordTok->isOneOf(
-   tok::kw_typedef, tok::kw_export, Keywords.kw_declare,
-   Keywords.kw_abstract, tok::kw_default, tok::kw_public,
-   tok::kw_private, tok::kw_protected, Keywords.kw_internal))
+   RecordTok->isOneOf(tok::kw_typedef, tok::kw_export,
+  Keywords.kw_declare, Keywords.kw_abstract,
+  tok::kw_default, Keywords.kw_override,
+  tok::kw_public, tok::kw_private,
+  tok::kw_protected, Keywords.kw_internal))
   RecordTok = RecordTok->Next;
 if (RecordTok &&
 RecordTok->isOneOf(tok::kw_class, tok::kw_union, tok::kw_struct,
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -3957,8 +3957,9 @@
 tok::kw_return, Keywords.kw_yield, tok::kw_continue, tok::kw_break,
 tok::kw_throw, Keywords.kw_interface, Keywords.kw_type,
 tok::kw_static, tok::kw_public, tok::kw_private, tok::kw_protected,
-Keywords.kw_readonly, Keywords.kw_abstract, Keywords.kw_get,
-Keywords.kw_set, Keywords.kw_async, Keywords.kw_await))
+Keywords.kw_readonly, Keywords.kw_override, Keywords.kw_abstract,
+Keywords.kw_get, Keywords.kw_set, Keywords.kw_async,
+Keywords.kw_await))
   return false; // Otherwise automatic semicolon insertion would trigger.
 if (Right.NestingLevel == 0 &&
 (Left.Tok.getIdentifierInfo() ||
Index: clang/lib/Format/FormatToken.h
===
--- clang/lib/Format/FormatToken.h
+++ clang/lib/Format/FormatToken.h
@@ -934,8 +934,8 @@
 // already initialized.
 JsExtraKeywords = std::unordered_set(
 {kw_as, kw_async, kw_await, kw_declare, kw_finally, kw_from,
- kw_function, kw_get, kw_import, kw_is, kw_let, kw_module, kw_readonly,
- kw_set, kw_type, kw_typeof, kw_var, kw_yield,
+ kw_function, kw_get, kw_import, kw_is, kw_let, kw_module, kw_override,
+ kw_readonly, kw_set, kw_type, kw_typeof, kw_var, kw_yield,
  // Keywords from the Java section.
  kw_abstra

[PATCH] D108693: [OpenCL] Defines helper function for kernel language compatible OpenCL version

2021-08-25 Thread Justas Janickas via Phabricator via cfe-commits
Topotuna created this revision.
Topotuna added a reviewer: Anastasia.
Herald added subscribers: ldrumm, dexonsmith, yaxunl.
Herald added a reviewer: aaron.ballman.
Topotuna requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This change defines a helper function getOpenCLCompatibleVersion()
inside LangOptions class. The function contains mapping between
C++ for OpenCL versions and their corresponding compatible OpenCL
versions. This mapping function should be updated each time a new
C++ for OpenCL language version is introduced. The helper function
is expected to simplify conditions on OpenCL C and C++ for OpenCL
versions inside compiler code.

Code refactoring performed.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D108693

Files:
  clang/include/clang/Basic/LangOptions.h
  clang/include/clang/Basic/OpenCLOptions.h
  clang/lib/Basic/Builtins.cpp
  clang/lib/Basic/LangOptions.cpp
  clang/lib/Basic/Targets.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Sema/DeclSpec.cpp
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaType.cpp

Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -1369,8 +1369,7 @@
 // value being declared, poison it as invalid so we don't get chains of
 // errors.
 declarator.setInvalidType(true);
-  } else if ((S.getLangOpts().OpenCLVersion >= 200 ||
-  S.getLangOpts().OpenCLCPlusPlus) &&
+  } else if (S.getLangOpts().getOpenCLCompatibleVersion() >= 200 &&
  DS.isTypeSpecPipe()) {
 S.Diag(DeclLoc, diag::err_missing_actual_pipe_type)
   << DS.getSourceRange();
@@ -5093,7 +5092,7 @@
 "__cl_clang_variadic_functions", S.getLangOpts()) &&
 !(D.getIdentifier() &&
   ((D.getIdentifier()->getName() == "printf" &&
-(LangOpts.OpenCLCPlusPlus || LangOpts.OpenCLVersion >= 120)) ||
+LangOpts.getOpenCLCompatibleVersion() >= 120) ||
D.getIdentifier()->getName().startswith("__" {
   S.Diag(D.getIdentifierLoc(), diag::err_opencl_variadic_function);
   D.setInvalidType(true);
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -12270,7 +12270,7 @@
 return computeResultTy();
   }
 
-  if (getLangOpts().OpenCLVersion >= 200 || getLangOpts().OpenCLCPlusPlus) {
+  if (getLangOpts().getOpenCLCompatibleVersion() >= 200) {
 if (LHSType->isClkEventT() && RHSType->isClkEventT()) {
   return computeResultTy();
 }
@@ -12529,8 +12529,9 @@
/*AllowBoolConversions*/false);
   if (vType.isNull())
 return InvalidOperands(Loc, LHS, RHS);
-  if (getLangOpts().OpenCL && getLangOpts().OpenCLVersion < 120 &&
-  !getLangOpts().OpenCLCPlusPlus && vType->hasFloatingRepresentation())
+  if (getLangOpts().OpenCL &&
+  getLangOpts().getOpenCLCompatibleVersion() < 120 &&
+  vType->hasFloatingRepresentation())
 return InvalidOperands(Loc, LHS, RHS);
   // FIXME: The check for C++ here is for GCC compatibility. GCC rejects the
   //usage of the logical operators && and || with vectors in C. This
@@ -14981,8 +14982,7 @@
   }
 } else if (resultType->isExtVectorType()) {
   if (Context.getLangOpts().OpenCL &&
-  Context.getLangOpts().OpenCLVersion < 120 &&
-  !Context.getLangOpts().OpenCLCPlusPlus) {
+  Context.getLangOpts().getOpenCLCompatibleVersion() < 120) {
 // OpenCL v1.1 6.3.h: The logical operator not (!) does not
 // operate on vector float types.
 QualType T = resultType->castAs()->getElementType();
Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -7488,7 +7488,7 @@
 }
 
 static void handleOpenCLNoSVMAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
-  if (S.LangOpts.OpenCLVersion < 200 && !S.LangOpts.OpenCLCPlusPlusVersion)
+  if (S.LangOpts.getOpenCLCompatibleVersion() < 200)
 S.Diag(AL.getLoc(), diag::err_attribute_requires_opencl_version)
 << AL << "2.0" << 1;
   else
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -8824,8 +8824,7 @@
 // OpenCL v3.0 s6.11.a:
 // A kernel function argument cannot be declared as a pointer to a pointer
 // type. [...] This restriction only applies to OpenCL C 1.2 or below.
-if (S.getLangOpts().OpenCLVersion <= 120 &&
-

[PATCH] D108692: [clang-format] Support TypeScript override keyword

2021-08-25 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir accepted this revision.
krasimir added a comment.
This revision is now accepted and ready to land.

Thank you!
Let me know if you would like me to commit this for you in case you don't have 
commit rights for LLVM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108692

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


[PATCH] D108643: Introduce _BitInt, deprecate _ExtInt

2021-08-25 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D108643#2964190 , @rjmccall wrote:

> I agree with James; I know you've reached out to the Itanium ABI group about 
> mangling, but ABI involvement needs to mean also reaching out and getting 
> psABI agreement about representation.  I would suggest proposing a generic 
> ABI, getting consensus on that generic ABI with other implementors, and then 
> running that generic ABI past as many platform ABI groups as you can get in 
> touch with.

I've already reached out to the psABI maintainers and have started those 
discussions before ever considering the mangling questions: 
https://gitlab.com/x86-psABIs/x86-64-ABI/-/commit/21622785649f2cbacb596d135a417171f52ad539
 Note that there are some changes expected to that wording (the "bit-aligned" 
stuff should say "byte-aligned" and we're missing information about 
bit-fields), so if there are additional changes we'd like to see made, now's a 
good time to make them.

If you have comments or concerns with what's proposed there, I can pass along 
feedback to H.J. about potential changes we'd like to see. However, once it's 
in psABI, I'm not certain what other platform ABI groups even exist -- that's a 
bit out of my wheelhouse, so help getting those discussions moving would be 
very much appreciated.

> I think the most logical generic ABI is:
>
> - Let `MaxFundamentalWidth` be the (target-chosen) bit-width of the largest 
> fundamental integer type that can be used to represent a `_BitInt`.  
> Typically this will be the largest integer type supported by the ABI, but 
> some targets may want to use a smaller limit.  At the very least, this needs 
> to be locked down in the ABI; the ABI for `_BitInt(256)` shouldn't change if 
> the ABI adds new support for  an `int256_t` type.
> - Let `chunk_t` be the (target-chosen) fundamental integer type that will be 
> used to store the components of a `_BitInt` that is wider than 
> `MaxFundamentalWidth`.  This should be an integer type that the architecture 
> comfortably supports overflow operations on, and it will typically be the 
> full width of a GPR.
> - Let `ChunkWidth` be defined as `CHAR_BITS * sizeof(chunk_t)`.
> - If `N < RepWidth(N)`, then signed/unsigned `_BitInt(N)` has the same 
> representation as `_BitInt(RepWidth(N))`, with the value held in the least 
> significant bits and sign/zero-extended to the full width.  Values must be in 
> the proper range of the original type; that is, it is undefined behavior if 
> e.g. a `signed _BitInt(7)` does not hold a value in the range of `-64 ..< 
> 63`.  Hereafter we will assume that `N == RepWidth(N)`.
> - If `N <= MaxFundamentalWidth`, then signed/unsigned `_BitInt(N)` has the 
> same representation as the smallest fundamental integer type (least rank, if 
> material) of at least `N` bits and the same signedness.  `_Bool` is not 
> considered in this selection.
> - Otherwise, signed/unsigned `_BitInt(N)` has the same representation as a 
> `struct` containing a single field of type `chunk_t[N / sizeof(chunk_t)]`, 
> where the element at index `i` stores bits `i*ChunkWidth ..< 
> (i+1)*ChunkWidth` of the integer.  That is, the array is always stored in 
> little-endian order, which should have better memory-access properties 
> regardless of the endianness of the target.  (The individual elements still 
> have natural host endianness, of course.)

I believe that's what's already been proposed for psABI, but if I've missed 
something, please let me know.

> Some targets that don't pass/return small structs efficiently as a matter of 
> course may want to treat smallish (but still non-fundamental) `_BitInt`s 
> specially in their calling convention.
>
> I think using a uniform, GPR-sized chunk makes more sense than trying to use 
> a smaller chunk that might eliminate some padding.  I could imagine that a 
> 64-bit platform that supports 32-bit overflow checking might consider 
> represent `_BitInt(96)` with three 32-bit chunks instead of two 64-bit 
> chunks, and that would indeed make an array of them pack better, but it would 
> also mean that e.g. addition would take three operations instead of two.
>
> You can't have bit-fields of `_BitInt` type, can you?  If people want that, 
> or want a truly packed `_BitInt` where `sizeof(_BitInt(56)) == 7`, it's going 
> to add a lot of complexity.

You can have bit-fields of _BitInt type (and we even tell you when you do dumb 
things with it https://godbolt.org/z/sTKKdb1o1), but I'm not seeing where the 
complexity comes in from that (there was a thought that referencing the 
existing bit-field wording with a mention about the width of _BitInts would be 
sufficient). But these are not truly packed -- `sizeof(_BitInt(56) == 8`.




Comment at: clang/include/clang/Basic/TargetInfo.h:581
   /// limitation is put into place for ABI reasons.
-  virtual bool hasExtIntType() const {
+  /// FIXME: _BitInt is a required type in C23, so there'

[PATCH] D106343: [OpenCL] Support cl_ext_float_atomics

2021-08-25 Thread Yang Haonan via Phabricator via cfe-commits
haonanya added a comment.

In D106343#2892946 , @Anastasia wrote:

> The extension spec seems to also mention `atomic_half`. Are planning to add 
> it too?

Hi, Anastasia. I also have some work to translate these atomic builtins on 
SPIRV currently, so I'd like to have another patch to add atomic_half later. 
Do you have any comments?
Thanks very much.


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

https://reviews.llvm.org/D106343

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


[PATCH] D108692: [clang-format] Support TypeScript override keyword

2021-08-25 Thread Jan Kühle via Phabricator via cfe-commits
jankuehle added a comment.

Thank you for the amazingly quick review, krasimir. I don't have commit access. 
So it would be great, if you could commit this for me.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108692

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


[clang] e708808 - [clang-format] Support TypeScript override keyword

2021-08-25 Thread Krasimir Georgiev via cfe-commits

Author: Jan Kuehle
Date: 2021-08-25T14:11:50+02:00
New Revision: e708808f875f58344ecaad66d9e6e167ca7ac90a

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

LOG: [clang-format] Support TypeScript override keyword

TypeScript 4.3 added a new "override" keyword for class members. This
lets clang-format know about it, so it can format code using it
properly.

Reviewed By: krasimir

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

Added: 


Modified: 
clang/lib/Format/FormatToken.h
clang/lib/Format/TokenAnnotator.cpp
clang/lib/Format/UnwrappedLineFormatter.cpp
clang/lib/Format/UnwrappedLineParser.cpp
clang/unittests/Format/FormatTestJS.cpp

Removed: 




diff  --git a/clang/lib/Format/FormatToken.h b/clang/lib/Format/FormatToken.h
index 0506cd554bcba..bbce27f799bc7 100644
--- a/clang/lib/Format/FormatToken.h
+++ b/clang/lib/Format/FormatToken.h
@@ -934,8 +934,8 @@ struct AdditionalKeywords {
 // already initialized.
 JsExtraKeywords = std::unordered_set(
 {kw_as, kw_async, kw_await, kw_declare, kw_finally, kw_from,
- kw_function, kw_get, kw_import, kw_is, kw_let, kw_module, kw_readonly,
- kw_set, kw_type, kw_typeof, kw_var, kw_yield,
+ kw_function, kw_get, kw_import, kw_is, kw_let, kw_module, kw_override,
+ kw_readonly, kw_set, kw_type, kw_typeof, kw_var, kw_yield,
  // Keywords from the Java section.
  kw_abstract, kw_extends, kw_implements, kw_instanceof, kw_interface});
 

diff  --git a/clang/lib/Format/TokenAnnotator.cpp 
b/clang/lib/Format/TokenAnnotator.cpp
index 703eced09d446..887f6e363db82 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -3957,8 +3957,9 @@ bool TokenAnnotator::canBreakBefore(const AnnotatedLine 
&Line,
 tok::kw_return, Keywords.kw_yield, tok::kw_continue, tok::kw_break,
 tok::kw_throw, Keywords.kw_interface, Keywords.kw_type,
 tok::kw_static, tok::kw_public, tok::kw_private, tok::kw_protected,
-Keywords.kw_readonly, Keywords.kw_abstract, Keywords.kw_get,
-Keywords.kw_set, Keywords.kw_async, Keywords.kw_await))
+Keywords.kw_readonly, Keywords.kw_override, Keywords.kw_abstract,
+Keywords.kw_get, Keywords.kw_set, Keywords.kw_async,
+Keywords.kw_await))
   return false; // Otherwise automatic semicolon insertion would trigger.
 if (Right.NestingLevel == 0 &&
 (Left.Tok.getIdentifierInfo() ||

diff  --git a/clang/lib/Format/UnwrappedLineFormatter.cpp 
b/clang/lib/Format/UnwrappedLineFormatter.cpp
index cca85c1074de5..2577aea3a480d 100644
--- a/clang/lib/Format/UnwrappedLineFormatter.cpp
+++ b/clang/lib/Format/UnwrappedLineFormatter.cpp
@@ -632,10 +632,11 @@ class LineJoiner {
 FormatToken *RecordTok = Line.First;
 // Skip record modifiers.
 while (RecordTok->Next &&
-   RecordTok->isOneOf(
-   tok::kw_typedef, tok::kw_export, Keywords.kw_declare,
-   Keywords.kw_abstract, tok::kw_default, tok::kw_public,
-   tok::kw_private, tok::kw_protected, Keywords.kw_internal))
+   RecordTok->isOneOf(tok::kw_typedef, tok::kw_export,
+  Keywords.kw_declare, Keywords.kw_abstract,
+  tok::kw_default, Keywords.kw_override,
+  tok::kw_public, tok::kw_private,
+  tok::kw_protected, Keywords.kw_internal))
   RecordTok = RecordTok->Next;
 if (RecordTok &&
 RecordTok->isOneOf(tok::kw_class, tok::kw_union, tok::kw_struct,

diff  --git a/clang/lib/Format/UnwrappedLineParser.cpp 
b/clang/lib/Format/UnwrappedLineParser.cpp
index 8487875064aa8..18dc5c4244706 100644
--- a/clang/lib/Format/UnwrappedLineParser.cpp
+++ b/clang/lib/Format/UnwrappedLineParser.cpp
@@ -962,8 +962,8 @@ static bool mustBeJSIdent(const AdditionalKeywords 
&Keywords,
   Keywords.kw_function, Keywords.kw_import, Keywords.kw_is,
   Keywords.kw_let, Keywords.kw_var, tok::kw_const,
   Keywords.kw_abstract, Keywords.kw_extends, 
Keywords.kw_implements,
-  Keywords.kw_instanceof, Keywords.kw_interface, 
Keywords.kw_throws,
-  Keywords.kw_from));
+  Keywords.kw_instanceof, Keywords.kw_interface,
+  Keywords.kw_override, Keywords.kw_throws, Keywords.kw_from));
 }
 
 static bool mustBeJSIdentOrValue(const AdditionalKeywords &Keywords,

diff  --git a/clang/unittests/Format/FormatTestJS.cpp 
b/clang/unittests/Format/FormatTestJS.cpp
index 311881dde273c..0c8329536 100644
--- a/clang/unittests/Format/FormatTestJS.cpp
+++ b/clang/unittests/Format/FormatTest

[PATCH] D108692: [clang-format] Support TypeScript override keyword

2021-08-25 Thread Krasimir Georgiev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe708808f875f: [clang-format] Support TypeScript override 
keyword (authored by jankuehle, committed by krasimir).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108692

Files:
  clang/lib/Format/FormatToken.h
  clang/lib/Format/TokenAnnotator.cpp
  clang/lib/Format/UnwrappedLineFormatter.cpp
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/unittests/Format/FormatTestJS.cpp


Index: clang/unittests/Format/FormatTestJS.cpp
===
--- clang/unittests/Format/FormatTestJS.cpp
+++ clang/unittests/Format/FormatTestJS.cpp
@@ -854,6 +854,26 @@
"}\n");
 }
 
+TEST_F(FormatTestJS, OverriddenMembers) {
+  verifyFormat(
+  "class C extends P {\n"
+  "  protected override "
+  "anOverlyLongPropertyNameSoLongItHasToGoInASeparateLineWhenOverriden:\n"
+  "  undefined;\n"
+  "}\n");
+  verifyFormat(
+  "class C extends P {\n"
+  "  protected override "
+  "anOverlyLongMethodNameSoLongItHasToGoInASeparateLineWhenOverriden() {\n"
+  "  }\n"
+  "}\n");
+  verifyFormat("class C extends P {\n"
+   "  protected override aMethodName() {}\n"
+   "}\n");
+}
+
 TEST_F(FormatTestJS, FunctionParametersTrailingComma) {
   verifyFormat("function trailingComma(\n"
"p1,\n"
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -962,8 +962,8 @@
   Keywords.kw_function, Keywords.kw_import, Keywords.kw_is,
   Keywords.kw_let, Keywords.kw_var, tok::kw_const,
   Keywords.kw_abstract, Keywords.kw_extends, 
Keywords.kw_implements,
-  Keywords.kw_instanceof, Keywords.kw_interface, 
Keywords.kw_throws,
-  Keywords.kw_from));
+  Keywords.kw_instanceof, Keywords.kw_interface,
+  Keywords.kw_override, Keywords.kw_throws, Keywords.kw_from));
 }
 
 static bool mustBeJSIdentOrValue(const AdditionalKeywords &Keywords,
Index: clang/lib/Format/UnwrappedLineFormatter.cpp
===
--- clang/lib/Format/UnwrappedLineFormatter.cpp
+++ clang/lib/Format/UnwrappedLineFormatter.cpp
@@ -632,10 +632,11 @@
 FormatToken *RecordTok = Line.First;
 // Skip record modifiers.
 while (RecordTok->Next &&
-   RecordTok->isOneOf(
-   tok::kw_typedef, tok::kw_export, Keywords.kw_declare,
-   Keywords.kw_abstract, tok::kw_default, tok::kw_public,
-   tok::kw_private, tok::kw_protected, Keywords.kw_internal))
+   RecordTok->isOneOf(tok::kw_typedef, tok::kw_export,
+  Keywords.kw_declare, Keywords.kw_abstract,
+  tok::kw_default, Keywords.kw_override,
+  tok::kw_public, tok::kw_private,
+  tok::kw_protected, Keywords.kw_internal))
   RecordTok = RecordTok->Next;
 if (RecordTok &&
 RecordTok->isOneOf(tok::kw_class, tok::kw_union, tok::kw_struct,
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -3957,8 +3957,9 @@
 tok::kw_return, Keywords.kw_yield, tok::kw_continue, tok::kw_break,
 tok::kw_throw, Keywords.kw_interface, Keywords.kw_type,
 tok::kw_static, tok::kw_public, tok::kw_private, tok::kw_protected,
-Keywords.kw_readonly, Keywords.kw_abstract, Keywords.kw_get,
-Keywords.kw_set, Keywords.kw_async, Keywords.kw_await))
+Keywords.kw_readonly, Keywords.kw_override, Keywords.kw_abstract,
+Keywords.kw_get, Keywords.kw_set, Keywords.kw_async,
+Keywords.kw_await))
   return false; // Otherwise automatic semicolon insertion would trigger.
 if (Right.NestingLevel == 0 &&
 (Left.Tok.getIdentifierInfo() ||
Index: clang/lib/Format/FormatToken.h
===
--- clang/lib/Format/FormatToken.h
+++ clang/lib/Format/FormatToken.h
@@ -934,8 +934,8 @@
 // already initialized.
 JsExtraKeywords = std::unordered_set(
 {kw_as, kw_async, kw_await, kw_declare, kw_finally, kw_from,
- kw_function, kw_get, kw_import, kw_is, kw_let, kw_module, kw_readonly,
- kw_set, kw_type, kw_typeof, kw_var, kw_yield,
+ kw_function, kw_get, kw_import, kw_is, kw_let, kw_module, kw_override,
+ kw_readonly, kw_set, kw_type, kw_typeof, kw_var, kw_yield,
  // Keywords from the Java section.

[PATCH] D108695: [analyzer][NFCI] Allow clients of NoStateChangeFuncVisitor to check entire function calls, rather than each ExplodedNode in it

2021-08-25 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus created this revision.
Szelethus added reviewers: NoQ, martong, balazske, vsavchenko, steakhal, 
ASDenysPetrov.
Szelethus added a project: clang.
Herald added subscribers: manas, gamesh411, dkrupp, donat.nagy, 
mikhail.ramalho, a.sidorin, rnkovacs, szepet, baloghadamsoftware, xazax.hun, 
whisperity.
Szelethus requested review of this revision.
Herald added subscribers: cfe-commits, aheejin.

D105553  added NoStateChangeFuncVisitor, an 
abstract class to aid in creating notes such as "Returning without writing to 
'x'", or "Returning without changing the ownership status of allocated memory". 
Its clients need to define, among other things, what a change of state is.

For code like this:

  f() {
g();
  }
  
  foo() {
f();
h();
  }

We'd have a path in the `ExplodedGraph` that looks like this:

   --  -->
  /  \   
   --- >---  --->
  /\  /\
   -- -->

When we're interested in whether `f` neglected to change some property, 
`NoStateChangeFuncVisitor` asks these questions:

 ÷×~ 
  --  -->
 ß   /  \$@&#*   
  --- >---  --->
 /\  /\
  -- -->
  
 
  Has anything changed in between # and *?
  Has anything changed in between & and *?
  Has anything changed in between @ and *?
  ...
  Has anything changed in between $ and *?
  Has anything changed in between × and ~?
  Has anything changed in between ÷ and ~?
  ...
  Has anything changed in between ß and *?
  ...

This is a rather thorough line of questioning, which is why in D105819 
, I was only interested in whether state 
*right before* and *right after* a function call changed, and early returned to 
the `CallEnter` location:

  if (!CurrN->getLocationAs())
return;

Except that I made a typo, and forgot to negate the condition. So, in this 
patch, I'm fixing that, and under the same hood allow all clients to decide to 
do this whole-function check instead of the thorough one.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D108695

Files:
  clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h
  clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
  clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp

Index: clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
===
--- clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
+++ clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
@@ -355,43 +355,70 @@
   return FramesModifying.count(SCtx);
 }
 
+void NoStateChangeFuncVisitor::markFrameAsModifying(
+const StackFrameContext *SCtx) {
+  while (!SCtx->inTopFrame()) {
+auto p = FramesModifying.insert(SCtx);
+if (!p.second)
+  break; // Frame and all its parents already inserted.
+SCtx = SCtx->getParent()->getStackFrame();
+  }
+}
+
+static const ExplodedNode *getCallExitEnd(const ExplodedNode *N) {
+  while (N && !N->getLocationAs())
+N = N->getFirstSucc();
+  return N;
+}
+
 void NoStateChangeFuncVisitor::findModifyingFrames(
 const ExplodedNode *const CallExitBeginN) {
 
   assert(CallExitBeginN->getLocationAs());
-  const ExplodedNode *LastReturnN = CallExitBeginN;
+
   const StackFrameContext *const OriginalSCtx =
   CallExitBeginN->getLocationContext()->getStackFrame();
 
   const ExplodedNode *CurrN = CallExitBeginN;
-
-  do {
-ProgramStateRef State = CurrN->getState();
-auto CallExitLoc = CurrN->getLocationAs();
-if (CallExitLoc) {
-  LastReturnN = CurrN;
+  const ExplodedNode *CurrCallExitBeginN = CallExitBeginN;
+  const StackFrameContext *CurrentSCtx = OriginalSCtx;
+
+  while (CurrN) {
+// Found a new inlined call.
+if (CurrN->getLocationAs()) {
+  CurrCallExitBeginN = CurrN;
+  CurrentSCtx = CurrN->getStackFrame();
+  FramesModifyingCalculated.insert(CurrentSCtx);
+  // We won't see a change in between two identical exploded nodes: skip.
+  CurrN = CurrN->getFirstPred();
+  continue;
 }
 
-FramesModifyingCalculated.insert(
-CurrN->getLocationContext()->getStackFrame());
-
-if (wasModifiedBeforeCallExit(CurrN, LastReturnN)) {
-  const StackFrameContext *SCtx = CurrN->getStackFrame();
-  while (!SCtx->inTopFrame()) {
-auto p = FramesModifying.insert(SCtx);
-if (!p.second)
-  break; // Frame and all its parents already inserted.
-SCtx = SCtx->getParent()->getStackFrame();
+if (auto CE = CurrN->getLocationAs()) {
+  if (const ExplodedNode *CallExitEndN = getCallExitEnd(CurrCallExitBeginN))
+if (wasModifiedInFunction(CurrN, CallEx

[PATCH] D108692: [clang-format] Support TypeScript override keyword

2021-08-25 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

Thanks for adding this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108692

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


[PATCH] D108695: [analyzer][NFCI] Allow clients of NoStateChangeFuncVisitor to check entire function calls, rather than each ExplodedNode in it

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

I also added new dump methods -- I had a trouble before realizing that 
`CallEnter`'s stack frame is actually the *caller's*, not the *callee's* stack 
frame. Changes in `findModifyingFrames` aim to make the function more readable, 
and make sure that the correct stack frame will be marked as modifying.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108695

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


[PATCH] D108615: [Coroutines] [libcxx] Move coroutine component out of experimental namespace

2021-08-25 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu abandoned this revision.
ChuanqiXu added a comment.

Oh, I find why the CI still fails. Since the compiler used to compile libcxx in 
the CI doesn't contain the change in this patch! So it would still lookup 
coroutine components in std::experimental namespace. So here are the failures. 
To avoid the problems, I had split this patch into D108696 
 and D108697 
, which contains the change in clang part and 
libcxx part respectively.


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

https://reviews.llvm.org/D108615

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


[PATCH] D108482: [Clang] Fix instantiation of OpaqueValueExprs (Bug #45964)

2021-08-25 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a reviewer: rsmith.
aaron.ballman added inline comments.



Comment at: clang/lib/Sema/SemaInit.cpp:8646
   Expr *Cur = CurInit.get();
-  Expr *BaseExpr = new (S.Context)
-  OpaqueValueExpr(Cur->getExprLoc(), Cur->getType(),
-  Cur->getValueKind(), Cur->getObjectKind(), Cur);
+  // prevent nested OpaqueValueExprs
+  Expr *BaseExpr = dyn_cast(Cur);





Comment at: clang/lib/Sema/TreeTransform.h:10515
+
+  // Note that SourceExpr can be nullptr
+  ExprResult SourceExpr = TransformExpr(E->getSourceExpr());





Comment at: clang/lib/Sema/TreeTransform.h:10519-10521
+  if (SourceExpr.get() == E->getSourceExpr() && !getDerived().AlwaysRebuild()) 
{
+return E;
+  }





Comment at: clang/test/SemaCXX/pr45964-nested-ove.cpp:1
+// RUN: %clang_cc1 -std=c++17 -emit-codegen-only -verify %s
+// Don't crash (Bugzilla - Bug 45964).

I think this test should live in CodeGenCXX rather than SemaCXX as it's testing 
codegen stuff (and rather than discarding the output, I'd recommend checking 
the output with `FileCheck` to verify that it looks valid).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108482

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


[PATCH] D108302: [PowerPC] Fixed the crash due to early if conversion with fixed CR fields.

2021-08-25 Thread Lei Huang via Phabricator via cfe-commits
lei requested changes to this revision.
lei added a comment.
This revision now requires changes to proceed.

I think there is something wrong with this diff cause there is no context 
available for `PPCInstrInfo.cpp`.




Comment at: llvm/lib/Target/PowerPC/PPCInstrInfo.cpp:1548
+return false;
+  }
+

nit: no need for braces 



Comment at: llvm/test/CodeGen/PowerPC/ifcvt_cr_field.ll:2
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc < %s -mtriple=powerpc64-unknown-linux-gnu -mcpu=pwr7 
-verify-machineinstrs | FileCheck %s
+target datalayout = 
"E-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-f128:128:128-v128:128:128-n32:64"

I believe this affects AIX as well.  


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108302

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


[PATCH] D108643: Introduce _BitInt, deprecate _ExtInt

2021-08-25 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D108643#2964740 , @aaron.ballman 
wrote:

> I've already reached out to the psABI maintainers and have started those 
> discussions before ever considering the mangling questions: 
> https://gitlab.com/x86-psABIs/x86-64-ABI/-/commit/21622785649f2cbacb596d135a417171f52ad539
>  Note that there are some changes expected to that wording (the "bit-aligned" 
> stuff should say "byte-aligned" and we're missing information about 
> bit-fields), so if there are additional changes we'd like to see made, now's 
> a good time to make them.

Btw, the psABI discussion thread can be found at: 
https://groups.google.com/g/x86-64-abi/c/XQiSj-zU3w8 and the latest version of 
the patch corrected the issues I mentioned.


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

https://reviews.llvm.org/D108643

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


[PATCH] D107775: [Clang][AST] Resolve FIXME: Remove ObjCObjectPointer from isSpecifierType

2021-08-25 Thread David Goldman via Phabricator via cfe-commits
dgoldman added a comment.

Does this change the behavior of TypePrinter or DeclPrinter - not sure if there 
are existing tests for those with ObjC code?


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

https://reviews.llvm.org/D107775

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


[clang] 360ced3 - [analyzer] Ignore IncompleteArrayTypes in getStaticSize() for FAMs

2021-08-25 Thread Balazs Benics via cfe-commits

Author: Balazs Benics
Date: 2021-08-25T16:12:17+02:00
New Revision: 360ced3b8fd2cfb9f2a26deb739e6c381e98b9a5

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

LOG: [analyzer] Ignore IncompleteArrayTypes in getStaticSize() for FAMs

Currently only `ConstantArrayType` is considered for flexible array
members (FAMs) in `getStaticSize()`.
However, `IncompleteArrayType` also shows up in practice as FAMs.

This patch will ignore the `IncompleteArrayType` and return Unknown
for that case as well. This way it will be at least consistent with
the current behavior until we start modeling them accurately.

I'm expecting that this will resolve a bunch of false-positives
internally, caused by the `ArrayBoundV2`.

Reviewed By: ASDenysPetrov

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

Added: 
clang/test/Analysis/flexible-array-members.c

Modified: 
clang/lib/StaticAnalyzer/Core/MemRegion.cpp

Removed: 




diff  --git a/clang/lib/StaticAnalyzer/Core/MemRegion.cpp 
b/clang/lib/StaticAnalyzer/Core/MemRegion.cpp
index bd725ee9eaa3..1a614d4d2bcd 100644
--- a/clang/lib/StaticAnalyzer/Core/MemRegion.cpp
+++ b/clang/lib/StaticAnalyzer/Core/MemRegion.cpp
@@ -768,14 +768,27 @@ DefinedOrUnknownSVal 
MemRegionManager::getStaticSize(const MemRegion *MR,
   return UnknownVal();
 
 QualType Ty = cast(SR)->getDesugaredValueType(Ctx);
-DefinedOrUnknownSVal Size = getElementExtent(Ty, SVB);
+const DefinedOrUnknownSVal Size = getElementExtent(Ty, SVB);
 
 // A zero-length array at the end of a struct often stands for dynamically
 // allocated extra memory.
-if (Size.isZeroConstant()) {
-  if (isa(Ty))
-return UnknownVal();
-}
+const auto isFlexibleArrayMemberCandidate = [this](QualType Ty) -> bool {
+  const ArrayType *AT = Ctx.getAsArrayType(Ty);
+  if (!AT)
+return false;
+  if (isa(AT))
+return true;
+
+  if (const auto *CAT = dyn_cast(AT)) {
+const llvm::APInt &Size = CAT->getSize();
+if (Size.isNullValue())
+  return true;
+  }
+  return false;
+};
+
+if (isFlexibleArrayMemberCandidate(Ty))
+  return UnknownVal();
 
 return Size;
   }

diff  --git a/clang/test/Analysis/flexible-array-members.c 
b/clang/test/Analysis/flexible-array-members.c
new file mode 100644
index ..23a8d1fde0d9
--- /dev/null
+++ b/clang/test/Analysis/flexible-array-members.c
@@ -0,0 +1,96 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix,debug.ExprInspection %s 
-verify -std=c90
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix,debug.ExprInspection %s 
-verify -std=c99
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix,debug.ExprInspection %s 
-verify -std=c11
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix,debug.ExprInspection %s 
-verify -std=c17
+
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix,debug.ExprInspection %s 
-verify -std=c++98 -x c++
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix,debug.ExprInspection %s 
-verify -std=c++03 -x c++
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix,debug.ExprInspection %s 
-verify -std=c++11 -x c++
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix,debug.ExprInspection %s 
-verify -std=c++14 -x c++
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix,debug.ExprInspection %s 
-verify -std=c++17 -x c++
+
+typedef __typeof(sizeof(int)) size_t;
+size_t clang_analyzer_getExtent(void *);
+void clang_analyzer_dump(size_t);
+
+void *alloca(size_t size);
+void *malloc(size_t size);
+void free(void *ptr);
+
+void test_incomplete_array_fam() {
+  typedef struct FAM {
+char c;
+int data[];
+  } FAM;
+
+  FAM fam;
+  clang_analyzer_dump(clang_analyzer_getExtent(&fam));
+  clang_analyzer_dump(clang_analyzer_getExtent(fam.data));
+  // expected-warning@-2 {{4 S64b}}
+  // expected-warning@-2 {{Unknown}}
+
+  FAM *p = (FAM *)alloca(sizeof(FAM));
+  clang_analyzer_dump(clang_analyzer_getExtent(p));
+  clang_analyzer_dump(clang_analyzer_getExtent(p->data));
+  // expected-warning@-2 {{4 U64b}}
+  // expected-warning@-2 {{Unknown}}
+
+  FAM *q = (FAM *)malloc(sizeof(FAM));
+  clang_analyzer_dump(clang_analyzer_getExtent(q));
+  clang_analyzer_dump(clang_analyzer_getExtent(q->data));
+  // expected-warning@-2 {{4 U64b}}
+  // expected-warning@-2 {{Unknown}}
+  free(q);
+}
+
+void test_zero_length_array_fam() {
+  typedef struct FAM {
+char c;
+int data[0];
+  } FAM;
+
+  FAM fam;
+  clang_analyzer_dump(clang_analyzer_getExtent(&fam));
+  clang_analyzer_dump(clang_analyzer_getExtent(fam.data));
+  // expected-warning@-2 {{4 S64b}}
+  // expected-warning@-2 {{Unknown}}
+
+  FAM *p = (FAM *)alloca(sizeof(FAM));
+  clang_analyzer_dump(clang_analyzer_getExtent(p));
+  clang_analyzer_dump(cl

[PATCH] D105184: [analyzer] Ignore IncompleteArrayTypes in getStaticSize() for FAMs

2021-08-25 Thread Balázs Benics via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG360ced3b8fd2: [analyzer] Ignore IncompleteArrayTypes in 
getStaticSize() for FAMs (authored by steakhal).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105184

Files:
  clang/lib/StaticAnalyzer/Core/MemRegion.cpp
  clang/test/Analysis/flexible-array-members.c

Index: clang/test/Analysis/flexible-array-members.c
===
--- /dev/null
+++ clang/test/Analysis/flexible-array-members.c
@@ -0,0 +1,96 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix,debug.ExprInspection %s -verify -std=c90
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix,debug.ExprInspection %s -verify -std=c99
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix,debug.ExprInspection %s -verify -std=c11
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix,debug.ExprInspection %s -verify -std=c17
+
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix,debug.ExprInspection %s -verify -std=c++98 -x c++
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix,debug.ExprInspection %s -verify -std=c++03 -x c++
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix,debug.ExprInspection %s -verify -std=c++11 -x c++
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix,debug.ExprInspection %s -verify -std=c++14 -x c++
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix,debug.ExprInspection %s -verify -std=c++17 -x c++
+
+typedef __typeof(sizeof(int)) size_t;
+size_t clang_analyzer_getExtent(void *);
+void clang_analyzer_dump(size_t);
+
+void *alloca(size_t size);
+void *malloc(size_t size);
+void free(void *ptr);
+
+void test_incomplete_array_fam() {
+  typedef struct FAM {
+char c;
+int data[];
+  } FAM;
+
+  FAM fam;
+  clang_analyzer_dump(clang_analyzer_getExtent(&fam));
+  clang_analyzer_dump(clang_analyzer_getExtent(fam.data));
+  // expected-warning@-2 {{4 S64b}}
+  // expected-warning@-2 {{Unknown}}
+
+  FAM *p = (FAM *)alloca(sizeof(FAM));
+  clang_analyzer_dump(clang_analyzer_getExtent(p));
+  clang_analyzer_dump(clang_analyzer_getExtent(p->data));
+  // expected-warning@-2 {{4 U64b}}
+  // expected-warning@-2 {{Unknown}}
+
+  FAM *q = (FAM *)malloc(sizeof(FAM));
+  clang_analyzer_dump(clang_analyzer_getExtent(q));
+  clang_analyzer_dump(clang_analyzer_getExtent(q->data));
+  // expected-warning@-2 {{4 U64b}}
+  // expected-warning@-2 {{Unknown}}
+  free(q);
+}
+
+void test_zero_length_array_fam() {
+  typedef struct FAM {
+char c;
+int data[0];
+  } FAM;
+
+  FAM fam;
+  clang_analyzer_dump(clang_analyzer_getExtent(&fam));
+  clang_analyzer_dump(clang_analyzer_getExtent(fam.data));
+  // expected-warning@-2 {{4 S64b}}
+  // expected-warning@-2 {{Unknown}}
+
+  FAM *p = (FAM *)alloca(sizeof(FAM));
+  clang_analyzer_dump(clang_analyzer_getExtent(p));
+  clang_analyzer_dump(clang_analyzer_getExtent(p->data));
+  // expected-warning@-2 {{4 U64b}}
+  // expected-warning@-2 {{Unknown}}
+
+  FAM *q = (FAM *)malloc(sizeof(FAM));
+  clang_analyzer_dump(clang_analyzer_getExtent(q));
+  clang_analyzer_dump(clang_analyzer_getExtent(q->data));
+  // expected-warning@-2 {{4 U64b}}
+  // expected-warning@-2 {{Unknown}}
+  free(q);
+}
+
+void test_single_element_array_possible_fam() {
+  typedef struct FAM {
+char c;
+int data[1];
+  } FAM;
+
+  FAM likely_fam;
+  clang_analyzer_dump(clang_analyzer_getExtent(&likely_fam));
+  clang_analyzer_dump(clang_analyzer_getExtent(likely_fam.data));
+  // expected-warning@-2 {{8 S64b}}
+  // expected-warning@-2 {{4 S64b}}
+
+  FAM *p = (FAM *)alloca(sizeof(FAM));
+  clang_analyzer_dump(clang_analyzer_getExtent(p));
+  clang_analyzer_dump(clang_analyzer_getExtent(p->data));
+  // expected-warning@-2 {{8 U64b}}
+  // expected-warning@-2 {{4 S64b}}
+
+  FAM *q = (FAM *)malloc(sizeof(FAM));
+  clang_analyzer_dump(clang_analyzer_getExtent(q));
+  clang_analyzer_dump(clang_analyzer_getExtent(q->data));
+  // expected-warning@-2 {{8 U64b}}
+  // expected-warning@-2 {{4 S64b}}
+  free(q);
+}
Index: clang/lib/StaticAnalyzer/Core/MemRegion.cpp
===
--- clang/lib/StaticAnalyzer/Core/MemRegion.cpp
+++ clang/lib/StaticAnalyzer/Core/MemRegion.cpp
@@ -768,14 +768,27 @@
   return UnknownVal();
 
 QualType Ty = cast(SR)->getDesugaredValueType(Ctx);
-DefinedOrUnknownSVal Size = getElementExtent(Ty, SVB);
+const DefinedOrUnknownSVal Size = getElementExtent(Ty, SVB);
 
 // A zero-length array at the end of a struct often stands for dynamically
 // allocated extra memory.
-if (Size.isZeroConstant()) {
-  if (isa(Ty))
-return UnknownVal();
-}
+const auto isFlexibleArrayMemberCandidate = [this](QualType Ty) -> bool {
+  const ArrayType *AT = Ctx.getAsArrayType(Ty);
+  

[PATCH] D108702: [PowerPC][NFC] Rename P10 builtins vec_clrl, vec_clrr to vec_clr_first and vec_clr_last

2021-08-25 Thread Victor Huang via Phabricator via cfe-commits
NeHuang created this revision.
NeHuang added reviewers: amyk, lei, stefanp, PowerPC.
NeHuang added a project: LLVM.
Herald added subscribers: shchenz, kbarton, nemanjai.
NeHuang requested review of this revision.
Herald added a project: clang.

This patch renames the vector clear left/right builtins `vec_clrl`, `vec_clrr` 
to `vec_clr_first` and `vec_clr_last` to avoid the ambiguities when dealing 
with endianness.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D108702

Files:
  clang/lib/Headers/altivec.h
  clang/test/CodeGen/builtins-ppc-p10vector.c


Index: clang/test/CodeGen/builtins-ppc-p10vector.c
===
--- clang/test/CodeGen/builtins-ppc-p10vector.c
+++ clang/test/CodeGen/builtins-ppc-p10vector.c
@@ -732,36 +732,36 @@
   return vec_genpcvm(vulla, 0);
 }
 
-vector signed char test_vec_vclrl_sc(void) {
+vector signed char test_vec_clr_first_sc(void) {
   // CHECK-BE: @llvm.ppc.altivec.vclrlb(<16 x i8>
   // CHECK-BE-NEXT: ret <16 x i8>
   // CHECK-LE: @llvm.ppc.altivec.vclrrb(<16 x i8>
   // CHECK-LE-NEXT: ret <16 x i8>
-  return vec_clrl(vsca, uia);
+  return vec_clr_first(vsca, uia);
 }
 
-vector unsigned char test_vec_clrl_uc(void) {
+vector unsigned char test_vec_clr_first_uc(void) {
   // CHECK-BE: @llvm.ppc.altivec.vclrlb(<16 x i8>
   // CHECK-BE-NEXT: ret <16 x i8>
   // CHECK-LE: @llvm.ppc.altivec.vclrrb(<16 x i8>
   // CHECK-LE-NEXT: ret <16 x i8>
-  return vec_clrl(vuca, uia);
+  return vec_clr_first(vuca, uia);
 }
 
-vector signed char test_vec_vclrr_sc(void) {
+vector signed char test_vec_clr_last_sc(void) {
   // CHECK-BE: @llvm.ppc.altivec.vclrrb(<16 x i8>
   // CHECK-BE-NEXT: ret <16 x i8>
   // CHECK-LE: @llvm.ppc.altivec.vclrlb(<16 x i8>
   // CHECK-LE-NEXT: ret <16 x i8>
-  return vec_clrr(vsca, uia);
+  return vec_clr_last(vsca, uia);
 }
 
-vector unsigned char test_vec_clrr_uc(void) {
+vector unsigned char test_vec_clr_last_uc(void) {
   // CHECK-BE: @llvm.ppc.altivec.vclrrb(<16 x i8>
   // CHECK-BE-NEXT: ret <16 x i8>
   // CHECK-LE: @llvm.ppc.altivec.vclrlb(<16 x i8>
   // CHECK-LE-NEXT: ret <16 x i8>
-  return vec_clrr(vuca, uia);
+  return vec_clr_last(vuca, uia);
 }
 
 vector unsigned long long test_vclzdm(void) {
Index: clang/lib/Headers/altivec.h
===
--- clang/lib/Headers/altivec.h
+++ clang/lib/Headers/altivec.h
@@ -18312,10 +18312,10 @@
: __builtin_vsx_xxgenpcvdm((__a), (int)(__imm)))
 #endif /* __VSX__ */
 
-/* vec_clrl */
+/* vec_clr_first */
 
 static __inline__ vector signed char __ATTRS_o_ai
-vec_clrl(vector signed char __a, unsigned int __n) {
+vec_clr_first(vector signed char __a, unsigned int __n) {
 #ifdef __LITTLE_ENDIAN__
   return __builtin_altivec_vclrrb(__a, __n);
 #else
@@ -18324,7 +18324,7 @@
 }
 
 static __inline__ vector unsigned char __ATTRS_o_ai
-vec_clrl(vector unsigned char __a, unsigned int __n) {
+vec_clr_first(vector unsigned char __a, unsigned int __n) {
 #ifdef __LITTLE_ENDIAN__
   return __builtin_altivec_vclrrb((vector signed char)__a, __n);
 #else
@@ -18332,10 +18332,10 @@
 #endif
 }
 
-/* vec_clrr */
+/* vec_clr_last */
 
 static __inline__ vector signed char __ATTRS_o_ai
-vec_clrr(vector signed char __a, unsigned int __n) {
+vec_clr_last(vector signed char __a, unsigned int __n) {
 #ifdef __LITTLE_ENDIAN__
   return __builtin_altivec_vclrlb(__a, __n);
 #else
@@ -18344,7 +18344,7 @@
 }
 
 static __inline__ vector unsigned char __ATTRS_o_ai
-vec_clrr(vector unsigned char __a, unsigned int __n) {
+vec_clr_last(vector unsigned char __a, unsigned int __n) {
 #ifdef __LITTLE_ENDIAN__
   return __builtin_altivec_vclrlb((vector signed char)__a, __n);
 #else


Index: clang/test/CodeGen/builtins-ppc-p10vector.c
===
--- clang/test/CodeGen/builtins-ppc-p10vector.c
+++ clang/test/CodeGen/builtins-ppc-p10vector.c
@@ -732,36 +732,36 @@
   return vec_genpcvm(vulla, 0);
 }
 
-vector signed char test_vec_vclrl_sc(void) {
+vector signed char test_vec_clr_first_sc(void) {
   // CHECK-BE: @llvm.ppc.altivec.vclrlb(<16 x i8>
   // CHECK-BE-NEXT: ret <16 x i8>
   // CHECK-LE: @llvm.ppc.altivec.vclrrb(<16 x i8>
   // CHECK-LE-NEXT: ret <16 x i8>
-  return vec_clrl(vsca, uia);
+  return vec_clr_first(vsca, uia);
 }
 
-vector unsigned char test_vec_clrl_uc(void) {
+vector unsigned char test_vec_clr_first_uc(void) {
   // CHECK-BE: @llvm.ppc.altivec.vclrlb(<16 x i8>
   // CHECK-BE-NEXT: ret <16 x i8>
   // CHECK-LE: @llvm.ppc.altivec.vclrrb(<16 x i8>
   // CHECK-LE-NEXT: ret <16 x i8>
-  return vec_clrl(vuca, uia);
+  return vec_clr_first(vuca, uia);
 }
 
-vector signed char test_vec_vclrr_sc(void) {
+vector signed char test_vec_clr_last_sc(void) {
   // CHECK-BE: @llvm.ppc.altivec.vclrrb(<16 x i8>
   // CHECK-BE-NEXT: ret <16 x i8>
   // CHECK-LE: @llvm.ppc.altivec.vclrlb(<16 x i8>
   // CHECK-LE-NEXT: ret <16 x i8>
-  return vec_clrr(vsca, uia);
+  r

[PATCH] D105462: [X86] Add CRC32 feature.

2021-08-25 Thread Pengfei Wang via Phabricator via cfe-commits
pengfei added inline comments.



Comment at: clang/lib/Basic/Targets/X86.cpp:159
+  // Enable CRC32 if SSE4.2 is enabled.
+  // NOTE: In conformance with GCC behavior, CRC32 is still available even if
+  // it's explicitly disabled.

hjl.tools wrote:
> craig.topper wrote:
> > hjl.tools wrote:
> > > tianqing wrote:
> > > > craig.topper wrote:
> > > > > This doesn't seem to be true. It causes gcc to crash. 
> > > > > https://godbolt.org/z/39rEbsejh
> > > > Well I was using GCC 11.1, it compiles.
> > > > 
> > > > The way I see it, crash means a bug (not surprising since it's trunk), 
> > > > and can be interpreted as incompletely defined behavior until it's 
> > > > fixed.
> > > > 
> > > > Some tests on GCC trunk:
> > > > 1. -msse4.2: Pass - sse4.2 enables crc32.
> > > > 2. -mcrc32 -mno-sse4.2: Pass - no-sse4.2 doesn't disable crc32.
> > > > 3. -msse4.2 -mno-sse4.2: Error - no-sse4.2 disables crc32.
> > > > 4. -mno-crc32 -msse4.2: Crash - undefined behavior
> > > > 5. -msse4.2 -mno-crc32: Crash - undefined behavior
> > > > 
> > > > 
> > > > It's hard to extract some consistent underlying logic from the GCC 
> > > > results.
> > > I posted a patch: 
> > > https://gcc.gnu.org/pipermail/gcc-patches/2021-July/575741.html
> > @hjl.tools does that turn the crash into making -mno-crc32 into making 
> > crc32 instruction disabled?
> Correct.  GCC issues an error now.
So we don't align with GCC regarding "1. -msse4.2: Pass - sse4.2 enables 
crc32."?



Comment at: llvm/lib/Support/X86TargetParser.cpp:531
 constexpr FeatureBitset ImpliedFeaturesSSSE3 = FeatureSSE3;
 constexpr FeatureBitset ImpliedFeaturesSSE4_1 = FeatureSSSE3;
 constexpr FeatureBitset ImpliedFeaturesSSE4_2 = FeatureSSE4_1;

Can we let `ImpliedFeaturesSSE4_1 = FeatureSSSE3 | FeaturesCRC32` so that we 
don't need to add `crc32` on sse4.1 and above?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105462

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


[clang] df1f4e0 - Revert "[analyzer] Ignore IncompleteArrayTypes in getStaticSize() for FAMs"

2021-08-25 Thread Balazs Benics via cfe-commits

Author: Balazs Benics
Date: 2021-08-25T16:43:25+02:00
New Revision: df1f4e0cc6ec9a734aae41ffd48ee8b2007fcabb

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

LOG: Revert "[analyzer] Ignore IncompleteArrayTypes in getStaticSize() for FAMs"

This reverts commit 360ced3b8fd2cfb9f2a26deb739e6c381e98b9a5.

Added: 


Modified: 
clang/lib/StaticAnalyzer/Core/MemRegion.cpp

Removed: 
clang/test/Analysis/flexible-array-members.c



diff  --git a/clang/lib/StaticAnalyzer/Core/MemRegion.cpp 
b/clang/lib/StaticAnalyzer/Core/MemRegion.cpp
index 1a614d4d2bcd..bd725ee9eaa3 100644
--- a/clang/lib/StaticAnalyzer/Core/MemRegion.cpp
+++ b/clang/lib/StaticAnalyzer/Core/MemRegion.cpp
@@ -768,27 +768,14 @@ DefinedOrUnknownSVal 
MemRegionManager::getStaticSize(const MemRegion *MR,
   return UnknownVal();
 
 QualType Ty = cast(SR)->getDesugaredValueType(Ctx);
-const DefinedOrUnknownSVal Size = getElementExtent(Ty, SVB);
+DefinedOrUnknownSVal Size = getElementExtent(Ty, SVB);
 
 // A zero-length array at the end of a struct often stands for dynamically
 // allocated extra memory.
-const auto isFlexibleArrayMemberCandidate = [this](QualType Ty) -> bool {
-  const ArrayType *AT = Ctx.getAsArrayType(Ty);
-  if (!AT)
-return false;
-  if (isa(AT))
-return true;
-
-  if (const auto *CAT = dyn_cast(AT)) {
-const llvm::APInt &Size = CAT->getSize();
-if (Size.isNullValue())
-  return true;
-  }
-  return false;
-};
-
-if (isFlexibleArrayMemberCandidate(Ty))
-  return UnknownVal();
+if (Size.isZeroConstant()) {
+  if (isa(Ty))
+return UnknownVal();
+}
 
 return Size;
   }

diff  --git a/clang/test/Analysis/flexible-array-members.c 
b/clang/test/Analysis/flexible-array-members.c
deleted file mode 100644
index 23a8d1fde0d9..
--- a/clang/test/Analysis/flexible-array-members.c
+++ /dev/null
@@ -1,96 +0,0 @@
-// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix,debug.ExprInspection %s 
-verify -std=c90
-// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix,debug.ExprInspection %s 
-verify -std=c99
-// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix,debug.ExprInspection %s 
-verify -std=c11
-// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix,debug.ExprInspection %s 
-verify -std=c17
-
-// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix,debug.ExprInspection %s 
-verify -std=c++98 -x c++
-// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix,debug.ExprInspection %s 
-verify -std=c++03 -x c++
-// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix,debug.ExprInspection %s 
-verify -std=c++11 -x c++
-// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix,debug.ExprInspection %s 
-verify -std=c++14 -x c++
-// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix,debug.ExprInspection %s 
-verify -std=c++17 -x c++
-
-typedef __typeof(sizeof(int)) size_t;
-size_t clang_analyzer_getExtent(void *);
-void clang_analyzer_dump(size_t);
-
-void *alloca(size_t size);
-void *malloc(size_t size);
-void free(void *ptr);
-
-void test_incomplete_array_fam() {
-  typedef struct FAM {
-char c;
-int data[];
-  } FAM;
-
-  FAM fam;
-  clang_analyzer_dump(clang_analyzer_getExtent(&fam));
-  clang_analyzer_dump(clang_analyzer_getExtent(fam.data));
-  // expected-warning@-2 {{4 S64b}}
-  // expected-warning@-2 {{Unknown}}
-
-  FAM *p = (FAM *)alloca(sizeof(FAM));
-  clang_analyzer_dump(clang_analyzer_getExtent(p));
-  clang_analyzer_dump(clang_analyzer_getExtent(p->data));
-  // expected-warning@-2 {{4 U64b}}
-  // expected-warning@-2 {{Unknown}}
-
-  FAM *q = (FAM *)malloc(sizeof(FAM));
-  clang_analyzer_dump(clang_analyzer_getExtent(q));
-  clang_analyzer_dump(clang_analyzer_getExtent(q->data));
-  // expected-warning@-2 {{4 U64b}}
-  // expected-warning@-2 {{Unknown}}
-  free(q);
-}
-
-void test_zero_length_array_fam() {
-  typedef struct FAM {
-char c;
-int data[0];
-  } FAM;
-
-  FAM fam;
-  clang_analyzer_dump(clang_analyzer_getExtent(&fam));
-  clang_analyzer_dump(clang_analyzer_getExtent(fam.data));
-  // expected-warning@-2 {{4 S64b}}
-  // expected-warning@-2 {{Unknown}}
-
-  FAM *p = (FAM *)alloca(sizeof(FAM));
-  clang_analyzer_dump(clang_analyzer_getExtent(p));
-  clang_analyzer_dump(clang_analyzer_getExtent(p->data));
-  // expected-warning@-2 {{4 U64b}}
-  // expected-warning@-2 {{Unknown}}
-
-  FAM *q = (FAM *)malloc(sizeof(FAM));
-  clang_analyzer_dump(clang_analyzer_getExtent(q));
-  clang_analyzer_dump(clang_analyzer_getExtent(q->data));
-  // expected-warning@-2 {{4 U64b}}
-  // expected-warning@-2 {{Unknown}}
-  free(q);
-}
-
-void test_single_element_array_possible_fam() {
-  typedef struct FAM {
-char c;
-int data[1];
-  } FAM;
-
-  FAM likely_fa

[PATCH] D105462: [X86] Add CRC32 feature.

2021-08-25 Thread H.J Lu via Phabricator via cfe-commits
hjl.tools added inline comments.



Comment at: llvm/lib/Support/X86TargetParser.cpp:531
 constexpr FeatureBitset ImpliedFeaturesSSSE3 = FeatureSSE3;
 constexpr FeatureBitset ImpliedFeaturesSSE4_1 = FeatureSSSE3;
 constexpr FeatureBitset ImpliedFeaturesSSE4_2 = FeatureSSE4_1;

pengfei wrote:
> Can we let `ImpliedFeaturesSSE4_1 = FeatureSSSE3 | FeaturesCRC32` so that we 
> don't need to add `crc32` on sse4.1 and above?
SSE4.1 implies CRC32.  But CRC32 shouldn't imply SSE4.1.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105462

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


[PATCH] D106577: [clang] Define __STDC_ISO_10646__

2021-08-25 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D106577#2958633 , @jyknight wrote:

> In D106577#2944086 , @aaron.ballman 
> wrote:
>
>> @jyknight, are you on the WG14 reflectors btw? Would you like to carry on 
>> with this discussion over there (or would you like me to convey your 
>> viewpoints on your behalf)?
>
> I'm not. I'd be happy to have you convey my viewpoints.

Thanks! I've passed them along to WG14 and will report back what I hear.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106577

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


[PATCH] D105462: [X86] Add CRC32 feature.

2021-08-25 Thread Pengfei Wang via Phabricator via cfe-commits
pengfei added inline comments.



Comment at: llvm/lib/Support/X86TargetParser.cpp:531
 constexpr FeatureBitset ImpliedFeaturesSSSE3 = FeatureSSE3;
 constexpr FeatureBitset ImpliedFeaturesSSE4_1 = FeatureSSSE3;
 constexpr FeatureBitset ImpliedFeaturesSSE4_2 = FeatureSSE4_1;

hjl.tools wrote:
> pengfei wrote:
> > Can we let `ImpliedFeaturesSSE4_1 = FeatureSSSE3 | FeaturesCRC32` so that 
> > we don't need to add `crc32` on sse4.1 and above?
> SSE4.1 implies CRC32.  But CRC32 shouldn't imply SSE4.1.
Yes. The constexpr here means `FeaturesSSE4_1` implies both `FeatureSSSE3` and 
`FeaturesCRC32`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105462

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


[PATCH] D108704: [OpenCL] Define OpenCL 3.0 optional core features in C++ for OpenCL 2021

2021-08-25 Thread Justas Janickas via Phabricator via cfe-commits
Topotuna created this revision.
Topotuna added a reviewer: Anastasia.
Herald added subscribers: ldrumm, yaxunl.
Topotuna requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Modifies OpenCL 3.0 optional core feature macro definitions so that
they are set analogously in C++ for OpenCL 2021.

This change aims to achieve compatibility between C++ for OpenCL
2021 and OpenCL 3.0.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D108704

Files:
  clang/lib/Headers/opencl-c-base.h
  clang/test/Headers/opencl-c-header.cl
  clang/test/SemaOpenCL/features.cl


Index: clang/test/SemaOpenCL/features.cl
===
--- clang/test/SemaOpenCL/features.cl
+++ clang/test/SemaOpenCL/features.cl
@@ -6,6 +6,14 @@
 // RUN:   | FileCheck -match-full-lines %s  --check-prefix=NO-FEATURES
 // RUN: %clang_cc1 -triple r600-unknown-unknown %s -E -dM -o - -x cl 
-cl-std=CL3.0 -cl-ext=+all \
 // RUN:   | FileCheck -match-full-lines %s  --check-prefix=FEATURES
+// RUN: %clang_cc1 -triple spir-unknown-unknown %s -E -dM -o - -x cl 
-cl-std=clc++2021 -cl-ext=-all \
+// RUN:   | FileCheck -match-full-lines %s  --check-prefix=NO-FEATURES
+// RUN: %clang_cc1 -triple spir-unknown-unknown %s -E -dM -o - -x cl 
-cl-std=clc++2021 -cl-ext=+all \
+// RUN:   | FileCheck -match-full-lines %s  --check-prefix=FEATURES
+// RUN: %clang_cc1 -triple r600-unknown-unknown %s -E -dM -o - -x cl 
-cl-std=clc++2021 \
+// RUN:   | FileCheck -match-full-lines %s  --check-prefix=NO-FEATURES
+// RUN: %clang_cc1 -triple r600-unknown-unknown %s -E -dM -o - -x cl 
-cl-std=clc++2021 -cl-ext=+all \
+// RUN:   | FileCheck -match-full-lines %s  --check-prefix=FEATURES
 
 // For OpenCL C 2.0 feature macros are defined only in header, so test that 
earlier OpenCL
 // versions don't define feature macros accidentally and CL2.0 don't define 
them without header
@@ -15,7 +23,7 @@
 // RUN:   | FileCheck -match-full-lines %s  --check-prefix=NO-FEATURES
 // RUN: %clang_cc1 -triple spir-unknown-unknown %s -E -dM -o - -x cl 
-cl-std=CL2.0 \
 // RUN:   | FileCheck -match-full-lines %s  --check-prefix=NO-FEATURES
-// RUN: %clang_cc1 -triple spir-unknown-unknown %s -E -dM -o - -x cl 
-cl-std=CLC++ \
+// RUN: %clang_cc1 -triple spir-unknown-unknown %s -E -dM -o - -x cl 
-cl-std=clc++1.0 \
 // RUN:   | FileCheck -match-full-lines %s  --check-prefix=NO-FEATURES
 
 // Note that __opencl_c_int64 is always defined assuming
Index: clang/test/Headers/opencl-c-header.cl
===
--- clang/test/Headers/opencl-c-header.cl
+++ clang/test/Headers/opencl-c-header.cl
@@ -175,13 +175,13 @@
 #endif //(defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200)
 
 // OpenCL C features.
-#if (__OPENCL_C_VERSION__ == 300)
+#if (__OPENCL_CPP_VERSION__ == 202100 || __OPENCL_C_VERSION__ == 300)
 
 #if __opencl_c_atomic_scope_all_devices != 1
 #error "Incorrectly defined feature macro __opencl_c_atomic_scope_all_devices"
 #endif
 
-#elif (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ == 200)
+#elif (__OPENCL_CPP_VERSION__ == 100 || __OPENCL_C_VERSION__ == 200)
 
 #ifndef  __opencl_c_pipes
 #error "Feature macro __opencl_c_pipes should be defined"
@@ -262,6 +262,6 @@
 #error "Incorrect feature macro __opencl_c_subgroups define"
 #endif
 
-#endif //(defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ == 200)
+#endif // (__OPENCL_CPP_VERSION__ == 202100 || __OPENCL_C_VERSION__ == 300)
 
 #endif // defined(__SPIR__)
Index: clang/lib/Headers/opencl-c-base.h
===
--- clang/lib/Headers/opencl-c-base.h
+++ clang/lib/Headers/opencl-c-base.h
@@ -30,7 +30,7 @@
 #endif // (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200)
 
 // Define feature macros for OpenCL C 2.0
-#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ == 200)
+#if (__OPENCL_CPP_VERSION__ == 100 || __OPENCL_C_VERSION__ == 200)
 #define __opencl_c_pipes 1
 #define __opencl_c_generic_address_space 1
 #define __opencl_c_work_group_collective_functions 1
@@ -45,12 +45,12 @@
 #endif
 
 // Define header-only feature macros for OpenCL C 3.0.
-#if (__OPENCL_C_VERSION__ == 300)
+#if (__OPENCL_CPP_VERSION__ == 202100 || __OPENCL_C_VERSION__ == 300)
 // For the SPIR target all features are supported.
 #if defined(__SPIR__)
 #define __opencl_c_atomic_scope_all_devices 1
 #endif // defined(__SPIR__)
-#endif // (__OPENCL_C_VERSION__ == 300)
+#endif // (__OPENCL_CPP_VERSION__ == 202100 || __OPENCL_C_VERSION__ == 300)
 
 // built-in scalar data types:
 


Index: clang/test/SemaOpenCL/features.cl
===
--- clang/test/SemaOpenCL/features.cl
+++ clang/test/SemaOpenCL/features.cl
@@ -6,6 +6,14 @@
 // RUN:   | FileCheck -match-full-lines %s  --check-prefix=NO-FEATURES
 // RUN: %clang_cc1 -triple r600-unknown-unknown %s -E -dM -o -

[clang] 2e192ab - [CodeExtractor] Preserve topological order for the return blocks.

2021-08-25 Thread Vyacheslav Zakharin via cfe-commits

Author: Vyacheslav Zakharin
Date: 2021-08-25T08:09:01-07:00
New Revision: 2e192ab1f457918484d3f41b9d2271a9dd8a9de3

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

LOG: [CodeExtractor] Preserve topological order for the return blocks.

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

Added: 


Modified: 
clang/test/OpenMP/cancel_codegen.cpp
clang/test/OpenMP/parallel_codegen.cpp
llvm/lib/Transforms/IPO/IROutliner.cpp
llvm/lib/Transforms/Utils/CodeExtractor.cpp
llvm/test/Transforms/CodeExtractor/LoopExtractor.ll
llvm/test/Transforms/CodeExtractor/LoopExtractor_crash.ll
llvm/test/Transforms/CodeExtractor/LoopExtractor_infinite.ll
llvm/test/Transforms/CodeExtractor/live_shrink_unsafe.ll
llvm/test/Transforms/CodeExtractor/unreachable-block.ll
llvm/test/Transforms/HotColdSplit/multiple-exits.ll
llvm/test/Transforms/IROutliner/outlining-different-output-blocks.ll
llvm/test/Transforms/IROutliner/outlining-same-output-blocks.ll
llvm/test/Transforms/OpenMP/parallel_region_merging.ll
llvm/test/tools/llvm-extract/extract-blocks-with-groups.ll

Removed: 




diff  --git a/clang/test/OpenMP/cancel_codegen.cpp 
b/clang/test/OpenMP/cancel_codegen.cpp
index 2b7c1d6d254d7..d87dee6184b0d 100644
--- a/clang/test/OpenMP/cancel_codegen.cpp
+++ b/clang/test/OpenMP/cancel_codegen.cpp
@@ -1560,8 +1560,6 @@ for (int i = 0; i < argc; ++i) {
 // CHECK3-NEXT:store i32 [[TMP0]], i32* [[TID_ADDR_LOCAL]], align 4
 // CHECK3-NEXT:[[TID:%.*]] = load i32, i32* [[TID_ADDR_LOCAL]], align 4
 // CHECK3-NEXT:br label [[OMP_PAR_REGION:%.*]]
-// CHECK3:   omp.par.outlined.exit.exitStub:
-// CHECK3-NEXT:ret void
 // CHECK3:   omp.par.region:
 // CHECK3-NEXT:[[TMP1:%.*]] = load float, float* @flag, align 4
 // CHECK3-NEXT:[[TOBOOL:%.*]] = fcmp une float [[TMP1]], 0.00e+00
@@ -1607,6 +1605,8 @@ for (int i = 0; i < argc; ++i) {
 // CHECK3-NEXT:br label [[OMP_PAR_OUTLINED_EXIT_EXITSTUB]]
 // CHECK3:   .split:
 // CHECK3-NEXT:br label [[TMP3]]
+// CHECK3:   omp.par.outlined.exit.exitStub:
+// CHECK3-NEXT:ret void
 //
 //
 // CHECK3-LABEL: define {{[^@]+}}@.omp_task_entry.
@@ -2187,8 +2187,6 @@ for (int i = 0; i < argc; ++i) {
 // CHECK4-NEXT:store i32 [[TMP0]], i32* [[TID_ADDR_LOCAL]], align 4
 // CHECK4-NEXT:[[TID:%.*]] = load i32, i32* [[TID_ADDR_LOCAL]], align 4
 // CHECK4-NEXT:br label [[OMP_PAR_REGION:%.*]]
-// CHECK4:   omp.par.outlined.exit.exitStub:
-// CHECK4-NEXT:ret void
 // CHECK4:   omp.par.region:
 // CHECK4-NEXT:[[TMP1:%.*]] = load float, float* @flag, align 4
 // CHECK4-NEXT:[[TOBOOL:%.*]] = fcmp une float [[TMP1]], 0.00e+00
@@ -2234,6 +2232,8 @@ for (int i = 0; i < argc; ++i) {
 // CHECK4-NEXT:br label [[OMP_PAR_OUTLINED_EXIT_EXITSTUB]]
 // CHECK4:   .split:
 // CHECK4-NEXT:br label [[TMP3]]
+// CHECK4:   omp.par.outlined.exit.exitStub:
+// CHECK4-NEXT:ret void
 //
 //
 // CHECK4-LABEL: define {{[^@]+}}@.omp_task_entry.
@@ -4054,8 +4054,6 @@ for (int i = 0; i < argc; ++i) {
 // CHECK9-NEXT:store i32 [[TMP0]], i32* [[TID_ADDR_LOCAL]], align 4
 // CHECK9-NEXT:[[TID:%.*]] = load i32, i32* [[TID_ADDR_LOCAL]], align 4
 // CHECK9-NEXT:br label [[OMP_PAR_REGION:%.*]]
-// CHECK9:   omp.par.outlined.exit.exitStub:
-// CHECK9-NEXT:ret void
 // CHECK9:   omp.par.region:
 // CHECK9-NEXT:[[TMP1:%.*]] = load float, float* @flag, align 4
 // CHECK9-NEXT:[[TOBOOL:%.*]] = fcmp une float [[TMP1]], 0.00e+00
@@ -4101,6 +4099,8 @@ for (int i = 0; i < argc; ++i) {
 // CHECK9-NEXT:br label [[OMP_PAR_OUTLINED_EXIT_EXITSTUB]]
 // CHECK9:   .split:
 // CHECK9-NEXT:br label [[TMP3]]
+// CHECK9:   omp.par.outlined.exit.exitStub:
+// CHECK9-NEXT:ret void
 //
 //
 // CHECK9-LABEL: define {{[^@]+}}@.omp_task_entry.
@@ -4681,8 +4681,6 @@ for (int i = 0; i < argc; ++i) {
 // CHECK10-NEXT:store i32 [[TMP0]], i32* [[TID_ADDR_LOCAL]], align 4
 // CHECK10-NEXT:[[TID:%.*]] = load i32, i32* [[TID_ADDR_LOCAL]], align 4
 // CHECK10-NEXT:br label [[OMP_PAR_REGION:%.*]]
-// CHECK10:   omp.par.outlined.exit.exitStub:
-// CHECK10-NEXT:ret void
 // CHECK10:   omp.par.region:
 // CHECK10-NEXT:[[TMP1:%.*]] = load float, float* @flag, align 4
 // CHECK10-NEXT:[[TOBOOL:%.*]] = fcmp une float [[TMP1]], 0.00e+00
@@ -4728,6 +4726,8 @@ for (int i = 0; i < argc; ++i) {
 // CHECK10-NEXT:br label [[OMP_PAR_OUTLINED_EXIT_EXITSTUB]]
 // CHECK10:   .split:
 // CHECK10-NEXT:br label [[TMP3]]
+// CHECK10:   omp.par.outlined.exit.exitStub:
+// CHECK10-NEXT:ret void
 //
 //
 // CHECK10-LABEL: define {{[^@]+}}@.omp_task_entry.

diff  --git a/clang/test/OpenMP/parallel_codegen.cpp 
b/clang/te

[PATCH] D108673: [CodeExtractor] Preserve topological order for the return blocks.

2021-08-25 Thread Vyacheslav Zakharin 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 rG2e192ab1f457: [CodeExtractor] Preserve topological order for 
the return blocks. (authored by vzakhari).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108673

Files:
  clang/test/OpenMP/cancel_codegen.cpp
  clang/test/OpenMP/parallel_codegen.cpp
  llvm/lib/Transforms/IPO/IROutliner.cpp
  llvm/lib/Transforms/Utils/CodeExtractor.cpp
  llvm/test/Transforms/CodeExtractor/LoopExtractor.ll
  llvm/test/Transforms/CodeExtractor/LoopExtractor_crash.ll
  llvm/test/Transforms/CodeExtractor/LoopExtractor_infinite.ll
  llvm/test/Transforms/CodeExtractor/live_shrink_unsafe.ll
  llvm/test/Transforms/CodeExtractor/unreachable-block.ll
  llvm/test/Transforms/HotColdSplit/multiple-exits.ll
  llvm/test/Transforms/IROutliner/outlining-different-output-blocks.ll
  llvm/test/Transforms/IROutliner/outlining-same-output-blocks.ll
  llvm/test/Transforms/OpenMP/parallel_region_merging.ll
  llvm/test/tools/llvm-extract/extract-blocks-with-groups.ll

Index: llvm/test/tools/llvm-extract/extract-blocks-with-groups.ll
===
--- llvm/test/tools/llvm-extract/extract-blocks-with-groups.ll
+++ llvm/test/tools/llvm-extract/extract-blocks-with-groups.ll
@@ -8,9 +8,6 @@
 ; CHECK: newFuncRoot:
 ; CHECK:   br label %if.split
 ;
-; CHECK: end.exitStub: ; preds = %end.split
-; CHECK:   ret void
-;
 ; CHECK: then: ; preds = %if.split
 ; CHECK:   %tmp12 = shl i32 %arg1, 2
 ; CHECK:   %tmp13 = add nsw i32 %tmp12, %arg
@@ -32,6 +29,9 @@
 ; CHECK:   %tmp.0.ce = phi i32 [ %tmp13, %then ], [ %tmp25, %else ]
 ; CHECK:   store i32 %tmp.0.ce, i32* %tmp.0.ce.out
 ; CHECK:   br label %end.exitStub
+;
+; CHECK: end.exitStub: ; preds = %end.split
+; CHECK:   ret void
 ; CHECK: }
 
 ; The second extracted function is the region composed by the blocks
@@ -40,12 +40,6 @@
 ; CHECK: newFuncRoot:
 ; CHECK:   br label %bb14
 ;
-; CHECK: bb26.exitStub:; preds = %bb14
-; CHECK:   ret i1 true
-;
-; CHECK: bb30.exitStub:; preds = %bb20
-; CHECK:   ret i1 false
-;
 ; CHECK: bb14: ; preds = %newFuncRoot
 ; CHECK:   %tmp0 = and i32 %arg1, %arg
 ; CHECK:   %tmp1 = icmp slt i32 %tmp0, 0
@@ -57,6 +51,12 @@
 ; CHECK:   %tmp25 = add nsw i32 %tmp24, %tmp22
 ; CHECK:   store i32 %tmp25, i32* %tmp25.out
 ; CHECK:   br label %bb30.exitStub
+;
+; CHECK: bb26.exitStub:; preds = %bb14
+; CHECK:   ret i1 true
+;
+; CHECK: bb30.exitStub:; preds = %bb20
+; CHECK:   ret i1 false
 ; CHECK: }
 
 define i32 @foo(i32 %arg, i32 %arg1) {
Index: llvm/test/Transforms/OpenMP/parallel_region_merging.ll
===
--- llvm/test/Transforms/OpenMP/parallel_region_merging.ll
+++ llvm/test/Transforms/OpenMP/parallel_region_merging.ll
@@ -4715,8 +4715,6 @@
 ; CHECK1-NEXT:store i32 [[TMP0]], i32* [[TID_ADDR_LOCAL]], align 4
 ; CHECK1-NEXT:[[TID:%.*]] = load i32, i32* [[TID_ADDR_LOCAL]], align 4
 ; CHECK1-NEXT:br label [[OMP_PAR_REGION:%.*]]
-; CHECK1:   omp.par.outlined.exit.exitStub:
-; CHECK1-NEXT:ret void
 ; CHECK1:   omp.par.region:
 ; CHECK1-NEXT:br label [[OMP_PAR_MERGED:%.*]]
 ; CHECK1:   omp.par.merged:
@@ -4731,6 +4729,8 @@
 ; CHECK1-NEXT:br label [[OMP_PAR_PRE_FINALIZE:%.*]]
 ; CHECK1:   omp.par.pre_finalize:
 ; CHECK1-NEXT:br label [[OMP_PAR_OUTLINED_EXIT_EXITSTUB:%.*]]
+; CHECK1:   omp.par.outlined.exit.exitStub:
+; CHECK1-NEXT:ret void
 ;
 ;
 ; CHECK1-LABEL: define {{[^@]+}}@.omp_outlined.
@@ -4860,8 +4860,6 @@
 ; CHECK1-NEXT:store i32 [[TMP0]], i32* [[TID_ADDR_LOCAL]], align 4
 ; CHECK1-NEXT:[[TID:%.*]] = load i32, i32* [[TID_ADDR_LOCAL]], align 4
 ; CHECK1-NEXT:br label [[OMP_PAR_REGION:%.*]]
-; CHECK1:   omp.par.outlined.exit.exitStub:
-; CHECK1-NEXT:ret void
 ; CHECK1:   omp.par.region:
 ; CHECK1-NEXT:br label [[OMP_PAR_MERGED:%.*]]
 ; CHECK1:   omp.par.merged:
@@ -4897,6 +4895,8 @@
 ; CHECK1:   omp_region.body.split:
 ; CHECK1-NEXT:call void @__kmpc_end_master(%struct.ident_t* @[[GLOB1]], i32 [[OMP_GLOBAL_THREAD_NUM]])
 ; CHECK1-NEXT:br label [[OMP_REGION_END]]
+; CHECK1:   omp.par.outlined.exit.exitStub:
+; CHECK1-NEXT:ret void
 ;
 ;
 ; CHECK1-LABEL: define {{[^@]+}}@.omp_outlined..8
@@ -4944,8 +4944,6 @@
 ; CHECK1-NEXT:[[TID:%.*]] = load i32, i32* [[TID_ADDR_LOCAL]], align 4
 ; CHECK1-NEXT:[[TMP1:%.*]] = load float, float* [[F_RELOADED]], align 4
 ; CHECK1-NEXT:

[PATCH] D107775: [Clang][AST] Resolve FIXME: Remove ObjCObjectPointer from isSpecifierType

2021-08-25 Thread Alf via Phabricator via cfe-commits
gAlfonso-bit added a comment.

In D107775#2964937 , @dgoldman wrote:

> Does this change the behavior of TypePrinter or DeclPrinter - not sure if 
> there are existing tests for those with ObjC code?

I put a case for it in the declprinter so it is handled appropriately so it 
would get the pointee type, whereas before this was neglected.

Other than that, there should be no difference.


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

https://reviews.llvm.org/D107775

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


[clang] e5646b9 - Revert "Revert "[analyzer] Ignore IncompleteArrayTypes in getStaticSize() for FAMs""

2021-08-25 Thread Balazs Benics via cfe-commits

Author: Balazs Benics
Date: 2021-08-25T17:19:06+02:00
New Revision: e5646b9254e0150e7897bd2658fa0b19eef39070

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

LOG: Revert "Revert "[analyzer] Ignore IncompleteArrayTypes in getStaticSize() 
for FAMs""

This reverts commit df1f4e0cc6ec9a734aae41ffd48ee8b2007fcabb.

Now the test case explicitly specifies the target triple.
I decided to use x86_64 for that matter, to have a fixed
bitwidth for `size_t`.

Aside from that, relanding the original changes of:
https://reviews.llvm.org/D105184

Added: 
clang/test/Analysis/flexible-array-members.c

Modified: 
clang/lib/StaticAnalyzer/Core/MemRegion.cpp

Removed: 




diff  --git a/clang/lib/StaticAnalyzer/Core/MemRegion.cpp 
b/clang/lib/StaticAnalyzer/Core/MemRegion.cpp
index bd725ee9eaa36..1a614d4d2bcdb 100644
--- a/clang/lib/StaticAnalyzer/Core/MemRegion.cpp
+++ b/clang/lib/StaticAnalyzer/Core/MemRegion.cpp
@@ -768,14 +768,27 @@ DefinedOrUnknownSVal 
MemRegionManager::getStaticSize(const MemRegion *MR,
   return UnknownVal();
 
 QualType Ty = cast(SR)->getDesugaredValueType(Ctx);
-DefinedOrUnknownSVal Size = getElementExtent(Ty, SVB);
+const DefinedOrUnknownSVal Size = getElementExtent(Ty, SVB);
 
 // A zero-length array at the end of a struct often stands for dynamically
 // allocated extra memory.
-if (Size.isZeroConstant()) {
-  if (isa(Ty))
-return UnknownVal();
-}
+const auto isFlexibleArrayMemberCandidate = [this](QualType Ty) -> bool {
+  const ArrayType *AT = Ctx.getAsArrayType(Ty);
+  if (!AT)
+return false;
+  if (isa(AT))
+return true;
+
+  if (const auto *CAT = dyn_cast(AT)) {
+const llvm::APInt &Size = CAT->getSize();
+if (Size.isNullValue())
+  return true;
+  }
+  return false;
+};
+
+if (isFlexibleArrayMemberCandidate(Ty))
+  return UnknownVal();
 
 return Size;
   }

diff  --git a/clang/test/Analysis/flexible-array-members.c 
b/clang/test/Analysis/flexible-array-members.c
new file mode 100644
index 0..6200ed6d41d27
--- /dev/null
+++ b/clang/test/Analysis/flexible-array-members.c
@@ -0,0 +1,96 @@
+// RUN: %clang_analyze_cc1 -triple x86_64-linux-gnu 
-analyzer-checker=core,unix,debug.ExprInspection %s -verify -std=c90
+// RUN: %clang_analyze_cc1 -triple x86_64-linux-gnu 
-analyzer-checker=core,unix,debug.ExprInspection %s -verify -std=c99
+// RUN: %clang_analyze_cc1 -triple x86_64-linux-gnu 
-analyzer-checker=core,unix,debug.ExprInspection %s -verify -std=c11
+// RUN: %clang_analyze_cc1 -triple x86_64-linux-gnu 
-analyzer-checker=core,unix,debug.ExprInspection %s -verify -std=c17
+
+// RUN: %clang_analyze_cc1 -triple x86_64-linux-gnu 
-analyzer-checker=core,unix,debug.ExprInspection %s -verify -std=c++98 -x c++
+// RUN: %clang_analyze_cc1 -triple x86_64-linux-gnu 
-analyzer-checker=core,unix,debug.ExprInspection %s -verify -std=c++03 -x c++
+// RUN: %clang_analyze_cc1 -triple x86_64-linux-gnu 
-analyzer-checker=core,unix,debug.ExprInspection %s -verify -std=c++11 -x c++
+// RUN: %clang_analyze_cc1 -triple x86_64-linux-gnu 
-analyzer-checker=core,unix,debug.ExprInspection %s -verify -std=c++14 -x c++
+// RUN: %clang_analyze_cc1 -triple x86_64-linux-gnu 
-analyzer-checker=core,unix,debug.ExprInspection %s -verify -std=c++17 -x c++
+
+typedef __typeof(sizeof(int)) size_t;
+size_t clang_analyzer_getExtent(void *);
+void clang_analyzer_dump(size_t);
+
+void *alloca(size_t size);
+void *malloc(size_t size);
+void free(void *ptr);
+
+void test_incomplete_array_fam() {
+  typedef struct FAM {
+char c;
+int data[];
+  } FAM;
+
+  FAM fam;
+  clang_analyzer_dump(clang_analyzer_getExtent(&fam));
+  clang_analyzer_dump(clang_analyzer_getExtent(fam.data));
+  // expected-warning@-2 {{4 S64b}}
+  // expected-warning@-2 {{Unknown}}
+
+  FAM *p = (FAM *)alloca(sizeof(FAM));
+  clang_analyzer_dump(clang_analyzer_getExtent(p));
+  clang_analyzer_dump(clang_analyzer_getExtent(p->data));
+  // expected-warning@-2 {{4 U64b}}
+  // expected-warning@-2 {{Unknown}}
+
+  FAM *q = (FAM *)malloc(sizeof(FAM));
+  clang_analyzer_dump(clang_analyzer_getExtent(q));
+  clang_analyzer_dump(clang_analyzer_getExtent(q->data));
+  // expected-warning@-2 {{4 U64b}}
+  // expected-warning@-2 {{Unknown}}
+  free(q);
+}
+
+void test_zero_length_array_fam() {
+  typedef struct FAM {
+char c;
+int data[0];
+  } FAM;
+
+  FAM fam;
+  clang_analyzer_dump(clang_analyzer_getExtent(&fam));
+  clang_analyzer_dump(clang_analyzer_getExtent(fam.data));
+  // expected-warning@-2 {{4 S64b}}
+  // expected-warning@-2 {{Unknown}}
+
+  FAM *p = (FAM *)alloca(sizeof(FAM));
+  clang_analyzer_dump(clang_analyzer_getExtent(p));
+  clang_analyzer_dump(clang_analyzer_getExtent(p->d

[PATCH] D105462: [X86] Add CRC32 feature.

2021-08-25 Thread Wang Tianqing via Phabricator via cfe-commits
tianqing added inline comments.



Comment at: clang/lib/Basic/Targets/X86.cpp:159
+  // Enable CRC32 if SSE4.2 is enabled.
+  // NOTE: In conformance with GCC behavior, CRC32 is still available even if
+  // it's explicitly disabled.

pengfei wrote:
> hjl.tools wrote:
> > craig.topper wrote:
> > > hjl.tools wrote:
> > > > tianqing wrote:
> > > > > craig.topper wrote:
> > > > > > This doesn't seem to be true. It causes gcc to crash. 
> > > > > > https://godbolt.org/z/39rEbsejh
> > > > > Well I was using GCC 11.1, it compiles.
> > > > > 
> > > > > The way I see it, crash means a bug (not surprising since it's 
> > > > > trunk), and can be interpreted as incompletely defined behavior until 
> > > > > it's fixed.
> > > > > 
> > > > > Some tests on GCC trunk:
> > > > > 1. -msse4.2: Pass - sse4.2 enables crc32.
> > > > > 2. -mcrc32 -mno-sse4.2: Pass - no-sse4.2 doesn't disable crc32.
> > > > > 3. -msse4.2 -mno-sse4.2: Error - no-sse4.2 disables crc32.
> > > > > 4. -mno-crc32 -msse4.2: Crash - undefined behavior
> > > > > 5. -msse4.2 -mno-crc32: Crash - undefined behavior
> > > > > 
> > > > > 
> > > > > It's hard to extract some consistent underlying logic from the GCC 
> > > > > results.
> > > > I posted a patch: 
> > > > https://gcc.gnu.org/pipermail/gcc-patches/2021-July/575741.html
> > > @hjl.tools does that turn the crash into making -mno-crc32 into making 
> > > crc32 instruction disabled?
> > Correct.  GCC issues an error now.
> So we don't align with GCC regarding "1. -msse4.2: Pass - sse4.2 enables 
> crc32."?
It's aligned, see clang/test/Driver/x86-mcrc32.c.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105462

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


[PATCH] D107850: [asan] Implemented intrinsic for the custom calling convention similar used by HWASan for X86.

2021-08-25 Thread Kirill Stoimenov via Phabricator via cfe-commits
kstoimenov updated this revision to Diff 368650.
kstoimenov added a comment.

Updated from the revert commit.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107850

Files:
  llvm/include/llvm/IR/Intrinsics.td
  llvm/include/llvm/Transforms/Instrumentation/AddressSanitizer.h
  llvm/lib/Target/X86/X86AsmPrinter.cpp
  llvm/lib/Target/X86/X86AsmPrinter.h
  llvm/lib/Target/X86/X86InstrCompiler.td
  llvm/lib/Target/X86/X86MCInstLower.cpp
  llvm/lib/Target/X86/X86RegisterInfo.td
  llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
  llvm/test/CodeGen/X86/asan-check-memaccess-add.ll
  llvm/test/CodeGen/X86/asan-check-memaccess-or.ll

Index: llvm/test/CodeGen/X86/asan-check-memaccess-or.ll
===
--- /dev/null
+++ llvm/test/CodeGen/X86/asan-check-memaccess-or.ll
@@ -0,0 +1,253 @@
+; RUN: llc < %s | FileCheck %s
+
+target triple = "x86_64-pc-win"
+
+define void @load1(i8* nocapture readonly %x) {
+; CHECK:  callq   __asan_check_load1_rn[[RN1:.*]]
+; CHECK:  callq   __asan_check_store1_rn[[RN1]]
+; CHECK-NEXT: retq
+  call void @llvm.asan.check.memaccess(i8* %x, i32 0)
+  call void @llvm.asan.check.memaccess(i8* %x, i32 32)
+  ret void
+}
+
+define void @load2(i16* nocapture readonly %x) {
+; CHECK:  callq   __asan_check_load2_rn[[RN2:.*]]
+; CHECK:  callq   __asan_check_store2_rn[[RN2]]
+; CHECK-NEXT: retq
+  %1 = ptrtoint i16* %x to i64
+  %2 = bitcast i16* %x to i8*
+  call void @llvm.asan.check.memaccess(i8* %2, i32 2)
+  call void @llvm.asan.check.memaccess(i8* %2, i32 34)
+  ret void
+}
+
+define void @load4(i32* nocapture readonly %x) {
+; CHECK:  callq   __asan_check_load4_rn[[RN4:.*]]
+; CHECK:  callq   __asan_check_store4_rn[[RN4]]
+; CHECK-NEXT: retq
+  %1 = ptrtoint i32* %x to i64
+  %2 = bitcast i32* %x to i8*
+  call void @llvm.asan.check.memaccess(i8* %2, i32 4)
+  call void @llvm.asan.check.memaccess(i8* %2, i32 36)
+  ret void
+}
+define void @load8(i64* nocapture readonly %x) {
+; CHECK:  callq   __asan_check_load8_rn[[RN8:.*]]
+; CHECK:  callq   __asan_check_store8_rn[[RN8]]
+; CHECK-NEXT: retq
+  %1 = ptrtoint i64* %x to i64
+  %2 = bitcast i64* %x to i8*
+  call void @llvm.asan.check.memaccess(i8* %2, i32 6)
+  call void @llvm.asan.check.memaccess(i8* %2, i32 38)
+  ret void
+}
+
+define void @load16(i128* nocapture readonly %x) {
+; CHECK:  callq   __asan_check_load16_rn[[RN16:.*]]
+; CHECK:  callq   __asan_check_store16_rn[[RN16]]
+; CHECK-NEXT: retq
+  %1 = ptrtoint i128* %x to i64
+  %2 = bitcast i128* %x to i8*
+  call void @llvm.asan.check.memaccess(i8* %2, i32 8)
+  call void @llvm.asan.check.memaccess(i8* %2, i32 40)
+  ret void
+}
+
+; CHECK:  .type   __asan_check_load1_rn[[RN1]],@function
+; CHECK-NEXT: .weak   __asan_check_load1_rn[[RN1]]
+; CHECK-NEXT: .hidden __asan_check_load1_rn[[RN1]]
+; CHECK-NEXT: __asan_check_load1_rn[[RN1]]:
+; CHECK-NEXT: movq[[REG:.*]], %r8
+; CHECK-NEXT: shrq$3, %r8
+; CHECK-NEXT: orq $17592186044416, %r8{{.*}}
+; CHECK-NEXT: movb(%r8), %r8b
+; CHECK-NEXT: testb   %r8b, %r8b
+; CHECK-NEXT: jne [[EXTRA:.*]]
+; CHECK-NEXT: [[RET:.*]]:
+; CHECK-NEXT: retq
+; CHECK-NEXT: [[EXTRA]]:
+; CHECK-NEXT: pushq   %rcx
+; CHECK-NEXT: movq[[REG]], %rcx
+; CHECK-NEXT: andl$7, %ecx
+; CHECK-NEXT: cmpl%r8d, %ecx
+; CHECK-NEXT: popq%rcx
+; CHECK-NEXT: jl  [[RET]]
+; CHECK-NEXT: movq[[REG:.*]], %rdi
+; CHECK-NEXT: jmp __asan_report_load1
+
+; CHECK:  .type   __asan_check_load2_rn[[RN2]],@function
+; CHECK-NEXT: .weak   __asan_check_load2_rn[[RN2]]
+; CHECK-NEXT: .hidden __asan_check_load2_rn[[RN2]]
+; CHECK-NEXT: __asan_check_load2_rn[[RN2]]:
+; CHECK-NEXT: movq[[REG:.*]], %r8
+; CHECK-NEXT: shrq$3, %r8
+; CHECK-NEXT: orq $17592186044416, %r8{{.*}}
+; CHECK-NEXT: movb(%r8), %r8b
+; CHECK-NEXT: testb   %r8b, %r8b
+; CHECK-NEXT: jne [[EXTRA:.*]]
+; CHECK-NEXT: [[RET:.*]]:
+; CHECK-NEXT: retq
+; CHECK-NEXT: [[EXTRA]]:
+; CHECK-NEXT: pushq   %rcx
+; CHECK-NEXT: movq[[REG]], %rcx
+; CHECK-NEXT: andl$7, %ecx
+; CHECK-NEXT: addl$1, %ecx
+; CHECK-NEXT: cmpl%r8d, %ecx
+; CHECK-NEXT: popq%rcx
+; CHECK-NEXT: jl  [[RET]]
+; CHECK-NEXT: movq[[REG:.*]], %rdi
+; CHECK-NEXT: jmp __asan_report_load2
+
+; CHECK:  .type   __asan_check_load4_rn[[RN4]],@function
+; CHECK-NEXT: .weak   __asan_check_load4_rn[[RN4]]
+; CHECK-NEXT: .hidden __asan_check_load4_rn[[RN4]]
+

[PATCH] D107850: [asan] Implemented intrinsic for the custom calling convention similar used by HWASan for X86.

2021-08-25 Thread Kirill Stoimenov 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 rG832aae738bec: [asan] Implemented intrinsic for the custom 
calling convention similar used by… (authored by kstoimenov).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107850

Files:
  llvm/include/llvm/IR/Intrinsics.td
  llvm/include/llvm/Transforms/Instrumentation/AddressSanitizer.h
  llvm/lib/Target/X86/X86AsmPrinter.cpp
  llvm/lib/Target/X86/X86AsmPrinter.h
  llvm/lib/Target/X86/X86InstrCompiler.td
  llvm/lib/Target/X86/X86MCInstLower.cpp
  llvm/lib/Target/X86/X86RegisterInfo.td
  llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
  llvm/test/CodeGen/X86/asan-check-memaccess-add.ll
  llvm/test/CodeGen/X86/asan-check-memaccess-or.ll

Index: llvm/test/CodeGen/X86/asan-check-memaccess-or.ll
===
--- /dev/null
+++ llvm/test/CodeGen/X86/asan-check-memaccess-or.ll
@@ -0,0 +1,253 @@
+; RUN: llc < %s | FileCheck %s
+
+target triple = "x86_64-pc-win"
+
+define void @load1(i8* nocapture readonly %x) {
+; CHECK:  callq   __asan_check_load1_rn[[RN1:.*]]
+; CHECK:  callq   __asan_check_store1_rn[[RN1]]
+; CHECK-NEXT: retq
+  call void @llvm.asan.check.memaccess(i8* %x, i32 0)
+  call void @llvm.asan.check.memaccess(i8* %x, i32 32)
+  ret void
+}
+
+define void @load2(i16* nocapture readonly %x) {
+; CHECK:  callq   __asan_check_load2_rn[[RN2:.*]]
+; CHECK:  callq   __asan_check_store2_rn[[RN2]]
+; CHECK-NEXT: retq
+  %1 = ptrtoint i16* %x to i64
+  %2 = bitcast i16* %x to i8*
+  call void @llvm.asan.check.memaccess(i8* %2, i32 2)
+  call void @llvm.asan.check.memaccess(i8* %2, i32 34)
+  ret void
+}
+
+define void @load4(i32* nocapture readonly %x) {
+; CHECK:  callq   __asan_check_load4_rn[[RN4:.*]]
+; CHECK:  callq   __asan_check_store4_rn[[RN4]]
+; CHECK-NEXT: retq
+  %1 = ptrtoint i32* %x to i64
+  %2 = bitcast i32* %x to i8*
+  call void @llvm.asan.check.memaccess(i8* %2, i32 4)
+  call void @llvm.asan.check.memaccess(i8* %2, i32 36)
+  ret void
+}
+define void @load8(i64* nocapture readonly %x) {
+; CHECK:  callq   __asan_check_load8_rn[[RN8:.*]]
+; CHECK:  callq   __asan_check_store8_rn[[RN8]]
+; CHECK-NEXT: retq
+  %1 = ptrtoint i64* %x to i64
+  %2 = bitcast i64* %x to i8*
+  call void @llvm.asan.check.memaccess(i8* %2, i32 6)
+  call void @llvm.asan.check.memaccess(i8* %2, i32 38)
+  ret void
+}
+
+define void @load16(i128* nocapture readonly %x) {
+; CHECK:  callq   __asan_check_load16_rn[[RN16:.*]]
+; CHECK:  callq   __asan_check_store16_rn[[RN16]]
+; CHECK-NEXT: retq
+  %1 = ptrtoint i128* %x to i64
+  %2 = bitcast i128* %x to i8*
+  call void @llvm.asan.check.memaccess(i8* %2, i32 8)
+  call void @llvm.asan.check.memaccess(i8* %2, i32 40)
+  ret void
+}
+
+; CHECK:  .type   __asan_check_load1_rn[[RN1]],@function
+; CHECK-NEXT: .weak   __asan_check_load1_rn[[RN1]]
+; CHECK-NEXT: .hidden __asan_check_load1_rn[[RN1]]
+; CHECK-NEXT: __asan_check_load1_rn[[RN1]]:
+; CHECK-NEXT: movq[[REG:.*]], %r8
+; CHECK-NEXT: shrq$3, %r8
+; CHECK-NEXT: orq $17592186044416, %r8{{.*}}
+; CHECK-NEXT: movb(%r8), %r8b
+; CHECK-NEXT: testb   %r8b, %r8b
+; CHECK-NEXT: jne [[EXTRA:.*]]
+; CHECK-NEXT: [[RET:.*]]:
+; CHECK-NEXT: retq
+; CHECK-NEXT: [[EXTRA]]:
+; CHECK-NEXT: pushq   %rcx
+; CHECK-NEXT: movq[[REG]], %rcx
+; CHECK-NEXT: andl$7, %ecx
+; CHECK-NEXT: cmpl%r8d, %ecx
+; CHECK-NEXT: popq%rcx
+; CHECK-NEXT: jl  [[RET]]
+; CHECK-NEXT: movq[[REG:.*]], %rdi
+; CHECK-NEXT: jmp __asan_report_load1
+
+; CHECK:  .type   __asan_check_load2_rn[[RN2]],@function
+; CHECK-NEXT: .weak   __asan_check_load2_rn[[RN2]]
+; CHECK-NEXT: .hidden __asan_check_load2_rn[[RN2]]
+; CHECK-NEXT: __asan_check_load2_rn[[RN2]]:
+; CHECK-NEXT: movq[[REG:.*]], %r8
+; CHECK-NEXT: shrq$3, %r8
+; CHECK-NEXT: orq $17592186044416, %r8{{.*}}
+; CHECK-NEXT: movb(%r8), %r8b
+; CHECK-NEXT: testb   %r8b, %r8b
+; CHECK-NEXT: jne [[EXTRA:.*]]
+; CHECK-NEXT: [[RET:.*]]:
+; CHECK-NEXT: retq
+; CHECK-NEXT: [[EXTRA]]:
+; CHECK-NEXT: pushq   %rcx
+; CHECK-NEXT: movq[[REG]], %rcx
+; CHECK-NEXT: andl$7, %ecx
+; CHECK-NEXT: addl$1, %ecx
+; CHECK-NEXT: cmpl%r8d, %ecx
+; CHECK-NEXT: popq%rcx
+; CHECK-NEXT: jl  [[RET]]
+; CHECK-NEXT: movq[[REG:.*]], %rdi
+; CHECK-NEXT: jmp __asan_report_load2
+
+; CHECK:  .type   _

[PATCH] D105462: [X86] Add CRC32 feature.

2021-08-25 Thread Wang Tianqing via Phabricator via cfe-commits
tianqing added inline comments.



Comment at: llvm/lib/Support/X86TargetParser.cpp:531
 constexpr FeatureBitset ImpliedFeaturesSSSE3 = FeatureSSE3;
 constexpr FeatureBitset ImpliedFeaturesSSE4_1 = FeatureSSSE3;
 constexpr FeatureBitset ImpliedFeaturesSSE4_2 = FeatureSSE4_1;

pengfei wrote:
> hjl.tools wrote:
> > pengfei wrote:
> > > Can we let `ImpliedFeaturesSSE4_1 = FeatureSSSE3 | FeaturesCRC32` so that 
> > > we don't need to add `crc32` on sse4.1 and above?
> > SSE4.1 implies CRC32.  But CRC32 shouldn't imply SSE4.1.
> Yes. The constexpr here means `FeaturesSSE4_1` implies both `FeatureSSSE3` 
> and `FeaturesCRC32`.
CRC32 was added in SSE4.2.

In LLVM this implication relationship is bidirectional, that is:

* -msse4.2 implies -mcrc32
* -mcrc32 doesn't implies -msse4.2.
* -mno-sse4.2 doesn't implies -mno-crc32.
* But -mno-crc32 also implies -mno-sse4.2.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105462

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


[PATCH] D105462: [X86] Add CRC32 feature.

2021-08-25 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: clang/lib/Basic/Targets/X86.cpp:158
 
+  // Enable CRC32 if SSE4.2 is enabled and CRC32 is not explicitly set.
+  I = Features.find("sse4.2");

Why doesn't this say "not explicitly disabled" like the others above?



Comment at: clang/lib/Headers/ia32intrin.h:19
 #define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__))
 #define __DEFAULT_FN_ATTRS_SSE42 __attribute__((__always_inline__, 
__nodebug__, __target__("sse4.2")))
+#define __DEFAULT_FN_ATTRS_CRC32 __attribute__((__always_inline__, 
__nodebug__, __target__("crc32")))

Is __DEFAULT_FN_ATTRS_SSE42 dead now?



Comment at: clang/lib/Headers/smmintrin.h:2358
-///operand \a __D.
-static __inline__ unsigned int __DEFAULT_FN_ATTRS
-_mm_crc32_u8(unsigned int __C, unsigned char __D)

Was min vector width incorrectly being applied to these before?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105462

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


[PATCH] D108377: [asan] Implemented flag to emit intrinsics to optimize ASan callbacks.

2021-08-25 Thread Kirill Stoimenov via Phabricator via cfe-commits
kstoimenov updated this revision to Diff 368663.
kstoimenov added a comment.

Upload after submitting the main patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108377

Files:
  llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
  llvm/test/Instrumentation/AddressSanitizer/asan-optimize-callbacks.ll


Index: llvm/test/Instrumentation/AddressSanitizer/asan-optimize-callbacks.ll
===
--- /dev/null
+++ llvm/test/Instrumentation/AddressSanitizer/asan-optimize-callbacks.ll
@@ -0,0 +1,14 @@
+; RUN: opt < %s -asan -asan-module -enable-new-pm=0 -S | FileCheck %s
+
+target triple = "x86_64-unknown-linux-gnu"
+
+define void @load1(i8* %p1, i16* %p2, i32* %p4, i64* %p8, i128* %p16)
+  sanitize_address {
+  %n1 = load i8, i8* %p1
+  %n2 = load i16, i16* %p2
+  %n4 = load i32, i32* %p4
+  %n8 = load i64, i64* %p8
+  %n16 = load i128, i128* %p16
+;  store i32 0, i32* %p4, align 8
+  ret void
+}
Index: llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
===
--- llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
+++ llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
@@ -356,6 +356,10 @@
 static cl::opt ClOpt("asan-opt", cl::desc("Optimize instrumentation"),
cl::Hidden, cl::init(true));
 
+static cl::opt ClOptimizeCallbacks("asan-optimize-callbacks",
+ cl::desc("Optimize callbacks"),
+ cl::Hidden, cl::init(false));
+
 static cl::opt ClOptSameTemp(
 "asan-opt-same-temp", cl::desc("Instrument the same temp just once"),
 cl::Hidden, cl::init(true));
@@ -657,6 +661,7 @@
 C = &(M.getContext());
 LongSize = M.getDataLayout().getPointerSizeInBits();
 IntptrTy = Type::getIntNTy(*C, LongSize);
+Int8PtrTy = Type::getInt8PtrTy(*C);
 TargetTriple = Triple(M.getTargetTriple());
 
 Mapping = getShadowMapping(TargetTriple, LongSize, this->CompileKernel);
@@ -747,6 +752,7 @@
   bool UseAfterScope;
   AsanDetectStackUseAfterReturnMode UseAfterReturn;
   Type *IntptrTy;
+  Type *Int8PtrTy;
   ShadowMapping Mapping;
   FunctionCallee AsanHandleNoReturnFunc;
   FunctionCallee AsanPtrCmpFunction, AsanPtrSubFunction;
@@ -1768,14 +1774,23 @@
   IRBuilder<> IRB(InsertBefore);
   Value *AddrLong = IRB.CreatePointerCast(Addr, IntptrTy);
   size_t AccessSizeIndex = TypeSizeToSizeIndex(TypeSize);
+  const ASanAccessInfo AccessInfo(IsWrite, CompileKernel, AccessSizeIndex);
 
   if (UseCalls) {
-if (Exp == 0)
-  IRB.CreateCall(AsanMemoryAccessCallback[IsWrite][0][AccessSizeIndex],
- AddrLong);
-else
-  IRB.CreateCall(AsanMemoryAccessCallback[IsWrite][1][AccessSizeIndex],
- {AddrLong, ConstantInt::get(IRB.getInt32Ty(), Exp)});
+if (ClOptimizeCallbacks) {
+  Value *Ptr8 = IRB.CreatePointerCast(Addr, Int8PtrTy);
+  Module *M = IRB.GetInsertBlock()->getParent()->getParent();
+  IRB.CreateCall(
+  Intrinsic::getDeclaration(M, Intrinsic::asan_check_memaccess),
+  {Ptr8, ConstantInt::get(IRB.getInt32Ty(), AccessInfo.Packed)});
+} else {
+  if (Exp == 0)
+IRB.CreateCall(AsanMemoryAccessCallback[IsWrite][0][AccessSizeIndex],
+   AddrLong);
+  else
+IRB.CreateCall(AsanMemoryAccessCallback[IsWrite][1][AccessSizeIndex],
+   {AddrLong, ConstantInt::get(IRB.getInt32Ty(), Exp)});
+}
 return;
   }
 


Index: llvm/test/Instrumentation/AddressSanitizer/asan-optimize-callbacks.ll
===
--- /dev/null
+++ llvm/test/Instrumentation/AddressSanitizer/asan-optimize-callbacks.ll
@@ -0,0 +1,14 @@
+; RUN: opt < %s -asan -asan-module -enable-new-pm=0 -S | FileCheck %s
+
+target triple = "x86_64-unknown-linux-gnu"
+
+define void @load1(i8* %p1, i16* %p2, i32* %p4, i64* %p8, i128* %p16)
+  sanitize_address {
+  %n1 = load i8, i8* %p1
+  %n2 = load i16, i16* %p2
+  %n4 = load i32, i32* %p4
+  %n8 = load i64, i64* %p8
+  %n16 = load i128, i128* %p16
+;  store i32 0, i32* %p4, align 8
+  ret void
+}
Index: llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
===
--- llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
+++ llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
@@ -356,6 +356,10 @@
 static cl::opt ClOpt("asan-opt", cl::desc("Optimize instrumentation"),
cl::Hidden, cl::init(true));
 
+static cl::opt ClOptimizeCallbacks("asan-optimize-callbacks",
+ cl::desc("Optimize callbacks"),
+ cl::Hidden, cl::init(false));
+
 static cl::opt ClOptSameTemp(
 "asan-opt-same-temp", cl::desc("Instrument the same

[PATCH] D108708: [openmp][amdgpu] Initial gfx10 offloading implementation

2021-08-25 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield created this revision.
JonChesterfield added reviewers: dpalermo, jdoerfert, tianshilei1992, ronlieb, 
ye-luo, grokos.
Herald added subscribers: kerbowa, guansong, t-tye, tpr, dstuttard, yaxunl, 
mgorny, nhaehnle, jvesely, kzhuravl.
JonChesterfield requested review of this revision.
Herald added subscribers: llvm-commits, openmp-commits, cfe-commits, sstefan1, 
wdng.
Herald added projects: clang, OpenMP, LLVM.

Lets wavefront size be 32 for amdgpu openmp, as well as 64.

Fixes up as little as possible to pass that through the libraries. This change
is end to end, as opposed to updating clang/devicertl/plugin separately. It can
be broken up for review/commit if preferred. Posting as-is so that others with
a gfx10 can try it out. It works roughly as well as gfx9 for me, but there are
probably bugs remaining as well as the todo: for letting grid values vary more.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D108708

Files:
  clang/lib/Basic/Targets/AMDGPU.h
  llvm/include/llvm/Frontend/OpenMP/OMPGridValues.h
  openmp/libomptarget/deviceRTLs/amdgcn/CMakeLists.txt
  openmp/libomptarget/deviceRTLs/amdgcn/src/target_impl.h
  openmp/libomptarget/plugins/amdgpu/src/rtl.cpp

Index: openmp/libomptarget/plugins/amdgpu/src/rtl.cpp
===
--- openmp/libomptarget/plugins/amdgpu/src/rtl.cpp
+++ openmp/libomptarget/plugins/amdgpu/src/rtl.cpp
@@ -436,8 +436,9 @@
   int MaxTeamsDefault;
 };
 
+template 
 static constexpr const llvm::omp::GV &getGridValue() {
-  return llvm::omp::AMDGPUGridValues;
+  return llvm::omp::getAMDGPUGridValues();
 }
 
 /// Class containing all the device information
@@ -508,10 +509,24 @@
   static const unsigned HardTeamLimit =
   (1 << 16) - 1; // 64K needed to fit in uint16
   static const int DefaultNumTeams = 128;
-  static const int Max_Teams = getGridValue().GV_Max_Teams;
-  static const int Warp_Size = getGridValue().GV_Warp_Size;
-  static const int Max_WG_Size = getGridValue().GV_Max_WG_Size;
-  static const int Default_WG_Size = getGridValue().GV_Default_WG_Size;
+
+  // These need to be per-device since different devices can have different
+  // wave sizes, but are currently the same number for each so that refactor
+  // can be postponed.
+  static_assert(getGridValue<32>().GV_Max_Teams ==
+getGridValue<64>().GV_Max_Teams,
+"");
+  static const int Max_Teams = getGridValue<64>().GV_Max_Teams;
+
+  static_assert(getGridValue<32>().GV_Max_WG_Size ==
+getGridValue<64>().GV_Max_WG_Size,
+"");
+  static const int Max_WG_Size = getGridValue<64>().GV_Max_WG_Size;
+
+  static_assert(getGridValue<32>().GV_Default_WG_Size ==
+getGridValue<64>().GV_Default_WG_Size,
+"");
+  static const int Default_WG_Size = getGridValue<64>().GV_Default_WG_Size;
 
   using MemcpyFunc = hsa_status_t (*)(hsa_signal_t, void *, const void *,
   size_t size, hsa_agent_t,
@@ -1060,8 +1075,9 @@
 DP("Queried wavefront size: %d\n", wavefront_size);
 DeviceInfo.WarpSize[device_id] = wavefront_size;
   } else {
-DP("Default wavefront size: %d\n", getGridValue().GV_Warp_Size);
-DeviceInfo.WarpSize[device_id] = getGridValue().GV_Warp_Size;
+// TODO: Burn the wavefront size into the code object
+DP("Warning: Unknown wavefront size, assuming 64\n");
+DeviceInfo.WarpSize[device_id] = 64;
   }
 
   // Adjust teams to the env variables
@@ -1886,9 +1902,10 @@
   int WorkgroupSize;
   int GridSize;
 };
-launchVals getLaunchVals(EnvironmentVariables Env, int ConstWGSize,
- int ExecutionMode, int num_teams, int thread_limit,
- uint64_t loop_tripcount, int DeviceNumTeams) {
+launchVals getLaunchVals(int WarpSize, EnvironmentVariables Env,
+ int ConstWGSize, int ExecutionMode, int num_teams,
+ int thread_limit, uint64_t loop_tripcount,
+ int DeviceNumTeams) {
 
   int threadsPerGroup = RTLDeviceInfoTy::Default_WG_Size;
   int num_groups = 0;
@@ -1901,7 +1918,7 @@
   if (print_kernel_trace & STARTUP_DETAILS) {
 DP("RTLDeviceInfoTy::Max_Teams: %d\n", RTLDeviceInfoTy::Max_Teams);
 DP("Max_Teams: %d\n", Max_Teams);
-DP("RTLDeviceInfoTy::Warp_Size: %d\n", RTLDeviceInfoTy::Warp_Size);
+DP("RTLDeviceInfoTy::Warp_Size: %d\n", WarpSize);
 DP("RTLDeviceInfoTy::Max_WG_Size: %d\n", RTLDeviceInfoTy::Max_WG_Size);
 DP("RTLDeviceInfoTy::Default_WG_Size: %d\n",
RTLDeviceInfoTy::Default_WG_Size);
@@ -1914,8 +1931,8 @@
 threadsPerGroup = thread_limit;
 DP("Setting threads per block to requested %d\n", thread_limit);
 if (ExecutionMode == GENERIC) { // Add master warp for GENERIC
-  threadsPerGroup += RTLDeviceInfoTy::Warp_Size;
-  DP("Adding master wavefront: +%d threads\n", RTLDeviceInfoTy::Warp_Size);
+  thread

[PATCH] D108708: [openmp][amdgpu] Initial gfx10 offloading implementation

2021-08-25 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield added inline comments.



Comment at: llvm/include/llvm/Frontend/OpenMP/OMPGridValues.h:102
+
+template  constexpr const GV &getAMDGPUGridValues() {
+  static_assert(wavesize == 32 || wavesize == 64, "");

Want to resolve this at compile time for the deviceRTL. Hoping to think of a 
prettier way to spell it. Currently all but one field are the same for the two, 
that's probably suboptimal for performance.



Comment at: openmp/libomptarget/deviceRTLs/amdgcn/CMakeLists.txt:111
+set(mcpus gfx700 gfx701 gfx801 gfx803 gfx900 gfx902 gfx906 gfx908 gfx1010 
gfx1031)
 if (DEFINED LIBOMPTARGET_AMDGCN_GFXLIST)
   set(mcpus ${LIBOMPTARGET_AMDGCN_GFXLIST})

I've got a gfx1010 locally and @dpalermo has a gfx1031



Comment at: openmp/libomptarget/deviceRTLs/amdgcn/src/target_impl.h:36
 
 INLINE constexpr const llvm::omp::GV &getGridValue() {
+  return llvm::omp::getAMDGPUGridValues<__AMDGCN_WAVEFRONT_SIZE>();

compiling for device code means a macro is available to pick between the two


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108708

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


[PATCH] D108710: [clang][deps] Reset non-modular language and preprocessor options

2021-08-25 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 created this revision.
jansvoboda11 added reviewers: Bigcheese, dexonsmith, arphaman.
jansvoboda11 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

There are a number of language and preprocessor options that are reset in the 
`CompilerInvocation` that describes the build of an implicit module. This patch 
uses the logic for explicit modules as well.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D108710

Files:
  clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
  clang/test/ClangScanDeps/Inputs/removed-args/cdb.json.template
  clang/test/ClangScanDeps/Inputs/removed-args/header.h
  clang/test/ClangScanDeps/Inputs/removed-args/mod_header.h
  clang/test/ClangScanDeps/Inputs/removed-args/mod_tu.h
  clang/test/ClangScanDeps/Inputs/removed-args/module.modulemap
  clang/test/ClangScanDeps/Inputs/removed-args/tu.c
  clang/test/ClangScanDeps/removed-args.c

Index: clang/test/ClangScanDeps/removed-args.c
===
--- /dev/null
+++ clang/test/ClangScanDeps/removed-args.c
@@ -0,0 +1,56 @@
+// RUN: rm -rf %t && mkdir %t
+// RUN: cp %S/Inputs/removed-args/* %t
+
+// RUN: sed "s|DIR|%/t|g" %S/Inputs/removed-args/cdb.json.template > %t/cdb.json
+// RUN: echo -%t > %t/result.json
+// RUN: clang-scan-deps -compilation-database %t/cdb.json -format experimental-full >> %t/result.json
+// RUN: cat %t/result.json | sed 's:\?:/:g' | FileCheck %s
+//
+// CHECK:  -[[PREFIX:.*]]
+// CHECK-NEXT: {
+// CHECK-NEXT:   "modules": [
+// CHECK-NEXT: {
+// CHECK-NEXT:   "clang-module-deps": [],
+// CHECK-NEXT:   "clang-modulemap-file": "[[PREFIX]]/module.modulemap",
+// CHECK-NEXT:   "command-line": [
+// CHECK-NEXT: "-cc1"
+// CHECK-NOT:  "-include"
+// CHECK:],
+// CHECK-NEXT:   "context-hash": "[[HASH_MOD_HEADER:.*]]",
+// CHECK-NEXT:   "file-deps": [
+// CHECK-NEXT: "[[PREFIX]]/mod_header.h",
+// CHECK-NEXT: "[[PREFIX]]/module.modulemap"
+// CHECK-NEXT:   ],
+// CHECK-NEXT:   "name": "ModHeader"
+// CHECK-NEXT: },
+// CHECK-NEXT: {
+// CHECK-NEXT:   "clang-module-deps": [],
+// CHECK-NEXT:   "clang-modulemap-file": "[[PREFIX]]/module.modulemap",
+// CHECK-NEXT:   "command-line": [
+// CHECK-NEXT: "-cc1"
+// CHECK-NOT:  "-include"
+// CHECK:],
+// CHECK-NEXT:   "context-hash": "[[HASH_MOD_TU:.*]]",
+// CHECK-NEXT:   "file-deps": [
+// CHECK-NEXT: "[[PREFIX]]/mod_tu.h",
+// CHECK-NEXT: "[[PREFIX]]/module.modulemap"
+// CHECK-NEXT:   ],
+// CHECK-NEXT:   "name": "ModTU"
+// CHECK-NEXT: }
+// CHECK-NEXT:   ],
+// CHECK-NEXT:   "translation-units": [
+// CHECK-NEXT: {
+// CHECK-NEXT:   "clang-context-hash": "[[HASH_TU:.*]]",
+// CHECK-NEXT:   "clang-module-deps": [
+// CHECK-NEXT: {
+// CHECK-NEXT:   "context-hash": "[[HASH_MOD_HEADER]]",
+// CHECK-NEXT:   "module-name": "ModHeader"
+// CHECK-NEXT: },
+// CHECK-NEXT: {
+// CHECK-NEXT:   "context-hash": "[[HASH_MOD_TU]]",
+// CHECK-NEXT:   "module-name": "ModTU"
+// CHECK-NEXT: }
+// CHECK-NEXT:   ]
+// CHECK:  }
+// CHECK-NEXT:   ]
+// CHECK-NEXT: }
Index: clang/test/ClangScanDeps/Inputs/removed-args/tu.c
===
--- /dev/null
+++ clang/test/ClangScanDeps/Inputs/removed-args/tu.c
@@ -0,0 +1 @@
+#include "mod_tu.h"
Index: clang/test/ClangScanDeps/Inputs/removed-args/module.modulemap
===
--- /dev/null
+++ clang/test/ClangScanDeps/Inputs/removed-args/module.modulemap
@@ -0,0 +1,2 @@
+module ModHeader { header "mod_header.h" }
+module ModTU { header "mod_tu.h" }
Index: clang/test/ClangScanDeps/Inputs/removed-args/header.h
===
--- /dev/null
+++ clang/test/ClangScanDeps/Inputs/removed-args/header.h
@@ -0,0 +1 @@
+#include "mod_header.h"
Index: clang/test/ClangScanDeps/Inputs/removed-args/cdb.json.template
===
--- /dev/null
+++ clang/test/ClangScanDeps/Inputs/removed-args/cdb.json.template
@@ -0,0 +1,7 @@
+[
+  {
+"directory": "DIR",
+"command": "clang -fsyntax-only DIR/tu.c -fmodules -fimplicit-module-maps -fmodules-cache-path=DIR/cache -include DIR/header.h -o DIR/tu.o",
+"file": "DIR/tu.c"
+  }
+]
Index: clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
===
--- clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
+++ clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
@@ -22,6 +22,9 @@
   // Make a deep copy of the original Clang invocation.
   CompilerInvocation CI(OriginalInvocation);
 
+  CI.getLangOpts()->resetNonModularOption

[clang] cc4bfd7 - [Sema][ObjC] Allow conversions between pointers to ObjC pointers and

2021-08-25 Thread Akira Hatanaka via cfe-commits

Author: Akira Hatanaka
Date: 2021-08-25T10:22:29-07:00
New Revision: cc4bfd7f59d5a0024ada2a5c2a6f46d53290882b

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

LOG: [Sema][ObjC] Allow conversions between pointers to ObjC pointers and
pointers to structs

clang was just being conservative and trying to prevent users from
messing up the qualifier on the inner pointer type. Lifting this
restriction enables using some of the libc++ templates with ObjC pointer
arguments, which clang currently rejects.

rdar://79018677

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

Added: 


Modified: 
clang/lib/Sema/SemaExprObjC.cpp
clang/test/SemaObjC/arc-type-conversion.m

Removed: 




diff  --git a/clang/lib/Sema/SemaExprObjC.cpp b/clang/lib/Sema/SemaExprObjC.cpp
index 9e46801ea5089..102edb0136e59 100644
--- a/clang/lib/Sema/SemaExprObjC.cpp
+++ b/clang/lib/Sema/SemaExprObjC.cpp
@@ -4450,9 +4450,14 @@ Sema::CheckObjCConversion(SourceRange castRange, 
QualType castType,
   // Allow casts between pointers to lifetime types (e.g., __strong id*)
   // and pointers to void (e.g., cv void *). Casting from void* to lifetime*
   // must be explicit.
-  if (exprACTC == ACTC_indirectRetainable && castACTC == ACTC_voidPtr)
+  // Allow conversions between pointers to lifetime types and coreFoundation
+  // pointers too, but only when the conversions are explicit.
+  if (exprACTC == ACTC_indirectRetainable &&
+  (castACTC == ACTC_voidPtr ||
+   (castACTC == ACTC_coreFoundation && isCast(CCK
 return ACR_okay;
-  if (castACTC == ACTC_indirectRetainable && exprACTC == ACTC_voidPtr &&
+  if (castACTC == ACTC_indirectRetainable &&
+  (exprACTC == ACTC_voidPtr || exprACTC == ACTC_coreFoundation) &&
   isCast(CCK))
 return ACR_okay;
 

diff  --git a/clang/test/SemaObjC/arc-type-conversion.m 
b/clang/test/SemaObjC/arc-type-conversion.m
index 5cf2cf4b745e2..a349d00ec8513 100644
--- a/clang/test/SemaObjC/arc-type-conversion.m
+++ b/clang/test/SemaObjC/arc-type-conversion.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -fobjc-arc -fobjc-runtime-has-weak -verify 
-fblocks %s
+// RUN: %clang_cc1 -fsyntax-only -fobjc-arc -fobjc-runtime-has-weak -verify 
-fblocks -Wno-incompatible-pointer-types %s
 
 typedef const void * CFTypeRef;
 CFTypeRef CFBridgingRetain(id X);
@@ -96,3 +96,14 @@ void conversion_in_conditional(id a, void* b) {
   id c = 1 ? a : b; // expected-error {{operands to conditional of types 'id' 
and 'void *' are incompatible in ARC mode}}
   id d = 1 ? b : a; // expected-error {{operands to conditional of types 'void 
*' and 'id' are incompatible in ARC mode}}
 }
+
+void conversion_pointer_to_id(__strong id *x) {
+  struct S {
+int a[2];
+  } s, *p;
+
+  x = (__strong id *)&s;
+  x = &s; // expected-error {{implicit conversion of a non-Objective-C pointer 
type 'struct S *' to '__strong id *' is disallowed with ARC}}
+  p = (struct S *)x;
+  p = x; // expected-error {{implicit conversion of an indirect pointer to an 
Objective-C pointer to 'struct S *' is disallowed with ARC}}
+}



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


[PATCH] D107021: [Sema][ObjC] Allow conversions between pointers to ObjC pointers and pointers to structs

2021-08-25 Thread Akira Hatanaka via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGcc4bfd7f59d5: [Sema][ObjC] Allow conversions between 
pointers to ObjC pointers and (authored by ahatanak).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107021

Files:
  clang/lib/Sema/SemaExprObjC.cpp
  clang/test/SemaObjC/arc-type-conversion.m


Index: clang/test/SemaObjC/arc-type-conversion.m
===
--- clang/test/SemaObjC/arc-type-conversion.m
+++ clang/test/SemaObjC/arc-type-conversion.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -fobjc-arc -fobjc-runtime-has-weak -verify 
-fblocks %s
+// RUN: %clang_cc1 -fsyntax-only -fobjc-arc -fobjc-runtime-has-weak -verify 
-fblocks -Wno-incompatible-pointer-types %s
 
 typedef const void * CFTypeRef;
 CFTypeRef CFBridgingRetain(id X);
@@ -96,3 +96,14 @@
   id c = 1 ? a : b; // expected-error {{operands to conditional of types 'id' 
and 'void *' are incompatible in ARC mode}}
   id d = 1 ? b : a; // expected-error {{operands to conditional of types 'void 
*' and 'id' are incompatible in ARC mode}}
 }
+
+void conversion_pointer_to_id(__strong id *x) {
+  struct S {
+int a[2];
+  } s, *p;
+
+  x = (__strong id *)&s;
+  x = &s; // expected-error {{implicit conversion of a non-Objective-C pointer 
type 'struct S *' to '__strong id *' is disallowed with ARC}}
+  p = (struct S *)x;
+  p = x; // expected-error {{implicit conversion of an indirect pointer to an 
Objective-C pointer to 'struct S *' is disallowed with ARC}}
+}
Index: clang/lib/Sema/SemaExprObjC.cpp
===
--- clang/lib/Sema/SemaExprObjC.cpp
+++ clang/lib/Sema/SemaExprObjC.cpp
@@ -4450,9 +4450,14 @@
   // Allow casts between pointers to lifetime types (e.g., __strong id*)
   // and pointers to void (e.g., cv void *). Casting from void* to lifetime*
   // must be explicit.
-  if (exprACTC == ACTC_indirectRetainable && castACTC == ACTC_voidPtr)
+  // Allow conversions between pointers to lifetime types and coreFoundation
+  // pointers too, but only when the conversions are explicit.
+  if (exprACTC == ACTC_indirectRetainable &&
+  (castACTC == ACTC_voidPtr ||
+   (castACTC == ACTC_coreFoundation && isCast(CCK
 return ACR_okay;
-  if (castACTC == ACTC_indirectRetainable && exprACTC == ACTC_voidPtr &&
+  if (castACTC == ACTC_indirectRetainable &&
+  (exprACTC == ACTC_voidPtr || exprACTC == ACTC_coreFoundation) &&
   isCast(CCK))
 return ACR_okay;
 


Index: clang/test/SemaObjC/arc-type-conversion.m
===
--- clang/test/SemaObjC/arc-type-conversion.m
+++ clang/test/SemaObjC/arc-type-conversion.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -fobjc-arc -fobjc-runtime-has-weak -verify -fblocks %s
+// RUN: %clang_cc1 -fsyntax-only -fobjc-arc -fobjc-runtime-has-weak -verify -fblocks -Wno-incompatible-pointer-types %s
 
 typedef const void * CFTypeRef;
 CFTypeRef CFBridgingRetain(id X);
@@ -96,3 +96,14 @@
   id c = 1 ? a : b; // expected-error {{operands to conditional of types 'id' and 'void *' are incompatible in ARC mode}}
   id d = 1 ? b : a; // expected-error {{operands to conditional of types 'void *' and 'id' are incompatible in ARC mode}}
 }
+
+void conversion_pointer_to_id(__strong id *x) {
+  struct S {
+int a[2];
+  } s, *p;
+
+  x = (__strong id *)&s;
+  x = &s; // expected-error {{implicit conversion of a non-Objective-C pointer type 'struct S *' to '__strong id *' is disallowed with ARC}}
+  p = (struct S *)x;
+  p = x; // expected-error {{implicit conversion of an indirect pointer to an Objective-C pointer to 'struct S *' is disallowed with ARC}}
+}
Index: clang/lib/Sema/SemaExprObjC.cpp
===
--- clang/lib/Sema/SemaExprObjC.cpp
+++ clang/lib/Sema/SemaExprObjC.cpp
@@ -4450,9 +4450,14 @@
   // Allow casts between pointers to lifetime types (e.g., __strong id*)
   // and pointers to void (e.g., cv void *). Casting from void* to lifetime*
   // must be explicit.
-  if (exprACTC == ACTC_indirectRetainable && castACTC == ACTC_voidPtr)
+  // Allow conversions between pointers to lifetime types and coreFoundation
+  // pointers too, but only when the conversions are explicit.
+  if (exprACTC == ACTC_indirectRetainable &&
+  (castACTC == ACTC_voidPtr ||
+   (castACTC == ACTC_coreFoundation && isCast(CCK
 return ACR_okay;
-  if (castACTC == ACTC_indirectRetainable && exprACTC == ACTC_voidPtr &&
+  if (castACTC == ACTC_indirectRetainable &&
+  (exprACTC == ACTC_voidPtr || exprACTC == ACTC_coreFoundation) &&
   isCast(CCK))
 return ACR_okay;
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D108712: Avoid nullptr dereferencing of 'SubExpr'; NFC

2021-08-25 Thread Sindhu Chittireddy via Phabricator via cfe-commits
schittir created this revision.
schittir added reviewers: aaron.ballman, erichkeane.
schittir added a project: clang.
schittir requested review of this revision.
Herald added a subscriber: cfe-commits.

Avoid nullptr dereferencing of 'Constraint'; NFC

Klocwork static code analysis exposed this bug:
Pointer 'SubExpr' returned from call to getSubExpr() function 
which may return NULL from 'cast_or_null(Operand)', 
which will be dereferenced in the statement following it

Add an assert on SubExpr to avoid nullptr dereferencing


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D108712

Files:
  clang/lib/CodeGen/MicrosoftCXXABI.cpp


Index: clang/lib/CodeGen/MicrosoftCXXABI.cpp
===
--- clang/lib/CodeGen/MicrosoftCXXABI.cpp
+++ clang/lib/CodeGen/MicrosoftCXXABI.cpp
@@ -4348,6 +4348,7 @@
 
 void MicrosoftCXXABI::emitThrow(CodeGenFunction &CGF, const CXXThrowExpr *E) {
   const Expr *SubExpr = E->getSubExpr();
+  assert(SubExpr && "SubExpr cannot be null");
   QualType ThrowType = SubExpr->getType();
   // The exception object lives on the stack and it's address is passed to the
   // runtime function.


Index: clang/lib/CodeGen/MicrosoftCXXABI.cpp
===
--- clang/lib/CodeGen/MicrosoftCXXABI.cpp
+++ clang/lib/CodeGen/MicrosoftCXXABI.cpp
@@ -4348,6 +4348,7 @@
 
 void MicrosoftCXXABI::emitThrow(CodeGenFunction &CGF, const CXXThrowExpr *E) {
   const Expr *SubExpr = E->getSubExpr();
+  assert(SubExpr && "SubExpr cannot be null");
   QualType ThrowType = SubExpr->getType();
   // The exception object lives on the stack and it's address is passed to the
   // runtime function.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 846e562 - [Clang] add support for error+warning fn attrs

2021-08-25 Thread Nick Desaulniers via cfe-commits

Author: Nick Desaulniers
Date: 2021-08-25T10:34:18-07:00
New Revision: 846e562dcc6a9a611d844dc0d123da95629a0567

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

LOG: [Clang] add support for error+warning fn attrs

Add support for the GNU C style __attribute__((error(""))) and
__attribute__((warning(""))). These attributes are meant to be put on
declarations of functions whom should not be called.

They are frequently used to provide compile time diagnostics similar to
_Static_assert, but which may rely on non-ICE conditions (ie. relying on
compiler optimizations). This is also similar to diagnose_if function
attribute, but can diagnose after optimizations have been run.

While users may instead simply call undefined functions in such cases to
get a linkage failure from the linker, these provide a much more
ergonomic and actionable diagnostic to users and do so at compile time
rather than at link time. Users instead may be able use inline asm .err
directives.

These are used throughout the Linux kernel in its implementation of
BUILD_BUG and BUILD_BUG_ON macros. These macros generally cannot be
converted to use _Static_assert because many of the parameters are not
ICEs. The Linux kernel still needs to be modified to make use of these
when building with Clang; I have a patch that does so I will send once
this feature is landed.

To do so, we create a new IR level Function attribute, "dontcall" (both
error and warning boil down to one IR Fn Attr).  Then, similar to calls
to inline asm, we attach a !srcloc Metadata node to call sites of such
attributed callees.

The backend diagnoses these during instruction selection, while we still
know that a call is a call (vs say a JMP that's a tail call) in an arch
agnostic manner.

The frontend then reconstructs the SourceLocation from that Metadata,
and determines whether to emit an error or warning based on the callee's
attribute.

Link: https://bugs.llvm.org/show_bug.cgi?id=16428
Link: https://github.com/ClangBuiltLinux/linux/issues/1173

Reviewed By: aaron.ballman

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

Added: 
clang/test/CodeGen/attr-error.c
clang/test/CodeGen/attr-warning.c
clang/test/Frontend/backend-attribute-error-warning-optimize.c
clang/test/Frontend/backend-attribute-error-warning.c
clang/test/Sema/attr-error.c
clang/test/Sema/attr-warning.c
llvm/test/CodeGen/X86/attr-dontcall.ll
llvm/test/ThinLTO/X86/dontcall.ll

Modified: 
clang/docs/ReleaseNotes.rst
clang/include/clang/Basic/Attr.td
clang/include/clang/Basic/AttrDocs.td
clang/include/clang/Basic/DiagnosticFrontendKinds.td
clang/include/clang/Basic/DiagnosticGroups.td
clang/include/clang/Sema/Sema.h
clang/lib/CodeGen/CGCall.cpp
clang/lib/CodeGen/CodeGenAction.cpp
clang/lib/CodeGen/CodeGenModule.cpp
clang/lib/Sema/SemaDecl.cpp
clang/lib/Sema/SemaDeclAttr.cpp
clang/test/Misc/pragma-attribute-supported-attributes-list.test
llvm/docs/LangRef.rst
llvm/include/llvm/IR/DiagnosticInfo.h
llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
llvm/lib/CodeGen/SelectionDAG/FastISel.cpp
llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
llvm/lib/IR/DiagnosticInfo.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 8b62f026765e3..4ed7543a2b865 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -103,6 +103,8 @@ C Language Changes in Clang
 - Wide multi-characters literals such as ``L'ab'`` that would previously be 
interpreted as ``L'b'``
   are now ill-formed in all language modes. The motivation for this change is 
outlined in
   `P2362 `_.
+- Support for ``__attribute__((error("")))`` and
+  ``__attribute__((warning("")))`` function attributes have been added.
 
 C++ Language Changes in Clang
 -

diff  --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index f9ae1b8d86281..a54039501a7f7 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -3838,3 +3838,12 @@ def EnforceTCBLeaf : InheritableAttr {
   let Documentation = [EnforceTCBLeafDocs];
   bit InheritEvenIfAlreadyPresent = 1;
 }
+
+def Error : InheritableAttr {
+  let Spellings = [GCC<"error">, GCC<"warning">];
+  let Accessors = [Accessor<"isError", [GCC<"error">]>,
+   Accessor<"isWarning", [GCC<"warning">]>];
+  let Args = [StringArgument<"UserDiagnostic">];
+  let Subjects = SubjectList<[Function], ErrorDiag>;
+  let Documentation = [ErrorAttrDocs];
+}

diff  --git a/clang/include/clang/Basic/AttrDocs.td 
b/clang/include/clang/Basic/AttrDocs.td
index 3e25041ba5510..b2b41c3bb4197 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include

[PATCH] D106030: [Clang] add support for error+warning fn attrs

2021-08-25 Thread Nick Desaulniers via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG846e562dcc6a: [Clang] add support for error+warning fn attrs 
(authored by nickdesaulniers).

Changed prior to commit:
  https://reviews.llvm.org/D106030?vs=366717&id=368678#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106030

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/DiagnosticFrontendKinds.td
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Sema/Sema.h
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CodeGenAction.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/CodeGen/attr-error.c
  clang/test/CodeGen/attr-warning.c
  clang/test/Frontend/backend-attribute-error-warning-optimize.c
  clang/test/Frontend/backend-attribute-error-warning.c
  clang/test/Misc/pragma-attribute-supported-attributes-list.test
  clang/test/Sema/attr-error.c
  clang/test/Sema/attr-warning.c
  llvm/docs/LangRef.rst
  llvm/include/llvm/IR/DiagnosticInfo.h
  llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
  llvm/lib/CodeGen/SelectionDAG/FastISel.cpp
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
  llvm/lib/IR/DiagnosticInfo.cpp
  llvm/test/CodeGen/X86/attr-dontcall.ll
  llvm/test/ThinLTO/X86/dontcall.ll

Index: llvm/test/ThinLTO/X86/dontcall.ll
===
--- /dev/null
+++ llvm/test/ThinLTO/X86/dontcall.ll
@@ -0,0 +1,33 @@
+; RUN: split-file %s %t
+; RUN: opt -module-summary %t/a.s -o %t/a.bc
+; RUN: opt -module-summary %t/b.s -o %t/b.bc
+; RUN: not llvm-lto2 run %t/a.bc %t/b.bc -o %t/out -save-temps 2>&1 \
+; RUN:   -r=%t/a.bc,callee,px \
+; RUN:   -r=%t/b.bc,callee,x  \
+; RUN:   -r=%t/b.bc,caller,px
+
+; TODO: As part of LTO, we check that types match, but *we don't yet check that
+; attributes match!!! What should happen if we remove "dontcall" from the
+; definition or declaration of @callee?
+
+; CHECK: call to callee marked "dontcall"
+
+;--- a.s
+target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+define i32 @callee() "dontcall" noinline {
+  ret i32 42
+}
+
+;--- b.s
+target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+declare i32 @callee() "dontcall"
+
+define i32 @caller() {
+entry:
+  %0 = call i32 @callee()
+  ret i32 %0
+}
Index: llvm/test/CodeGen/X86/attr-dontcall.ll
===
--- /dev/null
+++ llvm/test/CodeGen/X86/attr-dontcall.ll
@@ -0,0 +1,11 @@
+; RUN: not llc -global-isel=0 -fast-isel=0 -stop-after=finalize-isel %s 2>&1 | FileCheck %s
+; RUN: not llc -global-isel=0 -fast-isel=1 -stop-after=finalize-isel %s 2>&1 | FileCheck %s
+; RUN: not llc -global-isel=1 -fast-isel=0 -stop-after=irtranslator %s 2>&1 | FileCheck %s
+
+declare void @foo() "dontcall"
+define void @bar() {
+  call void @foo()
+  ret void
+}
+
+; CHECK: error: call to foo marked "dontcall"
Index: llvm/lib/IR/DiagnosticInfo.cpp
===
--- llvm/lib/IR/DiagnosticInfo.cpp
+++ llvm/lib/IR/DiagnosticInfo.cpp
@@ -401,3 +401,7 @@
 
 void OptimizationRemarkAnalysisFPCommute::anchor() {}
 void OptimizationRemarkAnalysisAliasing::anchor() {}
+
+void DiagnosticInfoDontCall::print(DiagnosticPrinter &DP) const {
+  DP << "call to " << getFunctionName() << " marked \"dontcall\"";
+}
Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
===
--- llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
+++ llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
@@ -69,6 +69,7 @@
 #include "llvm/IR/DataLayout.h"
 #include "llvm/IR/DebugInfoMetadata.h"
 #include "llvm/IR/DerivedTypes.h"
+#include "llvm/IR/DiagnosticInfo.h"
 #include "llvm/IR/Function.h"
 #include "llvm/IR/GetElementPtrTypeIterator.h"
 #include "llvm/IR/InlineAsm.h"
@@ -7952,6 +7953,15 @@
   }
 
   if (Function *F = I.getCalledFunction()) {
+if (F->hasFnAttribute("dontcall")) {
+  unsigned LocCookie = 0;
+  if (MDNode *MD = I.getMetadata("srcloc"))
+LocCookie =
+mdconst::extract(MD->getOperand(0))->getZExtValue();
+  DiagnosticInfoDontCall D(F->getName(), LocCookie);
+  DAG.getContext()->diagnose(D);
+}
+
 if (F->isDeclaration()) {
   // Is this an LLVM intrinsic or a target-specific intrinsic?
   unsigned IID = F->getIntrinsicID();
Index: llvm/lib/CodeGen/SelectionDAG/FastISel.cpp
===
--- llvm/lib/CodeGen/SelectionDAG/FastISel.cpp
+++ llvm/lib/CodeGen/SelectionDAG/FastISel.cpp
@@ -75,6 +75,7 @@
 #in

[PATCH] D108712: Avoid nullptr dereferencing of 'SubExpr'; NFC

2021-08-25 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! There is no way for this to be null because `emitRethrow()` is what 
should be called in that case.

I'll land this on your behalf sometime shortly (perhaps as late as tomorrow).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108712

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


[clang] 66e37c9 - [Preprocessor] Elide empty line(s) at start of file.

2021-08-25 Thread Michael Kruse via cfe-commits

Author: Michael Kruse
Date: 2021-08-25T12:48:59-05:00
New Revision: 66e37c99ef5d7da1b17b3bbaa4ef05b633a473f7

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

LOG: [Preprocessor] Elide empty line(s) at start of file.

In -P mode, PrintPPOutputPPCallbacks::MoveToLine started at least one
newline if current and target line number mismatched. The method is also
called when entering a new file, be it the main file or an include file.
In this situation line numbers always almost mismatch, resulting in a
newline for each occurance even if no tokens have been printed
in-between.

Empty lines at the beginning of the output must be trimmed because it
may be parsed by scripts expecting the result to appear on the first
output line, as done by LibreOffice's configure script.

Fix by only emitting a newline if tokens have been printed so far using
the EmittedTokensOnThisLine flag. Also adding a test case of FileChanged
callbacks occuring with empty include files.

This fixes llvm.org/PR51616

Added: 
clang/test/Preprocessor/print_empty_include.c
clang/test/Preprocessor/print_empty_include.h

Modified: 
clang/lib/Frontend/PrintPreprocessedOutput.cpp
clang/test/Preprocessor/print_line_track.c

Removed: 




diff  --git a/clang/lib/Frontend/PrintPreprocessedOutput.cpp 
b/clang/lib/Frontend/PrintPreprocessedOutput.cpp
index 5c5fc751179d1..3a3b158aafdb7 100644
--- a/clang/lib/Frontend/PrintPreprocessedOutput.cpp
+++ b/clang/lib/Frontend/PrintPreprocessedOutput.cpp
@@ -293,7 +293,7 @@ bool PrintPPOutputPPCallbacks::MoveToLine(unsigned LineNo,
   WriteLineInfo(LineNo, nullptr, 0);
 }
 StartedNewLine = true;
-  } else if (!StartedNewLine) {
+  } else if (EmittedTokensOnThisLine) {
 // If we are not on the correct line and don't need to be line-correct,
 // at least ensure we start on a new line.
 OS << '\n';

diff  --git a/clang/test/Preprocessor/print_empty_include.c 
b/clang/test/Preprocessor/print_empty_include.c
new file mode 100644
index 0..04cda99223fed
--- /dev/null
+++ b/clang/test/Preprocessor/print_empty_include.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -E -P %s | count 1
+// Ensure no superfluous newlines are printed
+// llvm.org/PR51616
+
+#include "print_empty_include.h"
+#include "print_empty_include.h"
+
+#define EXPANDED_TO_NOTHING
+EXPANDED_TO_NOTHING
+

diff  --git a/clang/test/Preprocessor/print_empty_include.h 
b/clang/test/Preprocessor/print_empty_include.h
new file mode 100644
index 0..34b07013ed6d2
--- /dev/null
+++ b/clang/test/Preprocessor/print_empty_include.h
@@ -0,0 +1,4 @@
+#if 0
+intentionally empty
+#endif
+

diff  --git a/clang/test/Preprocessor/print_line_track.c 
b/clang/test/Preprocessor/print_line_track.c
index fb2ccf270e242..156ae22693b85 100644
--- a/clang/test/Preprocessor/print_line_track.c
+++ b/clang/test/Preprocessor/print_line_track.c
@@ -3,7 +3,7 @@
  * RUN: %clang_cc1 -E -P %s | grep 'a 3'
  * RUN: %clang_cc1 -E -P %s | grep 'b 16'
  * RUN: %clang_cc1 -E %s | not grep '# 0 '
- * RUN: %clang_cc1 -E -P %s | count 4
+ * RUN: %clang_cc1 -E -P %s | count 2
  * PR1848 PR3437 PR7360
 */
 



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


[clang] 666906a - [test] Fix indention. NFC.

2021-08-25 Thread Michael Kruse via cfe-commits

Author: Michael Kruse
Date: 2021-08-25T12:48:59-05:00
New Revision: 666906a8032709e59ca6c9fb7b7a5e05cafbd3bf

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

LOG: [test] Fix indention. NFC.

Added: 


Modified: 
clang/test/Preprocessor/skip-empty-lines.c

Removed: 




diff  --git a/clang/test/Preprocessor/skip-empty-lines.c 
b/clang/test/Preprocessor/skip-empty-lines.c
index 6d248d748e29..3f3915ec927b 100644
--- a/clang/test/Preprocessor/skip-empty-lines.c
+++ b/clang/test/Preprocessor/skip-empty-lines.c
@@ -20,7 +20,7 @@ more than 8 empty lines
 
 // Check behavior after varying number of lines without emitted tokens.
 
-// LINEMARKERS:   {{^}}# 1 "{{.*}}skip-empty-lines.c" 2
+// LINEMARKERS:  {{^}}# 1 "{{.*}}skip-empty-lines.c" 2
 // LINEMARKERS-NEXT: {{^}}  int a ;
 // LINEMARKERS-NEXT: {{^}}  int b ;
 // LINEMARKERS-EMPTY:



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


[PATCH] D108710: [clang][deps] Reset non-modular language and preprocessor options

2021-08-25 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith requested changes to this revision.
dexonsmith added inline comments.
This revision now requires changes to proceed.



Comment at: clang/test/ClangScanDeps/Inputs/removed-args/cdb.json.template:4
+"directory": "DIR",
+"command": "clang -fsyntax-only DIR/tu.c -fmodules -fimplicit-module-maps 
-fmodules-cache-path=DIR/cache -include DIR/header.h -o DIR/tu.o",
+"file": "DIR/tu.c"

It looks to me like that this test would have passed before the code change, 
since there was already logic for dropping `-include`. Can you also add some 
other argument(s) that wouldn't have been dropped before, but will be now?



Comment at: clang/test/ClangScanDeps/removed-args.c:3
+// RUN: cp %S/Inputs/removed-args/* %t
+
+// RUN: sed "s|DIR|%/t|g" %S/Inputs/removed-args/cdb.json.template > 
%t/cdb.json

Please add a comment here explaining what args are expected to be dropped and 
why, to help future readers to understand the testcase.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108710

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


[PATCH] D106030: [Clang] add support for error+warning fn attrs

2021-08-25 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added a comment.

I'm getting test failures for the newly added 
llvm/test/CodeGen/X86/attr-dontcall.ll, thought there's not much info other than

> Exit Code: 1


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106030

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


[PATCH] D106804: [test-suite] Add tests for FP classification intrinsics

2021-08-25 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff updated this revision to Diff 368687.
sepavloff added a comment.

Updated patch

- Moved tests into header files. It should facilitate writing tests for various 
modes (strict exceptions, fast math etc),
- Added Makefile,
- Enhanced diagnostics if test fails,
- Avoid C++, it makes easier to run test on simulator if there are fewer 
dependencies.


Repository:
  rT test-suite

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

https://reviews.llvm.org/D106804

Files:
  SingleSource/UnitTests/CMakeLists.txt
  SingleSource/UnitTests/Float/CMakeLists.txt
  SingleSource/UnitTests/Float/Makefile
  SingleSource/UnitTests/Float/check-helper.h
  SingleSource/UnitTests/Float/classify-f32.h
  SingleSource/UnitTests/Float/classify-f64.h
  SingleSource/UnitTests/Float/classify-ldouble.h
  SingleSource/UnitTests/Float/classify.c
  SingleSource/UnitTests/Float/classify.reference_output
  SingleSource/UnitTests/Float/fformat.h

Index: SingleSource/UnitTests/Float/fformat.h
===
--- /dev/null
+++ SingleSource/UnitTests/Float/fformat.h
@@ -0,0 +1,65 @@
+//===--- fformat.h - Descriptions of floating point formats ---*- C -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This header file contains some macro definitions useful for working with bit
+// accurate floating point representations.
+//
+//===--===//
+#ifndef _FFORMAT_H_
+#define _FFORMAT_H_
+
+#define F32_SIGN_BIT0x8000U
+#define F32_EXP_MASK0x7F80U
+#define F32_MANTISSA_MASK   0x007FU
+#define F32_MANTISSA_MSB0x0040U
+#define F32_QNAN_BITF32_MANTISSA_MSB
+#define F32_PAYLOAD_MASK(F32_MANTISSA_MASK & ~F32_QNAN_BIT)
+#define F32_SIGN_SHIFT  31
+#define F32_EXP_SHIFT   23
+#define F32_EXP_SIZE(F32_SIGN_SHIFT - F32_EXP_SHIFT)
+#define F32_MANTISSA_SIZE   F32_EXP_SHIFT
+#define F32_EXP_BIAS127
+#define F32_EXP_MIN (-126)
+#define F32_EXP_MAX 127
+#define F32_EXP(e)  (((e) + F32_EXP_BIAS) << F32_EXP_SHIFT)
+#define F32_MANTISSA(b1, b2, b3)   \
+(((b1) ? F32_MANTISSA_MSB : 0) |   \
+ ((b2) ? (F32_MANTISSA_MSB >> 1) : 0) |\
+ ((b3) ? (F32_MANTISSA_MSB >> 2) : 0))
+#define F32_MAKE(s, e, m)  \
+(((s) ? F32_SIGN_BIT : 0) |\
+ ((e) & F32_EXP_MASK) |\
+ ((m) & F32_MANTISSA_MASK))
+#define F32_NORMAL(s, e, m) F32_MAKE((s), F32_EXP(e), (m))
+
+
+#define F64_SIGN_BIT0x8000ULL
+#define F64_EXP_MASK0x7FF0ULL
+#define F64_MANTISSA_MASK   0x000FULL
+#define F64_MANTISSA_MSB0x0008ULL
+#define F64_QNAN_BITF64_MANTISSA_MSB
+#define F64_PAYLOAD_MASK(F64_MANTISSA_MASK & ~F64_QNAN_BIT)
+#define F64_SIGN_SHIFT  63
+#define F64_EXP_SHIFT   52
+#define F64_EXP_SIZE(F64_SIGN_SHIFT - F64_EXP_SHIFT)
+#define F64_MANTISSA_SIZE   F64_EXP_SHIFT
+#define F64_EXP_BIAS1023
+#define F64_EXP_MIN (-1022)
+#define F64_EXP_MAX 1023
+#define F64_EXP(e)  (((uint64_t)(e) + F64_EXP_BIAS) << F64_EXP_SHIFT)
+#define F64_MANTISSA(b1, b2, b3)   \
+(((b1) ? F64_MANTISSA_MSB : 0) |   \
+ ((b2) ? (F64_MANTISSA_MSB >> 1) : 0) |\
+ ((b3) ? (F64_MANTISSA_MSB >> 2) : 0))
+#define F64_MAKE(s, e, m)  \
+(((s) ? F64_SIGN_BIT : 0) |\
+ ((e) & F64_EXP_MASK) |\
+ ((m) & F64_MANTISSA_MASK))
+#define F64_NORMAL(s, e, m) F64_MAKE((s), F64_EXP(e), (m))
+
+#endif
Index: SingleSource/UnitTests/Float/classify.reference_output
===
--- /dev/null
+++ SingleSource/UnitTests/Float/classify.reference_output
@@ -0,0 +1 @@
+exit 0
Index: SingleSource/UnitTests/Float/classify.c
===
--- /dev/null
+++ SingleSource/UnitTests/Float/classify.c
@@ -0,0 +1,26 @@
+//===--- classify.cpp - Tess for FP classification intrinsics ---*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identi

[PATCH] D106618: [Clang][LLVM] generate btf_tag annotations for DISubprogram types

2021-08-25 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

The clang side might benefit from a test with a function declaration, a call to 
that function, but no definition of it - with optimizations enabled, clang 
should emit the DISubprogram for that function for the purpose of call site 
DWARF, I think? (or maybe that behavior got rolled back for now? In which case 
the nearest thing I can think of/the only other place where we produce DWARF 
for a declaration would be for a member function declaration in a type DIE - 
are btf attributes supported there (or are they only supported in C, in which 
case there's no such thing as a member function)?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106618

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


[PATCH] D108712: Avoid nullptr dereferencing of 'SubExpr'; NFC

2021-08-25 Thread Sindhu Chittireddy via Phabricator via cfe-commits
schittir added a comment.

In D108712#2965433 , @aaron.ballman 
wrote:

> LGTM! There is no way for this to be null because `emitRethrow()` is what 
> should be called in that case.
>
> I'll land this on your behalf sometime shortly (perhaps as late as tomorrow).

Thank you, Aaron!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108712

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


[clang] ea1c01d - PR51105: look through ConstantExpr when looking for a braced string literal initialization.

2021-08-25 Thread Richard Smith via cfe-commits

Author: Richard Smith
Date: 2021-08-25T11:36:11-07:00
New Revision: ea1c01dde03b45e0b33d3883147d3b4fb489978c

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

LOG: PR51105: look through ConstantExpr when looking for a braced string 
literal initialization.

Added: 


Modified: 
clang/lib/AST/Expr.cpp
clang/lib/AST/ExprConstant.cpp
clang/lib/Sema/SemaInit.cpp
clang/test/CodeGenCXX/const-init.cpp

Removed: 




diff  --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp
index 11f10d4695fcd..31733932361f3 100644
--- a/clang/lib/AST/Expr.cpp
+++ b/clang/lib/AST/Expr.cpp
@@ -2308,7 +2308,7 @@ bool InitListExpr::isStringLiteralInit() const {
   const Expr *Init = getInit(0);
   if (!Init)
 return false;
-  Init = Init->IgnoreParens();
+  Init = Init->IgnoreParenImpCasts();
   return isa(Init) || isa(Init);
 }
 

diff  --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index f49a144879b3e..a3879db27bd70 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -10473,13 +10473,17 @@ bool ArrayExprEvaluator::VisitInitListExpr(const 
InitListExpr *E,
   // C++11 [dcl.init.string]p1: A char array [...] can be initialized by [...]
   // an appropriately-typed string literal enclosed in braces.
   if (E->isStringLiteralInit()) {
-auto *SL = dyn_cast(E->getInit(0)->IgnoreParens());
+auto *SL = dyn_cast(E->getInit(0)->IgnoreParenImpCasts());
 // FIXME: Support ObjCEncodeExpr here once we support it in
 // ArrayExprEvaluator generally.
 if (!SL)
   return Error(E);
 return VisitStringLiteral(SL, AllocType);
   }
+  // Any other transparent list init will need proper handling of the
+  // AllocType; we can't just recurse to the inner initializer.
+  assert(!E->isTransparent() &&
+ "transparent array list initialization is not string literal init?");
 
   bool Success = true;
 

diff  --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp
index 78574e34d9068..111d93b1e7a4d 100644
--- a/clang/lib/Sema/SemaInit.cpp
+++ b/clang/lib/Sema/SemaInit.cpp
@@ -2899,7 +2899,7 @@ InitListChecker::CheckDesignatedInitializer(const 
InitializedEntity &Entity,
 // We're modifying a string literal init; we have to decompose the string
 // so we can modify the individual characters.
 ASTContext &Context = SemaRef.Context;
-Expr *SubExpr = StructuredList->getInit(0)->IgnoreParens();
+Expr *SubExpr = StructuredList->getInit(0)->IgnoreParenImpCasts();
 
 // Compute the character type
 QualType CharTy = AT->getElementType();

diff  --git a/clang/test/CodeGenCXX/const-init.cpp 
b/clang/test/CodeGenCXX/const-init.cpp
index f5c9dae7ba4b6..ca53db02f10a9 100644
--- a/clang/test/CodeGenCXX/const-init.cpp
+++ b/clang/test/CodeGenCXX/const-init.cpp
@@ -84,6 +84,13 @@ int arr[2];
 // CHECK: @pastEnd = constant i32* bitcast (i8* getelementptr (i8, i8* bitcast 
([2 x i32]* @arr to i8*), i64 8) to i32*)
 int &pastEnd = arr[2];
 
+// CHECK: @[[WCHAR_STR:.*]] = internal global [2 x i32] [i32 112, i32 0],
+// CHECK: @PR51105_a = global i32* {{.*}} @[[WCHAR_STR]],
+wchar_t *PR51105_a = (wchar_t[2]){ (L"p") };
+// CHECK: @[[CHAR_STR:.*]] = internal global [5 x i8] c"p\00\00\00\00",
+// CHECK: @PR51105_b = global i8* {{.*}} @[[CHAR_STR]],
+char *PR51105_b = (char [5]){ ("p") };
+
 struct X {
   long n : 8;
 };



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


[PATCH] D106030: [Clang] add support for error+warning fn attrs

2021-08-25 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added a comment.

Fixup: https://reviews.llvm.org/D108718


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106030

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


[PATCH] D108720: Effectively revert 33c3d8a916c / D33782

2021-08-25 Thread Reid Kleckner via Phabricator via cfe-commits
rnk created this revision.
rnk added reviewers: zero9178, mibintc, erichkeane.
rnk requested review of this revision.
Herald added a project: clang.

This change would treat the token `or` in system headers as an
identifier, and elsewhere as an operator. As reported in
llvm.org/pr42427, many users classify their third party library headers
as "system" headers to suppress warnings. There's no clean way to
separate Windows SDK headers from user headers.

Since D103773 , clang-cl's default mode 
completely disables C++ operator
names. That means that query.h compiles out of the box without this hack
in the pre-processor. For users who are using /permissive-, they must
set the QUERY_H_RESTRICTION_PERMISSIVE macro to rename this problematic
`or` field.

By reverting this change, we get to a consistent state: C++ operator
names are either enabled or disabled globally. If that breaks
compilation because legacy code is using `or` as an identifier, the user
has flags to work around the problem (`/permissive` or
`/clang:-fno-operator-names`).

Fixes PR42427


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D108720

Files:
  clang/lib/Lex/Preprocessor.cpp
  clang/test/Headers/ms-cppoperkey.cpp
  clang/test/Headers/ms-cppoperkey1.cpp
  clang/test/Headers/ms-cppoperkey2.cpp


Index: clang/test/Headers/ms-cppoperkey2.cpp
===
--- clang/test/Headers/ms-cppoperkey2.cpp
+++ /dev/null
@@ -1,11 +0,0 @@
-// RUN: %clang_cc1  -triple x86_64-pc-win32 -fms-compatibility \
-// RUN: -ffreestanding -fsyntax-only -Werror  %s -verify
-// RUN: %clang_cc1 \
-// RUN: -ffreestanding -fsyntax-only -Werror  %s -verify
-// expected-no-diagnostics
-int bb ( int x)
-{
-  // In user code, treat operator keyword as operator keyword.
-  if ( x>1 or x<0) return 1;
-  else return 0;  
-}
Index: clang/test/Headers/ms-cppoperkey1.cpp
===
--- clang/test/Headers/ms-cppoperkey1.cpp
+++ /dev/null
@@ -1,27 +0,0 @@
-// RUN: %clang_cc1 \
-// RUN: -fms-compatibility -x c++-cpp-output \
-// RUN: -ffreestanding -fsyntax-only -Werror \
-// RUN: %s -verify
-
-
-# 1 "t.cpp"
-# 1 "query.h" 1 3 4
-// MS header  uses operator keyword as field name.  
-// Compile without syntax errors.
-struct tagRESTRICTION
-  {
-   union _URes 
- {
-   int or; // Note use of cpp operator token
- } res;
-  };
-   ;
-
-int aa ( int x)
-{
-  // In system header code, treat operator keyword as identifier.
-  if ( // expected-note{{to match this '('}}
-x>1 or x<0) return 1; // expected-error{{expected ')'}}
-  else return 0;  
-}
-
Index: clang/test/Headers/ms-cppoperkey.cpp
===
--- clang/test/Headers/ms-cppoperkey.cpp
+++ /dev/null
@@ -1,16 +0,0 @@
-// RUN: %clang_cc1 \
-// RUN: -fms-compatibility -x c++-cpp-output \
-// RUN: -ffreestanding -fsyntax-only -Werror \
-// RUN: %s -verify
-// expected-no-diagnostics
-# 1 "t.cpp"
-# 1 "query.h" 1 3
-// MS header  uses operator keyword as field name.  
-// Compile without syntax errors.
-struct tagRESTRICTION
-  {
-   union _URes 
- {
-   int or; // Note use of cpp operator token
- } res;
-  };
Index: clang/lib/Lex/Preprocessor.cpp
===
--- clang/lib/Lex/Preprocessor.cpp
+++ clang/lib/Lex/Preprocessor.cpp
@@ -723,11 +723,7 @@
   // is cleaned to tok::identifier "B". After cleaning the token's length is
   // still 3 and the SourceLocation refers to the location of the backslash.
   Identifier.setIdentifierInfo(II);
-  if (getLangOpts().MSVCCompat && II->isCPlusPlusOperatorKeyword() &&
-  getSourceManager().isInSystemHeader(Identifier.getLocation()))
-Identifier.setKind(tok::identifier);
-  else
-Identifier.setKind(II->getTokenID());
+  Identifier.setKind(II->getTokenID());
 
   return II;
 }


Index: clang/test/Headers/ms-cppoperkey2.cpp
===
--- clang/test/Headers/ms-cppoperkey2.cpp
+++ /dev/null
@@ -1,11 +0,0 @@
-// RUN: %clang_cc1  -triple x86_64-pc-win32 -fms-compatibility \
-// RUN: -ffreestanding -fsyntax-only -Werror  %s -verify
-// RUN: %clang_cc1 \
-// RUN: -ffreestanding -fsyntax-only -Werror  %s -verify
-// expected-no-diagnostics
-int bb ( int x)
-{
-  // In user code, treat operator keyword as operator keyword.
-  if ( x>1 or x<0) return 1;
-  else return 0;  
-}
Index: clang/test/Headers/ms-cppoperkey1.cpp
===
--- clang/test/Headers/ms-cppoperkey1.cpp
+++ /dev/null
@@ -1,27 +0,0 @@
-// RUN: %clang_cc1 \
-// RUN: -fms-compatibility -x c++-cpp-output \
-// RUN: -ffreestanding -fsyntax-only -Werror \
-// RUN: %s -verify
-
-
-# 1 "t.cpp"
-# 1 "query.h" 1 3 4
-// MS header  uses operator keyword as field name.  
-// Comp

[PATCH] D107764: [OpenMP][OpenMPIRBuilder] Implement loop unrolling.

2021-08-25 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert accepted this revision.
jdoerfert added a comment.
This revision is now accepted and ready to land.

LG, minor comments below.




Comment at: clang/lib/CodeGen/CGStmtOpenMP.cpp:2639-2643
+if (UnrolledCLI) {
+  OMPLoopNestStack.push_back(UnrolledCLI);
+} else {
+  assert(!NeedsUnrolledCLI);
+}

make it an unreachable or sink the assert and combine the conditions. Later 
allows to remove all braces.



Comment at: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp:2077
+  Latch->getTerminator()->setMetadata(LLVMContext::MD_loop, LoopID);
+}
+

Nit: Add an assert for latch to exist. Just for my sanity ;)



Comment at: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp:2119
+  OptLevel));
+}
+

Should we cache it in the OpenMPIRBuilder?



Comment at: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp:2241
+  unsigned Factor = UP.Count;
+  LLVM_DEBUG(dbgs() << "Suggesting unroll factor of " << LoopSize << "\n");
+





Comment at: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp:2275
+return nullptr;
+  }
+

This code matches the pattern we have in the 2 members above. Can we make it a 
member as well and make it clear in the name of all 3 that we use metadata and 
the unroller pass? No strong feelings, more of an idea.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107764

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


[PATCH] D108720: Effectively revert 33c3d8a916c / D33782

2021-08-25 Thread Erich Keane via Phabricator via cfe-commits
erichkeane accepted this revision.
erichkeane added a comment.
This revision is now accepted and ready to land.

This seems reasonable to me.  The changes for `/permissive` and `/permissive-` 
I think are a better way about this, and now that there is a trivial workaround 
(`QUERY_H_RESTRICTION_PERMISSIVE`) I don't really see value in the original 
patch anymore.

Side note: @mibintc is now retired, so you won't see a response from her.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108720

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


[PATCH] D108720: Effectively revert 33c3d8a916c / D33782

2021-08-25 Thread Markus Böck via Phabricator via cfe-commits
zero9178 accepted this revision.
zero9178 added a comment.

Thanks a lot for the patch :) Wanted this bit of code to be removed for quite 
some time.

> Since D103773 , clang-cl's default mode 
> completely disables C++ operator
> names. That means that query.h compiles out of the box without this hack
> in the pre-processor. For users who are using /permissive-, they must
> set the QUERY_H_RESTRICTION_PERMISSIVE macro to rename this problematic
> or field.

Just a heads up, the patch added `/permissive` and `/permissive-`, but made 
neither the default as to not be a breaking change. That means that clang-cl 
still parses operator keywords and also does delayed template parsing, as it 
did before the patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108720

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


[PATCH] D107394: [AIX] "aligned" attribute does not decrease alignment

2021-08-25 Thread Steven Wan via Phabricator via cfe-commits
stevewan updated this revision to Diff 368702.
stevewan added a comment.
Herald added a subscriber: jfb.

Add recursive check for typedef


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107394

Files:
  clang/lib/AST/RecordLayoutBuilder.cpp
  clang/test/Layout/aix-alignof-align-and-pack-attr.cpp
  clang/test/Layout/aix-power-alignment-typedef.cpp
  clang/test/Layout/aix-type-align-and-pack-attr.cpp

Index: clang/test/Layout/aix-type-align-and-pack-attr.cpp
===
--- /dev/null
+++ clang/test/Layout/aix-type-align-and-pack-attr.cpp
@@ -0,0 +1,59 @@
+// RUN: %clang_cc1 -triple powerpc-ibm-aix-xcoff -S -emit-llvm -x c++ < %s | \
+// RUN:   FileCheck %s
+
+// RUN: %clang_cc1 -triple powerpc64-ibm-aix-xcoff -S -emit-llvm -x c++ < %s | \
+// RUN:   FileCheck %s
+
+namespace test1 {
+struct __attribute__((__aligned__(2))) S {
+  double d;
+};
+
+S s;
+
+// CHECK: @{{.*}}test1{{.*}}s{{.*}} = global %"struct.test1::S" zeroinitializer, align 8
+} // namespace test1
+
+namespace test2 {
+struct __attribute__((__aligned__(2), packed)) S {
+  double d;
+};
+
+S s;
+
+// CHECK: @{{.*}}test2{{.*}}s{{.*}} = global %"struct.test2::S" zeroinitializer, align 2
+} // namespace test2
+
+namespace test3 {
+struct __attribute__((__aligned__(16))) S {
+  double d;
+};
+
+S s;
+
+// CHECK: @{{.*}}test3{{.*}}s{{.*}} = global %"struct.test3::S" zeroinitializer, align 16
+} // namespace test3
+
+namespace test4 {
+struct __attribute__((aligned(2))) SS {
+  double d;
+};
+
+struct S {
+  struct SS ss;
+} s;
+
+// CHECK: @{{.*}}test4{{.*}}s{{.*}} = global %"struct.test4::S" zeroinitializer, align 8
+} // namespace test4
+
+namespace test5 {
+struct __attribute__((aligned(2), packed)) SS {
+  double d;
+};
+
+struct S {
+  struct SS ss;
+} s;
+
+// CHECK: @{{.*}}test5{{.*}}s{{.*}} = global %"struct.test5::S" zeroinitializer, align 2
+} // namespace test5
Index: clang/test/Layout/aix-power-alignment-typedef.cpp
===
--- clang/test/Layout/aix-power-alignment-typedef.cpp
+++ clang/test/Layout/aix-power-alignment-typedef.cpp
@@ -37,3 +37,39 @@
 // CHECK-NEXT:   |  nvsize=2, nvalign=2, preferrednvalign=2]
 
 } // namespace test2
+
+namespace test3 {
+typedef double DblArr[] __attribute__((__aligned__(2)));
+
+union U {
+  DblArr da;
+  char x;
+};
+
+int x = sizeof(U);
+
+// CHECK:  0 | union test3::U
+// CHECK-NEXT: 0 |   test3::DblArr da
+// CHECK-NEXT: 0 |   char x
+// CHECK-NEXT:   | [sizeof=2, dsize=2, align=2, preferredalign=2,
+// CHECK-NEXT:   |  nvsize=2, nvalign=2, preferrednvalign=2]
+
+} // namespace test3
+
+namespace test4 {
+typedef double Dbl __attribute__((__aligned__(2)));
+
+union U {
+  Dbl DblArr[];
+  char x;
+};
+
+int x = sizeof(U);
+
+// CHECK:  0 | union test4::U
+// CHECK-NEXT: 0 |   test4::Dbl [] DblArr
+// CHECK-NEXT: 0 |   char x
+// CHECK-NEXT:   | [sizeof=2, dsize=2, align=2, preferredalign=2,
+// CHECK-NEXT:   |  nvsize=2, nvalign=2, preferrednvalign=2]
+
+} // namespace test4
Index: clang/test/Layout/aix-alignof-align-and-pack-attr.cpp
===
--- clang/test/Layout/aix-alignof-align-and-pack-attr.cpp
+++ /dev/null
@@ -1,29 +0,0 @@
-// RUN: %clang_cc1 -triple powerpc-ibm-aix-xcoff -S -emit-llvm -x c++ < %s | \
-// RUN:   FileCheck %s
-
-// RUN: %clang_cc1 -triple powerpc64-ibm-aix-xcoff -S -emit-llvm -x c++ < %s | \
-// RUN:   FileCheck %s
-
-namespace test1 {
-struct __attribute__((__aligned__(2))) C {
-  double x;
-} c;
-
-// CHECK: @{{.*}}test1{{.*}}c{{.*}} = global %"struct.test1::C" zeroinitializer, align 8
-} // namespace test1
-
-namespace test2 {
-struct __attribute__((__aligned__(2), packed)) C {
-  double x;
-} c;
-
-// CHECK: @{{.*}}test2{{.*}}c{{.*}} = global %"struct.test2::C" zeroinitializer, align 2
-} // namespace test2
-
-namespace test3 {
-struct __attribute__((__aligned__(16))) C {
-  double x;
-} c;
-
-// CHECK: @{{.*}}test3{{.*}}c{{.*}} = global %"struct.test3::C" zeroinitializer, align 16
-} // namespace test3
Index: clang/lib/AST/RecordLayoutBuilder.cpp
===
--- clang/lib/AST/RecordLayoutBuilder.cpp
+++ clang/lib/AST/RecordLayoutBuilder.cpp
@@ -1978,8 +1978,144 @@
   // and zero-width bit-fields count as prior members; members of empty class
   // types marked `no_unique_address` are not considered to be prior members.
   CharUnits PreferredAlign = FieldAlign;
-  if (DefaultsToAIXPowerAlignment && !AlignIsRequired &&
+  if (DefaultsToAIXPowerAlignment &&
   (FoundFirstNonOverlappingEmptyFieldForAIX || IsNaturalAlign)) {
+auto checkTypeIsTypedef = [](auto &&checkTypeIsTypedef,
+ const auto Ty) -> bool {
+  bool isTypedef = false;
+  switch (Ty->getTypeClass()) {

[PATCH] D108308: [WIP] Cleanup identifier parsing.

2021-08-25 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a reviewer: rsmith.
aaron.ballman added a subscriber: rsmith.
aaron.ballman added a comment.

In general, I'm in favor of these changes. They help identify (pun *totally* 
intended) where we're improperly expecting ASCII identifiers in places, which 
can hopefully be addressed in follow-up work. @rsmith, do you have any concerns 
with this direction?

Can you remove the [WIP] from the title so it's clear that this is no longer in 
progress? Also, I'd recommend slapping an NFC in the title somewhere to make it 
clear there's no functional changes intended.




Comment at: clang/include/clang/Lex/Lexer.h:702
   // Helper functions to lex the remainder of a token of the specific type.
-  bool LexIdentifier (Token &Result, const char *CurPtr);
+  bool LexIdentifierContinue(Token &Result, const char *CurPtr);
   bool LexNumericConstant(Token &Result, const char *CurPtr);

Should this be `LexUnicodeIdentifierContinue()`? If so, perhaps it can also be 
moved up to line 578 so it's near the "start" function?

Or does this function handle both Unicode and ASCII identifiers? If so, the 
comments could probably be updated.



Comment at: clang/lib/Lex/Lexer.cpp:1758
+bool Lexer::LexIdentifierContinue(Token &Result, const char *CurPtr) {
+  // Match [_A-Za-z0-9]*, we have already matched [_A-Za-z$]
+  unsigned Size;

Is the comment here still accurate? Might be worth rewriting in prose rather 
than regex?



Comment at: clang/lib/Lex/Lexer.cpp:1762
+unsigned char C = *CurPtr;
+// Fast path
+if (isAsciiIdentifierContinue(C)) {





Comment at: clang/lib/Lex/Lexer.cpp:1767
+}
+// Slow path: handle trigraph, unicode codepoints, UCNs
+C = getCharAndSize(CurPtr, Size);





Comment at: clang/lib/Lex/Lexer.cpp:1783-1788
+if (C == '\\' && tryConsumeIdentifierUCN(CurPtr, Size, Result)) {
   continue;
-} else if (!isASCII(C) && tryConsumeIdentifierUTF8Char(CurPtr)) {
-  C = getCharAndSize(CurPtr, Size);
+}
+if (!isASCII(C) && tryConsumeIdentifierUTF8Char(CurPtr)) {
   continue;
 }





Comment at: clang/lib/Lex/Lexer.cpp:1789
 }
+// Neither an expected unicode codepoint nor a UCN
+break;




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108308

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


[PATCH] D108308: [WIP] Cleanup identifier parsing.

2021-08-25 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added inline comments.



Comment at: clang/include/clang/Lex/Lexer.h:702
   // Helper functions to lex the remainder of a token of the specific type.
-  bool LexIdentifier (Token &Result, const char *CurPtr);
+  bool LexIdentifierContinue(Token &Result, const char *CurPtr);
   bool LexNumericConstant(Token &Result, const char *CurPtr);

aaron.ballman wrote:
> Should this be `LexUnicodeIdentifierContinue()`? If so, perhaps it can also 
> be moved up to line 578 so it's near the "start" function?
> 
> Or does this function handle both Unicode and ASCII identifiers? If so, the 
> comments could probably be updated.
This handles all identifiers - after the first codepoint has been parsed - 
Which comment are you referring to?



Comment at: clang/lib/Lex/Lexer.cpp:1758
+bool Lexer::LexIdentifierContinue(Token &Result, const char *CurPtr) {
+  // Match [_A-Za-z0-9]*, we have already matched [_A-Za-z$]
+  unsigned Size;

aaron.ballman wrote:
> Is the comment here still accurate? Might be worth rewriting in prose rather 
> than regex?
I don't think the comment was accurate before, I'll find somehing better!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108308

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


[PATCH] D108308: [WIP] Cleanup identifier parsing.

2021-08-25 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/include/clang/Lex/Lexer.h:701
 
   // Helper functions to lex the remainder of a token of the specific type.
+  bool LexIdentifierContinue(Token &Result, const char *CurPtr);

Something like this then?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108308

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


[PATCH] D108710: [clang][deps] Reset non-modular language and preprocessor options

2021-08-25 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 requested review of this revision.
jansvoboda11 added a comment.

Re-requesting review, since the test does cover the changes to 
`ModuleDepCollector.cpp`.




Comment at: clang/test/ClangScanDeps/Inputs/removed-args/cdb.json.template:4
+"directory": "DIR",
+"command": "clang -fsyntax-only DIR/tu.c -fmodules -fimplicit-module-maps 
-fmodules-cache-path=DIR/cache -include DIR/header.h -o DIR/tu.o",
+"file": "DIR/tu.c"

dexonsmith wrote:
> It looks to me like that this test would have passed before the code change, 
> since there was already logic for dropping `-include`. Can you also add some 
> other argument(s) that wouldn't have been dropped before, but will be now?
Only the `-include-pch` argument was being dropped 
(`PreprocessorOptions::ImplicitPCHInclude`). The `-include` arguments 
(`PreprocessorOptions::Includes`) were being preserved. This test would not 
pass without the changes to `ModuleDepCollector.cpp`.

I can add checks for other arguments that are being dropped now that weren't 
before, but assuming `resetNonModularOptions` are already being tested 
elsewhere, I don't think there's much value in that.



Comment at: clang/test/ClangScanDeps/removed-args.c:3
+// RUN: cp %S/Inputs/removed-args/* %t
+
+// RUN: sed "s|DIR|%/t|g" %S/Inputs/removed-args/cdb.json.template > 
%t/cdb.json

dexonsmith wrote:
> Please add a comment here explaining what args are expected to be dropped and 
> why, to help future readers to understand the testcase.
Will do.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108710

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


[PATCH] D107394: [AIX] "aligned" attribute does not decrease alignment

2021-08-25 Thread Steven Wan via Phabricator via cfe-commits
stevewan marked 2 inline comments as done.
stevewan added inline comments.



Comment at: clang/lib/AST/RecordLayoutBuilder.cpp:1975
+  bool AlignAttrCanDecreaseAlignment =
+  AlignIsRequired && (Ty->getAs() != nullptr || FieldPacked);
+

rjmccall wrote:
> stevewan wrote:
> > rjmccall wrote:
> > > Okay, so first off, the comment and variable names here make this sound 
> > > very general when in fact this computation is only relevant to the AIX 
> > > alignment upgrade logic.  Also, please do not introduce new variables 
> > > with broad scope named things like `Ty` that are actually referring to a 
> > > very specific type and not, say, the unadulterated type of the field.
> > > 
> > > It seems to me that the right way to think about this is that, while the 
> > > AIX power alignment upgrade considers whether field type alignment is 
> > > "required", it uses a different condition than the standard rule when 
> > > making that decision.  It's important to understand what that rule is 
> > > exactly, and we can't see that from the current test cases.  In 
> > > particular, attributes on fields that define structs inline actually end 
> > > up applying to both the field and the struct, which confounds unrelated 
> > > issues.  Consider:
> > > 
> > > ```
> > > struct __attribute__((packed, aligned(2))) SS {
> > >   double d;
> > > };
> > > 
> > > struct S {
> > >   // Neither the field nor the struct are packed, but the field type is.
> > >   // Do we apply the alignment upgrade to S or not?
> > >   struct SS s;
> > > };
> > > ```
> > > 
> > > Regardless, I don't think this check for a typedef works; it's bypassing 
> > > quite a bit of recursive logic for computing whether type alignment is 
> > > required.  For example, you could have an explicitly aligned typedef of 
> > > an array type, and you'll lose that typedef here.
> > Thanks for the review. 
> > 
> > > the comment and variable names here make this sound very general when in 
> > > fact this computation is only relevant to the AIX alignment upgrade logic.
> > Moved the variable declarations back to the AIX alignment upgrade logic. 
> > >  It's important to understand what that rule is exactly, and we can't see 
> > > that from the current test cases.
> > Updated the test cases accordingly.
> > > For example, you could have an explicitly aligned typedef of an array 
> > > type, and you'll lose that typedef here.
> > Updated the check to examine the immediate type rather than the base 
> > element type, this should take care of the array-type considerations. 
> > 
> No, I'm not sure that's quite correct, either, because you might have an 
> array of an explicitly aligned typedef.  You might need to do a recursive 
> examination of the type the same way that getTypeInfo would, except I guess 
> not recursing into records.
> 
> I assume you verified that the behavior in your new test cases matches the 
> behavior of some existing AIX compiler?  For our general edification, what 
> compiler(s) are you testing against?
> 
> I've found that extracting very complex conditions into a function (perhaps a 
> lambda if it's inconvenient to have it separately-declared) can be useful.
Added a lambda function that mimics getTypeInfo to do the recursive check. If 
this looks about right in direction, I'm also going to memorize known types' 
typedef-ness in a map for faster lookup.

Yes, the behaviour was verified, and matches the behaviour of XL 16.1 on AIX.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107394

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


[PATCH] D105759: [WIP] Implement P2361 Unevaluated string literals

2021-08-25 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a reviewer: rsmith.
aaron.ballman added a subscriber: jfb.
aaron.ballman added inline comments.



Comment at: clang/lib/Lex/LiteralSupport.cpp:95-96
+  case '?':
+  case 'n':
+  case 't':
+return true;

cor3ntin wrote:
> aaron.ballman wrote:
> > Do you intend to miss a bunch of escapes like `\'` and `\r` (etc)?
> \' is there. I am less sure about '\r' and '\a'. for example. This is 
> something I realized after writing P2361.
> what does '\a` in static assert mean? even '\r' is not so obvious
Looking at the list again, I think only `\a` is really of interest here. I know 
some folks like @jfb have mentioned that `\a` could be used to generate an 
alert sound on a terminal, which is a somewhat useful feature for a failed 
static assertion if you squint at it hard enough.

But the rest of the missing ones do seem more questionable to support.



Comment at: clang/lib/Parse/ParseDecl.cpp:422-423
 
-ExprResult ArgExpr(
-Actions.CorrectDelayedTyposInExpr(ParseAssignmentExpression()));
+ExprResult ArgExpr(Actions.CorrectDelayedTyposInExpr(
+ParseAttributeArgAsUnevaluatedLiteralOrExpression(AttrKind)));
 if (ArgExpr.isInvalid()) {

cor3ntin wrote:
> aaron.ballman wrote:
> > Hmmm, I'm not certain about these changes.
> > 
> > For some attributes, the standard currently requires accepting any kind of 
> > string literal (like `[[deprecated]]` 
> > https://eel.is/c++draft/dcl.attr.deprecated#1). P2361 is proposing to 
> > change that, but it's not yet accepted by WG21 (let alone WG14). So giving 
> > errors in those cases is a bit of a hard sell -- I think warnings would be 
> > a bit more reasonable.
> > 
> > But for other attributes (like `annotate`), it's a bit less clear whether 
> > we should *prevent* literal prefixes because the attribute can be used to 
> > have runtime impacts (for example, I can imagine someone using `annotate` 
> > to emit the string literal bytes into the resulting binary). In some cases, 
> > I think it's very reasonable (e.g., `diagnose_if` should behave the same as 
> > `deprecated` and `nodiscard` because those are purely about generating 
> > diagnostics at compile time).
> > 
> > I kind of wonder whether we're going to want to tablegenerate whether the 
> > argument needs to be parsed as unevaluated or not on an 
> > attribute-by-attribute basis.
> Yep, I would not expect this to get merge before P2361 but I think the 
> implementation experience is useful and raised a bunch of good questions.
> I don't think it ever makes sense to have `L` outside of literals - but 
> people *might* do it currently, in which case there is a concern about 
> whether it breaks code (I have found no evidence of that though).
> 
> If we wanted to inject these strings in the binary - in some form, then we 
> might have to transcode them at that point.
> I don't think the user would know if the string would be injected as wide or 
> narrow (or something else) by the compiler.
> 
> `L` is really is want to convert that string _at that point_. in an 
> attribute, strings might have multiple usages so it's better to delay any 
> transcoding.
> Does that make sense?
> 
> But I agree that a survey of what each attribute expects is in order.
> 
> 
> 
> Yep, I would not expect this to get merge before P2361 but I think the 
> implementation experience is useful and raised a bunch of good questions.

Absolutely agreed, this is worthwhile effort!

> If we wanted to inject these strings in the binary - in some form, then we 
> might have to transcode them at that point.
> I don't think the user would know if the string would be injected as wide or 
> narrow (or something else) by the compiler.

My intuition is that a user who writes `L"foo"` will expect a wide `"foo"` to 
appear in the binary in the cases where the string ends up making it that far.

> L is really is want to convert that string _at that point_. in an attribute, 
> strings might have multiple usages so it's better to delay any transcoding.
> Does that make sense?

Not yet, but I might get there eventually. :-D My concern is that vendor 
attributes can basically do anything, so there's no reason to assume that any 
given string literal usage should or should not transcode. I think we have to 
decide on a case by case basis by letting the attributes specify what they 
intend in their argument lists. However, my intuition is that *most* attributes 
will expect unevaluated string literals because the string argument doesn't get 
passed to LLVM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105759

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


[PATCH] D108710: [clang][deps] Reset non-modular language and preprocessor options

2021-08-25 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 added inline comments.



Comment at: clang/test/ClangScanDeps/Inputs/removed-args/cdb.json.template:4
+"directory": "DIR",
+"command": "clang -fsyntax-only DIR/tu.c -fmodules -fimplicit-module-maps 
-fmodules-cache-path=DIR/cache -include DIR/header.h -o DIR/tu.o",
+"file": "DIR/tu.c"

jansvoboda11 wrote:
> dexonsmith wrote:
> > It looks to me like that this test would have passed before the code 
> > change, since there was already logic for dropping `-include`. Can you also 
> > add some other argument(s) that wouldn't have been dropped before, but will 
> > be now?
> Only the `-include-pch` argument was being dropped 
> (`PreprocessorOptions::ImplicitPCHInclude`). The `-include` arguments 
> (`PreprocessorOptions::Includes`) were being preserved. This test would not 
> pass without the changes to `ModuleDepCollector.cpp`.
> 
> I can add checks for other arguments that are being dropped now that weren't 
> before, but assuming `resetNonModularOptions` are already being tested 
> elsewhere, I don't think there's much value in that.
Note that the driver will expand `-include ` into `-include-pch 
.gch` only if the PCH `.gch` file exists. Since we're not 
precompiling the header in this particular test, that won't be the case. This 
argument therefore doesn't map onto `PreprocessorOptions::ImplicitPCHInclude`. 
It maps onto `PreprocessorOptions::Includes`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108710

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


[PATCH] D108720: Effectively revert 33c3d8a916c / D33782

2021-08-25 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

In D108720#2965642 , @zero9178 wrote:

> Just a heads up, the patch added `/permissive` and `/permissive-`, but made 
> neither the default as to not be a breaking change. That means that clang-cl 
> still parses operator keywords and also does delayed template parsing, as it 
> did before the patch.

Oh, I see. So, my change will then be a breaking change: users of clang-cl with 
no flags will not be able to include  from the Windows SDK out of the 
box. But, such users can simply add `/permissive` and probably carry on their 
way. I think I can live with that. I may add a release note for it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108720

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


[PATCH] D108710: [clang][deps] Reset non-modular language and preprocessor options

2021-08-25 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith accepted this revision.
dexonsmith added a comment.
This revision is now accepted and ready to land.

LGTM with after adding a comment to the testcase. Thanks for explaining!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108710

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


[PATCH] D108661: The maximal representable alignment in LLVM IR is 1GiB, not 512MiB

2021-08-25 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added inline comments.



Comment at: llvm/test/CodeGen/X86/load-with-1gb-alignment.mir:1
+# RUN: llc -run-pass machine-cp -o - %s | FileCheck %s
+

Should use -run-pass=none, and go in test/CodeGen/MIR/X86



Comment at: llvm/test/CodeGen/X86/load-with-1gb-alignment.mir:6-16
+--- |
+  ; ModuleID = '/tmp/test.ll'
+  source_filename = "/tmp/test.ll"
+  target datalayout = 
"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
+
+  define i32 @load(i32* %ptr) {
+%r = load i32, i32* %ptr, align 1073741824

Don't need the IR section



Comment at: llvm/test/CodeGen/X86/load-with-1gb-alignment.mir:31
+
+renamable $eax = MOV32rm killed renamable $rdi, 1, $noreg, 0, $noreg :: 
(load (s32) from %ir.ptr, align 1073741824)
+RETQ $eax

Don't need the IR reference, can also test basealign


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108661

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


[clang] 9dc92bb - [OpenCL][NFC] Fix code example in __remove_address_space documentation.

2021-08-25 Thread Justas Janickas via cfe-commits

Author: Justas Janickas
Date: 2021-08-25T21:24:32+01:00
New Revision: 9dc92bba6c742216096e33402a1a8aebf5ca48b7

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

LOG: [OpenCL][NFC] Fix code example in __remove_address_space documentation.

Added: 


Modified: 
clang/docs/LanguageExtensions.rst

Removed: 




diff  --git a/clang/docs/LanguageExtensions.rst 
b/clang/docs/LanguageExtensions.rst
index fada65c487bc..3193c8cdc11e 100644
--- a/clang/docs/LanguageExtensions.rst
+++ b/clang/docs/LanguageExtensions.rst
@@ -1978,7 +1978,7 @@ address space qualifiers, therefore, other type 
qualifiers such as
   void foo(T *par){
 T var1; // error - local function variable with global address space
 __private T var2; // error - conflicting address space qualifiers
-__private __remove_address_space var3; // var3 is __private int
+__private __remove_address_space::type var3; // var3 is __private int
   }
 
   void bar(){



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


[PATCH] D107394: [AIX] "aligned" attribute does not decrease alignment

2021-08-25 Thread Steven Wan via Phabricator via cfe-commits
stevewan updated this revision to Diff 368716.
stevewan marked an inline comment as done.
stevewan added a comment.

Avoid unannotated fall-through between cases


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107394

Files:
  clang/lib/AST/RecordLayoutBuilder.cpp
  clang/test/Layout/aix-alignof-align-and-pack-attr.cpp
  clang/test/Layout/aix-power-alignment-typedef.cpp
  clang/test/Layout/aix-type-align-and-pack-attr.cpp

Index: clang/test/Layout/aix-type-align-and-pack-attr.cpp
===
--- /dev/null
+++ clang/test/Layout/aix-type-align-and-pack-attr.cpp
@@ -0,0 +1,59 @@
+// RUN: %clang_cc1 -triple powerpc-ibm-aix-xcoff -S -emit-llvm -x c++ < %s | \
+// RUN:   FileCheck %s
+
+// RUN: %clang_cc1 -triple powerpc64-ibm-aix-xcoff -S -emit-llvm -x c++ < %s | \
+// RUN:   FileCheck %s
+
+namespace test1 {
+struct __attribute__((__aligned__(2))) S {
+  double d;
+};
+
+S s;
+
+// CHECK: @{{.*}}test1{{.*}}s{{.*}} = global %"struct.test1::S" zeroinitializer, align 8
+} // namespace test1
+
+namespace test2 {
+struct __attribute__((__aligned__(2), packed)) S {
+  double d;
+};
+
+S s;
+
+// CHECK: @{{.*}}test2{{.*}}s{{.*}} = global %"struct.test2::S" zeroinitializer, align 2
+} // namespace test2
+
+namespace test3 {
+struct __attribute__((__aligned__(16))) S {
+  double d;
+};
+
+S s;
+
+// CHECK: @{{.*}}test3{{.*}}s{{.*}} = global %"struct.test3::S" zeroinitializer, align 16
+} // namespace test3
+
+namespace test4 {
+struct __attribute__((aligned(2))) SS {
+  double d;
+};
+
+struct S {
+  struct SS ss;
+} s;
+
+// CHECK: @{{.*}}test4{{.*}}s{{.*}} = global %"struct.test4::S" zeroinitializer, align 8
+} // namespace test4
+
+namespace test5 {
+struct __attribute__((aligned(2), packed)) SS {
+  double d;
+};
+
+struct S {
+  struct SS ss;
+} s;
+
+// CHECK: @{{.*}}test5{{.*}}s{{.*}} = global %"struct.test5::S" zeroinitializer, align 2
+} // namespace test5
Index: clang/test/Layout/aix-power-alignment-typedef.cpp
===
--- clang/test/Layout/aix-power-alignment-typedef.cpp
+++ clang/test/Layout/aix-power-alignment-typedef.cpp
@@ -37,3 +37,39 @@
 // CHECK-NEXT:   |  nvsize=2, nvalign=2, preferrednvalign=2]
 
 } // namespace test2
+
+namespace test3 {
+typedef double DblArr[] __attribute__((__aligned__(2)));
+
+union U {
+  DblArr da;
+  char x;
+};
+
+int x = sizeof(U);
+
+// CHECK:  0 | union test3::U
+// CHECK-NEXT: 0 |   test3::DblArr da
+// CHECK-NEXT: 0 |   char x
+// CHECK-NEXT:   | [sizeof=2, dsize=2, align=2, preferredalign=2,
+// CHECK-NEXT:   |  nvsize=2, nvalign=2, preferrednvalign=2]
+
+} // namespace test3
+
+namespace test4 {
+typedef double Dbl __attribute__((__aligned__(2)));
+
+union U {
+  Dbl DblArr[];
+  char x;
+};
+
+int x = sizeof(U);
+
+// CHECK:  0 | union test4::U
+// CHECK-NEXT: 0 |   test4::Dbl [] DblArr
+// CHECK-NEXT: 0 |   char x
+// CHECK-NEXT:   | [sizeof=2, dsize=2, align=2, preferredalign=2,
+// CHECK-NEXT:   |  nvsize=2, nvalign=2, preferrednvalign=2]
+
+} // namespace test4
Index: clang/test/Layout/aix-alignof-align-and-pack-attr.cpp
===
--- clang/test/Layout/aix-alignof-align-and-pack-attr.cpp
+++ /dev/null
@@ -1,29 +0,0 @@
-// RUN: %clang_cc1 -triple powerpc-ibm-aix-xcoff -S -emit-llvm -x c++ < %s | \
-// RUN:   FileCheck %s
-
-// RUN: %clang_cc1 -triple powerpc64-ibm-aix-xcoff -S -emit-llvm -x c++ < %s | \
-// RUN:   FileCheck %s
-
-namespace test1 {
-struct __attribute__((__aligned__(2))) C {
-  double x;
-} c;
-
-// CHECK: @{{.*}}test1{{.*}}c{{.*}} = global %"struct.test1::C" zeroinitializer, align 8
-} // namespace test1
-
-namespace test2 {
-struct __attribute__((__aligned__(2), packed)) C {
-  double x;
-} c;
-
-// CHECK: @{{.*}}test2{{.*}}c{{.*}} = global %"struct.test2::C" zeroinitializer, align 2
-} // namespace test2
-
-namespace test3 {
-struct __attribute__((__aligned__(16))) C {
-  double x;
-} c;
-
-// CHECK: @{{.*}}test3{{.*}}c{{.*}} = global %"struct.test3::C" zeroinitializer, align 16
-} // namespace test3
Index: clang/lib/AST/RecordLayoutBuilder.cpp
===
--- clang/lib/AST/RecordLayoutBuilder.cpp
+++ clang/lib/AST/RecordLayoutBuilder.cpp
@@ -1978,8 +1978,144 @@
   // and zero-width bit-fields count as prior members; members of empty class
   // types marked `no_unique_address` are not considered to be prior members.
   CharUnits PreferredAlign = FieldAlign;
-  if (DefaultsToAIXPowerAlignment && !AlignIsRequired &&
+  if (DefaultsToAIXPowerAlignment &&
   (FoundFirstNonOverlappingEmptyFieldForAIX || IsNaturalAlign)) {
+auto checkTypeIsTypedef = [](auto &&checkTypeIsTypedef,
+ const auto Ty) -> bool {
+  bool isTypedef = false;
+  switch

LLVM buildmaster will be restarted tonight

2021-08-25 Thread Galina Kistanova via cfe-commits
 Hello everyone,

LLVM buildmaster will be restarted at 5 PM PST today.

Thanks

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


[PATCH] D108661: The maximal representable alignment in LLVM IR is 1GiB, not 512MiB

2021-08-25 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri updated this revision to Diff 368719.
lebedev.ri added a comment.

@arsenm i do not understand how i can avoid having IR there, but addressed 
other nits. thanks for taking a look!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108661

Files:
  clang/include/clang/Sema/Sema.h
  clang/test/CXX/drs/dr6xx.cpp
  clang/test/CodeGen/builtin-assume-aligned.c
  
clang/test/CodeGen/catch-alignment-assumption-attribute-align_value-on-paramvar.cpp
  
clang/test/CodeGen/catch-alignment-assumption-builtin_assume_aligned-three-params-variable.cpp
  
clang/test/CodeGen/catch-alignment-assumption-builtin_assume_aligned-three-params.cpp
  
clang/test/CodeGen/catch-alignment-assumption-builtin_assume_aligned-two-params.cpp
  clang/test/CodeGen/catch-alignment-assumption-openmp.cpp
  clang/test/Sema/alloc-align-attr.c
  clang/test/Sema/attr-aligned.c
  clang/test/Sema/builtin-assume-aligned.c
  clang/test/SemaCXX/alloc-align-attr.cpp
  llvm/include/llvm/IR/Instruction.h
  llvm/include/llvm/IR/Value.h
  llvm/test/Assembler/align-inst-alloca.ll
  llvm/test/Assembler/align-inst-load.ll
  llvm/test/Assembler/align-inst-store.ll
  llvm/test/Bitcode/inalloca.ll
  llvm/test/CodeGen/MIR/X86/load-with-1gb-alignment.mir
  llvm/test/Transforms/Attributor/ArgumentPromotion/live_called_from_dead.ll
  llvm/test/Transforms/Attributor/ArgumentPromotion/live_called_from_dead_2.ll
  llvm/test/Transforms/Attributor/IPConstantProp/PR26044.ll
  llvm/test/Transforms/Attributor/IPConstantProp/pthreads.ll
  llvm/test/Transforms/Attributor/callbacks.ll
  llvm/test/Transforms/Attributor/liveness.ll
  llvm/test/Transforms/Attributor/memory_locations.ll
  llvm/test/Transforms/Attributor/noalias.ll
  llvm/test/Transforms/Attributor/nocapture-1.ll
  llvm/test/Transforms/Attributor/noundef.ll
  llvm/test/Transforms/Attributor/undefined_behavior.ll
  llvm/test/Transforms/Attributor/value-simplify.ll
  llvm/test/Transforms/GVN/PRE/2017-06-28-pre-load-dbgloc.ll
  llvm/test/Transforms/InstCombine/atomic.ll
  llvm/test/Transforms/InstCombine/getelementptr.ll
  llvm/test/Transforms/InstCombine/load.ll
  llvm/test/Transforms/InstCombine/mempcpy.ll
  llvm/test/Transforms/InstCombine/pr44245.ll
  llvm/test/Transforms/InstCombine/store.ll
  llvm/test/Transforms/OpenMP/parallel_level_fold.ll
  llvm/test/Verifier/align-md.ll
  llvm/unittests/IR/ValueTest.cpp

Index: llvm/unittests/IR/ValueTest.cpp
===
--- llvm/unittests/IR/ValueTest.cpp
+++ llvm/unittests/IR/ValueTest.cpp
@@ -61,9 +61,9 @@
  GlobalVariable::NotThreadLocal,
  1);
 
-  EXPECT_TRUE(Value::MaximumAlignment == 536870912U);
-  Dummy0->setAlignment(Align(536870912));
-  EXPECT_EQ(Dummy0->getAlignment(), 536870912U);
+  EXPECT_TRUE(Value::MaximumAlignment == 1073741824U);
+  Dummy0->setAlignment(Align(1073741824));
+  EXPECT_EQ(Dummy0->getAlignment(), 1073741824U);
 
   // Make sure the address space isn't dropped when returning this.
   Constant *Dummy1 = M->getOrInsertGlobal("dummy", Int32Ty);
@@ -101,7 +101,7 @@
  Constant::getAllOnesValue(Int32Ty), "var", nullptr,
  GlobalVariable::NotThreadLocal, 1);
 
-  EXPECT_DEATH(Var->setAlignment(Align(1073741824U)),
+  EXPECT_DEATH(Var->setAlignment(Align(2147483648U)),
"Alignment is greater than MaximumAlignment");
 }
 #endif
Index: llvm/test/Verifier/align-md.ll
===
--- llvm/test/Verifier/align-md.ll
+++ llvm/test/Verifier/align-md.ll
@@ -52,8 +52,8 @@
 
 define i8* @f7(i8** %x) {
 entry:
-  %y = load i8*, i8** %x, !align !{i64 1073741824}
+  %y = load i8*, i8** %x, !align !{i64 2147483648}
   ret i8* %y
 }
 ; CHECK: alignment is larger that implementation defined limit
-; CHECK-NEXT: load i8*, i8** %x
\ No newline at end of file
+; CHECK-NEXT: load i8*, i8** %x
Index: llvm/test/Transforms/OpenMP/parallel_level_fold.ll
===
--- llvm/test/Transforms/OpenMP/parallel_level_fold.ll
+++ llvm/test/Transforms/OpenMP/parallel_level_fold.ll
@@ -49,9 +49,9 @@
 
 define weak void @parallel() {
 ; CHECK-LABEL: define {{[^@]+}}@parallel() {
-; CHECK-NEXT:[[I:%.*]] = call i32 @__kmpc_target_init(%struct.ident_t* align 536870912 null, i1 true, i1 false, i1 false)
+; CHECK-NEXT:[[I:%.*]] = call i32 @__kmpc_target_init(%struct.ident_t* align 1073741824 null, i1 true, i1 false, i1 false)
 ; CHECK-NEXT:call void @spmd_helper()
-; CHECK-NEXT:call void @__kmpc_parallel_51(%struct.ident_t* noalias noundef align 536870912 null, i32 noundef 0, i32 noundef 0, i32 noundef 0, i32 noundef 0, i8* noalias noundef align 536870912 null, i8* noalias noundef align 536870912 null, i8** noalias noundef align 536870912 null, i64 noundef 0)
+; CHECK-NEXT:call void @__kmpc_parallel_51(%

[PATCH] D108643: Introduce _BitInt, deprecate _ExtInt

2021-08-25 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

In D108643#2964740 , @aaron.ballman 
wrote:

> In D108643#2964190 , @rjmccall 
> wrote:
>
>> I agree with James; I know you've reached out to the Itanium ABI group about 
>> mangling, but ABI involvement needs to mean also reaching out and getting 
>> psABI agreement about representation.  I would suggest proposing a generic 
>> ABI, getting consensus on that generic ABI with other implementors, and then 
>> running that generic ABI past as many platform ABI groups as you can get in 
>> touch with.
>
> I've already reached out to the psABI maintainers and have started those 
> discussions before ever considering the mangling questions: 
> https://gitlab.com/x86-psABIs/x86-64-ABI/-/commit/21622785649f2cbacb596d135a417171f52ad539

Okay.  To be clear, that's not "the psABI maintainers", that's specifically the 
x86_64 psABI group.  Is your expectation that other psABI groups would more or 
less copy the wording from the x86_64 psABI, potentially replacing 64 with 32 
as appropriate, or would you want to host a generic ABI document somewhere 
else?  If the latter, I think the Clang repository wouldn't be an unreasonable 
place to do that; we do something similar with blocks.

I would be happy to put you in touch with some other psABI groups when you're 
ready to talk to them.

> Note that there are some changes expected to that wording (the "bit-aligned" 
> stuff should say "byte-aligned" and we're missing information about 
> bit-fields), so if there are additional changes we'd like to see made, now's 
> a good time to make them.

The choice that high bits are unspecified rather than extended is an 
interesting one.  Can you speak to that?  That's good for +, -, *, &, |, ^, <<, 
and narrowing conversions, but bad for ==, <, /, >>, and widening conversions.

One advantage of having a generic ABI is that you can give a rationale in the 
document, which would be out of scope for a psABI.

>> You can't have bit-fields of `_BitInt` type, can you?  If people want that, 
>> or want a truly packed `_BitInt` where `sizeof(_BitInt(56)) == 7`, it's 
>> going to add a lot of complexity.
>
> You can have bit-fields of _BitInt type (and we even tell you when you do 
> dumb things with it https://godbolt.org/z/sTKKdb1o1), but I'm not seeing 
> where the complexity comes in from that

What is your expectation of how a `_BitInt` bit-field interacts with adjacent 
bit-fields?  Does `unsigned a: 1; _BitInt(8) b: 7;` only use 8 bits?  Does 
`unsigned a: 1; _BitInt(95) b: 95;` only use 96?  Does the latter change based 
on whether this is a 32-bit or 64-bit target?  Does it change if the type is 
`_BitInt(128)` instead?  What is the "storage unit" of a `_BitInt` for the 
purposes of ABIs that are sensitive to such things?

Also, C requires the width of a bit-field to be no larger than the width of the 
underlying type, but C++ allows "wide" bit-fields, and psABIs are inconsistent 
about giving rules for their layout.  Does this match that where supported, or 
is a different set of rules?


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

https://reviews.llvm.org/D108643

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


[PATCH] D108661: The maximal representable alignment in LLVM IR is 1GiB, not 512MiB

2021-08-25 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri updated this revision to Diff 368722.
lebedev.ri added a comment.

Address rest of nits.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108661

Files:
  clang/include/clang/Sema/Sema.h
  clang/test/CXX/drs/dr6xx.cpp
  clang/test/CodeGen/builtin-assume-aligned.c
  
clang/test/CodeGen/catch-alignment-assumption-attribute-align_value-on-paramvar.cpp
  
clang/test/CodeGen/catch-alignment-assumption-builtin_assume_aligned-three-params-variable.cpp
  
clang/test/CodeGen/catch-alignment-assumption-builtin_assume_aligned-three-params.cpp
  
clang/test/CodeGen/catch-alignment-assumption-builtin_assume_aligned-two-params.cpp
  clang/test/CodeGen/catch-alignment-assumption-openmp.cpp
  clang/test/Sema/alloc-align-attr.c
  clang/test/Sema/attr-aligned.c
  clang/test/Sema/builtin-assume-aligned.c
  clang/test/SemaCXX/alloc-align-attr.cpp
  llvm/include/llvm/IR/Instruction.h
  llvm/include/llvm/IR/Value.h
  llvm/test/Assembler/align-inst-alloca.ll
  llvm/test/Assembler/align-inst-load.ll
  llvm/test/Assembler/align-inst-store.ll
  llvm/test/Bitcode/inalloca.ll
  llvm/test/CodeGen/MIR/X86/load-with-1gb-alignment.mir
  llvm/test/Transforms/Attributor/ArgumentPromotion/live_called_from_dead.ll
  llvm/test/Transforms/Attributor/ArgumentPromotion/live_called_from_dead_2.ll
  llvm/test/Transforms/Attributor/IPConstantProp/PR26044.ll
  llvm/test/Transforms/Attributor/IPConstantProp/pthreads.ll
  llvm/test/Transforms/Attributor/callbacks.ll
  llvm/test/Transforms/Attributor/liveness.ll
  llvm/test/Transforms/Attributor/memory_locations.ll
  llvm/test/Transforms/Attributor/noalias.ll
  llvm/test/Transforms/Attributor/nocapture-1.ll
  llvm/test/Transforms/Attributor/noundef.ll
  llvm/test/Transforms/Attributor/undefined_behavior.ll
  llvm/test/Transforms/Attributor/value-simplify.ll
  llvm/test/Transforms/GVN/PRE/2017-06-28-pre-load-dbgloc.ll
  llvm/test/Transforms/InstCombine/atomic.ll
  llvm/test/Transforms/InstCombine/getelementptr.ll
  llvm/test/Transforms/InstCombine/load.ll
  llvm/test/Transforms/InstCombine/mempcpy.ll
  llvm/test/Transforms/InstCombine/pr44245.ll
  llvm/test/Transforms/InstCombine/store.ll
  llvm/test/Transforms/OpenMP/parallel_level_fold.ll
  llvm/test/Verifier/align-md.ll
  llvm/unittests/IR/ValueTest.cpp

Index: llvm/unittests/IR/ValueTest.cpp
===
--- llvm/unittests/IR/ValueTest.cpp
+++ llvm/unittests/IR/ValueTest.cpp
@@ -61,9 +61,9 @@
  GlobalVariable::NotThreadLocal,
  1);
 
-  EXPECT_TRUE(Value::MaximumAlignment == 536870912U);
-  Dummy0->setAlignment(Align(536870912));
-  EXPECT_EQ(Dummy0->getAlignment(), 536870912U);
+  EXPECT_TRUE(Value::MaximumAlignment == 1073741824U);
+  Dummy0->setAlignment(Align(1073741824));
+  EXPECT_EQ(Dummy0->getAlignment(), 1073741824U);
 
   // Make sure the address space isn't dropped when returning this.
   Constant *Dummy1 = M->getOrInsertGlobal("dummy", Int32Ty);
@@ -101,7 +101,7 @@
  Constant::getAllOnesValue(Int32Ty), "var", nullptr,
  GlobalVariable::NotThreadLocal, 1);
 
-  EXPECT_DEATH(Var->setAlignment(Align(1073741824U)),
+  EXPECT_DEATH(Var->setAlignment(Align(2147483648U)),
"Alignment is greater than MaximumAlignment");
 }
 #endif
Index: llvm/test/Verifier/align-md.ll
===
--- llvm/test/Verifier/align-md.ll
+++ llvm/test/Verifier/align-md.ll
@@ -52,8 +52,8 @@
 
 define i8* @f7(i8** %x) {
 entry:
-  %y = load i8*, i8** %x, !align !{i64 1073741824}
+  %y = load i8*, i8** %x, !align !{i64 2147483648}
   ret i8* %y
 }
 ; CHECK: alignment is larger that implementation defined limit
-; CHECK-NEXT: load i8*, i8** %x
\ No newline at end of file
+; CHECK-NEXT: load i8*, i8** %x
Index: llvm/test/Transforms/OpenMP/parallel_level_fold.ll
===
--- llvm/test/Transforms/OpenMP/parallel_level_fold.ll
+++ llvm/test/Transforms/OpenMP/parallel_level_fold.ll
@@ -49,9 +49,9 @@
 
 define weak void @parallel() {
 ; CHECK-LABEL: define {{[^@]+}}@parallel() {
-; CHECK-NEXT:[[I:%.*]] = call i32 @__kmpc_target_init(%struct.ident_t* align 536870912 null, i1 true, i1 false, i1 false)
+; CHECK-NEXT:[[I:%.*]] = call i32 @__kmpc_target_init(%struct.ident_t* align 1073741824 null, i1 true, i1 false, i1 false)
 ; CHECK-NEXT:call void @spmd_helper()
-; CHECK-NEXT:call void @__kmpc_parallel_51(%struct.ident_t* noalias noundef align 536870912 null, i32 noundef 0, i32 noundef 0, i32 noundef 0, i32 noundef 0, i8* noalias noundef align 536870912 null, i8* noalias noundef align 536870912 null, i8** noalias noundef align 536870912 null, i64 noundef 0)
+; CHECK-NEXT:call void @__kmpc_parallel_51(%struct.ident_t* noalias noundef align 1073741824 null, i32 noundef 0, i32 noundef 0, i32 nou

[PATCH] D108661: The maximal representable alignment in LLVM IR is 1GiB, not 512MiB

2021-08-25 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

Seems reasonable to me.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108661

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


[clang] db3d029 - Effectively revert 33c3d8a916c / D33782

2021-08-25 Thread Reid Kleckner via cfe-commits

Author: Reid Kleckner
Date: 2021-08-25T14:41:26-07:00
New Revision: db3d029fbe09925ea42a3279b1abb244fa547cff

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

LOG: Effectively revert 33c3d8a916c / D33782

This change would treat the token `or` in system headers as an
identifier, and elsewhere as an operator. As reported in
llvm.org/pr42427, many users classify their third party library headers
as "system" headers to suppress warnings. There's no clean way to
separate Windows SDK headers from user headers.

Clang is still able to parse old Windows SDK headers if C++ operator
names are disabled. Traditionally this was controlled by
`-fno-operator-names`, but is now also enabled with `/permissive` since
D103773. This change will prevent `clang-cl` from parsing  from
the Windows SDK out of the box, but there are multiple ways to work
around that:
- Pass `/clang:-fno-operator-names`
- Pass `/permissive`
- Pass `-DQUERY_H_RESTRICTION_PERMISSIVE`

In all of these modes, the operator names will consistently be available
or not available, instead of depending on whether the code is in a
system header.

I added a release note for this, since it may break straightforward
users of the Windows SDK.

Fixes PR42427

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

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/lib/Lex/Preprocessor.cpp

Removed: 
clang/test/Headers/ms-cppoperkey.cpp
clang/test/Headers/ms-cppoperkey1.cpp
clang/test/Headers/ms-cppoperkey2.cpp



diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 4ed7543a2b86..8bae1ed29eeb 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -97,6 +97,12 @@ Attribute Changes in Clang
 Windows Support
 ---
 
+- An MSVC compatibility workaround for C++ operator names was removed. As a
+  result, the  Windows SDK header may not compile out of the box.
+  Users should use a recent SDK and pass ``-DQUERY_H_RESTRICTION_PERMISSIVE``
+  or pass ``/permissive`` to disable C++ operator names altogether. See
+  `PR42427 ` for more info.
+
 C Language Changes in Clang
 ---
 

diff  --git a/clang/lib/Lex/Preprocessor.cpp b/clang/lib/Lex/Preprocessor.cpp
index d79637a68a8b..97615d89cefc 100644
--- a/clang/lib/Lex/Preprocessor.cpp
+++ b/clang/lib/Lex/Preprocessor.cpp
@@ -723,11 +723,7 @@ IdentifierInfo *Preprocessor::LookUpIdentifierInfo(Token 
&Identifier) const {
   // is cleaned to tok::identifier "B". After cleaning the token's length is
   // still 3 and the SourceLocation refers to the location of the backslash.
   Identifier.setIdentifierInfo(II);
-  if (getLangOpts().MSVCCompat && II->isCPlusPlusOperatorKeyword() &&
-  getSourceManager().isInSystemHeader(Identifier.getLocation()))
-Identifier.setKind(tok::identifier);
-  else
-Identifier.setKind(II->getTokenID());
+  Identifier.setKind(II->getTokenID());
 
   return II;
 }

diff  --git a/clang/test/Headers/ms-cppoperkey.cpp 
b/clang/test/Headers/ms-cppoperkey.cpp
deleted file mode 100644
index ca56ee17bcb1..
--- a/clang/test/Headers/ms-cppoperkey.cpp
+++ /dev/null
@@ -1,16 +0,0 @@
-// RUN: %clang_cc1 \
-// RUN: -fms-compatibility -x c++-cpp-output \
-// RUN: -ffreestanding -fsyntax-only -Werror \
-// RUN: %s -verify
-// expected-no-diagnostics
-# 1 "t.cpp"
-# 1 "query.h" 1 3
-// MS header  uses operator keyword as field name.  
-// Compile without syntax errors.
-struct tagRESTRICTION
-  {
-   union _URes 
- {
-   int or; // Note use of cpp operator token
- } res;
-  };

diff  --git a/clang/test/Headers/ms-cppoperkey1.cpp 
b/clang/test/Headers/ms-cppoperkey1.cpp
deleted file mode 100644
index c03efc9dacde..
--- a/clang/test/Headers/ms-cppoperkey1.cpp
+++ /dev/null
@@ -1,27 +0,0 @@
-// RUN: %clang_cc1 \
-// RUN: -fms-compatibility -x c++-cpp-output \
-// RUN: -ffreestanding -fsyntax-only -Werror \
-// RUN: %s -verify
-
-
-# 1 "t.cpp"
-# 1 "query.h" 1 3 4
-// MS header  uses operator keyword as field name.  
-// Compile without syntax errors.
-struct tagRESTRICTION
-  {
-   union _URes 
- {
-   int or; // Note use of cpp operator token
- } res;
-  };
-   ;
-
-int aa ( int x)
-{
-  // In system header code, treat operator keyword as identifier.
-  if ( // expected-note{{to match this '('}}
-x>1 or x<0) return 1; // expected-error{{expected ')'}}
-  else return 0;  
-}
-

diff  --git a/clang/test/Headers/ms-cppoperkey2.cpp 
b/clang/test/Headers/ms-cppoperkey2.cpp
deleted file mode 100644
index 2afed36b7446..
--- a/clang/test/Headers/ms-cppoperkey2.cpp
+++ /dev/null
@@ -1,11 +0,0 @@
-// RUN: %clang_cc1  -triple x86_64-pc-win32 -fms-compatibility \
-// RUN: -ffree

[PATCH] D108702: [PowerPC][NFC] Rename P10 builtins vec_clrl, vec_clrr to vec_clr_first and vec_clr_last

2021-08-25 Thread Lei Huang via Phabricator via cfe-commits
lei accepted this revision as: lei.
lei added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108702

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


[PATCH] D108720: Effectively revert 33c3d8a916c / D33782

2021-08-25 Thread Reid Kleckner 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 rGdb3d029fbe09: Effectively revert 33c3d8a916c / D33782 
(authored by rnk).

Changed prior to commit:
  https://reviews.llvm.org/D108720?vs=368693&id=368738#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108720

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Lex/Preprocessor.cpp
  clang/test/Headers/ms-cppoperkey.cpp
  clang/test/Headers/ms-cppoperkey1.cpp
  clang/test/Headers/ms-cppoperkey2.cpp

Index: clang/test/Headers/ms-cppoperkey2.cpp
===
--- clang/test/Headers/ms-cppoperkey2.cpp
+++ /dev/null
@@ -1,11 +0,0 @@
-// RUN: %clang_cc1  -triple x86_64-pc-win32 -fms-compatibility \
-// RUN: -ffreestanding -fsyntax-only -Werror  %s -verify
-// RUN: %clang_cc1 \
-// RUN: -ffreestanding -fsyntax-only -Werror  %s -verify
-// expected-no-diagnostics
-int bb ( int x)
-{
-  // In user code, treat operator keyword as operator keyword.
-  if ( x>1 or x<0) return 1;
-  else return 0;  
-}
Index: clang/test/Headers/ms-cppoperkey1.cpp
===
--- clang/test/Headers/ms-cppoperkey1.cpp
+++ /dev/null
@@ -1,27 +0,0 @@
-// RUN: %clang_cc1 \
-// RUN: -fms-compatibility -x c++-cpp-output \
-// RUN: -ffreestanding -fsyntax-only -Werror \
-// RUN: %s -verify
-
-
-# 1 "t.cpp"
-# 1 "query.h" 1 3 4
-// MS header  uses operator keyword as field name.  
-// Compile without syntax errors.
-struct tagRESTRICTION
-  {
-   union _URes 
- {
-   int or; // Note use of cpp operator token
- } res;
-  };
-   ;
-
-int aa ( int x)
-{
-  // In system header code, treat operator keyword as identifier.
-  if ( // expected-note{{to match this '('}}
-x>1 or x<0) return 1; // expected-error{{expected ')'}}
-  else return 0;  
-}
-
Index: clang/test/Headers/ms-cppoperkey.cpp
===
--- clang/test/Headers/ms-cppoperkey.cpp
+++ /dev/null
@@ -1,16 +0,0 @@
-// RUN: %clang_cc1 \
-// RUN: -fms-compatibility -x c++-cpp-output \
-// RUN: -ffreestanding -fsyntax-only -Werror \
-// RUN: %s -verify
-// expected-no-diagnostics
-# 1 "t.cpp"
-# 1 "query.h" 1 3
-// MS header  uses operator keyword as field name.  
-// Compile without syntax errors.
-struct tagRESTRICTION
-  {
-   union _URes 
- {
-   int or; // Note use of cpp operator token
- } res;
-  };
Index: clang/lib/Lex/Preprocessor.cpp
===
--- clang/lib/Lex/Preprocessor.cpp
+++ clang/lib/Lex/Preprocessor.cpp
@@ -723,11 +723,7 @@
   // is cleaned to tok::identifier "B". After cleaning the token's length is
   // still 3 and the SourceLocation refers to the location of the backslash.
   Identifier.setIdentifierInfo(II);
-  if (getLangOpts().MSVCCompat && II->isCPlusPlusOperatorKeyword() &&
-  getSourceManager().isInSystemHeader(Identifier.getLocation()))
-Identifier.setKind(tok::identifier);
-  else
-Identifier.setKind(II->getTokenID());
+  Identifier.setKind(II->getTokenID());
 
   return II;
 }
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -97,6 +97,12 @@
 Windows Support
 ---
 
+- An MSVC compatibility workaround for C++ operator names was removed. As a
+  result, the  Windows SDK header may not compile out of the box.
+  Users should use a recent SDK and pass ``-DQUERY_H_RESTRICTION_PERMISSIVE``
+  or pass ``/permissive`` to disable C++ operator names altogether. See
+  `PR42427 ` for more info.
+
 C Language Changes in Clang
 ---
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D108661: The maximal representable alignment in LLVM IR is 1GiB, not 512MiB

2021-08-25 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

@arsenm are you happy with the test coverage here?

In D108661#2963519 , @craig.topper 
wrote:

> Wild speculation. This may be a historical artifact of LoadInst and StoreInst 
> having their getAlignment() function written like this when this limit was 
> created
>
>   unsigned getAlignment() const {
> return (1 << (getSubclassDataFromInstruction() >> 1)) >> 1;
>   }
>
> Because "1" is signed int the left shift produced a signed int. The final 
> right shift would be an arithmetic shift. So if the alignment was 1 << 30, 
> the subclass data would be 31, the shift would produce INT_MIN, and the 
> arithmetic right shift would produce 0xc000 which would be incorrect.
>
> AllocaInst used 1U instead of 1 so would have been immune.

That does seem plausible :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108661

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


[PATCH] D108661: The maximal representable alignment in LLVM IR is 1GiB, not 512MiB

2021-08-25 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added inline comments.



Comment at: llvm/test/CodeGen/MIR/X86/load-with-1gb-alignment.mir:1
+# RUN: llc -run-pass=none -o - %s | FileCheck %s
+

Needs to add -march/-mtriple


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108661

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


  1   2   >