<html><head><meta http-equiv="Content-Type" content="text/html charset=GB2312"><base href="x-msg://168/"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On Aug 19, 2013, at 14:26 , chentommy <<a href="mailto:baiypwup@hotmail.com">baiypwup@hotmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div class="hmmessage" style="font-size: 12pt; font-family: ΢ÈíÑźÚ; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><div dir="ltr"><div dir="ltr">Hello LLVMDev List,<div id="haloword-lookup" class="ui-widget-content ui-draggable"><div id="haloword-title"><span id="haloword-word"></span><a herf="#" id="haloword-pron" class="haloword-button" title="??"></a><audio id="haloword-audio"></audio><div id="haloword-control-container"><a herf="#" id="haloword-add" class="haloword-button" title="?????"></a><a herf="#" id="haloword-remove" class="haloword-button" title="?????"></a><a href="#" id="haloword-open" class="haloword-button" title="????????" target="_blank"></a><a herf="#" id="haloword-close" class="haloword-button" title="?????"></a></div><br style="clear: both; "></div><div id="haloword-content"></div></div><div><br></div><div>It's my first time sending a message to the List - I have been working on a tool for my research project using LLVM. Thanks for your awesome work!</div><div><br></div><div>I have come across some bytecode like the following with an GetElementPtr instruction in brackets:</div><div><br></div><div>Bytecode:</div><div>%3 = call i32 @_Z4funcPKc(i8* getelementptr inbounds ([5 x i8]* @.str2, i32 0, i32 0))</div><div><br></div><div>C++ code:</div><div>func("bleh");</div><div><br></div><div>However when I am generating bytecode programmatically, I can not have the GetElementPtr value "inlined" in the function argument list:</div><div><br></div><div>Bytecode:</div><div><div>%bbname = getelementptr inbounds [29 x i8]* @bbname10, i32 0, i32 0</div><div>call void @incrementFaultSiteCount(i8* %bbname, i32 2)</div></div><div><br></div><div>C++ code: (What I mean to generate)</div><div>incrementFaultSiteCount("BBName", 2);</div><div><br></div><div>My question is:</div><div>- What is this phenomenon called, is it called "inlined/expanded function argument"?</div></div></div></div></blockquote><div>This is a constant expression cast. It will only happen for a constant arguments, in this case the address of global @bbname. You should get these if you run instcombine on it.</div><div><br></div><div><a href="http://llvm.org/docs/LangRef.html#constant-expressions">http://llvm.org/docs/LangRef.html#constant-expressions</a></div><div><br></div><br><blockquote type="cite"><div class="hmmessage" style="font-size: 12pt; font-family: ΢ÈíÑźÚ; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><div dir="ltr"><div dir="ltr"><div><span style="font-size: 12pt; ">- It seems the "inlined" GetElementPtr instruction is just more concise and saves the need for a name for a register holding the value of the pointer. Is this correct?</span></div><div><span style="font-size: 12pt; ">- I'm now generating the aforementioned instructions (non-inlined) with the following code snippet with LLVM 3.2. Is there a way to generate "inlined" GetElementPtr instructions when calling a function just like the first example programmatically?</span></div><div><span style="font-size: 12pt; "><br></span></div><div><span style="font-size: 12pt; ">-------------------------------------------------------------------</span></div><div><span style="font-size: 12pt; ">BasicBlock* bb = (omitted)</span></div><div>IRBuilder<> irb(bb);</div><div><span style="font-size: 12pt; "><div>Value* global_str_ptr = irb.CreateGlobalString(bbn, "bbname");</div><div>std::vector<Value*> indices;</div><div>indices.push_back(ConstantInt::get(IntegerType::getInt32Ty(getGlobalContext()), 0));</div><div>indices.push_back(ConstantInt::get(IntegerType::getInt32Ty(getGlobalContext()), 0));</div><div><span style="font-size: 12pt; ">GetElementPtrInst* gep_str = GetElementPtrInst::CreateInBounds(global_str_ptr,</span></div><div><span class="Apple-tab-span" style="white-space: pre; "> </span>indices,</div><div><span class="Apple-tab-span" style="white-space: pre; "> </span>"bbname", bb->getFirstNonPHI());</div><div><span style="font-size: 12pt; ">args.push_back(gep_str);</span></div><div>args.push_back(ConstantInt::get(IntegerType::getInt32Ty(getGlobalContext()),</div><div><span class="Apple-tab-span" style="white-space: pre; "> </span>size));</div><div>CallInst* inc_call = CallInst::Create(func_incrementFaultSitesEnumerated, args,</div><div><span class="Apple-tab-span" style="white-space: pre; "> </span>"", first_inst);</div><div>-------------------------------------------------------------------</div></span></div><div><span style="font-size: 12pt; "><br></span></div><div><span style="font-size: 12pt; ">Thanks in advance!</span></div><div><span style="font-size: 12pt; "><br></span></div><div><span style="font-size: 12pt; ">Tommy Chen</span></div><div><span style="font-size: 12pt; ">08-19-2013</span></div></div></div>_______________________________________________<br>LLVM Developers mailing list<br><a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a><span class="Apple-converted-space"> </span> <a href="http://llvm.cs.uiuc.edu">http://llvm.cs.uiuc.edu</a><br><a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br></div></blockquote></div><br></body></html>