From 71b9b6be1bca11f35172b8bef128ca76959dfd08 Mon Sep 17 00:00:00 2001 From: David Majnemer Date: Thu, 5 Mar 2015 18:50:12 +0000 Subject: [PATCH] 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. llvm-svn: 231389 --- llvm/lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp | 1 + llvm/lib/Target/X86/X86ISelDAGToDAG.cpp | 9 +++++++++ llvm/test/CodeGen/X86/frameescape.ll | 8 ++++---- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp index 17eff94..5898da4 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp @@ -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"; diff --git a/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp b/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp index 8d50ae1..4271556 100644 --- a/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp +++ b/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp @@ -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(N.getOperand(0))) + if (ESNode->getOpcode() == ISD::TargetExternalSymbol) { + AM.ES = ESNode->getSymbol(); + return false; + } + break; + } case ISD::Constant: { uint64_t Val = cast(N)->getSExtValue(); if (!FoldOffsetIntoAddress(Val, AM)) diff --git a/llvm/test/CodeGen/X86/frameescape.ll b/llvm/test/CodeGen/X86/frameescape.ll index 621dbe2..b48672d 100644 --- a/llvm/test/CodeGen/X86/frameescape.ll +++ b/llvm/test/CodeGen/X86/frameescape.ll @@ -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() { -- 2.7.4