This patch adds initial argmemonly inference, by checking the underlying
objects of locations returned by MemoryLocation.
I think this should cover most cases, except function calls to other
argmemonly functions.
I'm not sure if there's a reason why we don't infer those yet.
Additional argmemonly can improve codegen in some cases. It also makes
it easier to come up with a C reproducer for 7662d1687b (already fixed,
but I'm trying to see if C/C++ fuzzing could help to uncover similar
issues.)
Compile-time impact:
NewPM-O3: +0.01%
NewPM-ReleaseThinLTO: +0.03%
NewPM-ReleaseLTO+g: +0.05%
https://llvm-compile-time-tracker.com/compare.php?from=067c035012fc061ad6378458774ac2df117283c6&to=fe209d4aab5b593bd62d18c0876732ddcca1614d&stat=instructions
Reviewed By: nikic
Differential Revision: https://reviews.llvm.org/D121415
29 lines
1003 B
LLVM
29 lines
1003 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(i32* %ptr) {
|
|
entry:
|
|
%l = load i32, i32* %ptr
|
|
ret i32 %l
|
|
}
|
|
|
|
define void @test_write_global() {
|
|
entry:
|
|
store i32 0, i32* @g
|
|
ret void
|
|
}
|
|
|
|
; CHECK: 1 function-attrs - Number of functions marked argmemonly
|
|
; CHECK-NEXT: 1 function-attrs - Number of arguments marked nocapture
|
|
; 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 functions marked readonly
|
|
; CHECK-NEXT: 1 function-attrs - Number of arguments marked readonly
|
|
; CHECK-NEXT: 2 function-attrs - Number of functions marked as willreturn
|
|
; CHECK-NEXT: 1 function-attrs - Number of functions marked writeonly
|