[PATCH] D72183: [ELF][PPC64] Add --lax-call-lacks-nop
Fangrui Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 3 15:58:33 PST 2020
MaskRay updated this revision to Diff 236145.
MaskRay added a comment.
Herald added subscribers: kbarton, nemanjai.
Add a hint. Add a test (we have to work around a MC deficiency)
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D72183/new/
https://reviews.llvm.org/D72183
Files:
lld/ELF/Config.h
lld/ELF/Driver.cpp
lld/ELF/InputSection.cpp
lld/ELF/Options.td
lld/test/ELF/ppc64-error-toc-tail-call.s
Index: lld/test/ELF/ppc64-error-toc-tail-call.s
===================================================================
--- lld/test/ELF/ppc64-error-toc-tail-call.s
+++ lld/test/ELF/ppc64-error-toc-tail-call.s
@@ -11,8 +11,7 @@
// RUN: not ld.lld %t.o %t2.so -o %t 2>&1 | FileCheck %s
# A tail call to an external function without a nop should issue an error.
-// CHECK: call to foo lacks nop, can't restore toc
-// CHECK-NOT: lacks nop
+// CHECK: call to foo lacks nop, can't restore toc{{$}}
.text
.abiversion 2
Index: lld/ELF/Options.td
===================================================================
--- lld/ELF/Options.td
+++ lld/ELF/Options.td
@@ -220,6 +220,10 @@
defm keep_unique: Eq<"keep-unique", "Do not fold this symbol during ICF">;
+def lax_call_lacks_nop : F<"lax-call-lacks-nop">,
+ HelpText<"(PowerPC64) Don't error on b/bl not followed by nop, if the target is "
+ "defined in the same file. This is for compatibility with GCC<5.4 and GCC<6.4">;
+
defm library: Eq<"library", "Root name of library to use">,
MetaVarName<"<libName>">;
Index: lld/ELF/InputSection.cpp
===================================================================
--- lld/ELF/InputSection.cpp
+++ lld/ELF/InputSection.cpp
@@ -975,13 +975,16 @@
// gcc/gfortran 5.4, 6.3 and earlier versions do not add nop for
// recursive calls even if the function is preemptible. This is not
// wrong in the common case where the function is not preempted at
- // runtime. Just ignore.
+ // runtime. Just ignore if --lax-call-lacks-nop is specified.
if ((bufLoc + 8 > bufEnd || read32(bufLoc + 4) != 0x60000000) &&
- rel.sym->file != file) {
+ !(config->laxCallLacksNop && rel.sym->file == file)) {
+ std::string hint;
+ if (rel.sym->file == file)
+ hint = "; pass -Wl,--lax-call-lacks-nop to ignore the error";
// Use substr(6) to remove the "__plt_" prefix.
errorOrWarn(getErrorLocation(bufLoc) + "call to " +
lld::toString(*rel.sym).substr(6) +
- " lacks nop, can't restore toc");
+ " lacks nop, can't restore toc" + hint);
break;
}
write32(bufLoc + 4, 0xe8410018); // ld %r2, 24(%r1)
Index: lld/ELF/Driver.cpp
===================================================================
--- lld/ELF/Driver.cpp
+++ lld/ELF/Driver.cpp
@@ -887,6 +887,7 @@
config->ignoreFunctionAddressEquality =
args.hasArg(OPT_ignore_function_address_equality);
config->init = args.getLastArgValue(OPT_init, "_init");
+ config->laxCallLacksNop = args.hasArg(OPT_lax_call_lacks_nop);
config->ltoAAPipeline = args.getLastArgValue(OPT_lto_aa_pipeline);
config->ltoCSProfileGenerate = args.hasArg(OPT_lto_cs_profile_generate);
config->ltoCSProfileFile = args.getLastArgValue(OPT_lto_cs_profile_file);
Index: lld/ELF/Config.h
===================================================================
--- lld/ELF/Config.h
+++ lld/ELF/Config.h
@@ -148,6 +148,7 @@
bool emitLLVM;
bool emitRelocs;
bool enableNewDtags;
+ bool errorCallLacksNop;
bool executeOnly;
bool exportDynamic;
bool fixCortexA53Errata843419;
@@ -163,6 +164,7 @@
bool hasDynSymTab;
bool ignoreDataAddressEquality;
bool ignoreFunctionAddressEquality;
+ bool laxCallLacksNop;
bool ltoCSProfileGenerate;
bool ltoDebugPassManager;
bool ltoNewPassManager;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D72183.236145.patch
Type: text/x-patch
Size: 3477 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200103/2dc1bc59/attachment.bin>
More information about the llvm-commits
mailing list