[PATCH] D34660: [CFLAA] Move a common function to the utils header to reduce duplication
Davide Italiano via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 26 19:25:19 PDT 2017
This revision was automatically updated to reflect the committed changes.
Closed by commit rL306354: [CFLAA] Move a common function to the header to reduce duplication. (authored by davide).
Changed prior to commit:
https://reviews.llvm.org/D34660?vs=104061&id=104079#toc
Repository:
rL LLVM
https://reviews.llvm.org/D34660
Files:
llvm/trunk/include/llvm/Analysis/CFLAliasAnalysisUtils.h
llvm/trunk/lib/Analysis/CFLAndersAliasAnalysis.cpp
llvm/trunk/lib/Analysis/CFLSteensAliasAnalysis.cpp
Index: llvm/trunk/lib/Analysis/CFLSteensAliasAnalysis.cpp
===================================================================
--- llvm/trunk/lib/Analysis/CFLSteensAliasAnalysis.cpp
+++ llvm/trunk/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<Instruction>(Val)) {
- auto *Bb = Inst->getParent();
- return Bb->getParent();
- }
-
- if (auto *Arg = dyn_cast<Argument>(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<Function *>(parentFunctionOfValue(ValA));
+ Function *MaybeFnB = const_cast<Function *>(parentFunctionOfValue(ValB));
if (!MaybeFnA && !MaybeFnB) {
// The only times this is known to happen are when globals + InlineAsm are
// involved
Index: llvm/trunk/lib/Analysis/CFLAndersAliasAnalysis.cpp
===================================================================
--- llvm/trunk/lib/Analysis/CFLAndersAliasAnalysis.cpp
+++ llvm/trunk/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<Instruction>(Val)) {
- auto *Bb = Inst->getParent();
- return Bb->getParent();
- }
-
- if (auto *Arg = dyn_cast<Argument>(Val))
- return Arg->getParent();
- return nullptr;
-}
-
namespace {
enum class MatchState : uint8_t {
Index: llvm/trunk/include/llvm/Analysis/CFLAliasAnalysisUtils.h
===================================================================
--- llvm/trunk/include/llvm/Analysis/CFLAliasAnalysisUtils.h
+++ llvm/trunk/include/llvm/Analysis/CFLAliasAnalysisUtils.h
@@ -41,4 +41,19 @@
}
};
+namespace llvm {
+namespace cflaa {
+static inline const Function *parentFunctionOfValue(const Value *Val) {
+ if (auto *Inst = dyn_cast<Instruction>(Val)) {
+ auto *Bb = Inst->getParent();
+ return Bb->getParent();
+ }
+
+ if (auto *Arg = dyn_cast<Argument>(Val))
+ return Arg->getParent();
+ return nullptr;
+} // namespace cflaa
+} // namespace llvm
+}
+
#endif // LLVM_ANALYSIS_CFLALIASANALYSISUTILS_H
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D34660.104079.patch
Type: text/x-patch
Size: 2649 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170627/58c7ed63/attachment.bin>
More information about the llvm-commits
mailing list