Skip to content

[Clang][CodeGen] Fix bad codegen when building Clang with latest MSVC #102681

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions clang/lib/CodeGen/CGObjCGNU.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2092,10 +2092,15 @@ class CGObjCGNUstep2 : public CGObjCGNUstep {
auto *classStart =
llvm::StructType::get(PtrTy, PtrTy, PtrTy, LongTy, LongTy);
auto &astContext = CGM.getContext();
auto flags = Builder.CreateLoad(
Address{Builder.CreateStructGEP(classStart, selfValue, 4), LongTy,
CharUnits::fromQuantity(
astContext.getTypeAlign(astContext.UnsignedLongTy))});
// FIXME: The following few lines up to and including the call to
// `CreateLoad` were known to miscompile when MSVC 19.40.33813 is used
// to build Clang. When the bug is fixed in future MSVC releases, we
// should revert these lines to their previous state. See discussion in
// https://github.com/llvm/llvm-project/pull/102681
llvm::Value *Val = Builder.CreateStructGEP(classStart, selfValue, 4);
auto Align = CharUnits::fromQuantity(
astContext.getTypeAlign(astContext.UnsignedLongTy));
auto flags = Builder.CreateLoad(Address{Val, LongTy, Align});
auto isInitialized =
Builder.CreateAnd(flags, ClassFlags::ClassFlagInitialized);
llvm::BasicBlock *notInitializedBlock =
Expand Down
Loading