<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 12pt;
font-family:΢ÈíÑźÚ
}
--></style></head>
<body class='hmmessage'><div dir='ltr'>

<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 12pt;
font-family:????
}
--></style>
<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><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></body>
</html>