Skip to content

[Mangler] Calculate the argument list byte count suffix correctly whe… #116

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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions llvm/lib/IR/Mangler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,11 @@ static void addByteCountSuffix(raw_ostream &OS, const Function *F,
const unsigned PtrSize = DL.getPointerSize();

for (const Argument &A : F->args()) {
// For the purposes of the byte count suffix, structs returned by pointer
// do not count as function arguments.
if (A.hasStructRetAttr())
continue;

// 'Dereference' type in case of byval or inalloca parameter attribute.
uint64_t AllocSize = A.hasPassPointeeByValueCopyAttr() ?
A.getPassPointeeByValueCopySize(DL) :
Expand Down
15 changes: 15 additions & 0 deletions llvm/test/CodeGen/X86/stdcall.ll
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,21 @@ entry:
ret i32 %a
}

%struct.large_type = type { i64, i64, i64 }

define x86_stdcallcc void @ReturnLargeType(%struct.large_type* noalias nocapture sret(%struct.large_type) align 8 %agg.result) {
; CHECK: ReturnLargeType@0:
; CHECK: retl
entry:
%a = getelementptr inbounds %struct.large_type, %struct.large_type* %agg.result, i32 0, i32 0
store i64 123, i64* %a, align 8
%b = getelementptr inbounds %struct.large_type, %struct.large_type* %agg.result, i32 0, i32 1
store i64 456, i64* %b, align 8
%c = getelementptr inbounds %struct.large_type, %struct.large_type* %agg.result, i32 0, i32 2
store i64 789, i64* %c, align 8
ret void
}

@B = global %0 { void (...)* bitcast (void ()* @MyFunc to void (...)*) }, align 4
; CHECK: _B:
; CHECK: .long _MyFunc@0
Expand Down
3 changes: 1 addition & 2 deletions llvm/test/CodeGen/X86/vectorcall.ll
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,7 @@ declare void @llvm.memcpy.p0i8.p0i8.i64(i8* nocapture writeonly, i8* nocapture r
declare void @llvm.memcpy.p0i8.p0i8.i32(i8* nocapture writeonly, i8* nocapture readonly, i32, i1)

define x86_vectorcallcc void @test_mixed_7(%struct.HVA5* noalias sret(%struct.HVA5) %agg.result) {
; X86-LABEL: test_mixed_7@@4
; X64-LABEL: test_mixed_7@@8
; CHECK-LABEL: test_mixed_7@@0
; X64: mov{{[ql]}} %rcx, %rax
; CHECK: movaps %xmm{{[0-9]}}, 64(%{{rcx|eax}})
; CHECK: movaps %xmm{{[0-9]}}, 48(%{{rcx|eax}})
Expand Down