summaryrefslogtreecommitdiff
path: root/lib/IRReader
diff options
context:
space:
mode:
authorAdrian Prantl <aprantl@apple.com>2017-10-02 18:31:29 +0000
committerAdrian Prantl <aprantl@apple.com>2017-10-02 18:31:29 +0000
commit733fe2f23133cccdd7bac660abd76577b0589081 (patch)
tree001487e93e5b65a1aa873a535b50696fed02eea9 /lib/IRReader
parentfc20547ae6d3528a850caf7438d4c276ab47b3be (diff)
Move the stripping of invalid debug info from the Verifier to AutoUpgrade.
This came out of a recent discussion on llvm-dev (https://reviews.llvm.org/D38042). Currently the Verifier will strip the debug info metadata from a module if it finds the dbeug info to be malformed. This feature is very valuable since it allows us to improve the Verifier by making it stricter without breaking bcompatibility, but arguable the Verifier pass should not be modifying the IR. This patch moves the stripping of broken debug info into AutoUpgrade (UpgradeDebugInfo to be precise), which is a much better location for this since the stripping of malformed (i.e., produced by older, buggy versions of Clang) is a (harsh) form of AutoUpgrade. This change is mostly NFC in nature, the one big difference is the behavior when LLVM module passes are introducing malformed debug info. Prior to this patch, a NoAsserts build would have printed a warning and stripped the debug info, after this patch the Verifier will report a fatal error. I believe this behavior is actually more desirable anyway. Differential Revision: https://reviews.llvm.org/D38184 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@314699 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/IRReader')
-rw-r--r--lib/IRReader/IRReader.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/IRReader/IRReader.cpp b/lib/IRReader/IRReader.cpp
index ba587ced718..c4ba659fd05 100644
--- a/lib/IRReader/IRReader.cpp
+++ b/lib/IRReader/IRReader.cpp
@@ -68,7 +68,8 @@ std::unique_ptr<Module> llvm::getLazyIRFileModule(StringRef Filename,
}
std::unique_ptr<Module> llvm::parseIR(MemoryBufferRef Buffer, SMDiagnostic &Err,
- LLVMContext &Context) {
+ LLVMContext &Context,
+ bool UpgradeDebugInfo) {
NamedRegionTimer T(TimeIRParsingName, TimeIRParsingDescription,
TimeIRParsingGroupName, TimeIRParsingGroupDescription,
TimePassesIsEnabled);
@@ -86,11 +87,12 @@ std::unique_ptr<Module> llvm::parseIR(MemoryBufferRef Buffer, SMDiagnostic &Err,
return std::move(ModuleOrErr.get());
}
- return parseAssembly(Buffer, Err, Context);
+ return parseAssembly(Buffer, Err, Context, nullptr, UpgradeDebugInfo);
}
std::unique_ptr<Module> llvm::parseIRFile(StringRef Filename, SMDiagnostic &Err,
- LLVMContext &Context) {
+ LLVMContext &Context,
+ bool UpgradeDebugInfo) {
ErrorOr<std::unique_ptr<MemoryBuffer>> FileOrErr =
MemoryBuffer::getFileOrSTDIN(Filename);
if (std::error_code EC = FileOrErr.getError()) {
@@ -99,7 +101,8 @@ std::unique_ptr<Module> llvm::parseIRFile(StringRef Filename, SMDiagnostic &Err,
return nullptr;
}
- return parseIR(FileOrErr.get()->getMemBufferRef(), Err, Context);
+ return parseIR(FileOrErr.get()->getMemBufferRef(), Err, Context,
+ UpgradeDebugInfo);
}
//===----------------------------------------------------------------------===//