[llvm] fdf8cb9 - [Bitcode] Handle invalid data layout gracefully
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 7 03:28:23 PST 2022
Author: Nikita Popov
Date: 2022-02-07T12:28:15+01:00
New Revision: fdf8cb978f985f8d19c6b1e6ed97adec1dfd0e06
URL: https://github.com/llvm/llvm-project/commit/fdf8cb978f985f8d19c6b1e6ed97adec1dfd0e06
DIFF: https://github.com/llvm/llvm-project/commit/fdf8cb978f985f8d19c6b1e6ed97adec1dfd0e06.diff
LOG: [Bitcode] Handle invalid data layout gracefully
Added:
Modified:
llvm/lib/Bitcode/Reader/BitcodeReader.cpp
llvm/test/Bitcode/invalid-functionptr-align.ll
Removed:
################################################################################
diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
index c24dcf030deb..33f0f87108d9 100644
--- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
+++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
@@ -3800,7 +3800,10 @@ Error BitcodeReader::parseModule(uint64_t ResumeBit,
std::string S;
if (convertToString(Record, 0, S))
return error("Invalid record");
- TheModule->setDataLayout(S);
+ Expected<DataLayout> MaybeDL = DataLayout::parse(S);
+ if (!MaybeDL)
+ return MaybeDL.takeError();
+ TheModule->setDataLayout(MaybeDL.get());
break;
}
case bitc::MODULE_CODE_ASM: { // ASM: [strchr x N]
diff --git a/llvm/test/Bitcode/invalid-functionptr-align.ll b/llvm/test/Bitcode/invalid-functionptr-align.ll
index be7ce49e4d53..8b446d371f6f 100644
--- a/llvm/test/Bitcode/invalid-functionptr-align.ll
+++ b/llvm/test/Bitcode/invalid-functionptr-align.ll
@@ -1,5 +1,5 @@
; Bitcode with invalid function pointer alignment.
-; RUN: not --crash llvm-dis %s.bc -o - 2>&1 | FileCheck %s
+; RUN: not llvm-dis %s.bc -o - 2>&1 | FileCheck %s
-CHECK: LLVM ERROR: Alignment is neither 0 nor a power of 2
+CHECK: error: Alignment is neither 0 nor a power of 2
More information about the llvm-commits
mailing list