[PATCH] D150635: [clangd] Implement end-definition-comment inlay hints

2023-05-16 Thread Qingyuan Zheng via Phabricator via cfe-commits
daiyousei-qz added a comment.

For a quick peek to the hint:

F27483170: image.png 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150635

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


[PATCH] D150635: [clangd] Implement end-definition-comment inlay hints

2023-05-16 Thread Qingyuan Zheng via Phabricator via cfe-commits
daiyousei-qz added a comment.

@zyounan np! Feel free to leave your review comments!

@sammccall Thank you for you insightful and detailed review! I addressed many 
review comments in the updated patch and left things I'm not very sure.

Regarding to **Naming**, I agree that `EndDefinitionComment` sounds so tedious 
but I couldn't come up with a better name. However, I think `EndBlock` also 
feel a little strange to me as a public name. If I come across a setting key in 
`InlayHints` section named `EndBlock`, honestly I would be confused by what it 
would do ("end" could be a verb, and "block" usually make me to think of the 
local scope block). What about `AfterBlock` or `AfterDefinition`?

Regarding to **Configuration**, I suppose the line of definition is a very 
natural parameter for this feature. I doubt we could come up with some good 
heuristic to conditional show this hint. Considering how straightforward this 
parameter its implementation is, I'd prefer to having this around if possible. 
But I'll let you to decide.




Comment at: clang-tools-extra/clangd/InlayHints.cpp:763
+if (!LSPRange ||
+static_cast(LSPRange->end.line - LSPRange->start.line) + 1 <
+Cfg.InlayHints.EndDefinitionCommentMinLines)

sammccall wrote:
> I'm not sure we're using the right range here. Consider:
> 
> ```
> const some::long* function
>many params, therefore spanning, lines) {}
> ```
> 
> I don't think hinting `}` here is useful: the relevant distance is from `{` 
> rather than the start of the declaration.
I agree. What do you think is a good way get the range of the definition block? 
What I can think of is to walking backwards the expanded token buffer from the 
ending '}' and searching for the balanced '}'.



Comment at: clang-tools-extra/clangd/InlayHints.cpp:771
+if (const auto *FD = dyn_cast_or_null()) {
+  Label = printName(AST, D);
+} else {

sammccall wrote:
> why is printName OK here and not below?
I'm using printName here to print names for operator overload. Do you have any 
advice?



Comment at: clang-tools-extra/clangd/InlayHints.cpp:777-781
+  else if (isa(D)) {
+Label += "enum ";
+if (cast(D).isScopedUsingClassTag()) {
+  Label += "class ";
+}

sammccall wrote:
> zyounan wrote:
> > Perhaps duplicate the logic from [[ 
> > https://clang.llvm.org/doxygen/DeclPrinter_8cpp_source.html#l00529 | 
> > DeclPrinter::VisitEnumDecl ]]? For `enum struct`, printing `enum` only 
> > might confuse users.
> > 
> I'm torn here: "enum class Foo" is wordy so "enum Foo" is tempting to me. 
> Don't have a strong opinion.
> 
> regardless, printing the tag for class but not struct is definitely wrong :-)
Fixed `enum struct`. Honestly, just learnt there's such a thing, lol.



Comment at: clang-tools-extra/clangd/unittests/InlayHintTests.cpp:1566
+
+TEST(EndDefinitionHints, Functions) {
+  assertEndDefinitionHints(R"cpp(

sammccall wrote:
> can you add testcases where:
>  - the function name is an operator
>  - the function is templated
Added template function. I don't quite understand what you mean by "the 
function name is an operator". I'm assuming you meant operator overload so 
closing this one as covered below.



Comment at: clang-tools-extra/clangd/unittests/InlayHintTests.cpp:1576
+  )cpp",
+   0, ExpectedHint{" /* foo */ ", "foo"},
+   ExpectedHint{" /* bar */ ", "bar"});

sammccall wrote:
> we're not adding the kind here as in "function foo".
> 
> Maybe that's OK, "function" is long, doesn't appear in the C++ syntax, and is 
> mostly obvious.
> But in that case I'd like to have some hint, maybe `/* foo() */`? (Not the 
> actual param list of course, the parens would always be empty)
> 
> If you don't think we need any hint, then I'd question whether we need 
> "class" etc for class hints!
I think just `// foo` is good enough. Having no "qualifier" could be a 
privilege for functions since they are usually the majority of the source code. 
When reading through the source code, people will get that if no prefix is 
attached, then it's a function. (OFC they'll also see `// namespace` and .etc, 
but rare)

Honestly, IMO `// foo()` is worse than just the name. It could mislead me to 
think that this may be a complete signature while it is definitely not.



Comment at: clang-tools-extra/clangd/unittests/InlayHintTests.cpp:1580
+
+TEST(EndDefinitionHints, Methods) {
+  assertEndDefinitionHints(R"cpp(

sammccall wrote:
> can you add a test with a lambda?
> I think the hint should probably just be `lambda` or `(lambda)`, this 
> probably needs special handling.
> 
> It definitely shouldn't be `operator()` or `(lambda at somefile.cc:47)`.
I would argue we don't need hint for a lambda. This hint is only added to 

[PATCH] D150752: [bolt] Use correct output paths and passthrough necessary options

2023-05-16 Thread Petr Hosek via Phabricator via cfe-commits
phosek created this revision.
phosek added a reviewer: Amir.
Herald added subscribers: treapster, ayermolo, abrachet.
Herald added a reviewer: rafauler.
Herald added a reviewer: maksfb.
Herald added a project: All.
phosek requested review of this revision.
Herald added subscribers: cfe-commits, yota9.
Herald added a project: clang.

This addresses https://github.com/llvm/llvm-project/issues/62748.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D150752

Files:
  bolt/CMakeLists.txt
  bolt/runtime/CMakeLists.txt
  clang/cmake/caches/Fuchsia-stage2.cmake


Index: clang/cmake/caches/Fuchsia-stage2.cmake
===
--- clang/cmake/caches/Fuchsia-stage2.cmake
+++ clang/cmake/caches/Fuchsia-stage2.cmake
@@ -294,7 +294,6 @@
 set(LLVM_TOOLCHAIN_TOOLS
   dsymutil
   llvm-ar
-  llvm-bolt
   llvm-cov
   llvm-cxxfilt
   llvm-debuginfod-find
@@ -329,6 +328,7 @@
   CACHE STRING "")
 
 set(LLVM_Toolchain_DISTRIBUTION_COMPONENTS
+  bolt
   clang
   lld
   clang-apply-replacements
Index: bolt/runtime/CMakeLists.txt
===
--- bolt/runtime/CMakeLists.txt
+++ bolt/runtime/CMakeLists.txt
@@ -15,12 +15,12 @@
   instr.cpp
   ${CMAKE_CURRENT_BINARY_DIR}/config.h
   )
-set_target_properties(bolt_rt_instr PROPERTIES LIBRARY_OUTPUT_DIRECTORY 
"lib${LLVM_LIBDIR_SUFFIX}")
+set_target_properties(bolt_rt_instr PROPERTIES ARCHIVE_OUTPUT_DIRECTORY 
"${LLVM_LIBRARY_DIR}")
 add_library(bolt_rt_hugify STATIC
   hugify.cpp
   ${CMAKE_CURRENT_BINARY_DIR}/config.h
   )
-set_target_properties(bolt_rt_hugify PROPERTIES LIBRARY_OUTPUT_DIRECTORY 
"lib${LLVM_LIBDIR_SUFFIX}")
+set_target_properties(bolt_rt_hugify PROPERTIES ARCHIVE_OUTPUT_DIRECTORY 
"${LLVM_LIBRARY_DIR}")
 
 set(BOLT_RT_FLAGS
   -ffreestanding
@@ -44,7 +44,7 @@
 instr.cpp
 ${CMAKE_CURRENT_BINARY_DIR}/config.h
   )
-  set_target_properties(bolt_rt_instr_osx PROPERTIES LIBRARY_OUTPUT_DIRECTORY 
"lib${LLVM_LIBDIR_SUFFIX}")
+  set_target_properties(bolt_rt_instr_osx PROPERTIES ARCHIVE_OUTPUT_DIRECTORY 
"${LLVM_LIBRARY_DIR}")
   target_include_directories(bolt_rt_instr_osx PRIVATE 
${CMAKE_CURRENT_BINARY_DIR})
   target_compile_options(bolt_rt_instr_osx PRIVATE
 -target x86_64-apple-darwin19.6.0
Index: bolt/CMakeLists.txt
===
--- bolt/CMakeLists.txt
+++ bolt/CMakeLists.txt
@@ -84,6 +84,9 @@
 
 if (BOLT_ENABLE_RUNTIME)
   message(STATUS "Building BOLT runtime libraries for X86")
+  if(CMAKE_SYSROOT)
+list(APPEND extra_args -DCMAKE_SYSROOT=${CMAKE_SYSROOT})
+  endif()
   ExternalProject_Add(bolt_rt
 SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/runtime"
 STAMP_DIR ${CMAKE_CURRENT_BINARY_DIR}/bolt_rt-stamps
@@ -92,8 +95,12 @@
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
-DCMAKE_BUILD_TYPE=Release
-DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM}
-   -DCMAKE_INSTALL_PREFIX=${LLVM_BINARY_DIR}
+   -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
-DLLVM_LIBDIR_SUFFIX=${LLVM_LIBDIR_SUFFIX}
+   -DLLVM_LIBRARY_DIR=${LLVM_LIBRARY_DIR}
+   ${extra_args}
+INSTALL_COMMAND ""
+STEP_TARGETS configure build
 BUILD_ALWAYS True
 )
   install(CODE "execute_process\(COMMAND \${CMAKE_COMMAND} 
-DCMAKE_INSTALL_PREFIX=\${CMAKE_INSTALL_PREFIX} -P 
${CMAKE_CURRENT_BINARY_DIR}/bolt_rt-bins/cmake_install.cmake \)"


Index: clang/cmake/caches/Fuchsia-stage2.cmake
===
--- clang/cmake/caches/Fuchsia-stage2.cmake
+++ clang/cmake/caches/Fuchsia-stage2.cmake
@@ -294,7 +294,6 @@
 set(LLVM_TOOLCHAIN_TOOLS
   dsymutil
   llvm-ar
-  llvm-bolt
   llvm-cov
   llvm-cxxfilt
   llvm-debuginfod-find
@@ -329,6 +328,7 @@
   CACHE STRING "")
 
 set(LLVM_Toolchain_DISTRIBUTION_COMPONENTS
+  bolt
   clang
   lld
   clang-apply-replacements
Index: bolt/runtime/CMakeLists.txt
===
--- bolt/runtime/CMakeLists.txt
+++ bolt/runtime/CMakeLists.txt
@@ -15,12 +15,12 @@
   instr.cpp
   ${CMAKE_CURRENT_BINARY_DIR}/config.h
   )
-set_target_properties(bolt_rt_instr PROPERTIES LIBRARY_OUTPUT_DIRECTORY "lib${LLVM_LIBDIR_SUFFIX}")
+set_target_properties(bolt_rt_instr PROPERTIES ARCHIVE_OUTPUT_DIRECTORY "${LLVM_LIBRARY_DIR}")
 add_library(bolt_rt_hugify STATIC
   hugify.cpp
   ${CMAKE_CURRENT_BINARY_DIR}/config.h
   )
-set_target_properties(bolt_rt_hugify PROPERTIES LIBRARY_OUTPUT_DIRECTORY "lib${LLVM_LIBDIR_SUFFIX}")
+set_target_properties(bolt_rt_hugify PROPERTIES ARCHIVE_OUTPUT_DIRECTORY "${LLVM_LIBRARY_DIR}")
 
 set(BOLT_RT_FLAGS
   -ffreestanding
@@ -44,7 +44,7 @@
 instr.cpp
 ${CMAKE_CURRENT_BINARY_DIR}/config.h
   )
-  set_target_properties(bolt_rt_instr_osx PROPERTIES LIBRARY_OUTPUT_DIRECTORY "lib${LLVM_LIBDIR_SUFFIX}")
+  set_target_properties(bolt_rt_instr_osx PROPERTIES 

[PATCH] D150635: [clangd] Implement end-definition-comment inlay hints

2023-05-16 Thread Qingyuan Zheng via Phabricator via cfe-commits
daiyousei-qz updated this revision to Diff 522898.
daiyousei-qz marked 16 inline comments as done.
daiyousei-qz added a comment.

- addressed many review comment


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150635

Files:
  clang-tools-extra/clangd/Config.h
  clang-tools-extra/clangd/ConfigCompile.cpp
  clang-tools-extra/clangd/ConfigFragment.h
  clang-tools-extra/clangd/ConfigYAML.cpp
  clang-tools-extra/clangd/InlayHints.cpp
  clang-tools-extra/clangd/Protocol.cpp
  clang-tools-extra/clangd/Protocol.h
  clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp
  clang-tools-extra/clangd/unittests/InlayHintTests.cpp

Index: clang-tools-extra/clangd/unittests/InlayHintTests.cpp
===
--- clang-tools-extra/clangd/unittests/InlayHintTests.cpp
+++ clang-tools-extra/clangd/unittests/InlayHintTests.cpp
@@ -77,6 +77,7 @@
   C.InlayHints.Parameters = false;
   C.InlayHints.DeducedTypes = false;
   C.InlayHints.Designators = false;
+  C.InlayHints.EndDefinitionComments = false;
   return C;
 }
 
@@ -122,6 +123,17 @@
   assertHints(InlayHintKind::Designator, AnnotatedSource, Expected...);
 }
 
+template 
+void assertEndDefinitionHints(llvm::StringRef AnnotatedSource,
+  uint32_t MinLines, ExpectedHints... Expected) {
+  Config Cfg;
+  Cfg.InlayHints.EndDefinitionComments = true;
+  Cfg.InlayHints.EndDefinitionCommentMinLines = MinLines;
+  WithContextValue WithCfg(Config::Key, std::move(Cfg));
+  assertHints(InlayHintKind::EndDefinitionComment, AnnotatedSource,
+  Expected...);
+}
+
 TEST(ParameterHints, Smoke) {
   assertParameterHints(R"cpp(
 void foo(int param);
@@ -1550,6 +1562,196 @@
   ExpectedHint{"a: ", "param1"}, ExpectedHint{"b: ", "param2"},
   ExpectedHint{"c: ", "param3"});
 }
+
+TEST(EndDefinitionHints, Functions) {
+  assertEndDefinitionHints(R"cpp(
+$foo[[int foo() {
+  return 41;
+}]]
+
+template 
+$bar[[int bar() { return X; }]]
+
+// No hint because this isn't a definition
+int buz();
+  )cpp",
+   0, ExpectedHint{" // foo", "foo"},
+   ExpectedHint{" // bar", "bar"});
+}
+
+TEST(EndDefinitionHints, Methods) {
+  assertEndDefinitionHints(R"cpp(
+class Test {
+public:
+  // No hint because there's no function body
+  Test() = default;
+  
+  $dtor[[~Test() {}]]
+
+  $method1[[void method1() {}]]
+
+  // No hint because this isn't a definition
+  void method2();
+
+  template 
+  $method3[[void method3() {}]]
+
+  // No hint because this isn't a definition
+  template 
+  void method4();
+} x;
+
+$method2[[void Test::method2() {}]]
+
+template 
+$method4[[void Test::method4() {}]]
+  )cpp",
+   0, ExpectedHint{" // ~Test", "dtor"},
+   ExpectedHint{" // method1", "method1"},
+   ExpectedHint{" // method3", "method3"},
+   ExpectedHint{" // Test::method2", "method2"},
+   ExpectedHint{" // Test::method4", "method4"});
+}
+
+TEST(EndDefinitionHints, OverloadedOperators) {
+  assertEndDefinitionHints(R"cpp(
+struct S {
+  $opId[[S operator+(int) const {
+return *this;
+  }]]
+
+  $opBool[[operator bool() const {
+return true;
+  }]]
+
+  // No hint because there's no function body
+  operator int() const = delete;
+
+  // No hint because this isn't a definition
+  operator float() const;
+} x;
+
+$opEq[[bool operator==(const S&, const S&) {
+  return true;
+}]]
+  )cpp",
+   0, ExpectedHint{" // operator+", "opId"},
+   ExpectedHint{" // operator bool", "opBool"},
+   ExpectedHint{" // operator==", "opEq"});
+}
+
+TEST(EndDefinitionHints, Namespaces) {
+  assertEndDefinitionHints(
+  R"cpp(
+$anon[[namespace {
+  void foo();
+}]]
+
+$ns[[namespace ns {
+  void bar();
+}]]
+  )cpp",
+  0, ExpectedHint{" // namespace", "anon"},
+  ExpectedHint{" // namespace ns", "ns"});
+}
+
+TEST(EndDefinitionHints, Types) {
+  assertEndDefinitionHints(
+  R"cpp(
+$S[[struct S {
+};]]
+
+$C[[class C {
+};]]
+
+$U[[union U {
+};]]
+
+$E1[[enum E1 {
+};]]
+
+$E2[[enum class E2 {
+};]]
+  )cpp",
+  0, ExpectedHint{" // struct S", "S"}, ExpectedHint{" // class C", "C"},
+  ExpectedHint{" // union U", "U"}, ExpectedHint{" // enum E1", "E1"},
+  ExpectedHint{" // enum class E2", "E2"});
+}
+
+TEST(EndDefinitionHints, BundledTypeVariableDecl) {
+  assertEndDefinitionHints(
+  R"cpp(
+// No hint because we have a declarator right after '}'
+struct {
+  int x;
+} s;
+
+// Rare case, but yes we'll have a hint here.
+ 

[PATCH] D150740: [clang] Add `__attribute__((nooutline))`

2023-05-16 Thread Jessica Paquette via Phabricator via cfe-commits
paquette updated this revision to Diff 522894.
paquette added a comment.

Also support blocks


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

https://reviews.llvm.org/D150740

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/test/CodeGen/attr-nooutline-blocks.m
  clang/test/CodeGen/attr-nooutline.c

Index: clang/test/CodeGen/attr-nooutline.c
===
--- /dev/null
+++ clang/test/CodeGen/attr-nooutline.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 %s -S -emit-llvm -o - | FileCheck %s
+
+// CHECK: define i32 @has_attr_2() [[HAS_ATTR_2:#[0-9]+]]
+// CHECK: declare i32 @has_attr_1() [[HAS_ATTR_1:#[0-9]+]]
+
+__attribute__((nooutline)) int has_attr_1(void);
+__attribute__((nooutline)) int has_attr_2(void) { return has_attr_1(); }
+
+// CHECK: attributes [[HAS_ATTR_2]] = { {{.*}}"nooutline"{{.*}} }
+// CHECK: attributes [[HAS_ATTR_1]] = { {{.*}}"nooutline"{{.*}} }
Index: clang/test/CodeGen/attr-nooutline-blocks.m
===
--- /dev/null
+++ clang/test/CodeGen/attr-nooutline-blocks.m
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 %s -S -emit-llvm -fblocks /tmp/test.m -o - | FileCheck %s
+
+// CHECK: define internal void @__block_param_block_invoke({{.*}}) [[HAS_ATTR:#[0-9]+]]
+@interface ObjTy @end
+ObjTy *global;
+void escp(void (^)(ObjTy *));
+void block_param() {
+  escp(^(ObjTy *p) __attribute__((nooutline)) {});
+}
+
+// CHECK: attributes [[HAS_ATTR]] = { {{.*}}"nooutline"{{.*}} }
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -2133,6 +2133,8 @@
 if (D->hasAttr())
   B.addAttribute(llvm::Attribute::MinSize);
   }
+  if (D->hasAttr())
+B.addAttribute("nooutline");
 
   F->addFnAttrs(B);
 
Index: clang/lib/CodeGen/CGCall.cpp
===
--- clang/lib/CodeGen/CGCall.cpp
+++ clang/lib/CodeGen/CGCall.cpp
@@ -2344,6 +2344,8 @@
   FuncAttrs.addAttribute(llvm::Attribute::NoCfCheck);
 if (TargetDecl->hasAttr())
   FuncAttrs.addAttribute(llvm::Attribute::NoCallback);
+if (TargetDecl->hasAttr())
+  FuncAttrs.addAttribute("nooutline");
 
 HasOptnone = TargetDecl->hasAttr();
 if (auto *AllocSize = TargetDecl->getAttr()) {
Index: clang/include/clang/Basic/AttrDocs.td
===
--- clang/include/clang/Basic/AttrDocs.td
+++ clang/include/clang/Basic/AttrDocs.td
@@ -580,6 +580,26 @@
   }];
 }
 
+def NoOutlineDocs : Documentation {
+  let Category = DocCatFunction;
+  let Content = [{
+
+Suppresses outlining from a function. Functions with this attribute will not
+be considered for outlining.
+
+.. code-block:: c
+
+  __attribute__((nooutline))
+  int example(void) {
+int r;
+foo();
+bar();
+return r;
+  }
+
+  }];
+}
+
 def MustTailDocs : Documentation {
   let Category = DocCatStmt;
   let Content = [{
Index: clang/include/clang/Basic/Attr.td
===
--- clang/include/clang/Basic/Attr.td
+++ clang/include/clang/Basic/Attr.td
@@ -1469,6 +1469,13 @@
   let SimpleHandler = 1;
 }
 
+def NoOutline : InheritableAttr {
+  let Spellings = [Clang<"nooutline">];
+  let Subjects = SubjectList<[Function, ObjCMethod, Block]>;
+  let Documentation = [NoOutlineDocs];
+  let SimpleHandler = 1;
+}
+
 def MustTail : StmtAttr {
   let Spellings = [Clang<"musttail">];
   let Documentation = [MustTailDocs];
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D150740: [clang] Add `__attribute__((nooutline))`

2023-05-16 Thread Jessica Paquette via Phabricator via cfe-commits
paquette added inline comments.



Comment at: clang/include/clang/Basic/Attr.td:1474
+  let Spellings = [Clang<"nooutline">];
+  let Subjects = SubjectList<[Function, ObjCMethod]>;
+  let Documentation = [NoOutlineDocs];

jroelofs wrote:
> does it make sense on `Block` too?
Oh good idea


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

https://reviews.llvm.org/D150740

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


[PATCH] D150723: clang/openmp: Fix alignment for ThreadID Address variables

2023-05-16 Thread Jonathan Peyton via Phabricator via cfe-commits
jlpeyton accepted this revision.
jlpeyton 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/D150723/new/

https://reviews.llvm.org/D150723

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


[PATCH] D150632: [IR] Adds Instruction::setNoSanitizeMetadata()

2023-05-16 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay accepted this revision.
MaskRay added a comment.
This revision is now accepted and ready to land.

LGTM.




Comment at: llvm/include/llvm/IR/Instruction.h:353
 
+  /// Sets the nosanitize metadata on this instruction.
+  void setNoSanitizeMetadata();

`Set`.

Imperative sentences are more common in comments. Ignore `Sets` above that's 
inconsistent with other places in this file.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150632

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


[PATCH] D150646: [clang][X86] Add __cpuidex function to cpuid.h

2023-05-16 Thread Craig Topper via Phabricator via cfe-commits
craig.topper accepted this revision.
craig.topper added a comment.
This revision is now accepted and ready to land.

LGTM

I find it a little odd that we have if you include cpuid.h you get the gcc 
interface for __cpuid and the MSVC interface for __cpuidex. But gcc did it 
first so I guess we should match.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150646

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


[PATCH] D150646: [clang][X86] Add __cpuidex function to cpuid.h

2023-05-16 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

For MSVC compatibility this was already implemented as a builtin for intrin.h 
in https://reviews.llvm.org/D121653


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150646

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


[PATCH] D150632: [IR] Adds Instruction::setNoSanitizeMetadata()

2023-05-16 Thread Mingjie Xu via Phabricator via cfe-commits
Enna1 updated this revision to Diff 522884.
Enna1 added a comment.

address review comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150632

Files:
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/CodeGen/ItaniumCXXABI.cpp
  clang/lib/CodeGen/SanitizerMetadata.cpp
  clang/lib/CodeGen/SanitizerMetadata.h
  llvm/include/llvm/IR/Instruction.h
  llvm/lib/IR/Metadata.cpp
  llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp

Index: llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
===
--- llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
+++ llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
@@ -248,10 +248,6 @@
   std::pair CreateSecStartEnd(Module , const char *Section,
 Type *Ty);
 
-  void SetNoSanitizeMetadata(Instruction *I) {
-I->setMetadata(LLVMContext::MD_nosanitize, MDNode::get(*C, std::nullopt));
-  }
-
   std::string getSectionName(const std::string ) const;
   std::string getSectionStart(const std::string ) const;
   std::string getSectionEnd(const std::string ) const;
@@ -992,8 +988,8 @@
 auto Load = IRB.CreateLoad(Int8Ty, CounterPtr);
 auto Inc = IRB.CreateAdd(Load, ConstantInt::get(Int8Ty, 1));
 auto Store = IRB.CreateStore(Inc, CounterPtr);
-SetNoSanitizeMetadata(Load);
-SetNoSanitizeMetadata(Store);
+Load->setNoSanitizeMetadata();
+Store->setNoSanitizeMetadata();
   }
   if (Options.InlineBoolFlag) {
 auto FlagPtr = IRB.CreateGEP(
@@ -1004,8 +1000,8 @@
 SplitBlockAndInsertIfThen(IRB.CreateIsNull(Load), &*IP, false);
 IRBuilder<> ThenIRB(ThenTerm);
 auto Store = ThenIRB.CreateStore(ConstantInt::getTrue(Int1Ty), FlagPtr);
-SetNoSanitizeMetadata(Load);
-SetNoSanitizeMetadata(Store);
+Load->setNoSanitizeMetadata();
+Store->setNoSanitizeMetadata();
   }
   if (Options.StackDepth && IsEntryBB && !IsLeafFunc) {
 // Check stack depth.  If it's the deepest so far, record it.
@@ -1021,8 +1017,8 @@
 auto ThenTerm = SplitBlockAndInsertIfThen(IsStackLower, &*IP, false);
 IRBuilder<> ThenIRB(ThenTerm);
 auto Store = ThenIRB.CreateStore(FrameAddrInt, SanCovLowestStack);
-SetNoSanitizeMetadata(LowestStack);
-SetNoSanitizeMetadata(Store);
+LowestStack->setNoSanitizeMetadata();
+Store->setNoSanitizeMetadata();
   }
 }
 
Index: llvm/lib/IR/Metadata.cpp
===
--- llvm/lib/IR/Metadata.cpp
+++ llvm/lib/IR/Metadata.cpp
@@ -1610,6 +1610,11 @@
   setMetadata(LLVMContext::MD_noalias, N.NoAlias);
 }
 
+void Instruction::setNoSanitizeMetadata() {
+  setMetadata(llvm::LLVMContext::MD_nosanitize,
+  llvm::MDNode::get(getContext(), std::nullopt));
+}
+
 MDNode *Instruction::getMetadataImpl(unsigned KindID) const {
   // Handle 'dbg' as a special case since it is not stored in the hash table.
   if (KindID == LLVMContext::MD_dbg)
Index: llvm/include/llvm/IR/Instruction.h
===
--- llvm/include/llvm/IR/Instruction.h
+++ llvm/include/llvm/IR/Instruction.h
@@ -350,6 +350,9 @@
   /// Sets the AA metadata on this instruction from the AAMDNodes structure.
   void setAAMetadata(const AAMDNodes );
 
+  /// Sets the nosanitize metadata on this instruction.
+  void setNoSanitizeMetadata();
+
   /// Retrieve total raw weight values of a branch.
   /// Returns true on success with profile total weights filled in.
   /// Returns false if no metadata was found.
Index: clang/lib/CodeGen/SanitizerMetadata.h
===
--- clang/lib/CodeGen/SanitizerMetadata.h
+++ clang/lib/CodeGen/SanitizerMetadata.h
@@ -44,7 +44,6 @@
 SanitizerMask NoSanitizeAttrMask = {},
 bool IsDynInit = false);
   void disableSanitizerForGlobal(llvm::GlobalVariable *GV);
-  void disableSanitizerForInstruction(llvm::Instruction *I);
 };
 } // end namespace CodeGen
 } // end namespace clang
Index: clang/lib/CodeGen/SanitizerMetadata.cpp
===
--- clang/lib/CodeGen/SanitizerMetadata.cpp
+++ clang/lib/CodeGen/SanitizerMetadata.cpp
@@ -101,8 +101,3 @@
 void SanitizerMetadata::disableSanitizerForGlobal(llvm::GlobalVariable *GV) {
   reportGlobal(GV, SourceLocation(), "", QualType(), SanitizerKind::All);
 }
-
-void SanitizerMetadata::disableSanitizerForInstruction(llvm::Instruction *I) {
-  I->setMetadata(llvm::LLVMContext::MD_nosanitize,
- llvm::MDNode::get(CGM.getLLVMContext(), std::nullopt));
-}
Index: clang/lib/CodeGen/ItaniumCXXABI.cpp
===
--- clang/lib/CodeGen/ItaniumCXXABI.cpp
+++ clang/lib/CodeGen/ItaniumCXXABI.cpp
@@ -2189,7 +2189,7 @@
   

[PATCH] D150744: [NFC][CLANG] Fix uninitialized scalar field issues with Coverity

2023-05-16 Thread Soumi Manna via Phabricator via cfe-commits
Manna updated this revision to Diff 522877.
Herald added subscribers: steakhal, martong.

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

https://reviews.llvm.org/D150744

Files:
  clang/include/clang/Analysis/Analyses/Consumed.h
  clang/include/clang/Parse/Parser.h
  clang/lib/AST/ExprConstant.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.h
  clang/lib/CodeGen/ConstantEmitter.h
  clang/lib/Serialization/ASTReaderDecl.cpp
  clang/lib/StaticAnalyzer/Checkers/MoveChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/STLAlgorithmModeling.cpp

Index: clang/lib/StaticAnalyzer/Checkers/STLAlgorithmModeling.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/STLAlgorithmModeling.cpp
+++ clang/lib/StaticAnalyzer/Checkers/STLAlgorithmModeling.cpp
@@ -61,7 +61,7 @@
 public:
   STLAlgorithmModeling() = default;
 
-  bool AggressiveStdFindModeling;
+  bool AggressiveStdFindModeling = FALSE;
 
   bool evalCall(const CallEvent , CheckerContext ) const;
 }; //
Index: clang/lib/StaticAnalyzer/Checkers/MoveChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/MoveChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/MoveChecker.cpp
@@ -184,7 +184,7 @@
 bool Found;
   };
 
-  AggressivenessKind Aggressiveness;
+  AggressivenessKind Aggressiveness = AK_Invalid;
 
 public:
   void setAggressiveness(StringRef Str, CheckerManager ) {
Index: clang/lib/Serialization/ASTReaderDecl.cpp
===
--- clang/lib/Serialization/ASTReaderDecl.cpp
+++ clang/lib/Serialization/ASTReaderDecl.cpp
@@ -89,7 +89,7 @@
 using RecordData = ASTReader::RecordData;
 
 TypeID DeferredTypeID = 0;
-unsigned AnonymousDeclNumber;
+unsigned AnonymousDeclNumber = 0;
 GlobalDeclID NamedDeclForTagDecl = 0;
 IdentifierInfo *TypedefNameForLinkage = nullptr;
 
Index: clang/lib/CodeGen/ConstantEmitter.h
===
--- clang/lib/CodeGen/ConstantEmitter.h
+++ clang/lib/CodeGen/ConstantEmitter.h
@@ -42,7 +42,7 @@
 
   /// The AST address space where this (non-abstract) initializer is going.
   /// Used for generating appropriate placeholders.
-  LangAS DestAddressSpace;
+  LangAS DestAddressSpace = LangAS::Default;
 
   llvm::SmallVector, 4>
 PlaceholderAddresses;
Index: clang/lib/CodeGen/CGOpenMPRuntime.h
===
--- clang/lib/CodeGen/CGOpenMPRuntime.h
+++ clang/lib/CodeGen/CGOpenMPRuntime.h
@@ -232,7 +232,7 @@
   /// as those marked as `omp declare target`.
   class DisableAutoDeclareTargetRAII {
 CodeGenModule 
-bool SavedShouldMarkAsGlobal;
+bool SavedShouldMarkAsGlobal = FALSE;
 
   public:
 DisableAutoDeclareTargetRAII(CodeGenModule );
Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -1294,7 +1294,7 @@
   class SpeculativeEvaluationRAII {
 EvalInfo *Info = nullptr;
 Expr::EvalStatus OldStatus;
-unsigned OldSpeculativeEvaluationDepth;
+unsigned OldSpeculativeEvaluationDepth = 0;
 
 void moveFromAndCancel(SpeculativeEvaluationRAII &) {
   Info = Other.Info;
Index: clang/include/clang/Parse/Parser.h
===
--- clang/include/clang/Parse/Parser.h
+++ clang/include/clang/Parse/Parser.h
@@ -1188,7 +1188,7 @@
   /// RAII object used to modify the scope flags for the current scope.
   class ParseScopeFlags {
 Scope *CurScope;
-unsigned OldFlags;
+unsigned OldFlags = 0;
 ParseScopeFlags(const ParseScopeFlags &) = delete;
 void operator=(const ParseScopeFlags &) = delete;
 
Index: clang/include/clang/Analysis/Analyses/Consumed.h
===
--- clang/include/clang/Analysis/Analyses/Consumed.h
+++ clang/include/clang/Analysis/Analyses/Consumed.h
@@ -240,7 +240,7 @@
 ConsumedBlockInfo BlockInfo;
 std::unique_ptr CurrStates;
 
-ConsumedState ExpectedReturnState;
+ConsumedState ExpectedReturnState = CS_None;
 
 void determineExpectedReturnState(AnalysisDeclContext ,
   const FunctionDecl *D);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D150746: [CodeGen]Translating pointer arguments can require an address space cast

2023-05-16 Thread Alex Voicu via Phabricator via cfe-commits
AlexVlx created this revision.
AlexVlx added reviewers: aaron.ballman, yaxunl.
Herald added subscribers: arichardson, tpr.
Herald added a project: All.
AlexVlx requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

When lowering from a HLL that does not use explicit generic address spaces 
(e.g. HIP) to target specific IR for a target that uses explicit address spaces 
(e.g. AMDGPU), it is possible for an explicitly placed pointer to be passed as 
an argument to a function taking a generic pointer. An example of this 
situation is when GEPs are formed into VTTs. This flares in Debug builds (since 
a bitcast would be invalid) and, possibly, at runtime on targets where the 
bitwise representation of pointers in different address spaces is not identical.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D150746

Files:
  clang/lib/CodeGen/CGCall.cpp


Index: clang/lib/CodeGen/CGCall.cpp
===
--- clang/lib/CodeGen/CGCall.cpp
+++ clang/lib/CodeGen/CGCall.cpp
@@ -5183,11 +5183,17 @@
 V->getType()->isIntegerTy())
   V = Builder.CreateZExt(V, ArgInfo.getCoerceToType());
 
-// If the argument doesn't match, perform a bitcast to coerce it.  This
-// can happen due to trivial type mismatches.
+// If the argument doesn't match, perform a either a bitcast or an
+// address space cast to coerce it. This can happen either due to
+// trivial type mismatches or valid address space mismatches
+// (e.g. global -> generic; GEPs into VTTs are an example).
 if (FirstIRArg < IRFuncTy->getNumParams() &&
 V->getType() != IRFuncTy->getParamType(FirstIRArg))
-  V = Builder.CreateBitCast(V, IRFuncTy->getParamType(FirstIRArg));
+  if (V->getType()->isPointerTy())
+V = Builder.CreateAddrSpaceCast(V,
+
IRFuncTy->getParamType(FirstIrArg));
+  else
+V = Builder.CreateBitCast(V, IRFuncTy->getParamType(FirstIRArg));
 
 if (ArgHasMaybeUndefAttr)
   V = Builder.CreateFreeze(V);


Index: clang/lib/CodeGen/CGCall.cpp
===
--- clang/lib/CodeGen/CGCall.cpp
+++ clang/lib/CodeGen/CGCall.cpp
@@ -5183,11 +5183,17 @@
 V->getType()->isIntegerTy())
   V = Builder.CreateZExt(V, ArgInfo.getCoerceToType());
 
-// If the argument doesn't match, perform a bitcast to coerce it.  This
-// can happen due to trivial type mismatches.
+// If the argument doesn't match, perform a either a bitcast or an
+// address space cast to coerce it. This can happen either due to
+// trivial type mismatches or valid address space mismatches
+// (e.g. global -> generic; GEPs into VTTs are an example).
 if (FirstIRArg < IRFuncTy->getNumParams() &&
 V->getType() != IRFuncTy->getParamType(FirstIRArg))
-  V = Builder.CreateBitCast(V, IRFuncTy->getParamType(FirstIRArg));
+  if (V->getType()->isPointerTy())
+V = Builder.CreateAddrSpaceCast(V,
+IRFuncTy->getParamType(FirstIrArg));
+  else
+V = Builder.CreateBitCast(V, IRFuncTy->getParamType(FirstIRArg));
 
 if (ArgHasMaybeUndefAttr)
   V = Builder.CreateFreeze(V);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D150744: [NFC][CLANG] Fix uninitialized scalar field issues with Coverity

2023-05-16 Thread Soumi Manna via Phabricator via cfe-commits
Manna created this revision.
Herald added a reviewer: NoQ.
Herald added a project: All.
Manna requested review of this revision.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D150744

Files:
  clang/include/clang/Analysis/Analyses/Consumed.h
  clang/include/clang/Parse/Parser.h
  clang/lib/AST/ExprConstant.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.h
  clang/lib/CodeGen/ConstantEmitter.h
  clang/lib/Serialization/ASTReaderDecl.cpp


Index: clang/lib/Serialization/ASTReaderDecl.cpp
===
--- clang/lib/Serialization/ASTReaderDecl.cpp
+++ clang/lib/Serialization/ASTReaderDecl.cpp
@@ -89,7 +89,7 @@
 using RecordData = ASTReader::RecordData;
 
 TypeID DeferredTypeID = 0;
-unsigned AnonymousDeclNumber;
+unsigned AnonymousDeclNumber = 0;
 GlobalDeclID NamedDeclForTagDecl = 0;
 IdentifierInfo *TypedefNameForLinkage = nullptr;
 
Index: clang/lib/CodeGen/ConstantEmitter.h
===
--- clang/lib/CodeGen/ConstantEmitter.h
+++ clang/lib/CodeGen/ConstantEmitter.h
@@ -42,7 +42,7 @@
 
   /// The AST address space where this (non-abstract) initializer is going.
   /// Used for generating appropriate placeholders.
-  LangAS DestAddressSpace;
+  LangAS DestAddressSpace = LangAS::Default;
 
   llvm::SmallVector, 4>
 PlaceholderAddresses;
Index: clang/lib/CodeGen/CGOpenMPRuntime.h
===
--- clang/lib/CodeGen/CGOpenMPRuntime.h
+++ clang/lib/CodeGen/CGOpenMPRuntime.h
@@ -232,7 +232,7 @@
   /// as those marked as `omp declare target`.
   class DisableAutoDeclareTargetRAII {
 CodeGenModule 
-bool SavedShouldMarkAsGlobal;
+bool SavedShouldMarkAsGlobal = FALSE;
 
   public:
 DisableAutoDeclareTargetRAII(CodeGenModule );
Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -1294,7 +1294,7 @@
   class SpeculativeEvaluationRAII {
 EvalInfo *Info = nullptr;
 Expr::EvalStatus OldStatus;
-unsigned OldSpeculativeEvaluationDepth;
+unsigned OldSpeculativeEvaluationDepth = 0;
 
 void moveFromAndCancel(SpeculativeEvaluationRAII &) {
   Info = Other.Info;
Index: clang/include/clang/Parse/Parser.h
===
--- clang/include/clang/Parse/Parser.h
+++ clang/include/clang/Parse/Parser.h
@@ -1188,7 +1188,7 @@
   /// RAII object used to modify the scope flags for the current scope.
   class ParseScopeFlags {
 Scope *CurScope;
-unsigned OldFlags;
+unsigned OldFlags = 0;
 ParseScopeFlags(const ParseScopeFlags &) = delete;
 void operator=(const ParseScopeFlags &) = delete;
 
Index: clang/include/clang/Analysis/Analyses/Consumed.h
===
--- clang/include/clang/Analysis/Analyses/Consumed.h
+++ clang/include/clang/Analysis/Analyses/Consumed.h
@@ -240,7 +240,7 @@
 ConsumedBlockInfo BlockInfo;
 std::unique_ptr CurrStates;
 
-ConsumedState ExpectedReturnState;
+ConsumedState ExpectedReturnState = CS_None;
 
 void determineExpectedReturnState(AnalysisDeclContext ,
   const FunctionDecl *D);


Index: clang/lib/Serialization/ASTReaderDecl.cpp
===
--- clang/lib/Serialization/ASTReaderDecl.cpp
+++ clang/lib/Serialization/ASTReaderDecl.cpp
@@ -89,7 +89,7 @@
 using RecordData = ASTReader::RecordData;
 
 TypeID DeferredTypeID = 0;
-unsigned AnonymousDeclNumber;
+unsigned AnonymousDeclNumber = 0;
 GlobalDeclID NamedDeclForTagDecl = 0;
 IdentifierInfo *TypedefNameForLinkage = nullptr;
 
Index: clang/lib/CodeGen/ConstantEmitter.h
===
--- clang/lib/CodeGen/ConstantEmitter.h
+++ clang/lib/CodeGen/ConstantEmitter.h
@@ -42,7 +42,7 @@
 
   /// The AST address space where this (non-abstract) initializer is going.
   /// Used for generating appropriate placeholders.
-  LangAS DestAddressSpace;
+  LangAS DestAddressSpace = LangAS::Default;
 
   llvm::SmallVector, 4>
 PlaceholderAddresses;
Index: clang/lib/CodeGen/CGOpenMPRuntime.h
===
--- clang/lib/CodeGen/CGOpenMPRuntime.h
+++ clang/lib/CodeGen/CGOpenMPRuntime.h
@@ -232,7 +232,7 @@
   /// as those marked as `omp declare target`.
   class DisableAutoDeclareTargetRAII {
 CodeGenModule 
-bool SavedShouldMarkAsGlobal;
+bool SavedShouldMarkAsGlobal = FALSE;
 
   public:
 DisableAutoDeclareTargetRAII(CodeGenModule );
Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ 

[PATCH] D150730: [Clang][Sema] Substitute constraints only for declarations with different lexical contexts

2023-05-16 Thread Alexander Shaposhnikov via Phabricator via cfe-commits
alexander-shaposhnikov updated this revision to Diff 522856.
alexander-shaposhnikov added a comment.

Include context.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150730

Files:
  clang/lib/Sema/SemaConcept.cpp
  clang/test/SemaTemplate/concepts-no-early-substitution.cpp


Index: clang/test/SemaTemplate/concepts-no-early-substitution.cpp
===
--- /dev/null
+++ clang/test/SemaTemplate/concepts-no-early-substitution.cpp
@@ -0,0 +1,33 @@
+// RUN: %clang_cc1 -std=c++20 -x c++ %s -verify -fsyntax-only
+// expected-no-diagnostics
+
+template 
+concept HasMemberBegin = requires(T0 t) { t.begin(); };
+
+struct GetBegin {
+  template 
+  void operator()(T1);
+};
+
+GetBegin begin;
+
+template 
+concept Concept = requires(T2 t) { begin(t); };
+
+struct Subrange;
+
+template 
+struct View {
+  Subrange ();
+
+  operator bool()
+requires true;
+
+  operator bool()
+requires requires { begin(getSubrange()); };
+
+  void begin();
+};
+
+struct Subrange : View {};
+static_assert(Concept);
Index: clang/lib/Sema/SemaConcept.cpp
===
--- clang/lib/Sema/SemaConcept.cpp
+++ clang/lib/Sema/SemaConcept.cpp
@@ -780,7 +780,8 @@
  const Expr *NewConstr) {
   if (OldConstr == NewConstr)
 return true;
-  if (Old && New && Old != New) {
+  if (Old && New && Old != New &&
+  Old->getLexicalDeclContext() != New->getLexicalDeclContext()) {
 if (const Expr *SubstConstr =
 SubstituteConstraintExpression(*this, Old, OldConstr))
   OldConstr = SubstConstr;


Index: clang/test/SemaTemplate/concepts-no-early-substitution.cpp
===
--- /dev/null
+++ clang/test/SemaTemplate/concepts-no-early-substitution.cpp
@@ -0,0 +1,33 @@
+// RUN: %clang_cc1 -std=c++20 -x c++ %s -verify -fsyntax-only
+// expected-no-diagnostics
+
+template 
+concept HasMemberBegin = requires(T0 t) { t.begin(); };
+
+struct GetBegin {
+  template 
+  void operator()(T1);
+};
+
+GetBegin begin;
+
+template 
+concept Concept = requires(T2 t) { begin(t); };
+
+struct Subrange;
+
+template 
+struct View {
+  Subrange ();
+
+  operator bool()
+requires true;
+
+  operator bool()
+requires requires { begin(getSubrange()); };
+
+  void begin();
+};
+
+struct Subrange : View {};
+static_assert(Concept);
Index: clang/lib/Sema/SemaConcept.cpp
===
--- clang/lib/Sema/SemaConcept.cpp
+++ clang/lib/Sema/SemaConcept.cpp
@@ -780,7 +780,8 @@
  const Expr *NewConstr) {
   if (OldConstr == NewConstr)
 return true;
-  if (Old && New && Old != New) {
+  if (Old && New && Old != New &&
+  Old->getLexicalDeclContext() != New->getLexicalDeclContext()) {
 if (const Expr *SubstConstr =
 SubstituteConstraintExpression(*this, Old, OldConstr))
   OldConstr = SubstConstr;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D150723: clang/openmp: Fix alignment for ThreadID Address variables

2023-05-16 Thread Tom Stellard via Phabricator via cfe-commits
tstellar updated this revision to Diff 522853.
tstellar added a comment.

Add test case.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150723

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/test/OpenMP/for_reduction_codegen.cpp


Index: clang/test/OpenMP/for_reduction_codegen.cpp
===
--- clang/test/OpenMP/for_reduction_codegen.cpp
+++ clang/test/OpenMP/for_reduction_codegen.cpp
@@ -1,4 +1,4 @@
-// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --function-signature --include-generated-funcs --replace-value-regex 
"__omp_offloading_[0-9a-z]+_[0-9a-z]+" "reduction_size[.].+[.]" 
"pl_cond[.].+[.|,]" --prefix-filecheck-ir-name _
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --function-signature --check-globals --include-generated-funcs 
--replace-value-regex "__omp_offloading_[0-9a-z]+_[0-9a-z]+" 
"reduction_size[.].+[.]" "pl_cond[.].+[.|,]" --prefix-filecheck-ir-name _ 
--global-value-regex ".gomp_critical_user[a-zA-Z_.]+"
 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple x86_64-apple-darwin10 
-emit-llvm %s -o - | FileCheck -allow-deprecated-dag-overlap %s 
--check-prefix=CHECK1
 // RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple x86_64-apple-darwin10 
-emit-pch -o %t %s
 // RUN: %clang_cc1 -fopenmp -x c++ -triple x86_64-apple-darwin10 -std=c++11 
-include-pch %t -verify %s -emit-llvm -o - | FileCheck 
-allow-deprecated-dag-overlap %s --check-prefix=CHECK1
@@ -527,6 +527,14 @@
 
 
 #endif
+//.
+// CHECK1: @.gomp_critical_user_.reduction.var = common global [8 x i32] 
zeroinitializer, align 8
+// CHECK1: @.gomp_critical_user_.atomic_reduction.var = common global [8 x 
i32] zeroinitializer, align 8
+//.
+// CHECK3: @.gomp_critical_user_.reduction.var = common global [8 x i32] 
zeroinitializer, align 8
+//.
+// CHECK4: @.gomp_critical_user_.reduction.var = common global [8 x i32] 
zeroinitializer, align 8
+//.
 // CHECK1-LABEL: define {{[^@]+}}@main
 // CHECK1-SAME: () #[[ATTR0:[0-9]+]] {
 // CHECK1-NEXT:  entry:
Index: clang/lib/CodeGen/CGOpenMPRuntime.cpp
===
--- clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -2143,7 +2143,11 @@
 llvm::Value *CGOpenMPRuntime::getCriticalRegionLock(StringRef CriticalName) {
   std::string Prefix = Twine("gomp_critical_user_", CriticalName).str();
   std::string Name = getName({Prefix, "var"});
-  return OMPBuilder.getOrCreateInternalVariable(KmpCriticalNameTy, Name);
+  llvm::GlobalVariable *G = 
OMPBuilder.getOrCreateInternalVariable(KmpCriticalNameTy, Name);
+  llvm::Align PtrAlign = 
OMPBuilder.M.getDataLayout().getPointerABIAlignment(G->getAddressSpace());
+  if (PtrAlign > llvm::Align(G->getAlignment()))
+G->setAlignment(PtrAlign);
+  return G;
 }
 
 namespace {


Index: clang/test/OpenMP/for_reduction_codegen.cpp
===
--- clang/test/OpenMP/for_reduction_codegen.cpp
+++ clang/test/OpenMP/for_reduction_codegen.cpp
@@ -1,4 +1,4 @@
-// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --function-signature --include-generated-funcs --replace-value-regex "__omp_offloading_[0-9a-z]+_[0-9a-z]+" "reduction_size[.].+[.]" "pl_cond[.].+[.|,]" --prefix-filecheck-ir-name _
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --function-signature --check-globals --include-generated-funcs --replace-value-regex "__omp_offloading_[0-9a-z]+_[0-9a-z]+" "reduction_size[.].+[.]" "pl_cond[.].+[.|,]" --prefix-filecheck-ir-name _ --global-value-regex ".gomp_critical_user[a-zA-Z_.]+"
 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple x86_64-apple-darwin10 -emit-llvm %s -o - | FileCheck -allow-deprecated-dag-overlap %s --check-prefix=CHECK1
 // RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple x86_64-apple-darwin10 -emit-pch -o %t %s
 // RUN: %clang_cc1 -fopenmp -x c++ -triple x86_64-apple-darwin10 -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck -allow-deprecated-dag-overlap %s --check-prefix=CHECK1
@@ -527,6 +527,14 @@
 
 
 #endif
+//.
+// CHECK1: @.gomp_critical_user_.reduction.var = common global [8 x i32] zeroinitializer, align 8
+// CHECK1: @.gomp_critical_user_.atomic_reduction.var = common global [8 x i32] zeroinitializer, align 8
+//.
+// CHECK3: @.gomp_critical_user_.reduction.var = common global [8 x i32] zeroinitializer, align 8
+//.
+// CHECK4: @.gomp_critical_user_.reduction.var = common global [8 x i32] zeroinitializer, align 8
+//.
 // CHECK1-LABEL: define {{[^@]+}}@main
 // CHECK1-SAME: () #[[ATTR0:[0-9]+]] {
 // CHECK1-NEXT:  entry:
Index: clang/lib/CodeGen/CGOpenMPRuntime.cpp
===
--- clang/lib/CodeGen/CGOpenMPRuntime.cpp

[PATCH] D137872: Implement lambdas with inalloca parameters by forwarding to function without inalloca calling convention.

2023-05-16 Thread Amy Huang via Phabricator via cfe-commits
akhuang added a comment.

In D137872#4327615 , @efriedma wrote:

> I'm having a bit of trouble following how exactly the thunk creation is 
> working here... do we generate different code depending on whether the call 
> operator and/or the static invoker are referenced?

So I think it used to be that the static invoker calls the call operator which 
contains the body of the lambda? And now both the static invoker and the call 
operator are delegating to this new __impl function. In 
EmitLambdaStaticInvokeBody it first calls EmitLambdaInAllocaCallOpFn to make 
the new call operator (which is populated using 
EmitLambdaDelegatingInvokeBody). And then inside EmitLambdaDelegatingInvokeBody 
it generates the new impl function and calls it in the body. Not sure if that 
answers the question, I agree the code is a bit roundabout.

> Why is the function in EmitLambdaInAllocaCallOpFn not getting defined using 
> the normal CodeGenModule machinery?

Do you mean why it's not using CodeGenModule machinery to generate the new call 
op body or why we're changing the original call op body?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137872

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


[PATCH] D150740: [clang] Add `__attribute__((nooutline))`

2023-05-16 Thread Jon Roelofs via Phabricator via cfe-commits
jroelofs accepted this revision.
jroelofs added a comment.
This revision is now accepted and ready to land.

LGTM




Comment at: clang/include/clang/Basic/Attr.td:1474
+  let Spellings = [Clang<"nooutline">];
+  let Subjects = SubjectList<[Function, ObjCMethod]>;
+  let Documentation = [NoOutlineDocs];

does it make sense on `Block` too?


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

https://reviews.llvm.org/D150740

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


[PATCH] D150740: [clang] Add `__attribute__((nooutline))`

2023-05-16 Thread Jessica Paquette via Phabricator via cfe-commits
paquette created this revision.
paquette added reviewers: fhahn, aemerson, jroelofs, arphaman, ahatanak.
paquette added a project: clang.
Herald added a reviewer: aaron.ballman.
Herald added a subscriber: StephenFan.
Herald added a project: All.
paquette requested review of this revision.

Sometimes users want to toggle which functions should be outlined from. Users 
could be trying to:

1. Debug the compiler and disable outlining in some contexts
2. Control where outlining actually happens in their program

This adds a frontend attribute that will allow users to toggle this behaviour 
on specific functions.


https://reviews.llvm.org/D150740

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/test/CodeGen/attr-nooutline.c


Index: clang/test/CodeGen/attr-nooutline.c
===
--- /dev/null
+++ clang/test/CodeGen/attr-nooutline.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 %s -S -emit-llvm -o - | FileCheck %s
+
+// CHECK: define i32 @has_attr_2() [[HAS_ATTR_2:#[0-9]+]]
+// CHECK: declare i32 @has_attr_1() [[HAS_ATTR_1:#[0-9]+]]
+
+__attribute__((nooutline)) int has_attr_1(void);
+__attribute__((nooutline)) int has_attr_2(void) { return has_attr_1(); }
+
+// CHECK: attributes [[HAS_ATTR_2]] = { {{.*}}"nooutline"{{.*}} }
+// CHECK: attributes [[HAS_ATTR_1]] = { {{.*}}"nooutline"{{.*}} }
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -2133,6 +2133,8 @@
 if (D->hasAttr())
   B.addAttribute(llvm::Attribute::MinSize);
   }
+  if (D->hasAttr())
+B.addAttribute("nooutline");
 
   F->addFnAttrs(B);
 
Index: clang/lib/CodeGen/CGCall.cpp
===
--- clang/lib/CodeGen/CGCall.cpp
+++ clang/lib/CodeGen/CGCall.cpp
@@ -2344,6 +2344,8 @@
   FuncAttrs.addAttribute(llvm::Attribute::NoCfCheck);
 if (TargetDecl->hasAttr())
   FuncAttrs.addAttribute(llvm::Attribute::NoCallback);
+if (TargetDecl->hasAttr())
+  FuncAttrs.addAttribute("nooutline");
 
 HasOptnone = TargetDecl->hasAttr();
 if (auto *AllocSize = TargetDecl->getAttr()) {
Index: clang/include/clang/Basic/AttrDocs.td
===
--- clang/include/clang/Basic/AttrDocs.td
+++ clang/include/clang/Basic/AttrDocs.td
@@ -580,6 +580,26 @@
   }];
 }
 
+def NoOutlineDocs : Documentation {
+  let Category = DocCatFunction;
+  let Content = [{
+
+Suppresses outlining from a function. Functions with this attribute will not
+be considered for outlining.
+
+.. code-block:: c
+
+  __attribute__((nooutline))
+  int example(void) {
+int r;
+foo();
+bar();
+return r;
+  }
+
+  }];
+}
+
 def MustTailDocs : Documentation {
   let Category = DocCatStmt;
   let Content = [{
Index: clang/include/clang/Basic/Attr.td
===
--- clang/include/clang/Basic/Attr.td
+++ clang/include/clang/Basic/Attr.td
@@ -1469,6 +1469,13 @@
   let SimpleHandler = 1;
 }
 
+def NoOutline : InheritableAttr {
+  let Spellings = [Clang<"nooutline">];
+  let Subjects = SubjectList<[Function, ObjCMethod]>;
+  let Documentation = [NoOutlineDocs];
+  let SimpleHandler = 1;
+}
+
 def MustTail : StmtAttr {
   let Spellings = [Clang<"musttail">];
   let Documentation = [MustTailDocs];


Index: clang/test/CodeGen/attr-nooutline.c
===
--- /dev/null
+++ clang/test/CodeGen/attr-nooutline.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 %s -S -emit-llvm -o - | FileCheck %s
+
+// CHECK: define i32 @has_attr_2() [[HAS_ATTR_2:#[0-9]+]]
+// CHECK: declare i32 @has_attr_1() [[HAS_ATTR_1:#[0-9]+]]
+
+__attribute__((nooutline)) int has_attr_1(void);
+__attribute__((nooutline)) int has_attr_2(void) { return has_attr_1(); }
+
+// CHECK: attributes [[HAS_ATTR_2]] = { {{.*}}"nooutline"{{.*}} }
+// CHECK: attributes [[HAS_ATTR_1]] = { {{.*}}"nooutline"{{.*}} }
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -2133,6 +2133,8 @@
 if (D->hasAttr())
   B.addAttribute(llvm::Attribute::MinSize);
   }
+  if (D->hasAttr())
+B.addAttribute("nooutline");
 
   F->addFnAttrs(B);
 
Index: clang/lib/CodeGen/CGCall.cpp
===
--- clang/lib/CodeGen/CGCall.cpp
+++ clang/lib/CodeGen/CGCall.cpp
@@ -2344,6 +2344,8 @@
   FuncAttrs.addAttribute(llvm::Attribute::NoCfCheck);
 if (TargetDecl->hasAttr())
   FuncAttrs.addAttribute(llvm::Attribute::NoCallback);
+if (TargetDecl->hasAttr())
+  FuncAttrs.addAttribute("nooutline");
 
 HasOptnone = 

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

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

ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148094

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


[PATCH] D150492: [AST] Initialize local counter

2023-05-16 Thread Ben Barham via Phabricator via cfe-commits
bnbarham accepted this revision.
bnbarham added inline comments.



Comment at: clang/lib/Frontend/ASTUnit.cpp:825
   HeaderSearch  = *AST->HeaderInfo;
-  unsigned Counter;
 

> I assume it's optional and ReadAST does not have to set the counter on 
> success.

Looks like we only write the counter value when it's non-zero. So the reader 
would never set it. Thanks for fixing!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150492

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


[PATCH] D147417: [clang-tidy] Do not emit bugprone-exception-escape warnings from coroutines

2023-05-16 Thread Deniz Evrenci via Phabricator via cfe-commits
denizevrenci updated this revision to Diff 522829.
denizevrenci added a comment.

Fix commit message


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147417

Files:
  clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp
  clang-tools-extra/test/clang-tidy/checkers/bugprone/exception-escape-coro.cpp
  clang/include/clang/AST/StmtCXX.h

Index: clang/include/clang/AST/StmtCXX.h
===
--- clang/include/clang/AST/StmtCXX.h
+++ clang/include/clang/AST/StmtCXX.h
@@ -443,6 +443,17 @@
NumParams);
   }
 
+  child_range childrenExclBody() {
+return child_range(getStoredStmts() + SubStmt::Body + 1,
+   getStoredStmts() + SubStmt::FirstParamMove + NumParams);
+  }
+
+  const_child_range childrenExclBody() const {
+return const_child_range(getStoredStmts() + SubStmt::Body + 1,
+ getStoredStmts() + SubStmt::FirstParamMove +
+ NumParams);
+  }
+
   static bool classof(const Stmt *T) {
 return T->getStmtClass() == CoroutineBodyStmtClass;
   }
Index: clang-tools-extra/test/clang-tidy/checkers/bugprone/exception-escape-coro.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone/exception-escape-coro.cpp
@@ -0,0 +1,296 @@
+// RUN: %check_clang_tidy -std=c++20 %s bugprone-exception-escape %t -- \
+// RUN: -- -fexceptions
+
+namespace std {
+
+template  struct coroutine_traits {
+  using promise_type = typename Ret::promise_type;
+};
+
+template  struct coroutine_handle {
+  static coroutine_handle from_address(void *) noexcept;
+  static coroutine_handle from_promise(Promise );
+  constexpr void *address() const noexcept;
+};
+
+template <> struct coroutine_handle {
+  template 
+  coroutine_handle(coroutine_handle) noexcept;
+  static coroutine_handle from_address(void *);
+  constexpr void *address() const noexcept;
+};
+
+struct suspend_always {
+  bool await_ready() noexcept { return false; }
+  void await_suspend(coroutine_handle<>) noexcept {}
+  void await_resume() noexcept {}
+};
+
+struct suspend_never {
+  bool await_ready() noexcept { return true; }
+  void await_suspend(coroutine_handle<>) noexcept {}
+  void await_resume() noexcept {}
+};
+
+} // namespace std
+
+template 
+struct Promise;
+
+template <
+typename T, bool ThrowInTaskConstructor = false,
+bool ThrowInPromiseConstructor = false, bool ThrowInInitialSuspend = false,
+bool ThrowInGetReturnObject = false, bool ThrowInUnhandledException = false>
+struct Task {
+  using promise_type =
+  Promise;
+
+  explicit Task(promise_type ) {
+if constexpr (ThrowInTaskConstructor) {
+  throw 1;
+}
+
+p.return_val = this;
+  }
+
+  T value;
+};
+
+template 
+struct Promise {
+  Promise() {
+if constexpr (ThrowInPromiseConstructor) {
+  throw 1;
+}
+  }
+
+  Task get_return_object() {
+if constexpr (ThrowInGetReturnObject) {
+  throw 1;
+}
+
+return Task{*this};
+  }
+
+  std::suspend_never initial_suspend() const {
+if constexpr (ThrowInInitialSuspend) {
+  throw 1;
+}
+
+return {};
+  }
+
+  std::suspend_never final_suspend() const noexcept { return {}; }
+
+  template  void return_value(U &) {
+return_val->value = static_cast(val);
+  }
+
+  void unhandled_exception() {
+if constexpr (ThrowInUnhandledException) {
+  throw 1;
+}
+  }
+
+  Task *return_val;
+};
+
+struct Evil {
+  ~Evil() noexcept(false) {
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: an exception may be thrown in function '~Evil' which should not throw exceptions
+throw 42;
+  }
+};
+
+namespace function {
+
+Task a_ShouldNotDiag(const int a, const int b) {
+  // CHECK-MESSAGES-NOT: :[[@LINE-1]]:11: warning: an exception may be thrown in function 'a_ShouldNotDiag' which should not throw exceptions
+  if (b == 0)
+throw b;
+
+  co_return a / b;
+}
+
+Task b_ShouldNotDiag(const int a, const int b) noexcept {
+  // CHECK-MESSAGES-NOT: :[[@LINE-1]]:11: warning: an exception may be thrown in function 'b_ShouldNotDiag' which should not throw exceptions
+  if (b == 0)
+throw b;
+
+  co_return a / b;
+}
+
+Task c_ShouldNotDiag(const int a, const int b) {
+  // CHECK-MESSAGES-NOT: :[[@LINE-1]]:11: warning: an exception may be thrown in function 'c_ShouldNotDiag' which should not throw exceptions
+  if (b == 0)
+throw Evil{};
+
+  co_return a / b;
+}
+
+Task c_ShouldDiag(const int a, const int b) noexcept {
+  // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: an exception may be thrown in function 'c_ShouldDiag' which should not throw exceptions
+  if (b == 0)
+throw Evil{};
+
+  co_return a / b;
+}
+
+Task d_ShouldNotDiag(const int a, const int b) {
+  // CHECK-MESSAGES-NOT: :[[@LINE-1]]:17: warning: an exception may be 

[PATCH] D150730: [Clang][Sema] Substitute constraints only for declarations with different lexical contexts

2023-05-16 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added a comment.

Can you please add context to the diff. thank you.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150730

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


[PATCH] D148785: -fsanitize=function: use type hashes instead of RTTI objects

2023-05-16 Thread Sami Tolvanen via Phabricator via cfe-commits
samitolvanen accepted this revision.
samitolvanen added a comment.
This revision is now accepted and ready to land.

Looks good to me, but maybe worth waiting for someone more familiar with 
compiler-rt to take a look as well.




Comment at: llvm/test/CodeGen/AArch64/patchable-function-entry-bti.ll:92
 ; CHECK-NEXT: .Ltmp{{.*}}:
 ; CHECK-NEXT:   nop
 ; CHECK-NEXT:   .word   3238382334  // 0xc105cafe

peter.smith wrote:
> Assuming the test is the equivalent of `-fpatchable-function-entry=1,1` I 
> think this is the wrong place for the nop, I think it needs to be after the 
> signature and the loads adjusted. For example with -fsanitize=kcfi 
> -fpatchable-function-entries=1,1
> ```
> typedef int Fptr(void);
> 
> int function(void) {
>   return 0;
> }
> 
> int call(Fptr* fp) {
>   return fp();
> }
> ```
> Results in code like:
> ```
> .word   1670944012  // @call
> // 0x6398950c
> .Ltmp1:
> nop
> call:
> .Lfunc_begin1:
> .cfi_startproc
> // %bb.0:   // %entry
> ldurw16, [x0, #-8]
> movkw17, #50598
> movkw17, #14001, lsl #16
> cmp w16, w17
> b.eq.Ltmp2
> brk #0x8220
> .Ltmp2:
> br  x0
> .Lfunc_end1:
> ```
> Note the NOP is after the signature, with the `ldur` having an offset of -8 
> and not the usual -4. I think you would need to make sure the signature is a 
> branch instruction for each target for this scheme to work.
No, this looks correct to me. Note that in AsmPrinter the type hash is emitted 
after the patchable-function-prefix nops, while the KCFI type hash is emitted 
before them.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148785

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


[PATCH] D150492: [AST] Initialize local counter

2023-05-16 Thread Sergei Barannikov via Phabricator via cfe-commits
barannikov88 accepted this revision.
barannikov88 added a comment.
This revision is now accepted and ready to land.

Not my area, but the change is trivial.

Nit: could move the variable closer to its use.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150492

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


[PATCH] D150411: [NFC][Clang][Coverity] Fix Static Code Analysis Concerns with copy without assign

2023-05-16 Thread Soumi Manna via Phabricator via cfe-commits
Manna updated this revision to Diff 522826.

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

https://reviews.llvm.org/D150411

Files:
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/Analysis/Analyses/Consumed.h
  clang/include/clang/Analysis/Analyses/ThreadSafetyTIL.h
  clang/include/clang/Analysis/Analyses/ThreadSafetyUtil.h
  clang/include/clang/Rewrite/Core/RewriteRope.h
  clang/include/clang/Sema/ParsedAttr.h
  clang/include/clang/Sema/Sema.h
  clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h
  clang/lib/CodeGen/CGDebugInfo.h
  clang/lib/CodeGen/EHScopeStack.h

Index: clang/lib/CodeGen/EHScopeStack.h
===
--- clang/lib/CodeGen/EHScopeStack.h
+++ clang/lib/CodeGen/EHScopeStack.h
@@ -148,6 +148,8 @@
   public:
 Cleanup(const Cleanup &) = default;
 Cleanup(Cleanup &&) {}
+Cleanup =(const Cleanup &) = delete;
+Cleanup =(Cleanup &&) = delete;
 Cleanup() = default;
 
 virtual bool isRedundantBeforeReturn() { return false; }
Index: clang/lib/CodeGen/CGDebugInfo.h
===
--- clang/lib/CodeGen/CGDebugInfo.h
+++ clang/lib/CodeGen/CGDebugInfo.h
@@ -829,7 +829,12 @@
   ApplyDebugLocation(ApplyDebugLocation &) : CGF(Other.CGF) {
 Other.CGF = nullptr;
   }
-  ApplyDebugLocation =(ApplyDebugLocation &&) = default;
+
+  ApplyDebugLocation =(ApplyDebugLocation &) {
+CGF = Other.CGF;
+Other.CGF = nullptr;
+return *this;
+  }
 
   ~ApplyDebugLocation();
 
Index: clang/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h
===
--- clang/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h
+++ clang/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h
@@ -671,6 +671,8 @@
   SymbolVisitor() = default;
   SymbolVisitor(const SymbolVisitor &) = default;
   SymbolVisitor(SymbolVisitor &&) {}
+  SymbolVisitor =(const SymbolVisitor &) = delete;
+  SymbolVisitor =(SymbolVisitor &&) = delete;
 
   /// A visitor method invoked by ProgramStateManager::scanReachableSymbols.
   ///
Index: clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h
===
--- clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h
+++ clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h
@@ -51,6 +51,8 @@
   BugReporterVisitor() = default;
   BugReporterVisitor(const BugReporterVisitor &) = default;
   BugReporterVisitor(BugReporterVisitor &&) {}
+  BugReporterVisitor =(const BugReporterVisitor &) = delete;
+  BugReporterVisitor =(BugReporterVisitor &&) = delete;
   virtual ~BugReporterVisitor();
 
   /// Return a diagnostic piece which should be associated with the
Index: clang/include/clang/Sema/Sema.h
===
--- clang/include/clang/Sema/Sema.h
+++ clang/include/clang/Sema/Sema.h
@@ -1787,6 +1787,8 @@
   const FunctionDecl *Fn, Sema );
 SemaDiagnosticBuilder(SemaDiagnosticBuilder &);
 SemaDiagnosticBuilder(const SemaDiagnosticBuilder &) = default;
+SemaDiagnosticBuilder =(const SemaDiagnosticBuilder &) = delete;
+SemaDiagnosticBuilder =(SemaDiagnosticBuilder &&) = delete;
 ~SemaDiagnosticBuilder();
 
 bool isImmediate() const { return ImmediateDiag.has_value(); }
Index: clang/include/clang/Sema/ParsedAttr.h
===
--- clang/include/clang/Sema/ParsedAttr.h
+++ clang/include/clang/Sema/ParsedAttr.h
@@ -701,6 +701,7 @@
 
   /// Move the given pool's allocations to this pool.
   AttributePool(AttributePool &) = default;
+  AttributePool =(AttributePool &) = delete;
 
   AttributeFactory () const { return Factory; }
 
Index: clang/include/clang/Rewrite/Core/RewriteRope.h
===
--- clang/include/clang/Rewrite/Core/RewriteRope.h
+++ clang/include/clang/Rewrite/Core/RewriteRope.h
@@ -181,6 +181,8 @@
   RewriteRope() = default;
   RewriteRope(const RewriteRope ) : Chunks(RHS.Chunks) {}
 
+  RewriteRope =(const RewriteRope &) = delete;
+
   using iterator = RopePieceBTree::iterator;
   using const_iterator = RopePieceBTree::iterator;
 
Index: clang/include/clang/Analysis/Analyses/ThreadSafetyUtil.h
===
--- clang/include/clang/Analysis/Analyses/ThreadSafetyUtil.h
+++ clang/include/clang/Analysis/Analyses/ThreadSafetyUtil.h
@@ -240,6 +240,7 @@
 
 VectorData() = default;
 VectorData(const VectorData ) : Vect(VD.Vect) {}
+VectorData =(const VectorData &) = delete;
   };
 
 public:
Index: clang/include/clang/Analysis/Analyses/ThreadSafetyTIL.h

[PATCH] D144509: [CMake] Bumps minimum version to 3.20.0.

2023-05-16 Thread Mike Hommey via Phabricator via cfe-commits
glandium added a comment.

So the problem is that `CMakePolicy.cmake` is not included in 
`compiler-rt/CMakeLists.txt`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144509

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


[PATCH] D148785: -fsanitize=function: use type hashes instead of RTTI objects

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

In D148785#4348053 , @vitalybuka 
wrote:

> Is possible to split the patch into smaller ones?

The Clang CodeGen side needs to match 
`llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp` and `compiler-rt/lib/ubsan`, so 
no, I think this is the smallest unit...

I have placed logically independent parts in other patches: D148665 
, D148573 .


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148785

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


[PATCH] D150411: [NFC][Clang][Coverity] Fix Static Code Analysis Concerns with copy without assign

2023-05-16 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert added a comment.

I'd probably abstain from explicitly deleting what is already implicitly 
deleted, but otherwise this looks good to me. Thanks!




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

tahonermann wrote:
> 
Being explicit is certainly a good thing, but the C++ committee wants to go 
into the direction of "copy/move operations are implicitly deleted if any of 
them or the destructor is user-declared." See 
[depr.impldec](https://eel.is/c++draft/depr.impldec). It is already partially 
the case, for example here. So why do need to spell something out explicitly 
when the language goes into the direction of being even more implicit?


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

https://reviews.llvm.org/D150411

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


[PATCH] D150411: [NFC][Clang][Coverity] Fix Static Code Analysis Concerns with copy without assign

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



Comment at: clang/include/clang/Sema/Sema.h:1789-1791
+SemaDiagnosticBuilder =(SemaDiagnosticBuilder &) = delete;
 SemaDiagnosticBuilder(const SemaDiagnosticBuilder &) = default;
+SemaDiagnosticBuilder =(const SemaDiagnosticBuilder &) = delete;

tahonermann wrote:
> aaronpuchert wrote:
> > Manna wrote:
> > > @tahonermann This is follow-up comments from 
> > > https://reviews.llvm.org/D149718?id=519331#inline-1452044. 
> > > 
> > > >>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.
> > > 
> > > I tried to define move assignment operator in ` clang/lib/Sema/Sema.cpp` 
> > > but it failed because class Sema has deleted implicit copy assignment 
> > > operator.
> > > 
> > > ```
> > > /// Sema - This implements semantic analysis and AST building for C.
> > > class Sema final {
> > >   Sema(const Sema &) = delete;
> > >   void operator=(const Sema &) = delete;
> > > ```
> > > It seems like support for assignment is not desired, We probably need 
> > > deleted copy/move assignment operator.
> > > 
> > These are also implicitly deleted. Some code styles want this explicitly 
> > spelled out, but I don't think ours does.
> > I tried to define move assignment operator in  clang/lib/Sema/Sema.cpp but 
> > it failed because class Sema has deleted implicit copy assignment operator.
> 
> It is still permissible to define a move assignment operator if the implicit 
> copy assignment operator is deleted. See https://godbolt.org/z/sGaWd9M44.
> 
> I think it is fine to disable support for assignment for this class pending 
> use cases. But, since a move constructor is explicitly defined, we should 
> also be explicit above move assignment. I added a suggested edit. Without 
> that change, I think Coverity will continue to complain.
I see! Thanks @tahonermann for the explanation


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

https://reviews.llvm.org/D150411

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


[PATCH] D150411: [NFC][Clang][Coverity] Fix Static Code Analysis Concerns with copy without assign

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

Thanks @tahonermann for your reviews and feedbacks. I have addressed your 
review comments.


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

https://reviews.llvm.org/D150411

Files:
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/Analysis/Analyses/Consumed.h
  clang/include/clang/Analysis/Analyses/ThreadSafetyTIL.h
  clang/include/clang/Analysis/Analyses/ThreadSafetyUtil.h
  clang/include/clang/Rewrite/Core/RewriteRope.h
  clang/include/clang/Sema/Sema.h
  clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h
  clang/lib/CodeGen/CGDebugInfo.h
  clang/lib/CodeGen/EHScopeStack.h

Index: clang/lib/CodeGen/EHScopeStack.h
===
--- clang/lib/CodeGen/EHScopeStack.h
+++ clang/lib/CodeGen/EHScopeStack.h
@@ -148,6 +148,8 @@
   public:
 Cleanup(const Cleanup &) = default;
 Cleanup(Cleanup &&) {}
+Cleanup =(const Cleanup &) = delete;
+Cleanup =(Cleanup &&) = delete;
 Cleanup() = default;
 
 virtual bool isRedundantBeforeReturn() { return false; }
Index: clang/lib/CodeGen/CGDebugInfo.h
===
--- clang/lib/CodeGen/CGDebugInfo.h
+++ clang/lib/CodeGen/CGDebugInfo.h
@@ -829,7 +829,12 @@
   ApplyDebugLocation(ApplyDebugLocation &) : CGF(Other.CGF) {
 Other.CGF = nullptr;
   }
-  ApplyDebugLocation =(ApplyDebugLocation &&) = default;
+
+  ApplyDebugLocation =(ApplyDebugLocation &) {
+CGF = Other.CGF;
+Other.CGF = nullptr;
+return *this;
+  }
 
   ~ApplyDebugLocation();
 
Index: clang/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h
===
--- clang/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h
+++ clang/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h
@@ -671,6 +671,8 @@
   SymbolVisitor() = default;
   SymbolVisitor(const SymbolVisitor &) = default;
   SymbolVisitor(SymbolVisitor &&) {}
+  SymbolVisitor =(const SymbolVisitor &) = delete;
+  SymbolVisitor =(SymbolVisitor &&) = delete;
 
   /// A visitor method invoked by ProgramStateManager::scanReachableSymbols.
   ///
Index: clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h
===
--- clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h
+++ clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h
@@ -51,6 +51,8 @@
   BugReporterVisitor() = default;
   BugReporterVisitor(const BugReporterVisitor &) = default;
   BugReporterVisitor(BugReporterVisitor &&) {}
+  BugReporterVisitor =(const BugReporterVisitor &) = delete;
+  BugReporterVisitor =(BugReporterVisitor &&) = delete;
   virtual ~BugReporterVisitor();
 
   /// Return a diagnostic piece which should be associated with the
Index: clang/include/clang/Sema/Sema.h
===
--- clang/include/clang/Sema/Sema.h
+++ clang/include/clang/Sema/Sema.h
@@ -1787,6 +1787,8 @@
   const FunctionDecl *Fn, Sema );
 SemaDiagnosticBuilder(SemaDiagnosticBuilder &);
 SemaDiagnosticBuilder(const SemaDiagnosticBuilder &) = default;
+SemaDiagnosticBuilder =(const SemaDiagnosticBuilder &) = delete;
+SemaDiagnosticBuilder =(SemaDiagnosticBuilder &&) = delete;
 ~SemaDiagnosticBuilder();
 
 bool isImmediate() const { return ImmediateDiag.has_value(); }
Index: clang/include/clang/Rewrite/Core/RewriteRope.h
===
--- clang/include/clang/Rewrite/Core/RewriteRope.h
+++ clang/include/clang/Rewrite/Core/RewriteRope.h
@@ -181,6 +181,8 @@
   RewriteRope() = default;
   RewriteRope(const RewriteRope ) : Chunks(RHS.Chunks) {}
 
+  RewriteRope =(const RewriteRope &) = delete;
+
   using iterator = RopePieceBTree::iterator;
   using const_iterator = RopePieceBTree::iterator;
 
Index: clang/include/clang/Analysis/Analyses/ThreadSafetyUtil.h
===
--- clang/include/clang/Analysis/Analyses/ThreadSafetyUtil.h
+++ clang/include/clang/Analysis/Analyses/ThreadSafetyUtil.h
@@ -240,6 +240,7 @@
 
 VectorData() = default;
 VectorData(const VectorData ) : Vect(VD.Vect) {}
+VectorData =(const VectorData &) = delete;
   };
 
 public:
Index: clang/include/clang/Analysis/Analyses/ThreadSafetyTIL.h
===
--- clang/include/clang/Analysis/Analyses/ThreadSafetyTIL.h
+++ clang/include/clang/Analysis/Analyses/ThreadSafetyTIL.h
@@ -565,6 +565,7 @@
 public:
   LiteralT(T Dat) : Literal(ValueType::getValueType()), Val(Dat) {}
   LiteralT(const LiteralT ) : Literal(L), 

[PATCH] D150492: [AST] Initialize local counter

2023-05-16 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added a comment.

ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150492

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


[PATCH] D148785: -fsanitize=function: use type hashes instead of RTTI objects

2023-05-16 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added a comment.

Is possible to split the patch into smaller ones?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148785

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


[PATCH] D150629: [clang-format] Don't allow template to be preceded by closing brace

2023-05-16 Thread Emilia Kond 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 rGe4d3e8880239: [clang-format] Dont allow template to be 
preceded by closing brace (authored by rymiel).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150629

Files:
  clang/lib/Format/TokenAnnotator.cpp
  clang/unittests/Format/FormatTest.cpp
  clang/unittests/Format/TokenAnnotatorTest.cpp


Index: clang/unittests/Format/TokenAnnotatorTest.cpp
===
--- clang/unittests/Format/TokenAnnotatorTest.cpp
+++ clang/unittests/Format/TokenAnnotatorTest.cpp
@@ -480,6 +480,23 @@
   EXPECT_TOKEN(Tokens[8], tok::greater, TT_BinaryOperator);
 }
 
+TEST_F(TokenAnnotatorTest, UnderstandsNonTemplateAngleBrackets) {
+  auto Tokens = annotate("return a < b && c > d;");
+  ASSERT_EQ(Tokens.size(), 10u) << Tokens;
+  EXPECT_TOKEN(Tokens[2], tok::less, TT_BinaryOperator);
+  EXPECT_TOKEN(Tokens[6], tok::greater, TT_BinaryOperator);
+
+  Tokens = annotate("a < 0 ? b : a > 0 ? c : d;");
+  ASSERT_EQ(Tokens.size(), 15u) << Tokens;
+  EXPECT_TOKEN(Tokens[1], tok::less, TT_BinaryOperator);
+  EXPECT_TOKEN(Tokens[7], tok::greater, TT_BinaryOperator);
+
+  Tokens = annotate("ratio{-1, 2} < ratio{-1, 3} == -1 / 3 > -1 / 2;");
+  ASSERT_EQ(Tokens.size(), 27u) << Tokens;
+  EXPECT_TOKEN(Tokens[7], tok::less, TT_BinaryOperator);
+  EXPECT_TOKEN(Tokens[20], tok::greater, TT_BinaryOperator);
+}
+
 TEST_F(TokenAnnotatorTest, UnderstandsWhitespaceSensitiveMacros) {
   FormatStyle Style = getLLVMStyle();
   Style.WhitespaceSensitiveMacros.push_back("FOO");
Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -10679,6 +10679,7 @@
   // Not template parameters.
   verifyFormat("return a < b && c > d;");
   verifyFormat("a < 0 ? b : a > 0 ? c : d;");
+  verifyFormat("ratio{-1, 2} < ratio{-1, 3} == -1 / 3 > -1 / 2;");
   verifyFormat("void f() {\n"
"  while (a < b && c > d) {\n"
"  }\n"
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -144,6 +144,8 @@
 if (Previous.Previous) {
   if (Previous.Previous->Tok.isLiteral())
 return false;
+  if (Previous.Previous->is(tok::r_brace))
+return false;
   if (Previous.Previous->is(tok::r_paren) && Contexts.size() > 1 &&
   (!Previous.Previous->MatchingParen ||
!Previous.Previous->MatchingParen->is(


Index: clang/unittests/Format/TokenAnnotatorTest.cpp
===
--- clang/unittests/Format/TokenAnnotatorTest.cpp
+++ clang/unittests/Format/TokenAnnotatorTest.cpp
@@ -480,6 +480,23 @@
   EXPECT_TOKEN(Tokens[8], tok::greater, TT_BinaryOperator);
 }
 
+TEST_F(TokenAnnotatorTest, UnderstandsNonTemplateAngleBrackets) {
+  auto Tokens = annotate("return a < b && c > d;");
+  ASSERT_EQ(Tokens.size(), 10u) << Tokens;
+  EXPECT_TOKEN(Tokens[2], tok::less, TT_BinaryOperator);
+  EXPECT_TOKEN(Tokens[6], tok::greater, TT_BinaryOperator);
+
+  Tokens = annotate("a < 0 ? b : a > 0 ? c : d;");
+  ASSERT_EQ(Tokens.size(), 15u) << Tokens;
+  EXPECT_TOKEN(Tokens[1], tok::less, TT_BinaryOperator);
+  EXPECT_TOKEN(Tokens[7], tok::greater, TT_BinaryOperator);
+
+  Tokens = annotate("ratio{-1, 2} < ratio{-1, 3} == -1 / 3 > -1 / 2;");
+  ASSERT_EQ(Tokens.size(), 27u) << Tokens;
+  EXPECT_TOKEN(Tokens[7], tok::less, TT_BinaryOperator);
+  EXPECT_TOKEN(Tokens[20], tok::greater, TT_BinaryOperator);
+}
+
 TEST_F(TokenAnnotatorTest, UnderstandsWhitespaceSensitiveMacros) {
   FormatStyle Style = getLLVMStyle();
   Style.WhitespaceSensitiveMacros.push_back("FOO");
Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -10679,6 +10679,7 @@
   // Not template parameters.
   verifyFormat("return a < b && c > d;");
   verifyFormat("a < 0 ? b : a > 0 ? c : d;");
+  verifyFormat("ratio{-1, 2} < ratio{-1, 3} == -1 / 3 > -1 / 2;");
   verifyFormat("void f() {\n"
"  while (a < b && c > d) {\n"
"  }\n"
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -144,6 +144,8 @@
 if (Previous.Previous) {
   if (Previous.Previous->Tok.isLiteral())
 return false;
+  if (Previous.Previous->is(tok::r_brace))
+return false;
   if (Previous.Previous->is(tok::r_paren) && Contexts.size() > 1 &&
  

[clang] e4d3e88 - [clang-format] Don't allow template to be preceded by closing brace

2023-05-16 Thread Emilia Kond via cfe-commits

Author: Emilia Kond
Date: 2023-05-17T01:37:19+03:00
New Revision: e4d3e88802390a51ae62ade18e48c1a65a862d12

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

LOG: [clang-format] Don't allow template to be preceded by closing brace

This check is similar to the right paren check right below it, but it
doesn't need the overloaded operator check.

This patch prevents brace-initialized objects that are being compared
from being mis-annotated as template parameters.

Fixes https://github.com/llvm/llvm-project/issues/57004

Reviewed By: owenpan, MyDeveloperDay

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

Added: 


Modified: 
clang/lib/Format/TokenAnnotator.cpp
clang/unittests/Format/FormatTest.cpp
clang/unittests/Format/TokenAnnotatorTest.cpp

Removed: 




diff  --git a/clang/lib/Format/TokenAnnotator.cpp 
b/clang/lib/Format/TokenAnnotator.cpp
index fe32fa101356..997fe92cabac 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -144,6 +144,8 @@ class AnnotatingParser {
 if (Previous.Previous) {
   if (Previous.Previous->Tok.isLiteral())
 return false;
+  if (Previous.Previous->is(tok::r_brace))
+return false;
   if (Previous.Previous->is(tok::r_paren) && Contexts.size() > 1 &&
   (!Previous.Previous->MatchingParen ||
!Previous.Previous->MatchingParen->is(

diff  --git a/clang/unittests/Format/FormatTest.cpp 
b/clang/unittests/Format/FormatTest.cpp
index dc673934a3f1..dec0ea72b58a 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -10679,6 +10679,7 @@ TEST_F(FormatTest, UnderstandsTemplateParameters) {
   // Not template parameters.
   verifyFormat("return a < b && c > d;");
   verifyFormat("a < 0 ? b : a > 0 ? c : d;");
+  verifyFormat("ratio{-1, 2} < ratio{-1, 3} == -1 / 3 > -1 / 2;");
   verifyFormat("void f() {\n"
"  while (a < b && c > d) {\n"
"  }\n"

diff  --git a/clang/unittests/Format/TokenAnnotatorTest.cpp 
b/clang/unittests/Format/TokenAnnotatorTest.cpp
index 93f7f710d32c..b875b6f7144e 100644
--- a/clang/unittests/Format/TokenAnnotatorTest.cpp
+++ b/clang/unittests/Format/TokenAnnotatorTest.cpp
@@ -480,6 +480,23 @@ TEST_F(TokenAnnotatorTest, 
UnderstandsGreaterAfterTemplateCloser) {
   EXPECT_TOKEN(Tokens[8], tok::greater, TT_BinaryOperator);
 }
 
+TEST_F(TokenAnnotatorTest, UnderstandsNonTemplateAngleBrackets) {
+  auto Tokens = annotate("return a < b && c > d;");
+  ASSERT_EQ(Tokens.size(), 10u) << Tokens;
+  EXPECT_TOKEN(Tokens[2], tok::less, TT_BinaryOperator);
+  EXPECT_TOKEN(Tokens[6], tok::greater, TT_BinaryOperator);
+
+  Tokens = annotate("a < 0 ? b : a > 0 ? c : d;");
+  ASSERT_EQ(Tokens.size(), 15u) << Tokens;
+  EXPECT_TOKEN(Tokens[1], tok::less, TT_BinaryOperator);
+  EXPECT_TOKEN(Tokens[7], tok::greater, TT_BinaryOperator);
+
+  Tokens = annotate("ratio{-1, 2} < ratio{-1, 3} == -1 / 3 > -1 / 2;");
+  ASSERT_EQ(Tokens.size(), 27u) << Tokens;
+  EXPECT_TOKEN(Tokens[7], tok::less, TT_BinaryOperator);
+  EXPECT_TOKEN(Tokens[20], tok::greater, TT_BinaryOperator);
+}
+
 TEST_F(TokenAnnotatorTest, UnderstandsWhitespaceSensitiveMacros) {
   FormatStyle Style = getLLVMStyle();
   Style.WhitespaceSensitiveMacros.push_back("FOO");



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


[PATCH] D146269: MIPS: allow o32 abi with 64bit CPU and 64 abi with 32bit triple

2023-05-16 Thread Fangrui Song via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG7983f8aca82e: MIPS: allow o32 abi with 64bit CPU and 64 abi 
with 32bit triple (authored by wzssyqa, committed by MaskRay).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146269

Files:
  clang/lib/Basic/Targets/Mips.cpp
  clang/test/Driver/mips-abi.c
  clang/test/Driver/mips-cpu64abi32.c
  llvm/lib/Target/Mips/MipsSubtarget.cpp

Index: llvm/lib/Target/Mips/MipsSubtarget.cpp
===
--- llvm/lib/Target/Mips/MipsSubtarget.cpp
+++ llvm/lib/Target/Mips/MipsSubtarget.cpp
@@ -104,8 +104,7 @@
 report_fatal_error("Code generation for MIPS-V is not implemented", false);
 
   // Check if Architecture and ABI are compatible.
-  assert(((!isGP64bit() && isABI_O32()) ||
-  (isGP64bit() && (isABI_N32() || isABI_N64( &&
+  assert(((!isGP64bit() && isABI_O32()) || isGP64bit()) &&
  "Invalid  Arch & ABI pair.");
 
   if (hasMSA() && !isFP64bit())
Index: clang/test/Driver/mips-cpu64abi32.c
===
--- /dev/null
+++ clang/test/Driver/mips-cpu64abi32.c
@@ -0,0 +1,68 @@
+/// Check handling the CPU is 64bit while ABI is O32.
+/// when build for MIPS platforms.
+
+/// abi-n32
+// RUN: %clang -### -c %s --target=mips-linux-gnu -mabi=n32 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-ABI-N32 %s
+// CHECK-ABI-N32: "-target-abi" "n32"
+
+/// abi-64
+// RUN: %clang -### -c %s --target=mips-linux-gnu -mabi=64 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-ABI-64 %s
+// CHECK-ABI-64: "-target-abi" "n64"
+
+
+/// -march=mips3
+// RUN: %clang -### -c %s --target=mips-linux-gnu -march=mips3 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-MIPS-MIPS3 %s
+// CHECK-MIPS-MIPS3: "-target-cpu" "mips3" {{.*}} "-target-abi" "o32"
+
+/// -march=mips4
+// RUN: %clang -### -c %s --target=mips-linux-gnu -march=mips4 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-MIPS-MIPS4 %s
+// CHECK-MIPS-MIPS4: "-target-cpu" "mips4" {{.*}} "-target-abi" "o32"
+
+/// FIXME: MIPS V is not implemented yet.
+
+/// -march=mips64
+/// RUN: %clang -### -c %s --target=mips-linux-gnu -march=mips64 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-MIPS-MIPS64 %s
+// CHECK-MIPS-MIPS64: "-target-cpu" "mips64" {{.*}} "-target-abi" "o32"
+
+/// -march=mips64r2
+/// RUN: %clang -### -c %s --target=mips-linux-gnu -march=mips64r2 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-MIPS-MIPS64R2 %s
+// CHECK-MIPS-MIPS64R2: "-target-cpu" "mips64r2" {{.*}} "-target-abi" "o32"
+
+/// -march=mips64r6
+// RUN: %clang -### -c %s --target=mips-linux-gnu -march=mips64r6 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-MIPS-MIPS64R6 %s
+// CHECK-MIPS-MIPS64R6: "-target-cpu" "mips64r6" {{.*}} "-target-abi" "o32"
+
+
+/// mipsisa3
+// RUN: %clang -### -c %s --target=mips64-linux-gnu -march=mips3 -mabi=32 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-MIPS-MIPSISA3 %s
+// CHECK-MIPS-MIPSISA3: "-target-cpu" "mips3" {{.*}} "-target-abi" "o32"
+
+/// mipsisa4
+// RUN: %clang -### -c %s --target=mips64-linux-gnu -march=mips4 -mabi=32 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-MIPS-MIPSISA4 %s
+// CHECK-MIPS-MIPSISA4: "-target-cpu" "mips4" {{.*}} "-target-abi" "o32"
+
+/// FIXME: MIPS V is not implemented yet.
+
+/// mipsisa64
+// RUN: %clang -### -c %s --target=mips64-linux-gnu -march=mips64 -mabi=32 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-MIPS-MIPSISA64 %s
+// CHECK-MIPS-MIPSISA64: "-target-cpu" "mips64" {{.*}} "-target-abi" "o32"
+
+/// mipsisa64r2
+// RUN: %clang -### -c %s --target=mips64-linux-gnu -march=mips64r2 -mabi=32 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-MIPS-MIPSISA64R2 %s
+// CHECK-MIPS-MIPSISA64R2: "-target-cpu" "mips64r2" {{.*}} "-target-abi" "o32"
+
+/// mipsisa64r6
+// RUN: %clang -### -c %s --target=mips64-linux-gnu -march=mips64r6 -mabi=32 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-MIPS-MIPSISA64R6 %s
+// CHECK-MIPS-MIPSISA64R6: "-target-cpu" "mips64r6" {{.*}} "-target-abi" "o32"
Index: clang/test/Driver/mips-abi.c
===
--- clang/test/Driver/mips-abi.c
+++ clang/test/Driver/mips-abi.c
@@ -9,13 +9,6 @@
 // MIPS32R2-O32: "-target-cpu" "mips32r2"
 // MIPS32R2-O32: "-target-abi" "o32"
 //
-// FIXME: This is a valid combination of options but we reject it at the moment
-//because the backend can't handle it.
-// RUN: not %clang -target mips-linux-gnu -c %s \
-// RUN:-march=mips64r2 -mabi=32 2>&1 \
-// RUN:   | FileCheck -check-prefix=MIPS64R2-O32 %s
-// MIPS64R2-O32: error: ABI 'o32' is not supported on CPU 'mips64r2'
-//
 // RUN: %clang -target mips64-linux-gnu -### -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=MIPS64R2-N64 %s
 // RUN: %clang -target mips-img-linux-gnu 

[clang] 7983f8a - MIPS: allow o32 abi with 64bit CPU and 64 abi with 32bit triple

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

Author: YunQiang Su
Date: 2023-05-16T15:31:37-07:00
New Revision: 7983f8aca82e258174849f1cc6a70029353e9887

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

LOG: MIPS: allow o32 abi with 64bit CPU and 64 abi with 32bit triple

In general, MIPS support ELF format like
   ELF 32-bit LSB relocatable, MIPS, MIPS64 rel2 version 1 (SYSV)
and Linux's VDSO uses it.

Currently clang stop CMDs like
clang -march=mips64r2 -mabi=32

While it is not needed now, since the the backend support the combination now.

This patch also allows something like
 clang --target=mipsel-linux-gnu -mabi=64
Since the triple can convert to right 64bit one automaticly.

Reviewed By: MaskRay

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

Added: 
clang/test/Driver/mips-cpu64abi32.c

Modified: 
clang/lib/Basic/Targets/Mips.cpp
clang/test/Driver/mips-abi.c
llvm/lib/Target/Mips/MipsSubtarget.cpp

Removed: 




diff  --git a/clang/lib/Basic/Targets/Mips.cpp 
b/clang/lib/Basic/Targets/Mips.cpp
index 078a8fe62ac23..cdf652c49f603 100644
--- a/clang/lib/Basic/Targets/Mips.cpp
+++ b/clang/lib/Basic/Targets/Mips.cpp
@@ -238,12 +238,6 @@ bool MipsTargetInfo::validateTarget(DiagnosticsEngine 
) const {
 Diags.Report(diag::err_target_unsupported_cpu_for_micromips) << CPU;
 return false;
   }
-  // FIXME: It's valid to use O32 on a 64-bit CPU but the backend can't handle
-  //this yet. It's better to fail here than on the backend assertion.
-  if (processorSupportsGPR64() && ABI == "o32") {
-Diags.Report(diag::err_target_unsupported_abi) << ABI << CPU;
-return false;
-  }
 
   // 64-bit ABI's require 64-bit CPU's.
   if (!processorSupportsGPR64() && (ABI == "n32" || ABI == "n64")) {
@@ -251,24 +245,6 @@ bool MipsTargetInfo::validateTarget(DiagnosticsEngine 
) const {
 return false;
   }
 
-  // FIXME: It's valid to use O32 on a mips64/mips64el triple but the backend
-  //can't handle this yet. It's better to fail here than on the
-  //backend assertion.
-  if (getTriple().isMIPS64() && ABI == "o32") {
-Diags.Report(diag::err_target_unsupported_abi_for_triple)
-<< ABI << getTriple().str();
-return false;
-  }
-
-  // FIXME: It's valid to use N32/N64 on a mips/mipsel triple but the backend
-  //can't handle this yet. It's better to fail here than on the
-  //backend assertion.
-  if (getTriple().isMIPS32() && (ABI == "n32" || ABI == "n64")) {
-Diags.Report(diag::err_target_unsupported_abi_for_triple)
-<< ABI << getTriple().str();
-return false;
-  }
-
   // -fpxx is valid only for the o32 ABI
   if (FPMode == FPXX && (ABI == "n32" || ABI == "n64")) {
 Diags.Report(diag::err_unsupported_abi_for_opt) << "-mfpxx" << "o32";

diff  --git a/clang/test/Driver/mips-abi.c b/clang/test/Driver/mips-abi.c
index f0f678b42f608..98384ce8b3154 100644
--- a/clang/test/Driver/mips-abi.c
+++ b/clang/test/Driver/mips-abi.c
@@ -9,13 +9,6 @@
 // MIPS32R2-O32: "-target-cpu" "mips32r2"
 // MIPS32R2-O32: "-target-abi" "o32"
 //
-// FIXME: This is a valid combination of options but we reject it at the moment
-//because the backend can't handle it.
-// RUN: not %clang -target mips-linux-gnu -c %s \
-// RUN:-march=mips64r2 -mabi=32 2>&1 \
-// RUN:   | FileCheck -check-prefix=MIPS64R2-O32 %s
-// MIPS64R2-O32: error: ABI 'o32' is not supported on CPU 'mips64r2'
-//
 // RUN: %clang -target mips64-linux-gnu -### -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=MIPS64R2-N64 %s
 // RUN: %clang -target mips-img-linux-gnu -mips64r2 -### -c %s 2>&1 \

diff  --git a/clang/test/Driver/mips-cpu64abi32.c 
b/clang/test/Driver/mips-cpu64abi32.c
new file mode 100644
index 0..d8c8e44f05dae
--- /dev/null
+++ b/clang/test/Driver/mips-cpu64abi32.c
@@ -0,0 +1,68 @@
+/// Check handling the CPU is 64bit while ABI is O32.
+/// when build for MIPS platforms.
+
+/// abi-n32
+// RUN: %clang -### -c %s --target=mips-linux-gnu -mabi=n32 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-ABI-N32 %s
+// CHECK-ABI-N32: "-target-abi" "n32"
+
+/// abi-64
+// RUN: %clang -### -c %s --target=mips-linux-gnu -mabi=64 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-ABI-64 %s
+// CHECK-ABI-64: "-target-abi" "n64"
+
+
+/// -march=mips3
+// RUN: %clang -### -c %s --target=mips-linux-gnu -march=mips3 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-MIPS-MIPS3 %s
+// CHECK-MIPS-MIPS3: "-target-cpu" "mips3" {{.*}} "-target-abi" "o32"
+
+/// -march=mips4
+// RUN: %clang -### -c %s --target=mips-linux-gnu -march=mips4 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-MIPS-MIPS4 %s
+// CHECK-MIPS-MIPS4: "-target-cpu" "mips4" {{.*}} "-target-abi" "o32"
+
+/// FIXME: MIPS V is not implemented yet.
+
+/// -march=mips64
+/// RUN: %clang -### -c %s 

[PATCH] D144509: [CMake] Bumps minimum version to 3.20.0.

2023-05-16 Thread Mike Hommey via Phabricator via cfe-commits
glandium added a comment.

It's related, though, because now that I look at my build logs, the difference 
between when it works and when it doesn't is `/MT` vs `-MD` when compiler-rt is 
compiled. The main peculiarity on our end, though, is that the Windows 
compiler-rt is cross-compiled.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144509

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


[PATCH] D146269: MIPS: allow o32 abi with 64bit CPU and 64 abi with 32bit triple

2023-05-16 Thread YunQiang Su via Phabricator via cfe-commits
wzssyqa added a comment.

In D146269#4347514 , @MaskRay wrote:

> Is this the new GCC behavior?

Marking o32 objects with 64bit CPU is a long history gas behaviour, maybe 
appeared in 1990s, or even in the era of Irix.
I guess the reason is that to achive something like:

  -mabi=32 -march=octeon

`Octeon` is a 64bit CPU.
Since no matter about the -march value, due to all of them are using o32 abi,
they can interlink.
And thus Linux kernel uses this behaviour.

>> `clang -target mipsel-linux-gnu -mabi=64`
>
> Use `--target=`

Done


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

https://reviews.llvm.org/D146269

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


[PATCH] D148723: [clang] Enforce external linkage for inline builtin original declaration

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

Is there some reason we actually need to do this whole dance in C++?  The whole 
point of "inline builtins" was to handle constructs in the glibc headers that 
involve implementations of libc functions that somehow end up recursively 
calling themselves instead of a real implementation.  In C++, you can't get 
away with that sort of thing anyway: the compiler, in general, doesn't discard 
inline functions, so you can't guarantee that an external implementation will 
be used.

So if isInlineBuiltinDeclaration() simply returns false for C++ code, 
everything should just work, without messing with the linkage.


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

https://reviews.llvm.org/D148723

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


[PATCH] D144509: [CMake] Bumps minimum version to 3.20.0.

2023-05-16 Thread Mike Hommey via Phabricator via cfe-commits
glandium added a comment.

In D144509#4347604 , @mstorsjo wrote:

> See D150688  - I believe that might fix the 
> issue you're seeing, as that one mentions compiler-rt.

Unfortunately, it doesn't.

FWIW, the errors looks like:

  lld-link: error: undefined symbol: __declspec(dllimport) _getpid
  >>> referenced by 
clang_rt.profile-i386.lib(InstrProfilingFile.c.obj):(_getCurFilename)
  >>> referenced by 
clang_rt.profile-i386.lib(InstrProfilingFile.c.obj):(_parseAndSetFilename)
  >>> referenced by oldnames.lib(getpid.obi)

etc.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144509

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


[PATCH] D150733: [clang] Convert remaining OpenMP tests to opaque pointers

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

These are the last tests in OpenMP subdirectory.




Comment at: clang/test/OpenMP/target_simd_codegen.cpp:143
 
-  // CHECK:   call void [[HVT1:@.+]](i[[SZ]] {{[^,]+}}, i{{32|64}}{{[*]*}} 
{{[^)]+}})
+  // CHECK:   call void [[HVT1:@.+]](i[[SZ]] {{[^,]+}}, {{[^)]+}})
   long long k = get_val();

Depending on the RUN line, the second argument should match either ptr or an 
integer.
I couldn't invent a better solution than just to remove the check. Hopefully 
this is ok.



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150733

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


[PATCH] D150733: [clang] Convert remaining OpenMP tests to opaque pointers

2023-05-16 Thread Sergei Barannikov via Phabricator via cfe-commits
barannikov88 created this revision.
barannikov88 added a reviewer: nikic.
Herald added subscribers: sunshaoce, StephenFan, guansong, yaxunl.
Herald added a project: All.
barannikov88 requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added subscribers: cfe-commits, jplehr, sstefan1.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D150733

Files:
  clang/test/OpenMP/declare_reduction_codegen.cpp
  clang/test/OpenMP/parallel_for_simd_codegen.cpp
  clang/test/OpenMP/simd_codegen.cpp
  clang/test/OpenMP/target_codegen.cpp
  clang/test/OpenMP/target_data_codegen.cpp
  clang/test/OpenMP/target_enter_data_codegen.cpp
  clang/test/OpenMP/target_enter_data_depend_codegen.cpp
  clang/test/OpenMP/target_exit_data_codegen.cpp
  clang/test/OpenMP/target_exit_data_depend_codegen.cpp
  clang/test/OpenMP/target_in_reduction_codegen.cpp
  clang/test/OpenMP/target_private_codegen.cpp
  clang/test/OpenMP/target_reduction_codegen.cpp
  clang/test/OpenMP/target_simd_codegen.cpp
  clang/test/OpenMP/target_update_depend_codegen.cpp

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


[PATCH] D150694: [clang] Convert NVPTX OpenMP tests to opaque pointers

2023-05-16 Thread Sergei Barannikov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9beb817cc8db: [clang] Convert NVPTX OpenMP tests to opaque 
pointers (authored by barannikov88).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150694

Files:
  clang/test/OpenMP/nvptx_SPMD_codegen.cpp
  clang/test/OpenMP/nvptx_param_translate.c
  clang/test/OpenMP/nvptx_target_firstprivate_codegen.cpp
  clang/test/OpenMP/nvptx_target_parallel_reduction_codegen.cpp
  clang/test/OpenMP/nvptx_unsupported_type_codegen.cpp

___
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-16 Thread Zahira Ammarguellat via Phabricator via cfe-commits
zahiraam added a comment.

@rjmccall Made a bit of progress on this, but still not quite where it should 
be! Would appreciate your feedback/guidance to see that's moving in the right 
direction. Not sure about lazily creating the interesting identifiers? There 
are still some LIT tests failing but will care for those when I get your 
feedback. Thanks.


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-16 Thread Zahira Ammarguellat via Phabricator via cfe-commits
zahiraam updated this revision to Diff 522800.
zahiraam marked an inline comment as done.

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

https://reviews.llvm.org/D146148

Files:
  clang/docs/LanguageExtensions.rst
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/Builtins.def
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/IdentifierTable.h
  clang/include/clang/Basic/TokenKinds.def
  clang/include/clang/Basic/TokenKinds.h
  clang/lib/Basic/Builtins.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaLookup.cpp
  clang/test/Sema/abi-check-1.cpp
  clang/test/Sema/abi-check-2.cpp
  clang/test/Sema/abi-check-3.cpp
  clang/test/Sema/attr-only-in-default-eval.cpp

Index: clang/test/Sema/attr-only-in-default-eval.cpp
===
--- /dev/null
+++ clang/test/Sema/attr-only-in-default-eval.cpp
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+typedef float float_t [[clang::available_only_in_default_eval_method]];
+using double_t __attribute__((available_only_in_default_eval_method)) = double;
+
+// expected-error@+1{{'available_only_in_default_eval_method' attribute only applies to typedefs}}
+class  __attribute__((available_only_in_default_eval_method)) C1 {
+};
+// expected-error@+1{{'available_only_in_default_eval_method' attribute only applies to typedefs}}
+class  [[clang::available_only_in_default_eval_method]] C2 {
+};
+
+// expected-error@+1{{'available_only_in_default_eval_method' attribute only applies to typedefs}}
+struct [[clang::available_only_in_default_eval_method]] S1;
+// expected-error@+1{{'available_only_in_default_eval_method' attribute only applies to typedefs}}
+struct __attribute__((available_only_in_default_eval_method)) S2;
+
+// expected-error@+1{{'available_only_in_default_eval_method' attribute only applies to typedefs}}
+void __attribute__((available_only_in_default_eval_method)) foo();
+// expected-error@+1{{'available_only_in_default_eval_method' attribute cannot be applied to types}}
+void [[clang::available_only_in_default_eval_method]] goo();
+// expected-error@+1{{'available_only_in_default_eval_method' attribute cannot be applied to types}}
+void bar() [[clang::available_only_in_default_eval_method]];
+// expected-error@+1{{'available_only_in_default_eval_method' attribute only applies to typedefs}}
+void barz() __attribute__((available_only_in_default_eval_method));
+
Index: clang/test/Sema/abi-check-3.cpp
===
--- /dev/null
+++ clang/test/Sema/abi-check-3.cpp
@@ -0,0 +1,86 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -DNOERROR %s
+// RUN: %clang_cc1 -fsyntax-only -verify -ffp-eval-method=extended -DNOERROR %s
+
+// RUN: %clang_cc1 -verify -fsyntax-only -ffp-eval-method=source %s
+// RUN: %clang_cc1 -verify -fsyntax-only -ffp-eval-method=double %s
+
+
+#ifdef NOERROR
+// expected-no-diagnostics
+typedef float float_t;
+typedef double double_t;
+#else
+typedef float float_t; //expected-error 9 {{cannot use type 'float_t' within '#pragma clang fp eval_method'; type is set according to the default eval method for the translation unit}}
+
+typedef double double_t; //expected-error 9 {{cannot use type 'double_t' within '#pragma clang fp eval_method'; type is set according to the default eval method for the translation unit}}
+#endif
+
+float foo1() {
+#pragma clang fp eval_method(extended)
+  float a;
+  double b;
+  return a - b;
+}
+
+float foo2() {
+#pragma clang fp eval_method(extended)
+  float_t a; 
+  double_t b; 
+  return a - b;
+}
+
+void foo3() {
+#pragma clang fp eval_method(extended)
+  char buff[sizeof(float_t)];
+  char bufd[sizeof(double_t)];
+  buff[1] = bufd[2];
+}
+
+float foo4() {
+#pragma clang fp eval_method(extended)
+  typedef float_t FT;
+  typedef double_t DT;
+  FT a;
+  DT b;
+  return a - b;
+}
+
+int foo5() {
+#pragma clang fp eval_method(extended)
+  int t = _Generic( 1.0L, float_t:1, default:0);
+  int v = _Generic( 1.0L, double_t:1, default:0);
+  return t;
+}
+
+void foo6() {
+#pragma clang fp eval_method(extended)
+  auto resf = [](float_t f) { return f; };
+  auto resd = [](double_t g) { return g; };
+}
+
+void foo7() {
+#pragma clang fp eval_method(extended)
+  float f = (float_t)1; 
+  double d = (double_t)2; 
+}
+
+void foo8() {
+#pragma clang fp eval_method(extended)
+  using Ft = float_t;
+  using Dt = double_t;
+  Ft a;
+  Dt b;
+}
+
+void foo9() {
+#pragma clang fp eval_method(extended)
+  float c1 = (float_t)12;
+  double c2 = (double_t)13;
+}
+
+float foo10() {
+#pragma clang fp eval_method(extended)
+  extern float_t f;
+  extern double_t g;
+  return f-g;
+}
Index: clang/test/Sema/abi-check-2.cpp
===
--- /dev/null
+++ clang/test/Sema/abi-check-2.cpp
@@ -0,0 +1,85 @@
+// RUN: %clang_cc1 -fsyntax-only -verify 

[PATCH] D150411: [NFC][Clang][Coverity] Fix Static Code Analysis Concerns with copy without assign

2023-05-16 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 added a few comments and suggested edits, but this is mostly looking good.




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





Comment at: clang/include/clang/Sema/Sema.h:1789-1791
+SemaDiagnosticBuilder =(SemaDiagnosticBuilder &) = delete;
 SemaDiagnosticBuilder(const SemaDiagnosticBuilder &) = default;
+SemaDiagnosticBuilder =(const SemaDiagnosticBuilder &) = delete;

aaronpuchert wrote:
> Manna wrote:
> > @tahonermann This is follow-up comments from 
> > https://reviews.llvm.org/D149718?id=519331#inline-1452044. 
> > 
> > >>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.
> > 
> > I tried to define move assignment operator in ` clang/lib/Sema/Sema.cpp` 
> > but it failed because class Sema has deleted implicit copy assignment 
> > operator.
> > 
> > ```
> > /// Sema - This implements semantic analysis and AST building for C.
> > class Sema final {
> >   Sema(const Sema &) = delete;
> >   void operator=(const Sema &) = delete;
> > ```
> > It seems like support for assignment is not desired, We probably need 
> > deleted copy/move assignment operator.
> > 
> These are also implicitly deleted. Some code styles want this explicitly 
> spelled out, but I don't think ours does.
> I tried to define move assignment operator in  clang/lib/Sema/Sema.cpp but it 
> failed because class Sema has deleted implicit copy assignment operator.

It is still permissible to define a move assignment operator if the implicit 
copy assignment operator is deleted. See https://godbolt.org/z/sGaWd9M44.

I think it is fine to disable support for assignment for this class pending use 
cases. But, since a move constructor is explicitly defined, we should also be 
explicit above move assignment. I added a suggested edit. Without that change, 
I think Coverity will continue to complain.



Comment at: 
clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h:54
   BugReporterVisitor(BugReporterVisitor &&) {}
+  BugReporterVisitor =(const BugReporterVisitor &) = delete;
   virtual ~BugReporterVisitor();

Here too; since a user-defined move constructor is declared, let's be explicit 
about move assignment.



Comment at: clang/lib/CodeGen/CGDebugInfo.h:833-837
+  ApplyDebugLocation =(ApplyDebugLocation &) {
+CGF = Other.CGF;
+Other.CGF = nullptr;
+return *this;
+  }

Good catch! Since the destructor uses `CGF`, the defaulted move assignment 
operator was wrong!



Comment at: clang/lib/CodeGen/EHScopeStack.h:151
 Cleanup(Cleanup &&) {}
+Cleanup =(const Cleanup &) = delete;
 Cleanup() = default;

Here too; since a user-declared move constructor is present, let's be explicit 
about support for move assignment.


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

https://reviews.llvm.org/D150411

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


[PATCH] D150730: [Clang][Sema] Substitute constraints only for declarations with different lexical contexts

2023-05-16 Thread Alexander Shaposhnikov via Phabricator via cfe-commits
alexander-shaposhnikov created this revision.
alexander-shaposhnikov added a reviewer: erichkeane.
alexander-shaposhnikov created this object with visibility "All Users".
Herald added a project: All.
alexander-shaposhnikov requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Substitute constraints only for declarations with different lexical contexts.
This results in avoiding the substitution of constraints during the 
redeclaration check inside a class (and by product caching the wrong 
substitution result).

Test plan: ninja check-all


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D150730

Files:
  clang/lib/Sema/SemaConcept.cpp
  clang/test/SemaTemplate/concepts-no-early-substitution.cpp


Index: clang/test/SemaTemplate/concepts-no-early-substitution.cpp
===
--- /dev/null
+++ clang/test/SemaTemplate/concepts-no-early-substitution.cpp
@@ -0,0 +1,33 @@
+// RUN: %clang_cc1 -std=c++20 -x c++ %s -verify -fsyntax-only
+// expected-no-diagnostics
+
+template 
+concept HasMemberBegin = requires(T0 t) { t.begin(); };
+
+struct GetBegin {
+  template 
+  void operator()(T1);
+};
+
+GetBegin begin;
+
+template 
+concept Concept = requires(T2 t) { begin(t); };
+
+struct Subrange;
+
+template 
+struct View {
+  Subrange ();
+
+  operator bool()
+requires true;
+
+  operator bool()
+requires requires { begin(getSubrange()); };
+
+  void begin();
+};
+
+struct Subrange : View {};
+static_assert(Concept);
Index: clang/lib/Sema/SemaConcept.cpp
===
--- clang/lib/Sema/SemaConcept.cpp
+++ clang/lib/Sema/SemaConcept.cpp
@@ -780,7 +780,8 @@
  const Expr *NewConstr) {
   if (OldConstr == NewConstr)
 return true;
-  if (Old && New && Old != New) {
+  if (Old && New && Old != New &&
+  Old->getLexicalDeclContext() != New->getLexicalDeclContext()) {
 if (const Expr *SubstConstr =
 SubstituteConstraintExpression(*this, Old, OldConstr))
   OldConstr = SubstConstr;


Index: clang/test/SemaTemplate/concepts-no-early-substitution.cpp
===
--- /dev/null
+++ clang/test/SemaTemplate/concepts-no-early-substitution.cpp
@@ -0,0 +1,33 @@
+// RUN: %clang_cc1 -std=c++20 -x c++ %s -verify -fsyntax-only
+// expected-no-diagnostics
+
+template 
+concept HasMemberBegin = requires(T0 t) { t.begin(); };
+
+struct GetBegin {
+  template 
+  void operator()(T1);
+};
+
+GetBegin begin;
+
+template 
+concept Concept = requires(T2 t) { begin(t); };
+
+struct Subrange;
+
+template 
+struct View {
+  Subrange ();
+
+  operator bool()
+requires true;
+
+  operator bool()
+requires requires { begin(getSubrange()); };
+
+  void begin();
+};
+
+struct Subrange : View {};
+static_assert(Concept);
Index: clang/lib/Sema/SemaConcept.cpp
===
--- clang/lib/Sema/SemaConcept.cpp
+++ clang/lib/Sema/SemaConcept.cpp
@@ -780,7 +780,8 @@
  const Expr *NewConstr) {
   if (OldConstr == NewConstr)
 return true;
-  if (Old && New && Old != New) {
+  if (Old && New && Old != New &&
+  Old->getLexicalDeclContext() != New->getLexicalDeclContext()) {
 if (const Expr *SubstConstr =
 SubstituteConstraintExpression(*this, Old, OldConstr))
   OldConstr = SubstConstr;
___
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-16 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

> This is an adaptation of the IBM XL compiler's -qstatsym option, which is 
> meant to generate symbol table entries for static variables. An artifact of 
> that compiler is that static variables are often not discarded even when 
> unused.

Oh, I see; the compiler actually doesn't guarantee that the variables are 
preserved, it just ends up preserving them by accident because it's bad at 
optimizing global variables?

Do you have any idea how widespread this is?


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] D124642: [WIP] Add support for return from an SEH __finally block.

2023-05-16 Thread Eli Friedman via Phabricator via cfe-commits
efriedma updated this revision to Diff 522782.
efriedma added a comment.

Fixup a couple LLVM tests which are failing; I think they're affected by the 
WinException.cpp changes?  Maybe need to look a bit more closely to see if the 
changes make sense.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124642

Files:
  clang/lib/CodeGen/CGException.cpp
  clang/lib/CodeGen/CGStmt.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/Sema/SemaStmt.cpp
  clang/test/CodeGen/exceptions-seh-finally.c
  clang/test/CodeGen/exceptions-seh-leave.c
  clang/test/CodeGen/windows-seh-return-finally.c
  llvm/include/llvm/IR/Intrinsics.td
  llvm/lib/CodeGen/AsmPrinter/WinException.cpp
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
  llvm/lib/CodeGen/WinEHPrepare.cpp
  llvm/lib/IR/Verifier.cpp
  llvm/test/CodeGen/X86/seh-catchpad.ll
  llvm/test/CodeGen/X86/seh-return-from-finally.ll
  llvm/test/CodeGen/X86/seh-safe-div.ll
  llvm/utils/UpdateTestChecks/common.py

Index: llvm/utils/UpdateTestChecks/common.py
===
--- llvm/utils/UpdateTestChecks/common.py
+++ llvm/utils/UpdateTestChecks/common.py
@@ -353,7 +353,7 @@
 UNUSED_NOTE = 'NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line:'
 
 OPT_FUNCTION_RE = re.compile(
-r'^(\s*;\s*Function\sAttrs:\s(?P[\w\s():,]+?))?\s*define\s+(?P[^@]*)@(?P[\w.$-]+?)\s*'
+r'^(\s*;\s*Function\sAttrs:\s(?P[\w\s():,]+?))?\s*define\s+(?P[^@]*)@(?P([\w.$-]+?|"[\w.$-?@]+?"))\s*'
 r'(?P\((\)|(.*?[\w.-]+?)\))[^{]*\{)\n(?P.*?)^\}$',
 flags=(re.M | re.S))
 
Index: llvm/test/CodeGen/X86/seh-safe-div.ll
===
--- llvm/test/CodeGen/X86/seh-safe-div.ll
+++ llvm/test/CodeGen/X86/seh-safe-div.ll
@@ -89,6 +89,10 @@
 ; CHECK-NEXT: .long .Ltmp1@IMGREL+1
 ; CHECK-NEXT: .long safe_div_filt1@IMGREL
 ; CHECK-NEXT: .long [[handler1]]@IMGREL
+; CHECK-NEXT: .long .LBB0_1@IMGREL
+; CHECK-NEXT: .long .LBB0_1@IMGREL+1
+; CHECK-NEXT: .long safe_div_filt1@IMGREL
+; CHECK-NEXT: .long .LBB0_2@IMGREL
 ; CHECK-NEXT: .Llsda_end0:
 ; CHECK: .text
 ; CHECK: .seh_endproc
Index: llvm/test/CodeGen/X86/seh-return-from-finally.ll
===
--- /dev/null
+++ llvm/test/CodeGen/X86/seh-return-from-finally.ll
@@ -0,0 +1,237 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --include-generated-funcs --version 2
+; RUN: llc < %s | FileCheck %s
+target triple = "x86_64-unknown-windows-msvc19.20.0"
+
+; Function Attrs: noinline nounwind optnone uwtable
+define dso_local void @f(i32 noundef %z) #0 personality ptr @__C_specific_handler {
+entry:
+  %z.addr = alloca i32, align 4
+  %retnow = alloca i8, align 1
+  call void (...) @llvm.localescape(ptr %z.addr, ptr %retnow)
+  store i32 %z, ptr %z.addr, align 4
+  store i8 0, ptr %retnow, align 1
+  invoke void @f1() #6
+  to label %invoke.cont unwind label %ehcleanup
+
+invoke.cont:  ; preds = %entry
+  %0 = call ptr @llvm.localaddress()
+  invoke void @"?fin$0@0@f@@"(i8 noundef 0, ptr noundef %0)
+  to label %invoke.cont1 unwind label %catch.dispatch
+
+invoke.cont1: ; preds = %invoke.cont
+  br label %__finally.cont
+
+__finally.cont:   ; preds = %invoke.cont1
+  %1 = load i8, ptr %retnow, align 1
+  %2 = icmp ne i8 %1, 0
+  br i1 %2, label %if.then4, label %if.end5
+
+ehcleanup:; preds = %entry
+  %3 = cleanuppad within none []
+  %4 = call ptr @llvm.localaddress()
+  invoke void @"?fin$0@0@f@@"(i8 noundef 1, ptr noundef %4) [ "funclet"(token %3) ]
+  to label %invoke.cont2 unwind label %catch.dispatch
+
+invoke.cont2: ; preds = %ehcleanup
+  %5 = load i8, ptr %retnow, align 1
+  %6 = icmp ne i8 %5, 0
+  br i1 %6, label %if.then, label %if.end
+
+if.then:  ; preds = %invoke.cont2
+  invoke void @llvm.seh.localunwind()
+  to label %invoke.cont3 unwind label %catch.dispatch
+
+invoke.cont3: ; preds = %if.then
+  unreachable
+
+if.end:   ; preds = %invoke.cont2
+  cleanupret from %3 unwind label %catch.dispatch
+
+catch.dispatch:   ; preds = %if.end, %if.then, %ehcleanup, %invoke.cont
+  %7 = catchswitch within none [label %__except.ret] unwind to caller
+
+__except.ret: ; preds = %catch.dispatch
+  %8 = catchpad within %7 [ptr @__IsLocalUnwind]
+  catchret from %8 to label %if.then4
+
+if.then4: ; preds = %__except.ret, %__finally.cont
+  br label %if.end5
+
+if.end5: 

[PATCH] D150723: clang/openmp: Fix alignment for ThreadID Address variables

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

Needs test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150723

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


[PATCH] D150723: clang/openmp: Fix alignment for ThreadID Address variables

2023-05-16 Thread Tom Stellard via Phabricator via cfe-commits
tstellar created this revision.
tstellar added a reviewer: jlpeyton.
Herald added subscribers: sunshaoce, guansong, yaxunl.
Herald added a project: All.
tstellar requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added subscribers: cfe-commits, jplehr, sstefan1.
Herald added a project: clang.

There are places in the runtime, like __kmp_init_indirect_csptr, which
assume these pointers are aligned to sizeof(void*), so make sure we emit
them with the correct alignment.

Fixes #62668


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D150723

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp


Index: clang/lib/CodeGen/CGOpenMPRuntime.cpp
===
--- clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -2143,7 +2143,11 @@
 llvm::Value *CGOpenMPRuntime::getCriticalRegionLock(StringRef CriticalName) {
   std::string Prefix = Twine("gomp_critical_user_", CriticalName).str();
   std::string Name = getName({Prefix, "var"});
-  return OMPBuilder.getOrCreateInternalVariable(KmpCriticalNameTy, Name);
+  llvm::GlobalVariable *G = 
OMPBuilder.getOrCreateInternalVariable(KmpCriticalNameTy, Name);
+  llvm::Align PtrAlign = 
OMPBuilder.M.getDataLayout().getPointerABIAlignment(G->getAddressSpace());
+  if (PtrAlign > llvm::Align(G->getAlignment()))
+G->setAlignment(PtrAlign);
+  return G;
 }
 
 namespace {


Index: clang/lib/CodeGen/CGOpenMPRuntime.cpp
===
--- clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -2143,7 +2143,11 @@
 llvm::Value *CGOpenMPRuntime::getCriticalRegionLock(StringRef CriticalName) {
   std::string Prefix = Twine("gomp_critical_user_", CriticalName).str();
   std::string Name = getName({Prefix, "var"});
-  return OMPBuilder.getOrCreateInternalVariable(KmpCriticalNameTy, Name);
+  llvm::GlobalVariable *G = OMPBuilder.getOrCreateInternalVariable(KmpCriticalNameTy, Name);
+  llvm::Align PtrAlign = OMPBuilder.M.getDataLayout().getPointerABIAlignment(G->getAddressSpace());
+  if (PtrAlign > llvm::Align(G->getAlignment()))
+G->setAlignment(PtrAlign);
+  return G;
 }
 
 namespace {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D150629: [clang-format] Don't allow template to be preceded by closing brace

2023-05-16 Thread Emilia Kond via Phabricator via cfe-commits
rymiel updated this revision to Diff 522776.
rymiel added a comment.

Add annotator tests


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150629

Files:
  clang/lib/Format/TokenAnnotator.cpp
  clang/unittests/Format/FormatTest.cpp
  clang/unittests/Format/TokenAnnotatorTest.cpp


Index: clang/unittests/Format/TokenAnnotatorTest.cpp
===
--- clang/unittests/Format/TokenAnnotatorTest.cpp
+++ clang/unittests/Format/TokenAnnotatorTest.cpp
@@ -480,6 +480,23 @@
   EXPECT_TOKEN(Tokens[8], tok::greater, TT_BinaryOperator);
 }
 
+TEST_F(TokenAnnotatorTest, UnderstandsNonTemplateAngleBrackets) {
+  auto Tokens = annotate("return a < b && c > d;");
+  ASSERT_EQ(Tokens.size(), 10u) << Tokens;
+  EXPECT_TOKEN(Tokens[2], tok::less, TT_BinaryOperator);
+  EXPECT_TOKEN(Tokens[6], tok::greater, TT_BinaryOperator);
+
+  Tokens = annotate("a < 0 ? b : a > 0 ? c : d;");
+  ASSERT_EQ(Tokens.size(), 15u) << Tokens;
+  EXPECT_TOKEN(Tokens[1], tok::less, TT_BinaryOperator);
+  EXPECT_TOKEN(Tokens[7], tok::greater, TT_BinaryOperator);
+
+  Tokens = annotate("ratio{-1, 2} < ratio{-1, 3} == -1 / 3 > -1 / 2;");
+  ASSERT_EQ(Tokens.size(), 27u) << Tokens;
+  EXPECT_TOKEN(Tokens[7], tok::less, TT_BinaryOperator);
+  EXPECT_TOKEN(Tokens[20], tok::greater, TT_BinaryOperator);
+}
+
 TEST_F(TokenAnnotatorTest, UnderstandsWhitespaceSensitiveMacros) {
   FormatStyle Style = getLLVMStyle();
   Style.WhitespaceSensitiveMacros.push_back("FOO");
Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -10679,6 +10679,7 @@
   // Not template parameters.
   verifyFormat("return a < b && c > d;");
   verifyFormat("a < 0 ? b : a > 0 ? c : d;");
+  verifyFormat("ratio{-1, 2} < ratio{-1, 3} == -1 / 3 > -1 / 2;");
   verifyFormat("void f() {\n"
"  while (a < b && c > d) {\n"
"  }\n"
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -144,6 +144,8 @@
 if (Previous.Previous) {
   if (Previous.Previous->Tok.isLiteral())
 return false;
+  if (Previous.Previous->is(tok::r_brace))
+return false;
   if (Previous.Previous->is(tok::r_paren) && Contexts.size() > 1 &&
   (!Previous.Previous->MatchingParen ||
!Previous.Previous->MatchingParen->is(


Index: clang/unittests/Format/TokenAnnotatorTest.cpp
===
--- clang/unittests/Format/TokenAnnotatorTest.cpp
+++ clang/unittests/Format/TokenAnnotatorTest.cpp
@@ -480,6 +480,23 @@
   EXPECT_TOKEN(Tokens[8], tok::greater, TT_BinaryOperator);
 }
 
+TEST_F(TokenAnnotatorTest, UnderstandsNonTemplateAngleBrackets) {
+  auto Tokens = annotate("return a < b && c > d;");
+  ASSERT_EQ(Tokens.size(), 10u) << Tokens;
+  EXPECT_TOKEN(Tokens[2], tok::less, TT_BinaryOperator);
+  EXPECT_TOKEN(Tokens[6], tok::greater, TT_BinaryOperator);
+
+  Tokens = annotate("a < 0 ? b : a > 0 ? c : d;");
+  ASSERT_EQ(Tokens.size(), 15u) << Tokens;
+  EXPECT_TOKEN(Tokens[1], tok::less, TT_BinaryOperator);
+  EXPECT_TOKEN(Tokens[7], tok::greater, TT_BinaryOperator);
+
+  Tokens = annotate("ratio{-1, 2} < ratio{-1, 3} == -1 / 3 > -1 / 2;");
+  ASSERT_EQ(Tokens.size(), 27u) << Tokens;
+  EXPECT_TOKEN(Tokens[7], tok::less, TT_BinaryOperator);
+  EXPECT_TOKEN(Tokens[20], tok::greater, TT_BinaryOperator);
+}
+
 TEST_F(TokenAnnotatorTest, UnderstandsWhitespaceSensitiveMacros) {
   FormatStyle Style = getLLVMStyle();
   Style.WhitespaceSensitiveMacros.push_back("FOO");
Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -10679,6 +10679,7 @@
   // Not template parameters.
   verifyFormat("return a < b && c > d;");
   verifyFormat("a < 0 ? b : a > 0 ? c : d;");
+  verifyFormat("ratio{-1, 2} < ratio{-1, 3} == -1 / 3 > -1 / 2;");
   verifyFormat("void f() {\n"
"  while (a < b && c > d) {\n"
"  }\n"
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -144,6 +144,8 @@
 if (Previous.Previous) {
   if (Previous.Previous->Tok.isLiteral())
 return false;
+  if (Previous.Previous->is(tok::r_brace))
+return false;
   if (Previous.Previous->is(tok::r_paren) && Contexts.size() > 1 &&
   (!Previous.Previous->MatchingParen ||
!Previous.Previous->MatchingParen->is(
___
cfe-commits mailing 

[PATCH] D124642: [WIP] Add support for return from an SEH __finally block.

2023-05-16 Thread Eli Friedman via Phabricator via cfe-commits
efriedma updated this revision to Diff 522773.
efriedma added a comment.
Herald added a subscriber: arichardson.

Rebased so it builds, and added a couple tests, to unblock anyone wanting to 
look at this further.  Haven't re-done my runtime testing.  Still haven't 
addressed all the review comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124642

Files:
  clang/lib/CodeGen/CGException.cpp
  clang/lib/CodeGen/CGStmt.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/Sema/SemaStmt.cpp
  clang/test/CodeGen/exceptions-seh-finally.c
  clang/test/CodeGen/exceptions-seh-leave.c
  clang/test/CodeGen/windows-seh-return-finally.c
  llvm/include/llvm/IR/Intrinsics.td
  llvm/lib/CodeGen/AsmPrinter/WinException.cpp
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
  llvm/lib/CodeGen/WinEHPrepare.cpp
  llvm/lib/IR/Verifier.cpp
  llvm/test/CodeGen/X86/seh-return-from-finally.ll
  llvm/utils/UpdateTestChecks/common.py

Index: llvm/utils/UpdateTestChecks/common.py
===
--- llvm/utils/UpdateTestChecks/common.py
+++ llvm/utils/UpdateTestChecks/common.py
@@ -353,7 +353,7 @@
 UNUSED_NOTE = 'NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line:'
 
 OPT_FUNCTION_RE = re.compile(
-r'^(\s*;\s*Function\sAttrs:\s(?P[\w\s():,]+?))?\s*define\s+(?P[^@]*)@(?P[\w.$-]+?)\s*'
+r'^(\s*;\s*Function\sAttrs:\s(?P[\w\s():,]+?))?\s*define\s+(?P[^@]*)@(?P([\w.$-]+?|"[\w.$-?@]+?"))\s*'
 r'(?P\((\)|(.*?[\w.-]+?)\))[^{]*\{)\n(?P.*?)^\}$',
 flags=(re.M | re.S))
 
Index: llvm/test/CodeGen/X86/seh-return-from-finally.ll
===
--- /dev/null
+++ llvm/test/CodeGen/X86/seh-return-from-finally.ll
@@ -0,0 +1,237 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --include-generated-funcs --version 2
+; RUN: llc < %s | FileCheck %s
+target triple = "x86_64-unknown-windows-msvc19.20.0"
+
+; Function Attrs: noinline nounwind optnone uwtable
+define dso_local void @f(i32 noundef %z) #0 personality ptr @__C_specific_handler {
+entry:
+  %z.addr = alloca i32, align 4
+  %retnow = alloca i8, align 1
+  call void (...) @llvm.localescape(ptr %z.addr, ptr %retnow)
+  store i32 %z, ptr %z.addr, align 4
+  store i8 0, ptr %retnow, align 1
+  invoke void @f1() #6
+  to label %invoke.cont unwind label %ehcleanup
+
+invoke.cont:  ; preds = %entry
+  %0 = call ptr @llvm.localaddress()
+  invoke void @"?fin$0@0@f@@"(i8 noundef 0, ptr noundef %0)
+  to label %invoke.cont1 unwind label %catch.dispatch
+
+invoke.cont1: ; preds = %invoke.cont
+  br label %__finally.cont
+
+__finally.cont:   ; preds = %invoke.cont1
+  %1 = load i8, ptr %retnow, align 1
+  %2 = icmp ne i8 %1, 0
+  br i1 %2, label %if.then4, label %if.end5
+
+ehcleanup:; preds = %entry
+  %3 = cleanuppad within none []
+  %4 = call ptr @llvm.localaddress()
+  invoke void @"?fin$0@0@f@@"(i8 noundef 1, ptr noundef %4) [ "funclet"(token %3) ]
+  to label %invoke.cont2 unwind label %catch.dispatch
+
+invoke.cont2: ; preds = %ehcleanup
+  %5 = load i8, ptr %retnow, align 1
+  %6 = icmp ne i8 %5, 0
+  br i1 %6, label %if.then, label %if.end
+
+if.then:  ; preds = %invoke.cont2
+  invoke void @llvm.seh.localunwind()
+  to label %invoke.cont3 unwind label %catch.dispatch
+
+invoke.cont3: ; preds = %if.then
+  unreachable
+
+if.end:   ; preds = %invoke.cont2
+  cleanupret from %3 unwind label %catch.dispatch
+
+catch.dispatch:   ; preds = %if.end, %if.then, %ehcleanup, %invoke.cont
+  %7 = catchswitch within none [label %__except.ret] unwind to caller
+
+__except.ret: ; preds = %catch.dispatch
+  %8 = catchpad within %7 [ptr @__IsLocalUnwind]
+  catchret from %8 to label %if.then4
+
+if.then4: ; preds = %__except.ret, %__finally.cont
+  br label %if.end5
+
+if.end5:  ; preds = %if.then4, %__finally.cont
+  ret void
+}
+
+declare extern_weak void @__IsLocalUnwind(ptr, ptr)
+
+; Function Attrs: noinline nounwind uwtable
+define internal void @"?fin$0@0@f@@"(i8 noundef %abnormal_termination, ptr noundef %frame_pointer) #1 {
+entry:
+  %frame_pointer.addr = alloca ptr, align 8
+  %abnormal_termination.addr = alloca i8, align 1
+  %z.addr = call ptr @llvm.localrecover(ptr @f, ptr %frame_pointer, i32 0)
+  %retnow = call ptr @llvm.localrecover(ptr @f, ptr %frame_pointer, i32 1)
+  store ptr %frame_pointer, ptr %frame_pointer.addr, align 8

[PATCH] D124642: [WIP] Add support for return from an SEH __finally block.

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



Comment at: clang/lib/CodeGen/CGException.cpp:1833
+/// Find all local variable captures in the statement.
+struct ReturnStmtFinder : ConstStmtVisitor {
+  bool ContainsRetStmt = false;

rnk wrote:
> We have the option to generalize the naming here to include other kinds of 
> jumps that exit the scope of the finally. I think it's worth implementing 
> `__leave` eventually, which I think users have asked for at some point. I 
> could go either way, your choice.
Probably better to rename once we actually implement that?  I'm intentionally 
not trying to detect other forms of control flow because EnterSEHTryStmt only 
knows how to return from the function.  If we're going to branch elsewhere, we 
need to return a list of the destinations, not just a boolean "there's a return 
statement".



Comment at: llvm/lib/CodeGen/AsmPrinter/WinException.cpp:631-634
+  // Mark up the destination of _local_unwind so it doesn't unwind
+  // too far.
+  //
+  // FIXME: Can this overlap with the EH_LABEL for an invoke?

rnk wrote:
> I don't understand what this is doing, but I should look at the tests.
I don't remember all the details of this, but as I noted in the commit message, 
it affects nesting `__try`/`__finally` in `__try`.  I think without this, the 
destination of the `_local_unwind` somehow ended up inheriting an unrelated SEH 
state.



Comment at: llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp:2942
+  if (!isa(EHPadBB->getTerminator())) {
+report_fatal_error("localunwind doesn't point to catchswitch");
+  }

rnk wrote:
> Since this isn't verifier checked yet, is it possible to emit a diagnostic 
> via the LLVMContext and select this instruction to nothing, or would that 
> leave behind disconnected unreachable MBBs that break too many invariants 
> later?
I can't find any other code trying to report diagnostics that way, but I guess 
I can look into it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124642

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


[PATCH] D150394: [OpenMP 5.2] Deprecate MINUS (-) operator on reduction clauses

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



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:10490
+def warn_omp_minus_in_reduction_deprecated : Warning<
+  "minus(-) operator for reductions is deprecated; use an user defined 
reduction instead">,
+  InGroup;

mdfazlay wrote:
> ABataev wrote:
> > `use + or user defined reudction instead`? And better make it a fixme note.
> @ABataev, Do you want me to add a warning and a note at the same location? Or 
> Changing the warning message to `minus(-) operator for reductions is 
> deprecated; use + or user defined reduction instead` is just fine? Please let 
> me know which one you prefer.
Would be good to have both. But since it is a temp warning, I'm fine with your 
message


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150394

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


[PATCH] D150718: [CUDA] Relax restrictions on GPU-side variadic functions

2023-05-16 Thread Artem Belevich via Phabricator via cfe-commits
tra created this revision.
Herald added subscribers: mattd, carlosgalvezp, bixia, yaxunl.
Herald added a project: All.
tra added reviewers: jlebar, yaxunl.
tra published this revision for review.
Herald added subscribers: cfe-commits, MaskRay.
Herald added a project: clang.

Allow parsing GPU-side variadic functions when we're compiling with CUDA-9 or
newer. We still do not allow accessing variadic arguments.

CUDA-9 was the version which introduced PTX-6.0 which allows implementing
variadic functions, so older versions can't have variadics in principle.

This is required for dealing with headers in recent CUDA versions that rely on
variadic function declarations in some of the templated code in libcu++.
E.g. https://github.com/llvm/llvm-project/issues/58410


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D150718

Files:
  clang/lib/Driver/ToolChains/Cuda.cpp


Index: clang/lib/Driver/ToolChains/Cuda.cpp
===
--- clang/lib/Driver/ToolChains/Cuda.cpp
+++ clang/lib/Driver/ToolChains/Cuda.cpp
@@ -800,6 +800,13 @@
 if (DriverArgs.hasFlag(options::OPT_fcuda_approx_transcendentals,
options::OPT_fno_cuda_approx_transcendentals, 
false))
   CC1Args.push_back("-fcuda-approx-transcendentals");
+
+// Unsized function arguments used for variadics were introduced in 
CUDA-9.0
+// We still do not support generating code that actually uses variadic
+// arguments yet, but we do need to allow parsing them as recent CUDA
+// headers rely on that. https://github.com/llvm/llvm-project/issues/58410
+if (CudaInstallation.version() >= CudaVersion::CUDA_90)
+  CC1Args.push_back("-fcuda-allow-variadic-functions");
   }
 
   if (DriverArgs.hasArg(options::OPT_nogpulib))


Index: clang/lib/Driver/ToolChains/Cuda.cpp
===
--- clang/lib/Driver/ToolChains/Cuda.cpp
+++ clang/lib/Driver/ToolChains/Cuda.cpp
@@ -800,6 +800,13 @@
 if (DriverArgs.hasFlag(options::OPT_fcuda_approx_transcendentals,
options::OPT_fno_cuda_approx_transcendentals, false))
   CC1Args.push_back("-fcuda-approx-transcendentals");
+
+// Unsized function arguments used for variadics were introduced in CUDA-9.0
+// We still do not support generating code that actually uses variadic
+// arguments yet, but we do need to allow parsing them as recent CUDA
+// headers rely on that. https://github.com/llvm/llvm-project/issues/58410
+if (CudaInstallation.version() >= CudaVersion::CUDA_90)
+  CC1Args.push_back("-fcuda-allow-variadic-functions");
   }
 
   if (DriverArgs.hasArg(options::OPT_nogpulib))
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D144509: [CMake] Bumps minimum version to 3.20.0.

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

In D144509#4347562 , @glandium wrote:

> FYI, 65429b9af6a2c99d340ab2dcddd41dab201f399c 
>  is 
> causing problems on Windows compiler-rt for some reason I haven't identified 
> yet (with cmake 3.25.1). Which suggests for a same version of cmake, this is 
> actually altering its behavior, which I wouldn't have expected...

See D150688  - I believe that might fix the 
issue you're seeing, as that one mentions compiler-rt.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144509

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


[PATCH] D144509: [CMake] Bumps minimum version to 3.20.0.

2023-05-16 Thread Mike Hommey via Phabricator via cfe-commits
glandium added a comment.
Herald added subscribers: bviyer, ekilmer, jplehr.

FYI, 65429b9af6a2c99d340ab2dcddd41dab201f399c 
 is 
causing problems on Windows compiler-rt for some reason I haven't identified 
yet (with cmake 3.25.1). Which suggests for a same version of cmake, this is 
actually altering its behavior, which I wouldn't have expected...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144509

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


[PATCH] D150539: [clang-format] Handle ud suffixes in IntegerLiteralSeparator

2023-05-16 Thread Owen Pan via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa72b064acf95: [clang-format] Handle chrono ud 
suffixes in IntegerLiteralSeparator (authored by owenpan).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150539

Files:
  clang/lib/Format/IntegerLiteralSeparatorFixer.cpp
  clang/unittests/Format/IntegerLiteralSeparatorTest.cpp


Index: clang/unittests/Format/IntegerLiteralSeparatorTest.cpp
===
--- clang/unittests/Format/IntegerLiteralSeparatorTest.cpp
+++ clang/unittests/Format/IntegerLiteralSeparatorTest.cpp
@@ -60,6 +60,24 @@
"hil = 0xABCil;",
Style);
 
+  verifyFormat("bd = 0b1'd;\n"
+   "dh = 1'234h;\n"
+   "dmin = 1'234min;\n"
+   "dns = 1'234ns;\n"
+   "ds = 1'234s;\n"
+   "dus = 1'234us;\n"
+   "hy = 0xA'BCy;",
+   "bd = 0b1d;\n"
+   "dh = 1234h;\n"
+   "dmin = 1234min;\n"
+   "dns = 1234ns;\n"
+   "ds = 1234s;\n"
+   "dus = 1234us;\n"
+   "hy = 0xABCy;",
+   Style);
+
+  verifyFormat("hd = 0xAB'Cd;", "hd = 0xABCd;", Style);
+
   verifyFormat("d = 5'678_km;\n"
"h = 0xD'EF_u16;",
"d = 5678_km;\n"
Index: clang/lib/Format/IntegerLiteralSeparatorFixer.cpp
===
--- clang/lib/Format/IntegerLiteralSeparatorFixer.cpp
+++ clang/lib/Format/IntegerLiteralSeparatorFixer.cpp
@@ -113,7 +113,11 @@
   continue;
 }
 if (Style.isCpp()) {
-  if (const auto Pos = Text.find_first_of("_i"); Pos != StringRef::npos) {
+  // Hex alpha digits a-f/A-F must be at the end of the string literal.
+  StringRef Suffixes = "_himnsuyd";
+  if (const auto Pos =
+  Text.find_first_of(IsBase16 ? Suffixes.drop_back() : Suffixes);
+  Pos != StringRef::npos) {
 Text = Text.substr(0, Pos);
 Length = Pos;
   }


Index: clang/unittests/Format/IntegerLiteralSeparatorTest.cpp
===
--- clang/unittests/Format/IntegerLiteralSeparatorTest.cpp
+++ clang/unittests/Format/IntegerLiteralSeparatorTest.cpp
@@ -60,6 +60,24 @@
"hil = 0xABCil;",
Style);
 
+  verifyFormat("bd = 0b1'd;\n"
+   "dh = 1'234h;\n"
+   "dmin = 1'234min;\n"
+   "dns = 1'234ns;\n"
+   "ds = 1'234s;\n"
+   "dus = 1'234us;\n"
+   "hy = 0xA'BCy;",
+   "bd = 0b1d;\n"
+   "dh = 1234h;\n"
+   "dmin = 1234min;\n"
+   "dns = 1234ns;\n"
+   "ds = 1234s;\n"
+   "dus = 1234us;\n"
+   "hy = 0xABCy;",
+   Style);
+
+  verifyFormat("hd = 0xAB'Cd;", "hd = 0xABCd;", Style);
+
   verifyFormat("d = 5'678_km;\n"
"h = 0xD'EF_u16;",
"d = 5678_km;\n"
Index: clang/lib/Format/IntegerLiteralSeparatorFixer.cpp
===
--- clang/lib/Format/IntegerLiteralSeparatorFixer.cpp
+++ clang/lib/Format/IntegerLiteralSeparatorFixer.cpp
@@ -113,7 +113,11 @@
   continue;
 }
 if (Style.isCpp()) {
-  if (const auto Pos = Text.find_first_of("_i"); Pos != StringRef::npos) {
+  // Hex alpha digits a-f/A-F must be at the end of the string literal.
+  StringRef Suffixes = "_himnsuyd";
+  if (const auto Pos =
+  Text.find_first_of(IsBase16 ? Suffixes.drop_back() : Suffixes);
+  Pos != StringRef::npos) {
 Text = Text.substr(0, Pos);
 Length = Pos;
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] a72b064 - [clang-format] Handle ud suffixes in IntegerLiteralSeparator

2023-05-16 Thread Owen Pan via cfe-commits

Author: Owen Pan
Date: 2023-05-16T13:17:31-07:00
New Revision: a72b064acf9546ee41c67c77ed8662d5d3b2fadc

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

LOG: [clang-format] Handle  ud suffixes in IntegerLiteralSeparator

Fixes #62679.

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

Added: 


Modified: 
clang/lib/Format/IntegerLiteralSeparatorFixer.cpp
clang/unittests/Format/IntegerLiteralSeparatorTest.cpp

Removed: 




diff  --git a/clang/lib/Format/IntegerLiteralSeparatorFixer.cpp 
b/clang/lib/Format/IntegerLiteralSeparatorFixer.cpp
index 583cc3d682a79..87823ae32b113 100644
--- a/clang/lib/Format/IntegerLiteralSeparatorFixer.cpp
+++ b/clang/lib/Format/IntegerLiteralSeparatorFixer.cpp
@@ -113,7 +113,11 @@ IntegerLiteralSeparatorFixer::process(const Environment 
,
   continue;
 }
 if (Style.isCpp()) {
-  if (const auto Pos = Text.find_first_of("_i"); Pos != StringRef::npos) {
+  // Hex alpha digits a-f/A-F must be at the end of the string literal.
+  StringRef Suffixes = "_himnsuyd";
+  if (const auto Pos =
+  Text.find_first_of(IsBase16 ? Suffixes.drop_back() : Suffixes);
+  Pos != StringRef::npos) {
 Text = Text.substr(0, Pos);
 Length = Pos;
   }

diff  --git a/clang/unittests/Format/IntegerLiteralSeparatorTest.cpp 
b/clang/unittests/Format/IntegerLiteralSeparatorTest.cpp
index 27fc6d76f3c49..b1e42e924e05c 100644
--- a/clang/unittests/Format/IntegerLiteralSeparatorTest.cpp
+++ b/clang/unittests/Format/IntegerLiteralSeparatorTest.cpp
@@ -60,6 +60,24 @@ TEST_F(IntegerLiteralSeparatorTest, SingleQuoteAsSeparator) {
"hil = 0xABCil;",
Style);
 
+  verifyFormat("bd = 0b1'd;\n"
+   "dh = 1'234h;\n"
+   "dmin = 1'234min;\n"
+   "dns = 1'234ns;\n"
+   "ds = 1'234s;\n"
+   "dus = 1'234us;\n"
+   "hy = 0xA'BCy;",
+   "bd = 0b1d;\n"
+   "dh = 1234h;\n"
+   "dmin = 1234min;\n"
+   "dns = 1234ns;\n"
+   "ds = 1234s;\n"
+   "dus = 1234us;\n"
+   "hy = 0xABCy;",
+   Style);
+
+  verifyFormat("hd = 0xAB'Cd;", "hd = 0xABCd;", Style);
+
   verifyFormat("d = 5'678_km;\n"
"h = 0xD'EF_u16;",
"d = 5678_km;\n"



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


[PATCH] D146269: MIPS: allow o32 abi with 64bit CPU and 64 abi with 32bit triple

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

Is this the new GCC behavior?

> `clang -target mipsel-linux-gnu -mabi=64`

Use `--target=`


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

https://reviews.llvm.org/D146269

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


[PATCH] D148276: [clang] trigger -Wcast-qual on functional casts

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

In D148276#4324314 , @sousajo wrote:

> have been sick, and could not advance much except I added the tests to 
> replicate the issue. Any ideas on how to proceed here?

Sorry to hear you've been sick, but thank you for your patience while I thought 
about this further. Two points worth observing:

1. GCC diagnoses the problematic code the same way your patch does: 
https://godbolt.org/z/44GnM9jzE
2. Clang and GCC both diagnose the notionally equivalent code using a C-style 
cast: https://godbolt.org/z/bbTPYb5rE

Based on that, it seems defensible for us to diagnose that code by re-landing 
the patch. However, I wonder why the changes broke anything. We build with GCC 
all the time. Is `-Wcast-qual` only enabled for bots building with Clang?

However, I also feel like this behavior is somewhat user-hostile because it 
seems reasonable to expect the developer is well aware that they're casting 
away the `const` qualifier when using something named `remove_const_t` to 
specify the cast destination type, so it seems potentially reasonable to 
silence the diagnostic in those cases (consistently, for both function- and 
c-style casts). It seems to be a reasonably popular approach to casting away 
const in the wild: 
https://sourcegraph.com/search?q=context:global+%5Cb%5Bstd::%5D%3Fremove_const%5B_t%5D%3F%5C%3C.*%5C%3E%5B::type%5D%3F%5C%28.*%5C%29=regexp=1=group
 so this might allow more folks to opt into `-Wcast-qual`. But implementing 
that would be tricky because we'd have to look through the cast expression to 
see whether it came from a type trait, and we typically do not want the 
frontend to be inspecting AST nodes by name (like looking for particular 
identifiers and changing behavior based on that), and we'd be introducing 
another divergence between the Clang and GCC behaviors.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148276

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


[PATCH] D150614: [clang-format] Ignore first token when finding MustBreak

2023-05-16 Thread Emilia Kond via Phabricator via cfe-commits
rymiel added inline comments.



Comment at: clang/unittests/Format/FormatTest.cpp:20136
"#ifdef _DEBUG\n"
-   "void bar()\n"
-   "  {\n"
-   "  }\n"
+   "void bar() {}\n"
"#else\n"

rymiel wrote:
> HazardyKnusperkeks wrote:
> > This doesn't seem right.
> WhitesmithsBraceStyle.AllowShortFunctionsOnASingleLine = 
> FormatStyle::SFS_Empty; is set above
(this is mentioned in the summary)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150614

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


[PATCH] D150614: [clang-format] Ignore first token when finding MustBreak

2023-05-16 Thread Emilia Kond via Phabricator via cfe-commits
rymiel added inline comments.



Comment at: clang/unittests/Format/FormatTest.cpp:20136
"#ifdef _DEBUG\n"
-   "void bar()\n"
-   "  {\n"
-   "  }\n"
+   "void bar() {}\n"
"#else\n"

HazardyKnusperkeks wrote:
> This doesn't seem right.
WhitesmithsBraceStyle.AllowShortFunctionsOnASingleLine = 
FormatStyle::SFS_Empty; is set above


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150614

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


[PATCH] D150430: Implement BufferOverlap check for sprint/snprintf

2023-05-16 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added a comment.

In D150430#4347365 , @ArnaudBienner 
wrote:

> Thanks for the review :)
>
> I implemented the suggested changes.
>
> Just one question: `PointeeTy.isNull()`: is this guaranteed to always work 
> even though `getType()->isAnyPointerType() == false`?
>
> I'm assuming yes since the tests still pass, but wanted to confirm this is 
> the best way to do this check for `char*` arguments.

I was also surprised, but check the definition of that function. It will try to 
cast the nonnull type to a list of types, and return null if didnt match.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150430

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


[PATCH] D150430: Implement BufferOverlap check for sprint/snprintf

2023-05-16 Thread Arnaud Bienner via Phabricator via cfe-commits
ArnaudBienner added a comment.

Thanks for the review :)

I implemented the suggested changes.

Just one question: `PointeeTy.isNull()`: is this guaranteed to always work even 
though `getType()->isAnyPointerType() == false`?

I'm assuming yes since the tests still pass, but wanted to confirm this is the 
best way to do this check for `char*` arguments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150430

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


[PATCH] D150694: [clang] Convert NVPTX OpenMP tests to opaque pointers

2023-05-16 Thread Nikita Popov via Phabricator via cfe-commits
nikic accepted this revision.
nikic 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/D150694/new/

https://reviews.llvm.org/D150694

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


[PATCH] D150430: Implement BufferOverlap check for sprint/snprintf

2023-05-16 Thread Arnaud Bienner via Phabricator via cfe-commits
ArnaudBienner updated this revision to Diff 522738.
ArnaudBienner added a comment.

- Code review comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150430

Files:
  clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
  clang/test/Analysis/buffer-overlap.c

Index: clang/test/Analysis/buffer-overlap.c
===
--- /dev/null
+++ clang/test/Analysis/buffer-overlap.c
@@ -0,0 +1,98 @@
+// RUN: %clang_analyze_cc1 -verify %s \
+// RUN:   -analyzer-checker=alpha.unix.cstring.BufferOverlap
+//
+// RUN: %clang_analyze_cc1 -verify %s -DUSE_BUILTINS \
+// RUN:   -analyzer-checker=alpha.unix.cstring.BufferOverlap
+//
+// RUN: %clang_analyze_cc1 -verify %s -DVARIANT \
+// RUN:   -analyzer-checker=alpha.unix.cstring.BufferOverlap
+//
+// RUN: %clang_analyze_cc1 -verify %s -DVARIANT -DUSE_BUILTINS \
+// RUN:   -analyzer-checker=alpha.unix.cstring.BufferOverlap
+
+// This provides us with four possible sprintf() definitions.
+
+#ifdef USE_BUILTINS
+#define BUILTIN(f) __builtin_##f
+#else /* USE_BUILTINS */
+#define BUILTIN(f) f
+#endif /* USE_BUILTINS */
+
+typedef typeof(sizeof(int)) size_t;
+
+#ifdef VARIANT
+
+#define __sprintf_chk BUILTIN(__sprintf_chk)
+#define __snprintf_chk BUILTIN(__snprintf_chk)
+int __sprintf_chk (char * __restrict str, int flag, size_t os,
+const char * __restrict fmt, ...);
+int __snprintf_chk (char * __restrict str, size_t len, int flag, size_t os,
+const char * __restrict fmt, ...);
+
+#define sprintf(str, ...) __sprintf_chk(str, 0, __builtin_object_size(str, 0), __VA_ARGS__)
+#define snprintf(str, len, ...) __snprintf_chk(str, len, 0, __builtin_object_size(str, 0), __VA_ARGS__)
+
+#else /* VARIANT */
+
+#define sprintf BUILTIN(sprintf)
+int sprintf(char *restrict buffer, const char *restrict format, ... );
+int snprintf(char *restrict buffer, size_t bufsz,
+ const char *restrict format, ... );
+#endif /* VARIANT */
+
+void test_sprintf1() {
+  char a[4] = {0};
+  sprintf(a, "%d/%s", 1, a); // expected-warning{{Arguments must not be overlapping buffers}}
+}
+
+void test_sprintf2() {
+  char a[4] = {0};
+  sprintf(a, "%s", a); // expected-warning{{Arguments must not be overlapping buffers}}
+}
+
+void test_sprintf3() {
+  char a[4] = {0};
+  sprintf(a, "%s/%s", a, a); // expected-warning{{Arguments must not be overlapping buffers}}
+}
+
+void test_sprintf4() {
+  char a[4] = {0};
+  sprintf(a, "%d", 42); // no-warning
+}
+
+void test_sprintf5() {
+  char a[4] = {0};
+  char b[4] = {0};
+  sprintf(a, "%s", b); // no-warning
+}
+
+void test_snprintf1() {
+  char a[4] = {0};
+  snprintf(a, sizeof(a), "%d/%s", 1, a); // expected-warning{{Arguments must not be overlapping buffers}}
+}
+
+void test_snprintf2() {
+  char a[4] = {0};
+  snprintf(a+1, sizeof(a)-1, "%d/%s", 1, a); // expected-warning{{Arguments must not be overlapping buffers}}
+}
+
+void test_snprintf3() {
+  char a[4] = {0};
+  snprintf(a, sizeof(a), "%s", a); // expected-warning{{Arguments must not be overlapping buffers}}
+}
+
+void test_snprintf4() {
+  char a[4] = {0};
+  snprintf(a, sizeof(a), "%s/%s", a, a); // expected-warning{{Arguments must not be overlapping buffers}}
+}
+
+void test_snprintf5() {
+  char a[4] = {0};
+  snprintf(a, sizeof(a), "%d", 42); // no-warning
+}
+
+void test_snprintf6() {
+  char a[4] = {0};
+  char b[4] = {0};
+  snprintf(a, sizeof(a), "%s", b); // no-warning
+}
Index: clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
@@ -12,6 +12,7 @@
 //===--===//
 
 #include "InterCheckerAPI.h"
+#include "clang/Basic/Builtins.h"
 #include "clang/Basic/CharInfo.h"
 #include "clang/StaticAnalyzer/Checkers/BuiltinCheckerRegistration.h"
 #include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
@@ -175,6 +176,8 @@
std::bind(::evalMemcmp, _1, _2, _3, CK_Regular)},
   {{CDF_MaybeBuiltin, {"bzero"}, 2}, ::evalBzero},
   {{CDF_MaybeBuiltin, {"explicit_bzero"}, 2}, ::evalBzero},
+  {{CDF_MaybeBuiltin, {"sprintf"}, 2}, ::evalSprintf},
+  {{CDF_MaybeBuiltin, {"snprintf"}, 2}, ::evalSnprintf},
   };
 
   // These require a bit of special handling.
@@ -228,6 +231,11 @@
   void evalMemset(CheckerContext , const CallExpr *CE) const;
   void evalBzero(CheckerContext , const CallExpr *CE) const;
 
+  void evalSprintf(CheckerContext , const CallExpr *CE) const;
+  void evalSnprintf(CheckerContext , const CallExpr *CE) const;
+  void evalSprintfCommon(CheckerContext , const CallExpr *CE, bool IsBounded,
+ bool IsBuiltin) const;
+
   // Utility methods
   std::pair
   static assumeZero(CheckerContext ,
@@ -2352,6 +2360,50 @@
   C.addTransition(State);
 }
 

[PATCH] D150704: [clang] Convert several smaller OpenMP tests to opaque pointers

2023-05-16 Thread Nikita Popov via Phabricator via cfe-commits
nikic accepted this revision.
nikic 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/D150704/new/

https://reviews.llvm.org/D150704

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


[PATCH] D150403: [clang-format] Adjust braced list detection (try 2)

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

In D150403#4343708 , @galenelias 
wrote:

> Thanks @HazardyKnusperkeks!  I don't have commit access, so will need someone 
> to land this for me.

We'll wait a bit, if someone might have a comment. And (at least I) need name 
and email for the commit.


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

https://reviews.llvm.org/D150403

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


[PATCH] D150614: [clang-format] Ignore first token when finding MustBreak

2023-05-16 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks added inline comments.



Comment at: clang/unittests/Format/FormatTest.cpp:20136
"#ifdef _DEBUG\n"
-   "void bar()\n"
-   "  {\n"
-   "  }\n"
+   "void bar() {}\n"
"#else\n"

This doesn't seem right.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150614

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


[PATCH] D150629: [clang-format] Don't allow template to be preceded by closing brace

2023-05-16 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks added inline comments.



Comment at: clang/unittests/Format/FormatTest.cpp:10682
   verifyFormat("a < 0 ? b : a > 0 ? c : d;");
+  verifyFormat("ratio{-1, 2} < ratio{-1, 3} == -1 / 3 > -1 / 2;");
   verifyFormat("void f() {\n"

owenpan wrote:
> Do we need to add a token annotator test?
> Do we need to add a token annotator test?

I'm in favor of one.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150629

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


[PATCH] D150704: [clang] Convert several smaller OpenMP tests to opaque pointers

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

target_map_codegen_34.cpp was converted manually. I think I got it right, but 
I'm not 100% sure.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150704

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


[PATCH] D133633: [CMake] Add ClangBootstrap configuration

2023-05-16 Thread Amir Ayupov via Phabricator via cfe-commits
Amir abandoned this revision.
Amir added a comment.
Herald added a subscriber: ekilmer.

No longer needed for Clang-BOLT. @thevinster – feel free to commandeer if it 
fits your needs.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133633

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


[PATCH] D150394: [OpenMP 5.2] Deprecate MINUS (-) operator on reduction clauses

2023-05-16 Thread Fazlay Rabbi via Phabricator via cfe-commits
mdfazlay added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:10490
+def warn_omp_minus_in_reduction_deprecated : Warning<
+  "minus(-) operator for reductions is deprecated; use an user defined 
reduction instead">,
+  InGroup;

ABataev wrote:
> `use + or user defined reudction instead`? And better make it a fixme note.
@ABataev, Do you want me to add a warning and a note at the same location? Or 
Changing the warning message to `minus(-) operator for reductions is 
deprecated; use + or user defined reduction instead` is just fine? Please let 
me know which one you prefer.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150394

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


[PATCH] D150668: Add doc link to missing include diagnostics.

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

For the records: Fixed in 76941b68ecd9 
. Thanks 
for the quick fix!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150668

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


[PATCH] D150531: Fix start index for sprintf ovlerap check + tests

2023-05-16 Thread Arnaud Bienner via Phabricator via cfe-commits
ArnaudBienner abandoned this revision.
ArnaudBienner added a comment.

Sorry about creating a new patch instead of updating the existing one.
Closing that one.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150531

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


[PATCH] D150670: [WebAssembly] Disable generation of fshl/fshr for rotates

2023-05-16 Thread Derek Schuff via Phabricator via cfe-commits
dschuff added a comment.

FWIW X86 seems to do something similar elsewhere in this file 
(https://github.com/llvm/llvm-project/blob/main/clang/lib/CodeGen/CGBuiltin.cpp#L985-L986),
 although it doesn't seem common otherwise. I think I'd be OK with this 
approach (and it does seem better than trying to mess with instcombine or a new 
TTI hook or something)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150670

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


[PATCH] D146389: [clang-repl][CUDA] Initial interactive CUDA support for clang-repl

2023-05-16 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev accepted this revision.
v.g.vassilev 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/D146389/new/

https://reviews.llvm.org/D146389

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


[PATCH] D150694: [clang] Convert NVPTX OpenMP tests to opaque pointers

2023-05-16 Thread Sergei Barannikov via Phabricator via cfe-commits
barannikov88 updated this revision to Diff 522718.
barannikov88 added a comment.

Update failing checks


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150694

Files:
  clang/test/OpenMP/nvptx_SPMD_codegen.cpp
  clang/test/OpenMP/nvptx_param_translate.c
  clang/test/OpenMP/nvptx_target_firstprivate_codegen.cpp
  clang/test/OpenMP/nvptx_target_parallel_reduction_codegen.cpp
  clang/test/OpenMP/nvptx_unsupported_type_codegen.cpp

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


[PATCH] D146389: [clang-repl][CUDA] Initial interactive CUDA support for clang-repl

2023-05-16 Thread Anubhab Ghosh via Phabricator via cfe-commits
argentite updated this revision to Diff 522717.
argentite added a comment.

Update the filenames


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146389

Files:
  clang/include/clang/Interpreter/Interpreter.h
  clang/lib/CodeGen/CGCUDANV.cpp
  clang/lib/CodeGen/CodeGenAction.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/ModuleBuilder.cpp
  clang/lib/Interpreter/CMakeLists.txt
  clang/lib/Interpreter/DeviceOffload.cpp
  clang/lib/Interpreter/DeviceOffload.h
  clang/lib/Interpreter/IncrementalParser.cpp
  clang/lib/Interpreter/IncrementalParser.h
  clang/lib/Interpreter/Interpreter.cpp
  clang/test/Interpreter/CUDA/device-function-template.cu
  clang/test/Interpreter/CUDA/device-function.cu
  clang/test/Interpreter/CUDA/host-and-device.cu
  clang/test/Interpreter/CUDA/lit.local.cfg
  clang/test/Interpreter/CUDA/memory.cu
  clang/test/Interpreter/CUDA/sanity.cu
  clang/test/lit.cfg.py
  clang/tools/clang-repl/ClangRepl.cpp
  clang/unittests/Interpreter/ExceptionTests/InterpreterExceptionTest.cpp
  clang/unittests/Interpreter/IncrementalProcessingTest.cpp
  clang/unittests/Interpreter/InterpreterTest.cpp

Index: clang/unittests/Interpreter/InterpreterTest.cpp
===
--- clang/unittests/Interpreter/InterpreterTest.cpp
+++ clang/unittests/Interpreter/InterpreterTest.cpp
@@ -40,7 +40,9 @@
   DiagnosticConsumer *Client = nullptr) {
   Args ClangArgs = {"-Xclang", "-emit-llvm-only"};
   ClangArgs.insert(ClangArgs.end(), ExtraArgs.begin(), ExtraArgs.end());
-  auto CI = cantFail(clang::IncrementalCompilerBuilder::create(ClangArgs));
+  auto CB = clang::IncrementalCompilerBuilder();
+  CB.SetCompilerArgs(ClangArgs);
+  auto CI = cantFail(CB.CreateCpp());
   if (Client)
 CI->getDiagnostics().setClient(Client, /*ShouldOwnClient=*/false);
   return cantFail(clang::Interpreter::create(std::move(CI)));
Index: clang/unittests/Interpreter/IncrementalProcessingTest.cpp
===
--- clang/unittests/Interpreter/IncrementalProcessingTest.cpp
+++ clang/unittests/Interpreter/IncrementalProcessingTest.cpp
@@ -52,7 +52,9 @@
 
 TEST(IncrementalProcessing, EmitCXXGlobalInitFunc) {
   std::vector ClangArgv = {"-Xclang", "-emit-llvm-only"};
-  auto CI = llvm::cantFail(IncrementalCompilerBuilder::create(ClangArgv));
+  auto CB = clang::IncrementalCompilerBuilder();
+  CB.SetCompilerArgs(ClangArgv);
+  auto CI = cantFail(CB.CreateCpp());
   auto Interp = llvm::cantFail(Interpreter::create(std::move(CI)));
 
   std::array PTUs;
Index: clang/unittests/Interpreter/ExceptionTests/InterpreterExceptionTest.cpp
===
--- clang/unittests/Interpreter/ExceptionTests/InterpreterExceptionTest.cpp
+++ clang/unittests/Interpreter/ExceptionTests/InterpreterExceptionTest.cpp
@@ -38,7 +38,9 @@
   DiagnosticConsumer *Client = nullptr) {
   Args ClangArgs = {"-Xclang", "-emit-llvm-only"};
   ClangArgs.insert(ClangArgs.end(), ExtraArgs.begin(), ExtraArgs.end());
-  auto CI = cantFail(clang::IncrementalCompilerBuilder::create(ClangArgs));
+  auto CB = clang::IncrementalCompilerBuilder();
+  CB.SetCompilerArgs(ClangArgs);
+  auto CI = cantFail(CB.CreateCpp());
   if (Client)
 CI->getDiagnostics().setClient(Client, /*ShouldOwnClient=*/false);
   return cantFail(clang::Interpreter::create(std::move(CI)));
Index: clang/tools/clang-repl/ClangRepl.cpp
===
--- clang/tools/clang-repl/ClangRepl.cpp
+++ clang/tools/clang-repl/ClangRepl.cpp
@@ -23,6 +23,10 @@
 #include "llvm/Support/TargetSelect.h" // llvm::Initialize*
 #include 
 
+static llvm::cl::opt CudaEnabled("cuda", llvm::cl::Hidden);
+static llvm::cl::opt CudaPath("cuda-path", llvm::cl::Hidden);
+static llvm::cl::opt OffloadArch("offload-arch", llvm::cl::Hidden);
+
 static llvm::cl::list
 ClangArgs("Xcc",
   llvm::cl::desc("Argument to pass to the CompilerInvocation"),
@@ -90,9 +94,36 @@
 return 0;
   }
 
+  clang::IncrementalCompilerBuilder CB;
+  CB.SetCompilerArgs(ClangArgv);
+
+  std::unique_ptr DeviceCI;
+  if (CudaEnabled) {
+// initialize NVPTX backend
+LLVMInitializeNVPTXTargetInfo();
+LLVMInitializeNVPTXTarget();
+LLVMInitializeNVPTXTargetMC();
+LLVMInitializeNVPTXAsmPrinter();
+
+if (!CudaPath.empty())
+  CB.SetCudaSDK(CudaPath);
+
+if (OffloadArch.empty()) {
+  OffloadArch = "sm_35";
+}
+CB.SetOffloadArch(OffloadArch);
+
+DeviceCI = ExitOnErr(CB.CreateCudaDevice());
+  }
+
   // FIXME: Investigate if we could use runToolOnCodeWithArgs from tooling. It
   // can replace the boilerplate code for creation of the compiler instance.
-  auto CI = ExitOnErr(clang::IncrementalCompilerBuilder::create(ClangArgv));
+  std::unique_ptr CI;
+  if (CudaEnabled) {
+

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

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

Addressing Petr's comments. Adding buildLinker initial draft for UEFI.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131594

Files:
  clang/lib/Basic/Targets.cpp
  clang/lib/Basic/Targets/OSTargets.h
  clang/lib/Basic/Targets/X86.h
  clang/lib/Driver/CMakeLists.txt
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChains/UEFI.cpp
  clang/lib/Driver/ToolChains/UEFI.h
  clang/test/Driver/windows-thumbv7em.cpp
  llvm/include/llvm/MC/TargetRegistry.h
  llvm/include/llvm/TargetParser/Triple.h
  llvm/lib/MC/MCContext.cpp
  llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp
  llvm/lib/Target/X86/MCTargetDesc/X86MCAsmInfo.cpp
  llvm/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.cpp
  llvm/lib/Target/X86/X86MCInstLower.cpp
  llvm/lib/TargetParser/Triple.cpp
  llvm/test/ExecutionEngine/RuntimeDyld/X86/coff-alignment.ll
  llvm/test/Instrumentation/InstrProfiling/profiling.ll
  llvm/test/Transforms/PGOProfile/comdat_rename.ll

Index: llvm/test/Transforms/PGOProfile/comdat_rename.ll
===
--- llvm/test/Transforms/PGOProfile/comdat_rename.ll
+++ llvm/test/Transforms/PGOProfile/comdat_rename.ll
@@ -1,5 +1,6 @@
 ; RUN: opt < %s -mtriple=x86_64-unknown-linux -passes=pgo-instr-gen -do-comdat-renaming=true -S | FileCheck %s
 ; RUN: opt < %s -mtriple=x86_64-pc-win32-coff -passes=pgo-instr-gen -do-comdat-renaming=true -S | FileCheck %s
+; RUN: opt < %s -mtriple=x86_64-unknown-coff -passes=pgo-instr-gen -do-comdat-renaming=true -S | FileCheck %s
 
 ; Rename Comdat group and its function.
 $f = comdat any
Index: llvm/test/Instrumentation/InstrProfiling/profiling.ll
===
--- llvm/test/Instrumentation/InstrProfiling/profiling.ll
+++ llvm/test/Instrumentation/InstrProfiling/profiling.ll
@@ -7,6 +7,7 @@
 ; RUN: opt < %s -mtriple=x86_64-scei-ps4 -passes=instrprof -S | FileCheck %s --check-prefixes=ELF,PS
 ; RUN: opt < %s -mtriple=x86_64-sie-ps5 -passes=instrprof -S | FileCheck %s --check-prefixes=ELF,PS
 ; RUN: opt < %s  -mtriple=x86_64-pc-win32-coff -passes=instrprof -S | FileCheck %s --check-prefixes=COFF
+; RUN: opt < %s  -mtriple=x86_64-unknown-coff -passes=instrprof -S | FileCheck %s --check-prefixes=COFF
 ; RUN: opt < %s -mtriple=powerpc64-ibm-aix-xcoff -passes=instrprof -S | FileCheck %s --check-prefixes=XCOFF
 ; RUN: opt < %s -mtriple=x86_64-pc-freebsd13 -passes=instrprof -S | FileCheck %s --check-prefixes=ELF
 
Index: llvm/test/ExecutionEngine/RuntimeDyld/X86/coff-alignment.ll
===
--- llvm/test/ExecutionEngine/RuntimeDyld/X86/coff-alignment.ll
+++ llvm/test/ExecutionEngine/RuntimeDyld/X86/coff-alignment.ll
@@ -1,6 +1,7 @@
 ; XFAIL: target=aarch64-pc-windows-{{.*}}
 ; REQUIRES: system-windows
 ; RUN: opt -mtriple=x86_64-pc-win32-coff %s -o - | lli
+; RUN: opt -mtriple=x86_64-unknown-coff %s -o - | lli
 
 @o = common global i32 0, align 4
 
Index: llvm/lib/TargetParser/Triple.cpp
===
--- llvm/lib/TargetParser/Triple.cpp
+++ llvm/lib/TargetParser/Triple.cpp
@@ -238,6 +238,7 @@
   case RTEMS: return "rtems";
   case Solaris: return "solaris";
   case TvOS: return "tvos";
+  case UEFI: return "uefi";
   case WASI: return "wasi";
   case WatchOS: return "watchos";
   case Win32: return "windows";
@@ -588,6 +589,7 @@
 .StartsWith("netbsd", Triple::NetBSD)
 .StartsWith("openbsd", Triple::OpenBSD)
 .StartsWith("solaris", Triple::Solaris)
+.StartsWith("uefi", Triple::UEFI)
 .StartsWith("win32", Triple::Win32)
 .StartsWith("windows", Triple::Win32)
 .StartsWith("zos", Triple::ZOS)
Index: llvm/lib/Target/X86/X86MCInstLower.cpp
===
--- llvm/lib/Target/X86/X86MCInstLower.cpp
+++ llvm/lib/Target/X86/X86MCInstLower.cpp
@@ -1947,7 +1947,8 @@
 
 void X86AsmPrinter::EmitSEHInstruction(const MachineInstr *MI) {
   assert(MF->hasWinCFI() && "SEH_ instruction in function without WinCFI?");
-  assert(getSubtarget().isOSWindows() && "SEH_ instruction Windows only");
+  assert((getSubtarget().isOSWindows() || TM.getTargetTriple().isUEFI()) &&
+ "SEH_ instruction Windows and UEFI only");
 
   // Use the .cv_fpo directives if we're emitting CodeView on 32-bit x86.
   if (EmitFPOData) {
Index: llvm/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.cpp
===
--- llvm/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.cpp
+++ llvm/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.cpp
@@ -441,6 +441,8 @@
   } else if (TheTriple.isOSCygMing() ||
  TheTriple.isWindowsItaniumEnvironment()) {
 MAI = new X86MCAsmInfoGNUCOFF(TheTriple);
+  } else if (TheTriple.isUEFI()) {
+MAI = new 

[PATCH] D149162: [Clang][OpenMP][IRBuilder] Move registerTargetGlobalVariable & getAddrOfDeclareTargetVar into the OMPIRBuilder

2023-05-16 Thread Andrew Gozillon via Phabricator via cfe-commits
agozillon added a comment.

rebased and added helper function as recommended, in recent update!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149162

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


[PATCH] D149162: [Clang][OpenMP][IRBuilder] Move registerTargetGlobalVariable & getAddrOfDeclareTargetVar into the OMPIRBuilder

2023-05-16 Thread Andrew Gozillon via Phabricator via cfe-commits
agozillon updated this revision to Diff 522710.
agozillon added a comment.

- [Clang][OpenMP][IRBuilder] Tidy up function calls with helpful reviewer advice
- [Clang][OpenMP][IRBuilder] Replace all getTargetEntryUniqueInfo with 
IRBuilder version
- [Clang][OpenMP][IRBuilder] Run clang-format and tidy up files
- Run clang-format on offending file breaking build process
- Address reviewers comments
- Add a new OpenMPIRBuilder that utilises registerTargetGlobalVariable (and by 
extension getAddrOfDeclareTargetVar) to generate host declare target data
- Add helper function to tidy things up a little as requested


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149162

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
  llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
  llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp

Index: llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
===
--- llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
+++ llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
@@ -5766,4 +5766,84 @@
   GlobalValue::WeakAnyLinkage);
   EXPECT_TRUE(InfoManager.hasDeviceGlobalVarEntryInfo("gvar"));
 }
+
+// Tests both registerTargetGlobalVariable and getAddrOfDeclareTargetVar as they
+// call each other (recursively in some cases). The test case test these
+// functions by utilising them for host code generation for declare target
+// global variables
+TEST_F(OpenMPIRBuilderTest, registerTargetGlobalVariable) {
+  OpenMPIRBuilder OMPBuilder(*M);
+  OMPBuilder.initialize();
+  OpenMPIRBuilderConfig Config(false, false, false, false);
+  OMPBuilder.setConfig(Config);
+
+  std::vector TargetTriple;
+  TargetTriple.emplace_back("amdgcn-amd-amdhsa");
+
+  TargetRegionEntryInfo EntryInfo("", 42, 4711, 17);
+  std::vector RefsGathered;
+
+  std::vector Globals;
+  auto *IntTy = Type::getInt32Ty(Ctx);
+  for (int I = 0; I < 2; ++I) {
+Globals.push_back(M->getOrInsertGlobal(
+"test_data_int_" + std::to_string(I), IntTy, [&]() -> GlobalVariable * {
+  return new GlobalVariable(
+  *M, IntTy, false, GlobalValue::LinkageTypes::WeakAnyLinkage,
+  ConstantInt::get(IntTy, I), "test_data_int_" + std::to_string(I));
+}));
+  }
+
+  OMPBuilder.registerTargetGlobalVariable(
+  OffloadEntriesInfoManager::OMPTargetGlobalVarEntryTo,
+  OffloadEntriesInfoManager::OMPTargetDeviceClauseAny, false, true,
+  EntryInfo, Globals[0]->getName(), RefsGathered, false, TargetTriple,
+  nullptr, nullptr, Globals[0]->getType(), Globals[0]);
+
+  OMPBuilder.registerTargetGlobalVariable(
+  OffloadEntriesInfoManager::OMPTargetGlobalVarEntryLink,
+  OffloadEntriesInfoManager::OMPTargetDeviceClauseAny, false, true,
+  EntryInfo, Globals[1]->getName(), RefsGathered, false, TargetTriple,
+  nullptr, nullptr, Globals[1]->getType(), Globals[1]);
+
+  llvm::OpenMPIRBuilder::EmitMetadataErrorReportFunctionTy & =
+  [](llvm::OpenMPIRBuilder::EmitMetadataErrorKind Kind,
+ const llvm::TargetRegionEntryInfo ) -> void {
+// If this is invoked, then we want to emit an error, even if it is not
+// neccesarily the most readable, as something has went wrong. The
+// test-suite unfortunately eats up all error output
+ASSERT_EQ(Kind, Kind);
+  };
+
+  OMPBuilder.createOffloadEntriesAndInfoMetadata(ErrorReportfn);
+
+  // Clauses for data_int_0 with To + Any clauses for the host
+  std::vector OffloadEntries;
+  OffloadEntries.push_back(M->getNamedGlobal(".omp_offloading.entry_name"));
+  OffloadEntries.push_back(
+  M->getNamedGlobal(".omp_offloading.entry.test_data_int_0"));
+
+  // Clauses for data_int_1 with Link + Any clauses for the host
+  OffloadEntries.push_back(
+  M->getNamedGlobal("test_data_int_1_decl_tgt_ref_ptr"));
+  OffloadEntries.push_back(M->getNamedGlobal(".omp_offloading.entry_name.1"));
+  OffloadEntries.push_back(M->getNamedGlobal(
+  ".omp_offloading.entry.test_data_int_1_decl_tgt_ref_ptr"));
+
+  for (unsigned I = 0; I < OffloadEntries.size(); ++I)
+EXPECT_NE(OffloadEntries[I], nullptr);
+
+  // Metadata generated for the host offload module
+  NamedMDNode *OffloadMetadata = M->getNamedMetadata("omp_offload.info");
+  EXPECT_NE(OffloadMetadata, nullptr);
+  if (OffloadMetadata) {
+EXPECT_EQ(OffloadMetadata->getOperand(0)->getOperand(1).equalsStr(
+  "test_data_int_0"),
+  true);
+EXPECT_EQ(OffloadMetadata->getOperand(1)->getOperand(1).equalsStr(
+  "test_data_int_1_decl_tgt_ref_ptr"),
+  true);
+  }
+}
+
 } // namespace
Index: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
===
--- llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
+++ llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
@@ -33,6 +33,7 @@
 #include 

[PATCH] D143334: [clang][Interp] Fix diagnosing uninitialized ctor record arrays

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

LG with a request for an additional test.




Comment at: clang/lib/AST/Interp/Interp.cpp:390
 
-  if (isa(ElemType.getTypePtr())) {
+  if (ElemType->isRecordType()) {
 const Record *R = BasePtr.getElemRecord();

tbaeder wrote:
> shafik wrote:
> > aaron.ballman wrote:
> > > The difference between these two is that `isRecordType()` is looking at 
> > > the canonical type whereas `isa<>` is looking at the type under 
> > > inspection rather than the canonical type. I'd expect these to have the 
> > > same behavior in most cases, but only matter for cases involving typedefs.
> > > 
> > > I think you're correct about the test case below not needing these 
> > > particular changes -- at least, I'm not seeing what's changed that should 
> > > impact the test. Should this be split into two changes? 1) Expose the 
> > > test, 2) Make this functional change + add a new test where the canonical 
> > > type is different to demonstrate the fix.
> > +1
> Can you come up with a small test case that would show the difference? You 
> mentioned typedefs, but if the array is of a typedef type, the old `isa<>` 
> version doesn't work either.
Ah, I see what you mean, yeah. With a typedef type, the `isa` would have also 
failed. That's a good test case to add to this patch as well.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143334

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


[PATCH] D150549: Move SubtargetFeature.h from MC to TargetParser

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

This seems fine, but please consider making `MC/SubtargetFeature.h` a 
forwarding header temporarily.

Our official build system CMake doesn't do layering checking for headers 
(https://llvm.org/docs/CodingStandards.html#library-layering).

Our unofficial build system Bazel supports layering checking 
. You may edit 
`utils/bazel/llvm-project-overlay/llvm/BUILD.bazel` and see whether bazel 
reports a circular dependency. I think this patch is fine, but just in case.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150549

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


[PATCH] D150647: [WIP][analyzer] Fix EnumCastOutOfRangeChecker C++17 handling

2023-05-16 Thread Endre Fülöp via Phabricator via cfe-commits
gamesh411 added a comment.

In D150647#4345345 , @steakhal wrote:

>> In C++17 the initialization rules for enum classes are relaxed.
>
> In what way are they relaxed compared to regular enums?

The initialization rules are relaxed compared to their pre-C++17 state, so now 
there is a possibility of an initialization for enum classes without explicitly 
mentioning the underlying type.
I have updated the revision body.

That all being said, there is another fundamental issue with this checker, 
namely that the possible value range is I think restricted to the ones 
explicitly mentioned in the enumerators.
For example in the std::byte case even the old way of initializing gives a 
false positive.
I am investigating the issue, and have found so far, that fixed 
underlying-typed and non-fixed underlying-typed enums behave differently, which 
is not considered in the checker code.

Relevant info dump for future quoting:
https://eel.is/c++draft/dcl.enum#5
https://eel.is/c++draft/dcl.enum#7
https://eel.is/c++draft/dcl.enum#8
https://eel.is/c++draft/expr.static.cast#10
https://eel.is/c++draft/conv.fpint


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150647

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


[PATCH] D150694: [clang] Convert NVPTX OpenMP tests to opaque pointers

2023-05-16 Thread Sergei Barannikov via Phabricator via cfe-commits
barannikov88 planned changes to this revision.
barannikov88 added a comment.

Nah, they need some hand work after all.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150694

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


[PATCH] D148700: [clang] Add support for “regular” keyword attributes

2023-05-16 Thread Richard Sandiford via Phabricator via cfe-commits
rsandifo-arm marked an inline comment as done.
rsandifo-arm added a comment.

Thanks @erichkeane .  Adding the documentation with that kind of disclaimer 
sounds good to me.  I've done that in the updated version, and also fixed the 
comment problem that Aaron pointed out.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148700

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


[clang] 92b8ed6 - Correct documentation for -fconstexpr-depth=

2023-05-16 Thread Aaron Ballman via cfe-commits

Author: Aaron Ballman
Date: 2023-05-16T13:42:25-04:00
New Revision: 92b8ed6e5e5dc921c611eae4160570f169657030

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

LOG: Correct documentation for -fconstexpr-depth=

We were documenting that this was about recursive calls when it's
actually about arbitrary calls.

e.g., https://godbolt.org/z/en8sYd77E

Added: 


Modified: 
clang/docs/UsersManual.rst

Removed: 




diff  --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst
index 0a568f3c99d6..65d1eaaed53c 100644
--- a/clang/docs/UsersManual.rst
+++ b/clang/docs/UsersManual.rst
@@ -3294,8 +3294,7 @@ Controlling implementation limits
 
 .. option:: -fconstexpr-depth=N
 
-  Sets the limit for recursive constexpr function invocations to N.  The
-  default is 512.
+  Sets the limit for constexpr function invocations to N. The default is 512.
 
 .. option:: -fconstexpr-steps=N
 



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


[PATCH] D148700: [clang] Add support for “regular” keyword attributes

2023-05-16 Thread Richard Sandiford via Phabricator via cfe-commits
rsandifo-arm updated this revision to Diff 522703.
rsandifo-arm added a comment.

Add documentation.  Fix a comment cut-&-pasto that Aaron pointed out.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148700

Files:
  clang-tools-extra/pseudo/lib/grammar/CMakeLists.txt
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/AttributeCommonInfo.h
  clang/include/clang/Basic/CMakeLists.txt
  clang/include/clang/Basic/TokenKinds.def
  clang/include/clang/Basic/TokenKinds.h
  clang/include/clang/Lex/Token.h
  clang/lib/AST/TypePrinter.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/lib/Sema/SemaType.cpp
  clang/lib/Serialization/ASTReaderDecl.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/unittests/AST/AttrTest.cpp
  clang/utils/TableGen/ClangAttrEmitter.cpp
  clang/utils/TableGen/TableGen.cpp
  clang/utils/TableGen/TableGenBackends.h

Index: clang/utils/TableGen/TableGenBackends.h
===
--- clang/utils/TableGen/TableGenBackends.h
+++ clang/utils/TableGen/TableGenBackends.h
@@ -43,6 +43,8 @@
llvm::raw_ostream );
 void EmitClangAttrPCHRead(llvm::RecordKeeper , llvm::raw_ostream );
 void EmitClangAttrPCHWrite(llvm::RecordKeeper , llvm::raw_ostream );
+void EmitClangAttrTokenKinds(llvm::RecordKeeper ,
+ llvm::raw_ostream );
 void EmitClangAttrHasAttrImpl(llvm::RecordKeeper ,
   llvm::raw_ostream );
 void EmitClangAttrSpellingListIndex(llvm::RecordKeeper ,
Index: clang/utils/TableGen/TableGen.cpp
===
--- clang/utils/TableGen/TableGen.cpp
+++ clang/utils/TableGen/TableGen.cpp
@@ -35,6 +35,7 @@
   GenClangAttrSubjectMatchRuleList,
   GenClangAttrPCHRead,
   GenClangAttrPCHWrite,
+  GenClangAttrTokenKinds,
   GenClangAttrHasAttributeImpl,
   GenClangAttrSpellingListIndex,
   GenClangAttrASTVisitor,
@@ -128,6 +129,8 @@
"Generate clang PCH attribute reader"),
 clEnumValN(GenClangAttrPCHWrite, "gen-clang-attr-pch-write",
"Generate clang PCH attribute writer"),
+clEnumValN(GenClangAttrTokenKinds, "gen-clang-attr-token-kinds",
+   "Generate a list of attribute-related clang tokens"),
 clEnumValN(GenClangAttrHasAttributeImpl,
"gen-clang-attr-has-attribute-impl",
"Generate a clang attribute spelling list"),
@@ -303,6 +306,9 @@
   case GenClangAttrPCHWrite:
 EmitClangAttrPCHWrite(Records, OS);
 break;
+  case GenClangAttrTokenKinds:
+EmitClangAttrTokenKinds(Records, OS);
+break;
   case GenClangAttrHasAttributeImpl:
 EmitClangAttrHasAttrImpl(Records, OS);
 break;
Index: clang/utils/TableGen/ClangAttrEmitter.cpp
===
--- clang/utils/TableGen/ClangAttrEmitter.cpp
+++ clang/utils/TableGen/ClangAttrEmitter.cpp
@@ -2378,6 +2378,11 @@
   OS << "#endif // CLANG_ATTR_ACCEPTS_EXPR_PACK\n\n";
 }
 
+static bool isRegularKeywordAttribute(const FlattenedSpelling ) {
+  return (S.variety() == "Keyword" &&
+  !S.getSpellingRecord().getValueAsBit("HasOwnParseRules"));
+}
+
 static void emitFormInitializer(raw_ostream ,
 const FlattenedSpelling ,
 StringRef SpellingIndex) {
@@ -2385,7 +2390,9 @@
   (Spelling.variety() == "Keyword" && Spelling.name() == "alignas");
   OS << "{AttributeCommonInfo::AS_" << Spelling.variety() << ", "
  << SpellingIndex << ", " << (IsAlignas ? "true" : "false")
- << " /*IsAlignas*/}";
+ << " /*IsAlignas*/, "
+ << (isRegularKeywordAttribute(Spelling) ? "true" : "false")
+ << " /*IsRegularKeywordAttribute*/}";
 }
 
 static void emitAttributes(RecordKeeper , raw_ostream ,
@@ -3404,6 +3411,26 @@
   OS << ".Default(0);\n";
 }
 
+// Emits the list of tokens for regular keyword attributes.
+void EmitClangAttrTokenKinds(RecordKeeper , raw_ostream ) {
+  emitSourceFileHeader("A list of tokens generated from the attribute"
+   " definitions",
+   OS);
+  // Assume for now that the same token is not used in multiple regular
+  // keyword attributes.
+  for (auto *R : Records.getAllDerivedDefinitions("Attr"))
+for (const auto  : GetFlattenedSpellings(*R))
+  if (isRegularKeywordAttribute(S)) {
+if (!R->getValueAsListOfDefs("Args").empty())
+  PrintError(R->getLoc(),
+ "RegularKeyword attributes with arguments are not "
+ "yet supported");
+OS << "KEYWORD_ATTRIBUTE("
+   << S.getSpellingRecord().getValueAsString("Name") << ")\n";
+  }
+  OS << "#undef KEYWORD_ATTRIBUTE\n";
+}
+
 // Emits the list of spellings for attributes.
 void 

[PATCH] D150694: [clang] Convert NVPTX OpenMP tests to opaque pointers

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

These were completely handled by the script except that I manually renumbered 
basic blocks in the large SIMD test.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150694

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


[PATCH] D150694: [clang] Convert NVPTX OpenMP tests to opaque pointers

2023-05-16 Thread Sergei Barannikov via Phabricator via cfe-commits
barannikov88 created this revision.
barannikov88 added a reviewer: nikic.
Herald added subscribers: sunshaoce, mattd, gchakrabarti, asavonic, StephenFan, 
guansong, yaxunl.
Herald added a project: All.
barannikov88 requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added subscribers: cfe-commits, jplehr, sstefan1.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D150694

Files:
  clang/test/OpenMP/nvptx_SPMD_codegen.cpp
  clang/test/OpenMP/nvptx_param_translate.c
  clang/test/OpenMP/nvptx_target_firstprivate_codegen.cpp
  clang/test/OpenMP/nvptx_target_parallel_reduction_codegen.cpp
  clang/test/OpenMP/nvptx_unsupported_type_codegen.cpp

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


[PATCH] D148614: [clang][Interp] Add frame depth checking

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

LGTM, though I would appreciate adding the other test case from my comments 
since it's interesting behavior.




Comment at: clang/lib/AST/Interp/Interp.cpp:345-352
+  if ((S.Current->getDepth() + 1) > S.getLangOpts().ConstexprCallDepth) {
+S.FFDiag(S.Current->getSource(OpPC),
+ diag::note_constexpr_depth_limit_exceeded)
+<< S.getLangOpts().ConstexprCallDepth;
+return false;
+  }
+

aaron.ballman wrote:
> `-fconstexpr-depth` sets the number of *recursive* constexpr calls, but this 
> looks like it's measuring the depth of the call stack regardless of whether 
> there's recursion or not. Can you add a test where you set this value to 
> something low and make nested calls that exceed that depth?
> 
> (Also, there's `-fconstexpr-steps` 
> https://clang.llvm.org/docs/UsersManual.html#cmdoption-fconstexpr-steps we'll 
> need to support at some point, in case you weren't aware of the option.)
Whelp, TIL that our docs are wrong and should be updated (I'll take care of 
that): https://godbolt.org/z/ahPjPnhGr

It has nothing to do with recursion, that's just the way in which you'd 
typically run into it.


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

https://reviews.llvm.org/D148614

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


[PATCH] D150655: [clang][dataflow] Use `Strict` accessors in more places in Transfer.cpp.

2023-05-16 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun accepted this revision.
xazax.hun added inline comments.



Comment at: clang/lib/Analysis/FlowSensitive/Transfer.cpp:717-723
+Value *SubExprVal = Env.getValueStrict(*SubExpr);
+if (SubExprVal == nullptr)
   return;
 
-Env.setStorageLocation(*S, *SubExprLoc);
+auto  = Env.createStorageLocation(*S);
+Env.setStorageLocationStrict(*S, Loc);
+Env.setValue(Loc, *SubExprVal);

This operation is basically something like an RValue to LValue cast. I am not 
sure how many of these will we have, but it might be a good idea to look out if 
we want to create something like `propagateAsLValue` similar to 
`propagateValue`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150655

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


[PATCH] D148614: [clang][Interp] Add frame depth checking

2023-05-16 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/lib/AST/Interp/Interp.cpp:345-352
+  if ((S.Current->getDepth() + 1) > S.getLangOpts().ConstexprCallDepth) {
+S.FFDiag(S.Current->getSource(OpPC),
+ diag::note_constexpr_depth_limit_exceeded)
+<< S.getLangOpts().ConstexprCallDepth;
+return false;
+  }
+

`-fconstexpr-depth` sets the number of *recursive* constexpr calls, but this 
looks like it's measuring the depth of the call stack regardless of whether 
there's recursion or not. Can you add a test where you set this value to 
something low and make nested calls that exceed that depth?

(Also, there's `-fconstexpr-steps` 
https://clang.llvm.org/docs/UsersManual.html#cmdoption-fconstexpr-steps we'll 
need to support at some point, in case you weren't aware of the option.)


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

https://reviews.llvm.org/D148614

___
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-16 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

> I'd really want to look at IR for return inside try/finally, but for some 
> reason, I an not build compiler with your patch: no member named 
> 'setHasAddressTaken' in 'llvm::MachineBasicBlock'; did you mean 
> 'hasAddressTaken'. I may missing some thing in my environment.

The patch is old; I was having trouble getting any review, and then I forgot 
about it.  I'll try to find time to rebase.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150340

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


[PATCH] D143967: [DebugInfo][BPF] Add 'btf:type_tag' annotation in DWARF

2023-05-16 Thread Eduard Zingerman via Phabricator via cfe-commits
eddyz87 added a comment.

In D143967#4346934 , @dfaust wrote:

> In D143967#4343841 , @eddyz87 wrote:
>
>> Changes to avoid attaching type tags to DWARF derived types for 
>> const/volatile/restrict qualifiers.
>
> I just tested this locally and can confirm it LGTM in terms of implementing 
> the DWARF format we've been discussing and agreed upon.
> Also compared against my WIP patches implementing the same in GCC, and looks 
> like it is all consistent (apart from one known bug in my patches)

Heads-up, it currently fails on the following example:

  #define __rcu __attribute__((btf_type_tag("rcu")))
  
  struct cred;
  const struct cred *cred;
  void commit_creds()
  {
cred = (typeof(*cred) __rcu *)(0);
  }

I'm working on the fix.
Also I missed the fact that D145891  (actual 
BTF generation) needs adjustment as well.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143967

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


[PATCH] D150690: [RISCV] Use IRBuilder::CreateInsertVector/CreateExtractVector to simplify code. NFC

2023-05-16 Thread Craig Topper via Phabricator via cfe-commits
craig.topper updated this revision to Diff 522690.
craig.topper added a comment.

Update more intrinsics


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150690

Files:
  clang/include/clang/Basic/riscv_vector.td

Index: clang/include/clang/Basic/riscv_vector.td
===
--- clang/include/clang/Basic/riscv_vector.td
+++ clang/include/clang/Basic/riscv_vector.td
@@ -2045,28 +2045,18 @@
 // --(bitcast)> 
 // --(vector_extract)-> 
 llvm::Value *BitCast = Builder.CreateBitCast(Ops[0], Boolean64Ty);
-
-ID = Intrinsic::vector_extract;
-llvm::Value *Operands[2];
-Operands[0] = BitCast;
-Operands[1] = ConstantInt::get(Int64Ty, 0);
-IntrinsicTypes = {ResultType, Boolean64Ty};
-
-return Builder.CreateCall(CGM.getIntrinsic(ID, IntrinsicTypes), Operands, "");
+return Builder.CreateExtractVector(ResultType, BitCast,
+   ConstantInt::get(Int64Ty, 0));
   } else {
 // Casting from vector boolean -> m1 vector integer
 // Ex: 
 //   --(vector_insert)-> 
 //   --(bitcast)---> 
-ID = Intrinsic::vector_insert;
-llvm::Value *Operands[3];
-Operands[0] = llvm::PoisonValue::get(Boolean64Ty);
-Operands[1] = Ops[0];
-Operands[2] = ConstantInt::get(Int64Ty, 0);
-IntrinsicTypes = {Boolean64Ty, Ops[0]->getType()};
 llvm::Value *Boolean64Val =
-  Builder.CreateCall(CGM.getIntrinsic(ID, IntrinsicTypes), Operands, "");
-
+  Builder.CreateInsertVector(Boolean64Ty,
+ llvm::PoisonValue::get(Boolean64Ty),
+ Ops[0],
+ ConstantInt::get(Int64Ty, 0));
 return Builder.CreateBitCast(Boolean64Val, ResultType);
   }
 }
@@ -2151,10 +2141,8 @@
   let Name = "vlmul_trunc_v", OverloadedName = "vlmul_trunc",
   MaskedPolicyScheme = NonePolicy,
   ManualCodegen = [{ {
-ID = Intrinsic::vector_extract;
-IntrinsicTypes = {ResultType, Ops[0]->getType()};
-Ops.push_back(ConstantInt::get(Int64Ty, 0));
-return Builder.CreateCall(CGM.getIntrinsic(ID, IntrinsicTypes), Ops, "");
+return Builder.CreateExtractVector(ResultType, Ops[0],
+   ConstantInt::get(Int64Ty, 0));
   } }] in {
 foreach dst_lmul = ["(SFixedLog2LMUL:-3)", "(SFixedLog2LMUL:-2)", "(SFixedLog2LMUL:-1)",
 "(SFixedLog2LMUL:0)", "(SFixedLog2LMUL:1)", "(SFixedLog2LMUL:2)"] in {
@@ -2170,12 +2158,9 @@
   let Name = "vlmul_ext_v", OverloadedName = "vlmul_ext",
   MaskedPolicyScheme = NonePolicy,
   ManualCodegen = [{
-ID = Intrinsic::vector_insert;
-IntrinsicTypes = {ResultType, Ops[0]->getType()};
-Ops.push_back(llvm::PoisonValue::get(ResultType));
-std::swap(Ops[0], Ops[1]);
-Ops.push_back(ConstantInt::get(Int64Ty, 0));
-return Builder.CreateCall(CGM.getIntrinsic(ID, IntrinsicTypes), Ops, "");
+return Builder.CreateInsertVector(ResultType,
+  llvm::PoisonValue::get(ResultType),
+  Ops[0], ConstantInt::get(Int64Ty, 0));
   }] in {
 foreach dst_lmul = ["(LFixedLog2LMUL:-2)", "(LFixedLog2LMUL:-1)", "(LFixedLog2LMUL:-0)",
 "(LFixedLog2LMUL:1)", "(LFixedLog2LMUL:2)", "(LFixedLog2LMUL:3)"] in {
@@ -2189,7 +2174,6 @@
   let Name = "vget_v", MaskedPolicyScheme = NonePolicy,
   ManualCodegen = [{
   {
-ID = Intrinsic::vector_extract;
 auto *VecTy = cast(ResultType);
 auto *OpVecTy = cast(Ops[0]->getType());
 // Mask to only valid indices.
@@ -2200,8 +2184,7 @@
 Ops[1] = Builder.CreateMul(Ops[1],
ConstantInt::get(Ops[1]->getType(),
 VecTy->getMinNumElements()));
-IntrinsicTypes = {ResultType, Ops[0]->getType()};
-return Builder.CreateCall(CGM.getIntrinsic(ID, IntrinsicTypes), Ops, "");
+return Builder.CreateExtractVector(ResultType, Ops[0], Ops[1]);
   }
   }] in {
 foreach dst_lmul = ["(SFixedLog2LMUL:0)", "(SFixedLog2LMUL:1)", "(SFixedLog2LMUL:2)"] in {
@@ -2213,8 +2196,6 @@
   let Name = "vset_v", Log2LMUL = [0, 1, 2], MaskedPolicyScheme = NonePolicy,
   ManualCodegen = [{
   {
-ID = Intrinsic::vector_insert;
-IntrinsicTypes = {ResultType, Ops[2]->getType()};
 auto *ResVecTy = cast(ResultType);
 auto *VecTy = cast(Ops[2]->getType());
 // Mask to only valid indices.
@@ 

  1   2   3   >