Skip to content

Commit d317ea9

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

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"
@@ -2913,10 +2914,14 @@ handleDeclareTargetMapVar(MapInfoData &mapData,
29132914
// reference pointer and the pointer are assigned in the kernel argument
29142915
// structure for the host.
29152916
if (mapData.IsDeclareTarget[i]) {
2916-
2917-
moduleTranslation.getOpenMPBuilder()
2918-
->replaceConstantValueUsesInFuncWithInstr(mapData.OriginalValue[i],
2919-
func);
2917+
// If the original map value is a constant, then we have to make sure all
2918+
// of it's uses within the current kernel/function that we are going to
2919+
// rewrite are converted to instructions, as we will be altering the old
2920+
// use (OriginalValue) from a constant to an instruction, which will be
2921+
// illegal and ICE the compiler if the user is a constant expression of
2922+
// some kind e.g. a constant GEP.
2923+
if (auto *constant = dyn_cast<llvm::Constant>(mapData.OriginalValue[i]))
2924+
convertUsersOfConstantsToInstructions(constant, func, false);
29202925

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

0 commit comments

Comments
 (0)