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

[CIR] [CodeGen] Remove NYI in buildPointerWithAlignment #949

Merged
merged 1 commit into from
Oct 8, 2024
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
15 changes: 5 additions & 10 deletions clang/lib/CIR/CodeGen/CIRGenExpr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,6 @@ static Address buildPointerWithAlignment(const Expr *expr,
cgf.CGM.buildExplicitCastExprType(ECE, &cgf);

switch (CE->getCastKind()) {
default: {
llvm::errs() << CE->getCastKindName() << "\n";
assert(0 && "not implemented");
}
// Non-converting casts (but not C's implicit conversion from void*).
case CK_BitCast:
case CK_NoOp:
Expand Down Expand Up @@ -183,12 +179,6 @@ static Address buildPointerWithAlignment(const Expr *expr,
}
break;

// Nothing to do here...
case CK_LValueToRValue:
case CK_NullToPointer:
case CK_IntegralToPointer:
break;

// Array-to-pointer decay. TODO(cir): BaseInfo and TBAAInfo.
case CK_ArrayToPointerDecay:
return cgf.buildArrayToPointerDecay(CE->getSubExpr());
Expand All @@ -205,6 +195,11 @@ static Address buildPointerWithAlignment(const Expr *expr,
Addr, Derived, CE->path_begin(), CE->path_end(),
cgf.shouldNullCheckClassCastValue(CE), CE->getExprLoc());
}

// TODO: Is there any reason to treat base-to-derived conversions
// specially?
default:
break;
}
}

Expand Down
13 changes: 13 additions & 0 deletions clang/test/CIR/CodeGen/function-to-pointer-decay.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s -o - | FileCheck %s

void f(void);

void test_call_lvalue_cast() {
(*(void (*)(int))f)(42);
}

// CHECK: cir.func {{.*}}@test_call_lvalue_cast()
// CHECK: [[F:%.+]] = cir.get_global @f
// CHECK: [[CASTED:%.+]] = cir.cast(bitcast, [[F]]
// CHECK: [[CONST:%.+]] = cir.const #cir.int<42>
// CHECK: cir.call [[CASTED]]([[CONST]])