From craig.topper at gmail.com Mon Feb 13 01:23:42 2012 From: craig.topper at gmail.com (Craig Topper) Date: Mon, 13 Feb 2012 07:23:42 -0000 Subject: [llvm-commits] [llvm] r150365 - in /llvm/trunk/lib/Target/X86: X86InstrFragmentsSIMD.td X86InstrSSE.td Message-ID: <20120213072342.269722A6C12D@llvm.org> Author: ctopper Date: Mon Feb 13 01:23:41 2012 New Revision: 150365 URL: http://llvm.org/viewvc/llvm-project?rev=150365&view=rev Log: Still more vector_shuffle pattern removal. Modified: llvm/trunk/lib/Target/X86/X86InstrFragmentsSIMD.td llvm/trunk/lib/Target/X86/X86InstrSSE.td Modified: llvm/trunk/lib/Target/X86/X86InstrFragmentsSIMD.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrFragmentsSIMD.td?rev=150365&r1=150364&r2=150365&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86InstrFragmentsSIMD.td (original) +++ llvm/trunk/lib/Target/X86/X86InstrFragmentsSIMD.td Mon Feb 13 01:23:41 2012 @@ -385,16 +385,6 @@ return X86::isMOVLMask(cast(N)); }]>; -def unpckl : PatFrag<(ops node:$lhs, node:$rhs), - (vector_shuffle node:$lhs, node:$rhs), [{ - return X86::isUNPCKLMask(cast(N), Subtarget->hasAVX2()); -}]>; - -def unpckh : PatFrag<(ops node:$lhs, node:$rhs), - (vector_shuffle node:$lhs, node:$rhs), [{ - return X86::isUNPCKHMask(cast(N), Subtarget->hasAVX2()); -}]>; - def vextractf128_extract : PatFrag<(ops node:$bigvec, node:$index), (extract_subvector node:$bigvec, node:$index), [{ Modified: llvm/trunk/lib/Target/X86/X86InstrSSE.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrSSE.td?rev=150365&r1=150364&r2=150365&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86InstrSSE.td (original) +++ llvm/trunk/lib/Target/X86/X86InstrSSE.td Mon Feb 13 01:23:41 2012 @@ -1192,24 +1192,24 @@ def VMOVHPSmr : VPSI<0x17, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src), "movhps\t{$src, $dst|$dst, $src}", [(store (f64 (vector_extract - (unpckh (bc_v2f64 (v4f32 VR128:$src)), - (undef)), (iPTR 0))), addr:$dst)]>, - VEX; + (X86Unpckh (bc_v2f64 (v4f32 VR128:$src)), + (bc_v2f64 (v4f32 VR128:$src))), + (iPTR 0))), addr:$dst)]>, VEX; def VMOVHPDmr : VPDI<0x17, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src), "movhpd\t{$src, $dst|$dst, $src}", [(store (f64 (vector_extract - (v2f64 (unpckh VR128:$src, (undef))), - (iPTR 0))), addr:$dst)]>, - VEX; + (v2f64 (X86Unpckh VR128:$src, VR128:$src)), + (iPTR 0))), addr:$dst)]>, VEX; def MOVHPSmr : PSI<0x17, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src), "movhps\t{$src, $dst|$dst, $src}", [(store (f64 (vector_extract - (unpckh (bc_v2f64 (v4f32 VR128:$src)), - (undef)), (iPTR 0))), addr:$dst)]>; + (X86Unpckh (bc_v2f64 (v4f32 VR128:$src)), + (bc_v2f64 (v4f32 VR128:$src))), + (iPTR 0))), addr:$dst)]>; def MOVHPDmr : PDI<0x17, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src), "movhpd\t{$src, $dst|$dst, $src}", [(store (f64 (vector_extract - (v2f64 (unpckh VR128:$src, (undef))), + (v2f64 (X86Unpckh VR128:$src, VR128:$src)), (iPTR 0))), addr:$dst)]>; let Predicates = [HasAVX] in { @@ -1238,15 +1238,6 @@ def : Pat<(v2f64 (X86Movlhpd VR128:$src1, (scalar_to_vector (loadf64 addr:$src2)))), (VMOVHPDrm VR128:$src1, addr:$src2)>; - - // Store patterns - def : Pat<(store (f64 (vector_extract - (X86Unpckh (bc_v2f64 (v4f32 VR128:$src)), - (bc_v2f64 (v4f32 VR128:$src))), (iPTR 0))), addr:$dst), - (VMOVHPSmr addr:$dst, VR128:$src)>; - def : Pat<(store (f64 (vector_extract - (v2f64 (X86Unpckh VR128:$src, VR128:$src)), (iPTR 0))), addr:$dst), - (VMOVHPDmr addr:$dst, VR128:$src)>; } let Predicates = [HasSSE1] in { @@ -1262,12 +1253,6 @@ def : Pat<(X86Movlhps VR128:$src1, (bc_v4f32 (v2i64 (X86vzload addr:$src2)))), (MOVHPSrm VR128:$src1, addr:$src2)>; - - // Store patterns - def : Pat<(store (f64 (vector_extract - (X86Unpckh (bc_v2f64 (v4f32 VR128:$src)), - (bc_v2f64 (v4f32 VR128:$src))), (iPTR 0))), addr:$dst), - (MOVHPSmr addr:$dst, VR128:$src)>; } let Predicates = [HasSSE2] in { @@ -1283,11 +1268,6 @@ def : Pat<(v2f64 (X86Movlhpd VR128:$src1, (scalar_to_vector (loadf64 addr:$src2)))), (MOVHPDrm VR128:$src1, addr:$src2)>; - - // Store patterns - def : Pat<(store (f64 (vector_extract - (v2f64 (X86Unpckh VR128:$src, VR128:$src)), (iPTR 0))),addr:$dst), - (MOVHPDmr addr:$dst, VR128:$src)>; } //===----------------------------------------------------------------------===// From stpworld at narod.ru Mon Feb 13 01:38:06 2012 From: stpworld at narod.ru (Stepan Dyatkovskiy) Date: Mon, 13 Feb 2012 11:38:06 +0400 Subject: [llvm-commits] [llvm] r149481 - in /llvm/trunk: include/llvm/ include/llvm/Analysis/ lib/Analysis/ lib/Bitcode/Writer/ lib/CodeGen/SelectionDAG/ lib/ExecutionEngine/Interpreter/ lib/Target/CBackend/ lib/Target/CppBackend/ lib/Transforms/IPO/ lib/Transforms/InstCombine/ lib/Transforms/Scalar/ lib/Transforms/Utils/ lib/VMCore/ tools/llvm-diff/ In-Reply-To: <4F2A5E5F.5000403@free.fr> References: <20120201074953.13FFD2A6C12C@llvm.org> <4F2A5E5F.5000403@free.fr> Message-ID: <4F38BDDE.80400@narod.ru> Hi, Duncan. >> +#include > > please don't include this. You can just use ~0U. OK. >> + /// resolveSuccessorIndex - Converts case index to index of its successor >> + /// index in TerminatorInst successors collection. > > This comment is kind of obscure. There are too many uses of "index" flying > around. What is a successor in this context? I think I finally understood > that: a switch instruction has a number of edges coming out of it, and this > returns the edge index for the case. It would be nice if (like in Ada) you > could declare the different kinds of indices to have different types so that > they can't accidentally be confused. In fact you could make a "case index" > be opaque by creating a new CaseIndex class, and having indices be of that > class type. Hm... I thought about that too. Did you offer to implement some kind of iterators? >> + /// If CaseIndex == ErrorIndex, "default" successor will returned then. > > Why this behaviour? Is it a good idea to have ErrorIndex mean: index of > the default case? Because then it doesn't represent an error any more! > I think you should either rename ErrorIndex to DefaultIndex or change the > logic so that using ErrorIndex is an error, i.e. triggers an assert. Yes. DefaultIndex sounds much more better. I even propose to call it DefaultCase, since it doesn't index anything. Its like a some kind of unreachable numbers (infinity, or sqrt(-1) for real numbers), in short its not an eigenvalue. > >> + /// resolveCaseIndex - Converts index of successor in TerminatorInst >> + /// collection to index of case that corresponds to this successor. > > You didn't say it returns ErrorIndex if at the first case. And why does > it do that? Shouldn't an assertion fire then? See comments above. You right. If we replace ErrorIndex with DefaultCase, we got more logical behaviour: We have default successor and cases successors only. So if we meet some successor that are not belongs to any case, that means we got default successor. Also as you noticed I'll update the comment and add description what will returned for Successor with zero index. >> + /// Resolves successor for idx-th case. >> + /// Use getCaseSuccessor instead of TerminatorInst::getSuccessor, >> + /// since internal SwitchInst organization of operands/successors is >> + /// hidden and may be changed in any moment. > > I don't understand the point of this "Use getCaseSuccessor ..." comment. > There are perfectly legitimate uses of TerminatorInst::getSuccessor, i.e. > those which don't give a damn about case indices. So the comment is wrong > as it stands. Otherwise the only way to get things wrong is if use a case > index as a successor index. To prevent this easy accident you need more than > a comment, you need a way to make it impossible to confuse the types (see my > comment on introducing a class for this above). I think, iterators will solved that. In comment I asked do not mix TerminatorInst indexing with cases indexing. Of course if you want to use switch instruction as TerminatorInst - there is no crime to use get/setSuccessor methods. But again - iterators shoot this issue. >> - Succs[SI.findCaseValue(cast(C))] = true; >> + unsigned CCase = SI.findCaseValue(cast(C)); >> + Succs[SI.resolveSuccessorIndex(CCase)] = true; > > If the case is not found, kaboom! Use up all memory and die due to accessing > element UINT_MAX... Is this possible? Previously, did you get the default > case (0) here if not found? resolveSuccessorIndex remaps CCase == UINT_MAX to default successor index. > >> --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp (original) >> +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp Wed Feb 1 01:49:51 2012 >> @@ -2209,7 +2209,7 @@ >> >> CaseRange LHSR(CR.Range.first, Pivot); >> CaseRange RHSR(Pivot, CR.Range.second); >> - Constant *C = Pivot->Low; >> + const Constant *C = Pivot->Low; > > LLVM isn't into const qualifiers. I've already noticed it. I need to do that instead. SelectionDAGBuilder::visitSwitch works with "const SwitchInst &SI". So in that case I can work with "const ConstantInt SwitchInst::getCaseValue(unsigned) const" only. I kept this method declaration without changes. Do you propose to change it return value with "ConstaintInt*" instead of "const ConstantInt*" ? IMHO, looking LLVM sources I also noticed that there are some confusion relative to this subject. Just compare two method prototypes (I kept them unchanged): const ConstantInt *getCaseValue(unsigned i) const and ConstantInt *getSuccessorValue(unsigned idx) const So, looking on that I was confused too and decided to use "const". BTW, the last prototype is unused and should be removed. I'll apply the changes as community wishes. But IMHO it is better to use "const" modifier wherever it possible. In another case, this approach like a some kind of infection will removed all "const" modifiers in whole LLVM and its clients. > >> --- llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp (original) >> +++ llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp Wed Feb 1 01:49:51 2012 >> @@ -2455,7 +2455,8 @@ >> ConstantInt *Val = >> dyn_cast(getVal(Values, SI->getCondition())); >> if (!Val) return false; // Cannot determine. >> - NewBB = SI->getSuccessor(SI->findCaseValue(Val)); >> + unsigned ValTISucc = SI->resolveSuccessorIndex(SI->findCaseValue(Val)); >> + NewBB = SI->getSuccessor(ValTISucc); > > Does this resolve to the default successor if the case is not found? Yes. > >> --- llvm/trunk/lib/Transforms/Scalar/SCCP.cpp (original) >> +++ llvm/trunk/lib/Transforms/Scalar/SCCP.cpp Wed Feb 1 01:49:51 2012 >> @@ -564,7 +564,7 @@ >> return; >> } >> >> - Succs[SI->findCaseValue(CI)] = true; >> + Succs[SI->resolveSuccessorIndex(SI->findCaseValue(CI))] = true; > > Kaboom on the default case? Not. Default successor will resolved. > >> @@ -624,9 +624,9 @@ >> return !SCValue.isUndefined(); >> >> // Make sure to skip the "default value" which isn't a value >> - for (unsigned i = 1, E = SI->getNumSuccessors(); i != E; ++i) >> - if (SI->getSuccessorValue(i) == CI) // Found the taken branch. >> - return SI->getSuccessor(i) == To; >> + for (unsigned i = 0, E = SI->getNumCases(); i != E; ++i) >> + if (SI->getCaseValue(i) == CI) // Found the taken branch. >> + return SI->getCaseSuccessor(i) == To; > > Doesn't SwitchInst define a lookup method that does this? Yes. Sorry for stupid change. Of course we can use findCaseValue here. > >> --- llvm/trunk/lib/Transforms/Utils/Local.cpp (original) >> +++ llvm/trunk/lib/Transforms/Utils/Local.cpp Wed Feb 1 01:49:51 2012 >> @@ -106,22 +106,20 @@ >> // If we are switching on a constant, we can convert the switch into a >> // single branch instruction! >> ConstantInt *CI = dyn_cast(SI->getCondition()); >> - BasicBlock *TheOnlyDest = SI->getSuccessor(0); // The default dest >> + BasicBlock *TheOnlyDest = SI->getDefaultDest(); // The default dest > > The comment "// The default dest" is no longer useful. ok. > >> --- llvm/trunk/lib/Transforms/Utils/LowerExpectIntrinsic.cpp (original) >> +++ llvm/trunk/lib/Transforms/Utils/LowerExpectIntrinsic.cpp Wed Feb 1 01:49:51 2012 >> @@ -76,11 +76,14 @@ >> unsigned caseNo = SI->findCaseValue(ExpectedValue); >> std::vector Vec; >> unsigned n = SI->getNumCases(); >> - Vec.resize(n + 1); // +1 for MDString >> + Vec.resize(n + 1 + 1); // +1 for MDString and +1 for default case >> >> Vec[0] = MDString::get(Context, "branch_weights"); >> + Vec[1] = ConstantInt::get(Int32Ty, SwitchInst::ErrorIndex == caseNo ? >> + LikelyBranchWeight : UnlikelyBranchWeight); >> for (unsigned i = 0; i< n; ++i) { >> - Vec[i + 1] = ConstantInt::get(Int32Ty, i == caseNo ? LikelyBranchWeight : UnlikelyBranchWeight); >> + Vec[i + 1 + 1] = ConstantInt::get(Int32Ty, i == caseNo ? >> + LikelyBranchWeight : UnlikelyBranchWeight); >> } >> >> MDNode *WeightsNode = llvm::MDNode::get(Context, Vec); > > This seems to contain a bug fix/behaviour change, as such it should not have > been included in this patch. That said, it's there now so it might as well be > left there since it seems correct to me. Once more ErrorIndex is not indicating > an error... > I tried to keep semantics the same. Leaving that without changes means to change the semantics. Here we need to set Likely/Unlikey weights for DefaultCase and for all other Cases. Since getNumCases/getCaseValue is no longer enumerates DefaultCase, I need to write it explicitly outside the cycle. >> --- llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp (original) >> +++ llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp Wed Feb 1 01:49:51 2012 >> @@ -2007,8 +2010,10 @@ >> >> // Find the relevant condition and destinations. >> Value *Condition = Select->getCondition(); >> - BasicBlock *TrueBB = SI->getSuccessor(SI->findCaseValue(TrueVal)); >> - BasicBlock *FalseBB = SI->getSuccessor(SI->findCaseValue(FalseVal)); >> + unsigned TrueCase = SI->findCaseValue(TrueVal); >> + unsigned FalseCase = SI->findCaseValue(FalseVal); >> + BasicBlock *TrueBB = SI->getSuccessor(SI->resolveSuccessorIndex(TrueCase)); >> + BasicBlock *FalseBB = SI->getSuccessor(SI->resolveSuccessorIndex(FalseCase)); > > Since this idiom occurs a lot, how about adding a method for it to SwitchInst? Good idea. I can add something like a "BasicBlock *resolveSuccessor(CaseIndex &idx)". I will return either case succesor or default successor if idx == DefaultCase. > >> @@ -2616,8 +2621,10 @@ >> // Remove dead cases from the switch. >> for (unsigned I = 0, E = DeadCases.size(); I != E; ++I) { >> unsigned Case = SI->findCaseValue(DeadCases[I]); >> + assert(Case != SwitchInst::ErrorIndex&& >> + "Case was not found. Probably mistake in DeadCases forming."); > > As it actually wrong to get the default case here? Even if it dead we can't remove it here. Also algorithm implemented here said that its impossible. We analyse the condition bits and we calculate the bits that MUST be in value. Else the case value will never equals to condition - dead case. Current algorithm implementation will never detected that the default case is dead. Summary: 1. As you proposed I'll implement CaseIterator. It allows as to solve problem with mixing case indices with TerminatorInst indices, and with operand's indices. 2. I can replace "const ConstantInt*" with "ConstantInt*" in selection DAG. But I have a doubts relative to this change. 3. I'll implement "BasicBlock *resolveSuccessor(CaseIndex &idx)". 4. I also will remove getSuccessorValue, since it lost its semantics and unused. What do you think about it? -Stepan. From benny.kra at googlemail.com Mon Feb 13 01:57:26 2012 From: benny.kra at googlemail.com (Benjamin Kramer) Date: Mon, 13 Feb 2012 08:57:26 +0100 Subject: [llvm-commits] [llvm] r150328 - in /llvm/trunk/lib/Target/X86: X86InstrFragmentsSIMD.td X86InstrSSE.td In-Reply-To: References: <20120212081435.889421BE003@llvm.org> Message-ID: <1330967446003473764@unknownmsgid> On 13.02.2012, at 01:18, NAKAMURA Takumi wrote: > Craig, excuse me, I have reverted yours in r150357. > I have not reverted r150321, that Benjamin pointed, though. Thanks! it's possible that I blamed the wrong commit, they look very similar. - Ben > > ...Takumi From samsonov at google.com Mon Feb 13 02:27:10 2012 From: samsonov at google.com (Alexey Samsonov) Date: Mon, 13 Feb 2012 08:27:10 -0000 Subject: [llvm-commits] [compiler-rt] r150366 - in /compiler-rt/trunk/lib/asan/tests: test_output.sh use-after-free.c Message-ID: <20120213082710.76DAE2A6C12D@llvm.org> Author: samsonov Date: Mon Feb 13 02:27:10 2012 New Revision: 150366 URL: http://llvm.org/viewvc/llvm-project?rev=150366&view=rev Log: AddressSanitizer: Use FileCheck instead of grep for pure C output tests Modified: compiler-rt/trunk/lib/asan/tests/test_output.sh compiler-rt/trunk/lib/asan/tests/use-after-free.c Modified: compiler-rt/trunk/lib/asan/tests/test_output.sh URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/tests/test_output.sh?rev=150366&r1=150365&r2=150366&view=diff ============================================================================== --- compiler-rt/trunk/lib/asan/tests/test_output.sh (original) +++ compiler-rt/trunk/lib/asan/tests/test_output.sh Mon Feb 13 02:27:10 2012 @@ -7,22 +7,37 @@ CC=$2 CXXFLAGS="-mno-omit-leaf-frame-pointer -fno-omit-frame-pointer -fno-optimize-sibling-calls" SYMBOLIZER=../scripts/asan_symbolize.py +FILE_CHECK=../../../../../build/Release+Asserts/bin/FileCheck + +# check_program exe_file src_file [check_prefix] +check_program() { + exe=$1 + src=$2 + prefix="CHECK" + if [ "z$3" != "z" ] ; then + prefix=$3 + fi + ./$exe 2>&1 | $SYMBOLIZER 2> /dev/null | c++filt | \ + $FILE_CHECK $src --check-prefix=$prefix +} C_TEST=use-after-free echo "Sanity checking a test in pure C" $CC -g -faddress-sanitizer -O2 $C_TEST.c -./a.out 2>&1 | grep "heap-use-after-free" > /dev/null +check_program a.out $C_TEST.c rm ./a.out echo "Sanity checking a test in pure C with -pie" $CC -g -faddress-sanitizer -O2 $C_TEST.c -pie -./a.out 2>&1 | grep "heap-use-after-free" > /dev/null +check_program a.out $C_TEST.c rm ./a.out echo "Testing sleep_before_dying" $CC -g -faddress-sanitizer -O2 $C_TEST.c -ASAN_OPTIONS=sleep_before_dying=1 ./a.out 2>&1 | grep "Sleeping for 1 second" > /dev/null -rm a.out +export ASAN_OPTIONS="sleep_before_dying=1" +check_program a.out $C_TEST.c CHECKSLEEP +export ASAN_OPTIONS="" +rm ./a.out for t in *.tmpl; do for b in 32 64; do Modified: compiler-rt/trunk/lib/asan/tests/use-after-free.c URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/tests/use-after-free.c?rev=150366&r1=150365&r2=150366&view=diff ============================================================================== --- compiler-rt/trunk/lib/asan/tests/use-after-free.c (original) +++ compiler-rt/trunk/lib/asan/tests/use-after-free.c Mon Feb 13 02:27:10 2012 @@ -4,3 +4,6 @@ free(x); return x[5]; } + +// CHECK: heap-use-after-free +// CHECKSLEEP: Sleeping for 1 second From samsonov at google.com Mon Feb 13 02:50:22 2012 From: samsonov at google.com (Alexey Samsonov) Date: Mon, 13 Feb 2012 08:50:22 -0000 Subject: [llvm-commits] [compiler-rt] r150367 - in /compiler-rt/trunk/lib/asan: ./ output_tests/ tests/ Message-ID: <20120213085023.AADC62A6C12E@llvm.org> Author: samsonov Date: Mon Feb 13 02:50:21 2012 New Revision: 150367 URL: http://llvm.org/viewvc/llvm-project?rev=150367&view=rev Log: AddressSanitizer: move output tests to a separate directory Added: compiler-rt/trunk/lib/asan/output_tests/ compiler-rt/trunk/lib/asan/output_tests/clone_test.cc - copied unchanged from r150365, compiler-rt/trunk/lib/asan/tests/clone_test.cc compiler-rt/trunk/lib/asan/output_tests/clone_test.tmpl - copied unchanged from r150365, compiler-rt/trunk/lib/asan/tests/clone_test.tmpl compiler-rt/trunk/lib/asan/output_tests/deep_tail_call.cc - copied unchanged from r150365, compiler-rt/trunk/lib/asan/tests/deep_tail_call.cc compiler-rt/trunk/lib/asan/output_tests/deep_tail_call.tmpl - copied unchanged from r150365, compiler-rt/trunk/lib/asan/tests/deep_tail_call.tmpl compiler-rt/trunk/lib/asan/output_tests/dlclose-test-so.cc - copied unchanged from r150365, compiler-rt/trunk/lib/asan/tests/dlclose-test-so.cc compiler-rt/trunk/lib/asan/output_tests/dlclose-test.cc - copied unchanged from r150365, compiler-rt/trunk/lib/asan/tests/dlclose-test.cc compiler-rt/trunk/lib/asan/output_tests/dlclose-test.tmpl - copied unchanged from r150365, compiler-rt/trunk/lib/asan/tests/dlclose-test.tmpl compiler-rt/trunk/lib/asan/output_tests/global-overflow.cc - copied unchanged from r150365, compiler-rt/trunk/lib/asan/tests/global-overflow.cc compiler-rt/trunk/lib/asan/output_tests/global-overflow.tmpl - copied unchanged from r150365, compiler-rt/trunk/lib/asan/tests/global-overflow.tmpl compiler-rt/trunk/lib/asan/output_tests/heap-overflow.cc - copied unchanged from r150365, compiler-rt/trunk/lib/asan/tests/heap-overflow.cc compiler-rt/trunk/lib/asan/output_tests/heap-overflow.tmpl - copied unchanged from r150365, compiler-rt/trunk/lib/asan/tests/heap-overflow.tmpl compiler-rt/trunk/lib/asan/output_tests/heap-overflow.tmpl.Darwin - copied unchanged from r150365, compiler-rt/trunk/lib/asan/tests/heap-overflow.tmpl.Darwin compiler-rt/trunk/lib/asan/output_tests/large_func_test.cc - copied unchanged from r150365, compiler-rt/trunk/lib/asan/tests/large_func_test.cc compiler-rt/trunk/lib/asan/output_tests/large_func_test.tmpl - copied unchanged from r150365, compiler-rt/trunk/lib/asan/tests/large_func_test.tmpl compiler-rt/trunk/lib/asan/output_tests/match_output.py - copied unchanged from r150365, compiler-rt/trunk/lib/asan/tests/match_output.py compiler-rt/trunk/lib/asan/output_tests/null_deref.cc - copied unchanged from r150365, compiler-rt/trunk/lib/asan/tests/null_deref.cc compiler-rt/trunk/lib/asan/output_tests/null_deref.tmpl - copied unchanged from r150365, compiler-rt/trunk/lib/asan/tests/null_deref.tmpl compiler-rt/trunk/lib/asan/output_tests/null_deref.tmpl.Darwin - copied unchanged from r150365, compiler-rt/trunk/lib/asan/tests/null_deref.tmpl.Darwin compiler-rt/trunk/lib/asan/output_tests/shared-lib-test-so.cc - copied unchanged from r150365, compiler-rt/trunk/lib/asan/tests/shared-lib-test-so.cc compiler-rt/trunk/lib/asan/output_tests/shared-lib-test.cc - copied unchanged from r150365, compiler-rt/trunk/lib/asan/tests/shared-lib-test.cc compiler-rt/trunk/lib/asan/output_tests/shared-lib-test.tmpl - copied unchanged from r150365, compiler-rt/trunk/lib/asan/tests/shared-lib-test.tmpl compiler-rt/trunk/lib/asan/output_tests/stack-overflow.cc - copied unchanged from r150365, compiler-rt/trunk/lib/asan/tests/stack-overflow.cc compiler-rt/trunk/lib/asan/output_tests/stack-overflow.tmpl - copied unchanged from r150365, compiler-rt/trunk/lib/asan/tests/stack-overflow.tmpl compiler-rt/trunk/lib/asan/output_tests/stack-use-after-return.cc - copied unchanged from r150365, compiler-rt/trunk/lib/asan/tests/stack-use-after-return.cc compiler-rt/trunk/lib/asan/output_tests/stack-use-after-return.disabled - copied unchanged from r150365, compiler-rt/trunk/lib/asan/tests/stack-use-after-return.disabled compiler-rt/trunk/lib/asan/output_tests/strncpy-overflow.cc - copied unchanged from r150365, compiler-rt/trunk/lib/asan/tests/strncpy-overflow.cc compiler-rt/trunk/lib/asan/output_tests/strncpy-overflow.tmpl - copied unchanged from r150365, compiler-rt/trunk/lib/asan/tests/strncpy-overflow.tmpl compiler-rt/trunk/lib/asan/output_tests/strncpy-overflow.tmpl.Darwin - copied unchanged from r150365, compiler-rt/trunk/lib/asan/tests/strncpy-overflow.tmpl.Darwin compiler-rt/trunk/lib/asan/output_tests/test_output.sh - copied unchanged from r150366, compiler-rt/trunk/lib/asan/tests/test_output.sh compiler-rt/trunk/lib/asan/output_tests/use-after-free.c - copied unchanged from r150366, compiler-rt/trunk/lib/asan/tests/use-after-free.c compiler-rt/trunk/lib/asan/output_tests/use-after-free.cc - copied unchanged from r150365, compiler-rt/trunk/lib/asan/tests/use-after-free.cc compiler-rt/trunk/lib/asan/output_tests/use-after-free.tmpl - copied unchanged from r150365, compiler-rt/trunk/lib/asan/tests/use-after-free.tmpl compiler-rt/trunk/lib/asan/output_tests/use-after-free.tmpl.Darwin - copied unchanged from r150365, compiler-rt/trunk/lib/asan/tests/use-after-free.tmpl.Darwin Removed: compiler-rt/trunk/lib/asan/tests/clone_test.cc compiler-rt/trunk/lib/asan/tests/clone_test.tmpl compiler-rt/trunk/lib/asan/tests/deep_tail_call.cc compiler-rt/trunk/lib/asan/tests/deep_tail_call.tmpl compiler-rt/trunk/lib/asan/tests/dlclose-test-so.cc compiler-rt/trunk/lib/asan/tests/dlclose-test.cc compiler-rt/trunk/lib/asan/tests/dlclose-test.tmpl compiler-rt/trunk/lib/asan/tests/global-overflow.cc compiler-rt/trunk/lib/asan/tests/global-overflow.tmpl compiler-rt/trunk/lib/asan/tests/heap-overflow.cc compiler-rt/trunk/lib/asan/tests/heap-overflow.tmpl compiler-rt/trunk/lib/asan/tests/heap-overflow.tmpl.Darwin compiler-rt/trunk/lib/asan/tests/large_func_test.cc compiler-rt/trunk/lib/asan/tests/large_func_test.tmpl compiler-rt/trunk/lib/asan/tests/match_output.py compiler-rt/trunk/lib/asan/tests/null_deref.cc compiler-rt/trunk/lib/asan/tests/null_deref.tmpl compiler-rt/trunk/lib/asan/tests/null_deref.tmpl.Darwin compiler-rt/trunk/lib/asan/tests/shared-lib-test-so.cc compiler-rt/trunk/lib/asan/tests/shared-lib-test.cc compiler-rt/trunk/lib/asan/tests/shared-lib-test.tmpl compiler-rt/trunk/lib/asan/tests/stack-overflow.cc compiler-rt/trunk/lib/asan/tests/stack-overflow.tmpl compiler-rt/trunk/lib/asan/tests/stack-use-after-return.cc compiler-rt/trunk/lib/asan/tests/stack-use-after-return.disabled compiler-rt/trunk/lib/asan/tests/strncpy-overflow.cc compiler-rt/trunk/lib/asan/tests/strncpy-overflow.tmpl compiler-rt/trunk/lib/asan/tests/strncpy-overflow.tmpl.Darwin compiler-rt/trunk/lib/asan/tests/test_output.sh compiler-rt/trunk/lib/asan/tests/use-after-free.c compiler-rt/trunk/lib/asan/tests/use-after-free.cc compiler-rt/trunk/lib/asan/tests/use-after-free.tmpl compiler-rt/trunk/lib/asan/tests/use-after-free.tmpl.Darwin Modified: compiler-rt/trunk/lib/asan/Makefile.old Modified: compiler-rt/trunk/lib/asan/Makefile.old URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/Makefile.old?rev=150367&r1=150366&r2=150367&view=diff ============================================================================== --- compiler-rt/trunk/lib/asan/Makefile.old (original) +++ compiler-rt/trunk/lib/asan/Makefile.old Mon Feb 13 02:50:21 2012 @@ -213,7 +213,7 @@ @echo "ALL TESTS PASSED" output_tests: b32 b64 - cd tests && ./test_output.sh $(CLANG_CXX) $(CLANG_CC) + cd output_tests && ./test_output.sh $(CLANG_CXX) $(CLANG_CC) t64: b64 $(BIN)/asan_test64 Removed: compiler-rt/trunk/lib/asan/tests/clone_test.cc URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/tests/clone_test.cc?rev=150366&view=auto ============================================================================== --- compiler-rt/trunk/lib/asan/tests/clone_test.cc (original) +++ compiler-rt/trunk/lib/asan/tests/clone_test.cc (removed) @@ -1,33 +0,0 @@ -#ifdef __linux__ -#include -#include -#include -#include -#include -#include - -int Child(void *arg) { - char x[32] = {0}; // Stack gets poisoned. - printf("Child: %p\n", x); - _exit(1); // NoReturn, stack will remain unpoisoned unless we do something. -} - -int main(int argc, char **argv) { - const int kStackSize = 1 << 20; - char child_stack[kStackSize + 1]; - char *sp = child_stack + kStackSize; // Stack grows down. - printf("Parent: %p\n", sp); - pid_t clone_pid = clone(Child, sp, CLONE_FILES | CLONE_VM, NULL, 0, 0, 0); - waitpid(clone_pid, NULL, 0); - for (int i = 0; i < kStackSize; i++) - child_stack[i] = i; - int ret = child_stack[argc - 1]; - printf("PASSED\n"); - return ret; -} -#else // not __linux__ -#include -int main() { - printf("PASSED\n"); -} -#endif Removed: compiler-rt/trunk/lib/asan/tests/clone_test.tmpl URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/tests/clone_test.tmpl?rev=150366&view=auto ============================================================================== --- compiler-rt/trunk/lib/asan/tests/clone_test.tmpl (original) +++ compiler-rt/trunk/lib/asan/tests/clone_test.tmpl (removed) @@ -1 +0,0 @@ -PASSED Removed: compiler-rt/trunk/lib/asan/tests/deep_tail_call.cc URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/tests/deep_tail_call.cc?rev=150366&view=auto ============================================================================== --- compiler-rt/trunk/lib/asan/tests/deep_tail_call.cc (original) +++ compiler-rt/trunk/lib/asan/tests/deep_tail_call.cc (removed) @@ -1,13 +0,0 @@ -int global[10]; -__attribute__((noinline)) -void call4(int i) { global[i+10]++; } -__attribute__((noinline)) -void call3(int i) { call4(i); } -__attribute__((noinline)) -void call2(int i) { call3(i); } -__attribute__((noinline)) -void call1(int i) { call2(i); } -int main(int argc, char **argv) { - call1(argc); - return global[0]; -} Removed: compiler-rt/trunk/lib/asan/tests/deep_tail_call.tmpl URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/tests/deep_tail_call.tmpl?rev=150366&view=auto ============================================================================== --- compiler-rt/trunk/lib/asan/tests/deep_tail_call.tmpl (original) +++ compiler-rt/trunk/lib/asan/tests/deep_tail_call.tmpl (removed) @@ -1,6 +0,0 @@ -AddressSanitizer global-buffer-overflow - #0.*call4 - #1.*call3 - #2.*call2 - #3.*call1 - #4.*main Removed: compiler-rt/trunk/lib/asan/tests/dlclose-test-so.cc URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/tests/dlclose-test-so.cc?rev=150366&view=auto ============================================================================== --- compiler-rt/trunk/lib/asan/tests/dlclose-test-so.cc (original) +++ compiler-rt/trunk/lib/asan/tests/dlclose-test-so.cc (removed) @@ -1,33 +0,0 @@ -//===-- asan_rtl.cc ------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file is a part of AddressSanitizer, an address sanity checker. -// -// Regression test for -// http://code.google.com/p/address-sanitizer/issues/detail?id=19 -//===----------------------------------------------------------------------===// -#include - -static int pad1; -static int static_var; -static int pad2; - -extern "C" -int *get_address_of_static_var() { - return &static_var; -} - -__attribute__((constructor)) -void at_dlopen() { - printf("%s: I am being dlopened\n", __FILE__); -} -__attribute__((destructor)) -void at_dlclose() { - printf("%s: I am being dlclosed\n", __FILE__); -} Removed: compiler-rt/trunk/lib/asan/tests/dlclose-test.cc URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/tests/dlclose-test.cc?rev=150366&view=auto ============================================================================== --- compiler-rt/trunk/lib/asan/tests/dlclose-test.cc (original) +++ compiler-rt/trunk/lib/asan/tests/dlclose-test.cc (removed) @@ -1,73 +0,0 @@ -//===-- asan_rtl.cc ------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file is a part of AddressSanitizer, an address sanity checker. -// -// Regression test for -// http://code.google.com/p/address-sanitizer/issues/detail?id=19 -// Bug description: -// 1. application dlopens foo.so -// 2. asan registers all globals from foo.so -// 3. application dlcloses foo.so -// 4. application mmaps some memory to the location where foo.so was before -// 5. application starts using this mmaped memory, but asan still thinks there -// are globals. -// 6. BOOM -//===----------------------------------------------------------------------===// -#include -#include -#include -#include -#include - -#include - -using std::string; - -static const int kPageSize = 4096; - -typedef int *(fun_t)(); - -int main(int argc, char *argv[]) { - string path = string(argv[0]) + "-so.so"; - printf("opening %s ... \n", path.c_str()); - void *lib = dlopen(path.c_str(), RTLD_NOW); - if (!lib) { - printf("error in dlopen(): %s\n", dlerror()); - return 1; - } - fun_t *get = (fun_t*)dlsym(lib, "get_address_of_static_var"); - if (!get) { - printf("failed dlsym\n"); - return 1; - } - int *addr = get(); - assert(((size_t)addr % 32) == 0); // should be 32-byte aligned. - printf("addr: %p\n", addr); - addr[0] = 1; // make sure we can write there. - - // Now dlclose the shared library. - printf("attempting to dlclose\n"); - if (dlclose(lib)) { - printf("failed to dlclose\n"); - return 1; - } - // Now, the page where 'addr' is unmapped. Map it. - size_t page_beg = ((size_t)addr) & ~(kPageSize - 1); - void *res = mmap((void*)(page_beg), kPageSize, - PROT_READ | PROT_WRITE, - MAP_PRIVATE | MAP_ANON | MAP_FIXED | MAP_NORESERVE, 0, 0); - if (res == (char*)-1L) { - printf("failed to mmap\n"); - return 1; - } - addr[1] = 2; // BOOM (if the bug is not fixed). - printf("PASS\n"); - return 0; -} Removed: compiler-rt/trunk/lib/asan/tests/dlclose-test.tmpl URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/tests/dlclose-test.tmpl?rev=150366&view=auto ============================================================================== --- compiler-rt/trunk/lib/asan/tests/dlclose-test.tmpl (original) +++ compiler-rt/trunk/lib/asan/tests/dlclose-test.tmpl (removed) @@ -1 +0,0 @@ -PASS Removed: compiler-rt/trunk/lib/asan/tests/global-overflow.cc URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/tests/global-overflow.cc?rev=150366&view=auto ============================================================================== --- compiler-rt/trunk/lib/asan/tests/global-overflow.cc (original) +++ compiler-rt/trunk/lib/asan/tests/global-overflow.cc (removed) @@ -1,12 +0,0 @@ -#include -int main(int argc, char **argv) { - static char XXX[10]; - static char YYY[10]; - static char ZZZ[10]; - memset(XXX, 0, 10); - memset(YYY, 0, 10); - memset(ZZZ, 0, 10); - int res = YYY[argc * 10]; // BOOOM - res += XXX[argc] + ZZZ[argc]; - return res; -} Removed: compiler-rt/trunk/lib/asan/tests/global-overflow.tmpl URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/tests/global-overflow.tmpl?rev=150366&view=auto ============================================================================== --- compiler-rt/trunk/lib/asan/tests/global-overflow.tmpl (original) +++ compiler-rt/trunk/lib/asan/tests/global-overflow.tmpl (removed) @@ -1,3 +0,0 @@ -READ of size 1 at 0x.* thread T0 - #0 0x.* in main .*global-overflow.cc:9 -0x.* is located 0 bytes to the right of global variable .*YYY.* of size 10 Removed: compiler-rt/trunk/lib/asan/tests/heap-overflow.cc URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/tests/heap-overflow.cc?rev=150366&view=auto ============================================================================== --- compiler-rt/trunk/lib/asan/tests/heap-overflow.cc (original) +++ compiler-rt/trunk/lib/asan/tests/heap-overflow.cc (removed) @@ -1,9 +0,0 @@ -#include -#include -int main(int argc, char **argv) { - char *x = (char*)malloc(10 * sizeof(char)); - memset(x, 0, 10); - int res = x[argc * 10]; // BOOOM - free(x); - return res; -} Removed: compiler-rt/trunk/lib/asan/tests/heap-overflow.tmpl URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/tests/heap-overflow.tmpl?rev=150366&view=auto ============================================================================== --- compiler-rt/trunk/lib/asan/tests/heap-overflow.tmpl (original) +++ compiler-rt/trunk/lib/asan/tests/heap-overflow.tmpl (removed) @@ -1,6 +0,0 @@ -READ of size 1 at 0x.* thread T0 - #0 0x.* in main .*heap-overflow.cc:6 -0x.* is located 0 bytes to the right of 10-byte region -allocated by thread T0 here: - #0 0x.* in malloc - #1 0x.* in main .*heap-overflow.cc:[45] Removed: compiler-rt/trunk/lib/asan/tests/heap-overflow.tmpl.Darwin URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/tests/heap-overflow.tmpl.Darwin?rev=150366&view=auto ============================================================================== --- compiler-rt/trunk/lib/asan/tests/heap-overflow.tmpl.Darwin (original) +++ compiler-rt/trunk/lib/asan/tests/heap-overflow.tmpl.Darwin (removed) @@ -1,8 +0,0 @@ -READ of size 1 at 0x.* thread T0 - #0 0x.* in main .*heap-overflow.cc:6 -0x.* is located 0 bytes to the right of 10-byte region -allocated by thread T0 here: - #0 0x.* in .*mz_malloc.* - #1 0x.* in malloc_zone_malloc.* - #2 0x.* in malloc.* - #3 0x.* in main heap-overflow.cc:[45] Removed: compiler-rt/trunk/lib/asan/tests/large_func_test.cc URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/tests/large_func_test.cc?rev=150366&view=auto ============================================================================== --- compiler-rt/trunk/lib/asan/tests/large_func_test.cc (original) +++ compiler-rt/trunk/lib/asan/tests/large_func_test.cc (removed) @@ -1,33 +0,0 @@ -#include -__attribute__((noinline)) -static void LargeFunction(int *x, int zero) { - x[0]++; - x[1]++; - x[2]++; - x[3]++; - x[4]++; - x[5]++; - x[6]++; - x[7]++; - x[8]++; - x[9]++; - - x[zero + 111]++; // we should report this exact line - - x[10]++; - x[11]++; - x[12]++; - x[13]++; - x[14]++; - x[15]++; - x[16]++; - x[17]++; - x[18]++; - x[19]++; -} - -int main(int argc, char **argv) { - int *x = new int[100]; - LargeFunction(x, argc - 1); - delete x; -} Removed: compiler-rt/trunk/lib/asan/tests/large_func_test.tmpl URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/tests/large_func_test.tmpl?rev=150366&view=auto ============================================================================== --- compiler-rt/trunk/lib/asan/tests/large_func_test.tmpl (original) +++ compiler-rt/trunk/lib/asan/tests/large_func_test.tmpl (removed) @@ -1,8 +0,0 @@ -.*ERROR: AddressSanitizer heap-buffer-overflow on address 0x.* at pc 0x.* bp 0x.* sp 0x.* -READ of size 4 at 0x.* thread T0 - #0 0x.* in LargeFunction .*large_func_test.cc:15 - #1 0x.* in main .*large_func_test.cc:3[012] -0x.* is located 44 bytes to the right of 400-byte region -allocated by thread T0 here: - #0 0x.* in operator new.* - #1 0x.* in main .*large_func_test.cc:30 Removed: compiler-rt/trunk/lib/asan/tests/match_output.py URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/tests/match_output.py?rev=150366&view=auto ============================================================================== --- compiler-rt/trunk/lib/asan/tests/match_output.py (original) +++ compiler-rt/trunk/lib/asan/tests/match_output.py (removed) @@ -1,35 +0,0 @@ -#!/usr/bin/python - -import re -import sys - -def matchFile(f, f_re): - for line_re in f_re: - line_re = line_re.rstrip() - if not line_re: - continue - if line_re[0] == '#': - continue - match = False - for line in f: - line = line.rstrip() - # print line - if re.search(line_re, line): - match = True - #print 'match: %s =~ %s' % (line, line_re) - break - if not match: - print 'no match for: %s' % (line_re) - return False - return True - -if len(sys.argv) != 2: - print >>sys.stderr, 'Usage: %s