summaryrefslogtreecommitdiffstats
path: root/contrib
diff options
context:
space:
mode:
authordim <dim@FreeBSD.org>2015-02-14 23:28:09 +0000
committerdim <dim@FreeBSD.org>2015-02-14 23:28:09 +0000
commit5230c023c35b53219103cefc307353a351ab0a36 (patch)
treeed6e851d001113d81632efba53c4b6e37920fa0f /contrib
parent74485ef712cdd63cb11490d4b91230105145a5de (diff)
downloadFreeBSD-src-5230c023c35b53219103cefc307353a351ab0a36.zip
FreeBSD-src-5230c023c35b53219103cefc307353a351ab0a36.tar.gz
Add clang patches corresponding to r278788.
Diffstat (limited to 'contrib')
-rw-r--r--contrib/llvm/patches/patch-r278788-clang-r201130-pch-miscompilation.diff67
1 files changed, 67 insertions, 0 deletions
diff --git a/contrib/llvm/patches/patch-r278788-clang-r201130-pch-miscompilation.diff b/contrib/llvm/patches/patch-r278788-clang-r201130-pch-miscompilation.diff
new file mode 100644
index 0000000..33d8db3
--- /dev/null
+++ b/contrib/llvm/patches/patch-r278788-clang-r201130-pch-miscompilation.diff
@@ -0,0 +1,67 @@
+Pull in r201130 from upstream clang trunk (by Ted Kremenek):
+
+ Fix PCH deserialization bug with local static symbols being treated
+ as local extern.
+
+ This triggered a miscompilation of code using Boost's
+ function_template.hpp when it was included inside a PCH file. A
+ local static within that header would be treated as local extern,
+ resulting in the wrong mangling. This only occurred during PCH
+ deserialization.
+
+ Fixes <rdar://problem/15975816> and <rdar://problem/15926311>.
+
+This fixes a crash in audio/murmur, which is using both PCH and Boost.
+
+Introduced here: http://svnweb.freebsd.org/changeset/base/278788
+
+Index: tools/clang/lib/Serialization/ASTReaderDecl.cpp
+===================================================================
+--- tools/clang/lib/Serialization/ASTReaderDecl.cpp
++++ tools/clang/lib/Serialization/ASTReaderDecl.cpp
+@@ -971,7 +971,7 @@ ASTDeclReader::RedeclarableResult ASTDeclReader::V
+ VD->setCachedLinkage(VarLinkage);
+
+ // Reconstruct the one piece of the IdentifierNamespace that we need.
+- if (VarLinkage != NoLinkage &&
++ if (VD->getStorageClass() == SC_Extern && VarLinkage != NoLinkage &&
+ VD->getLexicalDeclContext()->isFunctionOrMethod())
+ VD->setLocalExternDecl();
+
+Index: tools/clang/test/PCH/local_static.cpp
+===================================================================
+--- tools/clang/test/PCH/local_static.cpp
++++ tools/clang/test/PCH/local_static.cpp
+@@ -0,0 +1,20 @@
++// Test this without PCH.
++// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9.0 -include %S/local_static.h -fsyntax-only %s -emit-llvm -o %t.no_pch.ll %s
++// RUN: FileCheck --input-file %t.no_pch.ll %s
++
++// Test with PCH.
++// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9.0 -x c++-header -emit-pch -o %t.pch %S/local_static.h
++// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9.0 -include-pch %t.pch -emit-llvm -o %t.pch.ll %s
++// RUN: FileCheck --input-file %t.pch.ll %s
++
++void test(Bar &b) {
++ b.f<int>();
++ static int s;
++}
++
++// Check if the mangling of static and local extern variables
++// are correct and preserved by PCH.
++
++// CHECK: @_ZZ4testR3BarE1s = internal global i32 0, align 4
++// CHECK: @_ZZN3Bar1fIiEEvvE1y = linkonce_odr constant i32 0, align 4
++
+Index: tools/clang/test/PCH/local_static.h
+===================================================================
+--- tools/clang/test/PCH/local_static.h
++++ tools/clang/test/PCH/local_static.h
+@@ -0,0 +1,7 @@
++class Bar {
++public:
++ template<typename T>
++ void f() {
++ static const T y = 0;
++ }
++};
OpenPOWER on IntegriCloud