forked from OSchip/llvm-project
[IR] Change maybeSetDSOLocal to isImplicitDSOLocal
This allows some simplification.
This commit is contained in:
parent
43874c365f
commit
a35b7288b1
|
@ -146,12 +146,6 @@ private:
|
|||
llvm_unreachable("Fully covered switch above!");
|
||||
}
|
||||
|
||||
void maybeSetDsoLocal() {
|
||||
if (hasLocalLinkage() ||
|
||||
(!hasDefaultVisibility() && !hasExternalWeakLinkage()))
|
||||
setDSOLocal(true);
|
||||
}
|
||||
|
||||
protected:
|
||||
/// The intrinsic ID for this subclass (which must be a Function).
|
||||
///
|
||||
|
@ -243,7 +237,8 @@ public:
|
|||
assert((!hasLocalLinkage() || V == DefaultVisibility) &&
|
||||
"local linkage requires default visibility");
|
||||
Visibility = V;
|
||||
maybeSetDsoLocal();
|
||||
if (isImplicitDSOLocal())
|
||||
setDSOLocal(true);
|
||||
}
|
||||
|
||||
/// If the value is "Thread Local", its value isn't shared by the threads.
|
||||
|
@ -278,6 +273,11 @@ public:
|
|||
|
||||
Type *getValueType() const { return ValueType; }
|
||||
|
||||
bool isImplicitDSOLocal() const {
|
||||
return hasLocalLinkage() ||
|
||||
(!hasDefaultVisibility() && !hasExternalWeakLinkage());
|
||||
}
|
||||
|
||||
void setDSOLocal(bool Local) { IsDSOLocal = Local; }
|
||||
|
||||
bool isDSOLocal() const {
|
||||
|
@ -455,7 +455,8 @@ public:
|
|||
if (isLocalLinkage(LT))
|
||||
Visibility = DefaultVisibility;
|
||||
Linkage = LT;
|
||||
maybeSetDsoLocal();
|
||||
if (isImplicitDSOLocal())
|
||||
setDSOLocal(true);
|
||||
}
|
||||
LinkageTypes getLinkage() const { return LinkageTypes(Linkage); }
|
||||
|
||||
|
|
|
@ -3210,11 +3210,7 @@ static void PrintVisibility(GlobalValue::VisibilityTypes Vis,
|
|||
|
||||
static void PrintDSOLocation(const GlobalValue &GV,
|
||||
formatted_raw_ostream &Out) {
|
||||
// GVs with local linkage or non default visibility are implicitly dso_local,
|
||||
// so we don't print it.
|
||||
bool Implicit = GV.hasLocalLinkage() ||
|
||||
(!GV.hasExternalWeakLinkage() && !GV.hasDefaultVisibility());
|
||||
if (GV.isDSOLocal() && !Implicit)
|
||||
if (GV.isDSOLocal() && !GV.isImplicitDSOLocal())
|
||||
Out << "dso_local ";
|
||||
}
|
||||
|
||||
|
|
|
@ -590,15 +590,12 @@ void Verifier::visitGlobalValue(const GlobalValue &GV) {
|
|||
"Global is marked as dllimport, but not external", &GV);
|
||||
}
|
||||
|
||||
if (GV.hasLocalLinkage())
|
||||
if (GV.isImplicitDSOLocal())
|
||||
Assert(GV.isDSOLocal(),
|
||||
"GlobalValue with private or internal linkage must be dso_local!",
|
||||
"GlobalValue with local linkage or non-default "
|
||||
"visibility must be dso_local!",
|
||||
&GV);
|
||||
|
||||
if (!GV.hasDefaultVisibility() && !GV.hasExternalWeakLinkage())
|
||||
Assert(GV.isDSOLocal(),
|
||||
"GlobalValue with non default visibility must be dso_local!", &GV);
|
||||
|
||||
forEachUser(&GV, GlobalValueVisited, [&](const Value *V) -> bool {
|
||||
if (const Instruction *I = dyn_cast<Instruction>(V)) {
|
||||
if (!I->getParent() || !I->getParent()->getParent())
|
||||
|
|
Loading…
Reference in New Issue