[PATCH] D152126: [WebAssembly] Add tests ensuring rotates persist

2023-06-05 Thread Paulo Matos via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9571a28ee4e8: [WebAssembly] Add tests ensuring rotates 
persist (authored by pmatos).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152126

Files:
  clang/test/CodeGen/WebAssembly/wasm-rotate.c
  llvm/test/CodeGen/WebAssembly/rotate-i3264.ll

Index: llvm/test/CodeGen/WebAssembly/rotate-i3264.ll
===
--- /dev/null
+++ llvm/test/CodeGen/WebAssembly/rotate-i3264.ll
@@ -0,0 +1,48 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 2
+; RUN: sed 's/iX/i32/g' %s | llc --mtriple=wasm32-unknown-unknown | FileCheck --check-prefix=I32 %s
+; RUN: sed 's/iX/i64/g' %s | llc --mtriple=wasm64-unknown-unknown | FileCheck --check-prefix=I64 %s
+
+declare iX @llvm.fshl.iX(iX, iX, iX)
+declare iX @llvm.fshr.iX(iX, iX, iX)
+
+; from https://github.com/llvm/llvm-project/issues/62703
+
+define iX @testLeft(iX noundef %0, iX noundef %1) {
+; I32-LABEL: testLeft:
+; I32: .functype testLeft (i32, i32) -> (i32)
+; I32-NEXT:  # %bb.0:
+; I32-NEXT:local.get 0
+; I32-NEXT:local.get 1
+; I32-NEXT:i32.rotl
+; I32-NEXT:# fallthrough-return
+;
+; I64-LABEL: testLeft:
+; I64: .functype testLeft (i64, i64) -> (i64)
+; I64-NEXT:  # %bb.0:
+; I64-NEXT:local.get 0
+; I64-NEXT:local.get 1
+; I64-NEXT:i64.rotl
+; I64-NEXT:# fallthrough-return
+  %3 = call iX @llvm.fshl.iX(iX %0, iX %0, iX %1)
+  ret iX %3
+}
+
+define iX @testRight(iX noundef %0, iX noundef %1) {
+; I32-LABEL: testRight:
+; I32: .functype testRight (i32, i32) -> (i32)
+; I32-NEXT:  # %bb.0:
+; I32-NEXT:local.get 0
+; I32-NEXT:local.get 1
+; I32-NEXT:i32.rotr
+; I32-NEXT:# fallthrough-return
+;
+; I64-LABEL: testRight:
+; I64: .functype testRight (i64, i64) -> (i64)
+; I64-NEXT:  # %bb.0:
+; I64-NEXT:local.get 0
+; I64-NEXT:local.get 1
+; I64-NEXT:i64.rotr
+; I64-NEXT:# fallthrough-return
+  %3 = call iX @llvm.fshr.iX(iX %0, iX %0, iX %1)
+  ret iX %3
+}
Index: clang/test/CodeGen/WebAssembly/wasm-rotate.c
===
--- /dev/null
+++ clang/test/CodeGen/WebAssembly/wasm-rotate.c
@@ -0,0 +1,53 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 2
+// RUN: %clang_cc1 -triple wasm32-unknown-unknown -o - -emit-llvm %s | FileCheck --check-prefix=WEBASSEMBLY32 %s
+// RUN: %clang_cc1 -triple wasm64-unknown-unknown -o - -emit-llvm %s | FileCheck --check-prefix=WEBASSEMBLY64 %s
+
+// WEBASSEMBLY32-LABEL: define i32 @test32
+// WEBASSEMBLY32-SAME: (i32 noundef [[X:%.*]]) #[[ATTR0:[0-9]+]] {
+// WEBASSEMBLY32-NEXT:  entry:
+// WEBASSEMBLY32-NEXT:[[X_ADDR:%.*]] = alloca i32, align 4
+// WEBASSEMBLY32-NEXT:store i32 [[X]], ptr [[X_ADDR]], align 4
+// WEBASSEMBLY32-NEXT:[[TMP0:%.*]] = load i32, ptr [[X_ADDR]], align 4
+// WEBASSEMBLY32-NEXT:[[AND:%.*]] = and i32 [[TMP0]], -16711936
+// WEBASSEMBLY32-NEXT:[[TMP1:%.*]] = call i32 @llvm.fshl.i32(i32 [[AND]], i32 [[AND]], i32 8)
+// WEBASSEMBLY32-NEXT:ret i32 [[TMP1]]
+//
+// WEBASSEMBLY64-LABEL: define i32 @test32
+// WEBASSEMBLY64-SAME: (i32 noundef [[X:%.*]]) #[[ATTR0:[0-9]+]] {
+// WEBASSEMBLY64-NEXT:  entry:
+// WEBASSEMBLY64-NEXT:[[X_ADDR:%.*]] = alloca i32, align 4
+// WEBASSEMBLY64-NEXT:store i32 [[X]], ptr [[X_ADDR]], align 4
+// WEBASSEMBLY64-NEXT:[[TMP0:%.*]] = load i32, ptr [[X_ADDR]], align 4
+// WEBASSEMBLY64-NEXT:[[AND:%.*]] = and i32 [[TMP0]], -16711936
+// WEBASSEMBLY64-NEXT:[[TMP1:%.*]] = call i32 @llvm.fshl.i32(i32 [[AND]], i32 [[AND]], i32 8)
+// WEBASSEMBLY64-NEXT:ret i32 [[TMP1]]
+//
+unsigned int test32(unsigned int x) {
+  return __builtin_rotateleft32((x & 0xFF00FF00), 8);
+}
+
+// WEBASSEMBLY32-LABEL: define i32 @test64
+// WEBASSEMBLY32-SAME: (i32 noundef [[X:%.*]]) #[[ATTR0]] {
+// WEBASSEMBLY32-NEXT:  entry:
+// WEBASSEMBLY32-NEXT:[[X_ADDR:%.*]] = alloca i32, align 4
+// WEBASSEMBLY32-NEXT:store i32 [[X]], ptr [[X_ADDR]], align 4
+// WEBASSEMBLY32-NEXT:[[TMP0:%.*]] = load i32, ptr [[X_ADDR]], align 4
+// WEBASSEMBLY32-NEXT:[[CONV:%.*]] = zext i32 [[TMP0]] to i64
+// WEBASSEMBLY32-NEXT:[[AND:%.*]] = and i64 [[CONV]], -71777214294589696
+// WEBASSEMBLY32-NEXT:[[TMP1:%.*]] = call i64 @llvm.fshl.i64(i64 [[AND]], i64 [[AND]], i64 8)
+// WEBASSEMBLY32-NEXT:[[CONV1:%.*]] = trunc i64 [[TMP1]] to i32
+// WEBASSEMBLY32-NEXT:ret i32 [[CONV1]]
+//
+// WEBASSEMBLY64-LABEL: define i64 @test64
+// WEBASSEMBLY64-SAME: (i64 noundef [[X:%.*]]) #[[ATTR0]] {
+// WEBASSEMBLY64-NEXT:  entry:
+// WEBASSEMBLY64-NEXT:[[X_ADDR:%.*]] = alloca i64, align 8
+// WEBASSEMBLY64-NEXT:store i64 [[X]], ptr [[X_ADDR]], align 8
+// WEBASSEMBLY64-NEXT:[[TMP0:%.*]] = load i64, ptr 

[clang] 9571a28 - [WebAssembly] Add tests ensuring rotates persist

2023-06-05 Thread Paulo Matos via cfe-commits

Author: Paulo Matos
Date: 2023-06-06T07:48:35+02:00
New Revision: 9571a28ee4e801a7796569d62fe037fc22cd65a4

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

LOG: [WebAssembly] Add tests ensuring rotates persist

Due to the nature of WebAssembly, it's always better to keep
rotates instead of trying to optimize it. Commit 9485d983
disabled the generation of fsh for rotates, however these
tests ensure that future changes don't change the behaviour for
the Wasm backend that tends to have different optimization
requirements than other architectures. Also see:
https://github.com/llvm/llvm-project/issues/62703

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

Added: 
clang/test/CodeGen/WebAssembly/wasm-rotate.c
llvm/test/CodeGen/WebAssembly/rotate-i3264.ll

Modified: 


Removed: 




diff  --git a/clang/test/CodeGen/WebAssembly/wasm-rotate.c 
b/clang/test/CodeGen/WebAssembly/wasm-rotate.c
new file mode 100644
index 0..a9579d6bdb366
--- /dev/null
+++ b/clang/test/CodeGen/WebAssembly/wasm-rotate.c
@@ -0,0 +1,53 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --version 2
+// RUN: %clang_cc1 -triple wasm32-unknown-unknown -o - -emit-llvm %s | 
FileCheck --check-prefix=WEBASSEMBLY32 %s
+// RUN: %clang_cc1 -triple wasm64-unknown-unknown -o - -emit-llvm %s | 
FileCheck --check-prefix=WEBASSEMBLY64 %s
+
+// WEBASSEMBLY32-LABEL: define i32 @test32
+// WEBASSEMBLY32-SAME: (i32 noundef [[X:%.*]]) #[[ATTR0:[0-9]+]] {
+// WEBASSEMBLY32-NEXT:  entry:
+// WEBASSEMBLY32-NEXT:[[X_ADDR:%.*]] = alloca i32, align 4
+// WEBASSEMBLY32-NEXT:store i32 [[X]], ptr [[X_ADDR]], align 4
+// WEBASSEMBLY32-NEXT:[[TMP0:%.*]] = load i32, ptr [[X_ADDR]], align 4
+// WEBASSEMBLY32-NEXT:[[AND:%.*]] = and i32 [[TMP0]], -16711936
+// WEBASSEMBLY32-NEXT:[[TMP1:%.*]] = call i32 @llvm.fshl.i32(i32 [[AND]], 
i32 [[AND]], i32 8)
+// WEBASSEMBLY32-NEXT:ret i32 [[TMP1]]
+//
+// WEBASSEMBLY64-LABEL: define i32 @test32
+// WEBASSEMBLY64-SAME: (i32 noundef [[X:%.*]]) #[[ATTR0:[0-9]+]] {
+// WEBASSEMBLY64-NEXT:  entry:
+// WEBASSEMBLY64-NEXT:[[X_ADDR:%.*]] = alloca i32, align 4
+// WEBASSEMBLY64-NEXT:store i32 [[X]], ptr [[X_ADDR]], align 4
+// WEBASSEMBLY64-NEXT:[[TMP0:%.*]] = load i32, ptr [[X_ADDR]], align 4
+// WEBASSEMBLY64-NEXT:[[AND:%.*]] = and i32 [[TMP0]], -16711936
+// WEBASSEMBLY64-NEXT:[[TMP1:%.*]] = call i32 @llvm.fshl.i32(i32 [[AND]], 
i32 [[AND]], i32 8)
+// WEBASSEMBLY64-NEXT:ret i32 [[TMP1]]
+//
+unsigned int test32(unsigned int x) {
+  return __builtin_rotateleft32((x & 0xFF00FF00), 8);
+}
+
+// WEBASSEMBLY32-LABEL: define i32 @test64
+// WEBASSEMBLY32-SAME: (i32 noundef [[X:%.*]]) #[[ATTR0]] {
+// WEBASSEMBLY32-NEXT:  entry:
+// WEBASSEMBLY32-NEXT:[[X_ADDR:%.*]] = alloca i32, align 4
+// WEBASSEMBLY32-NEXT:store i32 [[X]], ptr [[X_ADDR]], align 4
+// WEBASSEMBLY32-NEXT:[[TMP0:%.*]] = load i32, ptr [[X_ADDR]], align 4
+// WEBASSEMBLY32-NEXT:[[CONV:%.*]] = zext i32 [[TMP0]] to i64
+// WEBASSEMBLY32-NEXT:[[AND:%.*]] = and i64 [[CONV]], -71777214294589696
+// WEBASSEMBLY32-NEXT:[[TMP1:%.*]] = call i64 @llvm.fshl.i64(i64 [[AND]], 
i64 [[AND]], i64 8)
+// WEBASSEMBLY32-NEXT:[[CONV1:%.*]] = trunc i64 [[TMP1]] to i32
+// WEBASSEMBLY32-NEXT:ret i32 [[CONV1]]
+//
+// WEBASSEMBLY64-LABEL: define i64 @test64
+// WEBASSEMBLY64-SAME: (i64 noundef [[X:%.*]]) #[[ATTR0]] {
+// WEBASSEMBLY64-NEXT:  entry:
+// WEBASSEMBLY64-NEXT:[[X_ADDR:%.*]] = alloca i64, align 8
+// WEBASSEMBLY64-NEXT:store i64 [[X]], ptr [[X_ADDR]], align 8
+// WEBASSEMBLY64-NEXT:[[TMP0:%.*]] = load i64, ptr [[X_ADDR]], align 8
+// WEBASSEMBLY64-NEXT:[[AND:%.*]] = and i64 [[TMP0]], -71777214294589696
+// WEBASSEMBLY64-NEXT:[[TMP1:%.*]] = call i64 @llvm.fshl.i64(i64 [[AND]], 
i64 [[AND]], i64 8)
+// WEBASSEMBLY64-NEXT:ret i64 [[TMP1]]
+//
+unsigned long test64(unsigned long x) {
+  return __builtin_rotateleft64((x & 0xFF00FF00FF00FF00L), 8);
+}

diff  --git a/llvm/test/CodeGen/WebAssembly/rotate-i3264.ll 
b/llvm/test/CodeGen/WebAssembly/rotate-i3264.ll
new file mode 100644
index 0..209f0e43be722
--- /dev/null
+++ b/llvm/test/CodeGen/WebAssembly/rotate-i3264.ll
@@ -0,0 +1,48 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py 
UTC_ARGS: --version 2
+; RUN: sed 's/iX/i32/g' %s | llc --mtriple=wasm32-unknown-unknown | FileCheck 
--check-prefix=I32 %s
+; RUN: sed 's/iX/i64/g' %s | llc --mtriple=wasm64-unknown-unknown | FileCheck 
--check-prefix=I64 %s
+
+declare iX @llvm.fshl.iX(iX, iX, iX)
+declare iX @llvm.fshr.iX(iX, iX, iX)
+
+; from https://github.com/llvm/llvm-project/issues/62703
+
+define iX @testLeft(iX noundef %0, iX noundef %1) {
+; I32-LABEL: 

[clang] c336c98 - [C++20] [Modules] [Serialization] Don't write comments to BMI for C++20 Named Modules

2023-06-05 Thread Chuanqi Xu via cfe-commits

Author: Chuanqi Xu
Date: 2023-06-06T13:05:17+08:00
New Revision: c336c983bcd9bf3559c76ed4eb6b25fbafbcd361

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

LOG: [C++20] [Modules] [Serialization] Don't write comments to BMI for C++20 
Named Modules

This patch forbids to write comment to BMIs for C++20 Named Modules.
Originally I thought this was helpful for language services like clangd.
But I found clangd don't want the BMI to contain comments actually. So
it is meaningless for C++20 Named Modules to keep such comments in
their BMI.

It is simple to enable this when someday we found we want this actually.

Added: 
clang/unittests/Serialization/NoCommentsTest.cpp

Modified: 
clang/lib/Serialization/ASTWriter.cpp
clang/unittests/Serialization/CMakeLists.txt

Removed: 




diff  --git a/clang/lib/Serialization/ASTWriter.cpp 
b/clang/lib/Serialization/ASTWriter.cpp
index ee636028b8e25..5ac3030a7a676 100644
--- a/clang/lib/Serialization/ASTWriter.cpp
+++ b/clang/lib/Serialization/ASTWriter.cpp
@@ -3178,6 +3178,13 @@ void ASTWriter::WriteComments() {
   auto _ = llvm::make_scope_exit([this] { Stream.ExitBlock(); });
   if (!PP->getPreprocessorOpts().WriteCommentListToPCH)
 return;
+
+  // Don't write comments to BMI to reduce the size of BMI.
+  // If language services (e.g., clangd) want such abilities,
+  // we can offer a special option then.
+  if (isWritingStdCXXNamedModules())
+return;
+
   RecordData Record;
   for (const auto  : Context->Comments.OrderedComments) {
 for (const auto  : FO.second) {

diff  --git a/clang/unittests/Serialization/CMakeLists.txt 
b/clang/unittests/Serialization/CMakeLists.txt
index 44e4ecb314365..d4dfb54af3d70 100644
--- a/clang/unittests/Serialization/CMakeLists.txt
+++ b/clang/unittests/Serialization/CMakeLists.txt
@@ -8,6 +8,7 @@ set(LLVM_LINK_COMPONENTS
 add_clang_unittest(SerializationTests
   InMemoryModuleCacheTest.cpp
   ModuleCacheTest.cpp
+  NoCommentsTest.cpp
   SourceLocationEncodingTest.cpp
   VarDeclConstantInitTest.cpp
   )

diff  --git a/clang/unittests/Serialization/NoCommentsTest.cpp 
b/clang/unittests/Serialization/NoCommentsTest.cpp
new file mode 100644
index 0..48f76bbd9d5f8
--- /dev/null
+++ b/clang/unittests/Serialization/NoCommentsTest.cpp
@@ -0,0 +1,126 @@
+//===- unittests/Serialization/NoComments.cpp - CI tests -===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
+#include "clang/Basic/FileManager.h"
+#include "clang/Frontend/CompilerInstance.h"
+#include "clang/Frontend/CompilerInvocation.h"
+#include "clang/Frontend/FrontendActions.h"
+#include "clang/Frontend/Utils.h"
+#include "clang/Lex/HeaderSearch.h"
+#include "clang/Tooling/Tooling.h"
+#include "llvm/ADT/SmallString.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/raw_ostream.h"
+
+#include "gtest/gtest.h"
+
+using namespace llvm;
+using namespace clang;
+
+namespace {
+
+class NoComments : public ::testing::Test {
+  void SetUp() override {
+ASSERT_FALSE(
+sys::fs::createUniqueDirectory("modules-no-comments-test", TestDir));
+  }
+
+  void TearDown() override { sys::fs::remove_directories(TestDir); }
+
+public:
+  SmallString<256> TestDir;
+
+  void addFile(StringRef Path, StringRef Contents) {
+ASSERT_FALSE(sys::path::is_absolute(Path));
+
+SmallString<256> AbsPath(TestDir);
+sys::path::append(AbsPath, Path);
+
+ASSERT_FALSE(
+sys::fs::create_directories(llvm::sys::path::parent_path(AbsPath)));
+
+std::error_code EC;
+llvm::raw_fd_ostream OS(AbsPath, EC);
+ASSERT_FALSE(EC);
+OS << Contents;
+  }
+};
+
+TEST_F(NoComments, NonModulesTest) {
+  std::unique_ptr AST = tooling::buildASTFromCodeWithArgs(
+  R"cpp(
+/// Any comments
+void foo() {}
+)cpp",
+  /*Args=*/{"-std=c++20"});
+  EXPECT_TRUE(AST);
+
+  ASTContext  = AST->getASTContext();
+
+  using namespace clang::ast_matchers;
+  auto *foo = selectFirst(
+  "foo", match(functionDecl(hasName("foo")).bind("foo"), Ctx));
+  EXPECT_TRUE(foo);
+
+  const RawComment *RC = getCompletionComment(Ctx, foo);
+  EXPECT_TRUE(RC);
+  EXPECT_TRUE(RC->getRawText(Ctx.getSourceManager()).trim() ==
+  "/// Any comments");
+}
+
+TEST_F(NoComments, ModulesTest) {
+  addFile("Comments.cppm", R"cpp(
+export module Comments;
+
+/// Any comments
+void foo() {}
+  )cpp");
+
+  IntrusiveRefCntPtr Diags =
+  CompilerInstance::createDiagnostics(new 

[PATCH] D152226: [FunctionAttrs] Propagate some func/arg/ret attributes from caller to callsite (WIP)

2023-06-05 Thread Siva Chandra via Phabricator via cfe-commits
sivachandra added inline comments.



Comment at: libc/CMakeLists.txt:22
+# that clang will use it.
+if(LLVM_LIBC_MAKE_DISCOVERABLE)
+  if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR)

Likely out of date and not required for this patch?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152226

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


[PATCH] D152226: [FunctionAttrs] Propagate some func/arg/ret attributes from caller to callsite (WIP)

2023-06-05 Thread Noah Goldstein via Phabricator via cfe-commits
goldstein.w.n added a comment.

llvm-test-suite passes with this patch enabled.
But note: **There currently some failing clang tests**.
Most of them look benign (just need to propagate a few attributes to a few 
thousand places),
but I was hoping there is a way to auto-regenerate them before going through 
laboriously by hand.
All the ones that can be auto regenerated I updated + a few by hand before 
thinking better of it.
Currently the list of failing tests in the llvm-project with all projects 
enabled using `ninja check-all` is:

  Failed Tests (52):
Clang :: CodeGen/SystemZ/builtins-systemz-zvector-constrained.c
Clang :: CodeGen/SystemZ/builtins-systemz-zvector.c
Clang :: CodeGen/SystemZ/builtins-systemz-zvector2-constrained.c
Clang :: CodeGen/SystemZ/builtins-systemz-zvector2.c
Clang :: CodeGen/SystemZ/builtins-systemz-zvector3-constrained.c
Clang :: CodeGen/SystemZ/builtins-systemz-zvector3.c
Clang :: CodeGen/SystemZ/systemz-inline-asm.c
Clang :: CodeGen/aarch64-neon-vcmla.c
Clang :: CodeGen/aarch64-sme-intrinsics/acle_sme_ld1.c
Clang :: CodeGen/aarch64-sme-intrinsics/acle_sme_ld1_vnum.c
Clang :: CodeGen/aarch64-sme-intrinsics/acle_sme_st1.c
Clang :: CodeGen/aarch64-sme-intrinsics/acle_sme_st1_vnum.c
Clang :: CodeGen/aarch64-sve-acle-__ARM_FEATURE_SVE_VECTOR_OPERATORS.c
Clang :: CodeGen/aarch64-sve-acle-__ARM_FEATURE_SVE_VECTOR_OPERATORS.cpp
Clang :: CodeGen/arm-cmse.c
Clang :: CodeGen/arm64-mte.c
Clang :: CodeGen/builtins-multiprecision.c
Clang :: CodeGen/builtins-wasm.c
Clang :: CodeGen/cfi-icall-cross-dso.c
Clang :: CodeGen/fp-contract-on-pragma.cpp
Clang :: CodeGen/fp-contract-pragma.cpp
Clang :: CodeGen/fp-strictfp-exp.cpp
Clang :: CodeGen/inline-asm-aarch64-flag-output.c
Clang :: CodeGen/inline-asm-x86-flag-output.c
Clang :: CodeGen/ms-intrinsics-other.c
Clang :: CodeGen/ms-intrinsics.c
Clang :: CodeGen/neon-crypto.c
Clang :: CodeGenCXX/RelativeVTablesABI/dynamic-cast.cpp
Clang :: CodeGenCXX/microsoft-abi-dynamic-cast.cpp
Clang :: CodeGenCXX/microsoft-abi-typeid.cpp
Clang :: CodeGenCXX/sizeof-unwind-exception.cpp
Clang :: CodeGenObjC/synchronized.m
Clang :: CodeGenObjCXX/exceptions-legacy.mm
Clang :: CodeGenOpenCL/builtins-amdgcn-dl-insts-gfx11.cl
Clang :: CodeGenOpenCL/builtins-amdgcn-dl-insts.cl
Clang :: CodeGenOpenCL/builtins-amdgcn-fp8.cl
Clang :: CodeGenOpenCL/builtins-amdgcn-gfx10.cl
Clang :: CodeGenOpenCL/builtins-amdgcn-gfx11.cl
Clang :: CodeGenOpenCL/builtins-amdgcn-gfx9.cl
Clang :: CodeGenOpenCL/builtins-amdgcn-mfma.cl
Clang :: CodeGenOpenCL/builtins-amdgcn-vi.cl
Clang :: CodeGenOpenCL/builtins-amdgcn-wmma-w32.cl
Clang :: CodeGenOpenCL/builtins-amdgcn-wmma-w64.cl
Clang :: CodeGenOpenCL/builtins-amdgcn.cl
Clang :: CodeGenOpenCL/builtins-f16.cl
Clang :: CodeGenOpenCL/builtins-generic-amdgcn.cl
Clang :: CodeGenOpenCL/single-precision-constant.cl
Clang :: Headers/__clang_hip_cmath.hip
Clang :: Headers/__clang_hip_math.hip
Clang :: Headers/__clang_hip_math_ocml_rounded_ops.hip
Clang :: Headers/ms-arm64-intrin.cpp
Clang :: OpenMP/bug57757.cpp

Is there a way to autoregen them, some of them need a few thousand changes 
(just adding `noundef` for the most part) that hopefully doesn't need to be 
done by hand.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152226

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


[PATCH] D152226: [FunctionAttrs] Propagate some func/arg/ret attributes from caller to callsite (WIP)

2023-06-05 Thread Noah Goldstein via Phabricator via cfe-commits
goldstein.w.n created this revision.
goldstein.w.n added reviewers: nikic, fhahn, jdoerfert, arsenm.
Herald added subscribers: libc-commits, luke, pmatos, asb, ormris, StephenFan, 
frasercrmck, luismarques, apazos, sameer.abuasal, pengfei, s.egerton, Jim, 
jocewei, PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, 
zzheng, jrtc27, niosHD, sabuasal, simoncook, johnrusso, rbar, kbarton, 
hiraditya, sbc100, nemanjai.
Herald added projects: libc-project, All.
goldstein.w.n requested review of this revision.
Herald added subscribers: llvm-commits, cfe-commits, pcwang-thead, MaskRay, 
aheejin, wdng.
Herald added a reviewer: sstefan1.
Herald added projects: clang, LLVM.

This is the consolidation of D151644  and 
D151943  moved from
InstCombine to FunctionAttrs. This is based on discussion in the above
patches as well as D152081  (Attributor). 
This patch was written in a
way so it can have an immediate impact in currently active passes
(FunctionAttrs), but should be easy to port elsewhere (Attributor or
Inliner) if that makes more sense later on.

Some function attributes imply the attribute for all/some instructions
in the function. These attributes can be safely propagated to
callsites within the function that are missing the attribute. This can
be useful when 1) analyzing individual instructions in a function and

2. if the original caller is later inlined, as if the attributes are

not propagated, they will be lost.

This patch implements propagation in a new class/file
`InferCallsiteAttrs` which can hypothetically be included elsewhere.

At the moment this patch infers the following:

Function Attributes:

- mustprogress
- nofree
- willreturn
- All memory attributes (readnone, readonly, writeonly, argmem, etc...)
  - The memory attributes are only propagated IFF the set of pointers available 
to the callsite is the same as the set available outside the caller (i.e no 
local memory arguments from alloca or local malloc like functions).

Argument Attributes:

- noundef
- nonnull
- nofree
- readnone
- readonly
- writeonly
- nocapture
  - nocapture is only propagated IFF the set of pointers available to the 
callsite is the same as the set available outside the caller and its guranteed 
that between the callsite and function return, the state of any capture 
pointers will not change (so the nocaptured gurantee of the caller has been met 
by the instruction preceding the callsite and will not changed).

Argument are only propagated to callsite arguments that are also function
arguments, but not derived values.

Return Attributes:

- noundef
- nonnull

Return attributes are only propagated if the callsite's return value
is used as the caller's return and execution is guranteed to pass from
callsite to return.

The compile time hit of this for -O3 and -O3+thinLTO is ~[.02, .37]%
regression. Proper LTO, however, has more significant regressions (up
to 3.92%):
https://llvm-compile-time-tracker.com/compare.php?from=94407e1bba9807193afde61c56b6125c0fc0b1d1=79feb6e78b818e33ec69abdc58c5f713d691554f=instructions:u


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D152226

Files:
  clang/test/CodeGen/LoongArch/inline-asm-constraints.c
  clang/test/CodeGen/LoongArch/inline-asm-operand-modifiers.c
  clang/test/CodeGen/LoongArch/intrinsic-la32.c
  clang/test/CodeGen/LoongArch/intrinsic-la64.c
  clang/test/CodeGen/PowerPC/builtins-ppc-build-pair-mma.c
  clang/test/CodeGen/PowerPC/builtins-ppc-pair-mma.c
  
clang/test/CodeGen/PowerPC/builtins-ppc-xlcompat-LoadReseve-StoreCond-64bit-only.c
  clang/test/CodeGen/PowerPC/builtins-ppc-xlcompat-LoadReseve-StoreCond.c
  clang/test/CodeGen/PowerPC/ppc64-inline-asm.c
  clang/test/CodeGen/RISCV/riscv-inline-asm.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/vwrite-csr.c
  clang/test/CodeGen/X86/fma-builtins-constrained.c
  clang/test/CodeGen/X86/ms-x86-intrinsics.c
  clang/test/CodeGen/aarch64-bf16-ldst-intrinsics.c
  clang/test/CodeGen/aarch64-ls64-inline-asm.c
  clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_ldnt1.c
  clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_ldnt1sb.c
  clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_ldnt1sh.c
  clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_ldnt1sw.c
  clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_ldnt1ub.c
  clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_ldnt1uh.c
  clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_ldnt1uw.c
  clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_stnt1.c
  clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_stnt1b.c
  clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_stnt1h.c
  clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_stnt1w.c
  clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_whilege.c
  clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_whilegt.c
  

[PATCH] D152083: [clang] Warning for uninitialized elements in fixed-size arrays

2023-06-05 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added a reviewer: clang-language-wg.
shafik added a comment.

Adding reviewer for more visibility


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

https://reviews.llvm.org/D152083

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


[PATCH] D152090: [clang][Driver] Add -fcaret-diagnostics-max-lines as a driver option

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

In D152090#4395827 , @MaskRay wrote:

> `def fcaret_diagnostics_max_lines` in `Options.td` has the `NoDriverOption` 
> flag. Move it to other places with `BooleainFFlag` should work. 
> Then in `Clang.cpp` you can just write `Args.AddLastArg(...)`
>
> Can you add some description that this is related to D147875 
>  ?

Can you give a more concrete example? I modeled this patch after existing 
similar options, like `-fmacro-backtrace-limit`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152090

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


[PATCH] D151863: [x86][MC] Fix movdir64b addressing

2023-06-05 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: llvm/test/CodeGen/X86/movdir64b-inline-asm-x86_64.ll:1
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py 
UTC_ARGS: --version 2
+; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+movdir64b | FileCheck 
%s --check-prefix=X64

I think we should reuse an existing `*-inline-asm-*` test file.

See 
https://maskray.me/blog/2021-08-08-toolchain-testing#the-test-checks-at-the-wrong-layer
 "I don't know an existing test can be enhanced"


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151863

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


[PATCH] D148385: [RISCV] Implement KCFI operand bundle lowering

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

`KCFI_CHECK` lowering has some complexity to allocate a temporary register. 
This needs to following the calling convention which can be modified by many 
compiler options and function attributes.

I wonder whether we can move the if-condition part of the expanded code 
sequence (i.e. `if type-hashes mismatch; crash`) to ClangCodeGen (more like 
`-fsanitize=function`), and change the "kcfi" operand bundle to focus on 
expanding to a desired trap instruction (ud2 on x86-64).
On the plus side, this gives optimizers more opportunities to place trap basic 
blocks to cold regions.
On the downside, we cannot assume the code sequence is contiguous but that may 
be fine.

---

Some notice for other reviewers:

To emit `.kcfi_traps` and a preferred trap instruction, the instrumentation 
cannot be done purely in ClangCodeGen. Instead, the following scheme is used:

- ClangCodeGen emits "kcfi" operand bundles 
.
- In a target-overridden `TargetPassConfig::addPreSched`, add a KCFI pass to 
emit `KCFI_CHECK` pseudo instructions.
- In a target AsmPrinter, lower `KCFI_CHECK` pseudo instructions to a code 
sequence that crash if the type hashes don't match.

If a target doesn't implement `KCFI_CHECK` lowering, 
`llvm/lib/Transforms/Instrumentation/KCFI.cpp` is used to replace "kcfi" 
operand bundles with if conditions, then no `TargetPassConfig::addPreSched` or 
`KCFI_CHECK` lowering will be needed.
In this case, `llvm.debugtrap` is used to generate trap instructions.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148385

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


[PATCH] D127040: [InstrProf][WIP] Implement boolean counters in coverage

2023-06-05 Thread Gulfem Savrun Yeniceri via Phabricator via cfe-commits
gulfem abandoned this revision.
gulfem added a comment.
Herald added a subscriber: wlei.

Created a duplicate review by mistake.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127040

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


[PATCH] D105765: Prepare Compiler-RT for GnuInstallDirs, matching libcxx, document all

2023-06-05 Thread Tom Stellard via Phabricator via cfe-commits
tstellar added inline comments.
Herald added a subscriber: Enna1.
Herald added a project: All.



Comment at: compiler-rt/cmake/base-config-ix.cmake:126
+set(COMPILER_RT_INSTALL_DATA_DIR "${default_install_path}" CACHE PATH
+  "Path where compiler-rt data files should be installed.")
 

Was there supposed to be an extend_install_path call here?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105765

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


[PATCH] D152074: [6/11][Clang][RISCV] Expand all variants for strided segment load

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



Comment at: clang/include/clang/Basic/riscv_vector.td:1719
+
+  if (NoPassthru) // Push poison into passthru
+Operands.append(NF, llvm::PoisonValue::get(ElementVectorType));

Curly braces


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152074

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


[PATCH] D152073: [5/11][Clang][RISCV] Expand all variants for unit stride fault-first segment load

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



Comment at: clang/include/clang/Basic/riscv_vector.td:1645
+
+  if (NoPassthru) // Push poison into passthru
+Operands.append(NF, llvm::PoisonValue::get(ElementVectorType));

Curly braces


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152073

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


[PATCH] D152071: [3/11][Clang][RISCV] Expand all variants for unit stride segment load

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



Comment at: clang/include/clang/Basic/riscv_vector.td:1533
+
+  if (NoPassthru) // Push poison into passthru
+Operands.append(NF, llvm::PoisonValue::get(ElementVectorType));

`if` should use curly braces if the `else` uses curly braces.



Comment at: clang/lib/Support/RISCVVIntrinsicUtils.cpp:895
+  case 2:
+return VectorTypeModifier::Tuple2;
+  case 3:

Can we guarantee Tuple2-8 are contiguous? Then we can do `return (NF - 2) + 
VectorTypeModifier::Tuple2`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152071

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


[PATCH] D152070: [2/11][Clang][RISCV] Expand all variants of RVV intrinsic tuple types

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



Comment at: clang/include/clang/Basic/RISCVVTypes.def:224
+RVV_VECTOR_TYPE_INT("__rvv_uint8m4x2_t", RvvUint8m4x2, RvvUint8m4x2Ty, 32, 8, 
2, false)
+//===- Int16 tuple types 
--===//
+RVV_VECTOR_TYPE_INT("__rvv_int16mf4x2_t", RvvInt16mf4x2, RvvInt16mf4x2Ty, 1, 
16, 2, true)

Blank line before the start of each section



Comment at: clang/utils/TableGen/RISCVVEmitter.cpp:161
+  switch(NF) {
+case 2: return VectorTypeModifier::Tuple2;
+case 3: return VectorTypeModifier::Tuple3;

`case` should start at the same column as `switch`



Comment at: clang/utils/TableGen/RISCVVEmitter.cpp:163
+case 3: return VectorTypeModifier::Tuple3;
+case 4:
+  return VectorTypeModifier::Tuple4;

Inconsistent formatting between case 2-3 and 4-8.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152070

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


[clang] 949830a - [OpenMP] Mark kernels as mustprogress

2023-06-05 Thread Johannes Doerfert via cfe-commits

Author: Johannes Doerfert
Date: 2023-06-05T16:33:53-07:00
New Revision: 949830af4246688899657ac1974041804a143ae1

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

LOG: [OpenMP] Mark kernels as mustprogress

Added: 


Modified: 
clang/test/OpenMP/amdgcn-attributes.cpp
llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp

Removed: 




diff  --git a/clang/test/OpenMP/amdgcn-attributes.cpp 
b/clang/test/OpenMP/amdgcn-attributes.cpp
index bd0beb0ea289a..cfb4370da6860 100644
--- a/clang/test/OpenMP/amdgcn-attributes.cpp
+++ b/clang/test/OpenMP/amdgcn-attributes.cpp
@@ -32,10 +32,10 @@ int callable(int x) {
   return x + 1;
 }
 
-// DEFAULT: attributes #0 = { convergent noinline norecurse nounwind optnone 
"kernel" "no-trapping-math"="true" "stack-protector-buffer-size"="8" 
"uniform-work-group-size"="true" }
-// CPU: attributes #0 = { convergent noinline norecurse nounwind optnone 
"kernel" "no-trapping-math"="true" "stack-protector-buffer-size"="8" 
"target-cpu"="gfx900" 
"target-features"="+16-bit-insts,+ci-insts,+dpp,+gfx8-insts,+gfx9-insts,+s-memrealtime,+s-memtime-inst,+wavefrontsize64"
 "uniform-work-group-size"="true" }
-// NOIEEE: attributes #0 = { convergent noinline norecurse nounwind optnone 
"amdgpu-ieee"="false" "kernel" "no-nans-fp-math"="true" 
"no-trapping-math"="true" "stack-protector-buffer-size"="8" 
"uniform-work-group-size"="true" }
-// UNSAFEATOMIC: attributes #0 = { convergent noinline norecurse nounwind 
optnone "amdgpu-unsafe-fp-atomics"="true" "kernel" "no-trapping-math"="true" 
"stack-protector-buffer-size"="8" "uniform-work-group-size"="true" }
+// DEFAULT: attributes #0 = { convergent mustprogress noinline norecurse 
nounwind optnone "kernel" "no-trapping-math"="true" 
"stack-protector-buffer-size"="8" "uniform-work-group-size"="true" }
+// CPU: attributes #0 = { convergent mustprogress noinline norecurse nounwind 
optnone "kernel" "no-trapping-math"="true" "stack-protector-buffer-size"="8" 
"target-cpu"="gfx900" 
"target-features"="+16-bit-insts,+ci-insts,+dpp,+gfx8-insts,+gfx9-insts,+s-memrealtime,+s-memtime-inst,+wavefrontsize64"
 "uniform-work-group-size"="true" }
+// NOIEEE: attributes #0 = { convergent mustprogress noinline norecurse 
nounwind optnone "amdgpu-ieee"="false" "kernel" "no-nans-fp-math"="true" 
"no-trapping-math"="true" "stack-protector-buffer-size"="8" 
"uniform-work-group-size"="true" }
+// UNSAFEATOMIC: attributes #0 = { convergent mustprogress noinline norecurse 
nounwind optnone "amdgpu-unsafe-fp-atomics"="true" "kernel" 
"no-trapping-math"="true" "stack-protector-buffer-size"="8" 
"uniform-work-group-size"="true" }
 
 // DEFAULT: attributes #1 = { convergent mustprogress noinline nounwind 
optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" }
 // CPU: attributes #1 = { convergent mustprogress noinline nounwind optnone 
"no-trapping-math"="true" "stack-protector-buffer-size"="8" 
"target-cpu"="gfx900" 
"target-features"="+16-bit-insts,+ci-insts,+dpp,+gfx8-insts,+gfx9-insts,+s-memrealtime,+s-memtime-inst,+wavefrontsize64"
 }

diff  --git a/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp 
b/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
index 19ba9e8c22436..3f6ba1a90c036 100644
--- a/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
+++ b/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
@@ -22,6 +22,7 @@
 #include "llvm/Analysis/ScalarEvolution.h"
 #include "llvm/Analysis/TargetLibraryInfo.h"
 #include "llvm/Bitcode/BitcodeReader.h"
+#include "llvm/IR/Attributes.h"
 #include "llvm/IR/CFG.h"
 #include "llvm/IR/Constants.h"
 #include "llvm/IR/DebugInfoMetadata.h"
@@ -5025,6 +5026,7 @@ void OpenMPIRBuilder::createOffloadEntry(Constant *ID, 
Constant *Addr,
   Fn->addFnAttr(Attribute::get(Ctx, "kernel"));
   if (Triple(M.getTargetTriple()).isAMDGCN())
 Fn->addFnAttr("uniform-work-group-size", "true");
+  Fn->addFnAttr(Attribute::MustProgress);
 }
 
 // We only generate metadata for function that contain target regions.



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


[PATCH] D150427: [AMDGPU] Non hostcall printf support for HIP

2023-06-05 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added a comment.

Also should be noted in the release notes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150427

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


[PATCH] D150427: [AMDGPU] Non hostcall printf support for HIP

2023-06-05 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added inline comments.



Comment at: clang/test/CodeGenHIP/printf_nonhostcall.cpp:137
+
+__device__ float f1 = 3.14f;
+__device__ double f2 = 2.71828;

Also half 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150427

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


[PATCH] D150427: [AMDGPU] Non hostcall printf support for HIP

2023-06-05 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added inline comments.



Comment at: llvm/lib/Transforms/Utils/AMDGPUEmitPrintf.cpp:371
+// the offsets.
+uint64_t DstAlign = (i == 0) ? 4 : 8;
+Builder.CreateMemCpy(PtrToStore, /*DstAlign*/ Align(DstAlign), Args[i],

I don't follow this alignment logic, but I guess the optimizer will figure it 
out later anyway so I suppose the Align(1) was fine.

Also should use Align.



Comment at: llvm/lib/Transforms/Utils/AMDGPUEmitPrintf.cpp:373
+Builder.CreateMemCpy(PtrToStore, /*DstAlign*/ Align(DstAlign), Args[i],
+ /*SrcAlign*/ Align(1), StrIt->RealSize);
+

The source align is known



Comment at: llvm/lib/Transforms/Utils/AMDGPUEmitPrintf.cpp:386-387
+} else {
+  auto IntTy = dyn_cast(Args[i]->getType());
+  if (IntTy && IntTy->getBitWidth() == 32)
+WhatToStore.push_back(

isIntegerTy(32).

I also do not understand why only 32-bit integers would be promoted to 64-bit 
(or why this would be zext). This doesn't match varargs ABI handling, where 
everything smaller would be promoted to i32.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150427

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


[PATCH] D151587: [clang][ConstantEmitter] have tryEmitPrivateForVarInit try ConstExprEmitter fast-path first

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

> Yeah, but not because of this patch; that's a pre-existing issue.

Right; the _Atomic crashes are a pre-existing issue unrelated to 
MaterializeTemporaryExpr, so you shouldn't be trying to solve it by messing 
with HasAnyMaterializeTemporaryExpr.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151587

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


[PATCH] D151587: [clang][ConstantEmitter] have tryEmitPrivateForVarInit try ConstExprEmitter fast-path first

2023-06-05 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added a comment.

In D151587#4397446 , @efriedma wrote:

> The following also crashes, with no MaterializeTemporaryExpr involved.
>
>   struct X {
> short n;
> char c;
>   };
>   
>   struct Y {
> _Atomic(X) a;
> _Atomic(int) b;
>   };
>   constexpr X x{};
>   int z;
>   Y y = { x, z };

Yeah, but not because of this patch; that's a pre-existing issue.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151587

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


[PATCH] D152207: [HIP] Instruct lld to go through all archives

2023-06-05 Thread Siu Chi Chan via Phabricator via cfe-commits
scchan created this revision.
Herald added a subscriber: yaxunl.
Herald added a project: All.
scchan requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay.
Herald added a project: clang.

Add the --whole-archive flag when linking HIP programs to instruct lld
to go through every archive library to link in all the kernel functions
(entry pointers to the GPU program); otherwise, lld may skip some
library files if there are no more symbols that need to be resolved.

Change-Id: Ic7ea61ec3e6925f80a63d04654ac72177ffb27c8


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D152207

Files:
  clang/lib/Driver/ToolChains/HIPAMD.cpp
  clang/test/Driver/hip-toolchain-rdc-separate.hip
  clang/test/Driver/hip-toolchain-rdc-static-lib.hip


Index: clang/test/Driver/hip-toolchain-rdc-static-lib.hip
===
--- clang/test/Driver/hip-toolchain-rdc-static-lib.hip
+++ clang/test/Driver/hip-toolchain-rdc-static-lib.hip
@@ -81,6 +81,7 @@
 // CHECK: [[LLD]] {{.*}} "-plugin-opt=-amdgpu-internalize-symbols"
 // CHECK-SAME: "-plugin-opt=mcpu=gfx900"
 // CHECK-SAME: "-o" "[[IMG_DEV2:.*out]]" [[A_BC2]] [[B_BC2]]
+// CHECK-SAME: "--whole-archive"
 
 // combine images generated into hip fat binary object
 // CHECK: [[BUNDLER:".*clang-offload-bundler"]] "-type=o"
Index: clang/test/Driver/hip-toolchain-rdc-separate.hip
===
--- clang/test/Driver/hip-toolchain-rdc-separate.hip
+++ clang/test/Driver/hip-toolchain-rdc-separate.hip
@@ -129,6 +129,7 @@
 // LLD-TMP-SAME: "-o" "[[IMG_DEV1:.*.out]]"
 // LLD-FIN-SAME: "-o" "[[IMG_DEV1:a.out-.*gfx803]]"
 // LINK-SAME "[[A_BC1]]" "[[B_BC1]]"
+// LINK-SAME: "--whole-archive"
 
 // LINK-NOT: "*.llvm-link"
 // LINK-NOT: ".*opt"
@@ -138,6 +139,7 @@
 // LLD-TMP-SAME: "-o" "[[IMG_DEV2:.*.out]]"
 // LLD-FIN-SAME: "-o" "[[IMG_DEV1:a.out-.*gfx900]]"
 // LINK-SAME "[[A_BC2]]" "[[B_BC2]]"
+// LINK-SAME: "--whole-archive"
 
 // LINK-BUNDLE: [[BUNDLER:".*clang-offload-bundler"]] "-type=o"
 // LINK-BUNDLE-SAME: 
"-targets={{.*}},hipv4-amdgcn-amd-amdhsa--gfx803,hipv4-amdgcn-amd-amdhsa--gfx900"
Index: clang/lib/Driver/ToolChains/HIPAMD.cpp
===
--- clang/lib/Driver/ToolChains/HIPAMD.cpp
+++ clang/lib/Driver/ToolChains/HIPAMD.cpp
@@ -163,6 +163,9 @@
 
   // Look for archive of bundled bitcode in arguments, and add temporary files
   // for the extracted archive of bitcode to inputs.
+  // The archive libraries have to be linked with --whole-archive to instruct
+  // the linker to go through every library to look for kernel functions
+  LldArgs.push_back("--whole-archive");
   auto TargetID = Args.getLastArgValue(options::OPT_mcpu_EQ);
   AddStaticDeviceLibsLinking(C, *this, JA, Inputs, Args, LldArgs, "amdgcn",
  TargetID,


Index: clang/test/Driver/hip-toolchain-rdc-static-lib.hip
===
--- clang/test/Driver/hip-toolchain-rdc-static-lib.hip
+++ clang/test/Driver/hip-toolchain-rdc-static-lib.hip
@@ -81,6 +81,7 @@
 // CHECK: [[LLD]] {{.*}} "-plugin-opt=-amdgpu-internalize-symbols"
 // CHECK-SAME: "-plugin-opt=mcpu=gfx900"
 // CHECK-SAME: "-o" "[[IMG_DEV2:.*out]]" [[A_BC2]] [[B_BC2]]
+// CHECK-SAME: "--whole-archive"
 
 // combine images generated into hip fat binary object
 // CHECK: [[BUNDLER:".*clang-offload-bundler"]] "-type=o"
Index: clang/test/Driver/hip-toolchain-rdc-separate.hip
===
--- clang/test/Driver/hip-toolchain-rdc-separate.hip
+++ clang/test/Driver/hip-toolchain-rdc-separate.hip
@@ -129,6 +129,7 @@
 // LLD-TMP-SAME: "-o" "[[IMG_DEV1:.*.out]]"
 // LLD-FIN-SAME: "-o" "[[IMG_DEV1:a.out-.*gfx803]]"
 // LINK-SAME "[[A_BC1]]" "[[B_BC1]]"
+// LINK-SAME: "--whole-archive"
 
 // LINK-NOT: "*.llvm-link"
 // LINK-NOT: ".*opt"
@@ -138,6 +139,7 @@
 // LLD-TMP-SAME: "-o" "[[IMG_DEV2:.*.out]]"
 // LLD-FIN-SAME: "-o" "[[IMG_DEV1:a.out-.*gfx900]]"
 // LINK-SAME "[[A_BC2]]" "[[B_BC2]]"
+// LINK-SAME: "--whole-archive"
 
 // LINK-BUNDLE: [[BUNDLER:".*clang-offload-bundler"]] "-type=o"
 // LINK-BUNDLE-SAME: "-targets={{.*}},hipv4-amdgcn-amd-amdhsa--gfx803,hipv4-amdgcn-amd-amdhsa--gfx900"
Index: clang/lib/Driver/ToolChains/HIPAMD.cpp
===
--- clang/lib/Driver/ToolChains/HIPAMD.cpp
+++ clang/lib/Driver/ToolChains/HIPAMD.cpp
@@ -163,6 +163,9 @@
 
   // Look for archive of bundled bitcode in arguments, and add temporary files
   // for the extracted archive of bitcode to inputs.
+  // The archive libraries have to be linked with --whole-archive to instruct
+  // the linker to go through every library to look for kernel functions
+  LldArgs.push_back("--whole-archive");
   auto TargetID = Args.getLastArgValue(options::OPT_mcpu_EQ);
   AddStaticDeviceLibsLinking(C, *this, JA, Inputs, Args, 

[PATCH] D151587: [clang][ConstantEmitter] have tryEmitPrivateForVarInit try ConstExprEmitter fast-path first

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

The following also crashes, with no MaterializeTemporaryExpr involved.

  struct X {
short n;
char c;
  };
  
  struct Y {
_Atomic(X) a;
_Atomic(int) b;
  };
  constexpr X x{};
  int z;
  Y y = { x, z };


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151587

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


[PATCH] D131594: Add Clang UEFI target to support "x86_64-unknown-uefi" triple

2023-06-05 Thread Prabhu Karthikeyan Rajasekaran via Phabricator via cfe-commits
Prabhuk updated this revision to Diff 528610.
Prabhuk added a comment.

Updated commit message.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131594

Files:
  llvm/include/llvm/MC/TargetRegistry.h
  llvm/include/llvm/TargetParser/Triple.h
  llvm/lib/MC/MCContext.cpp
  llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp
  llvm/lib/Target/X86/MCTargetDesc/X86MCAsmInfo.cpp
  llvm/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.cpp
  llvm/lib/Target/X86/X86MCInstLower.cpp
  llvm/lib/TargetParser/Triple.cpp
  llvm/unittests/TargetParser/TripleTest.cpp

Index: llvm/unittests/TargetParser/TripleTest.cpp
===
--- llvm/unittests/TargetParser/TripleTest.cpp
+++ llvm/unittests/TargetParser/TripleTest.cpp
@@ -349,6 +349,12 @@
   EXPECT_EQ(Triple::HermitCore, T.getOS());
   EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
 
+  T = Triple("x86_64-unknown-uefi");
+  EXPECT_EQ(Triple::x86_64, T.getArch());
+  EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
+  EXPECT_EQ(Triple::UEFI, T.getOS());
+  EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
+
   T = Triple("wasm32-unknown-unknown");
   EXPECT_EQ(Triple::wasm32, T.getArch());
   EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
Index: llvm/lib/TargetParser/Triple.cpp
===
--- llvm/lib/TargetParser/Triple.cpp
+++ llvm/lib/TargetParser/Triple.cpp
@@ -238,6 +238,7 @@
   case RTEMS: return "rtems";
   case Solaris: return "solaris";
   case TvOS: return "tvos";
+  case UEFI: return "uefi";
   case WASI: return "wasi";
   case WatchOS: return "watchos";
   case Win32: return "windows";
@@ -588,6 +589,7 @@
 .StartsWith("netbsd", Triple::NetBSD)
 .StartsWith("openbsd", Triple::OpenBSD)
 .StartsWith("solaris", Triple::Solaris)
+.StartsWith("uefi", Triple::UEFI)
 .StartsWith("win32", Triple::Win32)
 .StartsWith("windows", Triple::Win32)
 .StartsWith("zos", Triple::ZOS)
Index: llvm/lib/Target/X86/X86MCInstLower.cpp
===
--- llvm/lib/Target/X86/X86MCInstLower.cpp
+++ llvm/lib/Target/X86/X86MCInstLower.cpp
@@ -1555,7 +1555,8 @@
 
 void X86AsmPrinter::EmitSEHInstruction(const MachineInstr *MI) {
   assert(MF->hasWinCFI() && "SEH_ instruction in function without WinCFI?");
-  assert(getSubtarget().isOSWindows() && "SEH_ instruction Windows only");
+  assert((getSubtarget().isOSWindows() || TM.getTargetTriple().isUEFI()) &&
+ "SEH_ instruction Windows and UEFI only");
 
   // Use the .cv_fpo directives if we're emitting CodeView on 32-bit x86.
   if (EmitFPOData) {
Index: llvm/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.cpp
===
--- llvm/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.cpp
+++ llvm/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.cpp
@@ -441,6 +441,8 @@
   } else if (TheTriple.isOSCygMing() ||
  TheTriple.isWindowsItaniumEnvironment()) {
 MAI = new X86MCAsmInfoGNUCOFF(TheTriple);
+  } else if (TheTriple.isUEFI()) {
+MAI = new X86MCAsmInfoGNUCOFF(TheTriple);
   } else {
 // The default is ELF.
 MAI = new X86ELFMCAsmInfo(TheTriple);
Index: llvm/lib/Target/X86/MCTargetDesc/X86MCAsmInfo.cpp
===
--- llvm/lib/Target/X86/MCTargetDesc/X86MCAsmInfo.cpp
+++ llvm/lib/Target/X86/MCTargetDesc/X86MCAsmInfo.cpp
@@ -153,7 +153,8 @@
 void X86MCAsmInfoGNUCOFF::anchor() { }
 
 X86MCAsmInfoGNUCOFF::X86MCAsmInfoGNUCOFF(const Triple ) {
-  assert(Triple.isOSWindows() && "Windows is the only supported COFF target");
+  assert((Triple.isOSWindows() || Triple.isUEFI()) &&
+ "Windows and UEFI are the only supported COFF targets");
   if (Triple.getArch() == Triple::x86_64) {
 PrivateGlobalPrefix = ".L";
 PrivateLabelPrefix = ".L";
Index: llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp
===
--- llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp
+++ llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp
@@ -1516,6 +1516,12 @@
   if (TheTriple.isOSWindows() && TheTriple.isOSBinFormatCOFF())
 return new WindowsX86AsmBackend(T, true, STI);
 
+  if (TheTriple.isUEFI()) {
+assert(TheTriple.isOSBinFormatCOFF() &&
+ "Only COFF format is supported in UEFI environment.");
+return new WindowsX86AsmBackend(T, true, STI);
+  }
+
   uint8_t OSABI = MCELFObjectTargetWriter::getOSABI(TheTriple.getOS());
 
   if (TheTriple.isX32())
Index: llvm/lib/MC/MCContext.cpp
===
--- llvm/lib/MC/MCContext.cpp
+++ llvm/lib/MC/MCContext.cpp
@@ -85,7 +85,7 @@
 Env = IsMachO;
 break;
   case Triple::COFF:
-if (!TheTriple.isOSWindows())
+if (!TheTriple.isOSWindows() && 

[PATCH] D152206: [Basic] Support 64-bit x86 target for UEFI

2023-06-05 Thread Prabhu Karthikeyan Rajasekaran via Phabricator via cfe-commits
Prabhuk updated this revision to Diff 528609.
Prabhuk added a comment.

Update commit message.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152206

Files:
  clang/lib/Basic/Targets.cpp
  clang/lib/Basic/Targets/OSTargets.h
  clang/lib/Basic/Targets/X86.h
  clang/lib/Driver/CMakeLists.txt
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChains/UEFI.cpp
  clang/lib/Driver/ToolChains/UEFI.h

Index: clang/lib/Driver/ToolChains/UEFI.h
===
--- /dev/null
+++ clang/lib/Driver/ToolChains/UEFI.h
@@ -0,0 +1,58 @@
+//===--- UEFI.h - UEFI ToolChain Implementations --*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_UEFI_H
+#define LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_UEFI_H
+#include "clang/Driver/Tool.h"
+#include "clang/Driver/ToolChain.h"
+
+namespace clang {
+namespace driver {
+namespace tools {
+namespace uefi {
+class LLVM_LIBRARY_VISIBILITY Linker : public Tool {
+public:
+  Linker(const ToolChain ) : Tool("uefi::Linker", "lld-link", TC) {}
+
+  bool hasIntegratedCPP() const override { return false; }
+  bool isLinkJob() const override { return true; }
+
+  void ConstructJob(Compilation , const JobAction ,
+const InputInfo , const InputInfoList ,
+const llvm::opt::ArgList ,
+const char *LinkingOutput) const override;
+};
+} // end namespace uefi
+} // end namespace tools
+
+namespace toolchains {
+
+class LLVM_LIBRARY_VISIBILITY UEFI : public ToolChain {
+public:
+  UEFI(const Driver , const llvm::Triple ,
+   const llvm::opt::ArgList );
+
+protected:
+  Tool *buildLinker() const override;
+
+public:
+  bool HasNativeLLVMSupport() const override { return true; }
+  bool IsIntegratedAssemblerDefault() const override { return true; }
+  bool IsUnwindTablesDefault(const llvm::opt::ArgList ) const {
+return true;
+  }
+  bool isPICDefault() const override { return true; }
+  bool isPIEDefault(const llvm::opt::ArgList ) const override {
+return false;
+  }
+  bool isPICDefaultForced() const override { return true; }
+};
+} // namespace toolchains
+} // namespace driver
+} // namespace clang
+#endif // LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_UEFI_H
Index: clang/lib/Driver/ToolChains/UEFI.cpp
===
--- /dev/null
+++ clang/lib/Driver/ToolChains/UEFI.cpp
@@ -0,0 +1,105 @@
+//===--- UEFI.h - UEFI ToolChain Implementations --*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "UEFI.h"
+#include "CommonArgs.h"
+#include "Darwin.h"
+#include "clang/Basic/CharInfo.h"
+#include "clang/Basic/Version.h"
+#include "clang/Config/config.h"
+#include "clang/Driver/Compilation.h"
+#include "clang/Driver/Driver.h"
+#include "clang/Driver/Options.h"
+#include "clang/Driver/SanitizerArgs.h"
+#include "llvm/ADT/StringExtras.h"
+#include "llvm/ADT/StringSwitch.h"
+#include "llvm/Option/Arg.h"
+#include "llvm/Option/ArgList.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/MemoryBuffer.h"
+#include "llvm/Support/VirtualFileSystem.h"
+#include "llvm/TargetParser/Host.h"
+
+using namespace clang::driver;
+using namespace clang::driver::toolchains;
+using namespace clang;
+using namespace llvm::opt;
+
+UEFI::UEFI(const Driver , const llvm::Triple , const ArgList )
+: ToolChain(D, Triple, Args) {
+  getProgramPaths().push_back(getDriver().getInstalledDir());
+  if (getDriver().getInstalledDir() != getDriver().Dir)
+getProgramPaths().push_back(getDriver().Dir);
+}
+
+Tool *UEFI::buildLinker() const { return new tools::uefi::Linker(*this); }
+
+void tools::uefi::Linker::ConstructJob(Compilation , const JobAction ,
+   const InputInfo ,
+   const InputInfoList ,
+   const ArgList ,
+   const char *LinkingOutput) const {
+  ArgStringList CmdArgs;
+
+  auto  = static_cast(getToolChain());
+
+  assert((Output.isFilename() || Output.isNothing()) && "invalid output");
+  if (Output.isFilename())
+CmdArgs.push_back(
+Args.MakeArgString(std::string("-out:") + Output.getFilename()));
+
+  CmdArgs.push_back("-nologo");
+
+  if (Args.hasArg(options::OPT_g_Group, options::OPT__SLASH_Z7))
+CmdArgs.push_back("-debug");
+
+  

[PATCH] D152206: [Basic] Support 64-bit x86 target for UEFI

2023-06-05 Thread Prabhu Karthikeyan Rajasekaran via Phabricator via cfe-commits
Prabhuk created this revision.
Prabhuk added a reviewer: phosek.
Herald added a subscriber: pengfei.
Herald added a project: All.
Prabhuk requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay.
Herald added a project: clang.

Adding support for X86_64 UEFI target to begin with.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D152206

Files:
  clang/lib/Basic/Targets.cpp
  clang/lib/Basic/Targets/OSTargets.h
  clang/lib/Basic/Targets/X86.h
  clang/lib/Driver/CMakeLists.txt
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChains/UEFI.cpp
  clang/lib/Driver/ToolChains/UEFI.h

Index: clang/lib/Driver/ToolChains/UEFI.h
===
--- /dev/null
+++ clang/lib/Driver/ToolChains/UEFI.h
@@ -0,0 +1,58 @@
+//===--- UEFI.h - UEFI ToolChain Implementations --*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_UEFI_H
+#define LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_UEFI_H
+#include "clang/Driver/Tool.h"
+#include "clang/Driver/ToolChain.h"
+
+namespace clang {
+namespace driver {
+namespace tools {
+namespace uefi {
+class LLVM_LIBRARY_VISIBILITY Linker : public Tool {
+public:
+  Linker(const ToolChain ) : Tool("uefi::Linker", "lld-link", TC) {}
+
+  bool hasIntegratedCPP() const override { return false; }
+  bool isLinkJob() const override { return true; }
+
+  void ConstructJob(Compilation , const JobAction ,
+const InputInfo , const InputInfoList ,
+const llvm::opt::ArgList ,
+const char *LinkingOutput) const override;
+};
+} // end namespace uefi
+} // end namespace tools
+
+namespace toolchains {
+
+class LLVM_LIBRARY_VISIBILITY UEFI : public ToolChain {
+public:
+  UEFI(const Driver , const llvm::Triple ,
+   const llvm::opt::ArgList );
+
+protected:
+  Tool *buildLinker() const override;
+
+public:
+  bool HasNativeLLVMSupport() const override { return true; }
+  bool IsIntegratedAssemblerDefault() const override { return true; }
+  bool IsUnwindTablesDefault(const llvm::opt::ArgList ) const {
+return true;
+  }
+  bool isPICDefault() const override { return true; }
+  bool isPIEDefault(const llvm::opt::ArgList ) const override {
+return false;
+  }
+  bool isPICDefaultForced() const override { return true; }
+};
+} // namespace toolchains
+} // namespace driver
+} // namespace clang
+#endif // LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_UEFI_H
Index: clang/lib/Driver/ToolChains/UEFI.cpp
===
--- /dev/null
+++ clang/lib/Driver/ToolChains/UEFI.cpp
@@ -0,0 +1,105 @@
+//===--- UEFI.h - UEFI ToolChain Implementations --*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "UEFI.h"
+#include "CommonArgs.h"
+#include "Darwin.h"
+#include "clang/Basic/CharInfo.h"
+#include "clang/Basic/Version.h"
+#include "clang/Config/config.h"
+#include "clang/Driver/Compilation.h"
+#include "clang/Driver/Driver.h"
+#include "clang/Driver/Options.h"
+#include "clang/Driver/SanitizerArgs.h"
+#include "llvm/ADT/StringExtras.h"
+#include "llvm/ADT/StringSwitch.h"
+#include "llvm/Option/Arg.h"
+#include "llvm/Option/ArgList.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/MemoryBuffer.h"
+#include "llvm/Support/VirtualFileSystem.h"
+#include "llvm/TargetParser/Host.h"
+
+using namespace clang::driver;
+using namespace clang::driver::toolchains;
+using namespace clang;
+using namespace llvm::opt;
+
+UEFI::UEFI(const Driver , const llvm::Triple , const ArgList )
+: ToolChain(D, Triple, Args) {
+  getProgramPaths().push_back(getDriver().getInstalledDir());
+  if (getDriver().getInstalledDir() != getDriver().Dir)
+getProgramPaths().push_back(getDriver().Dir);
+}
+
+Tool *UEFI::buildLinker() const { return new tools::uefi::Linker(*this); }
+
+void tools::uefi::Linker::ConstructJob(Compilation , const JobAction ,
+   const InputInfo ,
+   const InputInfoList ,
+   const ArgList ,
+   const char *LinkingOutput) const {
+  ArgStringList CmdArgs;
+
+  auto  = static_cast(getToolChain());
+
+  assert((Output.isFilename() || Output.isNothing()) && "invalid output");
+  if (Output.isFilename())
+CmdArgs.push_back(
+Args.MakeArgString(std::string("-out:") + 

[PATCH] D151587: [clang][ConstantEmitter] have tryEmitPrivateForVarInit try ConstExprEmitter fast-path first

2023-06-05 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added a comment.

In D151587#4397272 , @efriedma wrote:

> Two points I'm not sure about in the current version:
>
> - Handling MaterializeTemporaryExpr in ConstExprEmitter doesn't make sense; 
> ConstExprEmitter is not supposed to visit lvalues. (And I'm not sure what the 
> new check is supposed to do; `E->isGLValue()` is always true for a 
> MaterializeTemporaryExpr.)  Maybe try something like the following?

Yeah, that works.

> - HasAnyMaterializeTemporaryExpr shouldn't need to handle 
> VisitCXXConstructExpr.  The EvaluateAsLValue bug only applies to 
> lifetime-extended temporaries.  Any MaterializeTemporaryExpr that's the 
> operand of a VisitCXXConstructExpr should not be lifetime-extended beyond the 
> end of the expression. So it won't run into the EvaluateAsLValue issue.  
> (https://en.cppreference.com/w/cpp/language/reference_initialization#Lifetime_of_a_temporary
>  should be a complete list of cases where we might need to recurse; none of 
> those corresponds to a CXXConstructExpr.)

See the AST in https://reviews.llvm.org/D151587#4396705; without a visitor for 
that, we don't recurse far enough down to see there is a 
MaterializeTemporaryExpr child in the sub-AST.  Maybe that's because of my 
subclassing of `ConstStmtVisitor` returning `bool`, so if I don't implement a 
visitor, the default visit returns `false` (if I understand 
CRTP/Visitor-pattern correctly).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151587

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


[PATCH] D151587: [clang][ConstantEmitter] have tryEmitPrivateForVarInit try ConstExprEmitter fast-path first

2023-06-05 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers updated this revision to Diff 528605.
nickdesaulniers added a comment.

- use @efriedma's suggestion w/ dyn_cast


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151587

Files:
  clang/lib/CodeGen/CGExprConstant.cpp
  clang/test/CodeGenCXX/const-init-cxx11.cpp
  clang/test/CodeGenCXX/const-init-cxx1y.cpp
  clang/test/CodeGenOpenCL/amdgpu-nullptr.cl

Index: clang/test/CodeGenOpenCL/amdgpu-nullptr.cl
===
--- clang/test/CodeGenOpenCL/amdgpu-nullptr.cl
+++ clang/test/CodeGenOpenCL/amdgpu-nullptr.cl
@@ -57,7 +57,7 @@
 // CHECK: @fold_generic ={{.*}} local_unnamed_addr addrspace(1) global ptr null, align 8
 generic int *fold_generic = (global int*)(generic float*)(private char*)0;
 
-// CHECK: @fold_priv ={{.*}} local_unnamed_addr addrspace(1) global ptr addrspace(5) addrspacecast (ptr null to ptr addrspace(5)), align 4
+// CHECK: @fold_priv ={{.*}} local_unnamed_addr addrspace(1) global ptr addrspace(5) addrspacecast (ptr addrspace(1) null to ptr addrspace(5)), align 4
 private short *fold_priv = (private short*)(generic int*)(global void*)0;
 
 // CHECK: @fold_priv_arith ={{.*}} local_unnamed_addr addrspace(1) global ptr addrspace(5) inttoptr (i32 9 to ptr addrspace(5)), align 4
Index: clang/test/CodeGenCXX/const-init-cxx1y.cpp
===
--- clang/test/CodeGenCXX/const-init-cxx1y.cpp
+++ clang/test/CodeGenCXX/const-init-cxx1y.cpp
@@ -34,8 +34,8 @@
   // 'c.temporary', not the value as modified by the partial evaluation within
   // the initialization of 'c.x'.
   A c = { 10, (++c.temporary, b.x) };
-  // CHECK: @_ZGRN21ModifyStaticTemporary1cE_ = internal global i32 10
   // CHECK: @_ZN21ModifyStaticTemporary1cE ={{.*}} global {{.*}} zeroinitializer
+  // CHECK: @_ZGRN21ModifyStaticTemporary1cE_ = internal global i32 10
 }
 
 // CHECK: @_ZGRN28VariableTemplateWithConstRef1iIvEE_ = linkonce_odr constant i32 5, align 4
Index: clang/test/CodeGenCXX/const-init-cxx11.cpp
===
--- clang/test/CodeGenCXX/const-init-cxx11.cpp
+++ clang/test/CodeGenCXX/const-init-cxx11.cpp
@@ -88,7 +88,7 @@
 
   struct E {};
   struct Test2 : X, X, X, X {};
-  // CHECK: @_ZN9BaseClass2t2E ={{.*}} constant {{.*}} undef
+  // CHECK: @_ZN9BaseClass2t2E ={{.*}} constant {{.*}} zeroinitializer, align 1
   extern constexpr Test2 t2 = Test2();
 
   struct __attribute((packed)) PackedD { double y = 2; };
Index: clang/lib/CodeGen/CGExprConstant.cpp
===
--- clang/lib/CodeGen/CGExprConstant.cpp
+++ clang/lib/CodeGen/CGExprConstant.cpp
@@ -910,6 +910,27 @@
   .Build(Updater, /*AllowOverwrite*/ true);
 }
 
+class HasAnyMaterializeTemporaryExpr :
+  public ConstStmtVisitor {
+public:
+  bool VisitImplicitCastExpr(const ImplicitCastExpr *I) {
+return Visit(I->getSubExpr());
+  }
+  bool VisitCXXConstructExpr(const CXXConstructExpr *C) {
+return llvm::any_of(C->arguments(), [this](const Expr *A){
+  return Visit(A);
+});
+  }
+  bool VisitInitListExpr(const InitListExpr *I) {
+return llvm::any_of(I->inits(), [this](const Expr *II) {
+  return Visit(II);
+});
+  }
+  bool VisitMaterializeTemporaryExpr(const MaterializeTemporaryExpr *) {
+return true;
+  }
+};
+
 //===--===//
 // ConstExprEmitter
 //===--===//
@@ -1215,11 +1236,6 @@
 return Visit(E->getSubExpr(), T);
   }
 
-  llvm::Constant *VisitMaterializeTemporaryExpr(MaterializeTemporaryExpr *E,
-QualType T) {
-return Visit(E->getSubExpr(), T);
-  }
-
   llvm::Constant *EmitArrayInitialization(InitListExpr *ILE, QualType T) {
 auto *CAT = CGM.getContext().getAsConstantArrayType(ILE->getType());
 assert(CAT && "can't emit array init for non-constant-bound array");
@@ -1279,6 +1295,12 @@
 if (ILE->isTransparent())
   return Visit(ILE->getInit(0), T);
 
+// If the InitListExpr contains a MaterializeTemporaryExpr recursively,
+// bail...
+HasAnyMaterializeTemporaryExpr H;
+if (H.Visit(ILE))
+  return nullptr;
+
 if (ILE->getType()->isArrayType())
   return EmitArrayInitialization(ILE, T);
 
@@ -1322,7 +1344,12 @@
   assert(CGM.getContext().hasSameUnqualifiedType(Ty, Arg->getType()) &&
  "argument to copy ctor is of wrong type");
 
-  return Visit(Arg, Ty);
+  // Look through the temporary; it's just converting the value to an
+  // lvalue to pass it to the constructor.
+  if (auto *MTE = dyn_cast(Arg))
+return Visit(MTE->getSubExpr(), Ty);
+  // Don't try to support arbitrary lvalue-to-rvalue conversions for now.
+  

[PATCH] D131594: Add Clang UEFI target to support "x86_64-unknown-uefi" triple

2023-06-05 Thread Prabhu Karthikeyan Rajasekaran via Phabricator via cfe-commits
Prabhuk updated this revision to Diff 528603.
Prabhuk added a comment.

Update the test. Remove unnecessary items in UEFI toolchain.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131594

Files:
  clang/lib/Basic/Targets.cpp
  clang/lib/Basic/Targets/OSTargets.h
  clang/lib/Basic/Targets/X86.h
  clang/lib/Driver/CMakeLists.txt
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChains/UEFI.cpp
  clang/lib/Driver/ToolChains/UEFI.h
  llvm/include/llvm/MC/TargetRegistry.h
  llvm/include/llvm/TargetParser/Triple.h
  llvm/lib/MC/MCContext.cpp
  llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp
  llvm/lib/Target/X86/MCTargetDesc/X86MCAsmInfo.cpp
  llvm/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.cpp
  llvm/lib/Target/X86/X86MCInstLower.cpp
  llvm/lib/TargetParser/Triple.cpp
  llvm/unittests/TargetParser/TripleTest.cpp

Index: llvm/unittests/TargetParser/TripleTest.cpp
===
--- llvm/unittests/TargetParser/TripleTest.cpp
+++ llvm/unittests/TargetParser/TripleTest.cpp
@@ -349,6 +349,12 @@
   EXPECT_EQ(Triple::HermitCore, T.getOS());
   EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
 
+  T = Triple("x86_64-unknown-uefi");
+  EXPECT_EQ(Triple::x86_64, T.getArch());
+  EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
+  EXPECT_EQ(Triple::UEFI, T.getOS());
+  EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
+
   T = Triple("wasm32-unknown-unknown");
   EXPECT_EQ(Triple::wasm32, T.getArch());
   EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
Index: llvm/lib/TargetParser/Triple.cpp
===
--- llvm/lib/TargetParser/Triple.cpp
+++ llvm/lib/TargetParser/Triple.cpp
@@ -238,6 +238,7 @@
   case RTEMS: return "rtems";
   case Solaris: return "solaris";
   case TvOS: return "tvos";
+  case UEFI: return "uefi";
   case WASI: return "wasi";
   case WatchOS: return "watchos";
   case Win32: return "windows";
@@ -588,6 +589,7 @@
 .StartsWith("netbsd", Triple::NetBSD)
 .StartsWith("openbsd", Triple::OpenBSD)
 .StartsWith("solaris", Triple::Solaris)
+.StartsWith("uefi", Triple::UEFI)
 .StartsWith("win32", Triple::Win32)
 .StartsWith("windows", Triple::Win32)
 .StartsWith("zos", Triple::ZOS)
Index: llvm/lib/Target/X86/X86MCInstLower.cpp
===
--- llvm/lib/Target/X86/X86MCInstLower.cpp
+++ llvm/lib/Target/X86/X86MCInstLower.cpp
@@ -1555,7 +1555,8 @@
 
 void X86AsmPrinter::EmitSEHInstruction(const MachineInstr *MI) {
   assert(MF->hasWinCFI() && "SEH_ instruction in function without WinCFI?");
-  assert(getSubtarget().isOSWindows() && "SEH_ instruction Windows only");
+  assert((getSubtarget().isOSWindows() || TM.getTargetTriple().isUEFI()) &&
+ "SEH_ instruction Windows and UEFI only");
 
   // Use the .cv_fpo directives if we're emitting CodeView on 32-bit x86.
   if (EmitFPOData) {
Index: llvm/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.cpp
===
--- llvm/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.cpp
+++ llvm/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.cpp
@@ -441,6 +441,8 @@
   } else if (TheTriple.isOSCygMing() ||
  TheTriple.isWindowsItaniumEnvironment()) {
 MAI = new X86MCAsmInfoGNUCOFF(TheTriple);
+  } else if (TheTriple.isUEFI()) {
+MAI = new X86MCAsmInfoGNUCOFF(TheTriple);
   } else {
 // The default is ELF.
 MAI = new X86ELFMCAsmInfo(TheTriple);
Index: llvm/lib/Target/X86/MCTargetDesc/X86MCAsmInfo.cpp
===
--- llvm/lib/Target/X86/MCTargetDesc/X86MCAsmInfo.cpp
+++ llvm/lib/Target/X86/MCTargetDesc/X86MCAsmInfo.cpp
@@ -153,7 +153,8 @@
 void X86MCAsmInfoGNUCOFF::anchor() { }
 
 X86MCAsmInfoGNUCOFF::X86MCAsmInfoGNUCOFF(const Triple ) {
-  assert(Triple.isOSWindows() && "Windows is the only supported COFF target");
+  assert((Triple.isOSWindows() || Triple.isUEFI()) &&
+ "Windows and UEFI are the only supported COFF targets");
   if (Triple.getArch() == Triple::x86_64) {
 PrivateGlobalPrefix = ".L";
 PrivateLabelPrefix = ".L";
Index: llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp
===
--- llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp
+++ llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp
@@ -1516,6 +1516,12 @@
   if (TheTriple.isOSWindows() && TheTriple.isOSBinFormatCOFF())
 return new WindowsX86AsmBackend(T, true, STI);
 
+  if (TheTriple.isUEFI()) {
+assert(TheTriple.isOSBinFormatCOFF() &&
+ "Only COFF format is supported in UEFI environment.");
+return new WindowsX86AsmBackend(T, true, STI);
+  }
+
   uint8_t OSABI = MCELFObjectTargetWriter::getOSABI(TheTriple.getOS());
 
   if (TheTriple.isX32())
Index: llvm/lib/MC/MCContext.cpp

[PATCH] D149104: reland: [Demangle] make llvm::demangle take std::string_view rather than const std::string

2023-06-05 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers updated this revision to Diff 528599.
nickdesaulniers retitled this revision from "[Demangle] make llvm::demangle 
take std::string_view rather than const std::string&" to "reland: [Demangle] 
make llvm::demangle take std::string_view rather than const std::string&".
nickdesaulniers edited the summary of this revision.
nickdesaulniers added a comment.
This revision is now accepted and ready to land.

- rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149104

Files:
  clang/lib/CodeGen/CodeGenAction.cpp
  lld/COFF/Symbols.cpp
  lld/ELF/SymbolTable.cpp
  lld/ELF/Symbols.cpp
  lld/MachO/Symbols.cpp
  lld/wasm/Symbols.cpp
  llvm/docs/ReleaseNotes.rst
  llvm/include/llvm/Demangle/Demangle.h
  llvm/lib/DebugInfo/LogicalView/Readers/LVCodeViewVisitor.cpp
  llvm/lib/Demangle/Demangle.cpp
  llvm/lib/IR/DiagnosticInfo.cpp
  llvm/tools/llvm-objdump/ELFDump.cpp
  llvm/tools/llvm-objdump/XCOFFDump.cpp
  llvm/tools/llvm-objdump/llvm-objdump.cpp
  llvm/tools/llvm-readobj/ELFDumper.cpp
  llvm/tools/llvm-tli-checker/llvm-tli-checker.cpp

Index: llvm/tools/llvm-tli-checker/llvm-tli-checker.cpp
===
--- llvm/tools/llvm-tli-checker/llvm-tli-checker.cpp
+++ llvm/tools/llvm-tli-checker/llvm-tli-checker.cpp
@@ -107,7 +107,7 @@
   std::string OutputName = "'";
   OutputName += Name;
   OutputName += "'";
-  std::string DemangledName(demangle(Name.str()));
+  std::string DemangledName(demangle(Name));
   if (Name != DemangledName) {
 OutputName += " aka ";
 OutputName += DemangledName;
Index: llvm/tools/llvm-readobj/ELFDumper.cpp
===
--- llvm/tools/llvm-readobj/ELFDumper.cpp
+++ llvm/tools/llvm-readobj/ELFDumper.cpp
@@ -908,7 +908,7 @@
 }
 
 static std::string maybeDemangle(StringRef Name) {
-  return opts::Demangle ? demangle(std::string(Name)) : Name.str();
+  return opts::Demangle ? demangle(Name) : Name.str();
 }
 
 template 
Index: llvm/tools/llvm-objdump/llvm-objdump.cpp
===
--- llvm/tools/llvm-objdump/llvm-objdump.cpp
+++ llvm/tools/llvm-objdump/llvm-objdump.cpp
@@ -1545,7 +1545,7 @@
   if (Demangle) {
 // Fetch the demangled names and store them locally.
 for (const SymbolInfoTy  : SymbolsHere)
-  DemangledSymNamesHere.push_back(demangle(Symbol.Name.str()));
+  DemangledSymNamesHere.push_back(demangle(Symbol.Name));
 // Now we've finished modifying that vector, it's safe to make
 // a vector of StringRefs pointing into it.
 SymNamesHere.insert(SymNamesHere.begin(), DemangledSymNamesHere.begin(),
@@ -1906,9 +1906,8 @@
   if (TargetSym != nullptr) {
 uint64_t TargetAddress = TargetSym->Addr;
 uint64_t Disp = Target - TargetAddress;
-std::string TargetName = TargetSym->Name.str();
-if (Demangle)
-  TargetName = demangle(TargetName);
+std::string TargetName = Demangle ? demangle(TargetSym->Name)
+  : TargetSym->Name.str();
 
 *TargetOS << " <";
 if (!Disp) {
@@ -2508,10 +2507,8 @@
 
 if (NameOrErr) {
   outs() << " (csect:";
-  std::string SymName(NameOrErr.get());
-
-  if (Demangle)
-SymName = demangle(SymName);
+  std::string SymName =
+  Demangle ? demangle(*NameOrErr) : NameOrErr->str();
 
   if (SymbolDescription)
 SymName = getXCOFFSymbolDescription(createSymbolInfo(O, *SymRef),
@@ -2565,10 +2562,7 @@
 outs() << " .hidden";
   }
 
-  std::string SymName(Name);
-  if (Demangle)
-SymName = demangle(SymName);
-
+  std::string SymName = Demangle ? demangle(Name) : Name.str();
   if (O.isXCOFF() && SymbolDescription)
 SymName = getXCOFFSymbolDescription(createSymbolInfo(O, Symbol), SymName);
 
Index: llvm/tools/llvm-objdump/XCOFFDump.cpp
===
--- llvm/tools/llvm-objdump/XCOFFDump.cpp
+++ llvm/tools/llvm-objdump/XCOFFDump.cpp
@@ -32,10 +32,8 @@
   if (!SymNameOrErr)
 return SymNameOrErr.takeError();
 
-  std::string SymName = (*SymNameOrErr).str();
-  if (Demangle)
-SymName = demangle(SymName);
-
+  std::string SymName =
+  Demangle ? demangle(*SymNameOrErr) : SymNameOrErr->str();
   if (SymbolDescription)
 SymName = getXCOFFSymbolDescription(createSymbolInfo(Obj, *SymI), SymName);
 
Index: llvm/tools/llvm-objdump/ELFDump.cpp
===
--- llvm/tools/llvm-objdump/ELFDump.cpp
+++ llvm/tools/llvm-objdump/ELFDump.cpp
@@ -108,10 +108,7 @@
   Expected SymName = SI->getName();
   if (!SymName)
 return SymName.takeError();
-  if (Demangle)

[PATCH] D119711: Add asan support for MSVC debug runtimes

2023-06-05 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added subscribers: thieta, mstorsjo.
rnk added a comment.

+ @mstorsjo @thieta

Since we were talking about the complexity involved in choosing the correct 
ASan runtime, there is actually even more involved.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119711

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


[PATCH] D144911: adding bf16 support to NVPTX

2023-06-05 Thread Artem Belevich via Phabricator via cfe-commits
tra added inline comments.



Comment at: llvm/lib/Target/NVPTX/NVPTXISelLowering.cpp:615
 setFP16OperationAction(Op, MVT::v2f16, Legal, Expand);
-  }
-
-  for (const auto  : {ISD::FADD, ISD::FMUL, ISD::FSUB, ISD::FMA}) {
 setBF16OperationAction(Op, MVT::bf16, Legal, Promote);
 setBF16OperationAction(Op, MVT::v2bf16, Legal, Expand);

There's still something odd with this patch. The `setBF16OperationAction` is 
not in the upstream, but it does not show up in the diff on phabricator. 

Please do rebase on top of the LLVM and make sure that all your changes are on 
the git branch you use to send the patch to phabricator. If in doubt how to get 
`arc` to do it correctly, you can always create and upload the diff manually as 
described here: 
https://llvm.org/docs/Phabricator.html#requesting-a-review-via-the-web-interface



Comment at: llvm/lib/Target/NVPTX/NVPTXISelLowering.cpp:689
 setFP16OperationAction(Op, MVT::f16, GetMinMaxAction(Expand), Expand);
+setFP16OperationAction(Op, MVT::bf16, GetMinMaxAction(Expand), Expand);
 setOperationAction(Op, MVT::f32, GetMinMaxAction(Expand));

Should it be `set*BF*16OperationAction` ?



Comment at: llvm/lib/Target/NVPTX/NVPTXISelLowering.cpp:692
 setFP16OperationAction(Op, MVT::v2f16, GetMinMaxAction(Expand), Expand);
-  }
-  for (const auto  : {ISD::FMINNUM, ISD::FMAXNUM}) {
-setBF16OperationAction(Op, MVT::bf16, GetMinMaxAction(Promote), Promote);
-setBF16OperationAction(Op, MVT::v2bf16, GetMinMaxAction(Expand), Expand);
-setBF16OperationAction(Op, MVT::bf16, GetMinMaxAction(Expand), Expand);
-setBF16OperationAction(Op, MVT::v2bf16, GetMinMaxAction(Expand), Expand);
+setFP16OperationAction(Op, MVT::v2bf16, GetMinMaxAction(Expand), Expand);
   }

ditto.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144911

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


[PATCH] D144911: adding bf16 support to NVPTX

2023-06-05 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

FYI https://reviews.llvm.org/D151601 has landed in 
https://github.com/llvm/llvm-project/commit/dc90f42ea7b4f6d9e643f5ad2ba663eba2f9e421.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144911

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


[PATCH] D152017: [DebugInfo] Add flag to only emit referenced member functions

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

oh, side note: We don't emit DWARF descriptions of called non-member functions, 
generally (well, more often these days with optimized debug info call_site info 
we do need to emit function declarations for called functions) - so by analogy 
I'd have thought doing similarly for member functions would be suitable


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152017

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


[PATCH] D131594: Add Clang UEFI target to support "x86_64-unknown-uefi" triple

2023-06-05 Thread Petr Hosek via Phabricator via cfe-commits
phosek added a comment.

I'd omit the lit test cases for now since they're not necessary. There should 
be a test case in 
https://github.com/llvm/llvm-project/blob/86b6ac5d54d7fe5cd21beff64b5c2194b1368bdf/llvm/unittests/TargetParser/TripleTest.cpp
 though.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131594

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


[PATCH] D151587: [clang][ConstantEmitter] have tryEmitPrivateForVarInit try ConstExprEmitter fast-path first

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

Two points I'm not sure about in the current version:

- Handling MaterializeTemporaryExpr in ConstExprEmitter doesn't make sense; 
ConstExprEmitter is not supposed to visit lvalues. (And I'm not sure what the 
new check is supposed to do; `E->isGLValue()` is always true for a 
MaterializeTemporaryExpr.)  Maybe try something like the following?

  diff --git a/clang/lib/CodeGen/CGExprConstant.cpp 
b/clang/lib/CodeGen/CGExprConstant.cpp
  index b0dd598..51cf69e 100644
  --- a/clang/lib/CodeGen/CGExprConstant.cpp
  +++ b/clang/lib/CodeGen/CGExprConstant.cpp
  @@ -1215,11 +1215,6 @@ public:
   return Visit(E->getSubExpr(), T);
 }
  
  -  llvm::Constant *VisitMaterializeTemporaryExpr(MaterializeTemporaryExpr *E,
  -QualType T) {
  -return Visit(E->getSubExpr(), T);
  -  }
  -
 llvm::Constant *EmitArrayInitialization(InitListExpr *ILE, QualType T) {
   auto *CAT = CGM.getContext().getAsConstantArrayType(ILE->getType());
   assert(CAT && "can't emit array init for non-constant-bound array");
  @@ -1322,7 +1317,14 @@ public:
 assert(CGM.getContext().hasSameUnqualifiedType(Ty, Arg->getType()) &&
"argument to copy ctor is of wrong type");
  
  -  return Visit(Arg, Ty);
  +  if (auto *MTE = dyn_cast(Arg)) {
  +// Look through the temporary; it's just converting the value to an
  +// lvalue to pass it to the constructor.
  +return Visit(MTE->getSubExpr(), Ty);
  +  }
  +
  +  // Don't try to support arbitrary lvalue-to-rvalue conversions for now.
  +  return nullptr;
   }
  
   return CGM.EmitNullConstant(Ty);



- HasAnyMaterializeTemporaryExpr shouldn't need to handle 
VisitCXXConstructExpr.  The EvaluateAsLValue bug only applies to 
lifetime-extended temporaries.  Any MaterializeTemporaryExpr that's the operand 
of a VisitCXXConstructExpr should not be lifetime-extended beyond the end of 
the expression. So it won't run into the EvaluateAsLValue issue.  
(https://en.cppreference.com/w/cpp/language/reference_initialization#Lifetime_of_a_temporary
 should be a complete list of cases where we might need to recurse; none of 
those corresponds to a CXXConstructExpr.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151587

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


[PATCH] D143592: [flang][driver] Rename `flang-new -flang-experimental-exec` to `flang`

2023-06-05 Thread Brad Richardson via Phabricator via cfe-commits
everythingfunctional updated this revision to Diff 528586.
everythingfunctional added a comment.

Merge in updates from latest main branch and resolve conflicts


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143592

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/lib/Driver/ToolChains/Flang.cpp
  clang/test/Driver/flang/flang.f90
  clang/test/Driver/flang/flang_ucase.F90
  clang/test/Driver/flang/multiple-inputs-mixed.f90
  clang/test/Driver/flang/multiple-inputs.f90
  flang/docs/FlangDriver.md
  flang/docs/ImplementingASemanticCheck.md
  flang/docs/Overview.md
  flang/examples/FlangOmpReport/FlangOmpReport.cpp
  flang/lib/Frontend/CompilerInvocation.cpp
  flang/lib/Frontend/FrontendActions.cpp
  flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
  flang/test/CMakeLists.txt
  flang/test/Driver/color-diagnostics-forwarding.f90
  flang/test/Driver/compiler_options.f90
  flang/test/Driver/convert.f90
  flang/test/Driver/disable-ext-name-interop.f90
  flang/test/Driver/driver-help-hidden.f90
  flang/test/Driver/driver-version.f90
  flang/test/Driver/escaped-backslash.f90
  flang/test/Driver/fdefault.f90
  flang/test/Driver/flarge-sizes.f90
  flang/test/Driver/frontend-forwarding.f90
  flang/test/Driver/intrinsic-module-path.f90
  flang/test/Driver/linker-flags.f90
  flang/test/Driver/lto-flags.f90
  flang/test/Driver/macro-def-undef.F90
  flang/test/Driver/missing-input.f90
  flang/test/Driver/multiple-input-files.f90
  flang/test/Driver/omp-driver-offload.f90
  flang/test/Driver/predefined-macros-compiler-version.F90
  flang/test/Driver/std2018-wrong.f90
  flang/test/Driver/std2018.f90
  flang/test/Driver/supported-suffices/f03-suffix.f03
  flang/test/Driver/supported-suffices/f08-suffix.f08
  flang/test/Driver/use-module-error.f90
  flang/test/Driver/use-module.f90
  flang/test/Driver/version-loops.f90
  flang/test/Lower/Intrinsics/command_argument_count.f90
  flang/test/Lower/Intrinsics/exit.f90
  flang/test/Lower/Intrinsics/get_command_argument.f90
  flang/test/Lower/Intrinsics/get_environment_variable.f90
  flang/test/Lower/Intrinsics/ieee_is_normal.f90
  flang/test/Lower/Intrinsics/isnan.f90
  flang/test/Lower/Intrinsics/move_alloc.f90
  flang/test/Lower/OpenACC/Todo/acc-declare.f90
  flang/test/Lower/OpenACC/Todo/acc-routine.f90
  flang/test/Lower/OpenMP/Todo/omp-declarative-allocate.f90
  flang/test/Lower/OpenMP/Todo/omp-declare-reduction.f90
  flang/test/Lower/OpenMP/Todo/omp-declare-simd.f90
  flang/test/Lower/OpenMP/parallel-lastprivate-clause-scalar.f90
  flang/test/Lower/dummy-argument-optional.f90
  flang/test/lit.cfg.py
  flang/tools/f18/CMakeLists.txt
  flang/tools/f18/flang-to-external-fc.in
  flang/tools/flang-driver/CMakeLists.txt
  flang/tools/flang-driver/driver.cpp

Index: flang/tools/flang-driver/driver.cpp
===
--- flang/tools/flang-driver/driver.cpp
+++ flang/tools/flang-driver/driver.cpp
@@ -90,14 +90,15 @@
   llvm::InitLLVM x(argc, argv);
   llvm::SmallVector args(argv, argv + argc);
 
-  clang::driver::ParsedClangName targetandMode("flang", "--driver-mode=flang");
+  clang::driver::ParsedClangName targetandMode =
+  clang::driver::ToolChain::getTargetAndModeFromProgramName(argv[0]);
   std::string driverPath = getExecutablePath(args[0]);
 
   llvm::BumpPtrAllocator a;
   llvm::StringSaver saver(a);
   ExpandResponseFiles(saver, args);
 
-  // Check if flang-new is in the frontend mode
+  // Check if flang is in the frontend mode
   auto firstArg = std::find_if(args.begin() + 1, args.end(),
[](const char *a) { return a != nullptr; });
   if (firstArg != args.end()) {
@@ -106,7 +107,7 @@
<< "Valid tools include '-fc1'.\n";
   return 1;
 }
-// Call flang-new frontend
+// Call flang frontend
 if (llvm::StringRef(args[1]).startswith("-fc1")) {
   return executeFC1Tool(args);
 }
Index: flang/tools/flang-driver/CMakeLists.txt
===
--- flang/tools/flang-driver/CMakeLists.txt
+++ flang/tools/flang-driver/CMakeLists.txt
@@ -11,7 +11,7 @@
   TargetParser
 )
 
-add_flang_tool(flang-new
+add_flang_tool(flang
   driver.cpp
   fc1_main.cpp
 
@@ -24,13 +24,13 @@
   Fortran_main
 )
 
-target_link_libraries(flang-new
+target_link_libraries(flang
   PRIVATE
   flangFrontend
   flangFrontendTool
 )
 
-clang_target_link_libraries(flang-new
+clang_target_link_libraries(flang
   PRIVATE
   clangDriver
   clangBasic
@@ -38,9 +38,9 @@
 
 option(FLANG_PLUGIN_SUPPORT "Build Flang with plugin support." ON)
 
-# Enable support for plugins, which need access to symbols from flang-new
+# Enable support for plugins, which need access to symbols from flang
 if(FLANG_PLUGIN_SUPPORT)
-  export_executable_symbols_for_plugins(flang-new)
+  

[PATCH] D143592: [flang][driver] Rename `flang-new -flang-experimental-exec` to `flang`

2023-06-05 Thread Brad Richardson via Phabricator via cfe-commits
everythingfunctional updated this revision to Diff 528585.
everythingfunctional added a comment.

Update to latest main branch


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143592

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/lib/Driver/ToolChains/Flang.cpp
  clang/test/Driver/flang/flang.f90
  clang/test/Driver/flang/flang_ucase.F90
  clang/test/Driver/flang/multiple-inputs-mixed.f90
  clang/test/Driver/flang/multiple-inputs.f90
  flang/docs/FlangDriver.md
  flang/docs/ImplementingASemanticCheck.md
  flang/docs/Overview.md
  flang/examples/FlangOmpReport/FlangOmpReport.cpp
  flang/lib/Frontend/CompilerInvocation.cpp
  flang/lib/Frontend/FrontendActions.cpp
  flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
  flang/test/CMakeLists.txt
  flang/test/Driver/color-diagnostics-forwarding.f90
  flang/test/Driver/compiler_options.f90
  flang/test/Driver/convert.f90
  flang/test/Driver/disable-ext-name-interop.f90
  flang/test/Driver/driver-help-hidden.f90
  flang/test/Driver/driver-version.f90
  flang/test/Driver/escaped-backslash.f90
  flang/test/Driver/fdefault.f90
  flang/test/Driver/flarge-sizes.f90
  flang/test/Driver/frontend-forwarding.f90
  flang/test/Driver/intrinsic-module-path.f90
  flang/test/Driver/linker-flags.f90
  flang/test/Driver/lto-flags.f90
  flang/test/Driver/macro-def-undef.F90
  flang/test/Driver/missing-input.f90
  flang/test/Driver/multiple-input-files.f90
  flang/test/Driver/omp-driver-offload.f90
  flang/test/Driver/predefined-macros-compiler-version.F90
  flang/test/Driver/std2018-wrong.f90
  flang/test/Driver/std2018.f90
  flang/test/Driver/supported-suffices/f03-suffix.f03
  flang/test/Driver/supported-suffices/f08-suffix.f08
  flang/test/Driver/use-module-error.f90
  flang/test/Driver/use-module.f90
  flang/test/Driver/version-loops.f90
  flang/test/Lower/Intrinsics/command_argument_count.f90
  flang/test/Lower/Intrinsics/exit.f90
  flang/test/Lower/Intrinsics/get_command_argument.f90
  flang/test/Lower/Intrinsics/get_environment_variable.f90
  flang/test/Lower/Intrinsics/ieee_is_normal.f90
  flang/test/Lower/Intrinsics/isnan.f90
  flang/test/Lower/Intrinsics/move_alloc.f90
  flang/test/Lower/OpenACC/Todo/acc-declare.f90
  flang/test/Lower/OpenACC/Todo/acc-routine.f90
  flang/test/Lower/OpenMP/Todo/omp-declarative-allocate.f90
  flang/test/Lower/OpenMP/Todo/omp-declare-reduction.f90
  flang/test/Lower/OpenMP/Todo/omp-declare-simd.f90
  flang/test/Lower/OpenMP/parallel-lastprivate-clause-scalar.f90
  flang/test/Lower/dummy-argument-optional.f90
  flang/test/lit.cfg.py
  flang/tools/f18/CMakeLists.txt
  flang/tools/f18/flang-to-external-fc.in
  flang/tools/flang-driver/CMakeLists.txt
  flang/tools/flang-driver/driver.cpp

Index: flang/tools/flang-driver/driver.cpp
===
--- flang/tools/flang-driver/driver.cpp
+++ flang/tools/flang-driver/driver.cpp
@@ -90,14 +90,15 @@
   llvm::InitLLVM x(argc, argv);
   llvm::SmallVector args(argv, argv + argc);
 
-  clang::driver::ParsedClangName targetandMode("flang", "--driver-mode=flang");
+  clang::driver::ParsedClangName targetandMode =
+  clang::driver::ToolChain::getTargetAndModeFromProgramName(argv[0]);
   std::string driverPath = getExecutablePath(args[0]);
 
   llvm::BumpPtrAllocator a;
   llvm::StringSaver saver(a);
   ExpandResponseFiles(saver, args);
 
-  // Check if flang-new is in the frontend mode
+  // Check if flang is in the frontend mode
   auto firstArg = std::find_if(args.begin() + 1, args.end(),
[](const char *a) { return a != nullptr; });
   if (firstArg != args.end()) {
@@ -106,7 +107,7 @@
<< "Valid tools include '-fc1'.\n";
   return 1;
 }
-// Call flang-new frontend
+// Call flang frontend
 if (llvm::StringRef(args[1]).startswith("-fc1")) {
   return executeFC1Tool(args);
 }
Index: flang/tools/flang-driver/CMakeLists.txt
===
--- flang/tools/flang-driver/CMakeLists.txt
+++ flang/tools/flang-driver/CMakeLists.txt
@@ -11,7 +11,7 @@
   TargetParser
 )
 
-add_flang_tool(flang-new
+add_flang_tool(flang
   driver.cpp
   fc1_main.cpp
 
@@ -24,13 +24,13 @@
   Fortran_main
 )
 
-target_link_libraries(flang-new
+target_link_libraries(flang
   PRIVATE
   flangFrontend
   flangFrontendTool
 )
 
-clang_target_link_libraries(flang-new
+clang_target_link_libraries(flang
   PRIVATE
   clangDriver
   clangBasic
@@ -38,9 +38,9 @@
 
 option(FLANG_PLUGIN_SUPPORT "Build Flang with plugin support." ON)
 
-# Enable support for plugins, which need access to symbols from flang-new
+# Enable support for plugins, which need access to symbols from flang
 if(FLANG_PLUGIN_SUPPORT)
-  export_executable_symbols_for_plugins(flang-new)
+  

[PATCH] D133244: [clang-tidy] Readability-container-data-pointer adds new option to ignore Containers

2023-06-05 Thread FĂ©lix-Antoine Constantin via Phabricator via cfe-commits
felix642 added a comment.

ping?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133244

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


[PATCH] D151587: [clang][ConstantEmitter] have tryEmitPrivateForVarInit try ConstExprEmitter fast-path first

2023-06-05 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers updated this revision to Diff 528571.
nickdesaulniers added a comment.

- recursively check for MaterializeTemporaryExpr from InitListExprs; all tests 
pass (that doesn't imply this patch is good though!)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151587

Files:
  clang/lib/CodeGen/CGExprConstant.cpp
  clang/test/CodeGenCXX/const-init-cxx11.cpp
  clang/test/CodeGenCXX/const-init-cxx1y.cpp
  clang/test/CodeGenOpenCL/amdgpu-nullptr.cl

Index: clang/test/CodeGenOpenCL/amdgpu-nullptr.cl
===
--- clang/test/CodeGenOpenCL/amdgpu-nullptr.cl
+++ clang/test/CodeGenOpenCL/amdgpu-nullptr.cl
@@ -57,7 +57,7 @@
 // CHECK: @fold_generic ={{.*}} local_unnamed_addr addrspace(1) global ptr null, align 8
 generic int *fold_generic = (global int*)(generic float*)(private char*)0;
 
-// CHECK: @fold_priv ={{.*}} local_unnamed_addr addrspace(1) global ptr addrspace(5) addrspacecast (ptr null to ptr addrspace(5)), align 4
+// CHECK: @fold_priv ={{.*}} local_unnamed_addr addrspace(1) global ptr addrspace(5) addrspacecast (ptr addrspace(1) null to ptr addrspace(5)), align 4
 private short *fold_priv = (private short*)(generic int*)(global void*)0;
 
 // CHECK: @fold_priv_arith ={{.*}} local_unnamed_addr addrspace(1) global ptr addrspace(5) inttoptr (i32 9 to ptr addrspace(5)), align 4
Index: clang/test/CodeGenCXX/const-init-cxx1y.cpp
===
--- clang/test/CodeGenCXX/const-init-cxx1y.cpp
+++ clang/test/CodeGenCXX/const-init-cxx1y.cpp
@@ -34,8 +34,8 @@
   // 'c.temporary', not the value as modified by the partial evaluation within
   // the initialization of 'c.x'.
   A c = { 10, (++c.temporary, b.x) };
-  // CHECK: @_ZGRN21ModifyStaticTemporary1cE_ = internal global i32 10
   // CHECK: @_ZN21ModifyStaticTemporary1cE ={{.*}} global {{.*}} zeroinitializer
+  // CHECK: @_ZGRN21ModifyStaticTemporary1cE_ = internal global i32 10
 }
 
 // CHECK: @_ZGRN28VariableTemplateWithConstRef1iIvEE_ = linkonce_odr constant i32 5, align 4
Index: clang/test/CodeGenCXX/const-init-cxx11.cpp
===
--- clang/test/CodeGenCXX/const-init-cxx11.cpp
+++ clang/test/CodeGenCXX/const-init-cxx11.cpp
@@ -88,7 +88,7 @@
 
   struct E {};
   struct Test2 : X, X, X, X {};
-  // CHECK: @_ZN9BaseClass2t2E ={{.*}} constant {{.*}} undef
+  // CHECK: @_ZN9BaseClass2t2E ={{.*}} constant {{.*}} zeroinitializer, align 1
   extern constexpr Test2 t2 = Test2();
 
   struct __attribute((packed)) PackedD { double y = 2; };
Index: clang/lib/CodeGen/CGExprConstant.cpp
===
--- clang/lib/CodeGen/CGExprConstant.cpp
+++ clang/lib/CodeGen/CGExprConstant.cpp
@@ -910,6 +910,27 @@
   .Build(Updater, /*AllowOverwrite*/ true);
 }
 
+class HasAnyMaterializeTemporaryExpr :
+  public ConstStmtVisitor {
+public:
+  bool VisitImplicitCastExpr(const ImplicitCastExpr *I) {
+return Visit(I->getSubExpr());
+  }
+  bool VisitCXXConstructExpr(const CXXConstructExpr *C) {
+return llvm::any_of(C->arguments(), [this](const Expr *A){
+  return Visit(A);
+});
+  }
+  bool VisitInitListExpr(const InitListExpr *I) {
+return llvm::any_of(I->inits(), [this](const Expr *II) {
+  return Visit(II);
+});
+  }
+  bool VisitMaterializeTemporaryExpr(const MaterializeTemporaryExpr *) {
+return true;
+  }
+};
+
 //===--===//
 // ConstExprEmitter
 //===--===//
@@ -1216,8 +1237,10 @@
   }
 
   llvm::Constant *VisitMaterializeTemporaryExpr(MaterializeTemporaryExpr *E,
-QualType T) {
-return Visit(E->getSubExpr(), T);
+  QualType T) {
+if (E->isGLValue())
+  return Visit(E->getSubExpr(), T);
+return nullptr;
   }
 
   llvm::Constant *EmitArrayInitialization(InitListExpr *ILE, QualType T) {
@@ -1279,6 +1302,12 @@
 if (ILE->isTransparent())
   return Visit(ILE->getInit(0), T);
 
+// If the InitListExpr contains a MaterializeTemporaryExpr recursively,
+// bail...
+HasAnyMaterializeTemporaryExpr H;
+if (H.Visit(ILE))
+  return nullptr;
+
 if (ILE->getType()->isArrayType())
   return EmitArrayInitialization(ILE, T);
 
@@ -1655,27 +1684,27 @@
 
   QualType destType = D.getType();
 
-  // Try to emit the initializer.  Note that this can allow some things that
-  // are not allowed by tryEmitPrivateForMemory alone.
-  if (APValue *value = D.evaluateValue())
-return tryEmitPrivateForMemory(*value, destType);
-
   // FIXME: Implement C++11 [basic.start.init]p2: if the initializer of a
   // reference is a constant expression, and the 

[PATCH] D151923: [APFloat] Add APFloat semantic support for TF32

2023-06-05 Thread Jeremy Furtek via Phabricator via cfe-commits
jfurtek updated this revision to Diff 528567.
jfurtek added a comment.

- Another clang-format fix


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151923

Files:
  clang/lib/AST/MicrosoftMangle.cpp
  llvm/include/llvm/ADT/APFloat.h
  llvm/lib/Support/APFloat.cpp
  llvm/unittests/ADT/APFloatTest.cpp

Index: llvm/unittests/ADT/APFloatTest.cpp
===
--- llvm/unittests/ADT/APFloatTest.cpp
+++ llvm/unittests/ADT/APFloatTest.cpp
@@ -682,6 +682,27 @@
 EXPECT_TRUE(T.isDenormal());
 EXPECT_EQ(fcPosSubnormal, T.classify());
   }
+
+  // Test TF32
+  {
+const char *MinNormalStr = "1.17549435082228750797e-38";
+EXPECT_FALSE(APFloat(APFloat::FloatTF32(), MinNormalStr).isDenormal());
+EXPECT_FALSE(APFloat(APFloat::FloatTF32(), 0).isDenormal());
+
+APFloat Val2(APFloat::FloatTF32(), 2);
+APFloat T(APFloat::FloatTF32(), MinNormalStr);
+T.divide(Val2, rdmd);
+EXPECT_TRUE(T.isDenormal());
+EXPECT_EQ(fcPosSubnormal, T.classify());
+
+
+const char *NegMinNormalStr = "-1.17549435082228750797e-38";
+EXPECT_FALSE(APFloat(APFloat::FloatTF32(), NegMinNormalStr).isDenormal());
+APFloat NegT(APFloat::FloatTF32(), NegMinNormalStr);
+NegT.divide(Val2, rdmd);
+EXPECT_TRUE(NegT.isDenormal());
+EXPECT_EQ(fcNegSubnormal, NegT.classify());
+  }
 }
 
 TEST(APFloatTest, IsSmallestNormalized) {
@@ -1350,6 +1371,16 @@
 {   0x80ULL, APFloat::Float8E4M3B11FNUZ(), false, true, 0xaaULL },
 {   0x80ULL, APFloat::Float8E4M3B11FNUZ(), true, false, 0xaaULL },
 {   0x80ULL, APFloat::Float8E4M3B11FNUZ(), true, true,  0xaaULL },
+{0x3fe00ULL, APFloat::FloatTF32(), false, false,  0xULL },
+{0x7fe00ULL, APFloat::FloatTF32(), false,  true,  0xULL },
+{0x3feaaULL, APFloat::FloatTF32(), false, false,0xaaULL },
+{0x3ffaaULL, APFloat::FloatTF32(), false, false,   0xdaaULL },
+{0x3ffaaULL, APFloat::FloatTF32(), false, false,  0xfdaaULL },
+{0x3fd00ULL, APFloat::FloatTF32(),  true, false,  0xULL },
+{0x7fd00ULL, APFloat::FloatTF32(),  true,  true,  0xULL },
+{0x3fcaaULL, APFloat::FloatTF32(),  true, false,0xaaULL },
+{0x3fdaaULL, APFloat::FloatTF32(),  true, false,   0xfaaULL },
+{0x3fdaaULL, APFloat::FloatTF32(),  true, false,   0x1aaULL },
   // clang-format on
   };
 
@@ -1780,6 +1811,8 @@
 APFloat::getLargest(APFloat::Float8E5M2FNUZ()).convertToDouble());
   EXPECT_EQ(
   30, APFloat::getLargest(APFloat::Float8E4M3B11FNUZ()).convertToDouble());
+  EXPECT_EQ(3.40116213421e+38f,
+APFloat::getLargest(APFloat::FloatTF32()).convertToFloat());
 }
 
 TEST(APFloatTest, getSmallest) {
@@ -1831,6 +1864,13 @@
   EXPECT_TRUE(test.isFiniteNonZero());
   EXPECT_TRUE(test.isDenormal());
   EXPECT_TRUE(test.bitwiseIsEqual(expected));
+
+  test = APFloat::getSmallest(APFloat::FloatTF32(), true);
+  expected = APFloat(APFloat::FloatTF32(), "-0x0.004p-126");
+  EXPECT_TRUE(test.isNegative());
+  EXPECT_TRUE(test.isFiniteNonZero());
+  EXPECT_TRUE(test.isDenormal());
+  EXPECT_TRUE(test.bitwiseIsEqual(expected));
 }
 
 TEST(APFloatTest, getSmallestNormalized) {
@@ -1905,6 +1945,14 @@
   EXPECT_FALSE(test.isDenormal());
   EXPECT_TRUE(test.bitwiseIsEqual(expected));
   EXPECT_TRUE(test.isSmallestNormalized());
+
+  test = APFloat::getSmallestNormalized(APFloat::FloatTF32(), false);
+  expected = APFloat(APFloat::FloatTF32(), "0x1p-126");
+  EXPECT_FALSE(test.isNegative());
+  EXPECT_TRUE(test.isFiniteNonZero());
+  EXPECT_FALSE(test.isDenormal());
+  EXPECT_TRUE(test.bitwiseIsEqual(expected));
+  EXPECT_TRUE(test.isSmallestNormalized());
 }
 
 TEST(APFloatTest, getZero) {
@@ -1936,7 +1984,9 @@
   {::Float8E4M3FNUZ(), false, false, {0, 0}, 1},
   {::Float8E4M3FNUZ(), true, false, {0, 0}, 1},
   {::Float8E4M3B11FNUZ(), false, false, {0, 0}, 1},
-  {::Float8E4M3B11FNUZ(), true, false, {0, 0}, 1}};
+  {::Float8E4M3B11FNUZ(), true, false, {0, 0}, 1},
+  {::FloatTF32(), false, true, {0, 0}, 1},
+  {::FloatTF32(), true, true, {0x4ULL, 0}, 1}};
   const unsigned NumGetZeroTests = std::size(GetZeroTest);
   for (unsigned i = 0; i < NumGetZeroTests; ++i) {
 APFloat test = APFloat::getZero(*GetZeroTest[i].semantics,
@@ -6229,6 +6279,35 @@
   EXPECT_TRUE(std::isnan(QNaN.convertToDouble()));
 }
 
+TEST(APFloatTest, FloatTF32ToDouble) {
+  APFloat One(APFloat::FloatTF32(), "1.0");
+  EXPECT_EQ(1.0, One.convertToDouble());
+  APFloat PosLargest = APFloat::getLargest(APFloat::FloatTF32(), false);
+  EXPECT_EQ(3.401162134214653489792616e+38, 

[PATCH] D151587: [clang][ConstantEmitter] have tryEmitPrivateForVarInit try ConstExprEmitter fast-path first

2023-06-05 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added inline comments.



Comment at: clang/lib/CodeGen/CGExprConstant.cpp:1324
 // This is a string literal initializing an array in an initializer.
-return CGM.GetConstantArrayFromStringLiteral(E);
+return E->isLValue() ?
+  CGM.GetAddrOfConstantStringFromLiteral(E).getPointer() :

nickdesaulniers wrote:
> efriedma wrote:
> > nickdesaulniers wrote:
> > > efriedma wrote:
> > > > efriedma wrote:
> > > > > efriedma wrote:
> > > > > > nickdesaulniers wrote:
> > > > > > > efriedma wrote:
> > > > > > > > nickdesaulniers wrote:
> > > > > > > > > nickdesaulniers wrote:
> > > > > > > > > > efriedma wrote:
> > > > > > > > > > > nickdesaulniers wrote:
> > > > > > > > > > > > efriedma wrote:
> > > > > > > > > > > > > Maybe we should have a separate 
> > > > > > > > > > > > > ConstExprEmitterLValue... trying to handle both 
> > > > > > > > > > > > > LValues and RValues on the same codepath has been 
> > > > > > > > > > > > > problematic in the past.  It's very easy for code to 
> > > > > > > > > > > > > get confused what it's actually trying to emit.
> > > > > > > > > > > > So we'd have a `ConstExprEmitterLValue` class with some 
> > > > > > > > > > > > visitor methods, and a `ConstExprEmitterRValue` with 
> > > > > > > > > > > > other methods implemented?
> > > > > > > > > > > Something like that.
> > > > > > > > > > > 
> > > > > > > > > > > Actually thinking about it a bit more, not sure you need 
> > > > > > > > > > > to actually implement ConstExprEmitterLValue for now.  
> > > > > > > > > > > You might just be able to ensure we don't ever call 
> > > > > > > > > > > ConstExprEmitter with an lvalue.  The current 
> > > > > > > > > > > ConstExprEmitter doesn't expect lvalues, and shouldn't 
> > > > > > > > > > > call itself with lvalues.  (We bail on explicit 
> > > > > > > > > > > LValueToRValue conversions.)  And Evaluate() shouldn't 
> > > > > > > > > > > actually evaluate the contents of an lvalue if it isn't 
> > > > > > > > > > > dereferenced, so there hopefully aren't any performance 
> > > > > > > > > > > issues using that codepath.
> > > > > > > > > > > 
> > > > > > > > > > > In terms of implementation, I guess that's basically 
> > > > > > > > > > > restoring the destType->isReferenceType() that got 
> > > > > > > > > > > removed?  (I know I suggested it, but I wasn't really 
> > > > > > > > > > > thinking about it...)
> > > > > > > > > > One thing I think we may need to add to `ConstExprEmitter` 
> > > > > > > > > > is the ability to evaluate `CallExpr`s based on certain 
> > > > > > > > > > test case failures...does that seem right?
> > > > > > > > > See also the calls to `constexpr f()` in 
> > > > > > > > > clang/test/CodeGenCXX/const-init-cxx1y.cpp
> > > > > > > > The only things I know of that Evaluate() can't handle are 
> > > > > > > > CK_ToUnion, CK_ReinterpretMemberPointer, and 
> > > > > > > > DesignatedInitUpdateExpr.  DesignatedInitUpdateExpr is related 
> > > > > > > > to the failures in test/CodeGenCXX/designated-init.cpp; I don't 
> > > > > > > > think the others show up in any of the testcases you've 
> > > > > > > > mentioned.  (CK_ToUnion can't appear in C++ code. 
> > > > > > > > CK_ReinterpretMemberPointer is a `reinterpret_cast` where T 
> > > > > > > > is a member pointer type.)
> > > > > > > > 
> > > > > > > > Given none of those constructs show up in const-init-cxx1y.cpp, 
> > > > > > > > the only reason for it to fail is if we aren't correctly 
> > > > > > > > falling back for a construct the current code doesn't know how 
> > > > > > > > to handle.  You shouldn't need to implement any new constructs.
> > > > > > > in clang/test/CodeGenCXX/designated-init.cpp we have:
> > > > > > > ```
> > > > > > > >> 22 namespace ModifyStaticTemporary {   
> > > > > > > >> 
> > > > > > >23   struct A { int & int x; }; 
> > > > > > > 
> > > > > > >24   constexpr int f(int ) { r *= 9; return r - 12; }
> > > > > > > 
> > > > > > >25   A a = { 6, f(a.temporary) };
> > > > > > > ```
> > > > > > > In the AST, that looks like:
> > > > > > > ```
> > > > > > > | |-VarDecl 0x562b77df39b0  col:5 used a 
> > > > > > > 'A':'ModifyStaticTemporary::A' cinit
> > > > > > > | | `-ExprWithCleanups 0x562b77df3c68  
> > > > > > > 'A':'ModifyStaticTemporary::A'
> > > > > > > | |   `-InitListExpr 0x562b77df3bb8  
> > > > > > > 'A':'ModifyStaticTemporary::A'
> > > > > > > | | |-MaterializeTemporaryExpr 0x562b77df3c08  'int' 
> > > > > > > xvalue extended by Var 0x562b77df39b0 'a' 
> > > > > > > 'A':'ModifyStaticTemporary::A'
> > > > > > > | | | `-IntegerLiteral 0x562b77df3a18  'int' 6
> > > > > > > | | `-CallExpr 0x562b77df3b30  'int'
> > > > > > > | |   |-ImplicitCastExpr 0x562b77df3b18  'int (*)(int 
> > > > > > > &)' 
> > > > > > > | |   | `-DeclRefExpr 0x562b77df3ad0  'int (int &)' 
> > > > > > > lvalue Function 

[PATCH] D152197: [NFC][CLANG] Fix static analyzer bugs with dereference after null check

2023-06-05 Thread Soumi Manna via Phabricator via cfe-commits
Manna created this revision.
Manna added a reviewer: erichkeane.
Herald added subscribers: ctetreau, manas, ASDenysPetrov, dkrupp, donat.nagy, 
Szelethus, a.sidorin, baloghadamsoftware.
Herald added a project: All.
Manna requested review of this revision.
Herald added a project: clang.

This patch uses castAs instead of getAs which will assert if the type doesn't 
match in 
clang::​Sema::​CheckSizelessVectorOperands(clang::​ActionResult &, clang::​ActionResult &, clang::​SourceLocation, 
bool, clang::​Sema::​ArithConvKind).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D152197

Files:
  clang/lib/Sema/SemaExpr.cpp


Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -1,8 +1,8 @@
   QualType LHSType = LHS.get()->getType().getUnqualifiedType();
   QualType RHSType = RHS.get()->getType().getUnqualifiedType();
 
-  const BuiltinType *LHSBuiltinTy = LHSType->getAs();
-  const BuiltinType *RHSBuiltinTy = RHSType->getAs();
+  const BuiltinType *LHSBuiltinTy = LHSType->castAs();
+  const BuiltinType *RHSBuiltinTy = RHSType->castAs();
 
   unsigned DiagID = diag::err_typecheck_invalid_operands;
   if ((OperationKind == ACK_Arithmetic) &&


Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -1,8 +1,8 @@
   QualType LHSType = LHS.get()->getType().getUnqualifiedType();
   QualType RHSType = RHS.get()->getType().getUnqualifiedType();
 
-  const BuiltinType *LHSBuiltinTy = LHSType->getAs();
-  const BuiltinType *RHSBuiltinTy = RHSType->getAs();
+  const BuiltinType *LHSBuiltinTy = LHSType->castAs();
+  const BuiltinType *RHSBuiltinTy = RHSType->castAs();
 
   unsigned DiagID = diag::err_typecheck_invalid_operands;
   if ((OperationKind == ACK_Arithmetic) &&
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D152017: [DebugInfo] Add flag to only emit referenced member functions

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

In D152017#4396906 , @probinson wrote:

> I experimented with this. Looks like it emits info only for //defined// 
> methods, and not //used// methods. That is, if you change the test to say
> `void t1::f1() { f2(); }`
> you get DWARF for f1 but not f2. The way Sony does it, you get DWARF for f1 
> and f2.
> (Neither case sees info for f3, which is declared but not defined or used.)

Ah, that's good to understand - didn't realize that's what you folks were 
doing. Fair enough then.

> Is that what you intended?

It is.

What's the particular goal/value in including called-but-not-defined functions? 
Are your users generally building only parts of their program with debug info & 
you want it to be complete-ish in the parts that do have debug info? Because if 
they were building the whole program with debug info, /some/ translation unit 
would have the definition of the function, and the debug info for it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152017

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


[clang] 5a64a82 - [Driver] Allow -fsanitize=kcfi with -fsanitize-minimal-runtime

2023-06-05 Thread Sami Tolvanen via cfe-commits

Author: Sami Tolvanen
Date: 2023-06-05T20:39:45Z
New Revision: 5a64a826b9f0efab4ba7a8cdab4857794bbf07f3

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

LOG: [Driver] Allow -fsanitize=kcfi with -fsanitize-minimal-runtime

Having both UBSan with the minimal runtime and KCFI enabled can be
useful in low-level software. As there are no conflicts between the
flags, add KCFI to the list of compatible sanitizers.

Added: 


Modified: 
clang/lib/Driver/SanitizerArgs.cpp

Removed: 




diff  --git a/clang/lib/Driver/SanitizerArgs.cpp 
b/clang/lib/Driver/SanitizerArgs.cpp
index 91efe7f5488be..65c0bbeecc3b6 100644
--- a/clang/lib/Driver/SanitizerArgs.cpp
+++ b/clang/lib/Driver/SanitizerArgs.cpp
@@ -77,7 +77,7 @@ static const SanitizerMask CFIClasses =
 static const SanitizerMask CompatibleWithMinimalRuntime =
 TrappingSupported | SanitizerKind::Scudo | SanitizerKind::ShadowCallStack |
 SanitizerKind::MemtagStack | SanitizerKind::MemtagHeap |
-SanitizerKind::MemtagGlobals;
+SanitizerKind::MemtagGlobals | SanitizerKind::KCFI;
 
 enum CoverageFeature {
   CoverageFunc = 1 << 0,



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


[PATCH] D151587: [clang][ConstantEmitter] have tryEmitPrivateForVarInit try ConstExprEmitter fast-path first

2023-06-05 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added inline comments.



Comment at: clang/lib/CodeGen/CGExprConstant.cpp:1324
 // This is a string literal initializing an array in an initializer.
-return CGM.GetConstantArrayFromStringLiteral(E);
+return E->isLValue() ?
+  CGM.GetAddrOfConstantStringFromLiteral(E).getPointer() :

efriedma wrote:
> nickdesaulniers wrote:
> > efriedma wrote:
> > > efriedma wrote:
> > > > efriedma wrote:
> > > > > nickdesaulniers wrote:
> > > > > > efriedma wrote:
> > > > > > > nickdesaulniers wrote:
> > > > > > > > nickdesaulniers wrote:
> > > > > > > > > efriedma wrote:
> > > > > > > > > > nickdesaulniers wrote:
> > > > > > > > > > > efriedma wrote:
> > > > > > > > > > > > Maybe we should have a separate 
> > > > > > > > > > > > ConstExprEmitterLValue... trying to handle both LValues 
> > > > > > > > > > > > and RValues on the same codepath has been problematic 
> > > > > > > > > > > > in the past.  It's very easy for code to get confused 
> > > > > > > > > > > > what it's actually trying to emit.
> > > > > > > > > > > So we'd have a `ConstExprEmitterLValue` class with some 
> > > > > > > > > > > visitor methods, and a `ConstExprEmitterRValue` with 
> > > > > > > > > > > other methods implemented?
> > > > > > > > > > Something like that.
> > > > > > > > > > 
> > > > > > > > > > Actually thinking about it a bit more, not sure you need to 
> > > > > > > > > > actually implement ConstExprEmitterLValue for now.  You 
> > > > > > > > > > might just be able to ensure we don't ever call 
> > > > > > > > > > ConstExprEmitter with an lvalue.  The current 
> > > > > > > > > > ConstExprEmitter doesn't expect lvalues, and shouldn't call 
> > > > > > > > > > itself with lvalues.  (We bail on explicit LValueToRValue 
> > > > > > > > > > conversions.)  And Evaluate() shouldn't actually evaluate 
> > > > > > > > > > the contents of an lvalue if it isn't dereferenced, so 
> > > > > > > > > > there hopefully aren't any performance issues using that 
> > > > > > > > > > codepath.
> > > > > > > > > > 
> > > > > > > > > > In terms of implementation, I guess that's basically 
> > > > > > > > > > restoring the destType->isReferenceType() that got removed? 
> > > > > > > > > >  (I know I suggested it, but I wasn't really thinking about 
> > > > > > > > > > it...)
> > > > > > > > > One thing I think we may need to add to `ConstExprEmitter` is 
> > > > > > > > > the ability to evaluate `CallExpr`s based on certain test 
> > > > > > > > > case failures...does that seem right?
> > > > > > > > See also the calls to `constexpr f()` in 
> > > > > > > > clang/test/CodeGenCXX/const-init-cxx1y.cpp
> > > > > > > The only things I know of that Evaluate() can't handle are 
> > > > > > > CK_ToUnion, CK_ReinterpretMemberPointer, and 
> > > > > > > DesignatedInitUpdateExpr.  DesignatedInitUpdateExpr is related to 
> > > > > > > the failures in test/CodeGenCXX/designated-init.cpp; I don't 
> > > > > > > think the others show up in any of the testcases you've 
> > > > > > > mentioned.  (CK_ToUnion can't appear in C++ code. 
> > > > > > > CK_ReinterpretMemberPointer is a `reinterpret_cast` where T is 
> > > > > > > a member pointer type.)
> > > > > > > 
> > > > > > > Given none of those constructs show up in const-init-cxx1y.cpp, 
> > > > > > > the only reason for it to fail is if we aren't correctly falling 
> > > > > > > back for a construct the current code doesn't know how to handle. 
> > > > > > >  You shouldn't need to implement any new constructs.
> > > > > > in clang/test/CodeGenCXX/designated-init.cpp we have:
> > > > > > ```
> > > > > > >> 22 namespace ModifyStaticTemporary { 
> > > > > > >>   
> > > > > >23   struct A { int & int x; };   
> > > > > >   
> > > > > >24   constexpr int f(int ) { r *= 9; return r - 12; }  
> > > > > >   
> > > > > >25   A a = { 6, f(a.temporary) };
> > > > > > ```
> > > > > > In the AST, that looks like:
> > > > > > ```
> > > > > > | |-VarDecl 0x562b77df39b0  col:5 used a 
> > > > > > 'A':'ModifyStaticTemporary::A' cinit
> > > > > > | | `-ExprWithCleanups 0x562b77df3c68  
> > > > > > 'A':'ModifyStaticTemporary::A'
> > > > > > | |   `-InitListExpr 0x562b77df3bb8  
> > > > > > 'A':'ModifyStaticTemporary::A'
> > > > > > | | |-MaterializeTemporaryExpr 0x562b77df3c08  'int' 
> > > > > > xvalue extended by Var 0x562b77df39b0 'a' 
> > > > > > 'A':'ModifyStaticTemporary::A'
> > > > > > | | | `-IntegerLiteral 0x562b77df3a18  'int' 6
> > > > > > | | `-CallExpr 0x562b77df3b30  'int'
> > > > > > | |   |-ImplicitCastExpr 0x562b77df3b18  'int (*)(int 
> > > > > > &)' 
> > > > > > | |   | `-DeclRefExpr 0x562b77df3ad0  'int (int &)' 
> > > > > > lvalue Function 0x562b77df37a0 'f' 'int (int &)'
> > > > > > | |   `-MemberExpr 0x562b77df3aa0  'int' lvalue 
> > > > > > .temporary 0x562b77df35c0
> > > > > > | | `-DeclRefExpr 

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

2023-06-05 Thread Soumi Manna via Phabricator via cfe-commits
Manna added inline comments.



Comment at: clang/lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp:756
 if (ReceiverType->isObjCIdType() || ReceiverType->isObjCClassType() ||
 ASTCtxt.canAssignObjCInterfaces(ReceiverObjectPtrType, TrackedType)) {
   const ObjCInterfaceDecl *InterfaceDecl = TrackedType->getInterfaceDecl();

We are assigning: ReceiverObjectPtrType = nullptr return value from getAs.
```
const auto *ReceiverObjectPtrType =
  ReceiverType->getAs();
```

Then we are dereferencing  nullptr ReceiverObjectPtrType when calling 
canAssignObjCInterfaces()


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152194

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


[PATCH] D152195: [Clang] Fix access of friend function in local class

2023-06-05 Thread Elizabeth Andrews via Phabricator via cfe-commits
eandrews created this revision.
eandrews added reviewers: erichkeane, aaron.ballman.
Herald added a project: All.
eandrews requested review of this revision.

Clang currently emits an error when a friend of a local class tries to access 
it's private data members. This patch fixes the bug.


https://reviews.llvm.org/D152195

Files:
  clang/lib/Sema/SemaDecl.cpp
  clang/test/Sema/local-class-friend.cpp


Index: clang/test/Sema/local-class-friend.cpp
===
--- /dev/null
+++ clang/test/Sema/local-class-friend.cpp
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -verify -fsyntax-only %s
+// expected-no-diagnostics
+
+void foo()
+{ class c1 {
+private:
+  int testVar;
+public:
+  friend class c2;
+  };
+
+  class c2 {
+void f(c1 obj) {
+  int a = obj.testVar; // Ok
+}
+  };
+}
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -17065,11 +17065,14 @@
   S = getTagInjectionScope(S, getLangOpts());
 } else {
   assert(TUK == TUK_Friend);
+  CXXRecordDecl *RD = dyn_cast(SearchDC);
+
   // C++ [namespace.memdef]p3:
   //   If a friend declaration in a non-local class first declares a
   //   class or function, the friend class or function is a member of
   //   the innermost enclosing namespace.
-  SearchDC = SearchDC->getEnclosingNamespaceContext();
+  SearchDC = RD->isLocalClass() ? RD->isLocalClass()
+: SearchDC->getEnclosingNamespaceContext();
 }
 
 // In C++, we need to do a redeclaration lookup to properly


Index: clang/test/Sema/local-class-friend.cpp
===
--- /dev/null
+++ clang/test/Sema/local-class-friend.cpp
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -verify -fsyntax-only %s
+// expected-no-diagnostics
+
+void foo()
+{ class c1 {
+private:
+  int testVar;
+public:
+  friend class c2;
+  };
+
+  class c2 {
+void f(c1 obj) {
+  int a = obj.testVar; // Ok
+}
+  };
+}
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -17065,11 +17065,14 @@
   S = getTagInjectionScope(S, getLangOpts());
 } else {
   assert(TUK == TUK_Friend);
+  CXXRecordDecl *RD = dyn_cast(SearchDC);
+
   // C++ [namespace.memdef]p3:
   //   If a friend declaration in a non-local class first declares a
   //   class or function, the friend class or function is a member of
   //   the innermost enclosing namespace.
-  SearchDC = SearchDC->getEnclosingNamespaceContext();
+  SearchDC = RD->isLocalClass() ? RD->isLocalClass()
+: SearchDC->getEnclosingNamespaceContext();
 }
 
 // In C++, we need to do a redeclaration lookup to properly
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2023-06-05 Thread Soumi Manna via Phabricator via cfe-commits
Manna created this revision.
Manna added a reviewer: erichkeane.
Herald added subscribers: steakhal, manas, ASDenysPetrov, martong, dkrupp, 
donat.nagy, Szelethus, a.sidorin, baloghadamsoftware.
Herald added a reviewer: NoQ.
Herald added a project: All.
Manna requested review of this revision.
Herald added a project: clang.

This patch uses castAs instead of getAs which will assert if the type doesn't 
match in findMethodDecl(clang::​ObjCMessageExpr const *, 
clang::​ObjCObjectPointerType const *, clang::​ASTContext &).


Repository:
  rG LLVM Github Monorepo

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
@@ -743,7 +743,7 @@
 
   QualType ReceiverType = MessageExpr->getReceiverType();
   const auto *ReceiverObjectPtrType =
-  ReceiverType->getAs();
+  ReceiverType->castAs();
 
   // Do this "devirtualization" on instance and class methods only. Trust the
   // static type on super and super class calls.


Index: clang/lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp
+++ clang/lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp
@@ -743,7 +743,7 @@
 
   QualType ReceiverType = MessageExpr->getReceiverType();
   const auto *ReceiverObjectPtrType =
-  ReceiverType->getAs();
+  ReceiverType->castAs();
 
   // Do this "devirtualization" on instance and class methods only. Trust the
   // static type on super and super class calls.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D152034: [clang][NFC] refactors value type traits so we can have more than bools

2023-06-05 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added a subscriber: kazu.
nickdesaulniers added inline comments.



Comment at: clang/lib/Sema/SemaExprCXX.cpp:5591-5594
+  default:
+llvm_unreachable("reached the end of BuildTypeTrait because the type "
+ "trait's type is unaccounted for");
+  }

nickdesaulniers wrote:
> ```
> llvm-project/clang/lib/Sema/SemaExprCXX.cpp:5591:3: warning: default label in 
> switch which covers all enumeration values [-Wcovered-switch-default]
>   default:
>   ^
> ```
commit caf00725923c ("[Sema] Fix a warning")
via @kazu 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152034

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


[clang] caf0072 - [Sema] Fix a warning

2023-06-05 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2023-06-05T12:59:58-07:00
New Revision: caf00725923cb89af9b9478c53496e9f81ee4d6d

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

LOG: [Sema] Fix a warning

This patch fixes:

  clang/lib/Sema/SemaExprCXX.cpp:5591:3: error: default label in
  switch which covers all enumeration values
  [-Werror,-Wcovered-switch-default]

Added: 


Modified: 
clang/lib/Sema/SemaExprCXX.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp
index 30925c37dc08c..eeae6cda53e5b 100644
--- a/clang/lib/Sema/SemaExprCXX.cpp
+++ b/clang/lib/Sema/SemaExprCXX.cpp
@@ -5588,9 +5588,6 @@ ExprResult Sema::BuildTypeTrait(TypeTrait Kind, 
SourceLocation KWLoc,
 return TypeTraitExpr::Create(Context, Context.getLogicalOperationType(),
  KWLoc, Kind, Args, RParenLoc, Result);
   }
-  default:
-llvm_unreachable("reached the end of BuildTypeTrait because the type "
- "trait's type is unaccounted for");
   }
 }
 



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


[PATCH] D152034: [clang][NFC] refactors value type traits so we can have more than bools

2023-06-05 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added inline comments.



Comment at: clang/lib/Sema/SemaExprCXX.cpp:5591-5594
+  default:
+llvm_unreachable("reached the end of BuildTypeTrait because the type "
+ "trait's type is unaccounted for");
+  }

```
llvm-project/clang/lib/Sema/SemaExprCXX.cpp:5591:3: warning: default label in 
switch which covers all enumeration values [-Wcovered-switch-default]
  default:
  ^
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152034

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


[PATCH] D151047: [clang-format] Fix indentation for selective formatting.

2023-06-05 Thread Sedenion via Phabricator via cfe-commits
Sedeniono added a comment.

@barannikov88 ok, thanks. I just did that. The latest diff looks right. 
I wondered because phabricator suddenly showed changes in ocaml files, which I 
certainly did not want.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151047

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


[PATCH] D151047: [clang-format] Fix indentation for selective formatting.

2023-06-05 Thread Sedenion via Phabricator via cfe-commits
Sedeniono updated this revision to Diff 528547.
Sedeniono added a comment.

Next try at getting the 2nd attempt into review. This is again the complete 
fix, since the previous revision got reverted.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151047

Files:
  clang/lib/Format/UnwrappedLineFormatter.cpp
  clang/unittests/Format/FormatTestSelective.cpp

Index: clang/unittests/Format/FormatTestSelective.cpp
===
--- clang/unittests/Format/FormatTestSelective.cpp
+++ clang/unittests/Format/FormatTestSelective.cpp
@@ -528,6 +528,26 @@
 format("  int a;\n"
"void ff() {}",
11, 0));
+
+  // https://github.com/llvm/llvm-project/issues/59178
+  Style = getMozillaStyle();
+  EXPECT_EQ("int a()\n"
+"{\n"
+"return 0;\n"
+"}\n"
+"int b()\n"
+"{\n"
+"  return 42;\n"
+"}",
+format("int a()\n"
+   "{\n"
+   "return 0;\n"
+   "}\n"
+   "int b()\n"
+   "{\n"
+   "return 42;\n" // Format this line only
+   "}",
+   32, 0));
 }
 
 TEST_F(FormatTestSelective, UnderstandsTabs) {
@@ -617,6 +637,70 @@
  "namespace ns1 { namespace ns2 {\n"
  "}}";
   EXPECT_EQ(Code, format(Code, 0, 0));
+
+  Style = getLLVMStyle();
+  Style.FixNamespaceComments = false;
+  Code = "namespace ns {\n"
+ "#define REF(alias) alias alias_var;\n"
+ "}";
+  EXPECT_EQ(Code, format(Code, 51, 1));
+}
+
+TEST_F(FormatTestSelective, FormatMacroRegardlessOfPreviousIndent) {
+  // clang-format currently does not (or should not) take into account the
+  // indent of previous unformatted lines when formatting a PP directive.
+  // Technically speaking, LevelIndentTracker::IndentForLevel is only for non-PP
+  // lines. So these tests here check that the indent of previous non-PP lines
+  // do not affect the formatting. If this requirement changes, the tests here
+  // need to be adapted.
+  Style = getLLVMStyle();
+
+  Style.IndentPPDirectives = FormatStyle::PPDirectiveIndentStyle::PPDIS_None;
+  EXPECT_EQ("  class Foo {\n"
+"void test() {\n"
+"#ifdef 1\n"
+"#define some\n" // Formatted line
+"#endif\n"   // That this line is also formatted might be a bug.
+"}};", // Dito: Bug?
+format("  class Foo {\n"
+   "void test() {\n"
+   "#ifdef 1\n"
+   "#define some\n" // format this line
+   " #endif\n"
+   "}};",
+   75, 0));
+
+  Style.IndentPPDirectives =
+  FormatStyle::PPDirectiveIndentStyle::PPDIS_BeforeHash;
+  EXPECT_EQ("  class Foo {\n"
+"void test() {\n"
+"#ifdef 1\n"
+"  #define some\n" // Formatted line
+" #endif\n"
+"}};",
+format("  class Foo {\n"
+   "void test() {\n"
+   "#ifdef 1\n"
+   "#define some\n" // format this line
+   " #endif\n"
+   "}};",
+   75, 0));
+
+  Style.IndentPPDirectives =
+  FormatStyle::PPDirectiveIndentStyle::PPDIS_AfterHash;
+  EXPECT_EQ("  class Foo {\n"
+"void test() {\n"
+"#ifdef 1\n"
+"#  define some\n" // Formatted line
+"#endif\n" // That this line is also formatted might be a bug.
+"}};",
+format("  class Foo {\n"
+   "void test() {\n"
+   "#ifdef 1\n"
+   "#define some\n" // format this line
+   " #endif\n"
+   "}};",
+   75, 0));
 }
 
 } // end namespace
Index: clang/lib/Format/UnwrappedLineFormatter.cpp
===
--- clang/lib/Format/UnwrappedLineFormatter.cpp
+++ clang/lib/Format/UnwrappedLineFormatter.cpp
@@ -74,6 +74,12 @@
: Line.Level * PPIndentWidth;
   Indent += AdditionalIndent;
 } else {
+  // When going to lower levels, forget previous higher levels so that we
+  // recompute future higher levels. But don't forget them if we enter a PP
+  // directive, since these do not terminate a code block.
+  if (!Line.InPPDirective && Line.Level < IndentForLevel.size())
+IndentForLevel.resize(Line.Level + 1, -1);
+
   Indent = getIndent(Line.Level);
 }
 if (static_cast(Indent) + Offset >= 0)
@@ -88,13 +94,13 @@

[PATCH] D152017: [DebugInfo] Add flag to only emit referenced member functions

2023-06-05 Thread Paul Robinson via Phabricator via cfe-commits
probinson added a comment.

I experimented with this. Looks like it emits info only for //defined// 
methods, and not //used// methods. That is, if you change the test to say
`void t1::f1() { f2(); }`
you get DWARF for f1 but not f2. The way Sony does it, you get DWARF for f1 and 
f2.
(Neither case sees info for f3, which is declared but not defined or used.)

Is that what you intended?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152017

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


[PATCH] D131594: WORK IN PROGRESS Add Clang UEFI target to support "x86_64-unknown-uefi" triple

2023-06-05 Thread Petr Hosek via Phabricator via cfe-commits
phosek added a comment.

I'd split the `llvm/` changes into a separate change.




Comment at: clang/lib/Driver/ToolChains/UEFI.cpp:58-59
+  !C.getDriver().IsCLMode() && !C.getDriver().IsFlangMode()) {
+CmdArgs.push_back("-defaultlib:libcmt");
+CmdArgs.push_back("-defaultlib:oldnames");
+  }

I don't think these should be needed for UEFI targets.



Comment at: llvm/test/ExecutionEngine/RuntimeDyld/X86/coff-alignment.ll:4
 ; RUN: opt -mtriple=x86_64-pc-win32-coff %s -o - | lli
+; RUN: opt -mtriple=x86_64-unknown-coff %s -o - | lli
 

Should this be `uefi`?



Comment at: llvm/test/Instrumentation/InstrProfiling/profiling.ll:10
 ; RUN: opt < %s  -mtriple=x86_64-pc-win32-coff -passes=instrprof -S | 
FileCheck %s --check-prefixes=COFF
+; RUN: opt < %s  -mtriple=x86_64-unknown-coff -passes=instrprof -S | FileCheck 
%s --check-prefixes=COFF
 ; RUN: opt < %s -mtriple=powerpc64-ibm-aix-xcoff -passes=instrprof -S | 
FileCheck %s --check-prefixes=XCOFF

Should this be `uefi`?



Comment at: llvm/test/Transforms/PGOProfile/comdat_rename.ll:3
 ; RUN: opt < %s -mtriple=x86_64-pc-win32-coff -passes=pgo-instr-gen 
-do-comdat-renaming=true -S | FileCheck %s
+; RUN: opt < %s -mtriple=x86_64-unknown-coff -passes=pgo-instr-gen 
-do-comdat-renaming=true -S | FileCheck %s
 

Should this be `uefi`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131594

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


[PATCH] D152186: [Clang] Add release note for 877210faa447

2023-06-05 Thread Nathan Chancellor via Phabricator via cfe-commits
nathanchance added a comment.

Thanks, I landed it with those nits addressed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152186

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


[PATCH] D152186: [Clang] Add release note for 877210faa447

2023-06-05 Thread Nathan Chancellor 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 rGdeecf89a1361: [Clang] Add release note for 877210faa447 
(authored by nathanchance).

Changed prior to commit:
  https://reviews.llvm.org/D152186?vs=528534=528539#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152186

Files:
  clang/docs/ReleaseNotes.rst


Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -330,6 +330,8 @@
   ``-fno-diagnostics-show-line-numbers``. At the same time, the maximum
   number of code lines it prints has been increased from 1 to 16. This
   can be controlled using ``-fcaret-diagnostics-max-lines=``.
+- Clang no longer emits ``-Wunused-variable`` warnings for variables declared
+  with ``__attribute__((cleanup(...)))`` to match GCC's behavior.
 
 Bug Fixes in This Version
 -


Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -330,6 +330,8 @@
   ``-fno-diagnostics-show-line-numbers``. At the same time, the maximum
   number of code lines it prints has been increased from 1 to 16. This
   can be controlled using ``-fcaret-diagnostics-max-lines=``.
+- Clang no longer emits ``-Wunused-variable`` warnings for variables declared
+  with ``__attribute__((cleanup(...)))`` to match GCC's behavior.
 
 Bug Fixes in This Version
 -
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] deecf89 - [Clang] Add release note for 877210faa447

2023-06-05 Thread Nathan Chancellor via cfe-commits

Author: Nathan Chancellor
Date: 2023-06-05T12:14:51-07:00
New Revision: deecf89a1361cf3407f0fe32e7085127ec0865dc

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

LOG: [Clang] Add release note for 877210faa447

Reviewed By: erichkeane, nickdesaulniers

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

Added: 


Modified: 
clang/docs/ReleaseNotes.rst

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index f1ac1cb79fe23..8db6de896a121 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -330,6 +330,8 @@ Improvements to Clang's diagnostics
   ``-fno-diagnostics-show-line-numbers``. At the same time, the maximum
   number of code lines it prints has been increased from 1 to 16. This
   can be controlled using ``-fcaret-diagnostics-max-lines=``.
+- Clang no longer emits ``-Wunused-variable`` warnings for variables declared
+  with ``__attribute__((cleanup(...)))`` to match GCC's behavior.
 
 Bug Fixes in This Version
 -



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


[PATCH] D152186: [Clang] Add release note for 877210faa447

2023-06-05 Thread Erich Keane via Phabricator via cfe-commits
erichkeane accepted this revision.
erichkeane added a comment.

2 nits, otherwise LGTM!  Thanks!




Comment at: clang/docs/ReleaseNotes.rst:333
   can be controlled using ``-fcaret-diagnostics-max-lines=``.
+- Clang no longer emits ``-Wunused-variable`` for variables declared with
+  ``__attribute__((cleanup(...)))`` to match GCC.





Comment at: clang/docs/ReleaseNotes.rst:334
+- Clang no longer emits ``-Wunused-variable`` for variables declared with
+  ``__attribute__((cleanup(...)))`` to match GCC.
 




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152186

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


[PATCH] D152186: [Clang] Add release note for 877210faa447

2023-06-05 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers accepted this revision.
nickdesaulniers added a comment.
This revision is now accepted and ready to land.

Thanks for the patch!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152186

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


[PATCH] D151587: [clang][ConstantEmitter] have tryEmitPrivateForVarInit try ConstExprEmitter fast-path first

2023-06-05 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added inline comments.



Comment at: clang/lib/CodeGen/CGExprConstant.cpp:1324
 // This is a string literal initializing an array in an initializer.
-return CGM.GetConstantArrayFromStringLiteral(E);
+return E->isLValue() ?
+  CGM.GetAddrOfConstantStringFromLiteral(E).getPointer() :

nickdesaulniers wrote:
> efriedma wrote:
> > efriedma wrote:
> > > efriedma wrote:
> > > > nickdesaulniers wrote:
> > > > > efriedma wrote:
> > > > > > nickdesaulniers wrote:
> > > > > > > nickdesaulniers wrote:
> > > > > > > > efriedma wrote:
> > > > > > > > > nickdesaulniers wrote:
> > > > > > > > > > efriedma wrote:
> > > > > > > > > > > Maybe we should have a separate ConstExprEmitterLValue... 
> > > > > > > > > > > trying to handle both LValues and RValues on the same 
> > > > > > > > > > > codepath has been problematic in the past.  It's very 
> > > > > > > > > > > easy for code to get confused what it's actually trying 
> > > > > > > > > > > to emit.
> > > > > > > > > > So we'd have a `ConstExprEmitterLValue` class with some 
> > > > > > > > > > visitor methods, and a `ConstExprEmitterRValue` with other 
> > > > > > > > > > methods implemented?
> > > > > > > > > Something like that.
> > > > > > > > > 
> > > > > > > > > Actually thinking about it a bit more, not sure you need to 
> > > > > > > > > actually implement ConstExprEmitterLValue for now.  You might 
> > > > > > > > > just be able to ensure we don't ever call ConstExprEmitter 
> > > > > > > > > with an lvalue.  The current ConstExprEmitter doesn't expect 
> > > > > > > > > lvalues, and shouldn't call itself with lvalues.  (We bail on 
> > > > > > > > > explicit LValueToRValue conversions.)  And Evaluate() 
> > > > > > > > > shouldn't actually evaluate the contents of an lvalue if it 
> > > > > > > > > isn't dereferenced, so there hopefully aren't any performance 
> > > > > > > > > issues using that codepath.
> > > > > > > > > 
> > > > > > > > > In terms of implementation, I guess that's basically 
> > > > > > > > > restoring the destType->isReferenceType() that got removed?  
> > > > > > > > > (I know I suggested it, but I wasn't really thinking about 
> > > > > > > > > it...)
> > > > > > > > One thing I think we may need to add to `ConstExprEmitter` is 
> > > > > > > > the ability to evaluate `CallExpr`s based on certain test case 
> > > > > > > > failures...does that seem right?
> > > > > > > See also the calls to `constexpr f()` in 
> > > > > > > clang/test/CodeGenCXX/const-init-cxx1y.cpp
> > > > > > The only things I know of that Evaluate() can't handle are 
> > > > > > CK_ToUnion, CK_ReinterpretMemberPointer, and 
> > > > > > DesignatedInitUpdateExpr.  DesignatedInitUpdateExpr is related to 
> > > > > > the failures in test/CodeGenCXX/designated-init.cpp; I don't think 
> > > > > > the others show up in any of the testcases you've mentioned.  
> > > > > > (CK_ToUnion can't appear in C++ code. CK_ReinterpretMemberPointer 
> > > > > > is a `reinterpret_cast` where T is a member pointer type.)
> > > > > > 
> > > > > > Given none of those constructs show up in const-init-cxx1y.cpp, the 
> > > > > > only reason for it to fail is if we aren't correctly falling back 
> > > > > > for a construct the current code doesn't know how to handle.  You 
> > > > > > shouldn't need to implement any new constructs.
> > > > > in clang/test/CodeGenCXX/designated-init.cpp we have:
> > > > > ```
> > > > > >> 22 namespace ModifyStaticTemporary {   
> > > > > >> 
> > > > >23   struct A { int & int x; }; 
> > > > > 
> > > > >24   constexpr int f(int ) { r *= 9; return r - 12; }
> > > > > 
> > > > >25   A a = { 6, f(a.temporary) };
> > > > > ```
> > > > > In the AST, that looks like:
> > > > > ```
> > > > > | |-VarDecl 0x562b77df39b0  col:5 used a 
> > > > > 'A':'ModifyStaticTemporary::A' cinit
> > > > > | | `-ExprWithCleanups 0x562b77df3c68  
> > > > > 'A':'ModifyStaticTemporary::A'
> > > > > | |   `-InitListExpr 0x562b77df3bb8  
> > > > > 'A':'ModifyStaticTemporary::A'
> > > > > | | |-MaterializeTemporaryExpr 0x562b77df3c08  'int' 
> > > > > xvalue extended by Var 0x562b77df39b0 'a' 
> > > > > 'A':'ModifyStaticTemporary::A'
> > > > > | | | `-IntegerLiteral 0x562b77df3a18  'int' 6
> > > > > | | `-CallExpr 0x562b77df3b30  'int'
> > > > > | |   |-ImplicitCastExpr 0x562b77df3b18  'int (*)(int &)' 
> > > > > 
> > > > > | |   | `-DeclRefExpr 0x562b77df3ad0  'int (int &)' 
> > > > > lvalue Function 0x562b77df37a0 'f' 'int (int &)'
> > > > > | |   `-MemberExpr 0x562b77df3aa0  'int' lvalue 
> > > > > .temporary 0x562b77df35c0
> > > > > | | `-DeclRefExpr 0x562b77df3a80  
> > > > > 'A':'ModifyStaticTemporary::A' lvalue Var 0x562b77df39b0 'a' 
> > > > > 'A':'ModifyStaticTemporary::A'
> > > > > ```
> > > > > (So, indeed no `DesignatedInitUpdateExpr`) but the call to the 
> > > > > 

[PATCH] D151320: [clang] Add `// expected-maybe-no-diagnostics` comment to VerifyDiagnosticConsumer

2023-06-05 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.

LGTM!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151320

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


[PATCH] D151047: [clang-format] Fix indentation for selective formatting.

2023-06-05 Thread Sergei Barannikov via Phabricator via cfe-commits
barannikov88 added a comment.

In D151047#4396739 , @Sedeniono wrote:

> Oh damn, I executed `arc diff --update D151047` on the main branch instead of 
> my own local branch... Sorry.
> Can I somehow revert that? Or should I simply use the "abandon review" action 
> and create a entirely new one?

Just checkout the local branch and rerun this command :)
You will probably need to reset hard the main branch before or after that.

When you are updating the review and arc requests you to write a message, it 
asks for "what changed since the last revision".
It would usually be something like "Rebase" or "Address review comments", you 
don't need to repeat commit message there.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151047

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


[PATCH] D148094: [clang][CodeGen] Break up TargetInfo.cpp [8/8]

2023-06-05 Thread Sergei Barannikov via Phabricator via cfe-commits
barannikov88 added a comment.

@efriedma Thank you for all your reviews!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148094

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


[PATCH] D152186: [Clang] Add release note for 877210faa447

2023-06-05 Thread Nathan Chancellor via Phabricator via cfe-commits
nathanchance created this revision.
nathanchance added reviewers: erichkeane, nickdesaulniers.
Herald added a project: All.
nathanchance requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D152186

Files:
  clang/docs/ReleaseNotes.rst


Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -330,6 +330,8 @@
   ``-fno-diagnostics-show-line-numbers``. At the same time, the maximum
   number of code lines it prints has been increased from 1 to 16. This
   can be controlled using ``-fcaret-diagnostics-max-lines=``.
+- Clang no longer emits ``-Wunused-variable`` for variables declared with
+  ``__attribute__((cleanup(...)))`` to match GCC.
 
 Bug Fixes in This Version
 -


Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -330,6 +330,8 @@
   ``-fno-diagnostics-show-line-numbers``. At the same time, the maximum
   number of code lines it prints has been increased from 1 to 16. This
   can be controlled using ``-fcaret-diagnostics-max-lines=``.
+- Clang no longer emits ``-Wunused-variable`` for variables declared with
+  ``__attribute__((cleanup(...)))`` to match GCC.
 
 Bug Fixes in This Version
 -
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D152180: [Sema] Do not emit -Wunused-variable for variables declared with cleanup attribute

2023-06-05 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

I note I forgot to require a release note, so please add one of those (and make 
sure it gets incorporated in any cherry-pick that happens).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152180

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


[PATCH] D151047: [clang-format] Fix indentation for selective formatting.

2023-06-05 Thread Sedenion via Phabricator via cfe-commits
Sedeniono added a comment.

Oh damn, I executed `arc diff --update D151047` on the main branch instead of 
my own local branch... Sorry.
Can I somehow revert that? Or should I simply use the "abandon review" action 
and create a entirely new one?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151047

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


[PATCH] D151047: [clang-format] Fix indentation for selective formatting.

2023-06-05 Thread Sedenion via Phabricator via cfe-commits
Sedeniono updated this revision to Diff 528531.
Sedeniono added a comment.
Herald added subscribers: llvm-commits, pcwang-thead.
Herald added a project: LLVM.

Fixes github issues #59178, #58464 and #62799.

  

The problem was that the LevelIndentTracker remembered
the indentation level of previous deeper levels when
leaving a scope. Afterwards, when it entered again a
deeper level, it blindly reused the previous
indentation level. In case the --lines option was used
such that the previous deeper level was not formatted,
that previous level was whatever happened to be there
in the source code. The formatter simply believed it.

This is fixed by letting the LevelIndentTracker forget
the previous deeper levels when stepping out of them
(=> change in LevelIndentTracker::nextLine()).
Note that this used to be the case until LLVM 14.0.6,
but was changed in https://reviews.llvm.org/D129064
(#56352) to fix a crash. Our commit here essentially
reverts that crash fix. It was incorrect/incomplete.

Even with the revert, the crash from
https://reviews.llvm.org/D129064 (#56352) no longer
occurs, most likely because of the changes made in
https://reviews.llvm.org/D144296 (#60843).

The change in adjustToUnmodifiedLine() ensures that
the assert() is only checked if IndentForLevel is
actually accessed.

The new test FormatTestSelective.DontAssert checks
a case where a previous iteration of the present
patch triggered an assert().

The new tests in
FormatMacroRegardlessOfPreviousIndent check the
formatting of a preprocessor #define. They ensure
that the content of LevelIndentTracker::IndentForLevel
does not affect PP directives.

See
https://github.com/llvm/llvm-project/issues/59178#issuecomment-1542637781
for some more details.

This commit is the 2nd try for
https://reviews.llvm.org/D151047


Herald added a comment.

NOTE: Clang-Format Team Automated Review Comment

It looks like your clang-format review does not contain any unit tests, please 
try to ensure all code changes have a unit test (unless this is an `NFC` or 
refactoring, adding documentation etc..)

Add your unit tests in `clang/unittests/Format` and you can build with `ninja 
FormatTests`.  We recommend using the `verifyFormat(xxx)` format of unit tests 
rather than `EXPECT_EQ` as this will ensure you change is tolerant to random 
whitespace changes (see FormatTest.cpp as an example)

For situations where your change is altering the TokenAnnotator.cpp which can 
happen if you are trying to improve the annotation phase to ensure we are 
correctly identifying the type of a token, please add a token annotator test in 
`TokenAnnotatorTest.cpp`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151047

Files:
  llvm/bindings/ocaml/llvm/META.llvm.in
  llvm/bindings/ocaml/llvm/llvm_ocaml.h


Index: llvm/bindings/ocaml/llvm/llvm_ocaml.h
===
--- llvm/bindings/ocaml/llvm/llvm_ocaml.h
+++ llvm/bindings/ocaml/llvm/llvm_ocaml.h
@@ -56,7 +56,6 @@
 #define Use_val(v) ((LLVMUseRef)from_val(v))
 #define BasicBlock_val(v) ((LLVMBasicBlockRef)from_val(v))
 #define MemoryBuffer_val(v) ((LLVMMemoryBufferRef)from_val(v))
-#define PassManager_val(v) ((LLVMPassManagerRef)from_val(v))
 
 /* Convert a C pointer to an OCaml option */
 value ptr_to_option(void *Ptr);
Index: llvm/bindings/ocaml/llvm/META.llvm.in
===
--- llvm/bindings/ocaml/llvm/META.llvm.in
+++ llvm/bindings/ocaml/llvm/META.llvm.in
@@ -37,14 +37,6 @@
 archive(native) = "llvm_executionengine.cmxa"
 )
 
-package "ipo" (
-requires = "llvm"
-version  = "@PACKAGE_VERSION@"
-description = "IPO Transforms for LLVM"
-archive(byte) = "llvm_ipo.cma"
-archive(native) = "llvm_ipo.cmxa"
-)
-
 package "debuginfo" (
 requires = "llvm"
 version = "@PACKAGE_VERSION@"
@@ -61,14 +53,6 @@
 archive(native) = "llvm_irreader.cmxa"
 )
 
-package "scalar_opts" (
-requires = "llvm"
-version = "@PACKAGE_VERSION@"
-description = "Scalar Transforms for LLVM"
-archive(byte) = "llvm_scalar_opts.cma"
-archive(native) = "llvm_scalar_opts.cmxa"
-)
-
 package "transform_utils" (
 requires = "llvm"
 version = "@PACKAGE_VERSION@"
@@ -77,22 +61,6 @@
 archive(native) = "llvm_transform_utils.cmxa"
 )
 
-package "vectorize" (
-requires = "llvm"
-version = "@PACKAGE_VERSION@"
-description = "Vector Transforms for LLVM"
-archive(byte) = "llvm_vectorize.cma"
-archive(native) = "llvm_vectorize.cmxa"
-)
-
-package "passmgr_builder" (
-requires = "llvm"
-version = "@PACKAGE_VERSION@"
-description = "Pass Manager Builder for LLVM"
-archive(byte) = "llvm_passmgr_builder.cma"
-archive(native) = "llvm_passmgr_builder.cmxa"
-)
-
 package "target" (
 requires = "llvm"
 version  = "@PACKAGE_VERSION@"


Index: 

[PATCH] D151047: [clang-format] Fix indentation for selective formatting.

2023-06-05 Thread Sedenion via Phabricator via cfe-commits
Sedeniono reopened this revision.
Sedeniono added a comment.
This revision is now accepted and ready to land.

Ok, here is the 2nd attempt at fixing the issue. The patch is based on the 
current main branch.

Regarding `LineJoiner::join()`: Turns out, not setting `A.Level` but reverting 
the original crash fix of https://reviews.llvm.org/D129064 no longer produces 
the crash. From debugging it I guess this is because of 
https://reviews.llvm.org/D144296 (although I haven't bisected it to confirm 
this). I am not really sure whether setting `A.Level` should or should not be 
done. So I am keeping it as it is.

But therefore note, since https://reviews.llvm.org/D144296 seems to not have 
been merged into the LLVM 16, the present fix can probably not be merged 
without further changes.

So, the new patch basically just reverts the original fix of 
https://reviews.llvm.org/D129064 (i.e. it re-introduces the `resize()` in 
`LevelIndentTracker::nextLine()`). The other changes are just cosmetics and 
additional tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151047

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


[PATCH] D148094: [clang][CodeGen] Break up TargetInfo.cpp [8/8]

2023-06-05 Thread Eli Friedman via Phabricator via cfe-commits
efriedma accepted this revision.
efriedma added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148094

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


[PATCH] D144911: adding bf16 support to NVPTX

2023-06-05 Thread Kushan Ahmadian via Phabricator via cfe-commits
kushanam added a comment.

In D144911#4389187 , @manishucsd 
wrote:

> I tried this patch to resolve lowering `nvvm.mma.sync` on bf16 operands for 
> the PR 13858 
>
>   nvvm.mma.sync A[%293, %295, %297, %299]  B[%392, %394]  C[%484, %485, %487, 
> %488]  {layoutA = #nvvm.mma_layout, layoutB = #nvvm.mma_layout, 
> multiplicandAPtxType = #nvvm.mma_type, multiplicandBPtxType = 
> #nvvm.mma_type, shape = #nvvm.shape} : 
> (vector<2xbf16>, vector<2xbf16>, f32) -> !llvm.struct<(f32, f32, f32, f32)>
>
> I fail to compile this patch. Please find the compilation error below:
>
>   [build] ./llvm-project/llvm/lib/Target/NVPTX/NVPTXInstrInfo.td:1117:40: 
> error: Variable not defined: 'hasPTX70'
>   [build] Requires<[useFP16Math, hasPTX70, hasSM80, Pred]>;
>   [build]^
>
>   

Could you try again, I rebased and refactored the code


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144911

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


[PATCH] D144911: adding bf16 support to NVPTX

2023-06-05 Thread Kushan Ahmadian via Phabricator via cfe-commits
kushanam updated this revision to Diff 528526.
kushanam added a comment.

adding min and max for bf16 and refactoring the code


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144911

Files:
  llvm/lib/Target/NVPTX/NVPTXISelDAGToDAG.cpp
  llvm/lib/Target/NVPTX/NVPTXISelLowering.cpp


Index: llvm/lib/Target/NVPTX/NVPTXISelLowering.cpp
===
--- llvm/lib/Target/NVPTX/NVPTXISelLowering.cpp
+++ llvm/lib/Target/NVPTX/NVPTXISelLowering.cpp
@@ -150,23 +150,11 @@
 }
 
 static bool Isv2f16Orv2bf16Type(MVT VT) {
-  switch (VT.SimpleTy) {
-  default:
-return false;
-  case MVT::v2f16:
-  case MVT::v2bf16:
-return true;
-  }
+  return (VT.SimpleTy == MVT::v2f16 || VT.SimpleTy == MVT::v2bf16);
 }
 
 static bool Isf16Orbf16Type(MVT VT) {
-  switch (VT.SimpleTy) {
-  default:
-return false;
-  case MVT::f16:
-  case MVT::bf16:
-return true;
-  }
+  return (VT.SimpleTy == MVT::f16 || VT.SimpleTy == MVT::bf16);
 }
 
 /// ComputePTXValueVTs - For the given Type \p Ty, returns the set of primitive
@@ -624,9 +612,6 @@
   for (const auto  : {ISD::FADD, ISD::FMUL, ISD::FSUB, ISD::FMA}) {
 setFP16OperationAction(Op, MVT::f16, Legal, Promote);
 setFP16OperationAction(Op, MVT::v2f16, Legal, Expand);
-  }
-
-  for (const auto  : {ISD::FADD, ISD::FMUL, ISD::FSUB, ISD::FMA}) {
 setBF16OperationAction(Op, MVT::bf16, Legal, Promote);
 setBF16OperationAction(Op, MVT::v2bf16, Legal, Expand);
   }
@@ -693,20 +678,18 @@
   };
   for (const auto  : {ISD::FMINNUM, ISD::FMAXNUM}) {
 setFP16OperationAction(Op, MVT::f16, GetMinMaxAction(Promote), Promote);
+setBF16OperationAction(Op, MVT::bf16, GetMinMaxAction(Promote), Promote);
 setOperationAction(Op, MVT::f32, Legal);
 setOperationAction(Op, MVT::f64, Legal);
 setFP16OperationAction(Op, MVT::v2f16, GetMinMaxAction(Expand), Expand);
+setBF16OperationAction(Op, MVT::v2bf16, GetMinMaxAction(Expand), Expand);
   }
   for (const auto  : {ISD::FMINIMUM, ISD::FMAXIMUM}) {
 setFP16OperationAction(Op, MVT::f16, GetMinMaxAction(Expand), Expand);
+setFP16OperationAction(Op, MVT::bf16, GetMinMaxAction(Expand), Expand);
 setOperationAction(Op, MVT::f32, GetMinMaxAction(Expand));
 setFP16OperationAction(Op, MVT::v2f16, GetMinMaxAction(Expand), Expand);
-  }
-  for (const auto  : {ISD::FMINNUM, ISD::FMAXNUM}) {
-setBF16OperationAction(Op, MVT::bf16, GetMinMaxAction(Promote), Promote);
-setBF16OperationAction(Op, MVT::v2bf16, GetMinMaxAction(Expand), Expand);
-setBF16OperationAction(Op, MVT::bf16, GetMinMaxAction(Expand), Expand);
-setBF16OperationAction(Op, MVT::v2bf16, GetMinMaxAction(Expand), Expand);
+setFP16OperationAction(Op, MVT::v2bf16, GetMinMaxAction(Expand), Expand);
   }
 
   // No FEXP2, FLOG2.  The PTX ex2 and log2 functions are always approximate.
Index: llvm/lib/Target/NVPTX/NVPTXISelDAGToDAG.cpp
===
--- llvm/lib/Target/NVPTX/NVPTXISelDAGToDAG.cpp
+++ llvm/lib/Target/NVPTX/NVPTXISelDAGToDAG.cpp
@@ -1294,14 +1294,11 @@
 NumElts = EltVT.getVectorNumElements();
 EltVT = EltVT.getVectorElementType();
 // vectors of f16 are loaded/stored as multiples of v2f16 elements.
-if (EltVT == MVT::f16 && N->getValueType(0) == MVT::v2f16) {
-  assert(NumElts % 2 == 0 && "Vector must have even number of elements");
-  EltVT = MVT::v2f16;
-  NumElts /= 2;
-} else if (EltVT == MVT::bf16 && N->getValueType(0) == MVT::v2bf16) {
-  assert(NumElts % 2 == 0 && "Vector must have even number of elements");
-  EltVT = MVT::v2bf16;
-  NumElts /= 2;
+if ((EltVT == MVT::f16 && N->getValueType(0) == MVT::v2f16) || 
+(EltVT == MVT::bf16 && N->getValueType(0) == MVT::v2bf16)) {
+  assert(NumElts % 2 == 0 && "Vector must have even number of 
elements");
+  EltVT = N->getValueType(0);
+  NumElts /= 2;
 }
   }
 


Index: llvm/lib/Target/NVPTX/NVPTXISelLowering.cpp
===
--- llvm/lib/Target/NVPTX/NVPTXISelLowering.cpp
+++ llvm/lib/Target/NVPTX/NVPTXISelLowering.cpp
@@ -150,23 +150,11 @@
 }
 
 static bool Isv2f16Orv2bf16Type(MVT VT) {
-  switch (VT.SimpleTy) {
-  default:
-return false;
-  case MVT::v2f16:
-  case MVT::v2bf16:
-return true;
-  }
+  return (VT.SimpleTy == MVT::v2f16 || VT.SimpleTy == MVT::v2bf16);
 }
 
 static bool Isf16Orbf16Type(MVT VT) {
-  switch (VT.SimpleTy) {
-  default:
-return false;
-  case MVT::f16:
-  case MVT::bf16:
-return true;
-  }
+  return (VT.SimpleTy == MVT::f16 || VT.SimpleTy == MVT::bf16);
 }
 
 /// ComputePTXValueVTs - For the given Type \p Ty, returns the set of primitive
@@ -624,9 +612,6 @@
   for (const auto  : {ISD::FADD, ISD::FMUL, ISD::FSUB, ISD::FMA}) {
 setFP16OperationAction(Op, MVT::f16, Legal, Promote);
 

[PATCH] D151587: [clang][ConstantEmitter] have tryEmitPrivateForVarInit try ConstExprEmitter fast-path first

2023-06-05 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added inline comments.



Comment at: clang/lib/CodeGen/CGExprConstant.cpp:1324
 // This is a string literal initializing an array in an initializer.
-return CGM.GetConstantArrayFromStringLiteral(E);
+return E->isLValue() ?
+  CGM.GetAddrOfConstantStringFromLiteral(E).getPointer() :

efriedma wrote:
> efriedma wrote:
> > efriedma wrote:
> > > nickdesaulniers wrote:
> > > > efriedma wrote:
> > > > > nickdesaulniers wrote:
> > > > > > nickdesaulniers wrote:
> > > > > > > efriedma wrote:
> > > > > > > > nickdesaulniers wrote:
> > > > > > > > > efriedma wrote:
> > > > > > > > > > Maybe we should have a separate ConstExprEmitterLValue... 
> > > > > > > > > > trying to handle both LValues and RValues on the same 
> > > > > > > > > > codepath has been problematic in the past.  It's very easy 
> > > > > > > > > > for code to get confused what it's actually trying to emit.
> > > > > > > > > So we'd have a `ConstExprEmitterLValue` class with some 
> > > > > > > > > visitor methods, and a `ConstExprEmitterRValue` with other 
> > > > > > > > > methods implemented?
> > > > > > > > Something like that.
> > > > > > > > 
> > > > > > > > Actually thinking about it a bit more, not sure you need to 
> > > > > > > > actually implement ConstExprEmitterLValue for now.  You might 
> > > > > > > > just be able to ensure we don't ever call ConstExprEmitter with 
> > > > > > > > an lvalue.  The current ConstExprEmitter doesn't expect 
> > > > > > > > lvalues, and shouldn't call itself with lvalues.  (We bail on 
> > > > > > > > explicit LValueToRValue conversions.)  And Evaluate() shouldn't 
> > > > > > > > actually evaluate the contents of an lvalue if it isn't 
> > > > > > > > dereferenced, so there hopefully aren't any performance issues 
> > > > > > > > using that codepath.
> > > > > > > > 
> > > > > > > > In terms of implementation, I guess that's basically restoring 
> > > > > > > > the destType->isReferenceType() that got removed?  (I know I 
> > > > > > > > suggested it, but I wasn't really thinking about it...)
> > > > > > > One thing I think we may need to add to `ConstExprEmitter` is the 
> > > > > > > ability to evaluate `CallExpr`s based on certain test case 
> > > > > > > failures...does that seem right?
> > > > > > See also the calls to `constexpr f()` in 
> > > > > > clang/test/CodeGenCXX/const-init-cxx1y.cpp
> > > > > The only things I know of that Evaluate() can't handle are 
> > > > > CK_ToUnion, CK_ReinterpretMemberPointer, and 
> > > > > DesignatedInitUpdateExpr.  DesignatedInitUpdateExpr is related to the 
> > > > > failures in test/CodeGenCXX/designated-init.cpp; I don't think the 
> > > > > others show up in any of the testcases you've mentioned.  (CK_ToUnion 
> > > > > can't appear in C++ code. CK_ReinterpretMemberPointer is a 
> > > > > `reinterpret_cast` where T is a member pointer type.)
> > > > > 
> > > > > Given none of those constructs show up in const-init-cxx1y.cpp, the 
> > > > > only reason for it to fail is if we aren't correctly falling back for 
> > > > > a construct the current code doesn't know how to handle.  You 
> > > > > shouldn't need to implement any new constructs.
> > > > in clang/test/CodeGenCXX/designated-init.cpp we have:
> > > > ```
> > > > >> 22 namespace ModifyStaticTemporary { 
> > > > >>   
> > > >23   struct A { int & int x; };   
> > > >   
> > > >24   constexpr int f(int ) { r *= 9; return r - 12; }  
> > > >   
> > > >25   A a = { 6, f(a.temporary) };
> > > > ```
> > > > In the AST, that looks like:
> > > > ```
> > > > | |-VarDecl 0x562b77df39b0  col:5 used a 
> > > > 'A':'ModifyStaticTemporary::A' cinit
> > > > | | `-ExprWithCleanups 0x562b77df3c68  
> > > > 'A':'ModifyStaticTemporary::A'
> > > > | |   `-InitListExpr 0x562b77df3bb8  
> > > > 'A':'ModifyStaticTemporary::A'
> > > > | | |-MaterializeTemporaryExpr 0x562b77df3c08  'int' xvalue 
> > > > extended by Var 0x562b77df39b0 'a' 'A':'ModifyStaticTemporary::A'
> > > > | | | `-IntegerLiteral 0x562b77df3a18  'int' 6
> > > > | | `-CallExpr 0x562b77df3b30  'int'
> > > > | |   |-ImplicitCastExpr 0x562b77df3b18  'int (*)(int &)' 
> > > > 
> > > > | |   | `-DeclRefExpr 0x562b77df3ad0  'int (int &)' lvalue 
> > > > Function 0x562b77df37a0 'f' 'int (int &)'
> > > > | |   `-MemberExpr 0x562b77df3aa0  'int' lvalue 
> > > > .temporary 0x562b77df35c0
> > > > | | `-DeclRefExpr 0x562b77df3a80  
> > > > 'A':'ModifyStaticTemporary::A' lvalue Var 0x562b77df39b0 'a' 
> > > > 'A':'ModifyStaticTemporary::A'
> > > > ```
> > > > (So, indeed no `DesignatedInitUpdateExpr`) but the call to the 
> > > > `constexpr` `f()` updates the reference (to `54`).  If I remove the 
> > > > visitor for `MaterializeTemporaryExpr`, we fail to evaluate `f` and end 
> > > > up emitting `6` rather than `54`.  Doesn't that mean that the fast path 
> > > > 

[PATCH] D152164: [CUDA][HIP] Externalize device var in anonymous namespace

2023-06-05 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl marked an inline comment as done.
yaxunl added inline comments.



Comment at: clang/test/CodeGenCUDA/anon-ns.cu:46
+
+// COMMON-DAG: @[[STR1:.*]] = {{.*}} c"[[KERN1]]\00"
+// COMMON-DAG: @[[STR2:.*]] = {{.*}} c"[[KERN2]]\00"

tra wrote:
> Nit: I'd rename the patterns to reflect the names of the source entities they 
> track, so we don't have to dig through multiple dependent matches in order to 
> figure out what the test does.
> E.g. for `tempKern` : `KERN3`, `STR3` -> `TKERN`, `TKERNSTR`.
> 
> Maybe give kernels/variables more distinct names as well. My brain keeps 
> trying to interpret `temp` as `temporary`. 
> A common naming scheme would be nice. E.g. `tk`, `tv` for the template kernel 
> and variable, `a*` for anonymous entities.
> 
will do. thanks.


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

https://reviews.llvm.org/D152164

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


[PATCH] D150215: [clang][CodeGen] Break up TargetInfo.cpp [7/8]

2023-06-05 Thread Eli Friedman via Phabricator via cfe-commits
efriedma accepted this revision.
efriedma added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150215

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


[PATCH] D151833: Respect "-fdiagnostics-absolute-paths" on emit include location

2023-06-05 Thread Christopher Di Bella via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG91be60b34715: Respect 
-fdiagnostics-absolute-paths on emit include location (authored by 
charmitro, committed by cjdb).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151833

Files:
  clang/lib/Frontend/TextDiagnostic.cpp
  clang/test/Frontend/absolute-paths-import.h
  clang/test/Frontend/absolute-paths.c


Index: clang/test/Frontend/absolute-paths.c
===
--- clang/test/Frontend/absolute-paths.c
+++ clang/test/Frontend/absolute-paths.c
@@ -1,5 +1,10 @@
-// RUN: %clang_cc1 -fsyntax-only -I %S/Inputs/SystemHeaderPrefix/.. %s 2>&1 | 
FileCheck -check-prefix=NORMAL -check-prefix=CHECK %s
-// RUN: %clang_cc1 -fsyntax-only -I %S/Inputs/SystemHeaderPrefix/.. 
-fdiagnostics-absolute-paths %s 2>&1 | FileCheck -check-prefix=ABSOLUTE 
-check-prefix=CHECK %s
+// RUN: %clang_cc1 -fsyntax-only -I %S/Inputs/SystemHeaderPrefix/.. %s 2>&1 | 
FileCheck -DROOT_ABSOLUTE=%s -check-prefix=NORMAL -check-prefix=CHECK %s
+// RUN: %clang_cc1 -fsyntax-only -I %S/Inputs/SystemHeaderPrefix/.. 
-fdiagnostics-absolute-paths %s 2>&1 | FileCheck -DROOT_ABSOLUTE=%s 
-check-prefix=ABSOLUTE -check-prefix=CHECK %s
+
+#include "absolute-paths-import.h"
+// NORMAL: In file included from {{.*}}absolute-paths.c:4:
+// NORMAL-NOT: In file included from [[ROOT_ABSOLUTE]]:4:
+// ABSOLUTE: In file included from [[ROOT_ABSOLUTE]]:4:
 
 #include "absolute-paths.h"
 
Index: clang/test/Frontend/absolute-paths-import.h
===
--- /dev/null
+++ clang/test/Frontend/absolute-paths-import.h
@@ -0,0 +1 @@
+#warning abc
Index: clang/lib/Frontend/TextDiagnostic.cpp
===
--- clang/lib/Frontend/TextDiagnostic.cpp
+++ clang/lib/Frontend/TextDiagnostic.cpp
@@ -868,10 +868,11 @@
 }
 
 void TextDiagnostic::emitIncludeLocation(FullSourceLoc Loc, PresumedLoc PLoc) {
-  if (DiagOpts->ShowLocation && PLoc.isValid())
-OS << "In file included from " << PLoc.getFilename() << ':'
-   << PLoc.getLine() << ":\n";
-  else
+  if (DiagOpts->ShowLocation && PLoc.isValid()) {
+OS << "In file included from ";
+emitFilename(PLoc.getFilename(), Loc.getManager());
+OS << ':' << PLoc.getLine() << ":\n";
+  } else
 OS << "In included file:\n";
 }
 


Index: clang/test/Frontend/absolute-paths.c
===
--- clang/test/Frontend/absolute-paths.c
+++ clang/test/Frontend/absolute-paths.c
@@ -1,5 +1,10 @@
-// RUN: %clang_cc1 -fsyntax-only -I %S/Inputs/SystemHeaderPrefix/.. %s 2>&1 | FileCheck -check-prefix=NORMAL -check-prefix=CHECK %s
-// RUN: %clang_cc1 -fsyntax-only -I %S/Inputs/SystemHeaderPrefix/.. -fdiagnostics-absolute-paths %s 2>&1 | FileCheck -check-prefix=ABSOLUTE -check-prefix=CHECK %s
+// RUN: %clang_cc1 -fsyntax-only -I %S/Inputs/SystemHeaderPrefix/.. %s 2>&1 | FileCheck -DROOT_ABSOLUTE=%s -check-prefix=NORMAL -check-prefix=CHECK %s
+// RUN: %clang_cc1 -fsyntax-only -I %S/Inputs/SystemHeaderPrefix/.. -fdiagnostics-absolute-paths %s 2>&1 | FileCheck -DROOT_ABSOLUTE=%s -check-prefix=ABSOLUTE -check-prefix=CHECK %s
+
+#include "absolute-paths-import.h"
+// NORMAL: In file included from {{.*}}absolute-paths.c:4:
+// NORMAL-NOT: In file included from [[ROOT_ABSOLUTE]]:4:
+// ABSOLUTE: In file included from [[ROOT_ABSOLUTE]]:4:
 
 #include "absolute-paths.h"
 
Index: clang/test/Frontend/absolute-paths-import.h
===
--- /dev/null
+++ clang/test/Frontend/absolute-paths-import.h
@@ -0,0 +1 @@
+#warning abc
Index: clang/lib/Frontend/TextDiagnostic.cpp
===
--- clang/lib/Frontend/TextDiagnostic.cpp
+++ clang/lib/Frontend/TextDiagnostic.cpp
@@ -868,10 +868,11 @@
 }
 
 void TextDiagnostic::emitIncludeLocation(FullSourceLoc Loc, PresumedLoc PLoc) {
-  if (DiagOpts->ShowLocation && PLoc.isValid())
-OS << "In file included from " << PLoc.getFilename() << ':'
-   << PLoc.getLine() << ":\n";
-  else
+  if (DiagOpts->ShowLocation && PLoc.isValid()) {
+OS << "In file included from ";
+emitFilename(PLoc.getFilename(), Loc.getManager());
+OS << ':' << PLoc.getLine() << ":\n";
+  } else
 OS << "In included file:\n";
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D152034: [clang][NFC] refactors value type traits so we can have more than bools

2023-06-05 Thread Christopher Di Bella via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG798c5ba770d3: [clang][NFC] refactors value type traits so we 
can have more than bools (authored by cjdb).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152034

Files:
  clang/lib/Sema/SemaExprCXX.cpp


Index: clang/lib/Sema/SemaExprCXX.cpp
===
--- clang/lib/Sema/SemaExprCXX.cpp
+++ clang/lib/Sema/SemaExprCXX.cpp
@@ -5378,9 +5378,14 @@
 static bool EvaluateBinaryTypeTrait(Sema , TypeTrait BTT, QualType LhsT,
 QualType RhsT, SourceLocation KeyLoc);
 
-static bool evaluateTypeTrait(Sema , TypeTrait Kind, SourceLocation KWLoc,
-  ArrayRef Args,
-  SourceLocation RParenLoc) {
+static bool EvaluateBooleanTypeTrait(Sema , TypeTrait Kind,
+ SourceLocation KWLoc,
+ ArrayRef Args,
+ SourceLocation RParenLoc,
+ bool IsDependent) {
+  if (IsDependent)
+return false;
+
   if (Kind <= UTT_Last)
 return EvaluateUnaryTypeTrait(S, Kind, KWLoc, Args[0]->getType());
 
@@ -5548,12 +5553,19 @@
   return true;
 }
 
+enum class TypeTraitReturnType {
+  Bool,
+};
+
+static TypeTraitReturnType GetReturnType(TypeTrait Kind) {
+  return TypeTraitReturnType::Bool;
+}
+
 ExprResult Sema::BuildTypeTrait(TypeTrait Kind, SourceLocation KWLoc,
 ArrayRef Args,
 SourceLocation RParenLoc) {
   if (!CheckTypeTraitArity(getTypeTraitArity(Kind), KWLoc, Args.size()))
 return ExprError();
-  QualType ResultType = Context.getLogicalOperationType();
 
   if (Kind <= UTT_Last && !CheckUnaryTypeTraitTypeCompleteness(
*this, Kind, KWLoc, Args[0]->getType()))
@@ -5569,12 +5581,17 @@
 }
   }
 
-  bool Result = false;
-  if (!Dependent)
-Result = evaluateTypeTrait(*this, Kind, KWLoc, Args, RParenLoc);
-
-  return TypeTraitExpr::Create(Context, ResultType, KWLoc, Kind, Args,
-   RParenLoc, Result);
+  switch (GetReturnType(Kind)) {
+  case TypeTraitReturnType::Bool: {
+bool Result = EvaluateBooleanTypeTrait(*this, Kind, KWLoc, Args, RParenLoc,
+   Dependent);
+return TypeTraitExpr::Create(Context, Context.getLogicalOperationType(),
+ KWLoc, Kind, Args, RParenLoc, Result);
+  }
+  default:
+llvm_unreachable("reached the end of BuildTypeTrait because the type "
+ "trait's type is unaccounted for");
+  }
 }
 
 ExprResult Sema::ActOnTypeTrait(TypeTrait Kind, SourceLocation KWLoc,


Index: clang/lib/Sema/SemaExprCXX.cpp
===
--- clang/lib/Sema/SemaExprCXX.cpp
+++ clang/lib/Sema/SemaExprCXX.cpp
@@ -5378,9 +5378,14 @@
 static bool EvaluateBinaryTypeTrait(Sema , TypeTrait BTT, QualType LhsT,
 QualType RhsT, SourceLocation KeyLoc);
 
-static bool evaluateTypeTrait(Sema , TypeTrait Kind, SourceLocation KWLoc,
-  ArrayRef Args,
-  SourceLocation RParenLoc) {
+static bool EvaluateBooleanTypeTrait(Sema , TypeTrait Kind,
+ SourceLocation KWLoc,
+ ArrayRef Args,
+ SourceLocation RParenLoc,
+ bool IsDependent) {
+  if (IsDependent)
+return false;
+
   if (Kind <= UTT_Last)
 return EvaluateUnaryTypeTrait(S, Kind, KWLoc, Args[0]->getType());
 
@@ -5548,12 +5553,19 @@
   return true;
 }
 
+enum class TypeTraitReturnType {
+  Bool,
+};
+
+static TypeTraitReturnType GetReturnType(TypeTrait Kind) {
+  return TypeTraitReturnType::Bool;
+}
+
 ExprResult Sema::BuildTypeTrait(TypeTrait Kind, SourceLocation KWLoc,
 ArrayRef Args,
 SourceLocation RParenLoc) {
   if (!CheckTypeTraitArity(getTypeTraitArity(Kind), KWLoc, Args.size()))
 return ExprError();
-  QualType ResultType = Context.getLogicalOperationType();
 
   if (Kind <= UTT_Last && !CheckUnaryTypeTraitTypeCompleteness(
*this, Kind, KWLoc, Args[0]->getType()))
@@ -5569,12 +5581,17 @@
 }
   }
 
-  bool Result = false;
-  if (!Dependent)
-Result = evaluateTypeTrait(*this, Kind, KWLoc, Args, RParenLoc);
-
-  return TypeTraitExpr::Create(Context, ResultType, KWLoc, Kind, Args,
-   RParenLoc, Result);
+  switch (GetReturnType(Kind)) {
+  case TypeTraitReturnType::Bool: {
+bool Result = EvaluateBooleanTypeTrait(*this, Kind, KWLoc, Args, RParenLoc,
+  

[clang] 91be60b - Respect "-fdiagnostics-absolute-paths" on emit include location

2023-06-05 Thread Christopher Di Bella via cfe-commits

Author: Charalampos Mitrodimas
Date: 2023-06-05T18:07:18Z
New Revision: 91be60b34715bfe930dd1c56414c62a63cdaaa9c

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

LOG: Respect "-fdiagnostics-absolute-paths" on emit include location

This commit fixes "TextDiagnostic::emitIncludeLocation" when compiling
with "-fdiagnostics-absolute-paths" flag enabled by emitting the absolute
path of the included file.

Fixes #63026

Reviewed By: aaron.ballman

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

Added: 
clang/test/Frontend/absolute-paths-import.h

Modified: 
clang/lib/Frontend/TextDiagnostic.cpp
clang/test/Frontend/absolute-paths.c

Removed: 




diff  --git a/clang/lib/Frontend/TextDiagnostic.cpp 
b/clang/lib/Frontend/TextDiagnostic.cpp
index 01d2b10479ade..3cdf86f5c8a6e 100644
--- a/clang/lib/Frontend/TextDiagnostic.cpp
+++ b/clang/lib/Frontend/TextDiagnostic.cpp
@@ -868,10 +868,11 @@ void TextDiagnostic::emitDiagnosticLoc(FullSourceLoc Loc, 
PresumedLoc PLoc,
 }
 
 void TextDiagnostic::emitIncludeLocation(FullSourceLoc Loc, PresumedLoc PLoc) {
-  if (DiagOpts->ShowLocation && PLoc.isValid())
-OS << "In file included from " << PLoc.getFilename() << ':'
-   << PLoc.getLine() << ":\n";
-  else
+  if (DiagOpts->ShowLocation && PLoc.isValid()) {
+OS << "In file included from ";
+emitFilename(PLoc.getFilename(), Loc.getManager());
+OS << ':' << PLoc.getLine() << ":\n";
+  } else
 OS << "In included file:\n";
 }
 

diff  --git a/clang/test/Frontend/absolute-paths-import.h 
b/clang/test/Frontend/absolute-paths-import.h
new file mode 100644
index 0..e20fb3a355f72
--- /dev/null
+++ b/clang/test/Frontend/absolute-paths-import.h
@@ -0,0 +1 @@
+#warning abc

diff  --git a/clang/test/Frontend/absolute-paths.c 
b/clang/test/Frontend/absolute-paths.c
index 6192213841325..8a9687195c36b 100644
--- a/clang/test/Frontend/absolute-paths.c
+++ b/clang/test/Frontend/absolute-paths.c
@@ -1,5 +1,10 @@
-// RUN: %clang_cc1 -fsyntax-only -I %S/Inputs/SystemHeaderPrefix/.. %s 2>&1 | 
FileCheck -check-prefix=NORMAL -check-prefix=CHECK %s
-// RUN: %clang_cc1 -fsyntax-only -I %S/Inputs/SystemHeaderPrefix/.. 
-fdiagnostics-absolute-paths %s 2>&1 | FileCheck -check-prefix=ABSOLUTE 
-check-prefix=CHECK %s
+// RUN: %clang_cc1 -fsyntax-only -I %S/Inputs/SystemHeaderPrefix/.. %s 2>&1 | 
FileCheck -DROOT_ABSOLUTE=%s -check-prefix=NORMAL -check-prefix=CHECK %s
+// RUN: %clang_cc1 -fsyntax-only -I %S/Inputs/SystemHeaderPrefix/.. 
-fdiagnostics-absolute-paths %s 2>&1 | FileCheck -DROOT_ABSOLUTE=%s 
-check-prefix=ABSOLUTE -check-prefix=CHECK %s
+
+#include "absolute-paths-import.h"
+// NORMAL: In file included from {{.*}}absolute-paths.c:4:
+// NORMAL-NOT: In file included from [[ROOT_ABSOLUTE]]:4:
+// ABSOLUTE: In file included from [[ROOT_ABSOLUTE]]:4:
 
 #include "absolute-paths.h"
 



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


[clang] 798c5ba - [clang][NFC] refactors value type traits so we can have more than bools

2023-06-05 Thread Christopher Di Bella via cfe-commits

Author: Christopher Di Bella
Date: 2023-06-05T18:07:18Z
New Revision: 798c5ba770d30520a7cd6f431068ade2bda5a9f1

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

LOG: [clang][NFC] refactors value type traits so we can have more than bools

Since all the type traits up until now have had Boolean vaules, we've
always been able to assume that the expressions are `bool`. This is
about to change (D151952 introduces a trait that returns `size_t`), so
we need to restructure the code so it doesn't become unwieldy.

This is achieved by giving traits a designated "return" type.

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

Added: 


Modified: 
clang/lib/Sema/SemaExprCXX.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp
index 2bf5e6a473e30..30925c37dc08c 100644
--- a/clang/lib/Sema/SemaExprCXX.cpp
+++ b/clang/lib/Sema/SemaExprCXX.cpp
@@ -5378,9 +5378,14 @@ static bool EvaluateUnaryTypeTrait(Sema , TypeTrait 
UTT,
 static bool EvaluateBinaryTypeTrait(Sema , TypeTrait BTT, QualType LhsT,
 QualType RhsT, SourceLocation KeyLoc);
 
-static bool evaluateTypeTrait(Sema , TypeTrait Kind, SourceLocation KWLoc,
-  ArrayRef Args,
-  SourceLocation RParenLoc) {
+static bool EvaluateBooleanTypeTrait(Sema , TypeTrait Kind,
+ SourceLocation KWLoc,
+ ArrayRef Args,
+ SourceLocation RParenLoc,
+ bool IsDependent) {
+  if (IsDependent)
+return false;
+
   if (Kind <= UTT_Last)
 return EvaluateUnaryTypeTrait(S, Kind, KWLoc, Args[0]->getType());
 
@@ -5548,12 +5553,19 @@ bool Sema::CheckTypeTraitArity(unsigned Arity, 
SourceLocation Loc, size_t N) {
   return true;
 }
 
+enum class TypeTraitReturnType {
+  Bool,
+};
+
+static TypeTraitReturnType GetReturnType(TypeTrait Kind) {
+  return TypeTraitReturnType::Bool;
+}
+
 ExprResult Sema::BuildTypeTrait(TypeTrait Kind, SourceLocation KWLoc,
 ArrayRef Args,
 SourceLocation RParenLoc) {
   if (!CheckTypeTraitArity(getTypeTraitArity(Kind), KWLoc, Args.size()))
 return ExprError();
-  QualType ResultType = Context.getLogicalOperationType();
 
   if (Kind <= UTT_Last && !CheckUnaryTypeTraitTypeCompleteness(
*this, Kind, KWLoc, Args[0]->getType()))
@@ -5569,12 +5581,17 @@ ExprResult Sema::BuildTypeTrait(TypeTrait Kind, 
SourceLocation KWLoc,
 }
   }
 
-  bool Result = false;
-  if (!Dependent)
-Result = evaluateTypeTrait(*this, Kind, KWLoc, Args, RParenLoc);
-
-  return TypeTraitExpr::Create(Context, ResultType, KWLoc, Kind, Args,
-   RParenLoc, Result);
+  switch (GetReturnType(Kind)) {
+  case TypeTraitReturnType::Bool: {
+bool Result = EvaluateBooleanTypeTrait(*this, Kind, KWLoc, Args, RParenLoc,
+   Dependent);
+return TypeTraitExpr::Create(Context, Context.getLogicalOperationType(),
+ KWLoc, Kind, Args, RParenLoc, Result);
+  }
+  default:
+llvm_unreachable("reached the end of BuildTypeTrait because the type "
+ "trait's type is unaccounted for");
+  }
 }
 
 ExprResult Sema::ActOnTypeTrait(TypeTrait Kind, SourceLocation KWLoc,



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


[PATCH] D149573: [Clang][C++23] Implement core language changes from P1467R9 extended floating-point types and standard names

2023-06-05 Thread Tom Honermann via Phabricator via cfe-commits
tahonermann added a comment.

> @tahonermann Just a quick note - I've made the changes you initially 
> suggested in the RFC. When you get a chance, could you have another look?

Yes, I hope to today. If not, I'll make it a priority for tomorrow.


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

https://reviews.llvm.org/D149573

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


[clang] 65ceb42 - Replace deprecated startswith_insensitive with starts_with_insensitive

2023-06-05 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2023-06-05T11:01:27-07:00
New Revision: 65ceb42d636ea758a2c9ecdfb7473d528983a1e2

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

LOG: Replace deprecated startswith_insensitive with starts_with_insensitive

Added: 


Modified: 
clang/lib/Driver/ToolChains/MSVC.cpp
lldb/source/DataFormatters/FormatManager.cpp
lldb/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp
lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp
lldb/source/Plugins/Language/ObjCPlusPlus/ObjCPlusPlusLanguage.cpp
lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/MSVC.cpp 
b/clang/lib/Driver/ToolChains/MSVC.cpp
index 5e66bb9d1f88a..2ffe0d56835c5 100644
--- a/clang/lib/Driver/ToolChains/MSVC.cpp
+++ b/clang/lib/Driver/ToolChains/MSVC.cpp
@@ -381,7 +381,7 @@ void visualstudio::Linker::ConstructJob(Compilation , 
const JobAction ,
   // find it.
   for (const char *Cursor = EnvBlock.data(); *Cursor != '\0';) {
 llvm::StringRef EnvVar(Cursor);
-if (EnvVar.startswith_insensitive("path=")) {
+if (EnvVar.starts_with_insensitive("path=")) {
   constexpr size_t PrefixLen = 5; // strlen("path=")
   Environment.push_back(Args.MakeArgString(
   EnvVar.substr(0, PrefixLen) +

diff  --git a/lldb/source/DataFormatters/FormatManager.cpp 
b/lldb/source/DataFormatters/FormatManager.cpp
index 8387ce1121fd9..b1b5794a3efc9 100644
--- a/lldb/source/DataFormatters/FormatManager.cpp
+++ b/lldb/source/DataFormatters/FormatManager.cpp
@@ -103,7 +103,7 @@ static bool GetFormatFromFormatName(llvm::StringRef 
format_name,
   if (partial_match_ok) {
 for (i = 0; i < g_num_format_infos; ++i) {
   if (llvm::StringRef(g_format_infos[i].format_name)
-  .startswith_insensitive(format_name)) {
+  .starts_with_insensitive(format_name)) {
 format = g_format_infos[i].format;
 return true;
   }

diff  --git a/lldb/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp 
b/lldb/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp
index 7c79f2abe47e6..1a67c1676482a 100644
--- a/lldb/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp
+++ b/lldb/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp
@@ -13749,13 +13749,13 @@ bool EmulateInstructionARM::SetArchitecture(const 
ArchSpec ) {
 m_arm_isa = ARMvAll;
   else if (arch_cstr.equals_insensitive("thumb"))
 m_arm_isa = ARMvAll;
-  else if (arch_cstr.startswith_insensitive("armv4"))
+  else if (arch_cstr.starts_with_insensitive("armv4"))
 m_arm_isa = ARMv4;
-  else if (arch_cstr.startswith_insensitive("armv6"))
+  else if (arch_cstr.starts_with_insensitive("armv6"))
 m_arm_isa = ARMv6;
-  else if (arch_cstr.startswith_insensitive("armv7"))
+  else if (arch_cstr.starts_with_insensitive("armv7"))
 m_arm_isa = ARMv7;
-  else if (arch_cstr.startswith_insensitive("armv8"))
+  else if (arch_cstr.starts_with_insensitive("armv8"))
 m_arm_isa = ARMv8;
   return m_arm_isa != 0;
 }

diff  --git a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp 
b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
index 5baff9f9a61c6..3d709e3d67595 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
@@ -1465,7 +1465,7 @@ bool CPlusPlusLanguage::IsSourceFile(llvm::StringRef 
file_path) const {
   const auto suffixes = {".cpp", ".cxx", ".c++", ".cc",  ".c",
  ".h",   ".hh",  ".hpp", ".hxx", ".h++"};
   for (auto suffix : suffixes) {
-if (file_path.endswith_insensitive(suffix))
+if (file_path.ends_with_insensitive(suffix))
   return true;
   }
 

diff  --git a/lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp 
b/lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp
index 762f662d5773b..82b037129c244 100644
--- a/lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp
+++ b/lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp
@@ -1035,7 +1035,7 @@ bool ObjCLanguage::IsNilReference(ValueObject ) {
 bool ObjCLanguage::IsSourceFile(llvm::StringRef file_path) const {
   const auto suffixes = {".h", ".m", ".M"};
   for (auto suffix : suffixes) {
-if (file_path.endswith_insensitive(suffix))
+if (file_path.ends_with_insensitive(suffix))
   return true;
   }
   return false;

diff  --git 
a/lldb/source/Plugins/Language/ObjCPlusPlus/ObjCPlusPlusLanguage.cpp 
b/lldb/source/Plugins/Language/ObjCPlusPlus/ObjCPlusPlusLanguage.cpp
index 700dda3d33bb0..79830e529df2d 100644
--- a/lldb/source/Plugins/Language/ObjCPlusPlus/ObjCPlusPlusLanguage.cpp
+++ 

[PATCH] D152180: [Sema] Do not emit -Wunused-variable for variables declared with cleanup attribute

2023-06-05 Thread Nathan Chancellor 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 rG877210faa447: [Sema] Do not emit -Wunused-variable for 
variables declared with cleanup… (authored by nathanchance).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152180

Files:
  clang/lib/Sema/SemaDecl.cpp
  clang/test/Sema/warn-unused-variables.c


Index: clang/test/Sema/warn-unused-variables.c
===
--- clang/test/Sema/warn-unused-variables.c
+++ clang/test/Sema/warn-unused-variables.c
@@ -30,3 +30,8 @@
   (void)(^() { int X = 4; }); // expected-warning{{unused}}
   (void)(^() { int X = 4; return Y + X; }); // expected-error {{use of 
undeclared identifier 'Y'}}
 }
+
+void c1(int *);
+void f4(void) {
+  int __attribute__((cleanup(c1))) X1 = 4;
+}
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -1992,7 +1992,8 @@
 return false;
   }
 
-  if (D->hasAttr() || D->hasAttr())
+  if (D->hasAttr() || D->hasAttr() ||
+  D->hasAttr())
 return false;
 
   if (isa(D))


Index: clang/test/Sema/warn-unused-variables.c
===
--- clang/test/Sema/warn-unused-variables.c
+++ clang/test/Sema/warn-unused-variables.c
@@ -30,3 +30,8 @@
   (void)(^() { int X = 4; }); // expected-warning{{unused}}
   (void)(^() { int X = 4; return Y + X; }); // expected-error {{use of undeclared identifier 'Y'}}
 }
+
+void c1(int *);
+void f4(void) {
+  int __attribute__((cleanup(c1))) X1 = 4;
+}
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -1992,7 +1992,8 @@
 return false;
   }
 
-  if (D->hasAttr() || D->hasAttr())
+  if (D->hasAttr() || D->hasAttr() ||
+  D->hasAttr())
 return false;
 
   if (isa(D))
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 877210f - [Sema] Do not emit -Wunused-variable for variables declared with cleanup attribute

2023-06-05 Thread Nathan Chancellor via cfe-commits

Author: Nathan Chancellor
Date: 2023-06-05T10:54:47-07:00
New Revision: 877210faa447f4cc7db87812f8ed80e398fedd61

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

LOG: [Sema] Do not emit -Wunused-variable for variables declared with cleanup 
attribute

A variable declared with __attribute__((cleanup)) cannot be unused, as
its address is passed to the clean up function. Do not emit
-Wunused-variable for variables declared with the cleanup attribute,
which matches GCC's behavior: https://godbolt.org/z/dz5YfTsan

Reviewed By: erichkeane, nickdesaulniers

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

Added: 


Modified: 
clang/lib/Sema/SemaDecl.cpp
clang/test/Sema/warn-unused-variables.c

Removed: 




diff  --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index b8aba816283d6..12fd378fb170c 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -1992,7 +1992,8 @@ static bool ShouldDiagnoseUnusedDecl(const NamedDecl *D) {
 return false;
   }
 
-  if (D->hasAttr() || D->hasAttr())
+  if (D->hasAttr() || D->hasAttr() ||
+  D->hasAttr())
 return false;
 
   if (isa(D))

diff  --git a/clang/test/Sema/warn-unused-variables.c 
b/clang/test/Sema/warn-unused-variables.c
index d482c353f0ad1..26b18720849f9 100644
--- a/clang/test/Sema/warn-unused-variables.c
+++ b/clang/test/Sema/warn-unused-variables.c
@@ -30,3 +30,8 @@ int f3(void) {
   (void)(^() { int X = 4; }); // expected-warning{{unused}}
   (void)(^() { int X = 4; return Y + X; }); // expected-error {{use of 
undeclared identifier 'Y'}}
 }
+
+void c1(int *);
+void f4(void) {
+  int __attribute__((cleanup(c1))) X1 = 4;
+}



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


[PATCH] D132275: [clang] Create alloca to pass into static lambda

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

> EmitLambdaDelegatingInvokeBody emit an always_inline hint

To clarify, I mean on the call instruction, not on either function.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132275

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


[PATCH] D152180: [Sema] Do not emit -Wunused-variable for variables declared with cleanup attribute

2023-06-05 Thread Nathan Chancellor via Phabricator via cfe-commits
nathanchance updated this revision to Diff 528510.
nathanchance added a comment.

Change `f4()`'s return type to `void` (Nick)


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

https://reviews.llvm.org/D152180

Files:
  clang/lib/Sema/SemaDecl.cpp
  clang/test/Sema/warn-unused-variables.c


Index: clang/test/Sema/warn-unused-variables.c
===
--- clang/test/Sema/warn-unused-variables.c
+++ clang/test/Sema/warn-unused-variables.c
@@ -30,3 +30,8 @@
   (void)(^() { int X = 4; }); // expected-warning{{unused}}
   (void)(^() { int X = 4; return Y + X; }); // expected-error {{use of 
undeclared identifier 'Y'}}
 }
+
+void c1(int *);
+void f4(void) {
+  int __attribute__((cleanup(c1))) X1 = 4;
+}
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -1992,7 +1992,8 @@
 return false;
   }
 
-  if (D->hasAttr() || D->hasAttr())
+  if (D->hasAttr() || D->hasAttr() ||
+  D->hasAttr())
 return false;
 
   if (isa(D))


Index: clang/test/Sema/warn-unused-variables.c
===
--- clang/test/Sema/warn-unused-variables.c
+++ clang/test/Sema/warn-unused-variables.c
@@ -30,3 +30,8 @@
   (void)(^() { int X = 4; }); // expected-warning{{unused}}
   (void)(^() { int X = 4; return Y + X; }); // expected-error {{use of undeclared identifier 'Y'}}
 }
+
+void c1(int *);
+void f4(void) {
+  int __attribute__((cleanup(c1))) X1 = 4;
+}
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -1992,7 +1992,8 @@
 return false;
   }
 
-  if (D->hasAttr() || D->hasAttr())
+  if (D->hasAttr() || D->hasAttr() ||
+  D->hasAttr())
 return false;
 
   if (isa(D))
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D132275: [clang] Create alloca to pass into static lambda

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

Possibly the alloca doesn't get eliminated, or doesn't get eliminated early 
enough for attributor to kick in.  Not sure what context would make that 
significant, off the top of my head.

Is the lambda in question defined in an inline function (linkonce_odr)?  Maybe 
we should make EmitLambdaDelegatingInvokeBody emit an always_inline hint; it 
should be rare that a lambda is both called directly and converted to a 
function pointer.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132275

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


[PATCH] D147717: [C++20][NFC] Claim full support for consteval again

2023-06-05 Thread Nikolas Klauser via Phabricator via cfe-commits
philnik added a comment.

https://github.com/llvm/llvm-project/issues/60709 seems also pretty scary to me.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147717

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


[PATCH] D152180: [Sema] Do not emit -Wunused-variable for variables declared with cleanup attribute

2023-06-05 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers accepted this revision.
nickdesaulniers added a comment.

Thanks for the patch!




Comment at: clang/test/Sema/warn-unused-variables.c:35
+void c1(int *);
+int f4(void) {
+  int __attribute__((cleanup(c1))) X1 = 4;

`void` return type


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152180

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


[PATCH] D147717: [C++20][NFC] Claim full support for consteval again

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

Works for me


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147717

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


[PATCH] D152180: [Sema] Do not emit -Wunused-variable for variables declared with cleanup attribute

2023-06-05 Thread Nathan Chancellor via Phabricator via cfe-commits
nathanchance created this revision.
nathanchance added reviewers: aaron.ballman, nickdesaulniers, erichkeane.
Herald added a project: All.
nathanchance requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

A variable declared with `__attribute__((cleanup))` cannot be unused, as
its address is passed to the clean up function. Do not emit
`-Wunused-variable` for variables declared with the cleanup attribute,
which matches GCC's behavior: https://godbolt.org/z/dz5YfTsan


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D152180

Files:
  clang/lib/Sema/SemaDecl.cpp
  clang/test/Sema/warn-unused-variables.c


Index: clang/test/Sema/warn-unused-variables.c
===
--- clang/test/Sema/warn-unused-variables.c
+++ clang/test/Sema/warn-unused-variables.c
@@ -30,3 +30,8 @@
   (void)(^() { int X = 4; }); // expected-warning{{unused}}
   (void)(^() { int X = 4; return Y + X; }); // expected-error {{use of 
undeclared identifier 'Y'}}
 }
+
+void c1(int *);
+int f4(void) {
+  int __attribute__((cleanup(c1))) X1 = 4;
+}
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -1992,7 +1992,8 @@
 return false;
   }
 
-  if (D->hasAttr() || D->hasAttr())
+  if (D->hasAttr() || D->hasAttr() ||
+  D->hasAttr())
 return false;
 
   if (isa(D))


Index: clang/test/Sema/warn-unused-variables.c
===
--- clang/test/Sema/warn-unused-variables.c
+++ clang/test/Sema/warn-unused-variables.c
@@ -30,3 +30,8 @@
   (void)(^() { int X = 4; }); // expected-warning{{unused}}
   (void)(^() { int X = 4; return Y + X; }); // expected-error {{use of undeclared identifier 'Y'}}
 }
+
+void c1(int *);
+int f4(void) {
+  int __attribute__((cleanup(c1))) X1 = 4;
+}
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -1992,7 +1992,8 @@
 return false;
   }
 
-  if (D->hasAttr() || D->hasAttr())
+  if (D->hasAttr() || D->hasAttr() ||
+  D->hasAttr())
 return false;
 
   if (isa(D))
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D147717: [C++20][NFC] Claim full support for consteval again

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

In D147717#4396432 , @cjdb wrote:

> In D147717#4395204 , @Fznamznon 
> wrote:
>
>> In D147717#4393019 , @cor3ntin 
>> wrote:
>>
>>> I think we should make sure to land this for clang 17. The rate of 
>>> consteval bugs is no greater than that of any other feature at this point.
>>
>> There is https://github.com/llvm/llvm-project/issues/62886 which seems quite 
>> ugly, but has a patch on review.
>> Otherwise I agree, I'm not seeing more consteval bugs than any others.
>> @aaron.ballman , @erichkeane wdyt about landing it?
>
> The worst-case scenario is that we have to disable the status again. I can't 
> give an estimate on when I'll finish, so this is fine to me based on 
> available data.

I'd rather not claim support and then pull that back later (that increases 
confusion for users). That said, looking at the issues we have open for 
consteval in the issue tracker doesn't show any major issues that don't already 
have folks working on a fix for them. #62886 is the one that bothers me the 
most, but @Fznamznon already has a patch going for it that's progressing well. 
So I'm okay with landing this and claiming full support, but let's do that once 
the consteval operator bug is closed. WDYT?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147717

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


[PATCH] D151833: Respect "-fdiagnostics-absolute-paths" on emit include location

2023-06-05 Thread Christopher Di Bella via Phabricator via cfe-commits
cjdb added a comment.

I already have another commit I plan to push, will do these together :)


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

https://reviews.llvm.org/D151833

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


[PATCH] D151833: Respect "-fdiagnostics-absolute-paths" on emit include location

2023-06-05 Thread Charalampos Mitrodimas via Phabricator via cfe-commits
charmitro added a comment.

In D151833#4396008 , @charmitro wrote:

> In D151833#4395956 , @aaron.ballman 
> wrote:
>
>> Do you need someone to commit on your behalf? If so, what name and email 
>> address would you like used for patch attribution?
>
>
>
> In D151833#4395957 , @tbaeder wrote:
>
>> @charmitro do you have commit rights or do you need someone to push on your 
>> behalf?
>
> I do not have commit rights, since I'm planning to contribute more often, I'd 
> like commit access at some point. I can request it ASAP if needed.

Author should be:
Charalampos Mitrodimas 


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

https://reviews.llvm.org/D151833

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


[PATCH] D151952: [clang] adds `__type_pack_index` so we can get a type's parameter pack index

2023-06-05 Thread Christopher Di Bella via Phabricator via cfe-commits
cjdb added a comment.

In D151952#4392329 , @rsmith wrote:

> Taking a step back for a moment: what is the intended use case for this? My 
> concern is that most of the time you're going to want to make O(N) such 
> queries into a pack of N elements, resulting in O(N^2) compile time, much 
> like we regrettably get from uses of `__type_pack_element`. If we can avoid 
> the regret in this case by providing a different intrinsic, perhaps we should 
> do so. (For example, we could take two packs of types, and produce a sequence 
> of integers giving the indexes of each of the first types in the second list, 
> in O(N) time. And similarly we could add a `__type_pack_elements` that takes 
> a pack of types and a pack of indexes and performs N indexing operations at 
> once, in O(N) time, rather than having the program do it in O(N^2) time.)

When I wrote this I narrowly had `std::get(tuple)` and 
`std::get(variant)` in mind, both of which are linear in nature. Now that 
you raise this, I can see the described problem and will implement said feature 
(maybe there exists a world where `std::apply` can use this too?). Since we're 
doing this, it may also be worth checking that `T1s...` are unique in `T2s...`, 
which I'd intended to be a separate feature.

Can we get away with modifying `__type_pack_element` so that we don't need to 
introduce a new keyword, or should we have two for each?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151952

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


[PATCH] D147717: [C++20][NFC] Claim full support for consteval again

2023-06-05 Thread Christopher Di Bella via Phabricator via cfe-commits
cjdb added a comment.

In D147717#4395204 , @Fznamznon wrote:

> In D147717#4393019 , @cor3ntin 
> wrote:
>
>> I think we should make sure to land this for clang 17. The rate of consteval 
>> bugs is no greater than that of any other feature at this point.
>
> There is https://github.com/llvm/llvm-project/issues/62886 which seems quite 
> ugly, but has a patch on review.
> Otherwise I agree, I'm not seeing more consteval bugs than any others.
> @aaron.ballman , @erichkeane wdyt about landing it?

The worst-case scenario is that we have to disable the status again. I can't 
give an estimate on when I'll finish, so this is fine to me based on available 
data.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147717

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


[PATCH] D151833: Respect "-fdiagnostics-absolute-paths" on emit include location

2023-06-05 Thread Charalampos Mitrodimas via Phabricator via cfe-commits
charmitro added a comment.

In D151833#4396426 , @cjdb wrote:

> In D151833#4396399 , @charmitro 
> wrote:
>
>> In D151833#4396244 , @cjdb wrote:
>>
>>> Can the commit message have a description please? It's unclear to me why 
>>> this is necessary (although I'm sure there's a good reason).
>>
>> Thanks! Done, also check https://github.com/llvm/llvm-project/issues/63026
>
> Nice, thanks! Would you mind adding `Fixes #63026.` somewhere in the commit 
> message? That will auto-close the issue upon merge.

Thanks for pointing that, done.


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

https://reviews.llvm.org/D151833

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


[PATCH] D151833: Respect "-fdiagnostics-absolute-paths" on emit include location

2023-06-05 Thread Christopher Di Bella via Phabricator via cfe-commits
cjdb added a comment.

In D151833#4396399 , @charmitro wrote:

> In D151833#4396244 , @cjdb wrote:
>
>> Can the commit message have a description please? It's unclear to me why 
>> this is necessary (although I'm sure there's a good reason).
>
> Thanks! Done, also check https://github.com/llvm/llvm-project/issues/63026

Nice, thanks! Would you mind adding `Fixes #63026.` somewhere in the commit 
message? That will auto-close the issue upon merge.


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

https://reviews.llvm.org/D151833

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


[PATCH] D152164: [CUDA][HIP] Externalize device var in anonymous namespace

2023-06-05 Thread Artem Belevich via Phabricator via cfe-commits
tra accepted this revision.
tra added inline comments.
This revision is now accepted and ready to land.



Comment at: clang/test/CodeGenCUDA/anon-ns.cu:46
+
+// COMMON-DAG: @[[STR1:.*]] = {{.*}} c"[[KERN1]]\00"
+// COMMON-DAG: @[[STR2:.*]] = {{.*}} c"[[KERN2]]\00"

Nit: I'd rename the patterns to reflect the names of the source entities they 
track, so we don't have to dig through multiple dependent matches in order to 
figure out what the test does.
E.g. for `tempKern` : `KERN3`, `STR3` -> `TKERN`, `TKERNSTR`.

Maybe give kernels/variables more distinct names as well. My brain keeps trying 
to interpret `temp` as `temporary`. 
A common naming scheme would be nice. E.g. `tk`, `tv` for the template kernel 
and variable, `a*` for anonymous entities.



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

https://reviews.llvm.org/D152164

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


  1   2   3   >