mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
`ReadOnly, ArgMemOnly` previously meant `can only read argument memory`.
But with the rebranch changes, this became `(can only read *all* memory)
and (can read or write argument memory)`. Use `ArgMemReadOnly` for this
instead.
To expand on this, these attributes (prior to memory effects) used to be
split into two. There was the *kind* of access, eg.
```
readnone
readonly
writeonly
```
and the accessed *location*, eg.
```
argmemonly
inaccessiblememonly
inaccessiblemem_or_argmemonly
```
So `RuntimeFunctions.def` would use `ReadOnly, ArgMemOnly` to mean `can
only read argument memory`.
In the previous rebranch commits, this was changed such that `ReadOnly`
mapped to `MemoryEffectsBase::readOnly()` and `ArgMemOnly` to
`MemoryEffectsBase::argMemOnly()`.
And there lies the issue -
- `MemoryEffectsBase::readOnly()` == `MemoryEffectsBase(Ref)` ie. all
locations can only read
- `MemoryEffectsBase::argMemOnly()` == `MemoryEffectsBase(ArgMem,
ModRef)`, ie. can only access argument memory
But then OR'ing those together this would become:
```
ArgMem: ModRef, InaccessibleMem: Ref, Other: Ref
```
rather than the previously intended:
```
ArgMem: Ref, InaccessibleMem: NoModRef, Other: NoModRef
```
56 lines
2.0 KiB
C++
56 lines
2.0 KiB
C++
//===--- RuntimeFnWrappersGen.h - LLVM IR Generation for runtime functions ===//
|
|
//
|
|
// This source file is part of the Swift.org open source project
|
|
//
|
|
// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
|
|
// Licensed under Apache License v2.0 with Runtime Library Exception
|
|
//
|
|
// See https://swift.org/LICENSE.txt for license information
|
|
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
// Helper functions providing the LLVM IR generation for runtime entry points.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
#ifndef SWIFT_RUNTIME_RUNTIMEFNWRAPPERSGEN_H
|
|
#define SWIFT_RUNTIME_RUNTIMEFNWRAPPERSGEN_H
|
|
|
|
#include "swift/SIL/RuntimeEffect.h"
|
|
#include "llvm/ADT/ArrayRef.h"
|
|
#include "llvm/IR/Module.h"
|
|
|
|
namespace swift {
|
|
|
|
class AvailabilityContext;
|
|
class ASTContext;
|
|
|
|
namespace irgen {
|
|
class IRGenModule;
|
|
}
|
|
|
|
enum class RuntimeAvailability {
|
|
AlwaysAvailable,
|
|
AvailableByCompatibilityLibrary,
|
|
ConditionallyAvailable
|
|
};
|
|
|
|
/// Generate an llvm declaration for a runtime entry with a
|
|
/// given name, return types, argument types, attributes and
|
|
/// a calling convention.
|
|
llvm::Constant *getRuntimeFn(llvm::Module &Module, llvm::Constant *&cache,
|
|
char const *name, llvm::CallingConv::ID cc,
|
|
RuntimeAvailability availability,
|
|
llvm::ArrayRef<llvm::Type *> retTypes,
|
|
llvm::ArrayRef<llvm::Type *> argTypes,
|
|
llvm::ArrayRef<llvm::Attribute::AttrKind> attrs,
|
|
llvm::ArrayRef<llvm::MemoryEffects> memEffects,
|
|
irgen::IRGenModule *IGM = nullptr);
|
|
|
|
llvm::FunctionType *getRuntimeFnType(llvm::Module &Module,
|
|
llvm::ArrayRef<llvm::Type *> retTypes,
|
|
llvm::ArrayRef<llvm::Type *> argTypes);
|
|
|
|
} // namespace swift
|
|
#endif
|