Skip to content

Commit 8f001cb

Browse files
committed
[OpenMP][OMPIRBuilder][MLIR] Rebase and replace old constant -> instruction transformation code with newer variation from recently landed PR
1 parent c538cad commit 8f001cb

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2110,11 +2110,6 @@ class OpenMPIRBuilder {
21102110
int32_t UB);
21112111
///}
21122112

2113-
/// Replaces constant values with instruction equivelants where possible
2114-
/// inside of a function.
2115-
static void replaceConstantValueUsesInFuncWithInstr(llvm::Value *Input,
2116-
Function *Func);
2117-
21182113
private:
21192114
// Sets the function attributes expected for the outlined function
21202115
void setOutlinedTargetRegionFunctionAttributes(Function *OutlinedFn);

mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include "llvm/Frontend/OpenMP/OMPIRBuilder.h"
3131
#include "llvm/IR/DebugInfoMetadata.h"
3232
#include "llvm/IR/IRBuilder.h"
33+
#include "llvm/IR/ReplaceConstant.h"
3334
#include "llvm/Support/FileSystem.h"
3435
#include "llvm/TargetParser/Triple.h"
3536
#include "llvm/Transforms/Utils/ModuleUtils.h"
@@ -2862,10 +2863,14 @@ handleDeclareTargetMapVar(MapInfoData &mapData,
28622863
// reference pointer and the pointer are assigned in the kernel argument
28632864
// structure for the host.
28642865
if (mapData.IsDeclareTarget[i]) {
2865-
2866-
moduleTranslation.getOpenMPBuilder()
2867-
->replaceConstantValueUsesInFuncWithInstr(mapData.OriginalValue[i],
2868-
func);
2866+
// If the original map value is a constant, then we have to make sure all
2867+
// of it's uses within the current kernel/function that we are going to
2868+
// rewrite are converted to instructions, as we will be altering the old
2869+
// use (OriginalValue) from a constant to an instruction, which will be
2870+
// illegal and ICE the compiler if the user is a constant expression of
2871+
// some kind e.g. a constant GEP.
2872+
if (auto *constant = dyn_cast<llvm::Constant>(mapData.OriginalValue[i]))
2873+
convertUsersOfConstantsToInstructions(constant, func, false);
28692874

28702875
// The users iterator will get invalidated if we modify an element,
28712876
// so we populate this vector of uses to alter each user on an

0 commit comments

Comments
 (0)