Skip to content
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

LLVM 12: Fix ICEs wrt. bitcode writing & add vanilla LLVM 12 CI job #3708

Merged
merged 3 commits into from
Apr 28, 2021
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
2 changes: 1 addition & 1 deletion .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ task:
timeout_in: 60m
environment:
CI_OS: linux
LIBCLANG_COMMON_VERSION: "11"
LIBCLANG_COMMON_VERSION: "12"
EXTRA_APT_PACKAGES: "gdmd"
EXTRA_CMAKE_FLAGS: "-DBUILD_SHARED_LIBS=ON -DBUILD_LTO_LIBS=ON -DD_COMPILER=gdmd -DLDC_LINK_MANUALLY=ON"
PARALLELISM: 8
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/supported_llvm_versions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ jobs:
fail-fast: false
matrix:
include:
- job_name: Ubuntu 16.04, LLVM 12, latest LDC beta
os: ubuntu-16.04
host_dc: ldc-beta
llvm_version: "12.0.0"
cmake_opts: ""
- job_name: Ubuntu 16.04, LLVM 11, latest LDC beta
os: ubuntu-16.04
host_dc: ldc-beta
Expand Down
4 changes: 4 additions & 0 deletions gen/abi-x86-64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,11 @@ struct ImplicitByvalRewrite : ABIRewrite {

void applyTo(IrFuncTyArg &arg, LLType *finalLType = nullptr) override {
ABIRewrite::applyTo(arg, finalLType);
#if LDC_LLVM_VER >= 1200
arg.attrs.addByValAttr(DtoType(arg.type));
#else
arg.attrs.addAttribute(LLAttribute::ByVal);
#endif
if (auto alignment = DtoAlignment(arg.type))
arg.attrs.addAlignmentAttr(alignment);
}
Expand Down
8 changes: 8 additions & 0 deletions gen/functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,11 @@ llvm::FunctionType *DtoFunctionType(Type *type, IrFuncTy &irFty, Type *thistype,
if (abi->returnInArg(f, fd && fd->needThis())) {
// sret return
llvm::AttrBuilder sretAttrs;
#if LDC_LLVM_VER >= 1200
sretAttrs.addStructRetAttr(DtoType(rt));
#else
sretAttrs.addAttribute(LLAttribute::StructRet);
#endif
sretAttrs.addAttribute(LLAttribute::NoAlias);
if (unsigned alignment = DtoAlignment(rt))
sretAttrs.addAlignmentAttr(alignment);
Expand Down Expand Up @@ -198,7 +202,11 @@ llvm::FunctionType *DtoFunctionType(Type *type, IrFuncTy &irFty, Type *thistype,
// LLVM ByVal parameters are pointers to a copy in the function
// parameters stack. The caller needs to provide a pointer to the
// original argument.
#if LDC_LLVM_VER >= 1200
attrs.addByValAttr(DtoType(loweredDType));
#else
attrs.addAttribute(LLAttribute::ByVal);
#endif
if (auto alignment = DtoAlignment(loweredDType))
attrs.addAlignmentAttr(alignment);
passPointer = true;
Expand Down
4 changes: 4 additions & 0 deletions gen/tocall.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,11 @@ static void addExplicitArguments(std::vector<LLValue *> &args, AttrSet &attrs,

llvm::AttrBuilder initialAttrs;
if (passByVal) {
#if LDC_LLVM_VER >= 1200
initialAttrs.addByValAttr(DtoType(argType));
#else
initialAttrs.addAttribute(LLAttribute::ByVal);
#endif
if (auto alignment = DtoAlignment(argType))
initialAttrs.addAlignmentAttr(alignment);
} else {
Expand Down
8 changes: 4 additions & 4 deletions tests/codegen/align.d
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ static Inner globalInner;
Outer passAndReturnOuterByVal(Outer arg) { return arg; }
// CHECK: define{{.*}} void @{{.*}}_D5align23passAndReturnOuterByValFSQBh5OuterZQl
/* the 32-bit x86 ABI substitutes the sret attribute by inreg */
// CHECK-SAME: %align.Outer* {{noalias sret|inreg noalias}} align 32 %.sret_arg
// CHECK-SAME: %align.Outer* {{noalias sret.*|inreg noalias}} align 32 %.sret_arg
/* How the arg is passed by value is ABI-specific, but the pointer must be aligned.
* When the argument is passed as a byte array and copied into a stack alloc, that stack alloca must be aligned. */
// CHECK: {{(align 32 %arg|%arg = alloca %align.Outer, align 32)}}

Inner passAndReturnInnerByVal(Inner arg) { return arg; }
// CHECK: define{{.*}} void @{{.*}}_D5align23passAndReturnInnerByValFSQBh5InnerZQl
// CHECK-SAME: %align.Inner* {{noalias sret|inreg noalias}} align 32 %.sret_arg
// CHECK-SAME: %align.Inner* {{noalias sret.*|inreg noalias}} align 32 %.sret_arg
// CHECK: {{(align 32 %arg|%arg = alloca %align.Inner, align 32)}}

void main() {
Expand Down Expand Up @@ -59,13 +59,13 @@ void main() {

outer = passAndReturnOuterByVal(outer);
// CHECK: call{{.*}} void @{{.*}}_D5align23passAndReturnOuterByValFSQBh5OuterZQl
// CHECK-SAME: %align.Outer* {{noalias sret|inreg noalias}} align 32 %.sret_tmp
// CHECK-SAME: %align.Outer* {{noalias sret.*|inreg noalias}} align 32 %.sret_tmp
// The argument is either passed by aligned (optimizer hint) pointer or as an array of i32/64 and copied into an aligned stack slot inside the callee.
// CHECK-SAME: {{(align 32 %|\[[0-9]+ x i..\])}}

inner = passAndReturnInnerByVal(inner);
// CHECK: call{{.*}} void @{{.*}}_D5align23passAndReturnInnerByValFSQBh5InnerZQl
// CHECK-SAME: %align.Inner* {{noalias sret|inreg noalias}} align 32 %.sret_tmp
// CHECK-SAME: %align.Inner* {{noalias sret.*|inreg noalias}} align 32 %.sret_tmp
// The argument is either passed by aligned (optimizer hint) pointer or as an array of i32/64 and copied into an aligned stack slot inside the callee.
// CHECK-SAME: {{(align 32 %|\[[0-9]+ x i..\])}}
}