Skip to content

Commit a4e871f

Browse files
committed
Remove BranchFolding specialization, stacktrace->stack trace
1 parent b4439b9 commit a4e871f

File tree

4 files changed

+16
-13
lines changed

4 files changed

+16
-13
lines changed

llvm/include/llvm/IR/DebugLoc.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ namespace llvm {
7474
// allowing Debugify to ignore intentionally-empty DebugLocs and display the
7575
// code responsible for generating unintentionally-empty DebugLocs.
7676
// Currently we only need to track the Origin of this DILoc when using a
77-
// DebugLoc that is Normal and empty, so only collect the origin stacktrace in
78-
// those cases.
77+
// DebugLoc that is not annotated (i.e. has DebugLocKind::Normal) and has a
78+
// null DILocation, so only collect the origin stacktrace in those cases.
7979
class DILocAndCoverageTracking : public TrackingMDNodeRef,
8080
public DbgLocOrigin {
8181
public:

llvm/include/llvm/Support/Signals.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class StringRef;
2525
class raw_ostream;
2626

2727
#if ENABLE_DEBUGLOC_ORIGIN_TRACKING
28-
// Typedefs that are convenient but only used by the StackTrace-collection code
28+
// Typedefs that are convenient but only used by the stack-trace-collection code
2929
// added if DebugLoc origin-tracking is enabled.
3030
template <typename T, typename Enable> struct DenseMapInfo;
3131
template <typename ValueT, typename ValueInfoT> class DenseSet;
@@ -79,7 +79,7 @@ LLVM_ABI void PrintStackTrace(raw_ostream &OS, int Depth = 0);
7979
#ifdef NDEBUG
8080
#error DebugLoc origin-tracking should not be enabled in Release builds.
8181
#endif
82-
/// Populates the given array with a stacktrace of the current program, up to
82+
/// Populates the given array with a stack trace of the current program, up to
8383
/// MaxDepth frames. Returns the number of frames returned, which will be
8484
/// inserted into \p StackTrace from index 0. All entries after the returned
8585
/// depth will be unmodified. NB: This is only intended to be used for

llvm/lib/CodeGen/BranchFolding.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
#include "llvm/CodeGen/TargetPassConfig.h"
4343
#include "llvm/CodeGen/TargetRegisterInfo.h"
4444
#include "llvm/CodeGen/TargetSubtargetInfo.h"
45+
#include "llvm/Config/config.h"
4546
#include "llvm/IR/DebugInfoMetadata.h"
4647
#include "llvm/IR/DebugLoc.h"
4748
#include "llvm/IR/Function.h"
@@ -933,12 +934,18 @@ bool BranchFolder::TryTailMergeBlocks(MachineBasicBlock *SuccBB,
933934

934935
// Sort by hash value so that blocks with identical end sequences sort
935936
// together.
937+
#if ENABLE_DEBUGLOC_ORIGIN_TRACKING
938+
// If origin-tracking is enabled then MergePotentialElt is no longer a POD
939+
// type, so we need std::sort instead.
940+
std::sort(MergePotentials.begin(), MergePotentials.end());
941+
#else
936942
array_pod_sort(MergePotentials.begin(), MergePotentials.end());
943+
#endif
937944

938945
// Walk through equivalence sets looking for actual exact matches.
939946
while (MergePotentials.size() > 1) {
940947
unsigned CurHash = MergePotentials.back().getHash();
941-
const DebugLoc BranchDL = MergePotentials.back().getBranchDebugLoc();
948+
const DebugLoc &BranchDL = MergePotentials.back().getBranchDebugLoc();
942949

943950
// Build SameTails, identifying the set of blocks with this hash code
944951
// and with the maximum number of instructions in common.

llvm/lib/CodeGen/BranchFolding.h

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,11 @@ class TargetRegisterInfo;
5050
class MergePotentialsElt {
5151
unsigned Hash;
5252
MachineBasicBlock *Block;
53-
// We use MDNode rather than DebugLoc here because under certain CMake
54-
// options*, DebugLoc may contain a SmallVector used for introspection
55-
// purposes, which causes errors when stored here.
56-
// *LLVM_ENABLE_DEBUGLOC_COVERAGE_TRACKING=COVERAGE_AND_ORIGIN
57-
MDNode *BranchDebugLoc;
53+
DebugLoc BranchDebugLoc;
5854

5955
public:
60-
MergePotentialsElt(unsigned h, MachineBasicBlock *b, MDNode *bdl)
61-
: Hash(h), Block(b), BranchDebugLoc(bdl) {}
56+
MergePotentialsElt(unsigned h, MachineBasicBlock *b, DebugLoc bdl)
57+
: Hash(h), Block(b), BranchDebugLoc(std::move(bdl)) {}
6258

6359
unsigned getHash() const { return Hash; }
6460
MachineBasicBlock *getBlock() const { return Block; }
@@ -67,7 +63,7 @@ class TargetRegisterInfo;
6763
Block = MBB;
6864
}
6965

70-
const DebugLoc getBranchDebugLoc() { return DebugLoc(BranchDebugLoc); }
66+
const DebugLoc &getBranchDebugLoc() { return BranchDebugLoc; }
7167

7268
bool operator<(const MergePotentialsElt &) const;
7369
};

0 commit comments

Comments
 (0)