From: Vlastimil Labsky Date: Wed, 1 Apr 2020 08:05:45 +0000 (+1300) Subject: [AVR] Fix function pointer address space X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=57fd86de879cf2b4c7001b6d0a09df60877ce24d;p=platform%2Fupstream%2Fllvm.git [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 --- diff --git a/clang/lib/CodeGen/CodeGenTypes.cpp b/clang/lib/CodeGen/CodeGenTypes.cpp index befd80d..29adc2c 100644 --- a/clang/lib/CodeGen/CodeGenTypes.cpp +++ b/clang/lib/CodeGen/CodeGenTypes.cpp @@ -595,7 +595,11 @@ llvm::Type *CodeGenTypes::ConvertType(QualType T) { llvm::Type *PointeeType = ConvertTypeForMem(ETy); if (PointeeType->isVoidTy()) PointeeType = llvm::Type::getInt8Ty(getLLVMContext()); - unsigned AS = Context.getTargetAddressSpace(ETy); + + unsigned AS = PointeeType->isFunctionTy() + ? getDataLayout().getProgramAddressSpace() + : Context.getTargetAddressSpace(ETy); + ResultType = llvm::PointerType::get(PointeeType, AS); break; }