Skip to content

Commit 57fd86d

Browse files
vlasta-labskydylanmckay
authored andcommitted
[AVR] Fix function pointer address space
Summary: Function pointers should be created with program address space. This fixes function pointers on AVR. Reviewers: dylanmckay Reviewed By: dylanmckay Subscribers: Jim, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D77119
1 parent fa1b602 commit 57fd86d

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

clang/lib/CodeGen/CodeGenTypes.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -595,7 +595,11 @@ llvm::Type *CodeGenTypes::ConvertType(QualType T) {
595595
llvm::Type *PointeeType = ConvertTypeForMem(ETy);
596596
if (PointeeType->isVoidTy())
597597
PointeeType = llvm::Type::getInt8Ty(getLLVMContext());
598-
unsigned AS = Context.getTargetAddressSpace(ETy);
598+
599+
unsigned AS = PointeeType->isFunctionTy()
600+
? getDataLayout().getProgramAddressSpace()
601+
: Context.getTargetAddressSpace(ETy);
602+
599603
ResultType = llvm::PointerType::get(PointeeType, AS);
600604
break;
601605
}

0 commit comments

Comments
 (0)