Skip to content

[llvm] annotate interfaces in llvm/Analysis for DLL export #136623

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
164 changes: 91 additions & 73 deletions llvm/include/llvm/Analysis/AliasAnalysis.h

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions llvm/include/llvm/Analysis/AliasAnalysisEvaluator.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#define LLVM_ANALYSIS_ALIASANALYSISEVALUATOR_H

#include "llvm/IR/PassManager.h"
#include "llvm/Support/Compiler.h"

namespace llvm {
class AAResults;
Expand All @@ -47,10 +48,10 @@ class AAEvaluator : public PassInfoMixin<AAEvaluator> {
ModRefCount(Arg.ModRefCount) {
Arg.FunctionCount = 0;
}
~AAEvaluator();
LLVM_ABI ~AAEvaluator();

/// Run the pass over the function.
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
LLVM_ABI PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);

private:
void runInternal(Function &F, AAResults &AA);
Expand Down
56 changes: 30 additions & 26 deletions llvm/include/llvm/Analysis/AliasSetTracker.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "llvm/Analysis/MemoryLocation.h"
#include "llvm/IR/PassManager.h"
#include "llvm/IR/ValueHandle.h"
#include "llvm/Support/Compiler.h"
#include <cassert>
#include <vector>

Expand Down Expand Up @@ -113,7 +114,8 @@ class AliasSet : public ilist_node<AliasSet> {
bool isForwardingAliasSet() const { return Forward; }

/// Merge the specified alias set into this alias set.
void mergeSetIn(AliasSet &AS, AliasSetTracker &AST, BatchAAResults &BatchAA);
LLVM_ABI void mergeSetIn(AliasSet &AS, AliasSetTracker &AST,
BatchAAResults &BatchAA);

// Alias Set iteration - Allow access to all of the memory locations which are
// part of this alias set.
Expand All @@ -127,17 +129,17 @@ class AliasSet : public ilist_node<AliasSet> {
/// The order matches that of the memory locations, but duplicate pointer
/// values are omitted.
using PointerVector = SmallVector<const Value *, 8>;
PointerVector getPointers() const;
LLVM_ABI PointerVector getPointers() const;

void print(raw_ostream &OS) const;
void dump() const;
LLVM_ABI void print(raw_ostream &OS) const;
LLVM_ABI void dump() const;

private:
// Can only be created by AliasSetTracker.
AliasSet()
: RefCount(0), AliasAny(false), Access(NoAccess), Alias(SetMustAlias) {}

void removeFromTracker(AliasSetTracker &AST);
LLVM_ABI void removeFromTracker(AliasSetTracker &AST);

void addMemoryLocation(AliasSetTracker &AST, const MemoryLocation &MemLoc,
bool KnownMustAlias = false);
Expand All @@ -146,11 +148,11 @@ class AliasSet : public ilist_node<AliasSet> {
public:
/// If the specified memory location "may" (or must) alias one of the members
/// in the set return the appropriate AliasResult. Otherwise return NoAlias.
AliasResult aliasesMemoryLocation(const MemoryLocation &MemLoc,
BatchAAResults &AA) const;
LLVM_ABI AliasResult aliasesMemoryLocation(const MemoryLocation &MemLoc,
BatchAAResults &AA) const;

ModRefInfo aliasesUnknownInst(const Instruction *Inst,
BatchAAResults &AA) const;
LLVM_ABI ModRefInfo aliasesUnknownInst(const Instruction *Inst,
BatchAAResults &AA) const;
};

inline raw_ostream& operator<<(raw_ostream &OS, const AliasSet &AS) {
Expand Down Expand Up @@ -183,18 +185,20 @@ class AliasSetTracker {
/// 3. If the instruction aliases multiple sets, merge the sets, and add
/// the instruction to the result.
///
void add(const MemoryLocation &Loc);
void add(LoadInst *LI);
void add(StoreInst *SI);
void add(VAArgInst *VAAI);
void add(AnyMemSetInst *MSI);
void add(AnyMemTransferInst *MTI);
void add(Instruction *I); // Dispatch to one of the other add methods...
void add(BasicBlock &BB); // Add all instructions in basic block
void add(const AliasSetTracker &AST); // Add alias relations from another AST
void addUnknown(Instruction *I);

void clear();
LLVM_ABI void add(const MemoryLocation &Loc);
LLVM_ABI void add(LoadInst *LI);
LLVM_ABI void add(StoreInst *SI);
LLVM_ABI void add(VAArgInst *VAAI);
LLVM_ABI void add(AnyMemSetInst *MSI);
LLVM_ABI void add(AnyMemTransferInst *MTI);
LLVM_ABI void
add(Instruction *I); // Dispatch to one of the other add methods...
LLVM_ABI void add(BasicBlock &BB); // Add all instructions in basic block
LLVM_ABI void
add(const AliasSetTracker &AST); // Add alias relations from another AST
LLVM_ABI void addUnknown(Instruction *I);

LLVM_ABI void clear();

/// Return the alias sets that are active.
const ilist<AliasSet> &getAliasSets() const { return AliasSets; }
Expand All @@ -203,7 +207,7 @@ class AliasSetTracker {
/// the memory location aliases two or more existing alias sets, will have
/// the effect of merging those alias sets before the single resulting alias
/// set is returned.
AliasSet &getAliasSetFor(const MemoryLocation &MemLoc);
LLVM_ABI AliasSet &getAliasSetFor(const MemoryLocation &MemLoc);

/// Return the underlying alias analysis object used by this tracker.
BatchAAResults &getAliasAnalysis() const { return AA; }
Expand All @@ -217,8 +221,8 @@ class AliasSetTracker {
iterator begin() { return AliasSets.begin(); }
iterator end() { return AliasSets.end(); }

void print(raw_ostream &OS) const;
void dump() const;
LLVM_ABI void print(raw_ostream &OS) const;
LLVM_ABI void dump() const;

private:
friend class AliasSet;
Expand Down Expand Up @@ -270,8 +274,8 @@ class AliasSetsPrinterPass : public PassInfoMixin<AliasSetsPrinterPass> {
raw_ostream &OS;

public:
explicit AliasSetsPrinterPass(raw_ostream &OS);
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
LLVM_ABI explicit AliasSetsPrinterPass(raw_ostream &OS);
LLVM_ABI PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
static bool isRequired() { return true; }
};

Expand Down
34 changes: 18 additions & 16 deletions llvm/include/llvm/Analysis/AssumeBundleQueries.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

#include "llvm/ADT/DenseMap.h"
#include "llvm/IR/IntrinsicInst.h"
#include "llvm/Support/Compiler.h"

namespace llvm {
class AssumptionCache;
Expand All @@ -38,8 +39,9 @@ enum AssumeBundleArg {
///
/// Return true iff the queried attribute was found.
/// If ArgVal is set. the argument will be stored to ArgVal.
bool hasAttributeInAssume(AssumeInst &Assume, Value *IsOn, StringRef AttrName,
uint64_t *ArgVal = nullptr);
LLVM_ABI bool hasAttributeInAssume(AssumeInst &Assume, Value *IsOn,
StringRef AttrName,
uint64_t *ArgVal = nullptr);
inline bool hasAttributeInAssume(AssumeInst &Assume, Value *IsOn,
Attribute::AttrKind Kind,
uint64_t *ArgVal = nullptr) {
Expand Down Expand Up @@ -86,7 +88,8 @@ using RetainedKnowledgeMap =
/// many queries are going to be made on the same llvm.assume.
/// String attributes are not inserted in the map.
/// If the IR changes the map will be outdated.
void fillMapFromAssume(AssumeInst &Assume, RetainedKnowledgeMap &Result);
LLVM_ABI void fillMapFromAssume(AssumeInst &Assume,
RetainedKnowledgeMap &Result);

/// Represent one information held inside an operand bundle of an llvm.assume.
/// AttrKind is the property that holds.
Expand Down Expand Up @@ -120,8 +123,8 @@ struct RetainedKnowledge {

/// Retreive the information help by Assume on the operand at index Idx.
/// Assume should be an llvm.assume and Idx should be in the operand bundle.
RetainedKnowledge getKnowledgeFromOperandInAssume(AssumeInst &Assume,
unsigned Idx);
LLVM_ABI RetainedKnowledge getKnowledgeFromOperandInAssume(AssumeInst &Assume,
unsigned Idx);

/// Retreive the information help by the Use U of an llvm.assume. the use should
/// be in the operand bundle.
Expand All @@ -141,16 +144,16 @@ constexpr StringRef IgnoreBundleTag = "ignore";
///
/// the argument to the call of llvm.assume may still be useful even if the
/// function returned true.
bool isAssumeWithEmptyBundle(const AssumeInst &Assume);
LLVM_ABI bool isAssumeWithEmptyBundle(const AssumeInst &Assume);

/// Return a valid Knowledge associated to the Use U if its Attribute kind is
/// in AttrKinds.
RetainedKnowledge getKnowledgeFromUse(const Use *U,
ArrayRef<Attribute::AttrKind> AttrKinds);
LLVM_ABI RetainedKnowledge
getKnowledgeFromUse(const Use *U, ArrayRef<Attribute::AttrKind> AttrKinds);

/// Return a valid Knowledge associated to the Value V if its Attribute kind is
/// in AttrKinds and it matches the Filter.
RetainedKnowledge getKnowledgeForValue(
LLVM_ABI RetainedKnowledge getKnowledgeForValue(
const Value *V, ArrayRef<Attribute::AttrKind> AttrKinds,
AssumptionCache &AC,
function_ref<bool(RetainedKnowledge, Instruction *,
Expand All @@ -160,16 +163,15 @@ RetainedKnowledge getKnowledgeForValue(
/// Return a valid Knowledge associated to the Value V if its Attribute kind is
/// in AttrKinds and the knowledge is suitable to be used in the context of
/// CtxI.
RetainedKnowledge
getKnowledgeValidInContext(const Value *V,
ArrayRef<Attribute::AttrKind> AttrKinds,
AssumptionCache &AC, const Instruction *CtxI,
const DominatorTree *DT = nullptr);
LLVM_ABI RetainedKnowledge getKnowledgeValidInContext(
const Value *V, ArrayRef<Attribute::AttrKind> AttrKinds,
AssumptionCache &AC, const Instruction *CtxI,
const DominatorTree *DT = nullptr);

/// This extracts the Knowledge from an element of an operand bundle.
/// This is mostly for use in the assume builder.
RetainedKnowledge getKnowledgeFromBundle(AssumeInst &Assume,
const CallBase::BundleOpInfo &BOI);
LLVM_ABI RetainedKnowledge
getKnowledgeFromBundle(AssumeInst &Assume, const CallBase::BundleOpInfo &BOI);

} // namespace llvm

Expand Down
21 changes: 11 additions & 10 deletions llvm/include/llvm/Analysis/AssumptionCache.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "llvm/IR/PassManager.h"
#include "llvm/IR/ValueHandle.h"
#include "llvm/Pass.h"
#include "llvm/Support/Compiler.h"
#include <memory>

namespace llvm {
Expand Down Expand Up @@ -66,7 +67,7 @@ class AssumptionCache {
/// intrinsic.
SmallVector<ResultElem, 4> AssumeHandles;

class AffectedValueCallbackVH final : public CallbackVH {
class LLVM_ABI AffectedValueCallbackVH final : public CallbackVH {
AssumptionCache *AC;

void deleted() override;
Expand Down Expand Up @@ -101,7 +102,7 @@ class AssumptionCache {
bool Scanned = false;

/// Scan the function for assumptions and add them to the cache.
void scanFunction();
LLVM_ABI void scanFunction();

public:
/// Construct an AssumptionCache from a function by scanning all of
Expand All @@ -120,15 +121,15 @@ class AssumptionCache {
///
/// The call passed in must be an instruction within this function and must
/// not already be in the cache.
void registerAssumption(AssumeInst *CI);
LLVM_ABI void registerAssumption(AssumeInst *CI);

/// Remove an \@llvm.assume intrinsic from this function's cache if it has
/// been added to the cache earlier.
void unregisterAssumption(AssumeInst *CI);
LLVM_ABI void unregisterAssumption(AssumeInst *CI);

/// Update the cache of values being affected by this assumption (i.e.
/// the values about which this assumption provides information).
void updateAffectedValues(AssumeInst *CI);
LLVM_ABI void updateAffectedValues(AssumeInst *CI);

/// Clear the cache of \@llvm.assume intrinsics for a function.
///
Expand Down Expand Up @@ -173,12 +174,12 @@ class AssumptionCache {
class AssumptionAnalysis : public AnalysisInfoMixin<AssumptionAnalysis> {
friend AnalysisInfoMixin<AssumptionAnalysis>;

static AnalysisKey Key;
LLVM_ABI static AnalysisKey Key;

public:
using Result = AssumptionCache;

AssumptionCache run(Function &F, FunctionAnalysisManager &);
LLVM_ABI AssumptionCache run(Function &F, FunctionAnalysisManager &);
};

/// Printer pass for the \c AssumptionAnalysis results.
Expand All @@ -188,7 +189,7 @@ class AssumptionPrinterPass : public PassInfoMixin<AssumptionPrinterPass> {
public:
explicit AssumptionPrinterPass(raw_ostream &OS) : OS(OS) {}

PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
LLVM_ABI PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);

static bool isRequired() { return true; }
};
Expand All @@ -201,10 +202,10 @@ class AssumptionPrinterPass : public PassInfoMixin<AssumptionPrinterPass> {
/// function is deleted. The nature of the AssumptionCache is that it is not
/// invalidated by any changes to the function body and so this is sufficient
/// to be conservatively correct.
class AssumptionCacheTracker : public ImmutablePass {
class LLVM_ABI AssumptionCacheTracker : public ImmutablePass {
/// A callback value handle applied to function objects, which we use to
/// delete our cache of intrinsics for a function when it is deleted.
class FunctionCallbackVH final : public CallbackVH {
class LLVM_ABI FunctionCallbackVH final : public CallbackVH {
AssumptionCacheTracker *ACT;

void deleted() override;
Expand Down
37 changes: 21 additions & 16 deletions llvm/include/llvm/Analysis/BasicAliasAnalysis.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "llvm/Analysis/AliasAnalysis.h"
#include "llvm/IR/PassManager.h"
#include "llvm/Pass.h"
#include "llvm/Support/Compiler.h"
#include <memory>
#include <utility>

Expand Down Expand Up @@ -65,17 +66,19 @@ class BasicAAResult : public AAResultBase {
AC(Arg.AC), DT_(Arg.DT_) {}

/// Handle invalidation events in the new pass manager.
bool invalidate(Function &Fn, const PreservedAnalyses &PA,
FunctionAnalysisManager::Invalidator &Inv);
LLVM_ABI bool invalidate(Function &Fn, const PreservedAnalyses &PA,
FunctionAnalysisManager::Invalidator &Inv);

AliasResult alias(const MemoryLocation &LocA, const MemoryLocation &LocB,
AAQueryInfo &AAQI, const Instruction *CtxI);
LLVM_ABI AliasResult alias(const MemoryLocation &LocA,
const MemoryLocation &LocB, AAQueryInfo &AAQI,
const Instruction *CtxI);

ModRefInfo getModRefInfo(const CallBase *Call, const MemoryLocation &Loc,
AAQueryInfo &AAQI);
LLVM_ABI ModRefInfo getModRefInfo(const CallBase *Call,
const MemoryLocation &Loc,
AAQueryInfo &AAQI);

ModRefInfo getModRefInfo(const CallBase *Call1, const CallBase *Call2,
AAQueryInfo &AAQI);
LLVM_ABI ModRefInfo getModRefInfo(const CallBase *Call1,
const CallBase *Call2, AAQueryInfo &AAQI);

/// Returns a bitmask that should be unconditionally applied to the ModRef
/// info of a memory location. This allows us to eliminate Mod and/or Ref
Expand All @@ -84,18 +87,20 @@ class BasicAAResult : public AAResultBase {
///
/// If IgnoreLocals is true, then this method returns NoModRef for memory
/// that points to a local alloca.
ModRefInfo getModRefInfoMask(const MemoryLocation &Loc, AAQueryInfo &AAQI,
bool IgnoreLocals = false);
LLVM_ABI ModRefInfo getModRefInfoMask(const MemoryLocation &Loc,
AAQueryInfo &AAQI,
bool IgnoreLocals = false);

/// Get the location associated with a pointer argument of a callsite.
ModRefInfo getArgModRefInfo(const CallBase *Call, unsigned ArgIdx);
LLVM_ABI ModRefInfo getArgModRefInfo(const CallBase *Call, unsigned ArgIdx);

/// Returns the behavior when calling the given call site.
MemoryEffects getMemoryEffects(const CallBase *Call, AAQueryInfo &AAQI);
LLVM_ABI MemoryEffects getMemoryEffects(const CallBase *Call,
AAQueryInfo &AAQI);

/// Returns the behavior when calling the given function. For use when the
/// call site is not known.
MemoryEffects getMemoryEffects(const Function *Fn);
LLVM_ABI MemoryEffects getMemoryEffects(const Function *Fn);

private:
struct DecomposedGEP;
Expand Down Expand Up @@ -157,11 +162,11 @@ class BasicAA : public AnalysisInfoMixin<BasicAA> {
public:
using Result = BasicAAResult;

BasicAAResult run(Function &F, FunctionAnalysisManager &AM);
LLVM_ABI BasicAAResult run(Function &F, FunctionAnalysisManager &AM);
};

/// Legacy wrapper pass to provide the BasicAAResult object.
class BasicAAWrapperPass : public FunctionPass {
class LLVM_ABI BasicAAWrapperPass : public FunctionPass {
std::unique_ptr<BasicAAResult> Result;

virtual void anchor();
Expand All @@ -178,7 +183,7 @@ class BasicAAWrapperPass : public FunctionPass {
void getAnalysisUsage(AnalysisUsage &AU) const override;
};

FunctionPass *createBasicAAWrapperPass();
LLVM_ABI FunctionPass *createBasicAAWrapperPass();

} // end namespace llvm

Expand Down
Loading
Loading