Fix #112933: Fix codegen issue on MSVC 17.7

MSVC 17.7 generates bad code in some lambda's, this has been reported
upstream [1], and a workaround has been suggested by MS in the form of
turning the inliner off. In consultation with the geo nodes people this
was deemed a passable solution, there was only a single call to this
method so performance wasn't a concern, so no special care had to be
taken to single out just the problematic MSVC versions.

If this bug pops up in other parts of our code where performance IS a
concern a more delicate approach may be required.

[1] https://developercommunity.visualstudio.com/t/10448291

Pull Request: https://projects.blender.org/blender/blender/pulls/112616
This commit is contained in:
Iliya Katueshenock
2023-09-29 16:57:02 +02:00
committed by Ray molenkamp
parent 7340bdaa92
commit 6c14764f32
2 changed files with 15 additions and 9 deletions

View File

@@ -40,6 +40,8 @@ template<typename T> static inline T decltype_helper(T x)
#if defined(__GNUC__)
# define BLI_NOINLINE __attribute__((noinline))
#elif defined(_MSC_VER)
# define BLI_NOINLINE __declspec(noinline)
#else
# define BLI_NOINLINE
#endif

View File

@@ -192,15 +192,19 @@ static Vector<CornerGroup> calc_corner_groups_for_vertex(const OffsetIndices<int
return groups;
}
/* Calculate groups of corners that are contiguously connected to each input vertex. */
static Array<Vector<CornerGroup>> calc_all_corner_groups(const OffsetIndices<int> faces,
const Span<int> corner_verts,
const Span<int> corner_edges,
const GroupedSpan<int> vert_to_corner_map,
const GroupedSpan<int> edge_to_corner_map,
const Span<int> corner_to_face_map,
const BitSpan split_edges,
const IndexMask &affected_verts)
/* Calculate groups of corners that are contiguously connected to each input vertex.
* BLI_NOINLINE because MSVC 17.7 has a codegen bug here, given there is only a single call to this
* function, not inlining it for all platforms won't affect performance. See
* https://developercommunity.visualstudio.com/t/10448291 for details. */
BLI_NOINLINE static Array<Vector<CornerGroup>> calc_all_corner_groups(
const OffsetIndices<int> faces,
const Span<int> corner_verts,
const Span<int> corner_edges,
const GroupedSpan<int> vert_to_corner_map,
const GroupedSpan<int> edge_to_corner_map,
const Span<int> corner_to_face_map,
const BitSpan split_edges,
const IndexMask &affected_verts)
{
Array<Vector<CornerGroup>> corner_groups(affected_verts.size(), NoInitialization());
affected_verts.foreach_index(GrainSize(512), [&](const int vert, const int mask) {