From ea68c7c9a8ba5b791ffab2be4a554f44acef5690 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. llvm-svn: 85762 --- llvm/include/llvm/CodeGen/PseudoSourceValue.h | 4 ++++ llvm/lib/CodeGen/PseudoSourceValue.cpp | 17 +++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/llvm/include/llvm/CodeGen/PseudoSourceValue.h b/llvm/include/llvm/CodeGen/PseudoSourceValue.h index 7a9122d89f9d..26392f59bd79 100644 --- a/llvm/include/llvm/CodeGen/PseudoSourceValue.h +++ b/llvm/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/llvm/lib/CodeGen/PseudoSourceValue.cpp b/llvm/lib/CodeGen/PseudoSourceValue.cpp index 1875cc78f58a..5507646878cb 100644 --- a/llvm/lib/CodeGen/PseudoSourceValue.cpp +++ b/llvm/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); +}