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 | |
| parent | ce5f2034151d053640a8ca3dd2be5ab5af0dd510 (diff) | |
| download | bcm5719-llvm-9a71e8064581ed8567c8bad52a27fd5ad410e6d8.tar.gz bcm5719-llvm-9a71e8064581ed8567c8bad52a27fd5ad410e6d8.zip | |
Fix asserts when linking wrong address space declarations
llvm-svn: 342858
Diffstat (limited to 'llvm/lib/Linker')
| -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 738dec8e1f2..48b746a22fc 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(); } |

