forked from OSchip/llvm-project
GlobalISel: clear vreg mapping after translating each function
Otherwise we only materialize (shared) constants in the first function they appear in. This doesn't go well. llvm-svn: 278351
This commit is contained in:
parent
26f9e9ebc3
commit
0d51044b69
|
@ -252,7 +252,7 @@ private:
|
|||
// at the proper place. E.g., Entry block or dominator block
|
||||
// of each constant depending on how fancy we want to be.
|
||||
// * Clear the different maps.
|
||||
void finalize();
|
||||
void finalizeFunction();
|
||||
|
||||
/// Get the VReg that represents \p Val.
|
||||
/// If such VReg does not exist, it is created.
|
||||
|
|
|
@ -311,7 +311,9 @@ bool IRTranslator::translate(const Constant &C, unsigned Reg) {
|
|||
}
|
||||
|
||||
|
||||
void IRTranslator::finalize() {
|
||||
void IRTranslator::finalizeFunction() {
|
||||
finishPendingPhis();
|
||||
|
||||
// Release the memory used by the different maps we
|
||||
// needed during the translation.
|
||||
ValToVReg.clear();
|
||||
|
@ -362,7 +364,7 @@ bool IRTranslator::runOnMachineFunction(MachineFunction &MF) {
|
|||
}
|
||||
}
|
||||
|
||||
finishPendingPhis();
|
||||
finalizeFunction();
|
||||
|
||||
// Now that the MachineFrameInfo has been configured, no further changes to
|
||||
// the reserved registers are possible.
|
||||
|
|
|
@ -397,3 +397,12 @@ define i32 @test_undef() {
|
|||
define i8* @test_constant_inttoptr() {
|
||||
ret i8* inttoptr(i64 1 to i8*)
|
||||
}
|
||||
|
||||
; This failed purely because the Constant -> VReg map was kept across
|
||||
; functions, so reuse the "i64 1" from above.
|
||||
; CHECK-LABEL: name: test_reused_constant
|
||||
; CHECK: [[ONE:%[0-9]+]](64) = G_CONSTANT s64 1
|
||||
; CHECK: %x0 = COPY [[ONE]]
|
||||
define i64 @test_reused_constant() {
|
||||
ret i64 1
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue