[PATCH] D56130: Extend Module::getOrInsertGlobal to also take the default arguments accepted by the GlobalVariable constructor.
Chandler Carruth via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 28 16:27:23 PST 2018
chandlerc added inline comments.
================
Comment at: llvm/include/llvm/IR/Module.h:411-417
+ /// Note that if optional arguments aren't considered for matching the global.
+ Constant *getOrInsertGlobal(
+ StringRef Name, Type *Ty, bool isConstant = false,
+ GlobalValue::LinkageTypes Linkage = GlobalVariable::ExternalLinkage,
+ Constant *Initializer = nullptr,
+ GlobalValue::ThreadLocalMode TLM = GlobalValue::NotThreadLocal,
+ unsigned AddressSpace = 0, bool isExternallyInitialized = false);
----------------
I was going to suggest a different API that I think also addresses compnerd's comment:
```
Constant *getOrInsertGlobal(StringRef Name, Type *Ty,
function_ref<GlobalVariable *()> NewGlobalCallback);
```
This avoids duplicating all the ways of constructing the global variable and also makes it obvious that they don't participate in the `get` side of the API.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D56130/new/
https://reviews.llvm.org/D56130
More information about the llvm-commits
mailing list