Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
InferAddressSpaces: Avoid assertion failure with replacing identical
cloned constexpr Have cloneConstantExprWithNewAddressSpaces return nullptr when returning initial ConstantExpr. Reviewers: arsenm Subscribers: jholewinski, wdng, llvm-commits Differential Revision: https://reviews.llvm.org/D33995 llvm-svn: 304975
- Loading branch information
1 parent
a6d48f5
commit 62fb849
Showing
2 changed files
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
llvm/test/Transforms/InferAddressSpaces/NVPTX/clone_constexpr.ll
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
; RUN: opt -S -mtriple=nvptx64-nvidia-cuda -infer-address-spaces %s | FileCheck %s | ||
|
||
%struct.S = type { [5 x i32] } | ||
|
||
$g1 = comdat any | ||
|
||
@g1 = linkonce_odr addrspace(3) global %struct.S zeroinitializer, comdat, align 4 | ||
|
||
; CHECK-LABEL: @foo( | ||
; CHECK: %x0 = tail call i32 @llvm.nvvm.read.ptx.sreg.tid.x() #2 | ||
; CHECK: %idxprom.i = zext i32 %x0 to i64 | ||
; CHECK: %arrayidx.i = getelementptr %struct.S, %struct.S* addrspacecast (%struct.S addrspace(3)* @g1 to %struct.S*), i64 0, i32 0, i64 %idxprom.i | ||
; CHECK: tail call void @f1(i32* %arrayidx.i, i32 undef) #0 | ||
; CHECK: %x1 = load i32, i32* getelementptr (%struct.S, %struct.S* addrspacecast (%struct.S addrspace(3)* @g1 to %struct.S*), i64 0, i32 0, i64 0), align 4 | ||
; CHECK: %L.sroa.0.0.insert.ext.i = zext i32 %x1 to i64 | ||
; CHECK: tail call void @f2(i64* null, i64 %L.sroa.0.0.insert.ext.i) #0 | ||
; CHECK: ret void | ||
define void @foo() local_unnamed_addr #0 { | ||
entry: | ||
%x0 = tail call i32 @llvm.nvvm.read.ptx.sreg.tid.x() #2 | ||
%idxprom.i = zext i32 %x0 to i64 | ||
%arrayidx.i = getelementptr %struct.S, %struct.S* addrspacecast (%struct.S addrspace(3)* @g1 to %struct.S*), i64 0, i32 0, i64 %idxprom.i | ||
tail call void @f1(i32* %arrayidx.i, i32 undef) #0 | ||
%x1 = load i32, i32* getelementptr (%struct.S, %struct.S* addrspacecast (%struct.S addrspace(3)* @g1 to %struct.S*), i64 0, i32 0, i64 0), align 4 | ||
%L.sroa.0.0.insert.ext.i = zext i32 %x1 to i64 | ||
tail call void @f2(i64* null, i64 %L.sroa.0.0.insert.ext.i) #0 | ||
ret void | ||
} | ||
|
||
declare void @f1(i32*, i32) local_unnamed_addr #0 | ||
declare void @f2(i64*, i64) local_unnamed_addr #0 | ||
declare i32 @llvm.nvvm.read.ptx.sreg.tid.x() #1 | ||
|
||
attributes #0 = { convergent nounwind } | ||
attributes #1 = { nounwind readnone } | ||
attributes #2 = { nounwind } |