1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 03:02:36 +01:00
llvm-mirror/test/Transforms
Fangrui Song a99d809eec [SimplifyLibcalls] Don't replace locked IO (fgetc/fgets/fputc/fputs/fread/fwrite) with unlocked IO (*_unlocked)
This essentially reverts some of the SimplifyLibcalls part changes of D45736 [SimplifyLibcalls] Replace locked IO with unlocked IO.

C11 7.21.5.2 The fflush function

> If stream is a null pointer, the fflush function performs this flushing action on all streams for which the behavior is defined above.

i.e. fopen'ed FILE* is inherently captured.

POSIX.1-2017 getc_unlocked, getchar_unlocked, putc_unlocked, putchar_unlocked - stdio with explicit client locking

> These functions can safely be used in a multi-threaded program if and only if they are called while the invoking thread owns the ( FILE *) object, as is the case after a successful call to the flockfile() or ftrylockfile() functions.

After a thread fopen'ed a FILE*, when it is calling foobar() which is now replaced by foobar_unlocked(),
if another thread is concurrently calling fflush(0), the behavior is undefined.

C11 7.22.4.4 The exit function

> Next, all open streams with unwritten buffered data are flushed, all open streams are closed, and all files created by the tmpfile function are removed.

The replacement is only feasible if the program is single threaded, or exit or fflush(0) is never called.
See also http://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20180528/556615.html
for how the replacement makes libc interceptors difficult to implement.

dalias: in a worst case, it's unbounded data corruption because of concurrent access to pointers
without synchronization.  f->wpos or rpos could get outside of the buffer, thread A could do
f->wpos += j after knowing j is in bounds, while thread B also changes it concurrently.

This can produce exploitable conditions depending on libc internals.

Revert the SimplifyLibcalls part change because the cons obviously
overweigh the pros.  Even when the replacement is feasible, the benefit
is indemonstrable, more so in an application instead of an artificial
glibc benchmark.  Theoretically the replacement could be beneficial when
calling getc_unlocked/putc_unlocked in a loop, but then it is better
using a blocked IO operation and the user is likely aware of that.

The function attribute inference is still useful and thus kept.

Reviewed By: xbolva00

Differential Revision: https://reviews.llvm.org/D75933
2020-03-10 11:11:58 -07:00
..
ADCE
AddDiscriminators Migrate function attribute "no-frame-pointer-elim"="false" to "frame-pointer"="none" as cleanups after D56351 2019-12-24 16:27:51 -08:00
AggressiveInstCombine [AggressiveInstCombine] Add test with baseline CHECKs for aggressive inst combine for ICmp instruction. 2020-02-12 15:09:38 +02:00
AlignmentFromAssumptions
ArgumentPromotion
AtomicExpand
Attributor [Attributor] Deduction based on path exploration 2020-03-09 14:29:26 +09:00
BDCE
BlockExtractor Revert "Revert "Reland "[Support] make report_fatal_error abort instead of exit""" 2020-02-13 10:16:06 -08:00
BranchFolding
CalledValuePropagation
CallSiteSplitting
CanonicalizeAliases
CodeExtractor [LoopExtractor] Convert LoopExtractor from LoopPass to ModulePass 2020-02-09 12:25:21 +02:00
CodeGenPrepare Recommit "[PatternMatch] Match XOR variant of unsigned-add overflow check." 2020-02-23 18:33:18 +00:00
ConstantHoisting Migrate function attribute "no-frame-pointer-elim"="false" to "frame-pointer"="none" as cleanups after D56351 2019-12-24 16:27:51 -08:00
ConstantMerge
ConstProp [ConstProp] Add test for bitcast to gep fold; NFC 2020-03-04 18:27:20 +01:00
Coroutines [Coroutines] Optimized coroutine elision based on reachability 2020-03-05 14:43:50 +08:00
CorrelatedValuePropagation [CVP] Simplify cmp of local phi node 2020-02-26 20:36:41 +01:00
CrossDSOCFI
DCE
DeadArgElim [NFC] Fix trivial typos in comments 2020-01-06 10:50:26 +00:00
DeadStoreElimination Fix DSE miscompile when store is clobbered across loop iterations 2020-02-27 14:43:01 -08:00
DivRemPairs
EarlyCSE Let EarlyCSE fold equivalent freeze instructions 2020-02-28 20:35:20 +09:00
EliminateAvailableExternally
EntryExitInstrumenter
ExpandMemCmp [ExpandMemCmp] Properly constant-fold all compares. 2020-03-09 10:40:52 +01:00
Float2Int
ForcedFunctionAttrs
FunctionAttrs
FunctionImport Revert "Revert "Reland "[Support] make report_fatal_error abort instead of exit""" 2020-02-13 10:16:06 -08:00
GCOVProfiling Revert "Revert "Reland "[Support] make report_fatal_error abort instead of exit""" 2020-02-13 10:16:06 -08:00
GlobalDCE [WPD/VFE] Always emit vcall_visibility metadata for -fwhole-program-vtables 2020-01-23 11:36:01 -08:00
GlobalMerge
GlobalOpt [Transforms][GlobalSRA] huge array causes long compilation time and huge memory usage. 2020-01-04 16:42:38 +03:00
GlobalSplit [WPD/VFE] Always emit vcall_visibility metadata for -fwhole-program-vtables 2020-01-23 11:36:01 -08:00
GuardWidening
GVN [GVN] Fold equivalent freeze instructions 2020-03-01 07:32:05 +09:00
GVNHoist Migrate function attribute "no-frame-pointer-elim"="false" to "frame-pointer"="none" as cleanups after D56351 2019-12-24 16:27:51 -08:00
GVNSink
HardwareLoops
HotColdSplit [HotColdSplit] Mark entire function cold when entry block is cold 2020-02-17 15:57:50 -08:00
IndirectBrExpand
IndVarSimplify [IndVarSimplify] Extend previous special case for load use instruction to any narrow type loop variant to avoid extra trunc instruction 2020-03-05 16:27:59 -05:00
InferAddressSpaces
InferFunctionAttrs
Inline Devirtualize a call on alloca without waiting for post inline cleanup and next DevirtSCCRepeatedPass iteration. 2020-02-28 09:43:32 -08:00
InstCombine [SimplifyLibcalls] Don't replace locked IO (fgetc/fgets/fputc/fputs/fread/fwrite) with unlocked IO (*_unlocked) 2020-03-10 11:11:58 -07:00
InstMerge
InstNamer
InstSimplify [InstSimplify] Simplify calls with "returned" attribute 2020-03-09 18:53:47 +01:00
InterleavedAccess
Internalize
IPConstantProp [SCCP] Do not mark unknown loads as overdefined. 2020-02-20 22:48:58 +01:00
IRCE [IRCE] Use SCEVExpander to modify loop bound 2020-02-06 12:44:43 +03:00
JumpThreading [JumpThreading] Skip unconditional PredBB when threading jumps through two basic blocks 2020-02-18 11:01:46 -08:00
LCSSA [SSAUpdater] Don't call ValueIsRAUWd upon single use replacement 2020-01-23 15:53:53 +07:00
LICM [LICM] Allow freeze to hoist/sink out of a loop 2020-03-03 12:29:39 +09:00
LoadStoreVectorizer AMDGPU: Don't report 2-byte alignment as fast 2020-02-11 18:35:00 -05:00
LoopDataPrefetch
LoopDeletion
LoopDistribute
LoopFusion [LoopFusion] Move instructions from FC1.GuardBlock to FC0.GuardBlock and 2020-01-30 18:02:22 +00:00
LoopIdiom
LoopInstSimplify
LoopInterchange [DA] Delinearization of fixed-size multi-dimensional arrays 2020-02-27 10:29:01 -05:00
LoopLoadElim
LoopPredication [BasicBlock] fix looping in getPostdominatingDeoptimizeCall 2020-01-17 15:40:02 +03:00
LoopReroll
LoopRotate [Test] Add a regression test for failure introduced by 952ad4701cf0d8da79789f6b83ddaa386c60d535 2020-03-05 16:32:37 +07:00
LoopSimplify [LoopSimplify] Regenerate test checks; NFC 2020-01-11 11:02:24 +01:00
LoopSimplifyCFG
LoopStrengthReduce Migrate function attribute "no-frame-pointer-elim"="false" to "frame-pointer"="none" as cleanups after D56351 2019-12-24 16:27:51 -08:00
LoopTransformWarning
LoopUnroll [InstComine] Forego of one-use check in (X - (X & Y)) --> (X & ~Y) if Y is a constant 2020-03-06 21:39:07 +03:00
LoopUnrollAndJam [llvm] Make new pass manager's OptimizationLevel a class 2020-01-16 09:00:56 -08:00
LoopUnswitch
LoopVectorize [InstComine] Forego of one-use check in (X - (X & Y)) --> (X & ~Y) if Y is a constant 2020-03-06 21:39:07 +03:00
LoopVersioning
LoopVersioningLICM
LowerAtomic
LowerConstantIntrinsics
LowerExpectIntrinsic
LowerGuardIntrinsic
LowerInvoke
LowerMatrixIntrinsics [Matrix] Mark matrix memory intrinsics as argmemonly/write|read mem. 2020-02-04 12:32:45 +00:00
LowerSwitch
LowerTypeTests
LowerWidenableCondition
MakeGuardsExplicit
Mem2Reg
MemCpyOpt [Transform][MemCpyOpt] Add missing DebugLoc to %tmpbitcast 2020-02-28 15:20:51 +00:00
MergeFunc [NewPM] Port MergeFunctions pass 2020-01-14 20:55:41 +01:00
MergeICmps Migrate function attribute "no-frame-pointer-elim"="false" to "frame-pointer"="none" as cleanups after D56351 2019-12-24 16:27:51 -08:00
MetaRenamer
NameAnonGlobals
NaryReassociate
NewGVN Migrate function attribute "no-frame-pointer-elim"="false" to "frame-pointer"="none" as cleanups after D56351 2019-12-24 16:27:51 -08:00
ObjCARC [ObjC][ARC] Don't remove autoreleaseRV/retainRV pairs if the call isn't 2020-03-09 13:21:38 -07:00
OpenMP [OpenMP][Opt] Combine struct ident_t* during deduplication 2020-02-25 14:07:14 -08:00
PartiallyInlineLibCalls
PGOProfile [PGO] Attach appropriate funclet operand bundles to value profiling instrumentation calls 2020-01-24 11:20:53 -08:00
PhaseOrdering [InstComine] Forego of one-use check in (X - (X & Y)) --> (X & ~Y) if Y is a constant 2020-03-06 21:39:07 +03:00
PlaceSafepoints
PreISelIntrinsicLowering
PruneEH
Reassociate Remove BinaryOperator::CreateFNeg 2020-02-27 09:06:03 -08:00
Reg2Mem
RewriteStatepointsForGC [RS4GC] Handle uses of extractelement for conversion from vector to scalar base 2020-03-06 16:28:49 -05:00
SafeStack Migrate function attribute "no-frame-pointer-elim"="false" to "frame-pointer"="none" as cleanups after D56351 2019-12-24 16:27:51 -08:00
SampleProfile Fix test for profile remapper 2020-02-18 17:58:32 -08:00
ScalarizeMaskedMemIntrin/X86
Scalarizer Migrate function attribute "no-frame-pointer-elim"="false" to "frame-pointer"="none" as cleanups after D56351 2019-12-24 16:27:51 -08:00
SCCP [SCCP] Do not mark unknown loads as overdefined. 2020-02-20 22:48:58 +01:00
SeparateConstOffsetFromGEP [SeparateConstOffsetFromGEP] Fix: sext(a) + sext(b) -> sext(a + b) matches add and sub instructions with one another 2020-01-17 12:22:52 -05:00
SimpleLoopUnswitch Revert "[SimpleLoopUnswitch] Fix introduction of UB when hoisted condition may be undef or poison" 2020-02-28 11:10:46 +09:00
SimplifyCFG [SimplifyCFG] Skip merging return blocks if it would break a CallBr. 2020-03-10 14:59:13 +01:00
Sink
SLPVectorizer [SLP] Support vectorizing functions provided by vector libs. 2020-03-10 13:10:50 +00:00
SpeculateAroundPHIs
SpeculativeExecution
SROA SROA: Don't drop atomic load/store alignments (PR45010) 2020-02-28 10:38:40 +01:00
StraightLineStrengthReduce Migrate function attribute "no-frame-pointer-elim"="false" to "frame-pointer"="none" as cleanups after D56351 2019-12-24 16:27:51 -08:00
StripDeadPrototypes
StripSymbols
StructurizeCFG StructurizeCFG: simplify phi nodes when possible 2020-03-05 10:33:15 +05:30
SyntheticCountsPropagation
TailCallElim
ThinLTOBitcodeWriter ThinLTOBitcodeWriter: drop dso_local when a GlobalVariable is converted to a declaration 2020-03-05 18:09:33 -08:00
TypePromotion/ARM
Util Fixed [AssumeBundles] Move to IR so it can be used by Analysis 2020-03-10 18:02:39 +01:00
VectorCombine/X86 [VectorCombine] fold extract-extract-op with different extraction indexes 2020-03-08 09:57:55 -04:00
WholeProgramDevirt [WPD] Provide a way to prevent functions from being devirtualized 2020-03-09 14:05:15 +03:00