[PATCH] D27343: [framelowering] Improve tracking of first CS pop instruction.
Florian Hahn via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 6 02:35:06 PST 2016
This revision was automatically updated to reflect the committed changes.
Closed by commit rL288794: [framelowering] Improve tracking of first CS pop instruction. (authored by fhahn).
Changed prior to commit:
https://reviews.llvm.org/D27343?vs=80336&id=80393#toc
Repository:
rL LLVM
https://reviews.llvm.org/D27343
Files:
llvm/trunk/lib/Target/X86/X86FrameLowering.cpp
llvm/trunk/test/CodeGen/X86/frame-lowering-debug-intrinsic.ll
Index: llvm/trunk/test/CodeGen/X86/frame-lowering-debug-intrinsic.ll
===================================================================
--- llvm/trunk/test/CodeGen/X86/frame-lowering-debug-intrinsic.ll
+++ llvm/trunk/test/CodeGen/X86/frame-lowering-debug-intrinsic.ll
@@ -0,0 +1,41 @@
+; Test ensuring debug intrinsics do not affect generated function prologue.
+;
+; RUN: llc -O1 -mtriple=x86_64-unknown-unknown -o - %s | FileCheck %s
+
+
+define i64 @noDebug(i64 %a) {
+ %call = call i64 @fn(i64 %a, i64 0)
+ ret i64 %call
+}
+
+; CHECK-LABEL: noDebug
+; CHECK: popq %rcx
+; CHECK: ret
+
+
+define i64 @withDebug(i64 %a) !dbg !4 {
+ %call = call i64 @fn(i64 %a, i64 0)
+ tail call void @llvm.dbg.value(metadata i64 %call, i64 0, metadata !5, metadata !6), !dbg !7
+ ret i64 %call
+}
+
+; CHECK-LABEL: withDebug
+; CHECK: popq %rcx
+; CHECK: ret
+
+
+declare i64 @fn(i64, i64)
+
+declare void @llvm.dbg.value(metadata, i64, metadata, metadata)
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!2,!3}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 4.0.0")
+!1 = !DIFile(filename: "test.c", directory: "/")
+!2 = !{i32 2, !"Dwarf Version", i32 4}
+!3 = !{i32 2, !"Debug Info Version", i32 3}
+!4 = distinct !DISubprogram(name: "withDebug", unit: !0)
+!5 = !DILocalVariable(name: "w", scope: !4)
+!6 = !DIExpression()
+!7 = !DILocation(line: 210, column: 12, scope: !4)
Index: llvm/trunk/lib/Target/X86/X86FrameLowering.cpp
===================================================================
--- llvm/trunk/lib/Target/X86/X86FrameLowering.cpp
+++ llvm/trunk/lib/Target/X86/X86FrameLowering.cpp
@@ -1550,19 +1550,22 @@
}
uint64_t SEHStackAllocAmt = NumBytes;
+ MachineBasicBlock::iterator FirstCSPop = MBBI;
// Skip the callee-saved pop instructions.
while (MBBI != MBB.begin()) {
MachineBasicBlock::iterator PI = std::prev(MBBI);
unsigned Opc = PI->getOpcode();
- if ((Opc != X86::POP32r || !PI->getFlag(MachineInstr::FrameDestroy)) &&
- (Opc != X86::POP64r || !PI->getFlag(MachineInstr::FrameDestroy)) &&
- Opc != X86::DBG_VALUE && !PI->isTerminator())
- break;
+ if (Opc != X86::DBG_VALUE && !PI->isTerminator()) {
+ if ((Opc != X86::POP32r || !PI->getFlag(MachineInstr::FrameDestroy)) &&
+ (Opc != X86::POP64r || !PI->getFlag(MachineInstr::FrameDestroy)))
+ break;
+ FirstCSPop = PI;
+ }
--MBBI;
}
- MachineBasicBlock::iterator FirstCSPop = MBBI;
+ MBBI = FirstCSPop;
if (TargetMBB) {
// Fill EAX/RAX with the address of the target block.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D27343.80393.patch
Type: text/x-patch
Size: 2591 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161206/b41447ef/attachment.bin>
More information about the llvm-commits
mailing list