Add a -suppress-warnings option to bitcode linking.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@200927 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Eli Bendersky 2014-02-06 18:01:56 +00:00
parent efcc736270
commit 6984ee6aa2

View File

@ -19,12 +19,18 @@
#include "llvm/IR/Constants.h" #include "llvm/IR/Constants.h"
#include "llvm/IR/Module.h" #include "llvm/IR/Module.h"
#include "llvm/IR/TypeFinder.h" #include "llvm/IR/TypeFinder.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Debug.h" #include "llvm/Support/Debug.h"
#include "llvm/Support/raw_ostream.h" #include "llvm/Support/raw_ostream.h"
#include "llvm/Transforms/Utils/Cloning.h" #include "llvm/Transforms/Utils/Cloning.h"
#include <cctype> #include <cctype>
using namespace llvm; using namespace llvm;
static cl::opt<bool>
SuppressWarnings("suppress-warnings", cl::desc("Suppress all linking warnings"),
cl::init(false));
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// TypeMap implementation. // TypeMap implementation.
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
@ -1134,8 +1140,10 @@ bool ModuleLinker::linkModuleFlagsMetadata() {
case Module::Warning: { case Module::Warning: {
// Emit a warning if the values differ. // Emit a warning if the values differ.
if (SrcOp->getOperand(2) != DstOp->getOperand(2)) { if (SrcOp->getOperand(2) != DstOp->getOperand(2)) {
errs() << "WARNING: linking module flags '" << ID->getString() if (!SuppressWarnings) {
<< "': IDs have conflicting values"; errs() << "WARNING: linking module flags '" << ID->getString()
<< "': IDs have conflicting values";
}
} }
continue; continue;
} }
@ -1201,15 +1209,20 @@ bool ModuleLinker::run() {
DstM->setTargetTriple(SrcM->getTargetTriple()); DstM->setTargetTriple(SrcM->getTargetTriple());
if (!SrcM->getDataLayout().empty() && !DstM->getDataLayout().empty() && if (!SrcM->getDataLayout().empty() && !DstM->getDataLayout().empty() &&
SrcM->getDataLayout() != DstM->getDataLayout()) SrcM->getDataLayout() != DstM->getDataLayout()) {
errs() << "WARNING: Linking two modules of different data layouts!\n"; if (!SuppressWarnings) {
errs() << "WARNING: Linking two modules of different data layouts!\n";
}
}
if (!SrcM->getTargetTriple().empty() && if (!SrcM->getTargetTriple().empty() &&
DstM->getTargetTriple() != SrcM->getTargetTriple()) { DstM->getTargetTriple() != SrcM->getTargetTriple()) {
errs() << "WARNING: Linking two modules of different target triples: "; if (!SuppressWarnings) {
if (!SrcM->getModuleIdentifier().empty()) errs() << "WARNING: Linking two modules of different target triples: ";
errs() << SrcM->getModuleIdentifier() << ": "; if (!SrcM->getModuleIdentifier().empty())
errs() << "'" << SrcM->getTargetTriple() << "' and '" errs() << SrcM->getModuleIdentifier() << ": ";
<< DstM->getTargetTriple() << "'\n"; errs() << "'" << SrcM->getTargetTriple() << "' and '"
<< DstM->getTargetTriple() << "'\n";
}
} }
// Append the module inline asm string. // Append the module inline asm string.