mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-10-18 18:42:46 +02:00
Reapply [InstCombine] Don't try converting opaque pointer bitcast to GEP
Reapplied without changes -- this was reverted together with an underlying patch. ----- Bitcasts having opaque pointer source or result type cannot be converted into a zero-index GEP, GEP source and result types always have the same opaque-ness.
This commit is contained in:
parent
3520bd21c8
commit
628c200526
@ -2608,6 +2608,11 @@ static Instruction *convertBitCastToGEP(BitCastInst &CI, IRBuilderBase &Builder,
|
||||
Value *Src = CI.getOperand(0);
|
||||
PointerType *SrcPTy = cast<PointerType>(Src->getType());
|
||||
PointerType *DstPTy = cast<PointerType>(CI.getType());
|
||||
|
||||
// Bitcasts involving opaque pointers cannot be converted into a GEP.
|
||||
if (SrcPTy->isOpaque() || DstPTy->isOpaque())
|
||||
return nullptr;
|
||||
|
||||
Type *DstElTy = DstPTy->getElementType();
|
||||
Type *SrcElTy = SrcPTy->getElementType();
|
||||
|
||||
|
43
test/Transforms/InstCombine/opaque-ptr.ll
Normal file
43
test/Transforms/InstCombine/opaque-ptr.ll
Normal file
@ -0,0 +1,43 @@
|
||||
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
|
||||
; RUN: opt -S -instcombine < %s | FileCheck %s
|
||||
|
||||
define ptr @bitcast_opaque_to_opaque(ptr %a) {
|
||||
; CHECK-LABEL: @bitcast_opaque_to_opaque(
|
||||
; CHECK-NEXT: ret ptr [[A:%.*]]
|
||||
;
|
||||
%b = bitcast ptr %a to ptr
|
||||
ret ptr %b
|
||||
}
|
||||
|
||||
define ptr @bitcast_typed_to_opaque(i8* %a) {
|
||||
; CHECK-LABEL: @bitcast_typed_to_opaque(
|
||||
; CHECK-NEXT: [[B:%.*]] = bitcast i8* [[A:%.*]] to ptr
|
||||
; CHECK-NEXT: ret ptr [[B]]
|
||||
;
|
||||
%b = bitcast i8* %a to ptr
|
||||
ret ptr %b
|
||||
}
|
||||
|
||||
define i8* @bitcast_opaque_to_typed(ptr %a) {
|
||||
; CHECK-LABEL: @bitcast_opaque_to_typed(
|
||||
; CHECK-NEXT: [[B:%.*]] = bitcast ptr [[A:%.*]] to i8*
|
||||
; CHECK-NEXT: ret i8* [[B]]
|
||||
;
|
||||
%b = bitcast ptr %a to i8*
|
||||
ret i8* %b
|
||||
}
|
||||
|
||||
;define ptr @addrspacecast_opaque_to_opaque(ptr addrspace(1) %a) {
|
||||
; %b = addrspacecast ptr addrspace(1) %a to ptr
|
||||
; ret ptr %b
|
||||
;}
|
||||
|
||||
;define ptr @addrspacecast_typed_to_opaque(i8 addrspace(1)* %a) {
|
||||
; %b = addrspacecast i8 addrspace(1)* %a to ptr
|
||||
; ret ptr %b
|
||||
;}
|
||||
|
||||
;define i8* @addrspacecast_opaque_to_typed(ptr addrspace(1) %a) {
|
||||
; %b = addrspacecast ptr addrspace(1) %a to i8*
|
||||
; ret i8* %b
|
||||
;}
|
Loading…
Reference in New Issue
Block a user