[llvm] 6b4a193 - [XCOFF][AIX] Put undefined symbol name into StringTable when neccessary

via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 21 10:18:49 PST 2020


Author: jasonliu
Date: 2020-02-21T18:18:31Z
New Revision: 6b4a193defbe59b2b93e9d0289b2a7d9c2d842b9

URL: https://github.com/llvm/llvm-project/commit/6b4a193defbe59b2b93e9d0289b2a7d9c2d842b9
DIFF: https://github.com/llvm/llvm-project/commit/6b4a193defbe59b2b93e9d0289b2a7d9c2d842b9.diff

LOG: [XCOFF][AIX] Put undefined symbol name into StringTable when neccessary

Summary:
When we have a long name for the undefined symbol, we would hit this assertion:
Assertion failed: I != StringIndexMap.end() && "String is not in table!"
This patch addresses that.

Reviewed by: DiggerLin, daltenty

Differential Revision: https://reviews.llvm.org/D74924

Added: 
    

Modified: 
    llvm/lib/MC/XCOFFObjectWriter.cpp
    llvm/test/CodeGen/PowerPC/aix-undef-func-call.ll

Removed: 
    


################################################################################
diff  --git a/llvm/lib/MC/XCOFFObjectWriter.cpp b/llvm/lib/MC/XCOFFObjectWriter.cpp
index 67202833cfba..17ec6dd06a8b 100644
--- a/llvm/lib/MC/XCOFFObjectWriter.cpp
+++ b/llvm/lib/MC/XCOFFObjectWriter.cpp
@@ -343,29 +343,27 @@ void XCOFFObjectWriter::executePostLayoutBinding(MCAssembler &Asm,
     const MCSymbolXCOFF *XSym = cast<MCSymbolXCOFF>(&S);
     const MCSectionXCOFF *ContainingCsect = XSym->getContainingCsect();
 
-    // Handle undefined symbol.
     if (ContainingCsect->getCSectType() == XCOFF::XTY_ER) {
+      // Handle undefined symbol.
       UndefinedCsects.emplace_back(ContainingCsect);
       SectionMap[ContainingCsect] = &UndefinedCsects.back();
-      continue;
-    }
-
-    // If the symbol is the csect itself, we don't need to put the symbol
-    // into csect's Syms.
-    if (XSym == ContainingCsect->getQualNameSymbol())
-      continue;
-
-    assert(SectionMap.find(ContainingCsect) != SectionMap.end() &&
-           "Expected containing csect to exist in map");
+    } else {
+      // If the symbol is the csect itself, we don't need to put the symbol
+      // into csect's Syms.
+      if (XSym == ContainingCsect->getQualNameSymbol())
+        continue;
 
-    // Lookup the containing csect and add the symbol to it.
-    SectionMap[ContainingCsect]->Syms.emplace_back(XSym);
+      assert(SectionMap.find(ContainingCsect) != SectionMap.end() &&
+             "Expected containing csect to exist in map");
+      // Lookup the containing csect and add the symbol to it.
+      SectionMap[ContainingCsect]->Syms.emplace_back(XSym);
+    }
 
     // If the name does not fit in the storage provided in the symbol table
     // entry, add it to the string table.
     if (nameShouldBeInStringTable(XSym->getName()))
       Strings.add(XSym->getName());
-    }
+  }
 
   Strings.finalize();
   assignAddressesAndIndices(Layout);

diff  --git a/llvm/test/CodeGen/PowerPC/aix-undef-func-call.ll b/llvm/test/CodeGen/PowerPC/aix-undef-func-call.ll
index 31d707c2ae9f..0c5a728e9850 100644
--- a/llvm/test/CodeGen/PowerPC/aix-undef-func-call.ll
+++ b/llvm/test/CodeGen/PowerPC/aix-undef-func-call.ll
@@ -4,10 +4,12 @@
 define void @bar() {
 entry:
   call void bitcast (void (...)* @foo to void ()*)()
+  call void bitcast (void (...)* @long_undef_name to void ()*)()
   ret void
 }
 
 declare void @foo(...)
+declare void @long_undef_name(...)
 
 ;CHECK: Symbol {
 ;CHECK:   Name: .foo
@@ -27,3 +29,21 @@ declare void @foo(...)
 ;CHECK-NEXT:     StabSectNum: 0x0
 ;CHECK-NEXT:   }
 ;CHECK-NEXT: }
+;CHECK: Symbol {
+;CHECK:   Name: .long_undef_name
+;CHECK-NEXT:   Value (RelocatableAddress): 0x0
+;CHECK-NEXT:   Section: N_UNDEF
+;CHECK-NEXT:   Type: 0x0
+;CHECK-NEXT:   StorageClass: C_EXT (0x2)
+;CHECK-NEXT:   NumberOfAuxEntries: 1
+;CHECK-NEXT:   CSECT Auxiliary Entry {
+;CHECK:          SectionLen: 0
+;CHECK-NEXT:     ParameterHashIndex: 0x0
+;CHECK-NEXT:     TypeChkSectNum: 0x0
+;CHECK-NEXT:     SymbolAlignmentLog2: 0
+;CHECK-NEXT:     SymbolType: XTY_ER (0x0)
+;CHECK-NEXT:     StorageMappingClass: XMC_PR (0x0)
+;CHECK-NEXT:     StabInfoIndex: 0x0
+;CHECK-NEXT:     StabSectNum: 0x0
+;CHECK-NEXT:   }
+;CHECK-NEXT: }


        


More information about the llvm-commits mailing list