Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MC generated wrong code for label arithmetic #22434

Closed
llvmbot opened this issue Dec 30, 2014 · 6 comments
Closed

MC generated wrong code for label arithmetic #22434

llvmbot opened this issue Dec 30, 2014 · 6 comments
Assignees
Labels
bugzilla Issues migrated from bugzilla mc Machine (object) code

Comments

@llvmbot
Copy link
Collaborator

llvmbot commented Dec 30, 2014

Bugzilla Link 22060
Resolution FIXED
Resolved on Feb 09, 2015 00:31
Version trunk
OS Windows NT
Blocks #22748
Attachments the sample
Reporter LLVM Bugzilla Contributor
CC @majnemer,@zmodem

Extended Description

see aa.s in attachment, then

llvm-mc -arch=x86 -triple=pc-windows-msvc -filetype=obj aa.s -o aa.obj

we disassemble the aa.obj and can found following

calll	L18$pb

L18$pb:
popl %eax
leal "?WndProc@@YGJPAUHWND__@@iij@Z"-L18$pb(%eax), %eax
movl 24(%ebp), %ecx
movl 20(%ebp), %edx
movl 16(%ebp), %esi
movl 12(%ebp), %edi
movl 8(%ebp), %ebx
movl %eax, 76(%esp) # 4-byte Spill
retl

.def	 "?WndProc@@YGJPAUHWND__@@IIJ@Z";
.scl	2;
.type	32;
.endef
.globl	"?WndProc@@YGJPAUHWND__@@IIJ@Z"

"?WndProc@@YGJPAUHWND__@@iij@Z": # @"\01?WndProc@@YGJPAUHWND__@@iij@Z"

BB#0:

pushl	%ebp
movl	%esp, %ebp

retl

is assembled to

.text:00000000 public ?SetUpWindow@@YAPAUHWND__@@PBD0HHPAUHINSTANCE__@@@z
.text:00000000 ?SetUpWindow@@YAPAUHWND__@@PBD0HHPAUHINSTANCE__@@@z proc near
.text:00000000
.text:00000000 arg_0 = dword ptr 8
.text:00000000 arg_4 = dword ptr 0Ch
.text:00000000 arg_8 = dword ptr 10h
.text:00000000 arg_C = dword ptr 14h
.text:00000000 arg_10 = dword ptr 18h
.text:00000000
.text:00000000 push ebp
.text:00000001 mov ebp, esp
.text:00000003
.text:00000003 loc_3:
.text:00000003 push ebx
.text:00000004 push edi
.text:00000005 push esi
.text:00000006 and esp, 0FFFFFFF8h
.text:00000009 sub esp, 80h
.text:0000000F call $+5
.text:00000014 pop eax
.text:00000015
.text:00000015 loc_15:
.text:00000015 lea eax, [eax+3]
.text:0000001B mov ecx, [ebp+arg_10]
.text:0000001E mov edx, [ebp+arg_C]
.text:00000021 mov esi, [ebp+arg_8]
.text:00000024 mov edi, [ebp+arg_4]
.text:00000027 mov ebx, [ebp+arg_0]
.text:0000002A mov [esp+4Ch], eax
.text:0000002E retn
.text:0000002E ?SetUpWindow@@YAPAUHWND__@@PBD0HHPAUHINSTANCE__@@@z endp ; sp-analysis failed

.text:00000015 lea eax, [eax+3]

obviuosly it is not the right code for:

leal "?WndProc@@YGJPAUHWND__@@iij@Z"-L18$pb(%eax), %eax

@llvmbot
Copy link
Collaborator Author

llvmbot commented Dec 30, 2014

assigned to @majnemer

@zmodem
Copy link
Collaborator

zmodem commented Feb 6, 2015

Confirmed that this is a regression from 3.5 to 3.6 (and trunk).

objdump diff from 3.5 to 3.6:

@@ -14,7 +14,7 @@
9: 81 ec 80 00 00 00 sub $0x80,%esp
f: e8 00 00 00 00 call 14 <?SetUpWindow@@YAPAUHWND__@@PBD0HHPAUHINSTANCE__@@@z+0x14>
14: 58 pop %eax

  • 15: 8d 80 1b 00 00 00 lea 0x1b(%eax),%eax
  • 15: 8d 80 03 00 00 00 lea 0x3(%eax),%eax
    1b: 8b 4d 18 mov 0x18(%ebp),%ecx
    1e: 8b 55 14 mov 0x14(%ebp),%edx
    21: 8b 75 10 mov 0x10(%ebp),%esi

That certainly looks like a real problem.

@zmodem
Copy link
Collaborator

zmodem commented Feb 7, 2015

Bisection points to r221678.

David, can you take a look?

@majnemer
Copy link
Mannequin

majnemer mannequin commented Feb 7, 2015

Hi,

Can I please get some IR? I'm a little confused as to how we could generate this assembly.

@majnemer
Copy link
Mannequin

majnemer mannequin commented Feb 9, 2015

Fixed in r228565.

@zmodem
Copy link
Collaborator

zmodem commented Nov 26, 2021

mentioned in issue #22748

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 9, 2021
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla mc Machine (object) code
Projects
None yet
Development

No branches or pull requests

2 participants