diff options
author | Alex Voicu <alexandru.voicu@amd.com> | 2024-11-20 23:57:55 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-11-20 23:57:55 +0000 |
commit | 53a6a11e0d51229d341b8906252645cd8a5de796 (patch) | |
tree | 7031426b67d381bbd0e9435b1b2ff0b2e7c71b08 /llvm/lib/Bitcode/Writer/BitcodeWriter.cpp | |
parent | f5002a0faee76609a6b054d579e1e09312ab9ac9 (diff) | |
download | llvm-53a6a11e0d51229d341b8906252645cd8a5de796.zip llvm-53a6a11e0d51229d341b8906252645cd8a5de796.tar.gz llvm-53a6a11e0d51229d341b8906252645cd8a5de796.tar.bz2 |
[LLVM][NFC] Use `used`'s element type if available (#116804)
When embedding, if `compiler.used` exists, we should re-use it's element
type instead of blindly assuming it's an unqualified pointer.
Diffstat (limited to 'llvm/lib/Bitcode/Writer/BitcodeWriter.cpp')
-rw-r--r-- | llvm/lib/Bitcode/Writer/BitcodeWriter.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp index 24a4c2e..80e12be 100644 --- a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp +++ b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp @@ -5501,8 +5501,9 @@ void llvm::embedBitcodeInModule(llvm::Module &M, llvm::MemoryBufferRef Buf, // Save llvm.compiler.used and remove it. SmallVector<Constant *, 2> UsedArray; SmallVector<GlobalValue *, 4> UsedGlobals; - Type *UsedElementType = PointerType::getUnqual(M.getContext()); GlobalVariable *Used = collectUsedGlobalVariables(M, UsedGlobals, true); + Type *UsedElementType = Used ? Used->getValueType()->getArrayElementType() + : PointerType::getUnqual(M.getContext()); for (auto *GV : UsedGlobals) { if (GV->getName() != "llvm.embedded.module" && GV->getName() != "llvm.cmdline") |