diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2014-08-11 17:07:34 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2014-08-11 17:07:34 +0000 |
commit | b16196a3e0a1daea9d77415d3db24c9ae86a306b (patch) | |
tree | d62d531a5b9d51c2673091bfc67187741e4eee38 | |
parent | 2ef3f299d5debeba26aac0c50c1727c7a7ac4038 (diff) | |
download | bcm5719-llvm-b16196a3e0a1daea9d77415d3db24c9ae86a306b.tar.gz bcm5719-llvm-b16196a3e0a1daea9d77415d3db24c9ae86a306b.zip |
Fix use of uninitialized variable.
Fixes linking bitcode files that use the new style comdats for constructors
with ones that don't.
llvm-svn: 215364
-rw-r--r-- | llvm/lib/Linker/LinkModules.cpp | 8 | ||||
-rw-r--r-- | llvm/test/Linker/Inputs/constructor-comdat.ll | 7 | ||||
-rw-r--r-- | llvm/test/Linker/constructor-comdat.ll | 13 |
3 files changed, 26 insertions, 2 deletions
diff --git a/llvm/lib/Linker/LinkModules.cpp b/llvm/lib/Linker/LinkModules.cpp index 1f4c3c13238..1748af47402 100644 --- a/llvm/lib/Linker/LinkModules.cpp +++ b/llvm/lib/Linker/LinkModules.cpp @@ -644,15 +644,19 @@ bool ModuleLinker::computeResultingSelectionKind(StringRef ComdatName, 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); diff --git a/llvm/test/Linker/Inputs/constructor-comdat.ll b/llvm/test/Linker/Inputs/constructor-comdat.ll new file mode 100644 index 00000000000..b5f23da9035 --- /dev/null +++ b/llvm/test/Linker/Inputs/constructor-comdat.ll @@ -0,0 +1,7 @@ +define weak_odr void @_ZN3fooIiEC2Ev() { + ret void +} + +define weak_odr void @_ZN3fooIiEC1Ev() { + ret void +} diff --git a/llvm/test/Linker/constructor-comdat.ll b/llvm/test/Linker/constructor-comdat.ll new file mode 100644 index 00000000000..42e2d83424a --- /dev/null +++ b/llvm/test/Linker/constructor-comdat.ll @@ -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 + +@_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 +} |