[llvm] [Xtensa] Implement support for the BranchRelaxation. (PR #113450)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 5 13:16:57 PST 2024
================
@@ -378,6 +378,37 @@ void MachineFunction::RenumberBlocks(MachineBasicBlock *MBB) {
MBBNumberingEpoch++;
}
+int64_t MachineFunction::estimateFunctionSizeInBytes() {
+ const TargetInstrInfo &TII = *getSubtarget().getInstrInfo();
+ const Align FunctionAlignment = getAlignment();
+ MachineFunction::iterator MBBI = begin(), E = end();
+ /// Offset - Distance from the beginning of the function to the end
+ /// of the basic block.
+ int64_t Offset = 0;
+
+ for (; MBBI != E; ++MBBI) {
+ const Align Alignment = MBBI->getAlignment();
+ int64_t BlockSize = 0;
+
+ for (auto &MI : *MBBI) {
+ BlockSize += TII.getInstSizeInBytes(MI);
+ }
+
+ int64_t OffsetBB;
+ if (Alignment <= FunctionAlignment) {
+ OffsetBB = alignTo(Offset, Alignment);
+ } else {
+ // The alignment of this MBB is larger than the function's alignment, so
+ // we can't tell whether or not it will insert nops. Assume that it will.
----------------
arsenm wrote:
I'm wondering if this should be a verifier error
https://github.com/llvm/llvm-project/pull/113450
More information about the llvm-commits
mailing list