[cfe-users] getelementptr global type query

Bella V via cfe-users cfe-users at lists.llvm.org
Wed May 26 13:41:23 PDT 2021


Hello All,

I'm not able to extract f1 from a getelementptr inbounds Instruction.

struct foo {
int num;
};
extern struct foo f1;
void hello () {
if (f1.num){
}
}
@f1 = external dso_local global %struct.foo, align 4
define dso_local void @hello() #0 !dbg !9 {
%1 = load i32, i32* getelementptr inbounds (%struct.foo, %struct.foo* *@f1*
, i32 0, i32 0), align 4, !dbg !13
%2 = icmp ne i32 %1, 0, !dbg !15
br i1 %2, label %3, label %4, !dbg !16
}

Instruction*Inst = load i32, i32* getelementptr inbounds (%struct.foo,
%struct.foo* @f1, i32 0, i32 0)
Value *V=Inst->getOperand()[0] = i32* getelementptr inbounds (%struct.foo,
%struct.foo* @f1, i32 0, i32 0)
*V->getName().str() *// does not return anything.


Any pointers.

Thanks.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-users/attachments/20210526/7021cb7a/attachment.html>


More information about the cfe-users mailing list