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

Support memcpy/memmove with differing src/dst alignment #55633

Merged
merged 1 commit into from Nov 9, 2018

Conversation

Projects
None yet
6 participants
@nikic
Contributor

nikic commented Nov 2, 2018

If LLVM 7 is used, generate memcpy/memmove with differing src/dst alignment. I've added new FFI functions to construct these through the builder API, which is more convenient than dealing with differing intrinsic signatures depending on the LLVM version.

Fixes #49740.

@rust-highfive

This comment has been minimized.

Collaborator

rust-highfive commented Nov 2, 2018

r? @estebank

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive

This comment was marked as resolved.

Collaborator

rust-highfive commented Nov 2, 2018

The job x86_64-gnu-llvm-5.0 of your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
travis_time:end:0fbc0075:start=1541198502329507750,finish=1541198561069533610,duration=58740025860
$ git checkout -qf FETCH_HEAD
travis_fold:end:git.checkout

Encrypted environment variables have been removed for security reasons.
See https://docs.travis-ci.com/user/pull-requests/#Pull-Requests-and-Security-Restrictions
$ export SCCACHE_BUCKET=rust-lang-ci-sccache2
$ export SCCACHE_REGION=us-west-1
Setting environment variables from .travis.yml
$ export IMAGE=x86_64-gnu-llvm-5.0
---

[00:04:05] travis_fold:start:tidy
travis_time:start:tidy
tidy check
[00:04:05] tidy error: /checkout/src/librustc_codegen_llvm/mir/block.rs:755: line longer than 100 chars
[00:04:07] some tidy checks failed
[00:04:07] 
[00:04:07] 
[00:04:07] command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools-bin/tidy" "/checkout/src" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "--no-vendor" "--quiet"
[00:04:07] 
[00:04:07] 
[00:04:07] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test src/tools/tidy
[00:04:07] Build completed unsuccessfully in 0:00:48
[00:04:07] Build completed unsuccessfully in 0:00:48
[00:04:07] Makefile:79: recipe for target 'tidy' failed
[00:04:07] make: *** [tidy] Error 1

The command "stamp sh -x -c "$RUN_SCRIPT"" exited with 2.
travis_time:start:05353fbf
$ date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true)
---
travis_time:end:06ef3ea2:start=1541198818150528354,finish=1541198818156199226,duration=5670872
travis_fold:end:after_failure.3
travis_fold:start:after_failure.4
travis_time:start:0119d167
$ ln -s . checkout && for CORE in obj/cores/core.*; do EXE=$(echo $CORE | sed 's|obj/cores/core\.[0-9]*\.!checkout!\(.*\)|\1|;y|!|/|'); if [ -f "$EXE" ]; then printf travis_fold":start:crashlog\n\033[31;1m%s\033[0m\n" "$CORE"; gdb --batch -q -c "$CORE" "$EXE" -iex 'set auto-load off' -iex 'dir src/' -iex 'set sysroot .' -ex bt -ex q; echo travis_fold":"end:crashlog; fi; done || true
travis_fold:end:after_failure.4
travis_fold:start:after_failure.5
travis_time:start:26902fac
travis_time:start:26902fac
$ cat ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers || true
cat: ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers: No such file or directory
travis_fold:end:after_failure.5
travis_fold:start:after_failure.6
travis_time:start:1839ed0c
$ dmesg | grep -i kill

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@nikic nikic force-pushed the nikic:memcpy-align branch from 845ca78 to bea6b93 Nov 2, 2018

let volatile = C_bool(cx, flags.contains(MemFlags::VOLATILE));
bx.call(memcpy, &[dst_ptr, src_ptr, size, align, volatile], None);
let volatile = flags.contains(MemFlags::VOLATILE);
bx.memcpy(dst_ptr, dst_align.abi(), src_ptr, src_align.abi(), size, volatile);
}
pub fn memcpy_ty(

This comment has been minimized.

@nagisa

nagisa Nov 3, 2018

Contributor

What is the benefit of allowing caller to specify different src layout and src alignment (contained within their respective layout) separately?

Seeing it is a convenience wrapper, it would make sense to simply take TyLayout for both dst and src and extract the necessary information from that.

This comment has been minimized.

@nikic

nikic Nov 3, 2018

Contributor

I don't think those alignments necessarily match. A type can be stored at a location with higher alignment than what the type layout alignment specifies. One example where this may happen is for field projections, where the alignment of the field is determined by the alignment of the containing structure and the field offset, not the layout alignment of the field type.

This comment has been minimized.

@nagisa

nagisa Nov 3, 2018

Contributor

One example where this may happen is for field projections, where the alignment of the field is determined by the alignment of the containing structure and the field offset, not the layout alignment of the field type.

Fair. Although we don’t optimise this way currently, there were some discussion about doing so, so code might end up becoming what it looks like now anyway.

@nagisa

This comment has been minimized.

Contributor

nagisa commented Nov 3, 2018

@bors r+

@bors

This comment has been minimized.

Contributor

bors commented Nov 3, 2018

📌 Commit bea6b93 has been approved by nagisa

@bors

This comment has been minimized.

Contributor

bors commented Nov 3, 2018

☔️ The latest upstream changes (presumably #55238) made this pull request unmergeable. Please resolve the merge conflicts.

@nikic nikic force-pushed the nikic:memcpy-align branch from bea6b93 to a470395 Nov 3, 2018

@estebank

This comment has been minimized.

Contributor

estebank commented Nov 3, 2018

@estebank

This comment has been minimized.

Contributor

estebank commented Nov 3, 2018

r? @nagisa

@rust-highfive rust-highfive assigned nagisa and unassigned alexcrichton Nov 3, 2018

@nagisa

This comment has been minimized.

Contributor

nagisa commented Nov 3, 2018

@bors r+

@bors

This comment has been minimized.

Contributor

bors commented Nov 3, 2018

📌 Commit a470395 has been approved by nagisa

@bors

This comment has been minimized.

Contributor

bors commented Nov 4, 2018

☔️ The latest upstream changes (presumably #55349) made this pull request unmergeable. Please resolve the merge conflicts.

Support memcpy/memmove with differing src/dst alignment
If LLVM 7 is used, generate memcpy/memmove with differing
src/dst alignment. I've added new FFI functions to construct
these through the builder API, which is more convenient than
dealing with differing intrinsic signatures depending on the
LLVM version.

@nikic nikic force-pushed the nikic:memcpy-align branch from a470395 to 463ad90 Nov 4, 2018

@nikic

This comment has been minimized.

Contributor

nikic commented Nov 4, 2018

Rebased

@nagisa

This comment has been minimized.

Contributor

nagisa commented Nov 4, 2018

@bors r+

@bors

This comment has been minimized.

Contributor

bors commented Nov 4, 2018

📌 Commit 463ad90 has been approved by nagisa

@bors

This comment has been minimized.

Contributor

bors commented Nov 8, 2018

⌛️ Testing commit 463ad90 with merge 3cb9d37...

bors added a commit that referenced this pull request Nov 8, 2018

Auto merge of #55633 - nikic:memcpy-align, r=nagisa
Support memcpy/memmove with differing src/dst alignment

If LLVM 7 is used, generate memcpy/memmove with differing src/dst alignment. I've added new FFI functions to construct these through the builder API, which is more convenient than dealing with differing intrinsic signatures depending on the LLVM version.

Fixes #49740.
@bors

This comment has been minimized.

Contributor

bors commented Nov 8, 2018

💔 Test failed - status-appveyor

@nikic

This comment has been minimized.

Contributor

nikic commented Nov 8, 2018

Three hour timeout on one job, everything else passed. Probably spurious.

@alexcrichton

This comment has been minimized.

Member

alexcrichton commented Nov 8, 2018

@bors: retry delegate+

@bors

This comment has been minimized.

Contributor

bors commented Nov 8, 2018

✌️ @nikic can now approve this pull request

Mark-Simulacrum added a commit to Mark-Simulacrum/rust that referenced this pull request Nov 9, 2018

Rollup merge of rust-lang#55633 - nikic:memcpy-align, r=nagisa
Support memcpy/memmove with differing src/dst alignment

If LLVM 7 is used, generate memcpy/memmove with differing src/dst alignment. I've added new FFI functions to construct these through the builder API, which is more convenient than dealing with differing intrinsic signatures depending on the LLVM version.

Fixes rust-lang#49740.

bors added a commit that referenced this pull request Nov 9, 2018

Auto merge of #55803 - Mark-Simulacrum:rollup, r=Mark-Simulacrum
Rollup of 17 pull requests

Successful merges:

 - #55576 (Clarify error message for -C opt-level)
 - #55633 (Support memcpy/memmove with differing src/dst alignment)
 - #55638 (Fix ICE in msg_span_from_free_region on ReEmpty)
 - #55659 (rustc: Delete grouping logic from the musl target)
 - #55719 (Sidestep link error from rustfix'ed code by using a *defined* static.)
 - #55736 (Elide anon lifetimes in conflicting impl note)
 - #55739 (Consume optimization fuel from the MIR inliner)
 - #55742 (Avoid panic when matching function call)
 - #55753 (borrow_set: remove a helper function and a clone it uses)
 - #55755 (Improve creation of 3 IndexVecs)
 - #55758 ([regression - rust2018]: unused_mut lint false positives on nightly)
 - #55760 (Remove intermediate font specs)
 - #55761 (mir: remove a hacky recursive helper function)
 - #55774 (wasm32-unknown-emscripten expects the rust_eh_personality symbol)
 - #55777 (Use `Lit` rather than `P<Lit>` in `ast::ExprKind`.)
 - #55783 (Deprecate mpsc channel selection)
 - #55788 (rustc: Request ansi colors if stderr isn't a tty)

Failed merges:

r? @ghost

@bors bors merged commit 463ad90 into rust-lang:master Nov 9, 2018

1 of 2 checks passed

homu Test failed
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment