This allows some simplification.
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).
///
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.
Type *getValueType() const { return ValueType; }
+ bool isImplicitDSOLocal() const {
+ return hasLocalLinkage() ||
+ (!hasDefaultVisibility() && !hasExternalWeakLinkage());
+ }
+
void setDSOLocal(bool Local) { IsDSOLocal = Local; }
bool isDSOLocal() const {
if (isLocalLinkage(LT))
Visibility = DefaultVisibility;
Linkage = LT;
- maybeSetDsoLocal();
+ if (isImplicitDSOLocal())
+ setDSOLocal(true);
}
LinkageTypes getLinkage() const { return LinkageTypes(Linkage); }
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 ";
}
"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())