forked from llvm/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reapply "[HLSL] set alwaysinline on HLSL functions (llvm#106588)"
This reverts commit 4a63f4d. It was reverted because of a buildbot breakage, but the fix-forward has landed (llvm#109023).
- Loading branch information
Showing
9 changed files
with
282 additions
and
42 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 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 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,76 @@ | ||
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-compute -std=hlsl202x -emit-llvm -o - -disable-llvm-passes %s | FileCheck %s --check-prefixes=CHECK,NOINLINE | ||
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -std=hlsl202x -emit-llvm -o - -disable-llvm-passes %s | FileCheck %s --check-prefixes=CHECK,NOINLINE | ||
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-compute -std=hlsl202x -emit-llvm -o - -O0 %s | FileCheck %s --check-prefixes=CHECK,INLINE | ||
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -std=hlsl202x -emit-llvm -o - -O0 %s | FileCheck %s --check-prefixes=CHECK,INLINE | ||
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-compute -std=hlsl202x -emit-llvm -o - -O1 %s | FileCheck %s --check-prefixes=CHECK,INLINE | ||
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -std=hlsl202x -emit-llvm -o - -O1 %s | FileCheck %s --check-prefixes=CHECK,INLINE | ||
|
||
// Tests that implicit constructor calls for user classes will always be inlined. | ||
|
||
struct Weed { | ||
Weed() {Count += 1;} | ||
[[maybe_unused]] void pull() {Count--;} | ||
static int weedCount() { return Count; } | ||
private: | ||
static int Count; | ||
|
||
} YardWeeds; | ||
|
||
int Weed::Count = 1; // It begins. . . | ||
|
||
struct Kitty { | ||
unsigned burrsInFur; | ||
|
||
Kitty() { | ||
burrsInFur = 0; | ||
} | ||
|
||
void wanderInYard(int hours) { | ||
burrsInFur = hours*Weed::weedCount()/8; | ||
} | ||
|
||
void lick() { | ||
if(burrsInFur) { | ||
burrsInFur--; | ||
Weed w; | ||
} | ||
} | ||
|
||
} Nion; | ||
|
||
void NionsDay(int hours) { | ||
static Kitty Nion; | ||
Nion.wanderInYard(hours); | ||
while(Nion.burrsInFur) Nion.lick(); | ||
} | ||
|
||
// CHECK: define void @main() | ||
// CHECK-NEXT: entry: | ||
// Verify constructor is emitted | ||
// NOINLINE-NEXT: call void @_GLOBAL__sub_I_inline_constructors.hlsl() | ||
// NOINLINE-NEXT: %0 = call i32 @llvm.dx.flattened.thread.id.in.group() | ||
// NOINLINE-NEXT: call void @"?main@@YAXI@Z"(i32 %0) | ||
// Verify inlining leaves only calls to "llvm." intrinsics | ||
// INLINE-NOT: call {{[^@]*}} @{{[^l][^l][^v][^m][^\.]}} | ||
// CHECK: ret void | ||
[shader("compute")] | ||
[numthreads(1,1,1)] | ||
void main(unsigned GI : SV_GroupIndex) { | ||
NionsDay(10); | ||
} | ||
|
||
|
||
// CHECK: define void @rainyMain() | ||
// CHECK-NEXT: entry: | ||
// Verify constructor is emitted | ||
// NOINLINE-NEXT: call void @_GLOBAL__sub_I_inline_constructors.hlsl() | ||
// NOINLINE-NEXT: call void @"?rainyMain@@YAXXZ"() | ||
// Verify inlining leaves only calls to "llvm." intrinsics | ||
// INLINE-NOT: call {{[^@]*}} @{{[^l][^l][^v][^m][^\.]}} | ||
// CHECK: ret void | ||
[shader("compute")] | ||
[numthreads(1,1,1)] | ||
void rainyMain() { | ||
NionsDay(1); | ||
} | ||
|
Oops, something went wrong.