Skip to content

Commit ab75997

Browse files
committed
Fix a bug in the liveness analysis.
Before, the first instruction of a function *defined* the function's arguments. This meant that if you asked what was live at the first instruction, then the arguments would not yet be live. This is wrong! Nothing in-tree currently hits this case, but I have triggered it during development. Ideally we'd have dedicated tests for the liveness analysis: ykjit/yk#758
1 parent 9c9f169 commit ab75997

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

llvm/lib/Transforms/Yk/LivenessAnalysis.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -119,13 +119,14 @@ LivenessAnalysis::LivenessAnalysis(Function *Func) {
119119
}
120120
}
121121

122-
// A function implicitly defines its arguments.
123-
//
124-
// To propagate the arguments properly we pretend that the first instruction
125-
// in the entry block defines the arguments.
122+
// Normally the live range of a variable starts at the instruction that
123+
// defines it. No instruction defines the function's arguments, but it is
124+
// important that we don't report them dead. We make function arguments live
125+
// at the start of the function by adding them into the `In` set of the first
126+
// instruction.
126127
Instruction *FirstInst = &*Func->getEntryBlock().begin();
127128
for (auto &Arg : Func->args())
128-
Defs[FirstInst].insert(&Arg);
129+
In[FirstInst].insert(&Arg);
129130

130131
// Compute the live sets for each instruction.
131132
//

0 commit comments

Comments
 (0)