Index: include/llvm/Analysis/CFLAliasAnalysisUtils.h =================================================================== --- include/llvm/Analysis/CFLAliasAnalysisUtils.h +++ include/llvm/Analysis/CFLAliasAnalysisUtils.h @@ -41,4 +41,19 @@ } }; +namespace llvm { +namespace cflaa { +inline const Function *parentFunctionOfValue(const Value *Val) { + if (auto *Inst = dyn_cast(Val)) { + auto *Bb = Inst->getParent(); + return Bb->getParent(); + } + + if (auto *Arg = dyn_cast(Val)) + return Arg->getParent(); + return nullptr; +} +} +} + #endif // LLVM_ANALYSIS_CFLALIASANALYSISUTILS_H Index: lib/Analysis/CFLAndersAliasAnalysis.cpp =================================================================== --- lib/Analysis/CFLAndersAliasAnalysis.cpp +++ lib/Analysis/CFLAndersAliasAnalysis.cpp @@ -68,17 +68,6 @@ : AAResultBase(std::move(RHS)), TLI(RHS.TLI) {} CFLAndersAAResult::~CFLAndersAAResult() {} -static const Function *parentFunctionOfValue(const Value *Val) { - if (auto *Inst = dyn_cast(Val)) { - auto *Bb = Inst->getParent(); - return Bb->getParent(); - } - - if (auto *Arg = dyn_cast(Val)) - return Arg->getParent(); - return nullptr; -} - namespace { enum class MatchState : uint8_t { Index: lib/Analysis/CFLSteensAliasAnalysis.cpp =================================================================== --- lib/Analysis/CFLSteensAliasAnalysis.cpp +++ lib/Analysis/CFLSteensAliasAnalysis.cpp @@ -90,17 +90,6 @@ /// Determines whether it would be pointless to add the given Value to our sets. static bool canSkipAddingToSets(Value *Val); -static Function *parentFunctionOfValue(Value *Val) { - if (auto *Inst = dyn_cast(Val)) { - auto *Bb = Inst->getParent(); - return Bb->getParent(); - } - - if (auto *Arg = dyn_cast(Val)) - return Arg->getParent(); - return nullptr; -} - static bool canSkipAddingToSets(Value *Val) { // Constants can share instances, which may falsely unify multiple // sets, e.g. in @@ -281,8 +270,8 @@ return NoAlias; Function *Fn = nullptr; - Function *MaybeFnA = parentFunctionOfValue(ValA); - Function *MaybeFnB = parentFunctionOfValue(ValB); + Function *MaybeFnA = const_cast(parentFunctionOfValue(ValA)); + Function *MaybeFnB = const_cast(parentFunctionOfValue(ValB)); if (!MaybeFnA && !MaybeFnB) { // The only times this is known to happen are when globals + InlineAsm are // involved