diff options
author | pzzp <pzzp11@outlook.com> | 2025-03-22 02:44:01 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-03-21 11:44:01 -0700 |
commit | d6a2cca77e3c88755e0f6b0acefffdcfa5eb2fec (patch) | |
tree | e1912aa645574a63dedc5548b0d731f66d51e944 /llvm/lib/Bitcode/Writer/BitcodeWriter.cpp | |
parent | 9f919661dd2ffe0f9666564e186da68fae401a9e (diff) | |
download | llvm-d6a2cca77e3c88755e0f6b0acefffdcfa5eb2fec.zip llvm-d6a2cca77e3c88755e0f6b0acefffdcfa5eb2fec.tar.gz llvm-d6a2cca77e3c88755e0f6b0acefffdcfa5eb2fec.tar.bz2 |
[llvm:ir] Add support for constant data exceeding 4GiB (#126481)
The test file is over 4GiB, which is too big, so I didn’t submit it.
Diffstat (limited to 'llvm/lib/Bitcode/Writer/BitcodeWriter.cpp')
-rw-r--r-- | llvm/lib/Bitcode/Writer/BitcodeWriter.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp index f6510a7..8f7482d 100644 --- a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp +++ b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp @@ -2803,7 +2803,7 @@ void ModuleBitcodeWriter::writeConstants(unsigned FirstVal, unsigned LastVal, cast<ConstantDataSequential>(C)->isString()) { const ConstantDataSequential *Str = cast<ConstantDataSequential>(C); // Emit constant strings specially. - unsigned NumElts = Str->getNumElements(); + uint64_t NumElts = Str->getNumElements(); // If this is a null-terminated string, use the denser CSTRING encoding. if (Str->isCString()) { Code = bitc::CST_CODE_CSTRING; @@ -2814,7 +2814,7 @@ void ModuleBitcodeWriter::writeConstants(unsigned FirstVal, unsigned LastVal, } bool isCStr7 = Code == bitc::CST_CODE_CSTRING; bool isCStrChar6 = Code == bitc::CST_CODE_CSTRING; - for (unsigned i = 0; i != NumElts; ++i) { + for (uint64_t i = 0; i != NumElts; ++i) { unsigned char V = Str->getElementAsInteger(i); Record.push_back(V); isCStr7 &= (V & 128) == 0; @@ -2831,10 +2831,10 @@ void ModuleBitcodeWriter::writeConstants(unsigned FirstVal, unsigned LastVal, Code = bitc::CST_CODE_DATA; Type *EltTy = CDS->getElementType(); if (isa<IntegerType>(EltTy)) { - for (unsigned i = 0, e = CDS->getNumElements(); i != e; ++i) + for (uint64_t i = 0, e = CDS->getNumElements(); i != e; ++i) Record.push_back(CDS->getElementAsInteger(i)); } else { - for (unsigned i = 0, e = CDS->getNumElements(); i != e; ++i) + for (uint64_t i = 0, e = CDS->getNumElements(); i != e; ++i) Record.push_back( CDS->getElementAsAPFloat(i).bitcastToAPInt().getLimitedValue()); } |