Prior to this change, CallBase::hasFnAttr checked the called function to see if it had an attribute if it wasn't set on the CallBase, but getFnAttr didn't do the same delegation, which led to very confusing behavior. This patch fixes the issue by making CallBase::getFnAttr also check the function under the same circumstances. Test changes look (to me) like they're cleaning up redundant attributes which no longer get specified both on the callee and call. We also clean up the one ad-hoc implementation of this getter over in InlineCost.cpp. Differential Revision: https://reviews.llvm.org/D122821
96 lines
3.3 KiB
LLVM
96 lines
3.3 KiB
LLVM
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature --check-attributes --check-globals
|
|
; RUN: opt -attributor -enable-new-pm=0 -attributor-manifest-internal -attributor-max-iterations-verify -attributor-annotate-decl-cs -attributor-max-iterations=2 -S < %s | FileCheck %s --check-prefixes=CHECK,NOT_CGSCC_NPM,NOT_CGSCC_OPM,NOT_TUNIT_NPM,IS__TUNIT____,IS________OPM,IS__TUNIT_OPM
|
|
; RUN: opt -aa-pipeline=basic-aa -passes=attributor -attributor-manifest-internal -attributor-max-iterations-verify -attributor-annotate-decl-cs -attributor-max-iterations=2 -S < %s | FileCheck %s --check-prefixes=CHECK,NOT_CGSCC_OPM,NOT_CGSCC_NPM,NOT_TUNIT_OPM,IS__TUNIT____,IS________NPM,IS__TUNIT_NPM
|
|
; RUN: opt -attributor-cgscc -enable-new-pm=0 -attributor-manifest-internal -attributor-annotate-decl-cs -S < %s | FileCheck %s --check-prefixes=CHECK,NOT_TUNIT_NPM,NOT_TUNIT_OPM,NOT_CGSCC_NPM,IS__CGSCC____,IS________OPM,IS__CGSCC_OPM
|
|
; RUN: opt -aa-pipeline=basic-aa -passes=attributor-cgscc -attributor-manifest-internal -attributor-annotate-decl-cs -S < %s | FileCheck %s --check-prefixes=CHECK,NOT_TUNIT_NPM,NOT_TUNIT_OPM,NOT_CGSCC_OPM,IS__CGSCC____,IS________NPM,IS__CGSCC_NPM
|
|
|
|
define dso_local void @entry(i1 %cond) #0 {
|
|
; CHECK-LABEL: define {{[^@]+}}@entry
|
|
; CHECK-SAME: (i1 [[COND:%.*]]) #[[ATTR0:[0-9]+]] {
|
|
; CHECK-NEXT: entry:
|
|
; CHECK-NEXT: call void @foo(i1 [[COND]])
|
|
; CHECK-NEXT: call void @bar()
|
|
; CHECK-NEXT: call void @qux() #[[ATTR1:[0-9]+]]
|
|
; CHECK-NEXT: ret void
|
|
;
|
|
entry:
|
|
call void @foo(i1 %cond)
|
|
call void @bar()
|
|
call void @qux() #1
|
|
ret void
|
|
}
|
|
|
|
define internal void @foo(i1 %cond) #1 {
|
|
; CHECK-LABEL: define {{[^@]+}}@foo
|
|
; CHECK-SAME: (i1 [[COND:%.*]]) #[[ATTR1]] {
|
|
; CHECK-NEXT: entry:
|
|
; CHECK-NEXT: call void @baz(i1 [[COND]])
|
|
; CHECK-NEXT: ret void
|
|
;
|
|
entry:
|
|
call void @baz(i1 %cond)
|
|
ret void
|
|
}
|
|
|
|
define internal void @bar() #2 {
|
|
; CHECK-LABEL: define {{[^@]+}}@bar
|
|
; CHECK-SAME: () #[[ATTR2:[0-9]+]] {
|
|
; CHECK-NEXT: entry:
|
|
; CHECK-NEXT: call void @baz(i1 noundef false) #[[ATTR2]]
|
|
; CHECK-NEXT: ret void
|
|
;
|
|
entry:
|
|
call void @baz(i1 0)
|
|
ret void
|
|
}
|
|
|
|
define internal void @baz(i1 %Cond) {
|
|
; CHECK-LABEL: define {{[^@]+}}@baz
|
|
; CHECK-SAME: (i1 [[COND:%.*]]) #[[ATTR1]] {
|
|
; CHECK-NEXT: entry:
|
|
; CHECK-NEXT: [[TOBOOL:%.*]] = icmp ne i1 [[COND]], false
|
|
; CHECK-NEXT: br i1 [[TOBOOL]], label [[IF_THEN:%.*]], label [[IF_END:%.*]]
|
|
; CHECK: if.then:
|
|
; CHECK-NEXT: call void @baz(i1 noundef false)
|
|
; CHECK-NEXT: br label [[IF_END]]
|
|
; CHECK: if.end:
|
|
; CHECK-NEXT: call void @qux()
|
|
; CHECK-NEXT: ret void
|
|
;
|
|
entry:
|
|
%tobool = icmp ne i1 %Cond, 0
|
|
br i1 %tobool, label %if.then, label %if.end
|
|
|
|
if.then:
|
|
call void @baz(i1 0)
|
|
br label %if.end
|
|
|
|
if.end:
|
|
call void @qux()
|
|
ret void
|
|
}
|
|
|
|
define internal void @qux() {
|
|
; CHECK-LABEL: define {{[^@]+}}@qux
|
|
; CHECK-SAME: () #[[ATTR1]] {
|
|
; CHECK-NEXT: entry:
|
|
; CHECK-NEXT: call void @call()
|
|
; CHECK-NEXT: ret void
|
|
;
|
|
entry:
|
|
call void @call()
|
|
ret void
|
|
}
|
|
|
|
declare void @call() #3
|
|
|
|
attributes #0 = { "llvm.assume"="A" }
|
|
attributes #1 = { "llvm.assume"="B" }
|
|
attributes #2 = { "llvm.assume"="B,C" }
|
|
attributes #3 = { "llvm.assume"="B,C,A" }
|
|
;.
|
|
; CHECK: attributes #[[ATTR0]] = { "llvm.assume"="A" }
|
|
; CHECK: attributes #[[ATTR1]] = { "llvm.assume"="B,A" }
|
|
; CHECK: attributes #[[ATTR2]] = { "llvm.assume"="B,C,A" }
|
|
;.
|