We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent e3c28a5 commit cdaeac9Copy full SHA for cdaeac9
src/llvm-remove-addrspaces.cpp
@@ -208,7 +208,14 @@ bool RemoveNoopAddrSpaceCasts(Function *F)
208
LLVM_DEBUG(
209
dbgs() << "Removing noop address space cast:\n"
210
<< I << "\n");
211
- ASC->replaceAllUsesWith(ASC->getOperand(0));
+ if (ASC->getType() == ASC->getOperand(0)->getType()) {
212
+ ASC->replaceAllUsesWith(ASC->getOperand(0));
213
+ } else {
214
+ // uncanonicalized addrspacecast; demote to bitcast
215
+ llvm::IRBuilder<> builder(ASC);
216
+ auto BC = builder.CreateBitCast(ASC->getOperand(0), ASC->getType());
217
+ ASC->replaceAllUsesWith(BC);
218
+ }
219
NoopCasts.push_back(ASC);
220
}
221
0 commit comments