mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2026-04-21 23:17:16 +00:00
Refactor duplicated code.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@214328 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -25,6 +25,7 @@
|
||||
#include "llvm/Support/ErrorHandling.h"
|
||||
#include "llvm/Support/MathExtras.h"
|
||||
#include "llvm/Target/TargetLowering.h"
|
||||
#include "llvm/Transforms/Utils/GlobalStatus.h"
|
||||
using namespace llvm;
|
||||
|
||||
/// ComputeLinearIndex - Given an LLVM IR aggregate type and a sequence
|
||||
@@ -606,3 +607,29 @@ bool llvm::returnTypeIsEligibleForTailCall(const Function *F,
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool llvm::canBeOmittedFromSymbolTable(const GlobalValue *GV) {
|
||||
if (!GV->hasLinkOnceODRLinkage())
|
||||
return false;
|
||||
|
||||
if (GV->hasUnnamedAddr())
|
||||
return true;
|
||||
|
||||
// If it is a non constant variable, it needs to be uniqued across shared
|
||||
// objects.
|
||||
if (const GlobalVariable *Var = dyn_cast<GlobalVariable>(GV)) {
|
||||
if (!Var->isConstant())
|
||||
return false;
|
||||
}
|
||||
|
||||
// An alias can point to a variable. We could try to resolve the alias to
|
||||
// decide, but for now just don't hide them.
|
||||
if (isa<GlobalAlias>(GV))
|
||||
return false;
|
||||
|
||||
GlobalStatus GS;
|
||||
if (GlobalStatus::analyzeGlobal(GV, GS))
|
||||
return false;
|
||||
|
||||
return !GS.IsCompared;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user