Skip to content

Commit cf46e94

Browse files
[WASM] Replace relative ptr use for async func ptr with absolute ptr
1 parent 1f69c6f commit cf46e94

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

lib/IRGen/IRGenFunction.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,14 @@ IRGenFunction::emitLoadOfRelativePointer(Address addr, bool isFar,
318318
if (!isFar) {
319319
value = Builder.CreateSExt(value, IGM.IntPtrTy);
320320
}
321+
322+
// FIXME: add absolute pointer mode for IRGen
323+
if (IGM.TargetInfo.OutputObjectFormat == llvm::Triple::Wasm) {
324+
auto *uncastPointer = Builder.CreateIntToPtr(value, IGM.Int8PtrTy);
325+
auto uncastPointerAddress = Address(uncastPointer, IGM.getPointerAlignment());
326+
auto pointer = Builder.CreateBitCast(uncastPointerAddress, expectedType);
327+
return pointer.getAddress();
328+
}
321329
auto *addrInt = Builder.CreatePtrToInt(addr.getAddress(), IGM.IntPtrTy);
322330
auto *uncastPointerInt = Builder.CreateAdd(addrInt, value);
323331
auto *uncastPointer = Builder.CreateIntToPtr(uncastPointerInt, IGM.Int8PtrTy);

0 commit comments

Comments
 (0)