[PATCH] D56586: [PPC64] Update LocalEntry from assigned symbols
Leandro Lupori via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon May 13 06:31:14 PDT 2019
luporl updated this revision to Diff 199262.
luporl added a comment.
- Addressed MaskRay review comments
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D56586/new/
https://reviews.llvm.org/D56586
Files:
llvm/lib/Target/PowerPC/MCTargetDesc/PPCMCTargetDesc.cpp
llvm/test/MC/PowerPC/ppc64-localentry-symbols.s
llvm/test/MC/PowerPC/ppc64-localentry-symver.s
Index: llvm/test/MC/PowerPC/ppc64-localentry-symbols.s
===================================================================
--- llvm/test/MC/PowerPC/ppc64-localentry-symbols.s
+++ llvm/test/MC/PowerPC/ppc64-localentry-symbols.s
@@ -4,6 +4,11 @@
# CHECK: 0000000000000000 gw F .text 00000000 0x60 __impl_foo
# CHECK: 0000000000000000 g F .text 00000000 0x60 foo
# CHECK: 0000000000000000 gw F .text 00000000 0x60 foo at FBSD_1.1
+# CHECK: 0000000000000008 g F .text 00000000 0x60 func
+# CHECK: 0000000000000008 gw F .text 00000000 0x60 weak_func
+
+.text
+.abiversion 2
.globl foo
.type foo, at function
@@ -15,3 +20,15 @@
.symver __impl_foo, foo at FBSD_1.1
.weak __impl_foo
.set __impl_foo, foo
+
+.globl func
+# Mimick FreeBSD weak function/reference
+.weak weak_func
+.equ weak_func, func
+
+.p2align 2
+.type func, at function
+func:
+ nop
+ nop
+ .localentry func, 8
Index: llvm/lib/Target/PowerPC/MCTargetDesc/PPCMCTargetDesc.cpp
===================================================================
--- llvm/lib/Target/PowerPC/MCTargetDesc/PPCMCTargetDesc.cpp
+++ llvm/lib/Target/PowerPC/MCTargetDesc/PPCMCTargetDesc.cpp
@@ -14,6 +14,7 @@
#include "MCTargetDesc/PPCInstPrinter.h"
#include "MCTargetDesc/PPCMCAsmInfo.h"
#include "PPCTargetStreamer.h"
+#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/Triple.h"
#include "llvm/BinaryFormat/ELF.h"
@@ -181,16 +182,33 @@
void emitAssignment(MCSymbol *S, const MCExpr *Value) override {
auto *Symbol = cast<MCSymbolELF>(S);
+
// When encoding an assignment to set symbol A to symbol B, also copy
// the st_other bits encoding the local entry point offset.
- if (Value->getKind() != MCExpr::SymbolRef)
- return;
- const auto &RhsSym = cast<MCSymbolELF>(
- static_cast<const MCSymbolRefExpr *>(Value)->getSymbol());
- unsigned Other = Symbol->getOther();
+ if (copyLocalEntry(Symbol, Value))
+ UpdateOther.insert(Symbol);
+ else
+ UpdateOther.erase(Symbol);
+ }
+
+ void finish() override {
+ for (auto *Sym : UpdateOther)
+ copyLocalEntry(Sym, Sym->getVariableValue());
+ }
+
+private:
+ SmallPtrSet<MCSymbolELF *, 32> UpdateOther;
+
+ bool copyLocalEntry(MCSymbolELF *D, const MCExpr *S) {
+ auto *Ref = dyn_cast<const MCSymbolRefExpr>(S);
+ if (!Ref)
+ return false;
+ const auto &RhsSym = cast<MCSymbolELF>(Ref->getSymbol());
+ unsigned Other = D->getOther();
Other &= ~ELF::STO_PPC64_LOCAL_MASK;
Other |= RhsSym.getOther() & ELF::STO_PPC64_LOCAL_MASK;
- Symbol->setOther(Other);
+ D->setOther(Other);
+ return true;
}
};
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D56586.199262.patch
Type: text/x-patch
Size: 2665 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190513/983a4877/attachment.bin>
More information about the llvm-commits
mailing list