From 21d8fe40b9906e1ee27af8c4fcfa21bf9e284657 Mon Sep 17 00:00:00 2001 From: TB Schardl Date: Tue, 30 Jul 2024 08:04:27 -0400 Subject: [PATCH] [Outline] Add clarifying comments about constants in helper-function argument lists. --- llvm/lib/Transforms/Tapir/Outline.cpp | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/llvm/lib/Transforms/Tapir/Outline.cpp b/llvm/lib/Transforms/Tapir/Outline.cpp index 65898f8557c5..545aed39abf7 100644 --- a/llvm/lib/Transforms/Tapir/Outline.cpp +++ b/llvm/lib/Transforms/Tapir/Outline.cpp @@ -325,11 +325,18 @@ Function *llvm::CreateHelper( for (Value *I : Inputs) { if (VMap.count(I) == 0) { // Is this argument preserved? DestI->setName(I->getName()+NameSuffix); // Copy the name over... - if (isa(I)) - // Don't add this constant input to the VMap, so it won't get remapped - DestI++; - else - VMap[I] = &*DestI++; // Add mapping to VMap + + // The normal Tapir lowering process should never add a constant to the + // input list for a helper function, because the input list is determined + // by uses within the outlined blocks of SSA values defined outside of + // those outlined blocks. Specific Tapir targets can add constant + // inputs to the list, however. Don't add these constant inputs to the + // VMap, so that other instances of this constant won't get remapped + // to the function argument. + if (!isa(I)) + VMap[I] = &*DestI; // Add mapping to VMap + + DestI++; } // Check for any vector arguments, and record the maximum width of any // vector argument we find. @@ -554,7 +561,13 @@ void llvm::AddAlignmentAssumptions( for (Value *ArgVal : Args) { // Ignore arguments to non-pointer types if (!ArgVal->getType()->isPointerTy()) continue; - // Ignore constant pointer arguments + // Ignore constant pointer arguments. The normal Tapir lowering process + // should never add a constant to the input list for a helper function, + // because the input list is determined by uses within the outlined blocks + // of SSA values defined outside of those outlined blocks. Specific Tapir + // targets can add constant inputs to the list, however. We'll rely on + // the Tapir target to supply appropriate alignment information for this + // pointer argument. if (isa(ArgVal)) continue; Argument *Arg = cast(VMap[ArgVal]); // Ignore arguments to non-pointer types