<div style="line-height:1.7;color:#000000;font-size:14px;font-family:arial"> Hi, all<br>I try to get the Instructions where one function use the global variable.<br><br>for (llvm::Module::global_iterator gvar_iter = M.global_begin(); gvar_iter != M.global_end(); gvar_iter++)<br>    {<br>        llvm::GlobalVariable *gvar = &*gvar_iter;<br>        llvm::errs() << "const global var: " << gvar->getName() << "\n";<br><br>        for ( llvm::GlobalVariable::use_iterator iter = gvar->use_begin(); iter != gvar->use_end(); iter++ )<br>        {<br>                        llvm::User *user = llvm::dyn_cast<llvm::User>(*iter);<br><br>       &nbs!
 p;                if ( llvm::isa<llvm::Constant>(user))<br>                          llvm::errs() << "isa Constant :";<br>                        else if (llvm::isa<llvm::Instruction>(user))<br>                          llvm::errs() << "isa Instruction";<br>                        else if (llvm::isa<llvm::Operator>(user))<br>            &nbs!
 p;           &n
bsp; llvm::errs() << "isa Operator";<br><br>                        if ( llvm::isa<llvm::Instruction>(user))<br>                        {<br>                                llvm::Instruction *instr = llvm::dyn_cast<llvm::Instruction>(*iter);<br>                                llvm::errs() << *instr << "\n";<br>                 &nbsp!
 ;      }<br>                        else if ( llvm::isa<llvm::ConstantExpr>(user))<br>                        {<br>                                llvm::ConstantExpr *const_expr = llvm::dyn_cast<llvm::ConstantExpr>(*iter);<br>                                llvm::errs() <<*const_expr << "\n";<br>                 !
        }<br>    &nbs
p;           }<br>                llvm::errs() << "\n";<br>    }<br>by this method ,I want to get the instruction in the function,but there will be retrun constantExp.<br>for example:<br>in the IR:<br>@gNoise = common global %struct.rs_allocation.0 zeroinitializer, align 4<br>tail call void @_Z13rsClearObjectP13rs_allocation(%struct.rs_allocation.0* @gNoise) nounwind<br>%7 = load [1 x i32]* bitcast (%struct.rs_allocation.0* @gNoise to [1 x i32]*), align 4<br><br>but the user will return the use as follows:<br>1.tail call void @_Z13rsClearObjectP13rs_allocation(%struct.rs_allocation.0* @gNoise) #0       <br>2. [1 x i32]* bitcast (%struct.rs_allocation.0* @gNoise to [1 x i32]*)             <br>I want to get the " instruction %7 = load [1 x i32]*!
  bitcast (%struct.rs_allocation.0* @gNoise to [1 x i32]*), align 4",<br>not "[1 x i32]* bitcast (%struct.rs_allocation.0* @gNoise to [1 x i32]*)"<br>How could I get this?<br>Thanks,<br>Yaoxiao<br></div>