[lld] r219843 - [mach-o] avoid overly clever std::find_if
Rui Ueyama
ruiu at google.com
Wed Oct 15 13:55:04 PDT 2014
This change does seem to contain functionality changes.
In order to fix the buildbot breakage, the change to
MachO/CompactUnwindPass.cpp should suffice.
You just mixed two changes?
On Wed, Oct 15, 2014 at 1:26 PM, Tim Northover <tnorthover at apple.com> wrote:
> Author: tnorthover
> Date: Wed Oct 15 15:26:24 2014
> New Revision: 219843
>
> URL: http://llvm.org/viewvc/llvm-project?rev=219843&view=rev
> Log:
> [mach-o] avoid overly clever std::find_if
>
> The bots were complaining (possibly because of a lack of traits on the
> iterator
> I was trying to use). No functional change.
>
> Modified:
> lld/trunk/lib/ReaderWriter/MachO/ArchHandler.h
> lld/trunk/lib/ReaderWriter/MachO/ArchHandler_arm.cpp
> lld/trunk/lib/ReaderWriter/MachO/ArchHandler_arm64.cpp
> lld/trunk/lib/ReaderWriter/MachO/ArchHandler_x86.cpp
> lld/trunk/lib/ReaderWriter/MachO/ArchHandler_x86_64.cpp
> lld/trunk/lib/ReaderWriter/MachO/CompactUnwindPass.cpp
> lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp
> lld/trunk/test/mach-o/parse-eh-frame-x86-anon.yaml
> lld/trunk/test/mach-o/parse-eh-frame.yaml
>
> Modified: lld/trunk/lib/ReaderWriter/MachO/ArchHandler.h
> URL:
> http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/ArchHandler.h?rev=219843&r1=219842&r2=219843&view=diff
>
> ==============================================================================
> --- lld/trunk/lib/ReaderWriter/MachO/ArchHandler.h (original)
> +++ lld/trunk/lib/ReaderWriter/MachO/ArchHandler.h Wed Oct 15 15:26:24 2014
> @@ -74,6 +74,9 @@ public:
> /// actually be used.
> virtual uint32_t dwarfCompactUnwindType() = 0;
>
> + /// Reference from an __eh_frame FDE to the CIE it's based on.
> + virtual Reference::KindValue unwindRefToCIEKind() = 0;
> +
> /// Reference from an __eh_frame FDE atom to the function it's
> /// describing. Usually pointer-sized and PC-relative, but differs in
> whether
> /// it needs to be in relocatable objects.
>
> Modified: lld/trunk/lib/ReaderWriter/MachO/ArchHandler_arm.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/ArchHandler_arm.cpp?rev=219843&r1=219842&r2=219843&view=diff
>
> ==============================================================================
> --- lld/trunk/lib/ReaderWriter/MachO/ArchHandler_arm.cpp (original)
> +++ lld/trunk/lib/ReaderWriter/MachO/ArchHandler_arm.cpp Wed Oct 15
> 15:26:24 2014
> @@ -48,6 +48,10 @@ public:
> return invalid;
> }
>
> + Reference::KindValue unwindRefToCIEKind() override {
> + return invalid;
> + }
> +
> Reference::KindValue unwindRefToFunctionKind() override {
> return invalid;
> }
>
> Modified: lld/trunk/lib/ReaderWriter/MachO/ArchHandler_arm64.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/ArchHandler_arm64.cpp?rev=219843&r1=219842&r2=219843&view=diff
>
> ==============================================================================
> --- lld/trunk/lib/ReaderWriter/MachO/ArchHandler_arm64.cpp (original)
> +++ lld/trunk/lib/ReaderWriter/MachO/ArchHandler_arm64.cpp Wed Oct 15
> 15:26:24 2014
> @@ -91,6 +91,10 @@ public:
> return invalid;
> }
>
> + Reference::KindValue unwindRefToCIEKind() override {
> + return invalid;
> + }
> +
> Reference::KindValue unwindRefToFunctionKind() override {
> return invalid;
> }
>
> Modified: lld/trunk/lib/ReaderWriter/MachO/ArchHandler_x86.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/ArchHandler_x86.cpp?rev=219843&r1=219842&r2=219843&view=diff
>
> ==============================================================================
> --- lld/trunk/lib/ReaderWriter/MachO/ArchHandler_x86.cpp (original)
> +++ lld/trunk/lib/ReaderWriter/MachO/ArchHandler_x86.cpp Wed Oct 15
> 15:26:24 2014
> @@ -51,6 +51,10 @@ public:
> return invalid;
> }
>
> + Reference::KindValue unwindRefToCIEKind() override {
> + return negDelta32;
> + }
> +
> Reference::KindValue unwindRefToFunctionKind() override{
> return delta32;
> }
>
> Modified: lld/trunk/lib/ReaderWriter/MachO/ArchHandler_x86_64.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/ArchHandler_x86_64.cpp?rev=219843&r1=219842&r2=219843&view=diff
>
> ==============================================================================
> --- lld/trunk/lib/ReaderWriter/MachO/ArchHandler_x86_64.cpp (original)
> +++ lld/trunk/lib/ReaderWriter/MachO/ArchHandler_x86_64.cpp Wed Oct 15
> 15:26:24 2014
> @@ -84,6 +84,10 @@ public:
> return imageOffsetGot;
> }
>
> + Reference::KindValue unwindRefToCIEKind() override {
> + return negDelta32;
> + }
> +
> Reference::KindValue unwindRefToFunctionKind() override{
> return unwindFDEToFunction;
> }
> @@ -167,7 +171,8 @@ private:
> delta32, /// ex: .long _foo - .
> delta64Anon, /// ex: .quad L1 - .
> delta32Anon, /// ex: .long L1 - .
> -
> + negDelta32, /// ex: .long . - _foo
> +
> // Kinds introduced by Passes:
> ripRel32GotLoadNowLea, /// Target of GOT load is in linkage unit so
> /// "movq _foo at GOTPCREL(%rip), %rax" can be
> changed
> @@ -218,6 +223,7 @@ const Registry::KindStrings ArchHandler_
> LLD_KIND_STRING_ENTRY(pointer64), LLD_KIND_STRING_ENTRY(pointer64Anon),
> LLD_KIND_STRING_ENTRY(delta32), LLD_KIND_STRING_ENTRY(delta64),
> LLD_KIND_STRING_ENTRY(delta32Anon), LLD_KIND_STRING_ENTRY(delta64Anon),
> + LLD_KIND_STRING_ENTRY(negDelta32),
> LLD_KIND_STRING_ENTRY(imageOffset),
> LLD_KIND_STRING_ENTRY(imageOffsetGot),
> LLD_KIND_STRING_ENTRY(unwindFDEToFunction),
> LLD_KIND_STRING_ENTRY(unwindInfoToEhFrame),
> @@ -507,6 +513,9 @@ void ArchHandler_x86_64::applyFixupFinal
> location[-2] = 0x8D;
> write32(*loc32, _swap, (targetAddress - (fixupAddress + 4)) +
> ref.addend());
> return;
> + case negDelta32:
> + write32(*loc32, _swap, fixupAddress - targetAddress + ref.addend());
> + return;
> case lazyPointer:
> case lazyImmediateLocation:
> // do nothing
> @@ -574,6 +583,9 @@ void ArchHandler_x86_64::applyFixupReloc
> case delta64Anon:
> write64(*loc64, _swap, (targetAddress - fixupAddress) + ref.addend());
> return;
> + case negDelta32:
> + write32(*loc32, _swap, fixupAddress - targetAddress + ref.addend());
> + return;
> case ripRel32GotLoadNowLea:
> llvm_unreachable("ripRel32GotLoadNowLea implies GOT pass was run");
> return;
> @@ -675,6 +687,7 @@ void ArchHandler_x86_64::appendSectionRe
> return;
> case unwindFDEToFunction:
> case unwindInfoToEhFrame:
> + case negDelta32:
> return;
> case ripRel32GotLoadNowLea:
> llvm_unreachable("ripRel32GotLoadNowLea implies GOT pass was run");
>
> Modified: lld/trunk/lib/ReaderWriter/MachO/CompactUnwindPass.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/CompactUnwindPass.cpp?rev=219843&r1=219842&r2=219843&view=diff
>
> ==============================================================================
> --- lld/trunk/lib/ReaderWriter/MachO/CompactUnwindPass.cpp (original)
> +++ lld/trunk/lib/ReaderWriter/MachO/CompactUnwindPass.cpp Wed Oct 15
> 15:26:24 2014
> @@ -415,17 +415,14 @@ private:
> ArchHandler::isDwarfCIE(_swap, ehFrameAtom))
> continue;
>
> - auto functionRef = std::find_if(ehFrameAtom->begin(),
> ehFrameAtom->end(),
> - [&](const Reference *ref) {
> - return ref->kindNamespace() == Reference::KindNamespace::mach_o &&
> - ref->kindArch() == _archHandler.kindArch() &&
> - ref->kindValue() == _archHandler.unwindRefToFunctionKind();
> - });
> -
> - if (functionRef != ehFrameAtom->end()) {
> - const Atom *functionAtom = functionRef->target();
> - dwarfFrames.insert(std::make_pair(functionAtom, ehFrameAtom));
> - }
> + DefinedAtom::reference_iterator ref = ehFrameAtom->begin();
> + for (; ref != ehFrameAtom->end(); ++ref)
> + if (ref->kindNamespace() == Reference::KindNamespace::mach_o &&
> + ref->kindArch() == _archHandler.kindArch() &&
> + ref->kindValue() == _archHandler.unwindRefToFunctionKind()) {
> + dwarfFrames.insert(std::make_pair(ref->target(), ehFrameAtom));
> + break;
> + }
> }
> }
>
>
> Modified: lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp?rev=219843&r1=219842&r2=219843&view=diff
>
> ==============================================================================
> --- lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp
> (original)
> +++ lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp Wed
> Oct 15 15:26:24 2014
> @@ -660,15 +660,30 @@ std::error_code addEHFrameReferences(con
>
> const uint8_t *frameData = atom->rawContent().data();
> uint32_t size = read32(swap, *(uint32_t *)frameData);
> - uint64_t rangeFieldInFDE = size == 0xffffffffU
> - ? 2 * sizeof(uint32_t) +
> sizeof(uint64_t)
> - : 2 * sizeof(uint32_t);
> + uint64_t cieFieldInFDE = size == 0xffffffffU
> + ? sizeof(uint32_t) + sizeof(uint64_t)
> + : sizeof(uint32_t);
> +
> + // Linker needs to fixup a reference from the FDE to its parent CIE (a
> + // 32-bit byte offset backwards in the __eh_frame section).
> + uint32_t cieDelta = read32(swap, *(uint32_t *)(frameData +
> cieFieldInFDE));
> + uint64_t cieAddress = ehFrameSection->address + offset +
> cieFieldInFDE;
> + cieAddress -= cieDelta;
> +
> + Reference::Addend addend;
> + const Atom *cie =
> + findAtomCoveringAddress(normalizedFile, file, cieAddress,
> &addend);
> + atom->addReference(cieFieldInFDE, handler.unwindRefToCIEKind(), cie,
> + addend, handler.kindArch());
> +
> + // Linker needs to fixup reference from the FDE to the function it's
> + // describing.
> + uint64_t rangeFieldInFDE = cieFieldInFDE + sizeof(uint32_t);
>
> int64_t functionFromFDE = readSPtr(is64, swap, frameData +
> rangeFieldInFDE);
> uint64_t rangeStart = ehFrameSection->address + offset +
> rangeFieldInFDE;
> rangeStart += functionFromFDE;
>
> - Reference::Addend addend;
> const Atom *func =
> findAtomCoveringAddress(normalizedFile, file, rangeStart,
> &addend);
> atom->addReference(rangeFieldInFDE,
> handler.unwindRefToFunctionKind(), func,
>
> Modified: lld/trunk/test/mach-o/parse-eh-frame-x86-anon.yaml
> URL:
> http://llvm.org/viewvc/llvm-project/lld/trunk/test/mach-o/parse-eh-frame-x86-anon.yaml?rev=219843&r1=219842&r2=219843&view=diff
>
> ==============================================================================
> --- lld/trunk/test/mach-o/parse-eh-frame-x86-anon.yaml (original)
> +++ lld/trunk/test/mach-o/parse-eh-frame-x86-anon.yaml Wed Oct 15 15:26:24
> 2014
> @@ -105,24 +105,24 @@ undefined-symbols:
> ...
>
> # CHECK: defined-atoms:
> -# FIXME: - ref-name: [[CIE:L[L0-9]+]]
> +# CHECK: - ref-name: [[CIE:L[L0-9]+]]
> # CHECK: type: unwind-cfi
> # CHECK: content:
> # CHECK: - type: unwind-cfi
> # CHECK: content:
> # CHECK: references:
> -# FIXME: - kind: negDelta32
> -# FIXME: offset: 4
> -# FIXME: target: [[CIE]]
> +# CHECK: - kind: negDelta32
> +# CHECK: offset: 4
> +# CHECK: target: [[CIE]]
> # CHECK: - kind: delta32
> # CHECK: offset: 8
> # CHECK: target: __Z3foov
> # CHECK: - type: unwind-cfi
> # CHECK: content:
> # CHECK: references:
> -# FIXME: - kind: negDelta32
> -# FIXME: offset: 4
> -# FIXME: target: [[CIE]]
> +# CHECK: - kind: negDelta32
> +# CHECK: offset: 4
> +# CHECK: target: [[CIE]]
> # CHECK: - kind: delta32
> # CHECK: offset: 8
> # CHECK: target: __Z3barv
>
> Modified: lld/trunk/test/mach-o/parse-eh-frame.yaml
> URL:
> http://llvm.org/viewvc/llvm-project/lld/trunk/test/mach-o/parse-eh-frame.yaml?rev=219843&r1=219842&r2=219843&view=diff
>
> ==============================================================================
> --- lld/trunk/test/mach-o/parse-eh-frame.yaml (original)
> +++ lld/trunk/test/mach-o/parse-eh-frame.yaml Wed Oct 15 15:26:24 2014
> @@ -51,7 +51,8 @@ global-symbols:
> ...
>
> # CHECK: defined-atoms:
> -# CHECK: - type: unwind-cfi
> +# CHECK: - ref-name: [[CIE:L[0-9]+]]
> +# CHECK: type: unwind-cfi
> # CHECK: content: [ 14, 00, 00, 00, 00, 00, 00, 00, 01, 7A,
> 52, 00,
> # CHECK: 01, 78, 10, 01, 10, 0C, 07, 08, 90, 01,
> 00, 00 ]
> # CHECK: - type: unwind-cfi
> @@ -60,6 +61,9 @@ global-symbols:
> # CHECK: 00, 41, 0E, 10, 86, 02, 43, 0D, 06, 00,
> 00, 00,
> # CHECK: 00, 00, 00, 00 ]
> # CHECK: references:
> +# CHECK: - kind: negDelta32
> +# CHECK: offset: 4
> +# CHECK: target: [[CIE]]
> # CHECK: - kind: unwindFDEToFunction
> # CHECK: offset: 8
> # CHECK: target: __Z3barv
> @@ -69,6 +73,9 @@ global-symbols:
> # CHECK: 00, 41, 0E, 10, 86, 02, 43, 0D, 06, 00,
> 00, 00,
> # CHECK: 00, 00, 00, 00 ]
> # CHECK: references:
> +# CHECK: - kind: negDelta32
> +# CHECK: offset: 4
> +# CHECK: target: [[CIE]]
> # CHECK: - kind: unwindFDEToFunction
> # CHECK: offset: 8
> # CHECK: target: __Z3foov
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20141015/7cda7652/attachment.html>
More information about the llvm-commits
mailing list