aykevl updated this revision to Diff 257687. aykevl marked an inline comment as done. aykevl added a comment.
- added comment explaining the test case Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D78125/new/ https://reviews.llvm.org/D78125 Files: clang/lib/CodeGen/CGExpr.cpp clang/test/CodeGen/address-space-avr.c Index: clang/test/CodeGen/address-space-avr.c =================================================================== --- /dev/null +++ clang/test/CodeGen/address-space-avr.c @@ -0,0 +1,12 @@ +// RUN: %clang_cc1 -triple avr -emit-llvm < %s | FileCheck %s + +// Test that function declarations in nonzero address spaces without prototype +// are called correctly. + +// CHECK: define void @bar() addrspace(1) +// CHECK: call addrspace(1) void bitcast (void (...) addrspace(1)* @foo to void (i16) addrspace(1)*)(i16 3) +// CHECK: declare void @foo(...) addrspace(1) +void foo(); +void bar(void) { + foo(3); +} Index: clang/lib/CodeGen/CGExpr.cpp =================================================================== --- clang/lib/CodeGen/CGExpr.cpp +++ clang/lib/CodeGen/CGExpr.cpp @@ -5048,7 +5048,8 @@ // to the function type. if (isa<FunctionNoProtoType>(FnType) || Chain) { llvm::Type *CalleeTy = getTypes().GetFunctionType(FnInfo); - CalleeTy = CalleeTy->getPointerTo(); + int AS = Callee.getFunctionPointer()->getType()->getPointerAddressSpace(); + CalleeTy = CalleeTy->getPointerTo(AS); llvm::Value *CalleePtr = Callee.getFunctionPointer(); CalleePtr = Builder.CreateBitCast(CalleePtr, CalleeTy, "callee.knr.cast");
Index: clang/test/CodeGen/address-space-avr.c =================================================================== --- /dev/null +++ clang/test/CodeGen/address-space-avr.c @@ -0,0 +1,12 @@ +// RUN: %clang_cc1 -triple avr -emit-llvm < %s | FileCheck %s + +// Test that function declarations in nonzero address spaces without prototype +// are called correctly. + +// CHECK: define void @bar() addrspace(1) +// CHECK: call addrspace(1) void bitcast (void (...) addrspace(1)* @foo to void (i16) addrspace(1)*)(i16 3) +// CHECK: declare void @foo(...) addrspace(1) +void foo(); +void bar(void) { + foo(3); +} Index: clang/lib/CodeGen/CGExpr.cpp =================================================================== --- clang/lib/CodeGen/CGExpr.cpp +++ clang/lib/CodeGen/CGExpr.cpp @@ -5048,7 +5048,8 @@ // to the function type. if (isa<FunctionNoProtoType>(FnType) || Chain) { llvm::Type *CalleeTy = getTypes().GetFunctionType(FnInfo); - CalleeTy = CalleeTy->getPointerTo(); + int AS = Callee.getFunctionPointer()->getType()->getPointerAddressSpace(); + CalleeTy = CalleeTy->getPointerTo(AS); llvm::Value *CalleePtr = Callee.getFunctionPointer(); CalleePtr = Builder.CreateBitCast(CalleePtr, CalleeTy, "callee.knr.cast");
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits