Commit 96c1332e authored by scottmg@chromium.org's avatar scottmg@chromium.org

Simpler memset, avoids ICE on VS2013 Update2

The previous code is causing:

FAILED: ninja -t msvc -e environment.x86 -- C:\b\build\goma/gomacc "C:\b\depot_tools\win_toolchain\vs2013_files\VC\bin\amd64_x86\cl.exe" /nologo /showIncludes /FC @obj\chrome\installer\mini_installer\mini_installer.mini_installer.obj.rsp /c ..\..\chrome\installer\mini_installer\mini_installer.cc /Foobj\chrome\installer\mini_installer\mini_installer.mini_installer.obj /Fdobj\chrome\installer\mini_installer.cc.pdb
c:\b\build\slave\win-latest-rel\build\src\chrome\installer\mini_installer\mini_installer.cc(857) : fatalerror C1001: An internal error has occurred in the compiler.
(compiler file 'f:\dd\vctools\compiler\utc\src\p2\main.c', line 228)
 To work around this problem, try simplifying or changing the program near the locations listed above.
Please choose the Technical Support command on the Visual C++
 Help menu, or open the Technical Support help file for more information
INTERNAL COMPILER ERROR in 'C:\b\depot_tools\win_toolchain\vs2013_files\VC\bin\amd64_x86\cl.exe'
    Please choose the Technical Support command on the Visual C++
    Help menu, or open the Technical Support help file for more information

after Update 2. The CRT's implementation looks like the simple char
loop, so simplify here too.

In practice, I think this will only rarely get used, as the compiler
is allowed to "know" what memset does and replace it with an optimized
version.

There's an upstream bug filed here: https://connect.microsoft.com/VisualStudio/feedback/details/878340/ice-on-memset-implementation-at-o2

R=grt@chromium.org
BUG=372451

Review URL: https://codereview.chromium.org/294943005

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@271919 0039d316-1c4b-4281-b951-d872f2087c98
parent af0fb48d
......@@ -834,29 +834,11 @@ int MainEntryPoint() {
extern "C" {
#pragma function(memset)
void* memset(void* dest, int c, size_t count) {
// Simplistic 32-bit memset C implementation which assumes properly aligned
// memory; performance hit on memory that isn't properly aligned, but still
// better overall then a 8-bit implementation.
size_t adjcount = count >> 2;
UINT32 fill = (c << 24 | c << 16 | c << 8 | c);
UINT32* dest32 = reinterpret_cast<UINT32*>(dest);
UINT8* dest8 = reinterpret_cast<UINT8*>(dest);
// Take care of the ending 0-3 bytes (binary 11 = 3). The lack of breaks is
// deliberate; it falls through for each byte. Think of it a simplified for
// loop.
switch (count - (adjcount << 2)) {
case 3:
dest8[count - 3] = c;
case 2:
dest8[count - 2] = c;
case 1:
dest8[count - 1] = c;
void* start = dest;
while (count--) {
*reinterpret_cast<char*>(dest) = static_cast<char>(c);
dest = reinterpret_cast<char*>(dest) + 1;
}
while (adjcount-- > 0) // Copy the rest, 4 bytes/32 bits at a time
*(dest32++) = fill;
return dest;
return start;
}
} // extern "C"
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment