Skip to content

Commit 92e1937

Browse files
committed
[llvm] DLLExport Analysis library public interface
1 parent 3ceb3d9 commit 92e1937

File tree

86 files changed

+1932
-1838
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

86 files changed

+1932
-1838
lines changed

llvm/include/llvm/Analysis/AliasAnalysis.h

Lines changed: 57 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
#include "llvm/IR/Function.h"
4444
#include "llvm/IR/PassManager.h"
4545
#include "llvm/Pass.h"
46+
#include "llvm/Support/Compiler.h"
4647
#include "llvm/Support/ModRef.h"
4748
#include <cstdint>
4849
#include <functional>
@@ -142,11 +143,11 @@ static_assert(sizeof(AliasResult) == 4,
142143
"AliasResult size is intended to be 4 bytes!");
143144

144145
/// << operator for AliasResult.
145-
raw_ostream &operator<<(raw_ostream &OS, AliasResult AR);
146+
LLVM_ABI raw_ostream &operator<<(raw_ostream &OS, AliasResult AR);
146147

147148
/// Virtual base class for providers of capture analysis.
148149
struct CaptureAnalysis {
149-
virtual ~CaptureAnalysis() = 0;
150+
LLVM_ABI virtual ~CaptureAnalysis() = 0;
150151

151152
/// Check whether Object is not captured before instruction I. If OrAt is
152153
/// true, captures by instruction I itself are also considered.
@@ -159,10 +160,12 @@ struct CaptureAnalysis {
159160
/// Context-free CaptureAnalysis provider, which computes and caches whether an
160161
/// object is captured in the function at all, but does not distinguish whether
161162
/// it was captured before or after the context instruction.
162-
class SimpleCaptureAnalysis final : public CaptureAnalysis {
163+
class LLVM_ABI SimpleCaptureAnalysis final : public CaptureAnalysis {
163164
SmallDenseMap<const Value *, bool, 8> IsCapturedCache;
164165

165166
public:
167+
~SimpleCaptureAnalysis() = default;
168+
166169
bool isNotCapturedBefore(const Value *Object, const Instruction *I,
167170
bool OrAt) override;
168171
};
@@ -188,10 +191,12 @@ class EarliestEscapeAnalysis final : public CaptureAnalysis {
188191
EarliestEscapeAnalysis(DominatorTree &DT, const LoopInfo *LI = nullptr)
189192
: DT(DT), LI(LI) {}
190193

191-
bool isNotCapturedBefore(const Value *Object, const Instruction *I,
194+
LLVM_ABI ~EarliestEscapeAnalysis() = default;
195+
196+
LLVM_ABI bool isNotCapturedBefore(const Value *Object, const Instruction *I,
192197
bool OrAt) override;
193198

194-
void removeInstruction(Instruction *I);
199+
LLVM_ABI void removeInstruction(Instruction *I);
195200
};
196201

197202
/// Cache key for BasicAA results. It only includes the pointer and size from
@@ -315,9 +320,9 @@ class AAResults {
315320
public:
316321
// Make these results default constructable and movable. We have to spell
317322
// these out because MSVC won't synthesize them.
318-
AAResults(const TargetLibraryInfo &TLI);
319-
AAResults(AAResults &&Arg);
320-
~AAResults();
323+
LLVM_ABI AAResults(const TargetLibraryInfo &TLI);
324+
LLVM_ABI AAResults(AAResults &&Arg);
325+
LLVM_ABI ~AAResults();
321326

322327
/// Register a specific AA result.
323328
template <typename AAResultT> void addAAResult(AAResultT &AAResult) {
@@ -338,7 +343,7 @@ class AAResults {
338343
///
339344
/// The aggregation is invalidated if any of the underlying analyses is
340345
/// invalidated.
341-
bool invalidate(Function &F, const PreservedAnalyses &PA,
346+
LLVM_ABI bool invalidate(Function &F, const PreservedAnalyses &PA,
342347
FunctionAnalysisManager::Invalidator &Inv);
343348

344349
//===--------------------------------------------------------------------===//
@@ -349,7 +354,7 @@ class AAResults {
349354
/// Returns an AliasResult indicating whether the two pointers are aliased to
350355
/// each other. This is the interface that must be implemented by specific
351356
/// alias analysis implementations.
352-
AliasResult alias(const MemoryLocation &LocA, const MemoryLocation &LocB);
357+
LLVM_ABI AliasResult alias(const MemoryLocation &LocA, const MemoryLocation &LocB);
353358

354359
/// A convenience wrapper around the primary \c alias interface.
355360
AliasResult alias(const Value *V1, LocationSize V1Size, const Value *V2,
@@ -417,7 +422,7 @@ class AAResults {
417422
///
418423
/// If IgnoreLocals is true, then this method returns NoModRef for memory
419424
/// that points to a local alloca.
420-
ModRefInfo getModRefInfoMask(const MemoryLocation &Loc,
425+
LLVM_ABI ModRefInfo getModRefInfoMask(const MemoryLocation &Loc,
421426
bool IgnoreLocals = false);
422427

423428
/// A convenience wrapper around the primary \c getModRefInfoMask
@@ -431,13 +436,13 @@ class AAResults {
431436
/// that these bits do not necessarily account for the overall behavior of
432437
/// the function, but rather only provide additional per-argument
433438
/// information.
434-
ModRefInfo getArgModRefInfo(const CallBase *Call, unsigned ArgIdx);
439+
LLVM_ABI ModRefInfo getArgModRefInfo(const CallBase *Call, unsigned ArgIdx);
435440

436441
/// Return the behavior of the given call site.
437-
MemoryEffects getMemoryEffects(const CallBase *Call);
442+
LLVM_ABI MemoryEffects getMemoryEffects(const CallBase *Call);
438443

439444
/// Return the behavior when calling the given function.
440-
MemoryEffects getMemoryEffects(const Function *F);
445+
LLVM_ABI MemoryEffects getMemoryEffects(const Function *F);
441446

442447
/// Checks if the specified call is known to never read or write memory.
443448
///
@@ -519,7 +524,7 @@ class AAResults {
519524

520525
/// Return information about whether a call and an instruction may refer to
521526
/// the same memory locations.
522-
ModRefInfo getModRefInfo(const Instruction *I, const CallBase *Call);
527+
LLVM_ABI ModRefInfo getModRefInfo(const Instruction *I, const CallBase *Call);
523528

524529
/// Return information about whether two instructions may refer to the same
525530
/// memory locations.
@@ -548,7 +553,7 @@ class AAResults {
548553

549554
/// Check if it is possible for execution of the specified basic block to
550555
/// modify the location Loc.
551-
bool canBasicBlockModify(const BasicBlock &BB, const MemoryLocation &Loc);
556+
LLVM_ABI bool canBasicBlockModify(const BasicBlock &BB, const MemoryLocation &Loc);
552557

553558
/// A convenience wrapper synthesizing a memory location.
554559
bool canBasicBlockModify(const BasicBlock &BB, const Value *P,
@@ -561,7 +566,7 @@ class AAResults {
561566
///
562567
/// The instructions to consider are all of the instructions in the range of
563568
/// [I1,I2] INCLUSIVE. I1 and I2 must be in the same basic block.
564-
bool canInstructionRangeModRef(const Instruction &I1, const Instruction &I2,
569+
LLVM_ABI bool canInstructionRangeModRef(const Instruction &I1, const Instruction &I2,
565570
const MemoryLocation &Loc,
566571
const ModRefInfo Mode);
567572

@@ -574,42 +579,42 @@ class AAResults {
574579

575580
// CtxI can be nullptr, in which case the query is whether or not the aliasing
576581
// relationship holds through the entire function.
577-
AliasResult alias(const MemoryLocation &LocA, const MemoryLocation &LocB,
582+
LLVM_ABI AliasResult alias(const MemoryLocation &LocA, const MemoryLocation &LocB,
578583
AAQueryInfo &AAQI, const Instruction *CtxI = nullptr);
579584

580-
ModRefInfo getModRefInfoMask(const MemoryLocation &Loc, AAQueryInfo &AAQI,
585+
LLVM_ABI ModRefInfo getModRefInfoMask(const MemoryLocation &Loc, AAQueryInfo &AAQI,
581586
bool IgnoreLocals = false);
582-
ModRefInfo getModRefInfo(const Instruction *I, const CallBase *Call2,
587+
LLVM_ABI ModRefInfo getModRefInfo(const Instruction *I, const CallBase *Call2,
583588
AAQueryInfo &AAQIP);
584-
ModRefInfo getModRefInfo(const CallBase *Call, const MemoryLocation &Loc,
589+
LLVM_ABI ModRefInfo getModRefInfo(const CallBase *Call, const MemoryLocation &Loc,
585590
AAQueryInfo &AAQI);
586-
ModRefInfo getModRefInfo(const CallBase *Call1, const CallBase *Call2,
591+
LLVM_ABI ModRefInfo getModRefInfo(const CallBase *Call1, const CallBase *Call2,
587592
AAQueryInfo &AAQI);
588-
ModRefInfo getModRefInfo(const VAArgInst *V, const MemoryLocation &Loc,
593+
LLVM_ABI ModRefInfo getModRefInfo(const VAArgInst *V, const MemoryLocation &Loc,
589594
AAQueryInfo &AAQI);
590-
ModRefInfo getModRefInfo(const LoadInst *L, const MemoryLocation &Loc,
595+
LLVM_ABI ModRefInfo getModRefInfo(const LoadInst *L, const MemoryLocation &Loc,
591596
AAQueryInfo &AAQI);
592-
ModRefInfo getModRefInfo(const StoreInst *S, const MemoryLocation &Loc,
597+
LLVM_ABI ModRefInfo getModRefInfo(const StoreInst *S, const MemoryLocation &Loc,
593598
AAQueryInfo &AAQI);
594-
ModRefInfo getModRefInfo(const FenceInst *S, const MemoryLocation &Loc,
599+
LLVM_ABI ModRefInfo getModRefInfo(const FenceInst *S, const MemoryLocation &Loc,
595600
AAQueryInfo &AAQI);
596-
ModRefInfo getModRefInfo(const AtomicCmpXchgInst *CX,
601+
LLVM_ABI ModRefInfo getModRefInfo(const AtomicCmpXchgInst *CX,
597602
const MemoryLocation &Loc, AAQueryInfo &AAQI);
598-
ModRefInfo getModRefInfo(const AtomicRMWInst *RMW, const MemoryLocation &Loc,
603+
LLVM_ABI ModRefInfo getModRefInfo(const AtomicRMWInst *RMW, const MemoryLocation &Loc,
599604
AAQueryInfo &AAQI);
600-
ModRefInfo getModRefInfo(const CatchPadInst *I, const MemoryLocation &Loc,
605+
LLVM_ABI ModRefInfo getModRefInfo(const CatchPadInst *I, const MemoryLocation &Loc,
601606
AAQueryInfo &AAQI);
602-
ModRefInfo getModRefInfo(const CatchReturnInst *I, const MemoryLocation &Loc,
607+
LLVM_ABI ModRefInfo getModRefInfo(const CatchReturnInst *I, const MemoryLocation &Loc,
603608
AAQueryInfo &AAQI);
604-
ModRefInfo getModRefInfo(const Instruction *I,
609+
LLVM_ABI ModRefInfo getModRefInfo(const Instruction *I,
605610
const std::optional<MemoryLocation> &OptLoc,
606611
AAQueryInfo &AAQIP);
607-
ModRefInfo getModRefInfo(const Instruction *I1, const Instruction *I2,
612+
LLVM_ABI ModRefInfo getModRefInfo(const Instruction *I1, const Instruction *I2,
608613
AAQueryInfo &AAQI);
609-
ModRefInfo callCapturesBefore(const Instruction *I,
614+
LLVM_ABI ModRefInfo callCapturesBefore(const Instruction *I,
610615
const MemoryLocation &MemLoc, DominatorTree *DT,
611616
AAQueryInfo &AAQIP);
612-
MemoryEffects getMemoryEffects(const CallBase *Call, AAQueryInfo &AAQI);
617+
LLVM_ABI MemoryEffects getMemoryEffects(const CallBase *Call, AAQueryInfo &AAQI);
613618

614619
private:
615620
class Concept;
@@ -708,7 +713,7 @@ using AliasAnalysis = AAResults;
708713
/// All of these methods model methods by the same name in the \c
709714
/// AAResults class. Only differences and specifics to how the
710715
/// implementations are called are documented here.
711-
class AAResults::Concept {
716+
class LLVM_ABI AAResults::Concept {
712717
public:
713718
virtual ~Concept() = 0;
714719

@@ -869,7 +874,7 @@ class AAResultBase {
869874
};
870875

871876
/// Return true if this pointer is returned by a noalias function.
872-
bool isNoAliasCall(const Value *V);
877+
LLVM_ABI bool isNoAliasCall(const Value *V);
873878

874879
/// Return true if this pointer refers to a distinct and identifiable object.
875880
/// This returns true for:
@@ -878,32 +883,32 @@ bool isNoAliasCall(const Value *V);
878883
/// ByVal and NoAlias Arguments
879884
/// NoAlias returns (e.g. calls to malloc)
880885
///
881-
bool isIdentifiedObject(const Value *V);
886+
LLVM_ABI bool isIdentifiedObject(const Value *V);
882887

883888
/// Return true if V is umabigously identified at the function-level.
884889
/// Different IdentifiedFunctionLocals can't alias.
885890
/// Further, an IdentifiedFunctionLocal can not alias with any function
886891
/// arguments other than itself, which is not necessarily true for
887892
/// IdentifiedObjects.
888-
bool isIdentifiedFunctionLocal(const Value *V);
893+
LLVM_ABI bool isIdentifiedFunctionLocal(const Value *V);
889894

890895
/// Return true if we know V to the base address of the corresponding memory
891896
/// object. This implies that any address less than V must be out of bounds
892897
/// for the underlying object. Note that just being isIdentifiedObject() is
893898
/// not enough - For example, a negative offset from a noalias argument or call
894899
/// can be inbounds w.r.t the actual underlying object.
895-
bool isBaseOfObject(const Value *V);
900+
LLVM_ABI bool isBaseOfObject(const Value *V);
896901

897902
/// Returns true if the pointer is one which would have been considered an
898903
/// escape by isNonEscapingLocalObject.
899-
bool isEscapeSource(const Value *V);
904+
LLVM_ABI bool isEscapeSource(const Value *V);
900905

901906
/// Return true if Object memory is not visible after an unwind, in the sense
902907
/// that program semantics cannot depend on Object containing any particular
903908
/// value on unwind. If the RequiresNoCaptureBeforeUnwind out parameter is set
904909
/// to true, then the memory is only not visible if the object has not been
905910
/// captured prior to the unwind. Otherwise it is not visible even if captured.
906-
bool isNotVisibleOnUnwind(const Value *Object,
911+
LLVM_ABI bool isNotVisibleOnUnwind(const Value *Object,
907912
bool &RequiresNoCaptureBeforeUnwind);
908913

909914
/// Return true if the Object is writable, in the sense that any location based
@@ -917,7 +922,7 @@ bool isNotVisibleOnUnwind(const Value *Object,
917922
/// using the dereferenceable(N) attribute. It does not necessarily hold for
918923
/// parts that are only known to be dereferenceable due to the presence of
919924
/// loads.
920-
bool isWritableObject(const Value *Object, bool &ExplicitlyDereferenceableOnly);
925+
LLVM_ABI bool isWritableObject(const Value *Object, bool &ExplicitlyDereferenceableOnly);
921926

922927
/// A manager for alias analyses.
923928
///
@@ -950,12 +955,12 @@ class AAManager : public AnalysisInfoMixin<AAManager> {
950955
ResultGetters.push_back(&getModuleAAResultImpl<AnalysisT>);
951956
}
952957

953-
Result run(Function &F, FunctionAnalysisManager &AM);
958+
LLVM_ABI Result run(Function &F, FunctionAnalysisManager &AM);
954959

955960
private:
956961
friend AnalysisInfoMixin<AAManager>;
957962

958-
static AnalysisKey Key;
963+
LLVM_ABI static AnalysisKey Key;
959964

960965
SmallVector<void (*)(Function &F, FunctionAnalysisManager &AM,
961966
AAResults &AAResults),
@@ -988,16 +993,16 @@ class AAResultsWrapperPass : public FunctionPass {
988993
std::unique_ptr<AAResults> AAR;
989994

990995
public:
991-
static char ID;
996+
LLVM_ABI static char ID;
992997

993-
AAResultsWrapperPass();
998+
LLVM_ABI AAResultsWrapperPass();
994999

9951000
AAResults &getAAResults() { return *AAR; }
9961001
const AAResults &getAAResults() const { return *AAR; }
9971002

998-
bool runOnFunction(Function &F) override;
1003+
LLVM_ABI bool runOnFunction(Function &F) override;
9991004

1000-
void getAnalysisUsage(AnalysisUsage &AU) const override;
1005+
LLVM_ABI void getAnalysisUsage(AnalysisUsage &AU) const override;
10011006
};
10021007

10031008
/// A wrapper pass for external alias analyses. This just squirrels away the
@@ -1007,11 +1012,11 @@ struct ExternalAAWrapperPass : ImmutablePass {
10071012

10081013
CallbackT CB;
10091014

1010-
static char ID;
1015+
LLVM_ABI static char ID;
10111016

1012-
ExternalAAWrapperPass();
1017+
LLVM_ABI ExternalAAWrapperPass();
10131018

1014-
explicit ExternalAAWrapperPass(CallbackT CB);
1019+
LLVM_ABI explicit ExternalAAWrapperPass(CallbackT CB);
10151020

10161021
void getAnalysisUsage(AnalysisUsage &AU) const override {
10171022
AU.setPreservesAll();
@@ -1025,7 +1030,7 @@ struct ExternalAAWrapperPass : ImmutablePass {
10251030
/// object, and will receive a reference to the function wrapper pass, the
10261031
/// function, and the AAResults object to populate. This should be used when
10271032
/// setting up a custom pass pipeline to inject a hook into the AA results.
1028-
ImmutablePass *createExternalAAWrapperPass(
1033+
LLVM_ABI ImmutablePass *createExternalAAWrapperPass(
10291034
std::function<void(Pass &, Function &, AAResults &)> Callback);
10301035

10311036
} // end namespace llvm

llvm/include/llvm/Analysis/AliasAnalysisEvaluator.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#define LLVM_ANALYSIS_ALIASANALYSISEVALUATOR_H
2626

2727
#include "llvm/IR/PassManager.h"
28+
#include "llvm/Support/Compiler.h"
2829

2930
namespace llvm {
3031
class AAResults;
@@ -47,10 +48,10 @@ class AAEvaluator : public PassInfoMixin<AAEvaluator> {
4748
ModRefCount(Arg.ModRefCount) {
4849
Arg.FunctionCount = 0;
4950
}
50-
~AAEvaluator();
51+
LLVM_ABI ~AAEvaluator();
5152

5253
/// Run the pass over the function.
53-
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
54+
LLVM_ABI PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
5455

5556
private:
5657
void runInternal(Function &F, AAResults &AA);

0 commit comments

Comments
 (0)