Skip to content

Commit 1525abb

Browse files
authored
[FastISel] Don't use sizeWithoutDebug() for debug records (llvm#101648)
sizeWithoutDebug() iterates over the entire block, but all we do is to check whether the number is not equal to one. In times of debug records, simply check whether the first and last instructions are equal.
1 parent db1375f commit 1525abb

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

llvm/lib/CodeGen/SelectionDAG/FastISel.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@
8686
#include "llvm/IR/LLVMContext.h"
8787
#include "llvm/IR/Mangler.h"
8888
#include "llvm/IR/Metadata.h"
89+
#include "llvm/IR/Module.h"
8990
#include "llvm/IR/Operator.h"
9091
#include "llvm/IR/PatternMatch.h"
9192
#include "llvm/IR/Type.h"
@@ -1664,8 +1665,12 @@ bool FastISel::selectInstruction(const Instruction *I) {
16641665
/// (fall-through) successor, and update the CFG.
16651666
void FastISel::fastEmitBranch(MachineBasicBlock *MSucc,
16661667
const DebugLoc &DbgLoc) {
1667-
if (FuncInfo.MBB->getBasicBlock()->sizeWithoutDebug() > 1 &&
1668-
FuncInfo.MBB->isLayoutSuccessor(MSucc)) {
1668+
const BasicBlock *BB = FuncInfo.MBB->getBasicBlock();
1669+
bool BlockHasMultipleInstrs = &BB->front() != &BB->back();
1670+
// Handle legacy case of debug intrinsics
1671+
if (BlockHasMultipleInstrs && !BB->getModule()->IsNewDbgInfoFormat)
1672+
BlockHasMultipleInstrs = BB->sizeWithoutDebug() > 1;
1673+
if (BlockHasMultipleInstrs && FuncInfo.MBB->isLayoutSuccessor(MSucc)) {
16691674
// For more accurate line information if this is the only non-debug
16701675
// instruction in the block then emit it, otherwise we have the
16711676
// unconditional fall-through case, which needs no instructions.

llvm/test/CodeGen/AArch64/fast-isel-branch-uncond-debug.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
; RUN: llc -mtriple=aarch64 -O1 -opt-bisect-limit=2 -o - %s 2> /dev/null | FileCheck %s
2-
; RUN: llc --try-experimental-debuginfo-iterators -mtriple=aarch64 -O1 -opt-bisect-limit=2 -o - %s 2> /dev/null | FileCheck %s
2+
; RUN: llc --preserve-input-debuginfo-format=true -mtriple=aarch64 -O1 -opt-bisect-limit=2 -o - %s 2> /dev/null | FileCheck %s
33

44
define dso_local i32 @a() #0 !dbg !7 {
55
entry:

0 commit comments

Comments
 (0)