Skip to content

Conversation

@rastogishubham
Copy link
Contributor

In Debug builds, the names of adjusted pointers have a pointer-specific name prefix which doesn't exist in non-debug builds.

This causes differences in output when looking at the output of SROA with a Debug or Release compiler.

For most of our ongoing testing, we use essentially Release+Asserts build (basically release but without NDEBUG defined), however we ship a Release compiler. Therefore we want to say with reasonable confidence that building a large project with Release vs a Release+Asserts build gives us the same output when the same compiler version is used.

This difference however, makes it difficult to prove that the output is the same if the only difference is the name when using LTO builds and looking at bitcode.

Hence this change is being proposed.

In Debug builds, the names of adjusted pointers have a pointer-specific
name prefix which doesn't exist in non-debug builds.

This causes differences in output when looking at the output of SROA
with a Debug or Release compiler.

For most of our ongoing testing, we use essentially Release+Asserts
build (basically release but without NDEBUG defined), however we ship a
Release compiler. Therefore we want to say with reasonable confidence
that building a large project with Release vs a Release+Asserts build
gives us the same output when the same compiler version is used.

This difference however, makes it difficult to prove that the output is
the same if the only difference is the name when using LTO builds and
looking at bitcode.

Hence this change is being proposed.
@rastogishubham
Copy link
Contributor Author

To add to this, I looked at the output of the compile-time tracker and it looks to not increase compile-times by any significant amount

https://llvm-compile-time-tracker.com/compare.php?from=4d772de1526d824ac349de581509171fd02e1be7&to=707b8c29da343a0c9d66d7a4c713b5ae72c21786&stat=instructions:u

@llvmbot
Copy link
Member

llvmbot commented Nov 13, 2025

@llvm/pr-subscribers-llvm-transforms

Author: Shubham Sandeep Rastogi (rastogishubham)

Changes

In Debug builds, the names of adjusted pointers have a pointer-specific name prefix which doesn't exist in non-debug builds.

This causes differences in output when looking at the output of SROA with a Debug or Release compiler.

For most of our ongoing testing, we use essentially Release+Asserts build (basically release but without NDEBUG defined), however we ship a Release compiler. Therefore we want to say with reasonable confidence that building a large project with Release vs a Release+Asserts build gives us the same output when the same compiler version is used.

This difference however, makes it difficult to prove that the output is the same if the only difference is the name when using LTO builds and looking at bitcode.

Hence this change is being proposed.


Full diff: https://github.com/llvm/llvm-project/pull/167917.diff

1 Files Affected:

  • (modified) llvm/lib/Transforms/Scalar/SROA.cpp (+1-9)
diff --git a/llvm/lib/Transforms/Scalar/SROA.cpp b/llvm/lib/Transforms/Scalar/SROA.cpp
index 5c60fad6f91aa..70afe833c9f47 100644
--- a/llvm/lib/Transforms/Scalar/SROA.cpp
+++ b/llvm/lib/Transforms/Scalar/SROA.cpp
@@ -3150,7 +3150,6 @@ class AllocaSliceRewriter : public InstVisitor<AllocaSliceRewriter, bool> {
     assert(IsSplit || BeginOffset == NewBeginOffset);
     uint64_t Offset = NewBeginOffset - NewAllocaBeginOffset;
 
-#ifndef NDEBUG
     StringRef OldName = OldPtr->getName();
     // Skip through the last '.sroa.' component of the name.
     size_t LastSROAPrefix = OldName.rfind(".sroa.");
@@ -3169,17 +3168,10 @@ class AllocaSliceRewriter : public InstVisitor<AllocaSliceRewriter, bool> {
     }
     // Strip any SROA suffixes as well.
     OldName = OldName.substr(0, OldName.find(".sroa_"));
-#endif
 
     return getAdjustedPtr(IRB, DL, &NewAI,
                           APInt(DL.getIndexTypeSizeInBits(PointerTy), Offset),
-                          PointerTy,
-#ifndef NDEBUG
-                          Twine(OldName) + "."
-#else
-                          Twine()
-#endif
-    );
+                          PointerTy, Twine(OldName) + ".");
   }
 
   /// Compute suitable alignment to access this slice of the *new*

@aeubanks
Copy link
Contributor

instruction names don't affect compilation, so the motivation doesn't really make sense

@rastogishubham
Copy link
Contributor Author

rastogishubham commented Nov 18, 2025

@aeubanks Please correct me if I am wrong, if we do an LTO build and the names are different because one LTO build is Release + Asserts without NDEBUG defined, and the other is with a Release compiler (where NDEBUG) would be defined, wouldn't the bitcode be different, because NDEBUG is what causes the names to be different?

@jmagee
Copy link

jmagee commented Nov 20, 2025

This is important for us at Sony because we have tooling that analyzes bitcode to prove equivalence as a means to reduce testing by eliminating redundant test sets across different configurations. The change @rastogishubham is proposing will help eliminate a difference that doesn't seem necessary.

@rastogishubham
Copy link
Contributor Author

@aeubanks just pinging again

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants