diff --git a/llvm/include/llvm/Object/ELFTypes.h b/llvm/include/llvm/Object/ELFTypes.h --- a/llvm/include/llvm/Object/ELFTypes.h +++ b/llvm/include/llvm/Object/ELFTypes.h @@ -802,13 +802,15 @@ // The following fields are decoded from the Metadata field. The encoding // happens in AsmPrinter.cpp:getBBAddrMapMetadata. - bool HasReturn; // If this block ends with a return (or tail call). - bool HasTailCall; // If this block ends with a tail call. - bool IsEHPad; // If this is an exception handling block. + bool HasReturn; // If this block ends with a return (or tail call). + bool HasTailCall; // If this block ends with a tail call. + bool IsEHPad; // If this is an exception handling block. + bool CanFallThrough; // If this block can fall through to its next. BBEntry(uint32_t Offset, uint32_t Size, uint32_t Metadata) : Offset(Offset), Size(Size), HasReturn(Metadata & 1), - HasTailCall(Metadata & (1 << 1)), IsEHPad(Metadata & (1 << 2)){}; + HasTailCall(Metadata & (1 << 1)), IsEHPad(Metadata & (1 << 2)), + CanFallThrough(Metadata & (1 << 3)){}; }; std::vector BBEntries; // Basic block entries for this function. }; diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp --- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp @@ -1078,17 +1078,19 @@ /// Returns the BB metadata to be emitted in the .llvm_bb_addr_map section for a /// given basic block. This can be used to capture more precise profile -/// information. We use the last 3 bits (LSBs) to ecnode the following +/// information. We use the last 4 bits (LSBs) to encode the following /// information: /// * (1): set if return block (ret or tail call). /// * (2): set if ends with a tail call. /// * (3): set if exception handling (EH) landing pad. +/// * (4): set if the block can fall through to its next. /// The remaining bits are zero. static unsigned getBBAddrMapMetadata(const MachineBasicBlock &MBB) { const TargetInstrInfo *TII = MBB.getParent()->getSubtarget().getInstrInfo(); return ((unsigned)MBB.isReturnBlock()) | ((!MBB.empty() && TII->isTailCall(MBB.back())) << 1) | - (MBB.isEHPad() << 2); + (MBB.isEHPad() << 2) | + (const_cast(MBB).canFallThrough() << 3); } void AsmPrinter::emitBBAddrMapSection(const MachineFunction &MF) { diff --git a/llvm/test/tools/llvm-readobj/ELF/bb-addr-map.test b/llvm/test/tools/llvm-readobj/ELF/bb-addr-map.test --- a/llvm/test/tools/llvm-readobj/ELF/bb-addr-map.test +++ b/llvm/test/tools/llvm-readobj/ELF/bb-addr-map.test @@ -24,6 +24,7 @@ # LLVM-NEXT: HasReturn: No # LLVM-NEXT: HasTailCall: Yes # LLVM-NEXT: IsEHPad: No +# LLVM-NEXT: CanFallThrough: No # LLVM-NEXT: } # LLVM-NEXT: { # LLVM-NEXT: Offset: 0x3 @@ -31,6 +32,7 @@ # LLVM-NEXT: HasReturn: Yes # LLVM-NEXT: HasTailCall: No # LLVM-NEXT: IsEHPad: Yes +# LLVM-NEXT: CanFallThrough: No # LLVM-NEXT: } # LLVM-NEXT: ] # LLVM-NEXT: } @@ -43,6 +45,7 @@ # LLVM-NEXT: HasReturn: No # LLVM-NEXT: HasTailCall: No # LLVM-NEXT: IsEHPad: No +# LLVM-NEXT: CanFallThrough: Yes # LLVM-NEXT: } # LLVM-NEXT: ] # LLVM-NEXT: } @@ -57,6 +60,7 @@ # LLVM-NEXT: HasReturn: Yes # LLVM-NEXT: HasTailCall: Yes # LLVM-NEXT: IsEHPad: No +# LLVM-NEXT: CanFallThrough: Yes # LLVM-NEXT: } # LLVM-NEXT: ] # LLVM-NEXT: } @@ -78,6 +82,7 @@ # TRUNCATED-NEXT: HasReturn: Yes # TRUNCATED-NEXT: HasTailCall: Yes # TRUNCATED-NEXT: IsEHPad: No +# TRUNCATED-NEXT: CanFallThrough: Yes # TRUNCATED-NEXT: } # TRUNCATED-NEXT: ] # TRUNCATED-NEXT: } diff --git a/llvm/tools/llvm-readobj/ELFDumper.cpp b/llvm/tools/llvm-readobj/ELFDumper.cpp --- a/llvm/tools/llvm-readobj/ELFDumper.cpp +++ b/llvm/tools/llvm-readobj/ELFDumper.cpp @@ -6549,6 +6549,7 @@ W.printBoolean("HasReturn", BBE.HasReturn); W.printBoolean("HasTailCall", BBE.HasTailCall); W.printBoolean("IsEHPad", BBE.IsEHPad); + W.printBoolean("CanFallThrough", BBE.CanFallThrough); } } }