[llvm] r241103 - COFF: Do not assign linker-weak symbols to selectany comdat sections.
Peter Collingbourne
peter at pcc.me.uk
Tue Jun 30 12:10:32 PDT 2015
Author: pcc
Date: Tue Jun 30 14:10:31 2015
New Revision: 241103
URL: http://llvm.org/viewvc/llvm-project?rev=241103&view=rev
Log:
COFF: Do not assign linker-weak symbols to selectany comdat sections.
It is mandatory to specify a comdat in order to receive comdat semantics
for a symbol. We were previously getting this wrong in -function-sections
mode; linker-weak symbols were being emitted in a selectany comdat. This
change causes such symbols to use a noduplicates comdat instead, fixing
the inconsistency.
Also correct an inaccuracy in the docs.
Differential Revision: http://reviews.llvm.org/D10828
Added:
llvm/trunk/test/CodeGen/X86/coff-weak.ll
Modified:
llvm/trunk/docs/LangRef.rst
llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
Modified: llvm/trunk/docs/LangRef.rst
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/LangRef.rst?rev=241103&r1=241102&r2=241103&view=diff
==============================================================================
--- llvm/trunk/docs/LangRef.rst (original)
+++ llvm/trunk/docs/LangRef.rst Tue Jun 30 14:10:31 2015
@@ -823,9 +823,11 @@ with the same name. This is necessary b
COMDAT groups and COMDATs, at the object file level, are represented by
sections.
-Note that certain IR constructs like global variables and functions may create
-COMDATs in the object file in addition to any which are specified using COMDAT
-IR. This arises, for example, when a global variable has linkonce_odr linkage.
+Note that certain IR constructs like global variables and functions may
+create COMDATs in the object file in addition to any which are specified using
+COMDAT IR. This arises when the code generator is configured to emit globals
+in individual sections (e.g. when `-data-sections` or `-function-sections`
+is supplied to `llc`).
.. _namedmetadatastructure:
Modified: llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp?rev=241103&r1=241102&r2=241103&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp (original)
+++ llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp Tue Jun 30 14:10:31 2015
@@ -840,8 +840,6 @@ static int getSelectionForCOFF(const Glo
} else {
return COFF::IMAGE_COMDAT_SELECT_ASSOCIATIVE;
}
- } else if (GV->isWeakForLinker()) {
- return COFF::IMAGE_COMDAT_SELECT_ANY;
}
return 0;
}
Added: llvm/trunk/test/CodeGen/X86/coff-weak.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/coff-weak.ll?rev=241103&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/X86/coff-weak.ll (added)
+++ llvm/trunk/test/CodeGen/X86/coff-weak.ll Tue Jun 30 14:10:31 2015
@@ -0,0 +1,9 @@
+; RUN: llc -function-sections -o - %s | FileCheck %s
+
+target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-pc-windows-msvc"
+
+; CHECK: .section{{.*}}one_only
+define linkonce_odr void @foo() {
+ ret void
+}
More information about the llvm-commits
mailing list