[llvm] r236471 - [X86] Fix assertion while DAG combining offsets and ExternalSymbols
Reid Kleckner
reid at kleckner.net
Mon May 4 16:22:36 PDT 2015
Author: rnk
Date: Mon May 4 18:22:36 2015
New Revision: 236471
URL: http://llvm.org/viewvc/llvm-project?rev=236471&view=rev
Log:
[X86] Fix assertion while DAG combining offsets and ExternalSymbols
ExternalSymbol nodes do not contain offsets, unlike GlobalValue nodes.
Modified:
llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp
llvm/trunk/test/CodeGen/X86/frameescape.ll
Modified: llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp?rev=236471&r1=236470&r2=236471&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp Mon May 4 18:22:36 2015
@@ -603,6 +603,9 @@ static bool isDispSafeForFrameIndex(int6
bool X86DAGToDAGISel::FoldOffsetIntoAddress(uint64_t Offset,
X86ISelAddressMode &AM) {
+ // Cannot combine ExternalSymbol displacements with integer offsets.
+ if (Offset != 0 && AM.ES)
+ return true;
int64_t Val = AM.Disp + Offset;
CodeModel::Model M = TM.getCodeModel();
if (Subtarget->is64Bit()) {
@@ -1009,7 +1012,7 @@ bool X86DAGToDAGISel::MatchAddressRecurs
switch (N.getOpcode()) {
default: break;
case ISD::FRAME_ALLOC_RECOVER: {
- if (!AM.hasSymbolicDisplacement())
+ if (!AM.hasSymbolicDisplacement() && AM.Disp == 0)
if (const auto *ESNode = dyn_cast<ExternalSymbolSDNode>(N.getOperand(0)))
if (ESNode->getOpcode() == ISD::TargetExternalSymbol) {
// Use the symbol and don't prefix it.
Modified: llvm/trunk/test/CodeGen/X86/frameescape.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/frameescape.ll?rev=236471&r1=236470&r2=236471&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/X86/frameescape.ll (original)
+++ llvm/trunk/test/CodeGen/X86/frameescape.ll Mon May 4 18:22:36 2015
@@ -18,6 +18,9 @@ define void @print_framealloc_from_fp(i8
%b.val = load i32, i32* %b
call i32 (i8*, ...) @printf(i8* getelementptr ([10 x i8], [10 x i8]* @str, i32 0, i32 0), i32 %b.val)
store i32 42, i32* %b
+ %b2 = getelementptr i32, i32* %b, i32 1
+ %b2.val = load i32, i32* %b2
+ call i32 (i8*, ...) @printf(i8* getelementptr ([10 x i8], [10 x i8]* @str, i32 0, i32 0), i32 %b2.val)
ret void
}
@@ -46,13 +49,18 @@ define void @print_framealloc_from_fp(i8
; X86: movl $_str, (%esp)
; X86: calll _printf
; X86: movl $42, Lalloc_func$frame_escape_1(%esi)
+; X86: movl $4, %eax
+; X86: movl Lalloc_func$frame_escape_1(%esi,%eax), %eax
+; X86: movl %eax, 4(%esp)
+; X86: movl $_str, (%esp)
+; X86: calll _printf
; X86: addl $8, %esp
; X86: popl %esi
; X86: retl
define void @alloc_func() {
%a = alloca i32
- %b = alloca i32
+ %b = alloca i32, i32 2
call void (...) @llvm.frameescape(i32* %a, i32* %b)
store i32 42, i32* %a
store i32 13, i32* %b
@@ -67,9 +75,9 @@ define void @alloc_func() {
; X64: leaq 48(%rsp), %rbp
; X64: .seh_setframe 5, 48
; X64: .Lalloc_func$frame_escape_0 = 44
-; X64: .Lalloc_func$frame_escape_1 = 40
+; X64: .Lalloc_func$frame_escape_1 = 36
; X64: movl $42, -4(%rbp)
-; X64: movl $13, -8(%rbp)
+; X64: movl $13, -12(%rbp)
; X64: leaq -48(%rbp), %rcx
; X64: callq print_framealloc_from_fp
; X64: retq
@@ -77,14 +85,14 @@ define void @alloc_func() {
; X86-LABEL: alloc_func:
; X86: pushl %ebp
; X86: movl %esp, %ebp
-; X86: subl $12, %esp
+; X86: subl $16, %esp
; X86: Lalloc_func$frame_escape_0 = -4
-; X86: Lalloc_func$frame_escape_1 = -8
+; X86: Lalloc_func$frame_escape_1 = -12
; X86: movl $42, -4(%ebp)
-; X86: movl $13, -8(%ebp)
+; X86: movl $13, -12(%ebp)
; X86: movl %ebp, (%esp)
; X86: calll _print_framealloc_from_fp
-; X86: addl $12, %esp
+; X86: addl $16, %esp
; X86: popl %ebp
; X86: retl
@@ -116,3 +124,5 @@ define void @alloc_func_no_frameaddr() {
; X64: callq print_framealloc_from_fp
; X64: addq $40, %rsp
; X64: retq
+
+; X86-LABEL: alloc_func_no_frameaddr:
More information about the llvm-commits
mailing list