Commit 0b650c38 authored by Kevin Modzelewski's avatar Kevin Modzelewski

Merge pull request #305 from undingen/dup_guards

Don't emit duplicate attr guards
parents a3a12bb6 6509deb8
...@@ -174,6 +174,8 @@ void Rewriter::_addGuardNotEq(RewriterVar* var, uint64_t val) { ...@@ -174,6 +174,8 @@ void Rewriter::_addGuardNotEq(RewriterVar* var, uint64_t val) {
} }
void RewriterVar::addAttrGuard(int offset, uint64_t val, bool negate) { void RewriterVar::addAttrGuard(int offset, uint64_t val, bool negate) {
if (!attr_guards.insert(std::make_tuple(offset, val, negate)).second)
return; // duplicate guard detected
rewriter->addAction([=]() { rewriter->_addAttrGuard(this, offset, val, negate); }, { this }, ActionType::GUARD); rewriter->addAction([=]() { rewriter->_addAttrGuard(this, offset, val, negate); }, { this }, ActionType::GUARD);
} }
......
...@@ -17,6 +17,9 @@ ...@@ -17,6 +17,9 @@
#include <map> #include <map>
#include <memory> #include <memory>
#include <tuple>
#include "llvm/ADT/SmallSet.h"
#include "asm_writing/assembler.h" #include "asm_writing/assembler.h"
#include "asm_writing/icinfo.h" #include "asm_writing/icinfo.h"
...@@ -248,6 +251,8 @@ private: ...@@ -248,6 +251,8 @@ private:
bool is_arg; bool is_arg;
Location arg_loc; Location arg_loc;
llvm::SmallSet<std::tuple<int, uint64_t, bool>, 4> attr_guards; // used to detect duplicate guards
// Gets a copy of this variable in a register, spilling/reloading if necessary. // Gets a copy of this variable in a register, spilling/reloading if necessary.
// TODO have to be careful with the result since the interface doesn't guarantee // TODO have to be careful with the result since the interface doesn't guarantee
// that the register will still contain your value when you go to use it // that the register will still contain your value when you go to use it
......
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