llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang-codegen Author: Ben Shi (benshi001) <details> <summary>Changes</summary> fixes https://github.com/llvm/llvm-project/issues/236067 --- Full diff: https://github.com/llvm/llvm-project/pull/237887.diff 3 Files Affected: - (modified) clang/docs/ReleaseNotes.md (+2) - (modified) clang/lib/CodeGen/CGExprScalar.cpp (+3-1) - (added) clang/test/CodeGen/avr/issue-236067.c (+10) ``````````diff diff --git a/clang/docs/ReleaseNotes.md b/clang/docs/ReleaseNotes.md index e769ad6a24e6bf..9354edd7eb841d 100644 --- a/clang/docs/ReleaseNotes.md +++ b/clang/docs/ReleaseNotes.md @@ -1221,6 +1221,8 @@ documentation](CIR/index.md) for more information regarding ClangIR's status and type. (#GH88592) - Fixed an assertion when emitting base destructor as alias on targets (such as AVR) which have different address spaces for code and data. (#GH236285) +- Fixed an assertion when casting 'AddrLabelExpr' on targets (such as AVR) + which which have different address spaces for code and data. (#GH236067) ### OpenACC Specific Changes diff --git a/clang/lib/CodeGen/CGExprScalar.cpp b/clang/lib/CodeGen/CGExprScalar.cpp index 0e2e29f0745d27..fe2a9bfd002e12 100644 --- a/clang/lib/CodeGen/CGExprScalar.cpp +++ b/clang/lib/CodeGen/CGExprScalar.cpp @@ -582,7 +582,9 @@ class ScalarExprEmitter Value *VisitUnaryExprOrTypeTraitExpr(const UnaryExprOrTypeTraitExpr *E); Value *VisitAddrLabelExpr(const AddrLabelExpr *E) { llvm::Value *V = CGF.GetAddrOfLabel(E->getLabel()); - return Builder.CreateBitCast(V, ConvertType(E->getType())); + // For some targets (such as AVR), code and data have different addrspaces. + return Builder.CreatePointerBitCastOrAddrSpaceCast( + V, ConvertType(E->getType())); } Value *VisitSizeOfPackExpr(SizeOfPackExpr *E) { diff --git a/clang/test/CodeGen/avr/issue-236067.c b/clang/test/CodeGen/avr/issue-236067.c new file mode 100644 index 00000000000000..78c6b798273d46 --- /dev/null +++ b/clang/test/CodeGen/avr/issue-236067.c @@ -0,0 +1,10 @@ +// RUN: %clang_cc1 -triple avr -emit-llvm < %s | FileCheck %s + +// This test case verifies https://github.com/llvm/llvm-project/issues/236067 . + +void foo() { + void *bar = &&label; +label: +} + +// CHECK: store ptr addrspacecast (ptr addrspace(1) blockaddress(@foo, %label) to ptr), ptr %bar, align 1 `````````` </details> https://github.com/llvm/llvm-project/pull/237887 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
