2016-05-03 01:05:48 +02:00
|
|
|
#include "llvm/ADT/STLExtras.h"
|
2017-12-13 03:51:04 +01:00
|
|
|
#include "llvm/CodeGen/LiveIntervals.h"
|
2016-05-03 01:05:48 +02:00
|
|
|
#include "llvm/CodeGen/MIRParser/MIRParser.h"
|
|
|
|
#include "llvm/CodeGen/MachineFunction.h"
|
2016-05-10 05:03:55 +02:00
|
|
|
#include "llvm/CodeGen/MachineModuleInfo.h"
|
2017-11-17 02:07:10 +01:00
|
|
|
#include "llvm/CodeGen/TargetRegisterInfo.h"
|
2017-06-06 13:06:56 +02:00
|
|
|
#include "llvm/IR/LegacyPassManager.h"
|
2016-05-03 01:05:48 +02:00
|
|
|
#include "llvm/Support/MemoryBuffer.h"
|
|
|
|
#include "llvm/Support/SourceMgr.h"
|
|
|
|
#include "llvm/Support/TargetRegistry.h"
|
|
|
|
#include "llvm/Support/TargetSelect.h"
|
|
|
|
#include "llvm/Target/TargetMachine.h"
|
|
|
|
#include "llvm/Target/TargetOptions.h"
|
2017-06-06 13:06:56 +02:00
|
|
|
#include "gtest/gtest.h"
|
2016-02-18 08:37:17 +01:00
|
|
|
|
2016-05-03 01:05:48 +02:00
|
|
|
using namespace llvm;
|
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
void initializeTestPassPass(PassRegistry &);
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
void initLLVM() {
|
|
|
|
InitializeAllTargets();
|
|
|
|
InitializeAllTargetMCs();
|
|
|
|
InitializeAllAsmPrinters();
|
|
|
|
InitializeAllAsmParsers();
|
|
|
|
|
|
|
|
PassRegistry *Registry = PassRegistry::getPassRegistry();
|
|
|
|
initializeCore(*Registry);
|
|
|
|
initializeCodeGen(*Registry);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Create a TargetMachine. As we lack a dedicated always available target for
|
2016-07-26 05:57:45 +02:00
|
|
|
/// unittests, we go for "AMDGPU" to be able to test normal and subregister
|
|
|
|
/// liveranges.
|
2018-11-06 00:49:13 +01:00
|
|
|
std::unique_ptr<LLVMTargetMachine> createTargetMachine() {
|
2016-07-26 05:57:45 +02:00
|
|
|
Triple TargetTriple("amdgcn--");
|
2016-05-03 01:05:48 +02:00
|
|
|
std::string Error;
|
|
|
|
const Target *T = TargetRegistry::lookupTarget("", TargetTriple, Error);
|
|
|
|
if (!T)
|
|
|
|
return nullptr;
|
|
|
|
|
|
|
|
TargetOptions Options;
|
2018-11-06 00:49:13 +01:00
|
|
|
return std::unique_ptr<LLVMTargetMachine>(static_cast<LLVMTargetMachine*>(
|
|
|
|
T->createTargetMachine("AMDGPU", "", "", Options, None, None,
|
|
|
|
CodeGenOpt::Aggressive)));
|
2016-05-03 01:05:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
std::unique_ptr<Module> parseMIR(LLVMContext &Context,
|
|
|
|
legacy::PassManagerBase &PM, std::unique_ptr<MIRParser> &MIR,
|
2018-11-06 00:49:13 +01:00
|
|
|
const LLVMTargetMachine &TM, StringRef MIRCode, const char *FuncName) {
|
2016-05-03 01:05:48 +02:00
|
|
|
SMDiagnostic Diagnostic;
|
|
|
|
std::unique_ptr<MemoryBuffer> MBuffer = MemoryBuffer::getMemBuffer(MIRCode);
|
|
|
|
MIR = createMIRParser(std::move(MBuffer), Context);
|
|
|
|
if (!MIR)
|
|
|
|
return nullptr;
|
|
|
|
|
2017-06-06 02:44:35 +02:00
|
|
|
std::unique_ptr<Module> M = MIR->parseIRModule();
|
2016-05-03 01:05:48 +02:00
|
|
|
if (!M)
|
|
|
|
return nullptr;
|
|
|
|
|
|
|
|
M->setDataLayout(TM.createDataLayout());
|
|
|
|
|
2016-08-24 03:52:46 +02:00
|
|
|
MachineModuleInfo *MMI = new MachineModuleInfo(&TM);
|
2017-06-06 02:44:35 +02:00
|
|
|
if (MIR->parseMachineFunctions(*M, *MMI))
|
|
|
|
return nullptr;
|
2016-08-24 03:52:46 +02:00
|
|
|
PM.add(MMI);
|
2016-05-03 01:05:48 +02:00
|
|
|
|
|
|
|
return M;
|
|
|
|
}
|
|
|
|
|
|
|
|
typedef std::function<void(MachineFunction&,LiveIntervals&)> LiveIntervalTest;
|
|
|
|
|
|
|
|
struct TestPass : public MachineFunctionPass {
|
|
|
|
static char ID;
|
|
|
|
TestPass() : MachineFunctionPass(ID) {
|
|
|
|
// We should never call this but always use PM.add(new TestPass(...))
|
|
|
|
abort();
|
|
|
|
}
|
|
|
|
TestPass(LiveIntervalTest T) : MachineFunctionPass(ID), T(T) {
|
|
|
|
initializeTestPassPass(*PassRegistry::getPassRegistry());
|
|
|
|
}
|
|
|
|
|
|
|
|
bool runOnMachineFunction(MachineFunction &MF) override {
|
|
|
|
LiveIntervals &LIS = getAnalysis<LiveIntervals>();
|
|
|
|
T(MF, LIS);
|
|
|
|
EXPECT_TRUE(MF.verify(this));
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void getAnalysisUsage(AnalysisUsage &AU) const override {
|
|
|
|
AU.setPreservesAll();
|
|
|
|
AU.addRequired<LiveIntervals>();
|
|
|
|
AU.addPreserved<LiveIntervals>();
|
|
|
|
MachineFunctionPass::getAnalysisUsage(AU);
|
|
|
|
}
|
|
|
|
private:
|
|
|
|
LiveIntervalTest T;
|
|
|
|
};
|
|
|
|
|
2016-07-26 05:57:45 +02:00
|
|
|
static MachineInstr &getMI(MachineFunction &MF, unsigned At,
|
|
|
|
unsigned BlockNum) {
|
2016-05-24 23:54:01 +02:00
|
|
|
MachineBasicBlock &MBB = *MF.getBlockNumbered(BlockNum);
|
2016-05-03 01:05:48 +02:00
|
|
|
|
|
|
|
unsigned I = 0;
|
|
|
|
for (MachineInstr &MI : MBB) {
|
2016-07-26 05:57:45 +02:00
|
|
|
if (I == At)
|
|
|
|
return MI;
|
2016-05-03 01:05:48 +02:00
|
|
|
++I;
|
|
|
|
}
|
2016-07-26 05:57:45 +02:00
|
|
|
llvm_unreachable("Instruction not found");
|
|
|
|
}
|
2016-05-03 01:05:48 +02:00
|
|
|
|
2016-07-26 05:57:45 +02:00
|
|
|
/**
|
|
|
|
* Move instruction number \p From in front of instruction number \p To and
|
|
|
|
* update affected liveness intervals with LiveIntervalAnalysis::handleMove().
|
|
|
|
*/
|
|
|
|
static void testHandleMove(MachineFunction &MF, LiveIntervals &LIS,
|
|
|
|
unsigned From, unsigned To, unsigned BlockNum = 0) {
|
|
|
|
MachineInstr &FromInstr = getMI(MF, From, BlockNum);
|
|
|
|
MachineInstr &ToInstr = getMI(MF, To, BlockNum);
|
|
|
|
|
|
|
|
MachineBasicBlock &MBB = *FromInstr.getParent();
|
|
|
|
MBB.splice(ToInstr.getIterator(), &MBB, FromInstr.getIterator());
|
|
|
|
LIS.handleMove(FromInstr, true);
|
2016-05-03 01:05:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void liveIntervalTest(StringRef MIRFunc, LiveIntervalTest T) {
|
|
|
|
LLVMContext Context;
|
2018-11-06 00:49:13 +01:00
|
|
|
std::unique_ptr<LLVMTargetMachine> TM = createTargetMachine();
|
2016-05-03 01:05:48 +02:00
|
|
|
// This test is designed for the X86 backend; stop if it is not available.
|
|
|
|
if (!TM)
|
|
|
|
return;
|
|
|
|
|
|
|
|
legacy::PassManager PM;
|
|
|
|
|
|
|
|
SmallString<160> S;
|
2017-02-23 02:09:01 +01:00
|
|
|
StringRef MIRString = (Twine(R"MIR(
|
|
|
|
---
|
|
|
|
...
|
|
|
|
name: func
|
|
|
|
registers:
|
|
|
|
- { id: 0, class: sreg_64 }
|
|
|
|
body: |
|
|
|
|
bb.0:
|
|
|
|
)MIR") + Twine(MIRFunc) + Twine("...\n")).toNullTerminatedStringRef(S);
|
2016-05-03 01:05:48 +02:00
|
|
|
std::unique_ptr<MIRParser> MIR;
|
|
|
|
std::unique_ptr<Module> M = parseMIR(Context, PM, MIR, *TM, MIRString,
|
|
|
|
"func");
|
2017-06-16 00:50:57 +02:00
|
|
|
ASSERT_TRUE(M);
|
2016-05-03 01:05:48 +02:00
|
|
|
|
|
|
|
PM.add(new TestPass(T));
|
|
|
|
|
|
|
|
PM.run(*M);
|
|
|
|
}
|
|
|
|
|
|
|
|
} // End of anonymous namespace.
|
|
|
|
|
|
|
|
char TestPass::ID = 0;
|
|
|
|
INITIALIZE_PASS(TestPass, "testpass", "testpass", false, false)
|
|
|
|
|
|
|
|
TEST(LiveIntervalTest, MoveUpDef) {
|
|
|
|
// Value defined.
|
2017-02-23 02:09:01 +01:00
|
|
|
liveIntervalTest(R"MIR(
|
|
|
|
S_NOP 0
|
|
|
|
S_NOP 0
|
|
|
|
early-clobber %0 = IMPLICIT_DEF
|
|
|
|
S_NOP 0, implicit %0
|
|
|
|
)MIR", [](MachineFunction &MF, LiveIntervals &LIS) {
|
2016-05-03 01:05:48 +02:00
|
|
|
testHandleMove(MF, LIS, 2, 1);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(LiveIntervalTest, MoveUpRedef) {
|
2017-02-23 02:09:01 +01:00
|
|
|
liveIntervalTest(R"MIR(
|
|
|
|
%0 = IMPLICIT_DEF
|
|
|
|
S_NOP 0
|
|
|
|
%0 = IMPLICIT_DEF implicit %0(tied-def 0)
|
|
|
|
S_NOP 0, implicit %0
|
|
|
|
)MIR", [](MachineFunction &MF, LiveIntervals &LIS) {
|
2016-05-03 01:05:48 +02:00
|
|
|
testHandleMove(MF, LIS, 2, 1);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(LiveIntervalTest, MoveUpEarlyDef) {
|
2017-02-23 02:09:01 +01:00
|
|
|
liveIntervalTest(R"MIR(
|
|
|
|
S_NOP 0
|
|
|
|
S_NOP 0
|
|
|
|
early-clobber %0 = IMPLICIT_DEF
|
|
|
|
S_NOP 0, implicit %0
|
|
|
|
)MIR", [](MachineFunction &MF, LiveIntervals &LIS) {
|
2016-05-03 01:05:48 +02:00
|
|
|
testHandleMove(MF, LIS, 2, 1);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(LiveIntervalTest, MoveUpEarlyRedef) {
|
2017-02-23 02:09:01 +01:00
|
|
|
liveIntervalTest(R"MIR(
|
|
|
|
%0 = IMPLICIT_DEF
|
|
|
|
S_NOP 0
|
|
|
|
early-clobber %0 = IMPLICIT_DEF implicit %0(tied-def 0)
|
|
|
|
S_NOP 0, implicit %0
|
|
|
|
)MIR", [](MachineFunction &MF, LiveIntervals &LIS) {
|
2016-05-03 01:05:48 +02:00
|
|
|
testHandleMove(MF, LIS, 2, 1);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(LiveIntervalTest, MoveUpKill) {
|
2017-02-23 02:09:01 +01:00
|
|
|
liveIntervalTest(R"MIR(
|
|
|
|
%0 = IMPLICIT_DEF
|
|
|
|
S_NOP 0
|
|
|
|
S_NOP 0, implicit %0
|
|
|
|
)MIR", [](MachineFunction &MF, LiveIntervals &LIS) {
|
2016-05-03 01:05:48 +02:00
|
|
|
testHandleMove(MF, LIS, 2, 1);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(LiveIntervalTest, MoveUpKillFollowing) {
|
2017-02-23 02:09:01 +01:00
|
|
|
liveIntervalTest(R"MIR(
|
|
|
|
%0 = IMPLICIT_DEF
|
|
|
|
S_NOP 0
|
|
|
|
S_NOP 0, implicit %0
|
|
|
|
S_NOP 0, implicit %0
|
|
|
|
)MIR", [](MachineFunction &MF, LiveIntervals &LIS) {
|
2016-05-03 01:05:48 +02:00
|
|
|
testHandleMove(MF, LIS, 2, 1);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO: Construct a situation where we have intervals following a hole
|
|
|
|
// while still having connected components.
|
|
|
|
|
|
|
|
TEST(LiveIntervalTest, MoveDownDef) {
|
|
|
|
// Value defined.
|
2017-02-23 02:09:01 +01:00
|
|
|
liveIntervalTest(R"MIR(
|
|
|
|
S_NOP 0
|
|
|
|
early-clobber %0 = IMPLICIT_DEF
|
|
|
|
S_NOP 0
|
|
|
|
S_NOP 0, implicit %0
|
|
|
|
)MIR", [](MachineFunction &MF, LiveIntervals &LIS) {
|
2016-05-03 01:05:48 +02:00
|
|
|
testHandleMove(MF, LIS, 1, 2);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(LiveIntervalTest, MoveDownRedef) {
|
2017-02-23 02:09:01 +01:00
|
|
|
liveIntervalTest(R"MIR(
|
|
|
|
%0 = IMPLICIT_DEF
|
|
|
|
%0 = IMPLICIT_DEF implicit %0(tied-def 0)
|
|
|
|
S_NOP 0
|
|
|
|
S_NOP 0, implicit %0
|
|
|
|
)MIR", [](MachineFunction &MF, LiveIntervals &LIS) {
|
2016-05-03 01:05:48 +02:00
|
|
|
testHandleMove(MF, LIS, 1, 2);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(LiveIntervalTest, MoveDownEarlyDef) {
|
2017-02-23 02:09:01 +01:00
|
|
|
liveIntervalTest(R"MIR(
|
|
|
|
S_NOP 0
|
|
|
|
early-clobber %0 = IMPLICIT_DEF
|
|
|
|
S_NOP 0
|
|
|
|
S_NOP 0, implicit %0
|
|
|
|
)MIR", [](MachineFunction &MF, LiveIntervals &LIS) {
|
2016-05-03 01:05:48 +02:00
|
|
|
testHandleMove(MF, LIS, 1, 2);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(LiveIntervalTest, MoveDownEarlyRedef) {
|
2017-02-23 02:09:01 +01:00
|
|
|
liveIntervalTest(R"MIR(
|
|
|
|
%0 = IMPLICIT_DEF
|
|
|
|
early-clobber %0 = IMPLICIT_DEF implicit %0(tied-def 0)
|
|
|
|
S_NOP 0
|
|
|
|
S_NOP 0, implicit %0
|
|
|
|
)MIR", [](MachineFunction &MF, LiveIntervals &LIS) {
|
2016-05-03 01:05:48 +02:00
|
|
|
testHandleMove(MF, LIS, 1, 2);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(LiveIntervalTest, MoveDownKill) {
|
2017-02-23 02:09:01 +01:00
|
|
|
liveIntervalTest(R"MIR(
|
|
|
|
%0 = IMPLICIT_DEF
|
|
|
|
S_NOP 0, implicit %0
|
|
|
|
S_NOP 0
|
|
|
|
)MIR", [](MachineFunction &MF, LiveIntervals &LIS) {
|
2016-05-03 01:05:48 +02:00
|
|
|
testHandleMove(MF, LIS, 1, 2);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(LiveIntervalTest, MoveDownKillFollowing) {
|
2017-02-23 02:09:01 +01:00
|
|
|
liveIntervalTest(R"MIR(
|
|
|
|
%0 = IMPLICIT_DEF
|
|
|
|
S_NOP 0
|
|
|
|
S_NOP 0, implicit %0
|
|
|
|
S_NOP 0, implicit %0
|
|
|
|
)MIR", [](MachineFunction &MF, LiveIntervals &LIS) {
|
2016-05-03 01:05:48 +02:00
|
|
|
testHandleMove(MF, LIS, 1, 2);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2016-05-06 23:47:41 +02:00
|
|
|
TEST(LiveIntervalTest, MoveUndefUse) {
|
2017-02-23 02:09:01 +01:00
|
|
|
liveIntervalTest(R"MIR(
|
|
|
|
%0 = IMPLICIT_DEF
|
|
|
|
S_NOP 0, implicit undef %0
|
|
|
|
S_NOP 0, implicit %0
|
|
|
|
S_NOP 0
|
|
|
|
)MIR", [](MachineFunction &MF, LiveIntervals &LIS) {
|
2016-05-06 23:47:41 +02:00
|
|
|
testHandleMove(MF, LIS, 1, 3);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2016-05-24 23:54:01 +02:00
|
|
|
TEST(LiveIntervalTest, MoveUpValNos) {
|
|
|
|
// handleMoveUp() had a bug where it would reuse the value number of the
|
2019-09-26 17:20:16 +02:00
|
|
|
// destination segment, even though we have no guarantee that this valno
|
|
|
|
// wasn't used in other segments.
|
2017-02-23 02:09:01 +01:00
|
|
|
liveIntervalTest(R"MIR(
|
|
|
|
successors: %bb.1, %bb.2
|
|
|
|
%0 = IMPLICIT_DEF
|
2018-01-31 23:04:26 +01:00
|
|
|
S_CBRANCH_VCCNZ %bb.2, implicit undef $vcc
|
2017-02-23 02:09:01 +01:00
|
|
|
S_BRANCH %bb.1
|
|
|
|
bb.2:
|
|
|
|
S_NOP 0, implicit %0
|
|
|
|
bb.1:
|
|
|
|
successors: %bb.2
|
|
|
|
%0 = IMPLICIT_DEF implicit %0(tied-def 0)
|
|
|
|
%0 = IMPLICIT_DEF implicit %0(tied-def 0)
|
|
|
|
%0 = IMPLICIT_DEF implicit %0(tied-def 0)
|
|
|
|
S_BRANCH %bb.2
|
|
|
|
)MIR", [](MachineFunction &MF, LiveIntervals &LIS) {
|
2016-05-24 23:54:01 +02:00
|
|
|
testHandleMove(MF, LIS, 2, 0, 2);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2016-06-11 02:31:28 +02:00
|
|
|
TEST(LiveIntervalTest, MoveOverUndefUse0) {
|
|
|
|
// findLastUseBefore() used by handleMoveUp() must ignore undef operands.
|
2017-02-23 02:09:01 +01:00
|
|
|
liveIntervalTest(R"MIR(
|
|
|
|
%0 = IMPLICIT_DEF
|
|
|
|
S_NOP 0
|
|
|
|
S_NOP 0, implicit undef %0
|
|
|
|
%0 = IMPLICIT_DEF implicit %0(tied-def 0)
|
|
|
|
)MIR", [](MachineFunction &MF, LiveIntervals &LIS) {
|
2016-06-11 02:31:28 +02:00
|
|
|
testHandleMove(MF, LIS, 3, 1);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(LiveIntervalTest, MoveOverUndefUse1) {
|
|
|
|
// findLastUseBefore() used by handleMoveUp() must ignore undef operands.
|
2017-02-23 02:09:01 +01:00
|
|
|
liveIntervalTest(R"MIR(
|
2018-01-31 23:04:26 +01:00
|
|
|
$sgpr0 = IMPLICIT_DEF
|
2017-02-23 02:09:01 +01:00
|
|
|
S_NOP 0
|
2018-01-31 23:04:26 +01:00
|
|
|
S_NOP 0, implicit undef $sgpr0
|
|
|
|
$sgpr0 = IMPLICIT_DEF implicit $sgpr0(tied-def 0)
|
2017-02-23 02:09:01 +01:00
|
|
|
)MIR", [](MachineFunction &MF, LiveIntervals &LIS) {
|
2016-06-11 02:31:28 +02:00
|
|
|
testHandleMove(MF, LIS, 3, 1);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2016-07-26 05:57:45 +02:00
|
|
|
TEST(LiveIntervalTest, SubRegMoveDown) {
|
|
|
|
// Subregister ranges can have holes inside a basic block. Check for a
|
|
|
|
// movement of the form 32->150 in a liverange [16, 32) [100,200).
|
2017-02-23 02:09:01 +01:00
|
|
|
liveIntervalTest(R"MIR(
|
|
|
|
successors: %bb.1, %bb.2
|
|
|
|
%0 = IMPLICIT_DEF
|
2018-01-31 23:04:26 +01:00
|
|
|
S_CBRANCH_VCCNZ %bb.2, implicit undef $vcc
|
2017-02-23 02:09:01 +01:00
|
|
|
S_BRANCH %bb.1
|
|
|
|
bb.2:
|
|
|
|
successors: %bb.1
|
|
|
|
S_NOP 0, implicit %0.sub0
|
|
|
|
S_NOP 0, implicit %0.sub1
|
|
|
|
S_NOP 0
|
|
|
|
undef %0.sub0 = IMPLICIT_DEF
|
|
|
|
%0.sub1 = IMPLICIT_DEF
|
|
|
|
bb.1:
|
|
|
|
S_NOP 0, implicit %0
|
|
|
|
)MIR", [](MachineFunction &MF, LiveIntervals &LIS) {
|
2016-07-26 05:57:45 +02:00
|
|
|
// Scheduler behaviour: Clear def,read-undef flag and move.
|
|
|
|
MachineInstr &MI = getMI(MF, 3, /*BlockNum=*/1);
|
|
|
|
MI.getOperand(0).setIsUndef(false);
|
|
|
|
testHandleMove(MF, LIS, 1, 4, /*BlockNum=*/1);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2017-03-11 01:14:52 +01:00
|
|
|
TEST(LiveIntervalTest, SubRegMoveUp) {
|
|
|
|
// handleMoveUp had a bug not updating valno of segment incoming to bb.2
|
|
|
|
// after swapping subreg definitions.
|
|
|
|
liveIntervalTest(R"MIR(
|
|
|
|
successors: %bb.1, %bb.2
|
|
|
|
undef %0.sub0 = IMPLICIT_DEF
|
|
|
|
%0.sub1 = IMPLICIT_DEF
|
2018-01-31 23:04:26 +01:00
|
|
|
S_CBRANCH_VCCNZ %bb.2, implicit undef $vcc
|
2017-03-11 01:14:52 +01:00
|
|
|
S_BRANCH %bb.1
|
|
|
|
bb.1:
|
|
|
|
S_NOP 0, implicit %0.sub1
|
|
|
|
bb.2:
|
|
|
|
S_NOP 0, implicit %0.sub1
|
|
|
|
)MIR", [](MachineFunction &MF, LiveIntervals &LIS) {
|
|
|
|
testHandleMove(MF, LIS, 1, 0);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2018-02-26 15:42:13 +01:00
|
|
|
TEST(LiveIntervalTest, DeadSubRegMoveUp) {
|
|
|
|
// handleMoveUp had a bug where moving a dead subreg def into the middle of
|
|
|
|
// an earlier segment resulted in an invalid live range.
|
|
|
|
liveIntervalTest(R"MIR(
|
|
|
|
undef %125.sub0:vreg_128 = V_MOV_B32_e32 0, implicit $exec
|
|
|
|
%125.sub1:vreg_128 = COPY %125.sub0
|
|
|
|
%125.sub2:vreg_128 = COPY %125.sub0
|
|
|
|
undef %51.sub0:vreg_128 = V_MOV_B32_e32 898625526, implicit $exec
|
|
|
|
%51.sub1:vreg_128 = COPY %51.sub0
|
|
|
|
%51.sub2:vreg_128 = COPY %51.sub0
|
|
|
|
%52:vgpr_32 = V_MOV_B32_e32 986714345, implicit $exec
|
|
|
|
%54:vgpr_32 = V_MOV_B32_e32 1742342378, implicit $exec
|
|
|
|
%57:vgpr_32 = V_MOV_B32_e32 3168768712, implicit $exec
|
|
|
|
%59:vgpr_32 = V_MOV_B32_e32 1039972644, implicit $exec
|
|
|
|
%60:vgpr_32 = V_MAD_F32 0, %52, 0, undef %61:vgpr_32, 0, %59, 0, 0, implicit $exec
|
|
|
|
%63:vgpr_32 = V_ADD_F32_e32 %51.sub3, undef %64:vgpr_32, implicit $exec
|
|
|
|
dead %66:vgpr_32 = V_MAD_F32 0, %60, 0, undef %67:vgpr_32, 0, %125.sub2, 0, 0, implicit $exec
|
|
|
|
undef %124.sub1:vreg_128 = V_MAD_F32 0, %57, 0, undef %70:vgpr_32, 0, %125.sub1, 0, 0, implicit $exec
|
|
|
|
%124.sub0:vreg_128 = V_MAD_F32 0, %54, 0, undef %73:vgpr_32, 0, %125.sub0, 0, 0, implicit $exec
|
|
|
|
dead undef %125.sub3:vreg_128 = V_MAC_F32_e32 %63, undef %76:vgpr_32, %125.sub3, implicit $exec
|
|
|
|
)MIR", [](MachineFunction &MF, LiveIntervals &LIS) {
|
|
|
|
testHandleMove(MF, LIS, 15, 12);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2016-05-03 01:05:48 +02:00
|
|
|
int main(int argc, char **argv) {
|
|
|
|
::testing::InitGoogleTest(&argc, argv);
|
|
|
|
initLLVM();
|
|
|
|
return RUN_ALL_TESTS();
|
2016-02-18 08:37:17 +01:00
|
|
|
}
|