[llvm-commits] [llvm] r166763 - in /llvm/trunk: include/llvm/CodeGen/GCMetadata.h lib/CodeGen/GCStrategy.cpp
Nicolas Geoffray
nicolas.geoffray at lip6.fr
Fri Oct 26 02:15:56 PDT 2012
Author: geoffray
Date: Fri Oct 26 04:15:55 2012
New Revision: 166763
URL: http://llvm.org/viewvc/llvm-project?rev=166763&view=rev
Log:
Remove GC roots that reference dead objects.
Modified:
llvm/trunk/include/llvm/CodeGen/GCMetadata.h
llvm/trunk/lib/CodeGen/GCStrategy.cpp
Modified: llvm/trunk/include/llvm/CodeGen/GCMetadata.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/GCMetadata.h?rev=166763&r1=166762&r2=166763&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/GCMetadata.h (original)
+++ llvm/trunk/include/llvm/CodeGen/GCMetadata.h Fri Oct 26 04:15:55 2012
@@ -122,6 +122,11 @@
Roots.push_back(GCRoot(Num, Metadata));
}
+ /// removeStackRoot - Removes a root.
+ roots_iterator removeStackRoot(roots_iterator position) {
+ return Roots.erase(position);
+ }
+
/// addSafePoint - Notes the existence of a safe point. Num is the ID of the
/// label just prior to the safe point (if the code generator is using
/// MachineModuleInfo).
Modified: llvm/trunk/lib/CodeGen/GCStrategy.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/GCStrategy.cpp?rev=166763&r1=166762&r2=166763&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/GCStrategy.cpp (original)
+++ llvm/trunk/lib/CodeGen/GCStrategy.cpp Fri Oct 26 04:15:55 2012
@@ -388,9 +388,16 @@
const TargetFrameLowering *TFI = TM->getFrameLowering();
assert(TFI && "TargetRegisterInfo not available!");
- for (GCFunctionInfo::roots_iterator RI = FI->roots_begin(),
- RE = FI->roots_end(); RI != RE; ++RI)
- RI->StackOffset = TFI->getFrameIndexOffset(MF, RI->Num);
+ for (GCFunctionInfo::roots_iterator RI = FI->roots_begin();
+ RI != FI->roots_end();) {
+ // If the root references a dead object, no need to keep it.
+ if (MF.getFrameInfo()->isDeadObjectIndex(RI->Num)) {
+ RI = FI->removeStackRoot(RI);
+ } else {
+ RI->StackOffset = TFI->getFrameIndexOffset(MF, RI->Num);
+ ++RI;
+ }
+ }
}
bool GCMachineCodeAnalysis::runOnMachineFunction(MachineFunction &MF) {
More information about the llvm-commits
mailing list