aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Christopher <echristo@apple.com>2012-10-02 21:16:50 +0000
committerEric Christopher <echristo@apple.com>2012-10-02 21:16:50 +0000
commit96bd4418b2320dec7cf9573c4f1da0a0ef31465e (patch)
tree1899e9b59191e4a1f7f54d70278b0bb063bf2d22
parentdf5f0fbc27923be610bed35c32ba8ba91f5699ce (diff)
Remove the SavePoint infrastructure from fast isel, replace
with just an insert point from the MachineBasicBlock and let the location be updated as we access it. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@165049 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/llvm/CodeGen/FastISel.h9
-rw-r--r--lib/CodeGen/SelectionDAG/FastISel.cpp27
-rw-r--r--lib/Target/X86/X86FastISel.cpp4
-rw-r--r--test/DebugInfo/X86/constant-mat.ll65
4 files changed, 85 insertions, 20 deletions
diff --git a/include/llvm/CodeGen/FastISel.h b/include/llvm/CodeGen/FastISel.h
index 7cb96952aa..7f240f563a 100644
--- a/include/llvm/CodeGen/FastISel.h
+++ b/include/llvm/CodeGen/FastISel.h
@@ -131,17 +131,12 @@ public:
/// into the current block.
void recomputeInsertPt();
- struct SavePoint {
- MachineBasicBlock::iterator InsertPt;
- DebugLoc DL;
- };
-
/// enterLocalValueArea - Prepare InsertPt to begin inserting instructions
/// into the local value area and return the old insert position.
- SavePoint enterLocalValueArea();
+ MachineBasicBlock::iterator enterLocalValueArea();
/// leaveLocalValueArea - Reset InsertPt to the given old insert position.
- void leaveLocalValueArea(SavePoint Old);
+ void leaveLocalValueArea(MachineBasicBlock::iterator Old);
virtual ~FastISel();
diff --git a/lib/CodeGen/SelectionDAG/FastISel.cpp b/lib/CodeGen/SelectionDAG/FastISel.cpp
index 683fac6744..818940490f 100644
--- a/lib/CodeGen/SelectionDAG/FastISel.cpp
+++ b/lib/CodeGen/SelectionDAG/FastISel.cpp
@@ -149,13 +149,13 @@ unsigned FastISel::getRegForValue(const Value *V) {
!FuncInfo.StaticAllocaMap.count(cast<AllocaInst>(V))))
return FuncInfo.InitializeRegForValue(V);
- SavePoint SaveInsertPt = enterLocalValueArea();
+ MachineBasicBlock::iterator SaveIter = enterLocalValueArea();
// Materialize the value in a register. Emit any instructions in the
// local value area.
Reg = materializeRegForValue(V, VT);
- leaveLocalValueArea(SaveInsertPt);
+ leaveLocalValueArea(SaveIter);
return Reg;
}
@@ -238,7 +238,16 @@ unsigned FastISel::lookUpRegForValue(const Value *V) {
DenseMap<const Value *, unsigned>::iterator I = FuncInfo.ValueMap.find(V);
if (I != FuncInfo.ValueMap.end())
return I->second;
- return LocalValueMap[V];
+ unsigned Reg = LocalValueMap[V];
+
+ // If we managed to find a register here then go ahead and replace the
+ // current location with the location we're currently emitted for,
+ // 'moving' the value to a place that's closer to where it originally
+ // started.
+ if (Reg)
+ MRI.getVRegDef(Reg)->setDebugLoc(DL);
+
+ return Reg;
}
/// UpdateValueMap - Update the value map to include the new mapping for this
@@ -316,22 +325,18 @@ void FastISel::removeDeadCode(MachineBasicBlock::iterator I,
recomputeInsertPt();
}
-FastISel::SavePoint FastISel::enterLocalValueArea() {
+MachineBasicBlock::iterator FastISel::enterLocalValueArea() {
MachineBasicBlock::iterator OldInsertPt = FuncInfo.InsertPt;
- DebugLoc OldDL = DL;
recomputeInsertPt();
- DL = DebugLoc();
- SavePoint SP = { OldInsertPt, OldDL };
- return SP;
+ return OldInsertPt;
}
-void FastISel::leaveLocalValueArea(SavePoint OldInsertPt) {
+void FastISel::leaveLocalValueArea(MachineBasicBlock::iterator I) {
if (FuncInfo.InsertPt != FuncInfo.MBB->begin())
LastLocalValue = llvm::prior(FuncInfo.InsertPt);
// Restore the previous insert position.
- FuncInfo.InsertPt = OldInsertPt.InsertPt;
- DL = OldInsertPt.DL;
+ FuncInfo.InsertPt = I;
}
/// SelectBinaryOp - Select and emit code for a binary operator instruction,
diff --git a/lib/Target/X86/X86FastISel.cpp b/lib/Target/X86/X86FastISel.cpp
index 54704d84a9..83f2f6a202 100644
--- a/lib/Target/X86/X86FastISel.cpp
+++ b/lib/Target/X86/X86FastISel.cpp
@@ -545,7 +545,7 @@ bool X86FastISel::X86SelectAddress(const Value *V, X86AddressMode &AM) {
StubAM.GVOpFlags = GVFlags;
// Prepare for inserting code in the local-value area.
- SavePoint SaveInsertPt = enterLocalValueArea();
+ MachineBasicBlock::iterator SaveIter = enterLocalValueArea();
if (TLI.getPointerTy() == MVT::i64) {
Opc = X86::MOV64rm;
@@ -564,7 +564,7 @@ bool X86FastISel::X86SelectAddress(const Value *V, X86AddressMode &AM) {
addFullAddress(LoadMI, StubAM);
// Ok, back to normal mode.
- leaveLocalValueArea(SaveInsertPt);
+ leaveLocalValueArea(SaveIter);
// Prevent loading GV stub multiple times in same MBB.
LocalValueMap[V] = LoadReg;
diff --git a/test/DebugInfo/X86/constant-mat.ll b/test/DebugInfo/X86/constant-mat.ll
new file mode 100644
index 0000000000..8cf2d16fa4
--- /dev/null
+++ b/test/DebugInfo/X86/constant-mat.ll
@@ -0,0 +1,65 @@
+; RUN: llc -disable-fp-elim -O0 %s -mtriple x86_64-unknown-linux-gnu -o - | FileCheck %s
+
+; int callme(int);
+;
+; int isel_line_test(int arg)
+; {
+; callme(100);
+; if (arg > 5000)
+; callme(200);
+; callme(300);
+; return 0;
+; }
+
+define i32 @isel_line_test(i32 %arg) nounwind uwtable {
+; The start of each non-entry block (or sub-block) should get a .loc directive.
+; CHECK: isel_line_test:
+; CHECK: # BB#1:
+; CHECK-NEXT: .loc 1 7 5
+; CHECK: LBB0_2:
+; CHECK-NEXT: .loc 1 8 3
+; CHECK: callq callme
+; CHECK-NEXT: .loc 1 9 3
+
+entry:
+ %arg.addr = alloca i32, align 4
+ store i32 %arg, i32* %arg.addr, align 4
+ call void @llvm.dbg.declare(metadata !{i32* %arg.addr}, metadata !10), !dbg !11
+ %call = call i32 @callme(i32 100), !dbg !12
+ %0 = load i32* %arg.addr, align 4, !dbg !14
+ %cmp = icmp sgt i32 %0, 5000, !dbg !14
+ br i1 %cmp, label %if.then, label %if.end, !dbg !14
+
+if.then: ; preds = %entry
+ %call1 = call i32 @callme(i32 200), !dbg !15
+ br label %if.end, !dbg !15
+
+if.end: ; preds = %if.then, %entry
+ %call2 = call i32 @callme(i32 300), !dbg !16
+ ret i32 0, !dbg !17
+}
+
+declare void @llvm.dbg.declare(metadata, metadata) nounwind readnone
+
+declare i32 @callme(i32)
+
+!llvm.dbg.cu = !{!0}
+
+!0 = metadata !{i32 786449, i32 0, i32 12, metadata !"foo.c", metadata !"/usr/local/google/home/echristo/tmp", metadata !"clang version 3.2 (trunk 164952) (llvm/trunk 164949)", i1 true, i1 false, metadata !"", i32 0, metadata !1, metadata !1, metadata !3, metadata !1} ; [ DW_TAG_compile_unit ] [/usr/local/google/home/echristo/tmp/foo.c] [DW_LANG_C99]
+!1 = metadata !{metadata !2}
+!2 = metadata !{i32 0}
+!3 = metadata !{metadata !4}
+!4 = metadata !{metadata !5}
+!5 = metadata !{i32 786478, i32 0, metadata !6, metadata !"isel_line_test", metadata !"isel_line_test", metadata !"", metadata !6, i32 3, metadata !7, i1 false, i1 true, i32 0, i32 0, null, i32 256, i1 false, i32 (i32)* @isel_line_test, null, null, metadata !1, i32 4} ; [ DW_TAG_subprogram ] [line 3] [def] [scope 4] [isel_line_test]
+!6 = metadata !{i32 786473, metadata !"foo.c", metadata !"/usr/local/google/home/echristo/tmp", null} ; [ DW_TAG_file_type ]
+!7 = metadata !{i32 786453, i32 0, metadata !"", i32 0, i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !8, i32 0, i32 0} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ]
+!8 = metadata !{metadata !9, metadata !9}
+!9 = metadata !{i32 786468, null, metadata !"int", null, i32 0, i64 32, i64 32, i64 0, i32 0, i32 5} ; [ DW_TAG_base_type ] [int] [line 0, size 32, align 32, offset 0, enc DW_ATE_signed]
+!10 = metadata !{i32 786689, metadata !5, metadata !"arg", metadata !6, i32 16777219, metadata !9, i32 0, i32 0} ; [ DW_TAG_arg_variable ] [arg] [line 3]
+!11 = metadata !{i32 3, i32 24, metadata !5, null}
+!12 = metadata !{i32 5, i32 3, metadata !13, null}
+!13 = metadata !{i32 786443, metadata !5, i32 4, i32 1, metadata !6, i32 0} ; [ DW_TAG_lexical_block ] [/usr/local/google/home/echristo/tmp/foo.c]
+!14 = metadata !{i32 6, i32 3, metadata !13, null}
+!15 = metadata !{i32 7, i32 5, metadata !13, null}
+!16 = metadata !{i32 8, i32 3, metadata !13, null}
+!17 = metadata !{i32 9, i32 3, metadata !13, null}