[PATCH] D109971: [asan] Added TargetInstrInfo::isStackAdjustIntrinsic used to identify intrinsics, which adjust the stack when lowered to native.

Kirill Stoimenov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 17 08:30:02 PDT 2021


kstoimenov created this revision.
kstoimenov added a reviewer: eugenis.
Herald added subscribers: pengfei, hiraditya.
kstoimenov requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Used in the follow-up ASan patch to identify ASan intrinsics, which adjust the stack.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D109971

Files:
  llvm/include/llvm/CodeGen/TargetInstrInfo.h
  llvm/lib/Target/X86/X86InstrInfo.cpp
  llvm/lib/Target/X86/X86InstrInfo.h


Index: llvm/lib/Target/X86/X86InstrInfo.h
===================================================================
--- llvm/lib/Target/X86/X86InstrInfo.h
+++ llvm/lib/Target/X86/X86InstrInfo.h
@@ -172,6 +172,9 @@
   /// sequences involving PUSHes.
   int getSPAdjust(const MachineInstr &MI) const override;
 
+  // On X86 platform returns true for instrinsics lowered to calls.
+  bool isStackAdjustIntrinsic(const MachineInstr &MI) const override;
+
   /// isCoalescableExtInstr - Return true if the instruction is a "coalescable"
   /// extension instruction. That is, it's like a copy where it's legal for the
   /// source to overlap the destination. e.g. X86::MOVSX64rr32. If this returns
Index: llvm/lib/Target/X86/X86InstrInfo.cpp
===================================================================
--- llvm/lib/Target/X86/X86InstrInfo.cpp
+++ llvm/lib/Target/X86/X86InstrInfo.cpp
@@ -672,6 +672,12 @@
   }
 }
 
+/// Returns true for the sanitizer access check as it will be lowered to
+// a call.
+bool X86InstrInfo::isStackAdjustIntrinsic(const MachineInstr &MI) const {
+  return MI.getOpcode() == X86::ASAN_CHECK_MEMACCESS;
+}
+
 /// Return true and the FrameIndex if the specified
 /// operand and follow operands form a reference to the stack frame.
 bool X86InstrInfo::isFrameOperand(const MachineInstr &MI, unsigned int Op,
Index: llvm/include/llvm/CodeGen/TargetInstrInfo.h
===================================================================
--- llvm/include/llvm/CodeGen/TargetInstrInfo.h
+++ llvm/include/llvm/CodeGen/TargetInstrInfo.h
@@ -244,6 +244,12 @@
   /// to enable more fine-grained adjustment, or adjust by a different value.
   virtual int getSPAdjust(const MachineInstr &MI) const;
 
+  /// Returns true if the instruction is an intrinsic which will be lowered to
+  /// an natitive instruction manupulating the stack.
+  virtual bool isStackAdjustIntrinsic(const MachineInstr &MI) const {
+    return false;
+  }
+
   /// Return true if the instruction is a "coalescable" extension instruction.
   /// That is, it's like a copy where it's legal for the source to overlap the
   /// destination. e.g. X86::MOVSX64rr32. If this returns true, then it's


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D109971.373235.patch
Type: text/x-patch
Size: 2176 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210917/f5d25e2f/attachment.bin>


More information about the llvm-commits mailing list