Skip to content
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

New test from #119056 fails on LLVM 18, might be okay? #119193

Closed
durin42 opened this issue Dec 21, 2023 · 1 comment · Fixed by #119201
Closed

New test from #119056 fails on LLVM 18, might be okay? #119193

durin42 opened this issue Dec 21, 2023 · 1 comment · Fixed by #119201
Labels
A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. A-testsuite Area: The testsuite used to check the correctness of rustc

Comments

@durin42
Copy link
Contributor

durin42 commented Dec 21, 2023

The new test from #119056 (tests/codegen/overaligned-constant.rs) is broken on LLVM 18, and I'm having trouble telling if it's actually a problem or just over-constrained output. Sample failure:

tests/codegen/overaligned-constant.rs:20:12: error: CHECK: expected string not found in input
 // CHECK: %b.1 = load i32, ptr getelementptr inbounds ({ i32, i32 }, ptr @0, i32 0, i32 1), align 4
           ^
build/x86_64-unknown-linux-gnu/test/codegen/overaligned-constant/overaligned-constant.ll:140:35: note: scanning from here
 %b.0 = load i32, ptr @0, align 4, !range !6, !noundef !5
                                  ^
build/x86_64-unknown-linux-gnu/test/codegen/overaligned-constant/overaligned-constant.ll:141:2: note: possible intended match here
 %b.1 = load i32, ptr getelementptr inbounds (i8, ptr @0, i64 4), align 4
 ^
full output here ``` Input file: build/x86_64-unknown-linux-gnu/test/codegen/overaligned-constant/overaligned-constant.ll Check file: tests/codegen/overaligned-constant.rs

-dump-input=help explains the following input dump.

Input was:
<<<<<<
.
.
.
40:
41: ; std::rt::lang_start::{{closure}}
42: ; Function Attrs: inlinehint nonlazybind uwtable
43: define internal noundef i32 @"ZN3std2rt10lang_start28$u7b$$u7b$closure$u7d$$u7d$17h509a9dffb4969685E"(ptr noalias noundef readonly align 8 dereferenceable(8) %_1) unnamed_addr #2 {
44: start:
45: %self = alloca i8, align 1
46: call void @llvm.lifetime.start.p0(i64 1, ptr %self)
47: %_4 = load ptr, ptr %_1, align 8, !nonnull !5, !noundef !5
48: ; call std::sys_common::backtrace::__rust_begin_short_backtrace
49: call void @_ZN3std10sys_common9backtrace28__rust_begin_short_backtrace17hbe21c0cb3c3b090eE(ptr noundef nonnull %_4)
50: ; call <() as std::process::Termination>::report
51: %0 = call noundef i8 @"ZN54$LT$$LP$$RP$$u20$as$u20$std..process..Termination$GT$6report17h98723923612101fdE"()
52: store i8 %0, ptr %self, align 1
53: %_6 = load i8, ptr %self, align 1, !noundef !5
54: %_0 = zext i8 %_6 to i32
55: call void @llvm.lifetime.end.p0(i64 1, ptr %self)
56: ret i32 %_0
57: }
58:
59: ; core::ops::function::FnOnce::call_once{{vtable.shim}}
60: ; Function Attrs: inlinehint nonlazybind uwtable
61: define internal noundef i32 @"_ZN4core3ops8function6FnOnce40call_once$u7b$$u7b$vtable.shim$u7d$$u7d$17h33be9ae6ef9d2796E"(ptr noundef %_1) unnamed_addr #2 {
62: start:
63: %_2 = alloca {}, align 1
64: %0 = load ptr, ptr %_1, align 8, !nonnull !5, !noundef !5
65: ; call core::ops::function::FnOnce::call_once
66: %_0 = call noundef i32 @_ZN4core3ops8function6FnOnce9call_once17hadf2b987a2452c12E(ptr noundef nonnull %0)
67: ret i32 %_0
68: }
69:
70: ; core::ops::function::FnOnce::call_once
71: ; Function Attrs: inlinehint nonlazybind uwtable
72: define internal void @_ZN4core3ops8function6FnOnce9call_once17h59a5b54d5316c601E(ptr noundef nonnull %_1) unnamed_addr #2 {
73: start:
74: %_2 = alloca {}, align 1
75: call void %_1()
76: ret void
77: }
78:
79: ; core::ops::function::FnOnce::call_once
80: ; Function Attrs: inlinehint nonlazybind uwtable
81: define internal noundef i32 @_ZN4core3ops8function6FnOnce9call_once17hadf2b987a2452c12E(ptr noundef nonnull %0) unnamed_addr #2 personality ptr @rust_eh_personality {
82: start:
83: %1 = alloca { ptr, i32, [1 x i32] }, align 8
84: %_2 = alloca {}, align 1
85: %_1 = alloca ptr, align 8
86: store ptr %0, ptr %_1, align 8
87: ; invoke std::rt::lang_start::{{closure}}
88: %_0 = invoke noundef i32 @"ZN3std2rt10lang_start28$u7b$$u7b$closure$u7d$$u7d$17h509a9dffb4969685E"(ptr noalias noundef readonly align 8 dereferenceable(8) %_1)
89: to label %bb1 unwind label %cleanup
90:
91: bb3: ; preds = %cleanup
92: %2 = load ptr, ptr %1, align 8, !noundef !5
93: %3 = getelementptr inbounds i8, ptr %1, i64 8
94: %4 = load i32, ptr %3, align 8, !noundef !5
95: call void @llvm.lifetime.end.p0(i64 16, ptr %1)
96: %5 = insertvalue { ptr, i32 } poison, ptr %2, 0
97: %6 = insertvalue { ptr, i32 } %5, i32 %4, 1
98: resume { ptr, i32 } %6
99:
100: cleanup: ; preds = %start
101: %7 = landingpad { ptr, i32 }
102: cleanup
103: %8 = extractvalue { ptr, i32 } %7, 0
104: %9 = extractvalue { ptr, i32 } %7, 1
105: call void @llvm.lifetime.start.p0(i64 16, ptr %1)
106: store ptr %8, ptr %1, align 8
107: %10 = getelementptr inbounds i8, ptr %1, i64 8
108: store i32 %9, ptr %10, align 8
109: br label %bb3
110:
111: bb1: ; preds = %start
112: ret i32 %_0
113: }
114:
115: ; core::ptr::drop_in_place<std::rt::lang_start<()>::{{closure}}>
116: ; Function Attrs: inlinehint nonlazybind uwtable
117: define internal void @"_ZN4core3ptr85drop_in_place$LT$std..rt..lang_start$LT$$LP$$RP$$GT$..$u7b$$u7b$closure$u7d$$u7d$$GT$17h767efc4c10aaa433E"(ptr noalias noundef align 8 dereferenceable(8) %_1) unnamed_addr #2 {
118: start:
119: ret void
120: }
121:
122: ; <() as std::process::Termination>::report
123: ; Function Attrs: inlinehint nonlazybind uwtable
124: define internal noundef i8 @"ZN54$LT$$LP$$RP$$u20$as$u20$std..process..Termination$GT$6report17h98723923612101fdE"() unnamed_addr #2 {
125: start:
126: ret i8 0
127: }
128:
129: ; overaligned_constant::main
130: ; Function Attrs: nonlazybind uwtable
131: define internal void @_ZN20overaligned_constant4main17he5ab63a0a863ce51E() unnamed_addr #1 {
132: start:
133: %_5 = alloca %SmallStruct, align 8
134: %s = alloca i32, align 4
135: call void @llvm.lifetime.start.p0(i64 4, ptr %s)
136: store i32 1, ptr %s, align 4
137: store i32 3, ptr %s, align 4
138: call void @llvm.lifetime.start.p0(i64 32, ptr %_5)
139: call void @llvm.memcpy.p0.p0.i64(ptr align 8 %_5, ptr align 8 @0, i64 32, i1 false)
140: %b.0 = load i32, ptr @0, align 4, !range !6, !noundef !5
check:20'0 X~~~~~~~~~~~~~~~~~~~~~~~ error: no match found
141: %b.1 = load i32, ptr getelementptr inbounds (i8, ptr @0, i64 4), align 4
check:20'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
check:20'1 ? possible intended match
142: %0 = getelementptr inbounds %SmallStruct, ptr %_5, i32 0, i32 1
check:20'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
143: %c.0 = load ptr, ptr %0, align 8, !nonnull !5, !align !7, !noundef !5
check:20'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
144: %1 = getelementptr inbounds i8, ptr %0, i64 8
check:20'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
145: %c.1 = load i64, ptr %1, align 8, !noundef !5
check:20'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
146: call void @llvm.lifetime.end.p0(i64 32, ptr %_5)
check:20'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
147: call void @llvm.lifetime.end.p0(i64 4, ptr %s)
check:20'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
148: ret void
check:20'0 ~~~~~~~~~~
149: }
check:20'0 ~~
150:
check:20'0 ~
151: ; std::rt::lang_start_internal
check:20'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
152: ; Function Attrs: nonlazybind uwtable
check:20'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
153: declare noundef i64 @_ZN3std2rt19lang_start_internal17h5487a73e9bd0fa19E(ptr noundef nonnull align 1, ptr noalias noundef readonly align 8 dereferenceable(24), i64 noundef, ptr noundef, i8 noundef) unnamed_addr #1
check:20'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
154:
check:20'0 ~
155: ; Function Attrs: nonlazybind uwtable
check:20'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
156: declare noundef i32 @rust_eh_personality(i32 noundef, i32 noundef, i64 noundef, ptr noundef, ptr noundef) unnamed_addr #1
check:20'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
157:
check:20'0 ~
158: ; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
check:20'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
159: declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #3
check:20'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
160:
check:20'0 ~
161: ; Function Attrs: nonlazybind
check:20'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
162: define i32 @main(i32 %0, ptr %1) unnamed_addr #4 {
check:20'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
163: top:
check:20'0 ~~~~~
164: %2 = sext i32 %0 to i64
check:20'0 ~~~~~~~~~~~~~~~~~~~~~~~~~
165: ; call std::rt::lang_start
check:20'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~
166: %3 = call i64 @_ZN3std2rt10lang_start17ha9b08249fb3fc026E(ptr @_ZN20overaligned_constant4main17he5ab63a0a863ce51E, i64 %2, ptr %1, i8 0)
check:20'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
167: %4 = trunc i64 %3 to i32
check:20'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~
168: ret i32 %4
check:20'0 ~~~~~~~~~~~~
169: }
check:20'0 ~~
170:
check:20'0 ~
171: ; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
check:20'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
172: declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #5
check:20'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
173:
check:20'0 ~
174: ; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
check:20'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
175: declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #5
check:20'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
176:
check:20'0 ~
177: attributes #0 = { noinline nonlazybind uwtable "probe-stack"="inline-asm" "target-cpu"="x86-64" }
check:20'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
178: attributes #1 = { nonlazybind uwtable "probe-stack"="inline-asm" "target-cpu"="x86-64" }
check:20'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
179: attributes #2 = { inlinehint nonlazybind uwtable "probe-stack"="inline-asm" "target-cpu"="x86-64" }
check:20'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
180: attributes #3 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
check:20'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
181: attributes #4 = { nonlazybind "target-cpu"="x86-64" }
check:20'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
182: attributes #5 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
check:20'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
183:
check:20'0 ~
184: !llvm.module.flags = !{!0, !1, !2}
check:20'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
185: !llvm.ident = !{!3}
check:20'0 ~~~~~~~~~~~~~~~~~~~~
186:
check:20'0 ~
187: !0 = !{i32 8, !"PIC Level", i32 2}
check:20'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
188: !1 = !{i32 7, !"PIE Level", i32 2}
check:20'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
189: !2 = !{i32 2, !"RtLibUseGOT", i32 1}
check:20'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
190: !3 = !{!"rustc version 1.76.0-dev"}
check:20'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
191: !4 = !{i32 1149414}
check:20'0 ~~~~~~~~~~~~~~~~~~~~
192: !5 = !{}
check:20'0 ~~~~~~~~~
193: !6 = !{i32 0, i32 2}
check:20'0 ~~~~~~~~~~~~~~~~~~~~~
194: !7 = !{i64 4}
check:20'0 ~~~~~~~~~~~~~~


</details>

Does that look like it's alright? If I'm reading the test right it seems like the `align 4` is the significant part of the missed `CHECK`, so we're okay? If so, I can try and write a patch to ignore most of the `getelementptr` line there, I guess.
@durin42 durin42 added the A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. label Dec 21, 2023
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Dec 21, 2023
@nikic
Copy link
Contributor

nikic commented Dec 21, 2023

Looks like over-constrained output. A different but equivalent getelementptr is created and replacing it would a wildcard should be fine.

@saethlin saethlin added A-testsuite Area: The testsuite used to check the correctness of rustc and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Dec 21, 2023
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Dec 22, 2023
…rk-Simulacrum

tests: fix overaligned-constant to not over-specify getelementptr instr

On LLVM 18 we get slightly different arguments here, so it's easier to just regex those away. The important details are all still asserted as I understand things.

Fixes rust-lang#119193.

`@rustbot` label: +llvm-main
@bors bors closed this as completed in 58fdbd1 Dec 22, 2023
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Dec 22, 2023
Rollup merge of rust-lang#119201 - durin42:overaligned-constant, r=Mark-Simulacrum

tests: fix overaligned-constant to not over-specify getelementptr instr

On LLVM 18 we get slightly different arguments here, so it's easier to just regex those away. The important details are all still asserted as I understand things.

Fixes rust-lang#119193.

`@rustbot` label: +llvm-main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. A-testsuite Area: The testsuite used to check the correctness of rustc
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants