diff options
| author | Adrian Prantl <aprantl@apple.com> | 2017-10-02 18:31:29 +0000 |
|---|---|---|
| committer | Adrian Prantl <aprantl@apple.com> | 2017-10-02 18:31:29 +0000 |
| commit | a8b2ddbde453fab0db90be21b9a1ff961a7770e0 (patch) | |
| tree | 190712a839a2ce48d61e75501d2f68440891a2d8 /llvm/include | |
| parent | 6e17c00a88e23d0cc4cb491bfd0830f3df7fff66 (diff) | |
| download | bcm5719-llvm-a8b2ddbde453fab0db90be21b9a1ff961a7770e0.tar.gz bcm5719-llvm-a8b2ddbde453fab0db90be21b9a1ff961a7770e0.zip | |
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
llvm-svn: 314699
Diffstat (limited to 'llvm/include')
| -rw-r--r-- | llvm/include/llvm/AsmParser/Parser.h | 28 | ||||
| -rw-r--r-- | llvm/include/llvm/IRReader/IRReader.h | 12 |
2 files changed, 31 insertions, 9 deletions
diff --git a/llvm/include/llvm/AsmParser/Parser.h b/llvm/include/llvm/AsmParser/Parser.h index 768b089b8a2..5f02e488e5b 100644 --- a/llvm/include/llvm/AsmParser/Parser.h +++ b/llvm/include/llvm/AsmParser/Parser.h @@ -36,10 +36,12 @@ class Type; /// \param Context Context in which to allocate globals info. /// \param Slots The optional slot mapping that will be initialized during /// parsing. -std::unique_ptr<Module> parseAssemblyFile(StringRef Filename, - SMDiagnostic &Error, - LLVMContext &Context, - SlotMapping *Slots = nullptr); +/// \param UpgradeDebugInfo Run UpgradeDebugInfo, which runs the Verifier. +/// This option should only be set to false by llvm-as +/// for use inside the LLVM testuite! +std::unique_ptr<Module> +parseAssemblyFile(StringRef Filename, SMDiagnostic &Error, LLVMContext &Context, + SlotMapping *Slots = nullptr, bool UpgradeDebugInfo = true); /// The function is a secondary interface to the LLVM Assembly Parser. It parses /// an ASCII string that (presumably) contains LLVM Assembly code. It returns a @@ -52,10 +54,14 @@ std::unique_ptr<Module> parseAssemblyFile(StringRef Filename, /// \param Context Context in which to allocate globals info. /// \param Slots The optional slot mapping that will be initialized during /// parsing. +/// \param UpgradeDebugInfo Run UpgradeDebugInfo, which runs the Verifier. +/// This option should only be set to false by llvm-as +/// for use inside the LLVM testuite! std::unique_ptr<Module> parseAssemblyString(StringRef AsmString, SMDiagnostic &Error, LLVMContext &Context, - SlotMapping *Slots = nullptr); + SlotMapping *Slots = nullptr, + bool UpgradeDebugInfo = true); /// parseAssemblyFile and parseAssemblyString are wrappers around this function. /// \brief Parse LLVM Assembly from a MemoryBuffer. @@ -63,9 +69,13 @@ std::unique_ptr<Module> parseAssemblyString(StringRef AsmString, /// \param Err Error result info. /// \param Slots The optional slot mapping that will be initialized during /// parsing. +/// \param UpgradeDebugInfo Run UpgradeDebugInfo, which runs the Verifier. +/// This option should only be set to false by llvm-as +/// for use inside the LLVM testuite! std::unique_ptr<Module> parseAssembly(MemoryBufferRef F, SMDiagnostic &Err, LLVMContext &Context, - SlotMapping *Slots = nullptr); + SlotMapping *Slots = nullptr, + bool UpgradeDebugInfo = true); /// This function is the low-level interface to the LLVM Assembly Parser. /// This is kept as an independent function instead of being inlined into @@ -78,8 +88,12 @@ std::unique_ptr<Module> parseAssembly(MemoryBufferRef F, SMDiagnostic &Err, /// \param Slots The optional slot mapping that will be initialized during /// parsing. /// \return true on error. +/// \param UpgradeDebugInfo Run UpgradeDebugInfo, which runs the Verifier. +/// This option should only be set to false by llvm-as +/// for use inside the LLVM testuite! bool parseAssemblyInto(MemoryBufferRef F, Module &M, SMDiagnostic &Err, - SlotMapping *Slots = nullptr); + SlotMapping *Slots = nullptr, + bool UpgradeDebugInfo = true); /// Parse a type and a constant value in the given string. /// diff --git a/llvm/include/llvm/IRReader/IRReader.h b/llvm/include/llvm/IRReader/IRReader.h index 7b24ec11fb6..f5621647db0 100644 --- a/llvm/include/llvm/IRReader/IRReader.h +++ b/llvm/include/llvm/IRReader/IRReader.h @@ -37,14 +37,22 @@ getLazyIRFileModule(StringRef Filename, SMDiagnostic &Err, LLVMContext &Context, /// If the given MemoryBuffer holds a bitcode image, return a Module /// for it. Otherwise, attempt to parse it as LLVM Assembly and return /// a Module for it. +/// \param UpgradeDebugInfo Run UpgradeDebugInfo, which runs the Verifier. +/// This option should only be set to false by llvm-as +/// for use inside the LLVM testuite! std::unique_ptr<Module> parseIR(MemoryBufferRef Buffer, SMDiagnostic &Err, - LLVMContext &Context); + LLVMContext &Context, + bool UpgradeDebugInfo = true); /// If the given file holds a bitcode image, return a Module for it. /// Otherwise, attempt to parse it as LLVM Assembly and return a Module /// for it. +/// \param UpgradeDebugInfo Run UpgradeDebugInfo, which runs the Verifier. +/// This option should only be set to false by llvm-as +/// for use inside the LLVM testuite! std::unique_ptr<Module> parseIRFile(StringRef Filename, SMDiagnostic &Err, - LLVMContext &Context); + LLVMContext &Context, + bool UpgradeDebugInfo = true); } #endif |

