llvm-project/clang/test/CodeGen/stackrealign-main.c
Nick Desaulniers 3787ee4571 reland [IR] make -stack-alignment= into a module attr
Relands commit 433c8d950cb3a1fa0977355ce0367e8c763a3f13 with fixes for
MIPS.

Similar to D102742, specifying the stack alignment via CodegenOpts means
that this flag gets dropped during LTO, unless the command line is
re-specified as a plugin opt. Instead, encode this information as a
module level attribute so that we don't have to expose this llvm
internal flag when linking the Linux kernel with LTO.

Looks like external dependencies might need a fix:
* https://github.com/llvm-hs/llvm-hs/issues/345
* https://github.com/halide/Halide/issues/6079

Link: https://github.com/ClangBuiltLinux/linux/issues/1377

Reviewed By: tejohnson

Differential Revision: https://reviews.llvm.org/D103048
2021-06-08 10:59:46 -07:00

23 lines
742 B
C

// RUN: %clang_cc1 -triple i386-unknown-unknown -emit-llvm -o - -mstack-alignment=64 %s | FileCheck %s
// RUN: %clang_cc1 -triple i386-unknown-unknown -emit-llvm -o - %s | FileCheck %s --check-prefix=DEFAULT
// CHECK-LABEL: define{{.*}} void @other()
// CHECK: [[OTHER:#[0-9]+]]
// CHECK: {
void other(void) {}
// CHECK-LABEL: define{{.*}} i32 @main(
// CHECK: [[MAIN:#[0-9]+]]
// CHECK: {
int main(int argc, char **argv) {
other();
return 0;
}
// CHECK: attributes [[OTHER]] = { noinline nounwind optnone
// CHECK-NOT: "stackrealign"
// CHECK: }
// CHECK: attributes [[MAIN]] = { noinline nounwind optnone {{.*}}"stackrealign"{{.*}} }
// CHECK: !{i32 1, !"override-stack-alignment", i32 64}
// DEFAULT-NOT: "override-stack-alignment"