profile
viewpoint

eeckstein/swift-corelibs-foundation 1

The Foundation Project, providing core utilities, internationalization, and OS independence

eeckstein/llvm-project 0

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies. This fork is used to manage Apple’s stable releases of Clang as well as support the Swift project.

eeckstein/swift 0

The Swift Programming Language

eeckstein/swift-evolution 0

This maintains proposals for changes and user-visible enhancements to the Swift Programming Language.

eeckstein/swift-lldb 0

This is the version of LLDB that supports the Swift programming language & REPL.

eeckstein/swift-package-manager 0

The Package Manager for the Swift Programming Language

eeckstein/swift-source-compat-suite 0

The infrastructure and project index comprising the Swift source compatibility suite.

pull request commentapple/swift

RCIdentity: fix another case of not-RC-identity-preserving casts.

@swift-ci benchmark

eeckstein

comment created time in 6 hours

pull request commentapple/swift

RCIdentity: fix another case of not-RC-identity-preserving casts.

@swift-ci test

eeckstein

comment created time in 6 hours

PR opened apple/swift

RCIdentity: fix another case of not-RC-identity-preserving casts.

When casting from existentials to class - and vice versa - it can happen that a cast is not RC identity preserving (because of potential bridging). This also affects mayRelease() of such cast instructions. For details see the comments in SILDynamicCastInst::isRCIdentityPreserving().

This change also includes some refactoring: I centralized the logic in SILDynamicCastInst::isRCIdentityPreserving().

rdar://problem/70454804

+136 -32

0 comment

6 changed files

pr created time in 6 hours

create barncheeckstein/swift

branch : fix_bridging_casts

created branch time in 6 hours

PullRequestReviewEvent
PullRequestReviewEvent

push eventapple/swift

Erik Eckstein

commit sha c6be347d3ae3b56a2dc19ac04b14d2182d805284

SILCombine: fix metatype simplification Don't reuse argument metadata if it's an indirect argument. Fixes a verifier crash. https://bugs.swift.org/browse/SR-13731 rdar://problem/70338666

view details

eeckstein

commit sha 0d6e79c2d4072664a7436341cf646aceb5987ce3

Merge pull request #34375 from eeckstein/fix-metadat-combine SILCombine: fix metatype simplification

view details

push time in 13 hours

delete branch eeckstein/swift

delete branch : fix-metadat-combine

delete time in 13 hours

PR merged apple/swift

Reviewers
SILCombine: fix metatype simplification

Don't reuse argument metadata if it's an indirect argument. Fixes a verifier crash.

https://bugs.swift.org/browse/SR-13731 rdar://problem/70338666

+15 -1

4 comments

2 changed files

eeckstein

pr closed time in 13 hours

pull request commentapple/swift

update and unify the "please file a bug report" message

@swift-ci smoke test

eeckstein

comment created time in 15 hours

PR opened apple/swift

update and unify the "please file a bug report" message

The new message is: "Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the crash backtrace."

  1. In crash logs we used to print a message which points to the llvm bug tracking page. Now it points to the swift.org bug tracking guidelines.
  2. Use the same message in all compiler diagnostics which ask the user to file a bug report.

rdar://problem/70488534

+17 -10

0 comment

10 changed files

pr created time in 15 hours

create barncheeckstein/swift

branch : bug-report-message

created branch time in 15 hours

pull request commentapple/swift

SILCombine: fix metatype simplification

@swift-ci test macOS

eeckstein

comment created time in 16 hours

pull request commentapple/swift

SILCombine: fix metatype simplification

@swift-ci test macOS

eeckstein

comment created time in 16 hours

create barncheeckstein/swift

branch : fix-metadat-combine

created branch time in 19 hours

pull request commentapple/swift

SILCombine: fix metatype simplification

@swift-ci test

eeckstein

comment created time in 19 hours

PR opened apple/swift

SILCombine: fix metatype simplification

Don't reuse argument metadata if it's an indirect argument. Fixes a verifier crash.

https://bugs.swift.org/browse/SR-13731 rdar://problem/70338666

+15 -1

0 comment

2 changed files

pr created time in 19 hours

delete branch eeckstein/swift

delete branch : fix-test

delete time in a day

create barncheeckstein/swift

branch : fix-test

created branch time in 2 days

pull request commentapple/swift

tests: fix APINotes/blocks.swift

@swift-ci smoke test and merge

eeckstein

comment created time in 2 days

PR opened apple/swift

tests: fix APINotes/blocks.swift

The requirement executable_test is not needed here. It was there for historical reasons.

rdar://problem/70400635

+0 -1

0 comment

1 changed file

pr created time in 2 days

Pull request review commentapple/swift

AccessPath: Look past class casts when finding the reference root.

 SILBasicBlock::iterator removeBeginAccess(BeginAccessInst *beginAccess);  namespace swift { +/// Return true if \p value is a cast that preserves the identity and

typo: .. if \p svi is a...

atrick

comment created time in 2 days

PullRequestReviewEvent
PullRequestReviewEvent
PullRequestReviewEvent

Pull request review commentapple/swift

Fix several correctness issues in TempRValueOpt

 collectLoads(Operand *addressUse, CopyAddrInst *originalCopy,   case SILInstructionKind::UncheckedAddrCastInst:     return collectLoadsFromProjection(cast<SingleValueInstruction>(user),                                       originalCopy, loadInsts);-  case SILInstructionKind::LoadInst:++  case SILInstructionKind::LoadInst: {

yes, because we are inserting a new delete_addr now.

eeckstein

comment created time in 2 days

PullRequestReviewEvent

push eventapple/swift

Erik Eckstein

commit sha 007351223eb96a1a0132953a219b12d9b06ec0e7

MemBehavior: handle begin_access when checking for apply side-effects.

view details

Erik Eckstein

commit sha 68db2e7c6ce6f2bf9cdce1add556ef69971bc6a1

TempRValueOpt: don't use collectLoads in tryOptimizeStoreIntoTemp This refactoring removes a lot of special-casing in collectLoads and also makes tryOptimizeStoreIntoTemp simpler. It's a NFC.

view details

Erik Eckstein

commit sha 673b8873ab2930c0497944411a28070877883591

TempRValueOpt: refactoring: simplify the signature of collectLoads It's sufficient to pass the operand instead of the operand, the user and the operand value. NFC.

view details

Erik Eckstein

commit sha d569031f1a367281871ba18c92f385ffa0cafa7d

TempRValueOpt: move the mayWrite-check for applies from collectLoads to checkNoSourceModification ... where it belongs. This is mostly refactoring, but it also fixes a bug: we don't recurse into a begin_access in collectLoads. If there is an apply in such a scope, the mayWrite-check wouldn't be done. In checkNoSourceModification all instructions are visited, so the check is always done.

view details

Erik Eckstein

commit sha 7c293d8de960045fbe2d1717aa21481d801cd036

TempRValueOpt: fix the handling of begin_access Consider the related end_access instructions as uses to correctly mark the end of the lifetime of the temporary. This fixes a miscompile in case there is a modification of the copy-source between an begin_access and end_access.

view details

Erik Eckstein

commit sha 6310dfcc939d88664d1fb63a908f1139e9cf6b47

TempRValueOpt: fix the handling of load [take] load [take] was not considered as a use and it was not detected if it's in a different basic block. This fixes a miscompile in case there is a modification of the copy-source before a load [take]. rdar://problem/69757314

view details

Erik Eckstein

commit sha 9a10ec7d581345cbfcd15990c54848ca1b25dc8c

SILBuilder: add an API to insert _after_ an instruction. ... and use that API in FullApplySite::insertAfterInvocation. Also change FullApplySite::insertAfterInvocation/insertAfterFullEvaluation to directly pass a SILBuilder instead of just an insertion point to the callback. This makes more sense (given the function names) and simplifies the usages. It's a NFC.

view details

Erik Eckstein

commit sha 4557f151b1e90b874f77736bdf4ab20df8affe69

TempRValueOpt: fix the placement of destroy_addr in case of a copy_addr [take] Instead of reusing the existing destroy_addr (or load/copy_addr [take]) of the temporary, insert a new destroy_addr - at the correct location. This fixes a memory lifetime failure in case the copy-source is modified (actually: re-initialized) after the last use of the temporary: E.g. (before copy elimination): copy_addr [take] %src to [initialization] %temp %x = load %temp // last use of %temp store %y to [init] %src destroy_addr %temp The correct location for the destroy_addr is after the last use (after copy elimination): %x = load %src destroy_addr %src store %y to [init] %src rdar://problem/69757314

view details

Erik Eckstein

commit sha 262c7b251f9d650231a394bedcd5d12ca527cc92

TempRValueOpt: don't allow copy_addr [take] from a projection of the temporary. This fixes a memory lifetime failure.

view details

Erik Eckstein

commit sha 1e5f3bd253f0fbfab7f39f176f321b3dce94d11b

TempRValueOpt: only do the check for "unusual" temp object destruction in non-OSSA mode. In OSSA, memory locations are always destroyed in a "visible" way, e.g. with destroy_addr or load [take].

view details

eeckstein

commit sha f55e65177f0e830a9d94d76f5b82e2273a0b7914

Merge pull request #34308 from eeckstein/fix-temp-rvalue-opt Fix several correctness issues in TempRValueOpt

view details

push time in 3 days

delete branch eeckstein/swift

delete branch : fix-temp-rvalue-opt

delete time in 3 days

PR merged apple/swift

Fix several correctness issues in TempRValueOpt
  • fix the handling of begin_access
  • fix the handling of load [take]
  • don't allow copy_addr [take] from a projection of the temporary.
  • fix the placement of destroy_addr in case of a copy_addr [take]

plus some refactoring. For details see the commit messages.

rdar://problem/69757314

+466 -306

13 comments

13 changed files

eeckstein

pr closed time in 3 days

Pull request review commentapple/swift

Fix several correctness issues in TempRValueOpt

 collectLoads(Operand *addressUse, CopyAddrInst *originalCopy, /// generates). Instead we guarantee that all normal uses are within the block /// of the temporary and look for the last use, which effectively ends the /// lifetime.-bool TempRValueOptPass::checkNoSourceModification(+///+/// Return the instrution which is the last use (or copyInst if there are no+/// uses).+/// Returns a nullptr, if there is a source modification before the last use.+SILInstruction *TempRValueOptPass::checkNoSourceModification(

I renamed it and change the comment (though I kept it smaller than you suggested)

eeckstein

comment created time in 5 days

PullRequestReviewEvent

Pull request review commentapple/swift

Fix several correctness issues in TempRValueOpt

 bool TempRValueOptPass::tryOptimizeCopyIntoTemp(CopyAddrInst *copyInst) {       auto *cai = cast<CopyAddrInst>(user);       if (cai != copyInst) {         assert(cai->getSrc() == tempObj);-        if (cai->isTakeOfSrc() && !copyInst->isTakeOfSrc())+        if (cai->isTakeOfSrc())

I explained it in the comment above the loop

eeckstein

comment created time in 5 days

PullRequestReviewEvent

Pull request review commentapple/swift

Fix several correctness issues in TempRValueOpt

 bool TempRValueOptPass::tryOptimizeCopyIntoTemp(CopyAddrInst *copyInst) {   }    // Check if the source is modified within the lifetime of the temporary.

It should be clearer now with the new function name

eeckstein

comment created time in 5 days

PullRequestReviewEvent

Pull request review commentapple/swift

Fix several correctness issues in TempRValueOpt

 bool TempRValueOptPass::tryOptimizeCopyIntoTemp(CopyAddrInst *copyInst) {   }    // Check if the source is modified within the lifetime of the temporary.-  if (!checkNoSourceModification(copyInst, copySrc, loadInsts))+  SILInstruction *lastLoadInst = checkNoSourceModification(copyInst,+                                                           copySrc, loadInsts);+  if (!lastLoadInst)+    return false;++  bool needToInsertDestroy = copyInst->isTakeOfSrc();+  +  // We cannot insert a destroy after lastLoadInst if the copySrc is written+  // by this instruction. This is a corner case, but can happen if lastLoadInst+  // is a copy_addr.

done

eeckstein

comment created time in 5 days

PullRequestReviewEvent

Pull request review commentapple/swift

Fix several correctness issues in TempRValueOpt

 bool TempRValueOptPass::tryOptimizeCopyIntoTemp(CopyAddrInst *copyInst) {   }    // Check if the source is modified within the lifetime of the temporary.-  if (!checkNoSourceModification(copyInst, copySrc, loadInsts))+  SILInstruction *lastLoadInst = checkNoSourceModification(copyInst,+                                                           copySrc, loadInsts);+  if (!lastLoadInst)+    return false;++  bool needToInsertDestroy = copyInst->isTakeOfSrc();

I added a comment

eeckstein

comment created time in 5 days

PullRequestReviewEvent

Pull request review commentapple/swift

Fix several correctness issues in TempRValueOpt

 collectLoads(Operand *addressUse, CopyAddrInst *originalCopy, /// generates). Instead we guarantee that all normal uses are within the block /// of the temporary and look for the last use, which effectively ends the /// lifetime.-bool TempRValueOptPass::checkNoSourceModification(+///+/// Return the instrution which is the last use (or copyInst if there are no

done

eeckstein

comment created time in 5 days

PullRequestReviewEvent

Pull request review commentapple/swift

Fix several correctness issues in TempRValueOpt

 bb3:   return %9 : $() } +// CHECK-LABEL: sil [ossa] @copy_take_and_try_apply+// CHECK-NOT: copy_addr+// CHECK:   try_apply {{%[0-9]+}}(%0)+// CHECK: bb1({{.*}}):+// CHECK:   destroy_addr %0+// CHECK: bb2({{.*}}):+// CHECK:   destroy_addr %0+// CHECK: bb3:+// CHECK:   store %1 to [init] %0+// CHECK: } // end sil function 'copy_take_and_try_apply'+sil [ossa] @copy_take_and_try_apply : $@convention(thin) (@inout Klass, @owned Klass) -> () {+bb0(%0 : $*Klass, %1 : @owned $Klass):

I moved it

eeckstein

comment created time in 5 days

PullRequestReviewEvent
PullRequestReviewEvent

Pull request review commentapple/swift

Fix several correctness issues in TempRValueOpt

 bool TempRValueOptPass::collectLoads(     LLVM_DEBUG(llvm::dbgs()                << "  Temp use may write/destroy its source" << *user);     return false;-  case SILInstructionKind::BeginAccessInst:-    return cast<BeginAccessInst>(user)->getAccessKind() == SILAccessKind::Read;-+  case SILInstructionKind::BeginAccessInst: {+    auto *beginAccess = cast<BeginAccessInst>(user);+    if (beginAccess->getAccessKind() != SILAccessKind::Read)+      return false;+    // We don't have to recursively call collectLoads for the beginAccess+    // result, because a SILAccessKind::Read already guarantees that there are+    // no writes to the beginAccess result address (or any projection from it).+    // But we have to register the end-accesses as loads to correctly mark the+    // end-of-lifetime of the temporary object.

done

eeckstein

comment created time in 5 days

PullRequestReviewEvent

Pull request review commentapple/swift

Fix several correctness issues in TempRValueOpt

 bb0(%0 : $*Builtin.NativeObject):   %v = tuple ()   return %v : $() }++// CHECK-LABEL: sil [ossa] @dont_allow_copy_take_from_projection+// CHECK:   [[STK:%[0-9]+]] = alloc_stack+// CHECK:   copy_addr [take] %1 to [initialization] [[STK]]+// CHECK: } // end sil function 'dont_allow_copy_take_from_projection'+sil [ossa] @dont_allow_copy_take_from_projection : $@convention(thin) (@in Two) -> @out Two {+bb0(%0 : $*Two, %1 : $*Two):+  %a0 = struct_element_addr %0 : $*Two, #Two.a+  %b0 = struct_element_addr %0 : $*Two, #Two.b+  %s = alloc_stack $Two+  copy_addr [take] %1 to [initialization] %s : $*Two

The non-ossa version would be completely equivalent and also be handled equivalently in the optimization.

eeckstein

comment created time in 5 days

PullRequestReviewEvent

pull request commentapple/swift

Fix several correctness issues in TempRValueOpt

@swift-ci benchmark

eeckstein

comment created time in 5 days

pull request commentapple/swift

Fix several correctness issues in TempRValueOpt

@swift-ci test

eeckstein

comment created time in 5 days

push eventeeckstein/swift

Keith Smiley

commit sha ae0c380f1b0f37e11b111a06634dd4c64e67b96c

Improve -*prefix-map help text Before: ``` -coverage-prefix-map <value> -debug-prefix-map <value> ``` After: ``` -coverage-prefix-map <prefix=replacement> -debug-prefix-map <prefix=replacement> ```

view details

Dave Lee

commit sha 52bbe11161f908d4c58cbdd2a423c68b9688b191

[build] Remove dash-dash from build-presets.ini (NFC)

view details

Arnold Schwaighofer

commit sha 96a0d0e5840045e25d2c05f02999972f804201df

Rename various IncludeUsableFromInlineAndInlineable to IncludeUsableFromInline `@inlinable` implies `@usableFromInline`. NFC intended.

view details

Doug Gregor

commit sha 21a0696e165747248ac5f4532feeb942e13e326b

[Concurrency] Clean up inference logic for @asyncHandler.

view details

Doug Gregor

commit sha dee5356021f49ea31954e3ecc2170d285d47804c

[Concurrency] Add inferred actor-isolation attributes. When we infer an actor-isolation attribute on a declaration, add an implicit attribute that will show up in the printed interface and get serialized. ... and clean up the type resolution logic for global actor attributes to make it use CustomAttrTypeRequest, so the result gets appropriately cached in CustomAttr for serialization.

view details

Doug Gregor

commit sha 4032cd8e7d4857dad9e07782212e30848580ca56

Rename CustomAttrTypeKind::PropertyDelegate to PropertyWrapper.

view details

Alexis Laferrière

commit sha e509d6883a068334df96f34ade141d8c38dfd1f0

Revert "[Sema] Fix availability checking in inlinable code"

view details

Xi Ge

commit sha 29093b15df24e98dda65cd51e26a7bd618a2d709

Driver: -L= belongs to the linker option group rdar://70300892

view details

Arnold Schwaighofer

commit sha a7259558238eadd1c69a234baef1b67ab45f8492

More renaming

view details

Arnold Schwaighofer

commit sha d6d921d7fafcfa67e500e6013f93ac30f6248b79

IRGen: Fix fixLifetime emission of enums rdar://70270724

view details

Robert Widmann

commit sha 6125d25cb4f5059f455b3c6f4bde70f6aa79f59e

[NFC] Silence Non-Exhaustive Switch Warnings on Windows

view details

Robert Widmann

commit sha 9c879c008e642278b2bce557db19b78ca391caad

Resolve Virtual Inheritance By Dominance By Being Explicit Since the alternative is name lookup selecting members from a pure virtual base, it's probably best to be explicit here.

view details

Alexis Laferrière

commit sha 0d8f689d1c50121c13980eadf7ee58917a930aef

Merge pull request #34306 from apple/revert-33855-availability-inlinable Revert "[Sema] Fix availability checking in inlinable code"

view details

Robert Widmann

commit sha ba737b563154e2e5261c57c482699d6ee8f4abf3

[NFC] Use an Explicit 64-Bit Shift

view details

Robert Widmann

commit sha 0d6a16258a1519b59644618be1ae2280476878ba

Silence a Deprecation Warning with FixedVectorType

view details

Saleem Abdulrasool

commit sha 78bc6aae363ff8e82d28aa7725c562ecf7e66ab2

Platform: link against Pathcch.lib when using pathcch.h The MSDN documentation indicates that you should link against the `Pathcch.lib` import library when using functions from `pathcch.h` which can also be verified by use functions failing to link due to unresolved symbols. Add the missing linking to enable autolinking for `WinSDK`.

view details

Arnold Schwaighofer

commit sha 1c85d201921abcedbd3a693229f597a6d015f81d

Try to appease 32bit tests

view details

Holly Borla

commit sha 1e0038c3be0f6f2fbe1ba6ccb7fa394b7320aa22

[ConstraintSystem] Remove implementation of operator designated types in the solver.

view details

Robert Widmann

commit sha 476890cac5224f1c9a2fcfee5a2267bd44d24466

Merge pull request #34312 from CodaFi/just-keep-passing-the-open-windows Silence a Raft of Warnings from the Windows Build

view details

Holly Borla

commit sha 4c0f49f7a6a7a642cd57aeec70e8b392f3296cf1

[ConstraintSystem] Remove selectApplyDisjunction, which was only used by the operator designated types implementation.

view details

push time in 5 days

PullRequestReviewEvent

Pull request review commentapple/swift

[temp-rvalue-opt] Disable handling of load [take] in temp-rvalue-elim.

 TempRValueOptPass::tryOptimizeStoreIntoTemp(StoreInst *si) {     // our base, we fail since those would be re-initializations.     if (auto *li = dyn_cast<LoadInst>(user)) {       if (li->getOwnershipQualifier() == LoadOwnershipQualifier::Take) {-        continue;+        return {std::next(si->getIterator()), false};

There is no problem with load[take] in tryOptimizeStoreIntoTemp. You can keep the optimization here.

gottesmm

comment created time in 6 days

PullRequestReviewEvent

delete branch eeckstein/swift

delete branch : fix-simplify-cfg

delete time in 6 days

pull request commentapple/swift

SimplifyCFG: fix a crash caused by an unreachable CFG cycles with block arguments.

@swift-ci test and merge

eeckstein

comment created time in 7 days

PR opened apple/swift

SimplifyCFG: fix a crash caused by an unreachable CFG cycles with block arguments.

When SimplifyCFG (temporarily) produces an unreachable CFG cycle, some other transformations in SimplifyCFG didn't deal with this situation correctly.

Unfortunately I couldn't create a SIL test case for this bug, so I just added a swift test case.

https://bugs.swift.org/browse/SR-13650 rdar://problem/69942431

+46 -14

0 comment

3 changed files

pr created time in 7 days

create barncheeckstein/swift

branch : fix-simplify-cfg

created branch time in 7 days

pull request commentapple/swift

Fix several correctness issues in TempRValueOpt

@swift-ci test linux

eeckstein

comment created time in 7 days

pull request commentapple/swift

Fix several correctness issues in TempRValueOpt

@swift-ci test

eeckstein

comment created time in 7 days

Pull request review commentapple/swift

Fix several correctness issues in TempRValueOpt

 bb0(%0 : $*Builtin.NativeObject):   %v = tuple ()   return %v : $() }++// CHECK-LABEL: sil [ossa] @dont_allow_copy_take_from_projection+// CHECK:   [[STK:%[0-9]+]] = alloc_stack+// CHECK:   copy_addr [take] %1 to [initialization] [[STK]]+// CHECK: } // end sil function 'dont_allow_copy_take_from_projection'+sil [ossa] @dont_allow_copy_take_from_projection : $@convention(thin) (@in Two) -> @out Two {+bb0(%0 : $*Two, %1 : $*Two):+  %a0 = struct_element_addr %0 : $*Two, #Two.a+  %b0 = struct_element_addr %0 : $*Two, #Two.b+  %s = alloc_stack $Two+  copy_addr [take] %1 to [initialization] %s : $*Two

yes. The only difference is that the memory lifetime verifier will not catch it (because it only runs on ossa).

eeckstein

comment created time in 7 days

PullRequestReviewEvent

pull request commentapple/swift

Fix several correctness issues in TempRValueOpt

@swift-ci benchmark

eeckstein

comment created time in 7 days

pull request commentapple/swift

Fix several correctness issues in TempRValueOpt

@swift-ci test

eeckstein

comment created time in 7 days

PR opened apple/swift

Fix several correctness issues in TempRValueOpt
  • fix the handling of begin_access
  • fix the handling of load [take]
  • don't allow copy_addr [take] from a projection of the temporary.
  • fix the placement of destroy_addr in case of a copy_addr [take]

plus some refactoring. For details see the commit messages.

rdar://problem/69757314

+307 -202

0 comment

5 changed files

pr created time in 7 days

create barncheeckstein/swift

branch : fix-temp-rvalue-opt

created branch time in 7 days

delete branch eeckstein/swift

delete branch : fix-side-effect-analysis

delete time in 9 days

push eventapple/swift

Erik Eckstein

commit sha b0c9e69b6fd7bde871cf55570798094d51898fca

SideEffectAnalysis: don't assume that arguments with trivial type cannot be pointers. Even values of trivial type can contain a Builtin.RawPointer, which can be used to read/write from/to. To compensate for the removed check, enable the escape-analysis check in MemBehavior (as it was before). This fixes a recently introduced miscompile. rdar://problem/70220876

view details

eeckstein

commit sha 67d311d8da2b15e61ca866ffdd06fa125dd85d7f

Merge pull request #34289 from eeckstein/fix-side-effect-analysis SideEffectAnalysis: don't assume that arguments with trivial type can not be pointers.

view details

push time in 9 days

PR merged apple/swift

SideEffectAnalysis: don't assume that arguments with trivial type can not be pointers.

Even values of trivial type can contain a Builtin.RawPointer, which can be used to read/write from/to.

To compensate for the removed check, enable the escape-analysis check in MemBehavior (as it was before).

This fixes a recently introduced miscompile in https://github.com/apple/swift/pull/34252.

rdar://problem/70220876

+46 -11

5 comments

4 changed files

eeckstein

pr closed time in 9 days

pull request commentapple/swift

SideEffectAnalysis: don't assume that arguments with trivial type can not be pointers.

@swift-ci test macOS

eeckstein

comment created time in 9 days

pull request commentapple/swift

SILOptimizer: fix a miscompile in TempRValueOpt and improve MemBehavior

About the regressions: some regressions are noise and (I believe) some regressions are due to inlining decisions. But for example, NopDeinit is a case of passing a reference to a function.

eeckstein

comment created time in 9 days

Pull request review commentapple/swift

SILOptimizer: fix a miscompile in TempRValueOpt and improve MemBehavior

 MemBehavior MemoryBehaviorVisitor::visitBuiltinInst(BuiltinInst *BI) { }  MemBehavior MemoryBehaviorVisitor::visitTryApplyInst(TryApplyInst *AI) {-  MemBehavior Behavior = MemBehavior::MayHaveSideEffects;-  // Ask escape analysis.-  if (!EA->canEscapeTo(V, AI))-    Behavior = MemBehavior::None;--  // Otherwise be conservative and return that we may have side effects.-  LLVM_DEBUG(llvm::dbgs() << "  Found tryapply, returning " << Behavior <<'\n');-  return Behavior;+  return getApplyBehavior(AI); }  MemBehavior MemoryBehaviorVisitor::visitApplyInst(ApplyInst *AI) {+  return getApplyBehavior(AI);+} -  FunctionSideEffects ApplyEffects;-  SEA->getCalleeEffects(ApplyEffects, AI);+MemBehavior MemoryBehaviorVisitor::visitBeginApplyInst(BeginApplyInst *AI) {+  return getApplyBehavior(AI);+}++MemBehavior MemoryBehaviorVisitor::visitEndApplyInst(EndApplyInst *EAI) {+  return getApplyBehavior(EAI->getBeginApply());+}++MemBehavior MemoryBehaviorVisitor::visitAbortApplyInst(AbortApplyInst *AAI) {+  return getApplyBehavior(AAI->getBeginApply());+}++/// Returns true if the \p address may have any users which let the address+/// escape in an unusual way, e.g. with an address_to_pointer instruction.+static bool hasEscapingUses(SILValue address, int &numChecks) {+  for (Operand *use : address->getUses()) {+    SILInstruction *user = use->getUser();+    +    // Avoid quadratic complexity in corner cases. A limit of 24 is more than+    // enough in most cases.+    if (++numChecks > 24)+      return true;++    switch (user->getKind()) {+      case SILInstructionKind::DebugValueAddrInst:+      case SILInstructionKind::FixLifetimeInst:+      case SILInstructionKind::LoadInst:+      case SILInstructionKind::StoreInst:+      case SILInstructionKind::CopyAddrInst:+      case SILInstructionKind::DestroyAddrInst:+      case SILInstructionKind::DeallocStackInst:+        // Those instructions have no result and cannot escape the address.+        break;+      case SILInstructionKind::ApplyInst:+      case SILInstructionKind::TryApplyInst:+      case SILInstructionKind::BeginApplyInst:+        // Apply instructions can not let an address escape either. It's not+        // possible that an address, passed as an indirect parameter, escapes+        // the function in any way (which is not unsafe and undefined behavior).+        break;+      case SILInstructionKind::OpenExistentialAddrInst:+      case SILInstructionKind::UncheckedTakeEnumDataAddrInst:+      case SILInstructionKind::StructElementAddrInst:+      case SILInstructionKind::TupleElementAddrInst:+      case SILInstructionKind::UncheckedAddrCastInst:+        // Check the uses of address projections.+        if (hasEscapingUses(cast<SingleValueInstruction>(user), numChecks))+          return true;+        break;+      case SILInstructionKind::AddressToPointerInst:+        // This is _the_ instruction which can let an address escape.+        return true;+      default:+        // To be conservative, also bail for anything we don't handle here.+        return true;+    }+  }+  return false;+} -  MemBehavior Behavior = MemBehavior::None;+MemBehavior MemoryBehaviorVisitor::getApplyBehavior(FullApplySite AS) { -  // We can ignore mayTrap().-  bool any_in_guaranteed_params = false;-  for (auto op : enumerate(AI->getArgumentOperands())) {-    if (op.value().get() == V &&-        AI->getSubstCalleeConv().getSILArgumentConvention(op.index()) == swift::SILArgumentConvention::Indirect_In_Guaranteed) {-      any_in_guaranteed_params = true;-      break;+  // Do a quick check first: if V is directly passed to an in_guaranteed+  // argument, we know that the function cannot write to it.+  for (Operand &argOp : AS.getArgumentOperands()) {+    if (argOp.get() == V &&+        AS.getArgumentConvention(argOp) ==+          swift::SILArgumentConvention::Indirect_In_Guaranteed) {+      return MemBehavior::MayRead;     }   } -  if (any_in_guaranteed_params) {-    // one the parameters in the function call is @in_guaranteed of V, ie. the-    // callee isn't allowed to modify it.-    Behavior = MemBehavior::MayRead;-  } else {-    auto &GlobalEffects = ApplyEffects.getGlobalEffects();-    Behavior = GlobalEffects.getMemBehavior(RetainObserveKind::IgnoreRetains);--    // Check all parameter effects.-    for (unsigned Idx = 0, End = AI->getNumArguments();-         Idx < End && Behavior < MemBehavior::MayHaveSideEffects; ++Idx) {-      auto &ArgEffect = ApplyEffects.getParameterEffects()[Idx];-      auto ArgBehavior = ArgEffect.getMemBehavior(RetainObserveKind::IgnoreRetains);-      if (ArgEffect.mayRelease()) {-        Behavior = MemBehavior::MayHaveSideEffects;-        break;-      }-      auto NewBehavior = combineMemoryBehavior(Behavior, ArgBehavior);-      if (NewBehavior != Behavior) {-        SILValue Arg = AI->getArgument(Idx);-        // We only consider the argument effects if the argument aliases V.-        if (!Arg->getType().isAddress() || mayAlias(Arg))-          Behavior = NewBehavior;-      }+  SILValue object = getUnderlyingObject(V);+  int numUsesChecked = 0;+  +  // For exclusive/local addresses we can do a quick and good check with alias+  // analysis. For everything else we use escape analysis (see below).+  // TODO: The check for not-escaping can probably done easier with the upcoming+  // API of AccessStorage.+  bool nonEscapingAddress =+    (isa<AllocStackInst>(object) || isExclusiveArgument(object)) &&+    !hasEscapingUses(object, numUsesChecked);++  FunctionSideEffects applyEffects;+  SEA->getCalleeEffects(applyEffects, AS);++  MemBehavior behavior = MemBehavior::None;+  MemBehavior globalBehavior = applyEffects.getGlobalEffects().getMemBehavior(+                           RetainObserveKind::IgnoreRetains);++  // If it's a non-escaping address, we don't care about the "global" effects+  // of the called function.+  if (!nonEscapingAddress)+    behavior = globalBehavior;+  +  // Check all parameter effects.+  for (unsigned argIdx = 0, end = AS.getNumArguments();+       argIdx < end && behavior < MemBehavior::MayHaveSideEffects;+       ++argIdx) {+    SILValue arg = AS.getArgument(argIdx);+    +    // In case the argument is not an address, alias analysis will always report+    // a no-alias. Therefore we have to treat non-address arguments+    // conservatively here. For example V could be a ref_element_addr of a+    // reference argument. In this case V clearly "aliases" the argument, but+    // this is not reported by alias analysis.+    if ((!nonEscapingAddress && !arg->getType().isAddress()) ||+         mayAlias(arg)) {

I did see the intention of the original code. I did some experiments (for another reason) to check how often this code is actually called and found that it's not called very heavily. Therefore I decided to "optimize" for clarity.

eeckstein

comment created time in 9 days

PullRequestReviewEvent

Pull request review commentapple/swift

SILOptimizer: fix a miscompile in TempRValueOpt and improve MemBehavior

 class MemoryBehaviorVisitor   // memory this will be unnecessary.

yes. I removed it in https://github.com/apple/swift/pull/34289

eeckstein

comment created time in 9 days

PullRequestReviewEvent

create barncheeckstein/swift

branch : fix-side-effect-analysis

created branch time in 9 days

pull request commentapple/swift

SideEffectAnalysis: don't assume that arguments with trivial type can not be pointers.

@swift-ci benchmark

eeckstein

comment created time in 9 days

PR opened apple/swift

SideEffectAnalysis: don't assume that arguments with trivial type can not be pointers.

Even values of trivial type can contain a Builtin.RawPointer, which can be used to read/write from/to.

To compensate for the removed check, enable the escape-analysis check in MemBehavior (as it was before).

This fixes a recently introduced miscompile in https://github.com/apple/swift/pull/34252.

rdar://problem/70220876

+46 -11

0 comment

4 changed files

pr created time in 9 days

delete branch eeckstein/llvm-project

delete branch : cherry-pick-merge-func-fix

delete time in 9 days

PR closed apple/llvm-project

[MergeFuncs] Don't merge shufflevectors with different masks

When the shufflevector mask operand was converted into special instruction data, the FunctionComparator was not updated to account for this. As such, MergeFuncs will happily merge shufflevectors with different masks.

This fixes https://bugs.llvm.org/show_bug.cgi?id=45773.

Differential Revision: https://reviews.llvm.org/D79261

+50 -0

1 comment

2 changed files

eeckstein

pr closed time in 9 days

push eventapple/swift

Erik Eckstein

commit sha 77f16471951fbcdf0bba9929b8e6d5d9228e32f6

RCIdentityAnalysis: some refactoring to improve clarity. NFC.

view details

eeckstein

commit sha 45127174fb4803576fa36be0a70346d4e65ff541

Merge pull request #34274 from eeckstein/rc-identity RCIdentityAnalysis: some refactoring to improve clarity.

view details

push time in 9 days

delete branch eeckstein/swift

delete branch : rc-identity

delete time in 9 days

PR merged apple/swift

Reviewers
RCIdentityAnalysis: some refactoring to improve clarity.

NFC.

This is a follow-up of https://github.com/apple/swift/pull/34183

+37 -28

2 comments

1 changed file

eeckstein

pr closed time in 9 days

pull request commentapple/swift

RCIdentityAnalysis: some refactoring to improve clarity.

@swift-ci smoke test linux

eeckstein

comment created time in 9 days

create barncheeckstein/swift

branch : rc-identity

created branch time in 9 days

pull request commentapple/swift

RCIdentityAnalysis: some refactoring to improve clarity.

@swift-ci smoke test

eeckstein

comment created time in 9 days

PR opened apple/swift

RCIdentityAnalysis: some refactoring to improve clarity.

NFC.

This is a follow-up of https://github.com/apple/swift/pull/34183

+37 -28

0 comment

1 changed file

pr created time in 9 days

push eventapple/swift

Erik Eckstein

commit sha aced5c74df5804b7c567a1ae9cf68b7e9cb336ee

SILOptimizer: Remove InspectionMode from MemBehehaviorVisitor The InspectionMode was never set to anything else than "IgnoreRetains"

view details

Erik Eckstein

commit sha d4a6bd39b686307028b850d25a2a2fbc337160a3

SILOptimizer: improve MemBehavior for apply instructions. 1. Do a better alias analysis for "function-local" objects, like alloc_stack and inout parameters 2. Fully support try_apply and begin/end/abort_apply So far we fully relied on escape analysis. But escape analysis has some shortcomings with SIL address-types. Therefore, handle two common cases, alloc_stack and inout parameters, with alias analysis. This gives better results. The biggest change here is to do a quick check if the address escapes via an address_to_pointer instructions.

view details

Erik Eckstein

commit sha 9f85cb8576becac281397e967e67ec44e5aabc5b

TempRValueElimination: handle potential modifications of the copy-source in a called functions correctly. This fixes a miscompile in case the source of the optimized copy_addr is modified in a called function with to a not visible alias. This can happen with class properties or global variables. This fix removes the special handling of function parameters, which was just wrong. Instead it simply uses the alias analysis API to check for modifications of the source object. The fix makes TempRValueElimination more conservative and this can cause some performance regressions, but this is unavoidable. rdar://problem/69605657

view details

Erik Eckstein

commit sha 68f485424c2b655075c77877acc9ed05756c5d08

SILOptimizer: add an additional TempRValueOpt pass later in the pipeline. This can compensate the performance regression of the more conservative handling of function calls in TempRValueOpt (see previous commit). The pass runs after the inlining passes and can therefore optimize in some cases where it's not possible before inlining.

view details

eeckstein

commit sha 0f6f429ab3da07dc3ae2128ce27e4197bd29f957

Merge pull request #34252 from eeckstein/temp-rvalue-opt SILOptimizer: fix a miscompile in TempRValueOpt and improve MemBehavior

view details

push time in 10 days

delete branch eeckstein/swift

delete branch : temp-rvalue-opt

delete time in 10 days

PR merged apple/swift

Reviewers
SILOptimizer: fix a miscompile in TempRValueOpt and improve MemBehavior

Why include an optimization improvement and a correctness fix in one PR? Unfortunately the correctness fix makes TempRValueElimination more conservative and this can cause some performance regressions. To compensate for this, I improved the handling of apply instructions in MemBehavior.

This change fixes a miscompile in case the source of the optimized copy_addr is modified in a called function via an invisible alias. This can happen with class properties or global variables.

This fix removes the special handling of function parameters, which was just wrong. Instead it simply uses the alias analysis API to check for modifications of the source object.

The changes to improve MemBehavior for apply instructions include:

  1. Do a better alias analysis for "function-local" objects, like alloc_stack and inout parameters
  2. Fully support try_apply and begin/end/abort_apply

For details, see the commit messages.

rdar://problem/69605657

+482 -216

3 comments

15 changed files

eeckstein

pr closed time in 10 days

pull request commentapple/swift

SILOptimizer: fix a miscompile in TempRValueOpt and improve MemBehavior

@swift-ci benchmark

eeckstein

comment created time in 12 days

pull request commentapple/swift

SILOptimizer: fix a miscompile in TempRValueOpt and improve MemBehavior

@swift-ci test

eeckstein

comment created time in 12 days

PR opened apple/swift

SILOptimizer: fix a miscompile in TempRValueOpt and improve MemBehavior

Why include an optimization improvement and a correctness fix in one PR? Unfortunately the correctness fix makes TempRValueElimination more conservative and this can cause some performance regressions. To compensate for this, I improved the handling of apply instructions in MemBehavior.

This change fixes a miscompile in case the source of the optimized copy_addr is modified in a called function via an invisible alias. This can happen with class properties or global variables.

This fix removes the special handling of function parameters, which was just wrong. Instead it simply uses the alias analysis API to check for modifications of the source object.

The changes to improve MemBehavior for apply instructions include:

  1. Do a better alias analysis for "function-local" objects, like alloc_stack and inout parameters
  2. Fully support try_apply and begin/end/abort_apply

For details, see the commit messages.

rdar://problem/69605657

+482 -216

0 comment

15 changed files

pr created time in 12 days

create barncheeckstein/swift

branch : temp-rvalue-opt

created branch time in 12 days

pull request commentapple/swift

Optimize string switch

Yes, I think it makes sense to continue with this. Just let me do another round of review.

zoecarver

comment created time in 14 days

push eventapple/swift

Robert Widmann

commit sha 38b1da30bdea7c468ebdcd8cd289c9504eea2089

Patch Out Use-Of-Stack-After-Free In Cross Module Dependencies The fake job is entered into the map to satisfy the tracing machinery. When that same machinery kicks into gear to print out paths, lookups into the dictionary will access data has gone out of scope. For now, cut off the read. There will be another refactoring patch that keeps these temporaries out of the Driver's data structures entirely. rdar://70053563

view details

eeckstein

commit sha d70f35d09dece4ea054cf7aa735e7184e14af093

Merge pull request #34218 from CodaFi/pseudo-lithis Patch Out Use-Of-Stack-After-Free In Cross Module Dependencies

view details

push time in 14 days

PR merged apple/swift

Patch Out Use-Of-Stack-After-Free In Cross Module Dependencies

The fake job is entered into the map to satisfy the tracing machinery. When that same machinery kicks into gear to print out paths, lookups into the dictionary will access data has gone out of scope.

For now, cut off the read. There will be another refactoring patch that keeps these temporaries out of the Driver's data structures entirely.

rdar://70053563

+5 -0

2 comments

1 changed file

CodaFi

pr closed time in 14 days

push eventapple/swift

Karoy Lorentey

commit sha d5652fa9bf37b3bb6bfe0ec616ae220de2baff30

[test] Don’t check for new behavior on older systems that don’t include the change

view details

eeckstein

commit sha 840f1a42336e5cf9aaa4650903e2eae03c974aa4

Merge pull request #34203 from apple/data-test-availability [test] Don’t check for new behavior on older systems that don’t include the change

view details

push time in 15 days

more