mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-05-23 11:38:38 +00:00
Bitcode: Use unsigned char to record MDStrings
`MDString`s can have arbitrary characters in them. Prevent an assertion that fired in `BitcodeWriter` because of sign extension by copying the characters into the record as `unsigned char`s. Based on a patch by Keno Fischer; fixes PR21882. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@224077 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
033d8ea7a9
commit
4bedb48751
@ -91,6 +91,13 @@ namespace llvm {
|
|||||||
|
|
||||||
iterator end() const { return Data + Length; }
|
iterator end() const { return Data + Length; }
|
||||||
|
|
||||||
|
const unsigned char *bytes_begin() const {
|
||||||
|
return reinterpret_cast<const unsigned char *>(begin());
|
||||||
|
}
|
||||||
|
const unsigned char *bytes_end() const {
|
||||||
|
return reinterpret_cast<const unsigned char *>(end());
|
||||||
|
}
|
||||||
|
|
||||||
/// @}
|
/// @}
|
||||||
/// @name String Operations
|
/// @name String Operations
|
||||||
/// @{
|
/// @{
|
||||||
|
@ -459,6 +459,9 @@ public:
|
|||||||
/// \brief Pointer to one byte past the end of the string.
|
/// \brief Pointer to one byte past the end of the string.
|
||||||
iterator end() const { return getString().end(); }
|
iterator end() const { return getString().end(); }
|
||||||
|
|
||||||
|
const unsigned char *bytes_begin() const { return getString().bytes_begin(); }
|
||||||
|
const unsigned char *bytes_end() const { return getString().bytes_end(); }
|
||||||
|
|
||||||
/// \brief Methods for support type inquiry through isa, cast, and dyn_cast.
|
/// \brief Methods for support type inquiry through isa, cast, and dyn_cast.
|
||||||
static bool classof(const Metadata *MD) {
|
static bool classof(const Metadata *MD) {
|
||||||
return MD->getMetadataID() == MDStringKind;
|
return MD->getMetadataID() == MDStringKind;
|
||||||
|
@ -800,7 +800,7 @@ static void WriteModuleMetadata(const Module *M,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Code: [strchar x N]
|
// Code: [strchar x N]
|
||||||
Record.append(MDS->begin(), MDS->end());
|
Record.append(MDS->bytes_begin(), MDS->bytes_end());
|
||||||
|
|
||||||
// Emit the finished record.
|
// Emit the finished record.
|
||||||
Stream.EmitRecord(bitc::METADATA_STRING, Record, MDSAbbrev);
|
Stream.EmitRecord(bitc::METADATA_STRING, Record, MDSAbbrev);
|
||||||
|
9
test/Bitcode/mdstring-high-bits.ll
Normal file
9
test/Bitcode/mdstring-high-bits.ll
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
; RUN: llvm-as < %s | llvm-dis | FileCheck %s
|
||||||
|
|
||||||
|
; PR21882: confirm we don't crash when high bits are set in a character in a
|
||||||
|
; metadata string.
|
||||||
|
|
||||||
|
; CHECK: !name = !{!0}
|
||||||
|
!name = !{!0}
|
||||||
|
; CHECK: !0 = metadata !{metadata !"\80"}
|
||||||
|
!0 = metadata !{metadata !"\80"}
|
Loading…
x
Reference in New Issue
Block a user