Is it possible to set a maximum alignment for local variables, either by passing a command line option or using target-specific hooks?
For example, in the code shown below, if the maximum alignment is 8, the alignment attribute in the source code (aligned(16)) will be ignored, and local variable a will be aligned on an 8-byte boundary.
align2.c
#define N 16
int main1 (int n, int *a);
int main (void)
{
int a[N+1] attribute ((aligned(16)));
main1 (N, a+1);
return 0;
}
.ll
clang -O3 -S -o - -emit-llvm align2.c
; ModuleID = ‘align2.c’
target datalayout = “e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32-n8:16:32”
target triple = “i386-pc-linux-gnu”
define i32 @main() nounwind {
entry:
%a = alloca [17 x i32], align 16;
%add.ptr = getelementptr inbounds [17 x i32]* %a, i32 0, i32 1
%call = call i32 @main1(i32 16, i32* %add.ptr) nounwind
ret i32 0
}
declare i32 @main1(i32, i32*)