[llvm-branch-commits] [clang] cd4c65f - Add __warn_memset_zero_len builtin as a workaround for glibc issue
via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Fri Jan 17 01:03:09 PST 2020
Author: serge-sans-paille
Date: 2020-01-17T10:01:55+01:00
New Revision: cd4c65f91d5a77de28239979b772a8022dc6627a
URL: https://github.com/llvm/llvm-project/commit/cd4c65f91d5a77de28239979b772a8022dc6627a
DIFF: https://github.com/llvm/llvm-project/commit/cd4c65f91d5a77de28239979b772a8022dc6627a.diff
LOG: 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)
Added:
Modified:
clang/include/clang/Basic/Builtins.def
clang/lib/CodeGen/CGBuiltin.cpp
clang/test/CodeGen/builtins.c
Removed:
################################################################################
diff --git a/clang/include/clang/Basic/Builtins.def b/clang/include/clang/Basic/Builtins.def
index d388afe7fae6..1a6c85ce2dd3 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 09fd3087b494..2d20f92fbb3d 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 591416d00cc7..9f2a74f6c873 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
diff ers between platforms, so only test on X86
#ifdef __x86_64__
More information about the llvm-branch-commits
mailing list