<div dir="ltr"><span style="font-size:14px">There was an obvious bug when PANDA generating the 16th basic block on system booting.Following command could trigger that:</span><div style="font-size:14px"><br></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div style="font-size:14px"><div>[da2din9o@VBT ~/panda]$./build_panda/i386-<wbr>softmmu/qemu-system-i386  -llvm</div></div></blockquote><div style="font-size:14px"><br></div><div style="font-size:14px">Turn on the llvm_ir log option,IR generated are as following:</div><div style="font-size:14px"><br></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div style="font-size:14px"><div>define private i64 @tcg-llvm-tb-16-ef1c5(%struct.<wbr>CPUX86State*) {</div></div><div style="font-size:14px"><div>entry:</div></div><div style="font-size:14px"><div>  %1 = alloca i32</div></div><div style="font-size:14px"><div>  %2 = ptrtoint %struct.CPUX86State* %0 to i64, !host !0</div></div><div style="font-size:14px"><div>  %rrgic = load volatile i64* inttoptr (i64 0x5555572AEF98 to i64*), !host !1</div></div><div style="font-size:14px"><div>  %3 = add i64 %2, -4</div></div><div style="font-size:14px"><div>  %4 = inttoptr i64 %3 to i32*</div></div><div style="font-size:14px"><div>  %tmp11_v = load i32* %4</div></div><div style="font-size:14px"><div>  %5 = icmp ne i32 %tmp11_v, 0</div></div><div style="font-size:14px"><div>  br i1 %5, label %17, label %6</div></div><div style="font-size:14px"><div><br></div></div><div style="font-size:14px"><div>; &lt;label&gt;:6                                       ; preds = %entry</div></div><div style="font-size:14px"><div>  store volatile i64 0xEF1C5, i64* inttoptr (i64 0x555556D3D0F0 to i64*), !host !2</div></div><div style="font-size:14px"><div>  store volatile i64 0xEF1C5, i64* inttoptr (i64 0x5555572AEFA0 to i64*), !host !2</div></div><div style="font-size:14px"><div>  %rrgic1 = add i64 %rrgic, 1, !host !1</div></div><div style="font-size:14px"><div>  store volatile i64 %rrgic1, i64* inttoptr (i64 0x5555572AEF98 to i64*), !host !1</div></div><div style="font-size:14px"><div>  %7 = add i64 %2, 0x2c</div></div><div style="font-size:14px"><div>  %cc_src_ptr = inttoptr i64 %7 to i32*</div></div><div style="font-size:14px"><div>  store i32 37, i32* %cc_src_ptr</div></div><div style="font-size:14px"><div>  %8 = add i64 %2, 0x8</div></div><div style="font-size:14px"><div>  %edx_ptr = inttoptr i64 %8 to i32*</div></div><div style="font-size:14px"><div>  %edx_v = load i32* %edx_ptr</div></div><div style="font-size:14px"><div>  %tmp-25_v = sub i32 %edx_v, 0x25</div></div><div style="font-size:14px"><div>  %9 = add i64 %2, 0x28</div></div><div style="font-size:14px"><div>  %cc_dst_ptr = inttoptr i64 %9 to i32*</div></div><div style="font-size:14px"><div>  store i32 %tmp-25_v, i32* %cc_dst_ptr</div></div><div style="font-size:14px"><div>  store volatile i64 0xEF1C8, i64* inttoptr (i64 0x555556D3D0F0 to i64*), !host !2</div></div><div style="font-size:14px"><div>  store volatile i64 0xEF1C8, i64* inttoptr (i64 0x5555572AEFA0 to i64*), !host !2</div></div><div style="font-size:14px"><div>  %rrgic2 = add i64 %rrgic1, 1, !host !1</div></div><div style="font-size:14px"><div>  store volatile i64 %rrgic2, i64* inttoptr (i64 0x5555572AEF98 to i64*), !host !1</div></div><div style="font-size:14px"><div>  %10 = trunc i32 %tmp-25_v to i8</div></div><div style="font-size:14px"><div>  %tmp0_v = zext i8 %10 to i32</div></div><div style="font-size:14px"><div>  %11 = add i64 %2, 0x34</div></div><div style="font-size:14px"><div>  %cc_op_ptr = inttoptr i64 %11 to i32*</div></div><div style="font-size:14px"><div>  store i32 14, i32* %cc_op_ptr</div></div><div style="font-size:14px"><div>  %12 = icmp ne i32 %tmp0_v, 0</div></div><div style="font-size:14px"><div>  br i1 %12, label %16, label %13</div></div><div style="font-size:14px"><div><br></div></div><div style="font-size:14px"><div>; &lt;label&gt;:13                                      ; preds = %6</div></div><div style="font-size:14px"><div>  %14 = add i64 %2, 0x20</div></div><div style="font-size:14px"><div>  %15 = inttoptr i64 %14 to i32*</div></div><div style="font-size:14px"><div>  store i32 0xEF1CE, i32* %15</div></div><div style="font-size:14px"><div>  ret i64 140737050397200</div></div><div style="font-size:14px"><div><br></div></div><div style="font-size:14px"><div>; &lt;label&gt;:16                                      ; preds = %6</div></div><div style="font-size:14px"><div>  store i32 0xEF268, i32* %15</div></div><div style="font-size:14px"><div>  ret i64 140737050397201</div></div><div style="font-size:14px"><div><br></div></div><div style="font-size:14px"><div>; &lt;label&gt;:17                                      ; preds = %entry</div></div><div style="font-size:14px"><div>  ret i64 140737050397203</div></div><div style="font-size:14px"><div>}</div></div></blockquote><div style="font-size:14px"><br></div><div style="font-size:14px">Note that the variable%15, which is used as the destination address by operator “store” directly in label16 but initialized in label 13,and the label 13 has never been excuted.</div><div style="font-size:14px">I try to fix that issue by following patch:</div><div style="font-size:14px"><br></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div style="font-size:14px"><div>[da2din9o@VBT ~/panda/panda]$git diff a3c024 871b3d</div></div><div style="font-size:14px"><div>diff --git a/panda/llvm/tcg-llvm.cpp b/panda/llvm/tcg-llvm.cpp</div></div><div style="font-size:14px"><div>index 56bbcf0..0ecc797 100644</div></div><div style="font-size:14px"><div>--- a/panda/llvm/tcg-llvm.cpp</div></div><div style="font-size:14px"><div>+++ b/panda/llvm/tcg-llvm.cpp</div></div><div style="font-size:14px"><div>@@ -117,7 +117,6 @@ struct TCGLLVMContextPrivate {</div></div><div style="font-size:14px"><div>     /* Pointers to in-memory versions of globals or local temps */</div></div><div style="font-size:14px"><div>     Value* m_memValuesPtr[TCG_MAX_TEMPS];</div></div><div style="font-size:14px"><div><br></div></div><div style="font-size:14px"><div>-    std::map&lt;int64_t, Value *&gt; m_envOffsetValues;</div></div><div style="font-size:14px"><div>     Value *m_envInt;</div></div><div style="font-size:14px"><div><br></div></div><div style="font-size:14px"><div>     /* For reg-based globals, store argument number,</div></div><div style="font-size:14px"><div>@@ -433,19 +432,12 @@ Value* TCGLLVMContextPrivate::<wbr>getPtrForValue(int idx)</div></div><div style="font-size:14px"><div> }</div></div><div style="font-size:14px"><div><br></div></div><div style="font-size:14px"><div> Value* TCGLLVMContextPrivate::<wbr>getEnvOffsetPtr(int64_t offset, TCGTemp &amp;temp) {</div></div><div style="font-size:14px"><div>-    auto it = m_envOffsetValues.find(offset)<wbr>;</div></div><div style="font-size:14px"><div>-    llvm::Type *tempType = tcgPtrType(temp.type);</div></div><div style="font-size:14px"><div>-    if (it == m_envOffsetValues.end() || tempType != it-&gt;second-&gt;getType()) {</div></div><div style="font-size:14px"><div>-        Value *v;</div></div><div style="font-size:14px"><div>-        v = m_builder.CreateAdd(m_envInt, ConstantInt::get(wordType(), offset));</div></div><div style="font-size:14px"><div>-        v = m_builder.CreateIntToPtr(</div></div><div style="font-size:14px"><div>-                v, tcgPtrType(temp.type),</div></div><div style="font-size:14px"><div>-                <a href="http://temp.name/" target="_blank">temp.name</a> ? StringRef(<a href="http://temp.name/" target="_blank">temp.name</a>) + &quot;_ptr&quot;: &quot;&quot;);</div></div><div style="font-size:14px"><div>-        m_envOffsetValues[offset] = v;</div></div><div style="font-size:14px"><div>-        return v;</div></div><div style="font-size:14px"><div>-    } else {</div></div><div style="font-size:14px"><div>-        return it-&gt;second;</div></div><div style="font-size:14px"><div>-    }</div></div><div style="font-size:14px"><div>+    Value *v;</div></div><div style="font-size:14px"><div>+    v = m_builder.CreateAdd(m_envInt, ConstantInt::get(wordType(), offset));</div></div><div style="font-size:14px"><div>+    v = m_builder.CreateIntToPtr(</div></div><div style="font-size:14px"><div>+            v, tcgPtrType(temp.type),</div></div><div style="font-size:14px"><div>+            <a href="http://temp.name/" target="_blank">temp.name</a> ? StringRef(<a href="http://temp.name/" target="_blank">temp.name</a>) + &quot;_ptr&quot;: &quot;&quot;);</div></div><div style="font-size:14px"><div>+    return v;</div></div><div style="font-size:14px"><div> }</div></div><div style="font-size:14px"><div><br></div></div><div style="font-size:14px"><div> static inline void freeValue(Value *V) {</div></div><div style="font-size:14px"><div>@@ -1410,11 +1402,6 @@ void TCGLLVMContextPrivate::<wbr>generateCode(TCGContext *s, TranslationBlock *tb)</div></div><div style="font-size:14px"><div>     for(int i=0; i&lt;TCG_MAX_LABELS; ++i)</div></div><div style="font-size:14px"><div>         delLabel(i);</div></div><div style="font-size:14px"><div><br></div></div><div style="font-size:14px"><div>-    for (auto &amp;it : m_envOffsetValues) {</div></div><div style="font-size:14px"><div>-        freeValue(it.second);</div></div><div style="font-size:14px"><div>-    }</div></div><div style="font-size:14px"><div>-    m_envOffsetValues.clear();</div></div><div style="font-size:14px"><div>-</div></div><div style="font-size:14px"><div>     // run all specified function passes</div></div><div style="font-size:14px"><div>     m_functionPassManager-&gt;run(*<wbr>m_tbFunction);</div></div></blockquote><div style="font-size:14px"><div><br></div></div><div style="font-size:14px"><br></div><div style="font-size:14px">PANDA excuting normally,but I&#39;m not sure whether that patch could cause other unexpected problems.</div><div style="font-size:14px">So could you confirm if that patch can be accepted or <span style="color:rgb(0,0,0);font-size:13px;white-space:nowrap">issue a new patch to solve the beginning problem?</span></div></div>