diff options
| author | Vikram S. Adve <vadve@cs.uiuc.edu> | 2003-05-31 07:41:24 +0000 |
|---|---|---|
| committer | Vikram S. Adve <vadve@cs.uiuc.edu> | 2003-05-31 07:41:24 +0000 |
| commit | ad83684c770ac40109c78efb7136d984c604b2b2 (patch) | |
| tree | f276032fef297b778aa2c91d9c4c4210a85d5d86 /llvm/lib/CodeGen | |
| parent | c4688821556f607c544018e24d3b44bb0c8eeeba (diff) | |
| download | bcm5719-llvm-ad83684c770ac40109c78efb7136d984c604b2b2.tar.gz bcm5719-llvm-ad83684c770ac40109c78efb7136d984c604b2b2.zip | |
Added MachineCodeForInstruction object as an argument to
TmpInstruction constructors because every TmpInstruction object has
to be registered with a MachineCodeForInstruction to prevent leaks.
This simplifies the user's code.
llvm-svn: 6469
Diffstat (limited to 'llvm/lib/CodeGen')
| -rw-r--r-- | llvm/lib/CodeGen/InstrSelection/InstrSelection.cpp | 16 | ||||
| -rw-r--r-- | llvm/lib/CodeGen/InstrSelection/InstrSelectionSupport.cpp | 3 |
2 files changed, 13 insertions, 6 deletions
diff --git a/llvm/lib/CodeGen/InstrSelection/InstrSelection.cpp b/llvm/lib/CodeGen/InstrSelection/InstrSelection.cpp index 5e0fb8ec725..e4dd2e9dace 100644 --- a/llvm/lib/CodeGen/InstrSelection/InstrSelection.cpp +++ b/llvm/lib/CodeGen/InstrSelection/InstrSelection.cpp @@ -78,8 +78,12 @@ namespace { static RegisterLLC<InstructionSelection> X("instselect", "Instruction Selection", createInstructionSelectionPass); -TmpInstruction::TmpInstruction(Value *s1, Value *s2, const std::string &name) - : Instruction(s1->getType(), Instruction::UserOp1, name) { +TmpInstruction::TmpInstruction(MachineCodeForInstruction& mcfi, + Value *s1, Value *s2, const std::string &name) + : Instruction(s1->getType(), Instruction::UserOp1, name) +{ + mcfi.addTemp(this); + Operands.push_back(Use(s1, this)); // s1 must be nonnull if (s2) { Operands.push_back(Use(s2, this)); @@ -91,9 +95,13 @@ TmpInstruction::TmpInstruction(Value *s1, Value *s2, const std::string &name) // Constructor that requires the type of the temporary to be specified. // Both S1 and S2 may be NULL.( -TmpInstruction::TmpInstruction(const Type *Ty, Value *s1, Value* s2, +TmpInstruction::TmpInstruction(MachineCodeForInstruction& mcfi, + const Type *Ty, Value *s1, Value* s2, const std::string &name) - : Instruction(Ty, Instruction::UserOp1, name) { + : Instruction(Ty, Instruction::UserOp1, name) +{ + mcfi.addTemp(this); + if (s1) { Operands.push_back(Use(s1, this)); } if (s2) { Operands.push_back(Use(s2, this)); } diff --git a/llvm/lib/CodeGen/InstrSelection/InstrSelectionSupport.cpp b/llvm/lib/CodeGen/InstrSelection/InstrSelectionSupport.cpp index a5a3662e937..268fb3d877c 100644 --- a/llvm/lib/CodeGen/InstrSelection/InstrSelectionSupport.cpp +++ b/llvm/lib/CodeGen/InstrSelection/InstrSelectionSupport.cpp @@ -33,9 +33,8 @@ InsertCodeToLoadConstant(Function *F, TargetMachine& target) { // Create a tmp virtual register to hold the constant. - TmpInstruction* tmpReg = new TmpInstruction(opValue); MachineCodeForInstruction &mcfi = MachineCodeForInstruction::get(vmInstr); - mcfi.addTemp(tmpReg); + TmpInstruction* tmpReg = new TmpInstruction(mcfi, opValue); target.getInstrInfo().CreateCodeToLoadConst(target, F, opValue, tmpReg, loadConstVec, mcfi); |

