This is an archive of the discontinued LLVM Phabricator instance.

Preserve early clobber flag when using named registers in inline assembly.
ClosedPublic

Authored by dsanders on Feb 2 2015, 7:35 AM.

Details

Summary

Named registers with the constraint "=&r" currently lose the early clobber flag
and turn into "=r" when converted to LLVM-IR. This patch correctly passes it on.

Diff Detail

Event Timeline

dsanders updated this revision to Diff 19153.Feb 2 2015, 7:35 AM
dsanders retitled this revision from to Preserve early clobber flag when using named registers in inline assembly..
dsanders updated this object.
dsanders edited the test plan for this revision. (Show Details)
dsanders added a reviewer: atanasyan.
dsanders added a subscriber: Unknown Object (MLST).
atanasyan accepted this revision.Feb 2 2015, 8:07 AM
atanasyan edited edge metadata.

LGTM

This revision is now accepted and ready to land.Feb 2 2015, 8:07 AM
dsanders planned changes to this revision.Feb 2 2015, 9:39 AM

I found some regressions when I re-tested before committing. It was possible for the early-clobber flag to appear twice.

I'm about to upload a corrected version.

dsanders updated this revision to Diff 19162.Feb 2 2015, 9:41 AM
dsanders edited edge metadata.

Fixed crashes caused by the accidental introduction of constraints like '=&&r'.
Correct test/CodeGen/arm-asm-variable.c to expect the early-clobber flag.

This revision is now accepted and ready to land.Feb 2 2015, 9:41 AM

How did the compiler produce constraints like =&&r in the initial version of this patch? Might the CodeGenFunction::EmitAsmStmt be called twice?

The argument to SimplifyConstraint() would omit the first character (always '=') and the function preserved the '&', giving '&r' as the result of SimplifyConstraint(). Each of the paths of AddVariableConstraints() that returned Constraint unmodified would also preserve the '&'. Then the code I added would prepend '=&' for the early clobber case giving '=&&r'.

Thanks for the clarification.

LGTM

dsanders closed this revision.Feb 4 2015, 6:27 AM