diff options
| author | bors <bors@rust-lang.org> | 2014-06-22 00:01:34 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2014-06-22 00:01:34 +0000 |
| commit | 4c39962d325c09849e9cbb1828f85028f29fcea3 (patch) | |
| tree | 00465a2053409f3dee73d6daaf16e586cdd5fd46 /src/rustllvm/RustWrapper.cpp | |
| parent | db9af1d505809c965e719bf4ad775ff984ee3da6 (diff) | |
| parent | d747de5a927e405c7d12ae04d213bdc05add2032 (diff) | |
| download | rust-4c39962d325c09849e9cbb1828f85028f29fcea3.tar.gz rust-4c39962d325c09849e9cbb1828f85028f29fcea3.zip | |
auto merge of #15005 : dotdash/rust/i1_bool, r=alexcrichton
We currently compiled bools to i8 values, because there was a bug in LLVM that sometimes caused miscompilations when using i1 in, for example, structs. Using i8 means a lot of unnecessary zero-extend and truncate operations though, since we have to convert the value from and to i1 when using for example icmp or br instructions. Besides the unnecessary overhead caused by this, it also sometimes made LLVM miss some optimizations. First, we have to fix some bugs concerning the handling of attributes in foreign function declarations and calls. These are required because the i1 type needs the ZExt attribute when used as a function parameter or return type. Then we have to update LLVM to get a bugfix without which LLVM sometimes generates broken code when using i1. And then, finally, we can switch bools over to i1.
Diffstat (limited to 'src/rustllvm/RustWrapper.cpp')
| -rw-r--r-- | src/rustllvm/RustWrapper.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/rustllvm/RustWrapper.cpp b/src/rustllvm/RustWrapper.cpp index f42844b9f19..a1a88d1b14d 100644 --- a/src/rustllvm/RustWrapper.cpp +++ b/src/rustllvm/RustWrapper.cpp @@ -659,7 +659,7 @@ LLVMRustLinkInExternalBitcode(LLVMModuleRef dst, char *bc, size_t len) { extern "C" void* LLVMRustOpenArchive(char *path) { std::unique_ptr<MemoryBuffer> buf; - error_code err = MemoryBuffer::getFile(path, buf); + std::error_code err = MemoryBuffer::getFile(path, buf); if (err) { LLVMRustSetLastError(err.message().c_str()); return NULL; @@ -694,14 +694,18 @@ LLVMRustArchiveReadSection(Archive *ar, char *name, size_t *size) { #if LLVM_VERSION_MINOR >= 5 Archive::child_iterator child = ar->child_begin(), end = ar->child_end(); + for (; child != end; ++child) { + ErrorOr<StringRef> name_or_err = child->getName(); + if (name_or_err.getError()) continue; + StringRef sect_name = name_or_err.get(); #else Archive::child_iterator child = ar->begin_children(), end = ar->end_children(); -#endif for (; child != end; ++child) { StringRef sect_name; error_code err = child->getName(sect_name); if (err) continue; +#endif if (sect_name.trim(" ") == name) { StringRef buf = child->getBuffer(); *size = buf.size(); @@ -757,7 +761,11 @@ inline section_iterator *unwrap(LLVMSectionIteratorRef SI) { extern "C" int LLVMRustGetSectionName(LLVMSectionIteratorRef SI, const char **ptr) { StringRef ret; +#if LLVM_VERSION_MINOR >= 5 + if (std::error_code ec = (*unwrap(SI))->getName(ret)) +#else if (error_code ec = (*unwrap(SI))->getName(ret)) +#endif report_fatal_error(ec.message()); *ptr = ret.data(); return ret.size(); |
