[llvm-commits] [llvm] r45326 - /llvm/trunk/docs/GarbageCollection.html
Gordon Henriksen
gordonhenriksen at mac.com
Sat Dec 22 15:32:33 PST 2007
Author: gordon
Date: Sat Dec 22 17:32:32 2007
New Revision: 45326
URL: http://llvm.org/viewvc/llvm-project?rev=45326&view=rev
Log:
Document a more robust implementation of performCustomLowering.
Modified:
llvm/trunk/docs/GarbageCollection.html
Modified: llvm/trunk/docs/GarbageCollection.html
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/GarbageCollection.html?rev=45326&r1=45325&r2=45326&view=diff
==============================================================================
--- llvm/trunk/docs/GarbageCollection.html (original)
+++ llvm/trunk/docs/GarbageCollection.html Sat Dec 22 17:32:32 2007
@@ -1084,37 +1084,35 @@
<blockquote><pre
>#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;
More information about the llvm-commits
mailing list