[PATCH] D48112: Simplify PPC64::calcEFlags().

Rui Ueyama via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 12 18:20:19 PDT 2018


ruiu created this revision.
ruiu added reviewers: sfertile, syzaara.
Herald added subscribers: kbarton, arichardson, nemanjai, emaste.
Herald added a reviewer: espindola.

In this file we only have to handle the v2 ABI, so what we need to do
is to just make sure that all object files have v2 or unspecified version
number.


https://reviews.llvm.org/D48112

Files:
  lld/ELF/Arch/PPC64.cpp


Index: lld/ELF/Arch/PPC64.cpp
===================================================================
--- lld/ELF/Arch/PPC64.cpp
+++ lld/ELF/Arch/PPC64.cpp
@@ -107,52 +107,28 @@
 }
 
 static uint32_t getEFlags(InputFile *File) {
-  // Get the e_flag from the input file and issue an error if incompatible
-  // e_flag encountered.
-  uint32_t EFlags;
   switch (Config->EKind) {
   case ELF64BEKind:
-    EFlags = cast<ObjFile<ELF64BE>>(File)->getObj().getHeader()->e_flags;
-    break;
+    return cast<ObjFile<ELF64BE>>(File)->getObj().getHeader()->e_flags;
   case ELF64LEKind:
-    EFlags = cast<ObjFile<ELF64LE>>(File)->getObj().getHeader()->e_flags;
-    break;
+    return cast<ObjFile<ELF64LE>>(File)->getObj().getHeader()->e_flags;
   default:
     llvm_unreachable("unknown Config->EKind");
   }
-  if (EFlags > 2) {
-    error("incompatible e_flags: " +  toString(File));
-    return 0;
-  }
-  return EFlags;
 }
 
+// This file implements v2 ABI. This function makes sure that all
+// object files have v2 or unspecified as an ABI version.
 uint32_t PPC64::calcEFlags() const {
   assert(!ObjectFiles.empty());
 
-  uint32_t NonZeroFlag;
-  for (InputFile *F : makeArrayRef(ObjectFiles)) {
-    NonZeroFlag = getEFlags(F);
-    if (NonZeroFlag)
-      break;
-  }
-
-  // Verify that all input files have either the same e_flags, or zero.
   for (InputFile *F : makeArrayRef(ObjectFiles)) {
     uint32_t Flag = getEFlags(F);
-    if (Flag == 0 || Flag == NonZeroFlag)
-      continue;
-    error(toString(F) + ": ABI version " + Twine(Flag) +
-          " is not compatible with ABI version " + Twine(NonZeroFlag) +
-          " output");
-    return 0;
-  }
-
-  if (NonZeroFlag == 1) {
-    error("PPC64 V1 ABI not supported");
-    return 0;
+    if (Flag != 0 && Flag != 2) {
+      error(toString(F) + ": ABI version " + Twine(Flag) + " is not supported");
+      return 0;
+    }
   }
-
   return 2;
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D48112.151080.patch
Type: text/x-patch
Size: 1920 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180613/385a3cb8/attachment-0001.bin>


More information about the llvm-commits mailing list