[LLVMdev] MP1: Gelementptr question

Casey Carter ccarter at cs.uiuc.edu
Sat Sep 14 12:11:01 PDT 2002

The following is legal LLVM code in which ptr, ptr2, and ptr3 are all 

%struct = type { int, int }
int %p() {
  %ptr1 = alloca %struct
  %ptr2 = getelementptr %struct* %ptr1
  %ptr3 = getelementptr %struct* %ptr2, uint 0
  %pint = getelementptr %struct* %ptr3, uint 0, ubyte 0
  %rval = load int* %pint
   ret int %rval

Should our pass a) ignore this, not replace %ptr1, let copy-propagation 
fix the problem, or b) catch this obvious aliasing and replace uses of 
fields of %ptr2 and %ptr3 with the replaced scalar fields of ptr1?

Casey Carter
Casey at Carter.net
ccarter at uiuc.edu
AIM: cartec69

More information about the llvm-dev mailing list