diff options
| author | Ayke van Laethem <aykevanlaethem@gmail.com> | 2022-11-24 20:24:36 +0100 |
|---|---|---|
| committer | Ayke van Laethem <aykevanlaethem@gmail.com> | 2022-11-27 15:27:42 +0100 |
| commit | 131cddcba2c4c953a8a49d7adbf656cab9e9f1c7 (patch) | |
| tree | 2447708383f3e5d612d67086672ffde4499fe26b /clang/lib/CodeGen/CodeGenModule.cpp | |
| parent | 6a353c7756f2def4bbc48b4c76c8f173f05a6fa0 (diff) | |
[AVR] Fix broken bitcast for aliases in non-zero address space
This was triggered by some code in picolibc. The minimal version looks
like this:
double infinity(void) {
return 5;
}
extern long double infinityl() __attribute__((__alias__("infinity")));
These two declarations have a different type (not because of the 'long
double', which is also 'double' in IR, but because infinityl has
variadic parameters). This led to a crash in the bitcast which assumed
address space 0.
Differential Revision: https://reviews.llvm.org/D138681
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
| -rw-r--r-- | clang/lib/CodeGen/CodeGenModule.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index ae25767bc753..133c603622f8 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -4002,7 +4002,8 @@ llvm::Constant *CodeGenModule::GetOrCreateLLVMFunction( // (If function is requested for a definition, we always need to create a new // function, not just return a bitcast.) if (!IsForDefinition) - return llvm::ConstantExpr::getBitCast(Entry, Ty->getPointerTo()); + return llvm::ConstantExpr::getBitCast( + Entry, Ty->getPointerTo(Entry->getAddressSpace())); } // This function doesn't have a complete type (for example, the return |
