This is an archive of the discontinued LLVM Phabricator instance.

[IR] Remove support for and/or constant expressions
ClosedPublic

Authored by nikic on Jul 21 2023, 1:53 AM.

Details

Summary

As part of https://discourse.llvm.org/t/rfc-remove-most-constant-expressions/63179, this removes support for and and or constant expressions. Places creating such expressions have been migrated in advance, so this is mostly API removal and test updates.

Diff Detail

Event Timeline

nikic created this revision.Jul 21 2023, 1:53 AM
Herald added a project: Restricted Project. · View Herald Transcript
nikic requested review of this revision.Jul 21 2023, 1:53 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 21 2023, 1:53 AM
nikic planned changes to this revision.Jul 24 2023, 8:34 AM

I plan to include or here as well.

nikic updated this revision to Diff 548214.Aug 8 2023, 7:27 AM
nikic retitled this revision from [IR] Remove support for and constant expressions to [IR] Remove support for and/or constant expressions.
nikic edited the summary of this revision. (Show Details)

Remove both and and or.

nikic updated this revision to Diff 551952.Aug 21 2023, 3:15 AM
nikic edited the summary of this revision. (Show Details)

Rebase after pre-committing most of the test changes. Add missing LangRef update.

reames accepted this revision.Aug 21 2023, 11:07 AM

LGTM.

This revision is now accepted and ready to land.Aug 21 2023, 11:07 AM
This revision was landed with ongoing or failed builds.Aug 22 2023, 12:37 AM
This revision was automatically updated to reflect the committed changes.

This broke cross-language LTO with rust (based on LLVM 16) when e.g. building Firefox. It fails with this error message:

ThinLTO: /builds/worker/workspace/obj-build/x86_64-apple-darwin/release/libgkrust.a(rust_cascade-c3f1dd825cdd83c5.rust_cascade.d5b61b9a28017227-cgu.0.rcgu.o)2898: error: Invalid value reference from metadata
LLVM ERROR: Can't load module, abort.

@glandium Could you please share the relevant bitcode file? We generally can't auto-upgrade constant expressions in metadata (because we can't materialize instructions in that context), but depending on how it is used, we may be able to drop it entirely.

It looks like the instruction in question is:

call void @llvm.dbg.value(metadata i64 or (i64 zext (i32 ptrtoint (ptr @anon.436463c58f189989edb51bc04335cb6d.21 to i32) to i64), i64 shl (i64 zext (i32 trunc (i64 lshr (i64 ptrtoint (ptr @anon.436463c58f189989edb51bc04335cb6d.21 to i64), i64 32) to i32) to i64), i64 32)), metadata !4453, metadata !DIExpression(DW_OP_LLVM_fragment, 64, 64)), !dbg !4493
nikic added a comment.Sep 28 2023, 6:05 AM

@glandium Sorry for the long delay here. I've added support for expanding constant expressions in function metadata in https://github.com/llvm/llvm-project/commit/05b86a8fea23865e4a437efa9cb4f6844ccbf50e, so this should work fine now.

@glandium Sorry for the long delay here. I've added support for expanding constant expressions in function metadata in https://github.com/llvm/llvm-project/commit/05b86a8fea23865e4a437efa9cb4f6844ccbf50e, so this should work fine now.

This either didn't work or wasn't enough. Or something else broke in between. I'll dig deeper and will open an issue.

Yeah, it's happening in a different file, now.

It looks like the instruction in question is:

call void @llvm.dbg.value(metadata i64 or (i64 zext (i32 ptrtoint (ptr @anon.436463c58f189989edb51bc04335cb6d.21 to i32) to i64), i64 shl (i64 zext (i32 trunc (i64 lshr (i64 ptrtoint (ptr @anon.436463c58f189989edb51bc04335cb6d.21 to i64), i64 32) to i32) to i64), i64 32)), metadata !4453, metadata !DIExpression(DW_OP_LLVM_fragment, 64, 64)), !dbg !4493

How did you figure out the exact instruction?

How did you figure out the exact instruction?

I found out on my own.

llvm/lib/IR/Core.cpp