Skip to content

Commit 30c1633

Browse files
committed
Revert "[Instruction] Add updateLocationAfterHoist helper"
This reverts commit 4a646ca. This is causing some bots to fail with "!dbg attachment points at wrong subprogram for function", like: http://lab.llvm.org:8011/builders/sanitizer-windows/builds/67958/steps/stage%201%20check/logs/stdio
1 parent 54b6cca commit 30c1633

File tree

8 files changed

+14
-76
lines changed

8 files changed

+14
-76
lines changed

llvm/include/llvm/IR/Instruction.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -492,10 +492,6 @@ class Instruction : public User,
492492
/// merged DebugLoc.
493493
void applyMergedLocation(const DILocation *LocA, const DILocation *LocB);
494494

495-
/// Updates the debug location given that the instruction has been hoisted
496-
/// from a block to a predecessor of that block.
497-
void updateLocationAfterHoist();
498-
499495
private:
500496
/// Return true if we have an entry in the on-the-side metadata hash.
501497
bool hasMetadataHashEntry() const {

llvm/lib/IR/DebugInfo.cpp

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -696,24 +696,6 @@ void Instruction::applyMergedLocation(const DILocation *LocA,
696696
setDebugLoc(DILocation::getMergedLocation(LocA, LocB));
697697
}
698698

699-
void Instruction::updateLocationAfterHoist() {
700-
const DebugLoc &DL = getDebugLoc();
701-
if (!DL)
702-
return;
703-
704-
// If we didn't hoist a call, drop the location to allow a location from a
705-
// preceding instruction to propagate.
706-
if (!isa<CallBase>(this)) {
707-
setDebugLoc(DebugLoc());
708-
return;
709-
}
710-
711-
// Set a line 0 location for (potentially inlinable) calls. Set the scope to
712-
// the parent function's scope if it's available, and drop any inlinedAt info
713-
// to avoid making it look like the inlined callee was reached early.
714-
setDebugLoc(DebugLoc::get(0, 0, DL.getScope()));
715-
}
716-
717699
//===----------------------------------------------------------------------===//
718700
// LLVM C API implementations.
719701
//===----------------------------------------------------------------------===//

llvm/lib/Transforms/Scalar/GVN.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
#include "llvm/IR/Constant.h"
4747
#include "llvm/IR/Constants.h"
4848
#include "llvm/IR/DataLayout.h"
49+
#include "llvm/IR/DebugInfoMetadata.h"
4950
#include "llvm/IR/DebugLoc.h"
5051
#include "llvm/IR/Dominators.h"
5152
#include "llvm/IR/Function.h"
@@ -1313,7 +1314,8 @@ bool GVN::PerformLoadPRE(LoadInst *LI, AvailValInBlkVect &ValuesPerBlock,
13131314
// Instructions that have been inserted in predecessor(s) to materialize
13141315
// the load address do not retain their original debug locations. Doing
13151316
// so could lead to confusing (but correct) source attributions.
1316-
I->updateLocationAfterHoist();
1317+
if (const DebugLoc &DL = I->getDebugLoc())
1318+
I->setDebugLoc(DebugLoc::get(0, 0, DL.getScope(), DL.getInlinedAt()));
13171319

13181320
// FIXME: We really _ought_ to insert these value numbers into their
13191321
// parent's availability map. However, in doing so, we risk getting into

llvm/lib/Transforms/Scalar/LICM.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1658,7 +1658,10 @@ static void hoist(Instruction &I, const DominatorTree *DT, const Loop *CurLoop,
16581658
// Move the new node to the destination block, before its terminator.
16591659
moveInstructionBefore(I, *Dest->getTerminator(), *SafetyInfo, MSSAU, SE);
16601660

1661-
I.updateLocationAfterHoist();
1661+
// Apply line 0 debug locations when we are moving instructions to different
1662+
// basic blocks because we want to avoid jumpy line tables.
1663+
if (const DebugLoc &DL = I.getDebugLoc())
1664+
I.setDebugLoc(DebugLoc::get(0, 0, DL.getScope(), DL.getInlinedAt()));
16621665

16631666
if (isa<LoadInst>(I))
16641667
++NumMovedLoads;

llvm/test/DebugInfo/Generic/licm-hoist-debug-loc.ll

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@
1818
; We make sure that the instruction that is hoisted into the preheader
1919
; does not have a debug location.
2020
; CHECK: for.body.lr.ph:
21-
; CHECK: getelementptr{{.*}}%p.addr, i64 4{{$}}
21+
; CHECK: getelementptr{{.*}}%p.addr, i64 4{{.*}} !dbg [[zero:![0-9]+]]
2222
; CHECK: for.body:
23+
; CHECK: [[zero]] = !DILocation(line: 0
2324
;
2425
; ModuleID = 't.ll'
2526
source_filename = "test.c"

llvm/test/Transforms/GVN/PRE/phi-translate.ll

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ target datalayout = "e-p:64:64:64"
44

55
; CHECK-LABEL: @foo(
66
; CHECK: entry.end_crit_edge:
7-
; CHECK: %[[INDEX:[a-z0-9.]+]] = sext i32 %x to i64{{$}}
8-
; CHECK: %[[ADDRESS:[a-z0-9.]+]] = getelementptr [100 x i32], [100 x i32]* @G, i64 0, i64 %[[INDEX]]{{$}}
7+
; CHECK: %[[INDEX:[a-z0-9.]+]] = sext i32 %x to i64{{.*}} !dbg [[ZERO_LOC:![0-9]+]]
8+
; CHECK: %[[ADDRESS:[a-z0-9.]+]] = getelementptr [100 x i32], [100 x i32]* @G, i64 0, i64 %[[INDEX]]{{.*}} !dbg [[ZERO_LOC]]
99
; CHECK: %n.pre = load i32, i32* %[[ADDRESS]], align 4, !dbg [[N_LOC:![0-9]+]]
1010
; CHECK: br label %end
1111
; CHECK: then:
@@ -14,7 +14,8 @@ target datalayout = "e-p:64:64:64"
1414
; CHECK: %n = phi i32 [ %n.pre, %entry.end_crit_edge ], [ %z, %then ], !dbg [[N_LOC]]
1515
; CHECK: ret i32 %n
1616

17-
; CHECK: [[N_LOC]] = !DILocation(line: 47, column: 1, scope: !{{.*}})
17+
; CHECK-DAG: [[N_LOC]] = !DILocation(line: 47, column: 1, scope: !{{.*}})
18+
; CHECK-DAG: [[ZERO_LOC]] = !DILocation(line: 0
1819

1920
@G = external global [100 x i32]
2021
define i32 @foo(i32 %x, i32 %z) !dbg !6 {

llvm/test/Transforms/LICM/hoisting-preheader-debugloc.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
; RUN: opt -S -licm < %s | FileCheck %s
22

3-
; CHECK: %arrayidx4.promoted = load i32, i32* %arrayidx4, align 1, !tbaa !{{[0-9]+$}}
3+
; CHECK: %arrayidx4.promoted = load i32, i32* %arrayidx4, align 1, !tbaa !59
44

55
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
66
target triple = "x86_64-unknown-linux-gnu"

llvm/unittests/IR/InstructionsTest.cpp

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1304,52 +1304,5 @@ TEST(InstructionsTest, UnaryOperator) {
13041304
I->deleteValue();
13051305
}
13061306

1307-
TEST(InstructionsTest, UpdateLocationAfterHoist) {
1308-
LLVMContext C;
1309-
std::unique_ptr<Module> M = parseIR(C,
1310-
R"(
1311-
declare void @callee()
1312-
1313-
define void @f() {
1314-
call void @callee() ; Inst with no location.
1315-
call void @callee(), !dbg !11 ; Call with location.
1316-
ret void, !dbg !11 ; Non-call inst with location.
1317-
}
1318-
1319-
!llvm.dbg.cu = !{!0}
1320-
!llvm.module.flags = !{!3, !4}
1321-
!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 6.0.0", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
1322-
!1 = !DIFile(filename: "t2.c", directory: "foo")
1323-
!2 = !{}
1324-
!3 = !{i32 2, !"Dwarf Version", i32 4}
1325-
!4 = !{i32 2, !"Debug Info Version", i32 3}
1326-
!8 = distinct !DISubprogram(name: "f", scope: !1, file: !1, line: 1, type: !9, isLocal: false, isDefinition: true, scopeLine: 1, isOptimized: false, unit: !0, retainedNodes: !2)
1327-
!9 = !DISubroutineType(types: !10)
1328-
!10 = !{null}
1329-
!11 = !DILocation(line: 2, column: 7, scope: !8)
1330-
)");
1331-
ASSERT_TRUE(M);
1332-
Function *F = cast<Function>(M->getNamedValue("f"));
1333-
BasicBlock &BB = F->front();
1334-
1335-
auto *I1 = BB.getFirstNonPHI();
1336-
auto *I2 = I1->getNextNode();
1337-
auto *I3 = BB.getTerminator();
1338-
1339-
EXPECT_FALSE(bool(I1->getDebugLoc()));
1340-
I1->updateLocationAfterHoist();
1341-
EXPECT_FALSE(bool(I1->getDebugLoc()));
1342-
1343-
const MDNode *Scope = I2->getDebugLoc().getScope();
1344-
EXPECT_EQ(I2->getDebugLoc().getLine(), 2U);
1345-
I2->updateLocationAfterHoist();
1346-
EXPECT_EQ(I2->getDebugLoc().getLine(), 0U);
1347-
EXPECT_EQ(I2->getDebugLoc().getScope(), Scope);
1348-
1349-
EXPECT_EQ(I3->getDebugLoc().getLine(), 2U);
1350-
I3->updateLocationAfterHoist();
1351-
EXPECT_FALSE(bool(I3->getDebugLoc()));
1352-
}
1353-
13541307
} // end anonymous namespace
13551308
} // end namespace llvm

0 commit comments

Comments
 (0)