Author: Matt Arsenault Date: 2022-12-21T08:27:24-05:00 New Revision: 2bb59549e11fdb1d6b6c4e68f4572783f414d67f
URL: https://github.com/llvm/llvm-project/commit/2bb59549e11fdb1d6b6c4e68f4572783f414d67f DIFF: https://github.com/llvm/llvm-project/commit/2bb59549e11fdb1d6b6c4e68f4572783f414d67f.diff LOG: clang: Respect function address space for __builtin_function_start Fixes assertion. Added: clang/test/CodeGen/avr/builtin-function-start.c Modified: clang/lib/CodeGen/CodeGenModule.cpp Removed: ################################################################################ diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index ac71346de2987..fcb60e3b4e705 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -4170,8 +4170,9 @@ llvm::Constant *CodeGenModule::GetFunctionStart(const ValueDecl *Decl) { llvm::GlobalValue *F = cast<llvm::GlobalValue>(GetAddrOfFunction(Decl)->stripPointerCasts()); - return llvm::ConstantExpr::getBitCast(llvm::NoCFIValue::get(F), - llvm::Type::getInt8PtrTy(VMContext)); + return llvm::ConstantExpr::getBitCast( + llvm::NoCFIValue::get(F), + llvm::Type::getInt8PtrTy(VMContext, F->getAddressSpace())); } static const FunctionDecl * diff --git a/clang/test/CodeGen/avr/builtin-function-start.c b/clang/test/CodeGen/avr/builtin-function-start.c new file mode 100644 index 0000000000000..293c8061299d7 --- /dev/null +++ b/clang/test/CodeGen/avr/builtin-function-start.c @@ -0,0 +1,13 @@ +// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --function-signature --check-globals +// RUN: %clang_cc1 -triple avr-- -emit-llvm -o - %s | FileCheck %s + +//. +// CHECK: @e = global ptr addrspacecast (ptr addrspace(1) no_cfi @a to ptr), align 1 +//. +// CHECK-LABEL: define {{[^@]+}}@a +// CHECK-SAME: () addrspace(1) #[[ATTR0:[0-9]+]] { +// CHECK-NEXT: entry: +// CHECK-NEXT: ret void +// +void a(void) {} +const void *e = __builtin_function_start(a); _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits