From 090c0a2ffd0e3374ca55e964773c44ae2a3c80e7 Mon Sep 17 00:00:00 2001 From: John Criswell Date: Tue, 10 Mar 2009 15:04:53 +0000 Subject: [PATCH] Do not attempt to do parial redundancy elimination on void values. Also fixed a punctuation error in the header comment. This fixes PR3775. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@66542 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/Scalar/GVN.cpp | 7 +- test/Transforms/GVN/2009-03-10-PREOnVoid.ll | 82 +++++++++++++++++++++ 2 files changed, 86 insertions(+), 3 deletions(-) create mode 100644 test/Transforms/GVN/2009-03-10-PREOnVoid.ll diff --git a/lib/Transforms/Scalar/GVN.cpp b/lib/Transforms/Scalar/GVN.cpp index 6593b9c6223..e537986f306 100644 --- a/lib/Transforms/Scalar/GVN.cpp +++ b/lib/Transforms/Scalar/GVN.cpp @@ -10,7 +10,7 @@ // This pass performs global value numbering to eliminate fully redundant // instructions. It also performs simple dead load elimination. // -// Note that this pass does the value numbering itself, it does not use the +// Note that this pass does the value numbering itself; it does not use the // ValueNumbering analysis passes. // //===----------------------------------------------------------------------===// @@ -1469,8 +1469,9 @@ bool GVN::performPRE(Function& F) { Instruction *CurInst = BI++; if (isa(CurInst) || isa(CurInst) || - isa(CurInst) || CurInst->mayReadFromMemory() || - CurInst->mayWriteToMemory() || isa(CurInst)) + isa(CurInst) || (CurInst->getType() == Type::VoidTy) || + CurInst->mayReadFromMemory() || CurInst->mayWriteToMemory() || + isa(CurInst)) continue; uint32_t valno = VN.lookup(CurInst); diff --git a/test/Transforms/GVN/2009-03-10-PREOnVoid.ll b/test/Transforms/GVN/2009-03-10-PREOnVoid.ll new file mode 100644 index 00000000000..63ddc450869 --- /dev/null +++ b/test/Transforms/GVN/2009-03-10-PREOnVoid.ll @@ -0,0 +1,82 @@ +; RUN: llvm-as < %s | opt -gvn -disable-output +; PR3775 + +; ModuleID = 'bugpoint-reduced-simplified.bc' +target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32" +target triple = "i386-pc-linux-gnu" + %llvm.dbg.anchor.type = type { i32, i32 } + %"struct.__gnu_cxx::hash" = type <{ i8 }> + %struct.__sched_param = type { i32 } + %struct._pthread_descr_struct = type opaque + %struct.pthread_attr_t = type { i32, i32, %struct.__sched_param, i32, i32, i32, i32, i8*, i32 } + %struct.pthread_mutex_t = type { i32, i32, %struct._pthread_descr_struct*, i32, %llvm.dbg.anchor.type } + %"struct.std::_Rb_tree > >,std::_Select1st > > >,std::less,std::allocator > > > >" = type { %"struct.std::_Rb_tree > >,std::_Select1st > > >,std::less,std::allocator > > > >::_Rb_tree_impl,false>" } + %"struct.std::_Rb_tree > >,std::_Select1st > > >,std::less,std::allocator > > > >::_Rb_tree_impl,false>" = type { %"struct.__gnu_cxx::hash", %"struct.std::_Rb_tree_node_base", i32 } + %"struct.std::_Rb_tree_iterator > > >" = type { %"struct.std::_Rb_tree_node_base"* } + %"struct.std::_Rb_tree_node_base" = type { i32, %"struct.std::_Rb_tree_node_base"*, %"struct.std::_Rb_tree_node_base"*, %"struct.std::_Rb_tree_node_base"* } + %"struct.std::pair > > >,bool>" = type { %"struct.std::_Rb_tree_iterator > > >", i8 } + %"struct.std::pair" = type { i8*, i8* } + +@_ZL20__gthrw_pthread_oncePiPFvvE = alias weak i32 (i32*, void ()*)* @pthread_once ; [#uses=0] +@_ZL27__gthrw_pthread_getspecificj = alias weak i8* (i32)* @pthread_getspecific ; [#uses=0] +@_ZL27__gthrw_pthread_setspecificjPKv = alias weak i32 (i32, i8*)* @pthread_setspecific ; [#uses=0] +@_ZL22__gthrw_pthread_createPmPK16__pthread_attr_sPFPvS3_ES3_ = alias weak i32 (i32*, %struct.pthread_attr_t*, i8* (i8*)*, i8*)* @pthread_create ; [#uses=0] +@_ZL22__gthrw_pthread_cancelm = alias weak i32 (i32)* @pthread_cancel ; [#uses=0] +@_ZL26__gthrw_pthread_mutex_lockP15pthread_mutex_t = alias weak i32 (%struct.pthread_mutex_t*)* @pthread_mutex_lock ; [#uses=0] +@_ZL29__gthrw_pthread_mutex_trylockP15pthread_mutex_t = alias weak i32 (%struct.pthread_mutex_t*)* @pthread_mutex_trylock ; [#uses=0] +@_ZL28__gthrw_pthread_mutex_unlockP15pthread_mutex_t = alias weak i32 (%struct.pthread_mutex_t*)* @pthread_mutex_unlock ; [#uses=0] +@_ZL26__gthrw_pthread_mutex_initP15pthread_mutex_tPK19pthread_mutexattr_t = alias weak i32 (%struct.pthread_mutex_t*, %struct.__sched_param*)* @pthread_mutex_init ; [#uses=0] +@_ZL26__gthrw_pthread_key_createPjPFvPvE = alias weak i32 (i32*, void (i8*)*)* @pthread_key_create ; [#uses=0] +@_ZL26__gthrw_pthread_key_deletej = alias weak i32 (i32)* @pthread_key_delete ; [#uses=0] +@_ZL30__gthrw_pthread_mutexattr_initP19pthread_mutexattr_t = alias weak i32 (%struct.__sched_param*)* @pthread_mutexattr_init ; [#uses=0] +@_ZL33__gthrw_pthread_mutexattr_settypeP19pthread_mutexattr_ti = alias weak i32 (%struct.__sched_param*, i32)* @pthread_mutexattr_settype ; [#uses=0] +@_ZL33__gthrw_pthread_mutexattr_destroyP19pthread_mutexattr_t = alias weak i32 (%struct.__sched_param*)* @pthread_mutexattr_destroy ; [#uses=0] + +declare fastcc void @_ZNSt10_Select1stISt4pairIKPvS1_EEC1Ev() nounwind readnone + +define fastcc void @_ZNSt8_Rb_treeIPvSt4pairIKS0_S0_ESt10_Select1stIS3_ESt4lessIS0_ESaIS3_EE16_M_insert_uniqueERKS3_(%"struct.std::pair > > >,bool>"* noalias nocapture sret %agg.result, %"struct.std::_Rb_tree > >,std::_Select1st > > >,std::less,std::allocator > > > >"* %this, %"struct.std::pair"* %__v) nounwind { +entry: + br i1 false, label %bb7, label %bb + +bb: ; preds = %bb, %entry + br i1 false, label %bb5, label %bb + +bb5: ; preds = %bb + call fastcc void @_ZNSt10_Select1stISt4pairIKPvS1_EEC1Ev() nounwind + br i1 false, label %bb11, label %bb7 + +bb7: ; preds = %bb5, %entry + br label %bb11 + +bb11: ; preds = %bb7, %bb5 + call fastcc void @_ZNSt10_Select1stISt4pairIKPvS1_EEC1Ev() nounwind + unreachable +} + +declare i32 @pthread_once(i32*, void ()*) + +declare i8* @pthread_getspecific(i32) + +declare i32 @pthread_setspecific(i32, i8*) + +declare i32 @pthread_create(i32*, %struct.pthread_attr_t*, i8* (i8*)*, i8*) + +declare i32 @pthread_cancel(i32) + +declare i32 @pthread_mutex_lock(%struct.pthread_mutex_t*) + +declare i32 @pthread_mutex_trylock(%struct.pthread_mutex_t*) + +declare i32 @pthread_mutex_unlock(%struct.pthread_mutex_t*) + +declare i32 @pthread_mutex_init(%struct.pthread_mutex_t*, %struct.__sched_param*) + +declare i32 @pthread_key_create(i32*, void (i8*)*) + +declare i32 @pthread_key_delete(i32) + +declare i32 @pthread_mutexattr_init(%struct.__sched_param*) + +declare i32 @pthread_mutexattr_settype(%struct.__sched_param*, i32) + +declare i32 @pthread_mutexattr_destroy(%struct.__sched_param*)