Page MenuHomePhabricator

[AVR] Support aliases in non-zero address space

Authored by aykevl on Mar 14 2020, 11:47 AM.



This fixes code like the following on AVR:

void foo(void) {
void bar(void) __attribute__((alias("foo")));

Code like this is present in compiler-rt, which I'm trying to build.

I'm not sure how to add a test for this, are there any examples I can look at? And does this need a test at all, considering how trivial the change is?

Diff Detail

Event Timeline

aykevl created this revision.Mar 14 2020, 11:47 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 14 2020, 11:47 AM

I think we should add a test, it shouldn't be too hard I think.

Look in clang/tests, grep for alias. Look like it is extern const int __mod_usb_device_table __attribute__ ((alias("wacom_usb_ids")));. If you copy paste a new test (use clang/test/CodeGen/alias.c as a reference. You can also look for files with avr in the name under the test folder to see how to add an AVR-specific test.

You should be able to 1) define a function alias of another function and 2) CHECK that the final IR has address space attributes, even when the alias symbol is used instead of the original symbol.

Nice patch by the way, the code looks fine, if we can get a basic test in here then it's good to go

rjmccall requested changes to this revision.Apr 6 2020, 1:44 PM

I agree this needs a test case.



LGTM. If we ever allow functions to declare an explicit address space, we'll need semantic checks that aliases match up, but that's okay.

This revision now requires changes to proceed.Apr 6 2020, 1:44 PM
aykevl updated this revision to Diff 256977.Apr 13 2020, 8:01 AM
  • added test
  • using getPointerAddressSpace instead of a cast

This is now ready for review.

rjmccall accepted this revision.Apr 13 2020, 10:15 AM


This revision is now accepted and ready to land.Apr 13 2020, 10:15 AM
This revision was automatically updated to reflect the committed changes.