Skip to content

Commit

Permalink
Runtime: Rename reportMissingMethod to deletedMethodError.
Browse files Browse the repository at this point in the history
The runtime entry doesn't just report the error, unlike the other report* functions, it also does the crashing.

Reapplying independent of unrelated reverted patches.
  • Loading branch information
jckarter committed Dec 24, 2015
1 parent 6528ec2 commit 9af439b
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 13 deletions.
3 changes: 2 additions & 1 deletion docs/Runtime.md
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ optimization.
000000000001c400 T _swift_storeEnumTagMultiPayload
000000000001bf90 T _swift_storeEnumTagSinglePayload
```

## Type metadata lookup

These functions look up metadata for types that potentially require runtime
Expand Down Expand Up @@ -362,7 +363,7 @@ constants to supersede `swift_is*Type`.

```
000000000001c7d0 T _swift_reportError
000000000001c940 T _swift_reportMissingMethod
000000000001c940 T _swift_deletedMethodError
```

## Standard metadata
Expand Down
4 changes: 2 additions & 2 deletions lib/IRGen/GenDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -833,7 +833,7 @@ void IRGenModule::emitVTableStubs() {
continue;

if (!stub) {
// Create a single stub function which calls swift_reportMissingMethod().
// Create a single stub function which calls swift_deletedMethodError().
stub = llvm::Function::Create(llvm::FunctionType::get(VoidTy, false),
llvm::GlobalValue::LinkOnceODRLinkage,
"_swift_dead_method_stub");
Expand All @@ -842,7 +842,7 @@ void IRGenModule::emitVTableStubs() {
stub->setVisibility(llvm::GlobalValue::HiddenVisibility);
stub->setCallingConv(RuntimeCC);
auto *entry = llvm::BasicBlock::Create(getLLVMContext(), "entry", stub);
auto *errorFunc = getDeadMethodErrorFn();
auto *errorFunc = getDeletedMethodErrorFn();
llvm::CallInst::Create(errorFunc, ArrayRef<llvm::Value *>(), "", entry);
new llvm::UnreachableInst(getLLVMContext(), entry);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/IRGen/GenMeta.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3142,7 +3142,7 @@ namespace {
} else {
// The method is removed by dead method elimination.
// It should be never called. We add a pointer to an error function.
addWord(llvm::ConstantExpr::getBitCast(IGM.getDeadMethodErrorFn(),
addWord(llvm::ConstantExpr::getBitCast(IGM.getDeletedMethodErrorFn(),
IGM.FunctionPtrTy));
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/IRGen/GenProto.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1720,7 +1720,7 @@ namespace {
} else {
// The method is removed by dead method elimination.
// It should be never called. We add a pointer to an error function.
witness = llvm::ConstantExpr::getBitCast(IGM.getDeadMethodErrorFn(),
witness = llvm::ConstantExpr::getBitCast(IGM.getDeletedMethodErrorFn(),
IGM.Int8PtrTy);
}
Table.push_back(witness);
Expand Down
4 changes: 2 additions & 2 deletions lib/IRGen/RuntimeFunctions.def
Original file line number Diff line number Diff line change
Expand Up @@ -952,8 +952,8 @@ FUNCTION(BlockRelease, _Block_release, C_CC,
ARGS(ObjCBlockPtrTy),
ATTRS(NoUnwind))

// void swift_reportMissingMethod();
FUNCTION(DeadMethodError, swift_reportMissingMethod, C_CC,
// void swift_deletedMethodError();
FUNCTION(DeletedMethodError, swift_deletedMethodError, C_CC,
RETURNS(VoidTy),
ARGS(),
ATTRS(NoUnwind))
Expand Down
6 changes: 3 additions & 3 deletions stdlib/public/runtime/Errors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,9 @@ swift::fatalError(const char *format, ...)
abort();
}

// Report a call to a removed method.
// Crash when a deleted method is called by accident.
LLVM_ATTRIBUTE_NORETURN
extern "C" void
swift_reportMissingMethod() {
swift::fatalError("fatal error: call of removed method\n");
swift_deletedMethodError() {
swift::fatalError("fatal error: call of deleted method\n");
}
2 changes: 1 addition & 1 deletion test/IRGen/ivar_destroyer.sil
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
// \ CHECK: i32 16,
// \ CHECK: { {{.*}} }* @_TMnC14ivar_destroyer17NonTrivialDerived,
// \ CHECK: void (%C14ivar_destroyer17NonTrivialDerived*)* @_TFC14ivar_destroyer17NonTrivialDerivedE,
// \ CHECK: i8* bitcast (void ()* @swift_reportMissingMethod to i8*),
// \ CHECK: i8* bitcast (void ()* @swift_deletedMethodError to i8*),
// \ CHECK: %C14ivar_destroyer17NonTrivialDerived* ([[TYPE]]*)* @alloc_NonTrivialDerived,
// \ CHECK: i64 16
// \ CHECK: }
Expand Down
2 changes: 1 addition & 1 deletion test/IRGen/objc_attr_NSManaged.sil
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ sil_vtable X {}
// The getter/setter should not show up in the Swift metadata.
/* FIXME: sil_vtable parser picks the wrong 'init' overload. Both vtable entries
ought to be nonnull here. rdar://problem/19572342 */
// CHECK: @_TMfC19objc_attr_NSManaged10SwiftGizmo = internal global { {{.*}} } { void (%C19objc_attr_NSManaged10SwiftGizmo*)* @_TFC19objc_attr_NSManaged10SwiftGizmoD, i8** @_TWVBO, i64 ptrtoint (%objc_class* @"OBJC_METACLASS_$__TtC19objc_attr_NSManaged10SwiftGizmo" to i64), %objc_class* @"OBJC_CLASS_$_Gizmo", %swift.opaque* @_objc_empty_cache, %swift.opaque* null, i64 add (i64 ptrtoint ({ i32, i32, i32, i32, i8*, i8*, { i32, i32, [2 x { i8*, i8*, i8* }] }*, i8*, i8*, i8*, { i32, i32, [1 x { i8*, i8* }] }* }* @_DATA__TtC19objc_attr_NSManaged10SwiftGizmo to i64), i64 1), i32 1, i32 0, i32 16, i16 7, i16 0, i32 112, i32 16, { i64, i8*, i32, i32, i8*, %swift.type** (%swift.type*)*, %swift.type_pattern*, i32, i32, i32 }* @_TMnC19objc_attr_NSManaged10SwiftGizmo, i8* null, %C19objc_attr_NSManaged10SwiftGizmo* (i64, %C19objc_attr_NSManaged10SwiftGizmo*)* @_TFC19objc_attr_NSManaged10SwiftGizmocfT7bellsOnSi_S0_, i8* bitcast (void ()* @swift_reportMissingMethod to i8*) }
// CHECK: @_TMfC19objc_attr_NSManaged10SwiftGizmo = internal global { {{.*}} } { void (%C19objc_attr_NSManaged10SwiftGizmo*)* @_TFC19objc_attr_NSManaged10SwiftGizmoD, i8** @_TWVBO, i64 ptrtoint (%objc_class* @"OBJC_METACLASS_$__TtC19objc_attr_NSManaged10SwiftGizmo" to i64), %objc_class* @"OBJC_CLASS_$_Gizmo", %swift.opaque* @_objc_empty_cache, %swift.opaque* null, i64 add (i64 ptrtoint ({ i32, i32, i32, i32, i8*, i8*, { i32, i32, [2 x { i8*, i8*, i8* }] }*, i8*, i8*, i8*, { i32, i32, [1 x { i8*, i8* }] }* }* @_DATA__TtC19objc_attr_NSManaged10SwiftGizmo to i64), i64 1), i32 1, i32 0, i32 16, i16 7, i16 0, i32 112, i32 16, { i64, i8*, i32, i32, i8*, %swift.type** (%swift.type*)*, %swift.type_pattern*, i32, i32, i32 }* @_TMnC19objc_attr_NSManaged10SwiftGizmo, i8* null, %C19objc_attr_NSManaged10SwiftGizmo* (i64, %C19objc_attr_NSManaged10SwiftGizmo*)* @_TFC19objc_attr_NSManaged10SwiftGizmocfT7bellsOnSi_S0_, i8* bitcast (void ()* @swift_deletedMethodError to i8*) }

@objc class SwiftGizmo : Gizmo {
@objc @NSManaged var x: X
Expand Down
2 changes: 1 addition & 1 deletion test/IRGen/report_dead_method_call.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
// The -disable-access-control option let us "call" methods, which are removed
// by dead method elimination.

// CHECK: fatal error: call of removed method
// CHECK: fatal error: call of deleted method

private protocol PrivateProto {
func abc()
Expand Down

0 comments on commit 9af439b

Please sign in to comment.