-
Notifications
You must be signed in to change notification settings - Fork 15.1k
[Clang] Add __builtin_stack_address
#148281
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
moorabbit
wants to merge
23
commits into
llvm:main
Choose a base branch
from
moorabbit:gcc-builtin-stack-address
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
029d9fc
[Clang] Add `__builtin_stack_address`
moorabbit 0b5e0ed
[LLVM] Document 'llvm.stackaddress' Intrinsic
moorabbit 2b8084a
[LLVM] Correct minor typo in a comment
moorabbit 020909e
[LLVM] Change SelectionDAG Opcode name
moorabbit 88db438
[Clang] Refactor test case
moorabbit 0669180
[Clang] Code formatting
moorabbit aea6944
Merge branch 'main' into gcc-builtin-stack-address
moorabbit 20d0259
Disable custom lowering of STACKADDRESS on x86
moorabbit da68490
Expand STACKADDRESS to STACKSAVE by default
moorabbit 6cdcf58
Custom lowering of STACKADDRESS on Sparc
moorabbit c56be28
Remove Target check from Sema
moorabbit 1ed8a5d
clang-format
moorabbit 1339b31
refactor test cases
moorabbit 64eb4ad
AaronBallman's suggestion
moorabbit 7c38381
Fix windows CI failure
moorabbit d47cb56
efriedma-quic's comment
moorabbit 1ba60ce
Fix note
moorabbit 4f1fad5
move aarch64 test under llvm/test/CodeGen/aarch64/
moorabbit 6ced7f8
nikic's suggestions
moorabbit fdb520a
re-format clang docs
moorabbit 1f77682
nikic's suggestion
moorabbit 57e9fe5
arsenm's comment
moorabbit ae3b2b6
arsenm's comment
moorabbit File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| // RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s | ||
|
|
||
| // CHECK-LABEL: define {{[^@]+}} @a() | ||
| // CHECK: call {{[^@]+}} @llvm.stackaddress.p0() | ||
| void *a() { | ||
| return __builtin_stack_address(); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| // RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s -o - | llvm-cxxfilt | FileCheck %s --check-prefixes=COMMON,NO-OPT | ||
| // RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s -O3 -o - | llvm-cxxfilt | FileCheck %s --check-prefixes=COMMON,OPT | ||
|
|
||
| struct S { | ||
| void *a(); | ||
| }; | ||
|
|
||
| // COMMON-LABEL: @S::a() | ||
| // COMMON: call ptr @llvm.stackaddress.p0() | ||
| void *S::a() { | ||
| return __builtin_stack_address(); | ||
| } | ||
|
|
||
| // COMMON-LABEL: define {{[^@]+}} @two() | ||
| void *two() { | ||
|
|
||
| // The compiler is allowed to inline a function calling `__builtin_stack_address`. | ||
| // | ||
| // OPT-NOT: define {{[^@]+}} @"two()::$_0::operator()() const" | ||
| // OPT: call {{[^@]+}} @llvm.stackaddress.p0() | ||
| // | ||
| // NO-OPT-DAG: define {{[^@]+}} @"two()::$_0::operator()() const" | ||
| // NO-OPT-DAG: call {{[^@]+}} @"two()::$_0::operator()() const" | ||
| auto l = []() { return __builtin_stack_address(); }; | ||
| return l(); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| ; RUN: llc < %s -mtriple=aarch64 | FileCheck %s | ||
|
|
||
| declare ptr @llvm.stackaddress.p0() | ||
|
|
||
| define ptr @test() { | ||
| ; CHECK: mov x0, sp | ||
| ; CHECK: ret | ||
| %sp = call ptr @llvm.stackaddress.p0() | ||
| ret ptr %sp | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| ; RUN: llc < %s -mtriple=armv7 | FileCheck %s | ||
|
|
||
| declare ptr @llvm.stackaddress.p0() | ||
|
|
||
| define ptr @test() { | ||
| ; CHECK: mov r0, sp | ||
| ; CHECK: bx lr | ||
| %sp = call ptr @llvm.stackaddress.p0() | ||
| ret ptr %sp | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| ; RUN: not llc < %s -mtriple nvptx 2>&1 | FileCheck %s | ||
|
|
||
| declare ptr @llvm.stackaddress.p0() | ||
|
|
||
| define ptr @test() { | ||
| ; CHECK: error: <unknown>:0:0: llvm.stackaddress is not supported on this target. | ||
| %sp = call ptr @llvm.stackaddress.p0() | ||
| ret ptr %sp | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| ; RUN: llc < %s -mtriple=sparc | FileCheck --check-prefix=sparc32 %s | ||
| ; RUN: llc < %s -mtriple=sparcv9 | FileCheck --check-prefix=sparc64 %s | ||
|
|
||
| declare ptr @llvm.stackaddress.p0() | ||
|
|
||
| define ptr @test() { | ||
| ; sparc32: save %sp, -96, %sp | ||
| ; sparc32: ret | ||
| ; sparc32: restore %sp, 68, %o0 | ||
| ; | ||
| ; sparc64: save %sp, -128, %sp | ||
| ; sparc64: ret | ||
| ; sparc64: restore %sp, 2175, %o0 | ||
| %sp = call ptr @llvm.stackaddress.p0() | ||
| ret ptr %sp | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| ; RUN: llc < %s -mtriple=x86_64-linux-gnu -o - | FileCheck --check-prefix=x86_64 %s | ||
| ; RUN: llc < %s -mtriple=i386-linux-gnu -o - | FileCheck --check-prefix=i386 %s | ||
|
|
||
| declare ptr @llvm.stackaddress.p0() | ||
|
|
||
| define ptr @test() { | ||
| ; x86_64: movq %rsp, %rax | ||
| ; x86_64: retq | ||
|
|
||
| ; i386: movl %esp, %eax | ||
| ; i386: retl | ||
| %sp = call ptr @llvm.stackaddress.p0() | ||
| ret ptr %sp | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.