Christudasan D via llvm-dev
2016-Aug-30 04:51 UTC
[llvm-dev] Suspecting a frontend bug in LLVM compiler
Greetings to all. I am facing a problem with LLVM 3.5 and suspect it is a bug. Here is my observation. I am trying to support a target specific function attribute for a particular target machine. Having followed the steps specified in the compiler documentation, I see the attribute is passed to the backend if we include the attribute in the function definition. But this attribute is not propagate to the backend if I include it only in the function’s prototype/declaration (in the C program). This virtual function (given below) invocation in clang/lib/CodeGen/CodeGenModule.cpp in clang is responsible for attaching the target specific attributes to the backend CodeGen objects (functions, variables etc.) getTargetCodeGenInfo().SetTargetAttributes(D, GO, *this) I found that this virtual function is getting invoked only for function definitions and not for function declarations. Actual requirement: Along with regular C functions we have special functions supported in the target and its definition and invocation will always come in different compilation units. There must be a way to recognize these special functions at the call-sites during codegen in the backend. By attaching some info in the function prototype, we can recognize these special functions at the call-site during backend codegen. That’s why I thought of a new target specific attribute to achieve this purpose. *Is it really a bug?* When I compile a program having function declarations/prototypes with generic attributes like __attribute__((*const*)), clang will add it to that function’s attributelist in the IR and it will be available in the backend. Similarly I expected the target specific attribute should also be added to the attributelist available in the backend and I should be able to identify it using *F.hasFnAttribute("XYZ")*, where XYZ is the new attribute name. Since I work with LLVM 3.5 code-base, I am not sure whether this issue (if it is really a bug) has already been fixed with recent compiler releases. Please write to me. Thanks, Christu -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160830/f340438e/attachment.html>
Christudasan D via llvm-dev
2016-Sep-08 02:17 UTC
[llvm-dev] Suspecting a frontend bug in LLVM compiler
Please give a remark on this. Regards, Christu On Tue, Aug 30, 2016 at 10:21 AM, Christudasan D <xander.cd at gmail.com> wrote:> Greetings to all. > > > > I am facing a problem with LLVM 3.5 and suspect it is a bug. Here is my > observation. > > > > I am trying to support a target specific function attribute for a > particular target machine. > > Having followed the steps specified in the compiler documentation, I see > the attribute is passed to the backend if we include the attribute in the > function definition. But this attribute is not propagate to the backend if > I include it only in the function’s prototype/declaration (in the C > program). > > > > This virtual function (given below) invocation in > clang/lib/CodeGen/CodeGenModule.cpp in clang is responsible for attaching > the target specific attributes to the backend CodeGen objects (functions, > variables etc.) > > getTargetCodeGenInfo().SetTargetAttributes(D, GO, *this) > > > > I found that this virtual function is getting invoked only for function > definitions and not for function declarations. > > > > Actual requirement: > > Along with regular C functions we have special functions supported in the > target and its definition and invocation will always come in different > compilation units. There must be a way to recognize these special functions > at the call-sites during codegen in the backend. By attaching some info in > the function prototype, we can recognize these special functions at the > call-site during backend codegen. That’s why I thought of a new target > specific attribute to achieve this purpose. > > > > *Is it really a bug?* > > When I compile a program having function declarations/prototypes with > generic attributes like __attribute__((*const*)), clang will add it to > that function’s attributelist in the IR and it will be available in the > backend. > > > > Similarly I expected the target specific attribute should also be added to > the attributelist available in the backend and I should be able to identify > it using *F.hasFnAttribute("XYZ")*, where XYZ is the new attribute name. > > > > Since I work with LLVM 3.5 code-base, I am not sure whether this issue (if > it is really a bug) has already been fixed with recent compiler releases. > > Please write to me. > > > > Thanks, > > Christu >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160908/8f87f4df/attachment.html>
Daniel Berlin via llvm-dev
2016-Sep-08 04:43 UTC
[llvm-dev] Suspecting a frontend bug in LLVM compiler
LLVM 3.5 is 2+ years old, and 4 releases old now :) The immediate response would be "try it with a newer version, and see if it works". On Mon, Aug 29, 2016 at 9:51 PM, Christudasan D via llvm-dev < llvm-dev at lists.llvm.org> wrote:> Greetings to all. > > > > I am facing a problem with LLVM 3.5 and suspect it is a bug. Here is my > observation. > > > > I am trying to support a target specific function attribute for a > particular target machine. > > Having followed the steps specified in the compiler documentation, I see > the attribute is passed to the backend if we include the attribute in the > function definition. But this attribute is not propagate to the backend if > I include it only in the function’s prototype/declaration (in the C > program). > > > > This virtual function (given below) invocation in > clang/lib/CodeGen/CodeGenModule.cpp in clang is responsible for attaching > the target specific attributes to the backend CodeGen objects (functions, > variables etc.) > > getTargetCodeGenInfo().SetTargetAttributes(D, GO, *this) > > > > I found that this virtual function is getting invoked only for function > definitions and not for function declarations. > > > > Actual requirement: > > Along with regular C functions we have special functions supported in the > target and its definition and invocation will always come in different > compilation units. There must be a way to recognize these special functions > at the call-sites during codegen in the backend. By attaching some info in > the function prototype, we can recognize these special functions at the > call-site during backend codegen. That’s why I thought of a new target > specific attribute to achieve this purpose. > > > > *Is it really a bug?* > > When I compile a program having function declarations/prototypes with > generic attributes like __attribute__((*const*)), clang will add it to > that function’s attributelist in the IR and it will be available in the > backend. > > > > Similarly I expected the target specific attribute should also be added to > the attributelist available in the backend and I should be able to identify > it using *F.hasFnAttribute("XYZ")*, where XYZ is the new attribute name. > > > > Since I work with LLVM 3.5 code-base, I am not sure whether this issue (if > it is really a bug) has already been fixed with recent compiler releases. > > Please write to me. > > > > Thanks, > > Christu > > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160907/9ff45f03/attachment.html>