llvm.org GIT mirror llvm / a4e6397
Enforce stricter liveness rules for PHIs. Verify that all paths from the entry block to a virtual register read pass through a def. Enable this check even when MRI->isSSA() is false. Verify that the live range of a virtual register is live out of all predecessor blocks, even for PHI-values. This requires that PHIElimination sometimes inserts IMPLICIT_DEF instruction in predecessor blocks. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@159150 91177308-0d34-0410-b5e6-96231b3b80d8 Jakob Stoklund Olesen 8 years ago
2 changed file(s) with 37 addition(s) and 6 deletion(s). Raw diff Collapse all Expand all
10481048 // Now check liveness info if available
10491049 calcRegsRequired();
10501050
1051 if (MRI->isSSA() && !MF->empty()) {
1051 if (!MF->empty()) {
10521052 BBInfo &MInfo = MBBInfoMap[&MF->front()];
10531053 for (RegSet::iterator
10541054 I = MInfo.vregsRequired.begin(), E = MInfo.vregsRequired.end(); I != E;
13311331 ++MFI;
13321332 continue;
13331333 }
1334
1335 // Is VNI a PHI-def in the current block?
1336 bool IsPHI = VNI->isPHIDef() &&
1337 VNI->def == LiveInts->getMBBStartIdx(MFI);
1338
13341339 // Check that VNI is live-out of all predecessors.
13351340 for (MachineBasicBlock::const_pred_iterator PI = MFI->pred_begin(),
13361341 PE = MFI->pred_end(); PI != PE; ++PI) {
13371342 SlotIndex PEnd = LiveInts->getMBBEndIdx(*PI);
13381343 const VNInfo *PVNI = LI.getVNInfoBefore(PEnd);
13391344
1340 if (VNI->isPHIDef() && VNI->def == LiveInts->getMBBStartIdx(MFI))
1341 continue;
1342
1345 // All predecessors must have a live-out value.
13431346 if (!PVNI) {
13441347 report("Register not marked live out of predecessor", *PI);
13451348 *OS << "Valno #" << VNI->id << " live into BB#" << MFI->getNumber()
13481351 continue;
13491352 }
13501353
1351 if (PVNI != VNI) {
1354 // Only PHI-defs can take different predecessor values.
1355 if (!IsPHI && PVNI != VNI) {
13521356 report("Different value live out of predecessor", *PI);
13531357 *OS << "Valno #" << PVNI->id << " live out of BB#"
13541358 << (*PI)->getNumber() << '@' << PEnd
13551359 << "\nValno #" << VNI->id << " live into BB#" << MFI->getNumber()
1356 << '@' << LiveInts->getMBBStartIdx(MFI) << " in " << LI << '\n';
1360 << '@' << LiveInts->getMBBStartIdx(MFI) << " in "
1361 << PrintReg(Reg) << ": " << LI << '\n';
13571362 }
13581363 }
13591364 if (&*MFI == EndMBB)
0 ; RUN: llc < %s -verify-machineinstrs -verify-coalescing
1 ;
2 ; This function has a PHI with one undefined input. Verify that PHIElimination
3 ; inserts an IMPLICIT_DEF instruction in the predecessor so all paths to the use
4 ; pass through a def.
5
6 %struct.xx_stack = type { i32, %struct.xx_stack* }
7
8 define i32 @push(%struct.xx_stack* %stack) nounwind uwtable readonly ssp {
9 entry:
10 %tobool1 = icmp eq %struct.xx_stack* %stack, null
11 br i1 %tobool1, label %for.end, label %for.body
12
13 for.body:
14 %stack.addr.02 = phi %struct.xx_stack* [ %0, %for.body ], [ %stack, %entry ]
15 %next = getelementptr inbounds %struct.xx_stack* %stack.addr.02, i64 0, i32 1
16 %0 = load %struct.xx_stack** %next, align 8
17 %tobool = icmp eq %struct.xx_stack* %0, null
18 br i1 %tobool, label %for.end, label %for.body
19
20 for.end:
21 %top.0.lcssa = phi %struct.xx_stack* [ undef, %entry ], [ %stack.addr.02, %for.body ]
22 %first = getelementptr inbounds %struct.xx_stack* %top.0.lcssa, i64 0, i32 0
23 %1 = load i32* %first, align 4
24 ret i32 %1
25 }