[PATCH] D147844: [clang][Sema]Print diagnostic warning about precedence when integer expression is used without parentheses in an conditional operator expression

2023-05-10 Thread NagaChaitanya Vellanki via Phabricator via cfe-commits
chaitanyav updated this revision to Diff 521203.
chaitanyav added a comment.

Remove extra parens


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147844

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Sema/SemaExpr.cpp
  clang/test/Analysis/uninit-vals.c
  clang/test/Sema/integer-overflow.c
  clang/test/Sema/parentheses.c
  clang/test/Sema/parentheses.cpp
  clang/test/SemaCXX/array-bounds.cpp
  clang/test/SemaCXX/integer-overflow.cpp
  libcxx/include/__chrono/duration.h
  libcxx/include/strstream
  libcxx/test/libcxx/algorithms/nth_element_stability.pass.cpp
  libcxx/test/libcxx/algorithms/partial_sort_stability.pass.cpp
  libcxx/test/libcxx/algorithms/sort_stability.pass.cpp
  libcxxabi/src/cxa_personality.cpp

Index: libcxxabi/src/cxa_personality.cpp
===
--- libcxxabi/src/cxa_personality.cpp
+++ libcxxabi/src/cxa_personality.cpp
@@ -718,9 +718,7 @@
 if (actionEntry == 0)
 {
 // Found a cleanup
-results.reason = actions & _UA_SEARCH_PHASE
- ? _URC_CONTINUE_UNWIND
- : _URC_HANDLER_FOUND;
+results.reason = (actions & _UA_SEARCH_PHASE) ? _URC_CONTINUE_UNWIND : _URC_HANDLER_FOUND;
 return;
 }
 // Convert 1-based byte offset into
@@ -832,9 +830,8 @@
 // End of action list. If this is phase 2 and we have found
 // a cleanup (ttypeIndex=0), return _URC_HANDLER_FOUND;
 // otherwise return _URC_CONTINUE_UNWIND.
-results.reason = hasCleanup && actions & _UA_CLEANUP_PHASE
- ? _URC_HANDLER_FOUND
- : _URC_CONTINUE_UNWIND;
+results.reason =
+(hasCleanup && (actions & _UA_CLEANUP_PHASE)) ? _URC_HANDLER_FOUND : _URC_CONTINUE_UNWIND;
 return;
 }
 // Go to next action
@@ -1243,10 +1240,9 @@
 {
 const __shim_type_info* excpType =
 static_cast(new_exception_header->exceptionType);
-adjustedPtr =
-__getExceptionClass(_exception_header->unwindHeader) == kOurDependentExceptionClass ?
-((__cxa_dependent_exception*)new_exception_header)->primaryException :
-new_exception_header + 1;
+adjustedPtr = (__getExceptionClass(_exception_header->unwindHeader) == kOurDependentExceptionClass)
+  ? ((__cxa_dependent_exception*)new_exception_header)->primaryException
+  : new_exception_header + 1;
 if (!exception_spec_can_catch(ttypeIndex, classInfo, ttypeEncoding,
   excpType, adjustedPtr,
   unwind_exception, base))
Index: libcxx/test/libcxx/algorithms/sort_stability.pass.cpp
===
--- libcxx/test/libcxx/algorithms/sort_stability.pass.cpp
+++ libcxx/test/libcxx/algorithms/sort_stability.pass.cpp
@@ -32,7 +32,7 @@
   std::vector v;
   v.resize(kSize);
   for (int i = 0; i < kSize; ++i) {
-v[i].value = kSize / 2 - i * (i % 2 ? -1 : 1);
+v[i].value = kSize / 2 - i * ((i % 2) ? -1 : 1);
   }
   std::less comp;
   std::__sort_dispatch(v.begin(), v.end(), comp);
@@ -44,7 +44,7 @@
   std::vector v;
   v.resize(kSize);
   for (int i = 0; i < kSize; ++i) {
-v[i].value = kSize / 2 - i * (i % 2 ? -1 : 1);
+v[i].value = kSize / 2 - i * ((i % 2) ? -1 : 1);
   }
   auto deterministic_v = deterministic();
   std::sort(v.begin(), v.end());
@@ -62,7 +62,7 @@
   std::vector v;
   v.resize(kSize);
   for (int i = 0; i < kSize; ++i) {
-v[i].value = kSize / 2 - i * (i % 2 ? -1 : 1);
+v[i].value = kSize / 2 - i * ((i % 2) ? -1 : 1);
   }
   auto snapshot_v = v;
   auto snapshot_custom_v = v;
Index: libcxx/test/libcxx/algorithms/partial_sort_stability.pass.cpp
===
--- libcxx/test/libcxx/algorithms/partial_sort_stability.pass.cpp
+++ libcxx/test/libcxx/algorithms/partial_sort_stability.pass.cpp
@@ -32,7 +32,7 @@
   std::vector v;
   v.resize(kSize);
   for (int i = 0; i < kSize; ++i) {
-v[i].value = (i % 2 ? 1 : kSize / 2 + i);
+v[i].value = ((i % 2) ? 1 : kSize / 2 + i);
   }
   auto comp = std::less();
   std::__partial_sort_impl(v.begin(), v.begin() + kSize / 2, v.end(), comp);
@@ -44,7 +44,7 @@
   std::vector v;
   v.resize(kSize);
   for (int i = 0; i < kSize; ++i) {
-v[i].value = (i % 2 ? 1 : kSize / 2 + i);
+v[i].value = ((i % 2) ? 1 : kSize / 2 + i);
   }
   auto deterministic_v = deterministic();
   

[PATCH] D150013: [Clang] Respect `-L` options when compiling directly for AMDGPU

2023-05-10 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 updated this revision to Diff 521202.
jhuber6 added a comment.

Updating, @yaxunl does this look good?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150013

Files:
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/test/Driver/amdgpu-toolchain.c


Index: clang/test/Driver/amdgpu-toolchain.c
===
--- clang/test/Driver/amdgpu-toolchain.c
+++ clang/test/Driver/amdgpu-toolchain.c
@@ -11,6 +11,6 @@
 // DWARF_VER: "-dwarf-version=5"
 
 // RUN: %clang -### --target=amdgcn-amd-amdhsa -mcpu=gfx906 -nogpulib \
-// RUN:   -flto -fconvergent-functions %s 2>&1 | FileCheck -check-prefix=LTO %s
+// RUN:   -L. -flto -fconvergent-functions %s 2>&1 | FileCheck 
-check-prefix=LTO %s
 // LTO: clang{{.*}} "-flto=full"{{.*}}"-fconvergent-functions"
-// LTO: ld.lld{{.*}}-plugin-opt=mcpu=gfx906
+// LTO: ld.lld{{.*}}"-L."{{.*}}"-plugin-opt=mcpu=gfx906"
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -232,9 +232,11 @@
   Args.AddAllArgValues(CmdArgs, options::OPT_Zlinker_input);
 
   // LIBRARY_PATH are included before user inputs and only supported on native
-  // toolchains.
+  // toolchains. Otherwise only add the '-L' arguments requested by the user.
   if (!TC.isCrossCompiling())
 addDirectoryList(Args, CmdArgs, "-L", "LIBRARY_PATH");
+  else
+Args.AddAllArgs(CmdArgs, options::OPT_L);
 
   for (const auto  : Inputs) {
 // If the current tool chain refers to an OpenMP offloading host, we


Index: clang/test/Driver/amdgpu-toolchain.c
===
--- clang/test/Driver/amdgpu-toolchain.c
+++ clang/test/Driver/amdgpu-toolchain.c
@@ -11,6 +11,6 @@
 // DWARF_VER: "-dwarf-version=5"
 
 // RUN: %clang -### --target=amdgcn-amd-amdhsa -mcpu=gfx906 -nogpulib \
-// RUN:   -flto -fconvergent-functions %s 2>&1 | FileCheck -check-prefix=LTO %s
+// RUN:   -L. -flto -fconvergent-functions %s 2>&1 | FileCheck -check-prefix=LTO %s
 // LTO: clang{{.*}} "-flto=full"{{.*}}"-fconvergent-functions"
-// LTO: ld.lld{{.*}}-plugin-opt=mcpu=gfx906
+// LTO: ld.lld{{.*}}"-L."{{.*}}"-plugin-opt=mcpu=gfx906"
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -232,9 +232,11 @@
   Args.AddAllArgValues(CmdArgs, options::OPT_Zlinker_input);
 
   // LIBRARY_PATH are included before user inputs and only supported on native
-  // toolchains.
+  // toolchains. Otherwise only add the '-L' arguments requested by the user.
   if (!TC.isCrossCompiling())
 addDirectoryList(Args, CmdArgs, "-L", "LIBRARY_PATH");
+  else
+Args.AddAllArgs(CmdArgs, options::OPT_L);
 
   for (const auto  : Inputs) {
 // If the current tool chain refers to an OpenMP offloading host, we
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D148490: [AIX] use system assembler for assembly files

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



Comment at: clang/test/Driver/aix-assembler.s:23
+
+// RUN: %clang %s -### -c 2>&1 -fno-integrated-as \
+// RUN: --target=powerpc-ibm-aix7.1.0.0 \

I am not sure you need 6 RUN lines to test this. Whether a target uses 
integrated assembler has an existing test file and you can reuse that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148490

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


[PATCH] D149504: [clang][CodeGenPGO] Don't use an invalid index when region counts disagree

2023-05-10 Thread Nathan Lanza 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 rG220e77a83af1: [clang][CodeGenPGO] Dont use an invalid 
index when region counts disagree (authored by lanza).

Changed prior to commit:
  https://reviews.llvm.org/D149504?vs=518108=521200#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149504

Files:
  clang/lib/CodeGen/CodeGenPGO.h


Index: clang/lib/CodeGen/CodeGenPGO.h
===
--- clang/lib/CodeGen/CodeGenPGO.h
+++ clang/lib/CodeGen/CodeGenPGO.h
@@ -114,7 +114,12 @@
   return 0;
 if (!haveRegionCounts())
   return 0;
-return RegionCounts[(*RegionCounterMap)[S]];
+// With profiles from a differing version of clang we can have mismatched
+// decl counts. Don't crash in such a case.
+auto Index = (*RegionCounterMap)[S];
+if (Index >= RegionCounts.size())
+  return 0;
+return RegionCounts[Index];
   }
 };
 


Index: clang/lib/CodeGen/CodeGenPGO.h
===
--- clang/lib/CodeGen/CodeGenPGO.h
+++ clang/lib/CodeGen/CodeGenPGO.h
@@ -114,7 +114,12 @@
   return 0;
 if (!haveRegionCounts())
   return 0;
-return RegionCounts[(*RegionCounterMap)[S]];
+// With profiles from a differing version of clang we can have mismatched
+// decl counts. Don't crash in such a case.
+auto Index = (*RegionCounterMap)[S];
+if (Index >= RegionCounts.size())
+  return 0;
+return RegionCounts[Index];
   }
 };
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 220e77a - [clang][CodeGenPGO] Don't use an invalid index when region counts disagree

2023-05-10 Thread Nathan Lanza via cfe-commits

Author: Nathan Lanza
Date: 2023-05-10T22:53:53-04:00
New Revision: 220e77a83af19b3f6c47472596fdaaef8e305927

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

LOG: [clang][CodeGenPGO] Don't use an invalid index when region counts disagree

If we're using an old instrprof profile and the user passes we can get
Decls with children decl counts not matching the what the profile was
written against. In a particular case I was debugging we have 24 decls
in the AST and 22 decls in the profile. Avoid crashing in this case.

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

Added: 


Modified: 
clang/lib/CodeGen/CodeGenPGO.h

Removed: 




diff  --git a/clang/lib/CodeGen/CodeGenPGO.h b/clang/lib/CodeGen/CodeGenPGO.h
index 66c93cba4bb0..392ec5a144fe 100644
--- a/clang/lib/CodeGen/CodeGenPGO.h
+++ b/clang/lib/CodeGen/CodeGenPGO.h
@@ -114,7 +114,12 @@ class CodeGenPGO {
   return 0;
 if (!haveRegionCounts())
   return 0;
-return RegionCounts[(*RegionCounterMap)[S]];
+// With profiles from a 
diff ering version of clang we can have mismatched
+// decl counts. Don't crash in such a case.
+auto Index = (*RegionCounterMap)[S];
+if (Index >= RegionCounts.size())
+  return 0;
+return RegionCounts[Index];
   }
 };
 



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


[PATCH] D150340: [SEH]:Fix assertion when try is used inside catch(...) block with /EHa

2023-05-10 Thread Jennifer Yu via Phabricator via cfe-commits
jyu2 created this revision.
jyu2 added reviewers: asmith, efriedma, tentzen, pengfei.
jyu2 added a project: clang.
Herald added subscribers: kbarton, nemanjai.
Herald added a project: All.
jyu2 requested review of this revision.

Current assert wiht /EHa with
A single unwind edge may only enter one EH pad

  invoke void @llvm.seh.try.begin()
  to label %invoke.cont1 unwind label %catch.dispatch2

IR:
%1 = catchpad within %0 [ptr null, i32 0, ptr null]

  invoke void @llvm.seh.try.begin()
  to label %invoke.cont5 unwind label %catch.dispatch2

The problem is the invoke to llvm.seh.try.begin() missing "funclet"

Accodring: https://llvm.org/docs/LangRef.html#ob-funclet
If any "funclet" EH pads have been entered but not exited (per the
description in the EH doc), it is undefined behavior to execute a
call or invoke.

To fix the problem, when emit seh_try_begin,  call EmitSehScope,
instead of calling EmitRuntimeCallOrInvoke for proper "funclet"
gerenration.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D150340

Files:
  clang/lib/CodeGen/CGCleanup.cpp
  clang/lib/CodeGen/CGException.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/test/CodeGen/windows-seh-EHa-CppCatchDotDotDot.cpp

Index: clang/test/CodeGen/windows-seh-EHa-CppCatchDotDotDot.cpp
===
--- clang/test/CodeGen/windows-seh-EHa-CppCatchDotDotDot.cpp
+++ clang/test/CodeGen/windows-seh-EHa-CppCatchDotDotDot.cpp
@@ -9,11 +9,21 @@
 // CHECK: %[[dst1:[0-9-]+]] = catchpad within %[[dst]] [ptr null, i32 0, ptr null]
 // CHECK: "funclet"(token %[[dst1]])
 
+// CHECK: define dso_local void @"?bar@@YAXXZ
+// CHECK: invoke void @llvm.seh.try.begin()
+// CHECK: invoke void @_CxxThrowException
+// CHECK: %[[dst:[0-9-]+]] = catchpad within %0 [ptr null, i32 0, ptr null]
+// CHECK: invoke void @llvm.seh.try.begin() [ "funclet"(token %[[dst]]) ]
+
 // CHECK: invoke void @llvm.seh.try.begin()
 // CHECK: %[[src:[0-9-]+]] = load volatile i32, ptr %i
 // CHECK-NEXT: invoke void @"?crash@@YAXH@Z"(i32 noundef %[[src]])
 // CHECK: invoke void @llvm.seh.try.end()
 
+// CHECK: invoke void @llvm.seh.try.begin()
+// CHECK: invoke void @"?bar@@YAXXZ"()
+// CHECK: invoke void @llvm.seh.try.end()
+
 // *
 // Abstract: Test CPP catch(...) under SEH -EHa option
 
@@ -46,6 +56,18 @@
   }
 }
 
+void bar() {
+  try {
+throw 1;
+  } catch(...) {
+try {
+  *NullPtr = 0;
+} catch (...) {
+   throw 1;
+}
+  }
+}
+
 int main() {
   for (int i = 0; i < 2; i++) {
 __try {
@@ -54,5 +76,10 @@
   printf(" Test CPP unwind: in except handler i = %d \n", i);
 }
   }
+  __try {
+   bar();
+  } __except (1) {
+printf("Test CPP unwind: in except handler \n");
+  }
   return 0;
 }
Index: clang/lib/CodeGen/CodeGenFunction.h
===
--- clang/lib/CodeGen/CodeGenFunction.h
+++ clang/lib/CodeGen/CodeGenFunction.h
@@ -2933,6 +2933,7 @@
   void EmitSehCppScopeEnd();
   void EmitSehTryScopeBegin();
   void EmitSehTryScopeEnd();
+  void EmitSehScope(llvm::FunctionCallee );
 
   llvm::Value *EmitLifetimeStart(llvm::TypeSize Size, llvm::Value *Addr);
   void EmitLifetimeEnd(llvm::Value *Size, llvm::Value *Addr);
Index: clang/lib/CodeGen/CGException.cpp
===
--- clang/lib/CodeGen/CGException.cpp
+++ clang/lib/CodeGen/CGException.cpp
@@ -645,8 +645,10 @@
   CatchScope->setHandler(I, CGM.getCXXABI().getCatchAllTypeInfo(), Handler);
   // Under async exceptions, catch(...) need to catch HW exception too
   // Mark scope with SehTryBegin as a SEH __try scope
-  if (getLangOpts().EHAsynch)
-EmitRuntimeCallOrInvoke(getSehTryBeginFn(CGM));
+  if (getLangOpts().EHAsynch) {
+llvm::FunctionCallee SehCppScope = getSehTryBeginFn(CGM);
+EmitSehScope(SehCppScope);
+  }
 }
   }
 }
Index: clang/lib/CodeGen/CGCleanup.cpp
===
--- clang/lib/CodeGen/CGCleanup.cpp
+++ clang/lib/CodeGen/CGCleanup.cpp
@@ -1328,18 +1328,16 @@
 
 // Need to set "funclet" in OperandBundle properly for noThrow
 //   intrinsic (see CGCall.cpp)
-static void EmitSehScope(CodeGenFunction ,
- llvm::FunctionCallee ) {
-  llvm::BasicBlock *InvokeDest = CGF.getInvokeDest();
-  assert(CGF.Builder.GetInsertBlock() && InvokeDest);
-  llvm::BasicBlock *Cont = CGF.createBasicBlock("invoke.cont");
+void CodeGenFunction::EmitSehScope(llvm::FunctionCallee ) {
+  llvm::BasicBlock *InvokeDest = getInvokeDest();
+  assert(Builder.GetInsertBlock() && InvokeDest);
+  llvm::BasicBlock *Cont = createBasicBlock("invoke.cont");
   SmallVector BundleList =
-  CGF.getBundlesForFunclet(SehCppScope.getCallee());
-  if (CGF.CurrentFuncletPad)
-BundleList.emplace_back("funclet", 

[PATCH] D148490: [AIX] use system assembler for assembly files

2023-05-10 Thread ChenZheng via Phabricator via cfe-commits
shchenz added a comment.

gentle ping...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148490

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


[PATCH] D148506: [C++] Don't filter using declaration when we perform qualified look up

2023-05-10 Thread Chuanqi Xu 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 rG6e85d2708115: [C++] Dont filter using declaration when 
we perform qualified look up (authored by ChuanqiXu).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148506

Files:
  clang/lib/Sema/SemaDecl.cpp
  clang/test/Modules/pr62158.cppm
  clang/test/SemaCXX/pr62174.cpp

Index: clang/test/SemaCXX/pr62174.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/pr62174.cpp
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -std=c++20 %s -fsyntax-only -verify
+// expected-no-diagnostics
+namespace lib {
+namespace impl {
+template 
+inline constexpr bool test = false;
+}
+using impl::test;
+}
+
+struct foo {};
+
+template <>
+inline constexpr bool lib::test = true;
+
+static_assert(lib::test);
Index: clang/test/Modules/pr62158.cppm
===
--- /dev/null
+++ clang/test/Modules/pr62158.cppm
@@ -0,0 +1,46 @@
+// RUN: rm -rf %t
+// RUN: mkdir -p %t
+// RUN: split-file %s %t
+//
+// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/lib.cppm -o %t/lib.pcm
+// RUN: %clang_cc1 -std=c++20 %t/main.cpp -fmodule-file=lib=%t/lib.pcm \
+// RUN: -verify -fsyntax-only
+
+//--- header.h
+namespace lib::inline __1 {
+template 
+inline constexpr bool test = false;
+template 
+constexpr bool func() {
+return false;
+}
+inline constexpr bool non_templ = true;
+} // namespace lib
+
+//--- lib.cppm
+module;
+#include "header.h"
+export module lib;
+
+export namespace lib {
+using lib::test;
+using lib::func;
+using lib::non_templ;
+} // namespace lib
+
+//--- main.cpp
+// expected-no-diagnostics
+import lib;
+
+struct foo {};
+
+template <>
+inline constexpr bool lib::test = true;
+
+template <>
+constexpr bool lib::func() {
+return true;
+}
+
+static_assert(lib::test);
+static_assert(lib::func());
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -1821,17 +1821,21 @@
   return OldM == NewM;
 }
 
-static bool isUsingDecl(NamedDecl *D) {
+static bool isUsingDeclNotAtClassScope(NamedDecl *D) {
+  if (D->getDeclContext()->isFileContext())
+return false;
+
   return isa(D) ||
  isa(D) ||
  isa(D);
 }
 
-/// Removes using shadow declarations from the lookup results.
+/// Removes using shadow declarations not at class scope from the lookup
+/// results.
 static void RemoveUsingDecls(LookupResult ) {
   LookupResult::Filter F = R.makeFilter();
   while (F.hasNext())
-if (isUsingDecl(F.next()))
+if (isUsingDeclNotAtClassScope(F.next()))
   F.erase();
 
   F.done();
@@ -6378,10 +6382,6 @@
 // containing the two f's declared in X, but neither of them
 // matches.
 
-// C++ [dcl.meaning]p1:
-//   [...] the member shall not merely have been introduced by a
-//   using-declaration in the scope of the class or namespace nominated by
-//   the nested-name-specifier of the declarator-id.
 RemoveUsingDecls(Previous);
   }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 6e85d27 - [C++] Don't filter using declaration when we perform qualified look up

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

Author: Chuanqi Xu
Date: 2023-05-11T10:21:52+08:00
New Revision: 6e85d2708115bc1c7cd1bf1674b64934a3cf6c25

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

LOG: [C++] Don't filter using declaration when we perform qualified look up

Close https://github.com/llvm/llvm-project/issues/62174

And this was originally a try to close
https://github.com/llvm/llvm-project/issues/62158.

I don't feel this is the correct fix. I just think it is not bad as an
ad-hoc patch. And let's discuss things in the higher-level in the above
GitHub issue link.

Reviewed By: erichkeane

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

Added: 
clang/test/Modules/pr62158.cppm
clang/test/SemaCXX/pr62174.cpp

Modified: 
clang/lib/Sema/SemaDecl.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 4cdf2982b99d..f499a8658d73 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -1821,17 +1821,21 @@ bool Sema::IsRedefinitionInModule(const NamedDecl *New,
   return OldM == NewM;
 }
 
-static bool isUsingDecl(NamedDecl *D) {
+static bool isUsingDeclNotAtClassScope(NamedDecl *D) {
+  if (D->getDeclContext()->isFileContext())
+return false;
+
   return isa(D) ||
  isa(D) ||
  isa(D);
 }
 
-/// Removes using shadow declarations from the lookup results.
+/// Removes using shadow declarations not at class scope from the lookup
+/// results.
 static void RemoveUsingDecls(LookupResult ) {
   LookupResult::Filter F = R.makeFilter();
   while (F.hasNext())
-if (isUsingDecl(F.next()))
+if (isUsingDeclNotAtClassScope(F.next()))
   F.erase();
 
   F.done();
@@ -6378,10 +6382,6 @@ NamedDecl *Sema::HandleDeclarator(Scope *S, Declarator 
,
 // containing the two f's declared in X, but neither of them
 // matches.
 
-// C++ [dcl.meaning]p1:
-//   [...] the member shall not merely have been introduced by a
-//   using-declaration in the scope of the class or namespace nominated by
-//   the nested-name-specifier of the declarator-id.
 RemoveUsingDecls(Previous);
   }
 

diff  --git a/clang/test/Modules/pr62158.cppm b/clang/test/Modules/pr62158.cppm
new file mode 100644
index ..7a0761df7715
--- /dev/null
+++ b/clang/test/Modules/pr62158.cppm
@@ -0,0 +1,46 @@
+// RUN: rm -rf %t
+// RUN: mkdir -p %t
+// RUN: split-file %s %t
+//
+// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/lib.cppm -o %t/lib.pcm
+// RUN: %clang_cc1 -std=c++20 %t/main.cpp -fmodule-file=lib=%t/lib.pcm \
+// RUN: -verify -fsyntax-only
+
+//--- header.h
+namespace lib::inline __1 {
+template 
+inline constexpr bool test = false;
+template 
+constexpr bool func() {
+return false;
+}
+inline constexpr bool non_templ = true;
+} // namespace lib
+
+//--- lib.cppm
+module;
+#include "header.h"
+export module lib;
+
+export namespace lib {
+using lib::test;
+using lib::func;
+using lib::non_templ;
+} // namespace lib
+
+//--- main.cpp
+// expected-no-diagnostics
+import lib;
+
+struct foo {};
+
+template <>
+inline constexpr bool lib::test = true;
+
+template <>
+constexpr bool lib::func() {
+return true;
+}
+
+static_assert(lib::test);
+static_assert(lib::func());

diff  --git a/clang/test/SemaCXX/pr62174.cpp b/clang/test/SemaCXX/pr62174.cpp
new file mode 100644
index ..a5283706ec4f
--- /dev/null
+++ b/clang/test/SemaCXX/pr62174.cpp
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -std=c++20 %s -fsyntax-only -verify
+// expected-no-diagnostics
+namespace lib {
+namespace impl {
+template 
+inline constexpr bool test = false;
+}
+using impl::test;
+}
+
+struct foo {};
+
+template <>
+inline constexpr bool lib::test = true;
+
+static_assert(lib::test);



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


[PATCH] D146342: [-Wunsafe-buffer-usage] Move the whole analysis to the end of a translation unit

2023-05-10 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments.



Comment at: clang/lib/Sema/AnalysisBasedWarnings.cpp:2340
+  if (Node->doesThisDeclarationHaveABody())
+checkUnsafeBufferUsage(Node);
+  return true;

This code will grow bigger when more warnings are added, and it's quite likely 
that most warnings would want to duplicate themselves in each of the Visit 
methods. Maybe let's make a single function from which all per-function 
warnings are invoked?

Also, hmm, `UnsafeBufferUsageReporter` can probably be reused between callables.

Actually, here's an even fancier approach: maybe let's move the visitor outside 
the function so that it didn't get in the way of readability, and run warnings 
in a lambda so that we didn't need to explicitly capture anything:

```lang=c++
class CallableVisitor {
  llvm::function_ref callback;

public:
  CallableVisitor(llvm::function_ref callback):
callback(callback)
  {}

  VisitFunctionDecl(FunctionDecl *Node) {
  if (Node->doesThisDeclarationHaveABody()) {
callback(Node);
  }
  }

  // More Visit() methods.
};

void clang::sema::AnalysisBasedWarnings::IssueWarnings(const 
TranslationUnitDecl *TU) {
  // Common whole-TU safety checks go here.
  if (S.hasUncompilableErrorOccurred() || Diags.getIgnoreAllWarnings())
return;

  // Whole-TU variables for all warnings go here. Then they're implicitly 
captured,
  // so no need to list them in the constructor anymore.
  UnsafeBufferUsageReporter UnsafeBufferUsageDiags(S);
  const bool UnsafeBufferUsageEmitFixits =
  Diags.getDiagnosticOptions().ShowFixits && S.getLangOpts().CPlusPlus20;
 
  CallableVisitor([&](const Decl *Node) {
// Per-decl code for all warnings goes here.
if (!Diags.isIgnored(diag::warn_unsafe_buffer_operation, D->getBeginLoc()) 
||
!Diags.isIgnored(diag::warn_unsafe_buffer_variable, D->getBeginLoc())) {
  checkUnsafeBufferUsage(Node, UnsafeBufferUsageDiags, 
UnsafeBufferUsageEmitFixits);
}

  }).TraverseTranslationUnitDecl(TU);
}
```
I think that's a pretty neat way to organize this. This way it's immediately 
clear which code is executed how many times.



Comment at: clang/lib/Sema/AnalysisBasedWarnings.cpp:2369-2371
+  // Emit unsafe buffer usage warnings and fixits.
+  if (!Diags.isIgnored(diag::warn_unsafe_buffer_operation, SourceLocation()) ||
+  !Diags.isIgnored(diag::warn_unsafe_buffer_variable, SourceLocation())) {

Ooo interesting, there is indeed a good reason to keep those checks outside; we 
shouldn't make an entire extra pass when none of the analysis-based warnings 
are enabled.

I suggest making the comment a bit more generic, so that users felt empowered 
to add more checks there and reuse the visitor for their warnings.


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

https://reviews.llvm.org/D146342

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


[PATCH] D150326: [WPD] Update llvm.public.type.test after importing functions

2023-05-10 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks accepted this revision.
aeubanks added inline comments.
This revision is now accepted and ready to land.



Comment at: llvm/test/ThinLTO/X86/public-type-test.ll:31
 ; HIDDEN-NOT: call {{.*}}@llvm.public.type.test
 ; HIDDEN: call {{.*}}@llvm.type.test
 

should this be checked twice for both public type tests?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150326

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


[PATCH] D148506: [C++] Don't filter using declaration when we perform qualified look up

2023-05-10 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu updated this revision to Diff 521196.
ChuanqiXu added a comment.

Address comments and thank you for reviewing this!


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

https://reviews.llvm.org/D148506

Files:
  clang/lib/Sema/SemaDecl.cpp
  clang/test/Modules/pr62158.cppm
  clang/test/SemaCXX/pr62174.cpp

Index: clang/test/SemaCXX/pr62174.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/pr62174.cpp
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -std=c++20 %s -fsyntax-only -verify
+// expected-no-diagnostics
+namespace lib {
+namespace impl {
+template 
+inline constexpr bool test = false;
+}
+using impl::test;
+}
+
+struct foo {};
+
+template <>
+inline constexpr bool lib::test = true;
+
+static_assert(lib::test);
Index: clang/test/Modules/pr62158.cppm
===
--- /dev/null
+++ clang/test/Modules/pr62158.cppm
@@ -0,0 +1,46 @@
+// RUN: rm -rf %t
+// RUN: mkdir -p %t
+// RUN: split-file %s %t
+//
+// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/lib.cppm -o %t/lib.pcm
+// RUN: %clang_cc1 -std=c++20 %t/main.cpp -fmodule-file=lib=%t/lib.pcm \
+// RUN: -verify -fsyntax-only
+
+//--- header.h
+namespace lib::inline __1 {
+template 
+inline constexpr bool test = false;
+template 
+constexpr bool func() {
+return false;
+}
+inline constexpr bool non_templ = true;
+} // namespace lib
+
+//--- lib.cppm
+module;
+#include "header.h"
+export module lib;
+
+export namespace lib {
+using lib::test;
+using lib::func;
+using lib::non_templ;
+} // namespace lib
+
+//--- main.cpp
+// expected-no-diagnostics
+import lib;
+
+struct foo {};
+
+template <>
+inline constexpr bool lib::test = true;
+
+template <>
+constexpr bool lib::func() {
+return true;
+}
+
+static_assert(lib::test);
+static_assert(lib::func());
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -1821,17 +1821,21 @@
   return OldM == NewM;
 }
 
-static bool isUsingDecl(NamedDecl *D) {
+static bool isUsingDeclNotAtClassScope(NamedDecl *D) {
+  if (D->getDeclContext()->isFileContext())
+return false;
+
   return isa(D) ||
  isa(D) ||
  isa(D);
 }
 
-/// Removes using shadow declarations from the lookup results.
+/// Removes using shadow declarations not at class scope from the lookup
+/// results.
 static void RemoveUsingDecls(LookupResult ) {
   LookupResult::Filter F = R.makeFilter();
   while (F.hasNext())
-if (isUsingDecl(F.next()))
+if (isUsingDeclNotAtClassScope(F.next()))
   F.erase();
 
   F.done();
@@ -6378,10 +6382,6 @@
 // containing the two f's declared in X, but neither of them
 // matches.
 
-// C++ [dcl.meaning]p1:
-//   [...] the member shall not merely have been introduced by a
-//   using-declaration in the scope of the class or namespace nominated by
-//   the nested-name-specifier of the declarator-id.
 RemoveUsingDecls(Previous);
   }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D150181: [XCOFF][DWARF] XCOFF64 should be able to select the dwarf version under intergrated-as mode.

2023-05-10 Thread ChenZheng via Phabricator via cfe-commits
shchenz accepted this revision as: shchenz.
shchenz added a comment.
This revision is now accepted and ready to land.

I think this is correct. DWARF spec indicates that DWARF64 should not be set as 
default. So it is right to change to DWARF32 by default for integrated-as mode 
for XCOFF64.

LGTM with one nit.




Comment at: llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp:403
+  ((TT.isOSBinFormatELF() ||
+(TT.isOSBinFormatXCOFF() && UseIntegratedAs)) &&
+   (Asm->TM.Options.MCOptions.Dwarf64 || MMI->getModule()->isDwarf64())) ||

Nit: Maybe we can use a variable to contain the value for 
`TT.isOSBinFormatXCOFF()`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150181

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


[PATCH] D150338: [-Wunsafe-buffer-usage][WIP] Improving insertion of the [[clang::unsafe_buffer_usage]] attribute

2023-05-10 Thread Ziqing Luo via Phabricator via cfe-commits
ziqingluo-90 created this revision.
ziqingluo-90 added reviewers: jkorous, NoQ, malavikasamak, t-rasmud.
Herald added a subscriber: jdoerfert.
Herald added a project: All.
ziqingluo-90 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

For fix-its that insert `[[clang::unsafe_buffer_usage]]` attributes,  they will 
lookup existing macros defined for `[[clang::unsafe_buffer_usage]]` and use the 
(last defined such) macro directly.  Fix-its will use raw 
`[[clang::unsafe_buffer_usage]]` if no such macro is defined.

For example,

  // Suppose `foo` uses `p` in an unsafe way...
  
  void foo(int *p); // A fix-it will insert "[[clang::unsafe_buffer_usage]] " 
right before the declaration as there is no macro for the attribute defined here
  
  #define MACRO [[clang::unsafe_buffer_usage]]
  
  void foo(int *p); // A fix-it will insert "MACRO " right before the 
declaration

The implementation mimics how a similar machine for the  `[[fallthrough]]` 
attribute was implemented. (Mentioned here 
https://reviews.llvm.org/D143048#inline-1435398 )


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D150338

Files:
  clang/include/clang/Analysis/Analyses/UnsafeBufferUsage.h
  clang/lib/Analysis/UnsafeBufferUsage.cpp
  clang/test/SemaCXX/warn-unsafe-buffer-usage-fixits-attributes-spelling.cpp
  
clang/test/SemaCXX/warn-unsafe-buffer-usage-fixits-include-header/warn-unsafe-buffer-usage-fixits-header-exists.cpp
  
clang/test/SemaCXX/warn-unsafe-buffer-usage-fixits-include-header/warn-unsafe-buffer-usage-fixits-parm-in-header.cpp
  clang/test/SemaCXX/warn-unsafe-buffer-usage-fixits-parm-span-overload.cpp
  
clang/test/SemaCXX/warn-unsafe-buffer-usage-fixits-parm-span-qualified-names.cpp
  clang/test/SemaCXX/warn-unsafe-buffer-usage-fixits-parm-span.cpp
  clang/test/SemaCXX/warn-unsafe-buffer-usage-fixits-parm-unsupported.cpp

Index: clang/test/SemaCXX/warn-unsafe-buffer-usage-fixits-parm-unsupported.cpp
===
--- clang/test/SemaCXX/warn-unsafe-buffer-usage-fixits-parm-unsupported.cpp
+++ clang/test/SemaCXX/warn-unsafe-buffer-usage-fixits-parm-unsupported.cpp
@@ -8,7 +8,7 @@
   // FIXME: the fix-it above is incorrect
   int tmp = x[5]; // expected-note{{used in buffer access here}}
 }
-// CHECK-DAG: fix-it:{{.*}}:{[[@LINE-1]]:2-[[@LINE-1]]:2}:"\n#if __has_cpp_attribute(clang::unsafe_buffer_usage)\n{{\[}}{{\[}}clang::unsafe_buffer_usage{{\]}}{{\]}}\n#endif\nvoid const_ptr(int * const x) {return const_ptr(std::span(x, <# size #>));}\n"
+// CHECK-DAG: fix-it:{{.*}}:{[[@LINE-1]]:2-[[@LINE-1]]:2}:"\n{{\[}}{{\[}}clang::unsafe_buffer_usage{{\]}}{{\]}} void const_ptr(int * const x) {return const_ptr(std::span(x, <# size #>));}\n"
 // FIXME: the fix-it above is incorrect
 
 void const_ptr_to_const(const int * const x) {// expected-warning{{'x' is an unsafe pointer used for buffer access}} expected-note{{change type of 'x' to 'std::span' to preserve bounds information}}
@@ -16,7 +16,7 @@
   // FIXME: the fix-it above is incorrect
   int tmp = x[5]; // expected-note{{used in buffer access here}}
 }
-// CHECK-DAG: fix-it:{{.*}}:{[[@LINE-1]]:2-[[@LINE-1]]:2}:"\n#if __has_cpp_attribute(clang::unsafe_buffer_usage)\n{{\[}}{{\[}}clang::unsafe_buffer_usage{{\]}}{{\]}}\n#endif\nvoid const_ptr_to_const(const int * const x) {return const_ptr_to_const(std::span(x, <# size #>));}\n"
+// CHECK-DAG: fix-it:{{.*}}:{[[@LINE-1]]:2-[[@LINE-1]]:2}:"\n{{\[}}{{\[}}clang::unsafe_buffer_usage{{\]}}{{\]}} void const_ptr_to_const(const int * const x) {return const_ptr_to_const(std::span(x, <# size #>));}\n"
 // FIXME: the fix-it above is incorrect
 
 // We do not fix parameters participating unsafe operations for the
Index: clang/test/SemaCXX/warn-unsafe-buffer-usage-fixits-parm-span.cpp
===
--- clang/test/SemaCXX/warn-unsafe-buffer-usage-fixits-parm-span.cpp
+++ clang/test/SemaCXX/warn-unsafe-buffer-usage-fixits-parm-span.cpp
@@ -11,13 +11,13 @@
 void f();
 
 void simple(int *p);
-// CHECK-DAG: fix-it:{{.*}}:{[[@LINE-1]]:1-[[@LINE-1]]:1}:"#if __has_cpp_attribute(clang::unsafe_buffer_usage)\n{{\[}}{{\[}}clang::unsafe_buffer_usage{{\]}}{{\]}}\n#endif\n"
+// CHECK-DAG: fix-it:{{.*}}:{[[@LINE-1]]:1-[[@LINE-1]]:1}:"{{\[}}{{\[}}clang::unsafe_buffer_usage{{\]}}{{\]}} "
 // CHECK-DAG: fix-it:{{.*}}:{[[@LINE-2]]:20-[[@LINE-2]]:20}:";\nvoid simple(std::span p)"
 
 #else
 
 void simple(int *);
-// CHECK-DAG: fix-it:{{.*}}:{[[@LINE-1]]:1-[[@LINE-1]]:1}:"#if __has_cpp_attribute(clang::unsafe_buffer_usage)\n{{\[}}{{\[}}clang::unsafe_buffer_usage{{\]}}{{\]}}\n#endif\n"
+// CHECK-DAG: fix-it:{{.*}}:{[[@LINE-1]]:1-[[@LINE-1]]:1}:"{{\[}}{{\[}}clang::unsafe_buffer_usage{{\]}}{{\]}} "
 // CHECK-DAG: fix-it:{{.*}}:{[[@LINE-2]]:19-[[@LINE-2]]:19}:";\nvoid simple(std::span)"
 
 void simple(int *p) {
@@ -25,7 +25,7 @@
   int tmp;
   tmp = p[5];
 }
-// CHECK-DAG: 

[PATCH] D146342: [-Wunsafe-buffer-usage] Move the whole analysis to the end of a translation unit

2023-05-10 Thread Ziqing Luo via Phabricator via cfe-commits
ziqingluo-90 updated this revision to Diff 521184.

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

https://reviews.llvm.org/D146342

Files:
  clang/include/clang/Sema/AnalysisBasedWarnings.h
  clang/lib/Sema/AnalysisBasedWarnings.cpp
  clang/lib/Sema/Sema.cpp
  clang/test/SemaCXX/warn-unsafe-buffer-usage.cpp

Index: clang/test/SemaCXX/warn-unsafe-buffer-usage.cpp
===
--- clang/test/SemaCXX/warn-unsafe-buffer-usage.cpp
+++ clang/test/SemaCXX/warn-unsafe-buffer-usage.cpp
@@ -220,11 +220,11 @@
 void testTemplate(int * p) {
   int *a[10];
   foo(f(p, , a, a)[1]); // expected-warning{{unsafe buffer access}}
-  // expected-note@-1{{in instantiation of function template specialization 'f' requested here}}
+  // FIXME: expected note@-1{{in instantiation of function template specialization 'f' requested here}}
 
   const int **q = const_cast();
 
-  testPointerArithmetic(p, q, p); //expected-note{{in instantiation of}}
+  testPointerArithmetic(p, q, p); //FIXME: expected note{{in instantiation of}}
 }
 
 void testPointerToMember() {
@@ -315,7 +315,7 @@
   foo(ar[5]);   // expected-note{{used in buffer access here}}
 }
 
-template void fArr(int t[]); // expected-note {{in instantiation of}}
+template void fArr(int t[]); // FIXME: expected note {{in instantiation of}}
 
 int testReturn(int t[]) {
   // expected-warning@-1{{'t' is an unsafe pointer used for buffer access}}
Index: clang/lib/Sema/Sema.cpp
===
--- clang/lib/Sema/Sema.cpp
+++ clang/lib/Sema/Sema.cpp
@@ -1426,6 +1426,8 @@
 }
   }
 
+  AnalysisWarnings.IssueWarnings(Context.getTranslationUnitDecl());
+
   // Check we've noticed that we're no longer parsing the initializer for every
   // variable. If we miss cases, then at best we have a performance issue and
   // at worst a rejects-valid bug.
Index: clang/lib/Sema/AnalysisBasedWarnings.cpp
===
--- clang/lib/Sema/AnalysisBasedWarnings.cpp
+++ clang/lib/Sema/AnalysisBasedWarnings.cpp
@@ -13,6 +13,7 @@
 //===--===//
 
 #include "clang/Sema/AnalysisBasedWarnings.h"
+#include "clang/AST/Decl.h"
 #include "clang/AST/DeclCXX.h"
 #include "clang/AST/DeclObjC.h"
 #include "clang/AST/EvaluatedExprVisitor.h"
@@ -25,6 +26,8 @@
 #include "clang/AST/StmtCXX.h"
 #include "clang/AST/StmtObjC.h"
 #include "clang/AST/StmtVisitor.h"
+#include "clang/AST/RecursiveASTVisitor.h"
+#include "clang/AST/Type.h"
 #include "clang/Analysis/Analyses/CFGReachabilityAnalysis.h"
 #include "clang/Analysis/Analyses/CalledOnceCheck.h"
 #include "clang/Analysis/Analyses/Consumed.h"
@@ -35,6 +38,7 @@
 #include "clang/Analysis/AnalysisDeclContext.h"
 #include "clang/Analysis/CFG.h"
 #include "clang/Analysis/CFGStmtMap.h"
+#include "clang/Basic/Diagnostic.h"
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/Lex/Preprocessor.h"
@@ -2290,6 +2294,87 @@
 S.Diag(D.Loc, D.PD);
 }
 
+void clang::sema::AnalysisBasedWarnings::IssueWarnings(
+const TranslationUnitDecl *TU) {
+  if (!TU)
+return; // This is unexpected, give up quietly.
+
+  DiagnosticsEngine  = S.getDiagnostics();
+  // Whether -Wunsafe-buffer-usage should emit fix-its:
+  const bool UnsafeBufferEmitFixits =
+  Diags.getDiagnosticOptions().ShowFixits && S.getLangOpts().CPlusPlus20;
+
+  if (S.hasUncompilableErrorOccurred() || Diags.getIgnoreAllWarnings())
+// exit if having uncompilable errors or ignoring all warnings:
+return;
+
+  // An AST Visitor that calls analyzers on each callable definition:
+  class CallableVisitor : public RecursiveASTVisitor {
+  private:
+Sema 
+const bool UnsafeBufferEmitFixits;
+const DiagnosticsEngine 
+
+void checkUnsafeBufferUsage(Decl *Node) {
+  if (!Diags.isIgnored(diag::warn_unsafe_buffer_operation,
+   Node->getBeginLoc()) ||
+  !Diags.isIgnored(diag::warn_unsafe_buffer_variable,
+   Node->getBeginLoc())) {
+UnsafeBufferUsageReporter R(S);
+clang::checkUnsafeBufferUsage(Node, R, UnsafeBufferEmitFixits);
+  }
+}
+
+  public:
+CallableVisitor(Sema , bool EmitFixits)
+: S(S), UnsafeBufferEmitFixits(EmitFixits), Diags(S.getDiagnostics()) {}
+
+bool VisitFunctionDecl(FunctionDecl *Node) {
+  if (S.SourceMgr.isInSystemHeader(Node->getLocation()) ||
+  cast(Node)->isDependentContext())
+return true; // Not to analyze dependent decl
+  // `FunctionDecl->hasBody()` returns true if the function has a body
+  // somewhere defined.  But we want to know if this `Node` has a body
+  // child.  So we use `doesThisDeclarationHaveABody`:
+  if (Node->doesThisDeclarationHaveABody())
+checkUnsafeBufferUsage(Node);

[PATCH] D148654: Modify BoundsSan to improve debuggability

2023-05-10 Thread Oskar Wirga via Phabricator via cfe-commits
oskarwirga updated this revision to Diff 521180.
oskarwirga added a comment.

Rebase on trunk :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148654

Files:
  clang/lib/CodeGen/CGExpr.cpp
  clang/test/CodeGen/bounds-checking.c
  llvm/lib/Transforms/Instrumentation/BoundsChecking.cpp

Index: llvm/lib/Transforms/Instrumentation/BoundsChecking.cpp
===
--- llvm/lib/Transforms/Instrumentation/BoundsChecking.cpp
+++ llvm/lib/Transforms/Instrumentation/BoundsChecking.cpp
@@ -37,6 +37,10 @@
 static cl::opt SingleTrapBB("bounds-checking-single-trap",
   cl::desc("Use one trap block per function"));
 
+static cl::opt
+DebugTrapBB("bounds-checking-debug-trap",
+cl::desc("Use one trap block per check despite optimizations"));
+
 STATISTIC(ChecksAdded, "Bounds checks added");
 STATISTIC(ChecksSkipped, "Bounds checks skipped");
 STATISTIC(ChecksUnable, "Bounds checks unable to add");
@@ -180,24 +184,39 @@
   // will create a fresh block every time it is called.
   BasicBlock *TrapBB = nullptr;
   auto GetTrapBB = [](BuilderTy ) {
-if (TrapBB && SingleTrapBB)
-  return TrapBB;
-
-Function *Fn = IRB.GetInsertBlock()->getParent();
-// FIXME: This debug location doesn't make a lot of sense in the
-// `SingleTrapBB` case.
-auto DebugLoc = IRB.getCurrentDebugLocation();
-IRBuilder<>::InsertPointGuard Guard(IRB);
-TrapBB = BasicBlock::Create(Fn->getContext(), "trap", Fn);
-IRB.SetInsertPoint(TrapBB);
-
-auto *F = Intrinsic::getDeclaration(Fn->getParent(), Intrinsic::trap);
-CallInst *TrapCall = IRB.CreateCall(F, {});
-TrapCall->setDoesNotReturn();
-TrapCall->setDoesNotThrow();
-TrapCall->setDebugLoc(DebugLoc);
-IRB.CreateUnreachable();
-
+if (DebugTrapBB) {
+  Function *Fn = IRB.GetInsertBlock()->getParent();
+  auto DebugLoc = IRB.getCurrentDebugLocation();
+  IRBuilder<>::InsertPointGuard Guard(IRB);
+  TrapBB = BasicBlock::Create(Fn->getContext(), "trap", Fn);
+  IRB.SetInsertPoint(TrapBB);
+  auto *F =
+  Intrinsic::getDeclaration(Fn->getParent(), Intrinsic::ubsantrap);
+  CallInst *TrapCall =
+  IRB.CreateCall(F, ConstantInt::get(IRB.getInt8Ty(), Fn->size()));
+  TrapCall->setDoesNotReturn();
+  TrapCall->setDoesNotThrow();
+  TrapCall->setDebugLoc(DebugLoc);
+  IRB.CreateUnreachable();
+} else {
+  if (TrapBB && SingleTrapBB)
+return TrapBB;
+
+  Function *Fn = IRB.GetInsertBlock()->getParent();
+  // FIXME: This debug location doesn't make a lot of sense in the
+  // `SingleTrapBB` case.
+  auto DebugLoc = IRB.getCurrentDebugLocation();
+  IRBuilder<>::InsertPointGuard Guard(IRB);
+  TrapBB = BasicBlock::Create(Fn->getContext(), "trap", Fn);
+  IRB.SetInsertPoint(TrapBB);
+
+  auto *F = Intrinsic::getDeclaration(Fn->getParent(), Intrinsic::trap);
+  CallInst *TrapCall = IRB.CreateCall(F, {});
+  TrapCall->setDoesNotReturn();
+  TrapCall->setDoesNotThrow();
+  TrapCall->setDebugLoc(DebugLoc);
+  IRB.CreateUnreachable();
+}
 return TrapBB;
   };
 
Index: clang/test/CodeGen/bounds-checking.c
===
--- clang/test/CodeGen/bounds-checking.c
+++ clang/test/CodeGen/bounds-checking.c
@@ -1,5 +1,7 @@
 // RUN: %clang_cc1 -fsanitize=local-bounds -emit-llvm -triple x86_64-apple-darwin10 %s -o - | FileCheck %s
 // RUN: %clang_cc1 -fsanitize=array-bounds -O -fsanitize-trap=array-bounds -emit-llvm -triple x86_64-apple-darwin10 -DNO_DYNAMIC %s -o - | FileCheck %s
+// RUN: %clang_cc1 -fsanitize=local-bounds -fsanitize-trap=local-bounds -O3 -mllvm -bounds-checking-debug-trap -emit-llvm -triple x86_64-apple-darwin10 %s -o - | FileCheck %s --check-prefixes=NOOPTLOCAL
+// RUN: %clang_cc1 -fsanitize=array-bounds -fsanitize-trap=array-bounds -O3 -mllvm -sanitizer-de-opt-traps -emit-llvm -triple x86_64-apple-darwin10 %s -o - | FileCheck %s --check-prefixes=NOOPTARRAY
 //
 // REQUIRES: x86-registered-target
 
@@ -66,3 +68,16 @@
   // CHECK-NOT: @llvm.ubsantrap
   return u->c[i];
 }
+
+char B[10];
+char B2[10];
+// CHECK-LABEL: @f8
+void f8(int i, int k) {
+  // NOOPTLOCAL: call void @llvm.ubsantrap(i8 3)
+  // NOOPTARRAY: call void @llvm.ubsantrap(i8 2)
+  B[i] = '\0';
+
+  // NOOPTLOCAL: call void @llvm.ubsantrap(i8 5)
+  // NOOPTARRAY: call void @llvm.ubsantrap(i8 4)
+  B2[k] = '\0';
+}
Index: clang/lib/CodeGen/CGExpr.cpp
===
--- clang/lib/CodeGen/CGExpr.cpp
+++ clang/lib/CodeGen/CGExpr.cpp
@@ -48,6 +48,11 @@
 using namespace clang;
 using namespace CodeGen;
 
+// Experiment to make sanitizers easier to debug
+static llvm::cl::opt ClSanitizeDebugDeoptimization(
+"sanitizer-de-opt-traps", llvm::cl::Optional,
+

[PATCH] D146342: [-Wunsafe-buffer-usage] Move the whole analysis to the end of a translation unit

2023-05-10 Thread Ziqing Luo via Phabricator via cfe-commits
ziqingluo-90 updated this revision to Diff 521177.

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

https://reviews.llvm.org/D146342

Files:
  clang/include/clang/Sema/AnalysisBasedWarnings.h
  clang/lib/Sema/AnalysisBasedWarnings.cpp
  clang/lib/Sema/Sema.cpp
  clang/test/SemaCXX/warn-unsafe-buffer-usage.cpp

Index: clang/test/SemaCXX/warn-unsafe-buffer-usage.cpp
===
--- clang/test/SemaCXX/warn-unsafe-buffer-usage.cpp
+++ clang/test/SemaCXX/warn-unsafe-buffer-usage.cpp
@@ -220,11 +220,11 @@
 void testTemplate(int * p) {
   int *a[10];
   foo(f(p, , a, a)[1]); // expected-warning{{unsafe buffer access}}
-  // expected-note@-1{{in instantiation of function template specialization 'f' requested here}}
+  // FIXME: expected note@-1{{in instantiation of function template specialization 'f' requested here}}
 
   const int **q = const_cast();
 
-  testPointerArithmetic(p, q, p); //expected-note{{in instantiation of}}
+  testPointerArithmetic(p, q, p); //FIXME: expected note{{in instantiation of}}
 }
 
 void testPointerToMember() {
@@ -315,7 +315,7 @@
   foo(ar[5]);   // expected-note{{used in buffer access here}}
 }
 
-template void fArr(int t[]); // expected-note {{in instantiation of}}
+template void fArr(int t[]); // FIXME: expected note {{in instantiation of}}
 
 int testReturn(int t[]) {
   // expected-warning@-1{{'t' is an unsafe pointer used for buffer access}}
Index: clang/lib/Sema/Sema.cpp
===
--- clang/lib/Sema/Sema.cpp
+++ clang/lib/Sema/Sema.cpp
@@ -1426,6 +1426,8 @@
 }
   }
 
+  AnalysisWarnings.IssueWarnings(Context.getTranslationUnitDecl());
+
   // Check we've noticed that we're no longer parsing the initializer for every
   // variable. If we miss cases, then at best we have a performance issue and
   // at worst a rejects-valid bug.
Index: clang/lib/Sema/AnalysisBasedWarnings.cpp
===
--- clang/lib/Sema/AnalysisBasedWarnings.cpp
+++ clang/lib/Sema/AnalysisBasedWarnings.cpp
@@ -13,6 +13,7 @@
 //===--===//
 
 #include "clang/Sema/AnalysisBasedWarnings.h"
+#include "clang/AST/Decl.h"
 #include "clang/AST/DeclCXX.h"
 #include "clang/AST/DeclObjC.h"
 #include "clang/AST/EvaluatedExprVisitor.h"
@@ -25,6 +26,8 @@
 #include "clang/AST/StmtCXX.h"
 #include "clang/AST/StmtObjC.h"
 #include "clang/AST/StmtVisitor.h"
+#include "clang/AST/RecursiveASTVisitor.h"
+#include "clang/AST/Type.h"
 #include "clang/Analysis/Analyses/CFGReachabilityAnalysis.h"
 #include "clang/Analysis/Analyses/CalledOnceCheck.h"
 #include "clang/Analysis/Analyses/Consumed.h"
@@ -35,6 +38,7 @@
 #include "clang/Analysis/AnalysisDeclContext.h"
 #include "clang/Analysis/CFG.h"
 #include "clang/Analysis/CFGStmtMap.h"
+#include "clang/Basic/Diagnostic.h"
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/Lex/Preprocessor.h"
@@ -2290,6 +2294,87 @@
 S.Diag(D.Loc, D.PD);
 }
 
+void clang::sema::AnalysisBasedWarnings::IssueWarnings(
+const TranslationUnitDecl *TU) {
+  if (!TU)
+return; // This is unexpected, give up quietly.
+
+  DiagnosticsEngine  = S.getDiagnostics();
+  // Whether -Wunsafe-buffer-usage should emit fix-its:
+  const bool UnsafeBufferEmitFixits =
+  Diags.getDiagnosticOptions().ShowFixits && S.getLangOpts().CPlusPlus20;
+
+  if (S.hasUncompilableErrorOccurred() || Diags.getIgnoreAllWarnings())
+// exit if having uncompilable errors or ignoring all warnings:
+return;
+
+  // An AST Visitor that calls analyzers on each callable definition:
+  class CallableVisitor : public RecursiveASTVisitor {
+  private:
+Sema 
+const bool UnsafeBufferEmitFixits;
+const DiagnosticsEngine 
+
+void checkUnsafeBufferUsage(Decl *Node) {
+  if (!Diags.isIgnored(diag::warn_unsafe_buffer_operation,
+   Node->getBeginLoc()) ||
+  !Diags.isIgnored(diag::warn_unsafe_buffer_variable,
+   Node->getBeginLoc())) {
+UnsafeBufferUsageReporter R(S);
+clang::checkUnsafeBufferUsage(Node, R, UnsafeBufferEmitFixits);
+  }
+}
+
+  public:
+CallableVisitor(Sema , bool EmitFixits)
+: S(S), UnsafeBufferEmitFixits(EmitFixits), Diags(S.getDiagnostics()) {}
+
+bool VisitFunctionDecl(FunctionDecl *Node) {
+  if (S.SourceMgr.isInSystemHeader(Node->getLocation()) ||
+  cast(Node)->isDependentContext())
+return true; // Not to analyze dependent decl
+  // `FunctionDecl->hasBody()` returns true if the function has a body
+  // somewhere defined.  But we want to know if this `Node` has a body
+  // child.  So we use `doesThisDeclarationHaveABody`:
+  if (Node->doesThisDeclarationHaveABody())
+checkUnsafeBufferUsage(Node);

[PATCH] D146342: [-Wunsafe-buffer-usage] Move the whole analysis to the end of a translation unit

2023-05-10 Thread Ziqing Luo via Phabricator via cfe-commits
ziqingluo-90 updated this revision to Diff 521176.
ziqingluo-90 added a comment.

Clean up the code for early return in case of ignoring `unsafe_buffer_usage` 
warnings.


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

https://reviews.llvm.org/D146342

Files:
  clang/include/clang/Sema/AnalysisBasedWarnings.h
  clang/lib/Sema/AnalysisBasedWarnings.cpp
  clang/lib/Sema/Sema.cpp
  clang/test/SemaCXX/warn-unsafe-buffer-usage.cpp

Index: clang/test/SemaCXX/warn-unsafe-buffer-usage.cpp
===
--- clang/test/SemaCXX/warn-unsafe-buffer-usage.cpp
+++ clang/test/SemaCXX/warn-unsafe-buffer-usage.cpp
@@ -220,11 +220,11 @@
 void testTemplate(int * p) {
   int *a[10];
   foo(f(p, , a, a)[1]); // expected-warning{{unsafe buffer access}}
-  // expected-note@-1{{in instantiation of function template specialization 'f' requested here}}
+  // FIXME: expected note@-1{{in instantiation of function template specialization 'f' requested here}}
 
   const int **q = const_cast();
 
-  testPointerArithmetic(p, q, p); //expected-note{{in instantiation of}}
+  testPointerArithmetic(p, q, p); //FIXME: expected note{{in instantiation of}}
 }
 
 void testPointerToMember() {
@@ -315,7 +315,7 @@
   foo(ar[5]);   // expected-note{{used in buffer access here}}
 }
 
-template void fArr(int t[]); // expected-note {{in instantiation of}}
+template void fArr(int t[]); // FIXME: expected note {{in instantiation of}}
 
 int testReturn(int t[]) {
   // expected-warning@-1{{'t' is an unsafe pointer used for buffer access}}
Index: clang/lib/Sema/Sema.cpp
===
--- clang/lib/Sema/Sema.cpp
+++ clang/lib/Sema/Sema.cpp
@@ -1426,6 +1426,8 @@
 }
   }
 
+  AnalysisWarnings.IssueWarnings(Context.getTranslationUnitDecl());
+
   // Check we've noticed that we're no longer parsing the initializer for every
   // variable. If we miss cases, then at best we have a performance issue and
   // at worst a rejects-valid bug.
Index: clang/lib/Sema/AnalysisBasedWarnings.cpp
===
--- clang/lib/Sema/AnalysisBasedWarnings.cpp
+++ clang/lib/Sema/AnalysisBasedWarnings.cpp
@@ -13,6 +13,7 @@
 //===--===//
 
 #include "clang/Sema/AnalysisBasedWarnings.h"
+#include "clang/AST/Decl.h"
 #include "clang/AST/DeclCXX.h"
 #include "clang/AST/DeclObjC.h"
 #include "clang/AST/EvaluatedExprVisitor.h"
@@ -25,6 +26,8 @@
 #include "clang/AST/StmtCXX.h"
 #include "clang/AST/StmtObjC.h"
 #include "clang/AST/StmtVisitor.h"
+#include "clang/AST/RecursiveASTVisitor.h"
+#include "clang/AST/Type.h"
 #include "clang/Analysis/Analyses/CFGReachabilityAnalysis.h"
 #include "clang/Analysis/Analyses/CalledOnceCheck.h"
 #include "clang/Analysis/Analyses/Consumed.h"
@@ -35,6 +38,7 @@
 #include "clang/Analysis/AnalysisDeclContext.h"
 #include "clang/Analysis/CFG.h"
 #include "clang/Analysis/CFGStmtMap.h"
+#include "clang/Basic/Diagnostic.h"
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/Lex/Preprocessor.h"
@@ -2290,6 +2294,94 @@
 S.Diag(D.Loc, D.PD);
 }
 
+void clang::sema::AnalysisBasedWarnings::IssueWarnings(
+const TranslationUnitDecl *TU) {
+  if (!TU)
+return; // This is unexpected, give up quietly.
+
+  DiagnosticsEngine  = S.getDiagnostics();
+  // Whether -Wunsafe-buffer-usage should emit fix-its:
+  const bool UnsafeBufferEmitFixits =
+  Diags.getDiagnosticOptions().ShowFixits && S.getLangOpts().CPlusPlus20;
+
+  if (S.hasUncompilableErrorOccurred() || Diags.getIgnoreAllWarnings())
+// exit if having uncompilable errors or ignoring all warnings:
+return;
+
+  // An AST Visitor that calls analyzers on each callable definition:
+  class CallableVisitor : public RecursiveASTVisitor {
+  private:
+Sema 
+const bool UnsafeBufferEmitFixits;
+const DiagnosticsEngine 
+
+void checkUnsafeBufferUsage(Decl *Node) {
+  if (!Diags.isIgnored(diag::warn_unsafe_buffer_operation,
+   Node->getBeginLoc()) ||
+  !Diags.isIgnored(diag::warn_unsafe_buffer_variable,
+   Node->getBeginLoc())) {
+UnsafeBufferUsageReporter R(S);
+clang::checkUnsafeBufferUsage(Node, R, UnsafeBufferEmitFixits);
+  }
+}
+
+  public:
+CallableVisitor(Sema , bool EmitFixits)
+: S(S), UnsafeBufferEmitFixits(EmitFixits), Diags(S.getDiagnostics()) {}
+
+bool TraverseDecl(Decl *Node) {
+  if (!Node)
+return true;
+  // Do not analyze any `Decl` if we are going to just ignore them.
+  if (S.SourceMgr.isInSystemHeader(Node->getLocation()))
+return true;
+  // Continue to traverse descendants:
+  return RecursiveASTVisitor::TraverseDecl(Node);
+}
+
+bool VisitFunctionDecl(FunctionDecl *Node) {
+  

[PATCH] D150291: [Clang] Rename internal type identifier(s) for __bf16 to BF16Ty

2023-05-10 Thread M. Zeeshan Siddiqui via Phabricator via cfe-commits
codemzs added a comment.

Thank you for pointing that out and for reviewing my code. I appreciate your 
guidance. I was following the LLVM contribution guidelines to use git 
clang-format, but I understand the importance of maintaining existing code 
styles that may be altered by git-clang format. I will be more mindful of this 
in the future. I have reverted the style changes and updated the patch as per 
your feedback.


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

https://reviews.llvm.org/D150291

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


[PATCH] D150291: [Clang] Rename internal type identifier(s) for __bf16 to BF16Ty

2023-05-10 Thread M. Zeeshan Siddiqui via Phabricator via cfe-commits
codemzs updated this revision to Diff 521163.
codemzs marked 4 inline comments as done.
codemzs retitled this revision from "[Clang] Rename internal type identifier(s) 
for `__bf16` to `BF16Ty`" to "[Clang] Rename internal type identifier(s) for 
__bf16 to BF16Ty".
codemzs added a comment.

PR feedback: Revert style changes.


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

https://reviews.llvm.org/D150291

Files:
  clang/include/clang-c/Index.h
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/BuiltinTypes.def
  clang/include/clang/AST/Type.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/Specifiers.h
  clang/include/clang/Basic/TargetInfo.h
  clang/include/clang/Basic/arm_neon_incl.td
  clang/include/clang/Sema/DeclSpec.h
  clang/include/clang/Serialization/ASTBitCodes.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/MicrosoftMangle.cpp
  clang/lib/AST/NSAPI.cpp
  clang/lib/AST/PrintfFormatString.cpp
  clang/lib/AST/Type.cpp
  clang/lib/AST/TypeLoc.cpp
  clang/lib/Basic/TargetInfo.cpp
  clang/lib/Basic/Targets/AArch64.cpp
  clang/lib/Basic/Targets/AArch64.h
  clang/lib/Basic/Targets/AMDGPU.cpp
  clang/lib/Basic/Targets/AMDGPU.h
  clang/lib/Basic/Targets/ARM.cpp
  clang/lib/Basic/Targets/ARM.h
  clang/lib/Basic/Targets/NVPTX.cpp
  clang/lib/Basic/Targets/NVPTX.h
  clang/lib/Basic/Targets/X86.cpp
  clang/lib/Basic/Targets/X86.h
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/CodeGenTypes.cpp
  clang/lib/CodeGen/ItaniumCXXABI.cpp
  clang/lib/CodeGen/TargetInfo.cpp
  clang/lib/Index/USRGeneration.cpp
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/ParseExprCXX.cpp
  clang/lib/Sema/DeclSpec.cpp
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaCast.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaTemplateVariadic.cpp
  clang/lib/Sema/SemaType.cpp
  clang/lib/Serialization/ASTCommon.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/tools/libclang/CXType.cpp
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp

Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -4909,7 +4909,7 @@
 case clang::BuiltinType::Float128:
 case clang::BuiltinType::Double:
 case clang::BuiltinType::LongDouble:
-case clang::BuiltinType::BFloat16:
+case clang::BuiltinType::BF16:
 case clang::BuiltinType::Ibm128:
   return lldb::eEncodingIEEE754;
 
Index: clang/tools/libclang/CXType.cpp
===
--- clang/tools/libclang/CXType.cpp
+++ clang/tools/libclang/CXType.cpp
@@ -618,7 +618,7 @@
 TKIND(Pipe);
 TKIND(Attributed);
 TKIND(BTFTagAttributed);
-TKIND(BFloat16);
+TKIND(BF16);
 #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) TKIND(Id);
 #include "clang/Basic/OpenCLImageTypes.def"
 #undef IMAGE_TYPE
Index: clang/lib/Serialization/ASTReader.cpp
===
--- clang/lib/Serialization/ASTReader.cpp
+++ clang/lib/Serialization/ASTReader.cpp
@@ -7024,8 +7024,8 @@
 case PREDEF_TYPE_INT128_ID:
   T = Context.Int128Ty;
   break;
-case PREDEF_TYPE_BFLOAT16_ID:
-  T = Context.BFloat16Ty;
+case PREDEF_TYPE_BF16_ID:
+  T = Context.BF16Ty;
   break;
 case PREDEF_TYPE_HALF_ID:
   T = Context.HalfTy;
Index: clang/lib/Serialization/ASTCommon.cpp
===
--- clang/lib/Serialization/ASTCommon.cpp
+++ clang/lib/Serialization/ASTCommon.cpp
@@ -270,8 +270,8 @@
   case BuiltinType::OMPIterator:
 ID = PREDEF_TYPE_OMP_ITERATOR;
 break;
-  case BuiltinType::BFloat16:
-ID = PREDEF_TYPE_BFLOAT16_ID;
+  case BuiltinType::BF16:
+ID = PREDEF_TYPE_BF16_ID;
 break;
   }
 
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -1518,12 +1518,12 @@
 Result = Context.Float16Ty;
 break;
   case DeclSpec::TST_half:Result = Context.HalfTy; break;
-  case DeclSpec::TST_BFloat16:
-if (!S.Context.getTargetInfo().hasBFloat16Type() &&
+  case DeclSpec::TST_BF16:
+if (!S.Context.getTargetInfo().hasBF16Type() &&
 !(S.getLangOpts().OpenMP && S.getLangOpts().OpenMPIsDevice) &&
 !S.getLangOpts().SYCLIsDevice)
   S.Diag(DS.getTypeSpecTypeLoc(), diag::err_type_unsupported) << "__bf16";
-Result = Context.BFloat16Ty;
+Result = Context.BF16Ty;
 break;
   case DeclSpec::TST_float:   Result = Context.FloatTy; break;
   case DeclSpec::TST_double:
@@ -8133,7 +8133,7 @@
  BTy->getKind() == BuiltinType::ULongLong 

[PATCH] D150325: WIP: Prototype #ifdef-enforced DEPENDS on tablegen output

2023-05-10 Thread Jon Roelofs via Phabricator via cfe-commits
jroelofs added a comment.

link back to the discourse thread: 
https://discourse.llvm.org/t/rfc-permanently-fixing-the-missing-tablegen-dependency-issue/70442/14?u=jroelofs


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150325

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


[PATCH] D150326: [WPD] Update llvm.public.type.test after importing functions

2023-05-10 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson created this revision.
tejohnson added a reviewer: aeubanks.
Herald added subscribers: ormris, steven_wu, hiraditya, emaste.
Herald added a project: All.
tejohnson requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay.
Herald added projects: clang, LLVM.

I noticed that we are converting llvm.public.type.test to regular
llvm.type.test too early, and thus not updating those in imported
functions. This would result in losing out on WPD opportunities. Move
the update to after function importing, and improve test to cover this
case.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D150326

Files:
  clang/test/CodeGenCXX/thinlto_public_type_test_distributed.ll
  lld/test/ELF/lto/update_public_type_test.ll
  llvm/lib/LTO/LTOBackend.cpp
  llvm/lib/LTO/ThinLTOCodeGenerator.cpp
  llvm/test/ThinLTO/X86/devirt_vcall_vis_public.ll
  llvm/test/ThinLTO/X86/public-type-test.ll

Index: llvm/test/ThinLTO/X86/public-type-test.ll
===
--- llvm/test/ThinLTO/X86/public-type-test.ll
+++ llvm/test/ThinLTO/X86/public-type-test.ll
@@ -1,16 +1,36 @@
-; Test to ensure that the legacy LTO API lowers @llvm.public.type.test.
+; Test to ensure that the LTO API (legacy and new) lowers @llvm.public.type.test.
 
-; RUN: opt -module-summary %s -o %t.bc
-; RUN: llvm-lto --thinlto-action=run -exported-symbol=_main %t.bc --thinlto-save-temps=%t2
-; RUN: llvm-dis -o - %t20.2.internalized.bc | FileCheck %s --check-prefix=PUBLIC
-; RUN: llvm-lto --thinlto-action=run -exported-symbol=_main %t.bc --thinlto-save-temps=%t2 --whole-program-visibility
-; RUN: llvm-dis -o - %t20.2.internalized.bc | FileCheck %s --check-prefix=HIDDEN
+; RUN: split-file %s %t
+
+; RUN: opt -module-summary %t/main.ll -o %t/main.bc
+; RUN: opt -module-summary %t/foo.ll -o %t/foo.bc
+; RUN: llvm-lto --thinlto-action=run -exported-symbol=_main %t/main.bc %t/foo.bc --thinlto-save-temps=%t2.
+; RUN: llvm-dis -o - %t2.0.3.imported.bc | FileCheck %s --check-prefix=PUBLIC
+; RUN: llvm-lto --thinlto-action=run -exported-symbol=_main %t/main.bc %t/foo.bc --thinlto-save-temps=%t2. --whole-program-visibility
+; RUN: llvm-dis -o - %t2.0.3.imported.bc | FileCheck %s --check-prefix=HIDDEN
+
+; RUN: llvm-lto2 run %t/main.bc %t/foo.bc -save-temps -pass-remarks=. \
+; RUN:   -whole-program-visibility \
+; RUN:   -o %t3 \
+; RUN:   -r=%t/main.bc,_main,px \
+; RUN:   -r=%t/main.bc,_bar,px \
+; RUN:   -r=%t/main.bc,_foo, \
+; RUN:   -r=%t/foo.bc,_foo,px
+; RUN: llvm-dis %t3.1.3.import.bc -o - | FileCheck %s --check-prefix=HIDDEN
+; RUN: llvm-lto2 run %t/main.bc %t/foo.bc -save-temps -pass-remarks=. \
+; RUN:   -o %t3 \
+; RUN:   -r=%t/main.bc,_main,px \
+; RUN:   -r=%t/main.bc,_bar,px \
+; RUN:   -r=%t/main.bc,_foo, \
+; RUN:   -r=%t/foo.bc,_foo,px
+; RUN: llvm-dis %t3.1.3.import.bc -o - | FileCheck %s --check-prefix=PUBLIC
 
 ; PUBLIC-NOT: call {{.*}}@llvm.public.type.test
 ; PUBLIC-NOT: call {{.*}}@llvm.type.test
 ; HIDDEN-NOT: call {{.*}}@llvm.public.type.test
 ; HIDDEN: call {{.*}}@llvm.type.test
 
+;--- main.ll
 target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
 target triple = "x86_64-apple-macosx10.9"
 
@@ -18,8 +38,31 @@
 entry:
   %p = call i1 @llvm.public.type.test(ptr %vtable, metadata !"_ZTS1A")
   call void @llvm.assume(i1 %p)
+  call void @bar(ptr %vtable)
   ret i32 0
 }
 
+define void @bar(ptr %vtable) {
+entry:
+  call void @foo(ptr %vtable)
+  ret void
+}
+
+declare void @foo(ptr %vtable)
+
+declare void @llvm.assume(i1)
+declare i1 @llvm.public.type.test(ptr, metadata)
+
+;--- foo.ll
+target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-apple-macosx10.9"
+
+define void @foo(ptr %vtable) {
+entry:
+  %p = call i1 @llvm.public.type.test(ptr %vtable, metadata !"_ZTS1A")
+  call void @llvm.assume(i1 %p)
+  ret void
+}
+
 declare void @llvm.assume(i1)
 declare i1 @llvm.public.type.test(ptr, metadata)
Index: llvm/test/ThinLTO/X86/devirt_vcall_vis_public.ll
===
--- llvm/test/ThinLTO/X86/devirt_vcall_vis_public.ll
+++ llvm/test/ThinLTO/X86/devirt_vcall_vis_public.ll
@@ -18,7 +18,7 @@
 ; RUN:   -r=%t2.o,_ZTV1B,px \
 ; RUN:   -r=%t2.o,_ZTV1C,px \
 ; RUN:   -r=%t2.o,_ZTV1D,px 2>&1 | FileCheck %s --check-prefix=REMARK
-; RUN: llvm-dis %t3.1.0.preopt.bc -o - | FileCheck %s --check-prefix=CHECK-TT
+; RUN: llvm-dis %t3.1.3.import.bc -o - | FileCheck %s --check-prefix=CHECK-TT
 ; RUN: llvm-dis %t3.1.4.opt.bc -o - | FileCheck %s --check-prefix=CHECK-IR
 
 ; Hybrid WPD
@@ -43,7 +43,7 @@
 ; RUN:   -r=%t.o,_ZTV1B,px \
 ; RUN:   -r=%t.o,_ZTV1C,px \
 ; RUN:   -r=%t.o,_ZTV1D,px 2>&1 | FileCheck %s --check-prefix=REMARK --dump-input=fail
-; RUN: llvm-dis %t3.1.0.preopt.bc -o - | FileCheck %s --check-prefix=CHECK-TT
+; RUN: llvm-dis %t3.1.3.import.bc -o - | FileCheck %s --check-prefix=CHECK-TT
 ; RUN: llvm-dis 

[PATCH] D150325: WIP: Prototype #ifdef-enforced DEPENDS on tablegen output

2023-05-10 Thread Jon Roelofs via Phabricator via cfe-commits
jroelofs created this revision.
Herald added subscribers: steakhal, wenlei, martong, arphaman, hiraditya.
Herald added a reviewer: NoQ.
Herald added a reviewer: ributzka.
Herald added a project: All.
jroelofs requested review of this revision.
Herald added subscribers: llvm-commits, cfe-commits, MaskRay.
Herald added a reviewer: dang.
Herald added projects: clang, LLVM.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D150325

Files:
  clang/include/clang/Driver/CMakeLists.txt
  clang/lib/ARCMigrate/CMakeLists.txt
  clang/lib/Analysis/plugins/CheckerDependencyHandling/CMakeLists.txt
  clang/lib/Analysis/plugins/CheckerOptionHandling/CMakeLists.txt
  clang/lib/Analysis/plugins/SampleAnalyzer/CMakeLists.txt
  clang/lib/CodeGen/CMakeLists.txt
  clang/lib/CrossTU/CMakeLists.txt
  clang/lib/Driver/CMakeLists.txt
  clang/lib/ExtractAPI/CMakeLists.txt
  clang/lib/Frontend/Rewrite/CMakeLists.txt
  clang/lib/Index/CMakeLists.txt
  clang/lib/StaticAnalyzer/Core/CMakeLists.txt
  clang/lib/StaticAnalyzer/Frontend/CMakeLists.txt
  clang/lib/Tooling/ASTDiff/CMakeLists.txt
  clang/lib/Tooling/DumpTool/CMakeLists.txt
  clang/lib/Tooling/Refactoring/CMakeLists.txt
  clang/lib/Tooling/Syntax/CMakeLists.txt
  clang/lib/Tooling/Transformer/CMakeLists.txt
  clang/tools/arcmt-test/CMakeLists.txt
  clang/tools/c-index-test/CMakeLists.txt
  clang/tools/clang-check/CMakeLists.txt
  clang/tools/clang-diff/CMakeLists.txt
  clang/tools/clang-extdef-mapping/CMakeLists.txt
  clang/tools/clang-fuzzer/handle-cxx/CMakeLists.txt
  clang/tools/clang-import-test/CMakeLists.txt
  clang/tools/clang-offload-bundler/CMakeLists.txt
  clang/tools/clang-refactor/CMakeLists.txt
  clang/tools/clang-rename/CMakeLists.txt
  clang/tools/clang-repl/CMakeLists.txt
  clang/tools/clang-scan-deps/CMakeLists.txt
  clang/tools/diagtool/CMakeLists.txt
  clang/tools/driver/CMakeLists.txt
  llvm/cmake/modules/AddLLVM.cmake
  llvm/lib/TableGen/Main.cpp

Index: llvm/lib/TableGen/Main.cpp
===
--- llvm/lib/TableGen/Main.cpp
+++ llvm/lib/TableGen/Main.cpp
@@ -96,6 +96,16 @@
   return 0;
 }
 
+static cl::opt
+DependencyGuardName("dependency-guard=", cl::Prefix, cl::Hidden, cl::init(""));
+
+static void EmitDependencyGuard(StringRef Name, raw_ostream ) {
+  OS << "#ifndef LLVM_DEPENDS_ON_" << Name << "\n"
+ << "#  error If you're seeing this message, there is a missing DEPENDS "
+ << Name << " in the CMake target that includes this file.\n"
+ << "#endif\n";
+}
+
 int llvm::TableGenMain(const char *argv0,
std::function MainFn) {
   RecordKeeper Records;
@@ -139,6 +149,9 @@
 status = MainFn(Out, Records);
   else
 return 1;
+  if (!DependencyGuardName.empty()) {
+EmitDependencyGuard(DependencyGuardName, Out);
+  }
   Records.stopBackendTimer();
   if (status)
 return 1;
Index: llvm/cmake/modules/AddLLVM.cmake
===
--- llvm/cmake/modules/AddLLVM.cmake
+++ llvm/cmake/modules/AddLLVM.cmake
@@ -535,6 +535,10 @@
 
 set_target_properties(${obj_name} PROPERTIES FOLDER "Object Libraries")
 if(ARG_DEPENDS)
+  foreach(dependency ${ARG_DEPENDS})
+string(REPLACE "-" "_" dependency ${dependency})
+target_compile_definitions(${obj_name} PUBLIC -DLLVM_DEPENDS_ON_${dependency}=1)
+  endforeach()
   add_dependencies(${obj_name} ${ARG_DEPENDS})
 endif()
 # Treat link libraries like PUBLIC dependencies.  LINK_LIBS might
@@ -565,6 +569,12 @@
 if(ARG_OUTPUT_NAME)
   set(output_name OUTPUT_NAME "${ARG_OUTPUT_NAME}")
 endif()
+if(ARG_DEPENDS)
+  foreach(dependency ${ARG_DEPENDS})
+string(REPLACE "-" "_" dependency ${dependency})
+target_compile_definitions(${name_static} PRIVATE -DLLVM_DEPENDS_ON_${dependency}=1)
+  endforeach()
+endif()
 # DEPENDS has been appended to LLVM_COMMON_LIBS.
 llvm_add_library(${name_static} STATIC
   ${output_name}
@@ -590,6 +600,13 @@
 add_library(${name} STATIC ${ALL_FILES})
   endif()
 
+  if(ARG_DEPENDS)
+foreach(dependency ${ARG_DEPENDS})
+  string(REPLACE "-" "_" dependency ${dependency})
+  target_compile_definitions(${name} PRIVATE -DLLVM_DEPENDS_ON_${dependency}=1)
+endforeach()
+  endif()
+
   if(ARG_COMPONENT_LIB)
 set_target_properties(${name} PROPERTIES LLVM_COMPONENT TRUE)
 set_property(GLOBAL APPEND PROPERTY LLVM_COMPONENT_LIBS ${name})
@@ -950,9 +967,9 @@
   cmake_parse_arguments(ARG
 "DISABLE_LLVM_LINK_LLVM_DYLIB;IGNORE_EXTERNALIZE_DEBUGINFO;NO_INSTALL_RPATH;SUPPORT_PLUGINS"
 "ENTITLEMENTS;BUNDLE_PATH"
-""
+"DEPENDS"
 ${ARGN})
-  generate_llvm_objects(${name} ${ARG_UNPARSED_ARGUMENTS})
+  generate_llvm_objects(${name} ${ARG_UNPARSED_ARGUMENTS} DEPENDS ${ARG_DEPENDS})
   add_windows_version_resource_file(ALL_FILES ${ALL_FILES})
 
   if(XCODE)
@@ -967,6 +984,11 @@
 add_executable(${name} ${ALL_FILES})
   

[PATCH] D150291: [Clang] Rename internal type identifier(s) for `__bf16` to `BF16Ty`

2023-05-10 Thread Tom Honermann via Phabricator via cfe-commits
tahonermann requested changes to this revision.
tahonermann added a comment.
This revision now requires changes to proceed.

This looks great, thank you for doing this!

Requested changes are just to undo some of the style changes.




Comment at: clang/include/clang/Basic/Specifiers.h:82-89
+TST_class, // C++ class type
+TST_interface, // C++ (Microsoft-specific) __interface type
+TST_typename,  // Typedef, C++ class-name or enum name, etc.
 TST_typeofType,// C2x (and GNU extension) typeof(type-name)
 TST_typeofExpr,// C2x (and GNU extension) typeof(expression)
 TST_typeof_unqualType, // C2x typeof_unqual(type-name)
 TST_typeof_unqualExpr, // C2x typeof_unqual(expression)

Whitespace changes to code that is otherwise not being changed are discouraged 
due to the impact on tools like `git blame`. If you want to make such a change, 
please do so as a separate commit and add the commit to 
`.git-blame-ignore-revs`.



Comment at: clang/lib/AST/ASTContext.cpp:7075-7076
   case BuiltinType::Float128:   return Float128Rank;
-  case BuiltinType::BFloat16:   return BFloat16Rank;
+  case BuiltinType::BF16:
+return BF16Rank;
   case BuiltinType::Ibm128: return Ibm128Rank;

Please keep the same style here (I know `clang-format` might want to do 
differently; just ignore it in this case).



Comment at: clang/lib/AST/ItaniumMangle.cpp:3617-3619
+case BuiltinType::BF16:
+  EltName = "bfloat16_t";
+  break;

Likewise, please maintain consistent style here.

Thank you for *not* changing the literal! :)



Comment at: clang/lib/Sema/DeclSpec.cpp:590-591
   case DeclSpec::TST_atomic: return "_Atomic";
-  case DeclSpec::TST_BFloat16: return "__bf16";
+  case DeclSpec::TST_BF16:
+return "__bf16";
 #define GENERIC_IMAGE_TYPE(ImgType, Id) \

Please maintain consistent style here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150291

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


[PATCH] D150320: [clang][deps] Avoid relocatable modules checks

2023-05-10 Thread Ben Langmuir via Phabricator via cfe-commits
benlangmuir accepted this revision.
benlangmuir added a comment.
This revision is now accepted and ready to land.

With my naming comment addressed, LGTM




Comment at: clang/include/clang/Lex/PreprocessorOptions.h:73
+  /// Perform extra checks for relocatable modules when loading PCM files.
+  bool RelocatableModules = true;
+

Suggestion: `CheckRelocatableModules`.  The current name sounds like a compiler 
feature rather than controlling diagnostics.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150320

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


[PATCH] D150319: [clang][deps] Always use -fmodules-validate-once-per-build-session

2023-05-10 Thread Ben Langmuir via Phabricator via cfe-commits
benlangmuir added inline comments.



Comment at: 
clang/lib/Tooling/DependencyScanning/DependencyScanningService.cpp:26
+  ? BuildSessionTimestamp
+  : std::chrono::system_clock::now().time_since_epoch().count()) {
   // Initialize targets for object file support.

I'm not sure this is guaranteed to line up with the filesystem timestamps. I 
wonder if you should be writing a file and reading back that stamp instead.



Comment at: 
clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp:188
+// FIXME: Consider diagnosing when this overwrites existing timestamp.
+ScanInstance.getHeaderSearchOpts().BuildSessionTimestamp =
+Service.getBuildSessionTimestamp();

Why would it diagnose? This is going to be common.  Maybe we should use the 
minimum value between the service and the existing timestamp to get the widest 
possible session if the build system is already providing one?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150319

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


[PATCH] D150318: [clang][deps] NFC: Pass around the whole scanning service

2023-05-10 Thread Ben Langmuir via Phabricator via cfe-commits
benlangmuir added inline comments.



Comment at: 
clang/include/clang/Tooling/DependencyScanning/DependencyScanningService.h:69
+  /// The preprocessing mode used for scanning.
+  ScanningMode Mode;
+  /// The output format.

Why drop `const`?



Comment at: 
clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h:19
 #include "clang/Serialization/ASTReader.h"
+#include "clang/Tooling/DependencyScanning/DependencyScanningService.h"
 #include "llvm/ADT/DenseMap.h"

Forward declaration for the header file should be enough


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150318

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


[PATCH] D150140: [NFC][CLANG] Fix Static Code Analysis Concerns

2023-05-10 Thread Soumi Manna via Phabricator via cfe-commits
Manna marked an inline comment as done.
Manna added a comment.

In D150140#4333552 , @tahonermann 
wrote:

> Looks good to me!

Thank you @tahonermann for reviews!


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

https://reviews.llvm.org/D150140

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


[PATCH] D149718: [NFC][Clang] Fix Coverity issues of copy without assign

2023-05-10 Thread Soumi Manna via Phabricator via cfe-commits
Manna added a comment.

In D149718#4333563 , @tahonermann 
wrote:

> Looks good. Thanks @Manna!

Thank you @tahonermann for reviews!


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

https://reviews.llvm.org/D149718

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


[PATCH] D149718: [NFC][Clang] Fix Coverity issues of copy without assign

2023-05-10 Thread Tom Honermann via Phabricator via cfe-commits
tahonermann accepted this revision.
tahonermann added a comment.
This revision is now accepted and ready to land.

Looks good. Thanks @Manna!




Comment at: clang/include/clang/Sema/Sema.h:1786
 SemaDiagnosticBuilder(SemaDiagnosticBuilder &);
+SemaDiagnosticBuilder =(SemaDiagnosticBuilder &);
 SemaDiagnosticBuilder(const SemaDiagnosticBuilder &) = default;

Manna wrote:
> tahonermann wrote:
> > Manna wrote:
> > > tahonermann wrote:
> > > > Since this class declares a move constructor, the declaration of the 
> > > > implicit move assignment operator is inhibited and the implicitly 
> > > > declared assignment operator is defined as deleted. This change 
> > > > declares a move assignment operator but doesn't define it (perhaps `= 
> > > > delete` was intended?). If support for assignment is not desired, then 
> > > > I think a declaration of a deleted copy assignment operator is all that 
> > > > is needed (matching the change made for `Strategy` below). Otherwise, I 
> > > > think a defaulted copy assignment operator should be declared and a 
> > > > move assignment operator should be defined that implements the same 
> > > > behavior as the move constructor.
> > > Thanks @tahonermann for the comments. 
> > > 
> > > >> think a defaulted copy assignment operator should be declared and a 
> > > >> move assignment operator should be defined that implements the same 
> > > >> behavior as the move constructor.
> > > 
> > > I have updated patch based on further analysis and my understanding. This 
> > > seems reasonable to me.
> > This change still declares a move assignment operator, but doesn't provide 
> > a definition. The move constructor is implemented in 
> > `clang/lib/Sema/Sema.cpp`, so I would expect to see the move assignment 
> > operator definition provided there as well.
> Thanks @tahonermann for the comments. I have removed `Sema.h`  change from 
> the current patch. I will address it in a separate review pull request. Need 
> to look into this more.  
Ok, sounds good.


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

https://reviews.llvm.org/D149718

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


[PATCH] D150321: [clang] Document extensions from later standards

2023-05-10 Thread Nikolas Klauser via Phabricator via cfe-commits
philnik created this revision.
philnik added a reviewer: aaron.ballman.
Herald added a project: All.
philnik 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/D150321

Files:
  clang/docs/LanguageExtensions.rst


Index: clang/docs/LanguageExtensions.rst
===
--- clang/docs/LanguageExtensions.rst
+++ clang/docs/LanguageExtensions.rst
@@ -1370,6 +1370,38 @@
 
 More information could be found `here 
`_.
 
+Language extensions back-ported to previous standards
+=
+
+===  
= =
+Feature Feature Test Macro   
Introduced In Backported To
+===  
= =
+Conditional ``explicit``__cpp_conditional_explicit   C++20 
C++03
+``if constexpr``__cpp_if_constexpr   C++17 
C++11
+fold expressions__cpp_fold_expressions   C++17 
C++03
+Alias templates __cpp_alias_templatesC++11 
C++03
+Binary literals __cpp_binary_literalsC++14 
C++03
+Lambda capture of \*this by value   __cpp_capture_star_this  C++17 
C++11
+Relaxed constexpr   __cpp_constexpr  C++14 
C++11
+Designated initializers __cpp_designated_initializersC++20 
C++03
+Attributes on enums __cpp_enumerator_attributes  C++17 
C++11
+Guaranteed copy elision __cpp_guaranteed_copy_elisionC++17 
C++03
+``if consteval``__cpp_if_consteval   C++23 
C++20
+Hexadecimal floating literals   __cpp_hex_float  C++17 
C++03
+``inline`` variables__cpp_inline_variables   C++17 
C++03
+``static operator[]``   __cpp_multidimensional_subscript C++20 
C++03
+Attributes on namespaces__cpp_namespace_attributes   C++17 
C++11
+Non-static data member initializers __cpp_nsdmi  C++11 
C++03
+Range-based ``for`` loop__cpp_range_based_forC++11 
C++03
+RValue references   __cpp_rvalue_references  C++11 
C++03
+``static operator()``   __cpp_static_call_operator   C++23 
C++03
+Strucuted bindings  __cpp_structured_bindingsC++17 
C++03
+template template arguments __cpp_template_template_args C++17 
C++03
+``using enum``  __cpp_using_enum C++20 
C++03
+variable templates  __cpp_variable_templates C++14 
C++03
+variadic templates  __cpp_variadic_templates C++11 
C++03
+===  
= ==
+
 Type Trait Primitives
 =
 


Index: clang/docs/LanguageExtensions.rst
===
--- clang/docs/LanguageExtensions.rst
+++ clang/docs/LanguageExtensions.rst
@@ -1370,6 +1370,38 @@
 
 More information could be found `here `_.
 
+Language extensions back-ported to previous standards
+=
+
+===  = =
+Feature Feature Test Macro   Introduced In Backported To
+===  = =
+Conditional ``explicit``__cpp_conditional_explicit   C++20 C++03
+``if constexpr``__cpp_if_constexpr   C++17 C++11
+fold expressions__cpp_fold_expressions   C++17 C++03
+Alias templates __cpp_alias_templatesC++11 C++03
+Binary literals __cpp_binary_literalsC++14 C++03
+Lambda capture of \*this by value   __cpp_capture_star_this  C++17 C++11
+Relaxed constexpr   __cpp_constexpr  C++14 C++11
+Designated initializers __cpp_designated_initializersC++20 C++03
+Attributes on enums __cpp_enumerator_attributes  C++17 C++11
+Guaranteed copy elision __cpp_guaranteed_copy_elisionC++17 C++03
+``if consteval``  

[PATCH] D150140: [NFC][CLANG] Fix Static Code Analysis Concerns

2023-05-10 Thread Tom Honermann via Phabricator via cfe-commits
tahonermann accepted this revision.
tahonermann added a comment.
This revision is now accepted and ready to land.

Looks good to me!


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

https://reviews.llvm.org/D150140

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


[PATCH] D150320: [clang][deps] Avoid relocatable modules checks

2023-05-10 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 created this revision.
jansvoboda11 added reviewers: benlangmuir, Bigcheese.
Herald added a subscriber: ributzka.
Herald added a project: All.
jansvoboda11 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Currently, `ASTReader` performs some checks to diagnose relocated modules. This 
can add quite a bit of overhead to the scanner: it requires looking up, parsing 
and resolving module maps for all transitively loaded module files (and all the 
module maps encountered in the search paths on the way). Most of those checks 
are not really useful in the scanner anyway, since it uses strict context hash 
and immutable filesystem, which prevent those scenarios in the first place.

This can speed up scanning by up to 30%.

Depends on D150292 .


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D150320

Files:
  clang/include/clang/Lex/PreprocessorOptions.h
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp


Index: clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
===
--- clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
+++ clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
@@ -253,6 +253,9 @@
 // context hashing.
 ScanInstance.getHeaderSearchOpts().ModulesStrictContextHash = true;
 
+// Avoid some checks and module map parsing when loading PCM files.
+ScanInstance.getPreprocessorOpts().RelocatableModules = false;
+
 std::unique_ptr Action;
 
 if (ModuleName)
Index: clang/lib/Serialization/ASTReader.cpp
===
--- clang/lib/Serialization/ASTReader.cpp
+++ clang/lib/Serialization/ASTReader.cpp
@@ -2972,6 +2972,9 @@
   BaseDirectoryAsWritten = Blob;
   assert(!F.ModuleName.empty() &&
  "MODULE_DIRECTORY found before MODULE_NAME");
+  F.BaseDirectory = std::string(Blob);
+  if (!PP.getPreprocessorOpts().RelocatableModules)
+break;
   // If we've already loaded a module map file covering this module, we may
   // have a better path for it (relative to the current build).
   Module *M = PP.getHeaderSearchInfo().lookupModule(
@@ -2993,8 +2996,6 @@
   }
 }
 F.BaseDirectory = std::string(M->Directory->getName());
-  } else {
-F.BaseDirectory = std::string(Blob);
   }
   break;
 }
@@ -3992,7 +3993,8 @@
   // usable header search context.
   assert(!F.ModuleName.empty() &&
  "MODULE_NAME should come before MODULE_MAP_FILE");
-  if (F.Kind == MK_ImplicitModule && ModuleMgr.begin()->Kind != MK_MainFile) {
+  if (PP.getPreprocessorOpts().RelocatableModules &&
+  F.Kind == MK_ImplicitModule && ModuleMgr.begin()->Kind != MK_MainFile) {
 // An implicitly-loaded module file should have its module listed in some
 // module map file that we've already loaded.
 Module *M =
Index: clang/include/clang/Lex/PreprocessorOptions.h
===
--- clang/include/clang/Lex/PreprocessorOptions.h
+++ clang/include/clang/Lex/PreprocessorOptions.h
@@ -69,6 +69,9 @@
   std::vector Includes;
   std::vector MacroIncludes;
 
+  /// Perform extra checks for relocatable modules when loading PCM files.
+  bool RelocatableModules = true;
+
   /// Initialize the preprocessor with the compiler and target specific
   /// predefines.
   bool UsePredefines = true;


Index: clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
===
--- clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
+++ clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
@@ -253,6 +253,9 @@
 // context hashing.
 ScanInstance.getHeaderSearchOpts().ModulesStrictContextHash = true;
 
+// Avoid some checks and module map parsing when loading PCM files.
+ScanInstance.getPreprocessorOpts().RelocatableModules = false;
+
 std::unique_ptr Action;
 
 if (ModuleName)
Index: clang/lib/Serialization/ASTReader.cpp
===
--- clang/lib/Serialization/ASTReader.cpp
+++ clang/lib/Serialization/ASTReader.cpp
@@ -2972,6 +2972,9 @@
   BaseDirectoryAsWritten = Blob;
   assert(!F.ModuleName.empty() &&
  "MODULE_DIRECTORY found before MODULE_NAME");
+  F.BaseDirectory = std::string(Blob);
+  if (!PP.getPreprocessorOpts().RelocatableModules)
+break;
   // If we've already loaded a module map file covering this module, we may
   // have a better path for it (relative to the current build).
   Module *M = PP.getHeaderSearchInfo().lookupModule(
@@ -2993,8 +2996,6 @@
   }
 }
 F.BaseDirectory = 

[PATCH] D150319: [clang][deps] Always use -fmodules-validate-once-per-build-session

2023-05-10 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 created this revision.
jansvoboda11 added reviewers: benlangmuir, Bigcheese.
Herald added a subscriber: ributzka.
Herald added a project: All.
jansvoboda11 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

The dependency scanner assumes immutable file system. In that context, we don't 
need to repeatedly validate PCM input files. This patch avoids that by using 
the existing `-fmodules-validate-once-per-build-session` mechanism.

Depends on D150318 .


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D150319

Files:
  clang/include/clang/Tooling/DependencyScanning/DependencyScanningService.h
  clang/lib/Tooling/DependencyScanning/DependencyScanningService.cpp
  clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp


Index: clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
===
--- clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
+++ clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
@@ -182,6 +182,12 @@
 ScanInstance.getFrontendOpts().ModulesShareFileManager = false;
 ScanInstance.getHeaderSearchOpts().ModuleFormat = "raw";
 
+ScanInstance.getHeaderSearchOpts().ModulesValidateOncePerBuildSession =
+true;
+// FIXME: Consider diagnosing when this overwrites existing timestamp.
+ScanInstance.getHeaderSearchOpts().BuildSessionTimestamp =
+Service.getBuildSessionTimestamp();
+
 ScanInstance.setFileManager(FileMgr);
 // Support for virtual file system overlays.
 FileMgr->setVirtualFileSystem(createVFSFromCompilerInvocation(
Index: clang/lib/Tooling/DependencyScanning/DependencyScanningService.cpp
===
--- clang/lib/Tooling/DependencyScanning/DependencyScanningService.cpp
+++ clang/lib/Tooling/DependencyScanning/DependencyScanningService.cpp
@@ -9,15 +9,21 @@
 #include "clang/Tooling/DependencyScanning/DependencyScanningService.h"
 #include "llvm/Support/TargetSelect.h"
 
+#include 
+
 using namespace clang;
 using namespace tooling;
 using namespace dependencies;
 
 DependencyScanningService::DependencyScanningService(
 ScanningMode Mode, ScanningOutputFormat Format, bool OptimizeArgs,
-bool EagerLoadModules)
+bool EagerLoadModules, uint64_t BuildSessionTimestamp)
 : Mode(Mode), Format(Format), OptimizeArgs(OptimizeArgs),
-  EagerLoadModules(EagerLoadModules) {
+  EagerLoadModules(EagerLoadModules),
+  BuildSessionTimestamp(
+  BuildSessionTimestamp != 0
+  ? BuildSessionTimestamp
+  : std::chrono::system_clock::now().time_since_epoch().count()) {
   // Initialize targets for object file support.
   llvm::InitializeAllTargets();
   llvm::InitializeAllTargetMCs();
Index: 
clang/include/clang/Tooling/DependencyScanning/DependencyScanningService.h
===
--- clang/include/clang/Tooling/DependencyScanning/DependencyScanningService.h
+++ clang/include/clang/Tooling/DependencyScanning/DependencyScanningService.h
@@ -50,7 +50,8 @@
 public:
   DependencyScanningService(ScanningMode Mode, ScanningOutputFormat Format,
 bool OptimizeArgs = false,
-bool EagerLoadModules = false);
+bool EagerLoadModules = false,
+uint64_t BuildSessionTimestamp = 0);
 
   ScanningMode getMode() const { return Mode; }
 
@@ -60,6 +61,8 @@
 
   bool shouldEagerLoadModules() const { return EagerLoadModules; }
 
+  uint64_t getBuildSessionTimestamp() const { return BuildSessionTimestamp; }
+
   DependencyScanningFilesystemSharedCache () {
 return SharedCache;
   }
@@ -73,6 +76,8 @@
   bool OptimizeArgs;
   /// Whether to set up command-lines to load PCM files eagerly.
   bool EagerLoadModules;
+  /// The build session timestamp.
+  uint64_t BuildSessionTimestamp;
   /// The global file system cache.
   DependencyScanningFilesystemSharedCache SharedCache;
 };


Index: clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
===
--- clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
+++ clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
@@ -182,6 +182,12 @@
 ScanInstance.getFrontendOpts().ModulesShareFileManager = false;
 ScanInstance.getHeaderSearchOpts().ModuleFormat = "raw";
 
+ScanInstance.getHeaderSearchOpts().ModulesValidateOncePerBuildSession =
+true;
+// FIXME: Consider diagnosing when this overwrites existing timestamp.
+ScanInstance.getHeaderSearchOpts().BuildSessionTimestamp =
+Service.getBuildSessionTimestamp();
+
 ScanInstance.setFileManager(FileMgr);
 // Support for virtual file system overlays.
 

[PATCH] D150318: [clang][deps] NFC: Pass around the whole scanning service

2023-05-10 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 created this revision.
jansvoboda11 added reviewers: benlangmuir, Bigcheese.
Herald added a subscriber: ributzka.
Herald added a project: All.
jansvoboda11 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Adding new field into the scanning service and propagating it down into the 
worker, action or collector requires a lot of boilerplate and causes conflicts 
in our downstream repo. Fix this by passing around the whole service object.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D150318

Files:
  clang/include/clang/Tooling/DependencyScanning/DependencyScanningService.h
  clang/include/clang/Tooling/DependencyScanning/DependencyScanningWorker.h
  clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h
  clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
  clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp

Index: clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
===
--- clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
+++ clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
@@ -140,7 +140,8 @@
 // TODO: Verify this works fine when modulemap for module A is eagerly
 // loaded from A.pcm, and module map passed on the command line contains
 // definition of a submodule: "explicit module A.Private { ... }".
-if (EagerLoadModules && DepModuleMapFiles.contains(*ModuleMapEntry))
+if (Service.shouldEagerLoadModules() &&
+DepModuleMapFiles.contains(*ModuleMapEntry))
   continue;
 
 // Don't report module map file of the current module unless it also
@@ -193,7 +194,7 @@
 
 void ModuleDepCollector::addModuleMapFiles(
 CompilerInvocation , ArrayRef ClangModuleDeps) const {
-  if (EagerLoadModules)
+  if (Service.shouldEagerLoadModules())
 return; // Only pcm is needed for eager load.
 
   for (const ModuleID  : ClangModuleDeps) {
@@ -208,7 +209,7 @@
   for (const ModuleID  : ClangModuleDeps) {
 std::string PCMPath =
 Controller.lookupModuleOutput(MID, ModuleOutputKind::ModuleFile);
-if (EagerLoadModules)
+if (Service.shouldEagerLoadModules())
   CI.getFrontendOpts().ModuleFiles.push_back(std::move(PCMPath));
 else
   CI.getHeaderSearchOpts().PrebuiltModuleFiles.insert(
@@ -297,7 +298,8 @@
 
 void ModuleDepCollector::associateWithContextHash(const CompilerInvocation ,
   ModuleDeps ) {
-  Deps.ID.ContextHash = getModuleContextHash(Deps, CI, EagerLoadModules);
+  Deps.ID.ContextHash =
+  getModuleContextHash(Deps, CI, Service.shouldEagerLoadModules());
   bool Inserted = ModuleDepsByID.insert({Deps.ID, }).second;
   (void)Inserted;
   assert(Inserted && "duplicate module mapping");
@@ -401,7 +403,7 @@
 
   MDC.Consumer.handleDependencyOutputOpts(*MDC.Opts);
 
-  if (MDC.IsStdModuleP1689Format)
+  if (MDC.Service.getFormat() == ScanningOutputFormat::P1689)
 MDC.Consumer.handleProvidedAndRequiredStdCXXModules(
 MDC.ProvidedStdCXXModule, MDC.RequiredStdCXXModules);
 
@@ -480,7 +482,7 @@
 
   CompilerInvocation CI = MDC.makeInvocationForModuleBuildWithoutOutputs(
   MD, [&](CompilerInvocation ) {
-if (MDC.OptimizeArgs)
+if (MDC.Service.canOptimizeArgs())
   optimizeHeaderSearchOpts(BuildInvocation.getHeaderSearchOpts(),
*MDC.ScanInstance.getASTReader(), *MF);
   });
@@ -579,11 +581,10 @@
 std::unique_ptr Opts,
 CompilerInstance , DependencyConsumer ,
 DependencyActionController , CompilerInvocation OriginalCI,
-bool OptimizeArgs, bool EagerLoadModules, bool IsStdModuleP1689Format)
+const DependencyScanningService )
 : ScanInstance(ScanInstance), Consumer(C), Controller(Controller),
   Opts(std::move(Opts)), OriginalInvocation(std::move(OriginalCI)),
-  OptimizeArgs(OptimizeArgs), EagerLoadModules(EagerLoadModules),
-  IsStdModuleP1689Format(IsStdModuleP1689Format) {}
+  Service(Service) {}
 
 void ModuleDepCollector::attachToPreprocessor(Preprocessor ) {
   PP.addPPCallbacks(std::make_unique(*this));
Index: clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
===
--- clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
+++ clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
@@ -137,11 +137,10 @@
   StringRef WorkingDirectory, DependencyConsumer ,
   DependencyActionController ,
   llvm::IntrusiveRefCntPtr DepFS,
-  ScanningOutputFormat Format, bool OptimizeArgs, bool EagerLoadModules,
+  const DependencyScanningService ,
   bool DisableFree, std::optional ModuleName = std::nullopt)
   : WorkingDirectory(WorkingDirectory), Consumer(Consumer),
-Controller(Controller), DepFS(std::move(DepFS)), Format(Format),
-

[PATCH] D147266: [AArch64] Add IR intrinsics for vbsl* C intrinsics

2023-05-10 Thread Pranav Kant via Phabricator via cfe-commits
pranavk updated this revision to Diff 521115.
pranavk added a comment.

[AArch64] Change shouldSinkOperand to allow bitselect instructions


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147266

Files:
  llvm/lib/Target/AArch64/AArch64ISelLowering.cpp


Index: llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
===
--- llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
+++ llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
@@ -14332,6 +14332,61 @@
 
 return true;
   }
+  case Instruction::And: {
+// If Or(And(A, maskValue), And(B, ~maskValue)), sink ~maskValue
+// where ~maskValue = xor maskValue, -1
+// This is to select more performant bitselect instruction with NEON.
+
+// We start checking for this code sequence from AND instruction containing
+// ~maskValue because operands are sunk just before the Instruction* I
+// passed to this function. Starting pattern matching with any other
+// instruction (such as Or) would lead to malformed IR
+
+// Check if this AND instruction is part of bigger tree rooted at Or.
+if (Subtarget->hasNEON() && I->getNumUses() == 1) {
+  Use  = *(I->use_begin());
+  Instruction *OI = cast(U.getUser());
+  Value *And0_Op0 = nullptr, *And0_Op1 = nullptr, *And1_Op0 = nullptr,
+*And1_Op1 = nullptr;
+  if (!OI ||
+  !match(OI, m_Or(m_And(m_Value(And0_Op0), m_Value(And0_Op1)),
+  m_And(m_Value(And1_Op0), m_Value(And1_Op1 ||
+  !all_of(OI->operands(), [](Value *V) { return V->hasOneUser(); }))
+return false;
+
+  ArrayRef> Ands = {{And0_Op0, And0_Op1},
+  {And1_Op0, And1_Op1}};
+  for (unsigned AndIndex = 0; AndIndex < Ands.size(); ++AndIndex) {
+const unsigned OtherAndIndex = (AndIndex + 1) % 2;
+
+// Iterate operands of selected And
+for (unsigned AndOpIndex = 0; AndOpIndex < 2; ++AndOpIndex) {
+  if (const Instruction *XI =
+  dyn_cast(Ands[AndIndex][AndOpIndex]);
+  XI && XI->getOpcode() == Instruction::Xor) {
+Constant *MaskConst;
+Value *MaskValue;
+if (!match(XI, m_Xor(m_Value(MaskValue), m_Constant(MaskConst))) &&
+!match(XI, m_Xor(m_Constant(MaskConst), m_Value(MaskValue
+  return false;
+
+if (!MaskConst->isAllOnesValue())
+  return false;
+
+// one of the operands of other AND should be MaskValue
+if (!any_of(Ands[OtherAndIndex],
+[](Value *V) { return V == MaskValue; }))
+  return false;
+
+auto TI = cast(OI->getOperand(AndIndex));
+Ops.push_back(>getOperandUse(AndOpIndex));
+return true;
+  }
+}
+  }
+}
+return false;
+  }
   case Instruction::Mul: {
 int NumZExts = 0, NumSExts = 0;
 for (auto  : I->operands()) {


Index: llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
===
--- llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
+++ llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
@@ -14332,6 +14332,61 @@
 
 return true;
   }
+  case Instruction::And: {
+// If Or(And(A, maskValue), And(B, ~maskValue)), sink ~maskValue
+// where ~maskValue = xor maskValue, -1
+// This is to select more performant bitselect instruction with NEON.
+
+// We start checking for this code sequence from AND instruction containing
+// ~maskValue because operands are sunk just before the Instruction* I
+// passed to this function. Starting pattern matching with any other
+// instruction (such as Or) would lead to malformed IR
+
+// Check if this AND instruction is part of bigger tree rooted at Or.
+if (Subtarget->hasNEON() && I->getNumUses() == 1) {
+  Use  = *(I->use_begin());
+  Instruction *OI = cast(U.getUser());
+  Value *And0_Op0 = nullptr, *And0_Op1 = nullptr, *And1_Op0 = nullptr,
+*And1_Op1 = nullptr;
+  if (!OI ||
+  !match(OI, m_Or(m_And(m_Value(And0_Op0), m_Value(And0_Op1)),
+  m_And(m_Value(And1_Op0), m_Value(And1_Op1 ||
+  !all_of(OI->operands(), [](Value *V) { return V->hasOneUser(); }))
+return false;
+
+  ArrayRef> Ands = {{And0_Op0, And0_Op1},
+  {And1_Op0, And1_Op1}};
+  for (unsigned AndIndex = 0; AndIndex < Ands.size(); ++AndIndex) {
+const unsigned OtherAndIndex = (AndIndex + 1) % 2;
+
+// Iterate operands of selected And
+for (unsigned AndOpIndex = 0; AndOpIndex < 2; ++AndOpIndex) {
+  if (const Instruction *XI =
+  dyn_cast(Ands[AndIndex][AndOpIndex]);
+  XI && XI->getOpcode() == Instruction::Xor) {
+

[PATCH] D147266: [AArch64] Add IR intrinsics for vbsl* C intrinsics

2023-05-10 Thread Pranav Kant via Phabricator via cfe-commits
pranavk updated this revision to Diff 521114.
pranavk added a comment.

[AArch64][InstCombine] Bail out for bitselect instructions


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147266

Files:
  llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp


Index: llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
===
--- llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
+++ llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
@@ -56,6 +56,29 @@
 ///
 /// FIXME: It's possible to create more instructions than previously existed.
 static bool cheapToScalarize(Value *V, Value *EI) {
+  // Pattern: or(and(a, mask), and(b, ~mask)) can be efficiently folded to 
bitselect instructions
+  // where ~mask = xor mask, -1
+  if (isa(V)) {
+Instruction *TI = cast(V);
+if (TI->getOpcode() == Instruction::Or) {
+  Value *LHS = TI->getOperand(0);
+  Value *RHS = TI->getOperand(1);
+  Value *MaskValue = nullptr;
+  Value *MaskConst = nullptr;
+
+  if (match(LHS, m_And(m_Value(), m_Value(MaskValue))) &&
+  match(RHS, m_And(m_Value(), m_Xor(m_Specific(MaskValue), 
m_Value(MaskConst) {
+if (auto *CI = dyn_cast(MaskConst)) {
+  Constant *C = CI->getSplatValue();
+  if (C->isAllOnesValue()) {
+llvm::outs() << "return false from cheap\n";
+return false;
+  }
+}
+  }
+}
+  }
+
   ConstantInt *CEI = dyn_cast(EI);
 
   // If we can pick a scalar constant value out of a vector, that is free.


Index: llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
===
--- llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
+++ llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
@@ -56,6 +56,29 @@
 ///
 /// FIXME: It's possible to create more instructions than previously existed.
 static bool cheapToScalarize(Value *V, Value *EI) {
+  // Pattern: or(and(a, mask), and(b, ~mask)) can be efficiently folded to bitselect instructions
+  // where ~mask = xor mask, -1
+  if (isa(V)) {
+Instruction *TI = cast(V);
+if (TI->getOpcode() == Instruction::Or) {
+  Value *LHS = TI->getOperand(0);
+  Value *RHS = TI->getOperand(1);
+  Value *MaskValue = nullptr;
+  Value *MaskConst = nullptr;
+
+  if (match(LHS, m_And(m_Value(), m_Value(MaskValue))) &&
+  match(RHS, m_And(m_Value(), m_Xor(m_Specific(MaskValue), m_Value(MaskConst) {
+if (auto *CI = dyn_cast(MaskConst)) {
+  Constant *C = CI->getSplatValue();
+  if (C->isAllOnesValue()) {
+llvm::outs() << "return false from cheap\n";
+return false;
+  }
+}
+  }
+}
+  }
+
   ConstantInt *CEI = dyn_cast(EI);
 
   // If we can pick a scalar constant value out of a vector, that is free.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D150295: [MemProf] Update hot/cold information after importing

2023-05-10 Thread Teresa Johnson 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 rG9e280c47588b: [MemProf] Update hot/cold information after 
importing (authored by tejohnson).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150295

Files:
  clang/test/CodeGen/thinlto-distributed-supports-hot-cold-new.ll
  llvm/lib/LTO/LTOBackend.cpp
  llvm/test/ThinLTO/X86/memprof-supports-hot-cold-new.ll

Index: llvm/test/ThinLTO/X86/memprof-supports-hot-cold-new.ll
===
--- llvm/test/ThinLTO/X86/memprof-supports-hot-cold-new.ll
+++ llvm/test/ThinLTO/X86/memprof-supports-hot-cold-new.ll
@@ -3,37 +3,53 @@
 ;; from being removed from the LTO backend, and vice versa without passing
 ;; -supports-hot-cold-new.
 
+; RUN: split-file %s %t
+
 ;; First check with -supports-hot-cold-new.
-; RUN: opt -thinlto-bc %s >%t.o
-; RUN: llvm-lto2 run %t.o -enable-memprof-context-disambiguation \
+; RUN: opt -thinlto-bc %t/main.ll >%t/main.o
+; RUN: opt -thinlto-bc %t/foo.ll >%t/foo.o
+; RUN: llvm-lto2 run %t/main.o %t/foo.o -enable-memprof-context-disambiguation \
 ; RUN:	-supports-hot-cold-new \
-; RUN:	-r=%t.o,main,plx \
-; RUN:	-r=%t.o,_Znam, \
+; RUN:	-r=%t/main.o,main,plx \
+; RUN:	-r=%t/main.o,bar,plx \
+; RUN:	-r=%t/main.o,foo, \
+; RUN:	-r=%t/main.o,_Znam, \
+; RUN:	-r=%t/foo.o,foo,plx \
+; RUN:	-r=%t/foo.o,_Znam, \
 ; RUN:	-memprof-dump-ccg \
 ; RUN:	 -save-temps \
 ; RUN:	-o %t.out 2>&1 | FileCheck %s --check-prefix=DUMP
 ; DUMP: Callsite Context Graph:
 
-; RUN: llvm-dis %t.out.1.0.preopt.bc -o - | FileCheck %s --check-prefix=IR
+; RUN: llvm-dis %t.out.1.3.import.bc -o - | FileCheck %s --check-prefix=IR
+; IR: @main()
+; IR: !memprof {{.*}} !callsite
+; IR: @_Znam(i64 0) #[[ATTR:[0-9]+]]
+; IR: @bar()
 ; IR: !memprof {{.*}} !callsite
-; IR: "memprof"="cold"
+; IR: @_Znam(i64 0) #[[ATTR:[0-9]+]]
+; IR: attributes #[[ATTR]] = { "memprof"="cold" }
 
 ;; Next check without -supports-hot-cold-new, we should not perform
 ;; context disambiguation, and we should strip memprof metadata and
 ;; attributes before optimization.
-; RUN: llvm-lto2 run %t.o -enable-memprof-context-disambiguation \
-; RUN:	-r=%t.o,main,plx \
-; RUN:	-r=%t.o,_Znam, \
+; RUN: llvm-lto2 run %t/main.o %t/foo.o -enable-memprof-context-disambiguation \
+; RUN:	-r=%t/main.o,main,plx \
+; RUN:	-r=%t/main.o,bar,plx \
+; RUN:	-r=%t/main.o,foo, \
+; RUN:	-r=%t/main.o,_Znam, \
+; RUN:	-r=%t/foo.o,foo,plx \
+; RUN:	-r=%t/foo.o,_Znam, \
 ; RUN:	-memprof-dump-ccg \
 ; RUN:	 -save-temps \
 ; RUN:	-o %t.out 2>&1 | FileCheck %s --allow-empty \
 ; RUN:  --implicit-check-not "Callsite Context Graph:"
 
-; RUN: llvm-dis %t.out.1.0.preopt.bc -o - | FileCheck %s \
+; RUN: llvm-dis %t.out.1.3.import.bc -o - | FileCheck %s \
 ; RUN: --implicit-check-not "!memprof" --implicit-check-not "!callsite" \
 ; RUN: --implicit-check-not "memprof"="cold"
 
-source_filename = "memprof-supports-hot-cold-new.ll"
+;--- main.ll
 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
 target triple = "x86_64-unknown-linux-gnu"
 
@@ -44,6 +60,13 @@
   ret i32 0
 }
 
+define void @bar() {
+  call void @foo()
+  ret void
+}
+
+declare void @foo()
+
 declare ptr @_Znam(i64)
 
 attributes #0 = { noinline optnone }
@@ -55,3 +78,25 @@
 !3 = !{!4, !"cold"}
 !4 = !{i64 9086428284934609951, i64 -5964873800580613432, i64 2732490490862098848, i64 -3421689549917153178}
 !5 = !{i64 9086428284934609951}
+
+;--- foo.ll
+target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+define i32 @foo() {
+entry:
+  %call = call ptr @_Znam(i64 0), !memprof !0, !callsite !5
+  %call2 = call ptr @_Znam(i64 0) #1
+  ret i32 0
+}
+
+declare ptr @_Znam(i64)
+
+attributes #1 = { "memprof"="cold" }
+
+!0 = !{!1, !3}
+!1 = !{!2, !"notcold"}
+!2 = !{i64 9086428284934609951, i64 -5964873800580613432, i64 2732490490862098848, i64 8632435727821051414}
+!3 = !{!4, !"cold"}
+!4 = !{i64 9086428284934609951, i64 -5964873800580613432, i64 2732490490862098848, i64 -3421689549917153178}
+!5 = !{i64 9086428284934609951}
Index: llvm/lib/LTO/LTOBackend.cpp
===
--- llvm/lib/LTO/LTOBackend.cpp
+++ llvm/lib/LTO/LTOBackend.cpp
@@ -565,8 +565,6 @@
   // the module, if applicable.
   Mod.setPartialSampleProfileRatio(CombinedIndex);
 
-  updateMemProfAttributes(Mod, CombinedIndex);
-
   updatePublicTypeTestCalls(Mod, CombinedIndex.withWholeProgramVisibility());
 
   if (Conf.CodeGenOnly) {
@@ -653,6 +651,9 @@
   if (Error Err = Importer.importFunctions(Mod, ImportList).takeError())
 return Err;
 
+  // Do this after any importing so that imported code is updated.
+  updateMemProfAttributes(Mod, CombinedIndex);
+
   if (Conf.PostImportModuleHook && 

[clang] 9e280c4 - [MemProf] Update hot/cold information after importing

2023-05-10 Thread Teresa Johnson via cfe-commits

Author: Teresa Johnson
Date: 2023-05-10T14:58:35-07:00
New Revision: 9e280c47588bfaf008a5fb091cd47df92b9c4264

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

LOG: [MemProf] Update hot/cold information after importing

The support added by D149215 to remove memprof metadata and attributes
if we don't link with an allocator supporting hot/cold operator new
interfaces did not update imported code. Move the update handling later
in the ThinLTO backend to just after importing, and update the test to
check this case.

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

Added: 


Modified: 
clang/test/CodeGen/thinlto-distributed-supports-hot-cold-new.ll
llvm/lib/LTO/LTOBackend.cpp
llvm/test/ThinLTO/X86/memprof-supports-hot-cold-new.ll

Removed: 




diff  --git a/clang/test/CodeGen/thinlto-distributed-supports-hot-cold-new.ll 
b/clang/test/CodeGen/thinlto-distributed-supports-hot-cold-new.ll
index e213fbaf3fa14..08c1a2946971c 100644
--- a/clang/test/CodeGen/thinlto-distributed-supports-hot-cold-new.ll
+++ b/clang/test/CodeGen/thinlto-distributed-supports-hot-cold-new.ll
@@ -22,7 +22,7 @@
 
 ; RUN: %clang -target x86_64-unknown-linux-gnu -O2 -o %t1.o -x ir %t.o -c 
-fthinlto-index=%t.o.thinlto.bc -save-temps=obj
 
-; RUN: llvm-dis %t.s.0.preopt.bc -o - | FileCheck %s --check-prefix=CHECK-IR
+; RUN: llvm-dis %t.s.3.import.bc -o - | FileCheck %s --check-prefix=CHECK-IR
 ; CHECK-IR: !memprof {{.*}} !callsite
 ; CHECK-IR: "memprof"="cold"
 
@@ -42,7 +42,7 @@
 
 ; RUN: %clang -target x86_64-unknown-linux-gnu -O2 -o %t1.o -x ir %t.o -c 
-fthinlto-index=%t.o.thinlto.bc -save-temps=obj
 
-; RUN: llvm-dis %t.s.0.preopt.bc -o - | FileCheck %s \
+; RUN: llvm-dis %t.s.3.import.bc -o - | FileCheck %s \
 ; RUN: --implicit-check-not "!memprof" --implicit-check-not "!callsite" \
 ; RUN: --implicit-check-not "memprof"="cold"
 

diff  --git a/llvm/lib/LTO/LTOBackend.cpp b/llvm/lib/LTO/LTOBackend.cpp
index a18963fcaf85d..a089cbe63963e 100644
--- a/llvm/lib/LTO/LTOBackend.cpp
+++ b/llvm/lib/LTO/LTOBackend.cpp
@@ -565,8 +565,6 @@ Error lto::thinBackend(const Config , unsigned Task, 
AddStreamFn AddStream,
   // the module, if applicable.
   Mod.setPartialSampleProfileRatio(CombinedIndex);
 
-  updateMemProfAttributes(Mod, CombinedIndex);
-
   updatePublicTypeTestCalls(Mod, CombinedIndex.withWholeProgramVisibility());
 
   if (Conf.CodeGenOnly) {
@@ -653,6 +651,9 @@ Error lto::thinBackend(const Config , unsigned Task, 
AddStreamFn AddStream,
   if (Error Err = Importer.importFunctions(Mod, ImportList).takeError())
 return Err;
 
+  // Do this after any importing so that imported code is updated.
+  updateMemProfAttributes(Mod, CombinedIndex);
+
   if (Conf.PostImportModuleHook && !Conf.PostImportModuleHook(Task, Mod))
 return finalizeOptimizationRemarks(std::move(DiagnosticOutputFile));
 

diff  --git a/llvm/test/ThinLTO/X86/memprof-supports-hot-cold-new.ll 
b/llvm/test/ThinLTO/X86/memprof-supports-hot-cold-new.ll
index 9e69377d14443..7a4d860d8d0d9 100644
--- a/llvm/test/ThinLTO/X86/memprof-supports-hot-cold-new.ll
+++ b/llvm/test/ThinLTO/X86/memprof-supports-hot-cold-new.ll
@@ -3,37 +3,53 @@
 ;; from being removed from the LTO backend, and vice versa without passing
 ;; -supports-hot-cold-new.
 
+; RUN: split-file %s %t
+
 ;; First check with -supports-hot-cold-new.
-; RUN: opt -thinlto-bc %s >%t.o
-; RUN: llvm-lto2 run %t.o -enable-memprof-context-disambiguation \
+; RUN: opt -thinlto-bc %t/main.ll >%t/main.o
+; RUN: opt -thinlto-bc %t/foo.ll >%t/foo.o
+; RUN: llvm-lto2 run %t/main.o %t/foo.o -enable-memprof-context-disambiguation 
\
 ; RUN: -supports-hot-cold-new \
-; RUN: -r=%t.o,main,plx \
-; RUN: -r=%t.o,_Znam, \
+; RUN: -r=%t/main.o,main,plx \
+; RUN: -r=%t/main.o,bar,plx \
+; RUN: -r=%t/main.o,foo, \
+; RUN: -r=%t/main.o,_Znam, \
+; RUN: -r=%t/foo.o,foo,plx \
+; RUN: -r=%t/foo.o,_Znam, \
 ; RUN: -memprof-dump-ccg \
 ; RUN:  -save-temps \
 ; RUN: -o %t.out 2>&1 | FileCheck %s --check-prefix=DUMP
 ; DUMP: Callsite Context Graph:
 
-; RUN: llvm-dis %t.out.1.0.preopt.bc -o - | FileCheck %s --check-prefix=IR
+; RUN: llvm-dis %t.out.1.3.import.bc -o - | FileCheck %s --check-prefix=IR
+; IR: @main()
+; IR: !memprof {{.*}} !callsite
+; IR: @_Znam(i64 0) #[[ATTR:[0-9]+]]
+; IR: @bar()
 ; IR: !memprof {{.*}} !callsite
-; IR: "memprof"="cold"
+; IR: @_Znam(i64 0) #[[ATTR:[0-9]+]]
+; IR: attributes #[[ATTR]] = { "memprof"="cold" }
 
 ;; Next check without -supports-hot-cold-new, we should not perform
 ;; context disambiguation, and we should strip memprof metadata and
 ;; attributes before optimization.
-; RUN: llvm-lto2 run %t.o -enable-memprof-context-disambiguation \
-; RUN: -r=%t.o,main,plx \
-; RUN: -r=%t.o,_Znam, \
+; RUN: llvm-lto2 run %t/main.o %t/foo.o 

[PATCH] D147844: [clang][Sema]Print diagnostic warning about precedence when integer expression is used without parentheses in an conditional operator expression

2023-05-10 Thread Louis Dionne via Phabricator via cfe-commits
ldionne accepted this revision as: libc++abi.
ldionne added a comment.
This revision is now accepted and ready to land.

Code changes in libc++ and libc++abi LGTM. I am neutral on whether the 
diagnostic is worth adding, but don't consider libc++ and libc++abi as blockers 
for this patch.




Comment at: libcxxabi/src/cxa_personality.cpp:721
 // Found a cleanup
-results.reason = actions & _UA_SEARCH_PHASE
- ? _URC_CONTINUE_UNWIND
- : _URC_HANDLER_FOUND;
+results.reason = ((actions & _UA_SEARCH_PHASE) ? 
_URC_CONTINUE_UNWIND : _URC_HANDLER_FOUND);
 return;

Double-parens are not required.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147844

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


[PATCH] D146148: Float_t and double_t types shouldn't be modified by #pragma clang fp eval_method

2023-05-10 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

> Okay, so I did add that in TokenKinds.h. Isn't that the right place for it? 
> The same way it's done for the other builtins? And in TokenKinds.def I added 
> the lines for the interesting identifiers?

What you're doing in `TokenKinds.{def,h}` seems fine.  What I'm objecting to is 
adding another field to `IdentifierInfo` to store it instead of fitting it into 
`ObjCOrBuiltinID`.  Currently an given identifier is either normal, an ObjC 
keyword, or a builtin ID, and it determines this by checking what range of 
values ObjCOrBuiltinID fits into.  You can use the same idea to allow an 
identifier to be either normal, an ObjC keyword, a builtin ID, or an 
interesting.




Comment at: clang/include/clang/Basic/TokenKinds.def:89
+#ifndef Interesting_Identifier
+#define Interesting_Identifier(X)
+#endif

Please follow the existing pattern by spelling this INTERESTING_IDENTIFIER.


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

https://reviews.llvm.org/D146148

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


[PATCH] D146148: Float_t and double_t types shouldn't be modified by #pragma clang fp eval_method

2023-05-10 Thread Zahira Ammarguellat via Phabricator via cfe-commits
zahiraam added a comment.

In D146148#4330971 , @rjmccall wrote:

> In D146148#4330611 , @zahiraam 
> wrote:
>
>> In D146148#4221651 , @rjmccall 
>> wrote:
>>
>>> In D146148#4220591 , @zahiraam 
>>> wrote:
>>>
 In D146148#4220495 , 
 @aaron.ballman wrote:

> In D146148#4220433 , @zahiraam 
> wrote:
>
>> In D146148#4220268 , @rjmccall 
>> wrote:
>>
>>> Okay, so modifying `math.h` to use this attribute is acceptable?  
>>> That's great, that's definitely the best outcome for the compiler.
>>>
>>> Just a minor request about the diagnostic name, but otherwise LGTM.
>>
>> Yes. Added the attribute inside the included math.h header file.
>
> How does this work for, say, glibc, musl, or MSVC CRT? Won't those math.h 
> headers lack the attribute and thus run into problems when used with 
> Clang?

 Good point! @rjmccall are you thinking of something in particular with the 
 attribute?
>>>
>>> Zahira, this is what I was asking you when I asked whether modifying the 
>>> math.h header was acceptable: whether you were prepared to accept that the 
>>> warning would only fire on system math.h headers that we'd modified, or 
>>> whether you cared about making it work with non-cooperative headers.  I 
>>> wasn't asking if you were willing to change the test code.
>>>
 If not I guess we will have to rely on string comparison for all the 
 typedef in the TU. Aaron pointed out the compile time overhead.
>>>
>>> Well, the compile-time overhead of doing this on every typedef 
>>> *declaration* is way better than the overhead of doing this on every type 
>>> lookup, at least.
>>>
>>> Anyway, there are three possibilities I can see:
>>>
>>> - We accept that this needs cooperative system headers.
>>> - We add a math.h compiler header that `#include_next`s the system math.h 
>>> and then adds the attribute.  I believe you can just add an attribute to a 
>>> typedef retroactively with something like `typedef float_t float_t 
>>> __attribute__((whatever))`.
>>> - We do checks on every typedef declaration.  There's a builtin-identifier 
>>> trick that we do with library functions that we should be able to 
>>> generalize to typedefs, so you wouldn't need to actually do string 
>>> comparisons, you'd just check whether the `IdentifierInfo*` was storing a 
>>> special ID.  We'd set that up in `initializeBuiltins` at the start of the 
>>> translation unit, so the overhead would just be that we'd create two extra 
>>> `IdentifierInfo*`s in every TU.
>>>
>>> The builtin ID logic is currently specific to builtin *functions*, and I 
>>> don't think we'd want to hack typedef names into that.  But the same 
>>> storage in `IdentifierInfo*` is also used for identifying the ObjC 
>>> context-sensitive keywords, by just offsetting the builtin IDs by the 
>>> NUM_OBJC_KEYWORD.  You should be able to generalize that by also 
>>> introducing a concept of a builtin *type* name, so that e.g. IDs in 
>>> [0,NUM_OBJC_KEYWORDS) are ObjCKeywordKinds, IDs in [NUM_OBJC_KEYWORDS, 
>>> NUM_OBJC_KEYWORDS+NUM_BUILTIN_TYPES) are BuiltinTypeKinds (when you 
>>> subtract NUM_OBJC_KEYWORDS), and IDs in 
>>> [NUM_OBJC_KEYWORDS+NUM_BUILTIN_TYPES,∞) are builtin function IDs (when you 
>>> subtract NUM_OBJC_KEYWORDS+NUM_BUILTIN_TYPES).
>>
>> Reading this more carefully... Does that mean that we initialize the 
>> float_t, double_t in initializeBuiltins  even if they are not used in the 
>> source code?
>
> Yes.  If we decide this is an overhead worth eliminating, we'll find a way to 
> do it lazily to the builtins, and then we'll be able to take advantage of it 
> here, too.  The builtins are a much larger contributor to overhead.
>
>> Also not sure how to define the NUM_BUILTIN_TYPES since I don't need to add 
>> it to TokenKinds.h? I was proposing to do something like this:
>> enum InterestingIdentifierKind {
>> #define Interesting_Identifier(X) X,
>> #include "clang/Basic/TokenKinds.def"
>>
>>   NUM_INTERESTING_IDENTIFIERS
>>
>> };
>> But I guess I don't need since we don't want to add additional storage. Do I 
>> understand things correctly?
>
> We should have an enum like this, yes.  And this is what we do in 
> `IdentifierTable.h` for all the other kinds.  Alternatively, you can just 
> hard-code the number and then static_assert that it's correct in some .cpp 
> file.
>
> FWIW, I think I like NUM_INTERESTING_IDENTIFIERS as a name rather than 
> NUM_BUILTIN_TYPES.

Okay, so I did add that in TokenKinds.h. Isn't that the right place for it? The 
same way it's done for the other builtins? And in TokenKinds.def I added the 
lines for the interesting identifiers?

In D146148#4330971 

[PATCH] D150295: [MemProf] Update hot/cold information after importing

2023-05-10 Thread David Li via Phabricator via cfe-commits
davidxl accepted this revision.
davidxl 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/D150295/new/

https://reviews.llvm.org/D150295

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


[PATCH] D150209: [clang][Interp] Add more shift error checking

2023-05-10 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik accepted this revision.
shafik added a comment.
This revision is now accepted and ready to land.

LGTM




Comment at: clang/lib/AST/Interp/Interp.h:141-142
+
+  // C++2a [expr.shift]p2: E1 << E2 is the unique value congruent to
+  // E1 x 2^E2 module 2^N.
+

Just adding a reference to 
https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0907r4.html since 
that is the paper that changed this behavior


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

https://reviews.llvm.org/D150209

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


[PATCH] D150140: [NFC][CLANG] Fix Static Code Analysis Concerns

2023-05-10 Thread Soumi Manna via Phabricator via cfe-commits
Manna marked an inline comment as done.
Manna added inline comments.



Comment at: clang/utils/TableGen/SveEmitter.cpp:302
   unsigned Shift = llvm::countr_zero(Mask);
+  assert(Shift >= 64 && "Shift is out of encodable range");
   return (V << Shift) & Mask;

tahonermann wrote:
> Manna wrote:
> > sdesmalen wrote:
> > > erichkeane wrote:
> > > > sdesmalen wrote:
> > > > > erichkeane wrote:
> > > > > > Shouldn't this be: `assert(Shift < 64 &&"...")`?
> > > > > > 
> > > > > > `expr.shift` (https://eel.is/c++draft/expr.shift) says:
> > > > > > ```
> > > > > > The operands shall be of integral or unscoped enumeration type and 
> > > > > > integral promotions are performed.
> > > > > > The type of the result is that of the promoted left operand.
> > > > > > The behavior is undefined if the right operand is negative, or 
> > > > > > greater than or equal to the width of the promoted left operand.```
> > > > > > 
> > > > > > uint64 stays as an `unsigned long`, so it is still 64 bits, so the 
> > > > > > only invalid value for `Shift` is 64 (though >64 is 'nonsense', but 
> > > > > > only impossible because of `llvm::countr_zero`).
> > > > > > 
> > > > > > One thing to consider: I wonder if we should instead be changing 
> > > > > > the 'shift' to be:
> > > > > > 
> > > > > > `(V << (Shift % 64)) && Mask` ?  It looks like `arm_sve.td` has the 
> > > > > > `NoFlags` value as zero, which I think will end up going through 
> > > > > > here possibly (or at least, inserted into `FlagTypes`.
> > > > > > 
> > > > > > So I suspect an assert might not be sufficient, since a 64 bit 
> > > > > > shift is possible in that case (since a zero 'Mask' is the only 
> > > > > > case where `countr_zero` will end up being 64).
> > > > > > 
> > > > > > 
> > > > > > So I suspect an assert might not be sufficient, since a 64 bit 
> > > > > > shift is possible in that case (since a zero 'Mask' is the only 
> > > > > > case where countr_zero will end up being 64).
> > > > > It should be fine to assert that `Mask != 0`, since that would be an 
> > > > > invalid mask.
> > > > Thanks for the comment @sdesmalen!  Is there something that prevents 
> > > > the `NoFlags` from being passed as the `MaskName` here?  
> > > There's nothing that actively prevents it, but `encodeFlag` is a utility 
> > > function that has no uses outside this file and has only 4 uses. Adding 
> > > an assert should be sufficient.
> > Thank you for the explanation!
> I'm not sure if asserting `Mask != 0` will suffice to silence Coverity. While 
> Coverity can specifically observe that `countr_zero` might return 0 (because 
> `TrailingZerosCounter::count()` has a `return 64` statement), I don't 
> think Coverity can determine that the function can't return 65 or higher. I 
> think Erich's initial intuition is correct; the concern that Coverity is 
> reporting is that the shift might overflow, so that is what should be guarded.
>   assert(Shift < 64 && "Mask value produced an invalid shift value");
Thanks @tahonermann for comments. I have updated my patch to guard the shift 
overflow issue with Mask value.


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

https://reviews.llvm.org/D150140

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


[PATCH] D150140: [NFC][CLANG] Fix Static Code Analysis Concerns

2023-05-10 Thread Soumi Manna via Phabricator via cfe-commits
Manna updated this revision to Diff 521089.
Manna added a comment.

Fix Coverity complain about shift overflow issue


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

https://reviews.llvm.org/D150140

Files:
  clang/utils/TableGen/SveEmitter.cpp


Index: clang/utils/TableGen/SveEmitter.cpp
===
--- clang/utils/TableGen/SveEmitter.cpp
+++ clang/utils/TableGen/SveEmitter.cpp
@@ -299,6 +299,7 @@
 if (It != FlagTypes.end()) {
   uint64_t Mask = It->getValue();
   unsigned Shift = llvm::countr_zero(Mask);
+  assert(Shift < 64 && "Mask value produced an invalid shift value");
   return (V << Shift) & Mask;
 }
 llvm_unreachable("Unsupported flag");


Index: clang/utils/TableGen/SveEmitter.cpp
===
--- clang/utils/TableGen/SveEmitter.cpp
+++ clang/utils/TableGen/SveEmitter.cpp
@@ -299,6 +299,7 @@
 if (It != FlagTypes.end()) {
   uint64_t Mask = It->getValue();
   unsigned Shift = llvm::countr_zero(Mask);
+  assert(Shift < 64 && "Mask value produced an invalid shift value");
   return (V << Shift) & Mask;
 }
 llvm_unreachable("Unsupported flag");
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D150295: [MemProf] Update hot/cold information after importing

2023-05-10 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson created this revision.
tejohnson added a reviewer: davidxl.
Herald added subscribers: ormris, steven_wu, hiraditya.
Herald added a project: All.
tejohnson requested review of this revision.
Herald added projects: clang, LLVM.
Herald added a subscriber: cfe-commits.

The support added by D149215  to remove 
memprof metadata and attributes
if we don't link with an allocator supporting hot/cold operator new
interfaces did not update imported code. Move the update handling later
in the ThinLTO backend to just after importing, and update the test to
check this case.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D150295

Files:
  clang/test/CodeGen/thinlto-distributed-supports-hot-cold-new.ll
  llvm/lib/LTO/LTOBackend.cpp
  llvm/test/ThinLTO/X86/memprof-supports-hot-cold-new.ll

Index: llvm/test/ThinLTO/X86/memprof-supports-hot-cold-new.ll
===
--- llvm/test/ThinLTO/X86/memprof-supports-hot-cold-new.ll
+++ llvm/test/ThinLTO/X86/memprof-supports-hot-cold-new.ll
@@ -3,37 +3,53 @@
 ;; from being removed from the LTO backend, and vice versa without passing
 ;; -supports-hot-cold-new.
 
+; RUN: split-file %s %t
+
 ;; First check with -supports-hot-cold-new.
-; RUN: opt -thinlto-bc %s >%t.o
-; RUN: llvm-lto2 run %t.o -enable-memprof-context-disambiguation \
+; RUN: opt -thinlto-bc %t/main.ll >%t/main.o
+; RUN: opt -thinlto-bc %t/foo.ll >%t/foo.o
+; RUN: llvm-lto2 run %t/main.o %t/foo.o -enable-memprof-context-disambiguation \
 ; RUN:	-supports-hot-cold-new \
-; RUN:	-r=%t.o,main,plx \
-; RUN:	-r=%t.o,_Znam, \
+; RUN:	-r=%t/main.o,main,plx \
+; RUN:	-r=%t/main.o,bar,plx \
+; RUN:	-r=%t/main.o,foo, \
+; RUN:	-r=%t/main.o,_Znam, \
+; RUN:	-r=%t/foo.o,foo,plx \
+; RUN:	-r=%t/foo.o,_Znam, \
 ; RUN:	-memprof-dump-ccg \
 ; RUN:	 -save-temps \
 ; RUN:	-o %t.out 2>&1 | FileCheck %s --check-prefix=DUMP
 ; DUMP: Callsite Context Graph:
 
-; RUN: llvm-dis %t.out.1.0.preopt.bc -o - | FileCheck %s --check-prefix=IR
+; RUN: llvm-dis %t.out.1.3.import.bc -o - | FileCheck %s --check-prefix=IR
+; IR: @main()
+; IR: !memprof {{.*}} !callsite
+; IR: @_Znam(i64 0) #[[ATTR:[0-9]+]]
+; IR: @bar()
 ; IR: !memprof {{.*}} !callsite
-; IR: "memprof"="cold"
+; IR: @_Znam(i64 0) #[[ATTR:[0-9]+]]
+; IR: attributes #[[ATTR]] = { "memprof"="cold" }
 
 ;; Next check without -supports-hot-cold-new, we should not perform
 ;; context disambiguation, and we should strip memprof metadata and
 ;; attributes before optimization.
-; RUN: llvm-lto2 run %t.o -enable-memprof-context-disambiguation \
-; RUN:	-r=%t.o,main,plx \
-; RUN:	-r=%t.o,_Znam, \
+; RUN: llvm-lto2 run %t/main.o %t/foo.o -enable-memprof-context-disambiguation \
+; RUN:	-r=%t/main.o,main,plx \
+; RUN:	-r=%t/main.o,bar,plx \
+; RUN:	-r=%t/main.o,foo, \
+; RUN:	-r=%t/main.o,_Znam, \
+; RUN:	-r=%t/foo.o,foo,plx \
+; RUN:	-r=%t/foo.o,_Znam, \
 ; RUN:	-memprof-dump-ccg \
 ; RUN:	 -save-temps \
 ; RUN:	-o %t.out 2>&1 | FileCheck %s --allow-empty \
 ; RUN:  --implicit-check-not "Callsite Context Graph:"
 
-; RUN: llvm-dis %t.out.1.0.preopt.bc -o - | FileCheck %s \
+; RUN: llvm-dis %t.out.1.3.import.bc -o - | FileCheck %s \
 ; RUN: --implicit-check-not "!memprof" --implicit-check-not "!callsite" \
 ; RUN: --implicit-check-not "memprof"="cold"
 
-source_filename = "memprof-supports-hot-cold-new.ll"
+;--- main.ll
 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
 target triple = "x86_64-unknown-linux-gnu"
 
@@ -44,6 +60,13 @@
   ret i32 0
 }
 
+define void @bar() {
+  call void @foo()
+  ret void
+}
+
+declare void @foo()
+
 declare ptr @_Znam(i64)
 
 attributes #0 = { noinline optnone }
@@ -55,3 +78,25 @@
 !3 = !{!4, !"cold"}
 !4 = !{i64 9086428284934609951, i64 -5964873800580613432, i64 2732490490862098848, i64 -3421689549917153178}
 !5 = !{i64 9086428284934609951}
+
+;--- foo.ll
+target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+define i32 @foo() {
+entry:
+  %call = call ptr @_Znam(i64 0), !memprof !0, !callsite !5
+  %call2 = call ptr @_Znam(i64 0) #1
+  ret i32 0
+}
+
+declare ptr @_Znam(i64)
+
+attributes #1 = { "memprof"="cold" }
+
+!0 = !{!1, !3}
+!1 = !{!2, !"notcold"}
+!2 = !{i64 9086428284934609951, i64 -5964873800580613432, i64 2732490490862098848, i64 8632435727821051414}
+!3 = !{!4, !"cold"}
+!4 = !{i64 9086428284934609951, i64 -5964873800580613432, i64 2732490490862098848, i64 -3421689549917153178}
+!5 = !{i64 9086428284934609951}
Index: llvm/lib/LTO/LTOBackend.cpp
===
--- llvm/lib/LTO/LTOBackend.cpp
+++ llvm/lib/LTO/LTOBackend.cpp
@@ -565,8 +565,6 @@
   // the module, if applicable.
   Mod.setPartialSampleProfileRatio(CombinedIndex);
 
-  updateMemProfAttributes(Mod, CombinedIndex);
-
   updatePublicTypeTestCalls(Mod, CombinedIndex.withWholeProgramVisibility());
 
  

[clang] 642bd11 - [Headers][doc] Add "shift" intrinsic descriptions to avx2intrin.h

2023-05-10 Thread Paul Robinson via cfe-commits

Author: Paul Robinson
Date: 2023-05-10T13:14:41-07:00
New Revision: 642bd1123d05e594cd0ef1527516f421ac07c5a6

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

LOG: [Headers][doc] Add "shift" intrinsic descriptions to avx2intrin.h

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

Added: 


Modified: 
clang/lib/Headers/avx2intrin.h

Removed: 




diff  --git a/clang/lib/Headers/avx2intrin.h b/clang/lib/Headers/avx2intrin.h
index 33f24f2443b3a..1fbc4edafbd7f 100644
--- a/clang/lib/Headers/avx2intrin.h
+++ b/clang/lib/Headers/avx2intrin.h
@@ -493,108 +493,404 @@ _mm256_sign_epi32(__m256i __a, __m256i __b)
 return (__m256i)__builtin_ia32_psignd256((__v8si)__a, (__v8si)__b);
 }
 
+/// Shifts each 128-bit half of the 256-bit integer vector \a a left by
+///\a imm bytes, shifting in zero bytes, and returns the result. If \a imm
+///is greater than 15, the returned result is all zeroes.
+///
+/// \headerfile 
+///
+/// \code
+/// __m256i _mm256_slli_si256(__m256i a, const int imm);
+/// \endcode
+///
+/// This intrinsic corresponds to the \c VPSLLDQ instruction.
+///
+/// \param a
+///A 256-bit integer vector to be shifted.
+/// \param imm
+/// An unsigned immediate value specifying the shift count (in bytes).
+/// \returns A 256-bit integer vector containing the result.
 #define _mm256_slli_si256(a, imm) \
   ((__m256i)__builtin_ia32_pslldqi256_byteshift((__v4di)(__m256i)(a), 
(int)(imm)))
 
+/// Shifts each 128-bit half of the 256-bit integer vector \a a left by
+///\a imm bytes, shifting in zero bytes, and returns the result. If \a imm
+///is greater than 15, the returned result is all zeroes.
+///
+/// \headerfile 
+///
+/// \code
+/// __m256i _mm256_bslli_epi128(__m256i a, const int imm);
+/// \endcode
+///
+/// This intrinsic corresponds to the \c VPSLLDQ instruction.
+///
+/// \param a
+///A 256-bit integer vector to be shifted.
+/// \param imm
+///An unsigned immediate value specifying the shift count (in bytes).
+/// \returns A 256-bit integer vector containing the result.
 #define _mm256_bslli_epi128(a, imm) \
   ((__m256i)__builtin_ia32_pslldqi256_byteshift((__v4di)(__m256i)(a), 
(int)(imm)))
 
+/// Shifts each 16-bit element of the 256-bit vector of [16 x i16] in \a __a
+///left by \a __count bits, shifting in zero bits, and returns the result.
+///If \a __count is greater than 15, the returned result is all zeroes.
+///
+/// \headerfile 
+///
+/// This intrinsic corresponds to the \c VPSLLW instruction.
+///
+/// \param __a
+///A 256-bit vector of [16 x i16] to be shifted.
+/// \param __count
+///An unsigned integer value specifying the shift count (in bits).
+/// \returns A 256-bit vector of [16 x i16] containing the result.
 static __inline__ __m256i __DEFAULT_FN_ATTRS256
 _mm256_slli_epi16(__m256i __a, int __count)
 {
   return (__m256i)__builtin_ia32_psllwi256((__v16hi)__a, __count);
 }
 
+/// Shifts each 16-bit element of the 256-bit vector of [16 x i16] in \a __a
+///left by the number of bits specified by the lower 64 bits of \a __count,
+///shifting in zero bits, and returns the result. If \a __count is greater
+///than 15, the returned result is all zeroes.
+///
+/// \headerfile 
+///
+/// This intrinsic corresponds to the \c VPSLLW instruction.
+///
+/// \param __a
+///A 256-bit vector of [16 x i16] to be shifted.
+/// \param __count
+///A 128-bit vector of [2 x i64] whose lower element gives the unsigned
+///shift count (in bits). The upper element is ignored.
+/// \returns A 256-bit vector of [16 x i16] containing the result.
 static __inline__ __m256i __DEFAULT_FN_ATTRS256
 _mm256_sll_epi16(__m256i __a, __m128i __count)
 {
   return (__m256i)__builtin_ia32_psllw256((__v16hi)__a, (__v8hi)__count);
 }
 
+/// Shifts each 32-bit element of the 256-bit vector of [8 x i32] in \a __a
+///left by \a __count bits, shifting in zero bits, and returns the result.
+///If \a __count is greater than 31, the returned result is all zeroes.
+///
+/// \headerfile 
+///
+/// This intrinsic corresponds to the \c VPSLLD instruction.
+///
+/// \param __a
+///A 256-bit vector of [8 x i32] to be shifted.
+/// \param __count
+///An unsigned integer value specifying the shift count (in bits).
+/// \returns A 256-bit vector of [8 x i32] containing the result.
 static __inline__ __m256i __DEFAULT_FN_ATTRS256
 _mm256_slli_epi32(__m256i __a, int __count)
 {
   return (__m256i)__builtin_ia32_pslldi256((__v8si)__a, __count);
 }
 
+/// Shifts each 32-bit element of the 256-bit vector of [8 x i32] in \a __a
+///left by the number of bits given in the lower 64 bits of \a __count,
+///shifting in zero bits, and returns the result. If \a __count is greater
+///than 31, the returned 

[PATCH] D150278: [Headers][doc] Add "shift" intrinsic descriptions to avx2intrin.h

2023-05-10 Thread Paul Robinson 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 rG642bd1123d05: [Headers][doc] Add shift intrinsic 
descriptions to avx2intrin.h (authored by probinson).
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150278

Files:
  clang/lib/Headers/avx2intrin.h

Index: clang/lib/Headers/avx2intrin.h
===
--- clang/lib/Headers/avx2intrin.h
+++ clang/lib/Headers/avx2intrin.h
@@ -493,108 +493,404 @@
 return (__m256i)__builtin_ia32_psignd256((__v8si)__a, (__v8si)__b);
 }
 
+/// Shifts each 128-bit half of the 256-bit integer vector \a a left by
+///\a imm bytes, shifting in zero bytes, and returns the result. If \a imm
+///is greater than 15, the returned result is all zeroes.
+///
+/// \headerfile 
+///
+/// \code
+/// __m256i _mm256_slli_si256(__m256i a, const int imm);
+/// \endcode
+///
+/// This intrinsic corresponds to the \c VPSLLDQ instruction.
+///
+/// \param a
+///A 256-bit integer vector to be shifted.
+/// \param imm
+/// An unsigned immediate value specifying the shift count (in bytes).
+/// \returns A 256-bit integer vector containing the result.
 #define _mm256_slli_si256(a, imm) \
   ((__m256i)__builtin_ia32_pslldqi256_byteshift((__v4di)(__m256i)(a), (int)(imm)))
 
+/// Shifts each 128-bit half of the 256-bit integer vector \a a left by
+///\a imm bytes, shifting in zero bytes, and returns the result. If \a imm
+///is greater than 15, the returned result is all zeroes.
+///
+/// \headerfile 
+///
+/// \code
+/// __m256i _mm256_bslli_epi128(__m256i a, const int imm);
+/// \endcode
+///
+/// This intrinsic corresponds to the \c VPSLLDQ instruction.
+///
+/// \param a
+///A 256-bit integer vector to be shifted.
+/// \param imm
+///An unsigned immediate value specifying the shift count (in bytes).
+/// \returns A 256-bit integer vector containing the result.
 #define _mm256_bslli_epi128(a, imm) \
   ((__m256i)__builtin_ia32_pslldqi256_byteshift((__v4di)(__m256i)(a), (int)(imm)))
 
+/// Shifts each 16-bit element of the 256-bit vector of [16 x i16] in \a __a
+///left by \a __count bits, shifting in zero bits, and returns the result.
+///If \a __count is greater than 15, the returned result is all zeroes.
+///
+/// \headerfile 
+///
+/// This intrinsic corresponds to the \c VPSLLW instruction.
+///
+/// \param __a
+///A 256-bit vector of [16 x i16] to be shifted.
+/// \param __count
+///An unsigned integer value specifying the shift count (in bits).
+/// \returns A 256-bit vector of [16 x i16] containing the result.
 static __inline__ __m256i __DEFAULT_FN_ATTRS256
 _mm256_slli_epi16(__m256i __a, int __count)
 {
   return (__m256i)__builtin_ia32_psllwi256((__v16hi)__a, __count);
 }
 
+/// Shifts each 16-bit element of the 256-bit vector of [16 x i16] in \a __a
+///left by the number of bits specified by the lower 64 bits of \a __count,
+///shifting in zero bits, and returns the result. If \a __count is greater
+///than 15, the returned result is all zeroes.
+///
+/// \headerfile 
+///
+/// This intrinsic corresponds to the \c VPSLLW instruction.
+///
+/// \param __a
+///A 256-bit vector of [16 x i16] to be shifted.
+/// \param __count
+///A 128-bit vector of [2 x i64] whose lower element gives the unsigned
+///shift count (in bits). The upper element is ignored.
+/// \returns A 256-bit vector of [16 x i16] containing the result.
 static __inline__ __m256i __DEFAULT_FN_ATTRS256
 _mm256_sll_epi16(__m256i __a, __m128i __count)
 {
   return (__m256i)__builtin_ia32_psllw256((__v16hi)__a, (__v8hi)__count);
 }
 
+/// Shifts each 32-bit element of the 256-bit vector of [8 x i32] in \a __a
+///left by \a __count bits, shifting in zero bits, and returns the result.
+///If \a __count is greater than 31, the returned result is all zeroes.
+///
+/// \headerfile 
+///
+/// This intrinsic corresponds to the \c VPSLLD instruction.
+///
+/// \param __a
+///A 256-bit vector of [8 x i32] to be shifted.
+/// \param __count
+///An unsigned integer value specifying the shift count (in bits).
+/// \returns A 256-bit vector of [8 x i32] containing the result.
 static __inline__ __m256i __DEFAULT_FN_ATTRS256
 _mm256_slli_epi32(__m256i __a, int __count)
 {
   return (__m256i)__builtin_ia32_pslldi256((__v8si)__a, __count);
 }
 
+/// Shifts each 32-bit element of the 256-bit vector of [8 x i32] in \a __a
+///left by the number of bits given in the lower 64 bits of \a __count,
+///shifting in zero bits, and returns the result. If \a __count is greater
+///than 31, the returned result is all zeroes.
+///
+/// \headerfile 
+///
+/// This intrinsic corresponds to the \c VPSLLD instruction.
+///
+/// \param __a
+///A 256-bit vector of [8 x i32] to be shifted.
+/// 

[PATCH] D150209: [clang][Interp] Add more shift error checking

2023-05-10 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder updated this revision to Diff 521082.

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

https://reviews.llvm.org/D150209

Files:
  clang/lib/AST/Interp/Integral.h
  clang/lib/AST/Interp/Interp.h
  clang/test/AST/Interp/shifts.cpp


Index: clang/test/AST/Interp/shifts.cpp
===
--- clang/test/AST/Interp/shifts.cpp
+++ clang/test/AST/Interp/shifts.cpp
@@ -152,4 +152,21 @@
   constexpr signed int R = (sizeof(unsigned) * 8) + 1;
   constexpr decltype(L) M  = (R > 32 && R < 64) ?  L << R : 0;
   constexpr decltype(L) M2 = (R > 32 && R < 64) ?  L >> R : 0;
+
+
+  constexpr int signedShift() { // cxx17-error {{never produces a constant 
expression}} \
+// ref-cxx17-error {{never produces a constant 
expression}}
+return 1024 << 31; // cxx17-warning {{signed shift result}} \
+   // ref-cxx17-warning {{signed shift result}} \
+   // cxx17-note {{signed left shift discards bits}} \
+   // ref-cxx17-note {{signed left shift discards bits}}
+  }
+
+  constexpr int negativeShift() { // cxx17-error {{never produces a constant 
expression}} \
+  // ref-cxx17-error {{never produces a 
constant expression}}
+return -1 << 2; // cxx17-warning {{shifting a negative signed value is 
undefined}} \
+// ref-cxx17-warning {{shifting a negative signed value is 
undefined}} \
+// cxx17-note {{left shift of negative value -1}} \
+// ref-cxx17-note {{left shift of negative value -1}}
+  }
 };
Index: clang/lib/AST/Interp/Interp.h
===
--- clang/lib/AST/Interp/Interp.h
+++ clang/lib/AST/Interp/Interp.h
@@ -109,8 +109,9 @@
 bool CheckCtorCall(InterpState , CodePtr OpPC, const Pointer );
 
 /// Checks if the shift operation is legal.
-template 
-bool CheckShift(InterpState , CodePtr OpPC, const RT , unsigned Bits) {
+template 
+bool CheckShift(InterpState , CodePtr OpPC, const LT , const RT ,
+unsigned Bits) {
   if (RHS.isNegative()) {
 const SourceInfo  = S.Current->getSource(OpPC);
 S.CCEDiag(Loc, diag::note_constexpr_negative_shift) << RHS.toAPSInt();
@@ -126,6 +127,20 @@
 S.CCEDiag(E, diag::note_constexpr_large_shift) << Val << Ty << Bits;
 return false;
   }
+
+  if (LHS.isSigned() && !S.getLangOpts().CPlusPlus20) {
+const Expr *E = S.Current->getExpr(OpPC);
+// C++11 [expr.shift]p2: A signed left shift must have a non-negative
+// operand, and must not overflow the corresponding unsigned type.
+if (LHS.isNegative())
+  S.CCEDiag(E, diag::note_constexpr_lshift_of_negative) << LHS.toAPSInt();
+else if (LHS.toUnsigned().countLeadingZeros() < static_cast(RHS))
+  S.CCEDiag(E, diag::note_constexpr_lshift_discards);
+  }
+
+  // C++2a [expr.shift]p2: E1 << E2 is the unique value congruent to
+  // E1 x 2^E2 module 2^N.
+
   return true;
 }
 
@@ -1612,7 +1627,7 @@
   const auto  = S.Stk.pop();
   const unsigned Bits = LHS.bitWidth();
 
-  if (!CheckShift(S, OpPC, RHS, Bits))
+  if (!CheckShift(S, OpPC, LHS, RHS, Bits))
 return false;
 
   Integral R;
@@ -1629,7 +1644,7 @@
   const auto  = S.Stk.pop();
   const unsigned Bits = LHS.bitWidth();
 
-  if (!CheckShift(S, OpPC, RHS, Bits))
+  if (!CheckShift(S, OpPC, LHS, RHS, Bits))
 return false;
 
   Integral R;
Index: clang/lib/AST/Interp/Integral.h
===
--- clang/lib/AST/Interp/Integral.h
+++ clang/lib/AST/Interp/Integral.h
@@ -127,7 +127,11 @@
 return Compare(V, RHS.V);
   }
 
-  unsigned countLeadingZeros() const { return llvm::countl_zero(V); }
+  unsigned countLeadingZeros() const {
+if constexpr (!Signed)
+  return llvm::countl_zero(V);
+llvm_unreachable("Don't call countLeadingZeros() on signed types.");
+  }
 
   Integral truncate(unsigned TruncBits) const {
 if (TruncBits >= Bits)


Index: clang/test/AST/Interp/shifts.cpp
===
--- clang/test/AST/Interp/shifts.cpp
+++ clang/test/AST/Interp/shifts.cpp
@@ -152,4 +152,21 @@
   constexpr signed int R = (sizeof(unsigned) * 8) + 1;
   constexpr decltype(L) M  = (R > 32 && R < 64) ?  L << R : 0;
   constexpr decltype(L) M2 = (R > 32 && R < 64) ?  L >> R : 0;
+
+
+  constexpr int signedShift() { // cxx17-error {{never produces a constant expression}} \
+// ref-cxx17-error {{never produces a constant expression}}
+return 1024 << 31; // cxx17-warning {{signed shift result}} \
+   // ref-cxx17-warning {{signed shift result}} \
+   // cxx17-note {{signed left shift discards bits}} \
+   // ref-cxx17-note {{signed left shift discards bits}}
+  }
+
+  constexpr int negativeShift() { // cxx17-error {{never 

[PATCH] D150209: [clang][Interp] Add more shift error checking

2023-05-10 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder updated this revision to Diff 521078.

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

https://reviews.llvm.org/D150209

Files:
  clang/lib/AST/Interp/Integral.h
  clang/lib/AST/Interp/Interp.h
  clang/test/AST/Interp/shifts.cpp


Index: clang/test/AST/Interp/shifts.cpp
===
--- clang/test/AST/Interp/shifts.cpp
+++ clang/test/AST/Interp/shifts.cpp
@@ -152,4 +152,21 @@
   constexpr signed int R = (sizeof(unsigned) * 8) + 1;
   constexpr decltype(L) M  = (R > 32 && R < 64) ?  L << R : 0;
   constexpr decltype(L) M2 = (R > 32 && R < 64) ?  L >> R : 0;
+
+
+  constexpr int signedShift() { // cxx17-error {{never produces a constant 
expression}} \
+// ref-cxx17-error {{never produces a constant 
expression}}
+return 1024 << 31; // cxx17-warning {{signed shift result}} \
+   // ref-cxx17-warning {{signed shift result}} \
+   // cxx17-note {{signed left shift discards bits}} \
+   // ref-cxx17-note {{signed left shift discards bits}}
+  }
+
+  constexpr int negativeShift() { // cxx17-error {{never produces a constant 
expression}} \
+  // ref-cxx17-error {{never produces a 
constant expression}}
+return -1 << 2; // cxx17-warning {{shifting a negative signed value is 
undefined}} \
+// ref-cxx17-warning {{shifting a negative signed value is 
undefined}} \
+// cxx17-note {{left shift of negative value -1}} \
+// ref-cxx17-note {{left shift of negative value -1}}
+  }
 };
Index: clang/lib/AST/Interp/Interp.h
===
--- clang/lib/AST/Interp/Interp.h
+++ clang/lib/AST/Interp/Interp.h
@@ -109,8 +109,9 @@
 bool CheckCtorCall(InterpState , CodePtr OpPC, const Pointer );
 
 /// Checks if the shift operation is legal.
-template 
-bool CheckShift(InterpState , CodePtr OpPC, const RT , unsigned Bits) {
+template 
+bool CheckShift(InterpState , CodePtr OpPC, const LT , const RT ,
+unsigned Bits) {
   if (RHS.isNegative()) {
 const SourceInfo  = S.Current->getSource(OpPC);
 S.CCEDiag(Loc, diag::note_constexpr_negative_shift) << RHS.toAPSInt();
@@ -125,6 +126,16 @@
 QualType Ty = E->getType();
 S.CCEDiag(E, diag::note_constexpr_large_shift) << Val << Ty << Bits;
 return false;
+  } else if (LHS.isSigned() && !S.getLangOpts().CPlusPlus20) {
+const Expr *E = S.Current->getExpr(OpPC);
+// C++11 [expr.shift]p2: A signed left shift must have a non-negative
+// operand, and must not overflow the corresponding unsigned type.
+// C++2a [expr.shift]p2: E1 << E2 is the unique value congruent to
+// E1 x 2^E2 module 2^N.
+if (LHS.isNegative())
+  S.CCEDiag(E, diag::note_constexpr_lshift_of_negative) << LHS.toAPSInt();
+else if (LHS.toUnsigned().countLeadingZeros() < static_cast(RHS))
+  S.CCEDiag(E, diag::note_constexpr_lshift_discards);
   }
   return true;
 }
@@ -1612,7 +1623,7 @@
   const auto  = S.Stk.pop();
   const unsigned Bits = LHS.bitWidth();
 
-  if (!CheckShift(S, OpPC, RHS, Bits))
+  if (!CheckShift(S, OpPC, LHS, RHS, Bits))
 return false;
 
   Integral R;
@@ -1629,7 +1640,7 @@
   const auto  = S.Stk.pop();
   const unsigned Bits = LHS.bitWidth();
 
-  if (!CheckShift(S, OpPC, RHS, Bits))
+  if (!CheckShift(S, OpPC, LHS, RHS, Bits))
 return false;
 
   Integral R;
Index: clang/lib/AST/Interp/Integral.h
===
--- clang/lib/AST/Interp/Integral.h
+++ clang/lib/AST/Interp/Integral.h
@@ -127,7 +127,11 @@
 return Compare(V, RHS.V);
   }
 
-  unsigned countLeadingZeros() const { return llvm::countl_zero(V); }
+  unsigned countLeadingZeros() const {
+if constexpr (!Signed)
+  return llvm::countl_zero(V);
+llvm_unreachable("Don't call countLeadingZeros() on signed types.");
+  }
 
   Integral truncate(unsigned TruncBits) const {
 if (TruncBits >= Bits)


Index: clang/test/AST/Interp/shifts.cpp
===
--- clang/test/AST/Interp/shifts.cpp
+++ clang/test/AST/Interp/shifts.cpp
@@ -152,4 +152,21 @@
   constexpr signed int R = (sizeof(unsigned) * 8) + 1;
   constexpr decltype(L) M  = (R > 32 && R < 64) ?  L << R : 0;
   constexpr decltype(L) M2 = (R > 32 && R < 64) ?  L >> R : 0;
+
+
+  constexpr int signedShift() { // cxx17-error {{never produces a constant expression}} \
+// ref-cxx17-error {{never produces a constant expression}}
+return 1024 << 31; // cxx17-warning {{signed shift result}} \
+   // ref-cxx17-warning {{signed shift result}} \
+   // cxx17-note {{signed left shift discards bits}} \
+   // ref-cxx17-note {{signed left shift discards bits}}
+  }
+
+  constexpr int 

[PATCH] D150292: [clang][modules] Serialize `Module::DefinitionLoc`

2023-05-10 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 created this revision.
jansvoboda11 added reviewers: benlangmuir, Bigcheese.
Herald added a subscriber: ributzka.
Herald added a project: All.
jansvoboda11 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This is a prep patch for avoiding the quadratic number of calls to 
`HeaderSearch::lookupModule()` in `ASTReader` for each (transitively) loaded 
PCM file. (Specifically in the context of `clang-scan-deps`).

This patch explicitly serializes `Module::DefinitionLoc` so that we can stop 
relying on it being filled by the module map parser. This change also required 
change to the module map parser, where we used the absence of `DefinitionLoc` 
to determine whether a file came from a PCM file. We also need to make sure we 
consider the "containing" module map affecting when writing a PCM, so that it's 
not stripped during serialization, which ensures `DefinitionLoc` still ends up 
pointing to the correct offset. This is intended to be a NFC change.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D150292

Files:
  clang/include/clang/Serialization/ASTBitCodes.h
  clang/lib/Lex/ModuleMap.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp

Index: clang/lib/Serialization/ASTWriter.cpp
===
--- clang/lib/Serialization/ASTWriter.cpp
+++ clang/lib/Serialization/ASTWriter.cpp
@@ -201,7 +201,9 @@
 CB(F);
 FileID FID = SourceMgr.translateFile(F);
 SourceLocation Loc = SourceMgr.getIncludeLoc(FID);
-while (Loc.isValid()) {
+// The include location of inferred module maps can point into the header
+// file that triggered the inferring. Cut off the walk if that's the case.
+while (Loc.isValid() && isModuleMap(SourceMgr.getFileCharacteristic(Loc))) {
   FID = SourceMgr.getFileID(Loc);
   CB(*SourceMgr.getFileEntryRefForID(FID));
   Loc = SourceMgr.getIncludeLoc(FID);
@@ -210,11 +212,18 @@
 
   auto ProcessModuleOnce = [&](const Module *M) {
 for (const Module *Mod = M; Mod; Mod = Mod->Parent)
-  if (ProcessedModules.insert(Mod).second)
+  if (ProcessedModules.insert(Mod).second) {
+auto Insert = [&](FileEntryRef F) { ModuleMaps.insert(F); };
+// The containing module map is affecting, because it's being pointed
+// into by Module::DefinitionLoc.
+if (auto ModuleMapFile = MM.getContainingModuleMapFile(Mod))
+  ForIncludeChain(*ModuleMapFile, Insert);
+// For inferred modules, the module map that allowed inferring is not in
+// the include chain of the virtual containing module map file. It did
+// affect the compilation, though.
 if (auto ModuleMapFile = MM.getModuleMapFileForUniquing(Mod))
-  ForIncludeChain(*ModuleMapFile, [&](FileEntryRef F) {
-ModuleMaps.insert(F);
-  });
+  ForIncludeChain(*ModuleMapFile, Insert);
+  }
   };
 
   for (const Module *CurrentModule : ModulesToProcess) {
@@ -2720,6 +2729,7 @@
   Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // ID
   Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Parent
   Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 4)); // Kind
+  Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // Definition location
   Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // IsFramework
   Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // IsExplicit
   Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // IsSystem
@@ -2820,12 +2830,16 @@
   ParentID = SubmoduleIDs[Mod->Parent];
 }
 
+uint64_t DefinitionLoc =
+SourceLocationEncoding::encode(getAdjustedLocation(Mod->DefinitionLoc));
+
 // Emit the definition of the block.
 {
   RecordData::value_type Record[] = {SUBMODULE_DEFINITION,
  ID,
  ParentID,
  (RecordData::value_type)Mod->Kind,
+ DefinitionLoc,
  Mod->IsFramework,
  Mod->IsExplicit,
  Mod->IsSystem,
Index: clang/lib/Serialization/ASTReader.cpp
===
--- clang/lib/Serialization/ASTReader.cpp
+++ clang/lib/Serialization/ASTReader.cpp
@@ -5599,7 +5599,7 @@
   break;
 
 case SUBMODULE_DEFINITION: {
-  if (Record.size() < 12)
+  if (Record.size() < 13)
 return llvm::createStringError(std::errc::illegal_byte_sequence,
"malformed module definition");
 
@@ -5608,6 +5608,7 @@
   SubmoduleID GlobalID = getGlobalSubmoduleID(F, Record[Idx++]);
   SubmoduleID Parent = getGlobalSubmoduleID(F, Record[Idx++]);
   Module::ModuleKind Kind = 

[PATCH] D150291: [Clang] Rename internal type identifier(s) for `__bf16` to `BF16Ty`

2023-05-10 Thread M. Zeeshan Siddiqui via Phabricator via cfe-commits
codemzs created this revision.
codemzs added reviewers: tahonermann, erichkeane, stuij.
Herald added subscribers: mattd, gchakrabarti, asavonic, ctetreau, kerbowa, 
arphaman, kristof.beyls, jvesely.
Herald added a project: All.
codemzs requested review of this revision.
Herald added subscribers: lldb-commits, cfe-commits, jholewinski.
Herald added projects: clang, LLDB.

  This change updates internal type identifiers for `__bf16` from
  `BFloat16Ty` to `BF16Ty` and renames any associated variables and
  function names accordingly. The rationale for this change comes from
  the review feedback on https://reviews.llvm.org/D149573, which pointed
  out the confusing naming issues between `__bf16` and the upcoming
  `std::bfloat16_t`. This modification only affects LLVM/Clang specific
  code and does not interfere with target-specific code, such as
  NeonEmitters, SVE Type, AArch64, etc. The existing names are being
  updated to avoid potential mistakes and enhance clarity in the codebase.
  The change is made in a separate patch, as suggested in the review, to
  ensure a smooth integration of std::bfloat16_t support.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D150291

Files:
  clang/include/clang-c/Index.h
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/BuiltinTypes.def
  clang/include/clang/AST/Type.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/Specifiers.h
  clang/include/clang/Basic/TargetInfo.h
  clang/include/clang/Basic/arm_neon_incl.td
  clang/include/clang/Sema/DeclSpec.h
  clang/include/clang/Serialization/ASTBitCodes.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/MicrosoftMangle.cpp
  clang/lib/AST/NSAPI.cpp
  clang/lib/AST/PrintfFormatString.cpp
  clang/lib/AST/Type.cpp
  clang/lib/AST/TypeLoc.cpp
  clang/lib/Basic/TargetInfo.cpp
  clang/lib/Basic/Targets/AArch64.cpp
  clang/lib/Basic/Targets/AArch64.h
  clang/lib/Basic/Targets/AMDGPU.cpp
  clang/lib/Basic/Targets/AMDGPU.h
  clang/lib/Basic/Targets/ARM.cpp
  clang/lib/Basic/Targets/ARM.h
  clang/lib/Basic/Targets/NVPTX.cpp
  clang/lib/Basic/Targets/NVPTX.h
  clang/lib/Basic/Targets/X86.cpp
  clang/lib/Basic/Targets/X86.h
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/CodeGenTypes.cpp
  clang/lib/CodeGen/ItaniumCXXABI.cpp
  clang/lib/CodeGen/TargetInfo.cpp
  clang/lib/Index/USRGeneration.cpp
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/ParseExprCXX.cpp
  clang/lib/Sema/DeclSpec.cpp
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaCast.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaTemplateVariadic.cpp
  clang/lib/Sema/SemaType.cpp
  clang/lib/Serialization/ASTCommon.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/tools/libclang/CXType.cpp
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp

Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -4909,7 +4909,7 @@
 case clang::BuiltinType::Float128:
 case clang::BuiltinType::Double:
 case clang::BuiltinType::LongDouble:
-case clang::BuiltinType::BFloat16:
+case clang::BuiltinType::BF16:
 case clang::BuiltinType::Ibm128:
   return lldb::eEncodingIEEE754;
 
Index: clang/tools/libclang/CXType.cpp
===
--- clang/tools/libclang/CXType.cpp
+++ clang/tools/libclang/CXType.cpp
@@ -618,7 +618,7 @@
 TKIND(Pipe);
 TKIND(Attributed);
 TKIND(BTFTagAttributed);
-TKIND(BFloat16);
+TKIND(BF16);
 #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) TKIND(Id);
 #include "clang/Basic/OpenCLImageTypes.def"
 #undef IMAGE_TYPE
Index: clang/lib/Serialization/ASTReader.cpp
===
--- clang/lib/Serialization/ASTReader.cpp
+++ clang/lib/Serialization/ASTReader.cpp
@@ -7026,8 +7026,8 @@
 case PREDEF_TYPE_INT128_ID:
   T = Context.Int128Ty;
   break;
-case PREDEF_TYPE_BFLOAT16_ID:
-  T = Context.BFloat16Ty;
+case PREDEF_TYPE_BF16_ID:
+  T = Context.BF16Ty;
   break;
 case PREDEF_TYPE_HALF_ID:
   T = Context.HalfTy;
Index: clang/lib/Serialization/ASTCommon.cpp
===
--- clang/lib/Serialization/ASTCommon.cpp
+++ clang/lib/Serialization/ASTCommon.cpp
@@ -270,8 +270,8 @@
   case BuiltinType::OMPIterator:
 ID = PREDEF_TYPE_OMP_ITERATOR;
 break;
-  case BuiltinType::BFloat16:
-ID = PREDEF_TYPE_BFLOAT16_ID;
+  case BuiltinType::BF16:
+ID = PREDEF_TYPE_BF16_ID;
 break;
   }
 
Index: clang/lib/Sema/SemaType.cpp
===
--- 

[PATCH] D149718: [NFC][Clang] Fix Coverity issues of copy without assign

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



Comment at: clang/include/clang/Sema/Sema.h:1786
 SemaDiagnosticBuilder(SemaDiagnosticBuilder &);
+SemaDiagnosticBuilder =(SemaDiagnosticBuilder &);
 SemaDiagnosticBuilder(const SemaDiagnosticBuilder &) = default;

tahonermann wrote:
> Manna wrote:
> > tahonermann wrote:
> > > Since this class declares a move constructor, the declaration of the 
> > > implicit move assignment operator is inhibited and the implicitly 
> > > declared assignment operator is defined as deleted. This change declares 
> > > a move assignment operator but doesn't define it (perhaps `= delete` was 
> > > intended?). If support for assignment is not desired, then I think a 
> > > declaration of a deleted copy assignment operator is all that is needed 
> > > (matching the change made for `Strategy` below). Otherwise, I think a 
> > > defaulted copy assignment operator should be declared and a move 
> > > assignment operator should be defined that implements the same behavior 
> > > as the move constructor.
> > Thanks @tahonermann for the comments. 
> > 
> > >> think a defaulted copy assignment operator should be declared and a move 
> > >> assignment operator should be defined that implements the same behavior 
> > >> as the move constructor.
> > 
> > I have updated patch based on further analysis and my understanding. This 
> > seems reasonable to me.
> This change still declares a move assignment operator, but doesn't provide a 
> definition. The move constructor is implemented in `clang/lib/Sema/Sema.cpp`, 
> so I would expect to see the move assignment operator definition provided 
> there as well.
Thanks @tahonermann for the comments. I have removed `Sema.h`  change from the 
current patch. I will address it in a separate review pull request. Need to 
look into this more.  


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

https://reviews.llvm.org/D149718

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


[PATCH] D146520: [clang-tidy] Fix checks filter with warnings-as-errors

2023-05-10 Thread kiwixz via Phabricator via cfe-commits
kiwixz added a comment.

Ping.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146520

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


[PATCH] D149718: [NFC][Clang] Fix Coverity issues of copy without assign

2023-05-10 Thread Soumi Manna via Phabricator via cfe-commits
Manna updated this revision to Diff 521073.
Manna marked 2 inline comments as done.
Manna added a comment.

I have updated patch


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

https://reviews.llvm.org/D149718

Files:
  clang/include/clang/Analysis/BodyFarm.h
  clang/include/clang/Sema/ParsedAttr.h
  clang/lib/Analysis/UnsafeBufferUsage.cpp
  clang/lib/Serialization/ASTWriterStmt.cpp


Index: clang/lib/Serialization/ASTWriterStmt.cpp
===
--- clang/lib/Serialization/ASTWriterStmt.cpp
+++ clang/lib/Serialization/ASTWriterStmt.cpp
@@ -42,6 +42,7 @@
   Code(serialization::STMT_NULL_PTR), AbbrevToUse(0) {}
 
 ASTStmtWriter(const ASTStmtWriter&) = delete;
+ASTStmtWriter =(const ASTStmtWriter &) = delete;
 
 uint64_t Emit() {
   assert(Code != serialization::STMT_NULL_PTR &&
Index: clang/lib/Analysis/UnsafeBufferUsage.cpp
===
--- clang/lib/Analysis/UnsafeBufferUsage.cpp
+++ clang/lib/Analysis/UnsafeBufferUsage.cpp
@@ -762,7 +762,9 @@
 public:
   Strategy() = default;
   Strategy(const Strategy &) = delete; // Let's avoid copies.
+  Strategy =(const Strategy &) = delete;
   Strategy(Strategy &&) = default;
+  Strategy =(Strategy &&) = default;
 
   void set(const VarDecl *VD, Kind K) { Map[VD] = K; }
 
Index: clang/include/clang/Sema/ParsedAttr.h
===
--- clang/include/clang/Sema/ParsedAttr.h
+++ clang/include/clang/Sema/ParsedAttr.h
@@ -696,11 +696,13 @@
   AttributePool(AttributeFactory ) : Factory(factory) {}
 
   AttributePool(const AttributePool &) = delete;
+  AttributePool =(const AttributePool &) = delete;
 
   ~AttributePool() { Factory.reclaimPool(*this); }
 
   /// Move the given pool's allocations to this pool.
   AttributePool(AttributePool &) = default;
+  AttributePool =(AttributePool &) = default;
 
   AttributeFactory () const { return Factory; }
 
@@ -912,6 +914,7 @@
 public:
   ParsedAttributes(AttributeFactory ) : pool(factory) {}
   ParsedAttributes(const ParsedAttributes &) = delete;
+  ParsedAttributes =(const ParsedAttributes &) = delete;
 
   AttributePool () const { return pool; }
 
Index: clang/include/clang/Analysis/BodyFarm.h
===
--- clang/include/clang/Analysis/BodyFarm.h
+++ clang/include/clang/Analysis/BodyFarm.h
@@ -40,6 +40,9 @@
   /// Remove copy constructor to avoid accidental copying.
   BodyFarm(const BodyFarm ) = delete;
 
+  /// Delete copy assignment operator.
+  BodyFarm =(const BodyFarm ) = delete;
+
 private:
   typedef llvm::DenseMap> BodyMap;
 


Index: clang/lib/Serialization/ASTWriterStmt.cpp
===
--- clang/lib/Serialization/ASTWriterStmt.cpp
+++ clang/lib/Serialization/ASTWriterStmt.cpp
@@ -42,6 +42,7 @@
   Code(serialization::STMT_NULL_PTR), AbbrevToUse(0) {}
 
 ASTStmtWriter(const ASTStmtWriter&) = delete;
+ASTStmtWriter =(const ASTStmtWriter &) = delete;
 
 uint64_t Emit() {
   assert(Code != serialization::STMT_NULL_PTR &&
Index: clang/lib/Analysis/UnsafeBufferUsage.cpp
===
--- clang/lib/Analysis/UnsafeBufferUsage.cpp
+++ clang/lib/Analysis/UnsafeBufferUsage.cpp
@@ -762,7 +762,9 @@
 public:
   Strategy() = default;
   Strategy(const Strategy &) = delete; // Let's avoid copies.
+  Strategy =(const Strategy &) = delete;
   Strategy(Strategy &&) = default;
+  Strategy =(Strategy &&) = default;
 
   void set(const VarDecl *VD, Kind K) { Map[VD] = K; }
 
Index: clang/include/clang/Sema/ParsedAttr.h
===
--- clang/include/clang/Sema/ParsedAttr.h
+++ clang/include/clang/Sema/ParsedAttr.h
@@ -696,11 +696,13 @@
   AttributePool(AttributeFactory ) : Factory(factory) {}
 
   AttributePool(const AttributePool &) = delete;
+  AttributePool =(const AttributePool &) = delete;
 
   ~AttributePool() { Factory.reclaimPool(*this); }
 
   /// Move the given pool's allocations to this pool.
   AttributePool(AttributePool &) = default;
+  AttributePool =(AttributePool &) = default;
 
   AttributeFactory () const { return Factory; }
 
@@ -912,6 +914,7 @@
 public:
   ParsedAttributes(AttributeFactory ) : pool(factory) {}
   ParsedAttributes(const ParsedAttributes &) = delete;
+  ParsedAttributes =(const ParsedAttributes &) = delete;
 
   AttributePool () const { return pool; }
 
Index: clang/include/clang/Analysis/BodyFarm.h
===
--- clang/include/clang/Analysis/BodyFarm.h
+++ clang/include/clang/Analysis/BodyFarm.h
@@ -40,6 +40,9 @@
   /// Remove copy constructor to avoid accidental copying.
   BodyFarm(const BodyFarm ) = delete;
 
+  /// Delete copy assignment operator.
+  BodyFarm =(const BodyFarm ) = delete;
+
 

[PATCH] D144999: [Clang][MC][MachO]Only emits compact-unwind format for "canonical" personality symbols. For the rest, use DWARFs.

2023-05-10 Thread Vy Nguyen via Phabricator via cfe-commits
oontvoo added a comment.

@int3 @thakis, et al - friendly   :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144999

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


[PATCH] D150285: Fix CRTP partial specialization instantiation crash.

2023-05-10 Thread Alexander Shaposhnikov via Phabricator via cfe-commits
alexander-shaposhnikov accepted this revision.
alexander-shaposhnikov added a comment.
This revision is now accepted and ready to land.

LG


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

https://reviews.llvm.org/D150285

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


[PATCH] D150285: Fix CRTP partial specialization instantiation crash.

2023-05-10 Thread Erich Keane via Phabricator via cfe-commits
erichkeane created this revision.
erichkeane added reviewers: alexander-shaposhnikov, clang-language-wg.
Herald added a project: All.
erichkeane requested review of this revision.

Fixes #60778.

When instantiating the body of a class template specialization that was
instantiated from a partial specialization, we were incorrectly
collecting template arguments from the primary template, which resulted
in the template arguments list being inaccurate.  In the example from
the issue, we were trying to substitute the boolean 'false' into the
type on Nested, which caused an assertion.


https://reviews.llvm.org/D150285

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Sema/SemaTemplateInstantiate.cpp
  clang/test/SemaTemplate/partial-spec-instantiate.cpp


Index: clang/test/SemaTemplate/partial-spec-instantiate.cpp
===
--- clang/test/SemaTemplate/partial-spec-instantiate.cpp
+++ clang/test/SemaTemplate/partial-spec-instantiate.cpp
@@ -134,3 +134,23 @@
 
   _Static_assert(S::value, "");
 }
+
+namespace GH60778 {
+  template  class ClassTemplate {
+  public:
+  template  class Nested {};
+  };
+
+  template  class Base {};
+
+  template <>
+  template 
+  class ClassTemplate<>::Nested : public Base::Nested> 
{};
+
+  void use() {
+// This should instantiate the body of Nested with the template arguments
+// from the Partial Specialization. This would previously get confused and 
+// get the template arguments from the primary template instead.
+ClassTemplate<>::Nested instantiation;
+  }
+}
Index: clang/lib/Sema/SemaTemplateInstantiate.cpp
===
--- clang/lib/Sema/SemaTemplateInstantiate.cpp
+++ clang/lib/Sema/SemaTemplateInstantiate.cpp
@@ -163,6 +163,14 @@
 assert(ClassTemplSpec->getSpecializedTemplate() && "No class template?");
 if (ClassTemplSpec->getSpecializedTemplate()->isMemberSpecialization())
   return Response::Done();
+
+// If this was instantiated from a partial template specialization, we need
+// to get the next level of declaration context from the partial
+// specialization, as the ClassTemplateSpecializationDecl's
+// DeclContext/LexicalDeclContext will be for the primary template.
+if (auto *InstFromPartialTempl = 
ClassTemplSpec->getSpecializedTemplateOrPartial()
+  .dyn_cast())
+  return 
Response::ChangeDecl(InstFromPartialTempl->getLexicalDeclContext());
   }
   return Response::UseNextDecl(ClassTemplSpec);
 }
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -391,6 +391,10 @@
   at the point where it is required. This fixes:
   (`#62224 `_) and
   (`#62596 `_)
+- Fix an assertion when instantiating the body of a Class Template 
Specialization
+  when it had been instantiated from a partial template specialization with 
different
+  template arguments on the containing class. This fixes:
+  (`#60778 `_).
 
 Bug Fixes to Compiler Builtins
 ^^


Index: clang/test/SemaTemplate/partial-spec-instantiate.cpp
===
--- clang/test/SemaTemplate/partial-spec-instantiate.cpp
+++ clang/test/SemaTemplate/partial-spec-instantiate.cpp
@@ -134,3 +134,23 @@
 
   _Static_assert(S::value, "");
 }
+
+namespace GH60778 {
+  template  class ClassTemplate {
+  public:
+  template  class Nested {};
+  };
+
+  template  class Base {};
+
+  template <>
+  template 
+  class ClassTemplate<>::Nested : public Base::Nested> {};
+
+  void use() {
+// This should instantiate the body of Nested with the template arguments
+// from the Partial Specialization. This would previously get confused and 
+// get the template arguments from the primary template instead.
+ClassTemplate<>::Nested instantiation;
+  }
+}
Index: clang/lib/Sema/SemaTemplateInstantiate.cpp
===
--- clang/lib/Sema/SemaTemplateInstantiate.cpp
+++ clang/lib/Sema/SemaTemplateInstantiate.cpp
@@ -163,6 +163,14 @@
 assert(ClassTemplSpec->getSpecializedTemplate() && "No class template?");
 if (ClassTemplSpec->getSpecializedTemplate()->isMemberSpecialization())
   return Response::Done();
+
+// If this was instantiated from a partial template specialization, we need
+// to get the next level of declaration context from the partial
+// specialization, as the ClassTemplateSpecializationDecl's
+// DeclContext/LexicalDeclContext will be for the primary template.
+if (auto *InstFromPartialTempl = ClassTemplSpec->getSpecializedTemplateOrPartial()
+  .dyn_cast())
+  return 

[PATCH] D150282: [Driver] -ftime-trace: derive trace file names from -o and -dumpdir

2023-05-10 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay created this revision.
MaskRay added reviewers: clang, jamieschmeiser, Whitney, Maetveis, dblaikie, 
scott.linder.
Herald added a project: All.
MaskRay requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Inspired by D133662 .
Close https://github.com/llvm/llvm-project/issues/57285

When -ftime-trace is specified and the driver performs both compilation and
linking phases, the trace files are currently placed in the temporary directory
(/tmp by default on *NIX). A more sensible behavior would be to derive the trace
file names from the -o option, similar to how GCC derives auxiliary and dump
file names. Use -dumpdir (D149193 ) to 
implement the -gsplit-dwarf like behavior.

The following script demonstrates the time trace filenames.

  #!/bin/sh -e
  PATH=/tmp/Rel/bin:$PATH# adapt according to your build 
directory
  mkdir -p d e f
  echo 'int main() {}' > d/a.c
  echo > d/b.c
  
  a() { rm $1 || exit 1; }
  
  clang -ftime-trace d/a.c d/b.c # previously /tmp/[ab]-*.json
  a a-a.json; a a-b.json
  clang -ftime-trace d/a.c d/b.c -o e/x  # previously /tmp/[ab]-*.json
  a e/x-a.json; a e/x-b.json
  clang -ftime-trace d/a.c d/b.c -o e/x -dumpdir f/
  a f/a.json; a f/b.json
  clang -ftime-trace=f d/a.c d/b.c -o e/x
  a f/a-*.json; a f/b-*.json
  
  clang -c -ftime-trace d/a.c d/b.c
  a a.json b.json
  clang -c -ftime-trace=f d/a.c d/b.c
  a f/a.json f/b.json
  
  clang -c -ftime-trace d/a.c -o e/xa.o
  a e/xa.json
  clang -c -ftime-trace d/a.c -o e/xa.o -dumpdir f/
  a f/a.json

The driver checks `-ftime-trace` and `-ftime-trace=`, infers the trace file
name, and passes `-ftime-trace=` to cc1. The `-ftime-trace` cc1 option is
removed.

This patch doesn't attempt to change offloading behavior (D133662 
).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D150282

Files:
  clang/include/clang/Driver/Compilation.h
  clang/include/clang/Driver/Options.td
  clang/include/clang/Frontend/FrontendOptions.h
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/ftime-trace.cpp
  clang/tools/driver/cc1_main.cpp

Index: clang/tools/driver/cc1_main.cpp
===
--- clang/tools/driver/cc1_main.cpp
+++ clang/tools/driver/cc1_main.cpp
@@ -213,9 +213,7 @@
   bool Success = CompilerInvocation::CreateFromArgs(Clang->getInvocation(),
 Argv, Diags, Argv0);
 
-  if (Clang->getFrontendOpts().TimeTrace ||
-  !Clang->getFrontendOpts().TimeTracePath.empty()) {
-Clang->getFrontendOpts().TimeTrace = 1;
+  if (!Clang->getFrontendOpts().TimeTracePath.empty()) {
 llvm::timeTraceProfilerInitialize(
 Clang->getFrontendOpts().TimeTraceGranularity, Argv0);
   }
@@ -257,16 +255,6 @@
   llvm::TimerGroup::clearAll();
 
   if (llvm::timeTraceProfilerEnabled()) {
-SmallString<128> Path(Clang->getFrontendOpts().OutputFile);
-llvm::sys::path::replace_extension(Path, "json");
-if (!Clang->getFrontendOpts().TimeTracePath.empty()) {
-  // replace the suffix to '.json' directly
-  SmallString<128> TracePath(Clang->getFrontendOpts().TimeTracePath);
-  if (llvm::sys::fs::is_directory(TracePath))
-llvm::sys::path::append(TracePath, llvm::sys::path::filename(Path));
-  Path.assign(TracePath);
-}
-
 // It is possible that the compiler instance doesn't own a file manager here
 // if we're compiling a module unit. Since the file manager are owned by AST
 // when we're compiling a module unit. So the file manager may be invalid
@@ -280,7 +268,8 @@
   Clang->getInvocation(), Clang->getDiagnostics()));
 
 if (auto profilerOutput = Clang->createOutputFile(
-Path.str(), /*Binary=*/false, /*RemoveFileOnSignal=*/false,
+Clang->getFrontendOpts().TimeTracePath, /*Binary=*/false,
+/*RemoveFileOnSignal=*/false,
 /*useTemporary=*/false)) {
   llvm::timeTraceProfilerWrite(*profilerOutput);
   profilerOutput.reset();
Index: clang/test/Driver/ftime-trace.cpp
===
--- clang/test/Driver/ftime-trace.cpp
+++ clang/test/Driver/ftime-trace.cpp
@@ -31,6 +31,27 @@
 // CHECK:  "name": "process_name"
 // CHECK:  "name": "thread_name"
 
+// RUN: mkdir d e f && cp %s d/a.cpp && touch d/b.c
+
+// RUN: %clang -### -c -ftime-trace -ftime-trace-granularity=0 d/a.cpp -o e/a.o 2>&1 | FileCheck %s --check-prefix=COMPILE1
+// COMPILE1: -cc1{{.*}} "-ftime-trace=e/a.json"
+
+// RUN: %clang -### -c -ftime-trace -ftime-trace-granularity=0 d/a.cpp d/b.c -dumpdir f/ 2>&1 | FileCheck %s --check-prefix=COMPILE2
+// COMPILE2: -cc1{{.*}} "-ftime-trace=f/a.json"
+// COMPILE2: -cc1{{.*}} "-ftime-trace=f/b.json"
+
+// RUN: %clang -### -ftime-trace 

[PATCH] D147266: [AArch64] Add IR intrinsics for vbsl* C intrinsics

2023-05-10 Thread Pranav Kant via Phabricator via cfe-commits
pranavk planned changes to this revision.
pranavk added a comment.

I agree. I changed the implementation to not introduce the intrinsic. I will 
need another change in InstCombine to handle case #1 mentioned on github bug 
report. I will have separate patch for it changing InstCombine. Thanks


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147266

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


[PATCH] D147266: [AArch64] Add IR intrinsics for vbsl* C intrinsics

2023-05-10 Thread Pranav Kant via Phabricator via cfe-commits
pranavk updated this revision to Diff 521040.
pranavk edited the summary of this revision.
pranavk added a comment.

Change shouldSinkOperand to allow backend to generate bitselect instructions


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147266

Files:
  llvm/lib/Target/AArch64/AArch64ISelLowering.cpp


Index: llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
===
--- llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
+++ llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
@@ -14332,6 +14332,61 @@
 
 return true;
   }
+  case Instruction::And: {
+// If Or(And(A, maskValue), And(B, ~maskValue)), sink ~maskValue
+// where ~maskValue = xor maskValue, -1
+// This is to select more performant bitselect instruction with NEON.
+
+// We start checking for this code sequence from AND instruction containing
+// ~maskValue because operands are sunk just before the Instruction* I
+// passed to this function. Starting pattern matching with any other
+// instruction (such as Or) would lead to malformed IR
+
+// Check if this AND instruction is part of bigger tree rooted at Or.
+if (Subtarget->hasNEON() && I->getNumUses() == 1) {
+  Use  = *(I->use_begin());
+  Instruction *OI = cast(U.getUser());
+  Value *And0_Op0 = nullptr, *And0_Op1 = nullptr, *And1_Op0 = nullptr,
+*And1_Op1 = nullptr;
+  if (!OI ||
+  !match(OI, m_Or(m_And(m_Value(And0_Op0), m_Value(And0_Op1)),
+  m_And(m_Value(And1_Op0), m_Value(And1_Op1 ||
+  !all_of(OI->operands(), [](Value *V) { return V->hasOneUser(); }))
+return false;
+
+  ArrayRef> Ands = {{And0_Op0, And0_Op1},
+  {And1_Op0, And1_Op1}};
+  for (unsigned AndIndex = 0; AndIndex < Ands.size(); ++AndIndex) {
+const unsigned OtherAndIndex = (AndIndex + 1) % 2;
+
+// Iterate operands of selected And
+for (unsigned AndOpIndex = 0; AndOpIndex < 2; ++AndOpIndex) {
+  if (const Instruction *XI =
+  dyn_cast(Ands[AndIndex][AndOpIndex]);
+  XI && XI->getOpcode() == Instruction::Xor) {
+Constant *MaskConst;
+Value *MaskValue;
+if (!match(XI, m_Xor(m_Value(MaskValue), m_Constant(MaskConst))) &&
+!match(XI, m_Xor(m_Constant(MaskConst), m_Value(MaskValue
+  return false;
+
+if (!MaskConst->isAllOnesValue())
+  return false;
+
+// one of the operands of other AND should be MaskValue
+if (!any_of(Ands[OtherAndIndex],
+[](Value *V) { return V == MaskValue; }))
+  return false;
+
+auto TI = cast(OI->getOperand(AndIndex));
+Ops.push_back(>getOperandUse(AndOpIndex));
+return true;
+  }
+}
+  }
+}
+return false;
+  }
   case Instruction::Mul: {
 int NumZExts = 0, NumSExts = 0;
 for (auto  : I->operands()) {


Index: llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
===
--- llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
+++ llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
@@ -14332,6 +14332,61 @@
 
 return true;
   }
+  case Instruction::And: {
+// If Or(And(A, maskValue), And(B, ~maskValue)), sink ~maskValue
+// where ~maskValue = xor maskValue, -1
+// This is to select more performant bitselect instruction with NEON.
+
+// We start checking for this code sequence from AND instruction containing
+// ~maskValue because operands are sunk just before the Instruction* I
+// passed to this function. Starting pattern matching with any other
+// instruction (such as Or) would lead to malformed IR
+
+// Check if this AND instruction is part of bigger tree rooted at Or.
+if (Subtarget->hasNEON() && I->getNumUses() == 1) {
+  Use  = *(I->use_begin());
+  Instruction *OI = cast(U.getUser());
+  Value *And0_Op0 = nullptr, *And0_Op1 = nullptr, *And1_Op0 = nullptr,
+*And1_Op1 = nullptr;
+  if (!OI ||
+  !match(OI, m_Or(m_And(m_Value(And0_Op0), m_Value(And0_Op1)),
+  m_And(m_Value(And1_Op0), m_Value(And1_Op1 ||
+  !all_of(OI->operands(), [](Value *V) { return V->hasOneUser(); }))
+return false;
+
+  ArrayRef> Ands = {{And0_Op0, And0_Op1},
+  {And1_Op0, And1_Op1}};
+  for (unsigned AndIndex = 0; AndIndex < Ands.size(); ++AndIndex) {
+const unsigned OtherAndIndex = (AndIndex + 1) % 2;
+
+// Iterate operands of selected And
+for (unsigned AndOpIndex = 0; AndOpIndex < 2; ++AndOpIndex) {
+  if (const Instruction *XI =
+  dyn_cast(Ands[AndIndex][AndOpIndex]);
+  XI 

[PATCH] D146764: [clang] Make predefined expressions string literals under -fms-extensions

2023-05-10 Thread Arthur Eubanks via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG878e590503df: Reland [clang] Make predefined expressions 
string literals under -fms-extensions (authored by aeubanks).

Changed prior to commit:
  https://reviews.llvm.org/D146764?vs=520204=521039#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146764

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/AST/Expr.h
  clang/include/clang/AST/IgnoreExpr.h
  clang/include/clang/AST/Stmt.h
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/Expr.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaInit.cpp
  clang/lib/Serialization/ASTReaderStmt.cpp
  clang/lib/Serialization/ASTWriterStmt.cpp
  clang/test/Modules/predefined.cpp
  clang/test/Sema/ms_predefined_expr.cpp
  clang/test/SemaCXX/predefined-expr-msvc.cpp

Index: clang/test/SemaCXX/predefined-expr-msvc.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/predefined-expr-msvc.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 %s -std=c++17 -fsyntax-only -verify
+// RUN: %clang_cc1 %s -std=c++17 -fsyntax-only -verify -fms-extensions
+
+// expected-no-diagnostics
+
+struct StringRef {
+  StringRef(const char *);
+};
+template 
+StringRef getTypeName() {
+  StringRef s = __func__;
+}
+
Index: clang/test/Sema/ms_predefined_expr.cpp
===
--- /dev/null
+++ clang/test/Sema/ms_predefined_expr.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 %s -fsyntax-only -Wmicrosoft -verify -fms-extensions
+
+void f() {
+ const char a[] = __FUNCTION__; // expected-warning{{initializing an array from a '__FUNCTION__' predefined identifier is a Microsoft extension}}
+ const char b[] = __FUNCDNAME__; // expected-warning{{initializing an array from a '__FUNCDNAME__' predefined identifier is a Microsoft extension}}
+ const char c[] = __FUNCSIG__; // expected-warning{{initializing an array from a '__FUNCSIG__' predefined identifier is a Microsoft extension}}
+ const char d[] = __func__; // expected-warning{{initializing an array from a '__func__' predefined identifier is a Microsoft extension}}
+ const char e[] = __PRETTY_FUNCTION__; // expected-warning{{initializing an array from a '__PRETTY_FUNCTION__' predefined identifier is a Microsoft extension}}
+}
Index: clang/test/Modules/predefined.cpp
===
--- /dev/null
+++ clang/test/Modules/predefined.cpp
@@ -0,0 +1,27 @@
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+// RUN: cd %t
+
+// RUN: %clang_cc1 -x c++ -std=c++20 -emit-module-interface a.h -o a.pcm -fms-extensions -verify
+// RUN: %clang_cc1 -std=c++20 a.cpp -fmodule-file=A=a.pcm -fms-extensions -fsyntax-only -verify
+
+//--- a.h
+
+// expected-no-diagnostics
+
+export module A;
+
+export template 
+void f() {
+char a[] = __func__;
+}
+
+//--- a.cpp
+
+// expected-warning@a.h:8 {{initializing an array from a '__func__' predefined identifier is a Microsoft extension}}
+
+import A;
+
+void g() {
+f(); // expected-note {{in instantiation of function template specialization 'f' requested here}}
+}
Index: clang/lib/Serialization/ASTWriterStmt.cpp
===
--- clang/lib/Serialization/ASTWriterStmt.cpp
+++ clang/lib/Serialization/ASTWriterStmt.cpp
@@ -593,6 +593,7 @@
   bool HasFunctionName = E->getFunctionName() != nullptr;
   Record.push_back(HasFunctionName);
   Record.push_back(E->getIdentKind()); // FIXME: stable encoding
+  Record.push_back(E->isTransparent());
   Record.AddSourceLocation(E->getLocation());
   if (HasFunctionName)
 Record.AddStmt(E->getFunctionName());
Index: clang/lib/Serialization/ASTReaderStmt.cpp
===
--- clang/lib/Serialization/ASTReaderStmt.cpp
+++ clang/lib/Serialization/ASTReaderStmt.cpp
@@ -582,6 +582,7 @@
   bool HasFunctionName = Record.readInt();
   E->PredefinedExprBits.HasFunctionName = HasFunctionName;
   E->PredefinedExprBits.Kind = Record.readInt();
+  E->PredefinedExprBits.IsTransparent = Record.readInt();
   E->setLocation(readSourceLocation());
   if (HasFunctionName)
 E->setFunctionName(cast(Record.readSubExpr()));
Index: clang/lib/Sema/SemaInit.cpp
===
--- clang/lib/Sema/SemaInit.cpp
+++ clang/lib/Sema/SemaInit.cpp
@@ -174,6 +174,8 @@
   E = GSE->getResultExpr();
 } else if (ChooseExpr *CE = dyn_cast(E)) {
   E = CE->getChosenSubExpr();
+} else if (PredefinedExpr *PE = dyn_cast(E)) {
+  E = PE->getFunctionName();
 } else {
   llvm_unreachable("unexpected expr in string literal init");
 }
@@ -8508,6 +8510,15 @@
 << Init->getSourceRange();
   }
 
+  if 

[clang] 878e590 - Reland [clang] Make predefined expressions string literals under -fms-extensions

2023-05-10 Thread Arthur Eubanks via cfe-commits

Author: Arthur Eubanks
Date: 2023-05-10T10:54:58-07:00
New Revision: 878e590503dff0d9097e91c2bec4409f14503b82

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

LOG: Reland [clang] Make predefined expressions string literals under 
-fms-extensions

MSVC makes these string literals [1][2].

[1] https://godbolt.org/z/6vnTzbExx
[2] 
https://learn.microsoft.com/en-us/cpp/preprocessor/predefined-macros?view=msvc-170

Fixes #114

Initial commit didn't check if there was a function name when stepping through 
expressions ignoring parens.

Reviewed By: aaron.ballman

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

Added: 
clang/test/Modules/predefined.cpp
clang/test/Sema/ms_predefined_expr.cpp
clang/test/SemaCXX/predefined-expr-msvc.cpp

Modified: 
clang/docs/ReleaseNotes.rst
clang/include/clang/AST/Expr.h
clang/include/clang/AST/IgnoreExpr.h
clang/include/clang/AST/Stmt.h
clang/include/clang/Basic/DiagnosticGroups.td
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/AST/ASTImporter.cpp
clang/lib/AST/Expr.cpp
clang/lib/Sema/SemaExpr.cpp
clang/lib/Sema/SemaInit.cpp
clang/lib/Serialization/ASTReaderStmt.cpp
clang/lib/Serialization/ASTWriterStmt.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index c0820bd01fd5f..8b6232a6b9e6f 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -438,6 +438,9 @@ Bug Fixes to C++ Support
 - Fix a crash when expanding a pack as the index of a subscript expression.
 - Fix handling of constexpr dynamic memory allocations in template
   arguments. (`#62462 `_)
+- Some predefined expressions are now treated as string literals in MSVC
+  compatibility mode.
+  (`#114 `_)
 
 Bug Fixes to AST Handling
 ^

diff  --git a/clang/include/clang/AST/Expr.h b/clang/include/clang/AST/Expr.h
index 0ab778e5d8cd3..db4316d8faf1f 100644
--- a/clang/include/clang/AST/Expr.h
+++ b/clang/include/clang/AST/Expr.h
@@ -1992,7 +1992,7 @@ class PredefinedExpr final
 
 private:
   PredefinedExpr(SourceLocation L, QualType FNTy, IdentKind IK,
- StringLiteral *SL);
+ bool IsTransparent, StringLiteral *SL);
 
   explicit PredefinedExpr(EmptyShell Empty, bool HasFunctionName);
 
@@ -2007,8 +2007,12 @@ class PredefinedExpr final
 
 public:
   /// Create a PredefinedExpr.
+  ///
+  /// If IsTransparent, the PredefinedExpr is transparently handled as a
+  /// StringLiteral.
   static PredefinedExpr *Create(const ASTContext , SourceLocation L,
-QualType FNTy, IdentKind IK, StringLiteral 
*SL);
+QualType FNTy, IdentKind IK, bool 
IsTransparent,
+StringLiteral *SL);
 
   /// Create an empty PredefinedExpr.
   static PredefinedExpr *CreateEmpty(const ASTContext ,
@@ -2018,6 +2022,8 @@ class PredefinedExpr final
 return static_cast(PredefinedExprBits.Kind);
   }
 
+  bool isTransparent() const { return PredefinedExprBits.IsTransparent; }
+
   SourceLocation getLocation() const { return PredefinedExprBits.Loc; }
   void setLocation(SourceLocation L) { PredefinedExprBits.Loc = L; }
 

diff  --git a/clang/include/clang/AST/IgnoreExpr.h 
b/clang/include/clang/AST/IgnoreExpr.h
index f8d2d6c7d00c0..917bada61fa6f 100644
--- a/clang/include/clang/AST/IgnoreExpr.h
+++ b/clang/include/clang/AST/IgnoreExpr.h
@@ -166,6 +166,11 @@ inline Expr *IgnoreParensSingleStep(Expr *E) {
   return CE->getChosenSubExpr();
   }
 
+  else if (auto *PE = dyn_cast(E)) {
+if (PE->isTransparent() && PE->getFunctionName())
+  return PE->getFunctionName();
+  }
+
   return E;
 }
 

diff  --git a/clang/include/clang/AST/Stmt.h b/clang/include/clang/AST/Stmt.h
index ea979d791ce7b..e466aa1755daf 100644
--- a/clang/include/clang/AST/Stmt.h
+++ b/clang/include/clang/AST/Stmt.h
@@ -364,6 +364,10 @@ class alignas(void *) Stmt {
 /// for the predefined identifier.
 unsigned HasFunctionName : 1;
 
+/// True if this PredefinedExpr should be treated as a StringLiteral (for
+/// MSVC compatibility).
+unsigned IsTransparent : 1;
+
 /// The location of this PredefinedExpr.
 SourceLocation Loc;
   };

diff  --git a/clang/include/clang/Basic/DiagnosticGroups.td 
b/clang/include/clang/Basic/DiagnosticGroups.td
index 87e72f000d494..2ba42f9b73763 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -1190,6 +1190,7 @@ def MicrosoftCommentPaste : 
DiagGroup<"microsoft-comment-paste">;
 def MicrosoftEndOfFile : DiagGroup<"microsoft-end-of-file">;
 def 

[PATCH] D140275: [clangd] Tweak to add doxygen comment to the function declaration

2023-05-10 Thread David Goldman via Phabricator via cfe-commits
dgoldman added a comment.

In D140275#4203456 , @tupos wrote:

> Could you please also advice me what else need to be done for the ObjC, since 
> there were many years since I wrote ObjC last time I'm not sure what else 
> need to be done there.
>
> Thanks.

I think this is fine for a v1 - I think the main improvement would be changing 
the style/format, Xcode itself uses the following format instead where 
<#Placeholder Name#> denotes a placeholder:

  /// <#Description#>
  /// - Parameters:
  ///   - arg1: <#model description#>
  ///   - arg2: <#user description#>
  /// - Returns: <#description#>


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140275

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


[PATCH] D143675: Discussion: Darwin Sanitizers Stable ABI

2023-05-10 Thread Roy Sundahl via Phabricator via cfe-commits
rsundahl added a comment.

In D143675#4330599 , @thetruestblue 
wrote:

> Small insignificant note from me: When this lands, please be sure to add me 
> as co-author.
> https://github.blog/2018-01-29-commit-together-with-co-authors/

I've not seen this before @thetruestblue! I certainly will do so!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143675

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


[PATCH] D143675: Discussion: Darwin Sanitizers Stable ABI

2023-05-10 Thread Roy Sundahl via Phabricator via cfe-commits
rsundahl added a comment.

In D143675#4310903 , @eugenis wrote:

> I'm fine with it in general. Is asan_abi.cpp meant as a temporary stub? It's 
> not even link anywhere in the current version.

Right, we should be using it... We will add a test that compiles and links to 
it as affirmation that we have covered all of the entrypoints that ASan 
generates. It's also the case that asan_abi_shim.h is redundant since 
asan_abi_shim.cpp now gets its declarations from 
../asan/asan_interface_internal.h which is of course the source of truth for 
what the shim should be implementing. We will remove that as well and update. 
Thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143675

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


[PATCH] D150278: [Headers][doc] Add "shift" intrinsic descriptions to avx2intrin.h

2023-05-10 Thread Noah Goldstein via Phabricator via cfe-commits
goldstein.w.n accepted this revision.
goldstein.w.n added a comment.
This revision is now accepted and ready to land.

LGTM.


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

https://reviews.llvm.org/D150278

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


[PATCH] D149802: [clang][modules] Avoid unnecessary writes of .timestamp files

2023-05-10 Thread Jan Svoboda via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG63eb04a36839: [clang][modules] Avoid unnecessary writes of 
.timestamp files (authored by jansvoboda11).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149802

Files:
  clang/lib/Serialization/ASTReader.cpp


Index: clang/lib/Serialization/ASTReader.cpp
===
--- clang/lib/Serialization/ASTReader.cpp
+++ clang/lib/Serialization/ASTReader.cpp
@@ -4507,18 +4507,16 @@
 }
   }
 
-  if (PP.getHeaderSearchInfo()
-  .getHeaderSearchOpts()
-  .ModulesValidateOncePerBuildSession) {
+  HeaderSearchOptions  = PP.getHeaderSearchInfo().getHeaderSearchOpts();
+  if (HSOpts.ModulesValidateOncePerBuildSession) {
 // Now we are certain that the module and all modules it depends on are
-// up to date.  Create or update timestamp files for modules that are
-// located in the module cache (not for PCH files that could be anywhere
-// in the filesystem).
+// up-to-date. For implicitly-built module files, ensure the corresponding
+// timestamp files are up-to-date in this build session.
 for (unsigned I = 0, N = Loaded.size(); I != N; ++I) {
   ImportedModule  = Loaded[I];
-  if (M.Mod->Kind == MK_ImplicitModule) {
+  if (M.Mod->Kind == MK_ImplicitModule &&
+  M.Mod->InputFilesValidationTimestamp < HSOpts.BuildSessionTimestamp)
 updateModuleTimestamp(*M.Mod);
-  }
 }
   }
 


Index: clang/lib/Serialization/ASTReader.cpp
===
--- clang/lib/Serialization/ASTReader.cpp
+++ clang/lib/Serialization/ASTReader.cpp
@@ -4507,18 +4507,16 @@
 }
   }
 
-  if (PP.getHeaderSearchInfo()
-  .getHeaderSearchOpts()
-  .ModulesValidateOncePerBuildSession) {
+  HeaderSearchOptions  = PP.getHeaderSearchInfo().getHeaderSearchOpts();
+  if (HSOpts.ModulesValidateOncePerBuildSession) {
 // Now we are certain that the module and all modules it depends on are
-// up to date.  Create or update timestamp files for modules that are
-// located in the module cache (not for PCH files that could be anywhere
-// in the filesystem).
+// up-to-date. For implicitly-built module files, ensure the corresponding
+// timestamp files are up-to-date in this build session.
 for (unsigned I = 0, N = Loaded.size(); I != N; ++I) {
   ImportedModule  = Loaded[I];
-  if (M.Mod->Kind == MK_ImplicitModule) {
+  if (M.Mod->Kind == MK_ImplicitModule &&
+  M.Mod->InputFilesValidationTimestamp < HSOpts.BuildSessionTimestamp)
 updateModuleTimestamp(*M.Mod);
-  }
 }
   }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 63eb04a - [clang][modules] Avoid unnecessary writes of .timestamp files

2023-05-10 Thread Jan Svoboda via cfe-commits

Author: Jan Svoboda
Date: 2023-05-10T10:41:33-07:00
New Revision: 63eb04a3683996db26dbf1534682c5696d93b080

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

LOG: [clang][modules] Avoid unnecessary writes of .timestamp files

Clang currently updates the mtime of .timestamp files on each load of the 
corresponding .pcm file. This is not necessary. In a given build session, Clang 
only needs to write the .timestamp file once, when we first validate the input 
files. This patch makes it so that we only touch the .timestamp file when it's 
older than the build session, alleviating some filesystem contention in 
clang-scan-deps.

Reviewed By: benlangmuir

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

Added: 


Modified: 
clang/lib/Serialization/ASTReader.cpp

Removed: 




diff  --git a/clang/lib/Serialization/ASTReader.cpp 
b/clang/lib/Serialization/ASTReader.cpp
index 9c31f9db14679..bdf476cf128a3 100644
--- a/clang/lib/Serialization/ASTReader.cpp
+++ b/clang/lib/Serialization/ASTReader.cpp
@@ -4507,18 +4507,16 @@ ASTReader::ASTReadResult ASTReader::ReadAST(StringRef 
FileName,
 }
   }
 
-  if (PP.getHeaderSearchInfo()
-  .getHeaderSearchOpts()
-  .ModulesValidateOncePerBuildSession) {
+  HeaderSearchOptions  = PP.getHeaderSearchInfo().getHeaderSearchOpts();
+  if (HSOpts.ModulesValidateOncePerBuildSession) {
 // Now we are certain that the module and all modules it depends on are
-// up to date.  Create or update timestamp files for modules that are
-// located in the module cache (not for PCH files that could be anywhere
-// in the filesystem).
+// up-to-date. For implicitly-built module files, ensure the corresponding
+// timestamp files are up-to-date in this build session.
 for (unsigned I = 0, N = Loaded.size(); I != N; ++I) {
   ImportedModule  = Loaded[I];
-  if (M.Mod->Kind == MK_ImplicitModule) {
+  if (M.Mod->Kind == MK_ImplicitModule &&
+  M.Mod->InputFilesValidationTimestamp < HSOpts.BuildSessionTimestamp)
 updateModuleTimestamp(*M.Mod);
-  }
 }
   }
 



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


[PATCH] D150278: [Headers][doc] Add "shift" intrinsic descriptions to avx2intrin.h

2023-05-10 Thread Paul Robinson via Phabricator via cfe-commits
probinson created this revision.
probinson added reviewers: pengfei, RKSimon, goldstein.w.n, craig.topper.
Herald added a project: All.
probinson requested review of this revision.

https://reviews.llvm.org/D150278

Files:
  clang/lib/Headers/avx2intrin.h

Index: clang/lib/Headers/avx2intrin.h
===
--- clang/lib/Headers/avx2intrin.h
+++ clang/lib/Headers/avx2intrin.h
@@ -493,108 +493,404 @@
 return (__m256i)__builtin_ia32_psignd256((__v8si)__a, (__v8si)__b);
 }
 
+/// Shifts each 128-bit half of the 256-bit integer vector \a a left by
+///\a imm bytes, shifting in zero bytes, and returns the result. If \a imm
+///is greater than 15, the returned result is all zeroes.
+///
+/// \headerfile 
+///
+/// \code
+/// __m256i _mm256_slli_si256(__m256i a, const int imm);
+/// \endcode
+///
+/// This intrinsic corresponds to the \c VPSLLDQ instruction.
+///
+/// \param a
+///A 256-bit integer vector to be shifted.
+/// \param imm
+/// An unsigned immediate value specifying the shift count (in bytes).
+/// \returns A 256-bit integer vector containing the result.
 #define _mm256_slli_si256(a, imm) \
   ((__m256i)__builtin_ia32_pslldqi256_byteshift((__v4di)(__m256i)(a), (int)(imm)))
 
+/// Shifts each 128-bit half of the 256-bit integer vector \a a left by
+///\a imm bytes, shifting in zero bytes, and returns the result. If \a imm
+///is greater than 15, the returned result is all zeroes.
+///
+/// \headerfile 
+///
+/// \code
+/// __m256i _mm256_bslli_epi128(__m256i a, const int imm);
+/// \endcode
+///
+/// This intrinsic corresponds to the \c VPSLLDQ instruction.
+///
+/// \param a
+///A 256-bit integer vector to be shifted.
+/// \param imm
+///An unsigned immediate value specifying the shift count (in bytes).
+/// \returns A 256-bit integer vector containing the result.
 #define _mm256_bslli_epi128(a, imm) \
   ((__m256i)__builtin_ia32_pslldqi256_byteshift((__v4di)(__m256i)(a), (int)(imm)))
 
+/// Shifts each 16-bit element of the 256-bit vector of [16 x i16] in \a __a
+///left by \a __count bits, shifting in zero bits, and returns the result.
+///If \a __count is greater than 15, the returned result is all zeroes.
+///
+/// \headerfile 
+///
+/// This intrinsic corresponds to the \c VPSLLW instruction.
+///
+/// \param __a
+///A 256-bit vector of [16 x i16] to be shifted.
+/// \param __count
+///An unsigned integer value specifying the shift count (in bits).
+/// \returns A 256-bit vector of [16 x i16] containing the result.
 static __inline__ __m256i __DEFAULT_FN_ATTRS256
 _mm256_slli_epi16(__m256i __a, int __count)
 {
   return (__m256i)__builtin_ia32_psllwi256((__v16hi)__a, __count);
 }
 
+/// Shifts each 16-bit element of the 256-bit vector of [16 x i16] in \a __a
+///left by the number of bits specified by the lower 64 bits of \a __count,
+///shifting in zero bits, and returns the result. If \a __count is greater
+///than 15, the returned result is all zeroes.
+///
+/// \headerfile 
+///
+/// This intrinsic corresponds to the \c VPSLLW instruction.
+///
+/// \param __a
+///A 256-bit vector of [16 x i16] to be shifted.
+/// \param __count
+///A 128-bit vector of [2 x i64] whose lower element gives the unsigned
+///shift count (in bits). The upper element is ignored.
+/// \returns A 256-bit vector of [16 x i16] containing the result.
 static __inline__ __m256i __DEFAULT_FN_ATTRS256
 _mm256_sll_epi16(__m256i __a, __m128i __count)
 {
   return (__m256i)__builtin_ia32_psllw256((__v16hi)__a, (__v8hi)__count);
 }
 
+/// Shifts each 32-bit element of the 256-bit vector of [8 x i32] in \a __a
+///left by \a __count bits, shifting in zero bits, and returns the result.
+///If \a __count is greater than 31, the returned result is all zeroes.
+///
+/// \headerfile 
+///
+/// This intrinsic corresponds to the \c VPSLLD instruction.
+///
+/// \param __a
+///A 256-bit vector of [8 x i32] to be shifted.
+/// \param __count
+///An unsigned integer value specifying the shift count (in bits).
+/// \returns A 256-bit vector of [8 x i32] containing the result.
 static __inline__ __m256i __DEFAULT_FN_ATTRS256
 _mm256_slli_epi32(__m256i __a, int __count)
 {
   return (__m256i)__builtin_ia32_pslldi256((__v8si)__a, __count);
 }
 
+/// Shifts each 32-bit element of the 256-bit vector of [8 x i32] in \a __a
+///left by the number of bits given in the lower 64 bits of \a __count,
+///shifting in zero bits, and returns the result. If \a __count is greater
+///than 31, the returned result is all zeroes.
+///
+/// \headerfile 
+///
+/// This intrinsic corresponds to the \c VPSLLD instruction.
+///
+/// \param __a
+///A 256-bit vector of [8 x i32] to be shifted.
+/// \param __count
+///A 128-bit vector of [2 x i64] whose lower element gives the unsigned
+///shift count (in bits). The upper element is ignored.
+/// \returns A 256-bit vector of [8 x i32] containing 

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

2023-05-10 Thread M. Zeeshan Siddiqui via Phabricator via cfe-commits
codemzs marked an inline comment as done.
codemzs added a comment.

In D149573#4332549 , @tahonermann 
wrote:

> I reviewed about a third of this, but then stopped due to the `__bf16` vs 
> `std::bfloat16_t` naming issues. I think the existing names that use 
> "bfloat16" to support the `__bf16` type should be renamed, in a separate 
> patch, and this patch rebased on top of it. We are sure to make mistakes if 
> this confusing situation is not resolved.

@tahonermann, thank you for your review and highlighting the naming issues with 
`__bf16` and `std::bfloat16_t`. I agree that reversing the type names will 
improve readability and maintainability. I considered this while working on the 
code and appreciate your suggestion to address it in a separate patch before 
rebasing this one.




Comment at: clang/include/clang/Lex/LiteralSupport.h:75
   bool isBitInt : 1;// 1wb, 1uwb (C2x)
+  bool isBF16 : 1;  // 1.0bf
   uint8_t MicrosoftInteger; // Microsoft suffix extension i8, i16, i32, or i64.

tahonermann wrote:
> Is this for `__bf16` or for `std::bfloat16_t`?
Its for `std::bfloat16_t`, I don't believe `__bf16` has a literal suffix. 


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


[PATCH] D149495: [RISCV] Add support for V extension in SiFive7

2023-05-10 Thread Michael Maitland 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 rG1a855819a87f: [RISCV] Add support for V extenstion in 
SiFive7 (authored by michaelmaitland).

Changed prior to commit:
  https://reviews.llvm.org/D149495?vs=521024=521031#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149495

Files:
  llvm/lib/Target/RISCV/RISCVSchedSiFive7.td
  llvm/lib/Target/RISCV/RISCVScheduleV.td

Index: llvm/lib/Target/RISCV/RISCVScheduleV.td
===
--- llvm/lib/Target/RISCV/RISCVScheduleV.td
+++ llvm/lib/Target/RISCV/RISCVScheduleV.td
@@ -9,7 +9,7 @@
 //===--===//
 /// Define scheduler resources associated with def operands.
 
-defvar SchedMxList = ["M1", "M2", "M4", "M8", "MF2", "MF4", "MF8"];
+defvar SchedMxList = ["MF8", "MF4", "MF2", "M1", "M2", "M4", "M8"];
 // Used for widening and narrowing instructions as it doesn't contain M8.
 defvar SchedMxListW = !listremove(SchedMxList, ["M8"]);
 defvar SchedMxListFW = !listremove(SchedMxList, ["M8", "MF8"]);
@@ -38,6 +38,32 @@
 !eq(mx, "MF4"): [16]);
 }
 
+// Helper function to get the largest LMUL from MxList
+// Precondition: MxList is sorted in ascending LMUL order.
+class LargestLMUL MxList> {
+  // MX list is sorted from smallest to largest
+  string r = !foldl(!head(MxList), MxList, last, curr, curr);
+}
+// Helper function to get the smallest SEW that can be used with LMUL mx
+// Precondition: MxList is sorted in ascending LMUL order and SchedSEWSet
+class SmallestSEW {
+  int r = !head(!if(isF, SchedSEWSetF.val, SchedSEWSet.val));
+}
+
+// Creates WriteRes for (name, mx, resources) tuple
+multiclass LMULWriteResMX resources,
+  string mx, bit IsWorstCase> {
+  def : WriteRes(name # "_" # mx), resources>;
+  if IsWorstCase then
+def : WriteRes(name # "_WorstCase"), resources>;
+}
+multiclass LMULSEWWriteResMXSEW resources,
+ string mx, int sew,  bit IsWorstCase> {
+  def : WriteRes(name # "_" # mx # "_E" # sew), resources>;
+  if IsWorstCase then
+def : WriteRes(name # "_WorstCase"), resources>;
+}
+
 // Define multiclasses to define SchedWrite, SchedRead,  WriteRes, and
 // ReadAdvance for each (name, LMUL) pair and for each LMUL in each of the
 // SchedMxList variants above. Each multiclass is responsible for defining
Index: llvm/lib/Target/RISCV/RISCVSchedSiFive7.td
===
--- llvm/lib/Target/RISCV/RISCVSchedSiFive7.td
+++ llvm/lib/Target/RISCV/RISCVSchedSiFive7.td
@@ -8,6 +8,131 @@
 
 //===--===//
 
+/// c is true if mx has the worst case behavior compared to LMULs in MxList.
+/// On the SiFive7, the worst case LMUL is the Largest LMUL
+/// and the worst case sew is the smallest SEW for that LMUL.
+class SiFive7IsWorstCaseMX MxList> {
+  defvar LLMUL = LargestLMUL.r;
+  bit c = !eq(mx, LLMUL);
+}
+
+/// c is true if mx and sew have the worst case behavior compared to LMULs in
+/// MxList. On the SiFive7, the worst case LMUL is the Largest LMUL
+/// and the worst case sew is the smallest SEW for that LMUL.
+class SiFive7IsWorstCaseMXSEW MxList,
+   bit isF = 0> {
+  defvar LLMUL = LargestLMUL.r;
+  defvar SSEW = SmallestSEW.r;
+  bit c = !and(!eq(mx, LLMUL), !eq(sew, SSEW));
+}
+
+class SiFive7GetCyclesDefault {
+  int c = !cond(
+!eq(mx, "M1") : 2,
+!eq(mx, "M2") : 4,
+!eq(mx, "M4") : 8,
+!eq(mx, "M8") : 16,
+!eq(mx, "MF2") : 1,
+!eq(mx, "MF4") : 1,
+!eq(mx, "MF8") : 1
+  );
+}
+
+class SiFive7GetCyclesWidening {
+  int c = !cond(
+!eq(mx, "M1") : 2,
+!eq(mx, "M2") : 4,
+!eq(mx, "M4") : 8,
+!eq(mx, "MF2") : 1,
+!eq(mx, "MF4") : 1,
+!eq(mx, "MF8") : 1
+  );
+}
+
+class SiFive7GetCyclesNarrowing {
+  int c = !cond(
+!eq(mx, "M1") : 4,
+!eq(mx, "M2") : 8,
+!eq(mx, "M4") : 16,
+!eq(mx, "MF2") : 2,
+!eq(mx, "MF4") : 1,
+!eq(mx, "MF8") : 1
+  );
+}
+
+class SiFive7GetCyclesOutputLMUL {
+  int c = !cond(
+!eq(mx, "M1") : 1,
+!eq(mx, "M2") : 2,
+!eq(mx, "M4") : 4,
+!eq(mx, "M8") : 8,
+!eq(mx, "MF2") : 1,
+!eq(mx, "MF4") : 1,
+!eq(mx, "MF8") : 1
+  );
+}
+
+class SiFive7GetCyclesVMask {
+  int c = !cond(
+!eq(mx, "M1") : 1,
+!eq(mx, "M2") : 1,
+!eq(mx, "M4") : 1,
+!eq(mx, "M8") : 2,
+!eq(mx, "MF2") : 1,
+!eq(mx, "MF4") : 1,
+!eq(mx, "MF8") : 1
+  );
+}
+
+// Cycles for segmented loads and stores are calculated using the
+// formula ceil(2 * nf * lmul).
+class SiFive7GetCyclesSegmented {
+  int c = !cond(
+!eq(mx, "M1") : !mul(!mul(2, nf), 1),
+!eq(mx, "M2") : !mul(!mul(2, nf), 2),
+!eq(mx, 

[clang] d747f82 - libclang: add missing `struct` in the declaration

2023-05-10 Thread Saleem Abdulrasool via cfe-commits

Author: Saleem Abdulrasool
Date: 2023-05-10T10:31:53-07:00
New Revision: d747f8277b386059a74dee062295aa8d864398fc

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

LOG: libclang: add missing `struct` in the declaration

When building with compilers that do not support the Blocks extension,
we would fail to compile due to the missing type specifier on the
`typedef`.  This should repair those builds.

Fixes: #62640

Added: 


Modified: 
clang/include/clang-c/Index.h

Removed: 




diff  --git a/clang/include/clang-c/Index.h b/clang/include/clang-c/Index.h
index 2c1bc02003ba..29c53c0382ab 100644
--- a/clang/include/clang-c/Index.h
+++ b/clang/include/clang-c/Index.h
@@ -3874,7 +3874,7 @@ CINDEX_LINKAGE unsigned clang_visitChildren(CXCursor 
parent,
 typedef enum CXChildVisitResult (^CXCursorVisitorBlock)(CXCursor cursor,
 CXCursor parent);
 #else
-typedef _CXChildVisitResult *CXCursorVisitorBlock;
+typedef struct _CXChildVisitResult *CXCursorVisitorBlock;
 #endif
 
 /**



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


[PATCH] D103930: [clang][HeaderSearch] Fix implicit module when using header maps

2023-05-10 Thread Ian Anderson via Phabricator via cfe-commits
iana added a comment.

I wonder if clang should have better module interaction with the header maps 
produced by Xcode, or if Xcode should produce better header maps to work with 
clang. Or are you having problems with header maps outside of Xcode?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103930

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


[PATCH] D103930: [clang][HeaderSearch] Fix implicit module when using header maps

2023-05-10 Thread Ian Anderson via Phabricator via cfe-commits
iana added inline comments.



Comment at: clang/test/Modules/implicit-module-header-maps.cpp:52
+//header and trip a `#error`, or
+// 2) header maps aren't usesd, as the header name doesn't exist and relies on
+//the header map to remap it to the real header.

usesd -> used


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103930

___
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 and introduce Bfloat16 arithmetic type.

2023-05-10 Thread Tom Honermann via Phabricator via cfe-commits
tahonermann requested changes to this revision.
tahonermann added a comment.
This revision now requires changes to proceed.

I reviewed about a third of this, but then stopped due to the `__bf16` vs 
`std::bfloat16_t` naming issues. I think the existing names that use "bfloat16" 
to support the `__bf16` type should be renamed, in a separate patch, and this 
patch rebased on top of it. We are sure to make mistakes if this confusing 
situation is not resolved.




Comment at: clang/include/clang/AST/ASTContext.h:1113-1114
   CanQualType HalfTy; // [OpenCL 6.1.1.1], ARM NEON
   CanQualType BFloat16Ty;
+  CanQualType BF16Ty;// [C++23 6.8.3p5], ISO/IEC/IEEE 60559.
   CanQualType Float16Ty; // C11 extension ISO/IEC TS 18661-3

This seems wrong. C++23 introduces `std​::​bfloat16_t` and Clang already 
supports `__bf16`. It seems to me that the `BFloat16Ty` name should be used for 
the former and `BF16Ty` used for the latter. I get that the inconsistency is 
preexisting, but I think we should fix that (in another patch before landing 
this one; there aren't very many references).



Comment at: clang/include/clang/AST/BuiltinTypes.def:215-219
+// 'Bfloat16' arithmetic type to represent std::bfloat16_t.
+FLOATING_TYPE(BF16, BFloat16Ty)
+
 // '__bf16'
 FLOATING_TYPE(BFloat16, BFloat16Ty)

Here again, the type names are the exact opposite of what one would intuitively 
expect (I do appreciate that the comment makes the intent clear, but it still 
looks like a copy/paste error or similar).



Comment at: clang/include/clang/AST/Type.h:2152-2162
+  bool isCXX23FloatingPointType()
+  const; // C++23 6.8.2p12 [basic.fundamental] (standard floating point +
+ // extended floating point)
+  bool isCXX23StandardFloatingPointType()
+  const; // C++23 6.8.2p12 [basic.fundamental] (standard floating point)
+  bool isCXX23ExtendedFloatingPointType()
+  const; // C++23 6.8.2p12 [basic.fundamental] (extended floating point)

Precedent elsewhere in this file is to place multi-line comments ahead of the 
function they appertain to.



Comment at: clang/include/clang/AST/Type.h:7259-7265
 inline bool Type::isBFloat16Type() const {
   return isSpecificBuiltinType(BuiltinType::BFloat16);
 }
 
+inline bool Type::isBF16Type() const {
+  return isSpecificBuiltinType(BuiltinType::BF16);
+}

This is a great example of `BFloat16` vs `BF16` confusion; here the names are 
*not* reversed. It is really hard to know if this code is wrong or for callers 
to know which one they should use.



Comment at: clang/include/clang/Driver/Options.td:6418-6420
+def fnative_bfloat16_type: Flag<["-"], "fnative-bfloat16-type">,
+  HelpText<"Enable bfloat16 arithmetic type in C++23 for targets with native 
support.">,
+  MarshallingInfoFlag>;

Since this message is specific to C++ for now (pending the addition of a 
`_BFloat16` type in some future C standard, I think the message should 
reference `std::bfloat16_t` and skip explicit mention of C++23. I know it is 
kind of awkward to refer to the standard library name for the type, but since 
WG21 decided not to provide a keyword name (I wish they would just use the C 
names for these and get over it; they can still provide pretty library names!), 
there isn't another more explicit name to use. Alternatively, we could say 
something like "Enable the underlying type of std::bfloat16_t in C++ ...".



Comment at: clang/include/clang/Lex/LiteralSupport.h:75
   bool isBitInt : 1;// 1wb, 1uwb (C2x)
+  bool isBF16 : 1;  // 1.0bf
   uint8_t MicrosoftInteger; // Microsoft suffix extension i8, i16, i32, or i64.

Is this for `__bf16` or for `std::bfloat16_t`?


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


[PATCH] D149495: [RISCV] Add support for V extension in SiFive7

2023-05-10 Thread Michael Maitland via Phabricator via cfe-commits
michaelmaitland added inline comments.



Comment at: llvm/lib/Target/RISCV/RISCVScheduleV.td:41
 
+// Helper function to get the largest LMUL from MxList
+// Precondition: MxList is sorted in ascending LMUL order.

pcwang-thead wrote:
> So, are we going to discard `LMULXXXImpl` below?
I will use `LMULXXXImpl` in a follow up NFC patch. This code below comes from 
before `LMULXXXImpl` was introduced.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149495

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


[PATCH] D149495: [RISCV] Add support for V extension in SiFive7

2023-05-10 Thread Michael Maitland via Phabricator via cfe-commits
michaelmaitland updated this revision to Diff 521024.
michaelmaitland marked 2 inline comments as done.
michaelmaitland added a comment.

Use defvar in subroutines.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149495

Files:
  llvm/lib/Target/RISCV/RISCVSchedSiFive7.td
  llvm/lib/Target/RISCV/RISCVScheduleV.td

Index: llvm/lib/Target/RISCV/RISCVScheduleV.td
===
--- llvm/lib/Target/RISCV/RISCVScheduleV.td
+++ llvm/lib/Target/RISCV/RISCVScheduleV.td
@@ -9,7 +9,7 @@
 //===--===//
 /// Define scheduler resources associated with def operands.
 
-defvar SchedMxList = ["M1", "M2", "M4", "M8", "MF2", "MF4", "MF8"];
+defvar SchedMxList = ["MF8", "MF4", "MF2", "M1", "M2", "M4", "M8"];
 // Used for widening and narrowing instructions as it doesn't contain M8.
 defvar SchedMxListW = !listremove(SchedMxList, ["M8"]);
 defvar SchedMxListFW = !listremove(SchedMxList, ["M8", "MF8"]);
@@ -38,6 +38,32 @@
 !eq(mx, "MF4"): [16]);
 }
 
+// Helper function to get the largest LMUL from MxList
+// Precondition: MxList is sorted in ascending LMUL order.
+class LargestLMUL MxList> {
+  // MX list is sorted from smallest to largest
+  string r = !foldl(!head(MxList), MxList, last, curr, curr);
+}
+// Helper function to get the smallest SEW that can be used with LMUL mx
+// Precondition: MxList is sorted in ascending LMUL order and SchedSEWSet
+class SmallestSEW {
+  int r = !head(!if(isF, SchedSEWSetF.val, SchedSEWSet.val));
+}
+
+// Creates WriteRes for (name, mx, resources) tuple
+multiclass LMULWriteResMX resources,
+  string mx, bit IsWorstCase> {
+  def : WriteRes(name # "_" # mx), resources>;
+  if IsWorstCase then
+def : WriteRes(name # "_WorstCase"), resources>;
+}
+multiclass LMULSEWWriteResMXSEW resources,
+ string mx, int sew,  bit IsWorstCase> {
+  def : WriteRes(name # "_" # mx # "_E" # sew), resources>;
+  if IsWorstCase then
+def : WriteRes(name # "_WorstCase"), resources>;
+}
+
 // Define multiclasses to define SchedWrite, SchedRead,  WriteRes, and
 // ReadAdvance for each (name, LMUL) pair and for each LMUL in each of the
 // SchedMxList variants above. Each multiclass is responsible for defining
Index: llvm/lib/Target/RISCV/RISCVSchedSiFive7.td
===
--- llvm/lib/Target/RISCV/RISCVSchedSiFive7.td
+++ llvm/lib/Target/RISCV/RISCVSchedSiFive7.td
@@ -8,6 +8,131 @@
 
 //===--===//
 
+/// c is true if mx has the worst case behavior compared to LMULs in MxList.
+/// On the SiFive7, the worst case LMUL is the Largest LMUL
+/// and the worst case sew is the smallest SEW for that LMUL.
+class SiFive7IsWorstCaseMX MxList> {
+  defvar LLMUL = LargestLMUL.r;
+  bit c = !eq(mx, LLMUL);
+}
+
+/// c is true if mx and sew have the worst case behavior compared to LMULs in
+/// MxList. On the SiFive7, the worst case LMUL is the Largest LMUL
+/// and the worst case sew is the smallest SEW for that LMUL.
+class SiFive7IsWorstCaseMXSEW MxList,
+   bit isF = 0> {
+  defvar LLMUL = LargestLMUL.r;
+  defvar SSEW = SmallestSEW.r;
+  bit c = !and(!eq(mx, LLMUL), !eq(sew, SSEW));
+}
+
+class SiFive7GetCyclesDefault {
+  int c = !cond(
+!eq(mx, "M1") : 2,
+!eq(mx, "M2") : 4,
+!eq(mx, "M4") : 8,
+!eq(mx, "M8") : 16,
+!eq(mx, "MF2") : 1,
+!eq(mx, "MF4") : 1,
+!eq(mx, "MF8") : 1
+  );
+}
+
+class SiFive7GetCyclesWidening {
+  int c = !cond(
+!eq(mx, "M1") : 2,
+!eq(mx, "M2") : 4,
+!eq(mx, "M4") : 8,
+!eq(mx, "MF2") : 1,
+!eq(mx, "MF4") : 1,
+!eq(mx, "MF8") : 1
+  );
+}
+
+class SiFive7GetCyclesNarrowing {
+  int c = !cond(
+!eq(mx, "M1") : 4,
+!eq(mx, "M2") : 8,
+!eq(mx, "M4") : 16,
+!eq(mx, "MF2") : 2,
+!eq(mx, "MF4") : 1,
+!eq(mx, "MF8") : 1
+  );
+}
+
+class SiFive7GetCyclesOutputLMUL {
+  int c = !cond(
+!eq(mx, "M1") : 1,
+!eq(mx, "M2") : 2,
+!eq(mx, "M4") : 4,
+!eq(mx, "M8") : 8,
+!eq(mx, "MF2") : 1,
+!eq(mx, "MF4") : 1,
+!eq(mx, "MF8") : 1
+  );
+}
+
+class SiFive7GetCyclesVMask {
+  int c = !cond(
+!eq(mx, "M1") : 1,
+!eq(mx, "M2") : 1,
+!eq(mx, "M4") : 1,
+!eq(mx, "M8") : 2,
+!eq(mx, "MF2") : 1,
+!eq(mx, "MF4") : 1,
+!eq(mx, "MF8") : 1
+  );
+}
+
+// Cycles for segmented loads and stores are calculated using the
+// formula ceil(2 * nf * lmul).
+class SiFive7GetCyclesSegmented {
+  int c = !cond(
+!eq(mx, "M1") : !mul(!mul(2, nf), 1),
+!eq(mx, "M2") : !mul(!mul(2, nf), 2),
+!eq(mx, "M4") : !mul(!mul(2, nf), 4),
+!eq(mx, "M8") : !mul(!mul(2, nf), 8),
+// We can calculate ceil(a/b) using (a + b - 1) / b.
+// Since the 

[clang] ce5ad23 - libclang: declare blocks interfaces always

2023-05-10 Thread Saleem Abdulrasool via cfe-commits

Author: Saleem Abdulrasool
Date: 2023-05-10T10:00:25-07:00
New Revision: ce5ad23ac29bb70427dd22d9ee480d22e0aa6cf1

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

LOG: libclang: declare blocks interfaces always

The implementation of these methods is not reliant on the availability
of the Blocks extension in the compiler.  However, when building on
Windows, the interface declaration is important for the attribution of
the DLL storage.  Without the attribution, the method implementation is
built but not made available as part of the ABI.  Use a check for the
blocks extension to determine how method signature is viewed rather than
controlling whether it is part of the interface.

Added: 


Modified: 
clang/include/clang-c/Index.h

Removed: 




diff  --git a/clang/include/clang-c/Index.h b/clang/include/clang-c/Index.h
index c7d32e6a152ae..2c1bc02003ba3 100644
--- a/clang/include/clang-c/Index.h
+++ b/clang/include/clang-c/Index.h
@@ -48,6 +48,10 @@
 #define CINDEX_VERSION_STRING  
\
   CINDEX_VERSION_STRINGIZE(CINDEX_VERSION_MAJOR, CINDEX_VERSION_MINOR)
 
+#ifndef __has_feature
+#define __has_feature(feature) 0
+#endif
+
 LLVM_CLANG_C_EXTERN_C_BEGIN
 
 /** \defgroup CINDEX libclang: C Interface to Clang
@@ -3856,8 +3860,6 @@ typedef enum CXChildVisitResult 
(*CXCursorVisitor)(CXCursor cursor,
 CINDEX_LINKAGE unsigned clang_visitChildren(CXCursor parent,
 CXCursorVisitor visitor,
 CXClientData client_data);
-#ifdef __has_feature
-#if __has_feature(blocks)
 /**
  * Visitor invoked for each cursor found by a traversal.
  *
@@ -3868,8 +3870,12 @@ CINDEX_LINKAGE unsigned clang_visitChildren(CXCursor 
parent,
  * The visitor should return one of the \c CXChildVisitResult values
  * to direct clang_visitChildrenWithBlock().
  */
+#if __has_feature(blocks)
 typedef enum CXChildVisitResult (^CXCursorVisitorBlock)(CXCursor cursor,
 CXCursor parent);
+#else
+typedef _CXChildVisitResult *CXCursorVisitorBlock;
+#endif
 
 /**
  * Visits the children of a cursor using the specified block.  Behaves
@@ -3877,8 +3883,6 @@ typedef enum CXChildVisitResult 
(^CXCursorVisitorBlock)(CXCursor cursor,
  */
 CINDEX_LINKAGE unsigned
 clang_visitChildrenWithBlock(CXCursor parent, CXCursorVisitorBlock block);
-#endif
-#endif
 
 /**
  * @}
@@ -5879,11 +5883,12 @@ CINDEX_LINKAGE CXResult clang_findReferencesInFile(
 CINDEX_LINKAGE CXResult clang_findIncludesInFile(
 CXTranslationUnit TU, CXFile file, CXCursorAndRangeVisitor visitor);
 
-#ifdef __has_feature
 #if __has_feature(blocks)
-
 typedef enum CXVisitorResult (^CXCursorAndRangeVisitorBlock)(CXCursor,
  CXSourceRange);
+#else
+typedef struct _CXCursorAndRangeVisitorBlock *CXCursorAndRangeVisitorBlock;
+#endif
 
 CINDEX_LINKAGE
 CXResult clang_findReferencesInFileWithBlock(CXCursor, CXFile,
@@ -5893,9 +5898,6 @@ CINDEX_LINKAGE
 CXResult clang_findIncludesInFileWithBlock(CXTranslationUnit, CXFile,
CXCursorAndRangeVisitorBlock);
 
-#endif
-#endif
-
 /**
  * The client's data object that is associated with a CXFile.
  */



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


[PATCH] D150192: Allow clang to emit inrange metadata when generating code for array subscripts

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

See D115274 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150192

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


[PATCH] D149997: [clang] [test] Narrow down MSVC specific behaviours from "any windows" to only MSVC/clang-cl

2023-05-10 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added a comment.

In D149997#4331937 , @thakis wrote:

> This broke check-clang on windows: http://45.33.8.238/win/78359/step_7.txt
>
> (The Driver/split-debug.c failure is something else and since fixed, but the 
> other two tests are due to this change.)
>
> Please take a look and revert for now if it takes a while to fix.

Sorry about this, and thanks for reverting. I’ll have a closer look at the 
issue later.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149997

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


[PATCH] D146418: Support for OpenMP 5.0 sec 2.12.7 - Declare Target initializer expressions

2023-05-10 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: clang/lib/Sema/SemaOpenMP.cpp:23106-23107
+ it != Ex->child_end(); ++it) {
+  if (isa(*it))
+VisitExpr(dyn_cast(*it));
+  if (isa(*it))

Why just a regular Visit does not work here? Plus, isa + dyn_cast is weird.



Comment at: clang/lib/Sema/SemaOpenMP.cpp:23094-23095
+public:
+  SmallVector DeclVector;
+  Decl *TargetDecl;
+  void VisitDeclRefExpr(const DeclRefExpr *Node) {

RitanyaB wrote:
> ABataev wrote:
> > Why public?
> As the data members are accessed from outside the class (in 
> ActOnOpenMPImplicitDeclareTarget function), I have made them public.  
If you need them, implement getters for them and make them private.


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

https://reviews.llvm.org/D146418

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


[PATCH] D149986: AMDGPU: Force sc0 and sc1 on stores for gfx940 and gfx941

2023-05-10 Thread Konstantin Zhuravlyov via Phabricator via cfe-commits
kzhuravl marked an inline comment as done.
kzhuravl added inline comments.



Comment at: llvm/lib/Target/AMDGPU/SIMemoryLegalizer.cpp:524
+ SIAtomicAddrSpace::NONE)
+  return enableSC0Bit(MI) | enableSC1Bit(MI);
+return false;

jmmartinez wrote:
> NIT: Is the use of the bitwise or " | " intended? I'd use the logical or " || 
> " instead.
It is intentional, we need both SC0 and SC1 bits set. If I switch this to || it 
will short circuit and not invoke enableSC1Bit.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149986

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


[PATCH] D146418: Support for OpenMP 5.0 sec 2.12.7 - Declare Target initializer expressions

2023-05-10 Thread Ritanya via Phabricator via cfe-commits
RitanyaB added inline comments.



Comment at: clang/lib/Sema/SemaOpenMP.cpp:23094-23095
+public:
+  SmallVector DeclVector;
+  Decl *TargetDecl;
+  void VisitDeclRefExpr(const DeclRefExpr *Node) {

ABataev wrote:
> Why public?
As the data members are accessed from outside the class (in 
ActOnOpenMPImplicitDeclareTarget function), I have made them public.  



Comment at: clang/lib/Sema/SemaOpenMP.cpp:23107-23110
+  if (isa(*it))
+VisitExpr(dyn_cast(*it));
+  if (isa(*it))
+Visit(*it);

ABataev wrote:
> Just Visit(*it)?
Or I can call VisitDeclRefExpr directly. Would that be more suitable?


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

https://reviews.llvm.org/D146418

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


[PATCH] D146418: Support for OpenMP 5.0 sec 2.12.7 - Declare Target initializer expressions

2023-05-10 Thread Ritanya via Phabricator via cfe-commits
RitanyaB updated this revision to Diff 521014.

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

https://reviews.llvm.org/D146418

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/declare_target_messages.cpp
  clang/test/OpenMP/declare_target_variables_ast_print.cpp
  clang/test/OpenMP/nvptx_target_exceptions_messages.cpp

Index: clang/test/OpenMP/nvptx_target_exceptions_messages.cpp
===
--- clang/test/OpenMP/nvptx_target_exceptions_messages.cpp
+++ clang/test/OpenMP/nvptx_target_exceptions_messages.cpp
@@ -95,7 +95,7 @@
 int (*D)() = C; // expected-note {{used here}}
 // host-note@-1 {{used here}}
 #pragma omp end declare target
-int foobar3() { throw 1; }
+int foobar3() { throw 1; } // expected-error {{cannot use 'throw' with exceptions disabled}}
 
 // Check no infinite recursion in deferred diagnostic emitter.
 long E = (long)
Index: clang/test/OpenMP/declare_target_variables_ast_print.cpp
===
--- /dev/null
+++ clang/test/OpenMP/declare_target_variables_ast_print.cpp
@@ -0,0 +1,111 @@
+// RUN: %clang_cc1 -w -verify -fopenmp -I %S/Inputs -ast-print %s | FileCheck %s --check-prefix=CHECK
+// expected-no-diagnostics
+
+static int variable = 100; 
+static float variable1 = 200;
+static float variable2 = variable1; 
+
+static int var = 1;
+
+static int var1 = 10;
+static int *var2 = 
+static int **ptr1 = 
+
+int arr[2] = {1,2};
+int (*arrptr)[2] = 
+
+class declare{
+  public: int x;
+  void print();
+};
+declare obj1;
+declare *obj2 = 
+
+struct target{
+  int x;
+  void print();
+};
+static target S;
+
+#pragma omp declare target
+int target_var = variable;
+float target_var1 = variable2;
+int *ptr = 
+int ***ptr2 = 
+int (**ptr3)[2] = 
+declare **obj3 = 
+target *S1 = 
+#pragma omp end declare target
+// CHECK: #pragma omp declare target
+// CHECK-NEXT: static int variable = 100;
+// CHECK-NEXT: #pragma omp end declare target
+
+// CHECK-NEXT: #pragma omp declare target
+// CHECK-NEXT: static float variable1 = 200;
+// CHECK-NEXT: #pragma omp end declare target
+// CHECK-NEXT: #pragma omp declare target
+// CHECK-NEXT: static float variable2 = variable1;
+// CHECK-NEXT: #pragma omp end declare target
+
+// CHECK: #pragma omp declare target
+// CHECK-NEXT: static int var = 1;
+// CHECK-NEXT: #pragma omp end declare target
+
+// CHECK-NEXT: #pragma omp declare target
+// CHECK-NEXT: static int var1 = 10;
+// CHECK-NEXT: #pragma omp end declare target
+// CHECK-NEXT: #pragma omp declare target
+// CHECK-NEXT: static int *var2 = 
+// CHECK-NEXT: #pragma omp end declare target
+// CHECK-NEXT: #pragma omp declare target
+// CHECK-NEXT: static int **ptr1 = 
+// CHECK-NEXT: #pragma omp end declare target
+
+// CHECK-NEXT: #pragma omp declare target
+// CHECK-NEXT: int arr[2] = {1, 2};
+// CHECK-NEXT: #pragma omp end declare target
+// CHECK-NEXT: #pragma omp declare target
+// CHECK-NEXT: int (*arrptr)[2] = 
+// CHECK-NEXT: #pragma omp end declare target
+
+// CHECK-NEXT: class declare {
+// CHECK-NEXT: public: 
+// CHECK-NEXT:  int x;
+// CHECK-NEXT:  void print();
+// CHECK-NEXT: };
+// CHECK-NEXT: #pragma omp declare target
+// CHECK-NEXT: declare obj1;
+// CHECK-NEXT: #pragma omp end declare target
+// CHECK-NEXT: #pragma omp declare target
+// CHECK-NEXT: declare *obj2 = 
+// CHECK-NEXT: #pragma omp end declare target
+
+// CHECK-NEXT: struct target {
+// CHECK-NEXT:  int x;
+// CHECK-NEXT:  void print();
+// CHECK-NEXT: };
+// CHECK-NEXT: #pragma omp declare target
+// CHECK-NEXT: static target S;
+// CHECK-NEXT: #pragma omp end declare target
+
+// CHECK-NEXT: #pragma omp declare target
+// CHECK-NEXT: int target_var = variable;
+// CHECK-NEXT: #pragma omp end declare target
+// CHECK-NEXT: #pragma omp declare target
+// CHECK-NEXT: float target_var1 = variable2;
+// CHECK-NEXT: #pragma omp end declare target
+// CHECK-NEXT: #pragma omp declare target
+// CHECK-NEXT: int *ptr = 
+// CHECK-NEXT: #pragma omp end declare target
+// CHECK-NEXT: #pragma omp declare target
+// CHECK-NEXT: int ***ptr2 = 
+// CHECK-NEXT: #pragma omp end declare target
+// CHECK-NEXT: #pragma omp declare target
+// CHECK-NEXT: int (**ptr3)[2] = 
+// CHECK-NEXT: #pragma omp end declare target
+// CHECK-NEXT: #pragma omp declare target
+// CHECK-NEXT: declare **obj3 =  
+// CHECK-NEXT: #pragma omp end declare target
+// CHECK-NEXT: #pragma omp declare target
+// CHECK-NEXT: target *S1 = 
+// CHECK-NEXT: #pragma omp end declare target
Index: clang/test/OpenMP/declare_target_messages.cpp
===
--- clang/test/OpenMP/declare_target_messages.cpp
+++ clang/test/OpenMP/declare_target_messages.cpp
@@ -233,6 +233,42 @@
 #pragma omp declare target to(MultiDevTy) device_type(host)   // omp45-error {{unexpected 'device_type' clause, only 'to' 

[PATCH] D149983: AMDGPU: Add basic gfx942 target

2023-05-10 Thread Konstantin Zhuravlyov 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 rG9d0572797233: AMDGPU: Add basic gfx942 target (authored by 
kzhuravl).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149983

Files:
  clang/include/clang/Basic/Cuda.h
  clang/lib/Basic/Cuda.cpp
  clang/lib/Basic/Targets/NVPTX.cpp
  clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
  clang/test/CodeGenOpenCL/amdgpu-features.cl
  clang/test/Driver/amdgpu-macros.cl
  clang/test/Driver/amdgpu-mcpu.cl
  clang/test/Misc/target-invalid-cpu-note.c
  llvm/docs/AMDGPUUsage.rst
  llvm/include/llvm/BinaryFormat/ELF.h
  llvm/include/llvm/TargetParser/TargetParser.h
  llvm/lib/Object/ELFObjectFile.cpp
  llvm/lib/ObjectYAML/ELFYAML.cpp
  llvm/lib/Target/AMDGPU/AMDGPU.td
  llvm/lib/Target/AMDGPU/GCNProcessors.td
  llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUTargetStreamer.cpp
  llvm/lib/TargetParser/TargetParser.cpp
  llvm/test/CodeGen/AMDGPU/directive-amdgcn-target.ll
  llvm/test/CodeGen/AMDGPU/elf-header-flags-mach.ll
  llvm/test/Object/AMDGPU/elf-header-flags-mach.yaml
  llvm/test/tools/llvm-objdump/ELF/AMDGPU/subtarget.ll
  llvm/test/tools/llvm-readobj/ELF/amdgpu-elf-headers.test
  llvm/tools/llvm-readobj/ELFDumper.cpp

Index: llvm/tools/llvm-readobj/ELFDumper.cpp
===
--- llvm/tools/llvm-readobj/ELFDumper.cpp
+++ llvm/tools/llvm-readobj/ELFDumper.cpp
@@ -1589,6 +1589,7 @@
   LLVM_READOBJ_ENUM_ENT(ELF, EF_AMDGPU_MACH_AMDGCN_GFX90C),
   LLVM_READOBJ_ENUM_ENT(ELF, EF_AMDGPU_MACH_AMDGCN_GFX940),
   LLVM_READOBJ_ENUM_ENT(ELF, EF_AMDGPU_MACH_AMDGCN_GFX941),
+  LLVM_READOBJ_ENUM_ENT(ELF, EF_AMDGPU_MACH_AMDGCN_GFX942),
   LLVM_READOBJ_ENUM_ENT(ELF, EF_AMDGPU_MACH_AMDGCN_GFX1010),
   LLVM_READOBJ_ENUM_ENT(ELF, EF_AMDGPU_MACH_AMDGCN_GFX1011),
   LLVM_READOBJ_ENUM_ENT(ELF, EF_AMDGPU_MACH_AMDGCN_GFX1012),
@@ -1650,6 +1651,7 @@
   LLVM_READOBJ_ENUM_ENT(ELF, EF_AMDGPU_MACH_AMDGCN_GFX90C),
   LLVM_READOBJ_ENUM_ENT(ELF, EF_AMDGPU_MACH_AMDGCN_GFX940),
   LLVM_READOBJ_ENUM_ENT(ELF, EF_AMDGPU_MACH_AMDGCN_GFX941),
+  LLVM_READOBJ_ENUM_ENT(ELF, EF_AMDGPU_MACH_AMDGCN_GFX942),
   LLVM_READOBJ_ENUM_ENT(ELF, EF_AMDGPU_MACH_AMDGCN_GFX1010),
   LLVM_READOBJ_ENUM_ENT(ELF, EF_AMDGPU_MACH_AMDGCN_GFX1011),
   LLVM_READOBJ_ENUM_ENT(ELF, EF_AMDGPU_MACH_AMDGCN_GFX1012),
Index: llvm/test/tools/llvm-readobj/ELF/amdgpu-elf-headers.test
===
--- llvm/test/tools/llvm-readobj/ELF/amdgpu-elf-headers.test
+++ llvm/test/tools/llvm-readobj/ELF/amdgpu-elf-headers.test
@@ -214,6 +214,15 @@
 # RUN: yaml2obj %s -o %t -DABI_VERSION=2 -DFLAG_NAME=EF_AMDGPU_MACH_AMDGCN_GFX941
 # RUN: llvm-readobj -h %t | FileCheck %s --check-prefixes=ALL,KNOWN-ABI-VERSION,SINGLE-FLAG --match-full-lines -DABI_VERSION=2 -DFILE=%t -DFLAG_NAME=EF_AMDGPU_MACH_AMDGCN_GFX941 -DFLAG_VALUE=0x4B
 
+# RUN: yaml2obj %s -o %t -DABI_VERSION=0 -DFLAG_NAME=EF_AMDGPU_MACH_AMDGCN_GFX942
+# RUN: llvm-readobj -h %t | FileCheck %s --check-prefixes=ALL,KNOWN-ABI-VERSION,SINGLE-FLAG --match-full-lines -DABI_VERSION=0 -DFILE=%t -DFLAG_NAME=EF_AMDGPU_MACH_AMDGCN_GFX942 -DFLAG_VALUE=0x4C
+
+# RUN: yaml2obj %s -o %t -DABI_VERSION=1 -DFLAG_NAME=EF_AMDGPU_MACH_AMDGCN_GFX942
+# RUN: llvm-readobj -h %t | FileCheck %s --check-prefixes=ALL,KNOWN-ABI-VERSION,SINGLE-FLAG --match-full-lines -DABI_VERSION=1 -DFILE=%t -DFLAG_NAME=EF_AMDGPU_MACH_AMDGCN_GFX942 -DFLAG_VALUE=0x4C
+
+# RUN: yaml2obj %s -o %t -DABI_VERSION=2 -DFLAG_NAME=EF_AMDGPU_MACH_AMDGCN_GFX942
+# RUN: llvm-readobj -h %t | FileCheck %s --check-prefixes=ALL,KNOWN-ABI-VERSION,SINGLE-FLAG --match-full-lines -DABI_VERSION=2 -DFILE=%t -DFLAG_NAME=EF_AMDGPU_MACH_AMDGCN_GFX942 -DFLAG_VALUE=0x4C
+
 # RUN: yaml2obj %s -o %t -DABI_VERSION=0 -DFLAG_NAME=EF_AMDGPU_MACH_AMDGCN_GFX1010
 # RUN: llvm-readobj -h %t | FileCheck %s --check-prefixes=ALL,KNOWN-ABI-VERSION,SINGLE-FLAG --match-full-lines -DABI_VERSION=0 -DFILE=%t -DFLAG_NAME=EF_AMDGPU_MACH_AMDGCN_GFX1010 -DFLAG_VALUE=0x33
 
Index: llvm/test/tools/llvm-objdump/ELF/AMDGPU/subtarget.ll
===
--- llvm/test/tools/llvm-objdump/ELF/AMDGPU/subtarget.ll
+++ llvm/test/tools/llvm-objdump/ELF/AMDGPU/subtarget.ll
@@ -85,6 +85,11 @@
 
 ; --GFX9---
 ;
+; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx942 -filetype=obj -O0 -o %t.o %s
+; RUN: llvm-objdump -D --arch-name=amdgcn --mcpu=gfx942 %t.o > %t-specify.txt
+; RUN: llvm-objdump -D %t.o > %t-detect.txt
+; RUN: diff %t-specify.txt %t-detect.txt
+
 ; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx941 -filetype=obj -O0 -o %t.o %s
 ; RUN: llvm-objdump -D --arch-name=amdgcn --mcpu=gfx941 %t.o > %t-specify.txt
 ; RUN: llvm-objdump -D %t.o > %t-detect.txt
Index: llvm/test/Object/AMDGPU/elf-header-flags-mach.yaml

[PATCH] D149982: AMDGPU: Add basic gfx941 target

2023-05-10 Thread Konstantin Zhuravlyov 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 rG1fc70210a6a5: AMDGPU: Add basic gfx941 target (authored by 
kzhuravl).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149982

Files:
  clang/include/clang/Basic/Cuda.h
  clang/lib/Basic/Cuda.cpp
  clang/lib/Basic/Targets/NVPTX.cpp
  clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
  clang/test/CodeGenOpenCL/amdgpu-features.cl
  clang/test/Driver/amdgpu-macros.cl
  clang/test/Driver/amdgpu-mcpu.cl
  clang/test/Misc/target-invalid-cpu-note.c
  llvm/docs/AMDGPUUsage.rst
  llvm/include/llvm/BinaryFormat/ELF.h
  llvm/include/llvm/TargetParser/TargetParser.h
  llvm/lib/Object/ELFObjectFile.cpp
  llvm/lib/ObjectYAML/ELFYAML.cpp
  llvm/lib/Target/AMDGPU/AMDGPU.td
  llvm/lib/Target/AMDGPU/GCNProcessors.td
  llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUTargetStreamer.cpp
  llvm/lib/TargetParser/TargetParser.cpp
  llvm/test/CodeGen/AMDGPU/directive-amdgcn-target.ll
  llvm/test/CodeGen/AMDGPU/elf-header-flags-mach.ll
  llvm/test/Object/AMDGPU/elf-header-flags-mach.yaml
  llvm/test/tools/llvm-objdump/ELF/AMDGPU/subtarget.ll
  llvm/test/tools/llvm-readobj/ELF/amdgpu-elf-headers.test
  llvm/tools/llvm-readobj/ELFDumper.cpp

Index: llvm/tools/llvm-readobj/ELFDumper.cpp
===
--- llvm/tools/llvm-readobj/ELFDumper.cpp
+++ llvm/tools/llvm-readobj/ELFDumper.cpp
@@ -1588,6 +1588,7 @@
   LLVM_READOBJ_ENUM_ENT(ELF, EF_AMDGPU_MACH_AMDGCN_GFX90A),
   LLVM_READOBJ_ENUM_ENT(ELF, EF_AMDGPU_MACH_AMDGCN_GFX90C),
   LLVM_READOBJ_ENUM_ENT(ELF, EF_AMDGPU_MACH_AMDGCN_GFX940),
+  LLVM_READOBJ_ENUM_ENT(ELF, EF_AMDGPU_MACH_AMDGCN_GFX941),
   LLVM_READOBJ_ENUM_ENT(ELF, EF_AMDGPU_MACH_AMDGCN_GFX1010),
   LLVM_READOBJ_ENUM_ENT(ELF, EF_AMDGPU_MACH_AMDGCN_GFX1011),
   LLVM_READOBJ_ENUM_ENT(ELF, EF_AMDGPU_MACH_AMDGCN_GFX1012),
@@ -1648,6 +1649,7 @@
   LLVM_READOBJ_ENUM_ENT(ELF, EF_AMDGPU_MACH_AMDGCN_GFX90A),
   LLVM_READOBJ_ENUM_ENT(ELF, EF_AMDGPU_MACH_AMDGCN_GFX90C),
   LLVM_READOBJ_ENUM_ENT(ELF, EF_AMDGPU_MACH_AMDGCN_GFX940),
+  LLVM_READOBJ_ENUM_ENT(ELF, EF_AMDGPU_MACH_AMDGCN_GFX941),
   LLVM_READOBJ_ENUM_ENT(ELF, EF_AMDGPU_MACH_AMDGCN_GFX1010),
   LLVM_READOBJ_ENUM_ENT(ELF, EF_AMDGPU_MACH_AMDGCN_GFX1011),
   LLVM_READOBJ_ENUM_ENT(ELF, EF_AMDGPU_MACH_AMDGCN_GFX1012),
Index: llvm/test/tools/llvm-readobj/ELF/amdgpu-elf-headers.test
===
--- llvm/test/tools/llvm-readobj/ELF/amdgpu-elf-headers.test
+++ llvm/test/tools/llvm-readobj/ELF/amdgpu-elf-headers.test
@@ -205,6 +205,15 @@
 # RUN: yaml2obj %s -o %t -DABI_VERSION=2 -DFLAG_NAME=EF_AMDGPU_MACH_AMDGCN_GFX940
 # RUN: llvm-readobj -h %t | FileCheck %s --check-prefixes=ALL,KNOWN-ABI-VERSION,SINGLE-FLAG --match-full-lines -DABI_VERSION=2 -DFILE=%t -DFLAG_NAME=EF_AMDGPU_MACH_AMDGCN_GFX940 -DFLAG_VALUE=0x40
 
+# RUN: yaml2obj %s -o %t -DABI_VERSION=0 -DFLAG_NAME=EF_AMDGPU_MACH_AMDGCN_GFX941
+# RUN: llvm-readobj -h %t | FileCheck %s --check-prefixes=ALL,KNOWN-ABI-VERSION,SINGLE-FLAG --match-full-lines -DABI_VERSION=0 -DFILE=%t -DFLAG_NAME=EF_AMDGPU_MACH_AMDGCN_GFX941 -DFLAG_VALUE=0x4B
+
+# RUN: yaml2obj %s -o %t -DABI_VERSION=1 -DFLAG_NAME=EF_AMDGPU_MACH_AMDGCN_GFX941
+# RUN: llvm-readobj -h %t | FileCheck %s --check-prefixes=ALL,KNOWN-ABI-VERSION,SINGLE-FLAG --match-full-lines -DABI_VERSION=1 -DFILE=%t -DFLAG_NAME=EF_AMDGPU_MACH_AMDGCN_GFX941 -DFLAG_VALUE=0x4B
+
+# RUN: yaml2obj %s -o %t -DABI_VERSION=2 -DFLAG_NAME=EF_AMDGPU_MACH_AMDGCN_GFX941
+# RUN: llvm-readobj -h %t | FileCheck %s --check-prefixes=ALL,KNOWN-ABI-VERSION,SINGLE-FLAG --match-full-lines -DABI_VERSION=2 -DFILE=%t -DFLAG_NAME=EF_AMDGPU_MACH_AMDGCN_GFX941 -DFLAG_VALUE=0x4B
+
 # RUN: yaml2obj %s -o %t -DABI_VERSION=0 -DFLAG_NAME=EF_AMDGPU_MACH_AMDGCN_GFX1010
 # RUN: llvm-readobj -h %t | FileCheck %s --check-prefixes=ALL,KNOWN-ABI-VERSION,SINGLE-FLAG --match-full-lines -DABI_VERSION=0 -DFILE=%t -DFLAG_NAME=EF_AMDGPU_MACH_AMDGCN_GFX1010 -DFLAG_VALUE=0x33
 
Index: llvm/test/tools/llvm-objdump/ELF/AMDGPU/subtarget.ll
===
--- llvm/test/tools/llvm-objdump/ELF/AMDGPU/subtarget.ll
+++ llvm/test/tools/llvm-objdump/ELF/AMDGPU/subtarget.ll
@@ -85,6 +85,11 @@
 
 ; --GFX9---
 ;
+; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx941 -filetype=obj -O0 -o %t.o %s
+; RUN: llvm-objdump -D --arch-name=amdgcn --mcpu=gfx941 %t.o > %t-specify.txt
+; RUN: llvm-objdump -D %t.o > %t-detect.txt
+; RUN: diff %t-specify.txt %t-detect.txt
+
 ; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx940 -filetype=obj -O0 -o %t.o %s
 ; RUN: llvm-objdump -D --arch-name=amdgcn --mcpu=gfx940 %t.o > %t-specify.txt
 ; RUN: llvm-objdump -D %t.o > %t-detect.txt
Index: llvm/test/Object/AMDGPU/elf-header-flags-mach.yaml

[clang] 9d05727 - AMDGPU: Add basic gfx942 target

2023-05-10 Thread Konstantin Zhuravlyov via cfe-commits

Author: Konstantin Zhuravlyov
Date: 2023-05-10T11:51:06-04:00
New Revision: 9d0572797233857397f3fdc35fffcfb490354f56

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

LOG: AMDGPU: Add basic gfx942 target

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

Added: 


Modified: 
clang/include/clang/Basic/Cuda.h
clang/lib/Basic/Cuda.cpp
clang/lib/Basic/Targets/NVPTX.cpp
clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
clang/test/CodeGenOpenCL/amdgpu-features.cl
clang/test/Driver/amdgpu-macros.cl
clang/test/Driver/amdgpu-mcpu.cl
clang/test/Misc/target-invalid-cpu-note.c
llvm/docs/AMDGPUUsage.rst
llvm/include/llvm/BinaryFormat/ELF.h
llvm/include/llvm/TargetParser/TargetParser.h
llvm/lib/Object/ELFObjectFile.cpp
llvm/lib/ObjectYAML/ELFYAML.cpp
llvm/lib/Target/AMDGPU/AMDGPU.td
llvm/lib/Target/AMDGPU/GCNProcessors.td
llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUTargetStreamer.cpp
llvm/lib/TargetParser/TargetParser.cpp
llvm/test/CodeGen/AMDGPU/directive-amdgcn-target.ll
llvm/test/CodeGen/AMDGPU/elf-header-flags-mach.ll
llvm/test/Object/AMDGPU/elf-header-flags-mach.yaml
llvm/test/tools/llvm-objdump/ELF/AMDGPU/subtarget.ll
llvm/test/tools/llvm-readobj/ELF/amdgpu-elf-headers.test
llvm/tools/llvm-readobj/ELFDumper.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/Cuda.h 
b/clang/include/clang/Basic/Cuda.h
index dddbd651054da..2b8fc2a0bb1c3 100644
--- a/clang/include/clang/Basic/Cuda.h
+++ b/clang/include/clang/Basic/Cuda.h
@@ -93,6 +93,7 @@ enum class CudaArch {
   GFX90c,
   GFX940,
   GFX941,
+  GFX942,
   GFX1010,
   GFX1011,
   GFX1012,

diff  --git a/clang/lib/Basic/Cuda.cpp b/clang/lib/Basic/Cuda.cpp
index baca1106b263b..db30142ad866d 100644
--- a/clang/lib/Basic/Cuda.cpp
+++ b/clang/lib/Basic/Cuda.cpp
@@ -115,6 +115,7 @@ static const CudaArchToStringMap arch_names[] = {
 GFX(90c),  // gfx90c
 GFX(940),  // gfx940
 GFX(941),  // gfx941
+GFX(942),  // gfx942
 GFX(1010), // gfx1010
 GFX(1011), // gfx1011
 GFX(1012), // gfx1012

diff  --git a/clang/lib/Basic/Targets/NVPTX.cpp 
b/clang/lib/Basic/Targets/NVPTX.cpp
index 17e38a4f1d299..cfcf4ca36f285 100644
--- a/clang/lib/Basic/Targets/NVPTX.cpp
+++ b/clang/lib/Basic/Targets/NVPTX.cpp
@@ -196,6 +196,7 @@ void NVPTXTargetInfo::getTargetDefines(const LangOptions 
,
   case CudaArch::GFX90c:
   case CudaArch::GFX940:
   case CudaArch::GFX941:
+  case CudaArch::GFX942:
   case CudaArch::GFX1010:
   case CudaArch::GFX1011:
   case CudaArch::GFX1012:

diff  --git a/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp 
b/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
index dd0ed791588a9..74f8c19e1bc7e 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
@@ -3581,6 +3581,7 @@ void CGOpenMPRuntimeGPU::processRequiresDirective(
   case CudaArch::GFX90c:
   case CudaArch::GFX940:
   case CudaArch::GFX941:
+  case CudaArch::GFX942:
   case CudaArch::GFX1010:
   case CudaArch::GFX1011:
   case CudaArch::GFX1012:

diff  --git a/clang/test/CodeGenOpenCL/amdgpu-features.cl 
b/clang/test/CodeGenOpenCL/amdgpu-features.cl
index 5f452ae63925f..efa5759558cc5 100644
--- a/clang/test/CodeGenOpenCL/amdgpu-features.cl
+++ b/clang/test/CodeGenOpenCL/amdgpu-features.cl
@@ -31,6 +31,7 @@
 // RUN: %clang_cc1 -triple amdgcn -target-cpu gfx90c -S -emit-llvm -o - %s | 
FileCheck --check-prefix=GFX90C %s
 // RUN: %clang_cc1 -triple amdgcn -target-cpu gfx940 -S -emit-llvm -o - %s | 
FileCheck --check-prefix=GFX940 %s
 // RUN: %clang_cc1 -triple amdgcn -target-cpu gfx941 -S -emit-llvm -o - %s | 
FileCheck --check-prefix=GFX941 %s
+// RUN: %clang_cc1 -triple amdgcn -target-cpu gfx942 -S -emit-llvm -o - %s | 
FileCheck --check-prefix=GFX942 %s
 // RUN: %clang_cc1 -triple amdgcn -target-cpu gfx1010 -S -emit-llvm -o - %s | 
FileCheck --check-prefix=GFX1010 %s
 // RUN: %clang_cc1 -triple amdgcn -target-cpu gfx1011 -S -emit-llvm -o - %s | 
FileCheck --check-prefix=GFX1011 %s
 // RUN: %clang_cc1 -triple amdgcn -target-cpu gfx1012 -S -emit-llvm -o - %s | 
FileCheck --check-prefix=GFX1012 %s
@@ -77,6 +78,7 @@
 // GFX90C: 
"target-features"="+16-bit-insts,+ci-insts,+dpp,+gfx8-insts,+gfx9-insts,+s-memrealtime,+s-memtime-inst,+wavefrontsize64"
 // GFX940: 
"target-features"="+16-bit-insts,+atomic-buffer-global-pk-add-f16-insts,+atomic-ds-pk-add-16-insts,+atomic-fadd-rtn-insts,+atomic-flat-pk-add-16-insts,+atomic-global-pk-add-bf16-inst,+ci-insts,+dl-insts,+dot1-insts,+dot10-insts,+dot2-insts,+dot3-insts,+dot4-insts,+dot5-insts,+dot6-insts,+dot7-insts,+dpp,+fp8-insts,+gfx8-insts,+gfx9-insts,+gfx90a-insts,+gfx940-insts,+mai-insts,+s-memrealtime,+s-memtime-inst,+wavefrontsize64"
 // 

[clang] 1fc7021 - AMDGPU: Add basic gfx941 target

2023-05-10 Thread Konstantin Zhuravlyov via cfe-commits

Author: Konstantin Zhuravlyov
Date: 2023-05-10T11:51:06-04:00
New Revision: 1fc70210a6a585bad941f64bd3fca7909eeafdda

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

LOG: AMDGPU: Add basic gfx941 target

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

Added: 


Modified: 
clang/include/clang/Basic/Cuda.h
clang/lib/Basic/Cuda.cpp
clang/lib/Basic/Targets/NVPTX.cpp
clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
clang/test/CodeGenOpenCL/amdgpu-features.cl
clang/test/Driver/amdgpu-macros.cl
clang/test/Driver/amdgpu-mcpu.cl
clang/test/Misc/target-invalid-cpu-note.c
llvm/docs/AMDGPUUsage.rst
llvm/include/llvm/BinaryFormat/ELF.h
llvm/include/llvm/TargetParser/TargetParser.h
llvm/lib/Object/ELFObjectFile.cpp
llvm/lib/ObjectYAML/ELFYAML.cpp
llvm/lib/Target/AMDGPU/AMDGPU.td
llvm/lib/Target/AMDGPU/GCNProcessors.td
llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUTargetStreamer.cpp
llvm/lib/TargetParser/TargetParser.cpp
llvm/test/CodeGen/AMDGPU/directive-amdgcn-target.ll
llvm/test/CodeGen/AMDGPU/elf-header-flags-mach.ll
llvm/test/Object/AMDGPU/elf-header-flags-mach.yaml
llvm/test/tools/llvm-objdump/ELF/AMDGPU/subtarget.ll
llvm/test/tools/llvm-readobj/ELF/amdgpu-elf-headers.test
llvm/tools/llvm-readobj/ELFDumper.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/Cuda.h 
b/clang/include/clang/Basic/Cuda.h
index 8ff28944f23d5..dddbd651054da 100644
--- a/clang/include/clang/Basic/Cuda.h
+++ b/clang/include/clang/Basic/Cuda.h
@@ -92,6 +92,7 @@ enum class CudaArch {
   GFX90a,
   GFX90c,
   GFX940,
+  GFX941,
   GFX1010,
   GFX1011,
   GFX1012,

diff  --git a/clang/lib/Basic/Cuda.cpp b/clang/lib/Basic/Cuda.cpp
index b4cf6cbe95f8b..baca1106b263b 100644
--- a/clang/lib/Basic/Cuda.cpp
+++ b/clang/lib/Basic/Cuda.cpp
@@ -114,6 +114,7 @@ static const CudaArchToStringMap arch_names[] = {
 GFX(90a),  // gfx90a
 GFX(90c),  // gfx90c
 GFX(940),  // gfx940
+GFX(941),  // gfx941
 GFX(1010), // gfx1010
 GFX(1011), // gfx1011
 GFX(1012), // gfx1012

diff  --git a/clang/lib/Basic/Targets/NVPTX.cpp 
b/clang/lib/Basic/Targets/NVPTX.cpp
index 5eaa21e1a8f6a..17e38a4f1d299 100644
--- a/clang/lib/Basic/Targets/NVPTX.cpp
+++ b/clang/lib/Basic/Targets/NVPTX.cpp
@@ -195,6 +195,7 @@ void NVPTXTargetInfo::getTargetDefines(const LangOptions 
,
   case CudaArch::GFX90a:
   case CudaArch::GFX90c:
   case CudaArch::GFX940:
+  case CudaArch::GFX941:
   case CudaArch::GFX1010:
   case CudaArch::GFX1011:
   case CudaArch::GFX1012:

diff  --git a/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp 
b/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
index 68c4fc872e3b8..dd0ed791588a9 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
@@ -3580,6 +3580,7 @@ void CGOpenMPRuntimeGPU::processRequiresDirective(
   case CudaArch::GFX90a:
   case CudaArch::GFX90c:
   case CudaArch::GFX940:
+  case CudaArch::GFX941:
   case CudaArch::GFX1010:
   case CudaArch::GFX1011:
   case CudaArch::GFX1012:

diff  --git a/clang/test/CodeGenOpenCL/amdgpu-features.cl 
b/clang/test/CodeGenOpenCL/amdgpu-features.cl
index e000239cd03fe..5f452ae63925f 100644
--- a/clang/test/CodeGenOpenCL/amdgpu-features.cl
+++ b/clang/test/CodeGenOpenCL/amdgpu-features.cl
@@ -30,6 +30,7 @@
 // RUN: %clang_cc1 -triple amdgcn -target-cpu gfx90a -S -emit-llvm -o - %s | 
FileCheck --check-prefix=GFX90A %s
 // RUN: %clang_cc1 -triple amdgcn -target-cpu gfx90c -S -emit-llvm -o - %s | 
FileCheck --check-prefix=GFX90C %s
 // RUN: %clang_cc1 -triple amdgcn -target-cpu gfx940 -S -emit-llvm -o - %s | 
FileCheck --check-prefix=GFX940 %s
+// RUN: %clang_cc1 -triple amdgcn -target-cpu gfx941 -S -emit-llvm -o - %s | 
FileCheck --check-prefix=GFX941 %s
 // RUN: %clang_cc1 -triple amdgcn -target-cpu gfx1010 -S -emit-llvm -o - %s | 
FileCheck --check-prefix=GFX1010 %s
 // RUN: %clang_cc1 -triple amdgcn -target-cpu gfx1011 -S -emit-llvm -o - %s | 
FileCheck --check-prefix=GFX1011 %s
 // RUN: %clang_cc1 -triple amdgcn -target-cpu gfx1012 -S -emit-llvm -o - %s | 
FileCheck --check-prefix=GFX1012 %s
@@ -75,6 +76,7 @@
 // GFX90A: 
"target-features"="+16-bit-insts,+atomic-buffer-global-pk-add-f16-insts,+atomic-fadd-rtn-insts,+ci-insts,+dl-insts,+dot1-insts,+dot10-insts,+dot2-insts,+dot3-insts,+dot4-insts,+dot5-insts,+dot6-insts,+dot7-insts,+dpp,+gfx8-insts,+gfx9-insts,+gfx90a-insts,+mai-insts,+s-memrealtime,+s-memtime-inst,+wavefrontsize64"
 // GFX90C: 
"target-features"="+16-bit-insts,+ci-insts,+dpp,+gfx8-insts,+gfx9-insts,+s-memrealtime,+s-memtime-inst,+wavefrontsize64"
 // GFX940: 

[PATCH] D149158: [clang][analyzer] Cleanup tests of StdCLibraryFunctionsChecker (NFC)

2023-05-10 Thread Balázs Kéri via Phabricator via cfe-commits
balazske added inline comments.



Comment at: clang/test/Analysis/Inputs/std-c-library-functions.h:1-2
+typedef typeof(sizeof(int)) size_t;
+typedef signed long ssize_t;
+typedef struct {

steakhal wrote:
> balazske wrote:
> > steakhal wrote:
> > > `ssize_t`'s size should match the size of `size_t`. In this 
> > > implementation, it would be true only if `size_t` is `long`.
> > > 
> > I could not find a working way of defining the type in that way (there is 
> > no `__sizte_t`). The current definition should work well in the test code, 
> > the property of being the same size is supposedly not used in the tests. 
> > The previous definition was not better than this (and different in 
> > different places).
> I think [[ 
> https://github.com/llvm/llvm-project/blob/main/clang/test/Sema/format-strings-scanf.c#L7-L15
>  | clang/test/Sema/format-strings-scanf.c ]] uses something like this: 
> ```lang=C++
> typedef __SIZE_TYPE__ size_t;
> #define __SSIZE_TYPE__
>  \
>   __typeof__(_Generic((__SIZE_TYPE__)0,   
>  \
>   unsigned long long int : (long long int)0,  
>  \
>   unsigned long int : (long int)0,
>  \
>   unsigned int : (int)0,  
>  \
>   unsigned short : (short)0,  
>  \
>   unsigned char : (signed char)0))
> typedef __SSIZE_TYPE__ ssize_t;
> ```
This may work (probably not on all platforms) but still I think in this context 
it is only important that we have a type called `ssize_t` and it is signed, it 
is less important that it is exactly the correct type. Other types in the same 
header are not exact, and `ssize_t` in other test code (in Analysis tests) is 
defined not in this way.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149158

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


[PATCH] D146809: [clang-repl] Implement Value pretty printing

2023-05-10 Thread Jun Zhang via Phabricator via cfe-commits
junaire updated this revision to Diff 520998.
junaire added a comment.

Export symbols in Windows.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146809

Files:
  clang/include/clang/Interpreter/Interpreter.h
  clang/include/clang/Interpreter/Value.h
  clang/lib/Headers/CMakeLists.txt
  clang/lib/Headers/__clang_interpreter_runtime_printvalue.h
  clang/lib/Interpreter/CMakeLists.txt
  clang/lib/Interpreter/IncrementalExecutor.cpp
  clang/lib/Interpreter/IncrementalExecutor.h
  clang/lib/Interpreter/IncrementalParser.h
  clang/lib/Interpreter/Interpreter.cpp
  clang/lib/Interpreter/InterpreterUtils.cpp
  clang/lib/Interpreter/InterpreterUtils.h
  clang/lib/Interpreter/Value.cpp
  clang/lib/Interpreter/ValuePrinter.cpp
  clang/test/Interpreter/pretty-print.cpp
  clang/tools/clang-repl/CMakeLists.txt

Index: clang/tools/clang-repl/CMakeLists.txt
===
--- clang/tools/clang-repl/CMakeLists.txt
+++ clang/tools/clang-repl/CMakeLists.txt
@@ -11,6 +11,65 @@
   ClangRepl.cpp
   )
 
+if(MSVC)
+  set_target_properties(clang-repl PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS 1)
+
+  # RTTI/C++ symbols
+  set(clang_repl_exports ${clang_repl_exports} ??_7type_info@@6B@
+?__type_info_root_node@@3U__type_info_node@@A
+?nothrow@std@@3Unothrow_t@1@B
+  )
+
+  # Compiler added symbols for static variables. NOT for VStudio < 2015
+  set(clang_repl_exports ${clang_repl_exports} _Init_thread_abort _Init_thread_epoch
+_Init_thread_footer _Init_thread_header _tls_index
+  )
+
+  if(CMAKE_SIZEOF_VOID_P EQUAL 8)
+# new/delete variants needed when linking to static msvc runtime (esp. Debug)
+set(clang_repl_exports ${clang_repl_exports}
+  ??2@YAPEAX_K@Z
+  ??3@YAXPEAX@Z
+  ??_U@YAPEAX_K@Z
+  ??_V@YAXPEAX@Z
+  ??3@YAXPEAX_K@Z
+  ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@H@Z
+  ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@M@Z
+  ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@N@Z
+  ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@PEBX@Z
+  ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@P6AAEAV01@AEAV01@@Z@Z
+  ??$?6U?$char_traits@D@std@@@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@0@AEAV10@D@Z
+  ??$?6U?$char_traits@D@std@@@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@0@AEAV10@PEBD@Z
+  ?_Facet_Register@std@@YAXPEAV_Facet_base@1@@Z
+)
+  else()
+set(clang_repl_exports ${clang_repl_exports}
+  ??2@YAPAXI@Z
+  ??3@YAXPAX@Z
+  ??3@YAXPAXI@Z
+  ??_U@YAPAXI@Z
+  ??_V@YAXPAX@Z
+  ??_V@YAXPAXI@Z
+  ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@H@Z
+  ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@M@Z
+  ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@N@Z
+  ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@PBX@Z
+  ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@P6AAAV01@AAV01@@Z@Z
+  ??$?6U?$char_traits@D@std@@@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@0@AAV10@D@Z
+  ??$?6U?$char_traits@D@std@@@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@0@AAV10@PBD@Z
+  ?_Facet_Register@std@@YAXPAV_Facet_base@1@@Z
+)
+  endif()
+
+  # List to '/EXPORT:sym0 /EXPORT:sym1 /EXPORT:sym2 ...'
+  foreach(sym ${clang_repl_exports})
+set(clang_repl_link_str "${clang_repl_link_str} /EXPORT:${sym}")
+  endforeach(sym ${clang_repl_exports})
+
+  set_property(TARGET clang-repl APPEND_STRING PROPERTY LINK_FLAGS ${clang_repl_link_str})
+
+endif(MSVC)
+
 clang_target_link_libraries(clang-repl PRIVATE
   clangAST
   clangBasic
Index: clang/test/Interpreter/pretty-print.cpp
===
--- /dev/null
+++ clang/test/Interpreter/pretty-print.cpp
@@ -0,0 +1,180 @@
+// RUN: clang-repl "int i = 10;" 'extern "C" int printf(const char*,...);' \
+// RUN:'auto r1 = printf("i = %d\n", i);' | FileCheck --check-prefix=CHECK-DRIVER %s
+// UNSUPPORTED: system-aix
+// CHECK-DRIVER: i = 10
+// RUN: cat %s | clang-repl | FileCheck %s
+extern "C" int printf(const char*,...);
+
+char c = 'a';
+c
+// CHECK: (char) 'a'
+
+const char* c_str = "Goodbye, world!";
+c_str
+// CHECK-NEXT: (const char *) "Goodbye, world!"
+
+const char* c_null_str = 0;
+c_null_str
+// CHECK-NEXT: (const char *) nullptr
+
+"Hello, world"
+// CHECK-NEXT: (const char[13]) "Hello, world"
+
+int x = 42;
+x
+// CHECK-NEXT: (int) 42
+
+
+// CHECK-NEXT: (int *) [[Addr:@0x.*]]
+
+x - 2
+// CHECK-NEXT: (int) 40
+
+float f = 4.2f;
+f
+// CHECK-NEXT: (float) 4.2f
+
+double d = 4.21;
+d
+// CHECK-NEXT: (double) 4.210
+
+struct S1{};
+S1 s1;
+s1
+// CHECK-NEXT: (S1 &) [[Addr:@0x.*]]
+
+S1{}
+// CHECK-NEXT: (S1) [[Addr:@0x.*]]
+
+struct S2 {int d;} E = {22};
+E
+// CHECK-NEXT: (struct S2 &) [[Addr:@0x.*]]
+E.d
+// CHECK-NEXT: (int) 22
+

[PATCH] D150221: Add option -fkeep-static-variables to emit all static variables

2023-05-10 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added a comment.

In D150221#4332142 , @erichkeane 
wrote:

>> This is intended to prevent "excessive transformation" to enable migration 
>> of existing applications (using a non-Clang compiler) where users further 
>> manipulate the object or assembly after compilation.
>
> I don't get what you mean by this?  I don't currently see motivation for this?

The intent is to apply the `__attribute__((__used__))` semantic to static 
variables (since the front-end is likely to discard them). Additional reasons 
for using `__attribute__((__used__))` applies: The compiler cannot optimize 
with the assumption that it sees all direct accesses to the variable.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150221

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


[PATCH] D127910: [Clang][AArch64][SME] Add vector load/store (ld1/st1) intrinsics

2023-05-10 Thread Sander de Smalen via Phabricator via cfe-commits
sdesmalen added inline comments.



Comment at: clang/lib/Basic/Targets/AArch64.cpp:726
 
-if (Feature == "+sme") {
-  HasSME = true;

Why did you remove this?



Comment at: clang/test/CodeGen/aarch64-sme-intrinsics/acle_sme_ld1.c:16
+//
+__attribute__((arm_streaming)) void test_svld1_hor_za8(uint32_t slice_base, 
svbool_t pg, const void *ptr) {
+  svld1_hor_za8(0, slice_base, 0, pg, ptr);

Hi @bryanpkc, would you be happy to remove the dependence on the attributes 
patch for now, so that we can move forward to review/land this patch series?

I'm thinking of doing something like:

  // RUN: %clang_cc1 -DDISABLE_SME_ATTRIBUTES 
  ...
  
  #ifdef DISABLE_SME_ATTRIBUTES
  #define ARM_STREAMING_ATTR
  #else
  #define ARM_STREAMING_ATTR __attribute__((arm_streaming))
  #endif
  
  ...
  
  ARM_STREAMING_ATTR void test_svld1_hor_za16(uint32_t slice_base, svbool_t pg, 
const void *ptr) {
svld1_hor_za16(0, slice_base, 0, pg, ptr);
svld1_hor_za16(1, slice_base, 7, pg, ptr);
  }

With that the tests all pass, and when the attribute patches have landed we can 
just remove the `-DDISABLE_SME_ATTRIBUTES` from the RUN lines.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127910

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


[PATCH] D149997: [clang] [test] Narrow down MSVC specific behaviours from "any windows" to only MSVC/clang-cl

2023-05-10 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

Fails with cmake too: 
https://logs.chromium.org/logs/chromium/buildbucket/cr-buildbucket/8781510258907322449/+/u/package_clang/stdout?format=raw
 Reverted in 56bac6c87a2d9046dbac36aae4910b4b90edf643 
 for now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149997

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


[clang] 56bac6c - Revert "[clang] [test] Narrow down MSVC specific behaviours from "any windows" to only MSVC/clang-cl"

2023-05-10 Thread Nico Weber via cfe-commits

Author: Nico Weber
Date: 2023-05-10T16:49:18+02:00
New Revision: 56bac6c87a2d9046dbac36aae4910b4b90edf643

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

LOG: Revert "[clang] [test] Narrow down MSVC specific behaviours from "any 
windows" to only MSVC/clang-cl"

This reverts commit 7f037e5645bd62fca6fc7c3e77962aafe2bc8b27.
Breaks tests, see https://reviews.llvm.org/D149997#4331937

Added: 


Modified: 
clang/test/C/drs/dr1xx.c
clang/test/Driver/experimental-library-flag.cpp
clang/test/SemaCXX/attr-trivial-abi.cpp

Removed: 




diff  --git a/clang/test/C/drs/dr1xx.c b/clang/test/C/drs/dr1xx.c
index 6bbeb02408c7a..400807ed5da84 100644
--- a/clang/test/C/drs/dr1xx.c
+++ b/clang/test/C/drs/dr1xx.c
@@ -235,7 +235,7 @@ void dr118(void) {
 * type at this point.
 */
 Val = sizeof(enum E)
-#ifndef _MSC_VER
+#ifndef _WIN32
 /* expected-error@-2 {{invalid application of 'sizeof' to an incomplete 
type 'enum E'}} */
 /* expected-note@-12 {{definition of 'enum E' is not complete until the 
closing '}'}} */
 #endif

diff  --git a/clang/test/Driver/experimental-library-flag.cpp 
b/clang/test/Driver/experimental-library-flag.cpp
index db6a90b50f255..148cb7ed2adb0 100644
--- a/clang/test/Driver/experimental-library-flag.cpp
+++ b/clang/test/Driver/experimental-library-flag.cpp
@@ -1,6 +1,6 @@
 // On some platforms, -stdlib=libc++ is currently ignored, so 
-lc++experimental is not added.
 // Once -stdlib=libc++ works on those, this XFAIL can be removed.
-// XFAIL: target={{.*-windows-msvc.*}}, target={{.*-(ps4|ps5)}}
+// XFAIL: target={{.*-windows.*}}, target={{.*-(ps4|ps5)}}
 
 // For some reason, this fails with a core dump on AIX. This needs to be 
investigated.
 // UNSUPPORTED: target={{.*}}-aix{{.*}}

diff  --git a/clang/test/SemaCXX/attr-trivial-abi.cpp 
b/clang/test/SemaCXX/attr-trivial-abi.cpp
index 2cee3bd5dd215..deae99f7d0890 100644
--- a/clang/test/SemaCXX/attr-trivial-abi.cpp
+++ b/clang/test/SemaCXX/attr-trivial-abi.cpp
@@ -5,11 +5,11 @@ void __attribute__((trivial_abi)) foo(); // expected-warning 
{{'trivial_abi' att
 // Should not crash.
 template 
 class __attribute__((trivial_abi)) a { a(a &&); };
-#if defined(_WIN64) && defined(_MSC_VER)
-// On Windows/MSVC, to be trivial-for-calls, an object must be trivially 
copyable.
+#ifdef _WIN64
+// On Windows, to be trivial-for-calls, an object must be trivially copyable.
 // (And it is only trivially relocatable, currently, if it is trivial for 
calls.)
 // In this case, it is suppressed by an explicitly defined move constructor.
-// Similar concerns apply to later tests that have #if defined(_WIN64) && 
defined(_MSC_VER).
+// Similar concerns apply to later tests that have #ifdef _WIN64.
 static_assert(!__is_trivially_relocatable(a), "");
 #else
 static_assert(__is_trivially_relocatable(a), "");
@@ -137,7 +137,7 @@ struct __attribute__((trivial_abi)) CopyDeleted {
   CopyDeleted(const CopyDeleted &) = delete;
   CopyDeleted(CopyDeleted &&) = default;
 };
-#if defined(_WIN64) && defined(_MSC_VER)
+#ifdef _WIN64
 static_assert(!__is_trivially_relocatable(CopyDeleted), "");
 #else
 static_assert(__is_trivially_relocatable(CopyDeleted), "");
@@ -163,7 +163,7 @@ static_assert(!__is_trivially_relocatable(S19), "");
 struct __attribute__((trivial_abi)) S20 {
   int & // a member of rvalue reference type deletes the copy constructor.
 };
-#if defined(_WIN64) && defined(_MSC_VER)
+#ifdef _WIN64
 static_assert(!__is_trivially_relocatable(S20), "");
 #else
 static_assert(__is_trivially_relocatable(S20), "");



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


[clang] ddfb974 - Add support of the next Ubuntu (Ubuntu 23.10 - Mantic Minotaur)

2023-05-10 Thread Sylvestre Ledru via cfe-commits

Author: Sylvestre Ledru
Date: 2023-05-10T16:31:53+02:00
New Revision: ddfb974d0fca62e3eaeb98b79b5e29738c9082d2

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

LOG: Add support of the next Ubuntu (Ubuntu 23.10 - Mantic Minotaur)

Added: 


Modified: 
clang/include/clang/Driver/Distro.h
clang/lib/Driver/Distro.cpp

Removed: 




diff  --git a/clang/include/clang/Driver/Distro.h 
b/clang/include/clang/Driver/Distro.h
index 0c858b3d716f1..8291f6575a711 100644
--- a/clang/include/clang/Driver/Distro.h
+++ b/clang/include/clang/Driver/Distro.h
@@ -77,6 +77,7 @@ class Distro {
 UbuntuJammy,
 UbuntuKinetic,
 UbuntuLunar,
+UbuntuMantic,
 UnknownDistro
   };
 
@@ -128,7 +129,7 @@ class Distro {
   }
 
   bool IsUbuntu() const {
-return DistroVal >= UbuntuHardy && DistroVal <= UbuntuLunar;
+return DistroVal >= UbuntuHardy && DistroVal <= UbuntuMantic;
   }
 
   bool IsAlpineLinux() const { return DistroVal == AlpineLinux; }

diff  --git a/clang/lib/Driver/Distro.cpp b/clang/lib/Driver/Distro.cpp
index 85d82180a805c..e86b589a1cfb5 100644
--- a/clang/lib/Driver/Distro.cpp
+++ b/clang/lib/Driver/Distro.cpp
@@ -93,6 +93,7 @@ static Distro::DistroType 
DetectLsbRelease(llvm::vfs::FileSystem ) {
 .Case("jammy", Distro::UbuntuJammy)
 .Case("kinetic", Distro::UbuntuKinetic)
 .Case("lunar", Distro::UbuntuLunar)
+.Case("mantic", Distro::UbuntuMantic)
 .Default(Distro::UnknownDistro);
   return Version;
 }



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


[PATCH] D149562: [clang-format] Stop comment disrupting indentation of Verilog ports

2023-05-10 Thread sstwcw via Phabricator via cfe-commits
sstwcw added a comment.

> IMO a trailing comment (empty or not) belongs to the code before it.

There is only a parenthesis before it.  It doesn't usually need a comment.  It 
is like in 5a61139.  One doesn't tend to comment a single brace.

> A comment about the code below it should start on a new line.

In this special case, the comment would be indented to the same column as the 
next line, so it should be clear it is for the next line.  Like the case 
forbraced initializer lists, the first field will be on the same line as the 
brace if there isn't a comment, so the first comment is also on the same line 
as the brace when there is one.

  foo foo{// first field
  a,
  // second field
  b};


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149562

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


[PATCH] D149612: [Sema] avoid merge error type

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

@aaron.ballman : Can you comment, particularly on the 'x2' and 'x3' examples 
here?  I think our hackery here to get the AST back in a reasonable position 
here is unfortunate, and leads to some pretty awkward errors.  I'm not sure 
what else we could do?

We can't make it a dependent type, as it can then not be merged correctly.
We can't really make it a variable array type, since we would then have those 
types in places where it isn't 'legal'.
We would have a perhaps similar problem with the incomplete array type as the 
VLA, but at least we would diagnose `char[]`, right?

My original thoughts were to make this still be a constant-array-type, keeping 
the 'error' size expression, but with a '1' for the extent, but I'm second 
guessing here based on those errors.




Comment at: clang/test/Sema/merge-decls.c:101
+char x3[sizeof(d.data) == 8]; // expected-error {{member reference base type 
'char' is not a structure or union}}
+char x3[1];

Newline at end of file still needed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149612

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


[PATCH] D150221: Add option -fkeep-static-variables to emit all static variables

2023-05-10 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a subscriber: aaron.ballman.
erichkeane added a comment.

In D150221#4330534 , 
@hubert.reinterpretcast wrote:

> In D150221#4330504 , @MaskRay wrote:
>
>> Can you give a more compelling reason that this option is needed?
>
> This is intended to prevent "excessive transformation" to enable migration of 
> existing applications (using a non-Clang compiler) where users further 
> manipulate the object or assembly after compilation.

I don't get what you mean by this?  I don't currently see motivation for this?  
@aaron.ballman would have to make a decision here eventually, but I don't think 
he'd be compelled by this either.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150221

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


  1   2   >