Skip to content

Commit c6f681d

Browse files
committed
[DLCov] Origin-Tracking: Handle origin-tracking elsewhere in LLVM
1 parent 8ff21d6 commit c6f681d

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

llvm/include/llvm/IR/Instruction.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,7 @@ class Instruction : public User,
507507
LLVM_ABI bool extractProfTotalWeight(uint64_t &TotalVal) const;
508508

509509
/// Set the debug location information for this instruction.
510-
void setDebugLoc(DebugLoc Loc) { DbgLoc = std::move(Loc); }
510+
void setDebugLoc(DebugLoc Loc) { DbgLoc = std::move(Loc).getCopied(); }
511511

512512
/// Return the debug location for this node as a DebugLoc.
513513
const DebugLoc &getDebugLoc() const { return DbgLoc; }

llvm/lib/CodeGen/BranchFolding.cpp

Lines changed: 7 additions & 0 deletions
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/llvm-config.h"
4546
#include "llvm/IR/DebugInfoMetadata.h"
4647
#include "llvm/IR/DebugLoc.h"
4748
#include "llvm/IR/Function.h"
@@ -933,7 +934,13 @@ bool BranchFolder::TryTailMergeBlocks(MachineBasicBlock *SuccBB,
933934

934935
// Sort by hash value so that blocks with identical end sequences sort
935936
// together.
937+
#if LLVM_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) {

llvm/lib/IR/Instruction.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1375,7 +1375,7 @@ void Instruction::copyMetadata(const Instruction &SrcInst,
13751375
setMetadata(MD.first, MD.second);
13761376
}
13771377
if (WL.empty() || WLS.count(LLVMContext::MD_dbg))
1378-
setDebugLoc(SrcInst.getDebugLoc());
1378+
setDebugLoc(SrcInst.getDebugLoc().getCopied());
13791379
}
13801380

13811381
Instruction *Instruction::clone() const {

0 commit comments

Comments
 (0)