[llvm] r323483 - [CodeGen] Ignore private symbols in llvm.used for COFF

Shoaib Meenai via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 25 16:15:25 PST 2018


Author: smeenai
Date: Thu Jan 25 16:15:25 2018
New Revision: 323483

URL: http://llvm.org/viewvc/llvm-project?rev=323483&view=rev
Log:
[CodeGen] Ignore private symbols in llvm.used for COFF

Similar to the existing handling for internal symbols, private symbols
are also not visible to the linker and should be ignored.

Modified:
    llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
    llvm/trunk/test/CodeGen/X86/coff-no-dead-strip.ll

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp?rev=323483&r1=323482&r2=323483&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Thu Jan 25 16:15:25 2018
@@ -1456,10 +1456,10 @@ bool AsmPrinter::doFinalization(Module &
         for (const Value *Op : A->operands()) {
           const auto *GV =
               cast<GlobalValue>(Op->stripPointerCastsNoFollowAliases());
-          // Global symbols with internal linkage are not visible to the linker,
-          // and thus would cause an error when the linker tried to preserve the
-          // symbol due to the `/include:` directive.
-          if (GV->hasInternalLinkage())
+          // Global symbols with internal or private linkage are not visible to
+          // the linker, and thus would cause an error when the linker tried to
+          // preserve the symbol due to the `/include:` directive.
+          if (GV->hasInternalLinkage() || GV->hasPrivateLinkage())
             continue;
 
           raw_string_ostream OS(Flags);

Modified: llvm/trunk/test/CodeGen/X86/coff-no-dead-strip.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/coff-no-dead-strip.ll?rev=323483&r1=323482&r2=323483&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/X86/coff-no-dead-strip.ll (original)
+++ llvm/trunk/test/CodeGen/X86/coff-no-dead-strip.ll Thu Jan 25 16:15:25 2018
@@ -5,15 +5,18 @@
 @j = weak global i32 0
 @k = internal global i32 0
 declare x86_vectorcallcc void @l()
+ at m = private global i32 0
 
- at llvm.used = appending global [4 x i8*] [i8* bitcast (i32* @i to i8*), i8* bitcast (i32* @j to i8*), i8* bitcast (i32* @k to i8*), i8* bitcast (void ()* @l to i8*)]
+ at llvm.used = appending global [5 x i8*] [i8* bitcast (i32* @i to i8*), i8* bitcast (i32* @j to i8*), i8* bitcast (i32* @k to i8*), i8* bitcast (void ()* @l to i8*), i8* bitcast (i32* @m to i8*)]
 
 ; CHECK: .section .drectve
 ; CHECK-ULP: .ascii " /INCLUDE:_i"
 ; CHECK-ULP: .ascii " /INCLUDE:_j"
 ; CHECK-ULP-NOT: .ascii " /INCLUDE:_k"
+; CHECK-ULP-NOT: .ascii " /INCLUDE:L_m"
 ; CHECK-NOULP: .ascii " /INCLUDE:i"
 ; CHECK-NOULP: .ascii " /INCLUDE:j"
 ; CHECK-NOULP-NOT: .ascii " /INCLUDE:k"
+; CHECK-NOULP-NOT: .ascii " /INCLUDE:.Lm"
 ; CHECK: .ascii " /INCLUDE:l@@0"
 




More information about the llvm-commits mailing list