[llvm] r278351 - GlobalISel: clear vreg mapping after translating each function
Tim Northover via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 11 09:21:29 PDT 2016
Author: tnorthover
Date: Thu Aug 11 11:21:29 2016
New Revision: 278351
URL: http://llvm.org/viewvc/llvm-project?rev=278351&view=rev
Log:
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.
Modified:
llvm/trunk/include/llvm/CodeGen/GlobalISel/IRTranslator.h
llvm/trunk/lib/CodeGen/GlobalISel/IRTranslator.cpp
llvm/trunk/test/CodeGen/AArch64/GlobalISel/arm64-irtranslator.ll
Modified: llvm/trunk/include/llvm/CodeGen/GlobalISel/IRTranslator.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/GlobalISel/IRTranslator.h?rev=278351&r1=278350&r2=278351&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/GlobalISel/IRTranslator.h (original)
+++ llvm/trunk/include/llvm/CodeGen/GlobalISel/IRTranslator.h Thu Aug 11 11:21:29 2016
@@ -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.
Modified: llvm/trunk/lib/CodeGen/GlobalISel/IRTranslator.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/GlobalISel/IRTranslator.cpp?rev=278351&r1=278350&r2=278351&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/GlobalISel/IRTranslator.cpp (original)
+++ llvm/trunk/lib/CodeGen/GlobalISel/IRTranslator.cpp Thu Aug 11 11:21:29 2016
@@ -311,7 +311,9 @@ bool IRTranslator::translate(const Const
}
-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(
}
}
- finishPendingPhis();
+ finalizeFunction();
// Now that the MachineFrameInfo has been configured, no further changes to
// the reserved registers are possible.
Modified: llvm/trunk/test/CodeGen/AArch64/GlobalISel/arm64-irtranslator.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/AArch64/GlobalISel/arm64-irtranslator.ll?rev=278351&r1=278350&r2=278351&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/AArch64/GlobalISel/arm64-irtranslator.ll (original)
+++ llvm/trunk/test/CodeGen/AArch64/GlobalISel/arm64-irtranslator.ll Thu Aug 11 11:21:29 2016
@@ -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
+}
More information about the llvm-commits
mailing list