This is an archive of the discontinued LLVM Phabricator instance.

Split the indirect jump critical edges.
Needs ReviewPublic

Authored by hudsontek on Aug 18 2022, 10:52 PM.

Details

Summary

This diff is for processing the critical edges generated from the switch statements. When there are more than 2 cases in the switch statement, a critical edge will form between the entry block and the epilog block. This critical edge is not taken care of by the machine-sink pass. Therefore we created this diff to make the split happen

Diff Detail

Event Timeline

hudsontek created this revision.Aug 18 2022, 10:52 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 18 2022, 10:52 PM
hudsontek requested review of this revision.Aug 18 2022, 10:52 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 18 2022, 10:52 PM

Looks like llvm/test/CodeGen/X86/switch-phi-const.ll may need some adjustments.

MatzeB added inline comments.Aug 22 2022, 11:26 AM
llvm/lib/CodeGen/MachineBasicBlock.cpp
1067

I thought we had the magic number 3 abstracted away already. This needs to be abstracted in the findIndirectJumpTable function as it is X86 specific!

1275–1278

Why was the comment removed?

llvm/lib/Target/X86/X86InstrInfo.h
332

I thought this would return just the jump table for the particular instruction, but MachineJumpTableInfo is just the generic interface for all jumptables it seems. So we probably rather something like llvm::Optional<unsigned> to return the operand index with the JTI machine operand...

I updated this diff to to no longer hardcode machine specific numbers in MachineBasicBlock::SplitCriticalEdge and update the X86 to support PIC and non-PIC jump table styles in D140975