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

Fix ICE wrt. inline IR and empty parameter types tuple #3509

Merged
merged 1 commit into from
Jul 16, 2020
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
12 changes: 3 additions & 9 deletions gen/inlineir.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,24 +162,18 @@ DValue *DtoInlineIRExpr(Loc &loc, FuncDeclaration *fdecl,
}
stream << "define " << *DtoType(ret) << " @" << mangled_name << "(";

for (size_t i = 0;;) {
for (size_t i = 0; i < arg_types.length; ++i) {
Type *ty = isType(arg_types[i]);
// assert(ty);
if (!ty) {
error(tinst->loc,
"All parameters of a template defined with pragma "
"`LDC_inline_ir`, except for the first one or the first three"
", should be types");
fatal();
}
if (i != 0)
stream << ", ";
stream << *DtoType(ty);

i++;
if (i >= arg_types.length) {
break;
}

stream << ", ";
}

stream << ")\n{\n" << code;
Expand Down
25 changes: 25 additions & 0 deletions tests/codegen/inline_ir_noparams.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// RUN: %ldc -O -output-ll -of=%t.ll %s && FileCheck %s < %t.ll

// CHECK: define {{.*}}11unreachableFZv
void unreachable()
{
import ldc.llvmasm;
// CHECK-NEXT: unreachable
__ir!("unreachable", void)();
// CHECK-NEXT: }
}

extern bool flag;

// CHECK: define {{.*}}3bar
int bar()
{
int r = 123;
if (flag)
{
r = 456;
unreachable();
}
// CHECK: ret i32 123
return r;
}