summaryrefslogtreecommitdiffstats
path: root/llvm/lib/ExecutionEngine/Interpreter/Interpreter.h
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2014-09-15 19:20:52 +0000
committerBenjamin Kramer <benny.kra@googlemail.com>2014-09-15 19:20:52 +0000
commitfe5a5f6124c68b7da8529ad02fca2a176485dc09 (patch)
tree840ccf630d1a31735fed8ae0ce58919c92e17b1a /llvm/lib/ExecutionEngine/Interpreter/Interpreter.h
parent91f68b43c326ce7b23856b8ebdb15cf59256728e (diff)
downloadbcm5719-llvm-fe5a5f6124c68b7da8529ad02fca2a176485dc09.tar.gz
bcm5719-llvm-fe5a5f6124c68b7da8529ad02fca2a176485dc09.zip
Remove ancient hack that was emulating move semantics with reference counting.
No functionality change. llvm-svn: 217808
Diffstat (limited to 'llvm/lib/ExecutionEngine/Interpreter/Interpreter.h')
-rw-r--r--llvm/lib/ExecutionEngine/Interpreter/Interpreter.h33
1 files changed, 13 insertions, 20 deletions
diff --git a/llvm/lib/ExecutionEngine/Interpreter/Interpreter.h b/llvm/lib/ExecutionEngine/Interpreter/Interpreter.h
index 0b620d1f8d7..8ec6a6513e3 100644
--- a/llvm/lib/ExecutionEngine/Interpreter/Interpreter.h
+++ b/llvm/lib/ExecutionEngine/Interpreter/Interpreter.h
@@ -37,29 +37,22 @@ typedef generic_gep_type_iterator<User::const_op_iterator> gep_type_iterator;
// stack, which causes the dtor to be run, which frees all the alloca'd memory.
//
class AllocaHolder {
- friend class AllocaHolderHandle;
- std::vector<void*> Allocations;
- unsigned RefCnt;
+ std::vector<void *> Allocations;
+
public:
- AllocaHolder() : RefCnt(0) {}
- void add(void *mem) { Allocations.push_back(mem); }
- ~AllocaHolder() {
- for (unsigned i = 0; i < Allocations.size(); ++i)
- free(Allocations[i]);
+ AllocaHolder() {}
+ // Make this type move-only.
+ AllocaHolder(AllocaHolder &&RHS) : Allocations(std::move(RHS.Allocations)) {}
+ AllocaHolder &operator=(AllocaHolder &&RHS) {
+ Allocations = std::move(RHS.Allocations);
}
-};
-// AllocaHolderHandle gives AllocaHolder value semantics so we can stick it into
-// a vector...
-//
-class AllocaHolderHandle {
- AllocaHolder *H;
-public:
- AllocaHolderHandle() : H(new AllocaHolder()) { H->RefCnt++; }
- AllocaHolderHandle(const AllocaHolderHandle &AH) : H(AH.H) { H->RefCnt++; }
- ~AllocaHolderHandle() { if (--H->RefCnt == 0) delete H; }
+ ~AllocaHolder() {
+ for (void *Allocation : Allocations)
+ free(Allocation);
+ }
- void add(void *mem) { H->add(mem); }
+ void add(void *Mem) { Allocations.push_back(Mem); }
};
typedef std::vector<GenericValue> ValuePlaneTy;
@@ -75,7 +68,7 @@ struct ExecutionContext {
std::vector<GenericValue> VarArgs; // Values passed through an ellipsis
CallSite Caller; // Holds the call that called subframes.
// NULL if main func or debugger invoked fn
- AllocaHolderHandle Allocas; // Track memory allocated by alloca
+ AllocaHolder Allocas; // Track memory allocated by alloca
};
// Interpreter - This class represents the entirety of the interpreter.
OpenPOWER on IntegriCloud