diff --git a/lib/SILAnalysis/CallGraphAnalysis.cpp b/lib/SILAnalysis/CallGraphAnalysis.cpp index 2e8c6cc6114..7f4bc06de8b 100644 --- a/lib/SILAnalysis/CallGraphAnalysis.cpp +++ b/lib/SILAnalysis/CallGraphAnalysis.cpp @@ -11,6 +11,7 @@ //===----------------------------------------------------------------------===// #include "swift/SILAnalysis/CallGraphAnalysis.h" +#include "swift/Basic/Fallthrough.h" #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/SetVector.h" #include "llvm/ADT/SmallVector.h" @@ -64,6 +65,9 @@ bool CallGraph::tryGetCalleeSet(SILValue Callee, bool &Complete) { switch (Callee->getKind()) { + case ValueKind::ThinToThickFunctionInst: + Callee = cast(Callee)->getOperand(); + SWIFT_FALLTHROUGH; case ValueKind::FunctionRefInst: { auto *CalleeFn = cast(Callee)->getReferencedFunction(); auto *CalleeNode = getCallGraphNode(CalleeFn); @@ -82,14 +86,6 @@ bool CallGraph::tryGetCalleeSet(SILValue Callee, // graph. return false; - case ValueKind::ThinToThickFunctionInst: { - auto ThinCallee = cast(Callee)->getOperand(); - // TODO: We want to see through these to the underlying function. - assert(cast(ThinCallee) && "Expected function reference!"); - (void)ThinCallee; - return false; - } - case ValueKind::SILArgument: // First-pass call-graph construction will not do anything with // these, but a second pass can potentially statically determine diff --git a/test/DebugInfo/closure-multivalue.swift b/test/DebugInfo/closure-multivalue.swift index 235dd5a453e..562324ae63d 100644 --- a/test/DebugInfo/closure-multivalue.swift +++ b/test/DebugInfo/closure-multivalue.swift @@ -1,5 +1,5 @@ // RUN: %target-swift-frontend -Xllvm -debug-values-propagate-liveness -O %s -disable-llvm-optzns -emit-ir -g -o - | FileCheck %s -// CHECK: define {{.*}}4main4sort +// CHECK: define hidden i1 {{.*}}4main4sort // CHECK: call void @llvm.dbg.value({{.*}}, metadata ![[A:.*]], metadata ![[P1:.*]]) // CHECK: call void @llvm.dbg.value({{.*}}, metadata ![[A]], metadata ![[P2:.*]]) // CHECK: call void @llvm.dbg.value({{.*}}, metadata ![[A]], metadata ![[P3:.*]]) diff --git a/test/SILPasses/functionsigopts.sil b/test/SILPasses/functionsigopts.sil index fae3f9b0823..d08847b88c1 100644 --- a/test/SILPasses/functionsigopts.sil +++ b/test/SILPasses/functionsigopts.sil @@ -107,9 +107,10 @@ bb0(%0 : $Builtin.NativeObject, %1 : $Builtin.NativeObject): return %5 : $() } -// This test case verifies how dumb our implementation is currently. +// This test case verifies we can specialize functions called through thin_to_thick_function. // CHECK-LABEL: sil [fragile] @dead_arg_obfuscated_callsite : $@thin (Builtin.NativeObject, Builtin.NativeObject) -> () { -// CHECK-NOT: function_ref @_TTSf4d_n__dead_arg_with_callsites : $@thin (Builtin.NativeObject) -> () +// CHECK: [[OPT_FUN:%[0-9]+]] = function_ref @_TTSf4d_n__dead_arg_with_callsites : $@thin (Builtin.NativeObject) -> () +// CHECK-NEXT: apply [[OPT_FUN]]( sil [fragile] @dead_arg_obfuscated_callsite : $@thin (Builtin.NativeObject, Builtin.NativeObject) -> () { bb0(%0 : $Builtin.NativeObject, %1 : $Builtin.NativeObject): %2 = function_ref @dead_arg_with_callsites : $@thin (Builtin.NativeObject, Builtin.NativeObject) -> ()