summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
authorserge-sans-paille <sguelton@redhat.com>2020-01-16 21:53:32 +0100
committerserge-sans-paille <sguelton@redhat.com>2020-01-17 10:01:55 +0100
commitcd4c65f91d5a77de28239979b772a8022dc6627a (patch)
tree2d3dfcd70f26f427d0128444cf21dc4d9fc27b21 /clang
parent2d2d057ae23036baecb5a2a4a7f929626f46921a (diff)
downloadbcm5719-llvm-cd4c65f91d5a77de28239979b772a8022dc6627a.tar.gz
bcm5719-llvm-cd4c65f91d5a77de28239979b772a8022dc6627a.zip
Add __warn_memset_zero_len builtin as a workaround for glibc issue
Glibc issue: https://sourceware.org/bugzilla/show_bug.cgi?id=25399 The fix consist in considering the missing function as a builtin lowered to a nop. Differential Revision: https://reviews.llvm.org/D72869 (cherry picked from commit d293417931d3a9d46799b42795988ca3b5cfd766)
Diffstat (limited to 'clang')
-rw-r--r--clang/include/clang/Basic/Builtins.def3
-rw-r--r--clang/lib/CodeGen/CGBuiltin.cpp2
-rw-r--r--clang/test/CodeGen/builtins.c7
3 files changed, 12 insertions, 0 deletions
diff --git a/clang/include/clang/Basic/Builtins.def b/clang/include/clang/Basic/Builtins.def
index d388afe7fae..1a6c85ce2dd 100644
--- a/clang/include/clang/Basic/Builtins.def
+++ b/clang/include/clang/Basic/Builtins.def
@@ -788,6 +788,9 @@ BUILTIN(__builtin_abort, "v", "Fnr")
BUILTIN(__builtin_index, "c*cC*i", "Fn")
BUILTIN(__builtin_rindex, "c*cC*i", "Fn")
+// ignored glibc builtin, see https://sourceware.org/bugzilla/show_bug.cgi?id=25399
+BUILTIN(__warn_memset_zero_len, "v", "nU")
+
// Microsoft builtins. These are only active with -fms-extensions.
LANGBUILTIN(_alloca, "v*z", "n", ALL_MS_LANGUAGES)
LANGBUILTIN(__annotation, "wC*.","n", ALL_MS_LANGUAGES)
diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 09fd3087b49..2d20f92fbb3 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -3222,6 +3222,8 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID,
Builder.CreateZExt(EmitSignBit(*this, EmitScalarExpr(E->getArg(0))),
ConvertType(E->getType())));
}
+ case Builtin::BI__warn_memset_zero_len:
+ return RValue::getIgnored();
case Builtin::BI__annotation: {
// Re-encode each wide string to UTF8 and make an MDString.
SmallVector<Metadata *, 1> Strings;
diff --git a/clang/test/CodeGen/builtins.c b/clang/test/CodeGen/builtins.c
index 591416d00cc..9f2a74f6c87 100644
--- a/clang/test/CodeGen/builtins.c
+++ b/clang/test/CodeGen/builtins.c
@@ -453,6 +453,13 @@ void test_builtin_launder(int *p) {
int *d = __builtin_launder(p);
}
+// __warn_memset_zero_len should be NOP, see https://sourceware.org/bugzilla/show_bug.cgi?id=25399
+// CHECK-LABEL: define void @test___warn_memset_zero_len
+void test___warn_memset_zero_len() {
+ // CHECK-NOT: @__warn_memset_zero_len
+ __warn_memset_zero_len();
+}
+
// Behavior of __builtin_os_log differs between platforms, so only test on X86
#ifdef __x86_64__
OpenPOWER on IntegriCloud