llvm.org GIT mirror llvm / 982d11c
Remove the unit test from r321783. This test fails when run on the sanitizer bot, and I do not see a good way to fix it. The existing bogus target in MachineInstrTest.cpp is only good enough to create instructions but not sufficient to insert them into basic blocks. The addNodeToList ilist callback dereferences the pointer to the MachineRegisterInfo. Adding MachineRegisterInfo would also require TargetRegisterInfo, even a minimal implementation of that would be quite complicated. I would be glad to add this back if someone can suggest a better way to do it. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@321784 91177308-0d34-0410-b5e6-96231b3b80d8 Bob Wilson 2 years ago
1 changed file(s) with 0 addition(s) and 68 deletion(s). Raw diff Collapse all Expand all
77 //===----------------------------------------------------------------------===//
88
99 #include "llvm/CodeGen/MachineInstr.h"
10 #include "llvm/CodeGen/MachineInstrBuilder.h"
1110 #include "llvm/CodeGen/MachineFunction.h"
1211 #include "llvm/CodeGen/MachineModuleInfo.h"
1312 #include "llvm/CodeGen/TargetFrameLowering.h"
244243
245244 checkHashAndIsEqualMatch(VD2PU, VD2PD);
246245 }
247
248 TEST(MachineBasicBlockTest, PhiRange) {
249 auto MF = createMachineFunction();
250
251 // Create the main block.
252 auto BB = MF->CreateMachineBasicBlock();
253
254 // Create some predecessors of it.
255 auto BB1 = MF->CreateMachineBasicBlock();
256 BB1->addSuccessor(BB);
257 auto BB2 = MF->CreateMachineBasicBlock();
258 BB2->addSuccessor(BB);
259
260 // Make sure this doesn't crash if there are no phis.
261 for (auto &PN : BB->phis()) {
262 (void)PN;
263 ASSERT_TRUE(false) << "empty block should have no phis";
264 }
265
266 // Make it a cycle.
267 BB->addSuccessor(BB);
268
269 // Now insert some PHI nodes.
270 MCOperandInfo OpInfo[] = { { -1, 0, MCOI::OPERAND_UNKNOWN, 0} };
271 MCInstrDesc PHIMCID = {
272 TargetOpcode::PHI, 1, 1, 0, 0,
273 (1ULL << MCID::Pseudo) | (1ULL << MCID::Variadic), 0,
274 nullptr, nullptr, OpInfo, -1, nullptr};
275 auto P1 = BuildMI(*BB, BB->end(), DebugLoc(), PHIMCID, -101);
276 auto P2 = BuildMI(*BB, BB->end(), DebugLoc(), PHIMCID, -102);
277 auto P3 = BuildMI(*BB, BB->end(), DebugLoc(), PHIMCID, -103);
278
279 // A non-PHI node.
280 MCInstrDesc ImpDefMCID = {
281 TargetOpcode::IMPLICIT_DEF, 1, 1, 0, 0,
282 (1ULL << MCID::Pseudo), 0,
283 nullptr, nullptr, OpInfo, -1, nullptr};
284 BuildMI(*BB, BB->end(), DebugLoc(), ImpDefMCID, -104);
285
286 // Now wire up the incoming values that are interesting.
287 P1.addReg(-102).addMBB(BB);
288 P2.addReg(-101).addMBB(BB);
289 P3.addReg(-104).addMBB(BB);
290
291 // Finally, let's iterate them, which is the thing we're trying to test.
292 // We'll use this to wire up the rest of the incoming values.
293 for (auto &PN : BB->phis()) {
294 EXPECT_TRUE(PN.isPHI());
295 PN.addOperand(*MF, MachineOperand::CreateReg(-100, /*isDef*/ false));
296 PN.addOperand(*MF, MachineOperand::CreateMBB(BB1));
297 PN.addOperand(*MF, MachineOperand::CreateReg(-100, /*isDef*/ false));
298 PN.addOperand(*MF, MachineOperand::CreateMBB(BB2));
299 }
300
301 // Test that we can use const iterators and generally that the iterators
302 // behave like iterators.
303 MachineBasicBlock::const_iterator CI;
304 CI = BB->phis().begin();
305 EXPECT_NE(CI, BB->phis().end());
306
307 // And iterate a const range.
308 for (const auto &PN : const_cast(BB)->phis()) {
309 EXPECT_EQ(BB, PN.getOperand(2).getMBB());
310 EXPECT_EQ(BB1, PN.getOperand(4).getMBB());
311 EXPECT_EQ(BB2, PN.getOperand(6).getMBB());
312 }
313 }
314246 } // end namespace