llvm-project/llvm/lib/CodeGen/SelectionDAG
Hal Finkel 1e5733bbed [InlineAsm] Remove EarlyClobber on registers that are also inputs
When an inline asm call has an output register marked as early-clobber, but
that same register is also an input operand, what should we do? GCC accepts
this, and is documented to accept this for read/write operands saying,
"Furthermore, if the earlyclobber operand is also a read/write operand, then
that operand is written only after it's used." For write-only operands, the
situation seems less clear, but I have at least one existing codebase that
assumes this will work, in part because it has syscall macros like this:

({                                                                         \
  register uint64_t r0 __asm__ ("r0") = (__NR_ ## name);                   \
  register uint64_t r3 __asm__ ("r3") = ((uint64_t) (arg0));               \
  register uint64_t r4 __asm__ ("r4") = ((uint64_t) (arg1));               \
  register uint64_t r5 __asm__ ("r5") = ((uint64_t) (arg2));               \
  __asm__ __volatile__                                                     \
  ("sc"                                                                    \
   : "=&r"(r0),"=&r"(r3),"=&r"(r4),"=&r"(r5)                               \
   :   "0"(r0),  "1"(r3),  "2"(r4),  "3"(r5)                               \
   : "r6","r7","r8","r9","r10","r11","r12","cr0","memory");                \
  r3;                                                                      \
})

Furthermore, with register aliases and subregister relationships that only the
backend knows about, rejecting this in the frontend seems like a difficult
proposition (if we wanted to do so). However, keeping the early-clobber flag on
the INLINEASM MI does not work for us, because it will cause the register's
live interval to end to soon (so it will not appear defined to be used as an
input).

Fortunately, fixing this does not seem hard: When forming the INLINEASM MI,
check to see if any of the early-clobber outputs are also inputs, and if so,
remove the early-clobber flag.

llvm-svn: 235283
2015-04-20 00:01:30 +00:00
..
CMakeLists.txt [Statepoints 3/4] Statepoint infrastructure for garbage collection: SelectionDAGBuilder 2014-12-02 18:50:36 +00:00
DAGCombiner.cpp Add support to promote f16 to f32 2015-04-17 18:36:25 +00:00
FastISel.cpp CodeGen: Stop using DIDescriptor::is*() and auto-casting 2015-04-06 23:27:40 +00:00
FunctionLoweringInfo.cpp Revert r235154-r235156, they cause asserts when building win64 code (http://crbug.com/477988) 2015-04-17 09:10:43 +00:00
InstrEmitter.cpp [InlineAsm] Remove EarlyClobber on registers that are also inputs 2015-04-20 00:01:30 +00:00
InstrEmitter.h Remove the uses of getSubtargetImpl from InstrEmitter and remove 2014-10-09 01:35:29 +00:00
LLVMBuild.txt
LegalizeDAG.cpp [AArch64] Promote f16 operations to f32. 2015-04-10 00:08:48 +00:00
LegalizeFloatTypes.cpp Fix build errors introduced by r235215 2015-04-17 19:51:44 +00:00
LegalizeIntegerTypes.cpp Add support to promote f16 to f32 2015-04-17 18:36:25 +00:00
LegalizeTypes.cpp Add support to promote f16 to f32 2015-04-17 18:36:25 +00:00
LegalizeTypes.h Add support to promote f16 to f32 2015-04-17 18:36:25 +00:00
LegalizeTypesGeneric.cpp Fix build errors introduced by r235215 2015-04-17 19:51:44 +00:00
LegalizeVectorOps.cpp fix typo and 80-col; NFC 2015-03-27 21:45:18 +00:00
LegalizeVectorTypes.cpp Fix build errors introduced by r235215 2015-04-17 19:51:44 +00:00
Makefile
ResourcePriorityQueue.cpp unique_ptrify ResourcePriorityQueue::ResourceModel 2015-03-03 20:49:08 +00:00
SDNodeDbgValue.h constify the getters in SDNodeDbgValue. 2014-10-13 20:43:47 +00:00
ScheduleDAGFast.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
ScheduleDAGRRList.cpp Use 'override/final' instead of 'virtual' for overridden methods 2015-04-11 02:11:45 +00:00
ScheduleDAGSDNodes.cpp Prefer SmallVector::append/insert over push_back loops. 2015-02-17 15:29:18 +00:00
ScheduleDAGSDNodes.h Use 'override/final' instead of 'virtual' for overridden methods 2015-04-11 02:11:45 +00:00
ScheduleDAGVLIW.cpp Use 'override/final' instead of 'virtual' for overridden methods 2015-04-11 02:11:45 +00:00
SelectionDAG.cpp TRUNCATE constant folding - minor fix for rL233224 2015-04-16 08:21:09 +00:00
SelectionDAGBuilder.cpp Revert the switch lowering change (r235101, r235103, r235106) 2015-04-16 15:43:26 +00:00
SelectionDAGBuilder.h Revert the switch lowering change (r235101, r235103, r235106) 2015-04-16 15:43:26 +00:00
SelectionDAGDumper.cpp DebugInfo: Gut DIScope, DIEnumerator and DISubrange 2015-04-16 01:37:00 +00:00
SelectionDAGISel.cpp Revert r235154-r235156, they cause asserts when building win64 code (http://crbug.com/477988) 2015-04-17 09:10:43 +00:00
SelectionDAGPrinter.cpp Revert "Introduce a string_ostream string builder facilty" 2014-06-26 22:52:05 +00:00
StatepointLowering.cpp Reduce dyn_cast<> to isa<> or cast<> where possible. 2015-04-10 11:24:51 +00:00
StatepointLowering.h [Statepoints 3/4] Statepoint infrastructure for garbage collection: SelectionDAGBuilder 2014-12-02 18:50:36 +00:00
TargetLowering.cpp [CodeGen] Report error rather than crash when unable to makeLibCall. 2015-03-26 22:46:58 +00:00
TargetSelectionDAGInfo.cpp Have TargetSelectionDAGInfo take a DataLayout initializer rather than 2014-06-06 19:04:48 +00:00