-
Notifications
You must be signed in to change notification settings - Fork 12.5k
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
[GNU ObjC] Clang 14 regression: frontend crash in clang::CodeGen::CreateGNUObjCRuntime() building Objective-C++ code #54556
Comments
@llvm/issue-subscribers-clang-codegen |
It does looks as if @rjmccall's change introduced this. I believe the following patch fixes it: diff --git a/clang/lib/CodeGen/CGObjCGNU.cpp b/clang/lib/CodeGen/CGObjCGNU.cpp
index ec459f07f..7bbe9af7e 100644
--- a/clang/lib/CodeGen/CGObjCGNU.cpp
+++ b/clang/lib/CodeGen/CGObjCGNU.cpp
@@ -2837,11 +2837,13 @@ CGObjCGNU::GenerateMessageSend(CodeGenFunction &CGF,
// Enter the continuation block and emit a phi if required.
CGF.EmitBlock(continueBB);
if (msgRet.isScalar()) {
- llvm::Value *v = msgRet.getScalarVal();
- llvm::PHINode *phi = Builder.CreatePHI(v->getType(), 2);
- phi->addIncoming(v, nonNilPathBB);
- phi->addIncoming(CGM.EmitNullConstant(ResultType), nilPathBB);
- msgRet = RValue::get(phi);
+ // If the return type is void, do nothing
+ if (llvm::Value *v = msgRet.getScalarVal()) {
+ llvm::PHINode *phi = Builder.CreatePHI(v->getType(), 2);
+ phi->addIncoming(v, nonNilPathBB);
+ phi->addIncoming(CGM.EmitNullConstant(ResultType), nilPathBB);
+ msgRet = RValue::get(phi);
+ }
} else if (msgRet.isAggregate()) {
// Aggregate zeroing is handled in nilCleanupBB when it's required.
} else /* isComplex() */ { |
The three conditions required to trigger this bug are:
The Mac runtimes have an early return prior to the equivalent block and so never hit this condition. |
Fixed via 94c3b16. |
Known issues: #7 llvm/llvm-project#43828 llvm/llvm-project#51899 llvm/llvm-project#54556 llvm/llvm-project#56952 gnustep/libobjc2#222 Also removed copy about GNUstep test failures, as they have been fixed.
The following Objective-C++ code causes a frontend crash with Clang 14.0.0 using the GNU Objective-C runtime on Win64 and Win32 (and possibly other platforms). The same code does not crash with Clang 13.0.1 (both using pre-built binaries from GitHub). It also does not crash using the Apple runtime on macOS.
This seems to happen using various C++ standard library types as value arguments to Objective-C method, but not with pointer arguments or trivial self-defined C++ class types as value arguments. It also happens only with Objective-C instance methods, but not with class methods.
Preprocessed source and associated run script:
clang-14-crash.zip
@rjmccall I saw you made some changes to the non-Darwin runtime for llvm-14. I’d appreciate if you could take a look at this to see if this is related.
The text was updated successfully, but these errors were encountered: