Skip to content

Commit

Permalink
Fix handling of GlobalAlias (#84)
Browse files Browse the repository at this point in the history
The rule for GlobalAlias was assuming the type of the alias
matches the type of the aliasee (and both were pointers), but
actually the aliasee is to be a pointer-to-type-of-the-alias.

Adding a test-case that otherwise fails
  • Loading branch information
jcpetruzza authored Oct 15, 2021
1 parent b17ce13 commit 990bb69
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 1 addition & 3 deletions src/LLVM/Pretty.hs
Original file line number Diff line number Diff line change
Expand Up @@ -271,9 +271,7 @@ instance Pretty Global where
kind | isConstant = "constant"
| otherwise = "global"

pretty GlobalAlias {..} = global (pretty name) <+> "=" <+> pretty linkage <+> ppMaybe unnamedAddr <+> "alias" <+> pretty typ `cma` ppTyped aliasee
where
typ = getElementType type'
pretty GlobalAlias {..} = global (pretty name) <+> "=" <+> pretty linkage <+> ppMaybe unnamedAddr <+> "alias" <+> pretty type' `cma` ppTyped aliasee

ppFunctionAttribute :: Either GroupID FunctionAttribute -> Doc ann
ppFunctionAttribute (Left grpId) = pretty grpId
Expand Down
7 changes: 7 additions & 0 deletions tests/input/alias.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
; ModuleID = 'simple module'

define i32 @foo() {
ret i32 42
}

@bar = external alias i32 (), i32 ()* @foo

0 comments on commit 990bb69

Please sign in to comment.