Skip to content
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@ extension BuiltinInst : OnoneSimplifyable {
.AssignCopyArrayNoAlias,
.AssignCopyArrayFrontToBack,
.AssignCopyArrayBackToFront,
.AssignTakeArray:
optimizeArrayBuiltin(context)
.AssignTakeArray,
.IsPOD:
optimizeFirstArgumentToThinMetatype(context)
default:
if let literal = constantFold(context) {
uses.replaceAll(with: literal, context)
Expand Down Expand Up @@ -173,7 +174,7 @@ private extension BuiltinInst {
context.erase(instruction: self)
}

func optimizeArrayBuiltin(_ context: SimplifyContext) {
func optimizeFirstArgumentToThinMetatype(_ context: SimplifyContext) {
guard let metatypeInst = operands[0].value as? MetatypeInst,
metatypeInst.type.representationOfMetatype(in: parentFunction) == .Thick else {
return
Expand Down
34 changes: 34 additions & 0 deletions test/embedded/builtins-misc.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// RUN: %target-swift-emit-ir %s -parse-stdlib -module-name Swift -enable-experimental-feature Embedded -wmo -target arm64e-apple-none | %FileCheck %s

// REQUIRES: swift_in_compiler

class MyClass {}

struct MyStruct {
var c: MyClass
}

public func foo() -> Builtin.Int1 {
return Builtin.ispod(MyStruct.self)
}

// CHECK: define {{.*}}i1 @"$ss3fooBi1_yF"()
// CHECK-NEXT: entry:
// CHECK-NEXT: ret i1 false
// CHECK-NEXT: }

public func bar() -> Builtin.Int1 {
var s = MyGenericStruct<MyStruct>()
return s.foo()
}

public struct MyGenericStruct<T> {
public func foo() -> Builtin.Int1 {
return Builtin.ispod(T.self)
}
}

// CHECK: define {{.*}}i1 @"$ss15MyGenericStructV3fooBi1_yFs0aC0V_Tg5"()
// CHECK-NEXT: entry:
// CHECK-NEXT: ret i1 false
// CHECK-NEXT: }