[IR][NFC] Rename getBaseObject to getAliaseeObject
To better reflect the meaning of the now-disambiguated {GlobalValue,
GlobalAlias}::getBaseObject after breaking off GlobalIFunc::getResolverFunction
(D109792), the function is renamed to getAliaseeObject.
This commit is contained in:
parent
6707a7d7e9
commit
40ec1c0f16
|
|
@ -1844,7 +1844,7 @@ llvm::GlobalVariable *MicrosoftCXXABI::getAddrOfVTable(const CXXRecordDecl *RD,
|
|||
VFTablesMap[ID] = VFTable;
|
||||
VTable = VTableAliasIsRequred
|
||||
? cast<llvm::GlobalVariable>(
|
||||
cast<llvm::GlobalAlias>(VFTable)->getBaseObject())
|
||||
cast<llvm::GlobalAlias>(VFTable)->getAliaseeObject())
|
||||
: cast<llvm::GlobalVariable>(VFTable);
|
||||
return VTable;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -77,10 +77,10 @@ public:
|
|||
return getIndirectSymbol();
|
||||
}
|
||||
|
||||
const GlobalObject *getBaseObject() const;
|
||||
GlobalObject *getBaseObject() {
|
||||
const GlobalObject *getAliaseeObject() const;
|
||||
GlobalObject *getAliaseeObject() {
|
||||
return const_cast<GlobalObject *>(
|
||||
static_cast<const GlobalAlias *>(this)->getBaseObject());
|
||||
static_cast<const GlobalAlias *>(this)->getAliaseeObject());
|
||||
}
|
||||
|
||||
static bool isValidLinkage(LinkageTypes L) {
|
||||
|
|
|
|||
|
|
@ -57,10 +57,10 @@ public:
|
|||
static_cast<const GlobalIndirectSymbol *>(this)->getIndirectSymbol());
|
||||
}
|
||||
|
||||
const GlobalObject *getBaseObject() const;
|
||||
GlobalObject *getBaseObject() {
|
||||
const GlobalObject *getAliaseeObject() const;
|
||||
GlobalObject *getAliaseeObject() {
|
||||
return const_cast<GlobalObject *>(
|
||||
static_cast<const GlobalIndirectSymbol *>(this)->getBaseObject());
|
||||
static_cast<const GlobalIndirectSymbol *>(this)->getAliaseeObject());
|
||||
}
|
||||
|
||||
// Methods for support type inquiry through isa, cast, and dyn_cast:
|
||||
|
|
|
|||
|
|
@ -554,10 +554,10 @@ public:
|
|||
return !(isDeclarationForLinker() || isWeakForLinker());
|
||||
}
|
||||
|
||||
const GlobalObject *getBaseObject() const;
|
||||
GlobalObject *getBaseObject() {
|
||||
const GlobalObject *getAliaseeObject() const;
|
||||
GlobalObject *getAliaseeObject() {
|
||||
return const_cast<GlobalObject *>(
|
||||
static_cast<const GlobalValue *>(this)->getBaseObject());
|
||||
static_cast<const GlobalValue *>(this)->getAliaseeObject());
|
||||
}
|
||||
|
||||
/// Returns whether this is a reference to an absolute symbol.
|
||||
|
|
|
|||
|
|
@ -342,7 +342,7 @@ static void computeFunctionSummary(
|
|||
// called aliasee for the checks below.
|
||||
if (auto *GA = dyn_cast<GlobalAlias>(CalledValue)) {
|
||||
assert(!CalledFunction && "Expected null called function in callsite for alias");
|
||||
CalledFunction = dyn_cast<Function>(GA->getBaseObject());
|
||||
CalledFunction = dyn_cast<Function>(GA->getAliaseeObject());
|
||||
}
|
||||
// Check if this is a direct call to a known function or a known
|
||||
// intrinsic, or an indirect call with profile data.
|
||||
|
|
@ -645,7 +645,7 @@ computeAliasSummary(ModuleSummaryIndex &Index, const GlobalAlias &A,
|
|||
/* Live = */ false, A.isDSOLocal(),
|
||||
A.hasLinkOnceODRLinkage() && A.hasGlobalUnnamedAddr());
|
||||
auto AS = std::make_unique<AliasSummary>(Flags);
|
||||
auto *Aliasee = A.getBaseObject();
|
||||
auto *Aliasee = A.getAliaseeObject();
|
||||
auto AliaseeVI = Index.getValueInfo(Aliasee->getGUID());
|
||||
assert(AliaseeVI && "Alias expects aliasee summary to be available");
|
||||
assert(AliaseeVI.getSummaryList().size() == 1 &&
|
||||
|
|
|
|||
|
|
@ -685,7 +685,7 @@ const Function *findCalleeInModule(const GlobalValue *GV) {
|
|||
const GlobalAlias *A = dyn_cast<GlobalAlias>(GV);
|
||||
if (!A)
|
||||
return nullptr;
|
||||
GV = A->getBaseObject();
|
||||
GV = A->getAliaseeObject();
|
||||
if (GV == A)
|
||||
return nullptr;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4039,7 +4039,7 @@ void ModuleBitcodeWriterBase::writePerModuleGlobalValueSummary() {
|
|||
FSModVTableRefsAbbrev);
|
||||
|
||||
for (const GlobalAlias &A : M.aliases()) {
|
||||
auto *Aliasee = A.getBaseObject();
|
||||
auto *Aliasee = A.getAliaseeObject();
|
||||
if (!Aliasee->hasName())
|
||||
// Nameless function don't have an entry in the summary, skip it.
|
||||
continue;
|
||||
|
|
|
|||
|
|
@ -1666,9 +1666,9 @@ void AsmPrinter::emitGlobalIndirectSymbol(Module &M,
|
|||
// size of the alias symbol from the type of the alias. We don't do this in
|
||||
// other situations as the alias and aliasee having differing types but same
|
||||
// size may be intentional.
|
||||
const GlobalObject *BaseObject = GA->getBaseObject();
|
||||
const GlobalObject *Aliasee = GA->getAliaseeObject();
|
||||
if (MAI->hasDotTypeDotSizeDirective() && GA->getValueType()->isSized() &&
|
||||
(!BaseObject || BaseObject->hasPrivateLinkage())) {
|
||||
(!Aliasee || Aliasee->hasPrivateLinkage())) {
|
||||
const DataLayout &DL = M.getDataLayout();
|
||||
uint64_t Size = DL.getTypeAllocSize(GA->getValueType());
|
||||
OutStreamer->emitELFSize(Name, MCConstantExpr::create(Size, OutContext));
|
||||
|
|
|
|||
|
|
@ -1495,7 +1495,7 @@ void TargetLoweringObjectFileMachO::getNameWithPrefix(
|
|||
SmallVectorImpl<char> &OutName, const GlobalValue *GV,
|
||||
const TargetMachine &TM) const {
|
||||
bool CannotUsePrivateLabel = true;
|
||||
if (auto *GO = GV->getBaseObject()) {
|
||||
if (auto *GO = GV->getAliaseeObject()) {
|
||||
SectionKind GOKind = TargetLoweringObjectFile::getKindForGlobal(GO, TM);
|
||||
const MCSection *TheSection = SectionForGlobal(GO, GOKind, TM);
|
||||
CannotUsePrivateLabel =
|
||||
|
|
@ -1566,7 +1566,7 @@ static int getSelectionForCOFF(const GlobalValue *GV) {
|
|||
if (const Comdat *C = GV->getComdat()) {
|
||||
const GlobalValue *ComdatKey = getComdatGVForCOFF(GV);
|
||||
if (const auto *GA = dyn_cast<GlobalAlias>(ComdatKey))
|
||||
ComdatKey = GA->getBaseObject();
|
||||
ComdatKey = GA->getAliaseeObject();
|
||||
if (ComdatKey == GV) {
|
||||
switch (C->getSelectionKind()) {
|
||||
case Comdat::Any:
|
||||
|
|
@ -2490,12 +2490,12 @@ TargetLoweringObjectFileXCOFF::getStorageClassForGlobal(const GlobalValue *GV) {
|
|||
|
||||
MCSymbol *TargetLoweringObjectFileXCOFF::getFunctionEntryPointSymbol(
|
||||
const GlobalValue *Func, const TargetMachine &TM) const {
|
||||
assert(
|
||||
(isa<Function>(Func) ||
|
||||
(isa<GlobalAlias>(Func) &&
|
||||
isa_and_nonnull<Function>(cast<GlobalAlias>(Func)->getBaseObject()))) &&
|
||||
"Func must be a function or an alias which has a function as base "
|
||||
"object.");
|
||||
assert((isa<Function>(Func) ||
|
||||
(isa<GlobalAlias>(Func) &&
|
||||
isa_and_nonnull<Function>(
|
||||
cast<GlobalAlias>(Func)->getAliaseeObject()))) &&
|
||||
"Func must be a function or an alias which has a function as base "
|
||||
"object.");
|
||||
|
||||
SmallString<128> NameStr;
|
||||
NameStr.push_back('.');
|
||||
|
|
|
|||
|
|
@ -162,7 +162,7 @@ std::string GlobalValue::getGlobalIdentifier() const {
|
|||
StringRef GlobalValue::getSection() const {
|
||||
if (auto *GA = dyn_cast<GlobalAlias>(this)) {
|
||||
// In general we cannot compute this at the IR level, but we try.
|
||||
if (const GlobalObject *GO = GA->getBaseObject())
|
||||
if (const GlobalObject *GO = GA->getAliaseeObject())
|
||||
return GO->getSection();
|
||||
return "";
|
||||
}
|
||||
|
|
@ -172,7 +172,7 @@ StringRef GlobalValue::getSection() const {
|
|||
const Comdat *GlobalValue::getComdat() const {
|
||||
if (auto *GA = dyn_cast<GlobalAlias>(this)) {
|
||||
// In general we cannot compute this at the IR level, but we try.
|
||||
if (const GlobalObject *GO = GA->getBaseObject())
|
||||
if (const GlobalObject *GO = GA->getAliaseeObject())
|
||||
return const_cast<GlobalObject *>(GO)->getComdat();
|
||||
return nullptr;
|
||||
}
|
||||
|
|
@ -280,11 +280,11 @@ bool GlobalObject::canIncreaseAlignment() const {
|
|||
return true;
|
||||
}
|
||||
|
||||
const GlobalObject *GlobalValue::getBaseObject() const {
|
||||
const GlobalObject *GlobalValue::getAliaseeObject() const {
|
||||
if (auto *GO = dyn_cast<GlobalObject>(this))
|
||||
return GO;
|
||||
if (auto *GA = dyn_cast<GlobalAlias>(this))
|
||||
return GA->getBaseObject();
|
||||
return GA->getAliaseeObject();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
|
@ -519,7 +519,7 @@ void GlobalAlias::setAliasee(Constant *Aliasee) {
|
|||
setIndirectSymbol(Aliasee);
|
||||
}
|
||||
|
||||
const GlobalObject *GlobalAlias::getBaseObject() const {
|
||||
const GlobalObject *GlobalAlias::getAliaseeObject() const {
|
||||
DenseSet<const GlobalAlias *> Aliases;
|
||||
return findBaseObject(getOperand(0), Aliases);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -733,7 +733,7 @@ LTO::addRegularLTO(BitcodeModule BM, ArrayRef<InputFile::Symbol> Syms,
|
|||
|
||||
DenseSet<GlobalObject *> AliasedGlobals;
|
||||
for (auto &GA : M.aliases())
|
||||
if (GlobalObject *GO = GA.getBaseObject())
|
||||
if (GlobalObject *GO = GA.getAliaseeObject())
|
||||
AliasedGlobals.insert(GO);
|
||||
|
||||
// In this function we need IR GlobalValues matching the symbols in Syms
|
||||
|
|
|
|||
|
|
@ -133,7 +133,7 @@ bool ModuleLinker::getComdatLeader(Module &M, StringRef ComdatName,
|
|||
const GlobalVariable *&GVar) {
|
||||
const GlobalValue *GVal = M.getNamedValue(ComdatName);
|
||||
if (const auto *GA = dyn_cast_or_null<GlobalAlias>(GVal)) {
|
||||
GVal = GA->getBaseObject();
|
||||
GVal = GA->getAliaseeObject();
|
||||
if (!GVal)
|
||||
// We cannot resolve the size of the aliasee yet.
|
||||
return emitError("Linking COMDATs named '" + ComdatName +
|
||||
|
|
|
|||
|
|
@ -283,15 +283,15 @@ Error Builder::addSymbol(const ModuleSymbolTable &Msymtab,
|
|||
Uncommon().CommonAlign = GVar->getAlignment();
|
||||
}
|
||||
|
||||
const GlobalObject *Base = GV->getBaseObject();
|
||||
if (!Base) {
|
||||
const GlobalObject *GO = GV->getAliaseeObject();
|
||||
if (!GO) {
|
||||
if (isa<GlobalIFunc>(GV))
|
||||
Base = cast<GlobalIFunc>(GV)->getResolverFunction();
|
||||
if (!Base)
|
||||
GO = cast<GlobalIFunc>(GV)->getResolverFunction();
|
||||
if (!GO)
|
||||
return make_error<StringError>("Unable to determine comdat of alias!",
|
||||
inconvertibleErrorCode());
|
||||
}
|
||||
if (const Comdat *C = Base->getComdat()) {
|
||||
if (const Comdat *C = GO->getComdat()) {
|
||||
Expected<int> ComdatIndexOrErr = getComdatIndex(C, GV->getParent());
|
||||
if (!ComdatIndexOrErr)
|
||||
return ComdatIndexOrErr.takeError();
|
||||
|
|
@ -316,8 +316,8 @@ Error Builder::addSymbol(const ModuleSymbolTable &Msymtab,
|
|||
}
|
||||
}
|
||||
|
||||
if (!Base->getSection().empty())
|
||||
setStr(Uncommon().SectionName, Saver.save(Base->getSection()));
|
||||
if (!GO->getSection().empty())
|
||||
setStr(Uncommon().SectionName, Saver.save(GO->getSection()));
|
||||
|
||||
return Error::success();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -204,7 +204,7 @@ uint32_t ModuleSymbolTable::getSymbolFlags(Symbol S) const {
|
|||
if (GVar->isConstant())
|
||||
Res |= BasicSymbolRef::SF_Const;
|
||||
}
|
||||
if (isa_and_nonnull<Function>(GV->getBaseObject()) || isa<GlobalIFunc>(GV))
|
||||
if (isa_and_nonnull<Function>(GV->getAliaseeObject()) || isa<GlobalIFunc>(GV))
|
||||
Res |= BasicSymbolRef::SF_Executable;
|
||||
if (isa<GlobalAlias>(GV))
|
||||
Res |= BasicSymbolRef::SF_Indirect;
|
||||
|
|
|
|||
|
|
@ -3801,7 +3801,7 @@ static SDValue promoteToConstantPool(const ARMTargetLowering *TLI,
|
|||
|
||||
bool ARMTargetLowering::isReadOnly(const GlobalValue *GV) const {
|
||||
if (const GlobalAlias *GA = dyn_cast<GlobalAlias>(GV))
|
||||
if (!(GV = GA->getBaseObject()))
|
||||
if (!(GV = GA->getAliaseeObject()))
|
||||
return false;
|
||||
if (const auto *V = dyn_cast<GlobalVariable>(GV))
|
||||
return V->isConstant();
|
||||
|
|
|
|||
|
|
@ -1231,7 +1231,7 @@ HexagonTargetLowering::LowerGLOBALADDRESS(SDValue Op, SelectionDAG &DAG) const {
|
|||
|
||||
if (RM == Reloc::Static) {
|
||||
SDValue GA = DAG.getTargetGlobalAddress(GV, dl, PtrVT, Offset);
|
||||
const GlobalObject *GO = GV->getBaseObject();
|
||||
const GlobalObject *GO = GV->getAliaseeObject();
|
||||
if (GO && Subtarget.useSmallData() && HLOF.isGlobalInSmallSection(GO, HTM))
|
||||
return DAG.getNode(HexagonISD::CONST32_GP, dl, PtrVT, GA);
|
||||
return DAG.getNode(HexagonISD::CONST32, dl, PtrVT, GA);
|
||||
|
|
|
|||
|
|
@ -1176,7 +1176,7 @@ SDValue LanaiTargetLowering::LowerGlobalAddress(SDValue Op,
|
|||
|
||||
// If the code model is small or global variable will be placed in the small
|
||||
// section, then assume address will fit in 21-bits.
|
||||
const GlobalObject *GO = GV->getBaseObject();
|
||||
const GlobalObject *GO = GV->getAliaseeObject();
|
||||
if (TLOF->isGlobalInSmallSection(GO, getTargetMachine())) {
|
||||
SDValue Small = DAG.getTargetGlobalAddress(
|
||||
GV, DL, getPointerTy(DAG.getDataLayout()), Offset, LanaiII::MO_NO_FLAG);
|
||||
|
|
|
|||
|
|
@ -2076,7 +2076,7 @@ SDValue MipsTargetLowering::lowerGlobalAddress(SDValue Op,
|
|||
const MipsTargetObjectFile *TLOF =
|
||||
static_cast<const MipsTargetObjectFile *>(
|
||||
getTargetMachine().getObjFileLowering());
|
||||
const GlobalObject *GO = GV->getBaseObject();
|
||||
const GlobalObject *GO = GV->getAliaseeObject();
|
||||
if (GO && TLOF->IsGlobalInSmallSection(GO, getTargetMachine()))
|
||||
// %gp_rel relocation
|
||||
return getAddrGPRel(N, SDLoc(N), Ty, DAG, ABI.IsN64());
|
||||
|
|
|
|||
|
|
@ -2528,7 +2528,7 @@ bool PPCAIXAsmPrinter::doInitialization(Module &M) {
|
|||
|
||||
// Construct an aliasing list for each GlobalObject.
|
||||
for (const auto &Alias : M.aliases()) {
|
||||
const GlobalObject *Base = Alias.getBaseObject();
|
||||
const GlobalObject *Base = Alias.getAliaseeObject();
|
||||
if (!Base)
|
||||
report_fatal_error(
|
||||
"alias without a base object is not yet supported on AIX");
|
||||
|
|
|
|||
|
|
@ -4643,7 +4643,7 @@ static bool callsShareTOCBase(const Function *Caller, SDValue Callee,
|
|||
|
||||
// If we have an Alias we can try to get the function from there.
|
||||
if (Alias) {
|
||||
const GlobalObject *GlobalObj = Alias->getBaseObject();
|
||||
const GlobalObject *GlobalObj = Alias->getAliaseeObject();
|
||||
F = dyn_cast<Function>(GlobalObj);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1184,7 +1184,7 @@ void llvm::thinLTOInternalizeModule(Module &TheModule,
|
|||
|
||||
/// Make alias a clone of its aliasee.
|
||||
static Function *replaceAliasWithAliasee(Module *SrcModule, GlobalAlias *GA) {
|
||||
Function *Fn = cast<Function>(GA->getBaseObject());
|
||||
Function *Fn = cast<Function>(GA->getAliaseeObject());
|
||||
|
||||
ValueToValueMapTy VMap;
|
||||
Function *NewFn = CloneFunction(Fn, VMap);
|
||||
|
|
@ -1290,12 +1290,12 @@ Expected<bool> FunctionImporter::importFunctions(
|
|||
if (Error Err = GA.materialize())
|
||||
return std::move(Err);
|
||||
// Import alias as a copy of its aliasee.
|
||||
GlobalObject *Base = GA.getBaseObject();
|
||||
if (Error Err = Base->materialize())
|
||||
GlobalObject *GO = GA.getAliaseeObject();
|
||||
if (Error Err = GO->materialize())
|
||||
return std::move(Err);
|
||||
auto *Fn = replaceAliasWithAliasee(SrcModule.get(), &GA);
|
||||
LLVM_DEBUG(dbgs() << "Is importing aliasee fn " << Base->getGUID()
|
||||
<< " " << Base->getName() << " from "
|
||||
LLVM_DEBUG(dbgs() << "Is importing aliasee fn " << GO->getGUID() << " "
|
||||
<< GO->getName() << " from "
|
||||
<< SrcModule->getSourceFileName() << "\n");
|
||||
if (EnableImportMetadata) {
|
||||
// Add 'thinlto_src_module' metadata for statistics and debugging.
|
||||
|
|
|
|||
|
|
@ -323,7 +323,8 @@ void splitAndWriteThinLTOBitcode(
|
|||
return true;
|
||||
if (auto *F = dyn_cast<Function>(GV))
|
||||
return EligibleVirtualFns.count(F);
|
||||
if (auto *GVar = dyn_cast_or_null<GlobalVariable>(GV->getBaseObject()))
|
||||
if (auto *GVar =
|
||||
dyn_cast_or_null<GlobalVariable>(GV->getAliaseeObject()))
|
||||
return HasTypeMetadata(GVar);
|
||||
return false;
|
||||
}));
|
||||
|
|
@ -352,7 +353,7 @@ void splitAndWriteThinLTOBitcode(
|
|||
// Remove all globals with type metadata, globals with comdats that live in
|
||||
// MergedM, and aliases pointing to such globals from the thin LTO module.
|
||||
filterModule(&M, [&](const GlobalValue *GV) {
|
||||
if (auto *GVar = dyn_cast_or_null<GlobalVariable>(GV->getBaseObject()))
|
||||
if (auto *GVar = dyn_cast_or_null<GlobalVariable>(GV->getAliaseeObject()))
|
||||
if (HasTypeMetadata(GVar))
|
||||
return false;
|
||||
if (const auto *C = GV->getComdat())
|
||||
|
|
|
|||
|
|
@ -1430,7 +1430,7 @@ bool DataFlowSanitizer::runImpl(Module &M) {
|
|||
++AI;
|
||||
// Don't stop on weak. We assume people aren't playing games with the
|
||||
// instrumentedness of overridden weak aliases.
|
||||
auto *F = dyn_cast<Function>(GA->getBaseObject());
|
||||
auto *F = dyn_cast<Function>(GA->getAliaseeObject());
|
||||
if (!F)
|
||||
continue;
|
||||
|
||||
|
|
|
|||
|
|
@ -126,8 +126,8 @@ static void findPartitions(Module &M, ClusterIDMapType &ClusterIDMap,
|
|||
// For aliases we should not separate them from their aliasees regardless
|
||||
// of linkage.
|
||||
if (auto *GIS = dyn_cast<GlobalAlias>(&GV)) {
|
||||
if (const GlobalObject *Base = GIS->getBaseObject())
|
||||
GVtoClusterMap.unionSets(&GV, Base);
|
||||
if (const GlobalObject *Aliasee = GIS->getAliaseeObject())
|
||||
GVtoClusterMap.unionSets(&GV, Aliasee);
|
||||
} else if (auto *GIS = dyn_cast<GlobalIFunc>(&GV)) {
|
||||
GVtoClusterMap.unionSets(&GV, GIS->getResolverFunction());
|
||||
}
|
||||
|
|
@ -228,7 +228,7 @@ static void externalize(GlobalValue *GV) {
|
|||
// Returns whether GV should be in partition (0-based) I of N.
|
||||
static bool isInPartition(const GlobalValue *GV, unsigned I, unsigned N) {
|
||||
if (auto *GIS = dyn_cast<GlobalAlias>(GV)) {
|
||||
if (const GlobalObject *Base = GIS->getBaseObject())
|
||||
if (const GlobalObject *Base = GIS->getAliaseeObject())
|
||||
GV = Base;
|
||||
} else if (auto *GIS = dyn_cast<GlobalIFunc>(GV)) {
|
||||
GV = GIS->getResolverFunction();
|
||||
|
|
|
|||
|
|
@ -269,7 +269,7 @@ bool ReduceCrashingFunctions::TestFuncs(std::vector<Function *> &Funcs) {
|
|||
std::vector<GlobalValue *> ToRemove;
|
||||
// First, remove aliases to functions we're about to purge.
|
||||
for (GlobalAlias &Alias : M->aliases()) {
|
||||
GlobalObject *Root = Alias.getBaseObject();
|
||||
GlobalObject *Root = Alias.getAliaseeObject();
|
||||
Function *F = dyn_cast_or_null<Function>(Root);
|
||||
if (F) {
|
||||
if (Functions.count(F))
|
||||
|
|
|
|||
Loading…
Reference in New Issue