Skip to content

Commit f4f40c6

Browse files
committed
[Attributor] Introduce a hook for AAs to avoid inline-asm
1 parent 9207a90 commit f4f40c6

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

llvm/include/llvm/Transforms/IPO/Attributor.h

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1742,10 +1742,16 @@ struct Attributor {
17421742

17431743
Function *AssociatedFn = IRP.getAssociatedFunction();
17441744

1745-
// Check if we require a callee but there is none.
1746-
if (!AssociatedFn && AAType::requiresCalleeForCallBase() &&
1747-
IRP.isAnyCallSitePosition())
1748-
return false;
1745+
if (IRP.isAnyCallSitePosition()) {
1746+
// Check if we require a callee but there is none.
1747+
if (!AssociatedFn && AAType::requiresCalleeForCallBase())
1748+
return false;
1749+
1750+
// Check if we require non-asm but it is inline asm.
1751+
if (AAType::requiresNonAsmForCallBase() &&
1752+
cast<CallBase>(IRP.getAnchorValue()).isInlineAsm())
1753+
return false;
1754+
}
17491755

17501756
// Check if we require a calles but we can't see all.
17511757
if (AAType::requiresCallersForArgOrFunction())
@@ -3291,6 +3297,9 @@ struct AbstractAttribute : public IRPosition, public AADepGraphNode {
32913297
/// a call site positon. Default is optimistic to minimize AAs.
32923298
static bool requiresCalleeForCallBase() { return true; }
32933299

3300+
/// Return true if this AA requires non-asm "callee" for a call site positon.
3301+
static bool requiresNonAsmForCallBase() { return true; }
3302+
32943303
/// Return true if this AA requires all callees for an argument or function
32953304
/// positon.
32963305
static bool requiresCallersForArgOrFunction() { return false; }
@@ -5476,6 +5485,9 @@ struct AACallEdges : public StateWrapper<BooleanState, AbstractAttribute>,
54765485
/// unknown callees.
54775486
static bool requiresCalleeForCallBase() { return false; }
54785487

5488+
/// See AbstractAttribute::requiresNonAsmForCallBase.
5489+
static bool requiresNonAsmForCallBase() { return false; }
5490+
54795491
/// Get the optimistic edges.
54805492
virtual const SetVector<Function *> &getOptimisticEdges() const = 0;
54815493

0 commit comments

Comments
 (0)