]> granicus.if.org Git - llvm/commit
Fix InstCombine address space assert
authorEwan Crawford <ewan@codeplay.com>
Tue, 31 Jul 2018 15:53:03 +0000 (15:53 +0000)
committerEwan Crawford <ewan@codeplay.com>
Tue, 31 Jul 2018 15:53:03 +0000 (15:53 +0000)
commitd9904414c214ef94c480ce1cd76ebde0558403a0
treeef3b77c0a4bf2908d7d2758120c0cd4260547897
parentc49e38382fc2fb39c7e9bfec4c3f37f1cba92bdf
Fix InstCombine address space assert

Workaround bug where the InstCombine pass was asserting on the IR added in lit
test, where we have a bitcast instruction after a GEP from an addrspace cast.

The second bitcast in the test was getting combined into
`bitcast <16 x i32>* %0 to <16 x i32> addrspace(3)*`, which looks like it should
be an addrspace cast instruction instead. Otherwise if control flow is allowed
to continue as it is now we create a GEP instruction
`<badref> = getelementptr inbounds <16 x i32>, <16 x i32>* %0, i32 0`. However
because the type of this instruction doesn't match the address space we hit an
assert when replacing the bitcast with that GEP.

```
void llvm::Value::doRAUW(llvm::Value*, bool): Assertion `New->getType() == getType() && "replaceAllUses of value with new value of different type!"' failed.
```

Differential Revision: https://reviews.llvm.org/D50058

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@338395 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Transforms/InstCombine/InstCombineCasts.cpp
test/Transforms/InstCombine/gep-addrspace.ll