File indexing completed on 2026-05-10 08:43:19
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 #ifndef LLVM_ANALYSIS_TYPEBASEDALIASANALYSIS_H
0016 #define LLVM_ANALYSIS_TYPEBASEDALIASANALYSIS_H
0017
0018 #include "llvm/Analysis/AliasAnalysis.h"
0019 #include "llvm/IR/PassManager.h"
0020 #include "llvm/Pass.h"
0021 #include <memory>
0022
0023 namespace llvm {
0024
0025 class CallBase;
0026 class Function;
0027 class MDNode;
0028 class MemoryLocation;
0029
0030
0031 class TypeBasedAAResult : public AAResultBase {
0032
0033
0034
0035 bool UsingTypeSanitizer;
0036
0037 public:
0038 TypeBasedAAResult(bool UsingTypeSanitizer)
0039 : UsingTypeSanitizer(UsingTypeSanitizer) {}
0040
0041
0042
0043
0044 bool invalidate(Function &, const PreservedAnalyses &,
0045 FunctionAnalysisManager::Invalidator &) {
0046 return false;
0047 }
0048
0049 AliasResult alias(const MemoryLocation &LocA, const MemoryLocation &LocB,
0050 AAQueryInfo &AAQI, const Instruction *CtxI);
0051 ModRefInfo getModRefInfoMask(const MemoryLocation &Loc, AAQueryInfo &AAQI,
0052 bool IgnoreLocals);
0053
0054 MemoryEffects getMemoryEffects(const CallBase *Call, AAQueryInfo &AAQI);
0055 MemoryEffects getMemoryEffects(const Function *F);
0056 ModRefInfo getModRefInfo(const CallBase *Call, const MemoryLocation &Loc,
0057 AAQueryInfo &AAQI);
0058 ModRefInfo getModRefInfo(const CallBase *Call1, const CallBase *Call2,
0059 AAQueryInfo &AAQI);
0060
0061 private:
0062 bool Aliases(const MDNode *A, const MDNode *B) const;
0063
0064
0065
0066 bool shouldUseTBAA() const;
0067 };
0068
0069
0070 class TypeBasedAA : public AnalysisInfoMixin<TypeBasedAA> {
0071 friend AnalysisInfoMixin<TypeBasedAA>;
0072
0073 static AnalysisKey Key;
0074
0075 public:
0076 using Result = TypeBasedAAResult;
0077
0078 TypeBasedAAResult run(Function &F, FunctionAnalysisManager &AM);
0079 };
0080
0081
0082 class TypeBasedAAWrapperPass : public ImmutablePass {
0083 std::unique_ptr<TypeBasedAAResult> Result;
0084
0085 public:
0086 static char ID;
0087
0088 TypeBasedAAWrapperPass();
0089
0090 TypeBasedAAResult &getResult() { return *Result; }
0091 const TypeBasedAAResult &getResult() const { return *Result; }
0092
0093 bool doInitialization(Module &M) override;
0094 bool doFinalization(Module &M) override;
0095 void getAnalysisUsage(AnalysisUsage &AU) const override;
0096 };
0097
0098
0099
0100
0101
0102
0103 ImmutablePass *createTypeBasedAAWrapperPass();
0104
0105 }
0106
0107 #endif