[LLVMdev] LoadInst::getAlignment

Humphreys, Jonathan j-humphreys at ti.com
Thu Aug 30 15:01:07 PDT 2012


I'm just diving into LLVM.  What does it mean when LoadInst::getAlignment() returns 0?  Unknown alignment, use default alignment of the type for the load, something else?

In particular, clang  appears to set to 0 the alignment of the load instruction that results from accessing the lvalue returned by a call.  Is this the intended behavior?

For example:

const double &foo(void *p);
double ans;

void bar()
{
   ans = foo(0);
}

Produces:

target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f3
2:32:32-f64:64:64-v64:64:64-v128:64:128-a0:0:64-n32-S64"
target triple = "armv4t---eabi"

@ans = global double 0.000000e+00, align 8

define void @_Z3barv() {
entry:
  %call = call double* @_Z3fooPv(i8* null)
  %0 = load double* %call
  store double %0, double* @ans, align 8
  ret void
}

declare double* @_Z3fooPv(i8*)

Notice that the load does not have an alignment specification.

Thanks for your help,
Jon



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20120830/4ea71664/attachment.html>


More information about the llvm-dev mailing list