<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
</head>
<body>
<div dir="auto" style="direction: ltr; margin: 0; padding: 0; font-family: sans-serif; font-size: 11pt; color: black; ">
Do you use one llvm context or one per thread that interacts with llvm? I'm not an expert but the former might not be supported.
<br>
<br>
</div>
<div dir="auto" style="direction: ltr; margin: 0; padding: 0; font-family: sans-serif; font-size: 11pt; color: black; ">
Cheers, <br>
</div>
<div dir="auto" style="direction: ltr; margin: 0; padding: 0; font-family: sans-serif; font-size: 11pt; color: black; ">
Johannes <br>
<br>
</div>
<div dir="auto" style="direction: ltr; margin: 0; padding: 0; font-family: sans-serif; font-size: 11pt; color: black; ">
<div dir="auto" style="direction: ltr; margin: 0; padding: 0; font-family: sans-serif; font-size: 11pt; color: black; ">
Get <a href="https://aka.ms/ghei36">Outlook for Android</a></div>
<br>
</div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> llvm-dev <llvm-dev-bounces@lists.llvm.org> on behalf of pongba via llvm-dev <llvm-dev@lists.llvm.org><br>
<b>Sent:</b> Wednesday, April 3, 2019 7:24:25 PM<br>
<b>To:</b> llvm-dev@lists.llvm.org<br>
<b>Subject:</b> [llvm-dev] single-threaded code-gen and how to make it support multi-thread</font>
<div> </div>
</div>
<div>
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">
<div class="gmail_signature">Hi llvm-dev,</div>
<div class="gmail_signature"><br>
</div>
<div class="gmail_signature">Our code base has a ancient copy of llvm (ver 3.5.1), and it uses the LLVM code gen for some domain-specific language.</div>
<div class="gmail_signature"><br>
</div>
<div class="gmail_signature">The previous dev left a global lock around the usage of LLVM code gen stating that because LLVM code gen can only be accessed single-threaded it needs to be protected with this global lock.</div>
<div class="gmail_signature"><br>
</div>
<div class="gmail_signature">But now this lock has caused some perf issues as we pretty much lose concurrency when having to compile a large number of source files.</div>
<div class="gmail_signature"><br>
</div>
<div class="gmail_signature">I've tried to remove the global lock and what I have observed in crashing stack is something like below:</div>
<div class="gmail_signature"><br>
</div>
<div class="gmail_signature">(I did make sure LLVM_ENABLE_THREADS is defined to be 1, apparently it didn't seem to help)</div>
<div class="gmail_signature"><br>
</div>
<div class="gmail_signature">The document around this seems vague, I have not found a clear instruction as to how to solve this, hence this post. Can anyone help with some pointers?</div>
<div class="gmail_signature"><br>
</div>
<div class="gmail_signature">Any guidance is appreciated:)</div>
<div class="gmail_signature"><br>
</div>
<div class="gmail_signature">
<div class="gmail_signature"> <span style="white-space:pre"> </span>ntdll.dll!RtlReportCriticalFailure(long StatusCode, void * FailureInfo, unsigned long BreakIfDbgPresent) Line 201<span style="white-space:pre">
</span>C</div>
<div class="gmail_signature"> <span style="white-space:pre"> </span>ntdll.dll!RtlpHeapHandleError(long ErrorLevel) Line 344<span style="white-space:pre">
</span>C</div>
<div class="gmail_signature"> <span style="white-space:pre"> </span>ntdll.dll!RtlpHpHeapHandleError(_HEAP_FAILURE_TYPE FailureType, unsigned __int64 HeapAddress, unsigned __int64 Address) Line 670<span style="white-space:pre">
</span>C</div>
<div class="gmail_signature"> <span style="white-space:pre"> </span>ntdll.dll!RtlpLogHeapFailure(_HEAP_FAILURE_TYPE FailureType, void * HeapAddress, void * Address, void * Param1, void * Param2, void * Param3) Line 158<span style="white-space:pre">
</span>C</div>
<div class="gmail_signature"> <span style="white-space:pre"> </span>ntdll.dll!RtlFreeHeap(void * HeapHandle, unsigned long Flags, void * BaseAddress) Line 352<span style="white-space:pre">
</span>C</div>
<div class="gmail_signature"> <span style="white-space:pre"> </span>ucrtbase.dll!_free_base(void * block) Line 105<span style="white-space:pre">
</span>C++</div>
</div>
<div class="gmail_signature">
<div class="gmail_signature"> <span style="white-space:pre"> </span>XXXTest.exe!llvm::StringMapImpl::RehashTable(unsigned int BucketNo) Line 238<span style="white-space:pre">
</span>C++</div>
<div class="gmail_signature"> <span style="white-space:pre"> </span>XXXTest.exe!llvm::StringMap<llvm::ConstantDataSequential * __ptr64,llvm::MallocAllocator>::insert(std::pair<llvm::StringRef,llvm::ConstantDataSequential *> KV) Line 344<span style="white-space:pre">
</span>C++</div>
<div class="gmail_signature"> <span style="white-space:pre"> </span>[Inline Frame] XXXTest.exe!llvm::StringMap<llvm::Value *,llvm::MallocAllocator>::GetOrCreateValue(llvm::StringRef) Line 371<span style="white-space:pre">
</span>C++</div>
<div class="gmail_signature"> <span style="white-space:pre"> </span>[Inline Frame] XXXTest.exe!llvm::StringMap<llvm::Value *,llvm::MallocAllocator>::GetOrCreateValue(llvm::StringRef) Line 375<span style="white-space:pre">
</span>C++</div>
<div class="gmail_signature"> <span style="white-space:pre"> </span>XXXTest.exe!llvm::ValueSymbolTable::createValueName(llvm::StringRef Name, llvm::Value * V) Line 98<span style="white-space:pre">
</span>C++</div>
<div class="gmail_signature"> <span style="white-space:pre"> </span>XXXTest.exe!llvm::Value::setName(const llvm::Twine & NewName) Line 236<span style="white-space:pre">
</span>C++</div>
<div class="gmail_signature"> <span style="white-space:pre"> </span>XXXTest.exe!llvm::IRBuilder<1,llvm::ConstantFolder,llvm::IRBuilderDefaultInserter<1> >::Insert<llvm::GetElementPtrInst>(llvm::GetElementPtrInst * I, const llvm::Twine & Name) Line 497<span style="white-space:pre">
</span>C++</div>
<div class="gmail_signature"> <span style="white-space:pre"> </span>XXXTest.exe!llvm::IRBuilder<1,llvm::ConstantFolder,llvm::IRBuilderDefaultInserter<1> >::CreateConstInBoundsGEP1_32(llvm::Value * Ptr, unsigned int Idx0, const llvm::Twine & Name) Line 1014<span style="white-space:pre">
</span>C++</div>
<div class="gmail_signature">><span style="white-space:pre"> </span>XXXTest.exe!XXX::LlvmCodeGenerator::Visit(const XXX::FeatureRefExpression & p_expr) Line 953<span style="white-space:pre">
</span>C++</div>
<div class="gmail_signature"> <span style="white-space:pre"> </span>XXXTest.exe!XXX::FeatureRefExpression::Accept(XXX::Visitor & p_visitor) Line 46<span style="white-space:pre">
</span>C++</div>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>