[PATCH] D76182: [AVR] Support aliases in non-zero address space

Ayke via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sat Mar 14 11:48:01 PDT 2020


aykevl created this revision.
aykevl added reviewers: dylanmckay, rsmith, rjmccall.
Herald added subscribers: cfe-commits, Jim.
Herald added a project: clang.

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?


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D76182

Files:
  clang/lib/CodeGen/CodeGenModule.cpp


Index: clang/lib/CodeGen/CodeGenModule.cpp
===================================================================
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -4547,8 +4547,9 @@
   }
 
   // Create the new alias itself, but don't set a name yet.
+  unsigned AS = cast<llvm::PointerType>(Aliasee->getType())->getAddressSpace();
   auto *GA =
-      llvm::GlobalAlias::create(DeclTy, 0, LT, "", Aliasee, &getModule());
+      llvm::GlobalAlias::create(DeclTy, AS, LT, "", Aliasee, &getModule());
 
   if (Entry) {
     if (GA->getAliasee() == Entry) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D76182.250373.patch
Type: text/x-patch
Size: 585 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200314/74d58f19/attachment-0001.bin>


More information about the cfe-commits mailing list