llvm-6502/lib/Transforms/Utils
Ahmed Bougacha 37be0d7c43 [SimplifyLibCalls] Don't confuse strcpy_chk for stpcpy_chk.
This was introduced in a faulty refactoring (r225640, mea culpa):
the tests weren't testing the return values, so, for both
__strcpy_chk and __stpcpy_chk, we would return the end of the
buffer (matching stpcpy) instead of the beginning (for strcpy).

The root cause was the prefix "__" being ignored when comparing,
which made us always pick LibFunc::stpcpy_chk.
Pass the LibFunc::Func directly to avoid this kind of error.
Also, make the testcases as explicit as possible to prevent this.

The now-useful testcases expose another, entangled, stpcpy problem,
with the further simplification.  This was introduced in a
refactoring (r225640) to match the original behavior.

However, this leads to problems when successive simplifications
generate several similar instructions, none of which are removed
by the custom replaceAllUsesWith.

For instance, InstCombine (the main user) doesn't erase the
instruction in its custom RAUW.  When trying to simplify say
__stpcpy_chk:
- first, an stpcpy is created (fortified simplifier),
- second, a memcpy is created (normal simplifier), but the
  stpcpy call isn't removed.
- third, InstCombine later revisits the instructions,
  and simplifies the first stpcpy to a memcpy.  We now have
  two memcpys.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@227250 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-27 21:52:16 +00:00
..
AddDiscriminators.cpp IR: Split Metadata from Value 2014-12-09 18:38:53 +00:00
ASanStackFrameLayout.cpp Revert "Introduce a string_ostream string builder facilty" 2014-06-26 22:52:05 +00:00
BasicBlockUtils.cpp [PM] Replace the Pass argument to SplitEdge with specific analyses used 2015-01-19 12:36:53 +00:00
BreakCriticalEdges.cpp [PM] Remove the Pass argument from all of the critical edge splitting 2015-01-19 12:09:11 +00:00
BuildLibCalls.cpp [PM] Move TargetLibraryInfo into the Analysis library. 2015-01-15 02:16:27 +00:00
BypassSlowDivision.cpp [C++] Use 'nullptr'. Transforms edition. 2014-04-25 05:29:35 +00:00
CloneFunction.cpp Rename MapValue(Metadata*) to MapMetadata() 2014-12-19 06:06:18 +00:00
CloneModule.cpp Remove a bad cast in CloneModule() 2014-12-23 08:23:45 +00:00
CMakeLists.txt [PM] Move the LowerExpectIntrinsic pass to the Scalar library. 2015-01-24 10:18:47 +00:00
CmpInstAnalysis.cpp [C++] Use 'nullptr'. Transforms edition. 2014-04-25 05:29:35 +00:00
CodeExtractor.cpp Revert "[C++11] Add predecessors(BasicBlock *) / successors(BasicBlock *) iterator ranges." 2014-07-21 17:06:51 +00:00
CtorUtils.cpp GlobalOpt: Preserve comdats of unoptimized initializers 2014-09-23 22:33:01 +00:00
DemoteRegToStack.cpp [C++] Use 'nullptr'. Transforms edition. 2014-04-25 05:29:35 +00:00
FlattenCFG.cpp utils: Fix segfault in flattencfg 2014-08-13 20:31:53 +00:00
GlobalStatus.cpp Update SetVector to rely on the underlying set's insert to return a pair<iterator, bool> 2014-11-19 07:49:26 +00:00
InlineFunction.cpp DebugInfo: Use distinct inlinedAt MDLocations to avoid separate inlined calls being coalesced 2015-01-21 22:57:29 +00:00
InstructionNamer.cpp [C++11] Add 'override' keyword to virtual methods that override their base class. 2014-03-05 09:10:37 +00:00
IntegerDivision.cpp Fix heap-use-after-free bug in expandSDiv when the operands are 2014-11-05 21:28:24 +00:00
LCSSA.cpp [PM] Split the LoopInfo object apart from the legacy pass, creating 2015-01-17 14:16:18 +00:00
LLVMBuild.txt Update libdeps since TLI was moved from Target to Analysis in r226078. 2015-01-15 05:21:00 +00:00
Local.cpp Make ConstantFoldTerminator() handle switches with unreachable default. 2015-01-26 19:52:24 +00:00
LoopSimplify.cpp [PM] Lift the analyses into the interface for 2015-01-19 03:03:39 +00:00
LoopUnroll.cpp [PM] Now that LoopInfo isn't in the Pass type hierarchy, it is much 2015-01-18 01:25:51 +00:00
LoopUnrollRuntime.cpp [PM] Replace the Pass argument to SplitEdge with specific analyses used 2015-01-19 12:36:53 +00:00
LowerInvoke.cpp [Modules] Fix potential ODR violations by sinking the DEBUG_TYPE 2014-04-22 02:55:47 +00:00
LowerSwitch.cpp LowerSwitch: replace unreachable default with popular case destination 2015-01-23 20:43:51 +00:00
Makefile
Mem2Reg.cpp [PM] Split the AssumptionTracker immutable pass into two separate APIs: 2015-01-04 12:03:27 +00:00
MetaRenamer.cpp [C++11] Add 'override' keyword to virtual methods that override their base class. 2014-03-05 09:10:37 +00:00
ModuleUtils.cpp Repace SmallPtrSet with SmallPtrSetImpl in function arguments to avoid needing to mention the size. 2014-08-21 05:55:13 +00:00
PromoteMemoryToRegister.cpp [PM] Split the AssumptionTracker immutable pass into two separate APIs: 2015-01-04 12:03:27 +00:00
SimplifyCFG.cpp SimplifyCFG: Omit range checks for switch lookup tables when default is unreachable 2015-01-26 19:52:34 +00:00
SimplifyIndVar.cpp [PM] Remove a dead field. 2015-01-17 14:31:35 +00:00
SimplifyInstructions.cpp [PM] Separate the TargetLibraryInfo object from the immutable pass. 2015-01-15 10:41:28 +00:00
SimplifyLibCalls.cpp [SimplifyLibCalls] Don't confuse strcpy_chk for stpcpy_chk. 2015-01-27 21:52:16 +00:00
SSAUpdater.cpp Revert "[C++11] Add predecessors(BasicBlock *) / successors(BasicBlock *) iterator ranges." 2014-07-21 17:06:51 +00:00
SymbolRewriter.cpp SymbolRewriter: use iplist::splice 2015-01-05 17:56:32 +00:00
UnifyFunctionExitNodes.cpp [C++] Use 'nullptr'. Transforms edition. 2014-04-25 05:29:35 +00:00
Utils.cpp Pass to emit DWARF path discriminators. 2014-03-03 20:06:11 +00:00
ValueMapper.cpp IR: Move MDNode clone() methods from ValueMapper to MDNode, NFC 2015-01-20 02:56:57 +00:00