<div dir="ltr"><div dir="ltr"><div dir="ltr"><div class="gmail_default" style="font-family:trebuchet ms,sans-serif">Hi,</div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif"><br></div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif">Let's say, we want to insert a global variable to a module, that, we can accomplish as shown in the below code snippet. However, if I compare the original type with the type after the call to getOrInsertGlobal(), the two pointers are different as shown. Is it a correct behavior? If so, what is the right way to get the type of global variable so that it is same as original type?</div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif"><br></div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif">PS: I am using LLVM versoin 8<br></div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif"><br></div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif">------------------<br></div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif">// Get type of global variable to be inserted                              <br>auto varType = IntegerType::get(M.getContext(), 32);                       <br>outs() << "varType = " << varType << "\n";                                 <br>                                                                                 <br>// Insert newly created variable to current module                         <br>auto globalVar = M.getOrInsertGlobal("myVar", varType);                 <br>outs() << "varType = " << globalVar->getType() << "\n";  <br></div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif">------------------</div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif"><br></div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif"><br></div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif">------------------</div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif">varType = 0x5567b71a22b8<br>varType = 0x5567b71ce1b0<br></div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif">------------------<br clear="all"></div><br>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div>Thanks,</div><div>Mahesha<br></div></div></div></div></div></div>