[llvm] 6450580 - [SafeStack, NFC] Use IntrinsicInst instead of Instruction

Vitaly Buka via llvm-commits llvm-commits at lists.llvm.org
Sun Jun 14 23:15:02 PDT 2020


Author: Vitaly Buka
Date: 2020-06-14T23:05:41-07:00
New Revision: 645058036aedd241762487ed56ed73a1d8858875

URL: https://github.com/llvm/llvm-project/commit/645058036aedd241762487ed56ed73a1d8858875
DIFF: https://github.com/llvm/llvm-project/commit/645058036aedd241762487ed56ed73a1d8858875.diff

LOG: [SafeStack,NFC] Use IntrinsicInst instead of Instruction

Added: 
    

Modified: 
    llvm/lib/CodeGen/SafeStackColoring.cpp
    llvm/lib/CodeGen/SafeStackColoring.h

Removed: 
    


################################################################################
diff  --git a/llvm/lib/CodeGen/SafeStackColoring.cpp b/llvm/lib/CodeGen/SafeStackColoring.cpp
index 75aad268a018..d5ef92ff7499 100644
--- a/llvm/lib/CodeGen/SafeStackColoring.cpp
+++ b/llvm/lib/CodeGen/SafeStackColoring.cpp
@@ -53,7 +53,7 @@ void StackColoring::removeAllMarkers() {
 
 void StackColoring::collectMarkers() {
   InterestingAllocas.resize(NumAllocas);
-  DenseMap<BasicBlock *, SmallDenseMap<Instruction *, Marker>> BBMarkerSet;
+  DenseMap<BasicBlock *, SmallDenseMap<IntrinsicInst *, Marker>> BBMarkerSet;
 
   // Compute the set of start/end markers per basic block.
   for (unsigned AllocaNo = 0; AllocaNo < NumAllocas; ++AllocaNo) {
@@ -67,7 +67,7 @@ void StackColoring::collectMarkers() {
           WorkList.push_back(BI);
           continue;
         }
-        auto *UI = dyn_cast<Instruction>(U);
+        auto *UI = dyn_cast<IntrinsicInst>(U);
         if (!UI)
           continue;
         bool IsStart;
@@ -107,7 +107,7 @@ void StackColoring::collectMarkers() {
       continue;
     }
 
-    auto ProcessMarker = [&](Instruction *I, const Marker &M) {
+    auto ProcessMarker = [&](IntrinsicInst *I, const Marker &M) {
       LLVM_DEBUG(dbgs() << "  " << InstNo << ":  "
                         << (M.IsStart ? "start " : "end   ") << M.AllocaNo
                         << ", " << *I << "\n");
@@ -133,10 +133,13 @@ void StackColoring::collectMarkers() {
     } else {
       // Scan the BB to determine the marker order.
       for (Instruction &I : *BB) {
-        auto It = BlockMarkerSet.find(&I);
+        IntrinsicInst *II = dyn_cast<IntrinsicInst>(&I);
+        if (!II)
+          continue;
+        auto It = BlockMarkerSet.find(II);
         if (It == BlockMarkerSet.end())
           continue;
-        ProcessMarker(&I, It->getSecond());
+        ProcessMarker(II, It->getSecond());
       }
     }
 

diff  --git a/llvm/lib/CodeGen/SafeStackColoring.h b/llvm/lib/CodeGen/SafeStackColoring.h
index 05de021038dd..926756d6a1d7 100644
--- a/llvm/lib/CodeGen/SafeStackColoring.h
+++ b/llvm/lib/CodeGen/SafeStackColoring.h
@@ -13,6 +13,7 @@
 #include "llvm/ADT/BitVector.h"
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/SmallVector.h"
+#include "llvm/IR/IntrinsicInst.h"
 #include "llvm/Support/raw_ostream.h"
 #include <cassert>
 #include <utility>
@@ -95,7 +96,7 @@ class StackColoring {
   /// The set of allocas that have at least one lifetime.start. All other
   /// allocas get LiveRange that corresponds to the entire function.
   BitVector InterestingAllocas;
-  SmallVector<Instruction *, 8> Markers;
+  SmallVector<IntrinsicInst *, 8> Markers;
 
   struct Marker {
     unsigned AllocaNo;
@@ -109,7 +110,7 @@ class StackColoring {
   void dumpBlockLiveness();
   void dumpLiveRanges();
 
-  bool readMarker(Instruction *I, bool *IsStart);
+  bool readMarker(Instruction *II, bool *IsStart);
   void collectMarkers();
   void calculateLocalLiveness();
   void calculateLiveIntervals();


        


More information about the llvm-commits mailing list