Commit d2934179 authored by serge-sans-paille's avatar serge-sans-paille
Browse files

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
parent d437fba8
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -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)
+2 −0
Original line number Diff line number Diff line
@@ -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;
+7 −0
Original line number Diff line number Diff line
@@ -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__