summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp
diff options
context:
space:
mode:
authorGeorge Rimar <grimar@accesssoftek.com>2018-02-07 08:46:36 +0000
committerGeorge Rimar <grimar@accesssoftek.com>2018-02-07 08:46:36 +0000
commit545652491d51f44acef2adf4d009c8e6c324445a (patch)
tree17ac24b0c0ec56bffc63004840051285347b2f8e /llvm/lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp
parentc9b6c5c67dd10333ddc36b223d75fe000556ad21 (diff)
downloadbcm5719-llvm-545652491d51f44acef2adf4d009c8e6c324445a.tar.gz
bcm5719-llvm-545652491d51f44acef2adf4d009c8e6c324445a.zip
Revert r324455 "[ThinLTO] - Simplify code in ThinLTOBitcodeWriter."
It broke BB: http://lab.llvm.org:8011/builders/sanitizer-windows/builds/23721 llvm-svn: 324458
Diffstat (limited to 'llvm/lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp')
-rw-r--r--llvm/lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp48
1 files changed, 37 insertions, 11 deletions
diff --git a/llvm/lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp b/llvm/lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp
index 27ef6b3e4b4..d2ce97abdd4 100644
--- a/llvm/lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp
+++ b/llvm/lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp
@@ -23,7 +23,6 @@
#include "llvm/Support/raw_ostream.h"
#include "llvm/Transforms/IPO.h"
#include "llvm/Transforms/IPO/FunctionAttrs.h"
-#include "llvm/Transforms/IPO/FunctionImport.h"
#include "llvm/Transforms/Utils/Cloning.h"
#include "llvm/Transforms/Utils/ModuleUtils.h"
using namespace llvm;
@@ -170,18 +169,45 @@ void simplifyExternals(Module &M) {
}
}
-static void
-filterModule(Module *M,
- function_ref<bool(const GlobalValue *)> ShouldKeepDefinition) {
- auto I = M->global_values().begin();
- auto E = M->global_values().end();
- while (I != E) {
- GlobalValue &GV = *I++;
- if (ShouldKeepDefinition(&GV))
+void filterModule(
+ Module *M, function_ref<bool(const GlobalValue *)> ShouldKeepDefinition) {
+ for (Module::alias_iterator I = M->alias_begin(), E = M->alias_end();
+ I != E;) {
+ GlobalAlias *GA = &*I++;
+ if (ShouldKeepDefinition(GA))
continue;
- if (convertToDeclaration(GV))
+
+ GlobalObject *GO;
+ if (GA->getValueType()->isFunctionTy())
+ GO = Function::Create(cast<FunctionType>(GA->getValueType()),
+ GlobalValue::ExternalLinkage, "", M);
+ else
+ GO = new GlobalVariable(
+ *M, GA->getValueType(), false, GlobalValue::ExternalLinkage,
+ nullptr, "", nullptr,
+ GA->getThreadLocalMode(), GA->getType()->getAddressSpace());
+ GO->takeName(GA);
+ GA->replaceAllUsesWith(GO);
+ GA->eraseFromParent();
+ }
+
+ for (Function &F : *M) {
+ if (ShouldKeepDefinition(&F))
continue;
- GV.eraseFromParent();
+
+ F.deleteBody();
+ F.setComdat(nullptr);
+ F.clearMetadata();
+ }
+
+ for (GlobalVariable &GV : M->globals()) {
+ if (ShouldKeepDefinition(&GV))
+ continue;
+
+ GV.setInitializer(nullptr);
+ GV.setLinkage(GlobalValue::ExternalLinkage);
+ GV.setComdat(nullptr);
+ GV.clearMetadata();
}
}
OpenPOWER on IntegriCloud