[LLVMdev] deglobalizing TargetOptions
clattner at apple.com
Thu Dec 1 17:15:23 PST 2011
On Dec 1, 2011, at 5:09 PM, Nick Lewycky wrote:
> I'm running LLVM under threadsanitizer
> (http://code.google.com/p/data-race-test/) to find and remove races in
> a larger program that uses LLVM as a library. One of the things that I
> found is that the TargetOptions are all global; you could create a
> TargetMachine targeting ARM and X86 in two threads, but they both have
> to share the same FloatABIType setting.
> This is silly, and I plan to fix it by moving all the globals in
> TargetOptions into getters and setters on TargetMachine. This means
> that the TargetMachine object is going to get a bit bigger to
> accommodate, but at least two users of llvm linked into one program
> won't step on each other.
> The existing command-line options will move
> from TargetMachine into llc which will use the same setters. This has
> the side-effect that "clang -mllvm" won't work for them any more.
Instead of adding a bunch of instance variables (+ getters/setters) into TargetMachine, why not make TargetOptions be a class, and have TM contain an instance of it?
More information about the llvm-dev