From f57b1baa441e3bbce7f264d8bb5054e50fe8ee1c Mon Sep 17 00:00:00 2001 From: Evan Cheng Date: Sun, 1 Nov 2009 23:50:04 +0000 Subject: [PATCH] Add PseudoSourceValue::mayAlias. It returns true if the object can ever alias any LLVM IR value. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85762 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/PseudoSourceValue.h | 4 ++++ lib/CodeGen/PseudoSourceValue.cpp | 17 +++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/include/llvm/CodeGen/PseudoSourceValue.h b/include/llvm/CodeGen/PseudoSourceValue.h index 7a9122d89f9..26392f59bd7 100644 --- a/include/llvm/CodeGen/PseudoSourceValue.h +++ b/include/llvm/CodeGen/PseudoSourceValue.h @@ -43,6 +43,10 @@ namespace llvm { /// PseudoSourceValue may also be pointed to by an LLVM IR Value. virtual bool isAliased(const MachineFrameInfo *) const; + /// mayAlias - Return true if the memory pointed to by this + /// PseudoSourceValue can ever alias a LLVM IR Value. + virtual bool mayAlias(const MachineFrameInfo *) const; + /// classof - Methods for support type inquiry through isa, cast, and /// dyn_cast: /// diff --git a/lib/CodeGen/PseudoSourceValue.cpp b/lib/CodeGen/PseudoSourceValue.cpp index 1875cc78f58..5507646878c 100644 --- a/lib/CodeGen/PseudoSourceValue.cpp +++ b/lib/CodeGen/PseudoSourceValue.cpp @@ -64,6 +64,8 @@ namespace { virtual bool isAliased(const MachineFrameInfo *MFI) const; + virtual bool mayAlias(const MachineFrameInfo *) const; + virtual void printCustom(raw_ostream &OS) const { OS << "FixedStack" << FI; } @@ -100,6 +102,14 @@ bool PseudoSourceValue::isAliased(const MachineFrameInfo *MFI) const { return true; } +bool PseudoSourceValue::mayAlias(const MachineFrameInfo *MFI) const { + if (this == getGOT() || + this == getConstantPool() || + this == getJumpTable()) + return false; + return true; +} + bool FixedStackPseudoSourceValue::isConstant(const MachineFrameInfo *MFI) const{ return MFI && MFI->isImmutableObjectIndex(FI); } @@ -113,3 +123,10 @@ bool FixedStackPseudoSourceValue::isAliased(const MachineFrameInfo *MFI) const { // Spill slots should not alias others. return !MFI->isFixedObjectIndex(FI) && !MFI->isSpillSlotObjectIndex(FI); } + +bool FixedStackPseudoSourceValue::mayAlias(const MachineFrameInfo *MFI) const { + if (!MFI) + return true; + // Spill slots will not alias any LLVM IR value. + return !MFI->isSpillSlotObjectIndex(FI); +} -- 2.34.1