mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-31 10:34:17 +00:00
[X86] Fix assertion while DAG combining offsets and ExternalSymbols
ExternalSymbol nodes do not contain offsets, unlike GlobalValue nodes. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@236471 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
8737acdac2
commit
c5315e5d05
@ -603,6 +603,9 @@ static bool isDispSafeForFrameIndex(int64_t Val) {
|
||||
|
||||
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::MatchAddressRecursively(SDValue N, X86ISelAddressMode &AM,
|
||||
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.
|
||||
|
@ -18,6 +18,9 @@ define void @print_framealloc_from_fp(i8* %fp) {
|
||||
%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* %fp) {
|
||||
; 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:
|
||||
|
Loading…
x
Reference in New Issue
Block a user