Update prebuilt Clang to r416183b from Android.
https://android.googlesource.com/platform/prebuilts/clang/host/
linux-x86/+/06a71ddac05c22edb2d10b590e1769b3f8619bef
clang 12.0.5 (based on r416183b) from build 7284624.
Change-Id: I277a316abcf47307562d8b748b84870f31a72866
Signed-off-by: Olivier Deprez <olivier.deprez@arm.com>
diff --git a/linux-x64/clang/include/llvm/Analysis/AliasAnalysis.h b/linux-x64/clang/include/llvm/Analysis/AliasAnalysis.h
index 9483415..8a3ea62 100644
--- a/linux-x64/clang/include/llvm/Analysis/AliasAnalysis.h
+++ b/linux-x64/clang/include/llvm/Analysis/AliasAnalysis.h
@@ -42,10 +42,6 @@
#include "llvm/ADT/Optional.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/Analysis/MemoryLocation.h"
-#include "llvm/Analysis/TargetLibraryInfo.h"
-#include "llvm/IR/Function.h"
-#include "llvm/IR/Instruction.h"
-#include "llvm/IR/Instructions.h"
#include "llvm/IR/PassManager.h"
#include "llvm/Pass.h"
#include <cstdint>
@@ -56,10 +52,17 @@
namespace llvm {
class AnalysisUsage;
+class AtomicCmpXchgInst;
class BasicAAResult;
class BasicBlock;
+class CatchPadInst;
+class CatchReturnInst;
class DominatorTree;
-class OrderedBasicBlock;
+class FenceInst;
+class Function;
+class InvokeInst;
+class PreservedAnalyses;
+class TargetLibraryInfo;
class Value;
/// The possible results of an alias query.
@@ -226,11 +229,21 @@
/// non-volatile loads from objects pointed to by its pointer-typed
/// arguments, with arbitrary offsets.
///
- /// This property corresponds to the IntrReadArgMem LLVM intrinsic flag.
+ /// This property corresponds to the combination of the IntrReadMem
+ /// and IntrArgMemOnly LLVM intrinsic flags.
FMRB_OnlyReadsArgumentPointees =
FMRL_ArgumentPointees | static_cast<int>(ModRefInfo::Ref),
/// The only memory references in this function (if it has any) are
+ /// non-volatile stores from objects pointed to by its pointer-typed
+ /// arguments, with arbitrary offsets.
+ ///
+ /// This property corresponds to the combination of the IntrWriteMem
+ /// and IntrArgMemOnly LLVM intrinsic flags.
+ FMRB_OnlyWritesArgumentPointees =
+ FMRL_ArgumentPointees | static_cast<int>(ModRefInfo::Mod),
+
+ /// The only memory references in this function (if it has any) are
/// non-volatile loads and stores from objects pointed to by its
/// pointer-typed arguments, with arbitrary offsets.
///
@@ -239,12 +252,48 @@
FMRL_ArgumentPointees | static_cast<int>(ModRefInfo::ModRef),
/// The only memory references in this function (if it has any) are
+ /// reads of memory that is otherwise inaccessible via LLVM IR.
+ ///
+ /// This property corresponds to the LLVM IR inaccessiblememonly attribute.
+ FMRB_OnlyReadsInaccessibleMem =
+ FMRL_InaccessibleMem | static_cast<int>(ModRefInfo::Ref),
+
+ /// The only memory references in this function (if it has any) are
+ /// writes to memory that is otherwise inaccessible via LLVM IR.
+ ///
+ /// This property corresponds to the LLVM IR inaccessiblememonly attribute.
+ FMRB_OnlyWritesInaccessibleMem =
+ FMRL_InaccessibleMem | static_cast<int>(ModRefInfo::Mod),
+
+ /// The only memory references in this function (if it has any) are
/// references of memory that is otherwise inaccessible via LLVM IR.
///
/// This property corresponds to the LLVM IR inaccessiblememonly attribute.
FMRB_OnlyAccessesInaccessibleMem =
FMRL_InaccessibleMem | static_cast<int>(ModRefInfo::ModRef),
+ /// The function may perform non-volatile loads from objects pointed
+ /// to by its pointer-typed arguments, with arbitrary offsets, and
+ /// it may also perform loads of memory that is otherwise
+ /// inaccessible via LLVM IR.
+ ///
+ /// This property corresponds to the LLVM IR
+ /// inaccessiblemem_or_argmemonly attribute.
+ FMRB_OnlyReadsInaccessibleOrArgMem = FMRL_InaccessibleMem |
+ FMRL_ArgumentPointees |
+ static_cast<int>(ModRefInfo::Ref),
+
+ /// The function may perform non-volatile stores to objects pointed
+ /// to by its pointer-typed arguments, with arbitrary offsets, and
+ /// it may also perform stores of memory that is otherwise
+ /// inaccessible via LLVM IR.
+ ///
+ /// This property corresponds to the LLVM IR
+ /// inaccessiblemem_or_argmemonly attribute.
+ FMRB_OnlyWritesInaccessibleOrArgMem = FMRL_InaccessibleMem |
+ FMRL_ArgumentPointees |
+ static_cast<int>(ModRefInfo::Mod),
+
/// The function may perform non-volatile loads and stores of objects
/// pointed to by its pointer-typed arguments, with arbitrary offsets, and
/// it may also perform loads and stores of memory that is otherwise
@@ -269,7 +318,7 @@
//
// This property corresponds to the LLVM IR 'writeonly' attribute.
// This property corresponds to the IntrWriteMem LLVM intrinsic flag.
- FMRB_DoesNotReadMemory = FMRL_Anywhere | static_cast<int>(ModRefInfo::Mod),
+ FMRB_OnlyWritesMemory = FMRL_Anywhere | static_cast<int>(ModRefInfo::Mod),
/// This indicates that the function could not be classified into one of the
/// behaviors above.
@@ -297,7 +346,15 @@
class AAQueryInfo {
public:
using LocPair = std::pair<MemoryLocation, MemoryLocation>;
- using AliasCacheT = SmallDenseMap<LocPair, AliasResult, 8>;
+ struct CacheEntry {
+ AliasResult Result;
+ /// Number of times a NoAlias assumption has been used.
+ /// 0 for assumptions that have not been used, -1 for definitive results.
+ int NumAssumptionUses;
+ /// Whether this is a definitive (non-assumption) result.
+ bool isDefinitive() const { return NumAssumptionUses < 0; }
+ };
+ using AliasCacheT = SmallDenseMap<LocPair, CacheEntry, 8>;
AliasCacheT AliasCache;
using IsCapturedCacheT = SmallDenseMap<const Value *, bool, 8>;
@@ -356,7 +413,8 @@
/// A convenience wrapper around the primary \c alias interface.
AliasResult alias(const Value *V1, const Value *V2) {
- return alias(V1, LocationSize::unknown(), V2, LocationSize::unknown());
+ return alias(MemoryLocation::getBeforeOrAfter(V1),
+ MemoryLocation::getBeforeOrAfter(V2));
}
/// A trivial helper function to check to see if the specified pointers are
@@ -373,7 +431,8 @@
/// A convenience wrapper around the \c isNoAlias helper interface.
bool isNoAlias(const Value *V1, const Value *V2) {
- return isNoAlias(MemoryLocation(V1), MemoryLocation(V2));
+ return isNoAlias(MemoryLocation::getBeforeOrAfter(V1),
+ MemoryLocation::getBeforeOrAfter(V2));
}
/// A trivial helper function to check to see if the specified pointers are
@@ -395,7 +454,7 @@
/// A convenience wrapper around the primary \c pointsToConstantMemory
/// interface.
bool pointsToConstantMemory(const Value *P, bool OrLocal = false) {
- return pointsToConstantMemory(MemoryLocation(P), OrLocal);
+ return pointsToConstantMemory(MemoryLocation::getBeforeOrAfter(P), OrLocal);
}
/// @}
@@ -488,7 +547,7 @@
/// write at most from objects pointed to by their pointer-typed arguments
/// (with arbitrary offsets).
static bool onlyAccessesArgPointees(FunctionModRefBehavior MRB) {
- return !(MRB & FMRL_Anywhere & ~FMRL_ArgumentPointees);
+ return !((unsigned)MRB & FMRL_Anywhere & ~FMRL_ArgumentPointees);
}
/// Checks if functions with the specified behavior are known to potentially
@@ -496,26 +555,27 @@
/// (with arbitrary offsets).
static bool doesAccessArgPointees(FunctionModRefBehavior MRB) {
return isModOrRefSet(createModRefInfo(MRB)) &&
- (MRB & FMRL_ArgumentPointees);
+ ((unsigned)MRB & FMRL_ArgumentPointees);
}
/// Checks if functions with the specified behavior are known to read and
/// write at most from memory that is inaccessible from LLVM IR.
static bool onlyAccessesInaccessibleMem(FunctionModRefBehavior MRB) {
- return !(MRB & FMRL_Anywhere & ~FMRL_InaccessibleMem);
+ return !((unsigned)MRB & FMRL_Anywhere & ~FMRL_InaccessibleMem);
}
/// Checks if functions with the specified behavior are known to potentially
/// read or write from memory that is inaccessible from LLVM IR.
static bool doesAccessInaccessibleMem(FunctionModRefBehavior MRB) {
- return isModOrRefSet(createModRefInfo(MRB)) && (MRB & FMRL_InaccessibleMem);
+ return isModOrRefSet(createModRefInfo(MRB)) &&
+ ((unsigned)MRB & FMRL_InaccessibleMem);
}
/// Checks if functions with the specified behavior are known to read and
/// write at most from memory that is inaccessible from LLVM IR or objects
/// pointed to by their pointer-typed arguments (with arbitrary offsets).
static bool onlyAccessesInaccessibleOrArgMem(FunctionModRefBehavior MRB) {
- return !(MRB & FMRL_Anywhere &
+ return !((unsigned)MRB & FMRL_Anywhere &
~(FMRL_InaccessibleMem | FMRL_ArgumentPointees));
}
@@ -643,19 +703,16 @@
/// Return information about whether a particular call site modifies
/// or reads the specified memory location \p MemLoc before instruction \p I
- /// in a BasicBlock. An ordered basic block \p OBB can be used to speed up
- /// instruction ordering queries inside the BasicBlock containing \p I.
+ /// in a BasicBlock.
/// Early exits in callCapturesBefore may lead to ModRefInfo::Must not being
/// set.
ModRefInfo callCapturesBefore(const Instruction *I,
- const MemoryLocation &MemLoc, DominatorTree *DT,
- OrderedBasicBlock *OBB = nullptr);
+ const MemoryLocation &MemLoc, DominatorTree *DT);
/// A convenience wrapper to synthesize a memory location.
ModRefInfo callCapturesBefore(const Instruction *I, const Value *P,
- LocationSize Size, DominatorTree *DT,
- OrderedBasicBlock *OBB = nullptr) {
- return callCapturesBefore(I, MemoryLocation(P, Size), DT, OBB);
+ LocationSize Size, DominatorTree *DT) {
+ return callCapturesBefore(I, MemoryLocation(P, Size), DT);
}
/// @}
@@ -718,40 +775,7 @@
AAQueryInfo &AAQI);
ModRefInfo getModRefInfo(const Instruction *I,
const Optional<MemoryLocation> &OptLoc,
- AAQueryInfo &AAQIP) {
- if (OptLoc == None) {
- if (const auto *Call = dyn_cast<CallBase>(I)) {
- return createModRefInfo(getModRefBehavior(Call));
- }
- }
-
- const MemoryLocation &Loc = OptLoc.getValueOr(MemoryLocation());
-
- switch (I->getOpcode()) {
- case Instruction::VAArg:
- return getModRefInfo((const VAArgInst *)I, Loc, AAQIP);
- case Instruction::Load:
- return getModRefInfo((const LoadInst *)I, Loc, AAQIP);
- case Instruction::Store:
- return getModRefInfo((const StoreInst *)I, Loc, AAQIP);
- case Instruction::Fence:
- return getModRefInfo((const FenceInst *)I, Loc, AAQIP);
- case Instruction::AtomicCmpXchg:
- return getModRefInfo((const AtomicCmpXchgInst *)I, Loc, AAQIP);
- case Instruction::AtomicRMW:
- return getModRefInfo((const AtomicRMWInst *)I, Loc, AAQIP);
- case Instruction::Call:
- return getModRefInfo((const CallInst *)I, Loc, AAQIP);
- case Instruction::Invoke:
- return getModRefInfo((const InvokeInst *)I, Loc, AAQIP);
- case Instruction::CatchPad:
- return getModRefInfo((const CatchPadInst *)I, Loc, AAQIP);
- case Instruction::CatchRet:
- return getModRefInfo((const CatchReturnInst *)I, Loc, AAQIP);
- default:
- return ModRefInfo::NoModRef;
- }
- }
+ AAQueryInfo &AAQIP);
class Concept;
@@ -765,6 +789,9 @@
std::vector<AnalysisKey *> AADeps;
+ /// Query depth used to distinguish recursive queries.
+ unsigned Depth = 0;
+
friend class BatchAAResults;
};
@@ -805,6 +832,13 @@
FunctionModRefBehavior getModRefBehavior(const CallBase *Call) {
return AA.getModRefBehavior(Call);
}
+ bool isMustAlias(const MemoryLocation &LocA, const MemoryLocation &LocB) {
+ return alias(LocA, LocB) == MustAlias;
+ }
+ bool isMustAlias(const Value *V1, const Value *V2) {
+ return alias(MemoryLocation(V1, LocationSize::precise(1)),
+ MemoryLocation(V2, LocationSize::precise(1))) == MustAlias;
+ }
};
/// Temporary typedef for legacy code that uses a generic \c AliasAnalysis
@@ -949,7 +983,7 @@
/// A pointer to the AAResults object that this AAResult is
/// aggregated within. May be null if not aggregated.
- AAResults *AAR;
+ AAResults *AAR = nullptr;
/// Helper to dispatch calls back through the derived type.
DerivedT &derived() { return static_cast<DerivedT &>(*this); }
@@ -1065,9 +1099,6 @@
/// Return true if this pointer is returned by a noalias function.
bool isNoAliasCall(const Value *V);
-/// Return true if this is an argument with the noalias attribute.
-bool isNoAliasArgument(const Value *V);
-
/// Return true if this pointer refers to a distinct and identifiable object.
/// This returns true for:
/// Global Variables and Functions (but not Global Aliases)
@@ -1115,12 +1146,7 @@
ResultGetters.push_back(&getModuleAAResultImpl<AnalysisT>);
}
- Result run(Function &F, FunctionAnalysisManager &AM) {
- Result R(AM.getResult<TargetLibraryAnalysis>(F));
- for (auto &Getter : ResultGetters)
- (*Getter)(F, AM, R);
- return R;
- }
+ Result run(Function &F, FunctionAnalysisManager &AM);
private:
friend AnalysisInfoMixin<AAManager>;
@@ -1143,8 +1169,8 @@
static void getModuleAAResultImpl(Function &F, FunctionAnalysisManager &AM,
AAResults &AAResults) {
auto &MAMProxy = AM.getResult<ModuleAnalysisManagerFunctionProxy>(F);
- auto &MAM = MAMProxy.getManager();
- if (auto *R = MAM.template getCachedResult<AnalysisT>(*F.getParent())) {
+ if (auto *R =
+ MAMProxy.template getCachedResult<AnalysisT>(*F.getParent())) {
AAResults.addAAResult(*R);
MAMProxy
.template registerOuterAnalysisInvalidation<AnalysisT, AAManager>();
@@ -1179,14 +1205,9 @@
static char ID;
- ExternalAAWrapperPass() : ImmutablePass(ID) {
- initializeExternalAAWrapperPassPass(*PassRegistry::getPassRegistry());
- }
+ ExternalAAWrapperPass();
- explicit ExternalAAWrapperPass(CallbackT CB)
- : ImmutablePass(ID), CB(std::move(CB)) {
- initializeExternalAAWrapperPassPass(*PassRegistry::getPassRegistry());
- }
+ explicit ExternalAAWrapperPass(CallbackT CB);
void getAnalysisUsage(AnalysisUsage &AU) const override {
AU.setPreservesAll();