This is an archive of the discontinued LLVM Phabricator instance.

[windows] Don't inline fieldFromInstruction on Windows
ClosedPublic

Authored by stella.stamenova on Jul 24 2018, 1:17 PM.

Details

Summary

The VS compiler (on Windows) has a bug which results in fieldFromInstruction being optimized out in some circumstances. This only happens in *release no debug info* builds that have assertions *turned off* - in all other situations the function is not inlined, so the functionality is correct. All of the bots have assertions turned on, so this path is not regularly tested. The workaround is to not inline the function on Windows - if the bug is fixed in a later release of the VS compiler, the noinline specification can be removed.

The test that consistently reproduces this is Lanai v11.txt test.

Diff Detail

Repository
rL LLVM

Event Timeline

Does this currently affect all shipping versions of msvc? How come I’ve
never encountered it? Am i not running this test?

I don't know if it impacts all shipping versions since we only test with the latest versions. I would suspect that you either build with assertions set to ON or you include debug information when you build. Here's the CMAKE command line that reproduces this:

-DCMAKE_BUILD_TYPE=Release -G "Visual Studio 15 2017 Win64" -Thost=x64 -DLLVM_ENABLE_ASSERTIONS=OFF

I don’t use the vs generator and I don’t explicitly pass enable assertions

off (isn’t that the default for release builds)? I do build release

builds with no debug info though.

Note that clang-cl probably doesn’t have this bug, so the check should
probably be _MSC_VER && !clang

Do you build all targets? You could try explicitly running the test to see if it passes. It's a consistent repro for us.

Ahh I always pass LLVM_TARGETS_TO_BUILD=X86, that must be it (btw, that
cuts build time down a lot)

Follow Zachary's advise and do not force no inline in the case of clang.

Can you add a comment explaining why this is necessary? Other than that,
lgtm. Feel free to submit after adding the comment

I also filed a bug to reference.

This revision was not accepted when it landed; it landed in state Needs Review.Jul 25 2018, 10:33 AM
This revision was automatically updated to reflect the committed changes.