| 文件 | 最后提交记录 | 最后更新时间 |
|---|---|---|
[LLD][MachO] Fix warning when building with latest MSVC This fixes: [3902/4335] Building CXX object tools\lld\MachO\CMakeFiles\lldMachO.dir\Arch\X86_64.cpp.obj C:\git\llvm-project\lld\MachO\Arch\X86_64.cpp(107): warning C4334: '<<': result of 32-bit shift implicitly converted to 64 bits (was 64-bit shift intended?) | 8 个月前 | |
[lld][macho] Ignore cstrings in bp orderer (#165757) | 8 个月前 | |
[lld-macho] Refactor BPSectionOrderer with CRTP. NFC PR #117514 refactored BPSectionOrderer to be used by the ELF port but introduced some inefficiency: * BPSectionBase/BPSymbol are wrappers around a single pointer. The numbers of sections and symbols could be huge, and the extra allocations are memory inefficient. * Reconstructing the returned DenseMap (since BPSectionBase != InputSectin) is wasteful. This patch refactors BPSectionOrderer with Curiously Recurring Template Pattern and eliminates the inefficiency. In addition, symbolToSectionIdxs is removed and rootSymbolToSectionIdxs building is moved to lld/MachO: while getting sections for symbols is cheap in Mach-O, it is awkward and inefficient in the ELF port. While here, add a file-level comment and replace some StringMap<*> (which copies strings) with DenseMap<CachedHashStringRef, *>. Pull Request: https://github.com/llvm/llvm-project/pull/124482 | 1 年前 | |
[lld-macho] Link against libatomic when necessary (#144259) In Driver.cpp std::atomic<uint64_t> is used which may need libatomic. Build failure (if that is of interest): `` [127/135] Linking CXX shared library lib/liblldMachO.so.20.1 ninja: job failed: : && /usr/lib/ccache/bin/clang++-20 -fPIC -Os -fstack-clash-protection -Wformat -Werror=format-security -D_GLIBCXX_ASSERTIONS=1 -D_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS=1 -D_LIBCPP_ENABLE_HARDENED_MODE=1 -g -O2 -DNDEBUG -g1 -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -Wl,--as-needed,-O1,--sort-common -Wl,-z,defs -Wl,-z,nodelete -Wl,-rpath-link,/home/user/aports/main/lld20/src/lld-20.1.5.src/build/./lib -Wl,--gc-sections -shared -Wl,-soname,liblldMachO.so.20.1 -o lib/liblldMachO.so.20.1 MachO/CMakeFiles/lldMachO.dir/Arch/ARM64.cpp.o MachO/CMakeFiles/lldMachO.dir/Arch/ARM64Common.cpp.o MachO/CMakeFiles/lldMachO.dir/Arch/ARM64_32.cpp.o MachO/CMakeFiles/lldMachO.dir/Arch/X86_64.cpp.o MachO/CMakeFiles/lldMachO.dir/ConcatOutputSection.cpp.o MachO/CMakeFiles/lldMachO.dir/Driver.cpp.o MachO/CMakeFiles/lldMachO.dir/DriverUtils.cpp.o MachO/CMakeFiles/lldMachO.dir/Dwarf.cpp.o MachO/CMakeFiles/lldMachO.dir/EhFrame.cpp.o MachO/CMakeFiles/lldMachO.dir/ExportTrie.cpp.o MachO/CMakeFiles/lldMachO.dir/ICF.cpp.o MachO/CMakeFiles/lldMachO.dir/InputFiles.cpp.o MachO/CMakeFiles/lldMachO.dir/InputSection.cpp.o MachO/CMakeFiles/lldMachO.dir/LTO.cpp.o MachO/CMakeFiles/lldMachO.dir/MapFile.cpp.o MachO/CMakeFiles/lldMachO.dir/MarkLive.cpp.o MachO/CMakeFiles/lldMachO.dir/ObjC.cpp.o MachO/CMakeFiles/lldMachO.dir/OutputSection.cpp.o MachO/CMakeFiles/lldMachO.dir/OutputSegment.cpp.o MachO/CMakeFiles/lldMachO.dir/Relocations.cpp.o MachO/CMakeFiles/lldMachO.dir/BPSectionOrderer.cpp.o MachO/CMakeFiles/lldMachO.dir/SectionPriorities.cpp.o MachO/CMakeFiles/lldMachO.dir/Sections.cpp.o MachO/CMakeFiles/lldMachO.dir/SymbolTable.cpp.o MachO/CMakeFiles/lldMachO.dir/Symbols.cpp.o MachO/CMakeFiles/lldMachO.dir/SyntheticSections.cpp.o MachO/CMakeFiles/lldMachO.dir/Target.cpp.o MachO/CMakeFiles/lldMachO.dir/UnwindInfoSection.cpp.o MachO/CMakeFiles/lldMachO.dir/Writer.cpp.o -L/usr/lib/llvm20/lib -Wl,-rpath,"\$ORIGIN/../lib:/usr/lib/llvm20/lib:/home/user/aports/main/lld20/src/lld-20.1.5.src/build/lib:" lib/liblldCommon.so.20.1 /usr/lib/llvm20/lib/libLLVM.so.20.1 && : /usr/lib/gcc/powerpc-alpine-linux-musl/14.3.0/../../../../powerpc-alpine-linux-musl/bin/ld: MachO/CMakeFiles/lldMachO.dir/Driver.cpp.o: in function handleExplicitExports()': /usr/lib/gcc/powerpc-alpine-linux-musl/14.3.0/../../../../include/c++/14.3.0/bits/atomic_base.h:501:(.text._ZL21handleExplicitExportsv+0xb8): undefined reference to __atomic_load_8' /usr/lib/gcc/powerpc-alpine-linux-musl/14.3.0/../../../../powerpc-alpine-linux-musl/bin/ld: /usr/lib/gcc/powerpc-alpine-linux-musl/14.3.0/../../../../include/c++/14.3.0/bits/atomic_base.h:501:(.text._ZL21handleExplicitExportsv+0x180): undefined reference to __atomic_load_8' /usr/lib/gcc/powerpc-alpine-linux-musl/14.3.0/../../../../powerpc-alpine-linux-musl/bin/ld: MachO/CMakeFiles/lldMachO.dir/Driver.cpp.o: in function void llvm::function_ref<void (unsigned int)>::callback_fn<llvm::parallelForEach<lld::macho::Symbol* const*, handleExplicitExports()::$_0>(lld::macho::Symbol* const*, lld::macho::Symbol* const*, handleExplicitExports()::$_0)::{lambda(unsigned int)#1}>(int, unsigned int)': /usr/lib/gcc/powerpc-alpine-linux-musl/14.3.0/../../../../include/c++/14.3.0/bits/atomic_base.h:631:(.text._ZN4llvm12function_refIFvjEE11callback_fnIZNS_15parallelForEachIPKPN3lld5macho6SymbolEZL21handleExplicitExportsvE3$_0EEvT_SC_T0_EUljE_EEvij+0xd4): undefined reference to __atomic_fetch_add_8' clang++-20: error: linker command failed with exit code 1 (use -v to see invocation) ``` CC @int3 @gkmhub @smeenai Similar to https://github.com/llvm/llvm-project/commit/f0b451c77f14947e3e7d314f048679fa2f5c6298 | 9 个月前 | |
[lld] Remove unused includes (NFC) (#141421) | 1 年前 | |
[lld-macho] Fix branch extension logic compatibility with __objc_stubs (#137913) Enhance branch extension logic to handle __objc_stubs identically to __stubs The branch extension algorithm currently has specific handling for the __stubs section: 1. It ensures all __stubs content is directly reachable via branches from the text section. 2. It calculates the latest text section address that might require thunks to reach the end of __stubs. The __objc_stubs section requires precisely the same handling due to its similar nature, but this was not implemented. This commit generalizes the existing logic so it applies consistently to both the __stubs and __objc_stubs sections, ensuring correct reachability and thunk placement for both. Without this change it's possible to get relocation errors during linking in scenarios where the __objc_stubs section is large enough. | 1 年前 | |
[lld][MachO] Tail merge strings (#161262) Add the flag --tail-merge-strings to enable tail merging of cstrings. For example, if we have strings mystring\0 and ring\0, we could place mystring\0 at address 0x1000 and ring\0 at address 0x1004 and have them share the same underlying data. It turns out that many ObjC method names can be tail merged. For example, error: and doFoo:error:. On a large iOS binary, we saw nearly a 15% size improvement in the __TEXT__objc_methname section and negligible impact on link time. $ bloaty --domain=vm merged.o.stripped -- base.o.stripped VM SIZE -------------- +95% +5.85Ki [__TEXT] -2.4% -239Ki __TEXT,__cstring -14.5% -710Ki __TEXT,__objc_methname -1.0% -944Ki TOTAL Tail merging for MachO was originally removed in https://github.com/llvm/llvm-project/commit/7c269db779ff3950bac2e25ea78b14b4e2b8b247. The previous implementation used StringTableBuilder, but that was removed in https://github.com/llvm/llvm-project/commit/4308f031cd0c679c539914608134b9c8046743b3 to ensure deduplicated strings are aligned correctly. This implementation ensures that tail merged strings are also aligned correctly. Special thanks to nocchijiang for pointing this out in https://github.com/llvm/llvm-project/pull/158720#issuecomment-3310416030. Depends on https://github.com/llvm/llvm-project/pull/161253. | 9 个月前 | |
[ADT] Prepare to deprecate variadic StringSwitch::Cases. NFC. (#166020) Update all uses of variadic .Cases to use the initializer list overload instead. I plan to mark variadic .Cases as deprecated in a followup PR. For more context, see https://github.com/llvm/llvm-project/pull/163117. | 8 个月前 | |
[lld] Use context-aware outs() and errs() For COFF and ELF that are mostly free of global states, lld::errs() and lld::outs() should not be used. This migration change allows us to remove lld::errs, which uses the global errorHandler(). | 1 年前 | |
[llvm] Add subcommand support for OptTable (#155026) Implement support for subcommands in OptTable to attain feature parity with cl. Design overview: https://discourse.llvm.org/t/subcommand-feature-support-in-llvm-opttable/88098 Issue: https://github.com/llvm/llvm-project/issues/108307 | 9 个月前 | |
[lld-macho] Support creating N_SO stab for DWARF5 compile units In DWARF5, the DW_AT_name and DW_AT_comp_dir attributes are encoded using the strx* forms, which specify an index into __debug_str_offs. This commit adds that section to DwarfObject, so the debug info parser can resolve these references. The test case was manually adapted from stabs-icf.s. Fixes #51668 Differential Revision: https://reviews.llvm.org/D130559 | 3 年前 | |
[lld] Change Optional to std::optional https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716 | 3 年前 | |
[lld] Migrate away from PointerUnion::{is,get} (NFC) (#119993) Note that PointerUnion::{is,get} have been soft deprecated in PointerUnion.h: // FIXME: Replace the uses of is(), get() and dyn_cast() with // isa<T>, cast<T> and the llvm::dyn_cast<T> I'm not touching PointerUnion::dyn_cast for now because it's a bit complicated; we could blindly migrate it to dyn_cast_if_present, but we should probably use dyn_cast when the operand is known to be non-null. | 1 年前 | |
[lld-macho] Change most Optional to std::optional | 3 年前 | |
[lld-macho] Avoid infinite recursion when parsing corrupted export tries (#152569) If an export trie is encoded incorrectly, and one of the children offsets points back to one of the nodes earlier in the serialization, the current code will end up in an infinite recursion, and eventually fail exhausting the available memory. The failure can be avoided if, before recursing, one checks that the offset is valid, that is, that the offset is beyond the current position. This is similar to a check done by llvm-objdump which reports the trie being corrupted. | 10 个月前 | |
[lld-macho] Avoid infinite recursion when parsing corrupted export tries (#152569) If an export trie is encoded incorrectly, and one of the children offsets points back to one of the nodes earlier in the serialization, the current code will end up in an infinite recursion, and eventually fail exhausting the available memory. The failure can be avoided if, before recursing, one checks that the offset is valid, that is, that the offset is beyond the current position. This is similar to a check done by llvm-objdump which reports the trie being corrupted. | 10 个月前 | |
[lld][macho] Move unwind logic from equalsVariable to equalsConstant (#165325) Since equalsVariable runs a lot more times, we want to minimize the work it needs to do. Anything not dependent on the icfEqClass values should get hoisted out. With this change, ICF runs ~1.7% faster when linking clang. Benchmarking approach: cbdr sample -b ~/extract-icf-time.sh ~/old/ld64.lld bin/ld64.lld --timeout=300s | cbdr analyze -s 95 extract-icf-time.sh runs the clang link command with the --icf=all --time-trace flags, then parses out the ICF duration from the resulting time trace using jq: jq '{ICF: (.traceEvents[] | select(.name == "Fold Identical Code Sections") | .dur)}' Output: </Users/jezng/extract-icf-time.sh ["/Users/jezng/old/ld64.lld"]> </Users/jezng/extract-icf-time.sh ["bin/ld64.lld"]> difference (95% CI) ICF 83678.207 ± 1502.778 82234.751 ± 1290.984 [ -2.0% .. -1.4%] samples 208 225 | 8 个月前 | |
[lld-macho] Fix compatibility between --icf=safe_thunks and --keep-icf-stabs (#116687) Currently when --icf=safe_thunks is used, STABS entries cannot be generated for ICF'ed functions. This is because if ICF converts a full function into a thunk and then we generate a STABS entry for the thunk, dsymutil will expect to find the entire function body at the location of the thunk. Because just a thunk will be present at the location of the STABS entry - dsymutil will generate invalid debug info for such scenarios. With this change, if --icf=safe_thunks is used and --keep-icf-stabs is also specified, STABS entries will be created for all functions, even merged ones. However, the STABS entries will point at the actual (full) function body while having the name of the thunk. This way we still get program correctness as well as correct DWARF data. When doing this, the debug data will be identical to the scenario where we're using --icf=all and --keep-icf-stabs, but the actual program will also contain thunks, which won't show up in the DWARF data. | 1 年前 | |
[lld][macho] Fix segfault while processing malformed object file. (#167025) Ran into a use case where we had a MachO object file with a section symbol which did not have a section associated with it segfaults during linking. This patch aims to handle such cases gracefully and avoid the linker from crashing. --------- Co-authored-by: Ellis Hoag <ellis.sparky.hoag@gmail.com> | 8 个月前 | |
[lld-macho] Support archives without index (#132942) This is a ~port of https://reviews.llvm.org/D117284. Like in that change, archives without indices are treated as a collection of lazy object files (as in --start-lib/--end-lib) Porting the ELF follow-up to convert *all* archives to the lazy object code path (https://reviews.llvm.org/D119074) is a natural next step, but we would need to ensure the assertions about memory use hold for Mach-O. NB: without an index, we can't do the part of the -ObjC scan where we check for Objective-C symbols directly. We *can* still check for __obcj sections so I wonder how much of a problem this actually is, since I'm not sure how the "symbols but no sections" case can appear in the wild. | 1 年前 | |
[lld][macho] Error out gracefully when offset is outside literal section (#164660) We typically shouldn't get this, but when we do (e.g. in #139439) we should error out gracefully instead of crashing. Note that we are stricter than ld64 here; ld64 appears to be able to handle section offsets that point outside literal sections if the end result is a valid pointer to another section in the input object file. Supporting this would probably be a pain given our current design, and it seems like enough of an edge case that it's onot worth it. | 8 个月前 | |
[CGData][lld-macho] Merge CG Data by LLD (#112674) LLD now processes raw CG data for stable functions, similar to how it handles raw CG data for the outliner's hash tree. This data is encoded in the custom section ( __llvm_merge) within object files. LLD merges this information into the indexed CG data file specified by the -codegen-data-generate-path={path} option. For the linker that does not support this feature, we could use llvm-cgdata tool -- https://github.com/llvm/llvm-project/blob/main/llvm/docs/CommandGuide/llvm-cgdata.rst. Depends on #115750. This is a patch for https://discourse.llvm.org/t/rfc-global-function-merging/82608. | 1 年前 | |
[lld] Remove unused includes (NFC) (#141421) | 1 年前 | |
[lld-macho] Avoid running LTO pipeline for no files If no bitcode files are given as inputs but -object_path_lto is passed we should avoid running the LTO pipeline. This mirrors this patch from the ELF port https://github.com/llvm/llvm-project/commit/f3994e4dfa0214b2a09a0e327ba37e6b38bbcdb3 Fixes https://github.com/llvm/llvm-project/issues/61031 Differential Revision: https://reviews.llvm.org/D145273 | 3 年前 | |
[lld-macho][re-land] Warn on method name collisions from category definitions This implements ld64's checks for duplicate method names in categories & classes. In addition, this sets us up for implementing Obj-C category merging. This diff handles the most of the parsing work; what's left is rewriting those category / class structures. Numbers for chromium_framework: base diff difference (95% CI) sys_time 2.182 ± 0.027 2.200 ± 0.047 [ -0.2% .. +1.8%] user_time 6.451 ± 0.034 6.479 ± 0.062 [ -0.0% .. +0.9%] wall_time 6.841 ± 0.048 6.885 ± 0.105 [ -0.1% .. +1.4%] samples 33 22 Fixes https://github.com/llvm/llvm-project/issues/54912. Issues seen with the previous land will be fixed in the next commit. Reviewed By: #lld-macho, thevinster, oontvoo Differential Revision: https://reviews.llvm.org/D142916 | 3 年前 | |
[lld-macho] Enable Linker Optimization Hints pass for arm64_32 (#148964) The backend emits .loh directives for arm64_32 as well. Our pass already handles 32-bit pointer loads correctly (there was an extraneous sanity check for 8-byte pointer sizes, I removed that here), so we can enable them for all arm64 subtargets, including our upcoming arm64e support. | 1 年前 | |
[lld-macho] Move Linker Optimization Hints pass to a separate file Moving it away from the arm64 TargetInfo class will let us enable it more easily for arm64_32 and the soon-to-be-added arm64e target as well. This is the NFC part of #148964 | 1 年前 | |
[lld/mac] Use C++17 nested namespace syntax in most places Some header files used namespace lld { namespace macho { // ... } // namespace macho std::string toString(const Type &t); } // namespace lld In those files, I didn't use a nested namespace since it's not a big win there. No behavior change. Differential Revision: https://reviews.llvm.org/D131354 | 3 年前 | |
[LLD][MachO] Option to emit separate cstring sections (#158720) Add the --{no-}separate-cstring-literal-sections option to emit cstring literals into sections defined by their section name. This allows for changes like https://github.com/swiftlang/swift/pull/84300 and https://github.com/swiftlang/swift/pull/84236 to actually have an affect. The default behavior has not changed. The reason this is useful is because strings in different sections might have different access patterns at runtime. By splitting these strings into separate sections, we may reduce the number of page faults during startup. For example, the ObjC runtime accesses all strings in __objc_classname before main. | 10 个月前 | |
[lld/mac] Use C++17 nested namespace syntax in most places Some header files used namespace lld { namespace macho { // ... } // namespace macho std::string toString(const Type &t); } // namespace lld In those files, I didn't use a nested namespace since it's not a big win there. No behavior change. Differential Revision: https://reviews.llvm.org/D131354 | 3 年前 | |
[lld] Remove unused includes (NFC) (#141421) | 1 年前 | |
[lld/mac] Use C++17 nested namespace syntax in most places Some header files used namespace lld { namespace macho { // ... } // namespace macho std::string toString(const Type &t); } // namespace lld In those files, I didn't use a nested namespace since it's not a big win there. No behavior change. Differential Revision: https://reviews.llvm.org/D131354 | 3 年前 | |
[lld/mac] Fix comment typos to cycle bots | 10 个月前 | |
[lld-macho][NFC] Track category merger input data source language for better verification (#95473) This change adds tracking for the source language of the various input structs used by the category merger. Identification is based on expected symbol names. It also adds checks to ensure we're dealing with the expected data in known scenarios. | 2 年前 | |
[lld][MachO] Tail merge strings (#161262) Add the flag --tail-merge-strings to enable tail merging of cstrings. For example, if we have strings mystring\0 and ring\0, we could place mystring\0 at address 0x1000 and ring\0 at address 0x1004 and have them share the same underlying data. It turns out that many ObjC method names can be tail merged. For example, error: and doFoo:error:. On a large iOS binary, we saw nearly a 15% size improvement in the __TEXT__objc_methname section and negligible impact on link time. $ bloaty --domain=vm merged.o.stripped -- base.o.stripped VM SIZE -------------- +95% +5.85Ki [__TEXT] -2.4% -239Ki __TEXT,__cstring -14.5% -710Ki __TEXT,__objc_methname -1.0% -944Ki TOTAL Tail merging for MachO was originally removed in https://github.com/llvm/llvm-project/commit/7c269db779ff3950bac2e25ea78b14b4e2b8b247. The previous implementation used StringTableBuilder, but that was removed in https://github.com/llvm/llvm-project/commit/4308f031cd0c679c539914608134b9c8046743b3 to ensure deduplicated strings are aligned correctly. This implementation ensures that tail merged strings are also aligned correctly. Special thanks to nocchijiang for pointing this out in https://github.com/llvm/llvm-project/pull/158720#issuecomment-3310416030. Depends on https://github.com/llvm/llvm-project/pull/161253. | 9 个月前 | |
[lld-macho][nfc] Run clang-format on lld/MachO/*.{h,cpp} - fixed inconsistent indents and spaces - prevent extraneous formatting changes in other patches Differential Revision: https://reviews.llvm.org/D126262 | 4 年前 | |
[lld-macho] Include branch extension thunks in linker map (#120496) This patch extends the MachO linker's map file generation to include branch extension thunk symbols. Previously, thunks were omitted from the map file, making it difficult to understand the final layout of the binary, especially when debugging issues related to long branch thunks. This change ensures thunks are included and correctly interleaved with other symbols based on their address, providing an accurate representation of the linked output. | 1 年前 | |
[lld] Remove unused includes (NFC) (#141421) | 1 年前 | |
[lld-macho] Fix thunks for non-__text TEXT sections (#99052) This supersedes https://github.com/llvm/llvm-project/pull/87818 and fixes https://github.com/llvm/llvm-project/issues/52767 When calculating arm64 thunks, we make a few assumptions that may not hold when considering code sections outside of __text: 1. That a section needs thunks only if its size is larger than the branch range. 2. That any calls into __stubs are necessarily forward jumps (that is, the section with the jump is ordered before __stubs) Sections like this exist in the wild, most prominently the __lcxx_overrides section introduced in https://github.com/llvm/llvm-project/pull/69498 This change: - Ensures that if one section in __TEXT gets thunks, all of them do. - Makes all code sections in __TEXT contiguous (and guaranteed to be placed before __stubs) | 1 年前 | |
[lld] Migrate away from PointerUnion::dyn_cast (NFC) (#125458) Note that PointerUnion::dyn_cast has been soft deprecated in PointerUnion.h: // FIXME: Replace the uses of is(), get() and dyn_cast() with // isa<T>, cast<T> and the llvm::dyn_cast<T> Literal migration would result in dyn_cast_if_present (see the definition of PointerUnion::dyn_cast), but this patch uses dyn_cast because we expect referent to be nonnull. | 1 年前 | |
[lld][macho] Support 1-byte branch relocs for x86_64 (#164439) | 9 个月前 | |
[lld][MachO] Read cstring order for non deduped sections (#161879) https://github.com/llvm/llvm-project/pull/140307 added support for cstring hashes in the orderfile to layout cstrings in a specific order, but only when --deduplicate-strings is used. This PR supports cstring ordering when --no-deduplicate-strings is used. 1. Create cStringPriorities, separate from priorities, to hold only priorities for cstring pieces. This allows us to lookup by hash directly, instead of first converting to a string. It also fixes a contrived bug where we want to order a symbol named CSTR;12345 rather than a cstring. 2. Rather than calling buildCStringPriorities() which always constructs and returns a vector, we use forEachStringPiece() to efficiently iterate over cstring pieces without creating a new vector if no cstring is ordered. 3. Create SymbolPriorityEntry::{get,set}Priority() helper functions to simplify code. | 8 个月前 | |
[lld][MachO] Read cstring order for non deduped sections (#161879) https://github.com/llvm/llvm-project/pull/140307 added support for cstring hashes in the orderfile to layout cstrings in a specific order, but only when --deduplicate-strings is used. This PR supports cstring ordering when --no-deduplicate-strings is used. 1. Create cStringPriorities, separate from priorities, to hold only priorities for cstring pieces. This allows us to lookup by hash directly, instead of first converting to a string. It also fixes a contrived bug where we want to order a symbol named CSTR;12345 rather than a cstring. 2. Rather than calling buildCStringPriorities() which always constructs and returns a vector, we use forEachStringPiece() to efficiently iterate over cstring pieces without creating a new vector if no cstring is ordered. 3. Create SymbolPriorityEntry::{get,set}Priority() helper functions to simplify code. | 8 个月前 | |
[ADT] Prepare to deprecate variadic StringSwitch::Cases. NFC. (#166020) Update all uses of variadic .Cases to use the initializer list overload instead. I plan to mark variadic .Cases as deprecated in a followup PR. For more context, see https://github.com/llvm/llvm-project/pull/163117. | 8 个月前 | |
[lld-macho] Fix thunks for non-__text TEXT sections (#99052) This supersedes https://github.com/llvm/llvm-project/pull/87818 and fixes https://github.com/llvm/llvm-project/issues/52767 When calculating arm64 thunks, we make a few assumptions that may not hold when considering code sections outside of __text: 1. That a section needs thunks only if its size is larger than the branch range. 2. That any calls into __stubs are necessarily forward jumps (that is, the section with the jump is ordered before __stubs) Sections like this exist in the wild, most prominently the __lcxx_overrides section introduced in https://github.com/llvm/llvm-project/pull/69498 This change: - Ensures that if one section in __TEXT gets thunks, all of them do. - Makes all code sections in __TEXT contiguous (and guaranteed to be placed before __stubs) | 1 年前 | |
[lld:MachO] Allow independent override of weak symbols aliased via .set (#167825) Currently, if multiple external weak symbols are defined at the same address in an object file (e.g., by using the .set assembler directive to alias them to a single weak variable), ld64.lld treats them as a single unit. When any one of these symbols is overridden by a strong definition, all of the original weak symbols resolve to the strong definition. This patch changes the behavior in transplantSymbolsAtOffset. When a weak symbol is being replaced by a strong one, only non-external (local) symbols at the same offset are moved to the new symbol's section. Other *external* symbols are no longer transplanted. This allows each external weak symbol to be overridden independently. This behavior is consistent with Apple's ld-classic, but diverges from ld-prime in one case, as noted on https://github.com/llvm/llvm-project/issues/167262 (this discrepancy has recently been reported to Apple). ### Backward Compatibility This change alters linker behavior for a specific scenario. The creation of multiple external weak symbols aliased to the same address via assembler directives is primarily an advanced technique. It's unlikely that existing builds rely on the current behavior of all aliases being overridden together. If there are concerns, this could be put behind a linker option, but the new default seems more correct, less surprising, and is consistent with ld-classic. ### Testing The new lit test test/MachO/weak-alias-override.s verifies this behavior using llvm-nm. Fixes #167262 | 8 个月前 | |
[lld-macho] Remove partially supported 32-bit ARM arch We never really supported 32-bit ARM arch entirely, and partial support was added for very specific features. Regardless, it fails to even link the most basic applications that at this point, it might be better to move this arch as unsupported. Given that Apple will be moving towards arm64 long term, I don't see any reason for anyone to invest time in supporting this either, and for those who still need it should use apple's ld64 linker. Fixes #62691 Reviewed By: #lld-macho, int3 Differential Revision: https://reviews.llvm.org/D150544 | 3 年前 | |
[lld-macho][arm64] Enhance safe ICF with thunk-based deduplication (#106573) Currently, our safe ICF mode only merges non-address-significant code, leaving duplicate address-significant functions in the output. This patch introduces safe_thunks ICF mode, which keeps a single master copy of each function and replaces address-significant duplicates with thunks that branch to the master copy. Currently --icf=safe_thunks is only supported for arm64 architectures. **Perf stats for a large binary:** | ICF Option | Total Size | __text Size | __unwind_info | % total | |-------------------|------------|-------------|---------------------|---------------------------| | --icf=none | 91.738 MB | 55.220 MB | 1.424 MB | 0% | | --icf=safe | 85.042 MB | 49.572 MB | 1.168 MB | 7.30% | | --icf=safe_thunks | 84.650 MB | 49.219 MB | 1.143 MB | 7.72% | | --icf=all | 82.060 MB | 48.726 MB | 1.111 MB | 10.55% | So overall we can expect a ~0.45% binary size reduction for a typical large binary compared to the --icf=safe option. **Runtime:** Linking the above binary took ~10 seconds. Comparing the link performance of --icf=safe_thunks vs --icf=safe, a ~2% slowdown was observed. | 1 年前 | |
[lld-macho] Fix Defined size increase with -mms-bitfields (#107545) Under the Microsoft ABI, only those bit fields can be merged whose underlying types have the same size. d175616 ([lld-macho][arm64] Enhance safe ICF with thunk-based deduplication) added an enum field (identicalCodeFoldingKind) next to booleans in the Defined class, which increased the size under the MS ABI. On MinGW targets, this triggered the static_assert which checks the size of Defined (for MSVC targets, the check is disabled due to another problem). Let's store it as a uint8_t to allow merging to take place. Fixes #107511 | 1 年前 | |
[lld][MachO] Read cstring order for non deduped sections (#161879) https://github.com/llvm/llvm-project/pull/140307 added support for cstring hashes in the orderfile to layout cstrings in a specific order, but only when --deduplicate-strings is used. This PR supports cstring ordering when --no-deduplicate-strings is used. 1. Create cStringPriorities, separate from priorities, to hold only priorities for cstring pieces. This allows us to lookup by hash directly, instead of first converting to a string. It also fixes a contrived bug where we want to order a symbol named CSTR;12345 rather than a cstring. 2. Rather than calling buildCStringPriorities() which always constructs and returns a vector, we use forEachStringPiece() to efficiently iterate over cstring pieces without creating a new vector if no cstring is ordered. 3. Create SymbolPriorityEntry::{get,set}Priority() helper functions to simplify code. | 8 个月前 | |
[lld][MachO] Use llvm::Align and remove StringOffset type (#161253) Use llvm::Align instead of directly storing the shift amount for clarity. Also remove the DeduplicatedCStringSection::StringOffset in favor of simply storing the uint64_t offset since trailingZeros is not used outside of finalizeContents(). These two changes allow us to refactor finalizeContents(). No function change intended. Depends on https://github.com/llvm/llvm-project/pull/161241. | 9 个月前 | |
[lld-macho][nfc] Create Relocations.{h,cpp} for relocation-specific code This more closely mirrors the structure of lld-ELF. Reviewed By: #lld-macho, thakis Differential Revision: https://reviews.llvm.org/D98384 | 5 年前 | |
[Support] Rename CTLog2 to ConstantLog2 in MathExtras.h (#158006) This patch renames CTLog2 to ConstantLog2 for readability. This patch provides a forwarder under LLVM_DEPRECATED because CTLog2 is used downstream. | 10 个月前 | |
[lld] Use std::tie to implement comparison operators (NFC) (#143726) std::tie facilitates lexicographical comparisons through std::tuple's built-in operator< and operator>. | 1 年前 | |
[lld-macho][nfc] Clean up includes - remove unused/duplicate includes - reformatting/whitespaces Differential Revision: https://reviews.llvm.org/D136266 | 3 年前 | |
[LLD][MachO] Option to emit separate cstring sections (#158720) Add the --{no-}separate-cstring-literal-sections option to emit cstring literals into sections defined by their section name. This allows for changes like https://github.com/swiftlang/swift/pull/84300 and https://github.com/swiftlang/swift/pull/84236 to actually have an affect. The default behavior has not changed. The reason this is useful is because strings in different sections might have different access patterns at runtime. By splitting these strings into separate sections, we may reduce the number of page faults during startup. For example, the ObjC runtime accesses all strings in __objc_classname before main. | 10 个月前 | |
[lld/mac] Use C++17 nested namespace syntax in most places Some header files used namespace lld { namespace macho { // ... } // namespace macho std::string toString(const Type &t); } // namespace lld In those files, I didn't use a nested namespace since it's not a big win there. No behavior change. Differential Revision: https://reviews.llvm.org/D131354 | 3 年前 |
| 文件 | 最后提交记录 | 最后更新时间 |
|---|---|---|
| 8 个月前 | ||
| 8 个月前 | ||
| 1 年前 | ||
| 9 个月前 | ||
| 1 年前 | ||
| 1 年前 | ||
| 9 个月前 | ||
| 8 个月前 | ||
| 1 年前 | ||
| 9 个月前 | ||
| 3 年前 | ||
| 3 年前 | ||
| 1 年前 | ||
| 3 年前 | ||
| 10 个月前 | ||
| 10 个月前 | ||
| 8 个月前 | ||
| 1 年前 | ||
| 8 个月前 | ||
| 1 年前 | ||
| 8 个月前 | ||
| 1 年前 | ||
| 1 年前 | ||
| 3 年前 | ||
| 3 年前 | ||
| 1 年前 | ||
| 1 年前 | ||
| 3 年前 | ||
| 10 个月前 | ||
| 3 年前 | ||
| 1 年前 | ||
| 3 年前 | ||
| 10 个月前 | ||
| 2 年前 | ||
| 9 个月前 | ||
| 4 年前 | ||
| 1 年前 | ||
| 1 年前 | ||
| 1 年前 | ||
| 1 年前 | ||
| 9 个月前 | ||
| 8 个月前 | ||
| 8 个月前 | ||
| 8 个月前 | ||
| 1 年前 | ||
| 8 个月前 | ||
| 3 年前 | ||
| 1 年前 | ||
| 1 年前 | ||
| 8 个月前 | ||
| 9 个月前 | ||
| 5 年前 | ||
| 10 个月前 | ||
| 1 年前 | ||
| 3 年前 | ||
| 10 个月前 | ||
| 3 年前 |