diff options
Diffstat (limited to 'lib/Bitcode')
-rw-r--r-- | lib/Bitcode/Reader/BitcodeReader.cpp | 14 | ||||
-rw-r--r-- | lib/Bitcode/Writer/BitcodeWriter.cpp | 10 |
2 files changed, 19 insertions, 5 deletions
diff --git a/lib/Bitcode/Reader/BitcodeReader.cpp b/lib/Bitcode/Reader/BitcodeReader.cpp index e8b998e2a6..7a71b267ea 100644 --- a/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/lib/Bitcode/Reader/BitcodeReader.cpp @@ -1422,7 +1422,8 @@ bool BitcodeReader::ParseModule() { break; } // GLOBALVAR: [pointer type, isconst, initid, - // linkage, alignment, section, visibility, threadlocal] + // linkage, alignment, section, visibility, threadlocal, + // unnamed_addr] case bitc::MODULE_CODE_GLOBALVAR: { if (Record.size() < 6) return Error("Invalid MODULE_CODE_GLOBALVAR record"); @@ -1449,6 +1450,10 @@ bool BitcodeReader::ParseModule() { if (Record.size() > 7) isThreadLocal = Record[7]; + bool UnnamedAddr = false; + if (Record.size() > 8) + UnnamedAddr = Record[8]; + GlobalVariable *NewGV = new GlobalVariable(*TheModule, Ty, isConstant, Linkage, 0, "", 0, isThreadLocal, AddressSpace); @@ -1457,6 +1462,7 @@ bool BitcodeReader::ParseModule() { NewGV->setSection(Section); NewGV->setVisibility(Visibility); NewGV->setThreadLocal(isThreadLocal); + NewGV->setUnnamedAddr(UnnamedAddr); ValueList.push_back(NewGV); @@ -1466,7 +1472,7 @@ bool BitcodeReader::ParseModule() { break; } // FUNCTION: [type, callingconv, isproto, linkage, paramattr, - // alignment, section, visibility, gc] + // alignment, section, visibility, gc, unnamed_addr] case bitc::MODULE_CODE_FUNCTION: { if (Record.size() < 8) return Error("Invalid MODULE_CODE_FUNCTION record"); @@ -1499,6 +1505,10 @@ bool BitcodeReader::ParseModule() { return Error("Invalid GC ID"); Func->setGC(GCTable[Record[8]-1].c_str()); } + bool UnnamedAddr = false; + if (Record.size() > 9) + UnnamedAddr = Record[9]; + Func->setUnnamedAddr(UnnamedAddr); ValueList.push_back(Func); // If this is a function with a body, remember the prototype we are diff --git a/lib/Bitcode/Writer/BitcodeWriter.cpp b/lib/Bitcode/Writer/BitcodeWriter.cpp index 7b6b8433a3..702a611cbe 100644 --- a/lib/Bitcode/Writer/BitcodeWriter.cpp +++ b/lib/Bitcode/Writer/BitcodeWriter.cpp @@ -404,7 +404,8 @@ static void WriteModuleInfo(const Module *M, const ValueEnumerator &VE, unsigned AbbrevToUse = 0; // GLOBALVAR: [type, isconst, initid, - // linkage, alignment, section, visibility, threadlocal] + // linkage, alignment, section, visibility, threadlocal, + // unnamed_addr] Vals.push_back(VE.getTypeID(GV->getType())); Vals.push_back(GV->isConstant()); Vals.push_back(GV->isDeclaration() ? 0 : @@ -413,9 +414,11 @@ static void WriteModuleInfo(const Module *M, const ValueEnumerator &VE, Vals.push_back(Log2_32(GV->getAlignment())+1); Vals.push_back(GV->hasSection() ? SectionMap[GV->getSection()] : 0); if (GV->isThreadLocal() || - GV->getVisibility() != GlobalValue::DefaultVisibility) { + GV->getVisibility() != GlobalValue::DefaultVisibility || + GV->hasUnnamedAddr()) { Vals.push_back(getEncodedVisibility(GV)); Vals.push_back(GV->isThreadLocal()); + Vals.push_back(GV->hasUnnamedAddr()); } else { AbbrevToUse = SimpleGVarAbbrev; } @@ -427,7 +430,7 @@ static void WriteModuleInfo(const Module *M, const ValueEnumerator &VE, // Emit the function proto information. for (Module::const_iterator F = M->begin(), E = M->end(); F != E; ++F) { // FUNCTION: [type, callingconv, isproto, paramattr, - // linkage, alignment, section, visibility, gc] + // linkage, alignment, section, visibility, gc, unnamed_addr] Vals.push_back(VE.getTypeID(F->getType())); Vals.push_back(F->getCallingConv()); Vals.push_back(F->isDeclaration()); @@ -437,6 +440,7 @@ static void WriteModuleInfo(const Module *M, const ValueEnumerator &VE, Vals.push_back(F->hasSection() ? SectionMap[F->getSection()] : 0); Vals.push_back(getEncodedVisibility(F)); Vals.push_back(F->hasGC() ? GCMap[F->getGC()] : 0); + Vals.push_back(F->hasUnnamedAddr()); unsigned AbbrevToUse = 0; Stream.EmitRecord(bitc::MODULE_CODE_FUNCTION, Vals, AbbrevToUse); |