Skip to content

Commit c4d3188

Browse files
committed
[Attributor][NFC] Reduce indention for call site attribute seeding
Also added a TODO to remind us that indirect calls could be optimized as well.
1 parent d18bb24 commit c4d3188

File tree

1 file changed

+38
-34
lines changed

1 file changed

+38
-34
lines changed

llvm/lib/Transforms/IPO/Attributor.cpp

Lines changed: 38 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1807,54 +1807,58 @@ void Attributor::identifyDefaultAbstractAttributes(Function &F) {
18071807
// users. The return value might be dead if there are no live users.
18081808
getOrCreateAAFor<AAIsDead>(CSRetPos);
18091809

1810-
if (Function *Callee = CS.getCalledFunction()) {
1811-
// Skip declerations except if annotations on their call sites were
1812-
// explicitly requested.
1813-
if (!AnnotateDeclarationCallSites && Callee->isDeclaration() &&
1814-
!Callee->hasMetadata(LLVMContext::MD_callback))
1815-
return true;
1810+
Function *Callee = CS.getCalledFunction();
1811+
// TODO: Even if the callee is not known now we might be able to simplify
1812+
// the call/callee.
1813+
if (!Callee)
1814+
return true;
18161815

1817-
if (!Callee->getReturnType()->isVoidTy() && !CS->use_empty()) {
1816+
// Skip declarations except if annotations on their call sites were
1817+
// explicitly requested.
1818+
if (!AnnotateDeclarationCallSites && Callee->isDeclaration() &&
1819+
!Callee->hasMetadata(LLVMContext::MD_callback))
1820+
return true;
18181821

1819-
IRPosition CSRetPos = IRPosition::callsite_returned(CS);
1822+
if (!Callee->getReturnType()->isVoidTy() && !CS->use_empty()) {
18201823

1821-
// Call site return integer values might be limited by a constant range.
1822-
if (Callee->getReturnType()->isIntegerTy())
1823-
getOrCreateAAFor<AAValueConstantRange>(CSRetPos);
1824-
}
1824+
IRPosition CSRetPos = IRPosition::callsite_returned(CS);
1825+
1826+
// Call site return integer values might be limited by a constant range.
1827+
if (Callee->getReturnType()->isIntegerTy())
1828+
getOrCreateAAFor<AAValueConstantRange>(CSRetPos);
1829+
}
18251830

1826-
for (int i = 0, e = CS.getNumArgOperands(); i < e; i++) {
1831+
for (int i = 0, e = CS.getNumArgOperands(); i < e; i++) {
18271832

1828-
IRPosition CSArgPos = IRPosition::callsite_argument(CS, i);
1833+
IRPosition CSArgPos = IRPosition::callsite_argument(CS, i);
18291834

1830-
// Every call site argument might be dead.
1831-
getOrCreateAAFor<AAIsDead>(CSArgPos);
1835+
// Every call site argument might be dead.
1836+
getOrCreateAAFor<AAIsDead>(CSArgPos);
18321837

1833-
// Call site argument might be simplified.
1834-
getOrCreateAAFor<AAValueSimplify>(CSArgPos);
1838+
// Call site argument might be simplified.
1839+
getOrCreateAAFor<AAValueSimplify>(CSArgPos);
18351840

1836-
if (!CS.getArgument(i)->getType()->isPointerTy())
1837-
continue;
1841+
if (!CS.getArgument(i)->getType()->isPointerTy())
1842+
continue;
18381843

1839-
// Call site argument attribute "non-null".
1840-
getOrCreateAAFor<AANonNull>(CSArgPos);
1844+
// Call site argument attribute "non-null".
1845+
getOrCreateAAFor<AANonNull>(CSArgPos);
18411846

1842-
// Call site argument attribute "no-alias".
1843-
getOrCreateAAFor<AANoAlias>(CSArgPos);
1847+
// Call site argument attribute "no-alias".
1848+
getOrCreateAAFor<AANoAlias>(CSArgPos);
18441849

1845-
// Call site argument attribute "dereferenceable".
1846-
getOrCreateAAFor<AADereferenceable>(CSArgPos);
1850+
// Call site argument attribute "dereferenceable".
1851+
getOrCreateAAFor<AADereferenceable>(CSArgPos);
18471852

1848-
// Call site argument attribute "align".
1849-
getOrCreateAAFor<AAAlign>(CSArgPos);
1853+
// Call site argument attribute "align".
1854+
getOrCreateAAFor<AAAlign>(CSArgPos);
18501855

1851-
// Call site argument attribute
1852-
// "readnone/readonly/writeonly/..."
1853-
getOrCreateAAFor<AAMemoryBehavior>(CSArgPos);
1856+
// Call site argument attribute
1857+
// "readnone/readonly/writeonly/..."
1858+
getOrCreateAAFor<AAMemoryBehavior>(CSArgPos);
18541859

1855-
// Call site argument attribute "nofree".
1856-
getOrCreateAAFor<AANoFree>(CSArgPos);
1857-
}
1860+
// Call site argument attribute "nofree".
1861+
getOrCreateAAFor<AANoFree>(CSArgPos);
18581862
}
18591863
return true;
18601864
};

0 commit comments

Comments
 (0)