forked from llvm/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[AsmParser] Add missing globals declarations in incomplete IR mode (l…
…lvm#79855) If `-allow-incomplete-ir` is enabled, automatically insert declarations for missing globals. If a global is only used in calls with the same function type, insert a function declaration with that type. Otherwise, insert a dummy i8 global. The fallback case could be extended with various heuristics (e.g. we could look at load/store types), but I've chosen to keep it simple for now, because I'm unsure to what degree this would really useful without more experience. I expect that in most cases the declaration type doesn't really matter (note that the type of an external global specifies a *minimum* size only, not a precise size). This is a followup to llvm#78421.
- Loading branch information
Showing
2 changed files
with
52 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
; RUN: opt -S -allow-incomplete-ir < %s | FileCheck %s | ||
|
||
; CHECK: @fn2 = external global i8 | ||
; CHECK: @g1 = external global i8 | ||
; CHECK: @g2 = external global i8 | ||
; CHECK: @g3 = external global i8 | ||
|
||
; CHECK: declare void @fn1(i32) | ||
|
||
define ptr @test() { | ||
call void @fn1(i32 0) | ||
call void @fn1(i32 1) | ||
call void @fn2(i32 2) | ||
call void @fn2(i32 2, i32 3) | ||
load i32, ptr @g1 | ||
store i32 0, ptr @g1 | ||
load i32, ptr @g1 | ||
load i64, ptr @g2 | ||
ret ptr @g3 | ||
} |