Skip to content

Commit

Permalink
Don't count instructions that ge going to be eliminated by MEM2SSA pass
Browse files Browse the repository at this point in the history
  • Loading branch information
dstogov committed Dec 28, 2024
1 parent 36a2349 commit 06b23fb
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions ir_load_llvm.c
Original file line number Diff line number Diff line change
Expand Up @@ -1179,6 +1179,26 @@ static int llvm2ir_inline_cost(LLVMValueRef func)

for (bb = LLVMGetFirstBasicBlock(func); bb; bb = LLVMGetNextBasicBlock(bb)) {
for (insn = LLVMGetFirstInstruction(bb); insn; insn = LLVMGetNextInstruction(insn)) {
LLVMOpcode opcode = LLVMGetInstructionOpcode(insn);

/* Skip SSA related instuctions */
if (opcode == LLVMPHI
|| opcode == LLVMAlloca
|| (opcode == LLVMStore && LLVMGetInstructionOpcode(LLVMGetOperand(insn, 1)) == LLVMAlloca)
|| (opcode == LLVMLoad && LLVMGetInstructionOpcode(LLVMGetOperand(insn, 0)) == LLVMAlloca)) {
continue;
} else if (opcode == LLVMCall) {
LLVMValueRef f = LLVMGetCalledValue(insn);
if (LLVMGetValueKind(f) == LLVMFunctionValueKind) {
size_t name_len;
const char *name;

name = LLVMGetValueName2(f, &name_len);
if (STR_START(name, name_len, "llvm.lifetime.")) {
continue;
}
}
}
count++;
}
}
Expand Down

0 comments on commit 06b23fb

Please sign in to comment.