Skip to content
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

[SR-7540] OptionSet.contains() falls back to Sequence.contains() #50082

Closed
troughton opened this issue Apr 26, 2018 · 1 comment
Closed

[SR-7540] OptionSet.contains() falls back to Sequence.contains() #50082

troughton opened this issue Apr 26, 2018 · 1 comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. standard library Area: Standard library umbrella

Comments

@troughton
Copy link
Contributor

Previous ID SR-7540
Radar rdar://problem/39668481
Original Reporter @troughton
Type Bug
Status Closed
Resolution Invalid

Attachment: Download

Additional Detail from JIRA
Votes 0
Component/s Standard Library
Labels Bug
Assignee None
Priority Medium

md5: b3fd3d81b5a74db1bb83db68103a43ad

Issue Description:

In a complex app, OptionSet's contains() method fails to be inlined, resulting in calls through to Sequence.contains().

Unfortunately, I'm not able to produce a reduced test case for this. I've attached a screenshot of the stack trace from Instruments.

The full source code is attached to an unrelated Radar 39668481, in MetalRenderer/Conversion.swift.

Relevant code:

 
extension ArgumentReflection {
    init(_ argument: MTLArgument, bindingPath: MetalResourceBindingPath) {
        var stages : RenderStages = []
        let mtlStages = bindingPath.stages
        if mtlStages == [] {
            stages = .compute
        } else {
            if mtlStages.contains(.vertex) {
                stages.formUnion(.vertex)
            }
            if mtlStages.contains(.fragment) {
                stages.formUnion(.fragment)
            }
        }
        
        self.init(isActive: argument.isActive, type: ResourceType(argument.type), bindingPath: ResourceBindingPath(bindingPath), usageType: ResourceUsageType(argument.access), stages: stages)
    }
}
 
public struct RenderStages : OptionSet, Hashable {
    
    public let rawValue : UInt
    
    public init(rawValue: UInt) {
        self.rawValue = rawValue
    }
    
    public static var vertex: RenderStages = RenderStages(rawValue: 1 << 0)
    public static var fragment: RenderStages = RenderStages(rawValue: 1 << 1)
    
    public static var compute: RenderStages = RenderStages(rawValue: 1 << 5)
    public static var blit: RenderStages = RenderStages(rawValue: 1 << 6)
    
    public static var cpuBeforeRender: RenderStages = RenderStages(rawValue: 1 << 7)
    
    public var hashValue: Int {
        return Int(bitPattern: self.rawValue)
    }
}
 
@troughton
Copy link
Contributor Author

After more investigation, I'm not sure this is valid – the module may not have been compiling whole-module without optimisations.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. standard library Area: Standard library umbrella
Projects
None yet
Development

No branches or pull requests

1 participant