-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
assert "Function return type does not match operand type of return inst!" when building ObjC code for arm #16370
Comments
Jay touched this assert 2 years ago, maybe he knows how to find out which caller is doing something wrong. |
The assertion fails because clang is generating this: define linkonce_odr arm_aapcscc %struct.scoped_nsprotocol* @_ZN17scoped_nsprotocolI4ViewEC1Ev(%struct.scoped_nsprotocol*) unnamed_addr #0 align 2 { The return type of the function is "%struct.scoped_nsprotocol*", but the ret instruction tries to return "%struct.scoped_nsprotocol.0*" (note the extra ".0"). This happens because clang tries to create two different structs, but gives them the same name; LLVM then auto-renames one of them by appending ".0". I can see in the debugger that CodeGenTypes::ConvertRecordDecl is called on these two RecordDecls. Each call creates a different struct with the same name "struct.scoped_nsprotocol": (gdb) call RD->dump() (gdb) call RD->dump() |
And this doesn't happen on x86 because constructors return void there? Chris touched CodeGenTypes::ConvertRecordDecl() last (2011), maybe he knows if that function is doing the wrong thing or if the frontend is feeding it bad data. |
Sorry, I don't have any specific insight here anymore. |
This has been broken since at least r138188, so removing the "Regression" bit from the bug title. |
Jay: Hm, if I change the input to template struct scoped_nsprotocol { …then clang also generates structs with the same name, but llvm's renaming pass doesn't get confused about them. So just having an identical name doesn't seem to trigger the problem? |
The problem seems to be that we use the same mangled name for View and View but treat them as canonically different types. Note that neither "protocol1" nor "protocol2" appears within "_ZN17scoped_nsprotocolI4ViewEC2Ev" |
As far as I can tell, you've fallen into a hole in the Objective-C++ ABI. |
Ah, thanks! Reminds me of http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20110718/044168.html , so maybe something similar can be done here? |
r184250. |
Extended Description
hummer:src thakis$ cat test.mm
template struct scoped_nsprotocol {
scoped_nsprotocol() {}
};
@interface View
@end
@protocol protocol1
@end
@protocol protocol2
@end
class Controller {
public:
Controller();
scoped_nsprotocol<View > p1;
scoped_nsprotocol<View > p2;
};
Controller::Controller() {}
hummer:src thakis$ third_party/llvm-build/Release+Asserts/bin/clang -c test.mm
hummer:src thakis$ third_party/llvm-build/Release+Asserts/bin/clang -c test.mm -arch arm
Function return type does not match operand type of return inst!
ret %struct.scoped_nsprotocol.0* %call
%struct.scoped_nsprotocolBroken module found, compilation aborted!
0 clang 0x00000001018315d8 llvm::sys::PrintStackTrace(__sFILE) + 40
1 clang 0x0000000101831b44 SignalHandler(int) + 564
2 libsystem_c.dylib 0x00007fff87fa194a _sigtramp + 26
3 libsystem_c.dylib 0x0000000102840a00 _sigtramp + 2055860432
4 clang 0x00000001018318f6 abort + 22
5 clang 0x00000001017e865e (anonymous namespace)::Verifier::abortIfBroken() + 510
6 clang 0x00000001017e8316 (anonymous namespace)::Verifier::runOnFunction(llvm::Function&) + 1958
7 clang 0x00000001017cefdb llvm::FPPassManager::runOnFunction(llvm::Function&) + 347
8 clang 0x00000001017ce7fb llvm::FunctionPassManagerImpl::run(llvm::Function&) + 219
9 clang 0x00000001017ce6ce llvm::FunctionPassManager::run(llvm::Function&) + 94
10 clang 0x00000001001af264 clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::Module*, clang::BackendAction, llvm::raw_ostream*) + 5460
11 clang 0x00000001002a0f28 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) + 600
12 clang 0x00000001002e4144 clang::ParseAST(clang::Sema&, bool, bool) + 516
13 clang 0x000000010029fe97 clang::CodeGenAction::ExecuteAction() + 215
14 clang 0x0000000100066f17 clang::FrontendAction::Execute() + 119
15 clang 0x000000010004223d clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 957
16 clang 0x0000000100009e5d clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 3693
17 clang 0x0000000100001081 cc1_main(char const**, char const**, char const*, void*) + 801
18 clang 0x0000000100007133 main + 6963
19 clang 0x0000000100000d34 start + 52
20 clang 0x000000000000003f start + 4294964031
Stack dump:
0. Program arguments: /Volumes/MacintoshHD2/src/chrome-git/src/third_party/llvm-build/Release+Asserts/bin/clang -cc1 -triple armv4t-apple-macosx10.8.0 -emit-obj -mrelax-all -disable-free -main-file-name test.mm -mrelocation-model pic -pic-level 2 -mdisable-fp-elim -masm-verbose -target-abi apcs-gnu -target-cpu arm7tdmi -msoft-float -mfloat-abi soft -target-feature +soft-float -target-feature +soft-float-abi -target-feature -neon -target-linker-version 136 -coverage-file /Users/thakis/src/chrome-git/src/test.o -resource-dir /Volumes/MacintoshHD2/src/chrome-git/src/third_party/llvm-build/Release+Asserts/bin/../lib/clang/3.3 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk -fdeprecated-macro -fdebug-compilation-dir /Users/thakis/src/chrome-git/src -ferror-limit 19 -fmessage-length 271 -stack-protector 1 -mstackrealign -fblocks -fobjc-runtime=macosx-10.8.0 -fobjc-default-synthesize-properties -fencode-extended-block-signature -fobjc-exceptions -fcxx-exceptions -fexceptions -fsjlj-exceptions -fdiagnostics-show-option -fcolor-diagnostics -backend-option -vectorize-loops -o test.o -x objective-c++ test.mm
clang: error: unable to execute command: Illegal instruction: 4
clang: error: clang frontend command failed due to signal (use -v to see invocation)
clang version 3.3 (trunk 179138)
Target: arm-apple-darwin12.3.0
This works fine with Apple LLVM version 4.2 (clang-425.0.24) (based on LLVM 3.2svn) (but maybe only because that's build without asserts?).
It is still an issue at today's head (r181805).
The text was updated successfully, but these errors were encountered: