[clang] [llvm] [mlir] Use StringRef::find_first_of(char), etc (NFC) (PR #92841)
https://github.com/kazutakahirata closed https://github.com/llvm/llvm-project/pull/92841 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] e411c88 - Use StringRef::find_first_of(char), etc (NFC) (#92841)
Author: Kazu Hirata Date: 2024-05-20T22:55:24-07:00 New Revision: e411c88b7223d87520af819fdc012c9dbb46e575 URL: https://github.com/llvm/llvm-project/commit/e411c88b7223d87520af819fdc012c9dbb46e575 DIFF: https://github.com/llvm/llvm-project/commit/e411c88b7223d87520af819fdc012c9dbb46e575.diff LOG: Use StringRef::find_first_of(char), etc (NFC) (#92841) Added: Modified: clang/utils/TableGen/ClangDiagnosticsEmitter.cpp llvm/lib/Support/LockFileManager.cpp llvm/tools/llvm-rtdyld/llvm-rtdyld.cpp mlir/lib/Tools/mlir-lsp-server/MLIRServer.cpp Removed: diff --git a/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp b/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp index 4512acfd19a1b..f564689fff7cf 100644 --- a/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp +++ b/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp @@ -1086,7 +1086,7 @@ Piece *DiagnosticTextBuilder::DiagText::parseDiagText(StringRef , PluralPiece *Plural = New(); do { Text = Text.drop_front(); // '{' or '|' -size_t End = Text.find_first_of(":"); +size_t End = Text.find_first_of(':'); if (End == StringRef::npos) Builder.PrintFatalError("expected ':' while parsing %plural"); ++End; diff --git a/llvm/lib/Support/LockFileManager.cpp b/llvm/lib/Support/LockFileManager.cpp index 083f8d7b37be3..3169aa25ec0d9 100644 --- a/llvm/lib/Support/LockFileManager.cpp +++ b/llvm/lib/Support/LockFileManager.cpp @@ -66,7 +66,7 @@ LockFileManager::readLockFile(StringRef LockFileName) { StringRef Hostname; StringRef PIDStr; std::tie(Hostname, PIDStr) = getToken(MB.getBuffer(), " "); - PIDStr = PIDStr.substr(PIDStr.find_first_not_of(" ")); + PIDStr = PIDStr.substr(PIDStr.find_first_not_of(' ')); int PID; if (!PIDStr.getAsInteger(10, PID)) { auto Owner = std::make_pair(std::string(Hostname), PID); diff --git a/llvm/tools/llvm-rtdyld/llvm-rtdyld.cpp b/llvm/tools/llvm-rtdyld/llvm-rtdyld.cpp index 4cb76f4347422..06ac98b0c5e13 100644 --- a/llvm/tools/llvm-rtdyld/llvm-rtdyld.cpp +++ b/llvm/tools/llvm-rtdyld/llvm-rtdyld.cpp @@ -649,9 +649,9 @@ void applySpecificSectionMappings(RuntimeDyld , const FileToSectionIDMap ) { for (StringRef Mapping : SpecificSectionMappings) { -size_t EqualsIdx = Mapping.find_first_of("="); +size_t EqualsIdx = Mapping.find_first_of('='); std::string SectionIDStr = std::string(Mapping.substr(0, EqualsIdx)); -size_t ComaIdx = Mapping.find_first_of(","); +size_t ComaIdx = Mapping.find_first_of(','); if (ComaIdx == StringRef::npos) report_fatal_error("Invalid section specification '" + Mapping + diff --git a/mlir/lib/Tools/mlir-lsp-server/MLIRServer.cpp b/mlir/lib/Tools/mlir-lsp-server/MLIRServer.cpp index ed75b4a90536e..4e19274c3da40 100644 --- a/mlir/lib/Tools/mlir-lsp-server/MLIRServer.cpp +++ b/mlir/lib/Tools/mlir-lsp-server/MLIRServer.cpp @@ -917,7 +917,7 @@ void MLIRDocument::getCodeActionForDiagnostic( edit.range = lsp::Range(lsp::Position(pos.line, 0)); // Use the indent of the current line for the expected-* diagnostic. - size_t indent = line.find_first_not_of(" "); + size_t indent = line.find_first_not_of(' '); if (indent == StringRef::npos) indent = line.size(); ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [X86] Support EGPR for inline assembly. (PR #92338)
FreddyLeaf wrote: > ` > [4087704](/llvm/llvm-project/pull/92338/commits/40877041618aa8f472f0da7cda06c21f4007a1ec)` Thanks reminding. Added in 4087704, pls help review. https://github.com/llvm/llvm-project/pull/92338 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [X86] Support EGPR for inline assembly. (PR #92338)
https://github.com/FreddyLeaf updated https://github.com/llvm/llvm-project/pull/92338 >From 41fbc18c7a4a26b11bc4b772bbe2e384ad9d9dbc Mon Sep 17 00:00:00 2001 From: Freddy Ye Date: Fri, 10 May 2024 16:29:55 +0800 Subject: [PATCH 1/6] [X86] Support EGPR for inline assembly. "jR": explictly enables EGPR "r": enables/disables EGPR w/wo -mapx-inline-asm-use-gpr32 -mapx-inline-asm-use-gpr32 will also define a new Macro: __APX_INLINE_ASM_USE_GPR32__ --- clang/include/clang/Driver/Options.td | 2 + clang/lib/Basic/Targets/X86.cpp | 26 + clang/lib/Basic/Targets/X86.h | 1 + clang/lib/Driver/ToolChains/Arch/X86.cpp | 2 + .../Driver/x86-apx-inline-asm-use-gpr32.cpp | 3 + clang/test/Preprocessor/x86_target_features.c | 3 + llvm/lib/Target/X86/X86.td| 3 + llvm/lib/Target/X86/X86ISelLowering.cpp | 57 +-- .../CodeGen/X86/inline-asm-jR-constraint.ll | 19 +++ .../CodeGen/X86/inline-asm-r-constraint.ll| 16 ++ 10 files changed, 127 insertions(+), 5 deletions(-) create mode 100644 clang/test/Driver/x86-apx-inline-asm-use-gpr32.cpp create mode 100644 llvm/test/CodeGen/X86/inline-asm-jR-constraint.ll create mode 100644 llvm/test/CodeGen/X86/inline-asm-r-constraint.ll diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index 73a2518480e9b..20a7c482bbf06 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -6281,6 +6281,8 @@ def mno_apx_features_EQ : CommaJoined<["-"], "mno-apx-features=">, Group, Alias, AliasArgs<["egpr","push2pop2","ppx", "ndd"]>; def mno_apxf : Flag<["-"], "mno-apxf">, Alias, AliasArgs<["egpr","push2pop2","ppx","ndd"]>; +def mapx_inline_asm_use_gpr32 : Flag<["-"], "mapx-inline-asm-use-gpr32">, Group, +HelpText<"Enable use of GPR32 in inline assembly for APX">; } // let Flags = [TargetSpecific] // VE feature flags diff --git a/clang/lib/Basic/Targets/X86.cpp b/clang/lib/Basic/Targets/X86.cpp index 67e2126cf766b..9e61b6e6d6441 100644 --- a/clang/lib/Basic/Targets/X86.cpp +++ b/clang/lib/Basic/Targets/X86.cpp @@ -450,6 +450,8 @@ bool X86TargetInfo::handleTargetFeatures(std::vector , HasFullBFloat16 = true; } else if (Feature == "+egpr") { HasEGPR = true; +} else if (Feature == "+inline-asm-use-gpr32") { + HasInlineAsmUseGPR32 = true; } else if (Feature == "+push2pop2") { HasPush2Pop2 = true; } else if (Feature == "+ppx") { @@ -974,6 +976,8 @@ void X86TargetInfo::getTargetDefines(const LangOptions , // Condition here is aligned with the feature set of mapxf in Options.td if (HasEGPR && HasPush2Pop2 && HasPPX && HasNDD) Builder.defineMacro("__APX_F__"); + if (HasInlineAsmUseGPR32) +Builder.defineMacro("__APX_INLINE_ASM_USE_GPR32__"); // Each case falls through to the previous one here. switch (SSELevel) { @@ -1493,6 +1497,15 @@ bool X86TargetInfo::validateAsmConstraint( case 'C': // SSE floating point constant. case 'G': // x87 floating point constant. return true; + case 'j': +Name++; +switch (*Name) { +default: + return false; +case 'R': + Info.setAllowsRegister(); + return true; +} case '@': // CC condition changes. if (auto Len = matchAsmCCConstraint(Name)) { @@ -1764,6 +1777,19 @@ std::string X86TargetInfo::convertConstraint(const char *) const { // to the next constraint. return std::string("^") + std::string(Constraint++, 2); } + case 'j': +switch (Constraint[1]) { +default: + // Break from inner switch and fall through (copy single char), + // continue parsing after copying the current constraint into + // the return string. + break; +case 'R': + // "^" hints llvm that this is a 2 letter constraint. + // "Constraint++" is used to promote the string iterator + // to the next constraint. + return std::string("^") + std::string(Constraint++, 2); +} [[fallthrough]]; default: return std::string(1, *Constraint); diff --git a/clang/lib/Basic/Targets/X86.h b/clang/lib/Basic/Targets/X86.h index c14e4d5f433d8..69c68ee80f3ba 100644 --- a/clang/lib/Basic/Targets/X86.h +++ b/clang/lib/Basic/Targets/X86.h @@ -174,6 +174,7 @@ class LLVM_LIBRARY_VISIBILITY X86TargetInfo : public TargetInfo { bool HasNDD = false; bool HasCCMP = false; bool HasCF = false; + bool HasInlineAsmUseGPR32 = false; protected: llvm::X86::CPUKind CPU = llvm::X86::CK_None; diff --git a/clang/lib/Driver/ToolChains/Arch/X86.cpp b/clang/lib/Driver/ToolChains/Arch/X86.cpp index 53e26a9f8e229..085ff4824a9b0 100644 --- a/clang/lib/Driver/ToolChains/Arch/X86.cpp +++ b/clang/lib/Driver/ToolChains/Arch/X86.cpp @@ -309,4 +309,6 @@ void x86::getX86TargetFeatures(const Driver , const llvm::Triple , Features.push_back("+prefer-no-gather"); if
[clang] [llvm] [CodeGen] Assign SHT_LLVM_LTO to .llvm.lto section (PR #92856)
MaskRay wrote: @ilovepi I just realized that the FatLTO LLVM patch did not incorporate https://reviews.llvm.org/D153215 . I thought it did... Hope this is not too late. https://github.com/llvm/llvm-project/pull/92856 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [CodeGen] Assign SHT_LLVM_LTO to .llvm.lto section (PR #92856)
llvmbot wrote: @llvm/pr-subscribers-backend-x86 Author: Fangrui Song (MaskRay) Changes This follows up to SHT_LLVM_LTO (https://reviews.llvm.org/D153215) and resolves the comment of the FatLTO patch https://reviews.llvm.org/D146776#4430626 --- Full diff: https://github.com/llvm/llvm-project/pull/92856.diff 3 Files Affected: - (modified) clang/test/CodeGen/fat-lto-objects.c (+1-1) - (modified) llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp (+2) - (modified) llvm/test/CodeGen/X86/fat-lto-section.ll (+1-1) ``diff diff --git a/clang/test/CodeGen/fat-lto-objects.c b/clang/test/CodeGen/fat-lto-objects.c index b50567c024fc8..36a73684e7bfe 100644 --- a/clang/test/CodeGen/fat-lto-objects.c +++ b/clang/test/CodeGen/fat-lto-objects.c @@ -62,7 +62,7 @@ // ELF: .llvm.lto -// ASM: .section.llvm.lto,"e",@progbits +// ASM: .section.llvm.lto,"e",@llvm_lto // ASM-NEXT: .Lllvm.embedded.object: // ASM-NEXT:.asciz "BC // ASM-NEXT: .size .Lllvm.embedded.object diff --git a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp index 3e1897ce670a6..0fc915d89f6c0 100644 --- a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp +++ b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp @@ -523,6 +523,8 @@ static unsigned getELFSectionType(StringRef Name, SectionKind K) { if (hasPrefix(Name, ".llvm.offloading")) return ELF::SHT_LLVM_OFFLOADING; + if (Name == ".llvm.lto") +return ELF::SHT_LLVM_LTO; if (K.isBSS() || K.isThreadBSS()) return ELF::SHT_NOBITS; diff --git a/llvm/test/CodeGen/X86/fat-lto-section.ll b/llvm/test/CodeGen/X86/fat-lto-section.ll index 30c56229a0e2a..f3ca8436affb4 100644 --- a/llvm/test/CodeGen/X86/fat-lto-section.ll +++ b/llvm/test/CodeGen/X86/fat-lto-section.ll @@ -5,6 +5,6 @@ ; RUN: | FileCheck %s --check-prefix=EXCLUDE ; EXCLUDE: Name Type {{.*}} ES Flg Lk Inf Al -; EXCLUDE: .llvm.lto PROGBITS {{.*}} 00 E 0 0 1 +; EXCLUDE: .llvm.lto LLVM_LTO {{.*}} 00 E 0 0 1 @a = global i32 1 `` https://github.com/llvm/llvm-project/pull/92856 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [CodeGen] Assign SHT_LLVM_LTO to .llvm.lto section (PR #92856)
https://github.com/MaskRay created https://github.com/llvm/llvm-project/pull/92856 This follows up to SHT_LLVM_LTO (https://reviews.llvm.org/D153215) and resolves the comment of the FatLTO patch https://reviews.llvm.org/D146776#4430626 >From fdf70f50de2d51223f3f04b2db4913360ded3469 Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Mon, 20 May 2024 22:08:41 -0700 Subject: [PATCH] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20initia?= =?UTF-8?q?l=20version?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Created using spr 1.3.5-bogner --- clang/test/CodeGen/fat-lto-objects.c | 2 +- llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp | 2 ++ llvm/test/CodeGen/X86/fat-lto-section.ll | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/clang/test/CodeGen/fat-lto-objects.c b/clang/test/CodeGen/fat-lto-objects.c index b50567c024fc8..36a73684e7bfe 100644 --- a/clang/test/CodeGen/fat-lto-objects.c +++ b/clang/test/CodeGen/fat-lto-objects.c @@ -62,7 +62,7 @@ // ELF: .llvm.lto -// ASM: .section.llvm.lto,"e",@progbits +// ASM: .section.llvm.lto,"e",@llvm_lto // ASM-NEXT: .Lllvm.embedded.object: // ASM-NEXT:.asciz "BC // ASM-NEXT: .size .Lllvm.embedded.object diff --git a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp index 3e1897ce670a6..0fc915d89f6c0 100644 --- a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp +++ b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp @@ -523,6 +523,8 @@ static unsigned getELFSectionType(StringRef Name, SectionKind K) { if (hasPrefix(Name, ".llvm.offloading")) return ELF::SHT_LLVM_OFFLOADING; + if (Name == ".llvm.lto") +return ELF::SHT_LLVM_LTO; if (K.isBSS() || K.isThreadBSS()) return ELF::SHT_NOBITS; diff --git a/llvm/test/CodeGen/X86/fat-lto-section.ll b/llvm/test/CodeGen/X86/fat-lto-section.ll index 30c56229a0e2a..f3ca8436affb4 100644 --- a/llvm/test/CodeGen/X86/fat-lto-section.ll +++ b/llvm/test/CodeGen/X86/fat-lto-section.ll @@ -5,6 +5,6 @@ ; RUN: | FileCheck %s --check-prefix=EXCLUDE ; EXCLUDE: Name Type {{.*}} ES Flg Lk Inf Al -; EXCLUDE: .llvm.lto PROGBITS {{.*}} 00 E 0 0 1 +; EXCLUDE: .llvm.lto LLVM_LTO {{.*}} 00 E 0 0 1 @a = global i32 1 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] add unnamed_addr function attribute (PR #92499)
yamt wrote: > If we're going to do this, it should probably also work for constants. for completeness, maybe. i myself have no use cases though. > Also, I think I'd prefer to sort out the situation with the C++ standard's > rules for constant merging before we start extending those rules. See #63628. interesting. i was not aware of it. https://github.com/llvm/llvm-project/pull/92499 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-tools-extra] [clang] NFCI: use TemplateArgumentLoc for NTTP DefaultArgument (PR #92852)
mizvekov wrote: > Can you try to explain the what the patch does more and describe the > rationale? Done. https://github.com/llvm/llvm-project/pull/92852 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-tools-extra] [clang] NFCI: use TemplateArgumentLoc for NTTP DefaultArgument (PR #92852)
@@ -1435,7 +1436,10 @@ class NonTypeTemplateParmDecl final bool hasDefaultArgument() const { return DefaultArgument.isSet(); } /// Retrieve the default argument, if any. - Expr *getDefaultArgument() const { return DefaultArgument.get(); } + const TemplateArgumentLoc () const { mizvekov wrote: All template parameters currently use that name, so this is kept for consistency. I wouldn't object a later separate patch to rename all of them at once. https://github.com/llvm/llvm-project/pull/92852 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-tools-extra] [clang] NFCI: use TemplateArgumentLoc for NTTP DefaultArgument (PR #92852)
https://github.com/mizvekov edited https://github.com/llvm/llvm-project/pull/92852 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-tools-extra] [clang] NFCI: use TemplateArgumentLoc for NTTP DefaultArgument (PR #92852)
@@ -1435,7 +1436,10 @@ class NonTypeTemplateParmDecl final bool hasDefaultArgument() const { return DefaultArgument.isSet(); } /// Retrieve the default argument, if any. - Expr *getDefaultArgument() const { return DefaultArgument.get(); } + const TemplateArgumentLoc () const { ChuanqiXu9 wrote: Is it better to rename `getDefaultArgument` to `getDefaultArgumentLoc`? https://github.com/llvm/llvm-project/pull/92852 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-tools-extra] [clang] NFCI: use TemplateArgumentLoc for NTTP DefaultArgument (PR #92852)
https://github.com/ChuanqiXu9 edited https://github.com/llvm/llvm-project/pull/92852 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-tools-extra] [clang] NFCI: use TemplateArgumentLoc for NTTP DefaultArgument (PR #92852)
https://github.com/ChuanqiXu9 commented: Can you try to explain the what the patch does more and describe the rationale? https://github.com/llvm/llvm-project/pull/92852 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [InstallAPI] add JSON option to pass X arguments (PR #91770)
https://github.com/cyndyishida closed https://github.com/llvm/llvm-project/pull/91770 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] c9dc52d - [InstallAPI] add JSON option to pass X arguments (#91770)
Author: Cyndy Ishida Date: 2024-05-20T21:22:24-07:00 New Revision: c9dc52d424b7a264d4bcb29d7f56551304396d7f URL: https://github.com/llvm/llvm-project/commit/c9dc52d424b7a264d4bcb29d7f56551304396d7f DIFF: https://github.com/llvm/llvm-project/commit/c9dc52d424b7a264d4bcb29d7f56551304396d7f.diff LOG: [InstallAPI] add JSON option to pass X arguments (#91770) Added: clang/test/InstallAPI/exclusive-passes-3.test Modified: clang/include/clang/Basic/DiagnosticInstallAPIKinds.td clang/test/InstallAPI/alias_list.test clang/test/InstallAPI/exclusive-passes-2.test clang/test/InstallAPI/exclusive-passes.test clang/test/InstallAPI/invalid-exclusive-passes.test clang/tools/clang-installapi/InstallAPIOpts.td clang/tools/clang-installapi/Options.cpp clang/tools/clang-installapi/Options.h Removed: diff --git a/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td b/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td index 674742431dcb2..944b2a38b6e96 100644 --- a/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td +++ b/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td @@ -24,7 +24,7 @@ def err_no_matching_target : Error<"no matching target found for target variant def err_unsupported_vendor : Error<"vendor '%0' is not supported: '%1'">; def err_unsupported_environment : Error<"environment '%0' is not supported: '%1'">; def err_unsupported_os : Error<"os '%0' is not supported: '%1'">; -def err_cannot_read_input_list : Error<"could not read %select{alias list|filelist}0 '%1': %2">; +def err_cannot_read_input_list : Error<"could not read %0 input list '%1': %2">; def err_invalid_label: Error<"label '%0' is reserved: use a diff erent label name for -X">; } // end of command line category. diff --git a/clang/test/InstallAPI/alias_list.test b/clang/test/InstallAPI/alias_list.test index 3e12221e088c4..aba7e395cca95 100644 --- a/clang/test/InstallAPI/alias_list.test +++ b/clang/test/InstallAPI/alias_list.test @@ -23,7 +23,7 @@ ; RUN: -o %t/AliasList.tbd 2>&1 | FileCheck -allow-empty %s \ ; RUN: --check-prefix=INVALID -; INVALID: error: could not read alias list {{.*}} missing alias for: _hidden +; INVALID: error: could not read symbol alias input list {{.*}}invalid.txt': invalid input format: missing alias for: _hidden ;--- Frameworks/AliasList.framework/Headers/AliasList.h // simple alias from one symbol to another. diff --git a/clang/test/InstallAPI/exclusive-passes-2.test b/clang/test/InstallAPI/exclusive-passes-2.test index 3e7a6d777d5af..132b27df383c4 100644 --- a/clang/test/InstallAPI/exclusive-passes-2.test +++ b/clang/test/InstallAPI/exclusive-passes-2.test @@ -11,6 +11,15 @@ ; RUN: -DFoo -XApple -DDarwin=1 -XElf -DNONDarwin=1 2>&1 | FileCheck -allow-empty %s ; RUN: llvm-readtapi --compare %t/output.tbd %t/expected.tbd 2>&1 | FileCheck -allow-empty %s +; RUN: clang-installapi -target arm64-apple-macos12 \ +; RUN: -install_name @rpath/libfoo.dylib \ +; RUN: -current_version 1 -compatibility_version 1 \ +; RUN: -I%S/Inputs/LibFoo/usr/include -dynamiclib \ +; RUN: -extra-public-header %S/Inputs/LibFoo/usr/include/foo.h \ +; RUN: -o %t/output2.tbd \ +; RUN: -DFoo -optionlist %t/options.json 2>&1 | FileCheck -allow-empty %s +; RUN: llvm-readtapi --compare %t/output.tbd %t/expected.tbd 2>&1 | FileCheck -allow-empty %s + ; CHECK-NOT: error ; CHECK-NOT: warning diff --git a/clang/test/InstallAPI/exclusive-passes-3.test b/clang/test/InstallAPI/exclusive-passes-3.test new file mode 100644 index 0..3a9b64c9f7b86 --- /dev/null +++ b/clang/test/InstallAPI/exclusive-passes-3.test @@ -0,0 +1,86 @@ +; RUN: rm -rf %t +; RUN: split-file %s %t + +// "Apple" label has split options between the optionlist & command line. +; RUN: clang-installapi -target arm64-apple-macos12 \ +; RUN: -install_name @rpath/libfoo.dylib -current_version 1 \ +; RUN: -compatibility_version 1 \ +; RUN: -extra-public-header %t/usr/include/opts.h \ +; RUN: -optionlist %t/options.json -XApple -DCLI_OPT=1 \ +; RUN: -I%S/Inputs/LibFoo/usr/include \ +; RUN: -I%t/usr/include -dynamiclib -o %t/output.tbd 2>&1 | FileCheck %s -allow-empty +; RUN: llvm-readtapi --compare %t/output.tbd %t/expected.tbd 2>&1 | FileCheck -allow-empty %s + +// Validate duplicated options give same result. +; RUN: clang-installapi -target arm64-apple-macos12 \ +; RUN: -install_name @rpath/libfoo.dylib -current_version 1 \ +; RUN: -compatibility_version 1 \ +; RUN: -extra-public-header %t/usr/include/opts.h \ +; RUN: -optionlist %t/options.json -XApple -DCLI_OPT=1 \ +; RUN: -I%S/Inputs/LibFoo/usr/include \ +; RUN: -XApple -DDarwin -XElf -DNONDarwin \ +; RUN: -I%t/usr/include -dynamiclib -o %t/output2.tbd 2>&1 | FileCheck %s -allow-empty +; RUN: llvm-readtapi --compare %t/output2.tbd %t/expected.tbd 2>&1 | FileCheck -allow-empty %s + +; CHECK-NOT: error +; CHECK-NOT: warning + +;---
[clang] [clang-tools-extra] [clang] NFCI: use TemplateArgumentLoc for NTTP DefaultArgument (PR #92852)
llvmbot wrote: @llvm/pr-subscribers-clang-modules Author: Matheus Izvekov (mizvekov) Changes This is an enabler for a future patch. --- Patch is 26.46 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/92852.diff 25 Files Affected: - (modified) clang-tools-extra/clangd/Hover.cpp (+2-1) - (modified) clang/include/clang/AST/ASTNodeTraverser.h (+3-3) - (modified) clang/include/clang/AST/DeclTemplate.h (+8-3) - (modified) clang/include/clang/AST/RecursiveASTVisitor.h (+1-1) - (modified) clang/lib/AST/ASTContext.cpp (+4-2) - (modified) clang/lib/AST/ASTDiagnostic.cpp (+1-1) - (modified) clang/lib/AST/ASTImporter.cpp (+3-2) - (modified) clang/lib/AST/DeclPrinter.cpp (+2-2) - (modified) clang/lib/AST/DeclTemplate.cpp (+11-4) - (modified) clang/lib/AST/JSONNodeDumper.cpp (+1-1) - (modified) clang/lib/AST/ODRDiagsEmitter.cpp (+5-2) - (modified) clang/lib/AST/ODRHash.cpp (+1-1) - (modified) clang/lib/AST/TypePrinter.cpp (+3-2) - (modified) clang/lib/ExtractAPI/DeclarationFragments.cpp (+3-2) - (modified) clang/lib/Index/IndexDecl.cpp (+2-1) - (modified) clang/lib/Sema/HLSLExternalSemaSource.cpp (+6-4) - (modified) clang/lib/Sema/SemaTemplate.cpp (+22-24) - (modified) clang/lib/Sema/SemaTemplateDeduction.cpp (+5-5) - (modified) clang/lib/Sema/SemaTemplateInstantiateDecl.cpp (+4-3) - (modified) clang/lib/Serialization/ASTReaderDecl.cpp (+2-1) - (modified) clang/lib/Serialization/ASTWriterDecl.cpp (+1-1) - (modified) clang/test/AST/ast-dump-decl.cpp (+2-2) - (modified) clang/test/SemaTemplate/deduction-guide.cpp (+3-3) - (modified) clang/tools/libclang/CIndex.cpp (+3-2) - (modified) clang/unittests/AST/ASTImporterTest.cpp (+1-1) ``diff diff --git a/clang-tools-extra/clangd/Hover.cpp b/clang-tools-extra/clangd/Hover.cpp index 06b949bc4a2b5..51124ab371b2a 100644 --- a/clang-tools-extra/clangd/Hover.cpp +++ b/clang-tools-extra/clangd/Hover.cpp @@ -258,7 +258,8 @@ fetchTemplateParameters(const TemplateParameterList *Params, if (NTTP->hasDefaultArgument()) { P.Default.emplace(); llvm::raw_string_ostream Out(*P.Default); -NTTP->getDefaultArgument()->printPretty(Out, nullptr, PP); +NTTP->getDefaultArgument().getArgument().print(PP, Out, + /*IncludeType=*/false); } } else if (const auto *TTPD = dyn_cast(Param)) { P.Type = printType(TTPD, PP); diff --git a/clang/include/clang/AST/ASTNodeTraverser.h b/clang/include/clang/AST/ASTNodeTraverser.h index bf7c204e4ad73..a3918e30eadf5 100644 --- a/clang/include/clang/AST/ASTNodeTraverser.h +++ b/clang/include/clang/AST/ASTNodeTraverser.h @@ -704,9 +704,9 @@ class ASTNodeTraverser if (const auto *E = D->getPlaceholderTypeConstraint()) Visit(E); if (D->hasDefaultArgument()) - Visit(D->getDefaultArgument(), SourceRange(), -D->getDefaultArgStorage().getInheritedFrom(), -D->defaultArgumentWasInherited() ? "inherited from" : "previous"); + dumpTemplateArgumentLoc( + D->getDefaultArgument(), D->getDefaultArgStorage().getInheritedFrom(), + D->defaultArgumentWasInherited() ? "inherited from" : "previous"); } void VisitTemplateTemplateParmDecl(const TemplateTemplateParmDecl *D) { diff --git a/clang/include/clang/AST/DeclTemplate.h b/clang/include/clang/AST/DeclTemplate.h index f3d6a321ecf10..8a471bea0eaba 100644 --- a/clang/include/clang/AST/DeclTemplate.h +++ b/clang/include/clang/AST/DeclTemplate.h @@ -1365,7 +1365,8 @@ class NonTypeTemplateParmDecl final /// The default template argument, if any, and whether or not /// it was inherited. - using DefArgStorage = DefaultArgStorage; + using DefArgStorage = + DefaultArgStorage; DefArgStorage DefaultArgument; // FIXME: Collapse this into TemplateParamPosition; or, just move depth/index @@ -1435,7 +1436,10 @@ class NonTypeTemplateParmDecl final bool hasDefaultArgument() const { return DefaultArgument.isSet(); } /// Retrieve the default argument, if any. - Expr *getDefaultArgument() const { return DefaultArgument.get(); } + const TemplateArgumentLoc () const { +static const TemplateArgumentLoc NoneLoc; +return DefaultArgument.isSet() ? *DefaultArgument.get() : NoneLoc; + } /// Retrieve the location of the default argument, if any. SourceLocation getDefaultArgumentLoc() const; @@ -1449,7 +1453,8 @@ class NonTypeTemplateParmDecl final /// Set the default argument for this template parameter, and /// whether that default argument was inherited from another /// declaration. - void setDefaultArgument(Expr *DefArg) { DefaultArgument.set(DefArg); } + void setDefaultArgument(const ASTContext , + const TemplateArgumentLoc ); void setInheritedDefaultArgument(const ASTContext , NonTypeTemplateParmDecl *Parm) { DefaultArgument.setInherited(C, Parm); diff
[clang] [clang-tools-extra] [clang] NFCI: use TemplateArgumentLoc for NTTP DefaultArgument (PR #92852)
llvmbot wrote: @llvm/pr-subscribers-clangd @llvm/pr-subscribers-hlsl Author: Matheus Izvekov (mizvekov) Changes This is an enabler for a future patch. --- Patch is 26.46 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/92852.diff 25 Files Affected: - (modified) clang-tools-extra/clangd/Hover.cpp (+2-1) - (modified) clang/include/clang/AST/ASTNodeTraverser.h (+3-3) - (modified) clang/include/clang/AST/DeclTemplate.h (+8-3) - (modified) clang/include/clang/AST/RecursiveASTVisitor.h (+1-1) - (modified) clang/lib/AST/ASTContext.cpp (+4-2) - (modified) clang/lib/AST/ASTDiagnostic.cpp (+1-1) - (modified) clang/lib/AST/ASTImporter.cpp (+3-2) - (modified) clang/lib/AST/DeclPrinter.cpp (+2-2) - (modified) clang/lib/AST/DeclTemplate.cpp (+11-4) - (modified) clang/lib/AST/JSONNodeDumper.cpp (+1-1) - (modified) clang/lib/AST/ODRDiagsEmitter.cpp (+5-2) - (modified) clang/lib/AST/ODRHash.cpp (+1-1) - (modified) clang/lib/AST/TypePrinter.cpp (+3-2) - (modified) clang/lib/ExtractAPI/DeclarationFragments.cpp (+3-2) - (modified) clang/lib/Index/IndexDecl.cpp (+2-1) - (modified) clang/lib/Sema/HLSLExternalSemaSource.cpp (+6-4) - (modified) clang/lib/Sema/SemaTemplate.cpp (+22-24) - (modified) clang/lib/Sema/SemaTemplateDeduction.cpp (+5-5) - (modified) clang/lib/Sema/SemaTemplateInstantiateDecl.cpp (+4-3) - (modified) clang/lib/Serialization/ASTReaderDecl.cpp (+2-1) - (modified) clang/lib/Serialization/ASTWriterDecl.cpp (+1-1) - (modified) clang/test/AST/ast-dump-decl.cpp (+2-2) - (modified) clang/test/SemaTemplate/deduction-guide.cpp (+3-3) - (modified) clang/tools/libclang/CIndex.cpp (+3-2) - (modified) clang/unittests/AST/ASTImporterTest.cpp (+1-1) ``diff diff --git a/clang-tools-extra/clangd/Hover.cpp b/clang-tools-extra/clangd/Hover.cpp index 06b949bc4a2b5..51124ab371b2a 100644 --- a/clang-tools-extra/clangd/Hover.cpp +++ b/clang-tools-extra/clangd/Hover.cpp @@ -258,7 +258,8 @@ fetchTemplateParameters(const TemplateParameterList *Params, if (NTTP->hasDefaultArgument()) { P.Default.emplace(); llvm::raw_string_ostream Out(*P.Default); -NTTP->getDefaultArgument()->printPretty(Out, nullptr, PP); +NTTP->getDefaultArgument().getArgument().print(PP, Out, + /*IncludeType=*/false); } } else if (const auto *TTPD = dyn_cast(Param)) { P.Type = printType(TTPD, PP); diff --git a/clang/include/clang/AST/ASTNodeTraverser.h b/clang/include/clang/AST/ASTNodeTraverser.h index bf7c204e4ad73..a3918e30eadf5 100644 --- a/clang/include/clang/AST/ASTNodeTraverser.h +++ b/clang/include/clang/AST/ASTNodeTraverser.h @@ -704,9 +704,9 @@ class ASTNodeTraverser if (const auto *E = D->getPlaceholderTypeConstraint()) Visit(E); if (D->hasDefaultArgument()) - Visit(D->getDefaultArgument(), SourceRange(), -D->getDefaultArgStorage().getInheritedFrom(), -D->defaultArgumentWasInherited() ? "inherited from" : "previous"); + dumpTemplateArgumentLoc( + D->getDefaultArgument(), D->getDefaultArgStorage().getInheritedFrom(), + D->defaultArgumentWasInherited() ? "inherited from" : "previous"); } void VisitTemplateTemplateParmDecl(const TemplateTemplateParmDecl *D) { diff --git a/clang/include/clang/AST/DeclTemplate.h b/clang/include/clang/AST/DeclTemplate.h index f3d6a321ecf10..8a471bea0eaba 100644 --- a/clang/include/clang/AST/DeclTemplate.h +++ b/clang/include/clang/AST/DeclTemplate.h @@ -1365,7 +1365,8 @@ class NonTypeTemplateParmDecl final /// The default template argument, if any, and whether or not /// it was inherited. - using DefArgStorage = DefaultArgStorage; + using DefArgStorage = + DefaultArgStorage; DefArgStorage DefaultArgument; // FIXME: Collapse this into TemplateParamPosition; or, just move depth/index @@ -1435,7 +1436,10 @@ class NonTypeTemplateParmDecl final bool hasDefaultArgument() const { return DefaultArgument.isSet(); } /// Retrieve the default argument, if any. - Expr *getDefaultArgument() const { return DefaultArgument.get(); } + const TemplateArgumentLoc () const { +static const TemplateArgumentLoc NoneLoc; +return DefaultArgument.isSet() ? *DefaultArgument.get() : NoneLoc; + } /// Retrieve the location of the default argument, if any. SourceLocation getDefaultArgumentLoc() const; @@ -1449,7 +1453,8 @@ class NonTypeTemplateParmDecl final /// Set the default argument for this template parameter, and /// whether that default argument was inherited from another /// declaration. - void setDefaultArgument(Expr *DefArg) { DefaultArgument.set(DefArg); } + void setDefaultArgument(const ASTContext , + const TemplateArgumentLoc ); void setInheritedDefaultArgument(const ASTContext , NonTypeTemplateParmDecl *Parm) {
[clang] [clang-tools-extra] [clang] NFCI: use TemplateArgumentLoc for NTTP DefaultArgument (PR #92852)
https://github.com/mizvekov created https://github.com/llvm/llvm-project/pull/92852 This is an enabler for a future patch. >From 22964061e46ef0d37904f6c8e757dca9800c5cd0 Mon Sep 17 00:00:00 2001 From: Matheus Izvekov Date: Mon, 20 May 2024 00:39:55 -0300 Subject: [PATCH] [clang] NFCI: use TemplateArgumentLoc for NTTP DefaultArgument This is an enabler for a future patch. --- clang-tools-extra/clangd/Hover.cpp| 3 +- clang/include/clang/AST/ASTNodeTraverser.h| 6 +-- clang/include/clang/AST/DeclTemplate.h| 11 +++-- clang/include/clang/AST/RecursiveASTVisitor.h | 2 +- clang/lib/AST/ASTContext.cpp | 6 ++- clang/lib/AST/ASTDiagnostic.cpp | 2 +- clang/lib/AST/ASTImporter.cpp | 5 +- clang/lib/AST/DeclPrinter.cpp | 4 +- clang/lib/AST/DeclTemplate.cpp| 15 -- clang/lib/AST/JSONNodeDumper.cpp | 2 +- clang/lib/AST/ODRDiagsEmitter.cpp | 7 ++- clang/lib/AST/ODRHash.cpp | 2 +- clang/lib/AST/TypePrinter.cpp | 5 +- clang/lib/ExtractAPI/DeclarationFragments.cpp | 5 +- clang/lib/Index/IndexDecl.cpp | 3 +- clang/lib/Sema/HLSLExternalSemaSource.cpp | 10 ++-- clang/lib/Sema/SemaTemplate.cpp | 46 +-- clang/lib/Sema/SemaTemplateDeduction.cpp | 10 ++-- .../lib/Sema/SemaTemplateInstantiateDecl.cpp | 7 +-- clang/lib/Serialization/ASTReaderDecl.cpp | 3 +- clang/lib/Serialization/ASTWriterDecl.cpp | 2 +- clang/test/AST/ast-dump-decl.cpp | 4 +- clang/test/SemaTemplate/deduction-guide.cpp | 6 +-- clang/tools/libclang/CIndex.cpp | 5 +- clang/unittests/AST/ASTImporterTest.cpp | 2 +- 25 files changed, 99 insertions(+), 74 deletions(-) diff --git a/clang-tools-extra/clangd/Hover.cpp b/clang-tools-extra/clangd/Hover.cpp index 06b949bc4a2b5..51124ab371b2a 100644 --- a/clang-tools-extra/clangd/Hover.cpp +++ b/clang-tools-extra/clangd/Hover.cpp @@ -258,7 +258,8 @@ fetchTemplateParameters(const TemplateParameterList *Params, if (NTTP->hasDefaultArgument()) { P.Default.emplace(); llvm::raw_string_ostream Out(*P.Default); -NTTP->getDefaultArgument()->printPretty(Out, nullptr, PP); +NTTP->getDefaultArgument().getArgument().print(PP, Out, + /*IncludeType=*/false); } } else if (const auto *TTPD = dyn_cast(Param)) { P.Type = printType(TTPD, PP); diff --git a/clang/include/clang/AST/ASTNodeTraverser.h b/clang/include/clang/AST/ASTNodeTraverser.h index bf7c204e4ad73..a3918e30eadf5 100644 --- a/clang/include/clang/AST/ASTNodeTraverser.h +++ b/clang/include/clang/AST/ASTNodeTraverser.h @@ -704,9 +704,9 @@ class ASTNodeTraverser if (const auto *E = D->getPlaceholderTypeConstraint()) Visit(E); if (D->hasDefaultArgument()) - Visit(D->getDefaultArgument(), SourceRange(), -D->getDefaultArgStorage().getInheritedFrom(), -D->defaultArgumentWasInherited() ? "inherited from" : "previous"); + dumpTemplateArgumentLoc( + D->getDefaultArgument(), D->getDefaultArgStorage().getInheritedFrom(), + D->defaultArgumentWasInherited() ? "inherited from" : "previous"); } void VisitTemplateTemplateParmDecl(const TemplateTemplateParmDecl *D) { diff --git a/clang/include/clang/AST/DeclTemplate.h b/clang/include/clang/AST/DeclTemplate.h index f3d6a321ecf10..8a471bea0eaba 100644 --- a/clang/include/clang/AST/DeclTemplate.h +++ b/clang/include/clang/AST/DeclTemplate.h @@ -1365,7 +1365,8 @@ class NonTypeTemplateParmDecl final /// The default template argument, if any, and whether or not /// it was inherited. - using DefArgStorage = DefaultArgStorage; + using DefArgStorage = + DefaultArgStorage; DefArgStorage DefaultArgument; // FIXME: Collapse this into TemplateParamPosition; or, just move depth/index @@ -1435,7 +1436,10 @@ class NonTypeTemplateParmDecl final bool hasDefaultArgument() const { return DefaultArgument.isSet(); } /// Retrieve the default argument, if any. - Expr *getDefaultArgument() const { return DefaultArgument.get(); } + const TemplateArgumentLoc () const { +static const TemplateArgumentLoc NoneLoc; +return DefaultArgument.isSet() ? *DefaultArgument.get() : NoneLoc; + } /// Retrieve the location of the default argument, if any. SourceLocation getDefaultArgumentLoc() const; @@ -1449,7 +1453,8 @@ class NonTypeTemplateParmDecl final /// Set the default argument for this template parameter, and /// whether that default argument was inherited from another /// declaration. - void setDefaultArgument(Expr *DefArg) { DefaultArgument.set(DefArg); } + void setDefaultArgument(const ASTContext , + const TemplateArgumentLoc ); void setInheritedDefaultArgument(const ASTContext ,
[clang] [InstallAPI] add JSON option to pass X arguments (PR #91770)
https://github.com/cyndyishida updated https://github.com/llvm/llvm-project/pull/91770 >From 291412a203ea60465d4ecae9317f3490c59bfb50 Mon Sep 17 00:00:00 2001 From: Cyndy Ishida Date: Thu, 2 May 2024 19:53:07 -0700 Subject: [PATCH 1/3] [InstallAPI] add JSON option to pass X arguments --- .../clang/Basic/DiagnosticInstallAPIKinds.td | 2 +- clang/test/InstallAPI/alias_list.test | 2 +- clang/test/InstallAPI/exclusive-passes-2.test | 9 ++ clang/test/InstallAPI/exclusive-passes-3.test | 86 +++ clang/test/InstallAPI/exclusive-passes.test | 15 .../InstallAPI/invalid-exclusive-passes.test | 33 +++ .../tools/clang-installapi/InstallAPIOpts.td | 3 + clang/tools/clang-installapi/Options.cpp | 74 +++- clang/tools/clang-installapi/Options.h| 2 + 9 files changed, 222 insertions(+), 4 deletions(-) create mode 100644 clang/test/InstallAPI/exclusive-passes-3.test diff --git a/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td b/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td index 674742431dcb2..944b2a38b6e96 100644 --- a/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td +++ b/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td @@ -24,7 +24,7 @@ def err_no_matching_target : Error<"no matching target found for target variant def err_unsupported_vendor : Error<"vendor '%0' is not supported: '%1'">; def err_unsupported_environment : Error<"environment '%0' is not supported: '%1'">; def err_unsupported_os : Error<"os '%0' is not supported: '%1'">; -def err_cannot_read_input_list : Error<"could not read %select{alias list|filelist}0 '%1': %2">; +def err_cannot_read_input_list : Error<"could not read %0 input list '%1': %2">; def err_invalid_label: Error<"label '%0' is reserved: use a different label name for -X">; } // end of command line category. diff --git a/clang/test/InstallAPI/alias_list.test b/clang/test/InstallAPI/alias_list.test index 3e12221e088c4..aba7e395cca95 100644 --- a/clang/test/InstallAPI/alias_list.test +++ b/clang/test/InstallAPI/alias_list.test @@ -23,7 +23,7 @@ ; RUN: -o %t/AliasList.tbd 2>&1 | FileCheck -allow-empty %s \ ; RUN: --check-prefix=INVALID -; INVALID: error: could not read alias list {{.*}} missing alias for: _hidden +; INVALID: error: could not read symbol alias input list {{.*}}invalid.txt': invalid input format: missing alias for: _hidden ;--- Frameworks/AliasList.framework/Headers/AliasList.h // simple alias from one symbol to another. diff --git a/clang/test/InstallAPI/exclusive-passes-2.test b/clang/test/InstallAPI/exclusive-passes-2.test index 3e7a6d777d5af..132b27df383c4 100644 --- a/clang/test/InstallAPI/exclusive-passes-2.test +++ b/clang/test/InstallAPI/exclusive-passes-2.test @@ -11,6 +11,15 @@ ; RUN: -DFoo -XApple -DDarwin=1 -XElf -DNONDarwin=1 2>&1 | FileCheck -allow-empty %s ; RUN: llvm-readtapi --compare %t/output.tbd %t/expected.tbd 2>&1 | FileCheck -allow-empty %s +; RUN: clang-installapi -target arm64-apple-macos12 \ +; RUN: -install_name @rpath/libfoo.dylib \ +; RUN: -current_version 1 -compatibility_version 1 \ +; RUN: -I%S/Inputs/LibFoo/usr/include -dynamiclib \ +; RUN: -extra-public-header %S/Inputs/LibFoo/usr/include/foo.h \ +; RUN: -o %t/output2.tbd \ +; RUN: -DFoo -optionlist %t/options.json 2>&1 | FileCheck -allow-empty %s +; RUN: llvm-readtapi --compare %t/output.tbd %t/expected.tbd 2>&1 | FileCheck -allow-empty %s + ; CHECK-NOT: error ; CHECK-NOT: warning diff --git a/clang/test/InstallAPI/exclusive-passes-3.test b/clang/test/InstallAPI/exclusive-passes-3.test new file mode 100644 index 0..3a9b64c9f7b86 --- /dev/null +++ b/clang/test/InstallAPI/exclusive-passes-3.test @@ -0,0 +1,86 @@ +; RUN: rm -rf %t +; RUN: split-file %s %t + +// "Apple" label has split options between the optionlist & command line. +; RUN: clang-installapi -target arm64-apple-macos12 \ +; RUN: -install_name @rpath/libfoo.dylib -current_version 1 \ +; RUN: -compatibility_version 1 \ +; RUN: -extra-public-header %t/usr/include/opts.h \ +; RUN: -optionlist %t/options.json -XApple -DCLI_OPT=1 \ +; RUN: -I%S/Inputs/LibFoo/usr/include \ +; RUN: -I%t/usr/include -dynamiclib -o %t/output.tbd 2>&1 | FileCheck %s -allow-empty +; RUN: llvm-readtapi --compare %t/output.tbd %t/expected.tbd 2>&1 | FileCheck -allow-empty %s + +// Validate duplicated options give same result. +; RUN: clang-installapi -target arm64-apple-macos12 \ +; RUN: -install_name @rpath/libfoo.dylib -current_version 1 \ +; RUN: -compatibility_version 1 \ +; RUN: -extra-public-header %t/usr/include/opts.h \ +; RUN: -optionlist %t/options.json -XApple -DCLI_OPT=1 \ +; RUN: -I%S/Inputs/LibFoo/usr/include \ +; RUN: -XApple -DDarwin -XElf -DNONDarwin \ +; RUN: -I%t/usr/include -dynamiclib -o %t/output2.tbd 2>&1 | FileCheck %s -allow-empty +; RUN: llvm-readtapi --compare %t/output2.tbd %t/expected.tbd 2>&1 | FileCheck -allow-empty %s + +; CHECK-NOT: error +; CHECK-NOT: warning + +;---
[clang] [llvm] [mlir] Use StringRef::find_first_of(char), etc (NFC) (PR #92841)
https://github.com/MaskRay approved this pull request. https://github.com/llvm/llvm-project/pull/92841 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] add unnamed_addr function attribute (PR #92499)
yamt wrote: > Hmm... I'm not sure this meets our requirements for inclusion as an > attribute. The semantics of this are pretty opaque, no obvious significant > motivation/applicability in the base languages, etc. There doesn't seem to be > any reasonable use case that I can see. do you mean my use case is not reasonable? or it isn't well explained? or something else? https://github.com/llvm/llvm-project/pull/92499 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [RISCV] Bump Zaamo and Zalrsc to version 1.0 (PR #91556)
https://github.com/4vtomat closed https://github.com/llvm/llvm-project/pull/91556 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 8be079c - [RISCV] Bump Zaamo and Zalrsc to version 1.0 (#91556)
Author: Brandon Wu Date: 2024-05-21T12:04:46+08:00 New Revision: 8be079cdddfd628d356d9ddb5ab397ea95fb1030 URL: https://github.com/llvm/llvm-project/commit/8be079cdddfd628d356d9ddb5ab397ea95fb1030 DIFF: https://github.com/llvm/llvm-project/commit/8be079cdddfd628d356d9ddb5ab397ea95fb1030.diff LOG: [RISCV] Bump Zaamo and Zalrsc to version 1.0 (#91556) The ratified information can be found here: https://wiki.riscv.org/display/HOME/Ratified+Extensions Added: Modified: clang/test/Preprocessor/riscv-target-features.c llvm/docs/RISCVUsage.rst llvm/docs/ReleaseNotes.rst llvm/lib/Target/RISCV/RISCVFeatures.td llvm/test/CodeGen/RISCV/attributes.ll llvm/test/MC/RISCV/rv32zaamo-invalid.s llvm/test/MC/RISCV/rv32zaamo-valid.s llvm/test/MC/RISCV/rv32zalrsc-invalid.s llvm/test/MC/RISCV/rv32zalrsc-valid.s llvm/test/MC/RISCV/rv64zaamo-invalid.s llvm/test/MC/RISCV/rv64zaamo-valid.s llvm/test/MC/RISCV/rv64zalrsc-invalid.s llvm/test/MC/RISCV/rv64zalrsc-valid.s llvm/unittests/TargetParser/RISCVISAInfoTest.cpp Removed: diff --git a/clang/test/Preprocessor/riscv-target-features.c b/clang/test/Preprocessor/riscv-target-features.c index 913093bb51db6..0865add7e8fb8 100644 --- a/clang/test/Preprocessor/riscv-target-features.c +++ b/clang/test/Preprocessor/riscv-target-features.c @@ -79,7 +79,9 @@ // CHECK-NOT: __riscv_xventanacondops {{.*$}} // CHECK-NOT: __riscv_za128rs {{.*$}} // CHECK-NOT: __riscv_za64rs {{.*$}} +// CHECK-NOT: __riscv_zaamo {{.*$}} // CHECK-NOT: __riscv_zacas {{.*$}} +// CHECK-NOT: __riscv_zalrsc {{.*$}} // CHECK-NOT: __riscv_zama16b {{.*$}} // CHECK-NOT: __riscv_zawrs {{.*$}} // CHECK-NOT: __riscv_zba {{.*$}} @@ -174,10 +176,8 @@ // CHECK-NOT: __riscv_sspm{{.*$}} // CHECK-NOT: __riscv_ssqosid{{.*$}} // CHECK-NOT: __riscv_supm{{.*$}} -// CHECK-NOT: __riscv_zaamo {{.*$}} // CHECK-NOT: __riscv_zabha {{.*$}} // CHECK-NOT: __riscv_zalasr {{.*$}} -// CHECK-NOT: __riscv_zalrsc {{.*$}} // CHECK-NOT: __riscv_zfbfmin {{.*$}} // CHECK-NOT: __riscv_zicfilp {{.*$}} // CHECK-NOT: __riscv_zicfiss {{.*$}} @@ -707,6 +707,14 @@ // RUN: -o - | FileCheck --check-prefix=CHECK-ZA64RS-EXT %s // CHECK-ZA64RS-EXT: __riscv_za64rs 100{{$}} +// RUN: %clang --target=riscv32 \ +// RUN: -march=rv32i_zaamo1p0 -E -dM %s \ +// RUN: -o - | FileCheck --check-prefix=CHECK-ZAAMO-EXT %s +// RUN: %clang --target=riscv64 \ +// RUN: -march=rv64i_zaamo1p0 -E -dM %s \ +// RUN: -o - | FileCheck --check-prefix=CHECK-ZAAMO-EXT %s +// CHECK-ZAAMO-EXT: __riscv_zaamo 100{{$}} + // RUN: %clang --target=riscv32 \ // RUN: -march=rv32ia_zacas1p0 -E -dM %s \ // RUN: -o - | FileCheck --check-prefix=CHECK-ZACAS-EXT %s @@ -715,6 +723,14 @@ // RUN: -o - | FileCheck --check-prefix=CHECK-ZACAS-EXT %s // CHECK-ZACAS-EXT: __riscv_zacas 100{{$}} +// RUN: %clang --target=riscv32 \ +// RUN: -march=rv32i_zalrsc1p0 -E -dM %s \ +// RUN: -o - | FileCheck --check-prefix=CHECK-ZALRSC-EXT %s +// RUN: %clang --target=riscv64 \ +// RUN: -march=rv64i_zalrsc1p0 -E -dM %s \ +// RUN: -o - | FileCheck --check-prefix=CHECK-ZALRSC-EXT %s +// CHECK-ZALRSC-EXT: __riscv_zalrsc 100{{$}} + // RUN: %clang --target=riscv32 -march=rv32izama16b -x c -E -dM %s \ // RUN: -o - | FileCheck --check-prefix=CHECK-ZAMA16B-EXT %s // RUN: %clang --target=riscv64 -march=rv64izama16b -x c -E -dM %s \ @@ -1554,14 +1570,6 @@ // CHECK-ZVKT-EXT: __riscv_zvkt 100{{$}} // Experimental extensions -// RUN: %clang --target=riscv32 -menable-experimental-extensions \ -// RUN: -march=rv32i_zaamo0p2 -E -dM %s \ -// RUN: -o - | FileCheck --check-prefix=CHECK-ZAAMO-EXT %s -// RUN: %clang --target=riscv64 -menable-experimental-extensions \ -// RUN: -march=rv64i_zaamo0p2 -E -dM %s \ -// RUN: -o - | FileCheck --check-prefix=CHECK-ZAAMO-EXT %s -// CHECK-ZAAMO-EXT: __riscv_zaamo 2000{{$}} - // RUN: %clang --target=riscv32 -menable-experimental-extensions \ // RUN: -march=rv32ia_zabha1p0 -E -dM %s \ // RUN: -o - | FileCheck --check-prefix=CHECK-ZABHA-EXT %s @@ -1578,14 +1586,6 @@ // RUN: -o - | FileCheck --check-prefix=CHECK-ZALASR-EXT %s // CHECK-ZALASR-EXT: __riscv_zalasr 1000{{$}} -// RUN: %clang --target=riscv32 -menable-experimental-extensions \ -// RUN: -march=rv32i_zalrsc0p2 -E -dM %s \ -// RUN: -o - | FileCheck --check-prefix=CHECK-ZALRSC-EXT %s -// RUN: %clang --target=riscv64 -menable-experimental-extensions \ -// RUN: -march=rv64i_zalrsc0p2 -E -dM %s \ -// RUN: -o - | FileCheck --check-prefix=CHECK-ZALRSC-EXT %s -// CHECK-ZALRSC-EXT: __riscv_zalrsc 2000{{$}} - // RUN: %clang --target=riscv32 -menable-experimental-extensions \ // RUN: -march=rv32izfbfmin1p0 -E -dM %s \ // RUN: -o - | FileCheck --check-prefix=CHECK-ZFBFMIN-EXT %s diff --git a/llvm/docs/RISCVUsage.rst b/llvm/docs/RISCVUsage.rst index ff08c9d345d5f..5ecee2a480f7d 100644 ---
[clang] [llvm] [RISCV] Bump Zaamo and Zalrsc to version 1.0 (PR #91556)
https://github.com/4vtomat updated https://github.com/llvm/llvm-project/pull/91556 >From 062d7d5017b01fb3afbaffe1a34487cfe36288d2 Mon Sep 17 00:00:00 2001 From: Brandon Wu Date: Wed, 8 May 2024 21:43:07 -0700 Subject: [PATCH 1/4] [RISCV] Bump Zaamo and Zalrsc to version 1.0 The ratified information can be found here: https://wiki.riscv.org/display/HOME/Ratified+Extensions --- .../test/Preprocessor/riscv-target-features.c | 20 +-- llvm/lib/Target/RISCV/RISCVFeatures.td| 8 llvm/test/CodeGen/RISCV/attributes.ll | 16 +++ llvm/test/MC/RISCV/rv32zaamo-invalid.s| 2 +- llvm/test/MC/RISCV/rv32zaamo-valid.s | 12 +-- llvm/test/MC/RISCV/rv32zalrsc-invalid.s | 2 +- llvm/test/MC/RISCV/rv32zalrsc-valid.s | 12 +-- llvm/test/MC/RISCV/rv64zaamo-invalid.s| 2 +- llvm/test/MC/RISCV/rv64zaamo-valid.s | 8 llvm/test/MC/RISCV/rv64zalrsc-invalid.s | 2 +- llvm/test/MC/RISCV/rv64zalrsc-valid.s | 8 .../TargetParser/RISCVISAInfoTest.cpp | 4 ++-- 12 files changed, 48 insertions(+), 48 deletions(-) diff --git a/clang/test/Preprocessor/riscv-target-features.c b/clang/test/Preprocessor/riscv-target-features.c index 913093bb51db6..ead9ac9b4063f 100644 --- a/clang/test/Preprocessor/riscv-target-features.c +++ b/clang/test/Preprocessor/riscv-target-features.c @@ -1554,13 +1554,13 @@ // CHECK-ZVKT-EXT: __riscv_zvkt 100{{$}} // Experimental extensions -// RUN: %clang --target=riscv32 -menable-experimental-extensions \ -// RUN: -march=rv32i_zaamo0p2 -E -dM %s \ +// RUN: %clang --target=riscv32 \ +// RUN: -march=rv32i_zaamo1p0 -E -dM %s \ // RUN: -o - | FileCheck --check-prefix=CHECK-ZAAMO-EXT %s -// RUN: %clang --target=riscv64 -menable-experimental-extensions \ -// RUN: -march=rv64i_zaamo0p2 -E -dM %s \ +// RUN: %clang --target=riscv64 \ +// RUN: -march=rv64i_zaamo1p0 -E -dM %s \ // RUN: -o - | FileCheck --check-prefix=CHECK-ZAAMO-EXT %s -// CHECK-ZAAMO-EXT: __riscv_zaamo 2000{{$}} +// CHECK-ZAAMO-EXT: __riscv_zaamo 100{{$}} // RUN: %clang --target=riscv32 -menable-experimental-extensions \ // RUN: -march=rv32ia_zabha1p0 -E -dM %s \ @@ -1578,13 +1578,13 @@ // RUN: -o - | FileCheck --check-prefix=CHECK-ZALASR-EXT %s // CHECK-ZALASR-EXT: __riscv_zalasr 1000{{$}} -// RUN: %clang --target=riscv32 -menable-experimental-extensions \ -// RUN: -march=rv32i_zalrsc0p2 -E -dM %s \ +// RUN: %clang --target=riscv32 \ +// RUN: -march=rv32i_zalrsc1p0 -E -dM %s \ // RUN: -o - | FileCheck --check-prefix=CHECK-ZALRSC-EXT %s -// RUN: %clang --target=riscv64 -menable-experimental-extensions \ -// RUN: -march=rv64i_zalrsc0p2 -E -dM %s \ +// RUN: %clang --target=riscv64 \ +// RUN: -march=rv64i_zalrsc1p0 -E -dM %s \ // RUN: -o - | FileCheck --check-prefix=CHECK-ZALRSC-EXT %s -// CHECK-ZALRSC-EXT: __riscv_zalrsc 2000{{$}} +// CHECK-ZALRSC-EXT: __riscv_zalrsc 100{{$}} // RUN: %clang --target=riscv32 -menable-experimental-extensions \ // RUN: -march=rv32izfbfmin1p0 -E -dM %s \ diff --git a/llvm/lib/Target/RISCV/RISCVFeatures.td b/llvm/lib/Target/RISCV/RISCVFeatures.td index 89e1214f469da..b099496d18388 100644 --- a/llvm/lib/Target/RISCV/RISCVFeatures.td +++ b/llvm/lib/Target/RISCV/RISCVFeatures.td @@ -211,8 +211,8 @@ def FeatureStdExtZa128rs : RISCVExtension<"za128rs", 1, 0, "'Za128rs' (Reservation Set Size of at Most 128 Bytes)">; def FeatureStdExtZaamo -: RISCVExperimentalExtension<"zaamo", 0, 2, - "'Zaamo' (Atomic Memory Operations)">; +: RISCVExtension<"zaamo", 1, 0, + "'Zaamo' (Atomic Memory Operations)">; def HasStdExtAOrZaamo : Predicate<"Subtarget->hasStdExtA() || Subtarget->hasStdExtZaamo()">, AssemblerPredicate<(any_of FeatureStdExtA, FeatureStdExtZaamo), @@ -242,8 +242,8 @@ def HasStdExtZalasr : Predicate<"Subtarget->hasStdExtZalasr()">, "'Zalasr' (Load-Acquire and Store-Release Instructions)">; def FeatureStdExtZalrsc -: RISCVExperimentalExtension<"zalrsc", 0, 2, - "'Zalrsc' (Load-Reserved/Store-Conditional)">; +: RISCVExtension<"zalrsc", 1, 0, + "'Zalrsc' (Load-Reserved/Store-Conditional)">; def HasStdExtAOrZalrsc : Predicate<"Subtarget->hasStdExtA() || Subtarget->hasStdExtZalrsc()">, AssemblerPredicate<(any_of FeatureStdExtA, FeatureStdExtZalrsc), diff --git a/llvm/test/CodeGen/RISCV/attributes.ll b/llvm/test/CodeGen/RISCV/attributes.ll index 8f49f6648ad28..9fdd842e5dd37 100644 --- a/llvm/test/CodeGen/RISCV/attributes.ll +++ b/llvm/test/CodeGen/RISCV/attributes.ll @@ -112,10 +112,10 @@ ; RUN: llc -mtriple=riscv32 -mattr=+experimental-zfbfmin %s -o - | FileCheck --check-prefixes=CHECK,RV32ZFBFMIN %s ; RUN: llc -mtriple=riscv32 -mattr=+experimental-zvfbfmin %s -o - | FileCheck
[clang] [llvm] [RISCV] Bump Zaamo and Zalrsc to version 1.0 (PR #91556)
https://github.com/4vtomat updated https://github.com/llvm/llvm-project/pull/91556 >From 062d7d5017b01fb3afbaffe1a34487cfe36288d2 Mon Sep 17 00:00:00 2001 From: Brandon Wu Date: Wed, 8 May 2024 21:43:07 -0700 Subject: [PATCH 1/3] [RISCV] Bump Zaamo and Zalrsc to version 1.0 The ratified information can be found here: https://wiki.riscv.org/display/HOME/Ratified+Extensions --- .../test/Preprocessor/riscv-target-features.c | 20 +-- llvm/lib/Target/RISCV/RISCVFeatures.td| 8 llvm/test/CodeGen/RISCV/attributes.ll | 16 +++ llvm/test/MC/RISCV/rv32zaamo-invalid.s| 2 +- llvm/test/MC/RISCV/rv32zaamo-valid.s | 12 +-- llvm/test/MC/RISCV/rv32zalrsc-invalid.s | 2 +- llvm/test/MC/RISCV/rv32zalrsc-valid.s | 12 +-- llvm/test/MC/RISCV/rv64zaamo-invalid.s| 2 +- llvm/test/MC/RISCV/rv64zaamo-valid.s | 8 llvm/test/MC/RISCV/rv64zalrsc-invalid.s | 2 +- llvm/test/MC/RISCV/rv64zalrsc-valid.s | 8 .../TargetParser/RISCVISAInfoTest.cpp | 4 ++-- 12 files changed, 48 insertions(+), 48 deletions(-) diff --git a/clang/test/Preprocessor/riscv-target-features.c b/clang/test/Preprocessor/riscv-target-features.c index 913093bb51db6..ead9ac9b4063f 100644 --- a/clang/test/Preprocessor/riscv-target-features.c +++ b/clang/test/Preprocessor/riscv-target-features.c @@ -1554,13 +1554,13 @@ // CHECK-ZVKT-EXT: __riscv_zvkt 100{{$}} // Experimental extensions -// RUN: %clang --target=riscv32 -menable-experimental-extensions \ -// RUN: -march=rv32i_zaamo0p2 -E -dM %s \ +// RUN: %clang --target=riscv32 \ +// RUN: -march=rv32i_zaamo1p0 -E -dM %s \ // RUN: -o - | FileCheck --check-prefix=CHECK-ZAAMO-EXT %s -// RUN: %clang --target=riscv64 -menable-experimental-extensions \ -// RUN: -march=rv64i_zaamo0p2 -E -dM %s \ +// RUN: %clang --target=riscv64 \ +// RUN: -march=rv64i_zaamo1p0 -E -dM %s \ // RUN: -o - | FileCheck --check-prefix=CHECK-ZAAMO-EXT %s -// CHECK-ZAAMO-EXT: __riscv_zaamo 2000{{$}} +// CHECK-ZAAMO-EXT: __riscv_zaamo 100{{$}} // RUN: %clang --target=riscv32 -menable-experimental-extensions \ // RUN: -march=rv32ia_zabha1p0 -E -dM %s \ @@ -1578,13 +1578,13 @@ // RUN: -o - | FileCheck --check-prefix=CHECK-ZALASR-EXT %s // CHECK-ZALASR-EXT: __riscv_zalasr 1000{{$}} -// RUN: %clang --target=riscv32 -menable-experimental-extensions \ -// RUN: -march=rv32i_zalrsc0p2 -E -dM %s \ +// RUN: %clang --target=riscv32 \ +// RUN: -march=rv32i_zalrsc1p0 -E -dM %s \ // RUN: -o - | FileCheck --check-prefix=CHECK-ZALRSC-EXT %s -// RUN: %clang --target=riscv64 -menable-experimental-extensions \ -// RUN: -march=rv64i_zalrsc0p2 -E -dM %s \ +// RUN: %clang --target=riscv64 \ +// RUN: -march=rv64i_zalrsc1p0 -E -dM %s \ // RUN: -o - | FileCheck --check-prefix=CHECK-ZALRSC-EXT %s -// CHECK-ZALRSC-EXT: __riscv_zalrsc 2000{{$}} +// CHECK-ZALRSC-EXT: __riscv_zalrsc 100{{$}} // RUN: %clang --target=riscv32 -menable-experimental-extensions \ // RUN: -march=rv32izfbfmin1p0 -E -dM %s \ diff --git a/llvm/lib/Target/RISCV/RISCVFeatures.td b/llvm/lib/Target/RISCV/RISCVFeatures.td index 89e1214f469da..b099496d18388 100644 --- a/llvm/lib/Target/RISCV/RISCVFeatures.td +++ b/llvm/lib/Target/RISCV/RISCVFeatures.td @@ -211,8 +211,8 @@ def FeatureStdExtZa128rs : RISCVExtension<"za128rs", 1, 0, "'Za128rs' (Reservation Set Size of at Most 128 Bytes)">; def FeatureStdExtZaamo -: RISCVExperimentalExtension<"zaamo", 0, 2, - "'Zaamo' (Atomic Memory Operations)">; +: RISCVExtension<"zaamo", 1, 0, + "'Zaamo' (Atomic Memory Operations)">; def HasStdExtAOrZaamo : Predicate<"Subtarget->hasStdExtA() || Subtarget->hasStdExtZaamo()">, AssemblerPredicate<(any_of FeatureStdExtA, FeatureStdExtZaamo), @@ -242,8 +242,8 @@ def HasStdExtZalasr : Predicate<"Subtarget->hasStdExtZalasr()">, "'Zalasr' (Load-Acquire and Store-Release Instructions)">; def FeatureStdExtZalrsc -: RISCVExperimentalExtension<"zalrsc", 0, 2, - "'Zalrsc' (Load-Reserved/Store-Conditional)">; +: RISCVExtension<"zalrsc", 1, 0, + "'Zalrsc' (Load-Reserved/Store-Conditional)">; def HasStdExtAOrZalrsc : Predicate<"Subtarget->hasStdExtA() || Subtarget->hasStdExtZalrsc()">, AssemblerPredicate<(any_of FeatureStdExtA, FeatureStdExtZalrsc), diff --git a/llvm/test/CodeGen/RISCV/attributes.ll b/llvm/test/CodeGen/RISCV/attributes.ll index 8f49f6648ad28..9fdd842e5dd37 100644 --- a/llvm/test/CodeGen/RISCV/attributes.ll +++ b/llvm/test/CodeGen/RISCV/attributes.ll @@ -112,10 +112,10 @@ ; RUN: llc -mtriple=riscv32 -mattr=+experimental-zfbfmin %s -o - | FileCheck --check-prefixes=CHECK,RV32ZFBFMIN %s ; RUN: llc -mtriple=riscv32 -mattr=+experimental-zvfbfmin %s -o - | FileCheck
[clang] [llvm] [RISCV] Bump Zaamo and Zalrsc to version 1.0 (PR #91556)
@@ -1554,13 +1554,13 @@ // CHECK-ZVKT-EXT: __riscv_zvkt 100{{$}} // Experimental extensions -// RUN: %clang --target=riscv32 -menable-experimental-extensions \ -// RUN: -march=rv32i_zaamo0p2 -E -dM %s \ +// RUN: %clang --target=riscv32 \ 4vtomat wrote: Oh, I see. Thanks for catching this! https://github.com/llvm/llvm-project/pull/91556 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [IPO] Optimise variadic functions (PR #92850)
JonChesterfield wrote: [inline-then-fold-variadics.cpp](https://github.com/llvm/llvm-project/pull/92850/commits/15061bfbc2dc06de5bac32628389386cadaa5632#diff-0a9893e04ae7e0a5692ad93dfb73d6efa992953f7e9eebb68c1a3f4acd457e1e) is the motivating example for optimisation - simple variadic functions are removed entirely. Variadic logging wrappers around vfprintf and similar are similarly inlined. Wasm might choose to use a call to this to replace the backend handling, they should each build the same frame passed by pointer. That would help offset the increase in compiler complexity from this patch. AMDGPU has a requirement for variadic function lowering, at least sufficient for libc. It is much easier to debug in wasm or x64 than on the GPU so I'm hoping this can land as a target independent pass and not end up in a GPU backend. https://github.com/llvm/llvm-project/pull/92850 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [RISCV] Remove unneeded multiply in RISCV CodeGenTypes (PR #92644)
https://github.com/4vtomat closed https://github.com/llvm/llvm-project/pull/92644 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 64aafd6 - [RISCV] Remove unneeded multiply in RISCV CodeGenTypes (#92644)
Author: Brandon Wu Date: 2024-05-21T11:50:04+08:00 New Revision: 64aafd6908e3aa36c4504bc10f8d9fc819513f6c URL: https://github.com/llvm/llvm-project/commit/64aafd6908e3aa36c4504bc10f8d9fc819513f6c DIFF: https://github.com/llvm/llvm-project/commit/64aafd6908e3aa36c4504bc10f8d9fc819513f6c.diff LOG: [RISCV] Remove unneeded multiply in RISCV CodeGenTypes (#92644) The NumVectors other than 1 is handled by the code above. Added: Modified: clang/lib/CodeGen/CodeGenTypes.cpp Removed: diff --git a/clang/lib/CodeGen/CodeGenTypes.cpp b/clang/lib/CodeGen/CodeGenTypes.cpp index e8d75eda029e6..0a926e4ac27fe 100644 --- a/clang/lib/CodeGen/CodeGenTypes.cpp +++ b/clang/lib/CodeGen/CodeGenTypes.cpp @@ -523,8 +523,7 @@ llvm::Type *CodeGenTypes::ConvertType(QualType T) { return llvm::StructType::get(getLLVMContext(), EltTys); } return llvm::ScalableVectorType::get(ConvertType(Info.ElementType), - Info.EC.getKnownMinValue() * - Info.NumVectors); + Info.EC.getKnownMinValue()); } #define WASM_REF_TYPE(Name, MangledName, Id, SingletonId, AS) \ case BuiltinType::Id: { \ ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [X86] Support EGPR for inline assembly. (PR #92338)
jyknight wrote: Please update the constraint code list https://llvm.org/docs/LangRef.html#supported-constraint-code-list with any new codes. https://github.com/llvm/llvm-project/pull/92338 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [IPO] Optimise variadic functions (PR #92850)
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 560c2fd3d427a5e2dc2361abde1142f3fda40253 15061bfbc2dc06de5bac32628389386cadaa5632 -- clang/test/CodeGen/voidptr-vaarg.c clang/test/CodeGenCXX/inline-then-fold-variadics.cpp llvm/include/llvm/Transforms/IPO/ExpandVariadics.h llvm/lib/Transforms/IPO/ExpandVariadics.cpp clang/test/CodeGen/aarch64-ABI-align-packed.c llvm/include/llvm/InitializePasses.h llvm/lib/Passes/PassBuilder.cpp llvm/lib/Passes/PassBuilderPipelines.cpp `` View the diff from clang-format here. ``diff diff --git a/llvm/include/llvm/Transforms/IPO/ExpandVariadics.h b/llvm/include/llvm/Transforms/IPO/ExpandVariadics.h index 02f3aa45ef..f7c9618bad 100644 --- a/llvm/include/llvm/Transforms/IPO/ExpandVariadics.h +++ b/llvm/include/llvm/Transforms/IPO/ExpandVariadics.h @@ -18,9 +18,9 @@ class OptimizationLevel; enum class ExpandVariadicsMode { Unspecified, // Use the implementation defaults - Disable, // Disable the pass entirely - Optimize, // Optimise without changing ABI - Lowering, // Change variadic calling convention + Disable, // Disable the pass entirely + Optimize,// Optimise without changing ABI + Lowering,// Change variadic calling convention }; class ExpandVariadicsPass : public PassInfoMixin { diff --git a/llvm/lib/Transforms/IPO/ExpandVariadics.cpp b/llvm/lib/Transforms/IPO/ExpandVariadics.cpp index c04e16cb7b..e27c391d88 100644 --- a/llvm/lib/Transforms/IPO/ExpandVariadics.cpp +++ b/llvm/lib/Transforms/IPO/ExpandVariadics.cpp @@ -106,8 +106,7 @@ public: virtual Value *initializeVAList(LLVMContext , IRBuilder<> , AllocaInst *, Value * /*buffer*/) = 0; - struct VAArgSlotInfo - { + struct VAArgSlotInfo { Align Align; // With respect to the call frame bool Indirect; // Passed via a pointer bool Unknown; // Cannot analyse this type, cannot transform the call @@ -178,7 +177,6 @@ public: bool runOnModule(Module ) override; bool runOnFunction(Module , IRBuilder<> , Function *F); - bool rewriteABI() { return Mode == ExpandVariadicsMode::Lowering; } void memcpyVAListPointers(const DataLayout , IRBuilder<> , @@ -190,7 +188,6 @@ public: ConstantInt::get(Type::getInt32Ty(Ctx), Size)); } - template bool expandIntrinsicUsers(Module , IRBuilder<> , PointerType *ArgType) { @@ -217,7 +214,6 @@ public: bool expandVAIntrinsicCall(IRBuilder<> , const DataLayout , VACopyInst *Inst); - FunctionType *inlinableVariadicFunctionType(Module , FunctionType *FTy) { // The type of "FTy" with the ... removed and a va_list appended SmallVector ArgTypes(FTy->param_begin(), FTy->param_end()); @@ -492,7 +488,8 @@ bool ExpandVariadics::runOnFunction(Module , IRBuilder<> , assert(VariadicWrapper->isDeclaration()); assert(OriginalFunction->use_empty()); - // Create a new function taking va_list containing the implementation of the original + // Create a new function taking va_list containing the implementation of the + // original Function *FixedArityReplacement = deriveFixedArityReplacement(M, Builder, OriginalFunction); assert(OriginalFunction->isDeclaration()); @@ -511,7 +508,6 @@ bool ExpandVariadics::runOnFunction(Module , IRBuilder<> , // 2. a variadic function that unconditionally calls a fixed arity replacement // 3. a fixed arity function equivalent to the original function - // Replace known calls to the variadic with calls to the va_list equivalent for (User *U : llvm::make_early_inc_range(VariadicWrapper->users())) { if (CallBase *CB = dyn_cast(U)) { @@ -524,13 +520,11 @@ bool ExpandVariadics::runOnFunction(Module , IRBuilder<> , } } - Function *const ExternallyAccessible = - rewriteABI() ? FixedArityReplacement : VariadicWrapper; + rewriteABI() ? FixedArityReplacement : VariadicWrapper; Function *const InternalOnly = -rewriteABI() ? VariadicWrapper : FixedArityReplacement; + rewriteABI() ? VariadicWrapper : FixedArityReplacement; - // care needed over other attributes, metadata etc ExternallyAccessible->setLinkage(OriginalFunction->getLinkage()); @@ -548,10 +542,10 @@ bool ExpandVariadics::runOnFunction(Module , IRBuilder<> , if (rewriteABI()) { // All known calls to the function have been removed by expandCall // Resolve everything else by replace all uses with - + VariadicWrapper->replaceAllUsesWith(FixedArityReplacement); - -assert (VariadicWrapper->use_empty()); + +assert(VariadicWrapper->use_empty()); VariadicWrapper->eraseFromParent(); } @@ -613,10 +607,8 @@ ExpandVariadics::deriveFixedArityReplacement(Module , IRBuilder<> ,
[clang] [llvm] [IPO] Optimise variadic functions (PR #92850)
@@ -1,5 +1,6 @@ // REQUIRES: aarch64-registered-target -// RUN: %clang_cc1 -triple aarch64 -target-feature +neon -emit-llvm -O2 -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple aarch64 -target-feature +neon -emit-llvm -O2 -o - %s -mllvm -expand-variadics-override=disable | FileCheck %s + JonChesterfield wrote: ^this disable shouldn't be necessary, having trouble working out what the filecheck regex are complaining about https://github.com/llvm/llvm-project/pull/92850 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [IPO] Optimise variadic functions (PR #92850)
llvmbot wrote: @llvm/pr-subscribers-llvm-transforms @llvm/pr-subscribers-backend-x86 Author: Jon Chesterfield (JonChesterfield) Changes Replace variadic functions with equivalent functions taking a va_list. This composes with optimisations like inlining to give zero cost variadics. Scheduled before the inliner at O1 and callable from a backend to provide a lowering implementation on IR. Implementation is complete for webassembly. The frame constructed is the same as that done by the backend, a later patch will propose replacing the bespoke lowering there with a call to this pass. Most of the target-independent tests for this pass use wasm as a convenient triple. Implemented for simple types on x64 and aarch64 to show that more complicated va_list constructs work as expected. Complex types left to a later patch to help keep the test quantity reasonable here. Likewise exceptions are left for a later patch. Implementing nvptx and amdgpu in later patches as they're straightforward given this pass but may need discussion over what the proper calling convention should be. Both are expected to look similar to wasm. That would be consistent with ptx. Implementing for targets that have va_arg selected in place for is mechanical - construct whatever frame layout is the complement of va_arg, set up a va_list iterator, add the tests. The hope is that this is sufficiently useful to land as is. It'll remove any known calls for webassembly and the majority of known calls likely to exist in practice on x64 and aarch64. Having the pass in tree would be very helpful for reviews of amdgpu and nvptx variadic lowering, letting those focus on the what as opposed to the how. --- Patch is 198.86 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/92850.diff 28 Files Affected: - (modified) clang/test/CodeGen/aarch64-ABI-align-packed.c (+2-1) - (added) clang/test/CodeGen/voidptr-vaarg.c (+478) - (added) clang/test/CodeGenCXX/inline-then-fold-variadics.cpp (+128) - (modified) llvm/include/llvm/InitializePasses.h (+1) - (added) llvm/include/llvm/Transforms/IPO/ExpandVariadics.h (+43) - (modified) llvm/lib/Passes/PassBuilder.cpp (+1) - (modified) llvm/lib/Passes/PassBuilderPipelines.cpp (+4) - (modified) llvm/lib/Passes/PassRegistry.def (+1) - (modified) llvm/lib/Transforms/IPO/CMakeLists.txt (+1) - (added) llvm/lib/Transforms/IPO/ExpandVariadics.cpp (+1250) - (added) llvm/test/CodeGen/AArch64/expand-variadic-call-apcs64-linux.ll (+289) - (added) llvm/test/CodeGen/WebAssembly/expand-variadic-call.ll (+483) - (added) llvm/test/CodeGen/WebAssembly/vararg-frame.ll (+525) - (added) llvm/test/CodeGen/X86/expand-variadic-call-x64-linux.ll (+244) - (modified) llvm/test/Other/new-pm-defaults.ll (+1) - (modified) llvm/test/Other/new-pm-thinlto-postlink-defaults.ll (+1) - (modified) llvm/test/Other/new-pm-thinlto-postlink-pgo-defaults.ll (+1) - (modified) llvm/test/Other/new-pm-thinlto-postlink-samplepgo-defaults.ll (+1-1) - (modified) llvm/test/Other/new-pm-thinlto-prelink-defaults.ll (+1) - (modified) llvm/test/Other/new-pm-thinlto-prelink-pgo-defaults.ll (+1) - (modified) llvm/test/Other/new-pm-thinlto-prelink-samplepgo-defaults.ll (+1) - (added) llvm/test/Transforms/ExpandVariadics/expand-va-intrinsic-split-linkage.ll (+239) - (added) llvm/test/Transforms/ExpandVariadics/expand-va-intrinsic-split-simple.ll (+212) - (added) llvm/test/Transforms/ExpandVariadics/indirect-calls.ll (+58) - (added) llvm/test/Transforms/ExpandVariadics/intrinsics.ll (+117) - (added) llvm/test/Transforms/ExpandVariadics/pass-byval.ll (+81) - (added) llvm/test/Transforms/ExpandVariadics/pass-integers.ll (+344) - (modified) llvm/utils/gn/secondary/llvm/lib/Transforms/IPO/BUILD.gn (+1) ``diff diff --git a/clang/test/CodeGen/aarch64-ABI-align-packed.c b/clang/test/CodeGen/aarch64-ABI-align-packed.c index 0349ebc8cc639..9ce051369f390 100644 --- a/clang/test/CodeGen/aarch64-ABI-align-packed.c +++ b/clang/test/CodeGen/aarch64-ABI-align-packed.c @@ -1,5 +1,6 @@ // REQUIRES: aarch64-registered-target -// RUN: %clang_cc1 -triple aarch64 -target-feature +neon -emit-llvm -O2 -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple aarch64 -target-feature +neon -emit-llvm -O2 -o - %s -mllvm -expand-variadics-override=disable | FileCheck %s + #include #include diff --git a/clang/test/CodeGen/voidptr-vaarg.c b/clang/test/CodeGen/voidptr-vaarg.c new file mode 100644 index 0..d023ddf0fb5d2 --- /dev/null +++ b/clang/test/CodeGen/voidptr-vaarg.c @@ -0,0 +1,478 @@ +// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py +// REQUIRES: webassembly-registered-target +// RUN: %clang_cc1 -triple wasm32-unknown-unknown -emit-llvm -o - %s | FileCheck %s + +// Multiple targets use emitVoidPtrVAArg to lower va_arg instructions in clang +// PPC is complicated, excluding from this case analysis +// ForceRightAdjust is false for all
[clang] 1c58208 - [clang-format][NFC] Remove redundnat llvm::, clang::, etc.
Author: Owen Pan Date: 2024-05-20T20:32:18-07:00 New Revision: 1c58208d899285318c89e069268145c85ec33368 URL: https://github.com/llvm/llvm-project/commit/1c58208d899285318c89e069268145c85ec33368 DIFF: https://github.com/llvm/llvm-project/commit/1c58208d899285318c89e069268145c85ec33368.diff LOG: [clang-format][NFC] Remove redundnat llvm::, clang::, etc. Added: Modified: clang/include/clang/Format/Format.h clang/lib/Format/Format.cpp clang/lib/Format/FormatTokenSource.h clang/lib/Format/MacroExpander.cpp clang/lib/Format/Macros.h clang/lib/Format/SortJavaScriptImports.cpp clang/tools/clang-format/ClangFormat.cpp clang/unittests/Format/CleanupTest.cpp clang/unittests/Format/DefinitionBlockSeparatorTest.cpp clang/unittests/Format/FormatTestBase.h clang/unittests/Format/FormatTestCSharp.cpp clang/unittests/Format/FormatTestJS.cpp clang/unittests/Format/FormatTestJson.cpp clang/unittests/Format/FormatTestProto.cpp clang/unittests/Format/FormatTestRawStrings.cpp clang/unittests/Format/FormatTestSelective.cpp clang/unittests/Format/FormatTestTableGen.cpp clang/unittests/Format/FormatTestUtils.h clang/unittests/Format/FormatTestVerilog.cpp clang/unittests/Format/FormatTokenSourceTest.cpp clang/unittests/Format/MacroCallReconstructorTest.cpp clang/unittests/Format/MacroExpanderTest.cpp clang/unittests/Format/MatchFilePathTest.cpp clang/unittests/Format/NamespaceEndCommentsFixerTest.cpp clang/unittests/Format/ObjCPropertyAttributeOrderFixerTest.cpp clang/unittests/Format/QualifierFixerTest.cpp clang/unittests/Format/SortImportsTestJS.cpp clang/unittests/Format/SortImportsTestJava.cpp clang/unittests/Format/SortIncludesTest.cpp clang/unittests/Format/TestLexer.h clang/unittests/Format/TokenAnnotatorTest.cpp clang/unittests/Format/UsingDeclarationsSorterTest.cpp Removed: diff --git a/clang/include/clang/Format/Format.h b/clang/include/clang/Format/Format.h index 74893f23210cd..274b45d1bc586 100644 --- a/clang/include/clang/Format/Format.h +++ b/clang/include/clang/Format/Format.h @@ -5239,7 +5239,7 @@ tooling::Replacements sortIncludes(const FormatStyle , StringRef Code, /// Returns the replacements corresponding to applying and formatting /// \p Replaces on success; otheriwse, return an llvm::Error carrying /// llvm::StringError. -llvm::Expected +Expected formatReplacements(StringRef Code, const tooling::Replacements , const FormatStyle ); @@ -5256,7 +5256,7 @@ formatReplacements(StringRef Code, const tooling::Replacements , /// The include manipulation is done via ``tooling::HeaderInclude``, see its /// documentation for more details on how include insertion points are found and /// what edits are produced. -llvm::Expected +Expected cleanupAroundReplacements(StringRef Code, const tooling::Replacements , const FormatStyle ); @@ -5381,11 +5381,10 @@ extern const char *DefaultFallbackStyle; /// \returns FormatStyle as specified by ``StyleName``. If ``StyleName`` is /// "file" and no file is found, returns ``FallbackStyle``. If no style could be /// determined, returns an Error. -llvm::Expected getStyle(StringRef StyleName, StringRef FileName, - StringRef FallbackStyle, - StringRef Code = "", - llvm::vfs::FileSystem *FS = nullptr, - bool AllowUnknownOptions = false); +Expected getStyle(StringRef StyleName, StringRef FileName, + StringRef FallbackStyle, StringRef Code = "", + llvm::vfs::FileSystem *FS = nullptr, + bool AllowUnknownOptions = false); // Guesses the language from the ``FileName`` and ``Code`` to be formatted. // Defaults to FormatStyle::LK_Cpp. diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp index 52005a6c881f3..9cba0c2614eef 100644 --- a/clang/lib/Format/Format.cpp +++ b/clang/lib/Format/Format.cpp @@ -28,7 +28,7 @@ using clang::format::FormatStyle; -LLVM_YAML_IS_SEQUENCE_VECTOR(clang::format::FormatStyle::RawStringFormat) +LLVM_YAML_IS_SEQUENCE_VECTOR(FormatStyle::RawStringFormat) namespace llvm { namespace yaml { @@ -1235,7 +1235,7 @@ std::error_code make_error_code(ParseError e) { return std::error_code(static_cast(e), getParseCategory()); } -inline llvm::Error make_string_error(const llvm::Twine ) { +inline llvm::Error make_string_error(const Twine ) { return llvm::make_error(Message, llvm::inconvertibleErrorCode()); } @@ -2361,7 +2361,7 @@ class JavaScriptRequoter : public TokenAnalyzer { // FIXME: handle error. For now, print error message and skip the //
[clang] [clang] Introduce `SemaRISCV` (PR #92682)
@@ -0,0 +1,52 @@ +//===- SemaRISCV.h --- RISC-V target-specific routines ===// topperc wrote: I think header files are supposed to have `-*- C++ -*-` on this line https://github.com/llvm/llvm-project/pull/92682 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Introduce `SemaRISCV` (PR #92682)
https://github.com/wangpc-pp approved this pull request. LGTM. https://github.com/llvm/llvm-project/pull/92682 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [C++23] [CLANG] Adding C++23 constexpr math functions: fmin, fmax and frexp. (PR #88978)
https://github.com/hubert-reinterpretcast edited https://github.com/llvm/llvm-project/pull/88978 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [C++23] [CLANG] Adding C++23 constexpr math functions: fmin, fmax and frexp. (PR #88978)
https://github.com/hubert-reinterpretcast edited https://github.com/llvm/llvm-project/pull/88978 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [C++23] [CLANG] Adding C++23 constexpr math functions: fmin, fmax and frexp. (PR #88978)
@@ -6,17 +6,21 @@ // RUN: %clang_cc1 -triple powerpc-ibm-aix -mlong-double-64 -emit-llvm -o - %s | FileCheck -check-prefix=CHECK %s // RUN: %clang_cc1 -triple powerpc64-ibm-aix -mlong-double-64 -emit-llvm -o - %s | FileCheck -check-prefix=CHECK %s +long double input = 0.0L; + int main() { int DummyInt; long double DummyLongDouble; long double returnValue; returnValue = __builtin_modfl(1.0L, ); - returnValue = __builtin_frexpl(0.0L, ); + returnValue = __builtin_frexpl(input, ); hubert-reinterpretcast wrote: Once the handling of the second parameter is corrected, the change to the test should become unnecessary. https://github.com/llvm/llvm-project/pull/88978 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [C++23] [CLANG] Adding C++23 constexpr math functions: fmin, fmax and frexp. (PR #88978)
@@ -14674,6 +14676,31 @@ static bool TryEvaluateBuiltinNaN(const ASTContext , return true; } +// Checks that the value x is in the range (-1;-0.5], [0.5; 1) +static bool isInFrexpResultRange(const llvm::APFloat ) { + llvm::APFloat minusOne(x.getSemantics(), "-1.0"); + llvm::APFloat minusHalf(x.getSemantics(), "-0.5"); + llvm::APFloat half(x.getSemantics(), "0.5"); + llvm::APFloat one(x.getSemantics(), "1.0"); + + return ((x.compare(minusOne) == llvm::APFloat::cmpGreaterThan && + x.compare(minusHalf) != llvm::APFloat::cmpGreaterThan) || + (x.compare(half) != llvm::APFloat::cmpLessThan && + x.compare(one) == llvm::APFloat::cmpLessThan)); +} + +void FloatExprEvaluator::StoreExponent(LValue Pointer, int exp) { + const APValue::LValueBase Base = Pointer.getLValueBase(); + auto *VD = const_cast(Base.dyn_cast()); + if (auto *VarD = dyn_cast(VD)) { +clang::IntegerLiteral *IL = +clang::IntegerLiteral::Create(Info.Ctx, llvm::APSInt(32, exp), + Info.Ctx.IntTy, clang::SourceLocation()); +VarD->setInit(IL); hubert-reinterpretcast wrote: See use of `handleAssignment` for `__builtin_add_overflow`: https://github.com/llvm/llvm-project/blob/b2d7d72ff2408dcc27048e08d50ac719ff03a89e/clang/lib/AST/ExprConstant.cpp#L13071 https://github.com/llvm/llvm-project/pull/88978 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [AArch64] Use ptrmask for vaarg stack alignment (PR #92836)
https://github.com/JonChesterfield closed https://github.com/llvm/llvm-project/pull/92836 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] b2d7d72 - [AArch64] Use ptrmask for vaarg stack alignment (#92836)
Author: Jon Chesterfield Date: 2024-05-21T03:22:20+01:00 New Revision: b2d7d72ff2408dcc27048e08d50ac719ff03a89e URL: https://github.com/llvm/llvm-project/commit/b2d7d72ff2408dcc27048e08d50ac719ff03a89e DIFF: https://github.com/llvm/llvm-project/commit/b2d7d72ff2408dcc27048e08d50ac719ff03a89e.diff LOG: [AArch64] Use ptrmask for vaarg stack alignment (#92836) Added: Modified: clang/lib/CodeGen/Targets/AArch64.cpp clang/test/CodeGen/aarch64-varargs.c Removed: diff --git a/clang/lib/CodeGen/Targets/AArch64.cpp b/clang/lib/CodeGen/Targets/AArch64.cpp index 0a4711fb2170d..9aa3ea75681b3 100644 --- a/clang/lib/CodeGen/Targets/AArch64.cpp +++ b/clang/lib/CodeGen/Targets/AArch64.cpp @@ -750,18 +750,7 @@ Address AArch64ABIInfo::EmitAAPCSVAArg(Address VAListAddr, QualType Ty, // Again, stack arguments may need realignment. In this case both integer and // floating-point ones might be affected. if (!IsIndirect && TyAlign.getQuantity() > 8) { -int Align = TyAlign.getQuantity(); - -OnStackPtr = CGF.Builder.CreatePtrToInt(OnStackPtr, CGF.Int64Ty); - -OnStackPtr = CGF.Builder.CreateAdd( -OnStackPtr, llvm::ConstantInt::get(CGF.Int64Ty, Align - 1), -"align_stack"); -OnStackPtr = CGF.Builder.CreateAnd( -OnStackPtr, llvm::ConstantInt::get(CGF.Int64Ty, -Align), -"align_stack"); - -OnStackPtr = CGF.Builder.CreateIntToPtr(OnStackPtr, CGF.Int8PtrTy); +OnStackPtr = emitRoundPointerUpToAlignment(CGF, OnStackPtr, TyAlign); } Address OnStackAddr = Address(OnStackPtr, CGF.Int8Ty, std::max(CharUnits::fromQuantity(8), TyAlign)); diff --git a/clang/test/CodeGen/aarch64-varargs.c b/clang/test/CodeGen/aarch64-varargs.c index ee4e88eda4ef4..8952d6980a8d3 100644 --- a/clang/test/CodeGen/aarch64-varargs.c +++ b/clang/test/CodeGen/aarch64-varargs.c @@ -63,10 +63,8 @@ __int128 aligned_int(void) { // CHECK: [[VAARG_ON_STACK]] // CHECK: [[STACK:%[a-z_0-9]+]] = load ptr, ptr @the_list -// CHECK: [[STACKINT:%[a-z_0-9]+]] = ptrtoint ptr [[STACK]] to i64 -// CHECK: [[ALIGN_STACK:%[a-z_0-9]+]] = add i64 [[STACKINT]], 15 -// CHECK: [[ALIGNED_STACK_INT:%[a-z_0-9]+]] = and i64 [[ALIGN_STACK]], -16 -// CHECK: [[ALIGNED_STACK_PTR:%[a-z_0-9]+]] = inttoptr i64 [[ALIGNED_STACK_INT]] to ptr +// CHECK: [[STACKINC:%[a-z_0-9]+]] = getelementptr inbounds i8, ptr [[STACK]], i32 15 +// CHECK: [[ALIGNED_STACK_PTR:%[a-z_0-9.]+]] = call ptr @llvm.ptrmask.p0.i64(ptr [[STACKINC]], i64 -16) // CHECK: [[NEW_STACK:%[a-z_0-9]+]] = getelementptr inbounds i8, ptr [[ALIGNED_STACK_PTR]], i64 16 // CHECK: store ptr [[NEW_STACK]], ptr @the_list // CHECK: br label %[[VAARG_END]] @@ -377,10 +375,8 @@ underaligned_int128 underaligned_int128_test(void) { // CHECK: [[VAARG_ON_STACK]] // CHECK: [[STACK:%[a-z_0-9]+]] = load ptr, ptr @the_list -// CHECK: [[STACKINT:%[a-z_0-9]+]] = ptrtoint ptr [[STACK]] to i64 -// CHECK: [[ALIGN_STACK:%[a-z_0-9]+]] = add i64 [[STACKINT]], 15 -// CHECK: [[ALIGNED_STACK_INT:%[a-z_0-9]+]] = and i64 [[ALIGN_STACK]], -16 -// CHECK: [[ALIGNED_STACK_PTR:%[a-z_0-9]+]] = inttoptr i64 [[ALIGNED_STACK_INT]] to ptr +// CHECK: [[STACKINC:%[a-z_0-9]+]] = getelementptr inbounds i8, ptr [[STACK]], i32 15 +// CHECK: [[ALIGNED_STACK_PTR:%[a-z_0-9.]+]] = call ptr @llvm.ptrmask.p0.i64(ptr [[STACKINC]], i64 -16) // CHECK: [[NEW_STACK:%[a-z_0-9]+]] = getelementptr inbounds i8, ptr [[ALIGNED_STACK_PTR]], i64 16 // CHECK: store ptr [[NEW_STACK]], ptr @the_list // CHECK: br label %[[VAARG_END]] @@ -414,10 +410,8 @@ overaligned_int128 overaligned_int128_test(void) { // CHECK: [[VAARG_ON_STACK]] // CHECK: [[STACK:%[a-z_0-9]+]] = load ptr, ptr @the_list -// CHECK: [[STACKINT:%[a-z_0-9]+]] = ptrtoint ptr [[STACK]] to i64 -// CHECK: [[ALIGN_STACK:%[a-z_0-9]+]] = add i64 [[STACKINT]], 15 -// CHECK: [[ALIGNED_STACK_INT:%[a-z_0-9]+]] = and i64 [[ALIGN_STACK]], -16 -// CHECK: [[ALIGNED_STACK_PTR:%[a-z_0-9]+]] = inttoptr i64 [[ALIGNED_STACK_INT]] to ptr +// CHECK: [[STACKINC:%[a-z_0-9]+]] = getelementptr inbounds i8, ptr [[STACK]], i32 15 +// CHECK: [[ALIGNED_STACK_PTR:%[a-z_0-9.]+]] = call ptr @llvm.ptrmask.p0.i64(ptr [[STACKINC]], i64 -16) // CHECK: [[NEW_STACK:%[a-z_0-9]+]] = getelementptr inbounds i8, ptr [[ALIGNED_STACK_PTR]], i64 16 // CHECK: store ptr [[NEW_STACK]], ptr @the_list // CHECK: br label %[[VAARG_END]] @@ -688,10 +682,8 @@ overaligned_int_struct_member overaligned_int_struct_member_test(void) { // CHECK: [[VAARG_ON_STACK]] // CHECK: [[STACK:%[a-z_0-9]+]] = load ptr, ptr @the_list -// CHECK: [[STACKINT:%[a-z_0-9]+]] = ptrtoint ptr [[STACK]] to i64 -// CHECK: [[ALIGN_STACK:%[a-z_0-9]+]] = add i64 [[STACKINT]], 15 -// CHECK: [[ALIGNED_STACK_INT:%[a-z_0-9]+]] = and i64 [[ALIGN_STACK]], -16 -// CHECK: [[ALIGNED_STACK_PTR:%[a-z_0-9]+]] = inttoptr i64 [[ALIGNED_STACK_INT]] to ptr +// CHECK: [[STACKINC:%[a-z_0-9]+]] =
[clang] [llvm] [X86] Support EGPR for inline assembly. (PR #92338)
FreddyLeaf wrote: [4d1ad30](https://github.com/llvm/llvm-project/pull/92338/commits/4d1ad3090416cda320c88f1ddc0937b5749e64b4) moved but not merged. These two constraints will behavior different under -mattr=+egpr. https://github.com/llvm/llvm-project/pull/92338 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [X86] Support EGPR for inline assembly. (PR #92338)
https://github.com/FreddyLeaf updated https://github.com/llvm/llvm-project/pull/92338 >From 41fbc18c7a4a26b11bc4b772bbe2e384ad9d9dbc Mon Sep 17 00:00:00 2001 From: Freddy Ye Date: Fri, 10 May 2024 16:29:55 +0800 Subject: [PATCH 1/5] [X86] Support EGPR for inline assembly. "jR": explictly enables EGPR "r": enables/disables EGPR w/wo -mapx-inline-asm-use-gpr32 -mapx-inline-asm-use-gpr32 will also define a new Macro: __APX_INLINE_ASM_USE_GPR32__ --- clang/include/clang/Driver/Options.td | 2 + clang/lib/Basic/Targets/X86.cpp | 26 + clang/lib/Basic/Targets/X86.h | 1 + clang/lib/Driver/ToolChains/Arch/X86.cpp | 2 + .../Driver/x86-apx-inline-asm-use-gpr32.cpp | 3 + clang/test/Preprocessor/x86_target_features.c | 3 + llvm/lib/Target/X86/X86.td| 3 + llvm/lib/Target/X86/X86ISelLowering.cpp | 57 +-- .../CodeGen/X86/inline-asm-jR-constraint.ll | 19 +++ .../CodeGen/X86/inline-asm-r-constraint.ll| 16 ++ 10 files changed, 127 insertions(+), 5 deletions(-) create mode 100644 clang/test/Driver/x86-apx-inline-asm-use-gpr32.cpp create mode 100644 llvm/test/CodeGen/X86/inline-asm-jR-constraint.ll create mode 100644 llvm/test/CodeGen/X86/inline-asm-r-constraint.ll diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index 73a2518480e9b..20a7c482bbf06 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -6281,6 +6281,8 @@ def mno_apx_features_EQ : CommaJoined<["-"], "mno-apx-features=">, Group, Alias, AliasArgs<["egpr","push2pop2","ppx", "ndd"]>; def mno_apxf : Flag<["-"], "mno-apxf">, Alias, AliasArgs<["egpr","push2pop2","ppx","ndd"]>; +def mapx_inline_asm_use_gpr32 : Flag<["-"], "mapx-inline-asm-use-gpr32">, Group, +HelpText<"Enable use of GPR32 in inline assembly for APX">; } // let Flags = [TargetSpecific] // VE feature flags diff --git a/clang/lib/Basic/Targets/X86.cpp b/clang/lib/Basic/Targets/X86.cpp index 67e2126cf766b..9e61b6e6d6441 100644 --- a/clang/lib/Basic/Targets/X86.cpp +++ b/clang/lib/Basic/Targets/X86.cpp @@ -450,6 +450,8 @@ bool X86TargetInfo::handleTargetFeatures(std::vector , HasFullBFloat16 = true; } else if (Feature == "+egpr") { HasEGPR = true; +} else if (Feature == "+inline-asm-use-gpr32") { + HasInlineAsmUseGPR32 = true; } else if (Feature == "+push2pop2") { HasPush2Pop2 = true; } else if (Feature == "+ppx") { @@ -974,6 +976,8 @@ void X86TargetInfo::getTargetDefines(const LangOptions , // Condition here is aligned with the feature set of mapxf in Options.td if (HasEGPR && HasPush2Pop2 && HasPPX && HasNDD) Builder.defineMacro("__APX_F__"); + if (HasInlineAsmUseGPR32) +Builder.defineMacro("__APX_INLINE_ASM_USE_GPR32__"); // Each case falls through to the previous one here. switch (SSELevel) { @@ -1493,6 +1497,15 @@ bool X86TargetInfo::validateAsmConstraint( case 'C': // SSE floating point constant. case 'G': // x87 floating point constant. return true; + case 'j': +Name++; +switch (*Name) { +default: + return false; +case 'R': + Info.setAllowsRegister(); + return true; +} case '@': // CC condition changes. if (auto Len = matchAsmCCConstraint(Name)) { @@ -1764,6 +1777,19 @@ std::string X86TargetInfo::convertConstraint(const char *) const { // to the next constraint. return std::string("^") + std::string(Constraint++, 2); } + case 'j': +switch (Constraint[1]) { +default: + // Break from inner switch and fall through (copy single char), + // continue parsing after copying the current constraint into + // the return string. + break; +case 'R': + // "^" hints llvm that this is a 2 letter constraint. + // "Constraint++" is used to promote the string iterator + // to the next constraint. + return std::string("^") + std::string(Constraint++, 2); +} [[fallthrough]]; default: return std::string(1, *Constraint); diff --git a/clang/lib/Basic/Targets/X86.h b/clang/lib/Basic/Targets/X86.h index c14e4d5f433d8..69c68ee80f3ba 100644 --- a/clang/lib/Basic/Targets/X86.h +++ b/clang/lib/Basic/Targets/X86.h @@ -174,6 +174,7 @@ class LLVM_LIBRARY_VISIBILITY X86TargetInfo : public TargetInfo { bool HasNDD = false; bool HasCCMP = false; bool HasCF = false; + bool HasInlineAsmUseGPR32 = false; protected: llvm::X86::CPUKind CPU = llvm::X86::CK_None; diff --git a/clang/lib/Driver/ToolChains/Arch/X86.cpp b/clang/lib/Driver/ToolChains/Arch/X86.cpp index 53e26a9f8e229..085ff4824a9b0 100644 --- a/clang/lib/Driver/ToolChains/Arch/X86.cpp +++ b/clang/lib/Driver/ToolChains/Arch/X86.cpp @@ -309,4 +309,6 @@ void x86::getX86TargetFeatures(const Driver , const llvm::Triple , Features.push_back("+prefer-no-gather"); if
[clang] 4cebe5a - [clang] NFC: add test for cwg2398 ambiguity issue
Author: Matheus Izvekov Date: 2024-05-20T22:49:53-03:00 New Revision: 4cebe5a43ba83eab477358ef4da665b43463bb68 URL: https://github.com/llvm/llvm-project/commit/4cebe5a43ba83eab477358ef4da665b43463bb68 DIFF: https://github.com/llvm/llvm-project/commit/4cebe5a43ba83eab477358ef4da665b43463bb68.diff LOG: [clang] NFC: add test for cwg2398 ambiguity issue Added: Modified: clang/test/SemaTemplate/cwg2398.cpp Removed: diff --git a/clang/test/SemaTemplate/cwg2398.cpp b/clang/test/SemaTemplate/cwg2398.cpp index 31686c4bc9805..e3b5e575374d3 100644 --- a/clang/test/SemaTemplate/cwg2398.cpp +++ b/clang/test/SemaTemplate/cwg2398.cpp @@ -59,6 +59,21 @@ namespace templ { template struct C>; } // namespace templ +namespace class_template { + template struct A; + + template struct B; + + template class TT1, class T5> struct B>; + // new-note@-1 {{partial specialization matches}} + + template struct B> {}; + // new-note@-1 {{partial specialization matches}} + + template struct B>; + // new-error@-1 {{ambiguous partial specialization}} +} // namespace class_template + namespace type_pack1 { template struct A; template class TT1, class T4> struct A> ; ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][Sema] Avoid pack expansion for expanded empty PackIndexingExprs (PR #92385)
https://github.com/zyn0217 closed https://github.com/llvm/llvm-project/pull/92385 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 8ce2045 - [Clang][Sema] Avoid pack expansion for expanded empty PackIndexingExprs (#92385)
Author: Younan Zhang Date: 2024-05-21T09:47:05+08:00 New Revision: 8ce2045be0ce708af0bfce5dc14632fa15dc743a URL: https://github.com/llvm/llvm-project/commit/8ce2045be0ce708af0bfce5dc14632fa15dc743a DIFF: https://github.com/llvm/llvm-project/commit/8ce2045be0ce708af0bfce5dc14632fa15dc743a.diff LOG: [Clang][Sema] Avoid pack expansion for expanded empty PackIndexingExprs (#92385) We previously doubled the id-expression expansion, even when the pack was expanded to empty. The previous condition for determining whether we should expand couldn't distinguish between cases where 'the expansion was previously postponed' and 'the expansion occurred but resulted in emptiness.' In the latter scenario, we crash because we have not been examining the current lambda's parent local instantiation scope since [D98068](https://reviews.llvm.org/D98068): Any Decls instantiated in the parent scope are not visible to the generic lambda, and thus any attempt of looking for instantiated Decls in the lambda is capped to the current Lambda's LIS. Fixes https://github.com/llvm/llvm-project/issues/92230 Added: Modified: clang/include/clang/AST/ExprCXX.h clang/lib/AST/ExprCXX.cpp clang/lib/Sema/SemaTemplateVariadic.cpp clang/lib/Sema/TreeTransform.h clang/lib/Serialization/ASTReaderStmt.cpp clang/lib/Serialization/ASTWriterStmt.cpp clang/test/PCH/pack_indexing.cpp clang/test/SemaCXX/cxx2c-pack-indexing.cpp Removed: diff --git a/clang/include/clang/AST/ExprCXX.h b/clang/include/clang/AST/ExprCXX.h index fac65628ffede..dbf693611a7fa 100644 --- a/clang/include/clang/AST/ExprCXX.h +++ b/clang/include/clang/AST/ExprCXX.h @@ -4377,15 +4377,21 @@ class PackIndexingExpr final // The pack being indexed, followed by the index Stmt *SubExprs[2]; - size_t TransformedExpressions; + // The size of the trailing expressions. + unsigned TransformedExpressions : 31; + + LLVM_PREFERRED_TYPE(bool) + unsigned ExpandedToEmptyPack : 1; PackIndexingExpr(QualType Type, SourceLocation EllipsisLoc, SourceLocation RSquareLoc, Expr *PackIdExpr, Expr *IndexExpr, - ArrayRef SubstitutedExprs = {}) + ArrayRef SubstitutedExprs = {}, + bool ExpandedToEmptyPack = false) : Expr(PackIndexingExprClass, Type, VK_LValue, OK_Ordinary), EllipsisLoc(EllipsisLoc), RSquareLoc(RSquareLoc), SubExprs{PackIdExpr, IndexExpr}, -TransformedExpressions(SubstitutedExprs.size()) { +TransformedExpressions(SubstitutedExprs.size()), +ExpandedToEmptyPack(ExpandedToEmptyPack) { auto *Exprs = getTrailingObjects(); std::uninitialized_copy(SubstitutedExprs.begin(), SubstitutedExprs.end(), @@ -4408,10 +4414,14 @@ class PackIndexingExpr final SourceLocation EllipsisLoc, SourceLocation RSquareLoc, Expr *PackIdExpr, Expr *IndexExpr, std::optional Index, - ArrayRef SubstitutedExprs = {}); + ArrayRef SubstitutedExprs = {}, + bool ExpandedToEmptyPack = false); static PackIndexingExpr *CreateDeserialized(ASTContext , unsigned NumTransformedExprs); + /// Determine if the expression was expanded to empty. + bool expandsToEmptyPack() const { return ExpandedToEmptyPack; } + /// Determine the location of the 'sizeof' keyword. SourceLocation getEllipsisLoc() const { return EllipsisLoc; } @@ -4445,6 +4455,7 @@ class PackIndexingExpr final return getTrailingObjects()[*Index]; } + /// Return the trailing expressions, regardless of the expansion. ArrayRef getExpressions() const { return {getTrailingObjects(), TransformedExpressions}; } diff --git a/clang/lib/AST/ExprCXX.cpp b/clang/lib/AST/ExprCXX.cpp index 7e9343271ac3c..2abc0acbfde3b 100644 --- a/clang/lib/AST/ExprCXX.cpp +++ b/clang/lib/AST/ExprCXX.cpp @@ -1665,12 +1665,10 @@ NonTypeTemplateParmDecl *SubstNonTypeTemplateParmExpr::getParameter() const { getReplacedTemplateParameterList(getAssociatedDecl())->asArray()[Index]); } -PackIndexingExpr *PackIndexingExpr::Create(ASTContext , - SourceLocation EllipsisLoc, - SourceLocation RSquareLoc, - Expr *PackIdExpr, Expr *IndexExpr, - std::optional Index, - ArrayRef SubstitutedExprs) { +PackIndexingExpr *PackIndexingExpr::Create( +ASTContext , SourceLocation EllipsisLoc, SourceLocation RSquareLoc, +Expr *PackIdExpr, Expr *IndexExpr, std::optional Index, +ArrayRef SubstitutedExprs, bool ExpandedToEmptyPack) {
[libcxxabi] [libunwind] [WebAssembly] __USING_WASM_EXCEPTIONS__ -> __WASM_EXCEPTIONS__ (PR #92840)
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 00179e92c147e16de1f7c653f88c8805aef820c1 e04e685a8fbf3e7915a9eaff3798fe77d15aab0c -- libcxxabi/include/cxxabi.h libcxxabi/src/cxa_exception.cpp libcxxabi/src/cxa_exception.h libcxxabi/src/cxa_personality.cpp libunwind/src/Unwind-wasm.c libunwind/src/libunwind.cpp `` View the diff from clang-format here. ``diff diff --git a/libcxxabi/include/cxxabi.h b/libcxxabi/include/cxxabi.h index 9d9beecf75..58e240cdf3 100644 --- a/libcxxabi/include/cxxabi.h +++ b/libcxxabi/include/cxxabi.h @@ -51,14 +51,13 @@ extern _LIBCXXABI_FUNC_VIS __cxa_exception* __cxa_init_primary_exception(void* object, std::type_info* tinfo, void(_LIBCXXABI_DTOR_FUNC* dest)(void*)) throw(); // 2.4.3 Throwing the Exception Object -extern _LIBCXXABI_FUNC_VIS _LIBCXXABI_NORETURN void -__cxa_throw(void *thrown_exception, std::type_info *tinfo, -#ifdef __WASM_EXCEPTIONS__ -// In Wasm, a destructor returns its argument -void *(_LIBCXXABI_DTOR_FUNC *dest)(void *)); -#else +extern _LIBCXXABI_FUNC_VIS _LIBCXXABI_NORETURN void __cxa_throw(void* thrown_exception, std::type_info* tinfo, +# ifdef __WASM_EXCEPTIONS__ +// In Wasm, a destructor returns its argument + void*(_LIBCXXABI_DTOR_FUNC* dest)(void*)); +# else void (_LIBCXXABI_DTOR_FUNC *dest)(void *)); -#endif +# endif // 2.5.3 Exception Handlers extern _LIBCXXABI_FUNC_VIS void * diff --git a/libcxxabi/src/cxa_exception.cpp b/libcxxabi/src/cxa_exception.cpp index 3141d50a6b..3889fef1d6 100644 --- a/libcxxabi/src/cxa_exception.cpp +++ b/libcxxabi/src/cxa_exception.cpp @@ -269,7 +269,7 @@ exception. void #ifdef __WASM_EXCEPTIONS__ // In Wasm, a destructor returns its argument -__cxa_throw(void *thrown_object, std::type_info *tinfo, void *(_LIBCXXABI_DTOR_FUNC *dest)(void *)) { +__cxa_throw(void* thrown_object, std::type_info* tinfo, void*(_LIBCXXABI_DTOR_FUNC* dest)(void*)) { #else __cxa_throw(void *thrown_object, std::type_info *tinfo, void (_LIBCXXABI_DTOR_FUNC *dest)(void *)) { #endif diff --git a/libcxxabi/src/cxa_personality.cpp b/libcxxabi/src/cxa_personality.cpp index 843a18a4cb..eb18932ef0 100644 --- a/libcxxabi/src/cxa_personality.cpp +++ b/libcxxabi/src/cxa_personality.cpp @@ -548,7 +548,7 @@ set_registers(_Unwind_Exception* unwind_exception, _Unwind_Context* context, const scan_results& results) { #if defined(__USING_SJLJ_EXCEPTIONS__) || defined(__WASM_EXCEPTIONS__) -#define __builtin_eh_return_data_regno(regno) regno +# define __builtin_eh_return_data_regno(regno) regno #elif defined(__ibmxl__) // IBM xlclang++ compiler does not support __builtin_eh_return_data_regno. #define __builtin_eh_return_data_regno(regno) regno + 3 @@ -694,157 +694,133 @@ static void scan_eh_tab(scan_results , _Unwind_Action actions, uintptr_t landingPad = readEncodedPointer(, callSiteEncoding); uintptr_t actionEntry = readULEB128(); if ((start <= ipOffset) && (ipOffset < (start + length))) -#else // __USING_SJLJ_EXCEPTIONS__ || __WASM_EXCEPTIONS__ -// ip is 1-based index into this table +#else // __USING_SJLJ_EXCEPTIONS__ || __WASM_EXCEPTIONS__ \ + // ip is 1-based index into this table uintptr_t landingPad = readULEB128(); uintptr_t actionEntry = readULEB128(); if (--ip == 0) #endif // __USING_SJLJ_EXCEPTIONS__ || __WASM_EXCEPTIONS__ { -// Found the call site containing ip. + // Found the call site containing ip. #if !defined(__USING_SJLJ_EXCEPTIONS__) && !defined(__WASM_EXCEPTIONS__) -if (landingPad == 0) -{ -// No handler here -results.reason = _URC_CONTINUE_UNWIND; -return; -} -landingPad = (uintptr_t)lpStart + landingPad; + if (landingPad == 0) { +// No handler here +results.reason = _URC_CONTINUE_UNWIND; +return; + } + landingPad = (uintptr_t)lpStart + landingPad; #else // __USING_SJLJ_EXCEPTIONS__ || __WASM_EXCEPTIONS__ -++landingPad; + ++landingPad; #endif // __USING_SJLJ_EXCEPTIONS__ || __WASM_EXCEPTIONS__ -results.landingPad = landingPad; -if (actionEntry == 0) -{ -// Found a cleanup -results.reason = (actions & _UA_SEARCH_PHASE) ? _URC_CONTINUE_UNWIND : _URC_HANDLER_FOUND; + results.landingPad = landingPad; + if (actionEntry == 0) { +// Found a cleanup +results.reason = (actions & _UA_SEARCH_PHASE) ?
[clang] [llvm] [mlir] Use StringRef::find_first_of(char), etc (NFC) (PR #92841)
llvmbot wrote: @llvm/pr-subscribers-llvm-support Author: Kazu Hirata (kazutakahirata) Changes --- Full diff: https://github.com/llvm/llvm-project/pull/92841.diff 4 Files Affected: - (modified) clang/utils/TableGen/ClangDiagnosticsEmitter.cpp (+1-1) - (modified) llvm/lib/Support/LockFileManager.cpp (+1-1) - (modified) llvm/tools/llvm-rtdyld/llvm-rtdyld.cpp (+2-2) - (modified) mlir/lib/Tools/mlir-lsp-server/MLIRServer.cpp (+1-1) ``diff diff --git a/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp b/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp index 4512acfd19a1b..f564689fff7cf 100644 --- a/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp +++ b/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp @@ -1086,7 +1086,7 @@ Piece *DiagnosticTextBuilder::DiagText::parseDiagText(StringRef , PluralPiece *Plural = New(); do { Text = Text.drop_front(); // '{' or '|' -size_t End = Text.find_first_of(":"); +size_t End = Text.find_first_of(':'); if (End == StringRef::npos) Builder.PrintFatalError("expected ':' while parsing %plural"); ++End; diff --git a/llvm/lib/Support/LockFileManager.cpp b/llvm/lib/Support/LockFileManager.cpp index 083f8d7b37be3..3169aa25ec0d9 100644 --- a/llvm/lib/Support/LockFileManager.cpp +++ b/llvm/lib/Support/LockFileManager.cpp @@ -66,7 +66,7 @@ LockFileManager::readLockFile(StringRef LockFileName) { StringRef Hostname; StringRef PIDStr; std::tie(Hostname, PIDStr) = getToken(MB.getBuffer(), " "); - PIDStr = PIDStr.substr(PIDStr.find_first_not_of(" ")); + PIDStr = PIDStr.substr(PIDStr.find_first_not_of(' ')); int PID; if (!PIDStr.getAsInteger(10, PID)) { auto Owner = std::make_pair(std::string(Hostname), PID); diff --git a/llvm/tools/llvm-rtdyld/llvm-rtdyld.cpp b/llvm/tools/llvm-rtdyld/llvm-rtdyld.cpp index 4cb76f4347422..06ac98b0c5e13 100644 --- a/llvm/tools/llvm-rtdyld/llvm-rtdyld.cpp +++ b/llvm/tools/llvm-rtdyld/llvm-rtdyld.cpp @@ -649,9 +649,9 @@ void applySpecificSectionMappings(RuntimeDyld , const FileToSectionIDMap ) { for (StringRef Mapping : SpecificSectionMappings) { -size_t EqualsIdx = Mapping.find_first_of("="); +size_t EqualsIdx = Mapping.find_first_of('='); std::string SectionIDStr = std::string(Mapping.substr(0, EqualsIdx)); -size_t ComaIdx = Mapping.find_first_of(","); +size_t ComaIdx = Mapping.find_first_of(','); if (ComaIdx == StringRef::npos) report_fatal_error("Invalid section specification '" + Mapping + diff --git a/mlir/lib/Tools/mlir-lsp-server/MLIRServer.cpp b/mlir/lib/Tools/mlir-lsp-server/MLIRServer.cpp index ed75b4a90536e..4e19274c3da40 100644 --- a/mlir/lib/Tools/mlir-lsp-server/MLIRServer.cpp +++ b/mlir/lib/Tools/mlir-lsp-server/MLIRServer.cpp @@ -917,7 +917,7 @@ void MLIRDocument::getCodeActionForDiagnostic( edit.range = lsp::Range(lsp::Position(pos.line, 0)); // Use the indent of the current line for the expected-* diagnostic. - size_t indent = line.find_first_not_of(" "); + size_t indent = line.find_first_not_of(' '); if (indent == StringRef::npos) indent = line.size(); `` https://github.com/llvm/llvm-project/pull/92841 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [mlir] Use StringRef::find_first_of(char), etc (NFC) (PR #92841)
llvmbot wrote: @llvm/pr-subscribers-mlir-core Author: Kazu Hirata (kazutakahirata) Changes --- Full diff: https://github.com/llvm/llvm-project/pull/92841.diff 4 Files Affected: - (modified) clang/utils/TableGen/ClangDiagnosticsEmitter.cpp (+1-1) - (modified) llvm/lib/Support/LockFileManager.cpp (+1-1) - (modified) llvm/tools/llvm-rtdyld/llvm-rtdyld.cpp (+2-2) - (modified) mlir/lib/Tools/mlir-lsp-server/MLIRServer.cpp (+1-1) ``diff diff --git a/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp b/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp index 4512acfd19a1b..f564689fff7cf 100644 --- a/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp +++ b/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp @@ -1086,7 +1086,7 @@ Piece *DiagnosticTextBuilder::DiagText::parseDiagText(StringRef , PluralPiece *Plural = New(); do { Text = Text.drop_front(); // '{' or '|' -size_t End = Text.find_first_of(":"); +size_t End = Text.find_first_of(':'); if (End == StringRef::npos) Builder.PrintFatalError("expected ':' while parsing %plural"); ++End; diff --git a/llvm/lib/Support/LockFileManager.cpp b/llvm/lib/Support/LockFileManager.cpp index 083f8d7b37be3..3169aa25ec0d9 100644 --- a/llvm/lib/Support/LockFileManager.cpp +++ b/llvm/lib/Support/LockFileManager.cpp @@ -66,7 +66,7 @@ LockFileManager::readLockFile(StringRef LockFileName) { StringRef Hostname; StringRef PIDStr; std::tie(Hostname, PIDStr) = getToken(MB.getBuffer(), " "); - PIDStr = PIDStr.substr(PIDStr.find_first_not_of(" ")); + PIDStr = PIDStr.substr(PIDStr.find_first_not_of(' ')); int PID; if (!PIDStr.getAsInteger(10, PID)) { auto Owner = std::make_pair(std::string(Hostname), PID); diff --git a/llvm/tools/llvm-rtdyld/llvm-rtdyld.cpp b/llvm/tools/llvm-rtdyld/llvm-rtdyld.cpp index 4cb76f4347422..06ac98b0c5e13 100644 --- a/llvm/tools/llvm-rtdyld/llvm-rtdyld.cpp +++ b/llvm/tools/llvm-rtdyld/llvm-rtdyld.cpp @@ -649,9 +649,9 @@ void applySpecificSectionMappings(RuntimeDyld , const FileToSectionIDMap ) { for (StringRef Mapping : SpecificSectionMappings) { -size_t EqualsIdx = Mapping.find_first_of("="); +size_t EqualsIdx = Mapping.find_first_of('='); std::string SectionIDStr = std::string(Mapping.substr(0, EqualsIdx)); -size_t ComaIdx = Mapping.find_first_of(","); +size_t ComaIdx = Mapping.find_first_of(','); if (ComaIdx == StringRef::npos) report_fatal_error("Invalid section specification '" + Mapping + diff --git a/mlir/lib/Tools/mlir-lsp-server/MLIRServer.cpp b/mlir/lib/Tools/mlir-lsp-server/MLIRServer.cpp index ed75b4a90536e..4e19274c3da40 100644 --- a/mlir/lib/Tools/mlir-lsp-server/MLIRServer.cpp +++ b/mlir/lib/Tools/mlir-lsp-server/MLIRServer.cpp @@ -917,7 +917,7 @@ void MLIRDocument::getCodeActionForDiagnostic( edit.range = lsp::Range(lsp::Position(pos.line, 0)); // Use the indent of the current line for the expected-* diagnostic. - size_t indent = line.find_first_not_of(" "); + size_t indent = line.find_first_not_of(' '); if (indent == StringRef::npos) indent = line.size(); `` https://github.com/llvm/llvm-project/pull/92841 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [mlir] Use StringRef::find_first_of(char), etc (NFC) (PR #92841)
https://github.com/kazutakahirata edited https://github.com/llvm/llvm-project/pull/92841 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [mlir] Use StringRef::find_first_of(char), etc (NFC) (PR #92841)
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/92841 etc (NFC), >From 4711f9f61fd35f3388f665a396f95951ee4b3f5b Mon Sep 17 00:00:00 2001 From: Kazu Hirata Date: Mon, 20 May 2024 09:10:04 -0700 Subject: [PATCH] Use StringRef::find_first_of(char), etc (NFC) --- clang/utils/TableGen/ClangDiagnosticsEmitter.cpp | 2 +- llvm/lib/Support/LockFileManager.cpp | 2 +- llvm/tools/llvm-rtdyld/llvm-rtdyld.cpp | 4 ++-- mlir/lib/Tools/mlir-lsp-server/MLIRServer.cpp| 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp b/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp index 4512acfd19a1b..f564689fff7cf 100644 --- a/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp +++ b/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp @@ -1086,7 +1086,7 @@ Piece *DiagnosticTextBuilder::DiagText::parseDiagText(StringRef , PluralPiece *Plural = New(); do { Text = Text.drop_front(); // '{' or '|' -size_t End = Text.find_first_of(":"); +size_t End = Text.find_first_of(':'); if (End == StringRef::npos) Builder.PrintFatalError("expected ':' while parsing %plural"); ++End; diff --git a/llvm/lib/Support/LockFileManager.cpp b/llvm/lib/Support/LockFileManager.cpp index 083f8d7b37be3..3169aa25ec0d9 100644 --- a/llvm/lib/Support/LockFileManager.cpp +++ b/llvm/lib/Support/LockFileManager.cpp @@ -66,7 +66,7 @@ LockFileManager::readLockFile(StringRef LockFileName) { StringRef Hostname; StringRef PIDStr; std::tie(Hostname, PIDStr) = getToken(MB.getBuffer(), " "); - PIDStr = PIDStr.substr(PIDStr.find_first_not_of(" ")); + PIDStr = PIDStr.substr(PIDStr.find_first_not_of(' ')); int PID; if (!PIDStr.getAsInteger(10, PID)) { auto Owner = std::make_pair(std::string(Hostname), PID); diff --git a/llvm/tools/llvm-rtdyld/llvm-rtdyld.cpp b/llvm/tools/llvm-rtdyld/llvm-rtdyld.cpp index 4cb76f4347422..06ac98b0c5e13 100644 --- a/llvm/tools/llvm-rtdyld/llvm-rtdyld.cpp +++ b/llvm/tools/llvm-rtdyld/llvm-rtdyld.cpp @@ -649,9 +649,9 @@ void applySpecificSectionMappings(RuntimeDyld , const FileToSectionIDMap ) { for (StringRef Mapping : SpecificSectionMappings) { -size_t EqualsIdx = Mapping.find_first_of("="); +size_t EqualsIdx = Mapping.find_first_of('='); std::string SectionIDStr = std::string(Mapping.substr(0, EqualsIdx)); -size_t ComaIdx = Mapping.find_first_of(","); +size_t ComaIdx = Mapping.find_first_of(','); if (ComaIdx == StringRef::npos) report_fatal_error("Invalid section specification '" + Mapping + diff --git a/mlir/lib/Tools/mlir-lsp-server/MLIRServer.cpp b/mlir/lib/Tools/mlir-lsp-server/MLIRServer.cpp index ed75b4a90536e..4e19274c3da40 100644 --- a/mlir/lib/Tools/mlir-lsp-server/MLIRServer.cpp +++ b/mlir/lib/Tools/mlir-lsp-server/MLIRServer.cpp @@ -917,7 +917,7 @@ void MLIRDocument::getCodeActionForDiagnostic( edit.range = lsp::Range(lsp::Position(pos.line, 0)); // Use the indent of the current line for the expected-* diagnostic. - size_t indent = line.find_first_not_of(" "); + size_t indent = line.find_first_not_of(' '); if (indent == StringRef::npos) indent = line.size(); ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libcxxabi] [libunwind] [WebAssembly] __USING_WASM_EXCEPTIONS__ -> __WASM_EXCEPTIONS__ (PR #92840)
llvmbot wrote: @llvm/pr-subscribers-libcxxabi Author: Heejin Ahn (aheejin) Changes We've decided to change `__USING_WASM_EXCEPTIONS__` preprocessor to `__WASM_EXCEPTIONS__` given that it's more concise. --- Full diff: https://github.com/llvm/llvm-project/pull/92840.diff 6 Files Affected: - (modified) libcxxabi/include/cxxabi.h (+1-1) - (modified) libcxxabi/src/cxa_exception.cpp (+1-1) - (modified) libcxxabi/src/cxa_exception.h (+1-1) - (modified) libcxxabi/src/cxa_personality.cpp (+18-18) - (modified) libunwind/src/Unwind-wasm.c (+2-2) - (modified) libunwind/src/libunwind.cpp (+2-2) ``diff diff --git a/libcxxabi/include/cxxabi.h b/libcxxabi/include/cxxabi.h index d0701181751c5..9d9beecf751fc 100644 --- a/libcxxabi/include/cxxabi.h +++ b/libcxxabi/include/cxxabi.h @@ -53,7 +53,7 @@ __cxa_init_primary_exception(void* object, std::type_info* tinfo, void(_LIBCXXAB // 2.4.3 Throwing the Exception Object extern _LIBCXXABI_FUNC_VIS _LIBCXXABI_NORETURN void __cxa_throw(void *thrown_exception, std::type_info *tinfo, -#ifdef __USING_WASM_EXCEPTIONS__ +#ifdef __WASM_EXCEPTIONS__ // In Wasm, a destructor returns its argument void *(_LIBCXXABI_DTOR_FUNC *dest)(void *)); #else diff --git a/libcxxabi/src/cxa_exception.cpp b/libcxxabi/src/cxa_exception.cpp index 65e9f4504ddad..3141d50a6bb92 100644 --- a/libcxxabi/src/cxa_exception.cpp +++ b/libcxxabi/src/cxa_exception.cpp @@ -267,7 +267,7 @@ will call terminate, assuming that there was no handler for the exception. */ void -#ifdef __USING_WASM_EXCEPTIONS__ +#ifdef __WASM_EXCEPTIONS__ // In Wasm, a destructor returns its argument __cxa_throw(void *thrown_object, std::type_info *tinfo, void *(_LIBCXXABI_DTOR_FUNC *dest)(void *)) { #else diff --git a/libcxxabi/src/cxa_exception.h b/libcxxabi/src/cxa_exception.h index 10712f6f47bb5..7800b940b83f7 100644 --- a/libcxxabi/src/cxa_exception.h +++ b/libcxxabi/src/cxa_exception.h @@ -43,7 +43,7 @@ struct _LIBCXXABI_HIDDEN __cxa_exception { // Manage the exception object itself. std::type_info *exceptionType; -#ifdef __USING_WASM_EXCEPTIONS__ +#ifdef __WASM_EXCEPTIONS__ // In Wasm, a destructor returns its argument void *(_LIBCXXABI_DTOR_FUNC *exceptionDestructor)(void *); #else diff --git a/libcxxabi/src/cxa_personality.cpp b/libcxxabi/src/cxa_personality.cpp index d95d781319401..843a18a4cbd8a 100644 --- a/libcxxabi/src/cxa_personality.cpp +++ b/libcxxabi/src/cxa_personality.cpp @@ -70,7 +70,7 @@ extern "C" EXCEPTION_DISPOSITION _GCC_specific_handler(PEXCEPTION_RECORD, +--+--+-+-++--+ | callSiteTableLength | (ULEB128) | Call Site Table length, used to find Action table | +-+---+---+ -#if !defined(__USING_SJLJ_EXCEPTIONS__) && !defined(__USING_WASM_EXCEPTIONS__) +#if !defined(__USING_SJLJ_EXCEPTIONS__) && !defined(__WASM_EXCEPTIONS__) +-+---++ | Beginning of Call Site TableThe current ip lies within the | | ... (start, length) range of one of these| @@ -84,7 +84,7 @@ extern "C" EXCEPTION_DISPOSITION _GCC_specific_handler(PEXCEPTION_RECORD, | +-+-+--+ | | ... | +--+ -#else // __USING_SJLJ_EXCEPTIONS__ || __USING_WASM_EXCEPTIONS__ +#else // __USING_SJLJ_EXCEPTIONS__ || __WASM_EXCEPTIONS__ +-+---++ | Beginning of Call Site TableThe current ip is a 1-based index into | | ... this table. Or it is -1 meaning no | @@ -97,7 +97,7 @@ extern "C" EXCEPTION_DISPOSITION _GCC_specific_handler(PEXCEPTION_RECORD, | +-+-+--+ | | ... | +--+ -#endif // __USING_SJLJ_EXCEPTIONS__ || __USING_WASM_EXCEPTIONS__ +#endif // __USING_SJLJ_EXCEPTIONS__ || __WASM_EXCEPTIONS__ +-+ | Beginning of Action Table ttypeIndex == 0 : cleanup | | ... ttypeIndex > 0 : catch | @@ -547,7 +547,7 @@ void set_registers(_Unwind_Exception* unwind_exception, _Unwind_Context* context, const scan_results& results) { -#if defined(__USING_SJLJ_EXCEPTIONS__) || defined(__USING_WASM_EXCEPTIONS__) +#if defined(__USING_SJLJ_EXCEPTIONS__) ||
[libcxxabi] [libunwind] [WebAssembly] __USING_WASM_EXCEPTIONS__ -> __WASM_EXCEPTIONS__ (PR #92840)
https://github.com/aheejin created https://github.com/llvm/llvm-project/pull/92840 We've decided to change `__USING_WASM_EXCEPTIONS__` preprocessor to `__WASM_EXCEPTIONS__` given that it's more concise. >From e04e685a8fbf3e7915a9eaff3798fe77d15aab0c Mon Sep 17 00:00:00 2001 From: Heejin Ahn Date: Sat, 18 May 2024 01:55:29 + Subject: [PATCH] [WebAssembly] __USING_WASM_EXCEPTIONS__ -> __WASM_EXCEPTIONS__ We've decided to change `__USING_WASM_EXCEPTIONS__` preprocessor to `__WASM_EXCEPTIONS__` given that it's more concise. --- libcxxabi/include/cxxabi.h| 2 +- libcxxabi/src/cxa_exception.cpp | 2 +- libcxxabi/src/cxa_exception.h | 2 +- libcxxabi/src/cxa_personality.cpp | 36 +++ libunwind/src/Unwind-wasm.c | 4 ++-- libunwind/src/libunwind.cpp | 4 ++-- 6 files changed, 25 insertions(+), 25 deletions(-) diff --git a/libcxxabi/include/cxxabi.h b/libcxxabi/include/cxxabi.h index d0701181751c5..9d9beecf751fc 100644 --- a/libcxxabi/include/cxxabi.h +++ b/libcxxabi/include/cxxabi.h @@ -53,7 +53,7 @@ __cxa_init_primary_exception(void* object, std::type_info* tinfo, void(_LIBCXXAB // 2.4.3 Throwing the Exception Object extern _LIBCXXABI_FUNC_VIS _LIBCXXABI_NORETURN void __cxa_throw(void *thrown_exception, std::type_info *tinfo, -#ifdef __USING_WASM_EXCEPTIONS__ +#ifdef __WASM_EXCEPTIONS__ // In Wasm, a destructor returns its argument void *(_LIBCXXABI_DTOR_FUNC *dest)(void *)); #else diff --git a/libcxxabi/src/cxa_exception.cpp b/libcxxabi/src/cxa_exception.cpp index 65e9f4504ddad..3141d50a6bb92 100644 --- a/libcxxabi/src/cxa_exception.cpp +++ b/libcxxabi/src/cxa_exception.cpp @@ -267,7 +267,7 @@ will call terminate, assuming that there was no handler for the exception. */ void -#ifdef __USING_WASM_EXCEPTIONS__ +#ifdef __WASM_EXCEPTIONS__ // In Wasm, a destructor returns its argument __cxa_throw(void *thrown_object, std::type_info *tinfo, void *(_LIBCXXABI_DTOR_FUNC *dest)(void *)) { #else diff --git a/libcxxabi/src/cxa_exception.h b/libcxxabi/src/cxa_exception.h index 10712f6f47bb5..7800b940b83f7 100644 --- a/libcxxabi/src/cxa_exception.h +++ b/libcxxabi/src/cxa_exception.h @@ -43,7 +43,7 @@ struct _LIBCXXABI_HIDDEN __cxa_exception { // Manage the exception object itself. std::type_info *exceptionType; -#ifdef __USING_WASM_EXCEPTIONS__ +#ifdef __WASM_EXCEPTIONS__ // In Wasm, a destructor returns its argument void *(_LIBCXXABI_DTOR_FUNC *exceptionDestructor)(void *); #else diff --git a/libcxxabi/src/cxa_personality.cpp b/libcxxabi/src/cxa_personality.cpp index d95d781319401..843a18a4cbd8a 100644 --- a/libcxxabi/src/cxa_personality.cpp +++ b/libcxxabi/src/cxa_personality.cpp @@ -70,7 +70,7 @@ extern "C" EXCEPTION_DISPOSITION _GCC_specific_handler(PEXCEPTION_RECORD, +--+--+-+-++--+ | callSiteTableLength | (ULEB128) | Call Site Table length, used to find Action table | +-+---+---+ -#if !defined(__USING_SJLJ_EXCEPTIONS__) && !defined(__USING_WASM_EXCEPTIONS__) +#if !defined(__USING_SJLJ_EXCEPTIONS__) && !defined(__WASM_EXCEPTIONS__) +-+---++ | Beginning of Call Site TableThe current ip lies within the | | ... (start, length) range of one of these| @@ -84,7 +84,7 @@ extern "C" EXCEPTION_DISPOSITION _GCC_specific_handler(PEXCEPTION_RECORD, | +-+-+--+ | | ... | +--+ -#else // __USING_SJLJ_EXCEPTIONS__ || __USING_WASM_EXCEPTIONS__ +#else // __USING_SJLJ_EXCEPTIONS__ || __WASM_EXCEPTIONS__ +-+---++ | Beginning of Call Site TableThe current ip is a 1-based index into | | ... this table. Or it is -1 meaning no | @@ -97,7 +97,7 @@ extern "C" EXCEPTION_DISPOSITION _GCC_specific_handler(PEXCEPTION_RECORD, | +-+-+--+ | | ... | +--+ -#endif // __USING_SJLJ_EXCEPTIONS__ || __USING_WASM_EXCEPTIONS__ +#endif // __USING_SJLJ_EXCEPTIONS__ || __WASM_EXCEPTIONS__ +-+ | Beginning of Action Table ttypeIndex == 0 : cleanup | | ... ttypeIndex > 0 : catch | @@ -547,7 +547,7 @@ void
[clang] [WebAssembly] Define __WASM_EXCEPTIONS__ for -fwasm-exceptions (PR #92604)
https://github.com/aheejin closed https://github.com/llvm/llvm-project/pull/92604 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] d1aca0a - [WebAssembly] Define __WASM_EXCEPTIONS__ for -fwasm-exceptions (#92604)
Author: Heejin Ahn Date: 2024-05-20T18:43:13-07:00 New Revision: d1aca0ae2e0c52298966e35e4312e21045d4c6e4 URL: https://github.com/llvm/llvm-project/commit/d1aca0ae2e0c52298966e35e4312e21045d4c6e4 DIFF: https://github.com/llvm/llvm-project/commit/d1aca0ae2e0c52298966e35e4312e21045d4c6e4.diff LOG: [WebAssembly] Define __WASM_EXCEPTIONS__ for -fwasm-exceptions (#92604) When using other specific exception options in Clang, such as `-fseh-exceptions` or `-fsjlj-exceptions`, Clang defines a corresponding preprocessor such as `-D__USING_SJLJ_EXCEPTIONS__`. Emscripten does that in our own build system: https://github.com/emscripten-core/emscripten/blob/7dcd7f40749918e141dc33397d2f4311dd80637a/tools/system_libs.py#L1577-L1578 But to make Wasm EH usable in non-Emscripten toolchain, this has to be defined somewhere else. This PR makes Wasm EH consistent with other exception scheme by letting it defined by Clang depending on the exception option. We have been using `__USING_WASM_EXCEPTIONS__` in our current library code, but this changes it to `__WASM_EXCEPTIONS__` for its conciseness, and I will update other parts of LLVM as follow-ups. This does not break anything currently working, because we have not been defining anything in Clang so far. Added: Modified: clang/lib/Frontend/InitPreprocessor.cpp clang/test/CodeGenCXX/wasm-eh.cpp Removed: diff --git a/clang/lib/Frontend/InitPreprocessor.cpp b/clang/lib/Frontend/InitPreprocessor.cpp index c1d209466ffe5..68760e3e0 100644 --- a/clang/lib/Frontend/InitPreprocessor.cpp +++ b/clang/lib/Frontend/InitPreprocessor.cpp @@ -1006,6 +1006,8 @@ static void InitializePredefinedMacros(const TargetInfo , else if (LangOpts.hasDWARFExceptions() && (TI.getTriple().isThumb() || TI.getTriple().isARM())) Builder.defineMacro("__ARM_DWARF_EH__"); + else if (LangOpts.hasWasmExceptions() && TI.getTriple().isWasm()) +Builder.defineMacro("__WASM_EXCEPTIONS__"); if (LangOpts.Deprecated) Builder.defineMacro("__DEPRECATED"); diff --git a/clang/test/CodeGenCXX/wasm-eh.cpp b/clang/test/CodeGenCXX/wasm-eh.cpp index 1b17498ba9ce9..9dc15633bfed9 100644 --- a/clang/test/CodeGenCXX/wasm-eh.cpp +++ b/clang/test/CodeGenCXX/wasm-eh.cpp @@ -1,4 +1,8 @@ // REQUIRES: webassembly-registered-target + +// RUN: %clang -E -dM %s -target wasm32-unknown-unknown -fwasm-exceptions | FileCheck %s -check-prefix PREPROCESSOR +// PREPROCESSOR: #define __WASM_EXCEPTIONS__ 1 + // RUN: %clang_cc1 %s -triple wasm32-unknown-unknown -fms-extensions -fexceptions -fcxx-exceptions -mllvm -wasm-enable-eh -exception-model=wasm -target-feature +exception-handling -emit-llvm -o - -std=c++11 | FileCheck %s // RUN: %clang_cc1 %s -triple wasm64-unknown-unknown -fms-extensions -fexceptions -fcxx-exceptions -mllvm -wasm-enable-eh -exception-model=wasm -target-feature +exception-handling -emit-llvm -o - -std=c++11 | FileCheck %s ___ 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 RADSan backend (PR #92460)
MaskRay wrote: https://discourse.llvm.org/t/rfc-nolock-and-noalloc-attributes/76837/75 contains a discussion about the subproject name. Do you have opinions? @llvm/pr-subscribers-sanitizer @compnerd @petrhosek @isanbard 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] [AArch64] Use ptrmask for vaarg stack alignment (PR #92836)
JonChesterfield wrote: Dropped the NFC tag from the commit message. The machine code is expected to be the same or negligibly better, this patch makes some tests more legible for a different patch. Thanks for the quick review! https://github.com/llvm/llvm-project/pull/92836 ___ 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] [libcxx] [libcxxabi] [lld] [lldb] [llvm] [mlir] [BOLT] Ignore special symbols as function aliases in updateELFSymbolTable (PR #92713)
https://github.com/aaupov closed https://github.com/llvm/llvm-project/pull/92713 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [AArch64] Use ptrmask for vaarg stack alignment (PR #92836)
https://github.com/JonChesterfield edited https://github.com/llvm/llvm-project/pull/92836 ___ 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] [libcxx] [libcxxabi] [lld] [lldb] [llvm] [mlir] [BOLT] Ignore special symbols as function aliases in updateELFSymbolTable (PR #92713)
https://github.com/aaupov edited https://github.com/llvm/llvm-project/pull/92713 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Offload] Do not pass `-fcf-protection=` for offloading (PR #88402)
@@ -0,0 +1,39 @@ +// Check that -fcf-protection does not get passed to the device-side MaskRay wrote: We also have unsupported-option-gpu.c to test various ignored options for GPU. https://github.com/llvm/llvm-project/pull/88402 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [AArch64][NFC] Use ptrmask for vaarg stack alignment (PR #92836)
https://github.com/efriedma-quic approved this pull request. Please don't use "NFC" markings for patches that change the emitted IR, even if it doesn't significantly impact the resulting assembly in most cases. That said, LGTM https://github.com/llvm/llvm-project/pull/92836 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [CodeGen][AArch64] Added -mno-va-float to skip FP save in variadic functions (PR #92827)
efriedma-quic wrote: This patch, as proposed, doesn't seem like a good idea: it's very likely to miscompile user code without any diagnostic. Are you sure you don't want one of the following? - A soft-float ABI (-mabi=aapcs-soft) - Completely forbidding the use of floating-point values (-mgeneral-regs-only). - An optimization that opportunistically skips saving float registers if we can prove it isn't necessary. (Not currently implemented, but not something you'd add a compiler option for; you'd just make it work automatically. I can write up an outline of how to implement this if you're interested.) https://github.com/llvm/llvm-project/pull/92827 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [webkit.RefCntblBaseVirtualDtor] Allow CRTP classes without a virtual destructor. (PR #92837)
llvmbot wrote: @llvm/pr-subscribers-clang-static-analyzer-1 Author: Ryosuke Niwa (rniwa) Changes Exempt CRTP (Curiously Recurring Template Pattern) classes with a delete operation acting on "this" pointer with an appropriate cast from the requirement that a ref-countable superclass must have a virtual destructor. To do this, this PR introduces new DerefAnalysisVisitor, which looks for a delete operation with an explicit cast to the derived class in a base class. This PR also changes the checker so that we only check a given class's immediate base class instead of all ancestor base classes in the class hierarchy. This is sufficient because the checker will eventually see the definition for every class in the class hierarchy and transitively proves every ref-counted base class has a virtual destructor or deref function which casts this pointer back to the derived class before deleting. Without this change, we would keep traversing the same list of base classes whenever we encounter a new subclass, which is wholly unnecessary. It's possible for DerefAnalysisVisitor to come to a conclusoin that there isn't enough information to determine whether a given templated superclass invokes delete operation on a subclass when the template isn't fully specialized for the subclass. In this case, we return std::nullopt in HasSpecializedDelete, and visitCXXRecordDecl will skip this declaration. This is okay because the checker will eventually see a concreate fully specialized class definition if it ever gets instantiated. --- Patch is 23.33 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/92837.diff 2 Files Affected: - (modified) clang/lib/StaticAnalyzer/Checkers/WebKit/RefCntblBaseVirtualDtorChecker.cpp (+246-61) - (modified) clang/test/Analysis/Checkers/WebKit/ref-cntbl-base-virtual-dtor-templates.cpp (+316-8) ``diff diff --git a/clang/lib/StaticAnalyzer/Checkers/WebKit/RefCntblBaseVirtualDtorChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/WebKit/RefCntblBaseVirtualDtorChecker.cpp index 7f4c3a7b787e8..cd339911fbf38 100644 --- a/clang/lib/StaticAnalyzer/Checkers/WebKit/RefCntblBaseVirtualDtorChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/WebKit/RefCntblBaseVirtualDtorChecker.cpp @@ -11,16 +11,134 @@ #include "PtrTypesSemantics.h" #include "clang/AST/CXXInheritance.h" #include "clang/AST/RecursiveASTVisitor.h" +#include "clang/AST/StmtVisitor.h" #include "clang/StaticAnalyzer/Checkers/BuiltinCheckerRegistration.h" #include "clang/StaticAnalyzer/Core/BugReporter/BugReporter.h" #include "clang/StaticAnalyzer/Core/BugReporter/BugType.h" #include "clang/StaticAnalyzer/Core/Checker.h" +#include "llvm/ADT/DenseSet.h" +#include "llvm/ADT/SetVector.h" #include using namespace clang; using namespace ento; namespace { + +class DerefAnalysisVisitor +: public ConstStmtVisitor { + // Returns true if any of child statements return true. + bool VisitChildren(const Stmt *S) { +for (const Stmt *Child : S->children()) { + if (Child && Visit(Child)) +return true; +} +return false; + } + + bool VisitBody(const Stmt *Body) { +if (!Body) + return false; + +auto [It, IsNew] = VisitedBody.insert(Body); +if (!IsNew) // This body is recursive + return false; + +return Visit(Body); + } + +public: + DerefAnalysisVisitor(const TemplateArgumentList , + const CXXRecordDecl *ClassDecl) + : ArgList(), ClassDecl(ClassDecl) {} + + DerefAnalysisVisitor(const CXXRecordDecl *ClassDecl) : ClassDecl(ClassDecl) {} + + std::optional HasSpecializedDelete(CXXMethodDecl *Decl) { +if (auto *Body = Decl->getBody()) + return VisitBody(Body); +if (auto *Tmpl = Decl->getTemplateInstantiationPattern()) + return std::nullopt; // Indeterminate. There was no concrete instance. +return false; + } + + bool VisitCallExpr(const CallExpr *CE) { +auto *Callee = CE->getCallee(); +while (auto *Expr = dyn_cast(Callee)) + Callee = Expr->getSubExpr(); +if (auto *DeclRef = dyn_cast(Callee)) { + auto *Decl = DeclRef->getDecl(); + if (auto *VD = dyn_cast(Decl)) { +if (auto *Init = VD->getInit()) { + if (auto *Lambda = dyn_cast(Init)) +return VisitBody(Lambda->getBody()); +} + } else if (auto *FD = dyn_cast(Decl)) +return VisitBody(FD->getBody()); +} +return false; + } + + bool VisitCXXMemberCallExpr(const CXXMemberCallExpr *MCE) { +auto *Callee = MCE->getMethodDecl(); +if (!Callee) + return false; +return VisitBody(Callee->getBody()); + } + + bool VisitCXXDeleteExpr(const CXXDeleteExpr *E) { +auto *Arg = E->getArgument(); +while (Arg) { + if (auto *Paren = dyn_cast(Arg)) +Arg = Paren->getSubExpr(); + else if (auto *Cast = dyn_cast(Arg)) { +Arg = Cast->getSubExpr(); +auto CastType = Cast->getType(); +if (auto
[clang] [webkit.RefCntblBaseVirtualDtor] Allow CRTP classes without a virtual destructor. (PR #92837)
llvmbot wrote: @llvm/pr-subscribers-clang Author: Ryosuke Niwa (rniwa) Changes Exempt CRTP (Curiously Recurring Template Pattern) classes with a delete operation acting on "this" pointer with an appropriate cast from the requirement that a ref-countable superclass must have a virtual destructor. To do this, this PR introduces new DerefAnalysisVisitor, which looks for a delete operation with an explicit cast to the derived class in a base class. This PR also changes the checker so that we only check a given class's immediate base class instead of all ancestor base classes in the class hierarchy. This is sufficient because the checker will eventually see the definition for every class in the class hierarchy and transitively proves every ref-counted base class has a virtual destructor or deref function which casts this pointer back to the derived class before deleting. Without this change, we would keep traversing the same list of base classes whenever we encounter a new subclass, which is wholly unnecessary. It's possible for DerefAnalysisVisitor to come to a conclusoin that there isn't enough information to determine whether a given templated superclass invokes delete operation on a subclass when the template isn't fully specialized for the subclass. In this case, we return std::nullopt in HasSpecializedDelete, and visitCXXRecordDecl will skip this declaration. This is okay because the checker will eventually see a concreate fully specialized class definition if it ever gets instantiated. --- Patch is 23.33 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/92837.diff 2 Files Affected: - (modified) clang/lib/StaticAnalyzer/Checkers/WebKit/RefCntblBaseVirtualDtorChecker.cpp (+246-61) - (modified) clang/test/Analysis/Checkers/WebKit/ref-cntbl-base-virtual-dtor-templates.cpp (+316-8) ``diff diff --git a/clang/lib/StaticAnalyzer/Checkers/WebKit/RefCntblBaseVirtualDtorChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/WebKit/RefCntblBaseVirtualDtorChecker.cpp index 7f4c3a7b787e8..cd339911fbf38 100644 --- a/clang/lib/StaticAnalyzer/Checkers/WebKit/RefCntblBaseVirtualDtorChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/WebKit/RefCntblBaseVirtualDtorChecker.cpp @@ -11,16 +11,134 @@ #include "PtrTypesSemantics.h" #include "clang/AST/CXXInheritance.h" #include "clang/AST/RecursiveASTVisitor.h" +#include "clang/AST/StmtVisitor.h" #include "clang/StaticAnalyzer/Checkers/BuiltinCheckerRegistration.h" #include "clang/StaticAnalyzer/Core/BugReporter/BugReporter.h" #include "clang/StaticAnalyzer/Core/BugReporter/BugType.h" #include "clang/StaticAnalyzer/Core/Checker.h" +#include "llvm/ADT/DenseSet.h" +#include "llvm/ADT/SetVector.h" #include using namespace clang; using namespace ento; namespace { + +class DerefAnalysisVisitor +: public ConstStmtVisitor { + // Returns true if any of child statements return true. + bool VisitChildren(const Stmt *S) { +for (const Stmt *Child : S->children()) { + if (Child && Visit(Child)) +return true; +} +return false; + } + + bool VisitBody(const Stmt *Body) { +if (!Body) + return false; + +auto [It, IsNew] = VisitedBody.insert(Body); +if (!IsNew) // This body is recursive + return false; + +return Visit(Body); + } + +public: + DerefAnalysisVisitor(const TemplateArgumentList , + const CXXRecordDecl *ClassDecl) + : ArgList(), ClassDecl(ClassDecl) {} + + DerefAnalysisVisitor(const CXXRecordDecl *ClassDecl) : ClassDecl(ClassDecl) {} + + std::optional HasSpecializedDelete(CXXMethodDecl *Decl) { +if (auto *Body = Decl->getBody()) + return VisitBody(Body); +if (auto *Tmpl = Decl->getTemplateInstantiationPattern()) + return std::nullopt; // Indeterminate. There was no concrete instance. +return false; + } + + bool VisitCallExpr(const CallExpr *CE) { +auto *Callee = CE->getCallee(); +while (auto *Expr = dyn_cast(Callee)) + Callee = Expr->getSubExpr(); +if (auto *DeclRef = dyn_cast(Callee)) { + auto *Decl = DeclRef->getDecl(); + if (auto *VD = dyn_cast(Decl)) { +if (auto *Init = VD->getInit()) { + if (auto *Lambda = dyn_cast(Init)) +return VisitBody(Lambda->getBody()); +} + } else if (auto *FD = dyn_cast(Decl)) +return VisitBody(FD->getBody()); +} +return false; + } + + bool VisitCXXMemberCallExpr(const CXXMemberCallExpr *MCE) { +auto *Callee = MCE->getMethodDecl(); +if (!Callee) + return false; +return VisitBody(Callee->getBody()); + } + + bool VisitCXXDeleteExpr(const CXXDeleteExpr *E) { +auto *Arg = E->getArgument(); +while (Arg) { + if (auto *Paren = dyn_cast(Arg)) +Arg = Paren->getSubExpr(); + else if (auto *Cast = dyn_cast(Arg)) { +Arg = Cast->getSubExpr(); +auto CastType = Cast->getType(); +if (auto *PtrType =
[clang] [webkit.RefCntblBaseVirtualDtor] Ignore a base class which has a specialized deref function for a given derived class. (PR #92501)
rniwa wrote: Closing this PR in favor of https://github.com/llvm/llvm-project/pull/92837, which has a single consolidated commit. https://github.com/llvm/llvm-project/pull/92501 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [webkit.RefCntblBaseVirtualDtor] Ignore a base class which has a specialized deref function for a given derived class. (PR #92501)
https://github.com/rniwa closed https://github.com/llvm/llvm-project/pull/92501 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [webkit.RefCntblBaseVirtualDtor] Allow CRTP classes without a virtual destructor. (PR #92837)
https://github.com/rniwa created https://github.com/llvm/llvm-project/pull/92837 Exempt CRTP (Curiously Recurring Template Pattern) classes with a delete operation acting on "this" pointer with an appropriate cast from the requirement that a ref-countable superclass must have a virtual destructor. To do this, this PR introduces new DerefAnalysisVisitor, which looks for a delete operation with an explicit cast to the derived class in a base class. This PR also changes the checker so that we only check a given class's immediate base class instead of all ancestor base classes in the class hierarchy. This is sufficient because the checker will eventually see the definition for every class in the class hierarchy and transitively proves every ref-counted base class has a virtual destructor or deref function which casts this pointer back to the derived class before deleting. Without this change, we would keep traversing the same list of base classes whenever we encounter a new subclass, which is wholly unnecessary. It's possible for DerefAnalysisVisitor to come to a conclusoin that there isn't enough information to determine whether a given templated superclass invokes delete operation on a subclass when the template isn't fully specialized for the subclass. In this case, we return std::nullopt in HasSpecializedDelete, and visitCXXRecordDecl will skip this declaration. This is okay because the checker will eventually see a concreate fully specialized class definition if it ever gets instantiated. >From 6061b5e40b5a2ebf73c5ea29f781c910e147ef1f Mon Sep 17 00:00:00 2001 From: Ryosuke Niwa Date: Mon, 20 May 2024 16:12:44 -0700 Subject: [PATCH] [webkit.RefCntblBaseVirtualDtor] Allow CRTP classes without a virtual destructor. Exempt CRTP (Curiously Recurring Template Pattern) classes with a delete operation acting on "this" pointer with an appropriate cast from the requirement that a ref-countable superclass must have a virtual destructor. To do this, this PR introduces new DerefAnalysisVisitor, which looks for a delete operation with an explicit cast to the derived class in a base class. This PR also changes the checker so that we only check a given class's immediate base class instead of all ancestor base classes in the class hierarchy. This is sufficient because the checker will eventually see the definition for every class in the class hierarchy and transitively proves every ref-counted base class has a virtual destructor or deref function which casts this pointer back to the derived class before deleting. Without this change, we would keep traversing the same list of base classes whenever we encounter a new subclass, which is wholly unnecessary. It's possible for DerefAnalysisVisitor to come to a conclusoin that there isn't enough information to determine whether a given templated superclass invokes delete operation on a subclass when the template isn't fully specialized for the subclass. In this case, we return std::nullopt in HasSpecializedDelete, and visitCXXRecordDecl will skip this declaration. This is okay because the checker will eventually see a concreate fully specialized class definition if it ever gets instantiated. --- .../WebKit/RefCntblBaseVirtualDtorChecker.cpp | 307 + .../ref-cntbl-base-virtual-dtor-templates.cpp | 324 +- 2 files changed, 562 insertions(+), 69 deletions(-) diff --git a/clang/lib/StaticAnalyzer/Checkers/WebKit/RefCntblBaseVirtualDtorChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/WebKit/RefCntblBaseVirtualDtorChecker.cpp index 7f4c3a7b787e8..cd339911fbf38 100644 --- a/clang/lib/StaticAnalyzer/Checkers/WebKit/RefCntblBaseVirtualDtorChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/WebKit/RefCntblBaseVirtualDtorChecker.cpp @@ -11,16 +11,134 @@ #include "PtrTypesSemantics.h" #include "clang/AST/CXXInheritance.h" #include "clang/AST/RecursiveASTVisitor.h" +#include "clang/AST/StmtVisitor.h" #include "clang/StaticAnalyzer/Checkers/BuiltinCheckerRegistration.h" #include "clang/StaticAnalyzer/Core/BugReporter/BugReporter.h" #include "clang/StaticAnalyzer/Core/BugReporter/BugType.h" #include "clang/StaticAnalyzer/Core/Checker.h" +#include "llvm/ADT/DenseSet.h" +#include "llvm/ADT/SetVector.h" #include using namespace clang; using namespace ento; namespace { + +class DerefAnalysisVisitor +: public ConstStmtVisitor { + // Returns true if any of child statements return true. + bool VisitChildren(const Stmt *S) { +for (const Stmt *Child : S->children()) { + if (Child && Visit(Child)) +return true; +} +return false; + } + + bool VisitBody(const Stmt *Body) { +if (!Body) + return false; + +auto [It, IsNew] = VisitedBody.insert(Body); +if (!IsNew) // This body is recursive + return false; + +return Visit(Body); + } + +public: + DerefAnalysisVisitor(const TemplateArgumentList , + const CXXRecordDecl *ClassDecl) + :
[clang] [lld] [llvm] Run ObjCContractPass in Distributed Thin-LTO Pipeline (PR #92331)
https://github.com/NuriAmari updated https://github.com/llvm/llvm-project/pull/92331 >From 66ddf609c0e77867ec48c17136fb80d1e482041d Mon Sep 17 00:00:00 2001 From: Nuri Amari Date: Wed, 15 May 2024 16:33:03 -0700 Subject: [PATCH 1/5] Run ObjCContractPass in Distributed Thin-LTO Pipeline Prior to this patch, when using -fthinlto-index= the ObjCARCContractPass isn't run prior to CodeGen, and instruction selection fails on IR containing arc intrinstics. --- clang/lib/CodeGen/BackendUtil.cpp | 3 +++ .../thinlto-distributed-objc-contract-pass.ll | 19 +++ 2 files changed, 22 insertions(+) create mode 100644 clang/test/CodeGen/thinlto-distributed-objc-contract-pass.ll diff --git a/clang/lib/CodeGen/BackendUtil.cpp b/clang/lib/CodeGen/BackendUtil.cpp index 90985c08fe7f8..03dd1df281d80 100644 --- a/clang/lib/CodeGen/BackendUtil.cpp +++ b/clang/lib/CodeGen/BackendUtil.cpp @@ -1289,6 +1289,9 @@ static void runThinLTOBackend( }; break; default: +Conf.PreCodeGenPassesHook = [](legacy::PassManager ) { + Pm.add(createObjCARCContractPass()); +}; Conf.CGFileType = getCodeGenFileType(Action); break; } diff --git a/clang/test/CodeGen/thinlto-distributed-objc-contract-pass.ll b/clang/test/CodeGen/thinlto-distributed-objc-contract-pass.ll new file mode 100644 index 0..7d0247555b5c8 --- /dev/null +++ b/clang/test/CodeGen/thinlto-distributed-objc-contract-pass.ll @@ -0,0 +1,19 @@ +; RUN: opt -thinlto-bc -o %t.o %s + +; RUN: llvm-lto2 run -thinlto-distributed-indexes %t.o \ +; RUN: -o %t2.index \ +; RUN: -r=%t.o,_use_arc,px + +; RUN: %clang_cc1 -triple x86_64-apple-darwin \ +; RUN: -emit-obj -fthinlto-index=%t.o.thinlto.bc \ +; RUN: -o %t.native.o -x ir %t.o + +target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-apple-darwin" + +define void @use_arc(ptr %a, ptr %b) { + call void (...) @llvm.objc.clang.arc.use(i8* %a, i8* %b) nounwind + ret void +} + +declare void @llvm.objc.clang.arc.use(...) nounwind >From 142174dff7b12827f7af187e4ff08b3e75486923 Mon Sep 17 00:00:00 2001 From: Nuri Amari Date: Fri, 17 May 2024 11:38:16 -0700 Subject: [PATCH 2/5] Address PR Feedback - Adjust test - Unconditionally include ARC pass in ThinLTO pipeline --- clang/lib/CodeGen/BackendUtil.cpp| 3 --- clang/test/CodeGen/thinlto-distributed-objc-contract-pass.ll | 2 +- lld/MachO/LTO.cpp| 3 --- llvm/lib/LTO/LTOBackend.cpp | 2 ++ 4 files changed, 3 insertions(+), 7 deletions(-) diff --git a/clang/lib/CodeGen/BackendUtil.cpp b/clang/lib/CodeGen/BackendUtil.cpp index 03dd1df281d80..90985c08fe7f8 100644 --- a/clang/lib/CodeGen/BackendUtil.cpp +++ b/clang/lib/CodeGen/BackendUtil.cpp @@ -1289,9 +1289,6 @@ static void runThinLTOBackend( }; break; default: -Conf.PreCodeGenPassesHook = [](legacy::PassManager ) { - Pm.add(createObjCARCContractPass()); -}; Conf.CGFileType = getCodeGenFileType(Action); break; } diff --git a/clang/test/CodeGen/thinlto-distributed-objc-contract-pass.ll b/clang/test/CodeGen/thinlto-distributed-objc-contract-pass.ll index 7d0247555b5c8..a2a7b62cb7f93 100644 --- a/clang/test/CodeGen/thinlto-distributed-objc-contract-pass.ll +++ b/clang/test/CodeGen/thinlto-distributed-objc-contract-pass.ll @@ -12,7 +12,7 @@ target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16 target triple = "x86_64-apple-darwin" define void @use_arc(ptr %a, ptr %b) { - call void (...) @llvm.objc.clang.arc.use(i8* %a, i8* %b) nounwind + call void (...) @llvm.objc.clang.arc.use(ptr %a, ptr %b) nounwind ret void } diff --git a/lld/MachO/LTO.cpp b/lld/MachO/LTO.cpp index 7a9a9223a0322..6527cbb68f249 100644 --- a/lld/MachO/LTO.cpp +++ b/lld/MachO/LTO.cpp @@ -48,9 +48,6 @@ static lto::Config createConfig() { c.CPU = getCPUStr(); c.MAttrs = getMAttrs(); c.DiagHandler = diagnosticHandler; - c.PreCodeGenPassesHook = [](legacy::PassManager ) { -pm.add(createObjCARCContractPass()); - }; c.AlwaysEmitRegularLTOObj = !config->ltoObjPath.empty(); diff --git a/llvm/lib/LTO/LTOBackend.cpp b/llvm/lib/LTO/LTOBackend.cpp index d4b89ede2d713..aef3a7575dfdf 100644 --- a/llvm/lib/LTO/LTOBackend.cpp +++ b/llvm/lib/LTO/LTOBackend.cpp @@ -42,6 +42,7 @@ #include "llvm/Target/TargetMachine.h" #include "llvm/TargetParser/SubtargetFeature.h" #include "llvm/Transforms/IPO/WholeProgramDevirt.h" +#include "llvm/Transforms/ObjCARC.h" #include "llvm/Transforms/Scalar/LoopPassManager.h" #include "llvm/Transforms/Utils/FunctionImportUtils.h" #include "llvm/Transforms/Utils/SplitModule.h" @@ -415,6 +416,7 @@ static void codegen(const Config , TargetMachine *TM, CodeGenPasses.add(new TargetLibraryInfoWrapperPass(TLII)); CodeGenPasses.add( createImmutableModuleSummaryIndexWrapperPass()); +
[clang] [AArch64][NFC] Use ptrmask for vaarg stack alignment (PR #92836)
llvmbot wrote: @llvm/pr-subscribers-backend-aarch64 Author: Jon Chesterfield (JonChesterfield) Changes --- Full diff: https://github.com/llvm/llvm-project/pull/92836.diff 2 Files Affected: - (modified) clang/lib/CodeGen/Targets/AArch64.cpp (+1-12) - (modified) clang/test/CodeGen/aarch64-varargs.c (+10-20) ``diff diff --git a/clang/lib/CodeGen/Targets/AArch64.cpp b/clang/lib/CodeGen/Targets/AArch64.cpp index 0a4711fb2170d..9aa3ea75681b3 100644 --- a/clang/lib/CodeGen/Targets/AArch64.cpp +++ b/clang/lib/CodeGen/Targets/AArch64.cpp @@ -750,18 +750,7 @@ Address AArch64ABIInfo::EmitAAPCSVAArg(Address VAListAddr, QualType Ty, // Again, stack arguments may need realignment. In this case both integer and // floating-point ones might be affected. if (!IsIndirect && TyAlign.getQuantity() > 8) { -int Align = TyAlign.getQuantity(); - -OnStackPtr = CGF.Builder.CreatePtrToInt(OnStackPtr, CGF.Int64Ty); - -OnStackPtr = CGF.Builder.CreateAdd( -OnStackPtr, llvm::ConstantInt::get(CGF.Int64Ty, Align - 1), -"align_stack"); -OnStackPtr = CGF.Builder.CreateAnd( -OnStackPtr, llvm::ConstantInt::get(CGF.Int64Ty, -Align), -"align_stack"); - -OnStackPtr = CGF.Builder.CreateIntToPtr(OnStackPtr, CGF.Int8PtrTy); +OnStackPtr = emitRoundPointerUpToAlignment(CGF, OnStackPtr, TyAlign); } Address OnStackAddr = Address(OnStackPtr, CGF.Int8Ty, std::max(CharUnits::fromQuantity(8), TyAlign)); diff --git a/clang/test/CodeGen/aarch64-varargs.c b/clang/test/CodeGen/aarch64-varargs.c index ee4e88eda4ef4..8952d6980a8d3 100644 --- a/clang/test/CodeGen/aarch64-varargs.c +++ b/clang/test/CodeGen/aarch64-varargs.c @@ -63,10 +63,8 @@ __int128 aligned_int(void) { // CHECK: [[VAARG_ON_STACK]] // CHECK: [[STACK:%[a-z_0-9]+]] = load ptr, ptr @the_list -// CHECK: [[STACKINT:%[a-z_0-9]+]] = ptrtoint ptr [[STACK]] to i64 -// CHECK: [[ALIGN_STACK:%[a-z_0-9]+]] = add i64 [[STACKINT]], 15 -// CHECK: [[ALIGNED_STACK_INT:%[a-z_0-9]+]] = and i64 [[ALIGN_STACK]], -16 -// CHECK: [[ALIGNED_STACK_PTR:%[a-z_0-9]+]] = inttoptr i64 [[ALIGNED_STACK_INT]] to ptr +// CHECK: [[STACKINC:%[a-z_0-9]+]] = getelementptr inbounds i8, ptr [[STACK]], i32 15 +// CHECK: [[ALIGNED_STACK_PTR:%[a-z_0-9.]+]] = call ptr @llvm.ptrmask.p0.i64(ptr [[STACKINC]], i64 -16) // CHECK: [[NEW_STACK:%[a-z_0-9]+]] = getelementptr inbounds i8, ptr [[ALIGNED_STACK_PTR]], i64 16 // CHECK: store ptr [[NEW_STACK]], ptr @the_list // CHECK: br label %[[VAARG_END]] @@ -377,10 +375,8 @@ underaligned_int128 underaligned_int128_test(void) { // CHECK: [[VAARG_ON_STACK]] // CHECK: [[STACK:%[a-z_0-9]+]] = load ptr, ptr @the_list -// CHECK: [[STACKINT:%[a-z_0-9]+]] = ptrtoint ptr [[STACK]] to i64 -// CHECK: [[ALIGN_STACK:%[a-z_0-9]+]] = add i64 [[STACKINT]], 15 -// CHECK: [[ALIGNED_STACK_INT:%[a-z_0-9]+]] = and i64 [[ALIGN_STACK]], -16 -// CHECK: [[ALIGNED_STACK_PTR:%[a-z_0-9]+]] = inttoptr i64 [[ALIGNED_STACK_INT]] to ptr +// CHECK: [[STACKINC:%[a-z_0-9]+]] = getelementptr inbounds i8, ptr [[STACK]], i32 15 +// CHECK: [[ALIGNED_STACK_PTR:%[a-z_0-9.]+]] = call ptr @llvm.ptrmask.p0.i64(ptr [[STACKINC]], i64 -16) // CHECK: [[NEW_STACK:%[a-z_0-9]+]] = getelementptr inbounds i8, ptr [[ALIGNED_STACK_PTR]], i64 16 // CHECK: store ptr [[NEW_STACK]], ptr @the_list // CHECK: br label %[[VAARG_END]] @@ -414,10 +410,8 @@ overaligned_int128 overaligned_int128_test(void) { // CHECK: [[VAARG_ON_STACK]] // CHECK: [[STACK:%[a-z_0-9]+]] = load ptr, ptr @the_list -// CHECK: [[STACKINT:%[a-z_0-9]+]] = ptrtoint ptr [[STACK]] to i64 -// CHECK: [[ALIGN_STACK:%[a-z_0-9]+]] = add i64 [[STACKINT]], 15 -// CHECK: [[ALIGNED_STACK_INT:%[a-z_0-9]+]] = and i64 [[ALIGN_STACK]], -16 -// CHECK: [[ALIGNED_STACK_PTR:%[a-z_0-9]+]] = inttoptr i64 [[ALIGNED_STACK_INT]] to ptr +// CHECK: [[STACKINC:%[a-z_0-9]+]] = getelementptr inbounds i8, ptr [[STACK]], i32 15 +// CHECK: [[ALIGNED_STACK_PTR:%[a-z_0-9.]+]] = call ptr @llvm.ptrmask.p0.i64(ptr [[STACKINC]], i64 -16) // CHECK: [[NEW_STACK:%[a-z_0-9]+]] = getelementptr inbounds i8, ptr [[ALIGNED_STACK_PTR]], i64 16 // CHECK: store ptr [[NEW_STACK]], ptr @the_list // CHECK: br label %[[VAARG_END]] @@ -688,10 +682,8 @@ overaligned_int_struct_member overaligned_int_struct_member_test(void) { // CHECK: [[VAARG_ON_STACK]] // CHECK: [[STACK:%[a-z_0-9]+]] = load ptr, ptr @the_list -// CHECK: [[STACKINT:%[a-z_0-9]+]] = ptrtoint ptr [[STACK]] to i64 -// CHECK: [[ALIGN_STACK:%[a-z_0-9]+]] = add i64 [[STACKINT]], 15 -// CHECK: [[ALIGNED_STACK_INT:%[a-z_0-9]+]] = and i64 [[ALIGN_STACK]], -16 -// CHECK: [[ALIGNED_STACK_PTR:%[a-z_0-9]+]] = inttoptr i64 [[ALIGNED_STACK_INT]] to ptr +// CHECK: [[STACKINC:%[a-z_0-9]+]] = getelementptr inbounds i8, ptr [[STACK]], i32 15 +// CHECK: [[ALIGNED_STACK_PTR:%[a-z_0-9.]+]] = call ptr @llvm.ptrmask.p0.i64(ptr [[STACKINC]], i64 -16) // CHECK: [[NEW_STACK:%[a-z_0-9]+]] = getelementptr inbounds i8, ptr
[clang] [AArch64][NFC] Use ptrmask for vaarg stack alignment (PR #92836)
https://github.com/JonChesterfield created https://github.com/llvm/llvm-project/pull/92836 None >From b08088ddb37d2a03d321e3256ae19328dd7c502e Mon Sep 17 00:00:00 2001 From: Jon Chesterfield Date: Mon, 20 May 2024 23:07:50 +0100 Subject: [PATCH] [AArch64][NFC] Use ptrmask for vaarg stack alignment --- clang/lib/CodeGen/Targets/AArch64.cpp | 13 +--- clang/test/CodeGen/aarch64-varargs.c | 30 +-- 2 files changed, 11 insertions(+), 32 deletions(-) diff --git a/clang/lib/CodeGen/Targets/AArch64.cpp b/clang/lib/CodeGen/Targets/AArch64.cpp index 0a4711fb2170d..9aa3ea75681b3 100644 --- a/clang/lib/CodeGen/Targets/AArch64.cpp +++ b/clang/lib/CodeGen/Targets/AArch64.cpp @@ -750,18 +750,7 @@ Address AArch64ABIInfo::EmitAAPCSVAArg(Address VAListAddr, QualType Ty, // Again, stack arguments may need realignment. In this case both integer and // floating-point ones might be affected. if (!IsIndirect && TyAlign.getQuantity() > 8) { -int Align = TyAlign.getQuantity(); - -OnStackPtr = CGF.Builder.CreatePtrToInt(OnStackPtr, CGF.Int64Ty); - -OnStackPtr = CGF.Builder.CreateAdd( -OnStackPtr, llvm::ConstantInt::get(CGF.Int64Ty, Align - 1), -"align_stack"); -OnStackPtr = CGF.Builder.CreateAnd( -OnStackPtr, llvm::ConstantInt::get(CGF.Int64Ty, -Align), -"align_stack"); - -OnStackPtr = CGF.Builder.CreateIntToPtr(OnStackPtr, CGF.Int8PtrTy); +OnStackPtr = emitRoundPointerUpToAlignment(CGF, OnStackPtr, TyAlign); } Address OnStackAddr = Address(OnStackPtr, CGF.Int8Ty, std::max(CharUnits::fromQuantity(8), TyAlign)); diff --git a/clang/test/CodeGen/aarch64-varargs.c b/clang/test/CodeGen/aarch64-varargs.c index ee4e88eda4ef4..8952d6980a8d3 100644 --- a/clang/test/CodeGen/aarch64-varargs.c +++ b/clang/test/CodeGen/aarch64-varargs.c @@ -63,10 +63,8 @@ __int128 aligned_int(void) { // CHECK: [[VAARG_ON_STACK]] // CHECK: [[STACK:%[a-z_0-9]+]] = load ptr, ptr @the_list -// CHECK: [[STACKINT:%[a-z_0-9]+]] = ptrtoint ptr [[STACK]] to i64 -// CHECK: [[ALIGN_STACK:%[a-z_0-9]+]] = add i64 [[STACKINT]], 15 -// CHECK: [[ALIGNED_STACK_INT:%[a-z_0-9]+]] = and i64 [[ALIGN_STACK]], -16 -// CHECK: [[ALIGNED_STACK_PTR:%[a-z_0-9]+]] = inttoptr i64 [[ALIGNED_STACK_INT]] to ptr +// CHECK: [[STACKINC:%[a-z_0-9]+]] = getelementptr inbounds i8, ptr [[STACK]], i32 15 +// CHECK: [[ALIGNED_STACK_PTR:%[a-z_0-9.]+]] = call ptr @llvm.ptrmask.p0.i64(ptr [[STACKINC]], i64 -16) // CHECK: [[NEW_STACK:%[a-z_0-9]+]] = getelementptr inbounds i8, ptr [[ALIGNED_STACK_PTR]], i64 16 // CHECK: store ptr [[NEW_STACK]], ptr @the_list // CHECK: br label %[[VAARG_END]] @@ -377,10 +375,8 @@ underaligned_int128 underaligned_int128_test(void) { // CHECK: [[VAARG_ON_STACK]] // CHECK: [[STACK:%[a-z_0-9]+]] = load ptr, ptr @the_list -// CHECK: [[STACKINT:%[a-z_0-9]+]] = ptrtoint ptr [[STACK]] to i64 -// CHECK: [[ALIGN_STACK:%[a-z_0-9]+]] = add i64 [[STACKINT]], 15 -// CHECK: [[ALIGNED_STACK_INT:%[a-z_0-9]+]] = and i64 [[ALIGN_STACK]], -16 -// CHECK: [[ALIGNED_STACK_PTR:%[a-z_0-9]+]] = inttoptr i64 [[ALIGNED_STACK_INT]] to ptr +// CHECK: [[STACKINC:%[a-z_0-9]+]] = getelementptr inbounds i8, ptr [[STACK]], i32 15 +// CHECK: [[ALIGNED_STACK_PTR:%[a-z_0-9.]+]] = call ptr @llvm.ptrmask.p0.i64(ptr [[STACKINC]], i64 -16) // CHECK: [[NEW_STACK:%[a-z_0-9]+]] = getelementptr inbounds i8, ptr [[ALIGNED_STACK_PTR]], i64 16 // CHECK: store ptr [[NEW_STACK]], ptr @the_list // CHECK: br label %[[VAARG_END]] @@ -414,10 +410,8 @@ overaligned_int128 overaligned_int128_test(void) { // CHECK: [[VAARG_ON_STACK]] // CHECK: [[STACK:%[a-z_0-9]+]] = load ptr, ptr @the_list -// CHECK: [[STACKINT:%[a-z_0-9]+]] = ptrtoint ptr [[STACK]] to i64 -// CHECK: [[ALIGN_STACK:%[a-z_0-9]+]] = add i64 [[STACKINT]], 15 -// CHECK: [[ALIGNED_STACK_INT:%[a-z_0-9]+]] = and i64 [[ALIGN_STACK]], -16 -// CHECK: [[ALIGNED_STACK_PTR:%[a-z_0-9]+]] = inttoptr i64 [[ALIGNED_STACK_INT]] to ptr +// CHECK: [[STACKINC:%[a-z_0-9]+]] = getelementptr inbounds i8, ptr [[STACK]], i32 15 +// CHECK: [[ALIGNED_STACK_PTR:%[a-z_0-9.]+]] = call ptr @llvm.ptrmask.p0.i64(ptr [[STACKINC]], i64 -16) // CHECK: [[NEW_STACK:%[a-z_0-9]+]] = getelementptr inbounds i8, ptr [[ALIGNED_STACK_PTR]], i64 16 // CHECK: store ptr [[NEW_STACK]], ptr @the_list // CHECK: br label %[[VAARG_END]] @@ -688,10 +682,8 @@ overaligned_int_struct_member overaligned_int_struct_member_test(void) { // CHECK: [[VAARG_ON_STACK]] // CHECK: [[STACK:%[a-z_0-9]+]] = load ptr, ptr @the_list -// CHECK: [[STACKINT:%[a-z_0-9]+]] = ptrtoint ptr [[STACK]] to i64 -// CHECK: [[ALIGN_STACK:%[a-z_0-9]+]] = add i64 [[STACKINT]], 15 -// CHECK: [[ALIGNED_STACK_INT:%[a-z_0-9]+]] = and i64 [[ALIGN_STACK]], -16 -// CHECK: [[ALIGNED_STACK_PTR:%[a-z_0-9]+]] = inttoptr i64 [[ALIGNED_STACK_INT]] to ptr +// CHECK: [[STACKINC:%[a-z_0-9]+]] = getelementptr inbounds i8, ptr [[STACK]], i32 15 +// CHECK:
[clang] [lld] [llvm] Run ObjCContractPass in Distributed Thin-LTO Pipeline (PR #92331)
https://github.com/cachemeifyoucan approved this pull request. https://github.com/llvm/llvm-project/pull/92331 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [lld] [llvm] Run ObjCContractPass in Distributed Thin-LTO Pipeline (PR #92331)
NuriAmari wrote: I've added the check back in, and reverted my custom check. There is too much going on in https://reviews.llvm.org/D92808 for me to quickly understand everything, but I don't see an obvious reason the check needed to be removed. @ahatanaka Please let me know if I'm missing something. https://github.com/llvm/llvm-project/pull/92331 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] solve crash due to function overloading. (PR #90255)
efriedma-quic wrote: Bot is unreliable, so copy-pasting: > ⚠️ We detected that you are using a GitHub private e-mail address to > contribute to the repo. Please turn off [Keep my email addresses private](https://github.com/settings/emails) setting in your account. See [LLVM Discourse](https://discourse.llvm.org/t/hidden-emails-on-github-should-we-do-something-about-it) for more information. https://github.com/llvm/llvm-project/pull/90255 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [lld] [llvm] Run ObjCContractPass in Distributed Thin-LTO Pipeline (PR #92331)
https://github.com/NuriAmari updated https://github.com/llvm/llvm-project/pull/92331 >From 66ddf609c0e77867ec48c17136fb80d1e482041d Mon Sep 17 00:00:00 2001 From: Nuri Amari Date: Wed, 15 May 2024 16:33:03 -0700 Subject: [PATCH 1/4] Run ObjCContractPass in Distributed Thin-LTO Pipeline Prior to this patch, when using -fthinlto-index= the ObjCARCContractPass isn't run prior to CodeGen, and instruction selection fails on IR containing arc intrinstics. --- clang/lib/CodeGen/BackendUtil.cpp | 3 +++ .../thinlto-distributed-objc-contract-pass.ll | 19 +++ 2 files changed, 22 insertions(+) create mode 100644 clang/test/CodeGen/thinlto-distributed-objc-contract-pass.ll diff --git a/clang/lib/CodeGen/BackendUtil.cpp b/clang/lib/CodeGen/BackendUtil.cpp index 90985c08fe7f8..03dd1df281d80 100644 --- a/clang/lib/CodeGen/BackendUtil.cpp +++ b/clang/lib/CodeGen/BackendUtil.cpp @@ -1289,6 +1289,9 @@ static void runThinLTOBackend( }; break; default: +Conf.PreCodeGenPassesHook = [](legacy::PassManager ) { + Pm.add(createObjCARCContractPass()); +}; Conf.CGFileType = getCodeGenFileType(Action); break; } diff --git a/clang/test/CodeGen/thinlto-distributed-objc-contract-pass.ll b/clang/test/CodeGen/thinlto-distributed-objc-contract-pass.ll new file mode 100644 index 0..7d0247555b5c8 --- /dev/null +++ b/clang/test/CodeGen/thinlto-distributed-objc-contract-pass.ll @@ -0,0 +1,19 @@ +; RUN: opt -thinlto-bc -o %t.o %s + +; RUN: llvm-lto2 run -thinlto-distributed-indexes %t.o \ +; RUN: -o %t2.index \ +; RUN: -r=%t.o,_use_arc,px + +; RUN: %clang_cc1 -triple x86_64-apple-darwin \ +; RUN: -emit-obj -fthinlto-index=%t.o.thinlto.bc \ +; RUN: -o %t.native.o -x ir %t.o + +target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-apple-darwin" + +define void @use_arc(ptr %a, ptr %b) { + call void (...) @llvm.objc.clang.arc.use(i8* %a, i8* %b) nounwind + ret void +} + +declare void @llvm.objc.clang.arc.use(...) nounwind >From 142174dff7b12827f7af187e4ff08b3e75486923 Mon Sep 17 00:00:00 2001 From: Nuri Amari Date: Fri, 17 May 2024 11:38:16 -0700 Subject: [PATCH 2/4] Address PR Feedback - Adjust test - Unconditionally include ARC pass in ThinLTO pipeline --- clang/lib/CodeGen/BackendUtil.cpp| 3 --- clang/test/CodeGen/thinlto-distributed-objc-contract-pass.ll | 2 +- lld/MachO/LTO.cpp| 3 --- llvm/lib/LTO/LTOBackend.cpp | 2 ++ 4 files changed, 3 insertions(+), 7 deletions(-) diff --git a/clang/lib/CodeGen/BackendUtil.cpp b/clang/lib/CodeGen/BackendUtil.cpp index 03dd1df281d80..90985c08fe7f8 100644 --- a/clang/lib/CodeGen/BackendUtil.cpp +++ b/clang/lib/CodeGen/BackendUtil.cpp @@ -1289,9 +1289,6 @@ static void runThinLTOBackend( }; break; default: -Conf.PreCodeGenPassesHook = [](legacy::PassManager ) { - Pm.add(createObjCARCContractPass()); -}; Conf.CGFileType = getCodeGenFileType(Action); break; } diff --git a/clang/test/CodeGen/thinlto-distributed-objc-contract-pass.ll b/clang/test/CodeGen/thinlto-distributed-objc-contract-pass.ll index 7d0247555b5c8..a2a7b62cb7f93 100644 --- a/clang/test/CodeGen/thinlto-distributed-objc-contract-pass.ll +++ b/clang/test/CodeGen/thinlto-distributed-objc-contract-pass.ll @@ -12,7 +12,7 @@ target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16 target triple = "x86_64-apple-darwin" define void @use_arc(ptr %a, ptr %b) { - call void (...) @llvm.objc.clang.arc.use(i8* %a, i8* %b) nounwind + call void (...) @llvm.objc.clang.arc.use(ptr %a, ptr %b) nounwind ret void } diff --git a/lld/MachO/LTO.cpp b/lld/MachO/LTO.cpp index 7a9a9223a0322..6527cbb68f249 100644 --- a/lld/MachO/LTO.cpp +++ b/lld/MachO/LTO.cpp @@ -48,9 +48,6 @@ static lto::Config createConfig() { c.CPU = getCPUStr(); c.MAttrs = getMAttrs(); c.DiagHandler = diagnosticHandler; - c.PreCodeGenPassesHook = [](legacy::PassManager ) { -pm.add(createObjCARCContractPass()); - }; c.AlwaysEmitRegularLTOObj = !config->ltoObjPath.empty(); diff --git a/llvm/lib/LTO/LTOBackend.cpp b/llvm/lib/LTO/LTOBackend.cpp index d4b89ede2d713..aef3a7575dfdf 100644 --- a/llvm/lib/LTO/LTOBackend.cpp +++ b/llvm/lib/LTO/LTOBackend.cpp @@ -42,6 +42,7 @@ #include "llvm/Target/TargetMachine.h" #include "llvm/TargetParser/SubtargetFeature.h" #include "llvm/Transforms/IPO/WholeProgramDevirt.h" +#include "llvm/Transforms/ObjCARC.h" #include "llvm/Transforms/Scalar/LoopPassManager.h" #include "llvm/Transforms/Utils/FunctionImportUtils.h" #include "llvm/Transforms/Utils/SplitModule.h" @@ -415,6 +416,7 @@ static void codegen(const Config , TargetMachine *TM, CodeGenPasses.add(new TargetLibraryInfoWrapperPass(TLII)); CodeGenPasses.add( createImmutableModuleSummaryIndexWrapperPass()); +
[clang] [clang] solve crash due to function overloading. (PR #90255)
https://github.com/efriedma-quic approved this pull request. LGTM https://github.com/llvm/llvm-project/pull/90255 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [webkit.RefCntblBaseVirtualDtor] Ignore a base class which has a specialized deref function for a given derived class. (PR #92501)
https://github.com/rniwa updated https://github.com/llvm/llvm-project/pull/92501 >From 87cfc8234e1294dedc103b9bcd2b7d9d31874c4a Mon Sep 17 00:00:00 2001 From: Ryosuke Niwa Date: Thu, 16 May 2024 23:24:13 -0700 Subject: [PATCH 01/10] [webkit.RefCntblBaseVirtualDtor] Ignore a base class which has a specialized deref function for a given derived class. When a base class B has a deref function which calls delete operator on a derived class D, don't emit a warning for B even if it did not have a virtual destructor. --- .../WebKit/RefCntblBaseVirtualDtorChecker.cpp | 140 - .../ref-cntbl-base-virtual-dtor-templates.cpp | 196 +- 2 files changed, 330 insertions(+), 6 deletions(-) diff --git a/clang/lib/StaticAnalyzer/Checkers/WebKit/RefCntblBaseVirtualDtorChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/WebKit/RefCntblBaseVirtualDtorChecker.cpp index 7f4c3a7b787e8..36ab581f1edbd 100644 --- a/clang/lib/StaticAnalyzer/Checkers/WebKit/RefCntblBaseVirtualDtorChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/WebKit/RefCntblBaseVirtualDtorChecker.cpp @@ -11,16 +11,128 @@ #include "PtrTypesSemantics.h" #include "clang/AST/CXXInheritance.h" #include "clang/AST/RecursiveASTVisitor.h" +#include "clang/AST/StmtVisitor.h" #include "clang/StaticAnalyzer/Checkers/BuiltinCheckerRegistration.h" #include "clang/StaticAnalyzer/Core/BugReporter/BugReporter.h" #include "clang/StaticAnalyzer/Core/BugReporter/BugType.h" #include "clang/StaticAnalyzer/Core/Checker.h" +#include "llvm/ADT/DenseSet.h" #include using namespace clang; using namespace ento; namespace { + +class DerefAnalysisVisitor +: public ConstStmtVisitor { + // Returns true if any of child statements return true. + bool VisitChildren(const Stmt *S) { +for (const Stmt *Child : S->children()) { + if (Child && Visit(Child)) +return true; +} +return false; + } + + bool VisitBody(const Stmt *Body) { +if (!Body) + return false; + +auto [It, IsNew] = VisitedBody.insert(Body); +if (!IsNew) // This body is recursive + return false; + +return Visit(Body); + } + +public: + DerefAnalysisVisitor(const TemplateArgumentList , + const CXXRecordDecl *ClassDecl) +: ArgList() +, ClassDecl(ClassDecl) + { } + + DerefAnalysisVisitor(const CXXRecordDecl *ClassDecl) +: ClassDecl(ClassDecl) + { } + + bool HasSpecializedDelete(CXXMethodDecl *Decl) { +if (auto *Tmpl = Decl->getTemplateInstantiationPattern()) + return VisitBody(Tmpl->getBody()); +return VisitBody(Decl->getBody()); + } + + bool VisitCallExpr(const CallExpr *CE) { +auto *Callee = CE->getCallee(); +while (auto *Expr = dyn_cast(Callee)) + Callee = Expr->getSubExpr(); +if (auto *DeclRef = dyn_cast(Callee)) { + auto *Decl = DeclRef->getDecl(); + if (auto *VD = dyn_cast(Decl)) { +if (auto *Init = VD->getInit()) { + if (auto *Lambda = dyn_cast(Init)) +return VisitBody(Lambda->getBody()); +} + } else if (auto *FD = dyn_cast(Decl)) +return VisitBody(FD->getBody()); +} +return false; + } + + bool VisitCXXMemberCallExpr(const CXXMemberCallExpr *MCE) { +auto *Callee = MCE->getMethodDecl(); +if (!Callee) + return false; +return VisitBody(Callee->getBody()); + } + + bool VisitCXXDeleteExpr(const CXXDeleteExpr *E) { +auto *Arg = E->getArgument(); +while (Arg) { + if (auto *Paren = dyn_cast(Arg)) +Arg = Paren->getSubExpr(); + else if (auto *Cast = dyn_cast(Arg)) { +Arg = Cast->getSubExpr(); +auto CastType = Cast->getType(); +if (auto *PtrType = dyn_cast(CastType)) { + auto PointeeType = PtrType->getPointeeType(); + while (auto *ET = dyn_cast(PointeeType)) { +if (ET->isSugared()) + PointeeType = ET->desugar(); + } + if (auto *ParmType = dyn_cast(PointeeType)) { +if (ArgList) { + auto ParmIndex = ParmType->getIndex(); + auto Type = ArgList->get(ParmIndex).getAsType(); + if (auto *RD = dyn_cast(Type)) { +if (RD->getDecl() == ClassDecl) + return true; + } +} + } else if (auto *RD = dyn_cast(PointeeType)) { +if (RD->getDecl() == ClassDecl) + return true; + } +} + } else +break; +} +return false; + } + + bool VisitStmt(const Stmt *S) { return VisitChildren(S); } + + // Return false since the contents of lambda isn't necessarily executed. + // If it is executed, VisitCallExpr above will visit its body. + bool VisitLambdaExpr(const LambdaExpr *) { return false; } + +private: + const TemplateArgumentList* ArgList { nullptr }; + const CXXRecordDecl* ClassDecl; + llvm::DenseSet VisitedBody; +}; + class RefCntblBaseVirtualDtorChecker : public Checker> { private: @@ -91,8 +203,6 @@ class
[clang] [webkit.RefCntblBaseVirtualDtor] Ignore a base class which has a specialized deref function for a given derived class. (PR #92501)
https://github.com/rniwa updated https://github.com/llvm/llvm-project/pull/92501 >From 87cfc8234e1294dedc103b9bcd2b7d9d31874c4a Mon Sep 17 00:00:00 2001 From: Ryosuke Niwa Date: Thu, 16 May 2024 23:24:13 -0700 Subject: [PATCH 1/9] [webkit.RefCntblBaseVirtualDtor] Ignore a base class which has a specialized deref function for a given derived class. When a base class B has a deref function which calls delete operator on a derived class D, don't emit a warning for B even if it did not have a virtual destructor. --- .../WebKit/RefCntblBaseVirtualDtorChecker.cpp | 140 - .../ref-cntbl-base-virtual-dtor-templates.cpp | 196 +- 2 files changed, 330 insertions(+), 6 deletions(-) diff --git a/clang/lib/StaticAnalyzer/Checkers/WebKit/RefCntblBaseVirtualDtorChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/WebKit/RefCntblBaseVirtualDtorChecker.cpp index 7f4c3a7b787e8..36ab581f1edbd 100644 --- a/clang/lib/StaticAnalyzer/Checkers/WebKit/RefCntblBaseVirtualDtorChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/WebKit/RefCntblBaseVirtualDtorChecker.cpp @@ -11,16 +11,128 @@ #include "PtrTypesSemantics.h" #include "clang/AST/CXXInheritance.h" #include "clang/AST/RecursiveASTVisitor.h" +#include "clang/AST/StmtVisitor.h" #include "clang/StaticAnalyzer/Checkers/BuiltinCheckerRegistration.h" #include "clang/StaticAnalyzer/Core/BugReporter/BugReporter.h" #include "clang/StaticAnalyzer/Core/BugReporter/BugType.h" #include "clang/StaticAnalyzer/Core/Checker.h" +#include "llvm/ADT/DenseSet.h" #include using namespace clang; using namespace ento; namespace { + +class DerefAnalysisVisitor +: public ConstStmtVisitor { + // Returns true if any of child statements return true. + bool VisitChildren(const Stmt *S) { +for (const Stmt *Child : S->children()) { + if (Child && Visit(Child)) +return true; +} +return false; + } + + bool VisitBody(const Stmt *Body) { +if (!Body) + return false; + +auto [It, IsNew] = VisitedBody.insert(Body); +if (!IsNew) // This body is recursive + return false; + +return Visit(Body); + } + +public: + DerefAnalysisVisitor(const TemplateArgumentList , + const CXXRecordDecl *ClassDecl) +: ArgList() +, ClassDecl(ClassDecl) + { } + + DerefAnalysisVisitor(const CXXRecordDecl *ClassDecl) +: ClassDecl(ClassDecl) + { } + + bool HasSpecializedDelete(CXXMethodDecl *Decl) { +if (auto *Tmpl = Decl->getTemplateInstantiationPattern()) + return VisitBody(Tmpl->getBody()); +return VisitBody(Decl->getBody()); + } + + bool VisitCallExpr(const CallExpr *CE) { +auto *Callee = CE->getCallee(); +while (auto *Expr = dyn_cast(Callee)) + Callee = Expr->getSubExpr(); +if (auto *DeclRef = dyn_cast(Callee)) { + auto *Decl = DeclRef->getDecl(); + if (auto *VD = dyn_cast(Decl)) { +if (auto *Init = VD->getInit()) { + if (auto *Lambda = dyn_cast(Init)) +return VisitBody(Lambda->getBody()); +} + } else if (auto *FD = dyn_cast(Decl)) +return VisitBody(FD->getBody()); +} +return false; + } + + bool VisitCXXMemberCallExpr(const CXXMemberCallExpr *MCE) { +auto *Callee = MCE->getMethodDecl(); +if (!Callee) + return false; +return VisitBody(Callee->getBody()); + } + + bool VisitCXXDeleteExpr(const CXXDeleteExpr *E) { +auto *Arg = E->getArgument(); +while (Arg) { + if (auto *Paren = dyn_cast(Arg)) +Arg = Paren->getSubExpr(); + else if (auto *Cast = dyn_cast(Arg)) { +Arg = Cast->getSubExpr(); +auto CastType = Cast->getType(); +if (auto *PtrType = dyn_cast(CastType)) { + auto PointeeType = PtrType->getPointeeType(); + while (auto *ET = dyn_cast(PointeeType)) { +if (ET->isSugared()) + PointeeType = ET->desugar(); + } + if (auto *ParmType = dyn_cast(PointeeType)) { +if (ArgList) { + auto ParmIndex = ParmType->getIndex(); + auto Type = ArgList->get(ParmIndex).getAsType(); + if (auto *RD = dyn_cast(Type)) { +if (RD->getDecl() == ClassDecl) + return true; + } +} + } else if (auto *RD = dyn_cast(PointeeType)) { +if (RD->getDecl() == ClassDecl) + return true; + } +} + } else +break; +} +return false; + } + + bool VisitStmt(const Stmt *S) { return VisitChildren(S); } + + // Return false since the contents of lambda isn't necessarily executed. + // If it is executed, VisitCallExpr above will visit its body. + bool VisitLambdaExpr(const LambdaExpr *) { return false; } + +private: + const TemplateArgumentList* ArgList { nullptr }; + const CXXRecordDecl* ClassDecl; + llvm::DenseSet VisitedBody; +}; + class RefCntblBaseVirtualDtorChecker : public Checker> { private: @@ -91,8 +203,6 @@ class
[clang] [llvm] [AArch64] set AppleA14 architecture version to v8.4-a (PR #92600)
@@ -718,12 +718,16 @@ def ProcessorFeatures { list AppleA13 = [HasV8_4aOps, FeatureCrypto, FeatureFPARMv8, FeatureNEON, FeaturePerfMon, FeatureFullFP16, FeatureFP16FML, FeatureSHA3]; + // Apple A14 and M1 chips are based on Armv8.5-a but without BTI. Since there ahmedbougacha wrote: I don't think we need to emphasize this here or in `aarch64-target-features.c`; it's just v8.4a with some bits from .5, and there are other instances of that. This wasn't always explained clearly in the ARM ARM extension list, but the more recent issues make this pattern explicit (e.g., looking at DDI 0487K.a: A2.1.1, or the start of A2.2.5) https://github.com/llvm/llvm-project/pull/92600 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [CIR] Build out AST consumer patterns to reach the entry point into CIRGen (PR #91007)
bcardosolopes wrote: I encoded the discussion in our clangir.org page, with some speculation on Aaron's pending replies, happy to change and fix anything. In the future we'll upstream that too, but for the time being it's here: https://llvm.github.io/clangir/GettingStarted/coding-guideline.html https://github.com/llvm/llvm-project/pull/91007 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [libunwind] [libunwind][WebAssembly] Make libunwind compilable (PR #92192)
@@ -20,7 +20,7 @@ .text #endif -#if !defined(__USING_SJLJ_EXCEPTIONS__) +#if !defined(__USING_SJLJ_EXCEPTIONS__) && !defined(__wasm__) aheejin wrote: Can I land this? Thank you for your review! https://github.com/llvm/llvm-project/pull/92192 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [CodeGen][AArch64] Added -mno-va-float to skip FP save in variadic functions (PR #92827)
JonChesterfield wrote: Aarch64 has a dedicated floating point region in the va_list structure. Is the intent of this patch to globally disable the use of that, such that clang should arrange to put floating point values in the stack fallback area instead? https://github.com/llvm/llvm-project/pull/92827 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [lld] [llvm] Run ObjCContractPass in Distributed Thin-LTO Pipeline (PR #92331)
cachemeifyoucan wrote: > I couldn't find this check you're alluding to, so I added my own. If the > check does exist, could you point me to it? If not, does mine look > reasonable? Thanks. I was answering from my memory, now I have to check. We have this function `ModuleHasARC` which is used in other ARC optimization passes. It used to be in arc-contract pass too but it seems to be dropped by https://reviews.llvm.org/D92808 It is a good idea to added it back. Maybe by reusing the same function after double check the context of the old patch. @ahatanaka might have idea if there is a reason to drop the guard. https://github.com/llvm/llvm-project/pull/92331 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [CodeGen][AArch64] Added -mno-va-float to skip FP save in variadic functions (PR #92827)
ltertan wrote: @TNorthover The PR mentions no Reviewers, so I'm adding you. Please help me redirect this if you're not the right person to review this. Thanks! https://github.com/llvm/llvm-project/pull/92827 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [CodeGen][AArch64] Added -mno-va-float to skip FP save in variadic functions (PR #92827)
llvmbot wrote: @llvm/pr-subscribers-backend-aarch64 @llvm/pr-subscribers-clang-driver Author: Laurentiu Tertan (ltertan) Changes This patch adds a new option for AArch64, -mno-va-float which can be used to disable the generation of code that saves FP in variadic functions --- Full diff: https://github.com/llvm/llvm-project/pull/92827.diff 6 Files Affected: - (modified) clang/include/clang/Driver/Options.td (+3) - (modified) clang/lib/Driver/ToolChains/Arch/AArch64.cpp (+3) - (modified) llvm/lib/Target/AArch64/AArch64Features.td (+2) - (modified) llvm/lib/Target/AArch64/AArch64ISelLowering.cpp (+1-1) - (added) llvm/test/CodeGen/AArch64/mno-va-float.ll (+21) - (added) llvm/test/CodeGen/AArch64/mva-float.ll (+21) ``diff diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index 7bb781667e926..c70a21d71795f 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -4877,6 +4877,9 @@ foreach i = {8-15,18} in def fcall_saved_x#i : Flag<["-"], "fcall-saved-x"#i>, Group, HelpText<"Make the x"#i#" register call-saved (AArch64 only)">; +def mno_va_float : Flag<["-"], "mno-va-float">, Group, + HelpText<"Do not generate code to save FP in variadic functions">; + def msve_vector_bits_EQ : Joined<["-"], "msve-vector-bits=">, Group, Visibility<[ClangOption, FlangOption]>, HelpText<"Specify the size in bits of an SVE vector register. Defaults to the" diff --git a/clang/lib/Driver/ToolChains/Arch/AArch64.cpp b/clang/lib/Driver/ToolChains/Arch/AArch64.cpp index 2cd2b35ee51bc..2f25eb898b303 100644 --- a/clang/lib/Driver/ToolChains/Arch/AArch64.cpp +++ b/clang/lib/Driver/ToolChains/Arch/AArch64.cpp @@ -432,6 +432,9 @@ void aarch64::getAArch64TargetFeatures(const Driver , if (Args.hasArg(options::OPT_mno_neg_immediates)) Features.push_back("+no-neg-immediates"); + if (Args.hasArg(options::OPT_mno_va_float)) +Features.push_back("+no-va-float"); + if (Arg *A = Args.getLastArg(options::OPT_mfix_cortex_a53_835769, options::OPT_mno_fix_cortex_a53_835769)) { if (A->getOption().matches(options::OPT_mfix_cortex_a53_835769)) diff --git a/llvm/lib/Target/AArch64/AArch64Features.td b/llvm/lib/Target/AArch64/AArch64Features.td index ba0b760ce3d73..234d37a4e4dcf 100644 --- a/llvm/lib/Target/AArch64/AArch64Features.td +++ b/llvm/lib/Target/AArch64/AArch64Features.td @@ -788,6 +788,8 @@ def FeaturePAuthLR : Extension<"pauth-lr", "PAuthLR", def FeatureTLBIW : Extension<"tlbiw", "TLBIW", "Enable ARMv9.5-A TLBI VMALL for Dirty State (FEAT_TLBIW)">; +def FeatureVariadicSaveFP : SubtargetFeature<"no-va-float", "HasNoVaFloat", +"true", "Do not generate code to save FP in variadic functions">; //===--===// // Architectures. diff --git a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp index e31a27e9428e8..64969b4150e77 100644 --- a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp +++ b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp @@ -7470,7 +7470,7 @@ void AArch64TargetLowering::saveVarArgRegisters(CCState , FuncInfo->setVarArgsGPRIndex(GPRIdx); FuncInfo->setVarArgsGPRSize(GPRSaveSize); - if (Subtarget->hasFPARMv8() && !IsWin64) { + if (Subtarget->hasFPARMv8() && !IsWin64 && !Subtarget->hasNoVaFloat()) { auto FPRArgRegs = AArch64::getFPRArgRegs(); const unsigned NumFPRArgRegs = FPRArgRegs.size(); unsigned FirstVariadicFPR = CCInfo.getFirstUnallocated(FPRArgRegs); diff --git a/llvm/test/CodeGen/AArch64/mno-va-float.ll b/llvm/test/CodeGen/AArch64/mno-va-float.ll new file mode 100644 index 0..4205b2f03be04 --- /dev/null +++ b/llvm/test/CodeGen/AArch64/mno-va-float.ll @@ -0,0 +1,21 @@ +; RUN: llc < %s -march=aarch64 -mattr=+no-va-float | FileCheck %s + +target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128" +target triple = "arm64" + +%struct.__va_list = type { i8*, i8*, i8*, i32, i32 } + +declare i32 @vfunc(i8*, i8*) +declare void @llvm.va_start(i8*) +declare void @llvm.va_end(i8*) + +define i32 @func(i8*, double, ...) { +entry: + %argp = alloca %struct.__va_list, align 8 + %argp1 = bitcast %struct.__va_list* %argp to i8* + call void @llvm.va_start(i8* %argp1) +; CHECK-NOT: {{stp.*q[0-9]+}} + %ret = call i32 @vfunc(i8* %0, i8* %argp1) + call void @llvm.va_end(i8* %argp1) + ret i32 %ret +} diff --git a/llvm/test/CodeGen/AArch64/mva-float.ll b/llvm/test/CodeGen/AArch64/mva-float.ll new file mode 100644 index 0..6013aeb73cb20 --- /dev/null +++ b/llvm/test/CodeGen/AArch64/mva-float.ll @@ -0,0 +1,21 @@ +; RUN: llc < %s -march=aarch64 | FileCheck %s + +target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128" +target triple = "arm64" + +%struct.__va_list = type { i8*, i8*, i8*, i32, i32 } + +declare i32 @vfunc(i8*, i8*) +declare void
[clang] [llvm] [CodeGen][AArch64] Added -mno-va-float to skip FP save in variadic functions (PR #92827)
llvmbot wrote: @llvm/pr-subscribers-clang Author: Laurentiu Tertan (ltertan) Changes This patch adds a new option for AArch64, -mno-va-float which can be used to disable the generation of code that saves FP in variadic functions --- Full diff: https://github.com/llvm/llvm-project/pull/92827.diff 6 Files Affected: - (modified) clang/include/clang/Driver/Options.td (+3) - (modified) clang/lib/Driver/ToolChains/Arch/AArch64.cpp (+3) - (modified) llvm/lib/Target/AArch64/AArch64Features.td (+2) - (modified) llvm/lib/Target/AArch64/AArch64ISelLowering.cpp (+1-1) - (added) llvm/test/CodeGen/AArch64/mno-va-float.ll (+21) - (added) llvm/test/CodeGen/AArch64/mva-float.ll (+21) ``diff diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index 7bb781667e926..c70a21d71795f 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -4877,6 +4877,9 @@ foreach i = {8-15,18} in def fcall_saved_x#i : Flag<["-"], "fcall-saved-x"#i>, Group, HelpText<"Make the x"#i#" register call-saved (AArch64 only)">; +def mno_va_float : Flag<["-"], "mno-va-float">, Group, + HelpText<"Do not generate code to save FP in variadic functions">; + def msve_vector_bits_EQ : Joined<["-"], "msve-vector-bits=">, Group, Visibility<[ClangOption, FlangOption]>, HelpText<"Specify the size in bits of an SVE vector register. Defaults to the" diff --git a/clang/lib/Driver/ToolChains/Arch/AArch64.cpp b/clang/lib/Driver/ToolChains/Arch/AArch64.cpp index 2cd2b35ee51bc..2f25eb898b303 100644 --- a/clang/lib/Driver/ToolChains/Arch/AArch64.cpp +++ b/clang/lib/Driver/ToolChains/Arch/AArch64.cpp @@ -432,6 +432,9 @@ void aarch64::getAArch64TargetFeatures(const Driver , if (Args.hasArg(options::OPT_mno_neg_immediates)) Features.push_back("+no-neg-immediates"); + if (Args.hasArg(options::OPT_mno_va_float)) +Features.push_back("+no-va-float"); + if (Arg *A = Args.getLastArg(options::OPT_mfix_cortex_a53_835769, options::OPT_mno_fix_cortex_a53_835769)) { if (A->getOption().matches(options::OPT_mfix_cortex_a53_835769)) diff --git a/llvm/lib/Target/AArch64/AArch64Features.td b/llvm/lib/Target/AArch64/AArch64Features.td index ba0b760ce3d73..234d37a4e4dcf 100644 --- a/llvm/lib/Target/AArch64/AArch64Features.td +++ b/llvm/lib/Target/AArch64/AArch64Features.td @@ -788,6 +788,8 @@ def FeaturePAuthLR : Extension<"pauth-lr", "PAuthLR", def FeatureTLBIW : Extension<"tlbiw", "TLBIW", "Enable ARMv9.5-A TLBI VMALL for Dirty State (FEAT_TLBIW)">; +def FeatureVariadicSaveFP : SubtargetFeature<"no-va-float", "HasNoVaFloat", +"true", "Do not generate code to save FP in variadic functions">; //===--===// // Architectures. diff --git a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp index e31a27e9428e8..64969b4150e77 100644 --- a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp +++ b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp @@ -7470,7 +7470,7 @@ void AArch64TargetLowering::saveVarArgRegisters(CCState , FuncInfo->setVarArgsGPRIndex(GPRIdx); FuncInfo->setVarArgsGPRSize(GPRSaveSize); - if (Subtarget->hasFPARMv8() && !IsWin64) { + if (Subtarget->hasFPARMv8() && !IsWin64 && !Subtarget->hasNoVaFloat()) { auto FPRArgRegs = AArch64::getFPRArgRegs(); const unsigned NumFPRArgRegs = FPRArgRegs.size(); unsigned FirstVariadicFPR = CCInfo.getFirstUnallocated(FPRArgRegs); diff --git a/llvm/test/CodeGen/AArch64/mno-va-float.ll b/llvm/test/CodeGen/AArch64/mno-va-float.ll new file mode 100644 index 0..4205b2f03be04 --- /dev/null +++ b/llvm/test/CodeGen/AArch64/mno-va-float.ll @@ -0,0 +1,21 @@ +; RUN: llc < %s -march=aarch64 -mattr=+no-va-float | FileCheck %s + +target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128" +target triple = "arm64" + +%struct.__va_list = type { i8*, i8*, i8*, i32, i32 } + +declare i32 @vfunc(i8*, i8*) +declare void @llvm.va_start(i8*) +declare void @llvm.va_end(i8*) + +define i32 @func(i8*, double, ...) { +entry: + %argp = alloca %struct.__va_list, align 8 + %argp1 = bitcast %struct.__va_list* %argp to i8* + call void @llvm.va_start(i8* %argp1) +; CHECK-NOT: {{stp.*q[0-9]+}} + %ret = call i32 @vfunc(i8* %0, i8* %argp1) + call void @llvm.va_end(i8* %argp1) + ret i32 %ret +} diff --git a/llvm/test/CodeGen/AArch64/mva-float.ll b/llvm/test/CodeGen/AArch64/mva-float.ll new file mode 100644 index 0..6013aeb73cb20 --- /dev/null +++ b/llvm/test/CodeGen/AArch64/mva-float.ll @@ -0,0 +1,21 @@ +; RUN: llc < %s -march=aarch64 | FileCheck %s + +target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128" +target triple = "arm64" + +%struct.__va_list = type { i8*, i8*, i8*, i32, i32 } + +declare i32 @vfunc(i8*, i8*) +declare void @llvm.va_start(i8*) +declare void @llvm.va_end(i8*) +
[clang] [llvm] [CodeGen][AArch64] Added -mno-va-float to skip FP save in variadic functions (PR #92827)
github-actions[bot] wrote: Thank you for submitting a Pull Request (PR) to the LLVM Project! This PR will be automatically labeled and the relevant teams will be notified. If you wish to, you can add reviewers by using the "Reviewers" section on this page. If this is not working for you, it is probably because you do not have write permissions for the repository. In which case you can instead tag reviewers by name in a comment by using `@` followed by their GitHub username. If you have received no comments on your PR for a week, you can request a review by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate is once a week. Please remember that you are asking for valuable time from other developers. If you have further questions, they may be answered by the [LLVM GitHub User Guide](https://llvm.org/docs/GitHub.html). You can also ask questions in a comment on this PR, on the [LLVM Discord](https://discord.com/invite/xS7Z362) or on the [forums](https://discourse.llvm.org/). https://github.com/llvm/llvm-project/pull/92827 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [CodeGen][AArch64] Added -mno-va-float to skip FP save in variadic functions (PR #92827)
https://github.com/ltertan created https://github.com/llvm/llvm-project/pull/92827 This patch adds a new option for AArch64, -mno-va-float which can be used to disable the generation of code that saves FP in variadic functions >From 3d6a1b5d0bfff6b7ffb444a3fb6a32ea0faceea8 Mon Sep 17 00:00:00 2001 From: Laurentiu Tertan Date: Tue, 21 May 2024 00:56:08 +0300 Subject: [PATCH] [CodeGen][AArch64] Added -mno-va-float to skip FP save in variadic functions --- clang/include/clang/Driver/Options.td | 3 +++ clang/lib/Driver/ToolChains/Arch/AArch64.cpp | 3 +++ llvm/lib/Target/AArch64/AArch64Features.td| 2 ++ .../Target/AArch64/AArch64ISelLowering.cpp| 2 +- llvm/test/CodeGen/AArch64/mno-va-float.ll | 21 +++ llvm/test/CodeGen/AArch64/mva-float.ll| 21 +++ 6 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 llvm/test/CodeGen/AArch64/mno-va-float.ll create mode 100644 llvm/test/CodeGen/AArch64/mva-float.ll diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index 7bb781667e926..c70a21d71795f 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -4877,6 +4877,9 @@ foreach i = {8-15,18} in def fcall_saved_x#i : Flag<["-"], "fcall-saved-x"#i>, Group, HelpText<"Make the x"#i#" register call-saved (AArch64 only)">; +def mno_va_float : Flag<["-"], "mno-va-float">, Group, + HelpText<"Do not generate code to save FP in variadic functions">; + def msve_vector_bits_EQ : Joined<["-"], "msve-vector-bits=">, Group, Visibility<[ClangOption, FlangOption]>, HelpText<"Specify the size in bits of an SVE vector register. Defaults to the" diff --git a/clang/lib/Driver/ToolChains/Arch/AArch64.cpp b/clang/lib/Driver/ToolChains/Arch/AArch64.cpp index 2cd2b35ee51bc..2f25eb898b303 100644 --- a/clang/lib/Driver/ToolChains/Arch/AArch64.cpp +++ b/clang/lib/Driver/ToolChains/Arch/AArch64.cpp @@ -432,6 +432,9 @@ void aarch64::getAArch64TargetFeatures(const Driver , if (Args.hasArg(options::OPT_mno_neg_immediates)) Features.push_back("+no-neg-immediates"); + if (Args.hasArg(options::OPT_mno_va_float)) +Features.push_back("+no-va-float"); + if (Arg *A = Args.getLastArg(options::OPT_mfix_cortex_a53_835769, options::OPT_mno_fix_cortex_a53_835769)) { if (A->getOption().matches(options::OPT_mfix_cortex_a53_835769)) diff --git a/llvm/lib/Target/AArch64/AArch64Features.td b/llvm/lib/Target/AArch64/AArch64Features.td index ba0b760ce3d73..234d37a4e4dcf 100644 --- a/llvm/lib/Target/AArch64/AArch64Features.td +++ b/llvm/lib/Target/AArch64/AArch64Features.td @@ -788,6 +788,8 @@ def FeaturePAuthLR : Extension<"pauth-lr", "PAuthLR", def FeatureTLBIW : Extension<"tlbiw", "TLBIW", "Enable ARMv9.5-A TLBI VMALL for Dirty State (FEAT_TLBIW)">; +def FeatureVariadicSaveFP : SubtargetFeature<"no-va-float", "HasNoVaFloat", +"true", "Do not generate code to save FP in variadic functions">; //===--===// // Architectures. diff --git a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp index e31a27e9428e8..64969b4150e77 100644 --- a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp +++ b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp @@ -7470,7 +7470,7 @@ void AArch64TargetLowering::saveVarArgRegisters(CCState , FuncInfo->setVarArgsGPRIndex(GPRIdx); FuncInfo->setVarArgsGPRSize(GPRSaveSize); - if (Subtarget->hasFPARMv8() && !IsWin64) { + if (Subtarget->hasFPARMv8() && !IsWin64 && !Subtarget->hasNoVaFloat()) { auto FPRArgRegs = AArch64::getFPRArgRegs(); const unsigned NumFPRArgRegs = FPRArgRegs.size(); unsigned FirstVariadicFPR = CCInfo.getFirstUnallocated(FPRArgRegs); diff --git a/llvm/test/CodeGen/AArch64/mno-va-float.ll b/llvm/test/CodeGen/AArch64/mno-va-float.ll new file mode 100644 index 0..4205b2f03be04 --- /dev/null +++ b/llvm/test/CodeGen/AArch64/mno-va-float.ll @@ -0,0 +1,21 @@ +; RUN: llc < %s -march=aarch64 -mattr=+no-va-float | FileCheck %s + +target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128" +target triple = "arm64" + +%struct.__va_list = type { i8*, i8*, i8*, i32, i32 } + +declare i32 @vfunc(i8*, i8*) +declare void @llvm.va_start(i8*) +declare void @llvm.va_end(i8*) + +define i32 @func(i8*, double, ...) { +entry: + %argp = alloca %struct.__va_list, align 8 + %argp1 = bitcast %struct.__va_list* %argp to i8* + call void @llvm.va_start(i8* %argp1) +; CHECK-NOT: {{stp.*q[0-9]+}} + %ret = call i32 @vfunc(i8* %0, i8* %argp1) + call void @llvm.va_end(i8* %argp1) + ret i32 %ret +} diff --git a/llvm/test/CodeGen/AArch64/mva-float.ll b/llvm/test/CodeGen/AArch64/mva-float.ll new file mode 100644 index 0..6013aeb73cb20 --- /dev/null +++ b/llvm/test/CodeGen/AArch64/mva-float.ll @@ -0,0 +1,21 @@ +; RUN: llc < %s
[clang] [lld] [llvm] Run ObjCContractPass in Distributed Thin-LTO Pipeline (PR #92331)
NuriAmari wrote: > it seems like this should just be in the default codegen pipeline? you'd need > to change the pass to bail out early if there are no relevant intrinsics (by > checking if the module contains the intrinsic declaration) to not affect > compile times I've done this, and removed the other places the pass is added currently. Let me know if the location I've added it looks reasonable. Thanks. > Maybe that is a good idea since the check is already there and the check is > quite cheap (just check the existence of ARC intrinsics). @cachemeifyoucan I couldn't find this check you're alluding to, so I added my own. If the check does exist, could you point me to it? If not, does mine look reasonable? Thanks. https://github.com/llvm/llvm-project/pull/92331 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [lld] [llvm] Run ObjCContractPass in Distributed Thin-LTO Pipeline (PR #92331)
@@ -101,6 +101,19 @@ class ARCRuntimeEntryPoints { llvm_unreachable("Switch should be a covered switch."); } + bool moduleContainsARCEntryPoints() { +assert(TheModule != nullptr && "Not initialized."); + +for (auto ARCInstricID : + enum_seq_inclusive(Intrinsic::objc_arc_annotation_bottomup_bbend, NuriAmari wrote: Bit fragile if new arc intrinsics are added, or they are re-arranged, but not sure what else to do. Perhaps giving the sequence a name indicating it is the canonical representation of "all arc intrinsics" will help it stay up to date. https://github.com/llvm/llvm-project/pull/92331 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [lld] [llvm] Run ObjCContractPass in Distributed Thin-LTO Pipeline (PR #92331)
https://github.com/NuriAmari updated https://github.com/llvm/llvm-project/pull/92331 >From 66ddf609c0e77867ec48c17136fb80d1e482041d Mon Sep 17 00:00:00 2001 From: Nuri Amari Date: Wed, 15 May 2024 16:33:03 -0700 Subject: [PATCH 1/3] Run ObjCContractPass in Distributed Thin-LTO Pipeline Prior to this patch, when using -fthinlto-index= the ObjCARCContractPass isn't run prior to CodeGen, and instruction selection fails on IR containing arc intrinstics. --- clang/lib/CodeGen/BackendUtil.cpp | 3 +++ .../thinlto-distributed-objc-contract-pass.ll | 19 +++ 2 files changed, 22 insertions(+) create mode 100644 clang/test/CodeGen/thinlto-distributed-objc-contract-pass.ll diff --git a/clang/lib/CodeGen/BackendUtil.cpp b/clang/lib/CodeGen/BackendUtil.cpp index 90985c08fe7f8..03dd1df281d80 100644 --- a/clang/lib/CodeGen/BackendUtil.cpp +++ b/clang/lib/CodeGen/BackendUtil.cpp @@ -1289,6 +1289,9 @@ static void runThinLTOBackend( }; break; default: +Conf.PreCodeGenPassesHook = [](legacy::PassManager ) { + Pm.add(createObjCARCContractPass()); +}; Conf.CGFileType = getCodeGenFileType(Action); break; } diff --git a/clang/test/CodeGen/thinlto-distributed-objc-contract-pass.ll b/clang/test/CodeGen/thinlto-distributed-objc-contract-pass.ll new file mode 100644 index 0..7d0247555b5c8 --- /dev/null +++ b/clang/test/CodeGen/thinlto-distributed-objc-contract-pass.ll @@ -0,0 +1,19 @@ +; RUN: opt -thinlto-bc -o %t.o %s + +; RUN: llvm-lto2 run -thinlto-distributed-indexes %t.o \ +; RUN: -o %t2.index \ +; RUN: -r=%t.o,_use_arc,px + +; RUN: %clang_cc1 -triple x86_64-apple-darwin \ +; RUN: -emit-obj -fthinlto-index=%t.o.thinlto.bc \ +; RUN: -o %t.native.o -x ir %t.o + +target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-apple-darwin" + +define void @use_arc(ptr %a, ptr %b) { + call void (...) @llvm.objc.clang.arc.use(i8* %a, i8* %b) nounwind + ret void +} + +declare void @llvm.objc.clang.arc.use(...) nounwind >From 142174dff7b12827f7af187e4ff08b3e75486923 Mon Sep 17 00:00:00 2001 From: Nuri Amari Date: Fri, 17 May 2024 11:38:16 -0700 Subject: [PATCH 2/3] Address PR Feedback - Adjust test - Unconditionally include ARC pass in ThinLTO pipeline --- clang/lib/CodeGen/BackendUtil.cpp| 3 --- clang/test/CodeGen/thinlto-distributed-objc-contract-pass.ll | 2 +- lld/MachO/LTO.cpp| 3 --- llvm/lib/LTO/LTOBackend.cpp | 2 ++ 4 files changed, 3 insertions(+), 7 deletions(-) diff --git a/clang/lib/CodeGen/BackendUtil.cpp b/clang/lib/CodeGen/BackendUtil.cpp index 03dd1df281d80..90985c08fe7f8 100644 --- a/clang/lib/CodeGen/BackendUtil.cpp +++ b/clang/lib/CodeGen/BackendUtil.cpp @@ -1289,9 +1289,6 @@ static void runThinLTOBackend( }; break; default: -Conf.PreCodeGenPassesHook = [](legacy::PassManager ) { - Pm.add(createObjCARCContractPass()); -}; Conf.CGFileType = getCodeGenFileType(Action); break; } diff --git a/clang/test/CodeGen/thinlto-distributed-objc-contract-pass.ll b/clang/test/CodeGen/thinlto-distributed-objc-contract-pass.ll index 7d0247555b5c8..a2a7b62cb7f93 100644 --- a/clang/test/CodeGen/thinlto-distributed-objc-contract-pass.ll +++ b/clang/test/CodeGen/thinlto-distributed-objc-contract-pass.ll @@ -12,7 +12,7 @@ target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16 target triple = "x86_64-apple-darwin" define void @use_arc(ptr %a, ptr %b) { - call void (...) @llvm.objc.clang.arc.use(i8* %a, i8* %b) nounwind + call void (...) @llvm.objc.clang.arc.use(ptr %a, ptr %b) nounwind ret void } diff --git a/lld/MachO/LTO.cpp b/lld/MachO/LTO.cpp index 7a9a9223a0322..6527cbb68f249 100644 --- a/lld/MachO/LTO.cpp +++ b/lld/MachO/LTO.cpp @@ -48,9 +48,6 @@ static lto::Config createConfig() { c.CPU = getCPUStr(); c.MAttrs = getMAttrs(); c.DiagHandler = diagnosticHandler; - c.PreCodeGenPassesHook = [](legacy::PassManager ) { -pm.add(createObjCARCContractPass()); - }; c.AlwaysEmitRegularLTOObj = !config->ltoObjPath.empty(); diff --git a/llvm/lib/LTO/LTOBackend.cpp b/llvm/lib/LTO/LTOBackend.cpp index d4b89ede2d713..aef3a7575dfdf 100644 --- a/llvm/lib/LTO/LTOBackend.cpp +++ b/llvm/lib/LTO/LTOBackend.cpp @@ -42,6 +42,7 @@ #include "llvm/Target/TargetMachine.h" #include "llvm/TargetParser/SubtargetFeature.h" #include "llvm/Transforms/IPO/WholeProgramDevirt.h" +#include "llvm/Transforms/ObjCARC.h" #include "llvm/Transforms/Scalar/LoopPassManager.h" #include "llvm/Transforms/Utils/FunctionImportUtils.h" #include "llvm/Transforms/Utils/SplitModule.h" @@ -415,6 +416,7 @@ static void codegen(const Config , TargetMachine *TM, CodeGenPasses.add(new TargetLibraryInfoWrapperPass(TLII)); CodeGenPasses.add( createImmutableModuleSummaryIndexWrapperPass()); +
[clang] [llvm] [AArch64] Add intrinsics for 16-bit non-widening FMLA/FMLS (PR #88553)
@@ -0,0 +1,592 @@ +// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 4 +// RUN: %clang_cc1 -fclang-abi-compat=latest -triple aarch64-none-linux-gnu -target-feature +sme2 -target-feature +sme-f16f16 -target-feature +b16b16 -O2 -Werror -Wall -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1-x c++ -fclang-abi-compat=latest -triple aarch64-none-linux-gnu -target-feature +sme2 -target-feature +sme-f16f16 -target-feature +b16b16 -O2 -Werror -Wall -emit-llvm -o - %s | FileCheck %s --check-prefix CHECK-CXX +// RUN: %clang_cc1 -DSME_OVERLOADED_FORMS-fclang-abi-compat=latest -triple aarch64-none-linux-gnu -target-feature +sme2 -target-feature +sme-f16f16 -target-feature +b16b16 -O2 -Werror -Wall -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -DSME_OVERLOADED_FORMS -x c++ -fclang-abi-compat=latest -triple aarch64-none-linux-gnu -target-feature +sme2 -target-feature +sme-f16f16 -target-feature +b16b16 -O2 -Werror -Wall -emit-llvm -o - %s | FileCheck %s --check-prefix CHECK-CXX + +// RUN: %clang_cc1 -fclang-abi-compat=latest -triple aarch64-none-linux-gnu -target-feature +sme2p1 -target-feature +sme-f16f16 -target-feature +b16b16 -O2 -S -Werror -Wall %s -o /dev/null tmatheson-arm wrote: This needs something like `-target-feature +sme2` https://github.com/llvm/llvm-project/pull/88553 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [AArch64] set AppleA14 architecture version to v8.4-a (PR #92600)
https://github.com/jroelofs approved this pull request. Correct, apple-m1 does not have BTI, but BTI is required for v8.5. My mistake. https://github.com/llvm/llvm-project/pull/92600 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Coverage] Rework !SystemHeadersCoverage (PR #91446)
chapuni wrote: @AaronBallman Thanks. Aha, I've noticed my test was incompatible for targeting msvc mangling. https://github.com/llvm/llvm-project/pull/91446 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Introduce `SemaAccess` (PR #92674)
https://github.com/erichkeane approved this pull request. https://github.com/llvm/llvm-project/pull/92674 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Fix PS "selective" DLL import/export of vtable & typeinfo (PR #92579)
https://github.com/pogo59 approved this pull request. I've been persuaded this is the right direction. LGTM. https://github.com/llvm/llvm-project/pull/92579 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [InstallAPI] add JSON option to pass X arguments (PR #91770)
https://github.com/cyndyishida updated https://github.com/llvm/llvm-project/pull/91770 >From 291412a203ea60465d4ecae9317f3490c59bfb50 Mon Sep 17 00:00:00 2001 From: Cyndy Ishida Date: Thu, 2 May 2024 19:53:07 -0700 Subject: [PATCH 1/2] [InstallAPI] add JSON option to pass X arguments --- .../clang/Basic/DiagnosticInstallAPIKinds.td | 2 +- clang/test/InstallAPI/alias_list.test | 2 +- clang/test/InstallAPI/exclusive-passes-2.test | 9 ++ clang/test/InstallAPI/exclusive-passes-3.test | 86 +++ clang/test/InstallAPI/exclusive-passes.test | 15 .../InstallAPI/invalid-exclusive-passes.test | 33 +++ .../tools/clang-installapi/InstallAPIOpts.td | 3 + clang/tools/clang-installapi/Options.cpp | 74 +++- clang/tools/clang-installapi/Options.h| 2 + 9 files changed, 222 insertions(+), 4 deletions(-) create mode 100644 clang/test/InstallAPI/exclusive-passes-3.test diff --git a/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td b/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td index 674742431dcb2..944b2a38b6e96 100644 --- a/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td +++ b/clang/include/clang/Basic/DiagnosticInstallAPIKinds.td @@ -24,7 +24,7 @@ def err_no_matching_target : Error<"no matching target found for target variant def err_unsupported_vendor : Error<"vendor '%0' is not supported: '%1'">; def err_unsupported_environment : Error<"environment '%0' is not supported: '%1'">; def err_unsupported_os : Error<"os '%0' is not supported: '%1'">; -def err_cannot_read_input_list : Error<"could not read %select{alias list|filelist}0 '%1': %2">; +def err_cannot_read_input_list : Error<"could not read %0 input list '%1': %2">; def err_invalid_label: Error<"label '%0' is reserved: use a different label name for -X">; } // end of command line category. diff --git a/clang/test/InstallAPI/alias_list.test b/clang/test/InstallAPI/alias_list.test index 3e12221e088c4..aba7e395cca95 100644 --- a/clang/test/InstallAPI/alias_list.test +++ b/clang/test/InstallAPI/alias_list.test @@ -23,7 +23,7 @@ ; RUN: -o %t/AliasList.tbd 2>&1 | FileCheck -allow-empty %s \ ; RUN: --check-prefix=INVALID -; INVALID: error: could not read alias list {{.*}} missing alias for: _hidden +; INVALID: error: could not read symbol alias input list {{.*}}invalid.txt': invalid input format: missing alias for: _hidden ;--- Frameworks/AliasList.framework/Headers/AliasList.h // simple alias from one symbol to another. diff --git a/clang/test/InstallAPI/exclusive-passes-2.test b/clang/test/InstallAPI/exclusive-passes-2.test index 3e7a6d777d5af..132b27df383c4 100644 --- a/clang/test/InstallAPI/exclusive-passes-2.test +++ b/clang/test/InstallAPI/exclusive-passes-2.test @@ -11,6 +11,15 @@ ; RUN: -DFoo -XApple -DDarwin=1 -XElf -DNONDarwin=1 2>&1 | FileCheck -allow-empty %s ; RUN: llvm-readtapi --compare %t/output.tbd %t/expected.tbd 2>&1 | FileCheck -allow-empty %s +; RUN: clang-installapi -target arm64-apple-macos12 \ +; RUN: -install_name @rpath/libfoo.dylib \ +; RUN: -current_version 1 -compatibility_version 1 \ +; RUN: -I%S/Inputs/LibFoo/usr/include -dynamiclib \ +; RUN: -extra-public-header %S/Inputs/LibFoo/usr/include/foo.h \ +; RUN: -o %t/output2.tbd \ +; RUN: -DFoo -optionlist %t/options.json 2>&1 | FileCheck -allow-empty %s +; RUN: llvm-readtapi --compare %t/output.tbd %t/expected.tbd 2>&1 | FileCheck -allow-empty %s + ; CHECK-NOT: error ; CHECK-NOT: warning diff --git a/clang/test/InstallAPI/exclusive-passes-3.test b/clang/test/InstallAPI/exclusive-passes-3.test new file mode 100644 index 0..3a9b64c9f7b86 --- /dev/null +++ b/clang/test/InstallAPI/exclusive-passes-3.test @@ -0,0 +1,86 @@ +; RUN: rm -rf %t +; RUN: split-file %s %t + +// "Apple" label has split options between the optionlist & command line. +; RUN: clang-installapi -target arm64-apple-macos12 \ +; RUN: -install_name @rpath/libfoo.dylib -current_version 1 \ +; RUN: -compatibility_version 1 \ +; RUN: -extra-public-header %t/usr/include/opts.h \ +; RUN: -optionlist %t/options.json -XApple -DCLI_OPT=1 \ +; RUN: -I%S/Inputs/LibFoo/usr/include \ +; RUN: -I%t/usr/include -dynamiclib -o %t/output.tbd 2>&1 | FileCheck %s -allow-empty +; RUN: llvm-readtapi --compare %t/output.tbd %t/expected.tbd 2>&1 | FileCheck -allow-empty %s + +// Validate duplicated options give same result. +; RUN: clang-installapi -target arm64-apple-macos12 \ +; RUN: -install_name @rpath/libfoo.dylib -current_version 1 \ +; RUN: -compatibility_version 1 \ +; RUN: -extra-public-header %t/usr/include/opts.h \ +; RUN: -optionlist %t/options.json -XApple -DCLI_OPT=1 \ +; RUN: -I%S/Inputs/LibFoo/usr/include \ +; RUN: -XApple -DDarwin -XElf -DNONDarwin \ +; RUN: -I%t/usr/include -dynamiclib -o %t/output2.tbd 2>&1 | FileCheck %s -allow-empty +; RUN: llvm-readtapi --compare %t/output2.tbd %t/expected.tbd 2>&1 | FileCheck -allow-empty %s + +; CHECK-NOT: error +; CHECK-NOT: warning + +;---
[clang] [llvm] [Clang] Fix definition of layout-compatible to ignore empty classes (PR #92103)
dwblaikie wrote: How's this compare with other implementations clang is trying to be compatible with (gcc (in the normal clang driver mode) and msvc (in clang-cl mode))? Would this be an ABI break against them, or is this intended as an ABI fix to align better with them? Or some third option? https://github.com/llvm/llvm-project/pull/92103 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits