[all-commits] [llvm/llvm-project] f5c5bc: [CodeGen][ObjC] Invalidate cached ObjC class layou...
Akira Hatanaka via All-commits
all-commits at lists.llvm.org
Mon Feb 17 11:51:05 PST 2025
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: f5c5bc5ed57e63fe11ddd58c4b392f27b86730f1
https://github.com/llvm/llvm-project/commit/f5c5bc5ed57e63fe11ddd58c4b392f27b86730f1
Author: Akira Hatanaka <ahatanak at gmail.com>
Date: 2025-02-17 (Mon, 17 Feb 2025)
Changed paths:
M clang/include/clang/AST/ASTContext.h
M clang/lib/AST/ASTContext.cpp
M clang/lib/AST/RecordLayoutBuilder.cpp
M clang/lib/CodeGen/CGObjCGNU.cpp
M clang/lib/CodeGen/CGObjCMac.cpp
M clang/lib/CodeGen/CGObjCRuntime.cpp
M clang/lib/Sema/SemaDeclObjC.cpp
M clang/test/CodeGenObjC/constant-non-fragile-ivar-offset.m
M clang/test/CodeGenObjC/ivar-layout-64.m
Log Message:
-----------
[CodeGen][ObjC] Invalidate cached ObjC class layout information after parsing ObjC class implementations if new ivars are added to the interface (#126591)
The layout and the size of an ObjC interface can change after its
corresponding implementation is parsed when synthesized ivars or ivars
declared in categories are added to the interface's list of ivars. This
can cause clang to mis-compile if the optimization that emits fixed
offsets for ivars (see 923ddf65f4e21ec67018cf56e823895de18d83bc) uses an
ObjC class layout that is outdated and no longer reflects the current
state of the class.
For example, when compiling `constant-non-fragile-ivar-offset.m`, clang
emits 20 instead of 24 as the offset for `IntermediateClass2Property` as
the class layout for `SuperClass2`, which is created when the
implementation of IntermediateClass3 is parsed, is outdated when the
implementation of `IntermediateClass2` is parsed.
This commit invalidates the stale layout information of the class and
its subclasses if new ivars are added to the interface.
With this change, we can also stop using ObjC implementation decls as
the key to retrieve ObjC class layouts information as the layout
retrieved using the ObjC interface as the key will always be up to date.
rdar://139531391
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list