Skip to content

Commit aecca04

Browse files
committedSep 11, 2015
Record function attribute "stackrealign" instead of using backend option
-force-align-stack. Also, make changes to the driver so that -mno-stack-realign is no longer an option exposed to the end-user that disallows stack realignment in the backend. Differential Revision: http://reviews.llvm.org/D11815 llvm-svn: 247451
1 parent bc497c9 commit aecca04

File tree

7 files changed

+21
-25
lines changed

7 files changed

+21
-25
lines changed
 

‎clang/include/clang/Frontend/CodeGenOptions.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ CODEGENOPT(UseRegisterSizedBitfieldAccess , 1, 0)
150150
CODEGENOPT(VerifyModule , 1, 1) ///< Control whether the module should be run
151151
///< through the LLVM Verifier.
152152

153-
CODEGENOPT(StackRealignment , 1, 0) ///< Control whether to permit stack
153+
CODEGENOPT(StackRealignment , 1, 0) ///< Control whether to force stack
154154
///< realignment.
155155
CODEGENOPT(UseInitArray , 1, 0) ///< Control whether to use .init_array or
156156
///< .ctors.

‎clang/lib/CodeGen/CGCall.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1494,8 +1494,8 @@ void CodeGenModule::ConstructAttributeList(const CGFunctionInfo &FI,
14941494
FuncAttrs.addAttribute("stack-protector-buffer-size",
14951495
llvm::utostr(CodeGenOpts.SSPBufferSize));
14961496

1497-
if (!CodeGenOpts.StackRealignment)
1498-
FuncAttrs.addAttribute("no-realign-stack");
1497+
if (CodeGenOpts.StackRealignment)
1498+
FuncAttrs.addAttribute("stackrealign");
14991499

15001500
// Add target-cpu and target-features attributes to functions. If
15011501
// we have a decl for the function and it has a target attribute then

‎clang/lib/Driver/Tools.cpp

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4326,14 +4326,8 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
43264326

43274327
// Translate -mstackrealign
43284328
if (Args.hasFlag(options::OPT_mstackrealign, options::OPT_mno_stackrealign,
4329-
false)) {
4330-
CmdArgs.push_back("-backend-option");
4331-
CmdArgs.push_back("-force-align-stack");
4332-
}
4333-
if (!Args.hasFlag(options::OPT_mno_stackrealign, options::OPT_mstackrealign,
4334-
false)) {
4329+
false))
43354330
CmdArgs.push_back(Args.MakeArgString("-mstackrealign"));
4336-
}
43374331

43384332
if (Args.hasArg(options::OPT_mstack_alignment)) {
43394333
StringRef alignment = Args.getLastArgValue(options::OPT_mstack_alignment);

‎clang/test/CodeGen/stackrealign.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// RUN: %clang_cc1 %s -emit-llvm -o - -mstackrealign | FileCheck %s -check-prefix=REALIGN
2+
// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s -check-prefix=NO-REALIGN
3+
4+
// REALIGN: attributes #{{[0-9]+}} = {{{.*}} "stackrealign"
5+
// NO-REALIGN-NOT: attributes #{{[0-9]+}} = {{{.*}} "stackrealign"
6+
7+
void test1() {
8+
}

‎clang/test/Driver/rewrite-legacy-objc.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
// TEST0: clang{{.*}}" "-cc1"
44
// TEST0: "-rewrite-objc"
55
// FIXME: CHECK-NOT is broken somehow, it doesn't work here. Check adjacency instead.
6-
// TEST0: "-fmessage-length" "0" "-stack-protector" "1" "-mstackrealign" "-fblocks" "-fobjc-runtime=macosx-fragile" "-fencode-extended-block-signature" "-fno-objc-infer-related-result-type" "-fobjc-exceptions" "-fexceptions" "-fmax-type-align=16" "-fdiagnostics-show-option"
6+
// TEST0: "-fmessage-length" "0" "-stack-protector" "1" "-fblocks" "-fobjc-runtime=macosx-fragile" "-fencode-extended-block-signature" "-fno-objc-infer-related-result-type" "-fobjc-exceptions" "-fexceptions" "-fmax-type-align=16" "-fdiagnostics-show-option"
77
// TEST0: rewrite-legacy-objc.m"
88
// RUN: %clang -no-canonical-prefixes -target i386-apple-macosx10.9.0 -rewrite-legacy-objc %s -o - -### 2>&1 | \
99
// RUN: FileCheck -check-prefix=TEST1 %s
1010
// RUN: %clang -no-canonical-prefixes -target i386-apple-macosx10.6.0 -rewrite-legacy-objc %s -o - -### 2>&1 | \
1111
// RUN: FileCheck -check-prefix=TEST2 %s
12-
// TEST1: "-fmessage-length" "0" "-stack-protector" "1" "-mstackrealign" "-fblocks" "-fobjc-runtime=macosx-fragile" "-fobjc-subscripting-legacy-runtime" "-fencode-extended-block-signature" "-fno-objc-infer-related-result-type" "-fobjc-exceptions" "-fmax-type-align=16" "-fdiagnostics-show-option"
13-
// TEST2: "-fmessage-length" "0" "-stack-protector" "1" "-mstackrealign" "-fblocks" "-fobjc-runtime=macosx-fragile" "-fencode-extended-block-signature" "-fno-objc-infer-related-result-type" "-fobjc-exceptions" "-fmax-type-align=16" "-fdiagnostics-show-option"
12+
// TEST1: "-fmessage-length" "0" "-stack-protector" "1" "-fblocks" "-fobjc-runtime=macosx-fragile" "-fobjc-subscripting-legacy-runtime" "-fencode-extended-block-signature" "-fno-objc-infer-related-result-type" "-fobjc-exceptions" "-fmax-type-align=16" "-fdiagnostics-show-option"
13+
// TEST2: "-fmessage-length" "0" "-stack-protector" "1" "-fblocks" "-fobjc-runtime=macosx-fragile" "-fencode-extended-block-signature" "-fno-objc-infer-related-result-type" "-fobjc-exceptions" "-fmax-type-align=16" "-fdiagnostics-show-option"

‎clang/test/Driver/rewrite-objc.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
// TEST0: clang{{.*}}" "-cc1"
44
// TEST0: "-rewrite-objc"
55
// FIXME: CHECK-NOT is broken somehow, it doesn't work here. Check adjacency instead.
6-
// TEST0: "-fmessage-length" "0" "-stack-protector" "1" "-mstackrealign" "-fblocks" "-fobjc-runtime=macosx" "-fencode-extended-block-signature" "-fno-objc-infer-related-result-type" "-fobjc-exceptions" "-fexceptions" "-fmax-type-align=16" "-fdiagnostics-show-option"
6+
// TEST0: "-fmessage-length" "0" "-stack-protector" "1" "-fblocks" "-fobjc-runtime=macosx" "-fencode-extended-block-signature" "-fno-objc-infer-related-result-type" "-fobjc-exceptions" "-fexceptions" "-fmax-type-align=16" "-fdiagnostics-show-option"

‎clang/test/Driver/stackrealign.c

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
1-
// RUN: %clang -### %s 2>&1 | FileCheck %s -check-prefix=NORMAL
2-
// NORMAL-NOT: -force-align-stack
3-
// NORMAL: -mstackrealign
1+
// RUN: %clang -### %s 2>&1 | FileCheck %s -check-prefix=NO-REALIGN
2+
// RUN: %clang -### -mno-stackrealign -mstackrealign %s 2>&1 | FileCheck %s -check-prefix=REALIGN
3+
// RUN: %clang -### -mstackrealign -mno-stackrealign %s 2>&1 | FileCheck %s -check-prefix=NO-REALIGN
44

5-
// RUN: %clang -### -mstackrealign %s 2>&1 | FileCheck %s -check-prefix=MREALIGN
6-
// MREALIGN: -force-align-stack
7-
// MREALIGN: -mstackrealign
8-
9-
// RUN: %clang -### -mno-stackrealign %s 2>&1 | \
10-
// RUN: FileCheck %s -check-prefix=MNOREALIGN
11-
// MNOREALIGN-NOT: -force-align-stack
12-
// MNOREALIGN-NOT: -mstackrealign
5+
// REALIGN: -mstackrealign
6+
// NO-REALIGN-NOT: -mstackrealign

0 commit comments

Comments
 (0)
Please sign in to comment.