[llvm] 884bc6a - [X86] Modify LOOP*, HLT control flow attributes

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 2 10:35:10 PDT 2021


Author: Amir Ayupov
Date: 2021-07-02T10:34:29-07:00
New Revision: 884bc6a6ed95befa128e4bcb1a1e64cf39d73117

URL: https://github.com/llvm/llvm-project/commit/884bc6a6ed95befa128e4bcb1a1e64cf39d73117
DIFF: https://github.com/llvm/llvm-project/commit/884bc6a6ed95befa128e4bcb1a1e64cf39d73117.diff

LOG: [X86] Modify LOOP*, HLT control flow attributes

Add missing control flow attributes:
- LOOP*: isBranch, isTerminator
- HLT: isTerminator

This helps downstream disassemblers (such as BOLT) reconstruct the control
flow graph more accurately.

Reviewed By: craig.topper

Differential Revision: https://reviews.llvm.org/D102297

Added: 
    

Modified: 
    llvm/lib/Target/X86/X86InstrControl.td
    llvm/lib/Target/X86/X86InstrSystem.td

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/X86/X86InstrControl.td b/llvm/lib/Target/X86/X86InstrControl.td
index 838018ed5835..a6cb17f17a17 100644
--- a/llvm/lib/Target/X86/X86InstrControl.td
+++ b/llvm/lib/Target/X86/X86InstrControl.td
@@ -206,7 +206,7 @@ let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in {
 }
 
 // Loop instructions
-let SchedRW = [WriteJump] in {
+let isBranch = 1, isTerminator = 1, SchedRW = [WriteJump] in {
 def LOOP   : Ii8PCRel<0xE2, RawFrm, (outs), (ins brtarget8:$dst), "loop\t$dst", []>;
 def LOOPE  : Ii8PCRel<0xE1, RawFrm, (outs), (ins brtarget8:$dst), "loope\t$dst", []>;
 def LOOPNE : Ii8PCRel<0xE0, RawFrm, (outs), (ins brtarget8:$dst), "loopne\t$dst", []>;

diff  --git a/llvm/lib/Target/X86/X86InstrSystem.td b/llvm/lib/Target/X86/X86InstrSystem.td
index 32b00f52096b..48c27051a872 100644
--- a/llvm/lib/Target/X86/X86InstrSystem.td
+++ b/llvm/lib/Target/X86/X86InstrSystem.td
@@ -39,7 +39,8 @@ let mayLoad = 1, mayStore = 0, hasSideEffects = 1, isTrap = 1 in {
                    "ud1{q} {$src2, $src1|$src1, $src2}", []>, TB;
 }
 
-def HLT : I<0xF4, RawFrm, (outs), (ins), "hlt", []>;
+let isTerminator = 1 in
+  def HLT : I<0xF4, RawFrm, (outs), (ins), "hlt", []>;
 def RSM : I<0xAA, RawFrm, (outs), (ins), "rsm", []>, TB;
 
 // Interrupt and SysCall Instructions.


        


More information about the llvm-commits mailing list