[LLVMdev] Incorrect code generated for arm64

Simon Taylor simontaylor1 at ntlworld.com
Mon May 4 03:19:39 PDT 2015


Hi all,

I’ve narrowed down a problem in my code to the following test case:

- - - -

typedef struct {float v[2];} vec2;
typedef struct {float v[3];} vec3;

vec2 getVec2();

vec3 getVec3()
{
  vec2 myVec = getVec2();

  vec3 res;
  res.v[0] = myVec.v[0];
  res.v[1] = myVec.v[1];
  res.v[2] = 1;
  return res;
}

- - - -

Compiling this with any level of optimization for arm64 gives incorrect code, unless my test case above is triggering some undefined behaviour that I’m not aware of. Other architectures appear to work OK.

$ clang -arch arm64 -O1 test.c -S -o - 
	.section	__TEXT,__text,regular,pure_instructions
	.ios_version_min 5, 0
	.globl	_getVec3
	.align	2
_getVec3:                               ; @getVec3
; BB#0:
	b	_getVec2


.subsections_via_symbols

- - - -

I’m happy to file a bug for this, but not sure quite where it belongs - clang, LLVM or direct to Apple. Can someone test the top of tree and see if it suffers the same issue?

I’m currently using the latest Xcode from Apple (clang -v gives “Apple LLVM version 6.1.0 (clang-602.0.49) (based on LLVM 3.6.0svn)”) but the LLVM 3.5-based compiler in the previous Xcode release also generates the same code.


Simon





More information about the llvm-dev mailing list