[clang] 57fd86d - [AVR] Fix function pointer address space
Dylan McKay via cfe-commits
cfe-commits at lists.llvm.org
Wed Apr 1 01:09:37 PDT 2020
Author: Vlastimil Labsky
Date: 2020-04-01T21:08:37+13:00
New Revision: 57fd86de879cf2b4c7001b6d0a09df60877ce24d
URL: https://github.com/llvm/llvm-project/commit/57fd86de879cf2b4c7001b6d0a09df60877ce24d
DIFF: https://github.com/llvm/llvm-project/commit/57fd86de879cf2b4c7001b6d0a09df60877ce24d.diff
LOG: [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
Added:
Modified:
clang/lib/CodeGen/CodeGenTypes.cpp
Removed:
################################################################################
diff --git a/clang/lib/CodeGen/CodeGenTypes.cpp b/clang/lib/CodeGen/CodeGenTypes.cpp
index befd80de96f0..29adc2c7adb3 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;
}
More information about the cfe-commits
mailing list