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

Disable szclass 12 for i686 systems. #19647

Merged
merged 1 commit into from
Dec 20, 2016
Merged

Disable szclass 12 for i686 systems. #19647

merged 1 commit into from
Dec 20, 2016

Conversation

vchuravy
Copy link
Member

The interplay between platform ABI and alignment for atomic ops is
tricky. This disables szclass 12 on i686 until we can use libatomic on all 32bit platforms (Windows support is currently missing).

The interplay between platform ABI and alignment for atomic ops is
tricky. This disables szclass 12 on i686 until we can use libatomic on all 32bit platforms (Windows support is currently missing).
@vchuravy vchuravy requested review from yuyichao and tkelman December 19, 2016 12:02
@vchuravy
Copy link
Member Author

I tested this on a cross-compile with wine and LLVM 3.9

using Base.Threads

function f(a)
    a[] = 128
end

for T in (UInt32, UInt64)
  @show T
  open("atomic_$(T)_$(Sys.ARCH).ll", "w") do io
    code_llvm(io, f, (Atomic{T},))
  end
  open("atomic_$(T)_$(Sys.ARCH).S", "w") do io
    code_native(io, f, (Atomic{T},))
  end
end

Prior:


; Function Attrs: alignstack(16)
define i32 @julia_f_60451(%jl_value_t*) #0 !dbg !5 {
top:
  %1 = bitcast %jl_value_t* %0 to i64*
  store atomic i64 128, i64* %1 release, align 4
  ret i32 128
}

After:

; Function Attrs: alignstack(16)
define i32 @julia_f_60448(%jl_value_t*) #0 !dbg !5 {
top:
  %1 = bitcast %jl_value_t* %0 to i64*
  store atomic i64 128, i64* %1 release, align 16
  ret i32 128
}

code_native only works after the change:

	.text
Filename: atomic.jl
	pushl	%ebp
	movl	%esp, %ebp
	pushl	%ebx
	pushl	%esi
	andl	$-16, %esp
	movl	8(%ebp), %esi
Source line: 4
	movl	(%esi), %eax
	movl	4(%esi), %edx
L16:
	xorl	%ecx, %ecx
	movl	$128, %ebx
	lock
	cmpxchg8b	(%esi)
	jne	L16
	movl	$128, %eax
	leal	-8(%ebp), %esp
	popl	%esi
	popl	%ebx
	popl	%ebp
	retl
	nopl	(%eax)

@vchuravy vchuravy mentioned this pull request Dec 19, 2016
@tkelman
Copy link
Contributor

tkelman commented Dec 19, 2016

The patch looks fine. I'll test locally - need to remember to rebase (when I test locally) to pick up the arm patches just added, just in case

@tkelman tkelman merged commit 5f5c6bb into master Dec 20, 2016
@tkelman tkelman deleted the vc/32bit_atomic branch December 20, 2016 07:23
vchuravy added a commit that referenced this pull request Jun 2, 2017
vchuravy added a commit that referenced this pull request Jun 3, 2017
vchuravy added a commit that referenced this pull request Jun 6, 2017
jeffwong pushed a commit to jeffwong/julia that referenced this pull request Jul 24, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants