[llvm-branch-commits] [llvm] d4cb47d - Move ExpandLargeDivRem to llvm/test/CodeGen/X86 because they need a triple
Author: Matthias Gehre Date: 2022-09-13T08:29:24+01:00 New Revision: d4cb47d2ab8d030c4313bbdbcf995b8faa279c28 URL: https://github.com/llvm/llvm-project/commit/d4cb47d2ab8d030c4313bbdbcf995b8faa279c28 DIFF: https://github.com/llvm/llvm-project/commit/d4cb47d2ab8d030c4313bbdbcf995b8faa279c28.diff LOG: Move ExpandLargeDivRem to llvm/test/CodeGen/X86 because they need a triple Added: llvm/test/CodeGen/X86/expand-large-div-rem-sdiv129.ll llvm/test/CodeGen/X86/expand-large-div-rem-srem129.ll llvm/test/CodeGen/X86/expand-large-div-rem-udiv129.ll llvm/test/CodeGen/X86/expand-large-div-rem-urem129.ll Modified: Removed: llvm/test/Transforms/ExpandLargeDivRem/sdiv129.ll llvm/test/Transforms/ExpandLargeDivRem/srem129.ll llvm/test/Transforms/ExpandLargeDivRem/udiv129.ll llvm/test/Transforms/ExpandLargeDivRem/urem129.ll diff --git a/llvm/test/Transforms/ExpandLargeDivRem/sdiv129.ll b/llvm/test/CodeGen/X86/expand-large-div-rem-sdiv129.ll similarity index 100% rename from llvm/test/Transforms/ExpandLargeDivRem/sdiv129.ll rename to llvm/test/CodeGen/X86/expand-large-div-rem-sdiv129.ll diff --git a/llvm/test/Transforms/ExpandLargeDivRem/srem129.ll b/llvm/test/CodeGen/X86/expand-large-div-rem-srem129.ll similarity index 100% rename from llvm/test/Transforms/ExpandLargeDivRem/srem129.ll rename to llvm/test/CodeGen/X86/expand-large-div-rem-srem129.ll diff --git a/llvm/test/Transforms/ExpandLargeDivRem/udiv129.ll b/llvm/test/CodeGen/X86/expand-large-div-rem-udiv129.ll similarity index 100% rename from llvm/test/Transforms/ExpandLargeDivRem/udiv129.ll rename to llvm/test/CodeGen/X86/expand-large-div-rem-udiv129.ll diff --git a/llvm/test/Transforms/ExpandLargeDivRem/urem129.ll b/llvm/test/CodeGen/X86/expand-large-div-rem-urem129.ll similarity index 100% rename from llvm/test/Transforms/ExpandLargeDivRem/urem129.ll rename to llvm/test/CodeGen/X86/expand-large-div-rem-urem129.ll ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] 02aaf8e - [NFC][ScheduleDAGInstrs] Use structure bindings and emplace_back
Author: Pavel Samolysov Date: 2022-09-13T12:49:04+03:00 New Revision: 02aaf8e3d6e73116648afcbb691839ecec80aa0e URL: https://github.com/llvm/llvm-project/commit/02aaf8e3d6e73116648afcbb691839ecec80aa0e DIFF: https://github.com/llvm/llvm-project/commit/02aaf8e3d6e73116648afcbb691839ecec80aa0e.diff LOG: [NFC][ScheduleDAGInstrs] Use structure bindings and emplace_back Some uses of std::make_pair and the std::pair's first/second members in the ScheduleDAGInstrs.[cpp|h] files were replaced with using of the vector's emplace_back along with structure bindings from C++17. Added: Modified: llvm/include/llvm/CodeGen/ScheduleDAGInstrs.h llvm/lib/CodeGen/ScheduleDAGInstrs.cpp Removed: diff --git a/llvm/include/llvm/CodeGen/ScheduleDAGInstrs.h b/llvm/include/llvm/CodeGen/ScheduleDAGInstrs.h index fb3900b4a9c14..dc8f02e28adf4 100644 --- a/llvm/include/llvm/CodeGen/ScheduleDAGInstrs.h +++ b/llvm/include/llvm/CodeGen/ScheduleDAGInstrs.h @@ -29,6 +29,7 @@ #include #include #include +#include #include #include diff --git a/llvm/lib/CodeGen/ScheduleDAGInstrs.cpp b/llvm/lib/CodeGen/ScheduleDAGInstrs.cpp index 4fc9399c2b9e9..abf04888abdbd 100644 --- a/llvm/lib/CodeGen/ScheduleDAGInstrs.cpp +++ b/llvm/lib/CodeGen/ScheduleDAGInstrs.cpp @@ -12,6 +12,7 @@ //===--===// #include "llvm/CodeGen/ScheduleDAGInstrs.h" + #include "llvm/ADT/IntEqClasses.h" #include "llvm/ADT/MapVector.h" #include "llvm/ADT/SmallVector.h" @@ -53,7 +54,6 @@ #include #include #include -#include #include #include @@ -92,12 +92,12 @@ static unsigned getReductionSize() { return ReductionSize; } -static void dumpSUList(ScheduleDAGInstrs::SUList &L) { +static void dumpSUList(const ScheduleDAGInstrs::SUList &L) { #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) dbgs() << "{ "; - for (const SUnit *su : L) { -dbgs() << "SU(" << su->NodeNum << ")"; -if (su != L.back()) + for (const SUnit *SU : L) { +dbgs() << "SU(" << SU->NodeNum << ")"; +if (SU != L.back()) dbgs() << ", "; } dbgs() << "}\n"; @@ -125,7 +125,7 @@ static bool getUnderlyingObjectsForInstr(const MachineInstr *MI, const MachineFrameInfo &MFI, UnderlyingObjectsVector &Objects, const DataLayout &DL) { - auto allMMOsOkay = [&]() { + auto AllMMOsOkay = [&]() { for (const MachineMemOperand *MMO : MI->memoperands()) { // TODO: Figure out whether isAtomic is really necessary (see D57601). if (MMO->isVolatile() || MMO->isAtomic()) @@ -147,7 +147,7 @@ static bool getUnderlyingObjectsForInstr(const MachineInstr *MI, return false; bool MayAlias = PSV->mayAlias(&MFI); -Objects.push_back(UnderlyingObjectsVector::value_type(PSV, MayAlias)); +Objects.emplace_back(PSV, MayAlias); } else if (const Value *V = MMO->getValue()) { SmallVector Objs; if (!getUnderlyingObjectsForCodeGen(V, Objs)) @@ -155,7 +155,7 @@ static bool getUnderlyingObjectsForInstr(const MachineInstr *MI, for (Value *V : Objs) { assert(isIdentifiedObject(V)); - Objects.push_back(UnderlyingObjectsVector::value_type(V, true)); + Objects.emplace_back(V, true); } } else return false; @@ -163,7 +163,7 @@ static bool getUnderlyingObjectsForInstr(const MachineInstr *MI, return true; }; - if (!allMMOsOkay()) { + if (!AllMMOsOkay()) { Objects.clear(); return false; } @@ -676,9 +676,9 @@ void ScheduleDAGInstrs::addChainDependencies(SUnit *SU, void ScheduleDAGInstrs::addBarrierChain(Value2SUsMap &map) { assert(BarrierChain != nullptr); - for (auto &I : map) { -SUList &sus = I.second; -for (auto *SU : sus) + for (auto &[V, SUs] : map) { +(void)V; +for (auto *SU : SUs) SU->addPredBarrier(BarrierChain); } map.clear(); @@ -793,7 +793,7 @@ void ScheduleDAGInstrs::buildSchedGraph(AAResults *AA, MII != MIE; --MII) { MachineInstr &MI = *std::prev(MII); if (DbgMI) { - DbgValues.push_back(std::make_pair(DbgMI, &MI)); + DbgValues.emplace_back(DbgMI, &MI); DbgMI = nullptr; } @@ -1019,21 +1019,21 @@ raw_ostream &llvm::operator<<(raw_ostream &OS, const PseudoSourceValue* PSV) { } void ScheduleDAGInstrs::Value2SUsMap::dump() { - for (auto &Itr : *this) { -if (Itr.first.is()) { - const Value *V = Itr.first.get(); + for (const auto &[ValType, SUs] : *this) { +if (ValType.is()) { + const Value *V = ValType.get(); if (isa(V)) dbgs() << "Unknown"; else V->printAsOperand(dbgs()); } -else if (Itr.first.is()) - dbgs() << Itr.first.get(); +else if (ValType.is()) + dbgs() << Val
[llvm-branch-commits] [libcxx] c51a59d - [libc++][format] Updates feature-test macros.
Author: Mark de Wever Date: 2022-09-14T08:14:43+02:00 New Revision: c51a59d8a9470bb06edc9305135c59c19de96011 URL: https://github.com/llvm/llvm-project/commit/c51a59d8a9470bb06edc9305135c59c19de96011 DIFF: https://github.com/llvm/llvm-project/commit/c51a59d8a9470bb06edc9305135c59c19de96011.diff LOG: [libc++][format] Updates feature-test macros. During the discussion on the SG-10 mailinglist regarding the format feature-test macros voted in during the last plenary it turns out libc++ can't mark the format feature-test macro as implemented. According to https://isocpp.org/std/standing-documents/sd-6-sg10-feature-test-recommendations#__cpp_lib_format the not yet implemented paper P1361R2 Integration of chrono with text formatting affects the feature test macro. Note that P1361R2 doesn't mention the feature-test macro nor is there an LWG-issue to address the issue. The reporter of the issue didn't recall where this requirement exactly has been decided. Reviewed By: ldionne, #libc Differential Revision: https://reviews.llvm.org/D133271 Added: Modified: libcxx/docs/FeatureTestMacroTable.rst libcxx/include/version libcxx/test/std/language.support/support.limits/support.limits.general/format.version.compile.pass.cpp libcxx/test/std/language.support/support.limits/support.limits.general/version.version.compile.pass.cpp libcxx/utils/generate_feature_test_macro_components.py Removed: diff --git a/libcxx/docs/FeatureTestMacroTable.rst b/libcxx/docs/FeatureTestMacroTable.rst index e5a06dcced65a..b1bf86942e690 100644 --- a/libcxx/docs/FeatureTestMacroTable.rst +++ b/libcxx/docs/FeatureTestMacroTable.rst @@ -234,7 +234,7 @@ Status - - ``__cpp_lib_execution`` *unimplemented* - - -``__cpp_lib_format`` ``202106L`` +``__cpp_lib_format`` *unimplemented* - - ``__cpp_lib_generic_unordered_lookup````201811L`` - - diff --git a/libcxx/include/version b/libcxx/include/version index 8ffb1747eb276..d0c6fe466e70b 100644 --- a/libcxx/include/version +++ b/libcxx/include/version @@ -332,7 +332,7 @@ __cpp_lib_void_t 201411L # undef __cpp_lib_execution // # define __cpp_lib_execution201902L # if !defined(_LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_format) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_FORMAT) -# define __cpp_lib_format 202106L +// # define __cpp_lib_format 202106L # endif # define __cpp_lib_generic_unordered_lookup 201811L # define __cpp_lib_int_pow2 202002L diff --git a/libcxx/test/std/language.support/support.limits/support.limits.general/format.version.compile.pass.cpp b/libcxx/test/std/language.support/support.limits/support.limits.general/format.version.compile.pass.cpp index dd995cd87e834..7e183311bceca 100644 --- a/libcxx/test/std/language.support/support.limits/support.limits.general/format.version.compile.pass.cpp +++ b/libcxx/test/std/language.support/support.limits/support.limits.general/format.version.compile.pass.cpp @@ -44,31 +44,31 @@ #elif TEST_STD_VER == 20 -# if !defined(_LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_format) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_FORMAT) +# if !defined(_LIBCPP_VERSION) # ifndef __cpp_lib_format # error "__cpp_lib_format should be defined in c++20" # endif # if __cpp_lib_format != 202106L # error "__cpp_lib_format should have the value 202106L in c++20" # endif -# else +# else // _LIBCPP_VERSION # ifdef __cpp_lib_format -# error "__cpp_lib_format should not be defined when !defined(_LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_format) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_FORMAT) is not defined!" +# error "__cpp_lib_format should not be defined because it is unimplemented in libc++!" # endif # endif #elif TEST_STD_VER > 20 -# if !defined(_LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_format) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_FORMAT) +# if !defined(_LIBCPP_VERSION) # ifndef __cpp_lib_format # error "__cpp_lib_format should be defined in c++2b" # endif # if __cpp_lib_format != 202106L # error "__cpp_lib_format should have the value 202106L in c++2b" # endif -# else +# else // _LIBCPP_VERSION # ifdef __cpp_lib_format -# error "__cpp_lib_format should not be defined when !defined(_LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_format) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_FORMAT) is not defined!" +# error "__cpp_l
[llvm-branch-commits] [lld] 6fe6989 - [MachO] Don't fold compact unwind entries with LSDA
Author: Shoaib Meenai Date: 2022-09-14T08:14:57+02:00 New Revision: 6fe69891d15c69e2832e8158987f9d6179ce43bf URL: https://github.com/llvm/llvm-project/commit/6fe69891d15c69e2832e8158987f9d6179ce43bf DIFF: https://github.com/llvm/llvm-project/commit/6fe69891d15c69e2832e8158987f9d6179ce43bf.diff LOG: [MachO] Don't fold compact unwind entries with LSDA Folding them will cause the unwinder to compute the incorrect function start address for the folded entries, which in turn will cause the personality function to interpret the LSDA incorrectly and break exception handling. You can verify the end-to-end flow by creating a simple C++ file: ``` void h(); int main() { h(); } ``` and then linking this file against the liblsda.dylib produced by the test case added here. Before this change, running the resulting program would result in a program termination with an uncaught exception. Afterwards, it works correctly. Reviewed By: #lld-macho, thevinster Differential Revision: https://reviews.llvm.org/D132845 (cherry picked from commit 56bd3185cdd8d79731acd6c75bf41869284a12ed) Added: lld/test/MachO/compact-unwind-lsda-folding.s Modified: lld/MachO/UnwindInfoSection.cpp Removed: diff --git a/lld/MachO/UnwindInfoSection.cpp b/lld/MachO/UnwindInfoSection.cpp index c3f563d5572b..ca6cbdfbb8bb 100644 --- a/lld/MachO/UnwindInfoSection.cpp +++ b/lld/MachO/UnwindInfoSection.cpp @@ -196,13 +196,13 @@ UnwindInfoSection::UnwindInfoSection() // Record function symbols that may need entries emitted in __unwind_info, which // stores unwind data for address ranges. // -// Note that if several adjacent functions have the same unwind encoding, LSDA, -// and personality function, they share one unwind entry. For this to work, -// functions without unwind info need explicit "no unwind info" unwind entries -// -- else the unwinder would think they have the unwind info of the closest -// function with unwind info right before in the image. Thus, we add function -// symbols for each unique address regardless of whether they have associated -// unwind info. +// Note that if several adjacent functions have the same unwind encoding and +// personality function and no LSDA, they share one unwind entry. For this to +// work, functions without unwind info need explicit "no unwind info" unwind +// entries -- else the unwinder would think they have the unwind info of the +// closest function with unwind info right before in the image. Thus, we add +// function symbols for each unique address regardless of whether they have +// associated unwind info. void UnwindInfoSection::addSymbol(const Defined *d) { if (d->unwindEntry) allEntriesAreOmitted = false; @@ -427,9 +427,9 @@ void UnwindInfoSectionImpl::finalize() { // assigned, so we can relocate the __LD,__compact_unwind entries // into a temporary buffer. Relocation is necessary in order to sort // the CU entries by function address. Sorting is necessary so that - // we can fold adjacent CU entries with identical - // encoding+personality+lsda. Folding is necessary because it reduces - // the number of CU entries by as much as 3 orders of magnitude! + // we can fold adjacent CU entries with identical encoding+personality + // and without any LSDA. Folding is necessary because it reduces the + // number of CU entries by as much as 3 orders of magnitude! cuEntries.resize(symbols.size()); // The "map" part of the symbols MapVector was only needed for deduplication // in addSymbol(). Now that we are done adding, move the contents to a plain @@ -445,7 +445,7 @@ void UnwindInfoSectionImpl::finalize() { return cuEntries[a].functionAddress < cuEntries[b].functionAddress; }); - // Fold adjacent entries with matching encoding+personality+lsda + // Fold adjacent entries with matching encoding+personality and without LSDA // We use three iterators on the same cuIndices to fold in-situ: // (1) `foldBegin` is the first of a potential sequence of matching entries // (2) `foldEnd` is the first non-matching entry after `foldBegin`. @@ -455,11 +455,32 @@ void UnwindInfoSectionImpl::finalize() { auto foldWrite = cuIndices.begin(); for (auto foldBegin = cuIndices.begin(); foldBegin < cuIndices.end();) { auto foldEnd = foldBegin; +// Common LSDA encodings (e.g. for C++ and Objective-C) contain offsets from +// a base address. The base address is normally not contained directly in +// the LSDA, and in that case, the personality function treats the starting +// address of the function (which is computed by the unwinder) as the base +// address and interprets the LSDA accordingly. The unwinder computes the +// starting address of a function as the address associated with its CU +// entry. For this reason, we cannot fold adjacent entries if they have an +// LSDA, because folding would make the unwinder compute the
[llvm-branch-commits] [lld] a5ae700 - [MachO] Fix dead-stripping __eh_frame
Author: Shoaib Meenai Date: 2022-09-14T08:14:57+02:00 New Revision: a5ae700c67ec3d814249b1edfb40e6ca39b94eac URL: https://github.com/llvm/llvm-project/commit/a5ae700c67ec3d814249b1edfb40e6ca39b94eac DIFF: https://github.com/llvm/llvm-project/commit/a5ae700c67ec3d814249b1edfb40e6ca39b94eac.diff LOG: [MachO] Fix dead-stripping __eh_frame This section is marked S_ATTR_LIVE_SUPPORT in input files, which meant that on arm64, we were unnecessarily preserving FDEs if we e.g. had multiple weak definitions for a function. Worse, we would actually produce an invalid `__eh_frame` section in that case, because the CIE associated with the unnecessary FDE would still get dead-stripped and we'd end up with a dangling FDE. We set up associations from functions to their FDEs, so dead-stripping will just work naturally, and we can clear S_ATTR_LIVE_SUPPORT from our input `__eh_frame` sections to fix dead-stripping. Reviewed By: #lld-macho, int3 Differential Revision: https://reviews.llvm.org/D132489 (cherry picked from commit a745e47900dde15c180d5caea7a1d292ca809eb1) Added: lld/test/MachO/eh-frame-dead-strip.s Modified: lld/MachO/InputFiles.cpp Removed: diff --git a/lld/MachO/InputFiles.cpp b/lld/MachO/InputFiles.cpp index fd0e4ec8834c4..87034d41e87d2 100644 --- a/lld/MachO/InputFiles.cpp +++ b/lld/MachO/InputFiles.cpp @@ -1587,6 +1587,15 @@ void ObjFile::registerEhFrames(Section &ehFrameSection) { funcSym->unwindEntry = isec; ehRelocator.commit(); } + + // __eh_frame is marked as S_ATTR_LIVE_SUPPORT in input files, because FDEs + // are normally required to be kept alive if they reference a live symbol. + // However, we've explicitly created a dependency from a symbol to its FDE, so + // dead-stripping will just work as usual, and S_ATTR_LIVE_SUPPORT will only + // serve to incorrectly prevent us from dead-stripping duplicate FDEs for a + // live symbol (e.g. if there were multiple weak copies). Remove this flag to + // let dead-stripping proceed correctly. + ehFrameSection.flags &= ~S_ATTR_LIVE_SUPPORT; } std::string ObjFile::sourceFile() const { diff --git a/lld/test/MachO/eh-frame-dead-strip.s b/lld/test/MachO/eh-frame-dead-strip.s new file mode 100644 index 0..c9eb8c167720d --- /dev/null +++ b/lld/test/MachO/eh-frame-dead-strip.s @@ -0,0 +1,46 @@ +# REQUIRES: x86, aarch64 + +# RUN: rm -rf %t; split-file %s %t +# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-macos11.0 %t/strong.s -o %t/strong_x86_64.o +# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-macos11.0 %t/weak.s -o %t/weak_x86_64.o +# RUN: %lld -dylib -dead_strip %t/strong_x86_64.o %t/weak_x86_64.o -o %t/libstrongweak_x86_64.dylib +# RUN: llvm-dwarfdump --eh-frame %t/libstrongweak_x86_64.dylib | FileCheck --check-prefixes CHECK,X86_64 %s +# RUN: %lld -dylib -dead_strip %t/weak_x86_64.o %t/strong_x86_64.o -o %t/libweakstrong_x86_64.dylib +# RUN: llvm-dwarfdump --eh-frame %t/libweakstrong_x86_64.dylib | FileCheck --check-prefixes CHECK,X86_64 %s + +# RUN: llvm-mc -filetype=obj -triple=arm64-apple-macos11.0 %t/strong.s -o %t/strong_arm64.o +# RUN: llvm-mc -filetype=obj -triple=arm64-apple-macos11.0 %t/weak.s -o %t/weak_arm64.o +# RUN: %lld -arch arm64 -dylib -dead_strip %t/strong_arm64.o %t/weak_arm64.o -o %t/libstrongweak_arm64.dylib +# RUN: llvm-dwarfdump --eh-frame %t/libstrongweak_arm64.dylib | FileCheck --check-prefixes CHECK,ARM64 %s +# RUN: %lld -arch arm64 -dylib -dead_strip %t/weak_arm64.o %t/strong_arm64.o -o %t/libweakstrong_arm64.dylib +# RUN: llvm-dwarfdump --eh-frame %t/libweakstrong_arm64.dylib | FileCheck --check-prefixes CHECK,ARM64 %s + +## Verify that unneeded FDEs (and their CIEs) are dead-stripped even if they +## point to a live symbol (e.g. because we had multiple weak definitions). + +# CHECK: .eh_frame contents: +# X86_64: 0014 CIE +# X86_64: 0018 001c 001c FDE cie= +# ARM64: 0010 CIE +# ARM64: 0014 0018 0018 FDE cie= +# CHECK-NOT: CIE +# CHECK-NOT: FDE + +#--- strong.s +.globl _fun +_fun: + .cfi_startproc + ## cfi_escape cannot be encoded in compact unwind + .cfi_escape 0 + ret + .cfi_endproc + +#--- weak.s +.globl _fun +.weak_definition _fun +_fun: + .cfi_startproc + ## cfi_escape cannot be encoded in compact unwind + .cfi_escape 0 + ret + .cfi_endproc ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits