|
@@ -69,6 +69,30 @@ void GlobalValue::copyAttributesFrom(const GlobalValue *Src) {
|
|
|
setDLLStorageClass(Src->getDLLStorageClass());
|
|
|
}
|
|
|
|
|
|
+void GlobalValue::removeFromParent() {
|
|
|
+ switch (getValueID()) {
|
|
|
+#define HANDLE_GLOBAL_VALUE(NAME) \
|
|
|
+ case Value::NAME##Val: \
|
|
|
+ return static_cast<NAME *>(this)->removeFromParent();
|
|
|
+#include "llvm/IR/Value.def"
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ llvm_unreachable("not a global");
|
|
|
+}
|
|
|
+
|
|
|
+void GlobalValue::eraseFromParent() {
|
|
|
+ switch (getValueID()) {
|
|
|
+#define HANDLE_GLOBAL_VALUE(NAME) \
|
|
|
+ case Value::NAME##Val: \
|
|
|
+ return static_cast<NAME *>(this)->eraseFromParent();
|
|
|
+#include "llvm/IR/Value.def"
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ llvm_unreachable("not a global");
|
|
|
+}
|
|
|
+
|
|
|
unsigned GlobalValue::getAlignment() const {
|
|
|
if (auto *GA = dyn_cast<GlobalAlias>(this)) {
|
|
|
// In general we cannot compute this at the IR level, but we try.
|
|
@@ -93,12 +117,10 @@ void GlobalObject::setAlignment(unsigned Align) {
|
|
|
assert(getAlignment() == Align && "Alignment representation error!");
|
|
|
}
|
|
|
|
|
|
-void GlobalObject::copyAttributesFrom(const GlobalValue *Src) {
|
|
|
+void GlobalObject::copyAttributesFrom(const GlobalObject *Src) {
|
|
|
GlobalValue::copyAttributesFrom(Src);
|
|
|
- if (const auto *GV = dyn_cast<GlobalObject>(Src)) {
|
|
|
- setAlignment(GV->getAlignment());
|
|
|
- setSection(GV->getSection());
|
|
|
- }
|
|
|
+ setAlignment(Src->getAlignment());
|
|
|
+ setSection(Src->getSection());
|
|
|
}
|
|
|
|
|
|
std::string GlobalValue::getGlobalIdentifier(StringRef Name,
|
|
@@ -333,13 +355,11 @@ void GlobalVariable::setInitializer(Constant *InitVal) {
|
|
|
|
|
|
/// Copy all additional attributes (those not needed to create a GlobalVariable)
|
|
|
/// from the GlobalVariable Src to this one.
|
|
|
-void GlobalVariable::copyAttributesFrom(const GlobalValue *Src) {
|
|
|
+void GlobalVariable::copyAttributesFrom(const GlobalVariable *Src) {
|
|
|
GlobalObject::copyAttributesFrom(Src);
|
|
|
- if (const GlobalVariable *SrcVar = dyn_cast<GlobalVariable>(Src)) {
|
|
|
- setThreadLocalMode(SrcVar->getThreadLocalMode());
|
|
|
- setExternallyInitialized(SrcVar->isExternallyInitialized());
|
|
|
- setAttributes(SrcVar->getAttributes());
|
|
|
- }
|
|
|
+ setThreadLocalMode(Src->getThreadLocalMode());
|
|
|
+ setExternallyInitialized(Src->isExternallyInitialized());
|
|
|
+ setAttributes(Src->getAttributes());
|
|
|
}
|
|
|
|
|
|
void GlobalVariable::dropAllReferences() {
|