HomePhabricator

[llvm-readelf, propeller] Add fallthrough bit to basic block metadata in BB…

Authored by rahmanl on Mar 22 2021, 9:36 PM.

Description

[llvm-readelf, propeller] Add fallthrough bit to basic block metadata in BB-Address-Map section.

This patch adds a fallthrough bit to basic block metadata, indicating whether the basic block can fallthrough without taking any branches. The bit will help us avoid an intel LBR bug which results in occasional duplicate entries at the beginning of the LBR stack.

This patch uses MachineBasicBlock::canFallThrough() to set the bit. This is not a const method because it eventually calls TargetInstrInfo::analyzeBranch, but it calls this function with the default AllowModify=false. So we can either make the argument to the getBBAddrMapMetadata non-const, or we can use const_cast when calling canFallThrough. I decide to go with the latter since this is purely due to legacy code, and in general we should not allow the BasicBlock to be mutable during getBBAddrMapMetadata.

Reviewed By: tmsriram

Differential Revision: https://reviews.llvm.org/D96918

Details