diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2015-07-20 13:27:38 -0700 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2015-07-21 16:08:11 -0700 |
| commit | c35b2bd226736925961ca6853b2ef29e8094cd90 (patch) | |
| tree | 5fdbd08fb24f5e4ca71dbc92d9cae1c13f988898 /src/rt | |
| parent | 39d4faf989cea236e2e1669ab85d060d1c62cd85 (diff) | |
| download | rust-c35b2bd226736925961ca6853b2ef29e8094cd90.tar.gz rust-c35b2bd226736925961ca6853b2ef29e8094cd90.zip | |
trans: Move rust_try into the compiler
This commit moves the IR files in the distribution, rust_try.ll, rust_try_msvc_64.ll, and rust_try_msvc_32.ll into the compiler from the main distribution. There's a few reasons for this change: * LLVM changes its IR syntax from time to time, so it's very difficult to have these files build across many LLVM versions simultaneously. We'll likely want to retain this ability for quite some time into the future. * The implementation of these files is closely tied to the compiler and runtime itself, so it makes sense to fold it into a location which can do more platform-specific checks for various implementation details (such as MSVC 32 vs 64-bit). * This removes LLVM as a build-time dependency of the standard library. This may end up becoming very useful if we move towards building the standard library with Cargo. In the immediate future, however, this commit should restore compatibility with LLVM 3.5 and 3.6.
Diffstat (limited to 'src/rt')
| -rw-r--r-- | src/rt/rust_try.ll | 54 | ||||
| -rw-r--r-- | src/rt/rust_try_msvc_32.ll | 42 | ||||
| -rw-r--r-- | src/rt/rust_try_msvc_64.ll | 80 |
3 files changed, 0 insertions, 176 deletions
diff --git a/src/rt/rust_try.ll b/src/rt/rust_try.ll deleted file mode 100644 index 8643131d0fb..00000000000 --- a/src/rt/rust_try.ll +++ /dev/null @@ -1,54 +0,0 @@ -; Copyright 2013 The Rust Project Developers. See the COPYRIGHT -; file at the top-level directory of this distribution and at -; http://rust-lang.org/COPYRIGHT. -; -; Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or -; http://www.apache.org/licenses/LICENSE-2.0> or the MIT license -; <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your -; option. This file may not be copied, modified, or distributed -; except according to those terms. - -; Rust's try-catch -; When f(...) returns normally, the return value is null. -; When f(...) throws, the return value is a pointer to the caught exception object. - -; See also: libstd/rt/unwind/mod.rs - -define i8* @rust_try(void (i8*)* %f, i8* %env) - personality i8* bitcast (i32 (...)* @rust_eh_personality_catch to i8*) -{ - - %1 = invoke i8* @rust_try_inner(void (i8*)* %f, i8* %env) - to label %normal - unwind label %catch - -normal: - ret i8* %1 - -catch: - landingpad { i8*, i32 } catch i8* null - ; rust_try_inner's landing pad does not resume unwinds, so execution will - ; never reach here - ret i8* null -} - -define internal i8* @rust_try_inner(void (i8*)* %f, i8* %env) - personality i8* bitcast (i32 (...)* @rust_eh_personality to i8*) -{ - - invoke void %f(i8* %env) - to label %normal - unwind label %catch - -normal: - ret i8* null - -catch: - %1 = landingpad { i8*, i32 } catch i8* null - ; extract and return pointer to the exception object - %2 = extractvalue { i8*, i32 } %1, 0 - ret i8* %2 -} - -declare i32 @rust_eh_personality(...) -declare i32 @rust_eh_personality_catch(...) diff --git a/src/rt/rust_try_msvc_32.ll b/src/rt/rust_try_msvc_32.ll deleted file mode 100644 index bdee53b136e..00000000000 --- a/src/rt/rust_try_msvc_32.ll +++ /dev/null @@ -1,42 +0,0 @@ -; Copyright 2015 The Rust Project Developers. See the COPYRIGHT -; file at the top-level directory of this distribution and at -; http://rust-lang.org/COPYRIGHT. -; -; Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or -; http://www.apache.org/licenses/LICENSE-2.0> or the MIT license -; <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your -; option. This file may not be copied, modified, or distributed -; except according to those terms. - -; For more comments about what's going on here see rust_try_msvc_64.ll. The only -; difference between that and this file is the personality function used as it's -; different for 32-bit MSVC than it is for 64-bit. - -define i8* @rust_try(void (i8*)* %f, i8* %env) - personality i8* bitcast (i32 (...)* @_except_handler3 to i8*) -{ - invoke void %f(i8* %env) - to label %normal - unwind label %catch - -normal: - ret i8* null -catch: - %vals = landingpad { i8*, i32 } - catch i8* bitcast (i32 (i8*, i8*)* @__rust_try_filter to i8*) - %ehptr = extractvalue { i8*, i32 } %vals, 0 - %sel = extractvalue { i8*, i32 } %vals, 1 - %filter_sel = call i32 @llvm.eh.typeid.for(i8* bitcast (i32 (i8*, i8*)* @__rust_try_filter to i8*)) - %is_filter = icmp eq i32 %sel, %filter_sel - br i1 %is_filter, label %catch-return, label %catch-resume - -catch-return: - ret i8* %ehptr - -catch-resume: - resume { i8*, i32 } %vals -} - -declare i32 @_except_handler3(...) -declare i32 @__rust_try_filter(i8*, i8*) -declare i32 @llvm.eh.typeid.for(i8*) readnone nounwind diff --git a/src/rt/rust_try_msvc_64.ll b/src/rt/rust_try_msvc_64.ll deleted file mode 100644 index c38e6081bf2..00000000000 --- a/src/rt/rust_try_msvc_64.ll +++ /dev/null @@ -1,80 +0,0 @@ -; Copyright 2015 The Rust Project Developers. See the COPYRIGHT -; file at the top-level directory of this distribution and at -; http://rust-lang.org/COPYRIGHT. -; -; Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or -; http://www.apache.org/licenses/LICENSE-2.0> or the MIT license -; <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your -; option. This file may not be copied, modified, or distributed -; except according to those terms. - -; 64-bit MSVC's definition of the `rust_try` function. This function can't be -; defined in Rust as it's a "try-catch" block that's not expressible in Rust's -; syntax, so we're using LLVM to produce an object file with the associated -; handler. -; -; To use the correct system implementation details, this file is separate from -; the standard rust_try.ll as we need specifically use the __C_specific_handler -; personality function or otherwise LLVM doesn't emit SEH handling tables. -; There's also a few fiddly bits about SEH right now in LLVM that require us to -; structure this a fairly particular way! -; -; See also: src/libstd/rt/unwind/seh.rs - -define i8* @rust_try(void (i8*)* %f, i8* %env) - personality i8* bitcast (i32 (...)* @__C_specific_handler to i8*) -{ - invoke void %f(i8* %env) - to label %normal - unwind label %catch - -normal: - ret i8* null - -; Here's where most of the magic happens, this is the only landing pad in rust -; tagged with "catch" to indicate that we're catching an exception. The other -; catch handlers in rust_try.ll just catch *all* exceptions, but that's because -; most exceptions are already filtered out by their personality function. -; -; For MSVC we're just using a standard personality function that we can't -; customize, so we need to do the exception filtering ourselves, and this is -; currently performed by the `__rust_try_filter` function. This function, -; specified in the landingpad instruction, will be invoked by Windows SEH -; routines and will return whether the exception in question can be caught (aka -; the Rust runtime is the one that threw the exception). -; -; To get this to compile (currently LLVM segfaults if it's not in this -; particular structure), when the landingpad is executing we test to make sure -; that the ID of the exception being thrown is indeed the one that we were -; expecting. If it's not, we resume the exception, and otherwise we return the -; pointer that we got -; -; Full disclosure: It's not clear to me what this `llvm.eh.typeid` stuff is -; doing *other* then just allowing LLVM to compile this file without -; segfaulting. I would expect the entire landing pad to just be: -; -; %vals = landingpad ... -; %ehptr = extractvalue { i8*, i32 } %vals, 0 -; ret i8* %ehptr -; -; but apparently LLVM chokes on this, so we do the more complicated thing to -; placate it. -catch: - %vals = landingpad { i8*, i32 } - catch i8* bitcast (i32 (i8*, i8*)* @__rust_try_filter to i8*) - %ehptr = extractvalue { i8*, i32 } %vals, 0 - %sel = extractvalue { i8*, i32 } %vals, 1 - %filter_sel = call i32 @llvm.eh.typeid.for(i8* bitcast (i32 (i8*, i8*)* @__rust_try_filter to i8*)) - %is_filter = icmp eq i32 %sel, %filter_sel - br i1 %is_filter, label %catch-return, label %catch-resume - -catch-return: - ret i8* %ehptr - -catch-resume: - resume { i8*, i32 } %vals -} - -declare i32 @__C_specific_handler(...) -declare i32 @__rust_try_filter(i8*, i8*) -declare i32 @llvm.eh.typeid.for(i8*) readnone nounwind |
