LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 1357 - [inlineasm] earlyclobber modifier is silently ignored
Summary: [inlineasm] earlyclobber modifier is silently ignored
Status: RESOLVED FIXED
Alias: None
Product: libraries
Classification: Unclassified
Component: Common Code Generator Code (show other bugs)
Version: trunk
Hardware: All All
: P normal
Assignee: Chris Lattner
URL:
Keywords: miscompilation
Depends on:
Blocks: 862
  Show dependency tree
 
Reported: 2007-04-25 04:26 PDT by Bill Wendling
Modified: 2010-03-06 13:59 PST (History)
1 user (show)

See Also:
Fixed By Commit(s):


Attachments
.ll Version of the Program (5.29 KB, text/plain)
2007-04-25 04:27 PDT, Bill Wendling
Details
.c Version of the Program that Aborts (2.56 KB, text/plain)
2007-04-25 04:27 PDT, Bill Wendling
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Bill Wendling 2007-04-25 04:26:15 PDT
I've attached the .ll file that aborts when run. It's something to do with the inline assembly thingy.

On the plus side, GMP compiled! :-)
Comment 1 Bill Wendling 2007-04-25 04:27:24 PDT
Created attachment 801 [details]
.ll Version of the Program
Comment 2 Bill Wendling 2007-04-25 04:27:53 PDT
Created attachment 802 [details]
.c Version of the Program that Aborts
Comment 3 Chris Lattner 2007-04-30 11:53:48 PDT
Reduced testcase:

long long test(int A, int B, int C) {
  unsigned X, Y;
  __asm__ ("subf%I3c %1,%4,%3\nsubfze %0,%2"
                 : "=r" (X), "=&r" (Y)
                 : "r" (A), "rI" (B), "r" (C));
  return ((long long)Y << 32) | X;
}

We compile this to:

_test:
        # InlineAsm Start
        subfc r3,r5,r4
        subfze r4,r3
        # InlineAsm End
        stw r3, -4(r1)
        blr 

Note that the first instruction clobbers r3 before the second instruction uses it.

-Chris
Comment 4 Chris Lattner 2007-04-30 16:12:51 PDT
Fixed.  Patch here:
http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20070430/048747.html
There are several other required patches to go along with this though.

Testcase here: CodeGen/PowerPC/2007-04-30-InlineAsmEarlyClobber.ll

-Chris