ShadowCallStack/x86_64: Ignore pseudo-machine instructions
authorVlad Tsyrklevich <vlad@tsyrklevich.net>
Tue, 10 Apr 2018 01:31:01 +0000 (01:31 +0000)
committerVlad Tsyrklevich <vlad@tsyrklevich.net>
Tue, 10 Apr 2018 01:31:01 +0000 (01:31 +0000)
llvm-svn: 329656

llvm/lib/Target/X86/ShadowCallStack.cpp
llvm/test/CodeGen/X86/shadow-call-stack.mir

index ba02644..9a39455 100644 (file)
@@ -242,7 +242,8 @@ bool ShadowCallStack::runOnMachineFunction(MachineFunction &Fn) {
       for (auto &LiveIn : MBB.liveins())
         UsedRegs.set(LiveIn.PhysReg);
       for (auto &MI : MBB) {
-        InstructionCount++;
+        if (!MI.isDebugValue() && !MI.isCFIInstruction() && !MI.isLabel())
+          InstructionCount++;
         for (auto &Op : MI.operands())
           if (Op.isReg() && Op.isDef())
             UsedRegs.set(Op.getReg());
index 485b970..f10fabf 100644 (file)
@@ -106,6 +106,14 @@ frameInfo:
 body: |
   ; CHECK: bb.0:
   bb.0:
+    ; Ensure these are not counted as machine instructions
+    CFI_INSTRUCTION 0
+    CFI_INSTRUCTION 0
+    CFI_INSTRUCTION 0
+    DBG_VALUE 0
+    DBG_VALUE 0
+    DBG_VALUE 0
+
     ; CHECK: $eax = MOV32ri 13
     $eax = MOV32ri 13