X86: Optimize address mode matching for FRAME_ALLOC_RECOVER nodes

We know that the absolute symbol will be less than 2GB and thus will
always fit.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@231389 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
David Majnemer 2015-03-05 18:50:12 +00:00
parent 29d788f11b
commit 42fcf79f36
3 changed files with 14 additions and 4 deletions

View File

@ -95,6 +95,7 @@ std::string SDNode::getOperationName(const SelectionDAG *G) const {
case ISD::GLOBAL_OFFSET_TABLE: return "GLOBAL_OFFSET_TABLE";
case ISD::RETURNADDR: return "RETURNADDR";
case ISD::FRAMEADDR: return "FRAMEADDR";
case ISD::FRAME_ALLOC_RECOVER: return "FRAME_ALLOC_RECOVER";
case ISD::READ_REGISTER: return "READ_REGISTER";
case ISD::WRITE_REGISTER: return "WRITE_REGISTER";
case ISD::FRAME_TO_ARGS_OFFSET: return "FRAME_TO_ARGS_OFFSET";

View File

@ -1004,6 +1004,15 @@ bool X86DAGToDAGISel::MatchAddressRecursively(SDValue N, X86ISelAddressMode &AM,
switch (N.getOpcode()) {
default: break;
case ISD::FRAME_ALLOC_RECOVER: {
if (!AM.hasSymbolicDisplacement())
if (const auto *ESNode = dyn_cast<ExternalSymbolSDNode>(N.getOperand(0)))
if (ESNode->getOpcode() == ISD::TargetExternalSymbol) {
AM.ES = ESNode->getSymbol();
return false;
}
break;
}
case ISD::Constant: {
uint64_t Val = cast<ConstantSDNode>(N)->getSExtValue();
if (!FoldOffsetIntoAddress(Val, AM))

View File

@ -16,20 +16,20 @@ define void @print_framealloc_from_fp(i8* %fp) {
%b = bitcast i8* %b.i8 to i32*
%b.val = load i32, i32* %b
call i32 (i8*, ...)* @printf(i8* getelementptr ([10 x i8]* @str, i32 0, i32 0), i32 %b.val)
store i32 42, i32* %b
ret void
}
; CHECK-LABEL: print_framealloc_from_fp:
; CHECK: movq %rcx, %[[parent_fp:[a-z]+]]
; CHECK: movabsq $.Lalloc_func$frame_escape_0, %[[offs:[a-z]+]]
; CHECK: movl (%[[parent_fp]],%[[offs]]), %edx
; CHECK: movl .Lalloc_func$frame_escape_0(%[[parent_fp]]), %edx
; CHECK: leaq {{.*}}(%rip), %[[str:[a-z]+]]
; CHECK: movq %[[str]], %rcx
; CHECK: callq printf
; CHECK: movabsq $.Lalloc_func$frame_escape_1, %[[offs:[a-z]+]]
; CHECK: movl (%[[parent_fp]],%[[offs]]), %edx
; CHECK: movl .Lalloc_func$frame_escape_1(%[[parent_fp]]), %edx
; CHECK: movq %[[str]], %rcx
; CHECK: callq printf
; CHECK: movl $42, .Lalloc_func$frame_escape_1(%[[parent_fp]])
; CHECK: retq
define void @alloc_func() {