Commit fa406448 authored by Kevin Modzelewski's avatar Kevin Modzelewski

Merge pull request #1020 from kmod/clang3.7

clang-3.7 support
parents 99c951f5 169c9a65
From fda9fd463dae38840cc02c5ae668cb1097395b9a Mon Sep 17 00:00:00 2001
From: Benjamin Kramer <benny.kra@googlemail.com>
Date: Fri, 1 May 2015 15:16:11 +0000
Subject: [PATCH] Remove std::move on return when it could prevent copy
elision.
Found by -Wpessimizing-move, no functional change. The APFloat and
PassManager change doesn't affect codegen as returning a by-value
argument will always result in a move.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@236316 91177308-0d34-0410-b5e6-96231b3b80d8
---
include/llvm/ADT/APFloat.h | 2 +-
include/llvm/IR/PassManager.h | 4 ++--
utils/yaml-bench/YAMLBench.cpp | 2 +-
3 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/include/llvm/ADT/APFloat.h b/include/llvm/ADT/APFloat.h
index 53b53c5..958e3fd 100644
--- a/include/llvm/ADT/APFloat.h
+++ b/include/llvm/ADT/APFloat.h
@@ -343,7 +343,7 @@ class APFloat {
/// copied from some other APFloat.
static APFloat copySign(APFloat Value, const APFloat &Sign) {
Value.copySign(Sign);
- return std::move(Value);
+ return Value;
}
/// @}
diff --git a/include/llvm/IR/PassManager.h b/include/llvm/IR/PassManager.h
index 3c24e72..b566f01 100644
--- a/include/llvm/IR/PassManager.h
+++ b/include/llvm/IR/PassManager.h
@@ -509,7 +509,7 @@ class AnalysisManager
PreservedAnalyses invalidateImpl(IRUnitT &IR, PreservedAnalyses PA) {
// Short circuit for a common case of all analyses being preserved.
if (PA.areAllPreserved())
- return std::move(PA);
+ return PA;
if (DebugLogging)
dbgs() << "Invalidating all non-preserved analyses for: "
@@ -549,7 +549,7 @@ class AnalysisManager
if (ResultsList.empty())
AnalysisResultLists.erase(&IR);
- return std::move(PA);
+ return PA;
}
/// \brief List of function analysis pass IDs and associated concept pointers.
diff --git a/utils/yaml-bench/YAMLBench.cpp b/utils/yaml-bench/YAMLBench.cpp
index 872f586..0fb3138 100644
--- a/utils/yaml-bench/YAMLBench.cpp
+++ b/utils/yaml-bench/YAMLBench.cpp
@@ -69,7 +69,7 @@ static std::string prettyTag(yaml::Node *N) {
if (StringRef(Tag).startswith("tag:yaml.org,2002:")) {
std::string Ret = "!!";
Ret += StringRef(Tag).substr(18);
- return std::move(Ret);
+ return Ret;
}
std::string Ret = "!<";
Ret += Tag;
......@@ -80,7 +80,7 @@ void Assembler::emitArith(Immediate imm, Register r, int opcode) {
// assert(r != RSP && "This breaks unwinding, please don't use.");
int64_t amount = imm.val;
RELEASE_ASSERT((-1L << 31) <= amount && amount < (1L << 31) - 1, "");
RELEASE_ASSERT(fitsInto<int32_t>(amount), "");
assert(0 <= opcode && opcode < 8);
int rex = REX_W;
......@@ -183,7 +183,7 @@ void Assembler::mov(Immediate val, Register dest, bool force_64bit_load) {
void Assembler::movq(Immediate src, Indirect dest) {
int64_t src_val = src.val;
assert((-1L << 31) <= src_val && src_val < (1L << 31) - 1);
assert(fitsInto<int32_t>(src_val));
int rex = REX_W;
......@@ -739,7 +739,7 @@ void Assembler::cmp(Register reg, Immediate imm) {
void Assembler::cmp(Indirect mem, Immediate imm) {
int64_t val = imm.val;
assert((-1L << 31) <= val && val < (1L << 31) - 1);
assert(fitsInto<int32_t>(val));
int src_idx = mem.base.regnum;
......@@ -760,7 +760,7 @@ void Assembler::cmp(Indirect mem, Immediate imm) {
emitModRM(0b01, 7, src_idx);
emitByte(mem.offset);
} else {
assert((-1L << 31) <= mem.offset && mem.offset < (1L << 31) - 1);
assert(fitsInto<int32_t>(mem.offset));
emitModRM(0b10, 7, src_idx);
emitInt(mem.offset, 4);
}
......@@ -794,7 +794,7 @@ void Assembler::cmp(Indirect mem, Register reg) {
emitModRM(0b01, reg_idx, mem_idx);
emitByte(mem.offset);
} else {
assert((-1L << 31) <= mem.offset && mem.offset < (1L << 31) - 1);
assert(fitsInto<int32_t>(mem.offset));
emitModRM(0b10, reg_idx, mem_idx);
emitInt(mem.offset, 4);
}
......@@ -830,7 +830,7 @@ void Assembler::lea(Indirect mem, Register reg) {
if (mode == 0b01) {
emitByte(mem.offset);
} else if (mode == 0b10) {
assert((-1L << 31) <= mem.offset && mem.offset < (1L << 31) - 1);
assert(fitsInto<int32_t>(mem.offset));
emitInt(mem.offset, 4);
}
}
......@@ -910,7 +910,7 @@ void Assembler::jmp(Indirect dest) {
emitModRM(0b01, 0b100, reg_idx);
emitByte(dest.offset);
} else {
assert((-1L << 31) <= dest.offset && dest.offset < (1L << 31) - 1);
assert(fitsInto<int32_t>(dest.offset));
emitModRM(0b10, 0b100, reg_idx);
emitInt(dest.offset, 4);
}
......
......@@ -600,7 +600,7 @@ public:
static Rewriter* createRewriter(void* rtn_addr, int num_args, const char* debug_name);
static bool isLargeConstant(int64_t val) { return (val < (-1L << 31) || val >= (1L << 31) - 1); }
static bool isLargeConstant(int64_t val) { return !fitsInto<int32_t>(val); }
// The "aggressiveness" with which we should try to do this rewrite. It starts high, and decreases over time.
// The values are nominally in the range 0-100, with 0 being no aggressiveness and 100 being fully aggressive,
......
......@@ -172,9 +172,7 @@ struct JumpDestination {
int offset;
JumpDestination(OffsetType type, int64_t offset) : type(type), offset(offset) {
assert((-1L << 31) <= offset && offset < (1L << 31) - 1);
}
JumpDestination(OffsetType type, int64_t offset) : type(type), offset(offset) { assert(fitsInto<int32_t>(offset)); }
static JumpDestination fromStart(int offset) { return JumpDestination(FROM_START, offset); }
};
}
......
......@@ -2545,7 +2545,7 @@ public:
for (int i = 0; i < orig_elts.size(); i++) {
elts.push_back(orig_elts[i]->dup(cache));
}
return std::move(elts);
return elts;
}
ConcreteCompilerVariable* _makeConverted(IREmitter& emitter, const VEC& v, ConcreteCompilerType* other_type) {
......
......@@ -1200,7 +1200,7 @@ static std::vector<char> _reparse(const char* fn, const std::string& cache_fn, A
fwrite(&checksum, 1, CHECKSUM_LENGTH, cache_fp);
memcpy(&file_data[checksum_start + LENGTH_LENGTH], &checksum, CHECKSUM_LENGTH);
return std::move(file_data);
return file_data;
}
// Parsing the file is somewhat expensive since we have to shell out to cpython;
......
......@@ -19,6 +19,7 @@
#include <csignal>
#include <cstdio>
#include <cstdlib>
#include <limits>
#include <stdint.h>
#include <string>
#include <unordered_map>
......@@ -82,4 +83,11 @@ template <typename T1, typename T2, typename T3> struct hash<tuple<T1, T2, T3>>
};
}
namespace pyston {
template <typename T>
constexpr bool fitsInto(int64_t x) {
return std::numeric_limits<T>::min() <= x && x <= std::numeric_limits<T>::max();
}
}
#endif
......@@ -212,6 +212,12 @@ public:
template <typename T> class UniqueScanningHandle {
T* obj = NULL;
// Compiler bug workaround:
// clang-3.7 crashes if we do 'delete obj' in the places that are now 'do_delete(obj)'.
// Using a wrapper function seems to avoid whatever the weird code path is hat causes the crash.
// https://llvm.org/bugs/show_bug.cgi?id=25700
static void do_delete(T* t) { delete t; }
public:
UniqueScanningHandle(T* obj) : obj(obj) {
#if MOVING_GC
......@@ -227,7 +233,7 @@ public:
threading::popGCObject(obj);
}
#endif
delete obj;
do_delete(obj);
}
T* operator->() { return obj; }
......@@ -238,7 +244,7 @@ public:
threading::popGCObject(obj);
}
#endif
delete obj;
do_delete(obj);
obj = t;
#if MOVING_GC
if (t) {
......
......@@ -92,6 +92,8 @@ if __name__ == "__main__":
continue
if "Expose-getSymbolLoadAddress" in patch_fn and svn_rev <= 222840:
continue
if "Remove-move-warning" in patch_fn and svn_rev >= 236316:
continue
patch_fn = os.path.abspath(os.path.join(patch_dir, patch_fn))
code = subprocess.call(["git", "am", patch_fn], cwd=repo)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment