[PATCH] D153003: [ODRHash] Fix ODR hashing of template names

2023-06-28 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu added a comment.

In D153003#4456595 , @rsmith wrote:

> I think the behavior change for the testcase here is correct, though I'm not 
> sure that the patch is getting that behaviour change in the right way. Per 
> [temp.type]/1.4 (http://eel.is/c++draft/temp.type#1.4),
>
>> Two template-ids are the same if [...] their corresponding template 
>> template-arguments refer to the same template.
>
> so `B` and `B` are the same type. The stricter "same sequence of 
> tokens" rule doesn't apply here, because using-declarations are not 
> definitions.

Got it. Thanks for your commenting. I can't reopen this page. So I file an 
issue here https://github.com/llvm/llvm-project/issues/63595. @Hahnfeld you can 
still work on this by following the @rsmith 's suggestion  if you're still 
interested. Or I'd like to take it.

> But that also suggests that ODR hashing should not be visiting these template 
> arguments in using-declarations at all, because the ODR does not apply to the 
> types specified in a namespace-scope using-declaration. How to we even get 
> into the ODR hasher here? I thought we only applied it to function and class 
> definitions (to which the ODR does apply).

I think this comes from we add ODRHash for  RecordDecl. This is landed in 
https://reviews.llvm.org/D71734. Do you have suggestion on this? e.g., only 
limit this for C and Objective-C? So that we can solve the issue naturally.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153003

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


[PATCH] D151730: [RISCV] Support target attribute for function

2023-06-28 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: clang/lib/Basic/Targets/RISCV.cpp:385
+  StringRef ExtName = Ext.substr(1);
+  if (llvm::RISCVISAInfo::isSupportedExtensionWithVersion(ExtName) ||
+  llvm::RISCVISAInfo::isSupportedExtension(ExtName))

craig.topper wrote:
> I wonder if we could encapsulate this `if` and the 3 calls into RISCVISAInfo 
> into a single function in RISCVISAInfo?
> 
> Basically we want to know if an extension that may or may not have a version, 
> is a valid extension and if so what is the target feature name for it. We 
> could have one function that does all that and returns the target feature 
> name or an empty string.
I think I explained my idea poorly. I was wondering about having a function 
that allowed us to write

```
std::string TargetFeature = 
llvm::RISCVISAInfo::getTargetFeatureForExtension(ExtName);
if (!TargetFeature.empty())
  Ret.Features.push_back(Ext.front() + TargetFeature);
else
  Ret.Features.push_back(Ext.str());
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151730

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


[PATCH] D152356: [clang][ExtractAPI] Add --emit-symbol-graph option

2023-06-28 Thread Ankur Saini via Phabricator via cfe-commits
Arsenic updated this revision to Diff 535630.
Arsenic added a comment.

Changes majorly include fixing issues pointed out by review comments :

- Remove WrappingExtractAPIAction::prepareToExecuteAction()
- Move knownInputFiles from Base action to ExtractAPIFrontendAction
- Fix naming of MacroCallback and symbolGraphConsumer
- Fix minor typos
- Remove BasicExtractAPIVisitor, directly use ExtractAPIVisitor instead


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152356

Files:
  clang/include/clang/Driver/Options.td
  clang/include/clang/ExtractAPI/ExtractAPIActionBase.h
  clang/include/clang/ExtractAPI/FrontendActions.h
  clang/include/clang/Frontend/FrontendOptions.h
  clang/lib/ExtractAPI/ExtractAPIConsumer.cpp
  clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
  clang/test/ExtractAPI/emit-symbol-graph/multi_file.c
  clang/test/ExtractAPI/emit-symbol-graph/single_file.c

Index: clang/test/ExtractAPI/emit-symbol-graph/single_file.c
===
--- /dev/null
+++ clang/test/ExtractAPI/emit-symbol-graph/single_file.c
@@ -0,0 +1,213 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: split-file %s %t
+// RUN: sed -e "s@INPUT_DIR@%{/t:regex_replacement}@g" \
+// RUN: %t/reference.output.json.in >> %t/reference.output.json
+// RUN: %clang_cc1 %t/main.c --emit-symbol-graph=%t/SymbolGraphs --product-name=basicfile -triple=x86_64-apple-macosx12.0.0
+
+// Generator version is not consistent across test runs, normalize it.
+// RUN: sed -e "s@\"generator\": \".*\"@\"generator\": \"?\"@g" \
+// RUN: %t/SymbolGraphs/main.json >> %t/output-normalized.json
+// RUN: diff %t/reference.output.json %t/output-normalized.json
+
+// CHECK-NOT: error:
+// CHECK-NOT: warning:
+
+//--- main.c
+#define TESTMACRO1 2
+#define TESTMARCRO2 5
+
+int main ()
+{
+  return 0;
+}
+
+
+//--- reference.output.json.in
+{
+  "metadata": {
+"formatVersion": {
+  "major": 0,
+  "minor": 5,
+  "patch": 3
+},
+"generator": "?"
+  },
+  "module": {
+"name": "basicfile",
+"platform": {
+  "architecture": "x86_64",
+  "operatingSystem": {
+"name": "macosx"
+  },
+  "vendor": "apple"
+}
+  },
+  "relationships": [],
+  "symbols": [
+{
+  "accessLevel": "public",
+  "declarationFragments": [
+{
+  "kind": "typeIdentifier",
+  "preciseIdentifier": "c:I",
+  "spelling": "int"
+},
+{
+  "kind": "text",
+  "spelling": " "
+},
+{
+  "kind": "identifier",
+  "spelling": "main"
+},
+{
+  "kind": "text",
+  "spelling": "();"
+}
+  ],
+  "functionSignature": {
+"returns": [
+  {
+"kind": "typeIdentifier",
+"preciseIdentifier": "c:I",
+"spelling": "int"
+  }
+]
+  },
+  "identifier": {
+"interfaceLanguage": "c",
+"precise": "c:@F@main"
+  },
+  "kind": {
+"displayName": "Function",
+"identifier": "c.func"
+  },
+  "location": {
+"position": {
+  "character": 5,
+  "line": 4
+},
+"uri": "file://INPUT_DIR/main.c"
+  },
+  "names": {
+"navigator": [
+  {
+"kind": "identifier",
+"spelling": "main"
+  }
+],
+"subHeading": [
+  {
+"kind": "identifier",
+"spelling": "main"
+  }
+],
+"title": "main"
+  },
+  "pathComponents": [
+"main"
+  ]
+},
+{
+  "accessLevel": "public",
+  "declarationFragments": [
+{
+  "kind": "keyword",
+  "spelling": "#define"
+},
+{
+  "kind": "text",
+  "spelling": " "
+},
+{
+  "kind": "identifier",
+  "spelling": "TESTMACRO1"
+}
+  ],
+  "identifier": {
+"interfaceLanguage": "c",
+"precise": "c:main.c@8@macro@TESTMACRO1"
+  },
+  "kind": {
+"displayName": "Macro",
+"identifier": "c.macro"
+  },
+  "location": {
+"position": {
+  "character": 9,
+  "line": 1
+},
+"uri": "file://INPUT_DIR/main.c"
+  },
+  "names": {
+"navigator": [
+  {
+"kind": "identifier",
+"spelling": "TESTMACRO1"
+  }
+],
+"subHeading": [
+  {
+"kind": "identifier",
+"spelling": "TESTMACRO1"
+  }
+],
+"title": "TESTMACRO1"
+  },
+  "pathComponents": [
+"TESTMACRO1"
+  ]
+},
+{
+  "accessLevel": "public",
+  "declarationFragments": [
+{
+  "kind": "keyword",
+  "spelling": "#define"
+},
+{
+  "kind": 

[PATCH] D153714: [NFC] Add missing cpu tests in predefined-arch-macros.c

2023-06-28 Thread Freddy, Ye via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG548e08c3f635: [NFC] Add missing cpu tests in 
predefined-arch-macros.c (authored by FreddyYe).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153714

Files:
  clang/test/Preprocessor/predefined-arch-macros.c

Index: clang/test/Preprocessor/predefined-arch-macros.c
===
--- clang/test/Preprocessor/predefined-arch-macros.c
+++ clang/test/Preprocessor/predefined-arch-macros.c
@@ -365,9 +365,13 @@
 // RUN: %clang -march=core2 -m32 -E -dM %s -o - 2>&1 \
 // RUN: -target i386-unknown-linux \
 // RUN:   | FileCheck -match-full-lines %s -check-prefix=CHECK_CORE2_M32
+// RUN: %clang -march=penryn -m32 -E -dM %s -o - 2>&1 \
+// RUN: -target i386-unknown-linux \
+// RUN:   | FileCheck -match-full-lines %s -check-prefixes=CHECK_CORE2_M32,CHECK_PENRYN_M32
 // CHECK_CORE2_M32: #define __MMX__ 1
 // CHECK_CORE2_M32: #define __SSE2__ 1
 // CHECK_CORE2_M32: #define __SSE3__ 1
+// CHECK_PENRYN_M32: #define __SSE4_1__ 1
 // CHECK_CORE2_M32: #define __SSE__ 1
 // CHECK_CORE2_M32: #define __SSSE3__ 1
 // CHECK_CORE2_M32: #define __core2 1
@@ -380,10 +384,14 @@
 // RUN: %clang -march=core2 -m64 -E -dM %s -o - 2>&1 \
 // RUN: -target i386-unknown-linux \
 // RUN:   | FileCheck -match-full-lines %s -check-prefix=CHECK_CORE2_M64
+// RUN: %clang -march=penryn -m64 -E -dM %s -o - 2>&1 \
+// RUN: -target i386-unknown-linux \
+// RUN:   | FileCheck -match-full-lines %s -check-prefixes=CHECK_CORE2_M64,CHECK_PENRYN_M64
 // CHECK_CORE2_M64: #define __MMX__ 1
 // CHECK_CORE2_M64: #define __SSE2_MATH__ 1
 // CHECK_CORE2_M64: #define __SSE2__ 1
 // CHECK_CORE2_M64: #define __SSE3__ 1
+// CHECK_PENRYN_M64: #define __SSE4_1__ 1
 // CHECK_CORE2_M64: #define __SSE_MATH__ 1
 // CHECK_CORE2_M64: #define __SSE__ 1
 // CHECK_CORE2_M64: #define __SSSE3__ 1
@@ -398,7 +406,15 @@
 // RUN: %clang -march=corei7 -m32 -E -dM %s -o - 2>&1 \
 // RUN: -target i386-unknown-linux \
 // RUN:   | FileCheck -match-full-lines %s -check-prefix=CHECK_COREI7_M32
+// RUN: %clang -march=nehalem -m32 -E -dM %s -o - 2>&1 \
+// RUN: -target i386-unknown-linux \
+// RUN:   | FileCheck -match-full-lines %s -check-prefix=CHECK_COREI7_M32
+// RUN: %clang -march=westmere -m32 -E -dM %s -o - 2>&1 \
+// RUN: -target i386-unknown-linux \
+// RUN:   | FileCheck -match-full-lines %s -check-prefixes=CHECK_COREI7_M32,CHECK_WESTMERE_M32
+// CHECK_COREI7_M32: #define __CRC32__ 1
 // CHECK_COREI7_M32: #define __MMX__ 1
+// CHECK_WESTMERE_M32: #define __PCLMUL__ 1
 // CHECK_COREI7_M32: #define __POPCNT__ 1
 // CHECK_COREI7_M32: #define __SSE2__ 1
 // CHECK_COREI7_M32: #define __SSE3__ 1
@@ -416,7 +432,15 @@
 // RUN: %clang -march=corei7 -m64 -E -dM %s -o - 2>&1 \
 // RUN: -target i386-unknown-linux \
 // RUN:   | FileCheck -match-full-lines %s -check-prefix=CHECK_COREI7_M64
+// RUN: %clang -march=nehalem -m64 -E -dM %s -o - 2>&1 \
+// RUN: -target i386-unknown-linux \
+// RUN:   | FileCheck -match-full-lines %s -check-prefix=CHECK_COREI7_M64
+// RUN: %clang -march=westmere -m64 -E -dM %s -o - 2>&1 \
+// RUN: -target i386-unknown-linux \
+// RUN:   | FileCheck -match-full-lines %s -check-prefixes=CHECK_COREI7_M64,CHECK_WESTMERE_M64
+// CHECK_COREI7_M64: #define __CRC32__ 1
 // CHECK_COREI7_M64: #define __MMX__ 1
+// CHECK_WESTMERE_M64: #define __PCLMUL__ 1
 // CHECK_COREI7_M64: #define __POPCNT__ 1
 // CHECK_COREI7_M64: #define __SSE2_MATH__ 1
 // CHECK_COREI7_M64: #define __SSE2__ 1
@@ -437,6 +461,9 @@
 // RUN: %clang -march=corei7-avx -m32 -E -dM %s -o - 2>&1 \
 // RUN: -target i386-unknown-linux \
 // RUN:   | FileCheck -match-full-lines %s -check-prefix=CHECK_COREI7_AVX_M32
+// RUN: %clang -march=sandybridge -m32 -E -dM %s -o - 2>&1 \
+// RUN: -target i386-unknown-linux \
+// RUN:   | FileCheck -match-full-lines %s -check-prefix=CHECK_COREI7_AVX_M32
 // CHECK_COREI7_AVX_M32: #define __AVX__ 1
 // CHECK_COREI7_AVX_M32: #define __MMX__ 1
 // CHECK_COREI7_AVX_M32: #define __PCLMUL__ 1
@@ -460,6 +487,9 @@
 // RUN: %clang -march=corei7-avx -m64 -E -dM %s -o - 2>&1 \
 // RUN: -target i386-unknown-linux \
 // RUN:   | FileCheck -match-full-lines %s -check-prefix=CHECK_COREI7_AVX_M64
+// RUN: %clang -march=sandybridge -m64 -E -dM %s -o - 2>&1 \
+// RUN: -target i386-unknown-linux \
+// RUN:   | FileCheck -match-full-lines %s -check-prefix=CHECK_COREI7_AVX_M64
 // CHECK_COREI7_AVX_M64: #define __AVX__ 1
 // CHECK_COREI7_AVX_M64: #define __MMX__ 1
 // CHECK_COREI7_AVX_M64: #define __PCLMUL__ 1
@@ -486,6 +516,9 @@
 // RUN: %clang -march=core-avx-i -m32 -E -dM %s -o - 2>&1 \
 // RUN: -target i386-unknown-linux \
 // RUN:   | FileCheck -match-full-lines %s -check-prefix=CHECK_CORE_AVX_I_M32
+// RUN: %clang -march=ivybridge -m32 -E -dM %s -o - 2>&1 \
+// RUN: -target i386-unknown-linux \
+// RUN:   

[clang] 548e08c - [NFC] Add missing cpu tests in predefined-arch-macros.c

2023-06-28 Thread Freddy Ye via cfe-commits

Author: Freddy Ye
Date: 2023-06-29T13:30:13+08:00
New Revision: 548e08c3f635f72519d3bcadcc71cca7d31d1e6d

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

LOG: [NFC] Add missing cpu tests in predefined-arch-macros.c

Added tests for penryn, nehalem, westmere, sandybridge, ivybridge,
haswell, bonnell, silvermont.

Reviewed By: skan

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

Added: 


Modified: 
clang/test/Preprocessor/predefined-arch-macros.c

Removed: 




diff  --git a/clang/test/Preprocessor/predefined-arch-macros.c 
b/clang/test/Preprocessor/predefined-arch-macros.c
index fd84ea174856a..03d60c528e8e5 100644
--- a/clang/test/Preprocessor/predefined-arch-macros.c
+++ b/clang/test/Preprocessor/predefined-arch-macros.c
@@ -365,9 +365,13 @@
 // RUN: %clang -march=core2 -m32 -E -dM %s -o - 2>&1 \
 // RUN: -target i386-unknown-linux \
 // RUN:   | FileCheck -match-full-lines %s -check-prefix=CHECK_CORE2_M32
+// RUN: %clang -march=penryn -m32 -E -dM %s -o - 2>&1 \
+// RUN: -target i386-unknown-linux \
+// RUN:   | FileCheck -match-full-lines %s 
-check-prefixes=CHECK_CORE2_M32,CHECK_PENRYN_M32
 // CHECK_CORE2_M32: #define __MMX__ 1
 // CHECK_CORE2_M32: #define __SSE2__ 1
 // CHECK_CORE2_M32: #define __SSE3__ 1
+// CHECK_PENRYN_M32: #define __SSE4_1__ 1
 // CHECK_CORE2_M32: #define __SSE__ 1
 // CHECK_CORE2_M32: #define __SSSE3__ 1
 // CHECK_CORE2_M32: #define __core2 1
@@ -380,10 +384,14 @@
 // RUN: %clang -march=core2 -m64 -E -dM %s -o - 2>&1 \
 // RUN: -target i386-unknown-linux \
 // RUN:   | FileCheck -match-full-lines %s -check-prefix=CHECK_CORE2_M64
+// RUN: %clang -march=penryn -m64 -E -dM %s -o - 2>&1 \
+// RUN: -target i386-unknown-linux \
+// RUN:   | FileCheck -match-full-lines %s 
-check-prefixes=CHECK_CORE2_M64,CHECK_PENRYN_M64
 // CHECK_CORE2_M64: #define __MMX__ 1
 // CHECK_CORE2_M64: #define __SSE2_MATH__ 1
 // CHECK_CORE2_M64: #define __SSE2__ 1
 // CHECK_CORE2_M64: #define __SSE3__ 1
+// CHECK_PENRYN_M64: #define __SSE4_1__ 1
 // CHECK_CORE2_M64: #define __SSE_MATH__ 1
 // CHECK_CORE2_M64: #define __SSE__ 1
 // CHECK_CORE2_M64: #define __SSSE3__ 1
@@ -398,7 +406,15 @@
 // RUN: %clang -march=corei7 -m32 -E -dM %s -o - 2>&1 \
 // RUN: -target i386-unknown-linux \
 // RUN:   | FileCheck -match-full-lines %s -check-prefix=CHECK_COREI7_M32
+// RUN: %clang -march=nehalem -m32 -E -dM %s -o - 2>&1 \
+// RUN: -target i386-unknown-linux \
+// RUN:   | FileCheck -match-full-lines %s -check-prefix=CHECK_COREI7_M32
+// RUN: %clang -march=westmere -m32 -E -dM %s -o - 2>&1 \
+// RUN: -target i386-unknown-linux \
+// RUN:   | FileCheck -match-full-lines %s 
-check-prefixes=CHECK_COREI7_M32,CHECK_WESTMERE_M32
+// CHECK_COREI7_M32: #define __CRC32__ 1
 // CHECK_COREI7_M32: #define __MMX__ 1
+// CHECK_WESTMERE_M32: #define __PCLMUL__ 1
 // CHECK_COREI7_M32: #define __POPCNT__ 1
 // CHECK_COREI7_M32: #define __SSE2__ 1
 // CHECK_COREI7_M32: #define __SSE3__ 1
@@ -416,7 +432,15 @@
 // RUN: %clang -march=corei7 -m64 -E -dM %s -o - 2>&1 \
 // RUN: -target i386-unknown-linux \
 // RUN:   | FileCheck -match-full-lines %s -check-prefix=CHECK_COREI7_M64
+// RUN: %clang -march=nehalem -m64 -E -dM %s -o - 2>&1 \
+// RUN: -target i386-unknown-linux \
+// RUN:   | FileCheck -match-full-lines %s -check-prefix=CHECK_COREI7_M64
+// RUN: %clang -march=westmere -m64 -E -dM %s -o - 2>&1 \
+// RUN: -target i386-unknown-linux \
+// RUN:   | FileCheck -match-full-lines %s 
-check-prefixes=CHECK_COREI7_M64,CHECK_WESTMERE_M64
+// CHECK_COREI7_M64: #define __CRC32__ 1
 // CHECK_COREI7_M64: #define __MMX__ 1
+// CHECK_WESTMERE_M64: #define __PCLMUL__ 1
 // CHECK_COREI7_M64: #define __POPCNT__ 1
 // CHECK_COREI7_M64: #define __SSE2_MATH__ 1
 // CHECK_COREI7_M64: #define __SSE2__ 1
@@ -437,6 +461,9 @@
 // RUN: %clang -march=corei7-avx -m32 -E -dM %s -o - 2>&1 \
 // RUN: -target i386-unknown-linux \
 // RUN:   | FileCheck -match-full-lines %s -check-prefix=CHECK_COREI7_AVX_M32
+// RUN: %clang -march=sandybridge -m32 -E -dM %s -o - 2>&1 \
+// RUN: -target i386-unknown-linux \
+// RUN:   | FileCheck -match-full-lines %s -check-prefix=CHECK_COREI7_AVX_M32
 // CHECK_COREI7_AVX_M32: #define __AVX__ 1
 // CHECK_COREI7_AVX_M32: #define __MMX__ 1
 // CHECK_COREI7_AVX_M32: #define __PCLMUL__ 1
@@ -460,6 +487,9 @@
 // RUN: %clang -march=corei7-avx -m64 -E -dM %s -o - 2>&1 \
 // RUN: -target i386-unknown-linux \
 // RUN:   | FileCheck -match-full-lines %s -check-prefix=CHECK_COREI7_AVX_M64
+// RUN: %clang -march=sandybridge -m64 -E -dM %s -o - 2>&1 \
+// RUN: -target i386-unknown-linux \
+// RUN:   | FileCheck -match-full-lines %s -check-prefix=CHECK_COREI7_AVX_M64
 // CHECK_COREI7_AVX_M64: #define __AVX__ 1
 // CHECK_COREI7_AVX_M64: #define __MMX__ 1

[PATCH] D153689: [clang][Interp] Handle CXXConstructExprs

2023-06-28 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder added a comment.

I think this makes https://reviews.llvm.org/D153653 unnecessary(?)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153689

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


[PATCH] D153653: [clang][Interp] Make CXXTemporaryObjectExprs leave a value behind

2023-06-28 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder added inline comments.



Comment at: clang/lib/AST/Interp/ByteCodeExprGen.cpp:1022
+
+if (DiscardResult)
+  return this->emitPopPtr(E);

shafik wrote:
> Could you just pass `DiscardResult` to `visitLocalInitializer`
Nope, the `visitInitializer` function(s) don't handle `DiscardResult` at all 
right now; they just initialize an already existing value.


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

https://reviews.llvm.org/D153653

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


[PATCH] D151567: [LLVM][Support] Report EISDIR when opening a directory on AIX

2023-06-28 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added a comment.

In D151567#4458232 , 
@hubert.reinterpretcast wrote:

> @azhan92, please incorporate a revert of 
> https://reviews.llvm.org/rG64ca650cf9f180cc0b68c0005639028084066e10. Since it 
> is an `XFAIL`. once the problem is fixed, the test will end up being an 
> "unexpected success" unless we remove the `XFAIL`.

@azhan92, I believe that the fix needs to be done at a lower level. Currently, 
we are addressing one case (in `expandResponseFiles`). That does not address 
other cases where the ability to open directories for reading on AIX causes 
unexpected behaviour for LLVM.

We should go deeper to see where the `EISDIR` error originates (likely "below" 
the `expandResponseFile` call) on other platforms.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151567

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


[PATCH] D151567: [LLVM][Support] Report EISDIR when opening a directory on AIX

2023-06-28 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added a comment.

@azhan92, rG6ace52e5e49cff6664fc301fa4985fc28c88f26f 
 and 
rGc14df228ff3ca73e3c5c00c495216bba56665fd5 
 should 
also be reverted. Same reason: `XFAIL`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151567

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


[PATCH] D151567: [LLVM][Support] Report EISDIR when opening a directory on AIX

2023-06-28 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added a comment.

@azhan92, please incorporate a revert of 
https://reviews.llvm.org/rG64ca650cf9f180cc0b68c0005639028084066e10. Since it 
is an `XFAIL`. once the problem is fixed, the test will end up being an 
"unexpected success" unless we remove the `XFAIL`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151567

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


[PATCH] D153854: [clang][dataflow] Make `getThisPointeeStorageLocation()` return an `AggregateStorageLocation`.

2023-06-28 Thread Martin Böhme 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 rG74d8455ba6a1: [clang][dataflow] Make 
`getThisPointeeStorageLocation()` return an… (authored by mboehme).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153854

Files:
  clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
  clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
  clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
  clang/unittests/Analysis/FlowSensitive/TransferTest.cpp

Index: clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
===
--- clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
@@ -1517,8 +1517,7 @@
 ASSERT_THAT(Results.keys(), UnorderedElementsAre("p"));
 const Environment  = getEnvironmentAtAnnotation(Results, "p");
 
-const auto *ThisLoc = dyn_cast(
-Env.getThisPointeeStorageLocation());
+const auto *ThisLoc = Env.getThisPointeeStorageLocation();
 ASSERT_THAT(ThisLoc, NotNull());
 
 const ValueDecl *BarDecl = findValueDecl(ASTCtx, "Bar");
@@ -1593,8 +1592,7 @@
 ASSERT_THAT(Results.keys(), UnorderedElementsAre("p"));
 const Environment  = getEnvironmentAtAnnotation(Results, "p");
 
-const auto *ThisLoc =
-cast(Env.getThisPointeeStorageLocation());
+const auto *ThisLoc = Env.getThisPointeeStorageLocation();
 
 const ValueDecl *BarDecl = findValueDecl(ASTCtx, "Bar");
 ASSERT_THAT(BarDecl, NotNull());
@@ -1664,8 +1662,7 @@
 ASSERT_THAT(Results.keys(), UnorderedElementsAre("p"));
 const Environment  = getEnvironmentAtAnnotation(Results, "p");
 
-const auto *ThisLoc = dyn_cast(
-Env.getThisPointeeStorageLocation());
+const auto *ThisLoc = Env.getThisPointeeStorageLocation();
 ASSERT_THAT(ThisLoc, NotNull());
 
 const ValueDecl *FooDecl = findValueDecl(ASTCtx, "Foo");
@@ -1710,8 +1707,7 @@
 ASSERT_THAT(Results.keys(), UnorderedElementsAre("p1"));
 const Environment  = getEnvironmentAtAnnotation(Results, "p1");
 
-const auto *ThisLoc = dyn_cast(
-Env.getThisPointeeStorageLocation());
+const auto *ThisLoc = Env.getThisPointeeStorageLocation();
 ASSERT_THAT(ThisLoc, NotNull());
 
 const ValueDecl *BarDecl = findValueDecl(ASTCtx, "Bar");
@@ -1749,8 +1745,7 @@
 ASSERT_THAT(Results.keys(), UnorderedElementsAre("p2"));
 const Environment  = getEnvironmentAtAnnotation(Results, "p2");
 
-const auto *ThisLoc = dyn_cast(
-Env.getThisPointeeStorageLocation());
+const auto *ThisLoc = Env.getThisPointeeStorageLocation();
 ASSERT_THAT(ThisLoc, NotNull());
 
 const ValueDecl *BarDecl = findValueDecl(ASTCtx, "Bar");
@@ -1808,8 +1803,7 @@
 ASSERT_THAT(Results.keys(), UnorderedElementsAre("p"));
 const Environment  = getEnvironmentAtAnnotation(Results, "p");
 
-const auto *ThisLoc = dyn_cast(
-Env.getThisPointeeStorageLocation());
+const auto *ThisLoc = Env.getThisPointeeStorageLocation();
 ASSERT_THAT(ThisLoc, NotNull());
 
 const ValueDecl *FooDecl = findValueDecl(ASTCtx, "Foo");
@@ -1842,8 +1836,7 @@
 ASSERT_THAT(Results.keys(), UnorderedElementsAre("p"));
 const Environment  = getEnvironmentAtAnnotation(Results, "p");
 
-const auto *ThisLoc = dyn_cast(
-Env.getThisPointeeStorageLocation());
+const auto *ThisLoc = Env.getThisPointeeStorageLocation();
 ASSERT_THAT(ThisLoc, NotNull());
 
 const ValueDecl *FooDecl = findValueDecl(ASTCtx, "Foo");
@@ -1876,8 +1869,7 @@
 ASSERT_THAT(Results.keys(), UnorderedElementsAre("p"));
 const Environment  = getEnvironmentAtAnnotation(Results, "p");
 
-const auto *ThisLoc = dyn_cast(
-Env.getThisPointeeStorageLocation());
+const auto *ThisLoc = Env.getThisPointeeStorageLocation();
 ASSERT_THAT(ThisLoc, NotNull());
 
 const ValueDecl *FooDecl = findValueDecl(ASTCtx, "Foo");
Index: clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
===
--- clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
+++ clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
@@ -366,8 +366,7 @@
   assert(Init != nullptr);
 
   auto  = InputState.Env;
-  auto  =
-  *cast(Env.getThisPointeeStorageLocation());
+  auto  = *Env.getThisPointeeStorageLocation();
 
   if (!Init->isAnyMemberInitializer())
 // FIXME: Handle base initialization
Index: clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp

[PATCH] D153852: [clang][dataflow] Initialize fields of anonymous records correctly.

2023-06-28 Thread Martin Böhme via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
mboehme marked an inline comment as done.
Closed by commit rGd36324866ee1: [clang][dataflow] Initialize fields of 
anonymous records correctly. (authored by mboehme).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153852

Files:
  clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
  clang/lib/Analysis/FlowSensitive/Transfer.cpp
  clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
  clang/unittests/Analysis/FlowSensitive/TransferTest.cpp

Index: clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
===
--- clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
@@ -5483,4 +5483,35 @@
   });
 }
 
+TEST(TransferTest, AnonymousStructWithInitializer) {
+  std::string Code = R"(
+struct target {
+  target() {
+(void)0;
+// [[p]]
+  }
+  struct {
+bool b = true;
+  };
+};
+  )";
+  runDataflow(
+  Code,
+  [](const llvm::StringMap> ,
+ ASTContext ) {
+const Environment  = getEnvironmentAtAnnotation(Results, "p");
+const ValueDecl *BDecl = findValueDecl(ASTCtx, "b");
+const IndirectFieldDecl *IndirectField =
+findIndirectFieldDecl(ASTCtx, "b");
+
+auto *ThisLoc =
+cast(Env.getThisPointeeStorageLocation());
+auto  = cast(ThisLoc->getChild(
+*cast(IndirectField->chain().front(;
+
+auto *B = cast(Env.getValue(AnonStruct.getChild(*BDecl)));
+ASSERT_TRUE(Env.flowConditionImplies(*B));
+  });
+}
+
 } // namespace
Index: clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
===
--- clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
+++ clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
@@ -366,27 +366,41 @@
   assert(Init != nullptr);
 
   auto  = InputState.Env;
-  const auto  =
+  auto  =
   *cast(Env.getThisPointeeStorageLocation());
 
-  const FieldDecl *Member = Init->getMember();
-  if (Member == nullptr)
-// Not a field initializer.
+  if (!Init->isAnyMemberInitializer())
+// FIXME: Handle base initialization
 return;
 
   auto *InitStmt = Init->getInit();
   assert(InitStmt != nullptr);
 
+  const FieldDecl *Member = nullptr;
+  StorageLocation *MemberLoc = nullptr;
+  if (Init->isMemberInitializer()) {
+Member = Init->getMember();
+MemberLoc = (*Member);
+  } else {
+IndirectFieldDecl *IndirectField = Init->getIndirectMember();
+assert(IndirectField != nullptr);
+MemberLoc = 
+for (const auto *I : IndirectField->chain()) {
+  Member = cast(I);
+  MemberLoc = (MemberLoc)->getChild(*Member);
+}
+  }
+  assert(Member != nullptr);
+  assert(MemberLoc != nullptr);
+
   if (Member->getType()->isReferenceType()) {
 auto *InitStmtLoc = Env.getStorageLocationStrict(*InitStmt);
 if (InitStmtLoc == nullptr)
   return;
 
-auto  = ThisLoc.getChild(*Member);
-Env.setValue(MemberLoc, Env.create(*InitStmtLoc));
+Env.setValue(*MemberLoc, Env.create(*InitStmtLoc));
   } else if (auto *InitStmtVal = Env.getValueStrict(*InitStmt)) {
-auto  = ThisLoc.getChild(*Member);
-Env.setValue(MemberLoc, *InitStmtVal);
+Env.setValue(*MemberLoc, *InitStmtVal);
   }
 }
 
Index: clang/lib/Analysis/FlowSensitive/Transfer.cpp
===
--- clang/lib/Analysis/FlowSensitive/Transfer.cpp
+++ clang/lib/Analysis/FlowSensitive/Transfer.cpp
@@ -153,7 +153,7 @@
 Env.setStorageLocationStrict(To, *Loc);
 }
 
-// Forwards the value or storage location of `From` to `To` in cases where
+// Propagates the value or storage location of `From` to `To` in cases where
 // `From` may be either a glvalue or a prvalue. `To` must be a glvalue iff
 // `From` is a glvalue.
 static void propagateValueOrStorageLocation(const Expr , const Expr ,
@@ -572,18 +572,7 @@
   void VisitCXXDefaultInitExpr(const CXXDefaultInitExpr *S) {
 const Expr *InitExpr = S->getExpr();
 assert(InitExpr != nullptr);
-
-Value *InitExprVal = Env.getValue(*InitExpr, SkipPast::None);
-if (InitExprVal == nullptr)
-  return;
-
-const FieldDecl *Field = S->getField();
-assert(Field != nullptr);
-
-auto  =
-*cast(Env.getThisPointeeStorageLocation());
-auto  = ThisLoc.getChild(*Field);
-Env.setValue(FieldLoc, *InitExprVal);
+propagateValueOrStorageLocation(*InitExpr, *S, Env);
   }
 
   void VisitCXXConstructExpr(const CXXConstructExpr *S) {
Index: clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
===
--- 

[clang] d363248 - [clang][dataflow] Initialize fields of anonymous records correctly.

2023-06-28 Thread Martin Braenne via cfe-commits

Author: Martin Braenne
Date: 2023-06-29T04:07:04Z
New Revision: d36324866ee1fb4d1c26552b6b686a463d2b448f

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

LOG: [clang][dataflow] Initialize fields of anonymous records correctly.

Previously, the newly added test would crash.

Depends On D153851

Reviewed By: gribozavr2

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

Added: 


Modified: 
clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
clang/lib/Analysis/FlowSensitive/Transfer.cpp
clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
clang/unittests/Analysis/FlowSensitive/TransferTest.cpp

Removed: 




diff  --git a/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp 
b/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
index 44801a41c10fa..f4867c4becea0 100644
--- a/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
+++ b/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
@@ -227,8 +227,12 @@ void Environment::initFieldsGlobalsAndFuncs(const 
FunctionDecl *FuncDecl) {
   // constructor-initializers.
   if (const auto *CtorDecl = dyn_cast(FuncDecl)) {
 for (const auto *Init : CtorDecl->inits()) {
-  if (const auto *M = Init->getAnyMember())
-  Fields.insert(M);
+  if (Init->isMemberInitializer()) {
+Fields.insert(Init->getMember());
+  } else if (Init->isIndirectMemberInitializer()) {
+for (const auto *I : Init->getIndirectMember()->chain())
+  Fields.insert(cast(I));
+  }
   const Expr *E = Init->getInit();
   assert(E != nullptr);
   getFieldsGlobalsAndFuncs(*E, Fields, Vars, Funcs);

diff  --git a/clang/lib/Analysis/FlowSensitive/Transfer.cpp 
b/clang/lib/Analysis/FlowSensitive/Transfer.cpp
index 54b8b3a108dc0..651930f0dd22b 100644
--- a/clang/lib/Analysis/FlowSensitive/Transfer.cpp
+++ b/clang/lib/Analysis/FlowSensitive/Transfer.cpp
@@ -153,7 +153,7 @@ static void propagateStorageLocation(const Expr , 
const Expr ,
 Env.setStorageLocationStrict(To, *Loc);
 }
 
-// Forwards the value or storage location of `From` to `To` in cases where
+// Propagates the value or storage location of `From` to `To` in cases where
 // `From` may be either a glvalue or a prvalue. `To` must be a glvalue iff
 // `From` is a glvalue.
 static void propagateValueOrStorageLocation(const Expr , const Expr ,
@@ -572,18 +572,7 @@ class TransferVisitor : public 
ConstStmtVisitor {
   void VisitCXXDefaultInitExpr(const CXXDefaultInitExpr *S) {
 const Expr *InitExpr = S->getExpr();
 assert(InitExpr != nullptr);
-
-Value *InitExprVal = Env.getValue(*InitExpr, SkipPast::None);
-if (InitExprVal == nullptr)
-  return;
-
-const FieldDecl *Field = S->getField();
-assert(Field != nullptr);
-
-auto  =
-*cast(Env.getThisPointeeStorageLocation());
-auto  = ThisLoc.getChild(*Field);
-Env.setValue(FieldLoc, *InitExprVal);
+propagateValueOrStorageLocation(*InitExpr, *S, Env);
   }
 
   void VisitCXXConstructExpr(const CXXConstructExpr *S) {

diff  --git a/clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp 
b/clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
index 16f8ab9683d56..99f18a07ed65c 100644
--- a/clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
+++ b/clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
@@ -366,27 +366,41 @@ builtinTransferInitializer(const CFGInitializer ,
   assert(Init != nullptr);
 
   auto  = InputState.Env;
-  const auto  =
+  auto  =
   *cast(Env.getThisPointeeStorageLocation());
 
-  const FieldDecl *Member = Init->getMember();
-  if (Member == nullptr)
-// Not a field initializer.
+  if (!Init->isAnyMemberInitializer())
+// FIXME: Handle base initialization
 return;
 
   auto *InitStmt = Init->getInit();
   assert(InitStmt != nullptr);
 
+  const FieldDecl *Member = nullptr;
+  StorageLocation *MemberLoc = nullptr;
+  if (Init->isMemberInitializer()) {
+Member = Init->getMember();
+MemberLoc = (*Member);
+  } else {
+IndirectFieldDecl *IndirectField = Init->getIndirectMember();
+assert(IndirectField != nullptr);
+MemberLoc = 
+for (const auto *I : IndirectField->chain()) {
+  Member = cast(I);
+  MemberLoc = 
(MemberLoc)->getChild(*Member);
+}
+  }
+  assert(Member != nullptr);
+  assert(MemberLoc != nullptr);
+
   if (Member->getType()->isReferenceType()) {
 auto *InitStmtLoc = Env.getStorageLocationStrict(*InitStmt);
 if (InitStmtLoc == nullptr)
   return;
 
-auto  = ThisLoc.getChild(*Member);
-Env.setValue(MemberLoc, Env.create(*InitStmtLoc));
+Env.setValue(*MemberLoc, Env.create(*InitStmtLoc));
   } else if (auto *InitStmtVal = Env.getValueStrict(*InitStmt)) {
-auto  = 

[clang] 74d8455 - [clang][dataflow] Make `getThisPointeeStorageLocation()` return an `AggregateStorageLocation`.

2023-06-28 Thread Martin Braenne via cfe-commits

Author: Martin Braenne
Date: 2023-06-29T04:07:08Z
New Revision: 74d8455ba6a19d9eeaa561fd0eccc8cbf5351a47

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

LOG: [clang][dataflow] Make `getThisPointeeStorageLocation()` return an 
`AggregateStorageLocation`.

This avoids the need for casts at callsites.

Depends On D153852

Reviewed By: sammccall, xazax.hun, gribozavr2

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

Added: 


Modified: 
clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
clang/unittests/Analysis/FlowSensitive/TransferTest.cpp

Removed: 




diff  --git a/clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h 
b/clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
index 8da359880e3ce3..faeb5eb69cd838 100644
--- a/clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
+++ b/clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
@@ -330,7 +330,7 @@ class Environment {
   /// Returns the storage location assigned to the `this` pointee in the
   /// environment or null if the `this` pointee has no assigned storage 
location
   /// in the environment.
-  StorageLocation *getThisPointeeStorageLocation() const;
+  AggregateStorageLocation *getThisPointeeStorageLocation() const;
 
   /// Returns the return value of the current function. This can be null if:
   /// - The function has a void return type
@@ -600,7 +600,7 @@ class Environment {
   StorageLocation *ReturnLoc = nullptr;
   // The storage location of the `this` pointee. Should only be null if the
   // function being analyzed is only a function and not a method.
-  StorageLocation *ThisPointeeLoc = nullptr;
+  AggregateStorageLocation *ThisPointeeLoc = nullptr;
 
   // Maps from program declarations and statements to storage locations that 
are
   // assigned to them. Unlike the maps in `DataflowAnalysisContext`, these

diff  --git a/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp 
b/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
index f4867c4becea03..689f8abb51c8e0 100644
--- a/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
+++ b/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
@@ -309,7 +309,8 @@ Environment::Environment(DataflowAnalysisContext ,
 // FIXME: Initialize the ThisPointeeLoc of lambdas too.
 if (MethodDecl && !MethodDecl->isStatic()) {
   QualType ThisPointeeType = MethodDecl->getThisObjectType();
-  ThisPointeeLoc = (ThisPointeeType);
+  ThisPointeeLoc = (
+  createStorageLocation(ThisPointeeType));
   if (Value *ThisPointeeVal = createValue(ThisPointeeType))
 setValue(*ThisPointeeLoc, *ThisPointeeVal);
 }
@@ -327,7 +328,8 @@ Environment Environment::pushCall(const CallExpr *Call) 
const {
   if (const auto *MethodCall = dyn_cast(Call)) {
 if (const Expr *Arg = MethodCall->getImplicitObjectArgument()) {
   if (!isa(Arg))
-Env.ThisPointeeLoc = getStorageLocation(*Arg, SkipPast::Reference);
+Env.ThisPointeeLoc = cast(
+getStorageLocation(*Arg, SkipPast::Reference));
   // Otherwise (when the argument is `this`), retain the current
   // environment's `ThisPointeeLoc`.
 }
@@ -342,7 +344,8 @@ Environment Environment::pushCall(const CallExpr *Call) 
const {
 Environment Environment::pushCall(const CXXConstructExpr *Call) const {
   Environment Env(*this);
 
-  Env.ThisPointeeLoc = (Call->getType());
+  Env.ThisPointeeLoc = (
+  Env.createStorageLocation(Call->getType()));
   if (Value *Val = Env.createValue(Call->getType()))
 Env.setValue(*Env.ThisPointeeLoc, *Val);
 
@@ -685,7 +688,7 @@ StorageLocation 
*Environment::getStorageLocationStrict(const Expr ) const {
   return Loc;
 }
 
-StorageLocation *Environment::getThisPointeeStorageLocation() const {
+AggregateStorageLocation *Environment::getThisPointeeStorageLocation() const {
   return ThisPointeeLoc;
 }
 

diff  --git a/clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp 
b/clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
index 99f18a07ed65c4..d2908725d79b3d 100644
--- a/clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
+++ b/clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
@@ -366,8 +366,7 @@ builtinTransferInitializer(const CFGInitializer ,
   assert(Init != nullptr);
 
   auto  = InputState.Env;
-  auto  =
-  *cast(Env.getThisPointeeStorageLocation());
+  auto  = *Env.getThisPointeeStorageLocation();
 
   if (!Init->isAnyMemberInitializer())
 // FIXME: Handle base initialization

diff  --git a/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp 

[clang] a806ec4 - [analyzer] Refactor codes in findMethodDecl()

2023-06-28 Thread via cfe-commits

Author: Manna, Soumi
Date: 2023-06-28T20:40:02-07:00
New Revision: a806ec4857c2c662c89755edba56d893ae1beeb4

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

LOG: [analyzer] Refactor codes in findMethodDecl()

In findMethodDecl(clang::ObjCMessageExpr const *, clang::ObjCObjectPointerType 
const *, clang::ASTContext &), if the MessageExpr->getReceiverKind() is not 
Instance or Class, we never dereference pointer “ReceiverObjectPtrType”. Also, 
we don't dereference the pointer “ReceiverObjectPtrType” if ReceiverType is 
ObjCIdType or ObhjCClassType. So the pointer “ReceiverObjectPtrType”is only 
used in this branch and the declaration should be here.

This patch directly uses ReceiverType->castAs() instead 
of ReceiverObjectPtrType when calling canAssignObjCInterfaces() to express the 
intent more clearly.

Reviewed By: erichkeane, steakhal

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

Added: 


Modified: 
clang/lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp

Removed: 




diff  --git a/clang/lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp 
b/clang/lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp
index 6f26842e62c78..26f82fb67472b 100644
--- a/clang/lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp
@@ -742,8 +742,6 @@ findMethodDecl(const ObjCMessageExpr *MessageExpr,
   const ObjCMethodDecl *Method = nullptr;
 
   QualType ReceiverType = MessageExpr->getReceiverType();
-  const auto *ReceiverObjectPtrType =
-  ReceiverType->getAs();
 
   // Do this "devirtualization" on instance and class methods only. Trust the
   // static type on super and super class calls.
@@ -753,7 +751,8 @@ findMethodDecl(const ObjCMessageExpr *MessageExpr,
 // type, look up the method in the tracked type, not in the receiver type.
 // This way we preserve more information.
 if (ReceiverType->isObjCIdType() || ReceiverType->isObjCClassType() ||
-ASTCtxt.canAssignObjCInterfaces(ReceiverObjectPtrType, TrackedType)) {
+ASTCtxt.canAssignObjCInterfaces(
+ReceiverType->castAs(), TrackedType)) {
   const ObjCInterfaceDecl *InterfaceDecl = TrackedType->getInterfaceDecl();
   // The method might not be found.
   Selector Sel = MessageExpr->getSelector();



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


[PATCH] D152194: [StaticAnalyzer] Fix nullptr dereference issue found by static analyzer tool

2023-06-28 Thread Soumi Manna via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa806ec4857c2: [analyzer] Refactor codes in findMethodDecl() 
(authored by Manna).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152194

Files:
  clang/lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp


Index: clang/lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp
+++ clang/lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp
@@ -742,8 +742,6 @@
   const ObjCMethodDecl *Method = nullptr;
 
   QualType ReceiverType = MessageExpr->getReceiverType();
-  const auto *ReceiverObjectPtrType =
-  ReceiverType->getAs();
 
   // Do this "devirtualization" on instance and class methods only. Trust the
   // static type on super and super class calls.
@@ -753,7 +751,8 @@
 // type, look up the method in the tracked type, not in the receiver type.
 // This way we preserve more information.
 if (ReceiverType->isObjCIdType() || ReceiverType->isObjCClassType() ||
-ASTCtxt.canAssignObjCInterfaces(ReceiverObjectPtrType, TrackedType)) {
+ASTCtxt.canAssignObjCInterfaces(
+ReceiverType->castAs(), TrackedType)) {
   const ObjCInterfaceDecl *InterfaceDecl = TrackedType->getInterfaceDecl();
   // The method might not be found.
   Selector Sel = MessageExpr->getSelector();


Index: clang/lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp
+++ clang/lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp
@@ -742,8 +742,6 @@
   const ObjCMethodDecl *Method = nullptr;
 
   QualType ReceiverType = MessageExpr->getReceiverType();
-  const auto *ReceiverObjectPtrType =
-  ReceiverType->getAs();
 
   // Do this "devirtualization" on instance and class methods only. Trust the
   // static type on super and super class calls.
@@ -753,7 +751,8 @@
 // type, look up the method in the tracked type, not in the receiver type.
 // This way we preserve more information.
 if (ReceiverType->isObjCIdType() || ReceiverType->isObjCClassType() ||
-ASTCtxt.canAssignObjCInterfaces(ReceiverObjectPtrType, TrackedType)) {
+ASTCtxt.canAssignObjCInterfaces(
+ReceiverType->castAs(), TrackedType)) {
   const ObjCInterfaceDecl *InterfaceDecl = TrackedType->getInterfaceDecl();
   // The method might not be found.
   Selector Sel = MessageExpr->getSelector();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D140727: [XRay] Add initial support for loongarch64

2023-06-28 Thread Lu Weining via Phabricator via cfe-commits
SixWeining added a comment.

In D140727#4019019 , @SixWeining 
wrote:

> D140725  is abandoned. Let me defer this 
> change until we support 64bit PC-relative relocation for `SymA - SymB`.

Update: R_LARCH_64_PCREL can be emitted after D153872 
. And I'd like to ask @Ami-zhang to update 
this patch later.




Comment at: llvm/test/CodeGen/LoongArch/xray-attribute-instrumentation.ll:11
+; CHECK-NEXT:  b .Lxray_sled_end0
+; CHECK-NEXT:  nop
+; CHECK-NEXT:  nop

CHECK-COUNT-11


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140727

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


[PATCH] D153556: [OPENMP52] Initial support for doacross clause.

2023-06-28 Thread Jennifer Yu via Phabricator via cfe-commits
jyu2 added a comment.

Thanks.




Comment at: clang/lib/Parse/ParseOpenMP.cpp:4415-4439
+  } else if (Kind == OMPC_doacross) {
+// Handle dependence type for the doacross clause.
+ColonProtectionRAIIObject ColonRAII(*this);
+Data.ExtraModifier = getOpenMPSimpleClauseType(
+Kind, Tok.is(tok::identifier) ? PP.getSpelling(Tok) : "",
+getLangOpts());
+Data.ExtraModifierLoc = Tok.getLocation();

ABataev wrote:
> jyu2 wrote:
> > ABataev wrote:
> > > Can it be unified with depenbd clause parsing? (Maybe in a separate 
> > > template function)
> > I don't really has an idea on how to combine this two with template 
> > function.  Since depend clause in ordered is deprecated in 52, and will be 
> > removed, should we leave as this?
> Even ff it will be removed in 52, it will still stay for OpenMP < 52. Would 
> be good to try to unify it.
OKay thanks.  Changed



Comment at: clang/lib/Sema/SemaOpenMP.cpp:20694-20700
+auto *C = OMPDoacrossClause::Create(
+Context, StartLoc, LParenLoc, EndLoc,
+IsSource ? OMPC_DOACROSS_source : OMPC_DOACROSS_sink, DepLoc, ColonLoc,
+Vars, TotalDepCount.getZExtValue());
+if (DSAStack->isParentOrderedRegion())
+  DSAStack->addDoacrossDependClause(C, OpsOffs);
+return C;

ABataev wrote:
> Better to create clauses in ActOnDoAcross and ActOnDepend, this function 
> better to return required data as a struct/class/bolean, etc.
Okay I create static function instead.  Thanks.



Comment at: clang/lib/Sema/SemaOpenMP.cpp:11299-11344
   if (DC->getDependencyKind() == OMPC_DEPEND_source) {
 if (DependSourceClause) {
   Diag(C->getBeginLoc(), diag::err_omp_more_one_clause)
   << getOpenMPDirectiveName(OMPD_ordered)
   << getOpenMPClauseName(OMPC_depend) << 2;
   ErrorFound = true;
 } else {

jyu2 wrote:
> ABataev wrote:
> > Try to avoid copy-paste. Maybe introduce templated function?
> Not sure how to do this part.
I just merged code into OMPC_depend.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153556

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


[PATCH] D153556: [OPENMP52] Initial support for doacross clause.

2023-06-28 Thread Jennifer Yu via Phabricator via cfe-commits
jyu2 updated this revision to Diff 535601.
jyu2 added a comment.

Thanks Alexey's review.  This is address his comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153556

Files:
  clang/include/clang/AST/OpenMPClause.h
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/OpenMPKinds.def
  clang/include/clang/Basic/OpenMPKinds.h
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/OpenMPClause.cpp
  clang/lib/AST/StmtProfile.cpp
  clang/lib/Basic/OpenMPKinds.cpp
  clang/lib/Parse/ParseOpenMP.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/OpenMP/ordered_ast_print.cpp
  clang/test/OpenMP/ordered_messages.cpp
  clang/tools/libclang/CIndex.cpp
  flang/lib/Semantics/check-omp-structure.cpp
  llvm/include/llvm/Frontend/OpenMP/OMP.td

Index: llvm/include/llvm/Frontend/OpenMP/OMP.td
===
--- llvm/include/llvm/Frontend/OpenMP/OMP.td
+++ llvm/include/llvm/Frontend/OpenMP/OMP.td
@@ -444,6 +444,10 @@
   let flangClass = "ScalarIntExpr";
 }
 
+def OMPC_Doacross : Clause<"doacross"> {
+  let clangClass = "OMPDoacrossClause";
+}
+
 //===--===//
 // Definition of OpenMP directives
 //===--===//
@@ -604,7 +608,8 @@
 }
 def OMP_Ordered : Directive<"ordered"> {
   let allowedClauses = [
-VersionedClause
+VersionedClause,
+VersionedClause
   ];
   let allowedOnceClauses = [
 VersionedClause,
Index: flang/lib/Semantics/check-omp-structure.cpp
===
--- flang/lib/Semantics/check-omp-structure.cpp
+++ flang/lib/Semantics/check-omp-structure.cpp
@@ -1937,6 +1937,7 @@
 CHECK_SIMPLE_CLAUSE(Align, OMPC_align)
 CHECK_SIMPLE_CLAUSE(Compare, OMPC_compare)
 CHECK_SIMPLE_CLAUSE(CancellationConstructType, OMPC_cancellation_construct_type)
+CHECK_SIMPLE_CLAUSE(Doacross, OMPC_doacross)
 
 CHECK_REQ_SCALAR_INT_CLAUSE(Grainsize, OMPC_grainsize)
 CHECK_REQ_SCALAR_INT_CLAUSE(NumTasks, OMPC_num_tasks)
Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -2717,6 +2717,9 @@
   VisitOMPClauseWithPreInit(C);
   Visitor->AddStmt(C->getSize());
 }
+void OMPClauseEnqueue::VisitOMPDoacrossClause(const OMPDoacrossClause *C) {
+  VisitOMPClauseList(C);
+}
 
 } // namespace
 
Index: clang/test/OpenMP/ordered_messages.cpp
===
--- clang/test/OpenMP/ordered_messages.cpp
+++ clang/test/OpenMP/ordered_messages.cpp
@@ -1,6 +1,7 @@
 // RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 -o - %s -Wuninitialized
 // RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 -std=c++98 -o - %s -Wuninitialized
 // RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 -std=c++11 -o - %s -Wuninitialized
+// RUN: %clang_cc1 -verify=expected,omp52 -fopenmp -fopenmp-version=52 -ferror-limit 100 -o - %s -Wuninitialized
 
 // RUN: %clang_cc1 -verify -fopenmp-simd -ferror-limit 100 -o - %s -Wuninitialized
 // RUN: %clang_cc1 -verify -fopenmp-simd -ferror-limit 100 -std=c++98 -o - %s -Wuninitialized
@@ -135,12 +136,48 @@
   }
 #pragma omp parallel for ordered
   for (int i = 0; i < 10; ++i) {
+#if _OPENMP >= 202111
+#pragma omp ordered doacross(source:) // omp52-error {{'ordered' directive with 'doacross' clause cannot be closely nested inside ordered region without specified parameter}}
+#pragma omp ordered doacross(sink : i) // omp52-error {{'ordered' directive with 'doacross' clause cannot be closely nested inside ordered region without specified parameter}}
+#else
 #pragma omp ordered depend(source) // expected-error {{'ordered' directive with 'depend' clause cannot be closely nested inside ordered region without specified parameter}}
 #pragma omp ordered depend(sink : i) // expected-error {{'ordered' directive with 'depend' clause cannot be closely nested inside ordered region without specified parameter}}
+#endif
   }
 #pragma omp parallel for ordered(2) // expected-note 3 {{'ordered' clause with specified parameter}}
   for (int i = 0; i < 10; ++i) {
 for (int j = 0; j < 10; ++j) {
+#if _OPENMP >= 202111
+#pragma omp ordered doacross // omp52-error {{expected '(' after 'doacross'}} omp52-error {{'ordered' directive without any clauses cannot be closely nested inside ordered region with specified parameter}}
+#pragma omp ordered doacross( // omp52-error {{expected ')'}} omp52-error {{expected 'source' or 'sink' in OpenMP clause 'doacross'}} omp52-error {{'ordered' directive without any clauses cannot be closely nested inside 

[PATCH] D153836: [RISCV] Bump vector crypto to v1.0.0-rc1

2023-06-28 Thread Brandon Wu 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 rG02f94a655fb6: [RISCV] Bump vector crypto to v1.0.0-rc1 
(authored by 4vtomat).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153836

Files:
  clang/test/Preprocessor/riscv-target-features.c
  llvm/docs/RISCVUsage.rst
  llvm/lib/Support/RISCVISAInfo.cpp
  llvm/lib/Target/RISCV/RISCVInstrInfoZvk.td
  llvm/test/CodeGen/RISCV/attributes.ll
  llvm/test/MC/RISCV/attribute-arch.s

Index: llvm/test/MC/RISCV/attribute-arch.s
===
--- llvm/test/MC/RISCV/attribute-arch.s
+++ llvm/test/MC/RISCV/attribute-arch.s
@@ -111,50 +111,50 @@
 .attribute arch, "rv32izbc1p0"
 # CHECK: attribute  5, "rv32i2p1_zbc1p0"
 
-.attribute arch, "rv32i_zve64x_zvbb0p9"
-# CHECK: attribute  5, "rv32i2p1_zicsr2p0_zvbb0p9_zve32x1p0_zve64x1p0_zvl32b1p0_zvl64b1p0"
+.attribute arch, "rv32i_zve64x_zvbb1p0"
+# CHECK: attribute  5, "rv32i2p1_zicsr2p0_zvbb1p0_zve32x1p0_zve64x1p0_zvl32b1p0_zvl64b1p0"
 
-.attribute arch, "rv32i_zve64x_zvbc0p9"
-# CHECK: attribute  5, "rv32i2p1_zicsr2p0_zvbc0p9_zve32x1p0_zve64x1p0_zvl32b1p0_zvl64b1p0"
+.attribute arch, "rv32i_zve64x_zvbc1p0"
+# CHECK: attribute  5, "rv32i2p1_zicsr2p0_zvbc1p0_zve32x1p0_zve64x1p0_zvl32b1p0_zvl64b1p0"
 
-.attribute arch, "rv32i_zve32x_zvkg0p9"
-# CHECK: attribute  5, "rv32i2p1_zicsr2p0_zve32x1p0_zvkg0p9_zvl32b1p0"
+.attribute arch, "rv32i_zve32x_zvkg1p0"
+# CHECK: attribute  5, "rv32i2p1_zicsr2p0_zve32x1p0_zvkg1p0_zvl32b1p0"
 
-.attribute arch, "rv32i_zve64x_zvkn0p9"
-# CHECK: attribute  5, "rv32i2p1_zicsr2p0_zvbb0p9_zve32x1p0_zve64x1p0_zvkn0p9_zvkned0p9_zvknha0p9_zvknhb0p9_zvkt0p9_zvl32b1p0_zvl64b1p0"
+.attribute arch, "rv32i_zve64x_zvkn1p0"
+# CHECK: attribute  5, "rv32i2p1_zicsr2p0_zvbb1p0_zve32x1p0_zve64x1p0_zvkn1p0_zvkned1p0_zvknha1p0_zvknhb1p0_zvkt1p0_zvl32b1p0_zvl64b1p0"
 
-.attribute arch, "rv32i_zve64x_zvknc0p9"
-# CHECK: attribute  5, "rv32i2p1_zicsr2p0_zvbb0p9_zvbc0p9_zve32x1p0_zve64x1p0_zvkn0p9_zvknc0p9_zvkned0p9_zvknha0p9_zvknhb0p9_zvkt0p9_zvl32b1p0_zvl64b1p0"
+.attribute arch, "rv32i_zve64x_zvknc1p0"
+# CHECK: attribute  5, "rv32i2p1_zicsr2p0_zvbb1p0_zvbc1p0_zve32x1p0_zve64x1p0_zvkn1p0_zvknc1p0_zvkned1p0_zvknha1p0_zvknhb1p0_zvkt1p0_zvl32b1p0_zvl64b1p0"
 
-.attribute arch, "rv32i_zve64x_zvkng0p9"
-# CHECK: attribute  5, "rv32i2p1_zicsr2p0_zvbb0p9_zve32x1p0_zve64x1p0_zvkg0p9_zvkn0p9_zvkned0p9_zvkng0p9_zvknha0p9_zvknhb0p9_zvkt0p9_zvl32b1p0_zvl64b1p0"
+.attribute arch, "rv32i_zve64x_zvkng1p0"
+# CHECK: attribute  5, "rv32i2p1_zicsr2p0_zvbb1p0_zve32x1p0_zve64x1p0_zvkg1p0_zvkn1p0_zvkned1p0_zvkng1p0_zvknha1p0_zvknhb1p0_zvkt1p0_zvl32b1p0_zvl64b1p0"
 
-.attribute arch, "rv32i_zve32x_zvknha0p9"
-# CHECK: attribute  5, "rv32i2p1_zicsr2p0_zve32x1p0_zvknha0p9_zvl32b1p0"
+.attribute arch, "rv32i_zve32x_zvknha1p0"
+# CHECK: attribute  5, "rv32i2p1_zicsr2p0_zve32x1p0_zvknha1p0_zvl32b1p0"
 
-.attribute arch, "rv32i_zve64x_zvknhb0p9"
-# CHECK: attribute  5, "rv32i2p1_zicsr2p0_zve32x1p0_zve64x1p0_zvknha0p9_zvknhb0p9_zvl32b1p0_zvl64b1p0"
+.attribute arch, "rv32i_zve64x_zvknhb1p0"
+# CHECK: attribute  5, "rv32i2p1_zicsr2p0_zve32x1p0_zve64x1p0_zvknha1p0_zvknhb1p0_zvl32b1p0_zvl64b1p0"
 
-.attribute arch, "rv32i_zve32x_zvkned0p9"
-# CHECK: attribute  5, "rv32i2p1_zicsr2p0_zve32x1p0_zvkned0p9_zvl32b1p0"
+.attribute arch, "rv32i_zve32x_zvkned1p0"
+# CHECK: attribute  5, "rv32i2p1_zicsr2p0_zve32x1p0_zvkned1p0_zvl32b1p0"
 
-.attribute arch, "rv32i_zve64x_zvks0p9"
-# CHECK: attribute  5, "rv32i2p1_zicsr2p0_zvbb0p9_zve32x1p0_zve64x1p0_zvks0p9_zvksed0p9_zvksh0p9_zvkt0p9_zvl32b1p0_zvl64b1p0"
+.attribute arch, "rv32i_zve64x_zvks1p0"
+# CHECK: attribute  5, "rv32i2p1_zicsr2p0_zvbb1p0_zve32x1p0_zve64x1p0_zvks1p0_zvksed1p0_zvksh1p0_zvkt1p0_zvl32b1p0_zvl64b1p0"
 
-.attribute arch, "rv32i_zve64x_zvksc0p9"
-# CHECK: attribute  5, "rv32i2p1_zicsr2p0_zvbb0p9_zvbc0p9_zve32x1p0_zve64x1p0_zvks0p9_zvksc0p9_zvksed0p9_zvksh0p9_zvkt0p9_zvl32b1p0_zvl64b1p0"
+.attribute arch, "rv32i_zve64x_zvksc1p0"
+# CHECK: attribute  5, "rv32i2p1_zicsr2p0_zvbb1p0_zvbc1p0_zve32x1p0_zve64x1p0_zvks1p0_zvksc1p0_zvksed1p0_zvksh1p0_zvkt1p0_zvl32b1p0_zvl64b1p0"
 
-.attribute arch, "rv32i_zve64x_zvksg0p9"
-# CHECK: attribute  5, "rv32i2p1_zicsr2p0_zvbb0p9_zve32x1p0_zve64x1p0_zvkg0p9_zvks0p9_zvksed0p9_zvksg0p9_zvksh0p9_zvkt0p9_zvl32b1p0_zvl64b1p0"
+.attribute arch, "rv32i_zve64x_zvksg1p0"
+# CHECK: attribute  5, "rv32i2p1_zicsr2p0_zvbb1p0_zve32x1p0_zve64x1p0_zvkg1p0_zvks1p0_zvksed1p0_zvksg1p0_zvksh1p0_zvkt1p0_zvl32b1p0_zvl64b1p0"
 
-.attribute arch, "rv32i_zve32x_zvksed0p9"
-# CHECK: attribute  5, "rv32i2p1_zicsr2p0_zve32x1p0_zvksed0p9_zvl32b1p0"
+.attribute arch, "rv32i_zve32x_zvksed1p0"
+# CHECK: attribute  5, 

[clang] 02f94a6 - [RISCV] Bump vector crypto to v1.0.0-rc1

2023-06-28 Thread via cfe-commits

Author: 4vtomat
Date: 2023-06-28T19:53:07-07:00
New Revision: 02f94a655fb6ee494df6cd9e136e7ab713be2043

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

LOG: [RISCV] Bump vector crypto to v1.0.0-rc1

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

Added: 


Modified: 
clang/test/Preprocessor/riscv-target-features.c
llvm/docs/RISCVUsage.rst
llvm/lib/Support/RISCVISAInfo.cpp
llvm/lib/Target/RISCV/RISCVInstrInfoZvk.td
llvm/test/CodeGen/RISCV/attributes.ll
llvm/test/MC/RISCV/attribute-arch.s

Removed: 




diff  --git a/clang/test/Preprocessor/riscv-target-features.c 
b/clang/test/Preprocessor/riscv-target-features.c
index 7f0016f14c8da4..70a1ff97bac886 100644
--- a/clang/test/Preprocessor/riscv-target-features.c
+++ b/clang/test/Preprocessor/riscv-target-features.c
@@ -553,124 +553,124 @@
 // CHECK-ZFA-EXT: __riscv_zfa 2000{{$}}
 
 // RUN: %clang -target riscv32 -menable-experimental-extensions \
-// RUN: -march=rv32i_zve64x_zvbb0p9 -x c -E -dM %s \
+// RUN: -march=rv32i_zve64x_zvbb1p0 -x c -E -dM %s \
 // RUN: -o - | FileCheck --check-prefix=CHECK-ZVBB-EXT %s
 // RUN: %clang -target riscv64 -menable-experimental-extensions \
-// RUN: -march=rv64i_zve64x_zvbb0p9 -x c -E -dM %s \
+// RUN: -march=rv64i_zve64x_zvbb1p0 -x c -E -dM %s \
 // RUN: -o - | FileCheck --check-prefix=CHECK-ZVBB-EXT %s
-// CHECK-ZVBB-EXT: __riscv_zvbb  9000{{$}}
+// CHECK-ZVBB-EXT: __riscv_zvbb  100{{$}}
 
 // RUN: %clang -target riscv32 -menable-experimental-extensions \
-// RUN: -march=rv32i_zve64x_zvbc0p9 -x c -E -dM %s \
+// RUN: -march=rv32i_zve64x_zvbc1p0 -x c -E -dM %s \
 // RUN: -o - | FileCheck --check-prefix=CHECK-ZVBC-EXT %s
 // RUN: %clang -target riscv64 -menable-experimental-extensions \
-// RUN: -march=rv64i_zve64x_zvbc0p9 -x c -E -dM %s \
+// RUN: -march=rv64i_zve64x_zvbc1p0 -x c -E -dM %s \
 // RUN: -o - | FileCheck --check-prefix=CHECK-ZVBC-EXT %s
-// CHECK-ZVBC-EXT: __riscv_zvbc  9000{{$}}
+// CHECK-ZVBC-EXT: __riscv_zvbc  100{{$}}
 
 // RUN: %clang -target riscv32 -menable-experimental-extensions \
-// RUN: -march=rv32i_zve32x_zvkg0p9 -x c -E -dM %s \
+// RUN: -march=rv32i_zve32x_zvkg1p0 -x c -E -dM %s \
 // RUN: -o - | FileCheck --check-prefix=CHECK-ZVKG-EXT %s
 // RUN: %clang -target riscv64 -menable-experimental-extensions \
-// RUN: -march=rv64i_zve32x_zvkg0p9 -x c -E -dM %s \
+// RUN: -march=rv64i_zve32x_zvkg1p0 -x c -E -dM %s \
 // RUN: -o - | FileCheck --check-prefix=CHECK-ZVKG-EXT %s
-// CHECK-ZVKG-EXT: __riscv_zvkg  9000{{$}}
+// CHECK-ZVKG-EXT: __riscv_zvkg  100{{$}}
 
 // RUN: %clang -target riscv32 -menable-experimental-extensions \
-// RUN: -march=rv32i_zve64x_zvkn0p9 -x c -E -dM %s \
+// RUN: -march=rv32i_zve64x_zvkn1p0 -x c -E -dM %s \
 // RUN: -o - | FileCheck --check-prefix=CHECK-ZVKN-EXT %s
 // RUN: %clang -target riscv64 -menable-experimental-extensions \
-// RUN: -march=rv64i_zve64x_zvkn0p9 -x c -E -dM %s \
+// RUN: -march=rv64i_zve64x_zvkn1p0 -x c -E -dM %s \
 // RUN: -o - | FileCheck --check-prefix=CHECK-ZVKN-EXT %s
-// CHECK-ZVKN-EXT: __riscv_zvkn 9000{{$}}
+// CHECK-ZVKN-EXT: __riscv_zvkn 100{{$}}
 
 // RUN: %clang -target riscv32 -menable-experimental-extensions \
-// RUN: -march=rv32i_zve64x_zvknc0p9 -x c -E -dM %s \
+// RUN: -march=rv32i_zve64x_zvknc1p0 -x c -E -dM %s \
 // RUN: -o - | FileCheck --check-prefix=CHECK-ZVKNC-EXT %s
 // RUN: %clang -target riscv64 -menable-experimental-extensions \
-// RUN: -march=rv64i_zve64x_zvknc0p9 -x c -E -dM %s \
+// RUN: -march=rv64i_zve64x_zvknc1p0 -x c -E -dM %s \
 // RUN: -o - | FileCheck --check-prefix=CHECK-ZVKNC-EXT %s
-// CHECK-ZVKNC-EXT: __riscv_zvknc 9000{{$}}
+// CHECK-ZVKNC-EXT: __riscv_zvknc 100{{$}}
 
 // RUN: %clang -target riscv32 -menable-experimental-extensions \
-// RUN: -march=rv32i_zve64x_zvkng0p9 -x c -E -dM %s \
+// RUN: -march=rv32i_zve64x_zvkng1p0 -x c -E -dM %s \
 // RUN: -o - | FileCheck --check-prefix=CHECK-ZVKNG-EXT %s
 // RUN: %clang -target riscv64 -menable-experimental-extensions \
-// RUN: -march=rv64i_zve64x_zvkng0p9 -x c -E -dM %s \
+// RUN: -march=rv64i_zve64x_zvkng1p0 -x c -E -dM %s \
 // RUN: -o - | FileCheck --check-prefix=CHECK-ZVKNG-EXT %s
-// CHECK-ZVKNG-EXT: __riscv_zvkng 9000{{$}}
+// CHECK-ZVKNG-EXT: __riscv_zvkng 100{{$}}
 
 // RUN: %clang -target riscv32 -menable-experimental-extensions \
-// RUN: -march=rv32i_zve32x_zvknha0p9 -x c -E -dM %s \
+// RUN: -march=rv32i_zve32x_zvknha1p0 -x c -E -dM %s \
 // RUN: -o - | FileCheck --check-prefix=CHECK-ZVKNHA-EXT %s
 // RUN: %clang -target riscv64 -menable-experimental-extensions \
-// RUN: -march=rv64i_zve32x_zvknha0p9 -x c -E -dM %s \
+// RUN: -march=rv64i_zve32x_zvknha1p0 -x c -E -dM %s \
 // RUN: -o - | FileCheck --check-prefix=CHECK-ZVKNHA-EXT %s
-// CHECK-ZVKNHA-EXT: __riscv_zvknha 

[PATCH] D153836: [RISCV] Bump vector crypto to v1.0.0-rc1

2023-06-28 Thread Brandon Wu via Phabricator via cfe-commits
4vtomat added a comment.

In D153836#4452236 , @asb wrote:

> Agreed that looking at 
> https://github.com/riscv/riscv-crypto/compare/v20230531...v20230620 there are 
> no changes that need to be reflected on the LLVM side beyond the version bump 
> here. LGTM

Thanks for reviewing!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153836

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


[PATCH] D154038: [clang][ExtractAPI] Add semicolons to vars and fields and to test reference JSON

2023-06-28 Thread Erick Velez via Phabricator via cfe-commits
evelez7 added a comment.

These updated tests pass locally for me.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154038

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


[PATCH] D153321: [OpenMP] Fix lvalue reference type generation in untied task loop

2023-06-28 Thread Zhiheng Xie via Phabricator via cfe-commits
eastb233 added a comment.

In D153321#4455776 , @ABataev wrote:

> LG

Thanks a lot for the review. And I do not have commit access, could you please 
help commit the patch
And my name is "Zhiheng Xie", email is "eastb...@qq.com"


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153321

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


[PATCH] D153953: Revert "[AMDGPU] Mark mbcnt as convergent"

2023-06-28 Thread Sameer Sahasrabuddhe via Phabricator via cfe-commits
sameerds requested review of this revision.
sameerds added a comment.

@pravinjagtap @arsenm ... reverting the mbcnt intrinsic affects tests that were 
added for atomic optimizations. In particular, the mbcnt is now being moved 
across/into/out of control flow because it is no longer convergent. I eyeballed 
one example and it seemed okay to me, but a more thorough check will be useful.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153953

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


[PATCH] D153146: [CLANG] Fix potential integer overflow value in getRVVTypeSize()

2023-06-28 Thread Soumi Manna via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG7372c0d46d21: [CLANG] Fix potential integer overflow value 
in getRVVTypeSize() (authored by Manna).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153146

Files:
  clang/lib/AST/ASTContext.cpp


Index: clang/lib/AST/ASTContext.cpp
===
--- clang/lib/AST/ASTContext.cpp
+++ clang/lib/AST/ASTContext.cpp
@@ -9564,8 +9564,8 @@
 
   ASTContext::BuiltinVectorTypeInfo Info = 
Context.getBuiltinVectorTypeInfo(Ty);
 
-  unsigned EltSize = Context.getTypeSize(Info.ElementType);
-  unsigned MinElts = Info.EC.getKnownMinValue();
+  uint64_t EltSize = Context.getTypeSize(Info.ElementType);
+  uint64_t MinElts = Info.EC.getKnownMinValue();
   return VScale->first * MinElts * EltSize;
 }
 


Index: clang/lib/AST/ASTContext.cpp
===
--- clang/lib/AST/ASTContext.cpp
+++ clang/lib/AST/ASTContext.cpp
@@ -9564,8 +9564,8 @@
 
   ASTContext::BuiltinVectorTypeInfo Info = Context.getBuiltinVectorTypeInfo(Ty);
 
-  unsigned EltSize = Context.getTypeSize(Info.ElementType);
-  unsigned MinElts = Info.EC.getKnownMinValue();
+  uint64_t EltSize = Context.getTypeSize(Info.ElementType);
+  uint64_t MinElts = Info.EC.getKnownMinValue();
   return VScale->first * MinElts * EltSize;
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 7372c0d - [CLANG] Fix potential integer overflow value in getRVVTypeSize()

2023-06-28 Thread via cfe-commits

Author: Manna, Soumi
Date: 2023-06-28T19:25:53-07:00
New Revision: 7372c0d46d2185017c509eb30910b102b4f9cdaa

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

LOG: [CLANG] Fix potential integer overflow value in getRVVTypeSize()

In getRVVTypeSize(clang::ASTContext &, clang::BuiltinType const *) potential 
integer overflow occurs on expression VScale->first * MinElts with type 
unsigned int (32 bits, unsigned) is evaluated using 32-bit arithmetic, and then 
used in a context that expects an expression of type uint64_t (64 bits, 
unsigned).

To avoid integer overflow, this patch changes the types of variables MinElts 
and EltSize to uint64_t from unsigned instead of the cast.

Reviewed By: erichkeane

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

Added: 


Modified: 
clang/lib/AST/ASTContext.cpp

Removed: 




diff  --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index dd040a3b8896f..65132b9eb44b8 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -9564,8 +9564,8 @@ static uint64_t getRVVTypeSize(ASTContext , const 
BuiltinType *Ty) {
 
   ASTContext::BuiltinVectorTypeInfo Info = 
Context.getBuiltinVectorTypeInfo(Ty);
 
-  unsigned EltSize = Context.getTypeSize(Info.ElementType);
-  unsigned MinElts = Info.EC.getKnownMinValue();
+  uint64_t EltSize = Context.getTypeSize(Info.ElementType);
+  uint64_t MinElts = Info.EC.getKnownMinValue();
   return VScale->first * MinElts * EltSize;
 }
 



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


[PATCH] D154038: [clang][ExtractAPI] Add semicolons to vars and fields and to test reference JSON

2023-06-28 Thread Erick Velez via Phabricator via cfe-commits
evelez7 created this revision.
Herald added a reviewer: ributzka.
Herald added a project: All.
evelez7 requested review of this revision.
Herald added a reviewer: dang.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D154038

Files:
  clang/lib/ExtractAPI/DeclarationFragments.cpp
  clang/test/ExtractAPI/anonymous_record_no_typedef.c
  clang/test/ExtractAPI/global_record.c
  clang/test/ExtractAPI/global_record_multifile.c
  clang/test/ExtractAPI/known_files_only.c
  clang/test/ExtractAPI/language.c
  clang/test/ExtractAPI/objc_interface.m
  clang/test/ExtractAPI/relative_include.m
  clang/test/ExtractAPI/struct.c
  clang/test/ExtractAPI/typedef_struct_enum.c
  clang/test/ExtractAPI/underscored.c

Index: clang/test/ExtractAPI/underscored.c
===
--- clang/test/ExtractAPI/underscored.c
+++ clang/test/ExtractAPI/underscored.c
@@ -85,6 +85,10 @@
 {
   "kind": "identifier",
   "spelling": "exposed_global"
+},
+{
+  "kind": "text",
+  "spelling": ";"
 }
   ],
   "identifier": {
@@ -190,6 +194,10 @@
 {
   "kind": "identifier",
   "spelling": "a"
+},
+{
+  "kind": "text",
+  "spelling": ";"
 }
   ],
   "identifier": {
Index: clang/test/ExtractAPI/typedef_struct_enum.c
===
--- clang/test/ExtractAPI/typedef_struct_enum.c
+++ clang/test/ExtractAPI/typedef_struct_enum.c
@@ -328,6 +328,10 @@
 {
   "kind": "identifier",
   "spelling": "bar"
+},
+{
+  "kind": "text",
+  "spelling": ";"
 }
   ],
   "identifier": {
Index: clang/test/ExtractAPI/struct.c
===
--- clang/test/ExtractAPI/struct.c
+++ clang/test/ExtractAPI/struct.c
@@ -161,6 +161,10 @@
 {
   "kind": "identifier",
   "spelling": "Red"
+},
+{
+  "kind": "text",
+  "spelling": ";"
 }
   ],
   "identifier": {
@@ -213,6 +217,10 @@
 {
   "kind": "identifier",
   "spelling": "Green"
+},
+{
+  "kind": "text",
+  "spelling": ";"
 }
   ],
   "identifier": {
@@ -265,6 +273,10 @@
 {
   "kind": "identifier",
   "spelling": "Blue"
+},
+{
+  "kind": "text",
+  "spelling": ";"
 }
   ],
   "identifier": {
@@ -317,6 +329,10 @@
 {
   "kind": "identifier",
   "spelling": "Alpha"
+},
+{
+  "kind": "text",
+  "spelling": ";"
 }
   ],
   "docComment": {
Index: clang/test/ExtractAPI/relative_include.m
===
--- clang/test/ExtractAPI/relative_include.m
+++ clang/test/ExtractAPI/relative_include.m
@@ -102,6 +102,10 @@
 {
   "kind": "identifier",
   "spelling": "MyInt"
+},
+{
+  "kind": "text",
+  "spelling": ";"
 }
   ],
   "identifier": {
@@ -153,6 +157,10 @@
 {
   "kind": "identifier",
   "spelling": "MyChar"
+},
+{
+  "kind": "text",
+  "spelling": ";"
 }
   ],
   "identifier": {
Index: clang/test/ExtractAPI/objc_interface.m
===
--- clang/test/ExtractAPI/objc_interface.m
+++ clang/test/ExtractAPI/objc_interface.m
@@ -579,6 +579,10 @@
 {
   "kind": "identifier",
   "spelling": "Ivar"
+},
+{
+  "kind": "text",
+  "spelling": ";"
 }
   ],
   "identifier": {
Index: clang/test/ExtractAPI/language.c
===
--- clang/test/ExtractAPI/language.c
+++ clang/test/ExtractAPI/language.c
@@ -70,6 +70,10 @@
 {
   "kind": "identifier",
   "spelling": "c"
+},
+{
+  "kind": "text",
+  "spelling": ";"
 }
   ],
   "identifier": {
@@ -150,6 +154,10 @@
 {
   "kind": "identifier",
   "spelling": "objc"
+},
+{
+  "kind": "text",
+  "spelling": ";"
 }
   ],
   "identifier": {
Index: clang/test/ExtractAPI/known_files_only.c
===
--- clang/test/ExtractAPI/known_files_only.c
+++ clang/test/ExtractAPI/known_files_only.c
@@ -66,6 +66,10 @@
 {
   "kind": "identifier",
   "spelling": "num"
+},
+{
+  "kind": "text",
+  "spelling": ";"
 }
   ],
   "identifier": {
Index: 

[PATCH] D153667: [HIP]: Add -fhip-emit-relocatable to override link job creation for -fno-gpu-rdc

2023-06-28 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl accepted this revision.
yaxunl added a comment.
This revision is now accepted and ready to land.

LGTM. Thanks


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153667

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


[PATCH] D154036: [libc] Add support for creating wrapper headers for offloading in clang

2023-06-28 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 updated this revision to Diff 535600.
jhuber6 added a comment.

Hack around the `string` problem. GNU likes to provide different prototypes for 
C++. Manually disable this for now. Unsure if this will have reasonable 
fallout, but it seems bizarre that `string.h` would define C++ constructs?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154036

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Headers/CMakeLists.txt
  clang/lib/Headers/llvm_libc_wrappers/ctype.h
  clang/lib/Headers/llvm_libc_wrappers/llvm-libc-decls/README.txt
  clang/lib/Headers/llvm_libc_wrappers/stdio.h
  clang/lib/Headers/llvm_libc_wrappers/stdlib.h
  clang/lib/Headers/llvm_libc_wrappers/string.h
  clang/test/Driver/gpu-libc-headers.c
  libc/cmake/modules/LLVMLibCHeaderRules.cmake
  libc/include/CMakeLists.txt
  libc/utils/HdrGen/Generator.cpp
  libc/utils/HdrGen/Generator.h
  libc/utils/HdrGen/Main.cpp

Index: libc/utils/HdrGen/Main.cpp
===
--- libc/utils/HdrGen/Main.cpp
+++ libc/utils/HdrGen/Main.cpp
@@ -32,6 +32,9 @@
 llvm::cl::list ReplacementValues(
 "args", llvm::cl::desc("Command separated = pairs."),
 llvm::cl::value_desc("[,name=value]"));
+llvm::cl::opt ExportDecls(
+"export-decls",
+llvm::cl::desc("Output a new header containing only the entrypoints."));
 
 void ParseArgValuePairs(std::unordered_map ) {
   for (std::string  : ReplacementValues) {
@@ -48,7 +51,10 @@
   std::unordered_map ArgMap;
   ParseArgValuePairs(ArgMap);
   Generator G(HeaderDefFile, EntrypointNamesOption, StandardHeader, ArgMap);
-  G.generate(OS, Records);
+  if (ExportDecls)
+G.generateDecls(OS, Records);
+  else
+G.generate(OS, Records);
 
   return false;
 }
Index: libc/utils/HdrGen/Generator.h
===
--- libc/utils/HdrGen/Generator.h
+++ libc/utils/HdrGen/Generator.h
@@ -52,6 +52,7 @@
 ArgMap(Map) {}
 
   void generate(llvm::raw_ostream , llvm::RecordKeeper );
+  void generateDecls(llvm::raw_ostream , llvm::RecordKeeper );
 };
 
 } // namespace llvm_libc
Index: libc/utils/HdrGen/Generator.cpp
===
--- libc/utils/HdrGen/Generator.cpp
+++ libc/utils/HdrGen/Generator.cpp
@@ -10,6 +10,7 @@
 
 #include "IncludeFileCommand.h"
 #include "PublicAPICommand.h"
+#include "utils/LibcTableGenUtil/APIIndexer.h"
 
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/MemoryBuffer.h"
@@ -116,4 +117,78 @@
   }
 }
 
+void Generator::generateDecls(llvm::raw_ostream ,
+  llvm::RecordKeeper ) {
+
+  OS << "//===-- C standard declarations for " << StdHeader << " "
+ << std::string(80 - (42 + StdHeader.size()), '-') << "===//\n"
+ << "//\n"
+ << "// Part of the LLVM Project, under the Apache License v2.0 with LLVM "
+"Exceptions.\n"
+ << "// See https://llvm.org/LICENSE.txt for license information.\n"
+ << "// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n"
+ << "//\n"
+ << "//"
+"===---"
+"---===//\n\n";
+
+  std::string HeaderGuard(StdHeader.size(), '\0');
+  llvm::transform(StdHeader, HeaderGuard.begin(), [](const char C) -> char {
+return !isalnum(C) ? '_' : llvm::toUpper(C);
+  });
+  OS << "#ifndef __LLVM_LIBC_DECLARATIONS_" << HeaderGuard << "\n"
+ << "#define __LLVM_LIBC_DECLARATIONS_" << HeaderGuard << "\n\n";
+
+  OS << "#ifndef __LIBC_ATTRS\n"
+ << "#define __LIBC_ATTRS\n"
+ << "#endif\n\n";
+
+  OS << "#ifdef __cplusplus\n"
+ << "extern \"C\" {\n"
+ << "#endif\n\n";
+
+  APIIndexer G(StdHeader, Records);
+  for (auto  : EntrypointNameList) {
+// Filter out functions not exported by this header.
+if (G.FunctionSpecMap.find(Name) == G.FunctionSpecMap.end())
+  continue;
+
+llvm::Record *FunctionSpec = G.FunctionSpecMap[Name];
+llvm::Record *RetValSpec = FunctionSpec->getValueAsDef("Return");
+llvm::Record *ReturnType = RetValSpec->getValueAsDef("ReturnType");
+
+OS << G.getTypeAsString(ReturnType) << " " << Name << "(";
+
+auto ArgsList = FunctionSpec->getValueAsListOfDefs("Args");
+for (size_t i = 0; i < ArgsList.size(); ++i) {
+  llvm::Record *ArgType = ArgsList[i]->getValueAsDef("ArgType");
+  OS << G.getTypeAsString(ArgType);
+  if (i < ArgsList.size() - 1)
+OS << ", ";
+}
+
+OS << ") __LIBC_ATTRS;\n\n";
+  }
+
+  // Make another pass over entrypoints to emit object declarations.
+  for (const auto  : EntrypointNameList) {
+if (G.ObjectSpecMap.find(Name) == G.ObjectSpecMap.end())
+  continue;
+llvm::Record *ObjectSpec = G.ObjectSpecMap[Name];
+auto Type = ObjectSpec->getValueAsString("Type");
+OS << "extern " << Type << " " << Name << " __LIBC_ATTRS;\n";
+  }
+
+  // Emit a 

[PATCH] D146777: [clang] Preliminary fat-lto-object support

2023-06-28 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

In D146777#4457839 , @paulkirth wrote:

> In D146777#4457209 , @MaskRay wrote:
>
>> As mentioned, you may consider landing llvm patch then wait a bit so that 
>> (a) people can experiment with the clang patch better (b) prevent the 
>> llvm/clang patches to be both reverted, if some issue has been identified 
>> with the llvm patch.
>
> Well, any later than Friday morning and it will have to wait until I get back 
> from vacation. :) That isn't a big deal, though. and yeah, given the llvm 
> patch had to be reverted twice, I'm fine w/ being a bit cautious.

Sounds good!

>> (Don't worry that a feature doesn't have contiguous commits. It's common.)
>
> Yeah, I'm just trying to keep this stack up to date w/ the rebases. When I've 
> let them get very much out of sync it's caused my headaches in the past w/ 
> phabricator not being able to apply the patch or because I hadn't kept them 
> up to date and downloaded the patch from phabricator. I really miss Gerrits 
> ability to upload the whole stack at once and have all the correct 
> relationships. IDK if things will be better w/ github PRs, but I guess we'll 
> all find out soon.

I hope that this will be useful: `git rebase -i origin/main -x 'arc diff 
"HEAD^"'`

>> I do not accept the lld part now, just to have more time to ensure the llvm 
>> and clang part is mature :)
>
> No problem. There's still some non trivial test improvements to implement on 
> those anyway. Plus I need to figure out how to handle the archive case, which 
> I don't think will be very hard, but I haven't looked at that code yet either.

Thanks. I forgot that I mentioned archives:(


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146777

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


[PATCH] D154036: [libc] Add support for creating wrapper headers for offloading in clang

2023-06-28 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 added a comment.

For reference, here is what one of the newly generated headers looks like that 
is used.

  #ifndef __LLVM_LIBC_DECLARATIONS_STDIO_H
  #define __LLVM_LIBC_DECLARATIONS_STDIO_H
  
  #ifndef __LIBC_ATTRS
  #define __LIBC_ATTRS
  #endif
  
  #ifdef __cplusplus
  extern "C" {
  #endif
  
  int puts(const char *__restrict) __LIBC_ATTRS;
  
  int fputs(const char *__restrict, FILE *__restrict) __LIBC_ATTRS;
  
  extern FILE * stdin __LIBC_ATTRS;
  extern FILE * stdout __LIBC_ATTRS;
  extern FILE * stderr __LIBC_ATTRS;
  
  #ifdef __cplusplus
  }
  #endif

Unfortunately I have already run into a few problems with the re-declarations 
given the GNU `libc` headers. Here is the error message when including 
`string.h` now,

  
/home/jhuber/Documents/llvm/clang/lib/clang/17/include/llvm_libc_wrappers/llvm-libc-decls/string.h:54:8:
 error: 'strstr' is missing exception specification 'noexcept(true)'
 54 | char * strstr(const char *, const char *) __LIBC_ATTRS;
|^
  /usr/include/string.h:343:1: note: previous declaration is here
343 | strstr (const char *__haystack, const char *__needle) __THROW
| ^
  5 errors generated.

This occurs for `memchr`, `strchr`, `strpbrk`, `strchr`, and `strstr`. If you 
define `__LIBC_ATTRS` to the `noexcept(true)` you get a different error,

  
/home/jhuber/Documents/llvm/clang/lib/clang/17/include/llvm_libc_wrappers/llvm-libc-decls/string.h:54:8:
 error: functions that differ only in their return type cannot be overloaded
 54 | char * strstr(const char *, const char *) __LIBC_ATTRS;
| ~~ ^
  /usr/include/string.h:343:1: note: previous definition is here
343 | __extern_always_inline const char *
|  ~~
344 | strstr (const char *__haystack, const char *__needle) __THROW
| ^

Looking at the definitions, they look like this in the GNU headers,

  extern char *strstr (char *__haystack, const char *__needle)
   __THROW __asm ("strstr") __attribute_pure__ __nonnull ((1, 2));
  extern const char *strstr (const char *__haystack, const char *__needle)
   __THROW __asm ("strstr") __attribute_pure__ __nonnull ((1, 2));

Does anyone have any suggestions on working around this? The other supported 
headers work as far as I can tell.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154036

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


[PATCH] D154036: [libc] Add support for creating wrapper headers for offloading in clang

2023-06-28 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 created this revision.
jhuber6 added reviewers: jdoerfert, tianshilei1992, sivachandra, lntue, 
michaelrj, tra, JonChesterfield.
Herald added projects: libc-project, All.
Herald added a subscriber: libc-commits.
jhuber6 requested review of this revision.
Herald added subscribers: cfe-commits, jplehr, sstefan1, MaskRay.
Herald added a project: clang.

This is an alternate approach to the patches proposed in D153897 
 and
D153794 . Rather than exporting a single 
header that can be included on
the GPU in all circumstances, this patch chooses to instead generate a
separate set of headers that only provides the declarations. This can
then be used by external tooling to set up what's on the GPU. This
leaves room for header hacks for offloading languages without needing to
worry about the `libc` implementation.

Currently this generates a set of headers that only contain the
declarations. These will then be installed to a new clang resource
directory called `llvm_libc_wrappers/` which will house the shim code.
We can then automaticlaly include this from `clang` when offloading to
wrap around the headers while specifying what's on the GPU.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D154036

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Headers/CMakeLists.txt
  clang/lib/Headers/llvm_libc_wrappers/ctype.h
  clang/lib/Headers/llvm_libc_wrappers/llvm-libc-decls/README.txt
  clang/lib/Headers/llvm_libc_wrappers/stdio.h
  clang/lib/Headers/llvm_libc_wrappers/stdlib.h
  clang/lib/Headers/llvm_libc_wrappers/string.h
  clang/test/Driver/gpu-libc-headers.c
  libc/cmake/modules/LLVMLibCHeaderRules.cmake
  libc/include/CMakeLists.txt
  libc/utils/HdrGen/Generator.cpp
  libc/utils/HdrGen/Generator.h
  libc/utils/HdrGen/Main.cpp

Index: libc/utils/HdrGen/Main.cpp
===
--- libc/utils/HdrGen/Main.cpp
+++ libc/utils/HdrGen/Main.cpp
@@ -32,6 +32,9 @@
 llvm::cl::list ReplacementValues(
 "args", llvm::cl::desc("Command separated = pairs."),
 llvm::cl::value_desc("[,name=value]"));
+llvm::cl::opt ExportDecls(
+"export-decls",
+llvm::cl::desc("Output a new header containing only the entrypoints."));
 
 void ParseArgValuePairs(std::unordered_map ) {
   for (std::string  : ReplacementValues) {
@@ -48,7 +51,10 @@
   std::unordered_map ArgMap;
   ParseArgValuePairs(ArgMap);
   Generator G(HeaderDefFile, EntrypointNamesOption, StandardHeader, ArgMap);
-  G.generate(OS, Records);
+  if (ExportDecls)
+G.generateDecls(OS, Records);
+  else
+G.generate(OS, Records);
 
   return false;
 }
Index: libc/utils/HdrGen/Generator.h
===
--- libc/utils/HdrGen/Generator.h
+++ libc/utils/HdrGen/Generator.h
@@ -52,6 +52,7 @@
 ArgMap(Map) {}
 
   void generate(llvm::raw_ostream , llvm::RecordKeeper );
+  void generateDecls(llvm::raw_ostream , llvm::RecordKeeper );
 };
 
 } // namespace llvm_libc
Index: libc/utils/HdrGen/Generator.cpp
===
--- libc/utils/HdrGen/Generator.cpp
+++ libc/utils/HdrGen/Generator.cpp
@@ -10,6 +10,7 @@
 
 #include "IncludeFileCommand.h"
 #include "PublicAPICommand.h"
+#include "utils/LibcTableGenUtil/APIIndexer.h"
 
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/MemoryBuffer.h"
@@ -116,4 +117,78 @@
   }
 }
 
+void Generator::generateDecls(llvm::raw_ostream ,
+  llvm::RecordKeeper ) {
+
+  OS << "//===-- C standard declarations for " << StdHeader << " "
+ << std::string(80 - (42 + StdHeader.size()), '-') << "===//\n"
+ << "//\n"
+ << "// Part of the LLVM Project, under the Apache License v2.0 with LLVM "
+"Exceptions.\n"
+ << "// See https://llvm.org/LICENSE.txt for license information.\n"
+ << "// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n"
+ << "//\n"
+ << "//"
+"===---"
+"---===//\n\n";
+
+  std::string HeaderGuard(StdHeader.size(), '\0');
+  llvm::transform(StdHeader, HeaderGuard.begin(), [](const char C) -> char {
+return !isalnum(C) ? '_' : llvm::toUpper(C);
+  });
+  OS << "#ifndef __LLVM_LIBC_DECLARATIONS_" << HeaderGuard << "\n"
+ << "#define __LLVM_LIBC_DECLARATIONS_" << HeaderGuard << "\n\n";
+
+  OS << "#ifndef __LIBC_ATTRS\n"
+ << "#define __LIBC_ATTRS\n"
+ << "#endif\n\n";
+
+  OS << "#ifdef __cplusplus\n"
+ << "extern \"C\" {\n"
+ << "#endif\n\n";
+
+  APIIndexer G(StdHeader, Records);
+  for (auto  : EntrypointNameList) {
+// Filter out functions not exported by this header.
+if (G.FunctionSpecMap.find(Name) == G.FunctionSpecMap.end())
+  continue;
+
+llvm::Record *FunctionSpec = G.FunctionSpecMap[Name];
+llvm::Record *RetValSpec = FunctionSpec->getValueAsDef("Return");
+

[PATCH] D151696: [x86] Remove CPU_SPECIFIC* MACROs and add getCPUDispatchMangling

2023-06-28 Thread Freddy, Ye via Phabricator via cfe-commits
FreddyYe added a comment.

gentle ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151696

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


[PATCH] D154014: [SpecialCaseList] Use Globs instead of Regex

2023-06-28 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

> This is a breaking change since some SCLs might use .* or (abc|def) which are 
> supported regexes but not valid globs. Since we have just cut clang 16.x this 
> is a good time to make this change.

My user has some ignore lists, but there is no `^[a-z]+:.*\(` or `^[a-z]+:\.` 
occurrence, so this change is likely safe for us.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154014

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


[PATCH] D146777: [clang] Preliminary fat-lto-object support

2023-06-28 Thread Paul Kirth via Phabricator via cfe-commits
paulkirth added a comment.

In D146777#4457209 , @MaskRay wrote:

> As mentioned, you may consider landing llvm patch then wait a bit so that (a) 
> people can experiment with the clang patch better (b) prevent the llvm/clang 
> patches to be both reverted, if some issue has been identified with the llvm 
> patch.

Well, any later than Friday morning and it will have to wait until I get back 
from vacation. :) That isn't a big deal, though. and yeah, given the llvm patch 
had to be reverted twice, I'm fine w/ being a bit cautious.

> (Don't worry that a feature doesn't have contiguous commits. It's common.)

Yeah, I'm just trying to keep this stack up to date w/ the rebases. When I've 
let them get very much out of sync it's caused my headaches in the past w/ 
phabricator not being able to apply the patch or because I hadn't kept them up 
to date and downloaded the patch from phabricator. I really miss Gerrits 
ability to upload the whole stack at once and have all the correct 
relationships. IDK if things will be better w/ github PRs, but I guess we'll 
all find out soon.

> I do not accept the lld part now, just to have more time to ensure the llvm 
> and clang part is mature :)

No problem. There's still some non trivial test improvements to implement on 
those anyway. Plus I need to figure out how to handle the archive case, which I 
don't think will be very hard, but I haven't looked at that code yet either.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146777

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


[PATCH] D153898: [DebugInfo] Enable debug info emission for extern variables in C++

2023-06-28 Thread David Blaikie via Phabricator via cfe-commits
dblaikie accepted this revision.
dblaikie added a comment.

In D153898#4457263 , @chiyuze wrote:

> Regarding cost, only BPF target triggers this debug info generation for 
> extern variables.

Ah, OK - if that's what you need for BPF and it doesn't affect anything else - 
have at.

(though I'd still ask a bit about the issue of declaration V definition - is 
BPF just always "standalone" debug info generally? (is there a problem with the 
definition coming from another translation unit with debug info?)?)

> There is no impact on x86 builds of clang:

Oh, OK - no worries then.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153898

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


[PATCH] D153652: [Support] Don't set "all_exe" mode by default for file written by llvm::writeToOutput

2023-06-28 Thread Alexey Lapshin via Phabricator via cfe-commits
avl added a comment.

this LGTM. please, wait if James has any concern.




Comment at: llvm/unittests/Support/raw_ostream_test.cpp:525
+  ASSERT_TRUE(Perms) << "should be able to get permissions";
+  // Verify that writeToOutput doesn't set exe bit.
+  EXPECT_EQ(Perms.get(), llvm::sys::fs::all_read | llvm::sys::fs::all_write);

nit: comment looks a bit inconsistent as we check for read bits.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153652

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


[PATCH] D154014: [SpecialCaseList] Use Globs instead of Regex

2023-06-28 Thread Ellis Hoag via Phabricator via cfe-commits
ellis created this revision.
Herald added a subscriber: hiraditya.
Herald added a project: All.
ellis edited the summary of this revision.
ellis added reviewers: MaskRay, phosek, vitalybuka, samsonov, hctim.
ellis updated this revision to Diff 535560.
ellis added a comment.
ellis published this revision for review.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

Fix ProfileList


Switch `SpecialCaseList` from using Regex to Globs to match patterns. 
`GlobPattern` was extended in https://reviews.llvm.org/D153587 to support brace 
expansions which allows us to use patterns like `*/src/foo.{c,cpp}`. It turns 
out that most patterns only use `*` to match any string and a few special cases 
use brace expansions, so using Regex was overkill and required lots of escaping 
in practice.

This is a breaking change since some SCLs might use `.*` or `(abc|def)` which 
are supported regexes but not valid globs. Since we have just cut clang 16.x 
this is a good time to make this change.

See discussion in https://reviews.llvm.org/D152762


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D154014

Files:
  clang/docs/SanitizerSpecialCaseList.rst
  clang/lib/Basic/ProfileList.cpp
  clang/lib/Basic/SanitizerSpecialCaseList.cpp
  llvm/include/llvm/Support/SpecialCaseList.h
  llvm/lib/Support/SpecialCaseList.cpp
  llvm/unittests/Support/SpecialCaseListTest.cpp

Index: llvm/unittests/Support/SpecialCaseListTest.cpp
===
--- llvm/unittests/Support/SpecialCaseListTest.cpp
+++ llvm/unittests/Support/SpecialCaseListTest.cpp
@@ -10,8 +10,11 @@
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/VirtualFileSystem.h"
+#include "gmock/gmock.h"
 #include "gtest/gtest.h"
 
+using testing::HasSubstr;
+using testing::StartsWith;
 using namespace llvm;
 
 namespace {
@@ -50,7 +53,8 @@
   "src:hello\n"
   "src:bye\n"
   "src:hi=category\n"
-  "src:z*=category\n");
+  "src:z*=category\n"
+  " \n");
   EXPECT_TRUE(SCL->inSection("", "src", "hello"));
   EXPECT_TRUE(SCL->inSection("", "src", "bye"));
   EXPECT_TRUE(SCL->inSection("", "src", "hi", "category"));
@@ -74,31 +78,29 @@
  "\n"
  "[not valid\n",
  Error));
-  EXPECT_TRUE(
-  ((StringRef)Error).startswith("malformed section header on line 3:"));
+  EXPECT_THAT(Error, StartsWith("malformed section header on line 3:"));
 
   EXPECT_EQ(nullptr, makeSpecialCaseList("\n\n\n"
  "[not valid\n",
  Error));
-  EXPECT_TRUE(
-  ((StringRef)Error).startswith("malformed section header on line 4:"));
+  EXPECT_THAT(Error, StartsWith("malformed section header on line 4:"));
 }
 
-TEST_F(SpecialCaseListTest, SectionRegexErrorHandling) {
+TEST_F(SpecialCaseListTest, SectionGlobErrorHandling) {
   std::string Error;
   EXPECT_EQ(makeSpecialCaseList("[address", Error), nullptr);
-  EXPECT_TRUE(((StringRef)Error).startswith("malformed section header "));
+  EXPECT_THAT(Error, StartsWith("malformed section header "));
 
   EXPECT_EQ(makeSpecialCaseList("[[]", Error), nullptr);
-  EXPECT_TRUE(((StringRef)Error).startswith("malformed regex for section [: "));
+  EXPECT_EQ(Error, "malformed section at line 1: '[': invalid glob pattern: [");
 
   EXPECT_EQ(makeSpecialCaseList("src:=", Error), nullptr);
-  EXPECT_TRUE(((StringRef)Error).endswith("Supplied regexp was blank"));
+  EXPECT_THAT(Error, HasSubstr("Supplied glob was blank"));
 }
 
 TEST_F(SpecialCaseListTest, Section) {
   std::unique_ptr SCL = makeSpecialCaseList("src:global\n"
- "[sect1|sect2]\n"
+ "[{sect1,sect2}]\n"
  "src:test1\n"
  "[sect3*]\n"
  "src:test2\n");
@@ -154,17 +156,12 @@
   EXPECT_EQ(nullptr, makeSpecialCaseList("badline", Error));
   EXPECT_EQ("malformed line 1: 'badline'", Error);
   EXPECT_EQ(nullptr, makeSpecialCaseList("src:bad[a-", Error));
-  EXPECT_EQ("malformed regex in line 1: 'bad[a-': invalid character range",
-Error);
-  EXPECT_EQ(nullptr, makeSpecialCaseList("src:a.c\n"
-   "fun:fun(a\n",
-   Error));
-  EXPECT_EQ("malformed regex in line 2: 'fun(a': parentheses not balanced",
+  EXPECT_EQ("malformed glob in line 1: 'bad[a-': invalid glob pattern: bad[a-",
 Error);
   std::vector Files(1, "unexisting");
   EXPECT_EQ(nullptr,

[PATCH] D152762: [clang][docs] Update SanitizerSpecialCaseList docs

2023-06-28 Thread Ellis Hoag via Phabricator via cfe-commits
ellis abandoned this revision.
ellis added a comment.

Moved to https://reviews.llvm.org/D154014


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152762

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


[PATCH] D154016: [clang][modules] Avoid serializing all diag mappings in non-deterministic order

2023-06-28 Thread Ben Langmuir via Phabricator via cfe-commits
benlangmuir created this revision.
benlangmuir added reviewers: steven_wu, jansvoboda11, akyrtzi.
Herald added a subscriber: mgrang.
Herald added a project: All.
benlangmuir requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

When writing a pcm, we serialize diagnostic mappings in order to
accurately reproduce the diagnostic environment inside any headers from
that module. However, the diagnostic state mapping table contains
entries for every diagnostic ID ever accessed, while we only want to
serialize the ones that are actually modified from their default value.
Futher, we need to serialize them in a deterministic order.

rdar://111477511


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D154016

Files:
  clang/include/clang/Basic/DiagnosticIDs.h
  clang/lib/Basic/Diagnostic.cpp
  clang/lib/Basic/DiagnosticIDs.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/Modules/diag-mappings.c

Index: clang/test/Modules/diag-mappings.c
===
--- /dev/null
+++ clang/test/Modules/diag-mappings.c
@@ -0,0 +1,52 @@
+// Test that diagnostic mappings are emitted only when needed and in order of
+// diagnostic ID rather than non-deterministically. This test passes 3
+// -W options and expects exactly 3 mappings to be emitted in the pcm. The -W
+// options are chosen to be far apart in ID (see DiagnosticIDs.h) so we can
+// check they are ordered. We also intentionally trigger several other warnings
+// inside the module and ensure they do not show up in the pcm as mappings.
+
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+
+// RUN: %clang_cc1 -fmodules -fimplicit-module-maps \
+// RUN:   -fmodules-cache-path=%t/cache -triple x86_64-apple-macosx10.11.0 \
+// RUN:   %t/main.m -fdisable-module-hash \
+// RUN:   -Werror=stack-protector -Werror=empty-translation-unit -Werror=float-equal
+
+// RUN: mv %t/cache/A.pcm %t/A1.pcm
+
+// RUN: llvm-bcanalyzer --dump --disable-histogram %t/A1.pcm | FileCheck %s
+
+// CHECK:  2000
+// CHECK-SAME: op7={{[2-9][0-9][0-9][0-9]}} op8=
+
+// RUN: %clang_cc1 -fmodules -fimplicit-module-maps \
+// RUN:   -fmodules-cache-path=%t/cache -triple x86_64-apple-macosx10.11.0 \
+// RUN:   %t/main.m -fdisable-module-hash \
+// RUN:   -Werror=stack-protector -Werror=empty-translation-unit -Werror=float-equal
+
+// RUN: diff %t/cache/A.pcm %t/A1.pcm
+
+//--- module.modulemap
+module A { header "a.h" }
+
+//--- a.h
+// Lex warning
+#warning "w"
+
+static inline void f() {
+// Parse warning
+  ;
+// Sema warning
+  int x;
+}
+
+//--- main.m
+#import "a.h"
Index: clang/lib/Serialization/ASTWriter.cpp
===
--- clang/lib/Serialization/ASTWriter.cpp
+++ clang/lib/Serialization/ASTWriter.cpp
@@ -2997,20 +2997,41 @@
 assert(Flags == EncodeDiagStateFlags(State) &&
"diag state flags vary in single AST file");
 
+// If we ever serialize non-pragma mappings outside the initial state, the
+// code below will need to consider more than getDefaultMapping.
+assert(!IncludeNonPragmaStates ||
+   State == Diag.DiagStatesByLoc.FirstDiagState);
+
 unsigned  = DiagStateIDMap[State];
 Record.push_back(DiagStateID);
 
 if (DiagStateID == 0) {
   DiagStateID = ++CurrID;
+  SmallVector> Mappings;
 
   // Add a placeholder for the number of mappings.
   auto SizeIdx = Record.size();
   Record.emplace_back();
   for (const auto  : *State) {
-if (I.second.isPragma() || IncludeNonPragmaStates) {
-  Record.push_back(I.first);
-  Record.push_back(I.second.serialize());
-}
+// Maybe skip non-pragmas.
+if (!I.second.isPragma() && !IncludeNonPragmaStates)
+  continue;
+// Skip default mappings. We have a mapping for every diagnostic ever
+// emitted, regardless of whether it was customized.
+if (!I.second.isPragma() &&
+I.second == DiagnosticIDs::getDefaultMapping(I.first))
+  continue;
+Mappings.push_back(I);
+  }
+
+  // Sort by diag::kind for deterministic output.
+  llvm::sort(Mappings, [](const auto , const auto ) {
+return LHS.first < RHS.first;
+  });
+
+  for (const auto  : Mappings) {
+Record.push_back(I.first);
+Record.push_back(I.second.serialize());
   }
   // Update the placeholder.
   Record[SizeIdx] = (Record.size() - SizeIdx) / 2;
Index: clang/lib/Basic/DiagnosticIDs.cpp
===
--- clang/lib/Basic/DiagnosticIDs.cpp
+++ clang/lib/Basic/DiagnosticIDs.cpp
@@ -256,7 +256,7 @@
   return Found;
 }
 
-static DiagnosticMapping GetDefaultDiagMapping(unsigned DiagID) {
+DiagnosticMapping DiagnosticIDs::getDefaultMapping(unsigned DiagID) {
   DiagnosticMapping Info = DiagnosticMapping::Make(
   diag::Severity::Fatal, /*IsUser=*/false, 

[PATCH] D153557: [clang][ExtractAPI] Add support for C++ classes

2023-06-28 Thread Erick Velez via Phabricator via cfe-commits
evelez7 updated this revision to Diff 535559.
evelez7 marked 6 inline comments as done.
evelez7 added a comment.

Address some review feedback

Remove RK_Struct, RK_Union from CXXClassRecord::classof, use std::string for 
AccessControl, style and remove unused imports


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153557

Files:
  clang/include/clang/ExtractAPI/API.h
  clang/include/clang/ExtractAPI/DeclarationFragments.h
  clang/include/clang/ExtractAPI/ExtractAPIVisitor.h
  clang/include/clang/ExtractAPI/Serialization/SerializerBase.h
  clang/include/clang/ExtractAPI/Serialization/SymbolGraphSerializer.h
  clang/lib/ExtractAPI/API.cpp
  clang/lib/ExtractAPI/DeclarationFragments.cpp
  clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp

Index: clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
===
--- clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
+++ clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
@@ -38,6 +38,14 @@
 Paren[Key] = std::move(*Obj);
 }
 
+/// Helper function to inject a StringRef \p String into an object \p Paren at
+/// position \p Key
+void serializeString(Object , StringRef Key,
+ std::optional String) {
+  if (String)
+Paren[Key] = std::move(*String);
+}
+
 /// Helper function to inject a JSON array \p Array into object \p Paren at
 /// position \p Key.
 void serializeArray(Object , StringRef Key, std::optional Array) {
@@ -366,6 +374,38 @@
 Kind["identifier"] = AddLangPrefix("struct");
 Kind["displayName"] = "Structure";
 break;
+  case APIRecord::RK_CXXField:
+Kind["identifier"] = AddLangPrefix("property");
+Kind["displayName"] = "Instance Property";
+break;
+  case APIRecord::RK_Union:
+Kind["identifier"] = AddLangPrefix("union");
+Kind["displayName"] = "Union";
+break;
+  case APIRecord::RK_StaticField:
+Kind["identifier"] = AddLangPrefix("type.property");
+Kind["displayName"] = "Type Property";
+break;
+  case APIRecord::RK_CXXClass:
+Kind["identifier"] = AddLangPrefix("class");
+Kind["displayName"] = "Class";
+break;
+  case APIRecord::RK_CXXStaticMethod:
+Kind["identifier"] = AddLangPrefix("type.method");
+Kind["displayName"] = "Static Method";
+break;
+  case APIRecord::RK_CXXInstanceMethod:
+Kind["identifier"] = AddLangPrefix("method");
+Kind["displayName"] = "Instance Method";
+break;
+  case APIRecord::RK_CXXConstructorMethod:
+Kind["identifier"] = AddLangPrefix("method");
+Kind["displayName"] = "Constructor";
+break;
+  case APIRecord::RK_CXXDestructorMethod:
+Kind["identifier"] = AddLangPrefix("method");
+Kind["displayName"] = "Destructor";
+break;
   case APIRecord::RK_ObjCIvar:
 Kind["identifier"] = AddLangPrefix("ivar");
 Kind["displayName"] = "Instance Variable";
@@ -470,6 +510,31 @@
   Record, has_function_signature()));
 }
 
+template 
+std::optional serializeAccessMixinImpl(const RecordTy ,
+std::true_type) {
+  const auto  = Record.Access;
+  std::string Access;
+  if (AccessControl.empty())
+return std::nullopt;
+  Access = AccessControl.getAccess();
+  return Access;
+}
+
+template 
+std::optional serializeAccessMixinImpl(const RecordTy ,
+std::false_type) {
+  return std::nullopt;
+}
+
+template 
+void serializeAccessMixin(Object , const RecordTy ) {
+  auto accessLevel = serializeAccessMixinImpl(Record, has_access());
+  if (!accessLevel.has_value())
+accessLevel = "public";
+  serializeString(Paren, "accessLevel", accessLevel);
+}
+
 struct PathComponent {
   StringRef USR;
   StringRef Name;
@@ -543,7 +608,6 @@
 
   return ParentContexts;
 }
-
 } // namespace
 
 /// Defines the format version emitted by SymbolGraphSerializer.
@@ -602,9 +666,6 @@
   serializeObject(Obj, "docComment", serializeDocComment(Record.Comment));
   serializeArray(Obj, "declarationFragments",
  serializeDeclarationFragments(Record.Declaration));
-  // TODO: Once we keep track of symbol access information serialize it
-  // correctly here.
-  Obj["accessLevel"] = "public";
   SmallVector PathComponentsNames;
   // If this returns true it indicates that we couldn't find a symbol in the
   // hierarchy.
@@ -617,6 +678,7 @@
   serializeArray(Obj, "pathComponents", Array(PathComponentsNames));
 
   serializeFunctionSignatureMixin(Obj, Record);
+  serializeAccessMixin(Obj, Record);
 
   return Obj;
 }
@@ -698,6 +760,28 @@
   serializeMembers(Record, Record.Fields);
 }
 
+void SymbolGraphSerializer::visitStaticFieldRecord(
+const StaticFieldRecord ) {
+  auto StaticField = serializeAPIRecord(Record);
+  if (!StaticField)
+return;
+  Symbols.emplace_back(std::move(*StaticField));
+  

[PATCH] D154007: Reland "Try to implement lambdas with inalloca parameters by forwarding without use of inallocas."

2023-06-28 Thread Amy Huang via Phabricator via cfe-commits
akhuang added inline comments.



Comment at: clang/lib/CodeGen/CGCall.cpp:5103
 
-if (Addr.getAlignment() < Align &&
+if (CallInfo.isDelegateCall()) {
+  NeedCopy = false;

rnk wrote:
> akhuang wrote:
> > I think the problem is that it tries to do a copy here because the 
> > alignment of the forwarding function arg is larger than the alignment of 
> > the object that's being passed. I'm not sure how alignments are computed or 
> > if there are any other requirements for alignment. Is it ok to just ignore 
> > the new alignment? Do we need to change the code that computes the argument 
> > alignment?
> > 
> > (crbug.com/1457256#comment2 has an example repro)
> Yes, in general, structs with doubles and i64 members are passed misaligned 
> on i686. This is true for all functions, not just lambdas. We should power 
> down whatever alignment logic is causing the copy.
huh, ok, good to know. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154007

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


[PATCH] D154007: Reland "Try to implement lambdas with inalloca parameters by forwarding without use of inallocas."

2023-06-28 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added inline comments.



Comment at: clang/lib/CodeGen/CGCall.cpp:5103
 
-if (Addr.getAlignment() < Align &&
+if (CallInfo.isDelegateCall()) {
+  NeedCopy = false;

akhuang wrote:
> I think the problem is that it tries to do a copy here because the alignment 
> of the forwarding function arg is larger than the alignment of the object 
> that's being passed. I'm not sure how alignments are computed or if there are 
> any other requirements for alignment. Is it ok to just ignore the new 
> alignment? Do we need to change the code that computes the argument alignment?
> 
> (crbug.com/1457256#comment2 has an example repro)
Yes, in general, structs with doubles and i64 members are passed misaligned on 
i686. This is true for all functions, not just lambdas. We should power down 
whatever alignment logic is causing the copy.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154007

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


[PATCH] D154007: Reland "Try to implement lambdas with inalloca parameters by forwarding without use of inallocas."

2023-06-28 Thread Amy Huang via Phabricator via cfe-commits
akhuang added a comment.

In D154007#4457561 , @efriedma wrote:

> I'm not confident that isUsed() works the way you want it to in this context. 
>  In particular, if the code in question runs before we've translated the 
> whole translation unit, the isUsed() bit could change.  If you want that's 
> more obviously safe, you could just check if there are any captures.  (I'm 
> assuming the point of this is just to reduce the number of lambdas that go 
> through this codepath?)

Oh, thanks. Yeah, the point is we don't have to go down this path if we never 
have to emit the invoker.

In D154007#4457592 , @rnk wrote:

> Can you please add a test case for the issue that caused the revert? I wanted 
> to dig into that to try to understand why the extra copy was being emitted. I 
> think you mentioned it has something to do with increasing the alignment.

oops, I added comments when I put up the patch but never submitted them.. 
there's a repro in crbug.com/1457256 but I'll also add a test case




Comment at: clang/lib/CodeGen/CGCall.cpp:5103
 
-if (Addr.getAlignment() < Align &&
+if (CallInfo.isDelegateCall()) {
+  NeedCopy = false;

I think the problem is that it tries to do a copy here because the alignment of 
the forwarding function arg is larger than the alignment of the object that's 
being passed. I'm not sure how alignments are computed or if there are any 
other requirements for alignment. Is it ok to just ignore the new alignment? Do 
we need to change the code that computes the argument alignment?

(crbug.com/1457256#comment2 has an example repro)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154007

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


[PATCH] D154007: Reland "Try to implement lambdas with inalloca parameters by forwarding without use of inallocas."

2023-06-28 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

Can you please add a test case for the issue that caused the revert? I wanted 
to dig into that to try to understand why the extra copy was being emitted. I 
think you mentioned it has something to do with increasing the alignment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154007

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


[PATCH] D154007: Reland "Try to implement lambdas with inalloca parameters by forwarding without use of inallocas."

2023-06-28 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

I'm not confident that isUsed() works the way you want it to in this context.  
In particular, if the code in question runs before we've translated the whole 
translation unit, the isUsed() bit could change.  If you want that's more 
obviously safe, you could just check if there are any captures.  (I'm assuming 
the point of this is just to reduce the number of lambdas that go through this 
codepath?)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154007

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


[PATCH] D134334: [Clang] Fix crash in isCXXDeclarationSpecifier when attempting to annotate template name

2023-06-28 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added a comment.

I think I am going to land this as is and if we can come up w/ an example that 
covers the `annot_typename` I can do a follow-up. As this is now it fixes a 
crash bug.


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

https://reviews.llvm.org/D134334

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


[PATCH] D152953: [clang-tidy] Introduce fuchsia-global-variables check

2023-06-28 Thread Caslyn Tonelli via Phabricator via cfe-commits
Caslyn added a comment.

Hi Piotr - I'm sorry for the delay in getting back to you. Thank you again for 
your review comments. I did my best trying to get the right combination of 
matchers that limit the candidates and allow the exceptions that we want. I 
wasn't successful in figuring out a way to exempt static references to 
non-trivial destructor classes that don't have the lifetime extension (see 
comment).




Comment at: clang-tools-extra/clang-tidy/fuchsia/GlobalVariablesCheck.cpp:35
+  Finder->addMatcher(
+  varDecl(is_global_or_static_candidate,
+  unless(hasType(cxxRecordDecl(hasAnyName(IgnoreVars)

PiotrZSL wrote:
> only classes can be non trivial to destroy, so we should exclude on this 
> level all types that are not CXXRecordDecl.
In the latest revision I narrowed the matching candidates to: 

```
 anyOf(hasType(hasCanonicalType(references(qualType(,
hasType(arrayType()),
hasType(cxxRecordDecl(hasNonTrivialDestructor(,
```

I found I needed to capture arrays and references in the tests and included 
those in the limited candidates.

However, after a lot of testing and experimenting with 
`materializeTemporaryExpr` and your suggestions, I still couldn't figure out a 
way to allow references without lifetime extensions. For ex, this test gives a 
false positive with the latest patch:

```
  // Static references with function scope are allowed if they don't have
  // lifetime-extension.
  static const NonTriviallyDestructibleClass  = *new 
NonTriviallyDestructibleClass;
```

I've been starting to question if this is a general enough use case to include 
as an exception. Do you think it would be a mistake if this check does not 
allow static references to non-trivial destructors, regardless of a lifetime 
extension?  



Comment at: clang-tools-extra/clang-tidy/fuchsia/GlobalVariablesCheck.cpp:36
+  varDecl(is_global_or_static_candidate,
+  unless(hasType(cxxRecordDecl(hasAnyName(IgnoreVars)
+  .bind("global_var"),

PiotrZSL wrote:
> PiotrZSL wrote:
> > could be better, like in other checks.
> 
I went ahead and combined the two suggestions around the `IgnoreVars` matching .



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/fuchsia/global-variables.cpp:103
+ntdc_ref typedef_ref_ntdc =
+*new NonTriviallyDestructibleClass;
+

PiotrZSL wrote:
> that will act just like alias
> ``NonTriviallyDestructibleClass XYZ;
> typedef_ref_ntdc  = XYZ;``
> this ``new`` here is confusing... both examples should be made simpler.
I got rid of these scenarios and tested typedef to a reference per your 
suggestion in the latest patch - hopefully I captured it correctly:

> typedef for const reference of non trivial type that is used to exend 
> lfietime of variable (calling function that returns object with non trivial 
> destructor).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152953

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


[PATCH] D152953: [clang-tidy] Introduce fuchsia-global-variables check

2023-06-28 Thread Caslyn Tonelli via Phabricator via cfe-commits
Caslyn updated this revision to Diff 535546.
Caslyn marked 12 inline comments as done.
Caslyn added a comment.

Changes per review.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152953

Files:
  clang-tools-extra/clang-tidy/fuchsia/CMakeLists.txt
  clang-tools-extra/clang-tidy/fuchsia/FuchsiaTidyModule.cpp
  clang-tools-extra/clang-tidy/fuchsia/GlobalVariablesCheck.cpp
  clang-tools-extra/clang-tidy/fuchsia/GlobalVariablesCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/fuchsia/global-variables.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/test/clang-tidy/checkers/fuchsia/global-variables.cpp
  llvm/utils/gn/secondary/clang-tools-extra/clang-tidy/fuchsia/BUILD.gn

Index: llvm/utils/gn/secondary/clang-tools-extra/clang-tidy/fuchsia/BUILD.gn
===
--- llvm/utils/gn/secondary/clang-tools-extra/clang-tidy/fuchsia/BUILD.gn
+++ llvm/utils/gn/secondary/clang-tools-extra/clang-tidy/fuchsia/BUILD.gn
@@ -16,6 +16,7 @@
 "DefaultArgumentsDeclarationsCheck.cpp",
 "FuchsiaTidyModule.cpp",
 "MultipleInheritanceCheck.cpp",
+"GlobalVariablesCheck.cpp",
 "OverloadedOperatorCheck.cpp",
 "StaticallyConstructedObjectsCheck.cpp",
 "TrailingReturnCheck.cpp",
Index: clang-tools-extra/test/clang-tidy/checkers/fuchsia/global-variables.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/fuchsia/global-variables.cpp
@@ -0,0 +1,183 @@
+// RUN: %check_clang_tidy %s fuchsia-global-variables %t \
+// RUN: -config="{CheckOptions: \
+// RUN:   [{key: fuchsia-global-variables.Ignore, value: 'LazyRE2;ThreadLocal'}] \
+// RUN:  }"
+
+using size_t = decltype(sizeof(int));
+
+class TriviallyDestructibleClass {
+ public:
+  // This is a trivially destructible class.
+  int I;
+  float F;
+  char C;
+  char Cs[10];
+};
+
+class NonTriviallyDestructibleClass {
+ public:
+  // We need a destructor to make the class non trivially destructible.
+  ~NonTriviallyDestructibleClass() { Var = 0; }
+  int Var;
+};
+
+template 
+class NonTriviallyDestructibleTemplateClass {
+ public:
+  // We need a destructor to make the class non trivially destructible.
+  ~NonTriviallyDestructibleTemplateClass() { Var = 0; }
+  int Var;
+  T Var2;
+};
+
+int GlobalI;
+_Atomic size_t GlobalAtomic;
+
+TriviallyDestructibleClass Tdc;
+
+NonTriviallyDestructibleClass Ntdc;
+// CHECK-MESSAGES: [[@LINE-1]]:31: warning: non trivially destructible static and global variables are forbidden [fuchsia-global-variables]
+
+[[clang::no_destroy]] NonTriviallyDestructibleClass NtdcNoDestory;
+
+TriviallyDestructibleClass TdcArray[2] = { TriviallyDestructibleClass(), TriviallyDestructibleClass()};
+
+NonTriviallyDestructibleClass NtdcArray[2] = {
+NonTriviallyDestructibleClass(), NonTriviallyDestructibleClass()};
+// CHECK-MESSAGES: [[@LINE-2]]:31: warning: non trivially destructible static and global variables are forbidden [fuchsia-global-variables]
+
+const TriviallyDestructibleClass TdcConstArray[2] = {
+TriviallyDestructibleClass(), TriviallyDestructibleClass()};
+
+const NonTriviallyDestructibleClass NtdcConstArray[2] = {
+NonTriviallyDestructibleClass(), NonTriviallyDestructibleClass()};
+// CHECK-MESSAGES: [[@LINE-2]]:37: warning: non trivially destructible static and global variables are forbidden [fuchsia-global-variables]
+
+TriviallyDestructibleClass TdcMultiArray[2][2] = {
+{TriviallyDestructibleClass(), TriviallyDestructibleClass()},
+{TriviallyDestructibleClass(), TriviallyDestructibleClass()}};
+
+NonTriviallyDestructibleClass NtdcMultiArray[2][2] = {
+{NonTriviallyDestructibleClass(), NonTriviallyDestructibleClass()},
+{NonTriviallyDestructibleClass(), NonTriviallyDestructibleClass()}};
+// CHECK-MESSAGES: [[@LINE-3]]:31: warning: non trivially destructible static and global variables are forbidden [fuchsia-global-variables]
+
+const TriviallyDestructibleClass TdcMultiConstArray[2][2] = {
+{TriviallyDestructibleClass(), TriviallyDestructibleClass()},
+{TriviallyDestructibleClass(), TriviallyDestructibleClass()}};
+
+const NonTriviallyDestructibleClass NtdcMultiConstArray[2][2] = {
+{NonTriviallyDestructibleClass(), NonTriviallyDestructibleClass()},
+{NonTriviallyDestructibleClass(), NonTriviallyDestructibleClass()}};
+// CHECK-MESSAGES: [[@LINE-3]]:37: warning: non trivially destructible static and global variables are forbidden [fuchsia-global-variables]
+
+typedef TriviallyDestructibleClass TDCArray[1];
+TDCArray TdcTypedefArray[1];
+
+typedef NonTriviallyDestructibleClass NTDCArray[1];
+NTDCArray NTdcTypedefArray[1];
+// CHECK-MESSAGES: [[@LINE-1]]:11: warning: non trivially destructible static and global variables are forbidden [fuchsia-global-variables]
+
+const 

[PATCH] D89918: Fix issue: clang-format result is not consistent if "// clang-format off" is followed by macro definition.

2023-06-28 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a comment.

This is no longer an issue in version 17, e.g. 7a4cdbe 
:

  $ clang-format
  void main()
  {
  // clang-format off
  #define Sum(x, y) ((x) + (y))
  Sum(1, 2);
  #undef Sum
  // clang-format on
  }
  void main() {
// clang-format off
  #define Sum(x, y) ((x) + (y))
  Sum(1, 2);
  #undef Sum
// clang-format on
  }


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89918

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


[PATCH] D153898: [DebugInfo] Enable debug info emission for extern variables in C++

2023-06-28 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

> This patch is required so that we can still use kconfig in such BPF programs 
> compiled from C++.

Assuming that you mean 
https://www.kernel.org/doc/html/next/kbuild/kconfig-language.html#kconfig-language
 , how is Kconfig relevant here?

Clang BPF supports `-mcpu=v[123]`. v1 is for a very old kernel. 
https://pchaigno.github.io/bpf/2021/10/20/ebpf-instruction-sets.html 
I think there are some users so we cannot remove the support. Is it happy with 
the new behavior?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153898

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


[PATCH] D153898: [DebugInfo] Enable debug info emission for extern variables in C++

2023-06-28 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

I wonder whether you have ready-to-use instructions to test this for folks who 
are not familiar with Linux kernel/eBPF. (I happened to start to read eBPF one 
week ago, but I guess it would take some time for me to be more familiar with 
it, even if I contributed some stuff back in 2020)

  # /tmp/Rel is a llvm-project build directory.
  ninja -C /tmp/Rel clang lld llvm-{ar,nm,strings,objdump,objcopy,readelf,strip}
  
  # In a Linux kernel tree,
  PATH=/tmp/Rel/bin:$PATH make O=/tmp/linux/x86_64 LLVM=1 defconfig all -j 50
  
  qemu-system-x86_64 ...
  
  clang -O2 -emit-llvm -c bpf.c -o - | llc -march=bpf -filetype=obj -o bpf.o
  
  Run XXX command to load bpf.o into some tools, say, tc
  Run XXX command to inspect that the tool is happy with new Clang behavior


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153898

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


[PATCH] D153926: [NFC] Initialize class member pointers to nullptr.

2023-06-28 Thread Owen Pan via Phabricator via cfe-commits
owenpan accepted this revision.
owenpan added a comment.

In D153926#4456833 , @schittir wrote:

> Not sure what clang-format wants. I hope it likes this patch.

The clang-format part LGTM. Thanks!


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

https://reviews.llvm.org/D153926

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


[PATCH] D154007: Reland "Try to implement lambdas with inalloca parameters by forwarding without use of inallocas."

2023-06-28 Thread Amy Huang via Phabricator via cfe-commits
akhuang created this revision.
Herald added a project: All.
akhuang requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This reverts commit 8ed7aa59f489715d39d32e72a787b8e75cfda151 
.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D154007

Files:
  clang/include/clang/CodeGen/CGFunctionInfo.h
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CGCall.h
  clang/lib/CodeGen/CGClass.cpp
  clang/lib/CodeGen/CGDeclCXX.cpp
  clang/lib/CodeGen/CodeGenABITypes.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/CodeGen/CodeGenTypes.h
  clang/lib/CodeGen/Targets/X86.cpp
  clang/test/CodeGenCXX/inalloca-lambda.cpp

Index: clang/test/CodeGenCXX/inalloca-lambda.cpp
===
--- clang/test/CodeGenCXX/inalloca-lambda.cpp
+++ clang/test/CodeGenCXX/inalloca-lambda.cpp
@@ -1,11 +1,50 @@
-// RUN: not %clang_cc1 -triple i686-windows-msvc -emit-llvm -o /dev/null %s  2>&1 | FileCheck %s
+// RUN: %clang_cc1 -triple i686-windows-msvc -emit-llvm -o - %s  2>&1 | FileCheck %s
 
-// PR28299
-// CHECK: error: cannot compile this forwarded non-trivially copyable parameter yet
-
-class A {
+struct A {
+  A();
   A(const A &);
+  int x;
 };
-typedef void (*fptr_t)(A);
-fptr_t fn1() { return [](A) {}; }
+void decayToFp(int (*f)(A));
+void test() {
+  auto ld = [](A a) {
+static int calls = 0;
+++calls;
+return a.x + calls;
+  };
+  decayToFp(ld);
+  ld(A{});
+}
+
+// CHECK: define internal x86_thiscallcc noundef i32 
+// CHECK-SAME: @"??R@?0??test@@YAXXZ@QBE?A?@@UA@@@Z"
+// CHECK-SAME: (ptr noundef %this, ptr inalloca(<{ %struct.A }>) %[[ARG:.*]])
+// CHECK: %[[V:.*]] = getelementptr inbounds <{ %struct.A }>, ptr %[[ARG]], i32 0, i32 0
+// CHECK: %call = call x86_thiscallcc noundef i32 
+// CHECK-SAME: @"?__impl@@?0??test@@YAXXZ@QBE?A?@@UA@@@Z"
+// CHECK-SAME: (ptr noundef %this, ptr noundef %[[V]])
+
+// CHECK: define internal noundef i32
+// CHECK-SAME: @"?__invoke@@?0??test@@YAXXZ@CA?A?@@UA@@@Z"
+// CHECK-SAME: (ptr inalloca(<{ %struct.A }>) %[[ARG:.*]])
+// CHECK: %unused.capture = alloca %class.anon, align 1
+// CHECK: %[[VAR:.*]] = getelementptr inbounds <{ %struct.A }>, ptr %[[ARG]], i32 0, i32 0
+// CHECK: %call = call x86_thiscallcc noundef i32
+// CHECK-SAME: @"?__impl@@?0??test@@YAXXZ@QBE?A?@@UA@@@Z"
+// CHECK-SAME: (ptr noundef %unused.capture, ptr noundef %[[VAR]])
+// CHECK: ret i32 %call 
 
+// CHECK: define internal x86_thiscallcc noundef i32
+// CHECK-SAME: @"?__impl@@?0??test@@YAXXZ@QBE?A?@@UA@@@Z"
+// CHECK-SAME: (ptr noundef %this, ptr noundef %[[ARG:.*]])
+// CHECK: %this.addr = alloca ptr, align 4
+// CHECK: store ptr %this, ptr %this.addr, align 4
+// CHECK: %this1 = load ptr, ptr %this.addr, align 4
+// CHECK: %{{.*}} = load i32, ptr @"?calls@?1???R
+// CHECK: %inc = add nsw i32 %{{.*}}, 1
+// CHECK: store i32 %inc, ptr @"?calls@?1???R
+// CHECK: %{{.*}} = getelementptr inbounds %struct.A, ptr %{{.*}}, i32 0, i32 0
+// CHECK: %{{.*}} = load i32, ptr %{{.*}}, align 4
+// CHECK: %{{.*}} = load i32, ptr @"?calls@?1???R
+// CHECK: %add = add nsw i32 %{{.*}}, %{{.*}}
+// CHECK: ret i32 %add
Index: clang/lib/CodeGen/Targets/X86.cpp
===
--- clang/lib/CodeGen/Targets/X86.cpp
+++ clang/lib/CodeGen/Targets/X86.cpp
@@ -140,7 +140,8 @@
 
   Class classify(QualType Ty) const;
   ABIArgInfo classifyReturnType(QualType RetTy, CCState ) const;
-  ABIArgInfo classifyArgumentType(QualType RetTy, CCState ) const;
+  ABIArgInfo classifyArgumentType(QualType RetTy, CCState ,
+  bool isDelegateCall) const;
 
   /// Updates the number of available free registers, returns
   /// true if any registers were allocated.
@@ -738,8 +739,8 @@
   }
 }
 
-ABIArgInfo X86_32ABIInfo::classifyArgumentType(QualType Ty,
-   CCState ) const {
+ABIArgInfo X86_32ABIInfo::classifyArgumentType(QualType Ty, CCState ,
+   bool isDelegateCall) const {
   // FIXME: Set alignment on indirect arguments.
   bool IsFastCall = State.CC == llvm::CallingConv::X86_FastCall;
   bool IsRegCall = State.CC == llvm::CallingConv::X86_RegCall;
@@ -752,7 +753,7 @@
   const RecordType *RT = Ty->getAs();
   if (RT) {
 CGCXXABI::RecordArgABI RAA = getRecordArgABI(RT, getCXXABI());
-if (RAA == CGCXXABI::RAA_Indirect) {
+if (RAA == CGCXXABI::RAA_Indirect || isDelegateCall) {
   return getIndirectResult(Ty, false, State);
 } else if (RAA == CGCXXABI::RAA_DirectInMemory) {
   // The field index doesn't matter, we'll fix it up later.
@@ -941,7 +942,8 @@
 if (State.IsPreassigned.test(I))
   continue;
 
-Args[I].info = classifyArgumentType(Args[I].type, State);
+Args[I].info =
+

[PATCH] D153898: [DebugInfo] Enable debug info emission for extern variables in C++

2023-06-28 Thread Yuze Chi via Phabricator via cfe-commits
chiyuze added a comment.

Regarding cost, only BPF target triggers this debug info generation for extern 
variables. There is no impact on x86 builds of clang:

Without patch:

  bloaty build/RelWithDebInfo/83d47ba15a1229a21aaca8a8d6a33e0e90aabfd4/bin/clang
  FILE SIZEVM SIZE
   --  -- 
74.7%  2.98Gi   0.0%   0.debug_info
 9.2%   377Mi   0.0%   0.debug_loclists
 5.2%   210Mi   0.0%   0.debug_str
 4.3%   177Mi   0.0%   0.debug_line
 2.0%  81.5Mi  53.7%  81.5Mi.text
 1.7%  68.0Mi   0.0%   0.debug_rnglists
 1.1%  43.2Mi  28.5%  43.2Mi.rodata
 0.5%  21.4Mi   0.0%   0.debug_abbrev
 0.5%  20.3Mi   0.0%   0.strtab
 0.2%  8.79Mi   5.8%  8.79Mi.eh_frame
 0.2%  6.73Mi   4.4%  6.73Mi.rela.dyn
 0.1%  4.86Mi   0.0%   0.symtab
 0.1%  4.09Mi   2.7%  4.09Mi.dynstr
 0.1%  3.60Mi   2.4%  3.60Mi.data.rel.ro
 0.1%  3.30Mi   0.0%   0.debug_aranges
 0.0%  1.19Mi   0.8%  1.19Mi.dynsym
 0.0%  1.09Mi   0.7%  1.09Mi.eh_frame_hdr
 0.0%   0   0.4%   611Ki.bss
 0.0%   449Ki   0.1%   127Ki[25 Others]
 0.0%   393Ki   0.3%   393Ki.gnu.hash
 0.0%   332Ki   0.2%   332Ki.data
   100.0%  3.99Gi 100.0%   151MiTOTAL

With patch:

  bloaty build/RelWithDebInfo/23bc4427ab49716ce2c24c81529d9c90953b3c54/bin/clang
  FILE SIZEVM SIZE
   --  -- 
74.7%  2.98Gi   0.0%   0.debug_info
 9.2%   377Mi   0.0%   0.debug_loclists
 5.2%   210Mi   0.0%   0.debug_str
 4.3%   177Mi   0.0%   0.debug_line
 2.0%  81.5Mi  53.7%  81.5Mi.text
 1.7%  68.0Mi   0.0%   0.debug_rnglists
 1.1%  43.2Mi  28.5%  43.2Mi.rodata
 0.5%  21.4Mi   0.0%   0.debug_abbrev
 0.5%  20.3Mi   0.0%   0.strtab
 0.2%  8.79Mi   5.8%  8.79Mi.eh_frame
 0.2%  6.73Mi   4.4%  6.73Mi.rela.dyn
 0.1%  4.86Mi   0.0%   0.symtab
 0.1%  4.09Mi   2.7%  4.09Mi.dynstr
 0.1%  3.60Mi   2.4%  3.60Mi.data.rel.ro
 0.1%  3.30Mi   0.0%   0.debug_aranges
 0.0%  1.19Mi   0.8%  1.19Mi.dynsym
 0.0%  1.09Mi   0.7%  1.09Mi.eh_frame_hdr
 0.0%   0   0.4%   611Ki.bss
 0.0%   449Ki   0.1%   127Ki[25 Others]
 0.0%   393Ki   0.3%   393Ki.gnu.hash
 0.0%   332Ki   0.2%   332Ki.data
   100.0%  3.99Gi 100.0%   151MiTOTAL

For BPF, this debug info is needed to generate proper BTF and use kconfig 
.
 This patch just enables it for C++, which makes it possible for us to leverage 
templates to deduplicate almost identical BPF code for IPv4 and IPv6.

https://reviews.llvm.org/D70696 has more details regarding why it is needed for 
BPF in general and 
https://lore.kernel.org/bpf/cakh8qbt4xqbupxefqpk5ayu1rr0-h-vcjzs_0bu-987gl4w...@mail.gmail.com/
 has more details regarding why we are trying to compile BPF from C++.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153898

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


[PATCH] D153667: [HIP]: Add -fhip-emit-relocatable to override link job creation for -fno-gpu-rdc

2023-06-28 Thread Jeffrey Byrnes via Phabricator via cfe-commits
jrbyrnes added inline comments.



Comment at: clang/lib/Driver/Driver.cpp:3328-3330
+  CompileDeviceOnly = C.getDriver().offloadDeviceOnly();
+  Relocatable = Args.hasFlag(options::OPT_fgpu_rdc,
+ options::OPT_fno_gpu_rdc, /*Default=*/false);

yaxunl wrote:
> probably needs to be moved to ctor of CudaActionBuilderBase since they are 
> needed by both Cuda and HIP action builders.
Thanks


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153667

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


[PATCH] D153667: [HIP]: Add -fhip-emit-relocatable to override link job creation for -fno-gpu-rdc

2023-06-28 Thread Jeffrey Byrnes via Phabricator via cfe-commits
jrbyrnes updated this revision to Diff 535519.
jrbyrnes marked 3 inline comments as done.
jrbyrnes added a comment.

Address Comment


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153667

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/Driver.cpp
  clang/test/Driver/hip-dependent-options.hip
  clang/test/Driver/hip-device-compile.hip
  clang/test/Driver/hip-phases.hip
  clang/test/Driver/hip-rdc-device-only.hip

Index: clang/test/Driver/hip-rdc-device-only.hip
===
--- clang/test/Driver/hip-rdc-device-only.hip
+++ clang/test/Driver/hip-rdc-device-only.hip
@@ -18,6 +18,16 @@
 // RUN:   %S/Inputs/hip_multiple_inputs/b.hip --gpu-bundle-output \
 // RUN: 2>&1 | FileCheck -check-prefixes=COMMON,EMITBC %s
 
+// With `-fno-hip-emit-relocatable`, the output should be the same as the aforementioned line
+// as `-fgpu-rdc` in HIP implies `-fno-hip-emit-relocatable`.
+
+// RUN: %clang -### --target=x86_64-linux-gnu \
+// RUN:   -x hip --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 \
+// RUN:   -c -fno-hip-emit-relocatable -nogpuinc -nogpulib --cuda-device-only -fgpu-rdc \
+// RUN:   %S/Inputs/hip_multiple_inputs/a.cu \
+// RUN:   %S/Inputs/hip_multiple_inputs/b.hip --gpu-bundle-output \
+// RUN: 2>&1 | FileCheck -check-prefixes=COMMON,EMITBC %s
+
 // RUN: %clang -### --target=x86_64-linux-gnu \
 // RUN:   -x hip --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 \
 // RUN:   -S -nogpuinc -nogpulib --cuda-device-only -fgpu-rdc \
Index: clang/test/Driver/hip-phases.hip
===
--- clang/test/Driver/hip-phases.hip
+++ clang/test/Driver/hip-phases.hip
@@ -244,6 +244,43 @@
 // DASM-NOT: clang-offload-bundler
 // DASM-NOT: host
 
+//
+// Test single gpu architecture with compile to relocatable in device-only
+// compilation mode.
+//
+// RUN: %clang -x hip --target=x86_64-unknown-linux-gnu -ccc-print-phases \
+// RUN: --cuda-gpu-arch=gfx803 %s --cuda-device-only -fhip-emit-relocatable 2>&1 \
+// RUN: | FileCheck -check-prefixes=RELOC %s
+// RELOC-DAG: [[P0:[0-9]+]]: input, "{{.*}}hip-phases.hip", [[T:hip]], (device-[[T]], [[ARCH:gfx803]])
+// RELOC-DAG: [[P1:[0-9]+]]: preprocessor, {[[P0]]}, [[T]]-cpp-output, (device-[[T]], [[ARCH]])
+// RELOC-DAG: [[P2:[0-9]+]]: compiler, {[[P1]]}, ir, (device-[[T]], [[ARCH]])
+// RELOC-DAG: [[P3:[0-9]+]]: backend, {[[P2]]}, assembler, (device-[[T]], [[ARCH]])
+// RELOC-DAG: [[P4:[0-9]+]]: assembler, {[[P3]]}, object, (device-[[T]], [[ARCH]])
+// RELOC-NOT: linker
+// RELOC-DAG: [[P5:[0-9]+]]: offload, "device-[[T]] (amdgcn-amd-amdhsa:[[ARCH]])" {[[P4]]}, object
+
+//
+// Test two gpu architectures with compile to relocatable in device-only
+// compilation mode.
+//
+// RUN: %clang -x hip --target=x86_64-unknown-linux-gnu -ccc-print-phases \
+// RUN: --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 %s --cuda-device-only -fhip-emit-relocatable 2>&1 \
+// RUN: | FileCheck -check-prefixes=RELOC2 %s
+// RELOC2-DAG: [[P0:[0-9]+]]: input, "{{.*}}hip-phases.hip", [[T:hip]], (device-[[T]], [[ARCH:gfx803]])
+// RELOC2-DAG: [[P1:[0-9]+]]: preprocessor, {[[P0]]}, [[T]]-cpp-output, (device-[[T]], [[ARCH]])
+// RELOC2-DAG: [[P2:[0-9]+]]: compiler, {[[P1]]}, ir, (device-[[T]], [[ARCH]])
+// RELOC2-DAG: [[P3:[0-9]+]]: backend, {[[P2]]}, assembler, (device-[[T]], [[ARCH]])
+// RELOC2-DAG: [[P4:[0-9]+]]: assembler, {[[P3]]}, object, (device-[[T]], [[ARCH]])
+// RELOC2-NOT: [[P5:[0-9]+]]: linker, {[[P4]]}, image, (device-[[T]], [[ARCH]])
+// RELOC2-DAG: [[P5:[0-9]+]]: offload, "device-[[T]] (amdgcn-amd-amdhsa:[[ARCH]])" {[[P4]]}, object
+// RELOC2-DAG: [[P6:[0-9]+]]: input, "{{.*}}hip-phases.hip", [[T:hip]], (device-[[T]], [[ARCH2:gfx900]])
+// RELOC2-DAG: [[P7:[0-9]+]]: preprocessor, {[[P6]]}, [[T]]-cpp-output, (device-[[T]], [[ARCH2]])
+// RELOC2-DAG: [[P8:[0-9]+]]: compiler, {[[P7]]}, ir, (device-[[T]], [[ARCH2]])
+// RELOC2-DAG: [[P9:[0-9]+]]: backend, {[[P8]]}, assembler, (device-[[T]], [[ARCH2]])
+// RELOC2-DAG: [[P10:[0-9]+]]: assembler, {[[P9]]}, object, (device-[[T]], [[ARCH2]])
+// RELOC2-NOT: linker
+// RELOC2-DAG: [[P11:[0-9]+]]: offload, "device-[[T]] (amdgcn-amd-amdhsa:[[ARCH2]])" {[[P10]]}, object
+
 //
 // Test two gpu architectures with complete compilation in device-only
 // compilation mode.
Index: clang/test/Driver/hip-device-compile.hip
===
--- clang/test/Driver/hip-device-compile.hip
+++ clang/test/Driver/hip-device-compile.hip
@@ -45,6 +45,14 @@
 // RUN:   %S/Inputs/hip_multiple_inputs/a.cu \
 // RUN: 2>&1 | FileCheck -check-prefixes=CHECK,ASM,NBUN %s
 
+// Output relocatable.
+// RUN: %clang -c --cuda-device-only -### --target=x86_64-linux-gnu \
+// RUN:   -o a.o -x hip --cuda-gpu-arch=gfx900 -fhip-emit-relocatable \
+// RUN:   --hip-device-lib=lib1.bc \
+// RUN:   

[clang] fe65043 - HIP: Directly call floor builtins

2023-06-28 Thread Matt Arsenault via cfe-commits

Author: Matt Arsenault
Date: 2023-06-28T16:57:53-04:00
New Revision: fe65043a67c85345887339f371cca1a0c735a639

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

LOG: HIP: Directly call floor builtins

Added: 


Modified: 
clang/lib/Headers/__clang_hip_math.h
clang/test/Headers/__clang_hip_math.hip
clang/test/Headers/hip-header.hip

Removed: 




diff  --git a/clang/lib/Headers/__clang_hip_math.h 
b/clang/lib/Headers/__clang_hip_math.h
index 26c2f77c82c63..a914496cb7b14 100644
--- a/clang/lib/Headers/__clang_hip_math.h
+++ b/clang/lib/Headers/__clang_hip_math.h
@@ -239,7 +239,7 @@ __DEVICE__
 float fdividef(float __x, float __y) { return __x / __y; }
 
 __DEVICE__
-float floorf(float __x) { return __ocml_floor_f32(__x); }
+float floorf(float __x) { return __builtin_floorf(__x); }
 
 __DEVICE__
 float fmaf(float __x, float __y, float __z) {
@@ -787,7 +787,7 @@ __DEVICE__
 double fdim(double __x, double __y) { return __ocml_fdim_f64(__x, __y); }
 
 __DEVICE__
-double floor(double __x) { return __ocml_floor_f64(__x); }
+double floor(double __x) { return __builtin_floor(__x); }
 
 __DEVICE__
 double fma(double __x, double __y, double __z) {

diff  --git a/clang/test/Headers/__clang_hip_math.hip 
b/clang/test/Headers/__clang_hip_math.hip
index e507aa3ccf4ef..8e5201a89ceca 100644
--- a/clang/test/Headers/__clang_hip_math.hip
+++ b/clang/test/Headers/__clang_hip_math.hip
@@ -909,13 +909,13 @@ extern "C" __device__ float test_fdividef(float x, float 
y) {
 
 // DEFAULT-LABEL: @test_floorf(
 // DEFAULT-NEXT:  entry:
-// DEFAULT-NEXT:[[CALL_I:%.*]] = tail call contract float 
@__ocml_floor_f32(float noundef [[X:%.*]]) #[[ATTR14]]
-// DEFAULT-NEXT:ret float [[CALL_I]]
+// DEFAULT-NEXT:[[TMP0:%.*]] = tail call contract float 
@llvm.floor.f32(float [[X:%.*]])
+// DEFAULT-NEXT:ret float [[TMP0]]
 //
 // FINITEONLY-LABEL: @test_floorf(
 // FINITEONLY-NEXT:  entry:
-// FINITEONLY-NEXT:[[CALL_I:%.*]] = tail call nnan ninf contract 
nofpclass(nan inf) float @__ocml_floor_f32(float noundef nofpclass(nan inf) 
[[X:%.*]]) #[[ATTR14]]
-// FINITEONLY-NEXT:ret float [[CALL_I]]
+// FINITEONLY-NEXT:[[TMP0:%.*]] = tail call nnan ninf contract float 
@llvm.floor.f32(float [[X:%.*]])
+// FINITEONLY-NEXT:ret float [[TMP0]]
 //
 extern "C" __device__ float test_floorf(float x) {
   return floorf(x);
@@ -923,13 +923,13 @@ extern "C" __device__ float test_floorf(float x) {
 
 // DEFAULT-LABEL: @test_floor(
 // DEFAULT-NEXT:  entry:
-// DEFAULT-NEXT:[[CALL_I:%.*]] = tail call contract double 
@__ocml_floor_f64(double noundef [[X:%.*]]) #[[ATTR14]]
-// DEFAULT-NEXT:ret double [[CALL_I]]
+// DEFAULT-NEXT:[[TMP0:%.*]] = tail call contract double 
@llvm.floor.f64(double [[X:%.*]])
+// DEFAULT-NEXT:ret double [[TMP0]]
 //
 // FINITEONLY-LABEL: @test_floor(
 // FINITEONLY-NEXT:  entry:
-// FINITEONLY-NEXT:[[CALL_I:%.*]] = tail call nnan ninf contract 
nofpclass(nan inf) double @__ocml_floor_f64(double noundef nofpclass(nan inf) 
[[X:%.*]]) #[[ATTR14]]
-// FINITEONLY-NEXT:ret double [[CALL_I]]
+// FINITEONLY-NEXT:[[TMP0:%.*]] = tail call nnan ninf contract double 
@llvm.floor.f64(double [[X:%.*]])
+// FINITEONLY-NEXT:ret double [[TMP0]]
 //
 extern "C" __device__ double test_floor(double x) {
   return floor(x);

diff  --git a/clang/test/Headers/hip-header.hip 
b/clang/test/Headers/hip-header.hip
index 38567cb3b202f..7d7b5e7176d9d 100644
--- a/clang/test/Headers/hip-header.hip
+++ b/clang/test/Headers/hip-header.hip
@@ -103,7 +103,7 @@ __device__ size_t test_size_t() {
 // Check there is no ambiguity when calling overloaded math functions.
 
 // CHECK-LABEL: define{{.*}}@_Z10test_floorv
-// CHECK: call {{.*}}double @__ocml_floor_f64(double
+// CHECK: call {{.*}}double @llvm.floor.f64(double
 __device__ float test_floor() {
   return floor(5);
 }



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


[PATCH] D153600: Implement -frecord-command-line for XCOFF

2023-06-28 Thread Scott Linder via Phabricator via cfe-commits
scott.linder added a comment.

Sorry for the delay in review, I am not too familiar with XCOFF so I was hoping 
someone else would take a look first.

If my understanding of the COFF docs I could find is correct then this LGTM 
save for some nits/suggestions




Comment at: llvm/lib/MC/MCAsmStreamer.cpp:970-1037
+void MCAsmStreamer::emitXCOFFCInfoSym(StringRef Name, StringRef Metadata) {
+  const char *InfoDirective = "\t.info ";
+
+  // Start by emitting the .info pseudo-op and C_INFO symbol name
+  OS << InfoDirective;
+  PrintQuotedString(Name, OS);
+  OS << ", ";

I sketched out some of the suggestions I had, although the bigger changes are 
just because the extra `.info` for the padded byte bugged me. If you aren't 
concerned with it I'm also happy with what you have



Comment at: llvm/lib/MC/MCAsmStreamer.cpp:980
+  size_t MetadataSize = Metadata.size();
+  uint32_t MetadataPaddingSize = 3 - (MetadataSize - 1) % 4;
+

I couldn't quickly find a reference for the alignment requirement, but it seems 
like there is an additional requirement that the length must also be non-zero, 
not just even?

If so, can you update the comment?

I would also rather explicitly use `alignTo` and `max` to express this (see 
suggestion), but if we don't expect the optimizer to clean it up I'm fine with 
the more terse version.



Comment at: llvm/lib/MC/MCAsmStreamer.cpp:980
+  size_t MetadataSize = Metadata.size();
+  uint32_t MetadataPaddingSize = 3 - (MetadataSize - 1) % 4;
+

scott.linder wrote:
> I couldn't quickly find a reference for the alignment requirement, but it 
> seems like there is an additional requirement that the length must also be 
> non-zero, not just even?
> 
> If so, can you update the comment?
> 
> I would also rather explicitly use `alignTo` and `max` to express this (see 
> suggestion), but if we don't expect the optimizer to clean it up I'm fine 
> with the more terse version.
Can you factor this out at function scope? It gets repeated below



Comment at: llvm/lib/MC/MCAsmStreamer.cpp:984
+  uint32_t Length = MetadataSize + MetadataPaddingSize;
+  OS << format_hex(uint32_t(Length), 10) << ",";
+  EmitEOL();

Redundant cast



Comment at: llvm/lib/MC/MCAsmStreamer.cpp:988
+  // Return the remaining bytes padded with 0s.
+  auto GetLastWord = [](const uint8_t *Data,
+uint32_t PaddingBytes) -> uint32_t {

It seems odd to use a lambda when this is only used once. Why not just compute 
the last word directly?



Comment at: llvm/lib/MC/MCAsmStreamer.cpp:1033
+MetadataPaddingSize);
+OS << InfoDirective << ", ";
+OS << format_hex(LastWord, 10);

Can you factor this out as `Separator` at function scope?



Comment at: llvm/test/CodeGen/PowerPC/aix-command-line-metadata.ll:21
+; Trailing padding:
+; ASM: .info , 0x3233
+

Having the padded byte force a new `.info` directive doesn't seem ideal. I 
suggested something to avoid it, but I suppose it also doesn't really harm 
anything.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153600

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


[PATCH] D146777: [clang] Preliminary fat-lto-object support

2023-06-28 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

As mentioned, you may consider landing llvm patch then wait a bit so that (a) 
people can experiment with the clang patch better (b) prevent the llvm/clang 
patches to be both reverted, if some issue has been identified with the llvm 
patch.
(Don't worry that a feature doesn't have contiguous commits. It's common.)

I do not accept the lld part now, just to have more time to ensure the llvm and 
clang part is mature :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146777

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


[PATCH] D154000: HIP: Directly call round builtins

2023-06-28 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm created this revision.
arsenm added reviewers: JonChesterfield, yaxunl, jhuber6.
Herald added a project: All.
arsenm requested review of this revision.
Herald added a subscriber: wdng.

Pretty sure these lround->round cases are just wrong


https://reviews.llvm.org/D154000

Files:
  clang/lib/Headers/__clang_hip_math.h
  clang/test/Headers/__clang_hip_math.hip

Index: clang/test/Headers/__clang_hip_math.hip
===
--- clang/test/Headers/__clang_hip_math.hip
+++ clang/test/Headers/__clang_hip_math.hip
@@ -1515,14 +1515,14 @@
 
 // DEFAULT-LABEL: @test_llroundf(
 // DEFAULT-NEXT:  entry:
-// DEFAULT-NEXT:[[CALL_I:%.*]] = tail call contract float @__ocml_round_f32(float noundef [[X:%.*]]) #[[ATTR14]]
-// DEFAULT-NEXT:[[CONV_I:%.*]] = fptosi float [[CALL_I]] to i64
+// DEFAULT-NEXT:[[TMP0:%.*]] = tail call contract float @llvm.round.f32(float [[X:%.*]])
+// DEFAULT-NEXT:[[CONV_I:%.*]] = fptosi float [[TMP0]] to i64
 // DEFAULT-NEXT:ret i64 [[CONV_I]]
 //
 // FINITEONLY-LABEL: @test_llroundf(
 // FINITEONLY-NEXT:  entry:
-// FINITEONLY-NEXT:[[CALL_I:%.*]] = tail call nnan ninf contract nofpclass(nan inf) float @__ocml_round_f32(float noundef nofpclass(nan inf) [[X:%.*]]) #[[ATTR14]]
-// FINITEONLY-NEXT:[[CONV_I:%.*]] = fptosi float [[CALL_I]] to i64
+// FINITEONLY-NEXT:[[TMP0:%.*]] = tail call nnan ninf contract float @llvm.round.f32(float [[X:%.*]])
+// FINITEONLY-NEXT:[[CONV_I:%.*]] = fptosi float [[TMP0]] to i64
 // FINITEONLY-NEXT:ret i64 [[CONV_I]]
 //
 extern "C" __device__ long long int test_llroundf(float x) {
@@ -1531,14 +1531,14 @@
 
 // DEFAULT-LABEL: @test_llround(
 // DEFAULT-NEXT:  entry:
-// DEFAULT-NEXT:[[CALL_I:%.*]] = tail call contract double @__ocml_round_f64(double noundef [[X:%.*]]) #[[ATTR14]]
-// DEFAULT-NEXT:[[CONV_I:%.*]] = fptosi double [[CALL_I]] to i64
+// DEFAULT-NEXT:[[TMP0:%.*]] = tail call contract double @llvm.round.f64(double [[X:%.*]])
+// DEFAULT-NEXT:[[CONV_I:%.*]] = fptosi double [[TMP0]] to i64
 // DEFAULT-NEXT:ret i64 [[CONV_I]]
 //
 // FINITEONLY-LABEL: @test_llround(
 // FINITEONLY-NEXT:  entry:
-// FINITEONLY-NEXT:[[CALL_I:%.*]] = tail call nnan ninf contract nofpclass(nan inf) double @__ocml_round_f64(double noundef nofpclass(nan inf) [[X:%.*]]) #[[ATTR14]]
-// FINITEONLY-NEXT:[[CONV_I:%.*]] = fptosi double [[CALL_I]] to i64
+// FINITEONLY-NEXT:[[TMP0:%.*]] = tail call nnan ninf contract double @llvm.round.f64(double [[X:%.*]])
+// FINITEONLY-NEXT:[[CONV_I:%.*]] = fptosi double [[TMP0]] to i64
 // FINITEONLY-NEXT:ret i64 [[CONV_I]]
 //
 extern "C" __device__ long long int test_llround(double x) {
@@ -1691,14 +1691,14 @@
 
 // DEFAULT-LABEL: @test_lroundf(
 // DEFAULT-NEXT:  entry:
-// DEFAULT-NEXT:[[CALL_I:%.*]] = tail call contract float @__ocml_round_f32(float noundef [[X:%.*]]) #[[ATTR14]]
-// DEFAULT-NEXT:[[CONV_I:%.*]] = fptosi float [[CALL_I]] to i64
+// DEFAULT-NEXT:[[TMP0:%.*]] = tail call contract float @llvm.round.f32(float [[X:%.*]])
+// DEFAULT-NEXT:[[CONV_I:%.*]] = fptosi float [[TMP0]] to i64
 // DEFAULT-NEXT:ret i64 [[CONV_I]]
 //
 // FINITEONLY-LABEL: @test_lroundf(
 // FINITEONLY-NEXT:  entry:
-// FINITEONLY-NEXT:[[CALL_I:%.*]] = tail call nnan ninf contract nofpclass(nan inf) float @__ocml_round_f32(float noundef nofpclass(nan inf) [[X:%.*]]) #[[ATTR14]]
-// FINITEONLY-NEXT:[[CONV_I:%.*]] = fptosi float [[CALL_I]] to i64
+// FINITEONLY-NEXT:[[TMP0:%.*]] = tail call nnan ninf contract float @llvm.round.f32(float [[X:%.*]])
+// FINITEONLY-NEXT:[[CONV_I:%.*]] = fptosi float [[TMP0]] to i64
 // FINITEONLY-NEXT:ret i64 [[CONV_I]]
 //
 extern "C" __device__ long int test_lroundf(float x) {
@@ -1707,14 +1707,14 @@
 
 // DEFAULT-LABEL: @test_lround(
 // DEFAULT-NEXT:  entry:
-// DEFAULT-NEXT:[[CALL_I:%.*]] = tail call contract double @__ocml_round_f64(double noundef [[X:%.*]]) #[[ATTR14]]
-// DEFAULT-NEXT:[[CONV_I:%.*]] = fptosi double [[CALL_I]] to i64
+// DEFAULT-NEXT:[[TMP0:%.*]] = tail call contract double @llvm.round.f64(double [[X:%.*]])
+// DEFAULT-NEXT:[[CONV_I:%.*]] = fptosi double [[TMP0]] to i64
 // DEFAULT-NEXT:ret i64 [[CONV_I]]
 //
 // FINITEONLY-LABEL: @test_lround(
 // FINITEONLY-NEXT:  entry:
-// FINITEONLY-NEXT:[[CALL_I:%.*]] = tail call nnan ninf contract nofpclass(nan inf) double @__ocml_round_f64(double noundef nofpclass(nan inf) [[X:%.*]]) #[[ATTR14]]
-// FINITEONLY-NEXT:[[CONV_I:%.*]] = fptosi double [[CALL_I]] to i64
+// FINITEONLY-NEXT:[[TMP0:%.*]] = tail call nnan ninf contract double @llvm.round.f64(double [[X:%.*]])
+// FINITEONLY-NEXT:[[CONV_I:%.*]] = fptosi double [[TMP0]] to i64
 // FINITEONLY-NEXT:ret i64 [[CONV_I]]
 //
 extern "C" __device__ long int test_lround(double x) {
@@ -2616,13 +2616,13 @@
 
 // DEFAULT-LABEL: @test_roundf(
 // DEFAULT-NEXT:  entry:
-// DEFAULT-NEXT:[[CALL_I:%.*]] = tail 

[PATCH] D89918: Fix issue: clang-format result is not consistent if "// clang-format off" is followed by macro definition.

2023-06-28 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks added a comment.

Is this still an issue?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89918

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


[PATCH] D153890: [clang] Fix checking the equality comparator of base classes in __is_trivially_equality_comparable

2023-06-28 Thread Nikolas Klauser 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 rG3cf8b982042e: [clang] Fix checking the equality comparator 
of base classes in… (authored by philnik).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153890

Files:
  clang/lib/AST/Type.cpp
  clang/test/SemaCXX/type-traits.cpp


Index: clang/test/SemaCXX/type-traits.cpp
===
--- clang/test/SemaCXX/type-traits.cpp
+++ clang/test/SemaCXX/type-traits.cpp
@@ -3264,6 +3264,21 @@
 };
 
static_assert(!__is_trivially_equality_comparable(NotTriviallyEqualityComparableHasReferenceMember));
 
+struct NotTriviallyEqualityComparableNonTriviallyComparableBaseBase {
+  int i;
+
+  bool operator==(const 
NotTriviallyEqualityComparableNonTriviallyComparableBaseBase&) const {
+return true;
+  }
+};
+
+struct NotTriviallyEqualityComparableNonTriviallyComparableBase : 
NotTriviallyEqualityComparableNonTriviallyComparableBaseBase {
+  int i;
+
+  bool operator==(const 
NotTriviallyEqualityComparableNonTriviallyComparableBase&) const = default;
+};
+static_assert(!__is_trivially_equality_comparable(NotTriviallyEqualityComparableNonTriviallyComparableBase));
+
 enum E {
   a,
   b
Index: clang/lib/AST/Type.cpp
===
--- clang/lib/AST/Type.cpp
+++ clang/lib/AST/Type.cpp
@@ -2667,7 +2667,7 @@
   return llvm::all_of(Decl->bases(),
   [](const CXXBaseSpecifier ) {
 if (const auto *RD = 
BS.getType()->getAsCXXRecordDecl())
-  HasNonDeletedDefaultedEqualityComparison(RD);
+  return HasNonDeletedDefaultedEqualityComparison(RD);
 return true;
   }) &&
  llvm::all_of(Decl->fields(), [](const FieldDecl *FD) {


Index: clang/test/SemaCXX/type-traits.cpp
===
--- clang/test/SemaCXX/type-traits.cpp
+++ clang/test/SemaCXX/type-traits.cpp
@@ -3264,6 +3264,21 @@
 };
 static_assert(!__is_trivially_equality_comparable(NotTriviallyEqualityComparableHasReferenceMember));
 
+struct NotTriviallyEqualityComparableNonTriviallyComparableBaseBase {
+  int i;
+
+  bool operator==(const NotTriviallyEqualityComparableNonTriviallyComparableBaseBase&) const {
+return true;
+  }
+};
+
+struct NotTriviallyEqualityComparableNonTriviallyComparableBase : NotTriviallyEqualityComparableNonTriviallyComparableBaseBase {
+  int i;
+
+  bool operator==(const NotTriviallyEqualityComparableNonTriviallyComparableBase&) const = default;
+};
+static_assert(!__is_trivially_equality_comparable(NotTriviallyEqualityComparableNonTriviallyComparableBase));
+
 enum E {
   a,
   b
Index: clang/lib/AST/Type.cpp
===
--- clang/lib/AST/Type.cpp
+++ clang/lib/AST/Type.cpp
@@ -2667,7 +2667,7 @@
   return llvm::all_of(Decl->bases(),
   [](const CXXBaseSpecifier ) {
 if (const auto *RD = BS.getType()->getAsCXXRecordDecl())
-  HasNonDeletedDefaultedEqualityComparison(RD);
+  return HasNonDeletedDefaultedEqualityComparison(RD);
 return true;
   }) &&
  llvm::all_of(Decl->fields(), [](const FieldDecl *FD) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 3cf8b98 - [clang] Fix checking the equality comparator of base classes in __is_trivially_equality_comparable

2023-06-28 Thread Nikolas Klauser via cfe-commits

Author: Nikolas Klauser
Date: 2023-06-28T13:34:02-07:00
New Revision: 3cf8b982042e91d9aabb880ccc7a556256187ff9

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

LOG: [clang] Fix checking the equality comparator of base classes in 
__is_trivially_equality_comparable

Fixes #63192

Reviewed By: cor3ntin

Spies: cfe-commits

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

Added: 


Modified: 
clang/lib/AST/Type.cpp
clang/test/SemaCXX/type-traits.cpp

Removed: 




diff  --git a/clang/lib/AST/Type.cpp b/clang/lib/AST/Type.cpp
index 646eba90973f5..7ffed145c5fe5 100644
--- a/clang/lib/AST/Type.cpp
+++ b/clang/lib/AST/Type.cpp
@@ -2667,7 +2667,7 @@ HasNonDeletedDefaultedEqualityComparison(const 
CXXRecordDecl *Decl) {
   return llvm::all_of(Decl->bases(),
   [](const CXXBaseSpecifier ) {
 if (const auto *RD = 
BS.getType()->getAsCXXRecordDecl())
-  HasNonDeletedDefaultedEqualityComparison(RD);
+  return HasNonDeletedDefaultedEqualityComparison(RD);
 return true;
   }) &&
  llvm::all_of(Decl->fields(), [](const FieldDecl *FD) {

diff  --git a/clang/test/SemaCXX/type-traits.cpp 
b/clang/test/SemaCXX/type-traits.cpp
index 9bb093e985cfc..ba52ca748fed7 100644
--- a/clang/test/SemaCXX/type-traits.cpp
+++ b/clang/test/SemaCXX/type-traits.cpp
@@ -3264,6 +3264,21 @@ struct NotTriviallyEqualityComparableHasReferenceMember {
 };
 
static_assert(!__is_trivially_equality_comparable(NotTriviallyEqualityComparableHasReferenceMember));
 
+struct NotTriviallyEqualityComparableNonTriviallyComparableBaseBase {
+  int i;
+
+  bool operator==(const 
NotTriviallyEqualityComparableNonTriviallyComparableBaseBase&) const {
+return true;
+  }
+};
+
+struct NotTriviallyEqualityComparableNonTriviallyComparableBase : 
NotTriviallyEqualityComparableNonTriviallyComparableBaseBase {
+  int i;
+
+  bool operator==(const 
NotTriviallyEqualityComparableNonTriviallyComparableBase&) const = default;
+};
+static_assert(!__is_trivially_equality_comparable(NotTriviallyEqualityComparableNonTriviallyComparableBase));
+
 enum E {
   a,
   b



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


[PATCH] D153667: [HIP]: Add -fhip-emit-relocatable to override link job creation for -fno-gpu-rdc

2023-06-28 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added inline comments.



Comment at: clang/lib/Driver/Driver.cpp:3328-3330
+  CompileDeviceOnly = C.getDriver().offloadDeviceOnly();
+  Relocatable = Args.hasFlag(options::OPT_fgpu_rdc,
+ options::OPT_fno_gpu_rdc, /*Default=*/false);

probably needs to be moved to ctor of CudaActionBuilderBase since they are 
needed by both Cuda and HIP action builders.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153667

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


[PATCH] D153582: [SystemZ][z/OS] Add required options/macro/etc for z/os compilation step

2023-06-28 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan accepted this revision.
abhina.sreeskantharajan added a comment.

new changes LGTM


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

https://reviews.llvm.org/D153582

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


[PATCH] D105759: Implement P2361 Unevaluated string literals

2023-06-28 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added a comment.

In D105759#4456864 , @aaron.ballman 
wrote:

> I don't think it's correct to assume that all string arguments to attributes 
> are unevaluated, but it is hard to tell where to draw the line sometimes. 
> Backing up a step, as I understand P2361 , an 
> unevaluated string is one which is not converted into the execution character 
> set (effectively). Is that correct? If so, then as an example, 
> `[[clang::annotate()]]` should almost certainly be using an evaluated string 
> because the argument is passed down to LLVM IR and is used in ways we cannot 
> predict. What's more, an unevaluated string cannot have some kinds of escape 
> characters (numeric and conditional escape sequences) and those are currently 
> allowed by `clang::annotate` and could potentially be used by a backend 
> plugin.
>
> I think other attributes may have similar issues. For example, the `alias` 
> attribute is a bit of a question mark for me -- that takes a string literal 
> representing an external identifier that is looked up. I'm not certain 
> whether that should be in the execution character set or not, but we do 
> support escape sequences for it: https://godbolt.org/z/v65Yd7a68
>
> I think we need to track evaluated vs not on the argument level so that the 
> attributes in Attr.td can decide which form to use. I think we should default 
> to "evaluated" for any attribute we're on the fence about because that's the 
> current behavior they get today (so we should avoid regressions).

I really don't think it makes sense to have both "unevaluated" and "evaluated" 
arguments.
We chatted offline and we struggle to find places where escape sequences are 
used, or examples of attributes intended to be in the execution character set.

My suggestion would be to land the non-attributes changes now, and the 
attributes bits in early clang 18.
If we find clear example of attributes expecting execution character set, they 
should be able to be described as an expression, which will be checked as a 
string literal anyway, hopefully?

In the case of annotate, if these are fed, for example to a debugger, their may 
need to convert to whatever the debugger expect as encoding, which is not 
necessarily the execution charset,
Same for plugins, they certainly not expect ebcdic data, for example.
I would expect for example static analyzers and code generator to keep working 
after the introduction of fexec-charset
So it's important that it remains unevaluated in the front end so that it can 
be correctly converted to the appropriate encoding of the various consumers. 
Which doesn't have a single answer

> Do we know of any attributes in the "needs more thinking" list that should 
> have the string literal encoded in the execution character set? I think most 
> of these are for referring to identifiers in source and I expect those would 
> want source character set and not execution character set strings.

Identifiers and symbol names are in UTF8, and may get mangle through, for 
example replacing non-ascii codepoints by UCN. The source character set is 
never relevant
This address the WebAsm attributes

> BTFDeclTag/BTFTypeTag (is emitted to DWARF with -g so probably evaluated?)

Is it correct to assume the debugger file encoding is always the same as the 
program's ? Probably not!
If need be, we can then transcode the strings when doing codegen for these 
things


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] D153366: [dataflow] Add dedicated representation of boolean formulas

2023-06-28 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 535491.
sammccall added a comment.

rebase, primarily on the SAT-inputs-are-ordered change (SetVector etc)

clarify that Formula::print output is supposed to be reliably stable.
This is useful for testing downstream analyses: having a representation of
formulas that can outlive the DataAnalysisContext makes tests more ergonomic.

Change Formula::print back to using a map of atom names instead of a delegate
print function. The extra flexibility is not useful, and it's awkward to use.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153366

Files:
  clang/include/clang/Analysis/FlowSensitive/Arena.h
  clang/include/clang/Analysis/FlowSensitive/DebugSupport.h
  clang/include/clang/Analysis/FlowSensitive/Formula.h
  clang/include/clang/Analysis/FlowSensitive/Solver.h
  clang/include/clang/Analysis/FlowSensitive/WatchedLiteralsSolver.h
  clang/lib/Analysis/FlowSensitive/Arena.cpp
  clang/lib/Analysis/FlowSensitive/CMakeLists.txt
  clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp
  clang/lib/Analysis/FlowSensitive/DebugSupport.cpp
  clang/lib/Analysis/FlowSensitive/Formula.cpp
  clang/lib/Analysis/FlowSensitive/WatchedLiteralsSolver.cpp
  clang/unittests/Analysis/FlowSensitive/ArenaTest.cpp
  clang/unittests/Analysis/FlowSensitive/DebugSupportTest.cpp
  clang/unittests/Analysis/FlowSensitive/SolverTest.cpp
  clang/unittests/Analysis/FlowSensitive/TestingSupport.h

Index: clang/unittests/Analysis/FlowSensitive/TestingSupport.h
===
--- clang/unittests/Analysis/FlowSensitive/TestingSupport.h
+++ clang/unittests/Analysis/FlowSensitive/TestingSupport.h
@@ -43,6 +43,7 @@
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Allocator.h"
 #include "llvm/Support/Errc.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Testing/Annotations/Annotations.h"
@@ -467,55 +468,43 @@
 
 /// Creates and owns constraints which are boolean values.
 class ConstraintContext {
-public:
-  // Creates an atomic boolean value.
-  BoolValue *atom() {
-Vals.push_back(std::make_unique());
-return Vals.back().get();
+  unsigned NextAtom = 0;
+  llvm::BumpPtrAllocator A;
+
+  const Formula *make(Formula::Kind K, llvm::ArrayRef Operands) {
+return ::create(A, K, Operands);
   }
 
-  // Creates an instance of the Top boolean value.
-  BoolValue *top() {
-Vals.push_back(std::make_unique());
-return Vals.back().get();
+public:
+  // Creates a reference to a fresh atomic variable.
+  const Formula *atom() {
+return ::create(A, Formula::AtomRef, {}, NextAtom++);
   }
 
   // Creates a boolean conjunction value.
-  BoolValue *conj(BoolValue *LeftSubVal, BoolValue *RightSubVal) {
-Vals.push_back(
-std::make_unique(*LeftSubVal, *RightSubVal));
-return Vals.back().get();
+  const Formula *conj(const Formula *LeftSubVal, const Formula *RightSubVal) {
+return make(Formula::And, {LeftSubVal, RightSubVal});
   }
 
   // Creates a boolean disjunction value.
-  BoolValue *disj(BoolValue *LeftSubVal, BoolValue *RightSubVal) {
-Vals.push_back(
-std::make_unique(*LeftSubVal, *RightSubVal));
-return Vals.back().get();
+  const Formula*disj(const Formula*LeftSubVal, const Formula*RightSubVal) {
+return make(Formula::Or, {LeftSubVal, RightSubVal});
   }
 
   // Creates a boolean negation value.
-  BoolValue *neg(BoolValue *SubVal) {
-Vals.push_back(std::make_unique(*SubVal));
-return Vals.back().get();
+  const Formula *neg(const Formula *SubVal) {
+return make(Formula::Not, {SubVal});
   }
 
   // Creates a boolean implication value.
-  BoolValue *impl(BoolValue *LeftSubVal, BoolValue *RightSubVal) {
-Vals.push_back(
-std::make_unique(*LeftSubVal, *RightSubVal));
-return Vals.back().get();
+  const Formula *impl(const Formula *LeftSubVal, const Formula *RightSubVal) {
+return make(Formula::Implies, {LeftSubVal, RightSubVal});
   }
 
   // Creates a boolean biconditional value.
-  BoolValue *iff(BoolValue *LeftSubVal, BoolValue *RightSubVal) {
-Vals.push_back(
-std::make_unique(*LeftSubVal, *RightSubVal));
-return Vals.back().get();
+  const Formula *iff(const Formula *LeftSubVal, const Formula *RightSubVal) {
+return make(Formula::Equal, {LeftSubVal, RightSubVal});
   }
-
-private:
-  std::vector> Vals;
 };
 
 } // namespace test
Index: clang/unittests/Analysis/FlowSensitive/SolverTest.cpp
===
--- clang/unittests/Analysis/FlowSensitive/SolverTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/SolverTest.cpp
@@ -9,9 +9,10 @@
 #include 
 
 #include "TestingSupport.h"
+#include "clang/Analysis/FlowSensitive/Formula.h"
 #include "clang/Analysis/FlowSensitive/Solver.h"
-#include "clang/Analysis/FlowSensitive/Value.h"
 #include 

[PATCH] D105759: Implement P2361 Unevaluated string literals

2023-06-28 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D105759#4456864 , @aaron.ballman 
wrote:

> I don't think it's correct to assume that all string arguments to attributes 
> are unevaluated, but it is hard to tell where to draw the line sometimes. 
> Backing up a step, as I understand P2361 , an 
> unevaluated string is one which is not converted into the execution character 
> set (effectively). Is that correct? If so, then as an example, 
> `[[clang::annotate()]]` should almost certainly be using an evaluated string 
> because the argument is passed down to LLVM IR and is used in ways we cannot 
> predict. What's more, an unevaluated string cannot have some kinds of escape 
> characters (numeric and conditional escape sequences) and those are currently 
> allowed by `clang::annotate` and could potentially be used by a backend 
> plugin.
>
> I think other attributes may have similar issues. For example, the `alias` 
> attribute is a bit of a question mark for me -- that takes a string literal 
> representing an external identifier that is looked up. I'm not certain 
> whether that should be in the execution character set or not, but we do 
> support escape sequences for it: https://godbolt.org/z/v65Yd7a68

I took a quick pass over our existing attributes, and here's my intuition on 
them regarding encoding of the literal:

Unevaluated Strings are Fine:
AbiTag
TLSModel
Availability
Deprecated
EnableIf/DiagnoseIf
ObjCRuntimeName
PragmaClangBSSSection/PragmaClangDataSection/PragmaClangRodataSection/PragmaClangRelroSection/PragmaClangTextSection
 (only created implicitly)
Suppress
Target/TargetVersion/TargetClones
Unavailable
Uuid
WarnUnusedResult
NoSanitize
Capability
Assumption
NoBuiltin (it names a builtin name, so this is probably fine to leave 
unevaluated?)
AcquireHandle/UseHandle/ReleaseHandle
Error
HLSLResourceBinding

Unevaluated String are Potentially Bad:
Annotate
AnnotateType

Unevaluated String Needs More Thinking (common thread is that they survive to 
LLVM IR):
Alias
AsmLabel
IFunc
BTFDeclTag/BTFTypeTag (is emitted to DWARF with -g so probably evaluated?)
WebAssemblyExportName/WebAssemblyImportModule/WebAssemblyImportModule
ExternalSourceSymbol
SwiftAsyncName/SwiftAttr/SwiftBridge/SwiftName
Section/CodeSeg/InitSeg
WeakRef
EnforceTCB/EnforceTCBLeaf

There's also the escape sequences issue where use of an escape sequence will go 
from accepted to rejected in these contexts. I did some hunting to see if I 
could find uses of numeric escape sequences in asm labels or alias attributes, 
to see if there's some signs this is done in practice:

Testing we can find numeric escape sequences at all:
https://sourcegraph.com/search?q=context:global+%5C%28%5C%22%5B%5B:alpha:%5D%5D*%28%5C%5C%5B%5B:digit:%5D%5D%2B%29%2B%5B%5B:alpha:%5D%5D*%5C%22%5C%29+lang:C+lang:C%2B%2B=regexp=yes=1=repo

Testing we can find asm labels at all:
https://sourcegraph.com/search?q=context:global+asm%5C%28%5C%22%5B%5B:alpha:%5D%5D*%5B%5B:alpha:%5D%5D*%5C%22%5C%29+lang:C+lang:C%2B%2B=regexp=yes=1=repo

Testing we can find asm labels with numeric escapes:
https://sourcegraph.com/search?q=context:global+asm%5C%28%5C%22%5B%5B:alpha:%5D%5D*%28%5C%5C%5B%5B:digit:%5D%5D%2B%29%2B%5B%5B:alpha:%5D%5D*%5C%22%5C%29+lang:C+lang:C%2B%2B=regexp=yes=1=repo

Testing we can find alias attributes at all:
https://sourcegraph.com/search?q=context:global+alias%5C%28%5C%22%5B%5B:alpha:%5D%5D*%5B%5B:alpha:%5D%5D*%5C%22%5C%29+lang:C+lang:C%2B%2B=regexp=yes=1=repo

Testing we can find alias attributes with numeric escapes:
https://sourcegraph.com/search?q=context:global+alias%5C%28%5C%22%5B%5B:alpha:%5D%5D*%28%5C%5C%5B%5B:digit:%5D%5D%2B%29%2B%5B%5B:alpha:%5D%5D*%5C%22%5C%29+lang:C+lang:C%2B%2B=regexp=yes=1=repo

I think this leaves me with three open questions:

- Do we know of any uses of the `annotate` attribute that rely on the string 
literal being in the execution character set? I do not know of any but I know 
this is used by plugins quite often.
- Do we know of any attributes in the "needs more thinking" list that should 
have the string literal encoded in the execution character set? I think most of 
these are for referring to identifiers in source and I expect those would want 
source character set and not execution character set strings.
- Do we know of any significant body of code using numeric escape sequences in 
these string literals that could not be relatively easily modified to compile 
again? I would be surprised, but I think someone should probably run more of 
the attributes on the "needs more thinking" list through similar searches on 
source graph and we can use that as an approximation.

If all these answers come back "no" as best we can figure, then I think we can 
punt on argument-level handling of this until we add an attribute that really 
does need an execution-encoded (or numeric escape sequence-using) string 
literal. I think we've got enough time before the Clang 17 

[PATCH] D152818: [Clang] Make template instantiations respect pragma FENV_ACCESS state at point-of-definition

2023-06-28 Thread Zahira Ammarguellat via Phabricator via cfe-commits
zahiraam added a comment.

In D152818#4456872 , @aaron.ballman 
wrote:

> In D152818#4456797 , @zahiraam 
> wrote:
>
>> In D152818#4456717 , 
>> @aaron.ballman wrote:
>>
>>> In D152818#4456510 , @zahiraam 
>>> wrote:
>>>
 In D152818#4456483 , 
 @nicolerabjohn wrote:

> In D152818#4442116 , @rjmccall 
> wrote:
>
>> Does https://reviews.llvm.org/D143241 solve the original problem here, 
>> or is there something deeper?
>
> It does not solve the problem, at least for my test case (linked in 
> https://github.com/llvm/llvm-project/issues/63063) - we still hit the 
> assertion.

 Sorry! I will not be able to work on this until about September! I haven't 
 tried to reproduce the issue with the test case in the link above.
>>>
>>> We branch for the 17 release at the end of July, so I'm wondering whether 
>>> there's anything we need to revert related to this? It looks like this 
>>> assertion started firing in Clang 12.0.0 
>>> (https://cexplorer.testlabs.pro/z/Wh9o8W), so this doesn't seem to be a 
>>> regression, but confirmation would be appreciated.
>>
>> The code that is generating the assertion has been introduced by this patch: 
>> https://reviews.llvm.org/D80462 
>> I can checkout that commit and see if the test case fails with it? Would 
>> that be a good experiment to do?
>
> No need -- so long as we're all agreed that we haven't regressed anything 
> between Clang 16 and Clang 17 here, that's all I'm really after.

I verified that it's failing from clang12.0.0 through clang 16.0.0. I think 
this confirms that's not a regression between clang 16 and clang 17. Doesn't it?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152818

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


[PATCH] D153953: Revert "[AMDGPU] Mark mbcnt as convergent"

2023-06-28 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl accepted this revision.
yaxunl added a comment.
This revision is now accepted and ready to land.

I checked the ISA manual about mbcnt and I agree that its value should only 
depend on thread position in warp and not on CFG.

It is possible that the side effect of preventing it from merging fixed 
something by accident, but marking mbcnt as convergent seems not right. 
Therefore I agree to revert that patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153953

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


[PATCH] D153962: [clang] Do not discard cleanups while processing immediate invocation

2023-06-28 Thread Mariya Podchishchaeva via Phabricator via cfe-commits
Fznamznon updated this revision to Diff 535489.
Fznamznon added a comment.

Rebase, don't use MaybeCreateExprWithCleanups


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153962

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Sema/SemaExpr.cpp
  clang/test/CodeGenCXX/consteval-cleanup.cpp
  clang/test/SemaCXX/consteval-cleanup.cpp

Index: clang/test/SemaCXX/consteval-cleanup.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/consteval-cleanup.cpp
@@ -0,0 +1,42 @@
+// RUN: %clang_cc1 -Wno-unused-value -std=c++20 -ast-dump -verify %s -ast-dump | FileCheck %s
+
+// expected-no-diagnostics
+
+struct P {
+  consteval P() {}
+};
+
+struct A {
+  A(int v) { this->data = new int(v); }
+  ~A() { delete data; }
+private:
+  int *data;
+};
+
+void foo() {
+  for (;A(1), P(), false;);
+  // CHECK: foo
+  // CHECK: ExprWithCleanups
+  // CHECK-NEXT: BinaryOperator {{.*}} 'bool' ','
+  // CHECK-NEXT: BinaryOperator {{.*}} 'P':'P' ','
+  // CHECK-NEXT: CXXFunctionalCastExpr {{.*}} 'A':'A'
+  // CHECK-NEXT: CXXBindTemporaryExpr {{.*}} 'A':'A'
+  // CHECK-NEXT: CXXConstructExpr {{.*}} 'A':'A'
+  // CHECK: ConstantExpr {{.*}} 'P':'P'
+  // CHECK-NEXT: value:
+  // CHECK-NEXT: ExprWithCleanups
+}
+
+struct B {
+  int *p = new int(38);
+  consteval int get() { return *p; }
+  constexpr ~B() { delete p; }
+};
+
+void bar() {
+  // CHECK: bar
+  // CHECK: ConstantExpr
+  // CHECK-NEXT: value:
+  // CHECK-NEXT: ExprWithCleanups
+  int k = B().get();
+}
Index: clang/test/CodeGenCXX/consteval-cleanup.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/consteval-cleanup.cpp
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -std=c++20 -Wno-unused-value -triple x86_64-linux-gnu -emit-llvm %s -o - | FileCheck %s
+
+struct P {
+  consteval P() {}
+};
+
+struct A {
+  A(int v) { this->data = new int(v); }
+  ~A() { delete data; }
+private:
+  int *data;
+};
+
+void foo() {
+  for (;A(1), P(), false;);
+  // CHECK: foo
+  // CHECK: for.cond:
+  // CHECK: call void @_ZN1AC1Ei
+  // CHECK: call void @_ZN1AD1Ev
+  // CHECK: for.body
+}
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -18183,7 +18183,15 @@
 return E;
   }
 
-  E = MaybeCreateExprWithCleanups(E);
+  if (Cleanup.exprNeedsCleanups()) {
+// Since an immediate invocation is a full expression itself - it requires
+// an additional ExprWithCleanups node, but it can participate to a bigger
+// full expression which actually requires cleanups to be run after so
+// create ExprWithCleanups without using MaybeCreateExprWithCleanups as it
+// may discard cleanups for outer expression too early.
+E = ExprWithCleanups::Create(getASTContext(), E.get(),
+ Cleanup.cleanupsHaveSideEffects(), {});
+  }
 
   ConstantExpr *Res = ConstantExpr::Create(
   getASTContext(), E.get(),
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -549,6 +549,10 @@
   (`#48512 `_).
 - Fixed a failing assertion when parsing incomplete destructor.
   (`#63503 `_)
+- Fix missing destructor calls and therefore memory leaks in generated code
+  when an immediate invocation appears as a part of an expression that produces
+  temporaries.
+  (`#60709 `_).
 
 Bug Fixes to Compiler Builtins
 ^^
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 82a3969 - Revert "[Clang] Reset FP options before function instantiations"

2023-06-28 Thread Serge Pavlov via cfe-commits

Author: Serge Pavlov
Date: 2023-06-29T02:07:41+07:00
New Revision: 82a3969d710f5fb7a2ee4c9afadb648653923fef

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

LOG: Revert "[Clang] Reset FP options before function instantiations"

This reverts commit 98390ccb80569e8fbb20e6c996b4b8cff87fbec6.
It caused issue #63542.

Added: 


Modified: 
clang/include/clang/Sema/Sema.h
clang/lib/Parse/ParseTemplate.cpp
clang/lib/Sema/SemaTemplate.cpp
clang/test/CodeGen/fp-template.cpp

Removed: 




diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 35bd3e253f668..55d1dcf6ee0c2 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -710,12 +710,6 @@ class Sema final {
 return result;
   }
 
-  void resetFPOptions(FPOptions FPO) {
-CurFPFeatures = FPO;
-FpPragmaStack.Stack.clear();
-FpPragmaStack.CurrentValue = FPO.getChangesFrom(FPOptions(LangOpts));
-  }
-
   // RAII object to push / pop sentinel slots for all MS #pragma stacks.
   // Actions should be performed only if we enter / exit a C++ method body.
   class PragmaStackSentinelRAII {
@@ -14007,8 +14001,6 @@ struct LateParsedTemplate {
   CachedTokens Toks;
   /// The template function declaration to be late parsed.
   Decl *D;
-  /// Floating-point options in the point of definition.
-  FPOptions FPO;
 };
 
 template <>

diff  --git a/clang/lib/Parse/ParseTemplate.cpp 
b/clang/lib/Parse/ParseTemplate.cpp
index 776c66b436472..d2e8a81ad521a 100644
--- a/clang/lib/Parse/ParseTemplate.cpp
+++ b/clang/lib/Parse/ParseTemplate.cpp
@@ -1742,10 +1742,6 @@ void 
Parser::ParseLateTemplatedFuncDef(LateParsedTemplate ) {
   Actions.PushDeclContext(Actions.getCurScope(), DC);
   }
 
-  // Parsing should occur with empty FP pragma stack and FP options used in the
-  // point of the template definition.
-  Actions.resetFPOptions(LPT.FPO);
-
   assert(!LPT.Toks.empty() && "Empty body!");
 
   // Append the current token at the end of the new token stream so that it

diff  --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp
index cb94edf67af59..063ddb418c431 100644
--- a/clang/lib/Sema/SemaTemplate.cpp
+++ b/clang/lib/Sema/SemaTemplate.cpp
@@ -11342,7 +11342,6 @@ void Sema::MarkAsLateParsedTemplate(FunctionDecl *FD, 
Decl *FnD,
   // Take tokens to avoid allocations
   LPT->Toks.swap(Toks);
   LPT->D = FnD;
-  LPT->FPO = getCurFPFeatures();
   LateParsedTemplateMap.insert(std::make_pair(FD, std::move(LPT)));
 
   FD->setLateTemplateParsed(true);

diff  --git a/clang/test/CodeGen/fp-template.cpp 
b/clang/test/CodeGen/fp-template.cpp
index e0ea8e4d12ad3..9e0fc0555e336 100644
--- a/clang/test/CodeGen/fp-template.cpp
+++ b/clang/test/CodeGen/fp-template.cpp
@@ -15,40 +15,4 @@ float func_01(float x, float y) {
 // CHECK-SAME:  (float noundef %{{.*}}, float noundef %{{.*}}) 
#[[ATTR01:[0-9]+]]{{.*}} {
 // CHECK:   call float @llvm.experimental.constrained.fadd.f32
 
-
-template 
-Ty templ_02(Ty x, Ty y) {
-  return x + y;
-}
-
-#pragma STDC FENV_ROUND FE_UPWARD
-
-template 
-Ty templ_03(Ty x, Ty y) {
-  return x - y;
-}
-
-#pragma STDC FENV_ROUND FE_TONEAREST
-
-float func_02(float x, float y) {
-  return templ_02(x, y);
-}
-
-// CHECK-LABEL: define {{.*}} float @_Z8templ_02IfET_S0_S0_
-// CHECK:   %add = fadd float %0, %1
-
-float func_03(float x, float y) {
-  return templ_03(x, y);
-}
-
-// CHECK-LABEL: define {{.*}} float @_Z8templ_03IfET_S0_S0_
-// CHECK:   call float @llvm.experimental.constrained.fsub.f32({{.*}}, 
metadata !"round.upward", metadata !"fpexcept.ignore")
-
-
-// This pragma sets non-default rounding mode before delayed parsing occurs. It
-// is used to check that the parsing uses FP options defined by command line
-// options or by pragma before the template definition but not by this pragma.
-#pragma STDC FENV_ROUND FE_TOWARDZERO
-
-
 // CHECK: attributes #[[ATTR01]] = { {{.*}}strictfp



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


[clang] bf8e92c - HIP: Use frexp builtins in math headers

2023-06-28 Thread Matt Arsenault via cfe-commits

Author: Matt Arsenault
Date: 2023-06-28T15:06:54-04:00
New Revision: bf8e92c0e792cbe3c9cc50607a1e33c6912ffd0e

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

LOG: HIP: Use frexp builtins in math headers

Added: 


Modified: 
clang/lib/Headers/__clang_hip_math.h
clang/test/Headers/__clang_hip_math.hip

Removed: 




diff  --git a/clang/lib/Headers/__clang_hip_math.h 
b/clang/lib/Headers/__clang_hip_math.h
index 7e95b66232122..26c2f77c82c63 100644
--- a/clang/lib/Headers/__clang_hip_math.h
+++ b/clang/lib/Headers/__clang_hip_math.h
@@ -257,8 +257,7 @@ float fmodf(float __x, float __y) { return 
__ocml_fmod_f32(__x, __y); }
 
 __DEVICE__
 float frexpf(float __x, int *__nptr) {
-  *__nptr = __builtin_amdgcn_frexp_expf(__x);
-  return __builtin_amdgcn_frexp_mantf(__x);
+  return __builtin_frexpf(__x, __nptr);
 }
 
 __DEVICE__
@@ -806,8 +805,7 @@ double fmod(double __x, double __y) { return 
__ocml_fmod_f64(__x, __y); }
 
 __DEVICE__
 double frexp(double __x, int *__nptr) {
-  *__nptr = __builtin_amdgcn_frexp_exp(__x);
-  return __builtin_amdgcn_frexp_mant(__x);
+  return __builtin_frexp(__x, __nptr);
 }
 
 __DEVICE__

diff  --git a/clang/test/Headers/__clang_hip_math.hip 
b/clang/test/Headers/__clang_hip_math.hip
index 984adf6da4ba2..e507aa3ccf4ef 100644
--- a/clang/test/Headers/__clang_hip_math.hip
+++ b/clang/test/Headers/__clang_hip_math.hip
@@ -1061,37 +1061,25 @@ extern "C" __device__ double test_fmod(double x, double 
y) {
   return fmod(x, y);
 }
 
-// DEFAULT-LABEL: @test_frexpf(
-// DEFAULT-NEXT:  entry:
-// DEFAULT-NEXT:[[TMP0:%.*]] = tail call i32 
@llvm.amdgcn.frexp.exp.i32.f32(float [[X:%.*]])
-// DEFAULT-NEXT:store i32 [[TMP0]], ptr [[Y:%.*]], align 4, !tbaa 
[[TBAA12:![0-9]+]]
-// DEFAULT-NEXT:[[TMP1:%.*]] = tail call contract float 
@llvm.amdgcn.frexp.mant.f32(float [[X]])
-// DEFAULT-NEXT:ret float [[TMP1]]
-//
-// FINITEONLY-LABEL: @test_frexpf(
-// FINITEONLY-NEXT:  entry:
-// FINITEONLY-NEXT:[[TMP0:%.*]] = tail call i32 
@llvm.amdgcn.frexp.exp.i32.f32(float [[X:%.*]])
-// FINITEONLY-NEXT:store i32 [[TMP0]], ptr [[Y:%.*]], align 4, !tbaa 
[[TBAA12:![0-9]+]]
-// FINITEONLY-NEXT:[[TMP1:%.*]] = tail call nnan ninf contract float 
@llvm.amdgcn.frexp.mant.f32(float [[X]])
-// FINITEONLY-NEXT:ret float [[TMP1]]
+// CHECK-LABEL: @test_frexpf(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = tail call { float, i32 } 
@llvm.frexp.f32.i32(float [[X:%.*]])
+// CHECK-NEXT:[[TMP1:%.*]] = extractvalue { float, i32 } [[TMP0]], 1
+// CHECK-NEXT:store i32 [[TMP1]], ptr [[Y:%.*]], align 4, !tbaa 
[[TBAA12:![0-9]+]]
+// CHECK-NEXT:[[TMP2:%.*]] = extractvalue { float, i32 } [[TMP0]], 0
+// CHECK-NEXT:ret float [[TMP2]]
 //
 extern "C" __device__ float test_frexpf(float x, int* y) {
   return frexpf(x, y);
 }
 
-// DEFAULT-LABEL: @test_frexp(
-// DEFAULT-NEXT:  entry:
-// DEFAULT-NEXT:[[TMP0:%.*]] = tail call i32 
@llvm.amdgcn.frexp.exp.i32.f64(double [[X:%.*]])
-// DEFAULT-NEXT:store i32 [[TMP0]], ptr [[Y:%.*]], align 4, !tbaa 
[[TBAA12]]
-// DEFAULT-NEXT:[[TMP1:%.*]] = tail call contract double 
@llvm.amdgcn.frexp.mant.f64(double [[X]])
-// DEFAULT-NEXT:ret double [[TMP1]]
-//
-// FINITEONLY-LABEL: @test_frexp(
-// FINITEONLY-NEXT:  entry:
-// FINITEONLY-NEXT:[[TMP0:%.*]] = tail call i32 
@llvm.amdgcn.frexp.exp.i32.f64(double [[X:%.*]])
-// FINITEONLY-NEXT:store i32 [[TMP0]], ptr [[Y:%.*]], align 4, !tbaa 
[[TBAA12]]
-// FINITEONLY-NEXT:[[TMP1:%.*]] = tail call nnan ninf contract double 
@llvm.amdgcn.frexp.mant.f64(double [[X]])
-// FINITEONLY-NEXT:ret double [[TMP1]]
+// CHECK-LABEL: @test_frexp(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = tail call { double, i32 } 
@llvm.frexp.f64.i32(double [[X:%.*]])
+// CHECK-NEXT:[[TMP1:%.*]] = extractvalue { double, i32 } [[TMP0]], 1
+// CHECK-NEXT:store i32 [[TMP1]], ptr [[Y:%.*]], align 4, !tbaa [[TBAA12]]
+// CHECK-NEXT:[[TMP2:%.*]] = extractvalue { double, i32 } [[TMP0]], 0
+// CHECK-NEXT:ret double [[TMP2]]
 //
 extern "C" __device__ double test_frexp(double x, int* y) {
   return frexp(x, y);



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


[PATCH] D153667: [HIP]: Add -fhip-emit-relocatable to override link job creation for -fno-gpu-rdc

2023-06-28 Thread Jeffrey Byrnes via Phabricator via cfe-commits
jrbyrnes updated this revision to Diff 535484.
jrbyrnes added a comment.

Use member variabls + add diagnostic + tests


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153667

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/Driver.cpp
  clang/test/Driver/hip-dependent-options.hip
  clang/test/Driver/hip-device-compile.hip
  clang/test/Driver/hip-phases.hip
  clang/test/Driver/hip-rdc-device-only.hip

Index: clang/test/Driver/hip-rdc-device-only.hip
===
--- clang/test/Driver/hip-rdc-device-only.hip
+++ clang/test/Driver/hip-rdc-device-only.hip
@@ -18,6 +18,16 @@
 // RUN:   %S/Inputs/hip_multiple_inputs/b.hip --gpu-bundle-output \
 // RUN: 2>&1 | FileCheck -check-prefixes=COMMON,EMITBC %s
 
+// With `-fno-hip-emit-relocatable`, the output should be the same as the aforementioned line
+// as `-fgpu-rdc` in HIP implies `-fno-hip-emit-relocatable`.
+
+// RUN: %clang -### --target=x86_64-linux-gnu \
+// RUN:   -x hip --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 \
+// RUN:   -c -fno-hip-emit-relocatable -nogpuinc -nogpulib --cuda-device-only -fgpu-rdc \
+// RUN:   %S/Inputs/hip_multiple_inputs/a.cu \
+// RUN:   %S/Inputs/hip_multiple_inputs/b.hip --gpu-bundle-output \
+// RUN: 2>&1 | FileCheck -check-prefixes=COMMON,EMITBC %s
+
 // RUN: %clang -### --target=x86_64-linux-gnu \
 // RUN:   -x hip --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 \
 // RUN:   -S -nogpuinc -nogpulib --cuda-device-only -fgpu-rdc \
Index: clang/test/Driver/hip-phases.hip
===
--- clang/test/Driver/hip-phases.hip
+++ clang/test/Driver/hip-phases.hip
@@ -244,6 +244,43 @@
 // DASM-NOT: clang-offload-bundler
 // DASM-NOT: host
 
+//
+// Test single gpu architecture with compile to relocatable in device-only
+// compilation mode.
+//
+// RUN: %clang -x hip --target=x86_64-unknown-linux-gnu -ccc-print-phases \
+// RUN: --cuda-gpu-arch=gfx803 %s --cuda-device-only -fhip-emit-relocatable 2>&1 \
+// RUN: | FileCheck -check-prefixes=RELOC %s
+// RELOC-DAG: [[P0:[0-9]+]]: input, "{{.*}}hip-phases.hip", [[T:hip]], (device-[[T]], [[ARCH:gfx803]])
+// RELOC-DAG: [[P1:[0-9]+]]: preprocessor, {[[P0]]}, [[T]]-cpp-output, (device-[[T]], [[ARCH]])
+// RELOC-DAG: [[P2:[0-9]+]]: compiler, {[[P1]]}, ir, (device-[[T]], [[ARCH]])
+// RELOC-DAG: [[P3:[0-9]+]]: backend, {[[P2]]}, assembler, (device-[[T]], [[ARCH]])
+// RELOC-DAG: [[P4:[0-9]+]]: assembler, {[[P3]]}, object, (device-[[T]], [[ARCH]])
+// RELOC-NOT: linker
+// RELOC-DAG: [[P5:[0-9]+]]: offload, "device-[[T]] (amdgcn-amd-amdhsa:[[ARCH]])" {[[P4]]}, object
+
+//
+// Test two gpu architectures with compile to relocatable in device-only
+// compilation mode.
+//
+// RUN: %clang -x hip --target=x86_64-unknown-linux-gnu -ccc-print-phases \
+// RUN: --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 %s --cuda-device-only -fhip-emit-relocatable 2>&1 \
+// RUN: | FileCheck -check-prefixes=RELOC2 %s
+// RELOC2-DAG: [[P0:[0-9]+]]: input, "{{.*}}hip-phases.hip", [[T:hip]], (device-[[T]], [[ARCH:gfx803]])
+// RELOC2-DAG: [[P1:[0-9]+]]: preprocessor, {[[P0]]}, [[T]]-cpp-output, (device-[[T]], [[ARCH]])
+// RELOC2-DAG: [[P2:[0-9]+]]: compiler, {[[P1]]}, ir, (device-[[T]], [[ARCH]])
+// RELOC2-DAG: [[P3:[0-9]+]]: backend, {[[P2]]}, assembler, (device-[[T]], [[ARCH]])
+// RELOC2-DAG: [[P4:[0-9]+]]: assembler, {[[P3]]}, object, (device-[[T]], [[ARCH]])
+// RELOC2-NOT: [[P5:[0-9]+]]: linker, {[[P4]]}, image, (device-[[T]], [[ARCH]])
+// RELOC2-DAG: [[P5:[0-9]+]]: offload, "device-[[T]] (amdgcn-amd-amdhsa:[[ARCH]])" {[[P4]]}, object
+// RELOC2-DAG: [[P6:[0-9]+]]: input, "{{.*}}hip-phases.hip", [[T:hip]], (device-[[T]], [[ARCH2:gfx900]])
+// RELOC2-DAG: [[P7:[0-9]+]]: preprocessor, {[[P6]]}, [[T]]-cpp-output, (device-[[T]], [[ARCH2]])
+// RELOC2-DAG: [[P8:[0-9]+]]: compiler, {[[P7]]}, ir, (device-[[T]], [[ARCH2]])
+// RELOC2-DAG: [[P9:[0-9]+]]: backend, {[[P8]]}, assembler, (device-[[T]], [[ARCH2]])
+// RELOC2-DAG: [[P10:[0-9]+]]: assembler, {[[P9]]}, object, (device-[[T]], [[ARCH2]])
+// RELOC2-NOT: linker
+// RELOC2-DAG: [[P11:[0-9]+]]: offload, "device-[[T]] (amdgcn-amd-amdhsa:[[ARCH2]])" {[[P10]]}, object
+
 //
 // Test two gpu architectures with complete compilation in device-only
 // compilation mode.
Index: clang/test/Driver/hip-device-compile.hip
===
--- clang/test/Driver/hip-device-compile.hip
+++ clang/test/Driver/hip-device-compile.hip
@@ -45,6 +45,14 @@
 // RUN:   %S/Inputs/hip_multiple_inputs/a.cu \
 // RUN: 2>&1 | FileCheck -check-prefixes=CHECK,ASM,NBUN %s
 
+// Output relocatable.
+// RUN: %clang -c --cuda-device-only -### --target=x86_64-linux-gnu \
+// RUN:   -o a.o -x hip --cuda-gpu-arch=gfx900 --no-gpu-link-output \
+// RUN:   --hip-device-lib=lib1.bc \
+// RUN:   

[PATCH] D149716: clang: Use new frexp intrinsic for builtins and add f16 version

2023-06-28 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm closed this revision.
arsenm added a comment.

85bdea023f5116f789095b606554739403042a21 



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

https://reviews.llvm.org/D149716

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


[clang] 85bdea0 - clang: Use new frexp intrinsic for builtins and add f16 version

2023-06-28 Thread Matt Arsenault via cfe-commits

Author: Matt Arsenault
Date: 2023-06-28T14:50:17-04:00
New Revision: 85bdea023f5116f789095b606554739403042a21

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

LOG: clang: Use new frexp intrinsic for builtins and add f16 version

Added: 


Modified: 
clang/include/clang/Basic/Builtins.def
clang/lib/CodeGen/CGBuiltin.cpp
clang/test/CodeGen/aix-builtin-mapping.c
clang/test/CodeGen/builtin-attributes.c
clang/test/CodeGen/math-builtins-long.c
clang/test/CodeGen/math-builtins.c
clang/test/CodeGenOpenCL/builtins-generic-amdgcn.cl

Removed: 




diff  --git a/clang/include/clang/Basic/Builtins.def 
b/clang/include/clang/Basic/Builtins.def
index c0e045865e2c2..fe00a2f69922a 100644
--- a/clang/include/clang/Basic/Builtins.def
+++ b/clang/include/clang/Basic/Builtins.def
@@ -143,6 +143,7 @@ BUILTIN(__builtin_frexp , "ddi*"  , "Fn")
 BUILTIN(__builtin_frexpf, "ffi*"  , "Fn")
 BUILTIN(__builtin_frexpl, "LdLdi*", "Fn")
 BUILTIN(__builtin_frexpf128, "LLdLLdi*", "Fn")
+BUILTIN(__builtin_frexpf16, "hhi*"  , "Fn")
 BUILTIN(__builtin_huge_val, "d", "ncE")
 BUILTIN(__builtin_huge_valf, "f", "ncE")
 BUILTIN(__builtin_huge_vall, "Ld", "ncE")

diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 4ede75678652b..167756a3001cc 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -652,6 +652,24 @@ emitMaybeConstrainedFPToIntRoundBuiltin(CodeGenFunction 
, const CallExpr *E,
   }
 }
 
+static Value *emitFrexpBuiltin(CodeGenFunction , const CallExpr *E,
+   llvm::Intrinsic::ID IntrinsicID) {
+  llvm::Value *Src0 = CGF.EmitScalarExpr(E->getArg(0));
+  llvm::Value *Src1 = CGF.EmitScalarExpr(E->getArg(1));
+
+  QualType IntPtrTy = E->getArg(1)->getType()->getPointeeType();
+  llvm::Type *IntTy = CGF.ConvertType(IntPtrTy);
+  llvm::Function *F =
+  CGF.CGM.getIntrinsic(IntrinsicID, {Src0->getType(), IntTy});
+  llvm::Value *Call = CGF.Builder.CreateCall(F, Src0);
+
+  llvm::Value *Exp = CGF.Builder.CreateExtractValue(Call, 1);
+  LValue LV = CGF.MakeNaturalAlignAddrLValue(Src1, IntPtrTy);
+  CGF.EmitStoreOfScalar(Exp, LV);
+
+  return CGF.Builder.CreateExtractValue(Call, 0);
+}
+
 /// EmitFAbs - Emit a call to @llvm.fabs().
 static Value *EmitFAbs(CodeGenFunction , Value *V) {
   Function *F = CGF.CGM.getIntrinsic(Intrinsic::fabs, V->getType());
@@ -3062,6 +3080,12 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl 
GD, unsigned BuiltinID,
{ Src0->getType(), Src1->getType() });
 return RValue::get(Builder.CreateCall(F, { Src0, Src1 }));
   }
+  case Builtin::BI__builtin_frexp:
+  case Builtin::BI__builtin_frexpf:
+  case Builtin::BI__builtin_frexpl:
+  case Builtin::BI__builtin_frexpf128:
+  case Builtin::BI__builtin_frexpf16:
+return RValue::get(emitFrexpBuiltin(*this, E, Intrinsic::frexp));
   case Builtin::BI__builtin_isgreater:
   case Builtin::BI__builtin_isgreaterequal:
   case Builtin::BI__builtin_isless:

diff  --git a/clang/test/CodeGen/aix-builtin-mapping.c 
b/clang/test/CodeGen/aix-builtin-mapping.c
index 98fcfd4a3a6fc..a79218c6f1d8b 100644
--- a/clang/test/CodeGen/aix-builtin-mapping.c
+++ b/clang/test/CodeGen/aix-builtin-mapping.c
@@ -18,5 +18,5 @@ int main()
 }
 
 // CHECK: %call = call double @modf(double noundef 1.00e+00, ptr noundef 
%DummyLongDouble) #3
-// CHECK: %call1 = call double @frexp(double noundef 0.00e+00, ptr noundef 
%DummyInt) #3
+// CHECK: %{{.+}} = call { double, i32 } @llvm.frexp.f64.i32(double 
0.00e+00)
 // CHECK: %{{.+}} = call double @llvm.ldexp.f64.i32(double 1.00e+00, i32 1)

diff  --git a/clang/test/CodeGen/builtin-attributes.c 
b/clang/test/CodeGen/builtin-attributes.c
index fd1e107a41d58..ec184e3a7b048 100644
--- a/clang/test/CodeGen/builtin-attributes.c
+++ b/clang/test/CodeGen/builtin-attributes.c
@@ -4,6 +4,10 @@
 int printf(const char *, ...);
 void exit(int);
 
+float frexpf(float, int*);
+double frexp(double, int*);
+long double frexpl(long double, int*);
+
 // CHECK: declare i32 @printf(ptr noundef, ...)
 void f0() {
   printf("a\n");
@@ -49,9 +53,9 @@ char* f2(char* a, char* b) {
 // CHECK: ret
 int f3(double x) {
   int e;
-  __builtin_frexp(x, );
-  __builtin_frexpf(x, );
-  __builtin_frexpl(x, );
+  frexp(x, );
+  frexpf(x, );
+  frexpl(x, );
   __builtin_modf(x, );
   __builtin_modff(x, );
   __builtin_modfl(x, );

diff  --git a/clang/test/CodeGen/math-builtins-long.c 
b/clang/test/CodeGen/math-builtins-long.c
index e32fc99480ead..f3c328dcbfcd7 100644
--- a/clang/test/CodeGen/math-builtins-long.c
+++ b/clang/test/CodeGen/math-builtins-long.c
@@ -34,10 +34,10 @@ void foo(long double f, long double *l, int *i, const char 
*c) {
   // PPCF128: call fp128 

[PATCH] D153993: [Headers][doc] Add load/store/cmp/cvt intrinsic descriptions to avx2intrin.h

2023-06-28 Thread Paul Robinson via Phabricator via cfe-commits
probinson added a subscriber: cfe-commits.
probinson added a comment.

+ cfe-commits which didn't get added automatically.


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

https://reviews.llvm.org/D153993

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


[PATCH] D153898: [DebugInfo] Enable debug info emission for extern variables in C++

2023-06-28 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

Got some details on how much this costs? (eg: `bloaty` comparison for a clang 
bootstrap with/without this patch applied?)
Could you provide a quick summary of why this debug info is required? The 
definition should be provided in whatever translation unit defines the variable 
and you should be able to get debug info from there - if that translation unit 
is built without -g, then maybe this feature should be gated on 
`-fstandalone-debug` which is intended to express the intent to get debug info 
coverage when a translation unit may be the only one built with `-g`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153898

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


[PATCH] D146777: [clang] Preliminary fat-lto-object support

2023-06-28 Thread Paul Kirth via Phabricator via cfe-commits
paulkirth updated this revision to Diff 535472.
paulkirth added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146777

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/test/CodeGen/embed-fat-lto-objects.c
  clang/test/Driver/clang_f_opts.c
  clang/test/Driver/fat-lto-objects.c

Index: clang/test/Driver/fat-lto-objects.c
===
--- /dev/null
+++ clang/test/Driver/fat-lto-objects.c
@@ -0,0 +1,19 @@
+// RUN: %clang --target=x86_64-unknown-linux-gnu -flto -ffat-lto-objects -### %s -c 2>&1 | FileCheck %s -check-prefix=CHECK-CC
+// CHECK-CC: -cc1
+// CHECK-CC-SAME: -emit-obj
+// CHECK-CC-SAME: -ffat-lto-objects
+
+// RUN: %clang --target=x86_64-unknown-linux-gnu -ffat-lto-objects -### %s -c 2>&1 | FileCheck %s -check-prefix=CHECK-CC-NOLTO
+// CHECK-CC-NOLTO: -cc1
+// CHECK-CC-NOLTO-SAME: -emit-obj
+// CHECK-CC-NOLTO-NOT: -ffat-lto-objects
+// CHECK-CC-NOLTO-NOT: warning: argument unused during compilation: '-ffat-lto-objects'
+
+/// We need to pass an additional flag to lld when linking w/ -flto -ffat-lto-objects
+/// But it should not be there when LTO is disabled w/ -fno-lto
+// RUN: %clang --target=x86_64-unknown-linux-gnu --sysroot=%S/Inputs/basic_cross_linux_tree %s \
+// RUN:   -fuse-ld=lld -flto -ffat-lto-objects -### 2>&1 | FileCheck --check-prefix=LTO %s
+// RUN: %clang --target=x86_64-unknown-linux-gnu --sysroot=%S/Inputs/basic_cross_linux_tree %s \
+// RUN:   -fuse-ld=lld -fno-lto -ffat-lto-objects -### 2>&1 | FileCheck --check-prefix=NOLTO %s
+// LTO: "-fat-lto-objects"
+// NOLTO-NOT: "-fat-lto-objects"
Index: clang/test/Driver/clang_f_opts.c
===
--- clang/test/Driver/clang_f_opts.c
+++ clang/test/Driver/clang_f_opts.c
@@ -424,7 +424,6 @@
 // CHECK-WARNING-DAG: optimization flag '-fwhole-program' is not supported
 // CHECK-WARNING-DAG: optimization flag '-fcaller-saves' is not supported
 // CHECK-WARNING-DAG: optimization flag '-freorder-blocks' is not supported
-// CHECK-WARNING-DAG: optimization flag '-ffat-lto-objects' is not supported
 // CHECK-WARNING-DAG: optimization flag '-fmerge-constants' is not supported
 // CHECK-WARNING-DAG: optimization flag '-finline-small-functions' is not supported
 // CHECK-WARNING-DAG: optimization flag '-ftree-dce' is not supported
Index: clang/test/CodeGen/embed-fat-lto-objects.c
===
--- /dev/null
+++ clang/test/CodeGen/embed-fat-lto-objects.c
@@ -0,0 +1,17 @@
+// RUN: %clang -cc1 -triple x86_64-unknown-linux-gnu -flto=full -ffat-lto-objects -fsplit-lto-unit -emit-llvm < %s  | FileCheck %s --check-prefixes=FULL,SPLIT
+// RUN: %clang -cc1 -triple x86_64-unknown-linux-gnu -flto=full -ffat-lto-objects -emit-llvm < %s  | FileCheck %s --check-prefixes=FULL,SPLIT
+
+// RUN: %clang -cc1 -triple x86_64-unknown-linux-gnu -flto=thin -fsplit-lto-unit -ffat-lto-objects -emit-llvm < %s  | FileCheck %s --check-prefixes=THIN,SPLIT
+// RUN: %clang -cc1 -triple x86_64-unknown-linux-gnu -flto=thin -ffat-lto-objects -emit-llvm < %s  | FileCheck %s --check-prefixes=THIN,NOSPLIT
+
+/// Check that the ThinLTO metadata is only set false for full LTO.
+// FULL: ![[#]] = !{i32 1, !"ThinLTO", i32 0}
+// THIN-NOT: ![[#]] = !{i32 1, !"ThinLTO", i32 0}
+
+/// Be sure we enable split LTO unints correctly under -ffat-lto-objects.
+// SPLIT: ![[#]] = !{i32 1, !"EnableSplitLTOUnit", i32 1}
+// NOSPLIT: ![[#]] = !{i32 1, !"EnableSplitLTOUnit", i32 0}
+
+int test(void) {
+  return 0xabcd;
+}
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -619,6 +619,10 @@
 PluginName + Suffix,
 Plugin);
 CmdArgs.push_back(Args.MakeArgString(Twine(PluginPrefix) + Plugin));
+  } else {
+// For LLD we need to enable fat object support
+if (Args.hasArg(options::OPT_ffat_lto_objects))
+  CmdArgs.push_back("-fat-lto-objects");
   }
 
   const char *PluginOptPrefix = IsOSAIX ? "-bplugin_opt:" : "-plugin-opt=";
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -7275,6 +7275,22 @@
   if (SplitLTOUnit)
 CmdArgs.push_back("-fsplit-lto-unit");
 
+  if (Arg *A = Args.getLastArg(options::OPT_ffat_lto_objects,
+   options::OPT_fno_fat_lto_objects)) {
+if (IsUsingLTO && 

[PATCH] D153580: [SystemZ][z/OS] Add support for z/OS link step (executable and shared libs)

2023-06-28 Thread Zibi Sarbino via Phabricator via cfe-commits
zibi accepted this revision.
zibi added a comment.

LGTM


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

https://reviews.llvm.org/D153580

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


[PATCH] D152818: [Clang] Make template instantiations respect pragma FENV_ACCESS state at point-of-definition

2023-06-28 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D152818#4456797 , @zahiraam wrote:

> In D152818#4456717 , @aaron.ballman 
> wrote:
>
>> In D152818#4456510 , @zahiraam 
>> wrote:
>>
>>> In D152818#4456483 , 
>>> @nicolerabjohn wrote:
>>>
 In D152818#4442116 , @rjmccall 
 wrote:

> Does https://reviews.llvm.org/D143241 solve the original problem here, or 
> is there something deeper?

 It does not solve the problem, at least for my test case (linked in 
 https://github.com/llvm/llvm-project/issues/63063) - we still hit the 
 assertion.
>>>
>>> Sorry! I will not be able to work on this until about September! I haven't 
>>> tried to reproduce the issue with the test case in the link above.
>>
>> We branch for the 17 release at the end of July, so I'm wondering whether 
>> there's anything we need to revert related to this? It looks like this 
>> assertion started firing in Clang 12.0.0 
>> (https://cexplorer.testlabs.pro/z/Wh9o8W), so this doesn't seem to be a 
>> regression, but confirmation would be appreciated.
>
> The code that is generating the assertion has been introduced by this patch: 
> https://reviews.llvm.org/D80462 
> I can checkout that commit and see if the test case fails with it? Would that 
> be a good experiment to do?

No need -- so long as we're all agreed that we haven't regressed anything 
between Clang 16 and Clang 17 here, that's all I'm really after.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152818

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


[PATCH] D105759: Implement P2361 Unevaluated string literals

2023-06-28 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

I don't think it's correct to assume that all string arguments to attributes 
are unevaluated, but it is hard to tell where to draw the line sometimes. 
Backing up a step, as I understand P2361 , an 
unevaluated string is one which is not converted into the execution character 
set (effectively). Is that correct? If so, then as an example, 
`[[clang::annotate()]]` should almost certainly be using an evaluated string 
because the argument is passed down to LLVM IR and is used in ways we cannot 
predict. What's more, an unevaluated string cannot have some kinds of escape 
characters (numeric and conditional escape sequences) and those are currently 
allowed by `clang::annotate` and could potentially be used by a backend plugin.

I think other attributes may have similar issues. For example, the `alias` 
attribute is a bit of a question mark for me -- that takes a string literal 
representing an external identifier that is looked up. I'm not certain whether 
that should be in the execution character set or not, but we do support escape 
sequences for it: https://godbolt.org/z/v65Yd7a68

I think we need to track evaluated vs not on the argument level so that the 
attributes in Attr.td can decide which form to use. I think we should default 
to "evaluated" for any attribute we're on the fence about because that's the 
current behavior they get today (so we should avoid regressions).




Comment at: clang/include/clang/Sema/ParsedAttr.h:919
+  bool isStringLiteralArg(unsigned I) const {
+// If the last bit is set, assume we have a variadic parameter
+if (I >= StringLiterals.size())





Comment at: clang/lib/Parse/ParseDecl.cpp:291
 
+/// Determine whether the given attribute has an identifier argument.
+static ParsedAttributeArgumentsProperties

Comment doesn't match the function name. ;-)



Comment at: clang/lib/Parse/ParseDecl.cpp:453-454
+  ExprResult Expr = Actions.CorrectDelayedTyposInExpr(E);
+  if (Expr.isUsable())
+E = Expr.get();
+}

What are these lines intended to do? We assign to `E` but nothing ever reads 
from it after this assignment and we reset it on the next iteration through the 
loop.



Comment at: clang/lib/Parse/ParseExpr.cpp:3497
   Expr = ParseBraceInitializer();
-} else
+} else {
   Expr = ParseAssignmentExpression();

Can revert these two changes now.


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] D153962: [clang] Do not discard cleanups while processing immediate invocation

2023-06-28 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: clang/lib/Sema/SemaExprCXX.cpp:7374
   auto *E = ExprWithCleanups::Create(
   Context, SubExpr, Cleanup.cleanupsHaveSideEffects(), Cleanups);
 

Because we may potentially pass some cleanups here (which are outside 
`ConstantExpr`) and won't discard them later, we end up adding the unrelated 
blocks to this cleanup expression.
Here's an example. If we start with this code:
```cpp
  struct P {
consteval P() {}
  };

  struct A {
A(int v) { this->data = new int(v); }
const int& get() const {
  return *this->data;
}
~A() { delete data; }
  private:
int *data;
  };

  void foo() {
A a(1);
  for (; ^{ ptr = (); }(), P(), false;);
  }
```
And run `clang++ -std=c++20 -fblocks -Xclang=-ast-dump`, we'll get:
(notice same Block in two cleanups)
```
`-ForStmt 0x5592888b1318 
  |-<<>>
  |-<<>>
  |-ExprWithCleanups 0x5592888b12f0  'bool'
  | |-cleanup Block 0x5592888ad728
  | `-BinaryOperator 0x5592888b12d0  'bool' ','
  |   |-BinaryOperator 0x5592888b12a0  'P':'P' ','
  |   | |-CallExpr 0x5592888adb48  'void'
  |   | | `-BlockExpr 0x5592888adb30  'void (^)()'
  |   | |   `-BlockDecl 0x5592888ad728  col:10
  |   | | |-capture Var 0x5592888ad318 'a' 'A':'A'
  |   | | `-CompoundStmt 0x5592888ad930 
  |   | `-CXXFunctionalCastExpr 0x5592888b1278  'P':'P' 
functional cast to P 
  |   |   `-ConstantExpr 0x5592888b1108  'P':'P'
  |   | |-value: Struct
  |   | `-ExprWithCleanups 0x5592888b10e8  'P':'P'
  |   |   |-cleanup Block 0x5592888ad728
  |   |   `-CXXTemporaryObjectExpr 0x5592888b10b8  
'P':'P' 'void ()'
  |   `-CXXBoolLiteralExpr 0x5592888b12c0  'bool' false
```
I didn't check if this particular error can lead to codegen bug, but even 
having a misplaced cleanup in the AST is already a red flag.

I think in case of immediate invocations we could simply create 
`ExprWithCleanups` and not do anything else:
- `CleanupVarDeclMarking` will be handled when containing evaluation context is 
popped from the stack.
- `ExprCleanupObjects` may only contain blocks at this point (as it's C++ and 
we have assert for this). One can't use blocks inside a constant expression 
(Clang will produce an error) so in correct code any cleanups we see inside the 
current context **must handled by the containing evaluation context** and not 
this `ExprWithCleanups`.



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153962

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


[PATCH] D153667: [HIP]: Add -fhip-emit-relocatable to override link job creation for -fno-gpu-rdc

2023-06-28 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added inline comments.



Comment at: clang/lib/Driver/Driver.cpp:3335-3337
+bool IsRDCMode = Args.hasFlag(options::OPT_fgpu_rdc,
+  options::OPT_fno_gpu_rdc, false);
+bool DeviceOnly = C.getDriver().offloadDeviceOnly();

There are data members Relocatable and CompileDeviceOnly in the base class. You 
can use them instead of using local variables.




Comment at: clang/lib/Driver/Driver.cpp:3342
+!IsRDCMode && DeviceOnly;
+  }
+

need to emit a diag diag::err_opt_not_valid_with_opt for fgpu-rdc
and diag::err_opt_not_valid_without_opt if it is not device only.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153667

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


[PATCH] D153926: [NFC] Initialize class member pointers to nullptr.

2023-06-28 Thread Sindhu Chittireddy via Phabricator via cfe-commits
schittir updated this revision to Diff 535466.
schittir added a comment.

Not sure what clang-format wants. I hope it likes this patch.


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

https://reviews.llvm.org/D153926

Files:
  clang/include/clang/AST/RawCommentList.h
  clang/include/clang/AST/Redeclarable.h
  clang/include/clang/CodeGen/CodeGenAction.h
  clang/include/clang/Sema/HLSLExternalSemaSource.h
  clang/include/clang/Sema/Sema.h
  clang/include/clang/Serialization/ModuleFile.h
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/Format/SortJavaScriptImports.cpp
  clang/lib/Serialization/ASTReaderDecl.cpp
  clang/lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp
  clang/lib/StaticAnalyzer/Checkers/WebKit/UncountedLambdaCapturesChecker.cpp

Index: clang/lib/StaticAnalyzer/Checkers/WebKit/UncountedLambdaCapturesChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/WebKit/UncountedLambdaCapturesChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/WebKit/UncountedLambdaCapturesChecker.cpp
@@ -25,7 +25,7 @@
 private:
   BugType Bug{this, "Lambda capture of uncounted variable",
   "WebKit coding guidelines"};
-  mutable BugReporter *BR;
+  mutable BugReporter *BR = nullptr;
 
 public:
   void checkASTDecl(const TranslationUnitDecl *TUD, AnalysisManager ,
Index: clang/lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp
+++ clang/lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp
@@ -754,7 +754,7 @@
 
 ObjCDeallocChecker::ObjCDeallocChecker()
 : NSObjectII(nullptr), SenTestCaseII(nullptr), XCTestCaseII(nullptr),
-  CIFilterII(nullptr) {
+  Block_releaseII(nullptr), CIFilterII(nullptr) {
 
   MissingReleaseBugType.reset(
   new BugType(this, "Missing ivar release (leak)",
Index: clang/lib/Serialization/ASTReaderDecl.cpp
===
--- clang/lib/Serialization/ASTReaderDecl.cpp
+++ clang/lib/Serialization/ASTReaderDecl.cpp
@@ -476,9 +476,8 @@
 
 /// Iterator over the redeclarations of a declaration that have already
 /// been merged into the same redeclaration chain.
-template
-class MergedRedeclIterator {
-  DeclT *Start;
+template  class MergedRedeclIterator {
+  DeclT *Start = nullptr;
   DeclT *Canonical = nullptr;
   DeclT *Current = nullptr;
 
Index: clang/lib/Format/SortJavaScriptImports.cpp
===
--- clang/lib/Format/SortJavaScriptImports.cpp
+++ clang/lib/Format/SortJavaScriptImports.cpp
@@ -217,8 +217,8 @@
   }
 
 private:
-  FormatToken *Current;
-  FormatToken *LineEnd;
+  FormatToken *Current = nullptr;
+  FormatToken *LineEnd = nullptr;
 
   FormatToken invalidToken;
 
Index: clang/lib/CodeGen/CodeGenFunction.h
===
--- clang/lib/CodeGen/CodeGenFunction.h
+++ clang/lib/CodeGen/CodeGenFunction.h
@@ -318,10 +318,10 @@
 
   /// CurFuncDecl - Holds the Decl for the current outermost
   /// non-closure context.
-  const Decl *CurFuncDecl;
+  const Decl *CurFuncDecl = nullptr;
   /// CurCodeDecl - This is the inner-most code context, which includes blocks.
-  const Decl *CurCodeDecl;
-  const CGFunctionInfo *CurFnInfo;
+  const Decl *CurCodeDecl = nullptr;
+  const CGFunctionInfo *CurFnInfo = nullptr;
   QualType FnRetTy;
   llvm::Function *CurFn = nullptr;
 
@@ -748,11 +748,11 @@
 
 /// An i1 variable indicating whether or not the @finally is
 /// running for an exception.
-llvm::AllocaInst *ForEHVar;
+llvm::AllocaInst *ForEHVar = nullptr;
 
 /// An i8* variable into which the exception pointer to rethrow
 /// has been saved.
-llvm::AllocaInst *SavedExnVar;
+llvm::AllocaInst *SavedExnVar = nullptr;
 
   public:
 void enter(CodeGenFunction , const Stmt *Finally,
Index: clang/include/clang/Serialization/ModuleFile.h
===
--- clang/include/clang/Serialization/ModuleFile.h
+++ clang/include/clang/Serialization/ModuleFile.h
@@ -196,7 +196,7 @@
 
   /// The memory buffer that stores the data associated with
   /// this AST file, owned by the InMemoryModuleCache.
-  llvm::MemoryBuffer *Buffer;
+  llvm::MemoryBuffer *Buffer = nullptr;
 
   /// The size of this file, in bits.
   uint64_t SizeInBits = 0;
Index: clang/include/clang/Sema/Sema.h
===
--- clang/include/clang/Sema/Sema.h
+++ clang/include/clang/Sema/Sema.h
@@ -937,7 +937,7 @@
   class DelayedDiagnostics;
 
   class DelayedDiagnosticsState {
-sema::DelayedDiagnosticPool *SavedPool;
+sema::DelayedDiagnosticPool *SavedPool = nullptr;
 friend class Sema::DelayedDiagnostics;
   };
   typedef DelayedDiagnosticsState ParsingDeclState;
Index: 

[PATCH] D153857: [clang] Fix new-expression with elaborated-type-specifier

2023-06-28 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added a comment.

In D153857#4455480 , @Fznamznon wrote:

>> MSVC rejects the first but accepts the second which I think is wrong but 
>> worth testing:
>>
>> alignof(struct B {});
>> sizeof(struct B{});
>
> These don't have `new` so they are not affected by the patch ATM.
> But why MSVC wrong? Operand of `alignof` is a `type-id` which is not 
> `defining-type-id` meaning it shouldn't be parsed as type definition. So, 
> `struct B{}` there is a reference to `struct B` with braced initializer, i.e. 
> object creation. That is not a `type-id`, right? On the opposite, `sizeof` 
> can accept either `type-id` or an expression, I guess this is why MSVC 
> accepts.

new is special b/c it is has `new-initializer` after the `type-id` so that can 
be an initialization: https://eel.is/c++draft/expr.new#nt:new-expression in 
`sizeof` it is a definition which is not allowed and so it should be rejected.

if you do:

  struct B{ int x; };
  
  void f() {
 struct B{};
  }

That is a definition in `f`: https://godbolt.org/z/38eM6z17K


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153857

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


[PATCH] D153957: [C++20] [Modules] Allow Stmt::Profile to treat lambdas as equal conditionally

2023-06-28 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added inline comments.



Comment at: clang/lib/AST/StmtProfile.cpp:188
 StmtProfilerWithoutPointers(llvm::FoldingSetNodeID , ODRHash )
-: StmtProfiler(ID, false), Hash(Hash) {}
+: StmtProfiler(ID, false, false), Hash(Hash) {}
 

nit


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153957

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


[PATCH] D152818: [Clang] Make template instantiations respect pragma FENV_ACCESS state at point-of-definition

2023-06-28 Thread Zahira Ammarguellat via Phabricator via cfe-commits
zahiraam added a comment.

In D152818#4456717 , @aaron.ballman 
wrote:

> In D152818#4456510 , @zahiraam 
> wrote:
>
>> In D152818#4456483 , 
>> @nicolerabjohn wrote:
>>
>>> In D152818#4442116 , @rjmccall 
>>> wrote:
>>>
 Does https://reviews.llvm.org/D143241 solve the original problem here, or 
 is there something deeper?
>>>
>>> It does not solve the problem, at least for my test case (linked in 
>>> https://github.com/llvm/llvm-project/issues/63063) - we still hit the 
>>> assertion.
>>
>> Sorry! I will not be able to work on this until about September! I haven't 
>> tried to reproduce the issue with the test case in the link above.
>
> We branch for the 17 release at the end of July, so I'm wondering whether 
> there's anything we need to revert related to this? It looks like this 
> assertion started firing in Clang 12.0.0 
> (https://cexplorer.testlabs.pro/z/Wh9o8W), so this doesn't seem to be a 
> regression, but confirmation would be appreciated.

The code that is generating the assertion has been introduced by this patch: 
https://reviews.llvm.org/D80462 
I can checkout that commit and see if the test case fails with it? Would that 
be a good experiment to do?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152818

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


[PATCH] D153892: [NFC] Initialize class member pointers to nullptr.

2023-06-28 Thread Sindhu Chittireddy via Phabricator via cfe-commits
schittir updated this revision to Diff 535459.
schittir added a comment.

Hope clang-format likes this patch!


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

https://reviews.llvm.org/D153892

Files:
  clang/lib/ARCMigrate/TransProperties.cpp
  clang/lib/AST/ExprConstant.cpp
  clang/lib/Frontend/ASTConsumers.cpp
  clang/lib/StaticAnalyzer/Checkers/StackAddrEscapeChecker.cpp


Index: clang/lib/StaticAnalyzer/Checkers/StackAddrEscapeChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/StackAddrEscapeChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/StackAddrEscapeChecker.cpp
@@ -29,7 +29,7 @@
 class StackAddrEscapeChecker
 : public Checker,
  check::EndFunction> {
-  mutable IdentifierInfo *dispatch_semaphore_tII;
+  mutable IdentifierInfo *dispatch_semaphore_tII = nullptr;
   mutable std::unique_ptr BT_stackleak;
   mutable std::unique_ptr BT_returnstack;
   mutable std::unique_ptr BT_capturedstackasync;
Index: clang/lib/Frontend/ASTConsumers.cpp
===
--- clang/lib/Frontend/ASTConsumers.cpp
+++ clang/lib/Frontend/ASTConsumers.cpp
@@ -184,13 +184,12 @@
 
 namespace {
   class ASTViewer : public ASTConsumer {
-ASTContext *Context;
-  public:
-void Initialize(ASTContext ) override {
-  this->Context = 
-}
+  ASTContext *Context = nullptr;
+
+public:
+  void Initialize(ASTContext ) override { this->Context =  }
 
-bool HandleTopLevelDecl(DeclGroupRef D) override {
+  bool HandleTopLevelDecl(DeclGroupRef D) override {
   for (DeclGroupRef::iterator I = D.begin(), E = D.end(); I != E; ++I)
 HandleTopLevelSingleDecl(*I);
   return true;
Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -580,7 +580,7 @@
 /// LambdaCaptureFields - Mapping from captured variables/this to
 /// corresponding data members in the closure class.
 llvm::DenseMap LambdaCaptureFields;
-FieldDecl *LambdaThisCaptureField;
+FieldDecl *LambdaThisCaptureField = nullptr;
 
 CallStackFrame(EvalInfo , SourceLocation CallLoc,
const FunctionDecl *Callee, const LValue *This,
Index: clang/lib/ARCMigrate/TransProperties.cpp
===
--- clang/lib/ARCMigrate/TransProperties.cpp
+++ clang/lib/ARCMigrate/TransProperties.cpp
@@ -45,7 +45,7 @@
 class PropertiesRewriter {
   MigrationContext 
   MigrationPass 
-  ObjCImplementationDecl *CurImplD;
+  ObjCImplementationDecl *CurImplD = nullptr;
 
   enum PropActionKind {
 PropAction_None,


Index: clang/lib/StaticAnalyzer/Checkers/StackAddrEscapeChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/StackAddrEscapeChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/StackAddrEscapeChecker.cpp
@@ -29,7 +29,7 @@
 class StackAddrEscapeChecker
 : public Checker,
  check::EndFunction> {
-  mutable IdentifierInfo *dispatch_semaphore_tII;
+  mutable IdentifierInfo *dispatch_semaphore_tII = nullptr;
   mutable std::unique_ptr BT_stackleak;
   mutable std::unique_ptr BT_returnstack;
   mutable std::unique_ptr BT_capturedstackasync;
Index: clang/lib/Frontend/ASTConsumers.cpp
===
--- clang/lib/Frontend/ASTConsumers.cpp
+++ clang/lib/Frontend/ASTConsumers.cpp
@@ -184,13 +184,12 @@
 
 namespace {
   class ASTViewer : public ASTConsumer {
-ASTContext *Context;
-  public:
-void Initialize(ASTContext ) override {
-  this->Context = 
-}
+  ASTContext *Context = nullptr;
+
+public:
+  void Initialize(ASTContext ) override { this->Context =  }
 
-bool HandleTopLevelDecl(DeclGroupRef D) override {
+  bool HandleTopLevelDecl(DeclGroupRef D) override {
   for (DeclGroupRef::iterator I = D.begin(), E = D.end(); I != E; ++I)
 HandleTopLevelSingleDecl(*I);
   return true;
Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -580,7 +580,7 @@
 /// LambdaCaptureFields - Mapping from captured variables/this to
 /// corresponding data members in the closure class.
 llvm::DenseMap LambdaCaptureFields;
-FieldDecl *LambdaThisCaptureField;
+FieldDecl *LambdaThisCaptureField = nullptr;
 
 CallStackFrame(EvalInfo , SourceLocation CallLoc,
const FunctionDecl *Callee, const LValue *This,
Index: clang/lib/ARCMigrate/TransProperties.cpp
===
--- clang/lib/ARCMigrate/TransProperties.cpp
+++ clang/lib/ARCMigrate/TransProperties.cpp
@@ -45,7 +45,7 @@
 class PropertiesRewriter {
   MigrationContext 
   

[PATCH] D153969: [clang][ExprConstant] Fix crash on uninitialized base class subobject

2023-06-28 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder added inline comments.



Comment at: clang/lib/AST/ExprConstant.cpp:2422
+  << BS.getType();
+  Info.Note(BS.getBeginLoc(), 
diag::note_constexpr_base_inherited_here);
+  return false;

Can you pass `<< BS.getSourceRange()` here? Does that improve things?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153969

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


[PATCH] D151697: [clang] Add test for CWG1710 and related issues

2023-06-28 Thread Vlad Serebrennikov via Phabricator via cfe-commits
Endill added a comment.

Thank you for taking a look!
I found a bunch of issues pointing at the same diagnostics, but I'm not sure if 
they track exactly what I test here:
https://github.com/llvm/llvm-project/issues/17775
https://github.com/llvm/llvm-project/issues/36539
https://github.com/llvm/llvm-project/issues/38395
https://github.com/llvm/llvm-project/issues/57019


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151697

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


[PATCH] D153667: [HIP]: Add gpu-link-output to control link job creation

2023-06-28 Thread Jeffrey Byrnes via Phabricator via cfe-commits
jrbyrnes updated this revision to Diff 535456.
jrbyrnes added a comment.

Naming + -cuda-device-only and -fno-gpu-rdc only


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153667

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/Driver.cpp
  clang/test/Driver/hip-device-compile.hip
  clang/test/Driver/hip-phases.hip
  clang/test/Driver/hip-rdc-device-only.hip

Index: clang/test/Driver/hip-rdc-device-only.hip
===
--- clang/test/Driver/hip-rdc-device-only.hip
+++ clang/test/Driver/hip-rdc-device-only.hip
@@ -18,6 +18,27 @@
 // RUN:   %S/Inputs/hip_multiple_inputs/b.hip --gpu-bundle-output \
 // RUN: 2>&1 | FileCheck -check-prefixes=COMMON,EMITBC %s
 
+// With `-fno-hip-emit-relocatable`, the output should be the same as the aforementioned line
+// as `-fgpu-rdc` in HIP implies `-fno-hip-emit-relocatable`.
+
+// RUN: %clang -### --target=x86_64-linux-gnu \
+// RUN:   -x hip --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 \
+// RUN:   -c -fno-hip-emit-relocatable -nogpuinc -nogpulib --cuda-device-only -fgpu-rdc \
+// RUN:   %S/Inputs/hip_multiple_inputs/a.cu \
+// RUN:   %S/Inputs/hip_multiple_inputs/b.hip --gpu-bundle-output \
+// RUN: 2>&1 | FileCheck -check-prefixes=COMMON,EMITBC %s
+
+// With `-fhip-emit-relocatable`, the output should be the same as the aforementioned line
+// as `-fgpu-rdc` in HIP overrides `-fhip-emit-relocatable`.
+
+// RUN: %clang -### --target=x86_64-linux-gnu \
+// RUN:   -x hip --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 \
+// RUN:   -c -fhip-emit-relocatable -nogpuinc -nogpulib --cuda-device-only -fgpu-rdc \
+// RUN:   %S/Inputs/hip_multiple_inputs/a.cu \
+// RUN:   %S/Inputs/hip_multiple_inputs/b.hip --gpu-bundle-output \
+// RUN: 2>&1 | FileCheck -check-prefixes=COMMON,EMITBC %s
+
+
 // RUN: %clang -### --target=x86_64-linux-gnu \
 // RUN:   -x hip --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 \
 // RUN:   -S -nogpuinc -nogpulib --cuda-device-only -fgpu-rdc \
@@ -54,6 +75,12 @@
 // RUN:   %S/Inputs/hip_multiple_inputs/a.cu -o %t.s --no-gpu-bundle-output \
 // RUN: 2>&1 | FileCheck -check-prefix=FAIL %s
 
+// RUN: %clang -### --target=x86_64-linux-gnu \
+// RUN:   -x hip --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 \
+// RUN:   -S -nogpuinc -nogpulib --cuda-device-only -fgpu-rdc \
+// RUN:   %S/Inputs/hip_multiple_inputs/a.cu -o %t.s \
+// RUN: 2>&1 | FileCheck -check-prefix=FAIL %s
+
 // COMMON: [[CLANG:".*clang.*"]] "-cc1" "-triple" "amdgcn-amd-amdhsa"
 // COMMON-SAME: "-aux-triple" "x86_64-unknown-linux-gnu"
 // EMITBC-SAME: "-emit-llvm-bc"
Index: clang/test/Driver/hip-phases.hip
===
--- clang/test/Driver/hip-phases.hip
+++ clang/test/Driver/hip-phases.hip
@@ -244,6 +244,59 @@
 // DASM-NOT: clang-offload-bundler
 // DASM-NOT: host
 
+//
+// Test single gpu architecture with compile to relocatable in device-only
+// compilation mode.
+//
+// RUN: %clang -x hip --target=x86_64-unknown-linux-gnu -ccc-print-phases \
+// RUN: --cuda-gpu-arch=gfx803 %s --cuda-device-only -fhip-emit-relocatable 2>&1 \
+// RUN: | FileCheck -check-prefixes=RELOC %s
+// RELOC-DAG: [[P0:[0-9]+]]: input, "{{.*}}hip-phases.hip", [[T:hip]], (device-[[T]], [[ARCH:gfx803]])
+// RELOC-DAG: [[P1:[0-9]+]]: preprocessor, {[[P0]]}, [[T]]-cpp-output, (device-[[T]], [[ARCH]])
+// RELOC-DAG: [[P2:[0-9]+]]: compiler, {[[P1]]}, ir, (device-[[T]], [[ARCH]])
+// RELOC-DAG: [[P3:[0-9]+]]: backend, {[[P2]]}, assembler, (device-[[T]], [[ARCH]])
+// RELOC-DAG: [[P4:[0-9]+]]: assembler, {[[P3]]}, object, (device-[[T]], [[ARCH]])
+// RELOC-NOT: linker
+// RELOC-DAG: [[P5:[0-9]+]]: offload, "device-[[T]] (amdgcn-amd-amdhsa:[[ARCH]])" {[[P4]]}, object
+
+
+// Compile to relocatable with fgpu-rdc is not allowed
+
+// RUN: %clang -x hip --target=x86_64-unknown-linux-gnu -ccc-print-phases \
+// RUN: --cuda-gpu-arch=gfx803 %s --cuda-device-only -fhip-emit-relocatable -fgpu-rdc 2>&1 \
+// RUN: | FileCheck -check-prefixes=RELOCRDC %s
+// RELOCRDC-DAG: linker
+
+// Compile to relocatable with is only allowed in device-only compilation mode
+
+// RUN: %clang -x hip --target=x86_64-unknown-linux-gnu -ccc-print-phases \
+// RUN: --cuda-gpu-arch=gfx803 %s -fhip-emit-relocatable -fno-gpu-rdc 2>&1 \
+// RUN: | FileCheck -check-prefixes=RELOCHOST %s
+// RELOCHOST-DAG: linker
+
+
+//
+// Test two gpu architectures with compile to relocatable in device-only
+// compilation mode.
+//
+// RUN: %clang -x hip --target=x86_64-unknown-linux-gnu -ccc-print-phases \
+// RUN: --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 %s --cuda-device-only -fhip-emit-relocatable 2>&1 \
+// RUN: | FileCheck -check-prefixes=RELOC2 %s
+// RELOC2-DAG: [[P0:[0-9]+]]: input, "{{.*}}hip-phases.hip", [[T:hip]], (device-[[T]], [[ARCH:gfx803]])
+// RELOC2-DAG: [[P1:[0-9]+]]: preprocessor, {[[P0]]}, [[T]]-cpp-output, (device-[[T]], [[ARCH]])
+// 

[PATCH] D150860: [OpenMP] Change clang emitTargetDataCalls to use OMPIRBuilder

2023-06-28 Thread Akash Banerjee via Phabricator via cfe-commits
TIFitis added inline comments.



Comment at: clang/lib/CodeGen/CGOpenMPRuntime.cpp:10395-10399
+if (CGF.ConstantFoldsToSimpleInteger(IfCond, CondConstant)) {
+  IfCondVal = CGF.Builder.getInt1(CondConstant);
+} else {
+  IfCondVal = CGF.EvaluateExprAsBool(IfCond);
+}

arsenm wrote:
> Why do you need to do this? I would expect EvaluateExprAsBool to handle the 
> constant case for you
`CGOpenMPRuntime::emitIfClause` has the check for 
`ConstantFoldsToSimpleInteger` so I added it here.

Removing it didn't break any test so I've updated it,


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150860

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


[PATCH] D150860: [OpenMP] Change clang emitTargetDataCalls to use OMPIRBuilder

2023-06-28 Thread Akash Banerjee via Phabricator via cfe-commits
TIFitis updated this revision to Diff 535455.
TIFitis marked an inline comment as done.
TIFitis added a comment.

Addressed reviewer comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150860

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/test/OpenMP/target_data_codegen.cpp
  clang/test/OpenMP/target_data_use_device_ptr_codegen.cpp
  llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
  llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp

Index: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
===
--- llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
+++ llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
@@ -4084,7 +4084,9 @@
 function_ref GenMapInfoCB,
 omp::RuntimeFunction *MapperFunc,
 function_ref
-BodyGenCB) {
+BodyGenCB,
+function_ref DeviceAddrCB,
+function_ref CustomMapperCB) {
   if (!updateToLocation(Loc))
 return InsertPointTy();
 
@@ -4095,9 +4097,9 @@
   // arguments of the runtime call by reference because they are used in the
   // closing of the region.
   auto BeginThenGen = [&](InsertPointTy AllocaIP, InsertPointTy CodeGenIP) {
-emitOffloadingArrays(AllocaIP, Builder.saveIP(),
- GenMapInfoCB(Builder.saveIP()), Info,
- /*IsNonContiguous=*/true);
+emitOffloadingArrays(
+AllocaIP, Builder.saveIP(), GenMapInfoCB(Builder.saveIP()), Info,
+/*IsNonContiguous=*/true, DeviceAddrCB, CustomMapperCB);
 
 TargetDataRTArgs RTArgs;
 emitOffloadingArraysArgument(Builder, RTArgs, Info);
Index: llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
===
--- llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
+++ llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
@@ -2032,6 +2032,10 @@
   /// \param Info Stores all information realted to the Target Data directive.
   /// \param GenMapInfoCB Callback that populates the MapInfos and returns.
   /// \param BodyGenCB Optional Callback to generate the region code.
+  /// \param DeviceAddrCB Optional callback to generate code related to
+  /// use_device_ptr and use_device_addr.
+  /// \param CustomMapperCB Optional callback to generate code related to
+  /// custom mappers.
   OpenMPIRBuilder::InsertPointTy createTargetData(
   const LocationDescription , InsertPointTy AllocaIP,
   InsertPointTy CodeGenIP, Value *DeviceID, Value *IfCond,
@@ -2040,7 +2044,9 @@
   omp::RuntimeFunction *MapperFunc = nullptr,
   function_ref
-  BodyGenCB = nullptr);
+  BodyGenCB = nullptr,
+  function_ref DeviceAddrCB = nullptr,
+  function_ref CustomMapperCB = nullptr);
 
   using TargetBodyGenCallbackTy = function_ref;
Index: clang/test/OpenMP/target_data_use_device_ptr_codegen.cpp
===
--- clang/test/OpenMP/target_data_use_device_ptr_codegen.cpp
+++ clang/test/OpenMP/target_data_use_device_ptr_codegen.cpp
@@ -131,7 +131,6 @@
 ++l;
   }
   // CK1: [[BEND]]:
-  // CK1: [[CMP:%.+]] = icmp ne ptr %{{.+}}, null
   // CK1: br i1 [[CMP]], label %[[BTHEN:.+]], label %[[BELSE:.+]]
 
   // CK1: [[BTHEN]]:
Index: clang/test/OpenMP/target_data_codegen.cpp
===
--- clang/test/OpenMP/target_data_codegen.cpp
+++ clang/test/OpenMP/target_data_codegen.cpp
@@ -63,9 +63,7 @@
 
   // CK1: %{{.+}} = add nsw i32 %{{[^,]+}}, 1
 
-  // CK1-DAG: call void @__tgt_target_data_end_mapper(ptr @{{.+}}, i64 [[DEV:%[^,]+]], i32 1, ptr [[GEPBP:%.+]], ptr [[GEPP:%.+]], ptr [[SIZE00]], ptr [[MTYPE00]], ptr null, ptr null)
-  // CK1-DAG: [[DEV]] = sext i32 [[DEVi32:%[^,]+]] to i64
-  // CK1-DAG: [[DEVi32]] = load i32, ptr %{{[^,]+}},
+  // CK1-DAG: call void @__tgt_target_data_end_mapper(ptr @{{.+}}, i64 [[DEV]], i32 1, ptr [[GEPBP:%.+]], ptr [[GEPP:%.+]], ptr [[SIZE00]], ptr [[MTYPE00]], ptr null, ptr null)
   // CK1-DAG: [[GEPBP]] = getelementptr inbounds {{.+}}[[BP]]
 // CK1-DAG: [[GEPP]] = getelementptr inbounds {{.+}}[[P]]
   #pragma omp target data if(1+3-5) device(arg) map(from: gc)
@@ -354,11 +352,11 @@
 }
 
 // Region 00
+// CK2-DAG: [[DEV:%[^,]+]] = sext i32 [[DEVi32:%[^,]+]] to i64
+// CK2-DAG: [[DEVi32]] = load i32, ptr %{{[^,]+}},
 // CK2: br i1 %{{[^,]+}}, label %[[IFTHEN:[^,]+]], label %[[IFELSE:[^,]+]]
 // CK2: [[IFTHEN]]
-// CK2-DAG: call void @__tgt_target_data_begin_mapper(ptr @{{.+}}, i64 [[DEV:%[^,]+]], i32 2, ptr [[GEPBP:%.+]], ptr [[GEPP:%.+]], ptr [[GEPS:%[^,]+]], ptr [[MTYPE00]], ptr null, ptr null)
-// CK2-DAG: [[DEV]] = sext i32 [[DEVi32:%[^,]+]] to i64
-// CK2-DAG: [[DEVi32]] = load i32, ptr %{{[^,]+}},
+// CK2-DAG: call void @__tgt_target_data_begin_mapper(ptr @{{.+}}, i64 [[DEV]], i32 2, ptr [[GEPBP:%.+]], ptr [[GEPP:%.+]], ptr [[GEPS:%[^,]+]], ptr [[MTYPE00]], ptr null, ptr null)
 // CK2-DAG: [[GEPBP]] = 

[PATCH] D152818: [Clang] Make template instantiations respect pragma FENV_ACCESS state at point-of-definition

2023-06-28 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D152818#4456510 , @zahiraam wrote:

> In D152818#4456483 , @nicolerabjohn 
> wrote:
>
>> In D152818#4442116 , @rjmccall 
>> wrote:
>>
>>> Does https://reviews.llvm.org/D143241 solve the original problem here, or 
>>> is there something deeper?
>>
>> It does not solve the problem, at least for my test case (linked in 
>> https://github.com/llvm/llvm-project/issues/63063) - we still hit the 
>> assertion.
>
> Sorry! I will not be able to work on this until about September! I haven't 
> tried to reproduce the issue with the test case in the link above.

We branch for the 17 release at the end of July, so I'm wondering whether 
there's anything we need to revert related to this? It looks like this 
assertion started firing in Clang 12.0.0 
(https://cexplorer.testlabs.pro/z/Wh9o8W), so this doesn't seem to be a 
regression, but confirmation would be appreciated.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152818

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


[PATCH] D153954: [WIP][clang][analyzer] Relax alpha.cplusplus.EnumCastOutOfRange checker

2023-06-28 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added a comment.

I did not look at this in detail but I don't think this approach is correct. I 
fixed this for constant evaluation the other day and you can find the details 
here: D130058 

The test suite I wrote should be sufficient for you to validate your approach 
against.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153954

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


[PATCH] D153058: [clang][CFG] Support construction of a weak topological ordering of the CFG.

2023-06-28 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel marked 2 inline comments as done.
ymandel added inline comments.



Comment at: clang/lib/Analysis/IntervalPartition.cpp:121
+Index.emplace(N, ID);
+  Graph.Intervals.emplace_back(ID, Header, std::move(Data.Nodes));
 }

xazax.hun wrote:
> It would probably take for me some time to understand what is going on here, 
> but I think this part might worth a comment. In particular, I have the 
> impression that `Graph.Intervals` is the owner of all the intervals. But we 
> use pointers to refer to these intervals. What would guarantee that those 
> pointers are not being invalidated by this `emplace_back` operations?
Excellent question, not least because I *wasn't* careful the first around and 
indeed ran up against this as a memory bug. :) That's the reason I added IDs, 
so that I could _avoid_ taking the addresses of elements until after we finish 
growing the vector. See lines 148-165: after we finish building the intervals, 
we go through and take addresses.

I can add comments to this effect, but perhaps the safe option is to use a 
std::dequeue. What do you think?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153058

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


[PATCH] D153989: [compiler-rt] Move crt into builtins

2023-06-28 Thread Petr Hosek via Phabricator via cfe-commits
phosek updated this revision to Diff 535452.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153989

Files:
  compiler-rt/CMakeLists.txt
  compiler-rt/cmake/builtin-config-ix.cmake
  compiler-rt/lib/CMakeLists.txt
  compiler-rt/lib/builtins/CMakeLists.txt
  compiler-rt/lib/builtins/crtbegin.c
  compiler-rt/lib/builtins/crtend.c
  compiler-rt/lib/crt/CMakeLists.txt
  compiler-rt/lib/crt/crtbegin.c
  compiler-rt/lib/crt/crtend.c
  compiler-rt/test/CMakeLists.txt
  compiler-rt/test/builtins/CMakeLists.txt
  compiler-rt/test/builtins/Unit/ctor_dtor.c
  compiler-rt/test/builtins/Unit/dso_handle.cpp
  compiler-rt/test/builtins/Unit/lit.cfg.py
  compiler-rt/test/builtins/Unit/lit.site.cfg.py.in
  compiler-rt/test/crt/CMakeLists.txt
  compiler-rt/test/crt/ctor_dtor.c
  compiler-rt/test/crt/dso_handle.cpp
  compiler-rt/test/crt/lit.cfg.py
  compiler-rt/test/crt/lit.site.cfg.py.in

Index: compiler-rt/test/crt/lit.site.cfg.py.in
===
--- compiler-rt/test/crt/lit.site.cfg.py.in
+++ /dev/null
@@ -1,14 +0,0 @@
-@LIT_SITE_CFG_IN_HEADER@
-
-# Tool-specific config options.
-config.name_suffix = "@CRT_TEST_CONFIG_SUFFIX@"
-config.crt_lit_source_dir = "@CRT_LIT_SOURCE_DIR@"
-config.target_cflags = "@CRT_TEST_TARGET_CFLAGS@"
-config.target_arch = "@CRT_TEST_TARGET_ARCH@"
-config.sanitizer_cxx_lib = "@SANITIZER_TEST_CXX_LIBNAME@"
-
-# Load common config for all compiler-rt lit tests
-lit_config.load_config(config, "@COMPILER_RT_BINARY_DIR@/test/lit.common.configured")
-
-# Load tool-specific config that would do the real work.
-lit_config.load_config(config, "@CRT_LIT_SOURCE_DIR@/lit.cfg.py")
Index: compiler-rt/test/crt/lit.cfg.py
===
--- compiler-rt/test/crt/lit.cfg.py
+++ /dev/null
@@ -1,95 +0,0 @@
-# -*- Python -*-
-
-import os
-import subprocess
-import shlex
-
-# Setup config name.
-config.name = "CRT" + config.name_suffix
-
-# Setup source root.
-config.test_source_root = os.path.dirname(__file__)
-
-
-# Choose between lit's internal shell pipeline runner and a real shell.  If
-# LIT_USE_INTERNAL_SHELL is in the environment, we use that as an override.
-use_lit_shell = os.environ.get("LIT_USE_INTERNAL_SHELL")
-if use_lit_shell:
-# 0 is external, "" is default, and everything else is internal.
-execute_external = use_lit_shell == "0"
-else:
-# Otherwise we default to internal on Windows and external elsewhere, as
-# bash on Windows is usually very slow.
-execute_external = not sys.platform in ["win32"]
-
-
-def get_library_path(file):
-cmd = subprocess.Popen(
-[config.clang.strip(), "-print-file-name=%s" % file]
-+ shlex.split(config.target_cflags),
-stdout=subprocess.PIPE,
-env=config.environment,
-universal_newlines=True,
-)
-if not cmd.stdout:
-lit_config.fatal("Couldn't find the library path for '%s'" % file)
-dir = cmd.stdout.read().strip()
-if sys.platform in ["win32"] and execute_external:
-# Don't pass dosish path separator to msys bash.exe.
-dir = dir.replace("\\", "/")
-return dir
-
-
-def get_libgcc_file_name():
-cmd = subprocess.Popen(
-[config.clang.strip(), "-print-libgcc-file-name"]
-+ shlex.split(config.target_cflags),
-stdout=subprocess.PIPE,
-env=config.environment,
-universal_newlines=True,
-)
-if not cmd.stdout:
-lit_config.fatal("Couldn't find the library path for '%s'" % file)
-dir = cmd.stdout.read().strip()
-if sys.platform in ["win32"] and execute_external:
-# Don't pass dosish path separator to msys bash.exe.
-dir = dir.replace("\\", "/")
-return dir
-
-
-def build_invocation(compile_flags):
-return " " + " ".join([config.clang] + compile_flags) + " "
-
-
-# Setup substitutions.
-config.substitutions.append(("%clang ", build_invocation([config.target_cflags])))
-config.substitutions.append(
-("%clangxx ", build_invocation(config.cxx_mode_flags + [config.target_cflags]))
-)
-
-base_lib = os.path.join(
-config.compiler_rt_libdir, "clang_rt.%%s%s.o" % config.target_suffix
-)
-
-if sys.platform in ["win32"] and execute_external:
-# Don't pass dosish path separator to msys bash.exe.
-base_lib = base_lib.replace("\\", "/")
-
-config.substitutions.append(("%crtbegin", base_lib % "crtbegin"))
-config.substitutions.append(("%crtend", base_lib % "crtend"))
-
-config.substitutions.append(("%crt1", get_library_path("crt1.o")))
-config.substitutions.append(("%crti", get_library_path("crti.o")))
-config.substitutions.append(("%crtn", get_library_path("crtn.o")))
-
-config.substitutions.append(("%libgcc", get_libgcc_file_name()))
-
-config.substitutions.append(
-("%libstdcxx", "-l" + config.sanitizer_cxx_lib.lstrip("lib"))
-)
-
-# Default test suffixes.
-config.suffixes = [".c", ".cpp"]

  1   2   3   >