about summary refs log tree commit diff
path: root/src/rustllvm/RustWrapper.cpp
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2014-07-24 09:51:16 +0000
committerbors <bors@rust-lang.org>2014-07-24 09:51:16 +0000
commite70ee120bf70d5b6195c2b355b9820a8609564cf (patch)
tree8fd7e31dd7d687834797f564818bffb431a0bb9f /src/rustllvm/RustWrapper.cpp
parent02464196eaf56838c16d747e77536cefd14c5238 (diff)
parent0d6f2576573534215fc3a6cb96a3fd5d5e813cf7 (diff)
downloadrust-e70ee120bf70d5b6195c2b355b9820a8609564cf.tar.gz
rust-e70ee120bf70d5b6195c2b355b9820a8609564cf.zip
auto merge of #15921 : dotdash/rust/match_lifetimes, r=pcwalton
The allocas used in match expression currently don't get good lifetime
markers, in fact they only get lifetime start markers, because their
lifetimes don't match to cleanup scopes.

While the bindings themselves are bog standard and just need a matching
pair of start and end markers, they might need them twice, once for a
guard clause and once for the match body.

The __llmatch alloca OTOH needs a single lifetime start marker, but
when there's a guard clause, it needs two end markers, because its
lifetime ends either when the guard doesn't match or after the match
body.

With these intrinsics in place, LLVM can now, for example, optimize
code like this:

````rust
enum E {
  A1(int),
  A2(int),
  A3(int),
  A4(int),
}

pub fn variants(x: E) {
  match x {
    A1(m) => bar(&m),
    A2(m) => bar(&m),
    A3(m) => bar(&m),
    A4(m) => bar(&m),
  }
}
````

To a single call to bar, using only a single stack slot. It still fails
to eliminate some of checks.

````gas
.Ltmp5:
	.cfi_def_cfa_offset 16
	movb	(%rdi), %al
	testb	%al, %al
	je	.LBB3_5
	movzbl	%al, %eax
	cmpl	$1, %eax
	je	.LBB3_5
	cmpl	$2, %eax
.LBB3_5:
	movq	8(%rdi), %rax
	movq	%rax, (%rsp)
	leaq	(%rsp), %rdi
	callq	_ZN3bar20hcb7a0d8be8e17e37daaE@PLT
	popq	%rax
	retq
````

Refs #15665
Diffstat (limited to 'src/rustllvm/RustWrapper.cpp')
0 files changed, 0 insertions, 0 deletions