forked from JuliaLang/julia
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove non-integral pointer from data layout before codegen (JuliaLan…
…g#36705) This allows LLVM codegen passes to insert `inttoptr` and `ptrtoint` as it wish, and avoids hitting any illegal ones in those passes. Fix JuliaLang#36062
- Loading branch information
Showing
4 changed files
with
54 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// This file is a part of Julia. License is MIT: https://julialang.org/license | ||
|
||
#include "llvm-version.h" | ||
|
||
#include <llvm/IR/Module.h> | ||
#include <llvm/IR/LegacyPassManager.h> | ||
#include <llvm/Support/Debug.h> | ||
|
||
#define DEBUG_TYPE "remove_ni" | ||
|
||
using namespace llvm; | ||
|
||
namespace { | ||
|
||
struct RemoveNIPass : public ModulePass { | ||
static char ID; | ||
RemoveNIPass() : ModulePass(ID) {}; | ||
|
||
bool runOnModule(Module &M) | ||
{ | ||
auto dlstr = M.getDataLayoutStr(); | ||
auto nistart = dlstr.find("-ni:"); | ||
if (nistart == std::string::npos) | ||
return false; | ||
auto len = dlstr.size(); | ||
auto niend = nistart + 1; | ||
for (; niend < len; niend++) { | ||
if (dlstr[niend] == '-') { | ||
break; | ||
} | ||
} | ||
dlstr.erase(nistart, niend - nistart); | ||
M.setDataLayout(dlstr); | ||
return true; | ||
} | ||
}; | ||
|
||
char RemoveNIPass::ID = 0; | ||
static RegisterPass<RemoveNIPass> | ||
Y("RemoveNI", | ||
"Remove non-integral address space.", | ||
false, | ||
false); | ||
} | ||
|
||
Pass *createRemoveNIPass() | ||
{ | ||
return new RemoveNIPass(); | ||
} |