diff options
-rw-r--r-- | lib/Linker/LinkModules.cpp | 6 | ||||
-rw-r--r-- | test/Linker/unnamed-addr-err-a.ll | 4 | ||||
-rw-r--r-- | test/Linker/unnamed-addr-err-b.ll | 4 |
3 files changed, 13 insertions, 1 deletions
diff --git a/lib/Linker/LinkModules.cpp b/lib/Linker/LinkModules.cpp index 16e2851..4fffa55 100644 --- a/lib/Linker/LinkModules.cpp +++ b/lib/Linker/LinkModules.cpp @@ -704,7 +704,11 @@ bool ModuleLinker::linkAppendingVarProto(GlobalVariable *DstGV, if (DstGV->getVisibility() != SrcGV->getVisibility()) return emitError( "Appending variables with different visibility need to be linked!"); - + + if (DstGV->hasUnnamedAddr() != SrcGV->hasUnnamedAddr()) + return emitError( + "Appending variables with different unnamed_addr need to be linked!"); + if (DstGV->getSection() != SrcGV->getSection()) return emitError( "Appending variables with different section name need to be linked!"); diff --git a/test/Linker/unnamed-addr-err-a.ll b/test/Linker/unnamed-addr-err-a.ll new file mode 100644 index 0000000..4872098 --- /dev/null +++ b/test/Linker/unnamed-addr-err-a.ll @@ -0,0 +1,4 @@ +; RUN: not llvm-link %s %p/unnamed-addr-err-b.ll -S -o - 2>&1 | FileCheck %s + +@foo = appending unnamed_addr global [1 x i32] [i32 42] +; CHECK: Appending variables with different unnamed_addr need to be linked diff --git a/test/Linker/unnamed-addr-err-b.ll b/test/Linker/unnamed-addr-err-b.ll new file mode 100644 index 0000000..5e5fed9 --- /dev/null +++ b/test/Linker/unnamed-addr-err-b.ll @@ -0,0 +1,4 @@ +; This file is for use with unnamed-addr-err-a.ll +; RUN: true + +@foo = appending global [1 x i32] [i32 42] |