mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-29 10:32:47 +00:00
2bdb23849b
This change reverts the interesting parts of 226311 (and 227046). This change introduced two problems, and I've been convinced that an alternate approach is preferrable anyways. The bugs were: - Registery appears to require all users be within the same linkage unit. After this change, asking for "statepoint-example" in Transform/ would sometimes get you nullptr, whereas asking the same question in CodeGen would return the right GCStrategy. The correct long term fix is to get rid of the utter hack which is Registry, but I don't have time for that right now. 227046 appears to have been an attempt to fix this, but I don't believe it does so completely. - GCMetadataPrinter::finishAssembly was being called more than once per GCStrategy. Each Strategy was being added to the GCModuleInfo multiple times. Once I get time again, I'm going to split GCModuleInfo into the gc.root specific part and a GCStrategy owning Analysis pass. I'm probably also going to kill off the Registry. Once that's done, I'll move the new GCStrategyAnalysis and all built in GCStrategies into Analysis. (As original suggested by Chandler.) This will accomplish my original goal of being able to access GCStrategy from Transform/ without adding all of the builtin GCs to IR/. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@227109 91177308-0d34-0410-b5e6-96231b3b80d8
56 lines
2.0 KiB
C++
56 lines
2.0 KiB
C++
//===-- StatepointDefaultGC.cpp - The default statepoint GC strategy ------===//
|
|
//
|
|
// The LLVM Compiler Infrastructure
|
|
//
|
|
// This file is distributed under the University of Illinois Open Source
|
|
// License. See LICENSE.TXT for details.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
// This file contains a GCStrategy which serves as an example for the usage
|
|
// of a statepoint based lowering strategy. This GCStrategy is intended to
|
|
// suitable as a default implementation usable with any collector which can
|
|
// consume the standard stackmap format generated by statepoints, uses the
|
|
// default addrespace to distinguish between gc managed and non-gc managed
|
|
// pointers, and has reasonable relocation semantics.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "llvm/CodeGen/GCStrategy.h"
|
|
#include "llvm/IR/DerivedTypes.h"
|
|
#include "llvm/IR/Value.h"
|
|
|
|
using namespace llvm;
|
|
|
|
namespace {
|
|
class StatepointGC : public GCStrategy {
|
|
public:
|
|
StatepointGC() {
|
|
UseStatepoints = true;
|
|
// These options are all gc.root specific, we specify them so that the
|
|
// gc.root lowering code doesn't run.
|
|
InitRoots = false;
|
|
NeededSafePoints = 0;
|
|
UsesMetadata = false;
|
|
CustomRoots = false;
|
|
}
|
|
Optional<bool> isGCManagedPointer(const Value *V) const override {
|
|
// Method is only valid on pointer typed values.
|
|
PointerType *PT = cast<PointerType>(V->getType());
|
|
// For the sake of this example GC, we arbitrarily pick addrspace(1) as our
|
|
// GC managed heap. We know that a pointer into this heap needs to be
|
|
// updated and that no other pointer does. Note that addrspace(1) is used
|
|
// only as an example, it has no special meaning, and is not reserved for
|
|
// GC usage.
|
|
return (1 == PT->getAddressSpace());
|
|
}
|
|
};
|
|
}
|
|
|
|
static GCRegistry::Add<StatepointGC> X("statepoint-example",
|
|
"an example strategy for statepoint");
|
|
|
|
namespace llvm {
|
|
void linkStatepointExampleGC() {}
|
|
}
|