-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[Flang][Driver] Add a flag to control zero initialization of global v… #122144
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
4835015
[Flang][Driver] Add a flag to control zero initialization of global v…
kiranchandramohan 0887cca
Change name to init-global-zero and add positive flag as well
kiranchandramohan 84dd129
Fix formatting
kiranchandramohan 0d847f3
Switch to BoolOptionWithoutMarshalling
kiranchandramohan 8278bc8
Merge branch 'main' into zero-init
kiranchandramohan 7339f63
Fix formatting
kiranchandramohan acf99f5
Merge branch 'main' into zero-init
kiranchandramohan bf55f86
Merge branch 'main' into zero-init
kiranchandramohan 532eb67
Minor syntax changes
kiranchandramohan aa72dde
Correct help description
kiranchandramohan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,5 @@ | ||
| ! Check that the driver passes through -fno-zero-init-global-without-init: | ||
| ! RUN: %flang -### -S -fno-zero-init-global-without-init %s -o - 2>&1 | FileCheck %s | ||
| ! Check that the compiler accepts -fno-zero-init-global-without-init: | ||
| ! RUN: %flang_fc1 -emit-hlfir -fno-zero-init-global-without-init %s -o - | ||
| ! CHECK: "-fc1"{{.*}}"-fno-zero-init-global-without-init" |
This file contains hidden or 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,16 @@ | ||
| ! RUN: %flang_fc1 -emit-hlfir -o - %s | FileCheck --check-prefix=CHECK-DEFAULT %s | ||
| ! RUN: %flang_fc1 -fno-zero-init-global-without-init -emit-hlfir -o - %s | FileCheck --check-prefix=CHECK-NO-ZERO-INIT %s | ||
|
|
||
| module m1 | ||
| real :: x | ||
| end module m1 | ||
|
|
||
| !CHECK-DEFAULT: fir.global @_QMm1Ex : f32 { | ||
| !CHECK-DEFAULT: %[[UNDEF:.*]] = fir.zero_bits f32 | ||
| !CHECK-DEFAULT: fir.has_value %[[UNDEF]] : f32 | ||
| !CHECK-DEFAULT: } | ||
|
|
||
| !CHECK-NO-ZERO-INIT: fir.global @_QMm1Ex : f32 { | ||
| !CHECK-NO-ZERO-INIT: %[[UNDEF:.*]] = fir.undefined f32 | ||
| !CHECK-NO-ZERO-INIT: fir.has_value %[[UNDEF]] : f32 | ||
| !CHECK-NO-ZERO-INIT: } |
This file contains hidden or 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,18 @@ | ||
| ! RUN: %flang_fc1 -emit-hlfir -o - %s | FileCheck %s | ||
| ! RUN: %flang_fc1 -fno-zero-init-global-without-init -emit-hlfir -o - %s | FileCheck %s | ||
|
|
||
| ! Test that the flag does not affect globals with default init | ||
|
|
||
| module m2 | ||
| type val | ||
| integer :: my_val = 1 | ||
| end type val | ||
| type(val) :: v1 | ||
| end module m2 | ||
|
|
||
| !CHECK: fir.global @_QMm2Ev1 : !fir.type<_QMm2Tval{my_val:i32}> { | ||
| !CHECK: %[[V1:.*]] = fir.undefined !fir.type<_QMm2Tval{my_val:i32}> | ||
| !CHECK: %[[ONE:.*]] = arith.constant 1 : i32 | ||
| !CHECK: %[[V1_INIT:.*]] = fir.insert_value %[[V1]], %[[ONE]], ["my_val", !fir.type<_QMm2Tval{my_val:i32}>] : (!fir.type<_QMm2Tval{my_val:i32}>, i32) -> !fir.type<_QMm2Tval{my_val:i32}> | ||
| !CHECK: fir.has_value %[[V1_INIT]] : !fir.type<_QMm2Tval{my_val:i32}> | ||
| !CHECK: } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.