[PATCH] D70570: [PowerPC] Only use PLT annotations if using PIC relocation model

Sean Fertile via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 10 12:57:06 PST 2019


sfertile added a comment.

@MaskRay , @jhibbits Thank you for providing the correct ABI doc, and for the answers.  I'll start going through it.

In D70570#1777864 <https://reviews.llvm.org/D70570#1777864>, @jhibbits wrote:

> @Bdragon28 we might need to use -mlongcall for modules, if we aren't already.  This should(?) force the compiler to generate the appropriate long-distance code sequences.  I'm not sure, though, if clang supports this yet.


Clang does support it, there is a test `test/Driver/ppc-features.cpp`. Only calls where the callee is a `GlobalAddressSDNode` are transformed though. `ExternalSymbolSDNode` callees might need to be transformed as well: For example I believe the selection dag can create calls to memcpy/memset/memmove where the callee is an ExternalSymbolSDNode.  Is transforming every call into a direct call overkill though? Would it be possible to perform a direct all to any local callee, and indirect calls for external symbols?

IIUC this patch is a pretty drastic change. Take fopr example the following IR:

  target datalayout = "E-m:e-p:32:32-i64:64-n32"
  target triple = "powerpc-unknown-linux-gnu-unknown"
  
  @Dst = external global [512 x i32], align 4
  @Src = external global [512 x i32], align 4
  define dso_local void @caller(i32 %i) local_unnamed_addr {
  entry:
    %call = tail call i8* @memcpy(i8* bitcast ([512 x i32]* @Dst to i8*), i8* bitcast ([512 x i32]* @Src to i8*), i32 %i)
    ret void
  }
  declare i8* @memcpy(i8*, i8*, i32) local_unnamed_addr
  
  !llvm.module.flags = !{!0}
  !0 = !{i32 1, !"wchar_size", i32 4}

Will now produce: `bl memcpy` instead of `bl memcpy at PLT`

Combined with:

In D70570#1777864 <https://reviews.llvm.org/D70570#1777864>, @jhibbits wrote:

> - It is an error to not use a PLTREL relocation for a call that needs to be indirected through the PLT.  The linker will complain to recompile with -fPIC.


Means you can't link static execs against shared objects anymore. Is this the intent? Or am I missing something obvious?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D70570/new/

https://reviews.llvm.org/D70570





More information about the llvm-commits mailing list