diff options
author | Pirama Arumuga Nainar <pirama@google.com> | 2015-05-06 11:17:16 -0700 |
---|---|---|
committer | Pirama Arumuga Nainar <pirama@google.com> | 2015-05-19 13:37:00 -0700 |
commit | 2444eaadc5a5197e2c3192afd74c38e9e4bb0ffe (patch) | |
tree | 69e0e4913796ad730ebbd0451625d59ab705bad5 | |
parent | 21f7c3849ea609c8705af39a88ac98e369fc2742 (diff) | |
download | android_frameworks_compile_slang-2444eaadc5a5197e2c3192afd74c38e9e4bb0ffe.tar.gz android_frameworks_compile_slang-2444eaadc5a5197e2c3192afd74c38e9e4bb0ffe.tar.bz2 android_frameworks_compile_slang-2444eaadc5a5197e2c3192afd74c38e9e4bb0ffe.zip |
Update slang for rebase to LLVM r235153
- Include a tiny fix to an upstream bug
(https://llvm.org/bugs/show_bug.cgi?id=23436)
- Use BufferOutputStream instead of FormattedOutputStream in
slang_backend
Change-Id: I9c53b6bbbcccc95513b45d8f0374ced35f7baccd
(cherry picked from commit 21cc01860b95cad7ae60c686e511e8f4ae034e39)
-rw-r--r-- | BitWriter_2_9/BitcodeWriter.cpp | 33 | ||||
-rw-r--r-- | BitWriter_2_9/ValueEnumerator.cpp | 10 | ||||
-rw-r--r-- | BitWriter_2_9_func/BitcodeWriter.cpp | 33 | ||||
-rw-r--r-- | BitWriter_2_9_func/ValueEnumerator.cpp | 10 | ||||
-rw-r--r-- | BitWriter_3_2/BitcodeWriter.cpp | 40 | ||||
-rw-r--r-- | BitWriter_3_2/ValueEnumerator.cpp | 10 | ||||
-rw-r--r-- | slang_backend.cpp | 15 | ||||
-rw-r--r-- | slang_backend.h | 6 |
8 files changed, 76 insertions, 81 deletions
diff --git a/BitWriter_2_9/BitcodeWriter.cpp b/BitWriter_2_9/BitcodeWriter.cpp index 0e23213..4b914c0 100644 --- a/BitWriter_2_9/BitcodeWriter.cpp +++ b/BitWriter_2_9/BitcodeWriter.cpp @@ -1376,7 +1376,7 @@ static void WriteFunction(const Function &F, llvm_2_9::ValueEnumerator &VE, bool NeedsMetadataAttachment = false; - DebugLoc LastDL; + MDLocation *LastDL = nullptr;; // Finally, emit all the instructions, in order. for (Function::const_iterator BB = F.begin(), E = F.end(); BB != E; ++BB) @@ -1391,25 +1391,26 @@ static void WriteFunction(const Function &F, llvm_2_9::ValueEnumerator &VE, NeedsMetadataAttachment |= I->hasMetadataOtherThanDebugLoc(); // If the instruction has a debug location, emit it. - DebugLoc DL = I->getDebugLoc(); - if (DL.isUnknown()) { - // nothing todo. - } else if (DL == LastDL) { + MDLocation *DL = I->getDebugLoc(); + if (!DL) + continue; + + if (DL == LastDL) { // Just repeat the same debug loc as last time. Stream.EmitRecord(bitc::FUNC_CODE_DEBUG_LOC_AGAIN, Vals); - } else { - MDNode *Scope, *IA; - DL.getScopeAndInlinedAt(Scope, IA, I->getContext()); + continue; + } - Vals.push_back(DL.getLine()); - Vals.push_back(DL.getCol()); - Vals.push_back(VE.getMetadataOrNullID(Scope)); - Vals.push_back(VE.getMetadataOrNullID(IA)); - Stream.EmitRecord(FUNC_CODE_DEBUG_LOC_2_7, Vals); - Vals.clear(); + Vals.push_back(DL->getLine()); + Vals.push_back(DL->getColumn()); + Vals.push_back(VE.getMetadataOrNullID(DL->getScope())); + Vals.push_back(VE.getMetadataOrNullID(DL->getInlinedAt())); + Stream.EmitRecord(FUNC_CODE_DEBUG_LOC_2_7, Vals); + Vals.clear(); - LastDL = DL; - } + // Fixme(pirama): The following line is missing from upstream + // https://llvm.org/bugs/show_bug.cgi?id=23436 + LastDL = DL; } // Emit names for all the instructions etc. diff --git a/BitWriter_2_9/ValueEnumerator.cpp b/BitWriter_2_9/ValueEnumerator.cpp index 75949b3..02a6754 100644 --- a/BitWriter_2_9/ValueEnumerator.cpp +++ b/BitWriter_2_9/ValueEnumerator.cpp @@ -109,12 +109,10 @@ ValueEnumerator::ValueEnumerator(const llvm::Module &M) for (unsigned i = 0, e = MDs.size(); i != e; ++i) EnumerateMetadata(MDs[i].second); - if (!I.getDebugLoc().isUnknown()) { - MDNode *Scope, *IA; - I.getDebugLoc().getScopeAndInlinedAt(Scope, IA, I.getContext()); - if (Scope) EnumerateMetadata(Scope); - if (IA) EnumerateMetadata(IA); - } + // Don't enumerate the location directly -- it has a special record + // type -- but enumerate its operands. + if (MDLocation *L = I.getDebugLoc()) + EnumerateMDNodeOperands(L); } } diff --git a/BitWriter_2_9_func/BitcodeWriter.cpp b/BitWriter_2_9_func/BitcodeWriter.cpp index 6a4b6fb..d42803d 100644 --- a/BitWriter_2_9_func/BitcodeWriter.cpp +++ b/BitWriter_2_9_func/BitcodeWriter.cpp @@ -1438,7 +1438,7 @@ static void WriteFunction(const Function &F, llvm_2_9_func::ValueEnumerator &VE, bool NeedsMetadataAttachment = false; - DebugLoc LastDL; + MDLocation *LastDL = nullptr; // Finally, emit all the instructions, in order. for (Function::const_iterator BB = F.begin(), E = F.end(); BB != E; ++BB) @@ -1453,25 +1453,26 @@ static void WriteFunction(const Function &F, llvm_2_9_func::ValueEnumerator &VE, NeedsMetadataAttachment |= I->hasMetadataOtherThanDebugLoc(); // If the instruction has a debug location, emit it. - DebugLoc DL = I->getDebugLoc(); - if (DL.isUnknown()) { - // nothing todo. - } else if (DL == LastDL) { + MDLocation *DL = I->getDebugLoc(); + if (!DL) + continue; + + if (DL == LastDL) { // Just repeat the same debug loc as last time. Stream.EmitRecord(bitc::FUNC_CODE_DEBUG_LOC_AGAIN, Vals); - } else { - MDNode *Scope, *IA; - DL.getScopeAndInlinedAt(Scope, IA, I->getContext()); + continue; + } - Vals.push_back(DL.getLine()); - Vals.push_back(DL.getCol()); - Vals.push_back(VE.getMetadataOrNullID(Scope)); - Vals.push_back(VE.getMetadataOrNullID(IA)); - Stream.EmitRecord(bitc::FUNC_CODE_DEBUG_LOC, Vals); - Vals.clear(); + Vals.push_back(DL->getLine()); + Vals.push_back(DL->getColumn()); + Vals.push_back(VE.getMetadataOrNullID(DL->getScope())); + Vals.push_back(VE.getMetadataOrNullID(DL->getInlinedAt())); + Stream.EmitRecord(bitc::FUNC_CODE_DEBUG_LOC, Vals); + Vals.clear(); - LastDL = DL; - } + // Fixme(pirama): The following line is missing from upstream + // https://llvm.org/bugs/show_bug.cgi?id=23436 + LastDL = DL; } // Emit names for all the instructions etc. diff --git a/BitWriter_2_9_func/ValueEnumerator.cpp b/BitWriter_2_9_func/ValueEnumerator.cpp index 07217f6..0602318 100644 --- a/BitWriter_2_9_func/ValueEnumerator.cpp +++ b/BitWriter_2_9_func/ValueEnumerator.cpp @@ -109,12 +109,10 @@ ValueEnumerator::ValueEnumerator(const llvm::Module &M) for (unsigned i = 0, e = MDs.size(); i != e; ++i) EnumerateMetadata(MDs[i].second); - if (!I.getDebugLoc().isUnknown()) { - MDNode *Scope, *IA; - I.getDebugLoc().getScopeAndInlinedAt(Scope, IA, I.getContext()); - if (Scope) EnumerateMetadata(Scope); - if (IA) EnumerateMetadata(IA); - } + // Don't enumerate the location directly -- it has a special record + // type -- but enumerate its operands. + if (MDLocation *L = I.getDebugLoc()) + EnumerateMDNodeOperands(L); } } diff --git a/BitWriter_3_2/BitcodeWriter.cpp b/BitWriter_3_2/BitcodeWriter.cpp index 9e3bfbe..3d12f17 100644 --- a/BitWriter_3_2/BitcodeWriter.cpp +++ b/BitWriter_3_2/BitcodeWriter.cpp @@ -1513,7 +1513,7 @@ static void WriteFunction(const Function &F, llvm_3_2::ValueEnumerator &VE, bool NeedsMetadataAttachment = false; - DebugLoc LastDL; + MDLocation *LastDL = nullptr; // Finally, emit all the instructions, in order. for (Function::const_iterator BB = F.begin(), E = F.end(); BB != E; ++BB) @@ -1528,26 +1528,26 @@ static void WriteFunction(const Function &F, llvm_3_2::ValueEnumerator &VE, NeedsMetadataAttachment |= I->hasMetadataOtherThanDebugLoc(); // If the instruction has a debug location, emit it. - DebugLoc DL = I->getDebugLoc(); - if (DL.isUnknown()) { - // nothing todo. - } else if (DL == LastDL) { + MDLocation *DL = I->getDebugLoc(); + if (!DL) + continue; + + if (DL == LastDL) { // Just repeat the same debug loc as last time. Stream.EmitRecord(bitc::FUNC_CODE_DEBUG_LOC_AGAIN, Vals); - } else { - MDNode *Scope, *IA; - DL.getScopeAndInlinedAt(Scope, IA, I->getContext()); - assert(Scope && "Expected valid scope"); - - Vals.push_back(DL.getLine()); - Vals.push_back(DL.getCol()); - Vals.push_back(VE.getMetadataOrNullID(Scope)); - Vals.push_back(VE.getMetadataOrNullID(IA)); - Stream.EmitRecord(bitc::FUNC_CODE_DEBUG_LOC, Vals); - Vals.clear(); - - LastDL = DL; + continue; } + + Vals.push_back(DL->getLine()); + Vals.push_back(DL->getColumn()); + Vals.push_back(VE.getMetadataOrNullID(DL->getScope())); + Vals.push_back(VE.getMetadataOrNullID(DL->getInlinedAt())); + Stream.EmitRecord(bitc::FUNC_CODE_DEBUG_LOC, Vals); + Vals.clear(); + + // Fixme(pirama): The following line is missing from upstream + // https://llvm.org/bugs/show_bug.cgi?id=23436 + LastDL = DL; } // Emit names for all the instructions etc. @@ -1555,7 +1555,7 @@ static void WriteFunction(const Function &F, llvm_3_2::ValueEnumerator &VE, if (NeedsMetadataAttachment) WriteMetadataAttachment(F, VE, Stream); - if (shouldPreserveBitcodeUseListOrder()) + if (false) WriteUseListBlock(&F, VE, Stream); VE.purgeFunction(); Stream.ExitBlock(); @@ -1764,7 +1764,7 @@ static void WriteModule(const Module *M, BitstreamWriter &Stream) { WriteValueSymbolTable(M->getValueSymbolTable(), VE, Stream); // Emit module-level use-lists. - if (shouldPreserveBitcodeUseListOrder()) + if (false) WriteUseListBlock(nullptr, VE, Stream); // Emit function bodies. diff --git a/BitWriter_3_2/ValueEnumerator.cpp b/BitWriter_3_2/ValueEnumerator.cpp index 919e9df..6b1a33d 100644 --- a/BitWriter_3_2/ValueEnumerator.cpp +++ b/BitWriter_3_2/ValueEnumerator.cpp @@ -109,12 +109,10 @@ ValueEnumerator::ValueEnumerator(const llvm::Module &M) for (unsigned i = 0, e = MDs.size(); i != e; ++i) EnumerateMetadata(MDs[i].second); - if (!I.getDebugLoc().isUnknown()) { - MDNode *Scope, *IA; - I.getDebugLoc().getScopeAndInlinedAt(Scope, IA, I.getContext()); - if (Scope) EnumerateMetadata(Scope); - if (IA) EnumerateMetadata(IA); - } + // Don't enumerate the location directly -- it has a special record + // type -- but enumerate its operands. + if (MDLocation *L = I.getDebugLoc()) + EnumerateMDNodeOperands(L); } } diff --git a/slang_backend.cpp b/slang_backend.cpp index 1a45b41..8f4a255 100644 --- a/slang_backend.cpp +++ b/slang_backend.cpp @@ -205,7 +205,7 @@ bool Backend::CreateCodeGenPasses() { if (mOT == Slang::OT_Object) { CGFT = llvm::TargetMachine::CGFT_ObjectFile; } - if (TM->addPassesToEmitFile(*mCodeGenPasses, FormattedOutStream, + if (TM->addPassesToEmitFile(*mCodeGenPasses, mBufferOutStream, CGFT, OptLevel)) { mDiagEngine.Report(clang::diag::err_fe_unable_to_interface_with_target); return false; @@ -222,7 +222,8 @@ Backend::Backend(RSContext *Context, clang::DiagnosticsEngine *DiagEngine, bool IsFilterscript) : ASTConsumer(), mTargetOpts(TargetOpts), mpModule(nullptr), mpOS(OS), mOT(OT), mGen(nullptr), mPerFunctionPasses(nullptr), - mPerModulePasses(nullptr), mCodeGenPasses(nullptr), mContext(Context), + mPerModulePasses(nullptr), mCodeGenPasses(nullptr), + mBufferOutStream(*mpOS), mContext(Context), mSourceMgr(SourceMgr), mAllowRSPrefix(AllowRSPrefix), mIsFilterscript(IsFilterscript), mExportVarMetadata(nullptr), mExportFuncMetadata(nullptr), mExportForEachNameMetadata(nullptr), @@ -231,8 +232,6 @@ Backend::Backend(RSContext *Context, clang::DiagnosticsEngine *DiagEngine, mASTChecker(Context, Context->getTargetAPI(), IsFilterscript), mLLVMContext(llvm::getGlobalContext()), mDiagEngine(*DiagEngine), mCodeGenOpts(CodeGenOpts), mPragmas(Pragmas) { - FormattedOutStream.setStream(*mpOS, - llvm::formatted_raw_ostream::PRESERVE_STREAM); mGen = CreateLLVMCodeGen(mDiagEngine, "", mCodeGenOpts, mLLVMContext); } @@ -252,10 +251,10 @@ void Backend::WrapBitcode(llvm::raw_string_ostream &Bitcode) { slangAssert(actualWrapperLen > 0); // Write out the bitcode wrapper. - FormattedOutStream.write(reinterpret_cast<char*>(&wrapper), actualWrapperLen); + mBufferOutStream.write(reinterpret_cast<char*>(&wrapper), actualWrapperLen); // Write out the actual encoded bitcode. - FormattedOutStream << Bitcode.str(); + mBufferOutStream << Bitcode.str(); } void Backend::HandleTranslationUnit(clang::ASTContext &Ctx) { @@ -342,7 +341,7 @@ void Backend::HandleTranslationUnit(clang::ASTContext &Ctx) { } case Slang::OT_LLVMAssembly: { llvm::legacy::PassManager *LLEmitPM = new llvm::legacy::PassManager(); - LLEmitPM->add(llvm::createPrintModulePass(FormattedOutStream)); + LLEmitPM->add(llvm::createPrintModulePass(mBufferOutStream)); LLEmitPM->run(*mpModule); break; } @@ -391,7 +390,7 @@ void Backend::HandleTranslationUnit(clang::ASTContext &Ctx) { } } - FormattedOutStream.flush(); + mBufferOutStream.flush(); } void Backend::HandleTagDeclDefinition(clang::TagDecl *D) { diff --git a/slang_backend.h b/slang_backend.h index 1a97bd6..e3dbdef 100644 --- a/slang_backend.h +++ b/slang_backend.h @@ -21,7 +21,7 @@ #include "llvm/IR/LegacyPassManager.h" -#include "llvm/Support/FormattedStream.h" +#include "llvm/Support/raw_ostream.h" #include "slang.h" #include "slang_pragma_recorder.h" @@ -30,7 +30,7 @@ #include "slang_version.h" namespace llvm { - class formatted_raw_ostream; + class buffer_ostream; class LLVMContext; class NamedMDNode; class Module; @@ -75,7 +75,7 @@ class Backend : public clang::ASTConsumer { // Passes for code emission llvm::legacy::FunctionPassManager *mCodeGenPasses; - llvm::formatted_raw_ostream FormattedOutStream; + llvm::buffer_ostream mBufferOutStream; void CreateFunctionPasses(); void CreateModulePasses(); |