[LLD] [COFF] Fix post-commit suggestions for absolute symbol equality
authorMartin Storsjö <martin@martin.st>
Mon, 6 Jan 2020 11:54:12 +0000 (13:54 +0200)
committerMartin Storsjö <martin@martin.st>
Wed, 8 Jan 2020 20:10:05 +0000 (22:10 +0200)
Differential Revision: https://reviews.llvm.org/D72252

lld/COFF/SymbolTable.cpp
lld/COFF/Symbols.h
lld/test/COFF/duplicate-absolute-same.s

index b6e180f..7072f4d 100644 (file)
@@ -592,7 +592,7 @@ Symbol *SymbolTable::addAbsolute(StringRef n, COFFSymbolRef sym) {
   if (wasInserted || isa<Undefined>(s) || s->isLazy())
     replaceSymbol<DefinedAbsolute>(s, n, sym);
   else if (auto *da = dyn_cast<DefinedAbsolute>(s)) {
-    if (!da->isEqual(sym))
+    if (da->getVA() != sym.getValue())
       reportDuplicate(s, nullptr);
   } else if (!isa<DefinedCOFF>(s))
     reportDuplicate(s, nullptr);
@@ -607,7 +607,7 @@ Symbol *SymbolTable::addAbsolute(StringRef n, uint64_t va) {
   if (wasInserted || isa<Undefined>(s) || s->isLazy())
     replaceSymbol<DefinedAbsolute>(s, n, va);
   else if (auto *da = dyn_cast<DefinedAbsolute>(s)) {
-    if (!da->isEqual(va))
+    if (da->getVA() != va)
       reportDuplicate(s, nullptr);
   } else if (!isa<DefinedCOFF>(s))
     reportDuplicate(s, nullptr);
index 2d74dea..a8e7032 100644 (file)
@@ -228,14 +228,7 @@ public:
 
   uint64_t getRVA() { return va - config->imageBase; }
   void setVA(uint64_t v) { va = v; }
-
-  bool isEqual(COFFSymbolRef s) const {
-    return va == s.getValue();
-  }
-
-  bool isEqual(uint64_t otherVa) const {
-    return va == otherVa;
-  }
+  uint64_t getVA() const { return va; }
 
   // Section index relocations against absolute symbols resolve to
   // this 16 bit number, and it is the largest valid section index
index e8c807c..81ec1f1 100644 (file)
@@ -2,9 +2,9 @@
 // RUN: llvm-mc -triple x86_64-windows-msvc -filetype obj -o %t.obj %s
 // RUN: echo -e ".globl myabsolute\nmyabsolute = 0" > %t.dupl.s
 // RUN: llvm-mc -triple x86_64-windows-msvc -filetype obj -o %t.dupl.obj %t.dupl.s
-// RUN: lld-link /out:%t.exe %t.obj %t.dupl.obj -subsystem:console -entry:entry 2>&1 | FileCheck --allow-empty %s
+// RUN: lld-link /out:%t.exe %t.obj %t.dupl.obj -subsystem:console -entry:entry 2>&1 | count 0
 
-// CHECK-NOT: error: duplicate symbol: myabsolute
+// This shouldn't produce any duplicate symbol error.
 
 .globl myabsolute
 myabsolute = 0