From ce26c27b2a7fe1c11885223ed0c150859270391b Mon Sep 17 00:00:00 2001 From: Nirav Dave Date: Tue, 4 Dec 2018 17:59:43 +0000 Subject: [PATCH] [SelectionDAG] Redefine isGAPlusOffset in terms of unwrapAddress. NFCI. llvm-svn: 348288 --- llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp | 5 ++++- llvm/lib/Target/X86/X86ISelLowering.cpp | 15 --------------- llvm/lib/Target/X86/X86ISelLowering.h | 3 --- 3 files changed, 4 insertions(+), 19 deletions(-) diff --git a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp index 82d86204d80b..33dad187d4af 100644 --- a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp @@ -2998,8 +2998,11 @@ SDValue TargetLowering::SimplifySetCC(EVT VT, SDValue N0, SDValue N1, /// Returns true (and the GlobalValue and the offset) if the node is a /// GlobalAddress + offset. -bool TargetLowering::isGAPlusOffset(SDNode *N, const GlobalValue *&GA, +bool TargetLowering::isGAPlusOffset(SDNode *WN, const GlobalValue *&GA, int64_t &Offset) const { + + SDNode *N = unwrapAddress(SDValue(WN, 0)).getNode(); + if (auto *GASD = dyn_cast(N)) { GA = GASD->getGlobal(); Offset += GASD->getOffset(); diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp index 436ee4c42050..da1ebb809c0f 100644 --- a/llvm/lib/Target/X86/X86ISelLowering.cpp +++ b/llvm/lib/Target/X86/X86ISelLowering.cpp @@ -30169,21 +30169,6 @@ SDValue X86TargetLowering::unwrapAddress(SDValue N) const { return N; } -/// Returns true (and the GlobalValue and the offset) if the node is a -/// GlobalAddress + offset. -bool X86TargetLowering::isGAPlusOffset(SDNode *N, - const GlobalValue* &GA, - int64_t &Offset) const { - if (N->getOpcode() == X86ISD::Wrapper) { - if (isa(N->getOperand(0))) { - GA = cast(N->getOperand(0))->getGlobal(); - Offset = cast(N->getOperand(0))->getOffset(); - return true; - } - } - return TargetLowering::isGAPlusOffset(N, GA, Offset); -} - // Attempt to match a combined shuffle mask against supported unary shuffle // instructions. // TODO: Investigate sharing more of this with shuffle lowering. diff --git a/llvm/lib/Target/X86/X86ISelLowering.h b/llvm/lib/Target/X86/X86ISelLowering.h index a34416944520..e2a8eaacb3be 100644 --- a/llvm/lib/Target/X86/X86ISelLowering.h +++ b/llvm/lib/Target/X86/X86ISelLowering.h @@ -877,9 +877,6 @@ namespace llvm { SDValue unwrapAddress(SDValue N) const override; - bool isGAPlusOffset(SDNode *N, const GlobalValue* &GA, - int64_t &Offset) const override; - SDValue getReturnAddressFrameIndex(SelectionDAG &DAG) const; bool ExpandInlineAsm(CallInst *CI) const override;