Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Re-land "[MS] Overhaul how clang passes overaligned args on x86_32"
This brings back 2af74e2 and reverts eaabaf7. The changes were correct, the code that was broken contained an ODR violation that assumed that these types are passed equivalently: struct alignas(uint64_t) Wrapper { uint64_t P }; void f(uint64_t p); void f(Wrapper p); MSVC does not pass them the same way, and so clang-cl should not pass them the same way either.
- Loading branch information
Showing
6 changed files
with
269 additions
and
33 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// RUN: %clang_cc1 -fms-extensions -w -triple i386-pc-win32 -emit-llvm -o - %s | FileCheck %s | ||
|
||
// PR44395 | ||
// MSVC passes overaligned types indirectly since MSVC 2015. Make sure that | ||
// works with inalloca. | ||
|
||
// FIXME: Pass non-trivial *and* overaligned types indirectly. Right now the C++ | ||
// ABI rules say to use inalloca, and they take precedence, so it's not easy to | ||
// implement this. | ||
|
||
|
||
struct NonTrivial { | ||
NonTrivial(); | ||
NonTrivial(const NonTrivial &o); | ||
int x; | ||
}; | ||
|
||
struct __declspec(align(64)) OverAligned { | ||
OverAligned(); | ||
int buf[16]; | ||
}; | ||
|
||
extern int gvi32; | ||
|
||
int receive_inalloca_overaligned(NonTrivial nt, OverAligned o) { | ||
return nt.x + o.buf[0]; | ||
} | ||
|
||
// CHECK-LABEL: define dso_local i32 @"?receive_inalloca_overaligned@@Y{{.*}}" | ||
// CHECK-SAME: (<{ %struct.NonTrivial, %struct.OverAligned* }>* inalloca %0) | ||
|
||
int pass_inalloca_overaligned() { | ||
gvi32 = receive_inalloca_overaligned(NonTrivial(), OverAligned()); | ||
return gvi32; | ||
} | ||
|
||
// CHECK-LABEL: define dso_local i32 @"?pass_inalloca_overaligned@@Y{{.*}}" | ||
// CHECK: [[TMP:%[^ ]*]] = alloca %struct.OverAligned, align 64 | ||
// CHECK: call i8* @llvm.stacksave() | ||
// CHECK: alloca inalloca <{ %struct.NonTrivial, %struct.OverAligned* }> | ||
|
||
// Construct OverAligned into TMP. | ||
// CHECK: call x86_thiscallcc %struct.OverAligned* @"??0OverAligned@@QAE@XZ"(%struct.OverAligned* [[TMP]]) | ||
|
||
// Construct NonTrivial into the GEP. | ||
// CHECK: [[GEP:%[^ ]*]] = getelementptr inbounds <{ %struct.NonTrivial, %struct.OverAligned* }>, <{ %struct.NonTrivial, %struct.OverAligned* }>* %{{.*}}, i32 0, i32 0 | ||
// CHECK: call x86_thiscallcc %struct.NonTrivial* @"??0NonTrivial@@QAE@XZ"(%struct.NonTrivial* [[GEP]]) | ||
|
||
// Store the address of an OverAligned temporary into the struct. | ||
// CHECK: getelementptr inbounds <{ %struct.NonTrivial, %struct.OverAligned* }>, <{ %struct.NonTrivial, %struct.OverAligned* }>* %{{.*}}, i32 0, i32 1 | ||
// CHECK: store %struct.OverAligned* [[TMP]], %struct.OverAligned** %{{.*}}, align 4 | ||
// CHECK: call i32 @"?receive_inalloca_overaligned@@Y{{.*}}"(<{ %struct.NonTrivial, %struct.OverAligned* }>* inalloca %argmem) |
Oops, something went wrong.