forked from OSchip/llvm-project
[Attributes] Merge calls to getFnAttribute/hasFnAttribute using Attribute::isValid. NFC
Rather than calling hasFnAttribute and then calling getFnAttribute if the attribute exists, its better to just call getFnAttribute and then check if we got a valid attribute back.
This commit is contained in:
parent
c1b3e32118
commit
6dcd9f517e
|
@ -1937,21 +1937,19 @@ static void adjustCallerStackProbes(Function &Caller, const Function &Callee) {
|
||||||
/// that is no larger.
|
/// that is no larger.
|
||||||
static void
|
static void
|
||||||
adjustCallerStackProbeSize(Function &Caller, const Function &Callee) {
|
adjustCallerStackProbeSize(Function &Caller, const Function &Callee) {
|
||||||
if (Callee.hasFnAttribute("stack-probe-size")) {
|
Attribute CalleeAttr = Callee.getFnAttribute("stack-probe-size");
|
||||||
uint64_t CalleeStackProbeSize;
|
if (CalleeAttr.isValid()) {
|
||||||
Callee.getFnAttribute("stack-probe-size")
|
Attribute CallerAttr = Caller.getFnAttribute("stack-probe-size");
|
||||||
.getValueAsString()
|
if (CallerAttr.isValid()) {
|
||||||
.getAsInteger(0, CalleeStackProbeSize);
|
uint64_t CallerStackProbeSize, CalleeStackProbeSize;
|
||||||
if (Caller.hasFnAttribute("stack-probe-size")) {
|
CallerAttr.getValueAsString().getAsInteger(0, CallerStackProbeSize);
|
||||||
uint64_t CallerStackProbeSize;
|
CalleeAttr.getValueAsString().getAsInteger(0, CalleeStackProbeSize);
|
||||||
Caller.getFnAttribute("stack-probe-size")
|
|
||||||
.getValueAsString()
|
|
||||||
.getAsInteger(0, CallerStackProbeSize);
|
|
||||||
if (CallerStackProbeSize > CalleeStackProbeSize) {
|
if (CallerStackProbeSize > CalleeStackProbeSize) {
|
||||||
Caller.addFnAttr(Callee.getFnAttribute("stack-probe-size"));
|
Caller.addFnAttr(CalleeAttr);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Caller.addFnAttr(Callee.getFnAttribute("stack-probe-size"));
|
Caller.addFnAttr(CalleeAttr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1967,18 +1965,15 @@ adjustCallerStackProbeSize(Function &Caller, const Function &Callee) {
|
||||||
/// handled as part of inline cost analysis.
|
/// handled as part of inline cost analysis.
|
||||||
static void
|
static void
|
||||||
adjustMinLegalVectorWidth(Function &Caller, const Function &Callee) {
|
adjustMinLegalVectorWidth(Function &Caller, const Function &Callee) {
|
||||||
if (Caller.hasFnAttribute("min-legal-vector-width")) {
|
Attribute CallerAttr = Caller.getFnAttribute("min-legal-vector-width");
|
||||||
if (Callee.hasFnAttribute("min-legal-vector-width")) {
|
if (CallerAttr.isValid()) {
|
||||||
uint64_t CallerVectorWidth;
|
Attribute CalleeAttr = Callee.getFnAttribute("min-legal-vector-width");
|
||||||
Caller.getFnAttribute("min-legal-vector-width")
|
if (CalleeAttr.isValid()) {
|
||||||
.getValueAsString()
|
uint64_t CallerVectorWidth, CalleeVectorWidth;
|
||||||
.getAsInteger(0, CallerVectorWidth);
|
CallerAttr.getValueAsString().getAsInteger(0, CallerVectorWidth);
|
||||||
uint64_t CalleeVectorWidth;
|
CalleeAttr.getValueAsString().getAsInteger(0, CalleeVectorWidth);
|
||||||
Callee.getFnAttribute("min-legal-vector-width")
|
|
||||||
.getValueAsString()
|
|
||||||
.getAsInteger(0, CalleeVectorWidth);
|
|
||||||
if (CallerVectorWidth < CalleeVectorWidth)
|
if (CallerVectorWidth < CalleeVectorWidth)
|
||||||
Caller.addFnAttr(Callee.getFnAttribute("min-legal-vector-width"));
|
Caller.addFnAttr(CalleeAttr);
|
||||||
} else {
|
} else {
|
||||||
// If the callee doesn't have the attribute then we don't know anything
|
// If the callee doesn't have the attribute then we don't know anything
|
||||||
// and must drop the attribute from the caller.
|
// and must drop the attribute from the caller.
|
||||||
|
|
Loading…
Reference in New Issue