Skip to content
This repository was archived by the owner on Mar 28, 2020. It is now read-only.

Commit 50cc811

Browse files
committed
Revert r267210, it makes clang assert (PR27490).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@267232 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 1e455c5 commit 50cc811

File tree

2 files changed

+6
-50
lines changed

2 files changed

+6
-50
lines changed

lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -327,8 +327,6 @@ static LoadInst *combineLoadToNewType(InstCombiner &IC, LoadInst &LI, Type *NewT
327327
LoadInst *NewLoad = IC.Builder->CreateAlignedLoad(
328328
IC.Builder->CreateBitCast(Ptr, NewTy->getPointerTo(AS)),
329329
LI.getAlignment(), LI.getName() + Suffix);
330-
NewLoad->setAtomic(LI.getOrdering(), LI.getSynchScope());
331-
assert(!LI.isVolatile() && "volatile unhandled here");
332330
MDBuilder MDB(NewLoad->getContext());
333331
for (const auto &MDPair : MD) {
334332
unsigned ID = MDPair.first;
@@ -401,8 +399,6 @@ static StoreInst *combineStoreToNewValue(InstCombiner &IC, StoreInst &SI, Value
401399
StoreInst *NewStore = IC.Builder->CreateAlignedStore(
402400
V, IC.Builder->CreateBitCast(Ptr, V->getType()->getPointerTo(AS)),
403401
SI.getAlignment());
404-
NewStore->setAtomic(SI.getOrdering(), SI.getSynchScope());
405-
assert(!SI.isVolatile() && "volatile unhandled here");
406402
for (const auto &MDPair : MD) {
407403
unsigned ID = MDPair.first;
408404
MDNode *N = MDPair.second;
@@ -460,9 +456,9 @@ static StoreInst *combineStoreToNewValue(InstCombiner &IC, StoreInst &SI, Value
460456
/// later. However, it is risky in case some backend or other part of LLVM is
461457
/// relying on the exact type loaded to select appropriate atomic operations.
462458
static Instruction *combineLoadToOperationType(InstCombiner &IC, LoadInst &LI) {
463-
// FIXME: We could probably with some care handle both volatile and ordered
464-
// atomic loads here but it isn't clear that this is important.
465-
if (!LI.isUnordered())
459+
// FIXME: We could probably with some care handle both volatile and atomic
460+
// loads here but it isn't clear that this is important.
461+
if (!LI.isSimple())
466462
return nullptr;
467463

468464
if (LI.use_empty())
@@ -896,7 +892,6 @@ Instruction *InstCombiner::visitLoadInst(LoadInst &LI) {
896892
V1->setAtomic(LI.getOrdering(), LI.getSynchScope());
897893
V2->setAlignment(Align);
898894
V2->setAtomic(LI.getOrdering(), LI.getSynchScope());
899-
assert(!LI.isVolatile() && "volatile unhandled here");
900895
return SelectInst::Create(SI->getCondition(), V1, V2);
901896
}
902897

@@ -939,9 +934,9 @@ Instruction *InstCombiner::visitLoadInst(LoadInst &LI) {
939934
/// the store instruction as otherwise there is no way to signal whether it was
940935
/// combined or not: IC.EraseInstFromFunction returns a null pointer.
941936
static bool combineStoreToValueType(InstCombiner &IC, StoreInst &SI) {
942-
// FIXME: We could probably with some care handle both volatile and ordered
943-
// atomic stores here but it isn't clear that this is important.
944-
if (!SI.isUnordered())
937+
// FIXME: We could probably with some care handle both volatile and atomic
938+
// stores here but it isn't clear that this is important.
939+
if (!SI.isSimple())
945940
return false;
946941

947942
Value *V = SI.getValueOperand();

test/Transforms/InstCombine/atomic.ll

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -173,45 +173,6 @@ define i32 @test17(i1 %cnd) {
173173
ret i32 %x
174174
}
175175

176-
declare void @clobber()
177-
178-
define i32 @test18(float* %p) {
179-
; CHECK-LABEL: define i32 @test18(
180-
; CHECK: load atomic i32, i32* [[A:%.*]] unordered, align 4
181-
; CHECK: store atomic i32 [[B:%.*]], i32* [[C:%.*]] unordered, align 4
182-
%x = load atomic float, float* %p unordered, align 4
183-
call void @clobber() ;; keep the load around
184-
store atomic float %x, float* %p unordered, align 4
185-
ret i32 0
186-
}
187-
188-
; TODO: probably also legal in this case
189-
define i32 @test19(float* %p) {
190-
; CHECK-LABEL: define i32 @test19(
191-
; CHECK: load atomic float, float* %p seq_cst, align 4
192-
; CHECK: store atomic float %x, float* %p seq_cst, align 4
193-
%x = load atomic float, float* %p seq_cst, align 4
194-
call void @clobber() ;; keep the load around
195-
store atomic float %x, float* %p seq_cst, align 4
196-
ret i32 0
197-
}
198-
199-
define i32 @test20(i32** %p, i8* %v) {
200-
; CHECK-LABEL: define i32 @test20(
201-
; CHECK: store atomic i8* %v, i8** [[D:%.*]] unordered, align 4
202-
%cast = bitcast i8* %v to i32*
203-
store atomic i32* %cast, i32** %p unordered, align 4
204-
ret i32 0
205-
}
206-
; TODO: probably also legal in this case
207-
define i32 @test21(i32** %p, i8* %v) {
208-
; CHECK-LABEL: define i32 @test21(
209-
; CHECK: store atomic i32* %cast, i32** %p monotonic, align 4
210-
%cast = bitcast i8* %v to i32*
211-
store atomic i32* %cast, i32** %p monotonic, align 4
212-
ret i32 0
213-
}
214-
215176
define i32 @test22(i1 %cnd) {
216177
; CHECK-LABEL: define i32 @test22(
217178
; CHECK: [[PHI:%.*]] = phi i32

0 commit comments

Comments
 (0)