[Bf-blender-cvs] [2ddecfffc3d] blender-v2.91-release: Fix T81077 id_management test on macOS
Ankit Meel
noreply at git.blender.org
Mon Oct 26 10:33:09 CET 2020
Commit: 2ddecfffc3d3a3a1db4ae45e8665caa2a85ab43a
Author: Ankit Meel
Date: Mon Oct 26 15:02:20 2020 +0530
Branches: blender-v2.91-release
https://developer.blender.org/rB2ddecfffc3d3a3a1db4ae45e8665caa2a85ab43a
Fix T81077 id_management test on macOS
This looks like a optimizer bug where it makes wrong assumptions.
The code inside lib_id_delete:264 on rBafd13710b897cc1c11b
`for (id = last_remapped_id->next; id; id = id->next) {..}`
is not executed in release/relwithdebinfo builds.
This can be "fixed" by several ways:
- Adding a line that prints the `last_remapped_id->name` right before
the said for-loop starts.
- Turning off optimization for the whole function `id_delete`:
`#pragma clang optimize off/on` Ray Molenkamp
- Marking `last_remapped_id` volatile. Julian Eisel
- Marking `tagged_deleted_ids` volatile. But it adds a warning when
calling `BLI_addtail`: discards volatile qualifier. Discovered by
accident.
Fix T81077
Reviewed By: mont29
Maniphest Tasks: T81077
Differential Revision: https://developer.blender.org/D9315
===================================================================
M source/blender/blenkernel/intern/lib_id_delete.c
===================================================================
diff --git a/source/blender/blenkernel/intern/lib_id_delete.c b/source/blender/blenkernel/intern/lib_id_delete.c
index 1e45a3c1163..25c48479ef9 100644
--- a/source/blender/blenkernel/intern/lib_id_delete.c
+++ b/source/blender/blenkernel/intern/lib_id_delete.c
@@ -261,7 +261,9 @@ static void id_delete(Main *bmain, const bool do_tagged_deletion)
bool keep_looping = true;
while (keep_looping) {
ID *id, *id_next;
- ID *last_remapped_id = tagged_deleted_ids.last;
+ /* Marked volatile to avoid a macOS Clang optimization bug. See T81077.
+ * #last_remapped_id.next is assumed to be NULL by optimizer which is wrong. */
+ volatile ID *last_remapped_id = tagged_deleted_ids.last;
keep_looping = false;
/* First tag and remove from Main all datablocks directly from target lib.
More information about the Bf-blender-cvs
mailing list