Deduce captures(none) for a return place and parameters
Extend attribute deduction to determine whether parameters using indirect pass mode might have their address captured. Similarly to the deduction of `readonly` attribute this information facilitates memcpy optimizations.
This commit is contained in:
parent
79966ae420
commit
2a03a948b9
17 changed files with 333 additions and 181 deletions
|
|
@ -245,6 +245,7 @@ enum class LLVMRustAttributeKind {
|
|||
DeadOnUnwind = 43,
|
||||
DeadOnReturn = 44,
|
||||
CapturesReadOnly = 45,
|
||||
CapturesNone = 46,
|
||||
};
|
||||
|
||||
static Attribute::AttrKind fromRust(LLVMRustAttributeKind Kind) {
|
||||
|
|
@ -339,6 +340,7 @@ static Attribute::AttrKind fromRust(LLVMRustAttributeKind Kind) {
|
|||
#endif
|
||||
case LLVMRustAttributeKind::CapturesAddress:
|
||||
case LLVMRustAttributeKind::CapturesReadOnly:
|
||||
case LLVMRustAttributeKind::CapturesNone:
|
||||
report_fatal_error("Should be handled separately");
|
||||
}
|
||||
report_fatal_error("bad LLVMRustAttributeKind");
|
||||
|
|
@ -390,6 +392,9 @@ extern "C" void LLVMRustEraseInstFromParent(LLVMValueRef Instr) {
|
|||
extern "C" LLVMAttributeRef
|
||||
LLVMRustCreateAttrNoValue(LLVMContextRef C, LLVMRustAttributeKind RustAttr) {
|
||||
#if LLVM_VERSION_GE(21, 0)
|
||||
if (RustAttr == LLVMRustAttributeKind::CapturesNone) {
|
||||
return wrap(Attribute::getWithCaptureInfo(*unwrap(C), CaptureInfo::none()));
|
||||
}
|
||||
if (RustAttr == LLVMRustAttributeKind::CapturesAddress) {
|
||||
return wrap(Attribute::getWithCaptureInfo(
|
||||
*unwrap(C), CaptureInfo(CaptureComponents::Address)));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue