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 @@ -1088,7 +1088,8 @@ 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); } } }