Index: src/IceOperand.cpp |
diff --git a/src/IceOperand.cpp b/src/IceOperand.cpp |
index bf5546f1517099073ba3fa2f270b221edbd10d9c..8d0ffed074d35a7a73318470da2e936d9c3bfce9 100644 |
--- a/src/IceOperand.cpp |
+++ b/src/IceOperand.cpp |
@@ -126,13 +126,16 @@ IceString Variable::getName(const Cfg *Func) const { |
return "__" + std::to_string(getIndex()); |
} |
-Variable Variable::asType(Type Ty) { |
+Variable *Variable::asType(Type Ty) { |
// Note: This returns a Variable, even if the "this" object is a |
// subclass of Variable. |
- Variable V(kVariable, Ty, Number); |
- V.NameIndex = NameIndex; |
- V.RegNum = RegNum; |
- V.StackOffset = StackOffset; |
+ if (!ALLOW_DUMP || getType() == Ty) |
+ return this; |
+ Variable *V = new (getCurrentCfgAllocator()->Allocate<Variable>()) |
+ Variable(kVariable, Ty, Number); |
+ V->NameIndex = NameIndex; |
+ V->RegNum = RegNum; |
+ V->StackOffset = StackOffset; |
return V; |
} |