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 1513 - parameter attributes assigned to wrong argument
Summary: parameter attributes assigned to wrong argument
Status: RESOLVED FIXED
Alias: None
Product: tools
Classification: Unclassified
Component: llvm-gcc (show other bugs)
Version: trunk
Hardware: PC Linux
: P normal
Assignee: Chris Lattner
URL:
Keywords: miscompilation
Depends on:
Blocks:
 
Reported: 2007-06-15 10:24 PDT by Rafael Ávila de Espíndola
Modified: 2010-02-22 12:48 PST (History)
2 users (show)

See Also:
Fixed By Commit(s):


Attachments
hack that fixes this particular problem (3.95 KB, patch)
2007-06-18 13:26 PDT, Rafael Ávila de Espíndola
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Rafael Ávila de Espíndola 2007-06-15 10:24:38 PDT
consider the function

struct long s{
long a;
long b;
}

void f(struct s, char *, char);

In x86_64 the struct s is passed in registers, so the llvm type should be

f(i64, i64, i8 *, i8 sext)

The problem is that in TypeConvert::ConvertFunctionType, the Idx is only
incremented by one when passing by the first (C) argument. Because of this the
llvm type generated is invalid:

f(i64, i64, i8 * sext, i8)
Comment 1 Rafael Ávila de Espíndola 2007-06-18 13:26:57 PDT
Created attachment 1019 [details]
hack that fixes this particular problem

The general approach is to make ABIConverter.HandleArgument return the number
of llvm arguments used. I think this is ok, what makes this patch a hack is
that now ABIConverter.HandleArgument always return 1 except in the particular
case that fixes this bug.

I also don't understand why in TypeConverter::ConvertFunctionType the two loops
that walk the argument list cannot be unified in one.
Comment 2 Chris Lattner 2007-06-18 16:53:32 PDT
I'm taking a look.  You're right, the attribute code should be in the abiconverter stuff.  This is a good time 
for me to audit the attribute creation stuff in the front-end.  I'll see if I can merge the loops etc.
Comment 3 Chris Lattner 2007-06-18 19:17:08 PDT
Fixed.  Testcase here: CFrontend/2007-06-18-SextAttrAggregate.c

Patch here:
http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20070618/050591.html

Thanks Rafael!

-Chris