From 0adede059ed76940700195342bb5b02c79e58516 Mon Sep 17 00:00:00 2001 From: Gordon Henriksen Date: Sat, 22 Dec 2007 23:32:32 +0000 Subject: Document a more robust implementation of performCustomLowering. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45326 91177308-0d34-0410-b5e6-96231b3b80d8 --- docs/GarbageCollection.html | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) (limited to 'docs/GarbageCollection.html') diff --git a/docs/GarbageCollection.html b/docs/GarbageCollection.html index 4b5bd50aca..c9324859ba 100644 --- a/docs/GarbageCollection.html +++ b/docs/GarbageCollection.html @@ -1084,37 +1084,35 @@ href="WritingAnLLVMPass.html#doInitialization_mod">doInitialization(Module
#include "llvm/Module.h"
-#include "llvm/Instructions.h"
+#include "llvm/IntrinsicInst.h"
 
 bool MyCollector::initializeCustomLowering(Module &M) {
   return false;
 }
 
 bool MyCollector::performCustomLowering(Function &F) {
-  const Module *M = F.getParent();
-  
-  Function *GCReadInt  = M->getFunction("llvm.gcread"),
-           *GCWriteInt = M->getFunction("llvm.gcwrite"),
-           *GCRootInt  = M->getFunction("llvm.gcroot");
-  
   bool MadeChange = false;
   
   for (Function::iterator BB = F.begin(), E = F.end(); BB != E; ++BB)
-    for (BasicBlock::iterator II = BB->begin(), E = BB->end(); II != E;)
-      if (CallInst *CI = dyn_cast<CallInst>(II++))
-        if (Function *F = CI->getCalledFunction())
-          if (F == GCWriteInt) {
+    for (BasicBlock::iterator II = BB->begin(), E = BB->end(); II != E; ++II)
+      if (IntrinsicInst *CI = dyn_cast<IntrinsicInst>(II))
+        if (Function *F = CI->getCalledFunction())
+          switch (F->getIntrinsicID()) {
+          case Intrinsic::gcwrite:
             // Handle llvm.gcwrite.
-            CI->eraseFromParent();
+            CI->eraseFromParent();
             MadeChange = true;
-          } else if (F == GCReadInt) {
+            break;
+          case Intrinsic::gcread:
             // Handle llvm.gcread.
-            CI->eraseFromParent();
+            CI->eraseFromParent();
             MadeChange = true;
-          } else if (F == GCRootInt) {
+            break;
+          case Intrinsic::gcroot:
             // Handle llvm.gcroot.
-            CI->eraseFromParent();
+            CI->eraseFromParent();
             MadeChange = true;
+            break;
           }
   
   return MadeChange;
-- 
cgit v1.2.3