[clang-tools-extra] [clang-tidy] new check misc-use-internal-linkage (PR #90830)
https://github.com/PiotrZSL approved this pull request. I accept this change as it's fine for 1.0 version Any fixed can be always done in this or new change. https://github.com/llvm/llvm-project/pull/90830 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clang-tidy] new check misc-use-internal-linkage (PR #90830)
@@ -0,0 +1,78 @@ +//===--- UseInternalLinkageCheck.cpp - clang-tidy--===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#include "UseInternalLinkageCheck.h" +#include "../utils/FileExtensionsUtils.h" +#include "clang/AST/Decl.h" +#include "clang/ASTMatchers/ASTMatchFinder.h" +#include "clang/ASTMatchers/ASTMatchers.h" +#include "clang/ASTMatchers/ASTMatchersMacros.h" +#include "clang/Basic/SourceLocation.h" +#include "clang/Basic/Specifiers.h" +#include "llvm/ADT/STLExtras.h" + +using namespace clang::ast_matchers; + +namespace clang::tidy::misc { + +namespace { + +AST_MATCHER(Decl, isFirstDecl) { return Node.isFirstDecl(); } + +AST_MATCHER_P(Decl, isInMainFile, FileExtensionsSet, HeaderFileExtensions) { + return llvm::all_of(Node.redecls(), [&](const Decl *D) { +SourceManager &SM = Finder->getASTContext().getSourceManager(); +const SourceLocation L = D->getLocation(); +return SM.isInMainFile(L) && + !utils::isSpellingLocInHeaderFile(L, SM, HeaderFileExtensions); + }); PiotrZSL wrote: yes, that FirstDecl stuff will work. just note that we got config for header extensions and source extensions. better would be to use source. as those .inc could be part of header files also. https://github.com/llvm/llvm-project/pull/90830 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Macro for constant rounding mode (PR #92699)
spavloff wrote: The discussion for the proposed mechanism is open here: https://discourse.llvm.org/t/rfc-calling-functions-if-pragma-fenv-round-is-present/79372 > > This change introduces macro ROUNDING_MODE, which is a string dependent on > > the constant rounding mode > > It expands to an identify, not a string literal, right? Exactly. https://github.com/llvm/llvm-project/pull/92699 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Split up `SemaDeclAttr.cpp` (PR #93966)
https://github.com/Endilll closed https://github.com/llvm/llvm-project/pull/93966 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format] Don't format comments in SkipMacroDefinitionBody (PR #94425)
https://github.com/mydeveloperday approved this pull request. https://github.com/llvm/llvm-project/pull/94425 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [ARM][clang] Fix warning for VFP function calls from interrupts. (PR #91870)
chrisnc wrote: Ping https://github.com/llvm/llvm-project/pull/91870 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][CodeGen] Make `UnqualPtrTy` truly unqualified (PR #94388)
jrtc27 wrote: I think the point is there are two things going on here that people think of as unqualified: 1. "Give me a pointer that's whatever `void *` is" 2. "Give me a pointer in some address space just so I can put a global in some metadata" The vast majority of the time we're talking about 1, which is what most people would think of unqualified as meaning. #93601 / #93914 are about the three special cases that are case 2 above. But those are a special case, and normally when people say unqualified they mean "default" address space / `void *`. https://github.com/llvm/llvm-project/pull/94388 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][CodeGen] Make `UnqualPtrTy` truly unqualified (PR #94388)
efriedma-quic wrote: llvm::PointerType::getUnqual assumes pointers to addr-space 0 are "unqualified"... but the discussion on #88182 concluded that doesn't make sense: the "unqualified" address space is a target-specific choice, and address-space zero isn't required to have any meaning at all. Given that, it seems like this is going in the opposite direction of what you want. https://github.com/llvm/llvm-project/pull/94388 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format] Don't format comments in SkipMacroDefinitionBody (PR #94425)
llvmbot wrote: @llvm/pr-subscribers-clang-format Author: Owen Pan (owenca) Changes Fixes #94326. --- Full diff: https://github.com/llvm/llvm-project/pull/94425.diff 2 Files Affected: - (modified) clang/lib/Format/UnwrappedLineParser.cpp (+3-3) - (modified) clang/unittests/Format/FormatTest.cpp (+10-1) ``diff diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp index d6061c2666c2a..eb96b54ec4c96 100644 --- a/clang/lib/Format/UnwrappedLineParser.cpp +++ b/clang/lib/Format/UnwrappedLineParser.cpp @@ -1181,10 +1181,10 @@ void UnwrappedLineParser::parsePPDefine() { Line->InMacroBody = true; if (Style.SkipMacroDefinitionBody) { -do { +while (!eof()) { FormatTok->Finalized = true; - nextToken(); -} while (!eof()); + FormatTok = Tokens->getNextToken(); +} addUnwrappedLine(); return; } diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index 004ecb63f6620..4e427268fb82a 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -24879,7 +24879,7 @@ TEST_F(FormatTest, SkipMacroDefinitionBody) { Style); // With comments. - verifyFormat("/* */ #define A a // a a", "/* */ # define A a // a a", + verifyFormat("/* */ #define A a // a a", "/* */ # define A a // a a", Style); verifyNoChange("/* */ #define A a // a a", Style); @@ -24891,6 +24891,15 @@ TEST_F(FormatTest, SkipMacroDefinitionBody) { "int aaa; // a", Style); + verifyNoChange( + "#define MACRO_WITH_COMMENTS() \\\n" + " public: \\\n" + "/* Documentation parsed by Doxygen for the following method. */ \\\n" + "static MyType getClassTypeId(); \\\n" + "/** Normal comment for the following method. */ \\\n" + "virtual MyType getTypeId() const;", + Style); + // multiline macro definitions verifyNoChange("#define A a\\\n" " A a \\\n " `` https://github.com/llvm/llvm-project/pull/94425 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format] Don't format comments in SkipMacroDefinitionBody (PR #94425)
https://github.com/owenca created https://github.com/llvm/llvm-project/pull/94425 Fixes #94326. >From 7e4c3e6b5b77085f795d6ccdfbf7279e32741b16 Mon Sep 17 00:00:00 2001 From: Owen Pan Date: Tue, 4 Jun 2024 21:10:14 -0700 Subject: [PATCH] [clang-format] Don't format comments in SkipMacroDefinitionBody Fixes #94326. --- clang/lib/Format/UnwrappedLineParser.cpp | 6 +++--- clang/unittests/Format/FormatTest.cpp| 11 ++- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp index d6061c2666c2a..eb96b54ec4c96 100644 --- a/clang/lib/Format/UnwrappedLineParser.cpp +++ b/clang/lib/Format/UnwrappedLineParser.cpp @@ -1181,10 +1181,10 @@ void UnwrappedLineParser::parsePPDefine() { Line->InMacroBody = true; if (Style.SkipMacroDefinitionBody) { -do { +while (!eof()) { FormatTok->Finalized = true; - nextToken(); -} while (!eof()); + FormatTok = Tokens->getNextToken(); +} addUnwrappedLine(); return; } diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index 004ecb63f6620..4e427268fb82a 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -24879,7 +24879,7 @@ TEST_F(FormatTest, SkipMacroDefinitionBody) { Style); // With comments. - verifyFormat("/* */ #define A a // a a", "/* */ # define A a // a a", + verifyFormat("/* */ #define A a // a a", "/* */ # define A a // a a", Style); verifyNoChange("/* */ #define A a // a a", Style); @@ -24891,6 +24891,15 @@ TEST_F(FormatTest, SkipMacroDefinitionBody) { "int aaa; // a", Style); + verifyNoChange( + "#define MACRO_WITH_COMMENTS() \\\n" + " public: \\\n" + "/* Documentation parsed by Doxygen for the following method. */ \\\n" + "static MyType getClassTypeId(); \\\n" + "/** Normal comment for the following method. */ \\\n" + "virtual MyType getTypeId() const;", + Style); + // multiline macro definitions verifyNoChange("#define A a\\\n" " A a \\\n " ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format] Add DiagHandler for getStyle function (PR #91317)
@@ -3945,20 +3945,23 @@ const char *DefaultFallbackStyle = "LLVM"; llvm::ErrorOr> loadAndParseConfigFile(StringRef ConfigFile, llvm::vfs::FileSystem *FS, - FormatStyle *Style, bool AllowUnknownOptions) { + FormatStyle *Style, bool AllowUnknownOptions, + llvm::SourceMgr::DiagHandlerTy DiagHandler = nullptr) { owenca wrote: It seems we don't need the default `nullptr`. https://github.com/llvm/llvm-project/pull/91317 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format] Add DiagHandler for getStyle function (PR #91317)
@@ -4026,12 +4030,13 @@ Expected getStyle(StringRef StyleName, StringRef FileName, // Reset possible inheritance Style.InheritsParentConfig = false; - auto dropDiagnosticHandler = [](const llvm::SMDiagnostic &, void *) {}; + auto diagHandlerOrDropHandling = + DiagHandler ? DiagHandler : [](llvm::SMDiagnostic const &, void *) {}; auto applyChildFormatTexts = [&](FormatStyle *Style) { for (const auto &MemBuf : llvm::reverse(ChildFormatTextToApply)) { auto EC = parseConfiguration(*MemBuf, Style, AllowUnknownOptions, - dropDiagnosticHandler); + diagHandlerOrDropHandling); owenca wrote: It seems we only need to pass `DiagHandler`. https://github.com/llvm/llvm-project/pull/91317 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format] Add DiagHandler for getStyle function (PR #91317)
@@ -4026,12 +4030,13 @@ Expected getStyle(StringRef StyleName, StringRef FileName, // Reset possible inheritance Style.InheritsParentConfig = false; - auto dropDiagnosticHandler = [](const llvm::SMDiagnostic &, void *) {}; + auto diagHandlerOrDropHandling = + DiagHandler ? DiagHandler : [](llvm::SMDiagnostic const &, void *) {}; owenca wrote: It seems we can just delete line 4029. See below. https://github.com/llvm/llvm-project/pull/91317 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [flang] [llvm] [OpenMP][LLVM] Update alloca IP after `PrivCB` in `OMPIRBUIlder` (PR #93920)
https://github.com/ergawy closed https://github.com/llvm/llvm-project/pull/93920 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 7db4e6c - [OpenMP][LLVM] Update alloca IP after `PrivCB` in `OMPIRBUIlder` (#93920)
Author: Kareem Ergawy Date: 2024-06-05T05:13:47+02:00 New Revision: 7db4e6c1ec18785ad3f622556362d83c11d7efef URL: https://github.com/llvm/llvm-project/commit/7db4e6c1ec18785ad3f622556362d83c11d7efef DIFF: https://github.com/llvm/llvm-project/commit/7db4e6c1ec18785ad3f622556362d83c11d7efef.diff LOG: [OpenMP][LLVM] Update alloca IP after `PrivCB` in `OMPIRBUIlder` (#93920) Fixes a crash uncovered by [pr77666.f90](https://github.com/llvm/llvm-test-suite/blob/main/Fortran/gfortran/regression/gomp/pr77666.f90) in the test suite when delayed privatization is enabled by default. In particular, whenever `PrivCB` (the callback responsible for generating privatizaiton logic for an OMP variable) generates a multi-block privatization region, the insertion point diverges: the BB component of the IP can become a different BB from the parent block of the instruction iterator component of the IP. This PR updates the IP to make sure that the BB is the parent block of the instruction iterator. Added: flang/test/Lower/OpenMP/delayed-privatization-lower-allocatable-to-llvm.f90 Modified: clang/test/OpenMP/parallel_codegen.cpp llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp Removed: diff --git a/clang/test/OpenMP/parallel_codegen.cpp b/clang/test/OpenMP/parallel_codegen.cpp index d545b4a9d9fa8..9082f1c3232af 100644 --- a/clang/test/OpenMP/parallel_codegen.cpp +++ b/clang/test/OpenMP/parallel_codegen.cpp @@ -822,8 +822,8 @@ int main (int argc, char **argv) { // CHECK3-NEXT:[[TMP1:%.*]] = load i32, ptr [[TID_ADDR]], align 4 // CHECK3-NEXT:store i32 [[TMP1]], ptr [[TID_ADDR_LOCAL]], align 4 // CHECK3-NEXT:[[TID:%.*]] = load i32, ptr [[TID_ADDR_LOCAL]], align 4 -// CHECK3-NEXT:[[TMP2:%.*]] = load i64, ptr [[LOADGEP__RELOADED]], align 8 // CHECK3-NEXT:[[VAR:%.*]] = alloca ptr, align 8 +// CHECK3-NEXT:[[TMP2:%.*]] = load i64, ptr [[LOADGEP__RELOADED]], align 8 // CHECK3-NEXT:br label [[OMP_PAR_REGION:%.*]] // CHECK3: omp.par.region: // CHECK3-NEXT:[[TMP3:%.*]] = load ptr, ptr [[LOADGEP_ARGC_ADDR]], align 8 @@ -966,8 +966,8 @@ int main (int argc, char **argv) { // CHECK4-NEXT:[[TMP1:%.*]] = load i32, ptr [[TID_ADDR]], align 4 // CHECK4-NEXT:store i32 [[TMP1]], ptr [[TID_ADDR_LOCAL]], align 4 // CHECK4-NEXT:[[TID:%.*]] = load i32, ptr [[TID_ADDR_LOCAL]], align 4 -// CHECK4-NEXT:[[TMP2:%.*]] = load i64, ptr [[LOADGEP__RELOADED]], align 8 // CHECK4-NEXT:[[VAR:%.*]] = alloca ptr, align 8 +// CHECK4-NEXT:[[TMP2:%.*]] = load i64, ptr [[LOADGEP__RELOADED]], align 8 // CHECK4-NEXT:br label [[OMP_PAR_REGION:%.*]] // CHECK4: omp.par.region: // CHECK4-NEXT:[[TMP3:%.*]] = load ptr, ptr [[LOADGEP_ARGC_ADDR]], align 8, !dbg [[DBG58:![0-9]+]] diff --git a/flang/test/Lower/OpenMP/delayed-privatization-lower-allocatable-to-llvm.f90 b/flang/test/Lower/OpenMP/delayed-privatization-lower-allocatable-to-llvm.f90 new file mode 100644 index 0..ac9a6d8746cf2 --- /dev/null +++ b/flang/test/Lower/OpenMP/delayed-privatization-lower-allocatable-to-llvm.f90 @@ -0,0 +1,23 @@ +! Tests the OMPIRBuilder can handle multiple privatization regions that contain +! multiple BBs (for example, for allocatables). + +! RUN: %flang -S -emit-llvm -fopenmp -mmlir --openmp-enable-delayed-privatization \ +! RUN: -o - %s 2>&1 | FileCheck %s + +subroutine foo(x) + integer, allocatable :: x, y +!$omp parallel private(x, y) + x = y +!$omp end parallel +end + +! CHECK-LABEL: define void @foo_ +! CHECK: ret void +! CHECK-NEXT: } + +! CHECK-LABEL: define internal void @foo_..omp_par +! CHECK-DAG: call ptr @malloc +! CHECK-DAG: call ptr @malloc +! CHECK-DAG: call void @free +! CHECK-DAG: call void @free +! CHECK: } diff --git a/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp b/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp index cb4de9c8876dc..2c4b45255d059 100644 --- a/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp +++ b/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp @@ -1583,6 +1583,10 @@ IRBuilder<>::InsertPoint OpenMPIRBuilder::createParallel( } else { Builder.restoreIP( PrivCB(InnerAllocaIP, Builder.saveIP(), V, *Inner, ReplacementValue)); + InnerAllocaIP = { + InnerAllocaIP.getBlock(), + InnerAllocaIP.getBlock()->getTerminator()->getIterator()}; + assert(ReplacementValue && "Expected copy/create callback to set replacement value!"); if (ReplacementValue == &V) ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format] Allow open brace with trailing comment (no line break) (PR #89956)
owenca wrote: > @owenca Re. draft status: I thought a draft would be a better way (less > presumptuous, more tentative suggestion) to present one particular solution, > while acknowledging the possibility of alternatives. If that's not really the > way a draft is used or if it's more of a problem (e.g. people simply > filtering out drafts for whatever reason?) then I can remove the draftness; I > just didn't want to presume this change is the way to go. My understanding is that draft pull requests are not ready for review, so I have always ignored them. From https://github.blog/2019-02-14-introducing-draft-pull-requests/: > Also, if you have a [CODEOWNERS > file](https://github.blog/2017-07-06-introducing-code-owners/) in your > repository, a draft pull request will suppress notifications to those > reviewers until it is marked as ready for review. https://github.com/llvm/llvm-project/pull/89956 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clang-tidy] new check misc-use-internal-linkage (PR #90830)
@@ -0,0 +1,78 @@ +//===--- UseInternalLinkageCheck.cpp - clang-tidy--===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#include "UseInternalLinkageCheck.h" +#include "../utils/FileExtensionsUtils.h" +#include "clang/AST/Decl.h" +#include "clang/ASTMatchers/ASTMatchFinder.h" +#include "clang/ASTMatchers/ASTMatchers.h" +#include "clang/ASTMatchers/ASTMatchersMacros.h" +#include "clang/Basic/SourceLocation.h" +#include "clang/Basic/Specifiers.h" +#include "llvm/ADT/STLExtras.h" + +using namespace clang::ast_matchers; + +namespace clang::tidy::misc { + +namespace { + +AST_MATCHER(Decl, isFirstDecl) { return Node.isFirstDecl(); } + +AST_MATCHER_P(Decl, isInMainFile, FileExtensionsSet, HeaderFileExtensions) { + return llvm::all_of(Node.redecls(), [&](const Decl *D) { +SourceManager &SM = Finder->getASTContext().getSourceManager(); +const SourceLocation L = D->getLocation(); +return SM.isInMainFile(L) && + !utils::isSpellingLocInHeaderFile(L, SM, HeaderFileExtensions); + }); HerrCai0907 wrote: As a summary If main file include non-header file (*.inc, *.cpp, etc..), this check should treat it as main file. Then we just need to check there are no `redecl` in header file. https://github.com/llvm/llvm-project/pull/90830 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Reland "[Win32][ELF] Make CodeView a DebugInfoFormat only for COFF format", second try (PR #88245)
https://github.com/phoebewang closed https://github.com/llvm/llvm-project/pull/88245 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 99b2581 - Reland "[Win32][ELF] Make CodeView a DebugInfoFormat only for COFF format", second try (#88245)
Author: Phoebe Wang Date: 2024-06-05T09:56:08+08:00 New Revision: 99b2581a4b162b718925b791433faaa108745a90 URL: https://github.com/llvm/llvm-project/commit/99b2581a4b162b718925b791433faaa108745a90 DIFF: https://github.com/llvm/llvm-project/commit/99b2581a4b162b718925b791433faaa108745a90.diff LOG: Reland "[Win32][ELF] Make CodeView a DebugInfoFormat only for COFF format", second try (#88245) This is a second try to reland https://github.com/llvm/llvm-project/pull/87149. The previous commit exposed failures on some targets. The reason is only a few targets support COFF ObjectFormatType on Windows: https://github.com/llvm/llvm-project/blob/main/llvm/lib/TargetParser/Triple.cpp#L835-L842 With https://github.com/llvm/llvm-project/pull/87149, the targets don't support COFF will report "warning: argument unused during compilation: '-gcodeview-command-line' [-Wunused-command-line-argument]" in the test gcodeview-command-line.c I was thinking `REQUIRES: *-registered-target` could solve the problem, but it didn't. We need to check the actual triple instead of just `*-registered-target`. Added: clang/test/Misc/win32-elf.c Modified: clang/lib/Driver/ToolChains/MSVC.h clang/test/Driver/cl-options.c clang/test/Driver/cl-outputs.c clang/test/Driver/gcodeview-command-line.c clang/test/Driver/gcodeview-ghash.c Removed: diff --git a/clang/lib/Driver/ToolChains/MSVC.h b/clang/lib/Driver/ToolChains/MSVC.h index 48369e030aade..3950a8ed38e8b 100644 --- a/clang/lib/Driver/ToolChains/MSVC.h +++ b/clang/lib/Driver/ToolChains/MSVC.h @@ -61,9 +61,8 @@ class LLVM_LIBRARY_VISIBILITY MSVCToolChain : public ToolChain { /// formats, and to DWARF otherwise. Users can use -gcodeview and -gdwarf to /// override the default. llvm::codegenoptions::DebugInfoFormat getDefaultDebugFormat() const override { -return getTriple().isOSBinFormatMachO() - ? llvm::codegenoptions::DIF_DWARF - : llvm::codegenoptions::DIF_CodeView; +return getTriple().isOSBinFormatCOFF() ? llvm::codegenoptions::DIF_CodeView + : llvm::codegenoptions::DIF_DWARF; } /// Set the debugger tuning to "default", since we're definitely not tuning diff --git a/clang/test/Driver/cl-options.c b/clang/test/Driver/cl-options.c index 733f243d3c69b..2c17459dde656 100644 --- a/clang/test/Driver/cl-options.c +++ b/clang/test/Driver/cl-options.c @@ -549,15 +549,15 @@ // RTTI-NOT: "-fno-rtti-data" // RTTI-NOT: "-fno-rtti" -// RUN: %clang_cl /Zi /c -### -- %s 2>&1 | FileCheck -check-prefix=Zi %s +// RUN: %clang_cl -target x86_64-windows /Zi /c -### -- %s 2>&1 | FileCheck -check-prefix=Zi %s // Zi: "-gcodeview" // Zi: "-debug-info-kind=constructor" -// RUN: %clang_cl /Z7 /c -### -- %s 2>&1 | FileCheck -check-prefix=Z7 %s +// RUN: %clang_cl -target x86_64-windows /Z7 /c -### -- %s 2>&1 | FileCheck -check-prefix=Z7 %s // Z7: "-gcodeview" // Z7: "-debug-info-kind=constructor" -// RUN: %clang_cl -gline-tables-only /c -### -- %s 2>&1 | FileCheck -check-prefix=ZGMLT %s +// RUN: %clang_cl -target x86_64-windows -gline-tables-only /c -### -- %s 2>&1 | FileCheck -check-prefix=ZGMLT %s // ZGMLT: "-gcodeview" // ZGMLT: "-debug-info-kind=line-tables-only" diff --git a/clang/test/Driver/cl-outputs.c b/clang/test/Driver/cl-outputs.c index 4298657ac49f5..a8509e795c295 100644 --- a/clang/test/Driver/cl-outputs.c +++ b/clang/test/Driver/cl-outputs.c @@ -298,15 +298,15 @@ // FioRACE2: "-E" // FioRACE2: "-o" "foo.x" -// RUN: %clang_cl /Z7 /Foa.obj -### -- %s 2>&1 | FileCheck -check-prefix=ABSOLUTE_OBJPATH %s +// RUN: %clang_cl -target x86_64-windows /Z7 /Foa.obj -### -- %s 2>&1 | FileCheck -check-prefix=ABSOLUTE_OBJPATH %s // ABSOLUTE_OBJPATH: "-object-file-name={{.*}}a.obj" -// RUN: %clang_cl -fdebug-compilation-dir=. /Z7 /Foa.obj -### -- %s 2>&1 | FileCheck -check-prefix=RELATIVE_OBJPATH1 %s +// RUN: %clang_cl -target x86_64-windows -fdebug-compilation-dir=. /Z7 /Foa.obj -### -- %s 2>&1 | FileCheck -check-prefix=RELATIVE_OBJPATH1 %s // RELATIVE_OBJPATH1: "-object-file-name=a.obj" -// RUN: %clang_cl -fdebug-compilation-dir=. /Z7 /Fo:a.obj -### -- %s 2>&1 | FileCheck -check-prefix=RELATIVE_OBJPATH1_COLON %s -// RUN: %clang_cl -fdebug-compilation-dir=. /Z7 /Fo: a.obj -### -- %s 2>&1 | FileCheck -check-prefix=RELATIVE_OBJPATH1_COLON %s +// RUN: %clang_cl -target x86_64-windows -fdebug-compilation-dir=. /Z7 /Fo:a.obj -### -- %s 2>&1 | FileCheck -check-prefix=RELATIVE_OBJPATH1_COLON %s +// RUN: %clang_cl -target x86_64-windows -fdebug-compilation-dir=. /Z7 /Fo: a.obj -### -- %s 2>&1 | FileCheck -check-prefix=RELATIVE_OBJPATH1_COLON %s // RELATIVE_OBJPATH1_COLON: "-object-file-name=a.obj" -// RUN: %clang_cl -fdebug-compilation-dir=. /Z7 /Fofoo/a.obj -### -- %s 2>&1 | FileCheck -check-prefix=RELATIVE_OBJPATH2 %s +// RUN: %clang_cl -target x86_64-window
[clang] [compiler-rt] [compiler-rt] Realtime Sanitizer: Introduce Realtime Sanitizer (RTSan) backend (PR #92460)
@@ -1509,6 +1511,11 @@ void DarwinClang::AddLinkRuntimeLibArgs(const ArgList &Args, AddLinkSanitizerLibArgs(Args, CmdArgs, "asan"); } vitalybuka wrote: Driver needs tests https://github.com/llvm/llvm-project/pull/92460 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [compiler-rt] [compiler-rt] Realtime Sanitizer: Introduce Realtime Sanitizer (RTSan) backend (PR #92460)
vitalybuka wrote: If you want another round, make sure to click `re-request review` https://github.com/llvm/llvm-project/pull/92460 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Reland "[Win32][ELF] Make CodeView a DebugInfoFormat only for COFF format", second try (PR #88245)
@@ -5,15 +5,15 @@ // NO_GHASH-NOT: "-gcodeview-ghash" // default -// RUN: %clang_cl /Z7 -### -- %s 2>&1 | FileCheck -check-prefix=NO_GHASH %s +// RUN: %clang_cl -target x86_64-windows /Z7 -### -- %s 2>&1 | FileCheck -check-prefix=NO_GHASH %s // enabled -// RUN: %clang_cl /Z7 -gcodeview-ghash -### -- %s 2>&1 | FileCheck -check-prefix=GHASH %s +// RUN: %clang_cl -target x86_64-windows /Z7 -gcodeview-ghash -### -- %s 2>&1 | FileCheck -check-prefix=GHASH %s // disabled -// RUN: %clang_cl /Z7 -gcodeview-ghash -gno-codeview-ghash -### -- %s 2>&1 | FileCheck -check-prefix=NO_GHASH %s +// RUN: %clang_cl -target x86_64-windows /Z7 -gcodeview-ghash -gno-codeview-ghash -### -- %s 2>&1 | FileCheck -check-prefix=NO_GHASH %s // enabled, no /Z7 -// RUN: %clang_cl -gcodeview-ghash -### -- %s 2>&1 | FileCheck -check-prefix=NO_GHASH %s +// RUN: %clang_cl -target x86_64-windows -gcodeview-ghash -### -- %s 2>&1 | FileCheck -check-prefix=NO_GHASH %s // GCC-style driver -// RUN: %clang -g -gcodeview -gcodeview-ghash -### -- %s 2>&1 | FileCheck -check-prefix=GHASH %s -// RUN: %clang -g -gcodeview -gcodeview-ghash -gno-codeview-ghash -### -- %s 2>&1 | FileCheck -check-prefix=NO_GHASH %s +// RUN: %clang -target x86_64-windows -g -gcodeview -gcodeview-ghash -### -- %s 2>&1 | FileCheck -check-prefix=GHASH %s phoebewang wrote: Not only clang driver, but also clang-cl. The root cause is many target don't set BinFormat to COFF on Windows. This probably because they don't support Windows at all, but we need to exclude them to run this test to avoid the unused-command-line-argument warning. https://github.com/llvm/llvm-project/pull/88245 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Reland "[Win32][ELF] Make CodeView a DebugInfoFormat only for COFF format", second try (PR #88245)
@@ -298,15 +298,15 @@ // FioRACE2: "-E" // FioRACE2: "-o" "foo.x" -// RUN: %clang_cl /Z7 /Foa.obj -### -- %s 2>&1 | FileCheck -check-prefix=ABSOLUTE_OBJPATH %s +// RUN: %clang_cl -target x86_64-windows /Z7 /Foa.obj -### -- %s 2>&1 | FileCheck -check-prefix=ABSOLUTE_OBJPATH %s phoebewang wrote: Yes, the key is `x86_64` here, but I feel safe to add the `windows` together :) https://github.com/llvm/llvm-project/pull/88245 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][RISCV] Update vcpop.v C interface to follow the nameing convention (PR #94318)
https://github.com/kito-cheng approved this pull request. https://github.com/llvm/llvm-project/pull/94318 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][RISCV] Update vcpop.v C interface to follow the nameing convention (PR #94318)
4vtomat wrote: > Could you give few more word on the description to mention we missed that in > the vector crpyto intrinsic proposal, and it's fixing but rather than > incompatible/breaking change for the intrinsic API? Updated description. We are missing `vcpop.v` in the rvv_intrinsic_doc, so I think we don't break anything lol~ https://github.com/llvm/llvm-project/pull/94318 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][RISCV] Update vcpop.v C interface to follow the nameing convention (PR #94318)
https://github.com/4vtomat edited https://github.com/llvm/llvm-project/pull/94318 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][RISCV] Update vcpop.v C interface to follow the nameing convention (PR #94318)
https://github.com/4vtomat edited https://github.com/llvm/llvm-project/pull/94318 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-tools-extra] [compiler-rt] [flang] [llvm] [BOLT][BAT] Add support for three-way split functions (PR #93760)
https://github.com/aaupov edited https://github.com/llvm/llvm-project/pull/93760 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] clang/utils/TableGen/ClangAttrEmitter.cpp: 2 * pointless copy ? (#94372) (PR #94414)
llvmbot wrote: @llvm/pr-subscribers-clang Author: None (akshaykumars614) Changes modified parameter for code quality --- Full diff: https://github.com/llvm/llvm-project/pull/94414.diff 1 Files Affected: - (modified) clang/utils/TableGen/ClangAttrEmitter.cpp (+3-3) ``diff diff --git a/clang/utils/TableGen/ClangAttrEmitter.cpp b/clang/utils/TableGen/ClangAttrEmitter.cpp index ca7630adfbb7b..fcc3763b00380 100644 --- a/clang/utils/TableGen/ClangAttrEmitter.cpp +++ b/clang/utils/TableGen/ClangAttrEmitter.cpp @@ -394,8 +394,8 @@ namespace { public: DefaultSimpleArgument(const Record &Arg, StringRef Attr, - std::string T, int64_t Default) - : SimpleArgument(Arg, Attr, T), Default(Default) {} + const std::string &T, int64_t Default) +: SimpleArgument(Arg, Attr, T), Default(Default) {} void writeAccessors(raw_ostream &OS) const override { SimpleArgument::writeAccessors(OS); @@ -4994,7 +4994,7 @@ class SpellingList { return Spellings[(size_t)K]; } - void add(const Record &Attr, FlattenedSpelling Spelling) { + void add(const Record &Attr, const FlattenedSpelling &Spelling) { SpellingKind Kind = StringSwitch(Spelling.variety()) .Case("GNU", SpellingKind::GNU) `` https://github.com/llvm/llvm-project/pull/94414 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] clang/utils/TableGen/ClangAttrEmitter.cpp: 2 * pointless copy ? (#94372) (PR #94414)
https://github.com/akshaykumars614 created https://github.com/llvm/llvm-project/pull/94414 modified parameter for code quality >From f4dd886d3a33401865f03a4ca086f6f1f0332293 Mon Sep 17 00:00:00 2001 From: akshaykumars614 Date: Tue, 4 Jun 2024 19:25:10 -0400 Subject: [PATCH] clang/utils/TableGen/ClangAttrEmitter.cpp: 2 * pointless copy ? (#94372) modified parameter for code quality --- clang/utils/TableGen/ClangAttrEmitter.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/clang/utils/TableGen/ClangAttrEmitter.cpp b/clang/utils/TableGen/ClangAttrEmitter.cpp index ca7630adfbb7b..fcc3763b00380 100644 --- a/clang/utils/TableGen/ClangAttrEmitter.cpp +++ b/clang/utils/TableGen/ClangAttrEmitter.cpp @@ -394,8 +394,8 @@ namespace { public: DefaultSimpleArgument(const Record &Arg, StringRef Attr, - std::string T, int64_t Default) - : SimpleArgument(Arg, Attr, T), Default(Default) {} + const std::string &T, int64_t Default) +: SimpleArgument(Arg, Attr, T), Default(Default) {} void writeAccessors(raw_ostream &OS) const override { SimpleArgument::writeAccessors(OS); @@ -4994,7 +4994,7 @@ class SpellingList { return Spellings[(size_t)K]; } - void add(const Record &Attr, FlattenedSpelling Spelling) { + void add(const Record &Attr, const FlattenedSpelling &Spelling) { SpellingKind Kind = StringSwitch(Spelling.variety()) .Case("GNU", SpellingKind::GNU) ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] clang/utils/TableGen/ClangOptionDocEmitter.cpp:220: Pointless string copy ? (#94373) (PR #94413)
llvmbot wrote: @llvm/pr-subscribers-clang Author: None (akshaykumars614) Changes modified parameter for code quality --- Full diff: https://github.com/llvm/llvm-project/pull/94413.diff 1 Files Affected: - (modified) clang/utils/TableGen/ClangOptionDocEmitter.cpp (+1-1) ``diff diff --git a/clang/utils/TableGen/ClangOptionDocEmitter.cpp b/clang/utils/TableGen/ClangOptionDocEmitter.cpp index 86835611b8421..d0cb7f203c231 100644 --- a/clang/utils/TableGen/ClangOptionDocEmitter.cpp +++ b/clang/utils/TableGen/ClangOptionDocEmitter.cpp @@ -217,7 +217,7 @@ bool canSphinxCopeWithOption(const Record *Option) { return false; } -void emitHeading(int Depth, std::string Heading, raw_ostream &OS) { +void emitHeading(int Depth, const std::string &Heading, raw_ostream &OS) { assert(Depth < 8 && "groups nested too deeply"); OS << Heading << '\n' << std::string(Heading.size(), "=~-_'+<>"[Depth]) << "\n"; `` https://github.com/llvm/llvm-project/pull/94413 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] clang/utils/TableGen/ClangOptionDocEmitter.cpp:220: Pointless string copy ? (#94373) (PR #94413)
https://github.com/akshaykumars614 created https://github.com/llvm/llvm-project/pull/94413 modified parameter for code quality >From d07d360dcb00a4e6710c177b79ca4d76a5a863d3 Mon Sep 17 00:00:00 2001 From: akshaykumars614 Date: Tue, 4 Jun 2024 19:21:25 -0400 Subject: [PATCH] clang/utils/TableGen/ClangOptionDocEmitter.cpp:220: Pointless string copy ? (#94373) modified parameter for code quality --- clang/utils/TableGen/ClangOptionDocEmitter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clang/utils/TableGen/ClangOptionDocEmitter.cpp b/clang/utils/TableGen/ClangOptionDocEmitter.cpp index 86835611b8421..d0cb7f203c231 100644 --- a/clang/utils/TableGen/ClangOptionDocEmitter.cpp +++ b/clang/utils/TableGen/ClangOptionDocEmitter.cpp @@ -217,7 +217,7 @@ bool canSphinxCopeWithOption(const Record *Option) { return false; } -void emitHeading(int Depth, std::string Heading, raw_ostream &OS) { +void emitHeading(int Depth, const std::string &Heading, raw_ostream &OS) { assert(Depth < 8 && "groups nested too deeply"); OS << Heading << '\n' << std::string(Heading.size(), "=~-_'+<>"[Depth]) << "\n"; ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] clang/utils/TableGen/NeonEmitter.cpp:1058: pointless string copy ? (#94375) (PR #94408)
https://github.com/akshaykumars614 updated https://github.com/llvm/llvm-project/pull/94408 >From a018f2598f860498711cc46dcb41916d11127f15 Mon Sep 17 00:00:00 2001 From: akshaykumars614 Date: Tue, 4 Jun 2024 18:59:05 -0400 Subject: [PATCH 1/2] clang/utils/TableGen/NeonEmitter.cpp:1058: pointless string copy ? (#94375) modified parameter for code quality --- clang/utils/TableGen/NeonEmitter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clang/utils/TableGen/NeonEmitter.cpp b/clang/utils/TableGen/NeonEmitter.cpp index 56f1fdf9ef574..3f06e88c95ef5 100644 --- a/clang/utils/TableGen/NeonEmitter.cpp +++ b/clang/utils/TableGen/NeonEmitter.cpp @@ -1055,7 +1055,7 @@ std::string Intrinsic::getMangledName(bool ForceClassS) const { return mangleName(Name, ForceClassS ? ClassS : LocalCK); } -std::string Intrinsic::mangleName(std::string Name, ClassKind LocalCK) const { +std::string Intrinsic::mangleName( const std::string & Name, ClassKind LocalCK) const { std::string typeCode = getInstTypeCode(BaseType, LocalCK); std::string S = Name; >From d96629ea0dc40edca299d42f801721f30ea0b14d Mon Sep 17 00:00:00 2001 From: akshaykumars614 Date: Tue, 4 Jun 2024 19:11:59 -0400 Subject: [PATCH 2/2] clang/utils/TableGen/NeonEmitter.cpp:1058: pointless string copy ? (#94375) modified parameter for code quality --- clang/utils/TableGen/NeonEmitter.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/clang/utils/TableGen/NeonEmitter.cpp b/clang/utils/TableGen/NeonEmitter.cpp index 3f06e88c95ef5..ca8f42eb58970 100644 --- a/clang/utils/TableGen/NeonEmitter.cpp +++ b/clang/utils/TableGen/NeonEmitter.cpp @@ -1055,7 +1055,8 @@ std::string Intrinsic::getMangledName(bool ForceClassS) const { return mangleName(Name, ForceClassS ? ClassS : LocalCK); } -std::string Intrinsic::mangleName( const std::string & Name, ClassKind LocalCK) const { +std::string Intrinsic::mangleName(const std::string &Name, + ClassKind LocalCK) const { std::string typeCode = getInstTypeCode(BaseType, LocalCK); std::string S = Name; ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] clang/utils/TableGen/NeonEmitter.cpp:1058: pointless string copy ? (#94375) (PR #94408)
github-actions[bot] wrote: :warning: C/C++ code formatter, clang-format found issues in your code. :warning: You can test this locally with the following command: ``bash git-clang-format --diff 0360d03240f59e6b26a16769943f905c9520fe04 a018f2598f860498711cc46dcb41916d11127f15 -- clang/utils/TableGen/NeonEmitter.cpp `` View the diff from clang-format here. ``diff diff --git a/clang/utils/TableGen/NeonEmitter.cpp b/clang/utils/TableGen/NeonEmitter.cpp index 3f06e88c95..ca8f42eb58 100644 --- a/clang/utils/TableGen/NeonEmitter.cpp +++ b/clang/utils/TableGen/NeonEmitter.cpp @@ -1055,7 +1055,8 @@ std::string Intrinsic::getMangledName(bool ForceClassS) const { return mangleName(Name, ForceClassS ? ClassS : LocalCK); } -std::string Intrinsic::mangleName( const std::string & Name, ClassKind LocalCK) const { +std::string Intrinsic::mangleName(const std::string &Name, + ClassKind LocalCK) const { std::string typeCode = getInstTypeCode(BaseType, LocalCK); std::string S = Name; `` https://github.com/llvm/llvm-project/pull/94408 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] clang/utils/TableGen/NeonEmitter.cpp:1058: pointless string copy ? (#94375) (PR #94408)
llvmbot wrote: @llvm/pr-subscribers-clang Author: None (akshaykumars614) Changes modified parameter for code quality --- Full diff: https://github.com/llvm/llvm-project/pull/94408.diff 1 Files Affected: - (modified) clang/utils/TableGen/NeonEmitter.cpp (+1-1) ``diff diff --git a/clang/utils/TableGen/NeonEmitter.cpp b/clang/utils/TableGen/NeonEmitter.cpp index 56f1fdf9ef574..3f06e88c95ef5 100644 --- a/clang/utils/TableGen/NeonEmitter.cpp +++ b/clang/utils/TableGen/NeonEmitter.cpp @@ -1055,7 +1055,7 @@ std::string Intrinsic::getMangledName(bool ForceClassS) const { return mangleName(Name, ForceClassS ? ClassS : LocalCK); } -std::string Intrinsic::mangleName(std::string Name, ClassKind LocalCK) const { +std::string Intrinsic::mangleName( const std::string & Name, ClassKind LocalCK) const { std::string typeCode = getInstTypeCode(BaseType, LocalCK); std::string S = Name; `` https://github.com/llvm/llvm-project/pull/94408 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] clang/utils/TableGen/NeonEmitter.cpp:1058: pointless string copy ? (#94375) (PR #94408)
https://github.com/akshaykumars614 created https://github.com/llvm/llvm-project/pull/94408 modified parameter for code quality >From a018f2598f860498711cc46dcb41916d11127f15 Mon Sep 17 00:00:00 2001 From: akshaykumars614 Date: Tue, 4 Jun 2024 18:59:05 -0400 Subject: [PATCH] clang/utils/TableGen/NeonEmitter.cpp:1058: pointless string copy ? (#94375) modified parameter for code quality --- clang/utils/TableGen/NeonEmitter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clang/utils/TableGen/NeonEmitter.cpp b/clang/utils/TableGen/NeonEmitter.cpp index 56f1fdf9ef574..3f06e88c95ef5 100644 --- a/clang/utils/TableGen/NeonEmitter.cpp +++ b/clang/utils/TableGen/NeonEmitter.cpp @@ -1055,7 +1055,7 @@ std::string Intrinsic::getMangledName(bool ForceClassS) const { return mangleName(Name, ForceClassS ? ClassS : LocalCK); } -std::string Intrinsic::mangleName(std::string Name, ClassKind LocalCK) const { +std::string Intrinsic::mangleName( const std::string & Name, ClassKind LocalCK) const { std::string typeCode = getInstTypeCode(BaseType, LocalCK); std::string S = Name; ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [Clang][Sanitizers] Add numerical sanitizer (PR #93783)
@@ -826,6 +826,10 @@ SanitizerMask Linux::getSupportedSanitizers() const { if (IsX86_64 || IsAArch64) { Res |= SanitizerKind::KernelHWAddress; } + if (IsX86_64) { +Res |= SanitizerKind::NumericalStability; MaskRay wrote: This needs a `fsanitize-*.c` clang/test/Driver test https://github.com/llvm/llvm-project/pull/93783 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [Clang][Sanitizers] Add numerical sanitizer (PR #93783)
https://github.com/MaskRay approved this pull request. https://github.com/llvm/llvm-project/pull/93783 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [Clang][Sanitizers] Add numerical sanitizer (PR #93783)
@@ -826,6 +826,10 @@ SanitizerMask Linux::getSupportedSanitizers() const { if (IsX86_64 || IsAArch64) { Res |= SanitizerKind::KernelHWAddress; } + if (IsX86_64) { +Res |= SanitizerKind::NumericalStability; MaskRay wrote: drop braces for single-line simple statement https://github.com/llvm/llvm-project/pull/93783 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [Clang][Sanitizers] Add numerical sanitizer (PR #93783)
https://github.com/MaskRay edited https://github.com/llvm/llvm-project/pull/93783 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Safe Buffers] Serialize unsafe_buffer_usage pragmas (PR #92031)
https://github.com/ziqingluo-90 edited https://github.com/llvm/llvm-project/pull/92031 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [WIP][Safe Buffers] Serialize unsafe_buffer_usage pragmas (PR #92031)
ziqingluo-90 wrote: Learned more about how loaded files & ASTs are managed in clang. Now opt-out regions in a loaded AST can span over multiple files (within one TU). They now behave in a consistent way when they are from loaded files or local files. https://github.com/llvm/llvm-project/pull/92031 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [lldb] [llvm] Refactor GDB Index into a new file (PR #94405)
https://github.com/sayhaan updated https://github.com/llvm/llvm-project/pull/94405 >From f3533c92b6b64f50a933a9eb2f9cc4229bbd8da3 Mon Sep 17 00:00:00 2001 From: Amir Ayupov Date: Tue, 1 Jun 2021 11:37:41 -0700 Subject: [PATCH 1/2] Rebase: [Facebook] Add clang driver options to test debug info and BOLT Summary: This is an essential piece of infrastructure for us to be continuously testing debug info with BOLT. We can't only make changes to a test repo because we need to change debuginfo tests to call BOLT, hence, this diff needs to sit in our opensource repo. But when upstreaming to LLVM, this should be kept BOLT-only outside of LLVM. When upstreaming, we need to git diff and check all folders that are being modified by our commits and discard this one (and leave as an internal diff). To test BOLT in debuginfo tests, configure it with -DLLVM_TEST_BOLT=ON. Then run check-lldb and check-debuginfo. Manual rebase conflict history: https://phabricator.intern.facebook.com/D29205224 https://phabricator.intern.facebook.com/D29564078 https://phabricator.intern.facebook.com/D33289118 https://phabricator.intern.facebook.com/D34957174 https://phabricator.intern.facebook.com/D35317341 Test Plan: tested locally Configured with: -DLLVM_ENABLE_PROJECTS="clang;lld;lldb;compiler-rt;bolt;debuginfo-tests" -DLLVM_TEST_BOLT=ON Ran test suite with: ninja check-debuginfo ninja check-lldb Reviewers: maks, #llvm-bolt Reviewed By: maks Subscribers: ayermolo, phabricatorlinter Differential Revision: https://phabricator.intern.facebook.com/D46256657 Tasks: T92898286 --- clang/include/clang/Driver/Options.td | 4 clang/lib/Driver/ToolChains/Gnu.cpp| 29 ++ cross-project-tests/lit.cfg.py | 14 - cross-project-tests/lit.site.cfg.py.in | 4 lldb/test/API/lit.cfg.py | 5 + lldb/test/API/lit.site.cfg.py.in | 8 +++ lldb/test/Shell/helper/toolchain.py| 5 + lldb/test/Shell/lit.site.cfg.py.in | 9 llvm/CMakeLists.txt| 4 9 files changed, 81 insertions(+), 1 deletion(-) diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index 57f37c5023110f..7469db06839e3b 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -5465,6 +5465,10 @@ def pg : Flag<["-"], "pg">, HelpText<"Enable mcount instrumentation">, MarshallingInfoFlag>; def pipe : Flag<["-", "--"], "pipe">, HelpText<"Use pipes between commands, when possible">; +// Facebook T92898286 +def post_link_optimize : Flag<["--"], "post-link-optimize">, + HelpText<"Apply post-link optimizations using BOLT">; +// End Facebook T92898286 def prebind__all__twolevel__modules : Flag<["-"], "prebind_all_twolevel_modules">; def prebind : Flag<["-"], "prebind">; def preload : Flag<["-"], "preload">; diff --git a/clang/lib/Driver/ToolChains/Gnu.cpp b/clang/lib/Driver/ToolChains/Gnu.cpp index b141e5f2adfab1..f7611af5763ab7 100644 --- a/clang/lib/Driver/ToolChains/Gnu.cpp +++ b/clang/lib/Driver/ToolChains/Gnu.cpp @@ -672,12 +672,41 @@ void tools::gnutools::Linker::ConstructJob(Compilation &C, const JobAction &JA, } } + // Facebook T92898286 + if (Args.hasArg(options::OPT_post_link_optimize)) +CmdArgs.push_back("-q"); + // End Facebook T92898286 + Args.AddAllArgs(CmdArgs, options::OPT_T); const char *Exec = Args.MakeArgString(ToolChain.GetLinkerPath()); C.addCommand(std::make_unique(JA, *this, ResponseFileSupport::AtFileCurCP(), Exec, CmdArgs, Inputs, Output)); + // Facebook T92898286 + if (!Args.hasArg(options::OPT_post_link_optimize) || !Output.isFilename()) +return; + + const char *MvExec = Args.MakeArgString(ToolChain.GetProgramPath("mv")); + ArgStringList MoveCmdArgs; + MoveCmdArgs.push_back(Output.getFilename()); + const char *PreBoltBin = + Args.MakeArgString(Twine(Output.getFilename()) + ".pre-bolt"); + MoveCmdArgs.push_back(PreBoltBin); + C.addCommand(std::make_unique(JA, *this, ResponseFileSupport::None(), + MvExec, MoveCmdArgs, std::nullopt)); + + ArgStringList BoltCmdArgs; + const char *BoltExec = + Args.MakeArgString(ToolChain.GetProgramPath("llvm-bolt")); + BoltCmdArgs.push_back(PreBoltBin); + BoltCmdArgs.push_back("-reorder-blocks=reverse"); + BoltCmdArgs.push_back("-update-debug-sections"); + BoltCmdArgs.push_back("-o"); + BoltCmdArgs.push_back(Output.getFilename()); + C.addCommand(std::make_unique(JA, *this, ResponseFileSupport::None(), + BoltExec, BoltCmdArgs, std::nullopt)); + // End Facebook T92898286 } void tools::gnutools::Assembler::ConstructJob(Compilation &C, diff --git a/cross-project-tests/lit.cfg.py b/cross-project-tests/lit.cfg.py index 774c4eaf4d976b..619634578dfe60 100644 --- a/cross-project-tests/lit.cfg.py +
[clang] [lldb] [llvm] Refactor GDB Index into a new file (PR #94405)
llvmbot wrote: @llvm/pr-subscribers-clang Author: Sayhaan Siddiqui (sayhaan) Changes Create a new class and file for functions that update GDB index. --- Patch is 40.93 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/94405.diff 24 Files Affected: - (added) bolt/include/bolt/Core/GDBIndex.h (+60) - (modified) bolt/lib/Core/BinaryEmitter.cpp (+1) - (modified) bolt/lib/Core/CMakeLists.txt (+1) - (added) bolt/lib/Core/GDBIndex.cpp (+182) - (modified) bolt/lib/Passes/ValidateMemRefs.cpp (+5-6) - (modified) clang/include/clang/Driver/Options.td (+4) - (modified) clang/lib/Driver/ToolChains/Gnu.cpp (+29) - (modified) cross-project-tests/lit.cfg.py (+13-1) - (modified) cross-project-tests/lit.site.cfg.py.in (+4) - (modified) lldb/test/API/lit.cfg.py (+5) - (modified) lldb/test/API/lit.site.cfg.py.in (+8) - (modified) lldb/test/Shell/helper/toolchain.py (+5) - (modified) lldb/test/Shell/lit.site.cfg.py.in (+9) - (modified) llvm/CMakeLists.txt (+4) - (modified) llvm/include/llvm/MC/MCFragment.h (+22) - (modified) llvm/include/llvm/MC/MCObjectStreamer.h (+2) - (modified) llvm/include/llvm/MC/MCStreamer.h (+6) - (modified) llvm/lib/MC/MCAssembler.cpp (+81-37) - (modified) llvm/lib/MC/MCExpr.cpp (+2-8) - (modified) llvm/lib/MC/MCFragment.cpp (+12) - (modified) llvm/lib/MC/MCObjectStreamer.cpp (+5) - (modified) llvm/lib/MC/MCStreamer.cpp (+2) - (modified) llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp (+24) - (added) llvm/test/MC/X86/directive-avoid_end_align.s (+208) ``diff diff --git a/bolt/include/bolt/Core/GDBIndex.h b/bolt/include/bolt/Core/GDBIndex.h new file mode 100644 index 00..0ea588e9cba465 --- /dev/null +++ b/bolt/include/bolt/Core/GDBIndex.h @@ -0,0 +1,60 @@ +//===-- bolt/Core/GDBIndex.h - GDB Index support ---*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// +/// +/// This file contains declaration of classes required for generation of +/// .gdb_index section. +/// +//===--===// + +#ifndef BOLT_CORE_GDB_INDEX_H +#define BOLT_CORE_GDB_INDEX_H + +#include "bolt/Core/BinaryContext.h" +#include + +namespace llvm { +namespace bolt { + +class GDBIndex { +public: + /// Contains information about TU so we can write out correct entries in GDB + /// index. + struct GDBIndexTUEntry { +uint64_t UnitOffset; +uint64_t TypeHash; +uint64_t TypeDIERelativeOffset; + }; + +private: + BinaryContext &BC; + + /// Entries for GDB Index Types CU List + using GDBIndexTUEntryType = std::vector; + GDBIndexTUEntryType GDBIndexTUEntryVector; + +public: + GDBIndex(BinaryContext &BC) : BC(BC) {} + + /// Adds an GDBIndexTUEntry if .gdb_index section exists. + void addGDBTypeUnitEntry(const GDBIndexTUEntry &Entry); + + /// Rewrite .gdb_index section if present. + void updateGdbIndexSection( + CUOffsetMap &CUMap, uint32_t NumCUs, + std::unique_ptr &ARangesSectionWriter); + + /// Returns all entries needed for Types CU list + const GDBIndexTUEntryType &getGDBIndexTUEntryVector() const { +return GDBIndexTUEntryVector; + } +}; + +} // namespace bolt +} // namespace llvm + +#endif diff --git a/bolt/lib/Core/BinaryEmitter.cpp b/bolt/lib/Core/BinaryEmitter.cpp index 0b44acb0816f2f..e09b9ff92de064 100644 --- a/bolt/lib/Core/BinaryEmitter.cpp +++ b/bolt/lib/Core/BinaryEmitter.cpp @@ -485,6 +485,7 @@ void BinaryEmitter::emitFunctionBody(BinaryFunction &BF, FunctionFragment &FF, // This assumes the second instruction in the macro-op pair will get // assigned to its own MCRelaxableFragment. Since all JCC instructions // are relaxable, we should be safe. +Streamer.emitNeverAlignCodeAtEnd(/*Alignment to avoid=*/64, *BC.STI); } if (!EmitCodeOnly) { diff --git a/bolt/lib/Core/CMakeLists.txt b/bolt/lib/Core/CMakeLists.txt index 441df9fe084648..873cf67a56291f 100644 --- a/bolt/lib/Core/CMakeLists.txt +++ b/bolt/lib/Core/CMakeLists.txt @@ -25,6 +25,7 @@ add_llvm_library(LLVMBOLTCore DynoStats.cpp Exceptions.cpp FunctionLayout.cpp + GDBIndex.cpp HashUtilities.cpp JumpTable.cpp MCPlusBuilder.cpp diff --git a/bolt/lib/Core/GDBIndex.cpp b/bolt/lib/Core/GDBIndex.cpp new file mode 100644 index 00..fda19a2c8cb3ef --- /dev/null +++ b/bolt/lib/Core/GDBIndex.cpp @@ -0,0 +1,182 @@ +//===- bolt/Rewrite/GDBIndex.cpp -===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===
[clang] [lldb] [llvm] Refactor GDB Index into a new file (PR #94405)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Sayhaan Siddiqui (sayhaan) Changes Create a new class and file for functions that update GDB index. --- Patch is 40.93 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/94405.diff 24 Files Affected: - (added) bolt/include/bolt/Core/GDBIndex.h (+60) - (modified) bolt/lib/Core/BinaryEmitter.cpp (+1) - (modified) bolt/lib/Core/CMakeLists.txt (+1) - (added) bolt/lib/Core/GDBIndex.cpp (+182) - (modified) bolt/lib/Passes/ValidateMemRefs.cpp (+5-6) - (modified) clang/include/clang/Driver/Options.td (+4) - (modified) clang/lib/Driver/ToolChains/Gnu.cpp (+29) - (modified) cross-project-tests/lit.cfg.py (+13-1) - (modified) cross-project-tests/lit.site.cfg.py.in (+4) - (modified) lldb/test/API/lit.cfg.py (+5) - (modified) lldb/test/API/lit.site.cfg.py.in (+8) - (modified) lldb/test/Shell/helper/toolchain.py (+5) - (modified) lldb/test/Shell/lit.site.cfg.py.in (+9) - (modified) llvm/CMakeLists.txt (+4) - (modified) llvm/include/llvm/MC/MCFragment.h (+22) - (modified) llvm/include/llvm/MC/MCObjectStreamer.h (+2) - (modified) llvm/include/llvm/MC/MCStreamer.h (+6) - (modified) llvm/lib/MC/MCAssembler.cpp (+81-37) - (modified) llvm/lib/MC/MCExpr.cpp (+2-8) - (modified) llvm/lib/MC/MCFragment.cpp (+12) - (modified) llvm/lib/MC/MCObjectStreamer.cpp (+5) - (modified) llvm/lib/MC/MCStreamer.cpp (+2) - (modified) llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp (+24) - (added) llvm/test/MC/X86/directive-avoid_end_align.s (+208) ``diff diff --git a/bolt/include/bolt/Core/GDBIndex.h b/bolt/include/bolt/Core/GDBIndex.h new file mode 100644 index 00..0ea588e9cba465 --- /dev/null +++ b/bolt/include/bolt/Core/GDBIndex.h @@ -0,0 +1,60 @@ +//===-- bolt/Core/GDBIndex.h - GDB Index support ---*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// +/// +/// This file contains declaration of classes required for generation of +/// .gdb_index section. +/// +//===--===// + +#ifndef BOLT_CORE_GDB_INDEX_H +#define BOLT_CORE_GDB_INDEX_H + +#include "bolt/Core/BinaryContext.h" +#include + +namespace llvm { +namespace bolt { + +class GDBIndex { +public: + /// Contains information about TU so we can write out correct entries in GDB + /// index. + struct GDBIndexTUEntry { +uint64_t UnitOffset; +uint64_t TypeHash; +uint64_t TypeDIERelativeOffset; + }; + +private: + BinaryContext &BC; + + /// Entries for GDB Index Types CU List + using GDBIndexTUEntryType = std::vector; + GDBIndexTUEntryType GDBIndexTUEntryVector; + +public: + GDBIndex(BinaryContext &BC) : BC(BC) {} + + /// Adds an GDBIndexTUEntry if .gdb_index section exists. + void addGDBTypeUnitEntry(const GDBIndexTUEntry &Entry); + + /// Rewrite .gdb_index section if present. + void updateGdbIndexSection( + CUOffsetMap &CUMap, uint32_t NumCUs, + std::unique_ptr &ARangesSectionWriter); + + /// Returns all entries needed for Types CU list + const GDBIndexTUEntryType &getGDBIndexTUEntryVector() const { +return GDBIndexTUEntryVector; + } +}; + +} // namespace bolt +} // namespace llvm + +#endif diff --git a/bolt/lib/Core/BinaryEmitter.cpp b/bolt/lib/Core/BinaryEmitter.cpp index 0b44acb0816f2f..e09b9ff92de064 100644 --- a/bolt/lib/Core/BinaryEmitter.cpp +++ b/bolt/lib/Core/BinaryEmitter.cpp @@ -485,6 +485,7 @@ void BinaryEmitter::emitFunctionBody(BinaryFunction &BF, FunctionFragment &FF, // This assumes the second instruction in the macro-op pair will get // assigned to its own MCRelaxableFragment. Since all JCC instructions // are relaxable, we should be safe. +Streamer.emitNeverAlignCodeAtEnd(/*Alignment to avoid=*/64, *BC.STI); } if (!EmitCodeOnly) { diff --git a/bolt/lib/Core/CMakeLists.txt b/bolt/lib/Core/CMakeLists.txt index 441df9fe084648..873cf67a56291f 100644 --- a/bolt/lib/Core/CMakeLists.txt +++ b/bolt/lib/Core/CMakeLists.txt @@ -25,6 +25,7 @@ add_llvm_library(LLVMBOLTCore DynoStats.cpp Exceptions.cpp FunctionLayout.cpp + GDBIndex.cpp HashUtilities.cpp JumpTable.cpp MCPlusBuilder.cpp diff --git a/bolt/lib/Core/GDBIndex.cpp b/bolt/lib/Core/GDBIndex.cpp new file mode 100644 index 00..fda19a2c8cb3ef --- /dev/null +++ b/bolt/lib/Core/GDBIndex.cpp @@ -0,0 +1,182 @@ +//===- bolt/Rewrite/GDBIndex.cpp -===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===-
[clang] [lldb] [llvm] Refactor GDB Index into a new file (PR #94405)
https://github.com/sayhaan created https://github.com/llvm/llvm-project/pull/94405 Create a new class and file for functions that update GDB index. >From f3533c92b6b64f50a933a9eb2f9cc4229bbd8da3 Mon Sep 17 00:00:00 2001 From: Amir Ayupov Date: Tue, 1 Jun 2021 11:37:41 -0700 Subject: [PATCH 1/7] Rebase: [Facebook] Add clang driver options to test debug info and BOLT Summary: This is an essential piece of infrastructure for us to be continuously testing debug info with BOLT. We can't only make changes to a test repo because we need to change debuginfo tests to call BOLT, hence, this diff needs to sit in our opensource repo. But when upstreaming to LLVM, this should be kept BOLT-only outside of LLVM. When upstreaming, we need to git diff and check all folders that are being modified by our commits and discard this one (and leave as an internal diff). To test BOLT in debuginfo tests, configure it with -DLLVM_TEST_BOLT=ON. Then run check-lldb and check-debuginfo. Manual rebase conflict history: https://phabricator.intern.facebook.com/D29205224 https://phabricator.intern.facebook.com/D29564078 https://phabricator.intern.facebook.com/D33289118 https://phabricator.intern.facebook.com/D34957174 https://phabricator.intern.facebook.com/D35317341 Test Plan: tested locally Configured with: -DLLVM_ENABLE_PROJECTS="clang;lld;lldb;compiler-rt;bolt;debuginfo-tests" -DLLVM_TEST_BOLT=ON Ran test suite with: ninja check-debuginfo ninja check-lldb Reviewers: maks, #llvm-bolt Reviewed By: maks Subscribers: ayermolo, phabricatorlinter Differential Revision: https://phabricator.intern.facebook.com/D46256657 Tasks: T92898286 --- clang/include/clang/Driver/Options.td | 4 clang/lib/Driver/ToolChains/Gnu.cpp| 29 ++ cross-project-tests/lit.cfg.py | 14 - cross-project-tests/lit.site.cfg.py.in | 4 lldb/test/API/lit.cfg.py | 5 + lldb/test/API/lit.site.cfg.py.in | 8 +++ lldb/test/Shell/helper/toolchain.py| 5 + lldb/test/Shell/lit.site.cfg.py.in | 9 llvm/CMakeLists.txt| 4 9 files changed, 81 insertions(+), 1 deletion(-) diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index 57f37c5023110f..7469db06839e3b 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -5465,6 +5465,10 @@ def pg : Flag<["-"], "pg">, HelpText<"Enable mcount instrumentation">, MarshallingInfoFlag>; def pipe : Flag<["-", "--"], "pipe">, HelpText<"Use pipes between commands, when possible">; +// Facebook T92898286 +def post_link_optimize : Flag<["--"], "post-link-optimize">, + HelpText<"Apply post-link optimizations using BOLT">; +// End Facebook T92898286 def prebind__all__twolevel__modules : Flag<["-"], "prebind_all_twolevel_modules">; def prebind : Flag<["-"], "prebind">; def preload : Flag<["-"], "preload">; diff --git a/clang/lib/Driver/ToolChains/Gnu.cpp b/clang/lib/Driver/ToolChains/Gnu.cpp index b141e5f2adfab1..f7611af5763ab7 100644 --- a/clang/lib/Driver/ToolChains/Gnu.cpp +++ b/clang/lib/Driver/ToolChains/Gnu.cpp @@ -672,12 +672,41 @@ void tools::gnutools::Linker::ConstructJob(Compilation &C, const JobAction &JA, } } + // Facebook T92898286 + if (Args.hasArg(options::OPT_post_link_optimize)) +CmdArgs.push_back("-q"); + // End Facebook T92898286 + Args.AddAllArgs(CmdArgs, options::OPT_T); const char *Exec = Args.MakeArgString(ToolChain.GetLinkerPath()); C.addCommand(std::make_unique(JA, *this, ResponseFileSupport::AtFileCurCP(), Exec, CmdArgs, Inputs, Output)); + // Facebook T92898286 + if (!Args.hasArg(options::OPT_post_link_optimize) || !Output.isFilename()) +return; + + const char *MvExec = Args.MakeArgString(ToolChain.GetProgramPath("mv")); + ArgStringList MoveCmdArgs; + MoveCmdArgs.push_back(Output.getFilename()); + const char *PreBoltBin = + Args.MakeArgString(Twine(Output.getFilename()) + ".pre-bolt"); + MoveCmdArgs.push_back(PreBoltBin); + C.addCommand(std::make_unique(JA, *this, ResponseFileSupport::None(), + MvExec, MoveCmdArgs, std::nullopt)); + + ArgStringList BoltCmdArgs; + const char *BoltExec = + Args.MakeArgString(ToolChain.GetProgramPath("llvm-bolt")); + BoltCmdArgs.push_back(PreBoltBin); + BoltCmdArgs.push_back("-reorder-blocks=reverse"); + BoltCmdArgs.push_back("-update-debug-sections"); + BoltCmdArgs.push_back("-o"); + BoltCmdArgs.push_back(Output.getFilename()); + C.addCommand(std::make_unique(JA, *this, ResponseFileSupport::None(), + BoltExec, BoltCmdArgs, std::nullopt)); + // End Facebook T92898286 } void tools::gnutools::Assembler::ConstructJob(Compilation &C, diff --git a/cross-project-tests/lit.cfg.py b/cross-project-tests/lit.cfg.py index 774c4eaf4d
[clang] [llvm] Enable LLDB tests in Linux pre-merge CI (PR #94208)
AaronBallman wrote: > Following the logic in this argument, would you also say it's appropriate for > someone to commit an LLVM patch that changes how textual LLVM IR is printed > in a way that it breaks existing tests in Clang — without updating those > tests? Possibly! I'm talking about relying on implementation details of a project and I think the textual representation of LLVM IR isn't necessarily an implementation detail of LLVM. But if the change was to an implementation detail and LLVM had a need to make the change, it's on the Clang community to react to that change. > As far as I am concerned I would expect someone making such a change to at > the very least update the Clang tests to the new format, but even better to > have a discussion with the community whether the benefits of this change > warrant the churn in the tests. I'm not trying to suggest that Clang can change anything it wants and lldb needs to just deal with it. I'm saying that Clang needs the ability to change our internal implementation details without *requiring* a PR author to update downstream projects relying on those implementation details. We should work together to reduce the amount of burden between both projects of course, but if a downstream project is expecting a very specific wording for a diagnostic message, Clang developers should not have their (correct) changes reverted because they updated the diagnostic wording and it broke a downstream test. Would it be useful for us to have a conference call to discuss this in more detail to make sure we're all clear and comfortable? https://github.com/llvm/llvm-project/pull/94208 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [WIP][Safe Buffers] Serialize unsafe_buffer_usage pragmas (PR #92031)
https://github.com/ziqingluo-90 updated https://github.com/llvm/llvm-project/pull/92031 >From ac5aeb5c3a134d085320fc7fc5cf3f2c8c41a1f1 Mon Sep 17 00:00:00 2001 From: ziqingluo-90 Date: Mon, 13 May 2024 13:31:21 -0700 Subject: [PATCH 1/4] fix safe buffer opt-out region serialization --- clang/include/clang/Lex/Preprocessor.h| 22 +++- .../include/clang/Serialization/ASTBitCodes.h | 3 + clang/lib/Lex/Preprocessor.cpp| 106 ++ clang/lib/Serialization/ASTReader.cpp | 11 ++ clang/lib/Serialization/ASTWriter.cpp | 7 ++ clang/test/Modules/Inputs/SafeBuffers/base.h | 9 ++ .../SafeBuffers/safe_buffers_test.modulemap | 10 ++ .../Modules/Inputs/SafeBuffers/test_sub1.h| 20 .../Modules/Inputs/SafeBuffers/test_sub2.h| 11 ++ clang/test/Modules/safe_buffers_optout.cpp| 39 +++ ...unsafe-buffer-usage-pragma-pch-complex.cpp | 72 .../warn-unsafe-buffer-usage-pragma-pch.cpp | 27 + 12 files changed, 314 insertions(+), 23 deletions(-) create mode 100644 clang/test/Modules/Inputs/SafeBuffers/base.h create mode 100644 clang/test/Modules/Inputs/SafeBuffers/safe_buffers_test.modulemap create mode 100644 clang/test/Modules/Inputs/SafeBuffers/test_sub1.h create mode 100644 clang/test/Modules/Inputs/SafeBuffers/test_sub2.h create mode 100644 clang/test/Modules/safe_buffers_optout.cpp create mode 100644 clang/test/SemaCXX/warn-unsafe-buffer-usage-pragma-pch-complex.cpp create mode 100644 clang/test/SemaCXX/warn-unsafe-buffer-usage-pragma-pch.cpp diff --git a/clang/include/clang/Lex/Preprocessor.h b/clang/include/clang/Lex/Preprocessor.h index e89b4a2c5230e..8d6884ebe7597 100644 --- a/clang/include/clang/Lex/Preprocessor.h +++ b/clang/include/clang/Lex/Preprocessor.h @@ -2883,11 +2883,15 @@ class Preprocessor { /// otherwise. SourceLocation CurrentSafeBufferOptOutStart; // It is used to report the start location of an never-closed region. - // An ordered sequence of "-Wunsafe-buffer-usage" opt-out regions in one - // translation unit. Each region is represented by a pair of start and end - // locations. A region is "open" if its' start and end locations are + using SafeBufferOptOutMapTy = + SmallVector, 16>; + // An ordered sequence of "-Wunsafe-buffer-usage" opt-out regions in this + // translation unit. Each region is represented by a pair of start and + // end locations. A region is "open" if its' start and end locations are // identical. - SmallVector, 8> SafeBufferOptOutMap; + SafeBufferOptOutMapTy SafeBufferOptOutMap; + // `SafeBufferOptOutMap`s of loaded files: + llvm::DenseMap LoadedSafeBufferOptOutMap; public: /// \return true iff the given `Loc` is in a "-Wunsafe-buffer-usage" opt-out @@ -2918,6 +2922,16 @@ class Preprocessor { /// opt-out region bool isPPInSafeBufferOptOutRegion(SourceLocation &StartLoc); + /// \return a sequence of SourceLocations representing ordered opt-out regions + /// specified by + /// `\#pragma clang unsafe_buffer_usage begin/end`s of this translation unit. + SmallVector serializeSafeBufferOptOutMap() const; + + /// \param SrcLocSeqs a sequence of SourceLocations deserialized from a + /// record of code `PP_UNSAFE_BUFFER_USAGE`. + void setDeserializedSafeBufferOptOutMap( + const SmallVectorImpl &SrcLocSeqs); + private: /// Helper functions to forward lexing to the actual lexer. They all share the /// same signature. diff --git a/clang/include/clang/Serialization/ASTBitCodes.h b/clang/include/clang/Serialization/ASTBitCodes.h index dcfa4ac0c1967..d1a0eba943039 100644 --- a/clang/include/clang/Serialization/ASTBitCodes.h +++ b/clang/include/clang/Serialization/ASTBitCodes.h @@ -775,6 +775,9 @@ enum ASTRecordTypes { /// Record code for lexical and visible block for delayed namespace in /// reduced BMI. DELAYED_NAMESPACE_LEXICAL_VISIBLE_RECORD = 68, + + /// Record code for \#pragma clang unsafe_buffer_usage begin/end + PP_UNSAFE_BUFFER_USAGE = 69, }; /// Record types used within a source manager block. diff --git a/clang/lib/Lex/Preprocessor.cpp b/clang/lib/Lex/Preprocessor.cpp index 0b70192743a39..6a41e3d4138aa 100644 --- a/clang/lib/Lex/Preprocessor.cpp +++ b/clang/lib/Lex/Preprocessor.cpp @@ -58,6 +58,7 @@ #include "llvm/ADT/SmallString.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringRef.h" +#include "llvm/ADT/iterator_range.h" #include "llvm/Support/Capacity.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/MemoryBuffer.h" @@ -1483,26 +1484,41 @@ void Preprocessor::emitFinalMacroWarning(const Token &Identifier, } bool Preprocessor::isSafeBufferOptOut(const SourceManager &SourceMgr, - const SourceLocation &Loc) const { - // Try to find a region in `SafeBufferOptOutMap` where `Loc` is in: - auto FirstRegionEndingAfterLoc = llvm::partition_point( - SafeBufferOptOutMap, - [&SourceMgr, -
[clang] [compiler-rt] [llvm] [TypeProf][InstrFDO]Implement more efficient comparison sequence for indirect-call-promotion with vtable profiles. (PR #81442)
@@ -140,14 +337,51 @@ class IndirectCallPromoter { // indirect callee with functions. Returns true if there are IR // transformations and false otherwise. bool tryToPromoteWithFuncCmp( - CallBase &CB, const std::vector &Candidates, - uint64_t TotalCount, ArrayRef ICallProfDataRef, - uint32_t NumCandidates); + CallBase &CB, Instruction *VPtr, + const std::vector &Candidates, uint64_t TotalCount, + ArrayRef ICallProfDataRef, uint32_t NumCandidates, + VTableGUIDCountsMap &VTableGUIDCounts); + + // Promote a list of targets for one indirect call by comparing vtables with + // functions. Returns true if there are IR transformations and false + // otherwise. + bool tryToPromoteWithVTableCmp( + CallBase &CB, Instruction *VPtr, + const std::vector &Candidates, + uint64_t TotalFuncCount, uint32_t NumCandidates, + MutableArrayRef ICallProfDataRef, + VTableGUIDCountsMap &VTableGUIDCounts); + + // Returns true if it's profitable to compare vtables. + bool isProfitableToCompareVTables( + const std::vector &Candidates, uint64_t TotalCount); + + // Populate `VTableGUIDCounts` vtable GUIDs and their counts and each teresajohnson wrote: should that be "for each candidate with vtable information"? https://github.com/llvm/llvm-project/pull/81442 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [compiler-rt] [llvm] [TypeProf][InstrFDO]Implement more efficient comparison sequence for indirect-call-promotion with vtable profiles. (PR #81442)
@@ -321,14 +746,127 @@ bool IndirectCallPromoter::processFunction(ProfileSummaryInfo *PSI) { if (!NumCandidates || (PSI && PSI->hasProfileSummary() && !PSI->isHotCount(TotalCount))) continue; + auto PromotionCandidates = getPromotionCandidatesForCallSite( *CB, ICallProfDataRef, TotalCount, NumCandidates); -Changed |= tryToPromoteWithFuncCmp(*CB, PromotionCandidates, TotalCount, - ICallProfDataRef, NumCandidates); + +VTableGUIDCountsMap VTableGUIDCounts; +Instruction *VPtr = +computeVTableInfos(CB, VTableGUIDCounts, PromotionCandidates); + +if (isProfitableToCompareVTables(PromotionCandidates, TotalCount)) + Changed |= tryToPromoteWithVTableCmp(*CB, VPtr, PromotionCandidates, + TotalCount, NumCandidates, + ICallProfDataRef, VTableGUIDCounts); +else + Changed |= tryToPromoteWithFuncCmp(*CB, VPtr, PromotionCandidates, + TotalCount, ICallProfDataRef, + NumCandidates, VTableGUIDCounts); } return Changed; } +// TODO: Returns false if the function addressing and vtable load instructions +// cannot sink to indirect fallback. +bool IndirectCallPromoter::isProfitableToCompareVTables( +const std::vector &Candidates, uint64_t TotalCount) { + if (!ICPEnableVTableCmp || Candidates.empty()) +return false; + uint64_t RemainingVTableCount = TotalCount; + for (size_t I = 0; I < Candidates.size(); I++) { +auto &Candidate = Candidates[I]; +uint64_t VTableSumCount = 0; +for (auto &[GUID, Count] : Candidate.VTableGUIDAndCounts) + VTableSumCount += Count; + +if (VTableSumCount < Candidate.Count * ICPVTableCountPercentage) + return false; + +RemainingVTableCount -= Candidate.Count; + +int NumAdditionalVTable = 0; +if (I == Candidates.size() - 1) + NumAdditionalVTable = ICPNumAdditionalVTableLast; + +int ActualNumAdditionalInst = Candidate.AddressPoints.size() - 1; +if (ActualNumAdditionalInst > NumAdditionalVTable) { + return false; +} + } + + // If the indirect fallback is not cold, don't compare vtables. + if (PSI && PSI->hasProfileSummary() && + !PSI->isColdCount(RemainingVTableCount)) +return false; + + return true; +} + +static void +computeVirtualCallSiteTypeInfoMap(Module &M, ModuleAnalysisManager &MAM, + VirtualCallSiteTypeInfoMap &VirtualCSInfo) { + auto &FAM = MAM.getResult(M).getManager(); + auto LookupDomTree = [&FAM](Function &F) -> DominatorTree & { +return FAM.getResult(F); + }; + + auto compute = [&](Function *Func) { +if (!Func || Func->use_empty()) + return; +// Iterate all type.test calls and find all indirect calls. +// TODO: Add llvm.public.type.test +for (Use &U : llvm::make_early_inc_range(Func->uses())) { + auto *CI = dyn_cast(U.getUser()); + if (!CI) +continue; + auto *TypeMDVal = cast(CI->getArgOperand(1)); + if (!TypeMDVal) +continue; + auto *CompatibleTypeId = dyn_cast(TypeMDVal->getMetadata()); + if (!CompatibleTypeId) +continue; + + // Find out all devirtualizable call sites given a llvm.type.test + // intrinsic call. + SmallVector DevirtCalls; + SmallVector Assumes; + auto &DT = LookupDomTree(*CI->getFunction()); + findDevirtualizableCallsForTypeTest(DevirtCalls, Assumes, CI, DT); + + // type-id, offset from the address point + // combined with type metadata to compute function offset + for (auto &DevirtCall : DevirtCalls) { +CallBase &CB = DevirtCall.CB; +// Given an indirect call, try find the instruction which loads a +// pointer to virtual table. +Instruction *VTablePtr = +PGOIndirectCallVisitor::tryGetVTableInstruction(&CB); +if (!VTablePtr) + continue; +VirtualCSInfo[&CB] = {DevirtCall.Offset, VTablePtr, + CompatibleTypeId->getString()}; + } +} + }; + + // Right now only llvm.type.test is used to find out virtual call sites. + // With ThinLTO and whole-program-devirtualization, llvm.type.test and + // llvm.public.type.test are emitted, and llvm.public.type.test is either + // refined to llvm.type.test or dropped before indirect-call-promotion pass. teresajohnson wrote: Do we then need to do the below analysis on llvm.public.type.test? ICP should be after it gets converted or dropped. https://github.com/llvm/llvm-project/pull/81442 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [compiler-rt] [llvm] [TypeProf][InstrFDO]Implement more efficient comparison sequence for indirect-call-promotion with vtable profiles. (PR #81442)
@@ -103,30 +110,220 @@ static cl::opt ICPDUMPAFTER("icp-dumpafter", cl::init(false), cl::Hidden, cl::desc("Dump IR after transformation happens")); +// This option is meant to be used by LLVM regression test and test the +// transformation that compares vtables. +static cl::opt ICPEnableVTableCmp( +"icp-enable-vtable-cmp", cl::init(false), cl::Hidden, +cl::desc("If ThinLTO and WPD is enabled and this option is true, " + "indirect-call promotion pass will compare vtables rather than " + "functions for speculative devirtualization of virtual calls." + " If set to false, indirect-call promotion pass will always " + "compare functions.")); + +static cl::opt +ICPVTableCountPercentage("icp-vtable-count-percentage", cl::init(0.99), + cl::Hidden, + cl::desc("Percentage of vtable count to compare")); + +static cl::opt ICPNumAdditionalVTableLast( +"icp-num-additional-vtable-last", cl::init(0), cl::Hidden, +cl::desc("The number of additional instruction for the last candidate")); + namespace { +using VTableAddressPointOffsetValMap = teresajohnson wrote: Add comment describing the contents https://github.com/llvm/llvm-project/pull/81442 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [compiler-rt] [llvm] [TypeProf][InstrFDO]Implement more efficient comparison sequence for indirect-call-promotion with vtable profiles. (PR #81442)
@@ -103,30 +110,220 @@ static cl::opt ICPDUMPAFTER("icp-dumpafter", cl::init(false), cl::Hidden, cl::desc("Dump IR after transformation happens")); +// This option is meant to be used by LLVM regression test and test the +// transformation that compares vtables. +static cl::opt ICPEnableVTableCmp( +"icp-enable-vtable-cmp", cl::init(false), cl::Hidden, +cl::desc("If ThinLTO and WPD is enabled and this option is true, " + "indirect-call promotion pass will compare vtables rather than " + "functions for speculative devirtualization of virtual calls." + " If set to false, indirect-call promotion pass will always " + "compare functions.")); + +static cl::opt +ICPVTableCountPercentage("icp-vtable-count-percentage", cl::init(0.99), + cl::Hidden, + cl::desc("Percentage of vtable count to compare")); + +static cl::opt ICPNumAdditionalVTableLast( +"icp-num-additional-vtable-last", cl::init(0), cl::Hidden, +cl::desc("The number of additional instruction for the last candidate")); + namespace { +using VTableAddressPointOffsetValMap = +SmallDenseMap, 8>; + +// A struct to collect type information for a virtual call site. +struct VirtualCallSiteInfo { + // The offset from the address point to virtual function in the vtable. + uint64_t FunctionOffset; + // The instruction that computes the address point of vtable. + Instruction *VPtr; + // The compatible type used in LLVM type intrinsics. + StringRef CompatibleTypeStr; +}; + +// The key is a virtual call, and value is its type information. +using VirtualCallSiteTypeInfoMap = +SmallDenseMap; + +// Find the offset where type string is `CompatibleType`. +static std::optional +getCompatibleTypeOffset(const GlobalVariable &VTableVar, +StringRef CompatibleType) { + SmallVector Types; // type metadata associated with a vtable. + VTableVar.getMetadata(LLVMContext::MD_type, Types); + + for (MDNode *Type : Types) +if (auto *TypeId = dyn_cast(Type->getOperand(1).get()); +TypeId && TypeId->getString() == CompatibleType) + + return cast( + cast(Type->getOperand(0))->getValue()) + ->getZExtValue(); + + return std::nullopt; +} + +// Returns a constant representing the vtable's address point specified by the +// offset. +static Constant *getVTableAddressPointOffset(GlobalVariable *VTable, + uint32_t AddressPointOffset) { + Module &M = *VTable->getParent(); + LLVMContext &Context = M.getContext(); + assert(AddressPointOffset < + M.getDataLayout().getTypeAllocSize(VTable->getValueType()) && + "Out-of-bound access"); + + return ConstantExpr::getInBoundsGetElementPtr( + Type::getInt8Ty(Context), VTable, + llvm::ConstantInt::get(Type::getInt32Ty(Context), AddressPointOffset)); +} + +// Returns the basic block in which `Inst` by `Use`. +static BasicBlock *getUserBasicBlock(Use &U, Instruction *UserInst) { + if (PHINode *PN = dyn_cast(UserInst)) +return PN->getIncomingBlock(U); + + return UserInst->getParent(); +} + +// `DestBB` is a suitable basic block to sink `Inst` into when the following +// conditions are true: +// 1) `Inst->getParent()` is the sole predecessor of `DestBB`. This way `DestBB` +//is dominated by `Inst->getParent()` and we don't need to sink across a +//critical edge. +// 2) `Inst` have users and all users are in `DestBB`. +static bool isDestBBSuitableForSink(Instruction *Inst, BasicBlock *DestBB) { + BasicBlock *BB = Inst->getParent(); + assert(Inst->getParent() != DestBB && + BB->getTerminator()->getNumSuccessors() == 2 && + "Caller should guarantee"); + // Do not sink across a critical edge for simplicity. + if (DestBB->getUniquePredecessor() != BB) +return false; + + // Now we know BB dominates DestBB. + BasicBlock *UserBB = nullptr; + for (Use &Use : Inst->uses()) { +User *User = Use.getUser(); +// Do checked cast since IR verifier guarantees that the user of an +// instruction must be an instruction. See `Verifier::visitInstruction`. +Instruction *UserInst = cast(User); +// We can sink debug or pseudo instructions together with Inst. +if (UserInst->isDebugOrPseudoInst()) + continue; +UserBB = getUserBasicBlock(Use, UserInst); +// Do not sink if Inst is used in a basic block that is not DestBB. +// TODO: Sink to the common dominator of all user blocks. +if (UserBB != DestBB) + return false; + } + return UserBB != nullptr; +} + +// For the virtual call dispatch sequence, try to sink vtable load instructions +// to the cold indirect call fallback. +static bool tryToSinkInstruction(Instruction *I, BasicBlock *DestBlock) { + assert(!I->isTerminator()); + if (!isDestBBSuitableForSink(I, DestBlock)) +return false; + + assert(DestBlock->getUniquePre
[clang] [compiler-rt] [llvm] [TypeProf][InstrFDO]Implement more efficient comparison sequence for indirect-call-promotion with vtable profiles. (PR #81442)
@@ -140,14 +337,51 @@ class IndirectCallPromoter { // indirect callee with functions. Returns true if there are IR // transformations and false otherwise. bool tryToPromoteWithFuncCmp( - CallBase &CB, const std::vector &Candidates, - uint64_t TotalCount, ArrayRef ICallProfDataRef, - uint32_t NumCandidates); + CallBase &CB, Instruction *VPtr, + const std::vector &Candidates, uint64_t TotalCount, + ArrayRef ICallProfDataRef, uint32_t NumCandidates, + VTableGUIDCountsMap &VTableGUIDCounts); + + // Promote a list of targets for one indirect call by comparing vtables with + // functions. Returns true if there are IR transformations and false + // otherwise. + bool tryToPromoteWithVTableCmp( + CallBase &CB, Instruction *VPtr, + const std::vector &Candidates, + uint64_t TotalFuncCount, uint32_t NumCandidates, + MutableArrayRef ICallProfDataRef, + VTableGUIDCountsMap &VTableGUIDCounts); + + // Returns true if it's profitable to compare vtables. + bool isProfitableToCompareVTables( + const std::vector &Candidates, uint64_t TotalCount); + + // Populate `VTableGUIDCounts` vtable GUIDs and their counts and each teresajohnson wrote: "with vtable GUIDs and..." ? (i.e. missing "and"?) https://github.com/llvm/llvm-project/pull/81442 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [compiler-rt] [llvm] [TypeProf][InstrFDO]Implement more efficient comparison sequence for indirect-call-promotion with vtable profiles. (PR #81442)
@@ -341,6 +879,17 @@ static bool promoteIndirectCalls(Module &M, ProfileSummaryInfo *PSI, bool InLTO, return false; } bool Changed = false; + VirtualCallSiteTypeInfoMap VirtualCSInfo; + + computeVirtualCallSiteTypeInfoMap(M, MAM, VirtualCSInfo); + + // This map records states across functions in an LLVM IR module. teresajohnson wrote: What do you mean by "records states"? https://github.com/llvm/llvm-project/pull/81442 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [compiler-rt] [llvm] [TypeProf][InstrFDO]Implement more efficient comparison sequence for indirect-call-promotion with vtable profiles. (PR #81442)
@@ -103,30 +110,222 @@ static cl::opt ICPDUMPAFTER("icp-dumpafter", cl::init(false), cl::Hidden, cl::desc("Dump IR after transformation happens")); +// This option is meant to be used by LLVM regression test and test the +// transformation that compares vtables. +static cl::opt ICPEnableVTableCmp( +"icp-enable-vtable-cmp", cl::init(false), cl::Hidden, +cl::desc("If ThinLTO and WPD is enabled and this option is true, " + "indirect-call promotion pass will compare vtables rather than " + "functions for speculative devirtualization of virtual calls." + " If set to false, indirect-call promotion pass will always " + "compare functions.")); + +static cl::opt +ICPVTableCountPercentage("icp-vtable-count-percentage", cl::init(0.99), + cl::Hidden, + cl::desc("Percentage of vtable count to compare")); + +static cl::opt ICPNumAdditionalVTableLast( +"icp-num-additional-vtable-last", cl::init(0), cl::Hidden, +cl::desc("The number of additional instruction for the last candidate")); + namespace { +using VTableAddressPointOffsetValMap = +SmallDenseMap, 8>; + +// A struct to collect type information for a virtual call site. +struct VirtualCallSiteInfo { + // The offset from the address point to virtual function in the vtable. + uint64_t FunctionOffset; + // The instruction that computes the address point of vtable. + Instruction *VPtr; + // The compatible type used in LLVM type intrinsics. + StringRef CompatibleTypeStr; +}; + +// The key is a virtual call, and value is its type information. +using VirtualCallSiteTypeInfoMap = +SmallDenseMap; + +// Find the offset where type string is `CompatibleType`. +static std::optional +getCompatibleTypeOffset(const GlobalVariable &VTableVar, +StringRef CompatibleType) { + SmallVector Types; // type metadata associated with a vtable. + VTableVar.getMetadata(LLVMContext::MD_type, Types); + + for (MDNode *Type : Types) teresajohnson wrote: What you are getting here is the address point offset of the given compatible type within the given vtable. See also https://llvm.org/docs/TypeMetadata.html#representing-type-information-using-type-metadata. It might be good to add a comment describing this more explicitly. https://github.com/llvm/llvm-project/pull/81442 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [compiler-rt] [llvm] [TypeProf][InstrFDO]Implement more efficient comparison sequence for indirect-call-promotion with vtable profiles. (PR #81442)
@@ -276,35 +585,151 @@ CallBase &llvm::pgo::promoteIndirectCall(CallBase &CB, Function *DirectCallee, // Promote indirect-call to conditional direct-call for one callsite. bool IndirectCallPromoter::tryToPromoteWithFuncCmp( -CallBase &CB, const std::vector &Candidates, -uint64_t TotalCount, ArrayRef ICallProfDataRef, -uint32_t NumCandidates) { +CallBase &CB, Instruction *VPtr, +const std::vector &Candidates, uint64_t TotalCount, +ArrayRef ICallProfDataRef, uint32_t NumCandidates, +VTableGUIDCountsMap &VTableGUIDCounts) { uint32_t NumPromoted = 0; for (const auto &C : Candidates) { -uint64_t Count = C.Count; -pgo::promoteIndirectCall(CB, C.TargetFunction, Count, TotalCount, SamplePGO, - &ORE); -assert(TotalCount >= Count); -TotalCount -= Count; +uint64_t FuncCount = C.Count; +pgo::promoteIndirectCall(CB, C.TargetFunction, FuncCount, TotalCount, + SamplePGO, &ORE); +assert(TotalCount >= FuncCount); +TotalCount -= FuncCount; NumOfPGOICallPromotion++; NumPromoted++; - } +if (!ICPEnableVTableCmp || C.VTableGUIDAndCounts.empty()) + continue; + +// Update VTableGUIDCounts +uint64_t SumVTableCount = 0; +for (const auto &[GUID, VTableCount] : C.VTableGUIDAndCounts) + SumVTableCount += VTableCount; + +for (const auto &[GUID, VTableCount] : C.VTableGUIDAndCounts) { teresajohnson wrote: Can you add a comment describing the intuition behind the way the counts are being updated here https://github.com/llvm/llvm-project/pull/81442 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [compiler-rt] [llvm] [TypeProf][InstrFDO]Implement more efficient comparison sequence for indirect-call-promotion with vtable profiles. (PR #81442)
@@ -276,35 +585,151 @@ CallBase &llvm::pgo::promoteIndirectCall(CallBase &CB, Function *DirectCallee, // Promote indirect-call to conditional direct-call for one callsite. bool IndirectCallPromoter::tryToPromoteWithFuncCmp( -CallBase &CB, const std::vector &Candidates, -uint64_t TotalCount, ArrayRef ICallProfDataRef, -uint32_t NumCandidates) { +CallBase &CB, Instruction *VPtr, +const std::vector &Candidates, uint64_t TotalCount, +ArrayRef ICallProfDataRef, uint32_t NumCandidates, +VTableGUIDCountsMap &VTableGUIDCounts) { uint32_t NumPromoted = 0; for (const auto &C : Candidates) { -uint64_t Count = C.Count; -pgo::promoteIndirectCall(CB, C.TargetFunction, Count, TotalCount, SamplePGO, - &ORE); -assert(TotalCount >= Count); -TotalCount -= Count; +uint64_t FuncCount = C.Count; +pgo::promoteIndirectCall(CB, C.TargetFunction, FuncCount, TotalCount, + SamplePGO, &ORE); +assert(TotalCount >= FuncCount); +TotalCount -= FuncCount; NumOfPGOICallPromotion++; NumPromoted++; - } +if (!ICPEnableVTableCmp || C.VTableGUIDAndCounts.empty()) + continue; + +// Update VTableGUIDCounts +uint64_t SumVTableCount = 0; +for (const auto &[GUID, VTableCount] : C.VTableGUIDAndCounts) + SumVTableCount += VTableCount; + +for (const auto &[GUID, VTableCount] : C.VTableGUIDAndCounts) { + APInt APFuncCount((unsigned)128, FuncCount, false /*signed*/); + APFuncCount *= VTableCount; + VTableGUIDCounts[GUID] -= APFuncCount.udiv(SumVTableCount).getZExtValue(); +} + } if (NumPromoted == 0) return false; - // Adjust the MD.prof metadata. First delete the old one. - CB.setMetadata(LLVMContext::MD_prof, nullptr); - assert(NumPromoted <= ICallProfDataRef.size() && "Number of promoted functions should not be greater than the number " "of values in profile metadata"); + + // Update value profiles on the indirect call. + // TODO: Handle profile update properly when Clang `-fstrict-vtable-pointers` + // is enabled and a vtable is used to load multiple virtual functions. + updateFuncValueProfiles(CB, ICallProfDataRef.slice(NumPromoted), TotalCount, + NumCandidates); + // Update value profiles on the vtable pointer if it exists. + if (VPtr) +updateVPtrValueProfiles(VPtr, VTableGUIDCounts); + return true; +} + +void IndirectCallPromoter::updateFuncValueProfiles( +CallBase &CB, ArrayRef CallVDs, uint64_t TotalCount, +uint32_t MaxMDCount) { + // First clear the existing !prof. + CB.setMetadata(LLVMContext::MD_prof, nullptr); // Annotate the remaining value profiles if counter is not zero. if (TotalCount != 0) -annotateValueSite(*F.getParent(), CB, ICallProfDataRef.slice(NumPromoted), - TotalCount, IPVK_IndirectCallTarget, NumCandidates); +annotateValueSite(M, CB, CallVDs, TotalCount, IPVK_IndirectCallTarget, + MaxMDCount); +} + +void IndirectCallPromoter::updateVPtrValueProfiles( +Instruction *VPtr, VTableGUIDCountsMap &VTableGUIDCounts) { + VPtr->setMetadata(LLVMContext::MD_prof, nullptr); + std::vector VTableValueProfiles; + uint64_t TotalVTableCount = 0; + for (auto [GUID, Count] : VTableGUIDCounts) { +if (Count == 0) + continue; + +VTableValueProfiles.push_back({GUID, Count}); +TotalVTableCount += Count; + } + llvm::sort(VTableValueProfiles, + [](const InstrProfValueData &LHS, const InstrProfValueData &RHS) { + return LHS.Count > RHS.Count; + }); + + annotateValueSite(M, *VPtr, VTableValueProfiles, TotalVTableCount, +IPVK_VTableTarget, VTableValueProfiles.size()); +} + +bool IndirectCallPromoter::tryToPromoteWithVTableCmp( +CallBase &CB, Instruction *VPtr, +const std::vector &Candidates, uint64_t TotalFuncCount, +uint32_t NumCandidates, +MutableArrayRef ICallProfDataRef, +VTableGUIDCountsMap &VTableGUIDCounts) { + SmallVector PromotedFuncCount; + for (const auto &Candidate : Candidates) { +uint64_t IfCount = 0; teresajohnson wrote: The name IfCount isn't very intuitive to me, suggest using a different name. https://github.com/llvm/llvm-project/pull/81442 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [compiler-rt] [llvm] [TypeProf][InstrFDO]Implement more efficient comparison sequence for indirect-call-promotion with vtable profiles. (PR #81442)
https://github.com/teresajohnson commented: I haven't looked at the tests yet, but some comments/questions from a first pass through most of the code https://github.com/llvm/llvm-project/pull/81442 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [compiler-rt] [llvm] [TypeProf][InstrFDO]Implement more efficient comparison sequence for indirect-call-promotion with vtable profiles. (PR #81442)
https://github.com/teresajohnson edited https://github.com/llvm/llvm-project/pull/81442 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [compiler-rt] [llvm] [TypeProf][InstrFDO]Implement more efficient comparison sequence for indirect-call-promotion with vtable profiles. (PR #81442)
@@ -103,30 +110,220 @@ static cl::opt ICPDUMPAFTER("icp-dumpafter", cl::init(false), cl::Hidden, cl::desc("Dump IR after transformation happens")); +// This option is meant to be used by LLVM regression test and test the +// transformation that compares vtables. +static cl::opt ICPEnableVTableCmp( +"icp-enable-vtable-cmp", cl::init(false), cl::Hidden, +cl::desc("If ThinLTO and WPD is enabled and this option is true, " + "indirect-call promotion pass will compare vtables rather than " + "functions for speculative devirtualization of virtual calls." + " If set to false, indirect-call promotion pass will always " + "compare functions.")); + +static cl::opt +ICPVTableCountPercentage("icp-vtable-count-percentage", cl::init(0.99), + cl::Hidden, + cl::desc("Percentage of vtable count to compare")); + +static cl::opt ICPNumAdditionalVTableLast( +"icp-num-additional-vtable-last", cl::init(0), cl::Hidden, +cl::desc("The number of additional instruction for the last candidate")); + namespace { +using VTableAddressPointOffsetValMap = +SmallDenseMap, 8>; + +// A struct to collect type information for a virtual call site. +struct VirtualCallSiteInfo { + // The offset from the address point to virtual function in the vtable. + uint64_t FunctionOffset; + // The instruction that computes the address point of vtable. + Instruction *VPtr; + // The compatible type used in LLVM type intrinsics. + StringRef CompatibleTypeStr; +}; + +// The key is a virtual call, and value is its type information. +using VirtualCallSiteTypeInfoMap = +SmallDenseMap; + +// Find the offset where type string is `CompatibleType`. +static std::optional +getCompatibleTypeOffset(const GlobalVariable &VTableVar, +StringRef CompatibleType) { + SmallVector Types; // type metadata associated with a vtable. + VTableVar.getMetadata(LLVMContext::MD_type, Types); + + for (MDNode *Type : Types) +if (auto *TypeId = dyn_cast(Type->getOperand(1).get()); +TypeId && TypeId->getString() == CompatibleType) + + return cast( + cast(Type->getOperand(0))->getValue()) + ->getZExtValue(); + + return std::nullopt; +} + +// Returns a constant representing the vtable's address point specified by the +// offset. +static Constant *getVTableAddressPointOffset(GlobalVariable *VTable, + uint32_t AddressPointOffset) { + Module &M = *VTable->getParent(); + LLVMContext &Context = M.getContext(); + assert(AddressPointOffset < + M.getDataLayout().getTypeAllocSize(VTable->getValueType()) && + "Out-of-bound access"); + + return ConstantExpr::getInBoundsGetElementPtr( + Type::getInt8Ty(Context), VTable, + llvm::ConstantInt::get(Type::getInt32Ty(Context), AddressPointOffset)); +} + +// Returns the basic block in which `Inst` by `Use`. teresajohnson wrote: I don't quite follow the comment, can you expand it a bit? https://github.com/llvm/llvm-project/pull/81442 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [compiler-rt] [llvm] [TypeProf][InstrFDO]Implement more efficient comparison sequence for indirect-call-promotion with vtable profiles. (PR #81442)
@@ -103,30 +110,220 @@ static cl::opt ICPDUMPAFTER("icp-dumpafter", cl::init(false), cl::Hidden, cl::desc("Dump IR after transformation happens")); +// This option is meant to be used by LLVM regression test and test the +// transformation that compares vtables. +static cl::opt ICPEnableVTableCmp( +"icp-enable-vtable-cmp", cl::init(false), cl::Hidden, +cl::desc("If ThinLTO and WPD is enabled and this option is true, " + "indirect-call promotion pass will compare vtables rather than " + "functions for speculative devirtualization of virtual calls." + " If set to false, indirect-call promotion pass will always " + "compare functions.")); + +static cl::opt teresajohnson wrote: Add comment https://github.com/llvm/llvm-project/pull/81442 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [compiler-rt] [llvm] [TypeProf][InstrFDO]Implement more efficient comparison sequence for indirect-call-promotion with vtable profiles. (PR #81442)
@@ -103,30 +110,220 @@ static cl::opt ICPDUMPAFTER("icp-dumpafter", cl::init(false), cl::Hidden, cl::desc("Dump IR after transformation happens")); +// This option is meant to be used by LLVM regression test and test the +// transformation that compares vtables. +static cl::opt ICPEnableVTableCmp( +"icp-enable-vtable-cmp", cl::init(false), cl::Hidden, +cl::desc("If ThinLTO and WPD is enabled and this option is true, " + "indirect-call promotion pass will compare vtables rather than " + "functions for speculative devirtualization of virtual calls." + " If set to false, indirect-call promotion pass will always " + "compare functions.")); + +static cl::opt +ICPVTableCountPercentage("icp-vtable-count-percentage", cl::init(0.99), + cl::Hidden, + cl::desc("Percentage of vtable count to compare")); + +static cl::opt ICPNumAdditionalVTableLast( +"icp-num-additional-vtable-last", cl::init(0), cl::Hidden, +cl::desc("The number of additional instruction for the last candidate")); + namespace { +using VTableAddressPointOffsetValMap = +SmallDenseMap, 8>; + +// A struct to collect type information for a virtual call site. +struct VirtualCallSiteInfo { + // The offset from the address point to virtual function in the vtable. + uint64_t FunctionOffset; + // The instruction that computes the address point of vtable. + Instruction *VPtr; + // The compatible type used in LLVM type intrinsics. + StringRef CompatibleTypeStr; +}; + +// The key is a virtual call, and value is its type information. +using VirtualCallSiteTypeInfoMap = +SmallDenseMap; + +// Find the offset where type string is `CompatibleType`. +static std::optional +getCompatibleTypeOffset(const GlobalVariable &VTableVar, +StringRef CompatibleType) { + SmallVector Types; // type metadata associated with a vtable. + VTableVar.getMetadata(LLVMContext::MD_type, Types); + + for (MDNode *Type : Types) +if (auto *TypeId = dyn_cast(Type->getOperand(1).get()); +TypeId && TypeId->getString() == CompatibleType) + + return cast( + cast(Type->getOperand(0))->getValue()) + ->getZExtValue(); + + return std::nullopt; +} + +// Returns a constant representing the vtable's address point specified by the +// offset. +static Constant *getVTableAddressPointOffset(GlobalVariable *VTable, + uint32_t AddressPointOffset) { + Module &M = *VTable->getParent(); + LLVMContext &Context = M.getContext(); + assert(AddressPointOffset < + M.getDataLayout().getTypeAllocSize(VTable->getValueType()) && + "Out-of-bound access"); + + return ConstantExpr::getInBoundsGetElementPtr( + Type::getInt8Ty(Context), VTable, + llvm::ConstantInt::get(Type::getInt32Ty(Context), AddressPointOffset)); +} + +// Returns the basic block in which `Inst` by `Use`. +static BasicBlock *getUserBasicBlock(Use &U, Instruction *UserInst) { + if (PHINode *PN = dyn_cast(UserInst)) +return PN->getIncomingBlock(U); + + return UserInst->getParent(); +} + +// `DestBB` is a suitable basic block to sink `Inst` into when the following +// conditions are true: +// 1) `Inst->getParent()` is the sole predecessor of `DestBB`. This way `DestBB` +//is dominated by `Inst->getParent()` and we don't need to sink across a +//critical edge. +// 2) `Inst` have users and all users are in `DestBB`. +static bool isDestBBSuitableForSink(Instruction *Inst, BasicBlock *DestBB) { + BasicBlock *BB = Inst->getParent(); + assert(Inst->getParent() != DestBB && + BB->getTerminator()->getNumSuccessors() == 2 && + "Caller should guarantee"); + // Do not sink across a critical edge for simplicity. + if (DestBB->getUniquePredecessor() != BB) +return false; + + // Now we know BB dominates DestBB. + BasicBlock *UserBB = nullptr; + for (Use &Use : Inst->uses()) { +User *User = Use.getUser(); +// Do checked cast since IR verifier guarantees that the user of an +// instruction must be an instruction. See `Verifier::visitInstruction`. +Instruction *UserInst = cast(User); +// We can sink debug or pseudo instructions together with Inst. +if (UserInst->isDebugOrPseudoInst()) + continue; +UserBB = getUserBasicBlock(Use, UserInst); +// Do not sink if Inst is used in a basic block that is not DestBB. +// TODO: Sink to the common dominator of all user blocks. +if (UserBB != DestBB) + return false; + } + return UserBB != nullptr; +} + +// For the virtual call dispatch sequence, try to sink vtable load instructions +// to the cold indirect call fallback. +static bool tryToSinkInstruction(Instruction *I, BasicBlock *DestBlock) { + assert(!I->isTerminator()); + if (!isDestBBSuitableForSink(I, DestBlock)) +return false; + + assert(DestBlock->getUniquePre
[clang] [llvm] [CLANG][LLVM][AArch64]Add SME2.1 intrinsics for MOVAZ tile to vector,… (PR #88499)
https://github.com/momchil-velikov approved this pull request. https://github.com/llvm/llvm-project/pull/88499 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [CLANG][LLVM][AArch64]SME2.1 intrinsics for MOVAZ tile to 2/4 vectors (PR #88710)
https://github.com/momchil-velikov approved this pull request. https://github.com/llvm/llvm-project/pull/88710 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [flang] [Flang][OpenMP] Add -fopenmp-force-usm option to flang (PR #94359)
https://github.com/banach-space approved this pull request. https://github.com/llvm/llvm-project/pull/94359 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] Enable LLDB tests in Linux pre-merge CI (PR #94208)
adrian-prantl wrote: > A revert is not appropriate when: > lldb tests fail because AST printing has changed in Clang and the printed > output is valid Following the logic in this argument, would you also say it's appropriate for someone to commit an LLVM patch that changes how textual LLVM IR is printed in a way that it breaks existing tests in Clang — without updating those tests? As far as I am concerned I would expect someone making such a change to at the very least update the Clang tests to the new format, but even better to have a discussion with the community whether the benefits of this change warrant the churn in the tests. https://github.com/llvm/llvm-project/pull/94208 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Split up `SemaDeclAttr.cpp` (PR #93966)
https://github.com/AaronBallman edited https://github.com/llvm/llvm-project/pull/93966 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Split up `SemaDeclAttr.cpp` (PR #93966)
https://github.com/AaronBallman approved this pull request. LGTM! https://github.com/llvm/llvm-project/pull/93966 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Static and explicit object member functions with the same parameter-type-lists (PR #93430)
@@ -899,6 +899,8 @@ class Sema; /// object argument. bool IgnoreObjectArgument : 1; +bool TookAddressOfOverload : 1; AaronBallman wrote: CC @Endilll -- it might be nice to refactor this code to use `LLVM_PREFERRED_TYPE`, but also to fix the bit-field types so these all pack together consistently. https://github.com/llvm/llvm-project/pull/93430 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Static and explicit object member functions with the same parameter-type-lists (PR #93430)
@@ -5813,6 +5813,27 @@ static TypoCorrection TryTypoCorrectionForCall(Sema &S, Expr *Fn, return TypoCorrection(); } +// [C++26][[expr.unary.op]/p4 +// A pointer to member is only formed when an explicit & +// is used and its operand is a qualified-id not enclosed in parentheses. +static bool isParenthetizedAndQualifiedAddressOfExpr(Expr *Fn) { + if (!isa(Fn)) +return false; + + Fn = Fn->IgnoreParens(); + + auto *UO = dyn_cast(Fn); + if (!UO || UO->getOpcode() != clang::UO_AddrOf) +return false; + if (auto *DRE = dyn_cast(UO->getSubExpr()->IgnoreParens())) { +return DRE->hasQualifier(); + } + if (auto *OVL = dyn_cast(UO->getSubExpr()->IgnoreParens())) { +return OVL->getQualifier(); + } AaronBallman wrote: ```suggestion if (auto *DRE = dyn_cast(UO->getSubExpr()->IgnoreParens())) return DRE->hasQualifier(); if (auto *OVL = dyn_cast(UO->getSubExpr()->IgnoreParens())) return OVL->getQualifier(); ``` additional: is it possible to get a `MemberExpr` instead of a `DeclRefExpr`? (Thinking about accessing a data member by name; looks like a `DeclRefExpr` but is actually a `MemberExpr`.) https://github.com/llvm/llvm-project/pull/93430 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Static and explicit object member functions with the same parameter-type-lists (PR #93430)
@@ -999,6 +1001,8 @@ class Sema; /// Initialization of an object of class type by constructor, /// using either a parenthesized or braced list of arguments. CSK_InitByConstructor, + + CSK_AddressOfOverloadSet, AaronBallman wrote: Please add a doxygen comment for this enumerator. https://github.com/llvm/llvm-project/pull/93430 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] `constexpr` builtin floating point classification / comparison functions (PR #94118)
https://github.com/AaronBallman edited https://github.com/llvm/llvm-project/pull/94118 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] `constexpr` builtin floating point classification / comparison functions (PR #94118)
https://github.com/AaronBallman approved this pull request. LGTM! Thank you! https://github.com/llvm/llvm-project/pull/94118 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][C++23] update constexpr diagnostics for missing return statements per P2448 (PR #94123)
@@ -0,0 +1,7 @@ +// RUN: %clang_cc1 -Wno-return-type -std=c++23 -fsyntax-only -verify %s +// expected-no-diagnostics +constexpr int f() { } +static_assert(__is_same(decltype([] constexpr -> int { }( )), int)); AaronBallman wrote: We already have such an option, but it wasn't until today that the diagnostic worked in C++23: https://github.com/llvm/llvm-project/commit/e5f7123dfef3a80937d088d846ddb3b2bb1869b9 Should be nothing here for you to do. https://github.com/llvm/llvm-project/pull/94123 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Fix self-capturing `__block` variables (PR #89475)
@@ -2764,6 +2794,9 @@ void CodeGenFunction::emitByrefStructureInit(const AutoVarEmission &emission) { auto layoutInfo = CGM.getObjCRuntime().BuildByrefLayout(CGM, type); storeHeaderField(layoutInfo, getPointerSize(), "byref.layout"); } + + if (emission.NeedsInitOnHeap) +emitByrefInitOnHeap(pointer); ille-apple wrote: Updated to add the flag. It's not all that bad. In fact, if, as I suggested in my last comment, we want to support the byref lingering after unwinding, then there *must* be some kind of runtime state – to track whether whoever drops the last reference needs to run the destructor. It would be more natural for the Blocks runtime to track that state rather than relying on compiler-generated code, but the state has to live somewhere. If, on the other hand, we don't want to support the byref lingering after unwinding, then I could go back to the idea of mutating the existing `flags` field. In that scenario, the existence of runtime state would be unnecessary, but the implementation would be relatively unobtrusive. https://github.com/llvm/llvm-project/pull/89475 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Fix self-capturing `__block` variables (PR #89475)
https://github.com/ille-apple updated https://github.com/llvm/llvm-project/pull/89475 >From 26be4b6332bf6b58b3d99bb0065b854dcce2a944 Mon Sep 17 00:00:00 2001 From: ille-apple Date: Fri, 19 Apr 2024 15:36:44 -0700 Subject: [PATCH 1/3] [clang] Fix self-capturing `__block` variables Clang special-cases `__block` variables whose initializer contains a block literal that captures the variable itself. But this special case doesn't work for variables of record types, causing Clang to emit broken code. Fix this by initializing such variables directly on the heap, and add a warning for when this needs to be done. rdar://70498802 --- clang/include/clang/AST/Decl.h| 22 ++- .../clang/Basic/DiagnosticSemaKinds.td| 6 + clang/lib/AST/Decl.cpp| 13 ++ clang/lib/CodeGen/CGBlocks.cpp| 89 clang/lib/CodeGen/CGBlocks.h | 1 + clang/lib/CodeGen/CGDecl.cpp | 116 +--- clang/lib/CodeGen/CodeGenFunction.h | 12 +- clang/lib/CodeGen/CodeGenModule.h | 8 +- clang/lib/Sema/Sema.cpp | 66 + clang/lib/Serialization/ASTReaderDecl.cpp | 1 + clang/lib/Serialization/ASTWriterDecl.cpp | 6 +- clang/test/CodeGenCXX/block-capture.cpp | 127 +- 12 files changed, 347 insertions(+), 120 deletions(-) diff --git a/clang/include/clang/AST/Decl.h b/clang/include/clang/AST/Decl.h index 5e485ccb85a13..83c54144366b5 100644 --- a/clang/include/clang/AST/Decl.h +++ b/clang/include/clang/AST/Decl.h @@ -1103,6 +1103,11 @@ class VarDecl : public DeclaratorDecl, public Redeclarable { LLVM_PREFERRED_TYPE(bool) unsigned IsCXXCondDecl : 1; + +/// Whether this is a __block variable that is captured by a block +/// referenced in its own initializer. +LLVM_PREFERRED_TYPE(bool) +unsigned CapturedByOwnInit : 1; }; union { @@ -1588,10 +1593,23 @@ class VarDecl : public DeclaratorDecl, public Redeclarable { /// escaping block. bool isNonEscapingByref() const; - void setEscapingByref() { -NonParmVarDeclBits.EscapingByref = true; + void setEscapingByref(); + + /// Indicates this is a __block variable that is captured by a block + /// referenced in its own initializer. + bool isCapturedByOwnInit() const { +return !isa(this) && NonParmVarDeclBits.CapturedByOwnInit; } + void setCapturedByOwnInit() { +assert(!isa(this)); +NonParmVarDeclBits.CapturedByOwnInit = true; + } + + /// Check if this is a __block variable which needs to be initialized + /// directly on the heap. + bool needsInitOnHeap() const; + bool isCXXCondDecl() const { return isa(this) ? false : NonParmVarDeclBits.IsCXXCondDecl; } diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index 5a32463763aa6..c1b214fa28f07 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -2358,6 +2358,12 @@ def note_var_fixit_add_initialization : Note< def note_uninit_fixit_remove_cond : Note< "remove the %select{'%1' if its condition|condition if it}0 " "is always %select{false|true}2">; +def warn_implicit_block_var_alloc : Warning< + "variable %q0 will be initialized in a heap allocation">, + InGroup>, DefaultIgnore; +def note_because_captured_by_block : Note< + "because it is captured by a block used in its own initializer">; + def err_init_incomplete_type : Error<"initialization of incomplete type %0">; def err_list_init_in_parens : Error< "cannot initialize %select{non-class|reference}0 type %1 with a " diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp index 41fbfe281ef65..3a584849160a8 100644 --- a/clang/lib/AST/Decl.cpp +++ b/clang/lib/AST/Decl.cpp @@ -2680,6 +2680,19 @@ bool VarDecl::isNonEscapingByref() const { return hasAttr() && !NonParmVarDeclBits.EscapingByref; } +void VarDecl::setEscapingByref() { + assert(!isa(this) && hasAttr()); + NonParmVarDeclBits.EscapingByref = true; +} + +bool VarDecl::needsInitOnHeap() const { + // We need direct initialization on the heap for self-capturing __block + // variables of types that cause CodeGenFunction::getEvaluationKind to return + // TEK_Aggregate. The only such types that can be captured are records. + return isCapturedByOwnInit() && + getType().getAtomicUnqualifiedType()->isRecordType(); +} + bool VarDecl::hasDependentAlignment() const { QualType T = getType(); return T->isDependentType() || T->isUndeducedType() || diff --git a/clang/lib/CodeGen/CGBlocks.cpp b/clang/lib/CodeGen/CGBlocks.cpp index bf50f2025de57..2b381a5301180 100644 --- a/clang/lib/CodeGen/CGBlocks.cpp +++ b/clang/lib/CodeGen/CGBlocks.cpp @@ -45,6 +45,13 @@ CGBlockInfo::CGBlockInfo(const BlockDecl *block, StringRef name) name = name.substr(1); } +BlockByrefHelpers::BlockByrefHelpers(const BlockByrefInfo
[clang] [clang] Fix self-capturing `__block` variables (PR #89475)
https://github.com/ille-apple updated https://github.com/llvm/llvm-project/pull/89475 >From 26be4b6332bf6b58b3d99bb0065b854dcce2a944 Mon Sep 17 00:00:00 2001 From: ille-apple Date: Fri, 19 Apr 2024 15:36:44 -0700 Subject: [PATCH 1/2] [clang] Fix self-capturing `__block` variables Clang special-cases `__block` variables whose initializer contains a block literal that captures the variable itself. But this special case doesn't work for variables of record types, causing Clang to emit broken code. Fix this by initializing such variables directly on the heap, and add a warning for when this needs to be done. rdar://70498802 --- clang/include/clang/AST/Decl.h| 22 ++- .../clang/Basic/DiagnosticSemaKinds.td| 6 + clang/lib/AST/Decl.cpp| 13 ++ clang/lib/CodeGen/CGBlocks.cpp| 89 clang/lib/CodeGen/CGBlocks.h | 1 + clang/lib/CodeGen/CGDecl.cpp | 116 +--- clang/lib/CodeGen/CodeGenFunction.h | 12 +- clang/lib/CodeGen/CodeGenModule.h | 8 +- clang/lib/Sema/Sema.cpp | 66 + clang/lib/Serialization/ASTReaderDecl.cpp | 1 + clang/lib/Serialization/ASTWriterDecl.cpp | 6 +- clang/test/CodeGenCXX/block-capture.cpp | 127 +- 12 files changed, 347 insertions(+), 120 deletions(-) diff --git a/clang/include/clang/AST/Decl.h b/clang/include/clang/AST/Decl.h index 5e485ccb85a13..83c54144366b5 100644 --- a/clang/include/clang/AST/Decl.h +++ b/clang/include/clang/AST/Decl.h @@ -1103,6 +1103,11 @@ class VarDecl : public DeclaratorDecl, public Redeclarable { LLVM_PREFERRED_TYPE(bool) unsigned IsCXXCondDecl : 1; + +/// Whether this is a __block variable that is captured by a block +/// referenced in its own initializer. +LLVM_PREFERRED_TYPE(bool) +unsigned CapturedByOwnInit : 1; }; union { @@ -1588,10 +1593,23 @@ class VarDecl : public DeclaratorDecl, public Redeclarable { /// escaping block. bool isNonEscapingByref() const; - void setEscapingByref() { -NonParmVarDeclBits.EscapingByref = true; + void setEscapingByref(); + + /// Indicates this is a __block variable that is captured by a block + /// referenced in its own initializer. + bool isCapturedByOwnInit() const { +return !isa(this) && NonParmVarDeclBits.CapturedByOwnInit; } + void setCapturedByOwnInit() { +assert(!isa(this)); +NonParmVarDeclBits.CapturedByOwnInit = true; + } + + /// Check if this is a __block variable which needs to be initialized + /// directly on the heap. + bool needsInitOnHeap() const; + bool isCXXCondDecl() const { return isa(this) ? false : NonParmVarDeclBits.IsCXXCondDecl; } diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index 5a32463763aa6..c1b214fa28f07 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -2358,6 +2358,12 @@ def note_var_fixit_add_initialization : Note< def note_uninit_fixit_remove_cond : Note< "remove the %select{'%1' if its condition|condition if it}0 " "is always %select{false|true}2">; +def warn_implicit_block_var_alloc : Warning< + "variable %q0 will be initialized in a heap allocation">, + InGroup>, DefaultIgnore; +def note_because_captured_by_block : Note< + "because it is captured by a block used in its own initializer">; + def err_init_incomplete_type : Error<"initialization of incomplete type %0">; def err_list_init_in_parens : Error< "cannot initialize %select{non-class|reference}0 type %1 with a " diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp index 41fbfe281ef65..3a584849160a8 100644 --- a/clang/lib/AST/Decl.cpp +++ b/clang/lib/AST/Decl.cpp @@ -2680,6 +2680,19 @@ bool VarDecl::isNonEscapingByref() const { return hasAttr() && !NonParmVarDeclBits.EscapingByref; } +void VarDecl::setEscapingByref() { + assert(!isa(this) && hasAttr()); + NonParmVarDeclBits.EscapingByref = true; +} + +bool VarDecl::needsInitOnHeap() const { + // We need direct initialization on the heap for self-capturing __block + // variables of types that cause CodeGenFunction::getEvaluationKind to return + // TEK_Aggregate. The only such types that can be captured are records. + return isCapturedByOwnInit() && + getType().getAtomicUnqualifiedType()->isRecordType(); +} + bool VarDecl::hasDependentAlignment() const { QualType T = getType(); return T->isDependentType() || T->isUndeducedType() || diff --git a/clang/lib/CodeGen/CGBlocks.cpp b/clang/lib/CodeGen/CGBlocks.cpp index bf50f2025de57..2b381a5301180 100644 --- a/clang/lib/CodeGen/CGBlocks.cpp +++ b/clang/lib/CodeGen/CGBlocks.cpp @@ -45,6 +45,13 @@ CGBlockInfo::CGBlockInfo(const BlockDecl *block, StringRef name) name = name.substr(1); } +BlockByrefHelpers::BlockByrefHelpers(const BlockByrefInfo
[clang] [Clang] Fix potential null pointer dereferences in Sema::AddInitializerToDecl (PR #94368)
https://github.com/feg208 approved this pull request. ltgm https://github.com/llvm/llvm-project/pull/94368 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-tools-extra] [libcxx] Reland "[clang] Enable sized deallocation by default in C++14 onwards" (PR #90373)
glandium wrote: What kind of detail are you looking for? https://github.com/llvm/llvm-project/pull/90373 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-repl] Lay the foundation of pretty printing for C. (PR #89811)
https://github.com/vgvassilev updated https://github.com/llvm/llvm-project/pull/89811 >From 3094e6026925ebcba6da86dd16111f4f70f9a700 Mon Sep 17 00:00:00 2001 From: Vassil Vassilev Date: Tue, 23 Apr 2024 19:33:00 + Subject: [PATCH] [clang-repl] Lay the foundation of pretty printing for C. --- clang/lib/Interpreter/Interpreter.cpp | 166 ++ clang/lib/Parse/ParseStmt.cpp | 5 +- clang/test/Interpreter/pretty-print.c | 8 ++ 3 files changed, 101 insertions(+), 78 deletions(-) create mode 100644 clang/test/Interpreter/pretty-print.c diff --git a/clang/lib/Interpreter/Interpreter.cpp b/clang/lib/Interpreter/Interpreter.cpp index 683f87e8c8c79..bd5a91dbf8ec9 100644 --- a/clang/lib/Interpreter/Interpreter.cpp +++ b/clang/lib/Interpreter/Interpreter.cpp @@ -42,6 +42,9 @@ #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/raw_ostream.h" #include "llvm/TargetParser/Host.h" + +#include + using namespace clang; // FIXME: Figure out how to unify with namespace init_convenience from @@ -270,14 +273,10 @@ Interpreter::~Interpreter() { // can't find the precise resource directory in unittests so we have to hard // code them. const char *const Runtimes = R"( +#define __CLANG_REPL__ 1 #ifdef __cplusplus +#define EXTERN_C extern "C" void *__clang_Interpreter_SetValueWithAlloc(void*, void*, void*); -void __clang_Interpreter_SetValueNoAlloc(void*, void*, void*); -void __clang_Interpreter_SetValueNoAlloc(void*, void*, void*, void*); -void __clang_Interpreter_SetValueNoAlloc(void*, void*, void*, float); -void __clang_Interpreter_SetValueNoAlloc(void*, void*, void*, double); -void __clang_Interpreter_SetValueNoAlloc(void*, void*, void*, long double); -void __clang_Interpreter_SetValueNoAlloc(void*,void*,void*,unsigned long long); struct __clang_Interpreter_NewTag{} __ci_newtag; void* operator new(__SIZE_TYPE__, void* __p, __clang_Interpreter_NewTag) noexcept; template @@ -289,7 +288,11 @@ const char *const Runtimes = R"( void __clang_Interpreter_SetValueCopyArr(const T (*Src)[N], void* Placement, unsigned long Size) { __clang_Interpreter_SetValueCopyArr(Src[0], Placement, Size); } +#else +#define EXTERN_C extern #endif // __cplusplus + + EXTERN_C void __clang_Interpreter_SetValueNoAlloc(void *This, void *OutVal, void *OpaqueType, ...); )"; llvm::Expected> @@ -588,15 +591,17 @@ std::unique_ptr Interpreter::FindRuntimeInterface() { if (!LookupInterface(ValuePrintingInfo[NoAlloc], MagicRuntimeInterface[NoAlloc])) return nullptr; - if (!LookupInterface(ValuePrintingInfo[WithAlloc], - MagicRuntimeInterface[WithAlloc])) -return nullptr; - if (!LookupInterface(ValuePrintingInfo[CopyArray], - MagicRuntimeInterface[CopyArray])) -return nullptr; - if (!LookupInterface(ValuePrintingInfo[NewTag], - MagicRuntimeInterface[NewTag])) -return nullptr; + if (Ctx.getLangOpts().CPlusPlus) { +if (!LookupInterface(ValuePrintingInfo[WithAlloc], + MagicRuntimeInterface[WithAlloc])) + return nullptr; +if (!LookupInterface(ValuePrintingInfo[CopyArray], + MagicRuntimeInterface[CopyArray])) + return nullptr; +if (!LookupInterface(ValuePrintingInfo[NewTag], + MagicRuntimeInterface[NewTag])) + return nullptr; + } return createInProcessRuntimeInterfaceBuilder(*this, Ctx, S); } @@ -855,69 +860,82 @@ __clang_Interpreter_SetValueWithAlloc(void *This, void *OutVal, return VRef.getPtr(); } -// Pointers, lvalue struct that can take as a reference. -REPL_EXTERNAL_VISIBILITY void -__clang_Interpreter_SetValueNoAlloc(void *This, void *OutVal, void *OpaqueType, -void *Val) { +REPL_EXTERNAL_VISIBILITY +extern "C" void __clang_Interpreter_SetValueNoAlloc(void *This, void *OutVal, +void *OpaqueType, ...) { Value &VRef = *(Value *)OutVal; - VRef = Value(static_cast(This), OpaqueType); - VRef.setPtr(Val); -} + Interpreter *I = static_cast(This); + VRef = Value(I, OpaqueType); + if (VRef.isVoid()) +return; -REPL_EXTERNAL_VISIBILITY void -__clang_Interpreter_SetValueNoAlloc(void *This, void *OutVal, -void *OpaqueType) { - Value &VRef = *(Value *)OutVal; - VRef = Value(static_cast(This), OpaqueType); -} + va_list args; + va_start(args, /*last named param*/ OpaqueType); -static void SetValueDataBasedOnQualType(Value &V, unsigned long long Data) { - QualType QT = V.getType(); - if (const auto *ET = QT->getAs()) -QT = ET->getDecl()->getIntegerType(); - - switch (QT->castAs()->getKind()) { - default: -llvm_unreachable("unknown type kind!"); -#define X(type, name) \ - case BuiltinType::name:
[clang] [clang] Fix-it hint for `++this` -> `++*this` when deref is modifiable (PR #94159)
@@ -13367,6 +13367,8 @@ static void DiagnoseConstAssignment(Sema &S, const Expr *E, if (!DiagnosticEmitted) { S.Diag(Loc, diag::err_typecheck_assign_const) << ExprRange << ConstVariable << VD << VD->getType(); + S.Diag(Loc, diag::note_typecheck_expression_not_modifiable_lvalue) + << E->getSourceRange(); Sirraide wrote: > This addition caused few more tests to fail. Yes, that much is expected because the tests expect that certain diagnostics (and only those diagnostics) are emitted. You will probably have to update several tests to include this diagnostic because of that. Just make sure that the failures actually make sense (i.e. they’re failing because we’re adding this here, which is expected; we previously weren’t emitting this, and now we are) and that they aren’t something unrelated that your changes broke somehow. https://github.com/llvm/llvm-project/pull/94159 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Fix-it hint for `++this` -> `++*this` when deref is modifiable (PR #94159)
@@ -13367,6 +13367,8 @@ static void DiagnoseConstAssignment(Sema &S, const Expr *E, if (!DiagnosticEmitted) { S.Diag(Loc, diag::err_typecheck_assign_const) << ExprRange << ConstVariable << VD << VD->getType(); + S.Diag(Loc, diag::note_typecheck_expression_not_modifiable_lvalue) + << E->getSourceRange(); Rajveer100 wrote: @Sirraide This addition caused few more tests to fail. It's for the `++b` part in tests (maybe there's a different way to go about this), apart from that, looks fine to me. Let me know your thoughts. https://github.com/llvm/llvm-project/pull/94159 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Lower _BitInt(129+) to a different type in LLVM IR (PR #91364)
@@ -128,6 +128,15 @@ class CodeGenTypes { /// memory representation is usually i8 or i32, depending on the target. llvm::Type *ConvertTypeForMem(QualType T, bool ForBitField = false); + /// Check that size and abi alignment of given LLVM type matches size and + /// alignment of given AST type. + bool LLVMTypeLayoutMatchesAST(QualType ASTTy, llvm::Type *LLVMTy); efriedma-quic wrote: In that case, please rename this to something that more accurately corresponds to that usage. https://github.com/llvm/llvm-project/pull/91364 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Lower _BitInt(129+) to a different type in LLVM IR (PR #91364)
@@ -761,6 +761,10 @@ bool ConstStructBuilder::Build(const InitListExpr *ILE, bool AllowOverwrite) { if (Field->hasAttr()) AllowOverwrite = true; } else { + llvm::Type *LoadType = CGM.getTypes().convertTypeForLoadStore( efriedma-quic wrote: I think you can use llvm::Constant? But that's fine, sure. https://github.com/llvm/llvm-project/pull/91364 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][AMDGPU] Use `I` to decorate imm argument for `__builtin_amdgcn_global_load_lds` (PR #94376)
https://github.com/shiltian updated https://github.com/llvm/llvm-project/pull/94376 >From d5ecf4e5f3cd5b7191acf3fd24ef0ac98b8a9f3e Mon Sep 17 00:00:00 2001 From: Shilei Tian Date: Tue, 4 Jun 2024 15:10:08 -0400 Subject: [PATCH] [Clang][AMDGPU] Use `I` to decorate imm argument for `__builtin_amdgcn_global_load_lds` --- clang/include/clang/Basic/BuiltinsAMDGPU.def| 2 +- clang/lib/Sema/SemaAMDGPU.cpp | 3 +-- clang/test/SemaOpenCL/builtins-amdgcn-gfx940-err.cl | 6 -- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/clang/include/clang/Basic/BuiltinsAMDGPU.def b/clang/include/clang/Basic/BuiltinsAMDGPU.def index 433c7795325f0..9e6800ea814a0 100644 --- a/clang/include/clang/Basic/BuiltinsAMDGPU.def +++ b/clang/include/clang/Basic/BuiltinsAMDGPU.def @@ -240,7 +240,7 @@ TARGET_BUILTIN(__builtin_amdgcn_flat_atomic_fadd_v2bf16, "V2sV2s*0V2s", "t", "at TARGET_BUILTIN(__builtin_amdgcn_global_atomic_fadd_v2bf16, "V2sV2s*1V2s", "t", "atomic-global-pk-add-bf16-inst") TARGET_BUILTIN(__builtin_amdgcn_ds_atomic_fadd_v2bf16, "V2sV2s*3V2s", "t", "atomic-ds-pk-add-16-insts") TARGET_BUILTIN(__builtin_amdgcn_ds_atomic_fadd_v2f16, "V2hV2h*3V2h", "t", "atomic-ds-pk-add-16-insts") -TARGET_BUILTIN(__builtin_amdgcn_global_load_lds, "vv*1v*3UiiUi", "t", "gfx940-insts") +TARGET_BUILTIN(__builtin_amdgcn_global_load_lds, "vv*1v*3IUiIiIUi", "t", "gfx940-insts") //===--===// // Deep learning builtins. diff --git a/clang/lib/Sema/SemaAMDGPU.cpp b/clang/lib/Sema/SemaAMDGPU.cpp index c446cc1d042a4..51d4f0d3d9648 100644 --- a/clang/lib/Sema/SemaAMDGPU.cpp +++ b/clang/lib/Sema/SemaAMDGPU.cpp @@ -32,8 +32,7 @@ bool SemaAMDGPU::CheckAMDGCNBuiltinFunctionCall(unsigned BuiltinID, llvm::APSInt Size; Expr *ArgExpr = TheCall->getArg(SizeIdx); ExprResult R = SemaRef.VerifyIntegerConstantExpression(ArgExpr, &Size); -if (R.isInvalid()) - return true; +assert(!R.isInvalid()); switch (Size.getSExtValue()) { case 1: case 2: diff --git a/clang/test/SemaOpenCL/builtins-amdgcn-gfx940-err.cl b/clang/test/SemaOpenCL/builtins-amdgcn-gfx940-err.cl index 487cc53e8ad8a..2a1ba4300864c 100644 --- a/clang/test/SemaOpenCL/builtins-amdgcn-gfx940-err.cl +++ b/clang/test/SemaOpenCL/builtins-amdgcn-gfx940-err.cl @@ -3,8 +3,10 @@ typedef unsigned int u32; -void test_global_load_lds_unsupported_size(global u32* src, local u32 *dst, u32 size) { - __builtin_amdgcn_global_load_lds(src, dst, size, /*offset=*/0, /*aux=*/0); // expected-error{{expression is not an integer constant expression}} +void test_global_load_lds_unsupported_size(global u32* src, local u32 *dst, u32 size, u32 offset, u32 aux) { + __builtin_amdgcn_global_load_lds(src, dst, size, /*offset=*/0, /*aux=*/0); // expected-error{{argument to '__builtin_amdgcn_global_load_lds' must be a constant integer}} + __builtin_amdgcn_global_load_lds(src, dst, /*size=*/4, offset, /*aux=*/0); // expected-error{{argument to '__builtin_amdgcn_global_load_lds' must be a constant integer}} + __builtin_amdgcn_global_load_lds(src, dst, /*size=*/4, /*offset=*/0, aux); // expected-error{{argument to '__builtin_amdgcn_global_load_lds' must be a constant integer}} __builtin_amdgcn_global_load_lds(src, dst, /*size=*/5, /*offset=*/0, /*aux=*/0); // expected-error{{invalid size value}} expected-note {{size must be 1, 2, or 4}} __builtin_amdgcn_global_load_lds(src, dst, /*size=*/0, /*offset=*/0, /*aux=*/0); // expected-error{{invalid size value}} expected-note {{size must be 1, 2, or 4}} __builtin_amdgcn_global_load_lds(src, dst, /*size=*/3, /*offset=*/0, /*aux=*/0); // expected-error{{invalid size value}} expected-note {{size must be 1, 2, or 4}} ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][C++23] update constexpr diagnostics for missing return statements per P2448 (PR #94123)
@@ -0,0 +1,7 @@ +// RUN: %clang_cc1 -Wno-return-type -std=c++23 -fsyntax-only -verify %s +// expected-no-diagnostics +constexpr int f() { } +static_assert(__is_same(decltype([] constexpr -> int { }( )), int)); a-tarasyuk wrote: @AaronBallman Thanks for the review. Should a new option (`-Winvalid-constexpr`) be added to control warnings for this case? Is that what you're referring to? https://github.com/llvm/llvm-project/pull/94123 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][C++23] update constexpr diagnostics for missing return statements per P2448 (PR #94123)
https://github.com/a-tarasyuk deleted https://github.com/llvm/llvm-project/pull/94123 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][C++23] update constexpr diagnostics for missing return statements per P2448 (PR #94123)
@@ -0,0 +1,7 @@ +// RUN: %clang_cc1 -Wno-return-type -std=c++23 -fsyntax-only -verify %s +// expected-no-diagnostics +constexpr int f() { } +static_assert(__is_same(decltype([] constexpr -> int { }( )), int)); a-tarasyuk wrote: @AaronBallman Should a new option (`-Winvalid-constexpr`) be added to control warnings for this case? Is that what you're referring to? https://github.com/llvm/llvm-project/pull/94123 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][C++23] update constexpr diagnostics for missing return statements per P2448 (PR #94123)
@@ -2487,6 +2477,26 @@ static bool CheckConstexprFunctionBody(Sema &SemaRef, const FunctionDecl *Dcl, return true; } +static bool CheckConstexprMissingReturn(Sema &SemaRef, +const FunctionDecl *Dcl) { + bool IsVoidOrDependentType = Dcl->getReturnType()->isVoidType() || + Dcl->getReturnType()->isDependentType(); + + if (SemaRef.getLangOpts().CPlusPlus23 && !IsVoidOrDependentType) +return true; + + // C++1y doesn't require constexpr functions to contain a 'return' + // statement. We still do, unless the return type might be void, because + // otherwise if there's no return statement, the function cannot + // be used in a core constant expression. a-tarasyuk wrote: @Fznamznon Thanks for the review. I've added a comment. https://github.com/llvm/llvm-project/pull/94123 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][CodeGen] Make `UnqualPtrTy` truly unqualified (PR #94388)
jrtc27 wrote: I don't think that assumption is currently true. I think it's also worth clarifying what this thing is, and possibly renaming it, because "unqualified" has C language level meaning that would contradict what it is here. https://github.com/llvm/llvm-project/pull/94388 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][CodeGen] Make `UnqualPtrTy` truly unqualified (PR #94388)
https://github.com/AlexVlx updated https://github.com/llvm/llvm-project/pull/94388 >From cdf95a804614950167d2d4df227d06a86a70d4bb Mon Sep 17 00:00:00 2001 From: Alex Voicu Date: Tue, 4 Jun 2024 19:52:28 +0100 Subject: [PATCH] Unqualified `ptr`s should be truly unqualified, and not AS0 ptrs. --- clang/lib/CodeGen/CodeGenModule.cpp | 1 + clang/lib/CodeGen/CodeGenTypeCache.h | 4 +++- clang/lib/CodeGen/ItaniumCXXABI.cpp | 6 +++--- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index be7bf0b72dc0c..b58ca03ce69da 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -368,6 +368,7 @@ CodeGenModule::CodeGenModule(ASTContext &C, IntTy = llvm::IntegerType::get(LLVMContext, C.getTargetInfo().getIntWidth()); IntPtrTy = llvm::IntegerType::get(LLVMContext, C.getTargetInfo().getMaxPointerWidth()); + UnqualPtrTy = llvm::PointerType::getUnqual(LLVMContext); Int8PtrTy = llvm::PointerType::get(LLVMContext, C.getTargetAddressSpace(LangAS::Default)); const llvm::DataLayout &DL = M.getDataLayout(); diff --git a/clang/lib/CodeGen/CodeGenTypeCache.h b/clang/lib/CodeGen/CodeGenTypeCache.h index e273ebe3b060f..3b659bc182aa4 100644 --- a/clang/lib/CodeGen/CodeGenTypeCache.h +++ b/clang/lib/CodeGen/CodeGenTypeCache.h @@ -51,9 +51,11 @@ struct CodeGenTypeCache { llvm::IntegerType *PtrDiffTy; }; + /// unqualified void* + llvm::PointerType *UnqualPtrTy; + /// void*, void** in the target's default address space (often 0) union { -llvm::PointerType *UnqualPtrTy; llvm::PointerType *VoidPtrTy; llvm::PointerType *Int8PtrTy; llvm::PointerType *VoidPtrPtrTy; diff --git a/clang/lib/CodeGen/ItaniumCXXABI.cpp b/clang/lib/CodeGen/ItaniumCXXABI.cpp index 8427286dee887..8952e7ca072da 100644 --- a/clang/lib/CodeGen/ItaniumCXXABI.cpp +++ b/clang/lib/CodeGen/ItaniumCXXABI.cpp @@ -4656,14 +4656,14 @@ static void InitCatchParam(CodeGenFunction &CGF, auto catchRD = CatchType->getAsCXXRecordDecl(); CharUnits caughtExnAlignment = CGF.CGM.getClassPointerAlignment(catchRD); - llvm::Type *PtrTy = CGF.UnqualPtrTy; // addrspace 0 ok + llvm::Type *PtrTy = CGF.UnqualPtrTy; // unqualified is ok // Check for a copy expression. If we don't have a copy expression, // that means a trivial copy is okay. const Expr *copyExpr = CatchParam.getInit(); if (!copyExpr) { llvm::Value *rawAdjustedExn = CallBeginCatch(CGF, Exn, true); -Address adjustedExn(CGF.Builder.CreateBitCast(rawAdjustedExn, PtrTy), +Address adjustedExn(CGF.Builder.CreatePointerCast(rawAdjustedExn, PtrTy), LLVMCatchTy, caughtExnAlignment); LValue Dest = CGF.MakeAddrLValue(ParamAddr, CatchType); LValue Src = CGF.MakeAddrLValue(adjustedExn, CatchType); @@ -4677,7 +4677,7 @@ static void InitCatchParam(CodeGenFunction &CGF, CGF.EmitNounwindRuntimeCall(getGetExceptionPtrFn(CGF.CGM), Exn); // Cast that to the appropriate type. - Address adjustedExn(CGF.Builder.CreateBitCast(rawAdjustedExn, PtrTy), + Address adjustedExn(CGF.Builder.CreatePointerCast(rawAdjustedExn, PtrTy), LLVMCatchTy, caughtExnAlignment); // The copy expression is defined in terms of an OpaqueValueExpr. ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][CodeGen] Make `UnqualPtrTy` truly unqualified (PR #94388)
llvmbot wrote: @llvm/pr-subscribers-clang-codegen @llvm/pr-subscribers-clang Author: Alex Voicu (AlexVlx) Changes At the moment we alias `UnqualPtrTy` with the other default AS pointer types, which means that for certain targets using it doesn't actually yield an unqualified pointer. This patch changes that so that it does exactly what it says on the tin, under the assumption that if someone asks for an unqualified pointer they do so knowingly and expect to get exactly that. --- Full diff: https://github.com/llvm/llvm-project/pull/94388.diff 3 Files Affected: - (modified) clang/lib/CodeGen/CodeGenModule.cpp (+1) - (modified) clang/lib/CodeGen/CodeGenTypeCache.h (+3-1) - (modified) clang/lib/CodeGen/ItaniumCXXABI.cpp (+3-3) ``diff diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index be7bf0b72dc0c..b58ca03ce69da 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -368,6 +368,7 @@ CodeGenModule::CodeGenModule(ASTContext &C, IntTy = llvm::IntegerType::get(LLVMContext, C.getTargetInfo().getIntWidth()); IntPtrTy = llvm::IntegerType::get(LLVMContext, C.getTargetInfo().getMaxPointerWidth()); + UnqualPtrTy = llvm::PointerType::getUnqual(LLVMContext); Int8PtrTy = llvm::PointerType::get(LLVMContext, C.getTargetAddressSpace(LangAS::Default)); const llvm::DataLayout &DL = M.getDataLayout(); diff --git a/clang/lib/CodeGen/CodeGenTypeCache.h b/clang/lib/CodeGen/CodeGenTypeCache.h index e273ebe3b060f..3b659bc182aa4 100644 --- a/clang/lib/CodeGen/CodeGenTypeCache.h +++ b/clang/lib/CodeGen/CodeGenTypeCache.h @@ -51,9 +51,11 @@ struct CodeGenTypeCache { llvm::IntegerType *PtrDiffTy; }; + /// unqualified void* + llvm::PointerType *UnqualPtrTy; + /// void*, void** in the target's default address space (often 0) union { -llvm::PointerType *UnqualPtrTy; llvm::PointerType *VoidPtrTy; llvm::PointerType *Int8PtrTy; llvm::PointerType *VoidPtrPtrTy; diff --git a/clang/lib/CodeGen/ItaniumCXXABI.cpp b/clang/lib/CodeGen/ItaniumCXXABI.cpp index 8427286dee887..8952e7ca072da 100644 --- a/clang/lib/CodeGen/ItaniumCXXABI.cpp +++ b/clang/lib/CodeGen/ItaniumCXXABI.cpp @@ -4656,14 +4656,14 @@ static void InitCatchParam(CodeGenFunction &CGF, auto catchRD = CatchType->getAsCXXRecordDecl(); CharUnits caughtExnAlignment = CGF.CGM.getClassPointerAlignment(catchRD); - llvm::Type *PtrTy = CGF.UnqualPtrTy; // addrspace 0 ok + llvm::Type *PtrTy = CGF.UnqualPtrTy; // unqualified is ok // Check for a copy expression. If we don't have a copy expression, // that means a trivial copy is okay. const Expr *copyExpr = CatchParam.getInit(); if (!copyExpr) { llvm::Value *rawAdjustedExn = CallBeginCatch(CGF, Exn, true); -Address adjustedExn(CGF.Builder.CreateBitCast(rawAdjustedExn, PtrTy), +Address adjustedExn(CGF.Builder.CreatePointerCast(rawAdjustedExn, PtrTy), LLVMCatchTy, caughtExnAlignment); LValue Dest = CGF.MakeAddrLValue(ParamAddr, CatchType); LValue Src = CGF.MakeAddrLValue(adjustedExn, CatchType); @@ -4677,7 +4677,7 @@ static void InitCatchParam(CodeGenFunction &CGF, CGF.EmitNounwindRuntimeCall(getGetExceptionPtrFn(CGF.CGM), Exn); // Cast that to the appropriate type. - Address adjustedExn(CGF.Builder.CreateBitCast(rawAdjustedExn, PtrTy), + Address adjustedExn(CGF.Builder.CreatePointerCast(rawAdjustedExn, PtrTy), LLVMCatchTy, caughtExnAlignment); // The copy expression is defined in terms of an OpaqueValueExpr. `` https://github.com/llvm/llvm-project/pull/94388 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][C++23] update constexpr diagnostics for missing return statements per P2448 (PR #94123)
https://github.com/a-tarasyuk updated https://github.com/llvm/llvm-project/pull/94123 >From 90eeafc82ee08129c2d290e6382f42ec89680049 Mon Sep 17 00:00:00 2001 From: Oleksandr T Date: Sun, 2 Jun 2024 00:07:35 +0300 Subject: [PATCH 1/3] feat(92583): [C++23] update constexpr diagnostics for missing return statements per P2448 --- clang/lib/Sema/SemaDeclCXX.cpp| 34 --- .../CXX/dcl.dcl/dcl.spec/dcl.constexpr/p3.cpp | 2 +- .../SemaCXX/constant-expression-cxx14.cpp | 2 +- .../constexpr-return-non-void-cxx2b.cpp | 7 4 files changed, 31 insertions(+), 14 deletions(-) create mode 100644 clang/test/SemaCXX/constexpr-return-non-void-cxx2b.cpp diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp index 631fd4e354927..d4401a427282c 100644 --- a/clang/lib/Sema/SemaDeclCXX.cpp +++ b/clang/lib/Sema/SemaDeclCXX.cpp @@ -1806,6 +1806,7 @@ static unsigned getRecordDiagFromTagKind(TagTypeKind Tag) { static bool CheckConstexprFunctionBody(Sema &SemaRef, const FunctionDecl *Dcl, Stmt *Body, Sema::CheckConstexprKind Kind); +static bool CheckConstexprMissingReturn(Sema &SemaRef, const FunctionDecl *Dcl); // Check whether a function declaration satisfies the requirements of a // constexpr function definition or a constexpr constructor definition. If so, @@ -2411,20 +2412,9 @@ static bool CheckConstexprFunctionBody(Sema &SemaRef, const FunctionDecl *Dcl, } } else { if (ReturnStmts.empty()) { - // C++1y doesn't require constexpr functions to contain a 'return' - // statement. We still do, unless the return type might be void, because - // otherwise if there's no return statement, the function cannot - // be used in a core constant expression. - bool OK = SemaRef.getLangOpts().CPlusPlus14 && -(Dcl->getReturnType()->isVoidType() || - Dcl->getReturnType()->isDependentType()); switch (Kind) { case Sema::CheckConstexprKind::Diagnose: -SemaRef.Diag(Dcl->getLocation(), - OK ? diag::warn_cxx11_compat_constexpr_body_no_return -: diag::err_constexpr_body_no_return) -<< Dcl->isConsteval(); -if (!OK) +if (!CheckConstexprMissingReturn(SemaRef, Dcl)) return false; break; @@ -2487,6 +2477,26 @@ static bool CheckConstexprFunctionBody(Sema &SemaRef, const FunctionDecl *Dcl, return true; } +static bool CheckConstexprMissingReturn(Sema &SemaRef, +const FunctionDecl *Dcl) { + bool IsVoidOrDependentType = Dcl->getReturnType()->isVoidType() || + Dcl->getReturnType()->isDependentType(); + + if (SemaRef.getLangOpts().CPlusPlus23 && !IsVoidOrDependentType) +return true; + + // C++1y doesn't require constexpr functions to contain a 'return' + // statement. We still do, unless the return type might be void, because + // otherwise if there's no return statement, the function cannot + // be used in a core constant expression. + bool OK = SemaRef.getLangOpts().CPlusPlus14 && IsVoidOrDependentType; + SemaRef.Diag(Dcl->getLocation(), + OK ? diag::warn_cxx11_compat_constexpr_body_no_return + : diag::err_constexpr_body_no_return) + << Dcl->isConsteval(); + return OK; +} + bool Sema::CheckImmediateEscalatingFunctionDefinition( FunctionDecl *FD, const sema::FunctionScopeInfo *FSI) { if (!getLangOpts().CPlusPlus20 || !FD->isImmediateEscalating()) diff --git a/clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p3.cpp b/clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p3.cpp index 4416c82522649..51990ee4341d2 100644 --- a/clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p3.cpp +++ b/clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p3.cpp @@ -212,7 +212,7 @@ constexpr int ClassDecl3() { return 0; } -constexpr int NoReturn() {} // expected-error {{no return statement in constexpr function}} +constexpr int NoReturn() {} // beforecxx23-error {{no return statement in constexpr function}} constexpr int MultiReturn() { return 0; // beforecxx14-note {{return statement}} return 0; // beforecxx14-warning {{multiple return statements in constexpr function}} diff --git a/clang/test/SemaCXX/constant-expression-cxx14.cpp b/clang/test/SemaCXX/constant-expression-cxx14.cpp index 80a7a2dd31531..70ab5dcd357c1 100644 --- a/clang/test/SemaCXX/constant-expression-cxx14.cpp +++ b/clang/test/SemaCXX/constant-expression-cxx14.cpp @@ -82,7 +82,7 @@ constexpr void k() { // If the return type is not 'void', no return statements => never a constant // expression, so still diagnose that case. -[[noreturn]] constexpr int fn() { // expected-error {{no return statement in constexpr function}} +[[noreturn]] constexpr int fn() { // cxx14_20-error {{no return statement in constexpr function}} fn(); } diff -
[clang] [clang][CodeGen] Make `UnqualPtrTy` truly unqualified (PR #94388)
https://github.com/AlexVlx created https://github.com/llvm/llvm-project/pull/94388 At the moment we alias `UnqualPtrTy` with the other default AS pointer types, which means that for certain targets using it doesn't actually yield an unqualified pointer. This patch changes that so that it does exactly what it says on the tin, under the assumption that if someone asks for an unqualified pointer they do so knowingly and expect to get exactly that. >From cdf95a804614950167d2d4df227d06a86a70d4bb Mon Sep 17 00:00:00 2001 From: Alex Voicu Date: Tue, 4 Jun 2024 19:52:28 +0100 Subject: [PATCH] Unqualified `ptr`s should be truly unqualified, and not AS0 ptrs. --- clang/lib/CodeGen/CodeGenModule.cpp | 1 + clang/lib/CodeGen/CodeGenTypeCache.h | 4 +++- clang/lib/CodeGen/ItaniumCXXABI.cpp | 6 +++--- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index be7bf0b72dc0c..b58ca03ce69da 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -368,6 +368,7 @@ CodeGenModule::CodeGenModule(ASTContext &C, IntTy = llvm::IntegerType::get(LLVMContext, C.getTargetInfo().getIntWidth()); IntPtrTy = llvm::IntegerType::get(LLVMContext, C.getTargetInfo().getMaxPointerWidth()); + UnqualPtrTy = llvm::PointerType::getUnqual(LLVMContext); Int8PtrTy = llvm::PointerType::get(LLVMContext, C.getTargetAddressSpace(LangAS::Default)); const llvm::DataLayout &DL = M.getDataLayout(); diff --git a/clang/lib/CodeGen/CodeGenTypeCache.h b/clang/lib/CodeGen/CodeGenTypeCache.h index e273ebe3b060f..3b659bc182aa4 100644 --- a/clang/lib/CodeGen/CodeGenTypeCache.h +++ b/clang/lib/CodeGen/CodeGenTypeCache.h @@ -51,9 +51,11 @@ struct CodeGenTypeCache { llvm::IntegerType *PtrDiffTy; }; + /// unqualified void* + llvm::PointerType *UnqualPtrTy; + /// void*, void** in the target's default address space (often 0) union { -llvm::PointerType *UnqualPtrTy; llvm::PointerType *VoidPtrTy; llvm::PointerType *Int8PtrTy; llvm::PointerType *VoidPtrPtrTy; diff --git a/clang/lib/CodeGen/ItaniumCXXABI.cpp b/clang/lib/CodeGen/ItaniumCXXABI.cpp index 8427286dee887..8952e7ca072da 100644 --- a/clang/lib/CodeGen/ItaniumCXXABI.cpp +++ b/clang/lib/CodeGen/ItaniumCXXABI.cpp @@ -4656,14 +4656,14 @@ static void InitCatchParam(CodeGenFunction &CGF, auto catchRD = CatchType->getAsCXXRecordDecl(); CharUnits caughtExnAlignment = CGF.CGM.getClassPointerAlignment(catchRD); - llvm::Type *PtrTy = CGF.UnqualPtrTy; // addrspace 0 ok + llvm::Type *PtrTy = CGF.UnqualPtrTy; // unqualified is ok // Check for a copy expression. If we don't have a copy expression, // that means a trivial copy is okay. const Expr *copyExpr = CatchParam.getInit(); if (!copyExpr) { llvm::Value *rawAdjustedExn = CallBeginCatch(CGF, Exn, true); -Address adjustedExn(CGF.Builder.CreateBitCast(rawAdjustedExn, PtrTy), +Address adjustedExn(CGF.Builder.CreatePointerCast(rawAdjustedExn, PtrTy), LLVMCatchTy, caughtExnAlignment); LValue Dest = CGF.MakeAddrLValue(ParamAddr, CatchType); LValue Src = CGF.MakeAddrLValue(adjustedExn, CatchType); @@ -4677,7 +4677,7 @@ static void InitCatchParam(CodeGenFunction &CGF, CGF.EmitNounwindRuntimeCall(getGetExceptionPtrFn(CGF.CGM), Exn); // Cast that to the appropriate type. - Address adjustedExn(CGF.Builder.CreateBitCast(rawAdjustedExn, PtrTy), + Address adjustedExn(CGF.Builder.CreatePointerCast(rawAdjustedExn, PtrTy), LLVMCatchTy, caughtExnAlignment); // The copy expression is defined in terms of an OpaqueValueExpr. ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][RISCV] Enable RVV with function attribute __attribute__((target("arch=+v"))) (PR #83674)
camel-cdr wrote: Ah, thanks, that works. How can support for behavior be detected? The intrinsic spec says: > The `__riscv_v_intrinsic` macro is the C macro to test the compiler's support > for the RISC-V "V" extension intrinsics. and recommends using: ```c #ifdef __riscv_v_intrinsic #include #endif /* __riscv_v_intrinsic */ ``` But clang only defines `__riscv_v_intrinsic` when RVV is enabled by an march option, shouldn't it now always be enabled when it's possible to include ``? https://github.com/llvm/llvm-project/pull/83674 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Lower _BitInt(129+) to a different type in LLVM IR (PR #91364)
@@ -5348,18 +5348,8 @@ Value *ScalarExprEmitter::VisitVAArgExpr(VAArgExpr *VE) { return llvm::UndefValue::get(ArgTy); } - // FIXME Volatility. - llvm::Value *Val = Builder.CreateLoad(ArgPtr); - - // If EmitVAArg promoted the type, we must truncate it. - if (ArgTy != Val->getType()) { -if (ArgTy->isPointerTy() && !Val->getType()->isPointerTy()) - Val = Builder.CreateIntToPtr(Val, ArgTy); -else - Val = Builder.CreateTrunc(Val, ArgTy); - } - - return Val; + return CGF.EmitLoadOfScalar(ArgPtr, Ty.isVolatileQualified(), Ty, + VE->getExprLoc()); efriedma-quic wrote: > And all the callers of EmitVAAArg therefore should do getScalarVal() or > similar to get a llvm::value Yes, that's the idea. Should significantly simplify the code for some targets. This should be a dependent PR; we merge that first, then this PR doesn't need to touch the varargs code. https://github.com/llvm/llvm-project/pull/91364 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [CLANG][LLVM][AArch64]Add SME2.1 intrinsics for MOVAZ tile to vector,… (PR #88499)
https://github.com/aemerson approved this pull request. https://github.com/llvm/llvm-project/pull/88499 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [CLANG][LLVM][AArch64]SME2.1 intrinsics for MOVAZ tile to 2/4 vectors (PR #88710)
https://github.com/aemerson approved this pull request. LGTM unless others have comments. https://github.com/llvm/llvm-project/pull/88710 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [CLANG][LLVM][AArch64]SME2.1 intrinsics for MOVAZ tile to 2/4 vectors (PR #88710)
@@ -674,3 +674,26 @@ let TargetGuard = "sme2" in { def SVLUTI2_LANE_ZT_X2 : Inst<"svluti2_lane_zt_{d}_x2", "2.di[i", "cUcsUsiUibhf", MergeNone, "aarch64_sme_luti2_lane_zt_x2", [IsStreaming, IsInZT0], [ImmCheck<0, ImmCheck0_0>, ImmCheck<2, ImmCheck0_7>]>; def SVLUTI4_LANE_ZT_X2 : Inst<"svluti4_lane_zt_{d}_x2", "2.di[i", "cUcsUsiUibhf", MergeNone, "aarch64_sme_luti4_lane_zt_x2", [IsStreaming, IsInZT0], [ImmCheck<0, ImmCheck0_0>, ImmCheck<2, ImmCheck0_3>]>; } + +multiclass ZAReadz ch> { + let TargetGuard = "sme2p1" in { +def NAME # _H : SInst<"svreadz_hor_" # n_suffix # "_{d}_vg" # vg_num, vg_num # "im", t, + MergeNone, i_prefix # "_horiz_x" # vg_num, + [IsStreaming, IsInOutZA], ch>; aemerson wrote: Ah indeed. https://github.com/llvm/llvm-project/pull/88710 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [ASTMatchers] forCallable should not erase binding on success (PR #89657)
https://github.com/AaronBallman approved this pull request. LGTM aside from a small nit with the release notes. Do you need someone to land this on your behalf? https://github.com/llvm/llvm-project/pull/89657 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits