
Relative to the previous attempt this includes two fixes: * Adjust callCapturesBefore() to not skip captures(ret: address, provenance) arguments, as these will not count as a capture at the call-site. * When visiting uses during stack slot optimization, don't skip the ModRef check for passthru captures. Calls can both modref and be passthru for captures. ------ This extends CaptureTracking to support inferring non-trivial CaptureInfos. The focus of this patch is to only support FunctionAttrs, other users of CaptureTracking will be updated in followups. The key API changes here are: * DetermineUseCaptureKind() now returns a UseCaptureInfo where the UseCC component specifies what is captured at that Use and the ResultCC component specifies what may be captured via the return value of the User. Usually only one or the other will be used (corresponding to previous MAY_CAPTURE or PASSTHROUGH results), but both may be set for call captures. * The CaptureTracking::captures() extension point is passed this UseCaptureInfo as well and then can decide what to do with it by returning an Action, which is one of: Stop: stop traversal. ContinueIgnoringReturn: continue traversal but don't follow the instruction return value. Continue: continue traversal and follow the instruction return value if it has additional CaptureComponents. For now, this patch retains the (unsound) special logic for comparison of null with a dereferenceable pointer. I'd like to switch key code to take advantage of address/address_is_null before dropping it. This PR mainly intends to introduce necessary API changes and basic inference support, there are various possible improvements marked with TODOs.
27 lines
879 B
LLVM
27 lines
879 B
LLVM
; RUN: opt -passes=function-attrs -stats -disable-output %s 2>&1 | FileCheck %s
|
|
|
|
; REQUIRES: asserts
|
|
|
|
@g = global i32 20
|
|
|
|
define i32 @test_only_read_arg(ptr %ptr) {
|
|
entry:
|
|
%l = load i32, ptr %ptr
|
|
ret i32 %l
|
|
}
|
|
|
|
define void @test_write_global() {
|
|
entry:
|
|
store i32 0, ptr @g
|
|
ret void
|
|
}
|
|
|
|
; CHECK: 1 function-attrs - Number of arguments marked captures(none)
|
|
; CHECK-NEXT: 2 function-attrs - Number of functions with improved memory attribute
|
|
; CHECK-NEXT: 1 function-attrs - Number of functions marked as nofree
|
|
; CHECK-NEXT: 2 function-attrs - Number of functions marked as norecurse
|
|
; CHECK-NEXT: 2 function-attrs - Number of functions marked as nosync
|
|
; CHECK-NEXT: 2 function-attrs - Number of functions marked as nounwind
|
|
; CHECK-NEXT: 1 function-attrs - Number of arguments marked readonly
|
|
; CHECK-NEXT: 2 function-attrs - Number of functions marked as willreturn
|