[llvm] r215364 - Fix use of uninitialized variable.
Rafael Espindola
rafael.espindola at gmail.com
Mon Aug 11 10:07:34 PDT 2014
Author: rafael
Date: Mon Aug 11 12:07:34 2014
New Revision: 215364
URL: http://llvm.org/viewvc/llvm-project?rev=215364&view=rev
Log:
Fix use of uninitialized variable.
Fixes linking bitcode files that use the new style comdats for constructors
with ones that don't.
Added:
llvm/trunk/test/Linker/Inputs/constructor-comdat.ll
llvm/trunk/test/Linker/constructor-comdat.ll
Modified:
llvm/trunk/lib/Linker/LinkModules.cpp
Modified: llvm/trunk/lib/Linker/LinkModules.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Linker/LinkModules.cpp?rev=215364&r1=215363&r2=215364&view=diff
==============================================================================
--- llvm/trunk/lib/Linker/LinkModules.cpp (original)
+++ llvm/trunk/lib/Linker/LinkModules.cpp Mon Aug 11 12:07:34 2014
@@ -644,15 +644,19 @@ bool ModuleLinker::computeResultingSelec
bool ModuleLinker::getComdatResult(const Comdat *SrcC,
Comdat::SelectionKind &Result,
bool &LinkFromSrc) {
+ Comdat::SelectionKind SSK = SrcC->getSelectionKind();
StringRef ComdatName = SrcC->getName();
Module::ComdatSymTabType &ComdatSymTab = DstM->getComdatSymbolTable();
Module::ComdatSymTabType::iterator DstCI = ComdatSymTab.find(ComdatName);
- if (DstCI == ComdatSymTab.end())
+ if (DstCI == ComdatSymTab.end()) {
+ // Use the comdat if it is only available in one of the modules.
+ LinkFromSrc = true;
+ Result = SSK;
return false;
+ }
const Comdat *DstC = &DstCI->second;
- Comdat::SelectionKind SSK = SrcC->getSelectionKind();
Comdat::SelectionKind DSK = DstC->getSelectionKind();
return computeResultingSelectionKind(ComdatName, SSK, DSK, Result,
LinkFromSrc);
Added: llvm/trunk/test/Linker/Inputs/constructor-comdat.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Linker/Inputs/constructor-comdat.ll?rev=215364&view=auto
==============================================================================
--- llvm/trunk/test/Linker/Inputs/constructor-comdat.ll (added)
+++ llvm/trunk/test/Linker/Inputs/constructor-comdat.ll Mon Aug 11 12:07:34 2014
@@ -0,0 +1,7 @@
+define weak_odr void @_ZN3fooIiEC2Ev() {
+ ret void
+}
+
+define weak_odr void @_ZN3fooIiEC1Ev() {
+ ret void
+}
Added: llvm/trunk/test/Linker/constructor-comdat.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Linker/constructor-comdat.ll?rev=215364&view=auto
==============================================================================
--- llvm/trunk/test/Linker/constructor-comdat.ll (added)
+++ llvm/trunk/test/Linker/constructor-comdat.ll Mon Aug 11 12:07:34 2014
@@ -0,0 +1,13 @@
+; RUN: llvm-link %s %p/Inputs/constructor-comdat.ll -S -o - 2>&1 | FileCheck %s
+; RUN: llvm-link %p/Inputs/constructor-comdat.ll %s -S -o - 2>&1 | FileCheck %s
+
+$_ZN3fooIiEC5Ev = comdat any
+; CHECK: $_ZN3fooIiEC5Ev = comdat any
+
+ at _ZN3fooIiEC1Ev = weak_odr alias void ()* @_ZN3fooIiEC2Ev
+; CHECK: @_ZN3fooIiEC1Ev = weak_odr alias void ()* @_ZN3fooIiEC2Ev
+
+; CHECK: define weak_odr void @_ZN3fooIiEC2Ev() comdat $_ZN3fooIiEC5Ev {
+define weak_odr void @_ZN3fooIiEC2Ev() comdat $_ZN3fooIiEC5Ev {
+ ret void
+}
More information about the llvm-commits
mailing list