diff options
author | Matt Arsenault <Matthew.Arsenault@amd.com> | 2018-09-24 04:42:14 +0000 |
---|---|---|
committer | Matt Arsenault <Matthew.Arsenault@amd.com> | 2018-09-24 04:42:14 +0000 |
commit | 9a71e8064581ed8567c8bad52a27fd5ad410e6d8 (patch) | |
tree | 71725c038202ba18d1cad46820d47175c771b2fa /llvm/lib/Linker/IRMover.cpp | |
parent | llvm-diff: Fix crash on anonymous functions (diff) | |
download | llvm-project-9a71e8064581ed8567c8bad52a27fd5ad410e6d8.tar.gz llvm-project-9a71e8064581ed8567c8bad52a27fd5ad410e6d8.tar.bz2 llvm-project-9a71e8064581ed8567c8bad52a27fd5ad410e6d8.zip |
Fix asserts when linking wrong address space declarations
llvm-svn: 342858
Diffstat (limited to 'llvm/lib/Linker/IRMover.cpp')
-rw-r--r-- | llvm/lib/Linker/IRMover.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/llvm/lib/Linker/IRMover.cpp b/llvm/lib/Linker/IRMover.cpp index 738dec8e1f29..48b746a22fcf 100644 --- a/llvm/lib/Linker/IRMover.cpp +++ b/llvm/lib/Linker/IRMover.cpp @@ -978,11 +978,14 @@ Expected<Constant *> IRLinker::linkGlobalValueProto(GlobalValue *SGV, // containing a GV from the source module, in which case SGV will be // the same as DGV and NewGV, and TypeMap.get() will assert since it // assumes it is being invoked on a type in the source module. - if (DGV && NewGV != SGV) - C = ConstantExpr::getBitCast(NewGV, TypeMap.get(SGV->getType())); + if (DGV && NewGV != SGV) { + C = ConstantExpr::getPointerBitCastOrAddrSpaceCast( + NewGV, TypeMap.get(SGV->getType())); + } if (DGV && NewGV != DGV) { - DGV->replaceAllUsesWith(ConstantExpr::getBitCast(NewGV, DGV->getType())); + DGV->replaceAllUsesWith( + ConstantExpr::getPointerBitCastOrAddrSpaceCast(NewGV, DGV->getType())); DGV->eraseFromParent(); } |