[lld] r234580 - [ARM] Improve veneer handling and introduce handlePlain method

Denis Protivensky dprotivensky at accesssoftek.com
Mon Apr 13 01:40:45 PDT 2015


RelocationPass implements CRTP, and I believe it's a good practice of the base relocation handler switch to call specific handlers
with regard to their possible "overrides" in derived classes.

- Denis.

On 04/10/2015 10:59 PM, Rui Ueyama wrote:
On Fri, Apr 10, 2015 at 2:54 AM, Denis Protivensky <dprotivensky at accesssoftek.com<mailto:dprotivensky at accesssoftek.com>> wrote:
Author: denis-protivensky
Date: Fri Apr 10 04:54:10 2015
New Revision: 234580

URL: http://llvm.org/viewvc/llvm-project?rev=234580&view=rev
Log:
[ARM] Improve veneer handling and introduce handlePlain method

Handle veneers only for call-like relocations.

Modified:
    lld/trunk/lib/ReaderWriter/ELF/ARM/ARMRelocationPass.cpp

Modified: lld/trunk/lib/ReaderWriter/ELF/ARM/ARMRelocationPass.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/ARM/ARMRelocationPass.cpp?rev=234580&r1=234579&r2=234580&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/ARM/ARMRelocationPass.cpp (original)
+++ lld/trunk/lib/ReaderWriter/ELF/ARM/ARMRelocationPass.cpp Fri Apr 10 04:54:10 2015
@@ -297,12 +297,14 @@ template <class Derived> class ARMReloca
     case R_ARM_MOVT_ABS:
     case R_ARM_THM_MOVW_ABS_NC:
     case R_ARM_THM_MOVT_ABS:
+      static_cast<Derived *>(this)->handlePlain(atom, ref);
+      break;
     case R_ARM_THM_CALL:
     case R_ARM_CALL:
     case R_ARM_JUMP24:
     case R_ARM_THM_JUMP24:
     case R_ARM_THM_JUMP11:
-      static_cast<Derived *>(this)->handleIFUNC(atom, ref);
+      static_cast<Derived *>(this)->handlePlain(atom, ref);
       static_cast<Derived *>(this)->handleVeneer(atom, ref);

I believe this static_cast is to eliminate vtable lookup, but do you think we really need this? This is not written by you nor me, so maybe neither of us can't answer to the question, but it feels like premature optimization to me.

       break;
     case R_ARM_TLS_IE32:
@@ -666,6 +668,11 @@ public:
   ARMStaticRelocationPass(const elf::ARMLinkingContext &ctx)
       : ARMRelocationPass(ctx) {}

+  /// \brief Handle ordinary relocation references.
+  std::error_code handlePlain(const DefinedAtom &atom, const Reference &ref) {
+    return handleIFUNC(atom, ref);
+  }
+
   /// \brief Get the veneer for ARM B/BL instructions.
   const VeneerAtom *getVeneer_ARM_B_BL(const DefinedAtom *da,
                                        StringRef secName) {
@@ -728,6 +735,11 @@ public:
   ARMDynamicRelocationPass(const elf::ARMLinkingContext &ctx)
       : ARMRelocationPass(ctx) {}

+  /// \brief Handle ordinary relocation references.
+  std::error_code handlePlain(const DefinedAtom &atom, const Reference &ref) {
+    return handleIFUNC(atom, ref);
+  }
+
   /// \brief Get the veneer for ARM B/BL instructions.
   const VeneerAtom *getVeneer_ARM_B_BL(const DefinedAtom *da,
                                        StringRef secName) {


_______________________________________________
llvm-commits mailing list
llvm-commits at cs.uiuc.edu<mailto: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/20150413/1c0174d8/attachment.html>


More information about the llvm-commits mailing list