summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicolas Geoffray <nicolas.geoffray@lip6.fr>2012-10-26 09:15:55 +0000
committerNicolas Geoffray <nicolas.geoffray@lip6.fr>2012-10-26 09:15:55 +0000
commit457b356f3ab2b846fb95a43a34da63aec5e56c74 (patch)
tree0b39633df51a41260f56f6dca624dd242248a57a
parent4027f238eb0181178c668213c65276729f20873f (diff)
downloadbcm5719-llvm-457b356f3ab2b846fb95a43a34da63aec5e56c74.tar.gz
bcm5719-llvm-457b356f3ab2b846fb95a43a34da63aec5e56c74.zip
Remove GC roots that reference dead objects.
llvm-svn: 166763
-rw-r--r--llvm/include/llvm/CodeGen/GCMetadata.h5
-rw-r--r--llvm/lib/CodeGen/GCStrategy.cpp13
2 files changed, 15 insertions, 3 deletions
diff --git a/llvm/include/llvm/CodeGen/GCMetadata.h b/llvm/include/llvm/CodeGen/GCMetadata.h
index 20e33f74f65..076f6f39fe2 100644
--- a/llvm/include/llvm/CodeGen/GCMetadata.h
+++ b/llvm/include/llvm/CodeGen/GCMetadata.h
@@ -122,6 +122,11 @@ namespace llvm {
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).
diff --git a/llvm/lib/CodeGen/GCStrategy.cpp b/llvm/lib/CodeGen/GCStrategy.cpp
index 8de541de3d9..f4755bb1635 100644
--- a/llvm/lib/CodeGen/GCStrategy.cpp
+++ b/llvm/lib/CodeGen/GCStrategy.cpp
@@ -388,9 +388,16 @@ void GCMachineCodeAnalysis::FindStackOffsets(MachineFunction &MF) {
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) {
OpenPOWER on IntegriCloud