mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-28 22:36:05 +00:00
GlobalIFunc: Make ifunc respect function address spaces
This commit is contained in:
parent
6463961941
commit
0d527e56a5
@ -2873,8 +2873,8 @@ Error BitcodeReader::resolveGlobalAndIndirectSymbolInits() {
|
|||||||
Type *ResolverFTy =
|
Type *ResolverFTy =
|
||||||
GlobalIFunc::getResolverFunctionType(GI->getValueType());
|
GlobalIFunc::getResolverFunctionType(GI->getValueType());
|
||||||
// Transparently fix up the type for compatibility with older bitcode
|
// Transparently fix up the type for compatibility with older bitcode
|
||||||
GI->setResolver(
|
GI->setResolver(ConstantExpr::getBitCast(
|
||||||
ConstantExpr::getBitCast(C, ResolverFTy->getPointerTo()));
|
C, ResolverFTy->getPointerTo(GI->getAddressSpace())));
|
||||||
} else {
|
} else {
|
||||||
return error("Expected an alias or an ifunc");
|
return error("Expected an alias or an ifunc");
|
||||||
}
|
}
|
||||||
|
@ -889,7 +889,7 @@ void Verifier::visitGlobalIFunc(const GlobalIFunc &GI) {
|
|||||||
const Type *ResolverTy = GI.getResolver()->getType();
|
const Type *ResolverTy = GI.getResolver()->getType();
|
||||||
const Type *ResolverFuncTy =
|
const Type *ResolverFuncTy =
|
||||||
GlobalIFunc::getResolverFunctionType(GI.getValueType());
|
GlobalIFunc::getResolverFunctionType(GI.getValueType());
|
||||||
Check(ResolverTy == ResolverFuncTy->getPointerTo(),
|
Check(ResolverTy == ResolverFuncTy->getPointerTo(GI.getAddressSpace()),
|
||||||
"IFunc resolver has incorrect type", &GI);
|
"IFunc resolver has incorrect type", &GI);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
33
llvm/test/Assembler/ifunc-program-addrspace.ll
Normal file
33
llvm/test/Assembler/ifunc-program-addrspace.ll
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
; RUN: llvm-as < %s | llvm-dis | FileCheck %s
|
||||||
|
|
||||||
|
target datalayout = "P1"
|
||||||
|
|
||||||
|
; CHECK: @ifunc_as0 = ifunc void (), ptr @resolver_as0
|
||||||
|
@ifunc_as0 = ifunc void (), ptr @resolver_as0
|
||||||
|
|
||||||
|
; CHECK: @ifunc_as1 = ifunc void (), ptr addrspace(1) @resolver_as1
|
||||||
|
@ifunc_as1 = ifunc void (), ptr addrspace(1) @resolver_as1
|
||||||
|
|
||||||
|
; CHECK: define ptr @resolver_as0() addrspace(0) {
|
||||||
|
define ptr @resolver_as0() addrspace(0) {
|
||||||
|
ret ptr null
|
||||||
|
}
|
||||||
|
|
||||||
|
; CHECK: define ptr @resolver_as1() addrspace(1) {
|
||||||
|
define ptr @resolver_as1() addrspace(1) {
|
||||||
|
ret ptr null
|
||||||
|
}
|
||||||
|
|
||||||
|
; CHECK: define void @call_ifunc_as0() addrspace(1) {
|
||||||
|
; CHECK-NEXT: call addrspace(0) void @ifunc_as0()
|
||||||
|
define void @call_ifunc_as0() addrspace(1) {
|
||||||
|
call addrspace(0) void @ifunc_as0()
|
||||||
|
ret void
|
||||||
|
}
|
||||||
|
|
||||||
|
; CHECK: define void @call_ifunc_as1() addrspace(1) {
|
||||||
|
; CHECK-NEXT: call addrspace(1) void @ifunc_as1()
|
||||||
|
define void @call_ifunc_as1() addrspace(1) {
|
||||||
|
call addrspace(1) void @ifunc_as1()
|
||||||
|
ret void
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user